summaryrefslogtreecommitdiff
path: root/chromium/third_party/sqlite
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2019-02-13 16:23:34 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2019-02-14 10:37:21 +0000
commit38a9a29f4f9436cace7f0e7abf9c586057df8a4e (patch)
treec4e8c458dc595bc0ddb435708fa2229edfd00bd4 /chromium/third_party/sqlite
parente684a3455bcc29a6e3e66a004e352dea4e1141e7 (diff)
downloadqtwebengine-chromium-38a9a29f4f9436cace7f0e7abf9c586057df8a4e.tar.gz
BASELINE: Update Chromium to 73.0.3683.37
Change-Id: I08c9af2948b645f671e5d933aca1f7a90ea372f2 Reviewed-by: Michael Brüning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/third_party/sqlite')
-rw-r--r--chromium/third_party/sqlite/BUILD.gn219
-rw-r--r--chromium/third_party/sqlite/README.chromium113
-rw-r--r--chromium/third_party/sqlite/amalgamation/rename_exports.h528
-rw-r--r--chromium/third_party/sqlite/amalgamation/sqlite3.c5366
-rw-r--r--chromium/third_party/sqlite/amalgamation/sqlite3.h6
-rw-r--r--chromium/third_party/sqlite/fuzz/DEPS1
-rw-r--r--chromium/third_party/sqlite/fuzz/disabled_queries_parser.cc30
-rw-r--r--chromium/third_party/sqlite/fuzz/disabled_queries_parser.h16
-rw-r--r--chromium/third_party/sqlite/fuzz/icu_codes.proto189
-rw-r--r--chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries0bin0 -> 20189 bytes
-rw-r--r--chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries1bin0 -> 5569 bytes
-rw-r--r--chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries10bin0 -> 14720 bytes
-rw-r--r--chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries11bin0 -> 32275 bytes
-rw-r--r--chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries12bin0 -> 36953 bytes
-rw-r--r--chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries13bin0 -> 32246 bytes
-rw-r--r--chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries14bin0 -> 5439 bytes
-rw-r--r--chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries15bin0 -> 34799 bytes
-rw-r--r--chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries16bin0 -> 5647 bytes
-rw-r--r--chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries17bin0 -> 26498 bytes
-rw-r--r--chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries18bin0 -> 18939 bytes
-rw-r--r--chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries19bin0 -> 17233 bytes
-rw-r--r--chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries2bin0 -> 20274 bytes
-rw-r--r--chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries3bin0 -> 18276 bytes
-rw-r--r--chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries4bin0 -> 12855 bytes
-rw-r--r--chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries5bin0 -> 7890 bytes
-rw-r--r--chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries6bin0 -> 28166 bytes
-rw-r--r--chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries7bin0 -> 13183 bytes
-rw-r--r--chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries8bin0 -> 6235 bytes
-rw-r--r--chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries9bin0 -> 3768 bytes
-rw-r--r--chromium/third_party/sqlite/fuzz/sql_expr_fuzzer.cc31
-rw-r--r--chromium/third_party/sqlite/fuzz/sql_fuzzer.cc58
-rw-r--r--chromium/third_party/sqlite/fuzz/sql_generate_corpus.cc969
-rw-r--r--chromium/third_party/sqlite/fuzz/sql_multithreaded_fuzzer.cc91
-rw-r--r--chromium/third_party/sqlite/fuzz/sql_printf_fuzzer.cc31
-rw-r--r--chromium/third_party/sqlite/fuzz/sql_queries.proto23
-rw-r--r--chromium/third_party/sqlite/fuzz/sql_query_grammar.proto1663
-rw-r--r--chromium/third_party/sqlite/fuzz/sql_query_proto_to_string.cc2757
-rw-r--r--chromium/third_party/sqlite/fuzz/sql_query_proto_to_string.h30
-rw-r--r--chromium/third_party/sqlite/fuzz/sql_run_queries.cc172
-rw-r--r--chromium/third_party/sqlite/fuzz/sql_run_queries.h18
-rw-r--r--chromium/third_party/sqlite/fuzz/sql_strftime_fuzzer.cc31
-rw-r--r--chromium/third_party/sqlite/patches/0001-Modify-default-VFS-to-support-WebDatabase.patch2
-rw-r--r--chromium/third_party/sqlite/patches/0001-test-SQLite-tests-compiling-on-Linux.patch120
-rw-r--r--chromium/third_party/sqlite/patches/0002-Modify-default-VFS-to-support-WebDatabase.patch179
-rw-r--r--chromium/third_party/sqlite/patches/0002-Virtual-table-supporting-recovery-of-corrupted-datab.patch2
-rw-r--r--chromium/third_party/sqlite/patches/0003-Custom-shell.c-helpers-to-load-Chromium-s-ICU-data.patch2
-rw-r--r--chromium/third_party/sqlite/patches/0003-Virtual-table-supporting-recovery-of-corrupted-datab.patch3904
-rw-r--r--chromium/third_party/sqlite/patches/0004-Custom-shell.c-helpers-to-load-Chromium-s-ICU-data.patch145
-rw-r--r--chromium/third_party/sqlite/patches/0004-fts3-Disable-fts3_tokenizer-and-fts4.patch2
-rw-r--r--chromium/third_party/sqlite/patches/0005-fts3-Disable-fts3_tokenizer-and-fts4.patch60
-rw-r--r--chromium/third_party/sqlite/patches/0005-fuchsia-Use-dot-file-locking-for-sqlite.patch2
-rw-r--r--chromium/third_party/sqlite/patches/0006-Fix-dbfuzz2-for-Clusterfuzz.patch2
-rw-r--r--chromium/third_party/sqlite/patches/0006-fuchsia-Use-dot-file-locking-for-sqlite.patch27
-rw-r--r--chromium/third_party/sqlite/patches/0007-Allow-auto-vacuum-to-work-with-chunks.patch296
-rw-r--r--chromium/third_party/sqlite/patches/0007-Fix-the-Makefile-so-that-it-honors-CFLAGS-when-build.patch2
-rw-r--r--chromium/third_party/sqlite/patches/0008-Adjustments-to-the-page-cache-to-try-to-avoid-harmle.patch2
-rw-r--r--chromium/third_party/sqlite/patches/0008-fuchsia-Use-dot-file-locking-for-sqlite.patch27
-rw-r--r--chromium/third_party/sqlite/patches/0009-Fix-ossfuzz.c-to-compile-and-run-with-our-config.patch44
-rw-r--r--chromium/third_party/sqlite/patches/0009-Remove-an-ALWAYS-from-a-branch-that-is-not-always-ta.patch2
-rw-r--r--chromium/third_party/sqlite/patches/0010-Backport-Windows-VFS-mmap-fix.patch33
-rw-r--r--chromium/third_party/sqlite/patches/0010-Fix-a-problem-with-nested-CTEs-with-the-same-table.patch2
-rw-r--r--chromium/third_party/sqlite/patches/0011-Fix-detection-of-self-referencing-rows-in-foreign-ke.patch2
-rw-r--r--chromium/third_party/sqlite/patches/0012-Fix-a-segfault-caused-by-using-the-RAISE-function-in.patch2
-rw-r--r--chromium/third_party/sqlite/patches/0013-Fix-for-an-assert-that-could-be-false.patch2
-rw-r--r--chromium/third_party/sqlite/patches/0014-Fix-another-problem-found-by-Matthew-Denton-s-new-fu.patch2
-rw-r--r--chromium/third_party/sqlite/patches/0015-Report-a-new-corruption-case.patch2
-rw-r--r--chromium/third_party/sqlite/patches/0016-Avoid-a-buffer-overread-in-ptrmapPutOvflPtr.patch2
-rw-r--r--chromium/third_party/sqlite/patches/0017-Improved-detection-of-cell-corruption-in-sqlite3Vdbe.patch22
-rw-r--r--chromium/third_party/sqlite/patches/0018-Fix-a-segfault-in-fts3-prompted-by-a-corrupted-datab.patch29
-rw-r--r--chromium/third_party/sqlite/patches/0019-Prevent-integer-overflow-from-leading-to-buffer-over.patch31
-rw-r--r--chromium/third_party/sqlite/patches/0020-Add-extra-tests-for-database-corruption-inside-defra.patch57
-rw-r--r--chromium/third_party/sqlite/patches/0021-Fix-an-off-by-one-error-on-a-Goto-in-the-code-genera.patch29
-rw-r--r--chromium/third_party/sqlite/patches/0022-Fix-overread-on-corrupted-btree-key.patch37
-rw-r--r--chromium/third_party/sqlite/patches/0023-Avoid-buffer-overreads-on-corrupted-database-files.patch31
-rw-r--r--chromium/third_party/sqlite/patches/0024-Fix-integer-overflow-while-running-PRAGMA-integrity_.patch38
-rw-r--r--chromium/third_party/sqlite/patches/0025-Improved-corruption-handling-while-balancing-pages.patch120
-rw-r--r--chromium/third_party/sqlite/patches/0026-Avoid-reading-off-the-front-of-a-page-buffer-when-ba.patch38
-rw-r--r--chromium/third_party/sqlite/patches/0027-Fix-MSAN-error-in-sqlite3VdbeRecordUnpack-on-a-corru.patch34
-rw-r--r--chromium/third_party/sqlite/patches/0028-Fix-deleting-a-B-tree-entry-in-a-corrupt-database.patch27
-rw-r--r--chromium/third_party/sqlite/patches/0029-Fix-sorting-results-with-SRT_EphemTab-and-a-LIMIT-cl.patch42
-rw-r--r--chromium/third_party/sqlite/patches/0030-Fix-detection-of-orphaned-and-malformed-autoindexes.patch40
-rw-r--r--chromium/third_party/sqlite/patches/0031-Fix-potential-buffer-overread.patch41
-rw-r--r--chromium/third_party/sqlite/patches/0032-Fix-handling-negative-number-of-pages-database-field.patch69
-rw-r--r--chromium/third_party/sqlite/patches/0033-Fix-corner-case-in-inserting-null-into-integer-prima.patch42
-rw-r--r--chromium/third_party/sqlite/patches/0034-Fix-insert-infinite-recursion-on-some-corrupted-data.patch30
-rw-r--r--chromium/third_party/sqlite/patches/0035-Fix-null-pointer-dereference-in-sqlite3ExprCompare.patch32
-rw-r--r--chromium/third_party/sqlite/patches/0036-Fix-NEVER-that-is-sometimes-true.patch29
-rw-r--r--chromium/third_party/sqlite/patches/0037-Initialize-extra-bytes-allocated-for-saved-cursor-po.patch28
-rw-r--r--chromium/third_party/sqlite/patches/0038-Fix-leaks-caused-by-circular-references-in-vtable-sh.patch246
-rw-r--r--chromium/third_party/sqlite/patches/0039-Fix-overly-large-malloc-on-btree-corruption.patch28
-rw-r--r--chromium/third_party/sqlite/patches/0040-Fix-null-pointer-access-on-corrupted-index-key.patch44
-rwxr-xr-xchromium/third_party/sqlite/scripts/generate_amalgamation.sh60
-rw-r--r--chromium/third_party/sqlite/src/Makefile.linux-gcc41
-rw-r--r--chromium/third_party/sqlite/src/ext/fts3/fts3.c2
-rw-r--r--chromium/third_party/sqlite/src/ext/fts3/fts3_write.c5
-rw-r--r--chromium/third_party/sqlite/src/ext/fts5/fts5_index.c16
-rw-r--r--chromium/third_party/sqlite/src/ext/fts5/fts5_storage.c5
-rw-r--r--chromium/third_party/sqlite/src/ext/rtree/rtree.c7
-rw-r--r--chromium/third_party/sqlite/src/main.mk2
-rw-r--r--chromium/third_party/sqlite/src/src/btree.c145
-rw-r--r--chromium/third_party/sqlite/src/src/btree.h2
-rw-r--r--chromium/third_party/sqlite/src/src/btreeInt.h1
-rw-r--r--chromium/third_party/sqlite/src/src/build.c50
-rw-r--r--chromium/third_party/sqlite/src/src/expr.c4
-rw-r--r--chromium/third_party/sqlite/src/src/insert.c19
-rw-r--r--chromium/third_party/sqlite/src/src/pcache1.c3
-rw-r--r--chromium/third_party/sqlite/src/src/pragma.c21
-rw-r--r--chromium/third_party/sqlite/src/src/pragma.h164
-rw-r--r--chromium/third_party/sqlite/src/src/prepare.c15
-rw-r--r--chromium/third_party/sqlite/src/src/select.c8
-rw-r--r--chromium/third_party/sqlite/src/src/sqlite.h.in6
-rw-r--r--chromium/third_party/sqlite/src/src/sqliteInt.h1
-rw-r--r--chromium/third_party/sqlite/src/src/trigger.c1
-rw-r--r--chromium/third_party/sqlite/src/src/vdbeaux.c20
-rw-r--r--chromium/third_party/sqlite/src/tool/mkpragmatab.tcl4
115 files changed, 10739 insertions, 8236 deletions
diff --git a/chromium/third_party/sqlite/BUILD.gn b/chromium/third_party/sqlite/BUILD.gn
index 70853a88e15..87d7ed1e71b 100644
--- a/chromium/third_party/sqlite/BUILD.gn
+++ b/chromium/third_party/sqlite/BUILD.gn
@@ -5,6 +5,7 @@
import("//build/config/dcheck_always_on.gni")
import("//build/config/sanitizers/sanitizers.gni")
import("//testing/libfuzzer/fuzzer_test.gni")
+import("//third_party/protobuf/proto_library.gni")
# Compile-time options passed to SQLite.
#
@@ -58,11 +59,6 @@ config("chromium_sqlite3_compile_options") {
# private, so our databases use stricter settings.
"SQLITE_DEFAULT_FILE_PERMISSIONS=0600",
- # SQLite uses a lookaside buffer to improve performance of small mallocs.
- # Chrome already depends on small mallocs being efficient, so we disable
- # this to avoid the extra memory overhead.
- "SQLITE_DEFAULT_LOOKASIDE=0,0",
-
# Needed by the SQL MemoryDumpProvider.
#
# Setting this to 1 is needed to collect the information reported by
@@ -95,6 +91,17 @@ config("chromium_sqlite3_compile_options") {
"SQLITE_OMIT_SHARED_CACHE",
"SQLITE_USE_ALLOCA",
+ # Chrome doesn't use the ANALYZE SQLite extension.
+ #
+ # ANALYZE [1] is non-standard, and currently performs a table scan to
+ # update statistics used by the query planner. Chrome uses straightforward
+ # database schemas which do not require the level of fine tuning provided
+ # by ANALYZE, and we generally cannot afford the I/O cost of the required
+ # table scans.
+ #
+ # [1] https://www.sqlite.org/lang_analyze.html
+ "SQLITE_OMIT_ANALYZE",
+
# Chrome initializes SQLite manually in //sql/connection.cc.
"SQLITE_OMIT_AUTOINIT",
@@ -114,6 +121,13 @@ config("chromium_sqlite3_compile_options") {
# Chrome does not use sqlite3_column_decltype().
"SQLITE_OMIT_DECLTYPE",
+ # EXPLAIN's output is not stable across releases [1], so it should not be
+ # used in Chrome. Skipping the EXPLAIN machinery also results in
+ # non-trivial binary savings.
+ #
+ # [1] https://www.sqlite.org/lang_explain.html
+ "SQLITE_OMIT_EXPLAIN",
+
# Chrome does not use sqlite3_{get,free}_table().
"SQLITE_OMIT_GET_TABLE",
@@ -124,9 +138,23 @@ config("chromium_sqlite3_compile_options") {
# reach extension loading code.
"SQLITE_OMIT_LOAD_EXTENSION",
+ # Chrome already depends on malloc being very efficient, so we disable
+ # SQLite's arena allocator.
+ "SQLITE_DEFAULT_LOOKASIDE=0,0",
+ "SQLITE_OMIT_LOOKASIDE",
+
# Chrome doesn't use TCL variables.
"SQLITE_OMIT_TCL_VARIABLE",
+ # The REINDEX statemnt is only useful if a collation sequence's definition
+ # changes [1]. Chrome never defines its own collation sequences [2, 3], so
+ # it never needs to call REINDEX.
+ #
+ # [1] https://www.sqlite.org/lang_reindex.html
+ # [2] https://www.sqlite.org/datatype3.html#collating_sequences
+ # [3] https://www.sqlite.org/c3ref/create_collation.html
+ "SQLITE_OMIT_REINDEX",
+
# Chrome doesn't use sqlite3_{profile,trace}().
"SQLITE_OMIT_TRACE",
@@ -156,8 +184,8 @@ config("chromium_sqlite3_compile_options") {
}
if (using_sanitizer) {
- # Limit max length of data blobs and queries to 128 MB for fuzzing builds.
defines += [
+ # Limit max length of data blobs and queries to 128 MB for fuzzing builds.
"SQLITE_MAX_LENGTH=128000000",
"SQLITE_MAX_SQL_LENGTH=128000000",
"SQLITE_PRINTF_PRECISION_LIMIT=1280000",
@@ -170,7 +198,17 @@ config("chromium_sqlite3_compile_options") {
# pages, so fuzzer will not crash when reaching the limit.
# Apply this for fuzzing builds only, not for all builds with sanitizers.
if (use_fuzzing_engine) {
- defines += [ "SQLITE_MAX_PAGE_COUNT=16384" ]
+ defines += [
+ "SQLITE_MAX_PAGE_COUNT=16384",
+
+ # Used to deserialize a database from a libfuzzer-provided data blob.
+ # This is to fuzz SQLite's resilience to database corruption.
+ "SQLITE_ENABLE_DESERIALIZE",
+ ]
+
+ # The progress callback is used in fuzzing to cancel long-running queries
+ # so we don't spend too much time on them.
+ defines -= [ "SQLITE_OMIT_PROGRESS_CALLBACK" ]
}
}
@@ -340,7 +378,7 @@ group("sqlite") {
]
}
-if (is_linux || is_mac) {
+if (is_win || is_mac || is_linux) {
executable("sqlite_shell") {
include_dirs = [
# shell.c contains an '#include "sqlite3.h", which we want to be
@@ -359,8 +397,6 @@ if (is_linux || is_mac) {
sources += [ "src/src/shell_icu_linux.c" ]
}
- # TODO(pwnall): Re-enable the shell on Windows when compilation errors are
- # fixed upstream.
if (is_win) {
sources += [ "src/src/shell_icu_win.c" ]
}
@@ -382,6 +418,7 @@ if (is_linux || is_mac) {
}
}
+# Libfuzzer-based fuzzer test from SQLite source tree.
fuzzer_test("sqlite3_ossfuzz_fuzzer") {
include_dirs = [ "." ]
sources = [
@@ -392,3 +429,165 @@ fuzzer_test("sqlite3_ossfuzz_fuzzer") {
]
dict = "fuzz/sql.dict"
}
+
+source_set("sqlite3_lpm_fuzzer_core") {
+ sources = [
+ "fuzz/disabled_queries_parser.cc",
+ "fuzz/disabled_queries_parser.h",
+ "fuzz/sql_run_queries.cc",
+ "fuzz/sql_run_queries.h",
+ ]
+ deps = [
+ ":sqlite",
+ ]
+ public_deps = [
+ ":sqlite3_lpm_fuzzer_input",
+ ]
+ configs += [
+ ":sqlite_warnings",
+ ":chromium_sqlite3_compile_options",
+ ]
+ all_dependent_configs = [
+ ":lpm_fuzzer_omit_non_websql",
+ ":chromium_sqlite3_compile_options",
+ ]
+}
+
+# LPM-based fuzzer test.
+fuzzer_test("sqlite3_lpm_fuzzer") {
+ sources = [
+ "fuzz/sql_fuzzer.cc",
+ "fuzz/sql_query_proto_to_string.cc",
+ "fuzz/sql_query_proto_to_string.h",
+ ]
+ deps = [
+ ":sqlite3_lpm_fuzzer_core",
+ "//third_party/libprotobuf-mutator",
+ ]
+ additional_configs = [ ":sqlite_warnings" ]
+ libfuzzer_options = [
+ "max_len=2111000",
+ "len_control=0",
+ ]
+ seed_corpus = "fuzz/lpm_fuzzer_seed_corpus/"
+}
+
+# FTS3-focused LPM-based fuzzer test.
+fuzzer_test("sqlite3_fts3_lpm_fuzzer") {
+ sources = [
+ "fuzz/sql_fuzzer.cc",
+ "fuzz/sql_query_proto_to_string.cc",
+ "fuzz/sql_query_proto_to_string.h",
+ ]
+ deps = [
+ ":sqlite3_lpm_fuzzer_core",
+ "//third_party/libprotobuf-mutator",
+ ]
+ additional_configs = [
+ ":sqlite_warnings",
+ ":sqlite3_fts3_lpm_fuzzer_config",
+ ]
+ libfuzzer_options = [
+ "max_len=2111000",
+ "len_control=0",
+ ]
+}
+
+fuzzer_test("sqlite3_select_printf_lpm_fuzzer") {
+ sources = [
+ "fuzz/sql_printf_fuzzer.cc",
+ "fuzz/sql_query_proto_to_string.cc",
+ "fuzz/sql_query_proto_to_string.h",
+ ]
+ deps = [
+ ":sqlite3_lpm_fuzzer_core",
+ "//third_party/libprotobuf-mutator",
+ ]
+ libfuzzer_options = [ "max_len=111000" ]
+}
+
+fuzzer_test("sqlite3_select_strftime_lpm_fuzzer") {
+ sources = [
+ "fuzz/sql_query_proto_to_string.cc",
+ "fuzz/sql_query_proto_to_string.h",
+ "fuzz/sql_strftime_fuzzer.cc",
+ ]
+ deps = [
+ ":sqlite3_lpm_fuzzer_core",
+ "//third_party/libprotobuf-mutator",
+ ]
+ libfuzzer_options = [ "max_len=111000" ]
+}
+
+fuzzer_test("sqlite3_select_expr_lpm_fuzzer") {
+ sources = [
+ "fuzz/sql_expr_fuzzer.cc",
+ "fuzz/sql_query_proto_to_string.cc",
+ "fuzz/sql_query_proto_to_string.h",
+ ]
+ deps = [
+ ":sqlite3_lpm_fuzzer_core",
+ "//third_party/libprotobuf-mutator",
+ ]
+ libfuzzer_options = [
+ "max_len=111000",
+ "len_control=0",
+ ]
+}
+
+config("sqlite3_fts3_lpm_fuzzer_config") {
+ defines = [ "FUZZ_FTS3" ]
+}
+
+config("lpm_fuzzer_omit_non_websql") {
+ defines = [
+ "FUZZ_OMIT_SAVEPOINT",
+ "FUZZ_OMIT_PRAGMA",
+ ]
+}
+
+proto_library("sqlite3_lpm_fuzzer_input") {
+ sources = [
+ "fuzz/icu_codes.proto",
+ "fuzz/sql_queries.proto",
+ "fuzz/sql_query_grammar.proto",
+ ]
+}
+
+# Generates a good corpus for the sqlite_lpm_fuzzer
+# Don't build this tool on Windows since it uses a POSIX-only API and because it
+# only needs to be used on devs' machines.
+if (use_fuzzing_engine && !is_win) {
+ executable("sqlite3_lpm_corpus_gen") {
+ sources = [
+ "fuzz/sql_generate_corpus.cc",
+ "fuzz/sql_query_proto_to_string.cc",
+ "fuzz/sql_query_proto_to_string.h",
+ ]
+ deps = [
+ ":sqlite3_lpm_fuzzer_core",
+ "//base",
+ "//third_party/protobuf:protobuf_full",
+ ]
+ }
+}
+
+config("sqlite3_dbfuzz2_config") {
+ cflags = [ "-Wno-sign-compare" ]
+ configs = [ ":sqlite_warnings" ]
+}
+
+# Upstream fuzzer that tests corrupted database files.
+if (use_fuzzing_engine) {
+ fuzzer_test("sqlite3_dbfuzz2_fuzzer") {
+ include_dirs = [ "." ]
+ sources = [
+ "src/test/dbfuzz2.c",
+ ]
+ deps = [
+ ":sqlite",
+ ]
+ additional_configs = [ ":sqlite3_dbfuzz2_config" ]
+ seed_corpus = "fuzz/db_corpus"
+ }
+}
diff --git a/chromium/third_party/sqlite/README.chromium b/chromium/third_party/sqlite/README.chromium
index 420e7ca2956..8dd9ab13bbc 100644
--- a/chromium/third_party/sqlite/README.chromium
+++ b/chromium/third_party/sqlite/README.chromium
@@ -66,53 +66,61 @@ following is written like a shell script to allow copy/paste to a shell, ignore
comments and change the obvious lines. These instructions should work on Linux
or OSX. They may assume a modern version of git (I'm using 2.2.1).
-# Everything based in sqlite subdir.
+# The steps below are easier if done in the SQLite directory.
cd third_party/sqlite
-BASE=3080704
+# Must match the version in //third_party/sqlite/sqlite-src-xxxxxxx.
+# This is SQLite's version number, and uses upstream's convention.
+export BASE=3250300
+export GNU_SED=sed # OSX: "brew install gnu-sed", then use "gsed" here.
#### Create a reference branch.
-git checkout -b sqlite_${BASE} master
+git new-branch sqlite-base
git rm -rf src
-rm -rf src # In case there are things git doesn't know in there.
-cp -a sqlite-src-${BASE} src
-# -f includes ignored files, of which there are a couple.
-git add -f src/
-git commit -m "Reset to sqlite-src-${BASE}"
-# This branch is unlikely to build.
+cp -r sqlite-src-${BASE}/ src
+# Clean up trailing whitespace and CRLF so any patches look clean.
+find src/ -type f -not -iname "*.db" -not -iname "*.eps" -not -iname "*.ico" \
+ -not -iname "*.jpg" -not -iname "*.pfx" -not -iname "*.png" \
+ -not -iname "*.tiff" -not -iname "*.vsix" \
+ -exec $GNU_SED --in-place 's/[[:space:]]\+$//' {} \+
+git add src/
+git clean -i -d -x src # Make sure no file is git-ignored.
+git commit -m "Squash: Reset SQLite src/ to sqlite-src-${BASE}."
+# This branch will not build. It will be used for rebasing, then deleted.
#### Create a reference branch with patches applied.
-git checkout -b sqlite_${BASE}_patched master
-git rebase sqlite_${BASE}
-git am --keep-non-patch patches/*.patch
-git diff master
-# This branch should be identical to master, unless someone forgot to export
-# their changes into a patch. If so, do that as a separate CL and start over.
-
-#### Cherry-pick your change.
-git cherry-pick <your change>
-# This branch should be identical to your development branch, except
-# amalgamation.
+git new-branch --upstream-current sqlite-dev
+git am --keep-non-patch --ignore-space-change patches/*.patch
+git diff origin/master src/
+# This branch should be identical to master.
-# Rebuild the patch set.
-git rm patches/*
-git format-patch --output-directory=patches sqlite_${BASE}..HEAD
-git add patches/*.patch
-git commit -m "Rebuild patches for sqlite_${BASE}"
-# Re-generate the amalgamation.
+#### Develop and validate the change, or cherry-pick it from a dev branch.
+# The goal is to have a set of reasonably-independent CLs which can be
+# understood separately, so that future importers can sensibly determine how to
+# handle conflicts. So use git-rebase and slipstream fixups back into existing
+# patches, or add a new patch.
./scripts/generate_amalgamation.sh
-git commit -m './scripts/generate_amalgamation.sh' amalgamation/
-# At this point everything should build and work.
-
-# Do a squash upload. This should add your single patch to patches/, and apply
-# the changes your patch represents to src/ and amalgamation/. Other patches
-# will have hash changes. A sensible check-in comment would be something like
-# the patch's checkin comment, plus "regenerate amalgamation and generate patch
-# file."
-# TODO(pwnall): Should hash changes be checked in, or backed out?
+git cl format amalgamation/rename_exports.h
+cd ../..
+ninja -C out/Default
+# Check that extract_sqlite_api.py added chrome_ to all exported symbols.
+# Only "_fini" and "_init" should be unprefixed.
+nm -B out/Default/libchromium_sqlite3.so | cut -c 18- | sort | grep '^T'
+out/Default/sql_unittests
+third_party/blink/tools/run_web_tests.py -t Default storage/websql/*
+cd third_party/sqlite
-# Find unsuspecting victim and send review.
+#### Create the review.
+# Rebuild the patch set.
+git rm patches/*
+git format-patch --output-directory=patches --zero-commit \
+ sqlite-base..sqlite-dev
+git add amalgamation/
+git add patches/*.patch
+git commit -m "Squash: regenerate amalgamation and patches."
+git branch --set-upstream-to=origin/master
+git cl upload --squash
---
@@ -178,7 +186,7 @@ git commit -m "Squash: Reset SQLite src/ to sqlite-src-${OLD}."
#### Create a branch for our old SQLite code, with patches mapped to commits.
git new-branch --upstream-current sqlite-old
git am --keep-non-patch --ignore-space-change patches/*.patch
-git diff --ignore-space-change origin/master src/
+git diff origin/master src/
# This branch should be identical to master.
#### Create a branch for the new SQLite release's upstream version.
@@ -210,6 +218,14 @@ git new-branch --upstream-current sqlite-new-cl
./scripts/generate_amalgamation.sh
git cl format amalgamation/rename_exports.h
+#### Copy any new entries to the seed-corpus for dbfuzz2.
+# We use a set of seed databases for fuzzing SQLite's resilience to database
+# corruption. Sometimes, new seed databases are added upstream.
+# Find any files of the pattern src/test/dbfuzz2-seed*.db, and copy them to
+# the fuzz/db_corpus directory.
+cp --no-clobber third_party/sqlite/src/test/dbfuzz2-seed*.db \
+ third_party/sqlite/fuzz/db_corpus
+
#### Validate the upgrade.
# The goal is to have a set of reasonably-independent CLs which can be
# understood separately, so that future importers can sensibly determine how to
@@ -227,8 +243,8 @@ cd third_party/sqlite
#### Create the review.
# Rebuild the patch set.
git rm patches/*
-git format-patch --output-directory=patches --ignore-space-change \
- --zero-commit sqlite-new-base..sqlite-new
+git format-patch --output-directory=patches --zero-commit \
+ sqlite-new-base..sqlite-new
git add amalgamation/
git add patches/*.patch
git commit -m "Squash: regenerate amalgamation and patches."
@@ -261,17 +277,14 @@ TODO(pwnall): This hasn't been tried out for at least a year.
Prerequisites: The test suite requires tcl-dev and libicu-dev. Install those on
Ubuntu like:
sudo apt-get install tcl8.6-dev libicu-dev
-On OSX, I use MacPorts:
- sudo port install tcl
-
-cd third_party/sqlite/src
-mkdir build
-cd build
-# This sometimes gives integer-size warnings on the differences between
-# Tcl_WideInt and sqlite3_int64 and int64. Usually this is easily fixed by
-# changing a variable to Tcl_WideInt.
-make -j -f ../Makefile.linux-gcc testfixture sqlite3 sqlite3_analyzer sqldiff
-make -f ../Makefile.linux-gcc test > /tmp/test.log
+On macOS, I use Homebrew:
+ brew install icu4c tcl-tk
+ export PATH="$(brew --prefix icu4c)/bin:$(brew --prefix tcl-tk)/bin:$PATH"
+
+Run the commands in scripts/generate_amalgamation.sh, but replace the "make"
+command with "make test".
+
+make test > /tmp/test.log
egrep 'errors out of' /tmp/test.log
# Show broken tests:
egrep 'Failures on these tests:' /tmp/test.log
diff --git a/chromium/third_party/sqlite/amalgamation/rename_exports.h b/chromium/third_party/sqlite/amalgamation/rename_exports.h
index 84e9f331790..22e7fb57494 100644
--- a/chromium/third_party/sqlite/amalgamation/rename_exports.h
+++ b/chromium/third_party/sqlite/amalgamation/rename_exports.h
@@ -7,390 +7,390 @@
#ifndef THIRD_PARTY_SQLITE_AMALGAMATION_RENAME_EXPORTS_H_
#define THIRD_PARTY_SQLITE_AMALGAMATION_RENAME_EXPORTS_H_
-#define sqlite3_activate_cerod chrome_sqlite3_activate_cerod // Lines 5566-5568
-#define sqlite3_activate_see chrome_sqlite3_activate_see // Lines 5556-5558
-#define sqlite3_aggregate_context chrome_sqlite3_aggregate_context // Line 5103
-#define sqlite3_aggregate_count chrome_sqlite3_aggregate_count // Line 4886
-#define sqlite3_auto_extension chrome_sqlite3_auto_extension // Line 6232
-#define sqlite3_backup_finish chrome_sqlite3_backup_finish // Line 8227
-#define sqlite3_backup_init chrome_sqlite3_backup_init // Lines 8220-8225
-#define sqlite3_backup_pagecount chrome_sqlite3_backup_pagecount // Line 8229
-#define sqlite3_backup_remaining chrome_sqlite3_backup_remaining // Line 8228
-#define sqlite3_backup_step chrome_sqlite3_backup_step // Line 8226
-#define sqlite3_bind_blob chrome_sqlite3_bind_blob // Line 4061
-#define sqlite3_bind_blob64 chrome_sqlite3_bind_blob64 // Lines 4062-4063
-#define sqlite3_bind_double chrome_sqlite3_bind_double // Line 4064
-#define sqlite3_bind_int chrome_sqlite3_bind_int // Line 4065
-#define sqlite3_bind_int64 chrome_sqlite3_bind_int64 // Line 4066
-#define sqlite3_bind_null chrome_sqlite3_bind_null // Line 4067
+#define sqlite3_activate_cerod chrome_sqlite3_activate_cerod // Lines 5572-5574
+#define sqlite3_activate_see chrome_sqlite3_activate_see // Lines 5562-5564
+#define sqlite3_aggregate_context chrome_sqlite3_aggregate_context // Line 5109
+#define sqlite3_aggregate_count chrome_sqlite3_aggregate_count // Line 4892
+#define sqlite3_auto_extension chrome_sqlite3_auto_extension // Line 6238
+#define sqlite3_backup_finish chrome_sqlite3_backup_finish // Line 8233
+#define sqlite3_backup_init chrome_sqlite3_backup_init // Lines 8226-8231
+#define sqlite3_backup_pagecount chrome_sqlite3_backup_pagecount // Line 8235
+#define sqlite3_backup_remaining chrome_sqlite3_backup_remaining // Line 8234
+#define sqlite3_backup_step chrome_sqlite3_backup_step // Line 8232
+#define sqlite3_bind_blob chrome_sqlite3_bind_blob // Line 4067
+#define sqlite3_bind_blob64 chrome_sqlite3_bind_blob64 // Lines 4068-4069
+#define sqlite3_bind_double chrome_sqlite3_bind_double // Line 4070
+#define sqlite3_bind_int chrome_sqlite3_bind_int // Line 4071
+#define sqlite3_bind_int64 chrome_sqlite3_bind_int64 // Line 4072
+#define sqlite3_bind_null chrome_sqlite3_bind_null // Line 4073
#define sqlite3_bind_parameter_count \
- chrome_sqlite3_bind_parameter_count // Line 4096
+ chrome_sqlite3_bind_parameter_count // Line 4102
#define sqlite3_bind_parameter_index \
- chrome_sqlite3_bind_parameter_index // Line 4142
+ chrome_sqlite3_bind_parameter_index // Line 4148
#define sqlite3_bind_parameter_name \
- chrome_sqlite3_bind_parameter_name // Line 4124
-#define sqlite3_bind_pointer chrome_sqlite3_bind_pointer // Line 4073
-#define sqlite3_bind_text chrome_sqlite3_bind_text // Line 4068
-#define sqlite3_bind_text16 chrome_sqlite3_bind_text16 // Line 4069
-#define sqlite3_bind_text64 chrome_sqlite3_bind_text64 // Lines 4070-4071
-#define sqlite3_bind_value chrome_sqlite3_bind_value // Line 4072
-#define sqlite3_bind_zeroblob chrome_sqlite3_bind_zeroblob // Line 4074
-#define sqlite3_bind_zeroblob64 chrome_sqlite3_bind_zeroblob64 // Line 4075
-#define sqlite3_blob_bytes chrome_sqlite3_blob_bytes // Line 6781
-#define sqlite3_blob_close chrome_sqlite3_blob_close // Line 6765
-#define sqlite3_blob_open chrome_sqlite3_blob_open // Lines 6709-6717
-#define sqlite3_blob_read chrome_sqlite3_blob_read // Line 6810
-#define sqlite3_blob_reopen chrome_sqlite3_blob_reopen // Line 6742
-#define sqlite3_blob_write chrome_sqlite3_blob_write // Line 6852
+ chrome_sqlite3_bind_parameter_name // Line 4130
+#define sqlite3_bind_pointer chrome_sqlite3_bind_pointer // Line 4079
+#define sqlite3_bind_text chrome_sqlite3_bind_text // Line 4074
+#define sqlite3_bind_text16 chrome_sqlite3_bind_text16 // Line 4075
+#define sqlite3_bind_text64 chrome_sqlite3_bind_text64 // Lines 4076-4077
+#define sqlite3_bind_value chrome_sqlite3_bind_value // Line 4078
+#define sqlite3_bind_zeroblob chrome_sqlite3_bind_zeroblob // Line 4080
+#define sqlite3_bind_zeroblob64 chrome_sqlite3_bind_zeroblob64 // Line 4081
+#define sqlite3_blob_bytes chrome_sqlite3_blob_bytes // Line 6787
+#define sqlite3_blob_close chrome_sqlite3_blob_close // Line 6771
+#define sqlite3_blob_open chrome_sqlite3_blob_open // Lines 6715-6723
+#define sqlite3_blob_read chrome_sqlite3_blob_read // Line 6816
+#define sqlite3_blob_reopen chrome_sqlite3_blob_reopen // Line 6748
+#define sqlite3_blob_write chrome_sqlite3_blob_write // Line 6858
#define sqlite3_busy_handler chrome_sqlite3_busy_handler // Line 2504
#define sqlite3_busy_timeout chrome_sqlite3_busy_timeout // Line 2527
#define sqlite3_cancel_auto_extension \
- chrome_sqlite3_cancel_auto_extension // Line 6244
+ chrome_sqlite3_cancel_auto_extension // Line 6250
#define sqlite3_changes chrome_sqlite3_changes // Line 2333
-#define sqlite3_clear_bindings chrome_sqlite3_clear_bindings // Line 4152
+#define sqlite3_clear_bindings chrome_sqlite3_clear_bindings // Line 4158
#define sqlite3_close chrome_sqlite3_close // Line 331
#define sqlite3_close_v2 chrome_sqlite3_close_v2 // Line 332
#define sqlite3_collation_needed \
- chrome_sqlite3_collation_needed // Lines 5505-5509
+ chrome_sqlite3_collation_needed // Lines 5511-5515
#define sqlite3_collation_needed16 \
- chrome_sqlite3_collation_needed16 // Lines 5510-5514
-#define sqlite3_column_blob chrome_sqlite3_column_blob // Line 4632
-#define sqlite3_column_bytes chrome_sqlite3_column_bytes // Line 4639
-#define sqlite3_column_bytes16 chrome_sqlite3_column_bytes16 // Line 4640
-#define sqlite3_column_count chrome_sqlite3_column_count // Line 4168
+ chrome_sqlite3_collation_needed16 // Lines 5516-5520
+#define sqlite3_column_blob chrome_sqlite3_column_blob // Line 4638
+#define sqlite3_column_bytes chrome_sqlite3_column_bytes // Line 4645
+#define sqlite3_column_bytes16 chrome_sqlite3_column_bytes16 // Line 4646
+#define sqlite3_column_count chrome_sqlite3_column_count // Line 4174
#define sqlite3_column_database_name \
- chrome_sqlite3_column_database_name // Line 4246
+ chrome_sqlite3_column_database_name // Line 4252
#define sqlite3_column_database_name16 \
- chrome_sqlite3_column_database_name16 // Line 4247
-#define sqlite3_column_decltype chrome_sqlite3_column_decltype // Line 4283
-#define sqlite3_column_decltype16 chrome_sqlite3_column_decltype16 // Line 4284
-#define sqlite3_column_double chrome_sqlite3_column_double // Line 4633
-#define sqlite3_column_int chrome_sqlite3_column_int // Line 4634
-#define sqlite3_column_int64 chrome_sqlite3_column_int64 // Line 4635
-#define sqlite3_column_name chrome_sqlite3_column_name // Line 4197
-#define sqlite3_column_name16 chrome_sqlite3_column_name16 // Line 4198
+ chrome_sqlite3_column_database_name16 // Line 4253
+#define sqlite3_column_decltype chrome_sqlite3_column_decltype // Line 4289
+#define sqlite3_column_decltype16 chrome_sqlite3_column_decltype16 // Line 4290
+#define sqlite3_column_double chrome_sqlite3_column_double // Line 4639
+#define sqlite3_column_int chrome_sqlite3_column_int // Line 4640
+#define sqlite3_column_int64 chrome_sqlite3_column_int64 // Line 4641
+#define sqlite3_column_name chrome_sqlite3_column_name // Line 4203
+#define sqlite3_column_name16 chrome_sqlite3_column_name16 // Line 4204
#define sqlite3_column_origin_name \
- chrome_sqlite3_column_origin_name // Line 4250
+ chrome_sqlite3_column_origin_name // Line 4256
#define sqlite3_column_origin_name16 \
- chrome_sqlite3_column_origin_name16 // Line 4251
-#define sqlite3_column_table_name chrome_sqlite3_column_table_name // Line 4248
+ chrome_sqlite3_column_origin_name16 // Line 4257
+#define sqlite3_column_table_name chrome_sqlite3_column_table_name // Line 4254
#define sqlite3_column_table_name16 \
- chrome_sqlite3_column_table_name16 // Line 4249
-#define sqlite3_column_text chrome_sqlite3_column_text // Line 4636
-#define sqlite3_column_text16 chrome_sqlite3_column_text16 // Line 4637
-#define sqlite3_column_type chrome_sqlite3_column_type // Line 4641
-#define sqlite3_column_value chrome_sqlite3_column_value // Line 4638
-#define sqlite3_commit_hook chrome_sqlite3_commit_hook // Line 5847
+ chrome_sqlite3_column_table_name16 // Line 4255
+#define sqlite3_column_text chrome_sqlite3_column_text // Line 4642
+#define sqlite3_column_text16 chrome_sqlite3_column_text16 // Line 4643
+#define sqlite3_column_type chrome_sqlite3_column_type // Line 4647
+#define sqlite3_column_value chrome_sqlite3_column_value // Line 4644
+#define sqlite3_commit_hook chrome_sqlite3_commit_hook // Line 5853
#define sqlite3_compileoption_get chrome_sqlite3_compileoption_get // Line 191
#define sqlite3_compileoption_used \
chrome_sqlite3_compileoption_used // Line 190
#define sqlite3_complete chrome_sqlite3_complete // Line 2442
#define sqlite3_complete16 chrome_sqlite3_complete16 // Line 2443
#define sqlite3_config chrome_sqlite3_config // Line 1540
-#define sqlite3_context_db_handle chrome_sqlite3_context_db_handle // Line 5130
+#define sqlite3_context_db_handle chrome_sqlite3_context_db_handle // Line 5136
#define sqlite3_create_collation \
- chrome_sqlite3_create_collation // Lines 5455-5461
+ chrome_sqlite3_create_collation // Lines 5461-5467
#define sqlite3_create_collation16 \
- chrome_sqlite3_create_collation16 // Lines 5470-5476
+ chrome_sqlite3_create_collation16 // Lines 5476-5482
#define sqlite3_create_collation_v2 \
- chrome_sqlite3_create_collation_v2 // Lines 5462-5469
+ chrome_sqlite3_create_collation_v2 // Lines 5468-5475
#define sqlite3_create_function \
- chrome_sqlite3_create_function // Lines 4808-4817
+ chrome_sqlite3_create_function // Lines 4814-4823
#define sqlite3_create_function16 \
- chrome_sqlite3_create_function16 // Lines 4818-4827
+ chrome_sqlite3_create_function16 // Lines 4824-4833
#define sqlite3_create_function_v2 \
- chrome_sqlite3_create_function_v2 // Lines 4828-4838
-#define sqlite3_create_module chrome_sqlite3_create_module // Lines 6512-6517
+ chrome_sqlite3_create_function_v2 // Lines 4834-4844
+#define sqlite3_create_module chrome_sqlite3_create_module // Lines 6518-6523
#define sqlite3_create_module_v2 \
- chrome_sqlite3_create_module_v2 // Lines 6518-6524
+ chrome_sqlite3_create_module_v2 // Lines 6524-6530
#define sqlite3_create_window_function \
- chrome_sqlite3_create_window_function // Lines 4839-4850
-#define sqlite3_data_count chrome_sqlite3_data_count // Line 4389
-#define sqlite3_data_directory chrome_sqlite3_data_directory // Line 5683
-#define sqlite3_db_cacheflush chrome_sqlite3_db_cacheflush // Line 8912
+ chrome_sqlite3_create_window_function // Lines 4845-4856
+#define sqlite3_data_count chrome_sqlite3_data_count // Line 4395
+#define sqlite3_data_directory chrome_sqlite3_data_directory // Line 5689
+#define sqlite3_db_cacheflush chrome_sqlite3_db_cacheflush // Line 8918
#define sqlite3_db_config chrome_sqlite3_db_config // Line 1559
-#define sqlite3_db_filename chrome_sqlite3_db_filename // Line 5772
-#define sqlite3_db_handle chrome_sqlite3_db_handle // Line 5755
-#define sqlite3_db_mutex chrome_sqlite3_db_mutex // Line 7156
-#define sqlite3_db_readonly chrome_sqlite3_db_readonly // Line 5782
-#define sqlite3_db_release_memory chrome_sqlite3_db_release_memory // Line 5970
-#define sqlite3_db_status chrome_sqlite3_db_status // Line 7577
-#define sqlite3_declare_vtab chrome_sqlite3_declare_vtab // Line 6581
-#define sqlite3_deserialize chrome_sqlite3_deserialize // Lines 9306-9313
+#define sqlite3_db_filename chrome_sqlite3_db_filename // Line 5778
+#define sqlite3_db_handle chrome_sqlite3_db_handle // Line 5761
+#define sqlite3_db_mutex chrome_sqlite3_db_mutex // Line 7162
+#define sqlite3_db_readonly chrome_sqlite3_db_readonly // Line 5788
+#define sqlite3_db_release_memory chrome_sqlite3_db_release_memory // Line 5976
+#define sqlite3_db_status chrome_sqlite3_db_status // Line 7583
+#define sqlite3_declare_vtab chrome_sqlite3_declare_vtab // Line 6587
+#define sqlite3_deserialize chrome_sqlite3_deserialize // Lines 9312-9319
#define sqlite3_enable_load_extension \
- chrome_sqlite3_enable_load_extension // Line 6194
+ chrome_sqlite3_enable_load_extension // Line 6200
#define sqlite3_enable_shared_cache \
- chrome_sqlite3_enable_shared_cache // Line 5940
+ chrome_sqlite3_enable_shared_cache // Line 5946
#define sqlite3_errcode chrome_sqlite3_errcode // Line 3468
#define sqlite3_errmsg chrome_sqlite3_errmsg // Line 3470
#define sqlite3_errmsg16 chrome_sqlite3_errmsg16 // Line 3471
#define sqlite3_errstr chrome_sqlite3_errstr // Line 3472
#define sqlite3_exec chrome_sqlite3_exec // Lines 403-409
-#define sqlite3_expanded_sql chrome_sqlite3_expanded_sql // Line 3829
-#define sqlite3_expired chrome_sqlite3_expired // Line 4887
+#define sqlite3_expanded_sql chrome_sqlite3_expanded_sql // Line 3835
+#define sqlite3_expired chrome_sqlite3_expired // Line 4893
#define sqlite3_extended_errcode chrome_sqlite3_extended_errcode // Line 3469
#define sqlite3_extended_result_codes \
chrome_sqlite3_extended_result_codes // Line 2203
-#define sqlite3_file_control chrome_sqlite3_file_control // Line 7199
-#define sqlite3_finalize chrome_sqlite3_finalize // Line 4669
+#define sqlite3_file_control chrome_sqlite3_file_control // Line 7205
+#define sqlite3_finalize chrome_sqlite3_finalize // Line 4675
#define sqlite3_free chrome_sqlite3_free // Line 2749
#define sqlite3_free_table chrome_sqlite3_free_table // Line 2610
-#define sqlite3_get_autocommit chrome_sqlite3_get_autocommit // Line 5742
-#define sqlite3_get_auxdata chrome_sqlite3_get_auxdata // Line 5189
+#define sqlite3_get_autocommit chrome_sqlite3_get_autocommit // Line 5748
+#define sqlite3_get_auxdata chrome_sqlite3_get_auxdata // Line 5195
#define sqlite3_get_table chrome_sqlite3_get_table // Lines 2602-2609
-#define sqlite3_global_recover chrome_sqlite3_global_recover // Line 4889
+#define sqlite3_global_recover chrome_sqlite3_global_recover // Line 4895
#define sqlite3_initialize chrome_sqlite3_initialize // Line 1504
#define sqlite3_interrupt chrome_sqlite3_interrupt // Line 2407
-#define sqlite3_key chrome_sqlite3_key // Lines 5524-5527
-#define sqlite3_key_v2 chrome_sqlite3_key_v2 // Lines 5528-5532
-#define sqlite3_keyword_check chrome_sqlite3_keyword_check // Line 7307
-#define sqlite3_keyword_count chrome_sqlite3_keyword_count // Line 7305
-#define sqlite3_keyword_name chrome_sqlite3_keyword_name // Line 7306
+#define sqlite3_key chrome_sqlite3_key // Lines 5530-5533
+#define sqlite3_key_v2 chrome_sqlite3_key_v2 // Lines 5534-5538
+#define sqlite3_keyword_check chrome_sqlite3_keyword_check // Line 7313
+#define sqlite3_keyword_count chrome_sqlite3_keyword_count // Line 7311
+#define sqlite3_keyword_name chrome_sqlite3_keyword_name // Line 7312
#define sqlite3_last_insert_rowid chrome_sqlite3_last_insert_rowid // Line 2265
#define sqlite3_libversion chrome_sqlite3_libversion // Line 163
#define sqlite3_libversion_number chrome_sqlite3_libversion_number // Line 165
#define sqlite3_limit chrome_sqlite3_limit // Line 3540
-#define sqlite3_load_extension chrome_sqlite3_load_extension // Lines 6162-6167
-#define sqlite3_log chrome_sqlite3_log // Line 8448
+#define sqlite3_load_extension chrome_sqlite3_load_extension // Lines 6168-6173
+#define sqlite3_log chrome_sqlite3_log // Line 8454
#define sqlite3_malloc chrome_sqlite3_malloc // Line 2745
#define sqlite3_malloc64 chrome_sqlite3_malloc64 // Line 2746
-#define sqlite3_memory_alarm chrome_sqlite3_memory_alarm // Lines 4891-4892
+#define sqlite3_memory_alarm chrome_sqlite3_memory_alarm // Lines 4897-4898
#define sqlite3_memory_highwater chrome_sqlite3_memory_highwater // Line 2776
#define sqlite3_memory_used chrome_sqlite3_memory_used // Line 2775
#define sqlite3_mprintf chrome_sqlite3_mprintf // Line 2652
#define sqlite3_msize chrome_sqlite3_msize // Line 2750
-#define sqlite3_mutex_alloc chrome_sqlite3_mutex_alloc // Line 7001
-#define sqlite3_mutex_enter chrome_sqlite3_mutex_enter // Line 7003
-#define sqlite3_mutex_free chrome_sqlite3_mutex_free // Line 7002
-#define sqlite3_mutex_held chrome_sqlite3_mutex_held // Line 7115
-#define sqlite3_mutex_leave chrome_sqlite3_mutex_leave // Line 7005
-#define sqlite3_mutex_notheld chrome_sqlite3_mutex_notheld // Line 7116
-#define sqlite3_mutex_try chrome_sqlite3_mutex_try // Line 7004
-#define sqlite3_next_stmt chrome_sqlite3_next_stmt // Line 5798
-#define sqlite3_normalized_sql chrome_sqlite3_normalized_sql // Line 3830
+#define sqlite3_mutex_alloc chrome_sqlite3_mutex_alloc // Line 7007
+#define sqlite3_mutex_enter chrome_sqlite3_mutex_enter // Line 7009
+#define sqlite3_mutex_free chrome_sqlite3_mutex_free // Line 7008
+#define sqlite3_mutex_held chrome_sqlite3_mutex_held // Line 7121
+#define sqlite3_mutex_leave chrome_sqlite3_mutex_leave // Line 7011
+#define sqlite3_mutex_notheld chrome_sqlite3_mutex_notheld // Line 7122
+#define sqlite3_mutex_try chrome_sqlite3_mutex_try // Line 7010
+#define sqlite3_next_stmt chrome_sqlite3_next_stmt // Line 5804
+#define sqlite3_normalized_sql chrome_sqlite3_normalized_sql // Line 3836
#define sqlite3_open chrome_sqlite3_open // Lines 3357-3360
#define sqlite3_open16 chrome_sqlite3_open16 // Lines 3361-3364
#define sqlite3_open_v2 chrome_sqlite3_open_v2 // Lines 3365-3370
#define sqlite3_os_end chrome_sqlite3_os_end // Line 1507
#define sqlite3_os_init chrome_sqlite3_os_init // Line 1506
-#define sqlite3_overload_function chrome_sqlite3_overload_function // Line 6600
-#define sqlite3_prepare chrome_sqlite3_prepare // Lines 3745-3751
-#define sqlite3_prepare16 chrome_sqlite3_prepare16 // Lines 3767-3773
-#define sqlite3_prepare16_v2 chrome_sqlite3_prepare16_v2 // Lines 3774-3780
-#define sqlite3_prepare16_v3 chrome_sqlite3_prepare16_v3 // Lines 3781-3788
-#define sqlite3_prepare_v2 chrome_sqlite3_prepare_v2 // Lines 3752-3758
-#define sqlite3_prepare_v3 chrome_sqlite3_prepare_v3 // Lines 3759-3766
-#define sqlite3_preupdate_count chrome_sqlite3_preupdate_count // Line 9011
-#define sqlite3_preupdate_depth chrome_sqlite3_preupdate_depth // Line 9012
-#define sqlite3_preupdate_hook chrome_sqlite3_preupdate_hook // Lines 8997-9009
-#define sqlite3_preupdate_new chrome_sqlite3_preupdate_new // Line 9013
-#define sqlite3_preupdate_old chrome_sqlite3_preupdate_old // Line 9010
+#define sqlite3_overload_function chrome_sqlite3_overload_function // Line 6606
+#define sqlite3_prepare chrome_sqlite3_prepare // Lines 3751-3757
+#define sqlite3_prepare16 chrome_sqlite3_prepare16 // Lines 3773-3779
+#define sqlite3_prepare16_v2 chrome_sqlite3_prepare16_v2 // Lines 3780-3786
+#define sqlite3_prepare16_v3 chrome_sqlite3_prepare16_v3 // Lines 3787-3794
+#define sqlite3_prepare_v2 chrome_sqlite3_prepare_v2 // Lines 3758-3764
+#define sqlite3_prepare_v3 chrome_sqlite3_prepare_v3 // Lines 3765-3772
+#define sqlite3_preupdate_count chrome_sqlite3_preupdate_count // Line 9017
+#define sqlite3_preupdate_depth chrome_sqlite3_preupdate_depth // Line 9018
+#define sqlite3_preupdate_hook chrome_sqlite3_preupdate_hook // Lines 9003-9015
+#define sqlite3_preupdate_new chrome_sqlite3_preupdate_new // Line 9019
+#define sqlite3_preupdate_old chrome_sqlite3_preupdate_old // Line 9016
#define sqlite3_profile chrome_sqlite3_profile // Lines 3000-3001
#define sqlite3_progress_handler chrome_sqlite3_progress_handler // Line 3128
#define sqlite3_randomness chrome_sqlite3_randomness // Line 2799
#define sqlite3_realloc chrome_sqlite3_realloc // Line 2747
#define sqlite3_realloc64 chrome_sqlite3_realloc64 // Line 2748
-#define sqlite3_rekey chrome_sqlite3_rekey // Lines 5542-5545
-#define sqlite3_rekey_v2 chrome_sqlite3_rekey_v2 // Lines 5546-5550
-#define sqlite3_release_memory chrome_sqlite3_release_memory // Line 5956
-#define sqlite3_reset chrome_sqlite3_reset // Line 4696
+#define sqlite3_rekey chrome_sqlite3_rekey // Lines 5548-5551
+#define sqlite3_rekey_v2 chrome_sqlite3_rekey_v2 // Lines 5552-5556
+#define sqlite3_release_memory chrome_sqlite3_release_memory // Line 5962
+#define sqlite3_reset chrome_sqlite3_reset // Line 4702
#define sqlite3_reset_auto_extension \
- chrome_sqlite3_reset_auto_extension // Line 6252
-#define sqlite3_result_blob chrome_sqlite3_result_blob // Line 5337
-#define sqlite3_result_blob64 chrome_sqlite3_result_blob64 // Lines 5338-5339
-#define sqlite3_result_double chrome_sqlite3_result_double // Line 5340
-#define sqlite3_result_error chrome_sqlite3_result_error // Line 5341
-#define sqlite3_result_error16 chrome_sqlite3_result_error16 // Line 5342
-#define sqlite3_result_error_code chrome_sqlite3_result_error_code // Line 5345
+ chrome_sqlite3_reset_auto_extension // Line 6258
+#define sqlite3_result_blob chrome_sqlite3_result_blob // Line 5343
+#define sqlite3_result_blob64 chrome_sqlite3_result_blob64 // Lines 5344-5345
+#define sqlite3_result_double chrome_sqlite3_result_double // Line 5346
+#define sqlite3_result_error chrome_sqlite3_result_error // Line 5347
+#define sqlite3_result_error16 chrome_sqlite3_result_error16 // Line 5348
+#define sqlite3_result_error_code chrome_sqlite3_result_error_code // Line 5351
#define sqlite3_result_error_nomem \
- chrome_sqlite3_result_error_nomem // Line 5344
+ chrome_sqlite3_result_error_nomem // Line 5350
#define sqlite3_result_error_toobig \
- chrome_sqlite3_result_error_toobig // Line 5343
-#define sqlite3_result_int chrome_sqlite3_result_int // Line 5346
-#define sqlite3_result_int64 chrome_sqlite3_result_int64 // Line 5347
-#define sqlite3_result_null chrome_sqlite3_result_null // Line 5348
-#define sqlite3_result_pointer chrome_sqlite3_result_pointer // Line 5356
-#define sqlite3_result_subtype chrome_sqlite3_result_subtype // Line 5373
-#define sqlite3_result_text chrome_sqlite3_result_text // Line 5349
-#define sqlite3_result_text16 chrome_sqlite3_result_text16 // Line 5352
-#define sqlite3_result_text16be chrome_sqlite3_result_text16be // Line 5354
-#define sqlite3_result_text16le chrome_sqlite3_result_text16le // Line 5353
-#define sqlite3_result_text64 chrome_sqlite3_result_text64 // Lines 5350-5351
-#define sqlite3_result_value chrome_sqlite3_result_value // Line 5355
-#define sqlite3_result_zeroblob chrome_sqlite3_result_zeroblob // Line 5357
-#define sqlite3_result_zeroblob64 chrome_sqlite3_result_zeroblob64 // Line 5358
-#define sqlite3_rollback_hook chrome_sqlite3_rollback_hook // Line 5848
+ chrome_sqlite3_result_error_toobig // Line 5349
+#define sqlite3_result_int chrome_sqlite3_result_int // Line 5352
+#define sqlite3_result_int64 chrome_sqlite3_result_int64 // Line 5353
+#define sqlite3_result_null chrome_sqlite3_result_null // Line 5354
+#define sqlite3_result_pointer chrome_sqlite3_result_pointer // Line 5362
+#define sqlite3_result_subtype chrome_sqlite3_result_subtype // Line 5379
+#define sqlite3_result_text chrome_sqlite3_result_text // Line 5355
+#define sqlite3_result_text16 chrome_sqlite3_result_text16 // Line 5358
+#define sqlite3_result_text16be chrome_sqlite3_result_text16be // Line 5360
+#define sqlite3_result_text16le chrome_sqlite3_result_text16le // Line 5359
+#define sqlite3_result_text64 chrome_sqlite3_result_text64 // Lines 5356-5357
+#define sqlite3_result_value chrome_sqlite3_result_value // Line 5361
+#define sqlite3_result_zeroblob chrome_sqlite3_result_zeroblob // Line 5363
+#define sqlite3_result_zeroblob64 chrome_sqlite3_result_zeroblob64 // Line 5364
+#define sqlite3_rollback_hook chrome_sqlite3_rollback_hook // Line 5854
#define sqlite3_rtree_geometry_callback \
- chrome_sqlite3_rtree_geometry_callback // Lines 9393-9398
+ chrome_sqlite3_rtree_geometry_callback // Lines 9399-9404
#define sqlite3_rtree_query_callback \
- chrome_sqlite3_rtree_query_callback // Lines 9419-9425
-#define sqlite3_serialize chrome_sqlite3_serialize // Lines 9254-9259
+ chrome_sqlite3_rtree_query_callback // Lines 9425-9431
+#define sqlite3_serialize chrome_sqlite3_serialize // Lines 9260-9265
#define sqlite3_set_authorizer chrome_sqlite3_set_authorizer // Lines 2890-2894
-#define sqlite3_set_auxdata chrome_sqlite3_set_auxdata // Line 5190
+#define sqlite3_set_auxdata chrome_sqlite3_set_auxdata // Line 5196
#define sqlite3_set_last_insert_rowid \
chrome_sqlite3_set_last_insert_rowid // Line 2275
#define sqlite3_shutdown chrome_sqlite3_shutdown // Line 1505
-#define sqlite3_sleep chrome_sqlite3_sleep // Line 5588
-#define sqlite3_snapshot_cmp chrome_sqlite3_snapshot_cmp // Lines 9188-9191
-#define sqlite3_snapshot_free chrome_sqlite3_snapshot_free // Line 9161
-#define sqlite3_snapshot_get chrome_sqlite3_snapshot_get // Lines 9095-9099
-#define sqlite3_snapshot_open chrome_sqlite3_snapshot_open // Lines 9144-9148
-#define sqlite3_snapshot_recover chrome_sqlite3_snapshot_recover // Line 9216
+#define sqlite3_sleep chrome_sqlite3_sleep // Line 5594
+#define sqlite3_snapshot_cmp chrome_sqlite3_snapshot_cmp // Lines 9194-9197
+#define sqlite3_snapshot_free chrome_sqlite3_snapshot_free // Line 9167
+#define sqlite3_snapshot_get chrome_sqlite3_snapshot_get // Lines 9101-9105
+#define sqlite3_snapshot_open chrome_sqlite3_snapshot_open // Lines 9150-9154
+#define sqlite3_snapshot_recover chrome_sqlite3_snapshot_recover // Line 9222
#define sqlite3_snprintf chrome_sqlite3_snprintf // Line 2654
-#define sqlite3_soft_heap_limit chrome_sqlite3_soft_heap_limit // Line 6034
-#define sqlite3_soft_heap_limit64 chrome_sqlite3_soft_heap_limit64 // Line 6023
+#define sqlite3_soft_heap_limit chrome_sqlite3_soft_heap_limit // Line 6040
+#define sqlite3_soft_heap_limit64 chrome_sqlite3_soft_heap_limit64 // Line 6029
#define sqlite3_sourceid chrome_sqlite3_sourceid // Line 164
-#define sqlite3_sql chrome_sqlite3_sql // Line 3828
-#define sqlite3_status chrome_sqlite3_status // Line 7467
-#define sqlite3_status64 chrome_sqlite3_status64 // Lines 7468-7473
-#define sqlite3_step chrome_sqlite3_step // Line 4368
-#define sqlite3_stmt_busy chrome_sqlite3_stmt_busy // Line 3887
-#define sqlite3_stmt_readonly chrome_sqlite3_stmt_readonly // Line 3866
+#define sqlite3_sql chrome_sqlite3_sql // Line 3834
+#define sqlite3_status chrome_sqlite3_status // Line 7473
+#define sqlite3_status64 chrome_sqlite3_status64 // Lines 7474-7479
+#define sqlite3_step chrome_sqlite3_step // Line 4374
+#define sqlite3_stmt_busy chrome_sqlite3_stmt_busy // Line 3893
+#define sqlite3_stmt_readonly chrome_sqlite3_stmt_readonly // Line 3872
#define sqlite3_stmt_scanstatus \
- chrome_sqlite3_stmt_scanstatus // Lines 8864-8869
+ chrome_sqlite3_stmt_scanstatus // Lines 8870-8875
#define sqlite3_stmt_scanstatus_reset \
- chrome_sqlite3_stmt_scanstatus_reset // Line 8880
-#define sqlite3_stmt_status chrome_sqlite3_stmt_status // Line 7730
-#define sqlite3_str_append chrome_sqlite3_str_append // Line 7403
-#define sqlite3_str_appendall chrome_sqlite3_str_appendall // Line 7404
-#define sqlite3_str_appendchar chrome_sqlite3_str_appendchar // Line 7405
-#define sqlite3_str_appendf chrome_sqlite3_str_appendf // Line 7401
-#define sqlite3_str_errcode chrome_sqlite3_str_errcode // Line 7437
-#define sqlite3_str_finish chrome_sqlite3_str_finish // Line 7367
-#define sqlite3_str_length chrome_sqlite3_str_length // Line 7438
-#define sqlite3_str_new chrome_sqlite3_str_new // Line 7352
-#define sqlite3_str_reset chrome_sqlite3_str_reset // Line 7406
-#define sqlite3_str_value chrome_sqlite3_str_value // Line 7439
-#define sqlite3_str_vappendf chrome_sqlite3_str_vappendf // Line 7402
-#define sqlite3_strglob chrome_sqlite3_strglob // Line 8379
-#define sqlite3_stricmp chrome_sqlite3_stricmp // Line 8361
-#define sqlite3_strlike chrome_sqlite3_strlike // Line 8425
-#define sqlite3_strnicmp chrome_sqlite3_strnicmp // Line 8362
-#define sqlite3_system_errno chrome_sqlite3_system_errno // Line 9026
+ chrome_sqlite3_stmt_scanstatus_reset // Line 8886
+#define sqlite3_stmt_status chrome_sqlite3_stmt_status // Line 7736
+#define sqlite3_str_append chrome_sqlite3_str_append // Line 7409
+#define sqlite3_str_appendall chrome_sqlite3_str_appendall // Line 7410
+#define sqlite3_str_appendchar chrome_sqlite3_str_appendchar // Line 7411
+#define sqlite3_str_appendf chrome_sqlite3_str_appendf // Line 7407
+#define sqlite3_str_errcode chrome_sqlite3_str_errcode // Line 7443
+#define sqlite3_str_finish chrome_sqlite3_str_finish // Line 7373
+#define sqlite3_str_length chrome_sqlite3_str_length // Line 7444
+#define sqlite3_str_new chrome_sqlite3_str_new // Line 7358
+#define sqlite3_str_reset chrome_sqlite3_str_reset // Line 7412
+#define sqlite3_str_value chrome_sqlite3_str_value // Line 7445
+#define sqlite3_str_vappendf chrome_sqlite3_str_vappendf // Line 7408
+#define sqlite3_strglob chrome_sqlite3_strglob // Line 8385
+#define sqlite3_stricmp chrome_sqlite3_stricmp // Line 8367
+#define sqlite3_strlike chrome_sqlite3_strlike // Line 8431
+#define sqlite3_strnicmp chrome_sqlite3_strnicmp // Line 8368
+#define sqlite3_system_errno chrome_sqlite3_system_errno // Line 9032
#define sqlite3_table_column_metadata \
- chrome_sqlite3_table_column_metadata // Lines 6106-6116
-#define sqlite3_temp_directory chrome_sqlite3_temp_directory // Line 5646
-#define sqlite3_test_control chrome_sqlite3_test_control // Line 7218
-#define sqlite3_thread_cleanup chrome_sqlite3_thread_cleanup // Line 4890
+ chrome_sqlite3_table_column_metadata // Lines 6112-6122
+#define sqlite3_temp_directory chrome_sqlite3_temp_directory // Line 5652
+#define sqlite3_test_control chrome_sqlite3_test_control // Line 7224
+#define sqlite3_thread_cleanup chrome_sqlite3_thread_cleanup // Line 4896
#define sqlite3_threadsafe chrome_sqlite3_threadsafe // Line 230
#define sqlite3_total_changes chrome_sqlite3_total_changes // Line 2370
#define sqlite3_trace chrome_sqlite3_trace // Lines 2998-2999
#define sqlite3_trace_v2 chrome_sqlite3_trace_v2 // Lines 3089-3094
-#define sqlite3_transfer_bindings chrome_sqlite3_transfer_bindings // Line 4888
-#define sqlite3_unlock_notify chrome_sqlite3_unlock_notify // Lines 8346-8350
-#define sqlite3_update_hook chrome_sqlite3_update_hook // Lines 5899-5903
+#define sqlite3_transfer_bindings chrome_sqlite3_transfer_bindings // Line 4894
+#define sqlite3_unlock_notify chrome_sqlite3_unlock_notify // Lines 8352-8356
+#define sqlite3_update_hook chrome_sqlite3_update_hook // Lines 5905-5909
#define sqlite3_uri_boolean chrome_sqlite3_uri_boolean // Line 3412
#define sqlite3_uri_int64 chrome_sqlite3_uri_int64 // Line 3413
#define sqlite3_uri_parameter chrome_sqlite3_uri_parameter // Line 3411
-#define sqlite3_user_data chrome_sqlite3_user_data // Line 5118
-#define sqlite3_value_blob chrome_sqlite3_value_blob // Line 5016
-#define sqlite3_value_bytes chrome_sqlite3_value_bytes // Line 5025
-#define sqlite3_value_bytes16 chrome_sqlite3_value_bytes16 // Line 5026
-#define sqlite3_value_double chrome_sqlite3_value_double // Line 5017
-#define sqlite3_value_dup chrome_sqlite3_value_dup // Line 5057
-#define sqlite3_value_free chrome_sqlite3_value_free // Line 5058
-#define sqlite3_value_int chrome_sqlite3_value_int // Line 5018
-#define sqlite3_value_int64 chrome_sqlite3_value_int64 // Line 5019
-#define sqlite3_value_nochange chrome_sqlite3_value_nochange // Line 5029
+#define sqlite3_user_data chrome_sqlite3_user_data // Line 5124
+#define sqlite3_value_blob chrome_sqlite3_value_blob // Line 5022
+#define sqlite3_value_bytes chrome_sqlite3_value_bytes // Line 5031
+#define sqlite3_value_bytes16 chrome_sqlite3_value_bytes16 // Line 5032
+#define sqlite3_value_double chrome_sqlite3_value_double // Line 5023
+#define sqlite3_value_dup chrome_sqlite3_value_dup // Line 5063
+#define sqlite3_value_free chrome_sqlite3_value_free // Line 5064
+#define sqlite3_value_int chrome_sqlite3_value_int // Line 5024
+#define sqlite3_value_int64 chrome_sqlite3_value_int64 // Line 5025
+#define sqlite3_value_nochange chrome_sqlite3_value_nochange // Line 5035
#define sqlite3_value_numeric_type \
- chrome_sqlite3_value_numeric_type // Line 5028
-#define sqlite3_value_pointer chrome_sqlite3_value_pointer // Line 5020
-#define sqlite3_value_subtype chrome_sqlite3_value_subtype // Line 5041
-#define sqlite3_value_text chrome_sqlite3_value_text // Line 5021
-#define sqlite3_value_text16 chrome_sqlite3_value_text16 // Line 5022
-#define sqlite3_value_text16be chrome_sqlite3_value_text16be // Line 5024
-#define sqlite3_value_text16le chrome_sqlite3_value_text16le // Line 5023
-#define sqlite3_value_type chrome_sqlite3_value_type // Line 5027
+ chrome_sqlite3_value_numeric_type // Line 5034
+#define sqlite3_value_pointer chrome_sqlite3_value_pointer // Line 5026
+#define sqlite3_value_subtype chrome_sqlite3_value_subtype // Line 5047
+#define sqlite3_value_text chrome_sqlite3_value_text // Line 5027
+#define sqlite3_value_text16 chrome_sqlite3_value_text16 // Line 5028
+#define sqlite3_value_text16be chrome_sqlite3_value_text16be // Line 5030
+#define sqlite3_value_text16le chrome_sqlite3_value_text16le // Line 5029
+#define sqlite3_value_type chrome_sqlite3_value_type // Line 5033
#define sqlite3_version chrome_sqlite3_version // Line 162
-#define sqlite3_vfs_find chrome_sqlite3_vfs_find // Line 6883
-#define sqlite3_vfs_register chrome_sqlite3_vfs_register // Line 6884
-#define sqlite3_vfs_unregister chrome_sqlite3_vfs_unregister // Line 6885
+#define sqlite3_vfs_find chrome_sqlite3_vfs_find // Line 6889
+#define sqlite3_vfs_register chrome_sqlite3_vfs_register // Line 6890
+#define sqlite3_vfs_unregister chrome_sqlite3_vfs_unregister // Line 6891
#define sqlite3_vmprintf chrome_sqlite3_vmprintf // Line 2653
#define sqlite3_vsnprintf chrome_sqlite3_vsnprintf // Line 2655
-#define sqlite3_vtab_collation chrome_sqlite3_vtab_collation // Line 8759
-#define sqlite3_vtab_config chrome_sqlite3_vtab_config // Line 8671
-#define sqlite3_vtab_nochange chrome_sqlite3_vtab_nochange // Line 8744
-#define sqlite3_vtab_on_conflict chrome_sqlite3_vtab_on_conflict // Line 8725
+#define sqlite3_vtab_collation chrome_sqlite3_vtab_collation // Line 8765
+#define sqlite3_vtab_config chrome_sqlite3_vtab_config // Line 8677
+#define sqlite3_vtab_nochange chrome_sqlite3_vtab_nochange // Line 8750
+#define sqlite3_vtab_on_conflict chrome_sqlite3_vtab_on_conflict // Line 8731
#define sqlite3_wal_autocheckpoint \
- chrome_sqlite3_wal_autocheckpoint // Line 8519
-#define sqlite3_wal_checkpoint chrome_sqlite3_wal_checkpoint // Line 8541
+ chrome_sqlite3_wal_autocheckpoint // Line 8525
+#define sqlite3_wal_checkpoint chrome_sqlite3_wal_checkpoint // Line 8547
#define sqlite3_wal_checkpoint_v2 \
- chrome_sqlite3_wal_checkpoint_v2 // Lines 8635-8641
-#define sqlite3_wal_hook chrome_sqlite3_wal_hook // Lines 8484-8488
+ chrome_sqlite3_wal_checkpoint_v2 // Lines 8641-8647
+#define sqlite3_wal_hook chrome_sqlite3_wal_hook // Lines 8490-8494
#define sqlite3_win32_set_directory \
- chrome_sqlite3_win32_set_directory // Lines 5704-5707
+ chrome_sqlite3_win32_set_directory // Lines 5710-5713
#define sqlite3_win32_set_directory16 \
- chrome_sqlite3_win32_set_directory16 // Line 5709
+ chrome_sqlite3_win32_set_directory16 // Line 5715
#define sqlite3_win32_set_directory8 \
- chrome_sqlite3_win32_set_directory8 // Line 5708
-#define sqlite3changegroup_add chrome_sqlite3changegroup_add // Line 10406
+ chrome_sqlite3_win32_set_directory8 // Line 5714
+#define sqlite3changegroup_add chrome_sqlite3changegroup_add // Line 10412
#define sqlite3changegroup_add_strm \
- chrome_sqlite3changegroup_add_strm // Lines 11068-11071
+ chrome_sqlite3changegroup_add_strm // Lines 11074-11077
#define sqlite3changegroup_delete \
- chrome_sqlite3changegroup_delete // Line 10443
-#define sqlite3changegroup_new chrome_sqlite3changegroup_new // Line 10328
+ chrome_sqlite3changegroup_delete // Line 10449
+#define sqlite3changegroup_new chrome_sqlite3changegroup_new // Line 10334
#define sqlite3changegroup_output \
- chrome_sqlite3changegroup_output // Lines 10433-10437
+ chrome_sqlite3changegroup_output // Lines 10439-10443
#define sqlite3changegroup_output_strm \
- chrome_sqlite3changegroup_output_strm // Lines 11072-11075
+ chrome_sqlite3changegroup_output_strm // Lines 11078-11081
#define sqlite3changeset_apply \
- chrome_sqlite3changeset_apply // Lines 10603-10617
+ chrome_sqlite3changeset_apply // Lines 10609-10623
#define sqlite3changeset_apply_strm \
- chrome_sqlite3changeset_apply_strm // Lines 11001-11015
+ chrome_sqlite3changeset_apply_strm // Lines 11007-11021
#define sqlite3changeset_apply_v2 \
- chrome_sqlite3changeset_apply_v2 // Lines 10618-10634
+ chrome_sqlite3changeset_apply_v2 // Lines 10624-10640
#define sqlite3changeset_apply_v2_strm \
- chrome_sqlite3changeset_apply_v2_strm // Lines 11016-11032
+ chrome_sqlite3changeset_apply_v2_strm // Lines 11022-11038
#define sqlite3changeset_concat \
- chrome_sqlite3changeset_concat // Lines 10274-10281
+ chrome_sqlite3changeset_concat // Lines 10280-10287
#define sqlite3changeset_concat_strm \
- chrome_sqlite3changeset_concat_strm // Lines 11033-11040
+ chrome_sqlite3changeset_concat_strm // Lines 11039-11046
#define sqlite3changeset_conflict \
- chrome_sqlite3changeset_conflict // Lines 10160-10164
+ chrome_sqlite3changeset_conflict // Lines 10166-10170
#define sqlite3changeset_finalize \
- chrome_sqlite3changeset_finalize // Line 10213
+ chrome_sqlite3changeset_finalize // Line 10219
#define sqlite3changeset_fk_conflicts \
- chrome_sqlite3changeset_fk_conflicts // Lines 10177-10180
+ chrome_sqlite3changeset_fk_conflicts // Lines 10183-10186
#define sqlite3changeset_invert \
- chrome_sqlite3changeset_invert // Lines 10243-10246
+ chrome_sqlite3changeset_invert // Lines 10249-10252
#define sqlite3changeset_invert_strm \
- chrome_sqlite3changeset_invert_strm // Lines 11041-11046
-#define sqlite3changeset_new chrome_sqlite3changeset_new // Lines 10132-10136
-#define sqlite3changeset_next chrome_sqlite3changeset_next // Line 10004
-#define sqlite3changeset_old chrome_sqlite3changeset_old // Lines 10098-10102
-#define sqlite3changeset_op chrome_sqlite3changeset_op // Lines 10033-10039
-#define sqlite3changeset_pk chrome_sqlite3changeset_pk // Lines 10067-10071
-#define sqlite3changeset_start chrome_sqlite3changeset_start // Lines 9955-9959
+ chrome_sqlite3changeset_invert_strm // Lines 11047-11052
+#define sqlite3changeset_new chrome_sqlite3changeset_new // Lines 10138-10142
+#define sqlite3changeset_next chrome_sqlite3changeset_next // Line 10010
+#define sqlite3changeset_old chrome_sqlite3changeset_old // Lines 10104-10108
+#define sqlite3changeset_op chrome_sqlite3changeset_op // Lines 10039-10045
+#define sqlite3changeset_pk chrome_sqlite3changeset_pk // Lines 10073-10077
+#define sqlite3changeset_start chrome_sqlite3changeset_start // Lines 9961-9965
#define sqlite3changeset_start_strm \
- chrome_sqlite3changeset_start_strm // Lines 11047-11051
+ chrome_sqlite3changeset_start_strm // Lines 11053-11057
#define sqlite3changeset_start_v2 \
- chrome_sqlite3changeset_start_v2 // Lines 9960-9965
+ chrome_sqlite3changeset_start_v2 // Lines 9966-9971
#define sqlite3changeset_start_v2_strm \
- chrome_sqlite3changeset_start_v2_strm // Lines 11052-11057
+ chrome_sqlite3changeset_start_v2_strm // Lines 11058-11063
#define sqlite3rebaser_configure \
- chrome_sqlite3rebaser_configure // Lines 10876-10879
-#define sqlite3rebaser_create chrome_sqlite3rebaser_create // Line 10865
-#define sqlite3rebaser_delete chrome_sqlite3rebaser_delete // Line 10909
-#define sqlite3rebaser_rebase chrome_sqlite3rebaser_rebase // Lines 10895-10899
+ chrome_sqlite3rebaser_configure // Lines 10882-10885
+#define sqlite3rebaser_create chrome_sqlite3rebaser_create // Line 10871
+#define sqlite3rebaser_delete chrome_sqlite3rebaser_delete // Line 10915
+#define sqlite3rebaser_rebase chrome_sqlite3rebaser_rebase // Lines 10901-10905
#define sqlite3rebaser_rebase_strm \
- chrome_sqlite3rebaser_rebase_strm // Lines 11076-11082
-#define sqlite3session_attach chrome_sqlite3session_attach // Lines 9662-9665
+ chrome_sqlite3rebaser_rebase_strm // Lines 11082-11088
+#define sqlite3session_attach chrome_sqlite3session_attach // Lines 9668-9671
#define sqlite3session_changeset \
- chrome_sqlite3session_changeset // Lines 9791-9795
+ chrome_sqlite3session_changeset // Lines 9797-9801
#define sqlite3session_changeset_strm \
- chrome_sqlite3session_changeset_strm // Lines 11058-11062
-#define sqlite3session_config chrome_sqlite3session_config // Line 11117
-#define sqlite3session_create chrome_sqlite3session_create // Lines 9532-9536
-#define sqlite3session_delete chrome_sqlite3session_delete // Line 9551
-#define sqlite3session_diff chrome_sqlite3session_diff // Lines 9854-9859
-#define sqlite3session_enable chrome_sqlite3session_enable // Line 9572
-#define sqlite3session_indirect chrome_sqlite3session_indirect // Line 9602
-#define sqlite3session_isempty chrome_sqlite3session_isempty // Line 9912
+ chrome_sqlite3session_changeset_strm // Lines 11064-11068
+#define sqlite3session_config chrome_sqlite3session_config // Line 11123
+#define sqlite3session_create chrome_sqlite3session_create // Lines 9538-9542
+#define sqlite3session_delete chrome_sqlite3session_delete // Line 9557
+#define sqlite3session_diff chrome_sqlite3session_diff // Lines 9860-9865
+#define sqlite3session_enable chrome_sqlite3session_enable // Line 9578
+#define sqlite3session_indirect chrome_sqlite3session_indirect // Line 9608
+#define sqlite3session_isempty chrome_sqlite3session_isempty // Line 9918
#define sqlite3session_patchset \
- chrome_sqlite3session_patchset // Lines 9891-9895
+ chrome_sqlite3session_patchset // Lines 9897-9901
#define sqlite3session_patchset_strm \
- chrome_sqlite3session_patchset_strm // Lines 11063-11067
+ chrome_sqlite3session_patchset_strm // Lines 11069-11073
#define sqlite3session_table_filter \
- chrome_sqlite3session_table_filter // Lines 9677-9684
+ chrome_sqlite3session_table_filter // Lines 9683-9690
#endif // THIRD_PARTY_SQLITE_AMALGAMATION_RENAME_EXPORTS_H_
diff --git a/chromium/third_party/sqlite/amalgamation/sqlite3.c b/chromium/third_party/sqlite/amalgamation/sqlite3.c
index 9f03a9c121b..3ca72d7bb2b 100644
--- a/chromium/third_party/sqlite/amalgamation/sqlite3.c
+++ b/chromium/third_party/sqlite/amalgamation/sqlite3.c
@@ -4676,10 +4676,16 @@ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
** normalize a SQL statement are unspecified and subject to change.
** At a minimum, literal values will be replaced with suitable
** placeholders.
+**
+** [[SQLITE_PREPARE_NO_VTAB]] <dt>SQLITE_PREPARE_NO_VTAB</dt>
+** <dd>The SQLITE_PREPARE_NO_VTAB flag causes the SQL compiler
+** to return an error (error code SQLITE_ERROR) if the statement uses
+** any virtual tables.
** </dl>
*/
#define SQLITE_PREPARE_PERSISTENT 0x01
#define SQLITE_PREPARE_NORMALIZE 0x02
+#define SQLITE_PREPARE_NO_VTAB 0x04
/*
** CAPI3REF: Compiling An SQL Statement
@@ -13434,71 +13440,71 @@ SQLITE_PRIVATE void sqlite3HashClear(Hash*);
/************** Include parse.h in the middle of sqliteInt.h *****************/
/************** Begin file parse.h *******************************************/
#define TK_SEMI 1
-#define TK_EXPLAIN 2
-#define TK_QUERY 3
-#define TK_PLAN 4
-#define TK_BEGIN 5
-#define TK_TRANSACTION 6
-#define TK_DEFERRED 7
-#define TK_IMMEDIATE 8
-#define TK_EXCLUSIVE 9
-#define TK_COMMIT 10
-#define TK_END 11
-#define TK_ROLLBACK 12
-#define TK_SAVEPOINT 13
-#define TK_RELEASE 14
-#define TK_TO 15
-#define TK_TABLE 16
-#define TK_CREATE 17
-#define TK_IF 18
-#define TK_NOT 19
-#define TK_EXISTS 20
-#define TK_TEMP 21
-#define TK_LP 22
-#define TK_RP 23
-#define TK_AS 24
-#define TK_WITHOUT 25
-#define TK_COMMA 26
-#define TK_ABORT 27
-#define TK_ACTION 28
-#define TK_AFTER 29
-#define TK_ANALYZE 30
-#define TK_ASC 31
-#define TK_ATTACH 32
-#define TK_BEFORE 33
-#define TK_BY 34
-#define TK_CASCADE 35
-#define TK_CAST 36
-#define TK_CONFLICT 37
-#define TK_DATABASE 38
-#define TK_DESC 39
-#define TK_DETACH 40
-#define TK_EACH 41
-#define TK_FAIL 42
-#define TK_OR 43
-#define TK_AND 44
-#define TK_IS 45
-#define TK_MATCH 46
-#define TK_LIKE_KW 47
-#define TK_BETWEEN 48
-#define TK_IN 49
-#define TK_ISNULL 50
-#define TK_NOTNULL 51
-#define TK_NE 52
-#define TK_EQ 53
-#define TK_GT 54
-#define TK_LE 55
-#define TK_LT 56
-#define TK_GE 57
-#define TK_ESCAPE 58
-#define TK_ID 59
-#define TK_COLUMNKW 60
-#define TK_DO 61
-#define TK_FOR 62
-#define TK_IGNORE 63
-#define TK_INITIALLY 64
-#define TK_INSTEAD 65
-#define TK_NO 66
+#define TK_BEGIN 2
+#define TK_TRANSACTION 3
+#define TK_DEFERRED 4
+#define TK_IMMEDIATE 5
+#define TK_EXCLUSIVE 6
+#define TK_COMMIT 7
+#define TK_END 8
+#define TK_ROLLBACK 9
+#define TK_SAVEPOINT 10
+#define TK_RELEASE 11
+#define TK_TO 12
+#define TK_TABLE 13
+#define TK_CREATE 14
+#define TK_IF 15
+#define TK_NOT 16
+#define TK_EXISTS 17
+#define TK_TEMP 18
+#define TK_LP 19
+#define TK_RP 20
+#define TK_AS 21
+#define TK_WITHOUT 22
+#define TK_COMMA 23
+#define TK_ABORT 24
+#define TK_ACTION 25
+#define TK_AFTER 26
+#define TK_ANALYZE 27
+#define TK_ASC 28
+#define TK_ATTACH 29
+#define TK_BEFORE 30
+#define TK_BY 31
+#define TK_CASCADE 32
+#define TK_CAST 33
+#define TK_CONFLICT 34
+#define TK_DATABASE 35
+#define TK_DESC 36
+#define TK_DETACH 37
+#define TK_EACH 38
+#define TK_EXPLAIN 39
+#define TK_FAIL 40
+#define TK_OR 41
+#define TK_AND 42
+#define TK_IS 43
+#define TK_MATCH 44
+#define TK_LIKE_KW 45
+#define TK_BETWEEN 46
+#define TK_IN 47
+#define TK_ISNULL 48
+#define TK_NOTNULL 49
+#define TK_NE 50
+#define TK_EQ 51
+#define TK_GT 52
+#define TK_LE 53
+#define TK_LT 54
+#define TK_GE 55
+#define TK_ESCAPE 56
+#define TK_ID 57
+#define TK_COLUMNKW 58
+#define TK_DO 59
+#define TK_FOR 60
+#define TK_IGNORE 61
+#define TK_INITIALLY 62
+#define TK_INSTEAD 63
+#define TK_NO 64
+#define TK_PLAN 65
+#define TK_QUERY 66
#define TK_KEY 67
#define TK_OF 68
#define TK_OFFSET 69
@@ -14312,8 +14318,6 @@ SQLITE_PRIVATE int sqlite3BtreeGetOptimalReserve(Btree*);
SQLITE_PRIVATE int sqlite3BtreeGetReserveNoMutex(Btree *p);
SQLITE_PRIVATE int sqlite3BtreeSetAutoVacuum(Btree *, int);
SQLITE_PRIVATE int sqlite3BtreeGetAutoVacuum(Btree *);
-SQLITE_PRIVATE int sqlite3BtreeSetAutoVacuumSlackPages(Btree *, int);
-SQLITE_PRIVATE int sqlite3BtreeGetAutoVacuumSlackPages(Btree *);
SQLITE_PRIVATE int sqlite3BtreeBeginTrans(Btree*,int,int*);
SQLITE_PRIVATE int sqlite3BtreeCommitPhaseOne(Btree*, const char *zMaster);
SQLITE_PRIVATE int sqlite3BtreeCommitPhaseTwo(Btree*, int);
@@ -14821,10 +14825,10 @@ typedef struct VdbeOpList VdbeOpList;
#define OP_InitCoroutine 13 /* jump */
#define OP_Yield 14 /* jump */
#define OP_MustBeInt 15 /* jump */
-#define OP_Jump 16 /* jump */
-#define OP_Once 17 /* jump */
-#define OP_If 18 /* jump */
-#define OP_Not 19 /* same as TK_NOT, synopsis: r[P2]= !r[P1] */
+#define OP_Not 16 /* same as TK_NOT, synopsis: r[P2]= !r[P1] */
+#define OP_Jump 17 /* jump */
+#define OP_Once 18 /* jump */
+#define OP_If 19 /* jump */
#define OP_IfNot 20 /* jump */
#define OP_IfNullRow 21 /* jump, synopsis: if P1.nullRow then r[P3]=NULL, goto P2 */
#define OP_SeekLT 22 /* jump, synopsis: key=r[P3@P4] */
@@ -14846,24 +14850,24 @@ typedef struct VdbeOpList VdbeOpList;
#define OP_IdxGT 38 /* jump, synopsis: key=r[P3@P4] */
#define OP_IdxLT 39 /* jump, synopsis: key=r[P3@P4] */
#define OP_IdxGE 40 /* jump, synopsis: key=r[P3@P4] */
-#define OP_RowSetRead 41 /* jump, synopsis: r[P3]=rowset(P1) */
-#define OP_RowSetTest 42 /* jump, synopsis: if r[P3] in rowset(P1) goto P2 */
-#define OP_Or 43 /* same as TK_OR, synopsis: r[P3]=(r[P1] || r[P2]) */
-#define OP_And 44 /* same as TK_AND, synopsis: r[P3]=(r[P1] && r[P2]) */
+#define OP_Or 41 /* same as TK_OR, synopsis: r[P3]=(r[P1] || r[P2]) */
+#define OP_And 42 /* same as TK_AND, synopsis: r[P3]=(r[P1] && r[P2]) */
+#define OP_RowSetRead 43 /* jump, synopsis: r[P3]=rowset(P1) */
+#define OP_RowSetTest 44 /* jump, synopsis: if r[P3] in rowset(P1) goto P2 */
#define OP_Program 45 /* jump */
#define OP_FkIfZero 46 /* jump, synopsis: if fkctr[P1]==0 goto P2 */
#define OP_IfPos 47 /* jump, synopsis: if r[P1]>0 then r[P1]-=P3, goto P2 */
-#define OP_IfNotZero 48 /* jump, synopsis: if r[P1]!=0 then r[P1]--, goto P2 */
-#define OP_DecrJumpZero 49 /* jump, synopsis: if (--r[P1])==0 goto P2 */
-#define OP_IsNull 50 /* jump, same as TK_ISNULL, synopsis: if r[P1]==NULL goto P2 */
-#define OP_NotNull 51 /* jump, same as TK_NOTNULL, synopsis: if r[P1]!=NULL goto P2 */
-#define OP_Ne 52 /* jump, same as TK_NE, synopsis: IF r[P3]!=r[P1] */
-#define OP_Eq 53 /* jump, same as TK_EQ, synopsis: IF r[P3]==r[P1] */
-#define OP_Gt 54 /* jump, same as TK_GT, synopsis: IF r[P3]>r[P1] */
-#define OP_Le 55 /* jump, same as TK_LE, synopsis: IF r[P3]<=r[P1] */
-#define OP_Lt 56 /* jump, same as TK_LT, synopsis: IF r[P3]<r[P1] */
-#define OP_Ge 57 /* jump, same as TK_GE, synopsis: IF r[P3]>=r[P1] */
-#define OP_ElseNotEq 58 /* jump, same as TK_ESCAPE */
+#define OP_IsNull 48 /* jump, same as TK_ISNULL, synopsis: if r[P1]==NULL goto P2 */
+#define OP_NotNull 49 /* jump, same as TK_NOTNULL, synopsis: if r[P1]!=NULL goto P2 */
+#define OP_Ne 50 /* jump, same as TK_NE, synopsis: IF r[P3]!=r[P1] */
+#define OP_Eq 51 /* jump, same as TK_EQ, synopsis: IF r[P3]==r[P1] */
+#define OP_Gt 52 /* jump, same as TK_GT, synopsis: IF r[P3]>r[P1] */
+#define OP_Le 53 /* jump, same as TK_LE, synopsis: IF r[P3]<=r[P1] */
+#define OP_Lt 54 /* jump, same as TK_LT, synopsis: IF r[P3]<r[P1] */
+#define OP_Ge 55 /* jump, same as TK_GE, synopsis: IF r[P3]>=r[P1] */
+#define OP_ElseNotEq 56 /* jump, same as TK_ESCAPE */
+#define OP_IfNotZero 57 /* jump, synopsis: if r[P1]!=0 then r[P1]--, goto P2 */
+#define OP_DecrJumpZero 58 /* jump, synopsis: if (--r[P1])==0 goto P2 */
#define OP_IncrVacuum 59 /* jump */
#define OP_VNext 60 /* jump */
#define OP_Init 61 /* jump, synopsis: Start at P2 */
@@ -14993,12 +14997,12 @@ typedef struct VdbeOpList VdbeOpList;
#define OPFLG_INITIALIZER {\
/* 0 */ 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x10,\
/* 8 */ 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x03, 0x03,\
-/* 16 */ 0x01, 0x01, 0x03, 0x12, 0x03, 0x01, 0x09, 0x09,\
+/* 16 */ 0x12, 0x01, 0x01, 0x03, 0x03, 0x01, 0x09, 0x09,\
/* 24 */ 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09,\
/* 32 */ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,\
-/* 40 */ 0x01, 0x23, 0x0b, 0x26, 0x26, 0x01, 0x01, 0x03,\
-/* 48 */ 0x03, 0x03, 0x03, 0x03, 0x0b, 0x0b, 0x0b, 0x0b,\
-/* 56 */ 0x0b, 0x0b, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00,\
+/* 40 */ 0x01, 0x26, 0x26, 0x23, 0x0b, 0x01, 0x01, 0x03,\
+/* 48 */ 0x03, 0x03, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,\
+/* 56 */ 0x01, 0x03, 0x03, 0x01, 0x01, 0x01, 0x00, 0x00,\
/* 64 */ 0x00, 0x00, 0x02, 0x02, 0x08, 0x00, 0x10, 0x10,\
/* 72 */ 0x10, 0x10, 0x00, 0x10, 0x10, 0x00, 0x00, 0x10,\
/* 80 */ 0x10, 0x00, 0x00, 0x02, 0x02, 0x02, 0x26, 0x26,\
@@ -17933,6 +17937,7 @@ struct Parse {
u8 hasCompound; /* Need to invoke convertCompoundSelectToSubquery() */
u8 okConstFactor; /* OK to factor out constants */
u8 disableLookaside; /* Number of times lookaside has been disabled */
+ u8 disableVtab; /* Disable all virtual tables for this parse */
int nRangeReg; /* Size of the temporary register block */
int iRangeReg; /* First register in temporary register block */
int nErr; /* Number of errors seen */
@@ -31985,10 +31990,10 @@ SQLITE_PRIVATE const char *sqlite3OpcodeName(int i){
/* 13 */ "InitCoroutine" OpHelp(""),
/* 14 */ "Yield" OpHelp(""),
/* 15 */ "MustBeInt" OpHelp(""),
- /* 16 */ "Jump" OpHelp(""),
- /* 17 */ "Once" OpHelp(""),
- /* 18 */ "If" OpHelp(""),
- /* 19 */ "Not" OpHelp("r[P2]= !r[P1]"),
+ /* 16 */ "Not" OpHelp("r[P2]= !r[P1]"),
+ /* 17 */ "Jump" OpHelp(""),
+ /* 18 */ "Once" OpHelp(""),
+ /* 19 */ "If" OpHelp(""),
/* 20 */ "IfNot" OpHelp(""),
/* 21 */ "IfNullRow" OpHelp("if P1.nullRow then r[P3]=NULL, goto P2"),
/* 22 */ "SeekLT" OpHelp("key=r[P3@P4]"),
@@ -32010,24 +32015,24 @@ SQLITE_PRIVATE const char *sqlite3OpcodeName(int i){
/* 38 */ "IdxGT" OpHelp("key=r[P3@P4]"),
/* 39 */ "IdxLT" OpHelp("key=r[P3@P4]"),
/* 40 */ "IdxGE" OpHelp("key=r[P3@P4]"),
- /* 41 */ "RowSetRead" OpHelp("r[P3]=rowset(P1)"),
- /* 42 */ "RowSetTest" OpHelp("if r[P3] in rowset(P1) goto P2"),
- /* 43 */ "Or" OpHelp("r[P3]=(r[P1] || r[P2])"),
- /* 44 */ "And" OpHelp("r[P3]=(r[P1] && r[P2])"),
+ /* 41 */ "Or" OpHelp("r[P3]=(r[P1] || r[P2])"),
+ /* 42 */ "And" OpHelp("r[P3]=(r[P1] && r[P2])"),
+ /* 43 */ "RowSetRead" OpHelp("r[P3]=rowset(P1)"),
+ /* 44 */ "RowSetTest" OpHelp("if r[P3] in rowset(P1) goto P2"),
/* 45 */ "Program" OpHelp(""),
/* 46 */ "FkIfZero" OpHelp("if fkctr[P1]==0 goto P2"),
/* 47 */ "IfPos" OpHelp("if r[P1]>0 then r[P1]-=P3, goto P2"),
- /* 48 */ "IfNotZero" OpHelp("if r[P1]!=0 then r[P1]--, goto P2"),
- /* 49 */ "DecrJumpZero" OpHelp("if (--r[P1])==0 goto P2"),
- /* 50 */ "IsNull" OpHelp("if r[P1]==NULL goto P2"),
- /* 51 */ "NotNull" OpHelp("if r[P1]!=NULL goto P2"),
- /* 52 */ "Ne" OpHelp("IF r[P3]!=r[P1]"),
- /* 53 */ "Eq" OpHelp("IF r[P3]==r[P1]"),
- /* 54 */ "Gt" OpHelp("IF r[P3]>r[P1]"),
- /* 55 */ "Le" OpHelp("IF r[P3]<=r[P1]"),
- /* 56 */ "Lt" OpHelp("IF r[P3]<r[P1]"),
- /* 57 */ "Ge" OpHelp("IF r[P3]>=r[P1]"),
- /* 58 */ "ElseNotEq" OpHelp(""),
+ /* 48 */ "IsNull" OpHelp("if r[P1]==NULL goto P2"),
+ /* 49 */ "NotNull" OpHelp("if r[P1]!=NULL goto P2"),
+ /* 50 */ "Ne" OpHelp("IF r[P3]!=r[P1]"),
+ /* 51 */ "Eq" OpHelp("IF r[P3]==r[P1]"),
+ /* 52 */ "Gt" OpHelp("IF r[P3]>r[P1]"),
+ /* 53 */ "Le" OpHelp("IF r[P3]<=r[P1]"),
+ /* 54 */ "Lt" OpHelp("IF r[P3]<r[P1]"),
+ /* 55 */ "Ge" OpHelp("IF r[P3]>=r[P1]"),
+ /* 56 */ "ElseNotEq" OpHelp(""),
+ /* 57 */ "IfNotZero" OpHelp("if r[P1]!=0 then r[P1]--, goto P2"),
+ /* 58 */ "DecrJumpZero" OpHelp("if (--r[P1])==0 goto P2"),
/* 59 */ "IncrVacuum" OpHelp(""),
/* 60 */ "VNext" OpHelp(""),
/* 61 */ "Init" OpHelp("Start at P2"),
@@ -48988,6 +48993,9 @@ static void pcache1FreePage(PgHdr1 *p){
** exists, this function falls back to sqlite3Malloc().
*/
SQLITE_PRIVATE void *sqlite3PageMalloc(int sz){
+ /* During rebalance operations on a corrupt database file, it is sometimes
+ ** (rarely) possible to overread the temporary page buffer by a few bytes.
+ ** Enlarge the allocation slightly so that this does not cause problems. */
return pcache1Alloc(sz);
}
@@ -62428,7 +62436,6 @@ struct BtShared {
u8 openFlags; /* Flags to sqlite3BtreeOpen() */
#ifndef SQLITE_OMIT_AUTOVACUUM
u8 autoVacuum; /* True if auto-vacuum is enabled */
- u8 autoVacuumSlack; /* Optional pages of slack for auto-vacuum */
u8 incrVacuum; /* True if incr-vacuum is enabled */
u8 bDoTruncate; /* True to truncate db on commit */
#endif
@@ -63677,13 +63684,19 @@ static int saveCursorKey(BtCursor *pCur){
/* Only the rowid is required for a table btree */
pCur->nKey = sqlite3BtreeIntegerKey(pCur);
}else{
- /* For an index btree, save the complete key content */
+ /* For an index btree, save the complete key content. It is possible
+ ** that the current key is corrupt. In that case, it is possible that
+ ** the sqlite3VdbeRecordUnpack() function may overread the buffer by
+ ** up to the size of 1 varint plus 1 8-byte value when the cursor
+ ** position is restored. Hence the 17 bytes of padding allocated
+ ** below. */
void *pKey;
pCur->nKey = sqlite3BtreePayloadSize(pCur);
- pKey = sqlite3Malloc( pCur->nKey );
+ pKey = sqlite3Malloc( pCur->nKey + 9 + 8 );
if( pKey ){
rc = sqlite3BtreePayload(pCur, 0, (int)pCur->nKey, pKey);
if( rc==SQLITE_OK ){
+ memset(((u8*)pKey)+pCur->nKey, 0, 9+8);
pCur->pKey = pKey;
}else{
sqlite3_free(pKey);
@@ -64078,7 +64091,7 @@ static int ptrmapGet(BtShared *pBt, Pgno key, u8 *pEType, Pgno *pPgno){
#else /* if defined SQLITE_OMIT_AUTOVACUUM */
#define ptrmapPut(w,x,y,z,rc)
#define ptrmapGet(w,x,y,z) SQLITE_OK
- #define ptrmapPutOvflPtr(x, y, rc)
+ #define ptrmapPutOvflPtr(x, y, z, rc)
#endif
/*
@@ -64371,18 +64384,20 @@ static u16 cellSize(MemPage *pPage, int iCell){
#ifndef SQLITE_OMIT_AUTOVACUUM
/*
-** If the cell pCell, part of page pPage contains a pointer
-** to an overflow page, insert an entry into the pointer-map
-** for the overflow page.
+** The cell pCell is currently part of page pSrc but will ultimately be part
+** of pPage. (pSrc and pPager are often the same.) If pCell contains a
+** pointer to an overflow page, insert an entry into the pointer-map for
+** the overflow page that will be valid after pCell has been moved to pPage.
*/
-static void ptrmapPutOvflPtr(MemPage *pPage, u8 *pCell, int *pRC){
+static void ptrmapPutOvflPtr(MemPage *pPage, MemPage *pSrc, u8 *pCell, int *pRC){
CellInfo info;
if( *pRC ) return;
assert( pCell!=0 );
pPage->xParseCell(pPage, pCell, &info);
if( info.nLocal<info.nPayload ){
Pgno ovfl;
- if( SQLITE_WITHIN(pPage->aDataEnd, pCell, pCell+info.nLocal) ){
+ if( SQLITE_WITHIN(pSrc->aDataEnd, pCell, pCell+info.nLocal) ){
+ testcase( pSrc!=pPage );
*pRC = SQLITE_CORRUPT_BKPT;
return;
}
@@ -64441,18 +64456,14 @@ static int defragmentPage(MemPage *pPage, int nMaxFrag){
** reconstruct the entire page. */
if( (int)data[hdr+7]<=nMaxFrag ){
int iFree = get2byte(&data[hdr+1]);
+
+ /* If the initial freeblock offset were out of bounds, that would
+ ** have been detected by btreeInitPage() when it was computing the
+ ** number of free bytes on the page. */
+ assert( iFree<=usableSize-4 );
if( iFree ){
int iFree2 = get2byte(&data[iFree]);
-
- /* pageFindSlot() has already verified that free blocks are sorted
- ** in order of offset within the page, and that no block extends
- ** past the end of the page. Provided the two free slots do not
- ** overlap, this guarantees that the memmove() calls below will not
- ** overwrite the usableSize byte buffer, even if the database page
- ** is corrupt. */
- assert( iFree2==0 || iFree2>iFree );
- assert( iFree+get2byte(&data[iFree+2]) <= usableSize );
- assert( iFree2==0 || iFree2+get2byte(&data[iFree2+2]) <= usableSize );
+ if( iFree2>usableSize-4 ) return SQLITE_CORRUPT_PAGE(pPage);
if( 0==iFree2 || (data[iFree2]==0 && data[iFree2+1]==0) ){
u8 *pEnd = &data[cellOffset + nCell*2];
@@ -64464,9 +64475,9 @@ static int defragmentPage(MemPage *pPage, int nMaxFrag){
return SQLITE_CORRUPT_PAGE(pPage);
}
if( iFree2 ){
- assert( iFree+sz<=iFree2 ); /* Verified by pageFindSlot() */
+ if( iFree+sz>iFree2 ) return SQLITE_CORRUPT_PAGE(pPage);
sz2 = get2byte(&data[iFree2+2]);
- assert( iFree+sz+sz2+iFree2-(iFree+sz) <= usableSize );
+ if( iFree2+sz2 > usableSize ) return SQLITE_CORRUPT_PAGE(pPage);
memmove(&data[iFree+sz+sz2], &data[iFree+sz], iFree2-(iFree+sz));
sz += sz2;
}
@@ -66010,46 +66021,6 @@ static int newDatabase(BtShared*);
/*
-** Change the 'auto-vacuum-slack-pages' property of the database. If auto vacuum
-** is enabled, this is the number of chunks of slack to allow before
-** automatically running an incremental vacuum.
-*/
-SQLITE_PRIVATE int sqlite3BtreeSetAutoVacuumSlackPages(Btree *p, int autoVacuumSlack){
-#ifdef SQLITE_OMIT_AUTOVACUUM
- return SQLITE_READONLY;
-#else
- BtShared *pBt = p->pBt;
- int rc = SQLITE_OK;
- u8 avs = (u8)autoVacuumSlack;
- if( autoVacuumSlack>avs ){
- avs = 0xFF;
- }
-
- sqlite3BtreeEnter(p);
- pBt->autoVacuumSlack = avs;
- sqlite3BtreeLeave(p);
- return rc;
-#endif
-}
-
-/*
-** Return the value of the 'auto-vacuum-slack-pages' property.
-*/
-SQLITE_PRIVATE int sqlite3BtreeGetAutoVacuumSlackPages(Btree *p){
-#ifdef SQLITE_OMIT_AUTOVACUUM
- return 0;
-#else
- int rc = 0;
- sqlite3BtreeEnter(p);
- if( p->pBt->autoVacuum!=0 ){
- rc = p->pBt->autoVacuumSlack;
- }
- sqlite3BtreeLeave(p);
- return rc;
-#endif
-}
-
-/*
** Get a reference to pPage1 of the database file. This will
** also acquire a readlock on that file.
**
@@ -66061,9 +66032,9 @@ SQLITE_PRIVATE int sqlite3BtreeGetAutoVacuumSlackPages(Btree *p){
static int lockBtree(BtShared *pBt){
int rc; /* Result code from subfunctions */
MemPage *pPage1; /* Page 1 of the database file */
- int nPage; /* Number of pages in the database */
- int nPageFile = 0; /* Number of pages in the database file */
- int nPageHeader; /* Number of pages in the database according to hdr */
+ u32 nPage; /* Number of pages in the database */
+ u32 nPageFile = 0; /* Number of pages in the database file */
+ u32 nPageHeader; /* Number of pages in the database according to hdr */
assert( sqlite3_mutex_held(pBt->mutex) );
assert( pBt->pPage1==0 );
@@ -66076,7 +66047,7 @@ static int lockBtree(BtShared *pBt){
** a valid database file.
*/
nPage = nPageHeader = get4byte(28+(u8*)pPage1->aData);
- sqlite3PagerPagecount(pBt->pPager, &nPageFile);
+ sqlite3PagerPagecount(pBt->pPager, (int*)&nPageFile);
if( nPage==0 || memcmp(24+(u8*)pPage1->aData, 92+(u8*)pPage1->aData,4)!=0 ){
nPage = nPageFile;
}
@@ -66547,7 +66518,7 @@ static int setChildPtrmaps(MemPage *pPage){
for(i=0; i<nCell; i++){
u8 *pCell = findCell(pPage, i);
- ptrmapPutOvflPtr(pPage, pCell, &rc);
+ ptrmapPutOvflPtr(pPage, pPage, pCell, &rc);
if( !pPage->leaf ){
Pgno childPgno = get4byte(pCell);
@@ -66898,27 +66869,13 @@ SQLITE_PRIVATE int sqlite3BtreeIncrVacuum(Btree *p){
*/
static int autoVacuumCommit(BtShared *pBt){
int rc = SQLITE_OK;
- int bShouldVacuum = pBt->autoVacuum && !pBt->incrVacuum;
Pager *pPager = pBt->pPager;
VVA_ONLY( int nRef = sqlite3PagerRefcount(pPager); )
assert( sqlite3_mutex_held(pBt->mutex) );
invalidateAllOverflowCache(pBt);
assert(pBt->autoVacuum);
- if( bShouldVacuum && pBt->autoVacuumSlack ){
- Pgno nOrig; /* Database size before freeing */
- Pgno nFree; /* Number of pages on the freelist initially */
-
- nOrig = btreePagecount(pBt);
- nFree = get4byte(&pBt->pPage1->aData[36]);
- bShouldVacuum =
- (nOrig-nFree-1)/pBt->autoVacuumSlack < (nOrig-1)/pBt->autoVacuumSlack;
- /* TODO: When integrating this test with the following code, contrive to
- ** trim to the integral chunk boundary, rather than trimming the entire free
- ** list.
- */
- }
- if( bShouldVacuum ){
+ if( !pBt->incrVacuum ){
Pgno nFin; /* Number of pages in database after autovacuuming */
Pgno nFree; /* Number of pages on the freelist initially */
Pgno iFree; /* The next page to be freed */
@@ -68541,7 +68498,7 @@ SQLITE_PRIVATE int sqlite3BtreeMovetoUnpacked(
testcase( nCell==0 ); /* Invalid key size: 0x80 0x80 0x00 */
testcase( nCell==1 ); /* Invalid key size: 0x80 0x80 0x01 */
testcase( nCell==2 ); /* Minimum legal index key size */
- if( nCell<2 ){
+ if( nCell<2 || nCell/pCur->pBt->usableSize>pCur->pBt->nPage ){
rc = SQLITE_CORRUPT_PAGE(pPage);
goto moveto_finish;
}
@@ -69730,9 +69687,16 @@ static void insertCell(
assert( idx >= pPage->cellOffset+2*pPage->nCell+2 || CORRUPT_DB );
assert( idx+sz <= (int)pPage->pBt->usableSize );
pPage->nFree -= (u16)(2 + sz);
- memcpy(&data[idx], pCell, sz);
if( iChild ){
+ /* In a corrupt database where an entry in the cell index section of
+ ** a btree page has a value of 3 or less, the pCell value might point
+ ** as many as 4 bytes in front of the start of the aData buffer for
+ ** the source page. Make sure this does not cause problems by not
+ ** reading the first 4 bytes */
+ memcpy(&data[idx+4], pCell+4, sz-4);
put4byte(&data[idx], iChild);
+ }else{
+ memcpy(&data[idx], pCell, sz);
}
pIns = pPage->aCellIdx + i*2;
memmove(pIns+2, pIns, 2*(pPage->nCell - i));
@@ -69746,7 +69710,7 @@ static void insertCell(
/* The cell may contain a pointer to an overflow page. If so, write
** the entry for the overflow page into the pointer map.
*/
- ptrmapPutOvflPtr(pPage, pCell, pRC);
+ ptrmapPutOvflPtr(pPage, pPage, pCell, pRC);
}
#endif
}
@@ -69833,6 +69797,7 @@ static int rebuildPage(
for(i=0; i<nCell; i++){
u8 *pCell = apCell[i];
if( SQLITE_WITHIN(pCell,aData,pEnd) ){
+ if( ((uptr)(pCell+szCell[i]))>(uptr)pEnd ) return SQLITE_CORRUPT_BKPT;
pCell = &pTmp[pCell - aData];
}
pData -= szCell[i];
@@ -70127,8 +70092,7 @@ static int balance_quick(MemPage *pParent, MemPage *pPage, u8 *pSpace){
assert( sqlite3PagerIswriteable(pParent->pDbPage) );
assert( pPage->nOverflow==1 );
- /* This error condition is now caught prior to reaching this function */
- if( NEVER(pPage->nCell==0) ) return SQLITE_CORRUPT_BKPT;
+ if( pPage->nCell==0 ) return SQLITE_CORRUPT_BKPT; /* dbfuzz001.test */
/* Allocate a new page. This page will become the right-sibling of
** pPage. Make the parent page writable, so that the new divider cell
@@ -70162,7 +70126,7 @@ static int balance_quick(MemPage *pParent, MemPage *pPage, u8 *pSpace){
if( ISAUTOVACUUM ){
ptrmapPut(pBt, pgnoNew, PTRMAP_BTREE, pParent->pgno, &rc);
if( szCell>pNew->minLocal ){
- ptrmapPutOvflPtr(pNew, pCell, &rc);
+ ptrmapPutOvflPtr(pNew, pNew, pCell, &rc);
}
}
@@ -70385,10 +70349,6 @@ static int balance_nonroot(
assert( sqlite3_mutex_held(pBt->mutex) );
assert( sqlite3PagerIswriteable(pParent->pDbPage) );
-#if 0
- TRACE(("BALANCE: begin page %d child of %d\n", pPage->pgno, pParent->pgno));
-#endif
-
/* At this point pParent may have at most one overflow cell. And if
** this overflow cell is present, it must be the cell with
** index iParentIdx. This scenario comes about when this function
@@ -70854,7 +70814,8 @@ static int balance_nonroot(
** populated, not here.
*/
if( ISAUTOVACUUM ){
- MemPage *pNew = apNew[0];
+ MemPage *pOld;
+ MemPage *pNew = pOld = apNew[0];
u8 *aOld = pNew->aData;
int cntOldNext = pNew->nCell + pNew->nOverflow;
int usableSize = pBt->usableSize;
@@ -70864,7 +70825,7 @@ static int balance_nonroot(
for(i=0; i<b.nCell; i++){
u8 *pCell = b.apCell[i];
if( i==cntOldNext ){
- MemPage *pOld = (++iOld)<nNew ? apNew[iOld] : apOld[iOld];
+ pOld = (++iOld)<nNew ? apNew[iOld] : apOld[iOld];
cntOldNext += pOld->nCell + pOld->nOverflow + !leafData;
aOld = pOld->aData;
}
@@ -70887,7 +70848,7 @@ static int balance_nonroot(
ptrmapPut(pBt, get4byte(pCell), PTRMAP_BTREE, pNew->pgno, &rc);
}
if( cachedCellSize(&b,i)>pNew->minLocal ){
- ptrmapPutOvflPtr(pNew, pCell, &rc);
+ ptrmapPutOvflPtr(pNew, pOld, pCell, &rc);
}
if( rc ) goto balance_cleanup;
}
@@ -71706,6 +71667,7 @@ SQLITE_PRIVATE int sqlite3BtreeDelete(BtCursor *pCur, u8 flags){
if( bPreserve ){
if( !pPage->leaf
|| (pPage->nFree+cellSizePtr(pPage,pCell)+2)>(int)(pBt->usableSize*2/3)
+ || pPage->nCell==1 /* See dbfuzz001.test for a test case */
){
/* A b-tree rebalance will be required after deleting this entry.
** Save the cursor key. */
@@ -72484,7 +72446,7 @@ static void checkList(
}
pOvflData = (unsigned char *)sqlite3PagerGetData(pOvflPage);
if( isFreeList ){
- int n = get4byte(&pOvflData[4]);
+ u32 n = (u32)get4byte(&pOvflData[4]);
#ifndef SQLITE_OMIT_AUTOVACUUM
if( pCheck->pBt->autoVacuum ){
checkPtrmap(pCheck, iPage, PTRMAP_FREEPAGE, 0);
@@ -72495,7 +72457,7 @@ static void checkList(
"freelist leaf count too big on page %d", iPage);
N--;
}else{
- for(i=0; i<n; i++){
+ for(i=0; i<(int)n; i++){
Pgno iFreePage = get4byte(&pOvflData[8+i*4]);
#ifndef SQLITE_OMIT_AUTOVACUUM
if( pCheck->pBt->autoVacuum ){
@@ -79707,6 +79669,13 @@ SQLITE_PRIVATE void sqlite3VdbeRecordUnpack(
pMem++;
if( (++u)>=p->nField ) break;
}
+ if( d>nKey && u ){
+ assert( CORRUPT_DB );
+ /* In a corrupt record entry, the last pMem might have been set up using
+ ** uninitialized memory. Overwrite its value with NULL, to prevent
+ ** warnings from MSAN. */
+ sqlite3VdbeMemSetNull(pMem-1);
+ }
assert( u<=pKeyInfo->nKeyField + 1 );
p->nField = u;
}
@@ -79772,8 +79741,8 @@ static int vdbeRecordCompareDebug(
** Use that approximation to avoid the more expensive call to
** sqlite3VdbeSerialTypeLen() in the common case.
*/
- if( d1+serial_type1+2>(u32)nKey1
- && d1+sqlite3VdbeSerialTypeLen(serial_type1)>(u32)nKey1
+ if( d1+(u64)serial_type1+2>(u64)nKey1
+ && d1+(u64)sqlite3VdbeSerialTypeLen(serial_type1)>(u64)nKey1
){
break;
}
@@ -79784,7 +79753,8 @@ static int vdbeRecordCompareDebug(
/* Do the comparison
*/
- rc = sqlite3MemCompare(&mem1, &pPKey2->aMem[i], pKeyInfo->aColl[i]);
+ rc = sqlite3MemCompare(&mem1, &pPKey2->aMem[i],
+ pKeyInfo->nAllField>i ? pKeyInfo->aColl[i] : 0);
if( rc!=0 ){
assert( mem1.szMalloc==0 ); /* See comment below */
if( pKeyInfo->aSortOrder[i] ){
@@ -80215,10 +80185,12 @@ SQLITE_PRIVATE int sqlite3VdbeRecordCompareWithSkip(
mem1.n = (serial_type - 12) / 2;
testcase( (d1+mem1.n)==(unsigned)nKey1 );
testcase( (d1+mem1.n+1)==(unsigned)nKey1 );
- if( (d1+mem1.n) > (unsigned)nKey1 ){
+ if( (d1+mem1.n) > (unsigned)nKey1
+ || (pKeyInfo = pPKey2->pKeyInfo)->nAllField<=i
+ ){
pPKey2->errCode = (u8)SQLITE_CORRUPT_BKPT;
return 0; /* Corruption */
- }else if( (pKeyInfo = pPKey2->pKeyInfo)->aColl[i] ){
+ }else if( pKeyInfo->aColl[i] ){
mem1.enc = pKeyInfo->enc;
mem1.db = pKeyInfo->db;
mem1.flags = MEM_Str;
@@ -101009,9 +100981,11 @@ SQLITE_PRIVATE int sqlite3ExprCompare(Parse *pParse, Expr *pA, Expr *pB, int iTa
if( sqlite3WindowCompare(pParse,pA->y.pWin,pB->y.pWin)!=0 ) return 2;
}
#endif
+ }else if( pA->op==TK_NULL ){
+ return 0;
}else if( pA->op==TK_COLLATE ){
if( sqlite3_stricmp(pA->u.zToken,pB->u.zToken)!=0 ) return 2;
- }else if( strcmp(pA->u.zToken,pB->u.zToken)!=0 ){
+ }else if( ALWAYS(pB->u.zToken!=0) && strcmp(pA->u.zToken,pB->u.zToken)!=0 ){
return 2;
}
}
@@ -106425,26 +106399,32 @@ SQLITE_PRIVATE Table *sqlite3LocateTable(
p = sqlite3FindTable(db, zName, zDbase);
if( p==0 ){
- const char *zMsg = flags & LOCATE_VIEW ? "no such view" : "no such table";
#ifndef SQLITE_OMIT_VIRTUALTABLE
/* If zName is the not the name of a table in the schema created using
** CREATE, then check to see if it is the name of an virtual table that
** can be an eponymous virtual table. */
- Module *pMod = (Module*)sqlite3HashFind(&db->aModule, zName);
- if( pMod==0 && sqlite3_strnicmp(zName, "pragma_", 7)==0 ){
- pMod = sqlite3PragmaVtabRegister(db, zName);
- }
- if( pMod && sqlite3VtabEponymousTableInit(pParse, pMod) ){
- return pMod->pEpoTab;
+ if( pParse->disableVtab==0 ){
+ Module *pMod = (Module*)sqlite3HashFind(&db->aModule, zName);
+ if( pMod==0 && sqlite3_strnicmp(zName, "pragma_", 7)==0 ){
+ pMod = sqlite3PragmaVtabRegister(db, zName);
+ }
+ if( pMod && sqlite3VtabEponymousTableInit(pParse, pMod) ){
+ return pMod->pEpoTab;
+ }
}
#endif
- if( (flags & LOCATE_NOERR)==0 ){
- if( zDbase ){
- sqlite3ErrorMsg(pParse, "%s: %s.%s", zMsg, zDbase, zName);
- }else{
- sqlite3ErrorMsg(pParse, "%s: %s", zMsg, zName);
- }
- pParse->checkSchema = 1;
+ if( flags & LOCATE_NOERR ) return 0;
+ pParse->checkSchema = 1;
+ }else if( IsVirtual(p) && pParse->disableVtab ){
+ p = 0;
+ }
+
+ if( p==0 ){
+ const char *zMsg = flags & LOCATE_VIEW ? "no such view" : "no such table";
+ if( zDbase ){
+ sqlite3ErrorMsg(pParse, "%s: %s.%s", zMsg, zDbase, zName);
+ }else{
+ sqlite3ErrorMsg(pParse, "%s: %s", zMsg, zName);
}
}
@@ -110488,13 +110468,15 @@ static int collationMatch(const char *zColl, Index *pIndex){
*/
#ifndef SQLITE_OMIT_REINDEX
static void reindexTable(Parse *pParse, Table *pTab, char const *zColl){
- Index *pIndex; /* An index associated with pTab */
+ if (! IsVirtual(pTab) ){
+ Index *pIndex; /* An index associated with pTab */
- for(pIndex=pTab->pIndex; pIndex; pIndex=pIndex->pNext){
- if( zColl==0 || collationMatch(zColl, pIndex) ){
- int iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);
- sqlite3BeginWriteOperation(pParse, 0, iDb);
- sqlite3RefillIndex(pParse, pIndex, -1);
+ for(pIndex=pTab->pIndex; pIndex; pIndex=pIndex->pNext){
+ if( zColl==0 || collationMatch(zColl, pIndex) ){
+ int iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);
+ sqlite3BeginWriteOperation(pParse, 0, iDb);
+ sqlite3RefillIndex(pParse, pIndex, -1);
+ }
}
}
}
@@ -116586,16 +116568,12 @@ SQLITE_PRIVATE void sqlite3Insert(
}else if( pSelect ){
sqlite3VdbeAddOp2(v, OP_Copy, regFromSelect+ipkColumn, regRowid);
}else{
- VdbeOp *pOp;
- sqlite3ExprCode(pParse, pList->a[ipkColumn].pExpr, regRowid);
- pOp = sqlite3VdbeGetOp(v, -1);
- assert( pOp!=0 );
- if( pOp->opcode==OP_Null && !IsVirtual(pTab) ){
+ Expr *pIpk = pList->a[ipkColumn].pExpr;
+ if( pIpk->op==TK_NULL && !IsVirtual(pTab) ){
+ sqlite3VdbeAddOp3(v, OP_NewRowid, iDataCur, regRowid, regAutoinc);
appendFlag = 1;
- pOp->opcode = OP_NewRowid;
- pOp->p1 = iDataCur;
- pOp->p2 = regRowid;
- pOp->p3 = regAutoinc;
+ }else{
+ sqlite3ExprCode(pParse, pList->a[ipkColumn].pExpr, regRowid);
}
}
/* If the PRIMARY KEY expression is NULL, then use OP_NewRowid
@@ -117463,7 +117441,7 @@ SQLITE_PRIVATE void sqlite3GenerateConstraintChecks(
/* If the IPK constraint is a REPLACE, run it last */
if( ipkTop ){
- sqlite3VdbeGoto(v, ipkTop+1);
+ sqlite3VdbeGoto(v, ipkTop);
VdbeComment((v, "Do IPK REPLACE"));
sqlite3VdbeJumpHere(v, ipkBottom);
}
@@ -117833,7 +117811,8 @@ static int xferOptimization(
if( pSrc==0 ){
return 0; /* FROM clause does not contain a real table */
}
- if( pSrc==pDest ){
+ if( pSrc->tnum==pDest->tnum && pSrc->pSchema==pDest->pSchema ){
+ testcase( pSrc!=pDest ); /* Possible due to bad sqlite_master.rootpage */
return 0; /* tab1 and tab2 may not be the same table */
}
if( HasRowid(pDest)!=HasRowid(pSrc) ){
@@ -119707,51 +119686,50 @@ SQLITE_PRIVATE void sqlite3AutoLoadExtensions(sqlite3 *db){
/* The various pragma types */
#define PragTyp_HEADER_VALUE 0
#define PragTyp_AUTO_VACUUM 1
-#define PragTyp_AUTO_VACUUM_SLACK_PAGES 2
-#define PragTyp_FLAG 3
-#define PragTyp_BUSY_TIMEOUT 4
-#define PragTyp_CACHE_SIZE 5
-#define PragTyp_CACHE_SPILL 6
-#define PragTyp_CASE_SENSITIVE_LIKE 7
-#define PragTyp_COLLATION_LIST 8
-#define PragTyp_COMPILE_OPTIONS 9
-#define PragTyp_DATA_STORE_DIRECTORY 10
-#define PragTyp_DATABASE_LIST 11
-#define PragTyp_DEFAULT_CACHE_SIZE 12
-#define PragTyp_ENCODING 13
-#define PragTyp_FOREIGN_KEY_CHECK 14
-#define PragTyp_FOREIGN_KEY_LIST 15
-#define PragTyp_FUNCTION_LIST 16
-#define PragTyp_INCREMENTAL_VACUUM 17
-#define PragTyp_INDEX_INFO 18
-#define PragTyp_INDEX_LIST 19
-#define PragTyp_INTEGRITY_CHECK 20
-#define PragTyp_JOURNAL_MODE 21
-#define PragTyp_JOURNAL_SIZE_LIMIT 22
-#define PragTyp_LOCK_PROXY_FILE 23
-#define PragTyp_LOCKING_MODE 24
-#define PragTyp_PAGE_COUNT 25
-#define PragTyp_MMAP_SIZE 26
-#define PragTyp_MODULE_LIST 27
-#define PragTyp_OPTIMIZE 28
-#define PragTyp_PAGE_SIZE 29
-#define PragTyp_PRAGMA_LIST 30
-#define PragTyp_SECURE_DELETE 31
-#define PragTyp_SHRINK_MEMORY 32
-#define PragTyp_SOFT_HEAP_LIMIT 33
-#define PragTyp_SYNCHRONOUS 34
-#define PragTyp_TABLE_INFO 35
-#define PragTyp_TEMP_STORE 36
-#define PragTyp_TEMP_STORE_DIRECTORY 37
-#define PragTyp_THREADS 38
-#define PragTyp_WAL_AUTOCHECKPOINT 39
-#define PragTyp_WAL_CHECKPOINT 40
-#define PragTyp_ACTIVATE_EXTENSIONS 41
-#define PragTyp_HEXKEY 42
-#define PragTyp_KEY 43
-#define PragTyp_LOCK_STATUS 44
-#define PragTyp_PARSER_TRACE 45
-#define PragTyp_STATS 46
+#define PragTyp_FLAG 2
+#define PragTyp_BUSY_TIMEOUT 3
+#define PragTyp_CACHE_SIZE 4
+#define PragTyp_CACHE_SPILL 5
+#define PragTyp_CASE_SENSITIVE_LIKE 6
+#define PragTyp_COLLATION_LIST 7
+#define PragTyp_COMPILE_OPTIONS 8
+#define PragTyp_DATA_STORE_DIRECTORY 9
+#define PragTyp_DATABASE_LIST 10
+#define PragTyp_DEFAULT_CACHE_SIZE 11
+#define PragTyp_ENCODING 12
+#define PragTyp_FOREIGN_KEY_CHECK 13
+#define PragTyp_FOREIGN_KEY_LIST 14
+#define PragTyp_FUNCTION_LIST 15
+#define PragTyp_INCREMENTAL_VACUUM 16
+#define PragTyp_INDEX_INFO 17
+#define PragTyp_INDEX_LIST 18
+#define PragTyp_INTEGRITY_CHECK 19
+#define PragTyp_JOURNAL_MODE 20
+#define PragTyp_JOURNAL_SIZE_LIMIT 21
+#define PragTyp_LOCK_PROXY_FILE 22
+#define PragTyp_LOCKING_MODE 23
+#define PragTyp_PAGE_COUNT 24
+#define PragTyp_MMAP_SIZE 25
+#define PragTyp_MODULE_LIST 26
+#define PragTyp_OPTIMIZE 27
+#define PragTyp_PAGE_SIZE 28
+#define PragTyp_PRAGMA_LIST 29
+#define PragTyp_SECURE_DELETE 30
+#define PragTyp_SHRINK_MEMORY 31
+#define PragTyp_SOFT_HEAP_LIMIT 32
+#define PragTyp_SYNCHRONOUS 33
+#define PragTyp_TABLE_INFO 34
+#define PragTyp_TEMP_STORE 35
+#define PragTyp_TEMP_STORE_DIRECTORY 36
+#define PragTyp_THREADS 37
+#define PragTyp_WAL_AUTOCHECKPOINT 38
+#define PragTyp_WAL_CHECKPOINT 39
+#define PragTyp_ACTIVATE_EXTENSIONS 40
+#define PragTyp_HEXKEY 41
+#define PragTyp_KEY 42
+#define PragTyp_LOCK_STATUS 43
+#define PragTyp_PARSER_TRACE 44
+#define PragTyp_STATS 45
/* Property flags associated with various pragma. */
#define PragFlg_NeedSchema 0x01 /* Force schema load before running */
@@ -119769,53 +119747,53 @@ SQLITE_PRIVATE void sqlite3AutoLoadExtensions(sqlite3 *db){
*/
static const char *const pragCName[] = {
/* 0 */ "id", /* Used by: foreign_key_list */
- /* 1 */ "seq",
- /* 2 */ "table",
- /* 3 */ "from",
- /* 4 */ "to",
- /* 5 */ "on_update",
- /* 6 */ "on_delete",
- /* 7 */ "match",
+ /* 1 */ "seq",
+ /* 2 */ "table",
+ /* 3 */ "from",
+ /* 4 */ "to",
+ /* 5 */ "on_update",
+ /* 6 */ "on_delete",
+ /* 7 */ "match",
/* 8 */ "cid", /* Used by: table_xinfo */
- /* 9 */ "name",
- /* 10 */ "type",
- /* 11 */ "notnull",
- /* 12 */ "dflt_value",
- /* 13 */ "pk",
- /* 14 */ "hidden",
+ /* 9 */ "name",
+ /* 10 */ "type",
+ /* 11 */ "notnull",
+ /* 12 */ "dflt_value",
+ /* 13 */ "pk",
+ /* 14 */ "hidden",
/* table_info reuses 8 */
/* 15 */ "seqno", /* Used by: index_xinfo */
- /* 16 */ "cid",
- /* 17 */ "name",
- /* 18 */ "desc",
- /* 19 */ "coll",
- /* 20 */ "key",
+ /* 16 */ "cid",
+ /* 17 */ "name",
+ /* 18 */ "desc",
+ /* 19 */ "coll",
+ /* 20 */ "key",
/* 21 */ "tbl", /* Used by: stats */
- /* 22 */ "idx",
- /* 23 */ "wdth",
- /* 24 */ "hght",
- /* 25 */ "flgs",
+ /* 22 */ "idx",
+ /* 23 */ "wdth",
+ /* 24 */ "hght",
+ /* 25 */ "flgs",
/* 26 */ "seq", /* Used by: index_list */
- /* 27 */ "name",
- /* 28 */ "unique",
- /* 29 */ "origin",
- /* 30 */ "partial",
+ /* 27 */ "name",
+ /* 28 */ "unique",
+ /* 29 */ "origin",
+ /* 30 */ "partial",
/* 31 */ "table", /* Used by: foreign_key_check */
- /* 32 */ "rowid",
- /* 33 */ "parent",
- /* 34 */ "fkid",
+ /* 32 */ "rowid",
+ /* 33 */ "parent",
+ /* 34 */ "fkid",
/* index_info reuses 15 */
/* 35 */ "seq", /* Used by: database_list */
- /* 36 */ "name",
- /* 37 */ "file",
+ /* 36 */ "name",
+ /* 37 */ "file",
/* 38 */ "busy", /* Used by: wal_checkpoint */
- /* 39 */ "log",
+ /* 39 */ "log",
/* 40 */ "checkpointed",
/* 41 */ "name", /* Used by: function_list */
- /* 42 */ "builtin",
+ /* 42 */ "builtin",
/* collation_list reuses 26 */
/* 43 */ "database", /* Used by: lock_status */
- /* 44 */ "status",
+ /* 44 */ "status",
/* 45 */ "cache_size", /* Used by: default_cache_size */
/* module_list pragma_list reuses 9 */
/* 46 */ "timeout", /* Used by: busy_timeout */
@@ -119851,11 +119829,6 @@ static const PragmaName aPragmaName[] = {
/* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq|PragFlg_NoColumns1,
/* ColNames: */ 0, 0,
/* iArg: */ 0 },
- {/* zName: */ "auto_vacuum_slack_pages",
- /* ePragTyp: */ PragTyp_AUTO_VACUUM_SLACK_PAGES,
- /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq|PragFlg_NoColumns1,
- /* ColNames: */ 0, 0,
- /* iArg: */ 0 },
#endif
#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
#if !defined(SQLITE_OMIT_AUTOMATIC_INDEX)
@@ -120372,7 +120345,7 @@ static const PragmaName aPragmaName[] = {
/* iArg: */ SQLITE_WriteSchema|SQLITE_NoSchemaError },
#endif
};
-/* Number of pragmas: 63 on by default, 82 total. */
+/* Number of pragmas: 62 on by default, 81 total. */
/************** End of pragma.h **********************************************/
/************** Continuing where we left off in pragma.c *********************/
@@ -121103,27 +121076,6 @@ SQLITE_PRIVATE void sqlite3Pragma(
}
#endif
- /*
- ** PRAGMA [schema.]auto_vacuum_slack_pages(N)
- **
- ** Control chunk size of auto-vacuum.
- */
-#ifndef SQLITE_OMIT_AUTOVACUUM
- case PragTyp_AUTO_VACUUM_SLACK_PAGES: {
- Btree *pBt = pDb->pBt;
- assert( pBt!=0 );
- if( !zRight ){
- returnSingleInt(v, sqlite3BtreeGetAutoVacuumSlackPages(pBt));
- }else{
- int nPages = 8;
- if( sqlite3GetInt32(zRight, &nPages) ){
- sqlite3BtreeSetAutoVacuumSlackPages(pBt, nPages);
- }
- }
- break;
- }
-#endif
-
#ifndef SQLITE_OMIT_PAGER_PRAGMAS
/*
** PRAGMA [schema.]cache_size
@@ -122997,15 +122949,11 @@ SQLITE_PRIVATE int sqlite3InitCallback(void *pInit, int argc, char **argv, char
*/
Index *pIndex;
pIndex = sqlite3FindIndex(db, argv[0], db->aDb[iDb].zDbSName);
- if( pIndex==0 ){
- /* This can occur if there exists an index on a TEMP table which
- ** has the same name as another index on a permanent index. Since
- ** the permanent table is hidden by the TEMP table, we can also
- ** safely ignore the index on the permanent table.
- */
- /* Do Nothing */;
- }else if( sqlite3GetInt32(argv[1], &pIndex->tnum)==0 ){
- corruptSchema(pData, argv[0], "invalid rootpage");
+ if( pIndex==0
+ || sqlite3GetInt32(argv[1],&pIndex->tnum)==0
+ || pIndex->tnum<2
+ ){
+ corruptSchema(pData, argv[0], pIndex?"invalid rootpage":"orphan index");
}
}
return 0;
@@ -123424,6 +123372,7 @@ static int sqlite3Prepare(
sParse.disableLookaside++;
db->lookaside.bDisable++;
}
+ sParse.disableVtab = (prepFlags & SQLITE_PREPARE_NO_VTAB)!=0;
/* Check to verify that it is possible to get a read lock on all
** database schemas. The inability to get a read lock indicates that
@@ -125542,7 +125491,12 @@ static void generateSortTail(
regRow = pDest->iSdst;
}else{
regRowid = sqlite3GetTempReg(pParse);
- regRow = sqlite3GetTempRange(pParse, nColumn);
+ if( eDest==SRT_EphemTab || eDest==SRT_Table ){
+ regRow = sqlite3GetTempReg(pParse);
+ nColumn = 0;
+ }else{
+ regRow = sqlite3GetTempRange(pParse, nColumn);
+ }
}
nKey = pOrderBy->nExpr - pSort->nOBSat;
if( pSort->sortFlags & SORTFLAG_UseSorter ){
@@ -125622,6 +125576,7 @@ static void generateSortTail(
switch( eDest ){
case SRT_Table:
case SRT_EphemTab: {
+ sqlite3VdbeAddOp3(v, OP_Column, iSortTab, nKey+bSeq, regRow);
sqlite3VdbeAddOp2(v, OP_NewRowid, iParm, regRowid);
sqlite3VdbeAddOp3(v, OP_Insert, iParm, regRow, regRowid);
sqlite3VdbeChangeP5(v, OPFLAG_APPEND);
@@ -131828,6 +131783,7 @@ static TriggerPrg *codeRowTrigger(
pSubParse->zAuthContext = pTrigger->zName;
pSubParse->eTriggerOp = pTrigger->op;
pSubParse->nQueryLoop = pParse->nQueryLoop;
+ pSubParse->disableVtab = pParse->disableVtab;
v = sqlite3GetVdbe(pSubParse);
if( v ){
@@ -147231,26 +147187,26 @@ static void disableLookaside(Parse *pParse){
# define INTERFACE 1
#endif
/************* Begin control #defines *****************************************/
-#define YYCODETYPE unsigned short int
-#define YYNOCODE 256
+#define YYCODETYPE unsigned char
+#define YYNOCODE 255
#define YYACTIONTYPE unsigned short int
#define YYWILDCARD 85
#define sqlite3ParserTOKENTYPE Token
typedef union {
int yyinit;
sqlite3ParserTOKENTYPE yy0;
- Expr* yy2;
- SrcList* yy3;
- With* yy4;
- Select* yy43;
- struct {int value; int mask;} yy239;
- Upsert* yy258;
- IdList* yy272;
- struct TrigEvent yy338;
- TriggerStep* yy347;
- int yy348;
- const char* yy360;
- ExprList* yy402;
+ const char* yy36;
+ TriggerStep* yy47;
+ With* yy91;
+ struct {int value; int mask;} yy107;
+ Expr* yy182;
+ Upsert* yy198;
+ ExprList* yy232;
+ struct TrigEvent yy300;
+ Select* yy399;
+ SrcList* yy427;
+ int yy502;
+ IdList* yy510;
} YYMINORTYPE;
#ifndef YYSTACKDEPTH
#define YYSTACKDEPTH 100
@@ -147266,17 +147222,17 @@ typedef union {
#define sqlite3ParserCTX_FETCH Parse *pParse=yypParser->pParse;
#define sqlite3ParserCTX_STORE yypParser->pParse=pParse;
#define YYFALLBACK 1
-#define YYNSTATE 491
-#define YYNRULE 341
+#define YYNSTATE 484
+#define YYNRULE 334
#define YYNTOKEN 146
-#define YY_MAX_SHIFT 490
-#define YY_MIN_SHIFTREDUCE 707
-#define YY_MAX_SHIFTREDUCE 1047
-#define YY_ERROR_ACTION 1048
-#define YY_ACCEPT_ACTION 1049
-#define YY_NO_ACTION 1050
-#define YY_MIN_REDUCE 1051
-#define YY_MAX_REDUCE 1391
+#define YY_MAX_SHIFT 483
+#define YY_MIN_SHIFTREDUCE 696
+#define YY_MAX_SHIFTREDUCE 1029
+#define YY_ERROR_ACTION 1030
+#define YY_ACCEPT_ACTION 1031
+#define YY_NO_ACTION 1032
+#define YY_MIN_REDUCE 1033
+#define YY_MAX_REDUCE 1366
/************* End control #defines *******************************************/
#define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])))
@@ -147343,505 +147299,493 @@ typedef union {
** yy_default[] Default action for each state.
**
*********** Begin parsing tables **********************************************/
-#define YY_ACTTAB_COUNT (1657)
+#define YY_ACTTAB_COUNT (1614)
static const YYACTIONTYPE yy_action[] = {
- /* 0 */ 410, 98, 95, 183, 98, 95, 183, 233, 1049, 1,
- /* 10 */ 1, 490, 2, 1053, 485, 1117, 1096, 350, 261, 352,
- /* 20 */ 120, 1311, 232, 232, 1117, 168, 1180, 1130, 479, 479,
- /* 30 */ 479, 837, 416, 330, 482, 58, 58, 344, 347, 838,
- /* 40 */ 381, 381, 381, 105, 106, 96, 1025, 1025, 901, 904,
- /* 50 */ 894, 894, 103, 103, 104, 104, 104, 104, 361, 238,
- /* 60 */ 238, 98, 95, 183, 1335, 490, 2, 1053, 410, 244,
- /* 70 */ 467, 482, 261, 352, 120, 98, 95, 183, 427, 457,
- /* 80 */ 82, 1130, 348, 942, 194, 456, 102, 102, 102, 102,
- /* 90 */ 101, 101, 100, 100, 100, 99, 383, 105, 106, 96,
- /* 100 */ 1025, 1025, 901, 904, 894, 894, 103, 103, 104, 104,
- /* 110 */ 104, 104, 387, 238, 238, 403, 283, 238, 238, 1339,
- /* 120 */ 1310, 1053, 247, 107, 269, 482, 261, 352, 120, 482,
- /* 130 */ 947, 947, 424, 214, 180, 1130, 1004, 248, 194, 1179,
- /* 140 */ 102, 102, 102, 102, 101, 101, 100, 100, 100, 99,
- /* 150 */ 383, 105, 106, 96, 1025, 1025, 901, 904, 894, 894,
- /* 160 */ 103, 103, 104, 104, 104, 104, 387, 238, 238, 206,
- /* 170 */ 9, 881, 440, 437, 436, 67, 1004, 1005, 1006, 482,
- /* 180 */ 1211, 352, 435, 403, 283, 1004, 68, 874, 98, 95,
- /* 190 */ 183, 873, 194, 210, 102, 102, 102, 102, 101, 101,
- /* 200 */ 100, 100, 100, 99, 383, 105, 106, 96, 1025, 1025,
- /* 210 */ 901, 904, 894, 894, 103, 103, 104, 104, 104, 104,
- /* 220 */ 387, 383, 873, 873, 875, 1004, 1005, 1006, 206, 336,
- /* 230 */ 1045, 440, 437, 436, 1355, 352, 99, 383, 863, 297,
- /* 240 */ 417, 435, 1091, 380, 379, 357, 143, 365, 102, 102,
- /* 250 */ 102, 102, 101, 101, 100, 100, 100, 99, 383, 105,
- /* 260 */ 106, 96, 1025, 1025, 901, 904, 894, 894, 103, 103,
- /* 270 */ 104, 104, 104, 104, 485, 282, 101, 101, 100, 100,
- /* 280 */ 100, 99, 383, 712, 713, 714, 260, 476, 1032, 352,
- /* 290 */ 1032, 143, 1046, 745, 412, 58, 58, 100, 100, 100,
- /* 300 */ 99, 383, 102, 102, 102, 102, 101, 101, 100, 100,
- /* 310 */ 100, 99, 383, 105, 106, 96, 1025, 1025, 901, 904,
- /* 320 */ 894, 894, 103, 103, 104, 104, 104, 104, 485, 1134,
- /* 330 */ 467, 260, 476, 891, 891, 902, 905, 985, 1385, 466,
- /* 340 */ 482, 1385, 1359, 352, 985, 1386, 213, 738, 1386, 58,
- /* 350 */ 58, 863, 1358, 1004, 427, 768, 102, 102, 102, 102,
- /* 360 */ 101, 101, 100, 100, 100, 99, 383, 105, 106, 96,
- /* 370 */ 1025, 1025, 901, 904, 894, 894, 103, 103, 104, 104,
- /* 380 */ 104, 104, 485, 361, 462, 356, 803, 485, 282, 398,
- /* 390 */ 270, 895, 306, 1004, 1005, 1006, 390, 352, 336, 984,
- /* 400 */ 983, 882, 305, 58, 58, 1122, 1122, 983, 58, 58,
- /* 410 */ 102, 102, 102, 102, 101, 101, 100, 100, 100, 99,
- /* 420 */ 383, 105, 106, 96, 1025, 1025, 901, 904, 894, 894,
- /* 430 */ 103, 103, 104, 104, 104, 104, 485, 275, 467, 484,
- /* 440 */ 295, 260, 476, 378, 239, 239, 308, 446, 388, 245,
- /* 450 */ 483, 352, 793, 793, 837, 868, 482, 58, 58, 308,
- /* 460 */ 421, 1046, 838, 418, 102, 102, 102, 102, 101, 101,
- /* 470 */ 100, 100, 100, 99, 383, 105, 106, 96, 1025, 1025,
- /* 480 */ 901, 904, 894, 894, 103, 103, 104, 104, 104, 104,
- /* 490 */ 9, 126, 382, 361, 109, 209, 208, 207, 272, 410,
- /* 500 */ 274, 290, 308, 293, 128, 352, 102, 102, 102, 102,
- /* 510 */ 101, 101, 100, 100, 100, 99, 383, 416, 102, 102,
- /* 520 */ 102, 102, 101, 101, 100, 100, 100, 99, 383, 105,
- /* 530 */ 106, 96, 1025, 1025, 901, 904, 894, 894, 103, 103,
- /* 540 */ 104, 104, 104, 104, 455, 168, 158, 125, 485, 1211,
- /* 550 */ 1120, 1120, 1387, 337, 1211, 167, 320, 339, 427, 246,
- /* 560 */ 402, 352, 176, 175, 273, 13, 13, 427, 249, 43,
- /* 570 */ 43, 1004, 102, 102, 102, 102, 101, 101, 100, 100,
- /* 580 */ 100, 99, 383, 1004, 150, 105, 106, 96, 1025, 1025,
- /* 590 */ 901, 904, 894, 894, 103, 103, 104, 104, 104, 104,
- /* 600 */ 1276, 1211, 159, 1211, 1074, 358, 88, 281, 86, 1129,
- /* 610 */ 177, 1004, 1005, 1006, 427, 427, 366, 352, 308, 1008,
- /* 620 */ 395, 367, 169, 1004, 1005, 1006, 748, 84, 102, 102,
- /* 630 */ 102, 102, 101, 101, 100, 100, 100, 99, 383, 1004,
- /* 640 */ 5, 105, 106, 96, 1025, 1025, 901, 904, 894, 894,
- /* 650 */ 103, 103, 104, 104, 104, 104, 1125, 288, 478, 358,
- /* 660 */ 1008, 260, 476, 127, 798, 359, 144, 748, 423, 797,
- /* 670 */ 377, 352, 237, 180, 1022, 416, 309, 1004, 341, 1004,
- /* 680 */ 1005, 1006, 268, 87, 102, 102, 102, 102, 101, 101,
- /* 690 */ 100, 100, 100, 99, 383, 105, 106, 96, 1025, 1025,
- /* 700 */ 901, 904, 894, 894, 103, 103, 104, 104, 104, 104,
- /* 710 */ 238, 238, 369, 461, 238, 238, 79, 1004, 1005, 1006,
- /* 720 */ 259, 980, 482, 186, 338, 352, 482, 279, 944, 349,
- /* 730 */ 81, 309, 944, 124, 191, 29, 181, 408, 102, 102,
- /* 740 */ 102, 102, 101, 101, 100, 100, 100, 99, 383, 105,
- /* 750 */ 94, 96, 1025, 1025, 901, 904, 894, 894, 103, 103,
- /* 760 */ 104, 104, 104, 104, 422, 250, 485, 376, 1040, 865,
- /* 770 */ 322, 409, 216, 172, 216, 1325, 411, 1004, 352, 216,
- /* 780 */ 284, 433, 1322, 81, 212, 389, 14, 57, 57, 280,
- /* 790 */ 1319, 1128, 102, 102, 102, 102, 101, 101, 100, 100,
- /* 800 */ 100, 99, 383, 106, 96, 1025, 1025, 901, 904, 894,
- /* 810 */ 894, 103, 103, 104, 104, 104, 104, 1004, 1005, 1006,
- /* 820 */ 263, 238, 238, 238, 238, 404, 298, 81, 264, 81,
- /* 830 */ 352, 758, 757, 482, 193, 482, 267, 765, 766, 458,
- /* 840 */ 1278, 931, 759, 323, 824, 102, 102, 102, 102, 101,
- /* 850 */ 101, 100, 100, 100, 99, 383, 96, 1025, 1025, 901,
- /* 860 */ 904, 894, 894, 103, 103, 104, 104, 104, 104, 91,
- /* 870 */ 477, 1004, 4, 441, 235, 1004, 927, 822, 963, 212,
- /* 880 */ 1165, 760, 931, 1164, 164, 831, 480, 432, 216, 941,
- /* 890 */ 940, 941, 940, 964, 397, 240, 143, 102, 102, 102,
- /* 900 */ 102, 101, 101, 100, 100, 100, 99, 383, 965, 384,
- /* 910 */ 750, 1004, 1005, 1006, 210, 1004, 1005, 1006, 394, 459,
- /* 920 */ 372, 474, 405, 104, 104, 104, 104, 97, 276, 779,
- /* 930 */ 6, 143, 217, 1299, 881, 795, 260, 476, 93, 780,
- /* 940 */ 89, 89, 823, 1298, 860, 419, 3, 90, 485, 384,
- /* 950 */ 487, 486, 182, 485, 873, 102, 102, 102, 102, 101,
- /* 960 */ 101, 100, 100, 100, 99, 383, 357, 1023, 285, 44,
- /* 970 */ 44, 260, 476, 1161, 12, 12, 414, 822, 732, 289,
- /* 980 */ 822, 122, 300, 1004, 1100, 873, 873, 875, 876, 20,
- /* 990 */ 1334, 993, 386, 292, 217, 242, 796, 1348, 963, 93,
- /* 1000 */ 334, 334, 333, 227, 331, 993, 386, 721, 1023, 242,
- /* 1010 */ 374, 485, 294, 964, 334, 334, 333, 227, 331, 168,
- /* 1020 */ 187, 721, 266, 1004, 1005, 1006, 485, 23, 965, 1023,
- /* 1030 */ 265, 351, 10, 10, 187, 296, 266, 91, 477, 1113,
- /* 1040 */ 4, 485, 877, 1099, 265, 1098, 363, 10, 10, 473,
- /* 1050 */ 1097, 252, 301, 252, 480, 182, 415, 485, 24, 310,
- /* 1060 */ 189, 368, 10, 10, 91, 477, 257, 4, 190, 485,
- /* 1070 */ 1023, 138, 188, 311, 189, 1152, 370, 384, 10, 10,
- /* 1080 */ 822, 480, 190, 877, 1173, 138, 188, 371, 1210, 474,
- /* 1090 */ 34, 34, 251, 224, 241, 307, 443, 302, 442, 211,
- /* 1100 */ 123, 1148, 881, 1159, 384, 300, 353, 1071, 89, 89,
- /* 1110 */ 802, 260, 476, 393, 471, 90, 474, 384, 487, 486,
- /* 1120 */ 353, 472, 873, 1216, 428, 260, 476, 741, 1080, 881,
- /* 1130 */ 393, 392, 1073, 1062, 391, 89, 89, 734, 485, 238,
- /* 1140 */ 238, 724, 90, 1061, 384, 487, 486, 1063, 391, 873,
- /* 1150 */ 1342, 482, 881, 873, 873, 875, 876, 20, 170, 10,
- /* 1160 */ 10, 230, 83, 477, 1145, 4, 8, 741, 874, 1280,
- /* 1170 */ 174, 335, 873, 464, 313, 315, 317, 1004, 734, 480,
- /* 1180 */ 873, 873, 875, 876, 20, 242, 1280, 1282, 185, 1195,
- /* 1190 */ 334, 334, 333, 227, 331, 393, 396, 721, 271, 445,
- /* 1200 */ 401, 485, 384, 873, 873, 875, 278, 1203, 380, 379,
- /* 1210 */ 187, 343, 266, 449, 474, 438, 1029, 1004, 1005, 1006,
- /* 1220 */ 265, 1031, 45, 45, 178, 798, 924, 881, 304, 1030,
- /* 1230 */ 797, 1273, 413, 89, 89, 104, 104, 104, 104, 1096,
- /* 1240 */ 90, 1272, 384, 487, 486, 238, 238, 873, 319, 475,
- /* 1250 */ 189, 1280, 328, 1032, 1345, 1032, 173, 482, 190, 452,
- /* 1260 */ 1040, 138, 188, 1269, 485, 470, 485, 102, 102, 102,
- /* 1270 */ 102, 101, 101, 100, 100, 100, 99, 383, 873, 873,
- /* 1280 */ 875, 876, 20, 146, 485, 46, 46, 47, 47, 485,
- /* 1290 */ 219, 238, 238, 485, 1318, 468, 353, 238, 238, 485,
- /* 1300 */ 447, 260, 476, 482, 485, 58, 58, 1316, 485, 482,
- /* 1310 */ 39, 39, 66, 1037, 48, 48, 69, 360, 407, 1200,
- /* 1320 */ 49, 49, 156, 26, 391, 35, 35, 238, 238, 36,
- /* 1330 */ 36, 141, 238, 238, 148, 79, 485, 399, 485, 482,
- /* 1340 */ 467, 485, 1192, 151, 482, 448, 485, 152, 485, 469,
- /* 1350 */ 485, 400, 485, 153, 154, 485, 431, 38, 38, 50,
- /* 1360 */ 50, 340, 51, 51, 485, 196, 406, 52, 52, 11,
- /* 1370 */ 11, 53, 53, 111, 111, 485, 54, 54, 485, 342,
- /* 1380 */ 27, 485, 1267, 1206, 485, 40, 40, 160, 485, 420,
- /* 1390 */ 485, 200, 485, 74, 426, 485, 55, 55, 485, 56,
- /* 1400 */ 56, 485, 41, 41, 287, 132, 132, 1287, 485, 133,
- /* 1410 */ 133, 63, 63, 42, 42, 202, 59, 59, 485, 112,
- /* 1420 */ 112, 485, 60, 60, 485, 165, 485, 231, 485, 113,
- /* 1430 */ 113, 485, 429, 485, 291, 485, 203, 485, 204, 114,
- /* 1440 */ 114, 485, 110, 110, 485, 131, 131, 130, 130, 118,
- /* 1450 */ 118, 485, 117, 117, 115, 115, 116, 116, 62, 62,
- /* 1460 */ 485, 444, 64, 64, 1064, 61, 61, 1107, 1116, 345,
- /* 1470 */ 1115, 1114, 33, 33, 373, 346, 1088, 750, 375, 303,
- /* 1480 */ 1087, 37, 37, 1106, 1086, 1357, 255, 460, 78, 451,
- /* 1490 */ 454, 256, 218, 7, 321, 1253, 85, 108, 1156, 465,
- /* 1500 */ 258, 312, 80, 1157, 1155, 463, 225, 1070, 25, 314,
- /* 1510 */ 488, 999, 324, 316, 226, 229, 228, 489, 327, 325,
- /* 1520 */ 1138, 326, 1154, 1059, 354, 134, 1054, 1303, 318, 121,
- /* 1530 */ 1304, 253, 708, 385, 135, 1302, 171, 262, 1301, 184,
- /* 1540 */ 243, 119, 1084, 939, 937, 136, 857, 1083, 65, 147,
- /* 1550 */ 1081, 137, 149, 192, 782, 195, 277, 953, 155, 861,
- /* 1560 */ 139, 362, 157, 364, 70, 71, 72, 140, 73, 145,
- /* 1570 */ 355, 956, 197, 198, 952, 129, 15, 199, 286, 216,
- /* 1580 */ 1034, 162, 425, 201, 945, 161, 28, 723, 430, 305,
- /* 1590 */ 163, 761, 205, 75, 434, 299, 16, 17, 439, 76,
- /* 1600 */ 254, 142, 880, 879, 907, 830, 988, 30, 77, 31,
- /* 1610 */ 450, 989, 179, 453, 234, 236, 166, 825, 215, 93,
- /* 1620 */ 922, 81, 908, 906, 18, 910, 962, 220, 961, 221,
- /* 1630 */ 19, 911, 21, 32, 481, 878, 733, 92, 22, 332,
- /* 1640 */ 792, 329, 222, 223, 994, 1050, 1050, 1350, 1050, 1050,
- /* 1650 */ 1050, 1050, 1050, 1050, 1050, 1050, 1349,
+ /* 0 */ 478, 1102, 1102, 97, 94, 182, 97, 94, 182, 1031,
+ /* 10 */ 1, 1, 483, 1033, 229, 229, 347, 448, 258, 1114,
+ /* 20 */ 119, 57, 57, 1291, 1097, 1076, 475, 1110, 824, 449,
+ /* 30 */ 475, 1160, 5, 1097, 214, 123, 825, 28, 12, 12,
+ /* 40 */ 303, 104, 105, 95, 1007, 1007, 888, 891, 881, 881,
+ /* 50 */ 102, 102, 103, 103, 103, 103, 460, 403, 1330, 235,
+ /* 60 */ 235, 235, 235, 236, 236, 450, 1071, 1311, 483, 1033,
+ /* 70 */ 1005, 475, 347, 475, 258, 475, 119, 211, 179, 81,
+ /* 80 */ 97, 94, 182, 1110, 191, 125, 101, 101, 101, 101,
+ /* 90 */ 100, 100, 99, 99, 99, 98, 378, 104, 105, 95,
+ /* 100 */ 1007, 1007, 888, 891, 881, 881, 102, 102, 103, 103,
+ /* 110 */ 103, 103, 380, 1005, 108, 235, 235, 345, 100, 100,
+ /* 120 */ 99, 99, 99, 98, 378, 106, 241, 475, 347, 101,
+ /* 130 */ 101, 101, 101, 100, 100, 99, 99, 99, 98, 378,
+ /* 140 */ 191, 378, 101, 101, 101, 101, 100, 100, 99, 99,
+ /* 150 */ 99, 98, 378, 104, 105, 95, 1007, 1007, 888, 891,
+ /* 160 */ 881, 881, 102, 102, 103, 103, 103, 103, 380, 99,
+ /* 170 */ 99, 99, 98, 378, 478, 396, 278, 203, 185, 66,
+ /* 180 */ 433, 430, 429, 986, 347, 175, 174, 1159, 210, 67,
+ /* 190 */ 428, 878, 878, 889, 892, 57, 57, 342, 101, 101,
+ /* 200 */ 101, 101, 100, 100, 99, 99, 99, 98, 378, 104,
+ /* 210 */ 105, 95, 1007, 1007, 888, 891, 881, 881, 102, 102,
+ /* 220 */ 103, 103, 103, 103, 1022, 986, 987, 988, 203, 868,
+ /* 230 */ 460, 433, 430, 429, 230, 343, 97, 94, 182, 459,
+ /* 240 */ 347, 428, 968, 1360, 292, 861, 1360, 98, 378, 860,
+ /* 250 */ 986, 882, 375, 374, 101, 101, 101, 101, 100, 100,
+ /* 260 */ 99, 99, 99, 98, 378, 104, 105, 95, 1007, 1007,
+ /* 270 */ 888, 891, 881, 881, 102, 102, 103, 103, 103, 103,
+ /* 280 */ 860, 860, 862, 478, 1191, 478, 257, 469, 97, 94,
+ /* 290 */ 182, 167, 986, 987, 988, 290, 347, 1014, 1004, 1014,
+ /* 300 */ 732, 850, 986, 334, 57, 57, 57, 57, 966, 142,
+ /* 310 */ 101, 101, 101, 101, 100, 100, 99, 99, 99, 98,
+ /* 320 */ 378, 104, 105, 95, 1007, 1007, 888, 891, 881, 881,
+ /* 330 */ 102, 102, 103, 103, 103, 103, 478, 790, 277, 460,
+ /* 340 */ 1191, 455, 405, 478, 986, 987, 988, 1334, 439, 257,
+ /* 350 */ 469, 360, 347, 472, 472, 472, 725, 56, 56, 285,
+ /* 360 */ 336, 288, 142, 420, 57, 57, 101, 101, 101, 101,
+ /* 370 */ 100, 100, 99, 99, 99, 98, 378, 104, 105, 95,
+ /* 380 */ 1007, 1007, 888, 891, 881, 881, 102, 102, 103, 103,
+ /* 390 */ 103, 103, 235, 235, 270, 478, 351, 968, 1361, 373,
+ /* 400 */ 171, 1361, 257, 469, 475, 383, 986, 361, 347, 376,
+ /* 410 */ 376, 376, 869, 318, 929, 850, 57, 57, 87, 401,
+ /* 420 */ 85, 149, 101, 101, 101, 101, 100, 100, 99, 99,
+ /* 430 */ 99, 98, 378, 104, 105, 95, 1007, 1007, 888, 891,
+ /* 440 */ 881, 881, 102, 102, 103, 103, 103, 103, 986, 987,
+ /* 450 */ 988, 377, 277, 391, 265, 477, 8, 381, 267, 356,
+ /* 460 */ 269, 167, 986, 966, 347, 934, 934, 417, 855, 325,
+ /* 470 */ 315, 414, 931, 339, 411, 263, 931, 163, 101, 101,
+ /* 480 */ 101, 101, 100, 100, 99, 99, 99, 98, 378, 104,
+ /* 490 */ 105, 95, 1007, 1007, 888, 891, 881, 881, 102, 102,
+ /* 500 */ 103, 103, 103, 103, 986, 987, 988, 235, 235, 415,
+ /* 510 */ 476, 478, 780, 780, 699, 700, 701, 396, 278, 475,
+ /* 520 */ 347, 166, 1100, 1100, 268, 264, 395, 206, 205, 204,
+ /* 530 */ 454, 275, 42, 42, 101, 101, 101, 101, 100, 100,
+ /* 540 */ 99, 99, 99, 98, 378, 104, 105, 95, 1007, 1007,
+ /* 550 */ 888, 891, 881, 881, 102, 102, 103, 103, 103, 103,
+ /* 560 */ 386, 180, 1260, 235, 235, 356, 478, 317, 331, 1027,
+ /* 570 */ 331, 967, 1362, 332, 256, 475, 347, 386, 385, 1260,
+ /* 580 */ 1262, 303, 303, 344, 1108, 1298, 1051, 43, 43, 442,
+ /* 590 */ 101, 101, 101, 101, 100, 100, 99, 99, 99, 98,
+ /* 600 */ 378, 104, 105, 95, 1007, 1007, 888, 891, 881, 881,
+ /* 610 */ 102, 102, 103, 103, 103, 103, 235, 235, 235, 235,
+ /* 620 */ 403, 235, 235, 403, 785, 356, 127, 124, 475, 784,
+ /* 630 */ 475, 242, 347, 475, 1028, 420, 1028, 168, 420, 420,
+ /* 640 */ 445, 420, 386, 463, 1260, 83, 101, 101, 101, 101,
+ /* 650 */ 100, 100, 99, 99, 99, 98, 378, 104, 105, 95,
+ /* 660 */ 1007, 1007, 888, 891, 881, 881, 102, 102, 103, 103,
+ /* 670 */ 103, 103, 235, 235, 478, 235, 235, 1290, 478, 1191,
+ /* 680 */ 1256, 1109, 1191, 1105, 475, 382, 420, 475, 347, 245,
+ /* 690 */ 303, 243, 246, 990, 304, 11, 11, 409, 304, 33,
+ /* 700 */ 33, 86, 101, 101, 101, 101, 100, 100, 99, 99,
+ /* 710 */ 99, 98, 378, 104, 105, 95, 1007, 1007, 888, 891,
+ /* 720 */ 881, 881, 102, 102, 103, 103, 103, 103, 283, 478,
+ /* 730 */ 364, 478, 1295, 1191, 371, 126, 990, 1054, 353, 471,
+ /* 740 */ 353, 8, 257, 469, 347, 176, 362, 354, 143, 416,
+ /* 750 */ 44, 44, 45, 45, 103, 103, 103, 103, 101, 101,
+ /* 760 */ 101, 101, 100, 100, 99, 99, 99, 98, 378, 104,
+ /* 770 */ 93, 95, 1007, 1007, 888, 891, 881, 881, 102, 102,
+ /* 780 */ 103, 103, 103, 103, 478, 451, 478, 244, 101, 101,
+ /* 790 */ 101, 101, 100, 100, 99, 99, 99, 98, 378, 347,
+ /* 800 */ 372, 234, 179, 188, 207, 46, 46, 47, 47, 409,
+ /* 810 */ 409, 410, 80, 438, 101, 101, 101, 101, 100, 100,
+ /* 820 */ 99, 99, 99, 98, 378, 105, 95, 1007, 1007, 888,
+ /* 830 */ 891, 881, 881, 102, 102, 103, 103, 103, 103, 785,
+ /* 840 */ 1333, 478, 824, 755, 784, 963, 274, 262, 333, 80,
+ /* 850 */ 825, 745, 744, 347, 78, 369, 1258, 157, 352, 122,
+ /* 860 */ 752, 753, 48, 48, 13, 928, 735, 928, 452, 101,
+ /* 870 */ 101, 101, 101, 100, 100, 99, 99, 99, 98, 378,
+ /* 880 */ 95, 1007, 1007, 888, 891, 881, 881, 102, 102, 103,
+ /* 890 */ 103, 103, 103, 90, 470, 986, 3, 721, 737, 276,
+ /* 900 */ 247, 711, 301, 407, 397, 950, 190, 1145, 852, 735,
+ /* 910 */ 473, 213, 300, 402, 1144, 232, 213, 390, 809, 927,
+ /* 920 */ 951, 927, 746, 101, 101, 101, 101, 100, 100, 99,
+ /* 930 */ 99, 99, 98, 378, 379, 366, 952, 986, 987, 988,
+ /* 940 */ 721, 221, 238, 302, 436, 297, 435, 208, 467, 90,
+ /* 950 */ 470, 986, 3, 295, 434, 388, 22, 766, 142, 404,
+ /* 960 */ 142, 868, 213, 394, 747, 1301, 473, 88, 88, 767,
+ /* 970 */ 158, 271, 1279, 1080, 89, 167, 379, 480, 479, 1079,
+ /* 980 */ 1278, 860, 387, 214, 375, 374, 408, 346, 23, 911,
+ /* 990 */ 379, 1078, 1011, 986, 987, 988, 181, 1013, 257, 469,
+ /* 1000 */ 257, 469, 412, 367, 467, 1012, 280, 249, 986, 249,
+ /* 1010 */ 4, 425, 860, 860, 862, 863, 19, 868, 1141, 1005,
+ /* 1020 */ 284, 809, 918, 88, 88, 789, 1249, 287, 289, 1014,
+ /* 1030 */ 89, 1014, 379, 480, 479, 986, 2, 860, 398, 207,
+ /* 1040 */ 90, 470, 478, 3, 291, 478, 279, 1132, 986, 80,
+ /* 1050 */ 986, 987, 988, 461, 1093, 1077, 440, 473, 82, 470,
+ /* 1060 */ 847, 3, 1005, 57, 57, 918, 38, 38, 860, 860,
+ /* 1070 */ 862, 863, 19, 426, 986, 473, 209, 986, 987, 988,
+ /* 1080 */ 293, 379, 237, 80, 478, 235, 235, 986, 235, 235,
+ /* 1090 */ 986, 987, 988, 352, 864, 467, 950, 475, 460, 379,
+ /* 1100 */ 475, 441, 296, 305, 811, 9, 9, 462, 868, 295,
+ /* 1110 */ 306, 951, 1153, 467, 88, 88, 986, 987, 988, 358,
+ /* 1120 */ 809, 89, 1190, 379, 480, 479, 868, 952, 860, 986,
+ /* 1130 */ 987, 988, 88, 88, 1128, 254, 478, 864, 1139, 89,
+ /* 1140 */ 464, 379, 480, 479, 914, 465, 860, 209, 466, 818,
+ /* 1150 */ 1196, 478, 213, 478, 1060, 1053, 810, 34, 34, 860,
+ /* 1160 */ 860, 862, 863, 19, 1042, 1041, 103, 103, 103, 103,
+ /* 1170 */ 96, 1043, 9, 9, 9, 9, 1317, 860, 860, 862,
+ /* 1180 */ 863, 19, 1310, 976, 239, 421, 363, 1323, 365, 329,
+ /* 1190 */ 329, 328, 224, 326, 478, 169, 708, 1125, 181, 478,
+ /* 1200 */ 101, 101, 101, 101, 100, 100, 99, 99, 99, 98,
+ /* 1210 */ 378, 261, 227, 7, 308, 9, 9, 478, 310, 260,
+ /* 1220 */ 9, 9, 478, 809, 478, 312, 478, 173, 478, 248,
+ /* 1230 */ 782, 330, 478, 92, 457, 478, 184, 728, 35, 35,
+ /* 1240 */ 389, 1175, 266, 37, 37, 49, 49, 50, 50, 51,
+ /* 1250 */ 51, 1183, 186, 10, 10, 478, 52, 52, 177, 719,
+ /* 1260 */ 187, 478, 121, 137, 868, 976, 239, 431, 478, 338,
+ /* 1270 */ 478, 329, 329, 328, 224, 326, 110, 110, 708, 728,
+ /* 1280 */ 861, 1076, 53, 53, 860, 478, 299, 478, 273, 39,
+ /* 1290 */ 39, 54, 54, 261, 406, 1253, 783, 478, 348, 92,
+ /* 1300 */ 478, 260, 478, 257, 469, 1252, 55, 55, 40, 40,
+ /* 1310 */ 478, 314, 323, 468, 478, 860, 860, 862, 131, 131,
+ /* 1320 */ 172, 132, 132, 62, 62, 1320, 384, 478, 1022, 478,
+ /* 1330 */ 1019, 41, 41, 145, 186, 58, 58, 478, 65, 68,
+ /* 1340 */ 478, 216, 187, 478, 400, 137, 478, 1180, 111, 111,
+ /* 1350 */ 59, 59, 355, 478, 155, 478, 140, 478, 112, 112,
+ /* 1360 */ 478, 113, 113, 25, 109, 109, 147, 130, 130, 478,
+ /* 1370 */ 78, 478, 392, 478, 129, 129, 117, 117, 116, 116,
+ /* 1380 */ 348, 114, 114, 478, 1172, 257, 469, 393, 478, 150,
+ /* 1390 */ 115, 115, 61, 61, 63, 63, 424, 478, 337, 151,
+ /* 1400 */ 152, 193, 153, 26, 60, 60, 335, 413, 384, 32,
+ /* 1410 */ 32, 197, 399, 1186, 159, 1247, 419, 73, 36, 36,
+ /* 1420 */ 228, 199, 164, 286, 1267, 282, 200, 422, 1044, 340,
+ /* 1430 */ 201, 437, 1096, 1095, 1094, 368, 737, 1087, 341, 1067,
+ /* 1440 */ 370, 1068, 298, 453, 77, 252, 1136, 253, 1066, 1332,
+ /* 1450 */ 307, 215, 309, 1086, 444, 6, 311, 447, 1137, 316,
+ /* 1460 */ 1135, 1233, 1134, 84, 255, 313, 458, 107, 222, 79,
+ /* 1470 */ 456, 1050, 24, 481, 981, 223, 225, 226, 482, 349,
+ /* 1480 */ 1039, 1118, 1034, 133, 321, 319, 320, 322, 170, 120,
+ /* 1490 */ 1283, 350, 1284, 250, 259, 134, 1282, 1281, 183, 240,
+ /* 1500 */ 118, 926, 144, 1064, 1063, 924, 64, 844, 135, 1061,
+ /* 1510 */ 146, 136, 189, 148, 769, 272, 192, 940, 154, 138,
+ /* 1520 */ 848, 357, 359, 156, 69, 139, 70, 71, 72, 943,
+ /* 1530 */ 194, 195, 939, 14, 128, 196, 932, 281, 213, 160,
+ /* 1540 */ 1016, 418, 198, 161, 27, 710, 423, 300, 202, 427,
+ /* 1550 */ 432, 748, 162, 74, 15, 141, 294, 16, 75, 251,
+ /* 1560 */ 867, 866, 894, 178, 971, 29, 76, 30, 443, 972,
+ /* 1570 */ 165, 446, 231, 233, 812, 779, 212, 817, 92, 80,
+ /* 1580 */ 909, 895, 893, 897, 949, 17, 898, 948, 18, 217,
+ /* 1590 */ 218, 20, 31, 474, 865, 720, 91, 327, 21, 977,
+ /* 1600 */ 324, 1032, 1032, 219, 220, 1032, 1032, 1032, 1325, 1032,
+ /* 1610 */ 1032, 1032, 1032, 1324,
};
static const YYCODETYPE yy_lookahead[] = {
- /* 0 */ 154, 227, 228, 229, 227, 228, 229, 173, 146, 147,
- /* 10 */ 148, 149, 150, 151, 154, 182, 183, 175, 156, 19,
- /* 20 */ 158, 247, 197, 198, 191, 154, 178, 165, 170, 171,
- /* 30 */ 172, 31, 154, 162, 209, 175, 176, 166, 175, 39,
- /* 40 */ 170, 171, 172, 43, 44, 45, 46, 47, 48, 49,
- /* 50 */ 50, 51, 52, 53, 54, 55, 56, 57, 154, 197,
- /* 60 */ 198, 227, 228, 229, 148, 149, 150, 151, 154, 223,
- /* 70 */ 210, 209, 156, 19, 158, 227, 228, 229, 154, 219,
- /* 80 */ 26, 165, 175, 11, 222, 165, 86, 87, 88, 89,
- /* 90 */ 90, 91, 92, 93, 94, 95, 96, 43, 44, 45,
- /* 100 */ 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
- /* 110 */ 56, 57, 250, 197, 198, 111, 112, 197, 198, 149,
- /* 120 */ 196, 151, 244, 69, 220, 209, 156, 19, 158, 209,
- /* 130 */ 110, 111, 112, 213, 214, 165, 59, 223, 222, 178,
- /* 140 */ 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
- /* 150 */ 96, 43, 44, 45, 46, 47, 48, 49, 50, 51,
- /* 160 */ 52, 53, 54, 55, 56, 57, 250, 197, 198, 102,
- /* 170 */ 173, 84, 105, 106, 107, 67, 99, 100, 101, 209,
- /* 180 */ 154, 19, 115, 111, 112, 59, 24, 100, 227, 228,
- /* 190 */ 229, 104, 222, 46, 86, 87, 88, 89, 90, 91,
- /* 200 */ 92, 93, 94, 95, 96, 43, 44, 45, 46, 47,
- /* 210 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
- /* 220 */ 250, 96, 135, 136, 137, 99, 100, 101, 102, 22,
- /* 230 */ 23, 105, 106, 107, 174, 19, 95, 96, 73, 23,
- /* 240 */ 243, 115, 182, 90, 91, 98, 81, 221, 86, 87,
- /* 250 */ 88, 89, 90, 91, 92, 93, 94, 95, 96, 43,
- /* 260 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
- /* 270 */ 54, 55, 56, 57, 154, 110, 90, 91, 92, 93,
- /* 280 */ 94, 95, 96, 7, 8, 9, 121, 122, 135, 19,
- /* 290 */ 137, 81, 85, 23, 154, 175, 176, 92, 93, 94,
- /* 300 */ 95, 96, 86, 87, 88, 89, 90, 91, 92, 93,
- /* 310 */ 94, 95, 96, 43, 44, 45, 46, 47, 48, 49,
- /* 320 */ 50, 51, 52, 53, 54, 55, 56, 57, 154, 198,
- /* 330 */ 210, 121, 122, 46, 47, 48, 49, 22, 23, 219,
- /* 340 */ 209, 26, 188, 19, 22, 23, 26, 23, 26, 175,
- /* 350 */ 176, 73, 23, 59, 154, 26, 86, 87, 88, 89,
- /* 360 */ 90, 91, 92, 93, 94, 95, 96, 43, 44, 45,
- /* 370 */ 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
- /* 380 */ 56, 57, 154, 154, 210, 159, 92, 154, 110, 111,
- /* 390 */ 112, 104, 104, 99, 100, 101, 196, 19, 22, 23,
- /* 400 */ 85, 23, 114, 175, 176, 193, 194, 85, 175, 176,
- /* 410 */ 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
- /* 420 */ 96, 43, 44, 45, 46, 47, 48, 49, 50, 51,
- /* 430 */ 52, 53, 54, 55, 56, 57, 154, 16, 210, 154,
- /* 440 */ 16, 121, 122, 210, 197, 198, 154, 219, 248, 220,
- /* 450 */ 117, 19, 119, 120, 31, 23, 209, 175, 176, 154,
- /* 460 */ 234, 85, 39, 237, 86, 87, 88, 89, 90, 91,
- /* 470 */ 92, 93, 94, 95, 96, 43, 44, 45, 46, 47,
- /* 480 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
- /* 490 */ 173, 199, 210, 154, 22, 110, 111, 112, 77, 154,
- /* 500 */ 79, 77, 154, 79, 199, 19, 86, 87, 88, 89,
- /* 510 */ 90, 91, 92, 93, 94, 95, 96, 154, 86, 87,
- /* 520 */ 88, 89, 90, 91, 92, 93, 94, 95, 96, 43,
- /* 530 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
- /* 540 */ 54, 55, 56, 57, 154, 154, 22, 199, 154, 154,
- /* 550 */ 193, 194, 253, 254, 154, 238, 154, 166, 154, 220,
- /* 560 */ 243, 19, 90, 91, 143, 175, 176, 154, 223, 175,
- /* 570 */ 176, 59, 86, 87, 88, 89, 90, 91, 92, 93,
- /* 580 */ 94, 95, 96, 59, 72, 43, 44, 45, 46, 47,
- /* 590 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
- /* 600 */ 196, 154, 22, 154, 168, 169, 140, 244, 142, 196,
- /* 610 */ 26, 99, 100, 101, 154, 154, 221, 19, 154, 59,
- /* 620 */ 224, 221, 24, 99, 100, 101, 59, 141, 86, 87,
- /* 630 */ 88, 89, 90, 91, 92, 93, 94, 95, 96, 59,
- /* 640 */ 22, 43, 44, 45, 46, 47, 48, 49, 50, 51,
- /* 650 */ 52, 53, 54, 55, 56, 57, 196, 196, 168, 169,
- /* 660 */ 100, 121, 122, 199, 118, 251, 252, 100, 221, 123,
- /* 670 */ 221, 19, 213, 214, 26, 154, 154, 59, 165, 99,
- /* 680 */ 100, 101, 165, 141, 86, 87, 88, 89, 90, 91,
- /* 690 */ 92, 93, 94, 95, 96, 43, 44, 45, 46, 47,
- /* 700 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
- /* 710 */ 197, 198, 190, 154, 197, 198, 132, 99, 100, 101,
- /* 720 */ 202, 23, 209, 15, 26, 19, 209, 23, 29, 211,
- /* 730 */ 26, 154, 33, 22, 24, 24, 154, 224, 86, 87,
- /* 740 */ 88, 89, 90, 91, 92, 93, 94, 95, 96, 43,
- /* 750 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
- /* 760 */ 54, 55, 56, 57, 65, 244, 154, 190, 60, 23,
- /* 770 */ 154, 23, 26, 125, 26, 154, 23, 59, 19, 26,
- /* 780 */ 23, 23, 154, 26, 26, 154, 22, 175, 176, 165,
- /* 790 */ 154, 165, 86, 87, 88, 89, 90, 91, 92, 93,
- /* 800 */ 94, 95, 96, 44, 45, 46, 47, 48, 49, 50,
- /* 810 */ 51, 52, 53, 54, 55, 56, 57, 99, 100, 101,
- /* 820 */ 154, 197, 198, 197, 198, 61, 23, 26, 154, 26,
- /* 830 */ 19, 103, 104, 209, 124, 209, 154, 7, 8, 19,
- /* 840 */ 154, 59, 35, 231, 126, 86, 87, 88, 89, 90,
- /* 850 */ 91, 92, 93, 94, 95, 96, 45, 46, 47, 48,
- /* 860 */ 49, 50, 51, 52, 53, 54, 55, 56, 57, 19,
- /* 870 */ 20, 59, 22, 66, 23, 59, 23, 26, 12, 26,
- /* 880 */ 154, 74, 100, 154, 72, 23, 36, 19, 26, 135,
- /* 890 */ 135, 137, 137, 27, 154, 22, 81, 86, 87, 88,
- /* 900 */ 89, 90, 91, 92, 93, 94, 95, 96, 42, 59,
- /* 910 */ 109, 99, 100, 101, 46, 99, 100, 101, 103, 99,
- /* 920 */ 113, 71, 112, 54, 55, 56, 57, 58, 154, 63,
- /* 930 */ 22, 81, 24, 154, 84, 23, 121, 122, 26, 73,
- /* 940 */ 90, 91, 126, 154, 134, 154, 22, 97, 154, 99,
- /* 950 */ 100, 101, 101, 154, 104, 86, 87, 88, 89, 90,
- /* 960 */ 91, 92, 93, 94, 95, 96, 98, 59, 154, 175,
- /* 970 */ 176, 121, 122, 154, 175, 176, 19, 126, 23, 154,
- /* 980 */ 26, 26, 114, 59, 184, 135, 136, 137, 138, 139,
- /* 990 */ 0, 1, 2, 154, 24, 5, 23, 124, 12, 26,
- /* 1000 */ 10, 11, 12, 13, 14, 1, 2, 17, 100, 5,
- /* 1010 */ 19, 154, 154, 27, 10, 11, 12, 13, 14, 154,
- /* 1020 */ 30, 17, 32, 99, 100, 101, 154, 22, 42, 59,
- /* 1030 */ 40, 166, 175, 176, 30, 154, 32, 19, 20, 154,
- /* 1040 */ 22, 154, 59, 184, 40, 184, 189, 175, 176, 63,
- /* 1050 */ 154, 186, 154, 188, 36, 101, 99, 154, 53, 154,
- /* 1060 */ 70, 189, 175, 176, 19, 20, 212, 22, 78, 154,
- /* 1070 */ 100, 81, 82, 154, 70, 215, 189, 59, 175, 176,
- /* 1080 */ 126, 36, 78, 100, 154, 81, 82, 96, 154, 71,
- /* 1090 */ 175, 176, 189, 102, 103, 104, 105, 106, 107, 108,
- /* 1100 */ 22, 154, 84, 154, 59, 114, 116, 165, 90, 91,
- /* 1110 */ 92, 121, 122, 154, 154, 97, 71, 99, 100, 101,
- /* 1120 */ 116, 194, 104, 154, 240, 121, 122, 59, 154, 84,
- /* 1130 */ 171, 172, 154, 154, 144, 90, 91, 59, 154, 197,
- /* 1140 */ 198, 21, 97, 154, 99, 100, 101, 154, 144, 104,
- /* 1150 */ 154, 209, 84, 135, 136, 137, 138, 139, 200, 175,
- /* 1160 */ 176, 239, 19, 20, 212, 22, 201, 99, 100, 154,
- /* 1170 */ 173, 152, 104, 189, 212, 212, 212, 59, 100, 36,
- /* 1180 */ 135, 136, 137, 138, 139, 5, 171, 172, 249, 204,
- /* 1190 */ 10, 11, 12, 13, 14, 236, 216, 17, 216, 92,
- /* 1200 */ 80, 154, 59, 135, 136, 137, 245, 204, 90, 91,
- /* 1210 */ 30, 204, 32, 165, 71, 179, 98, 99, 100, 101,
- /* 1220 */ 40, 103, 175, 176, 187, 118, 106, 84, 178, 111,
- /* 1230 */ 123, 178, 245, 90, 91, 54, 55, 56, 57, 183,
- /* 1240 */ 97, 178, 99, 100, 101, 197, 198, 104, 216, 233,
- /* 1250 */ 70, 236, 203, 135, 157, 137, 201, 209, 78, 165,
- /* 1260 */ 60, 81, 82, 143, 154, 165, 154, 86, 87, 88,
- /* 1270 */ 89, 90, 91, 92, 93, 94, 95, 96, 135, 136,
- /* 1280 */ 137, 138, 139, 249, 154, 175, 176, 175, 176, 154,
- /* 1290 */ 124, 197, 198, 154, 161, 165, 116, 197, 198, 154,
- /* 1300 */ 165, 121, 122, 209, 154, 175, 176, 161, 154, 209,
- /* 1310 */ 175, 176, 246, 38, 175, 176, 246, 161, 98, 226,
- /* 1320 */ 175, 176, 22, 225, 144, 175, 176, 197, 198, 175,
- /* 1330 */ 176, 43, 197, 198, 192, 132, 154, 18, 154, 209,
- /* 1340 */ 210, 154, 204, 195, 209, 210, 154, 195, 154, 219,
- /* 1350 */ 154, 161, 154, 195, 195, 154, 18, 175, 176, 175,
- /* 1360 */ 176, 204, 175, 176, 154, 160, 204, 175, 176, 175,
- /* 1370 */ 176, 175, 176, 175, 176, 154, 175, 176, 154, 226,
- /* 1380 */ 225, 154, 204, 192, 154, 175, 176, 192, 154, 161,
- /* 1390 */ 154, 160, 154, 140, 62, 154, 175, 176, 154, 175,
- /* 1400 */ 176, 154, 175, 176, 241, 175, 176, 242, 154, 175,
- /* 1410 */ 176, 175, 176, 175, 176, 160, 175, 176, 154, 175,
- /* 1420 */ 176, 154, 175, 176, 154, 22, 154, 161, 154, 175,
- /* 1430 */ 176, 154, 180, 154, 161, 154, 160, 154, 160, 175,
- /* 1440 */ 176, 154, 175, 176, 154, 175, 176, 175, 176, 175,
- /* 1450 */ 176, 154, 175, 176, 175, 176, 175, 176, 175, 176,
- /* 1460 */ 154, 98, 175, 176, 161, 175, 176, 185, 177, 180,
- /* 1470 */ 177, 177, 175, 176, 64, 180, 177, 109, 96, 177,
- /* 1480 */ 179, 175, 176, 185, 177, 177, 235, 127, 98, 180,
- /* 1490 */ 180, 235, 161, 22, 161, 230, 140, 131, 218, 128,
- /* 1500 */ 232, 217, 130, 218, 218, 129, 25, 164, 26, 217,
- /* 1510 */ 163, 13, 207, 217, 155, 6, 155, 153, 204, 206,
- /* 1520 */ 208, 205, 218, 153, 255, 167, 153, 173, 217, 181,
- /* 1530 */ 173, 181, 4, 3, 167, 173, 22, 145, 173, 15,
- /* 1540 */ 83, 16, 173, 23, 23, 167, 122, 173, 173, 133,
- /* 1550 */ 173, 113, 125, 24, 20, 127, 16, 1, 125, 134,
- /* 1560 */ 113, 61, 133, 37, 53, 53, 53, 113, 53, 252,
- /* 1570 */ 255, 99, 34, 124, 1, 5, 22, 98, 143, 26,
- /* 1580 */ 75, 98, 41, 124, 68, 68, 24, 20, 19, 114,
- /* 1590 */ 22, 28, 108, 22, 67, 23, 22, 22, 67, 22,
- /* 1600 */ 67, 37, 23, 23, 23, 99, 23, 22, 26, 22,
- /* 1610 */ 24, 23, 124, 24, 23, 23, 22, 126, 34, 26,
- /* 1620 */ 23, 26, 23, 23, 34, 23, 23, 26, 23, 22,
- /* 1630 */ 34, 11, 22, 22, 26, 23, 23, 22, 22, 15,
- /* 1640 */ 118, 23, 124, 124, 1, 256, 256, 124, 256, 256,
- /* 1650 */ 256, 256, 256, 256, 256, 256, 124, 256, 256, 256,
- /* 1660 */ 256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
- /* 1670 */ 256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
- /* 1680 */ 256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
- /* 1690 */ 256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
- /* 1700 */ 256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
- /* 1710 */ 256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
- /* 1720 */ 256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
- /* 1730 */ 256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
- /* 1740 */ 256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
- /* 1750 */ 256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
- /* 1760 */ 256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
- /* 1770 */ 256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
- /* 1780 */ 256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
- /* 1790 */ 256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
- /* 1800 */ 256, 256, 256,
+ /* 0 */ 153, 192, 193, 226, 227, 228, 226, 227, 228, 146,
+ /* 10 */ 147, 148, 149, 150, 196, 197, 16, 153, 155, 197,
+ /* 20 */ 157, 174, 175, 246, 181, 182, 208, 164, 28, 164,
+ /* 30 */ 208, 177, 19, 190, 21, 19, 36, 21, 174, 175,
+ /* 40 */ 153, 41, 42, 43, 44, 45, 46, 47, 48, 49,
+ /* 50 */ 50, 51, 52, 53, 54, 55, 209, 153, 173, 196,
+ /* 60 */ 197, 196, 197, 196, 197, 218, 181, 148, 149, 150,
+ /* 70 */ 57, 208, 16, 208, 155, 208, 157, 212, 213, 23,
+ /* 80 */ 226, 227, 228, 164, 221, 198, 86, 87, 88, 89,
+ /* 90 */ 90, 91, 92, 93, 94, 95, 96, 41, 42, 43,
+ /* 100 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
+ /* 110 */ 54, 55, 249, 100, 19, 196, 197, 174, 90, 91,
+ /* 120 */ 92, 93, 94, 95, 96, 69, 222, 208, 16, 86,
+ /* 130 */ 87, 88, 89, 90, 91, 92, 93, 94, 95, 96,
+ /* 140 */ 221, 96, 86, 87, 88, 89, 90, 91, 92, 93,
+ /* 150 */ 94, 95, 96, 41, 42, 43, 44, 45, 46, 47,
+ /* 160 */ 48, 49, 50, 51, 52, 53, 54, 55, 249, 92,
+ /* 170 */ 93, 94, 95, 96, 153, 111, 112, 102, 12, 67,
+ /* 180 */ 105, 106, 107, 57, 16, 90, 91, 177, 23, 21,
+ /* 190 */ 115, 44, 45, 46, 47, 174, 175, 174, 86, 87,
+ /* 200 */ 88, 89, 90, 91, 92, 93, 94, 95, 96, 41,
+ /* 210 */ 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
+ /* 220 */ 52, 53, 54, 55, 58, 99, 100, 101, 102, 84,
+ /* 230 */ 209, 105, 106, 107, 172, 174, 226, 227, 228, 218,
+ /* 240 */ 16, 115, 19, 20, 20, 100, 23, 95, 96, 104,
+ /* 250 */ 57, 104, 90, 91, 86, 87, 88, 89, 90, 91,
+ /* 260 */ 92, 93, 94, 95, 96, 41, 42, 43, 44, 45,
+ /* 270 */ 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
+ /* 280 */ 135, 136, 137, 153, 153, 153, 121, 122, 226, 227,
+ /* 290 */ 228, 153, 99, 100, 101, 13, 16, 135, 23, 137,
+ /* 300 */ 20, 73, 57, 165, 174, 175, 174, 175, 85, 81,
+ /* 310 */ 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
+ /* 320 */ 96, 41, 42, 43, 44, 45, 46, 47, 48, 49,
+ /* 330 */ 50, 51, 52, 53, 54, 55, 153, 92, 110, 209,
+ /* 340 */ 153, 209, 153, 153, 99, 100, 101, 187, 218, 121,
+ /* 350 */ 122, 220, 16, 169, 170, 171, 20, 174, 175, 77,
+ /* 360 */ 164, 79, 81, 153, 174, 175, 86, 87, 88, 89,
+ /* 370 */ 90, 91, 92, 93, 94, 95, 96, 41, 42, 43,
+ /* 380 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
+ /* 390 */ 54, 55, 196, 197, 13, 153, 158, 19, 20, 209,
+ /* 400 */ 125, 23, 121, 122, 208, 195, 57, 220, 16, 169,
+ /* 410 */ 170, 171, 20, 230, 8, 73, 174, 175, 140, 223,
+ /* 420 */ 142, 72, 86, 87, 88, 89, 90, 91, 92, 93,
+ /* 430 */ 94, 95, 96, 41, 42, 43, 44, 45, 46, 47,
+ /* 440 */ 48, 49, 50, 51, 52, 53, 54, 55, 99, 100,
+ /* 450 */ 101, 209, 110, 111, 112, 153, 172, 247, 77, 153,
+ /* 460 */ 79, 153, 57, 85, 16, 110, 111, 112, 20, 161,
+ /* 470 */ 153, 233, 26, 165, 236, 164, 30, 72, 86, 87,
+ /* 480 */ 88, 89, 90, 91, 92, 93, 94, 95, 96, 41,
+ /* 490 */ 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
+ /* 500 */ 52, 53, 54, 55, 99, 100, 101, 196, 197, 63,
+ /* 510 */ 117, 153, 119, 120, 4, 5, 6, 111, 112, 208,
+ /* 520 */ 16, 237, 192, 193, 143, 219, 242, 110, 111, 112,
+ /* 530 */ 153, 164, 174, 175, 86, 87, 88, 89, 90, 91,
+ /* 540 */ 92, 93, 94, 95, 96, 41, 42, 43, 44, 45,
+ /* 550 */ 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
+ /* 560 */ 153, 153, 153, 196, 197, 153, 153, 153, 19, 20,
+ /* 570 */ 19, 20, 252, 253, 201, 208, 16, 170, 171, 170,
+ /* 580 */ 171, 153, 153, 210, 164, 153, 164, 174, 175, 164,
+ /* 590 */ 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
+ /* 600 */ 96, 41, 42, 43, 44, 45, 46, 47, 48, 49,
+ /* 610 */ 50, 51, 52, 53, 54, 55, 196, 197, 196, 197,
+ /* 620 */ 153, 196, 197, 153, 118, 153, 198, 198, 208, 123,
+ /* 630 */ 208, 219, 16, 208, 85, 153, 85, 21, 153, 153,
+ /* 640 */ 164, 153, 235, 164, 235, 141, 86, 87, 88, 89,
+ /* 650 */ 90, 91, 92, 93, 94, 95, 96, 41, 42, 43,
+ /* 660 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
+ /* 670 */ 54, 55, 196, 197, 153, 196, 197, 195, 153, 153,
+ /* 680 */ 195, 195, 153, 195, 208, 153, 153, 208, 16, 222,
+ /* 690 */ 153, 219, 222, 57, 153, 174, 175, 153, 153, 174,
+ /* 700 */ 175, 141, 86, 87, 88, 89, 90, 91, 92, 93,
+ /* 710 */ 94, 95, 96, 41, 42, 43, 44, 45, 46, 47,
+ /* 720 */ 48, 49, 50, 51, 52, 53, 54, 55, 195, 153,
+ /* 730 */ 189, 153, 153, 153, 189, 198, 100, 167, 168, 167,
+ /* 740 */ 168, 172, 121, 122, 16, 23, 220, 250, 251, 220,
+ /* 750 */ 174, 175, 174, 175, 52, 53, 54, 55, 86, 87,
+ /* 760 */ 88, 89, 90, 91, 92, 93, 94, 95, 96, 41,
+ /* 770 */ 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
+ /* 780 */ 52, 53, 54, 55, 153, 16, 153, 243, 86, 87,
+ /* 790 */ 88, 89, 90, 91, 92, 93, 94, 95, 96, 16,
+ /* 800 */ 220, 212, 213, 21, 44, 174, 175, 174, 175, 153,
+ /* 810 */ 153, 242, 23, 92, 86, 87, 88, 89, 90, 91,
+ /* 820 */ 92, 93, 94, 95, 96, 42, 43, 44, 45, 46,
+ /* 830 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 118,
+ /* 840 */ 20, 153, 28, 23, 123, 20, 20, 153, 23, 23,
+ /* 850 */ 36, 103, 104, 16, 132, 16, 153, 19, 98, 19,
+ /* 860 */ 4, 5, 174, 175, 19, 135, 57, 137, 99, 86,
+ /* 870 */ 87, 88, 89, 90, 91, 92, 93, 94, 95, 96,
+ /* 880 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
+ /* 890 */ 53, 54, 55, 16, 17, 57, 19, 57, 109, 243,
+ /* 900 */ 243, 18, 104, 16, 59, 9, 124, 153, 20, 100,
+ /* 910 */ 33, 23, 114, 20, 153, 20, 23, 153, 23, 135,
+ /* 920 */ 24, 137, 32, 86, 87, 88, 89, 90, 91, 92,
+ /* 930 */ 93, 94, 95, 96, 57, 96, 40, 99, 100, 101,
+ /* 940 */ 100, 102, 103, 104, 105, 106, 107, 108, 71, 16,
+ /* 950 */ 17, 57, 19, 114, 64, 223, 19, 61, 81, 20,
+ /* 960 */ 81, 84, 23, 80, 74, 153, 33, 90, 91, 73,
+ /* 970 */ 19, 153, 153, 183, 97, 153, 99, 100, 101, 183,
+ /* 980 */ 153, 104, 103, 21, 90, 91, 99, 165, 51, 106,
+ /* 990 */ 57, 183, 98, 99, 100, 101, 101, 103, 121, 122,
+ /* 1000 */ 121, 122, 153, 113, 71, 111, 153, 185, 57, 187,
+ /* 1010 */ 19, 16, 135, 136, 137, 138, 139, 84, 153, 57,
+ /* 1020 */ 153, 126, 57, 90, 91, 92, 143, 153, 153, 135,
+ /* 1030 */ 97, 137, 99, 100, 101, 57, 19, 104, 112, 44,
+ /* 1040 */ 16, 17, 153, 19, 153, 153, 20, 214, 57, 23,
+ /* 1050 */ 99, 100, 101, 164, 153, 153, 164, 33, 16, 17,
+ /* 1060 */ 134, 19, 100, 174, 175, 100, 174, 175, 135, 136,
+ /* 1070 */ 137, 138, 139, 20, 57, 33, 23, 99, 100, 101,
+ /* 1080 */ 20, 57, 19, 23, 153, 196, 197, 57, 196, 197,
+ /* 1090 */ 99, 100, 101, 98, 57, 71, 9, 208, 209, 57,
+ /* 1100 */ 208, 209, 153, 153, 126, 174, 175, 218, 84, 114,
+ /* 1110 */ 153, 24, 153, 71, 90, 91, 99, 100, 101, 188,
+ /* 1120 */ 23, 97, 153, 99, 100, 101, 84, 40, 104, 99,
+ /* 1130 */ 100, 101, 90, 91, 153, 211, 153, 100, 153, 97,
+ /* 1140 */ 153, 99, 100, 101, 20, 193, 104, 23, 61, 20,
+ /* 1150 */ 153, 153, 23, 153, 153, 153, 126, 174, 175, 135,
+ /* 1160 */ 136, 137, 138, 139, 153, 153, 52, 53, 54, 55,
+ /* 1170 */ 56, 153, 174, 175, 174, 175, 153, 135, 136, 137,
+ /* 1180 */ 138, 139, 0, 1, 2, 239, 188, 124, 188, 7,
+ /* 1190 */ 8, 9, 10, 11, 153, 199, 14, 211, 101, 153,
+ /* 1200 */ 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
+ /* 1210 */ 96, 29, 238, 200, 211, 174, 175, 153, 211, 37,
+ /* 1220 */ 174, 175, 153, 126, 153, 211, 153, 172, 153, 188,
+ /* 1230 */ 20, 151, 153, 23, 188, 153, 248, 57, 174, 175,
+ /* 1240 */ 215, 203, 215, 174, 175, 174, 175, 174, 175, 174,
+ /* 1250 */ 175, 203, 70, 174, 175, 153, 174, 175, 186, 20,
+ /* 1260 */ 78, 153, 23, 81, 84, 1, 2, 178, 153, 203,
+ /* 1270 */ 153, 7, 8, 9, 10, 11, 174, 175, 14, 99,
+ /* 1280 */ 100, 182, 174, 175, 104, 153, 177, 153, 244, 174,
+ /* 1290 */ 175, 174, 175, 29, 244, 177, 20, 153, 116, 23,
+ /* 1300 */ 153, 37, 153, 121, 122, 177, 174, 175, 174, 175,
+ /* 1310 */ 153, 215, 202, 232, 153, 135, 136, 137, 174, 175,
+ /* 1320 */ 200, 174, 175, 174, 175, 156, 144, 153, 58, 153,
+ /* 1330 */ 35, 174, 175, 248, 70, 174, 175, 153, 245, 245,
+ /* 1340 */ 153, 124, 78, 153, 98, 81, 153, 225, 174, 175,
+ /* 1350 */ 174, 175, 160, 153, 19, 153, 41, 153, 174, 175,
+ /* 1360 */ 153, 174, 175, 224, 174, 175, 191, 174, 175, 153,
+ /* 1370 */ 132, 153, 15, 153, 174, 175, 174, 175, 174, 175,
+ /* 1380 */ 116, 174, 175, 153, 203, 121, 122, 160, 153, 194,
+ /* 1390 */ 174, 175, 174, 175, 174, 175, 15, 153, 225, 194,
+ /* 1400 */ 194, 159, 194, 224, 174, 175, 203, 160, 144, 174,
+ /* 1410 */ 175, 159, 203, 191, 191, 203, 60, 140, 174, 175,
+ /* 1420 */ 160, 159, 19, 160, 241, 240, 159, 179, 160, 179,
+ /* 1430 */ 159, 98, 176, 176, 176, 62, 109, 184, 179, 178,
+ /* 1440 */ 96, 176, 176, 127, 98, 234, 217, 234, 176, 176,
+ /* 1450 */ 216, 160, 216, 184, 179, 19, 216, 179, 217, 160,
+ /* 1460 */ 217, 229, 217, 140, 231, 216, 128, 131, 22, 130,
+ /* 1470 */ 129, 163, 23, 162, 10, 154, 154, 3, 152, 254,
+ /* 1480 */ 152, 207, 152, 166, 204, 206, 205, 203, 19, 180,
+ /* 1490 */ 172, 254, 172, 180, 145, 166, 172, 172, 12, 83,
+ /* 1500 */ 13, 20, 251, 172, 172, 20, 172, 122, 166, 172,
+ /* 1510 */ 133, 113, 21, 125, 17, 13, 127, 1, 125, 113,
+ /* 1520 */ 134, 59, 34, 133, 51, 113, 51, 51, 51, 99,
+ /* 1530 */ 31, 124, 1, 19, 2, 98, 68, 143, 23, 68,
+ /* 1540 */ 75, 38, 124, 98, 21, 17, 16, 114, 108, 67,
+ /* 1550 */ 67, 25, 19, 19, 19, 34, 20, 19, 19, 67,
+ /* 1560 */ 20, 20, 20, 124, 20, 19, 23, 19, 21, 20,
+ /* 1570 */ 19, 21, 20, 20, 126, 118, 31, 99, 23, 23,
+ /* 1580 */ 20, 20, 20, 20, 20, 31, 8, 20, 31, 23,
+ /* 1590 */ 19, 19, 19, 23, 20, 20, 19, 12, 19, 1,
+ /* 1600 */ 20, 255, 255, 124, 124, 255, 255, 255, 124, 255,
+ /* 1610 */ 255, 255, 255, 124, 255, 255, 255, 255, 255, 255,
+ /* 1620 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
+ /* 1630 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
+ /* 1640 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
+ /* 1650 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
+ /* 1660 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
+ /* 1670 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
+ /* 1680 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
+ /* 1690 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
+ /* 1700 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
+ /* 1710 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
+ /* 1720 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
+ /* 1730 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
+ /* 1740 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
+ /* 1750 */ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
};
-#define YY_SHIFT_COUNT (490)
+#define YY_SHIFT_COUNT (483)
#define YY_SHIFT_MIN (0)
-#define YY_SHIFT_MAX (1643)
+#define YY_SHIFT_MAX (1598)
static const unsigned short int yy_shift_ofst[] = {
- /* 0 */ 1004, 990, 1180, 850, 850, 210, 1045, 1045, 1045, 165,
- /* 10 */ 0, 0, 108, 652, 1045, 1045, 1045, 1045, 1045, 1045,
- /* 20 */ 1045, 1045, 1045, 1118, 1118, 126, 815, 210, 210, 210,
- /* 30 */ 210, 210, 210, 54, 162, 216, 270, 324, 378, 432,
- /* 40 */ 486, 542, 598, 652, 652, 652, 652, 652, 652, 652,
- /* 50 */ 652, 652, 652, 652, 652, 652, 652, 652, 652, 652,
- /* 60 */ 706, 652, 759, 811, 811, 1018, 1045, 1045, 1045, 1045,
- /* 70 */ 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045,
- /* 80 */ 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045,
- /* 90 */ 1045, 1045, 1045, 1045, 1045, 1045, 1143, 1045, 1045, 1045,
- /* 100 */ 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045, 1045,
- /* 110 */ 869, 1181, 1181, 1181, 1181, 1181, 420, 186, 205, 77,
- /* 120 */ 1120, 868, 153, 153, 77, 320, 320, 320, 320, 4,
- /* 130 */ 141, 125, 1657, 1657, 991, 991, 991, 524, 512, 524,
- /* 140 */ 524, 866, 866, 812, 315, 322, 77, 77, 77, 77,
- /* 150 */ 77, 77, 77, 77, 77, 77, 77, 77, 77, 77,
- /* 160 */ 77, 77, 77, 77, 77, 77, 77, 72, 560, 560,
- /* 170 */ 540, 1657, 1657, 1657, 1068, 87, 87, 580, 67, 294,
- /* 180 */ 618, 718, 816, 924, 77, 77, 77, 77, 77, 77,
- /* 190 */ 77, 77, 77, 77, 278, 77, 77, 77, 77, 77,
- /* 200 */ 77, 77, 77, 77, 77, 77, 77, 807, 807, 807,
- /* 210 */ 77, 77, 77, 77, 851, 77, 77, 77, 908, 77,
- /* 220 */ 77, 986, 77, 77, 77, 77, 77, 77, 77, 77,
- /* 230 */ 20, 699, 333, 970, 970, 970, 970, 954, 333, 333,
- /* 240 */ 1107, 472, 276, 708, 584, 820, 820, 957, 584, 584,
- /* 250 */ 957, 801, 329, 147, 423, 423, 423, 820, 466, 648,
- /* 260 */ 546, 711, 1200, 1166, 1166, 1275, 1275, 1166, 1220, 1300,
- /* 270 */ 1288, 1203, 1319, 1319, 1319, 1319, 1166, 1338, 1203, 1203,
- /* 280 */ 1220, 1300, 1288, 1288, 1203, 1166, 1338, 1253, 1332, 1166,
- /* 290 */ 1338, 1403, 1166, 1338, 1166, 1338, 1403, 1363, 1363, 1363,
- /* 300 */ 1410, 1403, 1363, 1368, 1363, 1410, 1363, 1363, 1403, 1382,
- /* 310 */ 1382, 1403, 1360, 1390, 1360, 1390, 1360, 1390, 1360, 1390,
- /* 320 */ 1166, 1471, 1166, 1356, 1366, 1371, 1372, 1376, 1203, 1481,
- /* 330 */ 1482, 1498, 1498, 1509, 1509, 1509, 1657, 1657, 1657, 1657,
- /* 340 */ 1657, 1657, 1657, 1657, 1657, 1657, 1657, 1657, 1657, 1657,
- /* 350 */ 1657, 1657, 287, 421, 207, 376, 424, 385, 1078, 698,
- /* 360 */ 1005, 710, 810, 704, 764, 746, 748, 753, 757, 758,
- /* 370 */ 803, 567, 728, 830, 288, 782, 853, 862, 912, 754,
- /* 380 */ 755, 955, 973, 983, 873, 1528, 1530, 1514, 1392, 1524,
- /* 390 */ 1457, 1525, 1520, 1521, 1424, 1416, 1438, 1529, 1427, 1534,
- /* 400 */ 1428, 1540, 1556, 1433, 1425, 1447, 1500, 1526, 1429, 1511,
- /* 410 */ 1512, 1513, 1515, 1454, 1472, 1538, 1449, 1573, 1570, 1554,
- /* 420 */ 1479, 1435, 1516, 1553, 1517, 1505, 1541, 1459, 1483, 1562,
- /* 430 */ 1567, 1569, 1475, 1484, 1568, 1527, 1571, 1574, 1572, 1575,
- /* 440 */ 1531, 1563, 1577, 1533, 1564, 1579, 1580, 1581, 1582, 1583,
- /* 450 */ 1585, 1586, 1588, 1587, 1589, 1488, 1591, 1592, 1506, 1584,
- /* 460 */ 1594, 1491, 1593, 1590, 1595, 1596, 1597, 1593, 1599, 1600,
- /* 470 */ 1602, 1603, 1601, 1605, 1607, 1620, 1610, 1611, 1612, 1613,
- /* 480 */ 1615, 1616, 1608, 1522, 1518, 1519, 1523, 1532, 1618, 1624,
- /* 490 */ 1643,
+ /* 0 */ 1264, 1182, 877, 877, 281, 1024, 1024, 1024, 228, 0,
+ /* 10 */ 0, 112, 672, 1024, 1024, 1024, 1024, 1024, 1024, 1024,
+ /* 20 */ 1024, 1024, 894, 894, 126, 879, 281, 281, 281, 281,
+ /* 30 */ 281, 281, 56, 168, 224, 280, 336, 392, 448, 504,
+ /* 40 */ 560, 616, 672, 672, 672, 672, 672, 672, 672, 672,
+ /* 50 */ 672, 672, 672, 672, 672, 672, 672, 672, 672, 728,
+ /* 60 */ 672, 783, 837, 837, 933, 1024, 1024, 1024, 1024, 1024,
+ /* 70 */ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024,
+ /* 80 */ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024,
+ /* 90 */ 1024, 1024, 1024, 1024, 1024, 1042, 1024, 1024, 1024, 1024,
+ /* 100 */ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1114,
+ /* 110 */ 702, 702, 702, 702, 702, 43, 28, 77, 193, 883,
+ /* 120 */ 995, 162, 162, 193, 165, 165, 165, 165, 64, 152,
+ /* 130 */ 45, 1614, 1614, 839, 839, 839, 838, 349, 838, 838,
+ /* 140 */ 896, 896, 405, 223, 378, 193, 193, 193, 193, 193,
+ /* 150 */ 193, 193, 193, 193, 193, 193, 193, 193, 193, 193,
+ /* 160 */ 193, 193, 193, 193, 193, 193, 406, 636, 636, 621,
+ /* 170 */ 1614, 1614, 1614, 1180, 145, 145, 951, 75, 245, 991,
+ /* 180 */ 978, 1030, 1017, 193, 193, 193, 193, 193, 193, 193,
+ /* 190 */ 193, 342, 193, 193, 193, 193, 193, 193, 193, 193,
+ /* 200 */ 193, 193, 193, 193, 890, 890, 890, 193, 193, 193,
+ /* 210 */ 193, 895, 193, 193, 193, 13, 193, 193, 1087, 193,
+ /* 220 */ 193, 193, 193, 193, 193, 193, 193, 355, 446, 393,
+ /* 230 */ 962, 962, 962, 962, 1097, 393, 393, 721, 95, 510,
+ /* 240 */ 166, 722, 769, 769, 887, 722, 722, 887, 789, 820,
+ /* 250 */ 760, 814, 814, 814, 769, 278, 275, 506, 16, 1270,
+ /* 260 */ 1295, 1295, 1217, 1246, 1335, 1315, 1238, 1357, 1357, 1357,
+ /* 270 */ 1357, 1217, 1381, 1238, 1238, 1246, 1335, 1315, 1315, 1238,
+ /* 280 */ 1217, 1381, 1277, 1356, 1217, 1381, 1403, 1217, 1381, 1217,
+ /* 290 */ 1381, 1403, 1333, 1333, 1333, 1373, 1403, 1333, 1327, 1333,
+ /* 300 */ 1373, 1333, 1333, 1403, 1344, 1344, 1403, 1316, 1346, 1316,
+ /* 310 */ 1346, 1316, 1346, 1316, 1346, 1217, 1436, 1217, 1323, 1336,
+ /* 320 */ 1338, 1339, 1341, 1238, 1446, 1449, 1464, 1464, 1474, 1474,
+ /* 330 */ 1474, 1614, 1614, 1614, 1614, 1614, 1614, 1614, 1614, 1614,
+ /* 340 */ 1614, 1614, 1614, 1614, 1614, 1614, 1614, 147, 381, 549,
+ /* 350 */ 551, 282, 417, 840, 825, 937, 782, 926, 826, 845,
+ /* 360 */ 888, 893, 939, 1026, 1053, 1060, 809, 748, 856, 798,
+ /* 370 */ 965, 1124, 1129, 1210, 730, 784, 1239, 1276, 1037, 1063,
+ /* 380 */ 1469, 1349, 1486, 1416, 1487, 1481, 1485, 1385, 1377, 1398,
+ /* 390 */ 1491, 1388, 1497, 1389, 1502, 1516, 1393, 1386, 1406, 1462,
+ /* 400 */ 1488, 1390, 1473, 1475, 1476, 1477, 1412, 1430, 1499, 1407,
+ /* 410 */ 1531, 1532, 1514, 1437, 1394, 1468, 1515, 1471, 1465, 1503,
+ /* 420 */ 1418, 1445, 1523, 1528, 1530, 1433, 1440, 1533, 1482, 1534,
+ /* 430 */ 1535, 1536, 1538, 1483, 1526, 1539, 1492, 1521, 1540, 1541,
+ /* 440 */ 1542, 1543, 1544, 1546, 1547, 1549, 1548, 1550, 1439, 1552,
+ /* 450 */ 1553, 1478, 1545, 1551, 1448, 1555, 1554, 1556, 1557, 1560,
+ /* 460 */ 1555, 1561, 1562, 1563, 1564, 1566, 1567, 1571, 1578, 1572,
+ /* 470 */ 1573, 1574, 1575, 1577, 1579, 1570, 1457, 1479, 1480, 1484,
+ /* 480 */ 1489, 1580, 1585, 1598,
};
-#define YY_REDUCE_COUNT (351)
-#define YY_REDUCE_MIN (-226)
-#define YY_REDUCE_MAX (1378)
+#define YY_REDUCE_COUNT (346)
+#define YY_REDUCE_MIN (-223)
+#define YY_REDUCE_MAX (1342)
static const short yy_reduce_ofst[] = {
- /* 0 */ -138, -84, -30, 1130, 1135, -80, -140, 120, 228, 513,
- /* 10 */ -152, -39, -226, -166, 857, 872, 887, 903, 174, 984,
- /* 20 */ 612, 233, 282, 959, 1015, 865, 517, 624, 626, 942,
- /* 30 */ 1048, 1094, 1100, -223, -223, -223, -223, -223, -223, -223,
- /* 40 */ -223, -223, -223, -223, -223, -223, -223, -223, -223, -223,
- /* 50 */ -223, -223, -223, -223, -223, -223, -223, -223, -223, -223,
- /* 60 */ -223, -223, -223, -223, -223, 390, 394, 794, 799, 915,
- /* 70 */ 1047, 1110, 1112, 1139, 1145, 1150, 1154, 1182, 1184, 1187,
- /* 80 */ 1192, 1194, 1196, 1198, 1201, 1210, 1221, 1224, 1227, 1230,
- /* 90 */ 1234, 1236, 1238, 1241, 1244, 1247, 1254, 1264, 1267, 1270,
- /* 100 */ 1272, 1274, 1277, 1279, 1281, 1283, 1287, 1290, 1297, 1306,
- /* 110 */ -223, -223, -223, -223, -223, -223, -223, -223, -223, 200,
- /* 120 */ 226, -167, -142, -130, -129, -175, 247, -175, 247, 317,
- /* 130 */ -223, -223, -223, -223, 60, 60, 60, -154, 292, -86,
- /* 140 */ 345, 212, 357, 305, 299, 299, 391, -96, 229, 339,
- /* 150 */ 348, -76, 404, 413, 460, -122, 26, 363, 395, 400,
- /* 160 */ 521, 447, 461, 522, 464, 577, 449, -3, 436, 490,
- /* 170 */ 131, 414, 459, 518, -158, -137, -93, 140, 154, 285,
- /* 180 */ 402, 559, 582, 616, 628, 631, 636, 666, 674, 682,
- /* 190 */ 686, 726, 729, 740, 396, 621, 774, 779, 789, 791,
- /* 200 */ 814, 819, 825, 839, 858, 881, 885, 800, 859, 861,
- /* 210 */ 896, 898, 905, 919, 860, 930, 934, 947, 854, 949,
- /* 220 */ 960, 927, 969, 285, 974, 978, 979, 989, 993, 996,
- /* 230 */ 884, 922, 958, 952, 962, 963, 964, 860, 958, 958,
- /* 240 */ 965, 997, 1019, 939, 985, 980, 982, 961, 1003, 1007,
- /* 250 */ 987, 1036, 1037, 1056, 1050, 1053, 1063, 1032, 1016, 1049,
- /* 260 */ 1055, 1097, 1034, 1133, 1146, 1066, 1070, 1156, 1093, 1098,
- /* 270 */ 1142, 1138, 1148, 1152, 1158, 1159, 1190, 1205, 1157, 1162,
- /* 280 */ 1153, 1155, 1191, 1195, 1178, 1228, 1231, 1165, 1163, 1266,
- /* 290 */ 1255, 1252, 1273, 1276, 1303, 1278, 1289, 1291, 1293, 1294,
- /* 300 */ 1282, 1295, 1299, 1301, 1302, 1298, 1307, 1308, 1309, 1251,
- /* 310 */ 1256, 1310, 1280, 1284, 1285, 1292, 1286, 1296, 1304, 1311,
- /* 320 */ 1331, 1265, 1333, 1268, 1312, 1305, 1313, 1316, 1314, 1343,
- /* 330 */ 1347, 1359, 1361, 1364, 1370, 1373, 1269, 1315, 1317, 1358,
- /* 340 */ 1354, 1357, 1362, 1365, 1367, 1348, 1350, 1369, 1374, 1375,
- /* 350 */ 1377, 1378,
+ /* 0 */ -137, -81, 889, 892, -135, -153, 21, 130, 196, -146,
+ /* 10 */ 10, -223, 62, 931, 998, 1000, 1041, 132, 1046, 183,
+ /* 20 */ 190, 242, 407, 409, 822, 311, 367, 420, 422, 425,
+ /* 30 */ 476, 479, -220, -220, -220, -220, -220, -220, -220, -220,
+ /* 40 */ -220, -220, -220, -220, -220, -220, -220, -220, -220, -220,
+ /* 50 */ -220, -220, -220, -220, -220, -220, -220, -220, -220, -220,
+ /* 60 */ -220, -220, -220, -220, -136, 358, 413, 521, 525, 576,
+ /* 70 */ 578, 631, 633, 688, 983, 1064, 1069, 1071, 1073, 1075,
+ /* 80 */ 1079, 1082, 1102, 1108, 1115, 1117, 1132, 1134, 1144, 1147,
+ /* 90 */ 1149, 1157, 1161, 1174, 1176, 1184, 1187, 1190, 1193, 1200,
+ /* 100 */ 1202, 1204, 1207, 1216, 1218, 1220, 1230, 1235, 1244, -220,
+ /* 110 */ -220, -220, -220, -220, -220, -220, -220, -220, 210, 238,
+ /* 120 */ -157, 184, 240, 308, -182, -133, -182, -133, 284, -220,
+ /* 130 */ -220, -220, -220, -115, -115, -115, -96, -113, 467, 470,
+ /* 140 */ -191, 330, 428, 320, 320, 138, 306, 412, 472, 429,
+ /* 150 */ 482, 485, 486, 488, 544, 131, 656, 187, 526, 657,
+ /* 160 */ 529, 533, 541, 537, 545, 580, 569, 570, 572, -178,
+ /* 170 */ 497, 589, 373, -57, 23, 61, 189, 160, 302, 317,
+ /* 180 */ 377, 408, 414, 432, 532, 579, 694, 703, 754, 761,
+ /* 190 */ 764, 732, 812, 818, 819, 827, 849, 853, 865, 867,
+ /* 200 */ 874, 875, 891, 901, 790, 796, 808, 902, 949, 950,
+ /* 210 */ 957, 833, 959, 969, 981, 924, 985, 987, 952, 997,
+ /* 220 */ 302, 1001, 1002, 1011, 1012, 1018, 1023, 946, 974, 996,
+ /* 230 */ 986, 1003, 1007, 1014, 833, 996, 996, 1013, 1055, 1080,
+ /* 240 */ 988, 1038, 1025, 1027, 1044, 1048, 1066, 1050, 1089, 1072,
+ /* 250 */ 1099, 1109, 1118, 1128, 1096, 1081, 1110, 1120, 1169, 1085,
+ /* 260 */ 1093, 1094, 1192, 1122, 1139, 1175, 1181, 1195, 1205, 1206,
+ /* 270 */ 1208, 1227, 1242, 1203, 1209, 1173, 1179, 1222, 1223, 1212,
+ /* 280 */ 1247, 1252, 1183, 1185, 1260, 1262, 1248, 1263, 1267, 1268,
+ /* 290 */ 1271, 1250, 1256, 1257, 1258, 1253, 1259, 1265, 1261, 1266,
+ /* 300 */ 1269, 1272, 1273, 1275, 1211, 1213, 1278, 1229, 1234, 1241,
+ /* 310 */ 1236, 1243, 1240, 1245, 1249, 1291, 1232, 1299, 1233, 1274,
+ /* 320 */ 1279, 1281, 1280, 1284, 1308, 1311, 1321, 1322, 1326, 1328,
+ /* 330 */ 1330, 1225, 1237, 1251, 1317, 1318, 1320, 1324, 1325, 1329,
+ /* 340 */ 1309, 1313, 1331, 1332, 1334, 1337, 1342,
};
static const YYACTIONTYPE yy_default[] = {
- /* 0 */ 1391, 1391, 1391, 1262, 1048, 1153, 1262, 1262, 1262, 1048,
- /* 10 */ 1183, 1183, 1313, 1079, 1048, 1048, 1048, 1048, 1048, 1048,
- /* 20 */ 1261, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048,
- /* 30 */ 1048, 1048, 1048, 1189, 1048, 1048, 1048, 1048, 1263, 1264,
- /* 40 */ 1048, 1048, 1048, 1312, 1314, 1199, 1198, 1197, 1196, 1295,
- /* 50 */ 1170, 1194, 1187, 1191, 1257, 1258, 1256, 1260, 1264, 1263,
- /* 60 */ 1048, 1190, 1228, 1242, 1227, 1048, 1048, 1048, 1048, 1048,
- /* 70 */ 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048,
- /* 80 */ 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048,
- /* 90 */ 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048,
- /* 100 */ 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048,
- /* 110 */ 1236, 1241, 1247, 1240, 1237, 1230, 1229, 1231, 1232, 1048,
- /* 120 */ 1069, 1118, 1048, 1048, 1048, 1331, 1330, 1048, 1048, 1079,
- /* 130 */ 1233, 1234, 1244, 1243, 1320, 1347, 1346, 1048, 1048, 1048,
- /* 140 */ 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048,
- /* 150 */ 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048,
- /* 160 */ 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1079, 1075, 1075,
- /* 170 */ 1048, 1326, 1153, 1144, 1048, 1048, 1048, 1048, 1048, 1048,
- /* 180 */ 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1317, 1315, 1048,
- /* 190 */ 1277, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048,
- /* 200 */ 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048,
- /* 210 */ 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1149, 1048,
- /* 220 */ 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1341,
- /* 230 */ 1048, 1290, 1132, 1149, 1149, 1149, 1149, 1151, 1133, 1131,
- /* 240 */ 1143, 1079, 1055, 1383, 1193, 1172, 1172, 1380, 1193, 1193,
- /* 250 */ 1380, 1093, 1361, 1090, 1183, 1183, 1183, 1172, 1259, 1150,
- /* 260 */ 1143, 1048, 1383, 1158, 1158, 1382, 1382, 1158, 1202, 1208,
- /* 270 */ 1121, 1193, 1127, 1127, 1127, 1127, 1158, 1066, 1193, 1193,
- /* 280 */ 1202, 1208, 1121, 1121, 1193, 1158, 1066, 1294, 1377, 1158,
- /* 290 */ 1066, 1270, 1158, 1066, 1158, 1066, 1270, 1119, 1119, 1119,
- /* 300 */ 1108, 1270, 1119, 1093, 1119, 1108, 1119, 1119, 1270, 1274,
- /* 310 */ 1274, 1270, 1176, 1171, 1176, 1171, 1176, 1171, 1176, 1171,
- /* 320 */ 1158, 1265, 1158, 1048, 1188, 1177, 1186, 1184, 1193, 1072,
- /* 330 */ 1111, 1344, 1344, 1340, 1340, 1340, 1388, 1388, 1326, 1356,
- /* 340 */ 1079, 1079, 1079, 1079, 1356, 1095, 1095, 1079, 1079, 1079,
- /* 350 */ 1079, 1356, 1048, 1048, 1048, 1048, 1048, 1048, 1351, 1048,
- /* 360 */ 1279, 1162, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048,
- /* 370 */ 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048,
- /* 380 */ 1048, 1048, 1048, 1048, 1213, 1048, 1051, 1323, 1048, 1048,
- /* 390 */ 1321, 1048, 1048, 1048, 1048, 1048, 1048, 1163, 1048, 1048,
- /* 400 */ 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048,
- /* 410 */ 1048, 1048, 1048, 1048, 1048, 1048, 1379, 1048, 1048, 1048,
- /* 420 */ 1048, 1048, 1048, 1293, 1292, 1048, 1048, 1160, 1048, 1048,
- /* 430 */ 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048,
- /* 440 */ 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048,
- /* 450 */ 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048,
- /* 460 */ 1048, 1048, 1185, 1048, 1178, 1048, 1048, 1370, 1048, 1048,
- /* 470 */ 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048,
- /* 480 */ 1048, 1048, 1365, 1135, 1215, 1048, 1214, 1218, 1048, 1060,
- /* 490 */ 1048,
+ /* 0 */ 1366, 1366, 1242, 1030, 1133, 1242, 1242, 1242, 1030, 1163,
+ /* 10 */ 1163, 1293, 1059, 1030, 1030, 1030, 1030, 1030, 1030, 1241,
+ /* 20 */ 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030,
+ /* 30 */ 1030, 1030, 1169, 1030, 1030, 1030, 1030, 1243, 1244, 1030,
+ /* 40 */ 1030, 1030, 1292, 1294, 1179, 1178, 1177, 1176, 1275, 1150,
+ /* 50 */ 1174, 1167, 1171, 1237, 1238, 1236, 1240, 1244, 1243, 1030,
+ /* 60 */ 1170, 1208, 1222, 1207, 1030, 1030, 1030, 1030, 1030, 1030,
+ /* 70 */ 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030,
+ /* 80 */ 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030,
+ /* 90 */ 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030,
+ /* 100 */ 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1216,
+ /* 110 */ 1221, 1227, 1220, 1217, 1210, 1209, 1211, 1212, 1030, 1049,
+ /* 120 */ 1098, 1030, 1030, 1030, 1307, 1306, 1030, 1030, 1059, 1213,
+ /* 130 */ 1214, 1224, 1223, 1296, 1322, 1321, 1030, 1030, 1030, 1030,
+ /* 140 */ 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030,
+ /* 150 */ 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030,
+ /* 160 */ 1030, 1030, 1030, 1030, 1030, 1030, 1059, 1055, 1055, 1030,
+ /* 170 */ 1302, 1133, 1124, 1030, 1030, 1030, 1030, 1030, 1030, 1030,
+ /* 180 */ 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1257, 1030, 1030,
+ /* 190 */ 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030,
+ /* 200 */ 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030,
+ /* 210 */ 1030, 1030, 1030, 1030, 1030, 1129, 1030, 1030, 1030, 1030,
+ /* 220 */ 1030, 1030, 1030, 1030, 1030, 1030, 1316, 1030, 1270, 1112,
+ /* 230 */ 1129, 1129, 1129, 1129, 1131, 1113, 1111, 1123, 1059, 1035,
+ /* 240 */ 1358, 1173, 1152, 1152, 1355, 1173, 1173, 1355, 1073, 1336,
+ /* 250 */ 1070, 1163, 1163, 1163, 1152, 1239, 1130, 1123, 1030, 1358,
+ /* 260 */ 1357, 1357, 1138, 1182, 1188, 1101, 1173, 1107, 1107, 1107,
+ /* 270 */ 1107, 1138, 1046, 1173, 1173, 1182, 1188, 1101, 1101, 1173,
+ /* 280 */ 1138, 1046, 1274, 1352, 1138, 1046, 1250, 1138, 1046, 1138,
+ /* 290 */ 1046, 1250, 1099, 1099, 1099, 1088, 1250, 1099, 1073, 1099,
+ /* 300 */ 1088, 1099, 1099, 1250, 1254, 1254, 1250, 1156, 1151, 1156,
+ /* 310 */ 1151, 1156, 1151, 1156, 1151, 1138, 1245, 1138, 1030, 1168,
+ /* 320 */ 1157, 1166, 1164, 1173, 1052, 1091, 1319, 1319, 1315, 1315,
+ /* 330 */ 1315, 1363, 1363, 1302, 1331, 1059, 1059, 1059, 1059, 1331,
+ /* 340 */ 1075, 1075, 1059, 1059, 1059, 1059, 1331, 1030, 1030, 1030,
+ /* 350 */ 1030, 1030, 1030, 1326, 1030, 1259, 1142, 1030, 1030, 1030,
+ /* 360 */ 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030,
+ /* 370 */ 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1193,
+ /* 380 */ 1299, 1030, 1030, 1297, 1030, 1030, 1030, 1030, 1030, 1030,
+ /* 390 */ 1143, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030,
+ /* 400 */ 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1354,
+ /* 410 */ 1030, 1030, 1030, 1030, 1030, 1030, 1273, 1272, 1030, 1030,
+ /* 420 */ 1140, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030,
+ /* 430 */ 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030,
+ /* 440 */ 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030,
+ /* 450 */ 1030, 1030, 1030, 1030, 1030, 1165, 1030, 1158, 1030, 1030,
+ /* 460 */ 1345, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030,
+ /* 470 */ 1030, 1030, 1030, 1030, 1030, 1340, 1115, 1195, 1030, 1194,
+ /* 480 */ 1198, 1030, 1040, 1030,
};
/********** End of lemon-generated parsing tables *****************************/
@@ -147863,52 +147807,50 @@ static const YYACTIONTYPE yy_default[] = {
static const YYCODETYPE yyFallback[] = {
0, /* $ => nothing */
0, /* SEMI => nothing */
- 59, /* EXPLAIN => ID */
- 59, /* QUERY => ID */
- 59, /* PLAN => ID */
- 59, /* BEGIN => ID */
+ 57, /* BEGIN => ID */
0, /* TRANSACTION => nothing */
- 59, /* DEFERRED => ID */
- 59, /* IMMEDIATE => ID */
- 59, /* EXCLUSIVE => ID */
+ 57, /* DEFERRED => ID */
+ 57, /* IMMEDIATE => ID */
+ 57, /* EXCLUSIVE => ID */
0, /* COMMIT => nothing */
- 59, /* END => ID */
- 59, /* ROLLBACK => ID */
- 59, /* SAVEPOINT => ID */
- 59, /* RELEASE => ID */
+ 57, /* END => ID */
+ 57, /* ROLLBACK => ID */
+ 57, /* SAVEPOINT => ID */
+ 57, /* RELEASE => ID */
0, /* TO => nothing */
0, /* TABLE => nothing */
0, /* CREATE => nothing */
- 59, /* IF => ID */
+ 57, /* IF => ID */
0, /* NOT => nothing */
0, /* EXISTS => nothing */
- 59, /* TEMP => ID */
+ 57, /* TEMP => ID */
0, /* LP => nothing */
0, /* RP => nothing */
0, /* AS => nothing */
- 59, /* WITHOUT => ID */
+ 57, /* WITHOUT => ID */
0, /* COMMA => nothing */
- 59, /* ABORT => ID */
- 59, /* ACTION => ID */
- 59, /* AFTER => ID */
- 59, /* ANALYZE => ID */
- 59, /* ASC => ID */
- 59, /* ATTACH => ID */
- 59, /* BEFORE => ID */
- 59, /* BY => ID */
- 59, /* CASCADE => ID */
- 59, /* CAST => ID */
- 59, /* CONFLICT => ID */
- 59, /* DATABASE => ID */
- 59, /* DESC => ID */
- 59, /* DETACH => ID */
- 59, /* EACH => ID */
- 59, /* FAIL => ID */
+ 57, /* ABORT => ID */
+ 57, /* ACTION => ID */
+ 57, /* AFTER => ID */
+ 57, /* ANALYZE => ID */
+ 57, /* ASC => ID */
+ 57, /* ATTACH => ID */
+ 57, /* BEFORE => ID */
+ 57, /* BY => ID */
+ 57, /* CASCADE => ID */
+ 57, /* CAST => ID */
+ 57, /* CONFLICT => ID */
+ 57, /* DATABASE => ID */
+ 57, /* DESC => ID */
+ 57, /* DETACH => ID */
+ 57, /* EACH => ID */
+ 57, /* EXPLAIN => ID */
+ 57, /* FAIL => ID */
0, /* OR => nothing */
0, /* AND => nothing */
0, /* IS => nothing */
- 59, /* MATCH => ID */
- 59, /* LIKE_KW => ID */
+ 57, /* MATCH => ID */
+ 57, /* LIKE_KW => ID */
0, /* BETWEEN => nothing */
0, /* IN => nothing */
0, /* ISNULL => nothing */
@@ -147921,31 +147863,33 @@ static const YYCODETYPE yyFallback[] = {
0, /* GE => nothing */
0, /* ESCAPE => nothing */
0, /* ID => nothing */
- 59, /* COLUMNKW => ID */
- 59, /* DO => ID */
- 59, /* FOR => ID */
- 59, /* IGNORE => ID */
- 59, /* INITIALLY => ID */
- 59, /* INSTEAD => ID */
- 59, /* NO => ID */
- 59, /* KEY => ID */
- 59, /* OF => ID */
- 59, /* OFFSET => ID */
- 59, /* PRAGMA => ID */
- 59, /* RAISE => ID */
- 59, /* RECURSIVE => ID */
- 59, /* REPLACE => ID */
- 59, /* RESTRICT => ID */
- 59, /* ROW => ID */
- 59, /* ROWS => ID */
- 59, /* TRIGGER => ID */
- 59, /* VACUUM => ID */
- 59, /* VIEW => ID */
- 59, /* VIRTUAL => ID */
- 59, /* WITH => ID */
- 59, /* REINDEX => ID */
- 59, /* RENAME => ID */
- 59, /* CTIME_KW => ID */
+ 57, /* COLUMNKW => ID */
+ 57, /* DO => ID */
+ 57, /* FOR => ID */
+ 57, /* IGNORE => ID */
+ 57, /* INITIALLY => ID */
+ 57, /* INSTEAD => ID */
+ 57, /* NO => ID */
+ 57, /* PLAN => ID */
+ 57, /* QUERY => ID */
+ 57, /* KEY => ID */
+ 57, /* OF => ID */
+ 57, /* OFFSET => ID */
+ 57, /* PRAGMA => ID */
+ 57, /* RAISE => ID */
+ 57, /* RECURSIVE => ID */
+ 57, /* REPLACE => ID */
+ 57, /* RESTRICT => ID */
+ 57, /* ROW => ID */
+ 57, /* ROWS => ID */
+ 57, /* TRIGGER => ID */
+ 57, /* VACUUM => ID */
+ 57, /* VIEW => ID */
+ 57, /* VIRTUAL => ID */
+ 57, /* WITH => ID */
+ 57, /* REINDEX => ID */
+ 57, /* RENAME => ID */
+ 57, /* CTIME_KW => ID */
};
#endif /* YYFALLBACK */
@@ -148035,71 +147979,71 @@ SQLITE_PRIVATE void sqlite3ParserTrace(FILE *TraceFILE, char *zTracePrompt){
static const char *const yyTokenName[] = {
/* 0 */ "$",
/* 1 */ "SEMI",
- /* 2 */ "EXPLAIN",
- /* 3 */ "QUERY",
- /* 4 */ "PLAN",
- /* 5 */ "BEGIN",
- /* 6 */ "TRANSACTION",
- /* 7 */ "DEFERRED",
- /* 8 */ "IMMEDIATE",
- /* 9 */ "EXCLUSIVE",
- /* 10 */ "COMMIT",
- /* 11 */ "END",
- /* 12 */ "ROLLBACK",
- /* 13 */ "SAVEPOINT",
- /* 14 */ "RELEASE",
- /* 15 */ "TO",
- /* 16 */ "TABLE",
- /* 17 */ "CREATE",
- /* 18 */ "IF",
- /* 19 */ "NOT",
- /* 20 */ "EXISTS",
- /* 21 */ "TEMP",
- /* 22 */ "LP",
- /* 23 */ "RP",
- /* 24 */ "AS",
- /* 25 */ "WITHOUT",
- /* 26 */ "COMMA",
- /* 27 */ "ABORT",
- /* 28 */ "ACTION",
- /* 29 */ "AFTER",
- /* 30 */ "ANALYZE",
- /* 31 */ "ASC",
- /* 32 */ "ATTACH",
- /* 33 */ "BEFORE",
- /* 34 */ "BY",
- /* 35 */ "CASCADE",
- /* 36 */ "CAST",
- /* 37 */ "CONFLICT",
- /* 38 */ "DATABASE",
- /* 39 */ "DESC",
- /* 40 */ "DETACH",
- /* 41 */ "EACH",
- /* 42 */ "FAIL",
- /* 43 */ "OR",
- /* 44 */ "AND",
- /* 45 */ "IS",
- /* 46 */ "MATCH",
- /* 47 */ "LIKE_KW",
- /* 48 */ "BETWEEN",
- /* 49 */ "IN",
- /* 50 */ "ISNULL",
- /* 51 */ "NOTNULL",
- /* 52 */ "NE",
- /* 53 */ "EQ",
- /* 54 */ "GT",
- /* 55 */ "LE",
- /* 56 */ "LT",
- /* 57 */ "GE",
- /* 58 */ "ESCAPE",
- /* 59 */ "ID",
- /* 60 */ "COLUMNKW",
- /* 61 */ "DO",
- /* 62 */ "FOR",
- /* 63 */ "IGNORE",
- /* 64 */ "INITIALLY",
- /* 65 */ "INSTEAD",
- /* 66 */ "NO",
+ /* 2 */ "BEGIN",
+ /* 3 */ "TRANSACTION",
+ /* 4 */ "DEFERRED",
+ /* 5 */ "IMMEDIATE",
+ /* 6 */ "EXCLUSIVE",
+ /* 7 */ "COMMIT",
+ /* 8 */ "END",
+ /* 9 */ "ROLLBACK",
+ /* 10 */ "SAVEPOINT",
+ /* 11 */ "RELEASE",
+ /* 12 */ "TO",
+ /* 13 */ "TABLE",
+ /* 14 */ "CREATE",
+ /* 15 */ "IF",
+ /* 16 */ "NOT",
+ /* 17 */ "EXISTS",
+ /* 18 */ "TEMP",
+ /* 19 */ "LP",
+ /* 20 */ "RP",
+ /* 21 */ "AS",
+ /* 22 */ "WITHOUT",
+ /* 23 */ "COMMA",
+ /* 24 */ "ABORT",
+ /* 25 */ "ACTION",
+ /* 26 */ "AFTER",
+ /* 27 */ "ANALYZE",
+ /* 28 */ "ASC",
+ /* 29 */ "ATTACH",
+ /* 30 */ "BEFORE",
+ /* 31 */ "BY",
+ /* 32 */ "CASCADE",
+ /* 33 */ "CAST",
+ /* 34 */ "CONFLICT",
+ /* 35 */ "DATABASE",
+ /* 36 */ "DESC",
+ /* 37 */ "DETACH",
+ /* 38 */ "EACH",
+ /* 39 */ "EXPLAIN",
+ /* 40 */ "FAIL",
+ /* 41 */ "OR",
+ /* 42 */ "AND",
+ /* 43 */ "IS",
+ /* 44 */ "MATCH",
+ /* 45 */ "LIKE_KW",
+ /* 46 */ "BETWEEN",
+ /* 47 */ "IN",
+ /* 48 */ "ISNULL",
+ /* 49 */ "NOTNULL",
+ /* 50 */ "NE",
+ /* 51 */ "EQ",
+ /* 52 */ "GT",
+ /* 53 */ "LE",
+ /* 54 */ "LT",
+ /* 55 */ "GE",
+ /* 56 */ "ESCAPE",
+ /* 57 */ "ID",
+ /* 58 */ "COLUMNKW",
+ /* 59 */ "DO",
+ /* 60 */ "FOR",
+ /* 61 */ "IGNORE",
+ /* 62 */ "INITIALLY",
+ /* 63 */ "INSTEAD",
+ /* 64 */ "NO",
+ /* 65 */ "PLAN",
+ /* 66 */ "QUERY",
/* 67 */ "KEY",
/* 68 */ "OF",
/* 69 */ "OFFSET",
@@ -148183,112 +148127,111 @@ static const char *const yyTokenName[] = {
/* 147 */ "cmdlist",
/* 148 */ "ecmd",
/* 149 */ "cmdx",
- /* 150 */ "explain",
- /* 151 */ "cmd",
- /* 152 */ "transtype",
- /* 153 */ "trans_opt",
- /* 154 */ "nm",
- /* 155 */ "savepoint_opt",
- /* 156 */ "create_table",
- /* 157 */ "create_table_args",
- /* 158 */ "createkw",
- /* 159 */ "temp",
- /* 160 */ "ifnotexists",
- /* 161 */ "dbnm",
- /* 162 */ "columnlist",
- /* 163 */ "conslist_opt",
- /* 164 */ "table_options",
- /* 165 */ "select",
- /* 166 */ "columnname",
- /* 167 */ "carglist",
- /* 168 */ "typetoken",
- /* 169 */ "typename",
- /* 170 */ "signed",
- /* 171 */ "plus_num",
- /* 172 */ "minus_num",
- /* 173 */ "scanpt",
- /* 174 */ "ccons",
- /* 175 */ "term",
- /* 176 */ "expr",
- /* 177 */ "onconf",
- /* 178 */ "sortorder",
- /* 179 */ "autoinc",
- /* 180 */ "eidlist_opt",
- /* 181 */ "refargs",
- /* 182 */ "defer_subclause",
- /* 183 */ "refarg",
- /* 184 */ "refact",
- /* 185 */ "init_deferred_pred_opt",
- /* 186 */ "conslist",
- /* 187 */ "tconscomma",
- /* 188 */ "tcons",
- /* 189 */ "sortlist",
- /* 190 */ "eidlist",
- /* 191 */ "defer_subclause_opt",
- /* 192 */ "orconf",
- /* 193 */ "resolvetype",
- /* 194 */ "raisetype",
- /* 195 */ "ifexists",
- /* 196 */ "fullname",
- /* 197 */ "selectnowith",
- /* 198 */ "oneselect",
- /* 199 */ "wqlist",
- /* 200 */ "multiselect_op",
- /* 201 */ "distinct",
- /* 202 */ "selcollist",
- /* 203 */ "from",
- /* 204 */ "where_opt",
- /* 205 */ "groupby_opt",
- /* 206 */ "having_opt",
- /* 207 */ "orderby_opt",
- /* 208 */ "limit_opt",
- /* 209 */ "values",
- /* 210 */ "nexprlist",
- /* 211 */ "sclp",
- /* 212 */ "as",
- /* 213 */ "seltablist",
- /* 214 */ "stl_prefix",
- /* 215 */ "joinop",
- /* 216 */ "indexed_opt",
- /* 217 */ "on_opt",
- /* 218 */ "using_opt",
- /* 219 */ "exprlist",
- /* 220 */ "xfullname",
- /* 221 */ "idlist",
- /* 222 */ "with",
- /* 223 */ "setlist",
- /* 224 */ "insert_cmd",
- /* 225 */ "idlist_opt",
- /* 226 */ "upsert",
- /* 227 */ "likeop",
- /* 228 */ "between_op",
- /* 229 */ "in_op",
- /* 230 */ "paren_exprlist",
- /* 231 */ "case_operand",
- /* 232 */ "case_exprlist",
- /* 233 */ "case_else",
- /* 234 */ "uniqueflag",
- /* 235 */ "collate",
- /* 236 */ "nmnum",
- /* 237 */ "trigger_decl",
- /* 238 */ "trigger_cmd_list",
- /* 239 */ "trigger_time",
- /* 240 */ "trigger_event",
- /* 241 */ "foreach_clause",
- /* 242 */ "when_clause",
- /* 243 */ "trigger_cmd",
- /* 244 */ "trnm",
- /* 245 */ "tridxby",
- /* 246 */ "database_kw_opt",
- /* 247 */ "key_opt",
- /* 248 */ "add_column_fullname",
- /* 249 */ "kwcolumn_opt",
- /* 250 */ "create_vtab",
- /* 251 */ "vtabarglist",
- /* 252 */ "vtabarg",
- /* 253 */ "vtabargtoken",
- /* 254 */ "lp",
- /* 255 */ "anylist",
+ /* 150 */ "cmd",
+ /* 151 */ "transtype",
+ /* 152 */ "trans_opt",
+ /* 153 */ "nm",
+ /* 154 */ "savepoint_opt",
+ /* 155 */ "create_table",
+ /* 156 */ "create_table_args",
+ /* 157 */ "createkw",
+ /* 158 */ "temp",
+ /* 159 */ "ifnotexists",
+ /* 160 */ "dbnm",
+ /* 161 */ "columnlist",
+ /* 162 */ "conslist_opt",
+ /* 163 */ "table_options",
+ /* 164 */ "select",
+ /* 165 */ "columnname",
+ /* 166 */ "carglist",
+ /* 167 */ "typetoken",
+ /* 168 */ "typename",
+ /* 169 */ "signed",
+ /* 170 */ "plus_num",
+ /* 171 */ "minus_num",
+ /* 172 */ "scanpt",
+ /* 173 */ "ccons",
+ /* 174 */ "term",
+ /* 175 */ "expr",
+ /* 176 */ "onconf",
+ /* 177 */ "sortorder",
+ /* 178 */ "autoinc",
+ /* 179 */ "eidlist_opt",
+ /* 180 */ "refargs",
+ /* 181 */ "defer_subclause",
+ /* 182 */ "refarg",
+ /* 183 */ "refact",
+ /* 184 */ "init_deferred_pred_opt",
+ /* 185 */ "conslist",
+ /* 186 */ "tconscomma",
+ /* 187 */ "tcons",
+ /* 188 */ "sortlist",
+ /* 189 */ "eidlist",
+ /* 190 */ "defer_subclause_opt",
+ /* 191 */ "orconf",
+ /* 192 */ "resolvetype",
+ /* 193 */ "raisetype",
+ /* 194 */ "ifexists",
+ /* 195 */ "fullname",
+ /* 196 */ "selectnowith",
+ /* 197 */ "oneselect",
+ /* 198 */ "wqlist",
+ /* 199 */ "multiselect_op",
+ /* 200 */ "distinct",
+ /* 201 */ "selcollist",
+ /* 202 */ "from",
+ /* 203 */ "where_opt",
+ /* 204 */ "groupby_opt",
+ /* 205 */ "having_opt",
+ /* 206 */ "orderby_opt",
+ /* 207 */ "limit_opt",
+ /* 208 */ "values",
+ /* 209 */ "nexprlist",
+ /* 210 */ "sclp",
+ /* 211 */ "as",
+ /* 212 */ "seltablist",
+ /* 213 */ "stl_prefix",
+ /* 214 */ "joinop",
+ /* 215 */ "indexed_opt",
+ /* 216 */ "on_opt",
+ /* 217 */ "using_opt",
+ /* 218 */ "exprlist",
+ /* 219 */ "xfullname",
+ /* 220 */ "idlist",
+ /* 221 */ "with",
+ /* 222 */ "setlist",
+ /* 223 */ "insert_cmd",
+ /* 224 */ "idlist_opt",
+ /* 225 */ "upsert",
+ /* 226 */ "likeop",
+ /* 227 */ "between_op",
+ /* 228 */ "in_op",
+ /* 229 */ "paren_exprlist",
+ /* 230 */ "case_operand",
+ /* 231 */ "case_exprlist",
+ /* 232 */ "case_else",
+ /* 233 */ "uniqueflag",
+ /* 234 */ "collate",
+ /* 235 */ "nmnum",
+ /* 236 */ "trigger_decl",
+ /* 237 */ "trigger_cmd_list",
+ /* 238 */ "trigger_time",
+ /* 239 */ "trigger_event",
+ /* 240 */ "foreach_clause",
+ /* 241 */ "when_clause",
+ /* 242 */ "trigger_cmd",
+ /* 243 */ "trnm",
+ /* 244 */ "tridxby",
+ /* 245 */ "database_kw_opt",
+ /* 246 */ "key_opt",
+ /* 247 */ "add_column_fullname",
+ /* 248 */ "kwcolumn_opt",
+ /* 249 */ "create_vtab",
+ /* 250 */ "vtabarglist",
+ /* 251 */ "vtabarg",
+ /* 252 */ "vtabargtoken",
+ /* 253 */ "lp",
+ /* 254 */ "anylist",
};
#endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */
@@ -148296,347 +148239,340 @@ static const char *const yyTokenName[] = {
/* For tracing reduce actions, the names of all rules are required.
*/
static const char *const yyRuleName[] = {
- /* 0 */ "explain ::= EXPLAIN",
- /* 1 */ "explain ::= EXPLAIN QUERY PLAN",
- /* 2 */ "cmdx ::= cmd",
- /* 3 */ "cmd ::= BEGIN transtype trans_opt",
- /* 4 */ "transtype ::=",
- /* 5 */ "transtype ::= DEFERRED",
- /* 6 */ "transtype ::= IMMEDIATE",
- /* 7 */ "transtype ::= EXCLUSIVE",
- /* 8 */ "cmd ::= COMMIT|END trans_opt",
- /* 9 */ "cmd ::= ROLLBACK trans_opt",
- /* 10 */ "cmd ::= SAVEPOINT nm",
- /* 11 */ "cmd ::= RELEASE savepoint_opt nm",
- /* 12 */ "cmd ::= ROLLBACK trans_opt TO savepoint_opt nm",
- /* 13 */ "create_table ::= createkw temp TABLE ifnotexists nm dbnm",
- /* 14 */ "createkw ::= CREATE",
- /* 15 */ "ifnotexists ::=",
- /* 16 */ "ifnotexists ::= IF NOT EXISTS",
- /* 17 */ "temp ::= TEMP",
- /* 18 */ "temp ::=",
- /* 19 */ "create_table_args ::= LP columnlist conslist_opt RP table_options",
- /* 20 */ "create_table_args ::= AS select",
- /* 21 */ "table_options ::=",
- /* 22 */ "table_options ::= WITHOUT nm",
- /* 23 */ "columnname ::= nm typetoken",
- /* 24 */ "typetoken ::=",
- /* 25 */ "typetoken ::= typename LP signed RP",
- /* 26 */ "typetoken ::= typename LP signed COMMA signed RP",
- /* 27 */ "typename ::= typename ID|STRING",
- /* 28 */ "scanpt ::=",
- /* 29 */ "ccons ::= CONSTRAINT nm",
- /* 30 */ "ccons ::= DEFAULT scanpt term scanpt",
- /* 31 */ "ccons ::= DEFAULT LP expr RP",
- /* 32 */ "ccons ::= DEFAULT PLUS term scanpt",
- /* 33 */ "ccons ::= DEFAULT MINUS term scanpt",
- /* 34 */ "ccons ::= DEFAULT scanpt ID|INDEXED",
- /* 35 */ "ccons ::= NOT NULL onconf",
- /* 36 */ "ccons ::= PRIMARY KEY sortorder onconf autoinc",
- /* 37 */ "ccons ::= UNIQUE onconf",
- /* 38 */ "ccons ::= CHECK LP expr RP",
- /* 39 */ "ccons ::= REFERENCES nm eidlist_opt refargs",
- /* 40 */ "ccons ::= defer_subclause",
- /* 41 */ "ccons ::= COLLATE ID|STRING",
- /* 42 */ "autoinc ::=",
- /* 43 */ "autoinc ::= AUTOINCR",
- /* 44 */ "refargs ::=",
- /* 45 */ "refargs ::= refargs refarg",
- /* 46 */ "refarg ::= MATCH nm",
- /* 47 */ "refarg ::= ON INSERT refact",
- /* 48 */ "refarg ::= ON DELETE refact",
- /* 49 */ "refarg ::= ON UPDATE refact",
- /* 50 */ "refact ::= SET NULL",
- /* 51 */ "refact ::= SET DEFAULT",
- /* 52 */ "refact ::= CASCADE",
- /* 53 */ "refact ::= RESTRICT",
- /* 54 */ "refact ::= NO ACTION",
- /* 55 */ "defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt",
- /* 56 */ "defer_subclause ::= DEFERRABLE init_deferred_pred_opt",
- /* 57 */ "init_deferred_pred_opt ::=",
- /* 58 */ "init_deferred_pred_opt ::= INITIALLY DEFERRED",
- /* 59 */ "init_deferred_pred_opt ::= INITIALLY IMMEDIATE",
- /* 60 */ "conslist_opt ::=",
- /* 61 */ "tconscomma ::= COMMA",
- /* 62 */ "tcons ::= CONSTRAINT nm",
- /* 63 */ "tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf",
- /* 64 */ "tcons ::= UNIQUE LP sortlist RP onconf",
- /* 65 */ "tcons ::= CHECK LP expr RP onconf",
- /* 66 */ "tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt",
- /* 67 */ "defer_subclause_opt ::=",
- /* 68 */ "onconf ::=",
- /* 69 */ "onconf ::= ON CONFLICT resolvetype",
- /* 70 */ "orconf ::=",
- /* 71 */ "orconf ::= OR resolvetype",
- /* 72 */ "resolvetype ::= IGNORE",
- /* 73 */ "resolvetype ::= REPLACE",
- /* 74 */ "cmd ::= DROP TABLE ifexists fullname",
- /* 75 */ "ifexists ::= IF EXISTS",
- /* 76 */ "ifexists ::=",
- /* 77 */ "cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select",
- /* 78 */ "cmd ::= DROP VIEW ifexists fullname",
- /* 79 */ "cmd ::= select",
- /* 80 */ "select ::= WITH wqlist selectnowith",
- /* 81 */ "select ::= WITH RECURSIVE wqlist selectnowith",
- /* 82 */ "select ::= selectnowith",
- /* 83 */ "selectnowith ::= selectnowith multiselect_op oneselect",
- /* 84 */ "multiselect_op ::= UNION",
- /* 85 */ "multiselect_op ::= UNION ALL",
- /* 86 */ "multiselect_op ::= EXCEPT|INTERSECT",
- /* 87 */ "oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt",
- /* 88 */ "values ::= VALUES LP nexprlist RP",
- /* 89 */ "values ::= values COMMA LP nexprlist RP",
- /* 90 */ "distinct ::= DISTINCT",
- /* 91 */ "distinct ::= ALL",
- /* 92 */ "distinct ::=",
- /* 93 */ "sclp ::=",
- /* 94 */ "selcollist ::= sclp scanpt expr scanpt as",
- /* 95 */ "selcollist ::= sclp scanpt STAR",
- /* 96 */ "selcollist ::= sclp scanpt nm DOT STAR",
- /* 97 */ "as ::= AS nm",
- /* 98 */ "as ::=",
- /* 99 */ "from ::=",
- /* 100 */ "from ::= FROM seltablist",
- /* 101 */ "stl_prefix ::= seltablist joinop",
- /* 102 */ "stl_prefix ::=",
- /* 103 */ "seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt",
- /* 104 */ "seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt",
- /* 105 */ "seltablist ::= stl_prefix LP select RP as on_opt using_opt",
- /* 106 */ "seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt",
- /* 107 */ "dbnm ::=",
- /* 108 */ "dbnm ::= DOT nm",
- /* 109 */ "fullname ::= nm",
- /* 110 */ "fullname ::= nm DOT nm",
- /* 111 */ "xfullname ::= nm",
- /* 112 */ "xfullname ::= nm DOT nm",
- /* 113 */ "xfullname ::= nm DOT nm AS nm",
- /* 114 */ "xfullname ::= nm AS nm",
- /* 115 */ "joinop ::= COMMA|JOIN",
- /* 116 */ "joinop ::= JOIN_KW JOIN",
- /* 117 */ "joinop ::= JOIN_KW nm JOIN",
- /* 118 */ "joinop ::= JOIN_KW nm nm JOIN",
- /* 119 */ "on_opt ::= ON expr",
- /* 120 */ "on_opt ::=",
- /* 121 */ "indexed_opt ::=",
- /* 122 */ "indexed_opt ::= INDEXED BY nm",
- /* 123 */ "indexed_opt ::= NOT INDEXED",
- /* 124 */ "using_opt ::= USING LP idlist RP",
- /* 125 */ "using_opt ::=",
- /* 126 */ "orderby_opt ::=",
- /* 127 */ "orderby_opt ::= ORDER BY sortlist",
- /* 128 */ "sortlist ::= sortlist COMMA expr sortorder",
- /* 129 */ "sortlist ::= expr sortorder",
- /* 130 */ "sortorder ::= ASC",
- /* 131 */ "sortorder ::= DESC",
- /* 132 */ "sortorder ::=",
- /* 133 */ "groupby_opt ::=",
- /* 134 */ "groupby_opt ::= GROUP BY nexprlist",
- /* 135 */ "having_opt ::=",
- /* 136 */ "having_opt ::= HAVING expr",
- /* 137 */ "limit_opt ::=",
- /* 138 */ "limit_opt ::= LIMIT expr",
- /* 139 */ "limit_opt ::= LIMIT expr OFFSET expr",
- /* 140 */ "limit_opt ::= LIMIT expr COMMA expr",
- /* 141 */ "cmd ::= with DELETE FROM xfullname indexed_opt where_opt",
- /* 142 */ "where_opt ::=",
- /* 143 */ "where_opt ::= WHERE expr",
- /* 144 */ "cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt",
- /* 145 */ "setlist ::= setlist COMMA nm EQ expr",
- /* 146 */ "setlist ::= setlist COMMA LP idlist RP EQ expr",
- /* 147 */ "setlist ::= nm EQ expr",
- /* 148 */ "setlist ::= LP idlist RP EQ expr",
- /* 149 */ "cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert",
- /* 150 */ "cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES",
- /* 151 */ "upsert ::=",
- /* 152 */ "upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt",
- /* 153 */ "upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING",
- /* 154 */ "upsert ::= ON CONFLICT DO NOTHING",
- /* 155 */ "insert_cmd ::= INSERT orconf",
- /* 156 */ "insert_cmd ::= REPLACE",
- /* 157 */ "idlist_opt ::=",
- /* 158 */ "idlist_opt ::= LP idlist RP",
- /* 159 */ "idlist ::= idlist COMMA nm",
- /* 160 */ "idlist ::= nm",
- /* 161 */ "expr ::= LP expr RP",
- /* 162 */ "expr ::= ID|INDEXED",
- /* 163 */ "expr ::= JOIN_KW",
- /* 164 */ "expr ::= nm DOT nm",
- /* 165 */ "expr ::= nm DOT nm DOT nm",
- /* 166 */ "term ::= NULL|FLOAT|BLOB",
- /* 167 */ "term ::= STRING",
- /* 168 */ "term ::= INTEGER",
- /* 169 */ "expr ::= VARIABLE",
- /* 170 */ "expr ::= expr COLLATE ID|STRING",
- /* 171 */ "expr ::= CAST LP expr AS typetoken RP",
- /* 172 */ "expr ::= ID|INDEXED LP distinct exprlist RP",
- /* 173 */ "expr ::= ID|INDEXED LP STAR RP",
- /* 174 */ "term ::= CTIME_KW",
- /* 175 */ "expr ::= LP nexprlist COMMA expr RP",
- /* 176 */ "expr ::= expr AND expr",
- /* 177 */ "expr ::= expr OR expr",
- /* 178 */ "expr ::= expr LT|GT|GE|LE expr",
- /* 179 */ "expr ::= expr EQ|NE expr",
- /* 180 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr",
- /* 181 */ "expr ::= expr PLUS|MINUS expr",
- /* 182 */ "expr ::= expr STAR|SLASH|REM expr",
- /* 183 */ "expr ::= expr CONCAT expr",
- /* 184 */ "likeop ::= NOT LIKE_KW|MATCH",
- /* 185 */ "expr ::= expr likeop expr",
- /* 186 */ "expr ::= expr likeop expr ESCAPE expr",
- /* 187 */ "expr ::= expr ISNULL|NOTNULL",
- /* 188 */ "expr ::= expr NOT NULL",
- /* 189 */ "expr ::= expr IS expr",
- /* 190 */ "expr ::= expr IS NOT expr",
- /* 191 */ "expr ::= NOT expr",
- /* 192 */ "expr ::= BITNOT expr",
- /* 193 */ "expr ::= PLUS|MINUS expr",
- /* 194 */ "between_op ::= BETWEEN",
- /* 195 */ "between_op ::= NOT BETWEEN",
- /* 196 */ "expr ::= expr between_op expr AND expr",
- /* 197 */ "in_op ::= IN",
- /* 198 */ "in_op ::= NOT IN",
- /* 199 */ "expr ::= expr in_op LP exprlist RP",
- /* 200 */ "expr ::= LP select RP",
- /* 201 */ "expr ::= expr in_op LP select RP",
- /* 202 */ "expr ::= expr in_op nm dbnm paren_exprlist",
- /* 203 */ "expr ::= EXISTS LP select RP",
- /* 204 */ "expr ::= CASE case_operand case_exprlist case_else END",
- /* 205 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr",
- /* 206 */ "case_exprlist ::= WHEN expr THEN expr",
- /* 207 */ "case_else ::= ELSE expr",
- /* 208 */ "case_else ::=",
- /* 209 */ "case_operand ::= expr",
- /* 210 */ "case_operand ::=",
- /* 211 */ "exprlist ::=",
- /* 212 */ "nexprlist ::= nexprlist COMMA expr",
- /* 213 */ "nexprlist ::= expr",
- /* 214 */ "paren_exprlist ::=",
- /* 215 */ "paren_exprlist ::= LP exprlist RP",
- /* 216 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt",
- /* 217 */ "uniqueflag ::= UNIQUE",
- /* 218 */ "uniqueflag ::=",
- /* 219 */ "eidlist_opt ::=",
- /* 220 */ "eidlist_opt ::= LP eidlist RP",
- /* 221 */ "eidlist ::= eidlist COMMA nm collate sortorder",
- /* 222 */ "eidlist ::= nm collate sortorder",
- /* 223 */ "collate ::=",
- /* 224 */ "collate ::= COLLATE ID|STRING",
- /* 225 */ "cmd ::= DROP INDEX ifexists fullname",
- /* 226 */ "cmd ::= VACUUM",
- /* 227 */ "cmd ::= VACUUM nm",
- /* 228 */ "cmd ::= PRAGMA nm dbnm",
- /* 229 */ "cmd ::= PRAGMA nm dbnm EQ nmnum",
- /* 230 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP",
- /* 231 */ "cmd ::= PRAGMA nm dbnm EQ minus_num",
- /* 232 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP",
- /* 233 */ "plus_num ::= PLUS INTEGER|FLOAT",
- /* 234 */ "minus_num ::= MINUS INTEGER|FLOAT",
- /* 235 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
- /* 236 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
- /* 237 */ "trigger_time ::= BEFORE|AFTER",
- /* 238 */ "trigger_time ::= INSTEAD OF",
- /* 239 */ "trigger_time ::=",
- /* 240 */ "trigger_event ::= DELETE|INSERT",
- /* 241 */ "trigger_event ::= UPDATE",
- /* 242 */ "trigger_event ::= UPDATE OF idlist",
- /* 243 */ "when_clause ::=",
- /* 244 */ "when_clause ::= WHEN expr",
- /* 245 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
- /* 246 */ "trigger_cmd_list ::= trigger_cmd SEMI",
- /* 247 */ "trnm ::= nm DOT nm",
- /* 248 */ "tridxby ::= INDEXED BY nm",
- /* 249 */ "tridxby ::= NOT INDEXED",
- /* 250 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt",
- /* 251 */ "trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt",
- /* 252 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt",
- /* 253 */ "trigger_cmd ::= scanpt select scanpt",
- /* 254 */ "expr ::= RAISE LP IGNORE RP",
- /* 255 */ "expr ::= RAISE LP raisetype COMMA nm RP",
- /* 256 */ "raisetype ::= ROLLBACK",
- /* 257 */ "raisetype ::= ABORT",
- /* 258 */ "raisetype ::= FAIL",
- /* 259 */ "cmd ::= DROP TRIGGER ifexists fullname",
- /* 260 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
- /* 261 */ "cmd ::= DETACH database_kw_opt expr",
- /* 262 */ "key_opt ::=",
- /* 263 */ "key_opt ::= KEY expr",
- /* 264 */ "cmd ::= REINDEX",
- /* 265 */ "cmd ::= REINDEX nm dbnm",
- /* 266 */ "cmd ::= ANALYZE",
- /* 267 */ "cmd ::= ANALYZE nm dbnm",
- /* 268 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
- /* 269 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist",
- /* 270 */ "add_column_fullname ::= fullname",
- /* 271 */ "cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm",
- /* 272 */ "cmd ::= create_vtab",
- /* 273 */ "cmd ::= create_vtab LP vtabarglist RP",
- /* 274 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
- /* 275 */ "vtabarg ::=",
- /* 276 */ "vtabargtoken ::= ANY",
- /* 277 */ "vtabargtoken ::= lp anylist RP",
- /* 278 */ "lp ::= LP",
- /* 279 */ "with ::= WITH wqlist",
- /* 280 */ "with ::= WITH RECURSIVE wqlist",
- /* 281 */ "wqlist ::= nm eidlist_opt AS LP select RP",
- /* 282 */ "wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP",
- /* 283 */ "input ::= cmdlist",
- /* 284 */ "cmdlist ::= cmdlist ecmd",
- /* 285 */ "cmdlist ::= ecmd",
- /* 286 */ "ecmd ::= SEMI",
- /* 287 */ "ecmd ::= cmdx SEMI",
- /* 288 */ "ecmd ::= explain cmdx",
- /* 289 */ "trans_opt ::=",
- /* 290 */ "trans_opt ::= TRANSACTION",
- /* 291 */ "trans_opt ::= TRANSACTION nm",
- /* 292 */ "savepoint_opt ::= SAVEPOINT",
- /* 293 */ "savepoint_opt ::=",
- /* 294 */ "cmd ::= create_table create_table_args",
- /* 295 */ "columnlist ::= columnlist COMMA columnname carglist",
- /* 296 */ "columnlist ::= columnname carglist",
- /* 297 */ "nm ::= ID|INDEXED",
- /* 298 */ "nm ::= STRING",
- /* 299 */ "nm ::= JOIN_KW",
- /* 300 */ "typetoken ::= typename",
- /* 301 */ "typename ::= ID|STRING",
- /* 302 */ "signed ::= plus_num",
- /* 303 */ "signed ::= minus_num",
- /* 304 */ "carglist ::= carglist ccons",
- /* 305 */ "carglist ::=",
- /* 306 */ "ccons ::= NULL onconf",
- /* 307 */ "conslist_opt ::= COMMA conslist",
- /* 308 */ "conslist ::= conslist tconscomma tcons",
- /* 309 */ "conslist ::= tcons",
- /* 310 */ "tconscomma ::=",
- /* 311 */ "defer_subclause_opt ::= defer_subclause",
- /* 312 */ "resolvetype ::= raisetype",
- /* 313 */ "selectnowith ::= oneselect",
- /* 314 */ "oneselect ::= values",
- /* 315 */ "sclp ::= selcollist COMMA",
- /* 316 */ "as ::= ID|STRING",
- /* 317 */ "expr ::= term",
- /* 318 */ "likeop ::= LIKE_KW|MATCH",
- /* 319 */ "exprlist ::= nexprlist",
- /* 320 */ "nmnum ::= plus_num",
- /* 321 */ "nmnum ::= nm",
- /* 322 */ "nmnum ::= ON",
- /* 323 */ "nmnum ::= DELETE",
- /* 324 */ "nmnum ::= DEFAULT",
- /* 325 */ "plus_num ::= INTEGER|FLOAT",
- /* 326 */ "foreach_clause ::=",
- /* 327 */ "foreach_clause ::= FOR EACH ROW",
- /* 328 */ "trnm ::= nm",
- /* 329 */ "tridxby ::=",
- /* 330 */ "database_kw_opt ::= DATABASE",
- /* 331 */ "database_kw_opt ::=",
- /* 332 */ "kwcolumn_opt ::=",
- /* 333 */ "kwcolumn_opt ::= COLUMNKW",
- /* 334 */ "vtabarglist ::= vtabarg",
- /* 335 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
- /* 336 */ "vtabarg ::= vtabarg vtabargtoken",
- /* 337 */ "anylist ::=",
- /* 338 */ "anylist ::= anylist LP anylist RP",
- /* 339 */ "anylist ::= anylist ANY",
- /* 340 */ "with ::=",
+ /* 0 */ "cmdx ::= cmd",
+ /* 1 */ "cmd ::= BEGIN transtype trans_opt",
+ /* 2 */ "transtype ::=",
+ /* 3 */ "transtype ::= DEFERRED",
+ /* 4 */ "transtype ::= IMMEDIATE",
+ /* 5 */ "transtype ::= EXCLUSIVE",
+ /* 6 */ "cmd ::= COMMIT|END trans_opt",
+ /* 7 */ "cmd ::= ROLLBACK trans_opt",
+ /* 8 */ "cmd ::= SAVEPOINT nm",
+ /* 9 */ "cmd ::= RELEASE savepoint_opt nm",
+ /* 10 */ "cmd ::= ROLLBACK trans_opt TO savepoint_opt nm",
+ /* 11 */ "create_table ::= createkw temp TABLE ifnotexists nm dbnm",
+ /* 12 */ "createkw ::= CREATE",
+ /* 13 */ "ifnotexists ::=",
+ /* 14 */ "ifnotexists ::= IF NOT EXISTS",
+ /* 15 */ "temp ::= TEMP",
+ /* 16 */ "temp ::=",
+ /* 17 */ "create_table_args ::= LP columnlist conslist_opt RP table_options",
+ /* 18 */ "create_table_args ::= AS select",
+ /* 19 */ "table_options ::=",
+ /* 20 */ "table_options ::= WITHOUT nm",
+ /* 21 */ "columnname ::= nm typetoken",
+ /* 22 */ "typetoken ::=",
+ /* 23 */ "typetoken ::= typename LP signed RP",
+ /* 24 */ "typetoken ::= typename LP signed COMMA signed RP",
+ /* 25 */ "typename ::= typename ID|STRING",
+ /* 26 */ "scanpt ::=",
+ /* 27 */ "ccons ::= CONSTRAINT nm",
+ /* 28 */ "ccons ::= DEFAULT scanpt term scanpt",
+ /* 29 */ "ccons ::= DEFAULT LP expr RP",
+ /* 30 */ "ccons ::= DEFAULT PLUS term scanpt",
+ /* 31 */ "ccons ::= DEFAULT MINUS term scanpt",
+ /* 32 */ "ccons ::= DEFAULT scanpt ID|INDEXED",
+ /* 33 */ "ccons ::= NOT NULL onconf",
+ /* 34 */ "ccons ::= PRIMARY KEY sortorder onconf autoinc",
+ /* 35 */ "ccons ::= UNIQUE onconf",
+ /* 36 */ "ccons ::= CHECK LP expr RP",
+ /* 37 */ "ccons ::= REFERENCES nm eidlist_opt refargs",
+ /* 38 */ "ccons ::= defer_subclause",
+ /* 39 */ "ccons ::= COLLATE ID|STRING",
+ /* 40 */ "autoinc ::=",
+ /* 41 */ "autoinc ::= AUTOINCR",
+ /* 42 */ "refargs ::=",
+ /* 43 */ "refargs ::= refargs refarg",
+ /* 44 */ "refarg ::= MATCH nm",
+ /* 45 */ "refarg ::= ON INSERT refact",
+ /* 46 */ "refarg ::= ON DELETE refact",
+ /* 47 */ "refarg ::= ON UPDATE refact",
+ /* 48 */ "refact ::= SET NULL",
+ /* 49 */ "refact ::= SET DEFAULT",
+ /* 50 */ "refact ::= CASCADE",
+ /* 51 */ "refact ::= RESTRICT",
+ /* 52 */ "refact ::= NO ACTION",
+ /* 53 */ "defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt",
+ /* 54 */ "defer_subclause ::= DEFERRABLE init_deferred_pred_opt",
+ /* 55 */ "init_deferred_pred_opt ::=",
+ /* 56 */ "init_deferred_pred_opt ::= INITIALLY DEFERRED",
+ /* 57 */ "init_deferred_pred_opt ::= INITIALLY IMMEDIATE",
+ /* 58 */ "conslist_opt ::=",
+ /* 59 */ "tconscomma ::= COMMA",
+ /* 60 */ "tcons ::= CONSTRAINT nm",
+ /* 61 */ "tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf",
+ /* 62 */ "tcons ::= UNIQUE LP sortlist RP onconf",
+ /* 63 */ "tcons ::= CHECK LP expr RP onconf",
+ /* 64 */ "tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt",
+ /* 65 */ "defer_subclause_opt ::=",
+ /* 66 */ "onconf ::=",
+ /* 67 */ "onconf ::= ON CONFLICT resolvetype",
+ /* 68 */ "orconf ::=",
+ /* 69 */ "orconf ::= OR resolvetype",
+ /* 70 */ "resolvetype ::= IGNORE",
+ /* 71 */ "resolvetype ::= REPLACE",
+ /* 72 */ "cmd ::= DROP TABLE ifexists fullname",
+ /* 73 */ "ifexists ::= IF EXISTS",
+ /* 74 */ "ifexists ::=",
+ /* 75 */ "cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select",
+ /* 76 */ "cmd ::= DROP VIEW ifexists fullname",
+ /* 77 */ "cmd ::= select",
+ /* 78 */ "select ::= WITH wqlist selectnowith",
+ /* 79 */ "select ::= WITH RECURSIVE wqlist selectnowith",
+ /* 80 */ "select ::= selectnowith",
+ /* 81 */ "selectnowith ::= selectnowith multiselect_op oneselect",
+ /* 82 */ "multiselect_op ::= UNION",
+ /* 83 */ "multiselect_op ::= UNION ALL",
+ /* 84 */ "multiselect_op ::= EXCEPT|INTERSECT",
+ /* 85 */ "oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt",
+ /* 86 */ "values ::= VALUES LP nexprlist RP",
+ /* 87 */ "values ::= values COMMA LP nexprlist RP",
+ /* 88 */ "distinct ::= DISTINCT",
+ /* 89 */ "distinct ::= ALL",
+ /* 90 */ "distinct ::=",
+ /* 91 */ "sclp ::=",
+ /* 92 */ "selcollist ::= sclp scanpt expr scanpt as",
+ /* 93 */ "selcollist ::= sclp scanpt STAR",
+ /* 94 */ "selcollist ::= sclp scanpt nm DOT STAR",
+ /* 95 */ "as ::= AS nm",
+ /* 96 */ "as ::=",
+ /* 97 */ "from ::=",
+ /* 98 */ "from ::= FROM seltablist",
+ /* 99 */ "stl_prefix ::= seltablist joinop",
+ /* 100 */ "stl_prefix ::=",
+ /* 101 */ "seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt",
+ /* 102 */ "seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt",
+ /* 103 */ "seltablist ::= stl_prefix LP select RP as on_opt using_opt",
+ /* 104 */ "seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt",
+ /* 105 */ "dbnm ::=",
+ /* 106 */ "dbnm ::= DOT nm",
+ /* 107 */ "fullname ::= nm",
+ /* 108 */ "fullname ::= nm DOT nm",
+ /* 109 */ "xfullname ::= nm",
+ /* 110 */ "xfullname ::= nm DOT nm",
+ /* 111 */ "xfullname ::= nm DOT nm AS nm",
+ /* 112 */ "xfullname ::= nm AS nm",
+ /* 113 */ "joinop ::= COMMA|JOIN",
+ /* 114 */ "joinop ::= JOIN_KW JOIN",
+ /* 115 */ "joinop ::= JOIN_KW nm JOIN",
+ /* 116 */ "joinop ::= JOIN_KW nm nm JOIN",
+ /* 117 */ "on_opt ::= ON expr",
+ /* 118 */ "on_opt ::=",
+ /* 119 */ "indexed_opt ::=",
+ /* 120 */ "indexed_opt ::= INDEXED BY nm",
+ /* 121 */ "indexed_opt ::= NOT INDEXED",
+ /* 122 */ "using_opt ::= USING LP idlist RP",
+ /* 123 */ "using_opt ::=",
+ /* 124 */ "orderby_opt ::=",
+ /* 125 */ "orderby_opt ::= ORDER BY sortlist",
+ /* 126 */ "sortlist ::= sortlist COMMA expr sortorder",
+ /* 127 */ "sortlist ::= expr sortorder",
+ /* 128 */ "sortorder ::= ASC",
+ /* 129 */ "sortorder ::= DESC",
+ /* 130 */ "sortorder ::=",
+ /* 131 */ "groupby_opt ::=",
+ /* 132 */ "groupby_opt ::= GROUP BY nexprlist",
+ /* 133 */ "having_opt ::=",
+ /* 134 */ "having_opt ::= HAVING expr",
+ /* 135 */ "limit_opt ::=",
+ /* 136 */ "limit_opt ::= LIMIT expr",
+ /* 137 */ "limit_opt ::= LIMIT expr OFFSET expr",
+ /* 138 */ "limit_opt ::= LIMIT expr COMMA expr",
+ /* 139 */ "cmd ::= with DELETE FROM xfullname indexed_opt where_opt",
+ /* 140 */ "where_opt ::=",
+ /* 141 */ "where_opt ::= WHERE expr",
+ /* 142 */ "cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt",
+ /* 143 */ "setlist ::= setlist COMMA nm EQ expr",
+ /* 144 */ "setlist ::= setlist COMMA LP idlist RP EQ expr",
+ /* 145 */ "setlist ::= nm EQ expr",
+ /* 146 */ "setlist ::= LP idlist RP EQ expr",
+ /* 147 */ "cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert",
+ /* 148 */ "cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES",
+ /* 149 */ "upsert ::=",
+ /* 150 */ "upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt",
+ /* 151 */ "upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING",
+ /* 152 */ "upsert ::= ON CONFLICT DO NOTHING",
+ /* 153 */ "insert_cmd ::= INSERT orconf",
+ /* 154 */ "insert_cmd ::= REPLACE",
+ /* 155 */ "idlist_opt ::=",
+ /* 156 */ "idlist_opt ::= LP idlist RP",
+ /* 157 */ "idlist ::= idlist COMMA nm",
+ /* 158 */ "idlist ::= nm",
+ /* 159 */ "expr ::= LP expr RP",
+ /* 160 */ "expr ::= ID|INDEXED",
+ /* 161 */ "expr ::= JOIN_KW",
+ /* 162 */ "expr ::= nm DOT nm",
+ /* 163 */ "expr ::= nm DOT nm DOT nm",
+ /* 164 */ "term ::= NULL|FLOAT|BLOB",
+ /* 165 */ "term ::= STRING",
+ /* 166 */ "term ::= INTEGER",
+ /* 167 */ "expr ::= VARIABLE",
+ /* 168 */ "expr ::= expr COLLATE ID|STRING",
+ /* 169 */ "expr ::= CAST LP expr AS typetoken RP",
+ /* 170 */ "expr ::= ID|INDEXED LP distinct exprlist RP",
+ /* 171 */ "expr ::= ID|INDEXED LP STAR RP",
+ /* 172 */ "term ::= CTIME_KW",
+ /* 173 */ "expr ::= LP nexprlist COMMA expr RP",
+ /* 174 */ "expr ::= expr AND expr",
+ /* 175 */ "expr ::= expr OR expr",
+ /* 176 */ "expr ::= expr LT|GT|GE|LE expr",
+ /* 177 */ "expr ::= expr EQ|NE expr",
+ /* 178 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr",
+ /* 179 */ "expr ::= expr PLUS|MINUS expr",
+ /* 180 */ "expr ::= expr STAR|SLASH|REM expr",
+ /* 181 */ "expr ::= expr CONCAT expr",
+ /* 182 */ "likeop ::= NOT LIKE_KW|MATCH",
+ /* 183 */ "expr ::= expr likeop expr",
+ /* 184 */ "expr ::= expr likeop expr ESCAPE expr",
+ /* 185 */ "expr ::= expr ISNULL|NOTNULL",
+ /* 186 */ "expr ::= expr NOT NULL",
+ /* 187 */ "expr ::= expr IS expr",
+ /* 188 */ "expr ::= expr IS NOT expr",
+ /* 189 */ "expr ::= NOT expr",
+ /* 190 */ "expr ::= BITNOT expr",
+ /* 191 */ "expr ::= PLUS|MINUS expr",
+ /* 192 */ "between_op ::= BETWEEN",
+ /* 193 */ "between_op ::= NOT BETWEEN",
+ /* 194 */ "expr ::= expr between_op expr AND expr",
+ /* 195 */ "in_op ::= IN",
+ /* 196 */ "in_op ::= NOT IN",
+ /* 197 */ "expr ::= expr in_op LP exprlist RP",
+ /* 198 */ "expr ::= LP select RP",
+ /* 199 */ "expr ::= expr in_op LP select RP",
+ /* 200 */ "expr ::= expr in_op nm dbnm paren_exprlist",
+ /* 201 */ "expr ::= EXISTS LP select RP",
+ /* 202 */ "expr ::= CASE case_operand case_exprlist case_else END",
+ /* 203 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr",
+ /* 204 */ "case_exprlist ::= WHEN expr THEN expr",
+ /* 205 */ "case_else ::= ELSE expr",
+ /* 206 */ "case_else ::=",
+ /* 207 */ "case_operand ::= expr",
+ /* 208 */ "case_operand ::=",
+ /* 209 */ "exprlist ::=",
+ /* 210 */ "nexprlist ::= nexprlist COMMA expr",
+ /* 211 */ "nexprlist ::= expr",
+ /* 212 */ "paren_exprlist ::=",
+ /* 213 */ "paren_exprlist ::= LP exprlist RP",
+ /* 214 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt",
+ /* 215 */ "uniqueflag ::= UNIQUE",
+ /* 216 */ "uniqueflag ::=",
+ /* 217 */ "eidlist_opt ::=",
+ /* 218 */ "eidlist_opt ::= LP eidlist RP",
+ /* 219 */ "eidlist ::= eidlist COMMA nm collate sortorder",
+ /* 220 */ "eidlist ::= nm collate sortorder",
+ /* 221 */ "collate ::=",
+ /* 222 */ "collate ::= COLLATE ID|STRING",
+ /* 223 */ "cmd ::= DROP INDEX ifexists fullname",
+ /* 224 */ "cmd ::= VACUUM",
+ /* 225 */ "cmd ::= VACUUM nm",
+ /* 226 */ "cmd ::= PRAGMA nm dbnm",
+ /* 227 */ "cmd ::= PRAGMA nm dbnm EQ nmnum",
+ /* 228 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP",
+ /* 229 */ "cmd ::= PRAGMA nm dbnm EQ minus_num",
+ /* 230 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP",
+ /* 231 */ "plus_num ::= PLUS INTEGER|FLOAT",
+ /* 232 */ "minus_num ::= MINUS INTEGER|FLOAT",
+ /* 233 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
+ /* 234 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
+ /* 235 */ "trigger_time ::= BEFORE|AFTER",
+ /* 236 */ "trigger_time ::= INSTEAD OF",
+ /* 237 */ "trigger_time ::=",
+ /* 238 */ "trigger_event ::= DELETE|INSERT",
+ /* 239 */ "trigger_event ::= UPDATE",
+ /* 240 */ "trigger_event ::= UPDATE OF idlist",
+ /* 241 */ "when_clause ::=",
+ /* 242 */ "when_clause ::= WHEN expr",
+ /* 243 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
+ /* 244 */ "trigger_cmd_list ::= trigger_cmd SEMI",
+ /* 245 */ "trnm ::= nm DOT nm",
+ /* 246 */ "tridxby ::= INDEXED BY nm",
+ /* 247 */ "tridxby ::= NOT INDEXED",
+ /* 248 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt",
+ /* 249 */ "trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt",
+ /* 250 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt",
+ /* 251 */ "trigger_cmd ::= scanpt select scanpt",
+ /* 252 */ "expr ::= RAISE LP IGNORE RP",
+ /* 253 */ "expr ::= RAISE LP raisetype COMMA nm RP",
+ /* 254 */ "raisetype ::= ROLLBACK",
+ /* 255 */ "raisetype ::= ABORT",
+ /* 256 */ "raisetype ::= FAIL",
+ /* 257 */ "cmd ::= DROP TRIGGER ifexists fullname",
+ /* 258 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
+ /* 259 */ "cmd ::= DETACH database_kw_opt expr",
+ /* 260 */ "key_opt ::=",
+ /* 261 */ "key_opt ::= KEY expr",
+ /* 262 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
+ /* 263 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist",
+ /* 264 */ "add_column_fullname ::= fullname",
+ /* 265 */ "cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm",
+ /* 266 */ "cmd ::= create_vtab",
+ /* 267 */ "cmd ::= create_vtab LP vtabarglist RP",
+ /* 268 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
+ /* 269 */ "vtabarg ::=",
+ /* 270 */ "vtabargtoken ::= ANY",
+ /* 271 */ "vtabargtoken ::= lp anylist RP",
+ /* 272 */ "lp ::= LP",
+ /* 273 */ "with ::= WITH wqlist",
+ /* 274 */ "with ::= WITH RECURSIVE wqlist",
+ /* 275 */ "wqlist ::= nm eidlist_opt AS LP select RP",
+ /* 276 */ "wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP",
+ /* 277 */ "input ::= cmdlist",
+ /* 278 */ "cmdlist ::= cmdlist ecmd",
+ /* 279 */ "cmdlist ::= ecmd",
+ /* 280 */ "ecmd ::= SEMI",
+ /* 281 */ "ecmd ::= cmdx SEMI",
+ /* 282 */ "trans_opt ::=",
+ /* 283 */ "trans_opt ::= TRANSACTION",
+ /* 284 */ "trans_opt ::= TRANSACTION nm",
+ /* 285 */ "savepoint_opt ::= SAVEPOINT",
+ /* 286 */ "savepoint_opt ::=",
+ /* 287 */ "cmd ::= create_table create_table_args",
+ /* 288 */ "columnlist ::= columnlist COMMA columnname carglist",
+ /* 289 */ "columnlist ::= columnname carglist",
+ /* 290 */ "nm ::= ID|INDEXED",
+ /* 291 */ "nm ::= STRING",
+ /* 292 */ "nm ::= JOIN_KW",
+ /* 293 */ "typetoken ::= typename",
+ /* 294 */ "typename ::= ID|STRING",
+ /* 295 */ "signed ::= plus_num",
+ /* 296 */ "signed ::= minus_num",
+ /* 297 */ "carglist ::= carglist ccons",
+ /* 298 */ "carglist ::=",
+ /* 299 */ "ccons ::= NULL onconf",
+ /* 300 */ "conslist_opt ::= COMMA conslist",
+ /* 301 */ "conslist ::= conslist tconscomma tcons",
+ /* 302 */ "conslist ::= tcons",
+ /* 303 */ "tconscomma ::=",
+ /* 304 */ "defer_subclause_opt ::= defer_subclause",
+ /* 305 */ "resolvetype ::= raisetype",
+ /* 306 */ "selectnowith ::= oneselect",
+ /* 307 */ "oneselect ::= values",
+ /* 308 */ "sclp ::= selcollist COMMA",
+ /* 309 */ "as ::= ID|STRING",
+ /* 310 */ "expr ::= term",
+ /* 311 */ "likeop ::= LIKE_KW|MATCH",
+ /* 312 */ "exprlist ::= nexprlist",
+ /* 313 */ "nmnum ::= plus_num",
+ /* 314 */ "nmnum ::= nm",
+ /* 315 */ "nmnum ::= ON",
+ /* 316 */ "nmnum ::= DELETE",
+ /* 317 */ "nmnum ::= DEFAULT",
+ /* 318 */ "plus_num ::= INTEGER|FLOAT",
+ /* 319 */ "foreach_clause ::=",
+ /* 320 */ "foreach_clause ::= FOR EACH ROW",
+ /* 321 */ "trnm ::= nm",
+ /* 322 */ "tridxby ::=",
+ /* 323 */ "database_kw_opt ::= DATABASE",
+ /* 324 */ "database_kw_opt ::=",
+ /* 325 */ "kwcolumn_opt ::=",
+ /* 326 */ "kwcolumn_opt ::= COLUMNKW",
+ /* 327 */ "vtabarglist ::= vtabarg",
+ /* 328 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
+ /* 329 */ "vtabarg ::= vtabarg vtabargtoken",
+ /* 330 */ "anylist ::=",
+ /* 331 */ "anylist ::= anylist LP anylist RP",
+ /* 332 */ "anylist ::= anylist ANY",
+ /* 333 */ "with ::=",
};
#endif /* NDEBUG */
@@ -148762,73 +148698,73 @@ static void yy_destructor(
** inside the C code.
*/
/********* Begin destructor definitions ***************************************/
- case 165: /* select */
- case 197: /* selectnowith */
- case 198: /* oneselect */
- case 209: /* values */
+ case 164: /* select */
+ case 196: /* selectnowith */
+ case 197: /* oneselect */
+ case 208: /* values */
{
-sqlite3SelectDelete(pParse->db, (yypminor->yy43));
+sqlite3SelectDelete(pParse->db, (yypminor->yy399));
}
break;
- case 175: /* term */
- case 176: /* expr */
- case 204: /* where_opt */
- case 206: /* having_opt */
- case 217: /* on_opt */
- case 231: /* case_operand */
- case 233: /* case_else */
- case 242: /* when_clause */
- case 247: /* key_opt */
+ case 174: /* term */
+ case 175: /* expr */
+ case 203: /* where_opt */
+ case 205: /* having_opt */
+ case 216: /* on_opt */
+ case 230: /* case_operand */
+ case 232: /* case_else */
+ case 241: /* when_clause */
+ case 246: /* key_opt */
{
-sqlite3ExprDelete(pParse->db, (yypminor->yy2));
+sqlite3ExprDelete(pParse->db, (yypminor->yy182));
}
break;
- case 180: /* eidlist_opt */
- case 189: /* sortlist */
- case 190: /* eidlist */
- case 202: /* selcollist */
- case 205: /* groupby_opt */
- case 207: /* orderby_opt */
- case 210: /* nexprlist */
- case 211: /* sclp */
- case 219: /* exprlist */
- case 223: /* setlist */
- case 230: /* paren_exprlist */
- case 232: /* case_exprlist */
+ case 179: /* eidlist_opt */
+ case 188: /* sortlist */
+ case 189: /* eidlist */
+ case 201: /* selcollist */
+ case 204: /* groupby_opt */
+ case 206: /* orderby_opt */
+ case 209: /* nexprlist */
+ case 210: /* sclp */
+ case 218: /* exprlist */
+ case 222: /* setlist */
+ case 229: /* paren_exprlist */
+ case 231: /* case_exprlist */
{
-sqlite3ExprListDelete(pParse->db, (yypminor->yy402));
+sqlite3ExprListDelete(pParse->db, (yypminor->yy232));
}
break;
- case 196: /* fullname */
- case 203: /* from */
- case 213: /* seltablist */
- case 214: /* stl_prefix */
- case 220: /* xfullname */
+ case 195: /* fullname */
+ case 202: /* from */
+ case 212: /* seltablist */
+ case 213: /* stl_prefix */
+ case 219: /* xfullname */
{
-sqlite3SrcListDelete(pParse->db, (yypminor->yy3));
+sqlite3SrcListDelete(pParse->db, (yypminor->yy427));
}
break;
- case 199: /* wqlist */
+ case 198: /* wqlist */
{
-sqlite3WithDelete(pParse->db, (yypminor->yy4));
+sqlite3WithDelete(pParse->db, (yypminor->yy91));
}
break;
- case 218: /* using_opt */
- case 221: /* idlist */
- case 225: /* idlist_opt */
+ case 217: /* using_opt */
+ case 220: /* idlist */
+ case 224: /* idlist_opt */
{
-sqlite3IdListDelete(pParse->db, (yypminor->yy272));
+sqlite3IdListDelete(pParse->db, (yypminor->yy510));
}
break;
- case 238: /* trigger_cmd_list */
- case 243: /* trigger_cmd */
+ case 237: /* trigger_cmd_list */
+ case 242: /* trigger_cmd */
{
-sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy347));
+sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy47));
}
break;
- case 240: /* trigger_event */
+ case 239: /* trigger_event */
{
-sqlite3IdListDelete(pParse->db, (yypminor->yy338).b);
+sqlite3IdListDelete(pParse->db, (yypminor->yy300).b);
}
break;
/********* End destructor definitions *****************************************/
@@ -149127,347 +149063,340 @@ static const struct {
YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */
signed char nrhs; /* Negative of the number of RHS symbols in the rule */
} yyRuleInfo[] = {
- { 150, -1 }, /* (0) explain ::= EXPLAIN */
- { 150, -3 }, /* (1) explain ::= EXPLAIN QUERY PLAN */
- { 149, -1 }, /* (2) cmdx ::= cmd */
- { 151, -3 }, /* (3) cmd ::= BEGIN transtype trans_opt */
- { 152, 0 }, /* (4) transtype ::= */
- { 152, -1 }, /* (5) transtype ::= DEFERRED */
- { 152, -1 }, /* (6) transtype ::= IMMEDIATE */
- { 152, -1 }, /* (7) transtype ::= EXCLUSIVE */
- { 151, -2 }, /* (8) cmd ::= COMMIT|END trans_opt */
- { 151, -2 }, /* (9) cmd ::= ROLLBACK trans_opt */
- { 151, -2 }, /* (10) cmd ::= SAVEPOINT nm */
- { 151, -3 }, /* (11) cmd ::= RELEASE savepoint_opt nm */
- { 151, -5 }, /* (12) cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */
- { 156, -6 }, /* (13) create_table ::= createkw temp TABLE ifnotexists nm dbnm */
- { 158, -1 }, /* (14) createkw ::= CREATE */
- { 160, 0 }, /* (15) ifnotexists ::= */
- { 160, -3 }, /* (16) ifnotexists ::= IF NOT EXISTS */
- { 159, -1 }, /* (17) temp ::= TEMP */
- { 159, 0 }, /* (18) temp ::= */
- { 157, -5 }, /* (19) create_table_args ::= LP columnlist conslist_opt RP table_options */
- { 157, -2 }, /* (20) create_table_args ::= AS select */
- { 164, 0 }, /* (21) table_options ::= */
- { 164, -2 }, /* (22) table_options ::= WITHOUT nm */
- { 166, -2 }, /* (23) columnname ::= nm typetoken */
- { 168, 0 }, /* (24) typetoken ::= */
- { 168, -4 }, /* (25) typetoken ::= typename LP signed RP */
- { 168, -6 }, /* (26) typetoken ::= typename LP signed COMMA signed RP */
- { 169, -2 }, /* (27) typename ::= typename ID|STRING */
- { 173, 0 }, /* (28) scanpt ::= */
- { 174, -2 }, /* (29) ccons ::= CONSTRAINT nm */
- { 174, -4 }, /* (30) ccons ::= DEFAULT scanpt term scanpt */
- { 174, -4 }, /* (31) ccons ::= DEFAULT LP expr RP */
- { 174, -4 }, /* (32) ccons ::= DEFAULT PLUS term scanpt */
- { 174, -4 }, /* (33) ccons ::= DEFAULT MINUS term scanpt */
- { 174, -3 }, /* (34) ccons ::= DEFAULT scanpt ID|INDEXED */
- { 174, -3 }, /* (35) ccons ::= NOT NULL onconf */
- { 174, -5 }, /* (36) ccons ::= PRIMARY KEY sortorder onconf autoinc */
- { 174, -2 }, /* (37) ccons ::= UNIQUE onconf */
- { 174, -4 }, /* (38) ccons ::= CHECK LP expr RP */
- { 174, -4 }, /* (39) ccons ::= REFERENCES nm eidlist_opt refargs */
- { 174, -1 }, /* (40) ccons ::= defer_subclause */
- { 174, -2 }, /* (41) ccons ::= COLLATE ID|STRING */
- { 179, 0 }, /* (42) autoinc ::= */
- { 179, -1 }, /* (43) autoinc ::= AUTOINCR */
- { 181, 0 }, /* (44) refargs ::= */
- { 181, -2 }, /* (45) refargs ::= refargs refarg */
- { 183, -2 }, /* (46) refarg ::= MATCH nm */
- { 183, -3 }, /* (47) refarg ::= ON INSERT refact */
- { 183, -3 }, /* (48) refarg ::= ON DELETE refact */
- { 183, -3 }, /* (49) refarg ::= ON UPDATE refact */
- { 184, -2 }, /* (50) refact ::= SET NULL */
- { 184, -2 }, /* (51) refact ::= SET DEFAULT */
- { 184, -1 }, /* (52) refact ::= CASCADE */
- { 184, -1 }, /* (53) refact ::= RESTRICT */
- { 184, -2 }, /* (54) refact ::= NO ACTION */
- { 182, -3 }, /* (55) defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
- { 182, -2 }, /* (56) defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
- { 185, 0 }, /* (57) init_deferred_pred_opt ::= */
- { 185, -2 }, /* (58) init_deferred_pred_opt ::= INITIALLY DEFERRED */
- { 185, -2 }, /* (59) init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
- { 163, 0 }, /* (60) conslist_opt ::= */
- { 187, -1 }, /* (61) tconscomma ::= COMMA */
- { 188, -2 }, /* (62) tcons ::= CONSTRAINT nm */
- { 188, -7 }, /* (63) tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
- { 188, -5 }, /* (64) tcons ::= UNIQUE LP sortlist RP onconf */
- { 188, -5 }, /* (65) tcons ::= CHECK LP expr RP onconf */
- { 188, -10 }, /* (66) tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
- { 191, 0 }, /* (67) defer_subclause_opt ::= */
- { 177, 0 }, /* (68) onconf ::= */
- { 177, -3 }, /* (69) onconf ::= ON CONFLICT resolvetype */
- { 192, 0 }, /* (70) orconf ::= */
- { 192, -2 }, /* (71) orconf ::= OR resolvetype */
- { 193, -1 }, /* (72) resolvetype ::= IGNORE */
- { 193, -1 }, /* (73) resolvetype ::= REPLACE */
- { 151, -4 }, /* (74) cmd ::= DROP TABLE ifexists fullname */
- { 195, -2 }, /* (75) ifexists ::= IF EXISTS */
- { 195, 0 }, /* (76) ifexists ::= */
- { 151, -9 }, /* (77) cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
- { 151, -4 }, /* (78) cmd ::= DROP VIEW ifexists fullname */
- { 151, -1 }, /* (79) cmd ::= select */
- { 165, -3 }, /* (80) select ::= WITH wqlist selectnowith */
- { 165, -4 }, /* (81) select ::= WITH RECURSIVE wqlist selectnowith */
- { 165, -1 }, /* (82) select ::= selectnowith */
- { 197, -3 }, /* (83) selectnowith ::= selectnowith multiselect_op oneselect */
- { 200, -1 }, /* (84) multiselect_op ::= UNION */
- { 200, -2 }, /* (85) multiselect_op ::= UNION ALL */
- { 200, -1 }, /* (86) multiselect_op ::= EXCEPT|INTERSECT */
- { 198, -9 }, /* (87) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
- { 209, -4 }, /* (88) values ::= VALUES LP nexprlist RP */
- { 209, -5 }, /* (89) values ::= values COMMA LP nexprlist RP */
- { 201, -1 }, /* (90) distinct ::= DISTINCT */
- { 201, -1 }, /* (91) distinct ::= ALL */
- { 201, 0 }, /* (92) distinct ::= */
- { 211, 0 }, /* (93) sclp ::= */
- { 202, -5 }, /* (94) selcollist ::= sclp scanpt expr scanpt as */
- { 202, -3 }, /* (95) selcollist ::= sclp scanpt STAR */
- { 202, -5 }, /* (96) selcollist ::= sclp scanpt nm DOT STAR */
- { 212, -2 }, /* (97) as ::= AS nm */
- { 212, 0 }, /* (98) as ::= */
- { 203, 0 }, /* (99) from ::= */
- { 203, -2 }, /* (100) from ::= FROM seltablist */
- { 214, -2 }, /* (101) stl_prefix ::= seltablist joinop */
- { 214, 0 }, /* (102) stl_prefix ::= */
- { 213, -7 }, /* (103) seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
- { 213, -9 }, /* (104) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
- { 213, -7 }, /* (105) seltablist ::= stl_prefix LP select RP as on_opt using_opt */
- { 213, -7 }, /* (106) seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
- { 161, 0 }, /* (107) dbnm ::= */
- { 161, -2 }, /* (108) dbnm ::= DOT nm */
- { 196, -1 }, /* (109) fullname ::= nm */
- { 196, -3 }, /* (110) fullname ::= nm DOT nm */
- { 220, -1 }, /* (111) xfullname ::= nm */
- { 220, -3 }, /* (112) xfullname ::= nm DOT nm */
- { 220, -5 }, /* (113) xfullname ::= nm DOT nm AS nm */
- { 220, -3 }, /* (114) xfullname ::= nm AS nm */
- { 215, -1 }, /* (115) joinop ::= COMMA|JOIN */
- { 215, -2 }, /* (116) joinop ::= JOIN_KW JOIN */
- { 215, -3 }, /* (117) joinop ::= JOIN_KW nm JOIN */
- { 215, -4 }, /* (118) joinop ::= JOIN_KW nm nm JOIN */
- { 217, -2 }, /* (119) on_opt ::= ON expr */
- { 217, 0 }, /* (120) on_opt ::= */
- { 216, 0 }, /* (121) indexed_opt ::= */
- { 216, -3 }, /* (122) indexed_opt ::= INDEXED BY nm */
- { 216, -2 }, /* (123) indexed_opt ::= NOT INDEXED */
- { 218, -4 }, /* (124) using_opt ::= USING LP idlist RP */
- { 218, 0 }, /* (125) using_opt ::= */
- { 207, 0 }, /* (126) orderby_opt ::= */
- { 207, -3 }, /* (127) orderby_opt ::= ORDER BY sortlist */
- { 189, -4 }, /* (128) sortlist ::= sortlist COMMA expr sortorder */
- { 189, -2 }, /* (129) sortlist ::= expr sortorder */
- { 178, -1 }, /* (130) sortorder ::= ASC */
- { 178, -1 }, /* (131) sortorder ::= DESC */
- { 178, 0 }, /* (132) sortorder ::= */
- { 205, 0 }, /* (133) groupby_opt ::= */
- { 205, -3 }, /* (134) groupby_opt ::= GROUP BY nexprlist */
- { 206, 0 }, /* (135) having_opt ::= */
- { 206, -2 }, /* (136) having_opt ::= HAVING expr */
- { 208, 0 }, /* (137) limit_opt ::= */
- { 208, -2 }, /* (138) limit_opt ::= LIMIT expr */
- { 208, -4 }, /* (139) limit_opt ::= LIMIT expr OFFSET expr */
- { 208, -4 }, /* (140) limit_opt ::= LIMIT expr COMMA expr */
- { 151, -6 }, /* (141) cmd ::= with DELETE FROM xfullname indexed_opt where_opt */
- { 204, 0 }, /* (142) where_opt ::= */
- { 204, -2 }, /* (143) where_opt ::= WHERE expr */
- { 151, -8 }, /* (144) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt */
- { 223, -5 }, /* (145) setlist ::= setlist COMMA nm EQ expr */
- { 223, -7 }, /* (146) setlist ::= setlist COMMA LP idlist RP EQ expr */
- { 223, -3 }, /* (147) setlist ::= nm EQ expr */
- { 223, -5 }, /* (148) setlist ::= LP idlist RP EQ expr */
- { 151, -7 }, /* (149) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
- { 151, -7 }, /* (150) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */
- { 226, 0 }, /* (151) upsert ::= */
- { 226, -11 }, /* (152) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */
- { 226, -8 }, /* (153) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */
- { 226, -4 }, /* (154) upsert ::= ON CONFLICT DO NOTHING */
- { 224, -2 }, /* (155) insert_cmd ::= INSERT orconf */
- { 224, -1 }, /* (156) insert_cmd ::= REPLACE */
- { 225, 0 }, /* (157) idlist_opt ::= */
- { 225, -3 }, /* (158) idlist_opt ::= LP idlist RP */
- { 221, -3 }, /* (159) idlist ::= idlist COMMA nm */
- { 221, -1 }, /* (160) idlist ::= nm */
- { 176, -3 }, /* (161) expr ::= LP expr RP */
- { 176, -1 }, /* (162) expr ::= ID|INDEXED */
- { 176, -1 }, /* (163) expr ::= JOIN_KW */
- { 176, -3 }, /* (164) expr ::= nm DOT nm */
- { 176, -5 }, /* (165) expr ::= nm DOT nm DOT nm */
- { 175, -1 }, /* (166) term ::= NULL|FLOAT|BLOB */
- { 175, -1 }, /* (167) term ::= STRING */
- { 175, -1 }, /* (168) term ::= INTEGER */
- { 176, -1 }, /* (169) expr ::= VARIABLE */
- { 176, -3 }, /* (170) expr ::= expr COLLATE ID|STRING */
- { 176, -6 }, /* (171) expr ::= CAST LP expr AS typetoken RP */
- { 176, -5 }, /* (172) expr ::= ID|INDEXED LP distinct exprlist RP */
- { 176, -4 }, /* (173) expr ::= ID|INDEXED LP STAR RP */
- { 175, -1 }, /* (174) term ::= CTIME_KW */
- { 176, -5 }, /* (175) expr ::= LP nexprlist COMMA expr RP */
- { 176, -3 }, /* (176) expr ::= expr AND expr */
- { 176, -3 }, /* (177) expr ::= expr OR expr */
- { 176, -3 }, /* (178) expr ::= expr LT|GT|GE|LE expr */
- { 176, -3 }, /* (179) expr ::= expr EQ|NE expr */
- { 176, -3 }, /* (180) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */
- { 176, -3 }, /* (181) expr ::= expr PLUS|MINUS expr */
- { 176, -3 }, /* (182) expr ::= expr STAR|SLASH|REM expr */
- { 176, -3 }, /* (183) expr ::= expr CONCAT expr */
- { 227, -2 }, /* (184) likeop ::= NOT LIKE_KW|MATCH */
- { 176, -3 }, /* (185) expr ::= expr likeop expr */
- { 176, -5 }, /* (186) expr ::= expr likeop expr ESCAPE expr */
- { 176, -2 }, /* (187) expr ::= expr ISNULL|NOTNULL */
- { 176, -3 }, /* (188) expr ::= expr NOT NULL */
- { 176, -3 }, /* (189) expr ::= expr IS expr */
- { 176, -4 }, /* (190) expr ::= expr IS NOT expr */
- { 176, -2 }, /* (191) expr ::= NOT expr */
- { 176, -2 }, /* (192) expr ::= BITNOT expr */
- { 176, -2 }, /* (193) expr ::= PLUS|MINUS expr */
- { 228, -1 }, /* (194) between_op ::= BETWEEN */
- { 228, -2 }, /* (195) between_op ::= NOT BETWEEN */
- { 176, -5 }, /* (196) expr ::= expr between_op expr AND expr */
- { 229, -1 }, /* (197) in_op ::= IN */
- { 229, -2 }, /* (198) in_op ::= NOT IN */
- { 176, -5 }, /* (199) expr ::= expr in_op LP exprlist RP */
- { 176, -3 }, /* (200) expr ::= LP select RP */
- { 176, -5 }, /* (201) expr ::= expr in_op LP select RP */
- { 176, -5 }, /* (202) expr ::= expr in_op nm dbnm paren_exprlist */
- { 176, -4 }, /* (203) expr ::= EXISTS LP select RP */
- { 176, -5 }, /* (204) expr ::= CASE case_operand case_exprlist case_else END */
- { 232, -5 }, /* (205) case_exprlist ::= case_exprlist WHEN expr THEN expr */
- { 232, -4 }, /* (206) case_exprlist ::= WHEN expr THEN expr */
- { 233, -2 }, /* (207) case_else ::= ELSE expr */
- { 233, 0 }, /* (208) case_else ::= */
- { 231, -1 }, /* (209) case_operand ::= expr */
- { 231, 0 }, /* (210) case_operand ::= */
- { 219, 0 }, /* (211) exprlist ::= */
- { 210, -3 }, /* (212) nexprlist ::= nexprlist COMMA expr */
- { 210, -1 }, /* (213) nexprlist ::= expr */
- { 230, 0 }, /* (214) paren_exprlist ::= */
- { 230, -3 }, /* (215) paren_exprlist ::= LP exprlist RP */
- { 151, -12 }, /* (216) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
- { 234, -1 }, /* (217) uniqueflag ::= UNIQUE */
- { 234, 0 }, /* (218) uniqueflag ::= */
- { 180, 0 }, /* (219) eidlist_opt ::= */
- { 180, -3 }, /* (220) eidlist_opt ::= LP eidlist RP */
- { 190, -5 }, /* (221) eidlist ::= eidlist COMMA nm collate sortorder */
- { 190, -3 }, /* (222) eidlist ::= nm collate sortorder */
- { 235, 0 }, /* (223) collate ::= */
- { 235, -2 }, /* (224) collate ::= COLLATE ID|STRING */
- { 151, -4 }, /* (225) cmd ::= DROP INDEX ifexists fullname */
- { 151, -1 }, /* (226) cmd ::= VACUUM */
- { 151, -2 }, /* (227) cmd ::= VACUUM nm */
- { 151, -3 }, /* (228) cmd ::= PRAGMA nm dbnm */
- { 151, -5 }, /* (229) cmd ::= PRAGMA nm dbnm EQ nmnum */
- { 151, -6 }, /* (230) cmd ::= PRAGMA nm dbnm LP nmnum RP */
- { 151, -5 }, /* (231) cmd ::= PRAGMA nm dbnm EQ minus_num */
- { 151, -6 }, /* (232) cmd ::= PRAGMA nm dbnm LP minus_num RP */
- { 171, -2 }, /* (233) plus_num ::= PLUS INTEGER|FLOAT */
- { 172, -2 }, /* (234) minus_num ::= MINUS INTEGER|FLOAT */
- { 151, -5 }, /* (235) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
- { 237, -11 }, /* (236) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
- { 239, -1 }, /* (237) trigger_time ::= BEFORE|AFTER */
- { 239, -2 }, /* (238) trigger_time ::= INSTEAD OF */
- { 239, 0 }, /* (239) trigger_time ::= */
- { 240, -1 }, /* (240) trigger_event ::= DELETE|INSERT */
- { 240, -1 }, /* (241) trigger_event ::= UPDATE */
- { 240, -3 }, /* (242) trigger_event ::= UPDATE OF idlist */
- { 242, 0 }, /* (243) when_clause ::= */
- { 242, -2 }, /* (244) when_clause ::= WHEN expr */
- { 238, -3 }, /* (245) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
- { 238, -2 }, /* (246) trigger_cmd_list ::= trigger_cmd SEMI */
- { 244, -3 }, /* (247) trnm ::= nm DOT nm */
- { 245, -3 }, /* (248) tridxby ::= INDEXED BY nm */
- { 245, -2 }, /* (249) tridxby ::= NOT INDEXED */
- { 243, -8 }, /* (250) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */
- { 243, -8 }, /* (251) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
- { 243, -6 }, /* (252) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
- { 243, -3 }, /* (253) trigger_cmd ::= scanpt select scanpt */
- { 176, -4 }, /* (254) expr ::= RAISE LP IGNORE RP */
- { 176, -6 }, /* (255) expr ::= RAISE LP raisetype COMMA nm RP */
- { 194, -1 }, /* (256) raisetype ::= ROLLBACK */
- { 194, -1 }, /* (257) raisetype ::= ABORT */
- { 194, -1 }, /* (258) raisetype ::= FAIL */
- { 151, -4 }, /* (259) cmd ::= DROP TRIGGER ifexists fullname */
- { 151, -6 }, /* (260) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
- { 151, -3 }, /* (261) cmd ::= DETACH database_kw_opt expr */
- { 247, 0 }, /* (262) key_opt ::= */
- { 247, -2 }, /* (263) key_opt ::= KEY expr */
- { 151, -1 }, /* (264) cmd ::= REINDEX */
- { 151, -3 }, /* (265) cmd ::= REINDEX nm dbnm */
- { 151, -1 }, /* (266) cmd ::= ANALYZE */
- { 151, -3 }, /* (267) cmd ::= ANALYZE nm dbnm */
- { 151, -6 }, /* (268) cmd ::= ALTER TABLE fullname RENAME TO nm */
- { 151, -7 }, /* (269) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
- { 248, -1 }, /* (270) add_column_fullname ::= fullname */
- { 151, -8 }, /* (271) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
- { 151, -1 }, /* (272) cmd ::= create_vtab */
- { 151, -4 }, /* (273) cmd ::= create_vtab LP vtabarglist RP */
- { 250, -8 }, /* (274) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
- { 252, 0 }, /* (275) vtabarg ::= */
- { 253, -1 }, /* (276) vtabargtoken ::= ANY */
- { 253, -3 }, /* (277) vtabargtoken ::= lp anylist RP */
- { 254, -1 }, /* (278) lp ::= LP */
- { 222, -2 }, /* (279) with ::= WITH wqlist */
- { 222, -3 }, /* (280) with ::= WITH RECURSIVE wqlist */
- { 199, -6 }, /* (281) wqlist ::= nm eidlist_opt AS LP select RP */
- { 199, -8 }, /* (282) wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
- { 146, -1 }, /* (283) input ::= cmdlist */
- { 147, -2 }, /* (284) cmdlist ::= cmdlist ecmd */
- { 147, -1 }, /* (285) cmdlist ::= ecmd */
- { 148, -1 }, /* (286) ecmd ::= SEMI */
- { 148, -2 }, /* (287) ecmd ::= cmdx SEMI */
- { 148, -2 }, /* (288) ecmd ::= explain cmdx */
- { 153, 0 }, /* (289) trans_opt ::= */
- { 153, -1 }, /* (290) trans_opt ::= TRANSACTION */
- { 153, -2 }, /* (291) trans_opt ::= TRANSACTION nm */
- { 155, -1 }, /* (292) savepoint_opt ::= SAVEPOINT */
- { 155, 0 }, /* (293) savepoint_opt ::= */
- { 151, -2 }, /* (294) cmd ::= create_table create_table_args */
- { 162, -4 }, /* (295) columnlist ::= columnlist COMMA columnname carglist */
- { 162, -2 }, /* (296) columnlist ::= columnname carglist */
- { 154, -1 }, /* (297) nm ::= ID|INDEXED */
- { 154, -1 }, /* (298) nm ::= STRING */
- { 154, -1 }, /* (299) nm ::= JOIN_KW */
- { 168, -1 }, /* (300) typetoken ::= typename */
- { 169, -1 }, /* (301) typename ::= ID|STRING */
- { 170, -1 }, /* (302) signed ::= plus_num */
- { 170, -1 }, /* (303) signed ::= minus_num */
- { 167, -2 }, /* (304) carglist ::= carglist ccons */
- { 167, 0 }, /* (305) carglist ::= */
- { 174, -2 }, /* (306) ccons ::= NULL onconf */
- { 163, -2 }, /* (307) conslist_opt ::= COMMA conslist */
- { 186, -3 }, /* (308) conslist ::= conslist tconscomma tcons */
- { 186, -1 }, /* (309) conslist ::= tcons */
- { 187, 0 }, /* (310) tconscomma ::= */
- { 191, -1 }, /* (311) defer_subclause_opt ::= defer_subclause */
- { 193, -1 }, /* (312) resolvetype ::= raisetype */
- { 197, -1 }, /* (313) selectnowith ::= oneselect */
- { 198, -1 }, /* (314) oneselect ::= values */
- { 211, -2 }, /* (315) sclp ::= selcollist COMMA */
- { 212, -1 }, /* (316) as ::= ID|STRING */
- { 176, -1 }, /* (317) expr ::= term */
- { 227, -1 }, /* (318) likeop ::= LIKE_KW|MATCH */
- { 219, -1 }, /* (319) exprlist ::= nexprlist */
- { 236, -1 }, /* (320) nmnum ::= plus_num */
- { 236, -1 }, /* (321) nmnum ::= nm */
- { 236, -1 }, /* (322) nmnum ::= ON */
- { 236, -1 }, /* (323) nmnum ::= DELETE */
- { 236, -1 }, /* (324) nmnum ::= DEFAULT */
- { 171, -1 }, /* (325) plus_num ::= INTEGER|FLOAT */
- { 241, 0 }, /* (326) foreach_clause ::= */
- { 241, -3 }, /* (327) foreach_clause ::= FOR EACH ROW */
- { 244, -1 }, /* (328) trnm ::= nm */
- { 245, 0 }, /* (329) tridxby ::= */
- { 246, -1 }, /* (330) database_kw_opt ::= DATABASE */
- { 246, 0 }, /* (331) database_kw_opt ::= */
- { 249, 0 }, /* (332) kwcolumn_opt ::= */
- { 249, -1 }, /* (333) kwcolumn_opt ::= COLUMNKW */
- { 251, -1 }, /* (334) vtabarglist ::= vtabarg */
- { 251, -3 }, /* (335) vtabarglist ::= vtabarglist COMMA vtabarg */
- { 252, -2 }, /* (336) vtabarg ::= vtabarg vtabargtoken */
- { 255, 0 }, /* (337) anylist ::= */
- { 255, -4 }, /* (338) anylist ::= anylist LP anylist RP */
- { 255, -2 }, /* (339) anylist ::= anylist ANY */
- { 222, 0 }, /* (340) with ::= */
+ { 149, -1 }, /* (0) cmdx ::= cmd */
+ { 150, -3 }, /* (1) cmd ::= BEGIN transtype trans_opt */
+ { 151, 0 }, /* (2) transtype ::= */
+ { 151, -1 }, /* (3) transtype ::= DEFERRED */
+ { 151, -1 }, /* (4) transtype ::= IMMEDIATE */
+ { 151, -1 }, /* (5) transtype ::= EXCLUSIVE */
+ { 150, -2 }, /* (6) cmd ::= COMMIT|END trans_opt */
+ { 150, -2 }, /* (7) cmd ::= ROLLBACK trans_opt */
+ { 150, -2 }, /* (8) cmd ::= SAVEPOINT nm */
+ { 150, -3 }, /* (9) cmd ::= RELEASE savepoint_opt nm */
+ { 150, -5 }, /* (10) cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */
+ { 155, -6 }, /* (11) create_table ::= createkw temp TABLE ifnotexists nm dbnm */
+ { 157, -1 }, /* (12) createkw ::= CREATE */
+ { 159, 0 }, /* (13) ifnotexists ::= */
+ { 159, -3 }, /* (14) ifnotexists ::= IF NOT EXISTS */
+ { 158, -1 }, /* (15) temp ::= TEMP */
+ { 158, 0 }, /* (16) temp ::= */
+ { 156, -5 }, /* (17) create_table_args ::= LP columnlist conslist_opt RP table_options */
+ { 156, -2 }, /* (18) create_table_args ::= AS select */
+ { 163, 0 }, /* (19) table_options ::= */
+ { 163, -2 }, /* (20) table_options ::= WITHOUT nm */
+ { 165, -2 }, /* (21) columnname ::= nm typetoken */
+ { 167, 0 }, /* (22) typetoken ::= */
+ { 167, -4 }, /* (23) typetoken ::= typename LP signed RP */
+ { 167, -6 }, /* (24) typetoken ::= typename LP signed COMMA signed RP */
+ { 168, -2 }, /* (25) typename ::= typename ID|STRING */
+ { 172, 0 }, /* (26) scanpt ::= */
+ { 173, -2 }, /* (27) ccons ::= CONSTRAINT nm */
+ { 173, -4 }, /* (28) ccons ::= DEFAULT scanpt term scanpt */
+ { 173, -4 }, /* (29) ccons ::= DEFAULT LP expr RP */
+ { 173, -4 }, /* (30) ccons ::= DEFAULT PLUS term scanpt */
+ { 173, -4 }, /* (31) ccons ::= DEFAULT MINUS term scanpt */
+ { 173, -3 }, /* (32) ccons ::= DEFAULT scanpt ID|INDEXED */
+ { 173, -3 }, /* (33) ccons ::= NOT NULL onconf */
+ { 173, -5 }, /* (34) ccons ::= PRIMARY KEY sortorder onconf autoinc */
+ { 173, -2 }, /* (35) ccons ::= UNIQUE onconf */
+ { 173, -4 }, /* (36) ccons ::= CHECK LP expr RP */
+ { 173, -4 }, /* (37) ccons ::= REFERENCES nm eidlist_opt refargs */
+ { 173, -1 }, /* (38) ccons ::= defer_subclause */
+ { 173, -2 }, /* (39) ccons ::= COLLATE ID|STRING */
+ { 178, 0 }, /* (40) autoinc ::= */
+ { 178, -1 }, /* (41) autoinc ::= AUTOINCR */
+ { 180, 0 }, /* (42) refargs ::= */
+ { 180, -2 }, /* (43) refargs ::= refargs refarg */
+ { 182, -2 }, /* (44) refarg ::= MATCH nm */
+ { 182, -3 }, /* (45) refarg ::= ON INSERT refact */
+ { 182, -3 }, /* (46) refarg ::= ON DELETE refact */
+ { 182, -3 }, /* (47) refarg ::= ON UPDATE refact */
+ { 183, -2 }, /* (48) refact ::= SET NULL */
+ { 183, -2 }, /* (49) refact ::= SET DEFAULT */
+ { 183, -1 }, /* (50) refact ::= CASCADE */
+ { 183, -1 }, /* (51) refact ::= RESTRICT */
+ { 183, -2 }, /* (52) refact ::= NO ACTION */
+ { 181, -3 }, /* (53) defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
+ { 181, -2 }, /* (54) defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
+ { 184, 0 }, /* (55) init_deferred_pred_opt ::= */
+ { 184, -2 }, /* (56) init_deferred_pred_opt ::= INITIALLY DEFERRED */
+ { 184, -2 }, /* (57) init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
+ { 162, 0 }, /* (58) conslist_opt ::= */
+ { 186, -1 }, /* (59) tconscomma ::= COMMA */
+ { 187, -2 }, /* (60) tcons ::= CONSTRAINT nm */
+ { 187, -7 }, /* (61) tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
+ { 187, -5 }, /* (62) tcons ::= UNIQUE LP sortlist RP onconf */
+ { 187, -5 }, /* (63) tcons ::= CHECK LP expr RP onconf */
+ { 187, -10 }, /* (64) tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
+ { 190, 0 }, /* (65) defer_subclause_opt ::= */
+ { 176, 0 }, /* (66) onconf ::= */
+ { 176, -3 }, /* (67) onconf ::= ON CONFLICT resolvetype */
+ { 191, 0 }, /* (68) orconf ::= */
+ { 191, -2 }, /* (69) orconf ::= OR resolvetype */
+ { 192, -1 }, /* (70) resolvetype ::= IGNORE */
+ { 192, -1 }, /* (71) resolvetype ::= REPLACE */
+ { 150, -4 }, /* (72) cmd ::= DROP TABLE ifexists fullname */
+ { 194, -2 }, /* (73) ifexists ::= IF EXISTS */
+ { 194, 0 }, /* (74) ifexists ::= */
+ { 150, -9 }, /* (75) cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
+ { 150, -4 }, /* (76) cmd ::= DROP VIEW ifexists fullname */
+ { 150, -1 }, /* (77) cmd ::= select */
+ { 164, -3 }, /* (78) select ::= WITH wqlist selectnowith */
+ { 164, -4 }, /* (79) select ::= WITH RECURSIVE wqlist selectnowith */
+ { 164, -1 }, /* (80) select ::= selectnowith */
+ { 196, -3 }, /* (81) selectnowith ::= selectnowith multiselect_op oneselect */
+ { 199, -1 }, /* (82) multiselect_op ::= UNION */
+ { 199, -2 }, /* (83) multiselect_op ::= UNION ALL */
+ { 199, -1 }, /* (84) multiselect_op ::= EXCEPT|INTERSECT */
+ { 197, -9 }, /* (85) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
+ { 208, -4 }, /* (86) values ::= VALUES LP nexprlist RP */
+ { 208, -5 }, /* (87) values ::= values COMMA LP nexprlist RP */
+ { 200, -1 }, /* (88) distinct ::= DISTINCT */
+ { 200, -1 }, /* (89) distinct ::= ALL */
+ { 200, 0 }, /* (90) distinct ::= */
+ { 210, 0 }, /* (91) sclp ::= */
+ { 201, -5 }, /* (92) selcollist ::= sclp scanpt expr scanpt as */
+ { 201, -3 }, /* (93) selcollist ::= sclp scanpt STAR */
+ { 201, -5 }, /* (94) selcollist ::= sclp scanpt nm DOT STAR */
+ { 211, -2 }, /* (95) as ::= AS nm */
+ { 211, 0 }, /* (96) as ::= */
+ { 202, 0 }, /* (97) from ::= */
+ { 202, -2 }, /* (98) from ::= FROM seltablist */
+ { 213, -2 }, /* (99) stl_prefix ::= seltablist joinop */
+ { 213, 0 }, /* (100) stl_prefix ::= */
+ { 212, -7 }, /* (101) seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
+ { 212, -9 }, /* (102) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
+ { 212, -7 }, /* (103) seltablist ::= stl_prefix LP select RP as on_opt using_opt */
+ { 212, -7 }, /* (104) seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
+ { 160, 0 }, /* (105) dbnm ::= */
+ { 160, -2 }, /* (106) dbnm ::= DOT nm */
+ { 195, -1 }, /* (107) fullname ::= nm */
+ { 195, -3 }, /* (108) fullname ::= nm DOT nm */
+ { 219, -1 }, /* (109) xfullname ::= nm */
+ { 219, -3 }, /* (110) xfullname ::= nm DOT nm */
+ { 219, -5 }, /* (111) xfullname ::= nm DOT nm AS nm */
+ { 219, -3 }, /* (112) xfullname ::= nm AS nm */
+ { 214, -1 }, /* (113) joinop ::= COMMA|JOIN */
+ { 214, -2 }, /* (114) joinop ::= JOIN_KW JOIN */
+ { 214, -3 }, /* (115) joinop ::= JOIN_KW nm JOIN */
+ { 214, -4 }, /* (116) joinop ::= JOIN_KW nm nm JOIN */
+ { 216, -2 }, /* (117) on_opt ::= ON expr */
+ { 216, 0 }, /* (118) on_opt ::= */
+ { 215, 0 }, /* (119) indexed_opt ::= */
+ { 215, -3 }, /* (120) indexed_opt ::= INDEXED BY nm */
+ { 215, -2 }, /* (121) indexed_opt ::= NOT INDEXED */
+ { 217, -4 }, /* (122) using_opt ::= USING LP idlist RP */
+ { 217, 0 }, /* (123) using_opt ::= */
+ { 206, 0 }, /* (124) orderby_opt ::= */
+ { 206, -3 }, /* (125) orderby_opt ::= ORDER BY sortlist */
+ { 188, -4 }, /* (126) sortlist ::= sortlist COMMA expr sortorder */
+ { 188, -2 }, /* (127) sortlist ::= expr sortorder */
+ { 177, -1 }, /* (128) sortorder ::= ASC */
+ { 177, -1 }, /* (129) sortorder ::= DESC */
+ { 177, 0 }, /* (130) sortorder ::= */
+ { 204, 0 }, /* (131) groupby_opt ::= */
+ { 204, -3 }, /* (132) groupby_opt ::= GROUP BY nexprlist */
+ { 205, 0 }, /* (133) having_opt ::= */
+ { 205, -2 }, /* (134) having_opt ::= HAVING expr */
+ { 207, 0 }, /* (135) limit_opt ::= */
+ { 207, -2 }, /* (136) limit_opt ::= LIMIT expr */
+ { 207, -4 }, /* (137) limit_opt ::= LIMIT expr OFFSET expr */
+ { 207, -4 }, /* (138) limit_opt ::= LIMIT expr COMMA expr */
+ { 150, -6 }, /* (139) cmd ::= with DELETE FROM xfullname indexed_opt where_opt */
+ { 203, 0 }, /* (140) where_opt ::= */
+ { 203, -2 }, /* (141) where_opt ::= WHERE expr */
+ { 150, -8 }, /* (142) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt */
+ { 222, -5 }, /* (143) setlist ::= setlist COMMA nm EQ expr */
+ { 222, -7 }, /* (144) setlist ::= setlist COMMA LP idlist RP EQ expr */
+ { 222, -3 }, /* (145) setlist ::= nm EQ expr */
+ { 222, -5 }, /* (146) setlist ::= LP idlist RP EQ expr */
+ { 150, -7 }, /* (147) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
+ { 150, -7 }, /* (148) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */
+ { 225, 0 }, /* (149) upsert ::= */
+ { 225, -11 }, /* (150) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */
+ { 225, -8 }, /* (151) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */
+ { 225, -4 }, /* (152) upsert ::= ON CONFLICT DO NOTHING */
+ { 223, -2 }, /* (153) insert_cmd ::= INSERT orconf */
+ { 223, -1 }, /* (154) insert_cmd ::= REPLACE */
+ { 224, 0 }, /* (155) idlist_opt ::= */
+ { 224, -3 }, /* (156) idlist_opt ::= LP idlist RP */
+ { 220, -3 }, /* (157) idlist ::= idlist COMMA nm */
+ { 220, -1 }, /* (158) idlist ::= nm */
+ { 175, -3 }, /* (159) expr ::= LP expr RP */
+ { 175, -1 }, /* (160) expr ::= ID|INDEXED */
+ { 175, -1 }, /* (161) expr ::= JOIN_KW */
+ { 175, -3 }, /* (162) expr ::= nm DOT nm */
+ { 175, -5 }, /* (163) expr ::= nm DOT nm DOT nm */
+ { 174, -1 }, /* (164) term ::= NULL|FLOAT|BLOB */
+ { 174, -1 }, /* (165) term ::= STRING */
+ { 174, -1 }, /* (166) term ::= INTEGER */
+ { 175, -1 }, /* (167) expr ::= VARIABLE */
+ { 175, -3 }, /* (168) expr ::= expr COLLATE ID|STRING */
+ { 175, -6 }, /* (169) expr ::= CAST LP expr AS typetoken RP */
+ { 175, -5 }, /* (170) expr ::= ID|INDEXED LP distinct exprlist RP */
+ { 175, -4 }, /* (171) expr ::= ID|INDEXED LP STAR RP */
+ { 174, -1 }, /* (172) term ::= CTIME_KW */
+ { 175, -5 }, /* (173) expr ::= LP nexprlist COMMA expr RP */
+ { 175, -3 }, /* (174) expr ::= expr AND expr */
+ { 175, -3 }, /* (175) expr ::= expr OR expr */
+ { 175, -3 }, /* (176) expr ::= expr LT|GT|GE|LE expr */
+ { 175, -3 }, /* (177) expr ::= expr EQ|NE expr */
+ { 175, -3 }, /* (178) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */
+ { 175, -3 }, /* (179) expr ::= expr PLUS|MINUS expr */
+ { 175, -3 }, /* (180) expr ::= expr STAR|SLASH|REM expr */
+ { 175, -3 }, /* (181) expr ::= expr CONCAT expr */
+ { 226, -2 }, /* (182) likeop ::= NOT LIKE_KW|MATCH */
+ { 175, -3 }, /* (183) expr ::= expr likeop expr */
+ { 175, -5 }, /* (184) expr ::= expr likeop expr ESCAPE expr */
+ { 175, -2 }, /* (185) expr ::= expr ISNULL|NOTNULL */
+ { 175, -3 }, /* (186) expr ::= expr NOT NULL */
+ { 175, -3 }, /* (187) expr ::= expr IS expr */
+ { 175, -4 }, /* (188) expr ::= expr IS NOT expr */
+ { 175, -2 }, /* (189) expr ::= NOT expr */
+ { 175, -2 }, /* (190) expr ::= BITNOT expr */
+ { 175, -2 }, /* (191) expr ::= PLUS|MINUS expr */
+ { 227, -1 }, /* (192) between_op ::= BETWEEN */
+ { 227, -2 }, /* (193) between_op ::= NOT BETWEEN */
+ { 175, -5 }, /* (194) expr ::= expr between_op expr AND expr */
+ { 228, -1 }, /* (195) in_op ::= IN */
+ { 228, -2 }, /* (196) in_op ::= NOT IN */
+ { 175, -5 }, /* (197) expr ::= expr in_op LP exprlist RP */
+ { 175, -3 }, /* (198) expr ::= LP select RP */
+ { 175, -5 }, /* (199) expr ::= expr in_op LP select RP */
+ { 175, -5 }, /* (200) expr ::= expr in_op nm dbnm paren_exprlist */
+ { 175, -4 }, /* (201) expr ::= EXISTS LP select RP */
+ { 175, -5 }, /* (202) expr ::= CASE case_operand case_exprlist case_else END */
+ { 231, -5 }, /* (203) case_exprlist ::= case_exprlist WHEN expr THEN expr */
+ { 231, -4 }, /* (204) case_exprlist ::= WHEN expr THEN expr */
+ { 232, -2 }, /* (205) case_else ::= ELSE expr */
+ { 232, 0 }, /* (206) case_else ::= */
+ { 230, -1 }, /* (207) case_operand ::= expr */
+ { 230, 0 }, /* (208) case_operand ::= */
+ { 218, 0 }, /* (209) exprlist ::= */
+ { 209, -3 }, /* (210) nexprlist ::= nexprlist COMMA expr */
+ { 209, -1 }, /* (211) nexprlist ::= expr */
+ { 229, 0 }, /* (212) paren_exprlist ::= */
+ { 229, -3 }, /* (213) paren_exprlist ::= LP exprlist RP */
+ { 150, -12 }, /* (214) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
+ { 233, -1 }, /* (215) uniqueflag ::= UNIQUE */
+ { 233, 0 }, /* (216) uniqueflag ::= */
+ { 179, 0 }, /* (217) eidlist_opt ::= */
+ { 179, -3 }, /* (218) eidlist_opt ::= LP eidlist RP */
+ { 189, -5 }, /* (219) eidlist ::= eidlist COMMA nm collate sortorder */
+ { 189, -3 }, /* (220) eidlist ::= nm collate sortorder */
+ { 234, 0 }, /* (221) collate ::= */
+ { 234, -2 }, /* (222) collate ::= COLLATE ID|STRING */
+ { 150, -4 }, /* (223) cmd ::= DROP INDEX ifexists fullname */
+ { 150, -1 }, /* (224) cmd ::= VACUUM */
+ { 150, -2 }, /* (225) cmd ::= VACUUM nm */
+ { 150, -3 }, /* (226) cmd ::= PRAGMA nm dbnm */
+ { 150, -5 }, /* (227) cmd ::= PRAGMA nm dbnm EQ nmnum */
+ { 150, -6 }, /* (228) cmd ::= PRAGMA nm dbnm LP nmnum RP */
+ { 150, -5 }, /* (229) cmd ::= PRAGMA nm dbnm EQ minus_num */
+ { 150, -6 }, /* (230) cmd ::= PRAGMA nm dbnm LP minus_num RP */
+ { 170, -2 }, /* (231) plus_num ::= PLUS INTEGER|FLOAT */
+ { 171, -2 }, /* (232) minus_num ::= MINUS INTEGER|FLOAT */
+ { 150, -5 }, /* (233) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
+ { 236, -11 }, /* (234) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
+ { 238, -1 }, /* (235) trigger_time ::= BEFORE|AFTER */
+ { 238, -2 }, /* (236) trigger_time ::= INSTEAD OF */
+ { 238, 0 }, /* (237) trigger_time ::= */
+ { 239, -1 }, /* (238) trigger_event ::= DELETE|INSERT */
+ { 239, -1 }, /* (239) trigger_event ::= UPDATE */
+ { 239, -3 }, /* (240) trigger_event ::= UPDATE OF idlist */
+ { 241, 0 }, /* (241) when_clause ::= */
+ { 241, -2 }, /* (242) when_clause ::= WHEN expr */
+ { 237, -3 }, /* (243) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
+ { 237, -2 }, /* (244) trigger_cmd_list ::= trigger_cmd SEMI */
+ { 243, -3 }, /* (245) trnm ::= nm DOT nm */
+ { 244, -3 }, /* (246) tridxby ::= INDEXED BY nm */
+ { 244, -2 }, /* (247) tridxby ::= NOT INDEXED */
+ { 242, -8 }, /* (248) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */
+ { 242, -8 }, /* (249) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
+ { 242, -6 }, /* (250) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
+ { 242, -3 }, /* (251) trigger_cmd ::= scanpt select scanpt */
+ { 175, -4 }, /* (252) expr ::= RAISE LP IGNORE RP */
+ { 175, -6 }, /* (253) expr ::= RAISE LP raisetype COMMA nm RP */
+ { 193, -1 }, /* (254) raisetype ::= ROLLBACK */
+ { 193, -1 }, /* (255) raisetype ::= ABORT */
+ { 193, -1 }, /* (256) raisetype ::= FAIL */
+ { 150, -4 }, /* (257) cmd ::= DROP TRIGGER ifexists fullname */
+ { 150, -6 }, /* (258) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
+ { 150, -3 }, /* (259) cmd ::= DETACH database_kw_opt expr */
+ { 246, 0 }, /* (260) key_opt ::= */
+ { 246, -2 }, /* (261) key_opt ::= KEY expr */
+ { 150, -6 }, /* (262) cmd ::= ALTER TABLE fullname RENAME TO nm */
+ { 150, -7 }, /* (263) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
+ { 247, -1 }, /* (264) add_column_fullname ::= fullname */
+ { 150, -8 }, /* (265) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
+ { 150, -1 }, /* (266) cmd ::= create_vtab */
+ { 150, -4 }, /* (267) cmd ::= create_vtab LP vtabarglist RP */
+ { 249, -8 }, /* (268) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
+ { 251, 0 }, /* (269) vtabarg ::= */
+ { 252, -1 }, /* (270) vtabargtoken ::= ANY */
+ { 252, -3 }, /* (271) vtabargtoken ::= lp anylist RP */
+ { 253, -1 }, /* (272) lp ::= LP */
+ { 221, -2 }, /* (273) with ::= WITH wqlist */
+ { 221, -3 }, /* (274) with ::= WITH RECURSIVE wqlist */
+ { 198, -6 }, /* (275) wqlist ::= nm eidlist_opt AS LP select RP */
+ { 198, -8 }, /* (276) wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
+ { 146, -1 }, /* (277) input ::= cmdlist */
+ { 147, -2 }, /* (278) cmdlist ::= cmdlist ecmd */
+ { 147, -1 }, /* (279) cmdlist ::= ecmd */
+ { 148, -1 }, /* (280) ecmd ::= SEMI */
+ { 148, -2 }, /* (281) ecmd ::= cmdx SEMI */
+ { 152, 0 }, /* (282) trans_opt ::= */
+ { 152, -1 }, /* (283) trans_opt ::= TRANSACTION */
+ { 152, -2 }, /* (284) trans_opt ::= TRANSACTION nm */
+ { 154, -1 }, /* (285) savepoint_opt ::= SAVEPOINT */
+ { 154, 0 }, /* (286) savepoint_opt ::= */
+ { 150, -2 }, /* (287) cmd ::= create_table create_table_args */
+ { 161, -4 }, /* (288) columnlist ::= columnlist COMMA columnname carglist */
+ { 161, -2 }, /* (289) columnlist ::= columnname carglist */
+ { 153, -1 }, /* (290) nm ::= ID|INDEXED */
+ { 153, -1 }, /* (291) nm ::= STRING */
+ { 153, -1 }, /* (292) nm ::= JOIN_KW */
+ { 167, -1 }, /* (293) typetoken ::= typename */
+ { 168, -1 }, /* (294) typename ::= ID|STRING */
+ { 169, -1 }, /* (295) signed ::= plus_num */
+ { 169, -1 }, /* (296) signed ::= minus_num */
+ { 166, -2 }, /* (297) carglist ::= carglist ccons */
+ { 166, 0 }, /* (298) carglist ::= */
+ { 173, -2 }, /* (299) ccons ::= NULL onconf */
+ { 162, -2 }, /* (300) conslist_opt ::= COMMA conslist */
+ { 185, -3 }, /* (301) conslist ::= conslist tconscomma tcons */
+ { 185, -1 }, /* (302) conslist ::= tcons */
+ { 186, 0 }, /* (303) tconscomma ::= */
+ { 190, -1 }, /* (304) defer_subclause_opt ::= defer_subclause */
+ { 192, -1 }, /* (305) resolvetype ::= raisetype */
+ { 196, -1 }, /* (306) selectnowith ::= oneselect */
+ { 197, -1 }, /* (307) oneselect ::= values */
+ { 210, -2 }, /* (308) sclp ::= selcollist COMMA */
+ { 211, -1 }, /* (309) as ::= ID|STRING */
+ { 175, -1 }, /* (310) expr ::= term */
+ { 226, -1 }, /* (311) likeop ::= LIKE_KW|MATCH */
+ { 218, -1 }, /* (312) exprlist ::= nexprlist */
+ { 235, -1 }, /* (313) nmnum ::= plus_num */
+ { 235, -1 }, /* (314) nmnum ::= nm */
+ { 235, -1 }, /* (315) nmnum ::= ON */
+ { 235, -1 }, /* (316) nmnum ::= DELETE */
+ { 235, -1 }, /* (317) nmnum ::= DEFAULT */
+ { 170, -1 }, /* (318) plus_num ::= INTEGER|FLOAT */
+ { 240, 0 }, /* (319) foreach_clause ::= */
+ { 240, -3 }, /* (320) foreach_clause ::= FOR EACH ROW */
+ { 243, -1 }, /* (321) trnm ::= nm */
+ { 244, 0 }, /* (322) tridxby ::= */
+ { 245, -1 }, /* (323) database_kw_opt ::= DATABASE */
+ { 245, 0 }, /* (324) database_kw_opt ::= */
+ { 248, 0 }, /* (325) kwcolumn_opt ::= */
+ { 248, -1 }, /* (326) kwcolumn_opt ::= COLUMNKW */
+ { 250, -1 }, /* (327) vtabarglist ::= vtabarg */
+ { 250, -3 }, /* (328) vtabarglist ::= vtabarglist COMMA vtabarg */
+ { 251, -2 }, /* (329) vtabarg ::= vtabarg vtabargtoken */
+ { 254, 0 }, /* (330) anylist ::= */
+ { 254, -4 }, /* (331) anylist ::= anylist LP anylist RP */
+ { 254, -2 }, /* (332) anylist ::= anylist ANY */
+ { 221, 0 }, /* (333) with ::= */
};
static void yy_accept(yyParser*); /* Forward Declaration */
@@ -149554,139 +149483,133 @@ static YYACTIONTYPE yy_reduce(
*/
/********** Begin reduce actions **********************************************/
YYMINORTYPE yylhsminor;
- case 0: /* explain ::= EXPLAIN */
-{ pParse->explain = 1; }
- break;
- case 1: /* explain ::= EXPLAIN QUERY PLAN */
-{ pParse->explain = 2; }
- break;
- case 2: /* cmdx ::= cmd */
+ case 0: /* cmdx ::= cmd */
{ sqlite3FinishCoding(pParse); }
break;
- case 3: /* cmd ::= BEGIN transtype trans_opt */
-{sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy348);}
+ case 1: /* cmd ::= BEGIN transtype trans_opt */
+{sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy502);}
break;
- case 4: /* transtype ::= */
-{yymsp[1].minor.yy348 = TK_DEFERRED;}
+ case 2: /* transtype ::= */
+{yymsp[1].minor.yy502 = TK_DEFERRED;}
break;
- case 5: /* transtype ::= DEFERRED */
- case 6: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==6);
- case 7: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==7);
-{yymsp[0].minor.yy348 = yymsp[0].major; /*A-overwrites-X*/}
+ case 3: /* transtype ::= DEFERRED */
+ case 4: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==4);
+ case 5: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==5);
+{yymsp[0].minor.yy502 = yymsp[0].major; /*A-overwrites-X*/}
break;
- case 8: /* cmd ::= COMMIT|END trans_opt */
- case 9: /* cmd ::= ROLLBACK trans_opt */ yytestcase(yyruleno==9);
+ case 6: /* cmd ::= COMMIT|END trans_opt */
+ case 7: /* cmd ::= ROLLBACK trans_opt */ yytestcase(yyruleno==7);
{sqlite3EndTransaction(pParse,yymsp[-1].major);}
break;
- case 10: /* cmd ::= SAVEPOINT nm */
+ case 8: /* cmd ::= SAVEPOINT nm */
{
sqlite3Savepoint(pParse, SAVEPOINT_BEGIN, &yymsp[0].minor.yy0);
}
break;
- case 11: /* cmd ::= RELEASE savepoint_opt nm */
+ case 9: /* cmd ::= RELEASE savepoint_opt nm */
{
sqlite3Savepoint(pParse, SAVEPOINT_RELEASE, &yymsp[0].minor.yy0);
}
break;
- case 12: /* cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */
+ case 10: /* cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */
{
sqlite3Savepoint(pParse, SAVEPOINT_ROLLBACK, &yymsp[0].minor.yy0);
}
break;
- case 13: /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */
+ case 11: /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */
{
- sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy348,0,0,yymsp[-2].minor.yy348);
+ sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy502,0,0,yymsp[-2].minor.yy502);
}
break;
- case 14: /* createkw ::= CREATE */
+ case 12: /* createkw ::= CREATE */
{disableLookaside(pParse);}
break;
- case 15: /* ifnotexists ::= */
- case 18: /* temp ::= */ yytestcase(yyruleno==18);
- case 21: /* table_options ::= */ yytestcase(yyruleno==21);
- case 42: /* autoinc ::= */ yytestcase(yyruleno==42);
- case 57: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==57);
- case 67: /* defer_subclause_opt ::= */ yytestcase(yyruleno==67);
- case 76: /* ifexists ::= */ yytestcase(yyruleno==76);
- case 92: /* distinct ::= */ yytestcase(yyruleno==92);
- case 223: /* collate ::= */ yytestcase(yyruleno==223);
-{yymsp[1].minor.yy348 = 0;}
+ case 13: /* ifnotexists ::= */
+ case 16: /* temp ::= */ yytestcase(yyruleno==16);
+ case 19: /* table_options ::= */ yytestcase(yyruleno==19);
+ case 40: /* autoinc ::= */ yytestcase(yyruleno==40);
+ case 55: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==55);
+ case 65: /* defer_subclause_opt ::= */ yytestcase(yyruleno==65);
+ case 74: /* ifexists ::= */ yytestcase(yyruleno==74);
+ case 90: /* distinct ::= */ yytestcase(yyruleno==90);
+ case 221: /* collate ::= */ yytestcase(yyruleno==221);
+{yymsp[1].minor.yy502 = 0;}
break;
- case 16: /* ifnotexists ::= IF NOT EXISTS */
-{yymsp[-2].minor.yy348 = 1;}
+ case 14: /* ifnotexists ::= IF NOT EXISTS */
+{yymsp[-2].minor.yy502 = 1;}
break;
- case 17: /* temp ::= TEMP */
- case 43: /* autoinc ::= AUTOINCR */ yytestcase(yyruleno==43);
-{yymsp[0].minor.yy348 = 1;}
+ case 15: /* temp ::= TEMP */
+ case 41: /* autoinc ::= AUTOINCR */ yytestcase(yyruleno==41);
+{yymsp[0].minor.yy502 = 1;}
break;
- case 19: /* create_table_args ::= LP columnlist conslist_opt RP table_options */
+ case 17: /* create_table_args ::= LP columnlist conslist_opt RP table_options */
{
- sqlite3EndTable(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,yymsp[0].minor.yy348,0);
+ sqlite3EndTable(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,yymsp[0].minor.yy502,0);
}
break;
- case 20: /* create_table_args ::= AS select */
+ case 18: /* create_table_args ::= AS select */
{
- sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy43);
- sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy43);
+ sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy399);
+ sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy399);
}
break;
- case 22: /* table_options ::= WITHOUT nm */
+ case 20: /* table_options ::= WITHOUT nm */
{
if( yymsp[0].minor.yy0.n==5 && sqlite3_strnicmp(yymsp[0].minor.yy0.z,"rowid",5)==0 ){
- yymsp[-1].minor.yy348 = TF_WithoutRowid | TF_NoVisibleRowid;
+ yymsp[-1].minor.yy502 = TF_WithoutRowid | TF_NoVisibleRowid;
}else{
- yymsp[-1].minor.yy348 = 0;
+ yymsp[-1].minor.yy502 = 0;
sqlite3ErrorMsg(pParse, "unknown table option: %.*s", yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.z);
}
}
break;
- case 23: /* columnname ::= nm typetoken */
+ case 21: /* columnname ::= nm typetoken */
{sqlite3AddColumn(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0);}
break;
- case 24: /* typetoken ::= */
- case 60: /* conslist_opt ::= */ yytestcase(yyruleno==60);
- case 98: /* as ::= */ yytestcase(yyruleno==98);
+ case 22: /* typetoken ::= */
+ case 58: /* conslist_opt ::= */ yytestcase(yyruleno==58);
+ case 96: /* as ::= */ yytestcase(yyruleno==96);
{yymsp[1].minor.yy0.n = 0; yymsp[1].minor.yy0.z = 0;}
break;
- case 25: /* typetoken ::= typename LP signed RP */
+ case 23: /* typetoken ::= typename LP signed RP */
{
yymsp[-3].minor.yy0.n = (int)(&yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] - yymsp[-3].minor.yy0.z);
}
break;
- case 26: /* typetoken ::= typename LP signed COMMA signed RP */
+ case 24: /* typetoken ::= typename LP signed COMMA signed RP */
{
yymsp[-5].minor.yy0.n = (int)(&yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] - yymsp[-5].minor.yy0.z);
}
break;
- case 27: /* typename ::= typename ID|STRING */
+ case 25: /* typename ::= typename ID|STRING */
{yymsp[-1].minor.yy0.n=yymsp[0].minor.yy0.n+(int)(yymsp[0].minor.yy0.z-yymsp[-1].minor.yy0.z);}
break;
- case 28: /* scanpt ::= */
+ case 26: /* scanpt ::= */
{
assert( yyLookahead!=YYNOCODE );
- yymsp[1].minor.yy360 = yyLookaheadToken.z;
+ yymsp[1].minor.yy36 = yyLookaheadToken.z;
}
break;
- case 29: /* ccons ::= CONSTRAINT nm */
- case 62: /* tcons ::= CONSTRAINT nm */ yytestcase(yyruleno==62);
+ case 27: /* ccons ::= CONSTRAINT nm */
+ case 60: /* tcons ::= CONSTRAINT nm */ yytestcase(yyruleno==60);
{pParse->constraintName = yymsp[0].minor.yy0;}
break;
- case 30: /* ccons ::= DEFAULT scanpt term scanpt */
-{sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy2,yymsp[-2].minor.yy360,yymsp[0].minor.yy360);}
+ case 28: /* ccons ::= DEFAULT scanpt term scanpt */
+{sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy182,yymsp[-2].minor.yy36,yymsp[0].minor.yy36);}
break;
- case 31: /* ccons ::= DEFAULT LP expr RP */
-{sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy2,yymsp[-2].minor.yy0.z+1,yymsp[0].minor.yy0.z);}
+ case 29: /* ccons ::= DEFAULT LP expr RP */
+{sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy182,yymsp[-2].minor.yy0.z+1,yymsp[0].minor.yy0.z);}
break;
- case 32: /* ccons ::= DEFAULT PLUS term scanpt */
-{sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy2,yymsp[-2].minor.yy0.z,yymsp[0].minor.yy360);}
+ case 30: /* ccons ::= DEFAULT PLUS term scanpt */
+{sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy182,yymsp[-2].minor.yy0.z,yymsp[0].minor.yy36);}
break;
- case 33: /* ccons ::= DEFAULT MINUS term scanpt */
+ case 31: /* ccons ::= DEFAULT MINUS term scanpt */
{
- Expr *p = sqlite3PExpr(pParse, TK_UMINUS, yymsp[-1].minor.yy2, 0);
- sqlite3AddDefaultValue(pParse,p,yymsp[-2].minor.yy0.z,yymsp[0].minor.yy360);
+ Expr *p = sqlite3PExpr(pParse, TK_UMINUS, yymsp[-1].minor.yy182, 0);
+ sqlite3AddDefaultValue(pParse,p,yymsp[-2].minor.yy0.z,yymsp[0].minor.yy36);
}
break;
- case 34: /* ccons ::= DEFAULT scanpt ID|INDEXED */
+ case 32: /* ccons ::= DEFAULT scanpt ID|INDEXED */
{
Expr *p = tokenExpr(pParse, TK_STRING, yymsp[0].minor.yy0);
if( p ){
@@ -149696,171 +149619,171 @@ static YYACTIONTYPE yy_reduce(
sqlite3AddDefaultValue(pParse,p,yymsp[0].minor.yy0.z,yymsp[0].minor.yy0.z+yymsp[0].minor.yy0.n);
}
break;
- case 35: /* ccons ::= NOT NULL onconf */
-{sqlite3AddNotNull(pParse, yymsp[0].minor.yy348);}
+ case 33: /* ccons ::= NOT NULL onconf */
+{sqlite3AddNotNull(pParse, yymsp[0].minor.yy502);}
break;
- case 36: /* ccons ::= PRIMARY KEY sortorder onconf autoinc */
-{sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy348,yymsp[0].minor.yy348,yymsp[-2].minor.yy348);}
+ case 34: /* ccons ::= PRIMARY KEY sortorder onconf autoinc */
+{sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy502,yymsp[0].minor.yy502,yymsp[-2].minor.yy502);}
break;
- case 37: /* ccons ::= UNIQUE onconf */
-{sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy348,0,0,0,0,
+ case 35: /* ccons ::= UNIQUE onconf */
+{sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy502,0,0,0,0,
SQLITE_IDXTYPE_UNIQUE);}
break;
- case 38: /* ccons ::= CHECK LP expr RP */
-{sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy2);}
+ case 36: /* ccons ::= CHECK LP expr RP */
+{sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy182);}
break;
- case 39: /* ccons ::= REFERENCES nm eidlist_opt refargs */
-{sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy402,yymsp[0].minor.yy348);}
+ case 37: /* ccons ::= REFERENCES nm eidlist_opt refargs */
+{sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy232,yymsp[0].minor.yy502);}
break;
- case 40: /* ccons ::= defer_subclause */
-{sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy348);}
+ case 38: /* ccons ::= defer_subclause */
+{sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy502);}
break;
- case 41: /* ccons ::= COLLATE ID|STRING */
+ case 39: /* ccons ::= COLLATE ID|STRING */
{sqlite3AddCollateType(pParse, &yymsp[0].minor.yy0);}
break;
- case 44: /* refargs ::= */
-{ yymsp[1].minor.yy348 = OE_None*0x0101; /* EV: R-19803-45884 */}
+ case 42: /* refargs ::= */
+{ yymsp[1].minor.yy502 = OE_None*0x0101; /* EV: R-19803-45884 */}
break;
- case 45: /* refargs ::= refargs refarg */
-{ yymsp[-1].minor.yy348 = (yymsp[-1].minor.yy348 & ~yymsp[0].minor.yy239.mask) | yymsp[0].minor.yy239.value; }
+ case 43: /* refargs ::= refargs refarg */
+{ yymsp[-1].minor.yy502 = (yymsp[-1].minor.yy502 & ~yymsp[0].minor.yy107.mask) | yymsp[0].minor.yy107.value; }
break;
- case 46: /* refarg ::= MATCH nm */
-{ yymsp[-1].minor.yy239.value = 0; yymsp[-1].minor.yy239.mask = 0x000000; }
+ case 44: /* refarg ::= MATCH nm */
+{ yymsp[-1].minor.yy107.value = 0; yymsp[-1].minor.yy107.mask = 0x000000; }
break;
- case 47: /* refarg ::= ON INSERT refact */
-{ yymsp[-2].minor.yy239.value = 0; yymsp[-2].minor.yy239.mask = 0x000000; }
+ case 45: /* refarg ::= ON INSERT refact */
+{ yymsp[-2].minor.yy107.value = 0; yymsp[-2].minor.yy107.mask = 0x000000; }
break;
- case 48: /* refarg ::= ON DELETE refact */
-{ yymsp[-2].minor.yy239.value = yymsp[0].minor.yy348; yymsp[-2].minor.yy239.mask = 0x0000ff; }
+ case 46: /* refarg ::= ON DELETE refact */
+{ yymsp[-2].minor.yy107.value = yymsp[0].minor.yy502; yymsp[-2].minor.yy107.mask = 0x0000ff; }
break;
- case 49: /* refarg ::= ON UPDATE refact */
-{ yymsp[-2].minor.yy239.value = yymsp[0].minor.yy348<<8; yymsp[-2].minor.yy239.mask = 0x00ff00; }
+ case 47: /* refarg ::= ON UPDATE refact */
+{ yymsp[-2].minor.yy107.value = yymsp[0].minor.yy502<<8; yymsp[-2].minor.yy107.mask = 0x00ff00; }
break;
- case 50: /* refact ::= SET NULL */
-{ yymsp[-1].minor.yy348 = OE_SetNull; /* EV: R-33326-45252 */}
+ case 48: /* refact ::= SET NULL */
+{ yymsp[-1].minor.yy502 = OE_SetNull; /* EV: R-33326-45252 */}
break;
- case 51: /* refact ::= SET DEFAULT */
-{ yymsp[-1].minor.yy348 = OE_SetDflt; /* EV: R-33326-45252 */}
+ case 49: /* refact ::= SET DEFAULT */
+{ yymsp[-1].minor.yy502 = OE_SetDflt; /* EV: R-33326-45252 */}
break;
- case 52: /* refact ::= CASCADE */
-{ yymsp[0].minor.yy348 = OE_Cascade; /* EV: R-33326-45252 */}
+ case 50: /* refact ::= CASCADE */
+{ yymsp[0].minor.yy502 = OE_Cascade; /* EV: R-33326-45252 */}
break;
- case 53: /* refact ::= RESTRICT */
-{ yymsp[0].minor.yy348 = OE_Restrict; /* EV: R-33326-45252 */}
+ case 51: /* refact ::= RESTRICT */
+{ yymsp[0].minor.yy502 = OE_Restrict; /* EV: R-33326-45252 */}
break;
- case 54: /* refact ::= NO ACTION */
-{ yymsp[-1].minor.yy348 = OE_None; /* EV: R-33326-45252 */}
+ case 52: /* refact ::= NO ACTION */
+{ yymsp[-1].minor.yy502 = OE_None; /* EV: R-33326-45252 */}
break;
- case 55: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
-{yymsp[-2].minor.yy348 = 0;}
+ case 53: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
+{yymsp[-2].minor.yy502 = 0;}
break;
- case 56: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
- case 71: /* orconf ::= OR resolvetype */ yytestcase(yyruleno==71);
- case 155: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==155);
-{yymsp[-1].minor.yy348 = yymsp[0].minor.yy348;}
+ case 54: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
+ case 69: /* orconf ::= OR resolvetype */ yytestcase(yyruleno==69);
+ case 153: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==153);
+{yymsp[-1].minor.yy502 = yymsp[0].minor.yy502;}
break;
- case 58: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */
- case 75: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==75);
- case 195: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==195);
- case 198: /* in_op ::= NOT IN */ yytestcase(yyruleno==198);
- case 224: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==224);
-{yymsp[-1].minor.yy348 = 1;}
+ case 56: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */
+ case 73: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==73);
+ case 193: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==193);
+ case 196: /* in_op ::= NOT IN */ yytestcase(yyruleno==196);
+ case 222: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==222);
+{yymsp[-1].minor.yy502 = 1;}
break;
- case 59: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
-{yymsp[-1].minor.yy348 = 0;}
+ case 57: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
+{yymsp[-1].minor.yy502 = 0;}
break;
- case 61: /* tconscomma ::= COMMA */
+ case 59: /* tconscomma ::= COMMA */
{pParse->constraintName.n = 0;}
break;
- case 63: /* tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
-{sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy402,yymsp[0].minor.yy348,yymsp[-2].minor.yy348,0);}
+ case 61: /* tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
+{sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy232,yymsp[0].minor.yy502,yymsp[-2].minor.yy502,0);}
break;
- case 64: /* tcons ::= UNIQUE LP sortlist RP onconf */
-{sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy402,yymsp[0].minor.yy348,0,0,0,0,
+ case 62: /* tcons ::= UNIQUE LP sortlist RP onconf */
+{sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy232,yymsp[0].minor.yy502,0,0,0,0,
SQLITE_IDXTYPE_UNIQUE);}
break;
- case 65: /* tcons ::= CHECK LP expr RP onconf */
-{sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy2);}
+ case 63: /* tcons ::= CHECK LP expr RP onconf */
+{sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy182);}
break;
- case 66: /* tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
+ case 64: /* tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
{
- sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy402, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy402, yymsp[-1].minor.yy348);
- sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy348);
+ sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy232, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy232, yymsp[-1].minor.yy502);
+ sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy502);
}
break;
- case 68: /* onconf ::= */
- case 70: /* orconf ::= */ yytestcase(yyruleno==70);
-{yymsp[1].minor.yy348 = OE_Default;}
+ case 66: /* onconf ::= */
+ case 68: /* orconf ::= */ yytestcase(yyruleno==68);
+{yymsp[1].minor.yy502 = OE_Default;}
break;
- case 69: /* onconf ::= ON CONFLICT resolvetype */
-{yymsp[-2].minor.yy348 = yymsp[0].minor.yy348;}
+ case 67: /* onconf ::= ON CONFLICT resolvetype */
+{yymsp[-2].minor.yy502 = yymsp[0].minor.yy502;}
break;
- case 72: /* resolvetype ::= IGNORE */
-{yymsp[0].minor.yy348 = OE_Ignore;}
+ case 70: /* resolvetype ::= IGNORE */
+{yymsp[0].minor.yy502 = OE_Ignore;}
break;
- case 73: /* resolvetype ::= REPLACE */
- case 156: /* insert_cmd ::= REPLACE */ yytestcase(yyruleno==156);
-{yymsp[0].minor.yy348 = OE_Replace;}
+ case 71: /* resolvetype ::= REPLACE */
+ case 154: /* insert_cmd ::= REPLACE */ yytestcase(yyruleno==154);
+{yymsp[0].minor.yy502 = OE_Replace;}
break;
- case 74: /* cmd ::= DROP TABLE ifexists fullname */
+ case 72: /* cmd ::= DROP TABLE ifexists fullname */
{
- sqlite3DropTable(pParse, yymsp[0].minor.yy3, 0, yymsp[-1].minor.yy348);
+ sqlite3DropTable(pParse, yymsp[0].minor.yy427, 0, yymsp[-1].minor.yy502);
}
break;
- case 77: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
+ case 75: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
{
- sqlite3CreateView(pParse, &yymsp[-8].minor.yy0, &yymsp[-4].minor.yy0, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy402, yymsp[0].minor.yy43, yymsp[-7].minor.yy348, yymsp[-5].minor.yy348);
+ sqlite3CreateView(pParse, &yymsp[-8].minor.yy0, &yymsp[-4].minor.yy0, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy232, yymsp[0].minor.yy399, yymsp[-7].minor.yy502, yymsp[-5].minor.yy502);
}
break;
- case 78: /* cmd ::= DROP VIEW ifexists fullname */
+ case 76: /* cmd ::= DROP VIEW ifexists fullname */
{
- sqlite3DropTable(pParse, yymsp[0].minor.yy3, 1, yymsp[-1].minor.yy348);
+ sqlite3DropTable(pParse, yymsp[0].minor.yy427, 1, yymsp[-1].minor.yy502);
}
break;
- case 79: /* cmd ::= select */
+ case 77: /* cmd ::= select */
{
SelectDest dest = {SRT_Output, 0, 0, 0, 0, 0};
- sqlite3Select(pParse, yymsp[0].minor.yy43, &dest);
- sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy43);
+ sqlite3Select(pParse, yymsp[0].minor.yy399, &dest);
+ sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy399);
}
break;
- case 80: /* select ::= WITH wqlist selectnowith */
+ case 78: /* select ::= WITH wqlist selectnowith */
{
- Select *p = yymsp[0].minor.yy43;
+ Select *p = yymsp[0].minor.yy399;
if( p ){
- p->pWith = yymsp[-1].minor.yy4;
+ p->pWith = yymsp[-1].minor.yy91;
parserDoubleLinkSelect(pParse, p);
}else{
- sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy4);
+ sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy91);
}
- yymsp[-2].minor.yy43 = p;
+ yymsp[-2].minor.yy399 = p;
}
break;
- case 81: /* select ::= WITH RECURSIVE wqlist selectnowith */
+ case 79: /* select ::= WITH RECURSIVE wqlist selectnowith */
{
- Select *p = yymsp[0].minor.yy43;
+ Select *p = yymsp[0].minor.yy399;
if( p ){
- p->pWith = yymsp[-1].minor.yy4;
+ p->pWith = yymsp[-1].minor.yy91;
parserDoubleLinkSelect(pParse, p);
}else{
- sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy4);
+ sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy91);
}
- yymsp[-3].minor.yy43 = p;
+ yymsp[-3].minor.yy399 = p;
}
break;
- case 82: /* select ::= selectnowith */
+ case 80: /* select ::= selectnowith */
{
- Select *p = yymsp[0].minor.yy43;
+ Select *p = yymsp[0].minor.yy399;
if( p ){
parserDoubleLinkSelect(pParse, p);
}
- yymsp[0].minor.yy43 = p; /*A-overwrites-X*/
+ yymsp[0].minor.yy399 = p; /*A-overwrites-X*/
}
break;
- case 83: /* selectnowith ::= selectnowith multiselect_op oneselect */
+ case 81: /* selectnowith ::= selectnowith multiselect_op oneselect */
{
- Select *pRhs = yymsp[0].minor.yy43;
- Select *pLhs = yymsp[-2].minor.yy43;
+ Select *pRhs = yymsp[0].minor.yy399;
+ Select *pLhs = yymsp[-2].minor.yy399;
if( pRhs && pRhs->pPrior ){
SrcList *pFrom;
Token x;
@@ -149870,331 +149793,331 @@ static YYACTIONTYPE yy_reduce(
pRhs = sqlite3SelectNew(pParse,0,pFrom,0,0,0,0,0,0);
}
if( pRhs ){
- pRhs->op = (u8)yymsp[-1].minor.yy348;
+ pRhs->op = (u8)yymsp[-1].minor.yy502;
pRhs->pPrior = pLhs;
if( ALWAYS(pLhs) ) pLhs->selFlags &= ~SF_MultiValue;
pRhs->selFlags &= ~SF_MultiValue;
- if( yymsp[-1].minor.yy348!=TK_ALL ) pParse->hasCompound = 1;
+ if( yymsp[-1].minor.yy502!=TK_ALL ) pParse->hasCompound = 1;
}else{
sqlite3SelectDelete(pParse->db, pLhs);
}
- yymsp[-2].minor.yy43 = pRhs;
+ yymsp[-2].minor.yy399 = pRhs;
}
break;
- case 84: /* multiselect_op ::= UNION */
- case 86: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==86);
-{yymsp[0].minor.yy348 = yymsp[0].major; /*A-overwrites-OP*/}
+ case 82: /* multiselect_op ::= UNION */
+ case 84: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==84);
+{yymsp[0].minor.yy502 = yymsp[0].major; /*A-overwrites-OP*/}
break;
- case 85: /* multiselect_op ::= UNION ALL */
-{yymsp[-1].minor.yy348 = TK_ALL;}
+ case 83: /* multiselect_op ::= UNION ALL */
+{yymsp[-1].minor.yy502 = TK_ALL;}
break;
- case 87: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
+ case 85: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
{
- yymsp[-8].minor.yy43 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy402,yymsp[-5].minor.yy3,yymsp[-4].minor.yy2,yymsp[-3].minor.yy402,yymsp[-2].minor.yy2,yymsp[-1].minor.yy402,yymsp[-7].minor.yy348,yymsp[0].minor.yy2);
+ yymsp[-8].minor.yy399 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy232,yymsp[-5].minor.yy427,yymsp[-4].minor.yy182,yymsp[-3].minor.yy232,yymsp[-2].minor.yy182,yymsp[-1].minor.yy232,yymsp[-7].minor.yy502,yymsp[0].minor.yy182);
}
break;
- case 88: /* values ::= VALUES LP nexprlist RP */
+ case 86: /* values ::= VALUES LP nexprlist RP */
{
- yymsp[-3].minor.yy43 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy402,0,0,0,0,0,SF_Values,0);
+ yymsp[-3].minor.yy399 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy232,0,0,0,0,0,SF_Values,0);
}
break;
- case 89: /* values ::= values COMMA LP nexprlist RP */
+ case 87: /* values ::= values COMMA LP nexprlist RP */
{
- Select *pRight, *pLeft = yymsp[-4].minor.yy43;
- pRight = sqlite3SelectNew(pParse,yymsp[-1].minor.yy402,0,0,0,0,0,SF_Values|SF_MultiValue,0);
+ Select *pRight, *pLeft = yymsp[-4].minor.yy399;
+ pRight = sqlite3SelectNew(pParse,yymsp[-1].minor.yy232,0,0,0,0,0,SF_Values|SF_MultiValue,0);
if( ALWAYS(pLeft) ) pLeft->selFlags &= ~SF_MultiValue;
if( pRight ){
pRight->op = TK_ALL;
pRight->pPrior = pLeft;
- yymsp[-4].minor.yy43 = pRight;
+ yymsp[-4].minor.yy399 = pRight;
}else{
- yymsp[-4].minor.yy43 = pLeft;
+ yymsp[-4].minor.yy399 = pLeft;
}
}
break;
- case 90: /* distinct ::= DISTINCT */
-{yymsp[0].minor.yy348 = SF_Distinct;}
+ case 88: /* distinct ::= DISTINCT */
+{yymsp[0].minor.yy502 = SF_Distinct;}
break;
- case 91: /* distinct ::= ALL */
-{yymsp[0].minor.yy348 = SF_All;}
+ case 89: /* distinct ::= ALL */
+{yymsp[0].minor.yy502 = SF_All;}
break;
- case 93: /* sclp ::= */
- case 126: /* orderby_opt ::= */ yytestcase(yyruleno==126);
- case 133: /* groupby_opt ::= */ yytestcase(yyruleno==133);
- case 211: /* exprlist ::= */ yytestcase(yyruleno==211);
- case 214: /* paren_exprlist ::= */ yytestcase(yyruleno==214);
- case 219: /* eidlist_opt ::= */ yytestcase(yyruleno==219);
-{yymsp[1].minor.yy402 = 0;}
+ case 91: /* sclp ::= */
+ case 124: /* orderby_opt ::= */ yytestcase(yyruleno==124);
+ case 131: /* groupby_opt ::= */ yytestcase(yyruleno==131);
+ case 209: /* exprlist ::= */ yytestcase(yyruleno==209);
+ case 212: /* paren_exprlist ::= */ yytestcase(yyruleno==212);
+ case 217: /* eidlist_opt ::= */ yytestcase(yyruleno==217);
+{yymsp[1].minor.yy232 = 0;}
break;
- case 94: /* selcollist ::= sclp scanpt expr scanpt as */
+ case 92: /* selcollist ::= sclp scanpt expr scanpt as */
{
- yymsp[-4].minor.yy402 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy402, yymsp[-2].minor.yy2);
- if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy402, &yymsp[0].minor.yy0, 1);
- sqlite3ExprListSetSpan(pParse,yymsp[-4].minor.yy402,yymsp[-3].minor.yy360,yymsp[-1].minor.yy360);
+ yymsp[-4].minor.yy232 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy232, yymsp[-2].minor.yy182);
+ if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy232, &yymsp[0].minor.yy0, 1);
+ sqlite3ExprListSetSpan(pParse,yymsp[-4].minor.yy232,yymsp[-3].minor.yy36,yymsp[-1].minor.yy36);
}
break;
- case 95: /* selcollist ::= sclp scanpt STAR */
+ case 93: /* selcollist ::= sclp scanpt STAR */
{
Expr *p = sqlite3Expr(pParse->db, TK_ASTERISK, 0);
- yymsp[-2].minor.yy402 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy402, p);
+ yymsp[-2].minor.yy232 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy232, p);
}
break;
- case 96: /* selcollist ::= sclp scanpt nm DOT STAR */
+ case 94: /* selcollist ::= sclp scanpt nm DOT STAR */
{
Expr *pRight = sqlite3PExpr(pParse, TK_ASTERISK, 0, 0);
Expr *pLeft = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight);
- yymsp[-4].minor.yy402 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy402, pDot);
+ yymsp[-4].minor.yy232 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy232, pDot);
}
break;
- case 97: /* as ::= AS nm */
- case 108: /* dbnm ::= DOT nm */ yytestcase(yyruleno==108);
- case 233: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==233);
- case 234: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==234);
+ case 95: /* as ::= AS nm */
+ case 106: /* dbnm ::= DOT nm */ yytestcase(yyruleno==106);
+ case 231: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==231);
+ case 232: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==232);
{yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;}
break;
- case 99: /* from ::= */
-{yymsp[1].minor.yy3 = sqlite3DbMallocZero(pParse->db, sizeof(*yymsp[1].minor.yy3));}
+ case 97: /* from ::= */
+{yymsp[1].minor.yy427 = sqlite3DbMallocZero(pParse->db, sizeof(*yymsp[1].minor.yy427));}
break;
- case 100: /* from ::= FROM seltablist */
+ case 98: /* from ::= FROM seltablist */
{
- yymsp[-1].minor.yy3 = yymsp[0].minor.yy3;
- sqlite3SrcListShiftJoinType(yymsp[-1].minor.yy3);
+ yymsp[-1].minor.yy427 = yymsp[0].minor.yy427;
+ sqlite3SrcListShiftJoinType(yymsp[-1].minor.yy427);
}
break;
- case 101: /* stl_prefix ::= seltablist joinop */
+ case 99: /* stl_prefix ::= seltablist joinop */
{
- if( ALWAYS(yymsp[-1].minor.yy3 && yymsp[-1].minor.yy3->nSrc>0) ) yymsp[-1].minor.yy3->a[yymsp[-1].minor.yy3->nSrc-1].fg.jointype = (u8)yymsp[0].minor.yy348;
+ if( ALWAYS(yymsp[-1].minor.yy427 && yymsp[-1].minor.yy427->nSrc>0) ) yymsp[-1].minor.yy427->a[yymsp[-1].minor.yy427->nSrc-1].fg.jointype = (u8)yymsp[0].minor.yy502;
}
break;
- case 102: /* stl_prefix ::= */
-{yymsp[1].minor.yy3 = 0;}
+ case 100: /* stl_prefix ::= */
+{yymsp[1].minor.yy427 = 0;}
break;
- case 103: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
+ case 101: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
{
- yymsp[-6].minor.yy3 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy3,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy2,yymsp[0].minor.yy272);
- sqlite3SrcListIndexedBy(pParse, yymsp[-6].minor.yy3, &yymsp[-2].minor.yy0);
+ yymsp[-6].minor.yy427 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy427,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy182,yymsp[0].minor.yy510);
+ sqlite3SrcListIndexedBy(pParse, yymsp[-6].minor.yy427, &yymsp[-2].minor.yy0);
}
break;
- case 104: /* seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
+ case 102: /* seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
{
- yymsp[-8].minor.yy3 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-8].minor.yy3,&yymsp[-7].minor.yy0,&yymsp[-6].minor.yy0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy2,yymsp[0].minor.yy272);
- sqlite3SrcListFuncArgs(pParse, yymsp[-8].minor.yy3, yymsp[-4].minor.yy402);
+ yymsp[-8].minor.yy427 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-8].minor.yy427,&yymsp[-7].minor.yy0,&yymsp[-6].minor.yy0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy182,yymsp[0].minor.yy510);
+ sqlite3SrcListFuncArgs(pParse, yymsp[-8].minor.yy427, yymsp[-4].minor.yy232);
}
break;
- case 105: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */
+ case 103: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */
{
- yymsp[-6].minor.yy3 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy3,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy43,yymsp[-1].minor.yy2,yymsp[0].minor.yy272);
+ yymsp[-6].minor.yy427 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy427,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy399,yymsp[-1].minor.yy182,yymsp[0].minor.yy510);
}
break;
- case 106: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
+ case 104: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
{
- if( yymsp[-6].minor.yy3==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy2==0 && yymsp[0].minor.yy272==0 ){
- yymsp[-6].minor.yy3 = yymsp[-4].minor.yy3;
- }else if( yymsp[-4].minor.yy3->nSrc==1 ){
- yymsp[-6].minor.yy3 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy3,0,0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy2,yymsp[0].minor.yy272);
- if( yymsp[-6].minor.yy3 ){
- struct SrcList_item *pNew = &yymsp[-6].minor.yy3->a[yymsp[-6].minor.yy3->nSrc-1];
- struct SrcList_item *pOld = yymsp[-4].minor.yy3->a;
+ if( yymsp[-6].minor.yy427==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy182==0 && yymsp[0].minor.yy510==0 ){
+ yymsp[-6].minor.yy427 = yymsp[-4].minor.yy427;
+ }else if( yymsp[-4].minor.yy427->nSrc==1 ){
+ yymsp[-6].minor.yy427 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy427,0,0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy182,yymsp[0].minor.yy510);
+ if( yymsp[-6].minor.yy427 ){
+ struct SrcList_item *pNew = &yymsp[-6].minor.yy427->a[yymsp[-6].minor.yy427->nSrc-1];
+ struct SrcList_item *pOld = yymsp[-4].minor.yy427->a;
pNew->zName = pOld->zName;
pNew->zDatabase = pOld->zDatabase;
pNew->pSelect = pOld->pSelect;
pOld->zName = pOld->zDatabase = 0;
pOld->pSelect = 0;
}
- sqlite3SrcListDelete(pParse->db, yymsp[-4].minor.yy3);
+ sqlite3SrcListDelete(pParse->db, yymsp[-4].minor.yy427);
}else{
Select *pSubquery;
- sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy3);
- pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy3,0,0,0,0,SF_NestedFrom,0);
- yymsp[-6].minor.yy3 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy3,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy2,yymsp[0].minor.yy272);
+ sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy427);
+ pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy427,0,0,0,0,SF_NestedFrom,0);
+ yymsp[-6].minor.yy427 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy427,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy182,yymsp[0].minor.yy510);
}
}
break;
- case 107: /* dbnm ::= */
- case 121: /* indexed_opt ::= */ yytestcase(yyruleno==121);
+ case 105: /* dbnm ::= */
+ case 119: /* indexed_opt ::= */ yytestcase(yyruleno==119);
{yymsp[1].minor.yy0.z=0; yymsp[1].minor.yy0.n=0;}
break;
- case 109: /* fullname ::= nm */
+ case 107: /* fullname ::= nm */
{
- yylhsminor.yy3 = sqlite3SrcListAppend(pParse->db,0,&yymsp[0].minor.yy0,0);
- if( IN_RENAME_OBJECT && yylhsminor.yy3 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy3->a[0].zName, &yymsp[0].minor.yy0);
+ yylhsminor.yy427 = sqlite3SrcListAppend(pParse->db,0,&yymsp[0].minor.yy0,0);
+ if( IN_RENAME_OBJECT && yylhsminor.yy427 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy427->a[0].zName, &yymsp[0].minor.yy0);
}
- yymsp[0].minor.yy3 = yylhsminor.yy3;
+ yymsp[0].minor.yy427 = yylhsminor.yy427;
break;
- case 110: /* fullname ::= nm DOT nm */
+ case 108: /* fullname ::= nm DOT nm */
{
- yylhsminor.yy3 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);
- if( IN_RENAME_OBJECT && yylhsminor.yy3 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy3->a[0].zName, &yymsp[0].minor.yy0);
+ yylhsminor.yy427 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);
+ if( IN_RENAME_OBJECT && yylhsminor.yy427 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy427->a[0].zName, &yymsp[0].minor.yy0);
}
- yymsp[-2].minor.yy3 = yylhsminor.yy3;
+ yymsp[-2].minor.yy427 = yylhsminor.yy427;
break;
- case 111: /* xfullname ::= nm */
-{yymsp[0].minor.yy3 = sqlite3SrcListAppend(pParse->db,0,&yymsp[0].minor.yy0,0); /*A-overwrites-X*/}
+ case 109: /* xfullname ::= nm */
+{yymsp[0].minor.yy427 = sqlite3SrcListAppend(pParse->db,0,&yymsp[0].minor.yy0,0); /*A-overwrites-X*/}
break;
- case 112: /* xfullname ::= nm DOT nm */
-{yymsp[-2].minor.yy3 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/}
+ case 110: /* xfullname ::= nm DOT nm */
+{yymsp[-2].minor.yy427 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/}
break;
- case 113: /* xfullname ::= nm DOT nm AS nm */
+ case 111: /* xfullname ::= nm DOT nm AS nm */
{
- yymsp[-4].minor.yy3 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,&yymsp[-2].minor.yy0); /*A-overwrites-X*/
- if( yymsp[-4].minor.yy3 ) yymsp[-4].minor.yy3->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
+ yymsp[-4].minor.yy427 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,&yymsp[-2].minor.yy0); /*A-overwrites-X*/
+ if( yymsp[-4].minor.yy427 ) yymsp[-4].minor.yy427->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
}
break;
- case 114: /* xfullname ::= nm AS nm */
+ case 112: /* xfullname ::= nm AS nm */
{
- yymsp[-2].minor.yy3 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-2].minor.yy0,0); /*A-overwrites-X*/
- if( yymsp[-2].minor.yy3 ) yymsp[-2].minor.yy3->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
+ yymsp[-2].minor.yy427 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-2].minor.yy0,0); /*A-overwrites-X*/
+ if( yymsp[-2].minor.yy427 ) yymsp[-2].minor.yy427->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
}
break;
- case 115: /* joinop ::= COMMA|JOIN */
-{ yymsp[0].minor.yy348 = JT_INNER; }
+ case 113: /* joinop ::= COMMA|JOIN */
+{ yymsp[0].minor.yy502 = JT_INNER; }
break;
- case 116: /* joinop ::= JOIN_KW JOIN */
-{yymsp[-1].minor.yy348 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); /*X-overwrites-A*/}
+ case 114: /* joinop ::= JOIN_KW JOIN */
+{yymsp[-1].minor.yy502 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); /*X-overwrites-A*/}
break;
- case 117: /* joinop ::= JOIN_KW nm JOIN */
-{yymsp[-2].minor.yy348 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/}
+ case 115: /* joinop ::= JOIN_KW nm JOIN */
+{yymsp[-2].minor.yy502 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/}
break;
- case 118: /* joinop ::= JOIN_KW nm nm JOIN */
-{yymsp[-3].minor.yy348 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/}
+ case 116: /* joinop ::= JOIN_KW nm nm JOIN */
+{yymsp[-3].minor.yy502 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/}
break;
- case 119: /* on_opt ::= ON expr */
- case 136: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==136);
- case 143: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==143);
- case 207: /* case_else ::= ELSE expr */ yytestcase(yyruleno==207);
-{yymsp[-1].minor.yy2 = yymsp[0].minor.yy2;}
+ case 117: /* on_opt ::= ON expr */
+ case 134: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==134);
+ case 141: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==141);
+ case 205: /* case_else ::= ELSE expr */ yytestcase(yyruleno==205);
+{yymsp[-1].minor.yy182 = yymsp[0].minor.yy182;}
break;
- case 120: /* on_opt ::= */
- case 135: /* having_opt ::= */ yytestcase(yyruleno==135);
- case 137: /* limit_opt ::= */ yytestcase(yyruleno==137);
- case 142: /* where_opt ::= */ yytestcase(yyruleno==142);
- case 208: /* case_else ::= */ yytestcase(yyruleno==208);
- case 210: /* case_operand ::= */ yytestcase(yyruleno==210);
-{yymsp[1].minor.yy2 = 0;}
+ case 118: /* on_opt ::= */
+ case 133: /* having_opt ::= */ yytestcase(yyruleno==133);
+ case 135: /* limit_opt ::= */ yytestcase(yyruleno==135);
+ case 140: /* where_opt ::= */ yytestcase(yyruleno==140);
+ case 206: /* case_else ::= */ yytestcase(yyruleno==206);
+ case 208: /* case_operand ::= */ yytestcase(yyruleno==208);
+{yymsp[1].minor.yy182 = 0;}
break;
- case 122: /* indexed_opt ::= INDEXED BY nm */
+ case 120: /* indexed_opt ::= INDEXED BY nm */
{yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;}
break;
- case 123: /* indexed_opt ::= NOT INDEXED */
+ case 121: /* indexed_opt ::= NOT INDEXED */
{yymsp[-1].minor.yy0.z=0; yymsp[-1].minor.yy0.n=1;}
break;
- case 124: /* using_opt ::= USING LP idlist RP */
-{yymsp[-3].minor.yy272 = yymsp[-1].minor.yy272;}
+ case 122: /* using_opt ::= USING LP idlist RP */
+{yymsp[-3].minor.yy510 = yymsp[-1].minor.yy510;}
break;
- case 125: /* using_opt ::= */
- case 157: /* idlist_opt ::= */ yytestcase(yyruleno==157);
-{yymsp[1].minor.yy272 = 0;}
+ case 123: /* using_opt ::= */
+ case 155: /* idlist_opt ::= */ yytestcase(yyruleno==155);
+{yymsp[1].minor.yy510 = 0;}
break;
- case 127: /* orderby_opt ::= ORDER BY sortlist */
- case 134: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==134);
-{yymsp[-2].minor.yy402 = yymsp[0].minor.yy402;}
+ case 125: /* orderby_opt ::= ORDER BY sortlist */
+ case 132: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==132);
+{yymsp[-2].minor.yy232 = yymsp[0].minor.yy232;}
break;
- case 128: /* sortlist ::= sortlist COMMA expr sortorder */
+ case 126: /* sortlist ::= sortlist COMMA expr sortorder */
{
- yymsp[-3].minor.yy402 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy402,yymsp[-1].minor.yy2);
- sqlite3ExprListSetSortOrder(yymsp[-3].minor.yy402,yymsp[0].minor.yy348);
+ yymsp[-3].minor.yy232 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy232,yymsp[-1].minor.yy182);
+ sqlite3ExprListSetSortOrder(yymsp[-3].minor.yy232,yymsp[0].minor.yy502);
}
break;
- case 129: /* sortlist ::= expr sortorder */
+ case 127: /* sortlist ::= expr sortorder */
{
- yymsp[-1].minor.yy402 = sqlite3ExprListAppend(pParse,0,yymsp[-1].minor.yy2); /*A-overwrites-Y*/
- sqlite3ExprListSetSortOrder(yymsp[-1].minor.yy402,yymsp[0].minor.yy348);
+ yymsp[-1].minor.yy232 = sqlite3ExprListAppend(pParse,0,yymsp[-1].minor.yy182); /*A-overwrites-Y*/
+ sqlite3ExprListSetSortOrder(yymsp[-1].minor.yy232,yymsp[0].minor.yy502);
}
break;
- case 130: /* sortorder ::= ASC */
-{yymsp[0].minor.yy348 = SQLITE_SO_ASC;}
+ case 128: /* sortorder ::= ASC */
+{yymsp[0].minor.yy502 = SQLITE_SO_ASC;}
break;
- case 131: /* sortorder ::= DESC */
-{yymsp[0].minor.yy348 = SQLITE_SO_DESC;}
+ case 129: /* sortorder ::= DESC */
+{yymsp[0].minor.yy502 = SQLITE_SO_DESC;}
break;
- case 132: /* sortorder ::= */
-{yymsp[1].minor.yy348 = SQLITE_SO_UNDEFINED;}
+ case 130: /* sortorder ::= */
+{yymsp[1].minor.yy502 = SQLITE_SO_UNDEFINED;}
break;
- case 138: /* limit_opt ::= LIMIT expr */
-{yymsp[-1].minor.yy2 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy2,0);}
+ case 136: /* limit_opt ::= LIMIT expr */
+{yymsp[-1].minor.yy182 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy182,0);}
break;
- case 139: /* limit_opt ::= LIMIT expr OFFSET expr */
-{yymsp[-3].minor.yy2 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[-2].minor.yy2,yymsp[0].minor.yy2);}
+ case 137: /* limit_opt ::= LIMIT expr OFFSET expr */
+{yymsp[-3].minor.yy182 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[-2].minor.yy182,yymsp[0].minor.yy182);}
break;
- case 140: /* limit_opt ::= LIMIT expr COMMA expr */
-{yymsp[-3].minor.yy2 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy2,yymsp[-2].minor.yy2);}
+ case 138: /* limit_opt ::= LIMIT expr COMMA expr */
+{yymsp[-3].minor.yy182 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy182,yymsp[-2].minor.yy182);}
break;
- case 141: /* cmd ::= with DELETE FROM xfullname indexed_opt where_opt */
+ case 139: /* cmd ::= with DELETE FROM xfullname indexed_opt where_opt */
{
- sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy3, &yymsp[-1].minor.yy0);
- sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy3,yymsp[0].minor.yy2,0,0);
+ sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy427, &yymsp[-1].minor.yy0);
+ sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy427,yymsp[0].minor.yy182,0,0);
}
break;
- case 144: /* cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt */
+ case 142: /* cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt */
{
- sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy3, &yymsp[-3].minor.yy0);
- sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy402,"set list");
- sqlite3Update(pParse,yymsp[-4].minor.yy3,yymsp[-1].minor.yy402,yymsp[0].minor.yy2,yymsp[-5].minor.yy348,0,0,0);
+ sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy427, &yymsp[-3].minor.yy0);
+ sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy232,"set list");
+ sqlite3Update(pParse,yymsp[-4].minor.yy427,yymsp[-1].minor.yy232,yymsp[0].minor.yy182,yymsp[-5].minor.yy502,0,0,0);
}
break;
- case 145: /* setlist ::= setlist COMMA nm EQ expr */
+ case 143: /* setlist ::= setlist COMMA nm EQ expr */
{
- yymsp[-4].minor.yy402 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy402, yymsp[0].minor.yy2);
- sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy402, &yymsp[-2].minor.yy0, 1);
+ yymsp[-4].minor.yy232 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy232, yymsp[0].minor.yy182);
+ sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy232, &yymsp[-2].minor.yy0, 1);
}
break;
- case 146: /* setlist ::= setlist COMMA LP idlist RP EQ expr */
+ case 144: /* setlist ::= setlist COMMA LP idlist RP EQ expr */
{
- yymsp[-6].minor.yy402 = sqlite3ExprListAppendVector(pParse, yymsp[-6].minor.yy402, yymsp[-3].minor.yy272, yymsp[0].minor.yy2);
+ yymsp[-6].minor.yy232 = sqlite3ExprListAppendVector(pParse, yymsp[-6].minor.yy232, yymsp[-3].minor.yy510, yymsp[0].minor.yy182);
}
break;
- case 147: /* setlist ::= nm EQ expr */
+ case 145: /* setlist ::= nm EQ expr */
{
- yylhsminor.yy402 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy2);
- sqlite3ExprListSetName(pParse, yylhsminor.yy402, &yymsp[-2].minor.yy0, 1);
+ yylhsminor.yy232 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy182);
+ sqlite3ExprListSetName(pParse, yylhsminor.yy232, &yymsp[-2].minor.yy0, 1);
}
- yymsp[-2].minor.yy402 = yylhsminor.yy402;
+ yymsp[-2].minor.yy232 = yylhsminor.yy232;
break;
- case 148: /* setlist ::= LP idlist RP EQ expr */
+ case 146: /* setlist ::= LP idlist RP EQ expr */
{
- yymsp[-4].minor.yy402 = sqlite3ExprListAppendVector(pParse, 0, yymsp[-3].minor.yy272, yymsp[0].minor.yy2);
+ yymsp[-4].minor.yy232 = sqlite3ExprListAppendVector(pParse, 0, yymsp[-3].minor.yy510, yymsp[0].minor.yy182);
}
break;
- case 149: /* cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
+ case 147: /* cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
{
- sqlite3Insert(pParse, yymsp[-3].minor.yy3, yymsp[-1].minor.yy43, yymsp[-2].minor.yy272, yymsp[-5].minor.yy348, yymsp[0].minor.yy258);
+ sqlite3Insert(pParse, yymsp[-3].minor.yy427, yymsp[-1].minor.yy399, yymsp[-2].minor.yy510, yymsp[-5].minor.yy502, yymsp[0].minor.yy198);
}
break;
- case 150: /* cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */
+ case 148: /* cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */
{
- sqlite3Insert(pParse, yymsp[-3].minor.yy3, 0, yymsp[-2].minor.yy272, yymsp[-5].minor.yy348, 0);
+ sqlite3Insert(pParse, yymsp[-3].minor.yy427, 0, yymsp[-2].minor.yy510, yymsp[-5].minor.yy502, 0);
}
break;
- case 151: /* upsert ::= */
-{ yymsp[1].minor.yy258 = 0; }
+ case 149: /* upsert ::= */
+{ yymsp[1].minor.yy198 = 0; }
break;
- case 152: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */
-{ yymsp[-10].minor.yy258 = sqlite3UpsertNew(pParse->db,yymsp[-7].minor.yy402,yymsp[-5].minor.yy2,yymsp[-1].minor.yy402,yymsp[0].minor.yy2);}
+ case 150: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */
+{ yymsp[-10].minor.yy198 = sqlite3UpsertNew(pParse->db,yymsp[-7].minor.yy232,yymsp[-5].minor.yy182,yymsp[-1].minor.yy232,yymsp[0].minor.yy182);}
break;
- case 153: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */
-{ yymsp[-7].minor.yy258 = sqlite3UpsertNew(pParse->db,yymsp[-4].minor.yy402,yymsp[-2].minor.yy2,0,0); }
+ case 151: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */
+{ yymsp[-7].minor.yy198 = sqlite3UpsertNew(pParse->db,yymsp[-4].minor.yy232,yymsp[-2].minor.yy182,0,0); }
break;
- case 154: /* upsert ::= ON CONFLICT DO NOTHING */
-{ yymsp[-3].minor.yy258 = sqlite3UpsertNew(pParse->db,0,0,0,0); }
+ case 152: /* upsert ::= ON CONFLICT DO NOTHING */
+{ yymsp[-3].minor.yy198 = sqlite3UpsertNew(pParse->db,0,0,0,0); }
break;
- case 158: /* idlist_opt ::= LP idlist RP */
-{yymsp[-2].minor.yy272 = yymsp[-1].minor.yy272;}
+ case 156: /* idlist_opt ::= LP idlist RP */
+{yymsp[-2].minor.yy510 = yymsp[-1].minor.yy510;}
break;
- case 159: /* idlist ::= idlist COMMA nm */
-{yymsp[-2].minor.yy272 = sqlite3IdListAppend(pParse,yymsp[-2].minor.yy272,&yymsp[0].minor.yy0);}
+ case 157: /* idlist ::= idlist COMMA nm */
+{yymsp[-2].minor.yy510 = sqlite3IdListAppend(pParse,yymsp[-2].minor.yy510,&yymsp[0].minor.yy0);}
break;
- case 160: /* idlist ::= nm */
-{yymsp[0].minor.yy272 = sqlite3IdListAppend(pParse,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/}
+ case 158: /* idlist ::= nm */
+{yymsp[0].minor.yy510 = sqlite3IdListAppend(pParse,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/}
break;
- case 161: /* expr ::= LP expr RP */
-{yymsp[-2].minor.yy2 = yymsp[-1].minor.yy2;}
+ case 159: /* expr ::= LP expr RP */
+{yymsp[-2].minor.yy182 = yymsp[-1].minor.yy182;}
break;
- case 162: /* expr ::= ID|INDEXED */
- case 163: /* expr ::= JOIN_KW */ yytestcase(yyruleno==163);
-{yymsp[0].minor.yy2=tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/}
+ case 160: /* expr ::= ID|INDEXED */
+ case 161: /* expr ::= JOIN_KW */ yytestcase(yyruleno==161);
+{yymsp[0].minor.yy182=tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/}
break;
- case 164: /* expr ::= nm DOT nm */
+ case 162: /* expr ::= nm DOT nm */
{
Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[0].minor.yy0, 1);
@@ -150202,11 +150125,11 @@ static YYACTIONTYPE yy_reduce(
sqlite3RenameTokenMap(pParse, (void*)temp2, &yymsp[0].minor.yy0);
sqlite3RenameTokenMap(pParse, (void*)temp1, &yymsp[-2].minor.yy0);
}
- yylhsminor.yy2 = sqlite3PExpr(pParse, TK_DOT, temp1, temp2);
+ yylhsminor.yy182 = sqlite3PExpr(pParse, TK_DOT, temp1, temp2);
}
- yymsp[-2].minor.yy2 = yylhsminor.yy2;
+ yymsp[-2].minor.yy182 = yylhsminor.yy182;
break;
- case 165: /* expr ::= nm DOT nm DOT nm */
+ case 163: /* expr ::= nm DOT nm DOT nm */
{
Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-4].minor.yy0, 1);
Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
@@ -150216,26 +150139,26 @@ static YYACTIONTYPE yy_reduce(
sqlite3RenameTokenMap(pParse, (void*)temp3, &yymsp[0].minor.yy0);
sqlite3RenameTokenMap(pParse, (void*)temp2, &yymsp[-2].minor.yy0);
}
- yylhsminor.yy2 = sqlite3PExpr(pParse, TK_DOT, temp1, temp4);
+ yylhsminor.yy182 = sqlite3PExpr(pParse, TK_DOT, temp1, temp4);
}
- yymsp[-4].minor.yy2 = yylhsminor.yy2;
+ yymsp[-4].minor.yy182 = yylhsminor.yy182;
break;
- case 166: /* term ::= NULL|FLOAT|BLOB */
- case 167: /* term ::= STRING */ yytestcase(yyruleno==167);
-{yymsp[0].minor.yy2=tokenExpr(pParse,yymsp[0].major,yymsp[0].minor.yy0); /*A-overwrites-X*/}
+ case 164: /* term ::= NULL|FLOAT|BLOB */
+ case 165: /* term ::= STRING */ yytestcase(yyruleno==165);
+{yymsp[0].minor.yy182=tokenExpr(pParse,yymsp[0].major,yymsp[0].minor.yy0); /*A-overwrites-X*/}
break;
- case 168: /* term ::= INTEGER */
+ case 166: /* term ::= INTEGER */
{
- yylhsminor.yy2 = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &yymsp[0].minor.yy0, 1);
+ yylhsminor.yy182 = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &yymsp[0].minor.yy0, 1);
}
- yymsp[0].minor.yy2 = yylhsminor.yy2;
+ yymsp[0].minor.yy182 = yylhsminor.yy182;
break;
- case 169: /* expr ::= VARIABLE */
+ case 167: /* expr ::= VARIABLE */
{
if( !(yymsp[0].minor.yy0.z[0]=='#' && sqlite3Isdigit(yymsp[0].minor.yy0.z[1])) ){
u32 n = yymsp[0].minor.yy0.n;
- yymsp[0].minor.yy2 = tokenExpr(pParse, TK_VARIABLE, yymsp[0].minor.yy0);
- sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy2, n);
+ yymsp[0].minor.yy182 = tokenExpr(pParse, TK_VARIABLE, yymsp[0].minor.yy0);
+ sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy182, n);
}else{
/* When doing a nested parse, one can include terms in an expression
** that look like this: #1 #2 ... These terms refer to registers
@@ -150244,140 +150167,140 @@ static YYACTIONTYPE yy_reduce(
assert( t.n>=2 );
if( pParse->nested==0 ){
sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", &t);
- yymsp[0].minor.yy2 = 0;
+ yymsp[0].minor.yy182 = 0;
}else{
- yymsp[0].minor.yy2 = sqlite3PExpr(pParse, TK_REGISTER, 0, 0);
- if( yymsp[0].minor.yy2 ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy2->iTable);
+ yymsp[0].minor.yy182 = sqlite3PExpr(pParse, TK_REGISTER, 0, 0);
+ if( yymsp[0].minor.yy182 ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy182->iTable);
}
}
}
break;
- case 170: /* expr ::= expr COLLATE ID|STRING */
+ case 168: /* expr ::= expr COLLATE ID|STRING */
{
- yymsp[-2].minor.yy2 = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy2, &yymsp[0].minor.yy0, 1);
+ yymsp[-2].minor.yy182 = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy182, &yymsp[0].minor.yy0, 1);
}
break;
- case 171: /* expr ::= CAST LP expr AS typetoken RP */
+ case 169: /* expr ::= CAST LP expr AS typetoken RP */
{
- yymsp[-5].minor.yy2 = sqlite3ExprAlloc(pParse->db, TK_CAST, &yymsp[-1].minor.yy0, 1);
- sqlite3ExprAttachSubtrees(pParse->db, yymsp[-5].minor.yy2, yymsp[-3].minor.yy2, 0);
+ yymsp[-5].minor.yy182 = sqlite3ExprAlloc(pParse->db, TK_CAST, &yymsp[-1].minor.yy0, 1);
+ sqlite3ExprAttachSubtrees(pParse->db, yymsp[-5].minor.yy182, yymsp[-3].minor.yy182, 0);
}
break;
- case 172: /* expr ::= ID|INDEXED LP distinct exprlist RP */
+ case 170: /* expr ::= ID|INDEXED LP distinct exprlist RP */
{
- yylhsminor.yy2 = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy402, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy348);
+ yylhsminor.yy182 = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy232, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy502);
}
- yymsp[-4].minor.yy2 = yylhsminor.yy2;
+ yymsp[-4].minor.yy182 = yylhsminor.yy182;
break;
- case 173: /* expr ::= ID|INDEXED LP STAR RP */
+ case 171: /* expr ::= ID|INDEXED LP STAR RP */
{
- yylhsminor.yy2 = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0, 0);
+ yylhsminor.yy182 = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0, 0);
}
- yymsp[-3].minor.yy2 = yylhsminor.yy2;
+ yymsp[-3].minor.yy182 = yylhsminor.yy182;
break;
- case 174: /* term ::= CTIME_KW */
+ case 172: /* term ::= CTIME_KW */
{
- yylhsminor.yy2 = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0, 0);
+ yylhsminor.yy182 = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0, 0);
}
- yymsp[0].minor.yy2 = yylhsminor.yy2;
+ yymsp[0].minor.yy182 = yylhsminor.yy182;
break;
- case 175: /* expr ::= LP nexprlist COMMA expr RP */
+ case 173: /* expr ::= LP nexprlist COMMA expr RP */
{
- ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy402, yymsp[-1].minor.yy2);
- yymsp[-4].minor.yy2 = sqlite3PExpr(pParse, TK_VECTOR, 0, 0);
- if( yymsp[-4].minor.yy2 ){
- yymsp[-4].minor.yy2->x.pList = pList;
+ ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy232, yymsp[-1].minor.yy182);
+ yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_VECTOR, 0, 0);
+ if( yymsp[-4].minor.yy182 ){
+ yymsp[-4].minor.yy182->x.pList = pList;
}else{
sqlite3ExprListDelete(pParse->db, pList);
}
}
break;
- case 176: /* expr ::= expr AND expr */
- case 177: /* expr ::= expr OR expr */ yytestcase(yyruleno==177);
- case 178: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==178);
- case 179: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==179);
- case 180: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==180);
- case 181: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==181);
- case 182: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==182);
- case 183: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==183);
-{yymsp[-2].minor.yy2=sqlite3PExpr(pParse,yymsp[-1].major,yymsp[-2].minor.yy2,yymsp[0].minor.yy2);}
+ case 174: /* expr ::= expr AND expr */
+ case 175: /* expr ::= expr OR expr */ yytestcase(yyruleno==175);
+ case 176: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==176);
+ case 177: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==177);
+ case 178: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==178);
+ case 179: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==179);
+ case 180: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==180);
+ case 181: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==181);
+{yymsp[-2].minor.yy182=sqlite3PExpr(pParse,yymsp[-1].major,yymsp[-2].minor.yy182,yymsp[0].minor.yy182);}
break;
- case 184: /* likeop ::= NOT LIKE_KW|MATCH */
+ case 182: /* likeop ::= NOT LIKE_KW|MATCH */
{yymsp[-1].minor.yy0=yymsp[0].minor.yy0; yymsp[-1].minor.yy0.n|=0x80000000; /*yymsp[-1].minor.yy0-overwrite-yymsp[0].minor.yy0*/}
break;
- case 185: /* expr ::= expr likeop expr */
+ case 183: /* expr ::= expr likeop expr */
{
ExprList *pList;
int bNot = yymsp[-1].minor.yy0.n & 0x80000000;
yymsp[-1].minor.yy0.n &= 0x7fffffff;
- pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy2);
- pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy2);
- yymsp[-2].minor.yy2 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0, 0);
- if( bNot ) yymsp[-2].minor.yy2 = sqlite3PExpr(pParse, TK_NOT, yymsp[-2].minor.yy2, 0);
- if( yymsp[-2].minor.yy2 ) yymsp[-2].minor.yy2->flags |= EP_InfixFunc;
+ pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy182);
+ pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy182);
+ yymsp[-2].minor.yy182 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0, 0);
+ if( bNot ) yymsp[-2].minor.yy182 = sqlite3PExpr(pParse, TK_NOT, yymsp[-2].minor.yy182, 0);
+ if( yymsp[-2].minor.yy182 ) yymsp[-2].minor.yy182->flags |= EP_InfixFunc;
}
break;
- case 186: /* expr ::= expr likeop expr ESCAPE expr */
+ case 184: /* expr ::= expr likeop expr ESCAPE expr */
{
ExprList *pList;
int bNot = yymsp[-3].minor.yy0.n & 0x80000000;
yymsp[-3].minor.yy0.n &= 0x7fffffff;
- pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy2);
- pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy2);
- pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy2);
- yymsp[-4].minor.yy2 = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy0, 0);
- if( bNot ) yymsp[-4].minor.yy2 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy2, 0);
- if( yymsp[-4].minor.yy2 ) yymsp[-4].minor.yy2->flags |= EP_InfixFunc;
+ pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy182);
+ pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy182);
+ pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy182);
+ yymsp[-4].minor.yy182 = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy0, 0);
+ if( bNot ) yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy182, 0);
+ if( yymsp[-4].minor.yy182 ) yymsp[-4].minor.yy182->flags |= EP_InfixFunc;
}
break;
- case 187: /* expr ::= expr ISNULL|NOTNULL */
-{yymsp[-1].minor.yy2 = sqlite3PExpr(pParse,yymsp[0].major,yymsp[-1].minor.yy2,0);}
+ case 185: /* expr ::= expr ISNULL|NOTNULL */
+{yymsp[-1].minor.yy182 = sqlite3PExpr(pParse,yymsp[0].major,yymsp[-1].minor.yy182,0);}
break;
- case 188: /* expr ::= expr NOT NULL */
-{yymsp[-2].minor.yy2 = sqlite3PExpr(pParse,TK_NOTNULL,yymsp[-2].minor.yy2,0);}
+ case 186: /* expr ::= expr NOT NULL */
+{yymsp[-2].minor.yy182 = sqlite3PExpr(pParse,TK_NOTNULL,yymsp[-2].minor.yy182,0);}
break;
- case 189: /* expr ::= expr IS expr */
+ case 187: /* expr ::= expr IS expr */
{
- yymsp[-2].minor.yy2 = sqlite3PExpr(pParse,TK_IS,yymsp[-2].minor.yy2,yymsp[0].minor.yy2);
- binaryToUnaryIfNull(pParse, yymsp[0].minor.yy2, yymsp[-2].minor.yy2, TK_ISNULL);
+ yymsp[-2].minor.yy182 = sqlite3PExpr(pParse,TK_IS,yymsp[-2].minor.yy182,yymsp[0].minor.yy182);
+ binaryToUnaryIfNull(pParse, yymsp[0].minor.yy182, yymsp[-2].minor.yy182, TK_ISNULL);
}
break;
- case 190: /* expr ::= expr IS NOT expr */
+ case 188: /* expr ::= expr IS NOT expr */
{
- yymsp[-3].minor.yy2 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-3].minor.yy2,yymsp[0].minor.yy2);
- binaryToUnaryIfNull(pParse, yymsp[0].minor.yy2, yymsp[-3].minor.yy2, TK_NOTNULL);
+ yymsp[-3].minor.yy182 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-3].minor.yy182,yymsp[0].minor.yy182);
+ binaryToUnaryIfNull(pParse, yymsp[0].minor.yy182, yymsp[-3].minor.yy182, TK_NOTNULL);
}
break;
- case 191: /* expr ::= NOT expr */
- case 192: /* expr ::= BITNOT expr */ yytestcase(yyruleno==192);
-{yymsp[-1].minor.yy2 = sqlite3PExpr(pParse, yymsp[-1].major, yymsp[0].minor.yy2, 0);/*A-overwrites-B*/}
+ case 189: /* expr ::= NOT expr */
+ case 190: /* expr ::= BITNOT expr */ yytestcase(yyruleno==190);
+{yymsp[-1].minor.yy182 = sqlite3PExpr(pParse, yymsp[-1].major, yymsp[0].minor.yy182, 0);/*A-overwrites-B*/}
break;
- case 193: /* expr ::= PLUS|MINUS expr */
+ case 191: /* expr ::= PLUS|MINUS expr */
{
- yymsp[-1].minor.yy2 = sqlite3PExpr(pParse, yymsp[-1].major==TK_PLUS ? TK_UPLUS : TK_UMINUS, yymsp[0].minor.yy2, 0);
+ yymsp[-1].minor.yy182 = sqlite3PExpr(pParse, yymsp[-1].major==TK_PLUS ? TK_UPLUS : TK_UMINUS, yymsp[0].minor.yy182, 0);
/*A-overwrites-B*/
}
break;
- case 194: /* between_op ::= BETWEEN */
- case 197: /* in_op ::= IN */ yytestcase(yyruleno==197);
-{yymsp[0].minor.yy348 = 0;}
+ case 192: /* between_op ::= BETWEEN */
+ case 195: /* in_op ::= IN */ yytestcase(yyruleno==195);
+{yymsp[0].minor.yy502 = 0;}
break;
- case 196: /* expr ::= expr between_op expr AND expr */
+ case 194: /* expr ::= expr between_op expr AND expr */
{
- ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy2);
- pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy2);
- yymsp[-4].minor.yy2 = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy2, 0);
- if( yymsp[-4].minor.yy2 ){
- yymsp[-4].minor.yy2->x.pList = pList;
+ ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy182);
+ pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy182);
+ yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy182, 0);
+ if( yymsp[-4].minor.yy182 ){
+ yymsp[-4].minor.yy182->x.pList = pList;
}else{
sqlite3ExprListDelete(pParse->db, pList);
}
- if( yymsp[-3].minor.yy348 ) yymsp[-4].minor.yy2 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy2, 0);
+ if( yymsp[-3].minor.yy502 ) yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy182, 0);
}
break;
- case 199: /* expr ::= expr in_op LP exprlist RP */
+ case 197: /* expr ::= expr in_op LP exprlist RP */
{
- if( yymsp[-1].minor.yy402==0 ){
+ if( yymsp[-1].minor.yy232==0 ){
/* Expressions of the form
**
** expr1 IN ()
@@ -150386,9 +150309,9 @@ static YYACTIONTYPE yy_reduce(
** simplify to constants 0 (false) and 1 (true), respectively,
** regardless of the value of expr1.
*/
- sqlite3ExprDelete(pParse->db, yymsp[-4].minor.yy2);
- yymsp[-4].minor.yy2 = sqlite3ExprAlloc(pParse->db, TK_INTEGER,&sqlite3IntTokens[yymsp[-3].minor.yy348],1);
- }else if( yymsp[-1].minor.yy402->nExpr==1 ){
+ sqlite3ExprDelete(pParse->db, yymsp[-4].minor.yy182);
+ yymsp[-4].minor.yy182 = sqlite3ExprAlloc(pParse->db, TK_INTEGER,&sqlite3IntTokens[yymsp[-3].minor.yy502],1);
+ }else if( yymsp[-1].minor.yy232->nExpr==1 ){
/* Expressions of the form:
**
** expr1 IN (?1)
@@ -150405,198 +150328,198 @@ static YYACTIONTYPE yy_reduce(
** affinity or the collating sequence to use for comparison. Otherwise,
** the semantics would be subtly different from IN or NOT IN.
*/
- Expr *pRHS = yymsp[-1].minor.yy402->a[0].pExpr;
- yymsp[-1].minor.yy402->a[0].pExpr = 0;
- sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy402);
+ Expr *pRHS = yymsp[-1].minor.yy232->a[0].pExpr;
+ yymsp[-1].minor.yy232->a[0].pExpr = 0;
+ sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy232);
/* pRHS cannot be NULL because a malloc error would have been detected
** before now and control would have never reached this point */
if( ALWAYS(pRHS) ){
pRHS->flags &= ~EP_Collate;
pRHS->flags |= EP_Generic;
}
- yymsp[-4].minor.yy2 = sqlite3PExpr(pParse, yymsp[-3].minor.yy348 ? TK_NE : TK_EQ, yymsp[-4].minor.yy2, pRHS);
+ yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, yymsp[-3].minor.yy502 ? TK_NE : TK_EQ, yymsp[-4].minor.yy182, pRHS);
}else{
- yymsp[-4].minor.yy2 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy2, 0);
- if( yymsp[-4].minor.yy2 ){
- yymsp[-4].minor.yy2->x.pList = yymsp[-1].minor.yy402;
- sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy2);
+ yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy182, 0);
+ if( yymsp[-4].minor.yy182 ){
+ yymsp[-4].minor.yy182->x.pList = yymsp[-1].minor.yy232;
+ sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy182);
}else{
- sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy402);
+ sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy232);
}
- if( yymsp[-3].minor.yy348 ) yymsp[-4].minor.yy2 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy2, 0);
+ if( yymsp[-3].minor.yy502 ) yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy182, 0);
}
}
break;
- case 200: /* expr ::= LP select RP */
+ case 198: /* expr ::= LP select RP */
{
- yymsp[-2].minor.yy2 = sqlite3PExpr(pParse, TK_SELECT, 0, 0);
- sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy2, yymsp[-1].minor.yy43);
+ yymsp[-2].minor.yy182 = sqlite3PExpr(pParse, TK_SELECT, 0, 0);
+ sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy182, yymsp[-1].minor.yy399);
}
break;
- case 201: /* expr ::= expr in_op LP select RP */
+ case 199: /* expr ::= expr in_op LP select RP */
{
- yymsp[-4].minor.yy2 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy2, 0);
- sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy2, yymsp[-1].minor.yy43);
- if( yymsp[-3].minor.yy348 ) yymsp[-4].minor.yy2 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy2, 0);
+ yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy182, 0);
+ sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy182, yymsp[-1].minor.yy399);
+ if( yymsp[-3].minor.yy502 ) yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy182, 0);
}
break;
- case 202: /* expr ::= expr in_op nm dbnm paren_exprlist */
+ case 200: /* expr ::= expr in_op nm dbnm paren_exprlist */
{
SrcList *pSrc = sqlite3SrcListAppend(pParse->db, 0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);
Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0);
- if( yymsp[0].minor.yy402 ) sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy402);
- yymsp[-4].minor.yy2 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy2, 0);
- sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy2, pSelect);
- if( yymsp[-3].minor.yy348 ) yymsp[-4].minor.yy2 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy2, 0);
+ if( yymsp[0].minor.yy232 ) sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy232);
+ yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy182, 0);
+ sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy182, pSelect);
+ if( yymsp[-3].minor.yy502 ) yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy182, 0);
}
break;
- case 203: /* expr ::= EXISTS LP select RP */
+ case 201: /* expr ::= EXISTS LP select RP */
{
Expr *p;
- p = yymsp[-3].minor.yy2 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0);
- sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy43);
+ p = yymsp[-3].minor.yy182 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0);
+ sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy399);
}
break;
- case 204: /* expr ::= CASE case_operand case_exprlist case_else END */
+ case 202: /* expr ::= CASE case_operand case_exprlist case_else END */
{
- yymsp[-4].minor.yy2 = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy2, 0);
- if( yymsp[-4].minor.yy2 ){
- yymsp[-4].minor.yy2->x.pList = yymsp[-1].minor.yy2 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy402,yymsp[-1].minor.yy2) : yymsp[-2].minor.yy402;
- sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy2);
+ yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy182, 0);
+ if( yymsp[-4].minor.yy182 ){
+ yymsp[-4].minor.yy182->x.pList = yymsp[-1].minor.yy182 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy232,yymsp[-1].minor.yy182) : yymsp[-2].minor.yy232;
+ sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy182);
}else{
- sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy402);
- sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy2);
+ sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy232);
+ sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy182);
}
}
break;
- case 205: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
+ case 203: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
{
- yymsp[-4].minor.yy402 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy402, yymsp[-2].minor.yy2);
- yymsp[-4].minor.yy402 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy402, yymsp[0].minor.yy2);
+ yymsp[-4].minor.yy232 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy232, yymsp[-2].minor.yy182);
+ yymsp[-4].minor.yy232 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy232, yymsp[0].minor.yy182);
}
break;
- case 206: /* case_exprlist ::= WHEN expr THEN expr */
+ case 204: /* case_exprlist ::= WHEN expr THEN expr */
{
- yymsp[-3].minor.yy402 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy2);
- yymsp[-3].minor.yy402 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy402, yymsp[0].minor.yy2);
+ yymsp[-3].minor.yy232 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy182);
+ yymsp[-3].minor.yy232 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy232, yymsp[0].minor.yy182);
}
break;
- case 209: /* case_operand ::= expr */
-{yymsp[0].minor.yy2 = yymsp[0].minor.yy2; /*A-overwrites-X*/}
+ case 207: /* case_operand ::= expr */
+{yymsp[0].minor.yy182 = yymsp[0].minor.yy182; /*A-overwrites-X*/}
break;
- case 212: /* nexprlist ::= nexprlist COMMA expr */
-{yymsp[-2].minor.yy402 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy402,yymsp[0].minor.yy2);}
+ case 210: /* nexprlist ::= nexprlist COMMA expr */
+{yymsp[-2].minor.yy232 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy232,yymsp[0].minor.yy182);}
break;
- case 213: /* nexprlist ::= expr */
-{yymsp[0].minor.yy402 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy2); /*A-overwrites-Y*/}
+ case 211: /* nexprlist ::= expr */
+{yymsp[0].minor.yy232 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy182); /*A-overwrites-Y*/}
break;
- case 215: /* paren_exprlist ::= LP exprlist RP */
- case 220: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==220);
-{yymsp[-2].minor.yy402 = yymsp[-1].minor.yy402;}
+ case 213: /* paren_exprlist ::= LP exprlist RP */
+ case 218: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==218);
+{yymsp[-2].minor.yy232 = yymsp[-1].minor.yy232;}
break;
- case 216: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
+ case 214: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
{
sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0,
- sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy402, yymsp[-10].minor.yy348,
- &yymsp[-11].minor.yy0, yymsp[0].minor.yy2, SQLITE_SO_ASC, yymsp[-8].minor.yy348, SQLITE_IDXTYPE_APPDEF);
+ sqlite3SrcListAppend(pParse->db,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy232, yymsp[-10].minor.yy502,
+ &yymsp[-11].minor.yy0, yymsp[0].minor.yy182, SQLITE_SO_ASC, yymsp[-8].minor.yy502, SQLITE_IDXTYPE_APPDEF);
if( IN_RENAME_OBJECT && pParse->pNewIndex ){
sqlite3RenameTokenMap(pParse, pParse->pNewIndex->zName, &yymsp[-4].minor.yy0);
}
}
break;
- case 217: /* uniqueflag ::= UNIQUE */
- case 257: /* raisetype ::= ABORT */ yytestcase(yyruleno==257);
-{yymsp[0].minor.yy348 = OE_Abort;}
+ case 215: /* uniqueflag ::= UNIQUE */
+ case 255: /* raisetype ::= ABORT */ yytestcase(yyruleno==255);
+{yymsp[0].minor.yy502 = OE_Abort;}
break;
- case 218: /* uniqueflag ::= */
-{yymsp[1].minor.yy348 = OE_None;}
+ case 216: /* uniqueflag ::= */
+{yymsp[1].minor.yy502 = OE_None;}
break;
- case 221: /* eidlist ::= eidlist COMMA nm collate sortorder */
+ case 219: /* eidlist ::= eidlist COMMA nm collate sortorder */
{
- yymsp[-4].minor.yy402 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy402, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy348, yymsp[0].minor.yy348);
+ yymsp[-4].minor.yy232 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy232, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy502, yymsp[0].minor.yy502);
}
break;
- case 222: /* eidlist ::= nm collate sortorder */
+ case 220: /* eidlist ::= nm collate sortorder */
{
- yymsp[-2].minor.yy402 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy348, yymsp[0].minor.yy348); /*A-overwrites-Y*/
+ yymsp[-2].minor.yy232 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy502, yymsp[0].minor.yy502); /*A-overwrites-Y*/
}
break;
- case 225: /* cmd ::= DROP INDEX ifexists fullname */
-{sqlite3DropIndex(pParse, yymsp[0].minor.yy3, yymsp[-1].minor.yy348);}
+ case 223: /* cmd ::= DROP INDEX ifexists fullname */
+{sqlite3DropIndex(pParse, yymsp[0].minor.yy427, yymsp[-1].minor.yy502);}
break;
- case 226: /* cmd ::= VACUUM */
+ case 224: /* cmd ::= VACUUM */
{sqlite3Vacuum(pParse,0);}
break;
- case 227: /* cmd ::= VACUUM nm */
+ case 225: /* cmd ::= VACUUM nm */
{sqlite3Vacuum(pParse,&yymsp[0].minor.yy0);}
break;
- case 228: /* cmd ::= PRAGMA nm dbnm */
+ case 226: /* cmd ::= PRAGMA nm dbnm */
{sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);}
break;
- case 229: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
+ case 227: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
{sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);}
break;
- case 230: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
+ case 228: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
{sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);}
break;
- case 231: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
+ case 229: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
{sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);}
break;
- case 232: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */
+ case 230: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */
{sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);}
break;
- case 235: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
+ case 233: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
{
Token all;
all.z = yymsp[-3].minor.yy0.z;
all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n;
- sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy347, &all);
+ sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy47, &all);
}
break;
- case 236: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
+ case 234: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
{
- sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy348, yymsp[-4].minor.yy338.a, yymsp[-4].minor.yy338.b, yymsp[-2].minor.yy3, yymsp[0].minor.yy2, yymsp[-10].minor.yy348, yymsp[-8].minor.yy348);
+ sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy502, yymsp[-4].minor.yy300.a, yymsp[-4].minor.yy300.b, yymsp[-2].minor.yy427, yymsp[0].minor.yy182, yymsp[-10].minor.yy502, yymsp[-8].minor.yy502);
yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/
}
break;
- case 237: /* trigger_time ::= BEFORE|AFTER */
-{ yymsp[0].minor.yy348 = yymsp[0].major; /*A-overwrites-X*/ }
+ case 235: /* trigger_time ::= BEFORE|AFTER */
+{ yymsp[0].minor.yy502 = yymsp[0].major; /*A-overwrites-X*/ }
break;
- case 238: /* trigger_time ::= INSTEAD OF */
-{ yymsp[-1].minor.yy348 = TK_INSTEAD;}
+ case 236: /* trigger_time ::= INSTEAD OF */
+{ yymsp[-1].minor.yy502 = TK_INSTEAD;}
break;
- case 239: /* trigger_time ::= */
-{ yymsp[1].minor.yy348 = TK_BEFORE; }
+ case 237: /* trigger_time ::= */
+{ yymsp[1].minor.yy502 = TK_BEFORE; }
break;
- case 240: /* trigger_event ::= DELETE|INSERT */
- case 241: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==241);
-{yymsp[0].minor.yy338.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy338.b = 0;}
+ case 238: /* trigger_event ::= DELETE|INSERT */
+ case 239: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==239);
+{yymsp[0].minor.yy300.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy300.b = 0;}
break;
- case 242: /* trigger_event ::= UPDATE OF idlist */
-{yymsp[-2].minor.yy338.a = TK_UPDATE; yymsp[-2].minor.yy338.b = yymsp[0].minor.yy272;}
+ case 240: /* trigger_event ::= UPDATE OF idlist */
+{yymsp[-2].minor.yy300.a = TK_UPDATE; yymsp[-2].minor.yy300.b = yymsp[0].minor.yy510;}
break;
- case 243: /* when_clause ::= */
- case 262: /* key_opt ::= */ yytestcase(yyruleno==262);
-{ yymsp[1].minor.yy2 = 0; }
+ case 241: /* when_clause ::= */
+ case 260: /* key_opt ::= */ yytestcase(yyruleno==260);
+{ yymsp[1].minor.yy182 = 0; }
break;
- case 244: /* when_clause ::= WHEN expr */
- case 263: /* key_opt ::= KEY expr */ yytestcase(yyruleno==263);
-{ yymsp[-1].minor.yy2 = yymsp[0].minor.yy2; }
+ case 242: /* when_clause ::= WHEN expr */
+ case 261: /* key_opt ::= KEY expr */ yytestcase(yyruleno==261);
+{ yymsp[-1].minor.yy182 = yymsp[0].minor.yy182; }
break;
- case 245: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
+ case 243: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
{
- assert( yymsp[-2].minor.yy347!=0 );
- yymsp[-2].minor.yy347->pLast->pNext = yymsp[-1].minor.yy347;
- yymsp[-2].minor.yy347->pLast = yymsp[-1].minor.yy347;
+ assert( yymsp[-2].minor.yy47!=0 );
+ yymsp[-2].minor.yy47->pLast->pNext = yymsp[-1].minor.yy47;
+ yymsp[-2].minor.yy47->pLast = yymsp[-1].minor.yy47;
}
break;
- case 246: /* trigger_cmd_list ::= trigger_cmd SEMI */
+ case 244: /* trigger_cmd_list ::= trigger_cmd SEMI */
{
- assert( yymsp[-1].minor.yy347!=0 );
- yymsp[-1].minor.yy347->pLast = yymsp[-1].minor.yy347;
+ assert( yymsp[-1].minor.yy47!=0 );
+ yymsp[-1].minor.yy47->pLast = yymsp[-1].minor.yy47;
}
break;
- case 247: /* trnm ::= nm DOT nm */
+ case 245: /* trnm ::= nm DOT nm */
{
yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;
sqlite3ErrorMsg(pParse,
@@ -150604,201 +150527,188 @@ static YYACTIONTYPE yy_reduce(
"statements within triggers");
}
break;
- case 248: /* tridxby ::= INDEXED BY nm */
+ case 246: /* tridxby ::= INDEXED BY nm */
{
sqlite3ErrorMsg(pParse,
"the INDEXED BY clause is not allowed on UPDATE or DELETE statements "
"within triggers");
}
break;
- case 249: /* tridxby ::= NOT INDEXED */
+ case 247: /* tridxby ::= NOT INDEXED */
{
sqlite3ErrorMsg(pParse,
"the NOT INDEXED clause is not allowed on UPDATE or DELETE statements "
"within triggers");
}
break;
- case 250: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */
-{yylhsminor.yy347 = sqlite3TriggerUpdateStep(pParse, &yymsp[-5].minor.yy0, yymsp[-2].minor.yy402, yymsp[-1].minor.yy2, yymsp[-6].minor.yy348, yymsp[-7].minor.yy0.z, yymsp[0].minor.yy360);}
- yymsp[-7].minor.yy347 = yylhsminor.yy347;
+ case 248: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */
+{yylhsminor.yy47 = sqlite3TriggerUpdateStep(pParse, &yymsp[-5].minor.yy0, yymsp[-2].minor.yy232, yymsp[-1].minor.yy182, yymsp[-6].minor.yy502, yymsp[-7].minor.yy0.z, yymsp[0].minor.yy36);}
+ yymsp[-7].minor.yy47 = yylhsminor.yy47;
break;
- case 251: /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
+ case 249: /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
{
- yylhsminor.yy347 = sqlite3TriggerInsertStep(pParse,&yymsp[-4].minor.yy0,yymsp[-3].minor.yy272,yymsp[-2].minor.yy43,yymsp[-6].minor.yy348,yymsp[-1].minor.yy258,yymsp[-7].minor.yy360,yymsp[0].minor.yy360);/*yylhsminor.yy347-overwrites-yymsp[-6].minor.yy348*/
+ yylhsminor.yy47 = sqlite3TriggerInsertStep(pParse,&yymsp[-4].minor.yy0,yymsp[-3].minor.yy510,yymsp[-2].minor.yy399,yymsp[-6].minor.yy502,yymsp[-1].minor.yy198,yymsp[-7].minor.yy36,yymsp[0].minor.yy36);/*yylhsminor.yy47-overwrites-yymsp[-6].minor.yy502*/
}
- yymsp[-7].minor.yy347 = yylhsminor.yy347;
+ yymsp[-7].minor.yy47 = yylhsminor.yy47;
break;
- case 252: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
-{yylhsminor.yy347 = sqlite3TriggerDeleteStep(pParse, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy2, yymsp[-5].minor.yy0.z, yymsp[0].minor.yy360);}
- yymsp[-5].minor.yy347 = yylhsminor.yy347;
+ case 250: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
+{yylhsminor.yy47 = sqlite3TriggerDeleteStep(pParse, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy182, yymsp[-5].minor.yy0.z, yymsp[0].minor.yy36);}
+ yymsp[-5].minor.yy47 = yylhsminor.yy47;
break;
- case 253: /* trigger_cmd ::= scanpt select scanpt */
-{yylhsminor.yy347 = sqlite3TriggerSelectStep(pParse->db, yymsp[-1].minor.yy43, yymsp[-2].minor.yy360, yymsp[0].minor.yy360); /*yylhsminor.yy347-overwrites-yymsp[-1].minor.yy43*/}
- yymsp[-2].minor.yy347 = yylhsminor.yy347;
+ case 251: /* trigger_cmd ::= scanpt select scanpt */
+{yylhsminor.yy47 = sqlite3TriggerSelectStep(pParse->db, yymsp[-1].minor.yy399, yymsp[-2].minor.yy36, yymsp[0].minor.yy36); /*yylhsminor.yy47-overwrites-yymsp[-1].minor.yy399*/}
+ yymsp[-2].minor.yy47 = yylhsminor.yy47;
break;
- case 254: /* expr ::= RAISE LP IGNORE RP */
+ case 252: /* expr ::= RAISE LP IGNORE RP */
{
- yymsp[-3].minor.yy2 = sqlite3PExpr(pParse, TK_RAISE, 0, 0);
- if( yymsp[-3].minor.yy2 ){
- yymsp[-3].minor.yy2->affinity = OE_Ignore;
+ yymsp[-3].minor.yy182 = sqlite3PExpr(pParse, TK_RAISE, 0, 0);
+ if( yymsp[-3].minor.yy182 ){
+ yymsp[-3].minor.yy182->affinity = OE_Ignore;
}
}
break;
- case 255: /* expr ::= RAISE LP raisetype COMMA nm RP */
+ case 253: /* expr ::= RAISE LP raisetype COMMA nm RP */
{
- yymsp[-5].minor.yy2 = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1);
- if( yymsp[-5].minor.yy2 ) {
- yymsp[-5].minor.yy2->affinity = (char)yymsp[-3].minor.yy348;
+ yymsp[-5].minor.yy182 = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1);
+ if( yymsp[-5].minor.yy182 ) {
+ yymsp[-5].minor.yy182->affinity = (char)yymsp[-3].minor.yy502;
}
}
break;
- case 256: /* raisetype ::= ROLLBACK */
-{yymsp[0].minor.yy348 = OE_Rollback;}
+ case 254: /* raisetype ::= ROLLBACK */
+{yymsp[0].minor.yy502 = OE_Rollback;}
break;
- case 258: /* raisetype ::= FAIL */
-{yymsp[0].minor.yy348 = OE_Fail;}
+ case 256: /* raisetype ::= FAIL */
+{yymsp[0].minor.yy502 = OE_Fail;}
break;
- case 259: /* cmd ::= DROP TRIGGER ifexists fullname */
+ case 257: /* cmd ::= DROP TRIGGER ifexists fullname */
{
- sqlite3DropTrigger(pParse,yymsp[0].minor.yy3,yymsp[-1].minor.yy348);
+ sqlite3DropTrigger(pParse,yymsp[0].minor.yy427,yymsp[-1].minor.yy502);
}
break;
- case 260: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
+ case 258: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
{
- sqlite3Attach(pParse, yymsp[-3].minor.yy2, yymsp[-1].minor.yy2, yymsp[0].minor.yy2);
+ sqlite3Attach(pParse, yymsp[-3].minor.yy182, yymsp[-1].minor.yy182, yymsp[0].minor.yy182);
}
break;
- case 261: /* cmd ::= DETACH database_kw_opt expr */
+ case 259: /* cmd ::= DETACH database_kw_opt expr */
{
- sqlite3Detach(pParse, yymsp[0].minor.yy2);
+ sqlite3Detach(pParse, yymsp[0].minor.yy182);
}
break;
- case 264: /* cmd ::= REINDEX */
-{sqlite3Reindex(pParse, 0, 0);}
- break;
- case 265: /* cmd ::= REINDEX nm dbnm */
-{sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
- break;
- case 266: /* cmd ::= ANALYZE */
-{sqlite3Analyze(pParse, 0, 0);}
- break;
- case 267: /* cmd ::= ANALYZE nm dbnm */
-{sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
- break;
- case 268: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
+ case 262: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
{
- sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy3,&yymsp[0].minor.yy0);
+ sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy427,&yymsp[0].minor.yy0);
}
break;
- case 269: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
+ case 263: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
{
yymsp[-1].minor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-1].minor.yy0.z) + pParse->sLastToken.n;
sqlite3AlterFinishAddColumn(pParse, &yymsp[-1].minor.yy0);
}
break;
- case 270: /* add_column_fullname ::= fullname */
+ case 264: /* add_column_fullname ::= fullname */
{
disableLookaside(pParse);
- sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy3);
+ sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy427);
}
break;
- case 271: /* cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
+ case 265: /* cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
{
- sqlite3AlterRenameColumn(pParse, yymsp[-5].minor.yy3, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);
+ sqlite3AlterRenameColumn(pParse, yymsp[-5].minor.yy427, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);
}
break;
- case 272: /* cmd ::= create_vtab */
+ case 266: /* cmd ::= create_vtab */
{sqlite3VtabFinishParse(pParse,0);}
break;
- case 273: /* cmd ::= create_vtab LP vtabarglist RP */
+ case 267: /* cmd ::= create_vtab LP vtabarglist RP */
{sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}
break;
- case 274: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
+ case 268: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
{
- sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy348);
+ sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy502);
}
break;
- case 275: /* vtabarg ::= */
+ case 269: /* vtabarg ::= */
{sqlite3VtabArgInit(pParse);}
break;
- case 276: /* vtabargtoken ::= ANY */
- case 277: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==277);
- case 278: /* lp ::= LP */ yytestcase(yyruleno==278);
+ case 270: /* vtabargtoken ::= ANY */
+ case 271: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==271);
+ case 272: /* lp ::= LP */ yytestcase(yyruleno==272);
{sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}
break;
- case 279: /* with ::= WITH wqlist */
- case 280: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==280);
-{ sqlite3WithPush(pParse, yymsp[0].minor.yy4, 1); }
+ case 273: /* with ::= WITH wqlist */
+ case 274: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==274);
+{ sqlite3WithPush(pParse, yymsp[0].minor.yy91, 1); }
break;
- case 281: /* wqlist ::= nm eidlist_opt AS LP select RP */
+ case 275: /* wqlist ::= nm eidlist_opt AS LP select RP */
{
- yymsp[-5].minor.yy4 = sqlite3WithAdd(pParse, 0, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy402, yymsp[-1].minor.yy43); /*A-overwrites-X*/
+ yymsp[-5].minor.yy91 = sqlite3WithAdd(pParse, 0, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy232, yymsp[-1].minor.yy399); /*A-overwrites-X*/
}
break;
- case 282: /* wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
+ case 276: /* wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
{
- yymsp[-7].minor.yy4 = sqlite3WithAdd(pParse, yymsp[-7].minor.yy4, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy402, yymsp[-1].minor.yy43);
+ yymsp[-7].minor.yy91 = sqlite3WithAdd(pParse, yymsp[-7].minor.yy91, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy232, yymsp[-1].minor.yy399);
}
break;
default:
- /* (283) input ::= cmdlist */ yytestcase(yyruleno==283);
- /* (284) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==284);
- /* (285) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=285);
- /* (286) ecmd ::= SEMI */ yytestcase(yyruleno==286);
- /* (287) ecmd ::= cmdx SEMI */ yytestcase(yyruleno==287);
- /* (288) ecmd ::= explain cmdx */ yytestcase(yyruleno==288);
- /* (289) trans_opt ::= */ yytestcase(yyruleno==289);
- /* (290) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==290);
- /* (291) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==291);
- /* (292) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==292);
- /* (293) savepoint_opt ::= */ yytestcase(yyruleno==293);
- /* (294) cmd ::= create_table create_table_args */ yytestcase(yyruleno==294);
- /* (295) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==295);
- /* (296) columnlist ::= columnname carglist */ yytestcase(yyruleno==296);
- /* (297) nm ::= ID|INDEXED */ yytestcase(yyruleno==297);
- /* (298) nm ::= STRING */ yytestcase(yyruleno==298);
- /* (299) nm ::= JOIN_KW */ yytestcase(yyruleno==299);
- /* (300) typetoken ::= typename */ yytestcase(yyruleno==300);
- /* (301) typename ::= ID|STRING */ yytestcase(yyruleno==301);
- /* (302) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=302);
- /* (303) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=303);
- /* (304) carglist ::= carglist ccons */ yytestcase(yyruleno==304);
- /* (305) carglist ::= */ yytestcase(yyruleno==305);
- /* (306) ccons ::= NULL onconf */ yytestcase(yyruleno==306);
- /* (307) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==307);
- /* (308) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==308);
- /* (309) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=309);
- /* (310) tconscomma ::= */ yytestcase(yyruleno==310);
- /* (311) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=311);
- /* (312) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=312);
- /* (313) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=313);
- /* (314) oneselect ::= values */ yytestcase(yyruleno==314);
- /* (315) sclp ::= selcollist COMMA */ yytestcase(yyruleno==315);
- /* (316) as ::= ID|STRING */ yytestcase(yyruleno==316);
- /* (317) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=317);
- /* (318) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==318);
- /* (319) exprlist ::= nexprlist */ yytestcase(yyruleno==319);
- /* (320) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=320);
- /* (321) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=321);
- /* (322) nmnum ::= ON */ yytestcase(yyruleno==322);
- /* (323) nmnum ::= DELETE */ yytestcase(yyruleno==323);
- /* (324) nmnum ::= DEFAULT */ yytestcase(yyruleno==324);
- /* (325) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==325);
- /* (326) foreach_clause ::= */ yytestcase(yyruleno==326);
- /* (327) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==327);
- /* (328) trnm ::= nm */ yytestcase(yyruleno==328);
- /* (329) tridxby ::= */ yytestcase(yyruleno==329);
- /* (330) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==330);
- /* (331) database_kw_opt ::= */ yytestcase(yyruleno==331);
- /* (332) kwcolumn_opt ::= */ yytestcase(yyruleno==332);
- /* (333) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==333);
- /* (334) vtabarglist ::= vtabarg */ yytestcase(yyruleno==334);
- /* (335) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==335);
- /* (336) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==336);
- /* (337) anylist ::= */ yytestcase(yyruleno==337);
- /* (338) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==338);
- /* (339) anylist ::= anylist ANY */ yytestcase(yyruleno==339);
- /* (340) with ::= */ yytestcase(yyruleno==340);
+ /* (277) input ::= cmdlist */ yytestcase(yyruleno==277);
+ /* (278) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==278);
+ /* (279) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=279);
+ /* (280) ecmd ::= SEMI */ yytestcase(yyruleno==280);
+ /* (281) ecmd ::= cmdx SEMI */ yytestcase(yyruleno==281);
+ /* (282) trans_opt ::= */ yytestcase(yyruleno==282);
+ /* (283) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==283);
+ /* (284) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==284);
+ /* (285) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==285);
+ /* (286) savepoint_opt ::= */ yytestcase(yyruleno==286);
+ /* (287) cmd ::= create_table create_table_args */ yytestcase(yyruleno==287);
+ /* (288) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==288);
+ /* (289) columnlist ::= columnname carglist */ yytestcase(yyruleno==289);
+ /* (290) nm ::= ID|INDEXED */ yytestcase(yyruleno==290);
+ /* (291) nm ::= STRING */ yytestcase(yyruleno==291);
+ /* (292) nm ::= JOIN_KW */ yytestcase(yyruleno==292);
+ /* (293) typetoken ::= typename */ yytestcase(yyruleno==293);
+ /* (294) typename ::= ID|STRING */ yytestcase(yyruleno==294);
+ /* (295) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=295);
+ /* (296) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=296);
+ /* (297) carglist ::= carglist ccons */ yytestcase(yyruleno==297);
+ /* (298) carglist ::= */ yytestcase(yyruleno==298);
+ /* (299) ccons ::= NULL onconf */ yytestcase(yyruleno==299);
+ /* (300) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==300);
+ /* (301) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==301);
+ /* (302) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=302);
+ /* (303) tconscomma ::= */ yytestcase(yyruleno==303);
+ /* (304) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=304);
+ /* (305) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=305);
+ /* (306) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=306);
+ /* (307) oneselect ::= values */ yytestcase(yyruleno==307);
+ /* (308) sclp ::= selcollist COMMA */ yytestcase(yyruleno==308);
+ /* (309) as ::= ID|STRING */ yytestcase(yyruleno==309);
+ /* (310) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=310);
+ /* (311) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==311);
+ /* (312) exprlist ::= nexprlist */ yytestcase(yyruleno==312);
+ /* (313) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=313);
+ /* (314) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=314);
+ /* (315) nmnum ::= ON */ yytestcase(yyruleno==315);
+ /* (316) nmnum ::= DELETE */ yytestcase(yyruleno==316);
+ /* (317) nmnum ::= DEFAULT */ yytestcase(yyruleno==317);
+ /* (318) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==318);
+ /* (319) foreach_clause ::= */ yytestcase(yyruleno==319);
+ /* (320) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==320);
+ /* (321) trnm ::= nm */ yytestcase(yyruleno==321);
+ /* (322) tridxby ::= */ yytestcase(yyruleno==322);
+ /* (323) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==323);
+ /* (324) database_kw_opt ::= */ yytestcase(yyruleno==324);
+ /* (325) kwcolumn_opt ::= */ yytestcase(yyruleno==325);
+ /* (326) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==326);
+ /* (327) vtabarglist ::= vtabarg */ yytestcase(yyruleno==327);
+ /* (328) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==328);
+ /* (329) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==329);
+ /* (330) anylist ::= */ yytestcase(yyruleno==330);
+ /* (331) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==331);
+ /* (332) anylist ::= anylist ANY */ yytestcase(yyruleno==332);
+ /* (333) with ::= */ yytestcase(yyruleno==333);
break;
/********** End reduce actions ************************************************/
};
@@ -151261,132 +151171,130 @@ const unsigned char ebcdicToAscii[] = {
** is substantially reduced. This is important for embedded applications
** on platforms with limited memory.
*/
-/* Hash score: 183 */
-/* zKWText[] encodes 839 bytes of keyword text in 555 bytes */
-/* REINDEXEDESCAPEACHECKEYBEFOREIGNOREGEXPLAINSTEADDATABASELECT */
-/* ABLEFTHENDEFERRABLELSEXCEPTRANSACTIONATURALTERAISEXCLUSIVE */
-/* XISTSAVEPOINTERSECTRIGGEREFERENCESCONSTRAINTOFFSETEMPORARY */
-/* UNIQUERYWITHOUTERELEASEATTACHAVINGROUPDATEBEGINNERECURSIVE */
-/* BETWEENOTNULLIKECASCADELETECASECOLLATECREATECURRENT_DATEDETACH */
-/* IMMEDIATEJOINSERTMATCHPLANALYZEPRAGMABORTVALUESVIRTUALIMITWHEN */
-/* WHERENAMEAFTEREPLACEANDEFAULTAUTOINCREMENTCASTCOLUMNCOMMIT */
-/* CONFLICTCROSSCURRENT_TIMESTAMPRIMARYDEFERREDISTINCTDROPFAIL */
-/* FROMFULLGLOBYIFISNULLORDERESTRICTRIGHTROLLBACKROWSUNIONUSING */
-/* VACUUMVIEWINITIALLY */
-static const char zKWText[554] = {
- 'R','E','I','N','D','E','X','E','D','E','S','C','A','P','E','A','C','H',
- 'E','C','K','E','Y','B','E','F','O','R','E','I','G','N','O','R','E','G',
- 'E','X','P','L','A','I','N','S','T','E','A','D','D','A','T','A','B','A',
- 'S','E','L','E','C','T','A','B','L','E','F','T','H','E','N','D','E','F',
- 'E','R','R','A','B','L','E','L','S','E','X','C','E','P','T','R','A','N',
- 'S','A','C','T','I','O','N','A','T','U','R','A','L','T','E','R','A','I',
- 'S','E','X','C','L','U','S','I','V','E','X','I','S','T','S','A','V','E',
- 'P','O','I','N','T','E','R','S','E','C','T','R','I','G','G','E','R','E',
- 'F','E','R','E','N','C','E','S','C','O','N','S','T','R','A','I','N','T',
- 'O','F','F','S','E','T','E','M','P','O','R','A','R','Y','U','N','I','Q',
- 'U','E','R','Y','W','I','T','H','O','U','T','E','R','E','L','E','A','S',
- 'E','A','T','T','A','C','H','A','V','I','N','G','R','O','U','P','D','A',
- 'T','E','B','E','G','I','N','N','E','R','E','C','U','R','S','I','V','E',
- 'B','E','T','W','E','E','N','O','T','N','U','L','L','I','K','E','C','A',
- 'S','C','A','D','E','L','E','T','E','C','A','S','E','C','O','L','L','A',
- 'T','E','C','R','E','A','T','E','C','U','R','R','E','N','T','_','D','A',
- 'T','E','D','E','T','A','C','H','I','M','M','E','D','I','A','T','E','J',
- 'O','I','N','S','E','R','T','M','A','T','C','H','P','L','A','N','A','L',
- 'Y','Z','E','P','R','A','G','M','A','B','O','R','T','V','A','L','U','E',
- 'S','V','I','R','T','U','A','L','I','M','I','T','W','H','E','N','W','H',
- 'E','R','E','N','A','M','E','A','F','T','E','R','E','P','L','A','C','E',
- 'A','N','D','E','F','A','U','L','T','A','U','T','O','I','N','C','R','E',
- 'M','E','N','T','C','A','S','T','C','O','L','U','M','N','C','O','M','M',
- 'I','T','C','O','N','F','L','I','C','T','C','R','O','S','S','C','U','R',
- 'R','E','N','T','_','T','I','M','E','S','T','A','M','P','R','I','M','A',
- 'R','Y','D','E','F','E','R','R','E','D','I','S','T','I','N','C','T','D',
- 'R','O','P','F','A','I','L','F','R','O','M','F','U','L','L','G','L','O',
- 'B','Y','I','F','I','S','N','U','L','L','O','R','D','E','R','E','S','T',
- 'R','I','C','T','R','I','G','H','T','R','O','L','L','B','A','C','K','R',
- 'O','W','S','U','N','I','O','N','U','S','I','N','G','V','A','C','U','U',
- 'M','V','I','E','W','I','N','I','T','I','A','L','L','Y',
+/* Hash score: 176 */
+/* zKWText[] encodes 804 bytes of keyword text in 540 bytes */
+/* BEFOREIGNOREFERENCESCAPEACHECKEYCONSTRAINTERSECTABLEFTHENDESC */
+/* ASCADEFERRABLELSELECTRANSACTIONATURALTERAISEXCEPTRIGGERELEASE */
+/* XCLUSIVEXISTSAVEPOINTOFFSETEMPORARYWITHOUTERECURSIVEATTACH */
+/* AVINGROUPDATEBEGINSTEADDATABASEBETWEENOTNULLIKECASECOLLATE */
+/* CREATECURRENT_DATEDELETEDETACHIMMEDIATEJOINDEXEDEFAULTMATCH */
+/* PRAGMABORTVALUESVIRTUALIMITWHENWHEREGEXPRIMARYAFTERENAMEAND */
+/* EFERREDISTINCTAUTOINCREMENTCASTCOLUMNCOMMITCONFLICTCROSS */
+/* CURRENT_TIMESTAMPDROPFAILFROMFULLGLOBYIFINNEREPLACEINSERT */
+/* ISNULLORDERESTRICTRIGHTROLLBACKROWSUNIONUNIQUEUSINGVACUUMVIEW */
+/* INITIALLY */
+static const char zKWText[539] = {
+ 'B','E','F','O','R','E','I','G','N','O','R','E','F','E','R','E','N','C',
+ 'E','S','C','A','P','E','A','C','H','E','C','K','E','Y','C','O','N','S',
+ 'T','R','A','I','N','T','E','R','S','E','C','T','A','B','L','E','F','T',
+ 'H','E','N','D','E','S','C','A','S','C','A','D','E','F','E','R','R','A',
+ 'B','L','E','L','S','E','L','E','C','T','R','A','N','S','A','C','T','I',
+ 'O','N','A','T','U','R','A','L','T','E','R','A','I','S','E','X','C','E',
+ 'P','T','R','I','G','G','E','R','E','L','E','A','S','E','X','C','L','U',
+ 'S','I','V','E','X','I','S','T','S','A','V','E','P','O','I','N','T','O',
+ 'F','F','S','E','T','E','M','P','O','R','A','R','Y','W','I','T','H','O',
+ 'U','T','E','R','E','C','U','R','S','I','V','E','A','T','T','A','C','H',
+ 'A','V','I','N','G','R','O','U','P','D','A','T','E','B','E','G','I','N',
+ 'S','T','E','A','D','D','A','T','A','B','A','S','E','B','E','T','W','E',
+ 'E','N','O','T','N','U','L','L','I','K','E','C','A','S','E','C','O','L',
+ 'L','A','T','E','C','R','E','A','T','E','C','U','R','R','E','N','T','_',
+ 'D','A','T','E','D','E','L','E','T','E','D','E','T','A','C','H','I','M',
+ 'M','E','D','I','A','T','E','J','O','I','N','D','E','X','E','D','E','F',
+ 'A','U','L','T','M','A','T','C','H','P','R','A','G','M','A','B','O','R',
+ 'T','V','A','L','U','E','S','V','I','R','T','U','A','L','I','M','I','T',
+ 'W','H','E','N','W','H','E','R','E','G','E','X','P','R','I','M','A','R',
+ 'Y','A','F','T','E','R','E','N','A','M','E','A','N','D','E','F','E','R',
+ 'R','E','D','I','S','T','I','N','C','T','A','U','T','O','I','N','C','R',
+ 'E','M','E','N','T','C','A','S','T','C','O','L','U','M','N','C','O','M',
+ 'M','I','T','C','O','N','F','L','I','C','T','C','R','O','S','S','C','U',
+ 'R','R','E','N','T','_','T','I','M','E','S','T','A','M','P','D','R','O',
+ 'P','F','A','I','L','F','R','O','M','F','U','L','L','G','L','O','B','Y',
+ 'I','F','I','N','N','E','R','E','P','L','A','C','E','I','N','S','E','R',
+ 'T','I','S','N','U','L','L','O','R','D','E','R','E','S','T','R','I','C',
+ 'T','R','I','G','H','T','R','O','L','L','B','A','C','K','R','O','W','S',
+ 'U','N','I','O','N','U','N','I','Q','U','E','U','S','I','N','G','V','A',
+ 'C','U','U','M','V','I','E','W','I','N','I','T','I','A','L','L','Y',
};
/* aKWHash[i] is the hash value for the i-th keyword */
static const unsigned char aKWHash[127] = {
- 76, 105, 117, 74, 0, 45, 0, 0, 82, 0, 77, 0, 0,
- 42, 12, 78, 15, 0, 116, 85, 54, 112, 118, 19, 0, 0,
- 122, 0, 120, 115, 0, 22, 93, 0, 9, 0, 0, 70, 71,
- 0, 69, 6, 0, 48, 90, 102, 0, 119, 101, 0, 0, 44,
- 0, 103, 24, 0, 17, 0, 123, 53, 23, 0, 5, 110, 25,
- 96, 0, 0, 125, 106, 60, 124, 57, 28, 55, 0, 91, 0,
- 100, 26, 0, 99, 0, 0, 0, 95, 92, 97, 88, 109, 14,
- 39, 108, 0, 81, 0, 18, 89, 111, 32, 0, 121, 80, 113,
- 62, 46, 84, 0, 0, 94, 40, 59, 114, 0, 36, 0, 0,
- 29, 0, 86, 63, 64, 0, 20, 61, 0, 56,
+ 106, 86, 111, 66, 0, 39, 0, 0, 74, 0, 71, 0, 0,
+ 36, 4, 0, 68, 0, 110, 77, 46, 103, 112, 21, 0, 0,
+ 117, 0, 114, 109, 0, 79, 88, 0, 1, 0, 0, 61, 62,
+ 0, 60, 7, 0, 0, 83, 80, 0, 113, 96, 0, 0, 38,
+ 0, 84, 19, 0, 52, 0, 118, 45, 15, 0, 16, 101, 20,
+ 91, 0, 0, 120, 97, 54, 119, 49, 23, 69, 0, 70, 0,
+ 95, 28, 0, 94, 0, 0, 0, 90, 87, 92, 81, 100, 0,
+ 10, 99, 0, 73, 0, 53, 105, 102, 27, 0, 116, 72, 107,
+ 56, 40, 76, 0, 0, 89, 34, 44, 108, 0, 11, 0, 0,
+ 24, 0, 78, 104, 58, 0, 12, 55, 0, 115,
};
/* aKWNext[] forms the hash collision chain. If aKWHash[i]==0
** then the i-th keyword has no more hash collisions. Otherwise,
** the next keyword with the same hash is aKWHash[i]-1. */
-static const unsigned char aKWNext[125] = {
- 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 2, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 0,
- 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 33, 0, 21, 0, 0, 0, 0, 0, 50,
- 0, 43, 3, 47, 0, 0, 0, 0, 30, 0, 58, 0, 38,
- 0, 0, 0, 1, 66, 0, 0, 67, 0, 41, 0, 0, 0,
- 0, 0, 0, 49, 65, 0, 0, 0, 0, 31, 52, 16, 34,
- 10, 0, 0, 0, 0, 0, 0, 0, 11, 72, 79, 0, 8,
- 0, 104, 98, 0, 107, 0, 87, 0, 75, 51, 0, 27, 37,
- 0, 73, 83, 0, 35, 68, 0, 0,
+static const unsigned char aKWNext[120] = {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 6, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 31, 0,
+ 13, 0, 30, 0, 0, 0, 37, 0, 0, 0, 0, 0, 0,
+ 0, 0, 25, 0, 0, 0, 5, 0, 17, 0, 0, 0, 18,
+ 0, 35, 50, 47, 32, 0, 0, 0, 41, 59, 0, 0, 0,
+ 14, 0, 26, 0, 51, 0, 9, 0, 2, 0, 0, 0, 0,
+ 0, 0, 0, 3, 63, 85, 93, 0, 98, 0, 82, 0, 57,
+ 42, 0, 67, 43, 0, 22, 29, 0, 65, 75, 48, 0, 33,
+ 64, 0, 0,
};
/* aKWLen[i] is the length (in bytes) of the i-th keyword */
-static const unsigned char aKWLen[125] = {
- 7, 7, 5, 4, 6, 4, 5, 3, 6, 7, 3, 6, 6,
- 7, 7, 3, 8, 2, 6, 5, 4, 4, 3, 10, 4, 6,
- 11, 6, 2, 7, 5, 5, 9, 6, 9, 9, 7, 10, 10,
- 4, 6, 2, 3, 9, 4, 2, 6, 5, 7, 4, 5, 7,
- 6, 6, 5, 6, 5, 5, 9, 7, 7, 3, 2, 4, 4,
- 7, 3, 6, 4, 7, 6, 12, 6, 9, 4, 6, 5, 4,
- 7, 6, 5, 6, 7, 5, 4, 5, 6, 5, 7, 3, 7,
- 13, 2, 2, 4, 6, 6, 8, 5, 17, 12, 7, 8, 8,
- 2, 4, 4, 4, 4, 4, 2, 2, 6, 5, 8, 5, 8,
- 4, 3, 5, 5, 6, 4, 9, 3,
+static const unsigned char aKWLen[120] = {
+ 6, 7, 3, 6, 10, 6, 4, 5, 3, 10, 9, 5, 4,
+ 4, 3, 4, 7, 3, 10, 4, 6, 11, 6, 2, 7, 5,
+ 5, 6, 7, 7, 9, 6, 9, 4, 6, 2, 3, 9, 4,
+ 2, 7, 4, 5, 9, 6, 6, 5, 6, 5, 7, 3, 8,
+ 2, 7, 7, 3, 2, 4, 4, 4, 7, 6, 12, 6, 6,
+ 9, 4, 7, 5, 7, 5, 6, 5, 6, 7, 5, 4, 5,
+ 6, 7, 5, 6, 3, 8, 8, 2, 13, 2, 2, 4, 6,
+ 6, 8, 5, 17, 12, 4, 4, 4, 4, 4, 2, 2, 5,
+ 7, 6, 6, 5, 8, 5, 8, 4, 3, 5, 6, 5, 6,
+ 4, 9, 3,
};
/* aKWOffset[i] is the index into zKWText[] of the start of
** the text for the i-th keyword. */
-static const unsigned short int aKWOffset[125] = {
- 0, 2, 2, 8, 9, 14, 16, 20, 23, 25, 25, 29, 33,
- 36, 41, 46, 48, 53, 54, 59, 62, 65, 67, 69, 78, 81,
- 86, 91, 95, 96, 101, 105, 109, 117, 122, 128, 136, 142, 152,
- 159, 162, 162, 165, 167, 167, 171, 176, 179, 184, 184, 188, 192,
- 199, 204, 209, 212, 218, 221, 225, 234, 240, 240, 240, 243, 246,
- 250, 251, 255, 261, 265, 272, 278, 290, 296, 305, 307, 313, 318,
- 320, 327, 332, 337, 343, 349, 354, 358, 361, 367, 371, 378, 380,
- 387, 389, 391, 400, 404, 410, 416, 424, 429, 429, 445, 452, 459,
- 460, 467, 471, 475, 479, 483, 486, 488, 490, 496, 500, 508, 513,
- 521, 521, 525, 530, 535, 541, 545, 550,
+static const unsigned short int aKWOffset[120] = {
+ 0, 2, 2, 6, 10, 18, 23, 25, 29, 32, 39, 47, 50,
+ 53, 55, 57, 60, 61, 65, 74, 76, 81, 86, 90, 91, 96,
+ 100, 104, 109, 115, 121, 129, 134, 140, 143, 143, 146, 148, 148,
+ 152, 157, 157, 161, 165, 174, 179, 184, 187, 193, 196, 201, 203,
+ 208, 211, 217, 217, 217, 220, 223, 227, 231, 238, 244, 256, 262,
+ 268, 277, 279, 279, 285, 292, 297, 302, 307, 313, 319, 324, 328,
+ 331, 336, 343, 347, 353, 355, 362, 363, 370, 372, 374, 383, 387,
+ 393, 399, 407, 412, 412, 429, 433, 437, 441, 445, 448, 450, 452,
+ 456, 463, 469, 475, 479, 487, 492, 500, 500, 504, 509, 515, 520,
+ 526, 530, 535,
};
/* aKWCode[i] is the parser symbol code for the i-th keyword */
-static const unsigned char aKWCode[125] = {
- TK_REINDEX, TK_INDEXED, TK_INDEX, TK_DESC, TK_ESCAPE,
- TK_EACH, TK_CHECK, TK_KEY, TK_BEFORE, TK_FOREIGN,
- TK_FOR, TK_IGNORE, TK_LIKE_KW, TK_EXPLAIN, TK_INSTEAD,
- TK_ADD, TK_DATABASE, TK_AS, TK_SELECT, TK_TABLE,
- TK_JOIN_KW, TK_THEN, TK_END, TK_DEFERRABLE, TK_ELSE,
- TK_EXCEPT, TK_TRANSACTION,TK_ACTION, TK_ON, TK_JOIN_KW,
- TK_ALTER, TK_RAISE, TK_EXCLUSIVE, TK_EXISTS, TK_SAVEPOINT,
- TK_INTERSECT, TK_TRIGGER, TK_REFERENCES, TK_CONSTRAINT, TK_INTO,
- TK_OFFSET, TK_OF, TK_SET, TK_TEMP, TK_TEMP,
- TK_OR, TK_UNIQUE, TK_QUERY, TK_WITHOUT, TK_WITH,
- TK_JOIN_KW, TK_RELEASE, TK_ATTACH, TK_HAVING, TK_GROUP,
- TK_UPDATE, TK_BEGIN, TK_JOIN_KW, TK_RECURSIVE, TK_BETWEEN,
- TK_NOTNULL, TK_NOT, TK_NO, TK_NULL, TK_LIKE_KW,
- TK_CASCADE, TK_ASC, TK_DELETE, TK_CASE, TK_COLLATE,
- TK_CREATE, TK_CTIME_KW, TK_DETACH, TK_IMMEDIATE, TK_JOIN,
- TK_INSERT, TK_MATCH, TK_PLAN, TK_ANALYZE, TK_PRAGMA,
- TK_ABORT, TK_VALUES, TK_VIRTUAL, TK_LIMIT, TK_WHEN,
- TK_WHERE, TK_RENAME, TK_AFTER, TK_REPLACE, TK_AND,
- TK_DEFAULT, TK_AUTOINCR, TK_TO, TK_IN, TK_CAST,
+static const unsigned char aKWCode[120] = {
+ TK_BEFORE, TK_FOREIGN, TK_FOR, TK_IGNORE, TK_REFERENCES,
+ TK_ESCAPE, TK_EACH, TK_CHECK, TK_KEY, TK_CONSTRAINT,
+ TK_INTERSECT, TK_TABLE, TK_JOIN_KW, TK_THEN, TK_END,
+ TK_DESC, TK_CASCADE, TK_ASC, TK_DEFERRABLE, TK_ELSE,
+ TK_SELECT, TK_TRANSACTION,TK_ACTION, TK_ON, TK_JOIN_KW,
+ TK_ALTER, TK_RAISE, TK_EXCEPT, TK_TRIGGER, TK_RELEASE,
+ TK_EXCLUSIVE, TK_EXISTS, TK_SAVEPOINT, TK_INTO, TK_OFFSET,
+ TK_OF, TK_SET, TK_TEMP, TK_TEMP, TK_OR,
+ TK_WITHOUT, TK_WITH, TK_JOIN_KW, TK_RECURSIVE, TK_ATTACH,
+ TK_HAVING, TK_GROUP, TK_UPDATE, TK_BEGIN, TK_INSTEAD,
+ TK_ADD, TK_DATABASE, TK_AS, TK_BETWEEN, TK_NOTNULL,
+ TK_NOT, TK_NO, TK_NULL, TK_LIKE_KW, TK_CASE,
+ TK_COLLATE, TK_CREATE, TK_CTIME_KW, TK_DELETE, TK_DETACH,
+ TK_IMMEDIATE, TK_JOIN, TK_INDEXED, TK_INDEX, TK_DEFAULT,
+ TK_MATCH, TK_PRAGMA, TK_ABORT, TK_VALUES, TK_VIRTUAL,
+ TK_LIMIT, TK_WHEN, TK_WHERE, TK_LIKE_KW, TK_PRIMARY,
+ TK_AFTER, TK_RENAME, TK_AND, TK_DEFERRED, TK_DISTINCT,
+ TK_IS, TK_AUTOINCR, TK_TO, TK_IN, TK_CAST,
TK_COLUMNKW, TK_COMMIT, TK_CONFLICT, TK_JOIN_KW, TK_CTIME_KW,
- TK_CTIME_KW, TK_PRIMARY, TK_DEFERRED, TK_DISTINCT, TK_IS,
- TK_DROP, TK_FAIL, TK_FROM, TK_JOIN_KW, TK_LIKE_KW,
- TK_BY, TK_IF, TK_ISNULL, TK_ORDER, TK_RESTRICT,
- TK_JOIN_KW, TK_ROLLBACK, TK_ROWS, TK_ROW, TK_UNION,
+ TK_CTIME_KW, TK_DROP, TK_FAIL, TK_FROM, TK_JOIN_KW,
+ TK_LIKE_KW, TK_BY, TK_IF, TK_JOIN_KW, TK_REPLACE,
+ TK_INSERT, TK_ISNULL, TK_ORDER, TK_RESTRICT, TK_JOIN_KW,
+ TK_ROLLBACK, TK_ROWS, TK_ROW, TK_UNION, TK_UNIQUE,
TK_USING, TK_VACUUM, TK_VIEW, TK_INITIALLY, TK_ALL,
};
/* Check to see if z[0..n-1] is a keyword. If it is, write the
@@ -151408,131 +151316,126 @@ static int keywordCode(const char *z, int n, int *pType){
while( j<n && toupper(z[j])==zKW[j] ){ j++; }
#endif
if( j<n ) continue;
- testcase( i==0 ); /* REINDEX */
- testcase( i==1 ); /* INDEXED */
- testcase( i==2 ); /* INDEX */
- testcase( i==3 ); /* DESC */
- testcase( i==4 ); /* ESCAPE */
- testcase( i==5 ); /* EACH */
- testcase( i==6 ); /* CHECK */
- testcase( i==7 ); /* KEY */
- testcase( i==8 ); /* BEFORE */
- testcase( i==9 ); /* FOREIGN */
- testcase( i==10 ); /* FOR */
- testcase( i==11 ); /* IGNORE */
- testcase( i==12 ); /* REGEXP */
- testcase( i==13 ); /* EXPLAIN */
- testcase( i==14 ); /* INSTEAD */
- testcase( i==15 ); /* ADD */
- testcase( i==16 ); /* DATABASE */
- testcase( i==17 ); /* AS */
- testcase( i==18 ); /* SELECT */
- testcase( i==19 ); /* TABLE */
- testcase( i==20 ); /* LEFT */
- testcase( i==21 ); /* THEN */
- testcase( i==22 ); /* END */
- testcase( i==23 ); /* DEFERRABLE */
- testcase( i==24 ); /* ELSE */
- testcase( i==25 ); /* EXCEPT */
- testcase( i==26 ); /* TRANSACTION */
- testcase( i==27 ); /* ACTION */
- testcase( i==28 ); /* ON */
- testcase( i==29 ); /* NATURAL */
- testcase( i==30 ); /* ALTER */
- testcase( i==31 ); /* RAISE */
- testcase( i==32 ); /* EXCLUSIVE */
- testcase( i==33 ); /* EXISTS */
- testcase( i==34 ); /* SAVEPOINT */
- testcase( i==35 ); /* INTERSECT */
- testcase( i==36 ); /* TRIGGER */
- testcase( i==37 ); /* REFERENCES */
- testcase( i==38 ); /* CONSTRAINT */
- testcase( i==39 ); /* INTO */
- testcase( i==40 ); /* OFFSET */
- testcase( i==41 ); /* OF */
- testcase( i==42 ); /* SET */
- testcase( i==43 ); /* TEMPORARY */
- testcase( i==44 ); /* TEMP */
- testcase( i==45 ); /* OR */
- testcase( i==46 ); /* UNIQUE */
- testcase( i==47 ); /* QUERY */
- testcase( i==48 ); /* WITHOUT */
- testcase( i==49 ); /* WITH */
- testcase( i==50 ); /* OUTER */
- testcase( i==51 ); /* RELEASE */
- testcase( i==52 ); /* ATTACH */
- testcase( i==53 ); /* HAVING */
- testcase( i==54 ); /* GROUP */
- testcase( i==55 ); /* UPDATE */
- testcase( i==56 ); /* BEGIN */
- testcase( i==57 ); /* INNER */
- testcase( i==58 ); /* RECURSIVE */
- testcase( i==59 ); /* BETWEEN */
- testcase( i==60 ); /* NOTNULL */
- testcase( i==61 ); /* NOT */
- testcase( i==62 ); /* NO */
- testcase( i==63 ); /* NULL */
- testcase( i==64 ); /* LIKE */
- testcase( i==65 ); /* CASCADE */
- testcase( i==66 ); /* ASC */
- testcase( i==67 ); /* DELETE */
- testcase( i==68 ); /* CASE */
- testcase( i==69 ); /* COLLATE */
- testcase( i==70 ); /* CREATE */
- testcase( i==71 ); /* CURRENT_DATE */
- testcase( i==72 ); /* DETACH */
- testcase( i==73 ); /* IMMEDIATE */
- testcase( i==74 ); /* JOIN */
- testcase( i==75 ); /* INSERT */
- testcase( i==76 ); /* MATCH */
- testcase( i==77 ); /* PLAN */
- testcase( i==78 ); /* ANALYZE */
- testcase( i==79 ); /* PRAGMA */
- testcase( i==80 ); /* ABORT */
- testcase( i==81 ); /* VALUES */
- testcase( i==82 ); /* VIRTUAL */
- testcase( i==83 ); /* LIMIT */
- testcase( i==84 ); /* WHEN */
- testcase( i==85 ); /* WHERE */
- testcase( i==86 ); /* RENAME */
- testcase( i==87 ); /* AFTER */
- testcase( i==88 ); /* REPLACE */
- testcase( i==89 ); /* AND */
- testcase( i==90 ); /* DEFAULT */
- testcase( i==91 ); /* AUTOINCREMENT */
- testcase( i==92 ); /* TO */
- testcase( i==93 ); /* IN */
- testcase( i==94 ); /* CAST */
- testcase( i==95 ); /* COLUMN */
- testcase( i==96 ); /* COMMIT */
- testcase( i==97 ); /* CONFLICT */
- testcase( i==98 ); /* CROSS */
- testcase( i==99 ); /* CURRENT_TIMESTAMP */
- testcase( i==100 ); /* CURRENT_TIME */
- testcase( i==101 ); /* PRIMARY */
- testcase( i==102 ); /* DEFERRED */
- testcase( i==103 ); /* DISTINCT */
- testcase( i==104 ); /* IS */
- testcase( i==105 ); /* DROP */
- testcase( i==106 ); /* FAIL */
- testcase( i==107 ); /* FROM */
- testcase( i==108 ); /* FULL */
- testcase( i==109 ); /* GLOB */
- testcase( i==110 ); /* BY */
- testcase( i==111 ); /* IF */
- testcase( i==112 ); /* ISNULL */
- testcase( i==113 ); /* ORDER */
- testcase( i==114 ); /* RESTRICT */
- testcase( i==115 ); /* RIGHT */
- testcase( i==116 ); /* ROLLBACK */
- testcase( i==117 ); /* ROWS */
- testcase( i==118 ); /* ROW */
- testcase( i==119 ); /* UNION */
- testcase( i==120 ); /* USING */
- testcase( i==121 ); /* VACUUM */
- testcase( i==122 ); /* VIEW */
- testcase( i==123 ); /* INITIALLY */
- testcase( i==124 ); /* ALL */
+ testcase( i==0 ); /* BEFORE */
+ testcase( i==1 ); /* FOREIGN */
+ testcase( i==2 ); /* FOR */
+ testcase( i==3 ); /* IGNORE */
+ testcase( i==4 ); /* REFERENCES */
+ testcase( i==5 ); /* ESCAPE */
+ testcase( i==6 ); /* EACH */
+ testcase( i==7 ); /* CHECK */
+ testcase( i==8 ); /* KEY */
+ testcase( i==9 ); /* CONSTRAINT */
+ testcase( i==10 ); /* INTERSECT */
+ testcase( i==11 ); /* TABLE */
+ testcase( i==12 ); /* LEFT */
+ testcase( i==13 ); /* THEN */
+ testcase( i==14 ); /* END */
+ testcase( i==15 ); /* DESC */
+ testcase( i==16 ); /* CASCADE */
+ testcase( i==17 ); /* ASC */
+ testcase( i==18 ); /* DEFERRABLE */
+ testcase( i==19 ); /* ELSE */
+ testcase( i==20 ); /* SELECT */
+ testcase( i==21 ); /* TRANSACTION */
+ testcase( i==22 ); /* ACTION */
+ testcase( i==23 ); /* ON */
+ testcase( i==24 ); /* NATURAL */
+ testcase( i==25 ); /* ALTER */
+ testcase( i==26 ); /* RAISE */
+ testcase( i==27 ); /* EXCEPT */
+ testcase( i==28 ); /* TRIGGER */
+ testcase( i==29 ); /* RELEASE */
+ testcase( i==30 ); /* EXCLUSIVE */
+ testcase( i==31 ); /* EXISTS */
+ testcase( i==32 ); /* SAVEPOINT */
+ testcase( i==33 ); /* INTO */
+ testcase( i==34 ); /* OFFSET */
+ testcase( i==35 ); /* OF */
+ testcase( i==36 ); /* SET */
+ testcase( i==37 ); /* TEMPORARY */
+ testcase( i==38 ); /* TEMP */
+ testcase( i==39 ); /* OR */
+ testcase( i==40 ); /* WITHOUT */
+ testcase( i==41 ); /* WITH */
+ testcase( i==42 ); /* OUTER */
+ testcase( i==43 ); /* RECURSIVE */
+ testcase( i==44 ); /* ATTACH */
+ testcase( i==45 ); /* HAVING */
+ testcase( i==46 ); /* GROUP */
+ testcase( i==47 ); /* UPDATE */
+ testcase( i==48 ); /* BEGIN */
+ testcase( i==49 ); /* INSTEAD */
+ testcase( i==50 ); /* ADD */
+ testcase( i==51 ); /* DATABASE */
+ testcase( i==52 ); /* AS */
+ testcase( i==53 ); /* BETWEEN */
+ testcase( i==54 ); /* NOTNULL */
+ testcase( i==55 ); /* NOT */
+ testcase( i==56 ); /* NO */
+ testcase( i==57 ); /* NULL */
+ testcase( i==58 ); /* LIKE */
+ testcase( i==59 ); /* CASE */
+ testcase( i==60 ); /* COLLATE */
+ testcase( i==61 ); /* CREATE */
+ testcase( i==62 ); /* CURRENT_DATE */
+ testcase( i==63 ); /* DELETE */
+ testcase( i==64 ); /* DETACH */
+ testcase( i==65 ); /* IMMEDIATE */
+ testcase( i==66 ); /* JOIN */
+ testcase( i==67 ); /* INDEXED */
+ testcase( i==68 ); /* INDEX */
+ testcase( i==69 ); /* DEFAULT */
+ testcase( i==70 ); /* MATCH */
+ testcase( i==71 ); /* PRAGMA */
+ testcase( i==72 ); /* ABORT */
+ testcase( i==73 ); /* VALUES */
+ testcase( i==74 ); /* VIRTUAL */
+ testcase( i==75 ); /* LIMIT */
+ testcase( i==76 ); /* WHEN */
+ testcase( i==77 ); /* WHERE */
+ testcase( i==78 ); /* REGEXP */
+ testcase( i==79 ); /* PRIMARY */
+ testcase( i==80 ); /* AFTER */
+ testcase( i==81 ); /* RENAME */
+ testcase( i==82 ); /* AND */
+ testcase( i==83 ); /* DEFERRED */
+ testcase( i==84 ); /* DISTINCT */
+ testcase( i==85 ); /* IS */
+ testcase( i==86 ); /* AUTOINCREMENT */
+ testcase( i==87 ); /* TO */
+ testcase( i==88 ); /* IN */
+ testcase( i==89 ); /* CAST */
+ testcase( i==90 ); /* COLUMN */
+ testcase( i==91 ); /* COMMIT */
+ testcase( i==92 ); /* CONFLICT */
+ testcase( i==93 ); /* CROSS */
+ testcase( i==94 ); /* CURRENT_TIMESTAMP */
+ testcase( i==95 ); /* CURRENT_TIME */
+ testcase( i==96 ); /* DROP */
+ testcase( i==97 ); /* FAIL */
+ testcase( i==98 ); /* FROM */
+ testcase( i==99 ); /* FULL */
+ testcase( i==100 ); /* GLOB */
+ testcase( i==101 ); /* BY */
+ testcase( i==102 ); /* IF */
+ testcase( i==103 ); /* INNER */
+ testcase( i==104 ); /* REPLACE */
+ testcase( i==105 ); /* INSERT */
+ testcase( i==106 ); /* ISNULL */
+ testcase( i==107 ); /* ORDER */
+ testcase( i==108 ); /* RESTRICT */
+ testcase( i==109 ); /* RIGHT */
+ testcase( i==110 ); /* ROLLBACK */
+ testcase( i==111 ); /* ROWS */
+ testcase( i==112 ); /* ROW */
+ testcase( i==113 ); /* UNION */
+ testcase( i==114 ); /* UNIQUE */
+ testcase( i==115 ); /* USING */
+ testcase( i==116 ); /* VACUUM */
+ testcase( i==117 ); /* VIEW */
+ testcase( i==118 ); /* INITIALLY */
+ testcase( i==119 ); /* ALL */
*pType = aKWCode[i];
break;
}
@@ -151544,7 +151447,7 @@ SQLITE_PRIVATE int sqlite3KeywordCode(const unsigned char *z, int n){
keywordCode((char*)z, n, &id);
return id;
}
-#define SQLITE_N_KEYWORD 125
+#define SQLITE_N_KEYWORD 120
SQLITE_API int sqlite3_keyword_name(int i,const char **pzName,int *pnName){
if( i<0 || i>=SQLITE_N_KEYWORD ) return SQLITE_ERROR;
*pzName = zKWText + aKWOffset[i];
@@ -161089,7 +160992,7 @@ static int fts3SegReaderCursor(
/* If zTerm is not NULL, and this segment is not stored entirely on its
** root node, the range of leaves scanned can be reduced. Do this. */
- if( iStartBlock && zTerm ){
+ if( iStartBlock && zTerm && zRoot ){
sqlite3_int64 *pi = (isPrefix ? &iLeavesEndBlock : 0);
rc = fts3SelectLeaf(p, zTerm, nTerm, zRoot, nRoot, &iStartBlock, pi);
if( rc!=SQLITE_OK ) goto finished;
@@ -168689,10 +168592,12 @@ static int fts3SqlStmt(
pStmt = p->aStmt[eStmt];
if( !pStmt ){
+ int f = SQLITE_PREPARE_PERSISTENT|SQLITE_PREPARE_NO_VTAB;
char *zSql;
if( eStmt==SQL_CONTENT_INSERT ){
zSql = sqlite3_mprintf(azSql[eStmt], p->zDb, p->zName, p->zWriteExprlist);
}else if( eStmt==SQL_SELECT_CONTENT_BY_ROWID ){
+ f &= ~SQLITE_PREPARE_NO_VTAB;
zSql = sqlite3_mprintf(azSql[eStmt], p->zReadExprlist);
}else{
zSql = sqlite3_mprintf(azSql[eStmt], p->zDb, p->zName);
@@ -168700,8 +168605,7 @@ static int fts3SqlStmt(
if( !zSql ){
rc = SQLITE_NOMEM;
}else{
- rc = sqlite3_prepare_v3(p->db, zSql, -1, SQLITE_PREPARE_PERSISTENT,
- &pStmt, NULL);
+ rc = sqlite3_prepare_v3(p->db, zSql, -1, f, &pStmt, NULL);
sqlite3_free(zSql);
assert( rc==SQLITE_OK || pStmt==0 );
p->aStmt[eStmt] = pStmt;
@@ -182401,6 +182305,7 @@ static int rtreeSqlInit(
};
sqlite3_stmt **appStmt[N_STATEMENT];
int i;
+ const int f = SQLITE_PREPARE_PERSISTENT|SQLITE_PREPARE_NO_VTAB;
pRtree->db = db;
@@ -182457,8 +182362,7 @@ static int rtreeSqlInit(
}
zSql = sqlite3_mprintf(zFormat, zDb, zPrefix);
if( zSql ){
- rc = sqlite3_prepare_v3(db, zSql, -1, SQLITE_PREPARE_PERSISTENT,
- appStmt[i], 0);
+ rc = sqlite3_prepare_v3(db, zSql, -1, f, appStmt[i], 0);
}else{
rc = SQLITE_NOMEM;
}
@@ -182488,8 +182392,7 @@ static int rtreeSqlInit(
if( zSql==0 ){
rc = SQLITE_NOMEM;
}else{
- rc = sqlite3_prepare_v3(db, zSql, -1, SQLITE_PREPARE_PERSISTENT,
- &pRtree->pWriteAux, 0);
+ rc = sqlite3_prepare_v3(db, zSql, -1, f, &pRtree->pWriteAux, 0);
sqlite3_free(zSql);
}
}
@@ -207250,7 +207153,8 @@ static int fts5IndexPrepareStmt(
if( p->rc==SQLITE_OK ){
if( zSql ){
p->rc = sqlite3_prepare_v3(p->pConfig->db, zSql, -1,
- SQLITE_PREPARE_PERSISTENT, ppStmt, 0);
+ SQLITE_PREPARE_PERSISTENT|SQLITE_PREPARE_NO_VTAB,
+ ppStmt, 0);
}else{
p->rc = SQLITE_NOMEM;
}
@@ -207291,23 +207195,12 @@ static void fts5DataDelete(Fts5Index *p, i64 iFirst, i64 iLast){
if( p->rc!=SQLITE_OK ) return;
if( p->pDeleter==0 ){
- int rc;
Fts5Config *pConfig = p->pConfig;
char *zSql = sqlite3_mprintf(
"DELETE FROM '%q'.'%q_data' WHERE id>=? AND id<=?",
pConfig->zDb, pConfig->zName
);
- if( zSql==0 ){
- rc = SQLITE_NOMEM;
- }else{
- rc = sqlite3_prepare_v3(pConfig->db, zSql, -1,
- SQLITE_PREPARE_PERSISTENT, &p->pDeleter, 0);
- sqlite3_free(zSql);
- }
- if( rc!=SQLITE_OK ){
- p->rc = rc;
- return;
- }
+ if( fts5IndexPrepareStmt(p, &p->pDeleter, zSql) ) return;
}
sqlite3_bind_int64(p->pDeleter, 1, iFirst);
@@ -215942,8 +215835,9 @@ static int fts5StorageGetStmt(
if( zSql==0 ){
rc = SQLITE_NOMEM;
}else{
- rc = sqlite3_prepare_v3(pC->db, zSql, -1,
- SQLITE_PREPARE_PERSISTENT, &p->aStmt[eStmt], 0);
+ int f = SQLITE_PREPARE_PERSISTENT;
+ if( eStmt>FTS5_STMT_LOOKUP ) f |= SQLITE_PREPARE_NO_VTAB;
+ rc = sqlite3_prepare_v3(pC->db, zSql, -1, f, &p->aStmt[eStmt], 0);
sqlite3_free(zSql);
if( rc!=SQLITE_OK && pzErrMsg ){
*pzErrMsg = sqlite3_mprintf("%s", sqlite3_errmsg(pC->db));
@@ -220400,7 +220294,7 @@ SQLITE_API int sqlite3_stmt_init(
#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
/************** End of stmt.c ************************************************/
-#if __LINE__!=220403
+#if __LINE__!=220297
#undef SQLITE_SOURCE_ID
#define SQLITE_SOURCE_ID "2018-12-01 12:34:55 bf8c1b2b7a5960c282e543b9c293686dccff272512d08865f4600fb58238alt2"
#endif
diff --git a/chromium/third_party/sqlite/amalgamation/sqlite3.h b/chromium/third_party/sqlite/amalgamation/sqlite3.h
index fe538430428..3caa3d50732 100644
--- a/chromium/third_party/sqlite/amalgamation/sqlite3.h
+++ b/chromium/third_party/sqlite/amalgamation/sqlite3.h
@@ -3637,10 +3637,16 @@ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
** normalize a SQL statement are unspecified and subject to change.
** At a minimum, literal values will be replaced with suitable
** placeholders.
+**
+** [[SQLITE_PREPARE_NO_VTAB]] <dt>SQLITE_PREPARE_NO_VTAB</dt>
+** <dd>The SQLITE_PREPARE_NO_VTAB flag causes the SQL compiler
+** to return an error (error code SQLITE_ERROR) if the statement uses
+** any virtual tables.
** </dl>
*/
#define SQLITE_PREPARE_PERSISTENT 0x01
#define SQLITE_PREPARE_NORMALIZE 0x02
+#define SQLITE_PREPARE_NO_VTAB 0x04
/*
** CAPI3REF: Compiling An SQL Statement
diff --git a/chromium/third_party/sqlite/fuzz/DEPS b/chromium/third_party/sqlite/fuzz/DEPS
new file mode 100644
index 00000000000..8eb68bc404d
--- /dev/null
+++ b/chromium/third_party/sqlite/fuzz/DEPS
@@ -0,0 +1 @@
+include_rules = [ '+testing/libfuzzer/proto', '+base' ]
diff --git a/chromium/third_party/sqlite/fuzz/disabled_queries_parser.cc b/chromium/third_party/sqlite/fuzz/disabled_queries_parser.cc
new file mode 100644
index 00000000000..c2bd17b7ffb
--- /dev/null
+++ b/chromium/third_party/sqlite/fuzz/disabled_queries_parser.cc
@@ -0,0 +1,30 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "third_party/sqlite/fuzz/disabled_queries_parser.h"
+
+namespace sql_fuzzer {
+
+std::set<std::string> ParseDisabledQueries(std::string query_list) {
+ // Trimming
+ query_list.erase(query_list.find_last_not_of(" \t\n\r\f\v") + 1);
+ query_list.erase(0, query_list.find_first_not_of(" \t\n\r\f\v"));
+ std::set<std::string> ret;
+ std::string curr_query;
+ for (size_t i = 0; i < query_list.length(); i++) {
+ if (query_list[i] == ',') {
+ ret.insert(curr_query);
+ curr_query.clear();
+ continue;
+ }
+ curr_query += query_list[i];
+ }
+ if (curr_query.length() != 0) {
+ // Add last query, which doesn't have a trailing comma
+ ret.insert(curr_query);
+ }
+ return ret;
+}
+
+} // namespace sql_fuzzer
diff --git a/chromium/third_party/sqlite/fuzz/disabled_queries_parser.h b/chromium/third_party/sqlite/fuzz/disabled_queries_parser.h
new file mode 100644
index 00000000000..665b8719d01
--- /dev/null
+++ b/chromium/third_party/sqlite/fuzz/disabled_queries_parser.h
@@ -0,0 +1,16 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef THIRD_PARTY_SQLITE_FUZZ_DISABLED_QUERIES_PARSER_H_
+#define THIRD_PARTY_SQLITE_FUZZ_DISABLED_QUERIES_PARSER_H_
+
+#include <set>
+#include <string>
+
+namespace sql_fuzzer {
+// |query_list| should be a list of disabled queries separated only by commas.
+std::set<std::string> ParseDisabledQueries(std::string query_list);
+} // namespace sql_fuzzer
+
+#endif // THIRD_PARTY_SQLITE_FUZZ_DISABLED_QUERIES_PARSER_H_
diff --git a/chromium/third_party/sqlite/fuzz/icu_codes.proto b/chromium/third_party/sqlite/fuzz/icu_codes.proto
new file mode 100644
index 00000000000..d3d470a79b5
--- /dev/null
+++ b/chromium/third_party/sqlite/fuzz/icu_codes.proto
@@ -0,0 +1,189 @@
+syntax = "proto2";
+
+package sql_query_grammar;
+
+enum IsoLangCode {
+ ISO_LANG_CODE_ab = 1;
+ ISO_LANG_CODE_af = 2;
+ ISO_LANG_CODE_ak = 3;
+ ISO_LANG_CODE_sq = 4;
+ ISO_LANG_CODE_am = 5;
+ ISO_LANG_CODE_ar = 6;
+ ISO_LANG_CODE_an = 7;
+ ISO_LANG_CODE_hy = 8;
+ ISO_LANG_CODE_as = 9;
+ ISO_LANG_CODE_av = 10;
+ ISO_LANG_CODE_ae = 11;
+ ISO_LANG_CODE_ay = 12;
+ ISO_LANG_CODE_az = 13;
+ ISO_LANG_CODE_ba = 14;
+ ISO_LANG_CODE_bm = 15;
+ ISO_LANG_CODE_eu = 16;
+ ISO_LANG_CODE_be = 17;
+ ISO_LANG_CODE_bn = 18;
+ ISO_LANG_CODE_bh = 19;
+ ISO_LANG_CODE_bi = 20;
+ ISO_LANG_CODE_bs = 21;
+ ISO_LANG_CODE_br = 22;
+ ISO_LANG_CODE_bg = 23;
+ ISO_LANG_CODE_my = 24;
+ ISO_LANG_CODE_ca = 25;
+ ISO_LANG_CODE_ch = 26;
+ ISO_LANG_CODE_ce = 27;
+ ISO_LANG_CODE_zh = 28;
+ ISO_LANG_CODE_cu = 29;
+ ISO_LANG_CODE_cv = 30;
+ ISO_LANG_CODE_kw = 31;
+ ISO_LANG_CODE_co = 32;
+ ISO_LANG_CODE_cr = 33;
+ ISO_LANG_CODE_cs = 34;
+ ISO_LANG_CODE_da = 35;
+ ISO_LANG_CODE_dv = 36;
+ ISO_LANG_CODE_nl = 37;
+ ISO_LANG_CODE_dz = 38;
+ ISO_LANG_CODE_en = 39;
+ ISO_LANG_CODE_eo = 40;
+ ISO_LANG_CODE_et = 41;
+ ISO_LANG_CODE_ee = 42;
+ ISO_LANG_CODE_fo = 43;
+ ISO_LANG_CODE_fj = 44;
+ ISO_LANG_CODE_fi = 45;
+ ISO_LANG_CODE_fr = 46;
+ ISO_LANG_CODE_fy = 47;
+ ISO_LANG_CODE_ff = 48;
+ ISO_LANG_CODE_ka = 49;
+ ISO_LANG_CODE_de = 50;
+ ISO_LANG_CODE_gd = 51;
+ ISO_LANG_CODE_ga = 52;
+ ISO_LANG_CODE_gl = 53;
+ ISO_LANG_CODE_gv = 54;
+ ISO_LANG_CODE_el = 55;
+ ISO_LANG_CODE_gn = 56;
+ ISO_LANG_CODE_gu = 57;
+ ISO_LANG_CODE_ht = 58;
+ ISO_LANG_CODE_ha = 59;
+ ISO_LANG_CODE_he = 60;
+ ISO_LANG_CODE_hz = 61;
+ ISO_LANG_CODE_hi = 62;
+ ISO_LANG_CODE_ho = 63;
+ ISO_LANG_CODE_hr = 64;
+ ISO_LANG_CODE_hu = 65;
+ ISO_LANG_CODE_ig = 66;
+ ISO_LANG_CODE_is = 67;
+ ISO_LANG_CODE_io = 68;
+ ISO_LANG_CODE_ii = 69;
+ ISO_LANG_CODE_iu = 70;
+ ISO_LANG_CODE_ie = 71;
+ ISO_LANG_CODE_ia = 72;
+ ISO_LANG_CODE_id = 73;
+ ISO_LANG_CODE_ik = 74;
+ ISO_LANG_CODE_it = 75;
+ ISO_LANG_CODE_jv = 76;
+ ISO_LANG_CODE_ja = 77;
+ ISO_LANG_CODE_kl = 78;
+ ISO_LANG_CODE_kn = 79;
+ ISO_LANG_CODE_ks = 80;
+ ISO_LANG_CODE_kr = 81;
+ ISO_LANG_CODE_kk = 82;
+ ISO_LANG_CODE_km = 83;
+ ISO_LANG_CODE_ki = 84;
+ ISO_LANG_CODE_rw = 85;
+ ISO_LANG_CODE_ky = 86;
+ ISO_LANG_CODE_kv = 87;
+ ISO_LANG_CODE_kg = 88;
+ ISO_LANG_CODE_ko = 89;
+ ISO_LANG_CODE_kj = 90;
+ ISO_LANG_CODE_ku = 91;
+ ISO_LANG_CODE_lo = 92;
+ ISO_LANG_CODE_la = 93;
+ ISO_LANG_CODE_lv = 94;
+ ISO_LANG_CODE_li = 95;
+ ISO_LANG_CODE_ln = 96;
+ ISO_LANG_CODE_lt = 97;
+ ISO_LANG_CODE_lb = 98;
+ ISO_LANG_CODE_lu = 99;
+ ISO_LANG_CODE_lg = 100;
+ ISO_LANG_CODE_mk = 101;
+ ISO_LANG_CODE_mh = 102;
+ ISO_LANG_CODE_ml = 103;
+ ISO_LANG_CODE_mi = 104;
+ ISO_LANG_CODE_mr = 105;
+ ISO_LANG_CODE_ms = 106;
+ ISO_LANG_CODE_mg = 107;
+ ISO_LANG_CODE_mt = 108;
+ ISO_LANG_CODE_mn = 109;
+ ISO_LANG_CODE_na = 110;
+ ISO_LANG_CODE_nv = 111;
+ ISO_LANG_CODE_nr = 112;
+ ISO_LANG_CODE_nd = 113;
+ ISO_LANG_CODE_ng = 114;
+ ISO_LANG_CODE_ne = 115;
+ ISO_LANG_CODE_nn = 116;
+ ISO_LANG_CODE_nb = 117;
+ ISO_LANG_CODE_no = 118;
+ ISO_LANG_CODE_ny = 119;
+ ISO_LANG_CODE_oc = 120;
+ ISO_LANG_CODE_oj = 121;
+ ISO_LANG_CODE_or = 122;
+ ISO_LANG_CODE_om = 123;
+ ISO_LANG_CODE_os = 124;
+ ISO_LANG_CODE_pa = 125;
+ ISO_LANG_CODE_fa = 126;
+ ISO_LANG_CODE_pi = 127;
+ ISO_LANG_CODE_pl = 128;
+ ISO_LANG_CODE_pt = 129;
+ ISO_LANG_CODE_ps = 130;
+ ISO_LANG_CODE_qu = 131;
+ ISO_LANG_CODE_rm = 132;
+ ISO_LANG_CODE_ro = 133;
+ ISO_LANG_CODE_rn = 134;
+ ISO_LANG_CODE_ru = 135;
+ ISO_LANG_CODE_sg = 136;
+ ISO_LANG_CODE_sa = 137;
+ ISO_LANG_CODE_si = 138;
+ ISO_LANG_CODE_sk = 139;
+ ISO_LANG_CODE_sl = 140;
+ ISO_LANG_CODE_se = 141;
+ ISO_LANG_CODE_sm = 142;
+ ISO_LANG_CODE_sn = 143;
+ ISO_LANG_CODE_sd = 144;
+ ISO_LANG_CODE_so = 145;
+ ISO_LANG_CODE_st = 146;
+ ISO_LANG_CODE_es = 147;
+ ISO_LANG_CODE_sc = 148;
+ ISO_LANG_CODE_sr = 149;
+ ISO_LANG_CODE_ss = 150;
+ ISO_LANG_CODE_su = 151;
+ ISO_LANG_CODE_sw = 152;
+ ISO_LANG_CODE_sv = 153;
+ ISO_LANG_CODE_ty = 154;
+ ISO_LANG_CODE_ta = 155;
+ ISO_LANG_CODE_tt = 156;
+ ISO_LANG_CODE_te = 157;
+ ISO_LANG_CODE_tg = 158;
+ ISO_LANG_CODE_tl = 159;
+ ISO_LANG_CODE_th = 160;
+ ISO_LANG_CODE_bo = 161;
+ ISO_LANG_CODE_ti = 162;
+ ISO_LANG_CODE_to = 163;
+ ISO_LANG_CODE_tn = 164;
+ ISO_LANG_CODE_ts = 165;
+ ISO_LANG_CODE_tk = 166;
+ ISO_LANG_CODE_tr = 167;
+ ISO_LANG_CODE_tw = 168;
+ ISO_LANG_CODE_ug = 169;
+ ISO_LANG_CODE_uk = 170;
+ ISO_LANG_CODE_ur = 171;
+ ISO_LANG_CODE_uz = 172;
+ ISO_LANG_CODE_ve = 173;
+ ISO_LANG_CODE_vi = 174;
+ ISO_LANG_CODE_vo = 175;
+ ISO_LANG_CODE_cy = 176;
+ ISO_LANG_CODE_wa = 177;
+ ISO_LANG_CODE_wo = 178;
+ ISO_LANG_CODE_xh = 179;
+ ISO_LANG_CODE_yi = 180;
+ ISO_LANG_CODE_yo = 181;
+ ISO_LANG_CODE_za = 182;
+ ISO_LANG_CODE_zu = 183;
+}
diff --git a/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries0 b/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries0
new file mode 100644
index 00000000000..7a36870f564
--- /dev/null
+++ b/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries0
Binary files differ
diff --git a/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries1 b/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries1
new file mode 100644
index 00000000000..f2853929d0c
--- /dev/null
+++ b/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries1
Binary files differ
diff --git a/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries10 b/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries10
new file mode 100644
index 00000000000..cbc9fa63c8d
--- /dev/null
+++ b/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries10
Binary files differ
diff --git a/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries11 b/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries11
new file mode 100644
index 00000000000..9ee13e908f9
--- /dev/null
+++ b/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries11
Binary files differ
diff --git a/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries12 b/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries12
new file mode 100644
index 00000000000..04ae159ae62
--- /dev/null
+++ b/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries12
Binary files differ
diff --git a/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries13 b/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries13
new file mode 100644
index 00000000000..25fc7c70260
--- /dev/null
+++ b/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries13
Binary files differ
diff --git a/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries14 b/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries14
new file mode 100644
index 00000000000..e4e0a74810a
--- /dev/null
+++ b/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries14
Binary files differ
diff --git a/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries15 b/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries15
new file mode 100644
index 00000000000..6ef088e4694
--- /dev/null
+++ b/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries15
Binary files differ
diff --git a/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries16 b/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries16
new file mode 100644
index 00000000000..f45f4a2229d
--- /dev/null
+++ b/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries16
Binary files differ
diff --git a/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries17 b/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries17
new file mode 100644
index 00000000000..6d48cb7e597
--- /dev/null
+++ b/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries17
Binary files differ
diff --git a/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries18 b/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries18
new file mode 100644
index 00000000000..4fb9debe4a4
--- /dev/null
+++ b/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries18
Binary files differ
diff --git a/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries19 b/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries19
new file mode 100644
index 00000000000..529b54edfb1
--- /dev/null
+++ b/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries19
Binary files differ
diff --git a/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries2 b/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries2
new file mode 100644
index 00000000000..c51cd5f3081
--- /dev/null
+++ b/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries2
Binary files differ
diff --git a/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries3 b/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries3
new file mode 100644
index 00000000000..530de34a290
--- /dev/null
+++ b/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries3
Binary files differ
diff --git a/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries4 b/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries4
new file mode 100644
index 00000000000..b879fe23c80
--- /dev/null
+++ b/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries4
Binary files differ
diff --git a/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries5 b/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries5
new file mode 100644
index 00000000000..c443de66e6d
--- /dev/null
+++ b/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries5
Binary files differ
diff --git a/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries6 b/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries6
new file mode 100644
index 00000000000..3841499fd98
--- /dev/null
+++ b/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries6
Binary files differ
diff --git a/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries7 b/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries7
new file mode 100644
index 00000000000..a90d08846bb
--- /dev/null
+++ b/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries7
Binary files differ
diff --git a/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries8 b/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries8
new file mode 100644
index 00000000000..98ede46b5b8
--- /dev/null
+++ b/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries8
Binary files differ
diff --git a/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries9 b/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries9
new file mode 100644
index 00000000000..4d4c15c39c7
--- /dev/null
+++ b/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries9
Binary files differ
diff --git a/chromium/third_party/sqlite/fuzz/sql_expr_fuzzer.cc b/chromium/third_party/sqlite/fuzz/sql_expr_fuzzer.cc
new file mode 100644
index 00000000000..f20e5d9fb93
--- /dev/null
+++ b/chromium/third_party/sqlite/fuzz/sql_expr_fuzzer.cc
@@ -0,0 +1,31 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <cstdlib>
+#include <iostream>
+#include <string>
+#include <vector>
+
+#include "testing/libfuzzer/proto/lpm_interface.h"
+#include "third_party/sqlite/fuzz/sql_query_grammar.pb.h"
+#include "third_party/sqlite/fuzz/sql_query_proto_to_string.h"
+#include "third_party/sqlite/fuzz/sql_run_queries.h"
+
+using namespace sql_query_grammar;
+
+DEFINE_BINARY_PROTO_FUZZER(const Expr& expr) {
+ std::string expr_str = sql_fuzzer::ExprToString(expr);
+ // Convert printf command into runnable SQL query.
+ expr_str = "SELECT " + expr_str + ";";
+
+ if (::getenv("LPM_DUMP_NATIVE_INPUT")) {
+ std::cout << "_________________________" << std::endl;
+ std::cout << expr_str << std::endl;
+ std::cout << "------------------------" << std::endl;
+ }
+
+ std::vector<std::string> queries;
+ queries.push_back(expr_str);
+ sql_fuzzer::RunSqlQueries(queries, ::getenv("LPM_SQLITE_TRACE"));
+}
diff --git a/chromium/third_party/sqlite/fuzz/sql_fuzzer.cc b/chromium/third_party/sqlite/fuzz/sql_fuzzer.cc
new file mode 100644
index 00000000000..5b5c8009bdf
--- /dev/null
+++ b/chromium/third_party/sqlite/fuzz/sql_fuzzer.cc
@@ -0,0 +1,58 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <cstdlib>
+#include <iostream>
+#include <string>
+#include <vector>
+
+#include "testing/libfuzzer/proto/lpm_interface.h"
+#include "third_party/sqlite/fuzz/disabled_queries_parser.h"
+#include "third_party/sqlite/fuzz/sql_query_grammar.pb.h"
+#include "third_party/sqlite/fuzz/sql_query_proto_to_string.h"
+#include "third_party/sqlite/fuzz/sql_run_queries.h"
+
+using namespace sql_query_grammar;
+
+// TODO(mpdenton) Fuzzing tasks
+// 5. Definitely fix a lot of the syntax errors that SQlite spits out
+// 12. CORPUS Indexes on expressions (https://www.sqlite.org/expridx.html) and
+// other places using functions on columns???
+// 17. Generate a nice big random, well-formed corpus.
+// 18. Possibly very difficult for fuzzer to find certain areas of code, because
+// some protobufs need to be mutated together. For example, an index on an
+// expression is useless to change, if you don't change the SELECTs that use
+// that expression. May need to create a mechanism for the protobufs to
+// "register" (in the c++ fuzzer) expressions being used for certain purposes,
+// and then protobufs can simple reference those expressions later (similarly to
+// columns or tables, with just an index). This should be added if coverage
+// shows it is the case.
+
+// FIXME in the future
+// 1. Rest of the pragmas
+// 2. Make sure defensive config is off
+// 3. Fuzz the recover extension from the third patch
+// 5. Temp-file database, for better fuzzing of VACUUM and journalling.
+
+DEFINE_BINARY_PROTO_FUZZER(const SQLQueries& sql_queries) {
+ char* skip_queries = ::getenv("SQL_SKIP_QUERIES");
+ if (skip_queries) {
+ sql_fuzzer::SetDisabledQueries(
+ sql_fuzzer::ParseDisabledQueries(skip_queries));
+ }
+
+ std::vector<std::string> queries = sql_fuzzer::SQLQueriesToVec(sql_queries);
+
+ if (::getenv("LPM_DUMP_NATIVE_INPUT") && queries.size() != 0) {
+ std::cout << "_________________________" << std::endl;
+ for (std::string query : queries) {
+ if (query == ";")
+ continue;
+ std::cout << query << std::endl;
+ }
+ std::cout << "------------------------" << std::endl;
+ }
+
+ sql_fuzzer::RunSqlQueries(queries, ::getenv("LPM_SQLITE_TRACE"));
+}
diff --git a/chromium/third_party/sqlite/fuzz/sql_generate_corpus.cc b/chromium/third_party/sqlite/fuzz/sql_generate_corpus.cc
new file mode 100644
index 00000000000..a16101ebae7
--- /dev/null
+++ b/chromium/third_party/sqlite/fuzz/sql_generate_corpus.cc
@@ -0,0 +1,969 @@
+#include <unistd.h>
+
+#include <cstdlib>
+#include <iostream>
+#include <string>
+#include <vector>
+
+#include "base/command_line.h"
+#include "base/files/file.h"
+#include "base/files/file_path.h"
+#include "base/no_destructor.h"
+#include "base/strings/string_number_conversions.h"
+#include "base/strings/string_util.h"
+#include "base/time/default_clock.h"
+// TODO(mpdenton) okay to include this? Otherwise I'm copying it into this file
+// Tehcnically the std random number engines are banned in Chrome but if this
+// used base::Rand* this turns milliseconds into hours.
+#include "third_party/libFuzzer/src/FuzzerRandom.h"
+#include "third_party/sqlite/fuzz/sql_query_grammar.pb.h"
+#include "third_party/sqlite/fuzz/sql_query_proto_to_string.h"
+#include "third_party/sqlite/fuzz/sql_run_queries.h"
+
+using namespace sql_query_grammar;
+
+// TODO(mpdenton):
+// 2. Add functionality to start with a specific database so that the
+// fuzzer doesn't waste so much time getting a sufficiently complicated
+// database.
+// 3. FTS3 Corpus
+
+namespace {
+constexpr int kMinNumInsertions = 15;
+constexpr int kMaxNumInsertions = 20;
+constexpr int kMinNumIndexes = 5;
+constexpr int kMaxNumIndexes = 8;
+constexpr int kMinNumSelects = 3;
+constexpr int kMaxNumSelects = 6;
+constexpr int kMinNumJoins = 3;
+constexpr int kMaxNumJoins = 3;
+constexpr int kMinNumUpdates = 15;
+constexpr int kMaxNumUpdates = 20;
+constexpr int kMinNumDeletes = 5;
+constexpr int kMaxNumDeletes = 5;
+constexpr int kMinNumOthers = 10;
+constexpr int kMaxNumOthers = 10;
+} // namespace
+
+fuzzer::Random& GetRandom() {
+ static base::NoDestructor<fuzzer::Random> rand([] {
+ unsigned seed = base::DefaultClock::GetInstance()
+ ->Now()
+ .ToDeltaSinceWindowsEpoch()
+ .InMicroseconds() +
+ getpid();
+ return fuzzer::Random(seed);
+ }());
+ return *rand;
+}
+
+// Inclusive range.
+int RandInt(int min, int max) {
+ return GetRandom()(max - min + 1) + min;
+}
+
+void RandBytes(void* output, size_t output_len) {
+ uint8_t* out = static_cast<uint8_t*>(output);
+ for (size_t i = 0; i < output_len / sizeof(size_t); i++) {
+ size_t rand_num = GetRandom()();
+ for (size_t j = 0; j < sizeof(size_t); j++) {
+ *out = *reinterpret_cast<uint8_t*>(&rand_num);
+ out++;
+ rand_num >>= 8;
+ }
+ }
+ size_t rand_num = GetRandom()();
+ for (size_t j = 0; j < output_len % sizeof(size_t); j++) {
+ *out = *reinterpret_cast<uint8_t*>(&rand_num);
+ out++;
+ rand_num >>= 8;
+ }
+}
+
+std::string RandBytesAsString(size_t length) {
+ std::string result;
+ RandBytes(base::WriteInto(&result, length + 1), length);
+ return result;
+}
+
+uint64_t RandUint64() {
+ if (sizeof(size_t) == sizeof(uint64_t))
+ return GetRandom()();
+
+ CHECK(sizeof(size_t) == sizeof(uint32_t));
+ uint64_t rand = GetRandom()();
+ rand <<= 32;
+ rand |= GetRandom()();
+ return rand;
+}
+
+namespace i {
+struct Table {
+ uint32_t table_num;
+ int num_columns;
+ std::vector<CastTypeName::CastTypeNameEnum> col_types;
+ std::vector<std::unique_ptr<Expr>> index_exprs;
+};
+
+struct Schema {
+ int num_tables;
+ std::vector<i::Table> tables;
+};
+} // namespace i
+
+// WOW, a template AND a macro??? :)
+template <typename T>
+int GetRandomEnum(T is_valid_fn, int min, int max) {
+ int r;
+ while (!is_valid_fn(r = RandInt(min, max)))
+ ;
+ return r;
+}
+
+#define RANDOM_ENUM(CLASS_NAME, ENUM_NAME) \
+ static_cast<CLASS_NAME::ENUM_NAME>( \
+ GetRandomEnum(CLASS_NAME::ENUM_NAME##_IsValid, \
+ CLASS_NAME::ENUM_NAME##_MIN, CLASS_NAME::ENUM_NAME##_MAX))
+
+std::set<uint32_t> GetRandomNums(size_t size, uint32_t max_num) {
+ std::set<unsigned int> ret;
+ while (ret.size() < size)
+ ret.insert(RandInt(0, max_num));
+ return ret;
+}
+
+template <typename T>
+std::set<T> GetRandomSubset(const std::set<T>& s, size_t size) {
+ std::set<T> ret;
+ std::set<uint32_t> indices = GetRandomNums(size, s.size() - 1);
+
+ auto it = s.begin();
+ for (unsigned int i = 0; i < s.size(); i++) {
+ if (indices.count(i) > 0) {
+ ret.insert(*it);
+ }
+ it++;
+ }
+
+ return ret;
+}
+
+inline ColumnDef* CreateDefaultColDef(ColumnDef* cd) {
+ cd->mutable_col()->set_column(0);
+ return cd;
+}
+
+inline ComplicatedExpr* CreateDefaultCompExpr(ComplicatedExpr* ce) {
+ ce->mutable_lit_val();
+ return ce;
+}
+
+inline void CreateColumn(Column* col_ptr, uint32_t col) {
+ col_ptr->set_column(col);
+}
+
+inline void CreateTableFromUint32(Table* table_ptr, uint32_t table) {
+ table_ptr->set_table(table);
+}
+
+inline void CreateSchemaTable(ExprSchemaTable* e, i::Table* table) {
+ CreateTableFromUint32(e->mutable_table_name(), table->table_num);
+}
+
+inline void CreateColumnExpr(Expr* e, uint32_t col, i::Table* table) {
+ ExprSchemaTableColumn* stc =
+ CreateDefaultCompExpr(e->mutable_comp_expr())->mutable_expr_stc();
+ CreateColumn(stc->mutable_col(), col);
+ if (table)
+ CreateTableFromUint32(stc->mutable_table(), table->table_num);
+}
+
+std::set<uint32_t> GenerateColumnList(ColumnList* ret, i::Table* table) {
+ std::set<uint32_t> cols;
+ for (int i = 0; i < RandInt(1, table->num_columns); i++) {
+ cols.insert(RandInt(0, table->num_columns - 1));
+ }
+ std::set<uint32_t> cols_copy = cols;
+ auto it = cols.begin();
+ CreateColumn(ret->mutable_col(), *it);
+ cols.erase(it);
+ ret->mutable_extra_cols()->Reserve(cols.size());
+ for (uint32_t col : cols) {
+ CreateColumn(ret->mutable_extra_cols()->Add(), col);
+ }
+ return cols_copy;
+}
+
+void GenerateNumericLit(NumericLiteral* nl) {
+ for (int i = 0; i < RandInt(1, 20); i++) {
+ nl->add_digits(RandInt(0, 9));
+ }
+ nl->set_decimal_point(true);
+ for (int i = 0; i < RandInt(1, 20); i++) {
+ nl->add_dec_digits(RandInt(0, 9));
+ }
+}
+
+void GenerateLiteralValue(LiteralValue* ret,
+ CastTypeName::CastTypeNameEnum type) {
+ if (RandInt(1, 10) == 1) {
+ ret->set_special_val(RANDOM_ENUM(LiteralValue, SpecialVal));
+ return;
+ }
+
+ if (type == CastTypeName::INTEGER ||
+ (type == CastTypeName::NUMERIC && RandInt(1, 2) == 1)) {
+ if (RandInt(1, 3) == 1)
+ ret->set_num_lit((int64_t)RandInt(1, 3));
+ else
+ ret->set_num_lit((int64_t)RandUint64());
+ } else if (type == CastTypeName::TEXT) {
+ if (RandInt(1, 3) == 1)
+ ret->set_string_lit("a");
+ else
+ // string literals too often have unreadable chars, so instead of rand
+ // bytes just use a couple extra #'s
+ ret->set_string_lit("#####");
+ } else if (type == CastTypeName::BLOB) {
+ if (RandInt(1, 3) == 1)
+ ret->set_blob_lit("a");
+ else
+ ret->set_blob_lit(RandBytesAsString(5));
+ } else if (type == CastTypeName::REAL) {
+ GenerateNumericLit(ret->mutable_numeric_lit());
+ } else {
+ ret->set_special_val(RANDOM_ENUM(LiteralValue, SpecialVal));
+ }
+}
+
+void GenerateValuesStatement(ValuesStatement* v,
+ i::Table* table,
+ std::set<uint32_t> cols) {
+ int rand_num_values = RandInt(1, 10);
+ if (rand_num_values > 1)
+ v->mutable_extra_expr_lists()->Reserve(rand_num_values - 1);
+ for (int i = 0; i < rand_num_values; i++) {
+ ExprList* el;
+ if (i == 0) {
+ el = v->mutable_expr_list();
+ } else {
+ el = v->mutable_extra_expr_lists()->Add();
+ }
+ auto it = cols.begin();
+ GenerateLiteralValue(el->mutable_expr()->mutable_lit_val(),
+ table->col_types[*it]);
+ it++;
+ el->mutable_extra_exprs()->Reserve(cols.size() - 1);
+ for (size_t i = 0; i < cols.size() - 1; i++) {
+ GenerateLiteralValue(el->mutable_extra_exprs()->Add()->mutable_lit_val(),
+ table->col_types[*it]);
+ it++;
+ }
+ }
+}
+
+void GenerateWhereStatement(WhereStatement* where,
+ i::Schema* schema,
+ i::Table* table,
+ bool join = false) {
+ BinaryExpr* we = where->mutable_expr()
+ ->mutable_expr()
+ ->mutable_comp_expr()
+ ->mutable_binary_expr();
+
+ // TODO(mpdenton) exclude joins for now.
+ if (!join && table->index_exprs.size() != 0 && RandInt(1, 5) >= 4) {
+ // Use an indexed expression
+ *we->mutable_lhs() =
+ *table->index_exprs[RandInt(0, table->index_exprs.size() - 1)];
+ we->set_op(BINOP_LEQ);
+ GenerateLiteralValue(we->mutable_rhs()->mutable_lit_val(),
+ CastTypeName::NUMERIC);
+ return;
+ }
+
+ // Otherwise just use a simple predicate
+ uint32_t col = RandInt(0, table->num_columns - 1);
+ ExprSchemaTableColumn* stc =
+ we->mutable_lhs()->mutable_comp_expr()->mutable_expr_stc();
+ CreateColumn(stc->mutable_col(), col);
+ if (join)
+ CreateTableFromUint32(stc->mutable_table(), table->table_num);
+ if (table->col_types[col] == CastTypeName::BLOB) {
+ we->set_op(BINOP_NOTEQ);
+ we->mutable_rhs()->mutable_lit_val()->set_special_val(
+ LiteralValue::VAL_NULL);
+ } else if (table->col_types[col] == CastTypeName::TEXT) {
+ we->set_op(BINOP_REGEXP);
+ we->mutable_rhs()->mutable_lit_val()->set_string_lit(".*");
+ } else {
+ we->set_op(BINOP_LEQ);
+ we->mutable_rhs()->mutable_lit_val()->set_num_lit(RandUint64());
+ }
+}
+
+void GenerateInsertion(Insert* i, i::Schema* schema, i::Table* table) {
+ // TODO(mpdenton) generate With statement
+ // i->set_insert_type(RANDOM_ENUM(Insert, InsertType));
+
+ if (RandInt(1, 2) == 1)
+ i->set_insert_type(Insert::INSERT);
+ else
+ i->set_insert_type(Insert::REPLACE);
+
+ SchemaTableAsAlias* staa = i->mutable_staa();
+ CreateSchemaTable(staa->mutable_schema_table(), table);
+
+ if (RandInt(1, 5) >= 2) {
+ std::set<uint32_t> cols = GenerateColumnList(i->mutable_col_list(), table);
+ GenerateValuesStatement(i->mutable_values(), table, cols);
+ }
+}
+
+void GenerateUpdate(Update* u, i::Schema* schema, i::Table* table) {
+ SchemaTableAsAlias* staa = u->mutable_qtn()->mutable_staa();
+ CreateSchemaTable(staa->mutable_schema_table(), table);
+
+ ColEqualsExpr* cee = u->mutable_ucp2()->mutable_cee();
+ uint32_t col = RandInt(0, table->num_columns - 1);
+ CreateColumn(cee->mutable_col(), col);
+ GenerateLiteralValue(cee->mutable_expr()->mutable_lit_val(),
+ table->col_types[col]);
+
+ if (RandInt(1, 10) >= 2)
+ GenerateWhereStatement(u->mutable_ucp2()->mutable_where_stmt(), schema,
+ table);
+}
+
+void GenerateDelete(Delete* d, i::Schema* schema, i::Table* table) {
+ SchemaTableAsAlias* staa = d->mutable_qtn()->mutable_staa();
+ CreateSchemaTable(staa->mutable_schema_table(), table);
+
+ if (RandInt(1, 20) >= 2)
+ GenerateWhereStatement(d->mutable_where(), schema, table);
+}
+
+void GenerateCreateTable(CreateTable* ct, i::Schema* schema, i::Table* table) {
+ ct->set_if_not_exists(false);
+ if (RandInt(1, 4) == 1) {
+ ct->set_temp_modifier(TM_TEMP);
+ }
+
+ CreateSchemaTable(ct->mutable_schema_table(), table);
+
+ if (table->num_columns > 1)
+ ct->mutable_op1()->mutable_extra_col_defs()->Reserve(table->num_columns -
+ 1);
+
+ for (int i = 0; i < table->num_columns; i++) {
+ ColumnDef* col_def;
+ if (i == 0)
+ col_def = ct->mutable_op1()->mutable_col_def();
+ else
+ col_def = ct->mutable_op1()->mutable_extra_col_defs()->Add();
+ CreateColumn(col_def->mutable_col(), i);
+ col_def->mutable_type_name()->mutable_ctn()->set_type_enum(
+ table->col_types[i]);
+ // Set default values
+ GenerateLiteralValue(
+ col_def->add_col_constraints()->mutable_opt2()->mutable_lit_val(),
+ table->col_types[i]);
+ }
+}
+
+bool IsNumeric(CastTypeName::CastTypeNameEnum type) {
+ return (type == CastTypeName::NUMERIC || type == CastTypeName::INTEGER ||
+ type == CastTypeName::REAL);
+}
+
+Expr* GenerateJoinConstaints(i::Table* table,
+ const std::vector<i::Table*>& join_tables) {
+ std::vector<i::Table*> all_tables = join_tables;
+ all_tables.push_back(table);
+ // Decide some columns have to be equal
+ std::vector<std::pair<ExprSchemaTableColumn*, ExprSchemaTableColumn*>>
+ equal_cols;
+ std::vector<BinaryOperator> comparison_ops;
+
+ // Would be better if the num_constraints
+ do {
+ ExprSchemaTableColumn* a = new ExprSchemaTableColumn;
+ ExprSchemaTableColumn* b = new ExprSchemaTableColumn;
+ int table_index_a = RandInt(0, all_tables.size() - 1);
+ CreateTableFromUint32(a->mutable_table(),
+ all_tables[table_index_a]->table_num);
+ int table_index_b;
+ while ((table_index_b = RandInt(0, all_tables.size() - 1)) == table_index_a)
+ ;
+ CreateTableFromUint32(b->mutable_table(),
+ all_tables[table_index_b]->table_num);
+
+ uint32_t col_a = RandInt(0, all_tables[table_index_a]->num_columns - 1);
+ uint32_t col_b = RandInt(0, all_tables[table_index_b]->num_columns - 1);
+ CreateColumn(a->mutable_col(), col_a);
+ CreateColumn(b->mutable_col(), col_b);
+
+ equal_cols.push_back({a, b});
+
+ // If both columns are numeric, small chance of using a comparison op
+ // instead.
+ if (IsNumeric(all_tables[table_index_a]->col_types[col_a]) &&
+ IsNumeric(all_tables[table_index_b]->col_types[col_b]) &&
+ RandInt(1, 2) == 1)
+ comparison_ops.push_back(BINOP_LEQ);
+ else
+ comparison_ops.push_back(BINOP_EQ);
+ } while (RandInt(1, 3) >= 2);
+
+ // Actually generate the expressions.
+ Expr* initial_expr = new Expr;
+ Expr* curr_expr = initial_expr;
+ for (size_t i = 0; i < equal_cols.size() - 1; i++) {
+ BinaryExpr* bin_expr = CreateDefaultCompExpr(curr_expr->mutable_comp_expr())
+ ->mutable_binary_expr();
+ BinaryExpr* lhs_bin_expr =
+ bin_expr->mutable_lhs()->mutable_comp_expr()->mutable_binary_expr();
+ lhs_bin_expr->mutable_lhs()->mutable_comp_expr()->set_allocated_expr_stc(
+ equal_cols[i].first);
+ lhs_bin_expr->set_op(comparison_ops[i]);
+ lhs_bin_expr->mutable_rhs()->mutable_comp_expr()->set_allocated_expr_stc(
+ equal_cols[i].second);
+
+ if (RandInt(1, 2) == 1)
+ bin_expr->set_op(BINOP_AND);
+ else
+ bin_expr->set_op(BINOP_OR);
+
+ curr_expr = bin_expr->mutable_rhs();
+ }
+ // Finish off final expr
+ size_t last_index = equal_cols.size() - 1;
+ BinaryExpr* bin_expr = CreateDefaultCompExpr(curr_expr->mutable_comp_expr())
+ ->mutable_binary_expr();
+ bin_expr->mutable_lhs()->mutable_comp_expr()->set_allocated_expr_stc(
+ equal_cols[last_index].first);
+ bin_expr->set_op(comparison_ops[last_index]);
+ bin_expr->mutable_rhs()->mutable_comp_expr()->set_allocated_expr_stc(
+ equal_cols[last_index].second);
+
+ return initial_expr;
+}
+
+void GenerateFromStatement(FromStatement* from,
+ i::Schema* schema,
+ i::Table* table,
+ const std::vector<i::Table*>& join_tables) {
+ // TODO(mpdenton) join statements?
+ if (join_tables.size() == 0) {
+ SchemaTableAsAlias* staa =
+ from->mutable_tos3()->add_tos_list()->mutable_qtn()->mutable_staa();
+ CreateSchemaTable(staa->mutable_schema_table(), table);
+ return;
+ }
+
+ // Write some nice joins.
+ CreateSchemaTable(from->mutable_tos3()
+ ->mutable_join_clause()
+ ->mutable_tos()
+ ->mutable_qtn()
+ ->mutable_staa()
+ ->mutable_schema_table(),
+ table);
+
+ // For each table in join_tables, write a JoinClauseCore that inner joins
+ // with some comparisons between any two columns
+ for (i::Table* curr_table : join_tables) {
+ JoinClauseCore* jcc =
+ from->mutable_tos3()->mutable_join_clause()->add_clauses();
+
+ // Just generate inner joins, fuzzer should be smart enough to find other
+ // join types.
+ jcc->mutable_join_op()->set_join_type(JoinOperator::INNER);
+
+ // Fill in the join clause core with the current table
+ CreateSchemaTable(jcc->mutable_tos()
+ ->mutable_qtn()
+ ->mutable_staa()
+ ->mutable_schema_table(),
+ curr_table);
+
+ jcc->mutable_join_constraint()->set_allocated_on_expr(
+ GenerateJoinConstaints(table, join_tables));
+ }
+
+ // TODO(mpdenton) multiple Tables with aliases?
+}
+
+void GenerateGroupByStatement(GroupByStatement* gbs,
+ i::Schema* schema,
+ i::Table* table,
+ bool join = false) {
+ ExprSchemaTableColumn* stc = gbs->mutable_exprs()
+ ->mutable_expr()
+ ->mutable_comp_expr()
+ ->mutable_expr_stc();
+ // fine to just pick a single random column.
+ CreateColumn(stc->mutable_col(), RandInt(0, table->num_columns - 1));
+ if (join)
+ CreateTableFromUint32(stc->mutable_table(), table->table_num);
+}
+
+std::set<uint32_t> GenerateSelectStatementCore(
+ SelectStatementCore* ssc,
+ i::Schema* schema,
+ i::Table* table,
+ std::vector<i::Table*> join_tables) {
+ if (RandInt(1, 2) == 1) {
+ ssc->set_s_or_d(SelectStatementCore::SELECT);
+ } else {
+ ssc->set_s_or_d(SelectStatementCore::SELECT_DISTINCT);
+ }
+
+ std::set<uint32_t> cols;
+ if (join_tables.size() > 0) {
+ // This is a join. Add columns from all the tables and include the table.
+ for (size_t i = 0; i <= join_tables.size(); i++) {
+ i::Table* table2;
+ if (i == join_tables.size())
+ table2 = table;
+ else
+ table2 = join_tables[i];
+
+ cols = GetRandomNums(RandInt(1, table2->num_columns - 1),
+ table2->num_columns - 1);
+ for (uint32_t col : cols) {
+ ExprSchemaTableColumn* stc = ssc->add_result_columns()
+ ->mutable_eca()
+ ->mutable_expr()
+ ->mutable_comp_expr()
+ ->mutable_expr_stc();
+ CreateColumn(stc->mutable_col(), col);
+ CreateTableFromUint32(stc->mutable_table(), table2->table_num);
+ }
+ }
+ } else {
+ if (RandInt(1, 2) == 1) {
+ cols = GetRandomNums(RandInt(1, table->num_columns - 1),
+ table->num_columns - 1);
+ for (uint32_t col : cols) {
+ CreateColumn(ssc->add_result_columns()->mutable_col(), col);
+ }
+ } else {
+ AggregateFn* af = ssc->add_result_columns()
+ ->mutable_eca()
+ ->mutable_expr()
+ ->mutable_comp_expr()
+ ->mutable_fn_expr()
+ ->mutable_aggregate_fn();
+ af->set_fn_name(RANDOM_ENUM(AggregateFn, FnName));
+ af->set_distinct((bool)RandInt(0, 1));
+ CreateColumn(af->mutable_col1(), RandInt(0, table->num_columns - 1));
+ }
+ }
+
+ bool join = join_tables.size() > 0;
+
+ GenerateFromStatement(ssc->mutable_from(), schema, table, join_tables);
+
+ if (RandInt(1, 3) >= 2) {
+ GenerateWhereStatement(ssc->mutable_where(), schema, table, join);
+ }
+
+ if (RandInt(1, 3) == 1) {
+ GenerateGroupByStatement(ssc->mutable_groupby(), schema, table, join);
+ }
+
+ return cols;
+}
+
+void GenerateOrderByStatement(OrderByStatement* obs,
+ i::Schema* schema,
+ i::Table* table,
+ std::set<uint32_t> cols_tmp,
+ bool join = false) {
+ // TODO(mpdenton) exclude joins for now.
+ if (!join && table->index_exprs.size() != 0 && RandInt(1, 5) >= 4) {
+ // Use an indexed expression
+ *obs->mutable_ord_term()->mutable_expr() =
+ *table->index_exprs[RandInt(0, table->index_exprs.size() - 1)];
+ return;
+ }
+
+ std::set<uint32_t> cols =
+ GetRandomSubset(cols_tmp, RandInt(1, cols_tmp.size() - 1));
+
+ std::vector<uint32_t> v;
+ std::copy(cols.begin(), cols.end(), std::back_inserter(v));
+ std::shuffle(v.begin(), v.end(), GetRandom());
+
+ i::Table* table_in_col = join ? table : nullptr;
+ auto it = v.begin();
+ CreateColumnExpr(obs->mutable_ord_term()->mutable_expr(), *it, table_in_col);
+ it++;
+ for (size_t i = 0; i < v.size() - 1; i++) {
+ CreateColumnExpr(obs->add_extra_ord_terms()->mutable_expr(), *it,
+ table_in_col);
+ it++;
+ }
+}
+
+void GenerateSelect(Select* s,
+ i::Schema* schema,
+ i::Table* table,
+ std::vector<i::Table*> join_tables = {}) {
+ // Could be empty.
+ std::set<uint32_t> cols = GenerateSelectStatementCore(
+ s->mutable_select_core(), schema, table, join_tables);
+ // TODO(mpdenton)
+
+ if (RandInt(1, 2) == 1) {
+ GenerateOrderByStatement(s->mutable_orderby(), schema, table,
+ GetRandomNums(RandInt(1, table->num_columns - 1),
+ table->num_columns - 1),
+ join_tables.size() > 0);
+ }
+
+ // Limits are not very interesting from a corpus standpoint.
+}
+
+void InsertUpdateSelectOrDelete(SQLQuery* q,
+ i::Schema* main_schema,
+ int table_num) {
+ int rand = RandInt(1, 4);
+ if (rand == 1) {
+ GenerateInsertion(q->mutable_insert(), main_schema,
+ &main_schema->tables[table_num]);
+ } else if (rand == 2) {
+ GenerateDelete(q->mutable_delete_(), main_schema,
+ &main_schema->tables[table_num]);
+ } else if (rand == 3) {
+ GenerateUpdate(q->mutable_update(), main_schema,
+ &main_schema->tables[table_num]);
+ } else if (rand == 4) {
+ GenerateSelect(q->mutable_select(), main_schema,
+ &main_schema->tables[table_num]);
+ }
+}
+
+inline ExprSchemaTableColumn* GetSTC(Expr* expr) {
+ return CreateDefaultCompExpr(expr->mutable_comp_expr())->mutable_expr_stc();
+}
+
+Expr* GenerateCreateIndex(CreateIndex* ci,
+ i::Schema* schema,
+ i::Table* table,
+ std::set<uint32_t>& free_index_nums) {
+ CHECK(free_index_nums.size() != 0);
+
+ std::set<uint32_t> index_num_set = GetRandomSubset(free_index_nums, 1);
+ uint32_t index_num = *index_num_set.begin();
+ ci->mutable_index()->set_index(index_num);
+ free_index_nums.erase(index_num);
+ CreateTableFromUint32(ci->mutable_table(), table->table_num);
+
+ if (RandInt(1, 3) >= 2) {
+ Expr* expr = new Expr;
+ int expr_type = RandInt(1, 2);
+ if (expr_type == 1) {
+ // Select two random columns of the table, add or subtract them.
+ uint32_t col1 = RandInt(0, table->num_columns - 1);
+ uint32_t col2 = RandInt(0, table->num_columns - 1);
+
+ BinaryExpr* bin_expr = CreateDefaultCompExpr(expr->mutable_comp_expr())
+ ->mutable_binary_expr();
+ ExprSchemaTableColumn* lhs_stc = GetSTC(bin_expr->mutable_lhs());
+ ExprSchemaTableColumn* rhs_stc = GetSTC(bin_expr->mutable_rhs());
+
+ CreateColumn(lhs_stc->mutable_col(), col1);
+ CreateColumn(rhs_stc->mutable_col(), col2);
+
+ // TODO(mpdenton) perhaps set the tables here? The tables must not be set
+ // for CREATE INDEX, but MUST be set for JOINs to avoid ambiguous columns.
+ // Does it still count as the same expression if the table is included in
+ // the JOIN but not the CREATE INDEX?
+ if (RandInt(1, 2) == 1)
+ bin_expr->set_op(BINOP_PLUS);
+ else
+ bin_expr->set_op(BINOP_MINUS);
+ } else if (expr_type == 2) {
+ // Or, apply abs to a single column.
+ OneArgFn* oaf = CreateDefaultCompExpr(expr->mutable_comp_expr())
+ ->mutable_fn_expr()
+ ->mutable_simple_fn()
+ ->mutable_one_arg_fn();
+ oaf->set_fn_enum(OneArgFn::ABS);
+ uint32_t col = RandInt(0, table->num_columns - 1);
+ ExprSchemaTableColumn* stc = GetSTC(oaf->mutable_arg1());
+ CreateColumn(stc->mutable_col(), col);
+ // TODO(mpdenton) see above about setting tables.
+ }
+
+ ci->mutable_icol_list()->mutable_indexed_col()->set_allocated_expr(expr);
+
+ // Make a copy that isn't owned by another protobuf
+ Expr* ret_expr = new Expr;
+ *ret_expr = *expr;
+
+ return ret_expr;
+ }
+
+ IndexedColumnList* icol_list = ci->mutable_icol_list();
+ std::set<uint32_t> cols =
+ GetRandomNums(RandInt(1, table->num_columns - 1), table->num_columns - 1);
+ bool first;
+ for (uint32_t col : cols) {
+ IndexedColumn* icol;
+ if (first) {
+ first = false;
+ icol = icol_list->mutable_indexed_col();
+ } else {
+ icol = icol_list->add_extra_indexed_cols();
+ }
+ CreateColumn(icol->mutable_col(), col);
+ }
+
+ return NULL;
+}
+
+namespace {
+enum class GenQueryInstr {
+ SUCCESS,
+ MOVE_ON,
+ TRY_AGAIN,
+};
+}
+
+template <typename T>
+void GenQueries(SQLQueries& queries,
+ int min,
+ int max,
+ bool txn,
+ int num_tables,
+ T gen) {
+ queries.mutable_extra_queries()->Reserve(queries.extra_queries_size() + max +
+ 2);
+ SQLQuery* q;
+ if (txn) {
+ q = new SQLQuery;
+ q->mutable_begin_txn(); // constructs a begin txn.
+ queries.mutable_extra_queries()->AddAllocated(q);
+ }
+ for (int i = 0; i < num_tables; i++) {
+ for (int j = 0; j < RandInt(min, max); j++) {
+ // continue; // TODO(mpdenton)
+ q = new SQLQuery;
+ GenQueryInstr success = gen(q, i);
+ // Try again
+ if (success != GenQueryInstr::SUCCESS) {
+ if (success == GenQueryInstr::TRY_AGAIN)
+ j--;
+ delete q;
+ continue;
+ }
+ queries.mutable_extra_queries()->AddAllocated(q);
+ }
+ }
+ if (txn) {
+ q = new SQLQuery;
+ q->mutable_commit_txn(); // constructs a begin txn.
+ queries.mutable_extra_queries()->AddAllocated(q);
+ }
+}
+
+void FirstCreateTable(CreateTable* ct) {
+ ct->mutable_schema_table()->mutable_schema_name()->set_schema(5);
+ ct->mutable_schema_table()->mutable_schema_name()->set_main(false);
+ ct->mutable_schema_table()->mutable_schema_name()->set_temp(false);
+ ct->mutable_schema_table()->mutable_table_name()->set_table(0);
+ ct->set_if_not_exists(false);
+ ct->mutable_op();
+}
+
+SQLQueries GenCorpusEntry() {
+ // The answer is no, I free nothing at any point.
+
+ // Create the tables, and attached databases with tables
+ // Schema schemas[i::kNumSchemas];
+ // for (int i = 0; i < i::kNumSchemas; i++) {
+ // // schemas[i] = Schema{
+ // // .num_tables = RandInt(1, 5);
+ // // };
+ // }
+ SQLQueries queries;
+ FirstCreateTable(queries.mutable_create_table());
+
+ // Just get rid of the first CreateTable, it will error out but not screw up
+ // anything below
+
+ i::Schema main_schema;
+ main_schema.num_tables = RandInt(1, 5);
+
+ std::set<uint32_t> free_index_nums;
+ for (uint32_t i = 0; i < 10; i++) {
+ free_index_nums.insert(i);
+ }
+
+ GenQueries(
+ queries, 1, 1, false, main_schema.num_tables, [&](SQLQuery* q, int i) {
+ i::Table t = i::Table{
+ .table_num = i,
+ .num_columns = RandInt(1, 8),
+ };
+ for (int j = 0; j < t.num_columns; j++) {
+ t.col_types.push_back(RANDOM_ENUM(CastTypeName, CastTypeNameEnum));
+ }
+ main_schema.tables.push_back(std::move(t));
+ GenerateCreateTable(q->mutable_create_table(), &main_schema,
+ &main_schema.tables[i]);
+ return GenQueryInstr::SUCCESS;
+ });
+
+ GenQueries(queries, kMinNumIndexes, kMaxNumIndexes, false,
+ main_schema.num_tables, [&](SQLQuery* q, int i) {
+ if (free_index_nums.size() == 0)
+ return GenQueryInstr::MOVE_ON;
+
+ Expr* index_expr =
+ GenerateCreateIndex(q->mutable_create_index(), &main_schema,
+ &main_schema.tables[i], free_index_nums);
+ if (index_expr)
+ main_schema.tables[i].index_exprs.emplace_back(index_expr);
+ return GenQueryInstr::SUCCESS;
+ });
+
+ // Generate a bunch of inserts in a transaction (for speed)
+ GenQueries(queries, kMinNumInsertions, kMaxNumInsertions, true,
+ main_schema.num_tables, [&](SQLQuery* q, int i) {
+ GenerateInsertion(q->mutable_insert(), &main_schema,
+ &main_schema.tables[i]);
+ return GenQueryInstr::SUCCESS;
+ });
+
+ // Generate a bunch of interesting selects with GroupBys, OrderBys, aggregate
+ // functions, etc.
+ GenQueries(queries, kMinNumSelects, kMaxNumSelects, false,
+ main_schema.num_tables, [&](SQLQuery* q, int i) {
+ GenerateSelect(q->mutable_select(), &main_schema,
+ &main_schema.tables[i]);
+ return GenQueryInstr::SUCCESS;
+ });
+
+ // Generate lots of interesting JOINs.
+ if (main_schema.num_tables > 1) {
+ GenQueries(queries, kMinNumJoins, kMaxNumJoins, false,
+ main_schema.num_tables, [&](SQLQuery* q, int i) {
+ std::set<uint32_t> tables =
+ GetRandomNums(RandInt(1, main_schema.num_tables - 1),
+ main_schema.num_tables - 1);
+ tables.erase((uint32_t)i);
+ if (tables.size() == 0) {
+ // try again
+ return GenQueryInstr::TRY_AGAIN;
+ }
+ std::vector<i::Table*> tables_p;
+ for (uint32_t t : tables) {
+ tables_p.push_back(&main_schema.tables[t]);
+ }
+ GenerateSelect(q->mutable_select(), &main_schema,
+ &main_schema.tables[i], tables_p);
+ return GenQueryInstr::SUCCESS;
+ });
+ }
+
+ // Generate a bunch of interesting updates.
+ GenQueries(queries, kMinNumUpdates, kMaxNumUpdates, true,
+ main_schema.num_tables, [&](SQLQuery* q, int i) {
+ GenerateUpdate(q->mutable_update(), &main_schema,
+ &main_schema.tables[i]);
+ return GenQueryInstr::SUCCESS;
+ });
+
+ // Generate interesting deletes.
+ GenQueries(queries, kMinNumDeletes, kMaxNumDeletes, true,
+ main_schema.num_tables, [&](SQLQuery* q, int i) {
+ GenerateDelete(q->mutable_delete_(), &main_schema,
+ &main_schema.tables[i]);
+ return GenQueryInstr::SUCCESS;
+ });
+
+ // Do everything except joins.
+ GenQueries(queries, kMinNumOthers, kMaxNumOthers, true,
+ main_schema.num_tables, [&](SQLQuery* q, int i) {
+ InsertUpdateSelectOrDelete(q, &main_schema, i);
+ return GenQueryInstr::SUCCESS;
+ });
+
+ return queries;
+}
+
+int main(int argc, char** argv) {
+ base::CommandLine cl(argc, argv);
+
+ int num_entries;
+ if (!cl.HasSwitch("num_entries"))
+ LOG(FATAL) << "num_entries not specified.";
+ if (!base::StringToInt(cl.GetSwitchValueASCII("num_entries"), &num_entries))
+ LOG(FATAL) << "num_entries not parseable as an int.";
+
+ bool to_stdout = true;
+ base::FilePath dir_path;
+ if (cl.HasSwitch("corpus_dir")) {
+ to_stdout = false;
+
+ dir_path = cl.GetSwitchValuePath("corpus_dir");
+ base::File dir(dir_path, base::File::FLAG_OPEN | base::File::FLAG_READ);
+ if (!dir.IsValid())
+ LOG(FATAL) << "corpus_dir " << dir_path << " could not be opened.";
+
+ base::File::Info dir_info;
+ if (!dir.GetInfo(&dir_info))
+ LOG(FATAL) << "Could not get corpus_dir " << dir_path << " file info.";
+ if (!dir_info.is_directory)
+ LOG(FATAL) << "corpus_dir " << dir_path << " is not a directory.";
+ } else {
+ LOG(INFO) << "corpus_dir not specified, writing serialized output to "
+ "stdout instead.";
+ }
+
+ int last_index = 0;
+ for (int total = 0; total < num_entries; total++) {
+ SQLQueries queries = GenCorpusEntry();
+ std::vector<std::string> queries_str;
+ for (int i = 0; i < queries.extra_queries_size(); i++) {
+ queries_str.push_back(
+ sql_fuzzer::SQLQueryToString(queries.extra_queries(i)));
+ if (to_stdout || ::getenv("LPM_DUMP_NATIVE_INPUT"))
+ std::cout << queries_str[i] << std::endl;
+ }
+
+ if (getenv("PRINT_SQLITE_ERRORS"))
+ sql_fuzzer::RunSqlQueries(queries_str, ::getenv("LPM_SQLITE_TRACE"));
+
+ // If we just want to print to stdout, skip the directory stuff below.
+ if (to_stdout)
+ continue;
+
+ // It's okay to serialize without all required fields, as LPM uses
+ // ParsePartial* as well.
+ std::string proto_text;
+ if (!queries.SerializePartialToString(&proto_text))
+ LOG(FATAL) << "Could not serialize queries to string.";
+
+ bool found_file = false;
+ while (!found_file) {
+ base::FilePath file_path =
+ dir_path.Append("corpus_queries" + std::to_string(last_index));
+ base::File file(file_path,
+ base::File::FLAG_CREATE | base::File::FLAG_WRITE);
+ if (file.created()) {
+ found_file = true;
+ if (file.Write(0, proto_text.data(), proto_text.length()) < 0) {
+ LOG(FATAL) << "Failed to write to file " << file_path;
+ }
+ }
+ last_index++;
+ }
+ }
+
+ return 0;
+}
diff --git a/chromium/third_party/sqlite/fuzz/sql_multithreaded_fuzzer.cc b/chromium/third_party/sqlite/fuzz/sql_multithreaded_fuzzer.cc
new file mode 100644
index 00000000000..000e4afa42f
--- /dev/null
+++ b/chromium/third_party/sqlite/fuzz/sql_multithreaded_fuzzer.cc
@@ -0,0 +1,91 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Unused because SQLite is so serialized and concurrency-unfriendly that this
+// really wouldn't test anything.
+
+#include <condition_variable>
+#include <cstdlib>
+#include <iostream>
+#include <mutex>
+#include <string>
+#include <thread>
+#include <vector>
+
+#include "testing/libfuzzer/proto/lpm_interface.h"
+#include "third_party/sqlite/fuzz/disabled_queries_parser.h"
+#include "third_party/sqlite/fuzz/sql_query_grammar.pb.h"
+#include "third_party/sqlite/fuzz/sql_query_proto_to_string.h"
+#include "third_party/sqlite/fuzz/sql_run_queries.h"
+#include "third_party/sqlite/sqlite3.h"
+
+using namespace sql_query_grammar;
+
+namespace {
+constexpr int kNumThreads = 4; // Must change with MultipleSQLQueries protobuf.
+}
+
+DEFINE_BINARY_PROTO_FUZZER(const MultipleSQLQueries& multiple_sql_queries) {
+ char* skip_queries = ::getenv("SQL_SKIP_QUERIES");
+ if (skip_queries) {
+ sql_fuzzer::SetDisabledQueries(
+ sql_fuzzer::ParseDisabledQueries(skip_queries));
+ }
+
+ assert(multiple_sql_queries.GetDescriptor()->field_count() == kNumThreads);
+
+ sqlite3* db = sql_fuzzer::InitConnectionForFuzzing();
+ if (!db)
+ return;
+
+ if (::getenv("LPM_SQLITE_TRACE")) {
+ sql_fuzzer::EnableSqliteTracing(db);
+ }
+
+ std::vector<std::string> query_strs[kNumThreads];
+ query_strs[0] = sql_fuzzer::SQLQueriesToVec(multiple_sql_queries.queries1());
+ query_strs[1] = sql_fuzzer::SQLQueriesToVec(multiple_sql_queries.queries2());
+ query_strs[2] = sql_fuzzer::SQLQueriesToVec(multiple_sql_queries.queries3());
+ query_strs[3] = sql_fuzzer::SQLQueriesToVec(multiple_sql_queries.queries4());
+
+ if (::getenv("LPM_DUMP_NATIVE_INPUT")) {
+ std::cout << "_________________________" << std::endl;
+ for (int i = 0; i < kNumThreads; i++) {
+ std::cout << "Thread " << i << ":" << std::endl;
+ for (std::string query : query_strs[i]) {
+ if (query == ";")
+ continue;
+ std::cout << query << std::endl;
+ }
+ }
+ std::cout << "------------------------" << std::endl;
+ }
+
+ int num_threads_started = 0;
+ std::mutex m;
+ std::condition_variable cv;
+
+ std::vector<std::thread> threads;
+
+ auto to_run = [&](std::vector<std::string> queries) {
+ // Wait for all the threads to start.
+ std::unique_lock<std::mutex> lk(m);
+ num_threads_started++;
+ cv.notify_all();
+ cv.wait(lk, [&] { return num_threads_started == kNumThreads; });
+ m.unlock();
+
+ sql_fuzzer::RunSqlQueriesOnConnection(db, queries);
+ };
+
+ for (int i = 0; i < kNumThreads; i++) {
+ threads.emplace_back(to_run, query_strs[i]);
+ }
+
+ for (int i = 0; i < kNumThreads; i++) {
+ threads[i].join();
+ }
+
+ sql_fuzzer::CloseConnection(db);
+}
diff --git a/chromium/third_party/sqlite/fuzz/sql_printf_fuzzer.cc b/chromium/third_party/sqlite/fuzz/sql_printf_fuzzer.cc
new file mode 100644
index 00000000000..eb0dafb5c06
--- /dev/null
+++ b/chromium/third_party/sqlite/fuzz/sql_printf_fuzzer.cc
@@ -0,0 +1,31 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <cstdlib>
+#include <iostream>
+#include <string>
+#include <vector>
+
+#include "testing/libfuzzer/proto/lpm_interface.h"
+#include "third_party/sqlite/fuzz/sql_query_grammar.pb.h"
+#include "third_party/sqlite/fuzz/sql_query_proto_to_string.h"
+#include "third_party/sqlite/fuzz/sql_run_queries.h"
+
+using namespace sql_query_grammar;
+
+DEFINE_BINARY_PROTO_FUZZER(const Printf& sql_printf) {
+ std::string printf_str = sql_fuzzer::PrintfToString(sql_printf);
+ // Convert printf command into runnable SQL query.
+ printf_str = "SELECT " + printf_str + ";";
+
+ if (::getenv("LPM_DUMP_NATIVE_INPUT")) {
+ std::cout << "_________________________" << std::endl;
+ std::cout << printf_str << std::endl;
+ std::cout << "------------------------" << std::endl;
+ }
+
+ std::vector<std::string> queries;
+ queries.push_back(printf_str);
+ sql_fuzzer::RunSqlQueries(queries, ::getenv("LPM_SQLITE_TRACE"));
+}
diff --git a/chromium/third_party/sqlite/fuzz/sql_queries.proto b/chromium/third_party/sqlite/fuzz/sql_queries.proto
new file mode 100644
index 00000000000..d12ebe7b981
--- /dev/null
+++ b/chromium/third_party/sqlite/fuzz/sql_queries.proto
@@ -0,0 +1,23 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+syntax = "proto2";
+
+import "sql_query_grammar.proto";
+
+package sql_query_grammar;
+
+message MultipleSQLQueries {
+ required SQLQueries queries1 = 1;
+ required SQLQueries queries2 = 2;
+ required SQLQueries queries3 = 3;
+ required SQLQueries queries4 = 4;
+}
+
+message SQLQueries {
+ // Always have a CreateTable first because otherwise the queries are
+ // pointless.
+ required CreateTable create_table = 1;
+ repeated SQLQuery extra_queries = 2;
+}
diff --git a/chromium/third_party/sqlite/fuzz/sql_query_grammar.proto b/chromium/third_party/sqlite/fuzz/sql_query_grammar.proto
new file mode 100644
index 00000000000..ceb67799cd7
--- /dev/null
+++ b/chromium/third_party/sqlite/fuzz/sql_query_grammar.proto
@@ -0,0 +1,1663 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+syntax = "proto2";
+
+import "icu_codes.proto";
+
+package sql_query_grammar;
+
+/* Generates SQL queries in protobuf format, using enums for the tables and
+ integers for column names. The column name integers will be wrapped.
+ Relies heavily on the sqlite grammar from here:
+ https://www.sqlite.org/lang.html
+
+ Yes, it is all in one big blobby proto file, as everything is extremely
+ mutually recursive and there is no such thing as circular imports or forward
+ declarations in protobuf.
+*/
+
+message SQLQuery {
+ // No comments generated, nor EXPLAIN queries
+ oneof query_oneof {
+ Select select = 1;
+ CreateTable create_table = 2;
+ Insert insert = 3;
+ Delete delete = 4;
+ CreateFTS3Table fts3_table = 5;
+ FTS3SpecificQuery fts_query = 6;
+ BeginTransaction begin_txn = 7;
+ CommitTransaction commit_txn = 8;
+ RollbackStatement rollback_stmt = 9;
+ CreateSavePoint create_save_point = 10;
+ ReleaseSavePoint release_save_point = 11;
+ Analyze analyze = 12;
+ Vacuum vacuum = 13;
+ Pragma pragma = 14;
+ Update update = 15;
+ CreateIndex create_index = 16;
+ CreateView create_view = 17;
+ CreateTrigger create_trigger = 18;
+ ReIndex reindex = 19;
+ Drop drop = 20;
+ AlterTable alter_table = 21;
+ AttachDatabase attach_db = 22;
+ DetachDatabase detach_db = 23;
+ FTS3HiddenTableInsert fts3_insert = 24;
+ FTS3HiddenTableUpdate fts3_update = 25;
+ FTS3HiddenTableDelete fts3_delete = 26;
+ }
+}
+
+// ~~~~FTS3~~~
+
+message FTS3SpecificQuery {
+ oneof query_oneof {
+ FTS3SpecialCommand command = 1;
+ // The following exists to increase the probability of hitting MATCH
+ // queries.
+ FTS3SelectMatch select = 2;
+ }
+}
+
+message FTS3SelectMatch {
+ // SELECT * FROM |table| WHERE |col| MATCH |match_pattern|
+ required FTS3Table table = 1;
+ required Column col = 2;
+ required FTS3MatchFormat match_pattern = 3;
+}
+
+message FTS3SpecialCommand {
+ // INSERT INTO xyz(xyz) VALUES('optimize');
+ // is a special command that optimizes FTS table xyz.
+ required FTS3Table table = 1;
+ enum Command {
+ OPTIMIZE = 0;
+ REBUILD = 1;
+ INTEGRITY_CHECK = 2;
+ MERGE = 3;
+ AUTOMERGE = 4;
+ }
+ required Command command = 2;
+ required uint32 val1 = 3;
+ required uint32 val2 = 4;
+}
+
+message ICULocale {
+ required IsoLangCode iso_lang_code = 1;
+ // least significant 2 bytes will each be clamped to within 'A' and
+ // 'Z' and then concatenated together to form a country code.
+ required uint32 country_code = 2;
+ // TODO(mpdenton) generate anything else here? Will sqlite care?
+}
+
+enum TokenizerType {
+ TT_SIMPLE = 0;
+ TT_PORTER = 1;
+ TT_ICU = 2;
+ TT_UNICODE61 = 3; // FIXME in the future: remove_diacritics, separators,
+ // token_chars.... (not supported in Chrome)
+}
+
+// FIXME in the future: maybe also fuzz the tokenizer type/icu locales with
+// random strings???
+message CreateFTS3Table {
+ required bool if_not_exists = 1;
+ optional Schema schema = 6;
+ required FTS3Table table = 2;
+ optional ColumnList col_list = 3;
+ optional TokenizerType tokenizer_type = 4;
+ required ICULocale locale = 5; // used if tokenizer_type == TT_ICU.
+}
+
+message FTS3Table {
+ required uint32 table = 1;
+}
+
+// TODO(mpdenton) query by row id?
+
+message FTS3MatchFormat {
+ repeated FTS3MatchCompoundFormat ft = 1;
+}
+
+message FTS3MatchCompoundFormat {
+ required FTS3MatchFormatCore core = 1;
+ repeated FTS3CompoundAndCore compound_and_cores = 2;
+}
+
+message FTS3CompoundAndCore {
+ enum CompoundOp {
+ OR = 0;
+ // Chrome does not enable the enhanced query syntax. FIXME in the future.
+ // AND = 1;
+ // NOT = 2;
+ }
+ required CompoundOp op = 1;
+ required FTS3MatchFormatCore core = 2;
+}
+
+message FTS3MatchFormatCore {
+ oneof ft_oneof {
+ FTS3PhraseQuery pq = 1;
+ FTS3NearQuery nq = 2;
+ }
+ required FTS3MatchToken mt_fallback = 3;
+}
+
+message FTS3NearQuery {
+ // May generate into another NEAR query, this is fine.
+ required FTS3MatchFormatCore format_core1 = 1;
+ optional uint32 num_tokens_near = 2;
+ required FTS3MatchFormatCore format_core2 = 3;
+}
+
+message FTS3PhraseQuery {
+ required FTS3MatchToken mt = 1;
+ repeated FTS3MatchToken extra_mts = 2;
+}
+
+message FTS3MatchToken {
+ optional Column col = 1; // search in this column specifically
+ required bool negate = 4;
+ required string token = 2; // token (or prefix) to search for
+ required bool prefix = 3; // append star to end
+}
+
+// FIXME in the future: https://www.sqlite.org/fts3.html Section 8.2: Query
+// tokenizers themselves. Unsupported by Chrome.
+
+message FTS3OffsetsFn {
+ required FTS3Table table = 1;
+}
+
+message FTS3SnippetsFn {
+ required FTS3Table table = 1;
+ enum NumArgs {
+ A0 = 0;
+ A1 = 1;
+ A2 = 2;
+ A3 = 3;
+ A4 = 4;
+ A5 = 5;
+ }
+ required NumArgs num_optional_args = 2;
+ required string start_match = 3;
+ required string end_match = 4;
+ required string ellipses = 5;
+ optional uint32 col_number = 6; // capped by KMaxColumnNumber
+ required uint32 num_tokens = 7; // in [-64, 64].
+}
+
+message FTS3MatchInfoFn {
+ required FTS3Table table = 1;
+
+ // The following will be wrapped to any of the characters p,c,n,a,,l,s,x,y,b.
+ repeated uint32 chars = 2;
+}
+
+// FTS3 Auxiliary function format
+message FTS3AuxiliaryFn {
+ required FTS3OffsetsFn offsets_fallback = 1;
+ oneof fts_aux_fn_oneof {
+ FTS3SnippetsFn snippets = 2;
+ FTS3MatchInfoFn matchinfo = 3;
+ }
+}
+
+// Types of hidden tables in FTS3
+message FTS3HiddenTable {
+ enum HiddenTableVal {
+ // CONTENT = 0; // Taken care of in |Table|
+ SEGDIR = 1;
+ SEGMENTS = 2;
+ // stat and docsize are FTS4
+ }
+ required HiddenTableVal htv = 1;
+ required FTS3Table table = 2;
+}
+
+// The different columns that go into the FTS3 hidden tables above
+enum FTS3HiddenTableColumn {
+ FTS3_HT_BLOCKID = 0;
+ FTS3_HT_BLOCK = 1;
+ FTS3_HT_LEVEL = 2;
+ FTS3_HT_IDX = 3;
+ FTS3_HT_START_BLOCK = 4;
+ FTS3_HT_LEAVES_END_BLOCK = 5;
+ FTS3_HT_END_BLOCK = 6;
+ FTS3_HT_ROOT = 7;
+}
+
+// Some extra stuff to modify the FTS3 Hidden tables, only used for FTS3
+// Fuzzing.
+
+// Used to insert single values in.
+message FTS3HiddenTableInsert {
+ required FTS3HiddenTable fht = 1;
+ repeated FTS3HiddenTableColumnValue col_vals = 2;
+}
+
+message FTS3HiddenTableUpdate {
+ required FTS3HiddenTable fht = 1;
+ repeated FTS3HiddenTableColumnValue col_vals = 2;
+
+ // mini WHERE clause with some BinOp
+ optional FTS3HiddenTableColumn col_where = 3;
+ required BinaryOperator bin_op = 4;
+ required Expr comp_expr = 5;
+}
+
+message FTS3HiddenTableDelete {
+ required FTS3HiddenTable fht = 1;
+ optional FTS3HiddenTableColumn col_where = 2;
+ required BinaryOperator bin_op = 3;
+ required Expr comp_expr = 4;
+}
+
+message FTS3HiddenTableColumnValue {
+ required FTS3HiddenTableColumn col = 1;
+ required Expr expr = 2;
+}
+
+// ~~~~TRANSACTIONs~~~~
+// TODO(mpdenton) these could be meta-statements that enclose a bunch of other
+// statements. Is that worthwhile or should I just let the fuzzer generate them
+// haphazardly?
+message BeginTransaction {
+ enum TransactionType {
+ DEFERRED = 0;
+ IMMEDIATE = 1;
+ EXCLUSIVE = 2;
+ }
+ optional TransactionType type = 1;
+}
+
+message CommitTransaction {
+ enum CommitText {
+ COMMIT = 0;
+ END = 1;
+ COMMIT_TRANSACTION = 2;
+ END_TRANSACTION = 3;
+ }
+ required CommitText text = 1;
+}
+
+message SavePoint {
+ required uint32 savepoint_num = 1;
+}
+
+message RollbackStatement {
+ optional SavePoint save_point = 1;
+}
+
+message CreateSavePoint {
+ required SavePoint save_point = 1;
+}
+
+message ReleaseSavePoint {
+ required SavePoint save_point = 1;
+}
+
+// ~~~~ANALYZE~~~~
+message Analyze {
+ optional Schema schema_name = 1;
+ optional Table table_name = 2;
+ optional Index index_name = 3;
+}
+
+// ~~~~VACUUM~~~~
+message Vacuum {
+ optional Schema schema = 1;
+}
+
+// ~~~~PRAGMA~~~~
+message Pragma {
+ // FIXME in the future: full list here: https://www.sqlite.org/pragma.html
+ // These are the ones I've seen in Chrome
+ enum PragmaCommand {
+ // QUICK_CHECK = 0;
+ // INTEGRITY_CHECK = 1;
+ AUTO_VACUUM = 2;
+ WRITEABLE_SCHEMA = 3;
+ LOCKING_MODE = 4;
+ TEMP_STORE = 5;
+ PAGE_SIZE_ = 6;
+ TABLE_INFO = 7;
+ JOURNAL_MODE = 8;
+ MMAP_SIZE = 9;
+ }
+ required PragmaCommand command = 1;
+ optional Schema schema = 2;
+ required int32 arg1 = 3;
+}
+
+// ~~~~CREATE_TABLE~~~~
+enum TempModifier {
+ TM_TEMP = 3;
+ TM_TEMPORARY = 4;
+}
+
+message CreateTable {
+ optional TempModifier temp_modifier = 1;
+ required bool if_not_exists = 2;
+ required ExprSchemaTable schema_table = 3;
+ oneof create_table_oneof {
+ CreateTableOpt1 op1 = 4;
+ Select as_select_stmt = 5; // AS select-stmt
+ }
+ required CreateTableOpt1 op = 6; // used only if the above oneof is empty
+}
+
+message CreateTableOpt1 {
+ required ColumnDef col_def = 1;
+ repeated ColumnDef extra_col_defs = 2;
+ repeated TableConstraint table_constraints = 3;
+ required bool without_rowid = 4;
+}
+
+message ColumnDef {
+ required Column col = 1;
+ optional TypeName type_name = 2;
+ repeated ColumnConstraint col_constraints = 3;
+}
+
+message TypeName {
+ // Things like VARCHAR(100) are simply not enforced by SQLite (this example
+ // would end up with a column affinity of TEXT). So I don't make much effort
+ // to generate them.
+ required CastTypeName ctn = 1;
+ optional uint32 sn = 2;
+}
+
+message ColumnConstraint {
+ optional ColumnConstraintName constraint_name = 1;
+ oneof col_constraint_oneof {
+ ColConstraintOpt1 opt1 = 2;
+ ConflictClause not_null_conf_clause = 3;
+ ConflictClause unique_conf_clause = 4;
+ Expr check_expr = 5; // CORPUS specialize??
+ ColConstraintOpt2 opt2 = 6;
+ CollateType collate = 7;
+ ForeignKeyClause fkey_clause = 8;
+ }
+ required ColConstraintOpt2 opt2_fallback = 9;
+}
+
+message ColConstraintOpt1 {
+ required AscDesc asc_desc = 1;
+ required ConflictClause conflict = 2;
+ required bool autoincrement = 3;
+}
+
+message ColConstraintOpt2 {
+ required LiteralValue lit_val = 1;
+ optional Expr expr = 2; // CORPUS specialize?
+}
+
+message ConflictClause {
+ enum OnConflict {
+ ROLLBACK = 0;
+ ABORT = 1;
+ FAIL = 2;
+ IGNORE = 3;
+ REPLACE = 4;
+ }
+ optional OnConflict on_conflict = 1;
+}
+
+message TableConstraint {
+ optional TableConstraintName name = 1;
+ oneof table_constraint_oneof {
+ TableConstraintOpt1 opt1 = 2;
+ Expr check_expr = 3; // CORPUS specialize?
+ TableConstraintOpt2 opt2 = 4;
+ }
+}
+
+message TableConstraintOpt1 {
+ enum ConstraintType {
+ PRIMARY_KEY = 0;
+ UNIQUE = 1;
+ }
+ required ConstraintType constraint_type = 1;
+ required IndexedColumnList indexed_col_list = 2;
+ required ConflictClause conf_clause = 3;
+}
+
+message TableConstraintOpt2 {
+ required ColumnList cols = 1;
+ required ForeignKeyClause fkey_clause = 2;
+}
+
+message IndexedColumn {
+ optional Expr expr = 1; // CORPUS specialize?
+ required Column col = 2; // only used if expr non-existent
+ optional CollateType collate_type = 3;
+ required AscDesc asc_desc = 4;
+}
+
+message IndexedColumnList {
+ required IndexedColumn indexed_col = 1;
+ repeated IndexedColumn extra_indexed_cols = 2;
+}
+
+message ForeignKeyClause {
+ required Table foreign_table = 1;
+ optional ColumnList col_list = 2;
+ repeated ForeignKeyClauseCore fkey_cores = 3;
+ optional DeferStrategy defer_strat = 4;
+}
+
+message ForeignKeyClauseCore {
+ optional ForeignKeyClauseNotMatch fkey_not_match = 1;
+ // Sqlite doesn't obey MATCH expressions, MATCH SIMPLE is always assumed
+}
+
+message ForeignKeyClauseNotMatch {
+ enum DeleteOrUpdate {
+ DELETE = 0;
+ UPDATE = 1;
+ }
+ required DeleteOrUpdate del_or_update = 1;
+
+ enum Action {
+ SET_NULL = 0;
+ SET_DEFAULT = 1;
+ CASCADE = 2;
+ RESTRICT = 3;
+ NO_ACTION = 4;
+ }
+ required Action action = 2;
+}
+
+message DeferStrategy {
+ required bool not = 1;
+ enum DeferStratEnum {
+ INITIALLY_DEFERRED = 0;
+ INITIALLY_IMMEDIATE = 1;
+ NONE = 2;
+ }
+ required DeferStratEnum strat = 2;
+}
+
+// ~~~~DELETE~~~~
+// FIXME in the future: SQL_ENABLE_UPDATE_DELETE_LIMIT
+message Delete {
+ optional WithStatement with = 1;
+ required QualifiedTableName qtn = 2;
+ optional WhereStatement where = 3;
+}
+
+message QualifiedTableName {
+ required SchemaTableAsAlias staa = 1;
+ required bool indexed = 2;
+ required bool not_indexed = 3;
+ required Index indexed_by = 4;
+}
+
+// ~~~~INSERT~~~~
+
+message UpsertClausePart1 {
+ required IndexedColumnList icol_list = 1;
+ optional WhereStatement where_stmt = 2;
+}
+
+message ColEqualsExpr {
+ oneof uclause_p2_oneof {
+ Column col = 1;
+ ColumnList col_list = 2;
+ }
+ required Expr expr = 3;
+}
+
+message UpsertClausePart2 {
+ required ColEqualsExpr cee = 1;
+ repeated ColEqualsExpr extra_cees = 2;
+ optional WhereStatement where_stmt = 3;
+}
+
+message UpsertClause {
+ optional UpsertClausePart1 uclause_p1 = 1;
+ optional UpsertClausePart2 uclause_p2 = 2;
+}
+
+message SchemaTableAsAlias {
+ required ExprSchemaTable schema_table = 1;
+ optional Table as_table_alias = 2;
+}
+
+message Insert {
+ optional WithStatement with = 1;
+ enum InsertType {
+ INSERT = 0;
+ REPLACE = 1;
+ INSERT_OR_REPLACE = 2;
+ INSERT_OR_ROLLBACK = 3;
+ INSERT_OR_ABORT = 4;
+ INSERT_OR_FAIL = 5;
+ INSERT_OR_IGNORE = 6;
+ }
+ required InsertType insert_type = 2;
+ required SchemaTableAsAlias staa = 3;
+ optional ColumnList col_list = 5;
+ oneof insert_oneof {
+ ValuesStatement values = 6;
+ Select select = 7;
+ } // if empty, DEFAULT VALUES
+ optional UpsertClause upsert_clause = 8;
+}
+
+// ~~~~UPDATE~~~~
+message Update {
+ optional WithStatement with = 1;
+ enum UpdateType {
+ OR_ROLLBACK = 0;
+ OR_ABORT = 1;
+ OR_REPLACE = 2;
+ OR_FAIL = 3;
+ OR_IGNORE = 4;
+ }
+ optional UpdateType update_type = 2;
+ required QualifiedTableName qtn = 3;
+ required UpsertClausePart2 ucp2 = 4;
+}
+
+// ~~~~CREATE INDEX~~~~
+message CreateIndex {
+ required bool unique = 1;
+ required bool if_not_exists = 2;
+ optional Schema schema = 3;
+ required Index index = 4;
+ required Table table = 5;
+ required IndexedColumnList icol_list = 6;
+ optional WhereStatement where = 7;
+}
+
+// ~~~~CREATE VIEW~~~~
+message View {
+ required uint32 view = 1;
+}
+message CreateView {
+ optional TempModifier temp_modifier = 1;
+ required bool if_not_exists = 2;
+ optional Schema schema = 3;
+ required View view = 4;
+ optional ColumnList col_list = 5;
+ required Select select = 6;
+}
+
+// ~~~~CREATE TRIGGER~~~~
+message Trigger {
+ required uint32 trigger = 1;
+}
+
+message CreateTrigger {
+ optional TempModifier temp_modifier = 1;
+ required bool if_not_exists = 2;
+ optional Schema schema = 3;
+ required Trigger trigger = 4;
+ enum TriggerType {
+ BEFORE = 0;
+ AFTER = 1;
+ INSTEAD_OF = 2;
+ }
+ optional TriggerType trigger_type = 5;
+ enum TriggerInstr {
+ DELETE = 0;
+ UPDATE = 1;
+ INSERT = 2;
+ }
+ optional TriggerInstr trigger_instr = 6;
+ required ColumnList col_list = 7; // CORPUS create corpus item with an Update
+ // using the same ColumnList as this
+ required Table table = 8;
+ required bool for_each_row = 9;
+ optional ExprComparisonHighProbability when = 10; // for the WHEN statement
+ // There are significant restrictions on update, insert, select, and delete
+ // expressions used in triggers. However, we might as well generate normal
+ // queries and see if these restrictions are adequately enforced.
+
+ // Also, from https://www.sqlite.org/lang_createtrigger.html: "If a BEFORE
+ // UPDATE or BEFORE DELETE trigger modifies or deletes a row that was to have
+ // been updated or deleted, then the result of the subsequent update or delete
+ // operation is undefined. Furthermore, if a BEFORE trigger modifies or
+ // deletes a row, then it is undefined whether or not AFTER triggers that
+ // would have otherwise run on those rows will in fact run."
+
+ // It is unclear what is meant by "undefined". Are we talking memory
+ // corruption? I suppose the fuzzer will find it and we'll see.
+ required TypicalQuery tq = 11;
+ repeated TypicalQuery extra_tqs = 12;
+}
+
+message TypicalQuery {
+ oneof tq_oneof {
+ Update update = 1;
+ Insert insert = 2;
+ Select select = 3;
+ }
+ required Delete delete_fallback = 4;
+}
+
+// ~~~~REINDEX~~~~
+message ReIndex {
+ required bool empty = 5;
+ optional CollateType collate_type = 4; // used if schema does not exist
+ optional Schema schema = 1;
+ optional Table table = 2;
+ required Index index = 3; // used if table does not exist.
+}
+
+// ~~~~DROP *~~~~
+message Drop {
+ required bool if_exists = 5;
+ optional Schema schema = 6;
+ oneof drop_oneof {
+ Index index = 1;
+ Table table = 2;
+ Trigger trigger = 3;
+ }
+ required View view_fallback = 4;
+}
+
+// ~~~~ALTER TABLE~~~~
+message AlterTable {
+ required ExprSchemaTable schema_table = 1;
+ required bool column = 2;
+ optional Column col = 4;
+ required Column col_to = 5;
+ optional ColumnDef col_def = 6;
+ required Table table_fallback = 3;
+}
+
+// ~~~~ATTACH DATABASE~~~~
+
+// SEE: https://www.sqlite.org/inmemorydb.html
+// Lots of different options.
+// TODO(mpdenton) may want to experiment with on-filesystem main dbs as well...
+message AttachDatabase {
+ required bool in_memory = 1;
+ required bool file_uri = 2;
+ optional Schema db_name = 3;
+ required bool shared_cache = 4;
+ required Schema schema = 5;
+}
+
+// ~~~~DETACH DATABASE~~~~
+message DetachDatabase {
+ required Schema schema = 1;
+}
+
+// ~~~~SELECT~~~~
+/*
+ Select is obviously the most complicated syntax in the language, and the
+ fuzzer will likely generate plenty of invalid SELECT statements. As long as
+ it does not generate too many, we should still be perfectly fine.
+
+ From sqlite docs:
+ Note that there are paths through the syntax diagrams that are not allowed in
+ practice. Some examples:
+
+ A VALUES clause can be the first element in a compound SELECT that uses a WITH
+ clause, but a simple SELECT that consists of just a VALUES clause cannot be
+ preceded by a WITH clause. The WITH clause must occur on the first SELECT of a
+ compound SELECT. It cannot follow a compound-operator.
+
+
+ See https://www.sqlite.org/lang_select.html.
+*/
+message Select {
+ optional WithStatement with = 1;
+
+ // SQL grammar specifies SelectSubStatement here but that just leads
+ // to a bunch of unparseable VALUES ... ; statements. So require
+ // SelectCore here.
+ required SelectStatementCore select_core = 2;
+ repeated ExtraSelectSubStatement extra_select_substatements = 3;
+ optional OrderByStatement orderby = 4;
+ optional LimitStatement limit = 5;
+}
+
+message OrderByStatement {
+ required ExprOrderingTerm ord_term = 1;
+ repeated ExprOrderingTerm extra_ord_terms = 2;
+}
+
+message LimitStatement {
+ // CORPUS specialize these exprs???
+ required Expr limit_expr = 1;
+ required bool offset = 2; // this is only used if second_expr exists
+ optional Expr second_expr = 3;
+}
+
+message ExtraSelectSubStatement {
+ required CompoundOperator compound_op = 1;
+ required SelectSubStatement select_substatement = 2;
+}
+
+enum CompoundOperator {
+ CO_UNION = 0;
+ CO_UNION_ALL = 1;
+ CO_INTERSECT = 2;
+ CO_EXCEPT = 3;
+}
+
+message SelectSubStatement {
+ oneof select_subexpr_oneof {
+ SelectStatementCore select_core = 1;
+ ValuesStatement values = 2;
+ }
+ required ValuesStatement values_fallback = 3;
+}
+
+message ValuesStatement {
+ required ExprList expr_list = 1;
+ repeated ExprList extra_expr_lists = 2; // CORPUS specialize?
+}
+
+message ExprColAlias {
+ required Expr expr = 1;
+ optional Column col_alias = 2;
+ required bool as = 3;
+}
+
+message ResultColumn {
+ oneof result_col_oneof {
+ Column col = 1;
+ ExprColAlias eca = 2;
+ Table table_star = 3;
+ FTS3AuxiliaryFn fts3_fn = 4; // Only emitted when FUZZ_FTS3 enabled
+ } // if nothing, use star *
+}
+
+message SelectStatementCore {
+ enum SelectOrDistinct {
+ SELECT_DISTINCT = 0;
+ SELECT = 1;
+ SELECT_ALL = 2;
+ }
+ required SelectOrDistinct s_or_d = 1;
+ repeated ResultColumn result_columns = 2;
+ optional FromStatement from = 3;
+ optional WhereStatement where = 4;
+ optional GroupByStatement groupby = 5;
+ optional WindowStatement window = 6;
+}
+
+message WithStatement {
+ required bool recursive = 1;
+ required CommonTableExpr table_expr = 2;
+ repeated CommonTableExpr extra_table_exprs = 3;
+}
+
+message FromStatement {
+ required TableOrSubqueryOption3 tos3 = 1;
+}
+
+message WindowStatement {
+ required WindowStatementNaming win = 1;
+ repeated WindowStatementNaming extra_wins = 2;
+}
+
+message WindowStatementNaming {
+ required WindowName name = 1;
+ required WindowDefn defn = 2;
+}
+
+message GroupByStatement {
+ // CORPUS specialize all these exprs????
+ required ExprList exprs = 1;
+ optional Expr having_expr = 3;
+}
+
+message WhereStatement {
+ required ExprComparisonHighProbability expr = 1;
+}
+
+message CommonTableExpr {
+ required Table table = 1;
+ repeated Column columns = 2;
+ required Select select = 3;
+}
+
+// ~~~~Join stuff~~~~~
+message JoinClause {
+ required TableOrSubquery tos = 1;
+ repeated JoinClauseCore clauses = 2;
+}
+
+message JoinClauseCore {
+ required JoinOperator join_op = 1;
+ required TableOrSubquery tos = 2;
+ required JoinConstraint join_constraint = 3;
+}
+
+message JoinOperator {
+ required bool comma = 1;
+ // the following fields only used if comma is false
+ required bool natural = 2;
+ enum JoinType {
+ LEFT = 0;
+ LEFT_OUTER = 1;
+ INNER = 2;
+ CROSS = 3;
+ NONE = 4;
+ }
+ required JoinType join_type = 3;
+}
+
+message JoinConstraint {
+ oneof join_constraint_oneof {
+ Expr on_expr = 1;
+ UsingExpr using_expr = 2;
+ } // fine if empty
+}
+
+message UsingExpr {
+ required ColumnList col_list = 1;
+}
+
+// ~~~~~Table names etc.~~~~~
+
+// First checks if main is set. Then checks if temp is set. Then checks if
+// other schema number is set.
+message Schema {
+ required uint32 schema = 1;
+ required bool main = 2;
+ required bool temp = 3;
+}
+
+message Table {
+ required uint32 table = 1;
+ optional bool fts3_content_table = 2; // only used for FTS3 fuzzing
+}
+
+message Column {
+ required uint32 column = 1;
+ optional bool rowid = 2; // can also have "rowid" column
+
+ // FTS has a hidden column with the same name as the table.
+ optional FTS3Table fts3_table = 3;
+ // FTS3 tables have "docid" as an alias for "rowid".
+ optional bool fts3_docid = 4;
+}
+
+message WindowName {
+ required uint32 window_name = 1;
+}
+
+message ColumnConstraintName {
+ required uint32 constraint_name = 1;
+}
+
+message TableConstraintName {
+ required uint32 constraint_name = 1;
+}
+
+message Index {
+ required uint32 index = 1;
+}
+
+// Example:
+// column1, column2, column3
+message ColumnList {
+ required Column col = 1;
+ repeated Column extra_cols = 2;
+}
+
+// ~~~~table-or-subquery~~~~
+message TableOrSubquery {
+ oneof tos_oneof {
+ QualifiedTableName qtn = 1;
+ TableOrSubqueryOption2 toso2 = 2;
+ TableOrSubqueryOption3 toso3 = 3;
+ TableOrSubqueryOption4 toso4 = 4;
+ }
+ required ExprSchemaTable schema_table_expr = 5; // used if the oneof is empty
+}
+
+message TableOrSubqueryOption2 {
+ required ExprSchemaTableFn schema_table_fn = 1;
+ optional AsTableAlias as_table_alias = 2;
+}
+
+message TableOrSubqueryOption3 {
+ repeated TableOrSubquery tos_list = 1; // if empty, use the join clause
+ required JoinClause join_clause = 2;
+}
+
+message TableOrSubqueryOption4 {
+ required Select select = 1;
+ optional AsTableAlias as_table_alias = 2;
+}
+
+message AsTableAlias {
+ required bool as = 2;
+ required Table table_alias = 3;
+}
+
+// ~~~~Expressions~~~~
+message Expr {
+ oneof expr_oneof {
+ LiteralValue lit_val = 1;
+ ComplicatedExpr comp_expr = 2;
+ }
+}
+
+message NumericLiteral {
+ repeated uint32 hex_digits = 1;
+ repeated uint32 digits = 2;
+ required bool decimal_point = 3;
+ repeated uint32 dec_digits = 4;
+ repeated uint32 exp_digits = 5;
+ required bool negative_exp = 6;
+}
+
+message LiteralValue {
+ enum SpecialVal {
+ VAL_NULL = 0; // using just "NULL" vauses it not to compile.
+ VAL_TRUE = 1;
+ VAL_FALSE = 2;
+ CURRENT_TIME = 3;
+ CURRENT_DATE = 4;
+ CURRENT_TIMESTAMP = 5;
+ }
+ oneof lit_val_oneof {
+ int64 num_lit = 1;
+ string string_lit = 2;
+ bytes blob_lit = 3;
+ SpecialVal special_val = 4;
+ NumericLiteral numeric_lit = 5;
+ } // If no value, just use int64(1)
+}
+
+enum UnaryOperator {
+ UNOP_MINUS = 1;
+ UNOP_PLUS = 2;
+ UNOP_TILDE = 3;
+ UNOP_NOT = 4;
+}
+
+message UnaryExpr {
+ required UnaryOperator unary_op = 1;
+ required Expr expr = 2;
+}
+
+enum BinaryOperator {
+ BINOP_CONCAT = 1; // double pipe
+ BINOP_STAR = 2;
+ BINOP_SLASH = 3;
+ BINOP_PERCENT = 4;
+ BINOP_PLUS = 5;
+ BINOP_MINUS = 6;
+ BINOP_LELE = 7; // <<
+ BINOP_GRGR = 8; // >>
+ BINOP_AMPERSAND = 9;
+ BINOP_PIPE = 10;
+ BINOP_LE = 11;
+ BINOP_LEQ = 12;
+ BINOP_GR = 13;
+ BINOP_GREQ = 14;
+ BINOP_EQ = 15;
+ BINOP_EQEQ = 16;
+ BINOP_NOTEQ = 17;
+ BINOP_LEGR = 18; // <> (not equal)
+ BINOP_IS = 19;
+ BINOP_ISNOT = 20;
+ BINOP_IN = 21;
+ BINOP_LIKE = 22;
+ BINOP_GLOB = 23;
+ BINOP_MATCH = 24;
+ BINOP_REGEXP = 25;
+ BINOP_AND = 26;
+ BINOP_OR = 27;
+}
+
+message BinaryExpr {
+ required Expr lhs = 1;
+ required BinaryOperator op = 2;
+ required Expr rhs = 3;
+
+ // In FUZZ_FTS3 mode, if |fmt| exists we will use it instead of rhs to
+ // help generate better MATCH queries.
+ optional FTS3MatchFormat fmt = 4;
+}
+
+// Used to inflate the probability that we get a comparison of a column with an
+// expr. This is useful, as an example, for WHERE expressions.
+message ExprComparisonHighProbability {
+ oneof expr_comp_oneof {
+ ColumnComparison cc = 1;
+ Expr expr = 2;
+ }
+}
+
+// Special version of expr that only generates predicates with a column on the
+// left.
+message ColumnComparison {
+ required ExprSchemaTableColumn col = 1;
+ required BinaryOperator op = 2;
+ required Expr expr = 3;
+ // In FUZZ_FTS3 mode, if |fmt| exists we will use it instead of rhs to
+ // help generate better MATCH queries.
+ optional FTS3MatchFormat fmt = 4;
+}
+
+message ExprSchemaTableColumn {
+ optional Schema schema = 1;
+ optional Table table = 2;
+ required Column col = 3;
+}
+
+// Separate this out to inflate the probability of having a literal value
+message ComplicatedExpr {
+ // Don't want bind-parameter, unless fuzzing sql_bind
+ oneof complicated_expr_oneof {
+ ExprSchemaTableColumn expr_stc = 2;
+ UnaryExpr unary_expr = 3;
+ BinaryExpr binary_expr = 4;
+ Fn fn_expr = 5;
+ ParenthesesExpr par_expr = 6;
+ CastExpr cast_expr = 7;
+ CollateExpr collate_expr = 8;
+ Expr1 expr1 = 9;
+ ExprNullTests expr_null_tests = 10;
+ ExprIs expr_is = 11;
+ ExprBetween expr_between = 12;
+ ExprIn expr_in = 17;
+ ExprExists expr_exists = 13;
+ ExprCase expr_case = 14;
+ ExprRaiseFn expr_raise = 15;
+ }
+ required LiteralValue lit_val = 16; // used if oneof is empty.
+}
+
+message ExprRaiseFn {
+ required bool ignore = 3;
+ enum RaiseFnEnum {
+ ROLLBACK = 0;
+ ABORT = 1;
+ FAIL = 2;
+ }
+ required RaiseFnEnum raise_fn = 1;
+ required string error_msg = 2;
+}
+
+message ExprCase {
+ optional Expr expr = 1;
+ required ExprWhenThen when_then = 2;
+ repeated ExprWhenThen extra_when_thens = 3;
+ optional Expr else_expr = 4;
+}
+
+message ExprWhenThen {
+ required Expr when_expr = 1;
+ required Expr then_expr = 2;
+}
+
+message ExprExists {
+ required bool not = 1;
+ required bool exists = 2;
+ required Select select = 3;
+}
+
+message ExprIn {
+ required Expr expr = 5;
+ required bool not = 1;
+ oneof exprin_oneof {
+ ExprInParen expr_in_paren = 2;
+ ExprSchemaTable schema_table = 3;
+ ExprSchemaTableFn schema_table_fn = 4;
+ }
+}
+
+message ExprSchemaTable {
+ optional Schema schema_name = 1;
+ required Table table_name = 2;
+}
+
+message ExprSchemaTableFn {
+ required TableFn table_fn = 2;
+ // FIXME in the future add more. For now, no exprs.
+}
+
+message ExprInParen {
+ oneof exprin_paren_oneof {
+ Select select = 1;
+ ExprList exprs = 2;
+ } // if zero, can just emit closed parentheses
+}
+
+message ExprList {
+ required Expr expr = 1;
+ repeated Expr extra_exprs = 2;
+}
+
+message Expr1 {
+ required Expr expr1 = 5;
+ required bool not = 1;
+ enum PossibleKeywords {
+ LIKE = 0;
+ GLOB = 1;
+ REGEXP = 2;
+ MATCH = 3;
+ }
+ required PossibleKeywords keyword = 2;
+ required Expr expr2 = 3;
+ optional Expr escape_expr = 4; // CORPUS specialize?
+}
+
+message ExprNullTests {
+ required Expr expr = 1;
+ enum PossibleKeywords {
+ ISNULL = 0;
+ NOTNULL = 1;
+ NOT_NULL = 2;
+ }
+ required PossibleKeywords keyword = 2;
+}
+
+message ExprIs {
+ required bool not = 1;
+ required Expr expr1 = 2;
+ required Expr expr2 = 3;
+}
+
+message ExprBetween {
+ required bool not = 1;
+ required Expr expr1 = 2;
+ required Expr expr2 = 3;
+ required Expr expr3 = 4;
+}
+
+enum CollateType {
+ COLLATE_BINARY = 1;
+ COLLATE_NOCASE = 2;
+ COLLATE_RTRIM = 3;
+}
+
+message CollateExpr {
+ required Expr expr = 1;
+ required CollateType collate_type = 2;
+}
+
+message CastTypeName {
+ enum CastTypeNameEnum {
+ BLOB = 0;
+ TEXT = 1;
+ REAL = 2;
+ INTEGER = 3;
+ NUMERIC = 4;
+ }
+ required CastTypeNameEnum type_enum = 1;
+}
+
+message CastExpr {
+ required Expr expr = 1;
+ required CastTypeName type_name = 2;
+}
+
+message ParenthesesExpr {
+ required Expr expr = 1;
+ repeated Expr other_exprs = 2;
+}
+
+message Fn {
+ oneof fn_oneof {
+ SimpleFn simple_fn = 1;
+ FTS3AuxiliaryFn fts_aux_fn = 2;
+ DateAndTimeFn dat_fn = 3;
+ AggregateFn aggregate_fn = 4;
+ Printf printf = 5;
+ }
+ // FIXME in the future: JSON functions. Not used in Chrome.
+}
+
+// Aggregate FNs
+message AggregateFn {
+ optional bool count_star = 7;
+ enum FnName {
+ AVG = 0;
+ COUNT = 1;
+ GROUP_CONCAT = 2;
+ MAX = 3;
+ MIN = 4;
+ SUM = 5;
+ TOTAL = 6;
+ }
+ required FnName fn_name = 6;
+ required bool distinct = 5;
+ optional Column col1 = 1;
+ optional Column col2 = 2;
+ required Expr expr1 = 3;
+ optional Expr expr2 = 4;
+}
+
+// Date and Time Functions
+message DateAndTimeFn {
+ optional SimpleDateAndTimeFn simple = 1;
+ required StrftimeFn strftime = 2;
+}
+
+message StrftimeFn {
+ repeated StrftimeFormat fmts = 1;
+ required TimeString time_string = 2;
+ repeated TimeModifier modifiers = 3;
+}
+
+message StrftimeFormat {
+ enum Substitution {
+ D = 0;
+ F = 1;
+ H = 2;
+ J = 3;
+ M = 4;
+ S = 5;
+ W = 6;
+ Y = 7;
+ }
+ required bool lowercase = 1;
+ optional Substitution subs = 2;
+ required string bytes = 3;
+}
+
+message SimpleDateAndTimeFn {
+ enum FnName {
+ DATE = 0;
+ TIME = 1;
+ DATETIME = 2;
+ JULIANDAY = 3;
+ }
+ required FnName fn_name = 1;
+ required TimeString time_string = 2;
+ repeated TimeModifier modifiers = 3;
+}
+
+message HoursStuff {
+ optional uint32 hh = 1;
+ optional uint32 mm = 2;
+ optional uint32 ss = 3;
+ optional uint32 sss = 4;
+}
+
+message TimeString {
+ optional uint32 yyyy = 1;
+ optional uint32 mm = 2;
+ optional uint32 dd = 3;
+ optional HoursStuff hs = 4;
+ required bool extra_t = 6;
+
+ optional uint32 dddddddddd = 7;
+
+ required bool now = 8;
+
+ optional string random_bytes = 9;
+
+ required bool z = 13;
+ required bool plus = 14;
+ optional bool tz_plus = 10;
+ optional uint32 tz_hh = 11;
+ optional uint32 tz_mm = 12;
+}
+
+message TimeModifier {
+ enum NumberedModifiers {
+ DAYS = 0;
+ HOURS = 1;
+ MINUTES = 2;
+ SECONDS = 3;
+ MONTHS = 4;
+ YEARS = 5;
+ }
+ required uint32 num = 4;
+ optional uint32 dot_num = 5;
+ optional NumberedModifiers nm = 1;
+ enum OtherModifiers {
+ START_OF_MONTH = 0;
+ START_OF_YEAR = 1;
+ START_OF_DAY = 2;
+ WEEKDAY = 3;
+ UNIXEPOCH = 4;
+ LOCALTIME = 5;
+ UTC = 6;
+ }
+ required OtherModifiers om = 2;
+ required uint32 weekday = 3;
+}
+
+// Simple Functions finish
+message SimpleFn {
+ oneof simple_fn_oneof {
+ ZeroArgFn zero_arg_fn = 1;
+ OneArgFn one_arg_fn = 2;
+ TwoArgFn two_arg_fn = 3;
+ ThreeArgFn three_arg_fn = 4;
+ VarNumFn varnum_fn = 5;
+ CharFn char_fn = 6;
+ }
+}
+
+// Zero arguments fn
+enum ZeroArgFn {
+ ZFN_CHANGES = 0;
+ ZFN_LAST_INSERT_ROWID = 1;
+ ZFN_RANDOM = 2;
+ ZFN_SQLITE_SOURCE_ID = 3;
+ ZFN_SQLITE_VERSION = 4;
+ ZFN_TOTAL_CHANGES = 5;
+}
+
+message OneArgFn {
+ enum OneArgFnEnum {
+ ABS = 1;
+ HEX = 2;
+ LENGTH = 3;
+ LIKELY = 4;
+ LOWER = 5;
+ LTRIM = 6;
+ LOAD_EXTENSION = 7;
+ QUOTE = 8;
+ ROUND = 9;
+ RTRIM = 10;
+ RANDOMBLOB = 11;
+ SOUNDEX = 12;
+ SQLITE_COMPILE_OPTION_GET = 13;
+ SQLITE_COMPILE_OPTION_USED = 14;
+ SQLITE_OFFSET = 15;
+ TRIM = 16;
+ TYPEOF = 17;
+ UNICODE_ = 18;
+ UNLIKELY = 19;
+ UPPER = 20;
+ ZEROBLOB = 21;
+ }
+ required OneArgFnEnum fn_enum = 1;
+ required Expr arg1 = 2;
+}
+
+message TwoArgFn {
+ enum TwoArgFnEnum {
+ GLOB = 1;
+ IFNULL = 2;
+ INSTR = 3;
+ LIKE = 4;
+ LIKELIHOOD = 5;
+ LOAD_EXTENSION = 6;
+ LTRIM = 7;
+ NULLIF = 8;
+ ROUND = 9;
+ RTRIM = 10;
+ SUBSTR = 11;
+ TRIM = 12;
+ }
+ required TwoArgFnEnum fn_enum = 1;
+ required Expr arg1 = 2;
+ required Expr arg2 = 3;
+}
+
+message ThreeArgFn {
+ enum ThreeArgFnEnum {
+ LIKE = 0;
+ REPLACE = 1;
+ SUBSTR = 2;
+ }
+ required ThreeArgFnEnum fn_enum = 1;
+ required Expr arg1 = 2;
+ required Expr arg2 = 3;
+ required Expr arg3 = 4;
+}
+
+// Fns with two args required + an arbitrary number of other args.
+message VarNumFn {
+ enum VarNumFnEnum {
+ COALESCE = 1;
+ MAX = 2;
+ MIN = 3;
+ }
+ required VarNumFnEnum fn_enum = 1;
+ required Expr arg1 = 2;
+ required Expr arg2 = 3;
+ repeated Expr other_args = 4;
+}
+
+message CharFn {
+ required uint64 char = 1;
+ repeated uint64 extra_chars = 2;
+}
+
+message Printf {
+ repeated string strings = 1;
+ repeated PrintfFormatSpecifier specifiers = 2;
+ repeated Expr exprs = 3;
+}
+
+message PrintfFormatSpecifier {
+ enum Flags {
+ MINUS = 0;
+ PLUS = 1;
+ SPACE = 2;
+ ZERO = 3;
+ HASH = 4;
+ COMMA = 5;
+ BANG = 6;
+ }
+ repeated Flags flags = 1;
+ optional uint32 precision = 2;
+ optional uint32 width = 3;
+ optional bool width_star = 4;
+ // The length modifiers make no difference for the sqlite function.
+ optional uint32 length = 5;
+ enum SubType {
+ I = 0;
+ D = 1;
+ U = 2;
+ F = 3;
+ E = 4;
+ G = 5;
+ X = 6;
+ O = 7;
+ S = 8;
+ Z = 9;
+ C = 10;
+ P = 11;
+ N = 12;
+ Q = 13;
+ W = 14;
+ }
+ optional bool percent = 8;
+ required SubType sub_type = 6;
+ required bool lowercase = 7;
+}
+
+// Window fns!
+// FIXME in the future: this may only be in the result set and the ORDER_BY
+// clause of a SELECT statement.
+message WindowFnInvocation {
+ oneof window_fn_oneof {
+ ZeroArgWinFn zero_arg_fn = 1;
+ OneArgWinFn one_arg_fn = 2;
+ NthValueFn nth_value_fn = 4;
+ MiscWinFn misc_fn = 3;
+ }
+
+ // Used if the above oneof produces zero values.
+ required ZeroArgWinFn fallback_zero_arg_fn = 5;
+
+ // FIXME in the future: may just replace with a WHERE expr.
+ optional ExprFilter expr_filter = 6;
+ optional WindowDefn win_defn = 7;
+ required WindowName win_name = 8; // used only if win_defn above is unused.
+}
+
+message WindowDefn {
+ // FIXME in the future: change to specialized expr
+ optional ExprList partition_exprs = 1;
+ optional MultipleOrderingTerm ordering_terms = 2;
+ optional ExprFrameSpec frame_spec = 3;
+}
+
+message ExprFrameSpec {
+ enum RangeRows {
+ RANGE = 0;
+ ROWS = 1;
+ }
+ required RangeRows range_rows = 1;
+ required FrameSpecSubExpr left_expr = 2;
+ // if this exists, then this is a BETWEEN statement.
+ optional FrameSpecSubExprRight right_expr = 3;
+}
+
+message FrameSpecSubExpr {
+ enum Which {
+ UNBOUNDED_PRECEDING = 0;
+ EXPR_PRECEDING = 1;
+ CURRENT_ROW = 2;
+ EXPR_FOLLOWING = 3;
+ }
+ required Which which = 1;
+ // only used if which is EXPR_PRECEDING or EXPR_FOLLOWING
+ optional Expr expr = 2; // CORPUS specialize? integer?
+}
+
+message FrameSpecSubExprRight {
+ enum Which {
+ UNBOUNDED_FOLLOWING = 0;
+ EXPR_PRECEDING = 1;
+ CURRENT_ROW = 2;
+ EXPR_FOLLOWING = 3;
+ }
+ required Which which = 1;
+ // only used if which is EXPR_PRECEDING or EXPR_FOLLOWING
+ optional Expr expr = 2; // CORPUS specialize? integer?
+}
+
+message MultipleOrderingTerm {
+ repeated ExprOrderingTerm terms = 1;
+}
+
+message ExprOrderingTerm {
+ required Expr expr = 1; // CORPUS specialize???
+ optional CollateType collate_type = 2;
+ required AscDesc asc_desc = 3;
+}
+
+enum AscDesc {
+ ASCDESC_NONE = 0;
+ ASCDESC_ASC = 1;
+ ASCDESC_DESC = 2;
+}
+
+message ExprFilter {
+ required Expr expr = 1;
+}
+
+message ZeroArgWinFn {
+ enum ZeroArgWinFnEnum {
+ ROW_NUMBER = 0;
+ RANK = 1;
+ DENSE_RANK = 2;
+ PERCENT_RANK = 3;
+ CUME_DIST = 4;
+ }
+ required ZeroArgWinFnEnum win_fn = 1;
+}
+
+message OneArgWinFn {
+ enum OneArgWinFnEnum {
+ NTILE = 0;
+ FIRST_VALUE = 1;
+ LAST_VALUE = 2;
+ }
+ required OneArgWinFnEnum win_fn = 1;
+ required Expr expr = 2;
+}
+
+message NthValueFn {
+ required Expr expr = 1;
+ required uint32 row_num = 2;
+}
+
+message MiscWinFn {
+ enum MiscWinFnEnum {
+ LAG = 0;
+ LEAD = 1;
+ }
+ required MiscWinFnEnum fn = 1;
+ required Expr expr = 2;
+ optional uint32 offset = 3;
+ optional Expr default = 4; // unused if offset non-existent
+}
+// FIXME in the future: all aggregate functions may be used as window aggregate
+// functions!
+
+// Table-valued FNs, including pragma table-valued fns.
+enum PragmaFnZeroArgOneResult {
+ PFN_ZO_APPLICATION_ID = 0;
+ PFN_ZO_AUTO_VACUUM = 1;
+ PFN_ZO_AUTOMATIC_INDEX = 2;
+ PFN_ZO_BUSY_TIMEOUT = 3;
+ PFN_ZO_CACHE_SIZE = 4;
+ PFN_ZO_CACHE_SPILL = 5;
+ PFN_ZO_CELL_SIZE_CHECK = 6;
+ PFN_ZO_CHECKPOINT_FULL_FSYNC = 7;
+ PFN_ZO_COLLATION_LIST = 8;
+ PFN_ZO_COMPILE_OPTIONS = 9;
+ PFN_ZO_COUNT_CHANGES = 10;
+ PFN_ZO_DATA_VERSION = 11;
+ PFN_ZO_DATABASE_LIST = 12;
+ PFN_ZO_DEFAULT_CACHE_SIZE = 13;
+ PFN_ZO_DEFER_FOREIGN_KEYS = 14;
+ PFN_ZO_EMPTY_RESULT_CALLBACKS = 15;
+ PFN_ZO_ENCODING = 16;
+ PFN_ZO_FOREIGN_KEY_CHECK = 17;
+ PFN_ZO_FOREIGN_KEYS = 18;
+ PFN_ZO_FREELIST_COUNT = 19;
+ PFN_ZO_FULL_COLUMN_NAMES = 20;
+ PFN_ZO_FULLFSYNC = 21;
+ PFN_ZO_FUNCTION_LIST = 22;
+ PFN_ZO_IGNORE_CHECK_CONSTRAINTS = 23;
+ PFN_ZO_INTEGRITY_CHECK = 24;
+ PFN_ZO_JOURNAL_SIZE_LIMIT = 25;
+ PFN_ZO_LEGACY_ALTER_TABLE = 26;
+ PFN_ZO_LEGACY_FILE_FORMAT = 27;
+ PFN_ZO_LOCK_STATUS = 28;
+ PFN_ZO_LOCKING_MODE = 29;
+ PFN_ZO_MAX_PAGE_COUNT = 30;
+ PFN_ZO_MODULE_LIST = 31;
+ PFN_ZO_PAGE_COUNT = 32;
+ PFN_ZO_PAGE_SIZE = 33;
+ PFN_ZO_PRAGMA_LIST = 34;
+ PFN_ZO_QUERY_ONLY = 35;
+ PFN_ZO_QUICK_CHECK = 36;
+ PFN_ZO_READ_UNCOMMITTED = 37;
+ PFN_ZO_RECURSIVE_TRIGGERS = 38;
+ PFN_ZO_REVERSE_UNORDERED_SELECTS = 39;
+ PFN_ZO_SCHEMA_VERSION = 40;
+ PFN_ZO_SECURE_DELETE = 41;
+ PFN_ZO_SHORT_COLUMN_NAMES = 42;
+ PFN_ZO_SOFT_HEAP_LIMIT = 43;
+ PFN_ZO_SQL_TRACE = 44;
+ PFN_ZO_STATS = 45;
+ PFN_ZO_SYNCHRONOUS = 46;
+ PFN_ZO_TEMP_STORE = 47;
+ PFN_ZO_THREADS = 48;
+ PFN_ZO_USER_VERSION = 49;
+ // omit vdbe_* debug pragmas
+ PFN_ZO_WRITEABLE_SCHEMA = 50;
+}
+
+message TableFn {
+ required PragmaFnZeroArgOneResult no_arg_one_result = 10;
+ oneof pragma_fn_oneof {
+ Table foreign_key_list = 1;
+ Index index_info = 2;
+ Table index_list = 3;
+ Index index_xinfo = 4;
+ uint32 integrity_check = 5;
+ uint32 optimize = 6;
+ uint32 quick_check = 7;
+ Table table_info = 8;
+ Table table_xinfo = 9;
+ }
+}
diff --git a/chromium/third_party/sqlite/fuzz/sql_query_proto_to_string.cc b/chromium/third_party/sqlite/fuzz/sql_query_proto_to_string.cc
new file mode 100644
index 00000000000..84a09fd1604
--- /dev/null
+++ b/chromium/third_party/sqlite/fuzz/sql_query_proto_to_string.cc
@@ -0,0 +1,2757 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <algorithm>
+#include <array>
+#include <cctype>
+#include <cstdint>
+#include <iomanip>
+#include <map>
+#include <sstream>
+#include <string>
+#include <vector>
+
+#include "third_party/sqlite/fuzz/icu_codes.pb.h"
+#include "third_party/sqlite/fuzz/sql_queries.pb.h"
+#include "third_party/sqlite/fuzz/sql_query_grammar.pb.h"
+#include "third_party/sqlite/fuzz/sql_query_proto_to_string.h"
+
+using namespace sql_query_grammar;
+
+#define CONV_FN(TYPE, VAR_NAME) std::string TYPE##ToString(const TYPE& VAR_NAME)
+
+#define RETURN_IF_DISABLED_QUERY(TYPE) \
+ if (disabled_queries_.count(#TYPE) != 0) \
+ return "";
+
+namespace sql_fuzzer {
+
+namespace {
+constexpr uint32_t kMaxColumnNumber = 20;
+#if !defined(FUZZ_FTS3)
+constexpr uint32_t kMaxTableNumber = 8;
+#endif
+constexpr uint32_t kMaxSchemaNumber = 4;
+constexpr uint32_t kMaxWindowNumber = 5;
+
+constexpr uint32_t kMaxColumnConstraintNumber = 10;
+constexpr uint32_t kMaxTableConstraintNumber = 10;
+
+constexpr uint32_t kMaxIndexNumber = 10;
+
+// should be less than kMaxTableNumber
+constexpr uint32_t kMaxFTS3TableNumber = 2;
+
+constexpr uint32_t kMaxStrLength =
+ 200; // So these are readable and somewhat performant, keep a maximum
+ // string length......
+
+#if !defined(FUZZ_OMIT_SAVEPOINT)
+constexpr uint32_t kMaxSavePointNumber = 10;
+#endif
+
+constexpr uint32_t kMaxViewNumber = 5;
+constexpr uint32_t kMaxTriggerNumber = 10;
+
+std::set<std::string> disabled_queries_;
+} // namespace
+
+CONV_FN(Expr, expr);
+CONV_FN(Select, select);
+CONV_FN(TableOrSubquery, tos);
+CONV_FN(FTS3Table, ft);
+CONV_FN(FTS3NearQuery, fnq);
+CONV_FN(FTS3AuxiliaryFn, faf);
+CONV_FN(FTS3MatchFormat, fmf);
+CONV_FN(DateAndTimeFn, sfn);
+CONV_FN(ExprSchemaTableFn, estf);
+
+// ~~~~Numbered values to string~~~
+
+// WARNING does not include space at the end
+CONV_FN(Column, col) {
+ if (col.has_rowid() && col.rowid())
+ return "rowid";
+#if defined(FUZZ_FTS3)
+ if (col.has_fts3_docid() && col.fts3_docid())
+ return "docid";
+ if (col.has_fts3_table())
+ return FTS3TableToString(col.fts3_table());
+#endif
+ std::string ret("Col");
+ ret += std::to_string(col.column() % kMaxColumnNumber);
+ return ret;
+}
+
+// WARNING does not include space at the end
+CONV_FN(Table, table) {
+ std::string ret("Table");
+#if defined(FUZZ_FTS3)
+ // only fuzzing FTS3 tables, clamp to the max FTS3 table num.
+ ret += std::to_string(table.table() & kMaxFTS3TableNumber);
+ if (table.fts3_content_table())
+ ret += "_content";
+#else
+ ret += std::to_string(table.table() % kMaxTableNumber);
+#endif
+ return ret;
+}
+
+// WARNING does not include space at the end
+CONV_FN(Schema, schema) {
+ if (schema.main()) {
+ return "main";
+ }
+ if (schema.temp()) {
+ return "temp";
+ }
+ std::string ret("Schema");
+ ret += std::to_string(schema.schema() % kMaxSchemaNumber);
+ return ret;
+}
+
+// WARNING does not include space at the end
+CONV_FN(WindowName, win) {
+ std::string ret("Window");
+ ret += std::to_string(win.window_name() % kMaxWindowNumber);
+ return ret;
+}
+
+// WARNING does not include space at the end
+CONV_FN(ColumnConstraintName, cc) {
+ std::string ret("ColConstraint");
+ ret += std::to_string(cc.constraint_name() % kMaxColumnConstraintNumber);
+ return ret;
+}
+
+// WARNING does not include space at the end
+CONV_FN(TableConstraintName, tc) {
+ std::string ret("TableConstraint");
+ ret += std::to_string(tc.constraint_name() % kMaxTableConstraintNumber);
+ return ret;
+}
+
+// WARNING does not include space at the end
+CONV_FN(Index, index) {
+ std::string ret("Index");
+ ret += std::to_string(index.index() % kMaxIndexNumber);
+ return ret;
+}
+
+#if !defined(FUZZ_OMIT_SAVEPOINT)
+CONV_FN(SavePoint, sp) {
+ std::string ret("SavePoint");
+ ret += std::to_string(sp.savepoint_num() % kMaxSavePointNumber);
+ return ret;
+}
+#endif
+
+CONV_FN(View, v) {
+ std::string ret("View");
+ ret += std::to_string(v.view() % kMaxViewNumber);
+ return ret;
+}
+
+CONV_FN(Trigger, t) {
+ std::string ret("Trigger");
+ ret += std::to_string(t.trigger() % kMaxTriggerNumber);
+ return ret;
+}
+
+// ~~~~Utility functions~~~~
+
+std::string AscDescToString(AscDesc a) {
+ switch (a) {
+ case ASCDESC_NONE:
+ return " ";
+ case ASCDESC_ASC:
+ return "ASC ";
+ case ASCDESC_DESC:
+ return "DESC ";
+ default:
+ return " ";
+ }
+}
+
+std::string StrToLower(std::string s) {
+ std::transform(
+ s.begin(), s.end(), s.begin(),
+ [](unsigned char c) -> unsigned char { return std::tolower(c); });
+ return s;
+}
+
+std::string StripTrailingUnderscores(std::string s) {
+ s.erase(std::find_if(s.rbegin(), s.rend(),
+ [](unsigned char ch) { return ch != '_'; })
+ .base(),
+ s.end());
+ return s;
+}
+
+// Converts underscores to spaces in a string.
+// This is because many enums like SET_NULL will be displayed at SET NULL in
+// the query, and I want to use protobuf's enum to string function to save time.
+std::string EnumStrReplaceUnderscores(std::string s) {
+ std::transform(s.begin(), s.end(), s.begin(),
+ [](unsigned char c) -> unsigned char {
+ if (c == '_')
+ return ' ';
+ return c;
+ });
+ return s;
+}
+
+// Takes garbage data and produces a string, with quotes escaped.
+// Caps the number of bytes received from the protobuf at kMaxStrLength.
+// The final string could be as much as kMaxStrLength*2 as we added an extra
+// single quote for every single quote in the input string.
+std::string ConvertToSqlString(const std::string& s) {
+ std::string ret;
+ ret.reserve(kMaxStrLength * 2);
+ for (size_t i = 0; i < s.length() && i < kMaxStrLength; i++) {
+ ret += s[i];
+ if (s[i] == '\'')
+ ret += '\'';
+ }
+ return ret;
+}
+
+// WARNING does not include space
+std::string BytesToHex(const std::string& str) {
+ std::ostringstream ss;
+ ss << std::hex << std::setfill('0');
+ for (size_t i = 0; i < str.size() && i < kMaxStrLength; i++) {
+ ss << std::setw(2) << static_cast<int>(str[i]);
+ }
+ return ss.str();
+}
+
+// WARNING no space at end
+CONV_FN(ExprSchemaTable, st) {
+ std::string ret;
+ if (st.has_schema_name()) {
+ ret += SchemaToString(st.schema_name());
+ ret += ".";
+ }
+ ret += TableToString(st.table_name());
+ return ret;
+}
+
+CONV_FN(ExprSchemaTableColumn, stc) {
+ std::string ret;
+ if (stc.has_schema()) {
+ ret += SchemaToString(stc.schema());
+ ret += ".";
+ }
+ if (stc.has_table()) {
+ ret += TableToString(stc.table());
+ ret += ".";
+ }
+ ret += ColumnToString(stc.col());
+ return ret;
+}
+
+// WARNING does not include parentheses, nor a space at the end
+CONV_FN(ColumnList, cl) {
+ std::string ret = ColumnToString(cl.col());
+ for (int i = 0; i < cl.extra_cols_size(); i++) {
+ ret += ", ";
+ ret += ColumnToString(cl.extra_cols(i));
+ }
+ return ret;
+}
+
+CONV_FN(ExprList, me) {
+ std::string ret = ExprToString(me.expr());
+ for (int i = 0; i < me.extra_exprs_size(); i++) {
+ ret += ", ";
+ ret += ExprToString(me.extra_exprs(i));
+ }
+ return ret;
+}
+
+// WARNING does not include space
+CONV_FN(CollateType, collate_type) {
+ std::string ct = CollateType_Name(collate_type);
+ ct.erase(0, std::string("COLLATE_").length());
+ return ct;
+}
+
+// WARNING does not include space
+CONV_FN(IndexedColumn, ic) {
+ std::string ret;
+ if (ic.has_expr()) {
+ ret += ExprToString(ic.expr());
+ } else {
+ ret += ColumnToString(ic.col());
+ }
+ ret += " ";
+ if (ic.has_collate_type()) {
+ ret += "COLLATE ";
+ ret += CollateTypeToString(ic.collate_type());
+ ret += " ";
+ }
+ ret += AscDescToString(ic.asc_desc());
+
+ return ret;
+}
+
+CONV_FN(IndexedColumnList, ic_list) {
+ std::string ret;
+ ret += IndexedColumnToString(ic_list.indexed_col());
+ for (int i = 0; i < ic_list.extra_indexed_cols_size(); i++) {
+ ret += ", ";
+ ret += IndexedColumnToString(ic_list.extra_indexed_cols(i));
+ }
+ return ret;
+}
+
+CONV_FN(SchemaTableAsAlias, staa) {
+ std::string ret;
+ ret += ExprSchemaTableToString(staa.schema_table());
+ ret += " ";
+
+ if (staa.has_as_table_alias()) {
+ ret += "AS ";
+ ret += TableToString(staa.as_table_alias());
+ ret += " ";
+ }
+ return ret;
+}
+
+// ~~~~Expression stuff~~~~
+
+// WARNING does not include space
+CONV_FN(NumericLiteral, nl) {
+ static constexpr char hex_digits[] = "0123456789ABCDEF";
+ static constexpr char digits[] = "0123456789";
+ std::string ret;
+ if (nl.hex_digits_size() > 0) {
+ ret += "0x";
+ for (int i = 0; i < nl.hex_digits_size(); i++) {
+ ret += hex_digits[nl.hex_digits(i) % sizeof(hex_digits)];
+ }
+
+ return ret;
+ }
+ for (int i = 0; i < nl.digits_size(); i++) {
+ ret += digits[nl.digits(i) % sizeof(digits)];
+ }
+ if (nl.decimal_point()) {
+ ret += ".";
+ if (nl.dec_digits_size() == 0) {
+ ret += "0";
+ } else {
+ for (int i = 0; i < nl.dec_digits_size(); i++) {
+ ret += digits[nl.dec_digits(i) % sizeof(digits)];
+ }
+ }
+ }
+ if (nl.exp_digits_size() > 0) {
+ ret += "E";
+ if (nl.negative_exp())
+ ret += "-";
+ if (nl.exp_digits_size() == 0) {
+ ret += "0";
+ } else {
+ for (int i = 0; i < nl.exp_digits_size(); i++) {
+ ret += digits[nl.exp_digits(i) % sizeof(digits)];
+ }
+ }
+ }
+
+ return ret;
+}
+
+// WARNING does not include space
+CONV_FN(LiteralValue, lit_val) {
+ std::string ret;
+ using LitValType = LiteralValue::LitValOneofCase;
+ switch (lit_val.lit_val_oneof_case()) {
+ case LitValType::kNumLit:
+ return std::to_string(lit_val.num_lit());
+ case LitValType::kStringLit:
+ ret += '\'';
+ ret += ConvertToSqlString(lit_val.string_lit());
+ ret += '\'';
+ return ret;
+ case LitValType::kBlobLit:
+ ret += "x\'";
+ ret += BytesToHex(lit_val.blob_lit());
+ ret += '\'';
+ return ret;
+ case LitValType::kSpecialVal:
+ // special case for NULL, TRUE, FALSE
+ if (lit_val.special_val() == LiteralValue::VAL_NULL)
+ return "NULL";
+ if (lit_val.special_val() == LiteralValue::VAL_TRUE)
+ return "TRUE";
+ if (lit_val.special_val() == LiteralValue::VAL_FALSE)
+ return "FALSE";
+ // do not remove underscores
+ return LiteralValue_SpecialVal_Name(lit_val.special_val());
+ case LitValType::kNumericLit:
+ return NumericLiteralToString(lit_val.numeric_lit());
+ default:
+ return "1";
+ }
+}
+
+CONV_FN(UnaryExpr, uexpr) {
+ std::string ret;
+ switch (uexpr.unary_op()) {
+ case UNOP_MINUS:
+ ret += "-";
+ break;
+ case UNOP_PLUS:
+ ret += "+";
+ break;
+ case UNOP_TILDE:
+ ret += "~";
+ break;
+ case UNOP_NOT:
+ ret += "NOT ";
+ break;
+ default:
+ break;
+ }
+ ret += ExprToString(uexpr.expr());
+ return ret;
+}
+
+CONV_FN(BinaryOperator, bop) {
+ switch (bop) {
+ case BINOP_CONCAT:
+ return " || ";
+ break;
+ case BINOP_STAR:
+ return " * ";
+ break;
+ case BINOP_SLASH:
+ return " / ";
+ break;
+ case BINOP_PERCENT:
+ return " % ";
+ break;
+ case BINOP_PLUS:
+ return " + ";
+ break;
+ case BINOP_MINUS:
+ return " - ";
+ break;
+ case BINOP_LELE:
+ return " << ";
+ break;
+ case BINOP_GRGR:
+ return " >> ";
+ break;
+ case BINOP_AMPERSAND:
+ return " & ";
+ break;
+ case BINOP_PIPE:
+ return " | ";
+ break;
+ case BINOP_LE:
+ return " < ";
+ break;
+ case BINOP_LEQ:
+ return " <= ";
+ break;
+ case BINOP_GR:
+ return " > ";
+ break;
+ case BINOP_GREQ:
+ return " >= ";
+ break;
+ case BINOP_EQ:
+ return " = ";
+ break;
+ case BINOP_EQEQ:
+ return " == ";
+ break;
+ case BINOP_NOTEQ:
+ return " != ";
+ break;
+ case BINOP_LEGR:
+ return " <> ";
+ break;
+ case BINOP_IS:
+ return " IS ";
+ break;
+ case BINOP_ISNOT:
+ return " IS NOT ";
+ break;
+ case BINOP_IN:
+ return " IN "; // CORPUS specialize?
+ break;
+ case BINOP_LIKE:
+ return " LIKE "; // CORPUS specialize?
+ break;
+ case BINOP_GLOB:
+ return " GLOB "; // CORPUS
+ break;
+ case BINOP_MATCH:
+ return " MATCH "; // CORPUS
+ break;
+ case BINOP_REGEXP:
+ return " REGEXP "; // CORPUS
+ break;
+ case BINOP_AND:
+ return " AND ";
+ break;
+ case BINOP_OR:
+ return " OR ";
+ break;
+ default:
+ return " AND ";
+ break;
+ }
+}
+
+// TODO(mpdenton) generate better REGEXP queries in non-fts3 case. (in
+// ColumnComparison as well)
+// TODO(mpdenton) generate better MATCH queries in non-fts3 case.
+CONV_FN(BinaryExpr, bexpr) {
+ std::string ret;
+ ret += ExprToString(bexpr.lhs());
+ ret += BinaryOperatorToString(bexpr.op());
+#if defined(FUZZ_FTS3)
+ if (bexpr.op() == BINOP_MATCH && bexpr.has_fmt()) {
+ ret += FTS3MatchFormatToString(bexpr.fmt());
+ return ret;
+ }
+#endif
+ ret += ExprToString(bexpr.rhs());
+ return ret;
+}
+
+CONV_FN(AggregateFn, af) {
+ std::string ret;
+ ret += StrToLower(AggregateFn_FnName_Name(af.fn_name()));
+ ret += "(";
+ if (af.fn_name() == AggregateFn::COUNT && af.count_star())
+ return ret + "*) ";
+ if (af.distinct())
+ ret += "DISTINCT ";
+ if (af.has_col1()) {
+ ret += ColumnToString(af.col1());
+ if (af.fn_name() == AggregateFn::GROUP_CONCAT && af.has_col2()) {
+ ret += ", ";
+ ret += ColumnToString(af.col2());
+ }
+ } else {
+ ret += ExprToString(af.expr1());
+ if (af.fn_name() == AggregateFn::GROUP_CONCAT && af.has_expr2()) {
+ ret += ", ";
+ ret += ExprToString(af.expr2());
+ }
+ }
+
+ ret += ") ";
+ return ret;
+}
+
+CONV_FN(ZeroArgFn, zaf) {
+ std::string func = ZeroArgFn_Name(zaf);
+ // Remove ZFN_ prefix
+ func.erase(0, std::string("ZFN_").length());
+ return StrToLower(func) + "() ";
+}
+
+CONV_FN(OneArgFn, oaf) {
+ std::string ret;
+ ret += StripTrailingUnderscores(
+ StrToLower(OneArgFn_OneArgFnEnum_Name(oaf.fn_enum())));
+ ret += "(";
+ ret += ExprToString(oaf.arg1());
+ ret += ") ";
+ return ret;
+}
+
+CONV_FN(TwoArgFn, taf) {
+ std::string ret;
+ ret += StrToLower(TwoArgFn_TwoArgFnEnum_Name(taf.fn_enum()));
+ ret += "(";
+ ret += ExprToString(taf.arg1());
+ ret += ", ";
+ ret += ExprToString(taf.arg2());
+ ret += ") ";
+ return ret;
+}
+
+CONV_FN(ThreeArgFn, taf) {
+ std::string ret;
+ ret += StrToLower(ThreeArgFn_ThreeArgFnEnum_Name(taf.fn_enum()));
+ ret += "(";
+ ret += ExprToString(taf.arg1());
+ ret += ", ";
+ ret += ExprToString(taf.arg2());
+ ret += ", ";
+ ret += ExprToString(taf.arg3());
+ ret += ") ";
+ return ret;
+}
+
+CONV_FN(VarNumFn, vfn) {
+ std::string ret;
+ ret += StrToLower(VarNumFn_VarNumFnEnum_Name(vfn.fn_enum()));
+ ret += "(";
+ ret += ExprToString(vfn.arg1());
+ ret += ", ";
+ ret += ExprToString(vfn.arg2());
+ for (int i = 0; i < vfn.other_args_size(); i++) {
+ ret += ", ";
+ ret += ExprToString(vfn.other_args(i));
+ }
+ ret += ") ";
+ return ret;
+}
+
+CONV_FN(CharFn, cfn) {
+ std::string ret("char(");
+ ret += std::to_string(cfn.char_());
+ for (int i = 0; i < cfn.extra_chars_size(); i++) {
+ ret += ", ";
+ ret += std::to_string(cfn.extra_chars(i));
+ }
+ ret += ") ";
+ return ret;
+}
+
+CONV_FN(SimpleFn, sfn) {
+ // oneof
+ if (sfn.has_zero_arg_fn()) {
+ return ZeroArgFnToString(sfn.zero_arg_fn());
+ } else if (sfn.has_one_arg_fn()) {
+ return OneArgFnToString(sfn.one_arg_fn());
+ } else if (sfn.has_two_arg_fn()) {
+ return TwoArgFnToString(sfn.two_arg_fn());
+ } else if (sfn.has_three_arg_fn()) {
+ return ThreeArgFnToString(sfn.three_arg_fn());
+ } else if (sfn.has_varnum_fn()) {
+ return VarNumFnToString(sfn.varnum_fn());
+ } else if (sfn.has_char_fn()) {
+ return CharFnToString(sfn.char_fn());
+ } else {
+ return "changes() ";
+ }
+}
+
+CONV_FN(PrintfFormatSpecifier, pfs) {
+ std::string ret("%");
+ for (int i = 0; i < pfs.flags_size(); i++) {
+ switch (pfs.flags(i)) {
+ case PrintfFormatSpecifier::MINUS:
+ ret += "-";
+ break;
+ case PrintfFormatSpecifier::PLUS:
+ ret += "+";
+ break;
+ case PrintfFormatSpecifier::SPACE:
+ ret += " ";
+ break;
+ case PrintfFormatSpecifier::ZERO:
+ ret += "0";
+ break;
+ case PrintfFormatSpecifier::HASH:
+ ret += "#";
+ break;
+ case PrintfFormatSpecifier::COMMA:
+ ret += ",";
+ break;
+ case PrintfFormatSpecifier::BANG:
+ ret += "!";
+ break;
+ }
+ }
+ if (pfs.has_width()) {
+ ret += std::to_string(pfs.width());
+ } else if (pfs.width_star()) {
+ ret += "*";
+ }
+ if (pfs.has_precision()) {
+ ret += ".";
+ ret += std::to_string(pfs.precision());
+ }
+ if (pfs.has_length()) {
+ if (pfs.length() % 3 == 1) {
+ ret += "l";
+ } else if (pfs.length() % 3 == 2) {
+ ret += "ll";
+ }
+ }
+ if (pfs.percent()) {
+ ret += "%";
+ } else {
+ std::string specifier = PrintfFormatSpecifier_SubType_Name(pfs.sub_type());
+ if (pfs.lowercase())
+ specifier = StrToLower(specifier);
+ ret += specifier;
+ }
+ return ret;
+}
+
+CONV_FN(Printf, p) {
+ std::string ret("printf(\'");
+ for (int i = 0; i < p.specifiers_size(); i++) {
+ ret += PrintfFormatSpecifierToString(p.specifiers(i));
+ if (i < p.strings_size()) {
+ ret += ConvertToSqlString(p.strings(i));
+ }
+ }
+ ret += "\'";
+ for (int i = 0; i < p.exprs_size(); i++) {
+ ret += ", ";
+ ret += ExprToString(p.exprs(i));
+ }
+ ret += ") ";
+ return ret;
+}
+
+CONV_FN(Fn, fn) {
+ // oneof
+ if (fn.has_simple_fn()) {
+ return SimpleFnToString(fn.simple_fn());
+ } else if (fn.has_fts_aux_fn()) {
+#if defined(FUZZ_FTS3)
+ return FTS3AuxiliaryFnToString(fn.fts_aux_fn()) + " ";
+#else
+ return "changes() ";
+#endif
+ } else if (fn.has_dat_fn()) {
+ return DateAndTimeFnToString(fn.dat_fn());
+ } else if (fn.has_aggregate_fn()) {
+ return AggregateFnToString(fn.aggregate_fn());
+ } else if (fn.has_printf()) {
+ return PrintfToString(fn.printf());
+ } else {
+ return "changes() ";
+ }
+}
+
+CONV_FN(ParenthesesExpr, pexpr) {
+ std::string ret("(");
+ ret += ExprToString(pexpr.expr());
+ for (int i = 0; i < pexpr.other_exprs_size(); i++) {
+ ret += ", ";
+ ret += ExprToString(pexpr.other_exprs(i));
+ }
+ ret += ") ";
+ return ret;
+}
+
+CONV_FN(CastExpr, cexpr) {
+ std::string ret("CAST(");
+ ret += ExprToString(cexpr.expr());
+ ret += " AS ";
+ ret += EnumStrReplaceUnderscores(
+ CastTypeName_CastTypeNameEnum_Name(cexpr.type_name().type_enum()));
+ ret += ") ";
+ return ret;
+}
+
+CONV_FN(CollateExpr, cexpr) {
+ std::string ret;
+ ret += ExprToString(cexpr.expr());
+ ret += " COLLATE ";
+ ret += CollateTypeToString(cexpr.collate_type());
+ return ret;
+}
+
+CONV_FN(Expr1, e) {
+ std::string ret;
+ ret += ExprToString(e.expr1());
+ ret += " ";
+ if (e.not_())
+ ret += "NOT ";
+ ret += EnumStrReplaceUnderscores(Expr1_PossibleKeywords_Name(e.keyword()));
+ ret += " ";
+ ret += ExprToString(e.expr2());
+ ret += " "; //
+ if (e.has_escape_expr()) {
+ ret += "ESCAPE ";
+ ret += ExprToString(e.escape_expr());
+ ret += " "; //
+ }
+ return ret;
+}
+
+CONV_FN(ExprNullTests, e) {
+ std::string ret = ExprToString(e.expr());
+ ret += " ";
+ ret += EnumStrReplaceUnderscores(
+ ExprNullTests_PossibleKeywords_Name(e.keyword()));
+ ret += " ";
+ return ret;
+}
+
+CONV_FN(ExprIs, e) {
+ std::string ret = ExprToString(e.expr1());
+ ret += " IS ";
+ if (e.not_())
+ ret += "NOT ";
+ ret += ExprToString(e.expr2());
+ ret += " "; //
+ return ret;
+}
+
+CONV_FN(ExprBetween, e) {
+ std::string ret;
+ ret += ExprToString(e.expr1());
+ ret += " ";
+ if (e.not_())
+ ret += "NOT ";
+ ret += "BETWEEN ";
+ ret += ExprToString(e.expr2());
+ ret += " AND ";
+ ret += ExprToString(e.expr3());
+ return ret;
+}
+
+CONV_FN(ExprInParen, e) {
+ std::string ret("(");
+ // oneof
+ if (e.has_select()) {
+ ret += SelectToString(e.select());
+ } else if (e.has_exprs()) {
+ ret += ExprListToString(e.exprs());
+ }
+
+ ret += ") ";
+ return ret;
+}
+
+CONV_FN(ExprIn, e) {
+ std::string ret = ExprToString(e.expr());
+ ret += " ";
+ if (e.not_())
+ ret += "NOT ";
+ if (e.has_expr_in_paren()) {
+ ret += ExprInParenToString(e.expr_in_paren());
+ } else if (e.has_schema_table()) {
+ ret += ExprSchemaTableToString(e.schema_table());
+ } else if (e.has_schema_table_fn()) {
+ ret += ExprSchemaTableFnToString(e.schema_table_fn());
+ } else {
+ ret += "()";
+ }
+ return ret + " ";
+}
+
+CONV_FN(ExprExists, e) {
+ std::string ret;
+ if (e.not_())
+ ret += "NOT EXISTS ";
+ else if (e.exists())
+ ret += "EXISTS ";
+ ret += "(";
+ ret += SelectToString(e.select());
+ ret += ") ";
+ return ret;
+}
+
+// WARNING no space at end
+CONV_FN(ExprWhenThen, e) {
+ std::string ret("WHEN ");
+ ret += ExprToString(e.when_expr());
+ ret += " THEN ";
+ ret += ExprToString(e.then_expr());
+ return ret;
+}
+
+CONV_FN(ExprCase, e) {
+ std::string ret("CASE ");
+ if (e.has_expr()) {
+ ret += ExprToString(e.expr());
+ ret += " ";
+ }
+ ret += ExprWhenThenToString(e.when_then());
+ ret += " ";
+ for (int i = 0; i < e.extra_when_thens_size(); i++) {
+ ret += ExprWhenThenToString(e.extra_when_thens(i));
+ ret += " ";
+ }
+ if (e.has_else_expr()) {
+ ret += "ELSE ";
+ ret += ExprToString(e.else_expr());
+ ret += " ";
+ }
+ ret += "END ";
+ return ret;
+}
+
+CONV_FN(ExprRaiseFn, e) {
+ std::string ret("RAISE(");
+ if (e.ignore()) {
+ ret += "IGNORE";
+ } else {
+ ret +=
+ EnumStrReplaceUnderscores(ExprRaiseFn_RaiseFnEnum_Name(e.raise_fn()));
+ ret += " ";
+ ret += ", \'";
+ ret += ConvertToSqlString(e.error_msg());
+ ret += "\'";
+ }
+ ret += ") ";
+ return ret;
+}
+
+CONV_FN(ComplicatedExpr, expr) {
+ using ExprType = ComplicatedExpr::ComplicatedExprOneofCase;
+ switch (expr.complicated_expr_oneof_case()) {
+ case ExprType::kExprStc:
+ return ExprSchemaTableColumnToString(expr.expr_stc());
+ case ExprType::kUnaryExpr:
+ return UnaryExprToString(expr.unary_expr());
+ case ExprType::kBinaryExpr:
+ return BinaryExprToString(expr.binary_expr());
+ case ExprType::kFnExpr:
+ return FnToString(expr.fn_expr());
+ case ExprType::kParExpr:
+ return ParenthesesExprToString(expr.par_expr());
+ case ExprType::kCastExpr:
+ return CastExprToString(expr.cast_expr());
+ case ExprType::kCollateExpr:
+ return CollateExprToString(expr.collate_expr());
+ case ExprType::kExpr1:
+ return Expr1ToString(expr.expr1());
+ case ExprType::kExprNullTests:
+ return ExprNullTestsToString(expr.expr_null_tests());
+ case ExprType::kExprIs:
+ return ExprIsToString(expr.expr_is());
+ case ExprType::kExprBetween:
+ return ExprBetweenToString(expr.expr_between());
+ case ExprType::kExprIn:
+ return ExprInToString(expr.expr_in());
+ case ExprType::kExprExists:
+ return ExprExistsToString(expr.expr_exists());
+ case ExprType::kExprCase:
+ return ExprCaseToString(expr.expr_case());
+ case ExprType::kExprRaise:
+ return ExprRaiseFnToString(expr.expr_raise());
+ default:
+ return "1";
+ }
+}
+
+// TODO(mpdenton) wrap in parentheses???
+CONV_FN(Expr, expr) {
+ if (expr.has_lit_val()) {
+ return LiteralValueToString(expr.lit_val());
+ } else if (expr.has_comp_expr()) {
+ return ComplicatedExprToString(expr.comp_expr());
+ } else { // default
+ return "1";
+ }
+}
+
+// ~~~~Other~~~~
+
+std::string ForeignKeyClauseNotMatchToString(
+ const ForeignKeyClauseNotMatch& nm) {
+ std::string ret("ON ");
+ ret += EnumStrReplaceUnderscores(
+ ForeignKeyClauseNotMatch_DeleteOrUpdate_Name(nm.del_or_update()));
+ ret += " ";
+ ret += EnumStrReplaceUnderscores(
+ ForeignKeyClauseNotMatch_Action_Name(nm.action()));
+ ret += " ";
+ return ret;
+}
+
+CONV_FN(ForeignKeyClauseCore, fkc) {
+ if (fkc.has_fkey_not_match())
+ return ForeignKeyClauseNotMatchToString(fkc.fkey_not_match());
+
+ return "MATCH PARTIAL"; // Sqlite does not actually parse MATCH clauses. This
+ // is assumed to be MATCH SIMPLE.
+}
+
+CONV_FN(DeferStrategy, ds) {
+ std::string ret;
+ if (ds.not_()) {
+ ret += "NOT ";
+ }
+ ret += "DEFERRABLE ";
+ ret +=
+ EnumStrReplaceUnderscores(DeferStrategy_DeferStratEnum_Name(ds.strat()));
+ return ret;
+}
+
+CONV_FN(ForeignKeyClause, fkey_clause) {
+ std::string ret("REFERENCES ");
+ ret += TableToString(fkey_clause.foreign_table());
+ if (fkey_clause.has_col_list()) {
+ ret += "(";
+ ret += ColumnListToString(fkey_clause.col_list());
+ ret += ")";
+ }
+ ret += " ";
+ for (int i = 0; i < fkey_clause.fkey_cores_size(); i++) {
+ ret += ForeignKeyClauseCoreToString(fkey_clause.fkey_cores(i));
+ ret += " ";
+ }
+ if (fkey_clause.has_defer_strat()) {
+ ret += DeferStrategyToString(fkey_clause.defer_strat());
+ ret += " ";
+ }
+ return ret;
+}
+
+CONV_FN(ConflictClause, conf) {
+ if (!conf.has_on_conflict())
+ return " ";
+
+ std::string ret("ON CONFLICT ");
+ ret += EnumStrReplaceUnderscores(
+ ConflictClause_OnConflict_Name(conf.on_conflict()));
+ ret += " ";
+ return ret;
+}
+
+CONV_FN(ColConstraintOpt1, opt1) {
+ std::string ret("PRIMARY KEY ");
+ ret += AscDescToString(opt1.asc_desc());
+ // space at the end already
+ ret += ConflictClauseToString(opt1.conflict());
+ if (opt1.autoincrement())
+ ret += "AUTOINCREMENT ";
+
+ return ret;
+}
+
+CONV_FN(ColConstraintOpt2, opt2) {
+ std::string ret("DEFAULT ");
+ if (opt2.has_expr()) {
+ ret += "(";
+ ret += ExprToString(opt2.expr());
+ ret += ")";
+ } else {
+ ret += LiteralValueToString(opt2.lit_val());
+ }
+
+ ret += " ";
+ return ret;
+}
+
+CONV_FN(ColumnConstraint, col_constr) {
+ std::string ret;
+ if (col_constr.has_constraint_name()) {
+ ret += "CONSTRAINT ";
+ ret += ColumnConstraintNameToString(col_constr.constraint_name());
+ ret += " ";
+ }
+
+ using ColConstrType = ColumnConstraint::ColConstraintOneofCase;
+ switch (col_constr.col_constraint_oneof_case()) {
+ case ColConstrType::kOpt1:
+ ret += ColConstraintOpt1ToString(col_constr.opt1());
+ break;
+ case ColConstrType::kNotNullConfClause:
+ ret += "NOT NULL ";
+ ret += ConflictClauseToString(col_constr.not_null_conf_clause());
+ break;
+ case ColConstrType::kUniqueConfClause:
+ ret += "UNIQUE ";
+ ret += ConflictClauseToString(col_constr.unique_conf_clause());
+ break;
+ case ColConstrType::kCheckExpr:
+ ret += "CHECK(";
+ ret += ExprToString(col_constr.check_expr());
+ ret += ") ";
+ break;
+ case ColConstrType::kOpt2:
+ ret += ColConstraintOpt2ToString(col_constr.opt2());
+ break;
+ case ColConstrType::kCollate:
+ ret += "COLLATE ";
+ ret += CollateTypeToString(col_constr.collate());
+ ret += " ";
+ break;
+ case ColConstrType::kFkeyClause:
+ ret += ForeignKeyClauseToString(col_constr.fkey_clause());
+ break;
+ default:
+ ret += ColConstraintOpt2ToString(col_constr.opt2_fallback());
+ }
+
+ return ret;
+}
+
+CONV_FN(TypeName, type_name) {
+ std::string ret;
+ ret += EnumStrReplaceUnderscores(
+ CastTypeName_CastTypeNameEnum_Name(type_name.ctn().type_enum()));
+ if (type_name.has_sn()) {
+ ret += "(";
+ ret += std::to_string(type_name.sn());
+ ret += ")";
+ }
+ ret += " ";
+ return ret;
+}
+
+CONV_FN(ColumnDef, col_def) {
+ std::string ret;
+ ret += ColumnToString(col_def.col());
+ ret += " ";
+ if (col_def.has_type_name()) {
+ ret += TypeNameToString(col_def.type_name());
+ ret += " ";
+ }
+
+ for (int i = 0; i < col_def.col_constraints_size(); i++) {
+ ret += ColumnConstraintToString(col_def.col_constraints(i));
+ ret += " ";
+ }
+
+ return ret;
+}
+
+CONV_FN(TableConstraintOpt1, opt1) {
+ std::string ret;
+ ret += EnumStrReplaceUnderscores(
+ TableConstraintOpt1_ConstraintType_Name(opt1.constraint_type()));
+ ret += "(";
+ ret += IndexedColumnListToString(opt1.indexed_col_list());
+ ret += ") ";
+ ret += ConflictClauseToString(opt1.conf_clause());
+
+ return ret;
+}
+
+CONV_FN(TableConstraintOpt2, opt2) {
+ std::string ret("FOREIGN KEY (");
+ ret += ColumnListToString(opt2.cols());
+ ret += ") ";
+
+ ret += ForeignKeyClauseToString(opt2.fkey_clause());
+ return ret;
+}
+
+CONV_FN(TableConstraint, t_constr) {
+ std::string ret;
+ if (t_constr.has_name()) {
+ ret += "CONSTRAINT ";
+ ret += TableConstraintNameToString(t_constr.name());
+ ret += " ";
+ }
+
+ if (t_constr.has_opt1()) {
+ ret += TableConstraintOpt1ToString(t_constr.opt1());
+ } else if (t_constr.has_check_expr()) {
+ ret += "CHECK(";
+ ret += ExprToString(t_constr.check_expr()); // TODO(mpdenton)
+ ret += ") ";
+ } else if (t_constr.has_opt2()) {
+ ret += TableConstraintOpt2ToString(t_constr.opt2());
+ } else {
+ // default to no constraint
+ ret += "CHECK(1)";
+ }
+
+ ret += " ";
+ return ret;
+}
+
+CONV_FN(CreateTableOpt1, opt1) {
+ std::string ret("(");
+ ret += ColumnDefToString(opt1.col_def());
+ for (int i = 0; i < opt1.extra_col_defs_size(); i++) {
+ ret += ", ";
+ ret += ColumnDefToString(opt1.extra_col_defs(i));
+ }
+ for (int i = 0; i < opt1.table_constraints_size(); i++) {
+ ret += ", ";
+ ret += TableConstraintToString(opt1.table_constraints(i));
+ }
+ ret += ") ";
+
+ if (opt1.without_rowid())
+ ret += "WITHOUT ROWID ";
+
+ return ret;
+}
+
+CONV_FN(CreateTable, create_table) {
+ RETURN_IF_DISABLED_QUERY(CreateTable);
+#if defined(FUZZ_FTS3)
+ return ""; // Don't create normal tables in FTS3 fuzzing mode.
+#endif
+ std::string ret("CREATE ");
+ if (create_table.has_temp_modifier()) {
+ ret += EnumStrReplaceUnderscores(
+ TempModifier_Name(create_table.temp_modifier()))
+ .erase(0, std::string("TM_").length());
+ ret += " ";
+ }
+ ret += "TABLE ";
+ if (create_table.if_not_exists())
+ ret += "IF NOT EXISTS ";
+
+ ret += ExprSchemaTableToString(create_table.schema_table());
+ ret += " ";
+
+ // TODO(mpdenton) need spaces at the end here???
+ using TableCreationType = CreateTable::CreateTableOneofCase;
+ switch (create_table.create_table_oneof_case()) {
+ case TableCreationType::kOp1:
+ ret += CreateTableOpt1ToString(create_table.op1());
+ break;
+ case TableCreationType::kAsSelectStmt:
+ ret += SelectToString(create_table.as_select_stmt());
+ break;
+ default:
+ ret += CreateTableOpt1ToString(create_table.op());
+ break;
+ }
+
+ return ret; // TODO(mpdenton)
+}
+
+// ~~~~For INSERT and SELECT~~~~
+
+CONV_FN(CommonTableExpr, cte) {
+ std::string ret;
+ ret += TableToString(cte.table());
+ if (cte.columns_size() > 0) {
+ ret += "(";
+ ret += ColumnToString(cte.columns(0));
+ for (int i = 1; i < cte.columns_size(); i++) {
+ ret += ", ";
+ ret += ColumnToString(cte.columns(i));
+ }
+ ret += ")";
+ }
+ ret += " AS (";
+ ret += SelectToString(cte.select());
+ ret += ") ";
+ return ret;
+}
+
+CONV_FN(WithStatement, ws) {
+ std::string ret("WITH ");
+ if (ws.recursive())
+ ret += "RECURSIVE ";
+ ret += CommonTableExprToString(ws.table_expr());
+ ret += " ";
+ for (int i = 0; i < ws.extra_table_exprs_size(); i++) {
+ ret += CommonTableExprToString(ws.extra_table_exprs(i));
+ ret += " ";
+ }
+ ret += " ";
+ return ret;
+}
+
+// ~~~~INSERT~~~~
+
+// WARNING no space at end
+CONV_FN(ColumnComparison, cc) {
+ std::string ret;
+ ret += ExprSchemaTableColumnToString(cc.col());
+ ret += BinaryOperatorToString(cc.op());
+#if defined(FUZZ_FTS3)
+ if (cc.op() == BINOP_MATCH && cc.has_fmt()) {
+ ret += FTS3MatchFormatToString(cc.fmt());
+ return ret;
+ }
+#endif
+ ret += ExprToString(cc.expr());
+ return ret;
+}
+
+// WARNING no space at end
+CONV_FN(ExprComparisonHighProbability, echp) {
+ if (echp.has_cc()) {
+ return ColumnComparisonToString(echp.cc());
+ } else if (echp.has_expr()) {
+ return ExprToString(echp.expr());
+ } else {
+ return "Col0 = 1"; // default
+ }
+}
+
+CONV_FN(WhereStatement, ws) {
+ return "WHERE " + ExprComparisonHighProbabilityToString(ws.expr()) + " ";
+}
+
+#ifndef SQLITE_OMIT_UPSERT
+CONV_FN(UpsertClausePart1, uc1) {
+ std::string ret;
+ ret += "(";
+ ret += IndexedColumnListToString(uc1.icol_list());
+ ret += ") ";
+ if (uc1.has_where_stmt()) {
+ ret += WhereStatementToString(uc1.where_stmt());
+ ret += " ";
+ }
+ return ret;
+}
+#endif
+
+// WARNING no space at end
+CONV_FN(ColEqualsExpr, cee) {
+ std::string ret;
+ if (cee.has_col()) {
+ ret += ColumnToString(cee.col());
+ } else if (cee.has_col_list()) {
+ ret += ColumnListToString(cee.col_list());
+ } else {
+ ret += "Col0"; // default
+ }
+ ret += " = ";
+ ret += ExprToString(cee.expr());
+ return ret;
+}
+
+CONV_FN(UpsertClausePart2, uc2) {
+ std::string ret("SET ");
+ ret += ColEqualsExprToString(uc2.cee());
+ for (int i = 0; i < uc2.extra_cees_size(); i++) {
+ ret += ", ";
+ ret += ColEqualsExprToString(uc2.extra_cees(i));
+ }
+ if (uc2.has_where_stmt()) {
+ ret += " ";
+ ret += WhereStatementToString(uc2.where_stmt());
+ }
+ ret += " ";
+ return ret;
+}
+
+CONV_FN(UpsertClause, uc) {
+#ifndef SQLITE_OMIT_UPSERT
+ std::string ret("ON CONFLICT ");
+ if (uc.has_uclause_p1()) {
+ ret += UpsertClausePart1ToString(uc.uclause_p1());
+ }
+ ret += "DO ";
+ if (uc.has_uclause_p2()) {
+ ret += "UPDATE ";
+ ret += UpsertClausePart2ToString(uc.uclause_p2());
+ } else {
+ ret += "NOTHING ";
+ }
+ return ret;
+#else
+ return ""; // fine to return empty string here
+#endif
+}
+
+CONV_FN(ValuesStatement, values) {
+ std::string ret("VALUES (");
+ ret += ExprListToString(values.expr_list());
+ ret += ")";
+ for (int i = 0; i < values.extra_expr_lists_size(); i++) {
+ ret += ", (";
+ ret += ExprListToString(values.extra_expr_lists(i));
+ ret += ")";
+ }
+ ret += " ";
+ return ret;
+}
+
+CONV_FN(Insert, insert) {
+ RETURN_IF_DISABLED_QUERY(Insert);
+ std::string ret;
+ if (insert.has_with()) {
+ ret += WithStatementToString(insert.with());
+ ret += " ";
+ }
+
+ ret +=
+ EnumStrReplaceUnderscores(Insert_InsertType_Name(insert.insert_type()));
+ ret += " INTO ";
+ ret += SchemaTableAsAliasToString(insert.staa());
+
+ if (insert.has_col_list()) {
+ ret += "(";
+ ret += ColumnListToString(insert.col_list());
+ ret += ") ";
+ }
+
+ // oneof
+ if (insert.has_values()) {
+ ret += ValuesStatementToString(insert.values());
+ ret += " ";
+ } else if (insert.has_select()) {
+ ret += SelectToString(insert.select());
+ ret += " ";
+ } else {
+ ret += "DEFAULT VALUES ";
+ }
+
+ if (insert.has_upsert_clause()) {
+ ret += UpsertClauseToString(insert.upsert_clause());
+ ret += " ";
+ }
+ return ret;
+}
+
+// ~~~~DELETE~~~~
+
+CONV_FN(QualifiedTableName, qtn) {
+ std::string ret;
+ ret += SchemaTableAsAliasToString(qtn.staa());
+ ret += " ";
+ if (qtn.indexed()) {
+ if (qtn.not_indexed()) {
+ ret += "NOT INDEXED ";
+ } else {
+ ret += "INDEXED BY ";
+ ret += IndexToString(qtn.indexed_by());
+ ret += " ";
+ }
+ }
+ return ret;
+}
+
+CONV_FN(Delete, delete_) {
+ RETURN_IF_DISABLED_QUERY(Delete);
+ std::string ret;
+ if (delete_.has_with()) {
+ ret += WithStatementToString(delete_.with());
+ ret += " ";
+ }
+ ret += "DELETE FROM ";
+ ret += QualifiedTableNameToString(delete_.qtn());
+ if (delete_.has_where()) {
+ ret += WhereStatementToString(delete_.where());
+ }
+ ret += " ";
+ return ret;
+}
+
+// ~~~~UPDATE~~~~
+// WARNING no space at end
+CONV_FN(Update, update) {
+ RETURN_IF_DISABLED_QUERY(Update);
+ std::string ret;
+ if (update.has_with()) {
+ ret += WithStatementToString(update.with());
+ ret += " ";
+ }
+ ret += "UPDATE ";
+ if (update.has_update_type()) {
+ ret +=
+ EnumStrReplaceUnderscores(Update_UpdateType_Name(update.update_type()));
+ ret += " ";
+ }
+ ret += QualifiedTableNameToString(update.qtn());
+ ret += " ";
+ ret += UpsertClausePart2ToString(update.ucp2());
+ return ret;
+}
+// TODO(mpdenton) restrictions on UPDATEs in CREATE TRIGGER????
+
+// ~~~~SELECT~~~~
+
+CONV_FN(ExprColAlias, eca) {
+ std::string ret;
+ ret += ExprToString(eca.expr());
+ ret += " ";
+ if (eca.has_col_alias()) {
+ if (eca.as()) {
+ ret += "AS ";
+ }
+ ret += ColumnToString(eca.col_alias());
+ ret += " ";
+ }
+ return ret;
+}
+
+// WARNING no space at end
+CONV_FN(ResultColumn, rc) {
+ std::string ret;
+ // oneof
+ if (rc.has_col()) {
+ return ColumnToString(rc.col());
+ } else if (rc.has_eca()) {
+ return ExprColAliasToString(rc.eca());
+ } else if (rc.has_table_star()) {
+ return TableToString(rc.table_star()) + ".*";
+ } else if (rc.has_fts3_fn()) {
+#if defined(FUZZ_FTS3)
+ return FTS3AuxiliaryFnToString(rc.fts3_fn());
+#else
+ return "*";
+#endif
+ } else {
+ return "*";
+ }
+}
+
+CONV_FN(AsTableAlias, ata) {
+ std::string ret;
+ if (ata.as()) {
+ ret += "AS ";
+ }
+ ret += TableToString(ata.table_alias());
+ ret += " ";
+ return ret;
+}
+
+// WARNING no space at end
+CONV_FN(JoinOperator, jo) {
+ if (jo.comma())
+ return ",";
+
+ std::string ret;
+ if (jo.natural())
+ ret += "NATURAL ";
+
+ if (jo.join_type() != JoinOperator::NONE) {
+ ret +=
+ EnumStrReplaceUnderscores(JoinOperator_JoinType_Name(jo.join_type()));
+ ret += " ";
+ }
+ ret += "JOIN ";
+ return ret;
+}
+
+CONV_FN(JoinConstraint, jc) {
+ // oneof
+ if (jc.has_on_expr()) {
+ return "ON " + ExprToString(jc.on_expr()) + " ";
+ } else if (jc.has_using_expr()) {
+ std::string ret("(");
+ ret += ColumnListToString(jc.using_expr().col_list());
+ ret += ") ";
+ return ret;
+ }
+ return " ";
+}
+
+CONV_FN(JoinClauseCore, jcc) {
+ std::string ret;
+ ret += JoinOperatorToString(jcc.join_op());
+ ret += " ";
+ ret += TableOrSubqueryToString(jcc.tos());
+ ret += " ";
+ ret += JoinConstraintToString(jcc.join_constraint());
+ ret += " ";
+ return ret;
+}
+
+CONV_FN(JoinClause, jc) {
+ std::string ret;
+ ret += TableOrSubqueryToString(jc.tos());
+ ret += " ";
+ for (int i = 0; i < jc.clauses_size(); i++) {
+ ret += JoinClauseCoreToString(jc.clauses(i));
+ }
+ ret += " ";
+ return ret;
+}
+
+// TODO(mpdenton) ExprIn needs it schematablefn!!!!!
+
+CONV_FN(ExprSchemaTableFn, estf) {
+ std::string ret;
+ const TableFn& tfn = estf.table_fn();
+ // oneof for pragma fns
+ if (tfn.has_foreign_key_list()) {
+ ret += "pragma_foreign_key_list(\'";
+ ret += TableToString(tfn.foreign_key_list());
+ ret += "\') ";
+ } else if (tfn.has_index_info()) {
+ ret += "pragma_index_info(\'";
+ ret += IndexToString(tfn.index_info());
+ ret += "\') ";
+ } else if (tfn.has_index_list()) {
+ ret += "pragma_index_list(\'";
+ ret += TableToString(tfn.index_list());
+ ret += "\') ";
+ } else if (tfn.has_index_xinfo()) {
+ ret += "pragma_index_xinfo(\'";
+ ret += IndexToString(tfn.index_xinfo());
+ ret += "\') ";
+ } else if (tfn.has_integrity_check()) {
+ ret += "pragma_integrity_check(\'";
+ ret += std::to_string(tfn.integrity_check());
+ ret += "\') ";
+ } else if (tfn.has_optimize()) {
+ ret += "pragma_optimize(\'";
+ ret += std::to_string(tfn.optimize());
+ ret += "\') ";
+ } else if (tfn.has_quick_check()) {
+ ret += "pragma_quick_check(\'";
+ ret += std::to_string(tfn.quick_check());
+ ret += "\') ";
+ } else if (tfn.has_table_info()) {
+ ret += "pragma_table_info(\'";
+ ret += TableToString(tfn.table_info());
+ ret += "\') ";
+ } else if (tfn.has_table_xinfo()) {
+ ret += "pragma_table_xinfo(\'";
+ ret += TableToString(tfn.table_xinfo());
+ ret += "\') ";
+ } else {
+ ret += StrToLower(PragmaFnZeroArgOneResult_Name(tfn.no_arg_one_result()))
+ .erase(0, std::string("PFN_ZO_").length());
+ ret += "() ";
+ }
+ return ret;
+}
+
+CONV_FN(TableOrSubqueryOption2, toso2) {
+ std::string ret;
+ ret += ExprSchemaTableFnToString(toso2.schema_table_fn());
+ ret += " ";
+ if (toso2.has_as_table_alias()) {
+ ret += AsTableAliasToString(toso2.as_table_alias());
+ }
+ return ret;
+}
+
+CONV_FN(TableOrSubqueryOption3, tos3) {
+ std::string ret;
+ if (tos3.tos_list_size() > 0) {
+ ret += TableOrSubqueryToString(tos3.tos_list(0));
+ for (int i = 1; i < tos3.tos_list_size(); i++) {
+ ret += ", ";
+ ret += TableOrSubqueryToString(tos3.tos_list(i));
+ }
+ } else {
+ ret += JoinClauseToString(tos3.join_clause());
+ }
+ return ret;
+}
+
+CONV_FN(TableOrSubqueryOption4, tos4) {
+ std::string ret("(");
+ ret += SelectToString(tos4.select());
+ ret += ") ";
+ if (tos4.has_as_table_alias()) {
+ ret += AsTableAliasToString(tos4.as_table_alias());
+ ret += " ";
+ }
+ return ret;
+}
+
+CONV_FN(TableOrSubquery, tos) {
+ // oneof
+ if (tos.has_qtn()) {
+ return QualifiedTableNameToString(tos.qtn()) + " ";
+ } else if (tos.has_toso2()) {
+ return TableOrSubqueryOption2ToString(tos.toso2()) + " ";
+ } else if (tos.has_toso3()) {
+ return "(" + TableOrSubqueryOption3ToString(tos.toso3()) + ") ";
+ } else if (tos.has_toso4()) {
+ return TableOrSubqueryOption4ToString(tos.toso4()) + " ";
+ } else {
+ return ExprSchemaTableToString(tos.schema_table_expr()) + " ";
+ }
+}
+
+CONV_FN(FromStatement, fs) {
+ return "FROM " + TableOrSubqueryOption3ToString(fs.tos3());
+}
+
+CONV_FN(GroupByStatement, gbs) {
+ std::string ret("GROUP BY ");
+ ret += ExprListToString(gbs.exprs());
+ ret += " ";
+ if (gbs.has_having_expr()) {
+ ret += "HAVING ";
+ ret += ExprToString(gbs.having_expr());
+ ret += " ";
+ }
+ return ret;
+}
+
+CONV_FN(WindowStatement, ws) {
+#if !defined(SQLITE_OMIT_WINDOWFUNC)
+ return "";
+#else
+ return "";
+#endif
+}
+
+CONV_FN(SelectStatementCore, ssc) {
+ std::string ret;
+ ret += EnumStrReplaceUnderscores(
+ SelectStatementCore_SelectOrDistinct_Name(ssc.s_or_d()));
+ ret += " ";
+ if (ssc.result_columns_size() == 0) {
+ ret += "* ";
+ } else {
+ ret += ResultColumnToString(ssc.result_columns(0));
+ for (int i = 1; i < ssc.result_columns_size(); i++) {
+ ret += ", ";
+ ret += ResultColumnToString(ssc.result_columns(i));
+ }
+ ret += " ";
+ }
+ if (ssc.has_from()) {
+ ret += FromStatementToString(ssc.from());
+ ret += " ";
+ }
+ if (ssc.has_where()) {
+ ret += WhereStatementToString(ssc.where());
+ ret += " ";
+ }
+ if (ssc.has_groupby()) {
+ ret += GroupByStatementToString(ssc.groupby());
+ ret += " ";
+ }
+ if (ssc.has_window()) {
+ ret += WindowStatementToString(ssc.window());
+ ret += " ";
+ }
+ return ret;
+}
+
+CONV_FN(SelectSubStatement, sss) {
+ // oneof
+ if (sss.has_select_core()) {
+ return SelectStatementCoreToString(sss.select_core());
+ } else if (sss.has_values()) {
+ return ValuesStatementToString(sss.values());
+ } else {
+ return ValuesStatementToString(sss.values_fallback());
+ }
+}
+
+CONV_FN(ExprOrderingTerm, eot) {
+ std::string ret = ExprToString(eot.expr());
+ ret += " ";
+ if (eot.has_collate_type()) {
+ ret += "COLLATE ";
+ ret += CollateTypeToString(eot.collate_type());
+ ret += " ";
+ }
+ ret += AscDescToString(eot.asc_desc());
+ return ret;
+}
+
+CONV_FN(OrderByStatement, obs) {
+ std::string ret("ORDER BY ");
+ ret += ExprOrderingTermToString(obs.ord_term());
+ for (int i = 0; i < obs.extra_ord_terms_size(); i++) {
+ ret += ", ";
+ ret += ExprOrderingTermToString(obs.extra_ord_terms(i));
+ }
+ ret += " ";
+ return ret;
+}
+
+CONV_FN(LimitStatement, ls) {
+ std::string ret("LIMIT ");
+ ret += ExprToString(ls.limit_expr());
+ ret += " ";
+ if (ls.has_second_expr()) {
+ if (ls.offset()) {
+ ret += "OFFSET ";
+ } else {
+ ret += ", ";
+ }
+ ret += ExprToString(ls.second_expr());
+ ret += " ";
+ }
+ return ret;
+}
+
+CONV_FN(ExtraSelectSubStatement, esss) {
+ std::string ret, enum1;
+ enum1 = CompoundOperator_Name(esss.compound_op());
+ // erase prefix
+ enum1.erase(0, std::string("CO_").length());
+ ret += EnumStrReplaceUnderscores(enum1);
+ ret += " ";
+ ret += SelectSubStatementToString(esss.select_substatement());
+ return ret;
+}
+
+CONV_FN(Select, select) {
+ RETURN_IF_DISABLED_QUERY(Select);
+ std::string ret;
+ if (select.has_with()) {
+ ret += WithStatementToString(select.with());
+ ret += " ";
+ }
+ ret += SelectStatementCoreToString(select.select_core());
+ for (int i = 0; i < select.extra_select_substatements_size(); i++) {
+ ret +=
+ ExtraSelectSubStatementToString(select.extra_select_substatements(i));
+ ret += " ";
+ }
+ if (select.has_orderby()) {
+ ret += OrderByStatementToString(select.orderby());
+ ret += " ";
+ }
+ if (select.has_limit()) {
+ ret += LimitStatementToString(select.limit());
+ }
+ return ret;
+}
+
+// ~~~~FTS3~~~~
+
+// CORPUS currently relying on normal SELECTs to generate good compound
+// queries for FTS, like AND, OR, and NOT. Generate a corpus entry with a lot of
+// creative FTS queries.
+
+CONV_FN(FTS3Table, ft) {
+ // std::string ret("FTS3Table");
+ std::string ret(
+ "Table"); // for now, use the same naming scheme as normal tables.
+ ret += std::to_string(ft.table() % kMaxFTS3TableNumber);
+ return ret;
+}
+
+CONV_FN(FTS3MatchToken, fmt) {
+ std::string ret;
+ if (fmt.has_col()) {
+ ret += ColumnToString(fmt.col());
+ ret += ":";
+ }
+ if (fmt.negate()) {
+ ret += "-";
+ }
+ if (fmt.token().length() == 0)
+ ret += "a";
+ else
+ ret += ConvertToSqlString(
+ fmt.token()); // TODO(mpdenton) good enough? Need something better????
+ if (fmt.prefix())
+ ret += "*";
+ return ret;
+}
+
+CONV_FN(FTS3PhraseQuery, fpq) {
+ std::string ret("\"");
+ ret += FTS3MatchTokenToString(fpq.mt());
+ for (int i = 0; i < fpq.extra_mts_size(); i++) {
+ ret += " ";
+ ret += FTS3MatchTokenToString(fpq.extra_mts(i));
+ }
+ ret += "\"";
+ return ret;
+}
+
+CONV_FN(FTS3MatchFormatCore, fmfc) {
+ // oneof
+ if (fmfc.has_pq()) {
+ return FTS3PhraseQueryToString(fmfc.pq());
+ } else if (fmfc.has_nq()) {
+ return FTS3NearQueryToString(fmfc.nq());
+ } else {
+ return FTS3MatchTokenToString(fmfc.mt_fallback());
+ }
+}
+
+CONV_FN(FTS3NearQuery, fnq) {
+ std::string ret = FTS3MatchFormatCoreToString(fnq.format_core1());
+ ret += " NEAR";
+ if (fnq.has_num_tokens_near()) {
+ ret += "/";
+ ret += std::to_string(fnq.num_tokens_near());
+ }
+ ret += " ";
+ ret += FTS3MatchFormatCoreToString(fnq.format_core2());
+ return ret;
+}
+
+CONV_FN(FTS3CompoundAndCore, fcac) {
+ std::string ret(" ");
+ ret += FTS3CompoundAndCore_CompoundOp_Name(fcac.op());
+ ret += " ";
+ ret += FTS3MatchFormatCoreToString(fcac.core());
+ return ret;
+}
+
+CONV_FN(FTS3MatchCompoundFormat, fmcf) {
+ std::string ret = FTS3MatchFormatCoreToString(fmcf.core());
+ for (int i = 0; i < fmcf.compound_and_cores_size(); i++) {
+ ret += FTS3CompoundAndCoreToString(fmcf.compound_and_cores(i));
+ }
+ return ret;
+}
+
+CONV_FN(FTS3MatchFormat, fmf) {
+ std::string ret("\'");
+ if (fmf.ft_size() > 0) {
+ ret += FTS3MatchCompoundFormatToString(fmf.ft(0));
+ }
+ for (int i = 1; i < fmf.ft_size(); i++) {
+ ret += " ";
+ ret += FTS3MatchCompoundFormatToString(fmf.ft(i));
+ }
+ ret += "\'";
+ return ret;
+}
+
+CONV_FN(FTS3SpecialCommand, fsc) {
+ RETURN_IF_DISABLED_QUERY(FTS3SpecialCommand);
+ std::string ret("INSERT INTO ");
+ ret += FTS3TableToString(fsc.table());
+ ret += "(";
+ ret += FTS3TableToString(fsc.table());
+ ret += ") VALUES(\'";
+ switch (fsc.command()) {
+ case FTS3SpecialCommand::OPTIMIZE:
+ ret += "optimize";
+ break;
+ case FTS3SpecialCommand::REBUILD:
+ ret += "rebuild";
+ break;
+ case FTS3SpecialCommand::INTEGRITY_CHECK:
+ ret += "integrity-check";
+ break;
+ case FTS3SpecialCommand::MERGE:
+ ret += "merge=";
+ ret += std::to_string(fsc.val1());
+ ret += ",";
+ ret += std::to_string(fsc.val2());
+ break;
+ case FTS3SpecialCommand::AUTOMERGE:
+ ret += "automerge=";
+ ret += std::to_string(fsc.val1() % 16);
+ break;
+ }
+ ret += "\')";
+ return ret;
+}
+
+// WARNING no space at end
+CONV_FN(FTS3SelectMatch, fsm) {
+ RETURN_IF_DISABLED_QUERY(FTS3SelectMatch);
+ std::string ret("SELECT * FROM ");
+ ret += FTS3TableToString(fsm.table());
+ ret += " WHERE ";
+ ret += ColumnToString(fsm.col());
+ ret += " MATCH ";
+ ret += FTS3MatchFormatToString(fsm.match_pattern());
+ return ret;
+}
+
+CONV_FN(FTS3SpecificQuery, fsq) {
+ RETURN_IF_DISABLED_QUERY(FTS3SpecificQuery);
+#if defined(FUZZ_FTS3)
+ // oneof
+ if (fsq.has_command()) {
+ return FTS3SpecialCommandToString(fsq.command());
+ } else if (fsq.has_select()) {
+ return FTS3SelectMatchToString(fsq.select());
+ } else {
+ return "";
+ }
+
+#else
+ return "";
+#endif
+}
+
+CONV_FN(ICULocale, il) {
+ std::string ret;
+ std::string lc = IsoLangCode_Name(il.iso_lang_code());
+ lc.erase(0, std::string("ISO_LANG_CODE_").length());
+ ret += lc;
+ ret += "_";
+ // extract country code from integer
+ ret += (char)((il.country_code() & 0xFF) % 26) + 'A';
+ ret += (char)(((il.country_code() & 0xFF00) >> 8) % 26) + 'A';
+ return ret;
+}
+
+CONV_FN(CreateFTS3Table, cft) {
+ RETURN_IF_DISABLED_QUERY(CreateFTS3Table);
+ std::string ret("CREATE VIRTUAL TABLE ");
+ if (cft.if_not_exists())
+ ret += "IF NOT EXISTS ";
+ if (cft.has_schema()) {
+ ret += SchemaToString(cft.schema());
+ ret += ".";
+ }
+ ret += FTS3TableToString(cft.table());
+ ret += " USING fts3(";
+ // TODO(mpdenton) not using schema here, should I???
+ if (cft.has_col_list()) {
+ ret += ColumnListToString(cft.col_list());
+ if (cft.has_tokenizer_type())
+ ret += ", ";
+ }
+ if (cft.has_tokenizer_type()) {
+ ret += "tokenize=";
+ std::string tt = TokenizerType_Name(cft.tokenizer_type());
+ tt.erase(0, std::string("TT_").length());
+ tt = StrToLower(tt);
+#if defined(SQLITE_DISABLE_FTS3_UNICODE)
+ if (tt == "unicode61")
+ tt = "porter";
+#endif
+ ret += tt;
+ // now generate locales for ICU
+ if (cft.tokenizer_type() == TokenizerType::TT_ICU) {
+ ret += " ";
+ ret += ICULocaleToString(cft.locale());
+ } else if (cft.tokenizer_type() == TokenizerType::TT_UNICODE61) {
+ // Chrome does not actually enable this option. FIXME in the future.
+ }
+ }
+ ret += ")";
+ return ret;
+}
+
+// WARNING no space at end
+CONV_FN(FTS3OffsetsFn, fof) {
+ return "offsets(" + FTS3TableToString(fof.table()) + ")";
+}
+
+// WARNING no space at end
+CONV_FN(FTS3SnippetsFn, fsf) {
+ std::string ret("snippets(");
+ ret += FTS3TableToString(fsf.table());
+ // Now (possibly) emit the five optional arguments.
+ int num_args = (int)fsf.num_optional_args();
+ if (num_args >= 1) {
+ ret += ", \'";
+ ret += ConvertToSqlString(fsf.start_match());
+ ret += "\'";
+ }
+ if (num_args >= 2) {
+ ret += ", \'";
+ ret += ConvertToSqlString(fsf.end_match());
+ ret += "\'";
+ }
+ if (num_args >= 3) {
+ ret += ", \'";
+ ret += ConvertToSqlString(fsf.ellipses());
+ ret += "\'";
+ }
+ if (num_args >= 4) {
+ ret += ", ";
+ if (fsf.has_col_number()) {
+ ret += std::to_string(fsf.col_number() % kMaxColumnNumber);
+ } else {
+ ret += "-1";
+ }
+ }
+ if (num_args >= 5) {
+ ret += ", ";
+ ret +=
+ std::to_string((fsf.num_tokens() % 129) - 64); // clamp into [-64, 64]
+ }
+ ret += ")";
+ return ret;
+}
+
+// WARNING no space at end
+CONV_FN(FTS3MatchInfoFn, fmi) {
+ constexpr static char matchinfo_chars[] = {
+ 'p', 'c', 's', 'x', 'y', 'b',
+ // 'n', 'a', 'l', // These characters only available for FTS4.
+ };
+ std::string ret("matchinfo(");
+ ret += FTS3TableToString(fmi.table());
+ if (fmi.chars_size() > 0) {
+ ret += ", \'";
+ for (int i = 0; i < fmi.chars_size(); i++) {
+ ret += matchinfo_chars[fmi.chars(i) % sizeof(matchinfo_chars)];
+ }
+ ret += "\'";
+ }
+ ret += ")";
+ return ret;
+}
+
+// WARNING no space at end
+CONV_FN(FTS3AuxiliaryFn, faf) {
+ if (faf.has_snippets()) {
+ return FTS3SnippetsFnToString(faf.snippets());
+ } else if (faf.has_matchinfo()) {
+ return FTS3MatchInfoFnToString(faf.matchinfo());
+ } else {
+ return FTS3OffsetsFnToString(faf.offsets_fallback());
+ }
+}
+
+CONV_FN(FTS3HiddenTable, fht) {
+ std::string tab = FTS3HiddenTable_HiddenTableVal_Name(fht.htv());
+ tab = StrToLower(tab);
+ return FTS3TableToString(fht.table()) + "_" + tab;
+}
+
+CONV_FN(FTS3HiddenTableColumn, fhtc) {
+ std::string tab = FTS3HiddenTableColumn_Name(fhtc);
+ tab = tab.erase(0, std::string("FTS3_HT_").length());
+ tab = StrToLower(tab);
+ return tab;
+}
+
+CONV_FN(FTS3HiddenTableInsert, fi) {
+ RETURN_IF_DISABLED_QUERY(FTS3HiddenTableInsert);
+ std::string ret("INSERT INTO ");
+ ret += FTS3HiddenTableToString(fi.fht());
+ if (fi.col_vals_size() == 0) {
+ ret += " DEFAULT VALUES";
+ return ret;
+ }
+ ret += "(";
+ ret += FTS3HiddenTableColumnToString(fi.col_vals(0).col());
+ for (int i = 1; i < fi.col_vals_size(); i++) {
+ ret += ", ";
+ ret += FTS3HiddenTableColumnToString(fi.col_vals(i).col());
+ }
+ ret += ") VALUES(";
+ ret += ExprToString(fi.col_vals(0).expr());
+ for (int i = 0; i < fi.col_vals_size(); i++) {
+ ret += ", ";
+ ret += ExprToString(fi.col_vals(i).expr());
+ }
+ ret += ")";
+ return ret;
+}
+
+CONV_FN(FTS3HiddenTableUpdate, fu) {
+ RETURN_IF_DISABLED_QUERY(FTS3HiddenTableUpdate);
+ std::string ret("UPDATE ");
+ ret += FTS3HiddenTableToString(fu.fht());
+ ret += " ";
+ if (fu.col_vals_size() == 0) {
+ ret += "start_block = 0";
+ return ret;
+ }
+ ret += "SET ";
+ ret += FTS3HiddenTableColumnToString(fu.col_vals(0).col());
+ ret += " = ";
+ ret += ExprToString(fu.col_vals(0).expr());
+ for (int i = 1; i < fu.col_vals_size(); i++) {
+ ret += ", ";
+ ret += FTS3HiddenTableColumnToString(fu.col_vals(i).col());
+ ret += " = ";
+ ret += ExprToString(fu.col_vals(i).expr());
+ }
+ if (fu.has_col_where()) {
+ ret += " WHERE ";
+ ret += FTS3HiddenTableColumnToString(fu.col_where());
+ ret += BinaryOperatorToString(fu.bin_op());
+ ret += ExprToString(fu.comp_expr());
+ }
+ return ret;
+}
+
+CONV_FN(FTS3HiddenTableDelete, fd) {
+ RETURN_IF_DISABLED_QUERY(FTS3HiddenTableDelete);
+ std::string ret("DELETE FROM ");
+ ret += FTS3HiddenTableToString(fd.fht());
+ if (fd.has_col_where()) {
+ ret += " WHERE ";
+ ret += FTS3HiddenTableColumnToString(fd.col_where());
+ ret += BinaryOperatorToString(fd.bin_op());
+ ret += ExprToString(fd.comp_expr());
+ }
+ return ret;
+}
+
+// ~~~~TRANSACTIONS/SAVEPOINTS
+CONV_FN(BeginTransaction, bt) {
+ RETURN_IF_DISABLED_QUERY(BeginTransaction);
+ std::string ret("BEGIN ");
+ if (bt.has_type()) {
+ ret += BeginTransaction_TransactionType_Name(bt.type());
+ ret += " ";
+ }
+ ret += "TRANSACTION";
+ return ret;
+}
+
+CONV_FN(CommitTransaction, ct) {
+ RETURN_IF_DISABLED_QUERY(CommitTransaction);
+ return EnumStrReplaceUnderscores(
+ CommitTransaction_CommitText_Name(ct.text()));
+}
+
+CONV_FN(RollbackStatement, rt) {
+ RETURN_IF_DISABLED_QUERY(RollbackStatement);
+#if !defined(FUZZ_OMIT_SAVEPOINT)
+ if (rt.has_save_point()) {
+ return "ROLLBACK TO SAVEPOINT " + SavePointToString(rt.save_point());
+ }
+#endif
+ return "ROLLBACK TRANSACTION";
+}
+
+#if !defined(FUZZ_OMIT_SAVEPOINT)
+CONV_FN(CreateSavePoint, csp) {
+ RETURN_IF_DISABLED_QUERY(CreateSavePoint);
+ return "SAVEPOINT " + SavePointToString(csp.save_point());
+}
+
+CONV_FN(ReleaseSavePoint, rsp) {
+ RETURN_IF_DISABLED_QUERY(ReleaseSavePoint);
+ return "RELEASE SAVEPOINT " + SavePointToString(rsp.save_point());
+}
+#endif
+
+CONV_FN(Analyze, a) {
+ RETURN_IF_DISABLED_QUERY(Analyze);
+ std::string ret("ANALYZE");
+ if (a.has_schema_name()) {
+ ret += " ";
+ ret += SchemaToString(a.schema_name());
+ if (a.has_table_name()) {
+ ret += ".";
+ ret += TableToString(a.table_name());
+ } else if (a.has_index_name()) {
+ ret += ".";
+ ret += IndexToString(a.index_name());
+ }
+ } else if (a.has_table_name()) {
+ ret += " ";
+ ret += TableToString(a.table_name());
+ } else if (a.has_index_name()) {
+ ret += " ";
+ ret += IndexToString(a.index_name());
+ }
+
+ return ret;
+}
+
+// ~~~~VACUUM~~~~
+CONV_FN(Vacuum, v) {
+ RETURN_IF_DISABLED_QUERY(Vacuum);
+ std::string ret("VACUUM");
+ if (v.has_schema()) {
+ ret += " ";
+ ret += SchemaToString(v.schema());
+ }
+ return ret;
+}
+
+// ~~~~PRAGMA~~~~
+CONV_FN(Pragma, p) {
+ RETURN_IF_DISABLED_QUERY(Pragma);
+#if defined(FUZZ_OMIT_PRAGMA)
+ return "";
+#else
+ constexpr static const char* locking_modes[] = {"NORMAL", "EXCLUSIVE"};
+ constexpr static const char* journal_modes[] = {
+ "DELETE", "TRUNCATE", "PERSIST", "MEMORY", "WAL", "OFF"};
+
+ Table table;
+ std::string ret("PRAGMA ");
+ if (p.has_schema()) {
+ ret += SchemaToString(p.schema());
+ ret += ".";
+ }
+ ret += StripTrailingUnderscores(
+ StrToLower(Pragma_PragmaCommand_Name(p.command())));
+ switch (p.command()) {
+ case Pragma::AUTO_VACUUM:
+ ret += " = ";
+ ret += std::to_string((uint32_t)p.arg1() % 3);
+ break;
+ case Pragma::WRITEABLE_SCHEMA:
+ ret += " = ";
+ ret += std::to_string((uint32_t)p.arg1() % 2);
+ break;
+ case Pragma::LOCKING_MODE:
+ ret += " = ";
+ ret += locking_modes[(uint32_t)p.arg1() % 2];
+ break;
+ case Pragma::TEMP_STORE:
+ ret += " = ";
+ ret += std::to_string((uint32_t)p.arg1() % 3);
+ break;
+ case Pragma::PAGE_SIZE_:
+ ret += " = ";
+ ret += std::to_string(p.arg1());
+ break;
+ case Pragma::TABLE_INFO:
+ ret += "(\'";
+ table.set_table((uint32_t)p.arg1());
+ ret += TableToString(table);
+ ret += "\')";
+ break;
+ case Pragma::JOURNAL_MODE:
+ ret += " = ";
+ ret += journal_modes[(uint32_t)p.arg1() % 6];
+ break;
+ case Pragma::MMAP_SIZE:
+ ret += " = ";
+ ret += std::to_string(p.arg1());
+ break;
+ }
+ return ret;
+#endif
+}
+
+// ~~~~CREATE INDEX~~~~
+CONV_FN(CreateIndex, ci) {
+ RETURN_IF_DISABLED_QUERY(CreateIndex);
+ std::string ret("CREATE ");
+ if (ci.unique())
+ ret += "UNIQUE ";
+ ret += "INDEX ";
+ if (ci.if_not_exists())
+ ret += "IF NOT EXISTS ";
+ if (ci.has_schema()) {
+ ret += SchemaToString(ci.schema());
+ ret += ".";
+ }
+ ret += IndexToString(ci.index());
+ ret += " ON ";
+ ret += TableToString(ci.table());
+ ret += "(";
+ ret += IndexedColumnListToString(ci.icol_list());
+ ret += ")";
+ if (ci.has_where()) {
+ ret += " ";
+ ret += WhereStatementToString(ci.where());
+ }
+ return ret;
+}
+
+// ~~~~CREATE VIEW~~~~
+CONV_FN(CreateView, cv) {
+ RETURN_IF_DISABLED_QUERY(CreateView);
+ std::string ret("CREATE ");
+ if (cv.has_temp_modifier()) {
+ ret += EnumStrReplaceUnderscores(TempModifier_Name(cv.temp_modifier()))
+ .erase(0, std::string("TM_").length());
+ ret += " ";
+ }
+ ret += "VIEW ";
+ if (cv.if_not_exists())
+ ret += "IF NOT EXISTS ";
+
+ if (cv.has_schema()) {
+ ret += SchemaToString(cv.schema());
+ ret += ".";
+ }
+ ret += ViewToString(cv.view());
+ ret += " ";
+ if (cv.has_col_list()) {
+ ret += "(";
+ ret += ColumnListToString(cv.col_list());
+ ret += ") ";
+ }
+ ret += SelectToString(cv.select());
+ return ret;
+}
+
+// ~~~~CREATE TRIGGER~~~~
+
+CONV_FN(TypicalQuery, tq) {
+ // oneof
+ if (tq.has_update())
+ return UpdateToString(tq.update());
+ else if (tq.has_insert())
+ return InsertToString(tq.insert());
+ else if (tq.has_select())
+ return SelectToString(tq.select());
+ else
+ return DeleteToString(tq.delete_fallback());
+}
+
+// WARNING no space at end
+CONV_FN(CreateTrigger, ct) {
+ RETURN_IF_DISABLED_QUERY(CreateTrigger);
+ std::string ret("CREATE ");
+ if (ct.has_temp_modifier()) {
+ ret += EnumStrReplaceUnderscores(TempModifier_Name(ct.temp_modifier()))
+ .erase(0, std::string("TM_").length());
+ ret += " ";
+ }
+ ret += "TRIGGER ";
+ if (ct.if_not_exists())
+ ret += "IF NOT EXISTS ";
+
+ if (ct.has_schema()) {
+ ret += SchemaToString(ct.schema());
+ ret += " ";
+ }
+
+ ret += TriggerToString(ct.trigger());
+ ret += " ";
+ if (ct.has_trigger_type()) {
+ ret += EnumStrReplaceUnderscores(
+ CreateTrigger_TriggerType_Name(ct.trigger_type()));
+ ret += " ";
+ }
+ ret += CreateTrigger_TriggerInstr_Name(ct.trigger_instr());
+ ret += " ";
+ if (ct.trigger_instr() == CreateTrigger::UPDATE) {
+ ret += "OF ";
+ ret += ColumnListToString(ct.col_list());
+ ret += " ";
+ }
+ ret += "ON ";
+ ret += TableToString(ct.table());
+ ret += " ";
+ if (ct.for_each_row())
+ ret += "FOR EACH ROW ";
+
+ if (ct.has_when()) {
+ ret += "WHEN ";
+ ret += ExprComparisonHighProbabilityToString(ct.when());
+ ret += " ";
+ }
+
+ ret += "BEGIN ";
+ ret += TypicalQueryToString(ct.tq());
+ ret += "; ";
+ for (int i = 0; i < ct.extra_tqs_size(); i++) {
+ ret += TypicalQueryToString(ct.extra_tqs(i));
+ ret += "; ";
+ }
+ ret += "END";
+ return ret;
+}
+
+// ~~~~REINDEX~~~~
+CONV_FN(ReIndex, ri) {
+ RETURN_IF_DISABLED_QUERY(ReIndex);
+// Chrome doesn't use REINDEX
+#if !defined(SQLITE_OMIT_REINDEX)
+ if (ri.empty())
+ return "REINDEX";
+ std::string ret("REINDEX ");
+ if (ri.has_collate_type()) {
+ ret += CollateTypeToString(ri.collate_type());
+ return ret;
+ }
+ if (ri.has_schema()) {
+ ret += SchemaToString(ri.schema());
+ ret += ".";
+ }
+ if (ri.has_table())
+ ret += TableToString(ri.table());
+ else
+ ret += IndexToString(ri.index());
+
+ return ret;
+#else
+ return "";
+#endif
+}
+
+CONV_FN(Drop, d) {
+ RETURN_IF_DISABLED_QUERY(Drop);
+ std::string ret("DROP ");
+ std::string if_exists("");
+ std::string schema("");
+ if (d.if_exists())
+ if_exists = "IF EXISTS ";
+ if (d.has_schema()) {
+ schema = SchemaToString(d.schema());
+ schema += " ";
+ }
+ // oneof
+ if (d.has_index()) {
+ ret += "INDEX ";
+ ret += if_exists;
+ ret += schema;
+ ret += IndexToString(d.index());
+ } else if (d.has_table()) {
+ ret += "TABLE ";
+ ret += if_exists;
+ ret += schema;
+ ret += TableToString(d.table());
+ } else if (d.has_trigger()) {
+ ret += "TRIGGER ";
+ ret += if_exists;
+ ret += schema;
+ ret += TriggerToString(d.trigger());
+ } else {
+ ret += "VIEW ";
+ ret += if_exists;
+ ret += schema;
+ ret += ViewToString(d.view_fallback());
+ }
+ return ret;
+}
+
+// ~~~~ALTER TABLE~~~~
+CONV_FN(AlterTable, at) {
+ RETURN_IF_DISABLED_QUERY(AlterTable);
+ std::string ret("ALTER TABLE ");
+ ret += ExprSchemaTableToString(at.schema_table());
+ ret += " ";
+ if (at.has_col()) {
+ ret += "RENAME ";
+ if (at.column())
+ ret += "COLUMN ";
+ ret += ColumnToString(at.col());
+ ret += " TO ";
+ ret += ColumnToString(at.col_to());
+ } else if (at.has_col_def()) {
+ ret += "ADD ";
+ if (at.column())
+ ret += "COLUMN ";
+ ret += ColumnDefToString(at.col_def());
+ } else {
+ ret += "RENAME TO ";
+ ret += TableToString(at.table_fallback());
+ }
+ return ret;
+}
+
+// ~~~~ATTACH DATABASE~~~~
+CONV_FN(AttachDatabase, ad) {
+ RETURN_IF_DISABLED_QUERY(AttachDatabase);
+ std::string ret("ATTACH DATABASE \'");
+ if (ad.in_memory()) {
+ if (ad.file_uri()) {
+ ret += "file:";
+ std::string add;
+ if (ad.has_db_name()) {
+ ret += SchemaToString(ad.db_name());
+ ret += "?mode=memory";
+ add = "&";
+ } else {
+ ret += ":memory:";
+ add = "?";
+ }
+
+ if (ad.shared_cache()) {
+ ret += add;
+ ret += "cache=shared";
+ }
+ }
+ }
+ ret += "\' AS ";
+ ret += SchemaToString(ad.schema());
+ return ret;
+}
+
+// ~~~~DETACH DATABASE~~~~
+CONV_FN(DetachDatabase, dd) {
+ RETURN_IF_DISABLED_QUERY(DetachDatabase);
+ std::string ret("DETACH DATABASE ");
+ ret += SchemaToString(dd.schema());
+ return ret;
+}
+
+// ~~~~Time and date fns~~~~
+CONV_FN(HoursStuff, hs) {
+ std::string ret;
+ if (hs.has_hh()) {
+ ret += std::to_string(hs.hh() % 100);
+ if (hs.has_mm()) {
+ ret += ":";
+ ret += std::to_string(hs.mm() % 100);
+ if (hs.has_ss()) {
+ ret += ":";
+ ret += std::to_string(hs.ss() % 100);
+ if (hs.has_sss()) {
+ ret += ".";
+ ret += std::to_string(hs.sss() % 1000);
+ }
+ }
+ }
+ }
+ return ret;
+}
+
+CONV_FN(TimeString, ts) {
+ std::string ret;
+ if (ts.has_yyyy()) {
+ // FIXME in the future add zeroes for integers < 1000.
+ ret += std::to_string(ts.yyyy() % 10000);
+ ret += "-";
+ ret += std::to_string(ts.mm() % 100);
+ ret += "-";
+ ret += std::to_string(ts.dd() % 100);
+ if (ts.extra_t())
+ ret += "T";
+ if (ts.has_hs())
+ ret += HoursStuffToString(ts.hs());
+ } else if (ts.has_hs()) {
+ ret += HoursStuffToString(ts.hs());
+ } else if (ts.has_dddddddddd()) {
+ ret += std::to_string(ts.dddddddddd() % 10000000000);
+ } else if (ts.now()) {
+ ret += "now";
+ } else {
+ ret += ConvertToSqlString(ts.random_bytes());
+ }
+
+ if (ts.has_tz_plus()) {
+ if (ts.z()) {
+ ret += "Z";
+ } else {
+ if (ts.plus())
+ ret += "+";
+ else
+ ret += "-";
+ ret += std::to_string(ts.tz_hh() % 100);
+ ret += std::to_string(ts.tz_mm() % 100);
+ }
+ }
+ return ret;
+}
+
+CONV_FN(TimeModifier, tm) {
+ std::string ret;
+ if (tm.has_nm()) {
+ ret += std::to_string(tm.num());
+ ret += " ";
+ if (tm.has_dot_num()) {
+ ret += ".";
+ ret += std::to_string(tm.dot_num());
+ }
+ ret += StrToLower(TimeModifier_NumberedModifiers_Name(tm.nm()));
+ } else {
+ ret += StrToLower(
+ EnumStrReplaceUnderscores(TimeModifier_OtherModifiers_Name(tm.om())));
+ }
+ if (tm.om() == TimeModifier::WEEKDAY) {
+ ret += " ";
+ ret += std::to_string(tm.num());
+ }
+ return ret;
+}
+
+CONV_FN(SimpleDateAndTimeFn, sfn) {
+ std::string ret;
+ ret += StrToLower(SimpleDateAndTimeFn_FnName_Name(sfn.fn_name()));
+ ret += "(\'";
+ ret += TimeStringToString(sfn.time_string());
+ ret += "\'";
+ for (int i = 0; i < sfn.modifiers_size(); i++) {
+ ret += ", \'";
+ ret += TimeModifierToString(sfn.modifiers(i));
+ ret += "\'";
+ }
+ ret += ") ";
+ return ret;
+}
+
+CONV_FN(StrftimeFormat, sf) {
+ std::string ret;
+ if (sf.has_subs()) {
+ std::string subs = StrftimeFormat_Substitution_Name(sf.subs());
+ if (sf.lowercase())
+ subs = StrToLower(subs);
+ ret += "%" + subs;
+ } else {
+ ret += "%%";
+ }
+
+ ret += ConvertToSqlString(sf.bytes());
+ return ret;
+}
+
+CONV_FN(StrftimeFn, sfn) {
+ std::string ret("strftime(\'");
+ for (int i = 0; i < sfn.fmts_size(); i++) {
+ ret += StrftimeFormatToString(sfn.fmts(i));
+ }
+ ret += "\', \'";
+ ret += TimeStringToString(sfn.time_string());
+ ret += "\'";
+ for (int i = 0; i < sfn.modifiers_size(); i++) {
+ ret += ", \'";
+ ret += TimeModifierToString(sfn.modifiers(i));
+ ret += "\'";
+ }
+ ret += ") ";
+ return ret;
+}
+
+CONV_FN(DateAndTimeFn, dat) {
+ if (dat.has_simple())
+ return SimpleDateAndTimeFnToString(dat.simple());
+ else
+ return StrftimeFnToString(dat.strftime());
+}
+
+// ~~~~QUERY~~~~
+CONV_FN(SQLQuery, query) {
+ using QueryType = SQLQuery::QueryOneofCase;
+ switch (query.query_oneof_case()) {
+ case QueryType::kSelect:
+ return SelectToString(query.select());
+ case QueryType::kCreateTable:
+ return CreateTableToString(query.create_table());
+ case QueryType::kInsert:
+ return InsertToString(query.insert());
+ case QueryType::kDelete:
+ return DeleteToString(query.delete_());
+ case QueryType::kFts3Table:
+ return CreateFTS3TableToString(query.fts3_table());
+ case QueryType::kFtsQuery:
+ return FTS3SpecificQueryToString(query.fts_query());
+ case QueryType::kBeginTxn:
+ return BeginTransactionToString(query.begin_txn());
+ case QueryType::kCommitTxn:
+ return CommitTransactionToString(query.commit_txn());
+ case QueryType::kRollbackStmt:
+ return RollbackStatementToString(query.rollback_stmt());
+#if !defined(FUZZ_OMIT_SAVEPOINT)
+ case QueryType::kCreateSavePoint:
+ return CreateSavePointToString(query.create_save_point());
+ case QueryType::kReleaseSavePoint:
+ return ReleaseSavePointToString(query.release_save_point());
+#endif
+ case QueryType::kAnalyze:
+ return AnalyzeToString(query.analyze());
+ case QueryType::kVacuum:
+ return VacuumToString(query.vacuum());
+ case QueryType::kPragma:
+ return PragmaToString(query.pragma());
+ case QueryType::kUpdate:
+ return UpdateToString(query.update());
+ case QueryType::kCreateIndex:
+ return CreateIndexToString(query.create_index());
+ case QueryType::kCreateView:
+ return CreateViewToString(query.create_view());
+ case QueryType::kCreateTrigger:
+ return CreateTriggerToString(query.create_trigger());
+ case QueryType::kReindex:
+ return ReIndexToString(query.reindex());
+ case QueryType::kDrop:
+ return DropToString(query.drop());
+ case QueryType::kAlterTable:
+ return AlterTableToString(query.alter_table());
+ case QueryType::kAttachDb:
+ return AttachDatabaseToString(query.attach_db());
+ case QueryType::kDetachDb:
+ return DetachDatabaseToString(query.detach_db());
+#if defined(FUZZ_FTS3)
+ case QueryType::kFts3Insert:
+ return FTS3HiddenTableInsertToString(query.fts3_insert());
+ case QueryType::kFts3Update:
+ return FTS3HiddenTableUpdateToString(query.fts3_update());
+ case QueryType::kFts3Delete:
+ return FTS3HiddenTableDeleteToString(query.fts3_delete());
+#endif
+ default:
+ return "";
+ }
+}
+
+std::vector<std::string> SQLQueriesToVec(const SQLQueries& sql_queries) {
+ std::vector<std::string> queries;
+ queries.reserve(sql_queries.extra_queries_size() + 1);
+ queries.push_back(CreateTableToString(sql_queries.create_table()) + ";");
+ for (int i = 0; i < sql_queries.extra_queries_size(); i++) {
+ std::string query = SQLQueryToString(sql_queries.extra_queries(i));
+ if (query == "")
+ continue;
+ query += ";";
+ queries.push_back(query);
+ }
+ return queries;
+}
+
+CONV_FN(SQLQueries, sql_queries) {
+ std::string queries;
+
+ for (std::string& query : SQLQueriesToVec(sql_queries)) {
+ queries += query;
+ queries += "\n";
+ }
+
+ return queries;
+}
+
+void SetDisabledQueries(std::set<std::string> disabled_queries) {
+ disabled_queries_ = disabled_queries;
+}
+
+} // namespace sql_fuzzer
diff --git a/chromium/third_party/sqlite/fuzz/sql_query_proto_to_string.h b/chromium/third_party/sqlite/fuzz/sql_query_proto_to_string.h
new file mode 100644
index 00000000000..b4b7fe9104f
--- /dev/null
+++ b/chromium/third_party/sqlite/fuzz/sql_query_proto_to_string.h
@@ -0,0 +1,30 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef THIRD_PARTY_SQLITE_FUZZ_SQL_QUERY_PROTO_TO_STRING_H_
+#define THIRD_PARTY_SQLITE_FUZZ_SQL_QUERY_PROTO_TO_STRING_H_
+
+#include <string>
+#include <vector>
+
+#include "third_party/sqlite/fuzz/sql_queries.pb.h"
+
+namespace sql_fuzzer {
+
+std::string SQLQueriesToString(
+ const sql_query_grammar::SQLQueries& sql_queries);
+std::vector<std::string> SQLQueriesToVec(
+ const sql_query_grammar::SQLQueries& sql_queries);
+
+std::string PrintfToString(const sql_query_grammar::Printf&);
+std::string StrftimeFnToString(const sql_query_grammar::StrftimeFn&);
+std::string ExprToString(const sql_query_grammar::Expr&);
+
+std::string SQLQueryToString(const sql_query_grammar::SQLQuery&);
+
+void SetDisabledQueries(std::set<std::string> disabled_queries);
+
+} // namespace sql_fuzzer
+
+#endif // THIRD_PARTY_SQLITE_FUZZ_SQL_QUERY_PROTO_TO_STRING_H_
diff --git a/chromium/third_party/sqlite/fuzz/sql_run_queries.cc b/chromium/third_party/sqlite/fuzz/sql_run_queries.cc
new file mode 100644
index 00000000000..010b67efcae
--- /dev/null
+++ b/chromium/third_party/sqlite/fuzz/sql_run_queries.cc
@@ -0,0 +1,172 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Adapted from sqlite's ossfuzz.c
+
+#include <cstdlib>
+#include <iostream> // TODO(mpdenton) remove
+#include <string>
+#include <vector>
+
+#include "third_party/sqlite/sqlite3.h"
+
+namespace sql_fuzzer {
+
+namespace {
+constexpr int kMaxNumRows = 10;
+constexpr int kMaxNumColumns = 10;
+
+sqlite3_int64 killTime;
+
+/* Return the current real-world time in milliseconds since the
+** Julian epoch (-4714-11-24).
+*/
+static sqlite3_int64 timeOfDay(void) {
+ static sqlite3_vfs* clockVfs = 0;
+ sqlite3_int64 t;
+ if (clockVfs == 0) {
+ clockVfs = sqlite3_vfs_find(0);
+ if (clockVfs == 0)
+ return 0;
+ }
+ if (clockVfs->iVersion >= 2 && clockVfs->xCurrentTimeInt64 != 0) {
+ clockVfs->xCurrentTimeInt64(clockVfs, &t);
+ } else {
+ double r;
+ clockVfs->xCurrentTime(clockVfs, &r);
+ t = (sqlite3_int64)(r * 86400000.0);
+ }
+ return t;
+}
+
+int progress_handler(void*) {
+ sqlite3_int64 iNow = timeOfDay();
+ int rc = iNow >= killTime;
+ return rc;
+}
+} // namespace
+
+void RunSqlQueriesOnSameDB() {
+ // TODO(mpdenton) unimplemented
+}
+
+sqlite3* InitConnectionForFuzzing() {
+ int rc; // Return code from various interfaces.
+ sqlite3* db; // Sqlite db.
+
+ rc = sqlite3_initialize();
+ if (rc) {
+ std::cerr << "Failed initialization. " << std::endl;
+ return nullptr;
+ }
+
+ // Open the database connection. Only use an in-memory database.
+ rc = sqlite3_open_v2(
+ "fuzz.db", &db,
+ SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_MEMORY, 0);
+ if (rc) {
+ std::cerr << "Failed to open DB. " << std::endl;
+ return nullptr;
+ }
+
+ // Enables foreign key constraints
+ sqlite3_db_config(db, SQLITE_DBCONFIG_ENABLE_FKEY, 1, &rc);
+
+ // sqlite3_db_config(db, SQLITE_DBCONFIG_DEFENSIVE, 0, &rc); // TODO(pwnall)
+
+ return db;
+}
+
+void EnableSqliteTracing(sqlite3* db) {
+ sqlite3_exec(db, "PRAGMA vdbe_debug=ON", 0, 0, 0);
+}
+
+void CloseConnection(sqlite3* db) {
+ // Cleanup and return.
+ sqlite3_exec(db, "PRAGMA temp_store_directory=''", 0, 0, 0);
+ sqlite3_close(db);
+}
+
+void RunSqlQueriesOnConnection(sqlite3* db, std::vector<std::string> queries) {
+ int rc;
+ for (size_t i = 0; i < queries.size(); i++) {
+ // Run each query one by one.
+ // First, compile the query.
+ sqlite3_stmt* stmt;
+ const char* pzTail;
+ rc = sqlite3_prepare_v2(db, queries[i].c_str(), -1, &stmt, &pzTail);
+ if (rc != SQLITE_OK) {
+ if (::getenv("PRINT_SQLITE_ERRORS")) {
+ std::cerr << "Could not compile: " << queries[i] << std::endl;
+ std::cerr << "Error message from db: " << sqlite3_errmsg(db)
+ << std::endl;
+ std::cerr << "-----------------------------" << std::endl;
+ }
+ continue;
+ }
+
+ // No sqlite3_bind.
+
+ // Reset progress callback for every query. Timeout after 1 second.
+ // ClusterFuzz timeouts are not useful, so we try to avoid them.
+ // This will hopefully make Clusterfuzz find better, smaller SELECT
+ // statements.
+#ifndef SQLITE_OMIT_PROGRESS_CALLBACK
+ killTime = timeOfDay() + 1000;
+ sqlite3_progress_handler(db, 100, progress_handler, nullptr);
+#endif
+
+ // Now run the compiled query.
+ int col_cnt = sqlite3_column_count(stmt);
+ int count = 0;
+ rc = SQLITE_ROW;
+ while (rc == SQLITE_ROW && count++ <= kMaxNumRows) {
+ rc = sqlite3_step(stmt);
+ if (rc != SQLITE_DONE && rc != SQLITE_ROW) {
+ if (::getenv("PRINT_SQLITE_ERRORS")) {
+ std::cerr << "Step problem: " << queries[i] << std::endl;
+ std::cerr << "Error message from db: " << sqlite3_errmsg(db)
+ << std::endl;
+ std::cerr << "-----------------------------" << std::endl;
+ }
+ goto free_stmt;
+ }
+ // Loop through the columns to catch a little bit more coverage.
+ for (int i = 0; i < col_cnt && i < kMaxNumColumns; i++) {
+ switch (sqlite3_column_type(stmt, i)) {
+ case SQLITE_INTEGER:
+ sqlite3_column_int(stmt, i);
+ break;
+ case SQLITE_FLOAT:
+ sqlite3_column_double(stmt, i);
+ break;
+ case SQLITE_TEXT:
+ sqlite3_column_text(stmt, i);
+ break;
+ case SQLITE_BLOB:
+ sqlite3_column_blob(stmt, i);
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+ // Finalize the query
+ free_stmt:
+ sqlite3_finalize(stmt);
+ }
+}
+
+void RunSqlQueries(std::vector<std::string> queries, bool enable_tracing) {
+ sqlite3* db = InitConnectionForFuzzing();
+ if (enable_tracing)
+ EnableSqliteTracing(db);
+
+ RunSqlQueriesOnConnection(db, queries);
+
+ CloseConnection(db);
+}
+
+} // namespace sql_fuzzer
diff --git a/chromium/third_party/sqlite/fuzz/sql_run_queries.h b/chromium/third_party/sqlite/fuzz/sql_run_queries.h
new file mode 100644
index 00000000000..95506d92713
--- /dev/null
+++ b/chromium/third_party/sqlite/fuzz/sql_run_queries.h
@@ -0,0 +1,18 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <string>
+#include <vector>
+
+#include "third_party/sqlite/sqlite3.h"
+
+namespace sql_fuzzer {
+/* Standalone function that wraps the three functions below. */
+void RunSqlQueries(std::vector<std::string> queries, bool enable_tracing);
+
+sqlite3* InitConnectionForFuzzing();
+void EnableSqliteTracing(sqlite3* db);
+void RunSqlQueriesOnConnection(sqlite3* db, std::vector<std::string> queries);
+void CloseConnection(sqlite3* db);
+} // namespace sql_fuzzer
diff --git a/chromium/third_party/sqlite/fuzz/sql_strftime_fuzzer.cc b/chromium/third_party/sqlite/fuzz/sql_strftime_fuzzer.cc
new file mode 100644
index 00000000000..7c4322ea912
--- /dev/null
+++ b/chromium/third_party/sqlite/fuzz/sql_strftime_fuzzer.cc
@@ -0,0 +1,31 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <cstdlib>
+#include <iostream>
+#include <string>
+#include <vector>
+
+#include "testing/libfuzzer/proto/lpm_interface.h"
+#include "third_party/sqlite/fuzz/sql_query_grammar.pb.h"
+#include "third_party/sqlite/fuzz/sql_query_proto_to_string.h"
+#include "third_party/sqlite/fuzz/sql_run_queries.h"
+
+using namespace sql_query_grammar;
+
+DEFINE_BINARY_PROTO_FUZZER(const StrftimeFn& sql_strftime) {
+ std::string strftime_str = sql_fuzzer::StrftimeFnToString(sql_strftime);
+ // Convert printf command into runnable SQL query.
+ strftime_str = "SELECT " + strftime_str + ";";
+
+ if (getenv("LPM_DUMP_NATIVE_INPUT")) {
+ std::cout << "_________________________" << std::endl;
+ std::cout << strftime_str << std::endl;
+ std::cout << "------------------------" << std::endl;
+ }
+
+ std::vector<std::string> queries;
+ queries.push_back(strftime_str);
+ sql_fuzzer::RunSqlQueries(queries, ::getenv("LPM_SQLITE_TRACE"));
+}
diff --git a/chromium/third_party/sqlite/patches/0001-Modify-default-VFS-to-support-WebDatabase.patch b/chromium/third_party/sqlite/patches/0001-Modify-default-VFS-to-support-WebDatabase.patch
index 6d8ff9f0399..1d86c19c32f 100644
--- a/chromium/third_party/sqlite/patches/0001-Modify-default-VFS-to-support-WebDatabase.patch
+++ b/chromium/third_party/sqlite/patches/0001-Modify-default-VFS-to-support-WebDatabase.patch
@@ -1,7 +1,7 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: dumi <dumi@chromium.org>
Date: Mon, 20 Jul 2009 23:40:51 +0000
-Subject: [PATCH 01/17] Modify default VFS to support WebDatabase.
+Subject: [PATCH 01/40] Modify default VFS to support WebDatabase.
The renderer WebDatabase implementation needs to broker certain requests
to the browser. This modifies SQLite to allow monkey-patching the VFS
diff --git a/chromium/third_party/sqlite/patches/0001-test-SQLite-tests-compiling-on-Linux.patch b/chromium/third_party/sqlite/patches/0001-test-SQLite-tests-compiling-on-Linux.patch
deleted file mode 100644
index 97cd2bd4fa2..00000000000
--- a/chromium/third_party/sqlite/patches/0001-test-SQLite-tests-compiling-on-Linux.patch
+++ /dev/null
@@ -1,120 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Scott Hess <shess@chromium.org>
-Date: Fri, 16 Jan 2015 10:24:30 -0800
-Subject: [PATCH 1/6] [test] SQLite tests compiling on Linux.
-
----
- third_party/sqlite/src/Makefile.linux-gcc | 41 ++++++++++++++++-------
- third_party/sqlite/src/main.mk | 2 +-
- 2 files changed, 30 insertions(+), 13 deletions(-)
-
-diff --git a/third_party/sqlite/src/Makefile.linux-gcc b/third_party/sqlite/src/Makefile.linux-gcc
-index b838b844a312..62d029430803 100644
---- a/third_party/sqlite/src/Makefile.linux-gcc
-+++ b/third_party/sqlite/src/Makefile.linux-gcc
-@@ -14,7 +14,7 @@
- #### The toplevel directory of the source tree. This is the directory
- # that contains this "Makefile.in" and the "configure.in" script.
- #
--TOP = ../sqlite
-+TOP = ..
-
- #### C Compiler and options for use in building executables that
- # will run on the platform that is doing the build.
-@@ -32,19 +32,19 @@ USLEEP = -DHAVE_USLEEP=1
- # multi-threaded program, then define the following macro
- # appropriately:
- #
--#THREADSAFE = -DTHREADSAFE=1
--THREADSAFE = -DTHREADSAFE=0
-+THREADSAFE = -DTHREADSAFE=1
-+#THREADSAFE = -DTHREADSAFE=0
-
- #### Specify any extra linker options needed to make the library
- # thread safe
- #
--#THREADLIB = -lpthread
--THREADLIB =
-+THREADLIB = -lpthread
-+#THREADLIB =
-
- #### Specify any extra libraries needed to access required functions.
- #
- #TLIBS = -lrt # fdatasync on Solaris 8
--TLIBS =
-+TLIBS = -ldl
-
- #### Leave SQLITE_DEBUG undefined for maximum speed. Use SQLITE_DEBUG=1
- # to check for memory leaks. Use SQLITE_DEBUG=2 to print a log of all
-@@ -58,7 +58,24 @@ TLIBS =
- #OPTS = -DSQLITE_DEBUG=1
- #OPTS =
- OPTS = -DNDEBUG=1
--OPTS += -DHAVE_FDATASYNC=1
-+#OPTS += -DHAVE_FDATASYNC=1
-+
-+# These flags match those for SQLITE_CFLAGS in config.mk.
-+
-+OPTS += -DSQLITE_DEFAULT_FILE_PERMISSIONS=0600
-+OPTS += -DHAVE_USLEEP=1
-+
-+# Additional SQLite tests.
-+OPTS += -DSQLITE_MEMDEBUG=1
-+
-+# Don't include these ones, they break the SQLite tests.
-+# -DSQLITE_OMIT_ATTACH=1 \
-+# -DSQLITE_OMIT_LOAD_EXTENSION=1 \
-+# -DSQLITE_OMIT_VACUUM=1 \
-+# -DSQLITE_TRANSACTION_DEFAULT_IMMEDIATE=1 \
-+
-+# TODO(shess) I can't see why I need this setting.
-+OPTS += -DOS_UNIX=1
-
- #### The suffix to add to executable files. ".exe" for windows.
- # Nothing for unix.
-@@ -70,7 +87,7 @@ EXE =
- # will run on the target platform. This is usually the same
- # as BCC, unless you are cross-compiling.
- #
--TCC = gcc -O6
-+TCC = gcc -Os
- #TCC = gcc -g -O0 -Wall
- #TCC = gcc -g -O0 -Wall -fprofile-arcs -ftest-coverage
- #TCC = /opt/mingw/bin/i386-mingw32-gcc -O6
-@@ -91,16 +108,16 @@ SHPREFIX = lib
-
- #### Extra compiler options needed for programs that use the TCL library.
- #
--#TCL_FLAGS =
-+TCL_FLAGS = -I/usr/include/tcl8.6
- #TCL_FLAGS = -DSTATIC_BUILD=1
--TCL_FLAGS = -I/home/drh/tcltk/8.5linux
-+#TCL_FLAGS = -I/home/drh/tcltk/8.5linux
- #TCL_FLAGS = -I/home/drh/tcltk/8.5win -DSTATIC_BUILD=1
- #TCL_FLAGS = -I/home/drh/tcltk/8.3hpux
-
- #### Linker options needed to link against the TCL library.
- #
--#LIBTCL = -ltcl -lm -ldl
--LIBTCL = /home/drh/tcltk/8.5linux/libtcl8.5g.a -lm -ldl
-+LIBTCL = -ltcl8.6 -lm -ldl
-+#LIBTCL = /home/drh/tcltk/8.5linux/libtcl8.5g.a -lm -ldl
- #LIBTCL = /home/drh/tcltk/8.5win/libtcl85s.a -lmsvcrt
- #LIBTCL = /home/drh/tcltk/8.3hpux/libtcl8.3.a -ldld -lm -lc
-
-diff --git a/third_party/sqlite/src/main.mk b/third_party/sqlite/src/main.mk
-index d18313bdc79a..05c8f83b4212 100644
---- a/third_party/sqlite/src/main.mk
-+++ b/third_party/sqlite/src/main.mk
-@@ -836,7 +836,7 @@ sqlite3_analyzer.c: sqlite3.c $(TOP)/src/tclsqlite.c $(TOP)/tool/spaceanal.tcl $
- tclsh $(TOP)/tool/mkccode.tcl $(TOP)/tool/sqlite3_analyzer.c.in >sqlite3_analyzer.c
-
- sqlite3_analyzer$(EXE): sqlite3_analyzer.c
-- $(TCCX) $(TCL_FLAGS) sqlite3_analyzer.c -o $@ $(LIBTCL) $(THREADLIB)
-+ $(TCCX) $(TCL_FLAGS) sqlite3_analyzer.c -o $@ $(LIBTCL) $(TLIBS) $(THREADLIB)
-
- sqltclsh.c: sqlite3.c $(TOP)/src/tclsqlite.c $(TOP)/tool/sqltclsh.tcl $(TOP)/ext/misc/appendvfs.c $(TOP)/tool/mkccode.tcl
- tclsh $(TOP)/tool/mkccode.tcl $(TOP)/tool/sqltclsh.c.in >sqltclsh.c
---
-2.18.0
-
diff --git a/chromium/third_party/sqlite/patches/0002-Modify-default-VFS-to-support-WebDatabase.patch b/chromium/third_party/sqlite/patches/0002-Modify-default-VFS-to-support-WebDatabase.patch
deleted file mode 100644
index 1dd942c5921..00000000000
--- a/chromium/third_party/sqlite/patches/0002-Modify-default-VFS-to-support-WebDatabase.patch
+++ /dev/null
@@ -1,179 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: dumi <dumi@chromium.org>
-Date: Mon, 20 Jul 2009 23:40:51 +0000
-Subject: [PATCH 2/6] Modify default VFS to support WebDatabase.
-
-The renderer WebDatabase implementation needs to broker certain requests
-to the browser. This modifies SQLite to allow monkey-patching the VFS
-to support this.
-
-NOTE(shess): This patch relies on core SQLite implementation details
-remaining unchanged. When importing a new version of SQLite, pay very
-close attention to whether the change is still doing what is intended.
-
-Original review URLs:
-https://codereview.chromium.org/159044
-https://codereview.chromium.org/384075
-https://codereview.chromium.org/377039
-[Possibly not a complete list.]
----
- third_party/sqlite/src/src/os_unix.c | 51 ++++++++++++++++++++++++++
- third_party/sqlite/src/src/os_win.c | 8 ++++
- third_party/sqlite/src/src/sqlite.h.in | 23 ++++++++++++
- 3 files changed, 82 insertions(+)
-
-diff --git a/third_party/sqlite/src/src/os_unix.c b/third_party/sqlite/src/src/os_unix.c
-index 52ef64116444..d0e1c39bc4b8 100644
---- a/third_party/sqlite/src/src/os_unix.c
-+++ b/third_party/sqlite/src/src/os_unix.c
-@@ -1437,6 +1437,12 @@ static int fileHasMoved(unixFile *pFile){
- return pFile->pInode!=0 && pFile->pId!=pFile->pInode->fileId.pId;
- #else
- struct stat buf;
-+
-+ /* TODO(shess): This check doesn't work when the Chromium's WebDB code is
-+ ** running in the sandbox.
-+ */
-+ return 0;
-+
- return pFile->pInode!=0 &&
- (osStat(pFile->zPath, &buf)!=0
- || (u64)buf.st_ino!=pFile->pInode->fileId.ino);
-@@ -5879,6 +5885,45 @@ static int findCreateFileMode(
- return rc;
- }
-
-+/*
-+** Initialize |unixFile| internals of |file| on behalf of chromiumOpen() in
-+** WebDatabase SQLiteFileSystemPosix.cpp. Function is a subset of unixOpen(),
-+** each duplicated piece is marked by "Duplicated in" comment in unixOpen().
-+*/
-+CHROMIUM_SQLITE_API
-+int chromium_sqlite3_fill_in_unix_sqlite3_file(sqlite3_vfs* pVfs,
-+ int fd,
-+ sqlite3_file* pFile,
-+ const char* zPath,
-+ int noLock,
-+ int flags) {
-+ unixFile *p = (unixFile *)pFile;
-+ const int eType = flags&0xFFFFFF00; /* Type of file to open */
-+ const int ctrlFlags = (noLock ? UNIXFILE_NOLOCK : 0);
-+ int rc;
-+
-+ memset(p, 0, sizeof(unixFile));
-+
-+ /* osStat() will not work in the sandbox, so findReusableFd() will always
-+ ** fail, so directly include the failure-case setup then initialize
-+ ** pPreallocatedUnused.
-+ */
-+ if( eType==SQLITE_OPEN_MAIN_DB ){
-+ p->pPreallocatedUnused = sqlite3_malloc(sizeof(*p->pPreallocatedUnused));
-+ if (!p->pPreallocatedUnused) {
-+ return SQLITE_NOMEM_BKPT;
-+ }
-+ p->pPreallocatedUnused->fd = fd;
-+ p->pPreallocatedUnused->flags = flags;
-+ }
-+
-+ rc = fillInUnixFile(pVfs, fd, pFile, zPath, ctrlFlags);
-+ if( rc!=SQLITE_OK ){
-+ sqlite3_free(p->pPreallocatedUnused);
-+ }
-+ return rc;
-+}
-+
- /*
- ** Open the file zPath.
- **
-@@ -5979,6 +6024,8 @@ static int unixOpen(
- randomnessPid = osGetpid(0);
- sqlite3_randomness(0,0);
- }
-+
-+ /* Duplicated in chromium_sqlite3_fill_in_unix_sqlite3_file(). */
- memset(p, 0, sizeof(unixFile));
-
- if( eType==SQLITE_OPEN_MAIN_DB ){
-@@ -5987,6 +6034,7 @@ static int unixOpen(
- if( pUnused ){
- fd = pUnused->fd;
- }else{
-+ /* Duplicated in chromium_sqlite3_fill_in_unix_sqlite3_file(). */
- pUnused = sqlite3_malloc64(sizeof(*pUnused));
- if( !pUnused ){
- return SQLITE_NOMEM_BKPT;
-@@ -6071,6 +6119,7 @@ static int unixOpen(
- }
-
- if( p->pPreallocatedUnused ){
-+ /* Duplicated in chromium_sqlite3_fill_in_unix_sqlite3_file(). */
- p->pPreallocatedUnused->fd = fd;
- p->pPreallocatedUnused->flags = flags;
- }
-@@ -6152,10 +6201,12 @@ static int unixOpen(
- assert( zPath==0 || zPath[0]=='/'
- || eType==SQLITE_OPEN_MASTER_JOURNAL || eType==SQLITE_OPEN_MAIN_JOURNAL
- );
-+ /* Duplicated in chromium_sqlite3_fill_in_unix_sqlite3_file(). */
- rc = fillInUnixFile(pVfs, fd, pFile, zPath, ctrlFlags);
-
- open_finished:
- if( rc!=SQLITE_OK ){
-+ /* Duplicated in chromium_sqlite3_fill_in_unix_sqlite3_file(). */
- sqlite3_free(p->pPreallocatedUnused);
- }
- return rc;
-diff --git a/third_party/sqlite/src/src/os_win.c b/third_party/sqlite/src/src/os_win.c
-index aafc89f7d2d5..76743781a019 100644
---- a/third_party/sqlite/src/src/os_win.c
-+++ b/third_party/sqlite/src/src/os_win.c
-@@ -6130,4 +6130,12 @@ int sqlite3_os_end(void){
- return SQLITE_OK;
- }
-
-+CHROMIUM_SQLITE_API
-+void chromium_sqlite3_initialize_win_sqlite3_file(sqlite3_file* file, HANDLE handle) {
-+ winFile* winSQLite3File = (winFile*)file;
-+ memset(file, 0, sizeof(*file));
-+ winSQLite3File->pMethod = &winIoMethod;
-+ winSQLite3File->h = handle;
-+}
-+
- #endif /* SQLITE_OS_WIN */
-diff --git a/third_party/sqlite/src/src/sqlite.h.in b/third_party/sqlite/src/src/sqlite.h.in
-index cf17bc015fa7..11622a49697f 100644
---- a/third_party/sqlite/src/src/sqlite.h.in
-+++ b/third_party/sqlite/src/src/sqlite.h.in
-@@ -8378,6 +8378,29 @@ int sqlite3_strnicmp(const char *, const char *, int);
- */
- int sqlite3_strglob(const char *zGlob, const char *zStr);
-
-+/* Begin WebDatabase patch for Chromium */
-+/* Expose some SQLite internals for the WebDatabase vfs.
-+** DO NOT EXTEND THE USE OF THIS.
-+*/
-+#ifndef CHROMIUM_SQLITE_API
-+#define CHROMIUM_SQLITE_API SQLITE_API
-+#endif
-+#if defined(CHROMIUM_SQLITE_INTERNALS)
-+#ifdef _WIN32
-+CHROMIUM_SQLITE_API
-+void chromium_sqlite3_initialize_win_sqlite3_file(sqlite3_file* file, HANDLE handle);
-+#else /* _WIN32 */
-+CHROMIUM_SQLITE_API
-+int chromium_sqlite3_fill_in_unix_sqlite3_file(sqlite3_vfs* pVfs,
-+ int fd,
-+ sqlite3_file* pFile,
-+ const char* zPath,
-+ int noLock,
-+ int flags);
-+#endif /* _WIN32 */
-+#endif /* CHROMIUM_SQLITE_INTERNALS */
-+/* End WebDatabase patch for Chromium */
-+
- /*
- ** CAPI3REF: String LIKE Matching
- *
---
-2.18.0
-
diff --git a/chromium/third_party/sqlite/patches/0002-Virtual-table-supporting-recovery-of-corrupted-datab.patch b/chromium/third_party/sqlite/patches/0002-Virtual-table-supporting-recovery-of-corrupted-datab.patch
index ff5175af8b8..ef5d82012f0 100644
--- a/chromium/third_party/sqlite/patches/0002-Virtual-table-supporting-recovery-of-corrupted-datab.patch
+++ b/chromium/third_party/sqlite/patches/0002-Virtual-table-supporting-recovery-of-corrupted-datab.patch
@@ -1,7 +1,7 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Scott Hess <shess@chromium.org>
Date: Sat, 20 Jul 2013 11:42:21 -0700
-Subject: [PATCH 02/17] Virtual table supporting recovery of corrupted
+Subject: [PATCH 02/40] Virtual table supporting recovery of corrupted
databases.
"recover" implements a virtual table which uses the SQLite pager layer
diff --git a/chromium/third_party/sqlite/patches/0003-Custom-shell.c-helpers-to-load-Chromium-s-ICU-data.patch b/chromium/third_party/sqlite/patches/0003-Custom-shell.c-helpers-to-load-Chromium-s-ICU-data.patch
index 95f7042c522..6a49c96d76a 100644
--- a/chromium/third_party/sqlite/patches/0003-Custom-shell.c-helpers-to-load-Chromium-s-ICU-data.patch
+++ b/chromium/third_party/sqlite/patches/0003-Custom-shell.c-helpers-to-load-Chromium-s-ICU-data.patch
@@ -1,7 +1,7 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: "tc@google.com" <tc@google.com>
Date: Tue, 6 Jan 2009 22:39:41 +0000
-Subject: [PATCH 03/17] Custom shell.c helpers to load Chromium's ICU data.
+Subject: [PATCH 03/40] Custom shell.c helpers to load Chromium's ICU data.
History uses fts3 with an icu-based segmenter. These changes allow building a
sqlite3 binary for Linux or Windows which can read those files.
diff --git a/chromium/third_party/sqlite/patches/0003-Virtual-table-supporting-recovery-of-corrupted-datab.patch b/chromium/third_party/sqlite/patches/0003-Virtual-table-supporting-recovery-of-corrupted-datab.patch
deleted file mode 100644
index f7f7e3e5941..00000000000
--- a/chromium/third_party/sqlite/patches/0003-Virtual-table-supporting-recovery-of-corrupted-datab.patch
+++ /dev/null
@@ -1,3904 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Scott Hess <shess@chromium.org>
-Date: Sat, 20 Jul 2013 11:42:21 -0700
-Subject: [PATCH 3/6] Virtual table supporting recovery of corrupted databases.
-
-"recover" implements a virtual table which uses the SQLite pager layer
-to read table pages and pull out the data which is structurally sound
-(at least at the storage layer).
-
-BUG=109482
-
-Since this implements a new feature for SQLite, the review URLs aren't
-listed. This patch and the top of recover.c should be considered
-authoritative. The history is mostly under
-third_party/sqlite/src/src/{recover,recover-alt}.c .
----
- third_party/sqlite/src/main.mk | 5 +
- third_party/sqlite/src/src/main.c | 8 +
- third_party/sqlite/src/src/recover.c | 2270 +++++++++++++++++++
- third_party/sqlite/src/src/recover.h | 23 +
- third_party/sqlite/src/src/recover_varint.c | 201 ++
- third_party/sqlite/src/test/recover.test | 164 ++
- third_party/sqlite/src/test/recover0.test | 532 +++++
- third_party/sqlite/src/test/recover1.test | 429 ++++
- third_party/sqlite/src/test/recover2.test | 157 ++
- 9 files changed, 3789 insertions(+)
- create mode 100644 third_party/sqlite/src/src/recover.c
- create mode 100644 third_party/sqlite/src/src/recover.h
- create mode 100644 third_party/sqlite/src/src/recover_varint.c
- create mode 100644 third_party/sqlite/src/test/recover.test
- create mode 100644 third_party/sqlite/src/test/recover0.test
- create mode 100644 third_party/sqlite/src/test/recover1.test
- create mode 100644 third_party/sqlite/src/test/recover2.test
-
-diff --git a/third_party/sqlite/src/main.mk b/third_party/sqlite/src/main.mk
-index 05c8f83b4212..9b50874926dc 100644
---- a/third_party/sqlite/src/main.mk
-+++ b/third_party/sqlite/src/main.mk
-@@ -77,6 +77,8 @@ LIBOBJ+= vdbe.o parse.o \
- vdbetrace.o wal.o walker.o where.o wherecode.o whereexpr.o \
- utf.o vtab.o window.o
-
-+LIBOBJ += recover.o recover_varint.o
-+
- LIBOBJ += sqlite3session.o
-
- # All of the source code files.
-@@ -409,6 +411,8 @@ TESTSRC2 = \
- $(TOP)/src/prepare.c \
- $(TOP)/src/printf.c \
- $(TOP)/src/random.c \
-+ $(TOP)/src/recover.c \
-+ $(TOP)/src/recover_varint.c \
- $(TOP)/src/pcache.c \
- $(TOP)/src/pcache1.c \
- $(TOP)/src/select.c \
-@@ -876,6 +880,7 @@ TESTFIXTURE_FLAGS += -DSQLITE_DEFAULT_PAGE_SIZE=1024
- TESTFIXTURE_FLAGS += -DSQLITE_ENABLE_STMTVTAB
- TESTFIXTURE_FLAGS += -DSQLITE_ENABLE_DBPAGE_VTAB
- TESTFIXTURE_FLAGS += -DTCLSH_INIT_PROC=sqlite3TestInit
-+TESTFIXTURE_FLAGS += -DDEFAULT_ENABLE_RECOVER=1
-
- testfixture$(EXE): $(TESTSRC2) libsqlite3.a $(TESTSRC) $(TOP)/src/tclsqlite.c
- $(TCCX) $(TCL_FLAGS) $(TESTFIXTURE_FLAGS) \
-diff --git a/third_party/sqlite/src/src/main.c b/third_party/sqlite/src/src/main.c
-index d994c7176ea4..478428ac27c8 100644
---- a/third_party/sqlite/src/src/main.c
-+++ b/third_party/sqlite/src/src/main.c
-@@ -3201,6 +3201,14 @@ static int openDatabase(
- }
- #endif
-
-+#ifdef DEFAULT_ENABLE_RECOVER
-+ /* Initialize recover virtual table for testing. */
-+ extern int chrome_sqlite3_recoverVtableInit(sqlite3 *db);
-+ if( !db->mallocFailed && rc==SQLITE_OK ){
-+ rc = chrome_sqlite3_recoverVtableInit(db);
-+ }
-+#endif
-+
- #if defined(SQLITE_ENABLE_ICU) || defined(SQLITE_ENABLE_ICU_COLLATIONS)
- if( !db->mallocFailed && rc==SQLITE_OK ){
- rc = sqlite3IcuInit(db);
-diff --git a/third_party/sqlite/src/src/recover.c b/third_party/sqlite/src/src/recover.c
-new file mode 100644
-index 000000000000..ba239a507f9c
---- /dev/null
-+++ b/third_party/sqlite/src/src/recover.c
-@@ -0,0 +1,2270 @@
-+/*
-+** 2012 Jan 11
-+**
-+** The author disclaims copyright to this source code. In place of
-+** a legal notice, here is a blessing:
-+**
-+** May you do good and not evil.
-+** May you find forgiveness for yourself and forgive others.
-+** May you share freely, never taking more than you give.
-+*/
-+/* TODO(shess): THIS MODULE IS STILL EXPERIMENTAL. DO NOT USE IT. */
-+/* Implements a virtual table "recover" which can be used to recover
-+ * data from a corrupt table. The table is walked manually, with
-+ * corrupt items skipped. Additionally, any errors while reading will
-+ * be skipped.
-+ *
-+ * Given a table with this definition:
-+ *
-+ * CREATE TABLE Stuff (
-+ * name TEXT PRIMARY KEY,
-+ * value TEXT NOT NULL
-+ * );
-+ *
-+ * to recover the data from teh table, you could do something like:
-+ *
-+ * -- Attach another database, the original is not trustworthy.
-+ * ATTACH DATABASE '/tmp/db.db' AS rdb;
-+ * -- Create a new version of the table.
-+ * CREATE TABLE rdb.Stuff (
-+ * name TEXT PRIMARY KEY,
-+ * value TEXT NOT NULL
-+ * );
-+ * -- This will read the original table's data.
-+ * CREATE VIRTUAL TABLE temp.recover_Stuff using recover(
-+ * main.Stuff,
-+ * name TEXT STRICT NOT NULL, -- only real TEXT data allowed
-+ * value TEXT STRICT NOT NULL
-+ * );
-+ * -- Corruption means the UNIQUE constraint may no longer hold for
-+ * -- Stuff, so either OR REPLACE or OR IGNORE must be used.
-+ * INSERT OR REPLACE INTO rdb.Stuff (rowid, name, value )
-+ * SELECT rowid, name, value FROM temp.recover_Stuff;
-+ * DROP TABLE temp.recover_Stuff;
-+ * DETACH DATABASE rdb;
-+ * -- Move db.db to replace original db in filesystem.
-+ *
-+ *
-+ * Usage
-+ *
-+ * Given the goal of dealing with corruption, it would not be safe to
-+ * create a recovery table in the database being recovered. So
-+ * recovery tables must be created in the temp database. They are not
-+ * appropriate to persist, in any case. [As a bonus, sqlite_master
-+ * tables can be recovered. Perhaps more cute than useful, though.]
-+ *
-+ * The parameters are a specifier for the table to read, and a column
-+ * definition for each bit of data stored in that table. The named
-+ * table must be convertable to a root page number by reading the
-+ * sqlite_master table. Bare table names are assumed to be in
-+ * database 0 ("main"), other databases can be specified in db.table
-+ * fashion.
-+ *
-+ * Column definitions are similar to BUT NOT THE SAME AS those
-+ * provided to CREATE statements:
-+ * column-def: column-name [type-name [STRICT] [NOT NULL]]
-+ * type-name: (ANY|ROWID|INTEGER|FLOAT|NUMERIC|TEXT|BLOB)
-+ *
-+ * Only those exact type names are accepted, there is no type
-+ * intuition. The only constraints accepted are STRICT (see below)
-+ * and NOT NULL. Anything unexpected will cause the create to fail.
-+ *
-+ * ANY is a convenience to indicate that manifest typing is desired.
-+ * It is equivalent to not specifying a type at all. The results for
-+ * such columns will have the type of the data's storage. The exposed
-+ * schema will contain no type for that column.
-+ *
-+ * ROWID is used for columns representing aliases to the rowid
-+ * (INTEGER PRIMARY KEY, with or without AUTOINCREMENT), to make the
-+ * concept explicit. Such columns are actually stored as NULL, so
-+ * they cannot be simply ignored. The exposed schema will be INTEGER
-+ * for that column.
-+ *
-+ * NOT NULL causes rows with a NULL in that column to be skipped. It
-+ * also adds NOT NULL to the column in the exposed schema. If the
-+ * table has ever had columns added using ALTER TABLE, then those
-+ * columns implicitly contain NULL for rows which have not been
-+ * updated. [Workaround using COALESCE() in your SELECT statement.]
-+ *
-+ * The created table is read-only, with no indices. Any SELECT will
-+ * be a full-table scan, returning each valid row read from the
-+ * storage of the backing table. The rowid will be the rowid of the
-+ * row from the backing table. "Valid" means:
-+ * - The cell metadata for the row is well-formed. Mainly this means that
-+ * the cell header info describes a payload of the size indicated by
-+ * the cell's payload size.
-+ * - The cell does not run off the page.
-+ * - The cell does not overlap any other cell on the page.
-+ * - The cell contains doesn't contain too many columns.
-+ * - The types of the serialized data match the indicated types (see below).
-+ *
-+ *
-+ * Type affinity versus type storage.
-+ *
-+ * http://www.sqlite.org/datatype3.html describes SQLite's type
-+ * affinity system. The system provides for automated coercion of
-+ * types in certain cases, transparently enough that many developers
-+ * do not realize that it is happening. Importantly, it implies that
-+ * the raw data stored in the database may not have the obvious type.
-+ *
-+ * Differences between the stored data types and the expected data
-+ * types may be a signal of corruption. This module makes some
-+ * allowances for automatic coercion. It is important to be concious
-+ * of the difference between the schema exposed by the module, and the
-+ * data types read from storage. The following table describes how
-+ * the module interprets things:
-+ *
-+ * type schema data STRICT
-+ * ---- ------ ---- ------
-+ * ANY <none> any any
-+ * ROWID INTEGER n/a n/a
-+ * INTEGER INTEGER integer integer
-+ * FLOAT FLOAT integer or float float
-+ * NUMERIC NUMERIC integer, float, or text integer or float
-+ * TEXT TEXT text or blob text
-+ * BLOB BLOB blob blob
-+ *
-+ * type is the type provided to the recover module, schema is the
-+ * schema exposed by the module, data is the acceptable types of data
-+ * decoded from storage, and STRICT is a modification of that.
-+ *
-+ * A very loose recovery system might use ANY for all columns, then
-+ * use the appropriate sqlite3_column_*() calls to coerce to expected
-+ * types. This doesn't provide much protection if a page from a
-+ * different table with the same column count is linked into an
-+ * inappropriate btree.
-+ *
-+ * A very tight recovery system might use STRICT to enforce typing on
-+ * all columns, preferring to skip rows which are valid at the storage
-+ * level but don't contain the right types. Note that FLOAT STRICT is
-+ * almost certainly not appropriate, since integral values are
-+ * transparently stored as integers, when that is more efficient.
-+ *
-+ * Another option is to use ANY for all columns and inspect each
-+ * result manually (using sqlite3_column_*). This should only be
-+ * necessary in cases where developers have used manifest typing (test
-+ * to make sure before you decide that you aren't using manifest
-+ * typing!).
-+ *
-+ *
-+ * Caveats
-+ *
-+ * Leaf pages not referenced by interior nodes will not be found.
-+ *
-+ * Leaf pages referenced from interior nodes of other tables will not
-+ * be resolved.
-+ *
-+ * Rows referencing invalid overflow pages will be skipped.
-+ *
-+ * SQlite rows have a header which describes how to interpret the rest
-+ * of the payload. The header can be valid in cases where the rest of
-+ * the record is actually corrupt (in the sense that the data is not
-+ * the intended data). This can especially happen WRT overflow pages,
-+ * as lack of atomic updates between pages is the primary form of
-+ * corruption I have seen in the wild.
-+ */
-+/* The implementation is via a series of cursors. The cursor
-+ * implementations follow the pattern:
-+ *
-+ * // Creates the cursor using various initialization info.
-+ * int cursorCreate(...);
-+ *
-+ * // Returns 1 if there is no more data, 0 otherwise.
-+ * int cursorEOF(Cursor *pCursor);
-+ *
-+ * // Various accessors can be used if not at EOF.
-+ *
-+ * // Move to the next item.
-+ * int cursorNext(Cursor *pCursor);
-+ *
-+ * // Destroy the memory associated with the cursor.
-+ * void cursorDestroy(Cursor *pCursor);
-+ *
-+ * References in the following are to sections at
-+ * http://www.sqlite.org/fileformat2.html .
-+ *
-+ * RecoverLeafCursor iterates the records in a leaf table node
-+ * described in section 1.5 "B-tree Pages". When the node is
-+ * exhausted, an interior cursor is used to get the next leaf node,
-+ * and iteration continues there.
-+ *
-+ * RecoverInteriorCursor iterates the child pages in an interior table
-+ * node described in section 1.5 "B-tree Pages". When the node is
-+ * exhausted, a parent interior cursor is used to get the next
-+ * interior node at the same level, and iteration continues there.
-+ *
-+ * Together these record the path from the leaf level to the root of
-+ * the tree. Iteration happens from the leaves rather than the root
-+ * both for efficiency and putting the special case at the front of
-+ * the list is easier to implement.
-+ *
-+ * RecoverCursor uses a RecoverLeafCursor to iterate the rows of a
-+ * table, returning results via the SQLite virtual table interface.
-+ */
-+/* TODO(shess): It might be useful to allow DEFAULT in types to
-+ * specify what to do for NULL when an ALTER TABLE case comes up.
-+ * Unfortunately, simply adding it to the exposed schema and using
-+ * sqlite3_result_null() does not cause the default to be generate.
-+ * Handling it ourselves seems hard, unfortunately.
-+ */
-+
-+#include <assert.h>
-+#include <ctype.h>
-+#include <stdint.h>
-+#include <stdio.h>
-+#include <string.h>
-+
-+#include "sqlite3.h"
-+
-+/* Some SQLite internals use, cribbed from fts5int.h. */
-+#ifndef SQLITE_AMALGAMATION
-+typedef uint8_t u8;
-+typedef uint32_t u32;
-+typedef sqlite3_int64 i64;
-+typedef sqlite3_uint64 u64;
-+
-+#define ArraySize(x) (sizeof(x) / sizeof(x[0]))
-+#endif
-+
-+/* From recover_varint.c. */
-+u8 recoverGetVarint(const unsigned char *p, u64 *v);
-+
-+/* For debugging. */
-+#if 0
-+#define FNENTRY() fprintf(stderr, "In %s\n", __FUNCTION__)
-+#else
-+#define FNENTRY()
-+#endif
-+
-+/* Generic constants and helper functions. */
-+
-+static const unsigned char kTableLeafPage = 0x0D;
-+static const unsigned char kTableInteriorPage = 0x05;
-+
-+/* From section 1.2. */
-+static const unsigned kiHeaderPageSizeOffset = 16;
-+static const unsigned kiHeaderReservedSizeOffset = 20;
-+static const unsigned kiHeaderEncodingOffset = 56;
-+/* TODO(shess) |static const unsigned| fails creating the header in GetPager()
-+** because |knHeaderSize| isn't |constexpr|. But this isn't C++, either.
-+*/
-+enum { knHeaderSize = 100};
-+
-+/* From section 1.5. */
-+static const unsigned kiPageTypeOffset = 0;
-+/* static const unsigned kiPageFreeBlockOffset = 1; */
-+static const unsigned kiPageCellCountOffset = 3;
-+/* static const unsigned kiPageCellContentOffset = 5; */
-+/* static const unsigned kiPageFragmentedBytesOffset = 7; */
-+static const unsigned knPageLeafHeaderBytes = 8;
-+/* Interior pages contain an additional field. */
-+static const unsigned kiPageRightChildOffset = 8;
-+static const unsigned kiPageInteriorHeaderBytes = 12;
-+
-+/* Accepted types are specified by a mask. */
-+#define MASK_ROWID (1<<0)
-+#define MASK_INTEGER (1<<1)
-+#define MASK_FLOAT (1<<2)
-+#define MASK_TEXT (1<<3)
-+#define MASK_BLOB (1<<4)
-+#define MASK_NULL (1<<5)
-+
-+/* Helpers to decode fixed-size fields. */
-+static u32 decodeUnsigned16(const unsigned char *pData){
-+ return (pData[0]<<8) + pData[1];
-+}
-+static u32 decodeUnsigned32(const unsigned char *pData){
-+ return (decodeUnsigned16(pData)<<16) + decodeUnsigned16(pData+2);
-+}
-+static i64 decodeSigned(const unsigned char *pData, unsigned nBytes){
-+ i64 r = (char)(*pData);
-+ while( --nBytes ){
-+ r <<= 8;
-+ r += *(++pData);
-+ }
-+ return r;
-+}
-+/* Derived from vdbeaux.c, sqlite3VdbeSerialGet(), case 7. */
-+/* TODO(shess): Determine if swapMixedEndianFloat() applies. */
-+static double decodeFloat64(const unsigned char *pData){
-+#if !defined(NDEBUG)
-+ static const u64 t1 = ((u64)0x3ff00000)<<32;
-+ static const double r1 = 1.0;
-+ u64 t2 = t1;
-+ assert( sizeof(r1)==sizeof(t2) && memcmp(&r1, &t2, sizeof(r1))==0 );
-+#endif
-+ i64 x = decodeSigned(pData, 8);
-+ double d;
-+ memcpy(&d, &x, sizeof(x));
-+ return d;
-+}
-+
-+/* Return true if a varint can safely be read from pData/nData. */
-+/* TODO(shess): DbPage points into the middle of a buffer which
-+ * contains the page data before DbPage. So code should always be
-+ * able to read a small number of varints safely. Consider whether to
-+ * trust that or not.
-+ */
-+static int checkVarint(const unsigned char *pData, unsigned nData){
-+ unsigned i;
-+
-+ /* In the worst case the decoder takes all 8 bits of the 9th byte. */
-+ if( nData>=9 ){
-+ return 1;
-+ }
-+
-+ /* Look for a high-bit-clear byte in what's left. */
-+ for( i=0; i<nData; ++i ){
-+ if( !(pData[i]&0x80) ){
-+ return 1;
-+ }
-+ }
-+
-+ /* Cannot decode in the space given. */
-+ return 0;
-+}
-+
-+/* Return 1 if n varints can be read from pData/nData. */
-+static int checkVarints(const unsigned char *pData, unsigned nData,
-+ unsigned n){
-+ unsigned nCur = 0; /* Byte offset within current varint. */
-+ unsigned nFound = 0; /* Number of varints found. */
-+ unsigned i;
-+
-+ /* In the worst case the decoder takes all 8 bits of the 9th byte. */
-+ if( nData>=9*n ){
-+ return 1;
-+ }
-+
-+ for( i=0; nFound<n && i<nData; ++i ){
-+ nCur++;
-+ if( nCur==9 || !(pData[i]&0x80) ){
-+ nFound++;
-+ nCur = 0;
-+ }
-+ }
-+
-+ return nFound==n;
-+}
-+
-+/* ctype and str[n]casecmp() can be affected by locale (eg, tr_TR).
-+ * These versions consider only the ASCII space.
-+ */
-+/* TODO(shess): It may be reasonable to just remove the need for these
-+ * entirely. The module could require "TEXT STRICT NOT NULL", not
-+ * "Text Strict Not Null" or whatever the developer felt like typing
-+ * that day. Handling corrupt data is a PERFECT place to be pedantic.
-+ */
-+static int ascii_isspace(char c){
-+ /* From fts3_expr.c */
-+ return c==' ' || c=='\t' || c=='\n' || c=='\r' || c=='\v' || c=='\f';
-+}
-+static int ascii_isalnum(int x){
-+ /* From fts3_tokenizer1.c */
-+ return (x>='0' && x<='9') || (x>='A' && x<='Z') || (x>='a' && x<='z');
-+}
-+static int ascii_tolower(int x){
-+ /* From fts3_tokenizer1.c */
-+ return (x>='A' && x<='Z') ? x-'A'+'a' : x;
-+}
-+/* TODO(shess): Consider sqlite3_strnicmp() */
-+static int ascii_strncasecmp(const char *s1, const char *s2, size_t n){
-+ const unsigned char *us1 = (const unsigned char *)s1;
-+ const unsigned char *us2 = (const unsigned char *)s2;
-+ while( *us1 && *us2 && n && ascii_tolower(*us1)==ascii_tolower(*us2) ){
-+ us1++, us2++, n--;
-+ }
-+ return n ? ascii_tolower(*us1)-ascii_tolower(*us2) : 0;
-+}
-+static int ascii_strcasecmp(const char *s1, const char *s2){
-+ /* If s2 is equal through strlen(s1), will exit while() due to s1's
-+ * trailing NUL, and return NUL-s2[strlen(s1)].
-+ */
-+ return ascii_strncasecmp(s1, s2, strlen(s1)+1);
-+}
-+
-+/* Provide access to the pages of a SQLite database in a way similar to SQLite's
-+** Pager.
-+*/
-+typedef struct RecoverPager RecoverPager;
-+struct RecoverPager {
-+ sqlite3_file *pSqliteFile; /* Reference to database's file handle */
-+ u32 nPageSize; /* Size of pages in pSqliteFile */
-+};
-+
-+static void pagerDestroy(RecoverPager *pPager){
-+ pPager->pSqliteFile->pMethods->xUnlock(pPager->pSqliteFile, SQLITE_LOCK_NONE);
-+ memset(pPager, 0xA5, sizeof(*pPager));
-+ sqlite3_free(pPager);
-+}
-+
-+/* pSqliteFile should already have a SHARED lock. */
-+static int pagerCreate(sqlite3_file *pSqliteFile, u32 nPageSize,
-+ RecoverPager **ppPager){
-+ RecoverPager *pPager = sqlite3_malloc(sizeof(RecoverPager));
-+ if( !pPager ){
-+ return SQLITE_NOMEM;
-+ }
-+
-+ memset(pPager, 0, sizeof(*pPager));
-+ pPager->pSqliteFile = pSqliteFile;
-+ pPager->nPageSize = nPageSize;
-+ *ppPager = pPager;
-+ return SQLITE_OK;
-+}
-+
-+/* Matches DbPage (aka PgHdr) from SQLite internals. */
-+/* TODO(shess): SQLite by default allocates page metadata in a single allocation
-+** such that the page's data and metadata are contiguous, see pcache1AllocPage
-+** in pcache1.c. I believe this was intended to reduce malloc churn. It means
-+** that Chromium's automated tooling would be unlikely to see page-buffer
-+** overruns. I believe that this code is safe, but for now replicate SQLite's
-+** approach with kExcessSpace.
-+*/
-+const int kExcessSpace = 128;
-+typedef struct RecoverPage RecoverPage;
-+struct RecoverPage {
-+ u32 pgno; /* Page number for this page */
-+ void *pData; /* Page data for pgno */
-+ RecoverPager *pPager; /* The pager this page is part of */
-+};
-+
-+static void pageDestroy(RecoverPage *pPage){
-+ sqlite3_free(pPage->pData);
-+ memset(pPage, 0xA5, sizeof(*pPage));
-+ sqlite3_free(pPage);
-+}
-+
-+static int pageCreate(RecoverPager *pPager, u32 pgno, RecoverPage **ppPage){
-+ RecoverPage *pPage = sqlite3_malloc(sizeof(RecoverPage));
-+ if( !pPage ){
-+ return SQLITE_NOMEM;
-+ }
-+
-+ memset(pPage, 0, sizeof(*pPage));
-+ pPage->pPager = pPager;
-+ pPage->pgno = pgno;
-+ pPage->pData = sqlite3_malloc(pPager->nPageSize + kExcessSpace);
-+ if( pPage->pData==NULL ){
-+ pageDestroy(pPage);
-+ return SQLITE_NOMEM;
-+ }
-+ memset((u8 *)pPage->pData + pPager->nPageSize, 0, kExcessSpace);
-+
-+ *ppPage = pPage;
-+ return SQLITE_OK;
-+}
-+
-+static int pagerGetPage(RecoverPager *pPager, u32 iPage, RecoverPage **ppPage) {
-+ sqlite3_int64 iOfst;
-+ sqlite3_file *pFile = pPager->pSqliteFile;
-+ RecoverPage *pPage;
-+ int rc = pageCreate(pPager, iPage, &pPage);
-+ if( rc!=SQLITE_OK ){
-+ return rc;
-+ }
-+
-+ /* xRead() can return SQLITE_IOERR_SHORT_READ, which should be treated as
-+ ** SQLITE_OK plus an EOF indicator. The excess space is zero-filled.
-+ */
-+ iOfst = ((sqlite3_int64)iPage - 1) * pPager->nPageSize;
-+ rc = pFile->pMethods->xRead(pFile, pPage->pData, pPager->nPageSize, iOfst);
-+ if( rc!=SQLITE_OK && rc!=SQLITE_IOERR_SHORT_READ ){
-+ pageDestroy(pPage);
-+ return rc;
-+ }
-+
-+ *ppPage = pPage;
-+ return SQLITE_OK;
-+}
-+
-+/* For some reason I kept making mistakes with offset calculations. */
-+static const unsigned char *PageData(RecoverPage *pPage, unsigned iOffset){
-+ assert( iOffset<=pPage->pPager->nPageSize );
-+ return (unsigned char *)pPage->pData + iOffset;
-+}
-+
-+/* The first page in the file contains a file header in the first 100
-+ * bytes. The page's header information comes after that. Note that
-+ * the offsets in the page's header information are relative to the
-+ * beginning of the page, NOT the end of the page header.
-+ */
-+static const unsigned char *PageHeader(RecoverPage *pPage){
-+ if( pPage->pgno==1 ){
-+ return PageData(pPage, knHeaderSize);
-+ }else{
-+ return PageData(pPage, 0);
-+ }
-+}
-+
-+/* Helper to fetch the pager and page size for the named database. */
-+static int GetPager(sqlite3 *db, const char *zName,
-+ RecoverPager **ppPager, unsigned *pnPageSize,
-+ int *piEncoding){
-+ int rc, iEncoding;
-+ unsigned nPageSize, nReservedSize;
-+ unsigned char header[knHeaderSize];
-+ sqlite3_file *pFile = NULL;
-+ RecoverPager *pPager;
-+
-+ rc = sqlite3_file_control(db, zName, SQLITE_FCNTL_FILE_POINTER, &pFile);
-+ if( rc!=SQLITE_OK ) {
-+ return rc;
-+ } else if( pFile==NULL ){
-+ /* The documentation for sqlite3PagerFile() indicates it can return NULL if
-+ ** the file has not yet been opened. That should not be possible here...
-+ */
-+ return SQLITE_MISUSE;
-+ }
-+
-+ /* Get a shared lock to make sure the on-disk version of the file is truth. */
-+ rc = pFile->pMethods->xLock(pFile, SQLITE_LOCK_SHARED);
-+ if( rc != SQLITE_OK ){
-+ return rc;
-+ }
-+
-+ /* Read the Initial header information. In case of SQLITE_IOERR_SHORT_READ,
-+ ** the header is incomplete, which means no data could be recovered anyhow.
-+ */
-+ rc = pFile->pMethods->xRead(pFile, header, sizeof(header), 0);
-+ if( rc != SQLITE_OK ){
-+ pFile->pMethods->xUnlock(pFile, SQLITE_LOCK_NONE);
-+ if( rc==SQLITE_IOERR_SHORT_READ ){
-+ return SQLITE_CORRUPT;
-+ }
-+ return rc;
-+ }
-+
-+ /* Page size must be a power of two between 512 and 32768 inclusive. */
-+ nPageSize = decodeUnsigned16(header + kiHeaderPageSizeOffset);
-+ if( (nPageSize&(nPageSize-1)) || nPageSize>32768 || nPageSize<512 ){
-+ pFile->pMethods->xUnlock(pFile, SQLITE_LOCK_NONE);
-+ return rc;
-+ }
-+
-+ /* Space reserved a the end of the page for extensions. Usually 0. */
-+ nReservedSize = header[kiHeaderReservedSizeOffset];
-+
-+ /* 1 for UTF-8, 2 for UTF-16le, 3 for UTF-16be. */
-+ iEncoding = decodeUnsigned32(header + kiHeaderEncodingOffset);
-+ if( iEncoding==3 ){
-+ *piEncoding = SQLITE_UTF16BE;
-+ } else if( iEncoding==2 ){
-+ *piEncoding = SQLITE_UTF16LE;
-+ } else if( iEncoding==1 ){
-+ *piEncoding = SQLITE_UTF8;
-+ } else {
-+ /* This case should not be possible. */
-+ *piEncoding = SQLITE_UTF8;
-+ }
-+
-+ rc = pagerCreate(pFile, nPageSize, &pPager);
-+ if( rc!=SQLITE_OK ){
-+ pFile->pMethods->xUnlock(pFile, SQLITE_LOCK_NONE);
-+ return rc;
-+ }
-+
-+ *ppPager = pPager;
-+ *pnPageSize = nPageSize - nReservedSize;
-+ *piEncoding = iEncoding;
-+ return SQLITE_OK;
-+}
-+
-+/* iSerialType is a type read from a record header. See "2.1 Record Format".
-+ */
-+
-+/* Storage size of iSerialType in bytes. My interpretation of SQLite
-+ * documentation is that text and blob fields can have 32-bit length.
-+ * Values past 2^31-12 will need more than 32 bits to encode, which is
-+ * why iSerialType is u64.
-+ */
-+static u32 SerialTypeLength(u64 iSerialType){
-+ switch( iSerialType ){
-+ case 0 : return 0; /* NULL */
-+ case 1 : return 1; /* Various integers. */
-+ case 2 : return 2;
-+ case 3 : return 3;
-+ case 4 : return 4;
-+ case 5 : return 6;
-+ case 6 : return 8;
-+ case 7 : return 8; /* 64-bit float. */
-+ case 8 : return 0; /* Constant 0. */
-+ case 9 : return 0; /* Constant 1. */
-+ case 10 : case 11 : assert( "RESERVED TYPE"==NULL ); return 0;
-+ }
-+ return (u32)((iSerialType>>1) - 6);
-+}
-+
-+/* True if iSerialType refers to a blob. */
-+static int SerialTypeIsBlob(u64 iSerialType){
-+ assert( iSerialType>=12 );
-+ return (iSerialType%2)==0;
-+}
-+
-+/* Returns true if the serialized type represented by iSerialType is
-+ * compatible with the given type mask.
-+ */
-+static int SerialTypeIsCompatible(u64 iSerialType, unsigned char mask){
-+ switch( iSerialType ){
-+ case 0 : return (mask&MASK_NULL)!=0;
-+ case 1 : return (mask&MASK_INTEGER)!=0;
-+ case 2 : return (mask&MASK_INTEGER)!=0;
-+ case 3 : return (mask&MASK_INTEGER)!=0;
-+ case 4 : return (mask&MASK_INTEGER)!=0;
-+ case 5 : return (mask&MASK_INTEGER)!=0;
-+ case 6 : return (mask&MASK_INTEGER)!=0;
-+ case 7 : return (mask&MASK_FLOAT)!=0;
-+ case 8 : return (mask&MASK_INTEGER)!=0;
-+ case 9 : return (mask&MASK_INTEGER)!=0;
-+ case 10 : assert( "RESERVED TYPE"==NULL ); return 0;
-+ case 11 : assert( "RESERVED TYPE"==NULL ); return 0;
-+ }
-+ return (mask&(SerialTypeIsBlob(iSerialType) ? MASK_BLOB : MASK_TEXT));
-+}
-+
-+/* Versions of strdup() with return values appropriate for
-+ * sqlite3_free(). malloc.c has sqlite3DbStrDup()/NDup(), but those
-+ * need sqlite3DbFree(), which seems intrusive.
-+ */
-+static char *sqlite3_strndup(const char *z, unsigned n){
-+ char *zNew;
-+
-+ if( z==NULL ){
-+ return NULL;
-+ }
-+
-+ zNew = sqlite3_malloc(n+1);
-+ if( zNew!=NULL ){
-+ memcpy(zNew, z, n);
-+ zNew[n] = '\0';
-+ }
-+ return zNew;
-+}
-+static char *sqlite3_strdup(const char *z){
-+ if( z==NULL ){
-+ return NULL;
-+ }
-+ return sqlite3_strndup(z, strlen(z));
-+}
-+
-+/* Fetch the page number of zTable in zDb from sqlite_master in zDb,
-+ * and put it in *piRootPage.
-+ */
-+static int getRootPage(sqlite3 *db, const char *zDb, const char *zTable,
-+ u32 *piRootPage){
-+ char *zSql; /* SQL selecting root page of named element. */
-+ sqlite3_stmt *pStmt;
-+ int rc;
-+
-+ if( strcmp(zTable, "sqlite_master")==0 ){
-+ *piRootPage = 1;
-+ return SQLITE_OK;
-+ }
-+
-+ zSql = sqlite3_mprintf("SELECT rootpage FROM %s.sqlite_master "
-+ "WHERE type = 'table' AND tbl_name = %Q",
-+ zDb, zTable);
-+ if( !zSql ){
-+ return SQLITE_NOMEM;
-+ }
-+
-+ rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);
-+ sqlite3_free(zSql);
-+ if( rc!=SQLITE_OK ){
-+ return rc;
-+ }
-+
-+ /* Require a result. */
-+ rc = sqlite3_step(pStmt);
-+ if( rc==SQLITE_DONE ){
-+ rc = SQLITE_CORRUPT;
-+ }else if( rc==SQLITE_ROW ){
-+ *piRootPage = sqlite3_column_int(pStmt, 0);
-+
-+ /* Require only one result. */
-+ rc = sqlite3_step(pStmt);
-+ if( rc==SQLITE_DONE ){
-+ rc = SQLITE_OK;
-+ }else if( rc==SQLITE_ROW ){
-+ rc = SQLITE_CORRUPT;
-+ }
-+ }
-+ sqlite3_finalize(pStmt);
-+ return rc;
-+}
-+
-+/* Cursor for iterating interior nodes. Interior page cells contain a
-+ * child page number and a rowid. The child page contains items left
-+ * of the rowid (less than). The rightmost page of the subtree is
-+ * stored in the page header.
-+ *
-+ * interiorCursorDestroy - release all resources associated with the
-+ * cursor and any parent cursors.
-+ * interiorCursorCreate - create a cursor with the given parent and page.
-+ * interiorCursorNextPage - fetch the next child page from the cursor.
-+ *
-+ * Logically, interiorCursorNextPage() returns the next child page
-+ * number from the page the cursor is currently reading, calling the
-+ * parent cursor as necessary to get new pages to read, until done.
-+ * SQLITE_ROW if a page is returned, SQLITE_DONE if out of pages,
-+ * error otherwise. Unfortunately, if the table is corrupted
-+ * unexpected pages can be returned. If any unexpected page is found,
-+ * leaf or otherwise, it is returned to the caller for processing,
-+ * with the interior cursor left empty. The next call to
-+ * interiorCursorNextPage() will recurse to the parent cursor until an
-+ * interior page to iterate is returned.
-+ *
-+ * Note that while interiorCursorNextPage() will refuse to follow
-+ * loops, it does not keep track of pages returned for purposes of
-+ * preventing duplication.
-+ */
-+typedef struct RecoverInteriorCursor RecoverInteriorCursor;
-+struct RecoverInteriorCursor {
-+ RecoverInteriorCursor *pParent; /* Parent node to this node. */
-+ RecoverPage *pPage; /* Reference to leaf page. */
-+ unsigned nPageSize; /* Size of page. */
-+ unsigned nChildren; /* Number of children on the page. */
-+ unsigned iChild; /* Index of next child to return. */
-+};
-+
-+static void interiorCursorDestroy(RecoverInteriorCursor *pCursor){
-+ /* Destroy all the cursors to the root. */
-+ while( pCursor ){
-+ RecoverInteriorCursor *p = pCursor;
-+ pCursor = pCursor->pParent;
-+
-+ if( p->pPage ){
-+ pageDestroy(p->pPage);
-+ p->pPage = NULL;
-+ }
-+
-+ memset(p, 0xA5, sizeof(*p));
-+ sqlite3_free(p);
-+ }
-+}
-+
-+/* Internal helper. Reset storage in preparation for iterating pPage. */
-+static void interiorCursorSetPage(RecoverInteriorCursor *pCursor,
-+ RecoverPage *pPage){
-+ const unsigned knMinCellLength = 2 + 4 + 1;
-+ unsigned nMaxChildren;
-+ assert( PageHeader(pPage)[kiPageTypeOffset]==kTableInteriorPage );
-+
-+ if( pCursor->pPage ){
-+ pageDestroy(pCursor->pPage);
-+ pCursor->pPage = NULL;
-+ }
-+ pCursor->pPage = pPage;
-+ pCursor->iChild = 0;
-+
-+ /* A child for each cell, plus one in the header. */
-+ pCursor->nChildren = decodeUnsigned16(PageHeader(pPage) +
-+ kiPageCellCountOffset) + 1;
-+
-+ /* Each child requires a 16-bit offset from an array after the header,
-+ * and each child contains a 32-bit page number and at least a varint
-+ * (min size of one byte). The final child page is in the header. So
-+ * the maximum value for nChildren is:
-+ * (nPageSize - kiPageInteriorHeaderBytes) /
-+ * (sizeof(uint16) + sizeof(uint32) + 1) + 1
-+ */
-+ /* TODO(shess): This count is very unlikely to be corrupted in
-+ * isolation, so seeing this could signal to skip the page. OTOH, I
-+ * can't offhand think of how to get here unless this or the page-type
-+ * byte is corrupted. Could be an overflow page, but it would require
-+ * a very large database.
-+ */
-+ nMaxChildren =
-+ (pCursor->nPageSize - kiPageInteriorHeaderBytes) / knMinCellLength + 1;
-+ if (pCursor->nChildren > nMaxChildren) {
-+ pCursor->nChildren = nMaxChildren;
-+ }
-+}
-+
-+static int interiorCursorCreate(RecoverInteriorCursor *pParent,
-+ RecoverPage *pPage, int nPageSize,
-+ RecoverInteriorCursor **ppCursor){
-+ RecoverInteriorCursor *pCursor =
-+ sqlite3_malloc(sizeof(RecoverInteriorCursor));
-+ if( !pCursor ){
-+ return SQLITE_NOMEM;
-+ }
-+
-+ memset(pCursor, 0, sizeof(*pCursor));
-+ pCursor->pParent = pParent;
-+ pCursor->nPageSize = nPageSize;
-+ interiorCursorSetPage(pCursor, pPage);
-+ *ppCursor = pCursor;
-+ return SQLITE_OK;
-+}
-+
-+/* Internal helper. Return the child page number at iChild. */
-+static unsigned interiorCursorChildPage(RecoverInteriorCursor *pCursor){
-+ const unsigned char *pPageHeader; /* Header of the current page. */
-+ const unsigned char *pCellOffsets; /* Offset to page's cell offsets. */
-+ unsigned iCellOffset; /* Offset of target cell. */
-+
-+ assert( pCursor->iChild<pCursor->nChildren );
-+
-+ /* Rightmost child is in the header. */
-+ pPageHeader = PageHeader(pCursor->pPage);
-+ if( pCursor->iChild==pCursor->nChildren-1 ){
-+ return decodeUnsigned32(pPageHeader + kiPageRightChildOffset);
-+ }
-+
-+ /* Each cell is a 4-byte integer page number and a varint rowid
-+ * which is greater than the rowid of items in that sub-tree (this
-+ * module ignores ordering). The offset is from the beginning of the
-+ * page, not from the page header.
-+ */
-+ pCellOffsets = pPageHeader + kiPageInteriorHeaderBytes;
-+ iCellOffset = decodeUnsigned16(pCellOffsets + pCursor->iChild*2);
-+ if( iCellOffset<=pCursor->nPageSize-4 ){
-+ return decodeUnsigned32(PageData(pCursor->pPage, iCellOffset));
-+ }
-+
-+ /* TODO(shess): Check for cell overlaps? Cells require 4 bytes plus
-+ * a varint. Check could be identical to leaf check (or even a
-+ * shared helper testing for "Cells starting in this range"?).
-+ */
-+
-+ /* If the offset is broken, return an invalid page number. */
-+ return 0;
-+}
-+
-+/* Internal helper. Used to detect if iPage would cause a loop. */
-+static int interiorCursorPageInUse(RecoverInteriorCursor *pCursor,
-+ unsigned iPage){
-+ /* Find any parent using the indicated page. */
-+ while( pCursor && pCursor->pPage->pgno!=iPage ){
-+ pCursor = pCursor->pParent;
-+ }
-+ return pCursor!=NULL;
-+}
-+
-+/* Get the next page from the interior cursor at *ppCursor. Returns
-+ * SQLITE_ROW with the page in *ppPage, or SQLITE_DONE if out of
-+ * pages, or the error SQLite returned.
-+ *
-+ * If the tree is uneven, then when the cursor attempts to get a new
-+ * interior page from the parent cursor, it may get a non-interior
-+ * page. In that case, the new page is returned, and *ppCursor is
-+ * updated to point to the parent cursor (this cursor is freed).
-+ */
-+/* TODO(shess): I've tried to avoid recursion in most of this code,
-+ * but this case is more challenging because the recursive call is in
-+ * the middle of operation. One option for converting it without
-+ * adding memory management would be to retain the head pointer and
-+ * use a helper to "back up" as needed. Another option would be to
-+ * reverse the list during traversal.
-+ */
-+static int interiorCursorNextPage(RecoverInteriorCursor **ppCursor,
-+ RecoverPage **ppPage){
-+ RecoverInteriorCursor *pCursor = *ppCursor;
-+ while( 1 ){
-+ int rc;
-+ const unsigned char *pPageHeader; /* Header of found page. */
-+
-+ /* Find a valid child page which isn't on the stack. */
-+ while( pCursor->iChild<pCursor->nChildren ){
-+ const unsigned iPage = interiorCursorChildPage(pCursor);
-+ pCursor->iChild++;
-+ if( interiorCursorPageInUse(pCursor, iPage) ){
-+ fprintf(stderr, "Loop detected at %d\n", iPage);
-+ }else{
-+ int rc = pagerGetPage(pCursor->pPage->pPager, iPage, ppPage);
-+ if( rc==SQLITE_OK ){
-+ return SQLITE_ROW;
-+ }
-+ }
-+ }
-+
-+ /* This page has no more children. Get next page from parent. */
-+ if( !pCursor->pParent ){
-+ return SQLITE_DONE;
-+ }
-+ rc = interiorCursorNextPage(&pCursor->pParent, ppPage);
-+ if( rc!=SQLITE_ROW ){
-+ return rc;
-+ }
-+
-+ /* If a non-interior page is received, that either means that the
-+ * tree is uneven, or that a child was re-used (say as an overflow
-+ * page). Remove this cursor and let the caller handle the page.
-+ */
-+ pPageHeader = PageHeader(*ppPage);
-+ if( pPageHeader[kiPageTypeOffset]!=kTableInteriorPage ){
-+ *ppCursor = pCursor->pParent;
-+ pCursor->pParent = NULL;
-+ interiorCursorDestroy(pCursor);
-+ return SQLITE_ROW;
-+ }
-+
-+ /* Iterate the new page. */
-+ interiorCursorSetPage(pCursor, *ppPage);
-+ *ppPage = NULL;
-+ }
-+
-+ assert(NULL); /* NOTREACHED() */
-+ return SQLITE_CORRUPT;
-+}
-+
-+/* Large rows are spilled to overflow pages. The row's main page
-+ * stores the overflow page number after the local payload, with a
-+ * linked list forward from there as necessary. overflowMaybeCreate()
-+ * and overflowGetSegment() provide an abstraction for accessing such
-+ * data while centralizing the code.
-+ *
-+ * overflowDestroy - releases all resources associated with the structure.
-+ * overflowMaybeCreate - create the overflow structure if it is needed
-+ * to represent the given record. See function comment.
-+ * overflowGetSegment - fetch a segment from the record, accounting
-+ * for overflow pages. Segments which are not
-+ * entirely contained with a page are constructed
-+ * into a buffer which is returned. See function comment.
-+ */
-+typedef struct RecoverOverflow RecoverOverflow;
-+struct RecoverOverflow {
-+ RecoverOverflow *pNextOverflow;
-+ RecoverPage *pPage;
-+ unsigned nPageSize;
-+};
-+
-+static void overflowDestroy(RecoverOverflow *pOverflow){
-+ while( pOverflow ){
-+ RecoverOverflow *p = pOverflow;
-+ pOverflow = p->pNextOverflow;
-+
-+ if( p->pPage ){
-+ pageDestroy(p->pPage);
-+ p->pPage = NULL;
-+ }
-+
-+ memset(p, 0xA5, sizeof(*p));
-+ sqlite3_free(p);
-+ }
-+}
-+
-+/* Internal helper. Used to detect if iPage would cause a loop. */
-+static int overflowPageInUse(RecoverOverflow *pOverflow, unsigned iPage){
-+ while( pOverflow && pOverflow->pPage->pgno!=iPage ){
-+ pOverflow = pOverflow->pNextOverflow;
-+ }
-+ return pOverflow!=NULL;
-+}
-+
-+/* Setup to access an nRecordBytes record beginning at iRecordOffset
-+ * in pPage. If nRecordBytes can be satisfied entirely from pPage,
-+ * then no overflow pages are needed an *pnLocalRecordBytes is set to
-+ * nRecordBytes. Otherwise, *ppOverflow is set to the head of a list
-+ * of overflow pages, and *pnLocalRecordBytes is set to the number of
-+ * bytes local to pPage.
-+ *
-+ * overflowGetSegment() will do the right thing regardless of whether
-+ * those values are set to be in-page or not.
-+ */
-+static int overflowMaybeCreate(RecoverPage *pPage, unsigned nPageSize,
-+ unsigned iRecordOffset, unsigned nRecordBytes,
-+ unsigned *pnLocalRecordBytes,
-+ RecoverOverflow **ppOverflow){
-+ unsigned nLocalRecordBytes; /* Record bytes in the leaf page. */
-+ unsigned iNextPage; /* Next page number for record data. */
-+ unsigned nBytes; /* Maximum record bytes as of current page. */
-+ int rc;
-+ RecoverOverflow *pFirstOverflow; /* First in linked list of pages. */
-+ RecoverOverflow *pLastOverflow; /* End of linked list. */
-+
-+ /* Calculations from the "Table B-Tree Leaf Cell" part of section
-+ * 1.5 of http://www.sqlite.org/fileformat2.html . maxLocal and
-+ * minLocal to match naming in btree.c.
-+ */
-+ const unsigned maxLocal = nPageSize - 35;
-+ const unsigned minLocal = ((nPageSize-12)*32/255)-23; /* m */
-+
-+ /* Always fit anything smaller than maxLocal. */
-+ if( nRecordBytes<=maxLocal ){
-+ *pnLocalRecordBytes = nRecordBytes;
-+ *ppOverflow = NULL;
-+ return SQLITE_OK;
-+ }
-+
-+ /* Calculate the remainder after accounting for minLocal on the leaf
-+ * page and what packs evenly into overflow pages. If the remainder
-+ * does not fit into maxLocal, then a partially-full overflow page
-+ * will be required in any case, so store as little as possible locally.
-+ */
-+ nLocalRecordBytes = minLocal+((nRecordBytes-minLocal)%(nPageSize-4));
-+ if( maxLocal<nLocalRecordBytes ){
-+ nLocalRecordBytes = minLocal;
-+ }
-+
-+ /* Don't read off the end of the page. */
-+ if( iRecordOffset+nLocalRecordBytes+4>nPageSize ){
-+ return SQLITE_CORRUPT;
-+ }
-+
-+ /* First overflow page number is after the local bytes. */
-+ iNextPage =
-+ decodeUnsigned32(PageData(pPage, iRecordOffset + nLocalRecordBytes));
-+ nBytes = nLocalRecordBytes;
-+
-+ /* While there are more pages to read, and more bytes are needed,
-+ * get another page.
-+ */
-+ pFirstOverflow = pLastOverflow = NULL;
-+ rc = SQLITE_OK;
-+ while( iNextPage && nBytes<nRecordBytes ){
-+ RecoverOverflow *pOverflow; /* New overflow page for the list. */
-+
-+ rc = pagerGetPage(pPage->pPager, iNextPage, &pPage);
-+ if( rc!=SQLITE_OK ){
-+ break;
-+ }
-+
-+ pOverflow = sqlite3_malloc(sizeof(RecoverOverflow));
-+ if( !pOverflow ){
-+ pageDestroy(pPage);
-+ rc = SQLITE_NOMEM;
-+ break;
-+ }
-+ memset(pOverflow, 0, sizeof(*pOverflow));
-+ pOverflow->pPage = pPage;
-+ pOverflow->nPageSize = nPageSize;
-+
-+ if( !pFirstOverflow ){
-+ pFirstOverflow = pOverflow;
-+ }else{
-+ pLastOverflow->pNextOverflow = pOverflow;
-+ }
-+ pLastOverflow = pOverflow;
-+
-+ iNextPage = decodeUnsigned32(pPage->pData);
-+ nBytes += nPageSize-4;
-+
-+ /* Avoid loops. */
-+ if( overflowPageInUse(pFirstOverflow, iNextPage) ){
-+ fprintf(stderr, "Overflow loop detected at %d\n", iNextPage);
-+ rc = SQLITE_CORRUPT;
-+ break;
-+ }
-+ }
-+
-+ /* If there were not enough pages, or too many, things are corrupt.
-+ * Not having enough pages is an obvious problem, all the data
-+ * cannot be read. Too many pages means that the contents of the
-+ * row between the main page and the overflow page(s) is
-+ * inconsistent (most likely one or more of the overflow pages does
-+ * not really belong to this row).
-+ */
-+ if( rc==SQLITE_OK && (nBytes<nRecordBytes || iNextPage) ){
-+ rc = SQLITE_CORRUPT;
-+ }
-+
-+ if( rc==SQLITE_OK ){
-+ *ppOverflow = pFirstOverflow;
-+ *pnLocalRecordBytes = nLocalRecordBytes;
-+ }else if( pFirstOverflow ){
-+ overflowDestroy(pFirstOverflow);
-+ }
-+ return rc;
-+}
-+
-+/* Use in concert with overflowMaybeCreate() to efficiently read parts
-+ * of a potentially-overflowing record. pPage and iRecordOffset are
-+ * the values passed into overflowMaybeCreate(), nLocalRecordBytes and
-+ * pOverflow are the values returned by that call.
-+ *
-+ * On SQLITE_OK, *ppBase points to nRequestBytes of data at
-+ * iRequestOffset within the record. If the data exists contiguously
-+ * in a page, a direct pointer is returned, otherwise a buffer from
-+ * sqlite3_malloc() is returned with the data. *pbFree is set true if
-+ * sqlite3_free() should be called on *ppBase.
-+ */
-+/* Operation of this function is subtle. At any time, pPage is the
-+ * current page, with iRecordOffset and nLocalRecordBytes being record
-+ * data within pPage, and pOverflow being the overflow page after
-+ * pPage. This allows the code to handle both the initial leaf page
-+ * and overflow pages consistently by adjusting the values
-+ * appropriately.
-+ */
-+static int overflowGetSegment(RecoverPage *pPage, unsigned iRecordOffset,
-+ unsigned nLocalRecordBytes,
-+ RecoverOverflow *pOverflow,
-+ unsigned iRequestOffset, unsigned nRequestBytes,
-+ unsigned char **ppBase, int *pbFree){
-+ unsigned nBase; /* Amount of data currently collected. */
-+ unsigned char *pBase; /* Buffer to collect record data into. */
-+
-+ /* Skip to the page containing the start of the data. */
-+ while( iRequestOffset>=nLocalRecordBytes && pOverflow ){
-+ /* Factor out current page's contribution. */
-+ iRequestOffset -= nLocalRecordBytes;
-+
-+ /* Move forward to the next page in the list. */
-+ pPage = pOverflow->pPage;
-+ iRecordOffset = 4;
-+ nLocalRecordBytes = pOverflow->nPageSize - iRecordOffset;
-+ pOverflow = pOverflow->pNextOverflow;
-+ }
-+
-+ /* If the requested data is entirely within this page, return a
-+ * pointer into the page.
-+ */
-+ if( iRequestOffset+nRequestBytes<=nLocalRecordBytes ){
-+ /* TODO(shess): "assignment discards qualifiers from pointer target type"
-+ * Having ppBase be const makes sense, but sqlite3_free() takes non-const.
-+ */
-+ *ppBase = (unsigned char *)PageData(pPage, iRecordOffset + iRequestOffset);
-+ *pbFree = 0;
-+ return SQLITE_OK;
-+ }
-+
-+ /* The data range would require additional pages. */
-+ if( !pOverflow ){
-+ /* Should never happen, the range is outside the nRecordBytes
-+ * passed to overflowMaybeCreate().
-+ */
-+ assert(NULL); /* NOTREACHED */
-+ return SQLITE_ERROR;
-+ }
-+
-+ /* Get a buffer to construct into. */
-+ nBase = 0;
-+ pBase = sqlite3_malloc(nRequestBytes);
-+ if( !pBase ){
-+ return SQLITE_NOMEM;
-+ }
-+ while( nBase<nRequestBytes ){
-+ /* Copy over data present on this page. */
-+ unsigned nCopyBytes = nRequestBytes - nBase;
-+ if( nLocalRecordBytes-iRequestOffset<nCopyBytes ){
-+ nCopyBytes = nLocalRecordBytes - iRequestOffset;
-+ }
-+ memcpy(pBase + nBase, PageData(pPage, iRecordOffset + iRequestOffset),
-+ nCopyBytes);
-+ nBase += nCopyBytes;
-+
-+ if( pOverflow ){
-+ /* Copy from start of record data in future pages. */
-+ iRequestOffset = 0;
-+
-+ /* Move forward to the next page in the list. Should match
-+ * first while() loop.
-+ */
-+ pPage = pOverflow->pPage;
-+ iRecordOffset = 4;
-+ nLocalRecordBytes = pOverflow->nPageSize - iRecordOffset;
-+ pOverflow = pOverflow->pNextOverflow;
-+ }else if( nBase<nRequestBytes ){
-+ /* Ran out of overflow pages with data left to deliver. Not
-+ * possible if the requested range fits within nRecordBytes
-+ * passed to overflowMaybeCreate() when creating pOverflow.
-+ */
-+ assert(NULL); /* NOTREACHED */
-+ sqlite3_free(pBase);
-+ return SQLITE_ERROR;
-+ }
-+ }
-+ assert( nBase==nRequestBytes );
-+ *ppBase = pBase;
-+ *pbFree = 1;
-+ return SQLITE_OK;
-+}
-+
-+/* Primary structure for iterating the contents of a table.
-+ *
-+ * leafCursorDestroy - release all resources associated with the cursor.
-+ * leafCursorCreate - create a cursor to iterate items from tree at
-+ * the provided root page.
-+ * leafCursorNextValidCell - get the cursor ready to access data from
-+ * the next valid cell in the table.
-+ * leafCursorCellRowid - get the current cell's rowid.
-+ * leafCursorCellColumns - get current cell's column count.
-+ * leafCursorCellColInfo - get type and data for a column in current cell.
-+ *
-+ * leafCursorNextValidCell skips cells which fail simple integrity
-+ * checks, such as overlapping other cells, or being located at
-+ * impossible offsets, or where header data doesn't correctly describe
-+ * payload data. Returns SQLITE_ROW if a valid cell is found,
-+ * SQLITE_DONE if all pages in the tree were exhausted.
-+ *
-+ * leafCursorCellColInfo() accounts for overflow pages in the style of
-+ * overflowGetSegment().
-+ */
-+typedef struct RecoverLeafCursor RecoverLeafCursor;
-+struct RecoverLeafCursor {
-+ RecoverInteriorCursor *pParent; /* Parent node to this node. */
-+ RecoverPager *pPager; /* Page provider. */
-+ RecoverPage *pPage; /* Current leaf page. */
-+ unsigned nPageSize; /* Size of pPage. */
-+ unsigned nCells; /* Number of cells in pPage. */
-+ unsigned iCell; /* Current cell. */
-+
-+ /* Info parsed from data in iCell. */
-+ i64 iRowid; /* rowid parsed. */
-+ unsigned nRecordCols; /* how many items in the record. */
-+ u64 iRecordOffset; /* offset to record data. */
-+ /* TODO(shess): nRecordBytes and nRecordHeaderBytes are used in
-+ * leafCursorCellColInfo() to prevent buffer overruns.
-+ * leafCursorCellDecode() already verified that the cell is valid, so
-+ * those checks should be redundant.
-+ */
-+ u64 nRecordBytes; /* Size of record data. */
-+ unsigned nLocalRecordBytes; /* Amount of record data in-page. */
-+ unsigned nRecordHeaderBytes; /* Size of record header data. */
-+ unsigned char *pRecordHeader; /* Pointer to record header data. */
-+ int bFreeRecordHeader; /* True if record header requires free. */
-+ RecoverOverflow *pOverflow; /* Cell overflow info, if needed. */
-+};
-+
-+/* Internal helper shared between next-page and create-cursor. If
-+ * pPage is a leaf page, it will be stored in the cursor and state
-+ * initialized for reading cells.
-+ *
-+ * If pPage is an interior page, a new parent cursor is created and
-+ * injected on the stack. This is necessary to handle trees with
-+ * uneven depth, but also is used during initial setup.
-+ *
-+ * If pPage is not a table page at all, it is discarded.
-+ *
-+ * If SQLITE_OK is returned, the caller no longer owns pPage,
-+ * otherwise the caller is responsible for discarding it.
-+ */
-+static int leafCursorLoadPage(RecoverLeafCursor *pCursor, RecoverPage *pPage){
-+ const unsigned char *pPageHeader; /* Header of *pPage */
-+ unsigned nCells; /* Number of cells in the page */
-+
-+ /* Release the current page. */
-+ if( pCursor->pPage ){
-+ pageDestroy(pCursor->pPage);
-+ pCursor->pPage = NULL;
-+ pCursor->iCell = pCursor->nCells = 0;
-+ }
-+
-+ /* If the page is an unexpected interior node, inject a new stack
-+ * layer and try again from there.
-+ */
-+ pPageHeader = PageHeader(pPage);
-+ if( pPageHeader[kiPageTypeOffset]==kTableInteriorPage ){
-+ RecoverInteriorCursor *pParent;
-+ int rc = interiorCursorCreate(pCursor->pParent, pPage, pCursor->nPageSize,
-+ &pParent);
-+ if( rc!=SQLITE_OK ){
-+ return rc;
-+ }
-+ pCursor->pParent = pParent;
-+ return SQLITE_OK;
-+ }
-+
-+ /* Not a leaf page, skip it. */
-+ if( pPageHeader[kiPageTypeOffset]!=kTableLeafPage ){
-+ pageDestroy(pPage);
-+ return SQLITE_OK;
-+ }
-+
-+ /* Leaf contains no data, skip it. Empty tables, for instance. */
-+ nCells = decodeUnsigned16(pPageHeader + kiPageCellCountOffset);;
-+ if( nCells<1 ){
-+ pageDestroy(pPage);
-+ return SQLITE_OK;
-+ }
-+
-+ /* Take ownership of the page and start decoding. */
-+ pCursor->pPage = pPage;
-+ pCursor->iCell = 0;
-+ pCursor->nCells = nCells;
-+ return SQLITE_OK;
-+}
-+
-+/* Get the next leaf-level page in the tree. Returns SQLITE_ROW when
-+ * a leaf page is found, SQLITE_DONE when no more leaves exist, or any
-+ * error which occurred.
-+ */
-+static int leafCursorNextPage(RecoverLeafCursor *pCursor){
-+ if( !pCursor->pParent ){
-+ return SQLITE_DONE;
-+ }
-+
-+ /* Repeatedly load the parent's next child page until a leaf is found. */
-+ do {
-+ RecoverPage *pNextPage;
-+ int rc = interiorCursorNextPage(&pCursor->pParent, &pNextPage);
-+ if( rc!=SQLITE_ROW ){
-+ assert( rc==SQLITE_DONE );
-+ return rc;
-+ }
-+
-+ rc = leafCursorLoadPage(pCursor, pNextPage);
-+ if( rc!=SQLITE_OK ){
-+ pageDestroy(pNextPage);
-+ return rc;
-+ }
-+ } while( !pCursor->pPage );
-+
-+ return SQLITE_ROW;
-+}
-+
-+static void leafCursorDestroyCellData(RecoverLeafCursor *pCursor){
-+ if( pCursor->bFreeRecordHeader ){
-+ sqlite3_free(pCursor->pRecordHeader);
-+ }
-+ pCursor->bFreeRecordHeader = 0;
-+ pCursor->pRecordHeader = NULL;
-+
-+ if( pCursor->pOverflow ){
-+ overflowDestroy(pCursor->pOverflow);
-+ pCursor->pOverflow = NULL;
-+ }
-+}
-+
-+static void leafCursorDestroy(RecoverLeafCursor *pCursor){
-+ leafCursorDestroyCellData(pCursor);
-+
-+ if( pCursor->pParent ){
-+ interiorCursorDestroy(pCursor->pParent);
-+ pCursor->pParent = NULL;
-+ }
-+
-+ if( pCursor->pPage ){
-+ pageDestroy(pCursor->pPage);
-+ pCursor->pPage = NULL;
-+ }
-+
-+ if( pCursor->pPager ){
-+ pagerDestroy(pCursor->pPager);
-+ pCursor->pPager = NULL;
-+ }
-+
-+ memset(pCursor, 0xA5, sizeof(*pCursor));
-+ sqlite3_free(pCursor);
-+}
-+
-+/* Create a cursor to iterate the rows from the leaf pages of a table
-+ * rooted at iRootPage.
-+ */
-+/* TODO(shess): recoverOpen() calls this to setup the cursor, and I
-+ * think that recoverFilter() may make a hard assumption that the
-+ * cursor returned will turn up at least one valid cell.
-+ *
-+ * The cases I can think of which break this assumption are:
-+ * - pPage is a valid leaf page with no valid cells.
-+ * - pPage is a valid interior page with no valid leaves.
-+ * - pPage is a valid interior page who's leaves contain no valid cells.
-+ * - pPage is not a valid leaf or interior page.
-+ */
-+static int leafCursorCreate(RecoverPager *pPager, unsigned nPageSize,
-+ u32 iRootPage, RecoverLeafCursor **ppCursor){
-+ RecoverPage *pPage; /* Reference to page at iRootPage. */
-+ RecoverLeafCursor *pCursor; /* Leaf cursor being constructed. */
-+ int rc;
-+
-+ /* Start out with the root page. */
-+ rc = pagerGetPage(pPager, iRootPage, &pPage);
-+ if( rc!=SQLITE_OK ){
-+ return rc;
-+ }
-+
-+ pCursor = sqlite3_malloc(sizeof(RecoverLeafCursor));
-+ if( !pCursor ){
-+ pageDestroy(pPage);
-+ return SQLITE_NOMEM;
-+ }
-+ memset(pCursor, 0, sizeof(*pCursor));
-+
-+ pCursor->nPageSize = nPageSize;
-+ pCursor->pPager = pPager;
-+
-+ rc = leafCursorLoadPage(pCursor, pPage);
-+ if( rc!=SQLITE_OK ){
-+ pageDestroy(pPage);
-+ leafCursorDestroy(pCursor);
-+ return rc;
-+ }
-+
-+ /* pPage wasn't a leaf page, find the next leaf page. */
-+ if( !pCursor->pPage ){
-+ rc = leafCursorNextPage(pCursor);
-+ if( rc!=SQLITE_DONE && rc!=SQLITE_ROW ){
-+ leafCursorDestroy(pCursor);
-+ return rc;
-+ }
-+ }
-+
-+ *ppCursor = pCursor;
-+ return SQLITE_OK;
-+}
-+
-+/* Useful for setting breakpoints. */
-+static int ValidateError(){
-+ return SQLITE_ERROR;
-+}
-+
-+/* Setup the cursor for reading the information from cell iCell. */
-+static int leafCursorCellDecode(RecoverLeafCursor *pCursor){
-+ const unsigned char *pPageHeader; /* Header of current page. */
-+ const unsigned char *pPageEnd; /* Byte after end of current page. */
-+ const unsigned char *pCellOffsets; /* Pointer to page's cell offsets. */
-+ unsigned iCellOffset; /* Offset of current cell (iCell). */
-+ const unsigned char *pCell; /* Pointer to data at iCellOffset. */
-+ unsigned nCellMaxBytes; /* Maximum local size of iCell. */
-+ unsigned iEndOffset; /* End of iCell's in-page data. */
-+ u64 nRecordBytes; /* Expected size of cell, w/overflow. */
-+ u64 iRowid; /* iCell's rowid (in table). */
-+ unsigned nRead; /* Amount of cell read. */
-+ unsigned nRecordHeaderRead; /* Header data read. */
-+ u64 nRecordHeaderBytes; /* Header size expected. */
-+ unsigned nRecordCols; /* Columns read from header. */
-+ u64 nRecordColBytes; /* Bytes in payload for those columns. */
-+ unsigned i;
-+ int rc;
-+
-+ assert( pCursor->iCell<pCursor->nCells );
-+
-+ leafCursorDestroyCellData(pCursor);
-+
-+ /* Find the offset to the row. */
-+ pPageHeader = PageHeader(pCursor->pPage);
-+ pCellOffsets = pPageHeader + knPageLeafHeaderBytes;
-+ pPageEnd = PageData(pCursor->pPage, pCursor->nPageSize);
-+ if( pCellOffsets + pCursor->iCell*2 + 2 > pPageEnd ){
-+ return ValidateError();
-+ }
-+ iCellOffset = decodeUnsigned16(pCellOffsets + pCursor->iCell*2);
-+ if( iCellOffset>=pCursor->nPageSize ){
-+ return ValidateError();
-+ }
-+
-+ pCell = PageData(pCursor->pPage, iCellOffset);
-+ nCellMaxBytes = pCursor->nPageSize - iCellOffset;
-+
-+ /* B-tree leaf cells lead with varint record size, varint rowid and
-+ * varint header size.
-+ */
-+ /* TODO(shess): The smallest page size is 512 bytes, which has an m
-+ * of 39. Three varints need at most 27 bytes to encode. I think.
-+ */
-+ if( !checkVarints(pCell, nCellMaxBytes, 3) ){
-+ return ValidateError();
-+ }
-+
-+ nRead = recoverGetVarint(pCell, &nRecordBytes);
-+ assert( iCellOffset+nRead<=pCursor->nPageSize );
-+ pCursor->nRecordBytes = nRecordBytes;
-+
-+ nRead += recoverGetVarint(pCell + nRead, &iRowid);
-+ assert( iCellOffset+nRead<=pCursor->nPageSize );
-+ pCursor->iRowid = (i64)iRowid;
-+
-+ pCursor->iRecordOffset = iCellOffset + nRead;
-+
-+ /* Start overflow setup here because nLocalRecordBytes is needed to
-+ * check cell overlap.
-+ */
-+ rc = overflowMaybeCreate(pCursor->pPage, pCursor->nPageSize,
-+ pCursor->iRecordOffset, pCursor->nRecordBytes,
-+ &pCursor->nLocalRecordBytes,
-+ &pCursor->pOverflow);
-+ if( rc!=SQLITE_OK ){
-+ return ValidateError();
-+ }
-+
-+ /* Check that no other cell starts within this cell. */
-+ iEndOffset = pCursor->iRecordOffset + pCursor->nLocalRecordBytes;
-+ for( i=0; i<pCursor->nCells && pCellOffsets + i*2 + 2 <= pPageEnd; ++i ){
-+ const unsigned iOtherOffset = decodeUnsigned16(pCellOffsets + i*2);
-+ if( iOtherOffset>iCellOffset && iOtherOffset<iEndOffset ){
-+ return ValidateError();
-+ }
-+ }
-+
-+ nRecordHeaderRead = recoverGetVarint(pCell + nRead, &nRecordHeaderBytes);
-+ assert( nRecordHeaderBytes<=nRecordBytes );
-+ pCursor->nRecordHeaderBytes = nRecordHeaderBytes;
-+
-+ /* Large headers could overflow if pages are small. */
-+ rc = overflowGetSegment(pCursor->pPage,
-+ pCursor->iRecordOffset, pCursor->nLocalRecordBytes,
-+ pCursor->pOverflow, 0, nRecordHeaderBytes,
-+ &pCursor->pRecordHeader, &pCursor->bFreeRecordHeader);
-+ if( rc!=SQLITE_OK ){
-+ return ValidateError();
-+ }
-+
-+ /* Tally up the column count and size of data. */
-+ nRecordCols = 0;
-+ nRecordColBytes = 0;
-+ while( nRecordHeaderRead<nRecordHeaderBytes ){
-+ u64 iSerialType; /* Type descriptor for current column. */
-+ if( !checkVarint(pCursor->pRecordHeader + nRecordHeaderRead,
-+ nRecordHeaderBytes - nRecordHeaderRead) ){
-+ return ValidateError();
-+ }
-+ nRecordHeaderRead += recoverGetVarint(
-+ pCursor->pRecordHeader + nRecordHeaderRead, &iSerialType);
-+ if( iSerialType==10 || iSerialType==11 ){
-+ return ValidateError();
-+ }
-+ nRecordColBytes += SerialTypeLength(iSerialType);
-+ nRecordCols++;
-+ }
-+ pCursor->nRecordCols = nRecordCols;
-+
-+ /* Parsing the header used as many bytes as expected. */
-+ if( nRecordHeaderRead!=nRecordHeaderBytes ){
-+ return ValidateError();
-+ }
-+
-+ /* Calculated record is size of expected record. */
-+ if( nRecordHeaderBytes+nRecordColBytes!=nRecordBytes ){
-+ return ValidateError();
-+ }
-+
-+ return SQLITE_OK;
-+}
-+
-+static i64 leafCursorCellRowid(RecoverLeafCursor *pCursor){
-+ return pCursor->iRowid;
-+}
-+
-+static unsigned leafCursorCellColumns(RecoverLeafCursor *pCursor){
-+ return pCursor->nRecordCols;
-+}
-+
-+/* Get the column info for the cell. Pass NULL for ppBase to prevent
-+ * retrieving the data segment. If *pbFree is true, *ppBase must be
-+ * freed by the caller using sqlite3_free().
-+ */
-+static int leafCursorCellColInfo(RecoverLeafCursor *pCursor,
-+ unsigned iCol, u64 *piColType,
-+ unsigned char **ppBase, int *pbFree){
-+ const unsigned char *pRecordHeader; /* Current cell's header. */
-+ u64 nRecordHeaderBytes; /* Bytes in pRecordHeader. */
-+ unsigned nRead; /* Bytes read from header. */
-+ u64 iColEndOffset; /* Offset to end of column in cell. */
-+ unsigned nColsSkipped; /* Count columns as procesed. */
-+ u64 iSerialType; /* Type descriptor for current column. */
-+
-+ /* Implicit NULL for columns past the end. This case happens when
-+ * rows have not been updated since an ALTER TABLE added columns.
-+ * It is more convenient to address here than in callers.
-+ */
-+ if( iCol>=pCursor->nRecordCols ){
-+ *piColType = 0;
-+ if( ppBase ){
-+ *ppBase = 0;
-+ *pbFree = 0;
-+ }
-+ return SQLITE_OK;
-+ }
-+
-+ /* Must be able to decode header size. */
-+ pRecordHeader = pCursor->pRecordHeader;
-+ if( !checkVarint(pRecordHeader, pCursor->nRecordHeaderBytes) ){
-+ return SQLITE_CORRUPT;
-+ }
-+
-+ /* Rather than caching the header size and how many bytes it took,
-+ * decode it every time.
-+ */
-+ nRead = recoverGetVarint(pRecordHeader, &nRecordHeaderBytes);
-+ assert( nRecordHeaderBytes==pCursor->nRecordHeaderBytes );
-+
-+ /* Scan forward to the indicated column. Scans to _after_ column
-+ * for later range checking.
-+ */
-+ /* TODO(shess): This could get expensive for very wide tables. An
-+ * array of iSerialType could be built in leafCursorCellDecode(), but
-+ * the number of columns is dynamic per row, so it would add memory
-+ * management complexity. Enough info to efficiently forward
-+ * iterate could be kept, if all clients forward iterate
-+ * (recoverColumn() may not).
-+ */
-+ iColEndOffset = 0;
-+ nColsSkipped = 0;
-+ while( nColsSkipped<=iCol && nRead<nRecordHeaderBytes ){
-+ if( !checkVarint(pRecordHeader + nRead, nRecordHeaderBytes - nRead) ){
-+ return SQLITE_CORRUPT;
-+ }
-+ nRead += recoverGetVarint(pRecordHeader + nRead, &iSerialType);
-+ iColEndOffset += SerialTypeLength(iSerialType);
-+ nColsSkipped++;
-+ }
-+
-+ /* Column's data extends past record's end. */
-+ if( nRecordHeaderBytes+iColEndOffset>pCursor->nRecordBytes ){
-+ return SQLITE_CORRUPT;
-+ }
-+
-+ *piColType = iSerialType;
-+ if( ppBase ){
-+ const u32 nColBytes = SerialTypeLength(iSerialType);
-+
-+ /* Offset from start of record to beginning of column. */
-+ const unsigned iColOffset = nRecordHeaderBytes+iColEndOffset-nColBytes;
-+
-+ return overflowGetSegment(pCursor->pPage, pCursor->iRecordOffset,
-+ pCursor->nLocalRecordBytes, pCursor->pOverflow,
-+ iColOffset, nColBytes, ppBase, pbFree);
-+ }
-+ return SQLITE_OK;
-+}
-+
-+static int leafCursorNextValidCell(RecoverLeafCursor *pCursor){
-+ while( 1 ){
-+ int rc;
-+
-+ /* Move to the next cell. */
-+ pCursor->iCell++;
-+
-+ /* No more cells, get the next leaf. */
-+ if( pCursor->iCell>=pCursor->nCells ){
-+ rc = leafCursorNextPage(pCursor);
-+ if( rc!=SQLITE_ROW ){
-+ return rc;
-+ }
-+ assert( pCursor->iCell==0 );
-+ }
-+
-+ /* If the cell is valid, indicate that a row is available. */
-+ rc = leafCursorCellDecode(pCursor);
-+ if( rc==SQLITE_OK ){
-+ return SQLITE_ROW;
-+ }
-+
-+ /* Iterate until done or a valid row is found. */
-+ /* TODO(shess): Remove debugging output. */
-+ fprintf(stderr, "Skipping invalid cell\n");
-+ }
-+ return SQLITE_ERROR;
-+}
-+
-+typedef struct Recover Recover;
-+struct Recover {
-+ sqlite3_vtab base;
-+ sqlite3 *db; /* Host database connection */
-+ char *zDb; /* Database containing target table */
-+ char *zTable; /* Target table */
-+ unsigned nCols; /* Number of columns in target table */
-+ unsigned char *pTypes; /* Types of columns in target table */
-+};
-+
-+/* Internal helper for deleting the module. */
-+static void recoverRelease(Recover *pRecover){
-+ sqlite3_free(pRecover->zDb);
-+ sqlite3_free(pRecover->zTable);
-+ sqlite3_free(pRecover->pTypes);
-+ memset(pRecover, 0xA5, sizeof(*pRecover));
-+ sqlite3_free(pRecover);
-+}
-+
-+/* Helper function for initializing the module. Forward-declared so
-+ * recoverCreate() and recoverConnect() can see it.
-+ */
-+static int recoverInit(
-+ sqlite3 *, void *, int, const char *const*, sqlite3_vtab **, char **
-+);
-+
-+static int recoverCreate(
-+ sqlite3 *db,
-+ void *pAux,
-+ int argc, const char *const*argv,
-+ sqlite3_vtab **ppVtab,
-+ char **pzErr
-+){
-+ FNENTRY();
-+ return recoverInit(db, pAux, argc, argv, ppVtab, pzErr);
-+}
-+
-+/* This should never be called. */
-+static int recoverConnect(
-+ sqlite3 *db,
-+ void *pAux,
-+ int argc, const char *const*argv,
-+ sqlite3_vtab **ppVtab,
-+ char **pzErr
-+){
-+ FNENTRY();
-+ return recoverInit(db, pAux, argc, argv, ppVtab, pzErr);
-+}
-+
-+/* No indices supported. */
-+static int recoverBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){
-+ FNENTRY();
-+ return SQLITE_OK;
-+}
-+
-+/* Logically, this should never be called. */
-+static int recoverDisconnect(sqlite3_vtab *pVtab){
-+ FNENTRY();
-+ recoverRelease((Recover*)pVtab);
-+ return SQLITE_OK;
-+}
-+
-+static int recoverDestroy(sqlite3_vtab *pVtab){
-+ FNENTRY();
-+ recoverRelease((Recover*)pVtab);
-+ return SQLITE_OK;
-+}
-+
-+typedef struct RecoverCursor RecoverCursor;
-+struct RecoverCursor {
-+ sqlite3_vtab_cursor base;
-+ RecoverLeafCursor *pLeafCursor;
-+ int iEncoding;
-+ int bEOF;
-+};
-+
-+static int recoverOpen(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){
-+ Recover *pRecover = (Recover*)pVTab;
-+ u32 iRootPage; /* Root page of the backing table. */
-+ int iEncoding; /* UTF encoding for backing database. */
-+ unsigned nPageSize; /* Size of pages in backing database. */
-+ RecoverPager *pPager; /* Backing database pager. */
-+ RecoverLeafCursor *pLeafCursor; /* Cursor to read table's leaf pages. */
-+ RecoverCursor *pCursor; /* Cursor to read rows from leaves. */
-+ int rc;
-+
-+ FNENTRY();
-+
-+ iRootPage = 0;
-+ rc = getRootPage(pRecover->db, pRecover->zDb, pRecover->zTable,
-+ &iRootPage);
-+ if( rc!=SQLITE_OK ){
-+ return rc;
-+ }
-+
-+ rc = GetPager(pRecover->db, pRecover->zDb, &pPager, &nPageSize, &iEncoding);
-+ if( rc!=SQLITE_OK ){
-+ return rc;
-+ }
-+
-+ rc = leafCursorCreate(pPager, nPageSize, iRootPage, &pLeafCursor);
-+ if( rc!=SQLITE_OK ){
-+ pagerDestroy(pPager);
-+ return rc;
-+ }
-+
-+ pCursor = sqlite3_malloc(sizeof(RecoverCursor));
-+ if( !pCursor ){
-+ leafCursorDestroy(pLeafCursor);
-+ return SQLITE_NOMEM;
-+ }
-+ memset(pCursor, 0, sizeof(*pCursor));
-+ pCursor->base.pVtab = pVTab;
-+ pCursor->pLeafCursor = pLeafCursor;
-+ pCursor->iEncoding = iEncoding;
-+
-+ /* If no leaf pages were found, empty result set. */
-+ /* TODO(shess): leafCursorNextValidCell() would return SQLITE_ROW or
-+ * SQLITE_DONE to indicate whether there is further data to consider.
-+ */
-+ pCursor->bEOF = (pLeafCursor->pPage==NULL);
-+
-+ *ppCursor = (sqlite3_vtab_cursor*)pCursor;
-+ return SQLITE_OK;
-+}
-+
-+static int recoverClose(sqlite3_vtab_cursor *cur){
-+ RecoverCursor *pCursor = (RecoverCursor*)cur;
-+ FNENTRY();
-+ if( pCursor->pLeafCursor ){
-+ leafCursorDestroy(pCursor->pLeafCursor);
-+ pCursor->pLeafCursor = NULL;
-+ }
-+ memset(pCursor, 0xA5, sizeof(*pCursor));
-+ sqlite3_free(cur);
-+ return SQLITE_OK;
-+}
-+
-+/* Helpful place to set a breakpoint. */
-+static int RecoverInvalidCell(){
-+ return SQLITE_ERROR;
-+}
-+
-+/* Returns SQLITE_OK if the cell has an appropriate number of columns
-+ * with the appropriate types of data.
-+ */
-+static int recoverValidateLeafCell(Recover *pRecover, RecoverCursor *pCursor){
-+ unsigned i;
-+
-+ /* If the row's storage has too many columns, skip it. */
-+ if( leafCursorCellColumns(pCursor->pLeafCursor)>pRecover->nCols ){
-+ return RecoverInvalidCell();
-+ }
-+
-+ /* Skip rows with unexpected types. */
-+ for( i=0; i<pRecover->nCols; ++i ){
-+ u64 iType; /* Storage type of column i. */
-+ int rc;
-+
-+ /* ROWID alias. */
-+ if( (pRecover->pTypes[i]&MASK_ROWID) ){
-+ continue;
-+ }
-+
-+ rc = leafCursorCellColInfo(pCursor->pLeafCursor, i, &iType, NULL, NULL);
-+ assert( rc==SQLITE_OK );
-+ if( rc!=SQLITE_OK || !SerialTypeIsCompatible(iType, pRecover->pTypes[i]) ){
-+ return RecoverInvalidCell();
-+ }
-+ }
-+
-+ return SQLITE_OK;
-+}
-+
-+static int recoverNext(sqlite3_vtab_cursor *pVtabCursor){
-+ RecoverCursor *pCursor = (RecoverCursor*)pVtabCursor;
-+ Recover *pRecover = (Recover*)pCursor->base.pVtab;
-+ int rc;
-+
-+ FNENTRY();
-+
-+ /* Scan forward to the next cell with valid storage, then check that
-+ * the stored data matches the schema.
-+ */
-+ while( (rc = leafCursorNextValidCell(pCursor->pLeafCursor))==SQLITE_ROW ){
-+ if( recoverValidateLeafCell(pRecover, pCursor)==SQLITE_OK ){
-+ return SQLITE_OK;
-+ }
-+ }
-+
-+ if( rc==SQLITE_DONE ){
-+ pCursor->bEOF = 1;
-+ return SQLITE_OK;
-+ }
-+
-+ assert( rc!=SQLITE_OK );
-+ return rc;
-+}
-+
-+static int recoverFilter(
-+ sqlite3_vtab_cursor *pVtabCursor,
-+ int idxNum, const char *idxStr,
-+ int argc, sqlite3_value **argv
-+){
-+ RecoverCursor *pCursor = (RecoverCursor*)pVtabCursor;
-+ Recover *pRecover = (Recover*)pCursor->base.pVtab;
-+ int rc;
-+
-+ FNENTRY();
-+
-+ /* There were no valid leaf pages in the table. */
-+ if( pCursor->bEOF ){
-+ return SQLITE_OK;
-+ }
-+
-+ /* Load the first cell, and iterate forward if it's not valid. If no cells at
-+ * all are valid, recoverNext() sets bEOF and returns appropriately.
-+ */
-+ rc = leafCursorCellDecode(pCursor->pLeafCursor);
-+ if( rc!=SQLITE_OK || recoverValidateLeafCell(pRecover, pCursor)!=SQLITE_OK ){
-+ return recoverNext(pVtabCursor);
-+ }
-+
-+ return SQLITE_OK;
-+}
-+
-+static int recoverEof(sqlite3_vtab_cursor *pVtabCursor){
-+ RecoverCursor *pCursor = (RecoverCursor*)pVtabCursor;
-+ FNENTRY();
-+ return pCursor->bEOF;
-+}
-+
-+static int recoverColumn(sqlite3_vtab_cursor *cur, sqlite3_context *ctx, int i){
-+ RecoverCursor *pCursor = (RecoverCursor*)cur;
-+ Recover *pRecover = (Recover*)pCursor->base.pVtab;
-+ u64 iColType; /* Storage type of column i. */
-+ unsigned char *pColData; /* Column i's data. */
-+ int shouldFree; /* Non-zero if pColData should be freed. */
-+ int rc;
-+
-+ FNENTRY();
-+
-+ if( (unsigned)i>=pRecover->nCols ){
-+ return SQLITE_ERROR;
-+ }
-+
-+ /* ROWID alias. */
-+ if( (pRecover->pTypes[i]&MASK_ROWID) ){
-+ sqlite3_result_int64(ctx, leafCursorCellRowid(pCursor->pLeafCursor));
-+ return SQLITE_OK;
-+ }
-+
-+ pColData = NULL;
-+ shouldFree = 0;
-+ rc = leafCursorCellColInfo(pCursor->pLeafCursor, i, &iColType,
-+ &pColData, &shouldFree);
-+ if( rc!=SQLITE_OK ){
-+ return rc;
-+ }
-+ /* recoverValidateLeafCell() should guarantee that this will never
-+ * occur.
-+ */
-+ if( !SerialTypeIsCompatible(iColType, pRecover->pTypes[i]) ){
-+ if( shouldFree ){
-+ sqlite3_free(pColData);
-+ }
-+ return SQLITE_ERROR;
-+ }
-+
-+ switch( iColType ){
-+ case 0 : sqlite3_result_null(ctx); break;
-+ case 1 : sqlite3_result_int64(ctx, decodeSigned(pColData, 1)); break;
-+ case 2 : sqlite3_result_int64(ctx, decodeSigned(pColData, 2)); break;
-+ case 3 : sqlite3_result_int64(ctx, decodeSigned(pColData, 3)); break;
-+ case 4 : sqlite3_result_int64(ctx, decodeSigned(pColData, 4)); break;
-+ case 5 : sqlite3_result_int64(ctx, decodeSigned(pColData, 6)); break;
-+ case 6 : sqlite3_result_int64(ctx, decodeSigned(pColData, 8)); break;
-+ case 7 : sqlite3_result_double(ctx, decodeFloat64(pColData)); break;
-+ case 8 : sqlite3_result_int(ctx, 0); break;
-+ case 9 : sqlite3_result_int(ctx, 1); break;
-+ case 10 : assert( iColType!=10 ); break;
-+ case 11 : assert( iColType!=11 ); break;
-+
-+ default : {
-+ u32 l = SerialTypeLength(iColType);
-+
-+ /* If pColData was already allocated, arrange to pass ownership. */
-+ sqlite3_destructor_type pFn = SQLITE_TRANSIENT;
-+ if( shouldFree ){
-+ pFn = sqlite3_free;
-+ shouldFree = 0;
-+ }
-+
-+ if( SerialTypeIsBlob(iColType) ){
-+ sqlite3_result_blob(ctx, pColData, l, pFn);
-+ }else{
-+ if( pCursor->iEncoding==SQLITE_UTF16LE ){
-+ sqlite3_result_text16le(ctx, (const void*)pColData, l, pFn);
-+ }else if( pCursor->iEncoding==SQLITE_UTF16BE ){
-+ sqlite3_result_text16be(ctx, (const void*)pColData, l, pFn);
-+ }else{
-+ sqlite3_result_text(ctx, (const char*)pColData, l, pFn);
-+ }
-+ }
-+ } break;
-+ }
-+ if( shouldFree ){
-+ sqlite3_free(pColData);
-+ }
-+ return SQLITE_OK;
-+}
-+
-+static int recoverRowid(sqlite3_vtab_cursor *pVtabCursor, sqlite_int64 *pRowid){
-+ RecoverCursor *pCursor = (RecoverCursor*)pVtabCursor;
-+ FNENTRY();
-+ *pRowid = leafCursorCellRowid(pCursor->pLeafCursor);
-+ return SQLITE_OK;
-+}
-+
-+static sqlite3_module recoverModule = {
-+ 0, /* iVersion */
-+ recoverCreate, /* xCreate - create a table */
-+ recoverConnect, /* xConnect - connect to an existing table */
-+ recoverBestIndex, /* xBestIndex - Determine search strategy */
-+ recoverDisconnect, /* xDisconnect - Disconnect from a table */
-+ recoverDestroy, /* xDestroy - Drop a table */
-+ recoverOpen, /* xOpen - open a cursor */
-+ recoverClose, /* xClose - close a cursor */
-+ recoverFilter, /* xFilter - configure scan constraints */
-+ recoverNext, /* xNext - advance a cursor */
-+ recoverEof, /* xEof */
-+ recoverColumn, /* xColumn - read data */
-+ recoverRowid, /* xRowid - read data */
-+ 0, /* xUpdate - write data */
-+ 0, /* xBegin - begin transaction */
-+ 0, /* xSync - sync transaction */
-+ 0, /* xCommit - commit transaction */
-+ 0, /* xRollback - rollback transaction */
-+ 0, /* xFindFunction - function overloading */
-+ 0, /* xRename - rename the table */
-+};
-+
-+SQLITE_API
-+int chrome_sqlite3_recoverVtableInit(sqlite3 *db){
-+ return sqlite3_create_module_v2(db, "recover", &recoverModule, NULL, 0);
-+}
-+
-+/* This section of code is for parsing the create input and
-+ * initializing the module.
-+ */
-+
-+/* Find the next word in zText and place the endpoints in pzWord*.
-+ * Returns true if the word is non-empty. "Word" is defined as
-+ * ASCII alphanumeric plus '_' at this time.
-+ */
-+static int findWord(const char *zText,
-+ const char **pzWordStart, const char **pzWordEnd){
-+ int r;
-+ while( ascii_isspace(*zText) ){
-+ zText++;
-+ }
-+ *pzWordStart = zText;
-+ while( ascii_isalnum(*zText) || *zText=='_' ){
-+ zText++;
-+ }
-+ r = zText>*pzWordStart; /* In case pzWordStart==pzWordEnd */
-+ *pzWordEnd = zText;
-+ return r;
-+}
-+
-+/* Return true if the next word in zText is zWord, also setting
-+ * *pzContinue to the character after the word.
-+ */
-+static int expectWord(const char *zText, const char *zWord,
-+ const char **pzContinue){
-+ const char *zWordStart, *zWordEnd;
-+ if( findWord(zText, &zWordStart, &zWordEnd) &&
-+ ascii_strncasecmp(zWord, zWordStart, zWordEnd - zWordStart)==0 ){
-+ *pzContinue = zWordEnd;
-+ return 1;
-+ }
-+ return 0;
-+}
-+
-+/* Parse the name and type information out of parameter. In case of
-+ * success, *pzNameStart/End contain the name of the column,
-+ * *pzTypeStart/End contain the top-level type, and *pTypeMask has the
-+ * type mask to use for the column.
-+ */
-+static int findNameAndType(const char *parameter,
-+ const char **pzNameStart, const char **pzNameEnd,
-+ const char **pzTypeStart, const char **pzTypeEnd,
-+ unsigned char *pTypeMask){
-+ unsigned nNameLen; /* Length of found name. */
-+ const char *zEnd; /* Current end of parsed column information. */
-+ int bNotNull; /* Non-zero if NULL is not allowed for name. */
-+ int bStrict; /* Non-zero if column requires exact type match. */
-+ const char *zDummy; /* Dummy parameter, result unused. */
-+ unsigned i;
-+
-+ /* strictMask is used for STRICT, strictMask|otherMask if STRICT is
-+ * not supplied. zReplace provides an alternate type to expose to
-+ * the caller.
-+ */
-+ static struct {
-+ const char *zName;
-+ unsigned char strictMask;
-+ unsigned char otherMask;
-+ const char *zReplace;
-+ } kTypeInfo[] = {
-+ { "ANY",
-+ MASK_INTEGER | MASK_FLOAT | MASK_BLOB | MASK_TEXT | MASK_NULL,
-+ 0, "",
-+ },
-+ { "ROWID", MASK_INTEGER | MASK_ROWID, 0, "INTEGER", },
-+ { "INTEGER", MASK_INTEGER | MASK_NULL, 0, NULL, },
-+ { "FLOAT", MASK_FLOAT | MASK_NULL, MASK_INTEGER, NULL, },
-+ { "NUMERIC", MASK_INTEGER | MASK_FLOAT | MASK_NULL, MASK_TEXT, NULL, },
-+ { "TEXT", MASK_TEXT | MASK_NULL, MASK_BLOB, NULL, },
-+ { "BLOB", MASK_BLOB | MASK_NULL, 0, NULL, },
-+ };
-+
-+ if( !findWord(parameter, pzNameStart, pzNameEnd) ){
-+ return SQLITE_MISUSE;
-+ }
-+
-+ /* Manifest typing, accept any storage type. */
-+ if( !findWord(*pzNameEnd, pzTypeStart, pzTypeEnd) ){
-+ *pzTypeEnd = *pzTypeStart = "";
-+ *pTypeMask = MASK_INTEGER | MASK_FLOAT | MASK_BLOB | MASK_TEXT | MASK_NULL;
-+ return SQLITE_OK;
-+ }
-+
-+ nNameLen = *pzTypeEnd - *pzTypeStart;
-+ for( i=0; i<ArraySize(kTypeInfo); ++i ){
-+ if( ascii_strncasecmp(kTypeInfo[i].zName, *pzTypeStart, nNameLen)==0 ){
-+ break;
-+ }
-+ }
-+ if( i==ArraySize(kTypeInfo) ){
-+ return SQLITE_MISUSE;
-+ }
-+
-+ zEnd = *pzTypeEnd;
-+ bStrict = 0;
-+ if( expectWord(zEnd, "STRICT", &zEnd) ){
-+ /* TODO(shess): Ick. But I don't want another single-purpose
-+ * flag, either.
-+ */
-+ if( kTypeInfo[i].zReplace && !kTypeInfo[i].zReplace[0] ){
-+ return SQLITE_MISUSE;
-+ }
-+ bStrict = 1;
-+ }
-+
-+ bNotNull = 0;
-+ if( expectWord(zEnd, "NOT", &zEnd) ){
-+ if( expectWord(zEnd, "NULL", &zEnd) ){
-+ bNotNull = 1;
-+ }else{
-+ /* Anything other than NULL after NOT is an error. */
-+ return SQLITE_MISUSE;
-+ }
-+ }
-+
-+ /* Anything else is an error. */
-+ if( findWord(zEnd, &zDummy, &zDummy) ){
-+ return SQLITE_MISUSE;
-+ }
-+
-+ *pTypeMask = kTypeInfo[i].strictMask;
-+ if( !bStrict ){
-+ *pTypeMask |= kTypeInfo[i].otherMask;
-+ }
-+ if( bNotNull ){
-+ *pTypeMask &= ~MASK_NULL;
-+ }
-+ if( kTypeInfo[i].zReplace ){
-+ *pzTypeStart = kTypeInfo[i].zReplace;
-+ *pzTypeEnd = *pzTypeStart + strlen(*pzTypeStart);
-+ }
-+ return SQLITE_OK;
-+}
-+
-+/* Parse the arguments, placing type masks in *pTypes and the exposed
-+ * schema in *pzCreateSql (for sqlite3_declare_vtab).
-+ */
-+static int ParseColumnsAndGenerateCreate(unsigned nCols,
-+ const char *const *pCols,
-+ char **pzCreateSql,
-+ unsigned char *pTypes,
-+ char **pzErr){
-+ unsigned i;
-+ char *zCreateSql = sqlite3_mprintf("CREATE TABLE x(");
-+ if( !zCreateSql ){
-+ return SQLITE_NOMEM;
-+ }
-+
-+ for( i=0; i<nCols; i++ ){
-+ const char *zSep = (i < nCols - 1 ? ", " : ")");
-+ const char *zNotNull = "";
-+ const char *zNameStart, *zNameEnd;
-+ const char *zTypeStart, *zTypeEnd;
-+ int rc = findNameAndType(pCols[i],
-+ &zNameStart, &zNameEnd,
-+ &zTypeStart, &zTypeEnd,
-+ &pTypes[i]);
-+ if( rc!=SQLITE_OK ){
-+ *pzErr = sqlite3_mprintf("unable to parse column %d", i);
-+ sqlite3_free(zCreateSql);
-+ return rc;
-+ }
-+
-+ if( !(pTypes[i]&MASK_NULL) ){
-+ zNotNull = " NOT NULL";
-+ }
-+
-+ /* Add name and type to the create statement. */
-+ zCreateSql = sqlite3_mprintf("%z%.*s %.*s%s%s",
-+ zCreateSql,
-+ zNameEnd - zNameStart, zNameStart,
-+ zTypeEnd - zTypeStart, zTypeStart,
-+ zNotNull, zSep);
-+ if( !zCreateSql ){
-+ return SQLITE_NOMEM;
-+ }
-+ }
-+
-+ *pzCreateSql = zCreateSql;
-+ return SQLITE_OK;
-+}
-+
-+/* Helper function for initializing the module. */
-+/* argv[0] module name
-+ * argv[1] db name for virtual table
-+ * argv[2] virtual table name
-+ * argv[3] backing table name
-+ * argv[4] columns
-+ */
-+/* TODO(shess): Since connect isn't supported, could inline into
-+ * recoverCreate().
-+ */
-+/* TODO(shess): Explore cases where it would make sense to set *pzErr. */
-+static int recoverInit(
-+ sqlite3 *db, /* Database connection */
-+ void *pAux, /* unused */
-+ int argc, const char *const*argv, /* Parameters to CREATE TABLE statement */
-+ sqlite3_vtab **ppVtab, /* OUT: New virtual table */
-+ char **pzErr /* OUT: Error message, if any */
-+){
-+ const int kTypeCol = 4; /* First argument with column type info. */
-+ Recover *pRecover; /* Virtual table structure being created. */
-+ char *zDot; /* Any dot found in "db.table" backing. */
-+ u32 iRootPage; /* Root page of backing table. */
-+ char *zCreateSql; /* Schema of created virtual table. */
-+ int rc;
-+
-+ /* Require to be in the temp database. */
-+ if( ascii_strcasecmp(argv[1], "temp")!=0 ){
-+ *pzErr = sqlite3_mprintf("recover table must be in temp database");
-+ return SQLITE_MISUSE;
-+ }
-+
-+ /* Need the backing table and at least one column. */
-+ if( argc<=kTypeCol ){
-+ *pzErr = sqlite3_mprintf("no columns specified");
-+ return SQLITE_MISUSE;
-+ }
-+
-+ pRecover = sqlite3_malloc(sizeof(Recover));
-+ if( !pRecover ){
-+ return SQLITE_NOMEM;
-+ }
-+ memset(pRecover, 0, sizeof(*pRecover));
-+ pRecover->base.pModule = &recoverModule;
-+ pRecover->db = db;
-+
-+ /* Parse out db.table, assuming main if no dot. */
-+ zDot = strchr(argv[3], '.');
-+ if( !zDot ){
-+ pRecover->zDb = sqlite3_strdup("main");
-+ pRecover->zTable = sqlite3_strdup(argv[3]);
-+ }else if( zDot>argv[3] && zDot[1]!='\0' ){
-+ pRecover->zDb = sqlite3_strndup(argv[3], zDot - argv[3]);
-+ pRecover->zTable = sqlite3_strdup(zDot + 1);
-+ }else{
-+ /* ".table" or "db." not allowed. */
-+ *pzErr = sqlite3_mprintf("ill-formed table specifier");
-+ recoverRelease(pRecover);
-+ return SQLITE_ERROR;
-+ }
-+
-+ pRecover->nCols = argc - kTypeCol;
-+ pRecover->pTypes = sqlite3_malloc(pRecover->nCols);
-+ if( !pRecover->zDb || !pRecover->zTable || !pRecover->pTypes ){
-+ recoverRelease(pRecover);
-+ return SQLITE_NOMEM;
-+ }
-+
-+ /* Require the backing table to exist. */
-+ /* TODO(shess): Be more pedantic about the form of the descriptor
-+ * string. This already fails for poorly-formed strings, simply
-+ * because there won't be a root page, but it would make more sense
-+ * to be explicit.
-+ */
-+ rc = getRootPage(pRecover->db, pRecover->zDb, pRecover->zTable, &iRootPage);
-+ if( rc!=SQLITE_OK ){
-+ *pzErr = sqlite3_mprintf("unable to find backing table");
-+ recoverRelease(pRecover);
-+ return rc;
-+ }
-+
-+ /* Parse the column definitions. */
-+ rc = ParseColumnsAndGenerateCreate(pRecover->nCols, argv + kTypeCol,
-+ &zCreateSql, pRecover->pTypes, pzErr);
-+ if( rc!=SQLITE_OK ){
-+ recoverRelease(pRecover);
-+ return rc;
-+ }
-+
-+ rc = sqlite3_declare_vtab(db, zCreateSql);
-+ sqlite3_free(zCreateSql);
-+ if( rc!=SQLITE_OK ){
-+ recoverRelease(pRecover);
-+ return rc;
-+ }
-+
-+ *ppVtab = (sqlite3_vtab *)pRecover;
-+ return SQLITE_OK;
-+}
-diff --git a/third_party/sqlite/src/src/recover.h b/third_party/sqlite/src/src/recover.h
-new file mode 100644
-index 000000000000..49b0d9e860db
---- /dev/null
-+++ b/third_party/sqlite/src/src/recover.h
-@@ -0,0 +1,23 @@
-+/* TODO(shess): sqliteicu.h is able to make this include without
-+** trouble. It doesn't work when used with Chromium's SQLite. For
-+** now the including code must include sqlite3.h first.
-+*/
-+/* #include "sqlite3.h" */
-+
-+#ifdef __cplusplus
-+extern "C" {
-+#endif
-+
-+/*
-+** Call to initialize the recover virtual-table modules (see recover.c).
-+**
-+** This could be loaded by default in main.c, but that would make the
-+** virtual table available to Web SQL. Breaking it out allows only
-+** selected users to enable it (currently sql/recovery.cc).
-+*/
-+SQLITE_API
-+int chrome_sqlite3_recoverVtableInit(sqlite3 *db);
-+
-+#ifdef __cplusplus
-+} /* End of the 'extern "C"' block */
-+#endif
-diff --git a/third_party/sqlite/src/src/recover_varint.c b/third_party/sqlite/src/src/recover_varint.c
-new file mode 100644
-index 000000000000..c111e2cedc44
---- /dev/null
-+++ b/third_party/sqlite/src/src/recover_varint.c
-@@ -0,0 +1,201 @@
-+/*
-+** 2016 Feb 29
-+**
-+** The author disclaims copyright to this source code. In place of
-+** a legal notice, here is a blessing:
-+**
-+** May you do good and not evil.
-+** May you find forgiveness for yourself and forgive others.
-+** May you share freely, never taking more than you give.
-+**
-+******************************************************************************
-+**
-+** Copy of sqlite3Fts5GetVarint() from fts3_varint.c, which in turn is copied
-+** from SQLite core.
-+*/
-+
-+#include <assert.h>
-+#include "sqlite3.h"
-+
-+/* Copied from fts3int.h. */
-+#ifndef SQLITE_AMALGAMATION
-+typedef unsigned char u8;
-+typedef unsigned int u32;
-+typedef sqlite3_uint64 u64;
-+#endif
-+
-+/*
-+** Bitmasks used by recoverGetVarint(). These precomputed constants
-+** are defined here rather than simply putting the constant expressions
-+** inline in order to work around bugs in the RVT compiler.
-+**
-+** SLOT_2_0 A mask for (0x7f<<14) | 0x7f
-+**
-+** SLOT_4_2_0 A mask for (0x7f<<28) | SLOT_2_0
-+*/
-+#define SLOT_2_0 0x001fc07f
-+#define SLOT_4_2_0 0xf01fc07f
-+
-+/*
-+** Read a 64-bit variable-length integer from memory starting at p[0].
-+** Return the number of bytes read. The value is stored in *v.
-+*/
-+u8 recoverGetVarint(const unsigned char *p, u64 *v){
-+ u32 a,b,s;
-+
-+ a = *p;
-+ /* a: p0 (unmasked) */
-+ if (!(a&0x80))
-+ {
-+ *v = a;
-+ return 1;
-+ }
-+
-+ p++;
-+ b = *p;
-+ /* b: p1 (unmasked) */
-+ if (!(b&0x80))
-+ {
-+ a &= 0x7f;
-+ a = a<<7;
-+ a |= b;
-+ *v = a;
-+ return 2;
-+ }
-+
-+ /* Verify that constants are precomputed correctly */
-+ assert( SLOT_2_0 == ((0x7f<<14) | (0x7f)) );
-+ assert( SLOT_4_2_0 == ((0xfU<<28) | (0x7f<<14) | (0x7f)) );
-+
-+ p++;
-+ a = a<<14;
-+ a |= *p;
-+ /* a: p0<<14 | p2 (unmasked) */
-+ if (!(a&0x80))
-+ {
-+ a &= SLOT_2_0;
-+ b &= 0x7f;
-+ b = b<<7;
-+ a |= b;
-+ *v = a;
-+ return 3;
-+ }
-+
-+ /* CSE1 from below */
-+ a &= SLOT_2_0;
-+ p++;
-+ b = b<<14;
-+ b |= *p;
-+ /* b: p1<<14 | p3 (unmasked) */
-+ if (!(b&0x80))
-+ {
-+ b &= SLOT_2_0;
-+ /* moved CSE1 up */
-+ /* a &= (0x7f<<14)|(0x7f); */
-+ a = a<<7;
-+ a |= b;
-+ *v = a;
-+ return 4;
-+ }
-+
-+ /* a: p0<<14 | p2 (masked) */
-+ /* b: p1<<14 | p3 (unmasked) */
-+ /* 1:save off p0<<21 | p1<<14 | p2<<7 | p3 (masked) */
-+ /* moved CSE1 up */
-+ /* a &= (0x7f<<14)|(0x7f); */
-+ b &= SLOT_2_0;
-+ s = a;
-+ /* s: p0<<14 | p2 (masked) */
-+
-+ p++;
-+ a = a<<14;
-+ a |= *p;
-+ /* a: p0<<28 | p2<<14 | p4 (unmasked) */
-+ if (!(a&0x80))
-+ {
-+ /* we can skip these cause they were (effectively) done above in calc'ing s */
-+ /* a &= (0x7f<<28)|(0x7f<<14)|(0x7f); */
-+ /* b &= (0x7f<<14)|(0x7f); */
-+ b = b<<7;
-+ a |= b;
-+ s = s>>18;
-+ *v = ((u64)s)<<32 | a;
-+ return 5;
-+ }
-+
-+ /* 2:save off p0<<21 | p1<<14 | p2<<7 | p3 (masked) */
-+ s = s<<7;
-+ s |= b;
-+ /* s: p0<<21 | p1<<14 | p2<<7 | p3 (masked) */
-+
-+ p++;
-+ b = b<<14;
-+ b |= *p;
-+ /* b: p1<<28 | p3<<14 | p5 (unmasked) */
-+ if (!(b&0x80))
-+ {
-+ /* we can skip this cause it was (effectively) done above in calc'ing s */
-+ /* b &= (0x7f<<28)|(0x7f<<14)|(0x7f); */
-+ a &= SLOT_2_0;
-+ a = a<<7;
-+ a |= b;
-+ s = s>>18;
-+ *v = ((u64)s)<<32 | a;
-+ return 6;
-+ }
-+
-+ p++;
-+ a = a<<14;
-+ a |= *p;
-+ /* a: p2<<28 | p4<<14 | p6 (unmasked) */
-+ if (!(a&0x80))
-+ {
-+ a &= SLOT_4_2_0;
-+ b &= SLOT_2_0;
-+ b = b<<7;
-+ a |= b;
-+ s = s>>11;
-+ *v = ((u64)s)<<32 | a;
-+ return 7;
-+ }
-+
-+ /* CSE2 from below */
-+ a &= SLOT_2_0;
-+ p++;
-+ b = b<<14;
-+ b |= *p;
-+ /* b: p3<<28 | p5<<14 | p7 (unmasked) */
-+ if (!(b&0x80))
-+ {
-+ b &= SLOT_4_2_0;
-+ /* moved CSE2 up */
-+ /* a &= (0x7f<<14)|(0x7f); */
-+ a = a<<7;
-+ a |= b;
-+ s = s>>4;
-+ *v = ((u64)s)<<32 | a;
-+ return 8;
-+ }
-+
-+ p++;
-+ a = a<<15;
-+ a |= *p;
-+ /* a: p4<<29 | p6<<15 | p8 (unmasked) */
-+
-+ /* moved CSE2 up */
-+ /* a &= (0x7f<<29)|(0x7f<<15)|(0xff); */
-+ b &= SLOT_2_0;
-+ b = b<<8;
-+ a |= b;
-+
-+ s = s<<4;
-+ b = p[-4];
-+ b &= 0x7f;
-+ b = b>>3;
-+ s |= b;
-+
-+ *v = ((u64)s)<<32 | a;
-+
-+ return 9;
-+}
-+
-diff --git a/third_party/sqlite/src/test/recover.test b/third_party/sqlite/src/test/recover.test
-new file mode 100644
-index 000000000000..bfb788814866
---- /dev/null
-+++ b/third_party/sqlite/src/test/recover.test
-@@ -0,0 +1,164 @@
-+# 2012 January 11 {}
-+#
-+# The author disclaims copyright to this source code. In place of
-+# a legal notice, here is a blessing:
-+#
-+# May you do good and not evil.
-+# May you find forgiveness for yourself and forgive others.
-+# May you share freely, never taking more than you give.
-+#
-+#***********************************************************************
-+# This file implements regression tests for SQLite library.
-+#
-+# This file implements tests for the recover module, which can read
-+# through corrupt rows and pages.
-+#
-+# $Id$
-+
-+# TODO(shess): These all test that the module correctly reads good
-+# data. It would be good to implement tests of corrupt data.
-+
-+set testdir [file dirname $argv0]
-+source $testdir/tester.tcl
-+
-+db eval {
-+ DROP TABLE IF EXISTS altered;
-+ CREATE TABLE altered (
-+ c TEXT
-+ );
-+ INSERT INTO altered VALUES ('a');
-+ INSERT INTO altered VALUES ('b');
-+ INSERT INTO altered VALUES ('c');
-+ ALTER TABLE altered ADD COLUMN i INTEGER NOT NULL DEFAULT 10;
-+ INSERT INTO altered VALUES ('d', 5);
-+}
-+
-+# SQLite will fill the earlier rows with the default.
-+do_test recover-alter-1.0 {
-+ execsql {SELECT c, i FROM altered ORDER BY rowid}
-+} {a 10 b 10 c 10 d 5}
-+
-+# recover sees NULL for those rows.
-+do_test recover-alter-1.1 {
-+ db eval {
-+ DROP TABLE IF EXISTS temp.altered_recover;
-+ CREATE VIRTUAL TABLE temp.altered_recover USING recover(
-+ altered,
-+ c TEXT,
-+ i INTEGER
-+ );
-+ }
-+ execsql {SELECT c, i FROM altered_recover ORDER BY rowid}
-+} {a {} b {} c {} d 5}
-+
-+# Can skip those NULL columns like if they contained a real NULL.
-+do_test recover-alter-1.2 {
-+ db eval {
-+ DROP TABLE IF EXISTS temp.altered_recover;
-+ CREATE VIRTUAL TABLE temp.altered_recover USING recover(
-+ altered,
-+ c TEXT,
-+ i INTEGER NOT NULL
-+ );
-+ }
-+ execsql {SELECT c, i FROM altered_recover ORDER BY rowid}
-+} {d 5}
-+
-+if {0} {
-+# It would be neat if this could work. I tried putting "DEFAULT ..."
-+# in the schema exposed by the recover table, but it doesn't do the
-+# trick.
-+do_test recover-alter-1.2 {
-+ db eval {
-+ DROP TABLE IF EXISTS temp.altered_recover;
-+ CREATE VIRTUAL TABLE temp.altered_recover USING recover(
-+ altered,
-+ c TEXT,
-+ i INTEGER NOT NULL DEFAULT 10
-+ );
-+ }
-+ execsql {SELECT c, i FROM altered_recover ORDER BY rowid}
-+} {a 10 b 10 c 10 d 5}
-+}
-+
-+# Helper function to generate an arbitrarily-sized table.
-+proc generate {table base count} {
-+ db eval "DROP TABLE IF EXISTS $table"
-+ db transaction immediate {
-+ db eval "CREATE TABLE $table (t TEXT,n INT)"
-+ for {set i 0} {$i<$count} {incr i} {
-+ set t [concat $base $i]
-+ db eval [concat {INSERT INTO} $table {VALUES ($t, $i)}]
-+ }
-+ }
-+}
-+
-+# Leaf-only database parses.
-+do_test recover-leaf-1.0 {
-+ db close
-+ sqlite3 db test.db
-+ generate "leaf" "Leaf-node-generating line " 10
-+
-+ db eval {
-+ DROP TABLE IF EXISTS temp.leaf_recover;
-+ CREATE VIRTUAL TABLE temp.leaf_recover USING recover(
-+ leaf,
-+ t TEXT,
-+ n INTEGER
-+ );
-+ }
-+ execsql {SELECT t, n FROM leaf_recover ORDER BY rowid}
-+} {{Leaf-node-generating line 0} 0 {Leaf-node-generating line 1} 1 {Leaf-node-generating line 2} 2 {Leaf-node-generating line 3} 3 {Leaf-node-generating line 4} 4 {Leaf-node-generating line 5} 5 {Leaf-node-generating line 6} 6 {Leaf-node-generating line 7} 7 {Leaf-node-generating line 8} 8 {Leaf-node-generating line 9} 9}
-+
-+# Empty table gives empty results.
-+do_test recover-leaf-2.0 {
-+ db close
-+ sqlite3 db test.db
-+ generate "empty" "Leaf-node-generating line " 0
-+
-+ db eval {
-+ DROP TABLE IF EXISTS temp.leaf_recover;
-+ CREATE VIRTUAL TABLE temp.leaf_recover USING recover(
-+ empty,
-+ t TEXT,
-+ n INTEGER
-+ );
-+ }
-+ execsql {SELECT t, n FROM leaf_recover ORDER BY rowid}
-+} {}
-+
-+# Single level of interior node.
-+do_test recover-interior-1.0 {
-+ db close
-+ sqlite3 db test.db
-+ generate "interior" "Interior-node-generating line " 100
-+
-+ db eval {
-+ DROP TABLE IF EXISTS temp.interior_recover;
-+ CREATE VIRTUAL TABLE temp.interior_recover USING recover(
-+ interior,
-+ t TEXT,
-+ n INTEGER
-+ );
-+ }
-+ execsql {SELECT t, n FROM interior_recover WHERE (rowid%10)=0 ORDER BY rowid}
-+} {{Interior-node-generating line 9} 9 {Interior-node-generating line 19} 19 {Interior-node-generating line 29} 29 {Interior-node-generating line 39} 39 {Interior-node-generating line 49} 49 {Interior-node-generating line 59} 59 {Interior-node-generating line 69} 69 {Interior-node-generating line 79} 79 {Interior-node-generating line 89} 89 {Interior-node-generating line 99} 99}
-+
-+# Multiple levels of interior node.
-+do_test recover-interior-2.0 {
-+ db close
-+ sqlite3 db test.db
-+ generate "interior2" "Interior-node-generating line " 5000
-+
-+ db eval {
-+ DROP TABLE IF EXISTS temp.interior2_recover;
-+ CREATE VIRTUAL TABLE temp.interior2_recover USING recover(
-+ interior2,
-+ t TEXT,
-+ n INTEGER
-+ );
-+ }
-+ execsql {SELECT t, n FROM interior2_recover WHERE (rowid%500)=0 ORDER BY rowid}
-+} {{Interior-node-generating line 499} 499 {Interior-node-generating line 999} 999 {Interior-node-generating line 1499} 1499 {Interior-node-generating line 1999} 1999 {Interior-node-generating line 2499} 2499 {Interior-node-generating line 2999} 2999 {Interior-node-generating line 3499} 3499 {Interior-node-generating line 3999} 3999 {Interior-node-generating line 4499} 4499 {Interior-node-generating line 4999} 4999}
-+
-+finish_test
-diff --git a/third_party/sqlite/src/test/recover0.test b/third_party/sqlite/src/test/recover0.test
-new file mode 100644
-index 000000000000..aac2ed9164ba
---- /dev/null
-+++ b/third_party/sqlite/src/test/recover0.test
-@@ -0,0 +1,532 @@
-+# 2012 January 4 {}
-+#
-+# The author disclaims copyright to this source code. In place of
-+# a legal notice, here is a blessing:
-+#
-+# May you do good and not evil.
-+# May you find forgiveness for yourself and forgive others.
-+# May you share freely, never taking more than you give.
-+#
-+#***********************************************************************
-+# This file implements regression tests for SQLite library.
-+#
-+# Test recover module syntax.
-+#
-+# $Id$
-+
-+# TODO(shess): Test with attached databases.
-+
-+# TODO(shess): Handle column mismatches? As things stand, the code
-+# only needs to pull the root page, so that may not be completely
-+# feasible.
-+
-+set testdir [file dirname $argv0]
-+source $testdir/tester.tcl
-+
-+db eval {
-+ DROP TABLE IF EXISTS backing;
-+ CREATE TABLE backing (t TEXT);
-+
-+ DROP TABLE IF EXISTS backing2;
-+ CREATE TABLE backing2 (id INTEGER PRIMARY KEY, t TEXT);
-+}
-+
-+# Baseline create works.
-+do_test recover-syntax-0.0 {
-+ db eval {DROP TABLE IF EXISTS temp.syntax}
-+ catchsql {
-+ CREATE VIRTUAL TABLE temp.syntax USING recover(
-+ backing,
-+ t TEXT
-+ );
-+ }
-+} {0 {}}
-+
-+# Can specify database.
-+do_test recover-syntax-0.1 {
-+ db eval {DROP TABLE IF EXISTS temp.syntax}
-+ catchsql {
-+ CREATE VIRTUAL TABLE temp.syntax USING recover(
-+ main.backing,
-+ t TEXT
-+ );
-+ }
-+} {0 {}}
-+
-+# Can specify sqlite_master.
-+do_test recover-syntax-0.2 {
-+ db eval {DROP TABLE IF EXISTS temp.syntax}
-+ catchsql {
-+ CREATE VIRTUAL TABLE temp.syntax USING recover(
-+ sqlite_master,
-+ type TEXT,
-+ name TEXT,
-+ tbl_name TEXT,
-+ rootpage INTEGER,
-+ sql TEXT
-+ );
-+ }
-+} {0 {}}
-+
-+# Fails if virtual table is not in the temp database.
-+do_test recover-syntax-1.0 {
-+ db eval {DROP TABLE IF EXISTS temp.syntax;}
-+ catchsql {
-+ CREATE VIRTUAL TABLE syntax USING recover(
-+ backing,
-+ t TEXT
-+ );
-+ }
-+} {1 {recover table must be in temp database}}
-+
-+# Fails if mentions missing table.
-+do_test recover-syntax-2.0 {
-+ db eval {DROP TABLE IF EXISTS temp.syntax;}
-+ catchsql {
-+ CREATE VIRTUAL TABLE temp.syntax USING recover(
-+ snacking,
-+ t TEXT
-+ );
-+ }
-+} {1 {unable to find backing table}}
-+
-+# Fails if mentions missing database.
-+do_test recover-syntax-2.1 {
-+ db eval {DROP TABLE IF EXISTS temp.syntax;}
-+ catchsql {
-+ CREATE VIRTUAL TABLE temp.syntax USING recover(
-+ db.backing,
-+ t TEXT
-+ );
-+ }
-+} {1 {unable to find backing table}}
-+
-+# Fails if mentions garbage backing.
-+do_test recover-syntax-2.2 {
-+ db eval {DROP TABLE IF EXISTS temp.syntax;}
-+ catchsql {
-+ CREATE VIRTUAL TABLE temp.syntax USING recover(
-+ main.backing excess,
-+ t TEXT
-+ );
-+ }
-+} {1 {unable to find backing table}}
-+
-+# Database only fails.
-+do_test recover-syntax-2.3 {
-+ db eval {DROP TABLE IF EXISTS temp.syntax;}
-+ catchsql {
-+ CREATE VIRTUAL TABLE temp.syntax USING recover(
-+ main.,
-+ t TEXT
-+ );
-+ }
-+} {1 {ill-formed table specifier}}
-+
-+# Table only fails.
-+do_test recover-syntax-2.4 {
-+ db eval {DROP TABLE IF EXISTS temp.syntax;}
-+ catchsql {
-+ CREATE VIRTUAL TABLE temp.syntax USING recover(
-+ .backing,
-+ t TEXT
-+ );
-+ }
-+} {1 {ill-formed table specifier}}
-+
-+# Manifest typing.
-+do_test recover-syntax-3.0 {
-+ db eval {DROP TABLE IF EXISTS temp.syntax}
-+ execsql {
-+ CREATE VIRTUAL TABLE temp.syntax USING recover(
-+ backing,
-+ t
-+ );
-+ PRAGMA table_info(syntax);
-+ }
-+} {0 t {} 0 {} 0}
-+
-+# ANY as an alternative for manifest typing.
-+do_test recover-syntax-3.1 {
-+ db eval {DROP TABLE IF EXISTS temp.syntax}
-+ execsql {
-+ CREATE VIRTUAL TABLE temp.syntax USING recover(
-+ backing,
-+ t ANY
-+ );
-+ PRAGMA table_info(syntax);
-+ }
-+} {0 t {} 0 {} 0}
-+
-+# ANY NOT NULL
-+do_test recover-syntax-3.2 {
-+ db eval {DROP TABLE IF EXISTS temp.syntax}
-+ execsql {
-+ CREATE VIRTUAL TABLE temp.syntax USING recover(
-+ backing,
-+ t ANY NOT NULL
-+ );
-+ PRAGMA table_info(syntax);
-+ }
-+} {0 t {} 1 {} 0}
-+
-+# ANY STRICT is not sensible.
-+do_test recover-syntax-3.3 {
-+ db eval {DROP TABLE IF EXISTS temp.syntax}
-+ catchsql {
-+ CREATE VIRTUAL TABLE temp.syntax USING recover(
-+ backing,
-+ v ANY STRICT
-+ );
-+ PRAGMA table_info(syntax);
-+ }
-+} {1 {unable to parse column 0}}
-+
-+# TEXT column by type works.
-+do_test recover-syntax-4.0 {
-+ db eval {DROP TABLE IF EXISTS temp.syntax}
-+ execsql {
-+ CREATE VIRTUAL TABLE temp.syntax USING recover(
-+ backing,
-+ t TEXT
-+ );
-+ PRAGMA table_info(syntax);
-+ }
-+} {0 t TEXT 0 {} 0}
-+
-+# TEXT NOT NULL
-+do_test recover-syntax-4.1 {
-+ db eval {DROP TABLE IF EXISTS temp.syntax}
-+ execsql {
-+ CREATE VIRTUAL TABLE temp.syntax USING recover(
-+ backing,
-+ t TEXT NOT NULL
-+ );
-+ PRAGMA table_info(syntax);
-+ }
-+} {0 t TEXT 1 {} 0}
-+
-+# TEXT STRICT
-+do_test recover-syntax-4.2 {
-+ db eval {DROP TABLE IF EXISTS temp.syntax}
-+ execsql {
-+ CREATE VIRTUAL TABLE temp.syntax USING recover(
-+ backing,
-+ t TEXT STRICT
-+ );
-+ PRAGMA table_info(syntax);
-+ }
-+} {0 t TEXT 0 {} 0}
-+
-+# TEXT STRICT NOT NULL
-+do_test recover-syntax-4.3 {
-+ db eval {DROP TABLE IF EXISTS temp.syntax}
-+ execsql {
-+ CREATE VIRTUAL TABLE temp.syntax USING recover(
-+ backing,
-+ t TEXT STRICT NOT NULL
-+ );
-+ PRAGMA table_info(syntax);
-+ }
-+} {0 t TEXT 1 {} 0}
-+
-+# INTEGER
-+do_test recover-syntax-5.0 {
-+ db eval {DROP TABLE IF EXISTS temp.syntax}
-+ execsql {
-+ CREATE VIRTUAL TABLE temp.syntax USING recover(
-+ backing,
-+ i INTEGER
-+ );
-+ PRAGMA table_info(syntax);
-+ }
-+} {0 i INTEGER 0 {} 0}
-+
-+# INTEGER NOT NULL
-+do_test recover-syntax-5.1 {
-+ db eval {DROP TABLE IF EXISTS temp.syntax}
-+ execsql {
-+ CREATE VIRTUAL TABLE temp.syntax USING recover(
-+ backing,
-+ i INTEGER NOT NULL
-+ );
-+ PRAGMA table_info(syntax);
-+ }
-+} {0 i INTEGER 1 {} 0}
-+
-+# INTEGER STRICT
-+do_test recover-syntax-5.2 {
-+ db eval {DROP TABLE IF EXISTS temp.syntax}
-+ execsql {
-+ CREATE VIRTUAL TABLE temp.syntax USING recover(
-+ backing,
-+ i INTEGER STRICT
-+ );
-+ PRAGMA table_info(syntax);
-+ }
-+} {0 i INTEGER 0 {} 0}
-+
-+# INTEGER STRICT NOT NULL
-+do_test recover-syntax-5.3 {
-+ db eval {DROP TABLE IF EXISTS temp.syntax}
-+ execsql {
-+ CREATE VIRTUAL TABLE temp.syntax USING recover(
-+ backing,
-+ i INTEGER STRICT NOT NULL
-+ );
-+ PRAGMA table_info(syntax);
-+ }
-+} {0 i INTEGER 1 {} 0}
-+
-+# BLOB
-+do_test recover-syntax-6.0 {
-+ db eval {DROP TABLE IF EXISTS temp.syntax}
-+ execsql {
-+ CREATE VIRTUAL TABLE temp.syntax USING recover(
-+ backing,
-+ b BLOB
-+ );
-+ PRAGMA table_info(syntax);
-+ }
-+} {0 b BLOB 0 {} 0}
-+
-+# BLOB NOT NULL
-+do_test recover-syntax-6.1 {
-+ db eval {DROP TABLE IF EXISTS temp.syntax}
-+ execsql {
-+ CREATE VIRTUAL TABLE temp.syntax USING recover(
-+ backing,
-+ b BLOB NOT NULL
-+ );
-+ PRAGMA table_info(syntax);
-+ }
-+} {0 b BLOB 1 {} 0}
-+
-+# BLOB STRICT
-+do_test recover-syntax-6.2 {
-+ db eval {DROP TABLE IF EXISTS temp.syntax}
-+ execsql {
-+ CREATE VIRTUAL TABLE temp.syntax USING recover(
-+ backing,
-+ b BLOB STRICT
-+ );
-+ PRAGMA table_info(syntax);
-+ }
-+} {0 b BLOB 0 {} 0}
-+
-+# BLOB STRICT NOT NULL
-+do_test recover-syntax-6.3 {
-+ db eval {DROP TABLE IF EXISTS temp.syntax}
-+ execsql {
-+ CREATE VIRTUAL TABLE temp.syntax USING recover(
-+ backing,
-+ b BLOB STRICT NOT NULL
-+ );
-+ PRAGMA table_info(syntax);
-+ }
-+} {0 b BLOB 1 {} 0}
-+
-+# FLOAT
-+do_test recover-syntax-7.0 {
-+ db eval {DROP TABLE IF EXISTS temp.syntax}
-+ execsql {
-+ CREATE VIRTUAL TABLE temp.syntax USING recover(
-+ backing,
-+ f FLOAT
-+ );
-+ PRAGMA table_info(syntax);
-+ }
-+} {0 f FLOAT 0 {} 0}
-+
-+# FLOAT NOT NULL
-+do_test recover-syntax-7.1 {
-+ db eval {DROP TABLE IF EXISTS temp.syntax}
-+ execsql {
-+ CREATE VIRTUAL TABLE temp.syntax USING recover(
-+ backing,
-+ f FLOAT NOT NULL
-+ );
-+ PRAGMA table_info(syntax);
-+ }
-+} {0 f FLOAT 1 {} 0}
-+
-+# FLOAT STRICT
-+do_test recover-syntax-7.2 {
-+ db eval {DROP TABLE IF EXISTS temp.syntax}
-+ execsql {
-+ CREATE VIRTUAL TABLE temp.syntax USING recover(
-+ backing,
-+ f FLOAT STRICT
-+ );
-+ PRAGMA table_info(syntax);
-+ }
-+} {0 f FLOAT 0 {} 0}
-+
-+# FLOAT STRICT NOT NULL
-+do_test recover-syntax-7.3 {
-+ db eval {DROP TABLE IF EXISTS temp.syntax}
-+ execsql {
-+ CREATE VIRTUAL TABLE temp.syntax USING recover(
-+ backing,
-+ f FLOAT STRICT NOT NULL
-+ );
-+ PRAGMA table_info(syntax);
-+ }
-+} {0 f FLOAT 1 {} 0}
-+
-+# NUMERIC
-+do_test recover-syntax-8.0 {
-+ db eval {DROP TABLE IF EXISTS temp.syntax}
-+ execsql {
-+ CREATE VIRTUAL TABLE temp.syntax USING recover(
-+ backing,
-+ f NUMERIC
-+ );
-+ PRAGMA table_info(syntax);
-+ }
-+} {0 f NUMERIC 0 {} 0}
-+
-+# NUMERIC NOT NULL
-+do_test recover-syntax-8.1 {
-+ db eval {DROP TABLE IF EXISTS temp.syntax}
-+ execsql {
-+ CREATE VIRTUAL TABLE temp.syntax USING recover(
-+ backing,
-+ f NUMERIC NOT NULL
-+ );
-+ PRAGMA table_info(syntax);
-+ }
-+} {0 f NUMERIC 1 {} 0}
-+
-+# NUMERIC STRICT
-+do_test recover-syntax-8.2 {
-+ db eval {DROP TABLE IF EXISTS temp.syntax}
-+ execsql {
-+ CREATE VIRTUAL TABLE temp.syntax USING recover(
-+ backing,
-+ f NUMERIC STRICT
-+ );
-+ PRAGMA table_info(syntax);
-+ }
-+} {0 f NUMERIC 0 {} 0}
-+
-+# NUMERIC STRICT NOT NULL
-+do_test recover-syntax-8.3 {
-+ db eval {DROP TABLE IF EXISTS temp.syntax}
-+ execsql {
-+ CREATE VIRTUAL TABLE temp.syntax USING recover(
-+ backing,
-+ f NUMERIC STRICT NOT NULL
-+ );
-+ PRAGMA table_info(syntax);
-+ }
-+} {0 f NUMERIC 1 {} 0}
-+
-+# ROWID
-+do_test recover-syntax-9.0 {
-+ db eval {DROP TABLE IF EXISTS temp.syntax}
-+ execsql {
-+ CREATE VIRTUAL TABLE temp.syntax USING recover(
-+ backing2,
-+ id ROWID,
-+ v
-+ );
-+ PRAGMA table_info(syntax);
-+ }
-+} {0 id INTEGER 1 {} 0 1 v {} 0 {} 0}
-+
-+# ROWID NOT NULL (is default)
-+do_test recover-syntax-9.1 {
-+ db eval {DROP TABLE IF EXISTS temp.syntax}
-+ execsql {
-+ CREATE VIRTUAL TABLE temp.syntax USING recover(
-+ backing2,
-+ id ROWID NOT NULL,
-+ v
-+ );
-+ PRAGMA table_info(syntax);
-+ }
-+} {0 id INTEGER 1 {} 0 1 v {} 0 {} 0}
-+
-+# ROWID STRICT
-+do_test recover-syntax-9.0 {
-+ db eval {DROP TABLE IF EXISTS temp.syntax}
-+ execsql {
-+ CREATE VIRTUAL TABLE temp.syntax USING recover(
-+ backing2,
-+ id ROWID STRICT,
-+ v
-+ );
-+ PRAGMA table_info(syntax);
-+ }
-+} {0 id INTEGER 1 {} 0 1 v {} 0 {} 0}
-+
-+# ROWID STRICT NOT NULL (is default)
-+do_test recover-syntax-9.1 {
-+ db eval {DROP TABLE IF EXISTS temp.syntax}
-+ execsql {
-+ CREATE VIRTUAL TABLE temp.syntax USING recover(
-+ backing2,
-+ id ROWID STRICT NOT NULL,
-+ v
-+ );
-+ PRAGMA table_info(syntax);
-+ }
-+} {0 id INTEGER 1 {} 0 1 v {} 0 {} 0}
-+
-+# Invalid type info is not ignored.
-+do_test recover-syntax-10.0 {
-+ db eval {DROP TABLE IF EXISTS temp.syntax}
-+ catchsql {
-+ CREATE VIRTUAL TABLE temp.syntax USING recover(
-+ backing,
-+ v GARBAGE
-+ );
-+ }
-+} {1 {unable to parse column 0}}
-+
-+# Extraneous type info is not ignored.
-+do_test recover-syntax-10.1 {
-+ db eval {DROP TABLE IF EXISTS temp.syntax}
-+ catchsql {
-+ CREATE VIRTUAL TABLE temp.syntax USING recover(
-+ backing,
-+ v INTEGER GARBAGE
-+ );
-+ }
-+} {1 {unable to parse column 0}}
-+
-+# Extraneous type info is not ignored.
-+do_test recover-syntax-10.2 {
-+ db eval {DROP TABLE IF EXISTS temp.syntax}
-+ catchsql {
-+ CREATE VIRTUAL TABLE temp.syntax USING recover(
-+ backing,
-+ v INTEGER NOT NULL GARBAGE
-+ );
-+ }
-+} {1 {unable to parse column 0}}
-+
-+# Multiple types don't work.
-+do_test recover-syntax-10.3 {
-+ db eval {DROP TABLE IF EXISTS temp.syntax}
-+ catchsql {
-+ CREATE VIRTUAL TABLE temp.syntax USING recover(
-+ backing,
-+ v INTEGER FLOAT BLOB
-+ );
-+ }
-+} {1 {unable to parse column 0}}
-+
-+# Multiple types don't work.
-+do_test recover-syntax-10.4 {
-+ db eval {DROP TABLE IF EXISTS temp.syntax}
-+ catchsql {
-+ CREATE VIRTUAL TABLE temp.syntax USING recover(
-+ backing,
-+ v INTEGER NOT NULL TEXT
-+ );
-+ }
-+} {1 {unable to parse column 0}}
-+
-+finish_test
-diff --git a/third_party/sqlite/src/test/recover1.test b/third_party/sqlite/src/test/recover1.test
-new file mode 100644
-index 000000000000..1d90f096b727
---- /dev/null
-+++ b/third_party/sqlite/src/test/recover1.test
-@@ -0,0 +1,429 @@
-+# 2012 January 4 {}
-+#
-+# The author disclaims copyright to this source code. In place of
-+# a legal notice, here is a blessing:
-+#
-+# May you do good and not evil.
-+# May you find forgiveness for yourself and forgive others.
-+# May you share freely, never taking more than you give.
-+#
-+#***********************************************************************
-+# This file implements regression tests for SQLite library.
-+#
-+# Use tables to test leaf-node reading, and also type checking.
-+#
-+# $Id$
-+
-+set testdir [file dirname $argv0]
-+source $testdir/tester.tcl
-+
-+# A really basic table with manifest typing and a row of each type.
-+db close
-+sqlite3 db test.db
-+db eval {
-+ DROP TABLE IF EXISTS types;
-+ CREATE TABLE types (rowtype TEXT, value);
-+ INSERT INTO types VALUES ("NULL", NULL);
-+ INSERT INTO types VALUES ("INTEGER", 17);
-+ INSERT INTO types VALUES ("FLOAT", 3.1415927);
-+ INSERT INTO types VALUES ("TEXT", "This is text");
-+ INSERT INTO types VALUES ("BLOB", CAST("This is a blob" AS BLOB));
-+
-+ -- Same contents, with an alias for rowid. Testing separately
-+ -- because it changes the structure of the data (the alias column is
-+ -- serialized as NULL).
-+ DROP TABLE IF EXISTS types2;
-+ CREATE TABLE types2 (id INTEGER PRIMARY KEY, rowtype TEXT, value);
-+ INSERT INTO types2 (id, rowtype, value)
-+ SELECT rowid, rowtype, value FROM types;
-+}
-+
-+# Baseline results.
-+do_test recover-types-0.0 {
-+ execsql {SELECT rowid, rowtype, value, TYPEOF(value) FROM types}
-+} {1 NULL {} null 2 INTEGER 17 integer 3 FLOAT 3.1415927 real 4 TEXT {This is text} text 5 BLOB {This is a blob} blob}
-+
-+# With no restrictions, recover table shows identical results.
-+do_test recover-types-0.1 {
-+ db eval {
-+ DROP TABLE IF EXISTS temp.types_recover;
-+ CREATE VIRTUAL TABLE temp.types_recover USING recover(
-+ types,
-+ rowtype TEXT,
-+ value
-+ );
-+ }
-+ execsql {SELECT rowid, rowtype, value, TYPEOF(value) FROM types_recover}
-+} {1 NULL {} null 2 INTEGER 17 integer 3 FLOAT 3.1415927 real 4 TEXT {This is text} text 5 BLOB {This is a blob} blob}
-+
-+# Restrict by INTEGER
-+do_test recover-types-1.0 {
-+ db eval {
-+ DROP TABLE IF EXISTS temp.types_recover;
-+ CREATE VIRTUAL TABLE temp.types_recover USING recover(
-+ types,
-+ rowtype TEXT,
-+ value INTEGER
-+ );
-+ }
-+ execsql {SELECT rowid, rowtype, value, TYPEOF(value) FROM types_recover}
-+} {1 NULL {} null 2 INTEGER 17 integer}
-+
-+# Restrict by INTEGER NOT NULL
-+do_test recover-types-1.1 {
-+ db eval {
-+ DROP TABLE IF EXISTS temp.types_recover;
-+ CREATE VIRTUAL TABLE temp.types_recover USING recover(
-+ types,
-+ rowtype TEXT,
-+ value INTEGER NOT NULL
-+ );
-+ }
-+ execsql {SELECT rowid, rowtype, value, TYPEOF(value) FROM types_recover}
-+} {2 INTEGER 17 integer}
-+
-+# Restrict by FLOAT
-+do_test recover-types-2.0 {
-+ db eval {
-+ DROP TABLE IF EXISTS temp.types_recover;
-+ CREATE VIRTUAL TABLE temp.types_recover USING recover(
-+ types,
-+ rowtype TEXT,
-+ value FLOAT
-+ );
-+ }
-+ execsql {SELECT rowid, rowtype, value, TYPEOF(value) FROM types_recover}
-+} {1 NULL {} null 2 INTEGER 17.0 real 3 FLOAT 3.1415927 real}
-+
-+# Restrict by FLOAT NOT NULL
-+do_test recover-types-2.1 {
-+ db eval {
-+ DROP TABLE IF EXISTS temp.types_recover;
-+ CREATE VIRTUAL TABLE temp.types_recover USING recover(
-+ types,
-+ rowtype TEXT,
-+ value FLOAT NOT NULL
-+ );
-+ }
-+ execsql {SELECT rowid, rowtype, value, TYPEOF(value) FROM types_recover}
-+} {2 INTEGER 17.0 real 3 FLOAT 3.1415927 real}
-+
-+# Restrict by FLOAT STRICT
-+do_test recover-types-2.2 {
-+ db eval {
-+ DROP TABLE IF EXISTS temp.types_recover;
-+ CREATE VIRTUAL TABLE temp.types_recover USING recover(
-+ types,
-+ rowtype TEXT,
-+ value FLOAT STRICT
-+ );
-+ }
-+ execsql {SELECT rowid, rowtype, value, TYPEOF(value) FROM types_recover}
-+} {1 NULL {} null 3 FLOAT 3.1415927 real}
-+
-+# Restrict by FLOAT STRICT NOT NULL
-+do_test recover-types-2.3 {
-+ db eval {
-+ DROP TABLE IF EXISTS temp.types_recover;
-+ CREATE VIRTUAL TABLE temp.types_recover USING recover(
-+ types,
-+ rowtype TEXT,
-+ value FLOAT STRICT NOT NULL
-+ );
-+ }
-+ execsql {SELECT rowid, rowtype, value, TYPEOF(value) FROM types_recover}
-+} {3 FLOAT 3.1415927 real}
-+
-+# Restrict by TEXT
-+do_test recover-types-3.0 {
-+ db eval {
-+ DROP TABLE IF EXISTS temp.types_recover;
-+ CREATE VIRTUAL TABLE temp.types_recover USING recover(
-+ types,
-+ rowtype TEXT,
-+ value TEXT
-+ );
-+ }
-+ execsql {SELECT rowid, rowtype, value, TYPEOF(value) FROM types_recover}
-+} {1 NULL {} null 4 TEXT {This is text} text 5 BLOB {This is a blob} blob}
-+
-+# Restrict by TEXT NOT NULL
-+do_test recover-types-3.1 {
-+ db eval {
-+ DROP TABLE IF EXISTS temp.types_recover;
-+ CREATE VIRTUAL TABLE temp.types_recover USING recover(
-+ types,
-+ rowtype TEXT,
-+ value TEXT NOT NULL
-+ );
-+ }
-+ execsql {SELECT rowid, rowtype, value, TYPEOF(value) FROM types_recover}
-+} {4 TEXT {This is text} text 5 BLOB {This is a blob} blob}
-+
-+# Restrict by TEXT STRICT
-+do_test recover-types-3.2 {
-+ db eval {
-+ DROP TABLE IF EXISTS temp.types_recover;
-+ CREATE VIRTUAL TABLE temp.types_recover USING recover(
-+ types,
-+ rowtype TEXT,
-+ value TEXT STRICT
-+ );
-+ }
-+ execsql {SELECT rowid, rowtype, value, TYPEOF(value) FROM types_recover}
-+} {1 NULL {} null 4 TEXT {This is text} text}
-+
-+# Restrict by TEXT STRICT NOT NULL
-+do_test recover-types-3.3 {
-+ db eval {
-+ DROP TABLE IF EXISTS temp.types_recover;
-+ CREATE VIRTUAL TABLE temp.types_recover USING recover(
-+ types,
-+ rowtype TEXT,
-+ value TEXT STRICT NOT NULL
-+ );
-+ }
-+ execsql {SELECT rowid, rowtype, value, TYPEOF(value) FROM types_recover}
-+} {4 TEXT {This is text} text}
-+
-+# Restrict by BLOB
-+do_test recover-types-4.0 {
-+ db eval {
-+ DROP TABLE IF EXISTS temp.types_recover;
-+ CREATE VIRTUAL TABLE temp.types_recover USING recover(
-+ types,
-+ rowtype TEXT,
-+ value BLOB
-+ );
-+ }
-+ execsql {SELECT rowid, rowtype, value, TYPEOF(value) FROM types_recover}
-+} {1 NULL {} null 5 BLOB {This is a blob} blob}
-+
-+# Restrict by BLOB NOT NULL
-+do_test recover-types-4.1 {
-+ db eval {
-+ DROP TABLE IF EXISTS temp.types_recover;
-+ CREATE VIRTUAL TABLE temp.types_recover USING recover(
-+ types,
-+ rowtype TEXT,
-+ value BLOB NOT NULL
-+ );
-+ }
-+ execsql {SELECT rowid, rowtype, value, TYPEOF(value) FROM types_recover}
-+} {5 BLOB {This is a blob} blob}
-+
-+# Manifest typing.
-+do_test recover-types-5.0 {
-+ db eval {
-+ DROP TABLE IF EXISTS temp.types_recover;
-+ CREATE VIRTUAL TABLE temp.types_recover USING recover(
-+ types,
-+ rowtype TEXT,
-+ value
-+ );
-+ }
-+ execsql {SELECT rowid, rowtype, value, TYPEOF(value) FROM types_recover}
-+} {1 NULL {} null 2 INTEGER 17 integer 3 FLOAT 3.1415927 real 4 TEXT {This is text} text 5 BLOB {This is a blob} blob}
-+
-+# Should get same results specifying manifest typing explicitly.
-+do_test recover-types-5.1 {
-+ db eval {
-+ DROP TABLE IF EXISTS temp.types_recover;
-+ CREATE VIRTUAL TABLE temp.types_recover USING recover(
-+ types,
-+ rowtype TEXT,
-+ value ANY
-+ );
-+ }
-+ execsql {SELECT rowid, rowtype, value, TYPEOF(value) FROM types_recover}
-+} {1 NULL {} null 2 INTEGER 17 integer 3 FLOAT 3.1415927 real 4 TEXT {This is text} text 5 BLOB {This is a blob} blob}
-+
-+# Same results, skipping the NULL row.
-+do_test recover-types-5.2 {
-+ db eval {
-+ DROP TABLE IF EXISTS temp.types_recover;
-+ CREATE VIRTUAL TABLE temp.types_recover USING recover(
-+ types,
-+ rowtype TEXT,
-+ value ANY NOT NULL
-+ );
-+ }
-+ execsql {SELECT rowid, rowtype, value, TYPEOF(value) FROM types_recover}
-+} {2 INTEGER 17 integer 3 FLOAT 3.1415927 real 4 TEXT {This is text} text 5 BLOB {This is a blob} blob}
-+
-+# Test ROWID values.
-+do_test recover-types-6.0 {
-+ db eval {
-+ DROP TABLE IF EXISTS temp.types2_recover;
-+ CREATE VIRTUAL TABLE temp.types2_recover USING recover(
-+ types2,
-+ id ROWID,
-+ rowtype TEXT,
-+ value
-+ );
-+ }
-+ execsql {SELECT rowid, id, rowtype, value, TYPEOF(value) FROM types2_recover}
-+} {1 1 NULL {} null 2 2 INTEGER 17 integer 3 3 FLOAT 3.1415927 real 4 4 TEXT {This is text} text 5 5 BLOB {This is a blob} blob}
-+
-+# ROWID NOT NULL is identical.
-+do_test recover-types-6.1 {
-+ db eval {
-+ DROP TABLE IF EXISTS temp.types2_recover;
-+ CREATE VIRTUAL TABLE temp.types2_recover USING recover(
-+ types2,
-+ id ROWID NOT NULL,
-+ rowtype TEXT,
-+ value
-+ );
-+ }
-+ execsql {SELECT rowid, id, rowtype, value, TYPEOF(value) FROM types2_recover}
-+} {1 1 NULL {} null 2 2 INTEGER 17 integer 3 3 FLOAT 3.1415927 real 4 4 TEXT {This is text} text 5 5 BLOB {This is a blob} blob}
-+
-+# Check that each of the possible integer sizes is being decoded.
-+# TODO(shess): It would be neat to ACTUALLY test these things. As-is,
-+# this should exercise the code paths, but one needs logging or a
-+# debugger to verify that things are stored as expected.
-+do_test recover-types-7.0 {
-+ db eval {
-+ DROP TABLE IF EXISTS integers;
-+ CREATE TABLE integers (value);
-+
-+ -- encoded directly in type info.
-+ INSERT INTO integers VALUES (0);
-+ INSERT INTO integers VALUES (1);
-+
-+ -- 8-bit signed.
-+ INSERT INTO integers VALUES (2);
-+ INSERT INTO integers VALUES (-2);
-+ INSERT INTO integers VALUES (127);
-+ INSERT INTO integers VALUES (-128);
-+
-+ -- 16-bit signed.
-+ INSERT INTO integers VALUES (12345);
-+ INSERT INTO integers VALUES (-12345);
-+ INSERT INTO integers VALUES (32767);
-+ INSERT INTO integers VALUES (-32768);
-+
-+ -- 24-bit signed.
-+ INSERT INTO integers VALUES (1234567);
-+ INSERT INTO integers VALUES (-1234567);
-+ INSERT INTO integers VALUES (8388607);
-+ INSERT INTO integers VALUES (-8388608);
-+
-+ -- 32-bit signed.
-+ INSERT INTO integers VALUES (1234567890);
-+ INSERT INTO integers VALUES (-1234567890);
-+ INSERT INTO integers VALUES (2147483647);
-+ INSERT INTO integers VALUES (-2147483648);
-+
-+ -- 48-bit signed.
-+ INSERT INTO integers VALUES (123456789012345);
-+ INSERT INTO integers VALUES (-123456789012345);
-+ INSERT INTO integers VALUES (140737488355327);
-+ INSERT INTO integers VALUES (-140737488355328);
-+
-+ -- 64-bit signed.
-+ INSERT INTO integers VALUES (9223372036854775807);
-+ INSERT INTO integers VALUES (-9223372036854775808);
-+
-+ DROP TABLE IF EXISTS integers_recover;
-+ CREATE VIRTUAL TABLE temp.integers_recover USING recover(
-+ integers,
-+ value INTEGER
-+ );
-+ }
-+ execsql {SELECT rowid, value FROM integers_recover}
-+} {1 0 2 1 3 2 4 -2 5 127 6 -128 7 12345 8 -12345 9 32767 10 -32768 11 1234567 12 -1234567 13 8388607 14 -8388608 15 1234567890 16 -1234567890 17 2147483647 18 -2147483648 19 123456789012345 20 -123456789012345 21 140737488355327 22 -140737488355328 23 9223372036854775807 24 -9223372036854775808}
-+
-+# If UTF16 support is disabled, ignore the rest of the tests.
-+#
-+ifcapable {!utf16} {
-+ finish_test
-+ return
-+}
-+
-+# Baseline UTF-8.
-+file delete -force test.db
-+sqlite3 db test.db;
-+db eval {
-+ PRAGMA encoding = 'UTF-8';
-+}
-+
-+do_test recover-encoding-1.0 {
-+ execsql {
-+ DROP TABLE IF EXISTS e;
-+ CREATE TABLE e (v TEXT);
-+ INSERT INTO e VALUES('Mjollnir');
-+ INSERT INTO e VALUES('Mjölnir');
-+ INSERT INTO e VALUES('Mjǫlnir');
-+ INSERT INTO e VALUES('Mjölner');
-+ INSERT INTO e VALUES('Mjølner');
-+ INSERT INTO e VALUES('ハンマー');
-+ PRAGMA encoding;
-+
-+ DROP TABLE IF EXISTS e_recover;
-+ CREATE VIRTUAL TABLE temp.e_recover USING recover(
-+ e,
-+ v TEXT
-+ );
-+ SELECT rowid, v FROM e_recover ORDER BY rowid;
-+ }
-+} {UTF-8 1 Mjollnir 2 Mjölnir 3 Mjǫlnir 4 Mjölner 5 Mjølner 6 ハンマー}
-+
-+# Reset the database to UTF-16LE.
-+file delete -force test.db
-+sqlite3 db test.db;
-+db eval {
-+ PRAGMA encoding = 'UTF-16LE';
-+}
-+
-+do_test recover-encoding-2.0 {
-+ execsql {
-+ DROP TABLE IF EXISTS e;
-+ CREATE TABLE e (v TEXT);
-+ INSERT INTO e VALUES('Mjollnir');
-+ INSERT INTO e VALUES('Mjölnir');
-+ INSERT INTO e VALUES('Mjǫlnir');
-+ INSERT INTO e VALUES('Mjölner');
-+ INSERT INTO e VALUES('Mjølner');
-+ INSERT INTO e VALUES('ハンマー');
-+ PRAGMA encoding;
-+
-+ DROP TABLE IF EXISTS e_recover;
-+ CREATE VIRTUAL TABLE temp.e_recover USING recover(
-+ e,
-+ v TEXT
-+ );
-+ SELECT rowid, v FROM e_recover ORDER BY rowid;
-+ }
-+} {UTF-16le 1 Mjollnir 2 Mjölnir 3 Mjǫlnir 4 Mjölner 5 Mjølner 6 ハンマー}
-+
-+# Reset the database to UTF-16BE.
-+file delete -force test.db
-+sqlite3 db test.db;
-+db eval {
-+ PRAGMA encoding = 'UTF-16BE';
-+}
-+
-+do_test recover-encoding-3.0 {
-+ execsql {
-+ DROP TABLE IF EXISTS e;
-+ CREATE TABLE e (v TEXT);
-+ INSERT INTO e VALUES('Mjollnir');
-+ INSERT INTO e VALUES('Mjölnir');
-+ INSERT INTO e VALUES('Mjǫlnir');
-+ INSERT INTO e VALUES('Mjölner');
-+ INSERT INTO e VALUES('Mjølner');
-+ INSERT INTO e VALUES('ハンマー');
-+ PRAGMA encoding;
-+
-+ DROP TABLE IF EXISTS e_recover;
-+ CREATE VIRTUAL TABLE temp.e_recover USING recover(
-+ e,
-+ v TEXT
-+ );
-+ SELECT rowid, v FROM e_recover ORDER BY rowid;
-+ }
-+} {UTF-16be 1 Mjollnir 2 Mjölnir 3 Mjǫlnir 4 Mjölner 5 Mjølner 6 ハンマー}
-+
-+finish_test
-diff --git a/third_party/sqlite/src/test/recover2.test b/third_party/sqlite/src/test/recover2.test
-new file mode 100644
-index 000000000000..8aa4e049a010
---- /dev/null
-+++ b/third_party/sqlite/src/test/recover2.test
-@@ -0,0 +1,157 @@
-+# 2012 January 4 {}
-+#
-+# The author disclaims copyright to this source code. In place of
-+# a legal notice, here is a blessing:
-+#
-+# May you do good and not evil.
-+# May you find forgiveness for yourself and forgive others.
-+# May you share freely, never taking more than you give.
-+#
-+#***********************************************************************
-+# This file implements regression tests for SQLite library.
-+#
-+# This file implements tests for how the recover module handles cell
-+# overflow.
-+#
-+# $Id$
-+
-+set testdir [file dirname $argv0]
-+source $testdir/tester.tcl
-+
-+set lorem "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam sagittis gravida odio vitae ultrices. Nulla facilisi. Maecenas pulvinar, tellus ut bibendum semper, nibh tellus auctor nulla, in dignissim nisi ipsum id arcu. Nullam tincidunt arcu malesuada turpis faucibus in adipiscing enim mattis. Fusce augue magna, scelerisque sollicitudin egestas in, cursus eu sapien. Pellentesque tempor risus at lectus convallis a convallis orci ornare. Integer tristique aliquam leo vel interdum.
-+
-+Phasellus quis dictum nisi. Curabitur at enim non felis pharetra imperdiet. Duis tempus massa eu leo varius porta. Vestibulum sodales nulla at purus tincidunt ultrices. Nam euismod posuere nibh, nec sodales magna luctus ac. Ut commodo hendrerit mauris vitae gravida. In interdum justo ut sem eleifend convallis. Donec cursus molestie elementum. Suspendisse at nisl tellus, vel consequat mauris. Nullam non justo nibh.
-+
-+Maecenas varius sollicitudin libero, nec feugiat turpis facilisis eget. Quisque et sem risus. Aenean a magna quis purus hendrerit mattis eu vel lorem. Aenean fringilla diam eget tortor lacinia sed mollis eros feugiat. Quisque ac purus sapien. Nullam quis tellus vel magna convallis tincidunt. Donec eget ligula at libero tincidunt congue ut ut lacus. Integer dignissim aliquet congue. Pellentesque sed risus vitae lorem porta viverra ac eu risus. Vivamus congue suscipit odio pulvinar aliquet. Aliquam porttitor nunc non sapien auctor et vehicula augue molestie.
-+
-+Aliquam et dui ac sem tempus dictum. Fusce arcu nulla, viverra sit amet suscipit quis, malesuada at felis. Fusce ut diam felis. Fusce id ligula non eros fermentum sodales in nec quam. Donec tempor bibendum arcu ac adipiscing. Praesent nisl lectus, tempor ut vehicula eget, mattis a justo. Mauris condimentum luctus eros a varius. Morbi mollis elit eget velit convallis eu sodales odio egestas. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Vivamus interdum, metus sit amet varius varius, lectus eros semper risus, sed sagittis ipsum libero in sapien. Nam lacinia nulla vitae magna facilisis scelerisque. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
-+
-+Donec gravida dignissim eleifend. Aliquam vel tincidunt tortor. Curabitur massa ante, blandit a auctor at, ullamcorper sed nisl. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Suspendisse ut felis a eros egestas ultricies et quis mi. Vivamus ut risus massa. Donec nec ornare erat. Aliquam ornare, lorem a rhoncus aliquam, tellus diam tincidunt tellus, a mattis nunc ante ac arcu. Curabitur nec metus id risus commodo ullamcorper eu ut tortor."
-+
-+# Create a database which needs a multiple overflow pages to test the
-+# transition from main page to overflow, and then overflow to
-+# overflow.
-+do_test recover-overflow-1.0 {
-+ db eval {
-+ DROP TABLE IF EXISTS overflow;
-+ CREATE TABLE overflow (value TEXT);
-+ INSERT INTO overflow VALUES ($lorem);
-+
-+ DROP TABLE IF EXISTS overflow_recover;
-+ CREATE VIRTUAL TABLE temp.overflow_recover USING recover(
-+ overflow,
-+ value TEXT
-+ );
-+ }
-+
-+ # Should have root page, leaf page, and 2 overflow pages, because
-+ # length(value) is more than 2x page_size.
-+ execsql {
-+ PRAGMA page_count;
-+ PRAGMA page_size;
-+ SELECT rowid, TYPEOF(value), length(value), value FROM overflow_recover;
-+ }
-+} [list 4 1024 1 text [string length $lorem] $lorem]
-+
-+# No overflow. [1024-35 == 990, overhead of 1-byte rowid, 2-byte
-+# record length, 1-byte header length, 2-byte field type.]
-+set substr [string range $lorem 0 985]
-+do_test recover-overflow-1.1 {
-+ db eval {
-+ DROP TABLE IF EXISTS overflow;
-+ CREATE TABLE overflow (value TEXT);
-+ INSERT INTO overflow VALUES ($substr);
-+
-+ DROP TABLE IF EXISTS overflow_recover;
-+ CREATE VIRTUAL TABLE temp.overflow_recover USING recover(
-+ overflow,
-+ value TEXT
-+ );
-+ }
-+
-+ # Trim to remove excess pages from prior tests.
-+ db eval {VACUUM}
-+
-+ execsql {
-+ PRAGMA page_count;
-+ PRAGMA page_size;
-+ SELECT rowid, TYPEOF(value), length(value), value FROM overflow_recover;
-+ }
-+} [list 2 1024 1 text [string length $substr] $substr]
-+
-+# One byte of overflow.
-+set substr [string range $lorem 0 986]
-+do_test recover-overflow-1.2 {
-+ db eval {
-+ DROP TABLE IF EXISTS overflow;
-+ CREATE TABLE overflow (value TEXT);
-+ INSERT INTO overflow VALUES ($substr);
-+
-+ DROP TABLE IF EXISTS overflow_recover;
-+ CREATE VIRTUAL TABLE temp.overflow_recover USING recover(
-+ overflow,
-+ value TEXT
-+ );
-+ }
-+
-+ # Trim to remove excess pages from prior tests.
-+ db eval {VACUUM}
-+
-+ execsql {
-+ PRAGMA page_count;
-+ PRAGMA page_size;
-+ SELECT rowid, TYPEOF(value), length(value), value FROM overflow_recover;
-+ }
-+} [list 3 1024 1 text [string length $substr] $substr]
-+
-+# One full overflow page, plus maxLocal in-leaf. [985+1020]
-+set substr [string range $lorem 0 2005]
-+do_test recover-overflow-1.3 {
-+ db eval {
-+ DROP TABLE IF EXISTS overflow;
-+ CREATE TABLE overflow (value TEXT);
-+ INSERT INTO overflow VALUES ($substr);
-+
-+ DROP TABLE IF EXISTS overflow_recover;
-+ CREATE VIRTUAL TABLE temp.overflow_recover USING recover(
-+ overflow,
-+ value TEXT
-+ );
-+ }
-+
-+ # Trim to remove excess pages from prior tests.
-+ db eval {VACUUM}
-+
-+ execsql {
-+ PRAGMA page_count;
-+ PRAGMA page_size;
-+ SELECT rowid, TYPEOF(value), length(value), value FROM overflow_recover;
-+ }
-+} [list 3 1024 1 text [string length $substr] $substr]
-+
-+# Overflow to a second overflow page.
-+set substr [string range $lorem 0 2006]
-+do_test recover-overflow-1.4 {
-+ db eval {
-+ DROP TABLE IF EXISTS overflow;
-+ CREATE TABLE overflow (value TEXT);
-+ INSERT INTO overflow VALUES ($substr);
-+
-+ DROP TABLE IF EXISTS overflow_recover;
-+ CREATE VIRTUAL TABLE temp.overflow_recover USING recover(
-+ overflow,
-+ value TEXT
-+ );
-+ }
-+
-+ # Trim to remove excess pages from prior tests.
-+ db eval {VACUUM}
-+
-+ execsql {
-+ PRAGMA page_count;
-+ PRAGMA page_size;
-+ SELECT rowid, TYPEOF(value), length(value), value FROM overflow_recover;
-+ }
-+} [list 4 1024 1 text [string length $substr] $substr]
-+
-+finish_test
---
-2.18.0
-
diff --git a/chromium/third_party/sqlite/patches/0004-Custom-shell.c-helpers-to-load-Chromium-s-ICU-data.patch b/chromium/third_party/sqlite/patches/0004-Custom-shell.c-helpers-to-load-Chromium-s-ICU-data.patch
deleted file mode 100644
index 932b65a109b..00000000000
--- a/chromium/third_party/sqlite/patches/0004-Custom-shell.c-helpers-to-load-Chromium-s-ICU-data.patch
+++ /dev/null
@@ -1,145 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: "tc@google.com" <tc@google.com>
-Date: Tue, 6 Jan 2009 22:39:41 +0000
-Subject: [PATCH 4/6] Custom shell.c helpers to load Chromium's ICU data.
-
-History uses fts3 with an icu-based segmenter. These changes allow building a
-sqlite3 binary for Linux or Windows which can read those files.
-
-Original review URL: https://codereview.chromium.org/42250
----
- third_party/sqlite/src/Makefile.linux-gcc | 7 +++++
- third_party/sqlite/src/main.mk | 2 +-
- third_party/sqlite/src/src/shell.c.in | 10 ++++++
- third_party/sqlite/src/src/shell_icu_linux.c | 27 +++++++++++++++++
- third_party/sqlite/src/src/shell_icu_win.c | 32 ++++++++++++++++++++
- 5 files changed, 77 insertions(+), 1 deletion(-)
- create mode 100644 third_party/sqlite/src/src/shell_icu_linux.c
- create mode 100644 third_party/sqlite/src/src/shell_icu_win.c
-
-diff --git a/third_party/sqlite/src/Makefile.linux-gcc b/third_party/sqlite/src/Makefile.linux-gcc
-index 62d029430803..a37d41a0099d 100644
---- a/third_party/sqlite/src/Makefile.linux-gcc
-+++ b/third_party/sqlite/src/Makefile.linux-gcc
-@@ -77,6 +77,13 @@ OPTS += -DSQLITE_MEMDEBUG=1
- # TODO(shess) I can't see why I need this setting.
- OPTS += -DOS_UNIX=1
-
-+# Support for loading Chromium ICU data in sqlite3.
-+ifeq ($(shell uname -s),Darwin)
-+SHELL_ICU =
-+else
-+SHELL_ICU = $(TOP)/src/shell_icu_linux.c -licuuc
-+endif
-+
- #### The suffix to add to executable files. ".exe" for windows.
- # Nothing for unix.
- #
-diff --git a/third_party/sqlite/src/main.mk b/third_party/sqlite/src/main.mk
-index 9b50874926dc..40ab267ec72c 100644
---- a/third_party/sqlite/src/main.mk
-+++ b/third_party/sqlite/src/main.mk
-@@ -549,7 +549,7 @@ libsqlite3.a: $(LIBOBJ)
-
- sqlite3$(EXE): shell.c libsqlite3.a sqlite3.h
- $(TCCX) $(READLINE_FLAGS) -o sqlite3$(EXE) $(SHELL_OPT) \
-- shell.c libsqlite3.a $(LIBREADLINE) $(TLIBS) $(THREADLIB)
-+ shell.c $(SHELL_ICU) libsqlite3.a $(LIBREADLINE) $(TLIBS) $(THREADLIB)
-
- sqldiff$(EXE): $(TOP)/tool/sqldiff.c sqlite3.c sqlite3.h
- $(TCCX) -o sqldiff$(EXE) -DSQLITE_THREADSAFE=0 \
-diff --git a/third_party/sqlite/src/src/shell.c.in b/third_party/sqlite/src/src/shell.c.in
-index 0007d984d045..b13551dc61f2 100644
---- a/third_party/sqlite/src/src/shell.c.in
-+++ b/third_party/sqlite/src/src/shell.c.in
-@@ -8555,6 +8555,16 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){
- }
- #endif
-
-+ /* Begin evanm patch. */
-+#if !defined(__APPLE__)
-+ extern int sqlite_shell_init_icu();
-+ if( !sqlite_shell_init_icu() ){
-+ fprintf(stderr, "%s: warning: couldn't find icudt38.dll; "
-+ "queries against ICU FTS tables will fail.\n", argv[0]);
-+ }
-+#endif /* !defined(__APPLE__) */
-+ /* End evanm patch. */
-+
- /* Do an initial pass through the command-line argument to locate
- ** the name of the database file, the name of the initialization file,
- ** the size of the alternative malloc heap,
-diff --git a/third_party/sqlite/src/src/shell_icu_linux.c b/third_party/sqlite/src/src/shell_icu_linux.c
-new file mode 100644
-index 000000000000..4ad0e42d2293
---- /dev/null
-+++ b/third_party/sqlite/src/src/shell_icu_linux.c
-@@ -0,0 +1,27 @@
-+/* Copyright 2007 Google Inc. All Rights Reserved.
-+**/
-+
-+#include <limits.h>
-+#include <unistd.h>
-+#include "unicode/putil.h"
-+#include "unicode/udata.h"
-+
-+/*
-+** This function attempts to load the ICU data tables from a data file.
-+** Returns 0 on failure, nonzero on success.
-+** This a hack job of icu_utils.cc:Initialize(). It's Chrome-specific code.
-+*/
-+int sqlite_shell_init_icu() {
-+ char bin_dir[PATH_MAX + 1];
-+ int bin_dir_size = readlink("/proc/self/exe", bin_dir, PATH_MAX);
-+ if (bin_dir_size < 0 || bin_dir_size > PATH_MAX)
-+ return 0;
-+ bin_dir[bin_dir_size] = 0;;
-+
-+ u_setDataDirectory(bin_dir);
-+ // Only look for the packaged data file;
-+ // the default behavior is to look for individual files.
-+ UErrorCode err = U_ZERO_ERROR;
-+ udata_setFileAccess(UDATA_ONLY_PACKAGES, &err);
-+ return err == U_ZERO_ERROR;
-+}
-diff --git a/third_party/sqlite/src/src/shell_icu_win.c b/third_party/sqlite/src/src/shell_icu_win.c
-new file mode 100644
-index 000000000000..67ebbf4fbdb4
---- /dev/null
-+++ b/third_party/sqlite/src/src/shell_icu_win.c
-@@ -0,0 +1,32 @@
-+/* Copyright 2011 Google Inc. All Rights Reserved.
-+**/
-+
-+#include <windows.h>
-+#include "unicode/udata.h"
-+
-+/*
-+** This function attempts to load the ICU data tables from a DLL.
-+** Returns 0 on failure, nonzero on success.
-+** This a hack job of icu_utils.cc:Initialize(). It's Chrome-specific code.
-+*/
-+
-+#define ICU_DATA_SYMBOL "icudt" U_ICU_VERSION_SHORT "_dat"
-+int sqlite_shell_init_icu() {
-+ HMODULE module;
-+ FARPROC addr;
-+ UErrorCode err;
-+
-+ // Chrome dropped U_ICU_VERSION_SHORT from the icu data dll name.
-+ module = LoadLibrary(L"icudt.dll");
-+ if (!module)
-+ return 0;
-+
-+ addr = GetProcAddress(module, ICU_DATA_SYMBOL);
-+ if (!addr)
-+ return 0;
-+
-+ err = U_ZERO_ERROR;
-+ udata_setCommonData(addr, &err);
-+
-+ return 1;
-+}
---
-2.18.0
-
diff --git a/chromium/third_party/sqlite/patches/0004-fts3-Disable-fts3_tokenizer-and-fts4.patch b/chromium/third_party/sqlite/patches/0004-fts3-Disable-fts3_tokenizer-and-fts4.patch
index 13001c4210b..e77c9494f8c 100644
--- a/chromium/third_party/sqlite/patches/0004-fts3-Disable-fts3_tokenizer-and-fts4.patch
+++ b/chromium/third_party/sqlite/patches/0004-fts3-Disable-fts3_tokenizer-and-fts4.patch
@@ -1,7 +1,7 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Scott Hess <shess@chromium.org>
Date: Tue, 16 Dec 2014 13:02:27 -0800
-Subject: [PATCH 04/17] [fts3] Disable fts3_tokenizer and fts4.
+Subject: [PATCH 04/40] [fts3] Disable fts3_tokenizer and fts4.
fts3_tokenizer allows a SQLite user to specify a pointer to call as a
function, which has obvious sercurity implications. Disable fts4 until
diff --git a/chromium/third_party/sqlite/patches/0005-fts3-Disable-fts3_tokenizer-and-fts4.patch b/chromium/third_party/sqlite/patches/0005-fts3-Disable-fts3_tokenizer-and-fts4.patch
deleted file mode 100644
index 922a41fd0fc..00000000000
--- a/chromium/third_party/sqlite/patches/0005-fts3-Disable-fts3_tokenizer-and-fts4.patch
+++ /dev/null
@@ -1,60 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Scott Hess <shess@chromium.org>
-Date: Tue, 16 Dec 2014 13:02:27 -0800
-Subject: [PATCH 5/6] [fts3] Disable fts3_tokenizer and fts4.
-
-fts3_tokenizer allows a SQLite user to specify a pointer to call as a
-function, which has obvious sercurity implications. Disable fts4 until
-someone explicitly decides to own support for it. Disable fts3tokenize
-virtual table until someone explicitly decides to own support for it.
-
-No original review URL because this was part of the initial Chromium commit.
----
- third_party/sqlite/src/ext/fts3/fts3.c | 9 +++++++++
- 1 file changed, 9 insertions(+)
-
-diff --git a/third_party/sqlite/src/ext/fts3/fts3.c b/third_party/sqlite/src/ext/fts3/fts3.c
-index 44d9e20cc667..ef69a7b18681 100644
---- a/third_party/sqlite/src/ext/fts3/fts3.c
-+++ b/third_party/sqlite/src/ext/fts3/fts3.c
-@@ -287,6 +287,7 @@
- ** query logic likewise merges doclists so that newer data knocks out
- ** older data.
- */
-+#define CHROMIUM_FTS3_CHANGES 1
-
- #include "fts3Int.h"
- #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)
-@@ -3988,7 +3989,11 @@ int sqlite3Fts3Init(sqlite3 *db){
- ** module with sqlite.
- */
- if( SQLITE_OK==rc
-+#if CHROMIUM_FTS3_CHANGES && !SQLITE_TEST
-+ /* fts3_tokenizer() disabled for security reasons. */
-+#else
- && SQLITE_OK==(rc = sqlite3Fts3InitHashTable(db, pHash, "fts3_tokenizer"))
-+#endif
- && SQLITE_OK==(rc = sqlite3_overload_function(db, "snippet", -1))
- && SQLITE_OK==(rc = sqlite3_overload_function(db, "offsets", 1))
- && SQLITE_OK==(rc = sqlite3_overload_function(db, "matchinfo", 1))
-@@ -3998,6 +4003,9 @@ int sqlite3Fts3Init(sqlite3 *db){
- rc = sqlite3_create_module_v2(
- db, "fts3", &fts3Module, (void *)pHash, hashDestroy
- );
-+#if CHROMIUM_FTS3_CHANGES && !SQLITE_TEST
-+ /* Disable fts4 and tokenizer vtab pending review. */
-+#else
- if( rc==SQLITE_OK ){
- rc = sqlite3_create_module_v2(
- db, "fts4", &fts3Module, (void *)pHash, 0
-@@ -4006,6 +4014,7 @@ int sqlite3Fts3Init(sqlite3 *db){
- if( rc==SQLITE_OK ){
- rc = sqlite3Fts3InitTok(db, (void *)pHash);
- }
-+#endif
- return rc;
- }
-
---
-2.18.0
-
diff --git a/chromium/third_party/sqlite/patches/0005-fuchsia-Use-dot-file-locking-for-sqlite.patch b/chromium/third_party/sqlite/patches/0005-fuchsia-Use-dot-file-locking-for-sqlite.patch
index defb867ea9a..8f4f6e01db9 100644
--- a/chromium/third_party/sqlite/patches/0005-fuchsia-Use-dot-file-locking-for-sqlite.patch
+++ b/chromium/third_party/sqlite/patches/0005-fuchsia-Use-dot-file-locking-for-sqlite.patch
@@ -1,7 +1,7 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Scott Graham <scottmg@chromium.org>
Date: Mon, 11 Sep 2017 13:37:46 -0700
-Subject: [PATCH 05/17] fuchsia: Use dot-file locking for sqlite
+Subject: [PATCH 05/40] fuchsia: Use dot-file locking for sqlite
---
third_party/sqlite/src/src/os_unix.c | 4 ++++
diff --git a/chromium/third_party/sqlite/patches/0006-Fix-dbfuzz2-for-Clusterfuzz.patch b/chromium/third_party/sqlite/patches/0006-Fix-dbfuzz2-for-Clusterfuzz.patch
index a6ec51f7e2b..c5cd6153bd8 100644
--- a/chromium/third_party/sqlite/patches/0006-Fix-dbfuzz2-for-Clusterfuzz.patch
+++ b/chromium/third_party/sqlite/patches/0006-Fix-dbfuzz2-for-Clusterfuzz.patch
@@ -1,7 +1,7 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Matthew Denton <mpdenton@chromium.org>
Date: Fri, 7 Dec 2018 14:49:36 -0700
-Subject: [PATCH 06/17] Fix dbfuzz2 for Clusterfuzz.
+Subject: [PATCH 06/40] Fix dbfuzz2 for Clusterfuzz.
This backports https://www.sqlite.org/src/info/9ad796a8822f1b7e
---
diff --git a/chromium/third_party/sqlite/patches/0006-fuchsia-Use-dot-file-locking-for-sqlite.patch b/chromium/third_party/sqlite/patches/0006-fuchsia-Use-dot-file-locking-for-sqlite.patch
deleted file mode 100644
index c8aa08dec5d..00000000000
--- a/chromium/third_party/sqlite/patches/0006-fuchsia-Use-dot-file-locking-for-sqlite.patch
+++ /dev/null
@@ -1,27 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Scott Graham <scottmg@chromium.org>
-Date: Mon, 11 Sep 2017 13:37:46 -0700
-Subject: [PATCH 6/6] fuchsia: Use dot-file locking for sqlite
-
----
- third_party/sqlite/src/src/os_unix.c | 4 ++++
- 1 file changed, 4 insertions(+)
-
-diff --git a/third_party/sqlite/src/src/os_unix.c b/third_party/sqlite/src/src/os_unix.c
-index d0e1c39bc4b8..d0736e0a63de 100644
---- a/third_party/sqlite/src/src/os_unix.c
-+++ b/third_party/sqlite/src/src/os_unix.c
-@@ -7873,6 +7873,10 @@ int sqlite3_os_init(void){
- UNIXVFS("unix", autolockIoFinder ),
- #elif OS_VXWORKS
- UNIXVFS("unix", vxworksIoFinder ),
-+#elif __Fuchsia__
-+ /* None of the system calls for other exclusion methods are currently
-+ ** implemented on Fuchsia, so use simple dot-file locking for now. */
-+ UNIXVFS("unix", dotlockIoFinder ),
- #else
- UNIXVFS("unix", posixIoFinder ),
- #endif
---
-2.18.0
-
diff --git a/chromium/third_party/sqlite/patches/0007-Allow-auto-vacuum-to-work-with-chunks.patch b/chromium/third_party/sqlite/patches/0007-Allow-auto-vacuum-to-work-with-chunks.patch
deleted file mode 100644
index c2f3a2f2271..00000000000
--- a/chromium/third_party/sqlite/patches/0007-Allow-auto-vacuum-to-work-with-chunks.patch
+++ /dev/null
@@ -1,296 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Scott Hess <shess@chromium.org>
-Date: Thu, 2 Mar 2017 15:23:09 -0800
-Subject: [PATCH 07/10] Allow auto-vacuum to work with chunks.
-
-SQLITE_FCNTL_CHUNK_SIZE can advise the VFS to resize files in quantum
-amounts, to reduce fragmentation from tiny appends. This change allows
-a new PRAGMA auto_vacuum_slack_pages to provide auto_vacuum with a hint
-to only rearrange pages when an entire quantum can be released.
-
-When rebasing this patch, first ignore the conflicts in src/pragma.h,
-and fix all the other conflicts. Then run the commands below (in
-third_party/sqlite) to re-generate src/pragma.h.
-tclsh src/tool/mkpragmatab.tcl
-find src/ -type f -iname "*.h" -exec \
- $GNU_SED --in-place 's/[[:space:]]\+$//' {} \+
-
-BUG=698010
----
- third_party/sqlite/src/src/btree.c | 56 +++++++++++-
- third_party/sqlite/src/src/btree.h | 2 +
- third_party/sqlite/src/src/btreeInt.h | 1 +
- third_party/sqlite/src/src/pragma.c | 21 +++++
- third_party/sqlite/src/src/pragma.h | 96 +++++++++++----------
- third_party/sqlite/src/tool/mkpragmatab.tcl | 4 +
- 6 files changed, 134 insertions(+), 46 deletions(-)
-
-diff --git a/third_party/sqlite/src/src/btree.c b/third_party/sqlite/src/src/btree.c
-index b125859bf570..3fa8f88f1465 100644
---- a/third_party/sqlite/src/src/btree.c
-+++ b/third_party/sqlite/src/src/btree.c
-@@ -2980,6 +2980,46 @@ static void setDefaultSyncFlag(BtShared *pBt, u8 safety_level){
- static int newDatabase(BtShared*);
-
-
-+/*
-+** Change the 'auto-vacuum-slack-pages' property of the database. If auto vacuum
-+** is enabled, this is the number of chunks of slack to allow before
-+** automatically running an incremental vacuum.
-+*/
-+int sqlite3BtreeSetAutoVacuumSlackPages(Btree *p, int autoVacuumSlack){
-+#ifdef SQLITE_OMIT_AUTOVACUUM
-+ return SQLITE_READONLY;
-+#else
-+ BtShared *pBt = p->pBt;
-+ int rc = SQLITE_OK;
-+ u8 avs = (u8)autoVacuumSlack;
-+ if( autoVacuumSlack>avs ){
-+ avs = 0xFF;
-+ }
-+
-+ sqlite3BtreeEnter(p);
-+ pBt->autoVacuumSlack = avs;
-+ sqlite3BtreeLeave(p);
-+ return rc;
-+#endif
-+}
-+
-+/*
-+** Return the value of the 'auto-vacuum-slack-pages' property.
-+*/
-+int sqlite3BtreeGetAutoVacuumSlackPages(Btree *p){
-+#ifdef SQLITE_OMIT_AUTOVACUUM
-+ return 0;
-+#else
-+ int rc = 0;
-+ sqlite3BtreeEnter(p);
-+ if( p->pBt->autoVacuum!=0 ){
-+ rc = p->pBt->autoVacuumSlack;
-+ }
-+ sqlite3BtreeLeave(p);
-+ return rc;
-+#endif
-+}
-+
- /*
- ** Get a reference to pPage1 of the database file. This will
- ** also acquire a readlock on that file.
-@@ -3828,13 +3868,27 @@ int sqlite3BtreeIncrVacuum(Btree *p){
- */
- static int autoVacuumCommit(BtShared *pBt){
- int rc = SQLITE_OK;
-+ int bShouldVacuum = pBt->autoVacuum && !pBt->incrVacuum;
- Pager *pPager = pBt->pPager;
- VVA_ONLY( int nRef = sqlite3PagerRefcount(pPager); )
-
- assert( sqlite3_mutex_held(pBt->mutex) );
- invalidateAllOverflowCache(pBt);
- assert(pBt->autoVacuum);
-- if( !pBt->incrVacuum ){
-+ if( bShouldVacuum && pBt->autoVacuumSlack ){
-+ Pgno nOrig; /* Database size before freeing */
-+ Pgno nFree; /* Number of pages on the freelist initially */
-+
-+ nOrig = btreePagecount(pBt);
-+ nFree = get4byte(&pBt->pPage1->aData[36]);
-+ bShouldVacuum =
-+ (nOrig-nFree-1)/pBt->autoVacuumSlack < (nOrig-1)/pBt->autoVacuumSlack;
-+ /* TODO: When integrating this test with the following code, contrive to
-+ ** trim to the integral chunk boundary, rather than trimming the entire free
-+ ** list.
-+ */
-+ }
-+ if( bShouldVacuum ){
- Pgno nFin; /* Number of pages in database after autovacuuming */
- Pgno nFree; /* Number of pages on the freelist initially */
- Pgno iFree; /* The next page to be freed */
-diff --git a/third_party/sqlite/src/src/btree.h b/third_party/sqlite/src/src/btree.h
-index e4bd09c7e727..83307a95ad3f 100644
---- a/third_party/sqlite/src/src/btree.h
-+++ b/third_party/sqlite/src/src/btree.h
-@@ -78,6 +78,8 @@ int sqlite3BtreeGetOptimalReserve(Btree*);
- int sqlite3BtreeGetReserveNoMutex(Btree *p);
- int sqlite3BtreeSetAutoVacuum(Btree *, int);
- int sqlite3BtreeGetAutoVacuum(Btree *);
-+int sqlite3BtreeSetAutoVacuumSlackPages(Btree *, int);
-+int sqlite3BtreeGetAutoVacuumSlackPages(Btree *);
- int sqlite3BtreeBeginTrans(Btree*,int,int*);
- int sqlite3BtreeCommitPhaseOne(Btree*, const char *zMaster);
- int sqlite3BtreeCommitPhaseTwo(Btree*, int);
-diff --git a/third_party/sqlite/src/src/btreeInt.h b/third_party/sqlite/src/src/btreeInt.h
-index 8fe8e280fe5f..88f3b437b8ea 100644
---- a/third_party/sqlite/src/src/btreeInt.h
-+++ b/third_party/sqlite/src/src/btreeInt.h
-@@ -412,6 +412,7 @@ struct BtShared {
- u8 openFlags; /* Flags to sqlite3BtreeOpen() */
- #ifndef SQLITE_OMIT_AUTOVACUUM
- u8 autoVacuum; /* True if auto-vacuum is enabled */
-+ u8 autoVacuumSlack; /* Optional pages of slack for auto-vacuum */
- u8 incrVacuum; /* True if incr-vacuum is enabled */
- u8 bDoTruncate; /* True to truncate db on commit */
- #endif
-diff --git a/third_party/sqlite/src/src/pragma.c b/third_party/sqlite/src/src/pragma.c
-index 6e026557d561..472fca7ee699 100644
---- a/third_party/sqlite/src/src/pragma.c
-+++ b/third_party/sqlite/src/src/pragma.c
-@@ -756,6 +756,27 @@ void sqlite3Pragma(
- }
- #endif
-
-+ /*
-+ ** PRAGMA [schema.]auto_vacuum_slack_pages(N)
-+ **
-+ ** Control chunk size of auto-vacuum.
-+ */
-+#ifndef SQLITE_OMIT_AUTOVACUUM
-+ case PragTyp_AUTO_VACUUM_SLACK_PAGES: {
-+ Btree *pBt = pDb->pBt;
-+ assert( pBt!=0 );
-+ if( !zRight ){
-+ returnSingleInt(v, sqlite3BtreeGetAutoVacuumSlackPages(pBt));
-+ }else{
-+ int nPages = 8;
-+ if( sqlite3GetInt32(zRight, &nPages) ){
-+ sqlite3BtreeSetAutoVacuumSlackPages(pBt, nPages);
-+ }
-+ }
-+ break;
-+ }
-+#endif
-+
- #ifndef SQLITE_OMIT_PAGER_PRAGMAS
- /*
- ** PRAGMA [schema.]cache_size
-diff --git a/third_party/sqlite/src/src/pragma.h b/third_party/sqlite/src/src/pragma.h
-index 826516202e41..970092f1cd8d 100644
---- a/third_party/sqlite/src/src/pragma.h
-+++ b/third_party/sqlite/src/src/pragma.h
-@@ -7,51 +7,52 @@
- /* The various pragma types */
- #define PragTyp_HEADER_VALUE 0
- #define PragTyp_AUTO_VACUUM 1
--#define PragTyp_FLAG 2
--#define PragTyp_BUSY_TIMEOUT 3
--#define PragTyp_CACHE_SIZE 4
--#define PragTyp_CACHE_SPILL 5
--#define PragTyp_CASE_SENSITIVE_LIKE 6
--#define PragTyp_COLLATION_LIST 7
--#define PragTyp_COMPILE_OPTIONS 8
--#define PragTyp_DATA_STORE_DIRECTORY 9
--#define PragTyp_DATABASE_LIST 10
--#define PragTyp_DEFAULT_CACHE_SIZE 11
--#define PragTyp_ENCODING 12
--#define PragTyp_FOREIGN_KEY_CHECK 13
--#define PragTyp_FOREIGN_KEY_LIST 14
--#define PragTyp_FUNCTION_LIST 15
--#define PragTyp_INCREMENTAL_VACUUM 16
--#define PragTyp_INDEX_INFO 17
--#define PragTyp_INDEX_LIST 18
--#define PragTyp_INTEGRITY_CHECK 19
--#define PragTyp_JOURNAL_MODE 20
--#define PragTyp_JOURNAL_SIZE_LIMIT 21
--#define PragTyp_LOCK_PROXY_FILE 22
--#define PragTyp_LOCKING_MODE 23
--#define PragTyp_PAGE_COUNT 24
--#define PragTyp_MMAP_SIZE 25
--#define PragTyp_MODULE_LIST 26
--#define PragTyp_OPTIMIZE 27
--#define PragTyp_PAGE_SIZE 28
--#define PragTyp_PRAGMA_LIST 29
--#define PragTyp_SECURE_DELETE 30
--#define PragTyp_SHRINK_MEMORY 31
--#define PragTyp_SOFT_HEAP_LIMIT 32
--#define PragTyp_SYNCHRONOUS 33
--#define PragTyp_TABLE_INFO 34
--#define PragTyp_TEMP_STORE 35
--#define PragTyp_TEMP_STORE_DIRECTORY 36
--#define PragTyp_THREADS 37
--#define PragTyp_WAL_AUTOCHECKPOINT 38
--#define PragTyp_WAL_CHECKPOINT 39
--#define PragTyp_ACTIVATE_EXTENSIONS 40
--#define PragTyp_HEXKEY 41
--#define PragTyp_KEY 42
--#define PragTyp_REKEY 43
--#define PragTyp_LOCK_STATUS 44
--#define PragTyp_PARSER_TRACE 45
--#define PragTyp_STATS 46
-+#define PragTyp_AUTO_VACUUM_SLACK_PAGES 2
-+#define PragTyp_FLAG 3
-+#define PragTyp_BUSY_TIMEOUT 4
-+#define PragTyp_CACHE_SIZE 5
-+#define PragTyp_CACHE_SPILL 6
-+#define PragTyp_CASE_SENSITIVE_LIKE 7
-+#define PragTyp_COLLATION_LIST 8
-+#define PragTyp_COMPILE_OPTIONS 9
-+#define PragTyp_DATA_STORE_DIRECTORY 10
-+#define PragTyp_DATABASE_LIST 11
-+#define PragTyp_DEFAULT_CACHE_SIZE 12
-+#define PragTyp_ENCODING 13
-+#define PragTyp_FOREIGN_KEY_CHECK 14
-+#define PragTyp_FOREIGN_KEY_LIST 15
-+#define PragTyp_FUNCTION_LIST 16
-+#define PragTyp_INCREMENTAL_VACUUM 17
-+#define PragTyp_INDEX_INFO 18
-+#define PragTyp_INDEX_LIST 19
-+#define PragTyp_INTEGRITY_CHECK 20
-+#define PragTyp_JOURNAL_MODE 21
-+#define PragTyp_JOURNAL_SIZE_LIMIT 22
-+#define PragTyp_LOCK_PROXY_FILE 23
-+#define PragTyp_LOCKING_MODE 24
-+#define PragTyp_PAGE_COUNT 25
-+#define PragTyp_MMAP_SIZE 26
-+#define PragTyp_MODULE_LIST 27
-+#define PragTyp_OPTIMIZE 28
-+#define PragTyp_PAGE_SIZE 29
-+#define PragTyp_PRAGMA_LIST 30
-+#define PragTyp_SECURE_DELETE 31
-+#define PragTyp_SHRINK_MEMORY 32
-+#define PragTyp_SOFT_HEAP_LIMIT 33
-+#define PragTyp_SYNCHRONOUS 34
-+#define PragTyp_TABLE_INFO 35
-+#define PragTyp_TEMP_STORE 36
-+#define PragTyp_TEMP_STORE_DIRECTORY 37
-+#define PragTyp_THREADS 38
-+#define PragTyp_WAL_AUTOCHECKPOINT 39
-+#define PragTyp_WAL_CHECKPOINT 40
-+#define PragTyp_ACTIVATE_EXTENSIONS 41
-+#define PragTyp_HEXKEY 42
-+#define PragTyp_KEY 43
-+#define PragTyp_REKEY 44
-+#define PragTyp_LOCK_STATUS 45
-+#define PragTyp_PARSER_TRACE 46
-+#define PragTyp_STATS 47
-
- /* Property flags associated with various pragma. */
- #define PragFlg_NeedSchema 0x01 /* Force schema load before running */
-@@ -152,6 +153,11 @@ static const PragmaName aPragmaName[] = {
- /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq|PragFlg_NoColumns1,
- /* ColNames: */ 0, 0,
- /* iArg: */ 0 },
-+ {/* zName: */ "auto_vacuum_slack_pages",
-+ /* ePragTyp: */ PragTyp_AUTO_VACUUM_SLACK_PAGES,
-+ /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq|PragFlg_NoColumns1,
-+ /* ColNames: */ 0, 0,
-+ /* iArg: */ 0 },
- #endif
- #if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
- #if !defined(SQLITE_OMIT_AUTOMATIC_INDEX)
-diff --git a/third_party/sqlite/src/tool/mkpragmatab.tcl b/third_party/sqlite/src/tool/mkpragmatab.tcl
-index 83a85db9d6fd..6ed2dfc8e846 100644
---- a/third_party/sqlite/src/tool/mkpragmatab.tcl
-+++ b/third_party/sqlite/src/tool/mkpragmatab.tcl
-@@ -387,6 +387,10 @@ set pragma_def {
- TYPE: FLAG
- ARG: SQLITE_LegacyAlter
- IF: !defined(SQLITE_OMIT_FLAG_PRAGMAS)
-+
-+ NAME: auto_vacuum_slack_pages
-+ FLAG: NeedSchema Result0 SchemaReq NoColumns1
-+ IF: !defined(SQLITE_OMIT_AUTOVACUUM)
- }
-
- # Open the output file
---
-2.18.0
-
diff --git a/chromium/third_party/sqlite/patches/0007-Fix-the-Makefile-so-that-it-honors-CFLAGS-when-build.patch b/chromium/third_party/sqlite/patches/0007-Fix-the-Makefile-so-that-it-honors-CFLAGS-when-build.patch
index a20f7d621fb..8886eabfca3 100644
--- a/chromium/third_party/sqlite/patches/0007-Fix-the-Makefile-so-that-it-honors-CFLAGS-when-build.patch
+++ b/chromium/third_party/sqlite/patches/0007-Fix-the-Makefile-so-that-it-honors-CFLAGS-when-build.patch
@@ -1,7 +1,7 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Victor Costan <pwnall@chromium.org>
Date: Wed, 19 Dec 2018 18:22:15 -0800
-Subject: [PATCH 07/17] Fix the Makefile so that it honors CFLAGS when building
+Subject: [PATCH 07/40] Fix the Makefile so that it honors CFLAGS when building
sessionfuzz.
This backports https://www.sqlite.org/src/info/54231ac4ca506e6c
diff --git a/chromium/third_party/sqlite/patches/0008-Adjustments-to-the-page-cache-to-try-to-avoid-harmle.patch b/chromium/third_party/sqlite/patches/0008-Adjustments-to-the-page-cache-to-try-to-avoid-harmle.patch
index 8960fc9c0dd..8d86320bf7e 100644
--- a/chromium/third_party/sqlite/patches/0008-Adjustments-to-the-page-cache-to-try-to-avoid-harmle.patch
+++ b/chromium/third_party/sqlite/patches/0008-Adjustments-to-the-page-cache-to-try-to-avoid-harmle.patch
@@ -1,7 +1,7 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Victor Costan <pwnall@chromium.org>
Date: Fri, 11 Jan 2019 02:01:53 -0800
-Subject: [PATCH 08/17] Adjustments to the page cache to try to avoid harmless
+Subject: [PATCH 08/40] Adjustments to the page cache to try to avoid harmless
TSAN warnings
This backports https://www.sqlite.org/src/info/383437be276719ac
diff --git a/chromium/third_party/sqlite/patches/0008-fuchsia-Use-dot-file-locking-for-sqlite.patch b/chromium/third_party/sqlite/patches/0008-fuchsia-Use-dot-file-locking-for-sqlite.patch
deleted file mode 100644
index 666e11e362b..00000000000
--- a/chromium/third_party/sqlite/patches/0008-fuchsia-Use-dot-file-locking-for-sqlite.patch
+++ /dev/null
@@ -1,27 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Scott Graham <scottmg@chromium.org>
-Date: Mon, 11 Sep 2017 13:37:46 -0700
-Subject: [PATCH 08/10] fuchsia: Use dot-file locking for sqlite
-
----
- third_party/sqlite/src/src/os_unix.c | 4 ++++
- 1 file changed, 4 insertions(+)
-
-diff --git a/third_party/sqlite/src/src/os_unix.c b/third_party/sqlite/src/src/os_unix.c
-index ebae2eb47043..96802e62d7cb 100644
---- a/third_party/sqlite/src/src/os_unix.c
-+++ b/third_party/sqlite/src/src/os_unix.c
-@@ -7866,6 +7866,10 @@ int sqlite3_os_init(void){
- UNIXVFS("unix", autolockIoFinder ),
- #elif OS_VXWORKS
- UNIXVFS("unix", vxworksIoFinder ),
-+#elif __Fuchsia__
-+ /* None of the system calls for other exclusion methods are currently
-+ ** implemented on Fuchsia, so use simple dot-file locking for now. */
-+ UNIXVFS("unix", dotlockIoFinder ),
- #else
- UNIXVFS("unix", posixIoFinder ),
- #endif
---
-2.18.0
-
diff --git a/chromium/third_party/sqlite/patches/0009-Fix-ossfuzz.c-to-compile-and-run-with-our-config.patch b/chromium/third_party/sqlite/patches/0009-Fix-ossfuzz.c-to-compile-and-run-with-our-config.patch
deleted file mode 100644
index 4333b190e45..00000000000
--- a/chromium/third_party/sqlite/patches/0009-Fix-ossfuzz.c-to-compile-and-run-with-our-config.patch
+++ /dev/null
@@ -1,44 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Matthew Denton <mpdenton@chromium.org>
-Date: Fri, 16 Nov 2018 10:32:17 -0800
-Subject: [PATCH 09/10] Fix ossfuzz.c to compile and run with our config
-
----
- third_party/sqlite/src/test/ossfuzz.c | 7 +++++++
- 1 file changed, 7 insertions(+)
-
-diff --git a/third_party/sqlite/src/test/ossfuzz.c b/third_party/sqlite/src/test/ossfuzz.c
-index a8a637f2ac85..7b69015129d9 100644
---- a/third_party/sqlite/src/test/ossfuzz.c
-+++ b/third_party/sqlite/src/test/ossfuzz.c
-@@ -30,6 +30,7 @@ void ossfuzz_set_debug_flags(unsigned x){
- mDebug = x;
- }
-
-+#ifndef SQLITE_OMIT_PROGRESS_CALLBACK
- /* Return the current real-world time in milliseconds since the
- ** Julian epoch (-4714-11-24).
- */
-@@ -46,6 +47,7 @@ static sqlite3_int64 timeOfDay(void){
- }
- return t;
- }
-+#endif
-
- /* An instance of the following object is passed by pointer as the
- ** client data to various callbacks.
-@@ -133,6 +135,11 @@ int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
- uSelector = 0xfd;
- }
-
-+#ifdef SQLITE_OMIT_AUTOINIT
-+ rc = sqlite3_initialize();
-+ if( rc ) return 0;
-+#endif
-+
- /* Open the database connection. Only use an in-memory database. */
- rc = sqlite3_open_v2("fuzz.db", &cx.db,
- SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_MEMORY, 0);
---
-2.18.0
-
diff --git a/chromium/third_party/sqlite/patches/0009-Remove-an-ALWAYS-from-a-branch-that-is-not-always-ta.patch b/chromium/third_party/sqlite/patches/0009-Remove-an-ALWAYS-from-a-branch-that-is-not-always-ta.patch
index 10a26d255c4..d5159f6edd3 100644
--- a/chromium/third_party/sqlite/patches/0009-Remove-an-ALWAYS-from-a-branch-that-is-not-always-ta.patch
+++ b/chromium/third_party/sqlite/patches/0009-Remove-an-ALWAYS-from-a-branch-that-is-not-always-ta.patch
@@ -1,7 +1,7 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Victor Costan <pwnall@chromium.org>
Date: Fri, 11 Jan 2019 02:26:10 -0800
-Subject: [PATCH 09/17] Remove an ALWAYS() from a branch that is not always
+Subject: [PATCH 09/40] Remove an ALWAYS() from a branch that is not always
taken.
This backports https://www.sqlite.org/src/info/5c7dab
diff --git a/chromium/third_party/sqlite/patches/0010-Backport-Windows-VFS-mmap-fix.patch b/chromium/third_party/sqlite/patches/0010-Backport-Windows-VFS-mmap-fix.patch
deleted file mode 100644
index 9c27972ec1f..00000000000
--- a/chromium/third_party/sqlite/patches/0010-Backport-Windows-VFS-mmap-fix.patch
+++ /dev/null
@@ -1,33 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Victor Costan <pwnall@chromium.org>
-Date: Fri, 23 Nov 2018 10:51:10 -0800
-Subject: [PATCH 10/10] Backport Windows VFS mmap fix
-
-Original change: https://www.sqlite.org/src/info/8576ccb479fc4b76
-
-Original change description:
-Make the winTruncate() method of the windows VFS be a no-op if there are
-outstanding references to the memory-mapped pages. Otherwise, memory
-might be deleted out from under those references when the file is
-remapped during the truncate operation.
-
-Bug: 897576
----
- third_party/sqlite/src/src/os_win.c | 1 +
- 1 file changed, 1 insertion(+)
-
-diff --git a/third_party/sqlite/src/src/os_win.c b/third_party/sqlite/src/src/os_win.c
-index dfefc4452f02..5cd28a20e427 100644
---- a/third_party/sqlite/src/src/os_win.c
-+++ b/third_party/sqlite/src/src/os_win.c
-@@ -2906,6 +2906,7 @@ static int winTruncate(sqlite3_file *id, sqlite3_int64 nByte){
- DWORD lastErrno;
- #if SQLITE_MAX_MMAP_SIZE>0
- sqlite3_int64 oldMmapSize;
-+ if( pFile->nFetchOut>0 ) return SQLITE_OK;
- #endif
-
- assert( pFile );
---
-2.18.0
-
diff --git a/chromium/third_party/sqlite/patches/0010-Fix-a-problem-with-nested-CTEs-with-the-same-table.patch b/chromium/third_party/sqlite/patches/0010-Fix-a-problem-with-nested-CTEs-with-the-same-table.patch
index 7277ec29a90..216d8ef8117 100644
--- a/chromium/third_party/sqlite/patches/0010-Fix-a-problem-with-nested-CTEs-with-the-same-table.patch
+++ b/chromium/third_party/sqlite/patches/0010-Fix-a-problem-with-nested-CTEs-with-the-same-table.patch
@@ -1,7 +1,7 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Victor Costan <pwnall@chromium.org>
Date: Fri, 11 Jan 2019 02:30:28 -0800
-Subject: [PATCH 10/17] Fix a problem with nested CTEs with the same table.
+Subject: [PATCH 10/40] Fix a problem with nested CTEs with the same table.
This backports https://www.sqlite.org/src/info/202dd033019dd274
diff --git a/chromium/third_party/sqlite/patches/0011-Fix-detection-of-self-referencing-rows-in-foreign-ke.patch b/chromium/third_party/sqlite/patches/0011-Fix-detection-of-self-referencing-rows-in-foreign-ke.patch
index 8c1148a1c12..878c4b23cae 100644
--- a/chromium/third_party/sqlite/patches/0011-Fix-detection-of-self-referencing-rows-in-foreign-ke.patch
+++ b/chromium/third_party/sqlite/patches/0011-Fix-detection-of-self-referencing-rows-in-foreign-ke.patch
@@ -1,7 +1,7 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Victor Costan <pwnall@chromium.org>
Date: Fri, 11 Jan 2019 03:45:18 -0800
-Subject: [PATCH 11/17] Fix detection of self-referencing rows in foreign key
+Subject: [PATCH 11/40] Fix detection of self-referencing rows in foreign key
processing.
This backports https://www.sqlite.org/src/info/16fff05347f42fe9
diff --git a/chromium/third_party/sqlite/patches/0012-Fix-a-segfault-caused-by-using-the-RAISE-function-in.patch b/chromium/third_party/sqlite/patches/0012-Fix-a-segfault-caused-by-using-the-RAISE-function-in.patch
index ec396585010..5f739802ad8 100644
--- a/chromium/third_party/sqlite/patches/0012-Fix-a-segfault-caused-by-using-the-RAISE-function-in.patch
+++ b/chromium/third_party/sqlite/patches/0012-Fix-a-segfault-caused-by-using-the-RAISE-function-in.patch
@@ -1,7 +1,7 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Victor Costan <pwnall@chromium.org>
Date: Fri, 11 Jan 2019 03:52:20 -0800
-Subject: [PATCH 12/17] Fix a segfault caused by using the RAISE function
+Subject: [PATCH 12/40] Fix a segfault caused by using the RAISE function
incorrectly.
This backports https://sqlite.org/src/info/ddf06db702761d66
diff --git a/chromium/third_party/sqlite/patches/0013-Fix-for-an-assert-that-could-be-false.patch b/chromium/third_party/sqlite/patches/0013-Fix-for-an-assert-that-could-be-false.patch
index 38703cc1004..d9e280440e7 100644
--- a/chromium/third_party/sqlite/patches/0013-Fix-for-an-assert-that-could-be-false.patch
+++ b/chromium/third_party/sqlite/patches/0013-Fix-for-an-assert-that-could-be-false.patch
@@ -1,7 +1,7 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Victor Costan <pwnall@chromium.org>
Date: Fri, 11 Jan 2019 04:18:45 -0800
-Subject: [PATCH 13/17] Fix for an assert() that could be false.
+Subject: [PATCH 13/40] Fix for an assert() that could be false.
This backports https://www.sqlite.org/src/info/23b62fb160d86dc9 /
https://www.sqlite.org/src/info/bc891ac6b62fe7d9
diff --git a/chromium/third_party/sqlite/patches/0014-Fix-another-problem-found-by-Matthew-Denton-s-new-fu.patch b/chromium/third_party/sqlite/patches/0014-Fix-another-problem-found-by-Matthew-Denton-s-new-fu.patch
index 47238268504..4b4c61a4d89 100644
--- a/chromium/third_party/sqlite/patches/0014-Fix-another-problem-found-by-Matthew-Denton-s-new-fu.patch
+++ b/chromium/third_party/sqlite/patches/0014-Fix-another-problem-found-by-Matthew-Denton-s-new-fu.patch
@@ -1,7 +1,7 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Victor Costan <pwnall@chromium.org>
Date: Fri, 11 Jan 2019 04:21:21 -0800
-Subject: [PATCH 14/17] Fix another problem found by Matthew Denton's new
+Subject: [PATCH 14/40] Fix another problem found by Matthew Denton's new
fuzzer.
This backports https://sqlite.org/src/info/2b690dbdffe144bd
diff --git a/chromium/third_party/sqlite/patches/0015-Report-a-new-corruption-case.patch b/chromium/third_party/sqlite/patches/0015-Report-a-new-corruption-case.patch
index bdc0f68cb8b..12ea8973467 100644
--- a/chromium/third_party/sqlite/patches/0015-Report-a-new-corruption-case.patch
+++ b/chromium/third_party/sqlite/patches/0015-Report-a-new-corruption-case.patch
@@ -1,7 +1,7 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Victor Costan <pwnall@chromium.org>
Date: Fri, 11 Jan 2019 12:15:27 -0800
-Subject: [PATCH 15/17] Report a new corruption case.
+Subject: [PATCH 15/40] Report a new corruption case.
This backports https://sqlite.org/src/info/cc42dd15100db28a
diff --git a/chromium/third_party/sqlite/patches/0016-Avoid-a-buffer-overread-in-ptrmapPutOvflPtr.patch b/chromium/third_party/sqlite/patches/0016-Avoid-a-buffer-overread-in-ptrmapPutOvflPtr.patch
index 19d46bd276d..a912e8b7b54 100644
--- a/chromium/third_party/sqlite/patches/0016-Avoid-a-buffer-overread-in-ptrmapPutOvflPtr.patch
+++ b/chromium/third_party/sqlite/patches/0016-Avoid-a-buffer-overread-in-ptrmapPutOvflPtr.patch
@@ -1,7 +1,7 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Victor Costan <pwnall@chromium.org>
Date: Fri, 11 Jan 2019 12:19:01 -0800
-Subject: [PATCH 16/17] Avoid a buffer overread in ptrmapPutOvflPtr().
+Subject: [PATCH 16/40] Avoid a buffer overread in ptrmapPutOvflPtr().
This backports https://sqlite.org/src/info/f8b781cf41800e9f
diff --git a/chromium/third_party/sqlite/patches/0017-Improved-detection-of-cell-corruption-in-sqlite3Vdbe.patch b/chromium/third_party/sqlite/patches/0017-Improved-detection-of-cell-corruption-in-sqlite3Vdbe.patch
index 5d0877f09a3..9417c68acb5 100644
--- a/chromium/third_party/sqlite/patches/0017-Improved-detection-of-cell-corruption-in-sqlite3Vdbe.patch
+++ b/chromium/third_party/sqlite/patches/0017-Improved-detection-of-cell-corruption-in-sqlite3Vdbe.patch
@@ -1,15 +1,15 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Victor Costan <pwnall@chromium.org>
Date: Fri, 11 Jan 2019 13:22:44 -0800
-Subject: [PATCH 17/17] Improved detection of cell corruption in
+Subject: [PATCH 17/40] Improved detection of cell corruption in
sqlite3VdbeRecordCompareWithSkip().
This backports https://www.sqlite.org/src/info/fa47f4c6589c431c
Bug: 915348
---
- third_party/sqlite/src/src/vdbeaux.c | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
+ third_party/sqlite/src/src/vdbeaux.c | 8 ++++----
+ 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/third_party/sqlite/src/src/vdbeaux.c b/third_party/sqlite/src/src/vdbeaux.c
index ebcb652bad20..15a095ff6e7b 100644
@@ -19,14 +19,16 @@ index ebcb652bad20..15a095ff6e7b 100644
}else{
idx1 = getVarint32(aKey1, szHdr1);
d1 = szHdr1;
-+ i = 0;
-+ }
- if( d1>(unsigned)nKey1 ){
- pPKey2->errCode = (u8)SQLITE_CORRUPT_BKPT;
- return 0; /* Corruption */
+- if( d1>(unsigned)nKey1 ){
+- pPKey2->errCode = (u8)SQLITE_CORRUPT_BKPT;
+- return 0; /* Corruption */
+- }
+ i = 0;
}
-- i = 0;
-- }
++ if( d1>(unsigned)nKey1 ){
++ pPKey2->errCode = (u8)SQLITE_CORRUPT_BKPT;
++ return 0; /* Corruption */
++ }
VVA_ONLY( mem1.szMalloc = 0; ) /* Only needed by assert() statements */
assert( pPKey2->pKeyInfo->nAllField>=pPKey2->nField
diff --git a/chromium/third_party/sqlite/patches/0018-Fix-a-segfault-in-fts3-prompted-by-a-corrupted-datab.patch b/chromium/third_party/sqlite/patches/0018-Fix-a-segfault-in-fts3-prompted-by-a-corrupted-datab.patch
new file mode 100644
index 00000000000..d7272249a80
--- /dev/null
+++ b/chromium/third_party/sqlite/patches/0018-Fix-a-segfault-in-fts3-prompted-by-a-corrupted-datab.patch
@@ -0,0 +1,29 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Victor Costan <pwnall@chromium.org>
+Date: Sat, 12 Jan 2019 12:36:35 -0800
+Subject: [PATCH 18/40] Fix a segfault in fts3 prompted by a corrupted
+ database.
+
+This backports https://www.sqlite.org/src/info/2d7b1d1d41ff69d5
+
+Bug: 915499
+---
+ third_party/sqlite/src/ext/fts3/fts3.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/third_party/sqlite/src/ext/fts3/fts3.c b/third_party/sqlite/src/ext/fts3/fts3.c
+index ef69a7b18681..005d8e50212e 100644
+--- a/third_party/sqlite/src/ext/fts3/fts3.c
++++ b/third_party/sqlite/src/ext/fts3/fts3.c
+@@ -2899,7 +2899,7 @@ static int fts3SegReaderCursor(
+
+ /* If zTerm is not NULL, and this segment is not stored entirely on its
+ ** root node, the range of leaves scanned can be reduced. Do this. */
+- if( iStartBlock && zTerm ){
++ if( iStartBlock && zTerm && zRoot ){
+ sqlite3_int64 *pi = (isPrefix ? &iLeavesEndBlock : 0);
+ rc = fts3SelectLeaf(p, zTerm, nTerm, zRoot, nRoot, &iStartBlock, pi);
+ if( rc!=SQLITE_OK ) goto finished;
+--
+2.18.0
+
diff --git a/chromium/third_party/sqlite/patches/0019-Prevent-integer-overflow-from-leading-to-buffer-over.patch b/chromium/third_party/sqlite/patches/0019-Prevent-integer-overflow-from-leading-to-buffer-over.patch
new file mode 100644
index 00000000000..de615a94fba
--- /dev/null
+++ b/chromium/third_party/sqlite/patches/0019-Prevent-integer-overflow-from-leading-to-buffer-over.patch
@@ -0,0 +1,31 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Victor Costan <pwnall@chromium.org>
+Date: Sat, 12 Jan 2019 14:30:08 -0800
+Subject: [PATCH 19/40] Prevent integer overflow from leading to buffer
+ overread inside of an assert().
+
+This backports https://www.sqlite.org/src/info/0f850a25d67a752f
+
+Bug: 921298
+---
+ third_party/sqlite/src/src/vdbeaux.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/third_party/sqlite/src/src/vdbeaux.c b/third_party/sqlite/src/src/vdbeaux.c
+index 15a095ff6e7b..9ba127360fea 100644
+--- a/third_party/sqlite/src/src/vdbeaux.c
++++ b/third_party/sqlite/src/src/vdbeaux.c
+@@ -3799,8 +3799,8 @@ static int vdbeRecordCompareDebug(
+ ** Use that approximation to avoid the more expensive call to
+ ** sqlite3VdbeSerialTypeLen() in the common case.
+ */
+- if( d1+serial_type1+2>(u32)nKey1
+- && d1+sqlite3VdbeSerialTypeLen(serial_type1)>(u32)nKey1
++ if( d1+(u64)serial_type1+2>(u64)nKey1
++ && d1+(u64)sqlite3VdbeSerialTypeLen(serial_type1)>(u64)nKey1
+ ){
+ break;
+ }
+--
+2.18.0
+
diff --git a/chromium/third_party/sqlite/patches/0020-Add-extra-tests-for-database-corruption-inside-defra.patch b/chromium/third_party/sqlite/patches/0020-Add-extra-tests-for-database-corruption-inside-defra.patch
new file mode 100644
index 00000000000..b4d050318b9
--- /dev/null
+++ b/chromium/third_party/sqlite/patches/0020-Add-extra-tests-for-database-corruption-inside-defra.patch
@@ -0,0 +1,57 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Victor Costan <pwnall@chromium.org>
+Date: Sat, 12 Jan 2019 17:56:03 -0800
+Subject: [PATCH 20/40] Add extra tests for database corruption inside
+ defragmentPage().
+
+This backports https://sqlite.org/src/info/997b65117f8c12db
+
+Bug: 921355
+---
+ third_party/sqlite/src/src/btree.c | 20 ++++++++------------
+ 1 file changed, 8 insertions(+), 12 deletions(-)
+
+diff --git a/third_party/sqlite/src/src/btree.c b/third_party/sqlite/src/src/btree.c
+index 14af51e15ab2..aee43cccde46 100644
+--- a/third_party/sqlite/src/src/btree.c
++++ b/third_party/sqlite/src/src/btree.c
+@@ -1424,18 +1424,14 @@ static int defragmentPage(MemPage *pPage, int nMaxFrag){
+ ** reconstruct the entire page. */
+ if( (int)data[hdr+7]<=nMaxFrag ){
+ int iFree = get2byte(&data[hdr+1]);
++
++ /* If the initial freeblock offset were out of bounds, that would
++ ** have been detected by btreeInitPage() when it was computing the
++ ** number of free bytes on the page. */
++ assert( iFree<=usableSize-4 );
+ if( iFree ){
+ int iFree2 = get2byte(&data[iFree]);
+-
+- /* pageFindSlot() has already verified that free blocks are sorted
+- ** in order of offset within the page, and that no block extends
+- ** past the end of the page. Provided the two free slots do not
+- ** overlap, this guarantees that the memmove() calls below will not
+- ** overwrite the usableSize byte buffer, even if the database page
+- ** is corrupt. */
+- assert( iFree2==0 || iFree2>iFree );
+- assert( iFree+get2byte(&data[iFree+2]) <= usableSize );
+- assert( iFree2==0 || iFree2+get2byte(&data[iFree2+2]) <= usableSize );
++ if( iFree2>usableSize-4 ) return SQLITE_CORRUPT_PAGE(pPage);
+
+ if( 0==iFree2 || (data[iFree2]==0 && data[iFree2+1]==0) ){
+ u8 *pEnd = &data[cellOffset + nCell*2];
+@@ -1447,9 +1443,9 @@ static int defragmentPage(MemPage *pPage, int nMaxFrag){
+ return SQLITE_CORRUPT_PAGE(pPage);
+ }
+ if( iFree2 ){
+- assert( iFree+sz<=iFree2 ); /* Verified by pageFindSlot() */
++ if( iFree+sz>iFree2 ) return SQLITE_CORRUPT_PAGE(pPage);
+ sz2 = get2byte(&data[iFree2+2]);
+- assert( iFree+sz+sz2+iFree2-(iFree+sz) <= usableSize );
++ if( iFree2+sz2 > usableSize ) return SQLITE_CORRUPT_PAGE(pPage);
+ memmove(&data[iFree+sz+sz2], &data[iFree+sz], iFree2-(iFree+sz));
+ sz += sz2;
+ }
+--
+2.18.0
+
diff --git a/chromium/third_party/sqlite/patches/0021-Fix-an-off-by-one-error-on-a-Goto-in-the-code-genera.patch b/chromium/third_party/sqlite/patches/0021-Fix-an-off-by-one-error-on-a-Goto-in-the-code-genera.patch
new file mode 100644
index 00000000000..2ed2dd9b83b
--- /dev/null
+++ b/chromium/third_party/sqlite/patches/0021-Fix-an-off-by-one-error-on-a-Goto-in-the-code-genera.patch
@@ -0,0 +1,29 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Victor Costan <pwnall@chromium.org>
+Date: Sat, 12 Jan 2019 18:04:58 -0800
+Subject: [PATCH 21/40] Fix an off-by-one error on a Goto in the code
+ generator.
+
+This backports https://www.sqlite.org/src/info/e35eb8776ed539af
+
+Bug: 914507, 914648
+---
+ third_party/sqlite/src/src/insert.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/third_party/sqlite/src/src/insert.c b/third_party/sqlite/src/src/insert.c
+index cd2eec12864e..a834f3918439 100644
+--- a/third_party/sqlite/src/src/insert.c
++++ b/third_party/sqlite/src/src/insert.c
+@@ -1824,7 +1824,7 @@ void sqlite3GenerateConstraintChecks(
+
+ /* If the IPK constraint is a REPLACE, run it last */
+ if( ipkTop ){
+- sqlite3VdbeGoto(v, ipkTop+1);
++ sqlite3VdbeGoto(v, ipkTop);
+ VdbeComment((v, "Do IPK REPLACE"));
+ sqlite3VdbeJumpHere(v, ipkBottom);
+ }
+--
+2.18.0
+
diff --git a/chromium/third_party/sqlite/patches/0022-Fix-overread-on-corrupted-btree-key.patch b/chromium/third_party/sqlite/patches/0022-Fix-overread-on-corrupted-btree-key.patch
new file mode 100644
index 00000000000..315ba67c5b2
--- /dev/null
+++ b/chromium/third_party/sqlite/patches/0022-Fix-overread-on-corrupted-btree-key.patch
@@ -0,0 +1,37 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Victor Costan <pwnall@chromium.org>
+Date: Sun, 13 Jan 2019 13:36:26 -0800
+Subject: [PATCH 22/40] Fix overread on corrupted btree key.
+
+This backports https://sqlite.org/src/info/160b1e31c0f27257
+
+Bug: 914155
+---
+ third_party/sqlite/src/src/btree.c | 9 +++++++--
+ 1 file changed, 7 insertions(+), 2 deletions(-)
+
+diff --git a/third_party/sqlite/src/src/btree.c b/third_party/sqlite/src/src/btree.c
+index aee43cccde46..1f1c9e0402c8 100644
+--- a/third_party/sqlite/src/src/btree.c
++++ b/third_party/sqlite/src/src/btree.c
+@@ -660,10 +660,15 @@ static int saveCursorKey(BtCursor *pCur){
+ /* Only the rowid is required for a table btree */
+ pCur->nKey = sqlite3BtreeIntegerKey(pCur);
+ }else{
+- /* For an index btree, save the complete key content */
++ /* For an index btree, save the complete key content. It is possible
++ ** that the current key is corrupt. In that case, it is possible that
++ ** the sqlite3VdbeRecordUnpack() function may overread the buffer by
++ ** up to the size of 1 varint plus 1 8-byte value when the cursor
++ ** position is restored. Hence the 17 bytes of padding allocated
++ ** below. */
+ void *pKey;
+ pCur->nKey = sqlite3BtreePayloadSize(pCur);
+- pKey = sqlite3Malloc( pCur->nKey );
++ pKey = sqlite3Malloc( pCur->nKey + 9 + 8 );
+ if( pKey ){
+ rc = sqlite3BtreePayload(pCur, 0, (int)pCur->nKey, pKey);
+ if( rc==SQLITE_OK ){
+--
+2.18.0
+
diff --git a/chromium/third_party/sqlite/patches/0023-Avoid-buffer-overreads-on-corrupted-database-files.patch b/chromium/third_party/sqlite/patches/0023-Avoid-buffer-overreads-on-corrupted-database-files.patch
new file mode 100644
index 00000000000..ea5da8995e7
--- /dev/null
+++ b/chromium/third_party/sqlite/patches/0023-Avoid-buffer-overreads-on-corrupted-database-files.patch
@@ -0,0 +1,31 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Victor Costan <pwnall@chromium.org>
+Date: Sun, 13 Jan 2019 15:17:27 -0800
+Subject: [PATCH 23/40] Avoid buffer overreads on corrupted database files.
+
+This backports https://sqlite.org/src/info/32754ca6f86da816
+
+Bug: 914022, 914023
+---
+ third_party/sqlite/src/src/pcache1.c | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+diff --git a/third_party/sqlite/src/src/pcache1.c b/third_party/sqlite/src/src/pcache1.c
+index 1986b22ca61c..4fd6cb7bed39 100644
+--- a/third_party/sqlite/src/src/pcache1.c
++++ b/third_party/sqlite/src/src/pcache1.c
+@@ -477,7 +477,10 @@ static void pcache1FreePage(PgHdr1 *p){
+ ** exists, this function falls back to sqlite3Malloc().
+ */
+ void *sqlite3PageMalloc(int sz){
+- return pcache1Alloc(sz);
++ /* During rebalance operations on a corrupt database file, it is sometimes
++ ** (rarely) possible to overread the temporary page buffer by a few bytes.
++ ** Enlarge the allocation slightly so that this does not cause problems. */
++ return pcache1Alloc(sz + 32);
+ }
+
+ /*
+--
+2.18.0
+
diff --git a/chromium/third_party/sqlite/patches/0024-Fix-integer-overflow-while-running-PRAGMA-integrity_.patch b/chromium/third_party/sqlite/patches/0024-Fix-integer-overflow-while-running-PRAGMA-integrity_.patch
new file mode 100644
index 00000000000..01912a037e4
--- /dev/null
+++ b/chromium/third_party/sqlite/patches/0024-Fix-integer-overflow-while-running-PRAGMA-integrity_.patch
@@ -0,0 +1,38 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Victor Costan <pwnall@chromium.org>
+Date: Sun, 13 Jan 2019 16:12:08 -0800
+Subject: [PATCH 24/40] Fix integer overflow while running PRAGMA
+ integrity_check.
+
+This backports https://sqlite.org/src/info/395599116d801324
+
+Bug: 913235
+---
+ third_party/sqlite/src/src/btree.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/third_party/sqlite/src/src/btree.c b/third_party/sqlite/src/src/btree.c
+index 1f1c9e0402c8..eb7d8d0cb6bd 100644
+--- a/third_party/sqlite/src/src/btree.c
++++ b/third_party/sqlite/src/src/btree.c
+@@ -9414,7 +9414,7 @@ static void checkList(
+ }
+ pOvflData = (unsigned char *)sqlite3PagerGetData(pOvflPage);
+ if( isFreeList ){
+- int n = get4byte(&pOvflData[4]);
++ u32 n = (u32)get4byte(&pOvflData[4]);
+ #ifndef SQLITE_OMIT_AUTOVACUUM
+ if( pCheck->pBt->autoVacuum ){
+ checkPtrmap(pCheck, iPage, PTRMAP_FREEPAGE, 0);
+@@ -9425,7 +9425,7 @@ static void checkList(
+ "freelist leaf count too big on page %d", iPage);
+ N--;
+ }else{
+- for(i=0; i<n; i++){
++ for(i=0; i<(int)n; i++){
+ Pgno iFreePage = get4byte(&pOvflData[8+i*4]);
+ #ifndef SQLITE_OMIT_AUTOVACUUM
+ if( pCheck->pBt->autoVacuum ){
+--
+2.18.0
+
diff --git a/chromium/third_party/sqlite/patches/0025-Improved-corruption-handling-while-balancing-pages.patch b/chromium/third_party/sqlite/patches/0025-Improved-corruption-handling-while-balancing-pages.patch
new file mode 100644
index 00000000000..d8e9a64a4da
--- /dev/null
+++ b/chromium/third_party/sqlite/patches/0025-Improved-corruption-handling-while-balancing-pages.patch
@@ -0,0 +1,120 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Victor Costan <pwnall@chromium.org>
+Date: Sun, 13 Jan 2019 18:06:01 -0800
+Subject: [PATCH 25/40] Improved corruption handling while balancing pages.
+
+This backports https://www.sqlite.org/src/info/35f04235c4775013
+
+Bug: 921348
+---
+ third_party/sqlite/src/src/btree.c | 31 +++++++++++++++---------------
+ 1 file changed, 15 insertions(+), 16 deletions(-)
+
+diff --git a/third_party/sqlite/src/src/btree.c b/third_party/sqlite/src/src/btree.c
+index eb7d8d0cb6bd..5713bd09e49f 100644
+--- a/third_party/sqlite/src/src/btree.c
++++ b/third_party/sqlite/src/src/btree.c
+@@ -1066,7 +1066,7 @@ static int ptrmapGet(BtShared *pBt, Pgno key, u8 *pEType, Pgno *pPgno){
+ #else /* if defined SQLITE_OMIT_AUTOVACUUM */
+ #define ptrmapPut(w,x,y,z,rc)
+ #define ptrmapGet(w,x,y,z) SQLITE_OK
+- #define ptrmapPutOvflPtr(x, y, rc)
++ #define ptrmapPutOvflPtr(x, y, z, rc)
+ #endif
+
+ /*
+@@ -1359,18 +1359,20 @@ static u16 cellSize(MemPage *pPage, int iCell){
+
+ #ifndef SQLITE_OMIT_AUTOVACUUM
+ /*
+-** If the cell pCell, part of page pPage contains a pointer
+-** to an overflow page, insert an entry into the pointer-map
+-** for the overflow page.
++** The cell pCell is currently part of page pSrc but will ultimately be part
++** of pPage. (pSrc and pPager are often the same.) If pCell contains a
++** pointer to an overflow page, insert an entry into the pointer-map for
++** the overflow page that will be valid after pCell has been moved to pPage.
+ */
+-static void ptrmapPutOvflPtr(MemPage *pPage, u8 *pCell, int *pRC){
++static void ptrmapPutOvflPtr(MemPage *pPage, MemPage *pSrc, u8 *pCell, int *pRC){
+ CellInfo info;
+ if( *pRC ) return;
+ assert( pCell!=0 );
+ pPage->xParseCell(pPage, pCell, &info);
+ if( info.nLocal<info.nPayload ){
+ Pgno ovfl;
+- if( SQLITE_WITHIN(pPage->aDataEnd, pCell, pCell+info.nLocal) ){
++ if( SQLITE_WITHIN(pSrc->aDataEnd, pCell, pCell+info.nLocal) ){
++ testcase( pSrc!=pPage );
+ *pRC = SQLITE_CORRUPT_BKPT;
+ return;
+ }
+@@ -3491,7 +3493,7 @@ static int setChildPtrmaps(MemPage *pPage){
+ for(i=0; i<nCell; i++){
+ u8 *pCell = findCell(pPage, i);
+
+- ptrmapPutOvflPtr(pPage, pCell, &rc);
++ ptrmapPutOvflPtr(pPage, pPage, pCell, &rc);
+
+ if( !pPage->leaf ){
+ Pgno childPgno = get4byte(pCell);
+@@ -6676,7 +6678,7 @@ static void insertCell(
+ /* The cell may contain a pointer to an overflow page. If so, write
+ ** the entry for the overflow page into the pointer map.
+ */
+- ptrmapPutOvflPtr(pPage, pCell, pRC);
++ ptrmapPutOvflPtr(pPage, pPage, pCell, pRC);
+ }
+ #endif
+ }
+@@ -7092,7 +7094,7 @@ static int balance_quick(MemPage *pParent, MemPage *pPage, u8 *pSpace){
+ if( ISAUTOVACUUM ){
+ ptrmapPut(pBt, pgnoNew, PTRMAP_BTREE, pParent->pgno, &rc);
+ if( szCell>pNew->minLocal ){
+- ptrmapPutOvflPtr(pNew, pCell, &rc);
++ ptrmapPutOvflPtr(pNew, pNew, pCell, &rc);
+ }
+ }
+
+@@ -7315,10 +7317,6 @@ static int balance_nonroot(
+ assert( sqlite3_mutex_held(pBt->mutex) );
+ assert( sqlite3PagerIswriteable(pParent->pDbPage) );
+
+-#if 0
+- TRACE(("BALANCE: begin page %d child of %d\n", pPage->pgno, pParent->pgno));
+-#endif
+-
+ /* At this point pParent may have at most one overflow cell. And if
+ ** this overflow cell is present, it must be the cell with
+ ** index iParentIdx. This scenario comes about when this function
+@@ -7784,7 +7782,8 @@ static int balance_nonroot(
+ ** populated, not here.
+ */
+ if( ISAUTOVACUUM ){
+- MemPage *pNew = apNew[0];
++ MemPage *pOld;
++ MemPage *pNew = pOld = apNew[0];
+ u8 *aOld = pNew->aData;
+ int cntOldNext = pNew->nCell + pNew->nOverflow;
+ int usableSize = pBt->usableSize;
+@@ -7794,7 +7793,7 @@ static int balance_nonroot(
+ for(i=0; i<b.nCell; i++){
+ u8 *pCell = b.apCell[i];
+ if( i==cntOldNext ){
+- MemPage *pOld = (++iOld)<nNew ? apNew[iOld] : apOld[iOld];
++ pOld = (++iOld)<nNew ? apNew[iOld] : apOld[iOld];
+ cntOldNext += pOld->nCell + pOld->nOverflow + !leafData;
+ aOld = pOld->aData;
+ }
+@@ -7817,7 +7816,7 @@ static int balance_nonroot(
+ ptrmapPut(pBt, get4byte(pCell), PTRMAP_BTREE, pNew->pgno, &rc);
+ }
+ if( cachedCellSize(&b,i)>pNew->minLocal ){
+- ptrmapPutOvflPtr(pNew, pCell, &rc);
++ ptrmapPutOvflPtr(pNew, pOld, pCell, &rc);
+ }
+ if( rc ) goto balance_cleanup;
+ }
+--
+2.18.0
+
diff --git a/chromium/third_party/sqlite/patches/0026-Avoid-reading-off-the-front-of-a-page-buffer-when-ba.patch b/chromium/third_party/sqlite/patches/0026-Avoid-reading-off-the-front-of-a-page-buffer-when-ba.patch
new file mode 100644
index 00000000000..3cbd94d874b
--- /dev/null
+++ b/chromium/third_party/sqlite/patches/0026-Avoid-reading-off-the-front-of-a-page-buffer-when-ba.patch
@@ -0,0 +1,38 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Victor Costan <pwnall@chromium.org>
+Date: Sun, 13 Jan 2019 23:10:51 -0800
+Subject: [PATCH 26/40] Avoid reading off the front of a page buffer when
+ balancing a corrupt btree.
+
+This backports https://www.sqlite.org/src/info/cb50509020d952fa
+
+Bug: 914027
+---
+ third_party/sqlite/src/src/btree.c | 9 ++++++++-
+ 1 file changed, 8 insertions(+), 1 deletion(-)
+
+diff --git a/third_party/sqlite/src/src/btree.c b/third_party/sqlite/src/src/btree.c
+index 5713bd09e49f..13342288934d 100644
+--- a/third_party/sqlite/src/src/btree.c
++++ b/third_party/sqlite/src/src/btree.c
+@@ -6662,9 +6662,16 @@ static void insertCell(
+ assert( idx >= pPage->cellOffset+2*pPage->nCell+2 || CORRUPT_DB );
+ assert( idx+sz <= (int)pPage->pBt->usableSize );
+ pPage->nFree -= (u16)(2 + sz);
+- memcpy(&data[idx], pCell, sz);
+ if( iChild ){
++ /* In a corrupt database where an entry in the cell index section of
++ ** a btree page has a value of 3 or less, the pCell value might point
++ ** as many as 4 bytes in front of the start of the aData buffer for
++ ** the source page. Make sure this does not cause problems by not
++ ** reading the first 4 bytes */
++ memcpy(&data[idx+4], pCell+4, sz-4);
+ put4byte(&data[idx], iChild);
++ }else{
++ memcpy(&data[idx], pCell, sz);
+ }
+ pIns = pPage->aCellIdx + i*2;
+ memmove(pIns+2, pIns, 2*(pPage->nCell - i));
+--
+2.18.0
+
diff --git a/chromium/third_party/sqlite/patches/0027-Fix-MSAN-error-in-sqlite3VdbeRecordUnpack-on-a-corru.patch b/chromium/third_party/sqlite/patches/0027-Fix-MSAN-error-in-sqlite3VdbeRecordUnpack-on-a-corru.patch
new file mode 100644
index 00000000000..f3eecc7aaaa
--- /dev/null
+++ b/chromium/third_party/sqlite/patches/0027-Fix-MSAN-error-in-sqlite3VdbeRecordUnpack-on-a-corru.patch
@@ -0,0 +1,34 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Victor Costan <pwnall@chromium.org>
+Date: Mon, 14 Jan 2019 12:32:04 -0800
+Subject: [PATCH 27/40] Fix MSAN error in sqlite3VdbeRecordUnpack() on a
+ corrupt record.
+
+This backports https://www.sqlite.org/src/info/ddc3697efd61830f
+
+Bug: 914970
+---
+ third_party/sqlite/src/src/vdbeaux.c | 7 +++++++
+ 1 file changed, 7 insertions(+)
+
+diff --git a/third_party/sqlite/src/src/vdbeaux.c b/third_party/sqlite/src/src/vdbeaux.c
+index 9ba127360fea..1e9812288cfa 100644
+--- a/third_party/sqlite/src/src/vdbeaux.c
++++ b/third_party/sqlite/src/src/vdbeaux.c
+@@ -3734,6 +3734,13 @@ void sqlite3VdbeRecordUnpack(
+ pMem++;
+ if( (++u)>=p->nField ) break;
+ }
++ if( d>nKey && u ){
++ assert( CORRUPT_DB );
++ /* In a corrupt record entry, the last pMem might have been set up using
++ ** uninitialized memory. Overwrite its value with NULL, to prevent
++ ** warnings from MSAN. */
++ sqlite3VdbeMemSetNull(pMem-1);
++ }
+ assert( u<=pKeyInfo->nKeyField + 1 );
+ p->nField = u;
+ }
+--
+2.18.0
+
diff --git a/chromium/third_party/sqlite/patches/0028-Fix-deleting-a-B-tree-entry-in-a-corrupt-database.patch b/chromium/third_party/sqlite/patches/0028-Fix-deleting-a-B-tree-entry-in-a-corrupt-database.patch
new file mode 100644
index 00000000000..a5de315c0df
--- /dev/null
+++ b/chromium/third_party/sqlite/patches/0028-Fix-deleting-a-B-tree-entry-in-a-corrupt-database.patch
@@ -0,0 +1,27 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Victor Costan <pwnall@chromium.org>
+Date: Tue, 15 Jan 2019 20:35:58 -0800
+Subject: [PATCH 28/40] Fix deleting a B-tree entry in a corrupt database.
+
+This backports https://sqlite.org/src/info/682053d1e603c21b
+
+Bug: 921894
+---
+ third_party/sqlite/src/src/btree.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/third_party/sqlite/src/src/btree.c b/third_party/sqlite/src/src/btree.c
+index 13342288934d..9b5745558514 100644
+--- a/third_party/sqlite/src/src/btree.c
++++ b/third_party/sqlite/src/src/btree.c
+@@ -8642,6 +8642,7 @@ int sqlite3BtreeDelete(BtCursor *pCur, u8 flags){
+ if( bPreserve ){
+ if( !pPage->leaf
+ || (pPage->nFree+cellSizePtr(pPage,pCell)+2)>(int)(pBt->usableSize*2/3)
++ || pPage->nCell==1 /* See dbfuzz001.test for a test case */
+ ){
+ /* A b-tree rebalance will be required after deleting this entry.
+ ** Save the cursor key. */
+--
+2.18.0
+
diff --git a/chromium/third_party/sqlite/patches/0029-Fix-sorting-results-with-SRT_EphemTab-and-a-LIMIT-cl.patch b/chromium/third_party/sqlite/patches/0029-Fix-sorting-results-with-SRT_EphemTab-and-a-LIMIT-cl.patch
new file mode 100644
index 00000000000..34eb6b470e9
--- /dev/null
+++ b/chromium/third_party/sqlite/patches/0029-Fix-sorting-results-with-SRT_EphemTab-and-a-LIMIT-cl.patch
@@ -0,0 +1,42 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Victor Costan <pwnall@chromium.org>
+Date: Wed, 16 Jan 2019 12:46:56 -0800
+Subject: [PATCH 29/40] Fix sorting results with SRT_EphemTab and a LIMIT
+ clause.
+
+This backports https://www.sqlite.org/src/info/49fcde2f1f981ac0
+
+Bug: 922312
+---
+ third_party/sqlite/src/src/select.c | 8 +++++++-
+ 1 file changed, 7 insertions(+), 1 deletion(-)
+
+diff --git a/third_party/sqlite/src/src/select.c b/third_party/sqlite/src/src/select.c
+index fab4df68fa17..c68c1ddc643d 100644
+--- a/third_party/sqlite/src/src/select.c
++++ b/third_party/sqlite/src/src/select.c
+@@ -1457,7 +1457,12 @@ static void generateSortTail(
+ regRow = pDest->iSdst;
+ }else{
+ regRowid = sqlite3GetTempReg(pParse);
+- regRow = sqlite3GetTempRange(pParse, nColumn);
++ if( eDest==SRT_EphemTab || eDest==SRT_Table ){
++ regRow = sqlite3GetTempReg(pParse);
++ nColumn = 0;
++ }else{
++ regRow = sqlite3GetTempRange(pParse, nColumn);
++ }
+ }
+ nKey = pOrderBy->nExpr - pSort->nOBSat;
+ if( pSort->sortFlags & SORTFLAG_UseSorter ){
+@@ -1537,6 +1542,7 @@ static void generateSortTail(
+ switch( eDest ){
+ case SRT_Table:
+ case SRT_EphemTab: {
++ sqlite3VdbeAddOp3(v, OP_Column, iSortTab, nKey+bSeq, regRow);
+ sqlite3VdbeAddOp2(v, OP_NewRowid, iParm, regRowid);
+ sqlite3VdbeAddOp3(v, OP_Insert, iParm, regRow, regRowid);
+ sqlite3VdbeChangeP5(v, OPFLAG_APPEND);
+--
+2.18.0
+
diff --git a/chromium/third_party/sqlite/patches/0030-Fix-detection-of-orphaned-and-malformed-autoindexes.patch b/chromium/third_party/sqlite/patches/0030-Fix-detection-of-orphaned-and-malformed-autoindexes.patch
new file mode 100644
index 00000000000..e2529c39fe6
--- /dev/null
+++ b/chromium/third_party/sqlite/patches/0030-Fix-detection-of-orphaned-and-malformed-autoindexes.patch
@@ -0,0 +1,40 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Victor Costan <pwnall@chromium.org>
+Date: Wed, 16 Jan 2019 13:07:12 -0800
+Subject: [PATCH 30/40] Fix detection of orphaned and malformed autoindexes.
+
+This backports https://sqlite.org/src/info/10f9e39d6ed2413f
+
+Bug: 922213
+---
+ third_party/sqlite/src/src/prepare.c | 14 +++++---------
+ 1 file changed, 5 insertions(+), 9 deletions(-)
+
+diff --git a/third_party/sqlite/src/src/prepare.c b/third_party/sqlite/src/src/prepare.c
+index fe098cfa092e..cdf6f65bb115 100644
+--- a/third_party/sqlite/src/src/prepare.c
++++ b/third_party/sqlite/src/src/prepare.c
+@@ -118,15 +118,11 @@ int sqlite3InitCallback(void *pInit, int argc, char **argv, char **NotUsed){
+ */
+ Index *pIndex;
+ pIndex = sqlite3FindIndex(db, argv[0], db->aDb[iDb].zDbSName);
+- if( pIndex==0 ){
+- /* This can occur if there exists an index on a TEMP table which
+- ** has the same name as another index on a permanent index. Since
+- ** the permanent table is hidden by the TEMP table, we can also
+- ** safely ignore the index on the permanent table.
+- */
+- /* Do Nothing */;
+- }else if( sqlite3GetInt32(argv[1], &pIndex->tnum)==0 ){
+- corruptSchema(pData, argv[0], "invalid rootpage");
++ if( pIndex==0
++ || sqlite3GetInt32(argv[1],&pIndex->tnum)==0
++ || pIndex->tnum<2
++ ){
++ corruptSchema(pData, argv[0], pIndex?"invalid rootpage":"orphan index");
+ }
+ }
+ return 0;
+--
+2.18.0
+
diff --git a/chromium/third_party/sqlite/patches/0031-Fix-potential-buffer-overread.patch b/chromium/third_party/sqlite/patches/0031-Fix-potential-buffer-overread.patch
new file mode 100644
index 00000000000..c933c09eb1d
--- /dev/null
+++ b/chromium/third_party/sqlite/patches/0031-Fix-potential-buffer-overread.patch
@@ -0,0 +1,41 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Victor Costan <pwnall@chromium.org>
+Date: Fri, 18 Jan 2019 23:20:17 -0800
+Subject: [PATCH 31/40] Fix potential buffer overread.
+
+This backports https://sqlite.org/src/info/8ba3d9f38090c4bb
+
+Bug: 923196
+---
+ third_party/sqlite/src/src/btree.c | 1 +
+ third_party/sqlite/src/src/pcache1.c | 2 +-
+ 2 files changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/third_party/sqlite/src/src/btree.c b/third_party/sqlite/src/src/btree.c
+index 9b5745558514..5eb83736533a 100644
+--- a/third_party/sqlite/src/src/btree.c
++++ b/third_party/sqlite/src/src/btree.c
+@@ -6772,6 +6772,7 @@ static int rebuildPage(
+ for(i=0; i<nCell; i++){
+ u8 *pCell = apCell[i];
+ if( SQLITE_WITHIN(pCell,aData,pEnd) ){
++ if( ((uptr)(pCell+szCell[i]))>(uptr)pEnd ) return SQLITE_CORRUPT_BKPT;
+ pCell = &pTmp[pCell - aData];
+ }
+ pData -= szCell[i];
+diff --git a/third_party/sqlite/src/src/pcache1.c b/third_party/sqlite/src/src/pcache1.c
+index 4fd6cb7bed39..05ef4bde330b 100644
+--- a/third_party/sqlite/src/src/pcache1.c
++++ b/third_party/sqlite/src/src/pcache1.c
+@@ -480,7 +480,7 @@ void *sqlite3PageMalloc(int sz){
+ /* During rebalance operations on a corrupt database file, it is sometimes
+ ** (rarely) possible to overread the temporary page buffer by a few bytes.
+ ** Enlarge the allocation slightly so that this does not cause problems. */
+- return pcache1Alloc(sz + 32);
++ return pcache1Alloc(sz);
+ }
+
+ /*
+--
+2.18.0
+
diff --git a/chromium/third_party/sqlite/patches/0032-Fix-handling-negative-number-of-pages-database-field.patch b/chromium/third_party/sqlite/patches/0032-Fix-handling-negative-number-of-pages-database-field.patch
new file mode 100644
index 00000000000..7111acbfd28
--- /dev/null
+++ b/chromium/third_party/sqlite/patches/0032-Fix-handling-negative-number-of-pages-database-field.patch
@@ -0,0 +1,69 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Victor Costan <pwnall@chromium.org>
+Date: Sat, 19 Jan 2019 02:33:28 -0800
+Subject: [PATCH 32/40] Fix handling negative "number-of-pages" database field.
+
+This backports https://www.sqlite.org/src/info/556dd8922f
+
+Bug: 922849
+---
+ third_party/sqlite/src/src/btree.c | 8 ++++----
+ third_party/sqlite/src/src/build.c | 16 +++++++++-------
+ 2 files changed, 13 insertions(+), 11 deletions(-)
+
+diff --git a/third_party/sqlite/src/src/btree.c b/third_party/sqlite/src/src/btree.c
+index 5eb83736533a..dbff913299a9 100644
+--- a/third_party/sqlite/src/src/btree.c
++++ b/third_party/sqlite/src/src/btree.c
+@@ -3007,9 +3007,9 @@ static int newDatabase(BtShared*);
+ static int lockBtree(BtShared *pBt){
+ int rc; /* Result code from subfunctions */
+ MemPage *pPage1; /* Page 1 of the database file */
+- int nPage; /* Number of pages in the database */
+- int nPageFile = 0; /* Number of pages in the database file */
+- int nPageHeader; /* Number of pages in the database according to hdr */
++ u32 nPage; /* Number of pages in the database */
++ u32 nPageFile = 0; /* Number of pages in the database file */
++ u32 nPageHeader; /* Number of pages in the database according to hdr */
+
+ assert( sqlite3_mutex_held(pBt->mutex) );
+ assert( pBt->pPage1==0 );
+@@ -3022,7 +3022,7 @@ static int lockBtree(BtShared *pBt){
+ ** a valid database file.
+ */
+ nPage = nPageHeader = get4byte(28+(u8*)pPage1->aData);
+- sqlite3PagerPagecount(pBt->pPager, &nPageFile);
++ sqlite3PagerPagecount(pBt->pPager, (int*)&nPageFile);
+ if( nPage==0 || memcmp(24+(u8*)pPage1->aData, 92+(u8*)pPage1->aData,4)!=0 ){
+ nPage = nPageFile;
+ }
+diff --git a/third_party/sqlite/src/src/build.c b/third_party/sqlite/src/src/build.c
+index 806c89f439bf..5939fa9974a8 100644
+--- a/third_party/sqlite/src/src/build.c
++++ b/third_party/sqlite/src/src/build.c
+@@ -4417,13 +4417,15 @@ static int collationMatch(const char *zColl, Index *pIndex){
+ */
+ #ifndef SQLITE_OMIT_REINDEX
+ static void reindexTable(Parse *pParse, Table *pTab, char const *zColl){
+- Index *pIndex; /* An index associated with pTab */
+-
+- for(pIndex=pTab->pIndex; pIndex; pIndex=pIndex->pNext){
+- if( zColl==0 || collationMatch(zColl, pIndex) ){
+- int iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);
+- sqlite3BeginWriteOperation(pParse, 0, iDb);
+- sqlite3RefillIndex(pParse, pIndex, -1);
++ if (! IsVirtual(pTab) ){
++ Index *pIndex; /* An index associated with pTab */
++
++ for(pIndex=pTab->pIndex; pIndex; pIndex=pIndex->pNext){
++ if( zColl==0 || collationMatch(zColl, pIndex) ){
++ int iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);
++ sqlite3BeginWriteOperation(pParse, 0, iDb);
++ sqlite3RefillIndex(pParse, pIndex, -1);
++ }
+ }
+ }
+ }
+--
+2.18.0
+
diff --git a/chromium/third_party/sqlite/patches/0033-Fix-corner-case-in-inserting-null-into-integer-prima.patch b/chromium/third_party/sqlite/patches/0033-Fix-corner-case-in-inserting-null-into-integer-prima.patch
new file mode 100644
index 00000000000..77dbd02f020
--- /dev/null
+++ b/chromium/third_party/sqlite/patches/0033-Fix-corner-case-in-inserting-null-into-integer-prima.patch
@@ -0,0 +1,42 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Victor Costan <pwnall@chromium.org>
+Date: Sat, 19 Jan 2019 14:27:29 -0800
+Subject: [PATCH 33/40] Fix corner case in inserting null into integer primary
+ key.
+
+This backports https://www.sqlite.org/src/info/9a425051e7ba59e7
+
+Bug: 922844
+---
+ third_party/sqlite/src/src/insert.c | 14 +++++---------
+ 1 file changed, 5 insertions(+), 9 deletions(-)
+
+diff --git a/third_party/sqlite/src/src/insert.c b/third_party/sqlite/src/src/insert.c
+index a834f3918439..2dd4d8227a6c 100644
+--- a/third_party/sqlite/src/src/insert.c
++++ b/third_party/sqlite/src/src/insert.c
+@@ -947,16 +947,12 @@ void sqlite3Insert(
+ }else if( pSelect ){
+ sqlite3VdbeAddOp2(v, OP_Copy, regFromSelect+ipkColumn, regRowid);
+ }else{
+- VdbeOp *pOp;
+- sqlite3ExprCode(pParse, pList->a[ipkColumn].pExpr, regRowid);
+- pOp = sqlite3VdbeGetOp(v, -1);
+- assert( pOp!=0 );
+- if( pOp->opcode==OP_Null && !IsVirtual(pTab) ){
++ Expr *pIpk = pList->a[ipkColumn].pExpr;
++ if( pIpk->op==TK_NULL && !IsVirtual(pTab) ){
++ sqlite3VdbeAddOp3(v, OP_NewRowid, iDataCur, regRowid, regAutoinc);
+ appendFlag = 1;
+- pOp->opcode = OP_NewRowid;
+- pOp->p1 = iDataCur;
+- pOp->p2 = regRowid;
+- pOp->p3 = regAutoinc;
++ }else{
++ sqlite3ExprCode(pParse, pList->a[ipkColumn].pExpr, regRowid);
+ }
+ }
+ /* If the PRIMARY KEY expression is NULL, then use OP_NewRowid
+--
+2.18.0
+
diff --git a/chromium/third_party/sqlite/patches/0034-Fix-insert-infinite-recursion-on-some-corrupted-data.patch b/chromium/third_party/sqlite/patches/0034-Fix-insert-infinite-recursion-on-some-corrupted-data.patch
new file mode 100644
index 00000000000..8ff6e693947
--- /dev/null
+++ b/chromium/third_party/sqlite/patches/0034-Fix-insert-infinite-recursion-on-some-corrupted-data.patch
@@ -0,0 +1,30 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Victor Costan <pwnall@chromium.org>
+Date: Sat, 19 Jan 2019 15:39:26 -0800
+Subject: [PATCH 34/40] Fix insert infinite recursion on some corrupted
+ databases.
+
+This backports https://www.sqlite.org/src/info/f31b3bd2a6a8aa35
+
+Bug: 921684
+---
+ third_party/sqlite/src/src/insert.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/third_party/sqlite/src/src/insert.c b/third_party/sqlite/src/src/insert.c
+index 2dd4d8227a6c..b21bf714923a 100644
+--- a/third_party/sqlite/src/src/insert.c
++++ b/third_party/sqlite/src/src/insert.c
+@@ -2190,7 +2190,8 @@ static int xferOptimization(
+ if( pSrc==0 ){
+ return 0; /* FROM clause does not contain a real table */
+ }
+- if( pSrc==pDest ){
++ if( pSrc->tnum==pDest->tnum && pSrc->pSchema==pDest->pSchema ){
++ testcase( pSrc!=pDest ); /* Possible due to bad sqlite_master.rootpage */
+ return 0; /* tab1 and tab2 may not be the same table */
+ }
+ if( HasRowid(pDest)!=HasRowid(pSrc) ){
+--
+2.18.0
+
diff --git a/chromium/third_party/sqlite/patches/0035-Fix-null-pointer-dereference-in-sqlite3ExprCompare.patch b/chromium/third_party/sqlite/patches/0035-Fix-null-pointer-dereference-in-sqlite3ExprCompare.patch
new file mode 100644
index 00000000000..8afbbd97b30
--- /dev/null
+++ b/chromium/third_party/sqlite/patches/0035-Fix-null-pointer-dereference-in-sqlite3ExprCompare.patch
@@ -0,0 +1,32 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Victor Costan <pwnall@chromium.org>
+Date: Sat, 19 Jan 2019 15:48:54 -0800
+Subject: [PATCH 35/40] Fix null pointer dereference in sqlite3ExprCompare.
+
+This backports https://www.sqlite.org/src/info/835e2cc55feea2f2
+
+Bug: 921417
+---
+ third_party/sqlite/src/src/expr.c | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/third_party/sqlite/src/src/expr.c b/third_party/sqlite/src/src/expr.c
+index c61528288baf..50c398266f33 100644
+--- a/third_party/sqlite/src/src/expr.c
++++ b/third_party/sqlite/src/src/expr.c
+@@ -4748,9 +4748,11 @@ int sqlite3ExprCompare(Parse *pParse, Expr *pA, Expr *pB, int iTab){
+ if( sqlite3WindowCompare(pParse,pA->y.pWin,pB->y.pWin)!=0 ) return 2;
+ }
+ #endif
++ }else if( pA->op==TK_NULL ){
++ return 0;
+ }else if( pA->op==TK_COLLATE ){
+ if( sqlite3_stricmp(pA->u.zToken,pB->u.zToken)!=0 ) return 2;
+- }else if( strcmp(pA->u.zToken,pB->u.zToken)!=0 ){
++ }else if( ALWAYS(pB->u.zToken!=0) && strcmp(pA->u.zToken,pB->u.zToken)!=0 ){
+ return 2;
+ }
+ }
+--
+2.18.0
+
diff --git a/chromium/third_party/sqlite/patches/0036-Fix-NEVER-that-is-sometimes-true.patch b/chromium/third_party/sqlite/patches/0036-Fix-NEVER-that-is-sometimes-true.patch
new file mode 100644
index 00000000000..9d1bedac82d
--- /dev/null
+++ b/chromium/third_party/sqlite/patches/0036-Fix-NEVER-that-is-sometimes-true.patch
@@ -0,0 +1,29 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Victor Costan <pwnall@chromium.org>
+Date: Mon, 21 Jan 2019 14:26:47 -0800
+Subject: [PATCH 36/40] Fix NEVER that is sometimes true.
+
+This backports https://sqlite.org/src/info/1201615cbbd30701
+
+Bug: 923715
+---
+ third_party/sqlite/src/src/btree.c | 3 +--
+ 1 file changed, 1 insertion(+), 2 deletions(-)
+
+diff --git a/third_party/sqlite/src/src/btree.c b/third_party/sqlite/src/src/btree.c
+index dbff913299a9..cc4de24d79db 100644
+--- a/third_party/sqlite/src/src/btree.c
++++ b/third_party/sqlite/src/src/btree.c
+@@ -7067,8 +7067,7 @@ static int balance_quick(MemPage *pParent, MemPage *pPage, u8 *pSpace){
+ assert( sqlite3PagerIswriteable(pParent->pDbPage) );
+ assert( pPage->nOverflow==1 );
+
+- /* This error condition is now caught prior to reaching this function */
+- if( NEVER(pPage->nCell==0) ) return SQLITE_CORRUPT_BKPT;
++ if( pPage->nCell==0 ) return SQLITE_CORRUPT_BKPT; /* dbfuzz001.test */
+
+ /* Allocate a new page. This page will become the right-sibling of
+ ** pPage. Make the parent page writable, so that the new divider cell
+--
+2.18.0
+
diff --git a/chromium/third_party/sqlite/patches/0037-Initialize-extra-bytes-allocated-for-saved-cursor-po.patch b/chromium/third_party/sqlite/patches/0037-Initialize-extra-bytes-allocated-for-saved-cursor-po.patch
new file mode 100644
index 00000000000..a281eb69f02
--- /dev/null
+++ b/chromium/third_party/sqlite/patches/0037-Initialize-extra-bytes-allocated-for-saved-cursor-po.patch
@@ -0,0 +1,28 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Victor Costan <pwnall@chromium.org>
+Date: Mon, 21 Jan 2019 14:32:00 -0800
+Subject: [PATCH 37/40] Initialize extra bytes allocated for saved cursor
+ position.
+
+This backports https://www.sqlite.org/src/info/2737564929e86ead
+
+Bug: 923743
+---
+ third_party/sqlite/src/src/btree.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/third_party/sqlite/src/src/btree.c b/third_party/sqlite/src/src/btree.c
+index cc4de24d79db..3b018b5cc3c8 100644
+--- a/third_party/sqlite/src/src/btree.c
++++ b/third_party/sqlite/src/src/btree.c
+@@ -672,6 +672,7 @@ static int saveCursorKey(BtCursor *pCur){
+ if( pKey ){
+ rc = sqlite3BtreePayload(pCur, 0, (int)pCur->nKey, pKey);
+ if( rc==SQLITE_OK ){
++ memset(((u8*)pKey)+pCur->nKey, 0, 9+8);
+ pCur->pKey = pKey;
+ }else{
+ sqlite3_free(pKey);
+--
+2.18.0
+
diff --git a/chromium/third_party/sqlite/patches/0038-Fix-leaks-caused-by-circular-references-in-vtable-sh.patch b/chromium/third_party/sqlite/patches/0038-Fix-leaks-caused-by-circular-references-in-vtable-sh.patch
new file mode 100644
index 00000000000..4cf0bbb27a3
--- /dev/null
+++ b/chromium/third_party/sqlite/patches/0038-Fix-leaks-caused-by-circular-references-in-vtable-sh.patch
@@ -0,0 +1,246 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Victor Costan <pwnall@chromium.org>
+Date: Mon, 21 Jan 2019 14:57:17 -0800
+Subject: [PATCH 38/40] Fix leaks caused by circular references in vtable
+ shadow tables.
+
+This backports https://sqlite.org/src/info/da587d18575ac06a
+
+Bug: 914028, 917075, 917786, 922399
+---
+ third_party/sqlite/src/ext/fts3/fts3_write.c | 5 +--
+ third_party/sqlite/src/ext/fts5/fts5_index.c | 16 ++-------
+ .../sqlite/src/ext/fts5/fts5_storage.c | 5 +--
+ third_party/sqlite/src/ext/rtree/rtree.c | 7 ++--
+ third_party/sqlite/src/src/build.c | 34 +++++++++++--------
+ third_party/sqlite/src/src/prepare.c | 1 +
+ third_party/sqlite/src/src/sqlite.h.in | 6 ++++
+ third_party/sqlite/src/src/sqliteInt.h | 1 +
+ third_party/sqlite/src/src/trigger.c | 1 +
+ 9 files changed, 41 insertions(+), 35 deletions(-)
+
+diff --git a/third_party/sqlite/src/ext/fts3/fts3_write.c b/third_party/sqlite/src/ext/fts3/fts3_write.c
+index fc599a0c3e04..9bc6d70f45cb 100644
+--- a/third_party/sqlite/src/ext/fts3/fts3_write.c
++++ b/third_party/sqlite/src/ext/fts3/fts3_write.c
+@@ -396,10 +396,12 @@ static int fts3SqlStmt(
+
+ pStmt = p->aStmt[eStmt];
+ if( !pStmt ){
++ int f = SQLITE_PREPARE_PERSISTENT|SQLITE_PREPARE_NO_VTAB;
+ char *zSql;
+ if( eStmt==SQL_CONTENT_INSERT ){
+ zSql = sqlite3_mprintf(azSql[eStmt], p->zDb, p->zName, p->zWriteExprlist);
+ }else if( eStmt==SQL_SELECT_CONTENT_BY_ROWID ){
++ f &= ~SQLITE_PREPARE_NO_VTAB;
+ zSql = sqlite3_mprintf(azSql[eStmt], p->zReadExprlist);
+ }else{
+ zSql = sqlite3_mprintf(azSql[eStmt], p->zDb, p->zName);
+@@ -407,8 +409,7 @@ static int fts3SqlStmt(
+ if( !zSql ){
+ rc = SQLITE_NOMEM;
+ }else{
+- rc = sqlite3_prepare_v3(p->db, zSql, -1, SQLITE_PREPARE_PERSISTENT,
+- &pStmt, NULL);
++ rc = sqlite3_prepare_v3(p->db, zSql, -1, f, &pStmt, NULL);
+ sqlite3_free(zSql);
+ assert( rc==SQLITE_OK || pStmt==0 );
+ p->aStmt[eStmt] = pStmt;
+diff --git a/third_party/sqlite/src/ext/fts5/fts5_index.c b/third_party/sqlite/src/ext/fts5/fts5_index.c
+index 833b5e283644..7cacf930cc85 100644
+--- a/third_party/sqlite/src/ext/fts5/fts5_index.c
++++ b/third_party/sqlite/src/ext/fts5/fts5_index.c
+@@ -729,7 +729,8 @@ static int fts5IndexPrepareStmt(
+ if( p->rc==SQLITE_OK ){
+ if( zSql ){
+ p->rc = sqlite3_prepare_v3(p->pConfig->db, zSql, -1,
+- SQLITE_PREPARE_PERSISTENT, ppStmt, 0);
++ SQLITE_PREPARE_PERSISTENT|SQLITE_PREPARE_NO_VTAB,
++ ppStmt, 0);
+ }else{
+ p->rc = SQLITE_NOMEM;
+ }
+@@ -770,23 +771,12 @@ static void fts5DataDelete(Fts5Index *p, i64 iFirst, i64 iLast){
+ if( p->rc!=SQLITE_OK ) return;
+
+ if( p->pDeleter==0 ){
+- int rc;
+ Fts5Config *pConfig = p->pConfig;
+ char *zSql = sqlite3_mprintf(
+ "DELETE FROM '%q'.'%q_data' WHERE id>=? AND id<=?",
+ pConfig->zDb, pConfig->zName
+ );
+- if( zSql==0 ){
+- rc = SQLITE_NOMEM;
+- }else{
+- rc = sqlite3_prepare_v3(pConfig->db, zSql, -1,
+- SQLITE_PREPARE_PERSISTENT, &p->pDeleter, 0);
+- sqlite3_free(zSql);
+- }
+- if( rc!=SQLITE_OK ){
+- p->rc = rc;
+- return;
+- }
++ if( fts5IndexPrepareStmt(p, &p->pDeleter, zSql) ) return;
+ }
+
+ sqlite3_bind_int64(p->pDeleter, 1, iFirst);
+diff --git a/third_party/sqlite/src/ext/fts5/fts5_storage.c b/third_party/sqlite/src/ext/fts5/fts5_storage.c
+index 8424f9d536b2..1f08a9a7a848 100644
+--- a/third_party/sqlite/src/ext/fts5/fts5_storage.c
++++ b/third_party/sqlite/src/ext/fts5/fts5_storage.c
+@@ -136,8 +136,9 @@ static int fts5StorageGetStmt(
+ if( zSql==0 ){
+ rc = SQLITE_NOMEM;
+ }else{
+- rc = sqlite3_prepare_v3(pC->db, zSql, -1,
+- SQLITE_PREPARE_PERSISTENT, &p->aStmt[eStmt], 0);
++ int f = SQLITE_PREPARE_PERSISTENT;
++ if( eStmt>FTS5_STMT_LOOKUP ) f |= SQLITE_PREPARE_NO_VTAB;
++ rc = sqlite3_prepare_v3(pC->db, zSql, -1, f, &p->aStmt[eStmt], 0);
+ sqlite3_free(zSql);
+ if( rc!=SQLITE_OK && pzErrMsg ){
+ *pzErrMsg = sqlite3_mprintf("%s", sqlite3_errmsg(pC->db));
+diff --git a/third_party/sqlite/src/ext/rtree/rtree.c b/third_party/sqlite/src/ext/rtree/rtree.c
+index 9c436d5989e5..e09db482279e 100644
+--- a/third_party/sqlite/src/ext/rtree/rtree.c
++++ b/third_party/sqlite/src/ext/rtree/rtree.c
+@@ -3395,6 +3395,7 @@ static int rtreeSqlInit(
+ };
+ sqlite3_stmt **appStmt[N_STATEMENT];
+ int i;
++ const int f = SQLITE_PREPARE_PERSISTENT|SQLITE_PREPARE_NO_VTAB;
+
+ pRtree->db = db;
+
+@@ -3451,8 +3452,7 @@ static int rtreeSqlInit(
+ }
+ zSql = sqlite3_mprintf(zFormat, zDb, zPrefix);
+ if( zSql ){
+- rc = sqlite3_prepare_v3(db, zSql, -1, SQLITE_PREPARE_PERSISTENT,
+- appStmt[i], 0);
++ rc = sqlite3_prepare_v3(db, zSql, -1, f, appStmt[i], 0);
+ }else{
+ rc = SQLITE_NOMEM;
+ }
+@@ -3482,8 +3482,7 @@ static int rtreeSqlInit(
+ if( zSql==0 ){
+ rc = SQLITE_NOMEM;
+ }else{
+- rc = sqlite3_prepare_v3(db, zSql, -1, SQLITE_PREPARE_PERSISTENT,
+- &pRtree->pWriteAux, 0);
++ rc = sqlite3_prepare_v3(db, zSql, -1, f, &pRtree->pWriteAux, 0);
+ sqlite3_free(zSql);
+ }
+ }
+diff --git a/third_party/sqlite/src/src/build.c b/third_party/sqlite/src/src/build.c
+index 5939fa9974a8..e6e48875d129 100644
+--- a/third_party/sqlite/src/src/build.c
++++ b/third_party/sqlite/src/src/build.c
+@@ -354,26 +354,32 @@ Table *sqlite3LocateTable(
+
+ p = sqlite3FindTable(db, zName, zDbase);
+ if( p==0 ){
+- const char *zMsg = flags & LOCATE_VIEW ? "no such view" : "no such table";
+ #ifndef SQLITE_OMIT_VIRTUALTABLE
+ /* If zName is the not the name of a table in the schema created using
+ ** CREATE, then check to see if it is the name of an virtual table that
+ ** can be an eponymous virtual table. */
+- Module *pMod = (Module*)sqlite3HashFind(&db->aModule, zName);
+- if( pMod==0 && sqlite3_strnicmp(zName, "pragma_", 7)==0 ){
+- pMod = sqlite3PragmaVtabRegister(db, zName);
+- }
+- if( pMod && sqlite3VtabEponymousTableInit(pParse, pMod) ){
+- return pMod->pEpoTab;
++ if( pParse->disableVtab==0 ){
++ Module *pMod = (Module*)sqlite3HashFind(&db->aModule, zName);
++ if( pMod==0 && sqlite3_strnicmp(zName, "pragma_", 7)==0 ){
++ pMod = sqlite3PragmaVtabRegister(db, zName);
++ }
++ if( pMod && sqlite3VtabEponymousTableInit(pParse, pMod) ){
++ return pMod->pEpoTab;
++ }
+ }
+ #endif
+- if( (flags & LOCATE_NOERR)==0 ){
+- if( zDbase ){
+- sqlite3ErrorMsg(pParse, "%s: %s.%s", zMsg, zDbase, zName);
+- }else{
+- sqlite3ErrorMsg(pParse, "%s: %s", zMsg, zName);
+- }
+- pParse->checkSchema = 1;
++ if( flags & LOCATE_NOERR ) return 0;
++ pParse->checkSchema = 1;
++ }else if( IsVirtual(p) && pParse->disableVtab ){
++ p = 0;
++ }
++
++ if( p==0 ){
++ const char *zMsg = flags & LOCATE_VIEW ? "no such view" : "no such table";
++ if( zDbase ){
++ sqlite3ErrorMsg(pParse, "%s: %s.%s", zMsg, zDbase, zName);
++ }else{
++ sqlite3ErrorMsg(pParse, "%s: %s", zMsg, zName);
+ }
+ }
+
+diff --git a/third_party/sqlite/src/src/prepare.c b/third_party/sqlite/src/src/prepare.c
+index cdf6f65bb115..87711315a0c0 100644
+--- a/third_party/sqlite/src/src/prepare.c
++++ b/third_party/sqlite/src/src/prepare.c
+@@ -541,6 +541,7 @@ static int sqlite3Prepare(
+ sParse.disableLookaside++;
+ db->lookaside.bDisable++;
+ }
++ sParse.disableVtab = (prepFlags & SQLITE_PREPARE_NO_VTAB)!=0;
+
+ /* Check to verify that it is possible to get a read lock on all
+ ** database schemas. The inability to get a read lock indicates that
+diff --git a/third_party/sqlite/src/src/sqlite.h.in b/third_party/sqlite/src/src/sqlite.h.in
+index 11622a49697f..cf623163eaa1 100644
+--- a/third_party/sqlite/src/src/sqlite.h.in
++++ b/third_party/sqlite/src/src/sqlite.h.in
+@@ -3637,10 +3637,16 @@ int sqlite3_limit(sqlite3*, int id, int newVal);
+ ** normalize a SQL statement are unspecified and subject to change.
+ ** At a minimum, literal values will be replaced with suitable
+ ** placeholders.
++**
++** [[SQLITE_PREPARE_NO_VTAB]] <dt>SQLITE_PREPARE_NO_VTAB</dt>
++** <dd>The SQLITE_PREPARE_NO_VTAB flag causes the SQL compiler
++** to return an error (error code SQLITE_ERROR) if the statement uses
++** any virtual tables.
+ ** </dl>
+ */
+ #define SQLITE_PREPARE_PERSISTENT 0x01
+ #define SQLITE_PREPARE_NORMALIZE 0x02
++#define SQLITE_PREPARE_NO_VTAB 0x04
+
+ /*
+ ** CAPI3REF: Compiling An SQL Statement
+diff --git a/third_party/sqlite/src/src/sqliteInt.h b/third_party/sqlite/src/src/sqliteInt.h
+index 44d1406110ee..1aae87ea13b4 100644
+--- a/third_party/sqlite/src/src/sqliteInt.h
++++ b/third_party/sqlite/src/src/sqliteInt.h
+@@ -3057,6 +3057,7 @@ struct Parse {
+ u8 hasCompound; /* Need to invoke convertCompoundSelectToSubquery() */
+ u8 okConstFactor; /* OK to factor out constants */
+ u8 disableLookaside; /* Number of times lookaside has been disabled */
++ u8 disableVtab; /* Disable all virtual tables for this parse */
+ int nRangeReg; /* Size of the temporary register block */
+ int iRangeReg; /* First register in temporary register block */
+ int nErr; /* Number of errors seen */
+diff --git a/third_party/sqlite/src/src/trigger.c b/third_party/sqlite/src/src/trigger.c
+index cf31851f038f..69fddedd914a 100644
+--- a/third_party/sqlite/src/src/trigger.c
++++ b/third_party/sqlite/src/src/trigger.c
+@@ -916,6 +916,7 @@ static TriggerPrg *codeRowTrigger(
+ pSubParse->zAuthContext = pTrigger->zName;
+ pSubParse->eTriggerOp = pTrigger->op;
+ pSubParse->nQueryLoop = pParse->nQueryLoop;
++ pSubParse->disableVtab = pParse->disableVtab;
+
+ v = sqlite3GetVdbe(pSubParse);
+ if( v ){
+--
+2.18.0
+
diff --git a/chromium/third_party/sqlite/patches/0039-Fix-overly-large-malloc-on-btree-corruption.patch b/chromium/third_party/sqlite/patches/0039-Fix-overly-large-malloc-on-btree-corruption.patch
new file mode 100644
index 00000000000..83d67645830
--- /dev/null
+++ b/chromium/third_party/sqlite/patches/0039-Fix-overly-large-malloc-on-btree-corruption.patch
@@ -0,0 +1,28 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Victor Costan <pwnall@chromium.org>
+Date: Mon, 21 Jan 2019 16:37:48 -0800
+Subject: [PATCH 39/40] Fix overly large malloc on btree corruption.
+
+This backports https://www.sqlite.org/src/info/3ecaaee69f49e43d
+
+Bug: 914614
+---
+ third_party/sqlite/src/src/btree.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/third_party/sqlite/src/src/btree.c b/third_party/sqlite/src/src/btree.c
+index 3b018b5cc3c8..eaff20b24e2a 100644
+--- a/third_party/sqlite/src/src/btree.c
++++ b/third_party/sqlite/src/src/btree.c
+@@ -5474,7 +5474,7 @@ int sqlite3BtreeMovetoUnpacked(
+ testcase( nCell==0 ); /* Invalid key size: 0x80 0x80 0x00 */
+ testcase( nCell==1 ); /* Invalid key size: 0x80 0x80 0x01 */
+ testcase( nCell==2 ); /* Minimum legal index key size */
+- if( nCell<2 ){
++ if( nCell<2 || nCell/pCur->pBt->usableSize>pCur->pBt->nPage ){
+ rc = SQLITE_CORRUPT_PAGE(pPage);
+ goto moveto_finish;
+ }
+--
+2.18.0
+
diff --git a/chromium/third_party/sqlite/patches/0040-Fix-null-pointer-access-on-corrupted-index-key.patch b/chromium/third_party/sqlite/patches/0040-Fix-null-pointer-access-on-corrupted-index-key.patch
new file mode 100644
index 00000000000..873861030df
--- /dev/null
+++ b/chromium/third_party/sqlite/patches/0040-Fix-null-pointer-access-on-corrupted-index-key.patch
@@ -0,0 +1,44 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Victor Costan <pwnall@chromium.org>
+Date: Mon, 21 Jan 2019 22:29:21 -0800
+Subject: [PATCH 40/40] Fix null pointer access on corrupted index key.
+
+This backports https://www.sqlite.org/src/info/058a8006dceda78a
+
+Bug: 923902
+---
+ third_party/sqlite/src/src/vdbeaux.c | 9 ++++++---
+ 1 file changed, 6 insertions(+), 3 deletions(-)
+
+diff --git a/third_party/sqlite/src/src/vdbeaux.c b/third_party/sqlite/src/src/vdbeaux.c
+index 1e9812288cfa..13b2e1ef7280 100644
+--- a/third_party/sqlite/src/src/vdbeaux.c
++++ b/third_party/sqlite/src/src/vdbeaux.c
+@@ -3818,7 +3818,8 @@ static int vdbeRecordCompareDebug(
+
+ /* Do the comparison
+ */
+- rc = sqlite3MemCompare(&mem1, &pPKey2->aMem[i], pKeyInfo->aColl[i]);
++ rc = sqlite3MemCompare(&mem1, &pPKey2->aMem[i],
++ pKeyInfo->nAllField>i ? pKeyInfo->aColl[i] : 0);
+ if( rc!=0 ){
+ assert( mem1.szMalloc==0 ); /* See comment below */
+ if( pKeyInfo->aSortOrder[i] ){
+@@ -4249,10 +4250,12 @@ int sqlite3VdbeRecordCompareWithSkip(
+ mem1.n = (serial_type - 12) / 2;
+ testcase( (d1+mem1.n)==(unsigned)nKey1 );
+ testcase( (d1+mem1.n+1)==(unsigned)nKey1 );
+- if( (d1+mem1.n) > (unsigned)nKey1 ){
++ if( (d1+mem1.n) > (unsigned)nKey1
++ || (pKeyInfo = pPKey2->pKeyInfo)->nAllField<=i
++ ){
+ pPKey2->errCode = (u8)SQLITE_CORRUPT_BKPT;
+ return 0; /* Corruption */
+- }else if( (pKeyInfo = pPKey2->pKeyInfo)->aColl[i] ){
++ }else if( pKeyInfo->aColl[i] ){
+ mem1.enc = pKeyInfo->enc;
+ mem1.db = pKeyInfo->db;
+ mem1.flags = MEM_Str;
+--
+2.18.0
+
diff --git a/chromium/third_party/sqlite/scripts/generate_amalgamation.sh b/chromium/third_party/sqlite/scripts/generate_amalgamation.sh
index 3883563cae1..08bba8f889e 100755
--- a/chromium/third_party/sqlite/scripts/generate_amalgamation.sh
+++ b/chromium/third_party/sqlite/scripts/generate_amalgamation.sh
@@ -1,17 +1,63 @@
-#!/bin/bash
+#!/bin/sh
#
# Copyright (c) 2015 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+set -o errexit # Stop the script on the first error.
+set -o nounset # Catch un-initialized variables.
+
cd src
-mkdir bld
-cd bld
-../configure
+mkdir build
+cd build
+
+# The compile flags here should match the defines in BUILD.gn.
+BUILD_GN_FLAGS="\
+ -DSQLITE_DISABLE_FTS3_UNICODE \
+ -DSQLITE_DISABLE_FTS4_DEFERRED \
+ -DSQLITE_ENABLE_FTS3 \
+ -DSQLITE_ENABLE_ICU \
+ -DSQLITE_DEFAULT_FILE_PERMISSIONS=0600 \
+ -DSQLITE_DEFAULT_LOOKASIDE=0,0 \
+ -DSQLITE_DEFAULT_MEMSTATUS=1 \
+ -DSQLITE_DEFAULT_PAGE_SIZE=4096 \
+ -DSQLITE_DEFAULT_PCACHE_INITSZ=0 \
+ -DSQLITE_LIKE_DOESNT_MATCH_BLOBS \
+ -DSQLITE_HAVE_ISNAN \
+ -DSQLITE_MAX_WORKER_THREADS=0 \
+ -DSQLITE_MAX_MMAP_SIZE=268435456 \
+ -DSQLITE_OMIT_ANALYZE \
+ -DSQLITE_OMIT_AUTOINIT \
+ -DSQLITE_OMIT_AUTORESET \
+ -DSQLITE_OMIT_COMPILEOPTION_DIAGS \
+ -DSQLITE_OMIT_COMPLETE \
+ -DSQLITE_OMIT_DECLTYPE \
+ -DSQLITE_OMIT_DEPRECATED \
+ -DSQLITE_OMIT_EXPLAIN \
+ -DSQLITE_OMIT_GET_TABLE \
+ -DSQLITE_OMIT_LOAD_EXTENSION \
+ -DSQLITE_OMIT_LOOKASIDE \
+ -DSQLITE_OMIT_TCL_VARIABLE \
+ -DSQLITE_OMIT_PROGRESS_CALLBACK \
+ -DSQLITE_OMIT_REINDEX \
+ -DSQLITE_OMIT_SHARED_CACHE \
+ -DSQLITE_OMIT_TRACE \
+ -DSQLITE_OMIT_UPSERT \
+ -DSQLITE_OMIT_WINDOWFUNC \
+ -DSQLITE_SECURE_DELETE \
+ -DSQLITE_THREADSAFE=1 \
+ -DSQLITE_USE_ALLOCA \
+"
+
+../configure \
+ CFLAGS="-Os $BUILD_GN_FLAGS $(icu-config --cppflags)" \
+ LDFLAGS="$(icu-config --ldflags)" \
+ --disable-load-extension \
+ --enable-amalgamation \
+ --enable-threadsafe
-OPTS="-DSQLITE_OMIT_UPSERT -DSQLITE_OMIT_WINDOWFUNC"
-make "OPTS=$OPTS" shell.c sqlite3.h sqlite3.c
+make shell.c sqlite3.h sqlite3.c
cp -f sqlite3.h sqlite3.c ../../amalgamation
# shell.c must be placed in a different directory from sqlite3.h, because it
@@ -21,7 +67,7 @@ mkdir -p ../../amalgamation/shell/
cp -f shell.c ../../amalgamation/shell/
cd ..
-rm -rf bld
+rm -rf build
../scripts/extract_sqlite_api.py ../amalgamation/sqlite3.h \
../amalgamation/rename_exports.h
diff --git a/chromium/third_party/sqlite/src/Makefile.linux-gcc b/chromium/third_party/sqlite/src/Makefile.linux-gcc
index a37d41a0099..3047d172389 100644
--- a/chromium/third_party/sqlite/src/Makefile.linux-gcc
+++ b/chromium/third_party/sqlite/src/Makefile.linux-gcc
@@ -14,7 +14,7 @@
#### The toplevel directory of the source tree. This is the directory
# that contains this "Makefile.in" and the "configure.in" script.
#
-TOP = ..
+TOP = ../sqlite
#### C Compiler and options for use in building executables that
# will run on the platform that is doing the build.
@@ -32,19 +32,19 @@ USLEEP = -DHAVE_USLEEP=1
# multi-threaded program, then define the following macro
# appropriately:
#
-THREADSAFE = -DTHREADSAFE=1
-#THREADSAFE = -DTHREADSAFE=0
+#THREADSAFE = -DTHREADSAFE=1
+THREADSAFE = -DTHREADSAFE=0
#### Specify any extra linker options needed to make the library
# thread safe
#
-THREADLIB = -lpthread
-#THREADLIB =
+#THREADLIB = -lpthread
+THREADLIB =
#### Specify any extra libraries needed to access required functions.
#
#TLIBS = -lrt # fdatasync on Solaris 8
-TLIBS = -ldl
+TLIBS =
#### Leave SQLITE_DEBUG undefined for maximum speed. Use SQLITE_DEBUG=1
# to check for memory leaks. Use SQLITE_DEBUG=2 to print a log of all
@@ -58,24 +58,7 @@ TLIBS = -ldl
#OPTS = -DSQLITE_DEBUG=1
#OPTS =
OPTS = -DNDEBUG=1
-#OPTS += -DHAVE_FDATASYNC=1
-
-# These flags match those for SQLITE_CFLAGS in config.mk.
-
-OPTS += -DSQLITE_DEFAULT_FILE_PERMISSIONS=0600
-OPTS += -DHAVE_USLEEP=1
-
-# Additional SQLite tests.
-OPTS += -DSQLITE_MEMDEBUG=1
-
-# Don't include these ones, they break the SQLite tests.
-# -DSQLITE_OMIT_ATTACH=1 \
-# -DSQLITE_OMIT_LOAD_EXTENSION=1 \
-# -DSQLITE_OMIT_VACUUM=1 \
-# -DSQLITE_TRANSACTION_DEFAULT_IMMEDIATE=1 \
-
-# TODO(shess) I can't see why I need this setting.
-OPTS += -DOS_UNIX=1
+OPTS += -DHAVE_FDATASYNC=1
# Support for loading Chromium ICU data in sqlite3.
ifeq ($(shell uname -s),Darwin)
@@ -94,7 +77,7 @@ EXE =
# will run on the target platform. This is usually the same
# as BCC, unless you are cross-compiling.
#
-TCC = gcc -Os
+TCC = gcc -O6
#TCC = gcc -g -O0 -Wall
#TCC = gcc -g -O0 -Wall -fprofile-arcs -ftest-coverage
#TCC = /opt/mingw/bin/i386-mingw32-gcc -O6
@@ -115,16 +98,16 @@ SHPREFIX = lib
#### Extra compiler options needed for programs that use the TCL library.
#
-TCL_FLAGS = -I/usr/include/tcl8.6
+#TCL_FLAGS =
#TCL_FLAGS = -DSTATIC_BUILD=1
-#TCL_FLAGS = -I/home/drh/tcltk/8.5linux
+TCL_FLAGS = -I/home/drh/tcltk/8.5linux
#TCL_FLAGS = -I/home/drh/tcltk/8.5win -DSTATIC_BUILD=1
#TCL_FLAGS = -I/home/drh/tcltk/8.3hpux
#### Linker options needed to link against the TCL library.
#
-LIBTCL = -ltcl8.6 -lm -ldl
-#LIBTCL = /home/drh/tcltk/8.5linux/libtcl8.5g.a -lm -ldl
+#LIBTCL = -ltcl -lm -ldl
+LIBTCL = /home/drh/tcltk/8.5linux/libtcl8.5g.a -lm -ldl
#LIBTCL = /home/drh/tcltk/8.5win/libtcl85s.a -lmsvcrt
#LIBTCL = /home/drh/tcltk/8.3hpux/libtcl8.3.a -ldld -lm -lc
diff --git a/chromium/third_party/sqlite/src/ext/fts3/fts3.c b/chromium/third_party/sqlite/src/ext/fts3/fts3.c
index ef69a7b1868..005d8e50212 100644
--- a/chromium/third_party/sqlite/src/ext/fts3/fts3.c
+++ b/chromium/third_party/sqlite/src/ext/fts3/fts3.c
@@ -2899,7 +2899,7 @@ static int fts3SegReaderCursor(
/* If zTerm is not NULL, and this segment is not stored entirely on its
** root node, the range of leaves scanned can be reduced. Do this. */
- if( iStartBlock && zTerm ){
+ if( iStartBlock && zTerm && zRoot ){
sqlite3_int64 *pi = (isPrefix ? &iLeavesEndBlock : 0);
rc = fts3SelectLeaf(p, zTerm, nTerm, zRoot, nRoot, &iStartBlock, pi);
if( rc!=SQLITE_OK ) goto finished;
diff --git a/chromium/third_party/sqlite/src/ext/fts3/fts3_write.c b/chromium/third_party/sqlite/src/ext/fts3/fts3_write.c
index fc599a0c3e0..9bc6d70f45c 100644
--- a/chromium/third_party/sqlite/src/ext/fts3/fts3_write.c
+++ b/chromium/third_party/sqlite/src/ext/fts3/fts3_write.c
@@ -396,10 +396,12 @@ static int fts3SqlStmt(
pStmt = p->aStmt[eStmt];
if( !pStmt ){
+ int f = SQLITE_PREPARE_PERSISTENT|SQLITE_PREPARE_NO_VTAB;
char *zSql;
if( eStmt==SQL_CONTENT_INSERT ){
zSql = sqlite3_mprintf(azSql[eStmt], p->zDb, p->zName, p->zWriteExprlist);
}else if( eStmt==SQL_SELECT_CONTENT_BY_ROWID ){
+ f &= ~SQLITE_PREPARE_NO_VTAB;
zSql = sqlite3_mprintf(azSql[eStmt], p->zReadExprlist);
}else{
zSql = sqlite3_mprintf(azSql[eStmt], p->zDb, p->zName);
@@ -407,8 +409,7 @@ static int fts3SqlStmt(
if( !zSql ){
rc = SQLITE_NOMEM;
}else{
- rc = sqlite3_prepare_v3(p->db, zSql, -1, SQLITE_PREPARE_PERSISTENT,
- &pStmt, NULL);
+ rc = sqlite3_prepare_v3(p->db, zSql, -1, f, &pStmt, NULL);
sqlite3_free(zSql);
assert( rc==SQLITE_OK || pStmt==0 );
p->aStmt[eStmt] = pStmt;
diff --git a/chromium/third_party/sqlite/src/ext/fts5/fts5_index.c b/chromium/third_party/sqlite/src/ext/fts5/fts5_index.c
index 833b5e28364..7cacf930cc8 100644
--- a/chromium/third_party/sqlite/src/ext/fts5/fts5_index.c
+++ b/chromium/third_party/sqlite/src/ext/fts5/fts5_index.c
@@ -729,7 +729,8 @@ static int fts5IndexPrepareStmt(
if( p->rc==SQLITE_OK ){
if( zSql ){
p->rc = sqlite3_prepare_v3(p->pConfig->db, zSql, -1,
- SQLITE_PREPARE_PERSISTENT, ppStmt, 0);
+ SQLITE_PREPARE_PERSISTENT|SQLITE_PREPARE_NO_VTAB,
+ ppStmt, 0);
}else{
p->rc = SQLITE_NOMEM;
}
@@ -770,23 +771,12 @@ static void fts5DataDelete(Fts5Index *p, i64 iFirst, i64 iLast){
if( p->rc!=SQLITE_OK ) return;
if( p->pDeleter==0 ){
- int rc;
Fts5Config *pConfig = p->pConfig;
char *zSql = sqlite3_mprintf(
"DELETE FROM '%q'.'%q_data' WHERE id>=? AND id<=?",
pConfig->zDb, pConfig->zName
);
- if( zSql==0 ){
- rc = SQLITE_NOMEM;
- }else{
- rc = sqlite3_prepare_v3(pConfig->db, zSql, -1,
- SQLITE_PREPARE_PERSISTENT, &p->pDeleter, 0);
- sqlite3_free(zSql);
- }
- if( rc!=SQLITE_OK ){
- p->rc = rc;
- return;
- }
+ if( fts5IndexPrepareStmt(p, &p->pDeleter, zSql) ) return;
}
sqlite3_bind_int64(p->pDeleter, 1, iFirst);
diff --git a/chromium/third_party/sqlite/src/ext/fts5/fts5_storage.c b/chromium/third_party/sqlite/src/ext/fts5/fts5_storage.c
index 8424f9d536b..1f08a9a7a84 100644
--- a/chromium/third_party/sqlite/src/ext/fts5/fts5_storage.c
+++ b/chromium/third_party/sqlite/src/ext/fts5/fts5_storage.c
@@ -136,8 +136,9 @@ static int fts5StorageGetStmt(
if( zSql==0 ){
rc = SQLITE_NOMEM;
}else{
- rc = sqlite3_prepare_v3(pC->db, zSql, -1,
- SQLITE_PREPARE_PERSISTENT, &p->aStmt[eStmt], 0);
+ int f = SQLITE_PREPARE_PERSISTENT;
+ if( eStmt>FTS5_STMT_LOOKUP ) f |= SQLITE_PREPARE_NO_VTAB;
+ rc = sqlite3_prepare_v3(pC->db, zSql, -1, f, &p->aStmt[eStmt], 0);
sqlite3_free(zSql);
if( rc!=SQLITE_OK && pzErrMsg ){
*pzErrMsg = sqlite3_mprintf("%s", sqlite3_errmsg(pC->db));
diff --git a/chromium/third_party/sqlite/src/ext/rtree/rtree.c b/chromium/third_party/sqlite/src/ext/rtree/rtree.c
index 9c436d5989e..e09db482279 100644
--- a/chromium/third_party/sqlite/src/ext/rtree/rtree.c
+++ b/chromium/third_party/sqlite/src/ext/rtree/rtree.c
@@ -3395,6 +3395,7 @@ static int rtreeSqlInit(
};
sqlite3_stmt **appStmt[N_STATEMENT];
int i;
+ const int f = SQLITE_PREPARE_PERSISTENT|SQLITE_PREPARE_NO_VTAB;
pRtree->db = db;
@@ -3451,8 +3452,7 @@ static int rtreeSqlInit(
}
zSql = sqlite3_mprintf(zFormat, zDb, zPrefix);
if( zSql ){
- rc = sqlite3_prepare_v3(db, zSql, -1, SQLITE_PREPARE_PERSISTENT,
- appStmt[i], 0);
+ rc = sqlite3_prepare_v3(db, zSql, -1, f, appStmt[i], 0);
}else{
rc = SQLITE_NOMEM;
}
@@ -3482,8 +3482,7 @@ static int rtreeSqlInit(
if( zSql==0 ){
rc = SQLITE_NOMEM;
}else{
- rc = sqlite3_prepare_v3(db, zSql, -1, SQLITE_PREPARE_PERSISTENT,
- &pRtree->pWriteAux, 0);
+ rc = sqlite3_prepare_v3(db, zSql, -1, f, &pRtree->pWriteAux, 0);
sqlite3_free(zSql);
}
}
diff --git a/chromium/third_party/sqlite/src/main.mk b/chromium/third_party/sqlite/src/main.mk
index 40ab267ec72..b460a58d9a9 100644
--- a/chromium/third_party/sqlite/src/main.mk
+++ b/chromium/third_party/sqlite/src/main.mk
@@ -840,7 +840,7 @@ sqlite3_analyzer.c: sqlite3.c $(TOP)/src/tclsqlite.c $(TOP)/tool/spaceanal.tcl $
tclsh $(TOP)/tool/mkccode.tcl $(TOP)/tool/sqlite3_analyzer.c.in >sqlite3_analyzer.c
sqlite3_analyzer$(EXE): sqlite3_analyzer.c
- $(TCCX) $(TCL_FLAGS) sqlite3_analyzer.c -o $@ $(LIBTCL) $(TLIBS) $(THREADLIB)
+ $(TCCX) $(TCL_FLAGS) sqlite3_analyzer.c -o $@ $(LIBTCL) $(THREADLIB)
sqltclsh.c: sqlite3.c $(TOP)/src/tclsqlite.c $(TOP)/tool/sqltclsh.tcl $(TOP)/ext/misc/appendvfs.c $(TOP)/tool/mkccode.tcl
tclsh $(TOP)/tool/mkccode.tcl $(TOP)/tool/sqltclsh.c.in >sqltclsh.c
diff --git a/chromium/third_party/sqlite/src/src/btree.c b/chromium/third_party/sqlite/src/src/btree.c
index 62f4bd9db1d..eaff20b24e2 100644
--- a/chromium/third_party/sqlite/src/src/btree.c
+++ b/chromium/third_party/sqlite/src/src/btree.c
@@ -660,13 +660,19 @@ static int saveCursorKey(BtCursor *pCur){
/* Only the rowid is required for a table btree */
pCur->nKey = sqlite3BtreeIntegerKey(pCur);
}else{
- /* For an index btree, save the complete key content */
+ /* For an index btree, save the complete key content. It is possible
+ ** that the current key is corrupt. In that case, it is possible that
+ ** the sqlite3VdbeRecordUnpack() function may overread the buffer by
+ ** up to the size of 1 varint plus 1 8-byte value when the cursor
+ ** position is restored. Hence the 17 bytes of padding allocated
+ ** below. */
void *pKey;
pCur->nKey = sqlite3BtreePayloadSize(pCur);
- pKey = sqlite3Malloc( pCur->nKey );
+ pKey = sqlite3Malloc( pCur->nKey + 9 + 8 );
if( pKey ){
rc = sqlite3BtreePayload(pCur, 0, (int)pCur->nKey, pKey);
if( rc==SQLITE_OK ){
+ memset(((u8*)pKey)+pCur->nKey, 0, 9+8);
pCur->pKey = pKey;
}else{
sqlite3_free(pKey);
@@ -1061,7 +1067,7 @@ static int ptrmapGet(BtShared *pBt, Pgno key, u8 *pEType, Pgno *pPgno){
#else /* if defined SQLITE_OMIT_AUTOVACUUM */
#define ptrmapPut(w,x,y,z,rc)
#define ptrmapGet(w,x,y,z) SQLITE_OK
- #define ptrmapPutOvflPtr(x, y, rc)
+ #define ptrmapPutOvflPtr(x, y, z, rc)
#endif
/*
@@ -1354,18 +1360,20 @@ static u16 cellSize(MemPage *pPage, int iCell){
#ifndef SQLITE_OMIT_AUTOVACUUM
/*
-** If the cell pCell, part of page pPage contains a pointer
-** to an overflow page, insert an entry into the pointer-map
-** for the overflow page.
+** The cell pCell is currently part of page pSrc but will ultimately be part
+** of pPage. (pSrc and pPager are often the same.) If pCell contains a
+** pointer to an overflow page, insert an entry into the pointer-map for
+** the overflow page that will be valid after pCell has been moved to pPage.
*/
-static void ptrmapPutOvflPtr(MemPage *pPage, u8 *pCell, int *pRC){
+static void ptrmapPutOvflPtr(MemPage *pPage, MemPage *pSrc, u8 *pCell, int *pRC){
CellInfo info;
if( *pRC ) return;
assert( pCell!=0 );
pPage->xParseCell(pPage, pCell, &info);
if( info.nLocal<info.nPayload ){
Pgno ovfl;
- if( SQLITE_WITHIN(pPage->aDataEnd, pCell, pCell+info.nLocal) ){
+ if( SQLITE_WITHIN(pSrc->aDataEnd, pCell, pCell+info.nLocal) ){
+ testcase( pSrc!=pPage );
*pRC = SQLITE_CORRUPT_BKPT;
return;
}
@@ -1424,18 +1432,14 @@ static int defragmentPage(MemPage *pPage, int nMaxFrag){
** reconstruct the entire page. */
if( (int)data[hdr+7]<=nMaxFrag ){
int iFree = get2byte(&data[hdr+1]);
+
+ /* If the initial freeblock offset were out of bounds, that would
+ ** have been detected by btreeInitPage() when it was computing the
+ ** number of free bytes on the page. */
+ assert( iFree<=usableSize-4 );
if( iFree ){
int iFree2 = get2byte(&data[iFree]);
-
- /* pageFindSlot() has already verified that free blocks are sorted
- ** in order of offset within the page, and that no block extends
- ** past the end of the page. Provided the two free slots do not
- ** overlap, this guarantees that the memmove() calls below will not
- ** overwrite the usableSize byte buffer, even if the database page
- ** is corrupt. */
- assert( iFree2==0 || iFree2>iFree );
- assert( iFree+get2byte(&data[iFree+2]) <= usableSize );
- assert( iFree2==0 || iFree2+get2byte(&data[iFree2+2]) <= usableSize );
+ if( iFree2>usableSize-4 ) return SQLITE_CORRUPT_PAGE(pPage);
if( 0==iFree2 || (data[iFree2]==0 && data[iFree2+1]==0) ){
u8 *pEnd = &data[cellOffset + nCell*2];
@@ -1447,9 +1451,9 @@ static int defragmentPage(MemPage *pPage, int nMaxFrag){
return SQLITE_CORRUPT_PAGE(pPage);
}
if( iFree2 ){
- assert( iFree+sz<=iFree2 ); /* Verified by pageFindSlot() */
+ if( iFree+sz>iFree2 ) return SQLITE_CORRUPT_PAGE(pPage);
sz2 = get2byte(&data[iFree2+2]);
- assert( iFree+sz+sz2+iFree2-(iFree+sz) <= usableSize );
+ if( iFree2+sz2 > usableSize ) return SQLITE_CORRUPT_PAGE(pPage);
memmove(&data[iFree+sz+sz2], &data[iFree+sz], iFree2-(iFree+sz));
sz += sz2;
}
@@ -2993,46 +2997,6 @@ static int newDatabase(BtShared*);
/*
-** Change the 'auto-vacuum-slack-pages' property of the database. If auto vacuum
-** is enabled, this is the number of chunks of slack to allow before
-** automatically running an incremental vacuum.
-*/
-int sqlite3BtreeSetAutoVacuumSlackPages(Btree *p, int autoVacuumSlack){
-#ifdef SQLITE_OMIT_AUTOVACUUM
- return SQLITE_READONLY;
-#else
- BtShared *pBt = p->pBt;
- int rc = SQLITE_OK;
- u8 avs = (u8)autoVacuumSlack;
- if( autoVacuumSlack>avs ){
- avs = 0xFF;
- }
-
- sqlite3BtreeEnter(p);
- pBt->autoVacuumSlack = avs;
- sqlite3BtreeLeave(p);
- return rc;
-#endif
-}
-
-/*
-** Return the value of the 'auto-vacuum-slack-pages' property.
-*/
-int sqlite3BtreeGetAutoVacuumSlackPages(Btree *p){
-#ifdef SQLITE_OMIT_AUTOVACUUM
- return 0;
-#else
- int rc = 0;
- sqlite3BtreeEnter(p);
- if( p->pBt->autoVacuum!=0 ){
- rc = p->pBt->autoVacuumSlack;
- }
- sqlite3BtreeLeave(p);
- return rc;
-#endif
-}
-
-/*
** Get a reference to pPage1 of the database file. This will
** also acquire a readlock on that file.
**
@@ -3044,9 +3008,9 @@ int sqlite3BtreeGetAutoVacuumSlackPages(Btree *p){
static int lockBtree(BtShared *pBt){
int rc; /* Result code from subfunctions */
MemPage *pPage1; /* Page 1 of the database file */
- int nPage; /* Number of pages in the database */
- int nPageFile = 0; /* Number of pages in the database file */
- int nPageHeader; /* Number of pages in the database according to hdr */
+ u32 nPage; /* Number of pages in the database */
+ u32 nPageFile = 0; /* Number of pages in the database file */
+ u32 nPageHeader; /* Number of pages in the database according to hdr */
assert( sqlite3_mutex_held(pBt->mutex) );
assert( pBt->pPage1==0 );
@@ -3059,7 +3023,7 @@ static int lockBtree(BtShared *pBt){
** a valid database file.
*/
nPage = nPageHeader = get4byte(28+(u8*)pPage1->aData);
- sqlite3PagerPagecount(pBt->pPager, &nPageFile);
+ sqlite3PagerPagecount(pBt->pPager, (int*)&nPageFile);
if( nPage==0 || memcmp(24+(u8*)pPage1->aData, 92+(u8*)pPage1->aData,4)!=0 ){
nPage = nPageFile;
}
@@ -3530,7 +3494,7 @@ static int setChildPtrmaps(MemPage *pPage){
for(i=0; i<nCell; i++){
u8 *pCell = findCell(pPage, i);
- ptrmapPutOvflPtr(pPage, pCell, &rc);
+ ptrmapPutOvflPtr(pPage, pPage, pCell, &rc);
if( !pPage->leaf ){
Pgno childPgno = get4byte(pCell);
@@ -3881,27 +3845,13 @@ int sqlite3BtreeIncrVacuum(Btree *p){
*/
static int autoVacuumCommit(BtShared *pBt){
int rc = SQLITE_OK;
- int bShouldVacuum = pBt->autoVacuum && !pBt->incrVacuum;
Pager *pPager = pBt->pPager;
VVA_ONLY( int nRef = sqlite3PagerRefcount(pPager); )
assert( sqlite3_mutex_held(pBt->mutex) );
invalidateAllOverflowCache(pBt);
assert(pBt->autoVacuum);
- if( bShouldVacuum && pBt->autoVacuumSlack ){
- Pgno nOrig; /* Database size before freeing */
- Pgno nFree; /* Number of pages on the freelist initially */
-
- nOrig = btreePagecount(pBt);
- nFree = get4byte(&pBt->pPage1->aData[36]);
- bShouldVacuum =
- (nOrig-nFree-1)/pBt->autoVacuumSlack < (nOrig-1)/pBt->autoVacuumSlack;
- /* TODO: When integrating this test with the following code, contrive to
- ** trim to the integral chunk boundary, rather than trimming the entire free
- ** list.
- */
- }
- if( bShouldVacuum ){
+ if( !pBt->incrVacuum ){
Pgno nFin; /* Number of pages in database after autovacuuming */
Pgno nFree; /* Number of pages on the freelist initially */
Pgno iFree; /* The next page to be freed */
@@ -5524,7 +5474,7 @@ int sqlite3BtreeMovetoUnpacked(
testcase( nCell==0 ); /* Invalid key size: 0x80 0x80 0x00 */
testcase( nCell==1 ); /* Invalid key size: 0x80 0x80 0x01 */
testcase( nCell==2 ); /* Minimum legal index key size */
- if( nCell<2 ){
+ if( nCell<2 || nCell/pCur->pBt->usableSize>pCur->pBt->nPage ){
rc = SQLITE_CORRUPT_PAGE(pPage);
goto moveto_finish;
}
@@ -6713,9 +6663,16 @@ static void insertCell(
assert( idx >= pPage->cellOffset+2*pPage->nCell+2 || CORRUPT_DB );
assert( idx+sz <= (int)pPage->pBt->usableSize );
pPage->nFree -= (u16)(2 + sz);
- memcpy(&data[idx], pCell, sz);
if( iChild ){
+ /* In a corrupt database where an entry in the cell index section of
+ ** a btree page has a value of 3 or less, the pCell value might point
+ ** as many as 4 bytes in front of the start of the aData buffer for
+ ** the source page. Make sure this does not cause problems by not
+ ** reading the first 4 bytes */
+ memcpy(&data[idx+4], pCell+4, sz-4);
put4byte(&data[idx], iChild);
+ }else{
+ memcpy(&data[idx], pCell, sz);
}
pIns = pPage->aCellIdx + i*2;
memmove(pIns+2, pIns, 2*(pPage->nCell - i));
@@ -6729,7 +6686,7 @@ static void insertCell(
/* The cell may contain a pointer to an overflow page. If so, write
** the entry for the overflow page into the pointer map.
*/
- ptrmapPutOvflPtr(pPage, pCell, pRC);
+ ptrmapPutOvflPtr(pPage, pPage, pCell, pRC);
}
#endif
}
@@ -6816,6 +6773,7 @@ static int rebuildPage(
for(i=0; i<nCell; i++){
u8 *pCell = apCell[i];
if( SQLITE_WITHIN(pCell,aData,pEnd) ){
+ if( ((uptr)(pCell+szCell[i]))>(uptr)pEnd ) return SQLITE_CORRUPT_BKPT;
pCell = &pTmp[pCell - aData];
}
pData -= szCell[i];
@@ -7110,8 +7068,7 @@ static int balance_quick(MemPage *pParent, MemPage *pPage, u8 *pSpace){
assert( sqlite3PagerIswriteable(pParent->pDbPage) );
assert( pPage->nOverflow==1 );
- /* This error condition is now caught prior to reaching this function */
- if( NEVER(pPage->nCell==0) ) return SQLITE_CORRUPT_BKPT;
+ if( pPage->nCell==0 ) return SQLITE_CORRUPT_BKPT; /* dbfuzz001.test */
/* Allocate a new page. This page will become the right-sibling of
** pPage. Make the parent page writable, so that the new divider cell
@@ -7145,7 +7102,7 @@ static int balance_quick(MemPage *pParent, MemPage *pPage, u8 *pSpace){
if( ISAUTOVACUUM ){
ptrmapPut(pBt, pgnoNew, PTRMAP_BTREE, pParent->pgno, &rc);
if( szCell>pNew->minLocal ){
- ptrmapPutOvflPtr(pNew, pCell, &rc);
+ ptrmapPutOvflPtr(pNew, pNew, pCell, &rc);
}
}
@@ -7368,10 +7325,6 @@ static int balance_nonroot(
assert( sqlite3_mutex_held(pBt->mutex) );
assert( sqlite3PagerIswriteable(pParent->pDbPage) );
-#if 0
- TRACE(("BALANCE: begin page %d child of %d\n", pPage->pgno, pParent->pgno));
-#endif
-
/* At this point pParent may have at most one overflow cell. And if
** this overflow cell is present, it must be the cell with
** index iParentIdx. This scenario comes about when this function
@@ -7837,7 +7790,8 @@ static int balance_nonroot(
** populated, not here.
*/
if( ISAUTOVACUUM ){
- MemPage *pNew = apNew[0];
+ MemPage *pOld;
+ MemPage *pNew = pOld = apNew[0];
u8 *aOld = pNew->aData;
int cntOldNext = pNew->nCell + pNew->nOverflow;
int usableSize = pBt->usableSize;
@@ -7847,7 +7801,7 @@ static int balance_nonroot(
for(i=0; i<b.nCell; i++){
u8 *pCell = b.apCell[i];
if( i==cntOldNext ){
- MemPage *pOld = (++iOld)<nNew ? apNew[iOld] : apOld[iOld];
+ pOld = (++iOld)<nNew ? apNew[iOld] : apOld[iOld];
cntOldNext += pOld->nCell + pOld->nOverflow + !leafData;
aOld = pOld->aData;
}
@@ -7870,7 +7824,7 @@ static int balance_nonroot(
ptrmapPut(pBt, get4byte(pCell), PTRMAP_BTREE, pNew->pgno, &rc);
}
if( cachedCellSize(&b,i)>pNew->minLocal ){
- ptrmapPutOvflPtr(pNew, pCell, &rc);
+ ptrmapPutOvflPtr(pNew, pOld, pCell, &rc);
}
if( rc ) goto balance_cleanup;
}
@@ -8689,6 +8643,7 @@ int sqlite3BtreeDelete(BtCursor *pCur, u8 flags){
if( bPreserve ){
if( !pPage->leaf
|| (pPage->nFree+cellSizePtr(pPage,pCell)+2)>(int)(pBt->usableSize*2/3)
+ || pPage->nCell==1 /* See dbfuzz001.test for a test case */
){
/* A b-tree rebalance will be required after deleting this entry.
** Save the cursor key. */
@@ -9467,7 +9422,7 @@ static void checkList(
}
pOvflData = (unsigned char *)sqlite3PagerGetData(pOvflPage);
if( isFreeList ){
- int n = get4byte(&pOvflData[4]);
+ u32 n = (u32)get4byte(&pOvflData[4]);
#ifndef SQLITE_OMIT_AUTOVACUUM
if( pCheck->pBt->autoVacuum ){
checkPtrmap(pCheck, iPage, PTRMAP_FREEPAGE, 0);
@@ -9478,7 +9433,7 @@ static void checkList(
"freelist leaf count too big on page %d", iPage);
N--;
}else{
- for(i=0; i<n; i++){
+ for(i=0; i<(int)n; i++){
Pgno iFreePage = get4byte(&pOvflData[8+i*4]);
#ifndef SQLITE_OMIT_AUTOVACUUM
if( pCheck->pBt->autoVacuum ){
diff --git a/chromium/third_party/sqlite/src/src/btree.h b/chromium/third_party/sqlite/src/src/btree.h
index 83307a95ad3..e4bd09c7e72 100644
--- a/chromium/third_party/sqlite/src/src/btree.h
+++ b/chromium/third_party/sqlite/src/src/btree.h
@@ -78,8 +78,6 @@ int sqlite3BtreeGetOptimalReserve(Btree*);
int sqlite3BtreeGetReserveNoMutex(Btree *p);
int sqlite3BtreeSetAutoVacuum(Btree *, int);
int sqlite3BtreeGetAutoVacuum(Btree *);
-int sqlite3BtreeSetAutoVacuumSlackPages(Btree *, int);
-int sqlite3BtreeGetAutoVacuumSlackPages(Btree *);
int sqlite3BtreeBeginTrans(Btree*,int,int*);
int sqlite3BtreeCommitPhaseOne(Btree*, const char *zMaster);
int sqlite3BtreeCommitPhaseTwo(Btree*, int);
diff --git a/chromium/third_party/sqlite/src/src/btreeInt.h b/chromium/third_party/sqlite/src/src/btreeInt.h
index 88f3b437b8e..8fe8e280fe5 100644
--- a/chromium/third_party/sqlite/src/src/btreeInt.h
+++ b/chromium/third_party/sqlite/src/src/btreeInt.h
@@ -412,7 +412,6 @@ struct BtShared {
u8 openFlags; /* Flags to sqlite3BtreeOpen() */
#ifndef SQLITE_OMIT_AUTOVACUUM
u8 autoVacuum; /* True if auto-vacuum is enabled */
- u8 autoVacuumSlack; /* Optional pages of slack for auto-vacuum */
u8 incrVacuum; /* True if incr-vacuum is enabled */
u8 bDoTruncate; /* True to truncate db on commit */
#endif
diff --git a/chromium/third_party/sqlite/src/src/build.c b/chromium/third_party/sqlite/src/src/build.c
index 806c89f439b..e6e48875d12 100644
--- a/chromium/third_party/sqlite/src/src/build.c
+++ b/chromium/third_party/sqlite/src/src/build.c
@@ -354,26 +354,32 @@ Table *sqlite3LocateTable(
p = sqlite3FindTable(db, zName, zDbase);
if( p==0 ){
- const char *zMsg = flags & LOCATE_VIEW ? "no such view" : "no such table";
#ifndef SQLITE_OMIT_VIRTUALTABLE
/* If zName is the not the name of a table in the schema created using
** CREATE, then check to see if it is the name of an virtual table that
** can be an eponymous virtual table. */
- Module *pMod = (Module*)sqlite3HashFind(&db->aModule, zName);
- if( pMod==0 && sqlite3_strnicmp(zName, "pragma_", 7)==0 ){
- pMod = sqlite3PragmaVtabRegister(db, zName);
- }
- if( pMod && sqlite3VtabEponymousTableInit(pParse, pMod) ){
- return pMod->pEpoTab;
+ if( pParse->disableVtab==0 ){
+ Module *pMod = (Module*)sqlite3HashFind(&db->aModule, zName);
+ if( pMod==0 && sqlite3_strnicmp(zName, "pragma_", 7)==0 ){
+ pMod = sqlite3PragmaVtabRegister(db, zName);
+ }
+ if( pMod && sqlite3VtabEponymousTableInit(pParse, pMod) ){
+ return pMod->pEpoTab;
+ }
}
#endif
- if( (flags & LOCATE_NOERR)==0 ){
- if( zDbase ){
- sqlite3ErrorMsg(pParse, "%s: %s.%s", zMsg, zDbase, zName);
- }else{
- sqlite3ErrorMsg(pParse, "%s: %s", zMsg, zName);
- }
- pParse->checkSchema = 1;
+ if( flags & LOCATE_NOERR ) return 0;
+ pParse->checkSchema = 1;
+ }else if( IsVirtual(p) && pParse->disableVtab ){
+ p = 0;
+ }
+
+ if( p==0 ){
+ const char *zMsg = flags & LOCATE_VIEW ? "no such view" : "no such table";
+ if( zDbase ){
+ sqlite3ErrorMsg(pParse, "%s: %s.%s", zMsg, zDbase, zName);
+ }else{
+ sqlite3ErrorMsg(pParse, "%s: %s", zMsg, zName);
}
}
@@ -4417,13 +4423,15 @@ static int collationMatch(const char *zColl, Index *pIndex){
*/
#ifndef SQLITE_OMIT_REINDEX
static void reindexTable(Parse *pParse, Table *pTab, char const *zColl){
- Index *pIndex; /* An index associated with pTab */
-
- for(pIndex=pTab->pIndex; pIndex; pIndex=pIndex->pNext){
- if( zColl==0 || collationMatch(zColl, pIndex) ){
- int iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);
- sqlite3BeginWriteOperation(pParse, 0, iDb);
- sqlite3RefillIndex(pParse, pIndex, -1);
+ if (! IsVirtual(pTab) ){
+ Index *pIndex; /* An index associated with pTab */
+
+ for(pIndex=pTab->pIndex; pIndex; pIndex=pIndex->pNext){
+ if( zColl==0 || collationMatch(zColl, pIndex) ){
+ int iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);
+ sqlite3BeginWriteOperation(pParse, 0, iDb);
+ sqlite3RefillIndex(pParse, pIndex, -1);
+ }
}
}
}
diff --git a/chromium/third_party/sqlite/src/src/expr.c b/chromium/third_party/sqlite/src/src/expr.c
index c61528288ba..50c398266f3 100644
--- a/chromium/third_party/sqlite/src/src/expr.c
+++ b/chromium/third_party/sqlite/src/src/expr.c
@@ -4748,9 +4748,11 @@ int sqlite3ExprCompare(Parse *pParse, Expr *pA, Expr *pB, int iTab){
if( sqlite3WindowCompare(pParse,pA->y.pWin,pB->y.pWin)!=0 ) return 2;
}
#endif
+ }else if( pA->op==TK_NULL ){
+ return 0;
}else if( pA->op==TK_COLLATE ){
if( sqlite3_stricmp(pA->u.zToken,pB->u.zToken)!=0 ) return 2;
- }else if( strcmp(pA->u.zToken,pB->u.zToken)!=0 ){
+ }else if( ALWAYS(pB->u.zToken!=0) && strcmp(pA->u.zToken,pB->u.zToken)!=0 ){
return 2;
}
}
diff --git a/chromium/third_party/sqlite/src/src/insert.c b/chromium/third_party/sqlite/src/src/insert.c
index cd2eec12864..b21bf714923 100644
--- a/chromium/third_party/sqlite/src/src/insert.c
+++ b/chromium/third_party/sqlite/src/src/insert.c
@@ -947,16 +947,12 @@ void sqlite3Insert(
}else if( pSelect ){
sqlite3VdbeAddOp2(v, OP_Copy, regFromSelect+ipkColumn, regRowid);
}else{
- VdbeOp *pOp;
- sqlite3ExprCode(pParse, pList->a[ipkColumn].pExpr, regRowid);
- pOp = sqlite3VdbeGetOp(v, -1);
- assert( pOp!=0 );
- if( pOp->opcode==OP_Null && !IsVirtual(pTab) ){
+ Expr *pIpk = pList->a[ipkColumn].pExpr;
+ if( pIpk->op==TK_NULL && !IsVirtual(pTab) ){
+ sqlite3VdbeAddOp3(v, OP_NewRowid, iDataCur, regRowid, regAutoinc);
appendFlag = 1;
- pOp->opcode = OP_NewRowid;
- pOp->p1 = iDataCur;
- pOp->p2 = regRowid;
- pOp->p3 = regAutoinc;
+ }else{
+ sqlite3ExprCode(pParse, pList->a[ipkColumn].pExpr, regRowid);
}
}
/* If the PRIMARY KEY expression is NULL, then use OP_NewRowid
@@ -1824,7 +1820,7 @@ void sqlite3GenerateConstraintChecks(
/* If the IPK constraint is a REPLACE, run it last */
if( ipkTop ){
- sqlite3VdbeGoto(v, ipkTop+1);
+ sqlite3VdbeGoto(v, ipkTop);
VdbeComment((v, "Do IPK REPLACE"));
sqlite3VdbeJumpHere(v, ipkBottom);
}
@@ -2194,7 +2190,8 @@ static int xferOptimization(
if( pSrc==0 ){
return 0; /* FROM clause does not contain a real table */
}
- if( pSrc==pDest ){
+ if( pSrc->tnum==pDest->tnum && pSrc->pSchema==pDest->pSchema ){
+ testcase( pSrc!=pDest ); /* Possible due to bad sqlite_master.rootpage */
return 0; /* tab1 and tab2 may not be the same table */
}
if( HasRowid(pDest)!=HasRowid(pSrc) ){
diff --git a/chromium/third_party/sqlite/src/src/pcache1.c b/chromium/third_party/sqlite/src/src/pcache1.c
index 1986b22ca61..05ef4bde330 100644
--- a/chromium/third_party/sqlite/src/src/pcache1.c
+++ b/chromium/third_party/sqlite/src/src/pcache1.c
@@ -477,6 +477,9 @@ static void pcache1FreePage(PgHdr1 *p){
** exists, this function falls back to sqlite3Malloc().
*/
void *sqlite3PageMalloc(int sz){
+ /* During rebalance operations on a corrupt database file, it is sometimes
+ ** (rarely) possible to overread the temporary page buffer by a few bytes.
+ ** Enlarge the allocation slightly so that this does not cause problems. */
return pcache1Alloc(sz);
}
diff --git a/chromium/third_party/sqlite/src/src/pragma.c b/chromium/third_party/sqlite/src/src/pragma.c
index 40b600752da..264b10d9464 100644
--- a/chromium/third_party/sqlite/src/src/pragma.c
+++ b/chromium/third_party/sqlite/src/src/pragma.c
@@ -756,27 +756,6 @@ void sqlite3Pragma(
}
#endif
- /*
- ** PRAGMA [schema.]auto_vacuum_slack_pages(N)
- **
- ** Control chunk size of auto-vacuum.
- */
-#ifndef SQLITE_OMIT_AUTOVACUUM
- case PragTyp_AUTO_VACUUM_SLACK_PAGES: {
- Btree *pBt = pDb->pBt;
- assert( pBt!=0 );
- if( !zRight ){
- returnSingleInt(v, sqlite3BtreeGetAutoVacuumSlackPages(pBt));
- }else{
- int nPages = 8;
- if( sqlite3GetInt32(zRight, &nPages) ){
- sqlite3BtreeSetAutoVacuumSlackPages(pBt, nPages);
- }
- }
- break;
- }
-#endif
-
#ifndef SQLITE_OMIT_PAGER_PRAGMAS
/*
** PRAGMA [schema.]cache_size
diff --git a/chromium/third_party/sqlite/src/src/pragma.h b/chromium/third_party/sqlite/src/src/pragma.h
index dd10e0f77f2..c16dd2f0878 100644
--- a/chromium/third_party/sqlite/src/src/pragma.h
+++ b/chromium/third_party/sqlite/src/src/pragma.h
@@ -7,51 +7,50 @@
/* The various pragma types */
#define PragTyp_HEADER_VALUE 0
#define PragTyp_AUTO_VACUUM 1
-#define PragTyp_AUTO_VACUUM_SLACK_PAGES 2
-#define PragTyp_FLAG 3
-#define PragTyp_BUSY_TIMEOUT 4
-#define PragTyp_CACHE_SIZE 5
-#define PragTyp_CACHE_SPILL 6
-#define PragTyp_CASE_SENSITIVE_LIKE 7
-#define PragTyp_COLLATION_LIST 8
-#define PragTyp_COMPILE_OPTIONS 9
-#define PragTyp_DATA_STORE_DIRECTORY 10
-#define PragTyp_DATABASE_LIST 11
-#define PragTyp_DEFAULT_CACHE_SIZE 12
-#define PragTyp_ENCODING 13
-#define PragTyp_FOREIGN_KEY_CHECK 14
-#define PragTyp_FOREIGN_KEY_LIST 15
-#define PragTyp_FUNCTION_LIST 16
-#define PragTyp_INCREMENTAL_VACUUM 17
-#define PragTyp_INDEX_INFO 18
-#define PragTyp_INDEX_LIST 19
-#define PragTyp_INTEGRITY_CHECK 20
-#define PragTyp_JOURNAL_MODE 21
-#define PragTyp_JOURNAL_SIZE_LIMIT 22
-#define PragTyp_LOCK_PROXY_FILE 23
-#define PragTyp_LOCKING_MODE 24
-#define PragTyp_PAGE_COUNT 25
-#define PragTyp_MMAP_SIZE 26
-#define PragTyp_MODULE_LIST 27
-#define PragTyp_OPTIMIZE 28
-#define PragTyp_PAGE_SIZE 29
-#define PragTyp_PRAGMA_LIST 30
-#define PragTyp_SECURE_DELETE 31
-#define PragTyp_SHRINK_MEMORY 32
-#define PragTyp_SOFT_HEAP_LIMIT 33
-#define PragTyp_SYNCHRONOUS 34
-#define PragTyp_TABLE_INFO 35
-#define PragTyp_TEMP_STORE 36
-#define PragTyp_TEMP_STORE_DIRECTORY 37
-#define PragTyp_THREADS 38
-#define PragTyp_WAL_AUTOCHECKPOINT 39
-#define PragTyp_WAL_CHECKPOINT 40
-#define PragTyp_ACTIVATE_EXTENSIONS 41
-#define PragTyp_HEXKEY 42
-#define PragTyp_KEY 43
-#define PragTyp_LOCK_STATUS 44
-#define PragTyp_PARSER_TRACE 45
-#define PragTyp_STATS 46
+#define PragTyp_FLAG 2
+#define PragTyp_BUSY_TIMEOUT 3
+#define PragTyp_CACHE_SIZE 4
+#define PragTyp_CACHE_SPILL 5
+#define PragTyp_CASE_SENSITIVE_LIKE 6
+#define PragTyp_COLLATION_LIST 7
+#define PragTyp_COMPILE_OPTIONS 8
+#define PragTyp_DATA_STORE_DIRECTORY 9
+#define PragTyp_DATABASE_LIST 10
+#define PragTyp_DEFAULT_CACHE_SIZE 11
+#define PragTyp_ENCODING 12
+#define PragTyp_FOREIGN_KEY_CHECK 13
+#define PragTyp_FOREIGN_KEY_LIST 14
+#define PragTyp_FUNCTION_LIST 15
+#define PragTyp_INCREMENTAL_VACUUM 16
+#define PragTyp_INDEX_INFO 17
+#define PragTyp_INDEX_LIST 18
+#define PragTyp_INTEGRITY_CHECK 19
+#define PragTyp_JOURNAL_MODE 20
+#define PragTyp_JOURNAL_SIZE_LIMIT 21
+#define PragTyp_LOCK_PROXY_FILE 22
+#define PragTyp_LOCKING_MODE 23
+#define PragTyp_PAGE_COUNT 24
+#define PragTyp_MMAP_SIZE 25
+#define PragTyp_MODULE_LIST 26
+#define PragTyp_OPTIMIZE 27
+#define PragTyp_PAGE_SIZE 28
+#define PragTyp_PRAGMA_LIST 29
+#define PragTyp_SECURE_DELETE 30
+#define PragTyp_SHRINK_MEMORY 31
+#define PragTyp_SOFT_HEAP_LIMIT 32
+#define PragTyp_SYNCHRONOUS 33
+#define PragTyp_TABLE_INFO 34
+#define PragTyp_TEMP_STORE 35
+#define PragTyp_TEMP_STORE_DIRECTORY 36
+#define PragTyp_THREADS 37
+#define PragTyp_WAL_AUTOCHECKPOINT 38
+#define PragTyp_WAL_CHECKPOINT 39
+#define PragTyp_ACTIVATE_EXTENSIONS 40
+#define PragTyp_HEXKEY 41
+#define PragTyp_KEY 42
+#define PragTyp_LOCK_STATUS 43
+#define PragTyp_PARSER_TRACE 44
+#define PragTyp_STATS 45
/* Property flags associated with various pragma. */
#define PragFlg_NeedSchema 0x01 /* Force schema load before running */
@@ -69,53 +68,53 @@
*/
static const char *const pragCName[] = {
/* 0 */ "id", /* Used by: foreign_key_list */
- /* 1 */ "seq",
- /* 2 */ "table",
- /* 3 */ "from",
- /* 4 */ "to",
- /* 5 */ "on_update",
- /* 6 */ "on_delete",
- /* 7 */ "match",
+ /* 1 */ "seq",
+ /* 2 */ "table",
+ /* 3 */ "from",
+ /* 4 */ "to",
+ /* 5 */ "on_update",
+ /* 6 */ "on_delete",
+ /* 7 */ "match",
/* 8 */ "cid", /* Used by: table_xinfo */
- /* 9 */ "name",
- /* 10 */ "type",
- /* 11 */ "notnull",
- /* 12 */ "dflt_value",
- /* 13 */ "pk",
- /* 14 */ "hidden",
+ /* 9 */ "name",
+ /* 10 */ "type",
+ /* 11 */ "notnull",
+ /* 12 */ "dflt_value",
+ /* 13 */ "pk",
+ /* 14 */ "hidden",
/* table_info reuses 8 */
/* 15 */ "seqno", /* Used by: index_xinfo */
- /* 16 */ "cid",
- /* 17 */ "name",
- /* 18 */ "desc",
- /* 19 */ "coll",
- /* 20 */ "key",
+ /* 16 */ "cid",
+ /* 17 */ "name",
+ /* 18 */ "desc",
+ /* 19 */ "coll",
+ /* 20 */ "key",
/* 21 */ "tbl", /* Used by: stats */
- /* 22 */ "idx",
- /* 23 */ "wdth",
- /* 24 */ "hght",
- /* 25 */ "flgs",
+ /* 22 */ "idx",
+ /* 23 */ "wdth",
+ /* 24 */ "hght",
+ /* 25 */ "flgs",
/* 26 */ "seq", /* Used by: index_list */
- /* 27 */ "name",
- /* 28 */ "unique",
- /* 29 */ "origin",
- /* 30 */ "partial",
+ /* 27 */ "name",
+ /* 28 */ "unique",
+ /* 29 */ "origin",
+ /* 30 */ "partial",
/* 31 */ "table", /* Used by: foreign_key_check */
- /* 32 */ "rowid",
- /* 33 */ "parent",
- /* 34 */ "fkid",
+ /* 32 */ "rowid",
+ /* 33 */ "parent",
+ /* 34 */ "fkid",
/* index_info reuses 15 */
/* 35 */ "seq", /* Used by: database_list */
- /* 36 */ "name",
- /* 37 */ "file",
+ /* 36 */ "name",
+ /* 37 */ "file",
/* 38 */ "busy", /* Used by: wal_checkpoint */
- /* 39 */ "log",
+ /* 39 */ "log",
/* 40 */ "checkpointed",
/* 41 */ "name", /* Used by: function_list */
- /* 42 */ "builtin",
+ /* 42 */ "builtin",
/* collation_list reuses 26 */
/* 43 */ "database", /* Used by: lock_status */
- /* 44 */ "status",
+ /* 44 */ "status",
/* 45 */ "cache_size", /* Used by: default_cache_size */
/* module_list pragma_list reuses 9 */
/* 46 */ "timeout", /* Used by: busy_timeout */
@@ -151,11 +150,6 @@ static const PragmaName aPragmaName[] = {
/* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq|PragFlg_NoColumns1,
/* ColNames: */ 0, 0,
/* iArg: */ 0 },
- {/* zName: */ "auto_vacuum_slack_pages",
- /* ePragTyp: */ PragTyp_AUTO_VACUUM_SLACK_PAGES,
- /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_SchemaReq|PragFlg_NoColumns1,
- /* ColNames: */ 0, 0,
- /* iArg: */ 0 },
#endif
#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
#if !defined(SQLITE_OMIT_AUTOMATIC_INDEX)
@@ -672,4 +666,4 @@ static const PragmaName aPragmaName[] = {
/* iArg: */ SQLITE_WriteSchema|SQLITE_NoSchemaError },
#endif
};
-/* Number of pragmas: 63 on by default, 82 total. */
+/* Number of pragmas: 62 on by default, 81 total. */
diff --git a/chromium/third_party/sqlite/src/src/prepare.c b/chromium/third_party/sqlite/src/src/prepare.c
index fe098cfa092..87711315a0c 100644
--- a/chromium/third_party/sqlite/src/src/prepare.c
+++ b/chromium/third_party/sqlite/src/src/prepare.c
@@ -118,15 +118,11 @@ int sqlite3InitCallback(void *pInit, int argc, char **argv, char **NotUsed){
*/
Index *pIndex;
pIndex = sqlite3FindIndex(db, argv[0], db->aDb[iDb].zDbSName);
- if( pIndex==0 ){
- /* This can occur if there exists an index on a TEMP table which
- ** has the same name as another index on a permanent index. Since
- ** the permanent table is hidden by the TEMP table, we can also
- ** safely ignore the index on the permanent table.
- */
- /* Do Nothing */;
- }else if( sqlite3GetInt32(argv[1], &pIndex->tnum)==0 ){
- corruptSchema(pData, argv[0], "invalid rootpage");
+ if( pIndex==0
+ || sqlite3GetInt32(argv[1],&pIndex->tnum)==0
+ || pIndex->tnum<2
+ ){
+ corruptSchema(pData, argv[0], pIndex?"invalid rootpage":"orphan index");
}
}
return 0;
@@ -545,6 +541,7 @@ static int sqlite3Prepare(
sParse.disableLookaside++;
db->lookaside.bDisable++;
}
+ sParse.disableVtab = (prepFlags & SQLITE_PREPARE_NO_VTAB)!=0;
/* Check to verify that it is possible to get a read lock on all
** database schemas. The inability to get a read lock indicates that
diff --git a/chromium/third_party/sqlite/src/src/select.c b/chromium/third_party/sqlite/src/src/select.c
index fab4df68fa1..c68c1ddc643 100644
--- a/chromium/third_party/sqlite/src/src/select.c
+++ b/chromium/third_party/sqlite/src/src/select.c
@@ -1457,7 +1457,12 @@ static void generateSortTail(
regRow = pDest->iSdst;
}else{
regRowid = sqlite3GetTempReg(pParse);
- regRow = sqlite3GetTempRange(pParse, nColumn);
+ if( eDest==SRT_EphemTab || eDest==SRT_Table ){
+ regRow = sqlite3GetTempReg(pParse);
+ nColumn = 0;
+ }else{
+ regRow = sqlite3GetTempRange(pParse, nColumn);
+ }
}
nKey = pOrderBy->nExpr - pSort->nOBSat;
if( pSort->sortFlags & SORTFLAG_UseSorter ){
@@ -1537,6 +1542,7 @@ static void generateSortTail(
switch( eDest ){
case SRT_Table:
case SRT_EphemTab: {
+ sqlite3VdbeAddOp3(v, OP_Column, iSortTab, nKey+bSeq, regRow);
sqlite3VdbeAddOp2(v, OP_NewRowid, iParm, regRowid);
sqlite3VdbeAddOp3(v, OP_Insert, iParm, regRow, regRowid);
sqlite3VdbeChangeP5(v, OPFLAG_APPEND);
diff --git a/chromium/third_party/sqlite/src/src/sqlite.h.in b/chromium/third_party/sqlite/src/src/sqlite.h.in
index 11622a49697..cf623163eaa 100644
--- a/chromium/third_party/sqlite/src/src/sqlite.h.in
+++ b/chromium/third_party/sqlite/src/src/sqlite.h.in
@@ -3637,10 +3637,16 @@ int sqlite3_limit(sqlite3*, int id, int newVal);
** normalize a SQL statement are unspecified and subject to change.
** At a minimum, literal values will be replaced with suitable
** placeholders.
+**
+** [[SQLITE_PREPARE_NO_VTAB]] <dt>SQLITE_PREPARE_NO_VTAB</dt>
+** <dd>The SQLITE_PREPARE_NO_VTAB flag causes the SQL compiler
+** to return an error (error code SQLITE_ERROR) if the statement uses
+** any virtual tables.
** </dl>
*/
#define SQLITE_PREPARE_PERSISTENT 0x01
#define SQLITE_PREPARE_NORMALIZE 0x02
+#define SQLITE_PREPARE_NO_VTAB 0x04
/*
** CAPI3REF: Compiling An SQL Statement
diff --git a/chromium/third_party/sqlite/src/src/sqliteInt.h b/chromium/third_party/sqlite/src/src/sqliteInt.h
index 44d1406110e..1aae87ea13b 100644
--- a/chromium/third_party/sqlite/src/src/sqliteInt.h
+++ b/chromium/third_party/sqlite/src/src/sqliteInt.h
@@ -3057,6 +3057,7 @@ struct Parse {
u8 hasCompound; /* Need to invoke convertCompoundSelectToSubquery() */
u8 okConstFactor; /* OK to factor out constants */
u8 disableLookaside; /* Number of times lookaside has been disabled */
+ u8 disableVtab; /* Disable all virtual tables for this parse */
int nRangeReg; /* Size of the temporary register block */
int iRangeReg; /* First register in temporary register block */
int nErr; /* Number of errors seen */
diff --git a/chromium/third_party/sqlite/src/src/trigger.c b/chromium/third_party/sqlite/src/src/trigger.c
index cf31851f038..69fddedd914 100644
--- a/chromium/third_party/sqlite/src/src/trigger.c
+++ b/chromium/third_party/sqlite/src/src/trigger.c
@@ -916,6 +916,7 @@ static TriggerPrg *codeRowTrigger(
pSubParse->zAuthContext = pTrigger->zName;
pSubParse->eTriggerOp = pTrigger->op;
pSubParse->nQueryLoop = pParse->nQueryLoop;
+ pSubParse->disableVtab = pParse->disableVtab;
v = sqlite3GetVdbe(pSubParse);
if( v ){
diff --git a/chromium/third_party/sqlite/src/src/vdbeaux.c b/chromium/third_party/sqlite/src/src/vdbeaux.c
index 15a095ff6e7..13b2e1ef728 100644
--- a/chromium/third_party/sqlite/src/src/vdbeaux.c
+++ b/chromium/third_party/sqlite/src/src/vdbeaux.c
@@ -3734,6 +3734,13 @@ void sqlite3VdbeRecordUnpack(
pMem++;
if( (++u)>=p->nField ) break;
}
+ if( d>nKey && u ){
+ assert( CORRUPT_DB );
+ /* In a corrupt record entry, the last pMem might have been set up using
+ ** uninitialized memory. Overwrite its value with NULL, to prevent
+ ** warnings from MSAN. */
+ sqlite3VdbeMemSetNull(pMem-1);
+ }
assert( u<=pKeyInfo->nKeyField + 1 );
p->nField = u;
}
@@ -3799,8 +3806,8 @@ static int vdbeRecordCompareDebug(
** Use that approximation to avoid the more expensive call to
** sqlite3VdbeSerialTypeLen() in the common case.
*/
- if( d1+serial_type1+2>(u32)nKey1
- && d1+sqlite3VdbeSerialTypeLen(serial_type1)>(u32)nKey1
+ if( d1+(u64)serial_type1+2>(u64)nKey1
+ && d1+(u64)sqlite3VdbeSerialTypeLen(serial_type1)>(u64)nKey1
){
break;
}
@@ -3811,7 +3818,8 @@ static int vdbeRecordCompareDebug(
/* Do the comparison
*/
- rc = sqlite3MemCompare(&mem1, &pPKey2->aMem[i], pKeyInfo->aColl[i]);
+ rc = sqlite3MemCompare(&mem1, &pPKey2->aMem[i],
+ pKeyInfo->nAllField>i ? pKeyInfo->aColl[i] : 0);
if( rc!=0 ){
assert( mem1.szMalloc==0 ); /* See comment below */
if( pKeyInfo->aSortOrder[i] ){
@@ -4242,10 +4250,12 @@ int sqlite3VdbeRecordCompareWithSkip(
mem1.n = (serial_type - 12) / 2;
testcase( (d1+mem1.n)==(unsigned)nKey1 );
testcase( (d1+mem1.n+1)==(unsigned)nKey1 );
- if( (d1+mem1.n) > (unsigned)nKey1 ){
+ if( (d1+mem1.n) > (unsigned)nKey1
+ || (pKeyInfo = pPKey2->pKeyInfo)->nAllField<=i
+ ){
pPKey2->errCode = (u8)SQLITE_CORRUPT_BKPT;
return 0; /* Corruption */
- }else if( (pKeyInfo = pPKey2->pKeyInfo)->aColl[i] ){
+ }else if( pKeyInfo->aColl[i] ){
mem1.enc = pKeyInfo->enc;
mem1.db = pKeyInfo->db;
mem1.flags = MEM_Str;
diff --git a/chromium/third_party/sqlite/src/tool/mkpragmatab.tcl b/chromium/third_party/sqlite/src/tool/mkpragmatab.tcl
index c67e3102e7e..f6cf7790317 100644
--- a/chromium/third_party/sqlite/src/tool/mkpragmatab.tcl
+++ b/chromium/third_party/sqlite/src/tool/mkpragmatab.tcl
@@ -412,10 +412,6 @@ set pragma_def {
TYPE: FLAG
ARG: SQLITE_LegacyAlter
IF: !defined(SQLITE_OMIT_FLAG_PRAGMAS)
-
- NAME: auto_vacuum_slack_pages
- FLAG: NeedSchema Result0 SchemaReq NoColumns1
- IF: !defined(SQLITE_OMIT_AUTOVACUUM)
}
# Open the output file