summaryrefslogtreecommitdiffstats
path: root/chromium/third_party/sqlite
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/sqlite')
-rw-r--r--chromium/third_party/sqlite/amalgamation/rename_exports.h642
-rw-r--r--chromium/third_party/sqlite/amalgamation/shell/shell.c637
-rw-r--r--chromium/third_party/sqlite/amalgamation/sqlite3.c8014
-rw-r--r--chromium/third_party/sqlite/amalgamation/sqlite3.h73
-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_queries0bin20189 -> 0 bytes
-rw-r--r--chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries1bin5569 -> 0 bytes
-rw-r--r--chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries10bin14720 -> 0 bytes
-rw-r--r--chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries11bin32275 -> 0 bytes
-rw-r--r--chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries12bin36953 -> 0 bytes
-rw-r--r--chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries13bin32246 -> 0 bytes
-rw-r--r--chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries14bin5439 -> 0 bytes
-rw-r--r--chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries15bin34799 -> 0 bytes
-rw-r--r--chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries16bin5647 -> 0 bytes
-rw-r--r--chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries17bin26498 -> 0 bytes
-rw-r--r--chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries18bin18939 -> 0 bytes
-rw-r--r--chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries19bin17233 -> 0 bytes
-rw-r--r--chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries2bin20274 -> 0 bytes
-rw-r--r--chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries3bin18276 -> 0 bytes
-rw-r--r--chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries4bin12855 -> 0 bytes
-rw-r--r--chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries5bin7890 -> 0 bytes
-rw-r--r--chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries6bin28166 -> 0 bytes
-rw-r--r--chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries7bin13183 -> 0 bytes
-rw-r--r--chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries8bin6235 -> 0 bytes
-rw-r--r--chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries9bin3768 -> 0 bytes
-rw-r--r--chromium/third_party/sqlite/fuzz/sql.dict909
-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.patch8
-rw-r--r--chromium/third_party/sqlite/patches/0002-Virtual-table-supporting-recovery-of-corrupted-datab.patch13
-rw-r--r--chromium/third_party/sqlite/patches/0003-Custom-shell.c-helpers-to-load-Chromium-s-ICU-data.patch10
-rw-r--r--chromium/third_party/sqlite/patches/0004-fts3-Disable-fts3_tokenizer-and-fts4.patch12
-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-compilation-with-SQLITE_OMIT_WINDOWFUNC.patch32
-rw-r--r--chromium/third_party/sqlite/patches/0006-Fix-dbfuzz2-for-Clusterfuzz.patch25
-rw-r--r--chromium/third_party/sqlite/patches/0007-Fix-dbfuzz2.c-compilation-errors-on-Windows.patch43
-rw-r--r--chromium/third_party/sqlite/patches/0007-Fix-the-Makefile-so-that-it-honors-CFLAGS-when-build.patch27
-rw-r--r--chromium/third_party/sqlite/patches/0008-Adjustments-to-the-page-cache-to-try-to-avoid-harmle.patch38
-rw-r--r--chromium/third_party/sqlite/patches/0009-Remove-an-ALWAYS-from-a-branch-that-is-not-always-ta.patch29
-rw-r--r--chromium/third_party/sqlite/patches/0010-Fix-a-problem-with-nested-CTEs-with-the-same-table.patch42
-rw-r--r--chromium/third_party/sqlite/patches/0011-Fix-detection-of-self-referencing-rows-in-foreign-ke.patch50
-rw-r--r--chromium/third_party/sqlite/patches/0012-Fix-a-segfault-caused-by-using-the-RAISE-function-in.patch29
-rw-r--r--chromium/third_party/sqlite/patches/0013-Fix-for-an-assert-that-could-be-false.patch33
-rw-r--r--chromium/third_party/sqlite/patches/0014-Fix-another-problem-found-by-Matthew-Denton-s-new-fu.patch40
-rw-r--r--chromium/third_party/sqlite/patches/0015-Report-a-new-corruption-case.patch47
-rw-r--r--chromium/third_party/sqlite/patches/0016-Avoid-a-buffer-overread-in-ptrmapPutOvflPtr.patch33
-rw-r--r--chromium/third_party/sqlite/patches/0017-Improved-detection-of-cell-corruption-in-sqlite3Vdbe.patch37
-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
-rw-r--r--chromium/third_party/sqlite/src/Makefile.in41
-rw-r--r--chromium/third_party/sqlite/src/Makefile.msc25
-rw-r--r--chromium/third_party/sqlite/src/VERSION2
-rw-r--r--chromium/third_party/sqlite/src/autoconf/Makefile.msc2
-rwxr-xr-xchromium/third_party/sqlite/src/configure18
-rw-r--r--chromium/third_party/sqlite/src/ext/expert/expert1.test6
-rw-r--r--chromium/third_party/sqlite/src/ext/fts3/fts3.c126
-rw-r--r--chromium/third_party/sqlite/src/ext/fts3/fts3Int.h14
-rw-r--r--chromium/third_party/sqlite/src/ext/fts3/fts3_aux.c10
-rw-r--r--chromium/third_party/sqlite/src/ext/fts3/fts3_expr.c15
-rw-r--r--chromium/third_party/sqlite/src/ext/fts3/fts3_hash.c4
-rw-r--r--chromium/third_party/sqlite/src/ext/fts3/fts3_icu.c4
-rw-r--r--chromium/third_party/sqlite/src/ext/fts3/fts3_snippet.c64
-rw-r--r--chromium/third_party/sqlite/src/ext/fts3/fts3_term.c6
-rw-r--r--chromium/third_party/sqlite/src/ext/fts3/fts3_test.c31
-rw-r--r--chromium/third_party/sqlite/src/ext/fts3/fts3_tokenize_vtab.c2
-rw-r--r--chromium/third_party/sqlite/src/ext/fts3/fts3_unicode.c17
-rw-r--r--chromium/third_party/sqlite/src/ext/fts3/fts3_unicode2.c71
-rw-r--r--chromium/third_party/sqlite/src/ext/fts3/fts3_write.c42
-rw-r--r--chromium/third_party/sqlite/src/ext/fts3/unicode/mkunicode.tcl53
-rw-r--r--chromium/third_party/sqlite/src/ext/fts3/unicode/parseunicode.tcl31
-rw-r--r--chromium/third_party/sqlite/src/ext/fts5/fts5.h20
-rw-r--r--chromium/third_party/sqlite/src/ext/fts5/fts5Int.h28
-rw-r--r--chromium/third_party/sqlite/src/ext/fts5/fts5_aux.c20
-rw-r--r--chromium/third_party/sqlite/src/ext/fts5/fts5_buffer.c12
-rw-r--r--chromium/third_party/sqlite/src/ext/fts5/fts5_config.c8
-rw-r--r--chromium/third_party/sqlite/src/ext/fts5/fts5_expr.c55
-rw-r--r--chromium/third_party/sqlite/src/ext/fts5/fts5_hash.c22
-rw-r--r--chromium/third_party/sqlite/src/ext/fts5/fts5_index.c237
-rw-r--r--chromium/third_party/sqlite/src/ext/fts5/fts5_main.c302
-rw-r--r--chromium/third_party/sqlite/src/ext/fts5/fts5_storage.c20
-rw-r--r--chromium/third_party/sqlite/src/ext/fts5/fts5_test_mi.c4
-rw-r--r--chromium/third_party/sqlite/src/ext/fts5/fts5_test_tok.c6
-rw-r--r--chromium/third_party/sqlite/src/ext/fts5/fts5_tokenize.c37
-rw-r--r--chromium/third_party/sqlite/src/ext/fts5/fts5_unicode2.c82
-rw-r--r--chromium/third_party/sqlite/src/ext/fts5/fts5_varint.c3
-rw-r--r--chromium/third_party/sqlite/src/ext/fts5/fts5_vocab.c69
-rw-r--r--chromium/third_party/sqlite/src/ext/misc/amatch.c10
-rw-r--r--chromium/third_party/sqlite/src/ext/misc/closure.c6
-rw-r--r--chromium/third_party/sqlite/src/ext/misc/csv.c2
-rw-r--r--chromium/third_party/sqlite/src/ext/misc/dbdump.c2
-rw-r--r--chromium/third_party/sqlite/src/ext/misc/eval.c2
-rw-r--r--chromium/third_party/sqlite/src/ext/misc/fileio.c45
-rw-r--r--chromium/third_party/sqlite/src/ext/misc/fuzzer.c16
-rw-r--r--chromium/third_party/sqlite/src/ext/misc/json1.c6
-rw-r--r--chromium/third_party/sqlite/src/ext/misc/memstat.c2
-rw-r--r--chromium/third_party/sqlite/src/ext/misc/memtrace.c108
-rw-r--r--chromium/third_party/sqlite/src/ext/misc/mmapwarm.c1
-rw-r--r--chromium/third_party/sqlite/src/ext/misc/nextchar.c4
-rw-r--r--chromium/third_party/sqlite/src/ext/misc/percentile.c2
-rw-r--r--chromium/third_party/sqlite/src/ext/misc/prefixes.c319
-rw-r--r--chromium/third_party/sqlite/src/ext/misc/regexp.c6
-rw-r--r--chromium/third_party/sqlite/src/ext/misc/unionvtab.c8
-rw-r--r--chromium/third_party/sqlite/src/ext/misc/vfslog.c2
-rw-r--r--chromium/third_party/sqlite/src/ext/misc/zipfile.c24
-rw-r--r--chromium/third_party/sqlite/src/ext/rbu/rbu_common.tcl13
-rw-r--r--chromium/third_party/sqlite/src/ext/rbu/rbuvacuum2.test27
-rw-r--r--chromium/third_party/sqlite/src/ext/rbu/rbuvacuum3.test63
-rw-r--r--chromium/third_party/sqlite/src/ext/rbu/sqlite3rbu.c13
-rw-r--r--chromium/third_party/sqlite/src/ext/rbu/sqlite3rbu.h4
-rw-r--r--chromium/third_party/sqlite/src/ext/rbu/test_rbu.c1
-rw-r--r--chromium/third_party/sqlite/src/ext/rtree/geopoly.c95
-rw-r--r--chromium/third_party/sqlite/src/ext/rtree/rtree.c128
-rw-r--r--chromium/third_party/sqlite/src/ext/rtree/rtree1.test14
-rw-r--r--chromium/third_party/sqlite/src/ext/rtree/rtree6.test13
-rw-r--r--chromium/third_party/sqlite/src/ext/rtree/rtreecirc.test66
-rw-r--r--chromium/third_party/sqlite/src/ext/rtree/rtreefuzz001.test777
-rw-r--r--chromium/third_party/sqlite/src/ext/session/changeset.c6
-rw-r--r--chromium/third_party/sqlite/src/ext/session/changesetfuzz.c15
-rw-r--r--chromium/third_party/sqlite/src/ext/session/session_speed_test.c2
-rw-r--r--chromium/third_party/sqlite/src/ext/session/sessionwor.test74
-rw-r--r--chromium/third_party/sqlite/src/ext/session/sqlite3session.c36
-rw-r--r--chromium/third_party/sqlite/src/ext/session/sqlite3session.h2
-rw-r--r--chromium/third_party/sqlite/src/main.mk31
-rw-r--r--chromium/third_party/sqlite/src/manifest423
-rw-r--r--chromium/third_party/sqlite/src/manifest.uuid2
-rw-r--r--chromium/third_party/sqlite/src/src/alter.c56
-rw-r--r--chromium/third_party/sqlite/src/src/analyze.c2
-rw-r--r--chromium/third_party/sqlite/src/src/attach.c15
-rw-r--r--chromium/third_party/sqlite/src/src/btree.c304
-rw-r--r--chromium/third_party/sqlite/src/src/btree.h1
-rw-r--r--chromium/third_party/sqlite/src/src/btreeInt.h13
-rw-r--r--chromium/third_party/sqlite/src/src/build.c86
-rw-r--r--chromium/third_party/sqlite/src/src/callback.c21
-rw-r--r--chromium/third_party/sqlite/src/src/dbstat.c10
-rw-r--r--chromium/third_party/sqlite/src/src/delete.c8
-rw-r--r--chromium/third_party/sqlite/src/src/expr.c648
-rw-r--r--chromium/third_party/sqlite/src/src/fkey.c9
-rw-r--r--chromium/third_party/sqlite/src/src/func.c10
-rw-r--r--chromium/third_party/sqlite/src/src/global.c12
-rw-r--r--chromium/third_party/sqlite/src/src/hash.c56
-rw-r--r--chromium/third_party/sqlite/src/src/insert.c46
-rw-r--r--chromium/third_party/sqlite/src/src/legacy.c5
-rw-r--r--chromium/third_party/sqlite/src/src/loadext.c2
-rw-r--r--chromium/third_party/sqlite/src/src/main.c68
-rw-r--r--chromium/third_party/sqlite/src/src/memdb.c46
-rw-r--r--chromium/third_party/sqlite/src/src/pager.c5
-rw-r--r--chromium/third_party/sqlite/src/src/parse.y43
-rw-r--r--chromium/third_party/sqlite/src/src/pcache1.c24
-rw-r--r--chromium/third_party/sqlite/src/src/pragma.c25
-rw-r--r--chromium/third_party/sqlite/src/src/pragma.h13
-rw-r--r--chromium/third_party/sqlite/src/src/prepare.c305
-rw-r--r--chromium/third_party/sqlite/src/src/printf.c199
-rw-r--r--chromium/third_party/sqlite/src/src/resolve.c127
-rw-r--r--chromium/third_party/sqlite/src/src/select.c88
-rw-r--r--chromium/third_party/sqlite/src/src/shell.c.in458
-rw-r--r--chromium/third_party/sqlite/src/src/sqlite.h.in45
-rw-r--r--chromium/third_party/sqlite/src/src/sqliteInt.h68
-rw-r--r--chromium/third_party/sqlite/src/src/tclsqlite.c53
-rw-r--r--chromium/third_party/sqlite/src/src/test1.c80
-rw-r--r--chromium/third_party/sqlite/src/src/test_journal.c2
-rw-r--r--chromium/third_party/sqlite/src/src/test_vfs.c125
-rw-r--r--chromium/third_party/sqlite/src/src/tokenize.c211
-rw-r--r--chromium/third_party/sqlite/src/src/treeview.c3
-rw-r--r--chromium/third_party/sqlite/src/src/trigger.c4
-rw-r--r--chromium/third_party/sqlite/src/src/update.c11
-rw-r--r--chromium/third_party/sqlite/src/src/util.c7
-rw-r--r--chromium/third_party/sqlite/src/src/vacuum.c72
-rw-r--r--chromium/third_party/sqlite/src/src/vdbe.c124
-rw-r--r--chromium/third_party/sqlite/src/src/vdbe.h21
-rw-r--r--chromium/third_party/sqlite/src/src/vdbeInt.h30
-rw-r--r--chromium/third_party/sqlite/src/src/vdbeapi.c38
-rw-r--r--chromium/third_party/sqlite/src/src/vdbeaux.c188
-rw-r--r--chromium/third_party/sqlite/src/src/vdbemem.c13
-rw-r--r--chromium/third_party/sqlite/src/src/vtab.c2
-rw-r--r--chromium/third_party/sqlite/src/src/walker.c31
-rw-r--r--chromium/third_party/sqlite/src/src/where.c65
-rw-r--r--chromium/third_party/sqlite/src/src/whereInt.h3
-rw-r--r--chromium/third_party/sqlite/src/src/wherecode.c48
-rw-r--r--chromium/third_party/sqlite/src/src/whereexpr.c6
-rw-r--r--chromium/third_party/sqlite/src/src/window.c20
-rw-r--r--chromium/third_party/sqlite/src/tool/dbtotxt.c146
-rw-r--r--chromium/third_party/sqlite/src/tool/dbtotxt.md56
-rw-r--r--chromium/third_party/sqlite/src/tool/index_usage.c233
-rw-r--r--chromium/third_party/sqlite/src/tool/lemon.c12
-rw-r--r--chromium/third_party/sqlite/src/tool/lempar.c26
-rw-r--r--chromium/third_party/sqlite/src/tool/mkpragmatab.tcl5
220 files changed, 11554 insertions, 14855 deletions
diff --git a/chromium/third_party/sqlite/amalgamation/rename_exports.h b/chromium/third_party/sqlite/amalgamation/rename_exports.h
index 22e7fb57494..904ac258ca6 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 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_activate_cerod chrome_sqlite3_activate_cerod // Lines 5595-5597
+#define sqlite3_activate_see chrome_sqlite3_activate_see // Lines 5585-5587
+#define sqlite3_aggregate_context chrome_sqlite3_aggregate_context // Line 5132
+#define sqlite3_aggregate_count chrome_sqlite3_aggregate_count // Line 4915
+#define sqlite3_auto_extension chrome_sqlite3_auto_extension // Line 6261
+#define sqlite3_backup_finish chrome_sqlite3_backup_finish // Line 8256
+#define sqlite3_backup_init chrome_sqlite3_backup_init // Lines 8249-8254
+#define sqlite3_backup_pagecount chrome_sqlite3_backup_pagecount // Line 8258
+#define sqlite3_backup_remaining chrome_sqlite3_backup_remaining // Line 8257
+#define sqlite3_backup_step chrome_sqlite3_backup_step // Line 8255
+#define sqlite3_bind_blob chrome_sqlite3_bind_blob // Line 4090
+#define sqlite3_bind_blob64 chrome_sqlite3_bind_blob64 // Lines 4091-4092
+#define sqlite3_bind_double chrome_sqlite3_bind_double // Line 4093
+#define sqlite3_bind_int chrome_sqlite3_bind_int // Line 4094
+#define sqlite3_bind_int64 chrome_sqlite3_bind_int64 // Line 4095
+#define sqlite3_bind_null chrome_sqlite3_bind_null // Line 4096
#define sqlite3_bind_parameter_count \
- chrome_sqlite3_bind_parameter_count // Line 4102
+ chrome_sqlite3_bind_parameter_count // Line 4125
#define sqlite3_bind_parameter_index \
- chrome_sqlite3_bind_parameter_index // Line 4148
+ chrome_sqlite3_bind_parameter_index // Line 4171
#define sqlite3_bind_parameter_name \
- 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
+ chrome_sqlite3_bind_parameter_name // Line 4153
+#define sqlite3_bind_pointer chrome_sqlite3_bind_pointer // Line 4102
+#define sqlite3_bind_text chrome_sqlite3_bind_text // Line 4097
+#define sqlite3_bind_text16 chrome_sqlite3_bind_text16 // Line 4098
+#define sqlite3_bind_text64 chrome_sqlite3_bind_text64 // Lines 4099-4100
+#define sqlite3_bind_value chrome_sqlite3_bind_value // Line 4101
+#define sqlite3_bind_zeroblob chrome_sqlite3_bind_zeroblob // Line 4103
+#define sqlite3_bind_zeroblob64 chrome_sqlite3_bind_zeroblob64 // Line 4104
+#define sqlite3_blob_bytes chrome_sqlite3_blob_bytes // Line 6810
+#define sqlite3_blob_close chrome_sqlite3_blob_close // Line 6794
+#define sqlite3_blob_open chrome_sqlite3_blob_open // Lines 6738-6746
+#define sqlite3_blob_read chrome_sqlite3_blob_read // Line 6839
+#define sqlite3_blob_reopen chrome_sqlite3_blob_reopen // Line 6771
+#define sqlite3_blob_write chrome_sqlite3_blob_write // Line 6881
+#define sqlite3_busy_handler chrome_sqlite3_busy_handler // Line 2526
+#define sqlite3_busy_timeout chrome_sqlite3_busy_timeout // Line 2549
#define sqlite3_cancel_auto_extension \
- chrome_sqlite3_cancel_auto_extension // Line 6250
-#define sqlite3_changes chrome_sqlite3_changes // Line 2333
-#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
+ chrome_sqlite3_cancel_auto_extension // Line 6273
+#define sqlite3_changes chrome_sqlite3_changes // Line 2355
+#define sqlite3_clear_bindings chrome_sqlite3_clear_bindings // Line 4181
+#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 5511-5515
+ chrome_sqlite3_collation_needed // Lines 5534-5538
#define sqlite3_collation_needed16 \
- 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
+ chrome_sqlite3_collation_needed16 // Lines 5539-5543
+#define sqlite3_column_blob chrome_sqlite3_column_blob // Line 4661
+#define sqlite3_column_bytes chrome_sqlite3_column_bytes // Line 4668
+#define sqlite3_column_bytes16 chrome_sqlite3_column_bytes16 // Line 4669
+#define sqlite3_column_count chrome_sqlite3_column_count // Line 4197
#define sqlite3_column_database_name \
- chrome_sqlite3_column_database_name // Line 4252
+ chrome_sqlite3_column_database_name // Line 4275
#define sqlite3_column_database_name16 \
- 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
+ chrome_sqlite3_column_database_name16 // Line 4276
+#define sqlite3_column_decltype chrome_sqlite3_column_decltype // Line 4312
+#define sqlite3_column_decltype16 chrome_sqlite3_column_decltype16 // Line 4313
+#define sqlite3_column_double chrome_sqlite3_column_double // Line 4662
+#define sqlite3_column_int chrome_sqlite3_column_int // Line 4663
+#define sqlite3_column_int64 chrome_sqlite3_column_int64 // Line 4664
+#define sqlite3_column_name chrome_sqlite3_column_name // Line 4226
+#define sqlite3_column_name16 chrome_sqlite3_column_name16 // Line 4227
#define sqlite3_column_origin_name \
- chrome_sqlite3_column_origin_name // Line 4256
+ chrome_sqlite3_column_origin_name // Line 4279
#define sqlite3_column_origin_name16 \
- chrome_sqlite3_column_origin_name16 // Line 4257
-#define sqlite3_column_table_name chrome_sqlite3_column_table_name // Line 4254
+ chrome_sqlite3_column_origin_name16 // Line 4280
+#define sqlite3_column_table_name chrome_sqlite3_column_table_name // Line 4277
#define sqlite3_column_table_name16 \
- 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
+ chrome_sqlite3_column_table_name16 // Line 4278
+#define sqlite3_column_text chrome_sqlite3_column_text // Line 4665
+#define sqlite3_column_text16 chrome_sqlite3_column_text16 // Line 4666
+#define sqlite3_column_type chrome_sqlite3_column_type // Line 4670
+#define sqlite3_column_value chrome_sqlite3_column_value // Line 4667
+#define sqlite3_commit_hook chrome_sqlite3_commit_hook // Line 5876
#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 5136
+#define sqlite3_compileoption_used chrome_sqlite3_compileoption_used // Line 190
+#define sqlite3_complete chrome_sqlite3_complete // Line 2464
+#define sqlite3_complete16 chrome_sqlite3_complete16 // Line 2465
+#define sqlite3_config chrome_sqlite3_config // Line 1550
+#define sqlite3_context_db_handle chrome_sqlite3_context_db_handle // Line 5159
#define sqlite3_create_collation \
- chrome_sqlite3_create_collation // Lines 5461-5467
+ chrome_sqlite3_create_collation // Lines 5484-5490
#define sqlite3_create_collation16 \
- chrome_sqlite3_create_collation16 // Lines 5476-5482
+ chrome_sqlite3_create_collation16 // Lines 5499-5505
#define sqlite3_create_collation_v2 \
- chrome_sqlite3_create_collation_v2 // Lines 5468-5475
+ chrome_sqlite3_create_collation_v2 // Lines 5491-5498
#define sqlite3_create_function \
- chrome_sqlite3_create_function // Lines 4814-4823
+ chrome_sqlite3_create_function // Lines 4837-4846
#define sqlite3_create_function16 \
- chrome_sqlite3_create_function16 // Lines 4824-4833
+ chrome_sqlite3_create_function16 // Lines 4847-4856
#define sqlite3_create_function_v2 \
- chrome_sqlite3_create_function_v2 // Lines 4834-4844
-#define sqlite3_create_module chrome_sqlite3_create_module // Lines 6518-6523
+ chrome_sqlite3_create_function_v2 // Lines 4857-4867
+#define sqlite3_create_module chrome_sqlite3_create_module // Lines 6541-6546
#define sqlite3_create_module_v2 \
- chrome_sqlite3_create_module_v2 // Lines 6524-6530
+ chrome_sqlite3_create_module_v2 // Lines 6547-6553
#define sqlite3_create_window_function \
- 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 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
+ chrome_sqlite3_create_window_function // Lines 4868-4879
+#define sqlite3_data_count chrome_sqlite3_data_count // Line 4418
+#define sqlite3_data_directory chrome_sqlite3_data_directory // Line 5712
+#define sqlite3_db_cacheflush chrome_sqlite3_db_cacheflush // Line 8941
+#define sqlite3_db_config chrome_sqlite3_db_config // Line 1569
+#define sqlite3_db_filename chrome_sqlite3_db_filename // Line 5801
+#define sqlite3_db_handle chrome_sqlite3_db_handle // Line 5784
+#define sqlite3_db_mutex chrome_sqlite3_db_mutex // Line 7185
+#define sqlite3_db_readonly chrome_sqlite3_db_readonly // Line 5811
+#define sqlite3_db_release_memory chrome_sqlite3_db_release_memory // Line 5999
+#define sqlite3_db_status chrome_sqlite3_db_status // Line 7606
+#define sqlite3_declare_vtab chrome_sqlite3_declare_vtab // Line 6610
+#define sqlite3_deserialize chrome_sqlite3_deserialize // Lines 9335-9342
#define sqlite3_enable_load_extension \
- chrome_sqlite3_enable_load_extension // Line 6200
+ chrome_sqlite3_enable_load_extension // Line 6223
#define sqlite3_enable_shared_cache \
- 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 3835
-#define sqlite3_expired chrome_sqlite3_expired // Line 4893
-#define sqlite3_extended_errcode chrome_sqlite3_extended_errcode // Line 3469
+ chrome_sqlite3_enable_shared_cache // Line 5969
+#define sqlite3_errcode chrome_sqlite3_errcode // Line 3492
+#define sqlite3_errmsg chrome_sqlite3_errmsg // Line 3494
+#define sqlite3_errmsg16 chrome_sqlite3_errmsg16 // Line 3495
+#define sqlite3_errstr chrome_sqlite3_errstr // Line 3496
+#define sqlite3_exec chrome_sqlite3_exec // Lines 403-409
+#define sqlite3_expanded_sql chrome_sqlite3_expanded_sql // Line 3858
+#define sqlite3_expired chrome_sqlite3_expired // Line 4916
+#define sqlite3_extended_errcode chrome_sqlite3_extended_errcode // Line 3493
#define sqlite3_extended_result_codes \
- chrome_sqlite3_extended_result_codes // Line 2203
-#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 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 4895
-#define sqlite3_initialize chrome_sqlite3_initialize // Line 1504
-#define sqlite3_interrupt chrome_sqlite3_interrupt // Line 2407
-#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
+ chrome_sqlite3_extended_result_codes // Line 2225
+#define sqlite3_file_control chrome_sqlite3_file_control // Line 7228
+#define sqlite3_finalize chrome_sqlite3_finalize // Line 4698
+#define sqlite3_free chrome_sqlite3_free // Line 2771
+#define sqlite3_free_table chrome_sqlite3_free_table // Line 2632
+#define sqlite3_get_autocommit chrome_sqlite3_get_autocommit // Line 5771
+#define sqlite3_get_auxdata chrome_sqlite3_get_auxdata // Line 5218
+#define sqlite3_get_table chrome_sqlite3_get_table // Lines 2624-2631
+#define sqlite3_global_recover chrome_sqlite3_global_recover // Line 4918
+#define sqlite3_initialize chrome_sqlite3_initialize // Line 1514
+#define sqlite3_interrupt chrome_sqlite3_interrupt // Line 2429
+#define sqlite3_key chrome_sqlite3_key // Lines 5553-5556
+#define sqlite3_key_v2 chrome_sqlite3_key_v2 // Lines 5557-5561
+#define sqlite3_keyword_check chrome_sqlite3_keyword_check // Line 7336
+#define sqlite3_keyword_count chrome_sqlite3_keyword_count // Line 7334
+#define sqlite3_keyword_name chrome_sqlite3_keyword_name // Line 7335
+#define sqlite3_last_insert_rowid chrome_sqlite3_last_insert_rowid // Line 2287
+#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 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 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 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 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 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_limit chrome_sqlite3_limit // Line 3564
+#define sqlite3_load_extension chrome_sqlite3_load_extension // Lines 6191-6196
+#define sqlite3_log chrome_sqlite3_log // Line 8477
+#define sqlite3_malloc chrome_sqlite3_malloc // Line 2767
+#define sqlite3_malloc64 chrome_sqlite3_malloc64 // Line 2768
+#define sqlite3_memory_alarm chrome_sqlite3_memory_alarm // Lines 4920-4921
+#define sqlite3_memory_highwater chrome_sqlite3_memory_highwater // Line 2798
+#define sqlite3_memory_used chrome_sqlite3_memory_used // Line 2797
+#define sqlite3_mprintf chrome_sqlite3_mprintf // Line 2674
+#define sqlite3_msize chrome_sqlite3_msize // Line 2772
+#define sqlite3_mutex_alloc chrome_sqlite3_mutex_alloc // Line 7030
+#define sqlite3_mutex_enter chrome_sqlite3_mutex_enter // Line 7032
+#define sqlite3_mutex_free chrome_sqlite3_mutex_free // Line 7031
+#define sqlite3_mutex_held chrome_sqlite3_mutex_held // Line 7144
+#define sqlite3_mutex_leave chrome_sqlite3_mutex_leave // Line 7034
+#define sqlite3_mutex_notheld chrome_sqlite3_mutex_notheld // Line 7145
+#define sqlite3_mutex_try chrome_sqlite3_mutex_try // Line 7033
+#define sqlite3_next_stmt chrome_sqlite3_next_stmt // Line 5827
+#define sqlite3_normalized_sql chrome_sqlite3_normalized_sql // Line 3859
+#define sqlite3_open chrome_sqlite3_open // Lines 3379-3382
+#define sqlite3_open16 chrome_sqlite3_open16 // Lines 3383-3386
+#define sqlite3_open_v2 chrome_sqlite3_open_v2 // Lines 3387-3392
+#define sqlite3_os_end chrome_sqlite3_os_end // Line 1517
+#define sqlite3_os_init chrome_sqlite3_os_init // Line 1516
+#define sqlite3_overload_function chrome_sqlite3_overload_function // Line 6629
+#define sqlite3_prepare chrome_sqlite3_prepare // Lines 3774-3780
+#define sqlite3_prepare16 chrome_sqlite3_prepare16 // Lines 3796-3802
+#define sqlite3_prepare16_v2 chrome_sqlite3_prepare16_v2 // Lines 3803-3809
+#define sqlite3_prepare16_v3 chrome_sqlite3_prepare16_v3 // Lines 3810-3817
+#define sqlite3_prepare_v2 chrome_sqlite3_prepare_v2 // Lines 3781-3787
+#define sqlite3_prepare_v3 chrome_sqlite3_prepare_v3 // Lines 3788-3795
+#define sqlite3_preupdate_count chrome_sqlite3_preupdate_count // Line 9040
+#define sqlite3_preupdate_depth chrome_sqlite3_preupdate_depth // Line 9041
+#define sqlite3_preupdate_hook chrome_sqlite3_preupdate_hook // Lines 9026-9038
+#define sqlite3_preupdate_new chrome_sqlite3_preupdate_new // Line 9042
+#define sqlite3_preupdate_old chrome_sqlite3_preupdate_old // Line 9039
+#define sqlite3_profile chrome_sqlite3_profile // Lines 3022-3023
+#define sqlite3_progress_handler chrome_sqlite3_progress_handler // Line 3150
+#define sqlite3_randomness chrome_sqlite3_randomness // Line 2821
+#define sqlite3_realloc chrome_sqlite3_realloc // Line 2769
+#define sqlite3_realloc64 chrome_sqlite3_realloc64 // Line 2770
+#define sqlite3_rekey chrome_sqlite3_rekey // Lines 5571-5574
+#define sqlite3_rekey_v2 chrome_sqlite3_rekey_v2 // Lines 5575-5579
+#define sqlite3_release_memory chrome_sqlite3_release_memory // Line 5985
+#define sqlite3_reset chrome_sqlite3_reset // Line 4725
#define sqlite3_reset_auto_extension \
- 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
+ chrome_sqlite3_reset_auto_extension // Line 6281
+#define sqlite3_result_blob chrome_sqlite3_result_blob // Line 5366
+#define sqlite3_result_blob64 chrome_sqlite3_result_blob64 // Lines 5367-5368
+#define sqlite3_result_double chrome_sqlite3_result_double // Line 5369
+#define sqlite3_result_error chrome_sqlite3_result_error // Line 5370
+#define sqlite3_result_error16 chrome_sqlite3_result_error16 // Line 5371
+#define sqlite3_result_error_code chrome_sqlite3_result_error_code // Line 5374
#define sqlite3_result_error_nomem \
- chrome_sqlite3_result_error_nomem // Line 5350
+ chrome_sqlite3_result_error_nomem // Line 5373
#define sqlite3_result_error_toobig \
- 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
+ chrome_sqlite3_result_error_toobig // Line 5372
+#define sqlite3_result_int chrome_sqlite3_result_int // Line 5375
+#define sqlite3_result_int64 chrome_sqlite3_result_int64 // Line 5376
+#define sqlite3_result_null chrome_sqlite3_result_null // Line 5377
+#define sqlite3_result_pointer chrome_sqlite3_result_pointer // Line 5385
+#define sqlite3_result_subtype chrome_sqlite3_result_subtype // Line 5402
+#define sqlite3_result_text chrome_sqlite3_result_text // Line 5378
+#define sqlite3_result_text16 chrome_sqlite3_result_text16 // Line 5381
+#define sqlite3_result_text16be chrome_sqlite3_result_text16be // Line 5383
+#define sqlite3_result_text16le chrome_sqlite3_result_text16le // Line 5382
+#define sqlite3_result_text64 chrome_sqlite3_result_text64 // Lines 5379-5380
+#define sqlite3_result_value chrome_sqlite3_result_value // Line 5384
+#define sqlite3_result_zeroblob chrome_sqlite3_result_zeroblob // Line 5386
+#define sqlite3_result_zeroblob64 chrome_sqlite3_result_zeroblob64 // Line 5387
+#define sqlite3_rollback_hook chrome_sqlite3_rollback_hook // Line 5877
#define sqlite3_rtree_geometry_callback \
- chrome_sqlite3_rtree_geometry_callback // Lines 9399-9404
+ chrome_sqlite3_rtree_geometry_callback // Lines 9422-9427
#define sqlite3_rtree_query_callback \
- 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 5196
+ chrome_sqlite3_rtree_query_callback // Lines 9448-9454
+#define sqlite3_serialize chrome_sqlite3_serialize // Lines 9283-9288
+#define sqlite3_set_authorizer chrome_sqlite3_set_authorizer // Lines 2912-2916
+#define sqlite3_set_auxdata chrome_sqlite3_set_auxdata // Line 5219
#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 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 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 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
+ chrome_sqlite3_set_last_insert_rowid // Line 2297
+#define sqlite3_shutdown chrome_sqlite3_shutdown // Line 1515
+#define sqlite3_sleep chrome_sqlite3_sleep // Line 5617
+#define sqlite3_snapshot_cmp chrome_sqlite3_snapshot_cmp // Lines 9217-9220
+#define sqlite3_snapshot_free chrome_sqlite3_snapshot_free // Line 9190
+#define sqlite3_snapshot_get chrome_sqlite3_snapshot_get // Lines 9124-9128
+#define sqlite3_snapshot_open chrome_sqlite3_snapshot_open // Lines 9173-9177
+#define sqlite3_snapshot_recover chrome_sqlite3_snapshot_recover // Line 9245
+#define sqlite3_snprintf chrome_sqlite3_snprintf // Line 2676
+#define sqlite3_soft_heap_limit chrome_sqlite3_soft_heap_limit // Line 6063
+#define sqlite3_soft_heap_limit64 chrome_sqlite3_soft_heap_limit64 // Line 6052
+#define sqlite3_sourceid chrome_sqlite3_sourceid // Line 164
+#define sqlite3_sql chrome_sqlite3_sql // Line 3857
+#define sqlite3_status chrome_sqlite3_status // Line 7496
+#define sqlite3_status64 chrome_sqlite3_status64 // Lines 7497-7502
+#define sqlite3_step chrome_sqlite3_step // Line 4397
+#define sqlite3_stmt_busy chrome_sqlite3_stmt_busy // Line 3916
+#define sqlite3_stmt_readonly chrome_sqlite3_stmt_readonly // Line 3895
#define sqlite3_stmt_scanstatus \
- chrome_sqlite3_stmt_scanstatus // Lines 8870-8875
+ chrome_sqlite3_stmt_scanstatus // Lines 8893-8898
#define sqlite3_stmt_scanstatus_reset \
- 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
+ chrome_sqlite3_stmt_scanstatus_reset // Line 8909
+#define sqlite3_stmt_status chrome_sqlite3_stmt_status // Line 7759
+#define sqlite3_str_append chrome_sqlite3_str_append // Line 7432
+#define sqlite3_str_appendall chrome_sqlite3_str_appendall // Line 7433
+#define sqlite3_str_appendchar chrome_sqlite3_str_appendchar // Line 7434
+#define sqlite3_str_appendf chrome_sqlite3_str_appendf // Line 7430
+#define sqlite3_str_errcode chrome_sqlite3_str_errcode // Line 7466
+#define sqlite3_str_finish chrome_sqlite3_str_finish // Line 7396
+#define sqlite3_str_length chrome_sqlite3_str_length // Line 7467
+#define sqlite3_str_new chrome_sqlite3_str_new // Line 7381
+#define sqlite3_str_reset chrome_sqlite3_str_reset // Line 7435
+#define sqlite3_str_value chrome_sqlite3_str_value // Line 7468
+#define sqlite3_str_vappendf chrome_sqlite3_str_vappendf // Line 7431
+#define sqlite3_strglob chrome_sqlite3_strglob // Line 8408
+#define sqlite3_stricmp chrome_sqlite3_stricmp // Line 8390
+#define sqlite3_strlike chrome_sqlite3_strlike // Line 8454
+#define sqlite3_strnicmp chrome_sqlite3_strnicmp // Line 8391
+#define sqlite3_system_errno chrome_sqlite3_system_errno // Line 9055
#define sqlite3_table_column_metadata \
- 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 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 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
+ chrome_sqlite3_table_column_metadata // Lines 6135-6145
+#define sqlite3_temp_directory chrome_sqlite3_temp_directory // Line 5675
+#define sqlite3_test_control chrome_sqlite3_test_control // Line 7247
+#define sqlite3_thread_cleanup chrome_sqlite3_thread_cleanup // Line 4919
+#define sqlite3_threadsafe chrome_sqlite3_threadsafe // Line 230
+#define sqlite3_total_changes chrome_sqlite3_total_changes // Line 2392
+#define sqlite3_trace chrome_sqlite3_trace // Lines 3020-3021
+#define sqlite3_trace_v2 chrome_sqlite3_trace_v2 // Lines 3111-3116
+#define sqlite3_transfer_bindings chrome_sqlite3_transfer_bindings // Line 4917
+#define sqlite3_unlock_notify chrome_sqlite3_unlock_notify // Lines 8375-8379
+#define sqlite3_update_hook chrome_sqlite3_update_hook // Lines 5928-5932
+#define sqlite3_uri_boolean chrome_sqlite3_uri_boolean // Line 3436
+#define sqlite3_uri_int64 chrome_sqlite3_uri_int64 // Line 3437
+#define sqlite3_uri_parameter chrome_sqlite3_uri_parameter // Line 3435
+#define sqlite3_user_data chrome_sqlite3_user_data // Line 5147
+#define sqlite3_value_blob chrome_sqlite3_value_blob // Line 5045
+#define sqlite3_value_bytes chrome_sqlite3_value_bytes // Line 5054
+#define sqlite3_value_bytes16 chrome_sqlite3_value_bytes16 // Line 5055
+#define sqlite3_value_double chrome_sqlite3_value_double // Line 5046
+#define sqlite3_value_dup chrome_sqlite3_value_dup // Line 5086
+#define sqlite3_value_free chrome_sqlite3_value_free // Line 5087
+#define sqlite3_value_int chrome_sqlite3_value_int // Line 5047
+#define sqlite3_value_int64 chrome_sqlite3_value_int64 // Line 5048
+#define sqlite3_value_nochange chrome_sqlite3_value_nochange // Line 5058
#define sqlite3_value_numeric_type \
- 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 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 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
+ chrome_sqlite3_value_numeric_type // Line 5057
+#define sqlite3_value_pointer chrome_sqlite3_value_pointer // Line 5049
+#define sqlite3_value_subtype chrome_sqlite3_value_subtype // Line 5070
+#define sqlite3_value_text chrome_sqlite3_value_text // Line 5050
+#define sqlite3_value_text16 chrome_sqlite3_value_text16 // Line 5051
+#define sqlite3_value_text16be chrome_sqlite3_value_text16be // Line 5053
+#define sqlite3_value_text16le chrome_sqlite3_value_text16le // Line 5052
+#define sqlite3_value_type chrome_sqlite3_value_type // Line 5056
+#define sqlite3_version chrome_sqlite3_version // Line 162
+#define sqlite3_vfs_find chrome_sqlite3_vfs_find // Line 6912
+#define sqlite3_vfs_register chrome_sqlite3_vfs_register // Line 6913
+#define sqlite3_vfs_unregister chrome_sqlite3_vfs_unregister // Line 6914
+#define sqlite3_vmprintf chrome_sqlite3_vmprintf // Line 2675
+#define sqlite3_vsnprintf chrome_sqlite3_vsnprintf // Line 2677
+#define sqlite3_vtab_collation chrome_sqlite3_vtab_collation // Line 8788
+#define sqlite3_vtab_config chrome_sqlite3_vtab_config // Line 8700
+#define sqlite3_vtab_nochange chrome_sqlite3_vtab_nochange // Line 8773
+#define sqlite3_vtab_on_conflict chrome_sqlite3_vtab_on_conflict // Line 8754
#define sqlite3_wal_autocheckpoint \
- chrome_sqlite3_wal_autocheckpoint // Line 8525
-#define sqlite3_wal_checkpoint chrome_sqlite3_wal_checkpoint // Line 8547
+ chrome_sqlite3_wal_autocheckpoint // Line 8548
+#define sqlite3_wal_checkpoint chrome_sqlite3_wal_checkpoint // Line 8570
#define sqlite3_wal_checkpoint_v2 \
- chrome_sqlite3_wal_checkpoint_v2 // Lines 8641-8647
-#define sqlite3_wal_hook chrome_sqlite3_wal_hook // Lines 8490-8494
+ chrome_sqlite3_wal_checkpoint_v2 // Lines 8664-8670
+#define sqlite3_wal_hook chrome_sqlite3_wal_hook // Lines 8513-8517
#define sqlite3_win32_set_directory \
- chrome_sqlite3_win32_set_directory // Lines 5710-5713
+ chrome_sqlite3_win32_set_directory // Lines 5733-5736
#define sqlite3_win32_set_directory16 \
- chrome_sqlite3_win32_set_directory16 // Line 5715
+ chrome_sqlite3_win32_set_directory16 // Line 5738
#define sqlite3_win32_set_directory8 \
- chrome_sqlite3_win32_set_directory8 // Line 5714
-#define sqlite3changegroup_add chrome_sqlite3changegroup_add // Line 10412
+ chrome_sqlite3_win32_set_directory8 // Line 5737
+#define sqlite3changegroup_add chrome_sqlite3changegroup_add // Line 10435
#define sqlite3changegroup_add_strm \
- chrome_sqlite3changegroup_add_strm // Lines 11074-11077
+ chrome_sqlite3changegroup_add_strm // Lines 11097-11100
#define sqlite3changegroup_delete \
- chrome_sqlite3changegroup_delete // Line 10449
-#define sqlite3changegroup_new chrome_sqlite3changegroup_new // Line 10334
+ chrome_sqlite3changegroup_delete // Line 10472
+#define sqlite3changegroup_new chrome_sqlite3changegroup_new // Line 10357
#define sqlite3changegroup_output \
- chrome_sqlite3changegroup_output // Lines 10439-10443
+ chrome_sqlite3changegroup_output // Lines 10462-10466
#define sqlite3changegroup_output_strm \
- chrome_sqlite3changegroup_output_strm // Lines 11078-11081
+ chrome_sqlite3changegroup_output_strm // Lines 11101-11104
#define sqlite3changeset_apply \
- chrome_sqlite3changeset_apply // Lines 10609-10623
+ chrome_sqlite3changeset_apply // Lines 10632-10646
#define sqlite3changeset_apply_strm \
- chrome_sqlite3changeset_apply_strm // Lines 11007-11021
+ chrome_sqlite3changeset_apply_strm // Lines 11030-11044
#define sqlite3changeset_apply_v2 \
- chrome_sqlite3changeset_apply_v2 // Lines 10624-10640
+ chrome_sqlite3changeset_apply_v2 // Lines 10647-10663
#define sqlite3changeset_apply_v2_strm \
- chrome_sqlite3changeset_apply_v2_strm // Lines 11022-11038
+ chrome_sqlite3changeset_apply_v2_strm // Lines 11045-11061
#define sqlite3changeset_concat \
- chrome_sqlite3changeset_concat // Lines 10280-10287
+ chrome_sqlite3changeset_concat // Lines 10303-10310
#define sqlite3changeset_concat_strm \
- chrome_sqlite3changeset_concat_strm // Lines 11039-11046
+ chrome_sqlite3changeset_concat_strm // Lines 11062-11069
#define sqlite3changeset_conflict \
- chrome_sqlite3changeset_conflict // Lines 10166-10170
+ chrome_sqlite3changeset_conflict // Lines 10189-10193
#define sqlite3changeset_finalize \
- chrome_sqlite3changeset_finalize // Line 10219
+ chrome_sqlite3changeset_finalize // Line 10242
#define sqlite3changeset_fk_conflicts \
- chrome_sqlite3changeset_fk_conflicts // Lines 10183-10186
+ chrome_sqlite3changeset_fk_conflicts // Lines 10206-10209
#define sqlite3changeset_invert \
- chrome_sqlite3changeset_invert // Lines 10249-10252
+ chrome_sqlite3changeset_invert // Lines 10272-10275
#define sqlite3changeset_invert_strm \
- 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
+ chrome_sqlite3changeset_invert_strm // Lines 11070-11075
+#define sqlite3changeset_new chrome_sqlite3changeset_new // Lines 10161-10165
+#define sqlite3changeset_next chrome_sqlite3changeset_next // Line 10033
+#define sqlite3changeset_old chrome_sqlite3changeset_old // Lines 10127-10131
+#define sqlite3changeset_op chrome_sqlite3changeset_op // Lines 10062-10068
+#define sqlite3changeset_pk chrome_sqlite3changeset_pk // Lines 10096-10100
+#define sqlite3changeset_start chrome_sqlite3changeset_start // Lines 9984-9988
#define sqlite3changeset_start_strm \
- chrome_sqlite3changeset_start_strm // Lines 11053-11057
+ chrome_sqlite3changeset_start_strm // Lines 11076-11080
#define sqlite3changeset_start_v2 \
- chrome_sqlite3changeset_start_v2 // Lines 9966-9971
+ chrome_sqlite3changeset_start_v2 // Lines 9989-9994
#define sqlite3changeset_start_v2_strm \
- chrome_sqlite3changeset_start_v2_strm // Lines 11058-11063
+ chrome_sqlite3changeset_start_v2_strm // Lines 11081-11086
#define sqlite3rebaser_configure \
- 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
+ chrome_sqlite3rebaser_configure // Lines 10905-10908
+#define sqlite3rebaser_create chrome_sqlite3rebaser_create // Line 10894
+#define sqlite3rebaser_delete chrome_sqlite3rebaser_delete // Line 10938
+#define sqlite3rebaser_rebase chrome_sqlite3rebaser_rebase // Lines 10924-10928
#define sqlite3rebaser_rebase_strm \
- chrome_sqlite3rebaser_rebase_strm // Lines 11082-11088
-#define sqlite3session_attach chrome_sqlite3session_attach // Lines 9668-9671
+ chrome_sqlite3rebaser_rebase_strm // Lines 11105-11111
+#define sqlite3session_attach chrome_sqlite3session_attach // Lines 9691-9694
#define sqlite3session_changeset \
- chrome_sqlite3session_changeset // Lines 9797-9801
+ chrome_sqlite3session_changeset // Lines 9820-9824
#define sqlite3session_changeset_strm \
- 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
+ chrome_sqlite3session_changeset_strm // Lines 11087-11091
+#define sqlite3session_config chrome_sqlite3session_config // Line 11146
+#define sqlite3session_create chrome_sqlite3session_create // Lines 9561-9565
+#define sqlite3session_delete chrome_sqlite3session_delete // Line 9580
+#define sqlite3session_diff chrome_sqlite3session_diff // Lines 9883-9888
+#define sqlite3session_enable chrome_sqlite3session_enable // Line 9601
+#define sqlite3session_indirect chrome_sqlite3session_indirect // Line 9631
+#define sqlite3session_isempty chrome_sqlite3session_isempty // Line 9941
#define sqlite3session_patchset \
- chrome_sqlite3session_patchset // Lines 9897-9901
+ chrome_sqlite3session_patchset // Lines 9920-9924
#define sqlite3session_patchset_strm \
- chrome_sqlite3session_patchset_strm // Lines 11069-11073
+ chrome_sqlite3session_patchset_strm // Lines 11092-11096
#define sqlite3session_table_filter \
- chrome_sqlite3session_table_filter // Lines 9683-9690
+ chrome_sqlite3session_table_filter // Lines 9706-9713
#endif // THIRD_PARTY_SQLITE_AMALGAMATION_RENAME_EXPORTS_H_
+
diff --git a/chromium/third_party/sqlite/amalgamation/shell/shell.c b/chromium/third_party/sqlite/amalgamation/shell/shell.c
index 04ff4562761..ff7dc69d808 100644
--- a/chromium/third_party/sqlite/amalgamation/shell/shell.c
+++ b/chromium/third_party/sqlite/amalgamation/shell/shell.c
@@ -156,6 +156,9 @@ typedef unsigned char u8;
# ifndef unlink
# define unlink _unlink
# endif
+# ifndef strdup
+# define strdup _strdup
+# endif
# undef popen
# define popen _popen
# undef pclose
@@ -2143,22 +2146,47 @@ SQLITE_EXTENSION_INIT1
/*
** Set the result stored by context ctx to a blob containing the
-** contents of file zName.
+** contents of file zName. Or, leave the result unchanged (NULL)
+** if the file does not exist or is unreadable.
+**
+** If the file exceeds the SQLite blob size limit, through an
+** SQLITE_TOOBIG error.
+**
+** Throw an SQLITE_IOERR if there are difficulties pulling the file
+** off of disk.
*/
static void readFileContents(sqlite3_context *ctx, const char *zName){
FILE *in;
- long nIn;
+ sqlite3_int64 nIn;
void *pBuf;
+ sqlite3 *db;
+ int mxBlob;
in = fopen(zName, "rb");
- if( in==0 ) return;
+ if( in==0 ){
+ /* File does not exist or is unreadable. Leave the result set to NULL. */
+ return;
+ }
fseek(in, 0, SEEK_END);
nIn = ftell(in);
rewind(in);
- pBuf = sqlite3_malloc( nIn );
- if( pBuf && 1==fread(pBuf, nIn, 1, in) ){
- sqlite3_result_blob(ctx, pBuf, nIn, sqlite3_free);
+ db = sqlite3_context_db_handle(ctx);
+ mxBlob = sqlite3_limit(db, SQLITE_LIMIT_LENGTH, -1);
+ if( nIn>mxBlob ){
+ sqlite3_result_error_code(ctx, SQLITE_TOOBIG);
+ fclose(in);
+ return;
+ }
+ pBuf = sqlite3_malloc64( nIn );
+ if( pBuf==0 ){
+ sqlite3_result_error_nomem(ctx);
+ fclose(in);
+ return;
+ }
+ if( 1==fread(pBuf, nIn, 1, in) ){
+ sqlite3_result_blob64(ctx, pBuf, nIn, sqlite3_free);
}else{
+ sqlite3_result_error_code(ctx, SQLITE_IOERR);
sqlite3_free(pBuf);
}
fclose(in);
@@ -2668,8 +2696,8 @@ static int fsdirNext(sqlite3_vtab_cursor *cur){
FsdirLevel *pLvl;
if( iNew>=pCur->nLvl ){
int nNew = iNew+1;
- int nByte = nNew*sizeof(FsdirLevel);
- FsdirLevel *aNew = (FsdirLevel*)sqlite3_realloc(pCur->aLvl, nByte);
+ sqlite3_int64 nByte = nNew*sizeof(FsdirLevel);
+ FsdirLevel *aNew = (FsdirLevel*)sqlite3_realloc64(pCur->aLvl, nByte);
if( aNew==0 ) return SQLITE_NOMEM;
memset(&aNew[pCur->nLvl], 0, sizeof(FsdirLevel)*(nNew-pCur->nLvl));
pCur->aLvl = aNew;
@@ -2749,7 +2777,7 @@ static int fsdirColumn(
}else if( S_ISLNK(m) ){
char aStatic[64];
char *aBuf = aStatic;
- int nBuf = 64;
+ sqlite3_int64 nBuf = 64;
int n;
while( 1 ){
@@ -2757,7 +2785,7 @@ static int fsdirColumn(
if( n<nBuf ) break;
if( aBuf!=aStatic ) sqlite3_free(aBuf);
nBuf = nBuf*2;
- aBuf = sqlite3_malloc(nBuf);
+ aBuf = sqlite3_malloc64(nBuf);
if( aBuf==0 ){
sqlite3_result_error_nomem(ctx);
return SQLITE_NOMEM;
@@ -4061,6 +4089,117 @@ int sqlite3_appendvfs_init(
}
/************************* End ../ext/misc/appendvfs.c ********************/
+/************************* Begin ../ext/misc/memtrace.c ******************/
+/*
+** 2019-01-21
+**
+** The author disclaims copyright to this source code. In place of
+** a legal notice, here is a blessing:
+**
+** May you do good and not evil.
+** May you find forgiveness for yourself and forgive others.
+** May you share freely, never taking more than you give.
+**
+*************************************************************************
+**
+** This file implements an extension that uses the SQLITE_CONFIG_MALLOC
+** mechanism to add a tracing layer on top of SQLite. If this extension
+** is registered prior to sqlite3_initialize(), it will cause all memory
+** allocation activities to be logged on standard output, or to some other
+** FILE specified by the initializer.
+**
+** This file needs to be compiled into the application that uses it.
+**
+** This extension is used to implement the --memtrace option of the
+** command-line shell.
+*/
+#include <assert.h>
+#include <string.h>
+#include <stdio.h>
+
+/* The original memory allocation routines */
+static sqlite3_mem_methods memtraceBase;
+static FILE *memtraceOut;
+
+/* Methods that trace memory allocations */
+static void *memtraceMalloc(int n){
+ if( memtraceOut ){
+ fprintf(memtraceOut, "MEMTRACE: allocate %d bytes\n",
+ memtraceBase.xRoundup(n));
+ }
+ return memtraceBase.xMalloc(n);
+}
+static void memtraceFree(void *p){
+ if( p==0 ) return;
+ if( memtraceOut ){
+ fprintf(memtraceOut, "MEMTRACE: free %d bytes\n", memtraceBase.xSize(p));
+ }
+ memtraceBase.xFree(p);
+}
+static void *memtraceRealloc(void *p, int n){
+ if( p==0 ) return memtraceMalloc(n);
+ if( n==0 ){
+ memtraceFree(p);
+ return 0;
+ }
+ if( memtraceOut ){
+ fprintf(memtraceOut, "MEMTRACE: resize %d -> %d bytes\n",
+ memtraceBase.xSize(p), memtraceBase.xRoundup(n));
+ }
+ return memtraceBase.xRealloc(p, n);
+}
+static int memtraceSize(void *p){
+ return memtraceBase.xSize(p);
+}
+static int memtraceRoundup(int n){
+ return memtraceBase.xRoundup(n);
+}
+static int memtraceInit(void *p){
+ return memtraceBase.xInit(p);
+}
+static void memtraceShutdown(void *p){
+ memtraceBase.xShutdown(p);
+}
+
+/* The substitute memory allocator */
+static sqlite3_mem_methods ersaztMethods = {
+ memtraceMalloc,
+ memtraceFree,
+ memtraceRealloc,
+ memtraceSize,
+ memtraceRoundup,
+ memtraceInit,
+ memtraceShutdown,
+ 0
+};
+
+/* Begin tracing memory allocations to out. */
+int sqlite3MemTraceActivate(FILE *out){
+ int rc = SQLITE_OK;
+ if( memtraceBase.xMalloc==0 ){
+ rc = sqlite3_config(SQLITE_CONFIG_GETMALLOC, &memtraceBase);
+ if( rc==SQLITE_OK ){
+ rc = sqlite3_config(SQLITE_CONFIG_MALLOC, &ersaztMethods);
+ }
+ }
+ memtraceOut = out;
+ return rc;
+}
+
+/* Deactivate memory tracing */
+int sqlite3MemTraceDeactivate(void){
+ int rc = SQLITE_OK;
+ if( memtraceBase.xMalloc!=0 ){
+ rc = sqlite3_config(SQLITE_CONFIG_MALLOC, &memtraceBase);
+ if( rc==SQLITE_OK ){
+ memset(&memtraceBase, 0, sizeof(memtraceBase));
+ }
+ }
+ memtraceOut = 0;
+ return rc;
+}
+
+/************************* End ../ext/misc/memtrace.c ********************/
#ifdef SQLITE_HAVE_ZLIB
/************************* Begin ../ext/misc/zipfile.c ******************/
/*
@@ -4422,7 +4561,7 @@ static int zipfileConnect(
rc = sqlite3_declare_vtab(db, ZIPFILE_SCHEMA);
if( rc==SQLITE_OK ){
- pNew = (ZipfileTab*)sqlite3_malloc(nByte+nFile);
+ pNew = (ZipfileTab*)sqlite3_malloc64((sqlite3_int64)nByte+nFile);
if( pNew==0 ) return SQLITE_NOMEM;
memset(pNew, 0, nByte+nFile);
pNew->db = db;
@@ -4870,7 +5009,7 @@ static int zipfileGetEntry(
}
if( rc==SQLITE_OK ){
- int nAlloc;
+ sqlite3_int64 nAlloc;
ZipfileEntry *pNew;
int nFile = zipfileGetU16(&aRead[ZIPFILE_CDS_NFILE_OFF]);
@@ -4882,7 +5021,7 @@ static int zipfileGetEntry(
nAlloc += zipfileGetU32(&aRead[ZIPFILE_CDS_SZCOMPRESSED_OFF]);
}
- pNew = (ZipfileEntry*)sqlite3_malloc(nAlloc);
+ pNew = (ZipfileEntry*)sqlite3_malloc64(nAlloc);
if( pNew==0 ){
rc = SQLITE_NOMEM;
}else{
@@ -5045,11 +5184,11 @@ static int zipfileDeflate(
u8 **ppOut, int *pnOut, /* Output */
char **pzErr /* OUT: Error message */
){
- int nAlloc = (int)compressBound(nIn);
+ sqlite3_int64 nAlloc = compressBound(nIn);
u8 *aOut;
int rc = SQLITE_OK;
- aOut = (u8*)sqlite3_malloc(nAlloc);
+ aOut = (u8*)sqlite3_malloc64(nAlloc);
if( aOut==0 ){
rc = SQLITE_NOMEM;
}else{
@@ -5122,7 +5261,7 @@ static int zipfileColumn(
if( pCsr->pCurrent->aData ){
aBuf = pCsr->pCurrent->aData;
}else{
- aBuf = aFree = sqlite3_malloc(sz);
+ aBuf = aFree = sqlite3_malloc64(sz);
if( aBuf==0 ){
rc = SQLITE_NOMEM;
}else{
@@ -5961,14 +6100,14 @@ struct ZipfileCtx {
static int zipfileBufferGrow(ZipfileBuffer *pBuf, int nByte){
if( pBuf->n+nByte>pBuf->nAlloc ){
u8 *aNew;
- int nNew = pBuf->n ? pBuf->n*2 : 512;
+ sqlite3_int64 nNew = pBuf->n ? pBuf->n*2 : 512;
int nReq = pBuf->n + nByte;
while( nNew<nReq ) nNew = nNew*2;
- aNew = sqlite3_realloc(pBuf->a, nNew);
+ aNew = sqlite3_realloc64(pBuf->a, nNew);
if( aNew==0 ) return SQLITE_NOMEM;
pBuf->a = aNew;
- pBuf->nAlloc = nNew;
+ pBuf->nAlloc = (int)nNew;
}
return SQLITE_OK;
}
@@ -6159,7 +6298,7 @@ void zipfileStep(sqlite3_context *pCtx, int nVal, sqlite3_value **apVal){
void zipfileFinal(sqlite3_context *pCtx){
ZipfileCtx *p;
ZipfileEOCD eocd;
- int nZip;
+ sqlite3_int64 nZip;
u8 *aZip;
p = (ZipfileCtx*)sqlite3_aggregate_context(pCtx, sizeof(ZipfileCtx));
@@ -6172,14 +6311,14 @@ void zipfileFinal(sqlite3_context *pCtx){
eocd.iOffset = p->body.n;
nZip = p->body.n + p->cds.n + ZIPFILE_EOCD_FIXED_SZ;
- aZip = (u8*)sqlite3_malloc(nZip);
+ aZip = (u8*)sqlite3_malloc64(nZip);
if( aZip==0 ){
sqlite3_result_error_nomem(pCtx);
}else{
memcpy(aZip, p->body.a, p->body.n);
memcpy(&aZip[p->body.n], p->cds.a, p->cds.n);
zipfileSerializeEOCD(&eocd, &aZip[p->body.n + p->cds.n]);
- sqlite3_result_blob(pCtx, aZip, nZip, zipfileFree);
+ sqlite3_result_blob(pCtx, aZip, (int)nZip, zipfileFree);
}
}
@@ -8550,14 +8689,18 @@ struct ShellState {
u8 autoExplain; /* Automatically turn on .explain mode */
u8 autoEQP; /* Run EXPLAIN QUERY PLAN prior to seach SQL stmt */
u8 autoEQPtest; /* autoEQP is in test mode */
+ u8 autoEQPtrace; /* autoEQP is in trace mode */
u8 statsOn; /* True to display memory stats before each finalize */
u8 scanstatsOn; /* True to display scan stats before each finalize */
u8 openMode; /* SHELL_OPEN_NORMAL, _APPENDVFS, or _ZIPFILE */
u8 doXdgOpen; /* Invoke start/open/xdg-open in output_reset() */
u8 nEqpLevel; /* Depth of the EQP output graph */
+ u8 eTraceType; /* SHELL_TRACE_* value for type of trace */
unsigned mEqpLines; /* Mask of veritical lines in the EQP output graph */
int outCount; /* Revert to stdout when reaching zero */
int cnt; /* Number of records displayed so far */
+ int lineno; /* Line number of last line read from in */
+ FILE *in; /* Read commands from this stream */
FILE *out; /* Write results here */
FILE *traceOut; /* Output for sqlite3_trace() */
int nErr; /* Number of errors seen */
@@ -8568,7 +8711,11 @@ struct ShellState {
int writableSchema; /* True if PRAGMA writable_schema=ON */
int showHeader; /* True to show column names in List or Column mode */
int nCheck; /* Number of ".check" commands run */
+ unsigned nProgress; /* Number of progress callbacks encountered */
+ unsigned mxProgress; /* Maximum progress callbacks before failing */
+ unsigned flgProgress; /* Flags for the progress callback */
unsigned shellFlgs; /* Various flags */
+ sqlite3_int64 szMax; /* --maxsize argument to .open */
char *zDestTable; /* Name of destination table when MODE_Insert */
char *zTempFile; /* Temporary file that might need deleting */
char zTestcase[30]; /* Name of current test case */
@@ -8613,6 +8760,20 @@ struct ShellState {
#define SHELL_OPEN_ZIPFILE 3 /* Use the zipfile virtual table */
#define SHELL_OPEN_READONLY 4 /* Open a normal database read-only */
#define SHELL_OPEN_DESERIALIZE 5 /* Open using sqlite3_deserialize() */
+#define SHELL_OPEN_HEXDB 6 /* Use "dbtotxt" output as data source */
+
+/* Allowed values for ShellState.eTraceType
+*/
+#define SHELL_TRACE_PLAIN 0 /* Show input SQL text */
+#define SHELL_TRACE_EXPANDED 1 /* Show expanded SQL text */
+#define SHELL_TRACE_NORMALIZED 2 /* Show normalized SQL text */
+
+/* Bits in the ShellState.flgProgress variable */
+#define SHELL_PROGRESS_QUIET 0x01 /* Omit announcing every progress callback */
+#define SHELL_PROGRESS_RESET 0x02 /* Reset the count when the progres
+ ** callback limit is reached, and for each
+ ** top-level SQL statement */
+#define SHELL_PROGRESS_ONCE 0x04 /* Cancel the --limit after firing once */
/*
** These are the allowed shellFlgs values
@@ -9314,6 +9475,26 @@ static void eqp_render(ShellState *p){
}
}
+#ifndef SQLITE_OMIT_PROGRESS_CALLBACK
+/*
+** Progress handler callback.
+*/
+static int progress_handler(void *pClientData) {
+ ShellState *p = (ShellState*)pClientData;
+ p->nProgress++;
+ if( p->nProgress>=p->mxProgress && p->mxProgress>0 ){
+ raw_printf(p->out, "Progress limit reached (%u)\n", p->nProgress);
+ if( p->flgProgress & SHELL_PROGRESS_RESET ) p->nProgress = 0;
+ if( p->flgProgress & SHELL_PROGRESS_ONCE ) p->mxProgress = 0;
+ return 1;
+ }
+ if( (p->flgProgress & SHELL_PROGRESS_QUIET)==0 ){
+ raw_printf(p->out, "Progress %u\n", p->nProgress);
+ }
+ return 0;
+}
+#endif /* SQLITE_OMIT_PROGRESS_CALLBACK */
+
/*
** This is the callback routine that the shell
** invokes for each row of a query result.
@@ -10918,6 +11099,7 @@ static const char *(azHelp[]) = {
#endif
".backup ?DB? FILE Backup DB (default \"main\") to FILE",
" --append Use the appendvfs",
+ " --async Write to FILE without a journal and without fsync()",
".bail on|off Stop after hitting an error. Default OFF",
".binary on|off Turn binary output on or off. Default OFF",
".cd DIRECTORY Change the working directory to DIRECTORY",
@@ -10933,7 +11115,13 @@ static const char *(azHelp[]) = {
" --newlines Allow unescaped newline characters in output",
" TABLE is LIKE pattern for the tables to dump",
".echo on|off Turn command echo on or off",
- ".eqp on|off|full Enable or disable automatic EXPLAIN QUERY PLAN",
+ ".eqp on|off|full|... Enable or disable automatic EXPLAIN QUERY PLAN",
+ " Other Modes:",
+#ifdef SQLITE_DEBUG
+ " test Show raw EXPLAIN QUERY PLAN output",
+ " trace Like \"full\" but also enable \"PRAGMA vdbe_trace\"",
+#endif
+ " trigger Like \"full\" but also show trigger bytecode",
".excel Display the output of next command in a spreadsheet",
".exit ?CODE? Exit this program with return-code CODE",
".expert EXPERIMENTAL. Suggest indexes for specified queries",
@@ -10984,6 +11172,8 @@ static const char *(azHelp[]) = {
" --append Use appendvfs to append database to the end of FILE",
#ifdef SQLITE_ENABLE_DESERIALIZE
" --deserialize Load into memory useing sqlite3_deserialize()",
+ " --hexdb Load the output of \"dbtotxt\" as an in-memory database",
+ " --maxsize N Maximum size for --hexdb or --deserialized database",
#endif
" --new Initialize FILE to an empty database",
" --readonly Open FILE readonly",
@@ -10991,6 +11181,13 @@ static const char *(azHelp[]) = {
".output ?FILE? Send output to FILE or stdout if FILE is omitted",
" If FILE begins with '|' then open it as a pipe.",
".print STRING... Print literal STRING",
+#ifndef SQLITE_OMIT_PROGRESS_CALLBACK
+ ".progress N Invoke progress handler after every N opcodes",
+ " --limit N Interrupt after N progress callbacks",
+ " --once Do no more than one progress interrupt",
+ " --quiet|-q No output except at interrupts",
+ " --reset Reset the count for each input and interrupt",
+#endif
".prompt MAIN CONTINUE Replace the standard prompts",
".quit Exit this program",
".read FILE Read input from FILE",
@@ -11040,7 +11237,22 @@ static const char *(azHelp[]) = {
".testcase NAME Begin redirecting output to 'testcase-out.txt'",
".timeout MS Try opening locked tables for MS milliseconds",
".timer on|off Turn SQL timer on or off",
- ".trace FILE|off Output each SQL statement as it is run",
+#ifndef SQLITE_OMIT_TRACE
+ ".trace ?OPTIONS? Output each SQL statement as it is run",
+ " FILE Send output to FILE",
+ " stdout Send output to stdout",
+ " stderr Send output to stderr",
+ " off Disable tracing",
+ " --expanded Expand query parameters",
+#ifdef SQLITE_ENABLE_NORMALIZE
+ " --normalized Normal the SQL statements",
+#endif
+ " --plain Show SQL as it is input",
+ " --stmt Trace statement execution (SQLITE_TRACE_STMT)",
+ " --profile Profile statements (SQLITE_TRACE_PROFILE)",
+ " --row Trace each row (SQLITE_TRACE_ROW)",
+ " --close Trace connection close (SQLITE_TRACE_CLOSE)",
+#endif /* SQLITE_OMIT_TRACE */
".vfsinfo ?AUX? Information about the top-level VFS",
".vfslist List all available VFSes",
".vfsname ?AUX? Print the name of the VFS stack",
@@ -11118,7 +11330,7 @@ static int showHelp(FILE *out, const char *zPattern){
}
/* Forward reference */
-static int process_input(ShellState *p, FILE *in);
+static int process_input(ShellState *p);
/*
** Read the content of file zName into memory obtained from sqlite3_malloc64()
@@ -11248,6 +11460,94 @@ int deduceDatabaseType(const char *zName, int dfltZip){
return rc;
}
+#ifdef SQLITE_ENABLE_DESERIALIZE
+/*
+** Reconstruct an in-memory database using the output from the "dbtotxt"
+** program. Read content from the file in p->zDbFilename. If p->zDbFilename
+** is 0, then read from standard input.
+*/
+static unsigned char *readHexDb(ShellState *p, int *pnData){
+ unsigned char *a = 0;
+ int nLine;
+ int n = 0;
+ int pgsz = 0;
+ int iOffset = 0;
+ int j, k;
+ int rc;
+ FILE *in;
+ unsigned char x[16];
+ char zLine[1000];
+ if( p->zDbFilename ){
+ in = fopen(p->zDbFilename, "r");
+ if( in==0 ){
+ utf8_printf(stderr, "cannot open \"%s\" for reading\n", p->zDbFilename);
+ return 0;
+ }
+ nLine = 0;
+ }else{
+ in = p->in;
+ nLine = p->lineno;
+ }
+ *pnData = 0;
+ nLine++;
+ if( fgets(zLine, sizeof(zLine), in)==0 ) goto readHexDb_error;
+ rc = sscanf(zLine, "| size %d pagesize %d", &n, &pgsz);
+ if( rc!=2 ) goto readHexDb_error;
+ if( n<=0 ) goto readHexDb_error;
+ a = sqlite3_malloc( n );
+ if( a==0 ){
+ utf8_printf(stderr, "Out of memory!\n");
+ goto readHexDb_error;
+ }
+ memset(a, 0, n);
+ if( pgsz<512 || pgsz>65536 || (pgsz & (pgsz-1))!=0 ){
+ utf8_printf(stderr, "invalid pagesize\n");
+ goto readHexDb_error;
+ }
+ for(nLine++; fgets(zLine, sizeof(zLine), in)!=0; nLine++){
+ rc = sscanf(zLine, "| page %d offset %d", &j, &k);
+ if( rc==2 ){
+ iOffset = k;
+ continue;
+ }
+ if( strncmp(zLine, "| end ", 6)==0 ){
+ break;
+ }
+ rc = sscanf(zLine,"| %d: %hhx %hhx %hhx %hhx %hhx %hhx %hhx %hhx"
+ " %hhx %hhx %hhx %hhx %hhx %hhx %hhx %hhx",
+ &j, &x[0], &x[1], &x[2], &x[3], &x[4], &x[5], &x[6], &x[7],
+ &x[8], &x[9], &x[10], &x[11], &x[12], &x[13], &x[14], &x[15]);
+ if( rc==17 ){
+ k = iOffset+j;
+ if( k+16<=n ){
+ memcpy(a+k, x, 16);
+ }
+ }
+ }
+ *pnData = n;
+ if( in!=p->in ){
+ fclose(in);
+ }else{
+ p->lineno = nLine;
+ }
+ return a;
+
+readHexDb_error:
+ if( in!=stdin ){
+ fclose(in);
+ }else{
+ while( fgets(zLine, sizeof(zLine), p->in)!=0 ){
+ nLine++;
+ if(strncmp(zLine, "| end ", 6)==0 ) break;
+ }
+ p->lineno = nLine;
+ }
+ sqlite3_free(a);
+ utf8_printf(stderr,"Error on line %d of --hexdb input\n", nLine);
+ return 0;
+}
+#endif /* SQLITE_ENABLE_DESERIALIZE */
+
/* Flags for open_db().
**
** The default behavior of open_db() is to exit(1) if the database fails to
@@ -11281,6 +11581,7 @@ static void open_db(ShellState *p, int openFlags){
SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE, "apndvfs");
break;
}
+ case SHELL_OPEN_HEXDB:
case SHELL_OPEN_DESERIALIZE: {
sqlite3_open(0, &p->db);
break;
@@ -11303,7 +11604,10 @@ static void open_db(ShellState *p, int openFlags){
if( p->db==0 || SQLITE_OK!=sqlite3_errcode(p->db) ){
utf8_printf(stderr,"Error: unable to open database \"%s\": %s\n",
p->zDbFilename, sqlite3_errmsg(p->db));
- if( openFlags & OPEN_DB_KEEPALIVE ) return;
+ if( openFlags & OPEN_DB_KEEPALIVE ){
+ sqlite3_open(":memory:", &p->db);
+ return;
+ }
exit(1);
}
#ifndef SQLITE_OMIT_LOAD_EXTENSION
@@ -11335,15 +11639,29 @@ static void open_db(ShellState *p, int openFlags){
sqlite3_free(zSql);
}
#ifdef SQLITE_ENABLE_DESERIALIZE
- else if( p->openMode==SHELL_OPEN_DESERIALIZE ){
+ else
+ if( p->openMode==SHELL_OPEN_DESERIALIZE || p->openMode==SHELL_OPEN_HEXDB ){
+ int rc;
int nData = 0;
- unsigned char *aData = (unsigned char*)readFile(p->zDbFilename, &nData);
- int rc = sqlite3_deserialize(p->db, "main", aData, nData, nData,
+ unsigned char *aData;
+ if( p->openMode==SHELL_OPEN_DESERIALIZE ){
+ aData = (unsigned char*)readFile(p->zDbFilename, &nData);
+ }else{
+ aData = readHexDb(p, &nData);
+ if( aData==0 ){
+ utf8_printf(stderr, "Error in hexdb input\n");
+ return;
+ }
+ }
+ rc = sqlite3_deserialize(p->db, "main", aData, nData, nData,
SQLITE_DESERIALIZE_RESIZEABLE |
SQLITE_DESERIALIZE_FREEONCLOSE);
if( rc ){
utf8_printf(stderr, "Error: sqlite3_deserialize() returns %d\n", rc);
}
+ if( p->szMax>0 ){
+ sqlite3_file_control(p->db, "main", SQLITE_FCNTL_SIZE_LIMIT, &p->szMax);
+ }
}
#endif
}
@@ -11547,24 +11865,60 @@ static FILE *output_file_open(const char *zFile, int bTextMode){
return f;
}
-#if !defined(SQLITE_OMIT_TRACE) && !defined(SQLITE_OMIT_FLOATING_POINT)
+#ifndef SQLITE_OMIT_TRACE
/*
** A routine for handling output from sqlite3_trace().
*/
static int sql_trace_callback(
- unsigned mType,
- void *pArg,
- void *pP,
- void *pX
+ unsigned mType, /* The trace type */
+ void *pArg, /* The ShellState pointer */
+ void *pP, /* Usually a pointer to sqlite_stmt */
+ void *pX /* Auxiliary output */
){
- FILE *f = (FILE*)pArg;
- UNUSED_PARAMETER(mType);
- UNUSED_PARAMETER(pP);
- if( f ){
- const char *z = (const char*)pX;
- int i = strlen30(z);
- while( i>0 && z[i-1]==';' ){ i--; }
- utf8_printf(f, "%.*s;\n", i, z);
+ ShellState *p = (ShellState*)pArg;
+ sqlite3_stmt *pStmt;
+ const char *zSql;
+ int nSql;
+ if( p->traceOut==0 ) return 0;
+ if( mType==SQLITE_TRACE_CLOSE ){
+ utf8_printf(p->traceOut, "-- closing database connection\n");
+ return 0;
+ }
+ if( mType!=SQLITE_TRACE_ROW && ((const char*)pX)[0]=='-' ){
+ zSql = (const char*)pX;
+ }else{
+ pStmt = (sqlite3_stmt*)pP;
+ switch( p->eTraceType ){
+ case SHELL_TRACE_EXPANDED: {
+ zSql = sqlite3_expanded_sql(pStmt);
+ break;
+ }
+#ifdef SQLITE_ENABLE_NORMALIZE
+ case SHELL_TRACE_NORMALIZED: {
+ zSql = sqlite3_normalized_sql(pStmt);
+ break;
+ }
+#endif
+ default: {
+ zSql = sqlite3_sql(pStmt);
+ break;
+ }
+ }
+ }
+ if( zSql==0 ) return 0;
+ nSql = strlen30(zSql);
+ while( nSql>0 && zSql[nSql-1]==';' ){ nSql--; }
+ switch( mType ){
+ case SQLITE_TRACE_ROW:
+ case SQLITE_TRACE_STMT: {
+ utf8_printf(p->traceOut, "%.*s;\n", nSql, zSql);
+ break;
+ }
+ case SQLITE_TRACE_PROFILE: {
+ sqlite3_int64 nNanosec = *(sqlite3_int64*)pX;
+ utf8_printf(p->traceOut, "%.*s; -- %lld ns\n", nSql, zSql, nNanosec);
+ break;
+ }
}
return 0;
}
@@ -13131,7 +13485,7 @@ static int arCreateOrUpdateCommand(
}
end_ar_transaction:
if( rc!=SQLITE_OK ){
- arExecSql(pAr, "ROLLBACK TO ar; RELEASE ar;");
+ sqlite3_exec(pAr->db, "ROLLBACK TO ar; RELEASE ar;", 0, 0, 0);
}else{
rc = arExecSql(pAr, "RELEASE ar;");
if( pAr->bZip && pAr->zFile ){
@@ -13330,6 +13684,7 @@ static int do_meta_command(char *zLine, ShellState *p){
sqlite3 *pDest;
sqlite3_backup *pBackup;
int j;
+ int bAsync = 0;
const char *zVfs = 0;
for(j=1; j<nArg; j++){
const char *z = azArg[j];
@@ -13338,6 +13693,9 @@ static int do_meta_command(char *zLine, ShellState *p){
if( strcmp(z, "-append")==0 ){
zVfs = "apndvfs";
}else
+ if( strcmp(z, "-async")==0 ){
+ bAsync = 1;
+ }else
{
utf8_printf(stderr, "unknown option: %s\n", azArg[j]);
return 1;
@@ -13348,7 +13706,7 @@ static int do_meta_command(char *zLine, ShellState *p){
zDb = zDestFile;
zDestFile = azArg[j];
}else{
- raw_printf(stderr, "Usage: .backup ?DB? ?--append? FILENAME\n");
+ raw_printf(stderr, "Usage: .backup ?DB? ?OPTIONS? FILENAME\n");
return 1;
}
}
@@ -13364,6 +13722,10 @@ static int do_meta_command(char *zLine, ShellState *p){
close_db(pDest);
return 1;
}
+ if( bAsync ){
+ sqlite3_exec(pDest, "PRAGMA synchronous=OFF; PRAGMA journal_mode=OFF;",
+ 0, 0, 0);
+ }
open_db(p, 0);
pBackup = sqlite3_backup_init(pDest, "main", p->db, zDb);
if( pBackup==0 ){
@@ -13629,18 +13991,30 @@ static int do_meta_command(char *zLine, ShellState *p){
if( c=='e' && strncmp(azArg[0], "eqp", n)==0 ){
if( nArg==2 ){
p->autoEQPtest = 0;
+ if( p->autoEQPtrace ){
+ if( p->db ) sqlite3_exec(p->db, "PRAGMA vdbe_trace=OFF;", 0, 0, 0);
+ p->autoEQPtrace = 0;
+ }
if( strcmp(azArg[1],"full")==0 ){
p->autoEQP = AUTOEQP_full;
}else if( strcmp(azArg[1],"trigger")==0 ){
p->autoEQP = AUTOEQP_trigger;
+#ifdef SQLITE_DEBUG
}else if( strcmp(azArg[1],"test")==0 ){
p->autoEQP = AUTOEQP_on;
p->autoEQPtest = 1;
+ }else if( strcmp(azArg[1],"trace")==0 ){
+ p->autoEQP = AUTOEQP_full;
+ p->autoEQPtrace = 1;
+ open_db(p, 0);
+ sqlite3_exec(p->db, "SELECT name FROM sqlite_master LIMIT 1", 0, 0, 0);
+ sqlite3_exec(p->db, "PRAGMA vdbe_trace=ON;", 0, 0, 0);
+#endif
}else{
p->autoEQP = (u8)booleanValue(azArg[1]);
}
}else{
- raw_printf(stderr, "Usage: .eqp off|on|trigger|full\n");
+ raw_printf(stderr, "Usage: .eqp off|on|trace|trigger|full\n");
rc = 1;
}
}else
@@ -14214,6 +14588,7 @@ static int do_meta_command(char *zLine, ShellState *p){
sqlite3_free(p->zFreeOnClose);
p->zFreeOnClose = 0;
p->openMode = SHELL_OPEN_UNSPEC;
+ p->szMax = 0;
/* Check for command-line arguments */
for(iName=1; iName<nArg && azArg[iName][0]=='-'; iName++){
const char *z = azArg[iName];
@@ -14230,7 +14605,11 @@ static int do_meta_command(char *zLine, ShellState *p){
#ifdef SQLITE_ENABLE_DESERIALIZE
}else if( optionMatch(z, "deserialize") ){
p->openMode = SHELL_OPEN_DESERIALIZE;
-#endif
+ }else if( optionMatch(z, "hexdb") ){
+ p->openMode = SHELL_OPEN_HEXDB;
+ }else if( optionMatch(z, "maxsize") && iName+1<nArg ){
+ p->szMax = integerValue(azArg[++iName]);
+#endif /* SQLITE_ENABLE_DESERIALIZE */
}else if( z[0]=='-' ){
utf8_printf(stderr, "unknown option: %s\n", z);
rc = 1;
@@ -14239,7 +14618,7 @@ static int do_meta_command(char *zLine, ShellState *p){
}
/* If a filename is specified, try to open it first */
zNewFilename = nArg>iName ? sqlite3_mprintf("%s", azArg[iName]) : 0;
- if( zNewFilename ){
+ if( zNewFilename || p->openMode==SHELL_OPEN_HEXDB ){
if( newFlag ) shellDeleteFile(zNewFilename);
p->zDbFilename = zNewFilename;
open_db(p, OPEN_DB_KEEPALIVE);
@@ -14341,6 +14720,52 @@ static int do_meta_command(char *zLine, ShellState *p){
raw_printf(p->out, "\n");
}else
+#ifndef SQLITE_OMIT_PROGRESS_CALLBACK
+ if( c=='p' && n>=3 && strncmp(azArg[0], "progress", n)==0 ){
+ int i;
+ int nn = 0;
+ p->flgProgress = 0;
+ p->mxProgress = 0;
+ p->nProgress = 0;
+ for(i=1; i<nArg; i++){
+ const char *z = azArg[i];
+ if( z[0]=='-' ){
+ z++;
+ if( z[0]=='-' ) z++;
+ if( strcmp(z,"quiet")==0 || strcmp(z,"q")==0 ){
+ p->flgProgress |= SHELL_PROGRESS_QUIET;
+ continue;
+ }
+ if( strcmp(z,"reset")==0 ){
+ p->flgProgress |= SHELL_PROGRESS_RESET;
+ continue;
+ }
+ if( strcmp(z,"once")==0 ){
+ p->flgProgress |= SHELL_PROGRESS_ONCE;
+ continue;
+ }
+ if( strcmp(z,"limit")==0 ){
+ if( i+1>=nArg ){
+ utf8_printf(stderr, "Error: missing argument on --limit\n");
+ rc = 1;
+ goto meta_command_exit;
+ }else{
+ p->mxProgress = (int)integerValue(azArg[++i]);
+ }
+ continue;
+ }
+ utf8_printf(stderr, "Error: unknown option: \"%s\"\n", azArg[i]);
+ rc = 1;
+ goto meta_command_exit;
+ }else{
+ nn = (int)integerValue(z);
+ }
+ }
+ open_db(p, 0);
+ sqlite3_progress_handler(p->db, nn, progress_handler, p);
+ }else
+#endif /* SQLITE_OMIT_PROGRESS_CALLBACK */
+
if( c=='p' && strncmp(azArg[0], "prompt", n)==0 ){
if( nArg >= 2) {
strncpy(mainPrompt,azArg[1],(int)ArraySize(mainPrompt)-1);
@@ -14355,20 +14780,23 @@ static int do_meta_command(char *zLine, ShellState *p){
}else
if( c=='r' && n>=3 && strncmp(azArg[0], "read", n)==0 ){
- FILE *alt;
+ FILE *inSaved = p->in;
+ int savedLineno = p->lineno;
if( nArg!=2 ){
raw_printf(stderr, "Usage: .read FILE\n");
rc = 1;
goto meta_command_exit;
}
- alt = fopen(azArg[1], "rb");
- if( alt==0 ){
+ p->in = fopen(azArg[1], "rb");
+ if( p->in==0 ){
utf8_printf(stderr,"Error: cannot open \"%s\"\n", azArg[1]);
rc = 1;
}else{
- rc = process_input(p, alt);
- fclose(alt);
+ rc = process_input(p);
+ fclose(p->in);
}
+ p->in = inSaved;
+ p->lineno = savedLineno;
}else
if( c=='r' && n>=3 && strncmp(azArg[0], "restore", n)==0 ){
@@ -15386,23 +15814,55 @@ static int do_meta_command(char *zLine, ShellState *p){
}
}else
+#ifndef SQLITE_OMIT_TRACE
if( c=='t' && strncmp(azArg[0], "trace", n)==0 ){
+ int mType = 0;
+ int jj;
open_db(p, 0);
- if( nArg!=2 ){
- raw_printf(stderr, "Usage: .trace FILE|off\n");
- rc = 1;
- goto meta_command_exit;
+ for(jj=1; jj<nArg; jj++){
+ const char *z = azArg[jj];
+ if( z[0]=='-' ){
+ if( optionMatch(z, "expanded") ){
+ p->eTraceType = SHELL_TRACE_EXPANDED;
+ }
+#ifdef SQLITE_ENABLE_NORMALIZE
+ else if( optionMatch(z, "normalized") ){
+ p->eTraceType = SHELL_TRACE_NORMALIZED;
+ }
+#endif
+ else if( optionMatch(z, "plain") ){
+ p->eTraceType = SHELL_TRACE_PLAIN;
+ }
+ else if( optionMatch(z, "profile") ){
+ mType |= SQLITE_TRACE_PROFILE;
+ }
+ else if( optionMatch(z, "row") ){
+ mType |= SQLITE_TRACE_ROW;
+ }
+ else if( optionMatch(z, "stmt") ){
+ mType |= SQLITE_TRACE_STMT;
+ }
+ else if( optionMatch(z, "close") ){
+ mType |= SQLITE_TRACE_CLOSE;
+ }
+ else {
+ raw_printf(stderr, "Unknown option \"%s\" on \".trace\"\n", z);
+ rc = 1;
+ goto meta_command_exit;
+ }
+ }else{
+ output_file_close(p->traceOut);
+ p->traceOut = output_file_open(azArg[1], 0);
+ }
}
- output_file_close(p->traceOut);
- p->traceOut = output_file_open(azArg[1], 0);
-#if !defined(SQLITE_OMIT_TRACE) && !defined(SQLITE_OMIT_FLOATING_POINT)
if( p->traceOut==0 ){
sqlite3_trace_v2(p->db, 0, 0, 0);
}else{
- sqlite3_trace_v2(p->db, SQLITE_TRACE_STMT, sql_trace_callback,p->traceOut);
+ if( mType==0 ) mType = SQLITE_TRACE_STMT;
+ sqlite3_trace_v2(p->db, mType, sql_trace_callback, p);
}
-#endif
}else
+#endif /* !defined(SQLITE_OMIT_TRACE) */
#if SQLITE_USER_AUTHENTICATION
if( c=='u' && strncmp(azArg[0], "user", n)==0 ){
@@ -15641,6 +16101,7 @@ static int runOneSqlLine(ShellState *p, char *zSql, FILE *in, int startline){
open_db(p, 0);
if( ShellHasFlag(p,SHFLG_Backslash) ) resolve_backslashes(zSql);
+ if( p->flgProgress & SHELL_PROGRESS_RESET ) p->nProgress = 0;
BEGIN_TIMER;
rc = shell_exec(p, zSql, &zErrMsg);
END_TIMER;
@@ -15677,7 +16138,7 @@ static int runOneSqlLine(ShellState *p, char *zSql, FILE *in, int startline){
**
** Return the number of errors.
*/
-static int process_input(ShellState *p, FILE *in){
+static int process_input(ShellState *p){
char *zLine = 0; /* A single input line */
char *zSql = 0; /* Accumulated SQL text */
int nLine; /* Length of current line */
@@ -15686,22 +16147,22 @@ static int process_input(ShellState *p, FILE *in){
int nSqlPrior = 0; /* Bytes of zSql[] used by prior line */
int rc; /* Error code */
int errCnt = 0; /* Number of errors seen */
- int lineno = 0; /* Current line number */
int startline = 0; /* Line number for start of current input */
- while( errCnt==0 || !bail_on_error || (in==0 && stdin_is_interactive) ){
+ p->lineno = 0;
+ while( errCnt==0 || !bail_on_error || (p->in==0 && stdin_is_interactive) ){
fflush(p->out);
- zLine = one_input_line(in, zLine, nSql>0);
+ zLine = one_input_line(p->in, zLine, nSql>0);
if( zLine==0 ){
/* End of input */
- if( in==0 && stdin_is_interactive ) printf("\n");
+ if( p->in==0 && stdin_is_interactive ) printf("\n");
break;
}
if( seenInterrupt ){
- if( in!=0 ) break;
+ if( p->in!=0 ) break;
seenInterrupt = 0;
}
- lineno++;
+ p->lineno++;
if( nSql==0 && _all_whitespace(zLine) ){
if( ShellHasFlag(p, SHFLG_Echo) ) printf("%s\n", zLine);
continue;
@@ -15733,7 +16194,7 @@ static int process_input(ShellState *p, FILE *in){
for(i=0; zLine[i] && IsSpace(zLine[i]); i++){}
assert( nAlloc>0 && zSql!=0 );
memcpy(zSql, zLine+i, nLine+1-i);
- startline = lineno;
+ startline = p->lineno;
nSql = nLine-i;
}else{
zSql[nSql++] = '\n';
@@ -15742,7 +16203,7 @@ static int process_input(ShellState *p, FILE *in){
}
if( nSql && line_contains_semicolon(&zSql[nSqlPrior], nSql-nSqlPrior)
&& sqlite3_complete(zSql) ){
- errCnt += runOneSqlLine(p, zSql, in, startline);
+ errCnt += runOneSqlLine(p, zSql, p->in, startline);
nSql = 0;
if( p->outCount ){
output_reset(p);
@@ -15756,7 +16217,7 @@ static int process_input(ShellState *p, FILE *in){
}
}
if( nSql && !_all_whitespace(zSql) ){
- errCnt += runOneSqlLine(p, zSql, in, startline);
+ errCnt += runOneSqlLine(p, zSql, p->in, startline);
}
free(zSql);
free(zLine);
@@ -15845,7 +16306,8 @@ static void process_sqliterc(
char *home_dir = NULL;
const char *sqliterc = sqliterc_override;
char *zBuf = 0;
- FILE *in = NULL;
+ FILE *inSaved = p->in;
+ int savedLineno = p->lineno;
if (sqliterc == NULL) {
home_dir = find_home_dir(0);
@@ -15857,14 +16319,16 @@ static void process_sqliterc(
zBuf = sqlite3_mprintf("%s/.sqliterc",home_dir);
sqliterc = zBuf;
}
- in = fopen(sqliterc,"rb");
- if( in ){
+ p->in = fopen(sqliterc,"rb");
+ if( p->in ){
if( stdin_is_interactive ){
utf8_printf(stderr,"-- Loading resources from %s\n",sqliterc);
}
- process_input(p,in);
- fclose(in);
+ process_input(p);
+ fclose(p->in);
}
+ p->in = inSaved;
+ p->lineno = savedLineno;
sqlite3_free(zBuf);
}
@@ -15882,6 +16346,9 @@ static const char zOptions[] =
" -column set output mode to 'column'\n"
" -cmd COMMAND run \"COMMAND\" before reading stdin\n"
" -csv set output mode to 'csv'\n"
+#if defined(SQLITE_ENABLE_DESERIALIZE)
+ " -deserialize open the database using sqlite3_deserialize()\n"
+#endif
" -echo print commands before execution\n"
" -init FILENAME read/process named file\n"
" -[no]header turn headers on or off\n"
@@ -15894,6 +16361,10 @@ static const char zOptions[] =
" -line set output mode to 'line'\n"
" -list set output mode to 'list'\n"
" -lookaside SIZE N use N entries of SZ bytes for lookaside memory\n"
+#if defined(SQLITE_ENABLE_DESERIALIZE)
+ " -maxsize N maximum size for a --deserialize database\n"
+#endif
+ " -memtrace trace all memory allocations and deallocations\n"
" -mmap N default mmap size set to N\n"
#ifdef SQLITE_ENABLE_MULTIPLEX
" -multiplex enable the multiplexor VFS\n"
@@ -16214,6 +16685,8 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){
#ifdef SQLITE_ENABLE_DESERIALIZE
}else if( strcmp(z,"-deserialize")==0 ){
data.openMode = SHELL_OPEN_DESERIALIZE;
+ }else if( strcmp(z,"-maxsize")==0 && i+1<argc ){
+ data.szMax = integerValue(argv[++i]);
#endif
}else if( strcmp(z,"-readonly")==0 ){
data.openMode = SHELL_OPEN_READONLY;
@@ -16223,6 +16696,8 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){
** command, so ignore them */
break;
#endif
+ }else if( strcmp(z, "-memtrace")==0 ){
+ sqlite3MemTraceActivate(stderr);
}
}
verify_uninitialized();
@@ -16313,6 +16788,8 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){
#ifdef SQLITE_ENABLE_DESERIALIZE
}else if( strcmp(z,"-deserialize")==0 ){
data.openMode = SHELL_OPEN_DESERIALIZE;
+ }else if( strcmp(z,"-maxsize")==0 && i+1<argc ){
+ data.szMax = integerValue(argv[++i]);
#endif
}else if( strcmp(z,"-readonly")==0 ){
data.openMode = SHELL_OPEN_READONLY;
@@ -16369,6 +16846,8 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){
i+=2;
}else if( strcmp(z,"-mmap")==0 ){
i++;
+ }else if( strcmp(z,"-memtrace")==0 ){
+ i++;
#ifdef SQLITE_ENABLE_SORTER_REFERENCES
}else if( strcmp(z,"-sorterref")==0 ){
i++;
@@ -16486,14 +16965,16 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){
#elif HAVE_LINENOISE
linenoiseSetCompletionCallback(linenoise_completion);
#endif
- rc = process_input(&data, 0);
+ data.in = 0;
+ rc = process_input(&data);
if( zHistory ){
shell_stifle_history(2000);
shell_write_history(zHistory);
free(zHistory);
}
}else{
- rc = process_input(&data, stdin);
+ data.in = stdin;
+ rc = process_input(&data);
}
}
set_table_name(&data, 0);
diff --git a/chromium/third_party/sqlite/amalgamation/sqlite3.c b/chromium/third_party/sqlite/amalgamation/sqlite3.c
index 3ca72d7bb2b..695c0a5b8f0 100644
--- a/chromium/third_party/sqlite/amalgamation/sqlite3.c
+++ b/chromium/third_party/sqlite/amalgamation/sqlite3.c
@@ -1,6 +1,6 @@
/******************************************************************************
** This file is an amalgamation of many separate C source files from SQLite
-** version 3.26.0. By combining all the individual C code files into this
+** version 3.27.1. By combining all the individual C code files into this
** single large file, the entire code can be compiled as a single translation
** unit. This allows many compilers to do optimizations that would not be
** possible if the files were compiled separately. Performance improvements
@@ -1162,9 +1162,9 @@ extern "C" {
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
** [sqlite_version()] and [sqlite_source_id()].
*/
-#define SQLITE_VERSION "3.26.0"
-#define SQLITE_VERSION_NUMBER 3026000
-#define SQLITE_SOURCE_ID "2018-12-01 12:34:55 bf8c1b2b7a5960c282e543b9c293686dccff272512d08865f4600fb58238alt1"
+#define SQLITE_VERSION "3.27.1"
+#define SQLITE_VERSION_NUMBER 3027001
+#define SQLITE_SOURCE_ID "2019-02-08 13:17:39 0eca3dd3d38b31c92b49ca2d311128b74584714d9e7de895b1a6286ef959alt1"
/*
** CAPI3REF: Run-Time Library Version Numbers
@@ -1862,6 +1862,15 @@ struct sqlite3_io_methods {
** file space based on this hint in order to help writes to the database
** file run faster.
**
+** <li>[[SQLITE_FCNTL_SIZE_LIMIT]]
+** The [SQLITE_FCNTL_SIZE_LIMIT] opcode is used by in-memory VFS that
+** implements [sqlite3_deserialize()] to set an upper bound on the size
+** of the in-memory database. The argument is a pointer to a [sqlite3_int64].
+** If the integer pointed to is negative, then it is filled in with the
+** current limit. Otherwise the limit is set to the larger of the value
+** of the integer pointed to and the current database size. The integer
+** pointed to is set to the new limit.
+**
** <li>[[SQLITE_FCNTL_CHUNK_SIZE]]
** The [SQLITE_FCNTL_CHUNK_SIZE] opcode is used to request that the VFS
** extends and truncates the database file in chunks of a size specified
@@ -2170,6 +2179,7 @@ struct sqlite3_io_methods {
#define SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE 33
#define SQLITE_FCNTL_LOCK_TIMEOUT 34
#define SQLITE_FCNTL_DATA_VERSION 35
+#define SQLITE_FCNTL_SIZE_LIMIT 36
/* deprecated names */
#define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE
@@ -3011,6 +3021,17 @@ struct sqlite3_mem_methods {
** negative value for this option restores the default behaviour.
** This option is only available if SQLite is compiled with the
** [SQLITE_ENABLE_SORTER_REFERENCES] compile-time option.
+**
+** [[SQLITE_CONFIG_MEMDB_MAXSIZE]]
+** <dt>SQLITE_CONFIG_MEMDB_MAXSIZE
+** <dd>The SQLITE_CONFIG_MEMDB_MAXSIZE option accepts a single parameter
+** [sqlite3_int64] parameter which is the default maximum size for an in-memory
+** database created using [sqlite3_deserialize()]. This default maximum
+** size can be adjusted up or down for individual databases using the
+** [SQLITE_FCNTL_SIZE_LIMIT] [sqlite3_file_control|file-control]. If this
+** configuration setting is never used, then the default maximum is determined
+** by the [SQLITE_MEMDB_DEFAULT_MAXSIZE] compile-time option. If that
+** compile-time option is not set, then the default maximum is 1073741824.
** </dl>
*/
#define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */
@@ -3041,6 +3062,7 @@ struct sqlite3_mem_methods {
#define SQLITE_CONFIG_STMTJRNL_SPILL 26 /* int nByte */
#define SQLITE_CONFIG_SMALL_MALLOC 27 /* boolean */
#define SQLITE_CONFIG_SORTERREF_SIZE 28 /* int nByte */
+#define SQLITE_CONFIG_MEMDB_MAXSIZE 29 /* sqlite3_int64 */
/*
** CAPI3REF: Database Connection Configuration Options
@@ -4030,9 +4052,9 @@ SQLITE_API int sqlite3_set_authorizer(
** time is in units of nanoseconds, however the current implementation
** is only capable of millisecond resolution so the six least significant
** digits in the time are meaningless. Future versions of SQLite
-** might provide greater resolution on the profiler callback. The
-** sqlite3_profile() function is considered experimental and is
-** subject to change in future versions of SQLite.
+** might provide greater resolution on the profiler callback. Invoking
+** either [sqlite3_trace()] or [sqlite3_trace_v2()] will cancel the
+** profile callback.
*/
SQLITE_API SQLITE_DEPRECATED void *sqlite3_trace(sqlite3*,
void(*xTrace)(void*,const char*), void*);
@@ -4446,6 +4468,8 @@ SQLITE_API int sqlite3_open_v2(
** is not a database file pathname pointer that SQLite passed into the xOpen
** VFS method, then the behavior of this routine is undefined and probably
** undesirable.
+**
+** See the [URI filename] documentation for additional information.
*/
SQLITE_API const char *sqlite3_uri_parameter(const char *zFilename, const char *zParam);
SQLITE_API int sqlite3_uri_boolean(const char *zFile, const char *zParam, int bDefault);
@@ -4668,14 +4692,13 @@ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
** deplete the limited store of lookaside memory. Future versions of
** SQLite may act on this hint differently.
**
-** [[SQLITE_PREPARE_NORMALIZE]] ^(<dt>SQLITE_PREPARE_NORMALIZE</dt>
-** <dd>The SQLITE_PREPARE_NORMALIZE flag indicates that a normalized
-** representation of the SQL statement should be calculated and then
-** associated with the prepared statement, which can be obtained via
-** the [sqlite3_normalized_sql()] interface.)^ The semantics used to
-** normalize a SQL statement are unspecified and subject to change.
-** At a minimum, literal values will be replaced with suitable
-** placeholders.
+** [[SQLITE_PREPARE_NORMALIZE]] <dt>SQLITE_PREPARE_NORMALIZE</dt>
+** <dd>The SQLITE_PREPARE_NORMALIZE flag is a no-op. This flag used
+** to be required for any prepared statement that wanted to use the
+** [sqlite3_normalized_sql()] interface. However, the
+** [sqlite3_normalized_sql()] interface is now available to all
+** prepared statements, regardless of whether or not they use this
+** flag.
**
** [[SQLITE_PREPARE_NO_VTAB]] <dt>SQLITE_PREPARE_NO_VTAB</dt>
** <dd>The SQLITE_PREPARE_NO_VTAB flag causes the SQL compiler
@@ -11064,7 +11087,7 @@ SQLITE_API int sqlite3changeset_next(sqlite3_changeset_iter *pIter);
** sqlite3changeset_next() is called on the iterator or until the
** conflict-handler function returns. If pnCol is not NULL, then *pnCol is
** set to the number of columns in the table affected by the change. If
-** pbIncorrect is not NULL, then *pbIndirect is set to true (1) if the change
+** pbIndirect is not NULL, then *pbIndirect is set to true (1) if the change
** is an indirect change, or false (0) otherwise. See the documentation for
** [sqlite3session_indirect()] for a description of direct and indirect
** changes. Finally, if pOp is not NULL, then *pOp is set to one of
@@ -12298,12 +12321,8 @@ struct Fts5PhraseIter {
**
** Usually, output parameter *piPhrase is set to the phrase number, *piCol
** to the column in which it occurs and *piOff the token offset of the
-** first token of the phrase. The exception is if the table was created
-** with the offsets=0 option specified. In this case *piOff is always
-** set to -1.
-**
-** Returns SQLITE_OK if successful, or an error code (i.e. SQLITE_NOMEM)
-** if an error occurs.
+** first token of the phrase. Returns SQLITE_OK if successful, or an error
+** code (i.e. SQLITE_NOMEM) if an error occurs.
**
** This API can be quite slow if used with an FTS5 table created with the
** "detail=none" or "detail=column" option.
@@ -12592,11 +12611,11 @@ struct Fts5ExtensionApi {
** the tokenizer substitutes "first" for "1st" and the query works
** as expected.
**
-** <li> By adding multiple synonyms for a single term to the FTS index.
-** In this case, when tokenizing query text, the tokenizer may
-** provide multiple synonyms for a single term within the document.
-** FTS5 then queries the index for each synonym individually. For
-** example, faced with the query:
+** <li> By querying the index for all synonyms of each query term
+** separately. In this case, when tokenizing query text, the
+** tokenizer may provide multiple synonyms for a single term
+** within the document. FTS5 then queries the index for each
+** synonym individually. For example, faced with the query:
**
** <codeblock>
** ... MATCH 'first place'</codeblock>
@@ -12620,7 +12639,7 @@ struct Fts5ExtensionApi {
** "place".
**
** This way, even if the tokenizer does not provide synonyms
-** when tokenizing query text (it should not - to do would be
+** when tokenizing query text (it should not - to do so would be
** inefficient), it doesn't matter if the user queries for
** 'first + place' or '1st + place', as there are entries in the
** FTS index corresponding to both forms of the first token.
@@ -14555,6 +14574,7 @@ SQLITE_PRIVATE i64 sqlite3BtreeOffset(BtCursor*);
SQLITE_PRIVATE int sqlite3BtreePayload(BtCursor*, u32 offset, u32 amt, void*);
SQLITE_PRIVATE const void *sqlite3BtreePayloadFetch(BtCursor*, u32 *pAmt);
SQLITE_PRIVATE u32 sqlite3BtreePayloadSize(BtCursor*);
+SQLITE_PRIVATE sqlite3_int64 sqlite3BtreeMaxRecordSize(BtCursor*);
SQLITE_PRIVATE char *sqlite3BtreeIntegrityCheck(Btree*, int *aRoot, int nRoot, int, int*);
SQLITE_PRIVATE struct Pager *sqlite3BtreePager(Btree*);
@@ -14794,12 +14814,11 @@ typedef struct VdbeOpList VdbeOpList;
#endif
/*
-** The following macro converts a relative address in the p2 field
-** of a VdbeOp structure into a negative number so that
-** sqlite3VdbeAddOpList() knows that the address is relative. Calling
-** the macro again restores the address.
+** The following macro converts a label returned by sqlite3VdbeMakeLabel()
+** into an index into the Parse.aLabel[] array that contains the resolved
+** address of that label.
*/
-#define ADDR(X) (-1-(X))
+#define ADDR(X) (~(X))
/*
** The makefile scans the vdbe.c source file and creates the "opcodes.h"
@@ -15075,6 +15094,12 @@ SQLITE_PRIVATE int sqlite3VdbeExplainParent(Parse*);
# define ExplainQueryPlan(P)
# define ExplainQueryPlanPop(P)
# define ExplainQueryPlanParent(P) 0
+# define sqlite3ExplainBreakpoint(A,B) /*no-op*/
+#endif
+#if defined(SQLITE_DEBUG) && !defined(SQLITE_OMIT_EXPLAIN)
+SQLITE_PRIVATE void sqlite3ExplainBreakpoint(const char*,const char*);
+#else
+# define sqlite3ExplainBreakpoint(A,B) /*no-op*/
#endif
SQLITE_PRIVATE void sqlite3VdbeAddParseSchemaOp(Vdbe*,int,char*);
SQLITE_PRIVATE void sqlite3VdbeChangeOpcode(Vdbe*, u32 addr, u8);
@@ -15090,7 +15115,7 @@ SQLITE_PRIVATE void sqlite3VdbeAppendP4(Vdbe*, void *pP4, int p4type);
SQLITE_PRIVATE void sqlite3VdbeSetP4KeyInfo(Parse*, Index*);
SQLITE_PRIVATE void sqlite3VdbeUsesBtree(Vdbe*, int);
SQLITE_PRIVATE VdbeOp *sqlite3VdbeGetOp(Vdbe*, int);
-SQLITE_PRIVATE int sqlite3VdbeMakeLabel(Vdbe*);
+SQLITE_PRIVATE int sqlite3VdbeMakeLabel(Parse*);
SQLITE_PRIVATE void sqlite3VdbeRunOnlyOnce(Vdbe*);
SQLITE_PRIVATE void sqlite3VdbeReusable(Vdbe*);
SQLITE_PRIVATE void sqlite3VdbeDelete(Vdbe*);
@@ -15111,6 +15136,10 @@ SQLITE_PRIVATE void sqlite3VdbeCountChanges(Vdbe*);
SQLITE_PRIVATE sqlite3 *sqlite3VdbeDb(Vdbe*);
SQLITE_PRIVATE u8 sqlite3VdbePrepareFlags(Vdbe*);
SQLITE_PRIVATE void sqlite3VdbeSetSql(Vdbe*, const char *z, int n, u8);
+#ifdef SQLITE_ENABLE_NORMALIZE
+SQLITE_PRIVATE void sqlite3VdbeAddDblquoteStr(sqlite3*,Vdbe*,const char*);
+SQLITE_PRIVATE int sqlite3VdbeUsesDoubleQuotedString(Vdbe*,const char*);
+#endif
SQLITE_PRIVATE void sqlite3VdbeSwap(Vdbe*,Vdbe*);
SQLITE_PRIVATE VdbeOp *sqlite3VdbeTakeOpArray(Vdbe*, int*, int*);
SQLITE_PRIVATE sqlite3_value *sqlite3VdbeGetBoundValue(Vdbe*, int, u8);
@@ -16236,10 +16265,13 @@ SQLITE_PRIVATE void sqlite3CryptFunc(sqlite3_context*,int,sqlite3_value**);
/* This is an extra SQLITE_TRACE macro that indicates "legacy" tracing
** in the style of sqlite3_trace()
*/
-#define SQLITE_TRACE_LEGACY 0x80
+#define SQLITE_TRACE_LEGACY 0x40 /* Use the legacy xTrace */
+#define SQLITE_TRACE_XPROFILE 0x80 /* Use the legacy xProfile */
#else
-#define SQLITE_TRACE_LEGACY 0
+#define SQLITE_TRACE_LEGACY 0
+#define SQLITE_TRACE_XPROFILE 0
#endif /* SQLITE_OMIT_DEPRECATED */
+#define SQLITE_TRACE_NONLEGACY_MASK 0x0f /* Normal flags */
/*
@@ -16298,8 +16330,10 @@ struct sqlite3 {
void **aExtension; /* Array of shared library handles */
int (*xTrace)(u32,void*,void*,void*); /* Trace function */
void *pTraceArg; /* Argument to the trace function */
+#ifndef SQLITE_OMIT_DEPRECATED
void (*xProfile)(void*,const char*,u64); /* Profiling function */
void *pProfileArg; /* Argument to profile function */
+#endif
void *pCommitArg; /* Argument to xCommitCallback() */
int (*xCommitCallback)(void*); /* Invoked at every commit. */
void *pRollbackArg; /* Argument to xRollbackCallback() */
@@ -16430,6 +16464,7 @@ struct sqlite3 {
#define SQLITE_VdbeTrace HI(0x0004) /* True to trace VDBE execution */
#define SQLITE_VdbeAddopTrace HI(0x0008) /* Trace sqlite3VdbeAddOp() calls */
#define SQLITE_VdbeEQP HI(0x0010) /* Debug EXPLAIN QUERY PLAN */
+#define SQLITE_ParserTrace HI(0x0020) /* PRAGMA parser_trace=ON */
#endif
/*
@@ -16832,9 +16867,6 @@ struct VTable {
struct Table {
char *zName; /* Name of the table or view */
Column *aCol; /* Information about each column */
-#ifdef SQLITE_ENABLE_NORMALIZE
- Hash *pColHash; /* All columns indexed by name */
-#endif
Index *pIndex; /* List of SQL indexes on this table. */
Select *pSelect; /* NULL for tables. Points to definition if a view. */
FKey *pFKey; /* Linked list of all foreign keys in this table */
@@ -17121,7 +17153,7 @@ struct Index {
u16 nKeyCol; /* Number of columns forming the key */
u16 nColumn; /* Number of columns stored in the index */
u8 onError; /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */
- unsigned idxType:2; /* 1==UNIQUE, 2==PRIMARY KEY, 0==CREATE INDEX */
+ unsigned idxType:2; /* 0:Normal 1:UNIQUE, 2:PRIMARY KEY, 3:IPK */
unsigned bUnordered:1; /* Use this index for == or IN queries only */
unsigned uniqNotNull:1; /* True if UNIQUE and NOT NULL for all columns */
unsigned isResized:1; /* True if resizeIndexObject() has been called */
@@ -17146,6 +17178,7 @@ struct Index {
#define SQLITE_IDXTYPE_APPDEF 0 /* Created using CREATE INDEX */
#define SQLITE_IDXTYPE_UNIQUE 1 /* Implements a UNIQUE constraint */
#define SQLITE_IDXTYPE_PRIMARYKEY 2 /* Is the PRIMARY KEY for the table */
+#define SQLITE_IDXTYPE_IPK 3 /* INTEGER PRIMARY KEY index */
/* Return true if index X is a PRIMARY KEY index */
#define IsPrimaryKeyIndex(X) ((X)->idxType==SQLITE_IDXTYPE_PRIMARYKEY)
@@ -17363,6 +17396,10 @@ struct Expr {
Table *pTab; /* TK_COLUMN: Table containing column. Can be NULL
** for a column of an index on an expression */
Window *pWin; /* TK_FUNCTION: Window definition for the func */
+ struct { /* TK_IN, TK_SELECT, and TK_EXISTS */
+ int iAddr; /* Subroutine entry address */
+ int regReturn; /* Register used to hold return address */
+ } sub;
} y;
};
@@ -17394,6 +17431,8 @@ struct Expr {
#define EP_Alias 0x400000 /* Is an alias for a result set column */
#define EP_Leaf 0x800000 /* Expr.pLeft, .pRight, .u.pSelect all NULL */
#define EP_WinFunc 0x1000000 /* TK_FUNCTION with Expr.y.pWin set */
+#define EP_Subrtn 0x2000000 /* Uses Expr.y.sub. TK_IN, _SELECT, or _EXISTS */
+#define EP_Quoted 0x4000000 /* TK_ID was originally quoted */
/*
** The EP_Propagate mask is a set of properties that automatically propagate
@@ -17943,11 +17982,11 @@ struct Parse {
int nErr; /* Number of errors seen */
int nTab; /* Number of previously allocated VDBE cursors */
int nMem; /* Number of memory cells used so far */
- int nOpAlloc; /* Number of slots allocated for Vdbe.aOp[] */
int szOpAlloc; /* Bytes of memory space allocated for Vdbe.aOp[] */
int iSelfTab; /* Table associated with an index on expr, or negative
** of the base register during check-constraint eval */
- int nLabel; /* Number of labels used */
+ int nLabel; /* The *negative* of the number of labels used */
+ int nLabelAlloc; /* Number of slots in aLabel */
int *aLabel; /* Space to hold the labels */
ExprList *pConstExpr;/* Constant expressions */
Token constraintName;/* Name of the constraint currently being parsed */
@@ -18007,7 +18046,9 @@ struct Parse {
Vdbe *pReprepare; /* VM being reprepared (sqlite3Reprepare()) */
const char *zTail; /* All SQL text past the last semicolon parsed */
Table *pNewTable; /* A table being constructed by CREATE TABLE */
- Index *pNewIndex; /* An index being constructed by CREATE INDEX */
+ Index *pNewIndex; /* An index being constructed by CREATE INDEX.
+ ** Also used to hold redundant UNIQUE constraints
+ ** during a RENAME COLUMN */
Trigger *pNewTrigger; /* Trigger under construct by a CREATE TRIGGER */
const char *zAuthContext; /* The 6th parameter to db->xAuth callbacks */
#ifndef SQLITE_OMIT_VIRTUALTABLE
@@ -18235,6 +18276,7 @@ typedef struct {
int iDb; /* 0 for main database. 1 for TEMP, 2.. for ATTACHed */
int rc; /* Result code stored here */
u32 mInitFlags; /* Flags controlling error messages */
+ u32 nInitRow; /* Number of rows processed */
} InitData;
/*
@@ -18295,6 +18337,9 @@ struct Sqlite3Config {
void (*xVdbeBranch)(void*,unsigned iSrcLine,u8 eThis,u8 eMx); /* Callback */
void *pVdbeBranchArg; /* 1st argument */
#endif
+#ifdef SQLITE_ENABLE_DESERIALIZE
+ sqlite3_int64 mxMemdbSize; /* Default max memdb size */
+#endif
#ifndef SQLITE_UNTESTABLE
int (*xTestCallback)(int); /* Invoked by sqlite3FaultSim() */
#endif
@@ -18683,6 +18728,7 @@ SQLITE_PRIVATE void sqlite3TreeViewWinFunc(TreeView*, const Window*, u8);
SQLITE_PRIVATE void sqlite3SetString(char **, sqlite3*, const char*);
SQLITE_PRIVATE void sqlite3ErrorMsg(Parse*, const char*, ...);
SQLITE_PRIVATE void sqlite3Dequote(char*);
+SQLITE_PRIVATE void sqlite3DequoteExpr(Expr*);
SQLITE_PRIVATE void sqlite3TokenInit(Token*,char*);
SQLITE_PRIVATE int sqlite3KeywordCode(const unsigned char*, int);
SQLITE_PRIVATE int sqlite3RunParser(Parse*, const char*, char **);
@@ -18711,6 +18757,7 @@ SQLITE_PRIVATE void sqlite3ExprListSetName(Parse*,ExprList*,Token*,int);
SQLITE_PRIVATE void sqlite3ExprListSetSpan(Parse*,ExprList*,const char*,const char*);
SQLITE_PRIVATE void sqlite3ExprListDelete(sqlite3*, ExprList*);
SQLITE_PRIVATE u32 sqlite3ExprListFlags(const ExprList*);
+SQLITE_PRIVATE int sqlite3IndexHasDuplicateRootPage(Index*);
SQLITE_PRIVATE int sqlite3Init(sqlite3*, char**);
SQLITE_PRIVATE int sqlite3InitCallback(void*, int, char**, char**);
SQLITE_PRIVATE int sqlite3InitOne(sqlite3*, int, char**, u32);
@@ -18744,6 +18791,11 @@ SQLITE_PRIVATE void sqlite3AddCollateType(Parse*, Token*);
SQLITE_PRIVATE void sqlite3EndTable(Parse*,Token*,Token*,u8,Select*);
SQLITE_PRIVATE int sqlite3ParseUri(const char*,const char*,unsigned int*,
sqlite3_vfs**,char**,char **);
+#ifdef SQLITE_HAS_CODEC
+SQLITE_PRIVATE int sqlite3CodecQueryParameters(sqlite3*,const char*,const char*);
+#else
+# define sqlite3CodecQueryParameters(A,B,C) 0
+#endif
SQLITE_PRIVATE Btree *sqlite3DbNameToBtree(sqlite3*,const char*);
#ifdef SQLITE_UNTESTABLE
@@ -18796,8 +18848,8 @@ SQLITE_PRIVATE void sqlite3Insert(Parse*, SrcList*, Select*, IdList*, int, Upser
SQLITE_PRIVATE void *sqlite3ArrayAllocate(sqlite3*,void*,int,int*,int*);
SQLITE_PRIVATE IdList *sqlite3IdListAppend(Parse*, IdList*, Token*);
SQLITE_PRIVATE int sqlite3IdListIndex(IdList*,const char*);
-SQLITE_PRIVATE SrcList *sqlite3SrcListEnlarge(sqlite3*, SrcList*, int, int);
-SQLITE_PRIVATE SrcList *sqlite3SrcListAppend(sqlite3*, SrcList*, Token*, Token*);
+SQLITE_PRIVATE SrcList *sqlite3SrcListEnlarge(Parse*, SrcList*, int, int);
+SQLITE_PRIVATE SrcList *sqlite3SrcListAppend(Parse*, SrcList*, Token*, Token*);
SQLITE_PRIVATE SrcList *sqlite3SrcListAppendFromTerm(Parse*, SrcList*, Token*, Token*,
Token*, Select*, Expr*, IdList*);
SQLITE_PRIVATE void sqlite3SrcListIndexedBy(Parse *, SrcList *, Token *);
@@ -18864,8 +18916,8 @@ SQLITE_PRIVATE Table *sqlite3LocateTableItem(Parse*,u32 flags,struct SrcList_ite
SQLITE_PRIVATE Index *sqlite3FindIndex(sqlite3*,const char*, const char*);
SQLITE_PRIVATE void sqlite3UnlinkAndDeleteTable(sqlite3*,int,const char*);
SQLITE_PRIVATE void sqlite3UnlinkAndDeleteIndex(sqlite3*,int,const char*);
-SQLITE_PRIVATE void sqlite3Vacuum(Parse*,Token*);
-SQLITE_PRIVATE int sqlite3RunVacuum(char**, sqlite3*, int);
+SQLITE_PRIVATE void sqlite3Vacuum(Parse*,Token*,Expr*);
+SQLITE_PRIVATE int sqlite3RunVacuum(char**, sqlite3*, int, sqlite3_value*);
SQLITE_PRIVATE char *sqlite3NameFromToken(sqlite3*, Token*);
SQLITE_PRIVATE int sqlite3ExprCompare(Parse*,Expr*, Expr*, int);
SQLITE_PRIVATE int sqlite3ExprCompareSkip(Expr*, Expr*, int);
@@ -18903,9 +18955,6 @@ SQLITE_PRIVATE int sqlite3ExprIsInteger(Expr*, int*);
SQLITE_PRIVATE int sqlite3ExprCanBeNull(const Expr*);
SQLITE_PRIVATE int sqlite3ExprNeedsNoAffinityChange(const Expr*, char);
SQLITE_PRIVATE int sqlite3IsRowid(const char*);
-#ifdef SQLITE_ENABLE_NORMALIZE
-SQLITE_PRIVATE int sqlite3IsRowidN(const char*, int);
-#endif
SQLITE_PRIVATE void sqlite3GenerateRowDelete(
Parse*,Table*,Trigger*,int,int,int,i16,u8,u8,u8,int);
SQLITE_PRIVATE void sqlite3GenerateRowIndexDelete(Parse*, Table*, int, int, int*, int);
@@ -18932,9 +18981,7 @@ SQLITE_PRIVATE ExprList *sqlite3ExprListDup(sqlite3*,ExprList*,int);
SQLITE_PRIVATE SrcList *sqlite3SrcListDup(sqlite3*,SrcList*,int);
SQLITE_PRIVATE IdList *sqlite3IdListDup(sqlite3*,IdList*);
SQLITE_PRIVATE Select *sqlite3SelectDup(sqlite3*,Select*,int);
-#ifdef SQLITE_ENABLE_NORMALIZE
-SQLITE_PRIVATE FuncDef *sqlite3FunctionSearchN(int,const char*,int);
-#endif
+SQLITE_PRIVATE FuncDef *sqlite3FunctionSearch(int,const char*);
SQLITE_PRIVATE void sqlite3InsertBuiltinFuncs(FuncDef*,int);
SQLITE_PRIVATE FuncDef *sqlite3FindFunction(sqlite3*,const char*,int,u8,u8);
SQLITE_PRIVATE void sqlite3RegisterBuiltinFunctions(void);
@@ -19139,19 +19186,17 @@ SQLITE_PRIVATE void sqlite3AlterFunctions(void);
SQLITE_PRIVATE void sqlite3AlterRenameTable(Parse*, SrcList*, Token*);
SQLITE_PRIVATE void sqlite3AlterRenameColumn(Parse*, SrcList*, Token*, Token*);
SQLITE_PRIVATE int sqlite3GetToken(const unsigned char *, int *);
-#ifdef SQLITE_ENABLE_NORMALIZE
-SQLITE_PRIVATE int sqlite3GetTokenNormalized(const unsigned char *, int *, int *);
-#endif
SQLITE_PRIVATE void sqlite3NestedParse(Parse*, const char*, ...);
SQLITE_PRIVATE void sqlite3ExpirePreparedStatements(sqlite3*, int);
-SQLITE_PRIVATE int sqlite3CodeSubselect(Parse*, Expr *, int, int);
+SQLITE_PRIVATE void sqlite3CodeRhsOfIN(Parse*, Expr*, int, int);
+SQLITE_PRIVATE int sqlite3CodeSubselect(Parse*, Expr*);
SQLITE_PRIVATE void sqlite3SelectPrep(Parse*, Select*, NameContext*);
SQLITE_PRIVATE void sqlite3SelectWrongNumTermsError(Parse *pParse, Select *p);
SQLITE_PRIVATE int sqlite3MatchSpanName(const char*, const char*, const char*, const char*);
SQLITE_PRIVATE int sqlite3ResolveExprNames(NameContext*, Expr*);
SQLITE_PRIVATE int sqlite3ResolveExprListNames(NameContext*, ExprList*);
SQLITE_PRIVATE void sqlite3ResolveSelectNames(Parse*, Select*, NameContext*);
-SQLITE_PRIVATE void sqlite3ResolveSelfReference(Parse*,Table*,int,Expr*,ExprList*);
+SQLITE_PRIVATE int sqlite3ResolveSelfReference(Parse*,Table*,int,Expr*,ExprList*);
SQLITE_PRIVATE int sqlite3ResolveOrderGroupBy(Parse*, Select*, ExprList*, const char*);
SQLITE_PRIVATE void sqlite3ColumnDefault(Vdbe *, Table *, int, int);
SQLITE_PRIVATE void sqlite3AlterFinishAddColumn(Parse *, Token *);
@@ -19300,7 +19345,7 @@ SQLITE_PRIVATE int sqlite3VdbeParameterIndex(Vdbe*, const char*, int);
SQLITE_PRIVATE int sqlite3TransferBindings(sqlite3_stmt *, sqlite3_stmt *);
SQLITE_PRIVATE void sqlite3ParserReset(Parse*);
#ifdef SQLITE_ENABLE_NORMALIZE
-SQLITE_PRIVATE void sqlite3Normalize(Vdbe*, const char*, int, u8);
+SQLITE_PRIVATE char *sqlite3Normalize(Vdbe*, const char*);
#endif
SQLITE_PRIVATE int sqlite3Reprepare(Vdbe*);
SQLITE_PRIVATE void sqlite3ExprListCheckLength(Parse*, ExprList*, const char*);
@@ -19396,7 +19441,7 @@ SQLITE_PRIVATE void sqlite3EndBenignMalloc(void);
#define IN_INDEX_NOOP_OK 0x0001 /* OK to return IN_INDEX_NOOP */
#define IN_INDEX_MEMBERSHIP 0x0002 /* IN operator used for membership test */
#define IN_INDEX_LOOP 0x0004 /* IN operator used as a loop */
-SQLITE_PRIVATE int sqlite3FindInIndex(Parse *, Expr *, u32, int*, int*);
+SQLITE_PRIVATE int sqlite3FindInIndex(Parse *, Expr *, u32, int*, int*, int*);
SQLITE_PRIVATE int sqlite3JournalOpen(sqlite3_vfs *, const char *, sqlite3_file *, int, int);
SQLITE_PRIVATE int sqlite3JournalSize(sqlite3_vfs *);
@@ -19712,6 +19757,13 @@ SQLITE_PRIVATE const unsigned char sqlite3CtypeMap[256] = {
#endif
+/* The default maximum size of an in-memory database created using
+** sqlite3_deserialize()
+*/
+#ifndef SQLITE_MEMDB_DEFAULT_MAXSIZE
+# define SQLITE_MEMDB_DEFAULT_MAXSIZE 1073741824
+#endif
+
/*
** The following singleton contains the global configuration for
** the SQLite library.
@@ -19759,13 +19811,16 @@ SQLITE_PRIVATE SQLITE_WSD struct Sqlite3Config sqlite3Config = {
0, /* xVdbeBranch */
0, /* pVbeBranchArg */
#endif
+#ifdef SQLITE_ENABLE_DESERIALIZE
+ SQLITE_MEMDB_DEFAULT_MAXSIZE, /* mxMemdbSize */
+#endif
#ifndef SQLITE_UNTESTABLE
0, /* xTestCallback */
#endif
0, /* bLocaltimeFault */
0, /* bInternalFunctions */
0x7ffffffe, /* iOnceResetThreshold */
- SQLITE_DEFAULT_SORTERREF_SIZE /* szSorterRef */
+ SQLITE_DEFAULT_SORTERREF_SIZE, /* szSorterRef */
};
/*
@@ -20184,6 +20239,9 @@ struct sqlite3_context {
*/
typedef unsigned bft; /* Bit Field Type */
+/* The ScanStatus object holds a single value for the
+** sqlite3_stmt_scanstatus() interface.
+*/
typedef struct ScanStatus ScanStatus;
struct ScanStatus {
int addrExplain; /* OP_Explain for loop */
@@ -20194,6 +20252,19 @@ struct ScanStatus {
char *zName; /* Name of table or index */
};
+/* The DblquoteStr object holds the text of a double-quoted
+** string for a prepared statement. A linked list of these objects
+** is constructed during statement parsing and is held on Vdbe.pDblStr.
+** When computing a normalized SQL statement for an SQL statement, that
+** list is consulted for each double-quoted identifier to see if the
+** identifier should really be a string literal.
+*/
+typedef struct DblquoteStr DblquoteStr;
+struct DblquoteStr {
+ DblquoteStr *pNextStr; /* Next string literal in the list */
+ char z[8]; /* Dequoted value for the string */
+};
+
/*
** An instance of the virtual machine. This structure contains the complete
** state of the virtual machine.
@@ -20213,28 +20284,29 @@ struct Vdbe {
int pc; /* The program counter */
int rc; /* Value to return */
int nChange; /* Number of db changes made since last reset */
- int iStatement; /* Statement number (or 0 if has not opened stmt) */
+ int iStatement; /* Statement number (or 0 if has no opened stmt) */
i64 iCurrentTime; /* Value of julianday('now') for this statement */
i64 nFkConstraint; /* Number of imm. FK constraints this VM */
i64 nStmtDefCons; /* Number of def. constraints when stmt started */
i64 nStmtDefImmCons; /* Number of def. imm constraints when stmt started */
+ Mem *aMem; /* The memory locations */
+ Mem **apArg; /* Arguments to currently executing user function */
+ VdbeCursor **apCsr; /* One element of this array for each open cursor */
+ Mem *aVar; /* Values for the OP_Variable opcode. */
/* When allocating a new Vdbe object, all of the fields below should be
** initialized to zero or NULL */
Op *aOp; /* Space to hold the virtual machine's program */
- Mem *aMem; /* The memory locations */
- Mem **apArg; /* Arguments to currently executing user function */
+ int nOp; /* Number of instructions in the program */
+ int nOpAlloc; /* Slots allocated for aOp[] */
Mem *aColName; /* Column names to return */
Mem *pResultSet; /* Pointer to an array of results */
char *zErrMsg; /* Error message written here */
- VdbeCursor **apCsr; /* One element of this array for each open cursor */
- Mem *aVar; /* Values for the OP_Variable opcode. */
VList *pVList; /* Name of variables */
#ifndef SQLITE_OMIT_TRACE
i64 startTime; /* Time when query started - used for profiling */
#endif
- int nOp; /* Number of instructions in the program */
#ifdef SQLITE_DEBUG
int rcApp; /* errcode set by sqlite3_result_error_code() */
u32 nWrite; /* Number of write operations that have occurred */
@@ -20257,6 +20329,7 @@ struct Vdbe {
char *zSql; /* Text of the SQL statement that generated this */
#ifdef SQLITE_ENABLE_NORMALIZE
char *zNormSql; /* Normalization of the associated SQL statement */
+ DblquoteStr *pDblStr; /* List of double-quoted string literals */
#endif
void *pFree; /* Free this when deleting the vdbe */
VdbeFrame *pFrame; /* Parent frame */
@@ -27274,6 +27347,27 @@ static char *getTextArg(PrintfArguments *p){
return (char*)sqlite3_value_text(p->apArg[p->nUsed++]);
}
+/*
+** Allocate memory for a temporary buffer needed for printf rendering.
+**
+** If the requested size of the temp buffer is larger than the size
+** of the output buffer in pAccum, then cause an SQLITE_TOOBIG error.
+** Do the size check before the memory allocation to prevent rogue
+** SQL from requesting large allocations using the precision or width
+** field of the printf() function.
+*/
+static char *printfTempBuf(sqlite3_str *pAccum, sqlite3_int64 n){
+ char *z;
+ if( n>pAccum->nAlloc && n>pAccum->mxAlloc ){
+ setStrAccumError(pAccum, SQLITE_TOOBIG);
+ return 0;
+ }
+ z = sqlite3DbMallocRaw(pAccum->db, n);
+ if( z==0 ){
+ setStrAccumError(pAccum, SQLITE_NOMEM);
+ }
+ return z;
+}
/*
** On machines with a small stack size, you can redefine the
@@ -27356,6 +27450,9 @@ SQLITE_API void sqlite3_str_vappendf(
flag_leftjustify = flag_prefix = cThousand =
flag_alternateform = flag_altform2 = flag_zeropad = 0;
done = 0;
+ width = 0;
+ flag_long = 0;
+ precision = -1;
do{
switch( c ){
case '-': flag_leftjustify = 1; break;
@@ -27366,80 +27463,93 @@ SQLITE_API void sqlite3_str_vappendf(
case '0': flag_zeropad = 1; break;
case ',': cThousand = ','; break;
default: done = 1; break;
- }
- }while( !done && (c=(*++fmt))!=0 );
- /* Get the field width */
- if( c=='*' ){
- if( bArgList ){
- width = (int)getIntArg(pArgList);
- }else{
- width = va_arg(ap,int);
- }
- if( width<0 ){
- flag_leftjustify = 1;
- width = width >= -2147483647 ? -width : 0;
- }
- c = *++fmt;
- }else{
- unsigned wx = 0;
- while( c>='0' && c<='9' ){
- wx = wx*10 + c - '0';
- c = *++fmt;
- }
- testcase( wx>0x7fffffff );
- width = wx & 0x7fffffff;
- }
- assert( width>=0 );
+ case 'l': {
+ flag_long = 1;
+ c = *++fmt;
+ if( c=='l' ){
+ c = *++fmt;
+ flag_long = 2;
+ }
+ done = 1;
+ break;
+ }
+ case '1': case '2': case '3': case '4': case '5':
+ case '6': case '7': case '8': case '9': {
+ unsigned wx = c - '0';
+ while( (c = *++fmt)>='0' && c<='9' ){
+ wx = wx*10 + c - '0';
+ }
+ testcase( wx>0x7fffffff );
+ width = wx & 0x7fffffff;
#ifdef SQLITE_PRINTF_PRECISION_LIMIT
- if( width>SQLITE_PRINTF_PRECISION_LIMIT ){
- width = SQLITE_PRINTF_PRECISION_LIMIT;
- }
+ if( width>SQLITE_PRINTF_PRECISION_LIMIT ){
+ width = SQLITE_PRINTF_PRECISION_LIMIT;
+ }
#endif
-
- /* Get the precision */
- if( c=='.' ){
- c = *++fmt;
- if( c=='*' ){
- if( bArgList ){
- precision = (int)getIntArg(pArgList);
- }else{
- precision = va_arg(ap,int);
+ if( c!='.' && c!='l' ){
+ done = 1;
+ }else{
+ fmt--;
+ }
+ break;
}
- c = *++fmt;
- if( precision<0 ){
- precision = precision >= -2147483647 ? -precision : -1;
+ case '*': {
+ if( bArgList ){
+ width = (int)getIntArg(pArgList);
+ }else{
+ width = va_arg(ap,int);
+ }
+ if( width<0 ){
+ flag_leftjustify = 1;
+ width = width >= -2147483647 ? -width : 0;
+ }
+#ifdef SQLITE_PRINTF_PRECISION_LIMIT
+ if( width>SQLITE_PRINTF_PRECISION_LIMIT ){
+ width = SQLITE_PRINTF_PRECISION_LIMIT;
+ }
+#endif
+ if( (c = fmt[1])!='.' && c!='l' ){
+ c = *++fmt;
+ done = 1;
+ }
+ break;
}
- }else{
- unsigned px = 0;
- while( c>='0' && c<='9' ){
- px = px*10 + c - '0';
+ case '.': {
c = *++fmt;
- }
- testcase( px>0x7fffffff );
- precision = px & 0x7fffffff;
- }
- }else{
- precision = -1;
- }
- assert( precision>=(-1) );
+ if( c=='*' ){
+ if( bArgList ){
+ precision = (int)getIntArg(pArgList);
+ }else{
+ precision = va_arg(ap,int);
+ }
+ if( precision<0 ){
+ precision = precision >= -2147483647 ? -precision : -1;
+ }
+ c = *++fmt;
+ }else{
+ unsigned px = 0;
+ while( c>='0' && c<='9' ){
+ px = px*10 + c - '0';
+ c = *++fmt;
+ }
+ testcase( px>0x7fffffff );
+ precision = px & 0x7fffffff;
+ }
#ifdef SQLITE_PRINTF_PRECISION_LIMIT
- if( precision>SQLITE_PRINTF_PRECISION_LIMIT ){
- precision = SQLITE_PRINTF_PRECISION_LIMIT;
- }
+ if( precision>SQLITE_PRINTF_PRECISION_LIMIT ){
+ precision = SQLITE_PRINTF_PRECISION_LIMIT;
+ }
#endif
-
-
- /* Get the conversion type modifier */
- if( c=='l' ){
- flag_long = 1;
- c = *++fmt;
- if( c=='l' ){
- flag_long = 2;
- c = *++fmt;
+ if( c=='l' ){
+ --fmt;
+ }else{
+ done = 1;
+ }
+ break;
+ }
}
- }else{
- flag_long = 0;
- }
+ }while( !done && (c=(*++fmt))!=0 );
+
/* Fetch the info entry for the field */
infop = &fmtinfo[0];
xtype = etINVALID;
@@ -27524,12 +27634,11 @@ SQLITE_API void sqlite3_str_vappendf(
nOut = etBUFSIZE;
zOut = buf;
}else{
- u64 n = (u64)precision + 10 + precision/3;
- zOut = zExtra = sqlite3Malloc( n );
- if( zOut==0 ){
- setStrAccumError(pAccum, SQLITE_NOMEM);
- return;
- }
+ u64 n;
+ n = (u64)precision + 10;
+ if( cThousand ) n += precision/3;
+ zOut = zExtra = printfTempBuf(pAccum, n);
+ if( zOut==0 ) return;
nOut = (int)n;
}
bufpt = &zOut[nOut-1];
@@ -27648,12 +27757,12 @@ SQLITE_API void sqlite3_str_vappendf(
}else{
e2 = exp;
}
- if( MAX(e2,0)+(i64)precision+(i64)width > etBUFSIZE - 15 ){
- bufpt = zExtra
- = sqlite3Malloc( MAX(e2,0)+(i64)precision+(i64)width+15 );
- if( bufpt==0 ){
- setStrAccumError(pAccum, SQLITE_NOMEM);
- return;
+ {
+ i64 szBufNeeded; /* Size of a temporary buffer needed */
+ szBufNeeded = MAX(e2,0)+(i64)precision+(i64)width+15;
+ if( szBufNeeded > etBUFSIZE ){
+ bufpt = zExtra = printfTempBuf(pAccum, szBufNeeded);
+ if( bufpt==0 ) return;
}
}
zOut = bufpt;
@@ -27877,11 +27986,8 @@ SQLITE_API void sqlite3_str_vappendf(
needQuote = !isnull && xtype==etSQLESCAPE2;
n += i + 3;
if( n>etBUFSIZE ){
- bufpt = zExtra = sqlite3Malloc( n );
- if( bufpt==0 ){
- setStrAccumError(pAccum, SQLITE_NOMEM);
- return;
- }
+ bufpt = zExtra = printfTempBuf(pAccum, n);
+ if( bufpt==0 ) return;
}else{
bufpt = buf;
}
@@ -28507,7 +28613,8 @@ SQLITE_PRIVATE void sqlite3TreeViewSrcList(TreeView *pView, const SrcList *pSrc)
sqlite3_str_appendf(&x, " %s", pItem->zName);
}
if( pItem->pTab ){
- sqlite3_str_appendf(&x, " tabname=%Q", pItem->pTab->zName);
+ sqlite3_str_appendf(&x, " tab=%Q nCol=%d ptr=%p",
+ pItem->pTab->zName, pItem->pTab->nCol, pItem->pTab);
}
if( pItem->zAlias ){
sqlite3_str_appendf(&x, " (AS %s)", pItem->zAlias);
@@ -30247,7 +30354,7 @@ SQLITE_PRIVATE void sqlite3ErrorMsg(Parse *pParse, const char *zFormat, ...){
** dequoted string, exclusive of the zero terminator, if dequoting does
** occur.
**
-** 2002-Feb-14: This routine is extended to remove MS-Access style
+** 2002-02-14: This routine is extended to remove MS-Access style
** brackets from around identifiers. For example: "[a-b-c]" becomes
** "a-b-c".
*/
@@ -30273,6 +30380,11 @@ SQLITE_PRIVATE void sqlite3Dequote(char *z){
}
z[j] = 0;
}
+SQLITE_PRIVATE void sqlite3DequoteExpr(Expr *p){
+ assert( sqlite3Isquote(p->u.zToken[0]) );
+ p->flags |= p->u.zToken[0]=='"' ? EP_Quoted|EP_DblQuoted : EP_Quoted;
+ sqlite3Dequote(p->u.zToken);
+}
/*
** Generate a Token object from a string
@@ -31700,20 +31812,6 @@ static unsigned int strHash(const char *z){
}
return h;
}
-#ifdef SQLITE_ENABLE_NORMALIZE
-static unsigned int strHashN(const char *z, int n){
- unsigned int h = 0;
- int i;
- for(i=0; i<n; i++){
- /* Knuth multiplicative hashing. (Sorting & Searching, p. 510).
- ** 0x9e3779b1 is 2654435761 which is the closest prime number to
- ** (2**32)*golden_ratio, where golden_ratio = (sqrt(5) - 1)/2. */
- h += sqlite3UpperToLower[z[i]];
- h *= 0x9e3779b1;
- }
- return h;
-}
-#endif /* SQLITE_ENABLE_NORMALIZE */
/* Link pNew element into the hash table pH. If pEntry!=0 then also
@@ -31825,40 +31923,6 @@ static HashElem *findElementWithHash(
}
return &nullElement;
}
-#ifdef SQLITE_ENABLE_NORMALIZE
-static HashElem *findElementWithHashN(
- const Hash *pH, /* The pH to be searched */
- const char *pKey, /* The key we are searching for */
- int nKey, /* Number of key bytes to use */
- unsigned int *pHash /* Write the hash value here */
-){
- HashElem *elem; /* Used to loop thru the element list */
- int count; /* Number of elements left to test */
- unsigned int h; /* The computed hash */
- static HashElem nullElement = { 0, 0, 0, 0 };
-
- if( pH->ht ){ /*OPTIMIZATION-IF-TRUE*/
- struct _ht *pEntry;
- h = strHashN(pKey, nKey) % pH->htsize;
- pEntry = &pH->ht[h];
- elem = pEntry->chain;
- count = pEntry->count;
- }else{
- h = 0;
- elem = pH->first;
- count = pH->count;
- }
- if( pHash ) *pHash = h;
- while( count-- ){
- assert( elem!=0 );
- if( sqlite3StrNICmp(elem->pKey,pKey,nKey)==0 ){
- return elem;
- }
- elem = elem->next;
- }
- return &nullElement;
-}
-#endif /* SQLITE_ENABLE_NORMALIZE */
/* Remove a single entry from the hash table given a pointer to that
** element and a hash on the element's key.
@@ -31903,14 +31967,6 @@ SQLITE_PRIVATE void *sqlite3HashFind(const Hash *pH, const char *pKey){
assert( pKey!=0 );
return findElementWithHash(pH, pKey, 0)->data;
}
-#ifdef SQLITE_ENABLE_NORMALIZE
-SQLITE_PRIVATE void *sqlite3HashFindN(const Hash *pH, const char *pKey, int nKey){
- assert( pH!=0 );
- assert( pKey!=0 );
- assert( nKey>=0 );
- return findElementWithHashN(pH, pKey, nKey, 0)->data;
-}
-#endif /* SQLITE_ENABLE_NORMALIZE */
/* Insert an element into the hash table pH. The key is pKey
** and the data is "data".
@@ -46661,7 +46717,8 @@ typedef struct MemFile MemFile;
struct MemFile {
sqlite3_file base; /* IO methods */
sqlite3_int64 sz; /* Size of the file */
- sqlite3_int64 szMax; /* Space allocated to aData */
+ sqlite3_int64 szAlloc; /* Space allocated to aData */
+ sqlite3_int64 szMax; /* Maximum allowed size of the file */
unsigned char *aData; /* content of the file */
int nMmap; /* Number of memory mapped pages */
unsigned mFlags; /* Flags */
@@ -46787,10 +46844,15 @@ static int memdbEnlarge(MemFile *p, sqlite3_int64 newSz){
if( (p->mFlags & SQLITE_DESERIALIZE_RESIZEABLE)==0 || p->nMmap>0 ){
return SQLITE_FULL;
}
+ if( newSz>p->szMax ){
+ return SQLITE_FULL;
+ }
+ newSz *= 2;
+ if( newSz>p->szMax ) newSz = p->szMax;
pNew = sqlite3_realloc64(p->aData, newSz);
if( pNew==0 ) return SQLITE_NOMEM;
p->aData = pNew;
- p->szMax = newSz;
+ p->szAlloc = newSz;
return SQLITE_OK;
}
@@ -46804,10 +46866,11 @@ static int memdbWrite(
sqlite_int64 iOfst
){
MemFile *p = (MemFile *)pFile;
+ if( NEVER(p->mFlags & SQLITE_DESERIALIZE_READONLY) ) return SQLITE_READONLY;
if( iOfst+iAmt>p->sz ){
int rc;
- if( iOfst+iAmt>p->szMax
- && (rc = memdbEnlarge(p, (iOfst+iAmt)*2))!=SQLITE_OK
+ if( iOfst+iAmt>p->szAlloc
+ && (rc = memdbEnlarge(p, iOfst+iAmt))!=SQLITE_OK
){
return rc;
}
@@ -46853,6 +46916,11 @@ static int memdbFileSize(sqlite3_file *pFile, sqlite_int64 *pSize){
*/
static int memdbLock(sqlite3_file *pFile, int eLock){
MemFile *p = (MemFile *)pFile;
+ if( eLock>SQLITE_LOCK_SHARED
+ && (p->mFlags & SQLITE_DESERIALIZE_READONLY)!=0
+ ){
+ return SQLITE_READONLY;
+ }
p->eLock = eLock;
return SQLITE_OK;
}
@@ -46877,6 +46945,19 @@ static int memdbFileControl(sqlite3_file *pFile, int op, void *pArg){
*(char**)pArg = sqlite3_mprintf("memdb(%p,%lld)", p->aData, p->sz);
rc = SQLITE_OK;
}
+ if( op==SQLITE_FCNTL_SIZE_LIMIT ){
+ sqlite3_int64 iLimit = *(sqlite3_int64*)pArg;
+ if( iLimit<p->sz ){
+ if( iLimit<0 ){
+ iLimit = p->szMax;
+ }else{
+ iLimit = p->sz;
+ }
+ }
+ p->szMax = iLimit;
+ *(sqlite3_int64*)pArg = iLimit;
+ rc = SQLITE_OK;
+ }
return rc;
}
@@ -46907,8 +46988,12 @@ static int memdbFetch(
void **pp
){
MemFile *p = (MemFile *)pFile;
- p->nMmap++;
- *pp = (void*)(p->aData + iOfst);
+ if( iOfst+iAmt>p->sz ){
+ *pp = 0;
+ }else{
+ p->nMmap++;
+ *pp = (void*)(p->aData + iOfst);
+ }
return SQLITE_OK;
}
@@ -46938,6 +47023,7 @@ static int memdbOpen(
assert( pOutFlags!=0 ); /* True because flags==SQLITE_OPEN_MAIN_DB */
*pOutFlags = flags | SQLITE_OPEN_MEMORY;
p->base.pMethods = &memdb_io_methods;
+ p->szMax = sqlite3GlobalConfig.mxMemdbSize;
return SQLITE_OK;
}
@@ -47187,7 +47273,11 @@ SQLITE_API int sqlite3_deserialize(
}else{
p->aData = pData;
p->sz = szDb;
+ p->szAlloc = szBuf;
p->szMax = szBuf;
+ if( p->szMax<sqlite3GlobalConfig.mxMemdbSize ){
+ p->szMax = sqlite3GlobalConfig.mxMemdbSize;
+ }
p->mFlags = mFlags;
rc = SQLITE_OK;
}
@@ -48608,16 +48698,27 @@ typedef struct PGroup PGroup;
** structure. Unless SQLITE_PCACHE_SEPARATE_HEADER is defined, a buffer of
** PgHdr1.pCache->szPage bytes is allocated directly before this structure
** in memory.
+**
+** Note: Variables isBulkLocal and isAnchor were once type "u8". That works,
+** but causes a 2-byte gap in the structure for most architectures (since
+** pointers must be either 4 or 8-byte aligned). As this structure is located
+** in memory directly after the associated page data, if the database is
+** corrupt, code at the b-tree layer may overread the page buffer and
+** read part of this structure before the corruption is detected. This
+** can cause a valgrind error if the unitialized gap is accessed. Using u16
+** ensures there is no such gap, and therefore no bytes of unitialized memory
+** in the structure.
*/
struct PgHdr1 {
sqlite3_pcache_page page; /* Base class. Must be first. pBuf & pExtra */
unsigned int iKey; /* Key value (page number) */
- u8 isBulkLocal; /* This page from bulk local storage */
- u8 isAnchor; /* This is the PGroup.lru element */
+ u16 isBulkLocal; /* This page from bulk local storage */
+ u16 isAnchor; /* This is the PGroup.lru element */
PgHdr1 *pNext; /* Next in hash table chain */
PCache1 *pCache; /* Cache that currently owns this page */
PgHdr1 *pLruNext; /* Next in LRU list of unpinned pages */
PgHdr1 *pLruPrev; /* Previous in LRU list of unpinned pages */
+ /* NB: pLruPrev is only valid if pLruNext!=0 */
};
/*
@@ -48818,6 +48919,7 @@ static int pcache1InitBulk(PCache1 *pCache){
pX->isBulkLocal = 1;
pX->isAnchor = 0;
pX->pNext = pCache->pFree;
+ pX->pLruPrev = 0; /* Initializing this saves a valgrind error */
pCache->pFree = pX;
zBulk += pCache->szAlloc;
}while( --nBulk );
@@ -49090,7 +49192,8 @@ static PgHdr1 *pcache1PinPage(PgHdr1 *pPage){
pPage->pLruPrev->pLruNext = pPage->pLruNext;
pPage->pLruNext->pLruPrev = pPage->pLruPrev;
pPage->pLruNext = 0;
- pPage->pLruPrev = 0;
+ /* pPage->pLruPrev = 0;
+ ** No need to clear pLruPrev as it is never accessed if pLruNext is 0 */
assert( pPage->isAnchor==0 );
assert( pPage->pCache->pGroup->lru.isAnchor==1 );
pPage->pCache->nRecyclable--;
@@ -49427,8 +49530,9 @@ static SQLITE_NOINLINE PgHdr1 *pcache1FetchStage2(
pPage->iKey = iKey;
pPage->pNext = pCache->apHash[h];
pPage->pCache = pCache;
- pPage->pLruPrev = 0;
pPage->pLruNext = 0;
+ /* pPage->pLruPrev = 0;
+ ** No need to clear pLruPrev since it is not accessed when pLruNext==0 */
*(void **)pPage->page.pExtra = 0;
pCache->apHash[h] = pPage;
if( iKey>pCache->iMaxKey ){
@@ -49588,7 +49692,7 @@ static void pcache1Unpin(
/* It is an error to call this function if the page is already
** part of the PGroup LRU list.
*/
- assert( pPage->pLruPrev==0 && pPage->pLruNext==0 );
+ assert( pPage->pLruNext==0 );
assert( PAGE_IS_PINNED(pPage) );
if( reuseUnlikely || pGroup->nPurgeable>pGroup->nMaxPage ){
@@ -54279,7 +54383,10 @@ SQLITE_PRIVATE int sqlite3PagerMaxPageCount(Pager *pPager, int mxPage){
pPager->mxPgno = mxPage;
}
assert( pPager->eState!=PAGER_OPEN ); /* Called only by OP_MaxPgcnt */
- assert( pPager->mxPgno>=pPager->dbSize ); /* OP_MaxPgcnt enforces this */
+ /* assert( pPager->mxPgno>=pPager->dbSize ); */
+ /* OP_MaxPgcnt ensures that the parameter passed to this function is not
+ ** less than the total number of valid pages in the database. But this
+ ** may be less than Pager.dbSize, and so the assert() above is not valid */
return pPager->mxPgno;
}
@@ -62518,9 +62625,16 @@ struct CellInfo {
** found at self->pBt->mutex.
**
** skipNext meaning:
-** eState==SKIPNEXT && skipNext>0: Next sqlite3BtreeNext() is no-op.
-** eState==SKIPNEXT && skipNext<0: Next sqlite3BtreePrevious() is no-op.
-** eState==FAULT: Cursor fault with skipNext as error code.
+** The meaning of skipNext depends on the value of eState:
+**
+** eState Meaning of skipNext
+** VALID skipNext is meaningless and is ignored
+** INVALID skipNext is meaningless and is ignored
+** SKIPNEXT sqlite3BtreeNext() is a no-op if skipNext>0 and
+** sqlite3BtreePrevious() is no-op if skipNext<0.
+** REQUIRESEEK restoreCursorPosition() restores the cursor to
+** eState=SKIPNEXT if skipNext!=0
+** FAULT skipNext holds the cursor fault error code.
*/
struct BtCursor {
u8 eState; /* One of the CURSOR_XXX constants (see below) */
@@ -63828,11 +63942,12 @@ static int btreeMoveto(
UnpackedRecord *pIdxKey; /* Unpacked index key */
if( pKey ){
+ KeyInfo *pKeyInfo = pCur->pKeyInfo;
assert( nKey==(i64)(int)nKey );
- pIdxKey = sqlite3VdbeAllocUnpackedRecord(pCur->pKeyInfo);
+ pIdxKey = sqlite3VdbeAllocUnpackedRecord(pKeyInfo);
if( pIdxKey==0 ) return SQLITE_NOMEM_BKPT;
- sqlite3VdbeRecordUnpack(pCur->pKeyInfo, (int)nKey, pKey, pIdxKey);
- if( pIdxKey->nField==0 ){
+ sqlite3VdbeRecordUnpack(pKeyInfo, (int)nKey, pKey, pIdxKey);
+ if( pIdxKey->nField==0 || pIdxKey->nField>pKeyInfo->nAllField ){
rc = SQLITE_CORRUPT_BKPT;
goto moveto_done;
}
@@ -63868,7 +63983,7 @@ static int btreeRestoreCursorPosition(BtCursor *pCur){
sqlite3_free(pCur->pKey);
pCur->pKey = 0;
assert( pCur->eState==CURSOR_VALID || pCur->eState==CURSOR_INVALID );
- pCur->skipNext |= skipNext;
+ if( skipNext ) pCur->skipNext = skipNext;
if( pCur->skipNext && pCur->eState==CURSOR_VALID ){
pCur->eState = CURSOR_SKIPNEXT;
}
@@ -63938,7 +64053,6 @@ SQLITE_PRIVATE int sqlite3BtreeCursorRestore(BtCursor *pCur, int *pDifferentRow)
if( pCur->eState!=CURSOR_VALID ){
*pDifferentRow = 1;
}else{
- assert( pCur->skipNext==0 );
*pDifferentRow = 0;
}
return SQLITE_OK;
@@ -64389,7 +64503,7 @@ static u16 cellSize(MemPage *pPage, int iCell){
** 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, MemPage *pSrc, u8 *pCell, int *pRC){
+static void ptrmapPutOvflPtr(MemPage *pPage, MemPage *pSrc, u8 *pCell,int *pRC){
CellInfo info;
if( *pRC ) return;
assert( pCell!=0 );
@@ -64464,7 +64578,6 @@ static int defragmentPage(MemPage *pPage, int nMaxFrag){
if( iFree ){
int iFree2 = get2byte(&data[iFree]);
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];
u8 *pAddr;
@@ -66128,6 +66241,7 @@ static int lockBtree(BtShared *pBt){
){
goto page1_init_failed;
}
+ pBt->btsFlags |= BTS_PAGESIZE_FIXED;
assert( (pageSize & 7)==0 );
/* EVIDENCE-OF: R-59310-51205 The "reserved space" size in the 1-byte
** integer at offset 20 is the number of bytes of space at the end of
@@ -67444,6 +67558,7 @@ SQLITE_PRIVATE int sqlite3BtreeCloseCursor(BtCursor *pCur){
sqlite3_free(pCur->aOverflow);
sqlite3_free(pCur->pKey);
sqlite3BtreeLeave(pBtree);
+ pCur->pBtree = 0;
}
return SQLITE_OK;
}
@@ -67543,6 +67658,25 @@ SQLITE_PRIVATE u32 sqlite3BtreePayloadSize(BtCursor *pCur){
}
/*
+** Return an upper bound on the size of any record for the table
+** that the cursor is pointing into.
+**
+** This is an optimization. Everything will still work if this
+** routine always returns 2147483647 (which is the largest record
+** that SQLite can handle) or more. But returning a smaller value might
+** prevent large memory allocations when trying to interpret a
+** corrupt datrabase.
+**
+** The current implementation merely returns the size of the underlying
+** database file.
+*/
+SQLITE_PRIVATE sqlite3_int64 sqlite3BtreeMaxRecordSize(BtCursor *pCur){
+ assert( cursorHoldsMutex(pCur) );
+ assert( pCur->eState==CURSOR_VALID );
+ return pCur->pBt->pageSize * (sqlite3_int64)pCur->pBt->nPage;
+}
+
+/*
** Given the page number of an overflow page in the database (parameter
** ovfl), this function finds the page number of the next page in the
** linked list of overflow pages. If possible, it uses the auto-vacuum
@@ -68356,7 +68490,7 @@ SQLITE_PRIVATE int sqlite3BtreeMovetoUnpacked(
** try to get there using sqlite3BtreeNext() rather than a full
** binary search. This is an optimization only. The correct answer
** is still obtained without this case, only a little more slowely */
- if( pCur->info.nKey+1==intKey && !pCur->skipNext ){
+ if( pCur->info.nKey+1==intKey ){
*pRes = 0;
rc = sqlite3BtreeNext(pCur, 0);
if( rc==SQLITE_OK ){
@@ -68630,7 +68764,6 @@ static SQLITE_NOINLINE int btreeNext(BtCursor *pCur){
MemPage *pPage;
assert( cursorOwnsBtShared(pCur) );
- assert( pCur->skipNext==0 || pCur->eState!=CURSOR_VALID );
if( pCur->eState!=CURSOR_VALID ){
assert( (pCur->curFlags & BTCF_ValidOvfl)==0 );
rc = restoreCursorPosition(pCur);
@@ -68640,14 +68773,9 @@ static SQLITE_NOINLINE int btreeNext(BtCursor *pCur){
if( CURSOR_INVALID==pCur->eState ){
return SQLITE_DONE;
}
- if( pCur->skipNext ){
- assert( pCur->eState==CURSOR_VALID || pCur->eState==CURSOR_SKIPNEXT );
+ if( pCur->eState==CURSOR_SKIPNEXT ){
pCur->eState = CURSOR_VALID;
- if( pCur->skipNext>0 ){
- pCur->skipNext = 0;
- return SQLITE_OK;
- }
- pCur->skipNext = 0;
+ if( pCur->skipNext>0 ) return SQLITE_OK;
}
}
@@ -68702,7 +68830,6 @@ SQLITE_PRIVATE int sqlite3BtreeNext(BtCursor *pCur, int flags){
UNUSED_PARAMETER( flags ); /* Used in COMDB2 but not native SQLite */
assert( cursorOwnsBtShared(pCur) );
assert( flags==0 || flags==1 );
- assert( pCur->skipNext==0 || pCur->eState!=CURSOR_VALID );
pCur->info.nSize = 0;
pCur->curFlags &= ~(BTCF_ValidNKey|BTCF_ValidOvfl);
if( pCur->eState!=CURSOR_VALID ) return btreeNext(pCur);
@@ -68743,7 +68870,6 @@ static SQLITE_NOINLINE int btreePrevious(BtCursor *pCur){
MemPage *pPage;
assert( cursorOwnsBtShared(pCur) );
- assert( pCur->skipNext==0 || pCur->eState!=CURSOR_VALID );
assert( (pCur->curFlags & (BTCF_AtLast|BTCF_ValidOvfl|BTCF_ValidNKey))==0 );
assert( pCur->info.nSize==0 );
if( pCur->eState!=CURSOR_VALID ){
@@ -68754,14 +68880,9 @@ static SQLITE_NOINLINE int btreePrevious(BtCursor *pCur){
if( CURSOR_INVALID==pCur->eState ){
return SQLITE_DONE;
}
- if( pCur->skipNext ){
- assert( pCur->eState==CURSOR_VALID || pCur->eState==CURSOR_SKIPNEXT );
+ if( CURSOR_SKIPNEXT==pCur->eState ){
pCur->eState = CURSOR_VALID;
- if( pCur->skipNext<0 ){
- pCur->skipNext = 0;
- return SQLITE_OK;
- }
- pCur->skipNext = 0;
+ if( pCur->skipNext<0 ) return SQLITE_OK;
}
}
@@ -68796,7 +68917,6 @@ static SQLITE_NOINLINE int btreePrevious(BtCursor *pCur){
SQLITE_PRIVATE int sqlite3BtreePrevious(BtCursor *pCur, int flags){
assert( cursorOwnsBtShared(pCur) );
assert( flags==0 || flags==1 );
- assert( pCur->skipNext==0 || pCur->eState!=CURSOR_VALID );
UNUSED_PARAMETER( flags ); /* Used in COMDB2 but not native SQLite */
pCur->curFlags &= ~(BTCF_AtLast|BTCF_ValidOvfl|BTCF_ValidNKey);
pCur->info.nSize = 0;
@@ -69132,7 +69252,7 @@ static int allocateBtreePage(
TRACE(("ALLOCATE: %d from end of file\n", *pPgno));
}
- assert( *pPgno!=PENDING_BYTE_PAGE(pBt) );
+ assert( CORRUPT_DB || *pPgno!=PENDING_BYTE_PAGE(pBt) );
end_allocate_page:
releasePage(pTrunk);
@@ -69717,8 +69837,82 @@ static void insertCell(
}
/*
+** The following parameters determine how many adjacent pages get involved
+** in a balancing operation. NN is the number of neighbors on either side
+** of the page that participate in the balancing operation. NB is the
+** total number of pages that participate, including the target page and
+** NN neighbors on either side.
+**
+** The minimum value of NN is 1 (of course). Increasing NN above 1
+** (to 2 or 3) gives a modest improvement in SELECT and DELETE performance
+** in exchange for a larger degradation in INSERT and UPDATE performance.
+** The value of NN appears to give the best results overall.
+**
+** (Later:) The description above makes it seem as if these values are
+** tunable - as if you could change them and recompile and it would all work.
+** But that is unlikely. NB has been 3 since the inception of SQLite and
+** we have never tested any other value.
+*/
+#define NN 1 /* Number of neighbors on either side of pPage */
+#define NB 3 /* (NN*2+1): Total pages involved in the balance */
+
+/*
** A CellArray object contains a cache of pointers and sizes for a
** consecutive sequence of cells that might be held on multiple pages.
+**
+** The cells in this array are the divider cell or cells from the pParent
+** page plus up to three child pages. There are a total of nCell cells.
+**
+** pRef is a pointer to one of the pages that contributes cells. This is
+** used to access information such as MemPage.intKey and MemPage.pBt->pageSize
+** which should be common to all pages that contribute cells to this array.
+**
+** apCell[] and szCell[] hold, respectively, pointers to the start of each
+** cell and the size of each cell. Some of the apCell[] pointers might refer
+** to overflow cells. In other words, some apCel[] pointers might not point
+** to content area of the pages.
+**
+** A szCell[] of zero means the size of that cell has not yet been computed.
+**
+** The cells come from as many as four different pages:
+**
+** -----------
+** | Parent |
+** -----------
+** / | \
+** / | \
+** --------- --------- ---------
+** |Child-1| |Child-2| |Child-3|
+** --------- --------- ---------
+**
+** The order of cells is in the array is for an index btree is:
+**
+** 1. All cells from Child-1 in order
+** 2. The first divider cell from Parent
+** 3. All cells from Child-2 in order
+** 4. The second divider cell from Parent
+** 5. All cells from Child-3 in order
+**
+** For a table-btree (with rowids) the items 2 and 4 are empty because
+** content exists only in leaves and there are no divider cells.
+**
+** For an index btree, the apEnd[] array holds pointer to the end of page
+** for Child-1, the Parent, Child-2, the Parent (again), and Child-3,
+** respectively. The ixNx[] array holds the number of cells contained in
+** each of these 5 stages, and all stages to the left. Hence:
+**
+** ixNx[0] = Number of cells in Child-1.
+** ixNx[1] = Number of cells in Child-1 plus 1 for first divider.
+** ixNx[2] = Number of cells in Child-1 and Child-2 + 1 for 1st divider.
+** ixNx[3] = Number of cells in Child-1 and Child-2 + both divider cells
+** ixNx[4] = Total number of cells.
+**
+** For a table-btree, the concept is similar, except only apEnd[0]..apEnd[2]
+** are used and they point to the leaf pages only, and the ixNx value are:
+**
+** ixNx[0] = Number of cells in Child-1.
+** ixNx[1] = Number of cells in Child-1 and Child-2 + 1 for 1st divider.
+** ixNx[2] = Number of cells in Child-1 and Child-2 + both divider cells
*/
typedef struct CellArray CellArray;
struct CellArray {
@@ -69726,6 +69920,8 @@ struct CellArray {
MemPage *pRef; /* Reference page */
u8 **apCell; /* All cells begin balanced */
u16 *szCell; /* Local size of all cells in apCell[] */
+ u8 *apEnd[NB*2]; /* MemPage.aDataEnd values */
+ int ixNx[NB*2]; /* Index of at which we move to the next apEnd[] */
};
/*
@@ -69776,37 +69972,59 @@ static u16 cachedCellSize(CellArray *p, int N){
** responsibility of the caller to set it correctly.
*/
static int rebuildPage(
- MemPage *pPg, /* Edit this page */
+ CellArray *pCArray, /* Content to be added to page pPg */
+ int iFirst, /* First cell in pCArray to use */
int nCell, /* Final number of cells on page */
- u8 **apCell, /* Array of cells */
- u16 *szCell /* Array of cell sizes */
+ MemPage *pPg /* The page to be reconstructed */
){
const int hdr = pPg->hdrOffset; /* Offset of header on pPg */
u8 * const aData = pPg->aData; /* Pointer to data for pPg */
const int usableSize = pPg->pBt->usableSize;
u8 * const pEnd = &aData[usableSize];
- int i;
+ int i = iFirst; /* Which cell to copy from pCArray*/
+ u32 j; /* Start of cell content area */
+ int iEnd = i+nCell; /* Loop terminator */
u8 *pCellptr = pPg->aCellIdx;
u8 *pTmp = sqlite3PagerTempSpace(pPg->pBt->pPager);
u8 *pData;
+ int k; /* Current slot in pCArray->apEnd[] */
+ u8 *pSrcEnd; /* Current pCArray->apEnd[k] value */
- i = get2byte(&aData[hdr+5]);
- memcpy(&pTmp[i], &aData[i], usableSize - i);
+ assert( i<iEnd );
+ j = get2byte(&aData[hdr+5]);
+ if( NEVER(j>(u32)usableSize) ){ j = 0; }
+ memcpy(&pTmp[j], &aData[j], usableSize - j);
+
+ for(k=0; pCArray->ixNx[k]<=i && ALWAYS(k<NB*2); k++){}
+ pSrcEnd = pCArray->apEnd[k];
pData = pEnd;
- for(i=0; i<nCell; i++){
- u8 *pCell = apCell[i];
+ while( 1/*exit by break*/ ){
+ u8 *pCell = pCArray->apCell[i];
+ u16 sz = pCArray->szCell[i];
+ assert( sz>0 );
if( SQLITE_WITHIN(pCell,aData,pEnd) ){
- if( ((uptr)(pCell+szCell[i]))>(uptr)pEnd ) return SQLITE_CORRUPT_BKPT;
+ if( ((uptr)(pCell+sz))>(uptr)pEnd ) return SQLITE_CORRUPT_BKPT;
pCell = &pTmp[pCell - aData];
+ }else if( (uptr)(pCell+sz)>(uptr)pSrcEnd
+ && (uptr)(pCell)<(uptr)pSrcEnd
+ ){
+ return SQLITE_CORRUPT_BKPT;
}
- pData -= szCell[i];
+
+ pData -= sz;
put2byte(pCellptr, (pData - aData));
pCellptr += 2;
if( pData < pCellptr ) return SQLITE_CORRUPT_BKPT;
- memcpy(pData, pCell, szCell[i]);
- assert( szCell[i]==pPg->xCellSize(pPg, pCell) || CORRUPT_DB );
- testcase( szCell[i]!=pPg->xCellSize(pPg,pCell) );
+ memcpy(pData, pCell, sz);
+ assert( sz==pPg->xCellSize(pPg, pCell) || CORRUPT_DB );
+ testcase( sz!=pPg->xCellSize(pPg,pCell) );
+ i++;
+ if( i>=iEnd ) break;
+ if( pCArray->ixNx[k]<=i ){
+ k++;
+ pSrcEnd = pCArray->apEnd[k];
+ }
}
/* The pPg->nFree field is now set incorrectly. The caller will fix it. */
@@ -69821,12 +70039,11 @@ static int rebuildPage(
}
/*
-** Array apCell[] contains nCell pointers to b-tree cells. Array szCell
-** contains the size in bytes of each such cell. This function attempts to
-** add the cells stored in the array to page pPg. If it cannot (because
-** the page needs to be defragmented before the cells will fit), non-zero
-** is returned. Otherwise, if the cells are added successfully, zero is
-** returned.
+** The pCArray objects contains pointers to b-tree cells and the cell sizes.
+** This function attempts to add the cells stored in the array to page pPg.
+** If it cannot (because the page needs to be defragmented before the cells
+** will fit), non-zero is returned. Otherwise, if the cells are added
+** successfully, zero is returned.
**
** Argument pCellptr points to the first entry in the cell-pointer array
** (part of page pPg) to populate. After cell apCell[0] is written to the
@@ -69848,18 +70065,23 @@ static int rebuildPage(
static int pageInsertArray(
MemPage *pPg, /* Page to add cells to */
u8 *pBegin, /* End of cell-pointer array */
- u8 **ppData, /* IN/OUT: Page content -area pointer */
+ u8 **ppData, /* IN/OUT: Page content-area pointer */
u8 *pCellptr, /* Pointer to cell-pointer area */
int iFirst, /* Index of first cell to add */
int nCell, /* Number of cells to add to pPg */
CellArray *pCArray /* Array of cells */
){
- int i;
- u8 *aData = pPg->aData;
- u8 *pData = *ppData;
- int iEnd = iFirst + nCell;
+ int i = iFirst; /* Loop counter - cell index to insert */
+ u8 *aData = pPg->aData; /* Complete page */
+ u8 *pData = *ppData; /* Content area. A subset of aData[] */
+ int iEnd = iFirst + nCell; /* End of loop. One past last cell to ins */
+ int k; /* Current slot in pCArray->apEnd[] */
+ u8 *pEnd; /* Maximum extent of cell data */
assert( CORRUPT_DB || pPg->hdrOffset==0 ); /* Never called on page 1 */
- for(i=iFirst; i<iEnd; i++){
+ if( iEnd<=iFirst ) return 0;
+ for(k=0; pCArray->ixNx[k]<=i && ALWAYS(k<NB*2); k++){}
+ pEnd = pCArray->apEnd[k];
+ while( 1 /*Exit by break*/ ){
int sz, rc;
u8 *pSlot;
sz = cachedCellSize(pCArray, i);
@@ -69874,20 +70096,33 @@ static int pageInsertArray(
assert( (pSlot+sz)<=pCArray->apCell[i]
|| pSlot>=(pCArray->apCell[i]+sz)
|| CORRUPT_DB );
+ if( (uptr)(pCArray->apCell[i]+sz)>(uptr)pEnd
+ && (uptr)(pCArray->apCell[i])<(uptr)pEnd
+ ){
+ assert( CORRUPT_DB );
+ (void)SQLITE_CORRUPT_BKPT;
+ return 1;
+ }
memmove(pSlot, pCArray->apCell[i], sz);
put2byte(pCellptr, (pSlot - aData));
pCellptr += 2;
+ i++;
+ if( i>=iEnd ) break;
+ if( pCArray->ixNx[k]<=i ){
+ k++;
+ pEnd = pCArray->apEnd[k];
+ }
}
*ppData = pData;
return 0;
}
/*
-** Array apCell[] contains nCell pointers to b-tree cells. Array szCell
-** contains the size in bytes of each such cell. This function adds the
-** space associated with each cell in the array that is currently stored
-** within the body of pPg to the pPg free-list. The cell-pointers and other
-** fields of the page are not updated.
+** The pCArray object contains pointers to b-tree cells and their sizes.
+**
+** This function adds the space associated with each cell in the array
+** that is currently stored within the body of pPg to the pPg free-list.
+** The cell-pointers and other fields of the page are not updated.
**
** This function returns the total number of cells added to the free-list.
*/
@@ -69937,9 +70172,9 @@ static int pageFreeArray(
}
/*
-** apCell[] and szCell[] contains pointers to and sizes of all cells in the
-** pages being balanced. The current page, pPg, has pPg->nCell cells starting
-** with apCell[iOld]. After balancing, this page should hold nNew cells
+** pCArray contains pointers to and sizes of all cells in the page being
+** balanced. The current page, pPg, has pPg->nCell cells starting with
+** pCArray->apCell[iOld]. After balancing, this page should hold nNew cells
** starting at apCell[iNew].
**
** This routine makes the necessary adjustments to pPg so that it contains
@@ -69971,13 +70206,17 @@ static int editPage(
#endif
/* Remove cells from the start and end of the page */
+ assert( nCell>=0 );
if( iOld<iNew ){
int nShift = pageFreeArray(pPg, iOld, iNew-iOld, pCArray);
+ if( nShift>nCell ) return SQLITE_CORRUPT_BKPT;
memmove(pPg->aCellIdx, &pPg->aCellIdx[nShift*2], nCell*2);
nCell -= nShift;
}
if( iNewEnd < iOldEnd ){
- nCell -= pageFreeArray(pPg, iNewEnd, iOldEnd - iNewEnd, pCArray);
+ int nTail = pageFreeArray(pPg, iNewEnd, iOldEnd - iNewEnd, pCArray);
+ assert( nCell>=nTail );
+ nCell -= nTail;
}
pData = &aData[get2byteNotZero(&aData[hdr+5])];
@@ -69987,6 +70226,7 @@ static int editPage(
if( iNew<iOld ){
int nAdd = MIN(nNew,iOld-iNew);
assert( (iOld-iNew)<nNew || nCell==0 || CORRUPT_DB );
+ assert( nAdd>=0 );
pCellptr = pPg->aCellIdx;
memmove(&pCellptr[nAdd*2], pCellptr, nCell*2);
if( pageInsertArray(
@@ -70001,6 +70241,7 @@ static int editPage(
int iCell = (iOld + pPg->aiOvfl[i]) - iNew;
if( iCell>=0 && iCell<nNew ){
pCellptr = &pPg->aCellIdx[iCell * 2];
+ assert( nCell>=iCell );
memmove(&pCellptr[2], pCellptr, (nCell - iCell) * 2);
nCell++;
if( pageInsertArray(
@@ -70011,6 +70252,7 @@ static int editPage(
}
/* Append cells to the end of the page */
+ assert( nCell>=0 );
pCellptr = &pPg->aCellIdx[nCell*2];
if( pageInsertArray(
pPg, pBegin, &pData, pCellptr,
@@ -70039,24 +70281,9 @@ static int editPage(
editpage_fail:
/* Unable to edit this page. Rebuild it from scratch instead. */
populateCellCache(pCArray, iNew, nNew);
- return rebuildPage(pPg, nNew, &pCArray->apCell[iNew], &pCArray->szCell[iNew]);
+ return rebuildPage(pCArray, iNew, nNew, pPg);
}
-/*
-** The following parameters determine how many adjacent pages get involved
-** in a balancing operation. NN is the number of neighbors on either side
-** of the page that participate in the balancing operation. NB is the
-** total number of pages that participate, including the target page and
-** NN neighbors on either side.
-**
-** The minimum value of NN is 1 (of course). Increasing NN above 1
-** (to 2 or 3) gives a modest improvement in SELECT and DELETE performance
-** in exchange for a larger degradation in INSERT and UPDATE performance.
-** The value of NN appears to give the best results overall.
-*/
-#define NN 1 /* Number of neighbors on either side of pPage */
-#define NB (NN*2+1) /* Total pages involved in the balance */
-
#ifndef SQLITE_OMIT_QUICKBALANCE
/*
@@ -70106,12 +70333,22 @@ static int balance_quick(MemPage *pParent, MemPage *pPage, u8 *pSpace){
u8 *pCell = pPage->apOvfl[0];
u16 szCell = pPage->xCellSize(pPage, pCell);
u8 *pStop;
+ CellArray b;
assert( sqlite3PagerIswriteable(pNew->pDbPage) );
- assert( pPage->aData[0]==(PTF_INTKEY|PTF_LEAFDATA|PTF_LEAF) );
+ assert( CORRUPT_DB || pPage->aData[0]==(PTF_INTKEY|PTF_LEAFDATA|PTF_LEAF) );
zeroPage(pNew, PTF_INTKEY|PTF_LEAFDATA|PTF_LEAF);
- rc = rebuildPage(pNew, 1, &pCell, &szCell);
- if( NEVER(rc) ) return rc;
+ b.nCell = 1;
+ b.pRef = pPage;
+ b.apCell = &pCell;
+ b.szCell = &szCell;
+ b.apEnd[0] = pPage->aDataEnd;
+ b.ixNx[0] = 2;
+ rc = rebuildPage(&b, 0, 1, pNew);
+ if( NEVER(rc) ){
+ releasePage(pNew);
+ return rc;
+ }
pNew->nFree = pBt->usableSize - pNew->cellOffset - 2 - szCell;
/* If this is an auto-vacuum database, update the pointer map
@@ -70589,8 +70826,15 @@ static int balance_nonroot(
**
*/
usableSpace = pBt->usableSize - 12 + leafCorrection;
- for(i=0; i<nOld; i++){
+ for(i=k=0; i<nOld; i++, k++){
MemPage *p = apOld[i];
+ b.apEnd[k] = p->aDataEnd;
+ b.ixNx[k] = cntOld[i];
+ if( !leafData ){
+ k++;
+ b.apEnd[k] = pParent->aDataEnd;
+ b.ixNx[k] = cntOld[i]+1;
+ }
szNew[i] = usableSpace - p->nFree;
for(j=0; j<p->nOverflow; j++){
szNew[i] += 2 + p->xCellSize(p, p->apOvfl[j]);
@@ -71272,7 +71516,11 @@ static int btreeOverwriteContent(
if( memcmp(pDest, ((u8*)pX->pData) + iOffset, iAmt)!=0 ){
int rc = sqlite3PagerWrite(pPage->pDbPage);
if( rc ) return rc;
- memcpy(pDest, ((u8*)pX->pData) + iOffset, iAmt);
+ /* In a corrupt database, it is possible for the source and destination
+ ** buffers to overlap. This is harmless since the database is already
+ ** corrupt but it does cause valgrind and ASAN warnings. So use
+ ** memmove(). */
+ memmove(pDest, ((u8*)pX->pData) + iOffset, iAmt);
}
}
return SQLITE_OK;
@@ -72452,7 +72700,7 @@ static void checkList(
checkPtrmap(pCheck, iPage, PTRMAP_FREEPAGE, 0);
}
#endif
- if( n>(int)pCheck->pBt->usableSize/4-2 ){
+ if( n>pCheck->pBt->usableSize/4-2 ){
checkAppendMsg(pCheck,
"freelist leaf count too big on page %d", iPage);
N--;
@@ -72834,7 +73082,7 @@ SQLITE_PRIVATE char *sqlite3BtreeIntegrityCheck(
Pgno i;
IntegrityCk sCheck;
BtShared *pBt = p->pBt;
- int savedDbFlags = pBt->db->flags;
+ u64 savedDbFlags = pBt->db->flags;
char zErr[100];
VVA_ONLY( int nRef );
@@ -72901,7 +73149,7 @@ SQLITE_PRIVATE char *sqlite3BtreeIntegrityCheck(
}
#endif
testcase( pBt->db->flags & SQLITE_CellSizeCk );
- pBt->db->flags &= ~SQLITE_CellSizeCk;
+ pBt->db->flags &= ~(u64)SQLITE_CellSizeCk;
for(i=0; (int)i<nRoot && sCheck.mxErr; i++){
i64 notUsed;
if( aRoot[i]==0 ) continue;
@@ -74289,7 +74537,7 @@ SQLITE_PRIVATE SQLITE_NOINLINE int sqlite3VdbeMemGrow(Mem *pMem, int n, int bPre
** if unable to complete the resizing.
*/
SQLITE_PRIVATE int sqlite3VdbeMemClearAndResize(Mem *pMem, int szNew){
- assert( szNew>0 );
+ assert( CORRUPT_DB || szNew>0 );
assert( (pMem->flags & MEM_Dyn)==0 || pMem->szMalloc==0 );
if( pMem->szMalloc<szNew ){
return sqlite3VdbeMemGrow(pMem, szNew, 0);
@@ -75170,6 +75418,9 @@ static SQLITE_NOINLINE int vdbeMemFromBtreeResize(
){
int rc;
pMem->flags = MEM_Null;
+ if( sqlite3BtreeMaxRecordSize(pCur)<offset+amt ){
+ return SQLITE_CORRUPT_BKPT;
+ }
if( SQLITE_OK==(rc = sqlite3VdbeMemClearAndResize(pMem, amt+1)) ){
rc = sqlite3BtreePayload(pCur, offset, amt, pMem->z);
if( rc==SQLITE_OK ){
@@ -75576,9 +75827,11 @@ static int valueFromExpr(
}
#endif
else if( op==TK_TRUEFALSE ){
- pVal = valueNew(db, pCtx);
- pVal->flags = MEM_Int;
- pVal->u.i = pExpr->u.zToken[4]==0;
+ pVal = valueNew(db, pCtx);
+ if( pVal ){
+ pVal->flags = MEM_Int;
+ pVal->u.i = pExpr->u.zToken[4]==0;
+ }
}
*ppVal = pVal;
@@ -75971,7 +76224,7 @@ SQLITE_PRIVATE Vdbe *sqlite3VdbeCreate(Parse *pParse){
pParse->pVdbe = p;
assert( pParse->aLabel==0 );
assert( pParse->nLabel==0 );
- assert( pParse->nOpAlloc==0 );
+ assert( p->nOpAlloc==0 );
assert( pParse->szOpAlloc==0 );
sqlite3VdbeAddOp2(p, OP_Init, 0, 1);
return p;
@@ -75999,14 +76252,44 @@ SQLITE_PRIVATE void sqlite3VdbeSetSql(Vdbe *p, const char *z, int n, u8 prepFlag
}
assert( p->zSql==0 );
p->zSql = sqlite3DbStrNDup(p->db, z, n);
+}
+
#ifdef SQLITE_ENABLE_NORMALIZE
- assert( p->zNormSql==0 );
- if( p->zSql && (prepFlags & SQLITE_PREPARE_NORMALIZE)!=0 ){
- sqlite3Normalize(p, p->zSql, n, prepFlags);
- assert( p->zNormSql!=0 || p->db->mallocFailed );
+/*
+** Add a new element to the Vdbe->pDblStr list.
+*/
+SQLITE_PRIVATE void sqlite3VdbeAddDblquoteStr(sqlite3 *db, Vdbe *p, const char *z){
+ if( p ){
+ int n = sqlite3Strlen30(z);
+ DblquoteStr *pStr = sqlite3DbMallocRawNN(db,
+ sizeof(*pStr)+n+1-sizeof(pStr->z));
+ if( pStr ){
+ pStr->pNextStr = p->pDblStr;
+ p->pDblStr = pStr;
+ memcpy(pStr->z, z, n+1);
+ }
}
+}
#endif
+
+#ifdef SQLITE_ENABLE_NORMALIZE
+/*
+** zId of length nId is a double-quoted identifier. Check to see if
+** that identifier is really used as a string literal.
+*/
+SQLITE_PRIVATE int sqlite3VdbeUsesDoubleQuotedString(
+ Vdbe *pVdbe, /* The prepared statement */
+ const char *zId /* The double-quoted identifier, already dequoted */
+){
+ DblquoteStr *pStr;
+ assert( zId!=0 );
+ if( pVdbe->pDblStr==0 ) return 0;
+ for(pStr=pVdbe->pDblStr; pStr; pStr=pStr->pNextStr){
+ if( strcmp(zId, pStr->z)==0 ) return 1;
+ }
+ return 0;
}
+#endif
/*
** Swap all content between two VDBE structures.
@@ -76027,7 +76310,7 @@ SQLITE_PRIVATE void sqlite3VdbeSwap(Vdbe *pA, Vdbe *pB){
zTmp = pA->zSql;
pA->zSql = pB->zSql;
pB->zSql = zTmp;
-#ifdef SQLITE_ENABLE_NORMALIZE
+#if 0
zTmp = pA->zNormSql;
pA->zNormSql = pB->zNormSql;
pB->zNormSql = zTmp;
@@ -76044,7 +76327,7 @@ SQLITE_PRIVATE void sqlite3VdbeSwap(Vdbe *pA, Vdbe *pB){
** to 1024/sizeof(Op).
**
** If an out-of-memory error occurs while resizing the array, return
-** SQLITE_NOMEM. In this case Vdbe.aOp and Parse.nOpAlloc remain
+** SQLITE_NOMEM. In this case Vdbe.aOp and Vdbe.nOpAlloc remain
** unchanged (this is so that any opcodes already allocated can be
** correctly deallocated along with the rest of the Vdbe).
*/
@@ -76060,9 +76343,9 @@ static int growOpArray(Vdbe *v, int nOp){
** operation (without SQLITE_TEST_REALLOC_STRESS) is to double the current
** size of the op array or add 1KB of space, whichever is smaller. */
#ifdef SQLITE_TEST_REALLOC_STRESS
- int nNew = (p->nOpAlloc>=512 ? p->nOpAlloc*2 : p->nOpAlloc+nOp);
+ int nNew = (v->nOpAlloc>=512 ? v->nOpAlloc*2 : v->nOpAlloc+nOp);
#else
- int nNew = (p->nOpAlloc ? p->nOpAlloc*2 : (int)(1024/sizeof(Op)));
+ int nNew = (v->nOpAlloc ? v->nOpAlloc*2 : (int)(1024/sizeof(Op)));
UNUSED_PARAMETER(nOp);
#endif
@@ -76073,11 +76356,11 @@ static int growOpArray(Vdbe *v, int nOp){
}
assert( nOp<=(1024/sizeof(Op)) );
- assert( nNew>=(p->nOpAlloc+nOp) );
+ assert( nNew>=(v->nOpAlloc+nOp) );
pNew = sqlite3DbRealloc(p->db, v->aOp, nNew*sizeof(Op));
if( pNew ){
p->szOpAlloc = sqlite3DbMallocSize(p->db, pNew);
- p->nOpAlloc = p->szOpAlloc/sizeof(Op);
+ v->nOpAlloc = p->szOpAlloc/sizeof(Op);
v->aOp = pNew;
}
return (pNew ? SQLITE_OK : SQLITE_NOMEM_BKPT);
@@ -76111,9 +76394,9 @@ static void test_addop_breakpoint(void){
** operand.
*/
static SQLITE_NOINLINE int growOp3(Vdbe *p, int op, int p1, int p2, int p3){
- assert( p->pParse->nOpAlloc<=p->nOp );
+ assert( p->nOpAlloc<=p->nOp );
if( growOpArray(p, 1) ) return 1;
- assert( p->pParse->nOpAlloc>p->nOp );
+ assert( p->nOpAlloc>p->nOp );
return sqlite3VdbeAddOp3(p, op, p1, p2, p3);
}
SQLITE_PRIVATE int sqlite3VdbeAddOp3(Vdbe *p, int op, int p1, int p2, int p3){
@@ -76123,7 +76406,7 @@ SQLITE_PRIVATE int sqlite3VdbeAddOp3(Vdbe *p, int op, int p1, int p2, int p3){
i = p->nOp;
assert( p->magic==VDBE_MAGIC_INIT );
assert( op>=0 && op<0xff );
- if( p->pParse->nOpAlloc<=i ){
+ if( p->nOpAlloc<=i ){
return growOp3(p, op, p1, p2, p3);
}
p->nOp++;
@@ -76255,13 +76538,29 @@ SQLITE_PRIVATE int sqlite3VdbeExplainParent(Parse *pParse){
}
/*
-** Add a new OP_Explain opcode.
+** Set a debugger breakpoint on the following routine in order to
+** monitor the EXPLAIN QUERY PLAN code generation.
+*/
+#if defined(SQLITE_DEBUG)
+SQLITE_PRIVATE void sqlite3ExplainBreakpoint(const char *z1, const char *z2){
+ (void)z1;
+ (void)z2;
+}
+#endif
+
+/*
+** Add a new OP_ opcode.
**
** If the bPush flag is true, then make this opcode the parent for
** subsequent Explains until sqlite3VdbeExplainPop() is called.
*/
SQLITE_PRIVATE void sqlite3VdbeExplain(Parse *pParse, u8 bPush, const char *zFmt, ...){
- if( pParse->explain==2 ){
+#ifndef SQLITE_DEBUG
+ /* Always include the OP_Explain opcodes if SQLITE_DEBUG is defined.
+ ** But omit them (for performance) during production builds */
+ if( pParse->explain==2 )
+#endif
+ {
char *zMsg;
Vdbe *v;
va_list ap;
@@ -76273,7 +76572,10 @@ SQLITE_PRIVATE void sqlite3VdbeExplain(Parse *pParse, u8 bPush, const char *zFmt
iThis = v->nOp;
sqlite3VdbeAddOp4(v, OP_Explain, iThis, pParse->addrExplain, 0,
zMsg, P4_DYNAMIC);
- if( bPush) pParse->addrExplain = iThis;
+ sqlite3ExplainBreakpoint(bPush?"PUSH":"", sqlite3VdbeGetOp(v,-1)->p4.z);
+ if( bPush){
+ pParse->addrExplain = iThis;
+ }
}
}
@@ -76281,6 +76583,7 @@ SQLITE_PRIVATE void sqlite3VdbeExplain(Parse *pParse, u8 bPush, const char *zFmt
** Pop the EXPLAIN QUERY PLAN stack one level.
*/
SQLITE_PRIVATE void sqlite3VdbeExplainPop(Parse *pParse){
+ sqlite3ExplainBreakpoint("POP", 0);
pParse->addrExplain = sqlite3VdbeExplainParent(pParse);
}
#endif /* SQLITE_OMIT_EXPLAIN */
@@ -76345,21 +76648,22 @@ SQLITE_PRIVATE void sqlite3VdbeEndCoroutine(Vdbe *v, int regYield){
** The VDBE knows that a P2 value is a label because labels are
** always negative and P2 values are suppose to be non-negative.
** Hence, a negative P2 value is a label that has yet to be resolved.
+** (Later:) This is only true for opcodes that have the OPFLG_JUMP
+** property.
+**
+** Variable usage notes:
**
-** Zero is returned if a malloc() fails.
+** Parse.aLabel[x] Stores the address that the x-th label resolves
+** into. For testing (SQLITE_DEBUG), unresolved
+** labels stores -1, but that is not required.
+** Parse.nLabelAlloc Number of slots allocated to Parse.aLabel[]
+** Parse.nLabel The *negative* of the number of labels that have
+** been issued. The negative is stored because
+** that gives a performance improvement over storing
+** the equivalent positive value.
*/
-SQLITE_PRIVATE int sqlite3VdbeMakeLabel(Vdbe *v){
- Parse *p = v->pParse;
- int i = p->nLabel++;
- assert( v->magic==VDBE_MAGIC_INIT );
- if( (i & (i-1))==0 ){
- p->aLabel = sqlite3DbReallocOrFree(p->db, p->aLabel,
- (i*2+1)*sizeof(p->aLabel[0]));
- }
- if( p->aLabel ){
- p->aLabel[i] = -1;
- }
- return ADDR(i);
+SQLITE_PRIVATE int sqlite3VdbeMakeLabel(Parse *pParse){
+ return --pParse->nLabel;
}
/*
@@ -76367,18 +76671,35 @@ SQLITE_PRIVATE int sqlite3VdbeMakeLabel(Vdbe *v){
** be inserted. The parameter "x" must have been obtained from
** a prior call to sqlite3VdbeMakeLabel().
*/
+static SQLITE_NOINLINE void resizeResolveLabel(Parse *p, Vdbe *v, int j){
+ int nNewSize = 10 - p->nLabel;
+ p->aLabel = sqlite3DbReallocOrFree(p->db, p->aLabel,
+ nNewSize*sizeof(p->aLabel[0]));
+ if( p->aLabel==0 ){
+ p->nLabelAlloc = 0;
+ }else{
+#ifdef SQLITE_DEBUG
+ int i;
+ for(i=p->nLabelAlloc; i<nNewSize; i++) p->aLabel[i] = -1;
+#endif
+ p->nLabelAlloc = nNewSize;
+ p->aLabel[j] = v->nOp;
+ }
+}
SQLITE_PRIVATE void sqlite3VdbeResolveLabel(Vdbe *v, int x){
Parse *p = v->pParse;
int j = ADDR(x);
assert( v->magic==VDBE_MAGIC_INIT );
- assert( j<p->nLabel );
+ assert( j<-p->nLabel );
assert( j>=0 );
- if( p->aLabel ){
#ifdef SQLITE_DEBUG
- if( p->db->flags & SQLITE_VdbeAddopTrace ){
- printf("RESOLVE LABEL %d to %d\n", x, v->nOp);
- }
+ if( p->db->flags & SQLITE_VdbeAddopTrace ){
+ printf("RESOLVE LABEL %d to %d\n", x, v->nOp);
+ }
#endif
+ if( p->nLabelAlloc + p->nLabel < 0 ){
+ resizeResolveLabel(p,v,j);
+ }else{
assert( p->aLabel[j]==(-1) ); /* Labels may only be resolved once */
p->aLabel[j] = v->nOp;
}
@@ -76503,8 +76824,9 @@ SQLITE_PRIVATE int sqlite3VdbeAssertMayAbort(Vdbe *v, int mayAbort){
while( (pOp = opIterNext(&sIter))!=0 ){
int opcode = pOp->opcode;
if( opcode==OP_Destroy || opcode==OP_VUpdate || opcode==OP_VRename
+ || opcode==OP_VDestroy
|| ((opcode==OP_Halt || opcode==OP_HaltIfNull)
- && ((pOp->p1&0xff)==SQLITE_CONSTRAINT && pOp->p2==OE_Abort))
+ && ((pOp->p1)!=SQLITE_OK && pOp->p2==OE_Abort))
){
hasAbort = 1;
break;
@@ -76653,7 +76975,7 @@ static void resolveP2Values(Vdbe *p, int *pMaxFuncArgs){
** non-jump opcodes less than SQLITE_MX_JUMP_CODE are guaranteed to
** have non-negative values for P2. */
assert( (sqlite3OpcodeProperty[pOp->opcode] & OPFLG_JUMP)!=0 );
- assert( ADDR(pOp->p2)<pParse->nLabel );
+ assert( ADDR(pOp->p2)<-pParse->nLabel );
pOp->p2 = aLabel[ADDR(pOp->p2)];
}
break;
@@ -76692,7 +77014,7 @@ SQLITE_PRIVATE int sqlite3VdbeCurrentAddr(Vdbe *p){
*/
#if defined(SQLITE_DEBUG) && !defined(SQLITE_TEST_REALLOC_STRESS)
SQLITE_PRIVATE void sqlite3VdbeVerifyNoMallocRequired(Vdbe *p, int N){
- assert( p->nOp + N <= p->pParse->nOpAlloc );
+ assert( p->nOp + N <= p->nOpAlloc );
}
#endif
@@ -76764,7 +77086,7 @@ SQLITE_PRIVATE VdbeOp *sqlite3VdbeAddOpList(
VdbeOp *pOut, *pFirst;
assert( nOp>0 );
assert( p->magic==VDBE_MAGIC_INIT );
- if( p->nOp + nOp > p->pParse->nOpAlloc && growOpArray(p, nOp) ){
+ if( p->nOp + nOp > p->nOpAlloc && growOpArray(p, nOp) ){
return 0;
}
pFirst = pOut = &p->aOp[p->nOp];
@@ -78086,19 +78408,27 @@ SQLITE_PRIVATE void sqlite3VdbeMakeReady(
** the leftover memory at the end of the opcode array. This can significantly
** reduce the amount of memory held by a prepared statement.
*/
- do {
- x.nNeeded = 0;
- p->aMem = allocSpace(&x, p->aMem, nMem*sizeof(Mem));
- p->aVar = allocSpace(&x, p->aVar, nVar*sizeof(Mem));
- p->apArg = allocSpace(&x, p->apArg, nArg*sizeof(Mem*));
- p->apCsr = allocSpace(&x, p->apCsr, nCursor*sizeof(VdbeCursor*));
+ x.nNeeded = 0;
+ p->aMem = allocSpace(&x, 0, nMem*sizeof(Mem));
+ p->aVar = allocSpace(&x, 0, nVar*sizeof(Mem));
+ p->apArg = allocSpace(&x, 0, nArg*sizeof(Mem*));
+ p->apCsr = allocSpace(&x, 0, nCursor*sizeof(VdbeCursor*));
#ifdef SQLITE_ENABLE_STMT_SCANSTATUS
- p->anExec = allocSpace(&x, p->anExec, p->nOp*sizeof(i64));
+ p->anExec = allocSpace(&x, 0, p->nOp*sizeof(i64));
#endif
- if( x.nNeeded==0 ) break;
+ if( x.nNeeded ){
x.pSpace = p->pFree = sqlite3DbMallocRawNN(db, x.nNeeded);
x.nFree = x.nNeeded;
- }while( !db->mallocFailed );
+ if( !db->mallocFailed ){
+ p->aMem = allocSpace(&x, p->aMem, nMem*sizeof(Mem));
+ p->aVar = allocSpace(&x, p->aVar, nVar*sizeof(Mem));
+ p->apArg = allocSpace(&x, p->apArg, nArg*sizeof(Mem*));
+ p->apCsr = allocSpace(&x, p->apCsr, nCursor*sizeof(VdbeCursor*));
+#ifdef SQLITE_ENABLE_STMT_SCANSTATUS
+ p->anExec = allocSpace(&x, p->anExec, p->nOp*sizeof(i64));
+#endif
+ }
+ }
p->pVList = pParse->pVList;
pParse->pVList = 0;
@@ -78790,7 +79120,7 @@ SQLITE_PRIVATE int sqlite3VdbeHalt(Vdbe *p){
}else{
db->nDeferredCons = 0;
db->nDeferredImmCons = 0;
- db->flags &= ~SQLITE_DeferFKs;
+ db->flags &= ~(u64)SQLITE_DeferFKs;
sqlite3CommitInternalChanges(db);
}
}else{
@@ -79105,6 +79435,13 @@ SQLITE_PRIVATE void sqlite3VdbeClearObject(sqlite3 *db, Vdbe *p){
sqlite3DbFree(db, p->zSql);
#ifdef SQLITE_ENABLE_NORMALIZE
sqlite3DbFree(db, p->zNormSql);
+ {
+ DblquoteStr *pThis, *pNext;
+ for(pThis=p->pDblStr; pThis; pThis=pNext){
+ pNext = pThis->pNextStr;
+ sqlite3DbFree(db, pThis);
+ }
+ }
#endif
#ifdef SQLITE_ENABLE_STMT_SCANSTATUS
{
@@ -79645,7 +79982,7 @@ SQLITE_PRIVATE void sqlite3VdbeRecordUnpack(
UnpackedRecord *p /* Populate this structure before returning. */
){
const unsigned char *aKey = (const unsigned char *)pKey;
- int d;
+ u32 d;
u32 idx; /* Offset in aKey[] to read from */
u16 u; /* Unsigned loop counter */
u32 szHdr;
@@ -79656,7 +79993,7 @@ SQLITE_PRIVATE void sqlite3VdbeRecordUnpack(
idx = getVarint32(aKey, szHdr);
d = szHdr;
u = 0;
- while( idx<szHdr && d<=nKey ){
+ while( idx<szHdr && d<=(u32)nKey ){
u32 serial_type;
idx += getVarint32(&aKey[idx], serial_type);
@@ -79669,7 +80006,7 @@ SQLITE_PRIVATE void sqlite3VdbeRecordUnpack(
pMem++;
if( (++u)>=p->nField ) break;
}
- if( d>nKey && u ){
+ if( d>(u32)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
@@ -80890,14 +81227,16 @@ static SQLITE_NOINLINE void invokeProfileCallback(sqlite3 *db, Vdbe *p){
sqlite3_int64 iNow;
sqlite3_int64 iElapse;
assert( p->startTime>0 );
- assert( db->xProfile!=0 || (db->mTrace & SQLITE_TRACE_PROFILE)!=0 );
+ assert( (db->mTrace & (SQLITE_TRACE_PROFILE|SQLITE_TRACE_XPROFILE))!=0 );
assert( db->init.busy==0 );
assert( p->zSql!=0 );
sqlite3OsCurrentTimeInt64(db->pVfs, &iNow);
iElapse = (iNow - p->startTime)*1000000;
+#ifndef SQLITE_OMIT_DEPRECATED
if( db->xProfile ){
db->xProfile(db->pProfileArg, p->zSql, iElapse);
}
+#endif
if( db->mTrace & SQLITE_TRACE_PROFILE ){
db->xTrace(SQLITE_TRACE_PROFILE, db->pTraceArg, p, (void*)&iElapse);
}
@@ -81411,7 +81750,7 @@ static int sqlite3Step(Vdbe *p){
return SQLITE_NOMEM_BKPT;
}
- if( p->pc<=0 && p->expired ){
+ if( p->pc<0 && p->expired ){
p->rc = SQLITE_SCHEMA;
rc = SQLITE_ERROR;
goto end_of_step;
@@ -81430,7 +81769,7 @@ static int sqlite3Step(Vdbe *p){
);
#ifndef SQLITE_OMIT_TRACE
- if( (db->xProfile || (db->mTrace & SQLITE_TRACE_PROFILE)!=0)
+ if( (db->mTrace & (SQLITE_TRACE_PROFILE|SQLITE_TRACE_XPROFILE))!=0
&& !db->init.busy && p->zSql ){
sqlite3OsCurrentTimeInt64(db->pVfs, &p->startTime);
}else{
@@ -81457,16 +81796,18 @@ static int sqlite3Step(Vdbe *p){
db->nVdbeExec--;
}
+ if( rc!=SQLITE_ROW ){
#ifndef SQLITE_OMIT_TRACE
- /* If the statement completed successfully, invoke the profile callback */
- if( rc!=SQLITE_ROW ) checkProfileCallback(db, p);
+ /* If the statement completed successfully, invoke the profile callback */
+ checkProfileCallback(db, p);
#endif
- if( rc==SQLITE_DONE && db->autoCommit ){
- assert( p->rc==SQLITE_OK );
- p->rc = doWalCallbacks(db);
- if( p->rc!=SQLITE_OK ){
- rc = SQLITE_ERROR;
+ if( rc==SQLITE_DONE && db->autoCommit ){
+ assert( p->rc==SQLITE_OK );
+ p->rc = doWalCallbacks(db);
+ if( p->rc!=SQLITE_OK ){
+ rc = SQLITE_ERROR;
+ }
}
}
@@ -81486,9 +81827,9 @@ end_of_step:
|| (rc&0xff)==SQLITE_BUSY || rc==SQLITE_MISUSE
);
assert( (p->rc!=SQLITE_ROW && p->rc!=SQLITE_DONE) || p->rc==p->rcApp );
- if( (p->prepFlags & SQLITE_PREPARE_SAVESQL)!=0
- && rc!=SQLITE_ROW
+ if( rc!=SQLITE_ROW
&& rc!=SQLITE_DONE
+ && (p->prepFlags & SQLITE_PREPARE_SAVESQL)!=0
){
/* If this statement was prepared using saved SQL and an
** error has occurred, then return the error code in p->rc to the
@@ -82110,7 +82451,7 @@ static int vdbeUnbind(Vdbe *p, int i){
pVar = &p->aVar[i];
sqlite3VdbeMemRelease(pVar);
pVar->flags = MEM_Null;
- sqlite3Error(p->db, SQLITE_OK);
+ p->db->errCode = SQLITE_OK;
/* If the bit corresponding to this variable in Vdbe.expmask is set, then
** binding a new value to this variable invalidates the current query plan.
@@ -82536,7 +82877,13 @@ SQLITE_API char *sqlite3_expanded_sql(sqlite3_stmt *pStmt){
*/
SQLITE_API const char *sqlite3_normalized_sql(sqlite3_stmt *pStmt){
Vdbe *p = (Vdbe *)pStmt;
- return p ? p->zNormSql : 0;
+ if( p==0 ) return 0;
+ if( p->zNormSql==0 && ALWAYS(p->zSql!=0) ){
+ sqlite3_mutex_enter(p->db->mutex);
+ p->zNormSql = sqlite3Normalize(p, p->zSql);
+ sqlite3_mutex_leave(p->db->mutex);
+ }
+ return p->zNormSql;
}
#endif /* SQLITE_ENABLE_NORMALIZE */
@@ -83236,6 +83583,11 @@ static VdbeCursor *allocateCursor(
assert( iCur>=0 && iCur<p->nCursor );
if( p->apCsr[iCur] ){ /*OPTIMIZATION-IF-FALSE*/
+ /* Before calling sqlite3VdbeFreeCursor(), ensure the isEphemeral flag
+ ** is clear. Otherwise, if this is an ephemeral cursor created by
+ ** OP_OpenDup, the cursor will not be closed and will still be part
+ ** of a BtShared.pCursor list. */
+ p->apCsr[iCur]->isEphemeral = 0;
sqlite3VdbeFreeCursor(p, p->apCsr[iCur]);
p->apCsr[iCur] = 0;
}
@@ -83376,6 +83728,7 @@ SQLITE_PRIVATE void sqlite3ValueApplyAffinity(
static u16 SQLITE_NOINLINE computeNumericType(Mem *pMem){
assert( (pMem->flags & (MEM_Int|MEM_Real))==0 );
assert( (pMem->flags & (MEM_Str|MEM_Blob))!=0 );
+ ExpandBlob(pMem);
if( sqlite3AtoF(pMem->z, &pMem->u.r, pMem->n, pMem->enc)==0 ){
return 0;
}
@@ -84663,8 +85016,8 @@ fp_math:
break;
}
default: {
- iA = (i64)rA;
- iB = (i64)rB;
+ iA = sqlite3VdbeIntValue(pIn1);
+ iB = sqlite3VdbeIntValue(pIn2);
if( iA==0 ) goto arithmetic_result_is_null;
if( iA==-1 ) iA = 1;
rB = (double)(iB % iA);
@@ -85010,7 +85363,8 @@ case OP_Ge: { /* same as TK_GE, jump, in1, in3 */
*/
assert( pOp->opcode==OP_Eq || pOp->opcode==OP_Ne );
assert( (flags1 & MEM_Cleared)==0 );
- assert( (pOp->p5 & SQLITE_JUMPIFNULL)==0 );
+ assert( (pOp->p5 & SQLITE_JUMPIFNULL)==0 || CORRUPT_DB );
+ testcase( (pOp->p5 & SQLITE_JUMPIFNULL)!=0 );
if( (flags1&flags3&MEM_Null)!=0
&& (flags3&MEM_Cleared)==0
){
@@ -86694,7 +87048,8 @@ case OP_OpenDup: {
pCx->isEphemeral = 1;
pCx->pKeyInfo = pOrig->pKeyInfo;
pCx->isTable = pOrig->isTable;
- rc = sqlite3BtreeCursor(pOrig->pBtx, MASTER_ROOT, BTREE_WRCSR,
+ pCx->pgnoRoot = pOrig->pgnoRoot;
+ rc = sqlite3BtreeCursor(pOrig->pBtx, pCx->pgnoRoot, BTREE_WRCSR,
pCx->pKeyInfo, pCx->uc.pCursor);
/* The sqlite3BtreeCursor() routine can only fail for the first cursor
** opened for a database. Since there is already an open cursor when this
@@ -86712,6 +87067,9 @@ case OP_OpenDup: {
** the main database is read-only. The ephemeral
** table is deleted automatically when the cursor is closed.
**
+** If the cursor P1 is already opened on an ephemeral table, the table
+** is cleared (all content is erased).
+**
** P2 is the number of columns in the ephemeral table.
** The cursor points to a BTree table if P4==0 and to a BTree index
** if P4 is not 0. If P4 is not NULL, it points to a KeyInfo structure
@@ -86743,41 +87101,50 @@ case OP_OpenEphemeral: {
SQLITE_OPEN_TRANSIENT_DB;
assert( pOp->p1>=0 );
assert( pOp->p2>=0 );
- pCx = allocateCursor(p, pOp->p1, pOp->p2, -1, CURTYPE_BTREE);
- if( pCx==0 ) goto no_mem;
- pCx->nullRow = 1;
- pCx->isEphemeral = 1;
- rc = sqlite3BtreeOpen(db->pVfs, 0, db, &pCx->pBtx,
- BTREE_OMIT_JOURNAL | BTREE_SINGLE | pOp->p5, vfsFlags);
- if( rc==SQLITE_OK ){
- rc = sqlite3BtreeBeginTrans(pCx->pBtx, 1, 0);
- }
- if( rc==SQLITE_OK ){
- /* If a transient index is required, create it by calling
- ** sqlite3BtreeCreateTable() with the BTREE_BLOBKEY flag before
- ** opening it. If a transient table is required, just use the
- ** automatically created table with root-page 1 (an BLOB_INTKEY table).
- */
- if( (pCx->pKeyInfo = pKeyInfo = pOp->p4.pKeyInfo)!=0 ){
- int pgno;
- assert( pOp->p4type==P4_KEYINFO );
- rc = sqlite3BtreeCreateTable(pCx->pBtx, &pgno, BTREE_BLOBKEY | pOp->p5);
- if( rc==SQLITE_OK ){
- assert( pgno==MASTER_ROOT+1 );
- assert( pKeyInfo->db==db );
- assert( pKeyInfo->enc==ENC(db) );
- rc = sqlite3BtreeCursor(pCx->pBtx, pgno, BTREE_WRCSR,
- pKeyInfo, pCx->uc.pCursor);
+ pCx = p->apCsr[pOp->p1];
+ if( pCx ){
+ /* If the ephermeral table is already open, erase all existing content
+ ** so that the table is empty again, rather than creating a new table. */
+ rc = sqlite3BtreeClearTable(pCx->pBtx, pCx->pgnoRoot, 0);
+ }else{
+ pCx = allocateCursor(p, pOp->p1, pOp->p2, -1, CURTYPE_BTREE);
+ if( pCx==0 ) goto no_mem;
+ pCx->nullRow = 1;
+ pCx->isEphemeral = 1;
+ rc = sqlite3BtreeOpen(db->pVfs, 0, db, &pCx->pBtx,
+ BTREE_OMIT_JOURNAL | BTREE_SINGLE | pOp->p5,
+ vfsFlags);
+ if( rc==SQLITE_OK ){
+ rc = sqlite3BtreeBeginTrans(pCx->pBtx, 1, 0);
+ }
+ if( rc==SQLITE_OK ){
+ /* If a transient index is required, create it by calling
+ ** sqlite3BtreeCreateTable() with the BTREE_BLOBKEY flag before
+ ** opening it. If a transient table is required, just use the
+ ** automatically created table with root-page 1 (an BLOB_INTKEY table).
+ */
+ if( (pCx->pKeyInfo = pKeyInfo = pOp->p4.pKeyInfo)!=0 ){
+ assert( pOp->p4type==P4_KEYINFO );
+ rc = sqlite3BtreeCreateTable(pCx->pBtx, (int*)&pCx->pgnoRoot,
+ BTREE_BLOBKEY | pOp->p5);
+ if( rc==SQLITE_OK ){
+ assert( pCx->pgnoRoot==MASTER_ROOT+1 );
+ assert( pKeyInfo->db==db );
+ assert( pKeyInfo->enc==ENC(db) );
+ rc = sqlite3BtreeCursor(pCx->pBtx, pCx->pgnoRoot, BTREE_WRCSR,
+ pKeyInfo, pCx->uc.pCursor);
+ }
+ pCx->isTable = 0;
+ }else{
+ pCx->pgnoRoot = MASTER_ROOT;
+ rc = sqlite3BtreeCursor(pCx->pBtx, MASTER_ROOT, BTREE_WRCSR,
+ 0, pCx->uc.pCursor);
+ pCx->isTable = 1;
}
- pCx->isTable = 0;
- }else{
- rc = sqlite3BtreeCursor(pCx->pBtx, MASTER_ROOT, BTREE_WRCSR,
- 0, pCx->uc.pCursor);
- pCx->isTable = 1;
}
+ pCx->isOrdered = (pOp->p5!=BTREE_UNORDERED);
}
if( rc ) goto abort_due_to_error;
- pCx->isOrdered = (pOp->p5!=BTREE_UNORDERED);
break;
}
@@ -87427,7 +87794,7 @@ case OP_NotExists: /* jump, in3 */
pC = p->apCsr[pOp->p1];
assert( pC!=0 );
#ifdef SQLITE_DEBUG
- pC->seekOp = OP_SeekRowid;
+ if( pOp->opcode==OP_SeekRowid ) pC->seekOp = OP_SeekRowid;
#endif
assert( pC->isTable );
assert( pC->eCurType==CURTYPE_BTREE );
@@ -88335,7 +88702,7 @@ case OP_Next: /* jump */
assert( pOp->opcode!=OP_Next
|| pC->seekOp==OP_SeekGT || pC->seekOp==OP_SeekGE
|| pC->seekOp==OP_Rewind || pC->seekOp==OP_Found
- || pC->seekOp==OP_NullRow);
+ || pC->seekOp==OP_NullRow|| pC->seekOp==OP_SeekRowid);
assert( pOp->opcode!=OP_Prev
|| pC->seekOp==OP_SeekLT || pC->seekOp==OP_SeekLE
|| pC->seekOp==OP_Last
@@ -88865,9 +89232,16 @@ case OP_ParseSchema: {
assert( db->init.busy==0 );
db->init.busy = 1;
initData.rc = SQLITE_OK;
+ initData.nInitRow = 0;
assert( !db->mallocFailed );
rc = sqlite3_exec(db, zSql, sqlite3InitCallback, &initData, 0);
if( rc==SQLITE_OK ) rc = initData.rc;
+ if( rc==SQLITE_OK && initData.nInitRow==0 ){
+ /* The OP_ParseSchema opcode with a non-NULL P4 argument should parse
+ ** at least one SQL statement. Any less than that indicates that
+ ** the sqlite_master table is corrupt. */
+ rc = SQLITE_CORRUPT_BKPT;
+ }
sqlite3DbFreeNN(db, zSql);
db->init.busy = 0;
}
@@ -89231,6 +89605,17 @@ case OP_Program: { /* jump */
#ifdef SQLITE_ENABLE_STMT_SCANSTATUS
p->anExec = 0;
#endif
+#ifdef SQLITE_DEBUG
+ /* Verify that second and subsequent executions of the same trigger do not
+ ** try to reuse register values from the first use. */
+ {
+ int i;
+ for(i=0; i<p->nMem; i++){
+ aMem[i].pScopyFrom = 0; /* Prevent false-positive AboutToChange() errs */
+ aMem[i].flags |= MEM_Undefined; /* Cause a fault if this reg is reused */
+ }
+ }
+#endif
pOp = &aOp[-1];
break;
@@ -89769,14 +90154,19 @@ case OP_JournalMode: { /* out2 */
#endif /* SQLITE_OMIT_PRAGMA */
#if !defined(SQLITE_OMIT_VACUUM) && !defined(SQLITE_OMIT_ATTACH)
-/* Opcode: Vacuum P1 * * * *
+/* Opcode: Vacuum P1 P2 * * *
**
** Vacuum the entire database P1. P1 is 0 for "main", and 2 or more
** for an attached database. The "temp" database may not be vacuumed.
+**
+** If P2 is not zero, then it is a register holding a string which is
+** the file into which the result of vacuum should be written. When
+** P2 is zero, the vacuum overwrites the original database.
*/
case OP_Vacuum: {
assert( p->readOnly==0 );
- rc = sqlite3RunVacuum(&p->zErrMsg, db, pOp->p1);
+ rc = sqlite3RunVacuum(&p->zErrMsg, db, pOp->p1,
+ pOp->p2 ? &aMem[pOp->p2] : 0);
if( rc ) goto abort_due_to_error;
break;
}
@@ -89928,6 +90318,7 @@ case OP_VDestroy: {
db->nVDestroy++;
rc = sqlite3VtabCallDestroy(db, pOp->p1, pOp->p4.z);
db->nVDestroy--;
+ assert( p->errorAction==OE_Abort && p->usesStmtJournal );
if( rc ) goto abort_due_to_error;
break;
}
@@ -90171,7 +90562,7 @@ case OP_VRename: {
rc = sqlite3VdbeChangeEncoding(pName, SQLITE_UTF8);
if( rc ) goto abort_due_to_error;
rc = pVtab->pModule->xRename(pVtab, pName->z);
- if( isLegacy==0 ) db->flags &= ~SQLITE_LegacyAlter;
+ if( isLegacy==0 ) db->flags &= ~(u64)SQLITE_LegacyAlter;
sqlite3VtabImportErrmsg(p, pVtab);
p->expired = 0;
if( rc ) goto abort_due_to_error;
@@ -94398,6 +94789,22 @@ SQLITE_PRIVATE int sqlite3JournalSize(sqlite3_vfs *pVfs){
/* #include <string.h> */
+#if !defined(SQLITE_OMIT_WINDOWFUNC)
+/*
+** Walk all expressions linked into the list of Window objects passed
+** as the second argument.
+*/
+static int walkWindowList(Walker *pWalker, Window *pList){
+ Window *pWin;
+ for(pWin=pList; pWin; pWin=pWin->pNextWin){
+ if( sqlite3WalkExprList(pWalker, pWin->pOrderBy) ) return WRC_Abort;
+ if( sqlite3WalkExprList(pWalker, pWin->pPartition) ) return WRC_Abort;
+ if( sqlite3WalkExpr(pWalker, pWin->pFilter) ) return WRC_Abort;
+ }
+ return WRC_Continue;
+}
+#endif
+
/*
** Walk an expression tree. Invoke the callback once for each node
** of the expression, while descending. (In other words, the callback
@@ -94437,10 +94844,7 @@ static SQLITE_NOINLINE int walkExpr(Walker *pWalker, Expr *pExpr){
}
#ifndef SQLITE_OMIT_WINDOWFUNC
if( ExprHasProperty(pExpr, EP_WinFunc) ){
- Window *pWin = pExpr->y.pWin;
- if( sqlite3WalkExprList(pWalker, pWin->pPartition) ) return WRC_Abort;
- if( sqlite3WalkExprList(pWalker, pWin->pOrderBy) ) return WRC_Abort;
- if( sqlite3WalkExpr(pWalker, pWin->pFilter) ) return WRC_Abort;
+ if( walkWindowList(pWalker, pExpr->y.pWin) ) return WRC_Abort;
}
#endif
}
@@ -94480,6 +94884,16 @@ SQLITE_PRIVATE int sqlite3WalkSelectExpr(Walker *pWalker, Select *p){
if( sqlite3WalkExpr(pWalker, p->pHaving) ) return WRC_Abort;
if( sqlite3WalkExprList(pWalker, p->pOrderBy) ) return WRC_Abort;
if( sqlite3WalkExpr(pWalker, p->pLimit) ) return WRC_Abort;
+#if !defined(SQLITE_OMIT_WINDOWFUNC) && !defined(SQLITE_OMIT_ALTERTABLE)
+ {
+ Parse *pParse = pWalker->pParse;
+ if( pParse && IN_RENAME_OBJECT ){
+ int rc = walkWindowList(pWalker, p->pWinDefn);
+ assert( rc==WRC_Continue );
+ return rc;
+ }
+ }
+#endif
return WRC_Continue;
}
@@ -94631,7 +95045,6 @@ static void resolveAlias(
if( pExpr->op==TK_COLLATE ){
pDup = sqlite3ExprAddCollateString(pParse, pDup, pExpr->u.zToken);
}
- ExprSetProperty(pDup, EP_Alias);
/* Before calling sqlite3ExprDelete(), set the EP_Static flag. This
** prevents ExprDelete() from deleting the Expr structure itself,
@@ -95025,6 +95438,25 @@ static int lookupName(
if( cnt==0 && zTab==0 ){
assert( pExpr->op==TK_ID );
if( ExprHasProperty(pExpr,EP_DblQuoted) ){
+ /* If a double-quoted identifier does not match any known column name,
+ ** then treat it as a string.
+ **
+ ** This hack was added in the early days of SQLite in a misguided attempt
+ ** to be compatible with MySQL 3.x, which used double-quotes for strings.
+ ** I now sorely regret putting in this hack. The effect of this hack is
+ ** that misspelled identifier names are silently converted into strings
+ ** rather than causing an error, to the frustration of countless
+ ** programmers. To all those frustrated programmers, my apologies.
+ **
+ ** Someday, I hope to get rid of this hack. Unfortunately there is
+ ** a huge amount of legacy SQL that uses it. So for now, we just
+ ** issue a warning.
+ */
+ sqlite3_log(SQLITE_WARNING,
+ "double-quoted string literal: \"%w\"", zCol);
+#ifdef SQLITE_ENABLE_NORMALIZE
+ sqlite3VdbeAddDblquoteStr(db, pParse->pVdbe, zCol);
+#endif
pExpr->op = TK_STRING;
pExpr->y.pTab = 0;
return WRC_Prune;
@@ -95391,10 +95823,10 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
#ifndef SQLITE_OMIT_WINDOWFUNC
if( pExpr->y.pWin ){
Select *pSel = pNC->pWinSelect;
+ sqlite3WindowUpdate(pParse, pSel->pWinDefn, pExpr->y.pWin, pDef);
sqlite3WalkExprList(pWalker, pExpr->y.pWin->pPartition);
sqlite3WalkExprList(pWalker, pExpr->y.pWin->pOrderBy);
sqlite3WalkExpr(pWalker, pExpr->y.pWin->pFilter);
- sqlite3WindowUpdate(pParse, pSel->pWinDefn, pExpr->y.pWin, pDef);
if( 0==pSel->pWin
|| 0==sqlite3WindowCompare(pParse, pSel->pWin, pExpr->y.pWin)
){
@@ -95671,32 +96103,53 @@ static int resolveCompoundOrderBy(
}else{
iCol = resolveAsName(pParse, pEList, pE);
if( iCol==0 ){
- pDup = sqlite3ExprDup(db, pE, 0);
+ /* Now test if expression pE matches one of the values returned
+ ** by pSelect. In the usual case this is done by duplicating the
+ ** expression, resolving any symbols in it, and then comparing
+ ** it against each expression returned by the SELECT statement.
+ ** Once the comparisons are finished, the duplicate expression
+ ** is deleted.
+ **
+ ** Or, if this is running as part of an ALTER TABLE operation,
+ ** resolve the symbols in the actual expression, not a duplicate.
+ ** And, if one of the comparisons is successful, leave the expression
+ ** as is instead of transforming it to an integer as in the usual
+ ** case. This allows the code in alter.c to modify column
+ ** refererences within the ORDER BY expression as required. */
+ if( IN_RENAME_OBJECT ){
+ pDup = pE;
+ }else{
+ pDup = sqlite3ExprDup(db, pE, 0);
+ }
if( !db->mallocFailed ){
assert(pDup);
iCol = resolveOrderByTermToExprList(pParse, pSelect, pDup);
}
- sqlite3ExprDelete(db, pDup);
+ if( !IN_RENAME_OBJECT ){
+ sqlite3ExprDelete(db, pDup);
+ }
}
}
if( iCol>0 ){
/* Convert the ORDER BY term into an integer column number iCol,
** taking care to preserve the COLLATE clause if it exists */
- Expr *pNew = sqlite3Expr(db, TK_INTEGER, 0);
- if( pNew==0 ) return 1;
- pNew->flags |= EP_IntValue;
- pNew->u.iValue = iCol;
- if( pItem->pExpr==pE ){
- pItem->pExpr = pNew;
- }else{
- Expr *pParent = pItem->pExpr;
- assert( pParent->op==TK_COLLATE );
- while( pParent->pLeft->op==TK_COLLATE ) pParent = pParent->pLeft;
- assert( pParent->pLeft==pE );
- pParent->pLeft = pNew;
+ if( !IN_RENAME_OBJECT ){
+ Expr *pNew = sqlite3Expr(db, TK_INTEGER, 0);
+ if( pNew==0 ) return 1;
+ pNew->flags |= EP_IntValue;
+ pNew->u.iValue = iCol;
+ if( pItem->pExpr==pE ){
+ pItem->pExpr = pNew;
+ }else{
+ Expr *pParent = pItem->pExpr;
+ assert( pParent->op==TK_COLLATE );
+ while( pParent->pLeft->op==TK_COLLATE ) pParent = pParent->pLeft;
+ assert( pParent->pLeft==pE );
+ pParent->pLeft = pNew;
+ }
+ sqlite3ExprDelete(db, pE);
+ pItem->u.x.iOrderByCol = (u16)iCol;
}
- sqlite3ExprDelete(db, pE);
- pItem->u.x.iOrderByCol = (u16)iCol;
pItem->done = 1;
}else{
moreToDo = 1;
@@ -96045,6 +96498,19 @@ static int resolveSelectStep(Walker *pWalker, Select *p){
}
}
+#ifndef SQLITE_OMIT_WINDOWFUNC
+ if( IN_RENAME_OBJECT ){
+ Window *pWin;
+ for(pWin=p->pWinDefn; pWin; pWin=pWin->pNextWin){
+ if( sqlite3ResolveExprListNames(&sNC, pWin->pOrderBy)
+ || sqlite3ResolveExprListNames(&sNC, pWin->pPartition)
+ ){
+ return WRC_Abort;
+ }
+ }
+ }
+#endif
+
/* If this is part of a compound SELECT, check that it has the right
** number of expressions in the select list. */
if( p->pNext && p->pEList->nExpr!=p->pNext->pEList->nExpr ){
@@ -96195,38 +96661,47 @@ SQLITE_PRIVATE void sqlite3ResolveSelectNames(
}
/*
-** Resolve names in expressions that can only reference a single table:
+** Resolve names in expressions that can only reference a single table
+** or which cannot reference any tables at all. Examples:
**
-** * CHECK constraints
-** * WHERE clauses on partial indices
+** (1) CHECK constraints
+** (2) WHERE clauses on partial indices
+** (3) Expressions in indexes on expressions
+** (4) Expression arguments to VACUUM INTO.
**
-** The Expr.iTable value for Expr.op==TK_COLUMN nodes of the expression
-** is set to -1 and the Expr.iColumn value is set to the column number.
+** In all cases except (4), the Expr.iTable value for Expr.op==TK_COLUMN
+** nodes of the expression is set to -1 and the Expr.iColumn value is
+** set to the column number. In case (4), TK_COLUMN nodes cause an error.
**
** Any errors cause an error message to be set in pParse.
*/
-SQLITE_PRIVATE void sqlite3ResolveSelfReference(
+SQLITE_PRIVATE int sqlite3ResolveSelfReference(
Parse *pParse, /* Parsing context */
- Table *pTab, /* The table being referenced */
- int type, /* NC_IsCheck or NC_PartIdx or NC_IdxExpr */
+ Table *pTab, /* The table being referenced, or NULL */
+ int type, /* NC_IsCheck or NC_PartIdx or NC_IdxExpr, or 0 */
Expr *pExpr, /* Expression to resolve. May be NULL. */
ExprList *pList /* Expression list to resolve. May be NULL. */
){
SrcList sSrc; /* Fake SrcList for pParse->pNewTable */
NameContext sNC; /* Name context for pParse->pNewTable */
+ int rc;
- assert( type==NC_IsCheck || type==NC_PartIdx || type==NC_IdxExpr );
+ assert( type==0 || pTab!=0 );
+ assert( type==NC_IsCheck || type==NC_PartIdx || type==NC_IdxExpr || pTab==0 );
memset(&sNC, 0, sizeof(sNC));
memset(&sSrc, 0, sizeof(sSrc));
- sSrc.nSrc = 1;
- sSrc.a[0].zName = pTab->zName;
- sSrc.a[0].pTab = pTab;
- sSrc.a[0].iCursor = -1;
+ if( pTab ){
+ sSrc.nSrc = 1;
+ sSrc.a[0].zName = pTab->zName;
+ sSrc.a[0].pTab = pTab;
+ sSrc.a[0].iCursor = -1;
+ }
sNC.pParse = pParse;
sNC.pSrcList = &sSrc;
sNC.ncFlags = type;
- if( sqlite3ResolveExprNames(&sNC, pExpr) ) return;
- if( pList ) sqlite3ResolveExprListNames(&sNC, pList);
+ if( (rc = sqlite3ResolveExprNames(&sNC, pExpr))!=SQLITE_OK ) return rc;
+ if( pList ) rc = sqlite3ResolveExprListNames(&sNC, pList);
+ return rc;
}
/************** End of resolve.c *********************************************/
@@ -96698,6 +97173,7 @@ SQLITE_PRIVATE Expr *sqlite3ExprForVectorField(
}else{
if( pVector->op==TK_VECTOR ) pVector = pVector->x.pList->a[iField].pExpr;
pRet = sqlite3ExprDup(pParse->db, pVector, 0);
+ sqlite3RenameTokenRemap(pParse, pRet, pVector);
}
return pRet;
}
@@ -96714,7 +97190,7 @@ static int exprCodeSubselect(Parse *pParse, Expr *pExpr){
int reg = 0;
#ifndef SQLITE_OMIT_SUBQUERY
if( pExpr->op==TK_SELECT ){
- reg = sqlite3CodeSubselect(pParse, pExpr, 0, 0);
+ reg = sqlite3CodeSubselect(pParse, pExpr);
}
#endif
return reg;
@@ -96786,7 +97262,7 @@ static void codeVectorCompare(
int regLeft = 0;
int regRight = 0;
u8 opx = op;
- int addrDone = sqlite3VdbeMakeLabel(v);
+ int addrDone = sqlite3VdbeMakeLabel(pParse);
if( nLeft!=sqlite3ExprVectorSize(pRight) ){
sqlite3ErrorMsg(pParse, "row value misused");
@@ -97013,8 +97489,7 @@ SQLITE_PRIVATE Expr *sqlite3ExprAlloc(
if( pToken->n ) memcpy(pNew->u.zToken, pToken->z, pToken->n);
pNew->u.zToken[pToken->n] = 0;
if( dequote && sqlite3Isquote(pNew->u.zToken[0]) ){
- if( pNew->u.zToken[0]=='"' ) pNew->flags |= EP_DblQuoted;
- sqlite3Dequote(pNew->u.zToken);
+ sqlite3DequoteExpr(pNew);
}
}
}
@@ -97083,7 +97558,7 @@ SQLITE_PRIVATE Expr *sqlite3PExpr(
Expr *pRight /* Right operand */
){
Expr *p;
- if( op==TK_AND && pParse->nErr==0 ){
+ if( op==TK_AND && pParse->nErr==0 && !IN_RENAME_OBJECT ){
/* Take advantage of short-circuit false optimization for AND */
p = sqlite3ExprAnd(pParse->db, pLeft, pRight);
}else{
@@ -97333,6 +97808,16 @@ static int exprStructSize(Expr *p){
}
/*
+** Copy the complete content of an Expr node, taking care not to read
+** past the end of the structure for a reduced-size version of the source
+** Expr.
+*/
+static void exprNodeCopy(Expr *pDest, Expr *pSrc){
+ memset(pDest, 0, sizeof(Expr));
+ memcpy(pDest, pSrc, exprStructSize(pSrc));
+}
+
+/*
** The dupedExpr*Size() routines each return the number of bytes required
** to store a copy of an expression or expression tree. They differ in
** how much of the tree is measured.
@@ -97563,6 +98048,36 @@ static With *withDup(sqlite3 *db, With *p){
# define withDup(x,y) 0
#endif
+#ifndef SQLITE_OMIT_WINDOWFUNC
+/*
+** The gatherSelectWindows() procedure and its helper routine
+** gatherSelectWindowsCallback() are used to scan all the expressions
+** an a newly duplicated SELECT statement and gather all of the Window
+** objects found there, assembling them onto the linked list at Select->pWin.
+*/
+static int gatherSelectWindowsCallback(Walker *pWalker, Expr *pExpr){
+ if( pExpr->op==TK_FUNCTION && pExpr->y.pWin!=0 ){
+ assert( ExprHasProperty(pExpr, EP_WinFunc) );
+ pExpr->y.pWin->pNextWin = pWalker->u.pSelect->pWin;
+ pWalker->u.pSelect->pWin = pExpr->y.pWin;
+ }
+ return WRC_Continue;
+}
+static int gatherSelectWindowsSelectCallback(Walker *pWalker, Select *p){
+ return p==pWalker->u.pSelect ? WRC_Continue : WRC_Prune;
+}
+static void gatherSelectWindows(Select *p){
+ Walker w;
+ w.xExprCallback = gatherSelectWindowsCallback;
+ w.xSelectCallback = gatherSelectWindowsSelectCallback;
+ w.xSelectCallback2 = 0;
+ w.pParse = 0;
+ w.u.pSelect = p;
+ sqlite3WalkSelect(&w, p);
+}
+#endif
+
+
/*
** The following group of routines make deep copies of expressions,
** expression lists, ID lists, and select statements. The copies can
@@ -97730,6 +98245,7 @@ SQLITE_PRIVATE Select *sqlite3SelectDup(sqlite3 *db, Select *pDup, int flags){
#ifndef SQLITE_OMIT_WINDOWFUNC
pNew->pWin = 0;
pNew->pWinDefn = sqlite3WindowListDup(db, p->pWinDefn);
+ if( p->pWin ) gatherSelectWindows(pNew);
#endif
pNew->selId = p->selId;
*pp = pNew;
@@ -97862,6 +98378,9 @@ SQLITE_PRIVATE ExprList *sqlite3ExprListAppendVector(
}
vector_append_error:
+ if( IN_RENAME_OBJECT ){
+ sqlite3RenameExprUnmap(pParse, pExpr);
+ }
sqlite3ExprDelete(db, pExpr);
sqlite3IdListDelete(db, pColumns);
return pList;
@@ -98005,8 +98524,9 @@ SQLITE_PRIVATE int sqlite3SelectWalkFail(Walker *pWalker, Select *NotUsed){
*/
SQLITE_PRIVATE int sqlite3ExprIdToTrueFalse(Expr *pExpr){
assert( pExpr->op==TK_ID || pExpr->op==TK_STRING );
- if( sqlite3StrICmp(pExpr->u.zToken, "true")==0
- || sqlite3StrICmp(pExpr->u.zToken, "false")==0
+ if( !ExprHasProperty(pExpr, EP_Quoted)
+ && (sqlite3StrICmp(pExpr->u.zToken, "true")==0
+ || sqlite3StrICmp(pExpr->u.zToken, "false")==0)
){
pExpr->op = TK_TRUEFALSE;
return 1;
@@ -98315,7 +98835,9 @@ SQLITE_PRIVATE int sqlite3ExprIsInteger(Expr *p, int *pValue){
*/
SQLITE_PRIVATE int sqlite3ExprCanBeNull(const Expr *p){
u8 op;
- while( p->op==TK_UPLUS || p->op==TK_UMINUS ){ p = p->pLeft; }
+ while( p->op==TK_UPLUS || p->op==TK_UMINUS ){
+ p = p->pLeft;
+ }
op = p->op;
if( op==TK_REGISTER ) op = p->op2;
switch( op ){
@@ -98382,14 +98904,6 @@ SQLITE_PRIVATE int sqlite3IsRowid(const char *z){
if( sqlite3StrICmp(z, "OID")==0 ) return 1;
return 0;
}
-#ifdef SQLITE_ENABLE_NORMALIZE
-SQLITE_PRIVATE int sqlite3IsRowidN(const char *z, int n){
- if( sqlite3StrNICmp(z, "_ROWID_", n)==0 ) return 1;
- if( sqlite3StrNICmp(z, "ROWID", n)==0 ) return 1;
- if( sqlite3StrNICmp(z, "OID", n)==0 ) return 1;
- return 0;
-}
-#endif
/*
** pX is the RHS of an IN operator. If pX is a SELECT statement
@@ -98559,7 +99073,8 @@ SQLITE_PRIVATE int sqlite3FindInIndex(
Expr *pX, /* The right-hand side (RHS) of the IN operator */
u32 inFlags, /* IN_INDEX_LOOP, _MEMBERSHIP, and/or _NOOP_OK */
int *prRhsHasNull, /* Register holding NULL status. See notes */
- int *aiMap /* Mapping from Index fields to RHS fields */
+ int *aiMap, /* Mapping from Index fields to RHS fields */
+ int *piTab /* OUT: index to use */
){
Select *p; /* SELECT to the right of IN operator */
int eType = 0; /* Type of RHS table. IN_INDEX_* */
@@ -98654,6 +99169,7 @@ SQLITE_PRIVATE int sqlite3FindInIndex(
Bitmask colUsed; /* Columns of the index used */
Bitmask mCol; /* Mask for the current column */
if( pIdx->nColumn<nExpr ) continue;
+ if( pIdx->pPartIdxWhere!=0 ) continue;
/* Maximum nColumn is BMS-2, not BMS-1, so that we can compute
** BITMASK(nExpr) without overflowing */
testcase( pIdx->nColumn==BMS-2 );
@@ -98750,10 +99266,12 @@ SQLITE_PRIVATE int sqlite3FindInIndex(
}else if( prRhsHasNull ){
*prRhsHasNull = rMayHaveNull = ++pParse->nMem;
}
- sqlite3CodeSubselect(pParse, pX, rMayHaveNull, eType==IN_INDEX_ROWID);
+ assert( pX->op==TK_IN );
+ sqlite3CodeRhsOfIN(pParse, pX, iTab, eType==IN_INDEX_ROWID);
+ if( rMayHaveNull ){
+ sqlite3SetHasNullFlag(v, iTab, rMayHaveNull);
+ }
pParse->nQueryLoop = savedNQueryLoop;
- }else{
- pX->iTable = iTab;
}
if( aiMap && eType!=IN_INDEX_INDEX_ASC && eType!=IN_INDEX_INDEX_DESC ){
@@ -98761,6 +99279,7 @@ SQLITE_PRIVATE int sqlite3FindInIndex(
n = sqlite3ExprVectorSize(pX->pLeft);
for(i=0; i<n; i++) aiMap[i] = i;
}
+ *piTab = iTab;
return eType;
}
#endif
@@ -98834,260 +99353,326 @@ SQLITE_PRIVATE void sqlite3VectorErrorMsg(Parse *pParse, Expr *pExpr){
}
}
+#ifndef SQLITE_OMIT_SUBQUERY
/*
-** Generate code for scalar subqueries used as a subquery expression, EXISTS,
-** or IN operators. Examples:
+** Generate code that will construct an ephemeral table containing all terms
+** in the RHS of an IN operator. The IN operator can be in either of two
+** forms:
**
-** (SELECT a FROM b) -- subquery
-** EXISTS (SELECT a FROM b) -- EXISTS subquery
** x IN (4,5,11) -- IN operator with list on right-hand side
** x IN (SELECT a FROM b) -- IN operator with subquery on the right
**
-** The pExpr parameter describes the expression that contains the IN
-** operator or subquery.
-**
-** If parameter isRowid is non-zero, then expression pExpr is guaranteed
-** to be of the form "<rowid> IN (?, ?, ?)", where <rowid> is a reference
-** to some integer key column of a table B-Tree. In this case, use an
-** intkey B-Tree to store the set of IN(...) values instead of the usual
-** (slower) variable length keys B-Tree.
-**
-** If rMayHaveNull is non-zero, that means that the operation is an IN
-** (not a SELECT or EXISTS) and that the RHS might contains NULLs.
-** All this routine does is initialize the register given by rMayHaveNull
-** to NULL. Calling routines will take care of changing this register
-** value to non-NULL if the RHS is NULL-free.
-**
-** For a SELECT or EXISTS operator, return the register that holds the
-** result. For a multi-column SELECT, the result is stored in a contiguous
-** array of registers and the return value is the register of the left-most
-** result column. Return 0 for IN operators or if an error occurs.
-*/
-#ifndef SQLITE_OMIT_SUBQUERY
-SQLITE_PRIVATE int sqlite3CodeSubselect(
+** The pExpr parameter is the IN operator. The cursor number for the
+** constructed ephermeral table is returned. The first time the ephemeral
+** table is computed, the cursor number is also stored in pExpr->iTable,
+** however the cursor number returned might not be the same, as it might
+** have been duplicated using OP_OpenDup.
+**
+** If parameter isRowid is non-zero, then LHS of the IN operator is guaranteed
+** to be a non-null integer. In this case, the ephemeral table can be an
+** table B-Tree that keyed by only integers. The more general cases uses
+** an index B-Tree which can have arbitrary keys, but is slower to both
+** read and write.
+**
+** If the LHS expression ("x" in the examples) is a column value, or
+** the SELECT statement returns a column value, then the affinity of that
+** column is used to build the index keys. If both 'x' and the
+** SELECT... statement are columns, then numeric affinity is used
+** if either column has NUMERIC or INTEGER affinity. If neither
+** 'x' nor the SELECT... statement are columns, then numeric affinity
+** is used.
+*/
+SQLITE_PRIVATE void sqlite3CodeRhsOfIN(
Parse *pParse, /* Parsing context */
- Expr *pExpr, /* The IN, SELECT, or EXISTS operator */
- int rHasNullFlag, /* Register that records whether NULLs exist in RHS */
- int isRowid /* If true, LHS of IN operator is a rowid */
+ Expr *pExpr, /* The IN operator */
+ int iTab, /* Use this cursor number */
+ int isRowid /* If true, LHS is a rowid */
){
- int jmpIfDynamic = -1; /* One-time test address */
- int rReg = 0; /* Register storing resulting */
- Vdbe *v = sqlite3GetVdbe(pParse);
- if( NEVER(v==0) ) return 0;
+ int addrOnce = 0; /* Address of the OP_Once instruction at top */
+ int addr; /* Address of OP_OpenEphemeral instruction */
+ Expr *pLeft; /* the LHS of the IN operator */
+ KeyInfo *pKeyInfo = 0; /* Key information */
+ int nVal; /* Size of vector pLeft */
+ Vdbe *v; /* The prepared statement under construction */
- /* The evaluation of the IN/EXISTS/SELECT must be repeated every time it
+ v = pParse->pVdbe;
+ assert( v!=0 );
+
+ /* The evaluation of the IN must be repeated every time it
** is encountered if any of the following is true:
**
** * The right-hand side is a correlated subquery
** * The right-hand side is an expression list containing variables
** * We are inside a trigger
**
- ** If all of the above are false, then we can run this code just once
- ** save the results, and reuse the same result on subsequent invocations.
+ ** If all of the above are false, then we can compute the RHS just once
+ ** and reuse it many names.
*/
- if( !ExprHasProperty(pExpr, EP_VarSelect) ){
- jmpIfDynamic = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v);
+ if( !ExprHasProperty(pExpr, EP_VarSelect) && pParse->iSelfTab==0 ){
+ /* Reuse of the RHS is allowed */
+ /* If this routine has already been coded, but the previous code
+ ** might not have been invoked yet, so invoke it now as a subroutine.
+ */
+ if( ExprHasProperty(pExpr, EP_Subrtn) ){
+ addrOnce = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v);
+ if( ExprHasProperty(pExpr, EP_xIsSelect) ){
+ ExplainQueryPlan((pParse, 0, "REUSE LIST SUBQUERY %d",
+ pExpr->x.pSelect->selId));
+ }
+ sqlite3VdbeAddOp2(v, OP_Gosub, pExpr->y.sub.regReturn,
+ pExpr->y.sub.iAddr);
+ sqlite3VdbeAddOp2(v, OP_OpenDup, iTab, pExpr->iTable);
+ sqlite3VdbeJumpHere(v, addrOnce);
+ return;
+ }
+
+ /* Begin coding the subroutine */
+ ExprSetProperty(pExpr, EP_Subrtn);
+ pExpr->y.sub.regReturn = ++pParse->nMem;
+ pExpr->y.sub.iAddr =
+ sqlite3VdbeAddOp2(v, OP_Integer, 0, pExpr->y.sub.regReturn) + 1;
+ VdbeComment((v, "return address"));
+
+ addrOnce = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v);
}
- switch( pExpr->op ){
- case TK_IN: {
- int addr; /* Address of OP_OpenEphemeral instruction */
- Expr *pLeft = pExpr->pLeft; /* the LHS of the IN operator */
- KeyInfo *pKeyInfo = 0; /* Key information */
- int nVal; /* Size of vector pLeft */
-
- nVal = sqlite3ExprVectorSize(pLeft);
- assert( !isRowid || nVal==1 );
-
- /* Whether this is an 'x IN(SELECT...)' or an 'x IN(<exprlist>)'
- ** expression it is handled the same way. An ephemeral table is
- ** filled with index keys representing the results from the
- ** SELECT or the <exprlist>.
- **
- ** If the 'x' expression is a column value, or the SELECT...
- ** statement returns a column value, then the affinity of that
- ** column is used to build the index keys. If both 'x' and the
- ** SELECT... statement are columns, then numeric affinity is used
- ** if either column has NUMERIC or INTEGER affinity. If neither
- ** 'x' nor the SELECT... statement are columns, then numeric affinity
- ** is used.
- */
- pExpr->iTable = pParse->nTab++;
- addr = sqlite3VdbeAddOp2(v, OP_OpenEphemeral,
- pExpr->iTable, (isRowid?0:nVal));
- pKeyInfo = isRowid ? 0 : sqlite3KeyInfoAlloc(pParse->db, nVal, 1);
+ /* Check to see if this is a vector IN operator */
+ pLeft = pExpr->pLeft;
+ nVal = sqlite3ExprVectorSize(pLeft);
+ assert( !isRowid || nVal==1 );
- if( ExprHasProperty(pExpr, EP_xIsSelect) ){
- /* Case 1: expr IN (SELECT ...)
- **
- ** Generate code to write the results of the select into the temporary
- ** table allocated and opened above.
- */
- Select *pSelect = pExpr->x.pSelect;
- ExprList *pEList = pSelect->pEList;
-
- ExplainQueryPlan((pParse, 1, "%sLIST SUBQUERY",
- jmpIfDynamic>=0?"":"CORRELATED "
- ));
- assert( !isRowid );
- /* If the LHS and RHS of the IN operator do not match, that
- ** error will have been caught long before we reach this point. */
- if( ALWAYS(pEList->nExpr==nVal) ){
- SelectDest dest;
- int i;
- sqlite3SelectDestInit(&dest, SRT_Set, pExpr->iTable);
- dest.zAffSdst = exprINAffinity(pParse, pExpr);
- pSelect->iLimit = 0;
- testcase( pSelect->selFlags & SF_Distinct );
- testcase( pKeyInfo==0 ); /* Caused by OOM in sqlite3KeyInfoAlloc() */
- if( sqlite3Select(pParse, pSelect, &dest) ){
- sqlite3DbFree(pParse->db, dest.zAffSdst);
- sqlite3KeyInfoUnref(pKeyInfo);
- return 0;
- }
- sqlite3DbFree(pParse->db, dest.zAffSdst);
- assert( pKeyInfo!=0 ); /* OOM will cause exit after sqlite3Select() */
- assert( pEList!=0 );
- assert( pEList->nExpr>0 );
- assert( sqlite3KeyInfoIsWriteable(pKeyInfo) );
- for(i=0; i<nVal; i++){
- Expr *p = sqlite3VectorFieldSubexpr(pLeft, i);
- pKeyInfo->aColl[i] = sqlite3BinaryCompareCollSeq(
- pParse, p, pEList->a[i].pExpr
- );
- }
- }
- }else if( ALWAYS(pExpr->x.pList!=0) ){
- /* Case 2: expr IN (exprlist)
- **
- ** For each expression, build an index key from the evaluation and
- ** store it in the temporary table. If <expr> is a column, then use
- ** that columns affinity when building index keys. If <expr> is not
- ** a column, use numeric affinity.
- */
- char affinity; /* Affinity of the LHS of the IN */
- int i;
- ExprList *pList = pExpr->x.pList;
- struct ExprList_item *pItem;
- int r1, r2, r3;
- affinity = sqlite3ExprAffinity(pLeft);
- if( !affinity ){
- affinity = SQLITE_AFF_BLOB;
- }
- if( pKeyInfo ){
- assert( sqlite3KeyInfoIsWriteable(pKeyInfo) );
- pKeyInfo->aColl[0] = sqlite3ExprCollSeq(pParse, pExpr->pLeft);
- }
+ /* Construct the ephemeral table that will contain the content of
+ ** RHS of the IN operator.
+ */
+ pExpr->iTable = iTab;
+ addr = sqlite3VdbeAddOp2(v, OP_OpenEphemeral,
+ pExpr->iTable, (isRowid?0:nVal));
+#ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS
+ if( ExprHasProperty(pExpr, EP_xIsSelect) ){
+ VdbeComment((v, "Result of SELECT %u", pExpr->x.pSelect->selId));
+ }else{
+ VdbeComment((v, "RHS of IN operator"));
+ }
+#endif
+ pKeyInfo = isRowid ? 0 : sqlite3KeyInfoAlloc(pParse->db, nVal, 1);
- /* Loop through each expression in <exprlist>. */
- r1 = sqlite3GetTempReg(pParse);
- r2 = sqlite3GetTempReg(pParse);
- if( isRowid ) sqlite3VdbeAddOp4(v, OP_Blob, 0, r2, 0, "", P4_STATIC);
- for(i=pList->nExpr, pItem=pList->a; i>0; i--, pItem++){
- Expr *pE2 = pItem->pExpr;
- int iValToIns;
-
- /* If the expression is not constant then we will need to
- ** disable the test that was generated above that makes sure
- ** this code only executes once. Because for a non-constant
- ** expression we need to rerun this code each time.
- */
- if( jmpIfDynamic>=0 && !sqlite3ExprIsConstant(pE2) ){
- sqlite3VdbeChangeToNoop(v, jmpIfDynamic);
- jmpIfDynamic = -1;
- }
+ if( ExprHasProperty(pExpr, EP_xIsSelect) ){
+ /* Case 1: expr IN (SELECT ...)
+ **
+ ** Generate code to write the results of the select into the temporary
+ ** table allocated and opened above.
+ */
+ Select *pSelect = pExpr->x.pSelect;
+ ExprList *pEList = pSelect->pEList;
- /* Evaluate the expression and insert it into the temp table */
- if( isRowid && sqlite3ExprIsInteger(pE2, &iValToIns) ){
- sqlite3VdbeAddOp3(v, OP_InsertInt, pExpr->iTable, r2, iValToIns);
- }else{
- r3 = sqlite3ExprCodeTarget(pParse, pE2, r1);
- if( isRowid ){
- sqlite3VdbeAddOp2(v, OP_MustBeInt, r3,
- sqlite3VdbeCurrentAddr(v)+2);
- VdbeCoverage(v);
- sqlite3VdbeAddOp3(v, OP_Insert, pExpr->iTable, r2, r3);
- }else{
- sqlite3VdbeAddOp4(v, OP_MakeRecord, r3, 1, r2, &affinity, 1);
- sqlite3VdbeAddOp4Int(v, OP_IdxInsert, pExpr->iTable, r2, r3, 1);
- }
- }
- }
- sqlite3ReleaseTempReg(pParse, r1);
- sqlite3ReleaseTempReg(pParse, r2);
+ ExplainQueryPlan((pParse, 1, "%sLIST SUBQUERY %d",
+ addrOnce?"":"CORRELATED ", pSelect->selId
+ ));
+ assert( !isRowid );
+ /* If the LHS and RHS of the IN operator do not match, that
+ ** error will have been caught long before we reach this point. */
+ if( ALWAYS(pEList->nExpr==nVal) ){
+ SelectDest dest;
+ int i;
+ sqlite3SelectDestInit(&dest, SRT_Set, iTab);
+ dest.zAffSdst = exprINAffinity(pParse, pExpr);
+ pSelect->iLimit = 0;
+ testcase( pSelect->selFlags & SF_Distinct );
+ testcase( pKeyInfo==0 ); /* Caused by OOM in sqlite3KeyInfoAlloc() */
+ if( sqlite3Select(pParse, pSelect, &dest) ){
+ sqlite3DbFree(pParse->db, dest.zAffSdst);
+ sqlite3KeyInfoUnref(pKeyInfo);
+ return;
}
- if( pKeyInfo ){
- sqlite3VdbeChangeP4(v, addr, (void *)pKeyInfo, P4_KEYINFO);
+ sqlite3DbFree(pParse->db, dest.zAffSdst);
+ assert( pKeyInfo!=0 ); /* OOM will cause exit after sqlite3Select() */
+ assert( pEList!=0 );
+ assert( pEList->nExpr>0 );
+ assert( sqlite3KeyInfoIsWriteable(pKeyInfo) );
+ for(i=0; i<nVal; i++){
+ Expr *p = sqlite3VectorFieldSubexpr(pLeft, i);
+ pKeyInfo->aColl[i] = sqlite3BinaryCompareCollSeq(
+ pParse, p, pEList->a[i].pExpr
+ );
}
- break;
+ }
+ }else if( ALWAYS(pExpr->x.pList!=0) ){
+ /* Case 2: expr IN (exprlist)
+ **
+ ** For each expression, build an index key from the evaluation and
+ ** store it in the temporary table. If <expr> is a column, then use
+ ** that columns affinity when building index keys. If <expr> is not
+ ** a column, use numeric affinity.
+ */
+ char affinity; /* Affinity of the LHS of the IN */
+ int i;
+ ExprList *pList = pExpr->x.pList;
+ struct ExprList_item *pItem;
+ int r1, r2, r3;
+ affinity = sqlite3ExprAffinity(pLeft);
+ if( !affinity ){
+ affinity = SQLITE_AFF_BLOB;
+ }
+ if( pKeyInfo ){
+ assert( sqlite3KeyInfoIsWriteable(pKeyInfo) );
+ pKeyInfo->aColl[0] = sqlite3ExprCollSeq(pParse, pExpr->pLeft);
}
- case TK_EXISTS:
- case TK_SELECT:
- default: {
- /* Case 3: (SELECT ... FROM ...)
- ** or: EXISTS(SELECT ... FROM ...)
- **
- ** For a SELECT, generate code to put the values for all columns of
- ** the first row into an array of registers and return the index of
- ** the first register.
- **
- ** If this is an EXISTS, write an integer 0 (not exists) or 1 (exists)
- ** into a register and return that register number.
- **
- ** In both cases, the query is augmented with "LIMIT 1". Any
- ** preexisting limit is discarded in place of the new LIMIT 1.
+ /* Loop through each expression in <exprlist>. */
+ r1 = sqlite3GetTempReg(pParse);
+ r2 = sqlite3GetTempReg(pParse);
+ if( isRowid ) sqlite3VdbeAddOp4(v, OP_Blob, 0, r2, 0, "", P4_STATIC);
+ for(i=pList->nExpr, pItem=pList->a; i>0; i--, pItem++){
+ Expr *pE2 = pItem->pExpr;
+ int iValToIns;
+
+ /* If the expression is not constant then we will need to
+ ** disable the test that was generated above that makes sure
+ ** this code only executes once. Because for a non-constant
+ ** expression we need to rerun this code each time.
*/
- Select *pSel; /* SELECT statement to encode */
- SelectDest dest; /* How to deal with SELECT result */
- int nReg; /* Registers to allocate */
- Expr *pLimit; /* New limit expression */
-
- testcase( pExpr->op==TK_EXISTS );
- testcase( pExpr->op==TK_SELECT );
- assert( pExpr->op==TK_EXISTS || pExpr->op==TK_SELECT );
- assert( ExprHasProperty(pExpr, EP_xIsSelect) );
+ if( addrOnce && !sqlite3ExprIsConstant(pE2) ){
+ sqlite3VdbeChangeToNoop(v, addrOnce);
+ addrOnce = 0;
+ }
- pSel = pExpr->x.pSelect;
- ExplainQueryPlan((pParse, 1, "%sSCALAR SUBQUERY",
- jmpIfDynamic>=0?"":"CORRELATED "));
- nReg = pExpr->op==TK_SELECT ? pSel->pEList->nExpr : 1;
- sqlite3SelectDestInit(&dest, 0, pParse->nMem+1);
- pParse->nMem += nReg;
- if( pExpr->op==TK_SELECT ){
- dest.eDest = SRT_Mem;
- dest.iSdst = dest.iSDParm;
- dest.nSdst = nReg;
- sqlite3VdbeAddOp3(v, OP_Null, 0, dest.iSDParm, dest.iSDParm+nReg-1);
- VdbeComment((v, "Init subquery result"));
- }else{
- dest.eDest = SRT_Exists;
- sqlite3VdbeAddOp2(v, OP_Integer, 0, dest.iSDParm);
- VdbeComment((v, "Init EXISTS result"));
- }
- pLimit = sqlite3ExprAlloc(pParse->db, TK_INTEGER,&sqlite3IntTokens[1], 0);
- if( pSel->pLimit ){
- sqlite3ExprDelete(pParse->db, pSel->pLimit->pLeft);
- pSel->pLimit->pLeft = pLimit;
+ /* Evaluate the expression and insert it into the temp table */
+ if( isRowid && sqlite3ExprIsInteger(pE2, &iValToIns) ){
+ sqlite3VdbeAddOp3(v, OP_InsertInt, iTab, r2, iValToIns);
}else{
- pSel->pLimit = sqlite3PExpr(pParse, TK_LIMIT, pLimit, 0);
- }
- pSel->iLimit = 0;
- if( sqlite3Select(pParse, pSel, &dest) ){
- return 0;
+ r3 = sqlite3ExprCodeTarget(pParse, pE2, r1);
+ if( isRowid ){
+ sqlite3VdbeAddOp2(v, OP_MustBeInt, r3,
+ sqlite3VdbeCurrentAddr(v)+2);
+ VdbeCoverage(v);
+ sqlite3VdbeAddOp3(v, OP_Insert, iTab, r2, r3);
+ }else{
+ sqlite3VdbeAddOp4(v, OP_MakeRecord, r3, 1, r2, &affinity, 1);
+ sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iTab, r2, r3, 1);
+ }
}
- rReg = dest.iSDParm;
- ExprSetVVAProperty(pExpr, EP_NoReduce);
- break;
}
+ sqlite3ReleaseTempReg(pParse, r1);
+ sqlite3ReleaseTempReg(pParse, r2);
+ }
+ if( pKeyInfo ){
+ sqlite3VdbeChangeP4(v, addr, (void *)pKeyInfo, P4_KEYINFO);
+ }
+ if( addrOnce ){
+ sqlite3VdbeJumpHere(v, addrOnce);
+ /* Subroutine return */
+ sqlite3VdbeAddOp1(v, OP_Return, pExpr->y.sub.regReturn);
+ sqlite3VdbeChangeP1(v, pExpr->y.sub.iAddr-1, sqlite3VdbeCurrentAddr(v)-1);
+ }
+}
+#endif /* SQLITE_OMIT_SUBQUERY */
+
+/*
+** Generate code for scalar subqueries used as a subquery expression
+** or EXISTS operator:
+**
+** (SELECT a FROM b) -- subquery
+** EXISTS (SELECT a FROM b) -- EXISTS subquery
+**
+** The pExpr parameter is the SELECT or EXISTS operator to be coded.
+**
+** The register that holds the result. For a multi-column SELECT,
+** the result is stored in a contiguous array of registers and the
+** return value is the register of the left-most result column.
+** Return 0 if an error occurs.
+*/
+#ifndef SQLITE_OMIT_SUBQUERY
+SQLITE_PRIVATE int sqlite3CodeSubselect(Parse *pParse, Expr *pExpr){
+ int addrOnce = 0; /* Address of OP_Once at top of subroutine */
+ int rReg = 0; /* Register storing resulting */
+ Select *pSel; /* SELECT statement to encode */
+ SelectDest dest; /* How to deal with SELECT result */
+ int nReg; /* Registers to allocate */
+ Expr *pLimit; /* New limit expression */
+
+ Vdbe *v = pParse->pVdbe;
+ assert( v!=0 );
+ testcase( pExpr->op==TK_EXISTS );
+ testcase( pExpr->op==TK_SELECT );
+ assert( pExpr->op==TK_EXISTS || pExpr->op==TK_SELECT );
+ assert( ExprHasProperty(pExpr, EP_xIsSelect) );
+ pSel = pExpr->x.pSelect;
+
+ /* The evaluation of the EXISTS/SELECT must be repeated every time it
+ ** is encountered if any of the following is true:
+ **
+ ** * The right-hand side is a correlated subquery
+ ** * The right-hand side is an expression list containing variables
+ ** * We are inside a trigger
+ **
+ ** If all of the above are false, then we can run this code just once
+ ** save the results, and reuse the same result on subsequent invocations.
+ */
+ if( !ExprHasProperty(pExpr, EP_VarSelect) ){
+ /* If this routine has already been coded, then invoke it as a
+ ** subroutine. */
+ if( ExprHasProperty(pExpr, EP_Subrtn) ){
+ ExplainQueryPlan((pParse, 0, "REUSE SUBQUERY %d", pSel->selId));
+ sqlite3VdbeAddOp2(v, OP_Gosub, pExpr->y.sub.regReturn,
+ pExpr->y.sub.iAddr);
+ return pExpr->iTable;
+ }
+
+ /* Begin coding the subroutine */
+ ExprSetProperty(pExpr, EP_Subrtn);
+ pExpr->y.sub.regReturn = ++pParse->nMem;
+ pExpr->y.sub.iAddr =
+ sqlite3VdbeAddOp2(v, OP_Integer, 0, pExpr->y.sub.regReturn) + 1;
+ VdbeComment((v, "return address"));
+
+ addrOnce = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v);
}
- if( rHasNullFlag ){
- sqlite3SetHasNullFlag(v, pExpr->iTable, rHasNullFlag);
+ /* For a SELECT, generate code to put the values for all columns of
+ ** the first row into an array of registers and return the index of
+ ** the first register.
+ **
+ ** If this is an EXISTS, write an integer 0 (not exists) or 1 (exists)
+ ** into a register and return that register number.
+ **
+ ** In both cases, the query is augmented with "LIMIT 1". Any
+ ** preexisting limit is discarded in place of the new LIMIT 1.
+ */
+ ExplainQueryPlan((pParse, 1, "%sSCALAR SUBQUERY %d",
+ addrOnce?"":"CORRELATED ", pSel->selId));
+ nReg = pExpr->op==TK_SELECT ? pSel->pEList->nExpr : 1;
+ sqlite3SelectDestInit(&dest, 0, pParse->nMem+1);
+ pParse->nMem += nReg;
+ if( pExpr->op==TK_SELECT ){
+ dest.eDest = SRT_Mem;
+ dest.iSdst = dest.iSDParm;
+ dest.nSdst = nReg;
+ sqlite3VdbeAddOp3(v, OP_Null, 0, dest.iSDParm, dest.iSDParm+nReg-1);
+ VdbeComment((v, "Init subquery result"));
+ }else{
+ dest.eDest = SRT_Exists;
+ sqlite3VdbeAddOp2(v, OP_Integer, 0, dest.iSDParm);
+ VdbeComment((v, "Init EXISTS result"));
+ }
+ pLimit = sqlite3ExprAlloc(pParse->db, TK_INTEGER,&sqlite3IntTokens[1], 0);
+ if( pSel->pLimit ){
+ sqlite3ExprDelete(pParse->db, pSel->pLimit->pLeft);
+ pSel->pLimit->pLeft = pLimit;
+ }else{
+ pSel->pLimit = sqlite3PExpr(pParse, TK_LIMIT, pLimit, 0);
}
+ pSel->iLimit = 0;
+ if( sqlite3Select(pParse, pSel, &dest) ){
+ return 0;
+ }
+ pExpr->iTable = rReg = dest.iSDParm;
+ ExprSetVVAProperty(pExpr, EP_NoReduce);
+ if( addrOnce ){
+ sqlite3VdbeJumpHere(v, addrOnce);
- if( jmpIfDynamic>=0 ){
- sqlite3VdbeJumpHere(v, jmpIfDynamic);
+ /* Subroutine return */
+ sqlite3VdbeAddOp1(v, OP_Return, pExpr->y.sub.regReturn);
+ sqlite3VdbeChangeP1(v, pExpr->y.sub.iAddr-1, sqlite3VdbeCurrentAddr(v)-1);
}
return rReg;
@@ -99164,6 +99749,7 @@ static void sqlite3ExprCodeIN(
int addrTruthOp; /* Address of opcode that determines the IN is true */
int destNotNull; /* Jump here if a comparison is not true in step 6 */
int addrTop; /* Top of the step-6 loop */
+ int iTab = 0; /* Index to use */
pLeft = pExpr->pLeft;
if( sqlite3ExprCheckIN(pParse, pExpr) ) return;
@@ -99175,7 +99761,7 @@ static void sqlite3ExprCodeIN(
if( pParse->db->mallocFailed ) goto sqlite3ExprCodeIN_oom_error;
/* Attempt to compute the RHS. After this step, if anything other than
- ** IN_INDEX_NOOP is returned, the table opened ith cursor pExpr->iTable
+ ** IN_INDEX_NOOP is returned, the table opened with cursor iTab
** contains the values that make up the RHS. If IN_INDEX_NOOP is returned,
** the RHS has not yet been coded. */
v = pParse->pVdbe;
@@ -99183,7 +99769,8 @@ static void sqlite3ExprCodeIN(
VdbeNoopComment((v, "begin IN expr"));
eType = sqlite3FindInIndex(pParse, pExpr,
IN_INDEX_MEMBERSHIP | IN_INDEX_NOOP_OK,
- destIfFalse==destIfNull ? 0 : &rRhsHasNull, aiMap);
+ destIfFalse==destIfNull ? 0 : &rRhsHasNull,
+ aiMap, &iTab);
assert( pParse->nErr || nVector==1 || eType==IN_INDEX_EPH
|| eType==IN_INDEX_INDEX_ASC || eType==IN_INDEX_INDEX_DESC
@@ -99229,7 +99816,7 @@ static void sqlite3ExprCodeIN(
if( eType==IN_INDEX_NOOP ){
ExprList *pList = pExpr->x.pList;
CollSeq *pColl = sqlite3ExprCollSeq(pParse, pExpr->pLeft);
- int labelOk = sqlite3VdbeMakeLabel(v);
+ int labelOk = sqlite3VdbeMakeLabel(pParse);
int r2, regToFree;
int regCkNull = 0;
int ii;
@@ -99273,7 +99860,7 @@ static void sqlite3ExprCodeIN(
if( destIfNull==destIfFalse ){
destStep2 = destIfFalse;
}else{
- destStep2 = destStep6 = sqlite3VdbeMakeLabel(v);
+ destStep2 = destStep6 = sqlite3VdbeMakeLabel(pParse);
}
for(i=0; i<nVector; i++){
Expr *p = sqlite3VectorFieldSubexpr(pExpr->pLeft, i);
@@ -99291,19 +99878,19 @@ static void sqlite3ExprCodeIN(
/* In this case, the RHS is the ROWID of table b-tree and so we also
** know that the RHS is non-NULL. Hence, we combine steps 3 and 4
** into a single opcode. */
- sqlite3VdbeAddOp3(v, OP_SeekRowid, pExpr->iTable, destIfFalse, rLhs);
+ sqlite3VdbeAddOp3(v, OP_SeekRowid, iTab, destIfFalse, rLhs);
VdbeCoverage(v);
addrTruthOp = sqlite3VdbeAddOp0(v, OP_Goto); /* Return True */
}else{
sqlite3VdbeAddOp4(v, OP_Affinity, rLhs, nVector, 0, zAff, nVector);
if( destIfFalse==destIfNull ){
/* Combine Step 3 and Step 5 into a single opcode */
- sqlite3VdbeAddOp4Int(v, OP_NotFound, pExpr->iTable, destIfFalse,
+ sqlite3VdbeAddOp4Int(v, OP_NotFound, iTab, destIfFalse,
rLhs, nVector); VdbeCoverage(v);
goto sqlite3ExprCodeIN_finished;
}
/* Ordinary Step 3, for the case where FALSE and NULL are distinct */
- addrTruthOp = sqlite3VdbeAddOp4Int(v, OP_Found, pExpr->iTable, 0,
+ addrTruthOp = sqlite3VdbeAddOp4Int(v, OP_Found, iTab, 0,
rLhs, nVector); VdbeCoverage(v);
}
@@ -99328,10 +99915,10 @@ static void sqlite3ExprCodeIN(
** of the RHS.
*/
if( destStep6 ) sqlite3VdbeResolveLabel(v, destStep6);
- addrTop = sqlite3VdbeAddOp2(v, OP_Rewind, pExpr->iTable, destIfFalse);
+ addrTop = sqlite3VdbeAddOp2(v, OP_Rewind, iTab, destIfFalse);
VdbeCoverage(v);
if( nVector>1 ){
- destNotNull = sqlite3VdbeMakeLabel(v);
+ destNotNull = sqlite3VdbeMakeLabel(pParse);
}else{
/* For nVector==1, combine steps 6 and 7 by immediately returning
** FALSE if the first comparison is not NULL */
@@ -99343,7 +99930,7 @@ static void sqlite3ExprCodeIN(
int r3 = sqlite3GetTempReg(pParse);
p = sqlite3VectorFieldSubexpr(pLeft, i);
pColl = sqlite3ExprCollSeq(pParse, p);
- sqlite3VdbeAddOp3(v, OP_Column, pExpr->iTable, i, r3);
+ sqlite3VdbeAddOp3(v, OP_Column, iTab, i, r3);
sqlite3VdbeAddOp4(v, OP_Ne, rLhs+i, destNotNull, r3,
(void*)pColl, P4_COLLSEQ);
VdbeCoverage(v);
@@ -99352,7 +99939,7 @@ static void sqlite3ExprCodeIN(
sqlite3VdbeAddOp2(v, OP_Goto, 0, destIfNull);
if( nVector>1 ){
sqlite3VdbeResolveLabel(v, destNotNull);
- sqlite3VdbeAddOp2(v, OP_Next, pExpr->iTable, addrTop+1);
+ sqlite3VdbeAddOp2(v, OP_Next, iTab, addrTop+1);
VdbeCoverage(v);
/* Step 7: If we reach this point, we know that the result must
@@ -99551,7 +100138,7 @@ static int exprCodeVector(Parse *pParse, Expr *p, int *piFreeable){
#if SQLITE_OMIT_SUBQUERY
iResult = 0;
#else
- iResult = sqlite3CodeSubselect(pParse, p, 0, 0);
+ iResult = sqlite3CodeSubselect(pParse, p);
#endif
}else{
int i;
@@ -99896,7 +100483,7 @@ expr_code_doover:
** arguments past the first non-NULL argument.
*/
if( pDef->funcFlags & SQLITE_FUNC_COALESCE ){
- int endCoalesce = sqlite3VdbeMakeLabel(v);
+ int endCoalesce = sqlite3VdbeMakeLabel(pParse);
assert( nFarg>=2 );
sqlite3ExprCode(pParse, pFarg->a[0].pExpr, target);
for(i=1; i<nFarg; i++){
@@ -100025,14 +100612,14 @@ expr_code_doover:
if( op==TK_SELECT && (nCol = pExpr->x.pSelect->pEList->nExpr)!=1 ){
sqlite3SubselectError(pParse, nCol, 1);
}else{
- return sqlite3CodeSubselect(pParse, pExpr, 0, 0);
+ return sqlite3CodeSubselect(pParse, pExpr);
}
break;
}
case TK_SELECT_COLUMN: {
int n;
if( pExpr->pLeft->iTable==0 ){
- pExpr->pLeft->iTable = sqlite3CodeSubselect(pParse, pExpr->pLeft, 0, 0);
+ pExpr->pLeft->iTable = sqlite3CodeSubselect(pParse, pExpr->pLeft);
}
assert( pExpr->iTable==0 || pExpr->pLeft->op==TK_SELECT );
if( pExpr->iTable
@@ -100044,8 +100631,8 @@ expr_code_doover:
return pExpr->pLeft->iTable + pExpr->iColumn;
}
case TK_IN: {
- int destIfFalse = sqlite3VdbeMakeLabel(v);
- int destIfNull = sqlite3VdbeMakeLabel(v);
+ int destIfFalse = sqlite3VdbeMakeLabel(pParse);
+ int destIfNull = sqlite3VdbeMakeLabel(pParse);
sqlite3VdbeAddOp2(v, OP_Null, 0, target);
sqlite3ExprCodeIN(pParse, pExpr, destIfFalse, destIfNull);
sqlite3VdbeAddOp2(v, OP_Integer, 1, target);
@@ -100185,9 +100772,9 @@ expr_code_doover:
pEList = pExpr->x.pList;
aListelem = pEList->a;
nExpr = pEList->nExpr;
- endLabel = sqlite3VdbeMakeLabel(v);
+ endLabel = sqlite3VdbeMakeLabel(pParse);
if( (pX = pExpr->pLeft)!=0 ){
- tempX = *pX;
+ exprNodeCopy(&tempX, pX);
testcase( pX->op==TK_COLUMN );
exprToRegister(&tempX, exprCodeVector(pParse, &tempX, &regFree1));
testcase( regFree1==0 );
@@ -100208,7 +100795,7 @@ expr_code_doover:
}else{
pTest = aListelem[i].pExpr;
}
- nextCase = sqlite3VdbeMakeLabel(v);
+ nextCase = sqlite3VdbeMakeLabel(pParse);
testcase( pTest->op==TK_COLUMN );
sqlite3ExprIfFalse(pParse, pTest, nextCase, SQLITE_JUMPIFNULL);
testcase( aListelem[i+1].pExpr->op==TK_COLUMN );
@@ -100508,13 +101095,12 @@ static void exprCodeBetween(
Expr exprX; /* The x subexpression */
int regFree1 = 0; /* Temporary use register */
-
memset(&compLeft, 0, sizeof(Expr));
memset(&compRight, 0, sizeof(Expr));
memset(&exprAnd, 0, sizeof(Expr));
assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
- exprX = *pExpr->pLeft;
+ exprNodeCopy(&exprX, pExpr->pLeft);
exprAnd.op = TK_AND;
exprAnd.pLeft = &compLeft;
exprAnd.pRight = &compRight;
@@ -100577,7 +101163,7 @@ SQLITE_PRIVATE void sqlite3ExprIfTrue(Parse *pParse, Expr *pExpr, int dest, int
op = pExpr->op;
switch( op ){
case TK_AND: {
- int d2 = sqlite3VdbeMakeLabel(v);
+ int d2 = sqlite3VdbeMakeLabel(pParse);
testcase( jumpIfNull==0 );
sqlite3ExprIfFalse(pParse, pExpr->pLeft, d2,jumpIfNull^SQLITE_JUMPIFNULL);
sqlite3ExprIfTrue(pParse, pExpr->pRight, dest, jumpIfNull);
@@ -100663,7 +101249,7 @@ SQLITE_PRIVATE void sqlite3ExprIfTrue(Parse *pParse, Expr *pExpr, int dest, int
}
#ifndef SQLITE_OMIT_SUBQUERY
case TK_IN: {
- int destIfFalse = sqlite3VdbeMakeLabel(v);
+ int destIfFalse = sqlite3VdbeMakeLabel(pParse);
int destIfNull = jumpIfNull ? dest : destIfFalse;
sqlite3ExprCodeIN(pParse, pExpr, destIfFalse, destIfNull);
sqlite3VdbeGoto(v, dest);
@@ -100750,7 +101336,7 @@ SQLITE_PRIVATE void sqlite3ExprIfFalse(Parse *pParse, Expr *pExpr, int dest, int
break;
}
case TK_OR: {
- int d2 = sqlite3VdbeMakeLabel(v);
+ int d2 = sqlite3VdbeMakeLabel(pParse);
testcase( jumpIfNull==0 );
sqlite3ExprIfTrue(pParse, pExpr->pLeft, d2, jumpIfNull^SQLITE_JUMPIFNULL);
sqlite3ExprIfFalse(pParse, pExpr->pRight, dest, jumpIfNull);
@@ -100834,7 +101420,7 @@ SQLITE_PRIVATE void sqlite3ExprIfFalse(Parse *pParse, Expr *pExpr, int dest, int
if( jumpIfNull ){
sqlite3ExprCodeIN(pParse, pExpr, dest, dest);
}else{
- int destIfNull = sqlite3VdbeMakeLabel(v);
+ int destIfNull = sqlite3VdbeMakeLabel(pParse);
sqlite3ExprCodeIN(pParse, pExpr, dest, destIfNull);
sqlite3VdbeResolveLabel(v, destIfNull);
}
@@ -101108,6 +101694,7 @@ static int impliesNotNullRow(Walker *pWalker, Expr *pExpr){
case TK_ISNOT:
case TK_NOT:
case TK_ISNULL:
+ case TK_NOTNULL:
case TK_IS:
case TK_OR:
case TK_CASE:
@@ -101116,6 +101703,7 @@ static int impliesNotNullRow(Walker *pWalker, Expr *pExpr){
testcase( pExpr->op==TK_ISNOT );
testcase( pExpr->op==TK_NOT );
testcase( pExpr->op==TK_ISNULL );
+ testcase( pExpr->op==TK_NOTNULL );
testcase( pExpr->op==TK_IS );
testcase( pExpr->op==TK_OR );
testcase( pExpr->op==TK_CASE );
@@ -101489,6 +102077,7 @@ SQLITE_PRIVATE void sqlite3ExprAnalyzeAggregates(NameContext *pNC, Expr *pExpr){
w.xSelectCallback2 = analyzeAggregatesInSelectEnd;
w.walkerDepth = 0;
w.u.pNC = pNC;
+ w.pParse = 0;
assert( pNC->pSrcList!=0 );
sqlite3WalkExpr(&w, pExpr);
}
@@ -101620,9 +102209,16 @@ SQLITE_PRIVATE int sqlite3NoTempsInRange(Parse *pParse, int iFirst, int iLast){
**
** Or, if zName is not a system table, zero is returned.
*/
-static int isSystemTable(Parse *pParse, const char *zName){
- if( 0==sqlite3StrNICmp(zName, "sqlite_", 7) ){
- sqlite3ErrorMsg(pParse, "table %s may not be altered", zName);
+static int isAlterableTable(Parse *pParse, Table *pTab){
+ if( 0==sqlite3StrNICmp(pTab->zName, "sqlite_", 7)
+#ifndef SQLITE_OMIT_VIRTUALTABLE
+ || ( (pTab->tabFlags & TF_Shadow)
+ && (pParse->db->flags & SQLITE_Defensive)
+ && pParse->db->nVdbeExec==0
+ )
+#endif
+ ){
+ sqlite3ErrorMsg(pParse, "table %s may not be altered", pTab->zName);
return 1;
}
return 0;
@@ -101718,7 +102314,7 @@ SQLITE_PRIVATE void sqlite3AlterRenameTable(
/* Make sure it is not a system table being altered, or a reserved name
** that the table is being renamed to.
*/
- if( SQLITE_OK!=isSystemTable(pParse, pTab->zName) ){
+ if( SQLITE_OK!=isAlterableTable(pParse, pTab) ){
goto exit_rename_table;
}
if( SQLITE_OK!=sqlite3CheckObjectName(pParse, zName) ){ goto
@@ -102016,7 +102612,7 @@ SQLITE_PRIVATE void sqlite3AlterBeginAddColumn(Parse *pParse, SrcList *pSrc){
sqlite3ErrorMsg(pParse, "Cannot add a column to a view");
goto exit_begin_add_column;
}
- if( SQLITE_OK!=isSystemTable(pParse, pTab->zName) ){
+ if( SQLITE_OK!=isAlterableTable(pParse, pTab) ){
goto exit_begin_add_column;
}
@@ -102118,7 +102714,7 @@ SQLITE_PRIVATE void sqlite3AlterRenameColumn(
if( !pTab ) goto exit_rename_column;
/* Cannot alter a system table */
- if( SQLITE_OK!=isSystemTable(pParse, pTab->zName) ) goto exit_rename_column;
+ if( SQLITE_OK!=isAlterableTable(pParse, pTab) ) goto exit_rename_column;
if( SQLITE_OK!=isRealTable(pParse, pTab) ) goto exit_rename_column;
/* Which schema holds the table to be altered */
@@ -102373,13 +102969,30 @@ static void renameTokenFind(Parse *pParse, struct RenameCtx *pCtx, void *pPtr){
}
/*
+** Iterate through the Select objects that are part of WITH clauses attached
+** to select statement pSelect.
+*/
+static void renameWalkWith(Walker *pWalker, Select *pSelect){
+ if( pSelect->pWith ){
+ int i;
+ for(i=0; i<pSelect->pWith->nCte; i++){
+ Select *p = pSelect->pWith->a[i].pSelect;
+ NameContext sNC;
+ memset(&sNC, 0, sizeof(sNC));
+ sNC.pParse = pWalker->pParse;
+ sqlite3SelectPrep(sNC.pParse, p, &sNC);
+ sqlite3WalkSelect(pWalker, p);
+ }
+ }
+}
+
+/*
** This is a Walker select callback. It does nothing. It is only required
** because without a dummy callback, sqlite3WalkExpr() and similar do not
** descend into sub-select statements.
*/
static int renameColumnSelectCb(Walker *pWalker, Select *p){
- UNUSED_PARAMETER(pWalker);
- UNUSED_PARAMETER(p);
+ renameWalkWith(pWalker, p);
return WRC_Continue;
}
@@ -102529,7 +103142,6 @@ static int renameParseSql(
rc = sqlite3RunParser(p, zSql, &zErr);
assert( p->zErrMsg==0 );
assert( rc!=SQLITE_OK || zErr==0 );
- assert( (0!=p->pNewTable) + (0!=p->pNewIndex) + (0!=p->pNewTrigger)<2 );
p->zErrMsg = zErr;
if( db->mallocFailed ) rc = SQLITE_NOMEM;
if( rc==SQLITE_OK
@@ -102712,6 +103324,7 @@ static int renameResolveTrigger(Parse *pParse, const char *zDb){
}
sNC.ncFlags = 0;
}
+ sNC.pSrcList = 0;
}
}
}
@@ -102749,11 +103362,15 @@ static void renameWalkTrigger(Walker *pWalker, Trigger *pTrigger){
*/
static void renameParseCleanup(Parse *pParse){
sqlite3 *db = pParse->db;
+ Index *pIdx;
if( pParse->pVdbe ){
sqlite3VdbeFinalize(pParse->pVdbe);
}
sqlite3DeleteTable(db, pParse->pNewTable);
- if( pParse->pNewIndex ) sqlite3FreeIndex(db, pParse->pNewIndex);
+ while( (pIdx = pParse->pNewIndex)!=0 ){
+ pParse->pNewIndex = pIdx->pNext;
+ sqlite3FreeIndex(db, pIdx);
+ }
sqlite3DeleteTrigger(db, pParse->pNewTrigger);
sqlite3DbFree(db, pParse->zErrMsg);
renameTokenFree(db, pParse->pRename);
@@ -102864,6 +103481,9 @@ static void renameColumnFunc(
for(pIdx=sParse.pNewTable->pIndex; pIdx; pIdx=pIdx->pNext){
sqlite3WalkExprList(&sWalker, pIdx->aColExpr);
}
+ for(pIdx=sParse.pNewIndex; pIdx; pIdx=pIdx->pNext){
+ sqlite3WalkExprList(&sWalker, pIdx->aColExpr);
+ }
}
for(pFKey=sParse.pNewTable->pFKey; pFKey; pFKey=pFKey->pNextFrom){
@@ -102950,12 +103570,17 @@ static int renameTableSelectCb(Walker *pWalker, Select *pSelect){
int i;
RenameCtx *p = pWalker->u.pRename;
SrcList *pSrc = pSelect->pSrc;
+ if( pSrc==0 ){
+ assert( pWalker->pParse->db->mallocFailed );
+ return WRC_Abort;
+ }
for(i=0; i<pSrc->nSrc; i++){
struct SrcList_item *pItem = &pSrc->a[i];
if( pItem->pTab==p->pTab ){
renameTokenFind(pWalker->pParse, p, pItem->zName);
}
}
+ renameWalkWith(pWalker, pSelect);
return WRC_Continue;
}
@@ -104357,7 +104982,7 @@ static void analyzeOneTable(
addrNextRow = sqlite3VdbeCurrentAddr(v);
if( nColTest>0 ){
- int endDistinctTest = sqlite3VdbeMakeLabel(v);
+ int endDistinctTest = sqlite3VdbeMakeLabel(pParse);
int *aGotoChng; /* Array of jump instruction addresses */
aGotoChng = sqlite3DbMallocRawNN(db, sizeof(int)*nColTest);
if( aGotoChng==0 ) continue;
@@ -105295,8 +105920,8 @@ static void attachFunc(
assert( pVfs );
flags |= SQLITE_OPEN_MAIN_DB;
rc = sqlite3BtreeOpen(pVfs, zPath, db, &pNew->pBt, 0, flags);
- sqlite3_free( zPath );
db->nDb++;
+ pNew->zDbSName = sqlite3DbStrDup(db, zName);
}
db->noSharedCache = 0;
if( rc==SQLITE_CONSTRAINT ){
@@ -105324,7 +105949,6 @@ static void attachFunc(
sqlite3BtreeLeave(pNew->pBt);
}
pNew->safety_level = SQLITE_DEFAULT_SYNCHRONOUS+1;
- if( !REOPEN_AS_MEMDB(db) ) pNew->zDbSName = sqlite3DbStrDup(db, zName);
if( rc==SQLITE_OK && pNew->zDbSName==0 ){
rc = SQLITE_NOMEM_BKPT;
}
@@ -105352,15 +105976,19 @@ static void attachFunc(
break;
case SQLITE_NULL:
- /* No key specified. Use the key from the main database */
- sqlite3CodecGetKey(db, 0, (void**)&zKey, &nKey);
- if( nKey || sqlite3BtreeGetOptimalReserve(db->aDb[0].pBt)>0 ){
- rc = sqlite3CodecAttach(db, db->nDb-1, zKey, nKey);
+ /* No key specified. Use the key from URI filename, or if none,
+ ** use the key from the main database. */
+ if( sqlite3CodecQueryParameters(db, zName, zPath)==0 ){
+ sqlite3CodecGetKey(db, 0, (void**)&zKey, &nKey);
+ if( nKey || sqlite3BtreeGetOptimalReserve(db->aDb[0].pBt)>0 ){
+ rc = sqlite3CodecAttach(db, db->nDb-1, zKey, nKey);
+ }
}
break;
}
}
#endif
+ sqlite3_free( zPath );
/* If the file was opened successfully, read the schema for the new database.
** If this fails, or if opening the file failed, then close the file and
@@ -106272,7 +106900,7 @@ SQLITE_PRIVATE void sqlite3FinishCoding(Parse *pParse){
if( v && pParse->nErr==0 && !db->mallocFailed ){
/* A minimum of one cursor is required if autoincrement is used
* See ticket [a696379c1f08866] */
- if( pParse->pAinc!=0 && pParse->nTab==0 ) pParse->nTab = 1;
+ assert( pParse->pAinc==0 || pParse->nTab>0 );
sqlite3VdbeMakeReady(v, pParse);
pParse->rc = SQLITE_DONE;
}else{
@@ -106687,12 +107315,6 @@ static void SQLITE_NOINLINE deleteTable(sqlite3 *db, Table *pTable){
/* Delete the Table structure itself.
*/
-#ifdef SQLITE_ENABLE_NORMALIZE
- if( pTable->pColHash ){
- sqlite3HashClear(pTable->pColHash);
- sqlite3_free(pTable->pColHash);
- }
-#endif
sqlite3DeleteColumnNames(db, pTable);
sqlite3DbFree(db, pTable->zName);
sqlite3DbFree(db, pTable->zColAff);
@@ -108689,6 +109311,7 @@ SQLITE_PRIVATE void sqlite3CodeDropTable(Parse *pParse, Table *pTab, int iDb, in
*/
if( IsVirtual(pTab) ){
sqlite3VdbeAddOp4(v, OP_VDestroy, iDb, 0, 0, pTab->zName, 0);
+ sqlite3MayAbort(pParse);
}
sqlite3VdbeAddOp4(v, OP_DropTable, iDb, 0, 0, pTab->zName, 0);
sqlite3ChangeCookie(pParse, iDb);
@@ -109517,6 +110140,11 @@ SQLITE_PRIVATE void sqlite3CreateIndex(
}
}
if( idxType==SQLITE_IDXTYPE_PRIMARYKEY ) pIdx->idxType = idxType;
+ if( IN_RENAME_OBJECT ){
+ pIndex->pNext = pParse->pNewIndex;
+ pParse->pNewIndex = pIndex;
+ pIndex = 0;
+ }
goto exit_create_index;
}
}
@@ -109532,6 +110160,14 @@ SQLITE_PRIVATE void sqlite3CreateIndex(
Index *p;
assert( !IN_SPECIAL_PARSE );
assert( sqlite3SchemaMutexHeld(db, 0, pIndex->pSchema) );
+ if( pTblName!=0 ){
+ pIndex->tnum = db->init.newTnum;
+ if( sqlite3IndexHasDuplicateRootPage(pIndex) ){
+ sqlite3ErrorMsg(pParse, "invalid rootpage");
+ pParse->rc = SQLITE_CORRUPT_BKPT;
+ goto exit_create_index;
+ }
+ }
p = sqlite3HashInsert(&pIndex->pSchema->idxHash,
pIndex->zName, pIndex);
if( p ){
@@ -109540,9 +110176,6 @@ SQLITE_PRIVATE void sqlite3CreateIndex(
goto exit_create_index;
}
db->mDbFlags |= DBFLAG_SchemaChange;
- if( pTblName!=0 ){
- pIndex->tnum = db->init.newTnum;
- }
}
/* If this is the initial CREATE INDEX statement (or CREATE TABLE if the
@@ -109869,6 +110502,18 @@ SQLITE_PRIVATE int sqlite3IdListIndex(IdList *pList, const char *zName){
}
/*
+** Maximum size of a SrcList object.
+** The SrcList object is used to represent the FROM clause of a
+** SELECT statement, and the query planner cannot deal with more
+** than 64 tables in a join. So any value larger than 64 here
+** is sufficient for most uses. Smaller values, like say 10, are
+** appropriate for small and memory-limited applications.
+*/
+#ifndef SQLITE_MAX_SRCLIST
+# define SQLITE_MAX_SRCLIST 200
+#endif
+
+/*
** Expand the space allocated for the given SrcList object by
** creating nExtra new slots beginning at iStart. iStart is zero based.
** New slots are zeroed.
@@ -109884,11 +110529,12 @@ SQLITE_PRIVATE int sqlite3IdListIndex(IdList *pList, const char *zName){
** the iStart value would be 0. The result then would
** be: nil, nil, nil, A, B.
**
-** If a memory allocation fails the SrcList is unchanged. The
-** db->mallocFailed flag will be set to true.
+** If a memory allocation fails or the SrcList becomes too large, leave
+** the original SrcList unchanged, return NULL, and leave an error message
+** in pParse.
*/
SQLITE_PRIVATE SrcList *sqlite3SrcListEnlarge(
- sqlite3 *db, /* Database connection to notify of OOM errors */
+ Parse *pParse, /* Parsing context into which errors are reported */
SrcList *pSrc, /* The SrcList to be enlarged */
int nExtra, /* Number of new slots to add to pSrc->a[] */
int iStart /* Index in pSrc->a[] of first new slot */
@@ -109905,16 +110551,22 @@ SQLITE_PRIVATE SrcList *sqlite3SrcListEnlarge(
if( (u32)pSrc->nSrc+nExtra>pSrc->nAlloc ){
SrcList *pNew;
int nAlloc = pSrc->nSrc*2+nExtra;
- int nGot;
+ sqlite3 *db = pParse->db;
+
+ if( pSrc->nSrc+nExtra>=SQLITE_MAX_SRCLIST ){
+ sqlite3ErrorMsg(pParse, "too many FROM clause terms, max: %d",
+ SQLITE_MAX_SRCLIST);
+ return 0;
+ }
+ if( nAlloc>SQLITE_MAX_SRCLIST ) nAlloc = SQLITE_MAX_SRCLIST;
pNew = sqlite3DbRealloc(db, pSrc,
sizeof(*pSrc) + (nAlloc-1)*sizeof(pSrc->a[0]) );
if( pNew==0 ){
assert( db->mallocFailed );
- return pSrc;
+ return 0;
}
pSrc = pNew;
- nGot = (sqlite3DbMallocSize(db, pNew) - sizeof(*pSrc))/sizeof(pSrc->a[0])+1;
- pSrc->nAlloc = nGot;
+ pSrc->nAlloc = nAlloc;
}
/* Move existing slots that come after the newly inserted slots
@@ -109939,7 +110591,8 @@ SQLITE_PRIVATE SrcList *sqlite3SrcListEnlarge(
** Append a new table name to the given SrcList. Create a new SrcList if
** need be. A new entry is created in the SrcList even if pTable is NULL.
**
-** A SrcList is returned, or NULL if there is an OOM error. The returned
+** A SrcList is returned, or NULL if there is an OOM error or if the
+** SrcList grows to large. The returned
** SrcList might be the same as the SrcList that was input or it might be
** a new one. If an OOM error does occurs, then the prior value of pList
** that is input to this routine is automatically freed.
@@ -109970,27 +110623,32 @@ SQLITE_PRIVATE SrcList *sqlite3SrcListEnlarge(
** before being added to the SrcList.
*/
SQLITE_PRIVATE SrcList *sqlite3SrcListAppend(
- sqlite3 *db, /* Connection to notify of malloc failures */
+ Parse *pParse, /* Parsing context, in which errors are reported */
SrcList *pList, /* Append to this SrcList. NULL creates a new SrcList */
Token *pTable, /* Table to append */
Token *pDatabase /* Database of the table */
){
struct SrcList_item *pItem;
+ sqlite3 *db;
assert( pDatabase==0 || pTable!=0 ); /* Cannot have C without B */
- assert( db!=0 );
+ assert( pParse!=0 );
+ assert( pParse->db!=0 );
+ db = pParse->db;
if( pList==0 ){
- pList = sqlite3DbMallocRawNN(db, sizeof(SrcList) );
+ pList = sqlite3DbMallocRawNN(pParse->db, sizeof(SrcList) );
if( pList==0 ) return 0;
pList->nAlloc = 1;
pList->nSrc = 1;
memset(&pList->a[0], 0, sizeof(pList->a[0]));
pList->a[0].iCursor = -1;
}else{
- pList = sqlite3SrcListEnlarge(db, pList, 1, pList->nSrc);
- }
- if( db->mallocFailed ){
- sqlite3SrcListDelete(db, pList);
- return 0;
+ SrcList *pNew = sqlite3SrcListEnlarge(pParse, pList, 1, pList->nSrc);
+ if( pNew==0 ){
+ sqlite3SrcListDelete(db, pList);
+ return 0;
+ }else{
+ pList = pNew;
+ }
}
pItem = &pList->a[pList->nSrc-1];
if( pDatabase && pDatabase->z==0 ){
@@ -110079,7 +110737,7 @@ SQLITE_PRIVATE SrcList *sqlite3SrcListAppendFromTerm(
);
goto append_from_error;
}
- p = sqlite3SrcListAppend(db, p, pTable, pDatabase);
+ p = sqlite3SrcListAppend(pParse, p, pTable, pDatabase);
if( p==0 ){
goto append_from_error;
}
@@ -110468,7 +111126,7 @@ static int collationMatch(const char *zColl, Index *pIndex){
*/
#ifndef SQLITE_OMIT_REINDEX
static void reindexTable(Parse *pParse, Table *pTab, char const *zColl){
- if (! IsVirtual(pTab) ){
+ if( !IsVirtual(pTab) ){
Index *pIndex; /* An index associated with pTab */
for(pIndex=pTab->pIndex; pIndex; pIndex=pIndex->pNext){
@@ -110975,7 +111633,7 @@ static int matchQuality(
** Search a FuncDefHash for a function with the given name. Return
** a pointer to the matching FuncDef if found, or 0 if there is no match.
*/
-static FuncDef *functionSearch(
+SQLITE_PRIVATE FuncDef *sqlite3FunctionSearch(
int h, /* Hash of the name */
const char *zFunc /* Name of function */
){
@@ -110987,21 +111645,6 @@ static FuncDef *functionSearch(
}
return 0;
}
-#ifdef SQLITE_ENABLE_NORMALIZE
-SQLITE_PRIVATE FuncDef *sqlite3FunctionSearchN(
- int h, /* Hash of the name */
- const char *zFunc, /* Name of function */
- int nFunc /* Length of the name */
-){
- FuncDef *p;
- for(p=sqlite3BuiltinFunctions.a[h]; p; p=p->u.pHash){
- if( sqlite3StrNICmp(p->zName, zFunc, nFunc)==0 ){
- return p;
- }
- }
- return 0;
-}
-#endif /* SQLITE_ENABLE_NORMALIZE */
/*
** Insert a new FuncDef into a FuncDefHash hash table.
@@ -111017,7 +111660,7 @@ SQLITE_PRIVATE void sqlite3InsertBuiltinFuncs(
int nName = sqlite3Strlen30(zName);
int h = SQLITE_FUNC_HASH(zName[0], nName);
assert( zName[0]>='a' && zName[0]<='z' );
- pOther = functionSearch(h, zName);
+ pOther = sqlite3FunctionSearch(h, zName);
if( pOther ){
assert( pOther!=&aDef[i] && pOther->pNext!=&aDef[i] );
aDef[i].pNext = pOther->pNext;
@@ -111095,7 +111738,7 @@ SQLITE_PRIVATE FuncDef *sqlite3FindFunction(
if( !createFlag && (pBest==0 || (db->mDbFlags & DBFLAG_PreferBuiltin)!=0) ){
bestScore = 0;
h = SQLITE_FUNC_HASH(sqlite3UpperToLower[(u8)zName[0]], nName);
- p = functionSearch(h, zName);
+ p = sqlite3FunctionSearch(h, zName);
while( p ){
int score = matchQuality(p, nArg, enc);
if( score>bestScore ){
@@ -111315,7 +111958,7 @@ SQLITE_PRIVATE void sqlite3MaterializeView(
sqlite3 *db = pParse->db;
int iDb = sqlite3SchemaToIndex(db, pView->pSchema);
pWhere = sqlite3ExprDup(db, pWhere, 0);
- pFrom = sqlite3SrcListAppend(db, 0, 0, 0);
+ pFrom = sqlite3SrcListAppend(pParse, 0, 0, 0);
if( pFrom ){
assert( pFrom->nSrc==1 );
pFrom->a[0].zName = sqlite3DbStrDup(db, pView->zName);
@@ -111715,7 +112358,7 @@ SQLITE_PRIVATE void sqlite3DeleteFrom(
/* If this DELETE cannot use the ONEPASS strategy, this is the
** end of the WHERE loop */
if( eOnePass!=ONEPASS_OFF ){
- addrBypass = sqlite3VdbeMakeLabel(v);
+ addrBypass = sqlite3VdbeMakeLabel(pParse);
}else{
sqlite3WhereEnd(pWInfo);
}
@@ -111904,7 +112547,7 @@ SQLITE_PRIVATE void sqlite3GenerateRowDelete(
/* Seek cursor iCur to the row to delete. If this row no longer exists
** (this can happen if a trigger program has already deleted it), do
** not attempt to delete it or fire any DELETE triggers. */
- iLabel = sqlite3VdbeMakeLabel(v);
+ iLabel = sqlite3VdbeMakeLabel(pParse);
opSeek = HasRowid(pTab) ? OP_NotExists : OP_NotFound;
if( eMode==ONEPASS_OFF ){
sqlite3VdbeAddOp4Int(v, opSeek, iDataCur, iLabel, iPk, nPk);
@@ -112110,7 +112753,7 @@ SQLITE_PRIVATE int sqlite3GenerateIndexKey(
if( piPartIdxLabel ){
if( pIdx->pPartIdxWhere ){
- *piPartIdxLabel = sqlite3VdbeMakeLabel(v);
+ *piPartIdxLabel = sqlite3VdbeMakeLabel(pParse);
pParse->iSelfTab = iDataCur + 1;
sqlite3ExprIfFalseDup(pParse, pIdx->pPartIdxWhere, *piPartIdxLabel,
SQLITE_JUMPIFNULL);
@@ -112366,6 +113009,7 @@ static void instrFunc(
int typeHaystack, typeNeedle;
int N = 1;
int isText;
+ unsigned char firstChar;
UNUSED_PARAMETER(argc);
typeHaystack = sqlite3_value_type(argv[0]);
@@ -112384,7 +113028,10 @@ static void instrFunc(
isText = 1;
}
if( zNeedle==0 || (nHaystack && zHaystack==0) ) return;
- while( nNeedle<=nHaystack && memcmp(zHaystack, zNeedle, nNeedle)!=0 ){
+ firstChar = zNeedle[0];
+ while( nNeedle<=nHaystack
+ && (zHaystack[0]!=firstChar || memcmp(zHaystack, zNeedle, nNeedle)!=0)
+ ){
N++;
do{
nHaystack--;
@@ -112675,11 +113322,11 @@ static void randomBlob(
int argc,
sqlite3_value **argv
){
- int n;
+ sqlite3_int64 n;
unsigned char *p;
assert( argc==1 );
UNUSED_PARAMETER(argc);
- n = sqlite3_value_int(argv[0]);
+ n = sqlite3_value_int64(argv[0]);
if( n<1 ){
n = 1;
}
@@ -114515,7 +115162,7 @@ static void fkLookupParent(
int i; /* Iterator variable */
Vdbe *v = sqlite3GetVdbe(pParse); /* Vdbe to add code to */
int iCur = pParse->nTab - 1; /* Cursor number to use */
- int iOk = sqlite3VdbeMakeLabel(v); /* jump here if parent key found */
+ int iOk = sqlite3VdbeMakeLabel(pParse); /* jump here if parent key found */
sqlite3VdbeVerifyAbortable(v,
(!pFKey->isDeferred
@@ -114804,7 +115451,6 @@ static void fkScanChildren(
pNe = sqlite3PExpr(pParse, TK_NE, pLeft, pRight);
}else{
Expr *pEq, *pAll = 0;
- Index *pPk = sqlite3PrimaryKeyIndex(pTab);
assert( pIdx!=0 );
for(i=0; i<pIdx->nKeyCol; i++){
i16 iCol = pIdx->aiColumn[i];
@@ -114916,7 +115562,7 @@ SQLITE_PRIVATE void sqlite3FkDropTable(Parse *pParse, SrcList *pName, Table *pTa
if( p->isDeferred || (db->flags & SQLITE_DeferFKs) ) break;
}
if( !p ) return;
- iSkip = sqlite3VdbeMakeLabel(v);
+ iSkip = sqlite3VdbeMakeLabel(pParse);
sqlite3VdbeAddOp2(v, OP_FkIfZero, 1, iSkip); VdbeCoverage(v);
}
@@ -115201,7 +115847,7 @@ SQLITE_PRIVATE void sqlite3FkCheck(
/* Create a SrcList structure containing the child table. We need the
** child table as a SrcList for sqlite3WhereBegin() */
- pSrc = sqlite3SrcListAppend(db, 0, 0, 0);
+ pSrc = sqlite3SrcListAppend(pParse, 0, 0, 0);
if( pSrc ){
struct SrcList_item *pItem = pSrc->a;
pItem->pTab = pFKey->pFrom;
@@ -115478,7 +116124,7 @@ static Trigger *fkActionTrigger(
}
pSelect = sqlite3SelectNew(pParse,
sqlite3ExprListAppend(pParse, 0, pRaise),
- sqlite3SrcListAppend(db, 0, &tFrom, 0),
+ sqlite3SrcListAppend(pParse, 0, &tFrom, 0),
pWhere,
0, 0, 0, 0, 0
);
@@ -115940,6 +116586,7 @@ SQLITE_PRIVATE void sqlite3AutoincrementBegin(Parse *pParse){
aOp[7].p2 = memId+2;
aOp[7].p1 = memId;
aOp[10].p2 = memId;
+ if( pParse->nTab==0 ) pParse->nTab = 1;
}
}
@@ -116446,6 +117093,11 @@ SQLITE_PRIVATE void sqlite3Insert(
}
#ifndef SQLITE_OMIT_UPSERT
if( pUpsert ){
+ if( IsVirtual(pTab) ){
+ sqlite3ErrorMsg(pParse, "UPSERT not implemented for virtual table \"%s\"",
+ pTab->zName);
+ goto insert_cleanup;
+ }
pTabList->a[0].iCursor = iDataCur;
pUpsert->pUpsertSrc = pTabList;
pUpsert->regData = regData;
@@ -116486,7 +117138,7 @@ SQLITE_PRIVATE void sqlite3Insert(
/* Run the BEFORE and INSTEAD OF triggers, if there are any
*/
- endOfLoop = sqlite3VdbeMakeLabel(v);
+ endOfLoop = sqlite3VdbeMakeLabel(pParse);
if( tmask & TRIGGER_BEFORE ){
int regCols = sqlite3GetTempRange(pParse, pTab->nCol+1);
@@ -116968,7 +117620,20 @@ SQLITE_PRIVATE void sqlite3GenerateConstraintChecks(
}
assert( onError==OE_Rollback || onError==OE_Abort || onError==OE_Fail
|| onError==OE_Ignore || onError==OE_Replace );
+ addr1 = 0;
switch( onError ){
+ case OE_Replace: {
+ assert( onError==OE_Replace );
+ addr1 = sqlite3VdbeMakeLabel(pParse);
+ sqlite3VdbeAddOp2(v, OP_NotNull, regNewData+1+i, addr1);
+ VdbeCoverage(v);
+ sqlite3ExprCode(pParse, pTab->aCol[i].pDflt, regNewData+1+i);
+ sqlite3VdbeAddOp2(v, OP_NotNull, regNewData+1+i, addr1);
+ VdbeCoverage(v);
+ onError = OE_Abort;
+ /* Fall through into the OE_Abort case to generate code that runs
+ ** if both the input and the default value are NULL */
+ }
case OE_Abort:
sqlite3MayAbort(pParse);
/* Fall through */
@@ -116981,21 +117646,15 @@ SQLITE_PRIVATE void sqlite3GenerateConstraintChecks(
sqlite3VdbeAppendP4(v, zMsg, P4_DYNAMIC);
sqlite3VdbeChangeP5(v, P5_ConstraintNotNull);
VdbeCoverage(v);
+ if( addr1 ) sqlite3VdbeResolveLabel(v, addr1);
break;
}
- case OE_Ignore: {
+ default: {
+ assert( onError==OE_Ignore );
sqlite3VdbeAddOp2(v, OP_IsNull, regNewData+1+i, ignoreDest);
VdbeCoverage(v);
break;
}
- default: {
- assert( onError==OE_Replace );
- addr1 = sqlite3VdbeAddOp1(v, OP_NotNull, regNewData+1+i);
- VdbeCoverage(v);
- sqlite3ExprCode(pParse, pTab->aCol[i].pDflt, regNewData+1+i);
- sqlite3VdbeJumpHere(v, addr1);
- break;
- }
}
}
@@ -117016,7 +117675,7 @@ SQLITE_PRIVATE void sqlite3GenerateConstraintChecks(
** updated so there is no point it verifying the check constraint */
continue;
}
- allOk = sqlite3VdbeMakeLabel(v);
+ allOk = sqlite3VdbeMakeLabel(pParse);
sqlite3VdbeVerifyAbortable(v, onError);
sqlite3ExprIfTrue(pParse, pExpr, allOk, SQLITE_JUMPIFNULL);
if( onError==OE_Ignore ){
@@ -117083,7 +117742,7 @@ SQLITE_PRIVATE void sqlite3GenerateConstraintChecks(
** exist in the table.
*/
if( pkChng && pPk==0 ){
- int addrRowidOk = sqlite3VdbeMakeLabel(v);
+ int addrRowidOk = sqlite3VdbeMakeLabel(pParse);
/* Figure out what action to take in case of a rowid collision */
onError = pTab->keyConf;
@@ -117233,7 +117892,7 @@ SQLITE_PRIVATE void sqlite3GenerateConstraintChecks(
VdbeComment((v, "Skip upsert subroutine"));
sqlite3VdbeJumpHere(v, upsertJump);
}else{
- addrUniqueOk = sqlite3VdbeMakeLabel(v);
+ addrUniqueOk = sqlite3VdbeMakeLabel(pParse);
}
if( bAffinityDone==0 && (pUpIdx==0 || pUpIdx==pIdx) ){
sqlite3TableAffinity(v, pTab, regNewData+1);
@@ -117316,7 +117975,11 @@ SQLITE_PRIVATE void sqlite3GenerateConstraintChecks(
** (3) There are no secondary indexes on the table
** (4) No delete triggers need to be fired if there is a conflict
** (5) No FK constraint counters need to be updated if a conflict occurs.
- */
+ **
+ ** This is not possible for ENABLE_PREUPDATE_HOOK builds, as the row
+ ** must be explicitly deleted in order to ensure any pre-update hook
+ ** is invoked. */
+#ifndef SQLITE_ENABLE_PREUPDATE_HOOK
if( (ix==0 && pIdx->pNext==0) /* Condition 3 */
&& pPk==pIdx /* Condition 2 */
&& onError==OE_Replace /* Condition 1 */
@@ -117328,6 +117991,7 @@ SQLITE_PRIVATE void sqlite3GenerateConstraintChecks(
sqlite3VdbeResolveLabel(v, addrUniqueOk);
continue;
}
+#endif /* ifndef SQLITE_ENABLE_PREUPDATE_HOOK */
/* Check to see if the new index entry will be unique */
sqlite3VdbeVerifyAbortable(v, onError);
@@ -118088,7 +118752,7 @@ SQLITE_API int sqlite3_exec(
sqlite3_mutex_enter(db->mutex);
sqlite3Error(db, SQLITE_OK);
while( rc==SQLITE_OK && zSql[0] ){
- int nCol;
+ int nCol = 0;
char **azVals = 0;
pStmt = 0;
@@ -118102,9 +118766,7 @@ SQLITE_API int sqlite3_exec(
zSql = zLeftover;
continue;
}
-
callbackIsInit = 0;
- nCol = sqlite3_column_count(pStmt);
while( 1 ){
int i;
@@ -118115,6 +118777,7 @@ SQLITE_API int sqlite3_exec(
(SQLITE_DONE==rc && !callbackIsInit
&& db->flags&SQLITE_NullCallback)) ){
if( !callbackIsInit ){
+ nCol = sqlite3_column_count(pStmt);
azCols = sqlite3DbMallocRaw(db, (2*nCol+1)*sizeof(const char*));
if( azCols==0 ){
goto exec_out;
@@ -119469,7 +120132,7 @@ SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff){
if( onoff ){
db->flags |= SQLITE_LoadExtension|SQLITE_LoadExtFunc;
}else{
- db->flags &= ~(SQLITE_LoadExtension|SQLITE_LoadExtFunc);
+ db->flags &= ~(u64)(SQLITE_LoadExtension|SQLITE_LoadExtFunc);
}
sqlite3_mutex_leave(db->mutex);
return SQLITE_OK;
@@ -119728,8 +120391,7 @@ SQLITE_PRIVATE void sqlite3AutoLoadExtensions(sqlite3 *db){
#define PragTyp_HEXKEY 41
#define PragTyp_KEY 42
#define PragTyp_LOCK_STATUS 43
-#define PragTyp_PARSER_TRACE 44
-#define PragTyp_STATS 45
+#define PragTyp_STATS 44
/* Property flags associated with various pragma. */
#define PragFlg_NeedSchema 0x01 /* Force schema load before running */
@@ -120140,12 +120802,14 @@ static const PragmaName aPragmaName[] = {
/* ColNames: */ 0, 0,
/* iArg: */ 0 },
#endif
-#if defined(SQLITE_DEBUG) && !defined(SQLITE_OMIT_PARSER_TRACE)
+#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
+#if defined(SQLITE_DEBUG)
{/* zName: */ "parser_trace",
- /* ePragTyp: */ PragTyp_PARSER_TRACE,
- /* ePragFlg: */ 0,
+ /* ePragTyp: */ PragTyp_FLAG,
+ /* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
/* ColNames: */ 0, 0,
- /* iArg: */ 0 },
+ /* iArg: */ SQLITE_ParserTrace },
+#endif
#endif
#if defined(SQLITE_INTROSPECTION_PRAGMAS)
{/* zName: */ "pragma_list",
@@ -121136,7 +121800,7 @@ SQLITE_PRIVATE void sqlite3Pragma(
if( sqlite3GetBoolean(zRight, size!=0) ){
db->flags |= SQLITE_CacheSpill;
}else{
- db->flags &= ~SQLITE_CacheSpill;
+ db->flags &= ~(u64)SQLITE_CacheSpill;
}
setAllPagerFlags(db);
}
@@ -121696,7 +122360,7 @@ SQLITE_PRIVATE void sqlite3Pragma(
x = sqlite3FkLocateIndex(pParse, pParent, pFK, &pIdx, &aiCols);
assert( x==0 );
}
- addrOk = sqlite3VdbeMakeLabel(v);
+ addrOk = sqlite3VdbeMakeLabel(pParse);
/* Generate code to read the child key values into registers
** regRow..regRow+n. If any of the child key values are NULL, this
@@ -121741,19 +122405,6 @@ SQLITE_PRIVATE void sqlite3Pragma(
#endif /* !defined(SQLITE_OMIT_TRIGGER) */
#endif /* !defined(SQLITE_OMIT_FOREIGN_KEY) */
-#ifndef NDEBUG
- case PragTyp_PARSER_TRACE: {
- if( zRight ){
- if( sqlite3GetBoolean(zRight, 0) ){
- sqlite3ParserTrace(stdout, "parser: ");
- }else{
- sqlite3ParserTrace(0, 0);
- }
- }
- }
- break;
-#endif
-
/* Reinstall the LIKE and GLOB functions. The variant of LIKE
** used will be case sensitive or not depending on the RHS.
*/
@@ -121916,8 +122567,8 @@ SQLITE_PRIVATE void sqlite3Pragma(
if( pTab->pCheck && (db->flags & SQLITE_IgnoreChecks)==0 ){
ExprList *pCheck = sqlite3ExprListDup(db, pTab->pCheck, 0);
if( db->mallocFailed==0 ){
- int addrCkFault = sqlite3VdbeMakeLabel(v);
- int addrCkOk = sqlite3VdbeMakeLabel(v);
+ int addrCkFault = sqlite3VdbeMakeLabel(pParse);
+ int addrCkOk = sqlite3VdbeMakeLabel(pParse);
char *zErr;
int k;
pParse->iSelfTab = iDataCur + 1;
@@ -121940,7 +122591,7 @@ SQLITE_PRIVATE void sqlite3Pragma(
/* Validate index entries for the current row */
for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
int jmp2, jmp3, jmp4, jmp5;
- int ckUniq = sqlite3VdbeMakeLabel(v);
+ int ckUniq = sqlite3VdbeMakeLabel(pParse);
if( pPk==pIdx ) continue;
r1 = sqlite3GenerateIndexKey(pParse, pIdx, iDataCur, 0, 0, &jmp3,
pPrior, r1);
@@ -121961,7 +122612,7 @@ SQLITE_PRIVATE void sqlite3Pragma(
** current key. The entry is unique if (1) any column is NULL
** or (2) the next entry has a different key */
if( IsUniqueIndex(pIdx) ){
- int uniqOk = sqlite3VdbeMakeLabel(v);
+ int uniqOk = sqlite3VdbeMakeLabel(pParse);
int jmp6;
int kk;
for(kk=0; kk<pIdx->nKeyCol; kk++){
@@ -122876,6 +123527,19 @@ static void corruptSchema(
}
/*
+** Check to see if any sibling index (another index on the same table)
+** of pIndex has the same root page number, and if it does, return true.
+** This would indicate a corrupt schema.
+*/
+SQLITE_PRIVATE int sqlite3IndexHasDuplicateRootPage(Index *pIndex){
+ Index *p;
+ for(p=pIndex->pTable->pIndex; p; p=p->pNext){
+ if( p->tnum==pIndex->tnum && p!=pIndex ) return 1;
+ }
+ return 0;
+}
+
+/*
** This is the callback routine for the code that initializes the
** database. See sqlite3Init() below for additional information.
** This routine is also called from the OP_ParseSchema opcode of the VDBE.
@@ -122896,6 +123560,7 @@ SQLITE_PRIVATE int sqlite3InitCallback(void *pInit, int argc, char **argv, char
UNUSED_PARAMETER2(NotUsed, argc);
assert( sqlite3_mutex_held(db->mutex) );
DbClearProperty(db, iDb, DB_Empty);
+ pData->nInitRow++;
if( db->mallocFailed ){
corruptSchema(pData, argv[0], 0);
return 1;
@@ -122952,6 +123617,7 @@ SQLITE_PRIVATE int sqlite3InitCallback(void *pInit, int argc, char **argv, char
if( pIndex==0
|| sqlite3GetInt32(argv[1],&pIndex->tnum)==0
|| pIndex->tnum<2
+ || sqlite3IndexHasDuplicateRootPage(pIndex)
){
corruptSchema(pData, argv[0], pIndex?"invalid rootpage":"orphan index");
}
@@ -123003,6 +123669,7 @@ SQLITE_PRIVATE int sqlite3InitOne(sqlite3 *db, int iDb, char **pzErrMsg, u32 mFl
initData.rc = SQLITE_OK;
initData.pzErrMsg = pzErrMsg;
initData.mInitFlags = mFlags;
+ initData.nInitRow = 0;
sqlite3InitCallback(&initData, 3, (char **)azArg, 0);
if( initData.rc ){
rc = initData.rc;
@@ -123120,7 +123787,7 @@ SQLITE_PRIVATE int sqlite3InitOne(sqlite3 *db, int iDb, char **pzErrMsg, u32 mFl
** indices that the user might have created.
*/
if( iDb==0 && meta[BTREE_FILE_FORMAT-1]>=4 ){
- db->flags &= ~SQLITE_LegacyFileFmt;
+ db->flags &= ~(u64)SQLITE_LegacyFileFmt;
}
/* Read the schema information out of the schema tables
@@ -123537,293 +124204,6 @@ static int sqlite3LockAndPrepare(
return rc;
}
-#ifdef SQLITE_ENABLE_NORMALIZE
-/*
-** Checks if the specified token is a table, column, or function name,
-** based on the databases associated with the statement being prepared.
-** If the function fails, zero is returned and pRc is filled with the
-** error code.
-*/
-static int shouldTreatAsIdentifier(
- sqlite3 *db, /* Database handle. */
- const char *zToken, /* Pointer to start of token to be checked */
- int nToken, /* Length of token to be checked */
- int *pRc /* Pointer to error code upon failure */
-){
- int bFound = 0; /* Non-zero if token is an identifier name. */
- int i, j; /* Database and column loop indexes. */
- Schema *pSchema; /* Schema for current database. */
- Hash *pHash; /* Hash table of tables for current database. */
- HashElem *e; /* Hash element for hash table iteration. */
- Table *pTab; /* Database table for columns being checked. */
-
- if( sqlite3IsRowidN(zToken, nToken) ){
- return 1;
- }
- if( nToken>0 ){
- int hash = SQLITE_FUNC_HASH(sqlite3UpperToLower[(u8)zToken[0]], nToken);
- if( sqlite3FunctionSearchN(hash, zToken, nToken) ) return 1;
- }
- assert( db!=0 );
- sqlite3_mutex_enter(db->mutex);
- sqlite3BtreeEnterAll(db);
- for(i=0; i<db->nDb; i++){
- pHash = &db->aFunc;
- if( sqlite3HashFindN(pHash, zToken, nToken) ){
- bFound = 1;
- break;
- }
- pSchema = db->aDb[i].pSchema;
- if( pSchema==0 ) continue;
- pHash = &pSchema->tblHash;
- if( sqlite3HashFindN(pHash, zToken, nToken) ){
- bFound = 1;
- break;
- }
- for(e=sqliteHashFirst(pHash); e; e=sqliteHashNext(e)){
- pTab = sqliteHashData(e);
- if( pTab==0 ) continue;
- pHash = pTab->pColHash;
- if( pHash==0 ){
- pTab->pColHash = pHash = sqlite3_malloc(sizeof(Hash));
- if( pHash ){
- sqlite3HashInit(pHash);
- for(j=0; j<pTab->nCol; j++){
- Column *pCol = &pTab->aCol[j];
- sqlite3HashInsert(pHash, pCol->zName, pCol);
- }
- }else{
- *pRc = SQLITE_NOMEM_BKPT;
- bFound = 0;
- goto done;
- }
- }
- if( pHash && sqlite3HashFindN(pHash, zToken, nToken) ){
- bFound = 1;
- goto done;
- }
- }
- }
-done:
- sqlite3BtreeLeaveAll(db);
- sqlite3_mutex_leave(db->mutex);
- return bFound;
-}
-
-/*
-** Attempt to estimate the final output buffer size needed for the fully
-** normalized version of the specified SQL string. This should take into
-** account any potential expansion that could occur (e.g. via IN clauses
-** being expanded, etc). This size returned is the total number of bytes
-** including the NUL terminator.
-*/
-static int estimateNormalizedSize(
- const char *zSql, /* The original SQL string */
- int nSql, /* Length of original SQL string */
- u8 prepFlags /* The flags passed to sqlite3_prepare_v3() */
-){
- int nOut = nSql + 4;
- const char *z = zSql;
- while( nOut<nSql*5 ){
- while( z[0]!=0 && z[0]!='I' && z[0]!='i' ){ z++; }
- if( z[0]==0 ) break;
- z++;
- if( z[0]!='N' && z[0]!='n' ) break;
- z++;
- while( sqlite3Isspace(z[0]) ){ z++; }
- if( z[0]!='(' ) break;
- z++;
- nOut += 5; /* ?,?,? */
- }
- return nOut;
-}
-
-/*
-** Copy the current token into the output buffer while dealing with quoted
-** identifiers. By default, all letters will be converted into lowercase.
-** If the bUpper flag is set, uppercase will be used. The piOut argument
-** will be used to update the target index into the output string.
-*/
-static void copyNormalizedToken(
- const char *zSql, /* The original SQL string */
- int iIn, /* Current index into the original SQL string */
- int nToken, /* Number of bytes in the current token */
- int tokenFlags, /* Flags returned by the tokenizer */
- char *zOut, /* The output string */
- int *piOut /* Pointer to target index into the output string */
-){
- int bQuoted = tokenFlags & SQLITE_TOKEN_QUOTED;
- int bKeyword = tokenFlags & SQLITE_TOKEN_KEYWORD;
- int j = *piOut, k = 0;
- for(; k<nToken; k++){
- if( bQuoted ){
- if( k==0 && iIn>0 ){
- zOut[j++] = '"';
- continue;
- }else if( k==nToken-1 ){
- zOut[j++] = '"';
- continue;
- }
- }
- if( bKeyword ){
- zOut[j++] = sqlite3Toupper(zSql[iIn+k]);
- }else{
- zOut[j++] = sqlite3Tolower(zSql[iIn+k]);
- }
- }
- *piOut = j;
-}
-
-/*
-** Perform normalization of the SQL contained in the prepared statement and
-** store the result in the zNormSql field. The schema for the associated
-** databases are consulted while performing the normalization in order to
-** determine if a token appears to be an identifier. All identifiers are
-** left intact in the normalized SQL and all literals are replaced with a
-** single '?'.
-*/
-SQLITE_PRIVATE void sqlite3Normalize(
- Vdbe *pVdbe, /* VM being reprepared */
- const char *zSql, /* The original SQL string */
- int nSql, /* Size of the input string in bytes */
- u8 prepFlags /* The flags passed to sqlite3_prepare_v3() */
-){
- sqlite3 *db; /* Database handle. */
- char *z; /* The output string */
- int nZ; /* Size of the output string in bytes */
- int i; /* Next character to read from zSql[] */
- int j; /* Next character to fill in on z[] */
- int tokenType = 0; /* Type of the next token */
- int prevTokenType = 0; /* Type of the previous token, except spaces */
- int n; /* Size of the next token */
- int nParen = 0; /* Nesting level of parenthesis */
- Hash inHash; /* Table of parenthesis levels to output index. */
-
- db = sqlite3VdbeDb(pVdbe);
- assert( db!=0 );
- assert( pVdbe->zNormSql==0 );
- if( zSql==0 ) return;
- nZ = estimateNormalizedSize(zSql, nSql, prepFlags);
- z = sqlite3DbMallocRawNN(db, nZ);
- if( z==0 ) return;
- sqlite3HashInit(&inHash);
- for(i=j=0; i<nSql && zSql[i]; i+=n){
- int flags = 0;
- if( tokenType!=TK_SPACE ) prevTokenType = tokenType;
- n = sqlite3GetTokenNormalized((unsigned char*)zSql+i, &tokenType, &flags);
- switch( tokenType ){
- case TK_SPACE: {
- break;
- }
- case TK_ILLEGAL: {
- sqlite3DbFree(db, z);
- sqlite3HashClear(&inHash);
- return;
- }
- case TK_STRING:
- case TK_INTEGER:
- case TK_FLOAT:
- case TK_VARIABLE:
- case TK_BLOB: {
- z[j++] = '?';
- break;
- }
- case TK_LP:
- case TK_RP: {
- if( tokenType==TK_LP ){
- nParen++;
- if( prevTokenType==TK_IN ){
- assert( nParen<nSql );
- sqlite3HashInsert(&inHash, zSql+nParen, SQLITE_INT_TO_PTR(j));
- }
- }else{
- int jj;
- assert( nParen<nSql );
- jj = SQLITE_PTR_TO_INT(sqlite3HashFind(&inHash, zSql+nParen));
- if( jj>0 ){
- sqlite3HashInsert(&inHash, zSql+nParen, 0);
- assert( jj+6<nZ );
- memcpy(z+jj+1, "?,?,?", 5);
- j = jj+6;
- assert( nZ-1-j>=0 );
- assert( nZ-1-j<nZ );
- memset(z+j, 0, nZ-1-j);
- }
- nParen--;
- }
- assert( nParen>=0 );
- /* Fall through */
- }
- case TK_MINUS:
- case TK_SEMI:
- case TK_PLUS:
- case TK_STAR:
- case TK_SLASH:
- case TK_REM:
- case TK_EQ:
- case TK_LE:
- case TK_NE:
- case TK_LSHIFT:
- case TK_LT:
- case TK_RSHIFT:
- case TK_GT:
- case TK_GE:
- case TK_BITOR:
- case TK_CONCAT:
- case TK_COMMA:
- case TK_BITAND:
- case TK_BITNOT:
- case TK_DOT:
- case TK_IN:
- case TK_IS:
- case TK_NOT:
- case TK_NULL:
- case TK_ID: {
- if( tokenType==TK_NULL ){
- if( prevTokenType==TK_IS || prevTokenType==TK_NOT ){
- /* NULL is a keyword in this case, not a literal value */
- }else{
- /* Here the NULL is a literal value */
- z[j++] = '?';
- break;
- }
- }
- if( j>0 && sqlite3IsIdChar(z[j-1]) && sqlite3IsIdChar(zSql[i]) ){
- z[j++] = ' ';
- }
- if( tokenType==TK_ID ){
- int i2 = i, n2 = n, rc = SQLITE_OK;
- if( nParen>0 ){
- assert( nParen<nSql );
- sqlite3HashInsert(&inHash, zSql+nParen, 0);
- }
- if( flags&SQLITE_TOKEN_QUOTED ){ i2++; n2-=2; }
- if( shouldTreatAsIdentifier(db, zSql+i2, n2, &rc)==0 ){
- if( rc!=SQLITE_OK ){
- sqlite3DbFree(db, z);
- sqlite3HashClear(&inHash);
- return;
- }
- if( sqlite3_keyword_check(zSql+i2, n2)==0 ){
- z[j++] = '?';
- break;
- }
- }
- }
- copyNormalizedToken(zSql, i, n, flags, z, &j);
- break;
- }
- }
- }
- assert( j<nZ && "one" );
- while( j>0 && z[j-1]==' ' ){ j--; }
- if( j>0 && z[j-1]!=';' ){ z[j++] = ';'; }
- z[j] = 0;
- assert( j<nZ && "two" );
- pVdbe->zNormSql = z;
- sqlite3HashClear(&inHash);
-}
-#endif /* SQLITE_ENABLE_NORMALIZE */
/*
** Rerun the compilation of a statement after a schema change.
@@ -124665,7 +125045,7 @@ static void pushOntoSorter(
}
assert( pSelect->iOffset==0 || pSelect->iLimit!=0 );
iLimit = pSelect->iOffset ? pSelect->iOffset+1 : pSelect->iLimit;
- pSort->labelDone = sqlite3VdbeMakeLabel(v);
+ pSort->labelDone = sqlite3VdbeMakeLabel(pParse);
sqlite3ExprCodeExprList(pParse, pSort->pOrderBy, regBase, regOrigData,
SQLITE_ECEL_DUP | (regOrigData? SQLITE_ECEL_REF : 0));
if( bSeq ){
@@ -124704,7 +125084,7 @@ static void pushOntoSorter(
pKI->nAllField-pKI->nKeyField-1);
addrJmp = sqlite3VdbeCurrentAddr(v);
sqlite3VdbeAddOp3(v, OP_Jump, addrJmp+1, 0, addrJmp+1); VdbeCoverage(v);
- pSort->labelBkOut = sqlite3VdbeMakeLabel(v);
+ pSort->labelBkOut = sqlite3VdbeMakeLabel(pParse);
pSort->regReturn = ++pParse->nMem;
sqlite3VdbeAddOp2(v, OP_Gosub, pSort->regReturn, pSort->labelBkOut);
sqlite3VdbeAddOp1(v, OP_ResetSorter, pSort->iECursor);
@@ -125451,7 +125831,7 @@ static void generateSortTail(
){
Vdbe *v = pParse->pVdbe; /* The prepared statement */
int addrBreak = pSort->labelDone; /* Jump here to exit loop */
- int addrContinue = sqlite3VdbeMakeLabel(v); /* Jump here for next cycle */
+ int addrContinue = sqlite3VdbeMakeLabel(pParse);/* Jump here for next cycle */
int addr; /* Top of output loop. Jump for Next. */
int addrOnce = 0;
int iTab;
@@ -126117,15 +126497,15 @@ SQLITE_PRIVATE void sqlite3SelectAddColumnTypeAndCollation(
SQLITE_PRIVATE Table *sqlite3ResultSetOfSelect(Parse *pParse, Select *pSelect){
Table *pTab;
sqlite3 *db = pParse->db;
- int savedFlags;
+ u64 savedFlags;
savedFlags = db->flags;
- db->flags &= ~SQLITE_FullColNames;
+ db->flags &= ~(u64)SQLITE_FullColNames;
db->flags |= SQLITE_ShortColNames;
sqlite3SelectPrep(pParse, pSelect, 0);
+ db->flags = savedFlags;
if( pParse->nErr ) return 0;
while( pSelect->pPrior ) pSelect = pSelect->pPrior;
- db->flags = savedFlags;
pTab = sqlite3DbMallocZero(db, sizeof(Table) );
if( pTab==0 ){
return 0;
@@ -126369,7 +126749,7 @@ static void generateWithRecursiveQuery(
if( sqlite3AuthCheck(pParse, SQLITE_RECURSIVE, 0, 0, 0) ) return;
/* Process the LIMIT and OFFSET clauses, if they exist */
- addrBreak = sqlite3VdbeMakeLabel(v);
+ addrBreak = sqlite3VdbeMakeLabel(pParse);
p->nSelectRow = 320; /* 4 billion rows */
computeLimitRegisters(pParse, p, addrBreak);
pLimit = p->pLimit;
@@ -126439,7 +126819,7 @@ static void generateWithRecursiveQuery(
sqlite3VdbeAddOp1(v, OP_Delete, iQueue);
/* Output the single row in Current */
- addrCont = sqlite3VdbeMakeLabel(v);
+ addrCont = sqlite3VdbeMakeLabel(pParse);
codeOffset(v, regOffset, addrCont);
selectInnerLoop(pParse, p, iCurrent,
0, 0, pDest, addrCont, addrBreak);
@@ -126747,8 +127127,8 @@ static int multiSelect(
if( dest.eDest!=priorOp ){
int iCont, iBreak, iStart;
assert( p->pEList );
- iBreak = sqlite3VdbeMakeLabel(v);
- iCont = sqlite3VdbeMakeLabel(v);
+ iBreak = sqlite3VdbeMakeLabel(pParse);
+ iCont = sqlite3VdbeMakeLabel(pParse);
computeLimitRegisters(pParse, p, iBreak);
sqlite3VdbeAddOp2(v, OP_Rewind, unionTab, iBreak); VdbeCoverage(v);
iStart = sqlite3VdbeCurrentAddr(v);
@@ -126816,8 +127196,8 @@ static int multiSelect(
** tables.
*/
assert( p->pEList );
- iBreak = sqlite3VdbeMakeLabel(v);
- iCont = sqlite3VdbeMakeLabel(v);
+ iBreak = sqlite3VdbeMakeLabel(pParse);
+ iCont = sqlite3VdbeMakeLabel(pParse);
computeLimitRegisters(pParse, p, iBreak);
sqlite3VdbeAddOp2(v, OP_Rewind, tab1, iBreak); VdbeCoverage(v);
r1 = sqlite3GetTempReg(pParse);
@@ -126947,7 +127327,7 @@ static int generateOutputSubroutine(
int addr;
addr = sqlite3VdbeCurrentAddr(v);
- iContinue = sqlite3VdbeMakeLabel(v);
+ iContinue = sqlite3VdbeMakeLabel(pParse);
/* Suppress duplicates for UNION, EXCEPT, and INTERSECT
*/
@@ -127184,8 +127564,8 @@ static int multiSelectOrderBy(
db = pParse->db;
v = pParse->pVdbe;
assert( v!=0 ); /* Already thrown the error if VDBE alloc failed */
- labelEnd = sqlite3VdbeMakeLabel(v);
- labelCmpr = sqlite3VdbeMakeLabel(v);
+ labelEnd = sqlite3VdbeMakeLabel(pParse);
+ labelCmpr = sqlite3VdbeMakeLabel(pParse);
/* Patch up the ORDER BY clause
@@ -127501,6 +127881,7 @@ static Expr *substExpr(
ifNullRow.iTable = pSubst->iNewTable;
pCopy = &ifNullRow;
}
+ testcase( ExprHasProperty(pCopy, EP_Subquery) );
pNew = sqlite3ExprDup(db, pCopy, 0);
if( pNew && pSubst->isLeftJoin ){
ExprSetProperty(pNew, EP_CanBeNull);
@@ -127993,11 +128374,9 @@ static int flattenSubquery(
jointype = pSubitem->fg.jointype;
}else{
assert( pParent!=p ); /* 2nd and subsequent times through the loop */
- pSrc = pParent->pSrc = sqlite3SrcListAppend(db, 0, 0, 0);
- if( pSrc==0 ){
- assert( db->mallocFailed );
- break;
- }
+ pSrc = sqlite3SrcListAppend(pParse, 0, 0, 0);
+ if( pSrc==0 ) break;
+ pParent->pSrc = pSrc;
}
/* The subquery uses a single slot of the FROM clause of the outer
@@ -128016,10 +128395,9 @@ static int flattenSubquery(
** for the two elements in the FROM clause of the subquery.
*/
if( nSubSrc>1 ){
- pParent->pSrc = pSrc = sqlite3SrcListEnlarge(db, pSrc, nSubSrc-1,iFrom+1);
- if( db->mallocFailed ){
- break;
- }
+ pSrc = sqlite3SrcListEnlarge(pParse, pSrc, nSubSrc-1,iFrom+1);
+ if( pSrc==0 ) break;
+ pParent->pSrc = pSrc;
}
/* Transfer the FROM clause terms from the subquery into the
@@ -128065,7 +128443,8 @@ static int flattenSubquery(
pParent->pOrderBy = pOrderBy;
pSub->pOrderBy = 0;
}
- pWhere = sqlite3ExprDup(db, pSub->pWhere, 0);
+ pWhere = pSub->pWhere;
+ pSub->pWhere = 0;
if( isLeftJoin>0 ){
setJoinExpr(pWhere, iNewParent);
}
@@ -129368,7 +129747,7 @@ static void updateAccumulator(Parse *pParse, int regAcc, AggInfo *pAggInfo){
regAgg = 0;
}
if( pF->iDistinct>=0 ){
- addrNext = sqlite3VdbeMakeLabel(v);
+ addrNext = sqlite3VdbeMakeLabel(pParse);
testcase( nArg==0 ); /* Error condition */
testcase( nArg>1 ); /* Also an error */
codeDistinct(pParse, pF->iDistinct, addrNext, 1, regAgg);
@@ -129778,6 +130157,7 @@ SQLITE_PRIVATE int sqlite3Select(
}
if( flattenSubquery(pParse, p, i, isAgg) ){
+ if( pParse->nErr ) goto select_end;
/* This subquery can be absorbed into its parent. */
i = -1;
}
@@ -129873,22 +130253,12 @@ SQLITE_PRIVATE int sqlite3Select(
pSub = pItem->pSelect;
if( pSub==0 ) continue;
- /* Sometimes the code for a subquery will be generated more than
- ** once, if the subquery is part of the WHERE clause in a LEFT JOIN,
- ** for example. In that case, do not regenerate the code to manifest
- ** a view or the co-routine to implement a view. The first instance
- ** is sufficient, though the subroutine to manifest the view does need
- ** to be invoked again. */
- if( pItem->addrFillSub ){
- if( pItem->fg.viaCoroutine==0 ){
- /* The subroutine that manifests the view might be a one-time routine,
- ** or it might need to be rerun on each iteration because it
- ** encodes a correlated subquery. */
- testcase( sqlite3VdbeGetOp(v, pItem->addrFillSub)->opcode==OP_Once );
- sqlite3VdbeAddOp2(v, OP_Gosub, pItem->regReturn, pItem->addrFillSub);
- }
- continue;
- }
+ /* The code for a subquery should only be generated once, though it is
+ ** technically harmless for it to be generated multiple times. The
+ ** following assert() will detect if something changes to cause
+ ** the same subquery to be coded multiple times, as a signal to the
+ ** developers to try to optimize the situation. */
+ assert( pItem->addrFillSub==0 );
/* Increment Parse.nHeight by the height of the largest expression
** tree referred to by this, the parent select. The child select
@@ -130076,7 +130446,7 @@ SQLITE_PRIVATE int sqlite3Select(
/* Set the limiter.
*/
- iEnd = sqlite3VdbeMakeLabel(v);
+ iEnd = sqlite3VdbeMakeLabel(pParse);
if( (p->selFlags & SF_FixedLimit)==0 ){
p->nSelectRow = 320; /* 4 billion rows */
}
@@ -130143,9 +130513,9 @@ SQLITE_PRIVATE int sqlite3Select(
assert( p->pEList==pEList );
#ifndef SQLITE_OMIT_WINDOWFUNC
if( pWin ){
- int addrGosub = sqlite3VdbeMakeLabel(v);
- int iCont = sqlite3VdbeMakeLabel(v);
- int iBreak = sqlite3VdbeMakeLabel(v);
+ int addrGosub = sqlite3VdbeMakeLabel(pParse);
+ int iCont = sqlite3VdbeMakeLabel(pParse);
+ int iBreak = sqlite3VdbeMakeLabel(pParse);
int regGosub = ++pParse->nMem;
sqlite3WindowCodeStep(pParse, p, pWInfo, regGosub, addrGosub);
@@ -130220,7 +130590,7 @@ SQLITE_PRIVATE int sqlite3Select(
}
/* Create a label to jump to when we want to abort the query */
- addrEnd = sqlite3VdbeMakeLabel(v);
+ addrEnd = sqlite3VdbeMakeLabel(pParse);
/* Convert TK_COLUMN nodes into TK_AGG_COLUMN and make entries in
** sAggInfo for all TK_AGG_FUNCTION nodes in expressions of the
@@ -130309,9 +130679,9 @@ SQLITE_PRIVATE int sqlite3Select(
iUseFlag = ++pParse->nMem;
iAbortFlag = ++pParse->nMem;
regOutputRow = ++pParse->nMem;
- addrOutputRow = sqlite3VdbeMakeLabel(v);
+ addrOutputRow = sqlite3VdbeMakeLabel(pParse);
regReset = ++pParse->nMem;
- addrReset = sqlite3VdbeMakeLabel(v);
+ addrReset = sqlite3VdbeMakeLabel(pParse);
iAMem = pParse->nMem + 1;
pParse->nMem += pGroupBy->nExpr;
iBMem = pParse->nMem + 1;
@@ -131598,7 +131968,7 @@ static SrcList *targetSrcList(
int iDb; /* Index of the database to use */
SrcList *pSrc; /* SrcList to be returned */
- pSrc = sqlite3SrcListAppend(db, 0, 0, 0);
+ pSrc = sqlite3SrcListAppend(pParse, 0, 0, 0);
if( pSrc ){
assert( pSrc->nSrc>0 );
pSrc->a[pSrc->nSrc-1].zName = sqlite3DbStrDup(db, pStep->zTarget);
@@ -131811,7 +132181,7 @@ static TriggerPrg *codeRowTrigger(
if( SQLITE_OK==sqlite3ResolveExprNames(&sNC, pWhen)
&& db->mallocFailed==0
){
- iEndTrigger = sqlite3VdbeMakeLabel(v);
+ iEndTrigger = sqlite3VdbeMakeLabel(pSubParse);
sqlite3ExprIfFalse(pSubParse, pWhen, iEndTrigger, SQLITE_JUMPIFNULL);
}
sqlite3ExprDelete(db, pWhen);
@@ -132410,6 +132780,7 @@ SQLITE_PRIVATE void sqlite3Update(
** being updated. Fill in aRegIdx[] with a register number that will hold
** the key for accessing each index.
*/
+ if( onError==OE_Replace ) bReplace = 1;
for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
int reg;
if( chngKey || hasFK>1 || pIdx==pPk
@@ -132423,9 +132794,7 @@ SQLITE_PRIVATE void sqlite3Update(
if( indexColumnIsBeingUpdated(pIdx, i, aXRef, chngRowid) ){
reg = ++pParse->nMem;
pParse->nMem += pIdx->nColumn;
- if( (onError==OE_Replace)
- || (onError==OE_Default && pIdx->onError==OE_Replace)
- ){
+ if( onError==OE_Default && pIdx->onError==OE_Replace ){
bReplace = 1;
}
break;
@@ -132497,7 +132866,7 @@ SQLITE_PRIVATE void sqlite3Update(
#endif
/* Jump to labelBreak to abandon further processing of this UPDATE */
- labelContinue = labelBreak = sqlite3VdbeMakeLabel(v);
+ labelContinue = labelBreak = sqlite3VdbeMakeLabel(pParse);
/* Not an UPSERT. Normal processing. Begin by
** initialize the count of updated rows */
@@ -132632,13 +133001,13 @@ SQLITE_PRIVATE void sqlite3Update(
VdbeCoverage(v);
}
if( eOnePass!=ONEPASS_SINGLE ){
- labelContinue = sqlite3VdbeMakeLabel(v);
+ labelContinue = sqlite3VdbeMakeLabel(pParse);
}
sqlite3VdbeAddOp2(v, OP_IsNull, pPk ? regKey : regOldRowid, labelBreak);
VdbeCoverageIf(v, pPk==0);
VdbeCoverageIf(v, pPk!=0);
}else if( pPk ){
- labelContinue = sqlite3VdbeMakeLabel(v);
+ labelContinue = sqlite3VdbeMakeLabel(pParse);
sqlite3VdbeAddOp2(v, OP_Rewind, iEph, labelBreak); VdbeCoverage(v);
addrTop = sqlite3VdbeAddOp2(v, OP_RowData, iEph, regKey);
sqlite3VdbeAddOp4Int(v, OP_NotFound, iDataCur, labelContinue, regKey, 0);
@@ -133406,16 +133775,16 @@ static int execSqlF(sqlite3 *db, char **pzErrMsg, const char *zSql, ...){
** transient would cause the database file to appear to be deleted
** following reboot.
*/
-SQLITE_PRIVATE void sqlite3Vacuum(Parse *pParse, Token *pNm){
+SQLITE_PRIVATE void sqlite3Vacuum(Parse *pParse, Token *pNm, Expr *pInto){
Vdbe *v = sqlite3GetVdbe(pParse);
int iDb = 0;
- if( v==0 ) return;
+ if( v==0 ) goto build_vacuum_end;
if( pNm ){
#ifndef SQLITE_BUG_COMPATIBLE_20160819
/* Default behavior: Report an error if the argument to VACUUM is
** not recognized */
iDb = sqlite3TwoPartName(pParse, pNm, pNm, &pNm);
- if( iDb<0 ) return;
+ if( iDb<0 ) goto build_vacuum_end;
#else
/* When SQLITE_BUG_COMPATIBLE_20160819 is defined, unrecognized arguments
** to VACUUM are silently ignored. This is a back-out of a bug fix that
@@ -133427,21 +133796,33 @@ SQLITE_PRIVATE void sqlite3Vacuum(Parse *pParse, Token *pNm){
#endif
}
if( iDb!=1 ){
- sqlite3VdbeAddOp1(v, OP_Vacuum, iDb);
+ int iIntoReg = 0;
+ if( pInto && sqlite3ResolveSelfReference(pParse,0,0,pInto,0)==0 ){
+ iIntoReg = ++pParse->nMem;
+ sqlite3ExprCode(pParse, pInto, iIntoReg);
+ }
+ sqlite3VdbeAddOp2(v, OP_Vacuum, iDb, iIntoReg);
sqlite3VdbeUsesBtree(v, iDb);
}
+build_vacuum_end:
+ sqlite3ExprDelete(pParse->db, pInto);
return;
}
/*
** This routine implements the OP_Vacuum opcode of the VDBE.
*/
-SQLITE_PRIVATE int sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db, int iDb){
+SQLITE_PRIVATE int sqlite3RunVacuum(
+ char **pzErrMsg, /* Write error message here */
+ sqlite3 *db, /* Database connection */
+ int iDb, /* Which attached DB to vacuum */
+ sqlite3_value *pOut /* Write results here, if not NULL */
+){
int rc = SQLITE_OK; /* Return code from service routines */
Btree *pMain; /* The database being vacuumed */
Btree *pTemp; /* The temporary database we vacuum into */
- u16 saved_mDbFlags; /* Saved value of db->mDbFlags */
- u32 saved_flags; /* Saved value of db->flags */
+ u32 saved_mDbFlags; /* Saved value of db->mDbFlags */
+ u64 saved_flags; /* Saved value of db->flags */
int saved_nChange; /* Saved value of db->nChange */
int saved_nTotalChange; /* Saved value of db->nTotalChange */
u8 saved_mTrace; /* Saved trace settings */
@@ -133450,6 +133831,7 @@ SQLITE_PRIVATE int sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db, int iDb){
int nRes; /* Bytes of reserved space at the end of each page */
int nDb; /* Number of attached databases */
const char *zDbMain; /* Schema name of database to vacuum */
+ const char *zOut; /* Name of output file */
if( !db->autoCommit ){
sqlite3SetString(pzErrMsg, db, "cannot VACUUM from within a transaction");
@@ -133459,6 +133841,15 @@ SQLITE_PRIVATE int sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db, int iDb){
sqlite3SetString(pzErrMsg, db,"cannot VACUUM - SQL statements in progress");
return SQLITE_ERROR;
}
+ if( pOut ){
+ if( sqlite3_value_type(pOut)!=SQLITE_TEXT ){
+ sqlite3SetString(pzErrMsg, db, "non-text filename");
+ return SQLITE_ERROR;
+ }
+ zOut = (const char*)sqlite3_value_text(pOut);
+ }else{
+ zOut = "";
+ }
/* Save the current value of the database flags so that it can be
** restored before returning. Then set the writable-schema flag, and
@@ -133470,7 +133861,7 @@ SQLITE_PRIVATE int sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db, int iDb){
saved_mTrace = db->mTrace;
db->flags |= SQLITE_WriteSchema | SQLITE_IgnoreChecks;
db->mDbFlags |= DBFLAG_PreferBuiltin | DBFLAG_Vacuum;
- db->flags &= ~(SQLITE_ForeignKeys | SQLITE_ReverseOrder
+ db->flags &= ~(u64)(SQLITE_ForeignKeys | SQLITE_ReverseOrder
| SQLITE_Defensive | SQLITE_CountRows);
db->mTrace = 0;
@@ -133493,19 +133884,21 @@ SQLITE_PRIVATE int sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db, int iDb){
** to write the journal header file.
*/
nDb = db->nDb;
- rc = execSql(db, pzErrMsg, "ATTACH''AS vacuum_db");
+ rc = execSqlF(db, pzErrMsg, "ATTACH %Q AS vacuum_db", zOut);
if( rc!=SQLITE_OK ) goto end_of_vacuum;
assert( (db->nDb-1)==nDb );
pDb = &db->aDb[nDb];
assert( strcmp(pDb->zDbSName,"vacuum_db")==0 );
pTemp = pDb->pBt;
-
- /* The call to execSql() to attach the temp database has left the file
- ** locked (as there was more than one active statement when the transaction
- ** to read the schema was concluded. Unlock it here so that this doesn't
- ** cause problems for the call to BtreeSetPageSize() below. */
- sqlite3BtreeCommit(pTemp);
-
+ if( pOut ){
+ sqlite3_file *id = sqlite3PagerFile(sqlite3BtreePager(pTemp));
+ i64 sz = 0;
+ if( id->pMethods!=0 && (sqlite3OsFileSize(id, &sz)!=SQLITE_OK || sz>0) ){
+ rc = SQLITE_ERROR;
+ sqlite3SetString(pzErrMsg, db, "output file already exists");
+ goto end_of_vacuum;
+ }
+ }
nRes = sqlite3BtreeGetOptimalReserve(pMain);
/* A VACUUM cannot change the pagesize of an encrypted database. */
@@ -133529,7 +133922,7 @@ SQLITE_PRIVATE int sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db, int iDb){
*/
rc = execSql(db, pzErrMsg, "BEGIN");
if( rc!=SQLITE_OK ) goto end_of_vacuum;
- rc = sqlite3BtreeBeginTrans(pMain, 2, 0);
+ rc = sqlite3BtreeBeginTrans(pMain, pOut==0 ? 2 : 0, 0);
if( rc!=SQLITE_OK ) goto end_of_vacuum;
/* Do not attempt to change the page size for a WAL database */
@@ -133624,7 +134017,7 @@ SQLITE_PRIVATE int sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db, int iDb){
};
assert( 1==sqlite3BtreeIsInTrans(pTemp) );
- assert( 1==sqlite3BtreeIsInTrans(pMain) );
+ assert( pOut!=0 || 1==sqlite3BtreeIsInTrans(pMain) );
/* Copy Btree meta values */
for(i=0; i<ArraySize(aCopy); i+=2){
@@ -133635,17 +134028,23 @@ SQLITE_PRIVATE int sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db, int iDb){
if( NEVER(rc!=SQLITE_OK) ) goto end_of_vacuum;
}
- rc = sqlite3BtreeCopyFile(pMain, pTemp);
+ if( pOut==0 ){
+ rc = sqlite3BtreeCopyFile(pMain, pTemp);
+ }
if( rc!=SQLITE_OK ) goto end_of_vacuum;
rc = sqlite3BtreeCommit(pTemp);
if( rc!=SQLITE_OK ) goto end_of_vacuum;
#ifndef SQLITE_OMIT_AUTOVACUUM
- sqlite3BtreeSetAutoVacuum(pMain, sqlite3BtreeGetAutoVacuum(pTemp));
+ if( pOut==0 ){
+ sqlite3BtreeSetAutoVacuum(pMain, sqlite3BtreeGetAutoVacuum(pTemp));
+ }
#endif
}
assert( rc==SQLITE_OK );
- rc = sqlite3BtreeSetPageSize(pMain, sqlite3BtreeGetPageSize(pTemp), nRes,1);
+ if( pOut==0 ){
+ rc = sqlite3BtreeSetPageSize(pMain, sqlite3BtreeGetPageSize(pTemp), nRes,1);
+ }
end_of_vacuum:
/* Restore the original value of db->flags */
@@ -134686,6 +135085,7 @@ SQLITE_PRIVATE int sqlite3VtabSavepoint(sqlite3 *db, int op, int iSavepoint){
const sqlite3_module *pMod = pVTab->pMod->pModule;
if( pVTab->pVtab && pMod->iVersion>=2 ){
int (*xMethod)(sqlite3_vtab *, int);
+ sqlite3VtabLock(pVTab);
switch( op ){
case SAVEPOINT_BEGIN:
xMethod = pMod->xSavepoint;
@@ -134701,6 +135101,7 @@ SQLITE_PRIVATE int sqlite3VtabSavepoint(sqlite3 *db, int op, int iSavepoint){
if( xMethod && pVTab->iSavepoint>iSavepoint ){
rc = xMethod(pVTab->pVtab, iSavepoint);
}
+ sqlite3VtabUnlock(pVTab);
}
}
}
@@ -135462,8 +135863,11 @@ SQLITE_PRIVATE void sqlite3WhereAddScanStatus(
# define sqlite3WhereAddScanStatus(a, b, c, d) ((void)d)
#endif
SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(
+ Parse *pParse, /* Parsing context */
+ Vdbe *v, /* Prepared statement under construction */
WhereInfo *pWInfo, /* Complete information about the WHERE clause */
int iLevel, /* Which level of pWInfo->a[] should be coded */
+ WhereLevel *pLevel, /* The current level pointer */
Bitmask notReady /* Which tables are currently available */
);
@@ -135733,6 +136137,7 @@ SQLITE_PRIVATE int sqlite3WhereExplainOneScan(
}
#endif
zMsg = sqlite3StrAccumFinish(&str);
+ sqlite3ExplainBreakpoint("",zMsg);
ret = sqlite3VdbeAddOp4(v, OP_Explain, sqlite3VdbeCurrentAddr(v),
pParse->addrExplain, 0, zMsg,P4_DYNAMIC);
}
@@ -136058,16 +136463,17 @@ static int codeEqualityTerm(
if( pLoop->aLTerm[i]->pExpr==pX ) nEq++;
}
+ iTab = 0;
if( (pX->flags & EP_xIsSelect)==0 || pX->x.pSelect->pEList->nExpr==1 ){
- eType = sqlite3FindInIndex(pParse, pX, IN_INDEX_LOOP, 0, 0);
+ eType = sqlite3FindInIndex(pParse, pX, IN_INDEX_LOOP, 0, 0, &iTab);
}else{
sqlite3 *db = pParse->db;
pX = removeUnindexableInClauseTerms(pParse, iEq, pLoop, pX);
if( !db->mallocFailed ){
aiMap = (int*)sqlite3DbMallocZero(pParse->db, sizeof(int)*nEq);
- eType = sqlite3FindInIndex(pParse, pX, IN_INDEX_LOOP, 0, aiMap);
- pTerm->pExpr->iTable = pX->iTable;
+ eType = sqlite3FindInIndex(pParse, pX, IN_INDEX_LOOP, 0, aiMap, &iTab);
+ pTerm->pExpr->iTable = iTab;
}
sqlite3ExprDelete(db, pX);
pX = pTerm->pExpr;
@@ -136077,7 +136483,6 @@ static int codeEqualityTerm(
testcase( bRev );
bRev = !bRev;
}
- iTab = pX->iTable;
sqlite3VdbeAddOp2(v, bRev ? OP_Last : OP_Rewind, iTab, 0);
VdbeCoverageIf(v, bRev);
VdbeCoverageIf(v, !bRev);
@@ -136085,7 +136490,7 @@ static int codeEqualityTerm(
pLoop->wsFlags |= WHERE_IN_ABLE;
if( pLevel->u.in.nIn==0 ){
- pLevel->addrNxt = sqlite3VdbeMakeLabel(v);
+ pLevel->addrNxt = sqlite3VdbeMakeLabel(pParse);
}
i = pLevel->u.in.nIn;
@@ -136596,7 +137001,9 @@ static void codeExprOrVector(Parse *pParse, Expr *p, int iReg, int nReg){
#ifndef SQLITE_OMIT_SUBQUERY
if( (p->flags & EP_xIsSelect) ){
Vdbe *v = pParse->pVdbe;
- int iSelect = sqlite3CodeSubselect(pParse, p, 0, 0);
+ int iSelect;
+ assert( p->op==TK_SELECT );
+ iSelect = sqlite3CodeSubselect(pParse, p);
sqlite3VdbeAddOp3(v, OP_Copy, iSelect, iReg, nReg-1);
}else
#endif
@@ -136682,22 +137089,21 @@ static void whereIndexExprTrans(
** implementation described by pWInfo.
*/
SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(
+ Parse *pParse, /* Parsing context */
+ Vdbe *v, /* Prepared statement under construction */
WhereInfo *pWInfo, /* Complete information about the WHERE clause */
int iLevel, /* Which level of pWInfo->a[] should be coded */
+ WhereLevel *pLevel, /* The current level pointer */
Bitmask notReady /* Which tables are currently available */
){
int j, k; /* Loop counters */
int iCur; /* The VDBE cursor for the table */
int addrNxt; /* Where to jump to continue with the next IN case */
- int omitTable; /* True if we use the index only */
int bRev; /* True if we need to scan in reverse order */
- WhereLevel *pLevel; /* The where level to be coded */
WhereLoop *pLoop; /* The WhereLoop object being coded */
WhereClause *pWC; /* Decomposition of the entire WHERE clause */
WhereTerm *pTerm; /* A WHERE clause term */
- Parse *pParse; /* Parsing context */
sqlite3 *db; /* Database connection */
- Vdbe *v; /* The prepared stmt under constructions */
struct SrcList_item *pTabItem; /* FROM clause term being coded */
int addrBrk; /* Jump here to break out of the loop */
int addrHalt; /* addrBrk for the outermost loop */
@@ -136707,18 +137113,13 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(
Index *pIdx = 0; /* Index used by loop (if any) */
int iLoop; /* Iteration of constraint generator loop */
- pParse = pWInfo->pParse;
- v = pParse->pVdbe;
pWC = &pWInfo->sWC;
db = pParse->db;
- pLevel = &pWInfo->a[iLevel];
pLoop = pLevel->pWLoop;
pTabItem = &pWInfo->pTabList->a[pLevel->iFrom];
iCur = pTabItem->iCursor;
pLevel->notReady = notReady & ~sqlite3WhereGetMask(&pWInfo->sMaskSet, iCur);
bRev = (pWInfo->revMask>>iLevel)&1;
- omitTable = (pLoop->wsFlags & WHERE_IDX_ONLY)!=0
- && (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)==0;
VdbeModuleComment((v, "Begin WHERE-loop%d: %s",iLevel,pTabItem->pTab->zName));
/* Create labels for the "break" and "continue" instructions
@@ -136731,8 +137132,8 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(
** there are no IN operators in the constraints, the "addrNxt" label
** is the same as "addrBrk".
*/
- addrBrk = pLevel->addrBrk = pLevel->addrNxt = sqlite3VdbeMakeLabel(v);
- addrCont = pLevel->addrCont = sqlite3VdbeMakeLabel(v);
+ addrBrk = pLevel->addrBrk = pLevel->addrNxt = sqlite3VdbeMakeLabel(pParse);
+ addrCont = pLevel->addrCont = sqlite3VdbeMakeLabel(pParse);
/* If this is the right table of a LEFT OUTER JOIN, allocate and
** initialize a memory cell that records if this table matches any
@@ -136859,7 +137260,6 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(
pTerm = pLoop->aLTerm[0];
assert( pTerm!=0 );
assert( pTerm->pExpr!=0 );
- assert( omitTable==0 );
testcase( pTerm->wtFlags & TERM_VIRTUAL );
iReleaseReg = ++pParse->nMem;
iRowidReg = codeEqualityTerm(pParse, pTerm, pLevel, 0, bRev, iReleaseReg);
@@ -136878,7 +137278,6 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(
int memEndValue = 0;
WhereTerm *pStart, *pEnd;
- assert( omitTable==0 );
j = 0;
pStart = pEnd = 0;
if( pLoop->wsFlags & WHERE_BTM_LIMIT ) pStart = pLoop->aLTerm[j++];
@@ -137042,6 +137441,8 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(
char *zEndAff = 0; /* Affinity for end of range constraint */
u8 bSeekPastNull = 0; /* True to seek past initial nulls */
u8 bStopAtNull = 0; /* Add condition to terminate at NULLs */
+ int omitTable; /* True if we use the index only */
+
pIdx = pLoop->u.btree.pIndex;
iIdxCur = pLevel->iIdxCur;
@@ -137243,6 +137644,8 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(
}
/* Seek the table cursor, if required */
+ omitTable = (pLoop->wsFlags & WHERE_IDX_ONLY)!=0
+ && (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)==0;
if( omitTable ){
/* pIdx is a covering index. No need to access the main table. */
}else if( HasRowid(pIdx->pTable) ){
@@ -137277,8 +137680,13 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(
** the cursor. In this case it is important to do the full evaluation,
** as the result of the expression may not be NULL, even if all table
** column values are. https://www.sqlite.org/src/info/7fa8049685b50b5a
+ **
+ ** Also, do not do this when processing one index an a multi-index
+ ** OR clause, since the transformation will become invalid once we
+ ** move forward to the next index.
+ ** https://sqlite.org/src/info/4e8e4857d32d401f
*/
- if( pLevel->iLeftJoin==0 ){
+ if( pLevel->iLeftJoin==0 && (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)==0 ){
whereIndexExprTrans(pIdx, iCur, iIdxCur, pWInfo);
}
@@ -137353,7 +137761,7 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(
int regReturn = ++pParse->nMem; /* Register used with OP_Gosub */
int regRowset = 0; /* Register for RowSet object */
int regRowid = 0; /* Register holding rowid */
- int iLoopBody = sqlite3VdbeMakeLabel(v); /* Start of loop body */
+ int iLoopBody = sqlite3VdbeMakeLabel(pParse);/* Start of loop body */
int iRetInit; /* Address of regReturn init */
int untestedTerms = 0; /* Some terms not completely tested */
int ii; /* Loop counter */
@@ -137469,6 +137877,7 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(
pOrExpr = pAndExpr;
}
/* Loop through table entries that match term pOrTerm. */
+ ExplainQueryPlan((pParse, 1, "INDEX %d", ii+1));
WHERETRACE(0xffff, ("Subplan for OR-clause:\n"));
pSubWInfo = sqlite3WhereBegin(pParse, pOrTab, pOrExpr, 0, 0,
wctrlFlags, iCovCur);
@@ -137572,6 +137981,7 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(
/* Finish the loop through table entries that match term pOrTerm. */
sqlite3WhereEnd(pSubWInfo);
+ ExplainQueryPlanPop(pParse);
}
}
}
@@ -138533,6 +138943,7 @@ static void exprAnalyzeOrTerm(
** and column is found but leave okToChngToIN false if not found.
*/
for(j=0; j<2 && !okToChngToIN; j++){
+ Expr *pLeft = 0;
pOrTerm = pOrWc->a;
for(i=pOrWc->nTerm-1; i>=0; i--, pOrTerm++){
assert( pOrTerm->eOperator & WO_EQ );
@@ -138556,6 +138967,7 @@ static void exprAnalyzeOrTerm(
}
iColumn = pOrTerm->u.leftColumn;
iCursor = pOrTerm->leftCursor;
+ pLeft = pOrTerm->pExpr->pLeft;
break;
}
if( i<0 ){
@@ -138575,7 +138987,9 @@ static void exprAnalyzeOrTerm(
assert( pOrTerm->eOperator & WO_EQ );
if( pOrTerm->leftCursor!=iCursor ){
pOrTerm->wtFlags &= ~TERM_OR_OK;
- }else if( pOrTerm->u.leftColumn!=iColumn ){
+ }else if( pOrTerm->u.leftColumn!=iColumn || (iColumn==XN_EXPR
+ && sqlite3ExprCompare(pParse, pOrTerm->pExpr->pLeft, pLeft, -1)
+ )){
okToChngToIN = 0;
}else{
int affLeft, affRight;
@@ -139664,6 +140078,17 @@ static WhereTerm *whereScanNext(WhereScan *pScan){
}
/*
+** This is whereScanInit() for the case of an index on an expression.
+** It is factored out into a separate tail-recursion subroutine so that
+** the normal whereScanInit() routine, which is a high-runner, does not
+** need to push registers onto the stack as part of its prologue.
+*/
+static SQLITE_NOINLINE WhereTerm *whereScanInitIndexExpr(WhereScan *pScan){
+ pScan->idxaff = sqlite3ExprAffinity(pScan->pIdxExpr);
+ return whereScanNext(pScan);
+}
+
+/*
** Initialize a WHERE clause scanner object. Return a pointer to the
** first match. Return NULL if there are no matches.
**
@@ -139695,12 +140120,19 @@ static WhereTerm *whereScanInit(
pScan->pIdxExpr = 0;
pScan->idxaff = 0;
pScan->zCollName = 0;
+ pScan->opMask = opMask;
+ pScan->k = 0;
+ pScan->aiCur[0] = iCur;
+ pScan->nEquiv = 1;
+ pScan->iEquiv = 1;
if( pIdx ){
int j = iColumn;
iColumn = pIdx->aiColumn[j];
if( iColumn==XN_EXPR ){
pScan->pIdxExpr = pIdx->aColExpr->a[j].pExpr;
pScan->zCollName = pIdx->azColl[j];
+ pScan->aiColumn[0] = XN_EXPR;
+ return whereScanInitIndexExpr(pScan);
}else if( iColumn==pIdx->pTable->iPKey ){
iColumn = XN_ROWID;
}else if( iColumn>=0 ){
@@ -139710,12 +140142,7 @@ static WhereTerm *whereScanInit(
}else if( iColumn==XN_EXPR ){
return 0;
}
- pScan->opMask = opMask;
- pScan->k = 0;
- pScan->aiCur[0] = iCur;
pScan->aiColumn[0] = iColumn;
- pScan->nEquiv = 1;
- pScan->iEquiv = 1;
return whereScanNext(pScan);
}
@@ -140190,7 +140617,7 @@ static void constructAutomaticIndex(
addrTop = sqlite3VdbeAddOp1(v, OP_Rewind, pLevel->iTabCur); VdbeCoverage(v);
}
if( pPartial ){
- iContinue = sqlite3VdbeMakeLabel(v);
+ iContinue = sqlite3VdbeMakeLabel(pParse);
sqlite3ExprIfFalse(pParse, pPartial, iContinue, SQLITE_JUMPIFNULL);
pLoop->wsFlags |= WHERE_PARTIALIDX;
}
@@ -140207,6 +140634,7 @@ static void constructAutomaticIndex(
translateColumnToCopy(pParse, addrTop, pLevel->iTabCur,
pTabItem->regResult, 1);
sqlite3VdbeGoto(v, addrTop);
+ pTabItem->fg.viaCoroutine = 0;
}else{
sqlite3VdbeAddOp2(v, OP_Next, pLevel->iTabCur, addrTop+1); VdbeCoverage(v);
}
@@ -141562,7 +141990,7 @@ static int whereLoopInsert(WhereLoopBuilder *pBuilder, WhereLoop *pTemplate){
rc = whereLoopXfer(db, p, pTemplate);
if( (p->wsFlags & WHERE_VIRTUALTABLE)==0 ){
Index *pIndex = p->u.btree.pIndex;
- if( pIndex && pIndex->tnum==0 ){
+ if( pIndex && pIndex->idxType==SQLITE_IDXTYPE_IPK ){
p->u.btree.pIndex = 0;
}
}
@@ -141729,8 +142157,8 @@ static int whereRangeVectorLen(
** terms only. If it is modified, this value is restored before this
** function returns.
**
-** If pProbe->tnum==0, that means pIndex is a fake index used for the
-** INTEGER PRIMARY KEY.
+** If pProbe->idxType==SQLITE_IDXTYPE_IPK, that means pIndex is
+** a fake index used for the INTEGER PRIMARY KEY.
*/
static int whereLoopAddBtreeIndex(
WhereLoopBuilder *pBuilder, /* The WhereLoop factory */
@@ -142230,6 +142658,7 @@ static int whereLoopAddBtree(
sPk.onError = OE_Replace;
sPk.pTable = pTab;
sPk.szIdxRow = pTab->szTabRow;
+ sPk.idxType = SQLITE_IDXTYPE_IPK;
aiRowEstPk[0] = pTab->nRowLogEst;
aiRowEstPk[1] = 0;
pFirst = pSrc->pTab->pIndex;
@@ -142320,7 +142749,7 @@ static int whereLoopAddBtree(
b = indexMightHelpWithOrderBy(pBuilder, pProbe, pSrc->iCursor);
/* The ONEPASS_DESIRED flags never occurs together with ORDER BY */
assert( (pWInfo->wctrlFlags & WHERE_ONEPASS_DESIRED)==0 || b==0 );
- if( pProbe->tnum<=0 ){
+ if( pProbe->idxType==SQLITE_IDXTYPE_IPK ){
/* Integer primary key index */
pNew->wsFlags = WHERE_IPK;
@@ -143996,7 +144425,7 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
pWInfo->pResultSet = pResultSet;
pWInfo->aiCurOnePass[0] = pWInfo->aiCurOnePass[1] = -1;
pWInfo->nLevel = nTabList;
- pWInfo->iBreak = pWInfo->iContinue = sqlite3VdbeMakeLabel(v);
+ pWInfo->iBreak = pWInfo->iContinue = sqlite3VdbeMakeLabel(pParse);
pWInfo->wctrlFlags = wctrlFlags;
pWInfo->iLimit = iAuxArg;
pWInfo->savedNQueryLoop = pParse->nQueryLoop;
@@ -144270,9 +144699,10 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
if( (wctrlFlags & WHERE_ONEPASS_DESIRED)!=0 ){
int wsFlags = pWInfo->a[0].pWLoop->wsFlags;
int bOnerow = (wsFlags & WHERE_ONEROW)!=0;
+ assert( !(wsFlags & WHERE_VIRTUALTABLE) || IsVirtual(pTabList->a[0].pTab) );
if( bOnerow || (
0!=(wctrlFlags & WHERE_ONEPASS_MULTIROW)
- && 0==(wsFlags & WHERE_VIRTUALTABLE)
+ && !IsVirtual(pTabList->a[0].pTab)
&& (0==(wsFlags & WHERE_MULTI_OR) || (wctrlFlags & WHERE_DUPLICATES_OK))
)){
pWInfo->eOnePass = bOnerow ? ONEPASS_SINGLE : ONEPASS_MULTI;
@@ -144427,7 +144857,7 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
pParse, pTabList, pLevel, wctrlFlags
);
pLevel->addrBody = sqlite3VdbeCurrentAddr(v);
- notReady = sqlite3WhereCodeOneLoopStart(pWInfo, ii, notReady);
+ notReady = sqlite3WhereCodeOneLoopStart(pParse,v,pWInfo,ii,pLevel,notReady);
pWInfo->iContinue = pLevel->addrCont;
if( (wsFlags&WHERE_MULTI_OR)==0 && (wctrlFlags&WHERE_OR_SUBCLAUSE)==0 ){
sqlite3WhereAddScanStatus(v, pTabList, pLevel, addrExplain);
@@ -144612,6 +145042,29 @@ SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo *pWInfo){
continue;
}
+#ifdef SQLITE_ENABLE_EARLY_CURSOR_CLOSE
+ /* Close all of the cursors that were opened by sqlite3WhereBegin.
+ ** Except, do not close cursors that will be reused by the OR optimization
+ ** (WHERE_OR_SUBCLAUSE). And do not close the OP_OpenWrite cursors
+ ** created for the ONEPASS optimization.
+ */
+ if( (pTab->tabFlags & TF_Ephemeral)==0
+ && pTab->pSelect==0
+ && (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)==0
+ ){
+ int ws = pLoop->wsFlags;
+ if( pWInfo->eOnePass==ONEPASS_OFF && (ws & WHERE_IDX_ONLY)==0 ){
+ sqlite3VdbeAddOp1(v, OP_Close, pTabItem->iCursor);
+ }
+ if( (ws & WHERE_INDEXED)!=0
+ && (ws & (WHERE_IPK|WHERE_AUTO_INDEX))==0
+ && pLevel->iIdxCur!=pWInfo->aiCurOnePass[1]
+ ){
+ sqlite3VdbeAddOp1(v, OP_Close, pLevel->iIdxCur);
+ }
+ }
+#endif
+
/* If this scan uses an index, make VDBE code substitutions to read data
** from the index instead of from the table where possible. In some cases
** this optimization prevents the table from ever being read, which can
@@ -145511,8 +145964,7 @@ SQLITE_PRIVATE int sqlite3WindowRewrite(Parse *pParse, Select *p){
pSub = sqlite3SelectNew(
pParse, pSublist, pSrc, pWhere, pGroupBy, pHaving, pSort, 0, 0
);
- p->pSrc = sqlite3SrcListAppend(db, 0, 0, 0);
- assert( p->pSrc || db->mallocFailed );
+ p->pSrc = sqlite3SrcListAppend(pParse, 0, 0, 0);
if( p->pSrc ){
p->pSrc->a[0].pSelect = pSub;
sqlite3SrcListAssignCursors(pParse, p->pSrc);
@@ -145569,6 +146021,7 @@ SQLITE_PRIVATE void sqlite3WindowListDelete(sqlite3 *db, Window *p){
*/
static Expr *sqlite3WindowOffsetExpr(Parse *pParse, Expr *pExpr){
if( 0==sqlite3ExprIsConstant(pExpr) ){
+ if( IN_RENAME_OBJECT ) sqlite3RenameExprUnmap(pParse, pExpr);
sqlite3ExprDelete(pParse->db, pExpr);
pExpr = sqlite3ExprAlloc(pParse->db, TK_NULL, 0, 0);
}
@@ -145763,6 +146216,7 @@ static void windowCheckIntValue(Parse *pParse, int reg, int eCond){
VdbeCoverageNeverNullIf(v, eCond==0);
VdbeCoverageNeverNullIf(v, eCond==1);
VdbeCoverageNeverNullIf(v, eCond==2);
+ sqlite3MayAbort(pParse);
sqlite3VdbeAddOp2(v, OP_Halt, SQLITE_ERROR, OE_Abort);
sqlite3VdbeAppendP4(v, (void*)azErr[eCond], P4_STATIC);
sqlite3ReleaseTempReg(pParse, regZero);
@@ -146018,7 +146472,7 @@ static void windowReturnOneRow(
|| pFunc->zName==first_valueName
){
int csr = pWin->csrApp;
- int lbl = sqlite3VdbeMakeLabel(v);
+ int lbl = sqlite3VdbeMakeLabel(pParse);
int tmpReg = sqlite3GetTempReg(pParse);
sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regResult);
@@ -146041,7 +146495,7 @@ static void windowReturnOneRow(
int nArg = pWin->pOwner->x.pList->nExpr;
int iEph = pMWin->iEphCsr;
int csr = pWin->csrApp;
- int lbl = sqlite3VdbeMakeLabel(v);
+ int lbl = sqlite3VdbeMakeLabel(pParse);
int tmpReg = sqlite3GetTempReg(pParse);
if( nArg<3 ){
@@ -146302,8 +146756,8 @@ static void windowCodeRowExprStep(
/* Allocate register and label for the "flush_partition" sub-routine. */
regFlushPart = ++pParse->nMem;
- lblFlushPart = sqlite3VdbeMakeLabel(v);
- lblFlushDone = sqlite3VdbeMakeLabel(v);
+ lblFlushPart = sqlite3VdbeMakeLabel(pParse);
+ lblFlushDone = sqlite3VdbeMakeLabel(pParse);
regStart = ++pParse->nMem;
regEnd = ++pParse->nMem;
@@ -146413,7 +146867,7 @@ static void windowCodeRowExprStep(
|| pMWin->eStart==TK_PRECEDING
|| pMWin->eStart==TK_FOLLOWING
){
- int lblSkipInverse = sqlite3VdbeMakeLabel(v);;
+ int lblSkipInverse = sqlite3VdbeMakeLabel(pParse);;
if( pMWin->eStart==TK_PRECEDING ){
sqlite3VdbeAddOp3(v, OP_IfPos, regStart, lblSkipInverse, 1);
VdbeCoverage(v);
@@ -146578,13 +147032,13 @@ static void windowCodeCacheStep(
|| (pMWin->eStart==TK_CURRENT && pMWin->eEnd==TK_UNBOUNDED)
);
- lblEmpty = sqlite3VdbeMakeLabel(v);
+ lblEmpty = sqlite3VdbeMakeLabel(pParse);
regNewPeer = pParse->nMem+1;
pParse->nMem += nPeer;
/* Allocate register and label for the "flush_partition" sub-routine. */
regFlushPart = ++pParse->nMem;
- lblFlushPart = sqlite3VdbeMakeLabel(v);
+ lblFlushPart = sqlite3VdbeMakeLabel(pParse);
csrLead = pParse->nTab++;
regCtr = ++pParse->nMem;
@@ -146821,6 +147275,7 @@ SQLITE_PRIVATE Window *sqlite3WindowDup(sqlite3 *db, Expr *pOwner, Window *p){
if( pNew ){
pNew->zName = sqlite3DbStrDup(db, p->zName);
pNew->pFilter = sqlite3ExprDup(db, p->pFilter, 0);
+ pNew->pFunc = p->pFunc;
pNew->pPartition = sqlite3ExprListDup(db, p->pPartition, 0);
pNew->pOrderBy = sqlite3ExprListDup(db, p->pOrderBy, 0);
pNew->eType = p->eType;
@@ -147078,8 +147533,7 @@ static void disableLookaside(Parse *pParse){
memcpy(p->u.zToken, t.z, t.n);
p->u.zToken[t.n] = 0;
if( sqlite3Isquote(p->u.zToken[0]) ){
- if( p->u.zToken[0]=='"' ) p->flags |= EP_DblQuoted;
- sqlite3Dequote(p->u.zToken);
+ sqlite3DequoteExpr(p);
}
#if SQLITE_MAX_EXPR_DEPTH>0
p->nHeight = 1;
@@ -147187,26 +147641,26 @@ static void disableLookaside(Parse *pParse){
# define INTERFACE 1
#endif
/************* Begin control #defines *****************************************/
-#define YYCODETYPE unsigned char
-#define YYNOCODE 255
+#define YYCODETYPE unsigned short int
+#define YYNOCODE 256
#define YYACTIONTYPE unsigned short int
#define YYWILDCARD 85
#define sqlite3ParserTOKENTYPE Token
typedef union {
int yyinit;
sqlite3ParserTOKENTYPE yy0;
- 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;
+ 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;
} YYMINORTYPE;
#ifndef YYSTACKDEPTH
#define YYSTACKDEPTH 100
@@ -147222,17 +147676,17 @@ typedef union {
#define sqlite3ParserCTX_FETCH Parse *pParse=yypParser->pParse;
#define sqlite3ParserCTX_STORE yypParser->pParse=pParse;
#define YYFALLBACK 1
-#define YYNSTATE 484
-#define YYNRULE 334
+#define YYNSTATE 487
+#define YYNRULE 336
#define YYNTOKEN 146
-#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
+#define YY_MAX_SHIFT 486
+#define YY_MIN_SHIFTREDUCE 700
+#define YY_MAX_SHIFTREDUCE 1035
+#define YY_ERROR_ACTION 1036
+#define YY_ACCEPT_ACTION 1037
+#define YY_NO_ACTION 1038
+#define YY_MIN_REDUCE 1039
+#define YY_MAX_REDUCE 1374
/************* End control #defines *******************************************/
#define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])))
@@ -147299,493 +147753,494 @@ typedef union {
** yy_default[] Default action for each state.
**
*********** Begin parsing tables **********************************************/
-#define YY_ACTTAB_COUNT (1614)
+#define YY_ACTTAB_COUNT (1617)
static const YYACTIONTYPE yy_action[] = {
- /* 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,
+ /* 0 */ 99, 96, 185, 481, 1108, 1108, 232, 408, 1037, 1,
+ /* 10 */ 1, 486, 1039, 481, 1103, 1082, 350, 260, 451, 121,
+ /* 20 */ 348, 1299, 1120, 1103, 9, 9, 1116, 345, 828, 99,
+ /* 30 */ 96, 185, 452, 478, 58, 58, 829, 13, 361, 12,
+ /* 40 */ 12, 106, 107, 97, 1013, 1013, 892, 895, 885, 885,
+ /* 50 */ 104, 104, 105, 105, 105, 105, 1106, 1106, 237, 237,
+ /* 60 */ 99, 96, 185, 481, 237, 237, 1319, 486, 1039, 463,
+ /* 70 */ 478, 346, 350, 260, 992, 121, 478, 400, 453, 83,
+ /* 80 */ 213, 182, 1116, 193, 57, 57, 103, 103, 103, 103,
+ /* 90 */ 102, 102, 101, 101, 101, 100, 381, 106, 107, 97,
+ /* 100 */ 1013, 1013, 892, 895, 885, 885, 104, 104, 105, 105,
+ /* 110 */ 105, 105, 383, 481, 237, 237, 992, 993, 994, 205,
+ /* 120 */ 399, 281, 436, 433, 432, 108, 478, 381, 350, 974,
+ /* 130 */ 1368, 1166, 431, 1368, 58, 58, 475, 475, 475, 193,
+ /* 140 */ 321, 480, 103, 103, 103, 103, 102, 102, 101, 101,
+ /* 150 */ 101, 100, 381, 106, 107, 97, 1013, 1013, 892, 895,
+ /* 160 */ 885, 885, 104, 104, 105, 105, 105, 105, 383, 463,
+ /* 170 */ 102, 102, 101, 101, 101, 100, 381, 273, 462, 67,
+ /* 180 */ 99, 96, 185, 205, 350, 170, 436, 433, 432, 68,
+ /* 190 */ 101, 101, 101, 100, 381, 972, 431, 337, 103, 103,
+ /* 200 */ 103, 103, 102, 102, 101, 101, 101, 100, 381, 106,
+ /* 210 */ 107, 97, 1013, 1013, 892, 895, 885, 885, 104, 104,
+ /* 220 */ 105, 105, 105, 105, 481, 401, 103, 103, 103, 103,
+ /* 230 */ 102, 102, 101, 101, 101, 100, 381, 1165, 974, 1369,
+ /* 240 */ 350, 270, 1369, 272, 295, 58, 58, 851, 992, 882,
+ /* 250 */ 882, 893, 896, 1342, 103, 103, 103, 103, 102, 102,
+ /* 260 */ 101, 101, 101, 100, 381, 106, 107, 97, 1013, 1013,
+ /* 270 */ 892, 895, 885, 885, 104, 104, 105, 105, 105, 105,
+ /* 280 */ 463, 231, 231, 794, 318, 872, 99, 96, 185, 442,
+ /* 290 */ 992, 993, 994, 478, 378, 377, 350, 703, 704, 705,
+ /* 300 */ 736, 865, 992, 1341, 972, 864, 759, 271, 145, 886,
+ /* 310 */ 103, 103, 103, 103, 102, 102, 101, 101, 101, 100,
+ /* 320 */ 381, 106, 107, 97, 1013, 1013, 892, 895, 885, 885,
+ /* 330 */ 104, 104, 105, 105, 105, 105, 864, 864, 866, 1020,
+ /* 340 */ 481, 1020, 481, 179, 992, 993, 994, 457, 259, 472,
+ /* 350 */ 100, 381, 350, 379, 379, 379, 729, 212, 1370, 335,
+ /* 360 */ 183, 58, 58, 58, 58, 854, 103, 103, 103, 103,
+ /* 370 */ 102, 102, 101, 101, 101, 100, 381, 106, 107, 97,
+ /* 380 */ 1013, 1013, 892, 895, 885, 885, 104, 104, 105, 105,
+ /* 390 */ 105, 105, 481, 170, 481, 8, 458, 359, 376, 320,
+ /* 400 */ 406, 328, 280, 394, 268, 342, 238, 238, 350, 423,
+ /* 410 */ 935, 854, 873, 42, 42, 58, 58, 306, 478, 145,
+ /* 420 */ 1306, 266, 103, 103, 103, 103, 102, 102, 101, 101,
+ /* 430 */ 101, 100, 381, 106, 107, 97, 1013, 1013, 892, 895,
+ /* 440 */ 885, 885, 104, 104, 105, 105, 105, 105, 280, 481,
+ /* 450 */ 380, 386, 80, 237, 237, 259, 472, 385, 1197, 259,
+ /* 460 */ 472, 169, 127, 267, 350, 478, 398, 306, 859, 243,
+ /* 470 */ 43, 43, 940, 940, 420, 278, 188, 1114, 103, 103,
+ /* 480 */ 103, 103, 102, 102, 101, 101, 101, 100, 381, 106,
+ /* 490 */ 107, 97, 1013, 1013, 892, 895, 885, 885, 104, 104,
+ /* 500 */ 105, 105, 105, 105, 384, 359, 389, 237, 237, 237,
+ /* 510 */ 237, 110, 129, 399, 281, 334, 1033, 258, 992, 478,
+ /* 520 */ 350, 478, 1028, 389, 388, 363, 347, 479, 937, 784,
+ /* 530 */ 784, 1057, 937, 152, 103, 103, 103, 103, 102, 102,
+ /* 540 */ 101, 101, 101, 100, 381, 106, 107, 97, 1013, 1013,
+ /* 550 */ 892, 895, 885, 885, 104, 104, 105, 105, 105, 105,
+ /* 560 */ 992, 993, 994, 237, 237, 418, 481, 334, 973, 1338,
+ /* 570 */ 293, 244, 208, 207, 206, 478, 350, 1077, 359, 306,
+ /* 580 */ 1303, 1034, 178, 177, 339, 423, 445, 11, 11, 389,
+ /* 590 */ 103, 103, 103, 103, 102, 102, 101, 101, 101, 100,
+ /* 600 */ 381, 106, 107, 97, 1013, 1013, 892, 895, 885, 885,
+ /* 610 */ 104, 104, 105, 105, 105, 105, 237, 237, 237, 237,
+ /* 620 */ 406, 828, 406, 1197, 126, 1197, 1197, 1298, 478, 829,
+ /* 630 */ 478, 209, 350, 1034, 288, 264, 291, 171, 423, 423,
+ /* 640 */ 448, 423, 466, 404, 245, 85, 103, 103, 103, 103,
+ /* 650 */ 102, 102, 101, 101, 101, 100, 381, 106, 107, 97,
+ /* 660 */ 1013, 1013, 892, 895, 885, 885, 104, 104, 105, 105,
+ /* 670 */ 105, 105, 237, 237, 237, 237, 969, 481, 1197, 336,
+ /* 680 */ 1262, 1115, 1151, 1111, 478, 355, 478, 306, 350, 247,
+ /* 690 */ 364, 248, 365, 419, 412, 423, 412, 307, 33, 33,
+ /* 700 */ 307, 88, 103, 103, 103, 103, 102, 102, 101, 101,
+ /* 710 */ 101, 100, 381, 106, 107, 97, 1013, 1013, 892, 895,
+ /* 720 */ 885, 885, 104, 104, 105, 105, 105, 105, 265, 481,
+ /* 730 */ 1268, 8, 128, 367, 1060, 356, 374, 286, 474, 356,
+ /* 740 */ 259, 472, 357, 146, 350, 375, 1010, 1268, 1270, 277,
+ /* 750 */ 44, 44, 82, 412, 105, 105, 105, 105, 103, 103,
+ /* 760 */ 103, 103, 102, 102, 101, 101, 101, 100, 381, 106,
+ /* 770 */ 95, 97, 1013, 1013, 892, 895, 885, 885, 104, 104,
+ /* 780 */ 105, 105, 105, 105, 481, 246, 481, 279, 103, 103,
+ /* 790 */ 103, 103, 102, 102, 101, 101, 101, 100, 381, 350,
+ /* 800 */ 236, 182, 413, 996, 739, 45, 45, 46, 46, 89,
+ /* 810 */ 1263, 87, 190, 1268, 103, 103, 103, 103, 102, 102,
+ /* 820 */ 101, 101, 101, 100, 381, 107, 97, 1013, 1013, 892,
+ /* 830 */ 895, 885, 885, 104, 104, 105, 105, 105, 105, 125,
+ /* 840 */ 481, 28, 481, 354, 249, 789, 996, 739, 174, 856,
+ /* 850 */ 788, 405, 215, 350, 215, 372, 407, 454, 1150, 215,
+ /* 860 */ 922, 47, 47, 48, 48, 749, 748, 393, 22, 103,
+ /* 870 */ 103, 103, 103, 102, 102, 101, 101, 101, 100, 381,
+ /* 880 */ 97, 1013, 1013, 892, 895, 885, 885, 104, 104, 105,
+ /* 890 */ 105, 105, 105, 92, 473, 992, 3, 410, 481, 391,
+ /* 900 */ 23, 715, 234, 922, 282, 813, 429, 82, 296, 211,
+ /* 910 */ 476, 82, 756, 757, 145, 192, 1309, 274, 417, 49,
+ /* 920 */ 49, 124, 414, 103, 103, 103, 103, 102, 102, 101,
+ /* 930 */ 101, 101, 100, 381, 382, 369, 390, 992, 993, 994,
+ /* 940 */ 455, 223, 240, 305, 439, 300, 438, 210, 470, 92,
+ /* 950 */ 473, 992, 3, 298, 259, 472, 441, 956, 145, 725,
+ /* 960 */ 82, 872, 918, 397, 1287, 211, 476, 90, 90, 160,
+ /* 970 */ 1286, 70, 957, 1086, 91, 415, 382, 483, 482, 481,
+ /* 980 */ 411, 864, 789, 184, 378, 377, 1138, 788, 958, 915,
+ /* 990 */ 382, 239, 1017, 992, 993, 994, 283, 1019, 259, 472,
+ /* 1000 */ 34, 34, 725, 822, 470, 1018, 215, 992, 813, 770,
+ /* 1010 */ 161, 428, 864, 864, 866, 867, 19, 872, 304, 786,
+ /* 1020 */ 1147, 771, 94, 90, 90, 793, 1255, 287, 303, 1020,
+ /* 1030 */ 91, 1020, 382, 483, 482, 723, 4, 864, 123, 209,
+ /* 1040 */ 92, 473, 481, 3, 290, 481, 741, 468, 992, 992,
+ /* 1050 */ 993, 994, 787, 464, 292, 94, 443, 476, 84, 473,
+ /* 1060 */ 868, 3, 992, 58, 58, 294, 38, 38, 864, 864,
+ /* 1070 */ 866, 867, 19, 2, 992, 476, 934, 166, 934, 1099,
+ /* 1080 */ 933, 382, 933, 1085, 1083, 237, 237, 992, 237, 237,
+ /* 1090 */ 992, 993, 994, 355, 1084, 470, 1331, 478, 463, 382,
+ /* 1100 */ 478, 444, 299, 868, 992, 993, 994, 465, 872, 298,
+ /* 1110 */ 308, 992, 309, 470, 90, 90, 992, 993, 994, 956,
+ /* 1120 */ 1159, 91, 1196, 382, 483, 482, 872, 1134, 864, 992,
+ /* 1130 */ 993, 994, 90, 90, 957, 256, 5, 1145, 216, 91,
+ /* 1140 */ 467, 382, 483, 482, 992, 1202, 864, 1066, 813, 1059,
+ /* 1150 */ 958, 481, 229, 992, 993, 994, 815, 1048, 424, 864,
+ /* 1160 */ 864, 866, 867, 19, 1047, 1049, 105, 105, 105, 105,
+ /* 1170 */ 98, 469, 35, 35, 1011, 1325, 172, 864, 864, 866,
+ /* 1180 */ 867, 19, 1318, 982, 241, 7, 992, 993, 994, 332,
+ /* 1190 */ 332, 331, 226, 329, 481, 176, 712, 1131, 333, 481,
+ /* 1200 */ 103, 103, 103, 103, 102, 102, 101, 101, 101, 100,
+ /* 1210 */ 381, 263, 216, 814, 187, 9, 9, 1011, 481, 262,
+ /* 1220 */ 9, 9, 481, 392, 170, 481, 184, 750, 481, 366,
+ /* 1230 */ 311, 313, 315, 269, 368, 276, 349, 732, 1181, 9,
+ /* 1240 */ 9, 1189, 341, 9, 9, 409, 37, 37, 1011, 50,
+ /* 1250 */ 50, 813, 189, 250, 434, 481, 251, 460, 251, 437,
+ /* 1260 */ 138, 481, 1082, 140, 872, 982, 241, 180, 481, 751,
+ /* 1270 */ 302, 332, 332, 331, 226, 329, 51, 51, 712, 732,
+ /* 1280 */ 865, 1259, 52, 52, 864, 481, 1258, 471, 481, 10,
+ /* 1290 */ 10, 1011, 481, 263, 317, 175, 326, 481, 351, 1328,
+ /* 1300 */ 481, 262, 148, 259, 472, 1028, 53, 53, 370, 112,
+ /* 1310 */ 112, 1025, 66, 54, 54, 864, 864, 866, 39, 39,
+ /* 1320 */ 69, 55, 55, 218, 358, 481, 387, 481, 1186, 70,
+ /* 1330 */ 403, 481, 1264, 158, 189, 25, 481, 143, 481, 150,
+ /* 1340 */ 481, 80, 138, 481, 1178, 140, 56, 56, 40, 40,
+ /* 1350 */ 481, 395, 133, 133, 481, 153, 481, 134, 134, 63,
+ /* 1360 */ 63, 41, 41, 154, 59, 59, 396, 481, 427, 481,
+ /* 1370 */ 155, 113, 113, 481, 195, 60, 60, 114, 114, 481,
+ /* 1380 */ 351, 481, 156, 481, 338, 259, 472, 402, 115, 115,
+ /* 1390 */ 111, 111, 340, 481, 132, 132, 1192, 481, 162, 26,
+ /* 1400 */ 131, 131, 119, 119, 118, 118, 481, 1253, 387, 481,
+ /* 1410 */ 416, 481, 75, 481, 116, 116, 199, 422, 117, 117,
+ /* 1420 */ 481, 1275, 230, 167, 201, 425, 289, 62, 62, 202,
+ /* 1430 */ 64, 64, 61, 61, 32, 32, 440, 1050, 203, 285,
+ /* 1440 */ 343, 36, 36, 371, 1102, 1101, 741, 1100, 373, 456,
+ /* 1450 */ 1142, 1074, 254, 344, 79, 255, 1073, 1093, 301, 1072,
+ /* 1460 */ 1340, 310, 217, 6, 1092, 447, 450, 1239, 1143, 1141,
+ /* 1470 */ 312, 314, 319, 86, 257, 109, 1140, 461, 81, 316,
+ /* 1480 */ 459, 224, 1056, 24, 987, 484, 225, 228, 1124, 227,
+ /* 1490 */ 352, 322, 325, 323, 324, 485, 353, 1045, 1040, 1291,
+ /* 1500 */ 147, 1292, 1290, 1289, 122, 135, 136, 173, 252, 261,
+ /* 1510 */ 186, 242, 120, 1070, 1069, 932, 930, 848, 149, 65,
+ /* 1520 */ 137, 139, 1067, 191, 151, 773, 275, 194, 946, 141,
+ /* 1530 */ 157, 852, 360, 71, 362, 159, 72, 73, 74, 142,
+ /* 1540 */ 949, 196, 197, 945, 14, 130, 198, 938, 163, 284,
+ /* 1550 */ 1022, 215, 421, 200, 164, 27, 714, 426, 204, 303,
+ /* 1560 */ 430, 435, 752, 165, 76, 15, 144, 297, 16, 77,
+ /* 1570 */ 253, 871, 870, 898, 983, 977, 29, 78, 30, 446,
+ /* 1580 */ 978, 181, 449, 233, 235, 168, 783, 214, 821, 816,
+ /* 1590 */ 94, 82, 913, 17, 899, 220, 18, 897, 901, 955,
+ /* 1600 */ 902, 954, 20, 219, 31, 477, 869, 221, 724, 93,
+ /* 1610 */ 21, 330, 1038, 327, 222, 1333, 1332,
};
static const YYCODETYPE yy_lookahead[] = {
- /* 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,
+ /* 0 */ 226, 227, 228, 153, 192, 193, 172, 153, 146, 147,
+ /* 10 */ 148, 149, 150, 153, 181, 182, 16, 155, 153, 157,
+ /* 20 */ 174, 247, 197, 190, 174, 175, 164, 174, 28, 226,
+ /* 30 */ 227, 228, 164, 208, 174, 175, 36, 19, 188, 174,
+ /* 40 */ 175, 41, 42, 43, 44, 45, 46, 47, 48, 49,
+ /* 50 */ 50, 51, 52, 53, 54, 55, 192, 193, 196, 197,
+ /* 60 */ 226, 227, 228, 153, 196, 197, 148, 149, 150, 209,
+ /* 70 */ 208, 174, 16, 155, 57, 157, 208, 59, 218, 23,
+ /* 80 */ 212, 213, 164, 221, 174, 175, 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,
+ /* 110 */ 54, 55, 250, 153, 196, 197, 99, 100, 101, 102,
+ /* 120 */ 111, 112, 105, 106, 107, 69, 208, 96, 16, 19,
+ /* 130 */ 20, 177, 115, 23, 174, 175, 169, 170, 171, 221,
+ /* 140 */ 230, 153, 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,
+ /* 160 */ 48, 49, 50, 51, 52, 53, 54, 55, 250, 209,
+ /* 170 */ 90, 91, 92, 93, 94, 95, 96, 13, 218, 67,
+ /* 180 */ 226, 227, 228, 102, 16, 153, 105, 106, 107, 21,
+ /* 190 */ 92, 93, 94, 95, 96, 85, 115, 165, 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,
+ /* 220 */ 52, 53, 54, 55, 153, 112, 86, 87, 88, 89,
+ /* 230 */ 90, 91, 92, 93, 94, 95, 96, 177, 19, 20,
+ /* 240 */ 16, 77, 23, 79, 20, 174, 175, 134, 57, 44,
+ /* 250 */ 45, 46, 47, 187, 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,
+ /* 280 */ 209, 196, 197, 92, 153, 84, 226, 227, 228, 218,
+ /* 290 */ 99, 100, 101, 208, 90, 91, 16, 4, 5, 6,
+ /* 300 */ 20, 100, 57, 20, 85, 104, 23, 143, 81, 104,
/* 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,
+ /* 330 */ 50, 51, 52, 53, 54, 55, 135, 136, 137, 135,
+ /* 340 */ 153, 137, 153, 23, 99, 100, 101, 153, 121, 122,
+ /* 350 */ 95, 96, 16, 169, 170, 171, 20, 23, 253, 254,
+ /* 360 */ 153, 174, 175, 174, 175, 73, 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,
+ /* 390 */ 54, 55, 153, 153, 153, 172, 209, 153, 209, 153,
+ /* 400 */ 153, 161, 110, 111, 112, 165, 196, 197, 16, 153,
+ /* 410 */ 8, 73, 20, 174, 175, 174, 175, 153, 208, 81,
+ /* 420 */ 153, 164, 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,
+ /* 440 */ 48, 49, 50, 51, 52, 53, 54, 55, 110, 153,
+ /* 450 */ 209, 195, 132, 196, 197, 121, 122, 153, 153, 121,
+ /* 460 */ 122, 238, 198, 219, 16, 208, 243, 153, 20, 222,
+ /* 470 */ 174, 175, 110, 111, 112, 164, 12, 164, 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,
+ /* 500 */ 52, 53, 54, 55, 248, 153, 153, 196, 197, 196,
+ /* 510 */ 197, 19, 198, 111, 112, 19, 20, 201, 57, 208,
+ /* 520 */ 16, 208, 58, 170, 171, 220, 210, 117, 26, 119,
+ /* 530 */ 120, 164, 30, 72, 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,
+ /* 560 */ 99, 100, 101, 196, 197, 63, 153, 19, 20, 173,
+ /* 570 */ 13, 219, 110, 111, 112, 208, 16, 181, 153, 153,
+ /* 580 */ 153, 85, 90, 91, 164, 153, 164, 174, 175, 236,
/* 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,
+ /* 620 */ 153, 28, 153, 153, 198, 153, 153, 195, 208, 36,
+ /* 630 */ 208, 44, 16, 85, 77, 153, 79, 21, 153, 153,
+ /* 640 */ 164, 153, 164, 223, 219, 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,
+ /* 670 */ 54, 55, 196, 197, 196, 197, 20, 153, 153, 23,
+ /* 680 */ 195, 195, 153, 195, 208, 98, 208, 153, 16, 222,
+ /* 690 */ 220, 222, 220, 220, 153, 153, 153, 153, 174, 175,
+ /* 700 */ 153, 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,
+ /* 720 */ 48, 49, 50, 51, 52, 53, 54, 55, 153, 153,
+ /* 730 */ 153, 172, 198, 189, 167, 168, 189, 195, 167, 168,
+ /* 740 */ 121, 122, 251, 252, 16, 220, 23, 170, 171, 20,
+ /* 750 */ 174, 175, 23, 153, 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,
+ /* 780 */ 52, 53, 54, 55, 153, 244, 153, 244, 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,
+ /* 800 */ 212, 213, 243, 57, 57, 174, 175, 174, 175, 140,
+ /* 810 */ 235, 142, 21, 236, 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,
+ /* 830 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 19,
+ /* 840 */ 153, 21, 153, 158, 244, 118, 100, 100, 125, 20,
+ /* 850 */ 123, 20, 23, 16, 23, 16, 20, 16, 153, 23,
+ /* 860 */ 57, 174, 175, 174, 175, 103, 104, 153, 19, 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,
+ /* 890 */ 53, 54, 55, 16, 17, 57, 19, 16, 153, 223,
+ /* 900 */ 51, 18, 20, 100, 20, 23, 20, 23, 20, 23,
+ /* 910 */ 33, 23, 4, 5, 81, 124, 153, 153, 233, 174,
+ /* 920 */ 175, 19, 237, 86, 87, 88, 89, 90, 91, 92,
+ /* 930 */ 93, 94, 95, 96, 57, 96, 103, 99, 100, 101,
+ /* 940 */ 99, 102, 103, 104, 105, 106, 107, 108, 71, 16,
+ /* 950 */ 17, 57, 19, 114, 121, 122, 92, 9, 81, 57,
+ /* 960 */ 23, 84, 20, 80, 153, 23, 33, 90, 91, 19,
+ /* 970 */ 153, 133, 24, 183, 97, 153, 99, 100, 101, 153,
+ /* 980 */ 99, 104, 118, 101, 90, 91, 214, 123, 40, 106,
+ /* 990 */ 57, 19, 98, 99, 100, 101, 153, 103, 121, 122,
+ /* 1000 */ 174, 175, 100, 20, 71, 111, 23, 57, 126, 61,
+ /* 1010 */ 19, 16, 135, 136, 137, 138, 139, 84, 104, 20,
+ /* 1020 */ 153, 73, 23, 90, 91, 92, 143, 153, 114, 135,
+ /* 1030 */ 97, 137, 99, 100, 101, 20, 19, 104, 23, 44,
+ /* 1040 */ 16, 17, 153, 19, 153, 153, 109, 193, 57, 99,
+ /* 1050 */ 100, 101, 20, 164, 153, 23, 164, 33, 16, 17,
+ /* 1060 */ 57, 19, 57, 174, 175, 153, 174, 175, 135, 136,
+ /* 1070 */ 137, 138, 139, 19, 57, 33, 135, 72, 137, 153,
+ /* 1080 */ 135, 57, 137, 183, 153, 196, 197, 57, 196, 197,
+ /* 1090 */ 99, 100, 101, 98, 183, 71, 124, 208, 209, 57,
+ /* 1100 */ 208, 209, 153, 100, 99, 100, 101, 218, 84, 114,
+ /* 1110 */ 153, 57, 153, 71, 90, 91, 99, 100, 101, 9,
+ /* 1120 */ 153, 97, 153, 99, 100, 101, 84, 153, 104, 99,
+ /* 1130 */ 100, 101, 90, 91, 24, 211, 19, 153, 21, 97,
+ /* 1140 */ 153, 99, 100, 101, 57, 153, 104, 153, 23, 153,
+ /* 1150 */ 40, 153, 239, 99, 100, 101, 126, 153, 240, 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,
+ /* 1170 */ 56, 61, 174, 175, 57, 153, 199, 135, 136, 137,
+ /* 1180 */ 138, 139, 0, 1, 2, 200, 99, 100, 101, 7,
+ /* 1190 */ 8, 9, 10, 11, 153, 172, 14, 211, 151, 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,
+ /* 1210 */ 96, 29, 21, 126, 249, 174, 175, 100, 153, 37,
+ /* 1220 */ 174, 175, 153, 215, 153, 153, 101, 32, 153, 188,
+ /* 1230 */ 211, 211, 211, 215, 188, 245, 165, 57, 203, 174,
+ /* 1240 */ 175, 203, 203, 174, 175, 245, 174, 175, 57, 174,
+ /* 1250 */ 175, 126, 70, 188, 178, 153, 185, 188, 187, 64,
+ /* 1260 */ 78, 153, 182, 81, 84, 1, 2, 186, 153, 74,
+ /* 1270 */ 177, 7, 8, 9, 10, 11, 174, 175, 14, 99,
+ /* 1280 */ 100, 177, 174, 175, 104, 153, 177, 232, 153, 174,
+ /* 1290 */ 175, 100, 153, 29, 215, 200, 202, 153, 116, 156,
+ /* 1300 */ 153, 37, 249, 121, 122, 58, 174, 175, 113, 174,
+ /* 1310 */ 175, 35, 246, 174, 175, 135, 136, 137, 174, 175,
+ /* 1320 */ 246, 174, 175, 124, 160, 153, 144, 153, 225, 133,
+ /* 1330 */ 98, 153, 235, 19, 70, 224, 153, 41, 153, 191,
+ /* 1340 */ 153, 132, 78, 153, 203, 81, 174, 175, 174, 175,
+ /* 1350 */ 153, 15, 174, 175, 153, 194, 153, 174, 175, 174,
+ /* 1360 */ 175, 174, 175, 194, 174, 175, 160, 153, 15, 153,
+ /* 1370 */ 194, 174, 175, 153, 159, 174, 175, 174, 175, 153,
+ /* 1380 */ 116, 153, 194, 153, 203, 121, 122, 203, 174, 175,
+ /* 1390 */ 174, 175, 225, 153, 174, 175, 191, 153, 191, 224,
+ /* 1400 */ 174, 175, 174, 175, 174, 175, 153, 203, 144, 153,
+ /* 1410 */ 160, 153, 140, 153, 174, 175, 159, 60, 174, 175,
+ /* 1420 */ 153, 242, 160, 19, 159, 179, 160, 174, 175, 159,
+ /* 1430 */ 174, 175, 174, 175, 174, 175, 98, 160, 159, 241,
+ /* 1440 */ 179, 174, 175, 62, 176, 176, 109, 176, 96, 127,
+ /* 1450 */ 217, 176, 234, 179, 98, 234, 178, 184, 176, 176,
+ /* 1460 */ 176, 216, 160, 19, 184, 179, 179, 229, 217, 217,
+ /* 1470 */ 216, 216, 160, 140, 231, 131, 217, 128, 130, 216,
+ /* 1480 */ 129, 22, 163, 23, 10, 162, 154, 3, 207, 154,
+ /* 1490 */ 255, 206, 203, 205, 204, 152, 255, 152, 152, 172,
+ /* 1500 */ 252, 172, 172, 172, 180, 166, 166, 19, 180, 145,
+ /* 1510 */ 12, 83, 13, 172, 172, 20, 20, 122, 133, 172,
+ /* 1520 */ 166, 113, 172, 21, 125, 17, 13, 127, 1, 113,
+ /* 1530 */ 125, 134, 59, 51, 34, 133, 51, 51, 51, 113,
+ /* 1540 */ 99, 31, 124, 1, 19, 2, 98, 68, 68, 143,
+ /* 1550 */ 75, 23, 38, 124, 98, 21, 17, 16, 108, 114,
+ /* 1560 */ 67, 67, 25, 19, 19, 19, 34, 20, 19, 19,
+ /* 1570 */ 67, 20, 20, 20, 1, 20, 19, 23, 19, 21,
+ /* 1580 */ 20, 124, 21, 20, 20, 19, 118, 31, 99, 126,
+ /* 1590 */ 23, 23, 20, 31, 20, 19, 31, 20, 20, 20,
+ /* 1600 */ 8, 20, 19, 23, 19, 23, 20, 124, 20, 19,
+ /* 1610 */ 19, 12, 256, 20, 124, 124, 124, 256, 256, 256,
+ /* 1620 */ 256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
+ /* 1630 */ 256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
+ /* 1640 */ 256, 256, 256, 256, 256, 256, 256, 256, 256, 256,
+ /* 1650 */ 256, 256, 256, 256, 256, 256, 256, 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,
};
-#define YY_SHIFT_COUNT (483)
+#define YY_SHIFT_COUNT (486)
#define YY_SHIFT_MIN (0)
-#define YY_SHIFT_MAX (1598)
+#define YY_SHIFT_MAX (1599)
static const unsigned short int yy_shift_ofst[] = {
- /* 0 */ 1264, 1182, 877, 877, 281, 1024, 1024, 1024, 228, 0,
+ /* 0 */ 1264, 1182, 877, 877, 227, 1024, 1024, 1024, 338, 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,
+ /* 20 */ 1024, 1024, 894, 894, 17, 833, 227, 227, 227, 227,
+ /* 30 */ 227, 227, 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,
+ /* 50 */ 672, 672, 672, 672, 672, 672, 672, 672, 672, 672,
+ /* 60 */ 728, 672, 783, 837, 837, 933, 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,
+ /* 90 */ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1042, 1024, 1024,
+ /* 100 */ 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024,
+ /* 110 */ 1024, 1114, 702, 702, 702, 702, 702, 140, 80, 98,
+ /* 120 */ 245, 883, 995, 204, 204, 245, 334, 334, 334, 334,
+ /* 130 */ 9, 255, 31, 1617, 1617, 839, 839, 839, 838, 950,
+ /* 140 */ 461, 950, 950, 948, 948, 1005, 110, 219, 245, 245,
+ /* 150 */ 245, 245, 245, 245, 245, 245, 245, 245, 245, 245,
+ /* 160 */ 245, 245, 245, 245, 245, 245, 245, 245, 245, 402,
+ /* 170 */ 746, 746, 619, 1617, 1617, 1617, 1180, 201, 201, 991,
+ /* 180 */ 81, 191, 1017, 1030, 1087, 1054, 245, 245, 245, 245,
+ /* 190 */ 245, 245, 245, 292, 245, 245, 245, 245, 245, 245,
+ /* 200 */ 245, 245, 245, 245, 245, 245, 1195, 1195, 1195, 245,
+ /* 210 */ 245, 245, 245, 882, 245, 245, 245, 1117, 245, 245,
+ /* 220 */ 1110, 245, 245, 245, 245, 245, 245, 245, 245, 362,
+ /* 230 */ 502, 410, 1191, 1191, 1191, 1191, 1125, 410, 410, 864,
+ /* 240 */ 492, 293, 464, 320, 841, 841, 881, 320, 320, 881,
+ /* 250 */ 937, 283, 587, 593, 593, 593, 841, 669, 723, 727,
+ /* 260 */ 820, 1247, 1276, 1276, 1199, 1196, 1232, 1314, 1296, 1209,
+ /* 270 */ 1336, 1336, 1336, 1336, 1199, 1353, 1209, 1209, 1232, 1314,
+ /* 280 */ 1296, 1296, 1209, 1199, 1353, 1272, 1357, 1199, 1353, 1404,
+ /* 290 */ 1199, 1353, 1199, 1353, 1404, 1338, 1338, 1338, 1381, 1404,
+ /* 300 */ 1338, 1337, 1338, 1381, 1338, 1338, 1404, 1352, 1352, 1404,
+ /* 310 */ 1322, 1356, 1322, 1356, 1322, 1356, 1322, 1356, 1199, 1444,
+ /* 320 */ 1199, 1333, 1344, 1349, 1348, 1351, 1209, 1459, 1460, 1474,
+ /* 330 */ 1474, 1484, 1484, 1484, 1617, 1617, 1617, 1617, 1617, 1617,
+ /* 340 */ 1617, 1617, 1617, 1617, 1617, 1617, 1617, 1617, 1617, 1617,
+ /* 350 */ 205, 164, 496, 548, 557, 462, 902, 656, 849, 791,
+ /* 360 */ 113, 729, 18, 829, 831, 836, 884, 886, 888, 747,
+ /* 370 */ 762, 908, 914, 803, 942, 983, 999, 941, 945, 1015,
+ /* 380 */ 1032, 1003, 972, 1488, 1364, 1498, 1428, 1499, 1495, 1496,
+ /* 390 */ 1395, 1385, 1408, 1502, 1399, 1508, 1400, 1513, 1527, 1405,
+ /* 400 */ 1397, 1416, 1473, 1500, 1402, 1482, 1485, 1486, 1487, 1426,
+ /* 410 */ 1441, 1510, 1418, 1542, 1543, 1525, 1448, 1406, 1479, 1528,
+ /* 420 */ 1480, 1475, 1514, 1429, 1456, 1534, 1539, 1541, 1445, 1450,
+ /* 430 */ 1544, 1493, 1545, 1546, 1547, 1549, 1494, 1537, 1550, 1503,
+ /* 440 */ 1532, 1551, 1552, 1553, 1554, 1555, 1557, 1558, 1560, 1559,
+ /* 450 */ 1561, 1457, 1563, 1564, 1489, 1556, 1566, 1463, 1567, 1562,
+ /* 460 */ 1568, 1565, 1572, 1567, 1574, 1577, 1578, 1579, 1580, 1581,
+ /* 470 */ 1576, 1592, 1583, 1585, 1586, 1588, 1590, 1591, 1582, 1468,
+ /* 480 */ 1483, 1490, 1491, 1492, 1593, 1599, 1573,
};
-#define YY_REDUCE_COUNT (346)
-#define YY_REDUCE_MIN (-223)
-#define YY_REDUCE_MAX (1342)
+#define YY_REDUCE_COUNT (349)
+#define YY_REDUCE_MIN (-226)
+#define YY_REDUCE_MAX (1354)
static const short yy_reduce_ofst[] = {
- /* 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,
+ /* 0 */ -138, -82, 889, 892, -132, -140, -40, 71, 420, -46,
+ /* 10 */ 60, -226, -166, -150, 1041, 1046, 1065, 187, 1069, -90,
+ /* 20 */ 189, 241, 353, 577, 1071, 257, 311, 313, 367, 422,
+ /* 30 */ 476, 478, -197, -197, -197, -197, -197, -197, -197, -197,
+ /* 40 */ -197, -197, -197, -197, -197, -197, -197, -197, -197, -197,
+ /* 50 */ -197, -197, -197, -197, -197, -197, -197, -197, -197, -197,
+ /* 60 */ -197, -197, -197, -197, -197, -135, 239, 296, 413, 524,
+ /* 70 */ 576, 631, 633, 687, 689, 745, 826, 998, 1072, 1075,
+ /* 80 */ 1102, 1108, 1115, 1132, 1135, 1139, 1144, 1147, 1172, 1174,
+ /* 90 */ 1178, 1183, 1185, 1187, 1190, 1197, 1201, 1203, 1214, 1216,
+ /* 100 */ 1220, 1226, 1228, 1230, 1240, 1244, 1253, 1256, 1258, 1260,
+ /* 110 */ 1267, -197, -197, -197, -197, -197, -197, -197, -197, -197,
+ /* 120 */ 256, 685, -167, -33, 184, 240, 85, 210, 85, 210,
+ /* 130 */ 223, -197, -197, -197, -197, 396, 396, 396, 575, 247,
+ /* 140 */ 264, 467, 469, -188, -136, 314, 105, 105, 32, 244,
+ /* 150 */ 352, 425, 426, 432, 485, 486, 488, 541, 305, 543,
+ /* 160 */ 470, 472, 600, 473, 542, 544, 534, 547, 525, 559,
+ /* 170 */ 567, 571, -175, 491, 588, 316, -154, -147, -103, -146,
+ /* 180 */ 66, -12, 131, 194, 207, 246, 267, 304, 427, 482,
+ /* 190 */ 529, 705, 714, 676, 763, 764, 811, 817, 822, 843,
+ /* 200 */ 867, 874, 891, 901, 912, 926, 790, 900, 911, 931,
+ /* 210 */ 949, 957, 959, 772, 967, 969, 974, 924, 984, 987,
+ /* 220 */ 854, 992, -12, 994, 996, 1004, 1011, 1012, 1022, 918,
+ /* 230 */ 913, 977, 986, 1019, 1020, 1021, 772, 977, 977, 985,
+ /* 240 */ 1023, 1047, 965, 1035, 1008, 1018, 990, 1038, 1039, 1000,
+ /* 250 */ 1076, 1081, 1080, 1093, 1104, 1109, 1079, 1055, 1094, 1095,
+ /* 260 */ 1143, 1053, 1066, 1074, 1164, 1097, 1103, 1111, 1148, 1141,
+ /* 270 */ 1161, 1169, 1176, 1188, 1206, 1215, 1181, 1184, 1167, 1175,
+ /* 280 */ 1205, 1207, 1204, 1250, 1257, 1179, 1198, 1262, 1265, 1246,
+ /* 290 */ 1266, 1270, 1277, 1279, 1261, 1268, 1269, 1271, 1273, 1274,
+ /* 300 */ 1275, 1278, 1282, 1280, 1283, 1284, 1286, 1218, 1221, 1287,
+ /* 310 */ 1233, 1245, 1251, 1254, 1252, 1255, 1259, 1263, 1302, 1238,
+ /* 320 */ 1312, 1243, 1281, 1285, 1288, 1290, 1289, 1319, 1323, 1332,
+ /* 330 */ 1335, 1343, 1345, 1346, 1235, 1241, 1248, 1339, 1327, 1329,
+ /* 340 */ 1330, 1331, 1340, 1324, 1328, 1341, 1342, 1347, 1350, 1354,
};
static const YYACTIONTYPE yy_default[] = {
- /* 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,
+ /* 0 */ 1374, 1374, 1248, 1036, 1139, 1248, 1248, 1248, 1036, 1169,
+ /* 10 */ 1169, 1301, 1065, 1036, 1036, 1036, 1036, 1036, 1036, 1247,
+ /* 20 */ 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036,
+ /* 30 */ 1036, 1036, 1175, 1036, 1036, 1036, 1036, 1249, 1250, 1036,
+ /* 40 */ 1036, 1036, 1300, 1302, 1265, 1185, 1184, 1183, 1182, 1283,
+ /* 50 */ 1156, 1180, 1173, 1177, 1243, 1244, 1242, 1246, 1250, 1249,
+ /* 60 */ 1036, 1176, 1214, 1228, 1213, 1036, 1036, 1036, 1036, 1036,
+ /* 70 */ 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036,
+ /* 80 */ 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036,
+ /* 90 */ 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036,
+ /* 100 */ 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036,
+ /* 110 */ 1036, 1222, 1227, 1233, 1226, 1223, 1216, 1215, 1217, 1218,
+ /* 120 */ 1036, 1055, 1104, 1036, 1036, 1036, 1315, 1314, 1036, 1036,
+ /* 130 */ 1065, 1219, 1220, 1230, 1229, 1304, 1330, 1329, 1266, 1036,
+ /* 140 */ 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036,
+ /* 150 */ 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036,
+ /* 160 */ 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1065,
+ /* 170 */ 1061, 1061, 1036, 1310, 1139, 1130, 1036, 1036, 1036, 1036,
+ /* 180 */ 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036,
+ /* 190 */ 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036,
+ /* 200 */ 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036,
+ /* 210 */ 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1135, 1036, 1036,
+ /* 220 */ 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1324, 1036,
+ /* 230 */ 1278, 1118, 1135, 1135, 1135, 1135, 1137, 1119, 1117, 1129,
+ /* 240 */ 1065, 1041, 1366, 1179, 1158, 1158, 1363, 1179, 1179, 1363,
+ /* 250 */ 1079, 1344, 1076, 1169, 1169, 1169, 1158, 1245, 1136, 1129,
+ /* 260 */ 1036, 1366, 1365, 1365, 1144, 1266, 1188, 1194, 1107, 1179,
+ /* 270 */ 1113, 1113, 1113, 1113, 1144, 1052, 1179, 1179, 1188, 1194,
+ /* 280 */ 1107, 1107, 1179, 1144, 1052, 1282, 1360, 1144, 1052, 1256,
+ /* 290 */ 1144, 1052, 1144, 1052, 1256, 1105, 1105, 1105, 1094, 1256,
+ /* 300 */ 1105, 1079, 1105, 1094, 1105, 1105, 1256, 1260, 1260, 1256,
+ /* 310 */ 1162, 1157, 1162, 1157, 1162, 1157, 1162, 1157, 1144, 1251,
+ /* 320 */ 1144, 1036, 1174, 1163, 1172, 1170, 1179, 1058, 1097, 1327,
+ /* 330 */ 1327, 1323, 1323, 1323, 1371, 1371, 1310, 1339, 1065, 1065,
+ /* 340 */ 1065, 1065, 1339, 1081, 1081, 1065, 1065, 1065, 1065, 1339,
+ /* 350 */ 1036, 1036, 1036, 1036, 1036, 1036, 1334, 1036, 1267, 1148,
+ /* 360 */ 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036,
+ /* 370 */ 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036,
+ /* 380 */ 1036, 1036, 1199, 1307, 1036, 1036, 1305, 1036, 1036, 1036,
+ /* 390 */ 1036, 1036, 1036, 1149, 1036, 1036, 1036, 1036, 1036, 1036,
+ /* 400 */ 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036,
+ /* 410 */ 1036, 1036, 1362, 1036, 1036, 1036, 1036, 1036, 1036, 1281,
+ /* 420 */ 1280, 1036, 1036, 1146, 1036, 1036, 1036, 1036, 1036, 1036,
+ /* 430 */ 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036,
+ /* 440 */ 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036,
+ /* 450 */ 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1171, 1036,
+ /* 460 */ 1164, 1036, 1036, 1353, 1036, 1036, 1036, 1036, 1036, 1036,
+ /* 470 */ 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1036, 1348, 1121,
+ /* 480 */ 1201, 1036, 1200, 1204, 1036, 1046, 1036,
};
/********** End of lemon-generated parsing tables *****************************/
@@ -148212,26 +148667,27 @@ static const char *const yyTokenName[] = {
/* 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",
+ /* 235 */ "vinto",
+ /* 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",
};
#endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */
@@ -148463,116 +148919,118 @@ static const char *const yyRuleName[] = {
/* 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 ::=",
+ /* 224 */ "cmd ::= VACUUM vinto",
+ /* 225 */ "cmd ::= VACUUM nm vinto",
+ /* 226 */ "vinto ::= INTO expr",
+ /* 227 */ "vinto ::=",
+ /* 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 ::= ALTER TABLE fullname RENAME TO nm",
+ /* 265 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist",
+ /* 266 */ "add_column_fullname ::= fullname",
+ /* 267 */ "cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm",
+ /* 268 */ "cmd ::= create_vtab",
+ /* 269 */ "cmd ::= create_vtab LP vtabarglist RP",
+ /* 270 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
+ /* 271 */ "vtabarg ::=",
+ /* 272 */ "vtabargtoken ::= ANY",
+ /* 273 */ "vtabargtoken ::= lp anylist RP",
+ /* 274 */ "lp ::= LP",
+ /* 275 */ "with ::= WITH wqlist",
+ /* 276 */ "with ::= WITH RECURSIVE wqlist",
+ /* 277 */ "wqlist ::= nm eidlist_opt AS LP select RP",
+ /* 278 */ "wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP",
+ /* 279 */ "input ::= cmdlist",
+ /* 280 */ "cmdlist ::= cmdlist ecmd",
+ /* 281 */ "cmdlist ::= ecmd",
+ /* 282 */ "ecmd ::= SEMI",
+ /* 283 */ "ecmd ::= cmdx SEMI",
+ /* 284 */ "trans_opt ::=",
+ /* 285 */ "trans_opt ::= TRANSACTION",
+ /* 286 */ "trans_opt ::= TRANSACTION nm",
+ /* 287 */ "savepoint_opt ::= SAVEPOINT",
+ /* 288 */ "savepoint_opt ::=",
+ /* 289 */ "cmd ::= create_table create_table_args",
+ /* 290 */ "columnlist ::= columnlist COMMA columnname carglist",
+ /* 291 */ "columnlist ::= columnname carglist",
+ /* 292 */ "nm ::= ID|INDEXED",
+ /* 293 */ "nm ::= STRING",
+ /* 294 */ "nm ::= JOIN_KW",
+ /* 295 */ "typetoken ::= typename",
+ /* 296 */ "typename ::= ID|STRING",
+ /* 297 */ "signed ::= plus_num",
+ /* 298 */ "signed ::= minus_num",
+ /* 299 */ "carglist ::= carglist ccons",
+ /* 300 */ "carglist ::=",
+ /* 301 */ "ccons ::= NULL onconf",
+ /* 302 */ "conslist_opt ::= COMMA conslist",
+ /* 303 */ "conslist ::= conslist tconscomma tcons",
+ /* 304 */ "conslist ::= tcons",
+ /* 305 */ "tconscomma ::=",
+ /* 306 */ "defer_subclause_opt ::= defer_subclause",
+ /* 307 */ "resolvetype ::= raisetype",
+ /* 308 */ "selectnowith ::= oneselect",
+ /* 309 */ "oneselect ::= values",
+ /* 310 */ "sclp ::= selcollist COMMA",
+ /* 311 */ "as ::= ID|STRING",
+ /* 312 */ "expr ::= term",
+ /* 313 */ "likeop ::= LIKE_KW|MATCH",
+ /* 314 */ "exprlist ::= nexprlist",
+ /* 315 */ "nmnum ::= plus_num",
+ /* 316 */ "nmnum ::= nm",
+ /* 317 */ "nmnum ::= ON",
+ /* 318 */ "nmnum ::= DELETE",
+ /* 319 */ "nmnum ::= DEFAULT",
+ /* 320 */ "plus_num ::= INTEGER|FLOAT",
+ /* 321 */ "foreach_clause ::=",
+ /* 322 */ "foreach_clause ::= FOR EACH ROW",
+ /* 323 */ "trnm ::= nm",
+ /* 324 */ "tridxby ::=",
+ /* 325 */ "database_kw_opt ::= DATABASE",
+ /* 326 */ "database_kw_opt ::=",
+ /* 327 */ "kwcolumn_opt ::=",
+ /* 328 */ "kwcolumn_opt ::= COLUMNKW",
+ /* 329 */ "vtabarglist ::= vtabarg",
+ /* 330 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
+ /* 331 */ "vtabarg ::= vtabarg vtabargtoken",
+ /* 332 */ "anylist ::=",
+ /* 333 */ "anylist ::= anylist LP anylist RP",
+ /* 334 */ "anylist ::= anylist ANY",
+ /* 335 */ "with ::=",
};
#endif /* NDEBUG */
@@ -148703,7 +149161,7 @@ static void yy_destructor(
case 197: /* oneselect */
case 208: /* values */
{
-sqlite3SelectDelete(pParse->db, (yypminor->yy399));
+sqlite3SelectDelete(pParse->db, (yypminor->yy43));
}
break;
case 174: /* term */
@@ -148713,10 +149171,11 @@ sqlite3SelectDelete(pParse->db, (yypminor->yy399));
case 216: /* on_opt */
case 230: /* case_operand */
case 232: /* case_else */
- case 241: /* when_clause */
- case 246: /* key_opt */
+ case 235: /* vinto */
+ case 242: /* when_clause */
+ case 247: /* key_opt */
{
-sqlite3ExprDelete(pParse->db, (yypminor->yy182));
+sqlite3ExprDelete(pParse->db, (yypminor->yy2));
}
break;
case 179: /* eidlist_opt */
@@ -148732,7 +149191,7 @@ sqlite3ExprDelete(pParse->db, (yypminor->yy182));
case 229: /* paren_exprlist */
case 231: /* case_exprlist */
{
-sqlite3ExprListDelete(pParse->db, (yypminor->yy232));
+sqlite3ExprListDelete(pParse->db, (yypminor->yy402));
}
break;
case 195: /* fullname */
@@ -148741,30 +149200,30 @@ sqlite3ExprListDelete(pParse->db, (yypminor->yy232));
case 213: /* stl_prefix */
case 219: /* xfullname */
{
-sqlite3SrcListDelete(pParse->db, (yypminor->yy427));
+sqlite3SrcListDelete(pParse->db, (yypminor->yy3));
}
break;
case 198: /* wqlist */
{
-sqlite3WithDelete(pParse->db, (yypminor->yy91));
+sqlite3WithDelete(pParse->db, (yypminor->yy4));
}
break;
case 217: /* using_opt */
case 220: /* idlist */
case 224: /* idlist_opt */
{
-sqlite3IdListDelete(pParse->db, (yypminor->yy510));
+sqlite3IdListDelete(pParse->db, (yypminor->yy272));
}
break;
- case 237: /* trigger_cmd_list */
- case 242: /* trigger_cmd */
+ case 238: /* trigger_cmd_list */
+ case 243: /* trigger_cmd */
{
-sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy47));
+sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy347));
}
break;
- case 239: /* trigger_event */
+ case 240: /* trigger_event */
{
-sqlite3IdListDelete(pParse->db, (yypminor->yy300).b);
+sqlite3IdListDelete(pParse->db, (yypminor->yy338).b);
}
break;
/********* End destructor definitions *****************************************/
@@ -149056,347 +149515,686 @@ static void yy_shift(
yyTraceShift(yypParser, yyNewState, "Shift");
}
-/* The following table contains information about every rule that
-** is used during the reduce.
-*/
-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[] = {
- { 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 ::= */
+/* For rule J, yyRuleInfoLhs[J] contains the symbol on the left-hand side
+** of that rule */
+static const YYCODETYPE yyRuleInfoLhs[] = {
+ 149, /* (0) cmdx ::= cmd */
+ 150, /* (1) cmd ::= BEGIN transtype trans_opt */
+ 151, /* (2) transtype ::= */
+ 151, /* (3) transtype ::= DEFERRED */
+ 151, /* (4) transtype ::= IMMEDIATE */
+ 151, /* (5) transtype ::= EXCLUSIVE */
+ 150, /* (6) cmd ::= COMMIT|END trans_opt */
+ 150, /* (7) cmd ::= ROLLBACK trans_opt */
+ 150, /* (8) cmd ::= SAVEPOINT nm */
+ 150, /* (9) cmd ::= RELEASE savepoint_opt nm */
+ 150, /* (10) cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */
+ 155, /* (11) create_table ::= createkw temp TABLE ifnotexists nm dbnm */
+ 157, /* (12) createkw ::= CREATE */
+ 159, /* (13) ifnotexists ::= */
+ 159, /* (14) ifnotexists ::= IF NOT EXISTS */
+ 158, /* (15) temp ::= TEMP */
+ 158, /* (16) temp ::= */
+ 156, /* (17) create_table_args ::= LP columnlist conslist_opt RP table_options */
+ 156, /* (18) create_table_args ::= AS select */
+ 163, /* (19) table_options ::= */
+ 163, /* (20) table_options ::= WITHOUT nm */
+ 165, /* (21) columnname ::= nm typetoken */
+ 167, /* (22) typetoken ::= */
+ 167, /* (23) typetoken ::= typename LP signed RP */
+ 167, /* (24) typetoken ::= typename LP signed COMMA signed RP */
+ 168, /* (25) typename ::= typename ID|STRING */
+ 172, /* (26) scanpt ::= */
+ 173, /* (27) ccons ::= CONSTRAINT nm */
+ 173, /* (28) ccons ::= DEFAULT scanpt term scanpt */
+ 173, /* (29) ccons ::= DEFAULT LP expr RP */
+ 173, /* (30) ccons ::= DEFAULT PLUS term scanpt */
+ 173, /* (31) ccons ::= DEFAULT MINUS term scanpt */
+ 173, /* (32) ccons ::= DEFAULT scanpt ID|INDEXED */
+ 173, /* (33) ccons ::= NOT NULL onconf */
+ 173, /* (34) ccons ::= PRIMARY KEY sortorder onconf autoinc */
+ 173, /* (35) ccons ::= UNIQUE onconf */
+ 173, /* (36) ccons ::= CHECK LP expr RP */
+ 173, /* (37) ccons ::= REFERENCES nm eidlist_opt refargs */
+ 173, /* (38) ccons ::= defer_subclause */
+ 173, /* (39) ccons ::= COLLATE ID|STRING */
+ 178, /* (40) autoinc ::= */
+ 178, /* (41) autoinc ::= AUTOINCR */
+ 180, /* (42) refargs ::= */
+ 180, /* (43) refargs ::= refargs refarg */
+ 182, /* (44) refarg ::= MATCH nm */
+ 182, /* (45) refarg ::= ON INSERT refact */
+ 182, /* (46) refarg ::= ON DELETE refact */
+ 182, /* (47) refarg ::= ON UPDATE refact */
+ 183, /* (48) refact ::= SET NULL */
+ 183, /* (49) refact ::= SET DEFAULT */
+ 183, /* (50) refact ::= CASCADE */
+ 183, /* (51) refact ::= RESTRICT */
+ 183, /* (52) refact ::= NO ACTION */
+ 181, /* (53) defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
+ 181, /* (54) defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
+ 184, /* (55) init_deferred_pred_opt ::= */
+ 184, /* (56) init_deferred_pred_opt ::= INITIALLY DEFERRED */
+ 184, /* (57) init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
+ 162, /* (58) conslist_opt ::= */
+ 186, /* (59) tconscomma ::= COMMA */
+ 187, /* (60) tcons ::= CONSTRAINT nm */
+ 187, /* (61) tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
+ 187, /* (62) tcons ::= UNIQUE LP sortlist RP onconf */
+ 187, /* (63) tcons ::= CHECK LP expr RP onconf */
+ 187, /* (64) tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
+ 190, /* (65) defer_subclause_opt ::= */
+ 176, /* (66) onconf ::= */
+ 176, /* (67) onconf ::= ON CONFLICT resolvetype */
+ 191, /* (68) orconf ::= */
+ 191, /* (69) orconf ::= OR resolvetype */
+ 192, /* (70) resolvetype ::= IGNORE */
+ 192, /* (71) resolvetype ::= REPLACE */
+ 150, /* (72) cmd ::= DROP TABLE ifexists fullname */
+ 194, /* (73) ifexists ::= IF EXISTS */
+ 194, /* (74) ifexists ::= */
+ 150, /* (75) cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
+ 150, /* (76) cmd ::= DROP VIEW ifexists fullname */
+ 150, /* (77) cmd ::= select */
+ 164, /* (78) select ::= WITH wqlist selectnowith */
+ 164, /* (79) select ::= WITH RECURSIVE wqlist selectnowith */
+ 164, /* (80) select ::= selectnowith */
+ 196, /* (81) selectnowith ::= selectnowith multiselect_op oneselect */
+ 199, /* (82) multiselect_op ::= UNION */
+ 199, /* (83) multiselect_op ::= UNION ALL */
+ 199, /* (84) multiselect_op ::= EXCEPT|INTERSECT */
+ 197, /* (85) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
+ 208, /* (86) values ::= VALUES LP nexprlist RP */
+ 208, /* (87) values ::= values COMMA LP nexprlist RP */
+ 200, /* (88) distinct ::= DISTINCT */
+ 200, /* (89) distinct ::= ALL */
+ 200, /* (90) distinct ::= */
+ 210, /* (91) sclp ::= */
+ 201, /* (92) selcollist ::= sclp scanpt expr scanpt as */
+ 201, /* (93) selcollist ::= sclp scanpt STAR */
+ 201, /* (94) selcollist ::= sclp scanpt nm DOT STAR */
+ 211, /* (95) as ::= AS nm */
+ 211, /* (96) as ::= */
+ 202, /* (97) from ::= */
+ 202, /* (98) from ::= FROM seltablist */
+ 213, /* (99) stl_prefix ::= seltablist joinop */
+ 213, /* (100) stl_prefix ::= */
+ 212, /* (101) seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
+ 212, /* (102) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
+ 212, /* (103) seltablist ::= stl_prefix LP select RP as on_opt using_opt */
+ 212, /* (104) seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
+ 160, /* (105) dbnm ::= */
+ 160, /* (106) dbnm ::= DOT nm */
+ 195, /* (107) fullname ::= nm */
+ 195, /* (108) fullname ::= nm DOT nm */
+ 219, /* (109) xfullname ::= nm */
+ 219, /* (110) xfullname ::= nm DOT nm */
+ 219, /* (111) xfullname ::= nm DOT nm AS nm */
+ 219, /* (112) xfullname ::= nm AS nm */
+ 214, /* (113) joinop ::= COMMA|JOIN */
+ 214, /* (114) joinop ::= JOIN_KW JOIN */
+ 214, /* (115) joinop ::= JOIN_KW nm JOIN */
+ 214, /* (116) joinop ::= JOIN_KW nm nm JOIN */
+ 216, /* (117) on_opt ::= ON expr */
+ 216, /* (118) on_opt ::= */
+ 215, /* (119) indexed_opt ::= */
+ 215, /* (120) indexed_opt ::= INDEXED BY nm */
+ 215, /* (121) indexed_opt ::= NOT INDEXED */
+ 217, /* (122) using_opt ::= USING LP idlist RP */
+ 217, /* (123) using_opt ::= */
+ 206, /* (124) orderby_opt ::= */
+ 206, /* (125) orderby_opt ::= ORDER BY sortlist */
+ 188, /* (126) sortlist ::= sortlist COMMA expr sortorder */
+ 188, /* (127) sortlist ::= expr sortorder */
+ 177, /* (128) sortorder ::= ASC */
+ 177, /* (129) sortorder ::= DESC */
+ 177, /* (130) sortorder ::= */
+ 204, /* (131) groupby_opt ::= */
+ 204, /* (132) groupby_opt ::= GROUP BY nexprlist */
+ 205, /* (133) having_opt ::= */
+ 205, /* (134) having_opt ::= HAVING expr */
+ 207, /* (135) limit_opt ::= */
+ 207, /* (136) limit_opt ::= LIMIT expr */
+ 207, /* (137) limit_opt ::= LIMIT expr OFFSET expr */
+ 207, /* (138) limit_opt ::= LIMIT expr COMMA expr */
+ 150, /* (139) cmd ::= with DELETE FROM xfullname indexed_opt where_opt */
+ 203, /* (140) where_opt ::= */
+ 203, /* (141) where_opt ::= WHERE expr */
+ 150, /* (142) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt */
+ 222, /* (143) setlist ::= setlist COMMA nm EQ expr */
+ 222, /* (144) setlist ::= setlist COMMA LP idlist RP EQ expr */
+ 222, /* (145) setlist ::= nm EQ expr */
+ 222, /* (146) setlist ::= LP idlist RP EQ expr */
+ 150, /* (147) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
+ 150, /* (148) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */
+ 225, /* (149) upsert ::= */
+ 225, /* (150) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */
+ 225, /* (151) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */
+ 225, /* (152) upsert ::= ON CONFLICT DO NOTHING */
+ 223, /* (153) insert_cmd ::= INSERT orconf */
+ 223, /* (154) insert_cmd ::= REPLACE */
+ 224, /* (155) idlist_opt ::= */
+ 224, /* (156) idlist_opt ::= LP idlist RP */
+ 220, /* (157) idlist ::= idlist COMMA nm */
+ 220, /* (158) idlist ::= nm */
+ 175, /* (159) expr ::= LP expr RP */
+ 175, /* (160) expr ::= ID|INDEXED */
+ 175, /* (161) expr ::= JOIN_KW */
+ 175, /* (162) expr ::= nm DOT nm */
+ 175, /* (163) expr ::= nm DOT nm DOT nm */
+ 174, /* (164) term ::= NULL|FLOAT|BLOB */
+ 174, /* (165) term ::= STRING */
+ 174, /* (166) term ::= INTEGER */
+ 175, /* (167) expr ::= VARIABLE */
+ 175, /* (168) expr ::= expr COLLATE ID|STRING */
+ 175, /* (169) expr ::= CAST LP expr AS typetoken RP */
+ 175, /* (170) expr ::= ID|INDEXED LP distinct exprlist RP */
+ 175, /* (171) expr ::= ID|INDEXED LP STAR RP */
+ 174, /* (172) term ::= CTIME_KW */
+ 175, /* (173) expr ::= LP nexprlist COMMA expr RP */
+ 175, /* (174) expr ::= expr AND expr */
+ 175, /* (175) expr ::= expr OR expr */
+ 175, /* (176) expr ::= expr LT|GT|GE|LE expr */
+ 175, /* (177) expr ::= expr EQ|NE expr */
+ 175, /* (178) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */
+ 175, /* (179) expr ::= expr PLUS|MINUS expr */
+ 175, /* (180) expr ::= expr STAR|SLASH|REM expr */
+ 175, /* (181) expr ::= expr CONCAT expr */
+ 226, /* (182) likeop ::= NOT LIKE_KW|MATCH */
+ 175, /* (183) expr ::= expr likeop expr */
+ 175, /* (184) expr ::= expr likeop expr ESCAPE expr */
+ 175, /* (185) expr ::= expr ISNULL|NOTNULL */
+ 175, /* (186) expr ::= expr NOT NULL */
+ 175, /* (187) expr ::= expr IS expr */
+ 175, /* (188) expr ::= expr IS NOT expr */
+ 175, /* (189) expr ::= NOT expr */
+ 175, /* (190) expr ::= BITNOT expr */
+ 175, /* (191) expr ::= PLUS|MINUS expr */
+ 227, /* (192) between_op ::= BETWEEN */
+ 227, /* (193) between_op ::= NOT BETWEEN */
+ 175, /* (194) expr ::= expr between_op expr AND expr */
+ 228, /* (195) in_op ::= IN */
+ 228, /* (196) in_op ::= NOT IN */
+ 175, /* (197) expr ::= expr in_op LP exprlist RP */
+ 175, /* (198) expr ::= LP select RP */
+ 175, /* (199) expr ::= expr in_op LP select RP */
+ 175, /* (200) expr ::= expr in_op nm dbnm paren_exprlist */
+ 175, /* (201) expr ::= EXISTS LP select RP */
+ 175, /* (202) expr ::= CASE case_operand case_exprlist case_else END */
+ 231, /* (203) case_exprlist ::= case_exprlist WHEN expr THEN expr */
+ 231, /* (204) case_exprlist ::= WHEN expr THEN expr */
+ 232, /* (205) case_else ::= ELSE expr */
+ 232, /* (206) case_else ::= */
+ 230, /* (207) case_operand ::= expr */
+ 230, /* (208) case_operand ::= */
+ 218, /* (209) exprlist ::= */
+ 209, /* (210) nexprlist ::= nexprlist COMMA expr */
+ 209, /* (211) nexprlist ::= expr */
+ 229, /* (212) paren_exprlist ::= */
+ 229, /* (213) paren_exprlist ::= LP exprlist RP */
+ 150, /* (214) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
+ 233, /* (215) uniqueflag ::= UNIQUE */
+ 233, /* (216) uniqueflag ::= */
+ 179, /* (217) eidlist_opt ::= */
+ 179, /* (218) eidlist_opt ::= LP eidlist RP */
+ 189, /* (219) eidlist ::= eidlist COMMA nm collate sortorder */
+ 189, /* (220) eidlist ::= nm collate sortorder */
+ 234, /* (221) collate ::= */
+ 234, /* (222) collate ::= COLLATE ID|STRING */
+ 150, /* (223) cmd ::= DROP INDEX ifexists fullname */
+ 150, /* (224) cmd ::= VACUUM vinto */
+ 150, /* (225) cmd ::= VACUUM nm vinto */
+ 235, /* (226) vinto ::= INTO expr */
+ 235, /* (227) vinto ::= */
+ 150, /* (228) cmd ::= PRAGMA nm dbnm */
+ 150, /* (229) cmd ::= PRAGMA nm dbnm EQ nmnum */
+ 150, /* (230) cmd ::= PRAGMA nm dbnm LP nmnum RP */
+ 150, /* (231) cmd ::= PRAGMA nm dbnm EQ minus_num */
+ 150, /* (232) cmd ::= PRAGMA nm dbnm LP minus_num RP */
+ 170, /* (233) plus_num ::= PLUS INTEGER|FLOAT */
+ 171, /* (234) minus_num ::= MINUS INTEGER|FLOAT */
+ 150, /* (235) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
+ 237, /* (236) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
+ 239, /* (237) trigger_time ::= BEFORE|AFTER */
+ 239, /* (238) trigger_time ::= INSTEAD OF */
+ 239, /* (239) trigger_time ::= */
+ 240, /* (240) trigger_event ::= DELETE|INSERT */
+ 240, /* (241) trigger_event ::= UPDATE */
+ 240, /* (242) trigger_event ::= UPDATE OF idlist */
+ 242, /* (243) when_clause ::= */
+ 242, /* (244) when_clause ::= WHEN expr */
+ 238, /* (245) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
+ 238, /* (246) trigger_cmd_list ::= trigger_cmd SEMI */
+ 244, /* (247) trnm ::= nm DOT nm */
+ 245, /* (248) tridxby ::= INDEXED BY nm */
+ 245, /* (249) tridxby ::= NOT INDEXED */
+ 243, /* (250) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */
+ 243, /* (251) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
+ 243, /* (252) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
+ 243, /* (253) trigger_cmd ::= scanpt select scanpt */
+ 175, /* (254) expr ::= RAISE LP IGNORE RP */
+ 175, /* (255) expr ::= RAISE LP raisetype COMMA nm RP */
+ 193, /* (256) raisetype ::= ROLLBACK */
+ 193, /* (257) raisetype ::= ABORT */
+ 193, /* (258) raisetype ::= FAIL */
+ 150, /* (259) cmd ::= DROP TRIGGER ifexists fullname */
+ 150, /* (260) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
+ 150, /* (261) cmd ::= DETACH database_kw_opt expr */
+ 247, /* (262) key_opt ::= */
+ 247, /* (263) key_opt ::= KEY expr */
+ 150, /* (264) cmd ::= ALTER TABLE fullname RENAME TO nm */
+ 150, /* (265) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
+ 248, /* (266) add_column_fullname ::= fullname */
+ 150, /* (267) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
+ 150, /* (268) cmd ::= create_vtab */
+ 150, /* (269) cmd ::= create_vtab LP vtabarglist RP */
+ 250, /* (270) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
+ 252, /* (271) vtabarg ::= */
+ 253, /* (272) vtabargtoken ::= ANY */
+ 253, /* (273) vtabargtoken ::= lp anylist RP */
+ 254, /* (274) lp ::= LP */
+ 221, /* (275) with ::= WITH wqlist */
+ 221, /* (276) with ::= WITH RECURSIVE wqlist */
+ 198, /* (277) wqlist ::= nm eidlist_opt AS LP select RP */
+ 198, /* (278) wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
+ 146, /* (279) input ::= cmdlist */
+ 147, /* (280) cmdlist ::= cmdlist ecmd */
+ 147, /* (281) cmdlist ::= ecmd */
+ 148, /* (282) ecmd ::= SEMI */
+ 148, /* (283) ecmd ::= cmdx SEMI */
+ 152, /* (284) trans_opt ::= */
+ 152, /* (285) trans_opt ::= TRANSACTION */
+ 152, /* (286) trans_opt ::= TRANSACTION nm */
+ 154, /* (287) savepoint_opt ::= SAVEPOINT */
+ 154, /* (288) savepoint_opt ::= */
+ 150, /* (289) cmd ::= create_table create_table_args */
+ 161, /* (290) columnlist ::= columnlist COMMA columnname carglist */
+ 161, /* (291) columnlist ::= columnname carglist */
+ 153, /* (292) nm ::= ID|INDEXED */
+ 153, /* (293) nm ::= STRING */
+ 153, /* (294) nm ::= JOIN_KW */
+ 167, /* (295) typetoken ::= typename */
+ 168, /* (296) typename ::= ID|STRING */
+ 169, /* (297) signed ::= plus_num */
+ 169, /* (298) signed ::= minus_num */
+ 166, /* (299) carglist ::= carglist ccons */
+ 166, /* (300) carglist ::= */
+ 173, /* (301) ccons ::= NULL onconf */
+ 162, /* (302) conslist_opt ::= COMMA conslist */
+ 185, /* (303) conslist ::= conslist tconscomma tcons */
+ 185, /* (304) conslist ::= tcons */
+ 186, /* (305) tconscomma ::= */
+ 190, /* (306) defer_subclause_opt ::= defer_subclause */
+ 192, /* (307) resolvetype ::= raisetype */
+ 196, /* (308) selectnowith ::= oneselect */
+ 197, /* (309) oneselect ::= values */
+ 210, /* (310) sclp ::= selcollist COMMA */
+ 211, /* (311) as ::= ID|STRING */
+ 175, /* (312) expr ::= term */
+ 226, /* (313) likeop ::= LIKE_KW|MATCH */
+ 218, /* (314) exprlist ::= nexprlist */
+ 236, /* (315) nmnum ::= plus_num */
+ 236, /* (316) nmnum ::= nm */
+ 236, /* (317) nmnum ::= ON */
+ 236, /* (318) nmnum ::= DELETE */
+ 236, /* (319) nmnum ::= DEFAULT */
+ 170, /* (320) plus_num ::= INTEGER|FLOAT */
+ 241, /* (321) foreach_clause ::= */
+ 241, /* (322) foreach_clause ::= FOR EACH ROW */
+ 244, /* (323) trnm ::= nm */
+ 245, /* (324) tridxby ::= */
+ 246, /* (325) database_kw_opt ::= DATABASE */
+ 246, /* (326) database_kw_opt ::= */
+ 249, /* (327) kwcolumn_opt ::= */
+ 249, /* (328) kwcolumn_opt ::= COLUMNKW */
+ 251, /* (329) vtabarglist ::= vtabarg */
+ 251, /* (330) vtabarglist ::= vtabarglist COMMA vtabarg */
+ 252, /* (331) vtabarg ::= vtabarg vtabargtoken */
+ 255, /* (332) anylist ::= */
+ 255, /* (333) anylist ::= anylist LP anylist RP */
+ 255, /* (334) anylist ::= anylist ANY */
+ 221, /* (335) with ::= */
+};
+
+/* For rule J, yyRuleInfoNRhs[J] contains the negative of the number
+** of symbols on the right-hand side of that rule. */
+static const signed char yyRuleInfoNRhs[] = {
+ -1, /* (0) cmdx ::= cmd */
+ -3, /* (1) cmd ::= BEGIN transtype trans_opt */
+ 0, /* (2) transtype ::= */
+ -1, /* (3) transtype ::= DEFERRED */
+ -1, /* (4) transtype ::= IMMEDIATE */
+ -1, /* (5) transtype ::= EXCLUSIVE */
+ -2, /* (6) cmd ::= COMMIT|END trans_opt */
+ -2, /* (7) cmd ::= ROLLBACK trans_opt */
+ -2, /* (8) cmd ::= SAVEPOINT nm */
+ -3, /* (9) cmd ::= RELEASE savepoint_opt nm */
+ -5, /* (10) cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */
+ -6, /* (11) create_table ::= createkw temp TABLE ifnotexists nm dbnm */
+ -1, /* (12) createkw ::= CREATE */
+ 0, /* (13) ifnotexists ::= */
+ -3, /* (14) ifnotexists ::= IF NOT EXISTS */
+ -1, /* (15) temp ::= TEMP */
+ 0, /* (16) temp ::= */
+ -5, /* (17) create_table_args ::= LP columnlist conslist_opt RP table_options */
+ -2, /* (18) create_table_args ::= AS select */
+ 0, /* (19) table_options ::= */
+ -2, /* (20) table_options ::= WITHOUT nm */
+ -2, /* (21) columnname ::= nm typetoken */
+ 0, /* (22) typetoken ::= */
+ -4, /* (23) typetoken ::= typename LP signed RP */
+ -6, /* (24) typetoken ::= typename LP signed COMMA signed RP */
+ -2, /* (25) typename ::= typename ID|STRING */
+ 0, /* (26) scanpt ::= */
+ -2, /* (27) ccons ::= CONSTRAINT nm */
+ -4, /* (28) ccons ::= DEFAULT scanpt term scanpt */
+ -4, /* (29) ccons ::= DEFAULT LP expr RP */
+ -4, /* (30) ccons ::= DEFAULT PLUS term scanpt */
+ -4, /* (31) ccons ::= DEFAULT MINUS term scanpt */
+ -3, /* (32) ccons ::= DEFAULT scanpt ID|INDEXED */
+ -3, /* (33) ccons ::= NOT NULL onconf */
+ -5, /* (34) ccons ::= PRIMARY KEY sortorder onconf autoinc */
+ -2, /* (35) ccons ::= UNIQUE onconf */
+ -4, /* (36) ccons ::= CHECK LP expr RP */
+ -4, /* (37) ccons ::= REFERENCES nm eidlist_opt refargs */
+ -1, /* (38) ccons ::= defer_subclause */
+ -2, /* (39) ccons ::= COLLATE ID|STRING */
+ 0, /* (40) autoinc ::= */
+ -1, /* (41) autoinc ::= AUTOINCR */
+ 0, /* (42) refargs ::= */
+ -2, /* (43) refargs ::= refargs refarg */
+ -2, /* (44) refarg ::= MATCH nm */
+ -3, /* (45) refarg ::= ON INSERT refact */
+ -3, /* (46) refarg ::= ON DELETE refact */
+ -3, /* (47) refarg ::= ON UPDATE refact */
+ -2, /* (48) refact ::= SET NULL */
+ -2, /* (49) refact ::= SET DEFAULT */
+ -1, /* (50) refact ::= CASCADE */
+ -1, /* (51) refact ::= RESTRICT */
+ -2, /* (52) refact ::= NO ACTION */
+ -3, /* (53) defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
+ -2, /* (54) defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
+ 0, /* (55) init_deferred_pred_opt ::= */
+ -2, /* (56) init_deferred_pred_opt ::= INITIALLY DEFERRED */
+ -2, /* (57) init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
+ 0, /* (58) conslist_opt ::= */
+ -1, /* (59) tconscomma ::= COMMA */
+ -2, /* (60) tcons ::= CONSTRAINT nm */
+ -7, /* (61) tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
+ -5, /* (62) tcons ::= UNIQUE LP sortlist RP onconf */
+ -5, /* (63) tcons ::= CHECK LP expr RP onconf */
+ -10, /* (64) tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
+ 0, /* (65) defer_subclause_opt ::= */
+ 0, /* (66) onconf ::= */
+ -3, /* (67) onconf ::= ON CONFLICT resolvetype */
+ 0, /* (68) orconf ::= */
+ -2, /* (69) orconf ::= OR resolvetype */
+ -1, /* (70) resolvetype ::= IGNORE */
+ -1, /* (71) resolvetype ::= REPLACE */
+ -4, /* (72) cmd ::= DROP TABLE ifexists fullname */
+ -2, /* (73) ifexists ::= IF EXISTS */
+ 0, /* (74) ifexists ::= */
+ -9, /* (75) cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
+ -4, /* (76) cmd ::= DROP VIEW ifexists fullname */
+ -1, /* (77) cmd ::= select */
+ -3, /* (78) select ::= WITH wqlist selectnowith */
+ -4, /* (79) select ::= WITH RECURSIVE wqlist selectnowith */
+ -1, /* (80) select ::= selectnowith */
+ -3, /* (81) selectnowith ::= selectnowith multiselect_op oneselect */
+ -1, /* (82) multiselect_op ::= UNION */
+ -2, /* (83) multiselect_op ::= UNION ALL */
+ -1, /* (84) multiselect_op ::= EXCEPT|INTERSECT */
+ -9, /* (85) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
+ -4, /* (86) values ::= VALUES LP nexprlist RP */
+ -5, /* (87) values ::= values COMMA LP nexprlist RP */
+ -1, /* (88) distinct ::= DISTINCT */
+ -1, /* (89) distinct ::= ALL */
+ 0, /* (90) distinct ::= */
+ 0, /* (91) sclp ::= */
+ -5, /* (92) selcollist ::= sclp scanpt expr scanpt as */
+ -3, /* (93) selcollist ::= sclp scanpt STAR */
+ -5, /* (94) selcollist ::= sclp scanpt nm DOT STAR */
+ -2, /* (95) as ::= AS nm */
+ 0, /* (96) as ::= */
+ 0, /* (97) from ::= */
+ -2, /* (98) from ::= FROM seltablist */
+ -2, /* (99) stl_prefix ::= seltablist joinop */
+ 0, /* (100) stl_prefix ::= */
+ -7, /* (101) seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
+ -9, /* (102) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
+ -7, /* (103) seltablist ::= stl_prefix LP select RP as on_opt using_opt */
+ -7, /* (104) seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
+ 0, /* (105) dbnm ::= */
+ -2, /* (106) dbnm ::= DOT nm */
+ -1, /* (107) fullname ::= nm */
+ -3, /* (108) fullname ::= nm DOT nm */
+ -1, /* (109) xfullname ::= nm */
+ -3, /* (110) xfullname ::= nm DOT nm */
+ -5, /* (111) xfullname ::= nm DOT nm AS nm */
+ -3, /* (112) xfullname ::= nm AS nm */
+ -1, /* (113) joinop ::= COMMA|JOIN */
+ -2, /* (114) joinop ::= JOIN_KW JOIN */
+ -3, /* (115) joinop ::= JOIN_KW nm JOIN */
+ -4, /* (116) joinop ::= JOIN_KW nm nm JOIN */
+ -2, /* (117) on_opt ::= ON expr */
+ 0, /* (118) on_opt ::= */
+ 0, /* (119) indexed_opt ::= */
+ -3, /* (120) indexed_opt ::= INDEXED BY nm */
+ -2, /* (121) indexed_opt ::= NOT INDEXED */
+ -4, /* (122) using_opt ::= USING LP idlist RP */
+ 0, /* (123) using_opt ::= */
+ 0, /* (124) orderby_opt ::= */
+ -3, /* (125) orderby_opt ::= ORDER BY sortlist */
+ -4, /* (126) sortlist ::= sortlist COMMA expr sortorder */
+ -2, /* (127) sortlist ::= expr sortorder */
+ -1, /* (128) sortorder ::= ASC */
+ -1, /* (129) sortorder ::= DESC */
+ 0, /* (130) sortorder ::= */
+ 0, /* (131) groupby_opt ::= */
+ -3, /* (132) groupby_opt ::= GROUP BY nexprlist */
+ 0, /* (133) having_opt ::= */
+ -2, /* (134) having_opt ::= HAVING expr */
+ 0, /* (135) limit_opt ::= */
+ -2, /* (136) limit_opt ::= LIMIT expr */
+ -4, /* (137) limit_opt ::= LIMIT expr OFFSET expr */
+ -4, /* (138) limit_opt ::= LIMIT expr COMMA expr */
+ -6, /* (139) cmd ::= with DELETE FROM xfullname indexed_opt where_opt */
+ 0, /* (140) where_opt ::= */
+ -2, /* (141) where_opt ::= WHERE expr */
+ -8, /* (142) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt */
+ -5, /* (143) setlist ::= setlist COMMA nm EQ expr */
+ -7, /* (144) setlist ::= setlist COMMA LP idlist RP EQ expr */
+ -3, /* (145) setlist ::= nm EQ expr */
+ -5, /* (146) setlist ::= LP idlist RP EQ expr */
+ -7, /* (147) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
+ -7, /* (148) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */
+ 0, /* (149) upsert ::= */
+ -11, /* (150) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt */
+ -8, /* (151) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING */
+ -4, /* (152) upsert ::= ON CONFLICT DO NOTHING */
+ -2, /* (153) insert_cmd ::= INSERT orconf */
+ -1, /* (154) insert_cmd ::= REPLACE */
+ 0, /* (155) idlist_opt ::= */
+ -3, /* (156) idlist_opt ::= LP idlist RP */
+ -3, /* (157) idlist ::= idlist COMMA nm */
+ -1, /* (158) idlist ::= nm */
+ -3, /* (159) expr ::= LP expr RP */
+ -1, /* (160) expr ::= ID|INDEXED */
+ -1, /* (161) expr ::= JOIN_KW */
+ -3, /* (162) expr ::= nm DOT nm */
+ -5, /* (163) expr ::= nm DOT nm DOT nm */
+ -1, /* (164) term ::= NULL|FLOAT|BLOB */
+ -1, /* (165) term ::= STRING */
+ -1, /* (166) term ::= INTEGER */
+ -1, /* (167) expr ::= VARIABLE */
+ -3, /* (168) expr ::= expr COLLATE ID|STRING */
+ -6, /* (169) expr ::= CAST LP expr AS typetoken RP */
+ -5, /* (170) expr ::= ID|INDEXED LP distinct exprlist RP */
+ -4, /* (171) expr ::= ID|INDEXED LP STAR RP */
+ -1, /* (172) term ::= CTIME_KW */
+ -5, /* (173) expr ::= LP nexprlist COMMA expr RP */
+ -3, /* (174) expr ::= expr AND expr */
+ -3, /* (175) expr ::= expr OR expr */
+ -3, /* (176) expr ::= expr LT|GT|GE|LE expr */
+ -3, /* (177) expr ::= expr EQ|NE expr */
+ -3, /* (178) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */
+ -3, /* (179) expr ::= expr PLUS|MINUS expr */
+ -3, /* (180) expr ::= expr STAR|SLASH|REM expr */
+ -3, /* (181) expr ::= expr CONCAT expr */
+ -2, /* (182) likeop ::= NOT LIKE_KW|MATCH */
+ -3, /* (183) expr ::= expr likeop expr */
+ -5, /* (184) expr ::= expr likeop expr ESCAPE expr */
+ -2, /* (185) expr ::= expr ISNULL|NOTNULL */
+ -3, /* (186) expr ::= expr NOT NULL */
+ -3, /* (187) expr ::= expr IS expr */
+ -4, /* (188) expr ::= expr IS NOT expr */
+ -2, /* (189) expr ::= NOT expr */
+ -2, /* (190) expr ::= BITNOT expr */
+ -2, /* (191) expr ::= PLUS|MINUS expr */
+ -1, /* (192) between_op ::= BETWEEN */
+ -2, /* (193) between_op ::= NOT BETWEEN */
+ -5, /* (194) expr ::= expr between_op expr AND expr */
+ -1, /* (195) in_op ::= IN */
+ -2, /* (196) in_op ::= NOT IN */
+ -5, /* (197) expr ::= expr in_op LP exprlist RP */
+ -3, /* (198) expr ::= LP select RP */
+ -5, /* (199) expr ::= expr in_op LP select RP */
+ -5, /* (200) expr ::= expr in_op nm dbnm paren_exprlist */
+ -4, /* (201) expr ::= EXISTS LP select RP */
+ -5, /* (202) expr ::= CASE case_operand case_exprlist case_else END */
+ -5, /* (203) case_exprlist ::= case_exprlist WHEN expr THEN expr */
+ -4, /* (204) case_exprlist ::= WHEN expr THEN expr */
+ -2, /* (205) case_else ::= ELSE expr */
+ 0, /* (206) case_else ::= */
+ -1, /* (207) case_operand ::= expr */
+ 0, /* (208) case_operand ::= */
+ 0, /* (209) exprlist ::= */
+ -3, /* (210) nexprlist ::= nexprlist COMMA expr */
+ -1, /* (211) nexprlist ::= expr */
+ 0, /* (212) paren_exprlist ::= */
+ -3, /* (213) paren_exprlist ::= LP exprlist RP */
+ -12, /* (214) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
+ -1, /* (215) uniqueflag ::= UNIQUE */
+ 0, /* (216) uniqueflag ::= */
+ 0, /* (217) eidlist_opt ::= */
+ -3, /* (218) eidlist_opt ::= LP eidlist RP */
+ -5, /* (219) eidlist ::= eidlist COMMA nm collate sortorder */
+ -3, /* (220) eidlist ::= nm collate sortorder */
+ 0, /* (221) collate ::= */
+ -2, /* (222) collate ::= COLLATE ID|STRING */
+ -4, /* (223) cmd ::= DROP INDEX ifexists fullname */
+ -2, /* (224) cmd ::= VACUUM vinto */
+ -3, /* (225) cmd ::= VACUUM nm vinto */
+ -2, /* (226) vinto ::= INTO expr */
+ 0, /* (227) vinto ::= */
+ -3, /* (228) cmd ::= PRAGMA nm dbnm */
+ -5, /* (229) cmd ::= PRAGMA nm dbnm EQ nmnum */
+ -6, /* (230) cmd ::= PRAGMA nm dbnm LP nmnum RP */
+ -5, /* (231) cmd ::= PRAGMA nm dbnm EQ minus_num */
+ -6, /* (232) cmd ::= PRAGMA nm dbnm LP minus_num RP */
+ -2, /* (233) plus_num ::= PLUS INTEGER|FLOAT */
+ -2, /* (234) minus_num ::= MINUS INTEGER|FLOAT */
+ -5, /* (235) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
+ -11, /* (236) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
+ -1, /* (237) trigger_time ::= BEFORE|AFTER */
+ -2, /* (238) trigger_time ::= INSTEAD OF */
+ 0, /* (239) trigger_time ::= */
+ -1, /* (240) trigger_event ::= DELETE|INSERT */
+ -1, /* (241) trigger_event ::= UPDATE */
+ -3, /* (242) trigger_event ::= UPDATE OF idlist */
+ 0, /* (243) when_clause ::= */
+ -2, /* (244) when_clause ::= WHEN expr */
+ -3, /* (245) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
+ -2, /* (246) trigger_cmd_list ::= trigger_cmd SEMI */
+ -3, /* (247) trnm ::= nm DOT nm */
+ -3, /* (248) tridxby ::= INDEXED BY nm */
+ -2, /* (249) tridxby ::= NOT INDEXED */
+ -8, /* (250) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt scanpt */
+ -8, /* (251) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
+ -6, /* (252) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
+ -3, /* (253) trigger_cmd ::= scanpt select scanpt */
+ -4, /* (254) expr ::= RAISE LP IGNORE RP */
+ -6, /* (255) expr ::= RAISE LP raisetype COMMA nm RP */
+ -1, /* (256) raisetype ::= ROLLBACK */
+ -1, /* (257) raisetype ::= ABORT */
+ -1, /* (258) raisetype ::= FAIL */
+ -4, /* (259) cmd ::= DROP TRIGGER ifexists fullname */
+ -6, /* (260) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
+ -3, /* (261) cmd ::= DETACH database_kw_opt expr */
+ 0, /* (262) key_opt ::= */
+ -2, /* (263) key_opt ::= KEY expr */
+ -6, /* (264) cmd ::= ALTER TABLE fullname RENAME TO nm */
+ -7, /* (265) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
+ -1, /* (266) add_column_fullname ::= fullname */
+ -8, /* (267) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
+ -1, /* (268) cmd ::= create_vtab */
+ -4, /* (269) cmd ::= create_vtab LP vtabarglist RP */
+ -8, /* (270) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
+ 0, /* (271) vtabarg ::= */
+ -1, /* (272) vtabargtoken ::= ANY */
+ -3, /* (273) vtabargtoken ::= lp anylist RP */
+ -1, /* (274) lp ::= LP */
+ -2, /* (275) with ::= WITH wqlist */
+ -3, /* (276) with ::= WITH RECURSIVE wqlist */
+ -6, /* (277) wqlist ::= nm eidlist_opt AS LP select RP */
+ -8, /* (278) wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
+ -1, /* (279) input ::= cmdlist */
+ -2, /* (280) cmdlist ::= cmdlist ecmd */
+ -1, /* (281) cmdlist ::= ecmd */
+ -1, /* (282) ecmd ::= SEMI */
+ -2, /* (283) ecmd ::= cmdx SEMI */
+ 0, /* (284) trans_opt ::= */
+ -1, /* (285) trans_opt ::= TRANSACTION */
+ -2, /* (286) trans_opt ::= TRANSACTION nm */
+ -1, /* (287) savepoint_opt ::= SAVEPOINT */
+ 0, /* (288) savepoint_opt ::= */
+ -2, /* (289) cmd ::= create_table create_table_args */
+ -4, /* (290) columnlist ::= columnlist COMMA columnname carglist */
+ -2, /* (291) columnlist ::= columnname carglist */
+ -1, /* (292) nm ::= ID|INDEXED */
+ -1, /* (293) nm ::= STRING */
+ -1, /* (294) nm ::= JOIN_KW */
+ -1, /* (295) typetoken ::= typename */
+ -1, /* (296) typename ::= ID|STRING */
+ -1, /* (297) signed ::= plus_num */
+ -1, /* (298) signed ::= minus_num */
+ -2, /* (299) carglist ::= carglist ccons */
+ 0, /* (300) carglist ::= */
+ -2, /* (301) ccons ::= NULL onconf */
+ -2, /* (302) conslist_opt ::= COMMA conslist */
+ -3, /* (303) conslist ::= conslist tconscomma tcons */
+ -1, /* (304) conslist ::= tcons */
+ 0, /* (305) tconscomma ::= */
+ -1, /* (306) defer_subclause_opt ::= defer_subclause */
+ -1, /* (307) resolvetype ::= raisetype */
+ -1, /* (308) selectnowith ::= oneselect */
+ -1, /* (309) oneselect ::= values */
+ -2, /* (310) sclp ::= selcollist COMMA */
+ -1, /* (311) as ::= ID|STRING */
+ -1, /* (312) expr ::= term */
+ -1, /* (313) likeop ::= LIKE_KW|MATCH */
+ -1, /* (314) exprlist ::= nexprlist */
+ -1, /* (315) nmnum ::= plus_num */
+ -1, /* (316) nmnum ::= nm */
+ -1, /* (317) nmnum ::= ON */
+ -1, /* (318) nmnum ::= DELETE */
+ -1, /* (319) nmnum ::= DEFAULT */
+ -1, /* (320) plus_num ::= INTEGER|FLOAT */
+ 0, /* (321) foreach_clause ::= */
+ -3, /* (322) foreach_clause ::= FOR EACH ROW */
+ -1, /* (323) trnm ::= nm */
+ 0, /* (324) tridxby ::= */
+ -1, /* (325) database_kw_opt ::= DATABASE */
+ 0, /* (326) database_kw_opt ::= */
+ 0, /* (327) kwcolumn_opt ::= */
+ -1, /* (328) kwcolumn_opt ::= COLUMNKW */
+ -1, /* (329) vtabarglist ::= vtabarg */
+ -3, /* (330) vtabarglist ::= vtabarglist COMMA vtabarg */
+ -2, /* (331) vtabarg ::= vtabarg vtabargtoken */
+ 0, /* (332) anylist ::= */
+ -4, /* (333) anylist ::= anylist LP anylist RP */
+ -2, /* (334) anylist ::= anylist ANY */
+ 0, /* (335) with ::= */
};
static void yy_accept(yyParser*); /* Forward Declaration */
@@ -149428,7 +150226,7 @@ static YYACTIONTYPE yy_reduce(
yymsp = yypParser->yytos;
#ifndef NDEBUG
if( yyTraceFILE && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){
- yysize = yyRuleInfo[yyruleno].nrhs;
+ yysize = yyRuleInfoNRhs[yyruleno];
if( yysize ){
fprintf(yyTraceFILE, "%sReduce %d [%s], go to state %d.\n",
yyTracePrompt,
@@ -149443,7 +150241,7 @@ static YYACTIONTYPE yy_reduce(
/* Check that the stack is large enough to grow by a single entry
** if the RHS of the rule is empty. This ensures that there is room
** enough on the stack to push the LHS value */
- if( yyRuleInfo[yyruleno].nrhs==0 ){
+ if( yyRuleInfoNRhs[yyruleno]==0 ){
#ifdef YYTRACKMAXSTACKDEPTH
if( (int)(yypParser->yytos - yypParser->yystack)>yypParser->yyhwm ){
yypParser->yyhwm++;
@@ -149487,15 +150285,15 @@ static YYACTIONTYPE yy_reduce(
{ sqlite3FinishCoding(pParse); }
break;
case 1: /* cmd ::= BEGIN transtype trans_opt */
-{sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy502);}
+{sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy348);}
break;
case 2: /* transtype ::= */
-{yymsp[1].minor.yy502 = TK_DEFERRED;}
+{yymsp[1].minor.yy348 = TK_DEFERRED;}
break;
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*/}
+{yymsp[0].minor.yy348 = yymsp[0].major; /*A-overwrites-X*/}
break;
case 6: /* cmd ::= COMMIT|END trans_opt */
case 7: /* cmd ::= ROLLBACK trans_opt */ yytestcase(yyruleno==7);
@@ -149518,7 +150316,7 @@ static YYACTIONTYPE yy_reduce(
break;
case 11: /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */
{
- sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy502,0,0,yymsp[-2].minor.yy502);
+ sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy348,0,0,yymsp[-2].minor.yy348);
}
break;
case 12: /* createkw ::= CREATE */
@@ -149533,32 +150331,32 @@ static YYACTIONTYPE yy_reduce(
case 74: /* ifexists ::= */ yytestcase(yyruleno==74);
case 90: /* distinct ::= */ yytestcase(yyruleno==90);
case 221: /* collate ::= */ yytestcase(yyruleno==221);
-{yymsp[1].minor.yy502 = 0;}
+{yymsp[1].minor.yy348 = 0;}
break;
case 14: /* ifnotexists ::= IF NOT EXISTS */
-{yymsp[-2].minor.yy502 = 1;}
+{yymsp[-2].minor.yy348 = 1;}
break;
case 15: /* temp ::= TEMP */
case 41: /* autoinc ::= AUTOINCR */ yytestcase(yyruleno==41);
-{yymsp[0].minor.yy502 = 1;}
+{yymsp[0].minor.yy348 = 1;}
break;
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.yy502,0);
+ sqlite3EndTable(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,yymsp[0].minor.yy348,0);
}
break;
case 18: /* create_table_args ::= AS select */
{
- sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy399);
- sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy399);
+ sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy43);
+ sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy43);
}
break;
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.yy502 = TF_WithoutRowid | TF_NoVisibleRowid;
+ yymsp[-1].minor.yy348 = TF_WithoutRowid | TF_NoVisibleRowid;
}else{
- yymsp[-1].minor.yy502 = 0;
+ yymsp[-1].minor.yy348 = 0;
sqlite3ErrorMsg(pParse, "unknown table option: %.*s", yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.z);
}
}
@@ -149587,7 +150385,7 @@ static YYACTIONTYPE yy_reduce(
case 26: /* scanpt ::= */
{
assert( yyLookahead!=YYNOCODE );
- yymsp[1].minor.yy36 = yyLookaheadToken.z;
+ yymsp[1].minor.yy360 = yyLookaheadToken.z;
}
break;
case 27: /* ccons ::= CONSTRAINT nm */
@@ -149595,18 +150393,18 @@ static YYACTIONTYPE yy_reduce(
{pParse->constraintName = yymsp[0].minor.yy0;}
break;
case 28: /* ccons ::= DEFAULT scanpt term scanpt */
-{sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy182,yymsp[-2].minor.yy36,yymsp[0].minor.yy36);}
+{sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy2,yymsp[-2].minor.yy360,yymsp[0].minor.yy360);}
break;
case 29: /* ccons ::= DEFAULT LP expr RP */
-{sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy182,yymsp[-2].minor.yy0.z+1,yymsp[0].minor.yy0.z);}
+{sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy2,yymsp[-2].minor.yy0.z+1,yymsp[0].minor.yy0.z);}
break;
case 30: /* ccons ::= DEFAULT PLUS term scanpt */
-{sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy182,yymsp[-2].minor.yy0.z,yymsp[0].minor.yy36);}
+{sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy2,yymsp[-2].minor.yy0.z,yymsp[0].minor.yy360);}
break;
case 31: /* ccons ::= DEFAULT MINUS term scanpt */
{
- Expr *p = sqlite3PExpr(pParse, TK_UMINUS, yymsp[-1].minor.yy182, 0);
- sqlite3AddDefaultValue(pParse,p,yymsp[-2].minor.yy0.z,yymsp[0].minor.yy36);
+ Expr *p = sqlite3PExpr(pParse, TK_UMINUS, yymsp[-1].minor.yy2, 0);
+ sqlite3AddDefaultValue(pParse,p,yymsp[-2].minor.yy0.z,yymsp[0].minor.yy360);
}
break;
case 32: /* ccons ::= DEFAULT scanpt ID|INDEXED */
@@ -149620,170 +150418,170 @@ static YYACTIONTYPE yy_reduce(
}
break;
case 33: /* ccons ::= NOT NULL onconf */
-{sqlite3AddNotNull(pParse, yymsp[0].minor.yy502);}
+{sqlite3AddNotNull(pParse, yymsp[0].minor.yy348);}
break;
case 34: /* ccons ::= PRIMARY KEY sortorder onconf autoinc */
-{sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy502,yymsp[0].minor.yy502,yymsp[-2].minor.yy502);}
+{sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy348,yymsp[0].minor.yy348,yymsp[-2].minor.yy348);}
break;
case 35: /* ccons ::= UNIQUE onconf */
-{sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy502,0,0,0,0,
+{sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy348,0,0,0,0,
SQLITE_IDXTYPE_UNIQUE);}
break;
case 36: /* ccons ::= CHECK LP expr RP */
-{sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy182);}
+{sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy2);}
break;
case 37: /* ccons ::= REFERENCES nm eidlist_opt refargs */
-{sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy232,yymsp[0].minor.yy502);}
+{sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy402,yymsp[0].minor.yy348);}
break;
case 38: /* ccons ::= defer_subclause */
-{sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy502);}
+{sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy348);}
break;
case 39: /* ccons ::= COLLATE ID|STRING */
{sqlite3AddCollateType(pParse, &yymsp[0].minor.yy0);}
break;
case 42: /* refargs ::= */
-{ yymsp[1].minor.yy502 = OE_None*0x0101; /* EV: R-19803-45884 */}
+{ yymsp[1].minor.yy348 = OE_None*0x0101; /* EV: R-19803-45884 */}
break;
case 43: /* refargs ::= refargs refarg */
-{ yymsp[-1].minor.yy502 = (yymsp[-1].minor.yy502 & ~yymsp[0].minor.yy107.mask) | yymsp[0].minor.yy107.value; }
+{ yymsp[-1].minor.yy348 = (yymsp[-1].minor.yy348 & ~yymsp[0].minor.yy239.mask) | yymsp[0].minor.yy239.value; }
break;
case 44: /* refarg ::= MATCH nm */
-{ yymsp[-1].minor.yy107.value = 0; yymsp[-1].minor.yy107.mask = 0x000000; }
+{ yymsp[-1].minor.yy239.value = 0; yymsp[-1].minor.yy239.mask = 0x000000; }
break;
case 45: /* refarg ::= ON INSERT refact */
-{ yymsp[-2].minor.yy107.value = 0; yymsp[-2].minor.yy107.mask = 0x000000; }
+{ yymsp[-2].minor.yy239.value = 0; yymsp[-2].minor.yy239.mask = 0x000000; }
break;
case 46: /* refarg ::= ON DELETE refact */
-{ yymsp[-2].minor.yy107.value = yymsp[0].minor.yy502; yymsp[-2].minor.yy107.mask = 0x0000ff; }
+{ yymsp[-2].minor.yy239.value = yymsp[0].minor.yy348; yymsp[-2].minor.yy239.mask = 0x0000ff; }
break;
case 47: /* refarg ::= ON UPDATE refact */
-{ yymsp[-2].minor.yy107.value = yymsp[0].minor.yy502<<8; yymsp[-2].minor.yy107.mask = 0x00ff00; }
+{ yymsp[-2].minor.yy239.value = yymsp[0].minor.yy348<<8; yymsp[-2].minor.yy239.mask = 0x00ff00; }
break;
case 48: /* refact ::= SET NULL */
-{ yymsp[-1].minor.yy502 = OE_SetNull; /* EV: R-33326-45252 */}
+{ yymsp[-1].minor.yy348 = OE_SetNull; /* EV: R-33326-45252 */}
break;
case 49: /* refact ::= SET DEFAULT */
-{ yymsp[-1].minor.yy502 = OE_SetDflt; /* EV: R-33326-45252 */}
+{ yymsp[-1].minor.yy348 = OE_SetDflt; /* EV: R-33326-45252 */}
break;
case 50: /* refact ::= CASCADE */
-{ yymsp[0].minor.yy502 = OE_Cascade; /* EV: R-33326-45252 */}
+{ yymsp[0].minor.yy348 = OE_Cascade; /* EV: R-33326-45252 */}
break;
case 51: /* refact ::= RESTRICT */
-{ yymsp[0].minor.yy502 = OE_Restrict; /* EV: R-33326-45252 */}
+{ yymsp[0].minor.yy348 = OE_Restrict; /* EV: R-33326-45252 */}
break;
case 52: /* refact ::= NO ACTION */
-{ yymsp[-1].minor.yy502 = OE_None; /* EV: R-33326-45252 */}
+{ yymsp[-1].minor.yy348 = OE_None; /* EV: R-33326-45252 */}
break;
case 53: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
-{yymsp[-2].minor.yy502 = 0;}
+{yymsp[-2].minor.yy348 = 0;}
break;
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;}
+{yymsp[-1].minor.yy348 = yymsp[0].minor.yy348;}
break;
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;}
+{yymsp[-1].minor.yy348 = 1;}
break;
case 57: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
-{yymsp[-1].minor.yy502 = 0;}
+{yymsp[-1].minor.yy348 = 0;}
break;
case 59: /* tconscomma ::= COMMA */
{pParse->constraintName.n = 0;}
break;
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);}
+{sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy402,yymsp[0].minor.yy348,yymsp[-2].minor.yy348,0);}
break;
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,
+{sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy402,yymsp[0].minor.yy348,0,0,0,0,
SQLITE_IDXTYPE_UNIQUE);}
break;
case 63: /* tcons ::= CHECK LP expr RP onconf */
-{sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy182);}
+{sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy2);}
break;
case 64: /* tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
{
- sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy232, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy232, yymsp[-1].minor.yy502);
- sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy502);
+ sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy402, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy402, yymsp[-1].minor.yy348);
+ sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy348);
}
break;
case 66: /* onconf ::= */
case 68: /* orconf ::= */ yytestcase(yyruleno==68);
-{yymsp[1].minor.yy502 = OE_Default;}
+{yymsp[1].minor.yy348 = OE_Default;}
break;
case 67: /* onconf ::= ON CONFLICT resolvetype */
-{yymsp[-2].minor.yy502 = yymsp[0].minor.yy502;}
+{yymsp[-2].minor.yy348 = yymsp[0].minor.yy348;}
break;
case 70: /* resolvetype ::= IGNORE */
-{yymsp[0].minor.yy502 = OE_Ignore;}
+{yymsp[0].minor.yy348 = OE_Ignore;}
break;
case 71: /* resolvetype ::= REPLACE */
case 154: /* insert_cmd ::= REPLACE */ yytestcase(yyruleno==154);
-{yymsp[0].minor.yy502 = OE_Replace;}
+{yymsp[0].minor.yy348 = OE_Replace;}
break;
case 72: /* cmd ::= DROP TABLE ifexists fullname */
{
- sqlite3DropTable(pParse, yymsp[0].minor.yy427, 0, yymsp[-1].minor.yy502);
+ sqlite3DropTable(pParse, yymsp[0].minor.yy3, 0, yymsp[-1].minor.yy348);
}
break;
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.yy232, yymsp[0].minor.yy399, yymsp[-7].minor.yy502, yymsp[-5].minor.yy502);
+ 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);
}
break;
case 76: /* cmd ::= DROP VIEW ifexists fullname */
{
- sqlite3DropTable(pParse, yymsp[0].minor.yy427, 1, yymsp[-1].minor.yy502);
+ sqlite3DropTable(pParse, yymsp[0].minor.yy3, 1, yymsp[-1].minor.yy348);
}
break;
case 77: /* cmd ::= select */
{
SelectDest dest = {SRT_Output, 0, 0, 0, 0, 0};
- sqlite3Select(pParse, yymsp[0].minor.yy399, &dest);
- sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy399);
+ sqlite3Select(pParse, yymsp[0].minor.yy43, &dest);
+ sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy43);
}
break;
case 78: /* select ::= WITH wqlist selectnowith */
{
- Select *p = yymsp[0].minor.yy399;
+ Select *p = yymsp[0].minor.yy43;
if( p ){
- p->pWith = yymsp[-1].minor.yy91;
+ p->pWith = yymsp[-1].minor.yy4;
parserDoubleLinkSelect(pParse, p);
}else{
- sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy91);
+ sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy4);
}
- yymsp[-2].minor.yy399 = p;
+ yymsp[-2].minor.yy43 = p;
}
break;
case 79: /* select ::= WITH RECURSIVE wqlist selectnowith */
{
- Select *p = yymsp[0].minor.yy399;
+ Select *p = yymsp[0].minor.yy43;
if( p ){
- p->pWith = yymsp[-1].minor.yy91;
+ p->pWith = yymsp[-1].minor.yy4;
parserDoubleLinkSelect(pParse, p);
}else{
- sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy91);
+ sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy4);
}
- yymsp[-3].minor.yy399 = p;
+ yymsp[-3].minor.yy43 = p;
}
break;
case 80: /* select ::= selectnowith */
{
- Select *p = yymsp[0].minor.yy399;
+ Select *p = yymsp[0].minor.yy43;
if( p ){
parserDoubleLinkSelect(pParse, p);
}
- yymsp[0].minor.yy399 = p; /*A-overwrites-X*/
+ yymsp[0].minor.yy43 = p; /*A-overwrites-X*/
}
break;
case 81: /* selectnowith ::= selectnowith multiselect_op oneselect */
{
- Select *pRhs = yymsp[0].minor.yy399;
- Select *pLhs = yymsp[-2].minor.yy399;
+ Select *pRhs = yymsp[0].minor.yy43;
+ Select *pLhs = yymsp[-2].minor.yy43;
if( pRhs && pRhs->pPrior ){
SrcList *pFrom;
Token x;
@@ -149793,53 +150591,53 @@ static YYACTIONTYPE yy_reduce(
pRhs = sqlite3SelectNew(pParse,0,pFrom,0,0,0,0,0,0);
}
if( pRhs ){
- pRhs->op = (u8)yymsp[-1].minor.yy502;
+ pRhs->op = (u8)yymsp[-1].minor.yy348;
pRhs->pPrior = pLhs;
if( ALWAYS(pLhs) ) pLhs->selFlags &= ~SF_MultiValue;
pRhs->selFlags &= ~SF_MultiValue;
- if( yymsp[-1].minor.yy502!=TK_ALL ) pParse->hasCompound = 1;
+ if( yymsp[-1].minor.yy348!=TK_ALL ) pParse->hasCompound = 1;
}else{
sqlite3SelectDelete(pParse->db, pLhs);
}
- yymsp[-2].minor.yy399 = pRhs;
+ yymsp[-2].minor.yy43 = pRhs;
}
break;
case 82: /* multiselect_op ::= UNION */
case 84: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==84);
-{yymsp[0].minor.yy502 = yymsp[0].major; /*A-overwrites-OP*/}
+{yymsp[0].minor.yy348 = yymsp[0].major; /*A-overwrites-OP*/}
break;
case 83: /* multiselect_op ::= UNION ALL */
-{yymsp[-1].minor.yy502 = TK_ALL;}
+{yymsp[-1].minor.yy348 = TK_ALL;}
break;
case 85: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
{
- 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);
+ 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);
}
break;
case 86: /* values ::= VALUES LP nexprlist RP */
{
- yymsp[-3].minor.yy399 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy232,0,0,0,0,0,SF_Values,0);
+ yymsp[-3].minor.yy43 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy402,0,0,0,0,0,SF_Values,0);
}
break;
case 87: /* values ::= values COMMA LP nexprlist RP */
{
- Select *pRight, *pLeft = yymsp[-4].minor.yy399;
- pRight = sqlite3SelectNew(pParse,yymsp[-1].minor.yy232,0,0,0,0,0,SF_Values|SF_MultiValue,0);
+ Select *pRight, *pLeft = yymsp[-4].minor.yy43;
+ pRight = sqlite3SelectNew(pParse,yymsp[-1].minor.yy402,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.yy399 = pRight;
+ yymsp[-4].minor.yy43 = pRight;
}else{
- yymsp[-4].minor.yy399 = pLeft;
+ yymsp[-4].minor.yy43 = pLeft;
}
}
break;
case 88: /* distinct ::= DISTINCT */
-{yymsp[0].minor.yy502 = SF_Distinct;}
+{yymsp[0].minor.yy348 = SF_Distinct;}
break;
case 89: /* distinct ::= ALL */
-{yymsp[0].minor.yy502 = SF_All;}
+{yymsp[0].minor.yy348 = SF_All;}
break;
case 91: /* sclp ::= */
case 124: /* orderby_opt ::= */ yytestcase(yyruleno==124);
@@ -149847,19 +150645,19 @@ static YYACTIONTYPE yy_reduce(
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;}
+{yymsp[1].minor.yy402 = 0;}
break;
case 92: /* selcollist ::= sclp scanpt expr scanpt as */
{
- 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);
+ 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);
}
break;
case 93: /* selcollist ::= sclp scanpt STAR */
{
Expr *p = sqlite3Expr(pParse->db, TK_ASTERISK, 0);
- yymsp[-2].minor.yy232 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy232, p);
+ yymsp[-2].minor.yy402 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy402, p);
}
break;
case 94: /* selcollist ::= sclp scanpt nm DOT STAR */
@@ -149867,70 +150665,76 @@ static YYACTIONTYPE yy_reduce(
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.yy232 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy232, pDot);
+ yymsp[-4].minor.yy402 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy402, pDot);
}
break;
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);
+ case 233: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==233);
+ case 234: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==234);
{yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;}
break;
case 97: /* from ::= */
-{yymsp[1].minor.yy427 = sqlite3DbMallocZero(pParse->db, sizeof(*yymsp[1].minor.yy427));}
+{yymsp[1].minor.yy3 = sqlite3DbMallocZero(pParse->db, sizeof(*yymsp[1].minor.yy3));}
break;
case 98: /* from ::= FROM seltablist */
{
- yymsp[-1].minor.yy427 = yymsp[0].minor.yy427;
- sqlite3SrcListShiftJoinType(yymsp[-1].minor.yy427);
+ yymsp[-1].minor.yy3 = yymsp[0].minor.yy3;
+ sqlite3SrcListShiftJoinType(yymsp[-1].minor.yy3);
}
break;
case 99: /* stl_prefix ::= seltablist joinop */
{
- 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;
+ 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;
}
break;
case 100: /* stl_prefix ::= */
-{yymsp[1].minor.yy427 = 0;}
+{yymsp[1].minor.yy3 = 0;}
break;
case 101: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
{
- 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);
+ 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);
}
break;
case 102: /* seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
{
- 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);
+ 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);
}
break;
case 103: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */
{
- 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);
+ 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);
}
break;
case 104: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
{
- 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;
+ 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;
pNew->zName = pOld->zName;
pNew->zDatabase = pOld->zDatabase;
pNew->pSelect = pOld->pSelect;
+ if( pOld->fg.isTabFunc ){
+ pNew->u1.pFuncArg = pOld->u1.pFuncArg;
+ pOld->u1.pFuncArg = 0;
+ pOld->fg.isTabFunc = 0;
+ pNew->fg.isTabFunc = 1;
+ }
pOld->zName = pOld->zDatabase = 0;
pOld->pSelect = 0;
}
- sqlite3SrcListDelete(pParse->db, yymsp[-4].minor.yy427);
+ sqlite3SrcListDelete(pParse->db, yymsp[-4].minor.yy3);
}else{
Select *pSubquery;
- 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);
+ 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);
}
}
break;
@@ -149940,53 +150744,54 @@ static YYACTIONTYPE yy_reduce(
break;
case 107: /* fullname ::= nm */
{
- 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);
+ yylhsminor.yy3 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0);
+ if( IN_RENAME_OBJECT && yylhsminor.yy3 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy3->a[0].zName, &yymsp[0].minor.yy0);
}
- yymsp[0].minor.yy427 = yylhsminor.yy427;
+ yymsp[0].minor.yy3 = yylhsminor.yy3;
break;
case 108: /* fullname ::= nm DOT nm */
{
- 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);
+ yylhsminor.yy3 = sqlite3SrcListAppend(pParse,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);
}
- yymsp[-2].minor.yy427 = yylhsminor.yy427;
+ yymsp[-2].minor.yy3 = yylhsminor.yy3;
break;
case 109: /* xfullname ::= nm */
-{yymsp[0].minor.yy427 = sqlite3SrcListAppend(pParse->db,0,&yymsp[0].minor.yy0,0); /*A-overwrites-X*/}
+{yymsp[0].minor.yy3 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0); /*A-overwrites-X*/}
break;
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*/}
+{yymsp[-2].minor.yy3 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/}
break;
case 111: /* xfullname ::= nm DOT nm AS nm */
{
- 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);
+ yymsp[-4].minor.yy3 = sqlite3SrcListAppend(pParse,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);
}
break;
case 112: /* xfullname ::= nm AS nm */
{
- 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);
+ yymsp[-2].minor.yy3 = sqlite3SrcListAppend(pParse,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);
}
break;
case 113: /* joinop ::= COMMA|JOIN */
-{ yymsp[0].minor.yy502 = JT_INNER; }
+{ yymsp[0].minor.yy348 = JT_INNER; }
break;
case 114: /* joinop ::= JOIN_KW JOIN */
-{yymsp[-1].minor.yy502 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); /*X-overwrites-A*/}
+{yymsp[-1].minor.yy348 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); /*X-overwrites-A*/}
break;
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*/}
+{yymsp[-2].minor.yy348 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/}
break;
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*/}
+{yymsp[-3].minor.yy348 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/}
break;
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;}
+ case 226: /* vinto ::= INTO expr */ yytestcase(yyruleno==226);
+{yymsp[-1].minor.yy2 = yymsp[0].minor.yy2;}
break;
case 118: /* on_opt ::= */
case 133: /* having_opt ::= */ yytestcase(yyruleno==133);
@@ -149994,7 +150799,8 @@ static YYACTIONTYPE yy_reduce(
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;}
+ case 227: /* vinto ::= */ yytestcase(yyruleno==227);
+{yymsp[1].minor.yy2 = 0;}
break;
case 120: /* indexed_opt ::= INDEXED BY nm */
{yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;}
@@ -150003,119 +150809,119 @@ static YYACTIONTYPE yy_reduce(
{yymsp[-1].minor.yy0.z=0; yymsp[-1].minor.yy0.n=1;}
break;
case 122: /* using_opt ::= USING LP idlist RP */
-{yymsp[-3].minor.yy510 = yymsp[-1].minor.yy510;}
+{yymsp[-3].minor.yy272 = yymsp[-1].minor.yy272;}
break;
case 123: /* using_opt ::= */
case 155: /* idlist_opt ::= */ yytestcase(yyruleno==155);
-{yymsp[1].minor.yy510 = 0;}
+{yymsp[1].minor.yy272 = 0;}
break;
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;}
+{yymsp[-2].minor.yy402 = yymsp[0].minor.yy402;}
break;
case 126: /* sortlist ::= sortlist COMMA expr sortorder */
{
- yymsp[-3].minor.yy232 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy232,yymsp[-1].minor.yy182);
- sqlite3ExprListSetSortOrder(yymsp[-3].minor.yy232,yymsp[0].minor.yy502);
+ yymsp[-3].minor.yy402 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy402,yymsp[-1].minor.yy2);
+ sqlite3ExprListSetSortOrder(yymsp[-3].minor.yy402,yymsp[0].minor.yy348);
}
break;
case 127: /* sortlist ::= expr sortorder */
{
- yymsp[-1].minor.yy232 = sqlite3ExprListAppend(pParse,0,yymsp[-1].minor.yy182); /*A-overwrites-Y*/
- sqlite3ExprListSetSortOrder(yymsp[-1].minor.yy232,yymsp[0].minor.yy502);
+ yymsp[-1].minor.yy402 = sqlite3ExprListAppend(pParse,0,yymsp[-1].minor.yy2); /*A-overwrites-Y*/
+ sqlite3ExprListSetSortOrder(yymsp[-1].minor.yy402,yymsp[0].minor.yy348);
}
break;
case 128: /* sortorder ::= ASC */
-{yymsp[0].minor.yy502 = SQLITE_SO_ASC;}
+{yymsp[0].minor.yy348 = SQLITE_SO_ASC;}
break;
case 129: /* sortorder ::= DESC */
-{yymsp[0].minor.yy502 = SQLITE_SO_DESC;}
+{yymsp[0].minor.yy348 = SQLITE_SO_DESC;}
break;
case 130: /* sortorder ::= */
-{yymsp[1].minor.yy502 = SQLITE_SO_UNDEFINED;}
+{yymsp[1].minor.yy348 = SQLITE_SO_UNDEFINED;}
break;
case 136: /* limit_opt ::= LIMIT expr */
-{yymsp[-1].minor.yy182 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy182,0);}
+{yymsp[-1].minor.yy2 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy2,0);}
break;
case 137: /* limit_opt ::= LIMIT expr OFFSET expr */
-{yymsp[-3].minor.yy182 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[-2].minor.yy182,yymsp[0].minor.yy182);}
+{yymsp[-3].minor.yy2 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[-2].minor.yy2,yymsp[0].minor.yy2);}
break;
case 138: /* limit_opt ::= LIMIT expr COMMA expr */
-{yymsp[-3].minor.yy182 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy182,yymsp[-2].minor.yy182);}
+{yymsp[-3].minor.yy2 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy2,yymsp[-2].minor.yy2);}
break;
case 139: /* cmd ::= with DELETE FROM xfullname indexed_opt where_opt */
{
- sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy427, &yymsp[-1].minor.yy0);
- sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy427,yymsp[0].minor.yy182,0,0);
+ sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy3, &yymsp[-1].minor.yy0);
+ sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy3,yymsp[0].minor.yy2,0,0);
}
break;
case 142: /* cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist where_opt */
{
- 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);
+ 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);
}
break;
case 143: /* setlist ::= setlist COMMA nm EQ expr */
{
- 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);
+ 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);
}
break;
case 144: /* setlist ::= setlist COMMA LP idlist RP EQ expr */
{
- yymsp[-6].minor.yy232 = sqlite3ExprListAppendVector(pParse, yymsp[-6].minor.yy232, yymsp[-3].minor.yy510, yymsp[0].minor.yy182);
+ yymsp[-6].minor.yy402 = sqlite3ExprListAppendVector(pParse, yymsp[-6].minor.yy402, yymsp[-3].minor.yy272, yymsp[0].minor.yy2);
}
break;
case 145: /* setlist ::= nm EQ expr */
{
- yylhsminor.yy232 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy182);
- sqlite3ExprListSetName(pParse, yylhsminor.yy232, &yymsp[-2].minor.yy0, 1);
+ yylhsminor.yy402 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy2);
+ sqlite3ExprListSetName(pParse, yylhsminor.yy402, &yymsp[-2].minor.yy0, 1);
}
- yymsp[-2].minor.yy232 = yylhsminor.yy232;
+ yymsp[-2].minor.yy402 = yylhsminor.yy402;
break;
case 146: /* setlist ::= LP idlist RP EQ expr */
{
- yymsp[-4].minor.yy232 = sqlite3ExprListAppendVector(pParse, 0, yymsp[-3].minor.yy510, yymsp[0].minor.yy182);
+ yymsp[-4].minor.yy402 = sqlite3ExprListAppendVector(pParse, 0, yymsp[-3].minor.yy272, yymsp[0].minor.yy2);
}
break;
case 147: /* cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
{
- sqlite3Insert(pParse, yymsp[-3].minor.yy427, yymsp[-1].minor.yy399, yymsp[-2].minor.yy510, yymsp[-5].minor.yy502, yymsp[0].minor.yy198);
+ sqlite3Insert(pParse, yymsp[-3].minor.yy3, yymsp[-1].minor.yy43, yymsp[-2].minor.yy272, yymsp[-5].minor.yy348, yymsp[0].minor.yy258);
}
break;
case 148: /* cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES */
{
- sqlite3Insert(pParse, yymsp[-3].minor.yy427, 0, yymsp[-2].minor.yy510, yymsp[-5].minor.yy502, 0);
+ sqlite3Insert(pParse, yymsp[-3].minor.yy3, 0, yymsp[-2].minor.yy272, yymsp[-5].minor.yy348, 0);
}
break;
case 149: /* upsert ::= */
-{ yymsp[1].minor.yy198 = 0; }
+{ yymsp[1].minor.yy258 = 0; }
break;
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);}
+{ yymsp[-10].minor.yy258 = sqlite3UpsertNew(pParse->db,yymsp[-7].minor.yy402,yymsp[-5].minor.yy2,yymsp[-1].minor.yy402,yymsp[0].minor.yy2);}
break;
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); }
+{ yymsp[-7].minor.yy258 = sqlite3UpsertNew(pParse->db,yymsp[-4].minor.yy402,yymsp[-2].minor.yy2,0,0); }
break;
case 152: /* upsert ::= ON CONFLICT DO NOTHING */
-{ yymsp[-3].minor.yy198 = sqlite3UpsertNew(pParse->db,0,0,0,0); }
+{ yymsp[-3].minor.yy258 = sqlite3UpsertNew(pParse->db,0,0,0,0); }
break;
case 156: /* idlist_opt ::= LP idlist RP */
-{yymsp[-2].minor.yy510 = yymsp[-1].minor.yy510;}
+{yymsp[-2].minor.yy272 = yymsp[-1].minor.yy272;}
break;
case 157: /* idlist ::= idlist COMMA nm */
-{yymsp[-2].minor.yy510 = sqlite3IdListAppend(pParse,yymsp[-2].minor.yy510,&yymsp[0].minor.yy0);}
+{yymsp[-2].minor.yy272 = sqlite3IdListAppend(pParse,yymsp[-2].minor.yy272,&yymsp[0].minor.yy0);}
break;
case 158: /* idlist ::= nm */
-{yymsp[0].minor.yy510 = sqlite3IdListAppend(pParse,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/}
+{yymsp[0].minor.yy272 = sqlite3IdListAppend(pParse,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/}
break;
case 159: /* expr ::= LP expr RP */
-{yymsp[-2].minor.yy182 = yymsp[-1].minor.yy182;}
+{yymsp[-2].minor.yy2 = yymsp[-1].minor.yy2;}
break;
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*/}
+{yymsp[0].minor.yy2=tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/}
break;
case 162: /* expr ::= nm DOT nm */
{
@@ -150125,9 +150931,9 @@ static YYACTIONTYPE yy_reduce(
sqlite3RenameTokenMap(pParse, (void*)temp2, &yymsp[0].minor.yy0);
sqlite3RenameTokenMap(pParse, (void*)temp1, &yymsp[-2].minor.yy0);
}
- yylhsminor.yy182 = sqlite3PExpr(pParse, TK_DOT, temp1, temp2);
+ yylhsminor.yy2 = sqlite3PExpr(pParse, TK_DOT, temp1, temp2);
}
- yymsp[-2].minor.yy182 = yylhsminor.yy182;
+ yymsp[-2].minor.yy2 = yylhsminor.yy2;
break;
case 163: /* expr ::= nm DOT nm DOT nm */
{
@@ -150139,26 +150945,26 @@ static YYACTIONTYPE yy_reduce(
sqlite3RenameTokenMap(pParse, (void*)temp3, &yymsp[0].minor.yy0);
sqlite3RenameTokenMap(pParse, (void*)temp2, &yymsp[-2].minor.yy0);
}
- yylhsminor.yy182 = sqlite3PExpr(pParse, TK_DOT, temp1, temp4);
+ yylhsminor.yy2 = sqlite3PExpr(pParse, TK_DOT, temp1, temp4);
}
- yymsp[-4].minor.yy182 = yylhsminor.yy182;
+ yymsp[-4].minor.yy2 = yylhsminor.yy2;
break;
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*/}
+{yymsp[0].minor.yy2=tokenExpr(pParse,yymsp[0].major,yymsp[0].minor.yy0); /*A-overwrites-X*/}
break;
case 166: /* term ::= INTEGER */
{
- yylhsminor.yy182 = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &yymsp[0].minor.yy0, 1);
+ yylhsminor.yy2 = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &yymsp[0].minor.yy0, 1);
}
- yymsp[0].minor.yy182 = yylhsminor.yy182;
+ yymsp[0].minor.yy2 = yylhsminor.yy2;
break;
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.yy182 = tokenExpr(pParse, TK_VARIABLE, yymsp[0].minor.yy0);
- sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy182, n);
+ yymsp[0].minor.yy2 = tokenExpr(pParse, TK_VARIABLE, yymsp[0].minor.yy0);
+ sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy2, 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
@@ -150167,49 +150973,49 @@ static YYACTIONTYPE yy_reduce(
assert( t.n>=2 );
if( pParse->nested==0 ){
sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", &t);
- yymsp[0].minor.yy182 = 0;
+ yymsp[0].minor.yy2 = 0;
}else{
- yymsp[0].minor.yy182 = sqlite3PExpr(pParse, TK_REGISTER, 0, 0);
- if( yymsp[0].minor.yy182 ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy182->iTable);
+ yymsp[0].minor.yy2 = sqlite3PExpr(pParse, TK_REGISTER, 0, 0);
+ if( yymsp[0].minor.yy2 ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy2->iTable);
}
}
}
break;
case 168: /* expr ::= expr COLLATE ID|STRING */
{
- yymsp[-2].minor.yy182 = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy182, &yymsp[0].minor.yy0, 1);
+ yymsp[-2].minor.yy2 = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy2, &yymsp[0].minor.yy0, 1);
}
break;
case 169: /* expr ::= CAST LP expr AS typetoken RP */
{
- 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);
+ 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);
}
break;
case 170: /* expr ::= ID|INDEXED LP distinct exprlist RP */
{
- yylhsminor.yy182 = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy232, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy502);
+ yylhsminor.yy2 = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy402, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy348);
}
- yymsp[-4].minor.yy182 = yylhsminor.yy182;
+ yymsp[-4].minor.yy2 = yylhsminor.yy2;
break;
case 171: /* expr ::= ID|INDEXED LP STAR RP */
{
- yylhsminor.yy182 = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0, 0);
+ yylhsminor.yy2 = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0, 0);
}
- yymsp[-3].minor.yy182 = yylhsminor.yy182;
+ yymsp[-3].minor.yy2 = yylhsminor.yy2;
break;
case 172: /* term ::= CTIME_KW */
{
- yylhsminor.yy182 = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0, 0);
+ yylhsminor.yy2 = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0, 0);
}
- yymsp[0].minor.yy182 = yylhsminor.yy182;
+ yymsp[0].minor.yy2 = yylhsminor.yy2;
break;
case 173: /* expr ::= LP nexprlist COMMA expr RP */
{
- 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;
+ 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;
}else{
sqlite3ExprListDelete(pParse->db, pList);
}
@@ -150223,7 +151029,7 @@ static YYACTIONTYPE yy_reduce(
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);}
+{yymsp[-2].minor.yy2=sqlite3PExpr(pParse,yymsp[-1].major,yymsp[-2].minor.yy2,yymsp[0].minor.yy2);}
break;
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*/}
@@ -150233,11 +151039,11 @@ static YYACTIONTYPE yy_reduce(
ExprList *pList;
int bNot = yymsp[-1].minor.yy0.n & 0x80000000;
yymsp[-1].minor.yy0.n &= 0x7fffffff;
- 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;
+ 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;
}
break;
case 184: /* expr ::= expr likeop expr ESCAPE expr */
@@ -150245,62 +151051,62 @@ static YYACTIONTYPE yy_reduce(
ExprList *pList;
int bNot = yymsp[-3].minor.yy0.n & 0x80000000;
yymsp[-3].minor.yy0.n &= 0x7fffffff;
- 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;
+ 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;
}
break;
case 185: /* expr ::= expr ISNULL|NOTNULL */
-{yymsp[-1].minor.yy182 = sqlite3PExpr(pParse,yymsp[0].major,yymsp[-1].minor.yy182,0);}
+{yymsp[-1].minor.yy2 = sqlite3PExpr(pParse,yymsp[0].major,yymsp[-1].minor.yy2,0);}
break;
case 186: /* expr ::= expr NOT NULL */
-{yymsp[-2].minor.yy182 = sqlite3PExpr(pParse,TK_NOTNULL,yymsp[-2].minor.yy182,0);}
+{yymsp[-2].minor.yy2 = sqlite3PExpr(pParse,TK_NOTNULL,yymsp[-2].minor.yy2,0);}
break;
case 187: /* expr ::= expr IS expr */
{
- 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);
+ 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);
}
break;
case 188: /* expr ::= expr IS NOT expr */
{
- 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);
+ 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);
}
break;
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*/}
+{yymsp[-1].minor.yy2 = sqlite3PExpr(pParse, yymsp[-1].major, yymsp[0].minor.yy2, 0);/*A-overwrites-B*/}
break;
case 191: /* expr ::= PLUS|MINUS expr */
{
- yymsp[-1].minor.yy182 = sqlite3PExpr(pParse, yymsp[-1].major==TK_PLUS ? TK_UPLUS : TK_UMINUS, yymsp[0].minor.yy182, 0);
+ yymsp[-1].minor.yy2 = sqlite3PExpr(pParse, yymsp[-1].major==TK_PLUS ? TK_UPLUS : TK_UMINUS, yymsp[0].minor.yy2, 0);
/*A-overwrites-B*/
}
break;
case 192: /* between_op ::= BETWEEN */
case 195: /* in_op ::= IN */ yytestcase(yyruleno==195);
-{yymsp[0].minor.yy502 = 0;}
+{yymsp[0].minor.yy348 = 0;}
break;
case 194: /* expr ::= expr between_op expr AND expr */
{
- 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;
+ 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;
}else{
sqlite3ExprListDelete(pParse->db, pList);
}
- if( yymsp[-3].minor.yy502 ) yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy182, 0);
+ if( yymsp[-3].minor.yy348 ) yymsp[-4].minor.yy2 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy2, 0);
}
break;
case 197: /* expr ::= expr in_op LP exprlist RP */
{
- if( yymsp[-1].minor.yy232==0 ){
+ if( yymsp[-1].minor.yy402==0 ){
/* Expressions of the form
**
** expr1 IN ()
@@ -150309,9 +151115,11 @@ 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.yy182);
- yymsp[-4].minor.yy182 = sqlite3ExprAlloc(pParse->db, TK_INTEGER,&sqlite3IntTokens[yymsp[-3].minor.yy502],1);
- }else if( yymsp[-1].minor.yy232->nExpr==1 ){
+ if( IN_RENAME_OBJECT==0 ){
+ 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 ){
/* Expressions of the form:
**
** expr1 IN (?1)
@@ -150328,198 +151136,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.yy232->a[0].pExpr;
- yymsp[-1].minor.yy232->a[0].pExpr = 0;
- sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy232);
+ Expr *pRHS = yymsp[-1].minor.yy402->a[0].pExpr;
+ yymsp[-1].minor.yy402->a[0].pExpr = 0;
+ sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy402);
/* 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.yy182 = sqlite3PExpr(pParse, yymsp[-3].minor.yy502 ? TK_NE : TK_EQ, yymsp[-4].minor.yy182, pRHS);
+ yymsp[-4].minor.yy2 = sqlite3PExpr(pParse, yymsp[-3].minor.yy348 ? TK_NE : TK_EQ, yymsp[-4].minor.yy2, pRHS);
}else{
- 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);
+ 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);
}else{
- sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy232);
+ sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy402);
}
- if( yymsp[-3].minor.yy502 ) yymsp[-4].minor.yy182 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy182, 0);
+ if( yymsp[-3].minor.yy348 ) yymsp[-4].minor.yy2 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy2, 0);
}
}
break;
case 198: /* expr ::= LP select RP */
{
- yymsp[-2].minor.yy182 = sqlite3PExpr(pParse, TK_SELECT, 0, 0);
- sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy182, yymsp[-1].minor.yy399);
+ yymsp[-2].minor.yy2 = sqlite3PExpr(pParse, TK_SELECT, 0, 0);
+ sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy2, yymsp[-1].minor.yy43);
}
break;
case 199: /* expr ::= expr in_op LP select RP */
{
- 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);
+ 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);
}
break;
case 200: /* expr ::= expr in_op nm dbnm paren_exprlist */
{
- SrcList *pSrc = sqlite3SrcListAppend(pParse->db, 0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);
+ SrcList *pSrc = sqlite3SrcListAppend(pParse, 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.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);
+ 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);
}
break;
case 201: /* expr ::= EXISTS LP select RP */
{
Expr *p;
- p = yymsp[-3].minor.yy182 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0);
- sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy399);
+ p = yymsp[-3].minor.yy2 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0);
+ sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy43);
}
break;
case 202: /* expr ::= CASE case_operand case_exprlist case_else END */
{
- 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);
+ 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);
}else{
- sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy232);
- sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy182);
+ sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy402);
+ sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy2);
}
}
break;
case 203: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
{
- 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);
+ 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);
}
break;
case 204: /* case_exprlist ::= WHEN expr THEN expr */
{
- 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);
+ 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);
}
break;
case 207: /* case_operand ::= expr */
-{yymsp[0].minor.yy182 = yymsp[0].minor.yy182; /*A-overwrites-X*/}
+{yymsp[0].minor.yy2 = yymsp[0].minor.yy2; /*A-overwrites-X*/}
break;
case 210: /* nexprlist ::= nexprlist COMMA expr */
-{yymsp[-2].minor.yy232 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy232,yymsp[0].minor.yy182);}
+{yymsp[-2].minor.yy402 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy402,yymsp[0].minor.yy2);}
break;
case 211: /* nexprlist ::= expr */
-{yymsp[0].minor.yy232 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy182); /*A-overwrites-Y*/}
+{yymsp[0].minor.yy402 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy2); /*A-overwrites-Y*/}
break;
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;}
+{yymsp[-2].minor.yy402 = yymsp[-1].minor.yy402;}
break;
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.yy232, yymsp[-10].minor.yy502,
- &yymsp[-11].minor.yy0, yymsp[0].minor.yy182, SQLITE_SO_ASC, yymsp[-8].minor.yy502, SQLITE_IDXTYPE_APPDEF);
+ sqlite3SrcListAppend(pParse,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);
if( IN_RENAME_OBJECT && pParse->pNewIndex ){
sqlite3RenameTokenMap(pParse, pParse->pNewIndex->zName, &yymsp[-4].minor.yy0);
}
}
break;
case 215: /* uniqueflag ::= UNIQUE */
- case 255: /* raisetype ::= ABORT */ yytestcase(yyruleno==255);
-{yymsp[0].minor.yy502 = OE_Abort;}
+ case 257: /* raisetype ::= ABORT */ yytestcase(yyruleno==257);
+{yymsp[0].minor.yy348 = OE_Abort;}
break;
case 216: /* uniqueflag ::= */
-{yymsp[1].minor.yy502 = OE_None;}
+{yymsp[1].minor.yy348 = OE_None;}
break;
case 219: /* eidlist ::= eidlist COMMA nm collate sortorder */
{
- yymsp[-4].minor.yy232 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy232, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy502, yymsp[0].minor.yy502);
+ yymsp[-4].minor.yy402 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy402, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy348, yymsp[0].minor.yy348);
}
break;
case 220: /* eidlist ::= nm collate sortorder */
{
- yymsp[-2].minor.yy232 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy502, yymsp[0].minor.yy502); /*A-overwrites-Y*/
+ yymsp[-2].minor.yy402 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy348, yymsp[0].minor.yy348); /*A-overwrites-Y*/
}
break;
case 223: /* cmd ::= DROP INDEX ifexists fullname */
-{sqlite3DropIndex(pParse, yymsp[0].minor.yy427, yymsp[-1].minor.yy502);}
+{sqlite3DropIndex(pParse, yymsp[0].minor.yy3, yymsp[-1].minor.yy348);}
break;
- case 224: /* cmd ::= VACUUM */
-{sqlite3Vacuum(pParse,0);}
+ case 224: /* cmd ::= VACUUM vinto */
+{sqlite3Vacuum(pParse,0,yymsp[0].minor.yy2);}
break;
- case 225: /* cmd ::= VACUUM nm */
-{sqlite3Vacuum(pParse,&yymsp[0].minor.yy0);}
+ case 225: /* cmd ::= VACUUM nm vinto */
+{sqlite3Vacuum(pParse,&yymsp[-1].minor.yy0,yymsp[0].minor.yy2);}
break;
- case 226: /* cmd ::= PRAGMA nm dbnm */
+ case 228: /* cmd ::= PRAGMA nm dbnm */
{sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);}
break;
- case 227: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
+ case 229: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
{sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);}
break;
- case 228: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
+ case 230: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
{sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);}
break;
- case 229: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
+ case 231: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
{sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);}
break;
- case 230: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */
+ case 232: /* 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 233: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
+ case 235: /* 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.yy47, &all);
+ sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy347, &all);
}
break;
- case 234: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
+ case 236: /* 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.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);
+ 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);
yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/
}
break;
- case 235: /* trigger_time ::= BEFORE|AFTER */
-{ yymsp[0].minor.yy502 = yymsp[0].major; /*A-overwrites-X*/ }
+ case 237: /* trigger_time ::= BEFORE|AFTER */
+{ yymsp[0].minor.yy348 = yymsp[0].major; /*A-overwrites-X*/ }
break;
- case 236: /* trigger_time ::= INSTEAD OF */
-{ yymsp[-1].minor.yy502 = TK_INSTEAD;}
+ case 238: /* trigger_time ::= INSTEAD OF */
+{ yymsp[-1].minor.yy348 = TK_INSTEAD;}
break;
- case 237: /* trigger_time ::= */
-{ yymsp[1].minor.yy502 = TK_BEFORE; }
+ case 239: /* trigger_time ::= */
+{ yymsp[1].minor.yy348 = TK_BEFORE; }
break;
- 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;}
+ 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;}
break;
- case 240: /* trigger_event ::= UPDATE OF idlist */
-{yymsp[-2].minor.yy300.a = TK_UPDATE; yymsp[-2].minor.yy300.b = yymsp[0].minor.yy510;}
+ case 242: /* trigger_event ::= UPDATE OF idlist */
+{yymsp[-2].minor.yy338.a = TK_UPDATE; yymsp[-2].minor.yy338.b = yymsp[0].minor.yy272;}
break;
- case 241: /* when_clause ::= */
- case 260: /* key_opt ::= */ yytestcase(yyruleno==260);
-{ yymsp[1].minor.yy182 = 0; }
+ case 243: /* when_clause ::= */
+ case 262: /* key_opt ::= */ yytestcase(yyruleno==262);
+{ yymsp[1].minor.yy2 = 0; }
break;
- case 242: /* when_clause ::= WHEN expr */
- case 261: /* key_opt ::= KEY expr */ yytestcase(yyruleno==261);
-{ yymsp[-1].minor.yy182 = yymsp[0].minor.yy182; }
+ case 244: /* when_clause ::= WHEN expr */
+ case 263: /* key_opt ::= KEY expr */ yytestcase(yyruleno==263);
+{ yymsp[-1].minor.yy2 = yymsp[0].minor.yy2; }
break;
- case 243: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
+ case 245: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
{
- 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;
+ 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;
}
break;
- case 244: /* trigger_cmd_list ::= trigger_cmd SEMI */
+ case 246: /* trigger_cmd_list ::= trigger_cmd SEMI */
{
- assert( yymsp[-1].minor.yy47!=0 );
- yymsp[-1].minor.yy47->pLast = yymsp[-1].minor.yy47;
+ assert( yymsp[-1].minor.yy347!=0 );
+ yymsp[-1].minor.yy347->pLast = yymsp[-1].minor.yy347;
}
break;
- case 245: /* trnm ::= nm DOT nm */
+ case 247: /* trnm ::= nm DOT nm */
{
yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;
sqlite3ErrorMsg(pParse,
@@ -150527,194 +151335,194 @@ static YYACTIONTYPE yy_reduce(
"statements within triggers");
}
break;
- case 246: /* tridxby ::= INDEXED BY nm */
+ case 248: /* tridxby ::= INDEXED BY nm */
{
sqlite3ErrorMsg(pParse,
"the INDEXED BY clause is not allowed on UPDATE or DELETE statements "
"within triggers");
}
break;
- case 247: /* tridxby ::= NOT INDEXED */
+ case 249: /* tridxby ::= NOT INDEXED */
{
sqlite3ErrorMsg(pParse,
"the NOT INDEXED clause is not allowed on UPDATE or DELETE statements "
"within triggers");
}
break;
- 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;
+ 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;
break;
- case 249: /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
+ case 251: /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
{
- 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*/
+ 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*/
}
- yymsp[-7].minor.yy47 = yylhsminor.yy47;
+ yymsp[-7].minor.yy347 = yylhsminor.yy347;
break;
- 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;
+ 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;
break;
- 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;
+ 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;
break;
- case 252: /* expr ::= RAISE LP IGNORE RP */
+ case 254: /* expr ::= RAISE LP IGNORE RP */
{
- yymsp[-3].minor.yy182 = sqlite3PExpr(pParse, TK_RAISE, 0, 0);
- if( yymsp[-3].minor.yy182 ){
- yymsp[-3].minor.yy182->affinity = OE_Ignore;
+ yymsp[-3].minor.yy2 = sqlite3PExpr(pParse, TK_RAISE, 0, 0);
+ if( yymsp[-3].minor.yy2 ){
+ yymsp[-3].minor.yy2->affinity = OE_Ignore;
}
}
break;
- case 253: /* expr ::= RAISE LP raisetype COMMA nm RP */
+ case 255: /* expr ::= RAISE LP raisetype COMMA nm RP */
{
- 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;
+ 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;
}
}
break;
- case 254: /* raisetype ::= ROLLBACK */
-{yymsp[0].minor.yy502 = OE_Rollback;}
+ case 256: /* raisetype ::= ROLLBACK */
+{yymsp[0].minor.yy348 = OE_Rollback;}
break;
- case 256: /* raisetype ::= FAIL */
-{yymsp[0].minor.yy502 = OE_Fail;}
+ case 258: /* raisetype ::= FAIL */
+{yymsp[0].minor.yy348 = OE_Fail;}
break;
- case 257: /* cmd ::= DROP TRIGGER ifexists fullname */
+ case 259: /* cmd ::= DROP TRIGGER ifexists fullname */
{
- sqlite3DropTrigger(pParse,yymsp[0].minor.yy427,yymsp[-1].minor.yy502);
+ sqlite3DropTrigger(pParse,yymsp[0].minor.yy3,yymsp[-1].minor.yy348);
}
break;
- case 258: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
+ case 260: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
{
- sqlite3Attach(pParse, yymsp[-3].minor.yy182, yymsp[-1].minor.yy182, yymsp[0].minor.yy182);
+ sqlite3Attach(pParse, yymsp[-3].minor.yy2, yymsp[-1].minor.yy2, yymsp[0].minor.yy2);
}
break;
- case 259: /* cmd ::= DETACH database_kw_opt expr */
+ case 261: /* cmd ::= DETACH database_kw_opt expr */
{
- sqlite3Detach(pParse, yymsp[0].minor.yy182);
+ sqlite3Detach(pParse, yymsp[0].minor.yy2);
}
break;
- case 262: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
+ case 264: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
{
- sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy427,&yymsp[0].minor.yy0);
+ sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy3,&yymsp[0].minor.yy0);
}
break;
- case 263: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
+ case 265: /* 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 264: /* add_column_fullname ::= fullname */
+ case 266: /* add_column_fullname ::= fullname */
{
disableLookaside(pParse);
- sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy427);
+ sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy3);
}
break;
- case 265: /* cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
+ case 267: /* cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
{
- sqlite3AlterRenameColumn(pParse, yymsp[-5].minor.yy427, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);
+ sqlite3AlterRenameColumn(pParse, yymsp[-5].minor.yy3, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);
}
break;
- case 266: /* cmd ::= create_vtab */
+ case 268: /* cmd ::= create_vtab */
{sqlite3VtabFinishParse(pParse,0);}
break;
- case 267: /* cmd ::= create_vtab LP vtabarglist RP */
+ case 269: /* cmd ::= create_vtab LP vtabarglist RP */
{sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}
break;
- case 268: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
+ case 270: /* 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.yy502);
+ sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy348);
}
break;
- case 269: /* vtabarg ::= */
+ case 271: /* vtabarg ::= */
{sqlite3VtabArgInit(pParse);}
break;
- case 270: /* vtabargtoken ::= ANY */
- case 271: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==271);
- case 272: /* lp ::= LP */ yytestcase(yyruleno==272);
+ case 272: /* vtabargtoken ::= ANY */
+ case 273: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==273);
+ case 274: /* lp ::= LP */ yytestcase(yyruleno==274);
{sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}
break;
- case 273: /* with ::= WITH wqlist */
- case 274: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==274);
-{ sqlite3WithPush(pParse, yymsp[0].minor.yy91, 1); }
+ case 275: /* with ::= WITH wqlist */
+ case 276: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==276);
+{ sqlite3WithPush(pParse, yymsp[0].minor.yy4, 1); }
break;
- case 275: /* wqlist ::= nm eidlist_opt AS LP select RP */
+ case 277: /* wqlist ::= nm eidlist_opt AS LP select RP */
{
- yymsp[-5].minor.yy91 = sqlite3WithAdd(pParse, 0, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy232, yymsp[-1].minor.yy399); /*A-overwrites-X*/
+ yymsp[-5].minor.yy4 = sqlite3WithAdd(pParse, 0, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy402, yymsp[-1].minor.yy43); /*A-overwrites-X*/
}
break;
- case 276: /* wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
+ case 278: /* wqlist ::= wqlist COMMA nm eidlist_opt AS LP select RP */
{
- yymsp[-7].minor.yy91 = sqlite3WithAdd(pParse, yymsp[-7].minor.yy91, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy232, yymsp[-1].minor.yy399);
+ yymsp[-7].minor.yy4 = sqlite3WithAdd(pParse, yymsp[-7].minor.yy4, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy402, yymsp[-1].minor.yy43);
}
break;
default:
- /* (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);
+ /* (279) input ::= cmdlist */ yytestcase(yyruleno==279);
+ /* (280) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==280);
+ /* (281) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=281);
+ /* (282) ecmd ::= SEMI */ yytestcase(yyruleno==282);
+ /* (283) ecmd ::= cmdx SEMI */ yytestcase(yyruleno==283);
+ /* (284) trans_opt ::= */ yytestcase(yyruleno==284);
+ /* (285) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==285);
+ /* (286) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==286);
+ /* (287) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==287);
+ /* (288) savepoint_opt ::= */ yytestcase(yyruleno==288);
+ /* (289) cmd ::= create_table create_table_args */ yytestcase(yyruleno==289);
+ /* (290) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==290);
+ /* (291) columnlist ::= columnname carglist */ yytestcase(yyruleno==291);
+ /* (292) nm ::= ID|INDEXED */ yytestcase(yyruleno==292);
+ /* (293) nm ::= STRING */ yytestcase(yyruleno==293);
+ /* (294) nm ::= JOIN_KW */ yytestcase(yyruleno==294);
+ /* (295) typetoken ::= typename */ yytestcase(yyruleno==295);
+ /* (296) typename ::= ID|STRING */ yytestcase(yyruleno==296);
+ /* (297) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=297);
+ /* (298) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=298);
+ /* (299) carglist ::= carglist ccons */ yytestcase(yyruleno==299);
+ /* (300) carglist ::= */ yytestcase(yyruleno==300);
+ /* (301) ccons ::= NULL onconf */ yytestcase(yyruleno==301);
+ /* (302) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==302);
+ /* (303) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==303);
+ /* (304) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=304);
+ /* (305) tconscomma ::= */ yytestcase(yyruleno==305);
+ /* (306) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=306);
+ /* (307) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=307);
+ /* (308) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=308);
+ /* (309) oneselect ::= values */ yytestcase(yyruleno==309);
+ /* (310) sclp ::= selcollist COMMA */ yytestcase(yyruleno==310);
+ /* (311) as ::= ID|STRING */ yytestcase(yyruleno==311);
+ /* (312) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=312);
+ /* (313) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==313);
+ /* (314) exprlist ::= nexprlist */ yytestcase(yyruleno==314);
+ /* (315) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=315);
+ /* (316) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=316);
+ /* (317) nmnum ::= ON */ yytestcase(yyruleno==317);
+ /* (318) nmnum ::= DELETE */ yytestcase(yyruleno==318);
+ /* (319) nmnum ::= DEFAULT */ yytestcase(yyruleno==319);
+ /* (320) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==320);
+ /* (321) foreach_clause ::= */ yytestcase(yyruleno==321);
+ /* (322) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==322);
+ /* (323) trnm ::= nm */ yytestcase(yyruleno==323);
+ /* (324) tridxby ::= */ yytestcase(yyruleno==324);
+ /* (325) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==325);
+ /* (326) database_kw_opt ::= */ yytestcase(yyruleno==326);
+ /* (327) kwcolumn_opt ::= */ yytestcase(yyruleno==327);
+ /* (328) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==328);
+ /* (329) vtabarglist ::= vtabarg */ yytestcase(yyruleno==329);
+ /* (330) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==330);
+ /* (331) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==331);
+ /* (332) anylist ::= */ yytestcase(yyruleno==332);
+ /* (333) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==333);
+ /* (334) anylist ::= anylist ANY */ yytestcase(yyruleno==334);
+ /* (335) with ::= */ yytestcase(yyruleno==335);
break;
/********** End reduce actions ************************************************/
};
- assert( yyruleno<sizeof(yyRuleInfo)/sizeof(yyRuleInfo[0]) );
- yygoto = yyRuleInfo[yyruleno].lhs;
- yysize = yyRuleInfo[yyruleno].nrhs;
+ assert( yyruleno<sizeof(yyRuleInfoLhs)/sizeof(yyRuleInfoLhs[0]) );
+ yygoto = yyRuleInfoLhs[yyruleno];
+ yysize = yyRuleInfoNRhs[yyruleno];
yyact = yy_find_reduce_action(yymsp[yysize].stateno,(YYCODETYPE)yygoto);
/* There are no SHIFTREDUCE actions on nonterminals because the table
@@ -151862,73 +152670,6 @@ SQLITE_PRIVATE int sqlite3GetToken(const unsigned char *z, int *tokenType){
return i;
}
-#ifdef SQLITE_ENABLE_NORMALIZE
-/*
-** Return the length (in bytes) of the token that begins at z[0].
-** Store the token type in *tokenType before returning. If flags has
-** SQLITE_TOKEN_NORMALIZE flag enabled, use the identifier token type
-** for keywords. Add SQLITE_TOKEN_QUOTED to flags if the token was
-** actually a quoted identifier. Add SQLITE_TOKEN_KEYWORD to flags
-** if the token was recognized as a keyword; this is useful when the
-** SQLITE_TOKEN_NORMALIZE flag is used, because it enables the caller
-** to differentiate between a keyword being treated as an identifier
-** (for normalization purposes) and an actual identifier.
-*/
-SQLITE_PRIVATE int sqlite3GetTokenNormalized(
- const unsigned char *z,
- int *tokenType,
- int *flags
-){
- int n;
- unsigned char iClass = aiClass[*z];
- if( iClass==CC_KYWD ){
- int i;
- for(i=1; aiClass[z[i]]<=CC_KYWD; i++){}
- if( IdChar(z[i]) ){
- /* This token started out using characters that can appear in keywords,
- ** but z[i] is a character not allowed within keywords, so this must
- ** be an identifier instead */
- i++;
- while( IdChar(z[i]) ){ i++; }
- *tokenType = TK_ID;
- return i;
- }
- *tokenType = TK_ID;
- n = keywordCode((char*)z, i, tokenType);
- /* If the token is no longer considered to be an identifier, then it is a
- ** keyword of some kind. Make the token back into an identifier and then
- ** set the SQLITE_TOKEN_KEYWORD flag. Several non-identifier tokens are
- ** used verbatim, including IN, IS, NOT, and NULL. */
- switch( *tokenType ){
- case TK_ID: {
- /* do nothing, handled by caller */
- break;
- }
- case TK_IN:
- case TK_IS:
- case TK_NOT:
- case TK_NULL: {
- *flags |= SQLITE_TOKEN_KEYWORD;
- break;
- }
- default: {
- *tokenType = TK_ID;
- *flags |= SQLITE_TOKEN_KEYWORD;
- break;
- }
- }
- }else{
- n = sqlite3GetToken(z, tokenType);
- /* If the token is considered to be an identifier and the character class
- ** of the first character is a quote, set the SQLITE_TOKEN_QUOTED flag. */
- if( *tokenType==TK_ID && (iClass==CC_QUOTE || iClass==CC_QUOTE2) ){
- *flags |= SQLITE_TOKEN_QUOTED;
- }
- }
- return n;
-}
-#endif /* SQLITE_ENABLE_NORMALIZE */
-
/*
** Run the parser on the given SQL string. The parser structure is
** passed in. An SQLITE_ status code is returned. If an error occurs
@@ -151956,7 +152697,14 @@ SQLITE_PRIVATE int sqlite3RunParser(Parse *pParse, const char *zSql, char **pzEr
pParse->rc = SQLITE_OK;
pParse->zTail = zSql;
assert( pzErrMsg!=0 );
- /* sqlite3ParserTrace(stdout, "parser: "); */
+#ifdef SQLITE_DEBUG
+ if( db->flags & SQLITE_ParserTrace ){
+ printf("parser: [[[%s]]]\n", zSql);
+ sqlite3ParserTrace(stdout, "parser: ");
+ }else{
+ sqlite3ParserTrace(0, 0);
+ }
+#endif
#ifdef sqlite3Parser_ENGINEALWAYSONSTACK
pEngine = &sEngine;
sqlite3ParserInit(pEngine, pParse);
@@ -152099,6 +152847,141 @@ SQLITE_PRIVATE int sqlite3RunParser(Parse *pParse, const char *zSql, char **pzEr
return nErr;
}
+
+#ifdef SQLITE_ENABLE_NORMALIZE
+/*
+** Insert a single space character into pStr if the current string
+** ends with an identifier
+*/
+static void addSpaceSeparator(sqlite3_str *pStr){
+ if( pStr->nChar && sqlite3IsIdChar(pStr->zText[pStr->nChar-1]) ){
+ sqlite3_str_append(pStr, " ", 1);
+ }
+}
+
+/*
+** Compute a normalization of the SQL given by zSql[0..nSql-1]. Return
+** the normalization in space obtained from sqlite3DbMalloc(). Or return
+** NULL if anything goes wrong or if zSql is NULL.
+*/
+SQLITE_PRIVATE char *sqlite3Normalize(
+ Vdbe *pVdbe, /* VM being reprepared */
+ const char *zSql /* The original SQL string */
+){
+ sqlite3 *db; /* The database connection */
+ int i; /* Next unread byte of zSql[] */
+ int n; /* length of current token */
+ int tokenType; /* type of current token */
+ int prevType = 0; /* Previous non-whitespace token */
+ int nParen; /* Number of nested levels of parentheses */
+ int iStartIN; /* Start of RHS of IN operator in z[] */
+ int nParenAtIN; /* Value of nParent at start of RHS of IN operator */
+ int j; /* Bytes of normalized SQL generated so far */
+ sqlite3_str *pStr; /* The normalized SQL string under construction */
+
+ db = sqlite3VdbeDb(pVdbe);
+ tokenType = -1;
+ nParen = iStartIN = nParenAtIN = 0;
+ pStr = sqlite3_str_new(db);
+ assert( pStr!=0 ); /* sqlite3_str_new() never returns NULL */
+ for(i=0; zSql[i] && pStr->accError==0; i+=n){
+ if( tokenType!=TK_SPACE ){
+ prevType = tokenType;
+ }
+ n = sqlite3GetToken((unsigned char*)zSql+i, &tokenType);
+ if( NEVER(n<=0) ) break;
+ switch( tokenType ){
+ case TK_SPACE: {
+ break;
+ }
+ case TK_NULL: {
+ if( prevType==TK_IS || prevType==TK_NOT ){
+ sqlite3_str_append(pStr, " NULL", 5);
+ break;
+ }
+ /* Fall through */
+ }
+ case TK_STRING:
+ case TK_INTEGER:
+ case TK_FLOAT:
+ case TK_VARIABLE:
+ case TK_BLOB: {
+ sqlite3_str_append(pStr, "?", 1);
+ break;
+ }
+ case TK_LP: {
+ nParen++;
+ if( prevType==TK_IN ){
+ iStartIN = pStr->nChar;
+ nParenAtIN = nParen;
+ }
+ sqlite3_str_append(pStr, "(", 1);
+ break;
+ }
+ case TK_RP: {
+ if( iStartIN>0 && nParen==nParenAtIN ){
+ assert( pStr->nChar>=iStartIN );
+ pStr->nChar = iStartIN+1;
+ sqlite3_str_append(pStr, "?,?,?", 5);
+ iStartIN = 0;
+ }
+ nParen--;
+ sqlite3_str_append(pStr, ")", 1);
+ break;
+ }
+ case TK_ID: {
+ iStartIN = 0;
+ j = pStr->nChar;
+ if( sqlite3Isquote(zSql[i]) ){
+ char *zId = sqlite3DbStrNDup(db, zSql+i, n);
+ int nId;
+ int eType = 0;
+ if( zId==0 ) break;
+ sqlite3Dequote(zId);
+ if( zSql[i]=='"' && sqlite3VdbeUsesDoubleQuotedString(pVdbe, zId) ){
+ sqlite3_str_append(pStr, "?", 1);
+ sqlite3DbFree(db, zId);
+ break;
+ }
+ nId = sqlite3Strlen30(zId);
+ if( sqlite3GetToken((u8*)zId, &eType)==nId && eType==TK_ID ){
+ addSpaceSeparator(pStr);
+ sqlite3_str_append(pStr, zId, nId);
+ }else{
+ sqlite3_str_appendf(pStr, "\"%w\"", zId);
+ }
+ sqlite3DbFree(db, zId);
+ }else{
+ addSpaceSeparator(pStr);
+ sqlite3_str_append(pStr, zSql+i, n);
+ }
+ while( j<pStr->nChar ){
+ pStr->zText[j] = sqlite3Tolower(pStr->zText[j]);
+ j++;
+ }
+ break;
+ }
+ case TK_SELECT: {
+ iStartIN = 0;
+ /* fall through */
+ }
+ default: {
+ if( sqlite3IsIdChar(zSql[i]) ) addSpaceSeparator(pStr);
+ j = pStr->nChar;
+ sqlite3_str_append(pStr, zSql+i, n);
+ while( j<pStr->nChar ){
+ pStr->zText[j] = sqlite3Toupper(pStr->zText[j]);
+ j++;
+ }
+ break;
+ }
+ }
+ }
+ if( tokenType!=TK_SEMI ) sqlite3_str_append(pStr, ";", 1);
+ return sqlite3_str_finish(pStr);
+}
+#endif /* SQLITE_ENABLE_NORMALIZE */
+
/************** End of tokenize.c ********************************************/
/************** Begin file complete.c ****************************************/
/*
@@ -153144,6 +154027,13 @@ SQLITE_API int sqlite3_config(int op, ...){
}
#endif /* SQLITE_ENABLE_SORTER_REFERENCES */
+#ifdef SQLITE_ENABLE_DESERIALIZE
+ case SQLITE_CONFIG_MEMDB_MAXSIZE: {
+ sqlite3GlobalConfig.mxMemdbSize = va_arg(ap, sqlite3_int64);
+ break;
+ }
+#endif /* SQLITE_ENABLE_DESERIALIZE */
+
default: {
rc = SQLITE_ERROR;
break;
@@ -153334,11 +154224,11 @@ SQLITE_API int sqlite3_db_config(sqlite3 *db, int op, ...){
if( aFlagOp[i].op==op ){
int onoff = va_arg(ap, int);
int *pRes = va_arg(ap, int*);
- u32 oldFlags = db->flags;
+ u64 oldFlags = db->flags;
if( onoff>0 ){
db->flags |= aFlagOp[i].mask;
}else if( onoff==0 ){
- db->flags &= ~aFlagOp[i].mask;
+ db->flags &= ~(u64)aFlagOp[i].mask;
}
if( oldFlags!=db->flags ){
sqlite3ExpirePreparedStatements(db, 0);
@@ -153801,7 +154691,7 @@ SQLITE_PRIVATE void sqlite3RollbackAll(sqlite3 *db, int tripCode){
/* Any deferred constraint violations have now been resolved. */
db->nDeferredCons = 0;
db->nDeferredImmCons = 0;
- db->flags &= ~SQLITE_DeferFKs;
+ db->flags &= ~(u64)SQLITE_DeferFKs;
/* If one has been configured, invoke the rollback-hook callback */
if( db->xRollbackCallback && (inTrans || !db->autoCommit) ){
@@ -154543,6 +155433,8 @@ SQLITE_API void *sqlite3_profile(
pOld = db->pProfileArg;
db->xProfile = xProfile;
db->pProfileArg = pArg;
+ db->mTrace &= SQLITE_TRACE_NONLEGACY_MASK;
+ if( db->xProfile ) db->mTrace |= SQLITE_TRACE_XPROFILE;
sqlite3_mutex_leave(db->mutex);
return pOld;
}
@@ -154894,7 +155786,7 @@ SQLITE_API const char *sqlite3_errmsg(sqlite3 *db){
z = sqlite3ErrStr(SQLITE_NOMEM_BKPT);
}else{
testcase( db->pErr==0 );
- z = (char*)sqlite3_value_text(db->pErr);
+ z = db->errCode ? (char*)sqlite3_value_text(db->pErr) : 0;
assert( !db->mallocFailed );
if( z==0 ){
z = sqlite3ErrStr(db->errCode);
@@ -155424,6 +156316,40 @@ SQLITE_PRIVATE int sqlite3ParseUri(
return rc;
}
+#if defined(SQLITE_HAS_CODEC)
+/*
+** Process URI filename query parameters relevant to the SQLite Encryption
+** Extension. Return true if any of the relevant query parameters are
+** seen and return false if not.
+*/
+SQLITE_PRIVATE int sqlite3CodecQueryParameters(
+ sqlite3 *db, /* Database connection */
+ const char *zDb, /* Which schema is being created/attached */
+ const char *zUri /* URI filename */
+){
+ const char *zKey;
+ if( (zKey = sqlite3_uri_parameter(zUri, "hexkey"))!=0 && zKey[0] ){
+ u8 iByte;
+ int i;
+ char zDecoded[40];
+ for(i=0, iByte=0; i<sizeof(zDecoded)*2 && sqlite3Isxdigit(zKey[i]); i++){
+ iByte = (iByte<<4) + sqlite3HexToInt(zKey[i]);
+ if( (i&1)!=0 ) zDecoded[i/2] = iByte;
+ }
+ sqlite3_key_v2(db, zDb, zDecoded, i/2);
+ return 1;
+ }else if( (zKey = sqlite3_uri_parameter(zUri, "key"))!=0 ){
+ sqlite3_key_v2(db, zDb, zKey, sqlite3Strlen30(zKey));
+ return 1;
+ }else if( (zKey = sqlite3_uri_parameter(zUri, "textkey"))!=0 ){
+ sqlite3_key_v2(db, zDb, zKey, -1);
+ return 1;
+ }else{
+ return 0;
+ }
+}
+#endif
+
/*
** This routine does the work of opening a database on behalf of
@@ -155777,26 +156703,13 @@ opendb_out:
}
#endif
#if defined(SQLITE_HAS_CODEC)
- if( rc==SQLITE_OK ){
- const char *zKey;
- if( (zKey = sqlite3_uri_parameter(zOpen, "hexkey"))!=0 && zKey[0] ){
- u8 iByte;
- int i;
- char zDecoded[40];
- for(i=0, iByte=0; i<sizeof(zDecoded)*2 && sqlite3Isxdigit(zKey[i]); i++){
- iByte = (iByte<<4) + sqlite3HexToInt(zKey[i]);
- if( (i&1)!=0 ) zDecoded[i/2] = iByte;
- }
- sqlite3_key_v2(db, 0, zDecoded, i/2);
- }else if( (zKey = sqlite3_uri_parameter(zOpen, "key"))!=0 ){
- sqlite3_key_v2(db, 0, zKey, sqlite3Strlen30(zKey));
- }
- }
+ if( rc==SQLITE_OK ) sqlite3CodecQueryParameters(db, 0, zOpen);
#endif
sqlite3_free(zOpen);
return rc & 0xff;
}
+
/*
** Open a new database handle.
*/
@@ -157858,6 +158771,8 @@ SQLITE_PRIVATE Fts3HashElem *sqlite3Fts3HashFindElem(const Fts3Hash *, const voi
*/
#define FTS3_VARINT_MAX 10
+#define FTS3_BUFFER_PADDING 8
+
/*
** FTS4 virtual tables may maintain multiple indexes - one index of all terms
** in the document set and zero or more prefix indexes. All indexes are stored
@@ -157891,6 +158806,18 @@ SQLITE_PRIVATE Fts3HashElem *sqlite3Fts3HashFindElem(const Fts3Hash *, const voi
#define POS_END (0) /* Position-list terminator */
/*
+** The assert_fts3_nc() macro is similar to the assert() macro, except that it
+** is used for assert() conditions that are true only if it can be
+** guranteed that the database is not corrupt.
+*/
+#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)
+SQLITE_API extern int sqlite3_fts3_may_be_corrupt;
+# define assert_fts3_nc(x) assert(sqlite3_fts3_may_be_corrupt || (x))
+#else
+# define assert_fts3_nc(x) assert(x)
+#endif
+
+/*
** This section provides definitions to allow the
** FTS3 extension to be compiled outside of the
** amalgamation.
@@ -158415,6 +159342,14 @@ SQLITE_PRIVATE int sqlite3Fts3Never(int b) { assert( !b ); return b; }
#endif
/*
+** This variable is set to false when running tests for which the on disk
+** structures should not be corrupt. Otherwise, true. If it is false, extra
+** assert() conditions in the fts3 code are activated - conditions that are
+** only true if it is guaranteed that the fts3 database is not corrupt.
+*/
+SQLITE_API int sqlite3_fts3_may_be_corrupt = 1;
+
+/*
** Write a 64-bit variable-length integer to memory starting at p[0].
** The length of data written will be between 1 and FTS3_VARINT_MAX bytes.
** The number of bytes written is returned.
@@ -158432,7 +159367,7 @@ SQLITE_PRIVATE int sqlite3Fts3PutVarint(char *p, sqlite_int64 v){
}
#define GETVARINT_STEP(v, ptr, shift, mask1, mask2, var, ret) \
- v = (v & mask1) | ( (*ptr++) << shift ); \
+ v = (v & mask1) | ( (*(const unsigned char*)(ptr++)) << shift ); \
if( (v & mask2)==0 ){ var = v; return ret; }
#define GETVARINT_INIT(v, ptr, shift, mask1, mask2, var, ret) \
v = (*ptr++); \
@@ -158470,20 +159405,21 @@ SQLITE_PRIVATE int sqlite3Fts3GetVarint(const char *pBuf, sqlite_int64 *v){
** a non-negative 32-bit integer before it is returned.
*/
SQLITE_PRIVATE int sqlite3Fts3GetVarint32(const char *p, int *pi){
+ const unsigned char *ptr = (const unsigned char*)p;
u32 a;
#ifndef fts3GetVarint32
- GETVARINT_INIT(a, p, 0, 0x00, 0x80, *pi, 1);
+ GETVARINT_INIT(a, ptr, 0, 0x00, 0x80, *pi, 1);
#else
- a = (*p++);
+ a = (*ptr++);
assert( a & 0x80 );
#endif
- GETVARINT_STEP(a, p, 7, 0x7F, 0x4000, *pi, 2);
- GETVARINT_STEP(a, p, 14, 0x3FFF, 0x200000, *pi, 3);
- GETVARINT_STEP(a, p, 21, 0x1FFFFF, 0x10000000, *pi, 4);
+ GETVARINT_STEP(a, ptr, 7, 0x7F, 0x4000, *pi, 2);
+ GETVARINT_STEP(a, ptr, 14, 0x3FFF, 0x200000, *pi, 3);
+ GETVARINT_STEP(a, ptr, 21, 0x1FFFFF, 0x10000000, *pi, 4);
a = (a & 0x0FFFFFFF );
- *pi = (int)(a | ((u32)(*p & 0x07) << 28));
+ *pi = (int)(a | ((u32)(*ptr & 0x07) << 28));
assert( 0==(a & 0x80000000) );
assert( *pi>=0 );
return 5;
@@ -158654,13 +159590,18 @@ static int fts3DestroyMethod(sqlite3_vtab *pVtab){
sqlite3 *db = p->db; /* Database handle */
/* Drop the shadow tables */
- if( p->zContentTbl==0 ){
- fts3DbExec(&rc, db, "DROP TABLE IF EXISTS %Q.'%q_content'", zDb, p->zName);
- }
- fts3DbExec(&rc, db, "DROP TABLE IF EXISTS %Q.'%q_segments'", zDb,p->zName);
- fts3DbExec(&rc, db, "DROP TABLE IF EXISTS %Q.'%q_segdir'", zDb, p->zName);
- fts3DbExec(&rc, db, "DROP TABLE IF EXISTS %Q.'%q_docsize'", zDb, p->zName);
- fts3DbExec(&rc, db, "DROP TABLE IF EXISTS %Q.'%q_stat'", zDb, p->zName);
+ fts3DbExec(&rc, db,
+ "DROP TABLE IF EXISTS %Q.'%q_segments';"
+ "DROP TABLE IF EXISTS %Q.'%q_segdir';"
+ "DROP TABLE IF EXISTS %Q.'%q_docsize';"
+ "DROP TABLE IF EXISTS %Q.'%q_stat';"
+ "%s DROP TABLE IF EXISTS %Q.'%q_content';",
+ zDb, p->zName,
+ zDb, p->zName,
+ zDb, p->zName,
+ zDb, p->zName,
+ (p->zContentTbl ? "--" : ""), zDb,p->zName
+ );
/* If everything has worked, invoke fts3DisconnectMethod() to free the
** memory associated with the Fts3Table structure and return SQLITE_OK.
@@ -158892,10 +159833,10 @@ static void fts3Appendf(
** memory.
*/
static char *fts3QuoteId(char const *zInput){
- int nRet;
+ sqlite3_int64 nRet;
char *zRet;
nRet = 2 + (int)strlen(zInput)*2 + 1;
- zRet = sqlite3_malloc(nRet);
+ zRet = sqlite3_malloc64(nRet);
if( zRet ){
int i;
char *z = zRet;
@@ -159076,7 +160017,7 @@ static int fts3PrefixParameter(
}
}
- aIndex = sqlite3_malloc(sizeof(struct Fts3Index) * nIndex);
+ aIndex = sqlite3_malloc64(sizeof(struct Fts3Index) * nIndex);
*apIndex = aIndex;
if( !aIndex ){
return SQLITE_NOMEM;
@@ -159155,7 +160096,7 @@ static int fts3ContentColumns(
if( rc==SQLITE_OK ){
const char **azCol; /* Output array */
- int nStr = 0; /* Size of all column names (incl. 0x00) */
+ sqlite3_int64 nStr = 0; /* Size of all column names (incl. 0x00) */
int nCol; /* Number of table columns */
int i; /* Used to iterate through columns */
@@ -159165,11 +160106,11 @@ static int fts3ContentColumns(
nCol = sqlite3_column_count(pStmt);
for(i=0; i<nCol; i++){
const char *zCol = sqlite3_column_name(pStmt, i);
- nStr += (int)strlen(zCol) + 1;
+ nStr += strlen(zCol) + 1;
}
/* Allocate and populate the array to return. */
- azCol = (const char **)sqlite3_malloc(sizeof(char *) * nCol + nStr);
+ azCol = (const char **)sqlite3_malloc64(sizeof(char *) * nCol + nStr);
if( azCol==0 ){
rc = SQLITE_NOMEM;
}else{
@@ -159217,7 +160158,7 @@ static int fts3InitVtab(
Fts3Table *p = 0; /* Pointer to allocated vtab */
int rc = SQLITE_OK; /* Return code */
int i; /* Iterator variable */
- int nByte; /* Size of allocation used for *p */
+ sqlite3_int64 nByte; /* Size of allocation used for *p */
int iCol; /* Column index */
int nString = 0; /* Bytes required to hold all column names */
int nCol = 0; /* Number of columns in the FTS table */
@@ -159251,10 +160192,10 @@ static int fts3InitVtab(
nName = (int)strlen(argv[2]) + 1;
nByte = sizeof(const char *) * (argc-2);
- aCol = (const char **)sqlite3_malloc(nByte);
+ aCol = (const char **)sqlite3_malloc64(nByte);
if( aCol ){
memset((void*)aCol, 0, nByte);
- azNotindexed = (char **)sqlite3_malloc(nByte);
+ azNotindexed = (char **)sqlite3_malloc64(nByte);
}
if( azNotindexed ){
memset(azNotindexed, 0, nByte);
@@ -159449,7 +160390,7 @@ static int fts3InitVtab(
nName + /* zName */
nDb + /* zDb */
nString; /* Space for azColumn strings */
- p = (Fts3Table*)sqlite3_malloc(nByte);
+ p = (Fts3Table*)sqlite3_malloc64(nByte);
if( p==0 ){
rc = SQLITE_NOMEM;
goto fts3_init_out;
@@ -160228,7 +161169,7 @@ static int fts3PutColNumber(char **pp, int iCol){
** updated appropriately. The caller is responsible for insuring
** that there is enough space in *pp to hold the complete output.
*/
-static void fts3PoslistMerge(
+static int fts3PoslistMerge(
char **pp, /* Output buffer */
char **pp1, /* Left input list */
char **pp2 /* Right input list */
@@ -160241,11 +161182,17 @@ static void fts3PoslistMerge(
int iCol1; /* The current column index in pp1 */
int iCol2; /* The current column index in pp2 */
- if( *p1==POS_COLUMN ) fts3GetVarint32(&p1[1], &iCol1);
+ if( *p1==POS_COLUMN ){
+ fts3GetVarint32(&p1[1], &iCol1);
+ if( iCol1==0 ) return FTS_CORRUPT_VTAB;
+ }
else if( *p1==POS_END ) iCol1 = POSITION_LIST_END;
else iCol1 = 0;
- if( *p2==POS_COLUMN ) fts3GetVarint32(&p2[1], &iCol2);
+ if( *p2==POS_COLUMN ){
+ fts3GetVarint32(&p2[1], &iCol2);
+ if( iCol2==0 ) return FTS_CORRUPT_VTAB;
+ }
else if( *p2==POS_END ) iCol2 = POSITION_LIST_END;
else iCol2 = 0;
@@ -160293,6 +161240,7 @@ static void fts3PoslistMerge(
*pp = p;
*pp1 = p1 + 1;
*pp2 = p2 + 1;
+ return SQLITE_OK;
}
/*
@@ -160357,10 +161305,9 @@ static int fts3PoslistPhraseMerge(
p += sqlite3Fts3PutVarint(p, iCol1);
}
- assert( *p1!=POS_END && *p1!=POS_COLUMN );
- assert( *p2!=POS_END && *p2!=POS_COLUMN );
fts3GetDeltaVarint(&p1, &iPos1); iPos1 -= 2;
fts3GetDeltaVarint(&p2, &iPos2); iPos2 -= 2;
+ if( iPos1<0 || iPos2<0 ) break;
while( 1 ){
if( iPos2==iPos1+nToken
@@ -160586,6 +161533,7 @@ static int fts3DoclistOrMerge(
char *a2, int n2, /* Second doclist */
char **paOut, int *pnOut /* OUT: Malloc'd doclist */
){
+ int rc = SQLITE_OK;
sqlite3_int64 i1 = 0;
sqlite3_int64 i2 = 0;
sqlite3_int64 iPrev = 0;
@@ -160629,7 +161577,7 @@ static int fts3DoclistOrMerge(
** A symetric argument may be made if the doclists are in descending
** order.
*/
- aOut = sqlite3_malloc(n1+n2+FTS3_VARINT_MAX-1);
+ aOut = sqlite3_malloc64((i64)n1+n2+FTS3_VARINT_MAX-1+FTS3_BUFFER_PADDING);
if( !aOut ) return SQLITE_NOMEM;
p = aOut;
@@ -160640,7 +161588,8 @@ static int fts3DoclistOrMerge(
if( p2 && p1 && iDiff==0 ){
fts3PutDeltaVarint3(&p, bDescDoclist, &iPrev, &bFirstOut, i1);
- fts3PoslistMerge(&p, &p1, &p2);
+ rc = fts3PoslistMerge(&p, &p1, &p2);
+ if( rc ) break;
fts3GetDeltaVarint3(&p1, pEnd1, bDescDoclist, &i1);
fts3GetDeltaVarint3(&p2, pEnd2, bDescDoclist, &i2);
}else if( !p2 || (p1 && iDiff<0) ){
@@ -160654,10 +161603,16 @@ static int fts3DoclistOrMerge(
}
}
+ if( rc!=SQLITE_OK ){
+ sqlite3_free(aOut);
+ p = aOut = 0;
+ }else{
+ assert( (p-aOut)<=n1+n2+FTS3_VARINT_MAX-1 );
+ memset(&aOut[(p-aOut)], 0, FTS3_BUFFER_PADDING);
+ }
*paOut = aOut;
*pnOut = (int)(p-aOut);
- assert( *pnOut<=n1+n2+FTS3_VARINT_MAX-1 );
- return SQLITE_OK;
+ return rc;
}
/*
@@ -160692,7 +161647,7 @@ static int fts3DoclistPhraseMerge(
assert( nDist>0 );
if( bDescDoclist ){
- aOut = sqlite3_malloc(*pnRight + FTS3_VARINT_MAX);
+ aOut = sqlite3_malloc64((sqlite3_int64)*pnRight + FTS3_VARINT_MAX);
if( aOut==0 ) return SQLITE_NOMEM;
}else{
aOut = aRight;
@@ -160876,6 +161831,7 @@ static int fts3TermSelectMerge(
pTS->anOutput[0] = nDoclist;
if( pTS->aaOutput[0] ){
memcpy(pTS->aaOutput[0], aDoclist, nDoclist);
+ memset(&pTS->aaOutput[0][nDoclist], 0, FTS3_VARINT_MAX);
}else{
return SQLITE_NOMEM;
}
@@ -160927,8 +161883,8 @@ static int fts3SegReaderCursorAppend(
){
if( (pCsr->nSegment%16)==0 ){
Fts3SegReader **apNew;
- int nByte = (pCsr->nSegment + 16)*sizeof(Fts3SegReader*);
- apNew = (Fts3SegReader **)sqlite3_realloc(pCsr->apSegment, nByte);
+ sqlite3_int64 nByte = (pCsr->nSegment + 16)*sizeof(Fts3SegReader*);
+ apNew = (Fts3SegReader **)sqlite3_realloc64(pCsr->apSegment, nByte);
if( !apNew ){
sqlite3Fts3SegReaderFree(pNew);
return SQLITE_NOMEM;
@@ -161934,7 +162890,6 @@ static int fts3RollbackToMethod(sqlite3_vtab *pVtab, int iSavepoint){
Fts3Table *p = (Fts3Table*)pVtab;
UNUSED_PARAMETER(iSavepoint);
assert( p->inTransaction );
- assert( p->mxSavepoint >= iSavepoint );
TESTONLY( p->mxSavepoint = iSavepoint );
sqlite3Fts3PendingTermsClear(p);
return SQLITE_OK;
@@ -162717,9 +163672,10 @@ static int fts3EvalIncrPhraseNext(
if( bEof==0 ){
int nList = 0;
int nByte = a[p->nToken-1].nList;
- char *aDoclist = sqlite3_malloc(nByte+1);
+ char *aDoclist = sqlite3_malloc(nByte+FTS3_BUFFER_PADDING);
if( !aDoclist ) return SQLITE_NOMEM;
memcpy(aDoclist, a[p->nToken-1].pList, nByte+1);
+ memset(&aDoclist[nByte], 0, FTS3_BUFFER_PADDING);
for(i=0; i<(p->nToken-1); i++){
if( a[i].bIgnore==0 ){
@@ -163110,7 +164066,7 @@ static int fts3EvalStart(Fts3Cursor *pCsr){
if( rc==SQLITE_OK && nToken>1 && pTab->bFts4 ){
Fts3TokenAndCost *aTC;
Fts3Expr **apOr;
- aTC = (Fts3TokenAndCost *)sqlite3_malloc(
+ aTC = (Fts3TokenAndCost *)sqlite3_malloc64(
sizeof(Fts3TokenAndCost) * nToken
+ sizeof(Fts3Expr *) * nOr * 2
);
@@ -163421,7 +164377,7 @@ static int fts3EvalNearTest(Fts3Expr *pExpr, int *pRc){
&& (pExpr->pParent==0 || pExpr->pParent->eType!=FTSQUERY_NEAR)
){
Fts3Expr *p;
- int nTmp = 0; /* Bytes of temp space */
+ sqlite3_int64 nTmp = 0; /* Bytes of temp space */
char *aTmp; /* Temp space for PoslistNearMerge() */
/* Allocate temporary working space. */
@@ -163430,7 +164386,7 @@ static int fts3EvalNearTest(Fts3Expr *pExpr, int *pRc){
nTmp += p->pRight->pPhrase->doclist.nList;
}
nTmp += p->pPhrase->doclist.nList;
- aTmp = sqlite3_malloc(nTmp*2);
+ aTmp = sqlite3_malloc64(nTmp*2);
if( !aTmp ){
*pRc = SQLITE_NOMEM;
res = 0;
@@ -163700,15 +164656,14 @@ static void fts3EvalRestart(
** found in Fts3Expr.pPhrase->doclist.pList for each of the phrase
** expression nodes.
*/
-static void fts3EvalUpdateCounts(Fts3Expr *pExpr){
+static void fts3EvalUpdateCounts(Fts3Expr *pExpr, int nCol){
if( pExpr ){
Fts3Phrase *pPhrase = pExpr->pPhrase;
if( pPhrase && pPhrase->doclist.pList ){
int iCol = 0;
char *p = pPhrase->doclist.pList;
- assert( *p );
- while( 1 ){
+ do{
u8 c = 0;
int iCnt = 0;
while( 0xFE & (*p | c) ){
@@ -163724,11 +164679,11 @@ static void fts3EvalUpdateCounts(Fts3Expr *pExpr){
if( *p==0x00 ) break;
p++;
p += fts3GetVarint32(p, &iCol);
- }
+ }while( iCol<nCol );
}
- fts3EvalUpdateCounts(pExpr->pLeft);
- fts3EvalUpdateCounts(pExpr->pRight);
+ fts3EvalUpdateCounts(pExpr->pLeft, nCol);
+ fts3EvalUpdateCounts(pExpr->pRight, nCol);
}
}
@@ -163772,7 +164727,7 @@ static int fts3EvalGatherStats(
for(p=pRoot; p; p=p->pLeft){
Fts3Expr *pE = (p->eType==FTSQUERY_PHRASE?p:p->pRight);
assert( pE->aMI==0 );
- pE->aMI = (u32 *)sqlite3_malloc(pTab->nColumn * 3 * sizeof(u32));
+ pE->aMI = (u32 *)sqlite3_malloc64(pTab->nColumn * 3 * sizeof(u32));
if( !pE->aMI ) return SQLITE_NOMEM;
memset(pE->aMI, 0, pTab->nColumn * 3 * sizeof(u32));
}
@@ -163798,7 +164753,7 @@ static int fts3EvalGatherStats(
);
if( rc==SQLITE_OK && pCsr->isEof==0 ){
- fts3EvalUpdateCounts(pRoot);
+ fts3EvalUpdateCounts(pRoot, pTab->nColumn);
}
}
@@ -164148,7 +165103,7 @@ static int fts3auxConnectMethod(
char const *zFts3; /* Name of fts3 table */
int nDb; /* Result of strlen(zDb) */
int nFts3; /* Result of strlen(zFts3) */
- int nByte; /* Bytes of space to allocate here */
+ sqlite3_int64 nByte; /* Bytes of space to allocate here */
int rc; /* value returned by declare_vtab() */
Fts3auxTable *p; /* Virtual table object to return */
@@ -164180,7 +165135,7 @@ static int fts3auxConnectMethod(
if( rc!=SQLITE_OK ) return rc;
nByte = sizeof(Fts3auxTable) + sizeof(Fts3Table) + nDb + nFts3 + 2;
- p = (Fts3auxTable *)sqlite3_malloc(nByte);
+ p = (Fts3auxTable *)sqlite3_malloc64(nByte);
if( !p ) return SQLITE_NOMEM;
memset(p, 0, nByte);
@@ -164330,7 +165285,7 @@ static int fts3auxCloseMethod(sqlite3_vtab_cursor *pCursor){
static int fts3auxGrowStatArray(Fts3auxCursor *pCsr, int nSize){
if( nSize>pCsr->nStat ){
struct Fts3auxColstats *aNew;
- aNew = (struct Fts3auxColstats *)sqlite3_realloc(pCsr->aStat,
+ aNew = (struct Fts3auxColstats *)sqlite3_realloc64(pCsr->aStat,
sizeof(struct Fts3auxColstats) * nSize
);
if( aNew==0 ) return SQLITE_NOMEM;
@@ -164498,15 +165453,15 @@ static int fts3auxFilterMethod(
assert( (iEq==0 && iGe==-1) || (iEq==-1 && iGe==0) );
if( zStr ){
pCsr->filter.zTerm = sqlite3_mprintf("%s", zStr);
- pCsr->filter.nTerm = sqlite3_value_bytes(apVal[0]);
if( pCsr->filter.zTerm==0 ) return SQLITE_NOMEM;
+ pCsr->filter.nTerm = (int)strlen(pCsr->filter.zTerm);
}
}
if( iLe>=0 ){
pCsr->zStop = sqlite3_mprintf("%s", sqlite3_value_text(apVal[iLe]));
- pCsr->nStop = sqlite3_value_bytes(apVal[iLe]);
if( pCsr->zStop==0 ) return SQLITE_NOMEM;
+ pCsr->nStop = (int)strlen(pCsr->zStop);
}
if( iLangid>=0 ){
@@ -164758,8 +165713,8 @@ static int fts3isspace(char c){
** zero the memory before returning a pointer to it. If unsuccessful,
** return NULL.
*/
-static void *fts3MallocZero(int nByte){
- void *pRet = sqlite3_malloc(nByte);
+static void *fts3MallocZero(sqlite3_int64 nByte){
+ void *pRet = sqlite3_malloc64(nByte);
if( pRet ) memset(pRet, 0, nByte);
return pRet;
}
@@ -164834,7 +165789,7 @@ static int getNextToken(
if( rc==SQLITE_OK ){
const char *zToken;
int nToken = 0, iStart = 0, iEnd = 0, iPosition = 0;
- int nByte; /* total space to allocate */
+ sqlite3_int64 nByte; /* total space to allocate */
rc = pModule->xNext(pCursor, &zToken, &nToken, &iStart, &iEnd, &iPosition);
if( rc==SQLITE_OK ){
@@ -164888,8 +165843,8 @@ static int getNextToken(
** Enlarge a memory allocation. If an out-of-memory allocation occurs,
** then free the old allocation.
*/
-static void *fts3ReallocOrFree(void *pOrig, int nNew){
- void *pRet = sqlite3_realloc(pOrig, nNew);
+static void *fts3ReallocOrFree(void *pOrig, sqlite3_int64 nNew){
+ void *pRet = sqlite3_realloc64(pOrig, nNew);
if( !pRet ){
sqlite3_free(pOrig);
}
@@ -165133,7 +166088,6 @@ static int getNextNode(
int nConsumed = 0;
pParse->nNest++;
rc = fts3ExprParse(pParse, zInput+1, nInput-1, ppExpr, &nConsumed);
- if( rc==SQLITE_OK && !*ppExpr ){ rc = SQLITE_DONE; }
*pnConsumed = (int)(zInput - z) + 1 + nConsumed;
return rc;
}else if( *zInput==')' ){
@@ -165432,7 +166386,7 @@ static int fts3ExprBalance(Fts3Expr **pp, int nMaxDepth){
if( rc==SQLITE_OK ){
if( (eType==FTSQUERY_AND || eType==FTSQUERY_OR) ){
Fts3Expr **apLeaf;
- apLeaf = (Fts3Expr **)sqlite3_malloc(sizeof(Fts3Expr *) * nMaxDepth);
+ apLeaf = (Fts3Expr **)sqlite3_malloc64(sizeof(Fts3Expr *) * nMaxDepth);
if( 0==apLeaf ){
rc = SQLITE_NOMEM;
}else{
@@ -165852,7 +166806,7 @@ static void fts3ExprTestCommon(
zExpr = (const char *)sqlite3_value_text(argv[1]);
nExpr = sqlite3_value_bytes(argv[1]);
nCol = argc-2;
- azCol = (char **)sqlite3_malloc(nCol*sizeof(char *));
+ azCol = (char **)sqlite3_malloc64(nCol*sizeof(char *));
if( !azCol ){
sqlite3_result_error_nomem(context);
goto exprtest_out;
@@ -165966,8 +166920,8 @@ SQLITE_PRIVATE int sqlite3Fts3ExprInitTestInterface(sqlite3 *db, Fts3Hash *pHash
/*
** Malloc and Free functions
*/
-static void *fts3HashMalloc(int n){
- void *p = sqlite3_malloc(n);
+static void *fts3HashMalloc(sqlite3_int64 n){
+ void *p = sqlite3_malloc64(n);
if( p ){
memset(p, 0, n);
}
@@ -167860,7 +168814,7 @@ static int fts3tokDequoteArray(
nByte += (int)(strlen(argv[i]) + 1);
}
- *pazDequote = azDequote = sqlite3_malloc(sizeof(char *)*argc + nByte);
+ *pazDequote = azDequote = sqlite3_malloc64(sizeof(char *)*argc + nByte);
if( azDequote==0 ){
rc = SQLITE_NOMEM;
}else{
@@ -168763,7 +169717,7 @@ static sqlite3_int64 getAbsoluteLevel(
int iLevel /* Level of segments */
){
sqlite3_int64 iBase; /* First absolute level for iLangid/iIndex */
- assert( iLangid>=0 );
+ assert_fts3_nc( iLangid>=0 );
assert( p->nIndex>0 );
assert( iIndex>=0 && iIndex<p->nIndex );
@@ -169605,7 +170559,7 @@ static int fts3SegReaderNext(
** b-tree node. And that the final byte of the doclist is 0x00. If either
** of these statements is untrue, then the data structure is corrupt.
*/
- if( (&pReader->aNode[pReader->nNode] - pReader->aDoclist)<pReader->nDoclist
+ if( pReader->nDoclist > pReader->nNode-(pReader->aDoclist-pReader->aNode)
|| (pReader->nPopulate==0 && pReader->aDoclist[pReader->nDoclist-1])
){
return FTS_CORRUPT_VTAB;
@@ -169805,8 +170759,13 @@ SQLITE_PRIVATE int sqlite3Fts3SegReaderNew(
Fts3SegReader *pReader; /* Newly allocated SegReader object */
int nExtra = 0; /* Bytes to allocate segment root node */
- assert( iStartLeaf<=iEndLeaf );
+ assert( zRoot!=0 || nRoot==0 );
+#ifdef CORRUPT_DB
+ assert( zRoot!=0 || CORRUPT_DB );
+#endif
+
if( iStartLeaf==0 ){
+ if( iEndLeaf!=0 ) return FTS_CORRUPT_VTAB;
nExtra = nRoot + FTS3_NODE_PADDING;
}
@@ -169826,7 +170785,7 @@ SQLITE_PRIVATE int sqlite3Fts3SegReaderNew(
pReader->aNode = (char *)&pReader[1];
pReader->rootOnly = 1;
pReader->nNode = nRoot;
- memcpy(pReader->aNode, zRoot, nRoot);
+ if( nRoot ) memcpy(pReader->aNode, zRoot, nRoot);
memset(&pReader->aNode[nRoot], 0, FTS3_NODE_PADDING);
}else{
pReader->iCurrentBlock = iStartLeaf-1;
@@ -170446,6 +171405,11 @@ static int fts3SegWriterAdd(
nPrefix = fts3PrefixCompress(pWriter->zTerm, pWriter->nTerm, zTerm, nTerm);
nSuffix = nTerm-nPrefix;
+ /* If nSuffix is zero or less, then zTerm/nTerm must be a prefix of
+ ** pWriter->zTerm/pWriter->nTerm. i.e. must be equal to or less than when
+ ** compared with BINARY collation. This indicates corruption. */
+ if( nSuffix<=0 ) return FTS_CORRUPT_VTAB;
+
/* Figure out how many bytes are required by this new entry */
nReq = sqlite3Fts3VarintLen(nPrefix) + /* varint containing prefix size */
sqlite3Fts3VarintLen(nSuffix) + /* varint containing suffix size */
@@ -171153,7 +172117,9 @@ SQLITE_PRIVATE int sqlite3Fts3SegReaderStep(
}else{
iDelta = iDocid - iPrev;
}
- assert( iDelta>0 || (nDoclist==0 && iDelta==iDocid) );
+ if( iDelta<=0 && (nDoclist>0 || iDelta!=iDocid) ){
+ return FTS_CORRUPT_VTAB;
+ }
assert( nDoclist>0 || iDelta==iDocid );
nByte = sqlite3Fts3VarintLen(iDelta) + (isRequirePos?nList+1:0);
@@ -171519,14 +172485,16 @@ static void fts3DecodeIntArray(
const char *zBuf, /* The BLOB containing the varints */
int nBuf /* size of the BLOB */
){
- int i, j;
- UNUSED_PARAMETER(nBuf);
- for(i=j=0; i<N; i++){
- sqlite3_int64 x;
- j += sqlite3Fts3GetVarint(&zBuf[j], &x);
- assert(j<=nBuf);
- a[i] = (u32)(x & 0xffffffff);
+ int i = 0;
+ if( nBuf && (zBuf[nBuf-1]&0x80)==0 ){
+ int j;
+ for(i=j=0; i<N && j<nBuf; i++){
+ sqlite3_int64 x;
+ j += sqlite3Fts3GetVarint(&zBuf[j], &x);
+ a[i] = (u32)(x & 0xffffffff);
+ }
}
+ while( i<N ) a[i++] = 0;
}
/*
@@ -171932,7 +172900,7 @@ static int nodeReaderNext(NodeReader *p){
p->iOff += fts3GetVarint32(&p->aNode[p->iOff], &nSuffix);
if( nPrefix>p->iOff || nSuffix>p->nNode-p->iOff ){
- return SQLITE_CORRUPT_VTAB;
+ return FTS_CORRUPT_VTAB;
}
blobGrowBuffer(&p->term, nPrefix+nSuffix, &rc);
if( rc==SQLITE_OK ){
@@ -171942,7 +172910,7 @@ static int nodeReaderNext(NodeReader *p){
if( p->iChild==0 ){
p->iOff += fts3GetVarint32(&p->aNode[p->iOff], &p->nDoclist);
if( (p->nNode-p->iOff)<p->nDoclist ){
- return SQLITE_CORRUPT_VTAB;
+ return FTS_CORRUPT_VTAB;
}
p->aDoclist = &p->aNode[p->iOff];
p->iOff += p->nDoclist;
@@ -174072,7 +175040,7 @@ static void (*fts3MIBufferAlloc(MatchinfoBuffer *p, u32 **paOut))(void*){
aOut = &p->aMatchinfo[p->nElem+2];
xRet = fts3MIBufferFree;
}else{
- aOut = (u32*)sqlite3_malloc(p->nElem * sizeof(u32));
+ aOut = (u32*)sqlite3_malloc64(p->nElem * sizeof(u32));
if( aOut ){
xRet = sqlite3_free;
if( p->bGlobal ) memcpy(aOut, &p->aMatchinfo[1], p->nElem*sizeof(u32));
@@ -174327,7 +175295,8 @@ static void fts3SnippetDetails(
int j;
u64 mPhrase = (u64)1 << i;
u64 mPos = (u64)1 << (iCsr - iStart);
- assert( iCsr>=iStart );
+ assert( iCsr>=iStart && (iCsr - iStart)<=64 );
+ assert( i>=0 && i<=64 );
if( (mCover|mCovered)&mPhrase ){
iScore++;
}else{
@@ -174369,11 +175338,14 @@ static int fts3SnippetFindPositions(Fts3Expr *pExpr, int iPhrase, void *ctx){
int iFirst = 0;
pPhrase->pList = pCsr;
fts3GetDeltaPosition(&pCsr, &iFirst);
- assert( iFirst>=0 );
- pPhrase->pHead = pCsr;
- pPhrase->pTail = pCsr;
- pPhrase->iHead = iFirst;
- pPhrase->iTail = iFirst;
+ if( iFirst<0 ){
+ rc = FTS_CORRUPT_VTAB;
+ }else{
+ pPhrase->pHead = pCsr;
+ pPhrase->pTail = pCsr;
+ pPhrase->iHead = iFirst;
+ pPhrase->iTail = iFirst;
+ }
}else{
assert( rc!=SQLITE_OK || (
pPhrase->pList==0 && pPhrase->pHead==0 && pPhrase->pTail==0
@@ -174410,7 +175382,7 @@ static int fts3BestSnippet(
int rc; /* Return Code */
int nList; /* Number of phrases in expression */
SnippetIter sIter; /* Iterates through snippet candidates */
- int nByte; /* Number of bytes of space to allocate */
+ sqlite3_int64 nByte; /* Number of bytes of space to allocate */
int iBestScore = -1; /* Best snippet score found so far */
int i; /* Loop counter */
@@ -174428,7 +175400,7 @@ static int fts3BestSnippet(
** the required space using malloc().
*/
nByte = sizeof(SnippetPhrase) * nList;
- sIter.aPhrase = (SnippetPhrase *)sqlite3_malloc(nByte);
+ sIter.aPhrase = (SnippetPhrase *)sqlite3_malloc64(nByte);
if( !sIter.aPhrase ){
return SQLITE_NOMEM;
}
@@ -174498,8 +175470,8 @@ static int fts3StringAppend(
** appended data.
*/
if( pStr->n+nAppend+1>=pStr->nAlloc ){
- int nAlloc = pStr->nAlloc+nAppend+100;
- char *zNew = sqlite3_realloc(pStr->z, nAlloc);
+ sqlite3_int64 nAlloc = pStr->nAlloc+(sqlite3_int64)nAppend+100;
+ char *zNew = sqlite3_realloc64(pStr->z, nAlloc);
if( !zNew ){
return SQLITE_NOMEM;
}
@@ -174554,6 +175526,7 @@ static int fts3SnippetShift(
for(nLeft=0; !(hlmask & ((u64)1 << nLeft)); nLeft++);
for(nRight=0; !(hlmask & ((u64)1 << (nSnippet-1-nRight))); nRight++);
+ assert( (nSnippet-1-nRight)<=63 && (nSnippet-1-nRight)>=0 );
nDesired = (nLeft-nRight)/2;
/* Ideally, the start of the snippet should be pushed forward in the
@@ -174746,7 +175719,7 @@ static int fts3ColumnlistCount(char **ppCollist){
/*
** This function gathers 'y' or 'b' data for a single phrase.
*/
-static void fts3ExprLHits(
+static int fts3ExprLHits(
Fts3Expr *pExpr, /* Phrase expression node */
MatchInfo *p /* Matchinfo context */
){
@@ -174776,25 +175749,29 @@ static void fts3ExprLHits(
if( *pIter!=0x01 ) break;
pIter++;
pIter += fts3GetVarint32(pIter, &iCol);
+ if( iCol>=p->nCol ) return FTS_CORRUPT_VTAB;
}
+ return SQLITE_OK;
}
/*
** Gather the results for matchinfo directives 'y' and 'b'.
*/
-static void fts3ExprLHitGather(
+static int fts3ExprLHitGather(
Fts3Expr *pExpr,
MatchInfo *p
){
+ int rc = SQLITE_OK;
assert( (pExpr->pLeft==0)==(pExpr->pRight==0) );
if( pExpr->bEof==0 && pExpr->iDocid==p->pCursor->iPrevId ){
if( pExpr->pLeft ){
- fts3ExprLHitGather(pExpr->pLeft, p);
- fts3ExprLHitGather(pExpr->pRight, p);
+ rc = fts3ExprLHitGather(pExpr->pLeft, p);
+ if( rc==SQLITE_OK ) rc = fts3ExprLHitGather(pExpr->pRight, p);
}else{
- fts3ExprLHits(pExpr, p);
+ rc = fts3ExprLHits(pExpr, p);
}
}
+ return rc;
}
/*
@@ -175011,11 +175988,12 @@ static int fts3MatchinfoLcs(Fts3Cursor *pCsr, MatchInfo *pInfo){
int i;
int iCol;
int nToken = 0;
+ int rc = SQLITE_OK;
/* Allocate and populate the array of LcsIterator objects. The array
** contains one element for each matchable phrase in the query.
**/
- aIter = sqlite3_malloc(sizeof(LcsIterator) * pCsr->nPhrase);
+ aIter = sqlite3_malloc64(sizeof(LcsIterator) * pCsr->nPhrase);
if( !aIter ) return SQLITE_NOMEM;
memset(aIter, 0, sizeof(LcsIterator) * pCsr->nPhrase);
(void)fts3ExprIterate(pCsr->pExpr, fts3MatchinfoLcsCb, (void*)aIter);
@@ -175031,13 +176009,16 @@ static int fts3MatchinfoLcs(Fts3Cursor *pCsr, MatchInfo *pInfo){
int nLive = 0; /* Number of iterators in aIter not at EOF */
for(i=0; i<pInfo->nPhrase; i++){
- int rc;
LcsIterator *pIt = &aIter[i];
rc = sqlite3Fts3EvalPhrasePoslist(pCsr, pIt->pExpr, iCol, &pIt->pRead);
- if( rc!=SQLITE_OK ) return rc;
+ if( rc!=SQLITE_OK ) goto matchinfo_lcs_out;
if( pIt->pRead ){
pIt->iPos = pIt->iPosOffset;
- fts3LcsIteratorAdvance(&aIter[i]);
+ fts3LcsIteratorAdvance(pIt);
+ if( pIt->pRead==0 ){
+ rc = FTS_CORRUPT_VTAB;
+ goto matchinfo_lcs_out;
+ }
nLive++;
}
}
@@ -175069,8 +176050,9 @@ static int fts3MatchinfoLcs(Fts3Cursor *pCsr, MatchInfo *pInfo){
pInfo->aMatchinfo[iCol] = nLcs;
}
+ matchinfo_lcs_out:
sqlite3_free(aIter);
- return SQLITE_OK;
+ return rc;
}
/*
@@ -175166,7 +176148,7 @@ static int fts3MatchinfoValues(
case FTS3_MATCHINFO_LHITS: {
int nZero = fts3MatchinfoSize(pInfo, zArg[i]) * sizeof(u32);
memset(pInfo->aMatchinfo, 0, nZero);
- fts3ExprLHitGather(pCsr->pExpr, pInfo);
+ rc = fts3ExprLHitGather(pCsr->pExpr, pInfo);
break;
}
@@ -175318,6 +176300,10 @@ SQLITE_PRIVATE void sqlite3Fts3Snippet(
return;
}
+ /* Limit the snippet length to 64 tokens. */
+ if( nToken<-64 ) nToken = -64;
+ if( nToken>+64 ) nToken = +64;
+
for(nSnippet=1; 1; nSnippet++){
int iSnip; /* Loop counter 0..nSnippet-1 */
@@ -175460,7 +176446,7 @@ SQLITE_PRIVATE void sqlite3Fts3Offsets(
if( rc!=SQLITE_OK ) goto offsets_out;
/* Allocate the array of TermOffset iterators. */
- sCtx.aTerm = (TermOffset *)sqlite3_malloc(sizeof(TermOffset)*nToken);
+ sCtx.aTerm = (TermOffset *)sqlite3_malloc64(sizeof(TermOffset)*nToken);
if( 0==sCtx.aTerm ){
rc = SQLITE_NOMEM;
goto offsets_out;
@@ -175685,7 +176671,7 @@ typedef struct unicode_cursor unicode_cursor;
struct unicode_tokenizer {
sqlite3_tokenizer base;
- int bRemoveDiacritic;
+ int eRemoveDiacritic;
int nException;
int *aiException;
};
@@ -175758,7 +176744,7 @@ static int unicodeAddExceptions(
int *aNew; /* New aiException[] array */
int nNew; /* Number of valid entries in array aNew[] */
- aNew = sqlite3_realloc(p->aiException, (p->nException+nEntry)*sizeof(int));
+ aNew = sqlite3_realloc64(p->aiException,(p->nException+nEntry)*sizeof(int));
if( aNew==0 ) return SQLITE_NOMEM;
nNew = p->nException;
@@ -175830,17 +176816,20 @@ static int unicodeCreate(
pNew = (unicode_tokenizer *) sqlite3_malloc(sizeof(unicode_tokenizer));
if( pNew==NULL ) return SQLITE_NOMEM;
memset(pNew, 0, sizeof(unicode_tokenizer));
- pNew->bRemoveDiacritic = 1;
+ pNew->eRemoveDiacritic = 1;
for(i=0; rc==SQLITE_OK && i<nArg; i++){
const char *z = azArg[i];
int n = (int)strlen(z);
if( n==19 && memcmp("remove_diacritics=1", z, 19)==0 ){
- pNew->bRemoveDiacritic = 1;
+ pNew->eRemoveDiacritic = 1;
}
else if( n==19 && memcmp("remove_diacritics=0", z, 19)==0 ){
- pNew->bRemoveDiacritic = 0;
+ pNew->eRemoveDiacritic = 0;
+ }
+ else if( n==19 && memcmp("remove_diacritics=2", z, 19)==0 ){
+ pNew->eRemoveDiacritic = 2;
}
else if( n>=11 && memcmp("tokenchars=", z, 11)==0 ){
rc = unicodeAddExceptions(pNew, 1, &z[11], n-11);
@@ -175944,7 +176933,7 @@ static int unicodeNext(
/* Grow the output buffer if required. */
if( (zOut-pCsr->zToken)>=(pCsr->nAlloc-4) ){
- char *zNew = sqlite3_realloc(pCsr->zToken, pCsr->nAlloc+64);
+ char *zNew = sqlite3_realloc64(pCsr->zToken, pCsr->nAlloc+64);
if( !zNew ) return SQLITE_NOMEM;
zOut = &zNew[zOut - pCsr->zToken];
pCsr->zToken = zNew;
@@ -175953,7 +176942,7 @@ static int unicodeNext(
/* Write the folded case of the last character read to the output */
zEnd = z;
- iOut = sqlite3FtsUnicodeFold((int)iCode, p->bRemoveDiacritic);
+ iOut = sqlite3FtsUnicodeFold((int)iCode, p->eRemoveDiacritic);
if( iOut ){
WRITE_UTF8(zOut, iOut);
}
@@ -175998,7 +176987,7 @@ SQLITE_PRIVATE void sqlite3Fts3UnicodeTokenizer(sqlite3_tokenizer_module const *
/************** End of fts3_unicode.c ****************************************/
/************** Begin file fts3_unicode2.c ***********************************/
/*
-** 2012 May 25
+** 2012-05-25
**
** The author disclaims copyright to this source code. In place of
** a legal notice, here is a blessing:
@@ -176158,32 +177147,48 @@ SQLITE_PRIVATE int sqlite3FtsUnicodeIsalnum(int c){
** E"). The resuls of passing a codepoint that corresponds to an
** uppercase letter are undefined.
*/
-static int remove_diacritic(int c){
+static int remove_diacritic(int c, int bComplex){
unsigned short aDia[] = {
0, 1797, 1848, 1859, 1891, 1928, 1940, 1995,
2024, 2040, 2060, 2110, 2168, 2206, 2264, 2286,
2344, 2383, 2472, 2488, 2516, 2596, 2668, 2732,
2782, 2842, 2894, 2954, 2984, 3000, 3028, 3336,
- 3456, 3696, 3712, 3728, 3744, 3896, 3912, 3928,
- 3968, 4008, 4040, 4106, 4138, 4170, 4202, 4234,
- 4266, 4296, 4312, 4344, 4408, 4424, 4472, 4504,
- 6148, 6198, 6264, 6280, 6360, 6429, 6505, 6529,
- 61448, 61468, 61534, 61592, 61642, 61688, 61704, 61726,
- 61784, 61800, 61836, 61880, 61914, 61948, 61998, 62122,
- 62154, 62200, 62218, 62302, 62364, 62442, 62478, 62536,
- 62554, 62584, 62604, 62640, 62648, 62656, 62664, 62730,
- 62924, 63050, 63082, 63274, 63390,
+ 3456, 3696, 3712, 3728, 3744, 3766, 3832, 3896,
+ 3912, 3928, 3944, 3968, 4008, 4040, 4056, 4106,
+ 4138, 4170, 4202, 4234, 4266, 4296, 4312, 4344,
+ 4408, 4424, 4442, 4472, 4488, 4504, 6148, 6198,
+ 6264, 6280, 6360, 6429, 6505, 6529, 61448, 61468,
+ 61512, 61534, 61592, 61610, 61642, 61672, 61688, 61704,
+ 61726, 61784, 61800, 61816, 61836, 61880, 61896, 61914,
+ 61948, 61998, 62062, 62122, 62154, 62184, 62200, 62218,
+ 62252, 62302, 62364, 62410, 62442, 62478, 62536, 62554,
+ 62584, 62604, 62640, 62648, 62656, 62664, 62730, 62766,
+ 62830, 62890, 62924, 62974, 63032, 63050, 63082, 63118,
+ 63182, 63242, 63274, 63310, 63368, 63390,
};
- char aChar[] = {
- '\0', 'a', 'c', 'e', 'i', 'n', 'o', 'u', 'y', 'y', 'a', 'c',
- 'd', 'e', 'e', 'g', 'h', 'i', 'j', 'k', 'l', 'n', 'o', 'r',
- 's', 't', 'u', 'u', 'w', 'y', 'z', 'o', 'u', 'a', 'i', 'o',
- 'u', 'g', 'k', 'o', 'j', 'g', 'n', 'a', 'e', 'i', 'o', 'r',
- 'u', 's', 't', 'h', 'a', 'e', 'o', 'y', '\0', '\0', '\0', '\0',
- '\0', '\0', '\0', '\0', 'a', 'b', 'd', 'd', 'e', 'f', 'g', 'h',
- 'h', 'i', 'k', 'l', 'l', 'm', 'n', 'p', 'r', 'r', 's', 't',
- 'u', 'v', 'w', 'w', 'x', 'y', 'z', 'h', 't', 'w', 'y', 'a',
- 'e', 'i', 'o', 'u', 'y',
+#define HIBIT ((unsigned char)0x80)
+ unsigned char aChar[] = {
+ '\0', 'a', 'c', 'e', 'i', 'n',
+ 'o', 'u', 'y', 'y', 'a', 'c',
+ 'd', 'e', 'e', 'g', 'h', 'i',
+ 'j', 'k', 'l', 'n', 'o', 'r',
+ 's', 't', 'u', 'u', 'w', 'y',
+ 'z', 'o', 'u', 'a', 'i', 'o',
+ 'u', 'u'|HIBIT, 'a'|HIBIT, 'g', 'k', 'o',
+ 'o'|HIBIT, 'j', 'g', 'n', 'a'|HIBIT, 'a',
+ 'e', 'i', 'o', 'r', 'u', 's',
+ 't', 'h', 'a', 'e', 'o'|HIBIT, 'o',
+ 'o'|HIBIT, 'y', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', 'a', 'b',
+ 'c'|HIBIT, 'd', 'd', 'e'|HIBIT, 'e', 'e'|HIBIT,
+ 'f', 'g', 'h', 'h', 'i', 'i'|HIBIT,
+ 'k', 'l', 'l'|HIBIT, 'l', 'm', 'n',
+ 'o'|HIBIT, 'p', 'r', 'r'|HIBIT, 'r', 's',
+ 's'|HIBIT, 't', 'u', 'u'|HIBIT, 'v', 'w',
+ 'w', 'x', 'y', 'z', 'h', 't',
+ 'w', 'y', 'a', 'a'|HIBIT, 'a'|HIBIT, 'a'|HIBIT,
+ 'e', 'e'|HIBIT, 'e'|HIBIT, 'i', 'o', 'o'|HIBIT,
+ 'o'|HIBIT, 'o'|HIBIT, 'u', 'u'|HIBIT, 'u'|HIBIT, 'y',
};
unsigned int key = (((unsigned int)c)<<3) | 0x00000007;
@@ -176200,7 +177205,8 @@ static int remove_diacritic(int c){
}
}
assert( key>=aDia[iRes] );
- return ((c > (aDia[iRes]>>3) + (aDia[iRes]&0x07)) ? c : (int)aChar[iRes]);
+ if( bComplex==0 && (aChar[iRes] & 0x80) ) return c;
+ return (c > (aDia[iRes]>>3) + (aDia[iRes]&0x07)) ? c : ((int)aChar[iRes] & 0x7F);
}
@@ -176213,8 +177219,8 @@ SQLITE_PRIVATE int sqlite3FtsUnicodeIsdiacritic(int c){
unsigned int mask1 = 0x000361F8;
if( c<768 || c>817 ) return 0;
return (c < 768+32) ?
- (mask0 & (1 << (c-768))) :
- (mask1 & (1 << (c-768-32)));
+ (mask0 & ((unsigned int)1 << (c-768))) :
+ (mask1 & ((unsigned int)1 << (c-768-32)));
}
@@ -176227,7 +177233,7 @@ SQLITE_PRIVATE int sqlite3FtsUnicodeIsdiacritic(int c){
** The results are undefined if the value passed to this function
** is less than zero.
*/
-SQLITE_PRIVATE int sqlite3FtsUnicodeFold(int c, int bRemoveDiacritic){
+SQLITE_PRIVATE int sqlite3FtsUnicodeFold(int c, int eRemoveDiacritic){
/* Each entry in the following array defines a rule for folding a range
** of codepoints to lower case. The rule applies to a range of nRange
** codepoints starting at codepoint iCode.
@@ -176350,7 +177356,9 @@ SQLITE_PRIVATE int sqlite3FtsUnicodeFold(int c, int bRemoveDiacritic){
assert( ret>0 );
}
- if( bRemoveDiacritic ) ret = remove_diacritic(ret);
+ if( eRemoveDiacritic ){
+ ret = remove_diacritic(ret, eRemoveDiacritic==2);
+ }
}
else if( c>=66560 && c<66600 ){
@@ -177057,7 +178065,7 @@ static JSON_NOINLINE int jsonParseAddNodeExpand(
assert( pParse->nNode>=pParse->nAlloc );
if( pParse->oom ) return -1;
nNew = pParse->nAlloc*2 + 10;
- pNew = sqlite3_realloc(pParse->aNode, sizeof(JsonNode)*nNew);
+ pNew = sqlite3_realloc64(pParse->aNode, sizeof(JsonNode)*nNew);
if( pNew==0 ){
pParse->oom = 1;
return -1;
@@ -177331,7 +178339,7 @@ static void jsonParseFillInParentage(JsonParse *pParse, u32 i, u32 iParent){
static int jsonParseFindParents(JsonParse *pParse){
u32 *aUp;
assert( pParse->aUp==0 );
- aUp = pParse->aUp = sqlite3_malloc( sizeof(u32)*pParse->nNode );
+ aUp = pParse->aUp = sqlite3_malloc64( sizeof(u32)*pParse->nNode );
if( aUp==0 ){
pParse->oom = 1;
return SQLITE_NOMEM;
@@ -177393,7 +178401,7 @@ static JsonParse *jsonParseCached(
pMatch->iHold = iMaxHold+1;
return pMatch;
}
- p = sqlite3_malloc( sizeof(*p) + nJson + 1 );
+ p = sqlite3_malloc64( sizeof(*p) + nJson + 1 );
if( p==0 ){
sqlite3_result_error_nomem(pCtx);
return 0;
@@ -179038,6 +180046,9 @@ struct Rtree {
u8 inWrTrans; /* True if inside write transaction */
u8 nAux; /* # of auxiliary columns in %_rowid */
u8 nAuxNotNull; /* Number of initial not-null aux columns */
+#ifdef SQLITE_DEBUG
+ u8 bCorrupt; /* Shadow table corruption detected */
+#endif
int iDepth; /* Current depth of the r-tree structure */
char *zDb; /* Name of database containing r-tree table */
char *zName; /* Name of r-tree table */
@@ -179098,6 +180109,15 @@ struct Rtree {
#endif
/*
+** Set the Rtree.bCorrupt flag
+*/
+#ifdef SQLITE_DEBUG
+# define RTREE_IS_CORRUPT(X) ((X)->bCorrupt = 1)
+#else
+# define RTREE_IS_CORRUPT(X)
+#endif
+
+/*
** When doing a search of an r-tree, instances of the following structure
** record intermediate results from the tree walk.
**
@@ -179463,8 +180483,8 @@ static void nodeZero(Rtree *pRtree, RtreeNode *p){
** Given a node number iNode, return the corresponding key to use
** in the Rtree.aHash table.
*/
-static int nodeHash(i64 iNode){
- return iNode % HASHSIZE;
+static unsigned int nodeHash(i64 iNode){
+ return ((unsigned)iNode) % HASHSIZE;
}
/*
@@ -179509,7 +180529,7 @@ static void nodeHashDelete(Rtree *pRtree, RtreeNode *pNode){
*/
static RtreeNode *nodeNew(Rtree *pRtree, RtreeNode *pParent){
RtreeNode *pNode;
- pNode = (RtreeNode *)sqlite3_malloc(sizeof(RtreeNode) + pRtree->iNodeSize);
+ pNode = (RtreeNode *)sqlite3_malloc64(sizeof(RtreeNode) + pRtree->iNodeSize);
if( pNode ){
memset(pNode, 0, sizeof(RtreeNode) + pRtree->iNodeSize);
pNode->zData = (u8 *)&pNode[1];
@@ -179534,6 +180554,18 @@ static void nodeBlobReset(Rtree *pRtree){
}
/*
+** Check to see if pNode is the same as pParent or any of the parents
+** of pParent.
+*/
+static int nodeInParentChain(const RtreeNode *pNode, const RtreeNode *pParent){
+ do{
+ if( pNode==pParent ) return 1;
+ pParent = pParent->pParent;
+ }while( pParent );
+ return 0;
+}
+
+/*
** Obtain a reference to an r-tree node.
*/
static int nodeAcquire(
@@ -179551,6 +180583,10 @@ static int nodeAcquire(
if( (pNode = nodeHashLookup(pRtree, iNode))!=0 ){
assert( !pParent || !pNode->pParent || pNode->pParent==pParent );
if( pParent && !pNode->pParent ){
+ if( nodeInParentChain(pNode, pParent) ){
+ RTREE_IS_CORRUPT(pRtree);
+ return SQLITE_CORRUPT_VTAB;
+ }
pParent->nRef++;
pNode->pParent = pParent;
}
@@ -179581,9 +180617,12 @@ static int nodeAcquire(
*ppNode = 0;
/* If unable to open an sqlite3_blob on the desired row, that can only
** be because the shadow tables hold erroneous data. */
- if( rc==SQLITE_ERROR ) rc = SQLITE_CORRUPT_VTAB;
+ if( rc==SQLITE_ERROR ){
+ rc = SQLITE_CORRUPT_VTAB;
+ RTREE_IS_CORRUPT(pRtree);
+ }
}else if( pRtree->iNodeSize==sqlite3_blob_bytes(pRtree->pNodeBlob) ){
- pNode = (RtreeNode *)sqlite3_malloc(sizeof(RtreeNode)+pRtree->iNodeSize);
+ pNode = (RtreeNode *)sqlite3_malloc64(sizeof(RtreeNode)+pRtree->iNodeSize);
if( !pNode ){
rc = SQLITE_NOMEM;
}else{
@@ -179596,7 +180635,6 @@ static int nodeAcquire(
pNode->pNext = 0;
rc = sqlite3_blob_read(pRtree->pNodeBlob, pNode->zData,
pRtree->iNodeSize, 0);
- nodeReference(pParent);
}
}
@@ -179610,6 +180648,7 @@ static int nodeAcquire(
pRtree->iDepth = readInt16(pNode->zData);
if( pRtree->iDepth>RTREE_MAX_DEPTH ){
rc = SQLITE_CORRUPT_VTAB;
+ RTREE_IS_CORRUPT(pRtree);
}
}
@@ -179620,14 +180659,17 @@ static int nodeAcquire(
if( pNode && rc==SQLITE_OK ){
if( NCELL(pNode)>((pRtree->iNodeSize-4)/pRtree->nBytesPerCell) ){
rc = SQLITE_CORRUPT_VTAB;
+ RTREE_IS_CORRUPT(pRtree);
}
}
if( rc==SQLITE_OK ){
if( pNode!=0 ){
+ nodeReference(pParent);
nodeHashInsert(pRtree, pNode);
}else{
rc = SQLITE_CORRUPT_VTAB;
+ RTREE_IS_CORRUPT(pRtree);
}
*ppNode = pNode;
}else{
@@ -179853,7 +180895,7 @@ static void rtreeRelease(Rtree *pRtree){
pRtree->inWrTrans = 0;
assert( pRtree->nCursor==0 );
nodeBlobReset(pRtree);
- assert( pRtree->nNodeRef==0 );
+ assert( pRtree->nNodeRef==0 || pRtree->bCorrupt );
sqlite3_finalize(pRtree->pWriteNode);
sqlite3_finalize(pRtree->pDeleteNode);
sqlite3_finalize(pRtree->pReadRowid);
@@ -179912,7 +180954,7 @@ static int rtreeOpen(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){
Rtree *pRtree = (Rtree *)pVTab;
RtreeCursor *pCsr;
- pCsr = (RtreeCursor *)sqlite3_malloc(sizeof(RtreeCursor));
+ pCsr = (RtreeCursor *)sqlite3_malloc64(sizeof(RtreeCursor));
if( pCsr ){
memset(pCsr, 0, sizeof(RtreeCursor));
pCsr->base.pVtab = pVTab;
@@ -180185,6 +181227,7 @@ static int nodeRowidIndex(
return SQLITE_OK;
}
}
+ RTREE_IS_CORRUPT(pRtree);
return SQLITE_CORRUPT_VTAB;
}
@@ -180278,7 +181321,7 @@ static RtreeSearchPoint *rtreeEnqueue(
RtreeSearchPoint *pNew;
if( pCur->nPoint>=pCur->nPointAlloc ){
int nNew = pCur->nPointAlloc*2 + 8;
- pNew = sqlite3_realloc(pCur->aPoint, nNew*sizeof(pCur->aPoint[0]));
+ pNew = sqlite3_realloc64(pCur->aPoint, nNew*sizeof(pCur->aPoint[0]));
if( pNew==0 ) return 0;
pCur->aPoint = pNew;
pCur->nPointAlloc = nNew;
@@ -180680,7 +181723,7 @@ static int rtreeFilter(
*/
rc = nodeAcquire(pRtree, 1, 0, &pRoot);
if( rc==SQLITE_OK && argc>0 ){
- pCsr->aConstraint = sqlite3_malloc(sizeof(RtreeConstraint)*argc);
+ pCsr->aConstraint = sqlite3_malloc64(sizeof(RtreeConstraint)*argc);
pCsr->nConstraint = argc;
if( !pCsr->aConstraint ){
rc = SQLITE_NOMEM;
@@ -180825,20 +181868,20 @@ static int rtreeBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){
){
u8 op;
switch( p->op ){
- case SQLITE_INDEX_CONSTRAINT_EQ: op = RTREE_EQ; break;
- case SQLITE_INDEX_CONSTRAINT_GT: op = RTREE_GT; break;
- case SQLITE_INDEX_CONSTRAINT_LE: op = RTREE_LE; break;
- case SQLITE_INDEX_CONSTRAINT_LT: op = RTREE_LT; break;
- case SQLITE_INDEX_CONSTRAINT_GE: op = RTREE_GE; break;
- default:
- assert( p->op==SQLITE_INDEX_CONSTRAINT_MATCH );
- op = RTREE_MATCH;
- break;
+ case SQLITE_INDEX_CONSTRAINT_EQ: op = RTREE_EQ; break;
+ case SQLITE_INDEX_CONSTRAINT_GT: op = RTREE_GT; break;
+ case SQLITE_INDEX_CONSTRAINT_LE: op = RTREE_LE; break;
+ case SQLITE_INDEX_CONSTRAINT_LT: op = RTREE_LT; break;
+ case SQLITE_INDEX_CONSTRAINT_GE: op = RTREE_GE; break;
+ case SQLITE_INDEX_CONSTRAINT_MATCH: op = RTREE_MATCH; break;
+ default: op = 0; break;
+ }
+ if( op ){
+ zIdxStr[iIdx++] = op;
+ zIdxStr[iIdx++] = (char)(p->iColumn - 1 + '0');
+ pIdxInfo->aConstraintUsage[ii].argvIndex = (iIdx/2);
+ pIdxInfo->aConstraintUsage[ii].omit = 1;
}
- zIdxStr[iIdx++] = op;
- zIdxStr[iIdx++] = (char)(p->iColumn - 1 + '0');
- pIdxInfo->aConstraintUsage[ii].argvIndex = (iIdx/2);
- pIdxInfo->aConstraintUsage[ii].omit = 1;
}
}
@@ -180874,11 +181917,11 @@ static RtreeDValue cellArea(Rtree *pRtree, RtreeCell *p){
#endif
{
switch( pRtree->nDim ){
- case 5: area = p->aCoord[9].i - p->aCoord[8].i;
- case 4: area *= p->aCoord[7].i - p->aCoord[6].i;
- case 3: area *= p->aCoord[5].i - p->aCoord[4].i;
- case 2: area *= p->aCoord[3].i - p->aCoord[2].i;
- default: area *= p->aCoord[1].i - p->aCoord[0].i;
+ case 5: area = (i64)p->aCoord[9].i - (i64)p->aCoord[8].i;
+ case 4: area *= (i64)p->aCoord[7].i - (i64)p->aCoord[6].i;
+ case 3: area *= (i64)p->aCoord[5].i - (i64)p->aCoord[4].i;
+ case 2: area *= (i64)p->aCoord[3].i - (i64)p->aCoord[2].i;
+ default: area *= (i64)p->aCoord[1].i - (i64)p->aCoord[0].i;
}
}
return area;
@@ -181047,12 +182090,14 @@ static int AdjustTree(
RtreeCell *pCell /* This cell was just inserted */
){
RtreeNode *p = pNode;
+ int cnt = 0;
while( p->pParent ){
RtreeNode *pParent = p->pParent;
RtreeCell cell;
int iCell;
- if( nodeParentIndex(pRtree, p, &iCell) ){
+ if( (++cnt)>1000 || nodeParentIndex(pRtree, p, &iCell) ){
+ RTREE_IS_CORRUPT(pRtree);
return SQLITE_CORRUPT_VTAB;
}
@@ -181249,9 +182294,9 @@ static int splitNodeStartree(
int iBestSplit = 0;
RtreeDValue fBestMargin = RTREE_ZERO;
- int nByte = (pRtree->nDim+1)*(sizeof(int*)+nCell*sizeof(int));
+ sqlite3_int64 nByte = (pRtree->nDim+1)*(sizeof(int*)+nCell*sizeof(int));
- aaSorted = (int **)sqlite3_malloc(nByte);
+ aaSorted = (int **)sqlite3_malloc64(nByte);
if( !aaSorted ){
return SQLITE_NOMEM;
}
@@ -181372,7 +182417,7 @@ static int SplitNode(
/* Allocate an array and populate it with a copy of pCell and
** all cells from node pLeft. Then zero the original node.
*/
- aCell = sqlite3_malloc((sizeof(RtreeCell)+sizeof(int))*(nCell+1));
+ aCell = sqlite3_malloc64((sizeof(RtreeCell)+sizeof(int))*(nCell+1));
if( !aCell ){
rc = SQLITE_NOMEM;
goto splitnode_out;
@@ -181520,7 +182565,10 @@ static int fixLeafParent(Rtree *pRtree, RtreeNode *pLeaf){
}
rc = sqlite3_reset(pRtree->pReadParent);
if( rc==SQLITE_OK ) rc = rc2;
- if( rc==SQLITE_OK && !pChild->pParent ) rc = SQLITE_CORRUPT_VTAB;
+ if( rc==SQLITE_OK && !pChild->pParent ){
+ RTREE_IS_CORRUPT(pRtree);
+ rc = SQLITE_CORRUPT_VTAB;
+ }
pChild = pChild->pParent;
}
return rc;
@@ -181660,7 +182708,7 @@ static int Reinsert(
/* Allocate the buffers used by this operation. The allocation is
** relinquished before this function returns.
*/
- aCell = (RtreeCell *)sqlite3_malloc(n * (
+ aCell = (RtreeCell *)sqlite3_malloc64(n * (
sizeof(RtreeCell) + /* aCell array */
sizeof(int) + /* aOrder array */
sizeof(int) + /* aSpare array */
@@ -181834,8 +182882,12 @@ static int rtreeDeleteRowid(Rtree *pRtree, sqlite3_int64 iDelete){
rc = findLeafNode(pRtree, iDelete, &pLeaf, 0);
}
+#ifdef CORRUPT_DB
+ assert( pLeaf!=0 || rc!=SQLITE_OK || CORRUPT_DB );
+#endif
+
/* Delete the cell in question from the leaf node. */
- if( rc==SQLITE_OK ){
+ if( rc==SQLITE_OK && pLeaf ){
int rc2;
rc = nodeRowidIndex(pRtree, pLeaf, iDelete, &iCell);
if( rc==SQLITE_OK ){
@@ -182107,7 +183159,7 @@ static int rtreeUpdate(
rc = rc2;
}
}
- if( pRtree->nAux ){
+ if( rc==SQLITE_OK && pRtree->nAux ){
sqlite3_stmt *pUp = pRtree->pWriteAux;
int jj;
sqlite3_bind_int64(pUp, 1, *pRowid);
@@ -182468,6 +183520,7 @@ static int getNodeSize(
*pzErr = sqlite3_mprintf("%s", sqlite3_errmsg(db));
}else if( pRtree->iNodeSize<(512-64) ){
rc = SQLITE_CORRUPT_VTAB;
+ RTREE_IS_CORRUPT(pRtree);
*pzErr = sqlite3_mprintf("undersize RTree blobs in \"%q_node\"",
pRtree->zName);
}
@@ -182523,7 +183576,7 @@ static int rtreeInit(
/* Allocate the sqlite3_vtab structure */
nDb = (int)strlen(argv[1]);
nName = (int)strlen(argv[2]);
- pRtree = (Rtree *)sqlite3_malloc(sizeof(Rtree)+nDb+nName+2);
+ pRtree = (Rtree *)sqlite3_malloc64(sizeof(Rtree)+nDb+nName+2);
if( !pRtree ){
return SQLITE_NOMEM;
}
@@ -182791,8 +183844,7 @@ static void rtreeCheckAppendMsg(RtreeCheck *pCheck, const char *zFmt, ...){
static u8 *rtreeCheckGetNode(RtreeCheck *pCheck, i64 iNode, int *pnNode){
u8 *pRet = 0; /* Return value */
- assert( pCheck->rc==SQLITE_OK );
- if( pCheck->pGetNode==0 ){
+ if( pCheck->rc==SQLITE_OK && pCheck->pGetNode==0 ){
pCheck->pGetNode = rtreeCheckPrepare(pCheck,
"SELECT data FROM %Q.'%q_node' WHERE nodeno=?",
pCheck->zDb, pCheck->zTab
@@ -182804,7 +183856,7 @@ static u8 *rtreeCheckGetNode(RtreeCheck *pCheck, i64 iNode, int *pnNode){
if( sqlite3_step(pCheck->pGetNode)==SQLITE_ROW ){
int nNode = sqlite3_column_bytes(pCheck->pGetNode, 0);
const u8 *pNode = (const u8*)sqlite3_column_blob(pCheck->pGetNode, 0);
- pRet = sqlite3_malloc(nNode);
+ pRet = sqlite3_malloc64(nNode);
if( pRet==0 ){
pCheck->rc = SQLITE_NOMEM;
}else{
@@ -183283,6 +184335,14 @@ struct GeoPoly {
*/
#define GEOPOLY_SZ(N) (sizeof(GeoPoly) + sizeof(GeoCoord)*2*((N)-4))
+/* Macros to access coordinates of a GeoPoly.
+** We have to use these macros, rather than just say p->a[i] in order
+** to silence (incorrect) UBSAN warnings if the array index is too large.
+*/
+#define GeoX(P,I) (((GeoCoord*)(P)->a)[(I)*2])
+#define GeoY(P,I) (((GeoCoord*)(P)->a)[(I)*2+1])
+
+
/*
** State of a parse of a GeoJSON input.
*/
@@ -183475,8 +184535,9 @@ static GeoPoly *geopolyFuncParam(
memcpy(p->hdr, a, nByte);
if( a[0] != *(unsigned char*)&x ){
int ii;
- for(ii=0; ii<nVertex*2; ii++){
- geopolySwab32((unsigned char*)&p->a[ii]);
+ for(ii=0; ii<nVertex; ii++){
+ geopolySwab32((unsigned char*)&GeoX(p,ii));
+ geopolySwab32((unsigned char*)&GeoY(p,ii));
}
p->hdr[0] ^= 1;
}
@@ -183535,9 +184596,9 @@ static void geopolyJsonFunc(
int i;
sqlite3_str_append(x, "[", 1);
for(i=0; i<p->nVertex; i++){
- sqlite3_str_appendf(x, "[%!g,%!g],", p->a[i*2], p->a[i*2+1]);
+ sqlite3_str_appendf(x, "[%!g,%!g],", GeoX(p,i), GeoY(p,i));
}
- sqlite3_str_appendf(x, "[%!g,%!g]]", p->a[0], p->a[1]);
+ sqlite3_str_appendf(x, "[%!g,%!g]]", GeoX(p,0), GeoY(p,0));
sqlite3_result_text(context, sqlite3_str_finish(x), -1, sqlite3_free);
sqlite3_free(p);
}
@@ -183554,7 +184615,9 @@ static void geopolySvgFunc(
int argc,
sqlite3_value **argv
){
- GeoPoly *p = geopolyFuncParam(context, argv[0], 0);
+ GeoPoly *p;
+ if( argc<1 ) return;
+ p = geopolyFuncParam(context, argv[0], 0);
if( p ){
sqlite3 *db = sqlite3_context_db_handle(context);
sqlite3_str *x = sqlite3_str_new(db);
@@ -183562,10 +184625,10 @@ static void geopolySvgFunc(
char cSep = '\'';
sqlite3_str_appendf(x, "<polyline points=");
for(i=0; i<p->nVertex; i++){
- sqlite3_str_appendf(x, "%c%g,%g", cSep, p->a[i*2], p->a[i*2+1]);
+ sqlite3_str_appendf(x, "%c%g,%g", cSep, GeoX(p,i), GeoY(p,i));
cSep = ' ';
}
- sqlite3_str_appendf(x, " %g,%g'", p->a[0], p->a[1]);
+ sqlite3_str_appendf(x, " %g,%g'", GeoX(p,0), GeoY(p,0));
for(i=1; i<argc; i++){
const char *z = (const char*)sqlite3_value_text(argv[i]);
if( z && z[0] ){
@@ -183610,12 +184673,12 @@ static void geopolyXformFunc(
int ii;
if( p ){
for(ii=0; ii<p->nVertex; ii++){
- x0 = p->a[ii*2];
- y0 = p->a[ii*2+1];
+ x0 = GeoX(p,ii);
+ y0 = GeoY(p,ii);
x1 = (GeoCoord)(A*x0 + B*y0 + E);
y1 = (GeoCoord)(C*x0 + D*y0 + F);
- p->a[ii*2] = x1;
- p->a[ii*2+1] = y1;
+ GeoX(p,ii) = x1;
+ GeoY(p,ii) = y1;
}
sqlite3_result_blob(context, p->hdr,
4+8*p->nVertex, SQLITE_TRANSIENT);
@@ -183634,12 +184697,12 @@ static double geopolyArea(GeoPoly *p){
double rArea = 0.0;
int ii;
for(ii=0; ii<p->nVertex-1; ii++){
- rArea += (p->a[ii*2] - p->a[ii*2+2]) /* (x0 - x1) */
- * (p->a[ii*2+1] + p->a[ii*2+3]) /* (y0 + y1) */
+ rArea += (GeoX(p,ii) - GeoX(p,ii+1)) /* (x0 - x1) */
+ * (GeoY(p,ii) + GeoY(p,ii+1)) /* (y0 + y1) */
* 0.5;
}
- rArea += (p->a[ii*2] - p->a[0]) /* (xN - x0) */
- * (p->a[ii*2+1] + p->a[1]) /* (yN + y0) */
+ rArea += (GeoX(p,ii) - GeoX(p,0)) /* (xN - x0) */
+ * (GeoY(p,ii) + GeoY(p,0)) /* (yN + y0) */
* 0.5;
return rArea;
}
@@ -183686,13 +184749,13 @@ static void geopolyCcwFunc(
if( p ){
if( geopolyArea(p)<0.0 ){
int ii, jj;
- for(ii=2, jj=p->nVertex*2 - 2; ii<jj; ii+=2, jj-=2){
- GeoCoord t = p->a[ii];
- p->a[ii] = p->a[jj];
- p->a[jj] = t;
- t = p->a[ii+1];
- p->a[ii+1] = p->a[jj+1];
- p->a[jj+1] = t;
+ for(ii=1, jj=p->nVertex-1; ii<jj; ii++, jj--){
+ GeoCoord t = GeoX(p,ii);
+ GeoX(p,ii) = GeoX(p,jj);
+ GeoX(p,jj) = t;
+ t = GeoY(p,ii);
+ GeoY(p,ii) = GeoY(p,jj);
+ GeoY(p,jj) = t;
}
}
sqlite3_result_blob(context, p->hdr,
@@ -183752,8 +184815,8 @@ static void geopolyRegularFunc(
p->hdr[3] = n&0xff;
for(i=0; i<n; i++){
double rAngle = 2.0*GEOPOLY_PI*i/n;
- p->a[i*2] = x - r*geopolySine(rAngle-0.5*GEOPOLY_PI);
- p->a[i*2+1] = y + r*geopolySine(rAngle);
+ GeoX(p,i) = x - r*geopolySine(rAngle-0.5*GEOPOLY_PI);
+ GeoY(p,i) = y + r*geopolySine(rAngle);
}
sqlite3_result_blob(context, p->hdr, 4+8*n, SQLITE_TRANSIENT);
sqlite3_free(p);
@@ -183790,13 +184853,13 @@ static GeoPoly *geopolyBBox(
}
if( p ){
int ii;
- mnX = mxX = p->a[0];
- mnY = mxY = p->a[1];
+ mnX = mxX = GeoX(p,0);
+ mnY = mxY = GeoY(p,0);
for(ii=1; ii<p->nVertex; ii++){
- double r = p->a[ii*2];
+ double r = GeoX(p,ii);
if( r<mnX ) mnX = (float)r;
else if( r>mxX ) mxX = (float)r;
- r = p->a[ii*2+1];
+ r = GeoY(p,ii);
if( r<mnY ) mnY = (float)r;
else if( r>mxY ) mxY = (float)r;
}
@@ -183816,14 +184879,14 @@ static GeoPoly *geopolyBBox(
pOut->hdr[1] = 0;
pOut->hdr[2] = 0;
pOut->hdr[3] = 4;
- pOut->a[0] = mnX;
- pOut->a[1] = mnY;
- pOut->a[2] = mxX;
- pOut->a[3] = mnY;
- pOut->a[4] = mxX;
- pOut->a[5] = mxY;
- pOut->a[6] = mnX;
- pOut->a[7] = mxY;
+ GeoX(pOut,0) = mnX;
+ GeoY(pOut,0) = mnY;
+ GeoX(pOut,1) = mxX;
+ GeoY(pOut,1) = mnY;
+ GeoX(pOut,2) = mxX;
+ GeoY(pOut,2) = mxY;
+ GeoX(pOut,3) = mnX;
+ GeoY(pOut,3) = mxY;
}else{
sqlite3_free(p);
aCoord[0].f = mnX;
@@ -183961,14 +185024,14 @@ static void geopolyContainsPointFunc(
int ii;
if( p1==0 ) return;
for(ii=0; ii<p1->nVertex-1; ii++){
- v = pointBeneathLine(x0,y0,p1->a[ii*2],p1->a[ii*2+1],
- p1->a[ii*2+2],p1->a[ii*2+3]);
+ v = pointBeneathLine(x0,y0,GeoX(p1,ii), GeoY(p1,ii),
+ GeoX(p1,ii+1),GeoY(p1,ii+1));
if( v==2 ) break;
cnt += v;
}
if( v!=2 ){
- v = pointBeneathLine(x0,y0,p1->a[ii*2],p1->a[ii*2+1],
- p1->a[0],p1->a[1]);
+ v = pointBeneathLine(x0,y0,GeoX(p1,ii), GeoY(p1,ii),
+ GeoX(p1,0), GeoY(p1,0));
}
if( v==2 ){
sqlite3_result_int(context, 1);
@@ -184090,10 +185153,10 @@ static void geopolyAddSegments(
unsigned int i;
GeoCoord *x;
for(i=0; i<(unsigned)pPoly->nVertex-1; i++){
- x = pPoly->a + (i*2);
+ x = &GeoX(pPoly,i);
geopolyAddOneSegment(p, x[0], x[1], x[2], x[3], side, i);
}
- x = pPoly->a + (i*2);
+ x = &GeoX(pPoly,i);
geopolyAddOneSegment(p, x[0], x[1], pPoly->a[0], pPoly->a[1], side, i);
}
@@ -185038,12 +186101,12 @@ static void rtreeMatchArgFree(void *pArg){
static void geomCallback(sqlite3_context *ctx, int nArg, sqlite3_value **aArg){
RtreeGeomCallback *pGeomCtx = (RtreeGeomCallback *)sqlite3_user_data(ctx);
RtreeMatchArg *pBlob;
- int nBlob;
+ sqlite3_int64 nBlob;
int memErr = 0;
nBlob = sizeof(RtreeMatchArg) + (nArg-1)*sizeof(RtreeDValue)
+ nArg*sizeof(sqlite3_value*);
- pBlob = (RtreeMatchArg *)sqlite3_malloc(nBlob);
+ pBlob = (RtreeMatchArg *)sqlite3_malloc64(nBlob);
if( !pBlob ){
sqlite3_result_error_nomem(ctx);
}else{
@@ -185754,7 +186817,7 @@ static int icuCreate(
if( argc>0 ){
n = strlen(argv[0])+1;
}
- p = (IcuTokenizer *)sqlite3_malloc(sizeof(IcuTokenizer)+n);
+ p = (IcuTokenizer *)sqlite3_malloc64(sizeof(IcuTokenizer)+n);
if( !p ){
return SQLITE_NOMEM;
}
@@ -185811,7 +186874,7 @@ static int icuOpen(
nInput = strlen(zInput);
}
nChar = nInput+1;
- pCsr = (IcuCursor *)sqlite3_malloc(
+ pCsr = (IcuCursor *)sqlite3_malloc64(
sizeof(IcuCursor) + /* IcuCursor */
((nChar+3)&~3) * sizeof(UChar) + /* IcuCursor.aChar[] */
(nChar+1) * sizeof(int) /* IcuCursor.aOffset[] */
@@ -186385,6 +187448,10 @@ SQLITE_API sqlite3rbu *sqlite3rbu_open(
** state database is not already present in the file-system, it is created
** with the same permissions as the target db is made.
**
+** With an RBU vacuum, it is an SQLITE_MISUSE error if the name of the
+** state database ends with "-vactmp". This name is reserved for internal
+** use.
+**
** This function does not delete the state database after an RBU vacuum
** is completed, even if it created it. However, if the call to
** sqlite3rbu_close() returns any value other than SQLITE_OK, the contents
@@ -189041,7 +190108,7 @@ static void rbuOpenDatabase(sqlite3rbu *p, int *pbRetry){
if( *zExtra=='\0' ) zExtra = 0;
}
- zTarget = sqlite3_mprintf("file:%s-vacuum?rbu_memory=1%s%s",
+ zTarget = sqlite3_mprintf("file:%s-vactmp?rbu_memory=1%s%s",
sqlite3_db_filename(p->dbRbu, "main"),
(zExtra==0 ? "" : "&"), (zExtra==0 ? "" : zExtra)
);
@@ -190307,6 +191374,12 @@ SQLITE_API sqlite3rbu *sqlite3rbu_vacuum(
const char *zState
){
if( zTarget==0 ){ return rbuMisuseError(); }
+ if( zState ){
+ int n = strlen(zState);
+ if( n>=7 && 0==memcmp("-vactmp", &zState[n-7], 7) ){
+ return rbuMisuseError();
+ }
+ }
/* TODO: Check that both arguments are non-NULL */
return openRbuHandle(0, zTarget, zState);
}
@@ -190503,7 +191576,10 @@ SQLITE_API int sqlite3rbu_savestate(sqlite3rbu *p){
if( p->eStage==RBU_STAGE_OAL ){
assert( rc!=SQLITE_DONE );
if( rc==SQLITE_OK ) rc = sqlite3_exec(p->dbRbu, "COMMIT", 0, 0, 0);
- if( rc==SQLITE_OK ) rc = sqlite3_exec(p->dbRbu, "BEGIN IMMEDIATE", 0, 0, 0);
+ if( rc==SQLITE_OK ){
+ const char *zBegin = rbuIsVacuum(p) ? "BEGIN" : "BEGIN IMMEDIATE";
+ rc = sqlite3_exec(p->dbRbu, zBegin, 0, 0, 0);
+ }
if( rc==SQLITE_OK ) rc = sqlite3_exec(p->dbMain, "BEGIN IMMEDIATE", 0, 0,0);
}
@@ -192034,6 +193110,10 @@ statNextRestart:
goto statNextRestart; /* Tail recursion */
}
pCsr->iPage++;
+ if( pCsr->iPage>=ArraySize(pCsr->aPage) ){
+ statResetCsr(pCsr);
+ return SQLITE_CORRUPT_BKPT;
+ }
assert( p==&pCsr->aPage[pCsr->iPage-1] );
if( p->iCell==p->nCell ){
@@ -192105,7 +193185,6 @@ static int statFilter(
StatTable *pTab = (StatTable*)(pCursor->pVtab);
char *zSql;
int rc = SQLITE_OK;
- char *zMaster;
if( idxNum==1 ){
const char *zDbase = (const char*)sqlite3_value_text(argv[0]);
@@ -192121,13 +193200,12 @@ static int statFilter(
statResetCsr(pCsr);
sqlite3_finalize(pCsr->pStmt);
pCsr->pStmt = 0;
- zMaster = pCsr->iDb==1 ? "sqlite_temp_master" : "sqlite_master";
zSql = sqlite3_mprintf(
"SELECT 'sqlite_master' AS name, 1 AS rootpage, 'table' AS type"
" UNION ALL "
"SELECT name, rootpage, type"
- " FROM \"%w\".%s WHERE rootpage!=0"
- " ORDER BY name", pTab->db->aDb[pCsr->iDb].zDbSName, zMaster);
+ " FROM \"%w\".sqlite_master WHERE rootpage!=0"
+ " ORDER BY name", pTab->db->aDb[pCsr->iDb].zDbSName);
if( zSql==0 ){
return SQLITE_NOMEM_BKPT;
}else{
@@ -193015,7 +194093,7 @@ static void sessionPutI64(u8 *aBuf, sqlite3_int64 i){
static int sessionSerializeValue(
u8 *aBuf, /* If non-NULL, write serialized value here */
sqlite3_value *pValue, /* Value to serialize */
- int *pnWrite /* IN/OUT: Increment by bytes written */
+ sqlite3_int64 *pnWrite /* IN/OUT: Increment by bytes written */
){
int nByte; /* Size of serialized value in bytes */
@@ -193556,7 +194634,7 @@ static int sessionGrowHash(int bPatchset, SessionTable *pTab){
SessionChange **apNew;
int nNew = (pTab->nChange ? pTab->nChange : 128) * 2;
- apNew = (SessionChange **)sqlite3_malloc(sizeof(SessionChange *) * nNew);
+ apNew = (SessionChange **)sqlite3_malloc64(sizeof(SessionChange *) * nNew);
if( apNew==0 ){
if( pTab->nChange==0 ){
return SQLITE_ERROR;
@@ -193622,7 +194700,7 @@ static int sessionTableInfo(
char *zPragma;
sqlite3_stmt *pStmt;
int rc;
- int nByte;
+ sqlite3_int64 nByte;
int nDbCol = 0;
int nThis;
int i;
@@ -193665,7 +194743,7 @@ static int sessionTableInfo(
if( rc==SQLITE_OK ){
nByte += nDbCol * (sizeof(const char *) + sizeof(u8) + 1);
- pAlloc = sqlite3_malloc(nByte);
+ pAlloc = sqlite3_malloc64(nByte);
if( pAlloc==0 ){
rc = SQLITE_NOMEM;
}
@@ -193806,7 +194884,7 @@ static void sessionPreupdateOneChange(
int iHash;
int bNull = 0;
int rc = SQLITE_OK;
- SessionStat1Ctx stat1 = {0};
+ SessionStat1Ctx stat1 = {{0,0,0,0,0},0};
if( pSession->rc ) return;
@@ -193863,7 +194941,7 @@ static void sessionPreupdateOneChange(
** this is an SQLITE_UPDATE or SQLITE_DELETE), or just the PK
** values (if this is an INSERT). */
SessionChange *pChange; /* New change object */
- int nByte; /* Number of bytes to allocate */
+ sqlite3_int64 nByte; /* Number of bytes to allocate */
int i; /* Used to iterate through columns */
assert( rc==SQLITE_OK );
@@ -193888,7 +194966,7 @@ static void sessionPreupdateOneChange(
}
/* Allocate the change object */
- pChange = (SessionChange *)sqlite3_malloc(nByte);
+ pChange = (SessionChange *)sqlite3_malloc64(nByte);
if( !pChange ){
rc = SQLITE_NOMEM;
goto error_out;
@@ -194332,7 +195410,7 @@ SQLITE_API int sqlite3session_create(
*ppSession = 0;
/* Allocate and populate the new session object. */
- pNew = (sqlite3_session *)sqlite3_malloc(sizeof(sqlite3_session) + nDb + 1);
+ pNew = (sqlite3_session *)sqlite3_malloc64(sizeof(sqlite3_session) + nDb + 1);
if( !pNew ) return SQLITE_NOMEM;
memset(pNew, 0, sizeof(sqlite3_session));
pNew->db = db;
@@ -194451,7 +195529,7 @@ SQLITE_API int sqlite3session_attach(
if( !pTab ){
/* Allocate new SessionTable object. */
- pTab = (SessionTable *)sqlite3_malloc(sizeof(SessionTable) + nName + 1);
+ pTab = (SessionTable *)sqlite3_malloc64(sizeof(SessionTable) + nName + 1);
if( !pTab ){
rc = SQLITE_NOMEM;
}else{
@@ -194511,7 +195589,7 @@ static int sessionBufferGrow(SessionBuffer *p, int nByte, int *pRc){
static void sessionAppendValue(SessionBuffer *p, sqlite3_value *pVal, int *pRc){
int rc = *pRc;
if( rc==SQLITE_OK ){
- int nByte = 0;
+ sqlite3_int64 nByte = 0;
rc = sessionSerializeValue(0, pVal, &nByte);
sessionBufferGrow(p, nByte, &rc);
if( rc==SQLITE_OK ){
@@ -195387,7 +196465,7 @@ static int sessionValueSetStr(
** argument to sqlite3ValueSetStr() and have the copy created
** automatically. But doing so makes it difficult to detect any OOM
** error. Hence the code to create the copy externally. */
- u8 *aCopy = sqlite3_malloc(nData+1);
+ u8 *aCopy = sqlite3_malloc64((sqlite3_int64)nData+1);
if( aCopy==0 ) return SQLITE_NOMEM;
memcpy(aCopy, aData, nData);
sqlite3ValueSetStr(pVal, nData, (char*)aCopy, enc, sqlite3_free);
@@ -196000,7 +197078,7 @@ static int sessionChangesetInvert(
int iCol;
if( 0==apVal ){
- apVal = (sqlite3_value **)sqlite3_malloc(sizeof(apVal[0])*nCol*2);
+ apVal = (sqlite3_value **)sqlite3_malloc64(sizeof(apVal[0])*nCol*2);
if( 0==apVal ){
rc = SQLITE_NOMEM;
goto finished_invert;
@@ -197273,7 +198351,7 @@ static int sessionChangeMerge(
int rc = SQLITE_OK;
if( !pExist ){
- pNew = (SessionChange *)sqlite3_malloc(sizeof(SessionChange) + nRec);
+ pNew = (SessionChange *)sqlite3_malloc64(sizeof(SessionChange) + nRec);
if( !pNew ){
return SQLITE_NOMEM;
}
@@ -197306,8 +198384,8 @@ static int sessionChangeMerge(
if( pExist->op==SQLITE_DELETE && pExist->bIndirect ){
*ppNew = pExist;
}else{
- int nByte = nRec + pExist->nRecord + sizeof(SessionChange);
- pNew = (SessionChange*)sqlite3_malloc(nByte);
+ sqlite3_int64 nByte = nRec + pExist->nRecord + sizeof(SessionChange);
+ pNew = (SessionChange*)sqlite3_malloc64(nByte);
if( pNew==0 ){
rc = SQLITE_NOMEM;
}else{
@@ -197367,14 +198445,14 @@ static int sessionChangeMerge(
assert( pNew==0 );
}else{
u8 *aExist = pExist->aRecord;
- int nByte;
+ sqlite3_int64 nByte;
u8 *aCsr;
/* Allocate a new SessionChange object. Ensure that the aRecord[]
** buffer of the new object is large enough to hold any record that
** may be generated by combining the input records. */
nByte = sizeof(SessionChange) + pExist->nRecord + nRec;
- pNew = (SessionChange *)sqlite3_malloc(nByte);
+ pNew = (SessionChange *)sqlite3_malloc64(nByte);
if( !pNew ){
sqlite3_free(pExist);
return SQLITE_NOMEM;
@@ -197480,7 +198558,7 @@ static int sessionChangesetToHash(
if( !pTab ){
SessionTable **ppTab;
- pTab = sqlite3_malloc(sizeof(SessionTable) + nCol + nNew+1);
+ pTab = sqlite3_malloc64(sizeof(SessionTable) + nCol + nNew+1);
if( !pTab ){
rc = SQLITE_NOMEM;
break;
@@ -198254,12 +199332,8 @@ struct Fts5PhraseIter {
**
** Usually, output parameter *piPhrase is set to the phrase number, *piCol
** to the column in which it occurs and *piOff the token offset of the
-** first token of the phrase. The exception is if the table was created
-** with the offsets=0 option specified. In this case *piOff is always
-** set to -1.
-**
-** Returns SQLITE_OK if successful, or an error code (i.e. SQLITE_NOMEM)
-** if an error occurs.
+** first token of the phrase. Returns SQLITE_OK if successful, or an error
+** code (i.e. SQLITE_NOMEM) if an error occurs.
**
** This API can be quite slow if used with an FTS5 table created with the
** "detail=none" or "detail=column" option.
@@ -198548,11 +199622,11 @@ struct Fts5ExtensionApi {
** the tokenizer substitutes "first" for "1st" and the query works
** as expected.
**
-** <li> By adding multiple synonyms for a single term to the FTS index.
-** In this case, when tokenizing query text, the tokenizer may
-** provide multiple synonyms for a single term within the document.
-** FTS5 then queries the index for each synonym individually. For
-** example, faced with the query:
+** <li> By querying the index for all synonyms of each query term
+** separately. In this case, when tokenizing query text, the
+** tokenizer may provide multiple synonyms for a single term
+** within the document. FTS5 then queries the index for each
+** synonym individually. For example, faced with the query:
**
** <codeblock>
** ... MATCH 'first place'</codeblock>
@@ -198576,7 +199650,7 @@ struct Fts5ExtensionApi {
** "place".
**
** This way, even if the tokenizer does not provide synonyms
-** when tokenizing query text (it should not - to do would be
+** when tokenizing query text (it should not - to do so would be
** inefficient), it doesn't matter if the user queries for
** 'first + place' or '1st + place', as there are entries in the
** FTS index corresponding to both forms of the first token.
@@ -198801,6 +199875,12 @@ SQLITE_API extern int sqlite3_fts5_may_be_corrupt;
# define assert_nc(x) assert(x)
#endif
+/*
+** A version of memcmp() that does not cause asan errors if one of the pointer
+** parameters is NULL and the number of bytes to compare is zero.
+*/
+#define fts5Memcmp(s1, s2, n) ((n)==0 ? 0 : memcmp((s1), (s2), (n)))
+
/* Mark a function parameter as unused, to suppress nuisance compiler
** warnings. */
#ifndef UNUSED_PARAM
@@ -198988,7 +200068,7 @@ static void sqlite3Fts5Put32(u8*, int);
static int sqlite3Fts5Get32(const u8*);
#define FTS5_POS2COLUMN(iPos) (int)(iPos >> 32)
-#define FTS5_POS2OFFSET(iPos) (int)(iPos & 0xFFFFFFFF)
+#define FTS5_POS2OFFSET(iPos) (int)(iPos & 0x7FFFFFFF)
typedef struct Fts5PoslistReader Fts5PoslistReader;
struct Fts5PoslistReader {
@@ -199023,7 +200103,7 @@ static int sqlite3Fts5PoslistNext64(
);
/* Malloc utility */
-static void *sqlite3Fts5MallocZero(int *pRc, int nByte);
+static void *sqlite3Fts5MallocZero(int *pRc, sqlite3_int64 nByte);
static char *sqlite3Fts5Strndup(int *pRc, const char *pIn, int nIn);
/* Character set tests (like isspace(), isalpha() etc.) */
@@ -199234,8 +200314,18 @@ static int sqlite3Fts5PutVarint(unsigned char *p, u64 v);
/**************************************************************************
-** Interface to code in fts5.c.
+** Interface to code in fts5_main.c.
+*/
+
+/*
+** Virtual-table object.
*/
+typedef struct Fts5Table Fts5Table;
+struct Fts5Table {
+ sqlite3_vtab base; /* Base class used by SQLite core */
+ Fts5Config *pConfig; /* Virtual table configuration */
+ Fts5Index *pIndex; /* Full-text index */
+};
static int sqlite3Fts5GetTokenizer(
Fts5Global*,
@@ -199246,7 +200336,9 @@ static int sqlite3Fts5GetTokenizer(
char **pzErr
);
-static Fts5Index *sqlite3Fts5IndexFromCsrid(Fts5Global*, i64, Fts5Config **);
+static Fts5Table *sqlite3Fts5TableFromCsrid(Fts5Global*, i64);
+
+static int sqlite3Fts5FlushToDisk(Fts5Table*);
/*
** End of interface to code in fts5.c.
@@ -199502,7 +200594,7 @@ static int sqlite3Fts5UnicodeIsdiacritic(int c);
static int sqlite3Fts5UnicodeFold(int c, int bRemoveDiacritic);
static int sqlite3Fts5UnicodeCatParse(const char*, u8*);
-static int sqlite3Fts5UnicodeCategory(int iCode);
+static int sqlite3Fts5UnicodeCategory(u32 iCode);
static void sqlite3Fts5UnicodeAscii(u8*, u8*);
/*
** End of interface to code in fts5_unicode2.c.
@@ -200406,41 +201498,70 @@ static void fts5yy_shift(
fts5yyTraceShift(fts5yypParser, fts5yyNewState, "Shift");
}
-/* The following table contains information about every rule that
-** is used during the reduce.
-*/
-static const struct {
- fts5YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */
- signed char nrhs; /* Negative of the number of RHS symbols in the rule */
-} fts5yyRuleInfo[] = {
- { 16, -1 }, /* (0) input ::= expr */
- { 20, -4 }, /* (1) colset ::= MINUS LCP colsetlist RCP */
- { 20, -3 }, /* (2) colset ::= LCP colsetlist RCP */
- { 20, -1 }, /* (3) colset ::= STRING */
- { 20, -2 }, /* (4) colset ::= MINUS STRING */
- { 21, -2 }, /* (5) colsetlist ::= colsetlist STRING */
- { 21, -1 }, /* (6) colsetlist ::= STRING */
- { 17, -3 }, /* (7) expr ::= expr AND expr */
- { 17, -3 }, /* (8) expr ::= expr OR expr */
- { 17, -3 }, /* (9) expr ::= expr NOT expr */
- { 17, -5 }, /* (10) expr ::= colset COLON LP expr RP */
- { 17, -3 }, /* (11) expr ::= LP expr RP */
- { 17, -1 }, /* (12) expr ::= exprlist */
- { 19, -1 }, /* (13) exprlist ::= cnearset */
- { 19, -2 }, /* (14) exprlist ::= exprlist cnearset */
- { 18, -1 }, /* (15) cnearset ::= nearset */
- { 18, -3 }, /* (16) cnearset ::= colset COLON nearset */
- { 22, -1 }, /* (17) nearset ::= phrase */
- { 22, -2 }, /* (18) nearset ::= CARET phrase */
- { 22, -5 }, /* (19) nearset ::= STRING LP nearphrases neardist_opt RP */
- { 23, -1 }, /* (20) nearphrases ::= phrase */
- { 23, -2 }, /* (21) nearphrases ::= nearphrases phrase */
- { 25, 0 }, /* (22) neardist_opt ::= */
- { 25, -2 }, /* (23) neardist_opt ::= COMMA STRING */
- { 24, -4 }, /* (24) phrase ::= phrase PLUS STRING star_opt */
- { 24, -2 }, /* (25) phrase ::= STRING star_opt */
- { 26, -1 }, /* (26) star_opt ::= STAR */
- { 26, 0 }, /* (27) star_opt ::= */
+/* For rule J, fts5yyRuleInfoLhs[J] contains the symbol on the left-hand side
+** of that rule */
+static const fts5YYCODETYPE fts5yyRuleInfoLhs[] = {
+ 16, /* (0) input ::= expr */
+ 20, /* (1) colset ::= MINUS LCP colsetlist RCP */
+ 20, /* (2) colset ::= LCP colsetlist RCP */
+ 20, /* (3) colset ::= STRING */
+ 20, /* (4) colset ::= MINUS STRING */
+ 21, /* (5) colsetlist ::= colsetlist STRING */
+ 21, /* (6) colsetlist ::= STRING */
+ 17, /* (7) expr ::= expr AND expr */
+ 17, /* (8) expr ::= expr OR expr */
+ 17, /* (9) expr ::= expr NOT expr */
+ 17, /* (10) expr ::= colset COLON LP expr RP */
+ 17, /* (11) expr ::= LP expr RP */
+ 17, /* (12) expr ::= exprlist */
+ 19, /* (13) exprlist ::= cnearset */
+ 19, /* (14) exprlist ::= exprlist cnearset */
+ 18, /* (15) cnearset ::= nearset */
+ 18, /* (16) cnearset ::= colset COLON nearset */
+ 22, /* (17) nearset ::= phrase */
+ 22, /* (18) nearset ::= CARET phrase */
+ 22, /* (19) nearset ::= STRING LP nearphrases neardist_opt RP */
+ 23, /* (20) nearphrases ::= phrase */
+ 23, /* (21) nearphrases ::= nearphrases phrase */
+ 25, /* (22) neardist_opt ::= */
+ 25, /* (23) neardist_opt ::= COMMA STRING */
+ 24, /* (24) phrase ::= phrase PLUS STRING star_opt */
+ 24, /* (25) phrase ::= STRING star_opt */
+ 26, /* (26) star_opt ::= STAR */
+ 26, /* (27) star_opt ::= */
+};
+
+/* For rule J, fts5yyRuleInfoNRhs[J] contains the negative of the number
+** of symbols on the right-hand side of that rule. */
+static const signed char fts5yyRuleInfoNRhs[] = {
+ -1, /* (0) input ::= expr */
+ -4, /* (1) colset ::= MINUS LCP colsetlist RCP */
+ -3, /* (2) colset ::= LCP colsetlist RCP */
+ -1, /* (3) colset ::= STRING */
+ -2, /* (4) colset ::= MINUS STRING */
+ -2, /* (5) colsetlist ::= colsetlist STRING */
+ -1, /* (6) colsetlist ::= STRING */
+ -3, /* (7) expr ::= expr AND expr */
+ -3, /* (8) expr ::= expr OR expr */
+ -3, /* (9) expr ::= expr NOT expr */
+ -5, /* (10) expr ::= colset COLON LP expr RP */
+ -3, /* (11) expr ::= LP expr RP */
+ -1, /* (12) expr ::= exprlist */
+ -1, /* (13) exprlist ::= cnearset */
+ -2, /* (14) exprlist ::= exprlist cnearset */
+ -1, /* (15) cnearset ::= nearset */
+ -3, /* (16) cnearset ::= colset COLON nearset */
+ -1, /* (17) nearset ::= phrase */
+ -2, /* (18) nearset ::= CARET phrase */
+ -5, /* (19) nearset ::= STRING LP nearphrases neardist_opt RP */
+ -1, /* (20) nearphrases ::= phrase */
+ -2, /* (21) nearphrases ::= nearphrases phrase */
+ 0, /* (22) neardist_opt ::= */
+ -2, /* (23) neardist_opt ::= COMMA STRING */
+ -4, /* (24) phrase ::= phrase PLUS STRING star_opt */
+ -2, /* (25) phrase ::= STRING star_opt */
+ -1, /* (26) star_opt ::= STAR */
+ 0, /* (27) star_opt ::= */
};
static void fts5yy_accept(fts5yyParser*); /* Forward Declaration */
@@ -200472,7 +201593,7 @@ static fts5YYACTIONTYPE fts5yy_reduce(
fts5yymsp = fts5yypParser->fts5yytos;
#ifndef NDEBUG
if( fts5yyTraceFILE && fts5yyruleno<(int)(sizeof(fts5yyRuleName)/sizeof(fts5yyRuleName[0])) ){
- fts5yysize = fts5yyRuleInfo[fts5yyruleno].nrhs;
+ fts5yysize = fts5yyRuleInfoNRhs[fts5yyruleno];
if( fts5yysize ){
fprintf(fts5yyTraceFILE, "%sReduce %d [%s], go to state %d.\n",
fts5yyTracePrompt,
@@ -200487,7 +201608,7 @@ static fts5YYACTIONTYPE fts5yy_reduce(
/* Check that the stack is large enough to grow by a single entry
** if the RHS of the rule is empty. This ensures that there is room
** enough on the stack to push the LHS value */
- if( fts5yyRuleInfo[fts5yyruleno].nrhs==0 ){
+ if( fts5yyRuleInfoNRhs[fts5yyruleno]==0 ){
#ifdef fts5YYTRACKMAXSTACKDEPTH
if( (int)(fts5yypParser->fts5yytos - fts5yypParser->fts5yystack)>fts5yypParser->fts5yyhwm ){
fts5yypParser->fts5yyhwm++;
@@ -200666,9 +201787,9 @@ static fts5YYACTIONTYPE fts5yy_reduce(
break;
/********** End reduce actions ************************************************/
};
- assert( fts5yyruleno<sizeof(fts5yyRuleInfo)/sizeof(fts5yyRuleInfo[0]) );
- fts5yygoto = fts5yyRuleInfo[fts5yyruleno].lhs;
- fts5yysize = fts5yyRuleInfo[fts5yyruleno].nrhs;
+ assert( fts5yyruleno<sizeof(fts5yyRuleInfoLhs)/sizeof(fts5yyRuleInfoLhs[0]) );
+ fts5yygoto = fts5yyRuleInfoLhs[fts5yyruleno];
+ fts5yysize = fts5yyRuleInfoNRhs[fts5yyruleno];
fts5yyact = fts5yy_find_reduce_action(fts5yymsp[fts5yysize].stateno,(fts5YYCODETYPE)fts5yygoto);
/* There are no SHIFTREDUCE actions on nonterminals because the table
@@ -201099,7 +202220,7 @@ static void fts5HighlightAppend(
HighlightContext *p,
const char *z, int n
){
- if( *pRc==SQLITE_OK ){
+ if( *pRc==SQLITE_OK && z ){
if( n<0 ) n = (int)strlen(z);
p->zOut = sqlite3_mprintf("%z%.*s", p->zOut, n, z);
if( p->zOut==0 ) *pRc = SQLITE_NOMEM;
@@ -201231,7 +202352,7 @@ static int fts5SentenceFinderAdd(Fts5SFinder *p, int iAdd){
int nNew = p->nFirstAlloc ? p->nFirstAlloc*2 : 64;
int *aNew;
- aNew = (int*)sqlite3_realloc(p->aFirst, nNew*sizeof(int));
+ aNew = (int*)sqlite3_realloc64(p->aFirst, nNew*sizeof(int));
if( aNew==0 ) return SQLITE_NOMEM;
p->aFirst = aNew;
p->nFirstAlloc = nNew;
@@ -201298,11 +202419,12 @@ static int fts5SnippetScore(
int nInst;
int nScore = 0;
int iLast = 0;
+ sqlite3_int64 iEnd = (sqlite3_int64)iPos + nToken;
rc = pApi->xInstCount(pFts, &nInst);
for(i=0; i<nInst && rc==SQLITE_OK; i++){
rc = pApi->xInst(pFts, i, &ip, &ic, &iOff);
- if( rc==SQLITE_OK && ic==iCol && iOff>=iPos && iOff<(iPos+nToken) ){
+ if( rc==SQLITE_OK && ic==iCol && iOff>=iPos && iOff<iEnd ){
nScore += (aSeen[ip] ? 1 : 1000);
aSeen[ip] = 1;
if( iFirst<0 ) iFirst = iOff;
@@ -201312,7 +202434,7 @@ static int fts5SnippetScore(
*pnScore = nScore;
if( piPos ){
- int iAdj = iFirst - (nToken - (iLast-iFirst)) / 2;
+ sqlite3_int64 iAdj = iFirst - (nToken - (iLast-iFirst)) / 2;
if( (iAdj+nToken)>nDocsize ) iAdj = nDocsize - nToken;
if( iAdj<0 ) iAdj = 0;
*piPos = iAdj;
@@ -201405,7 +202527,9 @@ static void fts5SnippetFunction(
int jj;
rc = pApi->xInst(pFts, ii, &ip, &ic, &io);
- if( ic!=i || rc!=SQLITE_OK ) continue;
+ if( ic!=i ) continue;
+ if( io>nDocsize ) rc = FTS5_CORRUPT;
+ if( rc!=SQLITE_OK ) continue;
memset(aSeen, 0, nPhrase);
rc = fts5SnippetScore(pApi, pFts, nDocsize, aSeen, i,
io, nToken, &nScore, &iAdj
@@ -201531,13 +202655,13 @@ static int fts5Bm25GetData(
int nPhrase; /* Number of phrases in query */
sqlite3_int64 nRow = 0; /* Number of rows in table */
sqlite3_int64 nToken = 0; /* Number of tokens in table */
- int nByte; /* Bytes of space to allocate */
+ sqlite3_int64 nByte; /* Bytes of space to allocate */
int i;
/* Allocate the Fts5Bm25Data object */
nPhrase = pApi->xPhraseCount(pFts);
nByte = sizeof(Fts5Bm25Data) + nPhrase*2*sizeof(double);
- p = (Fts5Bm25Data*)sqlite3_malloc(nByte);
+ p = (Fts5Bm25Data*)sqlite3_malloc64(nByte);
if( p==0 ){
rc = SQLITE_NOMEM;
}else{
@@ -201549,6 +202673,7 @@ static int fts5Bm25GetData(
/* Calculate the average document length for this FTS5 table */
if( rc==SQLITE_OK ) rc = pApi->xRowCount(pFts, &nRow);
+ assert( rc!=SQLITE_OK || nRow>0 );
if( rc==SQLITE_OK ) rc = pApi->xColumnTotalSize(pFts, -1, &nToken);
if( rc==SQLITE_OK ) p->avgdl = (double)nToken / (double)nRow;
@@ -201674,8 +202799,6 @@ static int sqlite3Fts5AuxInit(fts5_api *pApi){
return rc;
}
-
-
/*
** 2014 May 31
**
@@ -201695,12 +202818,12 @@ static int sqlite3Fts5AuxInit(fts5_api *pApi){
static int sqlite3Fts5BufferSize(int *pRc, Fts5Buffer *pBuf, u32 nByte){
if( (u32)pBuf->nSpace<nByte ){
- u32 nNew = pBuf->nSpace ? pBuf->nSpace : 64;
+ u64 nNew = pBuf->nSpace ? pBuf->nSpace : 64;
u8 *pNew;
while( nNew<nByte ){
nNew = nNew * 2;
}
- pNew = sqlite3_realloc(pBuf->p, nNew);
+ pNew = sqlite3_realloc64(pBuf->p, nNew);
if( pNew==0 ){
*pRc = SQLITE_NOMEM;
return 1;
@@ -201730,7 +202853,7 @@ static void sqlite3Fts5Put32(u8 *aBuf, int iVal){
}
static int sqlite3Fts5Get32(const u8 *aBuf){
- return (aBuf[0] << 24) + (aBuf[1] << 16) + (aBuf[2] << 8) + aBuf[3];
+ return (int)((((u32)aBuf[0])<<24) + (aBuf[1]<<16) + (aBuf[2]<<8) + aBuf[3]);
}
/*
@@ -201861,7 +202984,7 @@ static int sqlite3Fts5PoslistNext64(
iOff = ((i64)iVal) << 32;
fts5FastGetVarint32(a, i, iVal);
}
- *piOff = iOff + (iVal-2);
+ *piOff = iOff + ((iVal-2) & 0x7FFFFFFF);
*pi = i;
return 0;
}
@@ -201922,10 +203045,10 @@ static int sqlite3Fts5PoslistWriterAppend(
return SQLITE_OK;
}
-static void *sqlite3Fts5MallocZero(int *pRc, int nByte){
+static void *sqlite3Fts5MallocZero(int *pRc, sqlite3_int64 nByte){
void *pRet = 0;
if( *pRc==SQLITE_OK ){
- pRet = sqlite3_malloc(nByte);
+ pRet = sqlite3_malloc64(nByte);
if( pRet==0 ){
if( nByte>0 ) *pRc = SQLITE_NOMEM;
}else{
@@ -202368,7 +203491,7 @@ static int fts5ConfigParseSpecial(
if( sqlite3_strnicmp("tokenize", zCmd, nCmd)==0 ){
const char *p = (const char*)zArg;
- int nArg = (int)strlen(zArg) + 1;
+ sqlite3_int64 nArg = strlen(zArg) + 1;
char **azArg = sqlite3Fts5MallocZero(&rc, sizeof(char*) * nArg);
char *pDel = sqlite3Fts5MallocZero(&rc, nArg * 2);
char *pSpace = pDel;
@@ -202498,8 +203621,8 @@ static const char *fts5ConfigGobbleWord(
){
const char *zRet = 0;
- int nIn = (int)strlen(zIn);
- char *zOut = sqlite3_malloc(nIn+1);
+ sqlite3_int64 nIn = strlen(zIn);
+ char *zOut = sqlite3_malloc64(nIn+1);
assert( *pRc==SQLITE_OK );
*pbQuoted = 0;
@@ -202602,7 +203725,7 @@ static int sqlite3Fts5ConfigParse(
int rc = SQLITE_OK; /* Return code */
Fts5Config *pRet; /* New object to return */
int i;
- int nByte;
+ sqlite3_int64 nByte;
*ppOut = pRet = (Fts5Config*)sqlite3_malloc(sizeof(Fts5Config));
if( pRet==0 ) return SQLITE_NOMEM;
@@ -203246,7 +204369,7 @@ static int fts5ExprGetToken(
return tok;
}
-static void *fts5ParseAlloc(u64 t){ return sqlite3_malloc((int)t); }
+static void *fts5ParseAlloc(u64 t){ return sqlite3_malloc64((sqlite3_int64)t);}
static void fts5ParseFree(void *p){ sqlite3_free(p); }
static int sqlite3Fts5ExprNew(
@@ -203391,8 +204514,8 @@ static int fts5ExprSynonymList(
if( sqlite3Fts5IterEof(pIter)==0 && pIter->iRowid==iRowid ){
if( pIter->nData==0 ) continue;
if( nIter==nAlloc ){
- int nByte = sizeof(Fts5PoslistReader) * nAlloc * 2;
- Fts5PoslistReader *aNew = (Fts5PoslistReader*)sqlite3_malloc(nByte);
+ sqlite3_int64 nByte = sizeof(Fts5PoslistReader) * nAlloc * 2;
+ Fts5PoslistReader *aNew = (Fts5PoslistReader*)sqlite3_malloc64(nByte);
if( aNew==0 ){
rc = SQLITE_NOMEM;
goto synonym_poslist_out;
@@ -203472,8 +204595,8 @@ static int fts5ExprPhraseIsMatch(
/* If the aStatic[] array is not large enough, allocate a large array
** using sqlite3_malloc(). This approach could be improved upon. */
if( pPhrase->nTerm>ArraySize(aStatic) ){
- int nByte = sizeof(Fts5PoslistReader) * pPhrase->nTerm;
- aIter = (Fts5PoslistReader*)sqlite3_malloc(nByte);
+ sqlite3_int64 nByte = sizeof(Fts5PoslistReader) * pPhrase->nTerm;
+ aIter = (Fts5PoslistReader*)sqlite3_malloc64(nByte);
if( !aIter ) return SQLITE_NOMEM;
}
memset(aIter, 0, sizeof(Fts5PoslistReader) * pPhrase->nTerm);
@@ -203607,7 +204730,7 @@ static int fts5ExprNearIsMatch(int *pRc, Fts5ExprNearset *pNear){
/* If the aStatic[] array is not large enough, allocate a large array
** using sqlite3_malloc(). This approach could be improved upon. */
if( pNear->nPhrase>ArraySize(aStatic) ){
- int nByte = sizeof(Fts5NearTrimmer) * pNear->nPhrase;
+ sqlite3_int64 nByte = sizeof(Fts5NearTrimmer) * pNear->nPhrase;
a = (Fts5NearTrimmer*)sqlite3Fts5MallocZero(&rc, nByte);
}else{
memset(aStatic, 0, sizeof(aStatic));
@@ -204516,8 +205639,9 @@ static Fts5ExprNearset *sqlite3Fts5ParseNearset(
return pNear;
}
if( pNear==0 ){
- int nByte = sizeof(Fts5ExprNearset) + SZALLOC * sizeof(Fts5ExprPhrase*);
- pRet = sqlite3_malloc(nByte);
+ sqlite3_int64 nByte;
+ nByte = sizeof(Fts5ExprNearset) + SZALLOC * sizeof(Fts5ExprPhrase*);
+ pRet = sqlite3_malloc64(nByte);
if( pRet==0 ){
pParse->rc = SQLITE_NOMEM;
}else{
@@ -204525,9 +205649,10 @@ static Fts5ExprNearset *sqlite3Fts5ParseNearset(
}
}else if( (pNear->nPhrase % SZALLOC)==0 ){
int nNew = pNear->nPhrase + SZALLOC;
- int nByte = sizeof(Fts5ExprNearset) + nNew * sizeof(Fts5ExprPhrase*);
+ sqlite3_int64 nByte;
- pRet = (Fts5ExprNearset*)sqlite3_realloc(pNear, nByte);
+ nByte = sizeof(Fts5ExprNearset) + nNew * sizeof(Fts5ExprPhrase*);
+ pRet = (Fts5ExprNearset*)sqlite3_realloc64(pNear, nByte);
if( pRet==0 ){
pParse->rc = SQLITE_NOMEM;
}
@@ -204591,8 +205716,8 @@ static int fts5ParseTokenize(
if( pPhrase && pPhrase->nTerm>0 && (tflags & FTS5_TOKEN_COLOCATED) ){
Fts5ExprTerm *pSyn;
- int nByte = sizeof(Fts5ExprTerm) + sizeof(Fts5Buffer) + nToken+1;
- pSyn = (Fts5ExprTerm*)sqlite3_malloc(nByte);
+ sqlite3_int64 nByte = sizeof(Fts5ExprTerm) + sizeof(Fts5Buffer) + nToken+1;
+ pSyn = (Fts5ExprTerm*)sqlite3_malloc64(nByte);
if( pSyn==0 ){
rc = SQLITE_NOMEM;
}else{
@@ -204608,7 +205733,7 @@ static int fts5ParseTokenize(
Fts5ExprPhrase *pNew;
int nNew = SZALLOC + (pPhrase ? pPhrase->nTerm : 0);
- pNew = (Fts5ExprPhrase*)sqlite3_realloc(pPhrase,
+ pNew = (Fts5ExprPhrase*)sqlite3_realloc64(pPhrase,
sizeof(Fts5ExprPhrase) + sizeof(Fts5ExprTerm) * nNew
);
if( pNew==0 ){
@@ -204694,9 +205819,9 @@ static Fts5ExprPhrase *sqlite3Fts5ParseTerm(
if( pAppend==0 ){
if( (pParse->nPhrase % 8)==0 ){
- int nByte = sizeof(Fts5ExprPhrase*) * (pParse->nPhrase + 8);
+ sqlite3_int64 nByte = sizeof(Fts5ExprPhrase*) * (pParse->nPhrase + 8);
Fts5ExprPhrase **apNew;
- apNew = (Fts5ExprPhrase**)sqlite3_realloc(pParse->apPhrase, nByte);
+ apNew = (Fts5ExprPhrase**)sqlite3_realloc64(pParse->apPhrase, nByte);
if( apNew==0 ){
pParse->rc = SQLITE_NOMEM;
fts5ExprPhraseFree(sCtx.pPhrase);
@@ -204751,8 +205876,10 @@ static int sqlite3Fts5ExprClonePhrase(
if( rc==SQLITE_OK ){
Fts5Colset *pColsetOrig = pOrig->pNode->pNear->pColset;
if( pColsetOrig ){
- int nByte = sizeof(Fts5Colset) + (pColsetOrig->nCol-1) * sizeof(int);
- Fts5Colset *pColset = (Fts5Colset*)sqlite3Fts5MallocZero(&rc, nByte);
+ sqlite3_int64 nByte;
+ Fts5Colset *pColset;
+ nByte = sizeof(Fts5Colset) + (pColsetOrig->nCol-1) * sizeof(int);
+ pColset = (Fts5Colset*)sqlite3Fts5MallocZero(&rc, nByte);
if( pColset ){
memcpy(pColset, pColsetOrig, nByte);
}
@@ -204872,7 +205999,7 @@ static Fts5Colset *fts5ParseColset(
assert( pParse->rc==SQLITE_OK );
assert( iCol>=0 && iCol<pParse->pConfig->nCol );
- pNew = sqlite3_realloc(p, sizeof(Fts5Colset) + sizeof(int)*nCol);
+ pNew = sqlite3_realloc64(p, sizeof(Fts5Colset) + sizeof(int)*nCol);
if( pNew==0 ){
pParse->rc = SQLITE_NOMEM;
}else{
@@ -204968,7 +206095,7 @@ static Fts5Colset *sqlite3Fts5ParseColset(
static Fts5Colset *fts5CloneColset(int *pRc, Fts5Colset *pOrig){
Fts5Colset *pRet;
if( pOrig ){
- int nByte = sizeof(Fts5Colset) + (pOrig->nCol-1) * sizeof(int);
+ sqlite3_int64 nByte = sizeof(Fts5Colset) + (pOrig->nCol-1) * sizeof(int);
pRet = (Fts5Colset*)sqlite3Fts5MallocZero(pRc, nByte);
if( pRet ){
memcpy(pRet, pOrig, nByte);
@@ -205122,7 +206249,7 @@ static Fts5ExprNode *sqlite3Fts5ParseNode(
if( pParse->rc==SQLITE_OK ){
int nChild = 0; /* Number of children of returned node */
- int nByte; /* Bytes of space to allocate for this node */
+ sqlite3_int64 nByte; /* Bytes of space to allocate for this node */
assert( (eType!=FTS5_STRING && !pNear)
|| (eType==FTS5_STRING && !pLeft && !pRight)
@@ -205254,7 +206381,7 @@ static Fts5ExprNode *sqlite3Fts5ParseImplicitAnd(
}
static char *fts5ExprTermPrint(Fts5ExprTerm *pTerm){
- int nByte = 0;
+ sqlite3_int64 nByte = 0;
Fts5ExprTerm *p;
char *zQuoted;
@@ -205262,7 +206389,7 @@ static char *fts5ExprTermPrint(Fts5ExprTerm *pTerm){
for(p=pTerm; p; p=p->pSynonym){
nByte += (int)strlen(pTerm->zTerm) * 2 + 3 + 2;
}
- zQuoted = sqlite3_malloc(nByte);
+ zQuoted = sqlite3_malloc64(nByte);
if( zQuoted ){
int i = 0;
@@ -205502,7 +206629,7 @@ static void fts5ExprFunction(
}
nConfig = 3 + (nArg-iArg);
- azConfig = (const char**)sqlite3_malloc(sizeof(char*) * nConfig);
+ azConfig = (const char**)sqlite3_malloc64(sizeof(char*) * nConfig);
if( azConfig==0 ){
sqlite3_result_error_nomem(pCtx);
return;
@@ -205588,7 +206715,7 @@ static void fts5ExprIsAlnum(
sqlite3Fts5UnicodeCatParse("N*", aArr);
sqlite3Fts5UnicodeCatParse("Co", aArr);
iCode = sqlite3_value_int(apVal[0]);
- sqlite3_result_int(pCtx, aArr[sqlite3Fts5UnicodeCategory(iCode)]);
+ sqlite3_result_int(pCtx, aArr[sqlite3Fts5UnicodeCategory((u32)iCode)]);
}
static void fts5ExprFold(
@@ -205683,7 +206810,7 @@ struct Fts5PoslistPopulator {
static Fts5PoslistPopulator *sqlite3Fts5ExprClearPoslists(Fts5Expr *pExpr, int bLive){
Fts5PoslistPopulator *pRet;
- pRet = sqlite3_malloc(sizeof(Fts5PoslistPopulator)*pExpr->nPhrase);
+ pRet = sqlite3_malloc64(sizeof(Fts5PoslistPopulator)*pExpr->nPhrase);
if( pRet ){
int i;
memset(pRet, 0, sizeof(Fts5PoslistPopulator)*pExpr->nPhrase);
@@ -205883,7 +207010,6 @@ static int sqlite3Fts5ExprPhraseCollist(
return rc;
}
-
/*
** 2014 August 11
**
@@ -205976,14 +207102,14 @@ static int sqlite3Fts5HashNew(Fts5Config *pConfig, Fts5Hash **ppNew, int *pnByte
if( pNew==0 ){
rc = SQLITE_NOMEM;
}else{
- int nByte;
+ sqlite3_int64 nByte;
memset(pNew, 0, sizeof(Fts5Hash));
pNew->pnByte = pnByte;
pNew->eDetail = pConfig->eDetail;
pNew->nSlot = 1024;
nByte = sizeof(Fts5HashEntry*) * pNew->nSlot;
- pNew->aSlot = (Fts5HashEntry**)sqlite3_malloc(nByte);
+ pNew->aSlot = (Fts5HashEntry**)sqlite3_malloc64(nByte);
if( pNew->aSlot==0 ){
sqlite3_free(pNew);
*ppNew = 0;
@@ -206051,7 +207177,7 @@ static int fts5HashResize(Fts5Hash *pHash){
Fts5HashEntry **apNew;
Fts5HashEntry **apOld = pHash->aSlot;
- apNew = (Fts5HashEntry**)sqlite3_malloc(nNew*sizeof(Fts5HashEntry*));
+ apNew = (Fts5HashEntry**)sqlite3_malloc64(nNew*sizeof(Fts5HashEntry*));
if( !apNew ) return SQLITE_NOMEM;
memset(apNew, 0, nNew*sizeof(Fts5HashEntry*));
@@ -206145,7 +207271,7 @@ static int sqlite3Fts5HashWrite(
if( p==0 ){
/* Figure out how much space to allocate */
char *zKey;
- int nByte = sizeof(Fts5HashEntry) + (nToken+1) + 1 + 64;
+ sqlite3_int64 nByte = sizeof(Fts5HashEntry) + (nToken+1) + 1 + 64;
if( nByte<128 ) nByte = 128;
/* Grow the Fts5Hash.aSlot[] array if necessary. */
@@ -206156,7 +207282,7 @@ static int sqlite3Fts5HashWrite(
}
/* Allocate new Fts5HashEntry and add it to the hash table. */
- p = (Fts5HashEntry*)sqlite3_malloc(nByte);
+ p = (Fts5HashEntry*)sqlite3_malloc64(nByte);
if( !p ) return SQLITE_NOMEM;
memset(p, 0, sizeof(Fts5HashEntry));
p->nAlloc = nByte;
@@ -206195,12 +207321,12 @@ static int sqlite3Fts5HashWrite(
** + 5 bytes for the new position offset (32-bit max).
*/
if( (p->nAlloc - p->nData) < (9 + 4 + 1 + 3 + 5) ){
- int nNew = p->nAlloc * 2;
+ sqlite3_int64 nNew = p->nAlloc * 2;
Fts5HashEntry *pNew;
Fts5HashEntry **pp;
- pNew = (Fts5HashEntry*)sqlite3_realloc(p, nNew);
+ pNew = (Fts5HashEntry*)sqlite3_realloc64(p, nNew);
if( pNew==0 ) return SQLITE_NOMEM;
- pNew->nAlloc = nNew;
+ pNew->nAlloc = (int)nNew;
for(pp=&pHash->aSlot[iHash]; *pp!=p; pp=&(*pp)->pHashNext);
*pp = pNew;
p = pNew;
@@ -206324,7 +207450,7 @@ static int fts5HashEntrySort(
int i;
*ppSorted = 0;
- ap = sqlite3_malloc(sizeof(Fts5HashEntry*) * nMergeSlot);
+ ap = sqlite3_malloc64(sizeof(Fts5HashEntry*) * nMergeSlot);
if( !ap ) return SQLITE_NOMEM;
memset(ap, 0, sizeof(Fts5HashEntry*) * nMergeSlot);
@@ -206369,7 +207495,8 @@ static int sqlite3Fts5HashQuery(
for(p=pHash->aSlot[iHash]; p; p=p->pHashNext){
zKey = fts5EntryKey(p);
- if( memcmp(zKey, pTerm, nTerm)==0 && zKey[nTerm]==0 ) break;
+ assert( p->nKey+1==(int)strlen(zKey) );
+ if( nTerm==p->nKey+1 && memcmp(zKey, pTerm, nTerm)==0 ) break;
}
if( p ){
@@ -206421,7 +207548,6 @@ static void sqlite3Fts5HashScanEntry(
}
}
-
/*
** 2014 May 31
**
@@ -206936,7 +208062,6 @@ struct Fts5Iter {
Fts5IndexIter base; /* Base class containing output vars */
Fts5Index *pIndex; /* Index that owns this iterator */
- Fts5Structure *pStruct; /* Database structure for this iterator */
Fts5Buffer poslist; /* Buffer containing current poslist */
Fts5Colset *pColset; /* Restrict matches to these columns */
@@ -206997,7 +208122,7 @@ static u16 fts5GetU16(const u8 *aIn){
** If an OOM error is encountered, return NULL and set the error code in
** the Fts5Index handle passed as the first argument.
*/
-static void *fts5IdxMalloc(Fts5Index *p, int nByte){
+static void *fts5IdxMalloc(Fts5Index *p, sqlite3_int64 nByte){
return sqlite3Fts5MallocZero(&p->rc, nByte);
}
@@ -207031,7 +208156,7 @@ static int fts5BufferCompareBlob(
*/
static int fts5BufferCompare(Fts5Buffer *pLeft, Fts5Buffer *pRight){
int nCmp = MIN(pLeft->n, pRight->n);
- int res = memcmp(pLeft->p, pRight->p, nCmp);
+ int res = fts5Memcmp(pLeft->p, pRight->p, nCmp);
return (res==0 ? (pLeft->n - pRight->n) : res);
}
@@ -207097,8 +208222,8 @@ static Fts5Data *fts5DataRead(Fts5Index *p, i64 iRowid){
if( rc==SQLITE_OK ){
u8 *aOut = 0; /* Read blob data into this buffer */
int nByte = sqlite3_blob_bytes(p->pReader);
- int nAlloc = sizeof(Fts5Data) + nByte + FTS5_DATA_PADDING;
- pRet = (Fts5Data*)sqlite3_malloc(nAlloc);
+ sqlite3_int64 nAlloc = sizeof(Fts5Data) + nByte + FTS5_DATA_PADDING;
+ pRet = (Fts5Data*)sqlite3_malloc64(nAlloc);
if( pRet ){
pRet->nn = nByte;
aOut = pRet->p = (u8*)&pRet[1];
@@ -207114,6 +208239,7 @@ static Fts5Data *fts5DataRead(Fts5Index *p, i64 iRowid){
pRet = 0;
}else{
/* TODO1: Fix this */
+ pRet->p[nByte] = 0x00;
pRet->szLeaf = fts5GetU16(&pRet->p[2]);
}
}
@@ -207272,7 +208398,7 @@ static int fts5StructureDecode(
int iLvl;
int nLevel = 0;
int nSegment = 0;
- int nByte; /* Bytes of space to allocate at pRet */
+ sqlite3_int64 nByte; /* Bytes of space to allocate at pRet */
Fts5Structure *pRet = 0; /* Structure object to return */
/* Grab the cookie value */
@@ -207283,6 +208409,11 @@ static int fts5StructureDecode(
** structure record. */
i += fts5GetVarint32(&pData[i], nLevel);
i += fts5GetVarint32(&pData[i], nSegment);
+ if( nLevel>FTS5_MAX_SEGMENT || nLevel<0
+ || nSegment>FTS5_MAX_SEGMENT || nSegment<0
+ ){
+ return FTS5_CORRUPT;
+ }
nByte = (
sizeof(Fts5Structure) + /* Main structure */
sizeof(Fts5StructureLevel) * (nLevel-1) /* aLevel[] array */
@@ -207305,25 +208436,35 @@ static int fts5StructureDecode(
}else{
i += fts5GetVarint32(&pData[i], pLvl->nMerge);
i += fts5GetVarint32(&pData[i], nTotal);
- assert( nTotal>=pLvl->nMerge );
+ if( nTotal<pLvl->nMerge ) rc = FTS5_CORRUPT;
pLvl->aSeg = (Fts5StructureSegment*)sqlite3Fts5MallocZero(&rc,
nTotal * sizeof(Fts5StructureSegment)
);
+ nSegment -= nTotal;
}
if( rc==SQLITE_OK ){
pLvl->nSeg = nTotal;
for(iSeg=0; iSeg<nTotal; iSeg++){
+ Fts5StructureSegment *pSeg = &pLvl->aSeg[iSeg];
if( i>=nData ){
rc = FTS5_CORRUPT;
break;
}
- i += fts5GetVarint32(&pData[i], pLvl->aSeg[iSeg].iSegid);
- i += fts5GetVarint32(&pData[i], pLvl->aSeg[iSeg].pgnoFirst);
- i += fts5GetVarint32(&pData[i], pLvl->aSeg[iSeg].pgnoLast);
+ i += fts5GetVarint32(&pData[i], pSeg->iSegid);
+ i += fts5GetVarint32(&pData[i], pSeg->pgnoFirst);
+ i += fts5GetVarint32(&pData[i], pSeg->pgnoLast);
+ if( pSeg->pgnoLast<pSeg->pgnoFirst ){
+ rc = FTS5_CORRUPT;
+ break;
+ }
}
+ if( iLvl>0 && pLvl[-1].nMerge && nTotal==0 ) rc = FTS5_CORRUPT;
+ if( iLvl==nLevel-1 && pLvl->nMerge ) rc = FTS5_CORRUPT;
}
}
+ if( nSegment!=0 && rc==SQLITE_OK ) rc = FTS5_CORRUPT;
+
if( rc!=SQLITE_OK ){
fts5StructureRelease(pRet);
pRet = 0;
@@ -207341,12 +208482,12 @@ static void fts5StructureAddLevel(int *pRc, Fts5Structure **ppStruct){
if( *pRc==SQLITE_OK ){
Fts5Structure *pStruct = *ppStruct;
int nLevel = pStruct->nLevel;
- int nByte = (
+ sqlite3_int64 nByte = (
sizeof(Fts5Structure) + /* Main structure */
sizeof(Fts5StructureLevel) * (nLevel+1) /* aLevel[] array */
);
- pStruct = sqlite3_realloc(pStruct, nByte);
+ pStruct = sqlite3_realloc64(pStruct, nByte);
if( pStruct ){
memset(&pStruct->aLevel[nLevel], 0, sizeof(Fts5StructureLevel));
pStruct->nLevel++;
@@ -207371,10 +208512,10 @@ static void fts5StructureExtendLevel(
if( *pRc==SQLITE_OK ){
Fts5StructureLevel *pLvl = &pStruct->aLevel[iLvl];
Fts5StructureSegment *aNew;
- int nByte;
+ sqlite3_int64 nByte;
nByte = (pLvl->nSeg + nExtra) * sizeof(Fts5StructureSegment);
- aNew = sqlite3_realloc(pLvl->aSeg, nByte);
+ aNew = sqlite3_realloc64(pLvl->aSeg, nByte);
if( aNew ){
if( bInsert==0 ){
memset(&aNew[pLvl->nSeg], 0, sizeof(Fts5StructureSegment) * nExtra);
@@ -207888,10 +209029,10 @@ static Fts5DlidxIter *fts5DlidxIterInit(
int bDone = 0;
for(i=0; p->rc==SQLITE_OK && bDone==0; i++){
- int nByte = sizeof(Fts5DlidxIter) + i * sizeof(Fts5DlidxLvl);
+ sqlite3_int64 nByte = sizeof(Fts5DlidxIter) + i * sizeof(Fts5DlidxLvl);
Fts5DlidxIter *pNew;
- pNew = (Fts5DlidxIter*)sqlite3_realloc(pIter, nByte);
+ pNew = (Fts5DlidxIter*)sqlite3_realloc64(pIter, nByte);
if( pNew==0 ){
p->rc = SQLITE_NOMEM;
}else{
@@ -208061,12 +209202,13 @@ static void fts5SegIterLoadTerm(Fts5Index *p, Fts5SegIter *pIter, int nKeep){
int nNew; /* Bytes of new data */
iOff += fts5GetVarint32(&a[iOff], nNew);
- if( iOff+nNew>pIter->pLeaf->nn ){
+ if( iOff+nNew>pIter->pLeaf->szLeaf || nKeep>pIter->term.n || nNew==0 ){
p->rc = FTS5_CORRUPT;
return;
}
pIter->term.n = nKeep;
fts5BufferAppendBlob(&p->rc, &pIter->term, nNew, &a[iOff]);
+ assert( pIter->term.n<=pIter->term.nSpace );
iOff += nNew;
pIter->iTermLeafOffset = iOff;
pIter->iTermLeafPgno = pIter->iLeafPgno;
@@ -208131,7 +209273,7 @@ static void fts5SegIterInit(
if( p->rc==SQLITE_OK ){
pIter->iLeafOffset = 4;
assert_nc( pIter->pLeaf->nn>4 );
- assert( fts5LeafFirstTermOff(pIter->pLeaf)==4 );
+ assert_nc( fts5LeafFirstTermOff(pIter->pLeaf)==4 );
pIter->iPgidxOff = pIter->pLeaf->szLeaf+1;
fts5SegIterLoadTerm(p, pIter, 0);
fts5SegIterLoadNPos(p, pIter);
@@ -208187,7 +209329,7 @@ static void fts5SegIterReverseInitPage(Fts5Index *p, Fts5SegIter *pIter){
/* If necessary, grow the pIter->aRowidOffset[] array. */
if( iRowidOffset>=pIter->nRowidOffset ){
int nNew = pIter->nRowidOffset + 8;
- int *aNew = (int*)sqlite3_realloc(pIter->aRowidOffset, nNew*sizeof(int));
+ int *aNew = (int*)sqlite3_realloc64(pIter->aRowidOffset,nNew*sizeof(int));
if( aNew==0 ){
p->rc = SQLITE_NOMEM;
break;
@@ -208641,10 +209783,10 @@ static void fts5LeafSeek(
int szLeaf = pIter->pLeaf->szLeaf;
int n = pIter->pLeaf->nn;
- int nMatch = 0;
- int nKeep = 0;
- int nNew = 0;
- int iTermOff;
+ u32 nMatch = 0;
+ u32 nKeep = 0;
+ u32 nNew = 0;
+ u32 iTermOff;
int iPgidx; /* Current offset in pgidx */
int bEndOfPage = 0;
@@ -208668,15 +209810,15 @@ static void fts5LeafSeek(
assert( nKeep>=nMatch );
if( nKeep==nMatch ){
- int nCmp;
- int i;
- nCmp = MIN(nNew, nTerm-nMatch);
+ u32 nCmp;
+ u32 i;
+ nCmp = (u32)MIN(nNew, nTerm-nMatch);
for(i=0; i<nCmp; i++){
if( a[iOff+i]!=pTerm[nMatch+i] ) break;
}
nMatch += i;
- if( nTerm==nMatch ){
+ if( (u32)nTerm==nMatch ){
if( i==nNew ){
goto search_success;
}else{
@@ -208720,6 +209862,7 @@ static void fts5LeafSeek(
iPgidx += fts5GetVarint32(&pIter->pLeaf->p[iPgidx], iOff);
if( iOff<4 || iOff>=pIter->pLeaf->szLeaf ){
p->rc = FTS5_CORRUPT;
+ return;
}else{
nKeep = 0;
iTermOff = iOff;
@@ -208732,8 +209875,11 @@ static void fts5LeafSeek(
}
search_success:
-
pIter->iLeafOffset = iOff + nNew;
+ if( pIter->iLeafOffset>n || nNew<1 ){
+ p->rc = FTS5_CORRUPT;
+ return;
+ }
pIter->iTermLeafOffset = pIter->iLeafOffset;
pIter->iTermLeafPgno = pIter->iLeafPgno;
@@ -208840,7 +209986,7 @@ static void fts5SegIterSeekInit(
** 4) the FTS5INDEX_QUERY_SCAN flag was set and the iterator points
** to an entry with a term greater than or equal to (pTerm/nTerm).
*/
- assert( p->rc!=SQLITE_OK /* 1 */
+ assert_nc( p->rc!=SQLITE_OK /* 1 */
|| pIter->pLeaf==0 /* 2 */
|| fts5BufferCompareBlob(&pIter->term, pTerm, nTerm)==0 /* 3 */
|| (bGe && fts5BufferCompareBlob(&pIter->term, pTerm, nTerm)>0) /* 4 */
@@ -208938,7 +210084,7 @@ static void fts5AssertComparisonResult(
assert( pRes->iFirst==i1 );
}else{
int nMin = MIN(p1->term.n, p2->term.n);
- int res = memcmp(p1->term.p, p2->term.p, nMin);
+ int res = fts5Memcmp(p1->term.p, p2->term.p, nMin);
if( res==0 ) res = p1->term.n - p2->term.n;
if( res==0 ){
@@ -209161,7 +210307,6 @@ static void fts5MultiIterFree(Fts5Iter *pIter){
for(i=0; i<pIter->nSeg; i++){
fts5SegIterClear(&pIter->aSeg[i]);
}
- fts5StructureRelease(pIter->pStruct);
fts5BufferFree(&pIter->poslist);
sqlite3_free(pIter);
}
@@ -209509,7 +210654,8 @@ static void fts5SegiterPoslist(
Fts5Colset *pColset,
Fts5Buffer *pBuf
){
- if( 0==fts5BufferGrow(&p->rc, pBuf, pSeg->nPos) ){
+ if( 0==fts5BufferGrow(&p->rc, pBuf, pSeg->nPos+FTS5_DATA_ZERO_PADDING) ){
+ memset(&pBuf->p[pBuf->n+pSeg->nPos], 0, FTS5_DATA_ZERO_PADDING);
if( pColset==0 ){
fts5ChunkIterate(p, pSeg, (void*)pBuf, fts5PoslistCallback);
}else{
@@ -209807,9 +210953,7 @@ static void fts5MultiIterNew(
if( pNew==0 ) return;
pNew->bRev = (0!=(flags & FTS5INDEX_QUERY_DESC));
pNew->bSkipEmpty = (0!=(flags & FTS5INDEX_QUERY_SKIPEMPTY));
- pNew->pStruct = pStruct;
pNew->pColset = pColset;
- fts5StructureRef(pStruct);
if( (flags & FTS5INDEX_QUERY_NOOUTPUT)==0 ){
fts5IterSetOutputCb(&p->rc, pNew);
}
@@ -209987,24 +211131,24 @@ static int fts5AllocateSegid(Fts5Index *p, Fts5Structure *pStruct){
for(iLvl=0; iLvl<pStruct->nLevel; iLvl++){
for(iSeg=0; iSeg<pStruct->aLevel[iLvl].nSeg; iSeg++){
int iId = pStruct->aLevel[iLvl].aSeg[iSeg].iSegid;
- if( iId<=FTS5_MAX_SEGMENT ){
- aUsed[(iId-1) / 32] |= 1 << ((iId-1) % 32);
+ if( iId<=FTS5_MAX_SEGMENT && iId>0 ){
+ aUsed[(iId-1) / 32] |= (u32)1 << ((iId-1) % 32);
}
}
}
for(i=0; aUsed[i]==0xFFFFFFFF; i++);
mask = aUsed[i];
- for(iSegid=0; mask & (1 << iSegid); iSegid++);
+ for(iSegid=0; mask & ((u32)1 << iSegid); iSegid++);
iSegid += 1 + i*32;
#ifdef SQLITE_DEBUG
for(iLvl=0; iLvl<pStruct->nLevel; iLvl++){
for(iSeg=0; iSeg<pStruct->aLevel[iLvl].nSeg; iSeg++){
- assert( iSegid!=pStruct->aLevel[iLvl].aSeg[iSeg].iSegid );
+ assert_nc( iSegid!=pStruct->aLevel[iLvl].aSeg[iSeg].iSegid );
}
}
- assert( iSegid>0 && iSegid<=FTS5_MAX_SEGMENT );
+ assert_nc( iSegid>0 && iSegid<=FTS5_MAX_SEGMENT );
{
sqlite3_stmt *pIdxSelect = fts5IdxSelectStmt(p);
@@ -210012,7 +211156,7 @@ static int fts5AllocateSegid(Fts5Index *p, Fts5Structure *pStruct){
u8 aBlob[2] = {0xff, 0xff};
sqlite3_bind_int(pIdxSelect, 1, iSegid);
sqlite3_bind_blob(pIdxSelect, 2, aBlob, 2, SQLITE_STATIC);
- assert( sqlite3_step(pIdxSelect)!=SQLITE_ROW );
+ assert_nc( sqlite3_step(pIdxSelect)!=SQLITE_ROW );
p->rc = sqlite3_reset(pIdxSelect);
sqlite3_bind_null(pIdxSelect, 2);
}
@@ -210082,7 +211226,7 @@ static int fts5WriteDlidxGrow(
int nLvl
){
if( p->rc==SQLITE_OK && nLvl>=pWriter->nDlidx ){
- Fts5DlidxWriter *aDlidx = (Fts5DlidxWriter*)sqlite3_realloc(
+ Fts5DlidxWriter *aDlidx = (Fts5DlidxWriter*)sqlite3_realloc64(
pWriter->aDlidx, sizeof(Fts5DlidxWriter) * nLvl
);
if( aDlidx==0 ){
@@ -210161,8 +211305,10 @@ static void fts5WriteBtreeTerm(
int nTerm, const u8 *pTerm /* First term on new page */
){
fts5WriteFlushBtree(p, pWriter);
- fts5BufferSet(&p->rc, &pWriter->btterm, nTerm, pTerm);
- pWriter->iBtPage = pWriter->writer.pgno;
+ if( p->rc==SQLITE_OK ){
+ fts5BufferSet(&p->rc, &pWriter->btterm, nTerm, pTerm);
+ pWriter->iBtPage = pWriter->writer.pgno;
+ }
}
/*
@@ -210313,6 +211459,7 @@ static void fts5WriteAppendTerm(
int nPrefix; /* Bytes of prefix compression for term */
Fts5PageWriter *pPage = &pWriter->writer;
Fts5Buffer *pPgidx = &pWriter->writer.pgidx;
+ int nMin = MIN(pPage->term.n, nTerm);
assert( p->rc==SQLITE_OK );
assert( pPage->buf.n>=4 );
@@ -210322,6 +211469,7 @@ static void fts5WriteAppendTerm(
if( (pPage->buf.n + pPgidx->n + nTerm + 2)>=p->pConfig->pgsz ){
if( pPage->buf.n>4 ){
fts5WriteFlushLeaf(p, pWriter);
+ if( p->rc!=SQLITE_OK ) return;
}
fts5BufferGrow(&p->rc, &pPage->buf, nTerm+FTS5_DATA_PADDING);
}
@@ -210354,13 +211502,14 @@ static void fts5WriteAppendTerm(
** inefficient, but still correct. */
int n = nTerm;
if( pPage->term.n ){
- n = 1 + fts5PrefixCompress(pPage->term.n, pPage->term.p, pTerm);
+ n = 1 + fts5PrefixCompress(nMin, pPage->term.p, pTerm);
}
fts5WriteBtreeTerm(p, pWriter, n, pTerm);
+ if( p->rc!=SQLITE_OK ) return;
pPage = &pWriter->writer;
}
}else{
- nPrefix = fts5PrefixCompress(pPage->term.n, pPage->term.p, pTerm);
+ nPrefix = fts5PrefixCompress(nMin, pPage->term.p, pTerm);
fts5BufferAppendVarint(&p->rc, &pPage->buf, nPrefix);
}
@@ -210407,7 +211556,7 @@ static void fts5WriteAppendRowid(
if( pWriter->bFirstRowidInDoclist || pWriter->bFirstRowidInPage ){
fts5BufferAppendVarint(&p->rc, &pPage->buf, iRowid);
}else{
- assert( p->rc || iRowid>pWriter->iPrevRowid );
+ assert_nc( p->rc || iRowid>pWriter->iPrevRowid );
fts5BufferAppendVarint(&p->rc, &pPage->buf, iRowid - pWriter->iPrevRowid);
}
pWriter->iPrevRowid = iRowid;
@@ -210529,7 +211678,7 @@ static void fts5TrimSegments(Fts5Index *p, Fts5Iter *pIter){
int i;
Fts5Buffer buf;
memset(&buf, 0, sizeof(Fts5Buffer));
- for(i=0; i<pIter->nSeg; i++){
+ for(i=0; i<pIter->nSeg && p->rc==SQLITE_OK; i++){
Fts5SegIter *pSeg = &pIter->aSeg[i];
if( pSeg->pSeg==0 ){
/* no-op */
@@ -210547,35 +211696,43 @@ static void fts5TrimSegments(Fts5Index *p, Fts5Iter *pIter){
u8 aHdr[4] = {0x00, 0x00, 0x00, 0x00};
iLeafRowid = FTS5_SEGMENT_ROWID(iId, pSeg->iTermLeafPgno);
- pData = fts5DataRead(p, iLeafRowid);
+ pData = fts5LeafRead(p, iLeafRowid);
if( pData ){
- fts5BufferZero(&buf);
- fts5BufferGrow(&p->rc, &buf, pData->nn);
- fts5BufferAppendBlob(&p->rc, &buf, sizeof(aHdr), aHdr);
- fts5BufferAppendVarint(&p->rc, &buf, pSeg->term.n);
- fts5BufferAppendBlob(&p->rc, &buf, pSeg->term.n, pSeg->term.p);
- fts5BufferAppendBlob(&p->rc, &buf, pData->szLeaf-iOff, &pData->p[iOff]);
- if( p->rc==SQLITE_OK ){
- /* Set the szLeaf field */
- fts5PutU16(&buf.p[2], (u16)buf.n);
- }
+ if( iOff>pData->szLeaf ){
+ /* This can occur if the pages that the segments occupy overlap - if
+ ** a single page has been assigned to more than one segment. In
+ ** this case a prior iteration of this loop may have corrupted the
+ ** segment currently being trimmed. */
+ p->rc = FTS5_CORRUPT;
+ }else{
+ fts5BufferZero(&buf);
+ fts5BufferGrow(&p->rc, &buf, pData->nn);
+ fts5BufferAppendBlob(&p->rc, &buf, sizeof(aHdr), aHdr);
+ fts5BufferAppendVarint(&p->rc, &buf, pSeg->term.n);
+ fts5BufferAppendBlob(&p->rc, &buf, pSeg->term.n, pSeg->term.p);
+ fts5BufferAppendBlob(&p->rc, &buf, pData->szLeaf-iOff,&pData->p[iOff]);
+ if( p->rc==SQLITE_OK ){
+ /* Set the szLeaf field */
+ fts5PutU16(&buf.p[2], (u16)buf.n);
+ }
- /* Set up the new page-index array */
- fts5BufferAppendVarint(&p->rc, &buf, 4);
- if( pSeg->iLeafPgno==pSeg->iTermLeafPgno
- && pSeg->iEndofDoclist<pData->szLeaf
- ){
- int nDiff = pData->szLeaf - pSeg->iEndofDoclist;
- fts5BufferAppendVarint(&p->rc, &buf, buf.n - 1 - nDiff - 4);
- fts5BufferAppendBlob(&p->rc, &buf,
- pData->nn - pSeg->iPgidxOff, &pData->p[pSeg->iPgidxOff]
- );
- }
+ /* Set up the new page-index array */
+ fts5BufferAppendVarint(&p->rc, &buf, 4);
+ if( pSeg->iLeafPgno==pSeg->iTermLeafPgno
+ && pSeg->iEndofDoclist<pData->szLeaf
+ ){
+ int nDiff = pData->szLeaf - pSeg->iEndofDoclist;
+ fts5BufferAppendVarint(&p->rc, &buf, buf.n - 1 - nDiff - 4);
+ fts5BufferAppendBlob(&p->rc, &buf,
+ pData->nn - pSeg->iPgidxOff, &pData->p[pSeg->iPgidxOff]
+ );
+ }
+ pSeg->pSeg->pgnoFirst = pSeg->iTermLeafPgno;
+ fts5DataDelete(p, FTS5_SEGMENT_ROWID(iId, 1), iLeafRowid);
+ fts5DataWrite(p, iLeafRowid, buf.p, buf.n);
+ }
fts5DataRelease(pData);
- pSeg->pSeg->pgnoFirst = pSeg->iTermLeafPgno;
- fts5DataDelete(p, FTS5_SEGMENT_ROWID(iId, 1), iLeafRowid);
- fts5DataWrite(p, iLeafRowid, buf.p, buf.n);
}
}
}
@@ -210667,7 +211824,7 @@ static void fts5IndexMergeLevel(
const u8 *pTerm;
pTerm = fts5MultiIterTerm(pIter, &nTerm);
- if( nTerm!=term.n || memcmp(pTerm, term.p, nTerm) ){
+ if( nTerm!=term.n || fts5Memcmp(pTerm, term.p, nTerm) ){
if( pnRem && writer.nLeafWritten>nRem ){
break;
}
@@ -210922,6 +212079,7 @@ static void fts5FlushOneHash(Fts5Index *p){
/* Write the term for this entry to disk. */
sqlite3Fts5HashScanEntry(pHash, &zTerm, &pDoclist, &nDoclist);
fts5WriteAppendTerm(p, &writer, (int)strlen(zTerm), (const u8*)zTerm);
+ if( p->rc!=SQLITE_OK ) break;
assert( writer.bFirstRowidInPage==0 );
if( pgsz>=(pBuf->n + pPgidx->n + nDoclist + 1) ){
@@ -210944,6 +212102,7 @@ static void fts5FlushOneHash(Fts5Index *p){
pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], iRowid);
writer.bFirstRowidInPage = 0;
fts5WriteDlidxAppend(p, &writer, iRowid);
+ if( p->rc!=SQLITE_OK ) break;
}else{
pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], iDelta);
}
@@ -211001,7 +212160,7 @@ static void fts5FlushOneHash(Fts5Index *p){
/* TODO2: Doclist terminator written here. */
/* pBuf->p[pBuf->n++] = '\0'; */
assert( pBuf->n<=pBuf->nSpace );
- sqlite3Fts5HashScanNext(pHash);
+ if( p->rc==SQLITE_OK ) sqlite3Fts5HashScanNext(pHash);
}
sqlite3Fts5HashClear(pHash);
fts5WriteFinish(p, &writer, &pgnoLast);
@@ -211045,7 +212204,7 @@ static Fts5Structure *fts5IndexOptimizeStruct(
Fts5Structure *pStruct
){
Fts5Structure *pNew = 0;
- int nByte = sizeof(Fts5Structure);
+ sqlite3_int64 nByte = sizeof(Fts5Structure);
int nSeg = pStruct->nSegment;
int i;
@@ -211175,11 +212334,13 @@ static void fts5AppendPoslist(
Fts5Buffer *pBuf
){
int nData = pMulti->base.nData;
+ int nByte = nData + 9 + 9 + FTS5_DATA_ZERO_PADDING;
assert( nData>0 );
- if( p->rc==SQLITE_OK && 0==fts5BufferGrow(&p->rc, pBuf, nData+9+9) ){
+ if( p->rc==SQLITE_OK && 0==fts5BufferGrow(&p->rc, pBuf, nByte) ){
fts5BufferSafeAppendVarint(pBuf, iDelta);
fts5BufferSafeAppendVarint(pBuf, nData*2);
fts5BufferSafeAppendBlob(pBuf, pMulti->base.pData, nData);
+ memset(&pBuf->p[pBuf->n], 0, FTS5_DATA_ZERO_PADDING);
}
}
@@ -211360,6 +212521,8 @@ static void fts5MergePrefixLists(
int iOff2 = 0;
u8 *a1 = &i1.aPoslist[i1.nSize];
u8 *a2 = &i2.aPoslist[i2.nSize];
+ int nCopy;
+ u8 *aCopy;
i64 iPrev = 0;
Fts5PoslistWriter writer;
@@ -211391,7 +212554,7 @@ static void fts5MergePrefixLists(
sqlite3Fts5PoslistNext64(a1, i1.nPoslist, &iOff1, &iPos1);
if( iPos1<0 ) break;
}else{
- assert( iPos2!=iPrev );
+ assert_nc( iPos2!=iPrev );
sqlite3Fts5PoslistSafeAppend(&tmp, &iPrev, iPos2);
sqlite3Fts5PoslistNext64(a2, i2.nPoslist, &iOff2, &iPos2);
if( iPos2<0 ) break;
@@ -211403,11 +212566,16 @@ static void fts5MergePrefixLists(
if( iPos1!=iPrev ){
sqlite3Fts5PoslistSafeAppend(&tmp, &iPrev, iPos1);
}
- fts5BufferSafeAppendBlob(&tmp, &a1[iOff1], i1.nPoslist-iOff1);
+ aCopy = &a1[iOff1];
+ nCopy = i1.nPoslist - iOff1;
}else{
assert( iPos2>=0 && iPos2!=iPrev );
sqlite3Fts5PoslistSafeAppend(&tmp, &iPrev, iPos2);
- fts5BufferSafeAppendBlob(&tmp, &a2[iOff2], i2.nPoslist-iOff2);
+ aCopy = &a2[iOff2];
+ nCopy = i2.nPoslist - iOff2;
+ }
+ if( nCopy>0 ){
+ fts5BufferSafeAppendBlob(&tmp, aCopy, nCopy);
}
/* WRITEPOSLISTSIZE */
@@ -211415,6 +212583,7 @@ static void fts5MergePrefixLists(
fts5BufferSafeAppendBlob(&out, tmp.p, tmp.n);
fts5DoclistIterNext(&i1);
fts5DoclistIterNext(&i2);
+ assert( out.n<=(p1->n+p2->n+9) );
if( i1.aPoslist==0 || i2.aPoslist==0 ) break;
}
}
@@ -211516,7 +212685,7 @@ static void fts5SetupPrefixIter(
}
fts5MultiIterFree(p1);
- pData = fts5IdxMalloc(p, sizeof(Fts5Data) + doclist.n);
+ pData = fts5IdxMalloc(p, sizeof(Fts5Data)+doclist.n+FTS5_DATA_ZERO_PADDING);
if( pData ){
pData->p = (u8*)&pData[1];
pData->nn = pData->szLeaf = doclist.n;
@@ -212278,11 +213447,11 @@ static void fts5IndexIntegrityCheckSegment(
iOff = fts5LeafFirstTermOff(pLeaf);
iRowidOff = fts5LeafFirstRowidOff(pLeaf);
- if( iRowidOff>=iOff ){
+ if( iRowidOff>=iOff || iOff>=pLeaf->szLeaf ){
p->rc = FTS5_CORRUPT;
}else{
iOff += fts5GetVarint32(&pLeaf->p[iOff], nTerm);
- res = memcmp(&pLeaf->p[iOff], zIdxTerm, MIN(nTerm, nIdxTerm));
+ res = fts5Memcmp(&pLeaf->p[iOff], zIdxTerm, MIN(nTerm, nIdxTerm));
if( res==0 ) res = nTerm - nIdxTerm;
if( res<0 ) p->rc = FTS5_CORRUPT;
}
@@ -212677,7 +213846,7 @@ static void fts5DecodeFunction(
u8 *a = 0;
Fts5Buffer s; /* Build up text to return here */
int rc = SQLITE_OK; /* Return code */
- int nSpace = 0;
+ sqlite3_int64 nSpace = 0;
int eDetailNone = (sqlite3_user_data(pCtx)!=0);
assert( nArg==2 );
@@ -212693,8 +213862,7 @@ static void fts5DecodeFunction(
nSpace = n + FTS5_DATA_ZERO_PADDING;
a = (u8*)sqlite3Fts5MallocZero(&rc, nSpace);
if( a==0 ) goto decode_out;
- memcpy(a, aBlob, n);
-
+ if( n>0 ) memcpy(a, aBlob, n);
fts5DecodeRowid(iRowid, &iSegid, &bDlidx, &iHeight, &iPgno);
@@ -212789,6 +213957,9 @@ static void fts5DecodeFunction(
iPgidxOff = szLeaf = fts5GetU16(&a[2]);
if( iPgidxOff<n ){
fts5GetVarint32(&a[iPgidxOff], iTermOff);
+ }else if( iPgidxOff>n ){
+ rc = FTS5_CORRUPT;
+ goto decode_out;
}
}
@@ -212800,14 +213971,22 @@ static void fts5DecodeFunction(
}else{
iOff = szLeaf;
}
+ if( iOff>n ){
+ rc = FTS5_CORRUPT;
+ goto decode_out;
+ }
fts5DecodePoslist(&rc, &s, &a[4], iOff-4);
/* Decode any more doclist data that appears on the page before the
** first term. */
nDoclist = (iTermOff ? iTermOff : szLeaf) - iOff;
+ if( nDoclist+iOff>n ){
+ rc = FTS5_CORRUPT;
+ goto decode_out;
+ }
fts5DecodeDoclist(&rc, &s, &a[iOff], nDoclist);
- while( iPgidxOff<n ){
+ while( iPgidxOff<n && rc==SQLITE_OK ){
int bFirst = (iPgidxOff==szLeaf); /* True for first term on page */
int nByte; /* Bytes of data */
int iEnd;
@@ -212822,12 +214001,24 @@ static void fts5DecodeFunction(
}else{
iEnd = szLeaf;
}
+ if( iEnd>szLeaf ){
+ rc = FTS5_CORRUPT;
+ break;
+ }
if( bFirst==0 ){
iOff += fts5GetVarint32(&a[iOff], nByte);
+ if( nByte>term.n ){
+ rc = FTS5_CORRUPT;
+ break;
+ }
term.n = nByte;
}
iOff += fts5GetVarint32(&a[iOff], nByte);
+ if( iOff+nByte>n ){
+ rc = FTS5_CORRUPT;
+ break;
+ }
fts5BufferAppendBlob(&rc, &term, nByte, &a[iOff]);
iOff += nByte;
@@ -212951,8 +214142,8 @@ SQLITE_API int sqlite3_fts5_may_be_corrupt = 1;
typedef struct Fts5Auxdata Fts5Auxdata;
typedef struct Fts5Auxiliary Fts5Auxiliary;
typedef struct Fts5Cursor Fts5Cursor;
+typedef struct Fts5FullTable Fts5FullTable;
typedef struct Fts5Sorter Fts5Sorter;
-typedef struct Fts5Table Fts5Table;
typedef struct Fts5TokenizerModule Fts5TokenizerModule;
/*
@@ -213033,13 +214224,8 @@ struct Fts5TokenizerModule {
Fts5TokenizerModule *pNext; /* Next registered tokenizer module */
};
-/*
-** Virtual-table object.
-*/
-struct Fts5Table {
- sqlite3_vtab base; /* Base class used by SQLite core */
- Fts5Config *pConfig; /* Virtual table configuration */
- Fts5Index *pIndex; /* Full-text index */
+struct Fts5FullTable {
+ Fts5Table p; /* Public class members from fts5Int.h */
Fts5Storage *pStorage; /* Document store */
Fts5Global *pGlobal; /* Global (connection wide) data */
Fts5Cursor *pSortCsr; /* Sort data from this cursor */
@@ -213177,7 +214363,7 @@ struct Fts5Auxdata {
#define FTS5_SAVEPOINT 5
#define FTS5_RELEASE 6
#define FTS5_ROLLBACKTO 7
-static void fts5CheckTransactionState(Fts5Table *p, int op, int iSavepoint){
+static void fts5CheckTransactionState(Fts5FullTable *p, int op, int iSavepoint){
switch( op ){
case FTS5_BEGIN:
assert( p->ts.eState==0 );
@@ -213216,7 +214402,7 @@ static void fts5CheckTransactionState(Fts5Table *p, int op, int iSavepoint){
case FTS5_ROLLBACKTO:
assert( p->ts.eState==1 );
- assert( iSavepoint>=0 );
+ assert( iSavepoint>=-1 );
assert( iSavepoint<=p->ts.iSavepoint );
p->ts.iSavepoint = iSavepoint;
break;
@@ -213229,18 +214415,18 @@ static void fts5CheckTransactionState(Fts5Table *p, int op, int iSavepoint){
/*
** Return true if pTab is a contentless table.
*/
-static int fts5IsContentless(Fts5Table *pTab){
- return pTab->pConfig->eContent==FTS5_CONTENT_NONE;
+static int fts5IsContentless(Fts5FullTable *pTab){
+ return pTab->p.pConfig->eContent==FTS5_CONTENT_NONE;
}
/*
** Delete a virtual table handle allocated by fts5InitVtab().
*/
-static void fts5FreeVtab(Fts5Table *pTab){
+static void fts5FreeVtab(Fts5FullTable *pTab){
if( pTab ){
- sqlite3Fts5IndexClose(pTab->pIndex);
+ sqlite3Fts5IndexClose(pTab->p.pIndex);
sqlite3Fts5StorageClose(pTab->pStorage);
- sqlite3Fts5ConfigFree(pTab->pConfig);
+ sqlite3Fts5ConfigFree(pTab->p.pConfig);
sqlite3_free(pTab);
}
}
@@ -213249,7 +214435,7 @@ static void fts5FreeVtab(Fts5Table *pTab){
** The xDisconnect() virtual table method.
*/
static int fts5DisconnectMethod(sqlite3_vtab *pVtab){
- fts5FreeVtab((Fts5Table*)pVtab);
+ fts5FreeVtab((Fts5FullTable*)pVtab);
return SQLITE_OK;
}
@@ -213260,7 +214446,7 @@ static int fts5DestroyMethod(sqlite3_vtab *pVtab){
Fts5Table *pTab = (Fts5Table*)pVtab;
int rc = sqlite3Fts5DropAll(pTab->pConfig);
if( rc==SQLITE_OK ){
- fts5FreeVtab((Fts5Table*)pVtab);
+ fts5FreeVtab((Fts5FullTable*)pVtab);
}
return rc;
}
@@ -213289,28 +214475,28 @@ static int fts5InitVtab(
const char **azConfig = (const char**)argv;
int rc = SQLITE_OK; /* Return code */
Fts5Config *pConfig = 0; /* Results of parsing argc/argv */
- Fts5Table *pTab = 0; /* New virtual table object */
+ Fts5FullTable *pTab = 0; /* New virtual table object */
/* Allocate the new vtab object and parse the configuration */
- pTab = (Fts5Table*)sqlite3Fts5MallocZero(&rc, sizeof(Fts5Table));
+ pTab = (Fts5FullTable*)sqlite3Fts5MallocZero(&rc, sizeof(Fts5FullTable));
if( rc==SQLITE_OK ){
rc = sqlite3Fts5ConfigParse(pGlobal, db, argc, azConfig, &pConfig, pzErr);
assert( (rc==SQLITE_OK && *pzErr==0) || pConfig==0 );
}
if( rc==SQLITE_OK ){
- pTab->pConfig = pConfig;
+ pTab->p.pConfig = pConfig;
pTab->pGlobal = pGlobal;
}
/* Open the index sub-system */
if( rc==SQLITE_OK ){
- rc = sqlite3Fts5IndexOpen(pConfig, bCreate, &pTab->pIndex, pzErr);
+ rc = sqlite3Fts5IndexOpen(pConfig, bCreate, &pTab->p.pIndex, pzErr);
}
/* Open the storage sub-system */
if( rc==SQLITE_OK ){
rc = sqlite3Fts5StorageOpen(
- pConfig, pTab->pIndex, bCreate, &pTab->pStorage, pzErr
+ pConfig, pTab->p.pIndex, bCreate, &pTab->pStorage, pzErr
);
}
@@ -213323,8 +214509,8 @@ static int fts5InitVtab(
if( rc==SQLITE_OK ){
assert( pConfig->pzErrmsg==0 );
pConfig->pzErrmsg = pzErr;
- rc = sqlite3Fts5IndexLoadConfig(pTab->pIndex);
- sqlite3Fts5IndexRollback(pTab->pIndex);
+ rc = sqlite3Fts5IndexLoadConfig(pTab->p.pIndex);
+ sqlite3Fts5IndexRollback(pTab->p.pIndex);
pConfig->pzErrmsg = 0;
}
@@ -213537,7 +214723,7 @@ static int fts5BestIndexMethod(sqlite3_vtab *pVTab, sqlite3_index_info *pInfo){
return SQLITE_OK;
}
-static int fts5NewTransaction(Fts5Table *pTab){
+static int fts5NewTransaction(Fts5FullTable *pTab){
Fts5Cursor *pCsr;
for(pCsr=pTab->pGlobal->pCsr; pCsr; pCsr=pCsr->pNext){
if( pCsr->base.pVtab==(sqlite3_vtab*)pTab ) return SQLITE_OK;
@@ -213549,16 +214735,16 @@ static int fts5NewTransaction(Fts5Table *pTab){
** Implementation of xOpen method.
*/
static int fts5OpenMethod(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCsr){
- Fts5Table *pTab = (Fts5Table*)pVTab;
- Fts5Config *pConfig = pTab->pConfig;
+ Fts5FullTable *pTab = (Fts5FullTable*)pVTab;
+ Fts5Config *pConfig = pTab->p.pConfig;
Fts5Cursor *pCsr = 0; /* New cursor object */
- int nByte; /* Bytes of space to allocate */
+ sqlite3_int64 nByte; /* Bytes of space to allocate */
int rc; /* Return code */
rc = fts5NewTransaction(pTab);
if( rc==SQLITE_OK ){
nByte = sizeof(Fts5Cursor) + pConfig->nCol * sizeof(int);
- pCsr = (Fts5Cursor*)sqlite3_malloc(nByte);
+ pCsr = (Fts5Cursor*)sqlite3_malloc64(nByte);
if( pCsr ){
Fts5Global *pGlobal = pTab->pGlobal;
memset(pCsr, 0, nByte);
@@ -213596,7 +214782,7 @@ static void fts5CsrNewrow(Fts5Cursor *pCsr){
}
static void fts5FreeCursorComponents(Fts5Cursor *pCsr){
- Fts5Table *pTab = (Fts5Table*)(pCsr->base.pVtab);
+ Fts5FullTable *pTab = (Fts5FullTable*)(pCsr->base.pVtab);
Fts5Auxdata *pData;
Fts5Auxdata *pNext;
@@ -213640,7 +214826,7 @@ static void fts5FreeCursorComponents(Fts5Cursor *pCsr){
*/
static int fts5CloseMethod(sqlite3_vtab_cursor *pCursor){
if( pCursor ){
- Fts5Table *pTab = (Fts5Table*)(pCursor->pVtab);
+ Fts5FullTable *pTab = (Fts5FullTable*)(pCursor->pVtab);
Fts5Cursor *pCsr = (Fts5Cursor*)pCursor;
Fts5Cursor **pp;
@@ -213697,7 +214883,7 @@ static int fts5SorterNext(Fts5Cursor *pCsr){
** Set the FTS5CSR_REQUIRE_RESEEK flag on all FTS5_PLAN_MATCH cursors
** open on table pTab.
*/
-static void fts5TripCursors(Fts5Table *pTab){
+static void fts5TripCursors(Fts5FullTable *pTab){
Fts5Cursor *pCsr;
for(pCsr=pTab->pGlobal->pCsr; pCsr; pCsr=pCsr->pNext){
if( pCsr->ePlan==FTS5_PLAN_MATCH
@@ -213724,11 +214910,11 @@ static int fts5CursorReseek(Fts5Cursor *pCsr, int *pbSkip){
int rc = SQLITE_OK;
assert( *pbSkip==0 );
if( CsrFlagTest(pCsr, FTS5CSR_REQUIRE_RESEEK) ){
- Fts5Table *pTab = (Fts5Table*)(pCsr->base.pVtab);
+ Fts5FullTable *pTab = (Fts5FullTable*)(pCsr->base.pVtab);
int bDesc = pCsr->bDesc;
i64 iRowid = sqlite3Fts5ExprRowid(pCsr->pExpr);
- rc = sqlite3Fts5ExprFirst(pCsr->pExpr, pTab->pIndex, iRowid, bDesc);
+ rc = sqlite3Fts5ExprFirst(pCsr->pExpr, pTab->p.pIndex, iRowid, bDesc);
if( rc==SQLITE_OK && iRowid!=sqlite3Fts5ExprRowid(pCsr->pExpr) ){
*pbSkip = 1;
}
@@ -213825,18 +215011,22 @@ static int fts5PrepareStatement(
return rc;
}
-static int fts5CursorFirstSorted(Fts5Table *pTab, Fts5Cursor *pCsr, int bDesc){
- Fts5Config *pConfig = pTab->pConfig;
+static int fts5CursorFirstSorted(
+ Fts5FullTable *pTab,
+ Fts5Cursor *pCsr,
+ int bDesc
+){
+ Fts5Config *pConfig = pTab->p.pConfig;
Fts5Sorter *pSorter;
int nPhrase;
- int nByte;
+ sqlite3_int64 nByte;
int rc;
const char *zRank = pCsr->zRank;
const char *zRankArgs = pCsr->zRankArgs;
nPhrase = sqlite3Fts5ExprPhraseCount(pCsr->pExpr);
nByte = sizeof(Fts5Sorter) + sizeof(int) * (nPhrase-1);
- pSorter = (Fts5Sorter*)sqlite3_malloc(nByte);
+ pSorter = (Fts5Sorter*)sqlite3_malloc64(nByte);
if( pSorter==0 ) return SQLITE_NOMEM;
memset(pSorter, 0, nByte);
pSorter->nIdx = nPhrase;
@@ -213873,10 +215063,10 @@ static int fts5CursorFirstSorted(Fts5Table *pTab, Fts5Cursor *pCsr, int bDesc){
return rc;
}
-static int fts5CursorFirst(Fts5Table *pTab, Fts5Cursor *pCsr, int bDesc){
+static int fts5CursorFirst(Fts5FullTable *pTab, Fts5Cursor *pCsr, int bDesc){
int rc;
Fts5Expr *pExpr = pCsr->pExpr;
- rc = sqlite3Fts5ExprFirst(pExpr, pTab->pIndex, pCsr->iFirstRowid, bDesc);
+ rc = sqlite3Fts5ExprFirst(pExpr, pTab->p.pIndex, pCsr->iFirstRowid, bDesc);
if( sqlite3Fts5ExprEof(pExpr) ){
CsrFlagSet(pCsr, FTS5CSR_EOF);
}
@@ -213891,7 +215081,7 @@ static int fts5CursorFirst(Fts5Table *pTab, Fts5Cursor *pCsr, int bDesc){
** parameters.
*/
static int fts5SpecialMatch(
- Fts5Table *pTab,
+ Fts5FullTable *pTab,
Fts5Cursor *pCsr,
const char *zQuery
){
@@ -213902,18 +215092,18 @@ static int fts5SpecialMatch(
while( z[0]==' ' ) z++;
for(n=0; z[n] && z[n]!=' '; n++);
- assert( pTab->base.zErrMsg==0 );
+ assert( pTab->p.base.zErrMsg==0 );
pCsr->ePlan = FTS5_PLAN_SPECIAL;
if( 0==sqlite3_strnicmp("reads", z, n) ){
- pCsr->iSpecial = sqlite3Fts5IndexReads(pTab->pIndex);
+ pCsr->iSpecial = sqlite3Fts5IndexReads(pTab->p.pIndex);
}
else if( 0==sqlite3_strnicmp("id", z, n) ){
pCsr->iSpecial = pCsr->iCsrId;
}
else{
/* An unrecognized directive. Return an error message. */
- pTab->base.zErrMsg = sqlite3_mprintf("unknown special query: %.*s", n, z);
+ pTab->p.base.zErrMsg = sqlite3_mprintf("unknown special query: %.*s", n, z);
rc = SQLITE_ERROR;
}
@@ -213925,7 +215115,7 @@ static int fts5SpecialMatch(
** pTab. If one is found, return a pointer to the corresponding Fts5Auxiliary
** structure. Otherwise, if no such function exists, return NULL.
*/
-static Fts5Auxiliary *fts5FindAuxiliary(Fts5Table *pTab, const char *zName){
+static Fts5Auxiliary *fts5FindAuxiliary(Fts5FullTable *pTab, const char *zName){
Fts5Auxiliary *pAux;
for(pAux=pTab->pGlobal->pAux; pAux; pAux=pAux->pNext){
@@ -213938,8 +215128,8 @@ static Fts5Auxiliary *fts5FindAuxiliary(Fts5Table *pTab, const char *zName){
static int fts5FindRankFunction(Fts5Cursor *pCsr){
- Fts5Table *pTab = (Fts5Table*)(pCsr->base.pVtab);
- Fts5Config *pConfig = pTab->pConfig;
+ Fts5FullTable *pTab = (Fts5FullTable*)(pCsr->base.pVtab);
+ Fts5Config *pConfig = pTab->p.pConfig;
int rc = SQLITE_OK;
Fts5Auxiliary *pAux = 0;
const char *zRank = pCsr->zRank;
@@ -213955,7 +215145,7 @@ static int fts5FindRankFunction(Fts5Cursor *pCsr){
assert( rc==SQLITE_OK || pCsr->pRankArgStmt==0 );
if( rc==SQLITE_OK ){
if( SQLITE_ROW==sqlite3_step(pStmt) ){
- int nByte;
+ sqlite3_int64 nByte;
pCsr->nRankArg = sqlite3_column_count(pStmt);
nByte = sizeof(sqlite3_value*)*pCsr->nRankArg;
pCsr->apRankArg = (sqlite3_value**)sqlite3Fts5MallocZero(&rc, nByte);
@@ -213977,8 +215167,8 @@ static int fts5FindRankFunction(Fts5Cursor *pCsr){
if( rc==SQLITE_OK ){
pAux = fts5FindAuxiliary(pTab, zRank);
if( pAux==0 ){
- assert( pTab->base.zErrMsg==0 );
- pTab->base.zErrMsg = sqlite3_mprintf("no such function: %s", zRank);
+ assert( pTab->p.base.zErrMsg==0 );
+ pTab->p.base.zErrMsg = sqlite3_mprintf("no such function: %s", zRank);
rc = SQLITE_ERROR;
}
}
@@ -214053,8 +215243,8 @@ static int fts5FilterMethod(
int nVal, /* Number of elements in apVal */
sqlite3_value **apVal /* Arguments for the indexing scheme */
){
- Fts5Table *pTab = (Fts5Table*)(pCursor->pVtab);
- Fts5Config *pConfig = pTab->pConfig;
+ Fts5FullTable *pTab = (Fts5FullTable*)(pCursor->pVtab);
+ Fts5Config *pConfig = pTab->p.pConfig;
Fts5Cursor *pCsr = (Fts5Cursor*)pCursor;
int rc = SQLITE_OK; /* Error code */
int iVal = 0; /* Counter for apVal[] */
@@ -214083,8 +215273,8 @@ static int fts5FilterMethod(
assert( pCsr->zRank==0 );
assert( pCsr->zRankArgs==0 );
- assert( pzErrmsg==0 || pzErrmsg==&pTab->base.zErrMsg );
- pConfig->pzErrmsg = &pTab->base.zErrMsg;
+ assert( pzErrmsg==0 || pzErrmsg==&pTab->p.base.zErrMsg );
+ pConfig->pzErrmsg = &pTab->p.base.zErrMsg;
/* Decode the arguments passed through to this function.
**
@@ -214150,7 +215340,7 @@ static int fts5FilterMethod(
** but a request for an internal parameter. */
rc = fts5SpecialMatch(pTab, pCsr, &zExpr[1]);
}else{
- char **pzErr = &pTab->base.zErrMsg;
+ char **pzErr = &pTab->p.base.zErrMsg;
rc = sqlite3Fts5ExprNew(pConfig, iCol, zExpr, &pCsr->pExpr, pzErr);
if( rc==SQLITE_OK ){
if( bOrderByRank ){
@@ -214173,7 +215363,7 @@ static int fts5FilterMethod(
** by rowid (ePlan==FTS5_PLAN_ROWID). */
pCsr->ePlan = (pRowidEq ? FTS5_PLAN_ROWID : FTS5_PLAN_SCAN);
rc = sqlite3Fts5StorageStmt(
- pTab->pStorage, fts5StmtType(pCsr), &pCsr->pStmt, &pTab->base.zErrMsg
+ pTab->pStorage, fts5StmtType(pCsr), &pCsr->pStmt, &pTab->p.base.zErrMsg
);
if( rc==SQLITE_OK ){
if( pCsr->ePlan==FTS5_PLAN_ROWID ){
@@ -214256,12 +215446,12 @@ static int fts5SeekCursor(Fts5Cursor *pCsr, int bErrormsg){
/* If the cursor does not yet have a statement handle, obtain one now. */
if( pCsr->pStmt==0 ){
- Fts5Table *pTab = (Fts5Table*)(pCsr->base.pVtab);
+ Fts5FullTable *pTab = (Fts5FullTable*)(pCsr->base.pVtab);
int eStmt = fts5StmtType(pCsr);
rc = sqlite3Fts5StorageStmt(
- pTab->pStorage, eStmt, &pCsr->pStmt, (bErrormsg?&pTab->base.zErrMsg:0)
+ pTab->pStorage, eStmt, &pCsr->pStmt, (bErrormsg?&pTab->p.base.zErrMsg:0)
);
- assert( rc!=SQLITE_OK || pTab->base.zErrMsg==0 );
+ assert( rc!=SQLITE_OK || pTab->p.base.zErrMsg==0 );
assert( CsrFlagTest(pCsr, FTS5CSR_REQUIRE_CONTENT) );
}
@@ -214283,11 +215473,11 @@ static int fts5SeekCursor(Fts5Cursor *pCsr, int bErrormsg){
return rc;
}
-static void fts5SetVtabError(Fts5Table *p, const char *zFormat, ...){
+static void fts5SetVtabError(Fts5FullTable *p, const char *zFormat, ...){
va_list ap; /* ... printf arguments */
va_start(ap, zFormat);
- assert( p->base.zErrMsg==0 );
- p->base.zErrMsg = sqlite3_vmprintf(zFormat, ap);
+ assert( p->p.base.zErrMsg==0 );
+ p->p.base.zErrMsg = sqlite3_vmprintf(zFormat, ap);
va_end(ap);
}
@@ -214307,11 +215497,11 @@ static void fts5SetVtabError(Fts5Table *p, const char *zFormat, ...){
** more commands are added to this function.
*/
static int fts5SpecialInsert(
- Fts5Table *pTab, /* Fts5 table object */
+ Fts5FullTable *pTab, /* Fts5 table object */
const char *zCmd, /* Text inserted into table-name column */
sqlite3_value *pVal /* Value inserted into rank column */
){
- Fts5Config *pConfig = pTab->pConfig;
+ Fts5Config *pConfig = pTab->p.pConfig;
int rc = SQLITE_OK;
int bError = 0;
@@ -214346,9 +215536,9 @@ static int fts5SpecialInsert(
pConfig->bPrefixIndex = sqlite3_value_int(pVal);
#endif
}else{
- rc = sqlite3Fts5IndexLoadConfig(pTab->pIndex);
+ rc = sqlite3Fts5IndexLoadConfig(pTab->p.pIndex);
if( rc==SQLITE_OK ){
- rc = sqlite3Fts5ConfigSetValue(pTab->pConfig, zCmd, pVal, &bError);
+ rc = sqlite3Fts5ConfigSetValue(pTab->p.pConfig, zCmd, pVal, &bError);
}
if( rc==SQLITE_OK ){
if( bError ){
@@ -214362,7 +215552,7 @@ static int fts5SpecialInsert(
}
static int fts5SpecialDelete(
- Fts5Table *pTab,
+ Fts5FullTable *pTab,
sqlite3_value **apVal
){
int rc = SQLITE_OK;
@@ -214376,7 +215566,7 @@ static int fts5SpecialDelete(
static void fts5StorageInsert(
int *pRc,
- Fts5Table *pTab,
+ Fts5FullTable *pTab,
sqlite3_value **apVal,
i64 *piRowid
){
@@ -214410,8 +215600,8 @@ static int fts5UpdateMethod(
sqlite3_value **apVal, /* Array of arguments */
sqlite_int64 *pRowid /* OUT: The affected (or effected) rowid */
){
- Fts5Table *pTab = (Fts5Table*)pVtab;
- Fts5Config *pConfig = pTab->pConfig;
+ Fts5FullTable *pTab = (Fts5FullTable*)pVtab;
+ Fts5Config *pConfig = pTab->p.pConfig;
int eType0; /* value_type() of apVal[0] */
int rc = SQLITE_OK; /* Return code */
@@ -214420,12 +215610,11 @@ static int fts5UpdateMethod(
assert( pVtab->zErrMsg==0 );
assert( nArg==1 || nArg==(2+pConfig->nCol+2) );
- assert( nArg==1
- || sqlite3_value_type(apVal[1])==SQLITE_INTEGER
- || sqlite3_value_type(apVal[1])==SQLITE_NULL
+ assert( sqlite3_value_type(apVal[0])==SQLITE_INTEGER
+ || sqlite3_value_type(apVal[0])==SQLITE_NULL
);
- assert( pTab->pConfig->pzErrmsg==0 );
- pTab->pConfig->pzErrmsg = &pTab->base.zErrMsg;
+ assert( pTab->p.pConfig->pzErrmsg==0 );
+ pTab->p.pConfig->pzErrmsg = &pTab->p.base.zErrMsg;
/* Put any active cursors into REQUIRE_SEEK state. */
fts5TripCursors(pTab);
@@ -214466,7 +215655,7 @@ static int fts5UpdateMethod(
/* Filter out attempts to run UPDATE or DELETE on contentless tables.
** This is not suported. */
if( eType0==SQLITE_INTEGER && fts5IsContentless(pTab) ){
- pTab->base.zErrMsg = sqlite3_mprintf(
+ pTab->p.base.zErrMsg = sqlite3_mprintf(
"cannot %s contentless fts5 table: %s",
(nArg>1 ? "UPDATE" : "DELETE from"), pConfig->zName
);
@@ -214479,46 +215668,52 @@ static int fts5UpdateMethod(
rc = sqlite3Fts5StorageDelete(pTab->pStorage, iDel, 0);
}
- /* INSERT */
- else if( eType0!=SQLITE_INTEGER ){
- /* If this is a REPLACE, first remove the current entry (if any) */
- if( eConflict==SQLITE_REPLACE
- && sqlite3_value_type(apVal[1])==SQLITE_INTEGER
- ){
- i64 iNew = sqlite3_value_int64(apVal[1]); /* Rowid to delete */
- rc = sqlite3Fts5StorageDelete(pTab->pStorage, iNew, 0);
+ /* INSERT or UPDATE */
+ else{
+ int eType1 = sqlite3_value_numeric_type(apVal[1]);
+
+ if( eType1!=SQLITE_INTEGER && eType1!=SQLITE_NULL ){
+ rc = SQLITE_MISMATCH;
}
- fts5StorageInsert(&rc, pTab, apVal, pRowid);
- }
- /* UPDATE */
- else{
- i64 iOld = sqlite3_value_int64(apVal[0]); /* Old rowid */
- i64 iNew = sqlite3_value_int64(apVal[1]); /* New rowid */
- if( iOld!=iNew ){
- if( eConflict==SQLITE_REPLACE ){
- rc = sqlite3Fts5StorageDelete(pTab->pStorage, iOld, 0);
- if( rc==SQLITE_OK ){
- rc = sqlite3Fts5StorageDelete(pTab->pStorage, iNew, 0);
- }
- fts5StorageInsert(&rc, pTab, apVal, pRowid);
- }else{
- rc = sqlite3Fts5StorageContentInsert(pTab->pStorage, apVal, pRowid);
- if( rc==SQLITE_OK ){
+ else if( eType0!=SQLITE_INTEGER ){
+ /* If this is a REPLACE, first remove the current entry (if any) */
+ if( eConflict==SQLITE_REPLACE && eType1==SQLITE_INTEGER ){
+ i64 iNew = sqlite3_value_int64(apVal[1]); /* Rowid to delete */
+ rc = sqlite3Fts5StorageDelete(pTab->pStorage, iNew, 0);
+ }
+ fts5StorageInsert(&rc, pTab, apVal, pRowid);
+ }
+
+ /* UPDATE */
+ else{
+ i64 iOld = sqlite3_value_int64(apVal[0]); /* Old rowid */
+ i64 iNew = sqlite3_value_int64(apVal[1]); /* New rowid */
+ if( eType1==SQLITE_INTEGER && iOld!=iNew ){
+ if( eConflict==SQLITE_REPLACE ){
rc = sqlite3Fts5StorageDelete(pTab->pStorage, iOld, 0);
+ if( rc==SQLITE_OK ){
+ rc = sqlite3Fts5StorageDelete(pTab->pStorage, iNew, 0);
+ }
+ fts5StorageInsert(&rc, pTab, apVal, pRowid);
+ }else{
+ rc = sqlite3Fts5StorageContentInsert(pTab->pStorage, apVal, pRowid);
+ if( rc==SQLITE_OK ){
+ rc = sqlite3Fts5StorageDelete(pTab->pStorage, iOld, 0);
+ }
+ if( rc==SQLITE_OK ){
+ rc = sqlite3Fts5StorageIndexInsert(pTab->pStorage, apVal,*pRowid);
+ }
}
- if( rc==SQLITE_OK ){
- rc = sqlite3Fts5StorageIndexInsert(pTab->pStorage, apVal, *pRowid);
- }
+ }else{
+ rc = sqlite3Fts5StorageDelete(pTab->pStorage, iOld, 0);
+ fts5StorageInsert(&rc, pTab, apVal, pRowid);
}
- }else{
- rc = sqlite3Fts5StorageDelete(pTab->pStorage, iOld, 0);
- fts5StorageInsert(&rc, pTab, apVal, pRowid);
}
}
}
- pTab->pConfig->pzErrmsg = 0;
+ pTab->p.pConfig->pzErrmsg = 0;
return rc;
}
@@ -214527,12 +215722,12 @@ static int fts5UpdateMethod(
*/
static int fts5SyncMethod(sqlite3_vtab *pVtab){
int rc;
- Fts5Table *pTab = (Fts5Table*)pVtab;
+ Fts5FullTable *pTab = (Fts5FullTable*)pVtab;
fts5CheckTransactionState(pTab, FTS5_SYNC, 0);
- pTab->pConfig->pzErrmsg = &pTab->base.zErrMsg;
+ pTab->p.pConfig->pzErrmsg = &pTab->p.base.zErrMsg;
fts5TripCursors(pTab);
rc = sqlite3Fts5StorageSync(pTab->pStorage);
- pTab->pConfig->pzErrmsg = 0;
+ pTab->p.pConfig->pzErrmsg = 0;
return rc;
}
@@ -214540,8 +215735,8 @@ static int fts5SyncMethod(sqlite3_vtab *pVtab){
** Implementation of xBegin() method.
*/
static int fts5BeginMethod(sqlite3_vtab *pVtab){
- fts5CheckTransactionState((Fts5Table*)pVtab, FTS5_BEGIN, 0);
- fts5NewTransaction((Fts5Table*)pVtab);
+ fts5CheckTransactionState((Fts5FullTable*)pVtab, FTS5_BEGIN, 0);
+ fts5NewTransaction((Fts5FullTable*)pVtab);
return SQLITE_OK;
}
@@ -214552,7 +215747,7 @@ static int fts5BeginMethod(sqlite3_vtab *pVtab){
*/
static int fts5CommitMethod(sqlite3_vtab *pVtab){
UNUSED_PARAM(pVtab); /* Call below is a no-op for NDEBUG builds */
- fts5CheckTransactionState((Fts5Table*)pVtab, FTS5_COMMIT, 0);
+ fts5CheckTransactionState((Fts5FullTable*)pVtab, FTS5_COMMIT, 0);
return SQLITE_OK;
}
@@ -214562,7 +215757,7 @@ static int fts5CommitMethod(sqlite3_vtab *pVtab){
*/
static int fts5RollbackMethod(sqlite3_vtab *pVtab){
int rc;
- Fts5Table *pTab = (Fts5Table*)pVtab;
+ Fts5FullTable *pTab = (Fts5FullTable*)pVtab;
fts5CheckTransactionState(pTab, FTS5_ROLLBACK, 0);
rc = sqlite3Fts5StorageRollback(pTab->pStorage);
return rc;
@@ -214586,13 +215781,13 @@ static int fts5ApiColumnTotalSize(
sqlite3_int64 *pnToken
){
Fts5Cursor *pCsr = (Fts5Cursor*)pCtx;
- Fts5Table *pTab = (Fts5Table*)(pCsr->base.pVtab);
+ Fts5FullTable *pTab = (Fts5FullTable*)(pCsr->base.pVtab);
return sqlite3Fts5StorageSize(pTab->pStorage, iCol, pnToken);
}
static int fts5ApiRowCount(Fts5Context *pCtx, i64 *pnRow){
Fts5Cursor *pCsr = (Fts5Cursor*)pCtx;
- Fts5Table *pTab = (Fts5Table*)(pCsr->base.pVtab);
+ Fts5FullTable *pTab = (Fts5FullTable*)(pCsr->base.pVtab);
return sqlite3Fts5StorageRowCount(pTab->pStorage, pnRow);
}
@@ -214627,7 +215822,9 @@ static int fts5ApiColumnText(
){
int rc = SQLITE_OK;
Fts5Cursor *pCsr = (Fts5Cursor*)pCtx;
- if( fts5IsContentless((Fts5Table*)(pCsr->base.pVtab)) ){
+ if( fts5IsContentless((Fts5FullTable*)(pCsr->base.pVtab))
+ || pCsr->ePlan==FTS5_PLAN_SPECIAL
+ ){
*pz = 0;
*pn = 0;
}else{
@@ -214696,10 +215893,11 @@ static int fts5CacheInstArray(Fts5Cursor *pCsr){
int rc = SQLITE_OK;
Fts5PoslistReader *aIter; /* One iterator for each phrase */
int nIter; /* Number of iterators/phrases */
+ int nCol = ((Fts5Table*)pCsr->base.pVtab)->pConfig->nCol;
nIter = sqlite3Fts5ExprPhraseCount(pCsr->pExpr);
if( pCsr->aInstIter==0 ){
- int nByte = sizeof(Fts5PoslistReader) * nIter;
+ sqlite3_int64 nByte = sizeof(Fts5PoslistReader) * nIter;
pCsr->aInstIter = (Fts5PoslistReader*)sqlite3Fts5MallocZero(&rc, nByte);
}
aIter = pCsr->aInstIter;
@@ -214734,7 +215932,7 @@ static int fts5CacheInstArray(Fts5Cursor *pCsr){
nInst++;
if( nInst>=pCsr->nInstAlloc ){
pCsr->nInstAlloc = pCsr->nInstAlloc ? pCsr->nInstAlloc*2 : 32;
- aInst = (int*)sqlite3_realloc(
+ aInst = (int*)sqlite3_realloc64(
pCsr->aInst, pCsr->nInstAlloc*sizeof(int)*3
);
if( aInst ){
@@ -214749,6 +215947,10 @@ static int fts5CacheInstArray(Fts5Cursor *pCsr){
aInst[0] = iBest;
aInst[1] = FTS5_POS2COLUMN(aIter[iBest].iPos);
aInst[2] = FTS5_POS2OFFSET(aIter[iBest].iPos);
+ if( aInst[1]<0 || aInst[1]>=nCol ){
+ rc = FTS5_CORRUPT;
+ break;
+ }
sqlite3Fts5PoslistReaderNext(&aIter[iBest]);
}
}
@@ -214821,8 +216023,8 @@ static int fts5ColumnSizeCb(
static int fts5ApiColumnSize(Fts5Context *pCtx, int iCol, int *pnToken){
Fts5Cursor *pCsr = (Fts5Cursor*)pCtx;
- Fts5Table *pTab = (Fts5Table*)(pCsr->base.pVtab);
- Fts5Config *pConfig = pTab->pConfig;
+ Fts5FullTable *pTab = (Fts5FullTable*)(pCsr->base.pVtab);
+ Fts5Config *pConfig = pTab->p.pConfig;
int rc = SQLITE_OK;
if( CsrFlagTest(pCsr, FTS5CSR_REQUIRE_DOCSIZE) ){
@@ -215078,7 +216280,7 @@ static int fts5ApiQueryPhrase(
int(*xCallback)(const Fts5ExtensionApi*, Fts5Context*, void*)
){
Fts5Cursor *pCsr = (Fts5Cursor*)pCtx;
- Fts5Table *pTab = (Fts5Table*)(pCsr->base.pVtab);
+ Fts5FullTable *pTab = (Fts5FullTable*)(pCsr->base.pVtab);
int rc;
Fts5Cursor *pNew = 0;
@@ -215155,25 +216357,19 @@ static void fts5ApiCallback(
/*
-** Given cursor id iId, return a pointer to the corresponding Fts5Index
+** Given cursor id iId, return a pointer to the corresponding Fts5Table
** object. Or NULL If the cursor id does not exist.
-**
-** If successful, set *ppConfig to point to the associated config object
-** before returning.
*/
-static Fts5Index *sqlite3Fts5IndexFromCsrid(
+static Fts5Table *sqlite3Fts5TableFromCsrid(
Fts5Global *pGlobal, /* FTS5 global context for db handle */
- i64 iCsrId, /* Id of cursor to find */
- Fts5Config **ppConfig /* OUT: Configuration object */
+ i64 iCsrId /* Id of cursor to find */
){
Fts5Cursor *pCsr;
- Fts5Table *pTab;
-
pCsr = fts5CursorFromCsrid(pGlobal, iCsrId);
- pTab = (Fts5Table*)pCsr->base.pVtab;
- *ppConfig = pTab->pConfig;
-
- return pTab->pIndex;
+ if( pCsr ){
+ return (Fts5Table*)pCsr->base.pVtab;
+ }
+ return 0;
}
/*
@@ -215253,8 +216449,8 @@ static int fts5ColumnMethod(
sqlite3_context *pCtx, /* Context for sqlite3_result_xxx() calls */
int iCol /* Index of column to read value from */
){
- Fts5Table *pTab = (Fts5Table*)(pCursor->pVtab);
- Fts5Config *pConfig = pTab->pConfig;
+ Fts5FullTable *pTab = (Fts5FullTable*)(pCursor->pVtab);
+ Fts5Config *pConfig = pTab->p.pConfig;
Fts5Cursor *pCsr = (Fts5Cursor*)pCursor;
int rc = SQLITE_OK;
@@ -215306,7 +216502,7 @@ static int fts5FindFunctionMethod(
void (**pxFunc)(sqlite3_context*,int,sqlite3_value**), /* OUT: Result */
void **ppArg /* OUT: User data for *pxFunc */
){
- Fts5Table *pTab = (Fts5Table*)pVtab;
+ Fts5FullTable *pTab = (Fts5FullTable*)pVtab;
Fts5Auxiliary *pAux;
UNUSED_PARAM(nUnused);
@@ -215328,21 +216524,24 @@ static int fts5RenameMethod(
sqlite3_vtab *pVtab, /* Virtual table handle */
const char *zName /* New name of table */
){
- Fts5Table *pTab = (Fts5Table*)pVtab;
+ Fts5FullTable *pTab = (Fts5FullTable*)pVtab;
return sqlite3Fts5StorageRename(pTab->pStorage, zName);
}
+static int sqlite3Fts5FlushToDisk(Fts5Table *pTab){
+ fts5TripCursors((Fts5FullTable*)pTab);
+ return sqlite3Fts5StorageSync(((Fts5FullTable*)pTab)->pStorage);
+}
+
/*
** The xSavepoint() method.
**
** Flush the contents of the pending-terms table to disk.
*/
static int fts5SavepointMethod(sqlite3_vtab *pVtab, int iSavepoint){
- Fts5Table *pTab = (Fts5Table*)pVtab;
UNUSED_PARAM(iSavepoint); /* Call below is a no-op for NDEBUG builds */
- fts5CheckTransactionState(pTab, FTS5_SAVEPOINT, iSavepoint);
- fts5TripCursors(pTab);
- return sqlite3Fts5StorageSync(pTab->pStorage);
+ fts5CheckTransactionState((Fts5FullTable*)pVtab, FTS5_SAVEPOINT, iSavepoint);
+ return sqlite3Fts5FlushToDisk((Fts5Table*)pVtab);
}
/*
@@ -215351,11 +216550,9 @@ static int fts5SavepointMethod(sqlite3_vtab *pVtab, int iSavepoint){
** This is a no-op.
*/
static int fts5ReleaseMethod(sqlite3_vtab *pVtab, int iSavepoint){
- Fts5Table *pTab = (Fts5Table*)pVtab;
UNUSED_PARAM(iSavepoint); /* Call below is a no-op for NDEBUG builds */
- fts5CheckTransactionState(pTab, FTS5_RELEASE, iSavepoint);
- fts5TripCursors(pTab);
- return sqlite3Fts5StorageSync(pTab->pStorage);
+ fts5CheckTransactionState((Fts5FullTable*)pVtab, FTS5_RELEASE, iSavepoint);
+ return sqlite3Fts5FlushToDisk((Fts5Table*)pVtab);
}
/*
@@ -215364,7 +216561,7 @@ static int fts5ReleaseMethod(sqlite3_vtab *pVtab, int iSavepoint){
** Discard the contents of the pending terms table.
*/
static int fts5RollbackToMethod(sqlite3_vtab *pVtab, int iSavepoint){
- Fts5Table *pTab = (Fts5Table*)pVtab;
+ Fts5FullTable *pTab = (Fts5FullTable*)pVtab;
UNUSED_PARAM(iSavepoint); /* Call below is a no-op for NDEBUG builds */
fts5CheckTransactionState(pTab, FTS5_ROLLBACKTO, iSavepoint);
fts5TripCursors(pTab);
@@ -215565,7 +216762,7 @@ static void fts5SourceIdFunc(
){
assert( nArg==0 );
UNUSED_PARAM2(nArg, apUnused);
- sqlite3_result_text(pCtx, "fts5: 2018-12-01 12:34:55 bf8c1b2b7a5960c282e543b9c293686dccff272512d08865f4600fb58238b4f9", -1, SQLITE_TRANSIENT);
+ sqlite3_result_text(pCtx, "fts5: 2019-02-08 13:17:39 0eca3dd3d38b31c92b49ca2d311128b74584714d9e7de895b1a6286ef959a1dd", -1, SQLITE_TRANSIENT);
}
/*
@@ -215814,7 +217011,7 @@ static int fts5StorageGetStmt(
char *zBind;
int i;
- zBind = sqlite3_malloc(1 + nCol*2);
+ zBind = sqlite3_malloc64(1 + nCol*2);
if( zBind ){
for(i=0; i<nCol; i++){
zBind[i*2] = '?';
@@ -215981,11 +217178,11 @@ static int sqlite3Fts5StorageOpen(
){
int rc = SQLITE_OK;
Fts5Storage *p; /* New object */
- int nByte; /* Bytes of space to allocate */
+ sqlite3_int64 nByte; /* Bytes of space to allocate */
nByte = sizeof(Fts5Storage) /* Fts5Storage object */
+ pConfig->nCol * sizeof(i64); /* Fts5Storage.aTotalSize[] */
- *pp = p = (Fts5Storage*)sqlite3_malloc(nByte);
+ *pp = p = (Fts5Storage*)sqlite3_malloc64(nByte);
if( !p ) return SQLITE_NOMEM;
memset(p, 0, nByte);
@@ -215996,7 +217193,7 @@ static int sqlite3Fts5StorageOpen(
if( bCreate ){
if( pConfig->eContent==FTS5_CONTENT_NORMAL ){
int nDefn = 32 + pConfig->nCol*10;
- char *zDefn = sqlite3_malloc(32 + pConfig->nCol * 10);
+ char *zDefn = sqlite3_malloc64(32 + (sqlite3_int64)pConfig->nCol * 10);
if( zDefn==0 ){
rc = SQLITE_NOMEM;
}else{
@@ -216287,7 +217484,7 @@ static int sqlite3Fts5StorageRebuild(Fts5Storage *p){
Fts5Config *pConfig = p->pConfig;
sqlite3_stmt *pScan = 0;
Fts5InsertCtx ctx;
- int rc;
+ int rc, rc2;
memset(&ctx, 0, sizeof(Fts5InsertCtx));
ctx.pStorage = p;
@@ -216326,6 +217523,8 @@ static int sqlite3Fts5StorageRebuild(Fts5Storage *p){
}
}
sqlite3_free(buf.p);
+ rc2 = sqlite3_reset(pScan);
+ if( rc==SQLITE_OK ) rc = rc2;
/* Write the averages record */
if( rc==SQLITE_OK ){
@@ -216575,7 +217774,7 @@ static int sqlite3Fts5StorageIntegrity(Fts5Storage *p){
memset(&ctx, 0, sizeof(Fts5IntegrityCtx));
ctx.pConfig = p->pConfig;
- aTotalSize = (i64*)sqlite3_malloc(pConfig->nCol * (sizeof(int)+sizeof(i64)));
+ aTotalSize = (i64*)sqlite3_malloc64(pConfig->nCol*(sizeof(int)+sizeof(i64)));
if( !aTotalSize ) return SQLITE_NOMEM;
aColSize = (int*)&aTotalSize[pConfig->nCol];
memset(aTotalSize, 0, sizeof(i64) * pConfig->nCol);
@@ -216775,7 +217974,13 @@ static int sqlite3Fts5StorageSize(Fts5Storage *p, int iCol, i64 *pnToken){
static int sqlite3Fts5StorageRowCount(Fts5Storage *p, i64 *pnRow){
int rc = fts5StorageLoadTotals(p, 0);
if( rc==SQLITE_OK ){
+ /* nTotalRow being zero does not necessarily indicate a corrupt
+ ** database - it might be that the FTS5 table really does contain zero
+ ** rows. However this function is only called from the xRowCount() API,
+ ** and there is no way for that API to be invoked if the table contains
+ ** no rows. Hence the FTS5_CORRUPT return. */
*pnRow = p->nTotalRow;
+ if( p->nTotalRow<=0 ) rc = FTS5_CORRUPT;
}
return rc;
}
@@ -216985,7 +218190,7 @@ static int fts5AsciiTokenize(
nByte = ie-is;
if( nByte>nFold ){
if( pFold!=aFold ) sqlite3_free(pFold);
- pFold = sqlite3_malloc(nByte*2);
+ pFold = sqlite3_malloc64((sqlite3_int64)nByte*2);
if( pFold==0 ){
rc = SQLITE_NOMEM;
break;
@@ -217067,13 +218272,18 @@ struct Unicode61Tokenizer {
unsigned char aTokenChar[128]; /* ASCII range token characters */
char *aFold; /* Buffer to fold text into */
int nFold; /* Size of aFold[] in bytes */
- int bRemoveDiacritic; /* True if remove_diacritics=1 is set */
+ int eRemoveDiacritic; /* True if remove_diacritics=1 is set */
int nException;
int *aiException;
unsigned char aCategory[32]; /* True for token char categories */
};
+/* Values for eRemoveDiacritic (must match internals of fts5_unicode2.c) */
+#define FTS5_REMOVE_DIACRITICS_NONE 0
+#define FTS5_REMOVE_DIACRITICS_SIMPLE 1
+#define FTS5_REMOVE_DIACRITICS_COMPLEX 2
+
static int fts5UnicodeAddExceptions(
Unicode61Tokenizer *p, /* Tokenizer object */
const char *z, /* Characters to treat as exceptions */
@@ -217084,13 +218294,14 @@ static int fts5UnicodeAddExceptions(
int *aNew;
if( n>0 ){
- aNew = (int*)sqlite3_realloc(p->aiException, (n+p->nException)*sizeof(int));
+ aNew = (int*)sqlite3_realloc64(p->aiException,
+ (n+p->nException)*sizeof(int));
if( aNew ){
int nNew = p->nException;
const unsigned char *zCsr = (const unsigned char*)z;
const unsigned char *zTerm = (const unsigned char*)&z[n];
while( zCsr<zTerm ){
- int iCode;
+ u32 iCode;
int bToken;
READ_UTF8(zCsr, zTerm, iCode);
if( iCode<128 ){
@@ -217102,7 +218313,7 @@ static int fts5UnicodeAddExceptions(
if( bToken!=bTokenChars && sqlite3Fts5UnicodeIsdiacritic(iCode)==0 ){
int i;
for(i=0; i<nNew; i++){
- if( aNew[i]>iCode ) break;
+ if( (u32)aNew[i]>iCode ) break;
}
memmove(&aNew[i+1], &aNew[i], (nNew-i)*sizeof(int));
aNew[i] = iCode;
@@ -217194,7 +218405,7 @@ static int fts5UnicodeCreate(
int i;
memset(p, 0, sizeof(Unicode61Tokenizer));
- p->bRemoveDiacritic = 1;
+ p->eRemoveDiacritic = FTS5_REMOVE_DIACRITICS_SIMPLE;
p->nFold = 64;
p->aFold = sqlite3_malloc(p->nFold * sizeof(char));
if( p->aFold==0 ){
@@ -217215,10 +218426,15 @@ static int fts5UnicodeCreate(
for(i=0; rc==SQLITE_OK && i<nArg; i+=2){
const char *zArg = azArg[i+1];
if( 0==sqlite3_stricmp(azArg[i], "remove_diacritics") ){
- if( (zArg[0]!='0' && zArg[0]!='1') || zArg[1] ){
+ if( (zArg[0]!='0' && zArg[0]!='1' && zArg[0]!='2') || zArg[1] ){
rc = SQLITE_ERROR;
+ }else{
+ p->eRemoveDiacritic = (zArg[0] - '0');
+ assert( p->eRemoveDiacritic==FTS5_REMOVE_DIACRITICS_NONE
+ || p->eRemoveDiacritic==FTS5_REMOVE_DIACRITICS_SIMPLE
+ || p->eRemoveDiacritic==FTS5_REMOVE_DIACRITICS_COMPLEX
+ );
}
- p->bRemoveDiacritic = (zArg[0]=='1');
}else
if( 0==sqlite3_stricmp(azArg[i], "tokenchars") ){
rc = fts5UnicodeAddExceptions(p, zArg, 1);
@@ -217252,7 +218468,7 @@ static int fts5UnicodeCreate(
*/
static int fts5UnicodeIsAlnum(Unicode61Tokenizer *p, int iCode){
return (
- p->aCategory[sqlite3Fts5UnicodeCategory(iCode)]
+ p->aCategory[sqlite3Fts5UnicodeCategory((u32)iCode)]
^ fts5UnicodeIsException(p, iCode)
);
}
@@ -217281,7 +218497,7 @@ static int fts5UnicodeTokenize(
/* Each iteration of this loop gobbles up a contiguous run of separators,
** then the next token. */
while( rc==SQLITE_OK ){
- int iCode; /* non-ASCII codepoint read from input */
+ u32 iCode; /* non-ASCII codepoint read from input */
char *zOut = aFold;
int is;
int ie;
@@ -217313,7 +218529,7 @@ static int fts5UnicodeTokenize(
/* Grow the output buffer so that there is sufficient space to fit the
** largest possible utf-8 character. */
if( zOut>pEnd ){
- aFold = sqlite3_malloc(nFold*2);
+ aFold = sqlite3_malloc64((sqlite3_int64)nFold*2);
if( aFold==0 ){
rc = SQLITE_NOMEM;
goto tokenize_done;
@@ -217332,7 +218548,7 @@ static int fts5UnicodeTokenize(
READ_UTF8(zCsr, zTerm, iCode);
if( fts5UnicodeIsAlnum(p,iCode)||sqlite3Fts5UnicodeIsdiacritic(iCode) ){
non_ascii_tokenchar:
- iCode = sqlite3Fts5UnicodeFold(iCode, p->bRemoveDiacritic);
+ iCode = sqlite3Fts5UnicodeFold(iCode, p->eRemoveDiacritic);
if( iCode ) WRITE_UTF8(zOut, iCode);
}else{
break;
@@ -218108,10 +219324,8 @@ static int sqlite3Fts5TokenizerInit(fts5_api *pApi){
return rc;
}
-
-
/*
-** 2012 May 25
+** 2012-05-25
**
** The author disclaims copyright to this source code. In place of
** a legal notice, here is a blessing:
@@ -218140,32 +219354,48 @@ static int sqlite3Fts5TokenizerInit(fts5_api *pApi){
** E"). The resuls of passing a codepoint that corresponds to an
** uppercase letter are undefined.
*/
-static int fts5_remove_diacritic(int c){
+static int fts5_remove_diacritic(int c, int bComplex){
unsigned short aDia[] = {
0, 1797, 1848, 1859, 1891, 1928, 1940, 1995,
2024, 2040, 2060, 2110, 2168, 2206, 2264, 2286,
2344, 2383, 2472, 2488, 2516, 2596, 2668, 2732,
2782, 2842, 2894, 2954, 2984, 3000, 3028, 3336,
- 3456, 3696, 3712, 3728, 3744, 3896, 3912, 3928,
- 3968, 4008, 4040, 4106, 4138, 4170, 4202, 4234,
- 4266, 4296, 4312, 4344, 4408, 4424, 4472, 4504,
- 6148, 6198, 6264, 6280, 6360, 6429, 6505, 6529,
- 61448, 61468, 61534, 61592, 61642, 61688, 61704, 61726,
- 61784, 61800, 61836, 61880, 61914, 61948, 61998, 62122,
- 62154, 62200, 62218, 62302, 62364, 62442, 62478, 62536,
- 62554, 62584, 62604, 62640, 62648, 62656, 62664, 62730,
- 62924, 63050, 63082, 63274, 63390,
+ 3456, 3696, 3712, 3728, 3744, 3766, 3832, 3896,
+ 3912, 3928, 3944, 3968, 4008, 4040, 4056, 4106,
+ 4138, 4170, 4202, 4234, 4266, 4296, 4312, 4344,
+ 4408, 4424, 4442, 4472, 4488, 4504, 6148, 6198,
+ 6264, 6280, 6360, 6429, 6505, 6529, 61448, 61468,
+ 61512, 61534, 61592, 61610, 61642, 61672, 61688, 61704,
+ 61726, 61784, 61800, 61816, 61836, 61880, 61896, 61914,
+ 61948, 61998, 62062, 62122, 62154, 62184, 62200, 62218,
+ 62252, 62302, 62364, 62410, 62442, 62478, 62536, 62554,
+ 62584, 62604, 62640, 62648, 62656, 62664, 62730, 62766,
+ 62830, 62890, 62924, 62974, 63032, 63050, 63082, 63118,
+ 63182, 63242, 63274, 63310, 63368, 63390,
};
- char aChar[] = {
- '\0', 'a', 'c', 'e', 'i', 'n', 'o', 'u', 'y', 'y', 'a', 'c',
- 'd', 'e', 'e', 'g', 'h', 'i', 'j', 'k', 'l', 'n', 'o', 'r',
- 's', 't', 'u', 'u', 'w', 'y', 'z', 'o', 'u', 'a', 'i', 'o',
- 'u', 'g', 'k', 'o', 'j', 'g', 'n', 'a', 'e', 'i', 'o', 'r',
- 'u', 's', 't', 'h', 'a', 'e', 'o', 'y', '\0', '\0', '\0', '\0',
- '\0', '\0', '\0', '\0', 'a', 'b', 'd', 'd', 'e', 'f', 'g', 'h',
- 'h', 'i', 'k', 'l', 'l', 'm', 'n', 'p', 'r', 'r', 's', 't',
- 'u', 'v', 'w', 'w', 'x', 'y', 'z', 'h', 't', 'w', 'y', 'a',
- 'e', 'i', 'o', 'u', 'y',
+#define HIBIT ((unsigned char)0x80)
+ unsigned char aChar[] = {
+ '\0', 'a', 'c', 'e', 'i', 'n',
+ 'o', 'u', 'y', 'y', 'a', 'c',
+ 'd', 'e', 'e', 'g', 'h', 'i',
+ 'j', 'k', 'l', 'n', 'o', 'r',
+ 's', 't', 'u', 'u', 'w', 'y',
+ 'z', 'o', 'u', 'a', 'i', 'o',
+ 'u', 'u'|HIBIT, 'a'|HIBIT, 'g', 'k', 'o',
+ 'o'|HIBIT, 'j', 'g', 'n', 'a'|HIBIT, 'a',
+ 'e', 'i', 'o', 'r', 'u', 's',
+ 't', 'h', 'a', 'e', 'o'|HIBIT, 'o',
+ 'o'|HIBIT, 'y', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', 'a', 'b',
+ 'c'|HIBIT, 'd', 'd', 'e'|HIBIT, 'e', 'e'|HIBIT,
+ 'f', 'g', 'h', 'h', 'i', 'i'|HIBIT,
+ 'k', 'l', 'l'|HIBIT, 'l', 'm', 'n',
+ 'o'|HIBIT, 'p', 'r', 'r'|HIBIT, 'r', 's',
+ 's'|HIBIT, 't', 'u', 'u'|HIBIT, 'v', 'w',
+ 'w', 'x', 'y', 'z', 'h', 't',
+ 'w', 'y', 'a', 'a'|HIBIT, 'a'|HIBIT, 'a'|HIBIT,
+ 'e', 'e'|HIBIT, 'e'|HIBIT, 'i', 'o', 'o'|HIBIT,
+ 'o'|HIBIT, 'o'|HIBIT, 'u', 'u'|HIBIT, 'u'|HIBIT, 'y',
};
unsigned int key = (((unsigned int)c)<<3) | 0x00000007;
@@ -218182,7 +219412,8 @@ static int fts5_remove_diacritic(int c){
}
}
assert( key>=aDia[iRes] );
- return ((c > (aDia[iRes]>>3) + (aDia[iRes]&0x07)) ? c : (int)aChar[iRes]);
+ if( bComplex==0 && (aChar[iRes] & 0x80) ) return c;
+ return (c > (aDia[iRes]>>3) + (aDia[iRes]&0x07)) ? c : ((int)aChar[iRes] & 0x7F);
}
@@ -218195,8 +219426,8 @@ static int sqlite3Fts5UnicodeIsdiacritic(int c){
unsigned int mask1 = 0x000361F8;
if( c<768 || c>817 ) return 0;
return (c < 768+32) ?
- (mask0 & (1 << (c-768))) :
- (mask1 & (1 << (c-768-32)));
+ (mask0 & ((unsigned int)1 << (c-768))) :
+ (mask1 & ((unsigned int)1 << (c-768-32)));
}
@@ -218209,7 +219440,7 @@ static int sqlite3Fts5UnicodeIsdiacritic(int c){
** The results are undefined if the value passed to this function
** is less than zero.
*/
-static int sqlite3Fts5UnicodeFold(int c, int bRemoveDiacritic){
+static int sqlite3Fts5UnicodeFold(int c, int eRemoveDiacritic){
/* Each entry in the following array defines a rule for folding a range
** of codepoints to lower case. The rule applies to a range of nRange
** codepoints starting at codepoint iCode.
@@ -218332,7 +219563,9 @@ static int sqlite3Fts5UnicodeFold(int c, int bRemoveDiacritic){
assert( ret>0 );
}
- if( bRemoveDiacritic ) ret = fts5_remove_diacritic(ret);
+ if( eRemoveDiacritic ){
+ ret = fts5_remove_diacritic(ret, eRemoveDiacritic==2);
+ }
}
else if( c>=66560 && c<66600 ){
@@ -218343,12 +219576,6 @@ static int sqlite3Fts5UnicodeFold(int c, int bRemoveDiacritic){
}
-#if 0
-static int sqlite3Fts5UnicodeNCat(void) {
- return 32;
-}
-#endif
-
static int sqlite3Fts5UnicodeCatParse(const char *zCat, u8 *aArray){
aArray[0] = 1;
switch( zCat[0] ){
@@ -218830,7 +220057,7 @@ static u16 aFts5UnicodeData[] = {
34, 3074, 7692, 63, 63,
};
-static int sqlite3Fts5UnicodeCategory(int iCode) {
+static int sqlite3Fts5UnicodeCategory(u32 iCode) {
int iRes = -1;
int iHi;
int iLo;
@@ -218868,13 +220095,12 @@ static void sqlite3Fts5UnicodeAscii(u8 *aArray, u8 *aAscii){
int bToken = aArray[ aFts5UnicodeData[iTbl] & 0x1F ];
int n = (aFts5UnicodeData[iTbl] >> 5) + i;
for(; i<128 && i<n; i++){
- aAscii[i] = (u8)bToken;
+ aAscii[i] = bToken;
}
iTbl++;
}
}
-
/*
** 2015 May 30
**
@@ -218953,7 +220179,7 @@ static int sqlite3Fts5GetVarint32(const unsigned char *p, u32 *v){
u8 n;
p -= 2;
n = sqlite3Fts5GetVarint(p, &v64);
- *v = (u32)v64;
+ *v = ((u32)v64) & 0x7FFFFFFF;
assert( n>3 && n<=9 );
return n;
}
@@ -219220,7 +220446,6 @@ static int sqlite3Fts5GetVarintLen(u32 iVal){
return 5;
}
-
/*
** 2015 May 08
**
@@ -219278,7 +220503,7 @@ struct Fts5VocabTable {
struct Fts5VocabCursor {
sqlite3_vtab_cursor base;
sqlite3_stmt *pStmt; /* Statement holding lock on pIndex */
- Fts5Index *pIndex; /* Associated FTS5 index */
+ Fts5Table *pFts5; /* Associated FTS5 table */
int bEof; /* True if this cursor is at EOF */
Fts5IndexIter *pIter; /* Term/rowid iterator object */
@@ -219287,7 +220512,6 @@ struct Fts5VocabCursor {
char *zLeTerm; /* (term <= $zLeTerm) paramater, or NULL */
/* These are used by 'col' tables only */
- Fts5Config *pConfig; /* Fts5 table configuration */
int iCol;
i64 *aCnt;
i64 *aDoc;
@@ -219550,8 +220774,7 @@ static int fts5VocabOpenMethod(
sqlite3_vtab_cursor **ppCsr
){
Fts5VocabTable *pTab = (Fts5VocabTable*)pVTab;
- Fts5Index *pIndex = 0;
- Fts5Config *pConfig = 0;
+ Fts5Table *pFts5 = 0;
Fts5VocabCursor *pCsr = 0;
int rc = SQLITE_OK;
sqlite3_stmt *pStmt = 0;
@@ -219570,31 +220793,34 @@ static int fts5VocabOpenMethod(
if( pStmt && sqlite3_step(pStmt)==SQLITE_ROW ){
i64 iId = sqlite3_column_int64(pStmt, 0);
- pIndex = sqlite3Fts5IndexFromCsrid(pTab->pGlobal, iId, &pConfig);
+ pFts5 = sqlite3Fts5TableFromCsrid(pTab->pGlobal, iId);
}
- if( rc==SQLITE_OK && pIndex==0 ){
- rc = sqlite3_finalize(pStmt);
- pStmt = 0;
- if( rc==SQLITE_OK ){
- pVTab->zErrMsg = sqlite3_mprintf(
- "no such fts5 table: %s.%s", pTab->zFts5Db, pTab->zFts5Tbl
- );
- rc = SQLITE_ERROR;
+ if( rc==SQLITE_OK ){
+ if( pFts5==0 ){
+ rc = sqlite3_finalize(pStmt);
+ pStmt = 0;
+ if( rc==SQLITE_OK ){
+ pVTab->zErrMsg = sqlite3_mprintf(
+ "no such fts5 table: %s.%s", pTab->zFts5Db, pTab->zFts5Tbl
+ );
+ rc = SQLITE_ERROR;
+ }
+ }else{
+ rc = sqlite3Fts5FlushToDisk(pFts5);
}
}
if( rc==SQLITE_OK ){
- int nByte = pConfig->nCol * sizeof(i64) * 2 + sizeof(Fts5VocabCursor);
+ int nByte = pFts5->pConfig->nCol * sizeof(i64)*2 + sizeof(Fts5VocabCursor);
pCsr = (Fts5VocabCursor*)sqlite3Fts5MallocZero(&rc, nByte);
}
if( pCsr ){
- pCsr->pIndex = pIndex;
+ pCsr->pFts5 = pFts5;
pCsr->pStmt = pStmt;
- pCsr->pConfig = pConfig;
pCsr->aCnt = (i64*)&pCsr[1];
- pCsr->aDoc = &pCsr->aCnt[pConfig->nCol];
+ pCsr->aDoc = &pCsr->aCnt[pFts5->pConfig->nCol];
}else{
sqlite3_finalize(pStmt);
}
@@ -219610,6 +220836,7 @@ static void fts5VocabResetCursor(Fts5VocabCursor *pCsr){
sqlite3_free(pCsr->zLeTerm);
pCsr->nLeTerm = -1;
pCsr->zLeTerm = 0;
+ pCsr->bEof = 0;
}
/*
@@ -219648,7 +220875,7 @@ static int fts5VocabInstanceNewTerm(Fts5VocabCursor *pCsr){
}
static int fts5VocabInstanceNext(Fts5VocabCursor *pCsr){
- int eDetail = pCsr->pConfig->eDetail;
+ int eDetail = pCsr->pFts5->pConfig->eDetail;
int rc = SQLITE_OK;
Fts5IndexIter *pIter = pCsr->pIter;
i64 *pp = &pCsr->iInstPos;
@@ -219683,7 +220910,7 @@ static int fts5VocabNextMethod(sqlite3_vtab_cursor *pCursor){
Fts5VocabCursor *pCsr = (Fts5VocabCursor*)pCursor;
Fts5VocabTable *pTab = (Fts5VocabTable*)pCursor->pVtab;
int rc = SQLITE_OK;
- int nCol = pCsr->pConfig->nCol;
+ int nCol = pCsr->pFts5->pConfig->nCol;
pCsr->rowid++;
@@ -219705,6 +220932,7 @@ static int fts5VocabNextMethod(sqlite3_vtab_cursor *pCursor){
int nTerm;
zTerm = sqlite3Fts5IterTerm(pCsr->pIter, &nTerm);
+ assert( nTerm>=0 );
if( pCsr->nLeTerm>=0 ){
int nCmp = MIN(nTerm, pCsr->nLeTerm);
int bCmp = memcmp(pCsr->zLeTerm, zTerm, nCmp);
@@ -219721,7 +220949,7 @@ static int fts5VocabNextMethod(sqlite3_vtab_cursor *pCursor){
assert( pTab->eType==FTS5_VOCAB_COL || pTab->eType==FTS5_VOCAB_ROW );
while( rc==SQLITE_OK ){
- int eDetail = pCsr->pConfig->eDetail;
+ int eDetail = pCsr->pFts5->pConfig->eDetail;
const u8 *pPos; int nPos; /* Position list */
i64 iPos = 0; /* 64-bit position read from poslist */
int iOff = 0; /* Current offset within position list */
@@ -219744,7 +220972,6 @@ static int fts5VocabNextMethod(sqlite3_vtab_cursor *pCursor){
int iCol = -1;
while( 0==sqlite3Fts5PoslistNext64(pPos, nPos, &iOff, &iPos) ){
int ii = FTS5_POS2COLUMN(iPos);
- pCsr->aCnt[ii]++;
if( iCol!=ii ){
if( ii>=nCol ){
rc = FTS5_CORRUPT;
@@ -219753,6 +220980,7 @@ static int fts5VocabNextMethod(sqlite3_vtab_cursor *pCursor){
pCsr->aDoc[ii]++;
iCol = ii;
}
+ pCsr->aCnt[ii]++;
}
}else if( eDetail==FTS5_DETAIL_COLUMNS ){
while( 0==sqlite3Fts5PoslistNext64(pPos, nPos, &iOff,&iPos) ){
@@ -219781,7 +221009,9 @@ static int fts5VocabNextMethod(sqlite3_vtab_cursor *pCursor){
if( rc==SQLITE_OK ){
zTerm = sqlite3Fts5IterTerm(pCsr->pIter, &nTerm);
- if( nTerm!=pCsr->term.n || memcmp(zTerm, pCsr->term.p, nTerm) ){
+ if( nTerm!=pCsr->term.n
+ || (nTerm>0 && memcmp(zTerm, pCsr->term.p, nTerm))
+ ){
break;
}
if( sqlite3Fts5IterEof(pCsr->pIter) ) break;
@@ -219792,7 +221022,7 @@ static int fts5VocabNextMethod(sqlite3_vtab_cursor *pCursor){
if( rc==SQLITE_OK && pCsr->bEof==0 && pTab->eType==FTS5_VOCAB_COL ){
while( pCsr->aDoc[pCsr->iCol]==0 ) pCsr->iCol++;
- assert( pCsr->iCol<pCsr->pConfig->nCol );
+ assert( pCsr->iCol<pCsr->pFts5->pConfig->nCol );
}
return rc;
}
@@ -219839,6 +221069,7 @@ static int fts5VocabFilterMethod(
}
if( pLe ){
const char *zCopy = (const char *)sqlite3_value_text(pLe);
+ if( zCopy==0 ) zCopy = "";
pCsr->nLeTerm = sqlite3_value_bytes(pLe);
pCsr->zLeTerm = sqlite3_malloc(pCsr->nLeTerm+1);
if( pCsr->zLeTerm==0 ){
@@ -219850,14 +221081,15 @@ static int fts5VocabFilterMethod(
}
if( rc==SQLITE_OK ){
- rc = sqlite3Fts5IndexQuery(pCsr->pIndex, zTerm, nTerm, f, 0, &pCsr->pIter);
+ Fts5Index *pIndex = pCsr->pFts5->pIndex;
+ rc = sqlite3Fts5IndexQuery(pIndex, zTerm, nTerm, f, 0, &pCsr->pIter);
}
if( rc==SQLITE_OK && eType==FTS5_VOCAB_INSTANCE ){
rc = fts5VocabInstanceNewTerm(pCsr);
}
- if( rc==SQLITE_OK
- && !pCsr->bEof
- && (eType!=FTS5_VOCAB_INSTANCE || pCsr->pConfig->eDetail!=FTS5_DETAIL_NONE)
+ if( rc==SQLITE_OK && !pCsr->bEof
+ && (eType!=FTS5_VOCAB_INSTANCE
+ || pCsr->pFts5->pConfig->eDetail!=FTS5_DETAIL_NONE)
){
rc = fts5VocabNextMethod(pCursor);
}
@@ -219880,7 +221112,7 @@ static int fts5VocabColumnMethod(
int iCol /* Index of column to read value from */
){
Fts5VocabCursor *pCsr = (Fts5VocabCursor*)pCursor;
- int eDetail = pCsr->pConfig->eDetail;
+ int eDetail = pCsr->pFts5->pConfig->eDetail;
int eType = ((Fts5VocabTable*)(pCursor->pVtab))->eType;
i64 iVal = 0;
@@ -219892,7 +221124,7 @@ static int fts5VocabColumnMethod(
assert( iCol==1 || iCol==2 || iCol==3 );
if( iCol==1 ){
if( eDetail!=FTS5_DETAIL_NONE ){
- const char *z = pCsr->pConfig->azCol[pCsr->iCol];
+ const char *z = pCsr->pFts5->pConfig->azCol[pCsr->iCol];
sqlite3_result_text(pCtx, z, -1, SQLITE_STATIC);
}
}else if( iCol==2 ){
@@ -219920,8 +221152,8 @@ static int fts5VocabColumnMethod(
}else if( eDetail==FTS5_DETAIL_COLUMNS ){
ii = (int)pCsr->iInstPos;
}
- if( ii>=0 && ii<pCsr->pConfig->nCol ){
- const char *z = pCsr->pConfig->azCol[ii];
+ if( ii>=0 && ii<pCsr->pFts5->pConfig->nCol ){
+ const char *z = pCsr->pFts5->pConfig->azCol[ii];
sqlite3_result_text(pCtx, z, -1, SQLITE_STATIC);
}
break;
@@ -220294,9 +221526,9 @@ SQLITE_API int sqlite3_stmt_init(
#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
/************** End of stmt.c ************************************************/
-#if __LINE__!=220297
+#if __LINE__!=221529
#undef SQLITE_SOURCE_ID
-#define SQLITE_SOURCE_ID "2018-12-01 12:34:55 bf8c1b2b7a5960c282e543b9c293686dccff272512d08865f4600fb58238alt2"
+#define SQLITE_SOURCE_ID "2019-02-08 13:17:39 0eca3dd3d38b31c92b49ca2d311128b74584714d9e7de895b1a6286ef959alt2"
#endif
/* Return the source-id for this library */
SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
diff --git a/chromium/third_party/sqlite/amalgamation/sqlite3.h b/chromium/third_party/sqlite/amalgamation/sqlite3.h
index 3caa3d50732..0755e9c1f72 100644
--- a/chromium/third_party/sqlite/amalgamation/sqlite3.h
+++ b/chromium/third_party/sqlite/amalgamation/sqlite3.h
@@ -123,9 +123,9 @@ extern "C" {
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
** [sqlite_version()] and [sqlite_source_id()].
*/
-#define SQLITE_VERSION "3.26.0"
-#define SQLITE_VERSION_NUMBER 3026000
-#define SQLITE_SOURCE_ID "2018-12-01 12:34:55 bf8c1b2b7a5960c282e543b9c293686dccff272512d08865f4600fb58238alt1"
+#define SQLITE_VERSION "3.27.1"
+#define SQLITE_VERSION_NUMBER 3027001
+#define SQLITE_SOURCE_ID "2019-02-08 13:17:39 0eca3dd3d38b31c92b49ca2d311128b74584714d9e7de895b1a6286ef959alt1"
/*
** CAPI3REF: Run-Time Library Version Numbers
@@ -823,6 +823,15 @@ struct sqlite3_io_methods {
** file space based on this hint in order to help writes to the database
** file run faster.
**
+** <li>[[SQLITE_FCNTL_SIZE_LIMIT]]
+** The [SQLITE_FCNTL_SIZE_LIMIT] opcode is used by in-memory VFS that
+** implements [sqlite3_deserialize()] to set an upper bound on the size
+** of the in-memory database. The argument is a pointer to a [sqlite3_int64].
+** If the integer pointed to is negative, then it is filled in with the
+** current limit. Otherwise the limit is set to the larger of the value
+** of the integer pointed to and the current database size. The integer
+** pointed to is set to the new limit.
+**
** <li>[[SQLITE_FCNTL_CHUNK_SIZE]]
** The [SQLITE_FCNTL_CHUNK_SIZE] opcode is used to request that the VFS
** extends and truncates the database file in chunks of a size specified
@@ -1131,6 +1140,7 @@ struct sqlite3_io_methods {
#define SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE 33
#define SQLITE_FCNTL_LOCK_TIMEOUT 34
#define SQLITE_FCNTL_DATA_VERSION 35
+#define SQLITE_FCNTL_SIZE_LIMIT 36
/* deprecated names */
#define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE
@@ -1972,6 +1982,17 @@ struct sqlite3_mem_methods {
** negative value for this option restores the default behaviour.
** This option is only available if SQLite is compiled with the
** [SQLITE_ENABLE_SORTER_REFERENCES] compile-time option.
+**
+** [[SQLITE_CONFIG_MEMDB_MAXSIZE]]
+** <dt>SQLITE_CONFIG_MEMDB_MAXSIZE
+** <dd>The SQLITE_CONFIG_MEMDB_MAXSIZE option accepts a single parameter
+** [sqlite3_int64] parameter which is the default maximum size for an in-memory
+** database created using [sqlite3_deserialize()]. This default maximum
+** size can be adjusted up or down for individual databases using the
+** [SQLITE_FCNTL_SIZE_LIMIT] [sqlite3_file_control|file-control]. If this
+** configuration setting is never used, then the default maximum is determined
+** by the [SQLITE_MEMDB_DEFAULT_MAXSIZE] compile-time option. If that
+** compile-time option is not set, then the default maximum is 1073741824.
** </dl>
*/
#define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */
@@ -2002,6 +2023,7 @@ struct sqlite3_mem_methods {
#define SQLITE_CONFIG_STMTJRNL_SPILL 26 /* int nByte */
#define SQLITE_CONFIG_SMALL_MALLOC 27 /* boolean */
#define SQLITE_CONFIG_SORTERREF_SIZE 28 /* int nByte */
+#define SQLITE_CONFIG_MEMDB_MAXSIZE 29 /* sqlite3_int64 */
/*
** CAPI3REF: Database Connection Configuration Options
@@ -2991,9 +3013,9 @@ SQLITE_API int sqlite3_set_authorizer(
** time is in units of nanoseconds, however the current implementation
** is only capable of millisecond resolution so the six least significant
** digits in the time are meaningless. Future versions of SQLite
-** might provide greater resolution on the profiler callback. The
-** sqlite3_profile() function is considered experimental and is
-** subject to change in future versions of SQLite.
+** might provide greater resolution on the profiler callback. Invoking
+** either [sqlite3_trace()] or [sqlite3_trace_v2()] will cancel the
+** profile callback.
*/
SQLITE_API SQLITE_DEPRECATED void *sqlite3_trace(sqlite3*,
void(*xTrace)(void*,const char*), void*);
@@ -3407,6 +3429,8 @@ SQLITE_API int sqlite3_open_v2(
** is not a database file pathname pointer that SQLite passed into the xOpen
** VFS method, then the behavior of this routine is undefined and probably
** undesirable.
+**
+** See the [URI filename] documentation for additional information.
*/
SQLITE_API const char *sqlite3_uri_parameter(const char *zFilename, const char *zParam);
SQLITE_API int sqlite3_uri_boolean(const char *zFile, const char *zParam, int bDefault);
@@ -3629,14 +3653,13 @@ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
** deplete the limited store of lookaside memory. Future versions of
** SQLite may act on this hint differently.
**
-** [[SQLITE_PREPARE_NORMALIZE]] ^(<dt>SQLITE_PREPARE_NORMALIZE</dt>
-** <dd>The SQLITE_PREPARE_NORMALIZE flag indicates that a normalized
-** representation of the SQL statement should be calculated and then
-** associated with the prepared statement, which can be obtained via
-** the [sqlite3_normalized_sql()] interface.)^ The semantics used to
-** normalize a SQL statement are unspecified and subject to change.
-** At a minimum, literal values will be replaced with suitable
-** placeholders.
+** [[SQLITE_PREPARE_NORMALIZE]] <dt>SQLITE_PREPARE_NORMALIZE</dt>
+** <dd>The SQLITE_PREPARE_NORMALIZE flag is a no-op. This flag used
+** to be required for any prepared statement that wanted to use the
+** [sqlite3_normalized_sql()] interface. However, the
+** [sqlite3_normalized_sql()] interface is now available to all
+** prepared statements, regardless of whether or not they use this
+** flag.
**
** [[SQLITE_PREPARE_NO_VTAB]] <dt>SQLITE_PREPARE_NO_VTAB</dt>
** <dd>The SQLITE_PREPARE_NO_VTAB flag causes the SQL compiler
@@ -10025,7 +10048,7 @@ SQLITE_API int sqlite3changeset_next(sqlite3_changeset_iter *pIter);
** sqlite3changeset_next() is called on the iterator or until the
** conflict-handler function returns. If pnCol is not NULL, then *pnCol is
** set to the number of columns in the table affected by the change. If
-** pbIncorrect is not NULL, then *pbIndirect is set to true (1) if the change
+** pbIndirect is not NULL, then *pbIndirect is set to true (1) if the change
** is an indirect change, or false (0) otherwise. See the documentation for
** [sqlite3session_indirect()] for a description of direct and indirect
** changes. Finally, if pOp is not NULL, then *pOp is set to one of
@@ -11259,12 +11282,8 @@ struct Fts5PhraseIter {
**
** Usually, output parameter *piPhrase is set to the phrase number, *piCol
** to the column in which it occurs and *piOff the token offset of the
-** first token of the phrase. The exception is if the table was created
-** with the offsets=0 option specified. In this case *piOff is always
-** set to -1.
-**
-** Returns SQLITE_OK if successful, or an error code (i.e. SQLITE_NOMEM)
-** if an error occurs.
+** first token of the phrase. Returns SQLITE_OK if successful, or an error
+** code (i.e. SQLITE_NOMEM) if an error occurs.
**
** This API can be quite slow if used with an FTS5 table created with the
** "detail=none" or "detail=column" option.
@@ -11553,11 +11572,11 @@ struct Fts5ExtensionApi {
** the tokenizer substitutes "first" for "1st" and the query works
** as expected.
**
-** <li> By adding multiple synonyms for a single term to the FTS index.
-** In this case, when tokenizing query text, the tokenizer may
-** provide multiple synonyms for a single term within the document.
-** FTS5 then queries the index for each synonym individually. For
-** example, faced with the query:
+** <li> By querying the index for all synonyms of each query term
+** separately. In this case, when tokenizing query text, the
+** tokenizer may provide multiple synonyms for a single term
+** within the document. FTS5 then queries the index for each
+** synonym individually. For example, faced with the query:
**
** <codeblock>
** ... MATCH 'first place'</codeblock>
@@ -11581,7 +11600,7 @@ struct Fts5ExtensionApi {
** "place".
**
** This way, even if the tokenizer does not provide synonyms
-** when tokenizing query text (it should not - to do would be
+** when tokenizing query text (it should not - to do so would be
** inefficient), it doesn't matter if the user queries for
** 'first + place' or '1st + place', as there are entries in the
** FTS index corresponding to both forms of the first token.
diff --git a/chromium/third_party/sqlite/fuzz/DEPS b/chromium/third_party/sqlite/fuzz/DEPS
deleted file mode 100644
index 8eb68bc404d..00000000000
--- a/chromium/third_party/sqlite/fuzz/DEPS
+++ /dev/null
@@ -1 +0,0 @@
-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
deleted file mode 100644
index c2bd17b7ffb..00000000000
--- a/chromium/third_party/sqlite/fuzz/disabled_queries_parser.cc
+++ /dev/null
@@ -1,30 +0,0 @@
-// 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
deleted file mode 100644
index 665b8719d01..00000000000
--- a/chromium/third_party/sqlite/fuzz/disabled_queries_parser.h
+++ /dev/null
@@ -1,16 +0,0 @@
-// 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
deleted file mode 100644
index d3d470a79b5..00000000000
--- a/chromium/third_party/sqlite/fuzz/icu_codes.proto
+++ /dev/null
@@ -1,189 +0,0 @@
-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
deleted file mode 100644
index 7a36870f564..00000000000
--- a/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries0
+++ /dev/null
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
deleted file mode 100644
index f2853929d0c..00000000000
--- a/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries1
+++ /dev/null
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
deleted file mode 100644
index cbc9fa63c8d..00000000000
--- a/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries10
+++ /dev/null
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
deleted file mode 100644
index 9ee13e908f9..00000000000
--- a/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries11
+++ /dev/null
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
deleted file mode 100644
index 04ae159ae62..00000000000
--- a/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries12
+++ /dev/null
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
deleted file mode 100644
index 25fc7c70260..00000000000
--- a/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries13
+++ /dev/null
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
deleted file mode 100644
index e4e0a74810a..00000000000
--- a/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries14
+++ /dev/null
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
deleted file mode 100644
index 6ef088e4694..00000000000
--- a/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries15
+++ /dev/null
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
deleted file mode 100644
index f45f4a2229d..00000000000
--- a/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries16
+++ /dev/null
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
deleted file mode 100644
index 6d48cb7e597..00000000000
--- a/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries17
+++ /dev/null
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
deleted file mode 100644
index 4fb9debe4a4..00000000000
--- a/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries18
+++ /dev/null
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
deleted file mode 100644
index 529b54edfb1..00000000000
--- a/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries19
+++ /dev/null
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
deleted file mode 100644
index c51cd5f3081..00000000000
--- a/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries2
+++ /dev/null
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
deleted file mode 100644
index 530de34a290..00000000000
--- a/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries3
+++ /dev/null
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
deleted file mode 100644
index b879fe23c80..00000000000
--- a/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries4
+++ /dev/null
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
deleted file mode 100644
index c443de66e6d..00000000000
--- a/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries5
+++ /dev/null
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
deleted file mode 100644
index 3841499fd98..00000000000
--- a/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries6
+++ /dev/null
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
deleted file mode 100644
index a90d08846bb..00000000000
--- a/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries7
+++ /dev/null
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
deleted file mode 100644
index 98ede46b5b8..00000000000
--- a/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries8
+++ /dev/null
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
deleted file mode 100644
index 4d4c15c39c7..00000000000
--- a/chromium/third_party/sqlite/fuzz/lpm_fuzzer_seed_corpus/corpus_queries9
+++ /dev/null
Binary files differ
diff --git a/chromium/third_party/sqlite/fuzz/sql.dict b/chromium/third_party/sqlite/fuzz/sql.dict
deleted file mode 100644
index 691b961ac21..00000000000
--- a/chromium/third_party/sqlite/fuzz/sql.dict
+++ /dev/null
@@ -1,909 +0,0 @@
-#
-# AFL dictionary for SQL
-# ----------------------
-#
-# Modeled based on SQLite documentation, contains some number of SQLite
-# extensions. Other dialects of SQL may benefit from customized dictionaries.
-#
-# If you append @1 to the file name when loading this dictionary, afl-fuzz
-# will also additionally load a selection of pragma keywords that are very
-# specific to SQLite (and are probably less interesting from the security
-# standpoint, because they are usually not allowed in non-privileged
-# contexts).
-#
-# Created by Michal Zalewski <lcamtuf@google.com>
-#
-
-function_abs=" abs(1)"
-function_avg=" avg(1)"
-function_changes=" changes()"
-function_char=" char(1)"
-function_coalesce=" coalesce(1,1)"
-function_count=" count(1)"
-function_date=" date(1,1,1)"
-function_datetime=" datetime(1,1,1)"
-function_decimal=" decimal(1,1)"
-function_glob=" glob(1,1)"
-function_group_concat=" group_concat(1,1)"
-function_hex=" hex(1)"
-function_ifnull=" ifnull(1,1)"
-function_instr=" instr(1,1)"
-function_julianday=" julianday(1,1,1)"
-function_last_insert_rowid=" last_insert_rowid()"
-function_length=" length(1)"
-function_like=" like(1,1)"
-function_likelihood=" likelihood(1,1)"
-function_likely=" likely(1)"
-function_load_extension=" load_extension(1,1)"
-function_lower=" lower(1)"
-function_ltrim=" ltrim(1,1)"
-function_max=" max(1,1)"
-function_min=" min(1,1)"
-function_nullif=" nullif(1,1)"
-function_printf=" printf(1,1)"
-function_quote=" quote(1)"
-function_random=" random()"
-function_randomblob=" randomblob(1)"
-function_replace=" replace(1,1,1)"
-function_round=" round(1,1)"
-function_rtrim=" rtrim(1,1)"
-function_soundex=" soundex(1)"
-function_sqlite_compileoption_get=" sqlite_compileoption_get(1)"
-function_sqlite_compileoption_used=" sqlite_compileoption_used(1)"
-function_sqlite_source_id=" sqlite_source_id()"
-function_sqlite_version=" sqlite_version()"
-function_strftime=" strftime(1,1,1,1)"
-function_substr=" substr(1,1,1)"
-function_sum=" sum(1)"
-function_time=" time(1,1,1)"
-function_total=" total(1)"
-function_total_changes=" total_changes()"
-function_trim=" trim(1,1)"
-function_typeof=" typeof(1)"
-function_unicode=" unicode(1)"
-function_unlikely=" unlikely(1)"
-function_upper=" upper(1)"
-function_varchar=" varchar(1)"
-function_zeroblob=" zeroblob(1)"
-
-keyword_ABORT="ABORT"
-keyword_ACTION="ACTION"
-keyword_ADD="ADD"
-keyword_AFTER="AFTER"
-keyword_ALL="ALL"
-keyword_ALTER="ALTER"
-keyword_ANALYZE="ANALYZE"
-keyword_AND="AND"
-keyword_AS="AS"
-keyword_ASC="ASC"
-keyword_ATTACH="ATTACH"
-keyword_AUTOINCREMENT="AUTOINCREMENT"
-keyword_BEFORE="BEFORE"
-keyword_BEGIN="BEGIN"
-keyword_BETWEEN="BETWEEN"
-keyword_BY="BY"
-keyword_CASCADE="CASCADE"
-keyword_CASE="CASE"
-keyword_CAST="CAST"
-keyword_CHECK="CHECK"
-keyword_COLLATE="COLLATE"
-keyword_COLUMN="COLUMN"
-keyword_COMMIT="COMMIT"
-keyword_CONFLICT="CONFLICT"
-keyword_CONSTRAINT="CONSTRAINT"
-keyword_CREATE="CREATE"
-keyword_CROSS="CROSS"
-keyword_CURRENT_DATE="CURRENT_DATE"
-keyword_CURRENT_TIME="CURRENT_TIME"
-keyword_CURRENT_TIMESTAMP="CURRENT_TIMESTAMP"
-keyword_DATABASE="DATABASE"
-keyword_DEFAULT="DEFAULT"
-keyword_DEFERRABLE="DEFERRABLE"
-keyword_DEFERRED="DEFERRED"
-keyword_DELETE="DELETE"
-keyword_DESC="DESC"
-keyword_DETACH="DETACH"
-keyword_DISTINCT="DISTINCT"
-keyword_DROP="DROP"
-keyword_EACH="EACH"
-keyword_ELSE="ELSE"
-keyword_END="END"
-keyword_ESCAPE="ESCAPE"
-keyword_EXCEPT="EXCEPT"
-keyword_EXCLUSIVE="EXCLUSIVE"
-keyword_EXISTS="EXISTS"
-keyword_EXPLAIN="EXPLAIN"
-keyword_FAIL="FAIL"
-keyword_FOR="FOR"
-keyword_FOREIGN="FOREIGN"
-keyword_FROM="FROM"
-keyword_FULL="FULL"
-keyword_GLOB="GLOB"
-keyword_GROUP="GROUP"
-keyword_HAVING="HAVING"
-keyword_IF="IF"
-keyword_IGNORE="IGNORE"
-keyword_IMMEDIATE="IMMEDIATE"
-keyword_IN="IN"
-keyword_INDEX="INDEX"
-keyword_INDEXED="INDEXED"
-keyword_INITIALLY="INITIALLY"
-keyword_INNER="INNER"
-keyword_INSERT="INSERT"
-keyword_INSTEAD="INSTEAD"
-keyword_INTERSECT="INTERSECT"
-keyword_INTO="INTO"
-keyword_IS="IS"
-keyword_ISNULL="ISNULL"
-keyword_JOIN="JOIN"
-keyword_KEY="KEY"
-keyword_LEFT="LEFT"
-keyword_LIKE="LIKE"
-keyword_LIMIT="LIMIT"
-keyword_MATCH="MATCH"
-keyword_NATURAL="NATURAL"
-keyword_NO="NO"
-keyword_NOT="NOT"
-keyword_NOTNULL="NOTNULL"
-keyword_NULL="NULL"
-keyword_OF="OF"
-keyword_OFFSET="OFFSET"
-keyword_ON="ON"
-keyword_OR="OR"
-keyword_ORDER="ORDER"
-keyword_OUTER="OUTER"
-keyword_PLAN="PLAN"
-keyword_PRAGMA="PRAGMA"
-keyword_PRIMARY="PRIMARY"
-keyword_QUERY="QUERY"
-keyword_RAISE="RAISE"
-keyword_RECURSIVE="RECURSIVE"
-keyword_REFERENCES="REFERENCES"
-#keyword_REGEXP="REGEXP"
-keyword_REINDEX="REINDEX"
-keyword_RELEASE="RELEASE"
-keyword_RENAME="RENAME"
-keyword_REPLACE="REPLACE"
-keyword_RESTRICT="RESTRICT"
-keyword_RIGHT="RIGHT"
-keyword_ROLLBACK="ROLLBACK"
-keyword_ROW="ROW"
-keyword_SAVEPOINT="SAVEPOINT"
-keyword_SELECT="SELECT"
-keyword_SET="SET"
-keyword_TABLE="TABLE"
-keyword_TEMP="TEMP"
-keyword_TEMPORARY="TEMPORARY"
-keyword_THEN="THEN"
-keyword_TO="TO"
-keyword_TRANSACTION="TRANSACTION"
-keyword_TRIGGER="TRIGGER"
-keyword_UNION="UNION"
-keyword_UNIQUE="UNIQUE"
-keyword_UPDATE="UPDATE"
-keyword_USING="USING"
-keyword_VACUUM="VACUUM"
-keyword_VALUES="VALUES"
-keyword_VIEW="VIEW"
-keyword_VIRTUAL="VIRTUAL"
-keyword_WHEN="WHEN"
-keyword_WHERE="WHERE"
-keyword_WITH="WITH"
-keyword_WITHOUT="WITHOUT"
-
-operator_concat=" || "
-operator_ebove_eq=" >="
-
-snippet_1eq1=" 1=1"
-snippet_at=" @1"
-snippet_backticks=" `a`"
-snippet_blob=" blob"
-snippet_brackets=" [a]"
-snippet_colon=" :1"
-snippet_comment=" /* */"
-snippet_date="2001-01-01"
-snippet_dollar=" $1"
-snippet_dotref=" a.b"
-snippet_fmtY="%Y"
-snippet_int=" int"
-snippet_neg1=" -1"
-snippet_pair=" a,b"
-snippet_parentheses=" (1)"
-snippet_plus2days="+2 days"
-snippet_qmark=" ?1"
-snippet_semicolon=" ;"
-snippet_star=" *"
-snippet_string_pair=" \"a\",\"b\""
-
-string_dbl_q=" \"a\""
-string_escaped_q=" 'a''b'"
-string_single_q=" 'a'"
-
-pragma_application_id@1=" application_id"
-pragma_auto_vacuum@1=" auto_vacuum"
-pragma_automatic_index@1=" automatic_index"
-pragma_busy_timeout@1=" busy_timeout"
-pragma_cache_size@1=" cache_size"
-pragma_cache_spill@1=" cache_spill"
-pragma_case_sensitive_like@1=" case_sensitive_like"
-pragma_checkpoint_fullfsync@1=" checkpoint_fullfsync"
-pragma_collation_list@1=" collation_list"
-pragma_compile_options@1=" compile_options"
-pragma_count_changes@1=" count_changes"
-pragma_data_store_directory@1=" data_store_directory"
-pragma_database_list@1=" database_list"
-pragma_default_cache_size@1=" default_cache_size"
-pragma_defer_foreign_keys@1=" defer_foreign_keys"
-pragma_empty_result_callbacks@1=" empty_result_callbacks"
-pragma_encoding@1=" encoding"
-pragma_foreign_key_check@1=" foreign_key_check"
-pragma_foreign_key_list@1=" foreign_key_list"
-pragma_foreign_keys@1=" foreign_keys"
-pragma_freelist_count@1=" freelist_count"
-pragma_full_column_names@1=" full_column_names"
-pragma_fullfsync@1=" fullfsync"
-pragma_ignore_check_constraints@1=" ignore_check_constraints"
-pragma_incremental_vacuum@1=" incremental_vacuum"
-pragma_index_info@1=" index_info"
-pragma_index_list@1=" index_list"
-pragma_integrity_check@1=" integrity_check"
-pragma_journal_mode@1=" journal_mode"
-pragma_journal_size_limit@1=" journal_size_limit"
-pragma_legacy_file_format@1=" legacy_file_format"
-pragma_locking_mode@1=" locking_mode"
-pragma_max_page_count@1=" max_page_count"
-pragma_mmap_size@1=" mmap_size"
-pragma_page_count@1=" page_count"
-pragma_page_size@1=" page_size"
-pragma_parser_trace@1=" parser_trace"
-pragma_query_only@1=" query_only"
-pragma_quick_check@1=" quick_check"
-pragma_read_uncommitted@1=" read_uncommitted"
-pragma_recursive_triggers@1=" recursive_triggers"
-pragma_reverse_unordered_selects@1=" reverse_unordered_selects"
-pragma_schema_version@1=" schema_version"
-pragma_secure_delete@1=" secure_delete"
-pragma_short_column_names@1=" short_column_names"
-pragma_shrink_memory@1=" shrink_memory"
-pragma_soft_heap_limit@1=" soft_heap_limit"
-pragma_stats@1=" stats"
-pragma_synchronous@1=" synchronous"
-pragma_table_info@1=" table_info"
-pragma_temp_store@1=" temp_store"
-pragma_temp_store_directory@1=" temp_store_directory"
-pragma_threads@1=" threads"
-pragma_user_version@1=" user_version"
-pragma_vdbe_addoptrace@1=" vdbe_addoptrace"
-pragma_vdbe_debug@1=" vdbe_debug"
-pragma_vdbe_listing@1=" vdbe_listing"
-pragma_vdbe_trace@1=" vdbe_trace"
-pragma_wal_autocheckpoint@1=" wal_autocheckpoint"
-pragma_wal_checkpoint@1=" wal_checkpoint"
-pragma_writable_schema@1=" writable_schema"
-
-
-# This part has been generated with testing/libfuzzer/dictionary_generator.py
-# using sqlite3_prepare_v2_fuzzer binary and ISO/IEC FCD 9075-1.
-"all"
-"code"
-"BE"
-"text"
-"TP2,"
-"supported"
-"GR4)"
-"syntax"
-"S151,"
-"S043,"
-"\xe2\x80\x9cCR\xe2\x80\x9d"
-"(SQL/PSM)"
-"query"
-"expressions"
-"TP2;"
-"row"
-"[ISO9075-14],"
-"BNF."
-"<SQL"
-"parameters"
-"title"
-"S211,"
-"ISO/IEC:"
-"BNF,"
-"SQL_FEATURES"
-"should"
-"to"
-"only"
-"program"
-"present"
-"T211,"
-"G,"
-"local"
-"NY"
-"columns"
-"END."
-"do"
-"OBJECT"
-"rollback"
-"string"
-"FEAT2."
-"get"
-"H"
-"P001,"
-"between"
-"RI."
-"[ISO9075-11]"
-"cannot"
-"entries"
-"referencing"
-"datetime"
-"[UCS]."
-"BNF"
-"MINUTE"
-"(BNF"
-"IEC,"
-"False"
-"OF,"
-"level"
-"did"
-"W."
-"list"
-"large"
-"SQL)"
-"PSM."
-"(ISO/IEC"
-"SQL,"
-"SQL-"
-"SQL."
-"small"
-"x"
-"DEFINITION_SCHEMA;"
-"view"
-"Index"
-"[ISO9075-3])."
-"set"
-"S024,"
-"CHANGE."
-"reference"
-"T1,"
-"OLAP."
-"direct"
-"(SQL/XML)."
-"LARGE"
-"likely"
-"result"
-"T341,"
-"ST"
-"ISO/JTC"
-"INSERT,"
-"PKG004"
-"index"
-"PKG006"
-"PKG007"
-"PKG001"
-"PKG002"
-"PKG008"
-"supplied"
-"T611,"
-"access"
-"3"
-"version"
-"NULL."
-"routine"
-"[ISO9075-10])."
-"S1"
-"[UCS],"
-"P003,"
-"C"
-"terms"
-"(SQL/MED)"
-"JTC1/SC32"
-"K"
-"(SQL/JRT)"
-"modify"
-"reported"
-"S"
-"objects"
-"32N1821"
-"SECOND."
-"key"
-"UNDER"
-"(ANSI)"
-"rows"
-"come"
-"(CALL"
-"change"
-"P-"
-"both"
-"search"
-"SQLSTATE,"
-"[ISO9075-"
-"[ISO9075-14]."
-"many"
-"changed"
-"foreign"
-"Symbols"
-"S023,"
-"connection"
-"SQL\xe2\x80\x9d),"
-"context"
-"delete"
-"changes"
-"REFERENCES,"
-"page."
-"named"
-"point"
-"UPDATE."
-"S2"
-"UPDATE,"
-"[ISO9075-13]"
-"Y\xe2\x80\x9d"
-"replace"
-"\xe2\x80\x9cPSM\xe2\x80\x9d"
-"SERIALIZABLE,"
-"names"
-"E"
-"PUBLIC."
-"table"
-"REF"
-"INFORMATION_SCHEMA"
-"C1."
-"ID."
-"use"
-"[ISO9075-2]."
-"from"
-"USA"
-"0"
-"distinct"
-"create"
-"contains"
-"due"
-"ISO."
-"few"
-"duplicate"
-"trigger"
-"call"
-"S111,"
-"expected"
-"REPEATABLE"
-"C1"
-"DOCUMENT"
-"type"
-"authorization"
-"more"
-"XML"
-"[ISO9075-3],"
-"<A>,"
-"P"
-"on"
-"initial"
-"name,"
-"[ISO9075-11]),"
-"QE,"
-"STANDARD"
-"PKG010"
-"TRIGGER,"
-"V"
-"CS"
-"SQL\xe2\x80\x9d:"
-"IEC"
-"Expression"
-"F521,"
-"sequence:"
-"must"
-"none"
-"SR3)"
-"word"
-"INTERNATIONAL"
-"ANSI"
-"this"
-"PSM"
-"PUBLIC),"
-"modified"
-"value"
-"<"
-"descriptor"
-"while"
-"paragraph"
-"values"
-"resources"
-"error"
-"exceptions"
-"IT"
-"F,"
-"CO,"
-"[ISO9075-4],"
-"control"
-"type,"
-"reserved"
-"SQL:"
-"<C>"
-"[ISO9075-2])."
-"F052,"
-"attribute"
-"is"
-"type:"
-"level,"
-"it"
-"[ISO9075-2],"
-"incremental"
-"MONTH,"
-"dropped"
-"MONTH."
-"allowed"
-"S241,"
-"\xe2\x80\x9cSQL"
-"TIMESTAMP"
-"failed"
-"SC"
-"end"
-"Format"
-"ST."
-"permission"
-"V,"
-"length"
-"same"
-"[ISO10646]."
-"write"
-"arguments"
-"F555,"
-"F671,"
-"<C>,"
-"<C>."
-"parameter"
-"NATIONAL"
-"Types"
-"A"
-"Insert"
-"32/WG"
-"used"
-"temporary"
-"\xe2\x80\x9cOLAP\xe2\x80\x9d"
-"(FCD)"
-"may"
-"after"
-"(SQL/OLB)"
-"THIS"
-"Q"
-"SQL/CLI"
-"levels"
-"two"
-"characters"
-"date"
-"such"
-"[ISO9075-9]"
-"data"
-"stack"
-"single"
-"a"
-"FEAT,"
-"lower"
-"transaction"
-"in"
-"database"
-"EXTRACT)"
-"expression"
-"32N1963"
-"CD"
-"without"
-"QE."
-"1"
-"CALL"
-"F"
-"[ISO9075-4])."
-"entry"
-"the"
-"SUBJECT"
-"N1968;"
-"order"
-"left"
-"FEAT1,"
-"FEAT1."
-"S081,"
-"YEAR"
-"READ,"
-"SQL;"
-"A,"
-"symbols"
-"S161,"
-"[ISO9075-10]"
-"already"
-"identify"
-"V."
-"during"
-"differs"
-"(UCS)."
-"Final"
-"before"
-"tables"
-"[UCS]"
-"Multiple"
-"integer"
-"NT,"
-"character"
-","
-"ID\xe2\x80\x9d"
-"(INFORMATION_SCHEMA)"
-"source"
-"add"
-"other"
-"TP1"
-"SQLSTATE"
-"has"
-"match"
-"KEY."
-"real"
-"On"
-"C1,"
-"D"
-"[ISO14651]"
-"views"
-"read"
-"\xe2\x80\x9cGR\xe2\x80\x9d"
-"L"
-"primary"
-"TB1."
-"qualified"
-"(SUBSTRING,"
-"T"
-"compound"
-"not"
-"using"
-"unique"
-"LOB"
-"name"
-"term"
-"sorting"
-"like"
-"B,"
-"[ISO9075-1]"
-"RESULT,"
-"Numeric"
-"MONTH"
-"PURPOSES."
-"[ISO9075-11]."
-"mode"
-"(DEFINITION_SCHEMA)."
-"SQL"
-"ISO"
-"page"
-"constraints"
-"\xc2\xa9ISO/IEC"
-"right"
-"Java"
-"sequence"
-"TB1"
-"TB2"
-"P002,"
-"DAY,"
-"extended"
-"(SQL/CLI)"
-"X"
-"specified"
-"S051,"
-"clauses"
-"operation"
-"FEAT"
-"out"
-"E,"
-"XML."
-"for"
-"space"
-"support"
-"T041,"
-"[ISO9075-4]"
-"content"
-"I"
-"does"
-"STUDY"
-"CHARACTER,"
-"B1"
-"T212,"
-"be"
-"object"
-"[ISO9075-11],"
-"G"
-"ZONE,"
-"S2."
-"collations"
-"[ISO9075-2]:"
-"<A>"
-"O"
-"standard"
-"[ISO9075-2]"
-"base"
-"W"
-"collation"
-"HOUR,"
-"UNDER,"
-"JTC"
-"C."
-"definition"
-"Square"
-"\xe2\x80\x9cSR\xe2\x80\x9d"
-"extension"
-"constraint"
-"column"
-"of"
-"C,"
-"F701,"
-"(SQL/CLI)."
-"T191,"
-"range"
-"GR"
-"1,"
-"constructor"
-"commit"
-"or"
-"first"
-"referenced"
-"statements"
-"encoding"
-"B1."
-"clause"
-"variables"
-"within"
-"number"
-"one"
-"NT"
-"variable"
-"because"
-"references"
-"another"
-"blank"
-"operator"
-"RETURN"
-"COMMITTED,"
-"9075-1:2011(E)"
-"[ISO9075-14]"
-"(SQL/OLB)."
-"D1"
-"exists"
-"REFERENCE"
-"area"
-"S041,"
-"unknown"
-"Symbol"
-"there"
-"system"
-"long"
-"ID"
-"start"
-"returns"
-"2"
-"authorized"
-"statement"
-"X2"
-"FCD"
-"STILL"
-"S231,"
-"final"
-"READ"
-"schema"
-"function"
-"DELETE,"
-"B"
-"TC\xe2\x80\x9d."
-"declare"
-"month"
-"Deprecated"
-"exactly"
-"[ISO10646]"
-"JTC1"
-"but"
-"9075-1:2010(E)"
-"part"
-"T201,"
-"D2."
-"<B>,"
-"attempt"
-"line"
-"with"
-"than"
-"<B>"
-"BEFORE,"
-"DAY."
-"DATE"
-"default"
-"EXECUTE."
-"B1,"
-"F191,"
-"tree"
-"second"
-"SHOULD"
-"[ISO9075-13],"
-"A1,"
-"1/SC"
-"VARYING,"
-"<B>."
-"SQL/CLI,"
-"were"
-"1)"
-"<A>."
-"CLI,"
-"called"
-"are"
-"and"
-"(SQL/MED)."
-"[ISO9075-4]:"
-"associated"
-"\xe2\x80\x9cAR\xe2\x80\x9d"
-"defined"
-"(SQL/XML)"
-"CHARACTER"
-"argument"
-"an"
-"[ISO9075-4])"
-"non-deterministic"
-"as"
-"Other"
-"at"
-"have"
-"[ISO9075-4]."
-"CS."
-"\xe2\x80\x9cV\xe2\x80\x9d"
-"Y."
-"null"
-"any"
-"CLI"
-"Function"
-"NOTE"
-"functions"
-"UCS"
-"returned"
-"F411,"
-"no"
-"TIME"
-"that"
-"-"
-"RETURN),"
-"A1"
-"OLAP"
-"internal"
-"S071,"
-"[ISO9075-10],"
-"T431,"
-"A1."
-"\xe2\x80\x9cONLY"
-"Y"
-"SS"
-"UNCOMMITTED,"
-"multiple"
-"Name"
-"truncate"
-"normal"
-"symbol"
-"literal"
-"M"
-"\xe2\x80\x9c<SQL"
-"prepared"
-"most"
-"ATOMIC,"
-"E."
-"U"
-"letter"
-"PUBLIC"
-"identical"
-"F491,"
-"N"
-"inserted"
-"Page"
-"(SQL/JRT)."
-"D,"
-"SELECT,"
-"USED"
-"lead"
-"Sequence"
-"FEAT1"
-"into"
-"required"
-"[ISO9075-9],"
-"USAGE,"
-"2nd"
-"depth"
-"R"
-"ISO,"
-"time"
-"SQL\xe2\x80\x9d,"
-"FEAT2"
-"[ISO9075-3]"
-"(SQL/PSM)."
-"ISO/IEC"
diff --git a/chromium/third_party/sqlite/fuzz/sql_expr_fuzzer.cc b/chromium/third_party/sqlite/fuzz/sql_expr_fuzzer.cc
deleted file mode 100644
index f20e5d9fb93..00000000000
--- a/chromium/third_party/sqlite/fuzz/sql_expr_fuzzer.cc
+++ /dev/null
@@ -1,31 +0,0 @@
-// 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
deleted file mode 100644
index 5b5c8009bdf..00000000000
--- a/chromium/third_party/sqlite/fuzz/sql_fuzzer.cc
+++ /dev/null
@@ -1,58 +0,0 @@
-// 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
deleted file mode 100644
index a16101ebae7..00000000000
--- a/chromium/third_party/sqlite/fuzz/sql_generate_corpus.cc
+++ /dev/null
@@ -1,969 +0,0 @@
-#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
deleted file mode 100644
index 000e4afa42f..00000000000
--- a/chromium/third_party/sqlite/fuzz/sql_multithreaded_fuzzer.cc
+++ /dev/null
@@ -1,91 +0,0 @@
-// 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
deleted file mode 100644
index eb0dafb5c06..00000000000
--- a/chromium/third_party/sqlite/fuzz/sql_printf_fuzzer.cc
+++ /dev/null
@@ -1,31 +0,0 @@
-// 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
deleted file mode 100644
index d12ebe7b981..00000000000
--- a/chromium/third_party/sqlite/fuzz/sql_queries.proto
+++ /dev/null
@@ -1,23 +0,0 @@
-// 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
deleted file mode 100644
index ceb67799cd7..00000000000
--- a/chromium/third_party/sqlite/fuzz/sql_query_grammar.proto
+++ /dev/null
@@ -1,1663 +0,0 @@
-// 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
deleted file mode 100644
index 84a09fd1604..00000000000
--- a/chromium/third_party/sqlite/fuzz/sql_query_proto_to_string.cc
+++ /dev/null
@@ -1,2757 +0,0 @@
-// 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
deleted file mode 100644
index b4b7fe9104f..00000000000
--- a/chromium/third_party/sqlite/fuzz/sql_query_proto_to_string.h
+++ /dev/null
@@ -1,30 +0,0 @@
-// 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
deleted file mode 100644
index 010b67efcae..00000000000
--- a/chromium/third_party/sqlite/fuzz/sql_run_queries.cc
+++ /dev/null
@@ -1,172 +0,0 @@
-// 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
deleted file mode 100644
index 95506d92713..00000000000
--- a/chromium/third_party/sqlite/fuzz/sql_run_queries.h
+++ /dev/null
@@ -1,18 +0,0 @@
-// 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
deleted file mode 100644
index 7c4322ea912..00000000000
--- a/chromium/third_party/sqlite/fuzz/sql_strftime_fuzzer.cc
+++ /dev/null
@@ -1,31 +0,0 @@
-// 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 1d86c19c32f..69f62077520 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/40] Modify default VFS to support WebDatabase.
+Subject: [PATCH 1/7] 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
@@ -141,10 +141,10 @@ index aafc89f7d2d5..76743781a019 100644
+
#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
+index fd6046dfe169..3d6b63e006a0 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);
+@@ -8407,6 +8407,29 @@ int sqlite3_strnicmp(const char *, const char *, int);
*/
int sqlite3_strglob(const char *zGlob, const char *zStr);
@@ -175,5 +175,5 @@ index cf17bc015fa7..11622a49697f 100644
** CAPI3REF: String LIKE Matching
*
--
-2.18.0
+2.20.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 ef5d82012f0..0e343fc21e7 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,8 +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/40] Virtual table supporting recovery of corrupted
- databases.
+Subject: [PATCH 2/7] 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
@@ -34,7 +33,7 @@ third_party/sqlite/src/src/{recover,recover-alt}.c .
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 d18313bdc79a..81774f9b100f 100644
+index c4e8b78e911f..57a27c1e3fc1 100644
--- a/third_party/sqlite/src/main.mk
+++ b/third_party/sqlite/src/main.mk
@@ -77,6 +77,8 @@ LIBOBJ+= vdbe.o parse.o \
@@ -46,7 +45,7 @@ index d18313bdc79a..81774f9b100f 100644
LIBOBJ += sqlite3session.o
# All of the source code files.
-@@ -409,6 +411,8 @@ TESTSRC2 = \
+@@ -410,6 +412,8 @@ TESTSRC2 = \
$(TOP)/src/prepare.c \
$(TOP)/src/printf.c \
$(TOP)/src/random.c \
@@ -55,7 +54,7 @@ index d18313bdc79a..81774f9b100f 100644
$(TOP)/src/pcache.c \
$(TOP)/src/pcache1.c \
$(TOP)/src/select.c \
-@@ -876,6 +880,7 @@ TESTFIXTURE_FLAGS += -DSQLITE_DEFAULT_PAGE_SIZE=1024
+@@ -898,6 +902,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
@@ -64,10 +63,10 @@ index d18313bdc79a..81774f9b100f 100644
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
+index c98cfe99eed3..d58f8c633f8b 100644
--- a/third_party/sqlite/src/src/main.c
+++ b/third_party/sqlite/src/src/main.c
-@@ -3201,6 +3201,14 @@ static int openDatabase(
+@@ -3244,6 +3244,14 @@ static int openDatabase(
}
#endif
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 6a49c96d76a..286ef28f2cb 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/40] Custom shell.c helpers to load Chromium's ICU data.
+Subject: [PATCH 3/7] 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.
@@ -36,10 +36,10 @@ index b838b844a312..3047d172389b 100644
# Nothing for unix.
#
diff --git a/third_party/sqlite/src/main.mk b/third_party/sqlite/src/main.mk
-index 81774f9b100f..b460a58d9a94 100644
+index 57a27c1e3fc1..ee8ebbb92f50 100644
--- a/third_party/sqlite/src/main.mk
+++ b/third_party/sqlite/src/main.mk
-@@ -549,7 +549,7 @@ libsqlite3.a: $(LIBOBJ)
+@@ -556,7 +556,7 @@ libsqlite3.a: $(LIBOBJ)
sqlite3$(EXE): shell.c libsqlite3.a sqlite3.h
$(TCCX) $(READLINE_FLAGS) -o sqlite3$(EXE) $(SHELL_OPT) \
@@ -49,10 +49,10 @@ index 81774f9b100f..b460a58d9a94 100644
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
+index cca409a6ac73..9ccac2b34ee5 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){
+@@ -8891,6 +8891,16 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){
}
#endif
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 e77c9494f8c..72b1a2d664c 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/40] [fts3] Disable fts3_tokenizer and fts4.
+Subject: [PATCH 4/7] [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
@@ -14,7 +14,7 @@ No original review URL because this was part of the initial Chromium commit.
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
+index 823e1b6a81fe..c371d3e8f0b5 100644
--- a/third_party/sqlite/src/ext/fts3/fts3.c
+++ b/third_party/sqlite/src/ext/fts3/fts3.c
@@ -287,6 +287,7 @@
@@ -25,7 +25,7 @@ index 44d9e20cc667..ef69a7b18681 100644
#include "fts3Int.h"
#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3)
-@@ -3988,7 +3989,11 @@ int sqlite3Fts3Init(sqlite3 *db){
+@@ -4016,7 +4017,11 @@ int sqlite3Fts3Init(sqlite3 *db){
** module with sqlite.
*/
if( SQLITE_OK==rc
@@ -37,7 +37,7 @@ index 44d9e20cc667..ef69a7b18681 100644
&& 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){
+@@ -4026,6 +4031,9 @@ int sqlite3Fts3Init(sqlite3 *db){
rc = sqlite3_create_module_v2(
db, "fts3", &fts3Module, (void *)pHash, hashDestroy
);
@@ -47,7 +47,7 @@ index 44d9e20cc667..ef69a7b18681 100644
if( rc==SQLITE_OK ){
rc = sqlite3_create_module_v2(
db, "fts4", &fts3Module, (void *)pHash, 0
-@@ -4006,6 +4014,7 @@ int sqlite3Fts3Init(sqlite3 *db){
+@@ -4034,6 +4042,7 @@ int sqlite3Fts3Init(sqlite3 *db){
if( rc==SQLITE_OK ){
rc = sqlite3Fts3InitTok(db, (void *)pHash);
}
@@ -56,5 +56,5 @@ index 44d9e20cc667..ef69a7b18681 100644
}
--
-2.18.0
+2.20.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 8f4f6e01db9..839564ce711 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/40] fuchsia: Use dot-file locking for sqlite
+Subject: [PATCH 5/7] 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-compilation-with-SQLITE_OMIT_WINDOWFUNC.patch b/chromium/third_party/sqlite/patches/0006-Fix-compilation-with-SQLITE_OMIT_WINDOWFUNC.patch
new file mode 100644
index 00000000000..8b30021ec55
--- /dev/null
+++ b/chromium/third_party/sqlite/patches/0006-Fix-compilation-with-SQLITE_OMIT_WINDOWFUNC.patch
@@ -0,0 +1,32 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Victor Costan <pwnall@chromium.org>
+Date: Sun, 10 Feb 2019 13:12:57 -0800
+Subject: [PATCH 6/7] Fix compilation with SQLITE_OMIT_WINDOWFUNC.
+
+---
+ third_party/sqlite/src/src/resolve.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/third_party/sqlite/src/src/resolve.c b/third_party/sqlite/src/src/resolve.c
+index 00c6bb9680b0..edf1e203440c 100644
+--- a/third_party/sqlite/src/src/resolve.c
++++ b/third_party/sqlite/src/src/resolve.c
+@@ -1533,6 +1533,7 @@ static int resolveSelectStep(Walker *pWalker, Select *p){
+ }
+ }
+
++#ifndef SQLITE_OMIT_WINDOWFUNC
+ if( IN_RENAME_OBJECT ){
+ Window *pWin;
+ for(pWin=p->pWinDefn; pWin; pWin=pWin->pNextWin){
+@@ -1543,6 +1544,7 @@ static int resolveSelectStep(Walker *pWalker, Select *p){
+ }
+ }
+ }
++#endif
+
+ /* If this is part of a compound SELECT, check that it has the right
+ ** number of expressions in the select list. */
+--
+2.18.0
+
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
deleted file mode 100644
index c5cd6153bd8..00000000000
--- a/chromium/third_party/sqlite/patches/0006-Fix-dbfuzz2-for-Clusterfuzz.patch
+++ /dev/null
@@ -1,25 +0,0 @@
-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/40] Fix dbfuzz2 for Clusterfuzz.
-
-This backports https://www.sqlite.org/src/info/9ad796a8822f1b7e
----
- third_party/sqlite/src/test/dbfuzz2.c | 1 +
- 1 file changed, 1 insertion(+)
-
-diff --git a/third_party/sqlite/src/test/dbfuzz2.c b/third_party/sqlite/src/test/dbfuzz2.c
-index 0833f0386884..9e3aca25274b 100644
---- a/third_party/sqlite/src/test/dbfuzz2.c
-+++ b/third_party/sqlite/src/test/dbfuzz2.c
-@@ -78,6 +78,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *aData, size_t nByte){
- printf("************** nByte=%d ***************\n", (int)nByte);
- fflush(stdout);
- }
-+ if( sqlite3_initialize() ) return 0;
- rc = sqlite3_open(0, &db);
- if( rc ) return 1;
- a = sqlite3_malloc64(nByte+1);
---
-2.18.0
-
diff --git a/chromium/third_party/sqlite/patches/0007-Fix-dbfuzz2.c-compilation-errors-on-Windows.patch b/chromium/third_party/sqlite/patches/0007-Fix-dbfuzz2.c-compilation-errors-on-Windows.patch
new file mode 100644
index 00000000000..d3f19f5d02f
--- /dev/null
+++ b/chromium/third_party/sqlite/patches/0007-Fix-dbfuzz2.c-compilation-errors-on-Windows.patch
@@ -0,0 +1,43 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Victor Costan <pwnall@chromium.org>
+Date: Sun, 10 Feb 2019 15:18:43 -0800
+Subject: [PATCH 7/7] Fix dbfuzz2.c compilation errors on Windows.
+
+---
+ third_party/sqlite/src/test/dbfuzz2.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/third_party/sqlite/src/test/dbfuzz2.c b/third_party/sqlite/src/test/dbfuzz2.c
+index c964ad4f018f..dd1ed061717b 100644
+--- a/third_party/sqlite/src/test/dbfuzz2.c
++++ b/third_party/sqlite/src/test/dbfuzz2.c
+@@ -43,8 +43,10 @@
+ #include <stdarg.h>
+ #include <ctype.h>
+ #include <stdint.h>
++#ifndef _WIN32
+ #include <sys/time.h>
+ #include <sys/resource.h>
++#endif
+ #include "sqlite3.h"
+
+ /*
+@@ -261,6 +263,7 @@ int LLVMFuzzerInitialize(int *pArgc, char ***pArgv){
+ szMax = strtol(argv[++i], 0, 0);
+ continue;
+ }
++#ifndef _WIN32
+ if( strcmp(z,"max-stack")==0
+ || strcmp(z,"max-data")==0
+ || strcmp(z,"max-as")==0
+@@ -291,6 +294,7 @@ int LLVMFuzzerInitialize(int *pArgc, char ***pArgv){
+ zType, (int)x.rlim_cur, (int)y.rlim_cur);
+ continue;
+ }
++#endif
+ }
+ argv[j++] = argv[i];
+ }
+--
+2.20.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
deleted file mode 100644
index 8886eabfca3..00000000000
--- a/chromium/third_party/sqlite/patches/0007-Fix-the-Makefile-so-that-it-honors-CFLAGS-when-build.patch
+++ /dev/null
@@ -1,27 +0,0 @@
-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/40] Fix the Makefile so that it honors CFLAGS when building
- sessionfuzz.
-
-This backports https://www.sqlite.org/src/info/54231ac4ca506e6c
----
- third_party/sqlite/src/Makefile.in | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/third_party/sqlite/src/Makefile.in b/third_party/sqlite/src/Makefile.in
-index d2f97100597b..3b05f1e25ca7 100644
---- a/third_party/sqlite/src/Makefile.in
-+++ b/third_party/sqlite/src/Makefile.in
-@@ -669,7 +669,7 @@ ossshell$(TEXE): $(TOP)/test/ossfuzz.c $(TOP)/test/ossshell.c sqlite3.c sqlite3.
- $(TOP)/test/ossfuzz.c sqlite3.c $(TLIBS)
-
- sessionfuzz$(TEXE): $(TOP)/test/sessionfuzz.c sqlite3.c sqlite3.h
-- $(CC) $(CFLAGS) -I. -o $@ $(TOP)/test/sessionfuzz.c $(TLIBS)
-+ $(LTLINK) -o $@ $(TOP)/test/sessionfuzz.c $(TLIBS)
-
- dbfuzz$(TEXE): $(TOP)/test/dbfuzz.c sqlite3.c sqlite3.h
- $(LTLINK) -o $@ $(DBFUZZ_OPT) $(TOP)/test/dbfuzz.c sqlite3.c $(TLIBS)
---
-2.18.0
-
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
deleted file mode 100644
index 8d86320bf7e..00000000000
--- a/chromium/third_party/sqlite/patches/0008-Adjustments-to-the-page-cache-to-try-to-avoid-harmle.patch
+++ /dev/null
@@ -1,38 +0,0 @@
-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/40] Adjustments to the page cache to try to avoid harmless
- TSAN warnings
-
-This backports https://www.sqlite.org/src/info/383437be276719ac
-
-Bug: 917380
----
- third_party/sqlite/src/src/pcache1.c | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/third_party/sqlite/src/src/pcache1.c b/third_party/sqlite/src/src/pcache1.c
-index 59c1869ff707..1986b22ca61c 100644
---- a/third_party/sqlite/src/src/pcache1.c
-+++ b/third_party/sqlite/src/src/pcache1.c
-@@ -167,6 +167,7 @@ struct PCache1 {
- unsigned int nMax; /* Configured "cache_size" value */
- unsigned int n90pct; /* nMax*9/10 */
- unsigned int iMaxKey; /* Largest key seen since xTruncate() */
-+ unsigned int nPurgeableDummy; /* pnPurgeable points here when not used*/
-
- /* Hash table of all pages. The following variables may only be accessed
- ** when the accessor is holding the PGroup mutex.
-@@ -780,8 +781,7 @@ static sqlite3_pcache *pcache1Create(int szPage, int szExtra, int bPurgeable){
- pGroup->mxPinned = pGroup->nMaxPage + 10 - pGroup->nMinPage;
- pCache->pnPurgeable = &pGroup->nPurgeable;
- }else{
-- static unsigned int dummyCurrentPage;
-- pCache->pnPurgeable = &dummyCurrentPage;
-+ pCache->pnPurgeable = &pCache->nPurgeableDummy;
- }
- pcache1LeaveMutex(pGroup);
- if( pCache->nHash==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
deleted file mode 100644
index d5159f6edd3..00000000000
--- a/chromium/third_party/sqlite/patches/0009-Remove-an-ALWAYS-from-a-branch-that-is-not-always-ta.patch
+++ /dev/null
@@ -1,29 +0,0 @@
-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/40] Remove an ALWAYS() from a branch that is not always
- taken.
-
-This backports https://www.sqlite.org/src/info/5c7dab
-
-Bug: 918035
----
- third_party/sqlite/src/src/expr.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/third_party/sqlite/src/src/expr.c b/third_party/sqlite/src/src/expr.c
-index 4aff7f67c9b6..6b2c5a540a82 100644
---- a/third_party/sqlite/src/src/expr.c
-+++ b/third_party/sqlite/src/src/expr.c
-@@ -4755,7 +4755,7 @@ int sqlite3ExprCompare(Parse *pParse, Expr *pA, Expr *pB, int iTab){
- }
- }
- if( (pA->flags & EP_Distinct)!=(pB->flags & EP_Distinct) ) return 2;
-- if( ALWAYS((combinedFlags & EP_TokenOnly)==0) ){
-+ if( (combinedFlags & EP_TokenOnly)==0 ){
- if( combinedFlags & EP_xIsSelect ) return 2;
- if( (combinedFlags & EP_FixedCol)==0
- && sqlite3ExprCompare(pParse, pA->pLeft, pB->pLeft, iTab) ) return 2;
---
-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
deleted file mode 100644
index 216d8ef8117..00000000000
--- a/chromium/third_party/sqlite/patches/0010-Fix-a-problem-with-nested-CTEs-with-the-same-table.patch
+++ /dev/null
@@ -1,42 +0,0 @@
-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/40] Fix a problem with nested CTEs with the same table.
-
-This backports https://www.sqlite.org/src/info/202dd033019dd274
-
-Bug: 917834
----
- third_party/sqlite/src/src/select.c | 11 ++++++++---
- 1 file changed, 8 insertions(+), 3 deletions(-)
-
-diff --git a/third_party/sqlite/src/src/select.c b/third_party/sqlite/src/src/select.c
-index 870c3b5c1739..fab4df68fa17 100644
---- a/third_party/sqlite/src/src/select.c
-+++ b/third_party/sqlite/src/src/select.c
-@@ -5464,14 +5464,19 @@ static struct SrcList_item *isSelfJoinView(
- ){
- struct SrcList_item *pItem;
- for(pItem = pTabList->a; pItem<pThis; pItem++){
-+ Select *pS1;
- if( pItem->pSelect==0 ) continue;
- if( pItem->fg.viaCoroutine ) continue;
- if( pItem->zName==0 ) continue;
- if( sqlite3_stricmp(pItem->zDatabase, pThis->zDatabase)!=0 ) continue;
- if( sqlite3_stricmp(pItem->zName, pThis->zName)!=0 ) continue;
-- if( sqlite3ExprCompare(0,
-- pThis->pSelect->pWhere, pItem->pSelect->pWhere, -1)
-- ){
-+ pS1 = pItem->pSelect;
-+ if( pThis->pSelect->selId!=pS1->selId ){
-+ /* The query flattener left two different CTE tables with identical
-+ ** names in the same FROM clause. */
-+ continue;
-+ }
-+ if( sqlite3ExprCompare(0, pThis->pSelect->pWhere, pS1->pWhere, -1) ){
- /* The view was modified by some other optimization such as
- ** pushDownWhereTerms() */
- continue;
---
-2.18.0
-
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
deleted file mode 100644
index 878c4b23cae..00000000000
--- a/chromium/third_party/sqlite/patches/0011-Fix-detection-of-self-referencing-rows-in-foreign-ke.patch
+++ /dev/null
@@ -1,50 +0,0 @@
-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/40] Fix detection of self-referencing rows in foreign key
- processing.
-
-This backports https://www.sqlite.org/src/info/16fff05347f42fe9
-
-Bug: 916478
----
- third_party/sqlite/src/src/fkey.c | 13 ++++++++-----
- 1 file changed, 8 insertions(+), 5 deletions(-)
-
-diff --git a/third_party/sqlite/src/src/fkey.c b/third_party/sqlite/src/src/fkey.c
-index 71e55adaf8ab..b9aad0c96588 100644
---- a/third_party/sqlite/src/src/fkey.c
-+++ b/third_party/sqlite/src/src/fkey.c
-@@ -602,8 +602,11 @@ static void fkScanChildren(
- ** NOT( $current_a==a AND $current_b==b AND ... )
- **
- ** The first form is used for rowid tables. The second form is used
-- ** for WITHOUT ROWID tables. In the second form, the primary key is
-- ** (a,b,...)
-+ ** for WITHOUT ROWID tables. In the second form, the *parent* key is
-+ ** (a,b,...). Either the parent or primary key could be used to
-+ ** uniquely identify the current row, but the parent key is more convenient
-+ ** as the required values have already been loaded into registers
-+ ** by the caller.
- */
- if( pTab==pFKey->pFrom && nIncr>0 ){
- Expr *pNe; /* Expression (pLeft != pRight) */
-@@ -617,12 +620,12 @@ static void fkScanChildren(
- Expr *pEq, *pAll = 0;
- Index *pPk = sqlite3PrimaryKeyIndex(pTab);
- assert( pIdx!=0 );
-- for(i=0; i<pPk->nKeyCol; i++){
-+ for(i=0; i<pIdx->nKeyCol; i++){
- i16 iCol = pIdx->aiColumn[i];
- assert( iCol>=0 );
- pLeft = exprTableRegister(pParse, pTab, regData, iCol);
-- pRight = exprTableColumn(db, pTab, pSrc->a[0].iCursor, iCol);
-- pEq = sqlite3PExpr(pParse, TK_EQ, pLeft, pRight);
-+ pRight = sqlite3Expr(db, TK_ID, pTab->aCol[iCol].zName);
-+ pEq = sqlite3PExpr(pParse, TK_IS, pLeft, pRight);
- pAll = sqlite3ExprAnd(db, pAll, pEq);
- }
- pNe = sqlite3PExpr(pParse, TK_NOT, pAll, 0);
---
-2.18.0
-
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
deleted file mode 100644
index 5f739802ad8..00000000000
--- a/chromium/third_party/sqlite/patches/0012-Fix-a-segfault-caused-by-using-the-RAISE-function-in.patch
+++ /dev/null
@@ -1,29 +0,0 @@
-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/40] Fix a segfault caused by using the RAISE function
- incorrectly.
-
-This backports https://sqlite.org/src/info/ddf06db702761d66
-
-Bug: 915479
----
- third_party/sqlite/src/src/expr.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/third_party/sqlite/src/src/expr.c b/third_party/sqlite/src/src/expr.c
-index 6b2c5a540a82..0aa11c43bf4a 100644
---- a/third_party/sqlite/src/src/expr.c
-+++ b/third_party/sqlite/src/src/expr.c
-@@ -4722,7 +4722,7 @@ int sqlite3ExprCompare(Parse *pParse, Expr *pA, Expr *pB, int iTab){
- }
- return 2;
- }
-- if( pA->op!=pB->op ){
-+ if( pA->op!=pB->op || pA->op==TK_RAISE ){
- if( pA->op==TK_COLLATE && sqlite3ExprCompare(pParse, pA->pLeft,pB,iTab)<2 ){
- return 1;
- }
---
-2.18.0
-
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
deleted file mode 100644
index d9e280440e7..00000000000
--- a/chromium/third_party/sqlite/patches/0013-Fix-for-an-assert-that-could-be-false.patch
+++ /dev/null
@@ -1,33 +0,0 @@
-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/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
-
-Bug: 911255
----
- third_party/sqlite/src/src/expr.c | 6 ++++--
- 1 file changed, 4 insertions(+), 2 deletions(-)
-
-diff --git a/third_party/sqlite/src/src/expr.c b/third_party/sqlite/src/src/expr.c
-index 0aa11c43bf4a..05c9521b2030 100644
---- a/third_party/sqlite/src/src/expr.c
-+++ b/third_party/sqlite/src/src/expr.c
-@@ -4761,8 +4761,10 @@ int sqlite3ExprCompare(Parse *pParse, Expr *pA, Expr *pB, int iTab){
- && sqlite3ExprCompare(pParse, pA->pLeft, pB->pLeft, iTab) ) return 2;
- if( sqlite3ExprCompare(pParse, pA->pRight, pB->pRight, iTab) ) return 2;
- if( sqlite3ExprListCompare(pA->x.pList, pB->x.pList, iTab) ) return 2;
-- assert( (combinedFlags & EP_Reduced)==0 );
-- if( pA->op!=TK_STRING && pA->op!=TK_TRUEFALSE ){
-+ if( pA->op!=TK_STRING
-+ && pA->op!=TK_TRUEFALSE
-+ && (combinedFlags & EP_Reduced)==0
-+ ){
- if( pA->iColumn!=pB->iColumn ) return 2;
- if( pA->iTable!=pB->iTable
- && (pA->iTable!=iTab || NEVER(pB->iTable>=0)) ) return 2;
---
-2.18.0
-
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
deleted file mode 100644
index 4b4c61a4d89..00000000000
--- a/chromium/third_party/sqlite/patches/0014-Fix-another-problem-found-by-Matthew-Denton-s-new-fu.patch
+++ /dev/null
@@ -1,40 +0,0 @@
-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/40] Fix another problem found by Matthew Denton's new
- fuzzer.
-
-This backports https://sqlite.org/src/info/2b690dbdffe144bd
-
-Bug: 911253
----
- third_party/sqlite/src/src/expr.c | 6 +++---
- 1 file changed, 3 insertions(+), 3 deletions(-)
-
-diff --git a/third_party/sqlite/src/src/expr.c b/third_party/sqlite/src/src/expr.c
-index 05c9521b2030..c61528288baf 100644
---- a/third_party/sqlite/src/src/expr.c
-+++ b/third_party/sqlite/src/src/expr.c
-@@ -141,8 +141,8 @@ CollSeq *sqlite3ExprCollSeq(Parse *pParse, Expr *pExpr){
- while( p ){
- int op = p->op;
- if( p->flags & EP_Generic ) break;
-- if( (op==TK_AGG_COLUMN || op==TK_COLUMN
-- || op==TK_REGISTER || op==TK_TRIGGER)
-+ if( op==TK_REGISTER ) op = p->op2;
-+ if( (op==TK_AGG_COLUMN || op==TK_COLUMN || op==TK_TRIGGER)
- && p->y.pTab!=0
- ){
- /* op==TK_REGISTER && p->y.pTab!=0 happens when pExpr was originally
-@@ -158,7 +158,7 @@ CollSeq *sqlite3ExprCollSeq(Parse *pParse, Expr *pExpr){
- p = p->pLeft;
- continue;
- }
-- if( op==TK_COLLATE || (op==TK_REGISTER && p->op2==TK_COLLATE) ){
-+ if( op==TK_COLLATE ){
- pColl = sqlite3GetCollSeq(pParse, ENC(db), 0, p->u.zToken);
- break;
- }
---
-2.18.0
-
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
deleted file mode 100644
index 12ea8973467..00000000000
--- a/chromium/third_party/sqlite/patches/0015-Report-a-new-corruption-case.patch
+++ /dev/null
@@ -1,47 +0,0 @@
-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/40] Report a new corruption case.
-
-This backports https://sqlite.org/src/info/cc42dd15100db28a
-
-Bug: 917285
----
- third_party/sqlite/src/src/btree.c | 7 +++++++
- third_party/sqlite/src/test/fuzzcheck.c | 2 +-
- 2 files changed, 8 insertions(+), 1 deletion(-)
-
-diff --git a/third_party/sqlite/src/src/btree.c b/third_party/sqlite/src/src/btree.c
-index 7a8de2d78c6a..6b17bdee5c4f 100644
---- a/third_party/sqlite/src/src/btree.c
-+++ b/third_party/sqlite/src/src/btree.c
-@@ -992,6 +992,13 @@ static void ptrmapPut(BtShared *pBt, Pgno key, u8 eType, Pgno parent, int *pRC){
- *pRC = rc;
- return;
- }
-+ if( ((char*)sqlite3PagerGetExtra(pDbPage))[0]!=0 ){
-+ /* The first byte of the extra data is the MemPage.isInit byte.
-+ ** If that byte is set, it means this page is also being used
-+ ** as a btree page. */
-+ *pRC = SQLITE_CORRUPT_BKPT;
-+ goto ptrmap_exit;
-+ }
- offset = PTRMAP_PTROFFSET(iPtrmap, key);
- if( offset<0 ){
- *pRC = SQLITE_CORRUPT_BKPT;
-diff --git a/third_party/sqlite/src/test/fuzzcheck.c b/third_party/sqlite/src/test/fuzzcheck.c
-index 61925fcbe435..7ed17ae8a7d1 100644
---- a/third_party/sqlite/src/test/fuzzcheck.c
-+++ b/third_party/sqlite/src/test/fuzzcheck.c
-@@ -447,7 +447,7 @@ static int inmemRead(
- if( iOfst+iAmt>pVFile->sz ){
- memset(pData, 0, iAmt);
- iAmt = (int)(pVFile->sz - iOfst);
-- memcpy(pData, pVFile->a, iAmt);
-+ memcpy(pData, pVFile->a + iOfst, iAmt);
- return SQLITE_IOERR_SHORT_READ;
- }
- memcpy(pData, pVFile->a + iOfst, iAmt);
---
-2.18.0
-
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
deleted file mode 100644
index a912e8b7b54..00000000000
--- a/chromium/third_party/sqlite/patches/0016-Avoid-a-buffer-overread-in-ptrmapPutOvflPtr.patch
+++ /dev/null
@@ -1,33 +0,0 @@
-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/40] Avoid a buffer overread in ptrmapPutOvflPtr().
-
-This backports https://sqlite.org/src/info/f8b781cf41800e9f
-
-Bug: 914407
----
- third_party/sqlite/src/src/btree.c | 7 ++++++-
- 1 file changed, 6 insertions(+), 1 deletion(-)
-
-diff --git a/third_party/sqlite/src/src/btree.c b/third_party/sqlite/src/src/btree.c
-index 6b17bdee5c4f..14af51e15ab2 100644
---- a/third_party/sqlite/src/src/btree.c
-+++ b/third_party/sqlite/src/src/btree.c
-@@ -1364,7 +1364,12 @@ static void ptrmapPutOvflPtr(MemPage *pPage, u8 *pCell, int *pRC){
- assert( pCell!=0 );
- pPage->xParseCell(pPage, pCell, &info);
- if( info.nLocal<info.nPayload ){
-- Pgno ovfl = get4byte(&pCell[info.nSize-4]);
-+ Pgno ovfl;
-+ if( SQLITE_WITHIN(pPage->aDataEnd, pCell, pCell+info.nLocal) ){
-+ *pRC = SQLITE_CORRUPT_BKPT;
-+ return;
-+ }
-+ ovfl = get4byte(&pCell[info.nSize-4]);
- ptrmapPut(pPage->pBt, ovfl, PTRMAP_OVERFLOW1, pPage->pgno, pRC);
- }
- }
---
-2.18.0
-
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
deleted file mode 100644
index 9417c68acb5..00000000000
--- a/chromium/third_party/sqlite/patches/0017-Improved-detection-of-cell-corruption-in-sqlite3Vdbe.patch
+++ /dev/null
@@ -1,37 +0,0 @@
-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/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 | 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
---- a/third_party/sqlite/src/src/vdbeaux.c
-+++ b/third_party/sqlite/src/src/vdbeaux.c
-@@ -4167,12 +4167,12 @@ int sqlite3VdbeRecordCompareWithSkip(
- }else{
- idx1 = getVarint32(aKey1, szHdr1);
- d1 = szHdr1;
-- if( d1>(unsigned)nKey1 ){
-- pPKey2->errCode = (u8)SQLITE_CORRUPT_BKPT;
-- return 0; /* Corruption */
-- }
- 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
---
-2.18.0
-
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
deleted file mode 100644
index d7272249a80..00000000000
--- a/chromium/third_party/sqlite/patches/0018-Fix-a-segfault-in-fts3-prompted-by-a-corrupted-datab.patch
+++ /dev/null
@@ -1,29 +0,0 @@
-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
deleted file mode 100644
index de615a94fba..00000000000
--- a/chromium/third_party/sqlite/patches/0019-Prevent-integer-overflow-from-leading-to-buffer-over.patch
+++ /dev/null
@@ -1,31 +0,0 @@
-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
deleted file mode 100644
index b4d050318b9..00000000000
--- a/chromium/third_party/sqlite/patches/0020-Add-extra-tests-for-database-corruption-inside-defra.patch
+++ /dev/null
@@ -1,57 +0,0 @@
-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
deleted file mode 100644
index 2ed2dd9b83b..00000000000
--- a/chromium/third_party/sqlite/patches/0021-Fix-an-off-by-one-error-on-a-Goto-in-the-code-genera.patch
+++ /dev/null
@@ -1,29 +0,0 @@
-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
deleted file mode 100644
index 315ba67c5b2..00000000000
--- a/chromium/third_party/sqlite/patches/0022-Fix-overread-on-corrupted-btree-key.patch
+++ /dev/null
@@ -1,37 +0,0 @@
-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
deleted file mode 100644
index ea5da8995e7..00000000000
--- a/chromium/third_party/sqlite/patches/0023-Avoid-buffer-overreads-on-corrupted-database-files.patch
+++ /dev/null
@@ -1,31 +0,0 @@
-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
deleted file mode 100644
index 01912a037e4..00000000000
--- a/chromium/third_party/sqlite/patches/0024-Fix-integer-overflow-while-running-PRAGMA-integrity_.patch
+++ /dev/null
@@ -1,38 +0,0 @@
-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
deleted file mode 100644
index d8e9a64a4da..00000000000
--- a/chromium/third_party/sqlite/patches/0025-Improved-corruption-handling-while-balancing-pages.patch
+++ /dev/null
@@ -1,120 +0,0 @@
-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
deleted file mode 100644
index 3cbd94d874b..00000000000
--- a/chromium/third_party/sqlite/patches/0026-Avoid-reading-off-the-front-of-a-page-buffer-when-ba.patch
+++ /dev/null
@@ -1,38 +0,0 @@
-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
deleted file mode 100644
index f3eecc7aaaa..00000000000
--- a/chromium/third_party/sqlite/patches/0027-Fix-MSAN-error-in-sqlite3VdbeRecordUnpack-on-a-corru.patch
+++ /dev/null
@@ -1,34 +0,0 @@
-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
deleted file mode 100644
index a5de315c0df..00000000000
--- a/chromium/third_party/sqlite/patches/0028-Fix-deleting-a-B-tree-entry-in-a-corrupt-database.patch
+++ /dev/null
@@ -1,27 +0,0 @@
-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
deleted file mode 100644
index 34eb6b470e9..00000000000
--- a/chromium/third_party/sqlite/patches/0029-Fix-sorting-results-with-SRT_EphemTab-and-a-LIMIT-cl.patch
+++ /dev/null
@@ -1,42 +0,0 @@
-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
deleted file mode 100644
index e2529c39fe6..00000000000
--- a/chromium/third_party/sqlite/patches/0030-Fix-detection-of-orphaned-and-malformed-autoindexes.patch
+++ /dev/null
@@ -1,40 +0,0 @@
-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
deleted file mode 100644
index c933c09eb1d..00000000000
--- a/chromium/third_party/sqlite/patches/0031-Fix-potential-buffer-overread.patch
+++ /dev/null
@@ -1,41 +0,0 @@
-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
deleted file mode 100644
index 7111acbfd28..00000000000
--- a/chromium/third_party/sqlite/patches/0032-Fix-handling-negative-number-of-pages-database-field.patch
+++ /dev/null
@@ -1,69 +0,0 @@
-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
deleted file mode 100644
index 77dbd02f020..00000000000
--- a/chromium/third_party/sqlite/patches/0033-Fix-corner-case-in-inserting-null-into-integer-prima.patch
+++ /dev/null
@@ -1,42 +0,0 @@
-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
deleted file mode 100644
index 8ff6e693947..00000000000
--- a/chromium/third_party/sqlite/patches/0034-Fix-insert-infinite-recursion-on-some-corrupted-data.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-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
deleted file mode 100644
index 8afbbd97b30..00000000000
--- a/chromium/third_party/sqlite/patches/0035-Fix-null-pointer-dereference-in-sqlite3ExprCompare.patch
+++ /dev/null
@@ -1,32 +0,0 @@
-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
deleted file mode 100644
index 9d1bedac82d..00000000000
--- a/chromium/third_party/sqlite/patches/0036-Fix-NEVER-that-is-sometimes-true.patch
+++ /dev/null
@@ -1,29 +0,0 @@
-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
deleted file mode 100644
index a281eb69f02..00000000000
--- a/chromium/third_party/sqlite/patches/0037-Initialize-extra-bytes-allocated-for-saved-cursor-po.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-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
deleted file mode 100644
index 4cf0bbb27a3..00000000000
--- a/chromium/third_party/sqlite/patches/0038-Fix-leaks-caused-by-circular-references-in-vtable-sh.patch
+++ /dev/null
@@ -1,246 +0,0 @@
-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
deleted file mode 100644
index 83d67645830..00000000000
--- a/chromium/third_party/sqlite/patches/0039-Fix-overly-large-malloc-on-btree-corruption.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-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
deleted file mode 100644
index 873861030df..00000000000
--- a/chromium/third_party/sqlite/patches/0040-Fix-null-pointer-access-on-corrupted-index-key.patch
+++ /dev/null
@@ -1,44 +0,0 @@
-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/src/Makefile.in b/chromium/third_party/sqlite/src/Makefile.in
index 3b05f1e25ca..65530e33c53 100644
--- a/chromium/third_party/sqlite/src/Makefile.in
+++ b/chromium/third_party/sqlite/src/Makefile.in
@@ -452,6 +452,7 @@ TESTSRC += \
$(TOP)/ext/misc/nextchar.c \
$(TOP)/ext/misc/normalize.c \
$(TOP)/ext/misc/percentile.c \
+ $(TOP)/ext/misc/prefixes.c \
$(TOP)/ext/misc/regexp.c \
$(TOP)/ext/misc/remember.c \
$(TOP)/ext/misc/series.c \
@@ -588,7 +589,8 @@ FUZZDATA = \
$(TOP)/test/fuzzdata4.db \
$(TOP)/test/fuzzdata5.db \
$(TOP)/test/fuzzdata6.db \
- $(TOP)/test/fuzzdata7.db
+ $(TOP)/test/fuzzdata7.db \
+ $(TOP)/test/fuzzdata8.db
# Standard options to testfixture
#
@@ -611,6 +613,12 @@ FUZZERSHELL_OPT = -DSQLITE_ENABLE_JSON1
FUZZCHECK_OPT = -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_MEMSYS5 -DSQLITE_OSS_FUZZ
FUZZCHECK_OPT += -DSQLITE_MAX_MEMORY=50000000
FUZZCHECK_OPT += -DSQLITE_PRINTF_PRECISION_LIMIT=1000
+FUZZCHECK_OPT += -DSQLITE_ENABLE_DESERIALIZE
+FUZZCHECK_OPT += -DSQLITE_ENABLE_FTS4
+#FUZZCHECK_OPT += -DSQLITE_ENABLE_FTS5
+FUZZCHECK_OPT += -DSQLITE_ENABLE_RTREE
+FUZZCHECK_OPT += -DSQLITE_ENABLE_GEOPOLY
+FUZZCHECK_OPT += -DSQLITE_ENABLE_DBSTAT_VTAB
FUZZCHECK_SRC = $(TOP)/test/fuzzcheck.c $(TOP)/test/ossfuzz.c
DBFUZZ_OPT =
@@ -682,11 +690,26 @@ DBFUZZ2_OPTS = \
-DSQLITE_ENABLE_DBSTAT_VTAB \
-DSQLITE_ENABLE_RTREE \
-DSQLITE_ENABLE_FTS4 \
- -DSQLITE_EANBLE_FTS5
+ -DSQLITE_ENABLE_FTS5
-dbfuzz2: $(TOP)/test/dbfuzz2.c sqlite3.c sqlite3.h
- clang-6.0 -I. -g -O0 -fsanitize=fuzzer,undefined,address -o dbfuzz2 \
- $(DBFUZZ2_OPTS) $(TOP)/test/dbfuzz2.c sqlite3.c
+dbfuzz2$(TEXE): $(TOP)/test/dbfuzz2.c sqlite3.c sqlite3.h
+ $(CC) $(OPT_FEATURE_FLAGS) $(OPTS) -I. -g -O0 \
+ -DSTANDALONE -o dbfuzz2 \
+ $(DBFUZZ2_OPTS) $(TOP)/test/dbfuzz2.c sqlite3.c $(TLIBS)
+ mkdir -p dbfuzz2-dir
+ cp $(TOP)/test/dbfuzz2-seed* dbfuzz2-dir
+
+dbfuzz2-asan: $(TOP)/test/dbfuzz2.c sqlite3.c sqlite3.h
+ clang-6.0 $(OPT_FEATURE_FLAGS) $(OPTS) -I. -g -O0 \
+ -fsanitize=fuzzer,undefined,address -o dbfuzz2-asan \
+ $(DBFUZZ2_OPTS) $(TOP)/test/dbfuzz2.c sqlite3.c $(TLIBS)
+ mkdir -p dbfuzz2-dir
+ cp $(TOP)/test/dbfuzz2-seed* dbfuzz2-dir
+
+dbfuzz2-msan: $(TOP)/test/dbfuzz2.c sqlite3.c sqlite3.h
+ clang-6.0 $(OPT_FEATURE_FLAGS) $(OPTS) -I. -g -O0 \
+ -fsanitize=fuzzer,undefined,memory -o dbfuzz2-msan \
+ $(DBFUZZ2_OPTS) $(TOP)/test/dbfuzz2.c sqlite3.c $(TLIBS)
mkdir -p dbfuzz2-dir
cp $(TOP)/test/dbfuzz2-seed* dbfuzz2-dir
@@ -1052,6 +1075,7 @@ SHELL_SRC = \
$(TOP)/ext/expert/sqlite3expert.c \
$(TOP)/ext/expert/sqlite3expert.h \
$(TOP)/ext/misc/zipfile.c \
+ $(TOP)/ext/misc/memtrace.c \
$(TOP)/src/test_windirent.c
shell.c: $(SHELL_SRC) $(TOP)/tool/mkshellc.tcl
@@ -1189,6 +1213,7 @@ TESTFIXTURE_FLAGS += -DSQLITE_SERIES_CONSTRAINT_VERIFY=1
TESTFIXTURE_FLAGS += -DSQLITE_DEFAULT_PAGE_SIZE=1024
TESTFIXTURE_FLAGS += -DSQLITE_ENABLE_STMTVTAB
TESTFIXTURE_FLAGS += -DSQLITE_ENABLE_DBPAGE_VTAB
+TESTFIXTURE_FLAGS += -DSQLITE_ENABLE_DESERIALIZE
TESTFIXTURE_SRC0 = $(TESTSRC2) libsqlite3.la
TESTFIXTURE_SRC1 = sqlite3.c
@@ -1291,6 +1316,9 @@ dbdump$(TEXE): $(TOP)/ext/misc/dbdump.c sqlite3.lo
$(LTLINK) -DDBDUMP_STANDALONE -o $@ \
$(TOP)/ext/misc/dbdump.c sqlite3.lo $(TLIBS)
+dbtotxt$(TEXE): $(TOP)/tool/dbtotxt.c
+ $(LTLINK)-o $@ $(TOP)/tool/dbtotxt.c
+
showdb$(TEXE): $(TOP)/tool/showdb.c sqlite3.lo
$(LTLINK) -o $@ $(TOP)/tool/showdb.c sqlite3.lo $(TLIBS)
@@ -1306,6 +1334,9 @@ showwal$(TEXE): $(TOP)/tool/showwal.c sqlite3.lo
showshm$(TEXE): $(TOP)/tool/showshm.c
$(LTLINK) -o $@ $(TOP)/tool/showshm.c
+index_usage$(TEXE): $(TOP)/tool/index_usage.c sqlite3.lo
+ $(LTLINK) $(SHELL_OPT) -o $@ $(TOP)/tool/index_usage.c sqlite3.lo $(TLIBS)
+
changeset$(TEXE): $(TOP)/ext/session/changeset.c sqlite3.lo
$(LTLINK) -o $@ $(TOP)/ext/session/changeset.c sqlite3.lo $(TLIBS)
diff --git a/chromium/third_party/sqlite/src/Makefile.msc b/chromium/third_party/sqlite/src/Makefile.msc
index e3feffab357..b4fa372f9a9 100644
--- a/chromium/third_party/sqlite/src/Makefile.msc
+++ b/chromium/third_party/sqlite/src/Makefile.msc
@@ -1527,6 +1527,7 @@ TESTEXT = \
$(TOP)\ext\misc\nextchar.c \
$(TOP)\ext\misc\normalize.c \
$(TOP)\ext\misc\percentile.c \
+ $(TOP)\ext\misc\prefixes.c \
$(TOP)\ext\misc\regexp.c \
$(TOP)\ext\misc\remember.c \
$(TOP)\ext\misc\series.c \
@@ -1625,7 +1626,8 @@ FUZZDATA = \
$(TOP)\test\fuzzdata4.db \
$(TOP)\test\fuzzdata5.db \
$(TOP)\test\fuzzdata6.db \
- $(TOP)\test\fuzzdata7.db
+ $(TOP)\test\fuzzdata7.db \
+ $(TOP)\test\fuzzdata8.db
# <</mark>>
# Additional compiler options for the shell. These are only effective
@@ -1643,7 +1645,13 @@ SHELL_COMPILE_OPTS = $(SHELL_COMPILE_OPTS) -DSQLITE_ENABLE_DESERIALIZE=1
#
MPTESTER_COMPILE_OPTS = -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_FTS5
FUZZERSHELL_COMPILE_OPTS = -DSQLITE_ENABLE_JSON1
-FUZZCHECK_COMPILE_OPTS = -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_MEMSYS5 -DSQLITE_OSS_FUZZ -DSQLITE_MAX_MEMORY=50000000 -DSQLITE_PRINTF_PRECISION_LIMIT=1000
+FUZZCHECK_OPTS = -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_MEMSYS5 -DSQLITE_OSS_FUZZ -DSQLITE_MAX_MEMORY=50000000 -DSQLITE_PRINTF_PRECISION_LIMIT=1000
+FUZZCHECK_OPTS = $(FUZZCHECK_OPTS) -DSQLITE_ENABLE_DESERIALIZE
+FUZZCHECK_OPTS = $(FUZZCHECK_OPTS) -DSQLITE_ENABLE_FTS4
+FUZZCHECK_OPTS = $(FUZZCHECK_OPTS) -DSQLITE_ENABLE_RTREE
+FUZZCHECK_OPTS = $(FUZZCHECK_OPTS) -DSQLITE_ENABLE_GEOPOLY
+FUZZCHECK_OPTS = $(FUZZCHECK_OPTS) -DSQLITE_ENABLE_DBSTAT_VTAB
+
FUZZCHECK_SRC = $(TOP)\test\fuzzcheck.c $(TOP)\test\ossfuzz.c
OSSSHELL_SRC = $(TOP)\test\ossshell.c $(TOP)\test\ossfuzz.c
DBFUZZ_COMPILE_OPTS = -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION
@@ -1730,10 +1738,10 @@ dbfuzz.exe: $(TOP)\test\dbfuzz.c $(SQLITE3C) $(SQLITE3H)
$(LTLINK) $(NO_WARN) $(DBFUZZ_COMPILE_OPTS) $(TOP)\test\dbfuzz.c $(SQLITE3C) /link $(LDFLAGS) $(LTLINKOPTS)
fuzzcheck.exe: $(FUZZCHECK_SRC) $(SQLITE3C) $(SQLITE3H)
- $(LTLINK) $(NO_WARN) $(FUZZCHECK_COMPILE_OPTS) $(FUZZCHECK_SRC) $(SQLITE3C) /link $(LDFLAGS) $(LTLINKOPTS)
+ $(LTLINK) $(NO_WARN) $(FUZZCHECK_OPTS) $(FUZZCHECK_SRC) $(SQLITE3C) /link $(LDFLAGS) $(LTLINKOPTS)
ossshell.exe: $(OSSSHELL_SRC) $(SQLITE3C) $(SQLITE3H)
- $(LTLINK) $(NO_WARN) $(FUZZCHECK_COMPILE_OPTS) $(OSSSHELL_SRC) $(SQLITE3C) /link $(LDFLAGS) $(LTLINKOPTS)
+ $(LTLINK) $(NO_WARN) $(FUZZCHECK_OPTS) $(OSSSHELL_SRC) $(SQLITE3C) /link $(LDFLAGS) $(LTLINKOPTS)
sessionfuzz.exe: zlib $(TOP)\test\sessionfuzz.c $(SQLITE3C) $(SQLITE3H)
$(LTLINK) $(NO_WARN) -I$(ZLIBINCDIR) $(TOP)\test\sessionfuzz.c /link $(LDFLAGS) $(LTLINKOPTS) /LIBPATH:$(ZLIBLIBDIR) $(ZLIBLIB)
@@ -2130,6 +2138,7 @@ SHELL_SRC = \
$(TOP)\ext\misc\completion.c \
$(TOP)\ext\expert\sqlite3expert.c \
$(TOP)\ext\expert\sqlite3expert.h \
+ $(TOP)\ext\misc\memtrace.c \
$(TOP)\src\test_windirent.c
# If use of zlib is enabled, add the "zipfile.c" source file.
@@ -2298,6 +2307,7 @@ TESTFIXTURE_FLAGS = $(TESTFIXTURE_FLAGS) -DSQLITE_DEFAULT_PAGE_SIZE=1024
TESTFIXTURE_FLAGS = $(TESTFIXTURE_FLAGS) -DSQLITE_ENABLE_STMTVTAB=1
TESTFIXTURE_FLAGS = $(TESTFIXTURE_FLAGS) -DSQLITE_ENABLE_DBPAGE_VTAB=1
TESTFIXTURE_FLAGS = $(TESTFIXTURE_FLAGS) -DSQLITE_ENABLE_JSON1=1
+TESTFIXTURE_FLAGS = $(TESTFIXTURE_FLAGS) -DSQLITE_ENABLE_DESERIALIZE=1
TESTFIXTURE_FLAGS = $(TESTFIXTURE_FLAGS) $(TEST_CCONV_OPTS)
TESTFIXTURE_SRC0 = $(TESTEXT) $(TESTSRC2)
@@ -2425,6 +2435,9 @@ testloadext.lo: $(TOP)\src\test_loadext.c $(SQLITE3H)
testloadext.dll: testloadext.lo
$(LD) $(LDFLAGS) $(LTLINKOPTS) $(LTLIBPATHS) /DLL /OUT:$@ testloadext.lo
+dbtotxt.exe: $(TOP)\tool\dbtotxt.c
+ $(LTLINK) $(NO_WARN) $(TOP)\tool\dbtotxt.c /link $(LDFLAGS) $(LTLINKOPTS)
+
showdb.exe: $(TOP)\tool\showdb.c $(SQLITE3C) $(SQLITE3H)
$(LTLINK) $(NO_WARN) -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION \
$(TOP)\tool\showdb.c $(SQLITE3C) /link $(LDFLAGS) $(LTLINKOPTS)
@@ -2444,6 +2457,10 @@ showwal.exe: $(TOP)\tool\showwal.c $(SQLITE3C) $(SQLITE3H)
showshm.exe: $(TOP)\tool\showshm.c
$(LTLINK) $(NO_WARN) $(TOP)\tool\showshm.c /link $(LDFLAGS) $(LTLINKOPTS)
+index_usage.exe: $(TOP)\tool\index_usage.c $(SQLITE3C) $(SQLITE3H)
+ $(LTLINK) $(NO_WARN) -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION \
+ $(TOP)\tool\index_usage.c $(SQLITE3C) /link $(LDFLAGS) $(LTLINKOPTS)
+
changeset.exe: $(TOP)\ext\session\changeset.c $(SQLITE3C) $(SQLITE3H)
$(LTLINK) $(NO_WARN) -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION \
-DSQLITE_ENABLE_SESSION=1 -DSQLITE_ENABLE_PREUPDATE_HOOK=1 \
diff --git a/chromium/third_party/sqlite/src/VERSION b/chromium/third_party/sqlite/src/VERSION
index 419ede3b9cb..c521c77d0c0 100644
--- a/chromium/third_party/sqlite/src/VERSION
+++ b/chromium/third_party/sqlite/src/VERSION
@@ -1 +1 @@
-3.26.0
+3.27.1
diff --git a/chromium/third_party/sqlite/src/autoconf/Makefile.msc b/chromium/third_party/sqlite/src/autoconf/Makefile.msc
index 270c83c2308..a131d4c6e73 100644
--- a/chromium/third_party/sqlite/src/autoconf/Makefile.msc
+++ b/chromium/third_party/sqlite/src/autoconf/Makefile.msc
@@ -283,6 +283,7 @@ OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_STMTVTAB=1
OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_DBPAGE_VTAB=1
OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_DBSTAT_VTAB=1
OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_INTROSPECTION_PRAGMAS=1
+OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_DESERIALIZE=1
!ENDIF
OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_COLUMN_METADATA=1
!ENDIF
@@ -937,6 +938,7 @@ LIBRESOBJS =
SHELL_COMPILE_OPTS = $(SHELL_COMPILE_OPTS) -DSQLITE_ENABLE_FTS4=1
SHELL_COMPILE_OPTS = $(SHELL_COMPILE_OPTS) -DSQLITE_ENABLE_EXPLAIN_COMMENTS=1
SHELL_COMPILE_OPTS = $(SHELL_COMPILE_OPTS) -DSQLITE_ENABLE_OFFSET_SQL_FUNC=1
+SHELL_COMPILE_OPTS = $(SHELL_COMPILE_OPTS) -DSQLITE_ENABLE_DESERIALIZE=1
!ENDIF
diff --git a/chromium/third_party/sqlite/src/configure b/chromium/third_party/sqlite/src/configure
index 51653aa5994..bb8daa5a6ab 100755
--- a/chromium/third_party/sqlite/src/configure
+++ b/chromium/third_party/sqlite/src/configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for sqlite 3.26.0.
+# Generated by GNU Autoconf 2.69 for sqlite 3.27.1.
#
#
# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
@@ -726,8 +726,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='sqlite'
PACKAGE_TARNAME='sqlite'
-PACKAGE_VERSION='3.26.0'
-PACKAGE_STRING='sqlite 3.26.0'
+PACKAGE_VERSION='3.27.1'
+PACKAGE_STRING='sqlite 3.27.1'
PACKAGE_BUGREPORT=''
PACKAGE_URL=''
@@ -1466,7 +1466,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures sqlite 3.26.0 to adapt to many kinds of systems.
+\`configure' configures sqlite 3.27.1 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1531,7 +1531,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of sqlite 3.26.0:";;
+ short | recursive ) echo "Configuration of sqlite 3.27.1:";;
esac
cat <<\_ACEOF
@@ -1657,7 +1657,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-sqlite configure 3.26.0
+sqlite configure 3.27.1
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
@@ -2076,7 +2076,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by sqlite $as_me 3.26.0, which was
+It was created by sqlite $as_me 3.27.1, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
@@ -12232,7 +12232,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by sqlite $as_me 3.26.0, which was
+This file was extended by sqlite $as_me 3.27.1, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -12298,7 +12298,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
-sqlite config.status 3.26.0
+sqlite config.status 3.27.1
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
diff --git a/chromium/third_party/sqlite/src/ext/expert/expert1.test b/chromium/third_party/sqlite/src/ext/expert/expert1.test
index 0ced8828289..356b828f6e5 100644
--- a/chromium/third_party/sqlite/src/ext/expert/expert1.test
+++ b/chromium/third_party/sqlite/src/ext/expert/expert1.test
@@ -243,8 +243,10 @@ do_setup_rec_test $tn.12.1 {
CREATE INDEX t7_idx_00000062 ON t7(b);
CREATE INDEX t7_idx_00000061 ON t7(a);
MULTI-INDEX OR
- SEARCH TABLE t7 USING INDEX t7_idx_00000061 (a=?)
- SEARCH TABLE t7 USING INDEX t7_idx_00000062 (b=?)
+ INDEX 1
+ SEARCH TABLE t7 USING INDEX t7_idx_00000061 (a=?)
+ INDEX 2
+ SEARCH TABLE t7 USING INDEX t7_idx_00000062 (b=?)
}
# rowid terms.
diff --git a/chromium/third_party/sqlite/src/ext/fts3/fts3.c b/chromium/third_party/sqlite/src/ext/fts3/fts3.c
index 005d8e50212..c371d3e8f0b 100644
--- a/chromium/third_party/sqlite/src/ext/fts3/fts3.c
+++ b/chromium/third_party/sqlite/src/ext/fts3/fts3.c
@@ -322,6 +322,14 @@ int sqlite3Fts3Never(int b) { assert( !b ); return b; }
#endif
/*
+** This variable is set to false when running tests for which the on disk
+** structures should not be corrupt. Otherwise, true. If it is false, extra
+** assert() conditions in the fts3 code are activated - conditions that are
+** only true if it is guaranteed that the fts3 database is not corrupt.
+*/
+int sqlite3_fts3_may_be_corrupt = 1;
+
+/*
** Write a 64-bit variable-length integer to memory starting at p[0].
** The length of data written will be between 1 and FTS3_VARINT_MAX bytes.
** The number of bytes written is returned.
@@ -339,7 +347,7 @@ int sqlite3Fts3PutVarint(char *p, sqlite_int64 v){
}
#define GETVARINT_STEP(v, ptr, shift, mask1, mask2, var, ret) \
- v = (v & mask1) | ( (*ptr++) << shift ); \
+ v = (v & mask1) | ( (*(const unsigned char*)(ptr++)) << shift ); \
if( (v & mask2)==0 ){ var = v; return ret; }
#define GETVARINT_INIT(v, ptr, shift, mask1, mask2, var, ret) \
v = (*ptr++); \
@@ -377,20 +385,21 @@ int sqlite3Fts3GetVarint(const char *pBuf, sqlite_int64 *v){
** a non-negative 32-bit integer before it is returned.
*/
int sqlite3Fts3GetVarint32(const char *p, int *pi){
+ const unsigned char *ptr = (const unsigned char*)p;
u32 a;
#ifndef fts3GetVarint32
- GETVARINT_INIT(a, p, 0, 0x00, 0x80, *pi, 1);
+ GETVARINT_INIT(a, ptr, 0, 0x00, 0x80, *pi, 1);
#else
- a = (*p++);
+ a = (*ptr++);
assert( a & 0x80 );
#endif
- GETVARINT_STEP(a, p, 7, 0x7F, 0x4000, *pi, 2);
- GETVARINT_STEP(a, p, 14, 0x3FFF, 0x200000, *pi, 3);
- GETVARINT_STEP(a, p, 21, 0x1FFFFF, 0x10000000, *pi, 4);
+ GETVARINT_STEP(a, ptr, 7, 0x7F, 0x4000, *pi, 2);
+ GETVARINT_STEP(a, ptr, 14, 0x3FFF, 0x200000, *pi, 3);
+ GETVARINT_STEP(a, ptr, 21, 0x1FFFFF, 0x10000000, *pi, 4);
a = (a & 0x0FFFFFFF );
- *pi = (int)(a | ((u32)(*p & 0x07) << 28));
+ *pi = (int)(a | ((u32)(*ptr & 0x07) << 28));
assert( 0==(a & 0x80000000) );
assert( *pi>=0 );
return 5;
@@ -561,13 +570,18 @@ static int fts3DestroyMethod(sqlite3_vtab *pVtab){
sqlite3 *db = p->db; /* Database handle */
/* Drop the shadow tables */
- if( p->zContentTbl==0 ){
- fts3DbExec(&rc, db, "DROP TABLE IF EXISTS %Q.'%q_content'", zDb, p->zName);
- }
- fts3DbExec(&rc, db, "DROP TABLE IF EXISTS %Q.'%q_segments'", zDb,p->zName);
- fts3DbExec(&rc, db, "DROP TABLE IF EXISTS %Q.'%q_segdir'", zDb, p->zName);
- fts3DbExec(&rc, db, "DROP TABLE IF EXISTS %Q.'%q_docsize'", zDb, p->zName);
- fts3DbExec(&rc, db, "DROP TABLE IF EXISTS %Q.'%q_stat'", zDb, p->zName);
+ fts3DbExec(&rc, db,
+ "DROP TABLE IF EXISTS %Q.'%q_segments';"
+ "DROP TABLE IF EXISTS %Q.'%q_segdir';"
+ "DROP TABLE IF EXISTS %Q.'%q_docsize';"
+ "DROP TABLE IF EXISTS %Q.'%q_stat';"
+ "%s DROP TABLE IF EXISTS %Q.'%q_content';",
+ zDb, p->zName,
+ zDb, p->zName,
+ zDb, p->zName,
+ zDb, p->zName,
+ (p->zContentTbl ? "--" : ""), zDb,p->zName
+ );
/* If everything has worked, invoke fts3DisconnectMethod() to free the
** memory associated with the Fts3Table structure and return SQLITE_OK.
@@ -799,10 +813,10 @@ static void fts3Appendf(
** memory.
*/
static char *fts3QuoteId(char const *zInput){
- int nRet;
+ sqlite3_int64 nRet;
char *zRet;
nRet = 2 + (int)strlen(zInput)*2 + 1;
- zRet = sqlite3_malloc(nRet);
+ zRet = sqlite3_malloc64(nRet);
if( zRet ){
int i;
char *z = zRet;
@@ -983,7 +997,7 @@ static int fts3PrefixParameter(
}
}
- aIndex = sqlite3_malloc(sizeof(struct Fts3Index) * nIndex);
+ aIndex = sqlite3_malloc64(sizeof(struct Fts3Index) * nIndex);
*apIndex = aIndex;
if( !aIndex ){
return SQLITE_NOMEM;
@@ -1062,7 +1076,7 @@ static int fts3ContentColumns(
if( rc==SQLITE_OK ){
const char **azCol; /* Output array */
- int nStr = 0; /* Size of all column names (incl. 0x00) */
+ sqlite3_int64 nStr = 0; /* Size of all column names (incl. 0x00) */
int nCol; /* Number of table columns */
int i; /* Used to iterate through columns */
@@ -1072,11 +1086,11 @@ static int fts3ContentColumns(
nCol = sqlite3_column_count(pStmt);
for(i=0; i<nCol; i++){
const char *zCol = sqlite3_column_name(pStmt, i);
- nStr += (int)strlen(zCol) + 1;
+ nStr += strlen(zCol) + 1;
}
/* Allocate and populate the array to return. */
- azCol = (const char **)sqlite3_malloc(sizeof(char *) * nCol + nStr);
+ azCol = (const char **)sqlite3_malloc64(sizeof(char *) * nCol + nStr);
if( azCol==0 ){
rc = SQLITE_NOMEM;
}else{
@@ -1124,7 +1138,7 @@ static int fts3InitVtab(
Fts3Table *p = 0; /* Pointer to allocated vtab */
int rc = SQLITE_OK; /* Return code */
int i; /* Iterator variable */
- int nByte; /* Size of allocation used for *p */
+ sqlite3_int64 nByte; /* Size of allocation used for *p */
int iCol; /* Column index */
int nString = 0; /* Bytes required to hold all column names */
int nCol = 0; /* Number of columns in the FTS table */
@@ -1158,10 +1172,10 @@ static int fts3InitVtab(
nName = (int)strlen(argv[2]) + 1;
nByte = sizeof(const char *) * (argc-2);
- aCol = (const char **)sqlite3_malloc(nByte);
+ aCol = (const char **)sqlite3_malloc64(nByte);
if( aCol ){
memset((void*)aCol, 0, nByte);
- azNotindexed = (char **)sqlite3_malloc(nByte);
+ azNotindexed = (char **)sqlite3_malloc64(nByte);
}
if( azNotindexed ){
memset(azNotindexed, 0, nByte);
@@ -1356,7 +1370,7 @@ static int fts3InitVtab(
nName + /* zName */
nDb + /* zDb */
nString; /* Space for azColumn strings */
- p = (Fts3Table*)sqlite3_malloc(nByte);
+ p = (Fts3Table*)sqlite3_malloc64(nByte);
if( p==0 ){
rc = SQLITE_NOMEM;
goto fts3_init_out;
@@ -2135,7 +2149,7 @@ static int fts3PutColNumber(char **pp, int iCol){
** updated appropriately. The caller is responsible for insuring
** that there is enough space in *pp to hold the complete output.
*/
-static void fts3PoslistMerge(
+static int fts3PoslistMerge(
char **pp, /* Output buffer */
char **pp1, /* Left input list */
char **pp2 /* Right input list */
@@ -2148,11 +2162,17 @@ static void fts3PoslistMerge(
int iCol1; /* The current column index in pp1 */
int iCol2; /* The current column index in pp2 */
- if( *p1==POS_COLUMN ) fts3GetVarint32(&p1[1], &iCol1);
+ if( *p1==POS_COLUMN ){
+ fts3GetVarint32(&p1[1], &iCol1);
+ if( iCol1==0 ) return FTS_CORRUPT_VTAB;
+ }
else if( *p1==POS_END ) iCol1 = POSITION_LIST_END;
else iCol1 = 0;
- if( *p2==POS_COLUMN ) fts3GetVarint32(&p2[1], &iCol2);
+ if( *p2==POS_COLUMN ){
+ fts3GetVarint32(&p2[1], &iCol2);
+ if( iCol2==0 ) return FTS_CORRUPT_VTAB;
+ }
else if( *p2==POS_END ) iCol2 = POSITION_LIST_END;
else iCol2 = 0;
@@ -2200,6 +2220,7 @@ static void fts3PoslistMerge(
*pp = p;
*pp1 = p1 + 1;
*pp2 = p2 + 1;
+ return SQLITE_OK;
}
/*
@@ -2264,10 +2285,9 @@ static int fts3PoslistPhraseMerge(
p += sqlite3Fts3PutVarint(p, iCol1);
}
- assert( *p1!=POS_END && *p1!=POS_COLUMN );
- assert( *p2!=POS_END && *p2!=POS_COLUMN );
fts3GetDeltaVarint(&p1, &iPos1); iPos1 -= 2;
fts3GetDeltaVarint(&p2, &iPos2); iPos2 -= 2;
+ if( iPos1<0 || iPos2<0 ) break;
while( 1 ){
if( iPos2==iPos1+nToken
@@ -2493,6 +2513,7 @@ static int fts3DoclistOrMerge(
char *a2, int n2, /* Second doclist */
char **paOut, int *pnOut /* OUT: Malloc'd doclist */
){
+ int rc = SQLITE_OK;
sqlite3_int64 i1 = 0;
sqlite3_int64 i2 = 0;
sqlite3_int64 iPrev = 0;
@@ -2536,7 +2557,7 @@ static int fts3DoclistOrMerge(
** A symetric argument may be made if the doclists are in descending
** order.
*/
- aOut = sqlite3_malloc(n1+n2+FTS3_VARINT_MAX-1);
+ aOut = sqlite3_malloc64((i64)n1+n2+FTS3_VARINT_MAX-1+FTS3_BUFFER_PADDING);
if( !aOut ) return SQLITE_NOMEM;
p = aOut;
@@ -2547,7 +2568,8 @@ static int fts3DoclistOrMerge(
if( p2 && p1 && iDiff==0 ){
fts3PutDeltaVarint3(&p, bDescDoclist, &iPrev, &bFirstOut, i1);
- fts3PoslistMerge(&p, &p1, &p2);
+ rc = fts3PoslistMerge(&p, &p1, &p2);
+ if( rc ) break;
fts3GetDeltaVarint3(&p1, pEnd1, bDescDoclist, &i1);
fts3GetDeltaVarint3(&p2, pEnd2, bDescDoclist, &i2);
}else if( !p2 || (p1 && iDiff<0) ){
@@ -2561,10 +2583,16 @@ static int fts3DoclistOrMerge(
}
}
+ if( rc!=SQLITE_OK ){
+ sqlite3_free(aOut);
+ p = aOut = 0;
+ }else{
+ assert( (p-aOut)<=n1+n2+FTS3_VARINT_MAX-1 );
+ memset(&aOut[(p-aOut)], 0, FTS3_BUFFER_PADDING);
+ }
*paOut = aOut;
*pnOut = (int)(p-aOut);
- assert( *pnOut<=n1+n2+FTS3_VARINT_MAX-1 );
- return SQLITE_OK;
+ return rc;
}
/*
@@ -2599,7 +2627,7 @@ static int fts3DoclistPhraseMerge(
assert( nDist>0 );
if( bDescDoclist ){
- aOut = sqlite3_malloc(*pnRight + FTS3_VARINT_MAX);
+ aOut = sqlite3_malloc64((sqlite3_int64)*pnRight + FTS3_VARINT_MAX);
if( aOut==0 ) return SQLITE_NOMEM;
}else{
aOut = aRight;
@@ -2783,6 +2811,7 @@ static int fts3TermSelectMerge(
pTS->anOutput[0] = nDoclist;
if( pTS->aaOutput[0] ){
memcpy(pTS->aaOutput[0], aDoclist, nDoclist);
+ memset(&pTS->aaOutput[0][nDoclist], 0, FTS3_VARINT_MAX);
}else{
return SQLITE_NOMEM;
}
@@ -2834,8 +2863,8 @@ static int fts3SegReaderCursorAppend(
){
if( (pCsr->nSegment%16)==0 ){
Fts3SegReader **apNew;
- int nByte = (pCsr->nSegment + 16)*sizeof(Fts3SegReader*);
- apNew = (Fts3SegReader **)sqlite3_realloc(pCsr->apSegment, nByte);
+ sqlite3_int64 nByte = (pCsr->nSegment + 16)*sizeof(Fts3SegReader*);
+ apNew = (Fts3SegReader **)sqlite3_realloc64(pCsr->apSegment, nByte);
if( !apNew ){
sqlite3Fts3SegReaderFree(pNew);
return SQLITE_NOMEM;
@@ -3841,7 +3870,6 @@ static int fts3RollbackToMethod(sqlite3_vtab *pVtab, int iSavepoint){
Fts3Table *p = (Fts3Table*)pVtab;
UNUSED_PARAMETER(iSavepoint);
assert( p->inTransaction );
- assert( p->mxSavepoint >= iSavepoint );
TESTONLY( p->mxSavepoint = iSavepoint );
sqlite3Fts3PendingTermsClear(p);
return SQLITE_OK;
@@ -4624,9 +4652,10 @@ static int fts3EvalIncrPhraseNext(
if( bEof==0 ){
int nList = 0;
int nByte = a[p->nToken-1].nList;
- char *aDoclist = sqlite3_malloc(nByte+1);
+ char *aDoclist = sqlite3_malloc(nByte+FTS3_BUFFER_PADDING);
if( !aDoclist ) return SQLITE_NOMEM;
memcpy(aDoclist, a[p->nToken-1].pList, nByte+1);
+ memset(&aDoclist[nByte], 0, FTS3_BUFFER_PADDING);
for(i=0; i<(p->nToken-1); i++){
if( a[i].bIgnore==0 ){
@@ -5017,7 +5046,7 @@ static int fts3EvalStart(Fts3Cursor *pCsr){
if( rc==SQLITE_OK && nToken>1 && pTab->bFts4 ){
Fts3TokenAndCost *aTC;
Fts3Expr **apOr;
- aTC = (Fts3TokenAndCost *)sqlite3_malloc(
+ aTC = (Fts3TokenAndCost *)sqlite3_malloc64(
sizeof(Fts3TokenAndCost) * nToken
+ sizeof(Fts3Expr *) * nOr * 2
);
@@ -5328,7 +5357,7 @@ static int fts3EvalNearTest(Fts3Expr *pExpr, int *pRc){
&& (pExpr->pParent==0 || pExpr->pParent->eType!=FTSQUERY_NEAR)
){
Fts3Expr *p;
- int nTmp = 0; /* Bytes of temp space */
+ sqlite3_int64 nTmp = 0; /* Bytes of temp space */
char *aTmp; /* Temp space for PoslistNearMerge() */
/* Allocate temporary working space. */
@@ -5337,7 +5366,7 @@ static int fts3EvalNearTest(Fts3Expr *pExpr, int *pRc){
nTmp += p->pRight->pPhrase->doclist.nList;
}
nTmp += p->pPhrase->doclist.nList;
- aTmp = sqlite3_malloc(nTmp*2);
+ aTmp = sqlite3_malloc64(nTmp*2);
if( !aTmp ){
*pRc = SQLITE_NOMEM;
res = 0;
@@ -5607,15 +5636,14 @@ static void fts3EvalRestart(
** found in Fts3Expr.pPhrase->doclist.pList for each of the phrase
** expression nodes.
*/
-static void fts3EvalUpdateCounts(Fts3Expr *pExpr){
+static void fts3EvalUpdateCounts(Fts3Expr *pExpr, int nCol){
if( pExpr ){
Fts3Phrase *pPhrase = pExpr->pPhrase;
if( pPhrase && pPhrase->doclist.pList ){
int iCol = 0;
char *p = pPhrase->doclist.pList;
- assert( *p );
- while( 1 ){
+ do{
u8 c = 0;
int iCnt = 0;
while( 0xFE & (*p | c) ){
@@ -5631,11 +5659,11 @@ static void fts3EvalUpdateCounts(Fts3Expr *pExpr){
if( *p==0x00 ) break;
p++;
p += fts3GetVarint32(p, &iCol);
- }
+ }while( iCol<nCol );
}
- fts3EvalUpdateCounts(pExpr->pLeft);
- fts3EvalUpdateCounts(pExpr->pRight);
+ fts3EvalUpdateCounts(pExpr->pLeft, nCol);
+ fts3EvalUpdateCounts(pExpr->pRight, nCol);
}
}
@@ -5679,7 +5707,7 @@ static int fts3EvalGatherStats(
for(p=pRoot; p; p=p->pLeft){
Fts3Expr *pE = (p->eType==FTSQUERY_PHRASE?p:p->pRight);
assert( pE->aMI==0 );
- pE->aMI = (u32 *)sqlite3_malloc(pTab->nColumn * 3 * sizeof(u32));
+ pE->aMI = (u32 *)sqlite3_malloc64(pTab->nColumn * 3 * sizeof(u32));
if( !pE->aMI ) return SQLITE_NOMEM;
memset(pE->aMI, 0, pTab->nColumn * 3 * sizeof(u32));
}
@@ -5705,7 +5733,7 @@ static int fts3EvalGatherStats(
);
if( rc==SQLITE_OK && pCsr->isEof==0 ){
- fts3EvalUpdateCounts(pRoot);
+ fts3EvalUpdateCounts(pRoot, pTab->nColumn);
}
}
diff --git a/chromium/third_party/sqlite/src/ext/fts3/fts3Int.h b/chromium/third_party/sqlite/src/ext/fts3/fts3Int.h
index 3c6501cea43..c64cb701b59 100644
--- a/chromium/third_party/sqlite/src/ext/fts3/fts3Int.h
+++ b/chromium/third_party/sqlite/src/ext/fts3/fts3Int.h
@@ -95,6 +95,8 @@ SQLITE_EXTENSION_INIT3
*/
#define FTS3_VARINT_MAX 10
+#define FTS3_BUFFER_PADDING 8
+
/*
** FTS4 virtual tables may maintain multiple indexes - one index of all terms
** in the document set and zero or more prefix indexes. All indexes are stored
@@ -128,6 +130,18 @@ SQLITE_EXTENSION_INIT3
#define POS_END (0) /* Position-list terminator */
/*
+** The assert_fts3_nc() macro is similar to the assert() macro, except that it
+** is used for assert() conditions that are true only if it can be
+** guranteed that the database is not corrupt.
+*/
+#if defined(SQLITE_DEBUG) || defined(SQLITE_TEST)
+extern int sqlite3_fts3_may_be_corrupt;
+# define assert_fts3_nc(x) assert(sqlite3_fts3_may_be_corrupt || (x))
+#else
+# define assert_fts3_nc(x) assert(x)
+#endif
+
+/*
** This section provides definitions to allow the
** FTS3 extension to be compiled outside of the
** amalgamation.
diff --git a/chromium/third_party/sqlite/src/ext/fts3/fts3_aux.c b/chromium/third_party/sqlite/src/ext/fts3/fts3_aux.c
index 1ca830dd226..a88c3cc9244 100644
--- a/chromium/third_party/sqlite/src/ext/fts3/fts3_aux.c
+++ b/chromium/third_party/sqlite/src/ext/fts3/fts3_aux.c
@@ -66,7 +66,7 @@ static int fts3auxConnectMethod(
char const *zFts3; /* Name of fts3 table */
int nDb; /* Result of strlen(zDb) */
int nFts3; /* Result of strlen(zFts3) */
- int nByte; /* Bytes of space to allocate here */
+ sqlite3_int64 nByte; /* Bytes of space to allocate here */
int rc; /* value returned by declare_vtab() */
Fts3auxTable *p; /* Virtual table object to return */
@@ -98,7 +98,7 @@ static int fts3auxConnectMethod(
if( rc!=SQLITE_OK ) return rc;
nByte = sizeof(Fts3auxTable) + sizeof(Fts3Table) + nDb + nFts3 + 2;
- p = (Fts3auxTable *)sqlite3_malloc(nByte);
+ p = (Fts3auxTable *)sqlite3_malloc64(nByte);
if( !p ) return SQLITE_NOMEM;
memset(p, 0, nByte);
@@ -248,7 +248,7 @@ static int fts3auxCloseMethod(sqlite3_vtab_cursor *pCursor){
static int fts3auxGrowStatArray(Fts3auxCursor *pCsr, int nSize){
if( nSize>pCsr->nStat ){
struct Fts3auxColstats *aNew;
- aNew = (struct Fts3auxColstats *)sqlite3_realloc(pCsr->aStat,
+ aNew = (struct Fts3auxColstats *)sqlite3_realloc64(pCsr->aStat,
sizeof(struct Fts3auxColstats) * nSize
);
if( aNew==0 ) return SQLITE_NOMEM;
@@ -416,15 +416,15 @@ static int fts3auxFilterMethod(
assert( (iEq==0 && iGe==-1) || (iEq==-1 && iGe==0) );
if( zStr ){
pCsr->filter.zTerm = sqlite3_mprintf("%s", zStr);
- pCsr->filter.nTerm = sqlite3_value_bytes(apVal[0]);
if( pCsr->filter.zTerm==0 ) return SQLITE_NOMEM;
+ pCsr->filter.nTerm = (int)strlen(pCsr->filter.zTerm);
}
}
if( iLe>=0 ){
pCsr->zStop = sqlite3_mprintf("%s", sqlite3_value_text(apVal[iLe]));
- pCsr->nStop = sqlite3_value_bytes(apVal[iLe]);
if( pCsr->zStop==0 ) return SQLITE_NOMEM;
+ pCsr->nStop = (int)strlen(pCsr->zStop);
}
if( iLangid>=0 ){
diff --git a/chromium/third_party/sqlite/src/ext/fts3/fts3_expr.c b/chromium/third_party/sqlite/src/ext/fts3/fts3_expr.c
index 5ca9de3c392..dcf922eea6a 100644
--- a/chromium/third_party/sqlite/src/ext/fts3/fts3_expr.c
+++ b/chromium/third_party/sqlite/src/ext/fts3/fts3_expr.c
@@ -122,8 +122,8 @@ static int fts3isspace(char c){
** zero the memory before returning a pointer to it. If unsuccessful,
** return NULL.
*/
-static void *fts3MallocZero(int nByte){
- void *pRet = sqlite3_malloc(nByte);
+static void *fts3MallocZero(sqlite3_int64 nByte){
+ void *pRet = sqlite3_malloc64(nByte);
if( pRet ) memset(pRet, 0, nByte);
return pRet;
}
@@ -198,7 +198,7 @@ static int getNextToken(
if( rc==SQLITE_OK ){
const char *zToken;
int nToken = 0, iStart = 0, iEnd = 0, iPosition = 0;
- int nByte; /* total space to allocate */
+ sqlite3_int64 nByte; /* total space to allocate */
rc = pModule->xNext(pCursor, &zToken, &nToken, &iStart, &iEnd, &iPosition);
if( rc==SQLITE_OK ){
@@ -252,8 +252,8 @@ static int getNextToken(
** Enlarge a memory allocation. If an out-of-memory allocation occurs,
** then free the old allocation.
*/
-static void *fts3ReallocOrFree(void *pOrig, int nNew){
- void *pRet = sqlite3_realloc(pOrig, nNew);
+static void *fts3ReallocOrFree(void *pOrig, sqlite3_int64 nNew){
+ void *pRet = sqlite3_realloc64(pOrig, nNew);
if( !pRet ){
sqlite3_free(pOrig);
}
@@ -497,7 +497,6 @@ static int getNextNode(
int nConsumed = 0;
pParse->nNest++;
rc = fts3ExprParse(pParse, zInput+1, nInput-1, ppExpr, &nConsumed);
- if( rc==SQLITE_OK && !*ppExpr ){ rc = SQLITE_DONE; }
*pnConsumed = (int)(zInput - z) + 1 + nConsumed;
return rc;
}else if( *zInput==')' ){
@@ -796,7 +795,7 @@ static int fts3ExprBalance(Fts3Expr **pp, int nMaxDepth){
if( rc==SQLITE_OK ){
if( (eType==FTSQUERY_AND || eType==FTSQUERY_OR) ){
Fts3Expr **apLeaf;
- apLeaf = (Fts3Expr **)sqlite3_malloc(sizeof(Fts3Expr *) * nMaxDepth);
+ apLeaf = (Fts3Expr **)sqlite3_malloc64(sizeof(Fts3Expr *) * nMaxDepth);
if( 0==apLeaf ){
rc = SQLITE_NOMEM;
}else{
@@ -1216,7 +1215,7 @@ static void fts3ExprTestCommon(
zExpr = (const char *)sqlite3_value_text(argv[1]);
nExpr = sqlite3_value_bytes(argv[1]);
nCol = argc-2;
- azCol = (char **)sqlite3_malloc(nCol*sizeof(char *));
+ azCol = (char **)sqlite3_malloc64(nCol*sizeof(char *));
if( !azCol ){
sqlite3_result_error_nomem(context);
goto exprtest_out;
diff --git a/chromium/third_party/sqlite/src/ext/fts3/fts3_hash.c b/chromium/third_party/sqlite/src/ext/fts3/fts3_hash.c
index 0a192220b77..1b1098712a6 100644
--- a/chromium/third_party/sqlite/src/ext/fts3/fts3_hash.c
+++ b/chromium/third_party/sqlite/src/ext/fts3/fts3_hash.c
@@ -35,8 +35,8 @@
/*
** Malloc and Free functions
*/
-static void *fts3HashMalloc(int n){
- void *p = sqlite3_malloc(n);
+static void *fts3HashMalloc(sqlite3_int64 n){
+ void *p = sqlite3_malloc64(n);
if( p ){
memset(p, 0, n);
}
diff --git a/chromium/third_party/sqlite/src/ext/fts3/fts3_icu.c b/chromium/third_party/sqlite/src/ext/fts3/fts3_icu.c
index 211803d7687..92ee4c9647a 100644
--- a/chromium/third_party/sqlite/src/ext/fts3/fts3_icu.c
+++ b/chromium/third_party/sqlite/src/ext/fts3/fts3_icu.c
@@ -60,7 +60,7 @@ static int icuCreate(
if( argc>0 ){
n = strlen(argv[0])+1;
}
- p = (IcuTokenizer *)sqlite3_malloc(sizeof(IcuTokenizer)+n);
+ p = (IcuTokenizer *)sqlite3_malloc64(sizeof(IcuTokenizer)+n);
if( !p ){
return SQLITE_NOMEM;
}
@@ -117,7 +117,7 @@ static int icuOpen(
nInput = strlen(zInput);
}
nChar = nInput+1;
- pCsr = (IcuCursor *)sqlite3_malloc(
+ pCsr = (IcuCursor *)sqlite3_malloc64(
sizeof(IcuCursor) + /* IcuCursor */
((nChar+3)&~3) * sizeof(UChar) + /* IcuCursor.aChar[] */
(nChar+1) * sizeof(int) /* IcuCursor.aOffset[] */
diff --git a/chromium/third_party/sqlite/src/ext/fts3/fts3_snippet.c b/chromium/third_party/sqlite/src/ext/fts3/fts3_snippet.c
index 41f64468281..953dd1954da 100644
--- a/chromium/third_party/sqlite/src/ext/fts3/fts3_snippet.c
+++ b/chromium/third_party/sqlite/src/ext/fts3/fts3_snippet.c
@@ -178,7 +178,7 @@ static void (*fts3MIBufferAlloc(MatchinfoBuffer *p, u32 **paOut))(void*){
aOut = &p->aMatchinfo[p->nElem+2];
xRet = fts3MIBufferFree;
}else{
- aOut = (u32*)sqlite3_malloc(p->nElem * sizeof(u32));
+ aOut = (u32*)sqlite3_malloc64(p->nElem * sizeof(u32));
if( aOut ){
xRet = sqlite3_free;
if( p->bGlobal ) memcpy(aOut, &p->aMatchinfo[1], p->nElem*sizeof(u32));
@@ -433,7 +433,8 @@ static void fts3SnippetDetails(
int j;
u64 mPhrase = (u64)1 << i;
u64 mPos = (u64)1 << (iCsr - iStart);
- assert( iCsr>=iStart );
+ assert( iCsr>=iStart && (iCsr - iStart)<=64 );
+ assert( i>=0 && i<=64 );
if( (mCover|mCovered)&mPhrase ){
iScore++;
}else{
@@ -475,11 +476,14 @@ static int fts3SnippetFindPositions(Fts3Expr *pExpr, int iPhrase, void *ctx){
int iFirst = 0;
pPhrase->pList = pCsr;
fts3GetDeltaPosition(&pCsr, &iFirst);
- assert( iFirst>=0 );
- pPhrase->pHead = pCsr;
- pPhrase->pTail = pCsr;
- pPhrase->iHead = iFirst;
- pPhrase->iTail = iFirst;
+ if( iFirst<0 ){
+ rc = FTS_CORRUPT_VTAB;
+ }else{
+ pPhrase->pHead = pCsr;
+ pPhrase->pTail = pCsr;
+ pPhrase->iHead = iFirst;
+ pPhrase->iTail = iFirst;
+ }
}else{
assert( rc!=SQLITE_OK || (
pPhrase->pList==0 && pPhrase->pHead==0 && pPhrase->pTail==0
@@ -516,7 +520,7 @@ static int fts3BestSnippet(
int rc; /* Return Code */
int nList; /* Number of phrases in expression */
SnippetIter sIter; /* Iterates through snippet candidates */
- int nByte; /* Number of bytes of space to allocate */
+ sqlite3_int64 nByte; /* Number of bytes of space to allocate */
int iBestScore = -1; /* Best snippet score found so far */
int i; /* Loop counter */
@@ -534,7 +538,7 @@ static int fts3BestSnippet(
** the required space using malloc().
*/
nByte = sizeof(SnippetPhrase) * nList;
- sIter.aPhrase = (SnippetPhrase *)sqlite3_malloc(nByte);
+ sIter.aPhrase = (SnippetPhrase *)sqlite3_malloc64(nByte);
if( !sIter.aPhrase ){
return SQLITE_NOMEM;
}
@@ -604,8 +608,8 @@ static int fts3StringAppend(
** appended data.
*/
if( pStr->n+nAppend+1>=pStr->nAlloc ){
- int nAlloc = pStr->nAlloc+nAppend+100;
- char *zNew = sqlite3_realloc(pStr->z, nAlloc);
+ sqlite3_int64 nAlloc = pStr->nAlloc+(sqlite3_int64)nAppend+100;
+ char *zNew = sqlite3_realloc64(pStr->z, nAlloc);
if( !zNew ){
return SQLITE_NOMEM;
}
@@ -660,6 +664,7 @@ static int fts3SnippetShift(
for(nLeft=0; !(hlmask & ((u64)1 << nLeft)); nLeft++);
for(nRight=0; !(hlmask & ((u64)1 << (nSnippet-1-nRight))); nRight++);
+ assert( (nSnippet-1-nRight)<=63 && (nSnippet-1-nRight)>=0 );
nDesired = (nLeft-nRight)/2;
/* Ideally, the start of the snippet should be pushed forward in the
@@ -852,7 +857,7 @@ static int fts3ColumnlistCount(char **ppCollist){
/*
** This function gathers 'y' or 'b' data for a single phrase.
*/
-static void fts3ExprLHits(
+static int fts3ExprLHits(
Fts3Expr *pExpr, /* Phrase expression node */
MatchInfo *p /* Matchinfo context */
){
@@ -882,25 +887,29 @@ static void fts3ExprLHits(
if( *pIter!=0x01 ) break;
pIter++;
pIter += fts3GetVarint32(pIter, &iCol);
+ if( iCol>=p->nCol ) return FTS_CORRUPT_VTAB;
}
+ return SQLITE_OK;
}
/*
** Gather the results for matchinfo directives 'y' and 'b'.
*/
-static void fts3ExprLHitGather(
+static int fts3ExprLHitGather(
Fts3Expr *pExpr,
MatchInfo *p
){
+ int rc = SQLITE_OK;
assert( (pExpr->pLeft==0)==(pExpr->pRight==0) );
if( pExpr->bEof==0 && pExpr->iDocid==p->pCursor->iPrevId ){
if( pExpr->pLeft ){
- fts3ExprLHitGather(pExpr->pLeft, p);
- fts3ExprLHitGather(pExpr->pRight, p);
+ rc = fts3ExprLHitGather(pExpr->pLeft, p);
+ if( rc==SQLITE_OK ) rc = fts3ExprLHitGather(pExpr->pRight, p);
}else{
- fts3ExprLHits(pExpr, p);
+ rc = fts3ExprLHits(pExpr, p);
}
}
+ return rc;
}
/*
@@ -1117,11 +1126,12 @@ static int fts3MatchinfoLcs(Fts3Cursor *pCsr, MatchInfo *pInfo){
int i;
int iCol;
int nToken = 0;
+ int rc = SQLITE_OK;
/* Allocate and populate the array of LcsIterator objects. The array
** contains one element for each matchable phrase in the query.
**/
- aIter = sqlite3_malloc(sizeof(LcsIterator) * pCsr->nPhrase);
+ aIter = sqlite3_malloc64(sizeof(LcsIterator) * pCsr->nPhrase);
if( !aIter ) return SQLITE_NOMEM;
memset(aIter, 0, sizeof(LcsIterator) * pCsr->nPhrase);
(void)fts3ExprIterate(pCsr->pExpr, fts3MatchinfoLcsCb, (void*)aIter);
@@ -1137,13 +1147,16 @@ static int fts3MatchinfoLcs(Fts3Cursor *pCsr, MatchInfo *pInfo){
int nLive = 0; /* Number of iterators in aIter not at EOF */
for(i=0; i<pInfo->nPhrase; i++){
- int rc;
LcsIterator *pIt = &aIter[i];
rc = sqlite3Fts3EvalPhrasePoslist(pCsr, pIt->pExpr, iCol, &pIt->pRead);
- if( rc!=SQLITE_OK ) return rc;
+ if( rc!=SQLITE_OK ) goto matchinfo_lcs_out;
if( pIt->pRead ){
pIt->iPos = pIt->iPosOffset;
- fts3LcsIteratorAdvance(&aIter[i]);
+ fts3LcsIteratorAdvance(pIt);
+ if( pIt->pRead==0 ){
+ rc = FTS_CORRUPT_VTAB;
+ goto matchinfo_lcs_out;
+ }
nLive++;
}
}
@@ -1175,8 +1188,9 @@ static int fts3MatchinfoLcs(Fts3Cursor *pCsr, MatchInfo *pInfo){
pInfo->aMatchinfo[iCol] = nLcs;
}
+ matchinfo_lcs_out:
sqlite3_free(aIter);
- return SQLITE_OK;
+ return rc;
}
/*
@@ -1272,7 +1286,7 @@ static int fts3MatchinfoValues(
case FTS3_MATCHINFO_LHITS: {
int nZero = fts3MatchinfoSize(pInfo, zArg[i]) * sizeof(u32);
memset(pInfo->aMatchinfo, 0, nZero);
- fts3ExprLHitGather(pCsr->pExpr, pInfo);
+ rc = fts3ExprLHitGather(pCsr->pExpr, pInfo);
break;
}
@@ -1424,6 +1438,10 @@ void sqlite3Fts3Snippet(
return;
}
+ /* Limit the snippet length to 64 tokens. */
+ if( nToken<-64 ) nToken = -64;
+ if( nToken>+64 ) nToken = +64;
+
for(nSnippet=1; 1; nSnippet++){
int iSnip; /* Loop counter 0..nSnippet-1 */
@@ -1566,7 +1584,7 @@ void sqlite3Fts3Offsets(
if( rc!=SQLITE_OK ) goto offsets_out;
/* Allocate the array of TermOffset iterators. */
- sCtx.aTerm = (TermOffset *)sqlite3_malloc(sizeof(TermOffset)*nToken);
+ sCtx.aTerm = (TermOffset *)sqlite3_malloc64(sizeof(TermOffset)*nToken);
if( 0==sCtx.aTerm ){
rc = SQLITE_NOMEM;
goto offsets_out;
diff --git a/chromium/third_party/sqlite/src/ext/fts3/fts3_term.c b/chromium/third_party/sqlite/src/ext/fts3/fts3_term.c
index 4b2872fe99b..ea51f43c6cc 100644
--- a/chromium/third_party/sqlite/src/ext/fts3/fts3_term.c
+++ b/chromium/third_party/sqlite/src/ext/fts3/fts3_term.c
@@ -68,9 +68,9 @@ static int fts3termConnectMethod(
char const *zFts3; /* Name of fts3 table */
int nDb; /* Result of strlen(zDb) */
int nFts3; /* Result of strlen(zFts3) */
- int nByte; /* Bytes of space to allocate here */
+ sqlite3_int64 nByte; /* Bytes of space to allocate here */
int rc; /* value returned by declare_vtab() */
- Fts3termTable *p; /* Virtual table object to return */
+ Fts3termTable *p; /* Virtual table object to return */
int iIndex = 0;
UNUSED_PARAMETER(pCtx);
@@ -96,7 +96,7 @@ static int fts3termConnectMethod(
if( rc!=SQLITE_OK ) return rc;
nByte = sizeof(Fts3termTable) + sizeof(Fts3Table) + nDb + nFts3 + 2;
- p = (Fts3termTable *)sqlite3_malloc(nByte);
+ p = (Fts3termTable *)sqlite3_malloc64(nByte);
if( !p ) return SQLITE_NOMEM;
memset(p, 0, nByte);
diff --git a/chromium/third_party/sqlite/src/ext/fts3/fts3_test.c b/chromium/third_party/sqlite/src/ext/fts3/fts3_test.c
index ac2a4adf055..01aa8e96fd4 100644
--- a/chromium/third_party/sqlite/src/ext/fts3/fts3_test.c
+++ b/chromium/third_party/sqlite/src/ext/fts3/fts3_test.c
@@ -574,6 +574,33 @@ static int SQLITE_TCLAPI fts3_test_varint_cmd(
** End of tokenizer code.
**************************************************************************/
+/*
+** sqlite3_fts3_may_be_corrupt BOOLEAN
+**
+** Set or clear the global "may-be-corrupt" flag. Return the old value.
+*/
+static int SQLITE_TCLAPI fts3_may_be_corrupt(
+ void * clientData,
+ Tcl_Interp *interp,
+ int objc,
+ Tcl_Obj *CONST objv[]
+){
+ int bOld = sqlite3_fts3_may_be_corrupt;
+
+ if( objc!=2 && objc!=1 ){
+ Tcl_WrongNumArgs(interp, 1, objv, "?BOOLEAN?");
+ return TCL_ERROR;
+ }
+ if( objc==2 ){
+ int bNew;
+ if( Tcl_GetBooleanFromObj(interp, objv[1], &bNew) ) return TCL_ERROR;
+ sqlite3_fts3_may_be_corrupt = bNew;
+ }
+
+ Tcl_SetObjResult(interp, Tcl_NewIntObj(bOld));
+ return TCL_OK;
+}
+
int Sqlitetestfts3_Init(Tcl_Interp *interp){
Tcl_CreateObjCommand(interp, "fts3_near_match", fts3_near_match_cmd, 0, 0);
Tcl_CreateObjCommand(interp,
@@ -582,10 +609,12 @@ int Sqlitetestfts3_Init(Tcl_Interp *interp){
Tcl_CreateObjCommand(
interp, "fts3_test_tokenizer", fts3_test_tokenizer_cmd, 0, 0
);
-
Tcl_CreateObjCommand(
interp, "fts3_test_varint", fts3_test_varint_cmd, 0, 0
);
+ Tcl_CreateObjCommand(
+ interp, "sqlite3_fts3_may_be_corrupt", fts3_may_be_corrupt, 0, 0
+ );
return TCL_OK;
}
#endif /* SQLITE_ENABLE_FTS3 || SQLITE_ENABLE_FTS4 */
diff --git a/chromium/third_party/sqlite/src/ext/fts3/fts3_tokenize_vtab.c b/chromium/third_party/sqlite/src/ext/fts3/fts3_tokenize_vtab.c
index 87c5da3ce43..6dfde7b91b6 100644
--- a/chromium/third_party/sqlite/src/ext/fts3/fts3_tokenize_vtab.c
+++ b/chromium/third_party/sqlite/src/ext/fts3/fts3_tokenize_vtab.c
@@ -122,7 +122,7 @@ static int fts3tokDequoteArray(
nByte += (int)(strlen(argv[i]) + 1);
}
- *pazDequote = azDequote = sqlite3_malloc(sizeof(char *)*argc + nByte);
+ *pazDequote = azDequote = sqlite3_malloc64(sizeof(char *)*argc + nByte);
if( azDequote==0 ){
rc = SQLITE_NOMEM;
}else{
diff --git a/chromium/third_party/sqlite/src/ext/fts3/fts3_unicode.c b/chromium/third_party/sqlite/src/ext/fts3/fts3_unicode.c
index a89b90ff77f..3101f3479f7 100644
--- a/chromium/third_party/sqlite/src/ext/fts3/fts3_unicode.c
+++ b/chromium/third_party/sqlite/src/ext/fts3/fts3_unicode.c
@@ -82,7 +82,7 @@ typedef struct unicode_cursor unicode_cursor;
struct unicode_tokenizer {
sqlite3_tokenizer base;
- int bRemoveDiacritic;
+ int eRemoveDiacritic;
int nException;
int *aiException;
};
@@ -155,7 +155,7 @@ static int unicodeAddExceptions(
int *aNew; /* New aiException[] array */
int nNew; /* Number of valid entries in array aNew[] */
- aNew = sqlite3_realloc(p->aiException, (p->nException+nEntry)*sizeof(int));
+ aNew = sqlite3_realloc64(p->aiException,(p->nException+nEntry)*sizeof(int));
if( aNew==0 ) return SQLITE_NOMEM;
nNew = p->nException;
@@ -227,17 +227,20 @@ static int unicodeCreate(
pNew = (unicode_tokenizer *) sqlite3_malloc(sizeof(unicode_tokenizer));
if( pNew==NULL ) return SQLITE_NOMEM;
memset(pNew, 0, sizeof(unicode_tokenizer));
- pNew->bRemoveDiacritic = 1;
+ pNew->eRemoveDiacritic = 1;
for(i=0; rc==SQLITE_OK && i<nArg; i++){
const char *z = azArg[i];
int n = (int)strlen(z);
if( n==19 && memcmp("remove_diacritics=1", z, 19)==0 ){
- pNew->bRemoveDiacritic = 1;
+ pNew->eRemoveDiacritic = 1;
}
else if( n==19 && memcmp("remove_diacritics=0", z, 19)==0 ){
- pNew->bRemoveDiacritic = 0;
+ pNew->eRemoveDiacritic = 0;
+ }
+ else if( n==19 && memcmp("remove_diacritics=2", z, 19)==0 ){
+ pNew->eRemoveDiacritic = 2;
}
else if( n>=11 && memcmp("tokenchars=", z, 11)==0 ){
rc = unicodeAddExceptions(pNew, 1, &z[11], n-11);
@@ -341,7 +344,7 @@ static int unicodeNext(
/* Grow the output buffer if required. */
if( (zOut-pCsr->zToken)>=(pCsr->nAlloc-4) ){
- char *zNew = sqlite3_realloc(pCsr->zToken, pCsr->nAlloc+64);
+ char *zNew = sqlite3_realloc64(pCsr->zToken, pCsr->nAlloc+64);
if( !zNew ) return SQLITE_NOMEM;
zOut = &zNew[zOut - pCsr->zToken];
pCsr->zToken = zNew;
@@ -350,7 +353,7 @@ static int unicodeNext(
/* Write the folded case of the last character read to the output */
zEnd = z;
- iOut = sqlite3FtsUnicodeFold((int)iCode, p->bRemoveDiacritic);
+ iOut = sqlite3FtsUnicodeFold((int)iCode, p->eRemoveDiacritic);
if( iOut ){
WRITE_UTF8(zOut, iOut);
}
diff --git a/chromium/third_party/sqlite/src/ext/fts3/fts3_unicode2.c b/chromium/third_party/sqlite/src/ext/fts3/fts3_unicode2.c
index b38d2fa54c4..243bbc6c7cf 100644
--- a/chromium/third_party/sqlite/src/ext/fts3/fts3_unicode2.c
+++ b/chromium/third_party/sqlite/src/ext/fts3/fts3_unicode2.c
@@ -1,5 +1,5 @@
/*
-** 2012 May 25
+** 2012-05-25
**
** The author disclaims copyright to this source code. In place of
** a legal notice, here is a blessing:
@@ -159,32 +159,48 @@ int sqlite3FtsUnicodeIsalnum(int c){
** E"). The resuls of passing a codepoint that corresponds to an
** uppercase letter are undefined.
*/
-static int remove_diacritic(int c){
+static int remove_diacritic(int c, int bComplex){
unsigned short aDia[] = {
0, 1797, 1848, 1859, 1891, 1928, 1940, 1995,
2024, 2040, 2060, 2110, 2168, 2206, 2264, 2286,
2344, 2383, 2472, 2488, 2516, 2596, 2668, 2732,
2782, 2842, 2894, 2954, 2984, 3000, 3028, 3336,
- 3456, 3696, 3712, 3728, 3744, 3896, 3912, 3928,
- 3968, 4008, 4040, 4106, 4138, 4170, 4202, 4234,
- 4266, 4296, 4312, 4344, 4408, 4424, 4472, 4504,
- 6148, 6198, 6264, 6280, 6360, 6429, 6505, 6529,
- 61448, 61468, 61534, 61592, 61642, 61688, 61704, 61726,
- 61784, 61800, 61836, 61880, 61914, 61948, 61998, 62122,
- 62154, 62200, 62218, 62302, 62364, 62442, 62478, 62536,
- 62554, 62584, 62604, 62640, 62648, 62656, 62664, 62730,
- 62924, 63050, 63082, 63274, 63390,
+ 3456, 3696, 3712, 3728, 3744, 3766, 3832, 3896,
+ 3912, 3928, 3944, 3968, 4008, 4040, 4056, 4106,
+ 4138, 4170, 4202, 4234, 4266, 4296, 4312, 4344,
+ 4408, 4424, 4442, 4472, 4488, 4504, 6148, 6198,
+ 6264, 6280, 6360, 6429, 6505, 6529, 61448, 61468,
+ 61512, 61534, 61592, 61610, 61642, 61672, 61688, 61704,
+ 61726, 61784, 61800, 61816, 61836, 61880, 61896, 61914,
+ 61948, 61998, 62062, 62122, 62154, 62184, 62200, 62218,
+ 62252, 62302, 62364, 62410, 62442, 62478, 62536, 62554,
+ 62584, 62604, 62640, 62648, 62656, 62664, 62730, 62766,
+ 62830, 62890, 62924, 62974, 63032, 63050, 63082, 63118,
+ 63182, 63242, 63274, 63310, 63368, 63390,
};
- char aChar[] = {
- '\0', 'a', 'c', 'e', 'i', 'n', 'o', 'u', 'y', 'y', 'a', 'c',
- 'd', 'e', 'e', 'g', 'h', 'i', 'j', 'k', 'l', 'n', 'o', 'r',
- 's', 't', 'u', 'u', 'w', 'y', 'z', 'o', 'u', 'a', 'i', 'o',
- 'u', 'g', 'k', 'o', 'j', 'g', 'n', 'a', 'e', 'i', 'o', 'r',
- 'u', 's', 't', 'h', 'a', 'e', 'o', 'y', '\0', '\0', '\0', '\0',
- '\0', '\0', '\0', '\0', 'a', 'b', 'd', 'd', 'e', 'f', 'g', 'h',
- 'h', 'i', 'k', 'l', 'l', 'm', 'n', 'p', 'r', 'r', 's', 't',
- 'u', 'v', 'w', 'w', 'x', 'y', 'z', 'h', 't', 'w', 'y', 'a',
- 'e', 'i', 'o', 'u', 'y',
+#define HIBIT ((unsigned char)0x80)
+ unsigned char aChar[] = {
+ '\0', 'a', 'c', 'e', 'i', 'n',
+ 'o', 'u', 'y', 'y', 'a', 'c',
+ 'd', 'e', 'e', 'g', 'h', 'i',
+ 'j', 'k', 'l', 'n', 'o', 'r',
+ 's', 't', 'u', 'u', 'w', 'y',
+ 'z', 'o', 'u', 'a', 'i', 'o',
+ 'u', 'u'|HIBIT, 'a'|HIBIT, 'g', 'k', 'o',
+ 'o'|HIBIT, 'j', 'g', 'n', 'a'|HIBIT, 'a',
+ 'e', 'i', 'o', 'r', 'u', 's',
+ 't', 'h', 'a', 'e', 'o'|HIBIT, 'o',
+ 'o'|HIBIT, 'y', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', 'a', 'b',
+ 'c'|HIBIT, 'd', 'd', 'e'|HIBIT, 'e', 'e'|HIBIT,
+ 'f', 'g', 'h', 'h', 'i', 'i'|HIBIT,
+ 'k', 'l', 'l'|HIBIT, 'l', 'm', 'n',
+ 'o'|HIBIT, 'p', 'r', 'r'|HIBIT, 'r', 's',
+ 's'|HIBIT, 't', 'u', 'u'|HIBIT, 'v', 'w',
+ 'w', 'x', 'y', 'z', 'h', 't',
+ 'w', 'y', 'a', 'a'|HIBIT, 'a'|HIBIT, 'a'|HIBIT,
+ 'e', 'e'|HIBIT, 'e'|HIBIT, 'i', 'o', 'o'|HIBIT,
+ 'o'|HIBIT, 'o'|HIBIT, 'u', 'u'|HIBIT, 'u'|HIBIT, 'y',
};
unsigned int key = (((unsigned int)c)<<3) | 0x00000007;
@@ -201,7 +217,8 @@ static int remove_diacritic(int c){
}
}
assert( key>=aDia[iRes] );
- return ((c > (aDia[iRes]>>3) + (aDia[iRes]&0x07)) ? c : (int)aChar[iRes]);
+ if( bComplex==0 && (aChar[iRes] & 0x80) ) return c;
+ return (c > (aDia[iRes]>>3) + (aDia[iRes]&0x07)) ? c : ((int)aChar[iRes] & 0x7F);
}
@@ -214,8 +231,8 @@ int sqlite3FtsUnicodeIsdiacritic(int c){
unsigned int mask1 = 0x000361F8;
if( c<768 || c>817 ) return 0;
return (c < 768+32) ?
- (mask0 & (1 << (c-768))) :
- (mask1 & (1 << (c-768-32)));
+ (mask0 & ((unsigned int)1 << (c-768))) :
+ (mask1 & ((unsigned int)1 << (c-768-32)));
}
@@ -228,7 +245,7 @@ int sqlite3FtsUnicodeIsdiacritic(int c){
** The results are undefined if the value passed to this function
** is less than zero.
*/
-int sqlite3FtsUnicodeFold(int c, int bRemoveDiacritic){
+int sqlite3FtsUnicodeFold(int c, int eRemoveDiacritic){
/* Each entry in the following array defines a rule for folding a range
** of codepoints to lower case. The rule applies to a range of nRange
** codepoints starting at codepoint iCode.
@@ -351,7 +368,9 @@ int sqlite3FtsUnicodeFold(int c, int bRemoveDiacritic){
assert( ret>0 );
}
- if( bRemoveDiacritic ) ret = remove_diacritic(ret);
+ if( eRemoveDiacritic ){
+ ret = remove_diacritic(ret, eRemoveDiacritic==2);
+ }
}
else if( c>=66560 && c<66600 ){
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 9bc6d70f45c..e368c09247d 100644
--- a/chromium/third_party/sqlite/src/ext/fts3/fts3_write.c
+++ b/chromium/third_party/sqlite/src/ext/fts3/fts3_write.c
@@ -567,7 +567,7 @@ static sqlite3_int64 getAbsoluteLevel(
int iLevel /* Level of segments */
){
sqlite3_int64 iBase; /* First absolute level for iLangid/iIndex */
- assert( iLangid>=0 );
+ assert_fts3_nc( iLangid>=0 );
assert( p->nIndex>0 );
assert( iIndex>=0 && iIndex<p->nIndex );
@@ -1409,7 +1409,7 @@ static int fts3SegReaderNext(
** b-tree node. And that the final byte of the doclist is 0x00. If either
** of these statements is untrue, then the data structure is corrupt.
*/
- if( (&pReader->aNode[pReader->nNode] - pReader->aDoclist)<pReader->nDoclist
+ if( pReader->nDoclist > pReader->nNode-(pReader->aDoclist-pReader->aNode)
|| (pReader->nPopulate==0 && pReader->aDoclist[pReader->nDoclist-1])
){
return FTS_CORRUPT_VTAB;
@@ -1609,8 +1609,13 @@ int sqlite3Fts3SegReaderNew(
Fts3SegReader *pReader; /* Newly allocated SegReader object */
int nExtra = 0; /* Bytes to allocate segment root node */
- assert( iStartLeaf<=iEndLeaf );
+ assert( zRoot!=0 || nRoot==0 );
+#ifdef CORRUPT_DB
+ assert( zRoot!=0 || CORRUPT_DB );
+#endif
+
if( iStartLeaf==0 ){
+ if( iEndLeaf!=0 ) return FTS_CORRUPT_VTAB;
nExtra = nRoot + FTS3_NODE_PADDING;
}
@@ -1630,7 +1635,7 @@ int sqlite3Fts3SegReaderNew(
pReader->aNode = (char *)&pReader[1];
pReader->rootOnly = 1;
pReader->nNode = nRoot;
- memcpy(pReader->aNode, zRoot, nRoot);
+ if( nRoot ) memcpy(pReader->aNode, zRoot, nRoot);
memset(&pReader->aNode[nRoot], 0, FTS3_NODE_PADDING);
}else{
pReader->iCurrentBlock = iStartLeaf-1;
@@ -2250,6 +2255,11 @@ static int fts3SegWriterAdd(
nPrefix = fts3PrefixCompress(pWriter->zTerm, pWriter->nTerm, zTerm, nTerm);
nSuffix = nTerm-nPrefix;
+ /* If nSuffix is zero or less, then zTerm/nTerm must be a prefix of
+ ** pWriter->zTerm/pWriter->nTerm. i.e. must be equal to or less than when
+ ** compared with BINARY collation. This indicates corruption. */
+ if( nSuffix<=0 ) return FTS_CORRUPT_VTAB;
+
/* Figure out how many bytes are required by this new entry */
nReq = sqlite3Fts3VarintLen(nPrefix) + /* varint containing prefix size */
sqlite3Fts3VarintLen(nSuffix) + /* varint containing suffix size */
@@ -2957,7 +2967,9 @@ int sqlite3Fts3SegReaderStep(
}else{
iDelta = iDocid - iPrev;
}
- assert( iDelta>0 || (nDoclist==0 && iDelta==iDocid) );
+ if( iDelta<=0 && (nDoclist>0 || iDelta!=iDocid) ){
+ return FTS_CORRUPT_VTAB;
+ }
assert( nDoclist>0 || iDelta==iDocid );
nByte = sqlite3Fts3VarintLen(iDelta) + (isRequirePos?nList+1:0);
@@ -3323,14 +3335,16 @@ static void fts3DecodeIntArray(
const char *zBuf, /* The BLOB containing the varints */
int nBuf /* size of the BLOB */
){
- int i, j;
- UNUSED_PARAMETER(nBuf);
- for(i=j=0; i<N; i++){
- sqlite3_int64 x;
- j += sqlite3Fts3GetVarint(&zBuf[j], &x);
- assert(j<=nBuf);
- a[i] = (u32)(x & 0xffffffff);
+ int i = 0;
+ if( nBuf && (zBuf[nBuf-1]&0x80)==0 ){
+ int j;
+ for(i=j=0; i<N && j<nBuf; i++){
+ sqlite3_int64 x;
+ j += sqlite3Fts3GetVarint(&zBuf[j], &x);
+ a[i] = (u32)(x & 0xffffffff);
+ }
}
+ while( i<N ) a[i++] = 0;
}
/*
@@ -3736,7 +3750,7 @@ static int nodeReaderNext(NodeReader *p){
p->iOff += fts3GetVarint32(&p->aNode[p->iOff], &nSuffix);
if( nPrefix>p->iOff || nSuffix>p->nNode-p->iOff ){
- return SQLITE_CORRUPT_VTAB;
+ return FTS_CORRUPT_VTAB;
}
blobGrowBuffer(&p->term, nPrefix+nSuffix, &rc);
if( rc==SQLITE_OK ){
@@ -3746,7 +3760,7 @@ static int nodeReaderNext(NodeReader *p){
if( p->iChild==0 ){
p->iOff += fts3GetVarint32(&p->aNode[p->iOff], &p->nDoclist);
if( (p->nNode-p->iOff)<p->nDoclist ){
- return SQLITE_CORRUPT_VTAB;
+ return FTS_CORRUPT_VTAB;
}
p->aDoclist = &p->aNode[p->iOff];
p->iOff += p->nDoclist;
diff --git a/chromium/third_party/sqlite/src/ext/fts3/unicode/mkunicode.tcl b/chromium/third_party/sqlite/src/ext/fts3/unicode/mkunicode.tcl
index ba11ab28ff7..b809abf218b 100644
--- a/chromium/third_party/sqlite/src/ext/fts3/unicode/mkunicode.tcl
+++ b/chromium/third_party/sqlite/src/ext/fts3/unicode/mkunicode.tcl
@@ -9,11 +9,12 @@ proc print_rd {map} {
set nRange 1
set iFirst [lindex $map 0 0]
set cPrev [lindex $map 0 1]
+ set fPrev [lindex $map 0 2]
foreach m [lrange $map 1 end] {
- foreach {i c} $m {}
+ foreach {i c f} $m {}
- if {$cPrev == $c} {
+ if {$cPrev == $c && $fPrev==$f} {
for {set j [expr $iFirst+$nRange]} {$j<$i} {incr j} {
if {[info exists tl_lookup_table($j)]==0} break
}
@@ -29,13 +30,16 @@ proc print_rd {map} {
lappend lRange [list $iFirst $nRange]
lappend aChar $cPrev
+ lappend aFlag $fPrev
set iFirst $i
set cPrev $c
+ set fPrev $f
set nRange 1
}
lappend lRange [list $iFirst $nRange]
lappend aChar $cPrev
+ lappend aFlag $fPrev
puts "/*"
puts "** If the argument is a codepoint corresponding to a lowercase letter"
@@ -45,7 +49,7 @@ proc print_rd {map} {
puts "** E\"). The resuls of passing a codepoint that corresponds to an"
puts "** uppercase letter are undefined."
puts "*/"
- puts "static int ${::remove_diacritic}(int c)\{"
+ puts "static int ${::remove_diacritic}(int c, int bComplex)\{"
puts " unsigned short aDia\[\] = \{"
puts -nonewline " 0, "
set i 1
@@ -59,14 +63,19 @@ proc print_rd {map} {
}
puts ""
puts " \};"
- puts " char aChar\[\] = \{"
- puts -nonewline " '\\0', "
+ puts "#define HIBIT ((unsigned char)0x80)"
+ puts " unsigned char aChar\[\] = \{"
+ puts -nonewline " '\\0', "
set i 1
- foreach c $aChar {
- set str "'$c', "
- if {$c == ""} { set str "'\\0', " }
+ foreach c $aChar f $aFlag {
+ if { $f } {
+ set str "'$c'|HIBIT, "
+ } else {
+ set str "'$c', "
+ }
+ if {$c == ""} { set str "'\\0', " }
- if {($i % 12)==0} {puts "" ; puts -nonewline " " }
+ if {($i % 6)==0} {puts "" ; puts -nonewline " " }
incr i
puts -nonewline "$str"
}
@@ -87,7 +96,8 @@ proc print_rd {map} {
}
}
assert( key>=aDia[iRes] );
- return ((c > (aDia[iRes]>>3) + (aDia[iRes]&0x07)) ? c : (int)aChar[iRes]);}
+ if( bComplex==0 && (aChar[iRes] & 0x80) ) return c;
+ return (c > (aDia[iRes]>>3) + (aDia[iRes]&0x07)) ? c : ((int)aChar[iRes] & 0x7F);}
puts "\}"
}
@@ -95,7 +105,8 @@ proc print_isdiacritic {zFunc map} {
set lCode [list]
foreach m $map {
- foreach {code char} $m {}
+ foreach {code char flag} $m {}
+ if {$flag} continue
if {$code && $char == ""} { lappend lCode $code }
}
set lCode [lsort -integer $lCode]
@@ -124,8 +135,8 @@ proc print_isdiacritic {zFunc map} {
puts " if( c<$iFirst || c>$iLast ) return 0;"
puts " return (c < $iFirst+32) ?"
- puts " (mask0 & (1 << (c-$iFirst))) :"
- puts " (mask1 & (1 << (c-$iFirst-32)));"
+ puts " (mask0 & ((unsigned int)1 << (c-$iFirst))) :"
+ puts " (mask1 & ((unsigned int)1 << (c-$iFirst-32)));"
puts "\}"
}
@@ -472,7 +483,7 @@ proc print_fold {zFunc} {
puts "** The results are undefined if the value passed to this function"
puts "** is less than zero."
puts "*/"
- puts "int ${zFunc}\(int c, int bRemoveDiacritic)\{"
+ puts "int ${zFunc}\(int c, int eRemoveDiacritic)\{"
set liOff [tl_generate_ioff_table $lRecord]
tl_print_table_header
@@ -516,7 +527,9 @@ proc print_fold {zFunc} {
assert( ret>0 );
}
- if( bRemoveDiacritic ) ret = ${::remove_diacritic}(ret);
+ if( eRemoveDiacritic ){
+ ret = ${::remove_diacritic}(ret, eRemoveDiacritic==2);
+ }
}
}]
@@ -605,10 +618,6 @@ proc print_categories {lMap} {
set nCat [expr [llength [array names C]] + 1]
puts [code {
- int sqlite3Fts5UnicodeNCat(void) {
- return $nCat;
- }
-
int sqlite3Fts5UnicodeCatParse(const char *zCat, u8 *aArray){
aArray[0] = 1;
switch( zCat[0] ){
@@ -691,7 +700,7 @@ proc print_categories {lMap} {
static u16 aFts5UnicodeMap[] = {$aMapArray};
static u16 aFts5UnicodeData[] = {$aDataArray};
- int sqlite3Fts5UnicodeCategory(int iCode) {
+ int sqlite3Fts5UnicodeCategory(u32 iCode) {
int iRes = -1;
int iHi;
int iLo;
@@ -774,7 +783,7 @@ proc print_test_categories {lMap} {
aArray[0] = 1;
}
- c = sqlite3Fts5UnicodeCategory(i);
+ c = sqlite3Fts5UnicodeCategory((u32)i);
if( aArray[c]==0 ){
*piCode = i;
return 1;
@@ -829,7 +838,7 @@ proc print_fold_test {zFunc mappings} {
proc print_fileheader {} {
puts [string trim {
/*
-** 2012 May 25
+** 2012-05-25
**
** The author disclaims copyright to this source code. In place of
** a legal notice, here is a blessing:
diff --git a/chromium/third_party/sqlite/src/ext/fts3/unicode/parseunicode.tcl b/chromium/third_party/sqlite/src/ext/fts3/unicode/parseunicode.tcl
index dda01396701..d7ec90dcd8b 100644
--- a/chromium/third_party/sqlite/src/ext/fts3/unicode/parseunicode.tcl
+++ b/chromium/third_party/sqlite/src/ext/fts3/unicode/parseunicode.tcl
@@ -7,12 +7,24 @@
# character that it should be replaced with, or an empty string if the
# codepoint should simply be removed from the input. Examples:
#
-# { 224 a } (replace codepoint 224 to "a")
-# { 769 "" } (remove codepoint 769 from input)
+# { 224 a 0 } (replace codepoint 224 to "a")
+# { 769 "" 0 } (remove codepoint 769 from input)
#
# Mappings are only returned for non-upper case codepoints. It is assumed
# that the input has already been folded to lower case.
#
+# The third value in the list is always either 0 or 1. 0 if the
+# UnicodeData.txt file maps the codepoint to a single ASCII character and
+# a diacritic, or 1 if the mapping is indirect. For example, consider the
+# two entries:
+#
+# 1ECD;LATIN SMALL LETTER O WITH DOT BELOW;Ll;0;L;006F 0323;;;;N;;;1ECC;;1ECC
+# 1ED9;LATIN SMALL LETTER O WITH CIRCUMFLEX AND DOT BELOW;Ll;0;L;1ECD 0302;;;;N;;;1ED8;;1ED8
+#
+# The first codepoint is a direct mapping (as 006F is ASCII and 0323 is a
+# diacritic). The second is an indirect mapping, as it maps to the
+# first codepoint plus 0302 (a diacritic).
+#
proc rd_load_unicodedata_text {zName} {
global tl_lookup_table
@@ -53,18 +65,29 @@ proc rd_load_unicodedata_text {zName} {
set iAscii [expr "0x[lindex $character_decomposition_mapping 0]"]
set iDia [expr "0x[lindex $character_decomposition_mapping 1]"]
+ # Filter out upper-case characters, as they will be mapped to their
+ # lower-case equivalents before this data is used.
if {[info exists tl_lookup_table($iCode)]} continue
+ # Check if this is an indirect mapping. If so, set bIndirect to true
+ # and change $iAscii to the indirectly mappped ASCII character.
+ set bIndirect 0
+ if {[info exists dia($iDia)] && [info exists mapping($iAscii)]} {
+ set iAscii $mapping($iAscii)
+ set bIndirect 1
+ }
+
if { ($iAscii >= 97 && $iAscii <= 122)
|| ($iAscii >= 65 && $iAscii <= 90)
} {
- lappend lRet [list $iCode [string tolower [format %c $iAscii]]]
+ lappend lRet [list $iCode [string tolower [format %c $iAscii]] $bIndirect]
+ set mapping($iCode) $iAscii
set dia($iDia) 1
}
}
foreach d [array names dia] {
- lappend lRet [list $d ""]
+ lappend lRet [list $d "" 0]
}
set lRet [lsort -integer -index 0 $lRet]
diff --git a/chromium/third_party/sqlite/src/ext/fts5/fts5.h b/chromium/third_party/sqlite/src/ext/fts5/fts5.h
index 08a1f5c4332..ad73ebaf4c2 100644
--- a/chromium/third_party/sqlite/src/ext/fts5/fts5.h
+++ b/chromium/third_party/sqlite/src/ext/fts5/fts5.h
@@ -120,12 +120,8 @@ struct Fts5PhraseIter {
**
** Usually, output parameter *piPhrase is set to the phrase number, *piCol
** to the column in which it occurs and *piOff the token offset of the
-** first token of the phrase. The exception is if the table was created
-** with the offsets=0 option specified. In this case *piOff is always
-** set to -1.
-**
-** Returns SQLITE_OK if successful, or an error code (i.e. SQLITE_NOMEM)
-** if an error occurs.
+** first token of the phrase. Returns SQLITE_OK if successful, or an error
+** code (i.e. SQLITE_NOMEM) if an error occurs.
**
** This API can be quite slow if used with an FTS5 table created with the
** "detail=none" or "detail=column" option.
@@ -414,11 +410,11 @@ struct Fts5ExtensionApi {
** the tokenizer substitutes "first" for "1st" and the query works
** as expected.
**
-** <li> By adding multiple synonyms for a single term to the FTS index.
-** In this case, when tokenizing query text, the tokenizer may
-** provide multiple synonyms for a single term within the document.
-** FTS5 then queries the index for each synonym individually. For
-** example, faced with the query:
+** <li> By querying the index for all synonyms of each query term
+** separately. In this case, when tokenizing query text, the
+** tokenizer may provide multiple synonyms for a single term
+** within the document. FTS5 then queries the index for each
+** synonym individually. For example, faced with the query:
**
** <codeblock>
** ... MATCH 'first place'</codeblock>
@@ -442,7 +438,7 @@ struct Fts5ExtensionApi {
** "place".
**
** This way, even if the tokenizer does not provide synonyms
-** when tokenizing query text (it should not - to do would be
+** when tokenizing query text (it should not - to do so would be
** inefficient), it doesn't matter if the user queries for
** 'first + place' or '1st + place', as there are entries in the
** FTS index corresponding to both forms of the first token.
diff --git a/chromium/third_party/sqlite/src/ext/fts5/fts5Int.h b/chromium/third_party/sqlite/src/ext/fts5/fts5Int.h
index 06f82505535..8cfad43094e 100644
--- a/chromium/third_party/sqlite/src/ext/fts5/fts5Int.h
+++ b/chromium/third_party/sqlite/src/ext/fts5/fts5Int.h
@@ -87,6 +87,12 @@ extern int sqlite3_fts5_may_be_corrupt;
# define assert_nc(x) assert(x)
#endif
+/*
+** A version of memcmp() that does not cause asan errors if one of the pointer
+** parameters is NULL and the number of bytes to compare is zero.
+*/
+#define fts5Memcmp(s1, s2, n) ((n)==0 ? 0 : memcmp((s1), (s2), (n)))
+
/* Mark a function parameter as unused, to suppress nuisance compiler
** warnings. */
#ifndef UNUSED_PARAM
@@ -274,7 +280,7 @@ void sqlite3Fts5Put32(u8*, int);
int sqlite3Fts5Get32(const u8*);
#define FTS5_POS2COLUMN(iPos) (int)(iPos >> 32)
-#define FTS5_POS2OFFSET(iPos) (int)(iPos & 0xFFFFFFFF)
+#define FTS5_POS2OFFSET(iPos) (int)(iPos & 0x7FFFFFFF)
typedef struct Fts5PoslistReader Fts5PoslistReader;
struct Fts5PoslistReader {
@@ -309,7 +315,7 @@ int sqlite3Fts5PoslistNext64(
);
/* Malloc utility */
-void *sqlite3Fts5MallocZero(int *pRc, int nByte);
+void *sqlite3Fts5MallocZero(int *pRc, sqlite3_int64 nByte);
char *sqlite3Fts5Strndup(int *pRc, const char *pIn, int nIn);
/* Character set tests (like isspace(), isalpha() etc.) */
@@ -520,8 +526,18 @@ int sqlite3Fts5PutVarint(unsigned char *p, u64 v);
/**************************************************************************
-** Interface to code in fts5.c.
+** Interface to code in fts5_main.c.
+*/
+
+/*
+** Virtual-table object.
*/
+typedef struct Fts5Table Fts5Table;
+struct Fts5Table {
+ sqlite3_vtab base; /* Base class used by SQLite core */
+ Fts5Config *pConfig; /* Virtual table configuration */
+ Fts5Index *pIndex; /* Full-text index */
+};
int sqlite3Fts5GetTokenizer(
Fts5Global*,
@@ -532,7 +548,9 @@ int sqlite3Fts5GetTokenizer(
char **pzErr
);
-Fts5Index *sqlite3Fts5IndexFromCsrid(Fts5Global*, i64, Fts5Config **);
+Fts5Table *sqlite3Fts5TableFromCsrid(Fts5Global*, i64);
+
+int sqlite3Fts5FlushToDisk(Fts5Table*);
/*
** End of interface to code in fts5.c.
@@ -788,7 +806,7 @@ int sqlite3Fts5UnicodeIsdiacritic(int c);
int sqlite3Fts5UnicodeFold(int c, int bRemoveDiacritic);
int sqlite3Fts5UnicodeCatParse(const char*, u8*);
-int sqlite3Fts5UnicodeCategory(int iCode);
+int sqlite3Fts5UnicodeCategory(u32 iCode);
void sqlite3Fts5UnicodeAscii(u8*, u8*);
/*
** End of interface to code in fts5_unicode2.c.
diff --git a/chromium/third_party/sqlite/src/ext/fts5/fts5_aux.c b/chromium/third_party/sqlite/src/ext/fts5/fts5_aux.c
index c841d887b03..087416aae69 100644
--- a/chromium/third_party/sqlite/src/ext/fts5/fts5_aux.c
+++ b/chromium/third_party/sqlite/src/ext/fts5/fts5_aux.c
@@ -136,7 +136,7 @@ static void fts5HighlightAppend(
HighlightContext *p,
const char *z, int n
){
- if( *pRc==SQLITE_OK ){
+ if( *pRc==SQLITE_OK && z ){
if( n<0 ) n = (int)strlen(z);
p->zOut = sqlite3_mprintf("%z%.*s", p->zOut, n, z);
if( p->zOut==0 ) *pRc = SQLITE_NOMEM;
@@ -268,7 +268,7 @@ static int fts5SentenceFinderAdd(Fts5SFinder *p, int iAdd){
int nNew = p->nFirstAlloc ? p->nFirstAlloc*2 : 64;
int *aNew;
- aNew = (int*)sqlite3_realloc(p->aFirst, nNew*sizeof(int));
+ aNew = (int*)sqlite3_realloc64(p->aFirst, nNew*sizeof(int));
if( aNew==0 ) return SQLITE_NOMEM;
p->aFirst = aNew;
p->nFirstAlloc = nNew;
@@ -335,11 +335,12 @@ static int fts5SnippetScore(
int nInst;
int nScore = 0;
int iLast = 0;
+ sqlite3_int64 iEnd = (sqlite3_int64)iPos + nToken;
rc = pApi->xInstCount(pFts, &nInst);
for(i=0; i<nInst && rc==SQLITE_OK; i++){
rc = pApi->xInst(pFts, i, &ip, &ic, &iOff);
- if( rc==SQLITE_OK && ic==iCol && iOff>=iPos && iOff<(iPos+nToken) ){
+ if( rc==SQLITE_OK && ic==iCol && iOff>=iPos && iOff<iEnd ){
nScore += (aSeen[ip] ? 1 : 1000);
aSeen[ip] = 1;
if( iFirst<0 ) iFirst = iOff;
@@ -349,7 +350,7 @@ static int fts5SnippetScore(
*pnScore = nScore;
if( piPos ){
- int iAdj = iFirst - (nToken - (iLast-iFirst)) / 2;
+ sqlite3_int64 iAdj = iFirst - (nToken - (iLast-iFirst)) / 2;
if( (iAdj+nToken)>nDocsize ) iAdj = nDocsize - nToken;
if( iAdj<0 ) iAdj = 0;
*piPos = iAdj;
@@ -442,7 +443,9 @@ static void fts5SnippetFunction(
int jj;
rc = pApi->xInst(pFts, ii, &ip, &ic, &io);
- if( ic!=i || rc!=SQLITE_OK ) continue;
+ if( ic!=i ) continue;
+ if( io>nDocsize ) rc = FTS5_CORRUPT;
+ if( rc!=SQLITE_OK ) continue;
memset(aSeen, 0, nPhrase);
rc = fts5SnippetScore(pApi, pFts, nDocsize, aSeen, i,
io, nToken, &nScore, &iAdj
@@ -568,13 +571,13 @@ static int fts5Bm25GetData(
int nPhrase; /* Number of phrases in query */
sqlite3_int64 nRow = 0; /* Number of rows in table */
sqlite3_int64 nToken = 0; /* Number of tokens in table */
- int nByte; /* Bytes of space to allocate */
+ sqlite3_int64 nByte; /* Bytes of space to allocate */
int i;
/* Allocate the Fts5Bm25Data object */
nPhrase = pApi->xPhraseCount(pFts);
nByte = sizeof(Fts5Bm25Data) + nPhrase*2*sizeof(double);
- p = (Fts5Bm25Data*)sqlite3_malloc(nByte);
+ p = (Fts5Bm25Data*)sqlite3_malloc64(nByte);
if( p==0 ){
rc = SQLITE_NOMEM;
}else{
@@ -586,6 +589,7 @@ static int fts5Bm25GetData(
/* Calculate the average document length for this FTS5 table */
if( rc==SQLITE_OK ) rc = pApi->xRowCount(pFts, &nRow);
+ assert( rc!=SQLITE_OK || nRow>0 );
if( rc==SQLITE_OK ) rc = pApi->xColumnTotalSize(pFts, -1, &nToken);
if( rc==SQLITE_OK ) p->avgdl = (double)nToken / (double)nRow;
@@ -710,5 +714,3 @@ int sqlite3Fts5AuxInit(fts5_api *pApi){
return rc;
}
-
-
diff --git a/chromium/third_party/sqlite/src/ext/fts5/fts5_buffer.c b/chromium/third_party/sqlite/src/ext/fts5/fts5_buffer.c
index 516174d3de6..3f5595a8517 100644
--- a/chromium/third_party/sqlite/src/ext/fts5/fts5_buffer.c
+++ b/chromium/third_party/sqlite/src/ext/fts5/fts5_buffer.c
@@ -17,12 +17,12 @@
int sqlite3Fts5BufferSize(int *pRc, Fts5Buffer *pBuf, u32 nByte){
if( (u32)pBuf->nSpace<nByte ){
- u32 nNew = pBuf->nSpace ? pBuf->nSpace : 64;
+ u64 nNew = pBuf->nSpace ? pBuf->nSpace : 64;
u8 *pNew;
while( nNew<nByte ){
nNew = nNew * 2;
}
- pNew = sqlite3_realloc(pBuf->p, nNew);
+ pNew = sqlite3_realloc64(pBuf->p, nNew);
if( pNew==0 ){
*pRc = SQLITE_NOMEM;
return 1;
@@ -52,7 +52,7 @@ void sqlite3Fts5Put32(u8 *aBuf, int iVal){
}
int sqlite3Fts5Get32(const u8 *aBuf){
- return (aBuf[0] << 24) + (aBuf[1] << 16) + (aBuf[2] << 8) + aBuf[3];
+ return (int)((((u32)aBuf[0])<<24) + (aBuf[1]<<16) + (aBuf[2]<<8) + aBuf[3]);
}
/*
@@ -183,7 +183,7 @@ int sqlite3Fts5PoslistNext64(
iOff = ((i64)iVal) << 32;
fts5FastGetVarint32(a, i, iVal);
}
- *piOff = iOff + (iVal-2);
+ *piOff = iOff + ((iVal-2) & 0x7FFFFFFF);
*pi = i;
return 0;
}
@@ -244,10 +244,10 @@ int sqlite3Fts5PoslistWriterAppend(
return SQLITE_OK;
}
-void *sqlite3Fts5MallocZero(int *pRc, int nByte){
+void *sqlite3Fts5MallocZero(int *pRc, sqlite3_int64 nByte){
void *pRet = 0;
if( *pRc==SQLITE_OK ){
- pRet = sqlite3_malloc(nByte);
+ pRet = sqlite3_malloc64(nByte);
if( pRet==0 ){
if( nByte>0 ) *pRc = SQLITE_NOMEM;
}else{
diff --git a/chromium/third_party/sqlite/src/ext/fts5/fts5_config.c b/chromium/third_party/sqlite/src/ext/fts5/fts5_config.c
index d0718f4dec6..f479d7ab163 100644
--- a/chromium/third_party/sqlite/src/ext/fts5/fts5_config.c
+++ b/chromium/third_party/sqlite/src/ext/fts5/fts5_config.c
@@ -295,7 +295,7 @@ static int fts5ConfigParseSpecial(
if( sqlite3_strnicmp("tokenize", zCmd, nCmd)==0 ){
const char *p = (const char*)zArg;
- int nArg = (int)strlen(zArg) + 1;
+ sqlite3_int64 nArg = strlen(zArg) + 1;
char **azArg = sqlite3Fts5MallocZero(&rc, sizeof(char*) * nArg);
char *pDel = sqlite3Fts5MallocZero(&rc, nArg * 2);
char *pSpace = pDel;
@@ -425,8 +425,8 @@ static const char *fts5ConfigGobbleWord(
){
const char *zRet = 0;
- int nIn = (int)strlen(zIn);
- char *zOut = sqlite3_malloc(nIn+1);
+ sqlite3_int64 nIn = strlen(zIn);
+ char *zOut = sqlite3_malloc64(nIn+1);
assert( *pRc==SQLITE_OK );
*pbQuoted = 0;
@@ -529,7 +529,7 @@ int sqlite3Fts5ConfigParse(
int rc = SQLITE_OK; /* Return code */
Fts5Config *pRet; /* New object to return */
int i;
- int nByte;
+ sqlite3_int64 nByte;
*ppOut = pRet = (Fts5Config*)sqlite3_malloc(sizeof(Fts5Config));
if( pRet==0 ) return SQLITE_NOMEM;
diff --git a/chromium/third_party/sqlite/src/ext/fts5/fts5_expr.c b/chromium/third_party/sqlite/src/ext/fts5/fts5_expr.c
index 8d155df4ae4..dc52cf602ee 100644
--- a/chromium/third_party/sqlite/src/ext/fts5/fts5_expr.c
+++ b/chromium/third_party/sqlite/src/ext/fts5/fts5_expr.c
@@ -211,7 +211,7 @@ static int fts5ExprGetToken(
return tok;
}
-static void *fts5ParseAlloc(u64 t){ return sqlite3_malloc((int)t); }
+static void *fts5ParseAlloc(u64 t){ return sqlite3_malloc64((sqlite3_int64)t);}
static void fts5ParseFree(void *p){ sqlite3_free(p); }
int sqlite3Fts5ExprNew(
@@ -356,8 +356,8 @@ static int fts5ExprSynonymList(
if( sqlite3Fts5IterEof(pIter)==0 && pIter->iRowid==iRowid ){
if( pIter->nData==0 ) continue;
if( nIter==nAlloc ){
- int nByte = sizeof(Fts5PoslistReader) * nAlloc * 2;
- Fts5PoslistReader *aNew = (Fts5PoslistReader*)sqlite3_malloc(nByte);
+ sqlite3_int64 nByte = sizeof(Fts5PoslistReader) * nAlloc * 2;
+ Fts5PoslistReader *aNew = (Fts5PoslistReader*)sqlite3_malloc64(nByte);
if( aNew==0 ){
rc = SQLITE_NOMEM;
goto synonym_poslist_out;
@@ -437,8 +437,8 @@ static int fts5ExprPhraseIsMatch(
/* If the aStatic[] array is not large enough, allocate a large array
** using sqlite3_malloc(). This approach could be improved upon. */
if( pPhrase->nTerm>ArraySize(aStatic) ){
- int nByte = sizeof(Fts5PoslistReader) * pPhrase->nTerm;
- aIter = (Fts5PoslistReader*)sqlite3_malloc(nByte);
+ sqlite3_int64 nByte = sizeof(Fts5PoslistReader) * pPhrase->nTerm;
+ aIter = (Fts5PoslistReader*)sqlite3_malloc64(nByte);
if( !aIter ) return SQLITE_NOMEM;
}
memset(aIter, 0, sizeof(Fts5PoslistReader) * pPhrase->nTerm);
@@ -572,7 +572,7 @@ static int fts5ExprNearIsMatch(int *pRc, Fts5ExprNearset *pNear){
/* If the aStatic[] array is not large enough, allocate a large array
** using sqlite3_malloc(). This approach could be improved upon. */
if( pNear->nPhrase>ArraySize(aStatic) ){
- int nByte = sizeof(Fts5NearTrimmer) * pNear->nPhrase;
+ sqlite3_int64 nByte = sizeof(Fts5NearTrimmer) * pNear->nPhrase;
a = (Fts5NearTrimmer*)sqlite3Fts5MallocZero(&rc, nByte);
}else{
memset(aStatic, 0, sizeof(aStatic));
@@ -1481,8 +1481,9 @@ Fts5ExprNearset *sqlite3Fts5ParseNearset(
return pNear;
}
if( pNear==0 ){
- int nByte = sizeof(Fts5ExprNearset) + SZALLOC * sizeof(Fts5ExprPhrase*);
- pRet = sqlite3_malloc(nByte);
+ sqlite3_int64 nByte;
+ nByte = sizeof(Fts5ExprNearset) + SZALLOC * sizeof(Fts5ExprPhrase*);
+ pRet = sqlite3_malloc64(nByte);
if( pRet==0 ){
pParse->rc = SQLITE_NOMEM;
}else{
@@ -1490,9 +1491,10 @@ Fts5ExprNearset *sqlite3Fts5ParseNearset(
}
}else if( (pNear->nPhrase % SZALLOC)==0 ){
int nNew = pNear->nPhrase + SZALLOC;
- int nByte = sizeof(Fts5ExprNearset) + nNew * sizeof(Fts5ExprPhrase*);
+ sqlite3_int64 nByte;
- pRet = (Fts5ExprNearset*)sqlite3_realloc(pNear, nByte);
+ nByte = sizeof(Fts5ExprNearset) + nNew * sizeof(Fts5ExprPhrase*);
+ pRet = (Fts5ExprNearset*)sqlite3_realloc64(pNear, nByte);
if( pRet==0 ){
pParse->rc = SQLITE_NOMEM;
}
@@ -1556,8 +1558,8 @@ static int fts5ParseTokenize(
if( pPhrase && pPhrase->nTerm>0 && (tflags & FTS5_TOKEN_COLOCATED) ){
Fts5ExprTerm *pSyn;
- int nByte = sizeof(Fts5ExprTerm) + sizeof(Fts5Buffer) + nToken+1;
- pSyn = (Fts5ExprTerm*)sqlite3_malloc(nByte);
+ sqlite3_int64 nByte = sizeof(Fts5ExprTerm) + sizeof(Fts5Buffer) + nToken+1;
+ pSyn = (Fts5ExprTerm*)sqlite3_malloc64(nByte);
if( pSyn==0 ){
rc = SQLITE_NOMEM;
}else{
@@ -1573,7 +1575,7 @@ static int fts5ParseTokenize(
Fts5ExprPhrase *pNew;
int nNew = SZALLOC + (pPhrase ? pPhrase->nTerm : 0);
- pNew = (Fts5ExprPhrase*)sqlite3_realloc(pPhrase,
+ pNew = (Fts5ExprPhrase*)sqlite3_realloc64(pPhrase,
sizeof(Fts5ExprPhrase) + sizeof(Fts5ExprTerm) * nNew
);
if( pNew==0 ){
@@ -1659,9 +1661,9 @@ Fts5ExprPhrase *sqlite3Fts5ParseTerm(
if( pAppend==0 ){
if( (pParse->nPhrase % 8)==0 ){
- int nByte = sizeof(Fts5ExprPhrase*) * (pParse->nPhrase + 8);
+ sqlite3_int64 nByte = sizeof(Fts5ExprPhrase*) * (pParse->nPhrase + 8);
Fts5ExprPhrase **apNew;
- apNew = (Fts5ExprPhrase**)sqlite3_realloc(pParse->apPhrase, nByte);
+ apNew = (Fts5ExprPhrase**)sqlite3_realloc64(pParse->apPhrase, nByte);
if( apNew==0 ){
pParse->rc = SQLITE_NOMEM;
fts5ExprPhraseFree(sCtx.pPhrase);
@@ -1716,8 +1718,10 @@ int sqlite3Fts5ExprClonePhrase(
if( rc==SQLITE_OK ){
Fts5Colset *pColsetOrig = pOrig->pNode->pNear->pColset;
if( pColsetOrig ){
- int nByte = sizeof(Fts5Colset) + (pColsetOrig->nCol-1) * sizeof(int);
- Fts5Colset *pColset = (Fts5Colset*)sqlite3Fts5MallocZero(&rc, nByte);
+ sqlite3_int64 nByte;
+ Fts5Colset *pColset;
+ nByte = sizeof(Fts5Colset) + (pColsetOrig->nCol-1) * sizeof(int);
+ pColset = (Fts5Colset*)sqlite3Fts5MallocZero(&rc, nByte);
if( pColset ){
memcpy(pColset, pColsetOrig, nByte);
}
@@ -1837,7 +1841,7 @@ static Fts5Colset *fts5ParseColset(
assert( pParse->rc==SQLITE_OK );
assert( iCol>=0 && iCol<pParse->pConfig->nCol );
- pNew = sqlite3_realloc(p, sizeof(Fts5Colset) + sizeof(int)*nCol);
+ pNew = sqlite3_realloc64(p, sizeof(Fts5Colset) + sizeof(int)*nCol);
if( pNew==0 ){
pParse->rc = SQLITE_NOMEM;
}else{
@@ -1933,7 +1937,7 @@ Fts5Colset *sqlite3Fts5ParseColset(
static Fts5Colset *fts5CloneColset(int *pRc, Fts5Colset *pOrig){
Fts5Colset *pRet;
if( pOrig ){
- int nByte = sizeof(Fts5Colset) + (pOrig->nCol-1) * sizeof(int);
+ sqlite3_int64 nByte = sizeof(Fts5Colset) + (pOrig->nCol-1) * sizeof(int);
pRet = (Fts5Colset*)sqlite3Fts5MallocZero(pRc, nByte);
if( pRet ){
memcpy(pRet, pOrig, nByte);
@@ -2087,7 +2091,7 @@ Fts5ExprNode *sqlite3Fts5ParseNode(
if( pParse->rc==SQLITE_OK ){
int nChild = 0; /* Number of children of returned node */
- int nByte; /* Bytes of space to allocate for this node */
+ sqlite3_int64 nByte; /* Bytes of space to allocate for this node */
assert( (eType!=FTS5_STRING && !pNear)
|| (eType==FTS5_STRING && !pLeft && !pRight)
@@ -2219,7 +2223,7 @@ Fts5ExprNode *sqlite3Fts5ParseImplicitAnd(
}
static char *fts5ExprTermPrint(Fts5ExprTerm *pTerm){
- int nByte = 0;
+ sqlite3_int64 nByte = 0;
Fts5ExprTerm *p;
char *zQuoted;
@@ -2227,7 +2231,7 @@ static char *fts5ExprTermPrint(Fts5ExprTerm *pTerm){
for(p=pTerm; p; p=p->pSynonym){
nByte += (int)strlen(pTerm->zTerm) * 2 + 3 + 2;
}
- zQuoted = sqlite3_malloc(nByte);
+ zQuoted = sqlite3_malloc64(nByte);
if( zQuoted ){
int i = 0;
@@ -2467,7 +2471,7 @@ static void fts5ExprFunction(
}
nConfig = 3 + (nArg-iArg);
- azConfig = (const char**)sqlite3_malloc(sizeof(char*) * nConfig);
+ azConfig = (const char**)sqlite3_malloc64(sizeof(char*) * nConfig);
if( azConfig==0 ){
sqlite3_result_error_nomem(pCtx);
return;
@@ -2553,7 +2557,7 @@ static void fts5ExprIsAlnum(
sqlite3Fts5UnicodeCatParse("N*", aArr);
sqlite3Fts5UnicodeCatParse("Co", aArr);
iCode = sqlite3_value_int(apVal[0]);
- sqlite3_result_int(pCtx, aArr[sqlite3Fts5UnicodeCategory(iCode)]);
+ sqlite3_result_int(pCtx, aArr[sqlite3Fts5UnicodeCategory((u32)iCode)]);
}
static void fts5ExprFold(
@@ -2648,7 +2652,7 @@ struct Fts5PoslistPopulator {
Fts5PoslistPopulator *sqlite3Fts5ExprClearPoslists(Fts5Expr *pExpr, int bLive){
Fts5PoslistPopulator *pRet;
- pRet = sqlite3_malloc(sizeof(Fts5PoslistPopulator)*pExpr->nPhrase);
+ pRet = sqlite3_malloc64(sizeof(Fts5PoslistPopulator)*pExpr->nPhrase);
if( pRet ){
int i;
memset(pRet, 0, sizeof(Fts5PoslistPopulator)*pExpr->nPhrase);
@@ -2847,4 +2851,3 @@ int sqlite3Fts5ExprPhraseCollist(
return rc;
}
-
diff --git a/chromium/third_party/sqlite/src/ext/fts5/fts5_hash.c b/chromium/third_party/sqlite/src/ext/fts5/fts5_hash.c
index bc79aad2515..71219ab3e14 100644
--- a/chromium/third_party/sqlite/src/ext/fts5/fts5_hash.c
+++ b/chromium/third_party/sqlite/src/ext/fts5/fts5_hash.c
@@ -90,14 +90,14 @@ int sqlite3Fts5HashNew(Fts5Config *pConfig, Fts5Hash **ppNew, int *pnByte){
if( pNew==0 ){
rc = SQLITE_NOMEM;
}else{
- int nByte;
+ sqlite3_int64 nByte;
memset(pNew, 0, sizeof(Fts5Hash));
pNew->pnByte = pnByte;
pNew->eDetail = pConfig->eDetail;
pNew->nSlot = 1024;
nByte = sizeof(Fts5HashEntry*) * pNew->nSlot;
- pNew->aSlot = (Fts5HashEntry**)sqlite3_malloc(nByte);
+ pNew->aSlot = (Fts5HashEntry**)sqlite3_malloc64(nByte);
if( pNew->aSlot==0 ){
sqlite3_free(pNew);
*ppNew = 0;
@@ -165,7 +165,7 @@ static int fts5HashResize(Fts5Hash *pHash){
Fts5HashEntry **apNew;
Fts5HashEntry **apOld = pHash->aSlot;
- apNew = (Fts5HashEntry**)sqlite3_malloc(nNew*sizeof(Fts5HashEntry*));
+ apNew = (Fts5HashEntry**)sqlite3_malloc64(nNew*sizeof(Fts5HashEntry*));
if( !apNew ) return SQLITE_NOMEM;
memset(apNew, 0, nNew*sizeof(Fts5HashEntry*));
@@ -259,7 +259,7 @@ int sqlite3Fts5HashWrite(
if( p==0 ){
/* Figure out how much space to allocate */
char *zKey;
- int nByte = sizeof(Fts5HashEntry) + (nToken+1) + 1 + 64;
+ sqlite3_int64 nByte = sizeof(Fts5HashEntry) + (nToken+1) + 1 + 64;
if( nByte<128 ) nByte = 128;
/* Grow the Fts5Hash.aSlot[] array if necessary. */
@@ -270,7 +270,7 @@ int sqlite3Fts5HashWrite(
}
/* Allocate new Fts5HashEntry and add it to the hash table. */
- p = (Fts5HashEntry*)sqlite3_malloc(nByte);
+ p = (Fts5HashEntry*)sqlite3_malloc64(nByte);
if( !p ) return SQLITE_NOMEM;
memset(p, 0, sizeof(Fts5HashEntry));
p->nAlloc = nByte;
@@ -309,12 +309,12 @@ int sqlite3Fts5HashWrite(
** + 5 bytes for the new position offset (32-bit max).
*/
if( (p->nAlloc - p->nData) < (9 + 4 + 1 + 3 + 5) ){
- int nNew = p->nAlloc * 2;
+ sqlite3_int64 nNew = p->nAlloc * 2;
Fts5HashEntry *pNew;
Fts5HashEntry **pp;
- pNew = (Fts5HashEntry*)sqlite3_realloc(p, nNew);
+ pNew = (Fts5HashEntry*)sqlite3_realloc64(p, nNew);
if( pNew==0 ) return SQLITE_NOMEM;
- pNew->nAlloc = nNew;
+ pNew->nAlloc = (int)nNew;
for(pp=&pHash->aSlot[iHash]; *pp!=p; pp=&(*pp)->pHashNext);
*pp = pNew;
p = pNew;
@@ -438,7 +438,7 @@ static int fts5HashEntrySort(
int i;
*ppSorted = 0;
- ap = sqlite3_malloc(sizeof(Fts5HashEntry*) * nMergeSlot);
+ ap = sqlite3_malloc64(sizeof(Fts5HashEntry*) * nMergeSlot);
if( !ap ) return SQLITE_NOMEM;
memset(ap, 0, sizeof(Fts5HashEntry*) * nMergeSlot);
@@ -483,7 +483,8 @@ int sqlite3Fts5HashQuery(
for(p=pHash->aSlot[iHash]; p; p=p->pHashNext){
zKey = fts5EntryKey(p);
- if( memcmp(zKey, pTerm, nTerm)==0 && zKey[nTerm]==0 ) break;
+ assert( p->nKey+1==(int)strlen(zKey) );
+ if( nTerm==p->nKey+1 && memcmp(zKey, pTerm, nTerm)==0 ) break;
}
if( p ){
@@ -534,4 +535,3 @@ void sqlite3Fts5HashScanEntry(
*pnDoclist = 0;
}
}
-
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 7cacf930cc8..bc85d864d79 100644
--- a/chromium/third_party/sqlite/src/ext/fts5/fts5_index.c
+++ b/chromium/third_party/sqlite/src/ext/fts5/fts5_index.c
@@ -512,7 +512,6 @@ struct Fts5Iter {
Fts5IndexIter base; /* Base class containing output vars */
Fts5Index *pIndex; /* Index that owns this iterator */
- Fts5Structure *pStruct; /* Database structure for this iterator */
Fts5Buffer poslist; /* Buffer containing current poslist */
Fts5Colset *pColset; /* Restrict matches to these columns */
@@ -573,7 +572,7 @@ static u16 fts5GetU16(const u8 *aIn){
** If an OOM error is encountered, return NULL and set the error code in
** the Fts5Index handle passed as the first argument.
*/
-static void *fts5IdxMalloc(Fts5Index *p, int nByte){
+static void *fts5IdxMalloc(Fts5Index *p, sqlite3_int64 nByte){
return sqlite3Fts5MallocZero(&p->rc, nByte);
}
@@ -607,7 +606,7 @@ static int fts5BufferCompareBlob(
*/
static int fts5BufferCompare(Fts5Buffer *pLeft, Fts5Buffer *pRight){
int nCmp = MIN(pLeft->n, pRight->n);
- int res = memcmp(pLeft->p, pRight->p, nCmp);
+ int res = fts5Memcmp(pLeft->p, pRight->p, nCmp);
return (res==0 ? (pLeft->n - pRight->n) : res);
}
@@ -673,8 +672,8 @@ static Fts5Data *fts5DataRead(Fts5Index *p, i64 iRowid){
if( rc==SQLITE_OK ){
u8 *aOut = 0; /* Read blob data into this buffer */
int nByte = sqlite3_blob_bytes(p->pReader);
- int nAlloc = sizeof(Fts5Data) + nByte + FTS5_DATA_PADDING;
- pRet = (Fts5Data*)sqlite3_malloc(nAlloc);
+ sqlite3_int64 nAlloc = sizeof(Fts5Data) + nByte + FTS5_DATA_PADDING;
+ pRet = (Fts5Data*)sqlite3_malloc64(nAlloc);
if( pRet ){
pRet->nn = nByte;
aOut = pRet->p = (u8*)&pRet[1];
@@ -690,6 +689,7 @@ static Fts5Data *fts5DataRead(Fts5Index *p, i64 iRowid){
pRet = 0;
}else{
/* TODO1: Fix this */
+ pRet->p[nByte] = 0x00;
pRet->szLeaf = fts5GetU16(&pRet->p[2]);
}
}
@@ -848,7 +848,7 @@ static int fts5StructureDecode(
int iLvl;
int nLevel = 0;
int nSegment = 0;
- int nByte; /* Bytes of space to allocate at pRet */
+ sqlite3_int64 nByte; /* Bytes of space to allocate at pRet */
Fts5Structure *pRet = 0; /* Structure object to return */
/* Grab the cookie value */
@@ -859,6 +859,11 @@ static int fts5StructureDecode(
** structure record. */
i += fts5GetVarint32(&pData[i], nLevel);
i += fts5GetVarint32(&pData[i], nSegment);
+ if( nLevel>FTS5_MAX_SEGMENT || nLevel<0
+ || nSegment>FTS5_MAX_SEGMENT || nSegment<0
+ ){
+ return FTS5_CORRUPT;
+ }
nByte = (
sizeof(Fts5Structure) + /* Main structure */
sizeof(Fts5StructureLevel) * (nLevel-1) /* aLevel[] array */
@@ -881,25 +886,35 @@ static int fts5StructureDecode(
}else{
i += fts5GetVarint32(&pData[i], pLvl->nMerge);
i += fts5GetVarint32(&pData[i], nTotal);
- assert( nTotal>=pLvl->nMerge );
+ if( nTotal<pLvl->nMerge ) rc = FTS5_CORRUPT;
pLvl->aSeg = (Fts5StructureSegment*)sqlite3Fts5MallocZero(&rc,
nTotal * sizeof(Fts5StructureSegment)
);
+ nSegment -= nTotal;
}
if( rc==SQLITE_OK ){
pLvl->nSeg = nTotal;
for(iSeg=0; iSeg<nTotal; iSeg++){
+ Fts5StructureSegment *pSeg = &pLvl->aSeg[iSeg];
if( i>=nData ){
rc = FTS5_CORRUPT;
break;
}
- i += fts5GetVarint32(&pData[i], pLvl->aSeg[iSeg].iSegid);
- i += fts5GetVarint32(&pData[i], pLvl->aSeg[iSeg].pgnoFirst);
- i += fts5GetVarint32(&pData[i], pLvl->aSeg[iSeg].pgnoLast);
+ i += fts5GetVarint32(&pData[i], pSeg->iSegid);
+ i += fts5GetVarint32(&pData[i], pSeg->pgnoFirst);
+ i += fts5GetVarint32(&pData[i], pSeg->pgnoLast);
+ if( pSeg->pgnoLast<pSeg->pgnoFirst ){
+ rc = FTS5_CORRUPT;
+ break;
+ }
}
+ if( iLvl>0 && pLvl[-1].nMerge && nTotal==0 ) rc = FTS5_CORRUPT;
+ if( iLvl==nLevel-1 && pLvl->nMerge ) rc = FTS5_CORRUPT;
}
}
+ if( nSegment!=0 && rc==SQLITE_OK ) rc = FTS5_CORRUPT;
+
if( rc!=SQLITE_OK ){
fts5StructureRelease(pRet);
pRet = 0;
@@ -917,12 +932,12 @@ static void fts5StructureAddLevel(int *pRc, Fts5Structure **ppStruct){
if( *pRc==SQLITE_OK ){
Fts5Structure *pStruct = *ppStruct;
int nLevel = pStruct->nLevel;
- int nByte = (
+ sqlite3_int64 nByte = (
sizeof(Fts5Structure) + /* Main structure */
sizeof(Fts5StructureLevel) * (nLevel+1) /* aLevel[] array */
);
- pStruct = sqlite3_realloc(pStruct, nByte);
+ pStruct = sqlite3_realloc64(pStruct, nByte);
if( pStruct ){
memset(&pStruct->aLevel[nLevel], 0, sizeof(Fts5StructureLevel));
pStruct->nLevel++;
@@ -947,10 +962,10 @@ static void fts5StructureExtendLevel(
if( *pRc==SQLITE_OK ){
Fts5StructureLevel *pLvl = &pStruct->aLevel[iLvl];
Fts5StructureSegment *aNew;
- int nByte;
+ sqlite3_int64 nByte;
nByte = (pLvl->nSeg + nExtra) * sizeof(Fts5StructureSegment);
- aNew = sqlite3_realloc(pLvl->aSeg, nByte);
+ aNew = sqlite3_realloc64(pLvl->aSeg, nByte);
if( aNew ){
if( bInsert==0 ){
memset(&aNew[pLvl->nSeg], 0, sizeof(Fts5StructureSegment) * nExtra);
@@ -1464,10 +1479,10 @@ static Fts5DlidxIter *fts5DlidxIterInit(
int bDone = 0;
for(i=0; p->rc==SQLITE_OK && bDone==0; i++){
- int nByte = sizeof(Fts5DlidxIter) + i * sizeof(Fts5DlidxLvl);
+ sqlite3_int64 nByte = sizeof(Fts5DlidxIter) + i * sizeof(Fts5DlidxLvl);
Fts5DlidxIter *pNew;
- pNew = (Fts5DlidxIter*)sqlite3_realloc(pIter, nByte);
+ pNew = (Fts5DlidxIter*)sqlite3_realloc64(pIter, nByte);
if( pNew==0 ){
p->rc = SQLITE_NOMEM;
}else{
@@ -1637,12 +1652,13 @@ static void fts5SegIterLoadTerm(Fts5Index *p, Fts5SegIter *pIter, int nKeep){
int nNew; /* Bytes of new data */
iOff += fts5GetVarint32(&a[iOff], nNew);
- if( iOff+nNew>pIter->pLeaf->nn ){
+ if( iOff+nNew>pIter->pLeaf->szLeaf || nKeep>pIter->term.n || nNew==0 ){
p->rc = FTS5_CORRUPT;
return;
}
pIter->term.n = nKeep;
fts5BufferAppendBlob(&p->rc, &pIter->term, nNew, &a[iOff]);
+ assert( pIter->term.n<=pIter->term.nSpace );
iOff += nNew;
pIter->iTermLeafOffset = iOff;
pIter->iTermLeafPgno = pIter->iLeafPgno;
@@ -1707,7 +1723,7 @@ static void fts5SegIterInit(
if( p->rc==SQLITE_OK ){
pIter->iLeafOffset = 4;
assert_nc( pIter->pLeaf->nn>4 );
- assert( fts5LeafFirstTermOff(pIter->pLeaf)==4 );
+ assert_nc( fts5LeafFirstTermOff(pIter->pLeaf)==4 );
pIter->iPgidxOff = pIter->pLeaf->szLeaf+1;
fts5SegIterLoadTerm(p, pIter, 0);
fts5SegIterLoadNPos(p, pIter);
@@ -1763,7 +1779,7 @@ static void fts5SegIterReverseInitPage(Fts5Index *p, Fts5SegIter *pIter){
/* If necessary, grow the pIter->aRowidOffset[] array. */
if( iRowidOffset>=pIter->nRowidOffset ){
int nNew = pIter->nRowidOffset + 8;
- int *aNew = (int*)sqlite3_realloc(pIter->aRowidOffset, nNew*sizeof(int));
+ int *aNew = (int*)sqlite3_realloc64(pIter->aRowidOffset,nNew*sizeof(int));
if( aNew==0 ){
p->rc = SQLITE_NOMEM;
break;
@@ -2217,10 +2233,10 @@ static void fts5LeafSeek(
int szLeaf = pIter->pLeaf->szLeaf;
int n = pIter->pLeaf->nn;
- int nMatch = 0;
- int nKeep = 0;
- int nNew = 0;
- int iTermOff;
+ u32 nMatch = 0;
+ u32 nKeep = 0;
+ u32 nNew = 0;
+ u32 iTermOff;
int iPgidx; /* Current offset in pgidx */
int bEndOfPage = 0;
@@ -2244,15 +2260,15 @@ static void fts5LeafSeek(
assert( nKeep>=nMatch );
if( nKeep==nMatch ){
- int nCmp;
- int i;
- nCmp = MIN(nNew, nTerm-nMatch);
+ u32 nCmp;
+ u32 i;
+ nCmp = (u32)MIN(nNew, nTerm-nMatch);
for(i=0; i<nCmp; i++){
if( a[iOff+i]!=pTerm[nMatch+i] ) break;
}
nMatch += i;
- if( nTerm==nMatch ){
+ if( (u32)nTerm==nMatch ){
if( i==nNew ){
goto search_success;
}else{
@@ -2296,6 +2312,7 @@ static void fts5LeafSeek(
iPgidx += fts5GetVarint32(&pIter->pLeaf->p[iPgidx], iOff);
if( iOff<4 || iOff>=pIter->pLeaf->szLeaf ){
p->rc = FTS5_CORRUPT;
+ return;
}else{
nKeep = 0;
iTermOff = iOff;
@@ -2308,8 +2325,11 @@ static void fts5LeafSeek(
}
search_success:
-
pIter->iLeafOffset = iOff + nNew;
+ if( pIter->iLeafOffset>n || nNew<1 ){
+ p->rc = FTS5_CORRUPT;
+ return;
+ }
pIter->iTermLeafOffset = pIter->iLeafOffset;
pIter->iTermLeafPgno = pIter->iLeafPgno;
@@ -2416,7 +2436,7 @@ static void fts5SegIterSeekInit(
** 4) the FTS5INDEX_QUERY_SCAN flag was set and the iterator points
** to an entry with a term greater than or equal to (pTerm/nTerm).
*/
- assert( p->rc!=SQLITE_OK /* 1 */
+ assert_nc( p->rc!=SQLITE_OK /* 1 */
|| pIter->pLeaf==0 /* 2 */
|| fts5BufferCompareBlob(&pIter->term, pTerm, nTerm)==0 /* 3 */
|| (bGe && fts5BufferCompareBlob(&pIter->term, pTerm, nTerm)>0) /* 4 */
@@ -2514,7 +2534,7 @@ static void fts5AssertComparisonResult(
assert( pRes->iFirst==i1 );
}else{
int nMin = MIN(p1->term.n, p2->term.n);
- int res = memcmp(p1->term.p, p2->term.p, nMin);
+ int res = fts5Memcmp(p1->term.p, p2->term.p, nMin);
if( res==0 ) res = p1->term.n - p2->term.n;
if( res==0 ){
@@ -2737,7 +2757,6 @@ static void fts5MultiIterFree(Fts5Iter *pIter){
for(i=0; i<pIter->nSeg; i++){
fts5SegIterClear(&pIter->aSeg[i]);
}
- fts5StructureRelease(pIter->pStruct);
fts5BufferFree(&pIter->poslist);
sqlite3_free(pIter);
}
@@ -3085,7 +3104,8 @@ static void fts5SegiterPoslist(
Fts5Colset *pColset,
Fts5Buffer *pBuf
){
- if( 0==fts5BufferGrow(&p->rc, pBuf, pSeg->nPos) ){
+ if( 0==fts5BufferGrow(&p->rc, pBuf, pSeg->nPos+FTS5_DATA_ZERO_PADDING) ){
+ memset(&pBuf->p[pBuf->n+pSeg->nPos], 0, FTS5_DATA_ZERO_PADDING);
if( pColset==0 ){
fts5ChunkIterate(p, pSeg, (void*)pBuf, fts5PoslistCallback);
}else{
@@ -3383,9 +3403,7 @@ static void fts5MultiIterNew(
if( pNew==0 ) return;
pNew->bRev = (0!=(flags & FTS5INDEX_QUERY_DESC));
pNew->bSkipEmpty = (0!=(flags & FTS5INDEX_QUERY_SKIPEMPTY));
- pNew->pStruct = pStruct;
pNew->pColset = pColset;
- fts5StructureRef(pStruct);
if( (flags & FTS5INDEX_QUERY_NOOUTPUT)==0 ){
fts5IterSetOutputCb(&p->rc, pNew);
}
@@ -3563,24 +3581,24 @@ static int fts5AllocateSegid(Fts5Index *p, Fts5Structure *pStruct){
for(iLvl=0; iLvl<pStruct->nLevel; iLvl++){
for(iSeg=0; iSeg<pStruct->aLevel[iLvl].nSeg; iSeg++){
int iId = pStruct->aLevel[iLvl].aSeg[iSeg].iSegid;
- if( iId<=FTS5_MAX_SEGMENT ){
- aUsed[(iId-1) / 32] |= 1 << ((iId-1) % 32);
+ if( iId<=FTS5_MAX_SEGMENT && iId>0 ){
+ aUsed[(iId-1) / 32] |= (u32)1 << ((iId-1) % 32);
}
}
}
for(i=0; aUsed[i]==0xFFFFFFFF; i++);
mask = aUsed[i];
- for(iSegid=0; mask & (1 << iSegid); iSegid++);
+ for(iSegid=0; mask & ((u32)1 << iSegid); iSegid++);
iSegid += 1 + i*32;
#ifdef SQLITE_DEBUG
for(iLvl=0; iLvl<pStruct->nLevel; iLvl++){
for(iSeg=0; iSeg<pStruct->aLevel[iLvl].nSeg; iSeg++){
- assert( iSegid!=pStruct->aLevel[iLvl].aSeg[iSeg].iSegid );
+ assert_nc( iSegid!=pStruct->aLevel[iLvl].aSeg[iSeg].iSegid );
}
}
- assert( iSegid>0 && iSegid<=FTS5_MAX_SEGMENT );
+ assert_nc( iSegid>0 && iSegid<=FTS5_MAX_SEGMENT );
{
sqlite3_stmt *pIdxSelect = fts5IdxSelectStmt(p);
@@ -3588,7 +3606,7 @@ static int fts5AllocateSegid(Fts5Index *p, Fts5Structure *pStruct){
u8 aBlob[2] = {0xff, 0xff};
sqlite3_bind_int(pIdxSelect, 1, iSegid);
sqlite3_bind_blob(pIdxSelect, 2, aBlob, 2, SQLITE_STATIC);
- assert( sqlite3_step(pIdxSelect)!=SQLITE_ROW );
+ assert_nc( sqlite3_step(pIdxSelect)!=SQLITE_ROW );
p->rc = sqlite3_reset(pIdxSelect);
sqlite3_bind_null(pIdxSelect, 2);
}
@@ -3658,7 +3676,7 @@ static int fts5WriteDlidxGrow(
int nLvl
){
if( p->rc==SQLITE_OK && nLvl>=pWriter->nDlidx ){
- Fts5DlidxWriter *aDlidx = (Fts5DlidxWriter*)sqlite3_realloc(
+ Fts5DlidxWriter *aDlidx = (Fts5DlidxWriter*)sqlite3_realloc64(
pWriter->aDlidx, sizeof(Fts5DlidxWriter) * nLvl
);
if( aDlidx==0 ){
@@ -3737,8 +3755,10 @@ static void fts5WriteBtreeTerm(
int nTerm, const u8 *pTerm /* First term on new page */
){
fts5WriteFlushBtree(p, pWriter);
- fts5BufferSet(&p->rc, &pWriter->btterm, nTerm, pTerm);
- pWriter->iBtPage = pWriter->writer.pgno;
+ if( p->rc==SQLITE_OK ){
+ fts5BufferSet(&p->rc, &pWriter->btterm, nTerm, pTerm);
+ pWriter->iBtPage = pWriter->writer.pgno;
+ }
}
/*
@@ -3889,6 +3909,7 @@ static void fts5WriteAppendTerm(
int nPrefix; /* Bytes of prefix compression for term */
Fts5PageWriter *pPage = &pWriter->writer;
Fts5Buffer *pPgidx = &pWriter->writer.pgidx;
+ int nMin = MIN(pPage->term.n, nTerm);
assert( p->rc==SQLITE_OK );
assert( pPage->buf.n>=4 );
@@ -3898,6 +3919,7 @@ static void fts5WriteAppendTerm(
if( (pPage->buf.n + pPgidx->n + nTerm + 2)>=p->pConfig->pgsz ){
if( pPage->buf.n>4 ){
fts5WriteFlushLeaf(p, pWriter);
+ if( p->rc!=SQLITE_OK ) return;
}
fts5BufferGrow(&p->rc, &pPage->buf, nTerm+FTS5_DATA_PADDING);
}
@@ -3930,13 +3952,14 @@ static void fts5WriteAppendTerm(
** inefficient, but still correct. */
int n = nTerm;
if( pPage->term.n ){
- n = 1 + fts5PrefixCompress(pPage->term.n, pPage->term.p, pTerm);
+ n = 1 + fts5PrefixCompress(nMin, pPage->term.p, pTerm);
}
fts5WriteBtreeTerm(p, pWriter, n, pTerm);
+ if( p->rc!=SQLITE_OK ) return;
pPage = &pWriter->writer;
}
}else{
- nPrefix = fts5PrefixCompress(pPage->term.n, pPage->term.p, pTerm);
+ nPrefix = fts5PrefixCompress(nMin, pPage->term.p, pTerm);
fts5BufferAppendVarint(&p->rc, &pPage->buf, nPrefix);
}
@@ -3983,7 +4006,7 @@ static void fts5WriteAppendRowid(
if( pWriter->bFirstRowidInDoclist || pWriter->bFirstRowidInPage ){
fts5BufferAppendVarint(&p->rc, &pPage->buf, iRowid);
}else{
- assert( p->rc || iRowid>pWriter->iPrevRowid );
+ assert_nc( p->rc || iRowid>pWriter->iPrevRowid );
fts5BufferAppendVarint(&p->rc, &pPage->buf, iRowid - pWriter->iPrevRowid);
}
pWriter->iPrevRowid = iRowid;
@@ -4105,7 +4128,7 @@ static void fts5TrimSegments(Fts5Index *p, Fts5Iter *pIter){
int i;
Fts5Buffer buf;
memset(&buf, 0, sizeof(Fts5Buffer));
- for(i=0; i<pIter->nSeg; i++){
+ for(i=0; i<pIter->nSeg && p->rc==SQLITE_OK; i++){
Fts5SegIter *pSeg = &pIter->aSeg[i];
if( pSeg->pSeg==0 ){
/* no-op */
@@ -4123,35 +4146,43 @@ static void fts5TrimSegments(Fts5Index *p, Fts5Iter *pIter){
u8 aHdr[4] = {0x00, 0x00, 0x00, 0x00};
iLeafRowid = FTS5_SEGMENT_ROWID(iId, pSeg->iTermLeafPgno);
- pData = fts5DataRead(p, iLeafRowid);
+ pData = fts5LeafRead(p, iLeafRowid);
if( pData ){
- fts5BufferZero(&buf);
- fts5BufferGrow(&p->rc, &buf, pData->nn);
- fts5BufferAppendBlob(&p->rc, &buf, sizeof(aHdr), aHdr);
- fts5BufferAppendVarint(&p->rc, &buf, pSeg->term.n);
- fts5BufferAppendBlob(&p->rc, &buf, pSeg->term.n, pSeg->term.p);
- fts5BufferAppendBlob(&p->rc, &buf, pData->szLeaf-iOff, &pData->p[iOff]);
- if( p->rc==SQLITE_OK ){
- /* Set the szLeaf field */
- fts5PutU16(&buf.p[2], (u16)buf.n);
- }
+ if( iOff>pData->szLeaf ){
+ /* This can occur if the pages that the segments occupy overlap - if
+ ** a single page has been assigned to more than one segment. In
+ ** this case a prior iteration of this loop may have corrupted the
+ ** segment currently being trimmed. */
+ p->rc = FTS5_CORRUPT;
+ }else{
+ fts5BufferZero(&buf);
+ fts5BufferGrow(&p->rc, &buf, pData->nn);
+ fts5BufferAppendBlob(&p->rc, &buf, sizeof(aHdr), aHdr);
+ fts5BufferAppendVarint(&p->rc, &buf, pSeg->term.n);
+ fts5BufferAppendBlob(&p->rc, &buf, pSeg->term.n, pSeg->term.p);
+ fts5BufferAppendBlob(&p->rc, &buf, pData->szLeaf-iOff,&pData->p[iOff]);
+ if( p->rc==SQLITE_OK ){
+ /* Set the szLeaf field */
+ fts5PutU16(&buf.p[2], (u16)buf.n);
+ }
- /* Set up the new page-index array */
- fts5BufferAppendVarint(&p->rc, &buf, 4);
- if( pSeg->iLeafPgno==pSeg->iTermLeafPgno
- && pSeg->iEndofDoclist<pData->szLeaf
- ){
- int nDiff = pData->szLeaf - pSeg->iEndofDoclist;
- fts5BufferAppendVarint(&p->rc, &buf, buf.n - 1 - nDiff - 4);
- fts5BufferAppendBlob(&p->rc, &buf,
- pData->nn - pSeg->iPgidxOff, &pData->p[pSeg->iPgidxOff]
- );
- }
+ /* Set up the new page-index array */
+ fts5BufferAppendVarint(&p->rc, &buf, 4);
+ if( pSeg->iLeafPgno==pSeg->iTermLeafPgno
+ && pSeg->iEndofDoclist<pData->szLeaf
+ ){
+ int nDiff = pData->szLeaf - pSeg->iEndofDoclist;
+ fts5BufferAppendVarint(&p->rc, &buf, buf.n - 1 - nDiff - 4);
+ fts5BufferAppendBlob(&p->rc, &buf,
+ pData->nn - pSeg->iPgidxOff, &pData->p[pSeg->iPgidxOff]
+ );
+ }
+ pSeg->pSeg->pgnoFirst = pSeg->iTermLeafPgno;
+ fts5DataDelete(p, FTS5_SEGMENT_ROWID(iId, 1), iLeafRowid);
+ fts5DataWrite(p, iLeafRowid, buf.p, buf.n);
+ }
fts5DataRelease(pData);
- pSeg->pSeg->pgnoFirst = pSeg->iTermLeafPgno;
- fts5DataDelete(p, FTS5_SEGMENT_ROWID(iId, 1), iLeafRowid);
- fts5DataWrite(p, iLeafRowid, buf.p, buf.n);
}
}
}
@@ -4243,7 +4274,7 @@ static void fts5IndexMergeLevel(
const u8 *pTerm;
pTerm = fts5MultiIterTerm(pIter, &nTerm);
- if( nTerm!=term.n || memcmp(pTerm, term.p, nTerm) ){
+ if( nTerm!=term.n || fts5Memcmp(pTerm, term.p, nTerm) ){
if( pnRem && writer.nLeafWritten>nRem ){
break;
}
@@ -4498,6 +4529,7 @@ static void fts5FlushOneHash(Fts5Index *p){
/* Write the term for this entry to disk. */
sqlite3Fts5HashScanEntry(pHash, &zTerm, &pDoclist, &nDoclist);
fts5WriteAppendTerm(p, &writer, (int)strlen(zTerm), (const u8*)zTerm);
+ if( p->rc!=SQLITE_OK ) break;
assert( writer.bFirstRowidInPage==0 );
if( pgsz>=(pBuf->n + pPgidx->n + nDoclist + 1) ){
@@ -4520,6 +4552,7 @@ static void fts5FlushOneHash(Fts5Index *p){
pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], iRowid);
writer.bFirstRowidInPage = 0;
fts5WriteDlidxAppend(p, &writer, iRowid);
+ if( p->rc!=SQLITE_OK ) break;
}else{
pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], iDelta);
}
@@ -4577,7 +4610,7 @@ static void fts5FlushOneHash(Fts5Index *p){
/* TODO2: Doclist terminator written here. */
/* pBuf->p[pBuf->n++] = '\0'; */
assert( pBuf->n<=pBuf->nSpace );
- sqlite3Fts5HashScanNext(pHash);
+ if( p->rc==SQLITE_OK ) sqlite3Fts5HashScanNext(pHash);
}
sqlite3Fts5HashClear(pHash);
fts5WriteFinish(p, &writer, &pgnoLast);
@@ -4621,7 +4654,7 @@ static Fts5Structure *fts5IndexOptimizeStruct(
Fts5Structure *pStruct
){
Fts5Structure *pNew = 0;
- int nByte = sizeof(Fts5Structure);
+ sqlite3_int64 nByte = sizeof(Fts5Structure);
int nSeg = pStruct->nSegment;
int i;
@@ -4751,11 +4784,13 @@ static void fts5AppendPoslist(
Fts5Buffer *pBuf
){
int nData = pMulti->base.nData;
+ int nByte = nData + 9 + 9 + FTS5_DATA_ZERO_PADDING;
assert( nData>0 );
- if( p->rc==SQLITE_OK && 0==fts5BufferGrow(&p->rc, pBuf, nData+9+9) ){
+ if( p->rc==SQLITE_OK && 0==fts5BufferGrow(&p->rc, pBuf, nByte) ){
fts5BufferSafeAppendVarint(pBuf, iDelta);
fts5BufferSafeAppendVarint(pBuf, nData*2);
fts5BufferSafeAppendBlob(pBuf, pMulti->base.pData, nData);
+ memset(&pBuf->p[pBuf->n], 0, FTS5_DATA_ZERO_PADDING);
}
}
@@ -4936,6 +4971,8 @@ static void fts5MergePrefixLists(
int iOff2 = 0;
u8 *a1 = &i1.aPoslist[i1.nSize];
u8 *a2 = &i2.aPoslist[i2.nSize];
+ int nCopy;
+ u8 *aCopy;
i64 iPrev = 0;
Fts5PoslistWriter writer;
@@ -4967,7 +5004,7 @@ static void fts5MergePrefixLists(
sqlite3Fts5PoslistNext64(a1, i1.nPoslist, &iOff1, &iPos1);
if( iPos1<0 ) break;
}else{
- assert( iPos2!=iPrev );
+ assert_nc( iPos2!=iPrev );
sqlite3Fts5PoslistSafeAppend(&tmp, &iPrev, iPos2);
sqlite3Fts5PoslistNext64(a2, i2.nPoslist, &iOff2, &iPos2);
if( iPos2<0 ) break;
@@ -4979,11 +5016,16 @@ static void fts5MergePrefixLists(
if( iPos1!=iPrev ){
sqlite3Fts5PoslistSafeAppend(&tmp, &iPrev, iPos1);
}
- fts5BufferSafeAppendBlob(&tmp, &a1[iOff1], i1.nPoslist-iOff1);
+ aCopy = &a1[iOff1];
+ nCopy = i1.nPoslist - iOff1;
}else{
assert( iPos2>=0 && iPos2!=iPrev );
sqlite3Fts5PoslistSafeAppend(&tmp, &iPrev, iPos2);
- fts5BufferSafeAppendBlob(&tmp, &a2[iOff2], i2.nPoslist-iOff2);
+ aCopy = &a2[iOff2];
+ nCopy = i2.nPoslist - iOff2;
+ }
+ if( nCopy>0 ){
+ fts5BufferSafeAppendBlob(&tmp, aCopy, nCopy);
}
/* WRITEPOSLISTSIZE */
@@ -4991,6 +5033,7 @@ static void fts5MergePrefixLists(
fts5BufferSafeAppendBlob(&out, tmp.p, tmp.n);
fts5DoclistIterNext(&i1);
fts5DoclistIterNext(&i2);
+ assert( out.n<=(p1->n+p2->n+9) );
if( i1.aPoslist==0 || i2.aPoslist==0 ) break;
}
}
@@ -5092,7 +5135,7 @@ static void fts5SetupPrefixIter(
}
fts5MultiIterFree(p1);
- pData = fts5IdxMalloc(p, sizeof(Fts5Data) + doclist.n);
+ pData = fts5IdxMalloc(p, sizeof(Fts5Data)+doclist.n+FTS5_DATA_ZERO_PADDING);
if( pData ){
pData->p = (u8*)&pData[1];
pData->nn = pData->szLeaf = doclist.n;
@@ -5854,11 +5897,11 @@ static void fts5IndexIntegrityCheckSegment(
iOff = fts5LeafFirstTermOff(pLeaf);
iRowidOff = fts5LeafFirstRowidOff(pLeaf);
- if( iRowidOff>=iOff ){
+ if( iRowidOff>=iOff || iOff>=pLeaf->szLeaf ){
p->rc = FTS5_CORRUPT;
}else{
iOff += fts5GetVarint32(&pLeaf->p[iOff], nTerm);
- res = memcmp(&pLeaf->p[iOff], zIdxTerm, MIN(nTerm, nIdxTerm));
+ res = fts5Memcmp(&pLeaf->p[iOff], zIdxTerm, MIN(nTerm, nIdxTerm));
if( res==0 ) res = nTerm - nIdxTerm;
if( res<0 ) p->rc = FTS5_CORRUPT;
}
@@ -6253,7 +6296,7 @@ static void fts5DecodeFunction(
u8 *a = 0;
Fts5Buffer s; /* Build up text to return here */
int rc = SQLITE_OK; /* Return code */
- int nSpace = 0;
+ sqlite3_int64 nSpace = 0;
int eDetailNone = (sqlite3_user_data(pCtx)!=0);
assert( nArg==2 );
@@ -6269,8 +6312,7 @@ static void fts5DecodeFunction(
nSpace = n + FTS5_DATA_ZERO_PADDING;
a = (u8*)sqlite3Fts5MallocZero(&rc, nSpace);
if( a==0 ) goto decode_out;
- memcpy(a, aBlob, n);
-
+ if( n>0 ) memcpy(a, aBlob, n);
fts5DecodeRowid(iRowid, &iSegid, &bDlidx, &iHeight, &iPgno);
@@ -6365,6 +6407,9 @@ static void fts5DecodeFunction(
iPgidxOff = szLeaf = fts5GetU16(&a[2]);
if( iPgidxOff<n ){
fts5GetVarint32(&a[iPgidxOff], iTermOff);
+ }else if( iPgidxOff>n ){
+ rc = FTS5_CORRUPT;
+ goto decode_out;
}
}
@@ -6376,14 +6421,22 @@ static void fts5DecodeFunction(
}else{
iOff = szLeaf;
}
+ if( iOff>n ){
+ rc = FTS5_CORRUPT;
+ goto decode_out;
+ }
fts5DecodePoslist(&rc, &s, &a[4], iOff-4);
/* Decode any more doclist data that appears on the page before the
** first term. */
nDoclist = (iTermOff ? iTermOff : szLeaf) - iOff;
+ if( nDoclist+iOff>n ){
+ rc = FTS5_CORRUPT;
+ goto decode_out;
+ }
fts5DecodeDoclist(&rc, &s, &a[iOff], nDoclist);
- while( iPgidxOff<n ){
+ while( iPgidxOff<n && rc==SQLITE_OK ){
int bFirst = (iPgidxOff==szLeaf); /* True for first term on page */
int nByte; /* Bytes of data */
int iEnd;
@@ -6398,12 +6451,24 @@ static void fts5DecodeFunction(
}else{
iEnd = szLeaf;
}
+ if( iEnd>szLeaf ){
+ rc = FTS5_CORRUPT;
+ break;
+ }
if( bFirst==0 ){
iOff += fts5GetVarint32(&a[iOff], nByte);
+ if( nByte>term.n ){
+ rc = FTS5_CORRUPT;
+ break;
+ }
term.n = nByte;
}
iOff += fts5GetVarint32(&a[iOff], nByte);
+ if( iOff+nByte>n ){
+ rc = FTS5_CORRUPT;
+ break;
+ }
fts5BufferAppendBlob(&rc, &term, nByte, &a[iOff]);
iOff += nByte;
diff --git a/chromium/third_party/sqlite/src/ext/fts5/fts5_main.c b/chromium/third_party/sqlite/src/ext/fts5/fts5_main.c
index 9c10405c627..8d4ddabb46c 100644
--- a/chromium/third_party/sqlite/src/ext/fts5/fts5_main.c
+++ b/chromium/third_party/sqlite/src/ext/fts5/fts5_main.c
@@ -28,8 +28,8 @@ int sqlite3_fts5_may_be_corrupt = 1;
typedef struct Fts5Auxdata Fts5Auxdata;
typedef struct Fts5Auxiliary Fts5Auxiliary;
typedef struct Fts5Cursor Fts5Cursor;
+typedef struct Fts5FullTable Fts5FullTable;
typedef struct Fts5Sorter Fts5Sorter;
-typedef struct Fts5Table Fts5Table;
typedef struct Fts5TokenizerModule Fts5TokenizerModule;
/*
@@ -110,13 +110,8 @@ struct Fts5TokenizerModule {
Fts5TokenizerModule *pNext; /* Next registered tokenizer module */
};
-/*
-** Virtual-table object.
-*/
-struct Fts5Table {
- sqlite3_vtab base; /* Base class used by SQLite core */
- Fts5Config *pConfig; /* Virtual table configuration */
- Fts5Index *pIndex; /* Full-text index */
+struct Fts5FullTable {
+ Fts5Table p; /* Public class members from fts5Int.h */
Fts5Storage *pStorage; /* Document store */
Fts5Global *pGlobal; /* Global (connection wide) data */
Fts5Cursor *pSortCsr; /* Sort data from this cursor */
@@ -254,7 +249,7 @@ struct Fts5Auxdata {
#define FTS5_SAVEPOINT 5
#define FTS5_RELEASE 6
#define FTS5_ROLLBACKTO 7
-static void fts5CheckTransactionState(Fts5Table *p, int op, int iSavepoint){
+static void fts5CheckTransactionState(Fts5FullTable *p, int op, int iSavepoint){
switch( op ){
case FTS5_BEGIN:
assert( p->ts.eState==0 );
@@ -293,7 +288,7 @@ static void fts5CheckTransactionState(Fts5Table *p, int op, int iSavepoint){
case FTS5_ROLLBACKTO:
assert( p->ts.eState==1 );
- assert( iSavepoint>=0 );
+ assert( iSavepoint>=-1 );
assert( iSavepoint<=p->ts.iSavepoint );
p->ts.iSavepoint = iSavepoint;
break;
@@ -306,18 +301,18 @@ static void fts5CheckTransactionState(Fts5Table *p, int op, int iSavepoint){
/*
** Return true if pTab is a contentless table.
*/
-static int fts5IsContentless(Fts5Table *pTab){
- return pTab->pConfig->eContent==FTS5_CONTENT_NONE;
+static int fts5IsContentless(Fts5FullTable *pTab){
+ return pTab->p.pConfig->eContent==FTS5_CONTENT_NONE;
}
/*
** Delete a virtual table handle allocated by fts5InitVtab().
*/
-static void fts5FreeVtab(Fts5Table *pTab){
+static void fts5FreeVtab(Fts5FullTable *pTab){
if( pTab ){
- sqlite3Fts5IndexClose(pTab->pIndex);
+ sqlite3Fts5IndexClose(pTab->p.pIndex);
sqlite3Fts5StorageClose(pTab->pStorage);
- sqlite3Fts5ConfigFree(pTab->pConfig);
+ sqlite3Fts5ConfigFree(pTab->p.pConfig);
sqlite3_free(pTab);
}
}
@@ -326,7 +321,7 @@ static void fts5FreeVtab(Fts5Table *pTab){
** The xDisconnect() virtual table method.
*/
static int fts5DisconnectMethod(sqlite3_vtab *pVtab){
- fts5FreeVtab((Fts5Table*)pVtab);
+ fts5FreeVtab((Fts5FullTable*)pVtab);
return SQLITE_OK;
}
@@ -337,7 +332,7 @@ static int fts5DestroyMethod(sqlite3_vtab *pVtab){
Fts5Table *pTab = (Fts5Table*)pVtab;
int rc = sqlite3Fts5DropAll(pTab->pConfig);
if( rc==SQLITE_OK ){
- fts5FreeVtab((Fts5Table*)pVtab);
+ fts5FreeVtab((Fts5FullTable*)pVtab);
}
return rc;
}
@@ -366,28 +361,28 @@ static int fts5InitVtab(
const char **azConfig = (const char**)argv;
int rc = SQLITE_OK; /* Return code */
Fts5Config *pConfig = 0; /* Results of parsing argc/argv */
- Fts5Table *pTab = 0; /* New virtual table object */
+ Fts5FullTable *pTab = 0; /* New virtual table object */
/* Allocate the new vtab object and parse the configuration */
- pTab = (Fts5Table*)sqlite3Fts5MallocZero(&rc, sizeof(Fts5Table));
+ pTab = (Fts5FullTable*)sqlite3Fts5MallocZero(&rc, sizeof(Fts5FullTable));
if( rc==SQLITE_OK ){
rc = sqlite3Fts5ConfigParse(pGlobal, db, argc, azConfig, &pConfig, pzErr);
assert( (rc==SQLITE_OK && *pzErr==0) || pConfig==0 );
}
if( rc==SQLITE_OK ){
- pTab->pConfig = pConfig;
+ pTab->p.pConfig = pConfig;
pTab->pGlobal = pGlobal;
}
/* Open the index sub-system */
if( rc==SQLITE_OK ){
- rc = sqlite3Fts5IndexOpen(pConfig, bCreate, &pTab->pIndex, pzErr);
+ rc = sqlite3Fts5IndexOpen(pConfig, bCreate, &pTab->p.pIndex, pzErr);
}
/* Open the storage sub-system */
if( rc==SQLITE_OK ){
rc = sqlite3Fts5StorageOpen(
- pConfig, pTab->pIndex, bCreate, &pTab->pStorage, pzErr
+ pConfig, pTab->p.pIndex, bCreate, &pTab->pStorage, pzErr
);
}
@@ -400,8 +395,8 @@ static int fts5InitVtab(
if( rc==SQLITE_OK ){
assert( pConfig->pzErrmsg==0 );
pConfig->pzErrmsg = pzErr;
- rc = sqlite3Fts5IndexLoadConfig(pTab->pIndex);
- sqlite3Fts5IndexRollback(pTab->pIndex);
+ rc = sqlite3Fts5IndexLoadConfig(pTab->p.pIndex);
+ sqlite3Fts5IndexRollback(pTab->p.pIndex);
pConfig->pzErrmsg = 0;
}
@@ -614,7 +609,7 @@ static int fts5BestIndexMethod(sqlite3_vtab *pVTab, sqlite3_index_info *pInfo){
return SQLITE_OK;
}
-static int fts5NewTransaction(Fts5Table *pTab){
+static int fts5NewTransaction(Fts5FullTable *pTab){
Fts5Cursor *pCsr;
for(pCsr=pTab->pGlobal->pCsr; pCsr; pCsr=pCsr->pNext){
if( pCsr->base.pVtab==(sqlite3_vtab*)pTab ) return SQLITE_OK;
@@ -626,16 +621,16 @@ static int fts5NewTransaction(Fts5Table *pTab){
** Implementation of xOpen method.
*/
static int fts5OpenMethod(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCsr){
- Fts5Table *pTab = (Fts5Table*)pVTab;
- Fts5Config *pConfig = pTab->pConfig;
+ Fts5FullTable *pTab = (Fts5FullTable*)pVTab;
+ Fts5Config *pConfig = pTab->p.pConfig;
Fts5Cursor *pCsr = 0; /* New cursor object */
- int nByte; /* Bytes of space to allocate */
+ sqlite3_int64 nByte; /* Bytes of space to allocate */
int rc; /* Return code */
rc = fts5NewTransaction(pTab);
if( rc==SQLITE_OK ){
nByte = sizeof(Fts5Cursor) + pConfig->nCol * sizeof(int);
- pCsr = (Fts5Cursor*)sqlite3_malloc(nByte);
+ pCsr = (Fts5Cursor*)sqlite3_malloc64(nByte);
if( pCsr ){
Fts5Global *pGlobal = pTab->pGlobal;
memset(pCsr, 0, nByte);
@@ -673,7 +668,7 @@ static void fts5CsrNewrow(Fts5Cursor *pCsr){
}
static void fts5FreeCursorComponents(Fts5Cursor *pCsr){
- Fts5Table *pTab = (Fts5Table*)(pCsr->base.pVtab);
+ Fts5FullTable *pTab = (Fts5FullTable*)(pCsr->base.pVtab);
Fts5Auxdata *pData;
Fts5Auxdata *pNext;
@@ -717,7 +712,7 @@ static void fts5FreeCursorComponents(Fts5Cursor *pCsr){
*/
static int fts5CloseMethod(sqlite3_vtab_cursor *pCursor){
if( pCursor ){
- Fts5Table *pTab = (Fts5Table*)(pCursor->pVtab);
+ Fts5FullTable *pTab = (Fts5FullTable*)(pCursor->pVtab);
Fts5Cursor *pCsr = (Fts5Cursor*)pCursor;
Fts5Cursor **pp;
@@ -774,7 +769,7 @@ static int fts5SorterNext(Fts5Cursor *pCsr){
** Set the FTS5CSR_REQUIRE_RESEEK flag on all FTS5_PLAN_MATCH cursors
** open on table pTab.
*/
-static void fts5TripCursors(Fts5Table *pTab){
+static void fts5TripCursors(Fts5FullTable *pTab){
Fts5Cursor *pCsr;
for(pCsr=pTab->pGlobal->pCsr; pCsr; pCsr=pCsr->pNext){
if( pCsr->ePlan==FTS5_PLAN_MATCH
@@ -801,11 +796,11 @@ static int fts5CursorReseek(Fts5Cursor *pCsr, int *pbSkip){
int rc = SQLITE_OK;
assert( *pbSkip==0 );
if( CsrFlagTest(pCsr, FTS5CSR_REQUIRE_RESEEK) ){
- Fts5Table *pTab = (Fts5Table*)(pCsr->base.pVtab);
+ Fts5FullTable *pTab = (Fts5FullTable*)(pCsr->base.pVtab);
int bDesc = pCsr->bDesc;
i64 iRowid = sqlite3Fts5ExprRowid(pCsr->pExpr);
- rc = sqlite3Fts5ExprFirst(pCsr->pExpr, pTab->pIndex, iRowid, bDesc);
+ rc = sqlite3Fts5ExprFirst(pCsr->pExpr, pTab->p.pIndex, iRowid, bDesc);
if( rc==SQLITE_OK && iRowid!=sqlite3Fts5ExprRowid(pCsr->pExpr) ){
*pbSkip = 1;
}
@@ -902,18 +897,22 @@ static int fts5PrepareStatement(
return rc;
}
-static int fts5CursorFirstSorted(Fts5Table *pTab, Fts5Cursor *pCsr, int bDesc){
- Fts5Config *pConfig = pTab->pConfig;
+static int fts5CursorFirstSorted(
+ Fts5FullTable *pTab,
+ Fts5Cursor *pCsr,
+ int bDesc
+){
+ Fts5Config *pConfig = pTab->p.pConfig;
Fts5Sorter *pSorter;
int nPhrase;
- int nByte;
+ sqlite3_int64 nByte;
int rc;
const char *zRank = pCsr->zRank;
const char *zRankArgs = pCsr->zRankArgs;
nPhrase = sqlite3Fts5ExprPhraseCount(pCsr->pExpr);
nByte = sizeof(Fts5Sorter) + sizeof(int) * (nPhrase-1);
- pSorter = (Fts5Sorter*)sqlite3_malloc(nByte);
+ pSorter = (Fts5Sorter*)sqlite3_malloc64(nByte);
if( pSorter==0 ) return SQLITE_NOMEM;
memset(pSorter, 0, nByte);
pSorter->nIdx = nPhrase;
@@ -950,10 +949,10 @@ static int fts5CursorFirstSorted(Fts5Table *pTab, Fts5Cursor *pCsr, int bDesc){
return rc;
}
-static int fts5CursorFirst(Fts5Table *pTab, Fts5Cursor *pCsr, int bDesc){
+static int fts5CursorFirst(Fts5FullTable *pTab, Fts5Cursor *pCsr, int bDesc){
int rc;
Fts5Expr *pExpr = pCsr->pExpr;
- rc = sqlite3Fts5ExprFirst(pExpr, pTab->pIndex, pCsr->iFirstRowid, bDesc);
+ rc = sqlite3Fts5ExprFirst(pExpr, pTab->p.pIndex, pCsr->iFirstRowid, bDesc);
if( sqlite3Fts5ExprEof(pExpr) ){
CsrFlagSet(pCsr, FTS5CSR_EOF);
}
@@ -968,7 +967,7 @@ static int fts5CursorFirst(Fts5Table *pTab, Fts5Cursor *pCsr, int bDesc){
** parameters.
*/
static int fts5SpecialMatch(
- Fts5Table *pTab,
+ Fts5FullTable *pTab,
Fts5Cursor *pCsr,
const char *zQuery
){
@@ -979,18 +978,18 @@ static int fts5SpecialMatch(
while( z[0]==' ' ) z++;
for(n=0; z[n] && z[n]!=' '; n++);
- assert( pTab->base.zErrMsg==0 );
+ assert( pTab->p.base.zErrMsg==0 );
pCsr->ePlan = FTS5_PLAN_SPECIAL;
if( 0==sqlite3_strnicmp("reads", z, n) ){
- pCsr->iSpecial = sqlite3Fts5IndexReads(pTab->pIndex);
+ pCsr->iSpecial = sqlite3Fts5IndexReads(pTab->p.pIndex);
}
else if( 0==sqlite3_strnicmp("id", z, n) ){
pCsr->iSpecial = pCsr->iCsrId;
}
else{
/* An unrecognized directive. Return an error message. */
- pTab->base.zErrMsg = sqlite3_mprintf("unknown special query: %.*s", n, z);
+ pTab->p.base.zErrMsg = sqlite3_mprintf("unknown special query: %.*s", n, z);
rc = SQLITE_ERROR;
}
@@ -1002,7 +1001,7 @@ static int fts5SpecialMatch(
** pTab. If one is found, return a pointer to the corresponding Fts5Auxiliary
** structure. Otherwise, if no such function exists, return NULL.
*/
-static Fts5Auxiliary *fts5FindAuxiliary(Fts5Table *pTab, const char *zName){
+static Fts5Auxiliary *fts5FindAuxiliary(Fts5FullTable *pTab, const char *zName){
Fts5Auxiliary *pAux;
for(pAux=pTab->pGlobal->pAux; pAux; pAux=pAux->pNext){
@@ -1015,8 +1014,8 @@ static Fts5Auxiliary *fts5FindAuxiliary(Fts5Table *pTab, const char *zName){
static int fts5FindRankFunction(Fts5Cursor *pCsr){
- Fts5Table *pTab = (Fts5Table*)(pCsr->base.pVtab);
- Fts5Config *pConfig = pTab->pConfig;
+ Fts5FullTable *pTab = (Fts5FullTable*)(pCsr->base.pVtab);
+ Fts5Config *pConfig = pTab->p.pConfig;
int rc = SQLITE_OK;
Fts5Auxiliary *pAux = 0;
const char *zRank = pCsr->zRank;
@@ -1032,7 +1031,7 @@ static int fts5FindRankFunction(Fts5Cursor *pCsr){
assert( rc==SQLITE_OK || pCsr->pRankArgStmt==0 );
if( rc==SQLITE_OK ){
if( SQLITE_ROW==sqlite3_step(pStmt) ){
- int nByte;
+ sqlite3_int64 nByte;
pCsr->nRankArg = sqlite3_column_count(pStmt);
nByte = sizeof(sqlite3_value*)*pCsr->nRankArg;
pCsr->apRankArg = (sqlite3_value**)sqlite3Fts5MallocZero(&rc, nByte);
@@ -1054,8 +1053,8 @@ static int fts5FindRankFunction(Fts5Cursor *pCsr){
if( rc==SQLITE_OK ){
pAux = fts5FindAuxiliary(pTab, zRank);
if( pAux==0 ){
- assert( pTab->base.zErrMsg==0 );
- pTab->base.zErrMsg = sqlite3_mprintf("no such function: %s", zRank);
+ assert( pTab->p.base.zErrMsg==0 );
+ pTab->p.base.zErrMsg = sqlite3_mprintf("no such function: %s", zRank);
rc = SQLITE_ERROR;
}
}
@@ -1130,8 +1129,8 @@ static int fts5FilterMethod(
int nVal, /* Number of elements in apVal */
sqlite3_value **apVal /* Arguments for the indexing scheme */
){
- Fts5Table *pTab = (Fts5Table*)(pCursor->pVtab);
- Fts5Config *pConfig = pTab->pConfig;
+ Fts5FullTable *pTab = (Fts5FullTable*)(pCursor->pVtab);
+ Fts5Config *pConfig = pTab->p.pConfig;
Fts5Cursor *pCsr = (Fts5Cursor*)pCursor;
int rc = SQLITE_OK; /* Error code */
int iVal = 0; /* Counter for apVal[] */
@@ -1160,8 +1159,8 @@ static int fts5FilterMethod(
assert( pCsr->zRank==0 );
assert( pCsr->zRankArgs==0 );
- assert( pzErrmsg==0 || pzErrmsg==&pTab->base.zErrMsg );
- pConfig->pzErrmsg = &pTab->base.zErrMsg;
+ assert( pzErrmsg==0 || pzErrmsg==&pTab->p.base.zErrMsg );
+ pConfig->pzErrmsg = &pTab->p.base.zErrMsg;
/* Decode the arguments passed through to this function.
**
@@ -1227,7 +1226,7 @@ static int fts5FilterMethod(
** but a request for an internal parameter. */
rc = fts5SpecialMatch(pTab, pCsr, &zExpr[1]);
}else{
- char **pzErr = &pTab->base.zErrMsg;
+ char **pzErr = &pTab->p.base.zErrMsg;
rc = sqlite3Fts5ExprNew(pConfig, iCol, zExpr, &pCsr->pExpr, pzErr);
if( rc==SQLITE_OK ){
if( bOrderByRank ){
@@ -1250,7 +1249,7 @@ static int fts5FilterMethod(
** by rowid (ePlan==FTS5_PLAN_ROWID). */
pCsr->ePlan = (pRowidEq ? FTS5_PLAN_ROWID : FTS5_PLAN_SCAN);
rc = sqlite3Fts5StorageStmt(
- pTab->pStorage, fts5StmtType(pCsr), &pCsr->pStmt, &pTab->base.zErrMsg
+ pTab->pStorage, fts5StmtType(pCsr), &pCsr->pStmt, &pTab->p.base.zErrMsg
);
if( rc==SQLITE_OK ){
if( pCsr->ePlan==FTS5_PLAN_ROWID ){
@@ -1333,12 +1332,12 @@ static int fts5SeekCursor(Fts5Cursor *pCsr, int bErrormsg){
/* If the cursor does not yet have a statement handle, obtain one now. */
if( pCsr->pStmt==0 ){
- Fts5Table *pTab = (Fts5Table*)(pCsr->base.pVtab);
+ Fts5FullTable *pTab = (Fts5FullTable*)(pCsr->base.pVtab);
int eStmt = fts5StmtType(pCsr);
rc = sqlite3Fts5StorageStmt(
- pTab->pStorage, eStmt, &pCsr->pStmt, (bErrormsg?&pTab->base.zErrMsg:0)
+ pTab->pStorage, eStmt, &pCsr->pStmt, (bErrormsg?&pTab->p.base.zErrMsg:0)
);
- assert( rc!=SQLITE_OK || pTab->base.zErrMsg==0 );
+ assert( rc!=SQLITE_OK || pTab->p.base.zErrMsg==0 );
assert( CsrFlagTest(pCsr, FTS5CSR_REQUIRE_CONTENT) );
}
@@ -1360,11 +1359,11 @@ static int fts5SeekCursor(Fts5Cursor *pCsr, int bErrormsg){
return rc;
}
-static void fts5SetVtabError(Fts5Table *p, const char *zFormat, ...){
+static void fts5SetVtabError(Fts5FullTable *p, const char *zFormat, ...){
va_list ap; /* ... printf arguments */
va_start(ap, zFormat);
- assert( p->base.zErrMsg==0 );
- p->base.zErrMsg = sqlite3_vmprintf(zFormat, ap);
+ assert( p->p.base.zErrMsg==0 );
+ p->p.base.zErrMsg = sqlite3_vmprintf(zFormat, ap);
va_end(ap);
}
@@ -1384,11 +1383,11 @@ static void fts5SetVtabError(Fts5Table *p, const char *zFormat, ...){
** more commands are added to this function.
*/
static int fts5SpecialInsert(
- Fts5Table *pTab, /* Fts5 table object */
+ Fts5FullTable *pTab, /* Fts5 table object */
const char *zCmd, /* Text inserted into table-name column */
sqlite3_value *pVal /* Value inserted into rank column */
){
- Fts5Config *pConfig = pTab->pConfig;
+ Fts5Config *pConfig = pTab->p.pConfig;
int rc = SQLITE_OK;
int bError = 0;
@@ -1423,9 +1422,9 @@ static int fts5SpecialInsert(
pConfig->bPrefixIndex = sqlite3_value_int(pVal);
#endif
}else{
- rc = sqlite3Fts5IndexLoadConfig(pTab->pIndex);
+ rc = sqlite3Fts5IndexLoadConfig(pTab->p.pIndex);
if( rc==SQLITE_OK ){
- rc = sqlite3Fts5ConfigSetValue(pTab->pConfig, zCmd, pVal, &bError);
+ rc = sqlite3Fts5ConfigSetValue(pTab->p.pConfig, zCmd, pVal, &bError);
}
if( rc==SQLITE_OK ){
if( bError ){
@@ -1439,7 +1438,7 @@ static int fts5SpecialInsert(
}
static int fts5SpecialDelete(
- Fts5Table *pTab,
+ Fts5FullTable *pTab,
sqlite3_value **apVal
){
int rc = SQLITE_OK;
@@ -1453,7 +1452,7 @@ static int fts5SpecialDelete(
static void fts5StorageInsert(
int *pRc,
- Fts5Table *pTab,
+ Fts5FullTable *pTab,
sqlite3_value **apVal,
i64 *piRowid
){
@@ -1487,8 +1486,8 @@ static int fts5UpdateMethod(
sqlite3_value **apVal, /* Array of arguments */
sqlite_int64 *pRowid /* OUT: The affected (or effected) rowid */
){
- Fts5Table *pTab = (Fts5Table*)pVtab;
- Fts5Config *pConfig = pTab->pConfig;
+ Fts5FullTable *pTab = (Fts5FullTable*)pVtab;
+ Fts5Config *pConfig = pTab->p.pConfig;
int eType0; /* value_type() of apVal[0] */
int rc = SQLITE_OK; /* Return code */
@@ -1497,12 +1496,11 @@ static int fts5UpdateMethod(
assert( pVtab->zErrMsg==0 );
assert( nArg==1 || nArg==(2+pConfig->nCol+2) );
- assert( nArg==1
- || sqlite3_value_type(apVal[1])==SQLITE_INTEGER
- || sqlite3_value_type(apVal[1])==SQLITE_NULL
+ assert( sqlite3_value_type(apVal[0])==SQLITE_INTEGER
+ || sqlite3_value_type(apVal[0])==SQLITE_NULL
);
- assert( pTab->pConfig->pzErrmsg==0 );
- pTab->pConfig->pzErrmsg = &pTab->base.zErrMsg;
+ assert( pTab->p.pConfig->pzErrmsg==0 );
+ pTab->p.pConfig->pzErrmsg = &pTab->p.base.zErrMsg;
/* Put any active cursors into REQUIRE_SEEK state. */
fts5TripCursors(pTab);
@@ -1543,7 +1541,7 @@ static int fts5UpdateMethod(
/* Filter out attempts to run UPDATE or DELETE on contentless tables.
** This is not suported. */
if( eType0==SQLITE_INTEGER && fts5IsContentless(pTab) ){
- pTab->base.zErrMsg = sqlite3_mprintf(
+ pTab->p.base.zErrMsg = sqlite3_mprintf(
"cannot %s contentless fts5 table: %s",
(nArg>1 ? "UPDATE" : "DELETE from"), pConfig->zName
);
@@ -1556,46 +1554,52 @@ static int fts5UpdateMethod(
rc = sqlite3Fts5StorageDelete(pTab->pStorage, iDel, 0);
}
- /* INSERT */
- else if( eType0!=SQLITE_INTEGER ){
- /* If this is a REPLACE, first remove the current entry (if any) */
- if( eConflict==SQLITE_REPLACE
- && sqlite3_value_type(apVal[1])==SQLITE_INTEGER
- ){
- i64 iNew = sqlite3_value_int64(apVal[1]); /* Rowid to delete */
- rc = sqlite3Fts5StorageDelete(pTab->pStorage, iNew, 0);
+ /* INSERT or UPDATE */
+ else{
+ int eType1 = sqlite3_value_numeric_type(apVal[1]);
+
+ if( eType1!=SQLITE_INTEGER && eType1!=SQLITE_NULL ){
+ rc = SQLITE_MISMATCH;
}
- fts5StorageInsert(&rc, pTab, apVal, pRowid);
- }
- /* UPDATE */
- else{
- i64 iOld = sqlite3_value_int64(apVal[0]); /* Old rowid */
- i64 iNew = sqlite3_value_int64(apVal[1]); /* New rowid */
- if( iOld!=iNew ){
- if( eConflict==SQLITE_REPLACE ){
- rc = sqlite3Fts5StorageDelete(pTab->pStorage, iOld, 0);
- if( rc==SQLITE_OK ){
- rc = sqlite3Fts5StorageDelete(pTab->pStorage, iNew, 0);
- }
- fts5StorageInsert(&rc, pTab, apVal, pRowid);
- }else{
- rc = sqlite3Fts5StorageContentInsert(pTab->pStorage, apVal, pRowid);
- if( rc==SQLITE_OK ){
+ else if( eType0!=SQLITE_INTEGER ){
+ /* If this is a REPLACE, first remove the current entry (if any) */
+ if( eConflict==SQLITE_REPLACE && eType1==SQLITE_INTEGER ){
+ i64 iNew = sqlite3_value_int64(apVal[1]); /* Rowid to delete */
+ rc = sqlite3Fts5StorageDelete(pTab->pStorage, iNew, 0);
+ }
+ fts5StorageInsert(&rc, pTab, apVal, pRowid);
+ }
+
+ /* UPDATE */
+ else{
+ i64 iOld = sqlite3_value_int64(apVal[0]); /* Old rowid */
+ i64 iNew = sqlite3_value_int64(apVal[1]); /* New rowid */
+ if( eType1==SQLITE_INTEGER && iOld!=iNew ){
+ if( eConflict==SQLITE_REPLACE ){
rc = sqlite3Fts5StorageDelete(pTab->pStorage, iOld, 0);
+ if( rc==SQLITE_OK ){
+ rc = sqlite3Fts5StorageDelete(pTab->pStorage, iNew, 0);
+ }
+ fts5StorageInsert(&rc, pTab, apVal, pRowid);
+ }else{
+ rc = sqlite3Fts5StorageContentInsert(pTab->pStorage, apVal, pRowid);
+ if( rc==SQLITE_OK ){
+ rc = sqlite3Fts5StorageDelete(pTab->pStorage, iOld, 0);
+ }
+ if( rc==SQLITE_OK ){
+ rc = sqlite3Fts5StorageIndexInsert(pTab->pStorage, apVal,*pRowid);
+ }
}
- if( rc==SQLITE_OK ){
- rc = sqlite3Fts5StorageIndexInsert(pTab->pStorage, apVal, *pRowid);
- }
+ }else{
+ rc = sqlite3Fts5StorageDelete(pTab->pStorage, iOld, 0);
+ fts5StorageInsert(&rc, pTab, apVal, pRowid);
}
- }else{
- rc = sqlite3Fts5StorageDelete(pTab->pStorage, iOld, 0);
- fts5StorageInsert(&rc, pTab, apVal, pRowid);
}
}
}
- pTab->pConfig->pzErrmsg = 0;
+ pTab->p.pConfig->pzErrmsg = 0;
return rc;
}
@@ -1604,12 +1608,12 @@ static int fts5UpdateMethod(
*/
static int fts5SyncMethod(sqlite3_vtab *pVtab){
int rc;
- Fts5Table *pTab = (Fts5Table*)pVtab;
+ Fts5FullTable *pTab = (Fts5FullTable*)pVtab;
fts5CheckTransactionState(pTab, FTS5_SYNC, 0);
- pTab->pConfig->pzErrmsg = &pTab->base.zErrMsg;
+ pTab->p.pConfig->pzErrmsg = &pTab->p.base.zErrMsg;
fts5TripCursors(pTab);
rc = sqlite3Fts5StorageSync(pTab->pStorage);
- pTab->pConfig->pzErrmsg = 0;
+ pTab->p.pConfig->pzErrmsg = 0;
return rc;
}
@@ -1617,8 +1621,8 @@ static int fts5SyncMethod(sqlite3_vtab *pVtab){
** Implementation of xBegin() method.
*/
static int fts5BeginMethod(sqlite3_vtab *pVtab){
- fts5CheckTransactionState((Fts5Table*)pVtab, FTS5_BEGIN, 0);
- fts5NewTransaction((Fts5Table*)pVtab);
+ fts5CheckTransactionState((Fts5FullTable*)pVtab, FTS5_BEGIN, 0);
+ fts5NewTransaction((Fts5FullTable*)pVtab);
return SQLITE_OK;
}
@@ -1629,7 +1633,7 @@ static int fts5BeginMethod(sqlite3_vtab *pVtab){
*/
static int fts5CommitMethod(sqlite3_vtab *pVtab){
UNUSED_PARAM(pVtab); /* Call below is a no-op for NDEBUG builds */
- fts5CheckTransactionState((Fts5Table*)pVtab, FTS5_COMMIT, 0);
+ fts5CheckTransactionState((Fts5FullTable*)pVtab, FTS5_COMMIT, 0);
return SQLITE_OK;
}
@@ -1639,7 +1643,7 @@ static int fts5CommitMethod(sqlite3_vtab *pVtab){
*/
static int fts5RollbackMethod(sqlite3_vtab *pVtab){
int rc;
- Fts5Table *pTab = (Fts5Table*)pVtab;
+ Fts5FullTable *pTab = (Fts5FullTable*)pVtab;
fts5CheckTransactionState(pTab, FTS5_ROLLBACK, 0);
rc = sqlite3Fts5StorageRollback(pTab->pStorage);
return rc;
@@ -1663,13 +1667,13 @@ static int fts5ApiColumnTotalSize(
sqlite3_int64 *pnToken
){
Fts5Cursor *pCsr = (Fts5Cursor*)pCtx;
- Fts5Table *pTab = (Fts5Table*)(pCsr->base.pVtab);
+ Fts5FullTable *pTab = (Fts5FullTable*)(pCsr->base.pVtab);
return sqlite3Fts5StorageSize(pTab->pStorage, iCol, pnToken);
}
static int fts5ApiRowCount(Fts5Context *pCtx, i64 *pnRow){
Fts5Cursor *pCsr = (Fts5Cursor*)pCtx;
- Fts5Table *pTab = (Fts5Table*)(pCsr->base.pVtab);
+ Fts5FullTable *pTab = (Fts5FullTable*)(pCsr->base.pVtab);
return sqlite3Fts5StorageRowCount(pTab->pStorage, pnRow);
}
@@ -1704,7 +1708,9 @@ static int fts5ApiColumnText(
){
int rc = SQLITE_OK;
Fts5Cursor *pCsr = (Fts5Cursor*)pCtx;
- if( fts5IsContentless((Fts5Table*)(pCsr->base.pVtab)) ){
+ if( fts5IsContentless((Fts5FullTable*)(pCsr->base.pVtab))
+ || pCsr->ePlan==FTS5_PLAN_SPECIAL
+ ){
*pz = 0;
*pn = 0;
}else{
@@ -1773,10 +1779,11 @@ static int fts5CacheInstArray(Fts5Cursor *pCsr){
int rc = SQLITE_OK;
Fts5PoslistReader *aIter; /* One iterator for each phrase */
int nIter; /* Number of iterators/phrases */
+ int nCol = ((Fts5Table*)pCsr->base.pVtab)->pConfig->nCol;
nIter = sqlite3Fts5ExprPhraseCount(pCsr->pExpr);
if( pCsr->aInstIter==0 ){
- int nByte = sizeof(Fts5PoslistReader) * nIter;
+ sqlite3_int64 nByte = sizeof(Fts5PoslistReader) * nIter;
pCsr->aInstIter = (Fts5PoslistReader*)sqlite3Fts5MallocZero(&rc, nByte);
}
aIter = pCsr->aInstIter;
@@ -1811,7 +1818,7 @@ static int fts5CacheInstArray(Fts5Cursor *pCsr){
nInst++;
if( nInst>=pCsr->nInstAlloc ){
pCsr->nInstAlloc = pCsr->nInstAlloc ? pCsr->nInstAlloc*2 : 32;
- aInst = (int*)sqlite3_realloc(
+ aInst = (int*)sqlite3_realloc64(
pCsr->aInst, pCsr->nInstAlloc*sizeof(int)*3
);
if( aInst ){
@@ -1826,6 +1833,10 @@ static int fts5CacheInstArray(Fts5Cursor *pCsr){
aInst[0] = iBest;
aInst[1] = FTS5_POS2COLUMN(aIter[iBest].iPos);
aInst[2] = FTS5_POS2OFFSET(aIter[iBest].iPos);
+ if( aInst[1]<0 || aInst[1]>=nCol ){
+ rc = FTS5_CORRUPT;
+ break;
+ }
sqlite3Fts5PoslistReaderNext(&aIter[iBest]);
}
}
@@ -1898,8 +1909,8 @@ static int fts5ColumnSizeCb(
static int fts5ApiColumnSize(Fts5Context *pCtx, int iCol, int *pnToken){
Fts5Cursor *pCsr = (Fts5Cursor*)pCtx;
- Fts5Table *pTab = (Fts5Table*)(pCsr->base.pVtab);
- Fts5Config *pConfig = pTab->pConfig;
+ Fts5FullTable *pTab = (Fts5FullTable*)(pCsr->base.pVtab);
+ Fts5Config *pConfig = pTab->p.pConfig;
int rc = SQLITE_OK;
if( CsrFlagTest(pCsr, FTS5CSR_REQUIRE_DOCSIZE) ){
@@ -2155,7 +2166,7 @@ static int fts5ApiQueryPhrase(
int(*xCallback)(const Fts5ExtensionApi*, Fts5Context*, void*)
){
Fts5Cursor *pCsr = (Fts5Cursor*)pCtx;
- Fts5Table *pTab = (Fts5Table*)(pCsr->base.pVtab);
+ Fts5FullTable *pTab = (Fts5FullTable*)(pCsr->base.pVtab);
int rc;
Fts5Cursor *pNew = 0;
@@ -2232,25 +2243,19 @@ static void fts5ApiCallback(
/*
-** Given cursor id iId, return a pointer to the corresponding Fts5Index
+** Given cursor id iId, return a pointer to the corresponding Fts5Table
** object. Or NULL If the cursor id does not exist.
-**
-** If successful, set *ppConfig to point to the associated config object
-** before returning.
*/
-Fts5Index *sqlite3Fts5IndexFromCsrid(
+Fts5Table *sqlite3Fts5TableFromCsrid(
Fts5Global *pGlobal, /* FTS5 global context for db handle */
- i64 iCsrId, /* Id of cursor to find */
- Fts5Config **ppConfig /* OUT: Configuration object */
+ i64 iCsrId /* Id of cursor to find */
){
Fts5Cursor *pCsr;
- Fts5Table *pTab;
-
pCsr = fts5CursorFromCsrid(pGlobal, iCsrId);
- pTab = (Fts5Table*)pCsr->base.pVtab;
- *ppConfig = pTab->pConfig;
-
- return pTab->pIndex;
+ if( pCsr ){
+ return (Fts5Table*)pCsr->base.pVtab;
+ }
+ return 0;
}
/*
@@ -2330,8 +2335,8 @@ static int fts5ColumnMethod(
sqlite3_context *pCtx, /* Context for sqlite3_result_xxx() calls */
int iCol /* Index of column to read value from */
){
- Fts5Table *pTab = (Fts5Table*)(pCursor->pVtab);
- Fts5Config *pConfig = pTab->pConfig;
+ Fts5FullTable *pTab = (Fts5FullTable*)(pCursor->pVtab);
+ Fts5Config *pConfig = pTab->p.pConfig;
Fts5Cursor *pCsr = (Fts5Cursor*)pCursor;
int rc = SQLITE_OK;
@@ -2383,7 +2388,7 @@ static int fts5FindFunctionMethod(
void (**pxFunc)(sqlite3_context*,int,sqlite3_value**), /* OUT: Result */
void **ppArg /* OUT: User data for *pxFunc */
){
- Fts5Table *pTab = (Fts5Table*)pVtab;
+ Fts5FullTable *pTab = (Fts5FullTable*)pVtab;
Fts5Auxiliary *pAux;
UNUSED_PARAM(nUnused);
@@ -2405,21 +2410,24 @@ static int fts5RenameMethod(
sqlite3_vtab *pVtab, /* Virtual table handle */
const char *zName /* New name of table */
){
- Fts5Table *pTab = (Fts5Table*)pVtab;
+ Fts5FullTable *pTab = (Fts5FullTable*)pVtab;
return sqlite3Fts5StorageRename(pTab->pStorage, zName);
}
+int sqlite3Fts5FlushToDisk(Fts5Table *pTab){
+ fts5TripCursors((Fts5FullTable*)pTab);
+ return sqlite3Fts5StorageSync(((Fts5FullTable*)pTab)->pStorage);
+}
+
/*
** The xSavepoint() method.
**
** Flush the contents of the pending-terms table to disk.
*/
static int fts5SavepointMethod(sqlite3_vtab *pVtab, int iSavepoint){
- Fts5Table *pTab = (Fts5Table*)pVtab;
UNUSED_PARAM(iSavepoint); /* Call below is a no-op for NDEBUG builds */
- fts5CheckTransactionState(pTab, FTS5_SAVEPOINT, iSavepoint);
- fts5TripCursors(pTab);
- return sqlite3Fts5StorageSync(pTab->pStorage);
+ fts5CheckTransactionState((Fts5FullTable*)pVtab, FTS5_SAVEPOINT, iSavepoint);
+ return sqlite3Fts5FlushToDisk((Fts5Table*)pVtab);
}
/*
@@ -2428,11 +2436,9 @@ static int fts5SavepointMethod(sqlite3_vtab *pVtab, int iSavepoint){
** This is a no-op.
*/
static int fts5ReleaseMethod(sqlite3_vtab *pVtab, int iSavepoint){
- Fts5Table *pTab = (Fts5Table*)pVtab;
UNUSED_PARAM(iSavepoint); /* Call below is a no-op for NDEBUG builds */
- fts5CheckTransactionState(pTab, FTS5_RELEASE, iSavepoint);
- fts5TripCursors(pTab);
- return sqlite3Fts5StorageSync(pTab->pStorage);
+ fts5CheckTransactionState((Fts5FullTable*)pVtab, FTS5_RELEASE, iSavepoint);
+ return sqlite3Fts5FlushToDisk((Fts5Table*)pVtab);
}
/*
@@ -2441,7 +2447,7 @@ static int fts5ReleaseMethod(sqlite3_vtab *pVtab, int iSavepoint){
** Discard the contents of the pending terms table.
*/
static int fts5RollbackToMethod(sqlite3_vtab *pVtab, int iSavepoint){
- Fts5Table *pTab = (Fts5Table*)pVtab;
+ Fts5FullTable *pTab = (Fts5FullTable*)pVtab;
UNUSED_PARAM(iSavepoint); /* Call below is a no-op for NDEBUG builds */
fts5CheckTransactionState(pTab, FTS5_ROLLBACKTO, iSavepoint);
fts5TripCursors(pTab);
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 1f08a9a7a84..633e5a4d96c 100644
--- a/chromium/third_party/sqlite/src/ext/fts5/fts5_storage.c
+++ b/chromium/third_party/sqlite/src/ext/fts5/fts5_storage.c
@@ -115,7 +115,7 @@ static int fts5StorageGetStmt(
char *zBind;
int i;
- zBind = sqlite3_malloc(1 + nCol*2);
+ zBind = sqlite3_malloc64(1 + nCol*2);
if( zBind ){
for(i=0; i<nCol; i++){
zBind[i*2] = '?';
@@ -282,11 +282,11 @@ int sqlite3Fts5StorageOpen(
){
int rc = SQLITE_OK;
Fts5Storage *p; /* New object */
- int nByte; /* Bytes of space to allocate */
+ sqlite3_int64 nByte; /* Bytes of space to allocate */
nByte = sizeof(Fts5Storage) /* Fts5Storage object */
+ pConfig->nCol * sizeof(i64); /* Fts5Storage.aTotalSize[] */
- *pp = p = (Fts5Storage*)sqlite3_malloc(nByte);
+ *pp = p = (Fts5Storage*)sqlite3_malloc64(nByte);
if( !p ) return SQLITE_NOMEM;
memset(p, 0, nByte);
@@ -297,7 +297,7 @@ int sqlite3Fts5StorageOpen(
if( bCreate ){
if( pConfig->eContent==FTS5_CONTENT_NORMAL ){
int nDefn = 32 + pConfig->nCol*10;
- char *zDefn = sqlite3_malloc(32 + pConfig->nCol * 10);
+ char *zDefn = sqlite3_malloc64(32 + (sqlite3_int64)pConfig->nCol * 10);
if( zDefn==0 ){
rc = SQLITE_NOMEM;
}else{
@@ -588,7 +588,7 @@ int sqlite3Fts5StorageRebuild(Fts5Storage *p){
Fts5Config *pConfig = p->pConfig;
sqlite3_stmt *pScan = 0;
Fts5InsertCtx ctx;
- int rc;
+ int rc, rc2;
memset(&ctx, 0, sizeof(Fts5InsertCtx));
ctx.pStorage = p;
@@ -627,6 +627,8 @@ int sqlite3Fts5StorageRebuild(Fts5Storage *p){
}
}
sqlite3_free(buf.p);
+ rc2 = sqlite3_reset(pScan);
+ if( rc==SQLITE_OK ) rc = rc2;
/* Write the averages record */
if( rc==SQLITE_OK ){
@@ -876,7 +878,7 @@ int sqlite3Fts5StorageIntegrity(Fts5Storage *p){
memset(&ctx, 0, sizeof(Fts5IntegrityCtx));
ctx.pConfig = p->pConfig;
- aTotalSize = (i64*)sqlite3_malloc(pConfig->nCol * (sizeof(int)+sizeof(i64)));
+ aTotalSize = (i64*)sqlite3_malloc64(pConfig->nCol*(sizeof(int)+sizeof(i64)));
if( !aTotalSize ) return SQLITE_NOMEM;
aColSize = (int*)&aTotalSize[pConfig->nCol];
memset(aTotalSize, 0, sizeof(i64) * pConfig->nCol);
@@ -1076,7 +1078,13 @@ int sqlite3Fts5StorageSize(Fts5Storage *p, int iCol, i64 *pnToken){
int sqlite3Fts5StorageRowCount(Fts5Storage *p, i64 *pnRow){
int rc = fts5StorageLoadTotals(p, 0);
if( rc==SQLITE_OK ){
+ /* nTotalRow being zero does not necessarily indicate a corrupt
+ ** database - it might be that the FTS5 table really does contain zero
+ ** rows. However this function is only called from the xRowCount() API,
+ ** and there is no way for that API to be invoked if the table contains
+ ** no rows. Hence the FTS5_CORRUPT return. */
*pnRow = p->nTotalRow;
+ if( p->nTotalRow<=0 ) rc = FTS5_CORRUPT;
}
return rc;
}
diff --git a/chromium/third_party/sqlite/src/ext/fts5/fts5_test_mi.c b/chromium/third_party/sqlite/src/ext/fts5/fts5_test_mi.c
index d520d0fc17f..a0e8be959cd 100644
--- a/chromium/third_party/sqlite/src/ext/fts5/fts5_test_mi.c
+++ b/chromium/third_party/sqlite/src/ext/fts5/fts5_test_mi.c
@@ -309,7 +309,7 @@ static Fts5MatchinfoCtx *fts5MatchinfoNew(
int nPhrase;
int i;
int nInt;
- int nByte;
+ sqlite3_int64 nByte;
int rc;
nCol = pApi->xColumnCount(pFts);
@@ -330,7 +330,7 @@ static Fts5MatchinfoCtx *fts5MatchinfoNew(
nByte = sizeof(Fts5MatchinfoCtx) /* The struct itself */
+ sizeof(u32) * nInt /* The p->aRet[] array */
+ (i+1); /* The p->zArg string */
- p = (Fts5MatchinfoCtx*)sqlite3_malloc(nByte);
+ p = (Fts5MatchinfoCtx*)sqlite3_malloc64(nByte);
if( p==0 ){
sqlite3_result_error_nomem(pCtx);
return 0;
diff --git a/chromium/third_party/sqlite/src/ext/fts5/fts5_test_tok.c b/chromium/third_party/sqlite/src/ext/fts5/fts5_test_tok.c
index 7453638b317..3d957d4b877 100644
--- a/chromium/third_party/sqlite/src/ext/fts5/fts5_test_tok.c
+++ b/chromium/third_party/sqlite/src/ext/fts5/fts5_test_tok.c
@@ -137,7 +137,7 @@ static int fts5tokDequoteArray(
nByte += (int)(strlen(argv[i]) + 1);
}
- *pazDequote = azDequote = sqlite3_malloc(sizeof(char *)*argc + nByte);
+ *pazDequote = azDequote = sqlite3_malloc64(sizeof(char *)*argc + nByte);
if( azDequote==0 ){
rc = SQLITE_NOMEM;
}else{
@@ -335,7 +335,7 @@ static int fts5tokCb(
if( (pCsr->nRow & (pCsr->nRow-1))==0 ){
int nNew = pCsr->nRow ? pCsr->nRow*2 : 32;
Fts5tokRow *aNew;
- aNew = (Fts5tokRow*)sqlite3_realloc(pCsr->aRow, nNew*sizeof(Fts5tokRow));
+ aNew = (Fts5tokRow*)sqlite3_realloc64(pCsr->aRow, nNew*sizeof(Fts5tokRow));
if( aNew==0 ) return SQLITE_NOMEM;
memset(&aNew[pCsr->nRow], 0, sizeof(Fts5tokRow)*(nNew-pCsr->nRow));
pCsr->aRow = aNew;
@@ -378,7 +378,7 @@ static int fts5tokFilterMethod(
if( pCsr->zInput==0 ){
rc = SQLITE_NOMEM;
}else{
- memcpy(pCsr->zInput, zByte, nByte);
+ if( nByte>0 ) memcpy(pCsr->zInput, zByte, nByte);
pCsr->zInput[nByte] = 0;
rc = pTab->tok.xTokenize(
pTab->pTok, (void*)pCsr, 0, zByte, nByte, fts5tokCb
diff --git a/chromium/third_party/sqlite/src/ext/fts5/fts5_tokenize.c b/chromium/third_party/sqlite/src/ext/fts5/fts5_tokenize.c
index b02707d8b6d..b39221bc253 100644
--- a/chromium/third_party/sqlite/src/ext/fts5/fts5_tokenize.c
+++ b/chromium/third_party/sqlite/src/ext/fts5/fts5_tokenize.c
@@ -152,7 +152,7 @@ static int fts5AsciiTokenize(
nByte = ie-is;
if( nByte>nFold ){
if( pFold!=aFold ) sqlite3_free(pFold);
- pFold = sqlite3_malloc(nByte*2);
+ pFold = sqlite3_malloc64((sqlite3_int64)nByte*2);
if( pFold==0 ){
rc = SQLITE_NOMEM;
break;
@@ -234,13 +234,18 @@ struct Unicode61Tokenizer {
unsigned char aTokenChar[128]; /* ASCII range token characters */
char *aFold; /* Buffer to fold text into */
int nFold; /* Size of aFold[] in bytes */
- int bRemoveDiacritic; /* True if remove_diacritics=1 is set */
+ int eRemoveDiacritic; /* True if remove_diacritics=1 is set */
int nException;
int *aiException;
unsigned char aCategory[32]; /* True for token char categories */
};
+/* Values for eRemoveDiacritic (must match internals of fts5_unicode2.c) */
+#define FTS5_REMOVE_DIACRITICS_NONE 0
+#define FTS5_REMOVE_DIACRITICS_SIMPLE 1
+#define FTS5_REMOVE_DIACRITICS_COMPLEX 2
+
static int fts5UnicodeAddExceptions(
Unicode61Tokenizer *p, /* Tokenizer object */
const char *z, /* Characters to treat as exceptions */
@@ -251,13 +256,14 @@ static int fts5UnicodeAddExceptions(
int *aNew;
if( n>0 ){
- aNew = (int*)sqlite3_realloc(p->aiException, (n+p->nException)*sizeof(int));
+ aNew = (int*)sqlite3_realloc64(p->aiException,
+ (n+p->nException)*sizeof(int));
if( aNew ){
int nNew = p->nException;
const unsigned char *zCsr = (const unsigned char*)z;
const unsigned char *zTerm = (const unsigned char*)&z[n];
while( zCsr<zTerm ){
- int iCode;
+ u32 iCode;
int bToken;
READ_UTF8(zCsr, zTerm, iCode);
if( iCode<128 ){
@@ -269,7 +275,7 @@ static int fts5UnicodeAddExceptions(
if( bToken!=bTokenChars && sqlite3Fts5UnicodeIsdiacritic(iCode)==0 ){
int i;
for(i=0; i<nNew; i++){
- if( aNew[i]>iCode ) break;
+ if( (u32)aNew[i]>iCode ) break;
}
memmove(&aNew[i+1], &aNew[i], (nNew-i)*sizeof(int));
aNew[i] = iCode;
@@ -361,7 +367,7 @@ static int fts5UnicodeCreate(
int i;
memset(p, 0, sizeof(Unicode61Tokenizer));
- p->bRemoveDiacritic = 1;
+ p->eRemoveDiacritic = FTS5_REMOVE_DIACRITICS_SIMPLE;
p->nFold = 64;
p->aFold = sqlite3_malloc(p->nFold * sizeof(char));
if( p->aFold==0 ){
@@ -382,10 +388,15 @@ static int fts5UnicodeCreate(
for(i=0; rc==SQLITE_OK && i<nArg; i+=2){
const char *zArg = azArg[i+1];
if( 0==sqlite3_stricmp(azArg[i], "remove_diacritics") ){
- if( (zArg[0]!='0' && zArg[0]!='1') || zArg[1] ){
+ if( (zArg[0]!='0' && zArg[0]!='1' && zArg[0]!='2') || zArg[1] ){
rc = SQLITE_ERROR;
+ }else{
+ p->eRemoveDiacritic = (zArg[0] - '0');
+ assert( p->eRemoveDiacritic==FTS5_REMOVE_DIACRITICS_NONE
+ || p->eRemoveDiacritic==FTS5_REMOVE_DIACRITICS_SIMPLE
+ || p->eRemoveDiacritic==FTS5_REMOVE_DIACRITICS_COMPLEX
+ );
}
- p->bRemoveDiacritic = (zArg[0]=='1');
}else
if( 0==sqlite3_stricmp(azArg[i], "tokenchars") ){
rc = fts5UnicodeAddExceptions(p, zArg, 1);
@@ -419,7 +430,7 @@ static int fts5UnicodeCreate(
*/
static int fts5UnicodeIsAlnum(Unicode61Tokenizer *p, int iCode){
return (
- p->aCategory[sqlite3Fts5UnicodeCategory(iCode)]
+ p->aCategory[sqlite3Fts5UnicodeCategory((u32)iCode)]
^ fts5UnicodeIsException(p, iCode)
);
}
@@ -448,7 +459,7 @@ static int fts5UnicodeTokenize(
/* Each iteration of this loop gobbles up a contiguous run of separators,
** then the next token. */
while( rc==SQLITE_OK ){
- int iCode; /* non-ASCII codepoint read from input */
+ u32 iCode; /* non-ASCII codepoint read from input */
char *zOut = aFold;
int is;
int ie;
@@ -480,7 +491,7 @@ static int fts5UnicodeTokenize(
/* Grow the output buffer so that there is sufficient space to fit the
** largest possible utf-8 character. */
if( zOut>pEnd ){
- aFold = sqlite3_malloc(nFold*2);
+ aFold = sqlite3_malloc64((sqlite3_int64)nFold*2);
if( aFold==0 ){
rc = SQLITE_NOMEM;
goto tokenize_done;
@@ -499,7 +510,7 @@ static int fts5UnicodeTokenize(
READ_UTF8(zCsr, zTerm, iCode);
if( fts5UnicodeIsAlnum(p,iCode)||sqlite3Fts5UnicodeIsdiacritic(iCode) ){
non_ascii_tokenchar:
- iCode = sqlite3Fts5UnicodeFold(iCode, p->bRemoveDiacritic);
+ iCode = sqlite3Fts5UnicodeFold(iCode, p->eRemoveDiacritic);
if( iCode ) WRITE_UTF8(zOut, iCode);
}else{
break;
@@ -1274,5 +1285,3 @@ int sqlite3Fts5TokenizerInit(fts5_api *pApi){
return rc;
}
-
-
diff --git a/chromium/third_party/sqlite/src/ext/fts5/fts5_unicode2.c b/chromium/third_party/sqlite/src/ext/fts5/fts5_unicode2.c
index 163800537b4..1f3522ff728 100644
--- a/chromium/third_party/sqlite/src/ext/fts5/fts5_unicode2.c
+++ b/chromium/third_party/sqlite/src/ext/fts5/fts5_unicode2.c
@@ -1,5 +1,5 @@
/*
-** 2012 May 25
+** 2012-05-25
**
** The author disclaims copyright to this source code. In place of
** a legal notice, here is a blessing:
@@ -28,32 +28,48 @@
** E"). The resuls of passing a codepoint that corresponds to an
** uppercase letter are undefined.
*/
-static int fts5_remove_diacritic(int c){
+static int fts5_remove_diacritic(int c, int bComplex){
unsigned short aDia[] = {
0, 1797, 1848, 1859, 1891, 1928, 1940, 1995,
2024, 2040, 2060, 2110, 2168, 2206, 2264, 2286,
2344, 2383, 2472, 2488, 2516, 2596, 2668, 2732,
2782, 2842, 2894, 2954, 2984, 3000, 3028, 3336,
- 3456, 3696, 3712, 3728, 3744, 3896, 3912, 3928,
- 3968, 4008, 4040, 4106, 4138, 4170, 4202, 4234,
- 4266, 4296, 4312, 4344, 4408, 4424, 4472, 4504,
- 6148, 6198, 6264, 6280, 6360, 6429, 6505, 6529,
- 61448, 61468, 61534, 61592, 61642, 61688, 61704, 61726,
- 61784, 61800, 61836, 61880, 61914, 61948, 61998, 62122,
- 62154, 62200, 62218, 62302, 62364, 62442, 62478, 62536,
- 62554, 62584, 62604, 62640, 62648, 62656, 62664, 62730,
- 62924, 63050, 63082, 63274, 63390,
+ 3456, 3696, 3712, 3728, 3744, 3766, 3832, 3896,
+ 3912, 3928, 3944, 3968, 4008, 4040, 4056, 4106,
+ 4138, 4170, 4202, 4234, 4266, 4296, 4312, 4344,
+ 4408, 4424, 4442, 4472, 4488, 4504, 6148, 6198,
+ 6264, 6280, 6360, 6429, 6505, 6529, 61448, 61468,
+ 61512, 61534, 61592, 61610, 61642, 61672, 61688, 61704,
+ 61726, 61784, 61800, 61816, 61836, 61880, 61896, 61914,
+ 61948, 61998, 62062, 62122, 62154, 62184, 62200, 62218,
+ 62252, 62302, 62364, 62410, 62442, 62478, 62536, 62554,
+ 62584, 62604, 62640, 62648, 62656, 62664, 62730, 62766,
+ 62830, 62890, 62924, 62974, 63032, 63050, 63082, 63118,
+ 63182, 63242, 63274, 63310, 63368, 63390,
};
- char aChar[] = {
- '\0', 'a', 'c', 'e', 'i', 'n', 'o', 'u', 'y', 'y', 'a', 'c',
- 'd', 'e', 'e', 'g', 'h', 'i', 'j', 'k', 'l', 'n', 'o', 'r',
- 's', 't', 'u', 'u', 'w', 'y', 'z', 'o', 'u', 'a', 'i', 'o',
- 'u', 'g', 'k', 'o', 'j', 'g', 'n', 'a', 'e', 'i', 'o', 'r',
- 'u', 's', 't', 'h', 'a', 'e', 'o', 'y', '\0', '\0', '\0', '\0',
- '\0', '\0', '\0', '\0', 'a', 'b', 'd', 'd', 'e', 'f', 'g', 'h',
- 'h', 'i', 'k', 'l', 'l', 'm', 'n', 'p', 'r', 'r', 's', 't',
- 'u', 'v', 'w', 'w', 'x', 'y', 'z', 'h', 't', 'w', 'y', 'a',
- 'e', 'i', 'o', 'u', 'y',
+#define HIBIT ((unsigned char)0x80)
+ unsigned char aChar[] = {
+ '\0', 'a', 'c', 'e', 'i', 'n',
+ 'o', 'u', 'y', 'y', 'a', 'c',
+ 'd', 'e', 'e', 'g', 'h', 'i',
+ 'j', 'k', 'l', 'n', 'o', 'r',
+ 's', 't', 'u', 'u', 'w', 'y',
+ 'z', 'o', 'u', 'a', 'i', 'o',
+ 'u', 'u'|HIBIT, 'a'|HIBIT, 'g', 'k', 'o',
+ 'o'|HIBIT, 'j', 'g', 'n', 'a'|HIBIT, 'a',
+ 'e', 'i', 'o', 'r', 'u', 's',
+ 't', 'h', 'a', 'e', 'o'|HIBIT, 'o',
+ 'o'|HIBIT, 'y', '\0', '\0', '\0', '\0',
+ '\0', '\0', '\0', '\0', 'a', 'b',
+ 'c'|HIBIT, 'd', 'd', 'e'|HIBIT, 'e', 'e'|HIBIT,
+ 'f', 'g', 'h', 'h', 'i', 'i'|HIBIT,
+ 'k', 'l', 'l'|HIBIT, 'l', 'm', 'n',
+ 'o'|HIBIT, 'p', 'r', 'r'|HIBIT, 'r', 's',
+ 's'|HIBIT, 't', 'u', 'u'|HIBIT, 'v', 'w',
+ 'w', 'x', 'y', 'z', 'h', 't',
+ 'w', 'y', 'a', 'a'|HIBIT, 'a'|HIBIT, 'a'|HIBIT,
+ 'e', 'e'|HIBIT, 'e'|HIBIT, 'i', 'o', 'o'|HIBIT,
+ 'o'|HIBIT, 'o'|HIBIT, 'u', 'u'|HIBIT, 'u'|HIBIT, 'y',
};
unsigned int key = (((unsigned int)c)<<3) | 0x00000007;
@@ -70,7 +86,8 @@ static int fts5_remove_diacritic(int c){
}
}
assert( key>=aDia[iRes] );
- return ((c > (aDia[iRes]>>3) + (aDia[iRes]&0x07)) ? c : (int)aChar[iRes]);
+ if( bComplex==0 && (aChar[iRes] & 0x80) ) return c;
+ return (c > (aDia[iRes]>>3) + (aDia[iRes]&0x07)) ? c : ((int)aChar[iRes] & 0x7F);
}
@@ -83,8 +100,8 @@ int sqlite3Fts5UnicodeIsdiacritic(int c){
unsigned int mask1 = 0x000361F8;
if( c<768 || c>817 ) return 0;
return (c < 768+32) ?
- (mask0 & (1 << (c-768))) :
- (mask1 & (1 << (c-768-32)));
+ (mask0 & ((unsigned int)1 << (c-768))) :
+ (mask1 & ((unsigned int)1 << (c-768-32)));
}
@@ -97,7 +114,7 @@ int sqlite3Fts5UnicodeIsdiacritic(int c){
** The results are undefined if the value passed to this function
** is less than zero.
*/
-int sqlite3Fts5UnicodeFold(int c, int bRemoveDiacritic){
+int sqlite3Fts5UnicodeFold(int c, int eRemoveDiacritic){
/* Each entry in the following array defines a rule for folding a range
** of codepoints to lower case. The rule applies to a range of nRange
** codepoints starting at codepoint iCode.
@@ -220,7 +237,9 @@ int sqlite3Fts5UnicodeFold(int c, int bRemoveDiacritic){
assert( ret>0 );
}
- if( bRemoveDiacritic ) ret = fts5_remove_diacritic(ret);
+ if( eRemoveDiacritic ){
+ ret = fts5_remove_diacritic(ret, eRemoveDiacritic==2);
+ }
}
else if( c>=66560 && c<66600 ){
@@ -231,12 +250,6 @@ int sqlite3Fts5UnicodeFold(int c, int bRemoveDiacritic){
}
-#if 0
-int sqlite3Fts5UnicodeNCat(void) {
- return 32;
-}
-#endif
-
int sqlite3Fts5UnicodeCatParse(const char *zCat, u8 *aArray){
aArray[0] = 1;
switch( zCat[0] ){
@@ -718,7 +731,7 @@ static u16 aFts5UnicodeData[] = {
34, 3074, 7692, 63, 63,
};
-int sqlite3Fts5UnicodeCategory(int iCode) {
+int sqlite3Fts5UnicodeCategory(u32 iCode) {
int iRes = -1;
int iHi;
int iLo;
@@ -756,9 +769,8 @@ void sqlite3Fts5UnicodeAscii(u8 *aArray, u8 *aAscii){
int bToken = aArray[ aFts5UnicodeData[iTbl] & 0x1F ];
int n = (aFts5UnicodeData[iTbl] >> 5) + i;
for(; i<128 && i<n; i++){
- aAscii[i] = (u8)bToken;
+ aAscii[i] = bToken;
}
iTbl++;
}
}
-
diff --git a/chromium/third_party/sqlite/src/ext/fts5/fts5_varint.c b/chromium/third_party/sqlite/src/ext/fts5/fts5_varint.c
index 91c5333933a..a982d46c522 100644
--- a/chromium/third_party/sqlite/src/ext/fts5/fts5_varint.c
+++ b/chromium/third_party/sqlite/src/ext/fts5/fts5_varint.c
@@ -76,7 +76,7 @@ int sqlite3Fts5GetVarint32(const unsigned char *p, u32 *v){
u8 n;
p -= 2;
n = sqlite3Fts5GetVarint(p, &v64);
- *v = (u32)v64;
+ *v = ((u32)v64) & 0x7FFFFFFF;
assert( n>3 && n<=9 );
return n;
}
@@ -342,4 +342,3 @@ int sqlite3Fts5GetVarintLen(u32 iVal){
if( iVal<(1 << 28) ) return 4;
return 5;
}
-
diff --git a/chromium/third_party/sqlite/src/ext/fts5/fts5_vocab.c b/chromium/third_party/sqlite/src/ext/fts5/fts5_vocab.c
index 6820706fd8f..fcc9e55497a 100644
--- a/chromium/third_party/sqlite/src/ext/fts5/fts5_vocab.c
+++ b/chromium/third_party/sqlite/src/ext/fts5/fts5_vocab.c
@@ -55,7 +55,7 @@ struct Fts5VocabTable {
struct Fts5VocabCursor {
sqlite3_vtab_cursor base;
sqlite3_stmt *pStmt; /* Statement holding lock on pIndex */
- Fts5Index *pIndex; /* Associated FTS5 index */
+ Fts5Table *pFts5; /* Associated FTS5 table */
int bEof; /* True if this cursor is at EOF */
Fts5IndexIter *pIter; /* Term/rowid iterator object */
@@ -64,7 +64,6 @@ struct Fts5VocabCursor {
char *zLeTerm; /* (term <= $zLeTerm) paramater, or NULL */
/* These are used by 'col' tables only */
- Fts5Config *pConfig; /* Fts5 table configuration */
int iCol;
i64 *aCnt;
i64 *aDoc;
@@ -327,8 +326,7 @@ static int fts5VocabOpenMethod(
sqlite3_vtab_cursor **ppCsr
){
Fts5VocabTable *pTab = (Fts5VocabTable*)pVTab;
- Fts5Index *pIndex = 0;
- Fts5Config *pConfig = 0;
+ Fts5Table *pFts5 = 0;
Fts5VocabCursor *pCsr = 0;
int rc = SQLITE_OK;
sqlite3_stmt *pStmt = 0;
@@ -347,31 +345,34 @@ static int fts5VocabOpenMethod(
if( pStmt && sqlite3_step(pStmt)==SQLITE_ROW ){
i64 iId = sqlite3_column_int64(pStmt, 0);
- pIndex = sqlite3Fts5IndexFromCsrid(pTab->pGlobal, iId, &pConfig);
+ pFts5 = sqlite3Fts5TableFromCsrid(pTab->pGlobal, iId);
}
- if( rc==SQLITE_OK && pIndex==0 ){
- rc = sqlite3_finalize(pStmt);
- pStmt = 0;
- if( rc==SQLITE_OK ){
- pVTab->zErrMsg = sqlite3_mprintf(
- "no such fts5 table: %s.%s", pTab->zFts5Db, pTab->zFts5Tbl
- );
- rc = SQLITE_ERROR;
+ if( rc==SQLITE_OK ){
+ if( pFts5==0 ){
+ rc = sqlite3_finalize(pStmt);
+ pStmt = 0;
+ if( rc==SQLITE_OK ){
+ pVTab->zErrMsg = sqlite3_mprintf(
+ "no such fts5 table: %s.%s", pTab->zFts5Db, pTab->zFts5Tbl
+ );
+ rc = SQLITE_ERROR;
+ }
+ }else{
+ rc = sqlite3Fts5FlushToDisk(pFts5);
}
}
if( rc==SQLITE_OK ){
- int nByte = pConfig->nCol * sizeof(i64) * 2 + sizeof(Fts5VocabCursor);
+ int nByte = pFts5->pConfig->nCol * sizeof(i64)*2 + sizeof(Fts5VocabCursor);
pCsr = (Fts5VocabCursor*)sqlite3Fts5MallocZero(&rc, nByte);
}
if( pCsr ){
- pCsr->pIndex = pIndex;
+ pCsr->pFts5 = pFts5;
pCsr->pStmt = pStmt;
- pCsr->pConfig = pConfig;
pCsr->aCnt = (i64*)&pCsr[1];
- pCsr->aDoc = &pCsr->aCnt[pConfig->nCol];
+ pCsr->aDoc = &pCsr->aCnt[pFts5->pConfig->nCol];
}else{
sqlite3_finalize(pStmt);
}
@@ -387,6 +388,7 @@ static void fts5VocabResetCursor(Fts5VocabCursor *pCsr){
sqlite3_free(pCsr->zLeTerm);
pCsr->nLeTerm = -1;
pCsr->zLeTerm = 0;
+ pCsr->bEof = 0;
}
/*
@@ -425,7 +427,7 @@ static int fts5VocabInstanceNewTerm(Fts5VocabCursor *pCsr){
}
static int fts5VocabInstanceNext(Fts5VocabCursor *pCsr){
- int eDetail = pCsr->pConfig->eDetail;
+ int eDetail = pCsr->pFts5->pConfig->eDetail;
int rc = SQLITE_OK;
Fts5IndexIter *pIter = pCsr->pIter;
i64 *pp = &pCsr->iInstPos;
@@ -460,7 +462,7 @@ static int fts5VocabNextMethod(sqlite3_vtab_cursor *pCursor){
Fts5VocabCursor *pCsr = (Fts5VocabCursor*)pCursor;
Fts5VocabTable *pTab = (Fts5VocabTable*)pCursor->pVtab;
int rc = SQLITE_OK;
- int nCol = pCsr->pConfig->nCol;
+ int nCol = pCsr->pFts5->pConfig->nCol;
pCsr->rowid++;
@@ -482,6 +484,7 @@ static int fts5VocabNextMethod(sqlite3_vtab_cursor *pCursor){
int nTerm;
zTerm = sqlite3Fts5IterTerm(pCsr->pIter, &nTerm);
+ assert( nTerm>=0 );
if( pCsr->nLeTerm>=0 ){
int nCmp = MIN(nTerm, pCsr->nLeTerm);
int bCmp = memcmp(pCsr->zLeTerm, zTerm, nCmp);
@@ -498,7 +501,7 @@ static int fts5VocabNextMethod(sqlite3_vtab_cursor *pCursor){
assert( pTab->eType==FTS5_VOCAB_COL || pTab->eType==FTS5_VOCAB_ROW );
while( rc==SQLITE_OK ){
- int eDetail = pCsr->pConfig->eDetail;
+ int eDetail = pCsr->pFts5->pConfig->eDetail;
const u8 *pPos; int nPos; /* Position list */
i64 iPos = 0; /* 64-bit position read from poslist */
int iOff = 0; /* Current offset within position list */
@@ -521,7 +524,6 @@ static int fts5VocabNextMethod(sqlite3_vtab_cursor *pCursor){
int iCol = -1;
while( 0==sqlite3Fts5PoslistNext64(pPos, nPos, &iOff, &iPos) ){
int ii = FTS5_POS2COLUMN(iPos);
- pCsr->aCnt[ii]++;
if( iCol!=ii ){
if( ii>=nCol ){
rc = FTS5_CORRUPT;
@@ -530,6 +532,7 @@ static int fts5VocabNextMethod(sqlite3_vtab_cursor *pCursor){
pCsr->aDoc[ii]++;
iCol = ii;
}
+ pCsr->aCnt[ii]++;
}
}else if( eDetail==FTS5_DETAIL_COLUMNS ){
while( 0==sqlite3Fts5PoslistNext64(pPos, nPos, &iOff,&iPos) ){
@@ -558,7 +561,9 @@ static int fts5VocabNextMethod(sqlite3_vtab_cursor *pCursor){
if( rc==SQLITE_OK ){
zTerm = sqlite3Fts5IterTerm(pCsr->pIter, &nTerm);
- if( nTerm!=pCsr->term.n || memcmp(zTerm, pCsr->term.p, nTerm) ){
+ if( nTerm!=pCsr->term.n
+ || (nTerm>0 && memcmp(zTerm, pCsr->term.p, nTerm))
+ ){
break;
}
if( sqlite3Fts5IterEof(pCsr->pIter) ) break;
@@ -569,7 +574,7 @@ static int fts5VocabNextMethod(sqlite3_vtab_cursor *pCursor){
if( rc==SQLITE_OK && pCsr->bEof==0 && pTab->eType==FTS5_VOCAB_COL ){
while( pCsr->aDoc[pCsr->iCol]==0 ) pCsr->iCol++;
- assert( pCsr->iCol<pCsr->pConfig->nCol );
+ assert( pCsr->iCol<pCsr->pFts5->pConfig->nCol );
}
return rc;
}
@@ -616,6 +621,7 @@ static int fts5VocabFilterMethod(
}
if( pLe ){
const char *zCopy = (const char *)sqlite3_value_text(pLe);
+ if( zCopy==0 ) zCopy = "";
pCsr->nLeTerm = sqlite3_value_bytes(pLe);
pCsr->zLeTerm = sqlite3_malloc(pCsr->nLeTerm+1);
if( pCsr->zLeTerm==0 ){
@@ -627,14 +633,15 @@ static int fts5VocabFilterMethod(
}
if( rc==SQLITE_OK ){
- rc = sqlite3Fts5IndexQuery(pCsr->pIndex, zTerm, nTerm, f, 0, &pCsr->pIter);
+ Fts5Index *pIndex = pCsr->pFts5->pIndex;
+ rc = sqlite3Fts5IndexQuery(pIndex, zTerm, nTerm, f, 0, &pCsr->pIter);
}
if( rc==SQLITE_OK && eType==FTS5_VOCAB_INSTANCE ){
rc = fts5VocabInstanceNewTerm(pCsr);
}
- if( rc==SQLITE_OK
- && !pCsr->bEof
- && (eType!=FTS5_VOCAB_INSTANCE || pCsr->pConfig->eDetail!=FTS5_DETAIL_NONE)
+ if( rc==SQLITE_OK && !pCsr->bEof
+ && (eType!=FTS5_VOCAB_INSTANCE
+ || pCsr->pFts5->pConfig->eDetail!=FTS5_DETAIL_NONE)
){
rc = fts5VocabNextMethod(pCursor);
}
@@ -657,7 +664,7 @@ static int fts5VocabColumnMethod(
int iCol /* Index of column to read value from */
){
Fts5VocabCursor *pCsr = (Fts5VocabCursor*)pCursor;
- int eDetail = pCsr->pConfig->eDetail;
+ int eDetail = pCsr->pFts5->pConfig->eDetail;
int eType = ((Fts5VocabTable*)(pCursor->pVtab))->eType;
i64 iVal = 0;
@@ -669,7 +676,7 @@ static int fts5VocabColumnMethod(
assert( iCol==1 || iCol==2 || iCol==3 );
if( iCol==1 ){
if( eDetail!=FTS5_DETAIL_NONE ){
- const char *z = pCsr->pConfig->azCol[pCsr->iCol];
+ const char *z = pCsr->pFts5->pConfig->azCol[pCsr->iCol];
sqlite3_result_text(pCtx, z, -1, SQLITE_STATIC);
}
}else if( iCol==2 ){
@@ -697,8 +704,8 @@ static int fts5VocabColumnMethod(
}else if( eDetail==FTS5_DETAIL_COLUMNS ){
ii = (int)pCsr->iInstPos;
}
- if( ii>=0 && ii<pCsr->pConfig->nCol ){
- const char *z = pCsr->pConfig->azCol[ii];
+ if( ii>=0 && ii<pCsr->pFts5->pConfig->nCol ){
+ const char *z = pCsr->pFts5->pConfig->azCol[ii];
sqlite3_result_text(pCtx, z, -1, SQLITE_STATIC);
}
break;
diff --git a/chromium/third_party/sqlite/src/ext/misc/amatch.c b/chromium/third_party/sqlite/src/ext/misc/amatch.c
index 519a5a0bf62..7bc09be38f1 100644
--- a/chromium/third_party/sqlite/src/ext/misc/amatch.c
+++ b/chromium/third_party/sqlite/src/ext/misc/amatch.c
@@ -619,7 +619,7 @@ static int amatchLoadOneRule(
if( p->rDel==0 || p->rDel>rCost ) p->rDel = rCost;
}else
{
- pRule = sqlite3_malloc( sizeof(*pRule) + nFrom + nTo );
+ pRule = sqlite3_malloc64( sizeof(*pRule) + nFrom + nTo );
if( pRule==0 ){
rc = SQLITE_NOMEM;
}else{
@@ -738,11 +738,11 @@ static int amatchLoadRules(
** `mno` becomes mno
*/
static char *amatchDequote(const char *zIn){
- int nIn; /* Size of input string, in bytes */
+ sqlite3_int64 nIn; /* Size of input string, in bytes */
char *zOut; /* Output (dequoted) string */
- nIn = (int)strlen(zIn);
- zOut = sqlite3_malloc(nIn+1);
+ nIn = strlen(zIn);
+ zOut = sqlite3_malloc64(nIn+1);
if( zOut ){
char q = zIn[0]; /* Quote character (if any ) */
@@ -1069,7 +1069,7 @@ static void amatchAddWord(
}
return;
}
- pWord = sqlite3_malloc( sizeof(*pWord) + nBase + nTail - 1 );
+ pWord = sqlite3_malloc64( sizeof(*pWord) + nBase + nTail - 1 );
if( pWord==0 ) return;
memset(pWord, 0, sizeof(*pWord));
pWord->rCost = rCost;
diff --git a/chromium/third_party/sqlite/src/ext/misc/closure.c b/chromium/third_party/sqlite/src/ext/misc/closure.c
index bf1a8696fcb..6aa2b1ef919 100644
--- a/chromium/third_party/sqlite/src/ext/misc/closure.c
+++ b/chromium/third_party/sqlite/src/ext/misc/closure.c
@@ -422,11 +422,11 @@ static closure_avl *queuePull(closure_queue *pQueue){
** `mno` becomes mno
*/
static char *closureDequote(const char *zIn){
- int nIn; /* Size of input string, in bytes */
+ sqlite3_int64 nIn; /* Size of input string, in bytes */
char *zOut; /* Output (dequoted) string */
- nIn = (int)strlen(zIn);
- zOut = sqlite3_malloc(nIn+1);
+ nIn = strlen(zIn);
+ zOut = sqlite3_malloc64(nIn+1);
if( zOut ){
char q = zIn[0]; /* Quote character (if any ) */
diff --git a/chromium/third_party/sqlite/src/ext/misc/csv.c b/chromium/third_party/sqlite/src/ext/misc/csv.c
index be58a3a9f8b..f0b7ba7b75d 100644
--- a/chromium/third_party/sqlite/src/ext/misc/csv.c
+++ b/chromium/third_party/sqlite/src/ext/misc/csv.c
@@ -621,7 +621,7 @@ static int csvtabConnect(
}else if( pNew->zData ){
pNew->iStart = (int)sRdr.iIn;
}else{
- pNew->iStart = ftell(sRdr.in);
+ pNew->iStart = (int)(ftell(sRdr.in) - sRdr.nIn + sRdr.iIn);
}
csv_reader_reset(&sRdr);
rc = sqlite3_declare_vtab(db, CSV_SCHEMA);
diff --git a/chromium/third_party/sqlite/src/ext/misc/dbdump.c b/chromium/third_party/sqlite/src/ext/misc/dbdump.c
index 60ade041ef1..014e7e312af 100644
--- a/chromium/third_party/sqlite/src/ext/misc/dbdump.c
+++ b/chromium/third_party/sqlite/src/ext/misc/dbdump.c
@@ -195,7 +195,7 @@ static char **tableColumnList(DState *p, const char *zTab){
if( nCol>=nAlloc-2 ){
char **azNew;
nAlloc = nAlloc*2 + nCol + 10;
- azNew = sqlite3_realloc(azCol, nAlloc*sizeof(azCol[0]));
+ azNew = sqlite3_realloc64(azCol, nAlloc*sizeof(azCol[0]));
if( azNew==0 ) goto col_oom;
azCol = azNew;
azCol[0] = 0;
diff --git a/chromium/third_party/sqlite/src/ext/misc/eval.c b/chromium/third_party/sqlite/src/ext/misc/eval.c
index 9094e8f43ae..4990bc0d8da 100644
--- a/chromium/third_party/sqlite/src/ext/misc/eval.c
+++ b/chromium/third_party/sqlite/src/ext/misc/eval.c
@@ -44,7 +44,7 @@ static int callback(void *pCtx, int argc, char **argv, char **colnames){
/* Using sqlite3_realloc64() would be better, but it is a recent
** addition and will cause a segfault if loaded by an older version
** of SQLite. */
- zNew = p->nAlloc<=0x7fffffff ? sqlite3_realloc(p->z, (int)p->nAlloc) : 0;
+ zNew = p->nAlloc<=0x7fffffff ? sqlite3_realloc64(p->z, p->nAlloc) : 0;
if( zNew==0 ){
sqlite3_free(p->z);
memset(p, 0, sizeof(*p));
diff --git a/chromium/third_party/sqlite/src/ext/misc/fileio.c b/chromium/third_party/sqlite/src/ext/misc/fileio.c
index 49f6f8aeb43..2383cd9446c 100644
--- a/chromium/third_party/sqlite/src/ext/misc/fileio.c
+++ b/chromium/third_party/sqlite/src/ext/misc/fileio.c
@@ -121,22 +121,47 @@ SQLITE_EXTENSION_INIT1
/*
** Set the result stored by context ctx to a blob containing the
-** contents of file zName.
+** contents of file zName. Or, leave the result unchanged (NULL)
+** if the file does not exist or is unreadable.
+**
+** If the file exceeds the SQLite blob size limit, through an
+** SQLITE_TOOBIG error.
+**
+** Throw an SQLITE_IOERR if there are difficulties pulling the file
+** off of disk.
*/
static void readFileContents(sqlite3_context *ctx, const char *zName){
FILE *in;
- long nIn;
+ sqlite3_int64 nIn;
void *pBuf;
+ sqlite3 *db;
+ int mxBlob;
in = fopen(zName, "rb");
- if( in==0 ) return;
+ if( in==0 ){
+ /* File does not exist or is unreadable. Leave the result set to NULL. */
+ return;
+ }
fseek(in, 0, SEEK_END);
nIn = ftell(in);
rewind(in);
- pBuf = sqlite3_malloc( nIn );
- if( pBuf && 1==fread(pBuf, nIn, 1, in) ){
- sqlite3_result_blob(ctx, pBuf, nIn, sqlite3_free);
+ db = sqlite3_context_db_handle(ctx);
+ mxBlob = sqlite3_limit(db, SQLITE_LIMIT_LENGTH, -1);
+ if( nIn>mxBlob ){
+ sqlite3_result_error_code(ctx, SQLITE_TOOBIG);
+ fclose(in);
+ return;
+ }
+ pBuf = sqlite3_malloc64( nIn );
+ if( pBuf==0 ){
+ sqlite3_result_error_nomem(ctx);
+ fclose(in);
+ return;
+ }
+ if( 1==fread(pBuf, nIn, 1, in) ){
+ sqlite3_result_blob64(ctx, pBuf, nIn, sqlite3_free);
}else{
+ sqlite3_result_error_code(ctx, SQLITE_IOERR);
sqlite3_free(pBuf);
}
fclose(in);
@@ -646,8 +671,8 @@ static int fsdirNext(sqlite3_vtab_cursor *cur){
FsdirLevel *pLvl;
if( iNew>=pCur->nLvl ){
int nNew = iNew+1;
- int nByte = nNew*sizeof(FsdirLevel);
- FsdirLevel *aNew = (FsdirLevel*)sqlite3_realloc(pCur->aLvl, nByte);
+ sqlite3_int64 nByte = nNew*sizeof(FsdirLevel);
+ FsdirLevel *aNew = (FsdirLevel*)sqlite3_realloc64(pCur->aLvl, nByte);
if( aNew==0 ) return SQLITE_NOMEM;
memset(&aNew[pCur->nLvl], 0, sizeof(FsdirLevel)*(nNew-pCur->nLvl));
pCur->aLvl = aNew;
@@ -727,7 +752,7 @@ static int fsdirColumn(
}else if( S_ISLNK(m) ){
char aStatic[64];
char *aBuf = aStatic;
- int nBuf = 64;
+ sqlite3_int64 nBuf = 64;
int n;
while( 1 ){
@@ -735,7 +760,7 @@ static int fsdirColumn(
if( n<nBuf ) break;
if( aBuf!=aStatic ) sqlite3_free(aBuf);
nBuf = nBuf*2;
- aBuf = sqlite3_malloc(nBuf);
+ aBuf = sqlite3_malloc64(nBuf);
if( aBuf==0 ){
sqlite3_result_error_nomem(ctx);
return SQLITE_NOMEM;
diff --git a/chromium/third_party/sqlite/src/ext/misc/fuzzer.c b/chromium/third_party/sqlite/src/ext/misc/fuzzer.c
index 8756b6313ac..94bf74dae93 100644
--- a/chromium/third_party/sqlite/src/ext/misc/fuzzer.c
+++ b/chromium/third_party/sqlite/src/ext/misc/fuzzer.c
@@ -337,7 +337,7 @@ static int fuzzerLoadOneRule(
rc = SQLITE_ERROR;
}else{
- pRule = sqlite3_malloc( sizeof(*pRule) + nFrom + nTo );
+ pRule = sqlite3_malloc64( sizeof(*pRule) + nFrom + nTo );
if( pRule==0 ){
rc = SQLITE_NOMEM;
}else{
@@ -447,11 +447,11 @@ static int fuzzerLoadRules(
** `mno` becomes mno
*/
static char *fuzzerDequote(const char *zIn){
- int nIn; /* Size of input string, in bytes */
+ sqlite3_int64 nIn; /* Size of input string, in bytes */
char *zOut; /* Output (dequoted) string */
- nIn = (int)strlen(zIn);
- zOut = sqlite3_malloc(nIn+1);
+ nIn = strlen(zIn);
+ zOut = sqlite3_malloc64(nIn+1);
if( zOut ){
char q = zIn[0]; /* Quote character (if any ) */
@@ -513,10 +513,10 @@ static int fuzzerConnect(
);
rc = SQLITE_ERROR;
}else{
- int nModule; /* Length of zModule, in bytes */
+ sqlite3_int64 nModule; /* Length of zModule, in bytes */
- nModule = (int)strlen(zModule);
- pNew = sqlite3_malloc( sizeof(*pNew) + nModule + 1);
+ nModule = strlen(zModule);
+ pNew = sqlite3_malloc64( sizeof(*pNew) + nModule + 1);
if( pNew==0 ){
rc = SQLITE_NOMEM;
}else{
@@ -872,7 +872,7 @@ static fuzzer_stem *fuzzerNewStem(
fuzzer_rule *pRule;
unsigned int h;
- pNew = sqlite3_malloc( sizeof(*pNew) + (int)strlen(zWord) + 1 );
+ pNew = sqlite3_malloc64( sizeof(*pNew) + strlen(zWord) + 1 );
if( pNew==0 ) return 0;
memset(pNew, 0, sizeof(*pNew));
pNew->zBasis = (char*)&pNew[1];
diff --git a/chromium/third_party/sqlite/src/ext/misc/json1.c b/chromium/third_party/sqlite/src/ext/misc/json1.c
index 2a99e3b73b7..8a64103043f 100644
--- a/chromium/third_party/sqlite/src/ext/misc/json1.c
+++ b/chromium/third_party/sqlite/src/ext/misc/json1.c
@@ -691,7 +691,7 @@ static JSON_NOINLINE int jsonParseAddNodeExpand(
assert( pParse->nNode>=pParse->nAlloc );
if( pParse->oom ) return -1;
nNew = pParse->nAlloc*2 + 10;
- pNew = sqlite3_realloc(pParse->aNode, sizeof(JsonNode)*nNew);
+ pNew = sqlite3_realloc64(pParse->aNode, sizeof(JsonNode)*nNew);
if( pNew==0 ){
pParse->oom = 1;
return -1;
@@ -965,7 +965,7 @@ static void jsonParseFillInParentage(JsonParse *pParse, u32 i, u32 iParent){
static int jsonParseFindParents(JsonParse *pParse){
u32 *aUp;
assert( pParse->aUp==0 );
- aUp = pParse->aUp = sqlite3_malloc( sizeof(u32)*pParse->nNode );
+ aUp = pParse->aUp = sqlite3_malloc64( sizeof(u32)*pParse->nNode );
if( aUp==0 ){
pParse->oom = 1;
return SQLITE_NOMEM;
@@ -1027,7 +1027,7 @@ static JsonParse *jsonParseCached(
pMatch->iHold = iMaxHold+1;
return pMatch;
}
- p = sqlite3_malloc( sizeof(*p) + nJson + 1 );
+ p = sqlite3_malloc64( sizeof(*p) + nJson + 1 );
if( p==0 ){
sqlite3_result_error_nomem(pCtx);
return 0;
diff --git a/chromium/third_party/sqlite/src/ext/misc/memstat.c b/chromium/third_party/sqlite/src/ext/misc/memstat.c
index f072398d2f6..2c7c69eff10 100644
--- a/chromium/third_party/sqlite/src/ext/misc/memstat.c
+++ b/chromium/third_party/sqlite/src/ext/misc/memstat.c
@@ -143,7 +143,7 @@ static int memstatFindSchemas(memstat_cursor *pCur){
}
while( sqlite3_step(pStmt)==SQLITE_ROW ){
char **az, *z;
- az = sqlite3_realloc(pCur->azDb, sizeof(char*)*(pCur->nDb+1));
+ az = sqlite3_realloc64(pCur->azDb, sizeof(char*)*(pCur->nDb+1));
if( az==0 ){
memstatClearSchema(pCur);
return SQLITE_NOMEM;
diff --git a/chromium/third_party/sqlite/src/ext/misc/memtrace.c b/chromium/third_party/sqlite/src/ext/misc/memtrace.c
new file mode 100644
index 00000000000..8a33caeb823
--- /dev/null
+++ b/chromium/third_party/sqlite/src/ext/misc/memtrace.c
@@ -0,0 +1,108 @@
+/*
+** 2019-01-21
+**
+** The author disclaims copyright to this source code. In place of
+** a legal notice, here is a blessing:
+**
+** May you do good and not evil.
+** May you find forgiveness for yourself and forgive others.
+** May you share freely, never taking more than you give.
+**
+*************************************************************************
+**
+** This file implements an extension that uses the SQLITE_CONFIG_MALLOC
+** mechanism to add a tracing layer on top of SQLite. If this extension
+** is registered prior to sqlite3_initialize(), it will cause all memory
+** allocation activities to be logged on standard output, or to some other
+** FILE specified by the initializer.
+**
+** This file needs to be compiled into the application that uses it.
+**
+** This extension is used to implement the --memtrace option of the
+** command-line shell.
+*/
+#include <assert.h>
+#include <string.h>
+#include <stdio.h>
+
+/* The original memory allocation routines */
+static sqlite3_mem_methods memtraceBase;
+static FILE *memtraceOut;
+
+/* Methods that trace memory allocations */
+static void *memtraceMalloc(int n){
+ if( memtraceOut ){
+ fprintf(memtraceOut, "MEMTRACE: allocate %d bytes\n",
+ memtraceBase.xRoundup(n));
+ }
+ return memtraceBase.xMalloc(n);
+}
+static void memtraceFree(void *p){
+ if( p==0 ) return;
+ if( memtraceOut ){
+ fprintf(memtraceOut, "MEMTRACE: free %d bytes\n", memtraceBase.xSize(p));
+ }
+ memtraceBase.xFree(p);
+}
+static void *memtraceRealloc(void *p, int n){
+ if( p==0 ) return memtraceMalloc(n);
+ if( n==0 ){
+ memtraceFree(p);
+ return 0;
+ }
+ if( memtraceOut ){
+ fprintf(memtraceOut, "MEMTRACE: resize %d -> %d bytes\n",
+ memtraceBase.xSize(p), memtraceBase.xRoundup(n));
+ }
+ return memtraceBase.xRealloc(p, n);
+}
+static int memtraceSize(void *p){
+ return memtraceBase.xSize(p);
+}
+static int memtraceRoundup(int n){
+ return memtraceBase.xRoundup(n);
+}
+static int memtraceInit(void *p){
+ return memtraceBase.xInit(p);
+}
+static void memtraceShutdown(void *p){
+ memtraceBase.xShutdown(p);
+}
+
+/* The substitute memory allocator */
+static sqlite3_mem_methods ersaztMethods = {
+ memtraceMalloc,
+ memtraceFree,
+ memtraceRealloc,
+ memtraceSize,
+ memtraceRoundup,
+ memtraceInit,
+ memtraceShutdown,
+ 0
+};
+
+/* Begin tracing memory allocations to out. */
+int sqlite3MemTraceActivate(FILE *out){
+ int rc = SQLITE_OK;
+ if( memtraceBase.xMalloc==0 ){
+ rc = sqlite3_config(SQLITE_CONFIG_GETMALLOC, &memtraceBase);
+ if( rc==SQLITE_OK ){
+ rc = sqlite3_config(SQLITE_CONFIG_MALLOC, &ersaztMethods);
+ }
+ }
+ memtraceOut = out;
+ return rc;
+}
+
+/* Deactivate memory tracing */
+int sqlite3MemTraceDeactivate(void){
+ int rc = SQLITE_OK;
+ if( memtraceBase.xMalloc!=0 ){
+ rc = sqlite3_config(SQLITE_CONFIG_MALLOC, &memtraceBase);
+ if( rc==SQLITE_OK ){
+ memset(&memtraceBase, 0, sizeof(memtraceBase));
+ }
+ }
+ memtraceOut = 0;
+ return rc;
+}
diff --git a/chromium/third_party/sqlite/src/ext/misc/mmapwarm.c b/chromium/third_party/sqlite/src/ext/misc/mmapwarm.c
index f4d1a01b54e..3e6a91d7393 100644
--- a/chromium/third_party/sqlite/src/ext/misc/mmapwarm.c
+++ b/chromium/third_party/sqlite/src/ext/misc/mmapwarm.c
@@ -105,4 +105,3 @@ int sqlite3_mmap_warm(sqlite3 *db, const char *zDb){
return rc;
}
-
diff --git a/chromium/third_party/sqlite/src/ext/misc/nextchar.c b/chromium/third_party/sqlite/src/ext/misc/nextchar.c
index 3a6e23de897..a0f77b04640 100644
--- a/chromium/third_party/sqlite/src/ext/misc/nextchar.c
+++ b/chromium/third_party/sqlite/src/ext/misc/nextchar.c
@@ -85,7 +85,7 @@ static void nextCharAppend(nextCharContext *p, unsigned c){
if( p->nUsed+1 > p->nAlloc ){
unsigned int *aNew;
int n = p->nAlloc*2 + 30;
- aNew = sqlite3_realloc(p->aResult, n*sizeof(unsigned int));
+ aNew = sqlite3_realloc64(p->aResult, n*sizeof(unsigned int));
if( aNew==0 ){
p->mallocFailed = 1;
return;
@@ -269,7 +269,7 @@ static void nextCharFunc(
sqlite3_result_error_nomem(context);
}else{
unsigned char *pRes;
- pRes = sqlite3_malloc( c.nUsed*4 + 1 );
+ pRes = sqlite3_malloc64( c.nUsed*4 + 1 );
if( pRes==0 ){
sqlite3_result_error_nomem(context);
}else{
diff --git a/chromium/third_party/sqlite/src/ext/misc/percentile.c b/chromium/third_party/sqlite/src/ext/misc/percentile.c
index 5b76777505c..dba66ca4766 100644
--- a/chromium/third_party/sqlite/src/ext/misc/percentile.c
+++ b/chromium/third_party/sqlite/src/ext/misc/percentile.c
@@ -151,7 +151,7 @@ static void percentStep(sqlite3_context *pCtx, int argc, sqlite3_value **argv){
/* Allocate and store the Y */
if( p->nUsed>=p->nAlloc ){
unsigned n = p->nAlloc*2 + 250;
- double *a = sqlite3_realloc(p->a, sizeof(double)*n);
+ double *a = sqlite3_realloc64(p->a, sizeof(double)*n);
if( a==0 ){
sqlite3_free(p->a);
memset(p, 0, sizeof(*p));
diff --git a/chromium/third_party/sqlite/src/ext/misc/prefixes.c b/chromium/third_party/sqlite/src/ext/misc/prefixes.c
new file mode 100644
index 00000000000..40fecd5e1df
--- /dev/null
+++ b/chromium/third_party/sqlite/src/ext/misc/prefixes.c
@@ -0,0 +1,319 @@
+/*
+** 2018-04-19
+**
+** The author disclaims copyright to this source code. In place of
+** a legal notice, here is a blessing:
+**
+** May you do good and not evil.
+** May you find forgiveness for yourself and forgive others.
+** May you share freely, never taking more than you give.
+**
+*************************************************************************
+**
+** This file implements a table-valued function:
+**
+** prefixes('abcdefg')
+**
+** The function has a single (non-HIDDEN) column named prefix that takes
+** on all prefixes of the string in its argument, including an empty string
+** and the input string itself. The order of prefixes is from longest
+** to shortest.
+*/
+#if !defined(SQLITE_CORE) || !defined(SQLITE_OMIT_VIRTUALTABLE)
+#if !defined(SQLITEINT_H)
+#include "sqlite3ext.h"
+#endif
+SQLITE_EXTENSION_INIT1
+#include <string.h>
+#include <assert.h>
+
+/* prefixes_vtab is a subclass of sqlite3_vtab which is
+** underlying representation of the virtual table
+*/
+typedef struct prefixes_vtab prefixes_vtab;
+struct prefixes_vtab {
+ sqlite3_vtab base; /* Base class - must be first */
+ /* No additional fields are necessary */
+};
+
+/* prefixes_cursor is a subclass of sqlite3_vtab_cursor which will
+** serve as the underlying representation of a cursor that scans
+** over rows of the result
+*/
+typedef struct prefixes_cursor prefixes_cursor;
+struct prefixes_cursor {
+ sqlite3_vtab_cursor base; /* Base class - must be first */
+ sqlite3_int64 iRowid; /* The rowid */
+ char *zStr; /* Original string to be prefixed */
+ int nStr; /* Length of the string in bytes */
+};
+
+/*
+** The prefixesConnect() method is invoked to create a new
+** template virtual table.
+**
+** Think of this routine as the constructor for prefixes_vtab objects.
+**
+** All this routine needs to do is:
+**
+** (1) Allocate the prefixes_vtab object and initialize all fields.
+**
+** (2) Tell SQLite (via the sqlite3_declare_vtab() interface) what the
+** result set of queries against the virtual table will look like.
+*/
+static int prefixesConnect(
+ sqlite3 *db,
+ void *pAux,
+ int argc, const char *const*argv,
+ sqlite3_vtab **ppVtab,
+ char **pzErr
+){
+ prefixes_vtab *pNew;
+ int rc;
+
+ rc = sqlite3_declare_vtab(db,
+ "CREATE TABLE prefixes(prefix TEXT, original_string TEXT HIDDEN)"
+ );
+ if( rc==SQLITE_OK ){
+ pNew = sqlite3_malloc( sizeof(*pNew) );
+ *ppVtab = (sqlite3_vtab*)pNew;
+ if( pNew==0 ) return SQLITE_NOMEM;
+ memset(pNew, 0, sizeof(*pNew));
+ }
+ return rc;
+}
+
+/*
+** This method is the destructor for prefixes_vtab objects.
+*/
+static int prefixesDisconnect(sqlite3_vtab *pVtab){
+ prefixes_vtab *p = (prefixes_vtab*)pVtab;
+ sqlite3_free(p);
+ return SQLITE_OK;
+}
+
+/*
+** Constructor for a new prefixes_cursor object.
+*/
+static int prefixesOpen(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor){
+ prefixes_cursor *pCur;
+ pCur = sqlite3_malloc( sizeof(*pCur) );
+ if( pCur==0 ) return SQLITE_NOMEM;
+ memset(pCur, 0, sizeof(*pCur));
+ *ppCursor = &pCur->base;
+ return SQLITE_OK;
+}
+
+/*
+** Destructor for a prefixes_cursor.
+*/
+static int prefixesClose(sqlite3_vtab_cursor *cur){
+ prefixes_cursor *pCur = (prefixes_cursor*)cur;
+ sqlite3_free(pCur->zStr);
+ sqlite3_free(pCur);
+ return SQLITE_OK;
+}
+
+
+/*
+** Advance a prefixes_cursor to its next row of output.
+*/
+static int prefixesNext(sqlite3_vtab_cursor *cur){
+ prefixes_cursor *pCur = (prefixes_cursor*)cur;
+ pCur->iRowid++;
+ return SQLITE_OK;
+}
+
+/*
+** Return values of columns for the row at which the prefixes_cursor
+** is currently pointing.
+*/
+static int prefixesColumn(
+ sqlite3_vtab_cursor *cur, /* The cursor */
+ sqlite3_context *ctx, /* First argument to sqlite3_result_...() */
+ int i /* Which column to return */
+){
+ prefixes_cursor *pCur = (prefixes_cursor*)cur;
+ switch( i ){
+ case 0:
+ sqlite3_result_text(ctx, pCur->zStr, pCur->nStr - (int)pCur->iRowid,
+ 0);
+ break;
+ default:
+ sqlite3_result_text(ctx, pCur->zStr, pCur->nStr, 0);
+ break;
+ }
+ return SQLITE_OK;
+}
+
+/*
+** Return the rowid for the current row. In this implementation, the
+** rowid is the same as the output value.
+*/
+static int prefixesRowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){
+ prefixes_cursor *pCur = (prefixes_cursor*)cur;
+ *pRowid = pCur->iRowid;
+ return SQLITE_OK;
+}
+
+/*
+** Return TRUE if the cursor has been moved off of the last
+** row of output.
+*/
+static int prefixesEof(sqlite3_vtab_cursor *cur){
+ prefixes_cursor *pCur = (prefixes_cursor*)cur;
+ return pCur->iRowid>pCur->nStr;
+}
+
+/*
+** This method is called to "rewind" the prefixes_cursor object back
+** to the first row of output. This method is always called at least
+** once prior to any call to prefixesColumn() or prefixesRowid() or
+** prefixesEof().
+*/
+static int prefixesFilter(
+ sqlite3_vtab_cursor *pVtabCursor,
+ int idxNum, const char *idxStr,
+ int argc, sqlite3_value **argv
+){
+ prefixes_cursor *pCur = (prefixes_cursor *)pVtabCursor;
+ sqlite3_free(pCur->zStr);
+ if( argc>0 ){
+ pCur->zStr = sqlite3_mprintf("%s", sqlite3_value_text(argv[0]));
+ pCur->nStr = pCur->zStr ? (int)strlen(pCur->zStr) : 0;
+ }else{
+ pCur->zStr = 0;
+ pCur->nStr = 0;
+ }
+ pCur->iRowid = 0;
+ return SQLITE_OK;
+}
+
+/*
+** SQLite will invoke this method one or more times while planning a query
+** that uses the virtual table. This routine needs to create
+** a query plan for each invocation and compute an estimated cost for that
+** plan.
+*/
+static int prefixesBestIndex(
+ sqlite3_vtab *tab,
+ sqlite3_index_info *pIdxInfo
+){
+ /* Search for a usable equality constraint against column 1
+ ** (original_string) and use it if at all possible */
+ int i;
+ const struct sqlite3_index_constraint *p;
+
+ for(i=0, p=pIdxInfo->aConstraint; i<pIdxInfo->nConstraint; i++, p++){
+ if( p->iColumn!=1 ) continue;
+ if( p->op!=SQLITE_INDEX_CONSTRAINT_EQ ) continue;
+ if( !p->usable ) continue;
+ pIdxInfo->aConstraintUsage[i].argvIndex = 1;
+ pIdxInfo->aConstraintUsage[i].omit = 1;
+ pIdxInfo->estimatedCost = (double)10;
+ pIdxInfo->estimatedRows = 10;
+ return SQLITE_OK;
+ }
+ pIdxInfo->estimatedCost = (double)1000000000;
+ pIdxInfo->estimatedRows = 1000000000;
+ return SQLITE_OK;
+}
+
+/*
+** This following structure defines all the methods for the
+** virtual table.
+*/
+static sqlite3_module prefixesModule = {
+ /* iVersion */ 0,
+ /* xCreate */ 0,
+ /* xConnect */ prefixesConnect,
+ /* xBestIndex */ prefixesBestIndex,
+ /* xDisconnect */ prefixesDisconnect,
+ /* xDestroy */ 0,
+ /* xOpen */ prefixesOpen,
+ /* xClose */ prefixesClose,
+ /* xFilter */ prefixesFilter,
+ /* xNext */ prefixesNext,
+ /* xEof */ prefixesEof,
+ /* xColumn */ prefixesColumn,
+ /* xRowid */ prefixesRowid,
+ /* xUpdate */ 0,
+ /* xBegin */ 0,
+ /* xSync */ 0,
+ /* xCommit */ 0,
+ /* xRollback */ 0,
+ /* xFindMethod */ 0,
+ /* xRename */ 0,
+ /* xSavepoint */ 0,
+ /* xRelease */ 0,
+ /* xRollbackTo */ 0,
+ /* xShadowName */ 0
+};
+
+/*
+** This is a copy of the SQLITE_SKIP_UTF8(zIn) macro in sqliteInt.h.
+**
+** Assuming zIn points to the first byte of a UTF-8 character,
+** advance zIn to point to the first byte of the next UTF-8 character.
+*/
+#define PREFIX_SKIP_UTF8(zIn) { \
+ if( (*(zIn++))>=0xc0 ){ \
+ while( (*zIn & 0xc0)==0x80 ){ zIn++; } \
+ } \
+}
+
+/*
+** Implementation of function prefix_length(). This function accepts two
+** strings as arguments and returns the length in characters (not bytes),
+** of the longest prefix shared by the two strings. For example:
+**
+** prefix_length('abcdxxx', 'abcyy') == 3
+** prefix_length('abcdxxx', 'bcyyy') == 0
+** prefix_length('abcdxxx', 'ab') == 2
+** prefix_length('ab', 'abcd') == 2
+**
+** This function assumes the input is well-formed utf-8. If it is not,
+** it is possible for this function to return -1.
+*/
+static void prefixLengthFunc(
+ sqlite3_context *ctx,
+ int nVal,
+ sqlite3_value **apVal
+){
+ int nByte; /* Number of bytes to compare */
+ int nRet = 0; /* Return value */
+ const unsigned char *zL = sqlite3_value_text(apVal[0]);
+ const unsigned char *zR = sqlite3_value_text(apVal[1]);
+ int nL = sqlite3_value_bytes(apVal[0]);
+ int nR = sqlite3_value_bytes(apVal[1]);
+ int i;
+
+ nByte = (nL > nR ? nL : nR);
+ for(i=0; i<nByte; i++){
+ if( zL[i]!=zR[i] ) break;
+ if( (zL[i] & 0xC0)!=0x80 ) nRet++;
+ }
+
+ if( (zL[i] & 0xC0)==0x80 ) nRet--;
+ sqlite3_result_int(ctx, nRet);
+}
+
+#ifdef _WIN32
+__declspec(dllexport)
+#endif
+int sqlite3_prefixes_init(
+ sqlite3 *db,
+ char **pzErrMsg,
+ const sqlite3_api_routines *pApi
+){
+ int rc = SQLITE_OK;
+ SQLITE_EXTENSION_INIT2(pApi);
+ rc = sqlite3_create_module(db, "prefixes", &prefixesModule, 0);
+ if( rc==SQLITE_OK ){
+ rc = sqlite3_create_function(
+ db, "prefix_length", 2, SQLITE_UTF8, 0, prefixLengthFunc, 0, 0
+ );
+ }
+ return rc;
+}
+#endif /* !defined(SQLITE_CORE) || !defined(SQLITE_OMIT_VIRTUALTABLE) */
diff --git a/chromium/third_party/sqlite/src/ext/misc/regexp.c b/chromium/third_party/sqlite/src/ext/misc/regexp.c
index 9001fef6fd9..5f6b7ce3e74 100644
--- a/chromium/third_party/sqlite/src/ext/misc/regexp.c
+++ b/chromium/third_party/sqlite/src/ext/misc/regexp.c
@@ -225,7 +225,7 @@ static int re_match(ReCompiled *pRe, const unsigned char *zIn, int nIn){
pToFree = 0;
aStateSet[0].aState = aSpace;
}else{
- pToFree = sqlite3_malloc( sizeof(ReStateNumber)*2*pRe->nState );
+ pToFree = sqlite3_malloc64( sizeof(ReStateNumber)*2*pRe->nState );
if( pToFree==0 ) return -1;
aStateSet[0].aState = pToFree;
}
@@ -337,10 +337,10 @@ re_match_end:
static int re_resize(ReCompiled *p, int N){
char *aOp;
int *aArg;
- aOp = sqlite3_realloc(p->aOp, N*sizeof(p->aOp[0]));
+ aOp = sqlite3_realloc64(p->aOp, N*sizeof(p->aOp[0]));
if( aOp==0 ) return 1;
p->aOp = aOp;
- aArg = sqlite3_realloc(p->aArg, N*sizeof(p->aArg[0]));
+ aArg = sqlite3_realloc64(p->aArg, N*sizeof(p->aArg[0]));
if( aArg==0 ) return 1;
p->aArg = aArg;
p->nAlloc = N;
diff --git a/chromium/third_party/sqlite/src/ext/misc/unionvtab.c b/chromium/third_party/sqlite/src/ext/misc/unionvtab.c
index 8a1d493de50..8e3784e81fd 100644
--- a/chromium/third_party/sqlite/src/ext/misc/unionvtab.c
+++ b/chromium/third_party/sqlite/src/ext/misc/unionvtab.c
@@ -250,11 +250,11 @@ struct UnionCsr {
** is attempted but fails, NULL is returned and *pRc is set to
** SQLITE_NOMEM.
*/
-static void *unionMalloc(int *pRc, int nByte){
+static void *unionMalloc(int *pRc, sqlite3_int64 nByte){
void *pRet;
assert( nByte>0 );
if( *pRc==SQLITE_OK ){
- pRet = sqlite3_malloc(nByte);
+ pRet = sqlite3_malloc64(nByte);
if( pRet ){
memset(pRet, 0, nByte);
}else{
@@ -276,7 +276,7 @@ static void *unionMalloc(int *pRc, int nByte){
static char *unionStrdup(int *pRc, const char *zIn){
char *zRet = 0;
if( zIn ){
- int nByte = (int)strlen(zIn) + 1;
+ sqlite3_int64 nByte = strlen(zIn) + 1;
zRet = unionMalloc(pRc, nByte);
if( zRet ){
memcpy(zRet, zIn, nByte);
@@ -939,7 +939,7 @@ static int unionConnect(
/* Grow the pTab->aSrc[] array if required. */
if( nAlloc<=pTab->nSrc ){
int nNew = nAlloc ? nAlloc*2 : 8;
- UnionSrc *aNew = (UnionSrc*)sqlite3_realloc(
+ UnionSrc *aNew = (UnionSrc*)sqlite3_realloc64(
pTab->aSrc, nNew*sizeof(UnionSrc)
);
if( aNew==0 ){
diff --git a/chromium/third_party/sqlite/src/ext/misc/vfslog.c b/chromium/third_party/sqlite/src/ext/misc/vfslog.c
index 263037ef77d..c9cbc80f72b 100644
--- a/chromium/third_party/sqlite/src/ext/misc/vfslog.c
+++ b/chromium/third_party/sqlite/src/ext/misc/vfslog.c
@@ -276,7 +276,7 @@ static VLogLog *vlogLogOpen(const char *zFilename){
&& sqlite3_strglob("-mj??????9??", zFilename+nName-12)==0 ){
return 0; /* Do not log master journal files */
}
- pTemp = sqlite3_malloc( sizeof(*pLog)*2 + nName + 60 );
+ pTemp = sqlite3_malloc64( sizeof(*pLog)*2 + nName + 60 );
if( pTemp==0 ) return 0;
pMutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER);
sqlite3_mutex_enter(pMutex);
diff --git a/chromium/third_party/sqlite/src/ext/misc/zipfile.c b/chromium/third_party/sqlite/src/ext/misc/zipfile.c
index a69f3a7e9e9..5a88389bf2d 100644
--- a/chromium/third_party/sqlite/src/ext/misc/zipfile.c
+++ b/chromium/third_party/sqlite/src/ext/misc/zipfile.c
@@ -358,7 +358,7 @@ static int zipfileConnect(
rc = sqlite3_declare_vtab(db, ZIPFILE_SCHEMA);
if( rc==SQLITE_OK ){
- pNew = (ZipfileTab*)sqlite3_malloc(nByte+nFile);
+ pNew = (ZipfileTab*)sqlite3_malloc64((sqlite3_int64)nByte+nFile);
if( pNew==0 ) return SQLITE_NOMEM;
memset(pNew, 0, nByte+nFile);
pNew->db = db;
@@ -806,7 +806,7 @@ static int zipfileGetEntry(
}
if( rc==SQLITE_OK ){
- int nAlloc;
+ sqlite3_int64 nAlloc;
ZipfileEntry *pNew;
int nFile = zipfileGetU16(&aRead[ZIPFILE_CDS_NFILE_OFF]);
@@ -818,7 +818,7 @@ static int zipfileGetEntry(
nAlloc += zipfileGetU32(&aRead[ZIPFILE_CDS_SZCOMPRESSED_OFF]);
}
- pNew = (ZipfileEntry*)sqlite3_malloc(nAlloc);
+ pNew = (ZipfileEntry*)sqlite3_malloc64(nAlloc);
if( pNew==0 ){
rc = SQLITE_NOMEM;
}else{
@@ -981,11 +981,11 @@ static int zipfileDeflate(
u8 **ppOut, int *pnOut, /* Output */
char **pzErr /* OUT: Error message */
){
- int nAlloc = (int)compressBound(nIn);
+ sqlite3_int64 nAlloc = compressBound(nIn);
u8 *aOut;
int rc = SQLITE_OK;
- aOut = (u8*)sqlite3_malloc(nAlloc);
+ aOut = (u8*)sqlite3_malloc64(nAlloc);
if( aOut==0 ){
rc = SQLITE_NOMEM;
}else{
@@ -1058,7 +1058,7 @@ static int zipfileColumn(
if( pCsr->pCurrent->aData ){
aBuf = pCsr->pCurrent->aData;
}else{
- aBuf = aFree = sqlite3_malloc(sz);
+ aBuf = aFree = sqlite3_malloc64(sz);
if( aBuf==0 ){
rc = SQLITE_NOMEM;
}else{
@@ -1897,14 +1897,14 @@ struct ZipfileCtx {
static int zipfileBufferGrow(ZipfileBuffer *pBuf, int nByte){
if( pBuf->n+nByte>pBuf->nAlloc ){
u8 *aNew;
- int nNew = pBuf->n ? pBuf->n*2 : 512;
+ sqlite3_int64 nNew = pBuf->n ? pBuf->n*2 : 512;
int nReq = pBuf->n + nByte;
while( nNew<nReq ) nNew = nNew*2;
- aNew = sqlite3_realloc(pBuf->a, nNew);
+ aNew = sqlite3_realloc64(pBuf->a, nNew);
if( aNew==0 ) return SQLITE_NOMEM;
pBuf->a = aNew;
- pBuf->nAlloc = nNew;
+ pBuf->nAlloc = (int)nNew;
}
return SQLITE_OK;
}
@@ -2095,7 +2095,7 @@ void zipfileStep(sqlite3_context *pCtx, int nVal, sqlite3_value **apVal){
void zipfileFinal(sqlite3_context *pCtx){
ZipfileCtx *p;
ZipfileEOCD eocd;
- int nZip;
+ sqlite3_int64 nZip;
u8 *aZip;
p = (ZipfileCtx*)sqlite3_aggregate_context(pCtx, sizeof(ZipfileCtx));
@@ -2108,14 +2108,14 @@ void zipfileFinal(sqlite3_context *pCtx){
eocd.iOffset = p->body.n;
nZip = p->body.n + p->cds.n + ZIPFILE_EOCD_FIXED_SZ;
- aZip = (u8*)sqlite3_malloc(nZip);
+ aZip = (u8*)sqlite3_malloc64(nZip);
if( aZip==0 ){
sqlite3_result_error_nomem(pCtx);
}else{
memcpy(aZip, p->body.a, p->body.n);
memcpy(&aZip[p->body.n], p->cds.a, p->cds.n);
zipfileSerializeEOCD(&eocd, &aZip[p->body.n + p->cds.n]);
- sqlite3_result_blob(pCtx, aZip, nZip, zipfileFree);
+ sqlite3_result_blob(pCtx, aZip, (int)nZip, zipfileFree);
}
}
diff --git a/chromium/third_party/sqlite/src/ext/rbu/rbu_common.tcl b/chromium/third_party/sqlite/src/ext/rbu/rbu_common.tcl
index 2b263b7660d..b5e63aafe55 100644
--- a/chromium/third_party/sqlite/src/ext/rbu/rbu_common.tcl
+++ b/chromium/third_party/sqlite/src/ext/rbu/rbu_common.tcl
@@ -86,12 +86,13 @@ proc step_rbu_legacy {target rbu} {
set rc
}
-proc do_rbu_vacuum_test {tn step} {
- forcedelete state.db
- uplevel [list do_test $tn.1 {
- if {$step==0} { sqlite3rbu_vacuum rbu test.db state.db }
+proc do_rbu_vacuum_test {tn step {statedb state.db}} {
+ forcedelete $statedb
+ if {$statedb=="" && $step==1} breakpoint
+ uplevel [list do_test $tn.1 [string map [list %state% $statedb] {
+ if {$step==0} { sqlite3rbu_vacuum rbu test.db {%state%}}
while 1 {
- if {$step==1} { sqlite3rbu_vacuum rbu test.db state.db }
+ if {$step==1} { sqlite3rbu_vacuum rbu test.db {%state%}}
set state [rbu state]
check_prestep_state test.db $state
set rc [rbu step]
@@ -100,7 +101,7 @@ proc do_rbu_vacuum_test {tn step} {
if {$step==1} { rbu close }
}
rbu close
- } {SQLITE_DONE}]
+ }] {SQLITE_DONE}]
uplevel [list do_execsql_test $tn.2 {
PRAGMA integrity_check
diff --git a/chromium/third_party/sqlite/src/ext/rbu/rbuvacuum2.test b/chromium/third_party/sqlite/src/ext/rbu/rbuvacuum2.test
index 140a0c1a8c4..6827725fb57 100644
--- a/chromium/third_party/sqlite/src/ext/rbu/rbuvacuum2.test
+++ b/chromium/third_party/sqlite/src/ext/rbu/rbuvacuum2.test
@@ -16,8 +16,11 @@
source [file join [file dirname [info script]] rbu_common.tcl]
-foreach step {0 1} {
- set ::testprefix rbuvacuum2-$step
+foreach {step} {0 1} {
+foreach {ttt state} {
+ s state.db t test.db-vacuum n {}
+} {
+ set ::testprefix rbuvacuum2-$step$ttt
#-------------------------------------------------------------------------
# Test that a database that contains fts3 tables can be vacuumed.
@@ -29,7 +32,7 @@ foreach step {0 1} {
INSERT INTO t1 VALUES('fix this issue', 'at some point');
}
- do_rbu_vacuum_test 1.2 $step
+ do_rbu_vacuum_test 1.2 $step $state
do_execsql_test 1.3 {
SELECT * FROM t1;
@@ -46,7 +49,7 @@ foreach step {0 1} {
INSERT INTO t1 VALUES('a b c', 'x y z');
}
- do_rbu_vacuum_test 1.6 $step
+ do_rbu_vacuum_test 1.6 $step $state
do_execsql_test 1.7 {
INSERT INTO t1(t1) VALUES('integrity-check');
SELECT * FROM t1;
@@ -67,7 +70,7 @@ foreach step {0 1} {
INSERT INTO t1 VALUES('fix this issue', 'at some point');
}
- do_rbu_vacuum_test 2.2 $step
+ do_rbu_vacuum_test 2.2 $step $state
do_execsql_test 2.3 {
SELECT * FROM t1;
@@ -84,7 +87,7 @@ foreach step {0 1} {
INSERT INTO t1 VALUES('a b c', 'x y z');
}
- do_rbu_vacuum_test 2.6 $step
+ do_rbu_vacuum_test 2.6 $step $state
do_execsql_test 2.7 {
INSERT INTO t1(t1) VALUES('integrity-check');
SELECT * FROM t1;
@@ -107,7 +110,7 @@ foreach step {0 1} {
INSERT INTO rt VALUES(3, 55, 65);
}
- do_rbu_vacuum_test 3.2 $step
+ do_rbu_vacuum_test 3.2 $step $state
do_execsql_test 3.3 {
SELECT * FROM rt;
@@ -120,7 +123,7 @@ foreach step {0 1} {
SELECT rowid FROM rt WHERE x2>59 AND x1 < 59
} {2 3}
- do_rbu_vacuum_test 3.5 $step
+ do_rbu_vacuum_test 3.5 $step $state
do_execsql_test 3.6.1 {
SELECT rowid FROM rt WHERE x2>51 AND x1 < 51
@@ -147,7 +150,7 @@ foreach step {0 1} {
trigger tr1 t1 0 {CREATE TRIGGER tr1 AFTER INSERT ON t1 BEGIN SELECT 1; END}
}
- do_rbu_vacuum_test 4.3 $step
+ do_rbu_vacuum_test 4.3 $step $state
do_execsql_test 4.4 {
SELECT * FROM sqlite_master;
} {
@@ -157,6 +160,7 @@ foreach step {0 1} {
}
}
}
+}
#-------------------------------------------------------------------------
# Test that passing a NULL value as the second argument to
@@ -231,4 +235,9 @@ do_test 6.3 {
execsql { PRAGMA integrity_check }
} {ok}
+do_test 6.4 {
+ sqlite3rbu_vacuum rbu test.db test.db-vactmp
+ list [catch { rbu close } msg] $msg
+} {1 SQLITE_MISUSE}
+
finish_test
diff --git a/chromium/third_party/sqlite/src/ext/rbu/rbuvacuum3.test b/chromium/third_party/sqlite/src/ext/rbu/rbuvacuum3.test
new file mode 100644
index 00000000000..d0cf461b2b3
--- /dev/null
+++ b/chromium/third_party/sqlite/src/ext/rbu/rbuvacuum3.test
@@ -0,0 +1,63 @@
+# 2019 Jan 3
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file contains tests for the RBU module. More specifically, it
+# contains tests to ensure that the sqlite3rbu_vacuum() API works as
+# expected.
+#
+
+source [file join [file dirname [info script]] rbu_common.tcl]
+set testprefix rbuvacuum3
+
+do_execsql_test 1.0 {
+ CREATE TABLE t1(a PRIMARY KEY, b, c);
+ CREATE INDEX i1b ON t1(b);
+ CREATE INDEX i1c ON t1(c);
+
+ WITH s(i) AS (
+ VALUES(1) UNION ALL SELECT i+1 FROM s WHERE i<100
+ )
+ INSERT INTO t1 SELECT i, randomblob(100), randomblob(100) FROM s;
+}
+
+forcedelete state.db
+do_test 1.1 {
+ sqlite3rbu_vacuum rbu test.db state.db
+ while {1} {
+ set rc [rbu step]
+ if {$rc!="SQLITE_OK"} break
+ rbu savestate
+ }
+ rbu close
+} {SQLITE_DONE}
+
+do_test 1.2 {
+ sqlite3rbu_vacuum rbu test.db state.db
+ while {1} {
+ set rc [rbu step]
+ if {$rc!="SQLITE_OK"} break
+ rbu savestate
+ }
+ rbu close
+} {SQLITE_DONE}
+
+do_test 1.3 {
+ while {1} {
+ sqlite3rbu_vacuum rbu test.db state.db
+ set rc [rbu step]
+ if {$rc!="SQLITE_OK"} break
+ rbu savestate
+ rbu close
+ }
+ rbu close
+} {SQLITE_DONE}
+
+finish_test
diff --git a/chromium/third_party/sqlite/src/ext/rbu/sqlite3rbu.c b/chromium/third_party/sqlite/src/ext/rbu/sqlite3rbu.c
index 0762529dcb0..4c81dcf1107 100644
--- a/chromium/third_party/sqlite/src/ext/rbu/sqlite3rbu.c
+++ b/chromium/third_party/sqlite/src/ext/rbu/sqlite3rbu.c
@@ -2477,7 +2477,7 @@ static void rbuOpenDatabase(sqlite3rbu *p, int *pbRetry){
if( *zExtra=='\0' ) zExtra = 0;
}
- zTarget = sqlite3_mprintf("file:%s-vacuum?rbu_memory=1%s%s",
+ zTarget = sqlite3_mprintf("file:%s-vactmp?rbu_memory=1%s%s",
sqlite3_db_filename(p->dbRbu, "main"),
(zExtra==0 ? "" : "&"), (zExtra==0 ? "" : zExtra)
);
@@ -3743,6 +3743,12 @@ sqlite3rbu *sqlite3rbu_vacuum(
const char *zState
){
if( zTarget==0 ){ return rbuMisuseError(); }
+ if( zState ){
+ int n = strlen(zState);
+ if( n>=7 && 0==memcmp("-vactmp", &zState[n-7], 7) ){
+ return rbuMisuseError();
+ }
+ }
/* TODO: Check that both arguments are non-NULL */
return openRbuHandle(0, zTarget, zState);
}
@@ -3939,7 +3945,10 @@ int sqlite3rbu_savestate(sqlite3rbu *p){
if( p->eStage==RBU_STAGE_OAL ){
assert( rc!=SQLITE_DONE );
if( rc==SQLITE_OK ) rc = sqlite3_exec(p->dbRbu, "COMMIT", 0, 0, 0);
- if( rc==SQLITE_OK ) rc = sqlite3_exec(p->dbRbu, "BEGIN IMMEDIATE", 0, 0, 0);
+ if( rc==SQLITE_OK ){
+ const char *zBegin = rbuIsVacuum(p) ? "BEGIN" : "BEGIN IMMEDIATE";
+ rc = sqlite3_exec(p->dbRbu, zBegin, 0, 0, 0);
+ }
if( rc==SQLITE_OK ) rc = sqlite3_exec(p->dbMain, "BEGIN IMMEDIATE", 0, 0,0);
}
diff --git a/chromium/third_party/sqlite/src/ext/rbu/sqlite3rbu.h b/chromium/third_party/sqlite/src/ext/rbu/sqlite3rbu.h
index 07b8685e243..1ffbd271f85 100644
--- a/chromium/third_party/sqlite/src/ext/rbu/sqlite3rbu.h
+++ b/chromium/third_party/sqlite/src/ext/rbu/sqlite3rbu.h
@@ -335,6 +335,10 @@ SQLITE_API sqlite3rbu *sqlite3rbu_open(
** state database is not already present in the file-system, it is created
** with the same permissions as the target db is made.
**
+** With an RBU vacuum, it is an SQLITE_MISUSE error if the name of the
+** state database ends with "-vactmp". This name is reserved for internal
+** use.
+**
** This function does not delete the state database after an RBU vacuum
** is completed, even if it created it. However, if the call to
** sqlite3rbu_close() returns any value other than SQLITE_OK, the contents
diff --git a/chromium/third_party/sqlite/src/ext/rbu/test_rbu.c b/chromium/third_party/sqlite/src/ext/rbu/test_rbu.c
index 1c1c9b41cc4..054774e606c 100644
--- a/chromium/third_party/sqlite/src/ext/rbu/test_rbu.c
+++ b/chromium/third_party/sqlite/src/ext/rbu/test_rbu.c
@@ -273,6 +273,7 @@ static int SQLITE_TCLAPI test_sqlite3rbu_vacuum(
zCmd = Tcl_GetString(objv[1]);
zTarget = Tcl_GetString(objv[2]);
if( objc==4 ) zStateDb = Tcl_GetString(objv[3]);
+ if( zStateDb && zStateDb[0]=='\0' ) zStateDb = 0;
pRbu = sqlite3rbu_vacuum(zTarget, zStateDb);
Tcl_CreateObjCommand(interp, zCmd, test_sqlite3rbu_cmd, (ClientData)pRbu, 0);
diff --git a/chromium/third_party/sqlite/src/ext/rtree/geopoly.c b/chromium/third_party/sqlite/src/ext/rtree/geopoly.c
index d7f6cd5f253..3652d14a1f3 100644
--- a/chromium/third_party/sqlite/src/ext/rtree/geopoly.c
+++ b/chromium/third_party/sqlite/src/ext/rtree/geopoly.c
@@ -124,6 +124,14 @@ struct GeoPoly {
*/
#define GEOPOLY_SZ(N) (sizeof(GeoPoly) + sizeof(GeoCoord)*2*((N)-4))
+/* Macros to access coordinates of a GeoPoly.
+** We have to use these macros, rather than just say p->a[i] in order
+** to silence (incorrect) UBSAN warnings if the array index is too large.
+*/
+#define GeoX(P,I) (((GeoCoord*)(P)->a)[(I)*2])
+#define GeoY(P,I) (((GeoCoord*)(P)->a)[(I)*2+1])
+
+
/*
** State of a parse of a GeoJSON input.
*/
@@ -316,8 +324,9 @@ static GeoPoly *geopolyFuncParam(
memcpy(p->hdr, a, nByte);
if( a[0] != *(unsigned char*)&x ){
int ii;
- for(ii=0; ii<nVertex*2; ii++){
- geopolySwab32((unsigned char*)&p->a[ii]);
+ for(ii=0; ii<nVertex; ii++){
+ geopolySwab32((unsigned char*)&GeoX(p,ii));
+ geopolySwab32((unsigned char*)&GeoY(p,ii));
}
p->hdr[0] ^= 1;
}
@@ -376,9 +385,9 @@ static void geopolyJsonFunc(
int i;
sqlite3_str_append(x, "[", 1);
for(i=0; i<p->nVertex; i++){
- sqlite3_str_appendf(x, "[%!g,%!g],", p->a[i*2], p->a[i*2+1]);
+ sqlite3_str_appendf(x, "[%!g,%!g],", GeoX(p,i), GeoY(p,i));
}
- sqlite3_str_appendf(x, "[%!g,%!g]]", p->a[0], p->a[1]);
+ sqlite3_str_appendf(x, "[%!g,%!g]]", GeoX(p,0), GeoY(p,0));
sqlite3_result_text(context, sqlite3_str_finish(x), -1, sqlite3_free);
sqlite3_free(p);
}
@@ -395,7 +404,9 @@ static void geopolySvgFunc(
int argc,
sqlite3_value **argv
){
- GeoPoly *p = geopolyFuncParam(context, argv[0], 0);
+ GeoPoly *p;
+ if( argc<1 ) return;
+ p = geopolyFuncParam(context, argv[0], 0);
if( p ){
sqlite3 *db = sqlite3_context_db_handle(context);
sqlite3_str *x = sqlite3_str_new(db);
@@ -403,10 +414,10 @@ static void geopolySvgFunc(
char cSep = '\'';
sqlite3_str_appendf(x, "<polyline points=");
for(i=0; i<p->nVertex; i++){
- sqlite3_str_appendf(x, "%c%g,%g", cSep, p->a[i*2], p->a[i*2+1]);
+ sqlite3_str_appendf(x, "%c%g,%g", cSep, GeoX(p,i), GeoY(p,i));
cSep = ' ';
}
- sqlite3_str_appendf(x, " %g,%g'", p->a[0], p->a[1]);
+ sqlite3_str_appendf(x, " %g,%g'", GeoX(p,0), GeoY(p,0));
for(i=1; i<argc; i++){
const char *z = (const char*)sqlite3_value_text(argv[i]);
if( z && z[0] ){
@@ -451,12 +462,12 @@ static void geopolyXformFunc(
int ii;
if( p ){
for(ii=0; ii<p->nVertex; ii++){
- x0 = p->a[ii*2];
- y0 = p->a[ii*2+1];
+ x0 = GeoX(p,ii);
+ y0 = GeoY(p,ii);
x1 = (GeoCoord)(A*x0 + B*y0 + E);
y1 = (GeoCoord)(C*x0 + D*y0 + F);
- p->a[ii*2] = x1;
- p->a[ii*2+1] = y1;
+ GeoX(p,ii) = x1;
+ GeoY(p,ii) = y1;
}
sqlite3_result_blob(context, p->hdr,
4+8*p->nVertex, SQLITE_TRANSIENT);
@@ -475,12 +486,12 @@ static double geopolyArea(GeoPoly *p){
double rArea = 0.0;
int ii;
for(ii=0; ii<p->nVertex-1; ii++){
- rArea += (p->a[ii*2] - p->a[ii*2+2]) /* (x0 - x1) */
- * (p->a[ii*2+1] + p->a[ii*2+3]) /* (y0 + y1) */
+ rArea += (GeoX(p,ii) - GeoX(p,ii+1)) /* (x0 - x1) */
+ * (GeoY(p,ii) + GeoY(p,ii+1)) /* (y0 + y1) */
* 0.5;
}
- rArea += (p->a[ii*2] - p->a[0]) /* (xN - x0) */
- * (p->a[ii*2+1] + p->a[1]) /* (yN + y0) */
+ rArea += (GeoX(p,ii) - GeoX(p,0)) /* (xN - x0) */
+ * (GeoY(p,ii) + GeoY(p,0)) /* (yN + y0) */
* 0.5;
return rArea;
}
@@ -527,13 +538,13 @@ static void geopolyCcwFunc(
if( p ){
if( geopolyArea(p)<0.0 ){
int ii, jj;
- for(ii=2, jj=p->nVertex*2 - 2; ii<jj; ii+=2, jj-=2){
- GeoCoord t = p->a[ii];
- p->a[ii] = p->a[jj];
- p->a[jj] = t;
- t = p->a[ii+1];
- p->a[ii+1] = p->a[jj+1];
- p->a[jj+1] = t;
+ for(ii=1, jj=p->nVertex-1; ii<jj; ii++, jj--){
+ GeoCoord t = GeoX(p,ii);
+ GeoX(p,ii) = GeoX(p,jj);
+ GeoX(p,jj) = t;
+ t = GeoY(p,ii);
+ GeoY(p,ii) = GeoY(p,jj);
+ GeoY(p,jj) = t;
}
}
sqlite3_result_blob(context, p->hdr,
@@ -593,8 +604,8 @@ static void geopolyRegularFunc(
p->hdr[3] = n&0xff;
for(i=0; i<n; i++){
double rAngle = 2.0*GEOPOLY_PI*i/n;
- p->a[i*2] = x - r*geopolySine(rAngle-0.5*GEOPOLY_PI);
- p->a[i*2+1] = y + r*geopolySine(rAngle);
+ GeoX(p,i) = x - r*geopolySine(rAngle-0.5*GEOPOLY_PI);
+ GeoY(p,i) = y + r*geopolySine(rAngle);
}
sqlite3_result_blob(context, p->hdr, 4+8*n, SQLITE_TRANSIENT);
sqlite3_free(p);
@@ -631,13 +642,13 @@ static GeoPoly *geopolyBBox(
}
if( p ){
int ii;
- mnX = mxX = p->a[0];
- mnY = mxY = p->a[1];
+ mnX = mxX = GeoX(p,0);
+ mnY = mxY = GeoY(p,0);
for(ii=1; ii<p->nVertex; ii++){
- double r = p->a[ii*2];
+ double r = GeoX(p,ii);
if( r<mnX ) mnX = (float)r;
else if( r>mxX ) mxX = (float)r;
- r = p->a[ii*2+1];
+ r = GeoY(p,ii);
if( r<mnY ) mnY = (float)r;
else if( r>mxY ) mxY = (float)r;
}
@@ -657,14 +668,14 @@ static GeoPoly *geopolyBBox(
pOut->hdr[1] = 0;
pOut->hdr[2] = 0;
pOut->hdr[3] = 4;
- pOut->a[0] = mnX;
- pOut->a[1] = mnY;
- pOut->a[2] = mxX;
- pOut->a[3] = mnY;
- pOut->a[4] = mxX;
- pOut->a[5] = mxY;
- pOut->a[6] = mnX;
- pOut->a[7] = mxY;
+ GeoX(pOut,0) = mnX;
+ GeoY(pOut,0) = mnY;
+ GeoX(pOut,1) = mxX;
+ GeoY(pOut,1) = mnY;
+ GeoX(pOut,2) = mxX;
+ GeoY(pOut,2) = mxY;
+ GeoX(pOut,3) = mnX;
+ GeoY(pOut,3) = mxY;
}else{
sqlite3_free(p);
aCoord[0].f = mnX;
@@ -802,14 +813,14 @@ static void geopolyContainsPointFunc(
int ii;
if( p1==0 ) return;
for(ii=0; ii<p1->nVertex-1; ii++){
- v = pointBeneathLine(x0,y0,p1->a[ii*2],p1->a[ii*2+1],
- p1->a[ii*2+2],p1->a[ii*2+3]);
+ v = pointBeneathLine(x0,y0,GeoX(p1,ii), GeoY(p1,ii),
+ GeoX(p1,ii+1),GeoY(p1,ii+1));
if( v==2 ) break;
cnt += v;
}
if( v!=2 ){
- v = pointBeneathLine(x0,y0,p1->a[ii*2],p1->a[ii*2+1],
- p1->a[0],p1->a[1]);
+ v = pointBeneathLine(x0,y0,GeoX(p1,ii), GeoY(p1,ii),
+ GeoX(p1,0), GeoY(p1,0));
}
if( v==2 ){
sqlite3_result_int(context, 1);
@@ -931,10 +942,10 @@ static void geopolyAddSegments(
unsigned int i;
GeoCoord *x;
for(i=0; i<(unsigned)pPoly->nVertex-1; i++){
- x = pPoly->a + (i*2);
+ x = &GeoX(pPoly,i);
geopolyAddOneSegment(p, x[0], x[1], x[2], x[3], side, i);
}
- x = pPoly->a + (i*2);
+ x = &GeoX(pPoly,i);
geopolyAddOneSegment(p, x[0], x[1], pPoly->a[0], pPoly->a[1], side, i);
}
diff --git a/chromium/third_party/sqlite/src/ext/rtree/rtree.c b/chromium/third_party/sqlite/src/ext/rtree/rtree.c
index e09db482279..3a16c5d4e18 100644
--- a/chromium/third_party/sqlite/src/ext/rtree/rtree.c
+++ b/chromium/third_party/sqlite/src/ext/rtree/rtree.c
@@ -128,6 +128,9 @@ struct Rtree {
u8 inWrTrans; /* True if inside write transaction */
u8 nAux; /* # of auxiliary columns in %_rowid */
u8 nAuxNotNull; /* Number of initial not-null aux columns */
+#ifdef SQLITE_DEBUG
+ u8 bCorrupt; /* Shadow table corruption detected */
+#endif
int iDepth; /* Current depth of the r-tree structure */
char *zDb; /* Name of database containing r-tree table */
char *zName; /* Name of r-tree table */
@@ -188,6 +191,15 @@ struct Rtree {
#endif
/*
+** Set the Rtree.bCorrupt flag
+*/
+#ifdef SQLITE_DEBUG
+# define RTREE_IS_CORRUPT(X) ((X)->bCorrupt = 1)
+#else
+# define RTREE_IS_CORRUPT(X)
+#endif
+
+/*
** When doing a search of an r-tree, instances of the following structure
** record intermediate results from the tree walk.
**
@@ -553,8 +565,8 @@ static void nodeZero(Rtree *pRtree, RtreeNode *p){
** Given a node number iNode, return the corresponding key to use
** in the Rtree.aHash table.
*/
-static int nodeHash(i64 iNode){
- return iNode % HASHSIZE;
+static unsigned int nodeHash(i64 iNode){
+ return ((unsigned)iNode) % HASHSIZE;
}
/*
@@ -599,7 +611,7 @@ static void nodeHashDelete(Rtree *pRtree, RtreeNode *pNode){
*/
static RtreeNode *nodeNew(Rtree *pRtree, RtreeNode *pParent){
RtreeNode *pNode;
- pNode = (RtreeNode *)sqlite3_malloc(sizeof(RtreeNode) + pRtree->iNodeSize);
+ pNode = (RtreeNode *)sqlite3_malloc64(sizeof(RtreeNode) + pRtree->iNodeSize);
if( pNode ){
memset(pNode, 0, sizeof(RtreeNode) + pRtree->iNodeSize);
pNode->zData = (u8 *)&pNode[1];
@@ -624,6 +636,18 @@ static void nodeBlobReset(Rtree *pRtree){
}
/*
+** Check to see if pNode is the same as pParent or any of the parents
+** of pParent.
+*/
+static int nodeInParentChain(const RtreeNode *pNode, const RtreeNode *pParent){
+ do{
+ if( pNode==pParent ) return 1;
+ pParent = pParent->pParent;
+ }while( pParent );
+ return 0;
+}
+
+/*
** Obtain a reference to an r-tree node.
*/
static int nodeAcquire(
@@ -641,6 +665,10 @@ static int nodeAcquire(
if( (pNode = nodeHashLookup(pRtree, iNode))!=0 ){
assert( !pParent || !pNode->pParent || pNode->pParent==pParent );
if( pParent && !pNode->pParent ){
+ if( nodeInParentChain(pNode, pParent) ){
+ RTREE_IS_CORRUPT(pRtree);
+ return SQLITE_CORRUPT_VTAB;
+ }
pParent->nRef++;
pNode->pParent = pParent;
}
@@ -671,9 +699,12 @@ static int nodeAcquire(
*ppNode = 0;
/* If unable to open an sqlite3_blob on the desired row, that can only
** be because the shadow tables hold erroneous data. */
- if( rc==SQLITE_ERROR ) rc = SQLITE_CORRUPT_VTAB;
+ if( rc==SQLITE_ERROR ){
+ rc = SQLITE_CORRUPT_VTAB;
+ RTREE_IS_CORRUPT(pRtree);
+ }
}else if( pRtree->iNodeSize==sqlite3_blob_bytes(pRtree->pNodeBlob) ){
- pNode = (RtreeNode *)sqlite3_malloc(sizeof(RtreeNode)+pRtree->iNodeSize);
+ pNode = (RtreeNode *)sqlite3_malloc64(sizeof(RtreeNode)+pRtree->iNodeSize);
if( !pNode ){
rc = SQLITE_NOMEM;
}else{
@@ -686,7 +717,6 @@ static int nodeAcquire(
pNode->pNext = 0;
rc = sqlite3_blob_read(pRtree->pNodeBlob, pNode->zData,
pRtree->iNodeSize, 0);
- nodeReference(pParent);
}
}
@@ -700,6 +730,7 @@ static int nodeAcquire(
pRtree->iDepth = readInt16(pNode->zData);
if( pRtree->iDepth>RTREE_MAX_DEPTH ){
rc = SQLITE_CORRUPT_VTAB;
+ RTREE_IS_CORRUPT(pRtree);
}
}
@@ -710,14 +741,17 @@ static int nodeAcquire(
if( pNode && rc==SQLITE_OK ){
if( NCELL(pNode)>((pRtree->iNodeSize-4)/pRtree->nBytesPerCell) ){
rc = SQLITE_CORRUPT_VTAB;
+ RTREE_IS_CORRUPT(pRtree);
}
}
if( rc==SQLITE_OK ){
if( pNode!=0 ){
+ nodeReference(pParent);
nodeHashInsert(pRtree, pNode);
}else{
rc = SQLITE_CORRUPT_VTAB;
+ RTREE_IS_CORRUPT(pRtree);
}
*ppNode = pNode;
}else{
@@ -943,7 +977,7 @@ static void rtreeRelease(Rtree *pRtree){
pRtree->inWrTrans = 0;
assert( pRtree->nCursor==0 );
nodeBlobReset(pRtree);
- assert( pRtree->nNodeRef==0 );
+ assert( pRtree->nNodeRef==0 || pRtree->bCorrupt );
sqlite3_finalize(pRtree->pWriteNode);
sqlite3_finalize(pRtree->pDeleteNode);
sqlite3_finalize(pRtree->pReadRowid);
@@ -1002,7 +1036,7 @@ static int rtreeOpen(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){
Rtree *pRtree = (Rtree *)pVTab;
RtreeCursor *pCsr;
- pCsr = (RtreeCursor *)sqlite3_malloc(sizeof(RtreeCursor));
+ pCsr = (RtreeCursor *)sqlite3_malloc64(sizeof(RtreeCursor));
if( pCsr ){
memset(pCsr, 0, sizeof(RtreeCursor));
pCsr->base.pVtab = pVTab;
@@ -1275,6 +1309,7 @@ static int nodeRowidIndex(
return SQLITE_OK;
}
}
+ RTREE_IS_CORRUPT(pRtree);
return SQLITE_CORRUPT_VTAB;
}
@@ -1368,7 +1403,7 @@ static RtreeSearchPoint *rtreeEnqueue(
RtreeSearchPoint *pNew;
if( pCur->nPoint>=pCur->nPointAlloc ){
int nNew = pCur->nPointAlloc*2 + 8;
- pNew = sqlite3_realloc(pCur->aPoint, nNew*sizeof(pCur->aPoint[0]));
+ pNew = sqlite3_realloc64(pCur->aPoint, nNew*sizeof(pCur->aPoint[0]));
if( pNew==0 ) return 0;
pCur->aPoint = pNew;
pCur->nPointAlloc = nNew;
@@ -1770,7 +1805,7 @@ static int rtreeFilter(
*/
rc = nodeAcquire(pRtree, 1, 0, &pRoot);
if( rc==SQLITE_OK && argc>0 ){
- pCsr->aConstraint = sqlite3_malloc(sizeof(RtreeConstraint)*argc);
+ pCsr->aConstraint = sqlite3_malloc64(sizeof(RtreeConstraint)*argc);
pCsr->nConstraint = argc;
if( !pCsr->aConstraint ){
rc = SQLITE_NOMEM;
@@ -1915,20 +1950,20 @@ static int rtreeBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){
){
u8 op;
switch( p->op ){
- case SQLITE_INDEX_CONSTRAINT_EQ: op = RTREE_EQ; break;
- case SQLITE_INDEX_CONSTRAINT_GT: op = RTREE_GT; break;
- case SQLITE_INDEX_CONSTRAINT_LE: op = RTREE_LE; break;
- case SQLITE_INDEX_CONSTRAINT_LT: op = RTREE_LT; break;
- case SQLITE_INDEX_CONSTRAINT_GE: op = RTREE_GE; break;
- default:
- assert( p->op==SQLITE_INDEX_CONSTRAINT_MATCH );
- op = RTREE_MATCH;
- break;
+ case SQLITE_INDEX_CONSTRAINT_EQ: op = RTREE_EQ; break;
+ case SQLITE_INDEX_CONSTRAINT_GT: op = RTREE_GT; break;
+ case SQLITE_INDEX_CONSTRAINT_LE: op = RTREE_LE; break;
+ case SQLITE_INDEX_CONSTRAINT_LT: op = RTREE_LT; break;
+ case SQLITE_INDEX_CONSTRAINT_GE: op = RTREE_GE; break;
+ case SQLITE_INDEX_CONSTRAINT_MATCH: op = RTREE_MATCH; break;
+ default: op = 0; break;
+ }
+ if( op ){
+ zIdxStr[iIdx++] = op;
+ zIdxStr[iIdx++] = (char)(p->iColumn - 1 + '0');
+ pIdxInfo->aConstraintUsage[ii].argvIndex = (iIdx/2);
+ pIdxInfo->aConstraintUsage[ii].omit = 1;
}
- zIdxStr[iIdx++] = op;
- zIdxStr[iIdx++] = (char)(p->iColumn - 1 + '0');
- pIdxInfo->aConstraintUsage[ii].argvIndex = (iIdx/2);
- pIdxInfo->aConstraintUsage[ii].omit = 1;
}
}
@@ -1964,11 +1999,11 @@ static RtreeDValue cellArea(Rtree *pRtree, RtreeCell *p){
#endif
{
switch( pRtree->nDim ){
- case 5: area = p->aCoord[9].i - p->aCoord[8].i;
- case 4: area *= p->aCoord[7].i - p->aCoord[6].i;
- case 3: area *= p->aCoord[5].i - p->aCoord[4].i;
- case 2: area *= p->aCoord[3].i - p->aCoord[2].i;
- default: area *= p->aCoord[1].i - p->aCoord[0].i;
+ case 5: area = (i64)p->aCoord[9].i - (i64)p->aCoord[8].i;
+ case 4: area *= (i64)p->aCoord[7].i - (i64)p->aCoord[6].i;
+ case 3: area *= (i64)p->aCoord[5].i - (i64)p->aCoord[4].i;
+ case 2: area *= (i64)p->aCoord[3].i - (i64)p->aCoord[2].i;
+ default: area *= (i64)p->aCoord[1].i - (i64)p->aCoord[0].i;
}
}
return area;
@@ -2137,12 +2172,14 @@ static int AdjustTree(
RtreeCell *pCell /* This cell was just inserted */
){
RtreeNode *p = pNode;
+ int cnt = 0;
while( p->pParent ){
RtreeNode *pParent = p->pParent;
RtreeCell cell;
int iCell;
- if( nodeParentIndex(pRtree, p, &iCell) ){
+ if( (++cnt)>1000 || nodeParentIndex(pRtree, p, &iCell) ){
+ RTREE_IS_CORRUPT(pRtree);
return SQLITE_CORRUPT_VTAB;
}
@@ -2339,9 +2376,9 @@ static int splitNodeStartree(
int iBestSplit = 0;
RtreeDValue fBestMargin = RTREE_ZERO;
- int nByte = (pRtree->nDim+1)*(sizeof(int*)+nCell*sizeof(int));
+ sqlite3_int64 nByte = (pRtree->nDim+1)*(sizeof(int*)+nCell*sizeof(int));
- aaSorted = (int **)sqlite3_malloc(nByte);
+ aaSorted = (int **)sqlite3_malloc64(nByte);
if( !aaSorted ){
return SQLITE_NOMEM;
}
@@ -2462,7 +2499,7 @@ static int SplitNode(
/* Allocate an array and populate it with a copy of pCell and
** all cells from node pLeft. Then zero the original node.
*/
- aCell = sqlite3_malloc((sizeof(RtreeCell)+sizeof(int))*(nCell+1));
+ aCell = sqlite3_malloc64((sizeof(RtreeCell)+sizeof(int))*(nCell+1));
if( !aCell ){
rc = SQLITE_NOMEM;
goto splitnode_out;
@@ -2610,7 +2647,10 @@ static int fixLeafParent(Rtree *pRtree, RtreeNode *pLeaf){
}
rc = sqlite3_reset(pRtree->pReadParent);
if( rc==SQLITE_OK ) rc = rc2;
- if( rc==SQLITE_OK && !pChild->pParent ) rc = SQLITE_CORRUPT_VTAB;
+ if( rc==SQLITE_OK && !pChild->pParent ){
+ RTREE_IS_CORRUPT(pRtree);
+ rc = SQLITE_CORRUPT_VTAB;
+ }
pChild = pChild->pParent;
}
return rc;
@@ -2750,7 +2790,7 @@ static int Reinsert(
/* Allocate the buffers used by this operation. The allocation is
** relinquished before this function returns.
*/
- aCell = (RtreeCell *)sqlite3_malloc(n * (
+ aCell = (RtreeCell *)sqlite3_malloc64(n * (
sizeof(RtreeCell) + /* aCell array */
sizeof(int) + /* aOrder array */
sizeof(int) + /* aSpare array */
@@ -2924,8 +2964,12 @@ static int rtreeDeleteRowid(Rtree *pRtree, sqlite3_int64 iDelete){
rc = findLeafNode(pRtree, iDelete, &pLeaf, 0);
}
+#ifdef CORRUPT_DB
+ assert( pLeaf!=0 || rc!=SQLITE_OK || CORRUPT_DB );
+#endif
+
/* Delete the cell in question from the leaf node. */
- if( rc==SQLITE_OK ){
+ if( rc==SQLITE_OK && pLeaf ){
int rc2;
rc = nodeRowidIndex(pRtree, pLeaf, iDelete, &iCell);
if( rc==SQLITE_OK ){
@@ -3197,7 +3241,7 @@ static int rtreeUpdate(
rc = rc2;
}
}
- if( pRtree->nAux ){
+ if( rc==SQLITE_OK && pRtree->nAux ){
sqlite3_stmt *pUp = pRtree->pWriteAux;
int jj;
sqlite3_bind_int64(pUp, 1, *pRowid);
@@ -3558,6 +3602,7 @@ static int getNodeSize(
*pzErr = sqlite3_mprintf("%s", sqlite3_errmsg(db));
}else if( pRtree->iNodeSize<(512-64) ){
rc = SQLITE_CORRUPT_VTAB;
+ RTREE_IS_CORRUPT(pRtree);
*pzErr = sqlite3_mprintf("undersize RTree blobs in \"%q_node\"",
pRtree->zName);
}
@@ -3613,7 +3658,7 @@ static int rtreeInit(
/* Allocate the sqlite3_vtab structure */
nDb = (int)strlen(argv[1]);
nName = (int)strlen(argv[2]);
- pRtree = (Rtree *)sqlite3_malloc(sizeof(Rtree)+nDb+nName+2);
+ pRtree = (Rtree *)sqlite3_malloc64(sizeof(Rtree)+nDb+nName+2);
if( !pRtree ){
return SQLITE_NOMEM;
}
@@ -3881,8 +3926,7 @@ static void rtreeCheckAppendMsg(RtreeCheck *pCheck, const char *zFmt, ...){
static u8 *rtreeCheckGetNode(RtreeCheck *pCheck, i64 iNode, int *pnNode){
u8 *pRet = 0; /* Return value */
- assert( pCheck->rc==SQLITE_OK );
- if( pCheck->pGetNode==0 ){
+ if( pCheck->rc==SQLITE_OK && pCheck->pGetNode==0 ){
pCheck->pGetNode = rtreeCheckPrepare(pCheck,
"SELECT data FROM %Q.'%q_node' WHERE nodeno=?",
pCheck->zDb, pCheck->zTab
@@ -3894,7 +3938,7 @@ static u8 *rtreeCheckGetNode(RtreeCheck *pCheck, i64 iNode, int *pnNode){
if( sqlite3_step(pCheck->pGetNode)==SQLITE_ROW ){
int nNode = sqlite3_column_bytes(pCheck->pGetNode, 0);
const u8 *pNode = (const u8*)sqlite3_column_blob(pCheck->pGetNode, 0);
- pRet = sqlite3_malloc(nNode);
+ pRet = sqlite3_malloc64(nNode);
if( pRet==0 ){
pCheck->rc = SQLITE_NOMEM;
}else{
@@ -4327,12 +4371,12 @@ static void rtreeMatchArgFree(void *pArg){
static void geomCallback(sqlite3_context *ctx, int nArg, sqlite3_value **aArg){
RtreeGeomCallback *pGeomCtx = (RtreeGeomCallback *)sqlite3_user_data(ctx);
RtreeMatchArg *pBlob;
- int nBlob;
+ sqlite3_int64 nBlob;
int memErr = 0;
nBlob = sizeof(RtreeMatchArg) + (nArg-1)*sizeof(RtreeDValue)
+ nArg*sizeof(sqlite3_value*);
- pBlob = (RtreeMatchArg *)sqlite3_malloc(nBlob);
+ pBlob = (RtreeMatchArg *)sqlite3_malloc64(nBlob);
if( !pBlob ){
sqlite3_result_error_nomem(ctx);
}else{
diff --git a/chromium/third_party/sqlite/src/ext/rtree/rtree1.test b/chromium/third_party/sqlite/src/ext/rtree/rtree1.test
index 9e10fee8e68..ddc5f182f09 100644
--- a/chromium/third_party/sqlite/src/ext/rtree/rtree1.test
+++ b/chromium/third_party/sqlite/src/ext/rtree/rtree1.test
@@ -647,5 +647,19 @@ do_execsql_test 16.130 {
SELECT * FROM rt1 WHERE id IN (1, 2, 3, 4);
} {1 1.0 2.0 aux1 2 2.0 3.0 aux2 3 3.0 4.0 aux3 4 4.0 5.0 aux4}
+reset_db
+do_execsql_test 17.0 {
+ CREATE VIRTUAL TABLE t1 USING rtree(id, x1 PRIMARY KEY, x2, y1, y2);
+ CREATE VIRTUAL TABLE t2 USING rtree(id, x1, x2, y1, y2 UNIQUE);
+}
+do_execsql_test 17.1 {
+ REINDEX t1;
+ REINDEX t2;
+} {}
+
+do_execsql_test 17.2 {
+ REINDEX;
+} {}
+
expand_all_sql db
finish_test
diff --git a/chromium/third_party/sqlite/src/ext/rtree/rtree6.test b/chromium/third_party/sqlite/src/ext/rtree/rtree6.test
index ec8672e56af..29300882028 100644
--- a/chromium/third_party/sqlite/src/ext/rtree/rtree6.test
+++ b/chromium/third_party/sqlite/src/ext/rtree/rtree6.test
@@ -15,6 +15,7 @@ if {![info exists testdir]} {
set testdir [file join [file dirname [info script]] .. .. test]
}
source $testdir/tester.tcl
+set testprefix rtree6
ifcapable {!rtree || rtree_int_only} {
finish_test
@@ -58,6 +59,9 @@ do_test rtree6-1.1 {
do_test rtree6-1.2 {
rtree_strategy {SELECT * FROM t1 WHERE x1>10}
} {E0}
+do_test rtree6-1.2.1 {
+ rtree_strategy {SELECT * FROM t1 WHERE x1>10 AND x2 LIKE '%x%'}
+} {E0}
do_test rtree6-1.3 {
rtree_strategy {SELECT * FROM t1 WHERE x1<10}
@@ -164,5 +168,14 @@ do_execsql_test rtree6-3.5 {
x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>0.5 AND x1>1.1
} {}
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test 4.0 {
+ CREATE VIRTUAL TABLE t1 USING rtree(id,x0,x1,y0,y1);
+}
+do_execsql_test 4.1 {
+ DELETE FROM t1 WHERE x0>1 AND x1<2 OR y0<92;
+}
+
expand_all_sql db
finish_test
diff --git a/chromium/third_party/sqlite/src/ext/rtree/rtreecirc.test b/chromium/third_party/sqlite/src/ext/rtree/rtreecirc.test
new file mode 100644
index 00000000000..d77ed04b3de
--- /dev/null
+++ b/chromium/third_party/sqlite/src/ext/rtree/rtreecirc.test
@@ -0,0 +1,66 @@
+# 2018 Dec 22
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#*************************************************************************
+# This file implements regression tests for SQLite library. The
+# focus of this script is testing the FTS5 module.
+#
+
+if {![info exists testdir]} {
+ set testdir [file join [file dirname [info script]] .. .. test]
+}
+source [file join [file dirname [info script]] rtree_util.tcl]
+source $testdir/tester.tcl
+set testprefix rtreecirc
+
+ifcapable !rtree {
+ finish_test
+ return
+}
+
+do_execsql_test 1.0 {
+ CREATE VIRTUAL TABLE rt USING rtree(id, x1, x2, y1, y2);
+ SELECT name FROM sqlite_master ORDER BY 1;
+} {
+ rt rt_node rt_parent rt_rowid
+}
+db_save_and_close
+
+foreach {tn schema sql} {
+ 1 {
+ CREATE TRIGGER tr1 AFTER INSERT ON rt_node BEGIN
+ SELECT * FROM rt;
+ END;
+ } {
+ INSERT INTO rt VALUES(1, 2, 3, 4, 5);
+ }
+ 2 {
+ CREATE TRIGGER tr1 AFTER INSERT ON rt_parent BEGIN
+ SELECT * FROM rt;
+ END;
+ } {
+ INSERT INTO rt VALUES(1, 2, 3, 4, 5);
+ }
+ 3 {
+ CREATE TRIGGER tr1 AFTER INSERT ON rt_rowid BEGIN
+ SELECT * FROM rt;
+ END;
+ } {
+ INSERT INTO rt VALUES(1, 2, 3, 4, 5);
+ }
+} {
+ db_restore_and_reopen
+ do_execsql_test 1.1.$tn.1 $schema
+ do_catchsql_test 1.1.$tn.2 $sql {1 {no such table: main.rt}}
+ db close
+}
+
+
+finish_test
+
diff --git a/chromium/third_party/sqlite/src/ext/rtree/rtreefuzz001.test b/chromium/third_party/sqlite/src/ext/rtree/rtreefuzz001.test
new file mode 100644
index 00000000000..36c8d27ec74
--- /dev/null
+++ b/chromium/third_party/sqlite/src/ext/rtree/rtreefuzz001.test
@@ -0,0 +1,777 @@
+# 2012-12-21
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# Test cases for corrupt database files.
+
+if {![info exists testdir]} {
+ set testdir [file join [file dirname [info script]] .. .. test]
+}
+source $testdir/tester.tcl
+
+ifcapable !deserialize||!rtree {
+ finish_test
+ return
+}
+database_may_be_corrupt
+
+do_test rtreefuzz001-100 {
+ sqlite3 db {}
+ db deserialize [decode_hexdb {
+| size 24576 pagesize 4096 filename c1b.db
+| page 1 offset 0
+| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
+| 16: 10 00 01 01 00 40 20 20 00 00 00 03 00 00 00 06 .....@ ........
+| 32: 00 00 00 00 00 00 00 00 00 00 00 03 00 00 00 04 ................
+| 48: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 ................
+| 80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 03 ................
+| 96: 00 2e 30 38 0d 00 00 00 04 0e 9c 00 0f ad 0f 4f ..08...........O
+| 112: 0e fc 0e 9c 00 00 00 00 00 00 00 00 00 00 00 00 ................
+| 3728: 00 00 00 00 00 00 00 00 00 00 00 00 5e 04 07 17 ............^...
+| 3744: 1f 1f 01 81 0b 74 61 62 6c 65 74 31 5f 70 61 72 .....tablet1_par
+| 3760: 65 6e 74 74 31 5f 70 61 72 65 6e 74 04 43 52 45 entt1_parent.CRE
+| 3776: 41 54 45 20 54 41 42 4c 45 20 22 74 31 5f 70 61 ATE TABLE .t1_pa
+| 3792: 72 66 6e 74 22 28 6e 6f 64 65 6e 6f 20 49 4e 54 rfnt.(nodeno INT
+| 3808: 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59 EGER PRIMARY KEY
+| 3824: 2c 70 61 72 65 6e 74 6e 6f 64 65 29 51 03 06 17 ,parentnode)Q...
+| 3840: 1b 1b 01 7b 74 61 62 6c 65 74 31 5f 6e 6f 64 65 ....tablet1_node
+| 3856: 74 31 5f 6e 6f 64 65 03 43 52 45 41 54 45 20 54 t1_node.CREATE T
+| 3872: 41 42 4c 45 20 22 74 31 5f 6e 6f 64 65 22 28 6e ABLE .t1_node.(n
+| 3888: 6f 64 65 6e 6f 20 49 4e 54 45 47 45 52 20 50 52 odeno INTEGER PR
+| 3904: 49 4d 41 52 59 20 4b 45 59 2c 64 61 74 61 29 5c IMARY KEY,data).
+| 3920: 02 07 17 1d 1d 01 81 0b 74 61 62 6c 65 74 31 5f ........tablet1_
+| 3936: 72 6f 77 69 64 74 31 5f 72 6f 77 69 64 02 43 52 rowidt1_rowid.CR
+| 3952: 45 41 54 45 20 54 41 42 4c 45 20 22 74 31 5f 72 EATE TABLE .t1_r
+| 3968: 6f 77 69 64 22 28 72 6f 77 69 64 20 49 4e 54 45 owid.(rowid INTE
+| 3984: 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c GER PRIMARY KEY,
+| 4000: 6e 6f 64 65 6e 6f 2c 61 30 2c 61 31 29 51 01 07 nodeno,a0,a1)Q..
+| 4016: 17 11 11 08 81 0f 74 61 62 6c 65 74 31 74 31 43 ......tablet1t1C
+| 4032: 52 45 41 54 45 20 56 49 52 54 55 41 4c 20 54 41 REATE VIRTUAL TA
+| 4048: 42 4c 45 20 74 31 20 55 53 49 4e 47 20 72 74 72 BLE t1 USING rtr
+| 4064: 65 65 28 69 64 2c 78 30 2c 78 31 2c 79 30 2c 79 ee(id,x0,x1,y0,y
+| 4080: 31 2c 2b 6c 61 62 65 6c 2c 2b 6f 74 68 65 72 29 1,+label,+other)
+| page 2 offset 4096
+| 0: 0d 0c cd 00 74 08 75 01 0f e8 0c b3 0f d0 0f b7 ....t.u.........
+| 16: 0f 9e 0f 91 0f 81 0f 70 0f 5e 0f 4f 0f 39 0f 29 .......p.^.O.9.)
+| 32: 0f 18 0f 06 0e f7 0c 65 0e 58 0d c2 0d 2c 0c 25 .......e.X...,.%
+| 48: 0b 85 0a e5 0a 45 09 a5 09 05 0c 83 0c 93 0c a3 .....E..........
+| 64: 0f f0 0c 15 0b 75 0a d5 0a 35 09 95 08 f5 0e d8 .....u...5......
+| 80: 0e 42 0d ac 0d 16 0c 05 0b 65 0a c5 0a 25 09 85 .B.......e...%..
+| 96: 08 e5 0e c8 0e 32 0d 9c 0d 06 0b f5 0b 55 0a b5 .....2.......U..
+| 112: 0a 15 09 75 08 d5 0e b8 0e 22 0d 8c 0c f6 0b e5 ...u............
+| 128: 0b 45 0a a5 0a 05 09 65 08 c5 0e a8 0e 12 0d 7c .E.....e.......|
+| 144: 0c e6 0b d5 0b 35 0a 95 09 f5 09 55 08 b5 0e 98 .....5.....U....
+| 160: 0e 02 0d 6c 0c d6 0b c5 0b 25 0a 85 09 e5 09 45 ...l.....%.....E
+| 176: 08 a5 0e 88 0d f2 0d 5c 0c 55 0b b5 0b 15 0a 75 .........U.....u
+| 192: 09 d5 09 35 08 95 0e 78 0d e2 0d 4c 0c 45 0b a5 ...5...x...L.E..
+| 208: 0b 05 0a 65 09 c5 09 25 08 85 0e 68 0d d2 0d 3c ...e...%...h...<
+| 224: 0c 35 0b 95 0a f5 0a 55 09 b5 09 15 08 75 0c 75 .5.....U.....u.u
+| 2160: 00 00 00 00 00 0d 8e 75 05 00 01 1b 00 04 62 6f .......u......bo
+| 2176: 78 2d 39 2c 39 0d 8e 11 05 00 01 1b 00 02 62 6f x-9,9.........bo
+| 2192: 78 2d 39 2c 38 0d 8d 2d 05 00 01 1b 00 02 62 6f x-9,8..-......bo
+| 2208: 78 2d 39 2c 37 0d 8c 49 05 00 01 1b 00 02 62 6f x-9,7..I......bo
+| 2224: 78 2d 39 2c 36 0d 8b 65 05 00 01 1b 00 02 62 6f x-9,6..e......bo
+| 2240: 78 2d 39 2c 35 0d 8b 01 05 00 01 1b 00 02 62 6f x-9,5.........bo
+| 2256: 78 2d 39 2c 34 0d 8a 1d 05 00 01 1b 00 02 62 6f x-9,4.........bo
+| 2272: 78 2d 39 2c 33 0d 89 39 05 00 01 1b 00 02 62 6f x-9,3..9......bo
+| 2288: 78 2d 39 2c 32 0d 88 55 05 00 01 1b 00 02 62 6f x-9,2..U......bo
+| 2304: 78 2d 39 2c 31 0d 87 71 05 00 01 1b 00 02 62 6f x-9,1..q......bo
+| 2320: 78 2d 39 2c 30 0d 8e 74 05 00 01 1b 00 04 62 6f x-9,0..t......bo
+| 2336: 78 2d 38 2c 39 0d 8e 10 05 00 01 1b 00 02 62 6f x-8,9.........bo
+| 2352: 78 2d 38 2c 38 0d 8d 2c 05 00 01 1b 00 02 62 6f x-8,8..,......bo
+| 2368: 78 2d 38 2c 37 0d 8c 48 05 00 01 1b 00 02 62 6f x-8,7..H......bo
+| 2384: 78 2d 38 2c 36 0d 8b 64 05 00 01 1b 00 02 62 6f x-8,6..d......bo
+| 2400: 78 2d 38 2c 35 0d 8b 00 05 00 01 1b 00 02 62 6f x-8,5.........bo
+| 2416: 78 2d 38 2c 34 0d 8a 1c 05 00 01 1b 00 02 62 6f x-8,4.........bo
+| 2432: 78 2d 38 2c 33 0d 89 38 05 00 01 1b 00 02 62 6f x-8,3..8......bo
+| 2448: 78 2d 38 2c 32 0d 88 54 05 00 01 1b 00 02 62 6f x-8,2..T......bo
+| 2464: 78 2d 38 2c 31 0d 87 70 05 00 01 1b 00 02 62 6f x-8,1..p......bo
+| 2480: 78 2d 38 2c 30 0d 8e 73 05 00 01 1b 00 05 62 6f x-8,0..s......bo
+| 2496: 78 2d 37 2c 39 0d 8e 0f 05 00 01 1b 00 05 62 6f x-7,9.........bo
+| 2512: 78 2d 37 2c 38 0d 8d 2b 05 00 01 1b 00 05 62 6f x-7,8..+......bo
+| 2528: 78 2d 37 2c 37 0d 8c 47 05 00 01 1b 00 05 62 6f x-7,7..G......bo
+| 2544: 78 2d 37 2c 36 0d 8b 63 05 00 01 1b 00 05 62 6f x-7,6..c......bo
+| 2560: 78 2d 37 2c 35 0d 8a 7f 05 00 01 1b 00 05 62 6f x-7,5.........bo
+| 2576: 78 2d 37 2c 34 0d 8a 1b 05 00 01 1b 00 05 62 6f x-7,4.........bo
+| 2592: 78 2d 37 2c 33 0d 89 37 05 00 01 1b 00 05 62 6f x-7,3..7......bo
+| 2608: 78 2d 37 2c 32 0d 88 53 05 00 01 1b 00 05 62 6f x-7,2..S......bo
+| 2624: 78 2d 37 2c 31 0d 87 6f 05 00 01 1b 00 05 62 6f x-7,1..o......bo
+| 2640: 78 2d 37 2c 30 0d 8e 72 05 00 01 1b 00 04 62 6f x-7,0..r......bo
+| 2656: 78 2d 36 2c 39 0d 8e 0e 05 00 01 1b 00 05 62 6f x-6,9.........bo
+| 2672: 78 2d 36 2c 38 0d 8d 2a 05 00 01 1b 00 05 62 6f x-6,8..*......bo
+| 2688: 78 2d 36 2c 37 0d 8c 46 05 00 01 1b 00 05 62 6f x-6,7..F......bo
+| 2704: 78 2d 36 2c 36 0d 8b 62 05 00 01 1b 00 05 62 6f x-6,6..b......bo
+| 2720: 78 2d 36 2c 35 0d 8a 7e 05 00 01 1b 00 05 62 6f x-6,5..~......bo
+| 2736: 78 2d 36 2c 34 0d 8a 1a 05 00 01 1b 00 05 62 6f x-6,4.........bo
+| 2752: 78 2d 36 2c 33 0d 89 36 05 00 01 1b 00 05 62 6f x-6,3..6......bo
+| 2768: 78 2d 36 2c 32 0d 88 52 05 00 01 1b 00 05 62 6f x-6,2..R......bo
+| 2784: 78 2d 36 2c 31 0d 87 6e 05 00 01 1b 00 05 62 6f x-6,1..n......bo
+| 2800: 78 2d 36 2c 30 0d 8e 71 05 00 01 1b 00 04 62 6f x-6,0..q......bo
+| 2816: 78 2d 35 2c 39 0d 8e 0d 05 00 01 1b 00 05 62 6f x-5,9.........bo
+| 2832: 78 2d 35 2c 38 0d 8d 29 05 00 01 1b 00 05 62 6f x-5,8..)......bo
+| 2848: 78 2d 35 2c 37 0d 8c 45 05 00 01 1b 00 05 62 6f x-5,7..E......bo
+| 2864: 78 2d 35 2c 36 0d 8b 61 05 00 01 1b 00 05 62 6f x-5,6..a......bo
+| 2880: 78 2d 35 2c 35 0d 8a 7d 05 00 01 1b 00 05 62 6f x-5,5.........bo
+| 2896: 78 2d 35 2c 34 0d 8a 19 05 00 01 1b 00 05 62 6f x-5,4.........bo
+| 2912: 78 2d 35 2c 33 0d 89 35 05 00 01 1b 00 05 62 6f x-5,3..5......bo
+| 2928: 78 2d 35 2c 32 0d 88 51 05 00 01 1b 00 05 62 6f x-5,2..Q......bo
+| 2944: 78 2d 35 2c 31 0d 87 6d 05 00 01 1b 00 05 62 6f x-5,1..m......bo
+| 2960: 78 2d 35 2c 30 0d 8e 70 05 00 01 1b 00 04 62 6f x-5,0..p......bo
+| 2976: 78 2d 34 2c 39 0d 8e 0c 05 00 01 1b 00 04 62 6f x-4,9.........bo
+| 2992: 78 2d 34 2c 38 0d 8d 28 05 00 01 1b 00 04 62 6f x-4,8..(......bo
+| 3008: 78 2d 34 2c 37 0d 8c 44 05 00 01 1b 00 04 62 6f x-4,7..D......bo
+| 3024: 78 2d 34 2c 36 0d 8b 60 05 00 01 1b 00 02 62 6f x-4,6..`......bo
+| 3040: 78 2d 34 2c 35 0d 8a 7c 05 00 01 1b 00 02 62 6f x-4,5..|......bo
+| 3056: 78 2d 34 2c 34 0d 8a 18 05 00 01 1b 00 02 62 6f x-4,4.........bo
+| 3072: 78 2d 34 2c 33 0d 89 34 05 00 01 1b 00 02 62 6f x-4,3..4......bo
+| 3088: 78 2d 34 2c 32 0d 88 50 05 00 01 1b 00 02 62 6f x-4,2..P......bo
+| 3104: 78 2d 34 2c 31 0d 87 6c 05 00 01 1b 00 02 62 6f x-4,1..l......bo
+| 3120: 78 2d 34 2c 30 0d 8e 6f 05 00 01 1b 00 04 62 6f x-4,0..o......bo
+| 3136: 78 2d 33 2c 39 0d 8e 0b 05 00 01 1b 00 04 62 6f x-3,9.........bo
+| 3152: 78 2d 33 2c 38 0d 8d 27 05 00 01 1b 00 04 62 6f x-3,8..'......bo
+| 3168: 78 2d 33 2c 37 0d 87 68 05 00 01 1b 00 03 62 6f x-3,7..h......bo
+| 3184: 78 2d 30 2c 30 06 90 d9 80 80 81 84 4c 05 00 01 x-0,0.......L...
+| 3200: 00 00 03 0d 88 4c 05 00 01 1b 00 02 62 6f 78 2d .....L......box-
+| 3216: 30 2c 31 0d 88 4d 05 00 01 1b 00 02 62 6f 78 2d 0,1..M......box-
+| 3232: 31 2c 31 0d 88 4e 05 00 01 1b 00 02 62 6f 78 2d 1,1..N......box-
+| 3248: 32 2c 31 17 01 05 00 01 2f 00 02 6c 6f 77 65 72 2,1...../..lower
+| 3264: 2d 6c 65 66 74 20 63 6f 72 6e 65 72 0d 0d 26 00 -left corner..&.
+| 3280: 09 00 01 00 00 04 0d 8c 43 05 00 01 1b 00 04 62 ........C......b
+| 3296: 6f 78 2d 33 2c 36 0d 8b 5f 05 00 01 1b 00 02 62 ox-3,6.._......b
+| 3312: 6f 78 2d 33 2c 35 0d 8a 7b 05 00 01 1b 00 02 62 ox-3,5.........b
+| 3328: 6f 78 2d 33 2c 34 0d 8a 17 05 00 01 1b 00 02 62 ox-3,4.........b
+| 3344: 6f 78 2d 33 2c 33 0d 89 33 05 00 01 1b 00 02 62 ox-3,3..3......b
+| 3360: 6f 78 2d 33 2c 32 0d bc 00 06 00 09 0d 87 6b 05 ox-3,2........k.
+| 3376: 00 01 1b 00 03 62 6f 78 2d 33 2c 30 0d 8e 6e 05 .....box-3,0..n.
+| 3392: 00 01 1b 00 04 62 6f 78 2d 32 2c 39 0d 8e 0a 05 .....box-2,9....
+| 3408: 00 01 1b 00 04 62 6f 78 2d 32 2c 38 0d 8d 26 05 .....box-2,8..&.
+| 3424: 00 01 1b 00 04 62 6f 78 2d 32 2c 37 0d 8c 42 05 .....box-2,7..B.
+| 3440: 00 01 1b 00 04 62 6f 78 2d 32 2c 36 0d 8b 5e 05 .....box-2,6..^.
+| 3456: 00 01 1b 00 02 62 6f 78 2d 32 2c 35 0d 8a 7a 05 .....box-2,5..z.
+| 3472: 00 01 1b 00 02 62 6f 78 2d 32 2c 34 0d 8a 16 05 .....box-2,4....
+| 3488: 00 01 1b 00 02 62 6f 78 2d 32 2c 33 0d 89 32 05 .....box-2,3..2.
+| 3504: 00 01 1b 00 02 62 6f 78 2d 32 2c 32 0e 52 00 06 .....box-2,2.R..
+| 3520: 00 09 0d 87 6a 05 00 01 1b 00 03 62 6f 78 2d 32 ....j......box-2
+| 3536: 2c 30 0d 8e 6d 05 00 01 1b 00 04 62 6f 78 2d 31 ,0..m......box-1
+| 3552: 2c 39 0d 8e 09 05 00 01 1b 00 04 62 6f 78 2d 31 ,9.........box-1
+| 3568: 2c 38 0d 8d 25 05 00 01 1b 00 04 62 6f 78 2d 31 ,8..%......box-1
+| 3584: 2c 37 0d 8c 41 05 00 01 1b 00 04 62 6f 78 2d 31 ,7..A......box-1
+| 3600: 2c 36 0d 8b 5d 05 00 01 1b 00 02 62 6f 78 2d 31 ,6..]......box-1
+| 3616: 2c 35 0d 8a 79 05 00 01 1b 00 02 62 6f 78 2d 31 ,5..y......box-1
+| 3632: 2c 34 0d 8a 15 05 00 01 1b 00 02 62 6f 78 2d 31 ,4.........box-1
+| 3648: 2c 33 0d 89 31 05 00 01 1b 00 02 62 6f 78 2d 31 ,3..1......box-1
+| 3664: 2c 32 0e e8 00 06 00 09 0d 87 69 05 00 01 1b 00 ,2........i.....
+| 3680: 03 62 6f 78 2d 31 2c 30 0d 8e 6c 05 00 01 1b 00 .box-1,0..l.....
+| 3696: 04 62 6f 78 2d 30 2c 39 0d 8e 08 05 00 01 1b 00 .box-0,9........
+| 3712: 04 62 6f 78 2d 30 2c 38 0d 8d 24 05 00 01 1b 00 .box-0,8..$.....
+| 3728: 04 62 6f 78 2d 30 2c 37 0d 8c 40 05 00 01 1b 00 .box-0,7..@.....
+| 3744: 04 62 6f 78 2d 30 2c 36 0d 8b 5c 05 00 01 1b 00 .box-0,6........
+| 3760: 02 62 6f 78 2d 30 2c 35 0d 8a 78 05 00 01 1b 00 .box-0,5..x.....
+| 3776: 02 62 6f 78 2d 30 2c 34 0d 8a 14 05 00 01 1b 00 .box-0,4........
+| 3792: 02 62 6f 78 2d 30 2c 33 0d 89 30 05 00 01 1b 00 .box-0,3..0.....
+| 3808: 02 62 6f 78 2d 30 2c 32 00 00 00 0f 00 09 1b 00 .box-0,2........
+| 3824: 62 6f 78 2d 30 2c 30 0d 0e 05 00 09 1d 00 74 6f box-0,0.......to
+| 3840: 70 20 68 61 6c 66 10 0d 05 00 09 23 00 62 6f 74 p half.....#.bot
+| 3856: 74 6f 6d 20 68 61 6c 66 0f 0c 02 05 09 01 00 72 tom half.......r
+| 3872: 69 67 68 74 20 68 61 6c 66 0e 0b 05 00 09 1f 00 ight half.......
+| 3888: 6c 65 66 74 20 68 61 6c 66 14 0a 05 00 09 2b 00 left half.....+.
+| 3904: 74 68 65 20 77 68 6f 6c 65 20 74 68 69 6e 67 0d the whole thing.
+| 3920: 09 05 00 09 1d 00 74 6f 70 20 65 64 67 65 10 08 ......top edge..
+| 3936: 05 00 09 23 00 62 6f 74 74 6f 6d 20 65 64 67 65 ...#.bottom edge
+| 3952: 0f 07 05 00 09 21 00 72 69 67 68 74 20 65 64 67 .....!.right edg
+| 3968: 65 0e 06 05 00 09 1f 00 6c 65 66 74 20 65 64 67 e.......left edg
+| 3984: 65 0b 05 05 00 09 19 00 63 65 6e 74 65 72 17 04 e.......center..
+| 4000: 05 00 09 31 00 75 70 70 65 72 2d 72 69 67 68 74 ...1.upper-right
+| 4016: 20 63 6f 72 6e 65 72 17 03 05 00 09 31 00 6c 6f corner.....1.lo
+| 4032: 77 65 72 2d 72 69 67 68 74 20 63 6f 72 6e 65 72 wer-right corner
+| 4048: 16 02 05 00 09 2f 00 75 70 70 65 72 2d 6c 65 66 ...../.upper-lef
+| 4064: 74 20 63 6f 72 6e 65 72 06 00 05 00 01 00 00 03 t corner........
+| 4080: 0d 88 4f 05 00 01 1b 00 02 62 6f 78 2d 33 2c 31 ..O......box-3,1
+| page 3 offset 8192
+| 0: 05 00 00 00 01 0f fb 00 00 00 00 06 0f fb 00 00 ................
+| 384: 00 00 00 00 00 00 00 89 50 03 04 00 93 24 00 00 ........P....$..
+| 400: 00 11 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+| 688: 00 00 00 00 42 c8 00 00 42 4c 00 00 42 00 00 00 ....B...BL..B...
+| 720: 03 eb 40 40 00 00 40 80 00 00 00 00 00 00 3f 80 ..@@..@.......?.
+| 736: 00 00 00 00 00 00 00 00 03 ea 40 00 00 00 40 40 ..........@...@@
+| 752: 00 00 00 00 00 00 3f 80 00 00 00 00 00 00 00 00 ......?.........
+| 768: 03 e9 3f 80 00 00 40 00 00 00 00 00 00 00 3f 80 ..?...@.......?.
+| 784: 00 00 00 00 00 00 00 00 03 e8 00 00 00 00 3f 80 ..............?.
+| 800: 00 00 00 00 00 00 3f 80 00 00 00 00 00 00 00 00 ......?.........
+| 1616: 00 00 00 00 00 00 00 00 00 00 89 50 02 04 00 93 ...........P....
+| 1632: 24 00 00 00 33 00 00 00 00 00 00 00 01 00 00 00 $...3...........
+| 1648: 00 41 20 00 00 00 00 00 00 41 0e 00 00 00 00 00 .A ......A......
+| 1664: 00 00 00 04 4f 40 40 00 00 40 80 00 00 3f 80 00 ....O@@..@...?..
+| 1680: 00 40 00 00 00 00 00 00 00 00 00 04 4e 40 00 00 .@..........N@..
+| 1696: 00 40 40 00 00 3f 80 00 00 40 00 00 00 00 00 00 .@@..?...@......
+| 1712: 00 00 00 04 4d 3f 80 00 00 40 00 00 00 3f 80 00 ....M?...@...?..
+| 1728: 00 40 00 00 00 00 00 00 00 00 00 04 4c 00 00 00 .@..........L...
+| 1744: 00 3f 80 00 00 3f 80 00 00 40 00 00 00 00 00 00 .?...?...@......
+| 1760: 00 00 00 04 b3 40 40 00 00 40 80 00 00 40 00 00 .....@@..@...@..
+| 1776: 00 40 40 00 00 00 00 00 00 00 00 04 b2 40 00 00 .@@..........@..
+| 1792: 00 40 40 00 00 40 00 00 00 40 40 00 00 00 00 00 .@@..@...@@.....
+| 1808: 00 00 00 04 b1 3f 80 00 00 40 00 00 00 40 00 00 .....?...@...@..
+| 1824: 00 40 40 00 00 00 00 00 00 00 00 04 b0 00 00 00 .@@.............
+| 1840: 00 3f 80 00 00 40 00 00 00 40 40 00 00 00 00 00 .?...@...@@.....
+| 1856: 00 00 00 05 17 40 40 00 00 40 80 00 00 40 40 00 .....@@..@...@@.
+| 1872: 00 40 80 00 00 00 00 00 00 00 00 05 16 40 00 00 .@...........@..
+| 1888: 00 40 40 00 00 40 40 00 00 40 80 00 00 00 00 00 .@@..@@..@......
+| 1904: 00 00 00 05 15 3f 80 00 00 40 00 00 00 40 40 00 .....?...@...@@.
+| 1920: 00 40 80 00 00 00 00 00 00 00 00 05 14 00 00 00 .@..............
+| 1936: 00 3f 80 00 00 40 40 00 00 40 80 00 00 00 00 00 .?...@@..@......
+| 1952: 00 00 00 05 7b 40 40 00 00 40 80 00 00 40 80 00 .....@@..@...@..
+| 1968: 00 40 a0 00 00 00 00 00 00 00 00 05 7a 40 00 00 .@..........z@..
+| 1984: 00 40 40 00 00 40 80 00 00 40 a0 00 00 00 00 00 .@@..@...@......
+| 2000: 00 00 00 05 79 3f 80 00 00 40 00 00 00 40 80 00 ....y?...@...@..
+| 2016: 00 40 a0 00 00 00 00 00 00 00 00 05 78 00 00 00 .@..........x...
+| 2032: 00 3f 80 00 00 40 80 00 00 40 a0 00 00 00 00 00 .?...@...@......
+| 2048: 00 00 00 05 df 40 40 00 00 40 80 00 00 40 a0 00 .....@@..@...@..
+| 2064: 00 40 c0 00 00 00 00 00 00 00 00 05 de 40 00 00 .@...........@..
+| 2080: 00 40 40 00 00 40 a0 00 00 40 c0 00 00 00 00 00 .@@..@...@......
+| 2096: 00 00 00 05 dd 3f 80 00 00 40 00 00 00 40 a0 00 .....?...@...@..
+| 2112: 00 40 c0 00 00 00 00 00 00 00 00 05 dc 00 00 00 .@..............
+| 2128: 00 3f 80 00 00 40 a0 00 00 40 c0 00 00 00 00 00 .?...@...@......
+| 2144: 00 00 00 06 43 40 40 00 00 40 80 00 00 40 c0 00 ....C@@..@...@..
+| 2160: 00 40 e0 00 00 00 00 00 00 00 00 06 42 40 00 00 .@..........B@..
+| 2176: 00 40 40 00 00 40 c0 00 00 40 e0 00 00 00 00 00 .@@..@...@......
+| 2192: 00 00 00 06 41 3f 80 00 00 40 00 00 00 40 c0 00 ....A?...@...@..
+| 2208: 00 40 e0 00 00 00 00 00 00 00 00 06 40 00 00 00 .@..........@...
+| 2224: 00 3f 80 00 00 40 c0 00 00 40 e0 00 00 00 00 00 .?...@...@......
+| 2240: 00 00 00 06 a7 40 40 00 00 40 80 00 00 40 e0 00 .....@@..@...@..
+| 2256: 00 41 00 00 00 00 00 00 00 00 00 06 a6 40 00 00 .A...........@..
+| 2272: 00 40 40 00 00 40 e0 00 00 41 00 00 00 00 00 00 .@@..@...A......
+| 2288: 00 00 00 06 a5 3f 80 00 00 40 00 00 00 40 e0 00 .....?...@...@..
+| 2304: 00 41 00 00 00 00 00 00 00 00 00 06 a4 00 00 00 .A..............
+| 2320: 00 3f 80 00 00 40 e0 00 00 41 00 00 00 00 00 00 .?...@...A......
+| 2336: 00 00 00 07 0a 40 00 00 00 40 40 00 00 41 00 00 .....@...@@..A..
+| 2352: 00 41 10 00 00 00 00 00 00 00 00 07 09 3f 80 00 .A...........?..
+| 2368: 00 40 00 00 00 41 00 00 00 41 10 00 00 00 00 00 .@...A...A......
+| 2384: 00 00 00 07 08 00 00 00 00 3f 80 00 00 41 00 00 .........?...A..
+| 2400: 00 41 10 00 00 00 00 00 00 00 00 07 6e 40 00 00 .A..........n@..
+| 2416: 00 40 40 00 00 41 10 00 00 41 20 00 00 00 00 00 .@@..A...A .....
+| 2432: 00 00 00 07 6d 3f 80 00 00 40 00 00 00 41 10 00 ....m?...@...A..
+| 2448: 00 41 20 00 00 00 00 00 00 00 00 07 6c 00 00 00 .A .........l...
+| 2464: 00 3f 80 00 00 41 10 00 00 41 20 00 00 00 00 00 .?...A...A .....
+| 2480: 00 00 00 07 0b 40 40 00 00 40 80 00 00 41 00 00 .....@@..@...A..
+| 2496: 00 41 10 00 00 00 00 00 00 00 00 07 6f 40 40 00 .A..........o@@.
+| 2512: 00 40 80 00 00 41 10 00 00 41 20 00 00 00 00 00 .@...A...A .....
+| 2528: 00 00 00 03 ec 40 80 00 00 40 a0 00 00 00 00 00 .....@...@......
+| 2544: 00 3f 80 00 00 00 00 00 00 00 00 04 50 40 80 00 .?..........P@..
+| 2560: 00 40 a0 00 00 3f 80 00 00 40 00 00 00 00 00 00 .@...?...@......
+| 2576: 00 00 00 04 b4 40 80 00 00 40 a0 00 00 40 00 00 .....@...@...@..
+| 2592: 00 40 40 00 00 00 00 00 00 00 00 05 18 40 80 00 .@@..........@..
+| 2608: 00 40 a0 00 00 40 40 00 00 40 80 00 00 00 00 00 .@...@@..@......
+| 2624: 00 00 00 05 7c 40 80 00 00 40 a0 00 00 40 80 00 ....|@...@...@..
+| 2640: 00 40 a0 00 00 00 00 00 00 00 00 05 e0 40 80 00 .@...........@..
+| 2656: 00 40 a0 00 00 40 a0 00 00 40 c0 00 00 00 00 00 .@...@...@......
+| 2672: 00 00 00 06 44 40 80 00 00 40 a0 00 00 40 c0 00 ....D@...@...@..
+| 2688: 00 40 e0 00 00 00 00 00 00 00 00 06 a8 40 80 00 .@...........@..
+| 2704: 00 40 a0 00 00 40 e0 00 00 41 00 00 00 00 00 00 .@...@...A......
+| 2720: 00 00 00 07 0c 40 80 00 00 40 a0 00 00 41 00 00 .....@...@...A..
+| 2736: 00 41 10 00 00 00 00 00 00 00 00 07 70 40 80 00 .A..........p@..
+| 2752: 00 40 a0 00 00 41 10 00 00 41 20 00 00 00 00 00 .@...A...A .....
+| 2768: 00 00 00 03 ed 40 a0 00 00 40 c0 00 00 00 00 00 .....@...@......
+| 2784: 00 3f 80 00 00 00 00 00 00 00 00 04 51 40 a0 00 .?..........Q@..
+| 2800: 00 40 c0 00 00 3f 80 00 00 40 00 00 00 00 00 00 .@...?...@......
+| 2816: 00 00 00 04 b5 40 a0 00 00 40 c0 00 00 40 00 00 .....@...@...@..
+| 2832: 00 40 40 00 00 00 00 00 00 00 00 05 19 40 a0 00 .@@..........@..
+| 2848: 00 40 c0 00 00 40 40 00 00 40 80 00 00 89 50 01 .@...@@..@....P.
+| 2864: 04 00 93 24 00 01 00 02 00 00 00 00 00 00 00 03 ...$............
+| 2880: 00 00 00 00 40 80 00 00 00 00 00 00 3f 80 00 00 ....@.......?...
+| 2896: 00 00 00 00 00 00 00 02 00 00 00 00 41 20 00 00 ............A ..
+| 2912: 00 00 00 00 41 20 00 00 00 00 00 00 00 00 00 00 ....A ..........
+| 4080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 05 03 ................
+| page 4 offset 12288
+| 0: 0d 00 00 00 00 10 00 00 00 00 00 00 00 00 00 00 ................
+| page 5 offset 16384
+| 0: 0d 00 00 00 03 01 87 00 0b 2d 06 5a 01 87 00 00 .........-.Z....
+| 384: 00 00 00 00 00 00 00 89 50 03 04 00 93 24 00 00 ........P....$..
+| 400: 00 11 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
+| 688: 00 00 00 00 42 c8 00 00 42 4c 00 00 42 00 00 00 ....B...BL..B...
+| 720: 03 eb 40 40 00 00 40 80 00 00 00 00 00 00 3f 80 ..@@..@.......?.
+| 736: 00 00 00 00 00 00 00 00 03 ea 40 00 00 00 40 40 ..........@...@@
+| 752: 00 00 00 00 00 00 3f 80 00 00 00 00 00 00 00 00 ......?.........
+| 768: 03 e9 3f 80 00 00 40 00 00 00 00 00 00 00 3f 80 ..?...@.......?.
+| 784: 00 00 00 00 00 00 00 00 03 e8 00 00 00 00 3f 80 ..............?.
+| 800: 00 00 00 00 00 00 3f 80 00 00 00 00 00 00 00 00 ......?.........
+| 1616: 00 00 00 00 00 00 00 00 00 00 89 50 02 04 00 93 ...........P....
+| 1632: 24 00 00 00 2d 00 00 00 00 00 00 04 4c 00 00 00 $...-.......L...
+| 1648: 00 3f 80 00 00 3f 80 00 00 40 00 00 00 00 00 00 .?...?...@......
+| 1664: 00 00 00 04 b0 00 00 00 00 3f 80 00 00 40 00 00 .........?...@..
+| 1680: 00 40 40 00 00 00 00 00 00 00 00 05 14 00 00 00 .@@.............
+| 1696: 00 3f 80 00 00 40 40 00 00 40 80 00 00 00 00 00 .?...@@..@......
+| 1712: 00 00 00 05 78 00 00 00 00 3f 80 00 00 40 80 00 ....x....?...@..
+| 1728: 00 40 a0 00 00 00 00 00 00 00 00 05 dc 00 00 00 .@..............
+| 1744: 00 3f 80 00 00 40 a0 00 00 40 c0 00 00 00 00 00 .?...@...@......
+| 1760: 00 00 00 00 01 00 00 00 00 41 20 00 00 00 00 00 .........A .....
+| 1776: 00 41 0e 00 00 00 00 00 00 00 00 04 4d 3f 80 00 .A..........M?..
+| 1792: 00 40 00 00 00 3f 80 00 00 40 00 00 00 00 00 00 .@...?...@......
+| 1808: 00 00 00 04 b1 3f 80 00 00 40 00 00 00 40 00 00 .....?...@...@..
+| 1824: 00 40 40 00 00 00 00 00 00 00 00 05 15 3f 80 00 .@@..........?..
+| 1840: 00 40 00 00 00 40 40 00 00 40 80 00 00 00 00 00 .@...@@..@......
+| 1856: 00 00 00 05 79 3f 80 00 00 40 00 00 00 40 80 00 ....y?...@...@..
+| 1872: 00 40 a0 00 00 00 00 00 00 00 00 05 dd 3f 80 00 .@...........?..
+| 1888: 00 40 00 00 00 40 a0 00 00 40 c0 00 00 00 00 00 .@...@...@......
+| 1904: 00 00 00 04 4e 40 00 00 00 40 40 00 00 3f 80 00 ....N@...@@..?..
+| 1920: 00 40 00 00 00 00 00 00 00 00 00 04 b2 40 00 00 .@...........@..
+| 1936: 00 40 40 00 00 40 00 00 00 40 40 00 00 00 00 00 .@@..@...@@.....
+| 1952: 00 00 00 05 16 40 00 00 00 40 40 00 00 40 40 00 .....@...@@..@@.
+| 1968: 00 40 80 00 00 00 00 00 00 00 00 05 7a 40 00 00 .@..........z@..
+| 1984: 00 40 40 00 00 40 80 00 00 40 a0 00 00 00 00 00 .@@..@...@......
+| 2000: 00 00 00 05 de 40 00 00 00 40 40 00 00 40 a0 00 .....@...@@..@..
+| 2016: 00 40 c0 00 00 00 00 00 00 00 00 04 4f 40 40 00 .@..........O@@.
+| 2032: 00 40 80 00 00 3f 80 00 00 40 00 00 00 00 00 00 .@...?...@......
+| 2048: 00 00 00 04 b3 40 40 00 00 40 80 00 00 40 00 00 .....@@..@...@..
+| 2064: 00 40 40 00 00 00 00 00 00 00 00 05 17 40 40 00 .@@..........@@.
+| 2080: 00 40 80 00 00 40 40 00 00 40 80 00 00 00 00 00 .@...@@..@......
+| 2096: 00 00 00 05 7b 40 40 00 00 40 80 00 00 40 80 00 .....@@..@...@..
+| 2112: 00 40 a0 00 00 00 00 00 00 00 00 05 df 40 40 00 .@...........@@.
+| 2128: 00 40 80 00 00 40 a0 00 00 40 c0 00 00 00 00 00 .@...@...@......
+| 2144: 00 00 00 03 ec 40 80 00 00 40 a0 00 00 00 00 00 .....@...@......
+| 2160: 00 3f 80 00 00 00 00 00 00 00 00 04 50 40 80 00 .?..........P@..
+| 2176: 00 40 a0 00 00 3f 80 00 00 40 00 00 00 00 00 00 .@...?...@......
+| 2192: 00 00 00 04 b4 40 80 00 00 40 a0 00 00 40 00 00 .....@...@...@..
+| 2208: 00 40 40 00 00 00 00 00 00 00 00 05 18 40 80 00 .@@..........@..
+| 2224: 00 40 a0 00 00 40 40 00 00 40 80 00 00 00 00 00 .@...@@..@......
+| 2240: 00 00 00 05 7c 40 80 00 00 40 a0 00 00 40 80 00 ....|@...@...@..
+| 2256: 00 40 a0 00 00 00 00 00 00 00 00 05 e0 40 80 00 .@...........@..
+| 2272: 00 40 a0 00 00 40 a0 00 00 40 c0 00 00 00 00 00 .@...@...@......
+| 2288: 00 00 00 03 f0 41 00 00 00 41 10 00 00 00 00 00 .....A...A......
+| 2304: 00 3f 80 00 00 00 00 00 00 00 00 04 54 41 00 00 .?..........TA..
+| 2320: 00 41 10 00 00 3f 80 00 00 40 00 00 00 00 00 00 .A...?...@......
+| 2336: 00 00 00 04 b8 41 00 00 00 41 10 00 00 40 00 00 .....A...A...@..
+| 2352: 00 40 40 00 00 00 00 00 00 00 00 05 1c 41 00 00 .@@..........A..
+| 2368: 00 41 10 00 00 40 40 00 00 40 80 00 00 00 00 00 .A...@@..@......
+| 2384: 00 00 00 05 80 41 00 00 00 41 10 00 00 40 80 00 .....A...A...@..
+| 2400: 00 40 a0 00 00 00 00 00 00 00 00 05 e4 41 00 00 .@...........A..
+| 2416: 00 41 10 00 00 40 a0 00 00 40 c0 00 00 00 00 00 .A...@...@......
+| 2432: 00 00 00 06 48 41 00 00 00 41 10 00 00 40 c0 00 ....HA...A...@..
+| 2448: 00 40 e0 00 00 00 00 00 00 00 00 06 ac 41 00 00 .@...........A..
+| 2464: 00 41 10 00 00 40 e0 00 00 41 00 00 00 00 00 00 .A...@...A......
+| 2480: 00 00 00 07 10 41 00 00 00 41 10 00 00 41 00 00 .....A...A...A..
+| 2496: 00 41 10 00 00 00 00 00 00 00 00 03 f1 41 10 00 .A...........A..
+| 2512: 00 41 20 00 00 00 00 00 00 3f 80 00 00 00 00 00 .A ......?......
+| 2528: 00 00 00 04 55 41 10 00 00 41 20 00 00 3f 80 00 ....UA...A ..?..
+| 2544: 00 40 00 00 00 00 00 00 00 00 00 04 b9 41 10 00 .@...........A..
+| 2560: 00 41 20 00 00 40 00 00 00 40 40 00 00 00 00 00 .A ..@...@@.....
+| 2576: 00 00 00 05 1d 41 10 00 00 41 20 00 00 40 40 00 .....A...A ..@@.
+| 2592: 00 40 80 00 00 00 00 00 00 00 00 05 81 41 10 00 .@...........A..
+| 2608: 00 41 20 00 00 40 80 00 00 40 a0 00 00 00 00 00 .A ..@...@......
+| 2624: 00 00 00 05 e5 41 10 00 00 41 20 00 00 40 a0 00 .....A...A ..@..
+| 2640: 00 40 c0 00 00 00 00 00 00 00 00 06 49 41 10 00 .@..........IA..
+| 2656: 00 41 20 00 00 40 c0 00 00 40 e0 00 00 00 00 00 .A ..@...@......
+| 2672: 00 00 00 06 ad 41 10 00 00 41 20 00 00 40 e0 00 .....A...A ..@..
+| 2688: 00 41 00 00 00 00 00 00 00 00 00 07 11 41 10 00 .A...........A..
+| 2704: 00 41 20 00 00 41 00 00 00 41 10 00 00 00 00 00 .A ..A...A......
+| 2848: 00 00 00 00 00 00 00 00 00 00 00 00 00 89 50 01 ..............P.
+| 2864: 04 00 93 24 00 01 00 04 00 00 00 00 00 00 00 03 ...$............
+| 2880: 00 00 00 00 40 80 00 00 00 00 00 00 3f 80 00 00 ....@.......?...
+| 2896: 00 00 00 00 00 00 00 02 00 00 00 00 41 20 00 00 ............A ..
+| 2912: 00 00 00 00 41 10 00 00 00 00 00 00 00 00 00 04 ....A...........
+| 2928: 00 00 00 00 41 20 00 00 40 c0 00 00 41 20 00 00 ....A ..@...A ..
+| 2944: 00 00 00 00 00 00 00 05 40 a0 00 00 41 00 00 00 ........@...A...
+| 2960: 00 00 00 00 41 20 00 00 00 00 00 00 00 00 00 00 ....A ..........
+| page 6 offset 20480
+| 0: 0d 00 00 00 02 06 5a 00 0b 2d 06 5a 00 00 00 00 ......Z..-.Z....
+| 1616: 00 00 00 00 00 00 00 00 00 00 89 50 05 04 00 93 ...........P....
+| 1632: 24 00 00 00 1c 00 00 00 00 00 00 03 ed 40 a0 00 $............@..
+| 1648: 00 40 c0 00 00 00 00 00 00 3f 80 00 00 00 00 00 .@.......?......
+| 1664: 00 00 00 04 51 40 a0 00 00 40 c0 00 00 3f 80 00 ....Q@...@...?..
+| 1680: 00 40 00 00 00 00 00 00 00 00 00 04 b5 40 a0 00 .@...........@..
+| 1696: 00 40 c0 00 00 40 00 00 00 40 40 00 00 00 00 00 .@...@...@@.....
+| 1712: 00 00 00 05 19 40 a0 00 00 40 c0 00 00 40 40 00 .....@...@...@@.
+| 1728: 00 40 80 00 00 00 00 00 00 00 00 05 7d 40 a0 00 .@...........@..
+| 1744: 00 40 c0 00 00 40 80 00 00 40 a0 00 00 00 00 00 .@...@...@......
+| 1760: 00 00 00 05 e1 40 a0 00 00 40 c0 00 00 40 a0 00 .....@...@...@..
+| 1776: 00 40 c0 00 00 00 00 00 00 00 00 06 45 40 a0 00 .@..........E@..
+| 1792: 00 40 c0 00 00 40 c0 00 00 40 e0 00 00 00 00 00 .@...@...@......
+| 1808: 00 00 00 06 a9 40 a0 00 00 40 c0 00 00 40 e0 00 .....@...@...@..
+| 1824: 00 41 00 00 00 00 00 00 00 00 00 07 0d 40 a0 00 .A...........@..
+| 1840: 00 40 c0 00 00 41 00 00 00 41 10 00 00 00 00 00 .@...A...A......
+| 1856: 00 00 00 03 ee 40 c0 00 00 40 e0 00 00 00 00 00 .....@...@......
+| 1872: 00 3f 80 00 00 00 00 00 00 00 00 04 52 40 c0 00 .?..........R@..
+| 1888: 00 40 e0 00 00 3f 80 00 00 40 00 00 00 00 00 00 .@...?...@......
+| 1904: 00 00 00 04 b6 40 c0 00 00 40 e0 00 00 40 00 00 .....@...@...@..
+| 1920: 00 40 40 00 00 00 00 00 00 00 00 05 1a 40 c0 00 .@@..........@..
+| 1936: 00 40 e0 00 00 40 40 00 00 40 80 00 00 00 00 00 .@...@@..@......
+| 1952: 00 00 00 05 7e 40 c0 00 00 40 e0 00 00 40 80 00 ....~@...@...@..
+| 1968: 00 40 a0 00 00 00 00 00 00 00 00 05 e2 40 c0 00 .@...........@..
+| 1984: 00 40 e0 00 00 40 a0 00 00 40 c0 00 00 00 00 00 .@...@...@......
+| 2000: 00 00 00 06 46 40 c0 00 00 40 e0 00 00 40 c0 00 ....F@...@...@..
+| 2016: 00 40 e0 00 00 00 00 00 00 00 00 06 aa 40 c0 00 .@...........@..
+| 2032: 00 40 e0 00 00 40 e0 00 00 41 00 00 00 00 00 00 .@...@...A......
+| 2048: 00 00 00 07 0e 40 c0 00 00 40 e0 00 00 41 00 00 .....@...@...A..
+| 2064: 00 41 10 00 00 00 00 00 00 00 00 03 ef 40 e0 00 .A...........@..
+| 2080: 00 41 00 00 00 00 00 00 00 3f 80 00 00 00 00 00 .A.......?......
+| 2096: 00 00 00 04 53 40 e0 00 00 41 00 00 00 3f 80 00 ....S@...A...?..
+| 2112: 00 40 00 00 00 00 00 00 00 00 00 04 b7 40 e0 00 .@...........@..
+| 2128: 00 41 00 00 00 40 00 00 00 40 40 00 00 00 00 00 .A...@...@@.....
+| 2144: 00 00 00 05 1b 40 e0 00 00 41 00 00 00 40 40 00 .....@...A...@@.
+| 2160: 00 40 80 00 00 00 00 00 00 00 00 05 7f 40 e0 00 .@...........@..
+| 2176: 00 41 00 00 00 40 80 00 00 40 a0 00 00 00 00 00 .A...@...@......
+| 2192: 00 00 00 05 e3 40 e0 00 00 41 00 00 00 40 a0 00 .....@...A...@..
+| 2208: 00 40 c0 00 00 00 00 00 00 00 00 06 47 40 e0 00 .@..........G@..
+| 2224: 00 41 00 00 00 40 c0 00 00 40 e0 00 00 00 00 00 .A...@...@......
+| 2240: 00 00 00 06 ab 40 e0 00 00 41 00 00 00 40 e0 00 .....@...A...@..
+| 2256: 00 41 00 00 00 00 00 00 00 00 00 07 0f 40 e0 00 .A...........@..
+| 2272: 00 41 00 00 00 41 00 00 00 41 10 00 00 00 00 00 .A...A...A......
+| 2288: 00 00 00 07 73 40 e0 00 00 41 00 00 00 41 10 00 ....s@...A...A..
+| 2304: 00 41 20 00 00 00 00 00 00 00 00 00 00 00 00 00 .A .............
+| 2848: 00 00 00 00 00 00 00 00 00 00 00 00 00 89 50 04 ..............P.
+| 2864: 04 00 93 24 00 00 00 18 00 00 00 00 00 00 06 43 ...$...........C
+| 2880: 40 40 00 00 40 80 00 00 40 c0 00 00 40 e0 00 00 @@..@...@...@...
+| 2896: 00 00 00 00 00 00 06 42 40 00 00 00 40 40 00 00 .......B@...@@..
+| 2912: 40 c0 00 00 40 e0 00 00 00 00 00 00 00 00 06 41 @...@..........A
+| 2928: 3f 80 00 00 40 00 00 00 40 c0 00 00 40 e0 00 00 ?...@...@...@...
+| 2944: 00 00 00 00 00 00 06 40 00 00 00 00 3f 80 00 00 .......@....?...
+| 2960: 40 c0 00 00 40 e0 00 00 00 00 00 00 00 00 06 44 @...@..........D
+| 2976: 40 80 00 00 40 a0 00 00 40 c0 00 00 40 e0 00 00 @...@...@...@...
+| 2992: 00 00 00 00 00 00 06 a7 40 40 00 00 40 80 00 00 ........@@..@...
+| 3008: 40 e0 00 00 41 00 00 00 00 00 00 00 00 00 06 a6 @...A...........
+| 3024: 40 00 00 00 40 40 00 00 40 e0 00 00 41 00 00 00 @...@@..@...A...
+| 3040: 00 00 00 00 00 00 06 a5 3f 80 00 00 40 00 00 00 ........?...@...
+| 3056: 40 e0 00 00 41 00 00 00 00 00 00 00 00 00 06 a4 @...A...........
+| 3072: 00 00 00 00 3f 80 00 00 40 e0 00 00 41 00 00 00 ....?...@...A...
+| 3088: 00 00 00 00 00 00 06 a8 40 80 00 00 40 a0 00 00 ........@...@...
+| 3104: 40 e0 00 00 41 00 00 00 00 00 00 00 00 00 07 0a @...A...........
+| 3120: 40 00 00 00 40 40 00 00 41 00 00 00 41 10 00 00 @...@@..A...A...
+| 3136: 00 00 00 00 00 00 07 09 3f 80 00 00 40 00 00 00 ........?...@...
+| 3152: 41 00 00 00 41 10 00 00 00 00 00 00 00 00 07 08 A...A...........
+| 3168: 00 00 00 00 3f 80 00 00 41 00 00 00 41 10 00 00 ....?...A...A...
+| 3184: 00 00 00 00 00 00 07 0b 40 40 00 00 40 80 00 00 ........@@..@...
+| 3200: 41 00 00 00 41 10 00 00 00 00 00 00 00 00 07 0c A...A...........
+| 3216: 40 80 00 00 40 a0 00 00 41 00 00 00 41 10 00 00 @...@...A...A...
+| 3232: 00 00 00 00 00 00 07 6e 40 00 00 00 40 40 00 00 .......n@...@@..
+| 3248: 41 10 00 00 41 20 00 00 00 00 00 00 00 00 07 6d A...A .........m
+| 3264: 3f 80 00 00 40 00 00 00 41 10 00 00 41 20 00 00 ?...@...A...A ..
+| 3280: 00 00 00 00 00 00 07 6c 00 00 00 00 3f 80 00 00 .......l....?...
+| 3296: 41 10 00 00 41 20 00 00 00 00 00 00 00 00 07 6f A...A .........o
+| 3312: 40 40 00 00 40 80 00 00 41 10 00 00 41 20 00 00 @@..@...A...A ..
+| 3328: 00 00 00 00 00 00 07 70 40 80 00 00 40 a0 00 00 .......p@...@...
+| 3344: 41 10 00 00 41 20 00 00 00 00 00 00 00 00 07 71 A...A .........q
+| 3360: 40 a0 00 00 40 c0 00 00 41 10 00 00 41 20 00 00 @...@...A...A ..
+| 3376: 00 00 00 00 00 00 07 72 40 c0 00 00 40 e0 00 00 .......r@...@...
+| 3392: 41 10 00 00 41 20 00 00 00 00 00 00 00 00 07 74 A...A .........t
+| 3408: 41 00 00 00 41 10 00 00 41 10 00 00 41 20 00 00 A...A...A...A ..
+| 3424: 00 00 00 00 00 00 07 75 41 10 00 00 41 20 00 00 .......uA...A ..
+| 3440: 41 10 00 00 41 20 00 00 00 00 00 00 00 00 00 00 A...A ..........
+| end c1b.db
+ }]
+ catchsql {
+ SELECT rtreecheck('t1');
+ }
+} {1 {SQL logic error}}
+
+do_test rtreefuzz001-200 {
+ sqlite3 db {}
+ db deserialize [decode_hexdb {
+| size 16384 pagesize 4096 filename c3.db
+| page 1 offset 0
+| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
+| 16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 04 .....@ ........
+| 32: 00 00 00 00 01 00 00 00 00 00 00 04 00 00 00 04 ................
+| 48: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 ................
+| 96: 00 00 00 00 0d 00 00 00 04 0e 9c 00 0f ad 0f 4f ...............O
+| 112: 0e fc 0e 9c 00 00 00 00 00 00 00 00 00 00 00 00 ................
+| 3728: 00 00 00 00 00 00 00 00 00 00 00 00 5e 04 07 17 ............^...
+| 3744: 1f 1f 01 81 0b 74 61 62 6c 65 74 31 5f 70 61 72 .....tablet1_par
+| 3760: 65 6e 74 74 31 5f 70 61 72 65 6e 74 04 43 52 45 entt1_parent.CRE
+| 3776: 41 54 45 20 54 41 42 4c 45 20 22 74 31 5f 70 61 ATE TABLE .t1_pa
+| 3792: 72 65 6e 74 22 28 6e 6f 64 65 6e 6f 20 49 4e 54 rent.(nodeno INT
+| 3808: 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59 EGER PRIMARY KEY
+| 3824: 2c 70 61 72 65 6e 74 6e 6f 64 65 29 51 03 06 17 ,parentnode)Q...
+| 3840: 1b 1b 01 7b 74 61 62 6c 65 74 31 5f 6e 6f 64 65 ....tablet1_node
+| 3856: 74 31 5f 6e 6f 64 65 03 43 52 45 41 54 45 20 54 t1_node.CREATE T
+| 3872: 41 42 4c 45 20 22 74 31 5f 6e 6f 64 65 22 28 6e ABLE .t1_node.(n
+| 3888: 6f 64 65 6e 6f 20 49 4e 54 45 47 45 52 20 50 52 odeno INTEGER PR
+| 3904: 49 4d 41 52 59 20 4b 45 59 2c 64 61 74 61 29 5c IMARY KEY,data).
+| 3920: 02 07 17 1d 1d 01 81 0b 74 61 62 6c 65 74 31 5f ........tablet1_
+| 3936: 72 6f 77 69 64 74 31 5f 72 6f 77 69 64 02 43 52 rowidt1_rowid.CR
+| 3952: 45 41 54 45 20 54 41 42 4c 45 20 22 74 31 5f 72 EATE TABLE .t1_r
+| 3968: 6f 77 69 64 22 28 72 6f 77 69 64 20 49 4e 54 45 owid.(rowid INTE
+| 3984: 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c GER PRIMARY KEY,
+| 4000: 6e 6f 64 65 6e 6f 2c 61 30 2c 61 31 29 51 01 07 nodeno,a0,a1)Q..
+| 4016: 17 11 11 08 81 0f 74 61 62 6c 65 74 31 74 31 43 ......tablet1t1C
+| 4032: 52 45 41 54 45 20 56 49 52 54 55 41 4c 20 54 41 REATE VIRTUAL TA
+| 4048: 42 4c 45 20 74 31 20 55 53 49 4e 47 20 72 74 72 BLE t1 USING rtr
+| 4064: 65 65 28 69 64 2c 78 30 2c 78 31 2c 79 30 2c 79 ee(id,x0,x1,y0,y
+| 4080: 31 2c 2b 6c 61 62 65 6c 2c 2b 6f 74 68 65 72 29 1,+label,+other)
+| page 2 offset 4096
+| 0: 0d 00 00 00 0e 0e f7 00 0f e8 0f d0 0f b7 0f 9e ................
+| 16: 0f 91 0f 81 0f 70 0f 5e 0f 4f 0f 39 0f 29 0f 18 .....p.^.O.9.)..
+| 32: 0f 06 0e f7 00 00 00 00 00 00 00 00 00 00 00 00 ................
+| 3824: 00 00 00 00 00 00 00 0d 0e 05 00 09 1d 00 74 6f ..............to
+| 3840: 70 20 68 61 6c 66 10 0d 05 00 09 23 00 62 6f 74 p half.....#.bot
+| 3856: 74 6f 6d 20 68 61 6c 66 0f 0c 05 00 09 21 00 72 tom half.....!.r
+| 3872: 69 67 68 74 20 68 61 6c 66 0e 0b 05 00 09 1f 00 ight half.......
+| 3888: 6c 65 66 74 20 68 61 6c 66 14 0a 05 00 09 2b 00 left half.....+.
+| 3904: 74 68 65 20 77 68 6f 6c 65 20 74 68 69 6e 67 0d the whole thing.
+| 3920: 09 05 00 09 1d 00 74 6f 70 20 65 64 67 65 10 08 ......top edge..
+| 3936: 05 00 09 23 00 62 6f 74 74 6f 6d 20 65 64 67 65 ...#.bottom edge
+| 3952: 0f 07 05 00 09 21 00 72 69 67 68 74 20 65 64 67 .....!.right edg
+| 3968: 65 0e 06 05 00 09 1f 00 6c 65 66 74 20 65 64 67 e.......left edg
+| 3984: 65 0b 05 05 00 09 19 00 63 65 6e 74 65 72 17 04 e.......center..
+| 4000: 05 00 09 31 00 75 70 70 65 72 2d 72 69 67 68 74 ...1.upper-right
+| 4016: 20 63 6f 72 6e 65 72 17 03 05 00 09 31 00 6c 6f corner.....1.lo
+| 4032: 77 65 72 2d 72 69 67 68 74 27 60 f6 32 6e 65 72 wer-right'`.2ner
+| 4048: 16 02 05 00 09 2f 00 75 70 70 65 72 2d 6c 65 66 ...../.upper-lef
+| 4064: 74 20 63 6f 72 6e 65 72 16 01 05 00 09 2f 00 6c t corner...../.l
+| 4080: 6f 77 65 72 2d 6c 65 66 74 20 63 6f 72 6e 65 72 ower-left corner
+| page 3 offset 8192
+| 0: 0d 00 00 00 02 0b 2d 00 0b 2d 00 00 00 00 00 00 ......-..-......
+| 2848: 00 00 00 00 00 00 00 00 00 00 00 00 00 89 50 01 ..............P.
+| 2864: 04 00 93 24 00 00 00 0e 00 00 00 00 00 00 00 01 ...$............
+| 2880: 00 00 00 00 41 20 00 00 00 00 00 00 41 20 01 00 ....A ......A ..
+| 2896: 00 00 00 00 00 00 00 02 00 00 00 00 41 00 00 04 ............A...
+| 2912: 2b 40 00 0c 42 c8 00 00 00 00 00 00 00 00 00 03 +@..B...........
+| 2928: 42 b4 00 00 42 c8 00 00 00 00 00 00 41 20 00 00 B...B.......A ..
+| 2944: 00 00 00 00 00 00 00 04 42 b4 00 00 42 c8 00 00 ........B...B...
+| 2960: 42 b4 00 00 42 c8 00 00 00 00 00 00 00 00 00 05 B...B...........
+| 2976: 42 20 00 00 42 70 00 00 42 20 00 00 42 70 00 00 B ..Bp..B ..Bp..
+| 2992: 00 00 00 00 00 00 00 60 00 00 00 04 0a 00 00 00 .......`........
+| 3008: 00 00 00 42 c8 00 00 00 00 00 00 00 00 00 07 42 ...B...........B
+| 3024: be 00 00 42 c8 00 00 00 00 00 00 42 c8 00 00 00 ...B.......B....
+| 3040: 00 00 00 00 00 00 08 00 00 00 00 42 c8 00 00 00 ...........B....
+| 3056: 00 00 00 40 a0 00 00 00 00 00 00 00 00 00 09 00 ...@............
+| 3072: 00 00 00 42 c8 00 00 42 be 00 00 42 c8 00 00 00 ...B...B...B....
+| 3088: 00 00 00 00 00 00 0a 00 00 00 00 42 c8 00 00 00 ...........B....
+| 3104: 00 00 00 42 c8 00 00 00 00 00 00 00 00 00 0b 00 ...B............
+| 3120: 00 00 00 42 48 00 00 00 00 00 04 2c 80 00 00 00 ...BH......,....
+| 3136: 00 00 00 00 00 00 c4 24 c0 00 04 2c 80 00 00 00 .......$...,....
+| 3152: 00 00 04 2c 80 00 00 00 00 00 00 00 00 00 d0 00 ...,............
+| 3168: 00 00 04 2c 80 00 00 00 00 00 04 24 80 00 00 00 ...,.......$....
+| 3184: 00 00 00 00 00 00 e0 00 00 00 04 2c 80 00 04 24 ...........,...$
+| 3200: c0 00 04 2c 00 00 00 00 00 00 00 00 00 00 00 00 ...,............
+| page 4 offset 12288
+| 0: 0d 00 00 00 00 10 00 00 00 00 00 00 00 00 00 00 ................
+| end c3.db
+ }]
+ catchsql {
+ WITH RECURSIVE
+ c1(x) AS (VALUES(0) UNION ALL SELECT x+1 FROM c1 WHERE x<99),
+ c2(y) AS (VALUES(0) UNION ALL SELECT y+1 FROM c2 WHERE y<99)
+ INSERT INTO t1(id, x0,x1,y0,y1,label)
+ SELECT 1000+x+y*100, x, x+1, y, y+1, printf('box-%d,%d',x,y) FROM c1, c2;
+ }
+} {1 {database disk image is malformed}}
+do_test rtreefuzz001-210 {
+ catchsql {
+ SELECT rtreecheck('t1');
+ }
+} {/1 .*corrupt.*/}
+
+do_test rtreefuzz001-300 {
+ sqlite3 db {}
+ db deserialize [decode_hexdb {
+| size 16384 pagesize 4096 filename c4.db
+| page 1 offset 0
+| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
+| 16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 04 .....@ ........
+| 32: 00 00 00 00 00 00 00 00 00 00 00 04 00 00 00 04 ................
+| 96: 00 00 00 00 0d 00 00 00 04 0e 9c 00 0f ad 0f 4f ...............O
+| 112: 0e fc 0e 9c 00 00 00 00 00 00 00 00 00 00 00 00 ................
+| 3728: 00 00 00 00 00 00 00 00 00 00 00 00 5e 04 07 17 ............^...
+| 3744: 1f 1f 01 81 0b 74 61 62 6c 65 74 31 5f 70 61 72 .....tablet1_par
+| 3760: 65 6e 74 74 31 5f 70 61 72 65 6e 74 04 43 52 45 entt1_parent.CRE
+| 3776: 41 54 45 20 54 41 42 4c 45 20 22 74 31 5f 70 61 ATE TABLE .t1_pa
+| 3792: 72 65 6e 74 22 28 6e 6f 64 65 6e 6f 20 49 4e 54 rent.(nodeno INT
+| 3808: 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59 EGER PRIMARY KEY
+| 3824: 2c 70 61 72 65 6e 74 6e 6f 64 65 29 51 03 06 17 ,parentnode)Q...
+| 3840: 1b 1b 01 7b 74 61 62 6c 65 74 31 5f 6e 6f 64 65 ....tablet1_node
+| 3856: 74 31 5f 6e 6f 64 65 03 43 52 45 41 54 45 20 54 t1_node.CREATE T
+| 3872: 41 42 4c 45 20 22 74 31 5f 6e 6f 64 65 22 28 6e ABLE .t1_node.(n
+| 3888: 6f 64 65 6e 6f 20 49 4e 54 45 47 45 52 20 50 52 odeno INTEGER PR
+| 3904: 49 4d 41 52 59 20 4b 45 59 2c 64 61 74 61 29 5c IMARY KEY,data).
+| 3920: 02 07 17 1d 1d 01 81 0b 74 61 62 6c 65 74 31 5f ........tablet1_
+| 3936: 72 6f 77 69 64 74 31 5f 72 6f 77 69 64 02 43 52 rowidt1_rowid.CR
+| 3952: 45 41 54 45 20 54 41 42 4c 45 20 22 74 31 5f 72 EATE TABLE .t1_r
+| 3968: 6f 77 69 64 22 28 72 6f 77 69 64 20 49 4e 54 45 owid.(rowid INTE
+| 3984: 47 45 72 20 50 52 49 4d 41 52 59 20 4b 45 59 2c GEr PRIMARY KEY,
+| 4000: 6e 6f 64 65 6e 6f 2c 61 30 2c 61 31 29 51 01 07 nodeno,a0,a1)Q..
+| 4016: 17 11 11 08 81 0f 74 61 62 6c 65 74 31 74 31 43 ......tablet1t1C
+| 4032: 52 45 41 54 45 20 56 49 52 54 55 41 4c 20 54 41 REATE VIRTUAL TA
+| 4048: 42 4c 45 20 74 31 20 55 53 49 4e 47 20 72 74 72 BLE t1 USING rtr
+| 4064: 65 65 28 69 64 2c 78 30 2c 78 31 2c 79 30 2c 79 ee(id,x0,x1,y0,y
+| 4080: 31 2c 2b 6c 61 62 65 6c 2c 2b 6f 74 68 65 72 29 1,+label,+other)
+| page 2 offset 4096
+| 0: 0d 00 00 00 0e 0e f7 00 0f e8 0f 00 fb 70 f9 e0 .............p..
+| 16: f9 10 f8 10 f7 00 f5 e0 f4 f0 f3 90 f2 90 f1 80 ................
+| 32: f0 60 ef 00 00 00 00 00 00 00 00 00 00 00 00 00 .`..............
+| 3824: 00 00 00 00 00 00 00 0d 0e 05 00 09 1d 00 74 6f ..............to
+| 3840: 70 20 68 61 6c 66 10 0d 05 00 09 23 00 62 6f 74 p half.....#.bot
+| 3856: 74 6f 6d 20 68 61 6c 66 0f 0c 05 00 09 21 00 72 tom half.....!.r
+| 3872: 69 67 68 74 20 68 61 6c 66 0e 0b 05 00 09 1f 00 ight half.......
+| 3888: 6c 65 66 74 20 68 61 6c 66 14 0a 05 00 09 2b 00 left half.....+.
+| 3904: 00 03 98 20 49 98 2f 6c 62 05 74 68 69 6e 67 0d ... I./lb.thing.
+| 3920: 09 05 00 09 1d 00 74 6f 70 20 65 64 67 65 10 08 ......top edge..
+| 3936: 05 00 09 23 00 62 6f 74 74 6f 6d 20 65 64 67 65 ...#.bottom edge
+| 3952: 0f 07 05 00 09 21 00 72 69 67 68 74 20 65 64 67 .....!.right edg
+| 3968: 65 0e 06 05 00 09 1f 00 6c 65 66 74 20 65 64 67 e.......left edg
+| 3984: 65 0b 05 05 00 09 19 00 63 65 6e 74 65 72 17 04 e.......center..
+| 4000: 05 00 09 31 00 75 70 70 65 72 2d 72 69 67 68 74 ...1.upper-right
+| 4016: 20 63 6f 72 6e 65 72 17 03 05 00 09 31 00 6c 6f corner.....1.lo
+| 4032: 77 65 72 2d 72 69 67 68 74 20 63 6f 72 6e 65 72 wer-right corner
+| 4048: 16 02 05 00 09 2f 00 75 70 70 65 72 2d 6c 65 66 ...../.upper-lef
+| 4064: 74 20 63 6f 72 6e 65 72 16 01 05 00 09 2f 00 6c t corner...../.l
+| 4080: 6f 77 65 72 2d 6c 65 66 74 20 63 6f 72 6e 65 72 ower-left corner
+| page 3 offset 8192
+| 0: 0d 00 00 00 01 0b 2d 00 0b 2d 00 00 00 00 00 00 ......-..-......
+| 2848: 00 00 00 00 00 00 00 00 00 00 00 00 00 89 50 01 ..............P.
+| 2864: 04 00 93 24 00 00 00 0e 00 00 00 00 00 00 00 01 ...$............
+| 2880: 00 00 00 04 01 20 00 00 00 00 00 04 12 00 00 00 ..... ..........
+| 2896: 00 00 00 00 00 00 00 23 00 00 00 00 41 20 00 00 .......#....A ..
+| 2912: 42 b4 00 00 42 c8 00 00 00 00 00 00 00 00 00 03 B...B...........
+| 2928: 42 b4 00 00 42 c8 00 00 00 00 00 00 41 20 00 00 B...B.......A ..
+| 2944: 00 00 00 00 00 00 00 04 42 b4 00 00 42 c8 00 00 ........B...B...
+| 2960: 42 b4 00 00 42 c8 00 00 00 00 00 00 00 00 00 05 B...B...........
+| 2976: 42 20 00 00 42 70 00 00 42 20 00 00 42 70 00 00 B ..Bp..B ..Bp..
+| 2992: 00 00 00 00 00 00 00 06 00 00 00 00 40 a0 00 00 ............@...
+| 3008: 00 00 00 04 2c 80 00 00 00 00 00 00 00 00 00 74 ....,..........t
+| 3024: 2b e0 00 04 2c 80 00 04 2c 80 00 00 00 00 00 00 +...,...,.......
+| 3040: 00 00 00 80 00 00 00 04 2c 80 00 00 00 00 00 04 ........,.......
+| 3056: 0a 00 00 00 00 00 b0 80 00 00 04 2c 80 00 04 2b ...........,...+
+| 3072: e0 00 04 2c 80 00 00 00 00 00 00 00 00 00 a0 00 ...,............
+| 3088: 00 00 04 2c 80 00 00 00 00 00 04 2c 80 00 00 00 ...,.......,....
+| 3104: 00 00 00 00 00 00 b0 00 00 00 04 24 80 00 00 00 ...........$....
+| 3120: 00 00 04 2c 80 00 00 00 00 00 00 00 50 00 91 f0 ...,........P...
+| 3136: 06 c6 56 67 42 06 86 16 c6 61 40 a0 50 00 92 b0 ..VgB....a@.P...
+| 3152: 07 46 86 52 07 76 86 f6 c6 52 07 46 86 96 e6 70 .F.R.v...R.F...p
+| 3168: d0 90 50 00 91 d0 07 46 f7 02 06 56 46 76 51 00 ..P....F...VFvQ.
+| 3184: 80 50 00 92 30 06 26 f7 47 46 f6 d2 06 56 46 76 .P..0.&.GF...VFv
+| 3200: 50 f0 70 50 00 92 10 07 26 96 76 87 42 06 56 46 P.pP....&.v.B.VF
+| 3216: 76 50 e0 60 50 00 91 f0 06 c6 56 67 42 06 56 46 vP.`P.....VgB.VF
+| 3232: 76 50 b0 50 50 00 91 90 06 36 56 e7 46 57 21 70 vP.PP....6V.FW!p
+| 3248: 40 50 00 93 10 07 57 07 06 57 22 d7 26 96 76 87 @P....W..W..&.v.
+| 3264: 42 06 36 f7 26 e6 57 21 70 30 50 00 93 10 06 c6 B.6.&.W!p0P.....
+| 3280: f7 76 57 22 d7 26 96 76 87 42 06 36 f7 26 e6 57 .vW..&.v.B.6.&.W
+| 3296: 21 60 20 50 00 92 f0 07 57 07 06 57 22 d6 c6 56 !` P....W..W...V
+| 3312: 60 00 00 c4 24 c0 00 04 2c 80 00 00 00 00 00 04 `...$...,.......
+| 3328: 2c 80 00 00 00 00 00 00 00 00 00 d0 00 00 00 04 ,...............
+| 3344: 2c 80 00 00 00 00 00 04 24 80 00 00 00 00 00 00 ,.......$.......
+| 3360: 00 00 00 e0 00 00 00 04 2c 80 00 04 24 c0 00 04 ........,...$...
+| 3376: 2c 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ,...............
+| page 4 offset 12288
+| 0: 0d 00 00 00 00 10 00 00 00 00 00 00 00 00 00 00 ................
+| end c4.db
+ }]
+ catchsql {
+ UPDATE t1 SET label='x';
+ }
+} {1 {rtree constraint failed: t1.(y0<=y1)}}
+do_test rtreefuzz001-310 {
+ catchsql {
+ SELECT rtreecheck('t1');
+ }
+} {/1 .*corrupt.*/}
+
+do_test rtreefuzz001-400 {
+ sqlite3 db {}
+ db deserialize [decode_hexdb {
+| size 16384 pagesize 4096 filename c7.db
+| page 1 offset 0
+| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
+| 16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 04 .....@ ........
+| 32: 00 00 00 00 01 00 00 00 00 00 00 04 00 00 00 04 ................
+| 48: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 ................
+| 96: 00 00 00 00 0d 00 00 00 04 0e 9c 00 0f ad 0f 4f ...............O
+| 112: 0e fc 0e 9c 00 00 00 00 00 00 00 00 00 00 00 00 ................
+| 3728: 00 00 00 00 00 00 00 00 00 00 00 00 5e 04 07 17 ............^...
+| 3744: 1f 1f 01 81 0b 74 61 62 6c 65 74 31 5f 70 61 72 .....tablet1_par
+| 3760: 65 6e 74 74 31 5f 70 61 72 65 6e 74 04 43 52 45 entt1_parent.CRE
+| 3776: 41 54 45 20 54 41 42 4c 45 20 22 74 31 5f 70 61 ATE TABLE .t1_pa
+| 3792: 72 65 6e 74 22 28 6e 6f 64 65 6e 6f 20 49 4e 54 rent.(nodeno INT
+| 3808: 45 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59 EGER PRIMARY KEY
+| 3824: 2c 70 61 72 65 6e 74 6e 6f 64 65 29 51 03 06 17 ,parentnode)Q...
+| 3840: 1b 1b 01 7b 74 61 62 6c 65 74 31 5f 6e 6f 64 65 ....tablet1_node
+| 3856: 74 31 5f 6e 6f 64 65 03 43 52 45 41 54 45 20 54 t1_node.CREATE T
+| 3872: 41 42 4c 45 20 22 74 31 5f 6e 6f 64 65 22 28 6e ABLE .t1_node.(n
+| 3888: 6f 64 65 6e 6f 20 49 4e 54 45 47 45 52 20 50 52 odeno INTEGER PR
+| 3904: 49 4d 41 52 59 20 4b 45 59 2c 64 61 74 61 29 5c IMARY KEY,data).
+| 3920: 02 07 17 1d 1d 01 81 0b 74 61 62 6c 65 74 31 5f ........tablet1_
+| 3936: 72 6f 77 69 64 74 31 5f 72 6f 77 69 64 02 43 52 rowidt1_rowid.CR
+| 3952: 45 41 54 45 20 54 41 42 4c 45 20 22 74 31 5f 72 EATE TABLE .t1_r
+| 3968: 6f 77 69 64 22 28 72 6f 77 69 64 20 49 4e 54 45 owid.(rowid INTE
+| 3984: 47 45 52 20 50 52 49 4d 41 52 59 20 4b 45 59 2c GER PRIMARY KEY,
+| 4000: 6e 6f 64 65 6e 6f 2c 61 30 2c 61 31 29 51 01 07 nodeno,a0,a1)Q..
+| 4016: 17 11 11 08 81 0f 74 61 62 6c 65 74 31 74 31 43 ......tablet1t1C
+| 4032: 52 45 41 54 45 20 56 49 52 54 55 41 4c 20 54 41 REATE VIRTUAL TA
+| 4048: 42 4c 45 20 74 31 20 55 53 49 4e 47 20 72 74 72 BLE t1 USING rtr
+| 4064: 65 65 28 69 64 2c 78 30 2c 78 31 2c 79 30 2c 79 ee(id,x0,x1,y0,y
+| 4080: 31 2c 2b 6c 61 62 65 6c 2c 2b 6f 74 68 65 72 29 1,+label,+other)
+| page 2 offset 4096
+| 0: 0d 00 00 00 0e 0e f7 00 0f e8 0f d0 0f b7 0f 9e ................
+| 16: 0f 91 0f 81 0f 70 0f 5e 0f 4f 0f 39 0f 29 0f 18 .....p.^.O.9.)..
+| 32: 0f 06 0e f7 00 00 00 00 00 00 00 00 00 00 00 00 ................
+| 3824: 00 00 00 00 00 00 00 0d 0e 05 00 09 1d 00 74 6f ..............to
+| 3840: 70 20 68 61 6c 66 10 0d 05 00 09 23 00 62 6f 74 p half.....#.bot
+| 3856: 74 6f 6d 20 68 61 6c 66 0f 0c 05 00 09 21 00 72 tom half.....!.r
+| 3872: 69 67 68 74 20 68 61 6c 66 0e 0b 05 00 09 1f 00 ight half.......
+| 3888: 6c 65 66 74 20 68 61 6c 66 14 0a 05 00 09 2b 00 left half.....+.
+| 3904: 74 68 65 20 77 68 6f 6c 65 20 74 68 69 6e 67 0d the whole thing.
+| 3920: 09 05 00 09 1d 00 74 6f 70 20 65 64 67 65 10 08 ......top edge..
+| 3936: 05 00 09 23 00 62 6f 74 74 6f 6d 20 65 64 67 65 ...#.bottom edge
+| 3952: 0f 07 05 00 09 21 00 72 69 67 68 74 20 65 64 67 .....!.right edg
+| 3968: 65 0e 06 05 00 09 1f 00 6c 65 66 74 20 65 64 67 e.......left edg
+| 3984: 65 0b 05 05 00 09 19 00 23 65 6e 74 65 72 17 04 e.......#enter..
+| 4000: 05 00 09 31 00 75 70 70 65 72 2d 72 69 67 68 74 ...1.upper-right
+| 4016: 20 63 6f 72 6e 65 72 17 03 05 00 09 31 00 6c 6f corner.....1.lo
+| 4032: 77 65 72 2d 72 69 67 68 74 20 63 6f 72 6e 65 72 wer-right corner
+| 4048: 16 02 05 00 09 2f 00 75 70 70 65 72 2d 6c 65 66 ...../.upper-lef
+| 4064: 74 20 63 6f 72 6e 65 72 16 01 05 00 09 2f 00 6c t corner...../.l
+| 4080: 6f 77 65 72 2d 6c 65 66 74 20 63 6f 72 6e 65 72 ower-left corner
+| page 3 offset 8192
+| 0: 0d 00 00 00 02 0b 2d 00 0b 2d 00 00 00 00 00 00 ......-..-......
+| 2848: 00 00 00 00 00 00 00 00 00 00 00 00 00 89 50 01 ..............P.
+| 2864: 04 00 93 24 00 00 00 00 00 00 00 00 08 00 00 00 ...$............
+| 2880: 00 42 c8 00 00 00 00 00 00 40 a0 00 00 00 00 00 .B.......@......
+| 2896: 00 00 00 00 42 c8 00 00 00 00 00 00 00 00 00 07 ....B...........
+| 2912: 42 be 00 00 42 c8 00 00 00 00 00 00 42 c8 00 00 B...B.......B...
+| 2928: 00 00 00 00 00 00 00 08 00 00 00 00 42 c8 00 00 ............B...
+| 2944: 00 00 00 00 40 a0 00 00 00 00 00 00 00 00 00 09 ....@...........
+| 2960: 00 00 00 00 42 c8 00 00 42 be 00 00 42 c8 00 00 ....B...B...B...
+| 2976: 00 00 00 00 00 00 00 0a 00 00 00 00 42 c8 00 00 ............B...
+| 2992: 00 00 00 00 42 c8 00 00 00 00 00 00 00 00 00 0b ....B...........
+| 3008: 00 00 00 00 42 48 00 00 00 00 00 04 2c 80 00 00 ....BH......,...
+| 3024: 00 00 00 00 00 00 00 c4 00 00 00 00 00 42 c8 00 .............B..
+| 3040: 00 00 00 00 00 00 00 00 07 42 be 00 00 42 c8 00 .........B...B..
+| 3056: 00 00 00 00 00 42 c8 00 00 00 00 00 00 00 00 00 .....B..........
+| 3072: 08 00 00 00 00 42 c8 00 00 00 00 00 00 40 a0 00 .....B.......@..
+| 3088: 00 00 00 00 00 00 00 00 09 00 00 00 00 42 c8 00 .............B..
+| 3104: 00 42 be 00 00 42 c8 00 00 00 00 00 00 00 00 00 .B...B..........
+| 3120: 0a 00 00 00 00 42 c8 00 00 00 00 00 00 42 c8 00 .....B.......B..
+| 3136: 00 00 00 00 00 00 00 00 0b 00 00 00 00 42 48 00 .............BH.
+| 3152: 00 00 00 00 04 2c 80 00 00 00 00 00 00 00 00 00 .....,..........
+| 3168: c4 24 c0 00 04 2c 80 00 00 00 00 00 04 2c 80 00 .$...,.......,..
+| 3184: 00 00 00 00 00 00 00 00 d0 00 00 00 04 2c 80 00 .............,..
+| 3200: 00 00 00 00 04 24 80 00 00 00 00 00 00 00 00 00 .....$..........
+| 3216: e0 00 00 00 04 2c 80 00 04 24 c0 00 04 2c 00 00 .....,...$...,..
+| page 4 offset 12288
+| 0: 0d 00 00 00 00 10 00 00 00 00 00 00 0e 00 00 00 ................
+| 16: 00 42 c8 00 00 42 4c 00 00 42 c8 00 00 00 00 00 .B...BL..B......
+| 32: 00 00 00 0a 00 00 00 00 42 c8 00 00 00 00 00 00 ........B.......
+| 48: 42 c8 00 00 00 00 00 00 00 00 00 0b 00 00 00 00 B...............
+| 64: 42 48 00 00 00 00 00 04 2c 80 00 00 00 00 00 00 BH......,.......
+| 80: 00 00 00 c4 24 c0 00 04 2c 80 00 00 00 00 00 04 ....$...,.......
+| 96: 2c 80 00 00 00 00 00 00 00 00 00 d0 00 00 00 04 ,...............
+| 112: 2c 80 00 00 00 00 00 04 24 80 00 00 00 00 00 00 ,.......$.......
+| 128: 00 00 00 e0 00 00 00 04 2c 80 00 04 24 c0 00 04 ........,...$...
+| 144: 2c 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ,...............
+| end c7.db
+ }]
+ catchsql {
+ WITH RECURSIVE
+ c1(x) AS (VALUES(0) UNION ALL SELECT x+1 FROM c1 WHERE x<8),
+ c2(y) AS (VALUES(0) UNION ALL SELECT y+1 FROM c2 WHERE y<5)
+ INSERT INTO t1(id, x0,x1,y0,y1,label)
+ SELECT 1000+x+y*100, x, x+1, y, y+1, printf('box-%d,%d',x,y) FROM c1, c2;
+ }
+} {1 {database disk image is malformed}}
+
+finish_test
diff --git a/chromium/third_party/sqlite/src/ext/session/changeset.c b/chromium/third_party/sqlite/src/ext/session/changeset.c
index 88db9da1b47..651d3066544 100644
--- a/chromium/third_party/sqlite/src/ext/session/changeset.c
+++ b/chromium/third_party/sqlite/src/ext/session/changeset.c
@@ -42,7 +42,7 @@ static void usage(const char *argv0){
*/
static void readFile(const char *zFilename, int *pSz, void **ppBuf){
FILE *f;
- int sz;
+ sqlite3_int64 sz;
void *pBuf;
f = fopen(zFilename, "rb");
if( f==0 ){
@@ -50,9 +50,9 @@ static void readFile(const char *zFilename, int *pSz, void **ppBuf){
exit(1);
}
fseek(f, 0, SEEK_END);
- sz = (int)ftell(f);
+ sz = ftell(f);
rewind(f);
- pBuf = sqlite3_malloc( sz ? sz : 1 );
+ pBuf = sqlite3_malloc64( sz ? sz : 1 );
if( pBuf==0 ){
fprintf(stderr, "cannot allocate %d to hold content of \"%s\"\n",
sz, zFilename);
diff --git a/chromium/third_party/sqlite/src/ext/session/changesetfuzz.c b/chromium/third_party/sqlite/src/ext/session/changesetfuzz.c
index 9b3619d64fe..3ebf7c7536d 100644
--- a/chromium/third_party/sqlite/src/ext/session/changesetfuzz.c
+++ b/chromium/third_party/sqlite/src/ext/session/changesetfuzz.c
@@ -141,7 +141,7 @@ static void usage(const char *argv0){
*/
static void fuzzReadFile(const char *zFilename, int *pSz, void **ppBuf){
FILE *f;
- int sz;
+ sqlite3_int64 sz;
void *pBuf;
f = fopen(zFilename, "rb");
if( f==0 ){
@@ -149,9 +149,9 @@ static void fuzzReadFile(const char *zFilename, int *pSz, void **ppBuf){
exit(1);
}
fseek(f, 0, SEEK_END);
- sz = (int)ftell(f);
+ sz = ftell(f);
rewind(f);
- pBuf = sqlite3_malloc( sz ? sz : 1 );
+ pBuf = sqlite3_malloc64( sz ? sz : 1 );
if( pBuf==0 ){
fprintf(stderr, "cannot allocate %d to hold content of \"%s\"\n",
sz, zFilename);
@@ -340,8 +340,8 @@ struct FuzzChange {
/*
** Allocate and return nByte bytes of zeroed memory.
*/
-static void *fuzzMalloc(int nByte){
- void *pRet = sqlite3_malloc(nByte);
+static void *fuzzMalloc(sqlite3_int64 nByte){
+ void *pRet = sqlite3_malloc64(nByte);
if( pRet ){
memset(pRet, 0, nByte);
}
@@ -631,7 +631,7 @@ static int fuzzParseChangeset(
/* If the table-header was successfully parsed, add the new change-group
** to the array and parse the associated changes. */
if( rc==SQLITE_OK ){
- FuzzChangesetGroup **apNew = (FuzzChangesetGroup**)sqlite3_realloc(
+ FuzzChangesetGroup **apNew = (FuzzChangesetGroup**)sqlite3_realloc64(
pParse->apGroup, sizeof(FuzzChangesetGroup*)*(pParse->nGroup+1)
);
if( apNew==0 ){
@@ -1214,7 +1214,7 @@ int main(int argc, char **argv){
fuzzPrintGroup(&changeset, changeset.apGroup[i]);
}
}else{
- pBuf = (u8*)fuzzMalloc(nChangeset*2 + 1024);
+ pBuf = (u8*)fuzzMalloc((sqlite3_int64)nChangeset*2 + 1024);
if( pBuf==0 ){
rc = SQLITE_NOMEM;
}else{
@@ -1237,4 +1237,3 @@ int main(int argc, char **argv){
return rc;
}
-
diff --git a/chromium/third_party/sqlite/src/ext/session/session_speed_test.c b/chromium/third_party/sqlite/src/ext/session/session_speed_test.c
index f18bb306e44..de9de273f62 100644
--- a/chromium/third_party/sqlite/src/ext/session/session_speed_test.c
+++ b/chromium/third_party/sqlite/src/ext/session/session_speed_test.c
@@ -356,5 +356,3 @@ int main(int argc, char **argv){
return 0;
}
-
-
diff --git a/chromium/third_party/sqlite/src/ext/session/sessionwor.test b/chromium/third_party/sqlite/src/ext/session/sessionwor.test
index e9545c5376e..1d594c5624f 100644
--- a/chromium/third_party/sqlite/src/ext/session/sessionwor.test
+++ b/chromium/third_party/sqlite/src/ext/session/sessionwor.test
@@ -30,27 +30,71 @@ proc test_reset {} {
sqlite3 db2 test.db2
}
+foreach {tn wo} {
+ 1 ""
+ 2 "WITHOUT ROWID"
+} {
+ reset_db
-do_execsql_test 1.0 {
- CREATE TABLE t1(a PRIMARY KEY, b) WITHOUT ROWID;
-}
+ do_execsql_test 1.$tn.0 "CREATE TABLE t1(a PRIMARY KEY, b) $wo ;"
-do_iterator_test 1.1 t1 {
- INSERT INTO t1 VALUES('one', 'two');
-} {
- {INSERT t1 0 X. {} {t one t two}}
-}
+ do_iterator_test 1.$tn.1 t1 {
+ INSERT INTO t1 VALUES('one', 'two');
+ } {
+ {INSERT t1 0 X. {} {t one t two}}
+ }
-do_iterator_test 1.2 t1 {
- UPDATE t1 SET b='three'
-} {
- {UPDATE t1 0 X. {t one t two} {{} {} t three}}
+ do_iterator_test 1.$tn.2 t1 {
+ UPDATE t1 SET b='three'
+ } {
+ {UPDATE t1 0 X. {t one t two} {{} {} t three}}
+ }
+
+ do_iterator_test 1.$tn.3 t1 {
+ REPLACE INTO t1 VALUES('one', 'four');
+ } {
+ {UPDATE t1 0 X. {t one t three} {{} {} t four}}
+ }
+
+ do_iterator_test 1.$tn.4 t1 {
+ DELETE FROM t1;
+ } {
+ {DELETE t1 0 X. {t one t four} {}}
+ }
}
-do_iterator_test 1.3 t1 {
- DELETE FROM t1;
+foreach {tn wo} {
+ 1 ""
+ 2 "WITHOUT ROWID"
} {
- {DELETE t1 0 X. {t one t three} {}}
+ reset_db
+
+ do_execsql_test 2.$tn.0 "CREATE TABLE t1(a INTEGER PRIMARY KEY, b) $wo ;"
+
+ do_iterator_test 1.1 t1 {
+ INSERT INTO t1 VALUES(1, 'two');
+ } {
+ {INSERT t1 0 X. {} {i 1 t two}}
+ }
+
+ do_iterator_test 2.$tn.2 t1 {
+ UPDATE t1 SET b='three'
+ } {
+ {UPDATE t1 0 X. {i 1 t two} {{} {} t three}}
+ }
+
+ do_iterator_test 2.$tn.3 t1 {
+ REPLACE INTO t1 VALUES(1, 'four');
+ } {
+ {UPDATE t1 0 X. {i 1 t three} {{} {} t four}}
+ }
+
+ do_iterator_test 2.$tn.4 t1 {
+ DELETE FROM t1;
+ } {
+ {DELETE t1 0 X. {i 1 t four} {}}
+ }
}
finish_test
+
diff --git a/chromium/third_party/sqlite/src/ext/session/sqlite3session.c b/chromium/third_party/sqlite/src/ext/session/sqlite3session.c
index 2e9a8ba7278..012473599b4 100644
--- a/chromium/third_party/sqlite/src/ext/session/sqlite3session.c
+++ b/chromium/third_party/sqlite/src/ext/session/sqlite3session.c
@@ -363,7 +363,7 @@ static void sessionPutI64(u8 *aBuf, sqlite3_int64 i){
static int sessionSerializeValue(
u8 *aBuf, /* If non-NULL, write serialized value here */
sqlite3_value *pValue, /* Value to serialize */
- int *pnWrite /* IN/OUT: Increment by bytes written */
+ sqlite3_int64 *pnWrite /* IN/OUT: Increment by bytes written */
){
int nByte; /* Size of serialized value in bytes */
@@ -904,7 +904,7 @@ static int sessionGrowHash(int bPatchset, SessionTable *pTab){
SessionChange **apNew;
int nNew = (pTab->nChange ? pTab->nChange : 128) * 2;
- apNew = (SessionChange **)sqlite3_malloc(sizeof(SessionChange *) * nNew);
+ apNew = (SessionChange **)sqlite3_malloc64(sizeof(SessionChange *) * nNew);
if( apNew==0 ){
if( pTab->nChange==0 ){
return SQLITE_ERROR;
@@ -970,7 +970,7 @@ static int sessionTableInfo(
char *zPragma;
sqlite3_stmt *pStmt;
int rc;
- int nByte;
+ sqlite3_int64 nByte;
int nDbCol = 0;
int nThis;
int i;
@@ -1013,7 +1013,7 @@ static int sessionTableInfo(
if( rc==SQLITE_OK ){
nByte += nDbCol * (sizeof(const char *) + sizeof(u8) + 1);
- pAlloc = sqlite3_malloc(nByte);
+ pAlloc = sqlite3_malloc64(nByte);
if( pAlloc==0 ){
rc = SQLITE_NOMEM;
}
@@ -1154,7 +1154,7 @@ static void sessionPreupdateOneChange(
int iHash;
int bNull = 0;
int rc = SQLITE_OK;
- SessionStat1Ctx stat1 = {0};
+ SessionStat1Ctx stat1 = {{0,0,0,0,0},0};
if( pSession->rc ) return;
@@ -1211,7 +1211,7 @@ static void sessionPreupdateOneChange(
** this is an SQLITE_UPDATE or SQLITE_DELETE), or just the PK
** values (if this is an INSERT). */
SessionChange *pChange; /* New change object */
- int nByte; /* Number of bytes to allocate */
+ sqlite3_int64 nByte; /* Number of bytes to allocate */
int i; /* Used to iterate through columns */
assert( rc==SQLITE_OK );
@@ -1236,7 +1236,7 @@ static void sessionPreupdateOneChange(
}
/* Allocate the change object */
- pChange = (SessionChange *)sqlite3_malloc(nByte);
+ pChange = (SessionChange *)sqlite3_malloc64(nByte);
if( !pChange ){
rc = SQLITE_NOMEM;
goto error_out;
@@ -1680,7 +1680,7 @@ int sqlite3session_create(
*ppSession = 0;
/* Allocate and populate the new session object. */
- pNew = (sqlite3_session *)sqlite3_malloc(sizeof(sqlite3_session) + nDb + 1);
+ pNew = (sqlite3_session *)sqlite3_malloc64(sizeof(sqlite3_session) + nDb + 1);
if( !pNew ) return SQLITE_NOMEM;
memset(pNew, 0, sizeof(sqlite3_session));
pNew->db = db;
@@ -1799,7 +1799,7 @@ int sqlite3session_attach(
if( !pTab ){
/* Allocate new SessionTable object. */
- pTab = (SessionTable *)sqlite3_malloc(sizeof(SessionTable) + nName + 1);
+ pTab = (SessionTable *)sqlite3_malloc64(sizeof(SessionTable) + nName + 1);
if( !pTab ){
rc = SQLITE_NOMEM;
}else{
@@ -1859,7 +1859,7 @@ static int sessionBufferGrow(SessionBuffer *p, int nByte, int *pRc){
static void sessionAppendValue(SessionBuffer *p, sqlite3_value *pVal, int *pRc){
int rc = *pRc;
if( rc==SQLITE_OK ){
- int nByte = 0;
+ sqlite3_int64 nByte = 0;
rc = sessionSerializeValue(0, pVal, &nByte);
sessionBufferGrow(p, nByte, &rc);
if( rc==SQLITE_OK ){
@@ -2735,7 +2735,7 @@ static int sessionValueSetStr(
** argument to sqlite3ValueSetStr() and have the copy created
** automatically. But doing so makes it difficult to detect any OOM
** error. Hence the code to create the copy externally. */
- u8 *aCopy = sqlite3_malloc(nData+1);
+ u8 *aCopy = sqlite3_malloc64((sqlite3_int64)nData+1);
if( aCopy==0 ) return SQLITE_NOMEM;
memcpy(aCopy, aData, nData);
sqlite3ValueSetStr(pVal, nData, (char*)aCopy, enc, sqlite3_free);
@@ -3348,7 +3348,7 @@ static int sessionChangesetInvert(
int iCol;
if( 0==apVal ){
- apVal = (sqlite3_value **)sqlite3_malloc(sizeof(apVal[0])*nCol*2);
+ apVal = (sqlite3_value **)sqlite3_malloc64(sizeof(apVal[0])*nCol*2);
if( 0==apVal ){
rc = SQLITE_NOMEM;
goto finished_invert;
@@ -4621,7 +4621,7 @@ static int sessionChangeMerge(
int rc = SQLITE_OK;
if( !pExist ){
- pNew = (SessionChange *)sqlite3_malloc(sizeof(SessionChange) + nRec);
+ pNew = (SessionChange *)sqlite3_malloc64(sizeof(SessionChange) + nRec);
if( !pNew ){
return SQLITE_NOMEM;
}
@@ -4654,8 +4654,8 @@ static int sessionChangeMerge(
if( pExist->op==SQLITE_DELETE && pExist->bIndirect ){
*ppNew = pExist;
}else{
- int nByte = nRec + pExist->nRecord + sizeof(SessionChange);
- pNew = (SessionChange*)sqlite3_malloc(nByte);
+ sqlite3_int64 nByte = nRec + pExist->nRecord + sizeof(SessionChange);
+ pNew = (SessionChange*)sqlite3_malloc64(nByte);
if( pNew==0 ){
rc = SQLITE_NOMEM;
}else{
@@ -4715,14 +4715,14 @@ static int sessionChangeMerge(
assert( pNew==0 );
}else{
u8 *aExist = pExist->aRecord;
- int nByte;
+ sqlite3_int64 nByte;
u8 *aCsr;
/* Allocate a new SessionChange object. Ensure that the aRecord[]
** buffer of the new object is large enough to hold any record that
** may be generated by combining the input records. */
nByte = sizeof(SessionChange) + pExist->nRecord + nRec;
- pNew = (SessionChange *)sqlite3_malloc(nByte);
+ pNew = (SessionChange *)sqlite3_malloc64(nByte);
if( !pNew ){
sqlite3_free(pExist);
return SQLITE_NOMEM;
@@ -4828,7 +4828,7 @@ static int sessionChangesetToHash(
if( !pTab ){
SessionTable **ppTab;
- pTab = sqlite3_malloc(sizeof(SessionTable) + nCol + nNew+1);
+ pTab = sqlite3_malloc64(sizeof(SessionTable) + nCol + nNew+1);
if( !pTab ){
rc = SQLITE_NOMEM;
break;
diff --git a/chromium/third_party/sqlite/src/ext/session/sqlite3session.h b/chromium/third_party/sqlite/src/ext/session/sqlite3session.h
index c93d0ecdaf4..d145733dc27 100644
--- a/chromium/third_party/sqlite/src/ext/session/sqlite3session.h
+++ b/chromium/third_party/sqlite/src/ext/session/sqlite3session.h
@@ -548,7 +548,7 @@ int sqlite3changeset_next(sqlite3_changeset_iter *pIter);
** sqlite3changeset_next() is called on the iterator or until the
** conflict-handler function returns. If pnCol is not NULL, then *pnCol is
** set to the number of columns in the table affected by the change. If
-** pbIncorrect is not NULL, then *pbIndirect is set to true (1) if the change
+** pbIndirect is not NULL, then *pbIndirect is set to true (1) if the change
** is an indirect change, or false (0) otherwise. See the documentation for
** [sqlite3session_indirect()] for a description of direct and indirect
** changes. Finally, if pOp is not NULL, then *pOp is set to one of
diff --git a/chromium/third_party/sqlite/src/main.mk b/chromium/third_party/sqlite/src/main.mk
index b460a58d9a9..ee8ebbb92f5 100644
--- a/chromium/third_party/sqlite/src/main.mk
+++ b/chromium/third_party/sqlite/src/main.mk
@@ -371,6 +371,7 @@ TESTSRC += \
$(TOP)/ext/misc/nextchar.c \
$(TOP)/ext/misc/normalize.c \
$(TOP)/ext/misc/percentile.c \
+ $(TOP)/ext/misc/prefixes.c \
$(TOP)/ext/misc/regexp.c \
$(TOP)/ext/misc/remember.c \
$(TOP)/ext/misc/series.c \
@@ -513,7 +514,8 @@ FUZZDATA = \
$(TOP)/test/fuzzdata4.db \
$(TOP)/test/fuzzdata5.db \
$(TOP)/test/fuzzdata6.db \
- $(TOP)/test/fuzzdata7.db
+ $(TOP)/test/fuzzdata7.db \
+ $(TOP)/test/fuzzdata8.db
# Standard options to testfixture
#
@@ -534,6 +536,11 @@ FUZZERSHELL_OPT = -DSQLITE_ENABLE_JSON1
FUZZCHECK_OPT = -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_MEMSYS5
FUZZCHECK_OPT += -DSQLITE_MAX_MEMORY=50000000
FUZZCHECK_OPT += -DSQLITE_PRINTF_PRECISION_LIMIT=1000
+FUZZCHECK_OPT += -DSQLITE_ENABLE_DESERIALIZE
+FUZZCHECK_OPT += -DSQLITE_ENABLE_FTS4
+FUZZCHECK_OPT += -DSQLITE_ENABLE_RTREE
+FUZZCHECK_OPT += -DSQLITE_ENABLE_GEOPOLY
+FUZZCHECK_OPT += -DSQLITE_ENABLE_DBSTAT_VTAB
DBFUZZ_OPT =
KV_OPT = -DSQLITE_THREADSAFE=0 -DSQLITE_DIRECT_OVERFLOW_READ
ST_OPT = -DSQLITE_THREADSAFE=0
@@ -578,6 +585,20 @@ dbfuzz$(EXE): $(TOP)/test/dbfuzz.c sqlite3.c sqlite3.h
$(DBFUZZ_OPT) $(TOP)/test/dbfuzz.c sqlite3.c \
$(TLIBS) $(THREADLIB)
+DBFUZZ2_OPTS = \
+ -DSQLITE_THREADSAFE=0 \
+ -DSQLITE_OMIT_LOAD_EXTENSION \
+ -DSQLITE_ENABLE_DESERIALIZE \
+ -DSQLITE_DEBUG \
+ -DSQLITE_ENABLE_DBSTAT_VTAB \
+ -DSQLITE_ENABLE_RTREE \
+ -DSQLITE_ENABLE_FTS4 \
+ -DSQLITE_ENABLE_FTS5
+
+dbfuzz2$(EXE): $(TOP)/test/dbfuzz2.c sqlite3.c sqlite3.h
+ $(TCCX) -I. -g -O0 -DSTANDALONE -o dbfuzz2$(EXE) \
+ $(DBFUZZ2_OPTS) $(TOP)/test/dbfuzz2.c sqlite3.c $(TLIBS) $(THREADLIB)
+
fuzzcheck$(EXE): $(TOP)/test/fuzzcheck.c sqlite3.c sqlite3.h $(TOP)/test/ossfuzz.c
$(TCCX) -o fuzzcheck$(EXE) -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION \
-DSQLITE_ENABLE_MEMSYS5 $(FUZZCHECK_OPT) -DSQLITE_OSS_FUZZ \
@@ -723,6 +744,7 @@ SHELL_SRC = \
$(TOP)/ext/expert/sqlite3expert.c \
$(TOP)/ext/expert/sqlite3expert.h \
$(TOP)/ext/misc/zipfile.c \
+ $(TOP)/ext/misc/memtrace.c \
$(TOP)/src/test_windirent.c
shell.c: $(SHELL_SRC) $(TOP)/tool/mkshellc.tcl
@@ -981,6 +1003,9 @@ $(TEST_EXTENSION): $(TOP)/src/test_loadext.c
extensiontest: testfixture$(EXE) $(TEST_EXTENSION)
./testfixture$(EXE) $(TOP)/test/loadext.test
+dbtotxt$(EXE): $(TOP)/tool/dbtotxt.c
+ $(TCC) -o dbtotxt$(EXE) $(TOP)/tool/dbtotxt.c
+
showdb$(EXE): $(TOP)/tool/showdb.c sqlite3.o
$(TCC) -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION -o showdb$(EXE) \
$(TOP)/tool/showdb.c sqlite3.o $(THREADLIB)
@@ -1000,6 +1025,10 @@ showwal$(EXE): $(TOP)/tool/showwal.c sqlite3.o
showshm$(EXE): $(TOP)/tool/showshm.c
$(TCC) -o showshm$(EXE) $(TOP)/tool/showshm.c
+index_usage$(EXE): $(TOP)/tool/index_usage.c sqlite3.o
+ $(TCC) -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_DEPRECATED $(SHELL_OPTS) -o index_usage$(EXE) \
+ $(TOP)/tool/index_usage.c sqlite3.o $(THREADLIB)
+
changeset$(EXE): $(TOP)/ext/session/changeset.c sqlite3.o
$(TCC) -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION -o changeset$(EXE) \
$(TOP)/ext/session/changeset.c sqlite3.o $(THREADLIB)
diff --git a/chromium/third_party/sqlite/src/manifest b/chromium/third_party/sqlite/src/manifest
index bb8f3728c11..65f29c943fc 100644
--- a/chromium/third_party/sqlite/src/manifest
+++ b/chromium/third_party/sqlite/src/manifest
@@ -1,12 +1,12 @@
-C Version\s3.26.0
-D 2018-12-01T12:34:55.966
+C Version\s3.27.1
+D 2019-02-08T13:17:39.690
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
-F Makefile.in a050c8670ea0d7b37b2192306cbb50d392acd9902b84e9b56f3444d006f97a6c
+F Makefile.in 178d8eb6840771149cee40b322d1b3be30d330198c522c903c1b66fb5a1bfca4
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
-F Makefile.msc 0d6831ff7951b302e888d86d4c469e2ec3c22f59eba4118b8c38d5a51d9e2d4f
+F Makefile.msc 5df60c70edb157feb2148a14c687551969599bd065875a0b959b6b139721ca72
F README.md 377233394b905d3b2e2b33741289e093bc93f2e7adbe00923b2c5958c9a9edee
-F VERSION 654da1d4053fb09ffc33a3910e6d427182a7dcdc67e934fa83de2849ac83fccb
+F VERSION 15b2d421b2265aad451c0493066c1c31a511a72c5153bb4e9d5f62adbc12134c
F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50
F art/sqlite370.eps aa97a671332b432a54e1d74ff5e8775be34200c2
F art/sqlite370.ico af56c1d00fee7cd4753e8631ed60703ed0fc6e90
@@ -14,7 +14,7 @@ F art/sqlite370.jpg d512473dae7e378a67e28ff96a34da7cb331def2
F autoconf/INSTALL 83e4a25da9fd053c7b3665eaaaf7919707915903
F autoconf/Makefile.am e14b629addaa1ce372b72043f28f40de2e32b7e211b6e0fc18dbb87989197e40
F autoconf/Makefile.fallback 22fe523eb36dfce31e0f6349f782eb084e86a5620b2b0b4f84a2d6133f53f5ac
-F autoconf/Makefile.msc 9e73d9abaadb7a4951ddd0e947c5c791770f23bb1e04bfa50b43c01bee0575f2
+F autoconf/Makefile.msc ee8ab2b6b5d712f68acc4c186e3fad7b831b87a2b118e0a123043ea8a2c8b016
F autoconf/README.first 6c4f34fe115ff55d4e8dbfa3cecf04a0188292f7
F autoconf/README.txt 4f04b0819303aabaa35fff5f7b257fb0c1ef95f1
F autoconf/configure.ac 308de24343e76ecfbe9a67f8fcd4c5216b790d230c5d9ce10210b7d5965d6192
@@ -33,7 +33,7 @@ F autoconf/tea/win/rules.vc c511f222b80064096b705dbeb97060ee1d6b6d63
F config.guess 226d9a188c6196f3033ffc651cbc9dcee1a42977
F config.h.in 6376abec766e9a0785178b1823b5a587e9f1ccbc
F config.sub 9ebe4c3b3dab6431ece34f16828b594fb420da55
-F configure 5811ffcd4866902d1706dcf8e0527f89165ec52859659942c9649bb1d3e4cc7b x
+F configure 2b0310f5ddb82f4e2c524c0bc7bacf480b0ac21bf05b543d7e72e2682772eaac x
F configure.ac 3552d3aecade98a9d4b64bceb48ffb7726cbc85902efde956812942f060fbd0a
F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad
F doc/F2FS.txt c1d4a0ae9711cfe0e1d8b019d154f1c29e0d3abfe820787ba1e9ed7691160fcd
@@ -46,7 +46,7 @@ F ext/async/sqlite3async.c 0f3070cc3f5ede78f2b9361fb3b629ce200d7d74
F ext/async/sqlite3async.h f489b080af7e72aec0e1ee6f1d98ab6cf2e4dcef
F ext/expert/README.md b321c2762bb93c18ea102d5a5f7753a4b8bac646cb392b3b437f633caf2020c3
F ext/expert/expert.c d548d603a4cc9e61f446cc179c120c6713511c413f82a4a32b1e1e69d3f086a4
-F ext/expert/expert1.test 333d037021c901322f9afc4a5687648ea23d56f1a0a079358a390664babf01be
+F ext/expert/expert1.test 358e416877a5693fb99d5514f5d88452b5239dc2196b74e0e926718502faef6d
F ext/expert/sqlite3expert.c 3da865f2286433588260f41e796422c611bceaca3a0bbf9139a619cf7d062c19
F ext/expert/sqlite3expert.h af6354f8ee5c9e025024e63fec3bd640a802afcc3099a44d804752cf0791d811
F ext/expert/test_expert.c d56c194b769bdc90cf829a14c9ecbc1edca9c850b837a4d0b13be14095c32a72
@@ -80,55 +80,55 @@ F ext/fts3/README.content fdc666a70d5257a64fee209f97cf89e0e6e32b51
F ext/fts3/README.syntax a19711dc5458c20734b8e485e75fb1981ec2427a
F ext/fts3/README.tokenizers e0a8b81383ea60d0334d274fadf305ea14a8c314
F ext/fts3/README.txt 8c18f41574404623b76917b9da66fcb0ab38328d
-F ext/fts3/fts3.c 65b8489e35da23b127992c6dd6cfd382a486f8c87bf26dfa72876efe46e551bb
+F ext/fts3/fts3.c 5da1329ccf66b6d597dfb16b1f81aa204133c1ec96117d82a59c20126f483b17
F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe
-F ext/fts3/fts3Int.h 3378157f383540857a466420b8279626204434c3eb0dc948ad9bcd3991fc41f5
-F ext/fts3/fts3_aux.c e9b465f8469acc2cd700a90c0242912a3202e4e4e15df72d7db7f1e3a2222c85
-F ext/fts3/fts3_expr.c 3b1dbceddd8622599f3cc2626897667fe40487aaa1676707d6c37ec5a8422fc1
-F ext/fts3/fts3_hash.c 29b986e43f4e9dd40110eafa377dc0d63c422c60
+F ext/fts3/fts3Int.h 74384e28b778a057f1467529715668b98f3f12f52eeb564fd6ae1e894125c00c
+F ext/fts3/fts3_aux.c 96708c8b3a7d9b8ca1b68ea2b7e503e283f20e95f145becadedfad096dbd0f34
+F ext/fts3/fts3_expr.c b132af223e90e35b9f9efa9fe63d6ae737d34153a3b6066736086df8abc78a1f
+F ext/fts3/fts3_hash.c 8b6e31bfb0844c27dc6092c2620bdb1fca17ed613072db057d96952c6bdb48b7
F ext/fts3/fts3_hash.h 39cf6874dc239d6b4e30479b1975fe5b22a3caaf
-F ext/fts3/fts3_icu.c deb46f7020d87ea7a14a433fb7a7f4bef42a9652
+F ext/fts3/fts3_icu.c 305ce7fb6036484085b5556a9c8e62acdc7763f0f4cdf5fd538212a9f3720116
F ext/fts3/fts3_porter.c 3565faf04b626cddf85f03825e86056a4562c009
-F ext/fts3/fts3_snippet.c 68ae118b0f834ea53d2b89e4087fc0f0b8c4ee4e
-F ext/fts3/fts3_term.c 9b8065cc70ad514fcc25a7b099ddab8b5333f724dedd57184b7e79238e2b2a39
-F ext/fts3/fts3_test.c 79f2a7fbb3f672fa032e5a432ca274ea3ee93c34
-F ext/fts3/fts3_tokenize_vtab.c a47c2a33de6db00816704315ac0a9afdfa1c71fa5b99f79171c0f7b30861f784
+F ext/fts3/fts3_snippet.c ac1f8945375d07076b7178de1fe549982e6ae6f050095e7f7e400ec4448f31df
+F ext/fts3/fts3_term.c 12f7b2318f1254e6cc46dd306e5f2ac5b00b06d6761f5cae09fee5e1817cc32a
+F ext/fts3/fts3_test.c b6e9f3fd7155cb388c6bc203fb24817a721fb61d9ce28810c73fcfda8c16fda6
+F ext/fts3/fts3_tokenize_vtab.c 969c132816b6f46ee2c7efafd2547a9bfd50b0aac3f8cef3f2dca2cbd90639c7
F ext/fts3/fts3_tokenizer.c a22bf311a71f3efa9d7012d8cc48fc9b0f3dace7
F ext/fts3/fts3_tokenizer.h 64c6ef6c5272c51ebe60fc607a896e84288fcbc3
F ext/fts3/fts3_tokenizer1.c 5c98225a53705e5ee34824087478cf477bdb7004
-F ext/fts3/fts3_unicode.c 525a3bd9a7564603c5c061b7de55403a565307758a94600e8a2f6b00d1c40d9d
-F ext/fts3/fts3_unicode2.c cc04fc672bfd42b1e650398cb0bf71f64f9aae032cfe75bbcfe75b9cf966029c
-F ext/fts3/fts3_write.c a85bc4885fde7f1b44c9de013b62f7cd3332dc59e208053d878729b1d04745bc
+F ext/fts3/fts3_unicode.c 4b9af6151c29b35ed09574937083cece7c31e911f69615e168a39677569b684d
+F ext/fts3/fts3_unicode2.c 416eb7e1e81142703520d284b768ca2751d40e31fa912cae24ba74860532bf0f
+F ext/fts3/fts3_write.c 45cbe0b06221f5debefe37f8f9882cf0401592668cb76624a64c0f3f185115de
F ext/fts3/fts3speed.tcl b54caf6a18d38174f1a6e84219950d85e98bb1e9
F ext/fts3/mkfts3amal.tcl 252ecb7fe6467854f2aa237bf2c390b74e71f100
F ext/fts3/tool/fts3cov.sh c331d006359456cf6f8f953e37f2b9c7d568f3863f00bb5f7eb87fea4ac01b73
F ext/fts3/tool/fts3view.c 202801a2056995b763864d60c2dee744d46f1677
F ext/fts3/unicode/CaseFolding.txt 8c678ca52ecc95e16bc7afc2dbf6fc9ffa05db8c
F ext/fts3/unicode/UnicodeData.txt cd07314edb62d49fde34debdaf92fa2aa69011e7
-F ext/fts3/unicode/mkunicode.tcl 0069320b64db6ee269c5e95f1f150d070fbf0a863fc7b3549d7e52bd068fb118
-F ext/fts3/unicode/parseunicode.tcl 024ae0bdd96309d7b8fc479148191e9b3001dc74017a3f65f9a27de3b3ff968b
+F ext/fts3/unicode/mkunicode.tcl 49499f7964504438e2b04cca0627827945bb2499154e2d3ec216b22d20b969ae
+F ext/fts3/unicode/parseunicode.tcl a981bd6466d12dd17967515801c3ff23f74a281be1a03cf1e6f52a6959fc77eb
F ext/fts5/extract_api_docs.tcl a36e54ec777172ddd3f9a88daf593b00848368e0
-F ext/fts5/fts5.h 5edc74ca603d71284d475886e6e91b5c5cf2e8e93e9ba3a36ba2f2440ee97948
-F ext/fts5/fts5Int.h 39f12034b598df4e0f59bbe6cf03af03a905a534b04f182d155641a04e1eb797
-F ext/fts5/fts5_aux.c ca666a3bbe07c5a3bbe9fffaea19c935a1efaf337333e28bad7bdd1971ffd093
-F ext/fts5/fts5_buffer.c 1dd1ec0446b3acfc2d7d407eb894762a461613e2695273f48e449bfd13e973ff
-F ext/fts5/fts5_config.c 5af9c360e99669d29f06492c370892394aba0857
-F ext/fts5/fts5_expr.c 5aef080ba3c8947e22f38ce1ff9fe548e4a740e72b77241f35ed941ae128d2c7
-F ext/fts5/fts5_hash.c 32be400cf761868c9db33efe81a06eb19a17c5402ad477ee9efb51301546dd55
-F ext/fts5/fts5_index.c baf3ad4451d32d35c2bd692ee4a81235ca7f26bd6f7613f7f73505474c33bbf2
-F ext/fts5/fts5_main.c 287a1a56580df304d7fa2fc1890f85b9cb6ac6b9e7c8af7dfa2151528db4b059
-F ext/fts5/fts5_storage.c 4bec8a1b3905978b22a67bca5f4a3cfdb94af234cf51efb36f4f2d733d278634
+F ext/fts5/fts5.h fed314270c1a61de3a0e373b11c2f8228b1c76ce59447dd96d0b6fae7d66399b
+F ext/fts5/fts5Int.h 0b002fc71ea705d2c4ec66a63ecd38a2c11127e5b52239b5d71d1dd28309fc19
+F ext/fts5/fts5_aux.c afe8c2394cf6de2a48f278442f4f4342365bf99a5983709ef8e6955c2cf4daf9
+F ext/fts5/fts5_buffer.c 2e750cd4c0d456d4e1a8dcc649382708422b535dc32b375fd3d3306fb9727046
+F ext/fts5/fts5_config.c eeec97cb0237991e7fa3bbae07b5cc354e3f238b661200c11228fe167c18f882
+F ext/fts5/fts5_expr.c 188d1dca5a262a0708efc5deb809f1aa6ecea4158986a439d2670cfe72d10b65
+F ext/fts5/fts5_hash.c d415f5ad332b051f0ade564bcf1762c4467cc49b2ba8ea5873d8744c705d8d42
+F ext/fts5/fts5_index.c ffff7e8d41594256cacf7b32072f8bc06478a86026196a7eb084450065df8d92
+F ext/fts5/fts5_main.c 95d63bbe6075955961e56878c3a8705dc475c2b17f5c767f7b8af14093ae614b
+F ext/fts5/fts5_storage.c 57e3f2b1a612961a27c944d6b8821028ec5fdb541d7e6b841785003ac3b0b43a
F ext/fts5/fts5_tcl.c 39bcbae507f594aad778172fa914cad0f585bf92fd3b078c686e249282db0d95
-F ext/fts5/fts5_test_mi.c 65864ba1e5c34a61d409c4c587e0bbe0466eb4f8f478d85dc42a92caad1338e6
-F ext/fts5/fts5_test_tok.c 80de1a4b1a3caa216c3be8862440f0117a8357dd9b7cfc5a2a2ce11fe6eb64ae
-F ext/fts5/fts5_tokenize.c ebd13d034f3dc7c841e1c32c364a4fca5cc2e05a0b91682a93fa1e6defcd4292
-F ext/fts5/fts5_unicode2.c 543cf0987c27ad59e5a7a6222480b917b5431009b7b139027c9581a63e39e37e
-F ext/fts5/fts5_varint.c a5aceacda04dafcbae725413d7a16818ecd65738
-F ext/fts5/fts5_vocab.c fbe38044889b2d2d99babeeef239c620fb0332bb928a84506ac748d81500b354
+F ext/fts5/fts5_test_mi.c 08c11ec968148d4cb4119d96d819f8c1f329812c568bac3684f5464be177d3ee
+F ext/fts5/fts5_test_tok.c f96c6e193c466711d6d7828d5f190407fe7ab897062d371426dd3036f01258e7
+F ext/fts5/fts5_tokenize.c 4d904c237707de8fbb8ab98d24d5c55d47204a3f1f35895d8a53a5327079b32c
+F ext/fts5/fts5_unicode2.c d8a1528c9a19f79b843c486e5e64bff17d667791ae7f658e11131ebac4b33c59
+F ext/fts5/fts5_varint.c e64d2113f6e1bfee0032972cffc1207b77af63319746951bf1d09885d1dadf80
+F ext/fts5/fts5_vocab.c 906dff069840347e68f654b12ca60a53a27cd1780daf155fbe7dd331f27c2329
F ext/fts5/fts5parse.y eb526940f892ade5693f22ffd6c4f2702543a9059942772526eac1fde256bb05
F ext/fts5/mkportersteps.tcl 5acf962d2e0074f701620bb5308155fa1e4a63ba
F ext/fts5/test/fts5_common.tcl b01c584144b5064f30e6c648145a2dd6bc440841
-F ext/fts5/test/fts5aa.test 840081efaee97f5ec570146bbdd79cfdfaea0ab303de3d5037b6d6c78b42ccdd
+F ext/fts5/test/fts5aa.test 1706f816308e5855fe493be85aa0fd28eea78fb163ab1d60a20bca4f0ebcf68d
F ext/fts5/test/fts5ab.test 9205c839332c908aaad2b01ab8670ece8b161e8f2ec8a9fabf18ca9385880bb7
F ext/fts5/test/fts5ac.test a7aa7e1fefc6e1918aa4d3111d5c44a09177168e962c5fd2cca9620de8a7ed6d
F ext/fts5/test/fts5ad.test e8cf959dfcd57c8e46d6f5f25665686f3b6627130a9a981371dafdf6482790de
@@ -136,9 +136,9 @@ F ext/fts5/test/fts5ae.test 1142d16d9cc193894dc13cc8f9c7a8a21411ac61b5567a878514
F ext/fts5/test/fts5af.test 724247405b13f8f06cc6ce464dc4f152dc5dd4e86b12c2099685d8f19747bf7b
F ext/fts5/test/fts5ag.test 7816f25a0707578f08145ab539fc0ca025f8951e788b28a6a18a06b2099469dd
F ext/fts5/test/fts5ah.test 27b5a33bfd0363ca8a4dc659e6e2a5df3dea1c3c5b04bc51ca6aeb1277bd9b21
-F ext/fts5/test/fts5ai.test d837c42249c0d8ad1a2912270e22cf2f303790a611f85c0be3a58e42a3696e3d
+F ext/fts5/test/fts5ai.test bc97e4758cc93e06bf851d61c98fdf4e8b8f8315ee28a84fb15f916360856414
F ext/fts5/test/fts5aj.test 745020852d85f5dd49d11cb7ad11d3cc6dafc4fe6d6d24bc0875ac8f43ee4149
-F ext/fts5/test/fts5ak.test 0d41cbf04e70249c84670e1782aa8972e4f67d91c9bc6205d0ba7c34e159481b
+F ext/fts5/test/fts5ak.test fc3595f8e6873bb86d70c9bd4b67d0413ce577bd4793c39a2b60a7b8825b60a6
F ext/fts5/test/fts5al.test 00c4c1c6a1366b73aa48ce2068c634520867c3cf7f5d1676ebbb775ee1f35734
F ext/fts5/test/fts5alter.test 5565f7e4605512b69171ac18ca84398603f9f6456dbe377beeca97e83cc242cd
F ext/fts5/test/fts5auto.test 78989e6527ce69c9eddbef7392fea5c10b0010cd2b2ae68eec7bc869c471e691
@@ -147,6 +147,7 @@ F ext/fts5/test/fts5auxdata.test eacc97ff04892f1a5f3d4df5a73f8bcbc3955ea1d12c9f2
F ext/fts5/test/fts5bigpl.test 6466c89b38439f0aba26ac09e232a6b963f29b1cbe1304f6a664fe1e7a8f5fd3
F ext/fts5/test/fts5bigtok.test 541119e616c637caea925a8c028c37c2c29e94383e00aa2f9198d530724b6e36
F ext/fts5/test/fts5cat.test daba0b80659460b0cb60bd1f40b402478a761fe7ea414c3c94c2be25568cc33a
+F ext/fts5/test/fts5circref.test f880dfd0d99f6fb73b88ccacb0927d18e833672fd906cc47d6b4e529419eaa62
F ext/fts5/test/fts5colset.test a30473451321bbf0b6218af62e96b4ae5fa99931cfdb210b5ecc804623b30f75
F ext/fts5/test/fts5columnsize.test 45459ce4dd9fd853b6044cdc9674921bff89e3d840f348ca8c1630f9edbf5482
F ext/fts5/test/fts5config.test 60094712debc59286c59aef0e6cf511c37d866802776a825ce437d26afe0817f
@@ -155,7 +156,7 @@ F ext/fts5/test/fts5connect.test 08030168fc96fc278fa81f28654fb7e90566f33aff269c0
F ext/fts5/test/fts5content.test 688d5ac7af194ebc67495daea76a69e3cd5480122c2320e72d41241b423b4116
F ext/fts5/test/fts5corrupt.test 77ae6f41a7eba10620efb921cf7dbe218b0ef232b04519deb43581cb17a57ebe
F ext/fts5/test/fts5corrupt2.test 7453752ba12ce91690c469a6449d412561cc604b1dec994e16ab132952e7805f
-F ext/fts5/test/fts5corrupt3.test ff9aee403611461e2619d2217c0d7d101a9c0179277c13c8a89516d7cf0dda43
+F ext/fts5/test/fts5corrupt3.test 4c506a138797d23049bf08552b4571f5beb5138ab7b3329b9210fe5aac8796d2
F ext/fts5/test/fts5delete.test cbf87e3b8867c4d5cfcaed975c7475fd3f99d072bce2075fcedf43d1f82af775
F ext/fts5/test/fts5detail.test 31b240dbf6d44ac3507e2f8b65f29fdc12465ffd531212378c7ce1066766f54e
F ext/fts5/test/fts5determin.test 1b77879b2ae818b5b71c859e534ee334dac088b7cf3ff3bf76a2c82b1c788d11
@@ -180,6 +181,7 @@ F ext/fts5/test/fts5full.test 49b565da02918c06e58f51f0b953b0302b96f155aa68baba24
F ext/fts5/test/fts5fuzz1.test 238d8c45f3b81342aa384de3e581ff2fa330bf922a7b69e484bbc06051a1080e
F ext/fts5/test/fts5hash.test a4cf51acad99bfc43c16fb74f9d22495dc221ae0701fc5e908ca963a9b26a02b
F ext/fts5/test/fts5integrity.test 4317561cd25eca7df16aa1f7d1a700ee958059fa639785f94aba0a84df9ab17b
+F ext/fts5/test/fts5interrupt.test 09613247b273a99889808ef852898177e671406fe71fdde7ea00e78ea283d227
F ext/fts5/test/fts5lastrowid.test be98fe3e03235296585b72daad7aed5717ba0062bae5e5c18dd6e04e194c6b28
F ext/fts5/test/fts5leftjoin.test c0b4cafb9661379e576dc4405c0891d8fcc2782680740513c4d1fc114b43d4ad
F ext/fts5/test/fts5matchinfo.test 79129ff6c9a2d86943b287a5a8caa7ee639f6dcf004d8975d15c279374e82e35
@@ -206,16 +208,17 @@ F ext/fts5/test/fts5synonym.test 1651815b8008de170e8e600dcacc17521d765482ea8f074
F ext/fts5/test/fts5synonym2.test b54cce5c34ec08ed616f646635538ae82e34a0e28f947ec60b6fadbc4b3fb17a
F ext/fts5/test/fts5tok1.test ce6551e41ff56f30b69963577324624733bed0d1753589f06120d664d9cd45c9
F ext/fts5/test/fts5tok2.test dcacb32d4a2a3f0dd3215d4a3987f78ae4be21a2
-F ext/fts5/test/fts5tokenizer.test 6aeb5e8061ffc0ff9a5299f27beaee3b2b4b8b336d4f107262bca338bea8f8e9
+F ext/fts5/test/fts5tokenizer.test ac3c9112b263a639fb0508ae73a3ee886bf4866d2153771a8e8a20c721305a43
+F ext/fts5/test/fts5umlaut.test a42fe2fe6387c40c49ab27ccbd070e1ae38e07f38d05926482cc0bccac9ad602
F ext/fts5/test/fts5unicode.test 17056f4efe6b0a5d4f41fdf7a7dc9af2873004562eaa899d40633b93dc95f5a9
F ext/fts5/test/fts5unicode2.test 9b3df486de05fb4bde4aa7ee8de2e6dae1df6eb90e3f2e242c9383b95d314e3e
-F ext/fts5/test/fts5unicode3.test c3caecbe8264629ffe653b43ca5790b9793eba4422f92203e5247558e5a534e7
+F ext/fts5/test/fts5unicode3.test 590c72e18195bda2446133f9d82d04a4e89d094bba58c75ae10f4afc6faa0744
F ext/fts5/test/fts5unicode4.test 6463301d669f963c83988017aa354108be0b947d325aef58d3abddf27147b687
F ext/fts5/test/fts5unindexed.test 9021af86a0fb9fc616f7a69a996db0116e7936d0db63892db6bafabbec21af4d
-F ext/fts5/test/fts5update.test 0737876e20e97a6a6abf45de19fc99315727bcee6a83fadcada1cc080b9aa8f0
+F ext/fts5/test/fts5update.test b8affd796e45c94a4d19ad5c26606ea06065a0f162a9562d9f005b5a80ccf0bc
F ext/fts5/test/fts5version.test c8f2cc105f0abf0224965f93e584633dee3e06c91478bc67e468f7cfdf97fd6a
-F ext/fts5/test/fts5vocab.test 2de834ee6405130d3373817ced8fefbfee392b63d932e471740e09829f1e4510
-F ext/fts5/test/fts5vocab2.test d6039b20118e886113fc63614d9ad39a466fc2af34184f3e915b9f92b7ebfa10
+F ext/fts5/test/fts5vocab.test 648fb2fe86b55e08295e34504704718d92fba3e2cf3e1f5d72fa3682df4cd0f0
+F ext/fts5/test/fts5vocab2.test e0fdc3a3095f6eda68ac9bf9a443ff929a124d46f00af19933604085712e9d47
F ext/fts5/tool/fts5speed.tcl b0056f91a55b2d1a3684ec05729de92b042e2f85
F ext/fts5/tool/fts5txt2db.tcl 526a9979c963f1c54fd50976a05a502e533a4c59
F ext/fts5/tool/loadfts5.tcl 95b03429ee6b138645703c6ca192c3ac96eaf093
@@ -270,29 +273,31 @@ F ext/lsm1/test/lsm1_common.tcl 5ed4bab07c93be2e4f300ebe46007ecf4b3e20bc5fbe1ded
F ext/lsm1/test/lsm1_simple.test ca949efefa102f4644231dcd9291d8cda7699a4ce1006b26e0e3fcb72233f422
F ext/lsm1/tool/mklsm1c.tcl f31561bbee5349f0a554d1ad7236ac1991fc09176626f529f6078e07335398b0
F ext/misc/README.md d6dd0fe1d8af77040216798a6a2b0c46c73054d2f0ea544fbbcdccf6f238c240
-F ext/misc/amatch.c c0a6a807a553eaa220bf69fca0353cd1587a3bfb3d2224fa425e3e6efcacc98a
+F ext/misc/amatch.c cc9835931fbe46f9c6b8dbb51779c16f169bee50ae372a20532ff5154ebaf5b1
F ext/misc/anycollseq.c 5ffdfde9829eeac52219136ad6aa7cd9a4edb3b15f4f2532de52f4a22525eddb
F ext/misc/appendvfs.c 3777f22ec1057dc4e5fd89f2fbddcc7a29fbeef1ad038c736c54411bb1967af7
F ext/misc/btreeinfo.c 4f0ebf278f46e68e6306c667917766cebc5550fd35d5de17847988e22892d4d2
F ext/misc/carray.c ed96c218ea940b85c9a274c4d9c59fe9491c299147a38a8bba537687bd6c6005
-F ext/misc/closure.c 9f8fa11aa6c6e2f6d7296ffa88f103df4b46abd9602bcab3ea2f8fc24f334f63
+F ext/misc/closure.c 037d055c5a4880d41607a3ea44037f655b5e8ac1bdce305ec497903fd2646960
F ext/misc/completion.c cec672d40604075bb341a7f11ac48393efdcd90a979269b8fe7977ea62d0547f
F ext/misc/compress.c dd4f8a6d0baccff3c694757db5b430f3bbd821d8686d1fc24df55cf9f035b189
-F ext/misc/csv.c 88333dc9f7dcf6a8148406f10ae04261e24e3b4c721550ae33e9e71f1265c1f1
-F ext/misc/dbdump.c 12389a10c410fadf1e68eeb382def92d5a7fa9ce7cce4fb86a736fa2bac1000a
-F ext/misc/eval.c 6ea9b22a5fa0dd973b67ca4e53555be177bc0b7b263aadf1024429457c82c0e3
+F ext/misc/csv.c 7f047aeb68f5802e7ce6639292095d622a488bb43526ed04810e0649faa71ceb
+F ext/misc/dbdump.c baf6e37447c9d6968417b1cd34cbedb0b0ab3f91b5329501d8a8d5be3287c336
+F ext/misc/eval.c 4b4757592d00fd32e44c7a067e6a0e4839c81a4d57abc4131ee7806d1be3104e
F ext/misc/explain.c d5c12962d79913ef774b297006872af1fccda388f61a11d37758f9179a09551f
-F ext/misc/fileio.c e3153b04433897a18a3d17185845f286892e96fdf87f4301290d09c36ae1759f
-F ext/misc/fuzzer.c 7c64b8197bb77b7d64eff7cac7848870235d4c25
+F ext/misc/fileio.c 592d6531d8413d81b25f5a47a45d7e310e455d33e03a64c6ae85724c6524a5d5
+F ext/misc/fuzzer.c 9e79c337faffdd4c5fe4485467537438359b43e0858a40038d4300b894ff553f
F ext/misc/ieee754.c f190d0cc5182529acb15babd177781be1ac1718c
-F ext/misc/json1.c 3f017d2659e531d021d015ec5d69ea0b1c71f2e15bf9768b1e149fcdf6c3e0b1
-F ext/misc/memstat.c 941928c6104d8ed569a6c47caa756dc78b8091f7a15f87d3004f3b1e576b10da
+F ext/misc/json1.c 8af4672f43634257dbcfdb4515b4070325463d67c6968b4be1bd414de28d4d58
+F ext/misc/memstat.c 3017a0832c645c0f8c773435620d663855f04690172316bd127270d1a7523d4d
+F ext/misc/memtrace.c 7c0d115d2ef716ad0ba632c91e05bd119cb16c1aedf3bec9f06196ead2d5537b
F ext/misc/memvfs.c ab36f49e02ebcdf85a1e08dc4d8599ea8f343e073ac9e0bca18a98b7e1ec9567
-F ext/misc/mmapwarm.c 70b618f2d0bde43fae288ad0b7498a629f2b6f61b50a27e06fae3cd23c83af29
-F ext/misc/nextchar.c 35c8b8baacb96d92abbb34a83a997b797075b342
+F ext/misc/mmapwarm.c 8c5fe90d807a23e44a8b93e96e8b812b19b300d5fd8c1d40a4fd1d8224e33f46
+F ext/misc/nextchar.c 279f80fe8ef5ba413242e2704e246503ac601f005eefb180d19e6c920338a0ba
F ext/misc/normalize.c b4290464f542bae7a97b43f15bd197949b833ffd668b7c313631bd5d4610212c
-F ext/misc/percentile.c 92699c8cd7d517ff610e6037e56506f8904dae2e
-F ext/misc/regexp.c a68d25c659bd2d893cd1215667bbf75ecb9dc7d4
+F ext/misc/percentile.c a6a1594c104da2d0ceab38fe609eb2f65529272377827f6f8a2b5c9fa6119e7e
+F ext/misc/prefixes.c 7be86d17525cfae6ed462fc3c519efc44488ac329890f77491c8f82871f57e17
+F ext/misc/regexp.c 79345bf03496155a640ee0300d3307296761cebb5e115b4e342cc2fb5861ec10
F ext/misc/remember.c add730f0f7e7436cd15ea3fd6a90fd83c3f706ab44169f7f048438b7d6baa69c
F ext/misc/rot13.c 540a169cb0d74f15522a8930b0cccdcb37a4fd071d219a5a083a319fc6e8db77
F ext/misc/scrub.c db9fff56fed322ca587d73727c6021b11ae79ce3f31b389e1d82891d144f22ad
@@ -305,13 +310,13 @@ F ext/misc/sqlar.c 57d5bc45cd5492208e451f697404be88f8612527d64c9d42f96b325b64983
F ext/misc/stmt.c 8a8dc4675042e4551e4afe99b8d0cc7a4a2fc1a8dacc0a9ce1b1bbff145da93d
F ext/misc/templatevtab.c 8a16a91a5ceaccfcbd6aaaa56d46828806e460dd194965b3f77bf38f14b942c4
F ext/misc/totype.c 4a167594e791abeed95e0a8db028822b5e8fe512
-F ext/misc/unionvtab.c acf947858054850db2d4a611bfeae072cdc6d9f517b46a993fe1f2f1ea20031e
-F ext/misc/vfslog.c fe40fab5c077a40477f7e5eba994309ecac6cc95
+F ext/misc/unionvtab.c 34ee634d09670909563dbde59c5bfb2ac048b27051f65f1aeac918b061d646d8
+F ext/misc/vfslog.c 3b25c2f56ba60788db247287be6ab024b53c4afffd412b4876db563389be0d35
F ext/misc/vfsstat.c bf10ef0bc51e1ad6756629e1edb142f7a8db1178
F ext/misc/vtablog.c 5538acd0c8ddaae372331bee11608d76973436b77d6a91e8635cfc9432fba5ae
F ext/misc/vtshim.c 1976e6dd68dd0d64508c91a6dfab8e75f8aaf6cd
F ext/misc/wholenumber.c 784b12543d60702ebdd47da936e278aa03076212
-F ext/misc/zipfile.c 1d731db326c40e11fc608f38132acff31619946c000e85ab8efe75bbedc2a441
+F ext/misc/zipfile.c c1ca8f52330b4564207036b978edac8141c737bf612659bf6f7bee3ddd563a03
F ext/misc/zorder.c b0ff58fa643afa1d846786d51ea8d5c4b6b35aa0254ab5a82617db92f3adda64
F ext/rbu/rbu.c 8681f6157db6adc82c34af24b14ea8a3be0146ad2a3b6c1d5da6cb8a5796c8ce
F ext/rbu/rbu1.test 221d9c18a5e600ac9ac6b1810d99d9f99163a7909ba61597876ab6e4d4beb3d6
@@ -329,7 +334,7 @@ F ext/rbu/rbu9.test 0e4d985e25620d61920597e8ea69c871c9e8c1f5a0be2ae9fa70bb641d74
F ext/rbu/rbuA.test b34a90cb495682c25b5fc03a9d5e7a4fc99541c29256f25e2e2a4f6542b4f5b3
F ext/rbu/rbuB.test 52b07158824c6927b7e25554ace92a695cdebfc296ae3d308ac386984aded9bc
F ext/rbu/rbuC.test 80f1cc2fb74f44b1128fd0ed8eedab3a76fefeb72a947860e2869ef76fc8dc6b
-F ext/rbu/rbu_common.tcl acfb7fbbaf8d46a9f6f6a5ec795616c84d705e1565d918afe43f0ff53ea0efa5
+F ext/rbu/rbu_common.tcl 4b3d033b3e3844292ae3a1aefc0e524e64b0db5a0e4310657919e4504ac3073f
F ext/rbu/rbucollate.test cac528a9a46318cba42e61258bb42660bbbf4fdb9a8c863de5a54ad0c658d197
F ext/rbu/rbucrash.test 000981a1fe8a6e4d9a684232f6a129e66a3ef595f5ed74655e2f9c68ffa613b4
F ext/rbu/rbucrash2.test efa143cc94228eb0266d3f1abfbee60a5838a84cef7cc3fcb8c145b74d96fd41
@@ -347,10 +352,11 @@ F ext/rbu/rbusave.test f4190a1a86fccf84f723af5c93813365ae33feda35845ba107b59683d
F ext/rbu/rbusplit.test b37e7b40b38760881dc9c854bd40b4744c6b6cd74990754eca3bda0f407051e8
F ext/rbu/rbutemplimit.test 7f408f49b90fa0a720d7599f3aec74a3c85e6cd78e56fdf726ce00af9147a341
F ext/rbu/rbuvacuum.test 55e101e90168c2b31df6c9638fe73dc7f7cc666b6142266d1563697d79f73534
-F ext/rbu/rbuvacuum2.test 0a7669bbabdaeed915f02f59f33fe20e13d4932ba2086fe00a82064d9424c80b
-F ext/rbu/sqlite3rbu.c 71f8c09948d09ec9c5a8dbe7127e8ef61ef0853e698b2650be2485ac7b9c75c8
-F ext/rbu/sqlite3rbu.h b42bcd4d8357268c6c39ab2a60b29c091e89328fa8cc49c8fac5ab8d007e79b2
-F ext/rbu/test_rbu.c baa23eb28457580673d2175e5f0c29ced0cd320ee819b13ad362398c53b96e90
+F ext/rbu/rbuvacuum2.test b8e5b51dc8b2c0153373d024c0936be3f66f9234acbd6d0baab0869d56b14e6b
+F ext/rbu/rbuvacuum3.test 8addd82e4b83b4c93fa47428eae4fd0dbf410f8512c186f38e348feb49ba03dc
+F ext/rbu/sqlite3rbu.c d643661c7c85e79f4d0bc56c73f6f2dd55c35732dd41f378b0fd3b182a33242d
+F ext/rbu/sqlite3rbu.h 1dc88ab7bd32d0f15890ea08d23476c4198d3da3056985403991f8c9cd389812
+F ext/rbu/test_rbu.c 03f6f177096a5f822d68d8e4069ad8907fe572c62ff2d19b141f59742821828a
F ext/repair/README.md 92f5e8aae749a4dae14f02eea8e1bb42d4db2b6ce5e83dbcdd6b1446997e0c15
F ext/repair/checkfreelist.c 0dbae18c1b552f58d64f8969e4fb1e7f11930c60a8c2a9a8d50b7f15bdfd54bd
F ext/repair/checkindex.c 7d28c01a2e012ac64257d230fc452b2cafb78311a91a343633d01d95220f66f3
@@ -361,15 +367,15 @@ F ext/repair/test/checkfreelist01.test 3e8aa6aeb4007680c94a8d07b41c339aa635cc782
F ext/repair/test/checkindex01.test b530f141413b587c9eb78ff734de6bb79bc3515c335096108c12c01bddbadcec
F ext/repair/test/test.tcl 686d76d888dffd021f64260abf29a55c57b2cedfa7fc69150b42b1d6119aac3c
F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761
-F ext/rtree/geopoly.c d56ff997f2646b03be742eb85e8206f779d777f3a282fe0da576780ca0e11f20
-F ext/rtree/rtree.c 7125183bf6c37b8b8ee1a04d2b0fe258531fd31650fdd050ed041817f1943d17
+F ext/rtree/geopoly.c 061432bddc38c4c10c7e4ce940d581c886d65bb5814b4b65b46ad046aa85eaa2
+F ext/rtree/rtree.c 57729cc19f3832e5f9051556af44ed264b5bd54b01543cd7e50d5143817b964c
F ext/rtree/rtree.h 4a690463901cb5e6127cf05eb8e642f127012fd5003830dbc974eca5802d9412
-F ext/rtree/rtree1.test 309afc04d4287542b2cd74f933296832cc681c7b014d9405cb329b62053a5349
+F ext/rtree/rtree1.test 7573134f1b4f59df36c1b0a6de51268fd3b9c714d91f3811482263e734e416ea
F ext/rtree/rtree2.test 5f25b01acd03470067a2d52783b2eb0a50bf836803d4342d20ca39e541220fe2
F ext/rtree/rtree3.test 4ee5d7df86040efe3d8d84f141f2962a7745452200a7cba1db06f86d97050499
F ext/rtree/rtree4.test 304de65d484540111b896827e4261815e5dca4ce28eeecd58be648cd73452c4b
F ext/rtree/rtree5.test 49c9041d713d54560b315c2c7ef7207ee287eba1b20f8266968a06f2e55d3142
-F ext/rtree/rtree6.test 593e0d36510d5ac1d1fb39b018274ff17604fe8fdca8cf1f8e16559cea1477f4
+F ext/rtree/rtree6.test 1252a0439da01d2f1f5cbbdeeb80455a2d68b9bae2a9787937b167a5e3957828
F ext/rtree/rtree7.test c8fb2e555b128dd0f0bdb520c61380014f497f8a23c40f2e820acc9f9e4fdce5
F ext/rtree/rtree8.test 2d99006a1386663978c9e1df167554671e4f711c419175b39f332719deb1ce0e
F ext/rtree/rtree9.test c646f12c8c1c68ef015c6c043d86a0c42488e2e68ed1bb1b0771a7ca246cbabf
@@ -384,14 +390,16 @@ F ext/rtree/rtreeH.test aa08cc4fa8005b4c67446c7110205055b4d6da90e760e6f44b82dfa4
F ext/rtree/rtree_perf.tcl 6c18c1f23cd48e0f948930c98dfdd37dfccb5195
F ext/rtree/rtree_util.tcl db734b4c5e75fed6acc56d9701f2235345acfdec750b5fc7b587936f5f6bceed
F ext/rtree/rtreecheck.test d67d5b3e9e45bfa8cd90734e8e9302144ac415b8e9176c6f02d4f92892ee8a35
+F ext/rtree/rtreecirc.test aec664eb21ae943aeb344191407afff5d392d3ae9d12b9a112ced0d9c5de298e
F ext/rtree/rtreeconnect.test 225ad3fcb483d36cbee423a25052a6bbae762c9576ae9268332360c68c170d3d
+F ext/rtree/rtreefuzz001.test 836d87653851ae8e7b506d8bd3d62329548adc48ff9bc0a9051efd576710be7b
F ext/rtree/sqlite3rtree.h 03c8db3261e435fbddcfc961471795cbf12b24e03001d0015b2636b0f3881373
F ext/rtree/tkt3363.test 142ab96eded44a3615ec79fba98c7bde7d0f96de
F ext/rtree/util/randomshape.tcl 54ee03d0d4a1c621806f7f44d5b78d2db8fac26e0e8687c36c4bd0203b27dbff
F ext/rtree/viewrtree.tcl eea6224b3553599ae665b239bd827e182b466024
F ext/rtree/visual01.txt e9c2564083bcd30ec51b07f881bffbf0e12b50a3f6fced0c222c5c1d2f94ac66
-F ext/session/changeset.c 4ccbaa4531944c24584bf6a61ba3a39c62b6267a
-F ext/session/changesetfuzz.c 255826ee367781ec4c29a36c7c63e9ee6387dc03a8346cf240feb8d597958b0e
+F ext/session/changeset.c d046906a0c9a37862fcd5dbfda5eb08dea361b9abdd959b34358a63fa246164f
+F ext/session/changesetfuzz.c 01023c41cfb02e191d144ea8bfdc46443393b62d13873f5fa044fc9886e60142
F ext/session/changesetfuzz1.test 2e1b90d888fbf0eea5e1bd2f1e527a48cc85f8e0ff75df1ec4e320b21f580b3a
F ext/session/session1.test 0b2f88995832ea040ae8e83a1ad4afa99c00b85c779d213da73a95ea4113233e
F ext/session/session2.test 284de45abae4cc1082bc52012ee81521d5ac58e0
@@ -410,7 +418,7 @@ F ext/session/sessionF.test d37ed800881e742c208df443537bf29aa49fd56eac520d0f0c6d
F ext/session/sessionG.test 3828b944cd1285f4379340fd36f8b64c464fc84df6ff3ccbc95578fd87140b9c
F ext/session/sessionH.test a417559f29a7e775950fc5fc82b3d01256a7cbe793ddf1180df234df823d56e2
F ext/session/session_common.tcl 29ec9910aca1e996ca1c8531b8cecabf96eb576aa53de65a8ff03d848b9a2a8b
-F ext/session/session_speed_test.c edc1f96fd5e0e4b16eb03e2a73041013d59e8723
+F ext/session/session_speed_test.c dcf0ef58d76b70c8fbd9eab3be77cf9deb8bc1638fed8be518b62d6cbdef88b3
F ext/session/sessionat.test efe88965e74ff1bc2af9c310b28358c02d420c1fb2705cc7a28f0c1cc142c3ec
F ext/session/sessiondiff.test ad13dd65664bae26744e1f18eb3cbd5588349b7e9118851d8f9364248d67bcec
F ext/session/sessionfault.test da273f2712b6411e85e71465a1733b8501dbf6f7
@@ -418,9 +426,9 @@ F ext/session/sessionfault2.test dd593f80b6b4786f7adfe83c5939620bc505559770cc181
F ext/session/sessioninvert.test ae1a003a9ab1f8d64227dbb5c3a4c97e65b561b01e7b2953cf48683fb2724169
F ext/session/sessionrebase.test ccfa716b23bd1d3b03217ee58cfd90c78d4b99f53e6a9a2f05e82363b9142810
F ext/session/sessionstat1.test 218d351cf9fcd6648f125a26b607b140310160184723c2666091b54450a68fb5
-F ext/session/sessionwor.test 07f0b304dc4df5454906069140bf6ec67edcaa3c548f3683354003cf2c22b64a
-F ext/session/sqlite3session.c dbd6f7a89c1236d8e7b58f4e217391670ce91b9e6f85c16ba02832674ef0cf3c
-F ext/session/sqlite3session.h 05351d2f50a1203fdffbeb590fdbbc796c9a6bfcd0c9b26cf6db3854e3eb4294
+F ext/session/sessionwor.test 67b5ab91d4f93ce65ff1f58240ac5ddf73f8670facc1ffa49cef56293d52818d
+F ext/session/sqlite3session.c 4c79daf65e89c78dd62fd97a1b2eac3e53be700b29914101453a0d951f7ba9c8
+F ext/session/sqlite3session.h 54d6356f5769d3695e5f63d719c6ee27671b2614973a2b675a3ff4d30d574233
F ext/session/test_session.c 98797aba475a799376c9a42214f2d1debf2d0c3cb657d9c8bbf4f70bf3fb4aec
F ext/userauth/sqlite3userauth.h 7f3ea8c4686db8e40b0a0e7a8e0b00fac13aa7a3
F ext/userauth/user-auth.txt e6641021a9210364665fe625d067617d03f27b04
@@ -428,7 +436,7 @@ F ext/userauth/userauth.c f81aa5a3ecacf406f170c62a144405858f6f6de51dbdc0920134e6
F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x
F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8
F magic.txt 8273bf49ba3b0c8559cb2774495390c31fd61c60
-F main.mk eeaa279fa6acdcfa6555058548075569a06f891fd67f5901b1e7700d18052fda
+F main.mk 3930eb2fcbebe49ab7408f6fef3baa8c4bf3c84540f9f29dfe849bf561ff6e51
F mkso.sh fd21c06b063bb16a5d25deea1752c2da6ac3ed83
F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271
F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504
@@ -440,44 +448,44 @@ F spec.template 86a4a43b99ebb3e75e6b9a735d5fd293a24e90ca
F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b
F sqlite3.1 fc7ad8990fc8409983309bb80de8c811a7506786
F sqlite3.pc.in 48fed132e7cb71ab676105d2a4dc77127d8c1f3a
-F src/alter.c f886160da189e4e99093cd5a2aca625652cc9b027d5100b87f81c175d1056387
-F src/analyze.c 3dc6b98cf007b005af89df165c966baaa48e8124f38c87b4d2b276fe7f0b9eb9
-F src/attach.c 92b51739a885da8bd84bc9a05485f1e48148bce5c15432f059b45af98fff75cd
+F src/alter.c cb691d6cd330312b7951c9d3bc0bc29804bbe80beac1cdd137d824b119b6f28a
+F src/analyze.c 58db66344a5c58dcabb57f26696f6f2993956c830446da40b444051d2fdaf644
+F src/attach.c 3f9b0f6c79500cc40f4e543bc130a0b4ee13f52b45cbb6735608776cbdb79f0e
F src/auth.c 0fac71038875693a937e506bceb492c5f136dd7b1249fbd4ae70b4e8da14f9df
F src/backup.c 78d3cecfbe28230a3a9a1793e2ead609f469be43e8f486ca996006be551857ab
F src/bitvec.c 17ea48eff8ba979f1f5b04cc484c7bb2be632f33
F src/btmutex.c 8acc2f464ee76324bf13310df5692a262b801808984c1b79defb2503bbafadb6
-F src/btree.c ba7c7eef4461790f37c309936bfc5d0d6ba9b194b02d3c8ff1fd53b420ea6d3b
-F src/btree.h febb2e817be499570b7a2e32a9bbb4b607a9234f6b84bb9ae84916d4806e96f2
-F src/btreeInt.h 620ab4c7235f43572cf3ac2ac8723cbdf68073be4d29da24897c7b77dda5fd96
-F src/build.c 127d33ad57b455a9339e9fabff41284c8b030cc6247ca7a2a6c0ad7abfc1ce85
-F src/callback.c 789bd33d188146f66c0dd8306472a72d1c05f71924b24a91caf6bd45cf9aba73
+F src/btree.c 84b7c5c3829b60823e15e7a8407462b69be3818f96518fef28f97ac0fbbca72b
+F src/btree.h 63b94fb38ce571c15eb6a3661815561b501d23d5948b2d1e951fbd7a2d04e8d3
+F src/btreeInt.h cd82f0f08886078bf99b29e1a7045960b1ca5d9d5829c38607e1299c508eaf00
+F src/build.c 906ca6663b9dcd413e72ae9c44dd51e596d8336b04d52e678a7501e71c20cab2
+F src/callback.c 25dda5e1c2334a367b94a64077b1d06b2553369f616261ca6783c48bcb6bda73
F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e
F src/ctime.c 109e58d00f62e8e71ee1eb5944ac18b90171c928ab2e082e058056e1137cc20b
F src/date.c ebe1dc7c8a347117bb02570f1a931c62dd78f4a2b1b516f4837d45b7d6426957
F src/dbpage.c 135eb3b5e74f9ef74bde5cec2571192c90c86984fa534c88bf4a055076fa19b7
-F src/dbstat.c 3c8bd4e77f0244fd2bd7cc90acf116ad2f8e82d70e536637f35ac2bc99b726f9
-F src/delete.c f7938125847e8ef485448db5fbad29acb2991381a02887dd854c1617315ab9fb
-F src/expr.c 9aacc0b72348ba90010b672dcbbbe2fa56e1182043bc917a3a147b2bc57a5497
+F src/dbstat.c c12833de69cb655751487d2c5a59607e36be1c58ba1f4bd536609909ad47b319
+F src/delete.c d08c9e01a2664afd12edcfa3a9c6578517e8ff8735f35509582693adbe0edeaf
+F src/expr.c 182dc9ff30aa6a430b7f728ce84fda85ec10890e29fdf75be1e871d13222a99c
F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007
-F src/fkey.c 972a4ba14296bef2303a0abbad1e3d82bc3c61f9e6ce4e8e9528bdee68748812
-F src/func.c 7c288b4ce309b5a8b8473514b88e1f8e69a80134509a8c0db8e39c858e367e7f
-F src/global.c 8291eee0782b83124de14ec0389ec9fd6ae1873358a6b0d9469fe17a46ad803b
-F src/hash.c 931ec82d7e070654a8facb42549bbb3a25720171d73ba94c3d3160580d01ef1f
+F src/fkey.c bd0138acdc008c1845ccf92f8e73787880562de649471804801c06fed814c765
+F src/func.c 0341881d22903aac5ba7f352b188806d6436e1d6ae4235ff01e44d56879dfe63
+F src/global.c 0dea3065ea72a65ae941559b6686aad6516d4913e76fa4f79a95ff7787f624ec
+F src/hash.c a12580e143f10301ed5166ea4964ae2853d3905a511d4e0c44497245c7ce1f7a
F src/hash.h ab34c5c54a9e9de2e790b24349ba5aab3dbb4fd4
F src/hwtime.h 747c1bbe9df21a92e9c50f3bbec1de841dc5e5da
F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71
-F src/insert.c 6b81aae27b196925d8ff78824f4bbd435d6a40cd38dc324685e21735bb402109
-F src/legacy.c 134ab3e3fae00a0f67a5187981d6935b24b337bcf0f4b3e5c9fa5763da95bf4e
-F src/loadext.c 9050dd153b5583804184be9c9dee9ebb554178d6db1f8ac280899e8aad9060e6
-F src/main.c 4cfb3913cc9e65d3ac649b1785ac753fc225d29425d5437e012f7eac0cefe0eb
+F src/insert.c 3ed9ceaa4b7d56a6f2613355e1cd1ae5cfe31712bce2bf5aa93c5f1f130704b2
+F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa
+F src/loadext.c e6f10875d52aca3b7e57ce1ec174aeafc9b6c00b43000cd30d791f9cb490b7a6
+F src/main.c 27d7265625ea6eaccdfe7c53ef41adc179c9357a077702a860c1a3b0a037a16f
F src/malloc.c 07295435093ce354c6d9063ac05a2eeae28bd251d2e63c48b3d67c12c76f7e18
F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645
F src/mem1.c c12a42539b1ba105e3707d0e628ad70e611040d8f5e38cf942cee30c867083de
F src/mem2.c f1940d9e91948dd6a908fbb9ce3835c36b5d83c3
F src/mem3.c 8768ac94694f31ffaf8b4d0ea5dc08af7010a35a
F src/mem5.c 9bf955937b07f8c32541c8a9991f33ce3173d944
-F src/memdb.c cb4013d56fa71c79c498717cbc47b27dd1c7653fd866584b2071ae04114eec46
+F src/memdb.c 02a5fcec19b9d40dd449ca802dc1b2e8f93f255fbf2a886277a3c3800d8d35db
F src/memjournal.c 6f3d36a0a8f72f48f6c3c722f04301ac64f2515435fa42924293e46fc7994661
F src/msvc.h 4942752b6a253116baaa8de75256c51a459a5e81
F src/mutex.c bae36f8af32c22ad80bbf0ccebec63c252b6a2b86e4d3e42672ff287ebf4a604
@@ -493,30 +501,30 @@ F src/os_setup.h 0dbaea40a7d36bf311613d31342e0b99e2536586
F src/os_unix.c f6e91b8fd82af7afbfd073c4974ad6cdb8e62d9f65ceddb45167835a0567fdc0
F src/os_win.c 85d9e532d0444ab6c16d7431490c2e279e282aa0917b0e988996b1ae0de5c5a0
F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a
-F src/pager.c 75e0f3cfa3962c714f519f8a3d1e67ecca1c91de0e010a036b988e40ce9e4c73
+F src/pager.c 857dde3e525f665cfab23b6765bf04ca6638c0759ae7da6d63acfb463e230aa6
F src/pager.h 217921e81eb5fe455caa5cda96061959706bcdd29ddb57166198645ef7822ac3
-F src/parse.y 6840fe7c0b5eb4dd25ee5d075213bc8255ed4c0678d71bfb6744d0520d91c179
+F src/parse.y 741a270b7f2f85bc5d026d06fb5a9ccba5335304ff2831e1cb44b36cd0da6006
F src/pcache.c 696a01f1a6370c1b50a09c15972bc3bee3333f8fcd1f2da8e9a76b1b062c59ee
F src/pcache.h 4f87acd914cef5016fae3030343540d75f5b85a1877eed1a2a19b9f284248586
-F src/pcache1.c bf9fcea656dce1cd2cca6b77a1d1d3552050d55a31c98bf0d9f405930a83bc95
-F src/pragma.c 4e056f042683b99c4ea0db395f68d051b1a95833ab40951c40d3ef7e1fee1354
-F src/pragma.h fdd03d78a7497f74a3f652909f945328480089189526841ae829ce7313d98d13
-F src/prepare.c f81f8d707e583192c28fea0b2e19385415b7d188123b23f49b038076408d7a69
-F src/printf.c 0f1177cf1dd4d7827bf64d840768514ec76409abecaca9e8b577dbd065150381
+F src/pcache1.c a72804486dfa8e4b6bc30d666c97ecf1155f91a4351fc6e48ea4097e4eb304fb
+F src/pragma.c af67dedaad8bafe9a5f9adcec32a0da6dd118617dd8220ad1d118f5a6bf83a02
+F src/pragma.h a776bb9c915207e9d1117b5754743ddf1bf6a39cc092a4a44e74e6cb5fab1177
+F src/prepare.c 78027c6231fbb19ca186a5f5f0c0a1375d9c2cec0655273f9bd90d9ff74a34b3
+F src/printf.c cbf27c320091a83279d1738f68a27a9fe01698c607ce80516ab6bdb5a9c36a1a
F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384
-F src/resolve.c 4cfc44def0f0690ceaab8f6481f5d76284d7f9509aab6e218a679b4836a54614
+F src/resolve.c c8f207247472c41ac73d738e1c1a80719ad253d1dbb617ed57740492b2a6c097
F src/rowset.c d977b011993aaea002cab3e0bb2ce50cf346000dff94e944d547b989f4b1fe93
-F src/select.c 61e867a906f140b73baf4ce7a201ad6dcba30820969f5618ee40e9a0d32c6f5f
-F src/shell.c.in 482e23a370cbe5b0d4c73a0f0f5fce34f7caa08a14a8d75e12f0225c4e14915c
-F src/sqlite.h.in cce9feede1c1c03923c091b4bbbd081dd77aaf92024cc2cdbf65f712c2f668c3
+F src/select.c c998f694759e37799929e28df8a2649747f8774d4fc233529ab6bda689388e15
+F src/shell.c.in f2c1adbee3f6f36686b4a38d2168ebfc25298b4ad1e6d95199fc4e95b539251d
+F src/sqlite.h.in 7da74fd5bd7a9dbe92297060f036935520b26e240457287c5e67c7b9db51a986
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
F src/sqlite3ext.h 960f1b86c3610fa23cb6a267572a97dcf286e77aa0dd3b9b23292ffaa1ea8683
-F src/sqliteInt.h 1161f7579cdd6217737a66517ef27f4016426603eff492e9b31f45a7d7d4c61f
+F src/sqliteInt.h f657e35d824fdc17ddf46bb85f0193df3b965e8354ded9ec37825057e3224bcc
F src/sqliteLimit.h 1513bfb7b20378aa0041e7022d04acb73525de35b80b252f1b83fedb4de6a76b
F src/status.c 46e7aec11f79dad50965a5ca5fa9de009f7d6bde08be2156f1538a0a296d4d0e
F src/table.c b46ad567748f24a326d9de40e5b9659f96ffff34
-F src/tclsqlite.c e72862a271348d779672b45a730c33fd0c535e630ff927e8ce4a0c908d1d28c6
-F src/test1.c 5390e5afb31fed61f72d0be0cb1b322d198a6e03fc13ff245ae76d17b4dcf2e9
+F src/tclsqlite.c 6b19e7562195aaf881f3e35e2472dc01ae3cb156961db5126c3d616744729b7e
+F src/test1.c 353b066e7ec761c4c715c1c20b888e0e7a0b0c0eda7f68c110e032d63713cade
F src/test2.c 3efb99ab7f1fc8d154933e02ae1378bac9637da5
F src/test3.c 61798bb0d38b915067a8c8e03f5a534b431181f802659a6616f9b4ff7d872644
F src/test4.c 18ec393bb4d0ad1de729f0b94da7267270f3d8e6
@@ -541,7 +549,7 @@ F src/test_hexio.c 1d4469ca61ab202a1fcec6543f584d2407205e8d
F src/test_init.c 4413c211a94b62157ca4c145b3f27c497f03c664
F src/test_intarray.c 39b4181662a0f33a427748d87218e7578d913e683dc27eab7098bb41617cac71
F src/test_intarray.h d57ae92f420cda25e22790dac474d60961bd0c500cbaa3338a05152d4a669ef7
-F src/test_journal.c 619f2aa10e0d7a5f87c0f06825bc61dfce1c6b9c7f3ad990fb13de6c3b8874a3
+F src/test_journal.c a0b9709b2f12b1ec819eea8a1176f283bca6d688a6d4a502bd6fd79786f4e287
F src/test_loadext.c 337056bae59f80b9eb00ba82088b39d0f4fe6dfd
F src/test_malloc.c dec0aa821b230773aeb3dd11d652c1193f7cedb18a20b25659bc672288115242
F src/test_md5.c 7268e1e8c399d4a5e181b64ac20e1e6f3bc4dd9fc87abac02db145a3d951fa8c
@@ -562,40 +570,40 @@ F src/test_syscall.c 1073306ba2e9bfc886771871a13d3de281ed3939
F src/test_tclsh.c 06317648b0d85a85fd823f7973b55535c59a3156c1ef59394fe511f932cfa78d
F src/test_tclvar.c 33ff42149494a39c5fbb0df3d25d6fafb2f668888e41c0688d07273dcb268dfc
F src/test_thread.c 911d15fb14e19c0c542bdc8aabf981c2f10a4858
-F src/test_vfs.c 112f1f9271c33c211812e0e681830a84262dac065da58579ff49f9cefec97d4f
+F src/test_vfs.c c6c6a58f66b26876c7b5769fb323a58b2c7120299b5084e7212c4116f902cbaa
F src/test_vfstrace.c bab9594adc976cbe696ff3970728830b4c5ed698
F src/test_windirent.c a895e2c068a06644eef91a7f0a32182445a893b9a0f33d0cdb4283dca2486ac1
F src/test_windirent.h 90dfbe95442c9762357fe128dc7ae3dc199d006de93eb33ba3972e0a90484215
F src/test_window.c cdae419fdcea5bad6dcd9368c685abdad6deb59e9fc8b84b153de513d394ba3f
F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9
F src/threads.c 4ae07fa022a3dc7c5beb373cf744a85d3c5c6c3c
-F src/tokenize.c 9e781e1ca80eefe7b5d6a9e2cd5c678c847da55fd6f093781fad7950934d4c83
-F src/treeview.c 7b12ac059de54c939b6eb0dbffc9410c29c80d2470cee5cbe07d5ff9ea2d9253
-F src/trigger.c d3d78568f37fb2e6cdcc2d1e7b60156f15b0b600adec55b83c5d42f6cad250bd
-F src/update.c 1816d56c1bca1ba4e0ef98cac2f49be62858e9df1dc08844c7067eb41cc44274
+F src/tokenize.c 0a065eaa31f494ba31ac21d4a5d24a5a7865a7d849459f8c6266df1ac6b9aedf
+F src/treeview.c c6ff90da4cc1813ff2d9bb11f17d4d927db62c47e552faa1835edc47269d753d
+F src/trigger.c bb034c08eca111e66a19cda045903a12547c1be2294b5570d794b869d9c44a73
+F src/update.c 0b973357d88092140531e07ff641139c26fb4380b0b9f5ed98c5f7691b4604d1
F src/upsert.c 0dd81b40206841814d46942a7337786932475f085716042d0cb2fc7791bf8ca4
F src/utf.c 810fbfebe12359f10bc2a011520a6e10879ab2a163bcb26c74768eab82ea62a5
-F src/util.c d9eb0a6c4aae1b00a7369eadd7ca0bbe946cb4c953b6751aa20d357c2f482157
-F src/vacuum.c 836cadc922de866c849e23a75f93d344cdc143d388339305d09a3fed27e8798d
-F src/vdbe.c 005e691ea4c7d51e6c1a69d9389aeb34700884c85f51681817ddea3fdc2fc39b
-F src/vdbe.h 5081dcc497777efe5e9ebe7330d283a044a005e4bdda2e2e984f03bf89a0d907
-F src/vdbeInt.h 437e6c6af679fdf157867eb83a8adc6cf5145d6774453c2214cfd0bd01d92980
-F src/vdbeapi.c ecccfce6f614c33a95952efeec969d163e8349eac314ee2b7b163eda921b5eb0
-F src/vdbeaux.c f547901b1aa9e2d81c63f06893f633648e434180666a827aacb547d7d6c8a601
+F src/util.c 82a2e3f691a3b654be872e305dab1f455e565dedf5e6a90c818c1ab307c00432
+F src/vacuum.c a9f389f41556c0ec310bc9169dc9476603c30a0a913ad92bfbc75c86886967ca
+F src/vdbe.c b7b6f965153607072917dbd81d654a268abf4872c58d556701d1549550766c02
+F src/vdbe.h 712bca562eaed1c25506b9faf9680bdc75fc42e2f4a1cd518d883fa79c7a4237
+F src/vdbeInt.h a76d5eed62c76bcd8de7afd3147fac1bc40c5a870582664bcd7d071ef437c37f
+F src/vdbeapi.c 57a2d794a8833f269b878dbc24e955369bdb379af6c4e93ebc5ce1a20fa3daf4
+F src/vdbeaux.c 4fa28b32452f6197dba7c8780dde11576b9a6d8ce6f35adbb69efc3e7d37fa0c
F src/vdbeblob.c f5c70f973ea3a9e915d1693278a5f890dc78594300cf4d54e64f2b0917c94191
-F src/vdbemem.c 7b3305bc4a5139f4536ac9b5f61da0f915e49d2e3fdfa87dfdfa9d7aba8bc1e9
+F src/vdbemem.c 3173f0275cf8643a03ed02084ee56b97fc1a17a2edb5907facec504f59c3172d
F src/vdbesort.c 90aad5a92608f2dd771c96749beabdb562c9d881131a860a7a5bccf66dc3be7f
F src/vdbetrace.c 79d6dbbc479267b255a7de8080eee6e729928a0ef93ed9b0bfa5618875b48392
-F src/vtab.c 70188a745dc4e57d26e942681ff4b2912b7c8249ad5de3f60f0677b4337bcfaa
+F src/vtab.c 2462b7d6fd72b0b916477f5ef210ee49ab58cec195483ebdac0c8c5e3ec42cab
F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9
F src/wal.c 3f4f653daf234fe713edbcbca3fec2350417d159d28801feabc702a22c4e213f
F src/wal.h 606292549f5a7be50b6227bd685fa76e3a4affad71bb8ac5ce4cb5c79f6a176a
-F src/walker.c fb94aadc9099ff9c6506d0a8b88d51266005bcaa265403f3d7caf732a562eb66
-F src/where.c 3818e8a736a05d2cb194e64399af707e367fbcc5c251d785804d02eaf121288e
-F src/whereInt.h f125f29fca80890768e0b2caa14f95db74b2dacd3a122a168f97aa7b64d6968f
-F src/wherecode.c c45f03aefc2266b990df0fc4d7acc4e27f56f881f4fc0fc355b7cbc4d7189da5
-F src/whereexpr.c 491f0894ad9903750cdecb7894437a0cabdffdd88f574d2b1c9ac85d14fe4b9c
-F src/window.c 6550e2850ebced51100ef83d49b00a1cf03f81a482dafedafb0320df647ed8fc
+F src/walker.c 7607f1a68130c028255d8d56094ea602fc402c79e1e35a46e6282849d90d5fe4
+F src/where.c 8a207cb2ca6b99e1edb1e4bbff9b0504385a759cbf66180d1deb34d80ca4b799
+F src/whereInt.h 5f14db426ca46a83eabab1ae9aa6d4b8f27504ad35b64c290916289b1ddb2e88
+F src/wherecode.c a571d8d7c19d6db786a201f2df8788b320fefcb2842f2a1eb9a85b85e91bc35f
+F src/whereexpr.c 36b47f7261d6b6f1a72d774c113b74beddf6745aba1018e64b196e29db233442
+F src/window.c df2456386e0b1553a8d1fcf3a0ddc4c058fe2c650ea8c74b6bf8862082ddafc9
F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2
F test/affinity2.test a6d901b436328bd67a79b41bb0ac2663918fe3bd
F test/affinity3.test 6a101af2fc945ce2912f6fe54dd646018551710d
@@ -609,12 +617,13 @@ F test/alter3.test 4d79934d812eaeacc6f22781a080f8cfe012fdc3
F test/alter4.test 7e93a21fe131e1dfeb317e90056856f96b10381fc7fe3a05e765569a23400433
F test/alterauth.test 63442ba61ceb0c1eeb63aac1f4f5cebfa509d352276059d27106ae256bafc959
F test/alterauth2.test c0a1ddf5b93d93cb0d15ba7acaf0c5c6fb515bbe861ede75b2d3fabad33b6499
-F test/altercol.test 313ed080ed61691c52cd87053129889f71582d6d0efebdd5f3edad2a98c66874
+F test/altercol.test 54374d2ba18af25bb24e23acf18a60270d4ec120b7ec0558078b59d5aa1a31ad
F test/alterlegacy.test 82022721ce0de29cedc9a7af63bc9fcc078b0ee000f8283b4b6ea9c3eab2f44b
F test/altermalloc.test 167a47de41b5c638f5f5c6efb59784002b196fff70f98d9b4ed3cd74a3fb80c9
F test/altermalloc2.test fa7b1c1139ea39b8dec407cf1feb032ca8e0076bd429574969b619175ad0174b
-F test/altertab.test 17e46baa6b2234048c91891a303141afceca4da95a36ee1a0a9fec6ccef1f4da
-F test/altertab2.test 0d64de5632ca5de13b023839cfe5b8952d029e4622befcea1433adaa93883220
+F test/altertab.test 6e13f13d8c30708f16187908c31dadb1bfff9e3cb2a07a7392a7a5e076f58f4a
+F test/altertab2.test 7bedde2e6e71fdecd7a2af64b696cd0b3d3a344f5cf1db6785d9e3b5665193cf
+F test/altertab3.test 9dd97ab8161eb6afc0e30e7c61a38336687fbd09e6ddc4c9f1e450cc0b12160b
F test/amatch1.test b5ae7065f042b7f4c1c922933f4700add50cdb9f
F test/analyze.test 7168c8bffa5d5cbc53c05b7e9c7fcdd24b365a1bc5046ce80c45efa3c02e6b7c
F test/analyze3.test ff62d9029e6deb2c914490c6b00caf7fae47cc85cdc046e4a0d0a4d4b87c71d8
@@ -650,7 +659,7 @@ F test/auth2.test 9eb7fce9f34bf1f50d3f366fb3e606be5a2000a1
F test/auth3.test db21405b95257c24d29273b6b31d0efc59e1d337e3d5804ba2d1fd4897b1ae49
F test/autoanalyze1.test b9cc3f32a990fa56669b668d237c6d53e983554ae80c0604992e18869a0b2dec
F test/autoinc.test 381f494fefa90acd999933829e2934efb6b40906db9d6a39e822e3f7b4c8bf61
-F test/autoindex1.test a09958fa756129af10b6582bcbf3cbdf11e305e027b393f393caef801159dee0
+F test/autoindex1.test 96185415f5faacd5b8d7a7f505efddd5abb1f111d58338e9c0b1dc40b87cd3cc
F test/autoindex2.test 12ef578928102baaa0dc23ad397601a2f4ecb0df
F test/autoindex3.test 2dd997d6590438b53e4f715f9278aa91c9299cf3f81246a0915269c35beb790e
F test/autoindex4.test 49d3cd791a9baa16fb461d7ea3de80d019a819cf
@@ -670,7 +679,7 @@ F test/badutf2.test f5bc7f2d280670ecd79b9cf4f0f1760c607fe51f
F test/bc_common.tcl b5e42d80305be95697e6370e015af571e5333a1c
F test/bestindex1.test 852170bddbb21daa121fabcc274640ff83d7d8705912e8b5fe7ed2c5a9a9224a
F test/bestindex2.test 9a0ccd320b6525eec3a706aae6cdab7e1b7b5abca75027e39f39f755e76e5928
-F test/bestindex3.test 001788a114ad96d81d5154fe77c7f1e26e84b3a2b5635ca29e4f96f6decc534e
+F test/bestindex3.test 7622e792ff2da16d262d3cea6ad914591ac4806d57ed128e6c940b7920b47b84
F test/bestindex4.test 038e3d0789332f3f1d61474f9bbc9c6d08c6bd1783a978f31f38ad82688de601
F test/bestindex5.test 67c1166131bb59f9e47c00118f7d432ca5491e6cae6ca3f87ca9db20103a78f9
F test/bestindex6.test d856a9bb63d927493575823eed44053bc36251e241aa364e54d0f2a2d302e1d4
@@ -693,7 +702,7 @@ F test/boundary3.test 56ef82096b4329aca2be74fa1e2b0f762ea0eb45
F test/boundary4.tcl 0bb4b1a94f4fc5ae59b79b9a2b7a140c405e2983
F test/boundary4.test 89e02fa66397b8a325d5eb102b5806f961f8ec4b
F test/btree01.test e08b3613540145b353f20c81cb18ead54ff12e0f
-F test/btree02.test a0f33669ba76632247c14718af32db939fa6de5cd13890798ad3f2a362cf7fe4
+F test/btree02.test 7555a5440453d900410160a52554fe6478af4faf53098f7235f1f443d5a1d6cc
F test/btreefault.test c2bcb542685eea44621275cfedbd8a13f65201e3
F test/busy.test 510dc6daaad18bcbbc085bcc6217d6dc418def5e73f72ce1475eea0cb7834727
F test/cache.test 13bc046b26210471ca6f2889aceb1ea52dc717de
@@ -724,7 +733,7 @@ F test/collateA.test b8218ab90d1fa5c59dcf156efabb1b2599c580d6
F test/collateB.test 1e68906951b846570f29f20102ed91d29e634854ee47454d725f2151ecac0b95
F test/colmeta.test 2c765ea61ee37bc43bbe6d6047f89004e6508eb1
F test/colname.test fb28b3687e03625425bc216edf8b186ce974aa71008e2aa1f426a7dcb75a601d
-F test/conflict.test 029faa2d81a0d1cafb5f88614beb663d972c01db
+F test/conflict.test c7cc007e2af151516ddf38f7412fe10d473a694f55e3df437e2c7b31c2590e8d
F test/conflict2.test bb0b94cf7196c64a3cbd815c66d3ee98c2fecd9c
F test/conflict3.test a83db76a6c3503b2fa057c7bfb08c318d8a422202d8bc5b86226e078e5b49ff9
F test/contrib01.test 2a1cbc0f2f48955d7d073f725765da6fbceda6b4
@@ -748,7 +757,8 @@ F test/corruptH.test 79801d97ec5c2f9f3c87739aa1ec2eb786f96454
F test/corruptI.test a17bbf54fdde78d43cf3cc34b0057719fd4a173a3d824285b67dc5257c064c7b
F test/corruptJ.test 4d5ccc4bf959464229a836d60142831ef76a5aa4
F test/corruptK.test 5ef338c560ca4dfb7360828da16f1829be4deba3b378cafdc7a1cdaf027eb5c4
-F test/cost.test b37db8a10d467a69e71a9f3d40bbb266c2f587742b37c6912f6e3f7185a0e216
+F test/corruptL.test 0f64242b83db6d0bd5b6e38c205bf7c2a3bc6c9f80351f49c4dee1639aca60d8
+F test/cost.test 51f4fcaae6e78ad5a57096831259ed6c760e2ac6876836e91c00030fad385b34
F test/count.test cb2e0f934c6eb33670044520748d2ecccd46259c
F test/countofview.test e3d4cd6900e4e4f074968ab24b8b87d3671cd624961bef40fd3a6b8f574343cf
F test/coveridxscan.test 5ec98719a2e2914e8908dc75f7247d9b54a26df04625f846ac7900d5483f7296
@@ -764,7 +774,7 @@ F test/crashM.test d95f59046fa749b0d0822edf18a717788c8f318d
F test/crashtest1.c 09c1c7d728ccf4feb9e481671e29dda5669bbcc2
F test/createtab.test b5de160630b209c4b8925bdcbbaf48cc90b67fe8
F test/cse.test 277350a26264495e86b1785f34d2d0c8600e021c
-F test/csv01.test 4a92840619ef435b905e6d3f35cd0644df23225d7b7967d7940b40f06d6a90a6
+F test/csv01.test c9c3af0d58c34e9ac970c5875a77939edb958762c8aafb95409e19a3f088b6cd
F test/ctime.test 78749e6c9a5f0010d67985be80788f841e3cd2da18114e2ed6010399a7d807f3
F test/cursorhint.test 7bc346788390475e77a345da2b92270d04d35856
F test/cursorhint2.test 6f3aa9cb19e7418967a10ec6905209bcbb5968054da855fc36c8beee9ae9c42f
@@ -772,8 +782,9 @@ F test/dataversion1.test 6e5e86ac681f0782e766ebcb56c019ae001522d114e0e111e5ebf68
F test/date.test 9b73bbeb1b82d9c1f44dec5cf563bf7da58d2373
F test/date2.test 74c234bece1b016e94dd4ef9c8cc7a199a8806c0e2291cab7ba64bace6350b10
F test/dbfuzz.c 73047c920d6210e5912c87cdffd9a1c281d4252e
+F test/dbfuzz001.test 29b6c6b39a701b6b5b08035c637674b76e1ecea515b1a184b29e3bd0f2d02dad
F test/dbfuzz2-seed1.db e6225c6f3d7b63f9c5b6867146a5f329d997ab105bee64644dc2b3a2f2aebaee
-F test/dbfuzz2.c 652f85bac1770e927da139db513234a3eba308f72ac2f8b32f0093d7d19def70
+F test/dbfuzz2.c 5d5eb817dc8195e0228227510ee6a4b49f46e679fc2d5be96841cce819bf42f7
F test/dbpage.test 650234ba683b9d82b899c6c51439819787e7609f17a0cc40e0080a7b6443bc38
F test/dbstatus.test cd83aa623b8aab477269bc94cf8aa90c1e195a144561dd04a1620770aaa8524e
F test/dbstatus2.test f5fe0afed3fa45e57cfa70d1147606c20d2ba23feac78e9a172f2fe8ab5b78ef
@@ -805,7 +816,7 @@ F test/e_fts3.test 17ba7c373aba4d4f5696ba147ee23fd1a1ef70782af050e03e262ca187c5e
F test/e_insert.test f02f7f17852b2163732c6611d193f84fc67bc641fb4882c77a464076e5eba80e
F test/e_reindex.test 2b0e29344497d9a8a999453a003cb476b6b1d2eef2d6c120f83c2d3a429f3164
F test/e_resolve.test a61751c368b109db73df0f20fc75fb47e166b1d8
-F test/e_select.test c5a669b4d63217aa10094ba737ba3ddd07bd439d4bc7a5b798f6ea32511cbe7c
+F test/e_select.test f9474205669a7736ef725b29cc7ae9e8601919a3d0ffc0ab30745a028f2a4b61
F test/e_select2.test aceb80ab927d46fba5ce7586ebabf23e2bb0604f
F test/e_totalchanges.test b12ee5809d3e63aeb83238dd501a7bca7fd72c10
F test/e_update.test f46c2554d915c9197548681e8d8c33a267e84528
@@ -820,7 +831,7 @@ F test/enc.test e54531cd6bf941ee6760be041dff19a104c7acea
F test/enc2.test 83437a79ba1545a55fb549309175c683fb334473
F test/enc3.test 6807f7a7740a00361ca8d0ccd66bc60c8dc5f2b6
F test/enc4.test c8f1ce3618508fd0909945beb8b8831feef2c020
-F test/eqp.test fc00ad1a7f5b90bf1bbccbf877ae9abef8bf5c7896174830d438c8f91a6ead88
+F test/eqp.test 84879b63e3110552bf8ce648a3507dc3ceb72109ecec83c2aef0db37a27f6382
F test/errmsg.test eae9f091eb39ce7e20305de45d8e5d115b68fa856fba4ea6757b6ca3705ff7f9
F test/eval.test a64c9105d6ff163df7cf09d6ac29cdad5922078c
F test/exclusive.test 1206b87e192497d78c7f35552e86a9d05421498da300fb1cce5ca5351ccde3c3
@@ -830,7 +841,7 @@ F test/exists.test 79a75323c78f02bbe9c251ea502a092f9ef63dac
F test/expr.test 7cb55e80aeb41d65fec968c08212505123063fea60bdc355d764d747670e9eea
F test/extension01.test 00d13cec817f331a687a243e0e5a2d87b0e358c9
F test/extraquick.test cb254400bd42bfb777ff675356aabf3287978f79
-F test/fallocate.test 07416bd593a116d5893cb244f45a94d5c6fe030561df3bd972e6135f8106e509
+F test/fallocate.test 37a62e396a68eeede8f8d2ecf23573a80faceb630788d314d0a073d862616717
F test/filectrl.test 6e871c2d35dead1d9a88e176e8d2ca094fec6bb3
F test/filefmt.test f393e80c4b8d493b7a7f8f3809a8425bbf4292af1f5140f01cb1427798a2bbd4
F test/fkey1.test d11dbb8a93ead9b5c46ae5d02da016d61245d47662fb2d844c99214f6163f768
@@ -840,7 +851,7 @@ F test/fkey4.test 86446017011273aad8f9a99c1a65019e7bd9ca9d
F test/fkey5.test 24dd28eb3d9f1b5a174f47e9899ace5facb08373a4223593c8c631e6cf9f7d5a
F test/fkey6.test d078a1e323a740062bed38df32b8a736fd320dc0
F test/fkey7.test 24076d43d3449f12f25503909ca4bfb5fc5fefd5af1f930723a496343eb28454
-F test/fkey8.test e5372e32cdb4481f121ec3550703eeb7b4e0762c
+F test/fkey8.test 863c6d84f0d289fd2c1a1c293abb9803f77efd35211d9012c0986c8f6ccf5d5a
F test/fkey_malloc.test 594a7ea1fbab553c036c70813cd8bd9407d63749
F test/fordelete.test eb93a2f34137bb87bdab88fcab06c0bd92719aff
F test/format4.test 1f0cac8ff3895e9359ed87e41aaabee982a812eb
@@ -880,8 +891,8 @@ F test/fts2q.test b2fbbe038b7a31a52a6079b215e71226d8c6a682
F test/fts2r.test b154c30b63061d8725e320fba1a39e2201cadd5e
F test/fts2token.test d8070b241a15ff13592a9ae4a8b7c171af6f445a
F test/fts3.test 672a040ea57036fb4b6fdc09027c18d7d24ab654
-F test/fts3_common.tcl 99cf6659b87c0f74f55963c2aea03b3a7d66ceb0
-F test/fts3aa.test f267fcd6aca30fc70b81e5d82b68b34b38f581896020b57ed49e9777c7ebd85f
+F test/fts3_common.tcl dffad248f9ce090800e272017d2898005c28ee6314fc1dd5550643a02666907a
+F test/fts3aa.test 814d60a1ba30b4a71d8f9306a6564bc7b636dd6efacd2ad80306f9b23ef3ebee
F test/fts3ab.test 7f6cf260ae80dda064023df8e8e503e9a412b91f
F test/fts3ac.test 636ed7486043055d4f126a0e385f2d5a82ebbf63
F test/fts3ad.test e40570cb6f74f059129ad48bcef3d7cbc20dda49
@@ -899,7 +910,7 @@ F test/fts3ao.test 266989148fec6d9f1bb6c5382f7aa3dcea0e9cd444576e28dd2b9287ac7dd
F test/fts3atoken.test 4b4c16fdcfc972f2cdbba212375a060a86ccf5f1
F test/fts3auto.test 19097050a3ca7ab7a43b2be967cb3dfd8ddf841dfdc4eac88deb172ad2f209f2
F test/fts3aux1.test 7a170e172afdbceb67f5baa05941fd4fbf56af42f61daa3d140f4b4bf4cb68f6
-F test/fts3aux2.test 7ae2b2c13aefdf4169279a27a5f51780ce57f6ba
+F test/fts3aux2.test 2459e7fa3e22734aed237d1e2ae192f5541c4d8b218956ad2d90754977bf907f
F test/fts3b.test c15c4a9d04e210d0be67e54ce6a87b927168fbf9c1e3faec8c1a732c366fd491
F test/fts3c.test fc723a9cf10b397fdfc2b32e73c53c8b1ec02958
F test/fts3comp1.test a0f5b16a2df44dd0b15751787130af2183167c0c
@@ -907,7 +918,7 @@ F test/fts3conf.test c84bbaec81281c1788aa545ac6e78a6bd6cde2bdbbce2da261690e3659f
F test/fts3corrupt.test 46b9ddda7f6588fd5a5b1f4bb4fc0618dc45010e7dddb8a3a188baf3197177ae
F test/fts3corrupt2.test bf55c3fa0b0dc8ea1c0fe5543623bd27714585da6a129038fd6999fe3b0d25f3
F test/fts3corrupt3.test 0d5b69a0998b4adf868cc301fc78f3d0707745f1d984ce044c205cdb764b491f
-F test/fts3corrupt4.test a27259f4f25d60b4eca481d050b3cfee97eddb0d937d38f231408c5239066e11
+F test/fts3corrupt4.test ff7313656c4ad446e61c41e5cb81336441eaaafe6f4fd6938f1c3ac0c985045e
F test/fts3cov.test cb932743da52a1c79a1ab8983e26c8121cf02263d6ff16e1f642e6f9b8348338
F test/fts3d.test 2bd8c97bcb9975f2334147173b4872505b6a41359a4f9068960a36afe07a679f
F test/fts3defer.test f4c20e4c7153d20a98ee49ee5f3faef624fefc9a067f8d8d629db380c4d9f1de
@@ -919,10 +930,11 @@ F test/fts3expr.test ebae205a7a89446c32583bcd492dcb817b9f6b31819bb4dde2583bb99c7
F test/fts3expr2.test 18da930352e5693eaa163a3eacf96233b7290d1a
F test/fts3expr3.test c4d4a7d6327418428c96e0a3a1137c251b8dfbf8
F test/fts3expr4.test cac5dd815fe6b5921741abdccdde3b7f50b86394de91e13308ee7986859c4a9f
-F test/fts3expr5.test f9abfffbf5e53d48a33e12a1e8f8ba2c551c9b49
-F test/fts3fault.test 9fb7d6266a38806de841f7244bac1b0fe3a1477184bbb10b172d19d2ca6ad692
+F test/fts3expr5.test 1368738e3298a7ce0dee3a44d6ebb8f468b2a76f3d1dd18d4ea6d8bc2eeccc1b
+F test/fts3fault.test 798e45af84be7978ca33d5bdc94246eb44724db24174b5d8e9b1ac46c57fb08d
F test/fts3fault2.test 6a17a11d8034b1c4eca9f3091649273d56c49ff049e2173df8060f94341e9da0
F test/fts3first.test dbdedd20914c8d539aa3206c9b34a23775644641
+F test/fts3fuzz001.test e3c7b0ce9b04cc02281dcc96812a277f02df03cd7dc082055d87e11eb18aaf56
F test/fts3join.test 949b4f5ae3ae9cc2423cb865d711e32476bdb205ab2be923fdf48246e4a44166
F test/fts3malloc.test b0e4c133b8d61d4f6d112d8110f8320e9e453ef6
F test/fts3matchinfo.test aa66cc50615578b30f6df9984819ae5b702511cf8a94251ec7c594096a703a4a
@@ -935,7 +947,7 @@ F test/fts3query.test ca033ff2ebcc22c69d89032fb0bc1850997d31e7e60ecd26440796ba16
F test/fts3rank.test cd99bc83a3c923c8d52afd90d86979cf05fc41849f892faeac3988055ef37b99
F test/fts3rnd.test 1320d8826a845e38a96e769562bf83d7a92a15d0
F test/fts3shared.test 57e26a801f21027b7530da77db54286a6fe4997e
-F test/fts3snippet.test 8cf586fe4b6878192602a81a665448aacbbad80ade0867bb5299d40e73584311
+F test/fts3snippet.test dace744104d1a44dc12dc9dd10b8d7542342df503d96942b7c4a55034e761789
F test/fts3sort.test ed34c716a11cc2009a35210e84ad5f9c102362ca
F test/fts3tok1.test a663f4cac22a9505400bc22aacb818d7055240409c28729669ea7d4cc2120d15
F test/fts3tok_err.test 52273cd193b9036282f7bacb43da78c6be87418d
@@ -956,6 +968,7 @@ F test/fts4merge4.test d895b1057a7798b67e03455d0fa50e9ea836c47b
F test/fts4noti.test 5553d7bb2e20bf4a06b23e849352efc022ce6309
F test/fts4onepass.test d69ddc4ee3415e40b0c5d1d0408488a87614d4f63ba9c44f3e52db541d6b7cc7
F test/fts4opt.test 0fd0cc84000743ff2a883b9b84b4a5be07249f0ba790c8848a757164cdd46b2a
+F test/fts4umlaut.test fcaca4471de7e78c9d1f7e8976e3e8704d7d8ad979d57a739d00f3f757380429
F test/fts4unicode.test ceca76422abc251818cb25dabe33d3c3970da5f7c90e1540f190824e6b3a7c95
F test/full.test 6b3c8fb43c6beab6b95438c1675374b95fab245d
F test/func.test 09dda479bcfc568f99f3070413e9672a8eeedc1be9c5d819bf55d4788c2583b7
@@ -968,16 +981,18 @@ F test/fuzz-oss1.test e58330d01cbbd8215ee636b17a03fe220b37dbfa
F test/fuzz.test 96083052bf5765e4518c1ba686ce2bab785670d1
F test/fuzz2.test 76dc35b32b6d6f965259508508abce75a6c4d7e1
F test/fuzz3.test 9c813e6613b837cb7a277b0383cd66bfa07042b4cf0317157c35852f30043c31
+F test/fuzz4.test c229bcdb45518a89e1d208a21343e061503460ac69fae1539320a89f572eb634
F test/fuzz_common.tcl a87dfbb88c2a6b08a38e9a070dabd129e617b45b
F test/fuzz_malloc.test f348276e732e814802e39f042b1f6da6362a610af73a528d8f76898fde6b22f2
-F test/fuzzcheck.c fda41c0e4e667fae96b002410bb19cece7a33314264ed6bbc6d012909ee9fd58
+F test/fuzzcheck.c 7ab35ca464fa0fa9c8340b71f08a16c50c14b961264c172cc3d1a67289b2800d
F test/fuzzdata1.db 7ee3227bad0e7ccdeb08a9e6822916777073c664
F test/fuzzdata2.db 128b3feeb78918d075c9b14b48610145a0dd4c8d6f1ca7c2870c7e425f5bf31f
F test/fuzzdata3.db c6586d3e3cef0fbc18108f9bb649aa77bfc38aba
F test/fuzzdata4.db b502c7d5498261715812dd8b3c2005bad08b3a26e6489414bd13926cd3e42ed2
F test/fuzzdata5.db e35f64af17ec48926481cfaf3b3855e436bd40d1cfe2d59a9474cb4b748a52a5
F test/fuzzdata6.db 92a80e4afc172c24f662a10a612d188fb272de4a9bd19e017927c95f737de6d7
-F test/fuzzdata7.db a1bf54eb455e9772942abae1b2d1cf1e3d3659f0e5dd14f00792fd01411ae8ef
+F test/fuzzdata7.db 3fc78e65dfe0be9df9e262075d5a335f18f627da47dfc691d1a7b822f34d4b99
+F test/fuzzdata8.db 3f7c67741ba91c13955609700a44608d2dfe4f037e508f77d236ea9abb431a02
F test/fuzzer1.test 3d4c4b7e547aba5e5511a2991e3e3d07166cfbb8
F test/fuzzer2.test a85ef814ce071293bce1ad8dffa217cbbaad4c14
F test/fuzzerfault.test 8792cd77fd5bce765b05d0c8e01b9edcf8af8536
@@ -1013,20 +1028,21 @@ F test/index2.test f835d5e13ca163bd78c4459ca15fd2e4ed487407
F test/index3.test 51685f39345462b84fcf77eb8537af847fdf438cc96b05c45d6aaca4e473ade0
F test/index4.test ab92e736d5946840236cd61ac3191f91a7856bf6
F test/index5.test 8621491915800ec274609e42e02a97d67e9b13e7
-F test/index6.test d07ea75b8c21f125c6f325522e8df8c05c91e9251ec923a31d0582b2ba4a617d
+F test/index6.test 6b3e6cd4bef343ed4541e74c55936ed112962a6552c085242612b598e12910a4
F test/index7.test 72b59b8ddc5c13f4962886b4011eb9975014317d17ef36c6297921362fb7dd98
F test/index8.test bc2e3db70e8e62459aaa1bd7e4a9b39664f8f9d7
F test/index9.test 0aa3e509dddf81f93380396e40e9bb386904c1054924ba8fa9bcdfe85a8e7721
F test/indexedby.test a52c8c6abfae4fbfb51d99440de4ca1840dbacc606b05e29328a2a8ba7cd914e
F test/indexexpr1.test 635261197bcdc19b9b2c59bbfa7227d525c00e9587faddb2d293c44d287ce60e
-F test/indexexpr2.test fc994dcd4b3da932d4add8e65ed7ca08166d541e00a46874cfacd98dfb93a31b
+F test/indexexpr2.test 38020c247ee77ba19322fadde99db84bdf2aef34f714866786563c3834bb2dce
F test/indexfault.test 31d4ab9a7d2f6e9616933eb079722362a883eb1d
F test/init.test 15c823093fdabbf7b531fe22cf037134d09587a7
-F test/insert.test 5604b1ff5675cc84c34a5b315792b958f48c32edccc0dafcc81d3b776270b70a
+F test/insert.test 9773604f8e1a2595f51488a5643c359d8a11dc55a11cb185910d93387d378458
F test/insert2.test 4d14b8f1b810a41995f6286b64a6943215d52208
F test/insert3.test 1b7db95a03ad9c5013fdf7d6722b6cd66ee55e30
F test/insert4.test 46bead5f39e181850ee56adcf49d3a3157c460c52249211714612ac89fe34835
F test/insert5.test 394f96728d1258f406fe5f5aeb0aaf29487c39a6
+F test/insertfault.test ac63d14ea3b49c573673a572f4014b9117383a03e497c58f308b5c776e4a7f74
F test/instr.test 9a8802f28437d8ade53fedfc47b2ca599b4e48ba
F test/instrfault.test 0f870b218ea17cd477bb19ed330eecdb460dd53a
F test/intarray.test 8319986182af37c8eb4879c6bfe9cf0074e9d43b193a4c728a0efa3417c53fb7
@@ -1041,11 +1057,11 @@ F test/ioerr4.test f130fe9e71008577b342b8874d52984bd04ede2c
F test/ioerr5.test 2edfa4fb0f896f733071303b42224df8bedd9da4
F test/ioerr6.test a395a6ab144b26a9e3e21059a1ab6a7149cca65b
F test/istrue.test 62372ad3ddcc5d0eb8ff9097dcb0aad8961bf1b9cb45ba634f6e284695126f9a
-F test/join.test 2ad9d7fe10e0cc06bc7803c22e5533be11cdadbc592f5f95d789a873b57a5a66
+F test/join.test d53a3662762eff50b65da8775201e609878a27dd0885a1ae7bcde9bb46cecbc5
F test/join2.test 10f7047e723ebd68b2f47189be8eed20451a6f665d8bf46f1774c640d1062417
F test/join3.test 6f0c774ff1ba0489e6c88a3e77b9d3528fb4fda0
F test/join4.test 1a352e4e267114444c29266ce79e941af5885916
-F test/join5.test 5a2da0c3ea852a7063d3e72fc7d5a04a6de5ef6e6d85092582f69033f7459adc
+F test/join5.test f8b5ffdf3c1513486b52ad4e49225507ecee5005f210eb18688f791d25370972
F test/join6.test cfe6503791ceb0cbb509966740286ec423cbf10b
F test/journal1.test c7b768041b7f494471531e17abc2f4f5ebf9e5096984f43ed17c4eb80ba34497
F test/journal2.test 9dac6b4ba0ca79c3b21446bbae993a462c2397c4
@@ -1053,7 +1069,7 @@ F test/journal3.test c9c29883f5bf535ae82ae21c472df6263806a22e467b6db7cd0d6d54530
F test/jrnlmode.test a6693f2bed4541a21e703aaa37bb3e10de154130645952933b82b2dec0a8b539
F test/jrnlmode2.test 8759a1d4657c064637f8b079592651530db738419e1d649c6df7048cd724363d
F test/jrnlmode3.test 556b447a05be0e0963f4311e95ab1632b11c9eaa
-F test/json101.test b40a9f5395d8e669b0bc3eb550ad2ae9e5ada01fbce23c446c2a30a305a6d575
+F test/json101.test 8f8977b00ba02f9a26c1d1f52f29f540f6d5eb162cbd5eb78bb805366d4ab26d
F test/json102.test eeb54efa221e50b74a2d6fb9259963b48d7414dca3ce2fdfdeed45cb28487bc1
F test/json103.test aff6b7a4c17d5a20b487a7bc1a274bfdc63b829413bdfb83bedac42ec7f67e3b
F test/json104.test 877d5845f6303899b7889ea5dd1bea99076e3100574d5c536082245c5805dcaa
@@ -1076,7 +1092,7 @@ F test/lock4.test 27143363eda1622f03c133efc8db808fc331afd973486cb571ea71cd717d37
F test/lock5.test c6c5e0ebcb21c61a572870cc86c0cb9f14cede38
F test/lock6.test ad5b387a3a8096afd3c68a55b9535056431b0cf5
F test/lock7.test 49f1eaff1cdc491cc5dee3669f3c671d9f172431
-F test/lock_common.tcl 7ffb45accf6ee91c736df9bafe0806a44358f035
+F test/lock_common.tcl 2f3f7f2e9637f93ccf609df48ef5b27a50278b6b1cd752b445d52262e5841413
F test/lookaside.test 5a828e7256f1ee4da8e1bdaa03373a3ccdb0f1ff98dfa82e9b76cb41a45b1083
F test/main.test 6bbb3999fd461eb8fb335cbab97409a3d7f91bbb8da60635e8be3e4a04a77772
F test/make-where7.tcl 05c16b5d4f5d6512881dfec560cb793915932ef9
@@ -1107,7 +1123,7 @@ F test/malloctraceviewer.tcl b7a54595270c1d201abf1c3f3d461f27eaf24cdef623ad08a0f
F test/manydb.test 28385ae2087967aa05c38624cec7d96ec74feb3e
F test/mem5.test c6460fba403c5703141348cd90de1c294188c68f
F test/memdb.test c1f2a343ad14398d5d6debda6ea33e80d0dafcc7
-F test/memdb1.test 61aa1dbdeea6320791d2ff42a9a6149d5716be674bf06ee0ffa0aad1bf3eb5f8
+F test/memdb1.test 0632e6ea56c48e3c6e9b0c73e120310bad8f93762543f809e267888f5a37943f
F test/memleak.test 10b9c6c57e19fc68c32941495e9ba1c50123f6e2
F test/memsubsys1.test 9e7555a22173b8f1c96c281ce289b338fcba2abe8b157f8798ca195bbf1d347e
F test/memsubsys2.test 3e4a8d0c05fd3e5fa92017c64666730a520c7e08
@@ -1115,13 +1131,13 @@ F test/minmax.test 6751e87b409fe11b02e70a306d846fa544e25a41
F test/minmax2.test dae92964ac87c1d2ef978c582e81a95e11c00f1cbef68980bfb2abaf10315063
F test/minmax3.test cc1e8b010136db0d01a6f2a29ba5a9f321034354
F test/minmax4.test 936941484ebdceb8adec7c86b6cd9b6e5e897c1f
-F test/misc1.test c8cfd1c3f842b3341fda9d81a96236d5c76ca89973aeff3fe50bac6fefcfc421
+F test/misc1.test 7ce84b25df9872e7d7878613a96815d2ba5bc974ac4e15a50118dde8f3917599
F test/misc2.test 00d7de54eda90e237fc9a38b9e5ccc769ebf6d4d
F test/misc3.test cf3dda47d5dda3e53fc5804a100d3c82be736c9d
F test/misc4.test 10cd6addb2fa9093df4751a1b92b50440175dd5468a6ec84d0386e78f087db0e
F test/misc5.test c4aeaa0fa28faa08f2485309c38db4719e6cd1364215d5687a5b96d340a3fa58
F test/misc6.test 953cc693924d88e6117aeba16f46f0bf5abede91
-F test/misc7.test 10d639a5e0fdf1bd51ad42be705393a38780ad71b6957110035a4e6c1e5e7f40
+F test/misc7.test 4f21954012e4eb0a923c54a311f38c81bf6798ccdd7b51584db46d4007f63daa
F test/misc8.test 8fb0f31d7a8aed484d759773ab8ad12ec746a477f4a67394a4af0e677494c3ca
F test/misuse.test 9e7f78402005e833af71dcab32d048003869eca5abcaccc985d4f8dc1d86bcc7
F test/mjournal.test 28a08d5cb5fb5b5702a46e19176e45e964e0800d1f894677169e79f34030e152
@@ -1140,7 +1156,7 @@ F test/mutex2.test bfeaeac2e73095b2ac32285d2756e3a65e681660
F test/nan.test 437d40e6d0778b050d7750726c0cbd2c9936b81962926e8f8c48ca698f00f4d1
F test/nockpt.test 8c43b25af63b0bd620cf1b003529e37b6f1dc53bd22690e96a1bd73f78dde53a
F test/nolock.test f196cf8b8fbea4e2ca345140a2b3f3b0da45c76e
-F test/normalize.test 6a80564d2000702b5919ed2c1069fef0f95762142bc96a71b4c124a845165713
+F test/normalize.test 422027884ffb67ebba32bb78487c67cf67643496d19c077b07044bdba071a3f6
F test/notify1.test 669b2b743618efdc18ca4b02f45423d5d2304abf
F test/notify2.test 2ecabaa1305083856b7c39cf32816b612740c161
F test/notify3.test 10ff25cde502e72a92053a2f215d64bece4ef934
@@ -1163,7 +1179,7 @@ F test/orderby7.test 3d1383d52ade5b9eb3a173b3147fdd296f0202da
F test/orderby8.test 23ef1a5d72bd3adcc2f65561c654295d1b8047bd
F test/orderby9.test 87fb9548debcc2cd141c5299002dd94672fa76a3
F test/oserror.test e7b3416be4b9d5dd2fe0b42dd394daaddbb6c83eeec1f0e47b120b53e0ad3ace
-F test/ossfuzz.c 273eaea2d65b70d77ea4f01404114b9e0244488943f768dc39458c72bd722e0e
+F test/ossfuzz.c 18af635fa73d12a109b305faca727a734c1fa28a421b161d9d15c5a84a4998a2
F test/ossshell.c f125c5bd16e537a2549aa579b328dd1c59905e7ab1338dfc210e755bb7b69f17
F test/ovfl.test 199c482696defceacee8c8e0e0ef36da62726b2f
F test/pager1.test 1e9ee778bdeaf4f7f09997d029cdaca6a42dfc2092edafe4f5e590acbf1eab13
@@ -1179,7 +1195,7 @@ F test/parser1.test 6ccdf5e459a5dc4673d3273dc311a7e9742ca952dd0551a6a6320d27035c
F test/pcache.test c8acbedd3b6fd0f9a7ca887a83b11d24a007972b
F test/pcache2.test af7f3deb1a819f77a6d0d81534e97d1cf62cd442
F test/percentile.test 4243af26b8f3f4555abe166f723715a1f74c77ff
-F test/permutations.test cf0b4e498db1d0143c19641d4420df7cc27fab2c95ed0abd2c7c5753beab25b8
+F test/permutations.test 52d2c37fe8cc07ec7362024c214b04bb69432995b3a984a3fbabc60fa6ada3ee
F test/pg_common.tcl 301ac19c1a52fd55166d26db929b3b89165c634d52b5f8ad76ea8cb06960db30
F test/pragma.test c267bf02742c823a191960895b3d52933cebd7beee26757d1ed694f213fcd867
F test/pragma2.test e5d5c176360c321344249354c0c16aec46214c9f
@@ -1187,6 +1203,7 @@ F test/pragma3.test 8300aa9c63cff1027006ca34bf413a148abbd6dcd471fa9a1ded322fe18c
F test/pragma4.test 52d8186f9e8d09b87189432cdd401dfa66d0b32445e837fa19046c8ae7621b0e
F test/pragma5.test 824ce6ced5d6b7ec71abe37fc6005ff836fe39d638273dc5192b39864b9ee983
F test/pragmafault.test 275edaf3161771d37de60e5c2b412627ac94cef11739236bec12ed1258b240f8
+F test/prefixes.test b524a1c44bffec225b9aec98bd728480352aa8532ac4c15771fb85e8beef65d9
F test/printf.test a3e559bc9d922e7fe44e9d05c6965fee34fe3bc28300a4248c6a063425246ffd
F test/printf2.test 30b5dd0b4b992dc5626496846ecce17ff592cacbcb11c3e589f3ac4d7e129dae
F test/progress.test ebab27f670bd0d4eb9d20d49cef96e68141d92fb
@@ -1205,8 +1222,8 @@ F test/rdonly.test 64e2696c322e3538df0b1ed624e21f9a23ed9ff8
F test/regexp1.test 497ea812f264d12b6198d6e50a76be4a1973a9d8
F test/regexp2.test 40e894223b3d6672655481493f1be12012f2b33c
F test/reindex.test 44edd3966b474468b823d481eafef0c305022254
-F test/releasetest.tcl b290d538ffcb2ff711f09eadc7396c1a42580f3fb078605471dc8875ca0b4d1e x
-F test/resetdb.test 373a9eb8fcbd58bf87affec6a88c6353038f98a5d25be5ab75a0b9636c462a36
+F test/releasetest.tcl 7712811e0f4e2f198ec786cb2e1352b3793d7395f48a3cceef0572d8823eb75e x
+F test/resetdb.test 8062cf10a09d8c048f8de7711e94571c38b38168db0e5877ba7561789e5eeb2b
F test/resolver01.test f4022acafda7f4d40eca94dbf16bc5fc4ac30ceb
F test/rollback.test 06680159bc6746d0f26276e339e3ae2f951c64812468308838e0a3362d911eaa
F test/rollback2.test bc868d57899dc6972e2b4483faae0e03365a0556941474eec487ae21d8d38bb6
@@ -1217,7 +1234,7 @@ F test/rowid.test 5b7509f384f4f6fae1af3c8c104c8ca299fea18d
F test/rowvalue.test b8680f07d19c8c5223b808bba998faffcec6d505f5689ff6070280119173bb51
F test/rowvalue2.test 060d238b7e5639a7c5630cb5e63e311b44efef2b
F test/rowvalue3.test 3068f508753af69884b12125995f023da0dbb256
-F test/rowvalue4.test 2b20468da3775aba971caf3158e9696a4d99c69a7623fb495f332a596daebbee
+F test/rowvalue4.test 02e35f7762371c2f57ebd856aa056eac56cb27ef7715a0bb31eac1895a745356
F test/rowvalue5.test c81c7d8cf36711ab37675ad7376084ae2a359cb6
F test/rowvalue6.test d19b54feb604d5601f8614b15e214e0774c01087
F test/rowvalue7.test 5d06ff19d9e6969e574a2e662a531dd0c67801a8
@@ -1243,7 +1260,7 @@ F test/schema6.test e4bd1f23d368695eb9e7b51ef6e02ca0642ea2ab4a52579959826b5e7dce
F test/schemafault.test 1936bceca55ac82c5efbcc9fc91a1933e45c8d1e1d106b9a7e56c972a5a2a51e
F test/securedel.test 2f70b2449186a1921bd01ec9da407fbfa98c3a7a5521854c300c194b2ff09384
F test/securedel2.test 2d54c28e46eb1fd6902089958b20b1b056c6f1c5
-F test/select1.test 2e760bab8f3658b3b97debcf52860d0d2e20aa6cbe8b40e678ddb99871a15491
+F test/select1.test 7d41f354998524070317207d4e2b68e725e4cf14a57835fc746d4bea686a8714
F test/select2.test 352480e0e9c66eda9c3044e412abdf5be0215b56
F test/select3.test 2ce595f8fb8e2ac10071d3b4e424cadd4634a054
F test/select4.test 5389d9895968d1196c457d59b3ee6515d771d328
@@ -1275,14 +1292,15 @@ F test/sharedA.test 49d87ec54ab640fbbc3786ee3c01de94aaa482a3a9f834ad3fe92770eb69
F test/sharedB.test 16cc7178e20965d75278f410943109b77b2e645e
F test/shared_err.test 32634e404a3317eeb94abc7a099c556a346fdb8fb3858dbe222a4cbb8926a939
F test/sharedlock.test 5ede3c37439067c43b0198f580fd374ebf15d304
-F test/shell1.test d2bf5daeb6f449f0169c9ef3094db17a16a02199c5dcf1a635a3e79b07eb0edd
+F test/shell1.test 0378c4e9e800da6fbb3c86c0c8f2cf5efc9e4155b4b6447d27dc71de648fc0a1
F test/shell2.test e242a9912f44f4c23c3d1d802a83e934e84c853b
F test/shell3.test ac8c2b744014c3e9a0e26bfd829ab65f00923dc1a91ffd044863e9423cc91494
-F test/shell4.test 89ad573879a745974ff2df20ff97c5d6ffffbd5d
+F test/shell4.test 1c6aef11daaa2d6830acaba3ac9cbec93fbc1c3d5530743a637f39b3987d08ce
F test/shell5.test 23939a4c51f0421330ea61dbd3c74f9c215f5f8d3d1a94846da6ffc777a35458
F test/shell6.test 1ceb51b2678c472ba6cf1e5da96679ce8347889fe2c3bf93a0e0fa73f00b00d3
F test/shell7.test 115132f66d0463417f408562cc2cf534f6bbc6d83a6d50f0072a9eb171bae97f
F test/shell8.test 96be02ea0c21f05b24c1883d7b711a1fa8525a68ab7b636aacf6057876941013
+F test/shmlock.test 3dbf017d34ab0c60abe6a44e447d3552154bd0c87b41eaf5ceacd408dd13fda5
F test/shortread1.test bb591ef20f0fd9ed26d0d12e80eee6d7ac8897a3
F test/show_speedtest1_rtree.tcl 32e6c5f073d7426148a6936a0408f4b5b169aba5
F test/shrink.test 1b4330b1fd9e818c04726d45cb28db73087535ce
@@ -1296,7 +1314,7 @@ F test/snapshot.test a504f2e7009f512ef66c719f0ea1c55a556bdaf1e1312c80a04d46fc1a3
F test/snapshot2.test 8d6ff5dd9cc503f6e12d408a30409c3f9c653507b24408d9cd7195931c89bc54
F test/snapshot3.test 8744313270c55f6e18574283553d3c5c5fe4c5970585663613a0e75c151e599b
F test/snapshot4.test d4e9347ef2fcabc491fc893506c7bbaf334da3be111d6eb4f3a97cc623b78322
-F test/snapshot_fault.test 508ae6f211d4991e9ff3b5080aeb0a179bf6755138aabeac4bca8083044d895a
+F test/snapshot_fault.test f6c5ef7cb93bf92fbb4e864ecc5c87df7d3a250064838822db5b4d3a5563ede4
F test/snapshot_up.test a0a29c4cf33475fcef07c3f8e64af795e24ab91b4cc68295863402a393cdd41c
F test/soak.test 18944cf21b94a7fe0df02016a6ee1e9632bc4e8d095a0cb49d95e15d5cca2d5c
F test/softheap1.test 843cd84db9891b2d01b9ab64cef3e9020f98d087
@@ -1343,7 +1361,7 @@ F test/sync.test 89539f4973c010eda5638407e71ca7fddbcd8e0594f4c9980229f804d433309
F test/sync2.test 8f9f7d4f6d5be8ca8941a8dadcc4299e558cb6a1ff653a9469146c7a76ef2039
F test/syscall.test a39d9a36f852ae6e4800f861bc2f2e83f68bbc2112d9399931ecfadeabd2d69d
F test/sysfault.test c9f2b0d8d677558f74de750c75e12a5454719d04
-F test/tabfunc01.test 54300134f76db817685194d2f0e63e3fbf7380b45e0d426e00a9aee752497cfb
+F test/tabfunc01.test 20e98ffe55f35d8d33fd834ca8bf9d4b637e560af8fcd00464b4154d90a4db45
F test/table.test eb3463b7add9f16a5bb836badf118cf391b809d09fdccd1f79684600d07ec132
F test/tableapi.test ecbcc29c4ab62c1912c3717c48ea5c5e59f7d64e4a91034e6148bd2b82f177f4
F test/tableopts.test dba698ba97251017b7c80d738c198d39ab747930
@@ -1355,7 +1373,7 @@ F test/temptable.test d2c9b87a54147161bcd1822e30c1d1cd891e5b30
F test/temptable2.test d2940417496e2b9548e01d09990763fbe88c316504033256d51493e1f1a5ce6a
F test/temptable3.test d11a0974e52b347e45ee54ef1923c91ed91e4637
F test/temptrigger.test 38f0ca479b1822d3117069e014daabcaacefffcc
-F test/tester.tcl fa5656391e3b477508abe12b3b81f019b2e71397399ab38a2f32d8d7f3bf8e56
+F test/tester.tcl 499a5086815aa416d971ff438d7425c64f41ed3233251db4836d270f9a6671e8
F test/thread001.test b61a29dd87cf669f5f6ac96124a7c97d71b0c80d9012746072055877055cf9ef
F test/thread002.test e630504f8a06c00bf8bbe68528774dd96aeb2e58
F test/thread003.test ee4c9efc3b86a6a2767516a37bd64251272560a7
@@ -1530,10 +1548,10 @@ F test/trigger8.test 30cb0530bd7c4728055420e3f739aa00412eafa4
F test/trigger9.test 2226ec795a33b0460ab5cf8891e9054cc7edef41
F test/triggerA.test 837be862d8721f903dba3f3ceff05b32e0bee5214cf6ea3da5fadf12d3650e9d
F test/triggerB.test 56780c031b454abac2340dbb3b71ac5c56c3d7fe
-F test/triggerC.test 302d8995f5ffe63bbc15053abb3ef7a39cf5a092
+F test/triggerC.test c7fbc3eb241b5a7ba4b0815f76c3708483e91890f9573add12a610c45b2a6022
F test/triggerD.test 8e7f3921a92a5797d472732108109e44575fa650
F test/triggerE.test ede2e4bce4ba802337bd69d39447fa04a938e06d84a8bfc53c76850fc36ed86d
-F test/triggerF.test 6a8c22bd058cf467f0c7d112afe87f7a8c579c0c4681b914b8f19020f48528a4
+F test/triggerF.test 5d76f0a8c428ff87a4d5ed52da06f6096a2c787a1e21b846111dfac4123de3ad
F test/triggerG.test d5caeef6144ede2426dd13211fd72248241ff2ebc68e12a4c0bf30f5faa21499
F test/tt3_checkpoint.c 9e75cf7c1c364f52e1c47fd0f14c4340a9db0fe1
F test/tt3_index.c 39eec10a35f57672225be4d182862152896dee4a
@@ -1543,14 +1561,14 @@ F test/tt3_vacuum.c 1753f45917699c9c1f66b64c717a717c9379f776
F test/types.test bf816ce73c7dfcfe26b700c19f97ef4050d194ff
F test/types2.test 1aeb81976841a91eef292723649b5c4fe3bc3cac
F test/types3.test 99e009491a54f4dc02c06bdbc0c5eea56ae3e25a
-F test/unionvtab.test 5ae0f0b4f302a4c6bb310b64386f9ac6a4c1c271c08f31cc7c5d92722e2b2729
+F test/unionvtab.test e1704ab1b4c1bb3ffc9da4681f8e85a0b909fd80b937984fc94b27415ac8e5a4
F test/unionvtabfault.test e8759f3d14fb938ce9657e2342db34aeac0fb9bc1692b0d1ebb0069630151d06
F test/unique.test 93f8b2ef5ea51b9495f8d6493429b1fd0f465264
F test/unique2.test 3674e9f2a3f1fbbfd4772ac74b7a97090d0f77d2
F test/unixexcl.test d936ba2b06794018e136418addd59a2354eeae97
F test/unordered.test ffeea7747d5ba962a8009a20b7e53d68cbae05b063604c68702c5998eb50c981
F test/update.test 1148de8d913e9817717990603aadeca07aab9ddbb10a30f167cbfd8d3a3ccb60
-F test/update2.test 5e67667e1c54017d964e626db765cf8bedcf87483c184f4c575bdb8c1dd2313e
+F test/update2.test 67455bc61fcbcf96923c45b3bc4f87bc72be7d67575ad35f134906148c7b06d3
F test/upsert1.test 994bde41800bb77dbe32fcd2e1f6c4b49cc9f2c6cd345731c774dff02b51c110
F test/upsert2.test 9c3cdbb1a890227f6504ce4b0e3de68f4cdfa16bb21d8641208a9239896c5a09
F test/upsert3.test 88d7d590a1948a9cb6eac1b54b0642f67a9f35a1fc0f19b200e97d5d39e3179c
@@ -1560,6 +1578,7 @@ F test/uri.test 3481026f00ade6dfe8adb7acb6e1e47b04369568
F test/uri2.test 9d3ba7a53ee167572d53a298ee4a5d38ec4a8fb7
F test/userauth01.test e740a2697a7b40d7c5003a7d7edaee16acd349a9
F test/utf16align.test 54cd35a27c005a9b6e7815d887718780b6a462ae
+F test/vacuum-into.test 41d84c0603f3e8f3540321e5974d69008c562238c30924a9390c211a8c0a415e
F test/vacuum.test ce91c39f7f91a4273bf620efad21086b5aa6ef1d
F test/vacuum2.test aa048abee196c16c9ba308465494009057b79f9b
F test/vacuum3.test 77ecdd54592b45a0bcb133339f99f1ae0ae94d0d
@@ -1590,7 +1609,8 @@ F test/vtabJ.test d7b73675708cf63cfcb9d443bb451fc01a028347275b7311e51f9fdf3ca675
F test/vtab_alter.test 736e66fb5ec7b4fee58229aa3ada2f27ec58bc58c00edae4836890c3784c6783
F test/vtab_err.test dcc8b7b9cb67522b3fe7a272c73856829dae4ab7fdb30399aea1b6981bda2b65
F test/vtab_shared.test 5253bff2355a9a3f014c15337da7e177ab0ef8ad
-F test/wal.test 613efec03e517e1775d86b993a54877d2e29a477
+F test/vtabdrop.test 65d4cf6722972e5499bdaf0c0d70ee3b8133944a4e4bc31862563f32a7edca12
+F test/wal.test cdf0ca6cc0447520d19ef1c83287824ebeb3e82d75af856511ba96841a79fc9b
F test/wal2.test 155b9efa999bdb38ce1cd729b9a4fcdbffd6b88be27f039bad1d2929d287d918
F test/wal3.test 2a93004bc0fb2b5c29888964024695bade278ab2
F test/wal4.test 4744e155cd6299c6bd99d3eab1c82f77db9cdb3c
@@ -1610,6 +1630,7 @@ F test/walcrash2.test a0edab4e5390f03b99a790de89aad15d6ec70b36
F test/walcrash3.test e426aa58122d20f2b9fbe9a507f9eb8cab85b8af
F test/walcrash4.test e7b6e7639a950a0cca8e210e248c8dad4d63bf20
F test/walfault.test 09b8ad7e52d2f54bce50e31aa7ea51412bb9f70ac13c74e669ddcd8b48b0d98d
+F test/walfault2.test e039ac66c78d5561683cacde04097213cdad3b58e2b3f3fe1112862217bfd915
F test/walhook.test ed00a40ba7255da22d6b66433ab61fab16a63483
F test/walmode.test cd6e7cff618eaaa5910ce57c3657aa50110397f86213886a2400afb9bfec7b7b
F test/walnoshm.test 84ca10c544632a756467336b7c3b864d493ee496
@@ -1623,15 +1644,16 @@ F test/walrofault.test c70cb6e308c443867701856cce92ad8288cd99488fa52afab77cca6cf
F test/walshared.test 0befc811dcf0b287efae21612304d15576e35417
F test/walslow.test c05c68d4dc2700a982f89133ce103a1a84cc285f
F test/walthread.test 14b20fcfa6ae152f5d8e12f5dc8a8a724b7ef189f5d8ef1e2ceab79f2af51747
+F test/walvfs.test c0faffda13d045a96dfc541347886bb1a3d6f3205857fc98e683edfab766ea88
F test/where.test 8215d220633f08da331781cf9ede7fb7aed50eb113473c10acd39a643fd258ba
F test/where2.test 478d2170637b9211f593120648858593bf2445a1
F test/where3.test 2341a294e17193a6b1699ea7f192124a5286ca6acfcc3f4b06d16c931fbcda2c
F test/where4.test 4a371bfcc607f41d233701bdec33ac2972908ba8
F test/where5.test fdf66f96d29a064b63eb543e28da4dfdccd81ad2
F test/where6.test 5da5a98cec820d488e82708301b96cb8c18a258b
-F test/where7.test e579da972eb3372edc9de850efc221848c763f9e4feafc8426d84a4453b92b23
+F test/where7.test 75722434c486ac9e74718caa6cce234f45ba34c0b6c0f9555b29eb8bb5f6ade1
F test/where8.test 461ca40265ed996a6305da99bb024b0e41602bb586acf544c08f95922358e49f
-F test/where9.test ad2ddb339d10d324763c3da60502b8631f15a2397b869192fbd4e82f40e167d3
+F test/where9.test 4fb43ad451758d9535693e110d4398fb6a6e3e153dc57bba5e61f884566c725f
F test/whereA.test 6c6a420ca7d313242f9b1bd471dc80e4d0f8323700ba9c78df0bb843d4daa3b4
F test/whereB.test 0def95db3bdec220a731c7e4bec5930327c1d8c5
F test/whereC.test cae295158703cb3fc23bf1a108a9ab730efff0f6
@@ -1640,7 +1662,7 @@ F test/whereE.test b3a055eef928c992b0a33198a7b8dc10eea5ad2f
F test/whereF.test 3d9412b1199d3e2bed34fcb76b4c48d0bf4df95d27e3f8dd27b6f8b4716d0d89
F test/whereG.test 0158783235a6dd82fc0e37652b8522b186b9510594ac0a4bff0c4101b4396a52
F test/whereH.test e4b07f7a3c2f5d31195cd33710054c78667573b2
-F test/whereI.test b7769ee8dbefd987fb266715fee887f05f9ff180016b06fca7fa402df739193b
+F test/whereI.test a2874062140ed4aba9ffae76e6190a3df6fc73d1373fdfa8fd632945082a5364
F test/whereJ.test 88287550f6ee604422403b053455b1ad894eeaa5c35d348532dfa1439286cb9a
F test/whereK.test f8e3cf26a8513ecc7f514f54df9f0572c046c42b
F test/whereL.test 0a19fc44cd1122040f56c934f1b14d0ca85bde28f270268a428dd9796ea0634c
@@ -1653,7 +1675,7 @@ F test/win32heap.test 10fd891266bd00af68671e702317726375e5407561d859be1aa04696f2
F test/win32lock.test fbf107c91d8f5512be5a5b87c4c42ab9fdd54972
F test/win32longpath.test 169c75a3b2e43481f4a62122510210c67b08f26d
F test/win32nolock.test ac4f08811a562e45a5755e661f45ca85892bdbbc
-F test/window1.test 02e481ac48c445b43bab7b3cf1e4115165b5127a1aa29e14f5372922c836f1a4
+F test/window1.test 2798c8249e0f122c9bacce6aa7324765a5cd9106e49e7aacc81f6033d281577b
F test/window2.tcl 9bfa842d8a62b0d36dc8c1b5972206393c43847433c6d75940b87fec93ce3143
F test/window2.test 8e6d2a1b9f54dfebee1cde961c8590cd87b4db45c50f44947a211e1b63c2a05e
F test/window3.tcl 577a3b1ff913208e5248c04dab9df17fd760ce159a752789e26d0cb4a5f91823
@@ -1663,9 +1685,9 @@ F test/window4.test c5d6bf3403e4ade2f19df2afe4c16f29fb817c392c6c1c8017edb7165c19
F test/window5.test d328dd18221217c49c144181975eea17339eaeaf0e9aa558cee3afb84652821e
F test/window6.test 5eae4ae7a590ccf1e605880969ca0bad3955616ac91cad3031baea38748badb3
F test/windowfault.test 12ceb6bbb355d13e8fcd88c5731a57256dfdf77b9a7ae20842a76fcd4623df5b
-F test/with1.test 2465d98ffce80d00553ac7135697c18b0369275b6ecc750daa2af320b8c812ca
+F test/with1.test a07b5aad7f77acdf13e52e8814ea94606fcc72e9ea4c99baf293e9d7c63940be
F test/with2.test e0030e2f0267a910d6c0e4f46f2dfe941c1cc0d4f659ba69b3597728e7e8f1ab
-F test/with3.test 5e8ce2c585170bbbc0544e2a01a4941fa0be173ba5265e5c92eb588cd99a232d
+F test/with3.test 8d26920c88283e0a473ceebd3451554922108ce7b2a6a1157c47eb0a7011212c
F test/with4.test 257be66c0c67fee1defbbac0f685c3465e2cad037f21ce65f23f86084f198205
F test/withM.test 693b61765f2b387b5e3e24a4536e2e82de15ff64
F test/without_rowid1.test 533add9100255e4cc430d371b3ecfb79f11f956b86c3a1b9d34413bf8e482d8f
@@ -1676,7 +1698,7 @@ F test/without_rowid5.test 89b1c587bd92a0590e440da33e7666bf4891572a
F test/without_rowid6.test 1f99644e6508447fb050f73697350c7ceca3392e
F test/wordcount.c d721a4b6fae93e6e33449700bce1686bc23257c27425bc3ef1599dc912adec66
F test/writecrash.test f1da7f7adfe8d7f09ea79b42e5ca6dcc41102f27f8e334ad71539501ddd910cc
-F test/zeroblob.test 3857870fe681b8185654414a9bccfde80b62a0fa
+F test/zeroblob.test 07a5b11ab591d1f26c626945fb7f228f68b993533b2ada77273edf6ee29db174
F test/zerodamage.test 9c41628db7e8d9e8a0181e59ea5f189df311a9f6ce99cc376dc461f66db6f8dc
F test/zipfile.test b3b558639f7a103e095713ad0f57fec1fce1b7d60c8054df5789b98f7547a395
F test/zipfile2.test 9903388a602a3834189857a985106ff95c3bba6a3969e0134127df991889db5d
@@ -1690,6 +1712,8 @@ F tool/build-shell.sh 950f47c6174f1eea171319438b93ba67ff5bf367
F tool/cg_anno.tcl f95b0006c52cf7f0496b506343415b6ee3cdcdd3 x
F tool/checkSpacing.c 810e51703529a204fc4e1eb060e9ab663e3c06d2
F tool/dbhash.c a06228aa21ebc4e6ea8daa486601d938499238a5
+F tool/dbtotxt.c 04e25f26be7c7743cdfb4111a8483de0b111925d6afeeb7559ade0ceb73f7f52
+F tool/dbtotxt.md c9a57af8739957ef36d2cfad5c4b1443ff3688ed33e4901ee200c8b651f43f3c
F tool/extract.c 054069d81b095fbdc189a6f5d4466e40380505e2
F tool/fast_vacuum.c 5ba0d6f5963a0a63bdc42840f678bad75b2ebce1
F tool/fragck.tcl 5265a95126abcf6ab357f7efa544787e5963f439
@@ -1697,9 +1721,10 @@ F tool/fuzzershell.c e1d90a03ca790d7c331c2aae08ca46ff435f1ae1faa6cb9cc48f4687c18
F tool/genfkey.README cf68fddd4643bbe3ff8e31b8b6d8b0a1b85e20f4
F tool/genfkey.test b6afd7b825d797a1e1274f519ab5695373552ecad5cd373530c63533638a5a4f
F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce
+F tool/index_usage.c 9ec344d29cbeb03fdc0fce668eedfb7495792170de933adf95cf8d6904a166ad
F tool/kvtest-speed.sh 4761a9c4b3530907562314d7757995787f7aef8f
-F tool/lemon.c 60d1e1eb0f7ebae709f68f1472d77fbf291c5345cd98ff417219da7e74fd09e9
-F tool/lempar.c 452f12d40229847634a160e5666b6c4ec4392fd81941c3443861b48d497054cc
+F tool/lemon.c 900a15b9efba9890d10e7959914db94c4ad5162912127f061c4328add122d6fb
+F tool/lempar.c 61af95b8fac2bfd59c09d55330e78f3f5e352d7aa80bf37404b96ef795be3fdc
F tool/libvers.c caafc3b689638a1d88d44bc5f526c2278760d9b9
F tool/loadfts.c c3c64e4d5e90e8ba41159232c2189dba4be7b862
F tool/logest.c 11346aa019e2e77a00902aa7d0cabd27bd2e8cca
@@ -1712,7 +1737,7 @@ F tool/mkmsvcmin.tcl cad0c7b54d7dd92bc87d59f36d4cc4f070eb2e625f14159dc2f5c4204e6
F tool/mkopcodec.tcl d1b6362bd3aa80d5520d4d6f3765badf01f6c43c
F tool/mkopcodeh.tcl 352a4319c0ad869eb26442bf7c3b015aa15594c21f1cce5a6420dbe999367c21
F tool/mkopts.tcl 680f785fdb09729fd9ac50632413da4eadbdf9071535e3f26d03795828ab07fa
-F tool/mkpragmatab.tcl a1334e70a08fdf5de32cd0093613212bb11ac8f880487540987175c536ac335f
+F tool/mkpragmatab.tcl 49039adedafbc430d2959400da2e0e8f20ef8dcf6898e447c946e7d50ef5906b
F tool/mkshellc.tcl 1f45770aea226ac093a9c72f718efbb88a2a2833409ec2e1c4cecae4202626f5
F tool/mksourceid.c d458f9004c837bee87a6382228ac20d3eae3c49ea3b0a5aace936f8b60748d3b
F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97
@@ -1779,11 +1804,11 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 23684cb841ac2cb0d69e5470253bd96feb733762a7553b952a08470834fe85fa
-R dcc394af10af6094607f56a6086fb748
+P d5d944d7947d7b44ba9a1c844418af49c5f39dbe84f181af790bb1412daed578
+R 2251df76230cd55e64293ef8a825ebab
T +bgcolor * #d0c0ff
T +sym-release *
-T +sym-version-3.26.0 *
+T +sym-version-3.27.1 *
U drh
-Z 560a5decbb241d53eb97e72267b6e6e8
+Z 4aa002629995b65b1d5f498ebad69e25
# Remove this line to create a well-formed manifest.
diff --git a/chromium/third_party/sqlite/src/manifest.uuid b/chromium/third_party/sqlite/src/manifest.uuid
index 166b1b3d3af..68364f77ee9 100644
--- a/chromium/third_party/sqlite/src/manifest.uuid
+++ b/chromium/third_party/sqlite/src/manifest.uuid
@@ -1 +1 @@
-bf8c1b2b7a5960c282e543b9c293686dccff272512d08865f4600fb58238b4f9
+0eca3dd3d38b31c92b49ca2d311128b74584714d9e7de895b1a6286ef959a1dd
diff --git a/chromium/third_party/sqlite/src/src/alter.c b/chromium/third_party/sqlite/src/src/alter.c
index fcddc40d0c5..408270854a6 100644
--- a/chromium/third_party/sqlite/src/src/alter.c
+++ b/chromium/third_party/sqlite/src/src/alter.c
@@ -28,9 +28,16 @@
**
** Or, if zName is not a system table, zero is returned.
*/
-static int isSystemTable(Parse *pParse, const char *zName){
- if( 0==sqlite3StrNICmp(zName, "sqlite_", 7) ){
- sqlite3ErrorMsg(pParse, "table %s may not be altered", zName);
+static int isAlterableTable(Parse *pParse, Table *pTab){
+ if( 0==sqlite3StrNICmp(pTab->zName, "sqlite_", 7)
+#ifndef SQLITE_OMIT_VIRTUALTABLE
+ || ( (pTab->tabFlags & TF_Shadow)
+ && (pParse->db->flags & SQLITE_Defensive)
+ && pParse->db->nVdbeExec==0
+ )
+#endif
+ ){
+ sqlite3ErrorMsg(pParse, "table %s may not be altered", pTab->zName);
return 1;
}
return 0;
@@ -126,7 +133,7 @@ void sqlite3AlterRenameTable(
/* Make sure it is not a system table being altered, or a reserved name
** that the table is being renamed to.
*/
- if( SQLITE_OK!=isSystemTable(pParse, pTab->zName) ){
+ if( SQLITE_OK!=isAlterableTable(pParse, pTab) ){
goto exit_rename_table;
}
if( SQLITE_OK!=sqlite3CheckObjectName(pParse, zName) ){ goto
@@ -424,7 +431,7 @@ void sqlite3AlterBeginAddColumn(Parse *pParse, SrcList *pSrc){
sqlite3ErrorMsg(pParse, "Cannot add a column to a view");
goto exit_begin_add_column;
}
- if( SQLITE_OK!=isSystemTable(pParse, pTab->zName) ){
+ if( SQLITE_OK!=isAlterableTable(pParse, pTab) ){
goto exit_begin_add_column;
}
@@ -526,7 +533,7 @@ void sqlite3AlterRenameColumn(
if( !pTab ) goto exit_rename_column;
/* Cannot alter a system table */
- if( SQLITE_OK!=isSystemTable(pParse, pTab->zName) ) goto exit_rename_column;
+ if( SQLITE_OK!=isAlterableTable(pParse, pTab) ) goto exit_rename_column;
if( SQLITE_OK!=isRealTable(pParse, pTab) ) goto exit_rename_column;
/* Which schema holds the table to be altered */
@@ -781,13 +788,30 @@ static void renameTokenFind(Parse *pParse, struct RenameCtx *pCtx, void *pPtr){
}
/*
+** Iterate through the Select objects that are part of WITH clauses attached
+** to select statement pSelect.
+*/
+static void renameWalkWith(Walker *pWalker, Select *pSelect){
+ if( pSelect->pWith ){
+ int i;
+ for(i=0; i<pSelect->pWith->nCte; i++){
+ Select *p = pSelect->pWith->a[i].pSelect;
+ NameContext sNC;
+ memset(&sNC, 0, sizeof(sNC));
+ sNC.pParse = pWalker->pParse;
+ sqlite3SelectPrep(sNC.pParse, p, &sNC);
+ sqlite3WalkSelect(pWalker, p);
+ }
+ }
+}
+
+/*
** This is a Walker select callback. It does nothing. It is only required
** because without a dummy callback, sqlite3WalkExpr() and similar do not
** descend into sub-select statements.
*/
static int renameColumnSelectCb(Walker *pWalker, Select *p){
- UNUSED_PARAMETER(pWalker);
- UNUSED_PARAMETER(p);
+ renameWalkWith(pWalker, p);
return WRC_Continue;
}
@@ -937,7 +961,6 @@ static int renameParseSql(
rc = sqlite3RunParser(p, zSql, &zErr);
assert( p->zErrMsg==0 );
assert( rc!=SQLITE_OK || zErr==0 );
- assert( (0!=p->pNewTable) + (0!=p->pNewIndex) + (0!=p->pNewTrigger)<2 );
p->zErrMsg = zErr;
if( db->mallocFailed ) rc = SQLITE_NOMEM;
if( rc==SQLITE_OK
@@ -1120,6 +1143,7 @@ static int renameResolveTrigger(Parse *pParse, const char *zDb){
}
sNC.ncFlags = 0;
}
+ sNC.pSrcList = 0;
}
}
}
@@ -1157,11 +1181,15 @@ static void renameWalkTrigger(Walker *pWalker, Trigger *pTrigger){
*/
static void renameParseCleanup(Parse *pParse){
sqlite3 *db = pParse->db;
+ Index *pIdx;
if( pParse->pVdbe ){
sqlite3VdbeFinalize(pParse->pVdbe);
}
sqlite3DeleteTable(db, pParse->pNewTable);
- if( pParse->pNewIndex ) sqlite3FreeIndex(db, pParse->pNewIndex);
+ while( (pIdx = pParse->pNewIndex)!=0 ){
+ pParse->pNewIndex = pIdx->pNext;
+ sqlite3FreeIndex(db, pIdx);
+ }
sqlite3DeleteTrigger(db, pParse->pNewTrigger);
sqlite3DbFree(db, pParse->zErrMsg);
renameTokenFree(db, pParse->pRename);
@@ -1272,6 +1300,9 @@ static void renameColumnFunc(
for(pIdx=sParse.pNewTable->pIndex; pIdx; pIdx=pIdx->pNext){
sqlite3WalkExprList(&sWalker, pIdx->aColExpr);
}
+ for(pIdx=sParse.pNewIndex; pIdx; pIdx=pIdx->pNext){
+ sqlite3WalkExprList(&sWalker, pIdx->aColExpr);
+ }
}
for(pFKey=sParse.pNewTable->pFKey; pFKey; pFKey=pFKey->pNextFrom){
@@ -1358,12 +1389,17 @@ static int renameTableSelectCb(Walker *pWalker, Select *pSelect){
int i;
RenameCtx *p = pWalker->u.pRename;
SrcList *pSrc = pSelect->pSrc;
+ if( pSrc==0 ){
+ assert( pWalker->pParse->db->mallocFailed );
+ return WRC_Abort;
+ }
for(i=0; i<pSrc->nSrc; i++){
struct SrcList_item *pItem = &pSrc->a[i];
if( pItem->pTab==p->pTab ){
renameTokenFind(pWalker->pParse, p, pItem->zName);
}
}
+ renameWalkWith(pWalker, pSelect);
return WRC_Continue;
}
diff --git a/chromium/third_party/sqlite/src/src/analyze.c b/chromium/third_party/sqlite/src/src/analyze.c
index 6fbf46a9d2c..2b324ec8130 100644
--- a/chromium/third_party/sqlite/src/src/analyze.c
+++ b/chromium/third_party/sqlite/src/src/analyze.c
@@ -1156,7 +1156,7 @@ static void analyzeOneTable(
addrNextRow = sqlite3VdbeCurrentAddr(v);
if( nColTest>0 ){
- int endDistinctTest = sqlite3VdbeMakeLabel(v);
+ int endDistinctTest = sqlite3VdbeMakeLabel(pParse);
int *aGotoChng; /* Array of jump instruction addresses */
aGotoChng = sqlite3DbMallocRawNN(db, sizeof(int)*nColTest);
if( aGotoChng==0 ) continue;
diff --git a/chromium/third_party/sqlite/src/src/attach.c b/chromium/third_party/sqlite/src/src/attach.c
index fcb05046de2..02af65ce3ea 100644
--- a/chromium/third_party/sqlite/src/src/attach.c
+++ b/chromium/third_party/sqlite/src/src/attach.c
@@ -155,8 +155,8 @@ static void attachFunc(
assert( pVfs );
flags |= SQLITE_OPEN_MAIN_DB;
rc = sqlite3BtreeOpen(pVfs, zPath, db, &pNew->pBt, 0, flags);
- sqlite3_free( zPath );
db->nDb++;
+ pNew->zDbSName = sqlite3DbStrDup(db, zName);
}
db->noSharedCache = 0;
if( rc==SQLITE_CONSTRAINT ){
@@ -184,7 +184,6 @@ static void attachFunc(
sqlite3BtreeLeave(pNew->pBt);
}
pNew->safety_level = SQLITE_DEFAULT_SYNCHRONOUS+1;
- if( !REOPEN_AS_MEMDB(db) ) pNew->zDbSName = sqlite3DbStrDup(db, zName);
if( rc==SQLITE_OK && pNew->zDbSName==0 ){
rc = SQLITE_NOMEM_BKPT;
}
@@ -212,15 +211,19 @@ static void attachFunc(
break;
case SQLITE_NULL:
- /* No key specified. Use the key from the main database */
- sqlite3CodecGetKey(db, 0, (void**)&zKey, &nKey);
- if( nKey || sqlite3BtreeGetOptimalReserve(db->aDb[0].pBt)>0 ){
- rc = sqlite3CodecAttach(db, db->nDb-1, zKey, nKey);
+ /* No key specified. Use the key from URI filename, or if none,
+ ** use the key from the main database. */
+ if( sqlite3CodecQueryParameters(db, zName, zPath)==0 ){
+ sqlite3CodecGetKey(db, 0, (void**)&zKey, &nKey);
+ if( nKey || sqlite3BtreeGetOptimalReserve(db->aDb[0].pBt)>0 ){
+ rc = sqlite3CodecAttach(db, db->nDb-1, zKey, nKey);
+ }
}
break;
}
}
#endif
+ sqlite3_free( zPath );
/* If the file was opened successfully, read the schema for the new database.
** If this fails, or if opening the file failed, then close the file and
diff --git a/chromium/third_party/sqlite/src/src/btree.c b/chromium/third_party/sqlite/src/src/btree.c
index eaff20b24e2..773be164691 100644
--- a/chromium/third_party/sqlite/src/src/btree.c
+++ b/chromium/third_party/sqlite/src/src/btree.c
@@ -804,11 +804,12 @@ static int btreeMoveto(
UnpackedRecord *pIdxKey; /* Unpacked index key */
if( pKey ){
+ KeyInfo *pKeyInfo = pCur->pKeyInfo;
assert( nKey==(i64)(int)nKey );
- pIdxKey = sqlite3VdbeAllocUnpackedRecord(pCur->pKeyInfo);
+ pIdxKey = sqlite3VdbeAllocUnpackedRecord(pKeyInfo);
if( pIdxKey==0 ) return SQLITE_NOMEM_BKPT;
- sqlite3VdbeRecordUnpack(pCur->pKeyInfo, (int)nKey, pKey, pIdxKey);
- if( pIdxKey->nField==0 ){
+ sqlite3VdbeRecordUnpack(pKeyInfo, (int)nKey, pKey, pIdxKey);
+ if( pIdxKey->nField==0 || pIdxKey->nField>pKeyInfo->nAllField ){
rc = SQLITE_CORRUPT_BKPT;
goto moveto_done;
}
@@ -844,7 +845,7 @@ static int btreeRestoreCursorPosition(BtCursor *pCur){
sqlite3_free(pCur->pKey);
pCur->pKey = 0;
assert( pCur->eState==CURSOR_VALID || pCur->eState==CURSOR_INVALID );
- pCur->skipNext |= skipNext;
+ if( skipNext ) pCur->skipNext = skipNext;
if( pCur->skipNext && pCur->eState==CURSOR_VALID ){
pCur->eState = CURSOR_SKIPNEXT;
}
@@ -914,7 +915,6 @@ int sqlite3BtreeCursorRestore(BtCursor *pCur, int *pDifferentRow){
if( pCur->eState!=CURSOR_VALID ){
*pDifferentRow = 1;
}else{
- assert( pCur->skipNext==0 );
*pDifferentRow = 0;
}
return SQLITE_OK;
@@ -1365,7 +1365,7 @@ static u16 cellSize(MemPage *pPage, int iCell){
** 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, MemPage *pSrc, u8 *pCell, int *pRC){
+static void ptrmapPutOvflPtr(MemPage *pPage, MemPage *pSrc, u8 *pCell,int *pRC){
CellInfo info;
if( *pRC ) return;
assert( pCell!=0 );
@@ -1440,7 +1440,6 @@ static int defragmentPage(MemPage *pPage, int nMaxFrag){
if( iFree ){
int iFree2 = get2byte(&data[iFree]);
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];
u8 *pAddr;
@@ -3104,6 +3103,7 @@ static int lockBtree(BtShared *pBt){
){
goto page1_init_failed;
}
+ pBt->btsFlags |= BTS_PAGESIZE_FIXED;
assert( (pageSize & 7)==0 );
/* EVIDENCE-OF: R-59310-51205 The "reserved space" size in the 1-byte
** integer at offset 20 is the number of bytes of space at the end of
@@ -4420,6 +4420,7 @@ int sqlite3BtreeCloseCursor(BtCursor *pCur){
sqlite3_free(pCur->aOverflow);
sqlite3_free(pCur->pKey);
sqlite3BtreeLeave(pBtree);
+ pCur->pBtree = 0;
}
return SQLITE_OK;
}
@@ -4519,6 +4520,25 @@ u32 sqlite3BtreePayloadSize(BtCursor *pCur){
}
/*
+** Return an upper bound on the size of any record for the table
+** that the cursor is pointing into.
+**
+** This is an optimization. Everything will still work if this
+** routine always returns 2147483647 (which is the largest record
+** that SQLite can handle) or more. But returning a smaller value might
+** prevent large memory allocations when trying to interpret a
+** corrupt datrabase.
+**
+** The current implementation merely returns the size of the underlying
+** database file.
+*/
+sqlite3_int64 sqlite3BtreeMaxRecordSize(BtCursor *pCur){
+ assert( cursorHoldsMutex(pCur) );
+ assert( pCur->eState==CURSOR_VALID );
+ return pCur->pBt->pageSize * (sqlite3_int64)pCur->pBt->nPage;
+}
+
+/*
** Given the page number of an overflow page in the database (parameter
** ovfl), this function finds the page number of the next page in the
** linked list of overflow pages. If possible, it uses the auto-vacuum
@@ -5332,7 +5352,7 @@ int sqlite3BtreeMovetoUnpacked(
** try to get there using sqlite3BtreeNext() rather than a full
** binary search. This is an optimization only. The correct answer
** is still obtained without this case, only a little more slowely */
- if( pCur->info.nKey+1==intKey && !pCur->skipNext ){
+ if( pCur->info.nKey+1==intKey ){
*pRes = 0;
rc = sqlite3BtreeNext(pCur, 0);
if( rc==SQLITE_OK ){
@@ -5606,7 +5626,6 @@ static SQLITE_NOINLINE int btreeNext(BtCursor *pCur){
MemPage *pPage;
assert( cursorOwnsBtShared(pCur) );
- assert( pCur->skipNext==0 || pCur->eState!=CURSOR_VALID );
if( pCur->eState!=CURSOR_VALID ){
assert( (pCur->curFlags & BTCF_ValidOvfl)==0 );
rc = restoreCursorPosition(pCur);
@@ -5616,14 +5635,9 @@ static SQLITE_NOINLINE int btreeNext(BtCursor *pCur){
if( CURSOR_INVALID==pCur->eState ){
return SQLITE_DONE;
}
- if( pCur->skipNext ){
- assert( pCur->eState==CURSOR_VALID || pCur->eState==CURSOR_SKIPNEXT );
+ if( pCur->eState==CURSOR_SKIPNEXT ){
pCur->eState = CURSOR_VALID;
- if( pCur->skipNext>0 ){
- pCur->skipNext = 0;
- return SQLITE_OK;
- }
- pCur->skipNext = 0;
+ if( pCur->skipNext>0 ) return SQLITE_OK;
}
}
@@ -5678,7 +5692,6 @@ int sqlite3BtreeNext(BtCursor *pCur, int flags){
UNUSED_PARAMETER( flags ); /* Used in COMDB2 but not native SQLite */
assert( cursorOwnsBtShared(pCur) );
assert( flags==0 || flags==1 );
- assert( pCur->skipNext==0 || pCur->eState!=CURSOR_VALID );
pCur->info.nSize = 0;
pCur->curFlags &= ~(BTCF_ValidNKey|BTCF_ValidOvfl);
if( pCur->eState!=CURSOR_VALID ) return btreeNext(pCur);
@@ -5719,7 +5732,6 @@ static SQLITE_NOINLINE int btreePrevious(BtCursor *pCur){
MemPage *pPage;
assert( cursorOwnsBtShared(pCur) );
- assert( pCur->skipNext==0 || pCur->eState!=CURSOR_VALID );
assert( (pCur->curFlags & (BTCF_AtLast|BTCF_ValidOvfl|BTCF_ValidNKey))==0 );
assert( pCur->info.nSize==0 );
if( pCur->eState!=CURSOR_VALID ){
@@ -5730,14 +5742,9 @@ static SQLITE_NOINLINE int btreePrevious(BtCursor *pCur){
if( CURSOR_INVALID==pCur->eState ){
return SQLITE_DONE;
}
- if( pCur->skipNext ){
- assert( pCur->eState==CURSOR_VALID || pCur->eState==CURSOR_SKIPNEXT );
+ if( CURSOR_SKIPNEXT==pCur->eState ){
pCur->eState = CURSOR_VALID;
- if( pCur->skipNext<0 ){
- pCur->skipNext = 0;
- return SQLITE_OK;
- }
- pCur->skipNext = 0;
+ if( pCur->skipNext<0 ) return SQLITE_OK;
}
}
@@ -5772,7 +5779,6 @@ static SQLITE_NOINLINE int btreePrevious(BtCursor *pCur){
int sqlite3BtreePrevious(BtCursor *pCur, int flags){
assert( cursorOwnsBtShared(pCur) );
assert( flags==0 || flags==1 );
- assert( pCur->skipNext==0 || pCur->eState!=CURSOR_VALID );
UNUSED_PARAMETER( flags ); /* Used in COMDB2 but not native SQLite */
pCur->curFlags &= ~(BTCF_AtLast|BTCF_ValidOvfl|BTCF_ValidNKey);
pCur->info.nSize = 0;
@@ -6108,7 +6114,7 @@ static int allocateBtreePage(
TRACE(("ALLOCATE: %d from end of file\n", *pPgno));
}
- assert( *pPgno!=PENDING_BYTE_PAGE(pBt) );
+ assert( CORRUPT_DB || *pPgno!=PENDING_BYTE_PAGE(pBt) );
end_allocate_page:
releasePage(pTrunk);
@@ -6693,8 +6699,82 @@ static void insertCell(
}
/*
+** The following parameters determine how many adjacent pages get involved
+** in a balancing operation. NN is the number of neighbors on either side
+** of the page that participate in the balancing operation. NB is the
+** total number of pages that participate, including the target page and
+** NN neighbors on either side.
+**
+** The minimum value of NN is 1 (of course). Increasing NN above 1
+** (to 2 or 3) gives a modest improvement in SELECT and DELETE performance
+** in exchange for a larger degradation in INSERT and UPDATE performance.
+** The value of NN appears to give the best results overall.
+**
+** (Later:) The description above makes it seem as if these values are
+** tunable - as if you could change them and recompile and it would all work.
+** But that is unlikely. NB has been 3 since the inception of SQLite and
+** we have never tested any other value.
+*/
+#define NN 1 /* Number of neighbors on either side of pPage */
+#define NB 3 /* (NN*2+1): Total pages involved in the balance */
+
+/*
** A CellArray object contains a cache of pointers and sizes for a
** consecutive sequence of cells that might be held on multiple pages.
+**
+** The cells in this array are the divider cell or cells from the pParent
+** page plus up to three child pages. There are a total of nCell cells.
+**
+** pRef is a pointer to one of the pages that contributes cells. This is
+** used to access information such as MemPage.intKey and MemPage.pBt->pageSize
+** which should be common to all pages that contribute cells to this array.
+**
+** apCell[] and szCell[] hold, respectively, pointers to the start of each
+** cell and the size of each cell. Some of the apCell[] pointers might refer
+** to overflow cells. In other words, some apCel[] pointers might not point
+** to content area of the pages.
+**
+** A szCell[] of zero means the size of that cell has not yet been computed.
+**
+** The cells come from as many as four different pages:
+**
+** -----------
+** | Parent |
+** -----------
+** / | \
+** / | \
+** --------- --------- ---------
+** |Child-1| |Child-2| |Child-3|
+** --------- --------- ---------
+**
+** The order of cells is in the array is for an index btree is:
+**
+** 1. All cells from Child-1 in order
+** 2. The first divider cell from Parent
+** 3. All cells from Child-2 in order
+** 4. The second divider cell from Parent
+** 5. All cells from Child-3 in order
+**
+** For a table-btree (with rowids) the items 2 and 4 are empty because
+** content exists only in leaves and there are no divider cells.
+**
+** For an index btree, the apEnd[] array holds pointer to the end of page
+** for Child-1, the Parent, Child-2, the Parent (again), and Child-3,
+** respectively. The ixNx[] array holds the number of cells contained in
+** each of these 5 stages, and all stages to the left. Hence:
+**
+** ixNx[0] = Number of cells in Child-1.
+** ixNx[1] = Number of cells in Child-1 plus 1 for first divider.
+** ixNx[2] = Number of cells in Child-1 and Child-2 + 1 for 1st divider.
+** ixNx[3] = Number of cells in Child-1 and Child-2 + both divider cells
+** ixNx[4] = Total number of cells.
+**
+** For a table-btree, the concept is similar, except only apEnd[0]..apEnd[2]
+** are used and they point to the leaf pages only, and the ixNx value are:
+**
+** ixNx[0] = Number of cells in Child-1.
+** ixNx[1] = Number of cells in Child-1 and Child-2 + 1 for 1st divider.
+** ixNx[2] = Number of cells in Child-1 and Child-2 + both divider cells
*/
typedef struct CellArray CellArray;
struct CellArray {
@@ -6702,6 +6782,8 @@ struct CellArray {
MemPage *pRef; /* Reference page */
u8 **apCell; /* All cells begin balanced */
u16 *szCell; /* Local size of all cells in apCell[] */
+ u8 *apEnd[NB*2]; /* MemPage.aDataEnd values */
+ int ixNx[NB*2]; /* Index of at which we move to the next apEnd[] */
};
/*
@@ -6752,37 +6834,59 @@ static u16 cachedCellSize(CellArray *p, int N){
** responsibility of the caller to set it correctly.
*/
static int rebuildPage(
- MemPage *pPg, /* Edit this page */
+ CellArray *pCArray, /* Content to be added to page pPg */
+ int iFirst, /* First cell in pCArray to use */
int nCell, /* Final number of cells on page */
- u8 **apCell, /* Array of cells */
- u16 *szCell /* Array of cell sizes */
+ MemPage *pPg /* The page to be reconstructed */
){
const int hdr = pPg->hdrOffset; /* Offset of header on pPg */
u8 * const aData = pPg->aData; /* Pointer to data for pPg */
const int usableSize = pPg->pBt->usableSize;
u8 * const pEnd = &aData[usableSize];
- int i;
+ int i = iFirst; /* Which cell to copy from pCArray*/
+ u32 j; /* Start of cell content area */
+ int iEnd = i+nCell; /* Loop terminator */
u8 *pCellptr = pPg->aCellIdx;
u8 *pTmp = sqlite3PagerTempSpace(pPg->pBt->pPager);
u8 *pData;
+ int k; /* Current slot in pCArray->apEnd[] */
+ u8 *pSrcEnd; /* Current pCArray->apEnd[k] value */
+
+ assert( i<iEnd );
+ j = get2byte(&aData[hdr+5]);
+ if( NEVER(j>(u32)usableSize) ){ j = 0; }
+ memcpy(&pTmp[j], &aData[j], usableSize - j);
- i = get2byte(&aData[hdr+5]);
- memcpy(&pTmp[i], &aData[i], usableSize - i);
+ for(k=0; pCArray->ixNx[k]<=i && ALWAYS(k<NB*2); k++){}
+ pSrcEnd = pCArray->apEnd[k];
pData = pEnd;
- for(i=0; i<nCell; i++){
- u8 *pCell = apCell[i];
+ while( 1/*exit by break*/ ){
+ u8 *pCell = pCArray->apCell[i];
+ u16 sz = pCArray->szCell[i];
+ assert( sz>0 );
if( SQLITE_WITHIN(pCell,aData,pEnd) ){
- if( ((uptr)(pCell+szCell[i]))>(uptr)pEnd ) return SQLITE_CORRUPT_BKPT;
+ if( ((uptr)(pCell+sz))>(uptr)pEnd ) return SQLITE_CORRUPT_BKPT;
pCell = &pTmp[pCell - aData];
+ }else if( (uptr)(pCell+sz)>(uptr)pSrcEnd
+ && (uptr)(pCell)<(uptr)pSrcEnd
+ ){
+ return SQLITE_CORRUPT_BKPT;
}
- pData -= szCell[i];
+
+ pData -= sz;
put2byte(pCellptr, (pData - aData));
pCellptr += 2;
if( pData < pCellptr ) return SQLITE_CORRUPT_BKPT;
- memcpy(pData, pCell, szCell[i]);
- assert( szCell[i]==pPg->xCellSize(pPg, pCell) || CORRUPT_DB );
- testcase( szCell[i]!=pPg->xCellSize(pPg,pCell) );
+ memcpy(pData, pCell, sz);
+ assert( sz==pPg->xCellSize(pPg, pCell) || CORRUPT_DB );
+ testcase( sz!=pPg->xCellSize(pPg,pCell) );
+ i++;
+ if( i>=iEnd ) break;
+ if( pCArray->ixNx[k]<=i ){
+ k++;
+ pSrcEnd = pCArray->apEnd[k];
+ }
}
/* The pPg->nFree field is now set incorrectly. The caller will fix it. */
@@ -6797,12 +6901,11 @@ static int rebuildPage(
}
/*
-** Array apCell[] contains nCell pointers to b-tree cells. Array szCell
-** contains the size in bytes of each such cell. This function attempts to
-** add the cells stored in the array to page pPg. If it cannot (because
-** the page needs to be defragmented before the cells will fit), non-zero
-** is returned. Otherwise, if the cells are added successfully, zero is
-** returned.
+** The pCArray objects contains pointers to b-tree cells and the cell sizes.
+** This function attempts to add the cells stored in the array to page pPg.
+** If it cannot (because the page needs to be defragmented before the cells
+** will fit), non-zero is returned. Otherwise, if the cells are added
+** successfully, zero is returned.
**
** Argument pCellptr points to the first entry in the cell-pointer array
** (part of page pPg) to populate. After cell apCell[0] is written to the
@@ -6824,18 +6927,23 @@ static int rebuildPage(
static int pageInsertArray(
MemPage *pPg, /* Page to add cells to */
u8 *pBegin, /* End of cell-pointer array */
- u8 **ppData, /* IN/OUT: Page content -area pointer */
+ u8 **ppData, /* IN/OUT: Page content-area pointer */
u8 *pCellptr, /* Pointer to cell-pointer area */
int iFirst, /* Index of first cell to add */
int nCell, /* Number of cells to add to pPg */
CellArray *pCArray /* Array of cells */
){
- int i;
- u8 *aData = pPg->aData;
- u8 *pData = *ppData;
- int iEnd = iFirst + nCell;
+ int i = iFirst; /* Loop counter - cell index to insert */
+ u8 *aData = pPg->aData; /* Complete page */
+ u8 *pData = *ppData; /* Content area. A subset of aData[] */
+ int iEnd = iFirst + nCell; /* End of loop. One past last cell to ins */
+ int k; /* Current slot in pCArray->apEnd[] */
+ u8 *pEnd; /* Maximum extent of cell data */
assert( CORRUPT_DB || pPg->hdrOffset==0 ); /* Never called on page 1 */
- for(i=iFirst; i<iEnd; i++){
+ if( iEnd<=iFirst ) return 0;
+ for(k=0; pCArray->ixNx[k]<=i && ALWAYS(k<NB*2); k++){}
+ pEnd = pCArray->apEnd[k];
+ while( 1 /*Exit by break*/ ){
int sz, rc;
u8 *pSlot;
sz = cachedCellSize(pCArray, i);
@@ -6850,20 +6958,33 @@ static int pageInsertArray(
assert( (pSlot+sz)<=pCArray->apCell[i]
|| pSlot>=(pCArray->apCell[i]+sz)
|| CORRUPT_DB );
+ if( (uptr)(pCArray->apCell[i]+sz)>(uptr)pEnd
+ && (uptr)(pCArray->apCell[i])<(uptr)pEnd
+ ){
+ assert( CORRUPT_DB );
+ (void)SQLITE_CORRUPT_BKPT;
+ return 1;
+ }
memmove(pSlot, pCArray->apCell[i], sz);
put2byte(pCellptr, (pSlot - aData));
pCellptr += 2;
+ i++;
+ if( i>=iEnd ) break;
+ if( pCArray->ixNx[k]<=i ){
+ k++;
+ pEnd = pCArray->apEnd[k];
+ }
}
*ppData = pData;
return 0;
}
/*
-** Array apCell[] contains nCell pointers to b-tree cells. Array szCell
-** contains the size in bytes of each such cell. This function adds the
-** space associated with each cell in the array that is currently stored
-** within the body of pPg to the pPg free-list. The cell-pointers and other
-** fields of the page are not updated.
+** The pCArray object contains pointers to b-tree cells and their sizes.
+**
+** This function adds the space associated with each cell in the array
+** that is currently stored within the body of pPg to the pPg free-list.
+** The cell-pointers and other fields of the page are not updated.
**
** This function returns the total number of cells added to the free-list.
*/
@@ -6913,9 +7034,9 @@ static int pageFreeArray(
}
/*
-** apCell[] and szCell[] contains pointers to and sizes of all cells in the
-** pages being balanced. The current page, pPg, has pPg->nCell cells starting
-** with apCell[iOld]. After balancing, this page should hold nNew cells
+** pCArray contains pointers to and sizes of all cells in the page being
+** balanced. The current page, pPg, has pPg->nCell cells starting with
+** pCArray->apCell[iOld]. After balancing, this page should hold nNew cells
** starting at apCell[iNew].
**
** This routine makes the necessary adjustments to pPg so that it contains
@@ -6947,13 +7068,17 @@ static int editPage(
#endif
/* Remove cells from the start and end of the page */
+ assert( nCell>=0 );
if( iOld<iNew ){
int nShift = pageFreeArray(pPg, iOld, iNew-iOld, pCArray);
+ if( nShift>nCell ) return SQLITE_CORRUPT_BKPT;
memmove(pPg->aCellIdx, &pPg->aCellIdx[nShift*2], nCell*2);
nCell -= nShift;
}
if( iNewEnd < iOldEnd ){
- nCell -= pageFreeArray(pPg, iNewEnd, iOldEnd - iNewEnd, pCArray);
+ int nTail = pageFreeArray(pPg, iNewEnd, iOldEnd - iNewEnd, pCArray);
+ assert( nCell>=nTail );
+ nCell -= nTail;
}
pData = &aData[get2byteNotZero(&aData[hdr+5])];
@@ -6963,6 +7088,7 @@ static int editPage(
if( iNew<iOld ){
int nAdd = MIN(nNew,iOld-iNew);
assert( (iOld-iNew)<nNew || nCell==0 || CORRUPT_DB );
+ assert( nAdd>=0 );
pCellptr = pPg->aCellIdx;
memmove(&pCellptr[nAdd*2], pCellptr, nCell*2);
if( pageInsertArray(
@@ -6977,6 +7103,7 @@ static int editPage(
int iCell = (iOld + pPg->aiOvfl[i]) - iNew;
if( iCell>=0 && iCell<nNew ){
pCellptr = &pPg->aCellIdx[iCell * 2];
+ assert( nCell>=iCell );
memmove(&pCellptr[2], pCellptr, (nCell - iCell) * 2);
nCell++;
if( pageInsertArray(
@@ -6987,6 +7114,7 @@ static int editPage(
}
/* Append cells to the end of the page */
+ assert( nCell>=0 );
pCellptr = &pPg->aCellIdx[nCell*2];
if( pageInsertArray(
pPg, pBegin, &pData, pCellptr,
@@ -7015,24 +7143,9 @@ static int editPage(
editpage_fail:
/* Unable to edit this page. Rebuild it from scratch instead. */
populateCellCache(pCArray, iNew, nNew);
- return rebuildPage(pPg, nNew, &pCArray->apCell[iNew], &pCArray->szCell[iNew]);
+ return rebuildPage(pCArray, iNew, nNew, pPg);
}
-/*
-** The following parameters determine how many adjacent pages get involved
-** in a balancing operation. NN is the number of neighbors on either side
-** of the page that participate in the balancing operation. NB is the
-** total number of pages that participate, including the target page and
-** NN neighbors on either side.
-**
-** The minimum value of NN is 1 (of course). Increasing NN above 1
-** (to 2 or 3) gives a modest improvement in SELECT and DELETE performance
-** in exchange for a larger degradation in INSERT and UPDATE performance.
-** The value of NN appears to give the best results overall.
-*/
-#define NN 1 /* Number of neighbors on either side of pPage */
-#define NB (NN*2+1) /* Total pages involved in the balance */
-
#ifndef SQLITE_OMIT_QUICKBALANCE
/*
@@ -7082,12 +7195,22 @@ static int balance_quick(MemPage *pParent, MemPage *pPage, u8 *pSpace){
u8 *pCell = pPage->apOvfl[0];
u16 szCell = pPage->xCellSize(pPage, pCell);
u8 *pStop;
+ CellArray b;
assert( sqlite3PagerIswriteable(pNew->pDbPage) );
- assert( pPage->aData[0]==(PTF_INTKEY|PTF_LEAFDATA|PTF_LEAF) );
+ assert( CORRUPT_DB || pPage->aData[0]==(PTF_INTKEY|PTF_LEAFDATA|PTF_LEAF) );
zeroPage(pNew, PTF_INTKEY|PTF_LEAFDATA|PTF_LEAF);
- rc = rebuildPage(pNew, 1, &pCell, &szCell);
- if( NEVER(rc) ) return rc;
+ b.nCell = 1;
+ b.pRef = pPage;
+ b.apCell = &pCell;
+ b.szCell = &szCell;
+ b.apEnd[0] = pPage->aDataEnd;
+ b.ixNx[0] = 2;
+ rc = rebuildPage(&b, 0, 1, pNew);
+ if( NEVER(rc) ){
+ releasePage(pNew);
+ return rc;
+ }
pNew->nFree = pBt->usableSize - pNew->cellOffset - 2 - szCell;
/* If this is an auto-vacuum database, update the pointer map
@@ -7565,8 +7688,15 @@ static int balance_nonroot(
**
*/
usableSpace = pBt->usableSize - 12 + leafCorrection;
- for(i=0; i<nOld; i++){
+ for(i=k=0; i<nOld; i++, k++){
MemPage *p = apOld[i];
+ b.apEnd[k] = p->aDataEnd;
+ b.ixNx[k] = cntOld[i];
+ if( !leafData ){
+ k++;
+ b.apEnd[k] = pParent->aDataEnd;
+ b.ixNx[k] = cntOld[i]+1;
+ }
szNew[i] = usableSpace - p->nFree;
for(j=0; j<p->nOverflow; j++){
szNew[i] += 2 + p->xCellSize(p, p->apOvfl[j]);
@@ -8248,7 +8378,11 @@ static int btreeOverwriteContent(
if( memcmp(pDest, ((u8*)pX->pData) + iOffset, iAmt)!=0 ){
int rc = sqlite3PagerWrite(pPage->pDbPage);
if( rc ) return rc;
- memcpy(pDest, ((u8*)pX->pData) + iOffset, iAmt);
+ /* In a corrupt database, it is possible for the source and destination
+ ** buffers to overlap. This is harmless since the database is already
+ ** corrupt but it does cause valgrind and ASAN warnings. So use
+ ** memmove(). */
+ memmove(pDest, ((u8*)pX->pData) + iOffset, iAmt);
}
}
return SQLITE_OK;
@@ -9428,7 +9562,7 @@ static void checkList(
checkPtrmap(pCheck, iPage, PTRMAP_FREEPAGE, 0);
}
#endif
- if( n>(int)pCheck->pBt->usableSize/4-2 ){
+ if( n>pCheck->pBt->usableSize/4-2 ){
checkAppendMsg(pCheck,
"freelist leaf count too big on page %d", iPage);
N--;
@@ -9810,7 +9944,7 @@ char *sqlite3BtreeIntegrityCheck(
Pgno i;
IntegrityCk sCheck;
BtShared *pBt = p->pBt;
- int savedDbFlags = pBt->db->flags;
+ u64 savedDbFlags = pBt->db->flags;
char zErr[100];
VVA_ONLY( int nRef );
@@ -9877,7 +10011,7 @@ char *sqlite3BtreeIntegrityCheck(
}
#endif
testcase( pBt->db->flags & SQLITE_CellSizeCk );
- pBt->db->flags &= ~SQLITE_CellSizeCk;
+ pBt->db->flags &= ~(u64)SQLITE_CellSizeCk;
for(i=0; (int)i<nRoot && sCheck.mxErr; i++){
i64 notUsed;
if( aRoot[i]==0 ) continue;
diff --git a/chromium/third_party/sqlite/src/src/btree.h b/chromium/third_party/sqlite/src/src/btree.h
index e4bd09c7e72..52d09b21575 100644
--- a/chromium/third_party/sqlite/src/src/btree.h
+++ b/chromium/third_party/sqlite/src/src/btree.h
@@ -315,6 +315,7 @@ i64 sqlite3BtreeOffset(BtCursor*);
int sqlite3BtreePayload(BtCursor*, u32 offset, u32 amt, void*);
const void *sqlite3BtreePayloadFetch(BtCursor*, u32 *pAmt);
u32 sqlite3BtreePayloadSize(BtCursor*);
+sqlite3_int64 sqlite3BtreeMaxRecordSize(BtCursor*);
char *sqlite3BtreeIntegrityCheck(Btree*, int *aRoot, int nRoot, int, int*);
struct Pager *sqlite3BtreePager(Btree*);
diff --git a/chromium/third_party/sqlite/src/src/btreeInt.h b/chromium/third_party/sqlite/src/src/btreeInt.h
index 8fe8e280fe5..af29c897f9b 100644
--- a/chromium/third_party/sqlite/src/src/btreeInt.h
+++ b/chromium/third_party/sqlite/src/src/btreeInt.h
@@ -494,9 +494,16 @@ struct CellInfo {
** found at self->pBt->mutex.
**
** skipNext meaning:
-** eState==SKIPNEXT && skipNext>0: Next sqlite3BtreeNext() is no-op.
-** eState==SKIPNEXT && skipNext<0: Next sqlite3BtreePrevious() is no-op.
-** eState==FAULT: Cursor fault with skipNext as error code.
+** The meaning of skipNext depends on the value of eState:
+**
+** eState Meaning of skipNext
+** VALID skipNext is meaningless and is ignored
+** INVALID skipNext is meaningless and is ignored
+** SKIPNEXT sqlite3BtreeNext() is a no-op if skipNext>0 and
+** sqlite3BtreePrevious() is no-op if skipNext<0.
+** REQUIRESEEK restoreCursorPosition() restores the cursor to
+** eState=SKIPNEXT if skipNext!=0
+** FAULT skipNext holds the cursor fault error code.
*/
struct BtCursor {
u8 eState; /* One of the CURSOR_XXX constants (see below) */
diff --git a/chromium/third_party/sqlite/src/src/build.c b/chromium/third_party/sqlite/src/src/build.c
index e6e48875d12..e9371afd2b7 100644
--- a/chromium/third_party/sqlite/src/src/build.c
+++ b/chromium/third_party/sqlite/src/src/build.c
@@ -227,7 +227,7 @@ void sqlite3FinishCoding(Parse *pParse){
if( v && pParse->nErr==0 && !db->mallocFailed ){
/* A minimum of one cursor is required if autoincrement is used
* See ticket [a696379c1f08866] */
- if( pParse->pAinc!=0 && pParse->nTab==0 ) pParse->nTab = 1;
+ assert( pParse->pAinc==0 || pParse->nTab>0 );
sqlite3VdbeMakeReady(v, pParse);
pParse->rc = SQLITE_DONE;
}else{
@@ -642,12 +642,6 @@ static void SQLITE_NOINLINE deleteTable(sqlite3 *db, Table *pTable){
/* Delete the Table structure itself.
*/
-#ifdef SQLITE_ENABLE_NORMALIZE
- if( pTable->pColHash ){
- sqlite3HashClear(pTable->pColHash);
- sqlite3_free(pTable->pColHash);
- }
-#endif
sqlite3DeleteColumnNames(db, pTable);
sqlite3DbFree(db, pTable->zName);
sqlite3DbFree(db, pTable->zColAff);
@@ -2644,6 +2638,7 @@ void sqlite3CodeDropTable(Parse *pParse, Table *pTab, int iDb, int isView){
*/
if( IsVirtual(pTab) ){
sqlite3VdbeAddOp4(v, OP_VDestroy, iDb, 0, 0, pTab->zName, 0);
+ sqlite3MayAbort(pParse);
}
sqlite3VdbeAddOp4(v, OP_DropTable, iDb, 0, 0, pTab->zName, 0);
sqlite3ChangeCookie(pParse, iDb);
@@ -3472,6 +3467,11 @@ void sqlite3CreateIndex(
}
}
if( idxType==SQLITE_IDXTYPE_PRIMARYKEY ) pIdx->idxType = idxType;
+ if( IN_RENAME_OBJECT ){
+ pIndex->pNext = pParse->pNewIndex;
+ pParse->pNewIndex = pIndex;
+ pIndex = 0;
+ }
goto exit_create_index;
}
}
@@ -3487,6 +3487,14 @@ void sqlite3CreateIndex(
Index *p;
assert( !IN_SPECIAL_PARSE );
assert( sqlite3SchemaMutexHeld(db, 0, pIndex->pSchema) );
+ if( pTblName!=0 ){
+ pIndex->tnum = db->init.newTnum;
+ if( sqlite3IndexHasDuplicateRootPage(pIndex) ){
+ sqlite3ErrorMsg(pParse, "invalid rootpage");
+ pParse->rc = SQLITE_CORRUPT_BKPT;
+ goto exit_create_index;
+ }
+ }
p = sqlite3HashInsert(&pIndex->pSchema->idxHash,
pIndex->zName, pIndex);
if( p ){
@@ -3495,9 +3503,6 @@ void sqlite3CreateIndex(
goto exit_create_index;
}
db->mDbFlags |= DBFLAG_SchemaChange;
- if( pTblName!=0 ){
- pIndex->tnum = db->init.newTnum;
- }
}
/* If this is the initial CREATE INDEX statement (or CREATE TABLE if the
@@ -3824,6 +3829,18 @@ int sqlite3IdListIndex(IdList *pList, const char *zName){
}
/*
+** Maximum size of a SrcList object.
+** The SrcList object is used to represent the FROM clause of a
+** SELECT statement, and the query planner cannot deal with more
+** than 64 tables in a join. So any value larger than 64 here
+** is sufficient for most uses. Smaller values, like say 10, are
+** appropriate for small and memory-limited applications.
+*/
+#ifndef SQLITE_MAX_SRCLIST
+# define SQLITE_MAX_SRCLIST 200
+#endif
+
+/*
** Expand the space allocated for the given SrcList object by
** creating nExtra new slots beginning at iStart. iStart is zero based.
** New slots are zeroed.
@@ -3839,11 +3856,12 @@ int sqlite3IdListIndex(IdList *pList, const char *zName){
** the iStart value would be 0. The result then would
** be: nil, nil, nil, A, B.
**
-** If a memory allocation fails the SrcList is unchanged. The
-** db->mallocFailed flag will be set to true.
+** If a memory allocation fails or the SrcList becomes too large, leave
+** the original SrcList unchanged, return NULL, and leave an error message
+** in pParse.
*/
SrcList *sqlite3SrcListEnlarge(
- sqlite3 *db, /* Database connection to notify of OOM errors */
+ Parse *pParse, /* Parsing context into which errors are reported */
SrcList *pSrc, /* The SrcList to be enlarged */
int nExtra, /* Number of new slots to add to pSrc->a[] */
int iStart /* Index in pSrc->a[] of first new slot */
@@ -3860,16 +3878,22 @@ SrcList *sqlite3SrcListEnlarge(
if( (u32)pSrc->nSrc+nExtra>pSrc->nAlloc ){
SrcList *pNew;
int nAlloc = pSrc->nSrc*2+nExtra;
- int nGot;
+ sqlite3 *db = pParse->db;
+
+ if( pSrc->nSrc+nExtra>=SQLITE_MAX_SRCLIST ){
+ sqlite3ErrorMsg(pParse, "too many FROM clause terms, max: %d",
+ SQLITE_MAX_SRCLIST);
+ return 0;
+ }
+ if( nAlloc>SQLITE_MAX_SRCLIST ) nAlloc = SQLITE_MAX_SRCLIST;
pNew = sqlite3DbRealloc(db, pSrc,
sizeof(*pSrc) + (nAlloc-1)*sizeof(pSrc->a[0]) );
if( pNew==0 ){
assert( db->mallocFailed );
- return pSrc;
+ return 0;
}
pSrc = pNew;
- nGot = (sqlite3DbMallocSize(db, pNew) - sizeof(*pSrc))/sizeof(pSrc->a[0])+1;
- pSrc->nAlloc = nGot;
+ pSrc->nAlloc = nAlloc;
}
/* Move existing slots that come after the newly inserted slots
@@ -3894,7 +3918,8 @@ SrcList *sqlite3SrcListEnlarge(
** Append a new table name to the given SrcList. Create a new SrcList if
** need be. A new entry is created in the SrcList even if pTable is NULL.
**
-** A SrcList is returned, or NULL if there is an OOM error. The returned
+** A SrcList is returned, or NULL if there is an OOM error or if the
+** SrcList grows to large. The returned
** SrcList might be the same as the SrcList that was input or it might be
** a new one. If an OOM error does occurs, then the prior value of pList
** that is input to this routine is automatically freed.
@@ -3925,27 +3950,32 @@ SrcList *sqlite3SrcListEnlarge(
** before being added to the SrcList.
*/
SrcList *sqlite3SrcListAppend(
- sqlite3 *db, /* Connection to notify of malloc failures */
+ Parse *pParse, /* Parsing context, in which errors are reported */
SrcList *pList, /* Append to this SrcList. NULL creates a new SrcList */
Token *pTable, /* Table to append */
Token *pDatabase /* Database of the table */
){
struct SrcList_item *pItem;
+ sqlite3 *db;
assert( pDatabase==0 || pTable!=0 ); /* Cannot have C without B */
- assert( db!=0 );
+ assert( pParse!=0 );
+ assert( pParse->db!=0 );
+ db = pParse->db;
if( pList==0 ){
- pList = sqlite3DbMallocRawNN(db, sizeof(SrcList) );
+ pList = sqlite3DbMallocRawNN(pParse->db, sizeof(SrcList) );
if( pList==0 ) return 0;
pList->nAlloc = 1;
pList->nSrc = 1;
memset(&pList->a[0], 0, sizeof(pList->a[0]));
pList->a[0].iCursor = -1;
}else{
- pList = sqlite3SrcListEnlarge(db, pList, 1, pList->nSrc);
- }
- if( db->mallocFailed ){
- sqlite3SrcListDelete(db, pList);
- return 0;
+ SrcList *pNew = sqlite3SrcListEnlarge(pParse, pList, 1, pList->nSrc);
+ if( pNew==0 ){
+ sqlite3SrcListDelete(db, pList);
+ return 0;
+ }else{
+ pList = pNew;
+ }
}
pItem = &pList->a[pList->nSrc-1];
if( pDatabase && pDatabase->z==0 ){
@@ -4034,7 +4064,7 @@ SrcList *sqlite3SrcListAppendFromTerm(
);
goto append_from_error;
}
- p = sqlite3SrcListAppend(db, p, pTable, pDatabase);
+ p = sqlite3SrcListAppend(pParse, p, pTable, pDatabase);
if( p==0 ){
goto append_from_error;
}
@@ -4423,7 +4453,7 @@ static int collationMatch(const char *zColl, Index *pIndex){
*/
#ifndef SQLITE_OMIT_REINDEX
static void reindexTable(Parse *pParse, Table *pTab, char const *zColl){
- if (! IsVirtual(pTab) ){
+ if( !IsVirtual(pTab) ){
Index *pIndex; /* An index associated with pTab */
for(pIndex=pTab->pIndex; pIndex; pIndex=pIndex->pNext){
diff --git a/chromium/third_party/sqlite/src/src/callback.c b/chromium/third_party/sqlite/src/src/callback.c
index 3d55b286736..e356b19e612 100644
--- a/chromium/third_party/sqlite/src/src/callback.c
+++ b/chromium/third_party/sqlite/src/src/callback.c
@@ -283,7 +283,7 @@ static int matchQuality(
** Search a FuncDefHash for a function with the given name. Return
** a pointer to the matching FuncDef if found, or 0 if there is no match.
*/
-static FuncDef *functionSearch(
+FuncDef *sqlite3FunctionSearch(
int h, /* Hash of the name */
const char *zFunc /* Name of function */
){
@@ -295,21 +295,6 @@ static FuncDef *functionSearch(
}
return 0;
}
-#ifdef SQLITE_ENABLE_NORMALIZE
-FuncDef *sqlite3FunctionSearchN(
- int h, /* Hash of the name */
- const char *zFunc, /* Name of function */
- int nFunc /* Length of the name */
-){
- FuncDef *p;
- for(p=sqlite3BuiltinFunctions.a[h]; p; p=p->u.pHash){
- if( sqlite3StrNICmp(p->zName, zFunc, nFunc)==0 ){
- return p;
- }
- }
- return 0;
-}
-#endif /* SQLITE_ENABLE_NORMALIZE */
/*
** Insert a new FuncDef into a FuncDefHash hash table.
@@ -325,7 +310,7 @@ void sqlite3InsertBuiltinFuncs(
int nName = sqlite3Strlen30(zName);
int h = SQLITE_FUNC_HASH(zName[0], nName);
assert( zName[0]>='a' && zName[0]<='z' );
- pOther = functionSearch(h, zName);
+ pOther = sqlite3FunctionSearch(h, zName);
if( pOther ){
assert( pOther!=&aDef[i] && pOther->pNext!=&aDef[i] );
aDef[i].pNext = pOther->pNext;
@@ -403,7 +388,7 @@ FuncDef *sqlite3FindFunction(
if( !createFlag && (pBest==0 || (db->mDbFlags & DBFLAG_PreferBuiltin)!=0) ){
bestScore = 0;
h = SQLITE_FUNC_HASH(sqlite3UpperToLower[(u8)zName[0]], nName);
- p = functionSearch(h, zName);
+ p = sqlite3FunctionSearch(h, zName);
while( p ){
int score = matchQuality(p, nArg, enc);
if( score>bestScore ){
diff --git a/chromium/third_party/sqlite/src/src/dbstat.c b/chromium/third_party/sqlite/src/src/dbstat.c
index 73ab7d926e2..96008f358ec 100644
--- a/chromium/third_party/sqlite/src/src/dbstat.c
+++ b/chromium/third_party/sqlite/src/src/dbstat.c
@@ -531,6 +531,10 @@ statNextRestart:
goto statNextRestart; /* Tail recursion */
}
pCsr->iPage++;
+ if( pCsr->iPage>=ArraySize(pCsr->aPage) ){
+ statResetCsr(pCsr);
+ return SQLITE_CORRUPT_BKPT;
+ }
assert( p==&pCsr->aPage[pCsr->iPage-1] );
if( p->iCell==p->nCell ){
@@ -602,7 +606,6 @@ static int statFilter(
StatTable *pTab = (StatTable*)(pCursor->pVtab);
char *zSql;
int rc = SQLITE_OK;
- char *zMaster;
if( idxNum==1 ){
const char *zDbase = (const char*)sqlite3_value_text(argv[0]);
@@ -618,13 +621,12 @@ static int statFilter(
statResetCsr(pCsr);
sqlite3_finalize(pCsr->pStmt);
pCsr->pStmt = 0;
- zMaster = pCsr->iDb==1 ? "sqlite_temp_master" : "sqlite_master";
zSql = sqlite3_mprintf(
"SELECT 'sqlite_master' AS name, 1 AS rootpage, 'table' AS type"
" UNION ALL "
"SELECT name, rootpage, type"
- " FROM \"%w\".%s WHERE rootpage!=0"
- " ORDER BY name", pTab->db->aDb[pCsr->iDb].zDbSName, zMaster);
+ " FROM \"%w\".sqlite_master WHERE rootpage!=0"
+ " ORDER BY name", pTab->db->aDb[pCsr->iDb].zDbSName);
if( zSql==0 ){
return SQLITE_NOMEM_BKPT;
}else{
diff --git a/chromium/third_party/sqlite/src/src/delete.c b/chromium/third_party/sqlite/src/src/delete.c
index 69135c226e9..dcb117f2e10 100644
--- a/chromium/third_party/sqlite/src/src/delete.c
+++ b/chromium/third_party/sqlite/src/src/delete.c
@@ -117,7 +117,7 @@ void sqlite3MaterializeView(
sqlite3 *db = pParse->db;
int iDb = sqlite3SchemaToIndex(db, pView->pSchema);
pWhere = sqlite3ExprDup(db, pWhere, 0);
- pFrom = sqlite3SrcListAppend(db, 0, 0, 0);
+ pFrom = sqlite3SrcListAppend(pParse, 0, 0, 0);
if( pFrom ){
assert( pFrom->nSrc==1 );
pFrom->a[0].zName = sqlite3DbStrDup(db, pView->zName);
@@ -517,7 +517,7 @@ void sqlite3DeleteFrom(
/* If this DELETE cannot use the ONEPASS strategy, this is the
** end of the WHERE loop */
if( eOnePass!=ONEPASS_OFF ){
- addrBypass = sqlite3VdbeMakeLabel(v);
+ addrBypass = sqlite3VdbeMakeLabel(pParse);
}else{
sqlite3WhereEnd(pWInfo);
}
@@ -706,7 +706,7 @@ void sqlite3GenerateRowDelete(
/* Seek cursor iCur to the row to delete. If this row no longer exists
** (this can happen if a trigger program has already deleted it), do
** not attempt to delete it or fire any DELETE triggers. */
- iLabel = sqlite3VdbeMakeLabel(v);
+ iLabel = sqlite3VdbeMakeLabel(pParse);
opSeek = HasRowid(pTab) ? OP_NotExists : OP_NotFound;
if( eMode==ONEPASS_OFF ){
sqlite3VdbeAddOp4Int(v, opSeek, iDataCur, iLabel, iPk, nPk);
@@ -912,7 +912,7 @@ int sqlite3GenerateIndexKey(
if( piPartIdxLabel ){
if( pIdx->pPartIdxWhere ){
- *piPartIdxLabel = sqlite3VdbeMakeLabel(v);
+ *piPartIdxLabel = sqlite3VdbeMakeLabel(pParse);
pParse->iSelfTab = iDataCur + 1;
sqlite3ExprIfFalseDup(pParse, pIdx->pPartIdxWhere, *piPartIdxLabel,
SQLITE_JUMPIFNULL);
diff --git a/chromium/third_party/sqlite/src/src/expr.c b/chromium/third_party/sqlite/src/src/expr.c
index 50c398266f3..eb75cb863d1 100644
--- a/chromium/third_party/sqlite/src/src/expr.c
+++ b/chromium/third_party/sqlite/src/src/expr.c
@@ -465,6 +465,7 @@ Expr *sqlite3ExprForVectorField(
}else{
if( pVector->op==TK_VECTOR ) pVector = pVector->x.pList->a[iField].pExpr;
pRet = sqlite3ExprDup(pParse->db, pVector, 0);
+ sqlite3RenameTokenRemap(pParse, pRet, pVector);
}
return pRet;
}
@@ -481,7 +482,7 @@ static int exprCodeSubselect(Parse *pParse, Expr *pExpr){
int reg = 0;
#ifndef SQLITE_OMIT_SUBQUERY
if( pExpr->op==TK_SELECT ){
- reg = sqlite3CodeSubselect(pParse, pExpr, 0, 0);
+ reg = sqlite3CodeSubselect(pParse, pExpr);
}
#endif
return reg;
@@ -553,7 +554,7 @@ static void codeVectorCompare(
int regLeft = 0;
int regRight = 0;
u8 opx = op;
- int addrDone = sqlite3VdbeMakeLabel(v);
+ int addrDone = sqlite3VdbeMakeLabel(pParse);
if( nLeft!=sqlite3ExprVectorSize(pRight) ){
sqlite3ErrorMsg(pParse, "row value misused");
@@ -780,8 +781,7 @@ Expr *sqlite3ExprAlloc(
if( pToken->n ) memcpy(pNew->u.zToken, pToken->z, pToken->n);
pNew->u.zToken[pToken->n] = 0;
if( dequote && sqlite3Isquote(pNew->u.zToken[0]) ){
- if( pNew->u.zToken[0]=='"' ) pNew->flags |= EP_DblQuoted;
- sqlite3Dequote(pNew->u.zToken);
+ sqlite3DequoteExpr(pNew);
}
}
}
@@ -850,7 +850,7 @@ Expr *sqlite3PExpr(
Expr *pRight /* Right operand */
){
Expr *p;
- if( op==TK_AND && pParse->nErr==0 ){
+ if( op==TK_AND && pParse->nErr==0 && !IN_RENAME_OBJECT ){
/* Take advantage of short-circuit false optimization for AND */
p = sqlite3ExprAnd(pParse->db, pLeft, pRight);
}else{
@@ -1100,6 +1100,16 @@ static int exprStructSize(Expr *p){
}
/*
+** Copy the complete content of an Expr node, taking care not to read
+** past the end of the structure for a reduced-size version of the source
+** Expr.
+*/
+static void exprNodeCopy(Expr *pDest, Expr *pSrc){
+ memset(pDest, 0, sizeof(Expr));
+ memcpy(pDest, pSrc, exprStructSize(pSrc));
+}
+
+/*
** The dupedExpr*Size() routines each return the number of bytes required
** to store a copy of an expression or expression tree. They differ in
** how much of the tree is measured.
@@ -1330,6 +1340,36 @@ static With *withDup(sqlite3 *db, With *p){
# define withDup(x,y) 0
#endif
+#ifndef SQLITE_OMIT_WINDOWFUNC
+/*
+** The gatherSelectWindows() procedure and its helper routine
+** gatherSelectWindowsCallback() are used to scan all the expressions
+** an a newly duplicated SELECT statement and gather all of the Window
+** objects found there, assembling them onto the linked list at Select->pWin.
+*/
+static int gatherSelectWindowsCallback(Walker *pWalker, Expr *pExpr){
+ if( pExpr->op==TK_FUNCTION && pExpr->y.pWin!=0 ){
+ assert( ExprHasProperty(pExpr, EP_WinFunc) );
+ pExpr->y.pWin->pNextWin = pWalker->u.pSelect->pWin;
+ pWalker->u.pSelect->pWin = pExpr->y.pWin;
+ }
+ return WRC_Continue;
+}
+static int gatherSelectWindowsSelectCallback(Walker *pWalker, Select *p){
+ return p==pWalker->u.pSelect ? WRC_Continue : WRC_Prune;
+}
+static void gatherSelectWindows(Select *p){
+ Walker w;
+ w.xExprCallback = gatherSelectWindowsCallback;
+ w.xSelectCallback = gatherSelectWindowsSelectCallback;
+ w.xSelectCallback2 = 0;
+ w.pParse = 0;
+ w.u.pSelect = p;
+ sqlite3WalkSelect(&w, p);
+}
+#endif
+
+
/*
** The following group of routines make deep copies of expressions,
** expression lists, ID lists, and select statements. The copies can
@@ -1497,6 +1537,7 @@ Select *sqlite3SelectDup(sqlite3 *db, Select *pDup, int flags){
#ifndef SQLITE_OMIT_WINDOWFUNC
pNew->pWin = 0;
pNew->pWinDefn = sqlite3WindowListDup(db, p->pWinDefn);
+ if( p->pWin ) gatherSelectWindows(pNew);
#endif
pNew->selId = p->selId;
*pp = pNew;
@@ -1629,6 +1670,9 @@ ExprList *sqlite3ExprListAppendVector(
}
vector_append_error:
+ if( IN_RENAME_OBJECT ){
+ sqlite3RenameExprUnmap(pParse, pExpr);
+ }
sqlite3ExprDelete(db, pExpr);
sqlite3IdListDelete(db, pColumns);
return pList;
@@ -1772,8 +1816,9 @@ int sqlite3SelectWalkFail(Walker *pWalker, Select *NotUsed){
*/
int sqlite3ExprIdToTrueFalse(Expr *pExpr){
assert( pExpr->op==TK_ID || pExpr->op==TK_STRING );
- if( sqlite3StrICmp(pExpr->u.zToken, "true")==0
- || sqlite3StrICmp(pExpr->u.zToken, "false")==0
+ if( !ExprHasProperty(pExpr, EP_Quoted)
+ && (sqlite3StrICmp(pExpr->u.zToken, "true")==0
+ || sqlite3StrICmp(pExpr->u.zToken, "false")==0)
){
pExpr->op = TK_TRUEFALSE;
return 1;
@@ -2082,7 +2127,9 @@ int sqlite3ExprIsInteger(Expr *p, int *pValue){
*/
int sqlite3ExprCanBeNull(const Expr *p){
u8 op;
- while( p->op==TK_UPLUS || p->op==TK_UMINUS ){ p = p->pLeft; }
+ while( p->op==TK_UPLUS || p->op==TK_UMINUS ){
+ p = p->pLeft;
+ }
op = p->op;
if( op==TK_REGISTER ) op = p->op2;
switch( op ){
@@ -2149,14 +2196,6 @@ int sqlite3IsRowid(const char *z){
if( sqlite3StrICmp(z, "OID")==0 ) return 1;
return 0;
}
-#ifdef SQLITE_ENABLE_NORMALIZE
-int sqlite3IsRowidN(const char *z, int n){
- if( sqlite3StrNICmp(z, "_ROWID_", n)==0 ) return 1;
- if( sqlite3StrNICmp(z, "ROWID", n)==0 ) return 1;
- if( sqlite3StrNICmp(z, "OID", n)==0 ) return 1;
- return 0;
-}
-#endif
/*
** pX is the RHS of an IN operator. If pX is a SELECT statement
@@ -2326,7 +2365,8 @@ int sqlite3FindInIndex(
Expr *pX, /* The right-hand side (RHS) of the IN operator */
u32 inFlags, /* IN_INDEX_LOOP, _MEMBERSHIP, and/or _NOOP_OK */
int *prRhsHasNull, /* Register holding NULL status. See notes */
- int *aiMap /* Mapping from Index fields to RHS fields */
+ int *aiMap, /* Mapping from Index fields to RHS fields */
+ int *piTab /* OUT: index to use */
){
Select *p; /* SELECT to the right of IN operator */
int eType = 0; /* Type of RHS table. IN_INDEX_* */
@@ -2421,6 +2461,7 @@ int sqlite3FindInIndex(
Bitmask colUsed; /* Columns of the index used */
Bitmask mCol; /* Mask for the current column */
if( pIdx->nColumn<nExpr ) continue;
+ if( pIdx->pPartIdxWhere!=0 ) continue;
/* Maximum nColumn is BMS-2, not BMS-1, so that we can compute
** BITMASK(nExpr) without overflowing */
testcase( pIdx->nColumn==BMS-2 );
@@ -2517,10 +2558,12 @@ int sqlite3FindInIndex(
}else if( prRhsHasNull ){
*prRhsHasNull = rMayHaveNull = ++pParse->nMem;
}
- sqlite3CodeSubselect(pParse, pX, rMayHaveNull, eType==IN_INDEX_ROWID);
+ assert( pX->op==TK_IN );
+ sqlite3CodeRhsOfIN(pParse, pX, iTab, eType==IN_INDEX_ROWID);
+ if( rMayHaveNull ){
+ sqlite3SetHasNullFlag(v, iTab, rMayHaveNull);
+ }
pParse->nQueryLoop = savedNQueryLoop;
- }else{
- pX->iTable = iTab;
}
if( aiMap && eType!=IN_INDEX_INDEX_ASC && eType!=IN_INDEX_INDEX_DESC ){
@@ -2528,6 +2571,7 @@ int sqlite3FindInIndex(
n = sqlite3ExprVectorSize(pX->pLeft);
for(i=0; i<n; i++) aiMap[i] = i;
}
+ *piTab = iTab;
return eType;
}
#endif
@@ -2601,260 +2645,326 @@ void sqlite3VectorErrorMsg(Parse *pParse, Expr *pExpr){
}
}
+#ifndef SQLITE_OMIT_SUBQUERY
/*
-** Generate code for scalar subqueries used as a subquery expression, EXISTS,
-** or IN operators. Examples:
+** Generate code that will construct an ephemeral table containing all terms
+** in the RHS of an IN operator. The IN operator can be in either of two
+** forms:
**
-** (SELECT a FROM b) -- subquery
-** EXISTS (SELECT a FROM b) -- EXISTS subquery
** x IN (4,5,11) -- IN operator with list on right-hand side
** x IN (SELECT a FROM b) -- IN operator with subquery on the right
**
-** The pExpr parameter describes the expression that contains the IN
-** operator or subquery.
-**
-** If parameter isRowid is non-zero, then expression pExpr is guaranteed
-** to be of the form "<rowid> IN (?, ?, ?)", where <rowid> is a reference
-** to some integer key column of a table B-Tree. In this case, use an
-** intkey B-Tree to store the set of IN(...) values instead of the usual
-** (slower) variable length keys B-Tree.
-**
-** If rMayHaveNull is non-zero, that means that the operation is an IN
-** (not a SELECT or EXISTS) and that the RHS might contains NULLs.
-** All this routine does is initialize the register given by rMayHaveNull
-** to NULL. Calling routines will take care of changing this register
-** value to non-NULL if the RHS is NULL-free.
-**
-** For a SELECT or EXISTS operator, return the register that holds the
-** result. For a multi-column SELECT, the result is stored in a contiguous
-** array of registers and the return value is the register of the left-most
-** result column. Return 0 for IN operators or if an error occurs.
+** The pExpr parameter is the IN operator. The cursor number for the
+** constructed ephermeral table is returned. The first time the ephemeral
+** table is computed, the cursor number is also stored in pExpr->iTable,
+** however the cursor number returned might not be the same, as it might
+** have been duplicated using OP_OpenDup.
+**
+** If parameter isRowid is non-zero, then LHS of the IN operator is guaranteed
+** to be a non-null integer. In this case, the ephemeral table can be an
+** table B-Tree that keyed by only integers. The more general cases uses
+** an index B-Tree which can have arbitrary keys, but is slower to both
+** read and write.
+**
+** If the LHS expression ("x" in the examples) is a column value, or
+** the SELECT statement returns a column value, then the affinity of that
+** column is used to build the index keys. If both 'x' and the
+** SELECT... statement are columns, then numeric affinity is used
+** if either column has NUMERIC or INTEGER affinity. If neither
+** 'x' nor the SELECT... statement are columns, then numeric affinity
+** is used.
*/
-#ifndef SQLITE_OMIT_SUBQUERY
-int sqlite3CodeSubselect(
+void sqlite3CodeRhsOfIN(
Parse *pParse, /* Parsing context */
- Expr *pExpr, /* The IN, SELECT, or EXISTS operator */
- int rHasNullFlag, /* Register that records whether NULLs exist in RHS */
- int isRowid /* If true, LHS of IN operator is a rowid */
+ Expr *pExpr, /* The IN operator */
+ int iTab, /* Use this cursor number */
+ int isRowid /* If true, LHS is a rowid */
){
- int jmpIfDynamic = -1; /* One-time test address */
- int rReg = 0; /* Register storing resulting */
- Vdbe *v = sqlite3GetVdbe(pParse);
- if( NEVER(v==0) ) return 0;
+ int addrOnce = 0; /* Address of the OP_Once instruction at top */
+ int addr; /* Address of OP_OpenEphemeral instruction */
+ Expr *pLeft; /* the LHS of the IN operator */
+ KeyInfo *pKeyInfo = 0; /* Key information */
+ int nVal; /* Size of vector pLeft */
+ Vdbe *v; /* The prepared statement under construction */
+
+ v = pParse->pVdbe;
+ assert( v!=0 );
- /* The evaluation of the IN/EXISTS/SELECT must be repeated every time it
+ /* The evaluation of the IN must be repeated every time it
** is encountered if any of the following is true:
**
** * The right-hand side is a correlated subquery
** * The right-hand side is an expression list containing variables
** * We are inside a trigger
**
- ** If all of the above are false, then we can run this code just once
- ** save the results, and reuse the same result on subsequent invocations.
+ ** If all of the above are false, then we can compute the RHS just once
+ ** and reuse it many names.
*/
- if( !ExprHasProperty(pExpr, EP_VarSelect) ){
- jmpIfDynamic = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v);
- }
+ if( !ExprHasProperty(pExpr, EP_VarSelect) && pParse->iSelfTab==0 ){
+ /* Reuse of the RHS is allowed */
+ /* If this routine has already been coded, but the previous code
+ ** might not have been invoked yet, so invoke it now as a subroutine.
+ */
+ if( ExprHasProperty(pExpr, EP_Subrtn) ){
+ addrOnce = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v);
+ if( ExprHasProperty(pExpr, EP_xIsSelect) ){
+ ExplainQueryPlan((pParse, 0, "REUSE LIST SUBQUERY %d",
+ pExpr->x.pSelect->selId));
+ }
+ sqlite3VdbeAddOp2(v, OP_Gosub, pExpr->y.sub.regReturn,
+ pExpr->y.sub.iAddr);
+ sqlite3VdbeAddOp2(v, OP_OpenDup, iTab, pExpr->iTable);
+ sqlite3VdbeJumpHere(v, addrOnce);
+ return;
+ }
- switch( pExpr->op ){
- case TK_IN: {
- int addr; /* Address of OP_OpenEphemeral instruction */
- Expr *pLeft = pExpr->pLeft; /* the LHS of the IN operator */
- KeyInfo *pKeyInfo = 0; /* Key information */
- int nVal; /* Size of vector pLeft */
-
- nVal = sqlite3ExprVectorSize(pLeft);
- assert( !isRowid || nVal==1 );
-
- /* Whether this is an 'x IN(SELECT...)' or an 'x IN(<exprlist>)'
- ** expression it is handled the same way. An ephemeral table is
- ** filled with index keys representing the results from the
- ** SELECT or the <exprlist>.
- **
- ** If the 'x' expression is a column value, or the SELECT...
- ** statement returns a column value, then the affinity of that
- ** column is used to build the index keys. If both 'x' and the
- ** SELECT... statement are columns, then numeric affinity is used
- ** if either column has NUMERIC or INTEGER affinity. If neither
- ** 'x' nor the SELECT... statement are columns, then numeric affinity
- ** is used.
- */
- pExpr->iTable = pParse->nTab++;
- addr = sqlite3VdbeAddOp2(v, OP_OpenEphemeral,
- pExpr->iTable, (isRowid?0:nVal));
- pKeyInfo = isRowid ? 0 : sqlite3KeyInfoAlloc(pParse->db, nVal, 1);
+ /* Begin coding the subroutine */
+ ExprSetProperty(pExpr, EP_Subrtn);
+ pExpr->y.sub.regReturn = ++pParse->nMem;
+ pExpr->y.sub.iAddr =
+ sqlite3VdbeAddOp2(v, OP_Integer, 0, pExpr->y.sub.regReturn) + 1;
+ VdbeComment((v, "return address"));
- if( ExprHasProperty(pExpr, EP_xIsSelect) ){
- /* Case 1: expr IN (SELECT ...)
- **
- ** Generate code to write the results of the select into the temporary
- ** table allocated and opened above.
- */
- Select *pSelect = pExpr->x.pSelect;
- ExprList *pEList = pSelect->pEList;
-
- ExplainQueryPlan((pParse, 1, "%sLIST SUBQUERY",
- jmpIfDynamic>=0?"":"CORRELATED "
- ));
- assert( !isRowid );
- /* If the LHS and RHS of the IN operator do not match, that
- ** error will have been caught long before we reach this point. */
- if( ALWAYS(pEList->nExpr==nVal) ){
- SelectDest dest;
- int i;
- sqlite3SelectDestInit(&dest, SRT_Set, pExpr->iTable);
- dest.zAffSdst = exprINAffinity(pParse, pExpr);
- pSelect->iLimit = 0;
- testcase( pSelect->selFlags & SF_Distinct );
- testcase( pKeyInfo==0 ); /* Caused by OOM in sqlite3KeyInfoAlloc() */
- if( sqlite3Select(pParse, pSelect, &dest) ){
- sqlite3DbFree(pParse->db, dest.zAffSdst);
- sqlite3KeyInfoUnref(pKeyInfo);
- return 0;
- }
- sqlite3DbFree(pParse->db, dest.zAffSdst);
- assert( pKeyInfo!=0 ); /* OOM will cause exit after sqlite3Select() */
- assert( pEList!=0 );
- assert( pEList->nExpr>0 );
- assert( sqlite3KeyInfoIsWriteable(pKeyInfo) );
- for(i=0; i<nVal; i++){
- Expr *p = sqlite3VectorFieldSubexpr(pLeft, i);
- pKeyInfo->aColl[i] = sqlite3BinaryCompareCollSeq(
- pParse, p, pEList->a[i].pExpr
- );
- }
- }
- }else if( ALWAYS(pExpr->x.pList!=0) ){
- /* Case 2: expr IN (exprlist)
- **
- ** For each expression, build an index key from the evaluation and
- ** store it in the temporary table. If <expr> is a column, then use
- ** that columns affinity when building index keys. If <expr> is not
- ** a column, use numeric affinity.
- */
- char affinity; /* Affinity of the LHS of the IN */
- int i;
- ExprList *pList = pExpr->x.pList;
- struct ExprList_item *pItem;
- int r1, r2, r3;
- affinity = sqlite3ExprAffinity(pLeft);
- if( !affinity ){
- affinity = SQLITE_AFF_BLOB;
- }
- if( pKeyInfo ){
- assert( sqlite3KeyInfoIsWriteable(pKeyInfo) );
- pKeyInfo->aColl[0] = sqlite3ExprCollSeq(pParse, pExpr->pLeft);
- }
+ addrOnce = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v);
+ }
- /* Loop through each expression in <exprlist>. */
- r1 = sqlite3GetTempReg(pParse);
- r2 = sqlite3GetTempReg(pParse);
- if( isRowid ) sqlite3VdbeAddOp4(v, OP_Blob, 0, r2, 0, "", P4_STATIC);
- for(i=pList->nExpr, pItem=pList->a; i>0; i--, pItem++){
- Expr *pE2 = pItem->pExpr;
- int iValToIns;
-
- /* If the expression is not constant then we will need to
- ** disable the test that was generated above that makes sure
- ** this code only executes once. Because for a non-constant
- ** expression we need to rerun this code each time.
- */
- if( jmpIfDynamic>=0 && !sqlite3ExprIsConstant(pE2) ){
- sqlite3VdbeChangeToNoop(v, jmpIfDynamic);
- jmpIfDynamic = -1;
- }
+ /* Check to see if this is a vector IN operator */
+ pLeft = pExpr->pLeft;
+ nVal = sqlite3ExprVectorSize(pLeft);
+ assert( !isRowid || nVal==1 );
- /* Evaluate the expression and insert it into the temp table */
- if( isRowid && sqlite3ExprIsInteger(pE2, &iValToIns) ){
- sqlite3VdbeAddOp3(v, OP_InsertInt, pExpr->iTable, r2, iValToIns);
- }else{
- r3 = sqlite3ExprCodeTarget(pParse, pE2, r1);
- if( isRowid ){
- sqlite3VdbeAddOp2(v, OP_MustBeInt, r3,
- sqlite3VdbeCurrentAddr(v)+2);
- VdbeCoverage(v);
- sqlite3VdbeAddOp3(v, OP_Insert, pExpr->iTable, r2, r3);
- }else{
- sqlite3VdbeAddOp4(v, OP_MakeRecord, r3, 1, r2, &affinity, 1);
- sqlite3VdbeAddOp4Int(v, OP_IdxInsert, pExpr->iTable, r2, r3, 1);
- }
- }
- }
- sqlite3ReleaseTempReg(pParse, r1);
- sqlite3ReleaseTempReg(pParse, r2);
+ /* Construct the ephemeral table that will contain the content of
+ ** RHS of the IN operator.
+ */
+ pExpr->iTable = iTab;
+ addr = sqlite3VdbeAddOp2(v, OP_OpenEphemeral,
+ pExpr->iTable, (isRowid?0:nVal));
+#ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS
+ if( ExprHasProperty(pExpr, EP_xIsSelect) ){
+ VdbeComment((v, "Result of SELECT %u", pExpr->x.pSelect->selId));
+ }else{
+ VdbeComment((v, "RHS of IN operator"));
+ }
+#endif
+ pKeyInfo = isRowid ? 0 : sqlite3KeyInfoAlloc(pParse->db, nVal, 1);
+
+ if( ExprHasProperty(pExpr, EP_xIsSelect) ){
+ /* Case 1: expr IN (SELECT ...)
+ **
+ ** Generate code to write the results of the select into the temporary
+ ** table allocated and opened above.
+ */
+ Select *pSelect = pExpr->x.pSelect;
+ ExprList *pEList = pSelect->pEList;
+
+ ExplainQueryPlan((pParse, 1, "%sLIST SUBQUERY %d",
+ addrOnce?"":"CORRELATED ", pSelect->selId
+ ));
+ assert( !isRowid );
+ /* If the LHS and RHS of the IN operator do not match, that
+ ** error will have been caught long before we reach this point. */
+ if( ALWAYS(pEList->nExpr==nVal) ){
+ SelectDest dest;
+ int i;
+ sqlite3SelectDestInit(&dest, SRT_Set, iTab);
+ dest.zAffSdst = exprINAffinity(pParse, pExpr);
+ pSelect->iLimit = 0;
+ testcase( pSelect->selFlags & SF_Distinct );
+ testcase( pKeyInfo==0 ); /* Caused by OOM in sqlite3KeyInfoAlloc() */
+ if( sqlite3Select(pParse, pSelect, &dest) ){
+ sqlite3DbFree(pParse->db, dest.zAffSdst);
+ sqlite3KeyInfoUnref(pKeyInfo);
+ return;
}
- if( pKeyInfo ){
- sqlite3VdbeChangeP4(v, addr, (void *)pKeyInfo, P4_KEYINFO);
+ sqlite3DbFree(pParse->db, dest.zAffSdst);
+ assert( pKeyInfo!=0 ); /* OOM will cause exit after sqlite3Select() */
+ assert( pEList!=0 );
+ assert( pEList->nExpr>0 );
+ assert( sqlite3KeyInfoIsWriteable(pKeyInfo) );
+ for(i=0; i<nVal; i++){
+ Expr *p = sqlite3VectorFieldSubexpr(pLeft, i);
+ pKeyInfo->aColl[i] = sqlite3BinaryCompareCollSeq(
+ pParse, p, pEList->a[i].pExpr
+ );
}
- break;
+ }
+ }else if( ALWAYS(pExpr->x.pList!=0) ){
+ /* Case 2: expr IN (exprlist)
+ **
+ ** For each expression, build an index key from the evaluation and
+ ** store it in the temporary table. If <expr> is a column, then use
+ ** that columns affinity when building index keys. If <expr> is not
+ ** a column, use numeric affinity.
+ */
+ char affinity; /* Affinity of the LHS of the IN */
+ int i;
+ ExprList *pList = pExpr->x.pList;
+ struct ExprList_item *pItem;
+ int r1, r2, r3;
+ affinity = sqlite3ExprAffinity(pLeft);
+ if( !affinity ){
+ affinity = SQLITE_AFF_BLOB;
+ }
+ if( pKeyInfo ){
+ assert( sqlite3KeyInfoIsWriteable(pKeyInfo) );
+ pKeyInfo->aColl[0] = sqlite3ExprCollSeq(pParse, pExpr->pLeft);
}
- case TK_EXISTS:
- case TK_SELECT:
- default: {
- /* Case 3: (SELECT ... FROM ...)
- ** or: EXISTS(SELECT ... FROM ...)
- **
- ** For a SELECT, generate code to put the values for all columns of
- ** the first row into an array of registers and return the index of
- ** the first register.
- **
- ** If this is an EXISTS, write an integer 0 (not exists) or 1 (exists)
- ** into a register and return that register number.
- **
- ** In both cases, the query is augmented with "LIMIT 1". Any
- ** preexisting limit is discarded in place of the new LIMIT 1.
+ /* Loop through each expression in <exprlist>. */
+ r1 = sqlite3GetTempReg(pParse);
+ r2 = sqlite3GetTempReg(pParse);
+ if( isRowid ) sqlite3VdbeAddOp4(v, OP_Blob, 0, r2, 0, "", P4_STATIC);
+ for(i=pList->nExpr, pItem=pList->a; i>0; i--, pItem++){
+ Expr *pE2 = pItem->pExpr;
+ int iValToIns;
+
+ /* If the expression is not constant then we will need to
+ ** disable the test that was generated above that makes sure
+ ** this code only executes once. Because for a non-constant
+ ** expression we need to rerun this code each time.
*/
- Select *pSel; /* SELECT statement to encode */
- SelectDest dest; /* How to deal with SELECT result */
- int nReg; /* Registers to allocate */
- Expr *pLimit; /* New limit expression */
-
- testcase( pExpr->op==TK_EXISTS );
- testcase( pExpr->op==TK_SELECT );
- assert( pExpr->op==TK_EXISTS || pExpr->op==TK_SELECT );
- assert( ExprHasProperty(pExpr, EP_xIsSelect) );
-
- pSel = pExpr->x.pSelect;
- ExplainQueryPlan((pParse, 1, "%sSCALAR SUBQUERY",
- jmpIfDynamic>=0?"":"CORRELATED "));
- nReg = pExpr->op==TK_SELECT ? pSel->pEList->nExpr : 1;
- sqlite3SelectDestInit(&dest, 0, pParse->nMem+1);
- pParse->nMem += nReg;
- if( pExpr->op==TK_SELECT ){
- dest.eDest = SRT_Mem;
- dest.iSdst = dest.iSDParm;
- dest.nSdst = nReg;
- sqlite3VdbeAddOp3(v, OP_Null, 0, dest.iSDParm, dest.iSDParm+nReg-1);
- VdbeComment((v, "Init subquery result"));
- }else{
- dest.eDest = SRT_Exists;
- sqlite3VdbeAddOp2(v, OP_Integer, 0, dest.iSDParm);
- VdbeComment((v, "Init EXISTS result"));
+ if( addrOnce && !sqlite3ExprIsConstant(pE2) ){
+ sqlite3VdbeChangeToNoop(v, addrOnce);
+ addrOnce = 0;
}
- pLimit = sqlite3ExprAlloc(pParse->db, TK_INTEGER,&sqlite3IntTokens[1], 0);
- if( pSel->pLimit ){
- sqlite3ExprDelete(pParse->db, pSel->pLimit->pLeft);
- pSel->pLimit->pLeft = pLimit;
+
+ /* Evaluate the expression and insert it into the temp table */
+ if( isRowid && sqlite3ExprIsInteger(pE2, &iValToIns) ){
+ sqlite3VdbeAddOp3(v, OP_InsertInt, iTab, r2, iValToIns);
}else{
- pSel->pLimit = sqlite3PExpr(pParse, TK_LIMIT, pLimit, 0);
- }
- pSel->iLimit = 0;
- if( sqlite3Select(pParse, pSel, &dest) ){
- return 0;
+ r3 = sqlite3ExprCodeTarget(pParse, pE2, r1);
+ if( isRowid ){
+ sqlite3VdbeAddOp2(v, OP_MustBeInt, r3,
+ sqlite3VdbeCurrentAddr(v)+2);
+ VdbeCoverage(v);
+ sqlite3VdbeAddOp3(v, OP_Insert, iTab, r2, r3);
+ }else{
+ sqlite3VdbeAddOp4(v, OP_MakeRecord, r3, 1, r2, &affinity, 1);
+ sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iTab, r2, r3, 1);
+ }
}
- rReg = dest.iSDParm;
- ExprSetVVAProperty(pExpr, EP_NoReduce);
- break;
}
+ sqlite3ReleaseTempReg(pParse, r1);
+ sqlite3ReleaseTempReg(pParse, r2);
}
+ if( pKeyInfo ){
+ sqlite3VdbeChangeP4(v, addr, (void *)pKeyInfo, P4_KEYINFO);
+ }
+ if( addrOnce ){
+ sqlite3VdbeJumpHere(v, addrOnce);
+ /* Subroutine return */
+ sqlite3VdbeAddOp1(v, OP_Return, pExpr->y.sub.regReturn);
+ sqlite3VdbeChangeP1(v, pExpr->y.sub.iAddr-1, sqlite3VdbeCurrentAddr(v)-1);
+ }
+}
+#endif /* SQLITE_OMIT_SUBQUERY */
- if( rHasNullFlag ){
- sqlite3SetHasNullFlag(v, pExpr->iTable, rHasNullFlag);
+/*
+** Generate code for scalar subqueries used as a subquery expression
+** or EXISTS operator:
+**
+** (SELECT a FROM b) -- subquery
+** EXISTS (SELECT a FROM b) -- EXISTS subquery
+**
+** The pExpr parameter is the SELECT or EXISTS operator to be coded.
+**
+** The register that holds the result. For a multi-column SELECT,
+** the result is stored in a contiguous array of registers and the
+** return value is the register of the left-most result column.
+** Return 0 if an error occurs.
+*/
+#ifndef SQLITE_OMIT_SUBQUERY
+int sqlite3CodeSubselect(Parse *pParse, Expr *pExpr){
+ int addrOnce = 0; /* Address of OP_Once at top of subroutine */
+ int rReg = 0; /* Register storing resulting */
+ Select *pSel; /* SELECT statement to encode */
+ SelectDest dest; /* How to deal with SELECT result */
+ int nReg; /* Registers to allocate */
+ Expr *pLimit; /* New limit expression */
+
+ Vdbe *v = pParse->pVdbe;
+ assert( v!=0 );
+ testcase( pExpr->op==TK_EXISTS );
+ testcase( pExpr->op==TK_SELECT );
+ assert( pExpr->op==TK_EXISTS || pExpr->op==TK_SELECT );
+ assert( ExprHasProperty(pExpr, EP_xIsSelect) );
+ pSel = pExpr->x.pSelect;
+
+ /* The evaluation of the EXISTS/SELECT must be repeated every time it
+ ** is encountered if any of the following is true:
+ **
+ ** * The right-hand side is a correlated subquery
+ ** * The right-hand side is an expression list containing variables
+ ** * We are inside a trigger
+ **
+ ** If all of the above are false, then we can run this code just once
+ ** save the results, and reuse the same result on subsequent invocations.
+ */
+ if( !ExprHasProperty(pExpr, EP_VarSelect) ){
+ /* If this routine has already been coded, then invoke it as a
+ ** subroutine. */
+ if( ExprHasProperty(pExpr, EP_Subrtn) ){
+ ExplainQueryPlan((pParse, 0, "REUSE SUBQUERY %d", pSel->selId));
+ sqlite3VdbeAddOp2(v, OP_Gosub, pExpr->y.sub.regReturn,
+ pExpr->y.sub.iAddr);
+ return pExpr->iTable;
+ }
+
+ /* Begin coding the subroutine */
+ ExprSetProperty(pExpr, EP_Subrtn);
+ pExpr->y.sub.regReturn = ++pParse->nMem;
+ pExpr->y.sub.iAddr =
+ sqlite3VdbeAddOp2(v, OP_Integer, 0, pExpr->y.sub.regReturn) + 1;
+ VdbeComment((v, "return address"));
+
+ addrOnce = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v);
+ }
+
+ /* For a SELECT, generate code to put the values for all columns of
+ ** the first row into an array of registers and return the index of
+ ** the first register.
+ **
+ ** If this is an EXISTS, write an integer 0 (not exists) or 1 (exists)
+ ** into a register and return that register number.
+ **
+ ** In both cases, the query is augmented with "LIMIT 1". Any
+ ** preexisting limit is discarded in place of the new LIMIT 1.
+ */
+ ExplainQueryPlan((pParse, 1, "%sSCALAR SUBQUERY %d",
+ addrOnce?"":"CORRELATED ", pSel->selId));
+ nReg = pExpr->op==TK_SELECT ? pSel->pEList->nExpr : 1;
+ sqlite3SelectDestInit(&dest, 0, pParse->nMem+1);
+ pParse->nMem += nReg;
+ if( pExpr->op==TK_SELECT ){
+ dest.eDest = SRT_Mem;
+ dest.iSdst = dest.iSDParm;
+ dest.nSdst = nReg;
+ sqlite3VdbeAddOp3(v, OP_Null, 0, dest.iSDParm, dest.iSDParm+nReg-1);
+ VdbeComment((v, "Init subquery result"));
+ }else{
+ dest.eDest = SRT_Exists;
+ sqlite3VdbeAddOp2(v, OP_Integer, 0, dest.iSDParm);
+ VdbeComment((v, "Init EXISTS result"));
+ }
+ pLimit = sqlite3ExprAlloc(pParse->db, TK_INTEGER,&sqlite3IntTokens[1], 0);
+ if( pSel->pLimit ){
+ sqlite3ExprDelete(pParse->db, pSel->pLimit->pLeft);
+ pSel->pLimit->pLeft = pLimit;
+ }else{
+ pSel->pLimit = sqlite3PExpr(pParse, TK_LIMIT, pLimit, 0);
+ }
+ pSel->iLimit = 0;
+ if( sqlite3Select(pParse, pSel, &dest) ){
+ return 0;
}
+ pExpr->iTable = rReg = dest.iSDParm;
+ ExprSetVVAProperty(pExpr, EP_NoReduce);
+ if( addrOnce ){
+ sqlite3VdbeJumpHere(v, addrOnce);
- if( jmpIfDynamic>=0 ){
- sqlite3VdbeJumpHere(v, jmpIfDynamic);
+ /* Subroutine return */
+ sqlite3VdbeAddOp1(v, OP_Return, pExpr->y.sub.regReturn);
+ sqlite3VdbeChangeP1(v, pExpr->y.sub.iAddr-1, sqlite3VdbeCurrentAddr(v)-1);
}
return rReg;
@@ -2931,6 +3041,7 @@ static void sqlite3ExprCodeIN(
int addrTruthOp; /* Address of opcode that determines the IN is true */
int destNotNull; /* Jump here if a comparison is not true in step 6 */
int addrTop; /* Top of the step-6 loop */
+ int iTab = 0; /* Index to use */
pLeft = pExpr->pLeft;
if( sqlite3ExprCheckIN(pParse, pExpr) ) return;
@@ -2942,7 +3053,7 @@ static void sqlite3ExprCodeIN(
if( pParse->db->mallocFailed ) goto sqlite3ExprCodeIN_oom_error;
/* Attempt to compute the RHS. After this step, if anything other than
- ** IN_INDEX_NOOP is returned, the table opened ith cursor pExpr->iTable
+ ** IN_INDEX_NOOP is returned, the table opened with cursor iTab
** contains the values that make up the RHS. If IN_INDEX_NOOP is returned,
** the RHS has not yet been coded. */
v = pParse->pVdbe;
@@ -2950,7 +3061,8 @@ static void sqlite3ExprCodeIN(
VdbeNoopComment((v, "begin IN expr"));
eType = sqlite3FindInIndex(pParse, pExpr,
IN_INDEX_MEMBERSHIP | IN_INDEX_NOOP_OK,
- destIfFalse==destIfNull ? 0 : &rRhsHasNull, aiMap);
+ destIfFalse==destIfNull ? 0 : &rRhsHasNull,
+ aiMap, &iTab);
assert( pParse->nErr || nVector==1 || eType==IN_INDEX_EPH
|| eType==IN_INDEX_INDEX_ASC || eType==IN_INDEX_INDEX_DESC
@@ -2996,7 +3108,7 @@ static void sqlite3ExprCodeIN(
if( eType==IN_INDEX_NOOP ){
ExprList *pList = pExpr->x.pList;
CollSeq *pColl = sqlite3ExprCollSeq(pParse, pExpr->pLeft);
- int labelOk = sqlite3VdbeMakeLabel(v);
+ int labelOk = sqlite3VdbeMakeLabel(pParse);
int r2, regToFree;
int regCkNull = 0;
int ii;
@@ -3040,7 +3152,7 @@ static void sqlite3ExprCodeIN(
if( destIfNull==destIfFalse ){
destStep2 = destIfFalse;
}else{
- destStep2 = destStep6 = sqlite3VdbeMakeLabel(v);
+ destStep2 = destStep6 = sqlite3VdbeMakeLabel(pParse);
}
for(i=0; i<nVector; i++){
Expr *p = sqlite3VectorFieldSubexpr(pExpr->pLeft, i);
@@ -3058,19 +3170,19 @@ static void sqlite3ExprCodeIN(
/* In this case, the RHS is the ROWID of table b-tree and so we also
** know that the RHS is non-NULL. Hence, we combine steps 3 and 4
** into a single opcode. */
- sqlite3VdbeAddOp3(v, OP_SeekRowid, pExpr->iTable, destIfFalse, rLhs);
+ sqlite3VdbeAddOp3(v, OP_SeekRowid, iTab, destIfFalse, rLhs);
VdbeCoverage(v);
addrTruthOp = sqlite3VdbeAddOp0(v, OP_Goto); /* Return True */
}else{
sqlite3VdbeAddOp4(v, OP_Affinity, rLhs, nVector, 0, zAff, nVector);
if( destIfFalse==destIfNull ){
/* Combine Step 3 and Step 5 into a single opcode */
- sqlite3VdbeAddOp4Int(v, OP_NotFound, pExpr->iTable, destIfFalse,
+ sqlite3VdbeAddOp4Int(v, OP_NotFound, iTab, destIfFalse,
rLhs, nVector); VdbeCoverage(v);
goto sqlite3ExprCodeIN_finished;
}
/* Ordinary Step 3, for the case where FALSE and NULL are distinct */
- addrTruthOp = sqlite3VdbeAddOp4Int(v, OP_Found, pExpr->iTable, 0,
+ addrTruthOp = sqlite3VdbeAddOp4Int(v, OP_Found, iTab, 0,
rLhs, nVector); VdbeCoverage(v);
}
@@ -3095,10 +3207,10 @@ static void sqlite3ExprCodeIN(
** of the RHS.
*/
if( destStep6 ) sqlite3VdbeResolveLabel(v, destStep6);
- addrTop = sqlite3VdbeAddOp2(v, OP_Rewind, pExpr->iTable, destIfFalse);
+ addrTop = sqlite3VdbeAddOp2(v, OP_Rewind, iTab, destIfFalse);
VdbeCoverage(v);
if( nVector>1 ){
- destNotNull = sqlite3VdbeMakeLabel(v);
+ destNotNull = sqlite3VdbeMakeLabel(pParse);
}else{
/* For nVector==1, combine steps 6 and 7 by immediately returning
** FALSE if the first comparison is not NULL */
@@ -3110,7 +3222,7 @@ static void sqlite3ExprCodeIN(
int r3 = sqlite3GetTempReg(pParse);
p = sqlite3VectorFieldSubexpr(pLeft, i);
pColl = sqlite3ExprCollSeq(pParse, p);
- sqlite3VdbeAddOp3(v, OP_Column, pExpr->iTable, i, r3);
+ sqlite3VdbeAddOp3(v, OP_Column, iTab, i, r3);
sqlite3VdbeAddOp4(v, OP_Ne, rLhs+i, destNotNull, r3,
(void*)pColl, P4_COLLSEQ);
VdbeCoverage(v);
@@ -3119,7 +3231,7 @@ static void sqlite3ExprCodeIN(
sqlite3VdbeAddOp2(v, OP_Goto, 0, destIfNull);
if( nVector>1 ){
sqlite3VdbeResolveLabel(v, destNotNull);
- sqlite3VdbeAddOp2(v, OP_Next, pExpr->iTable, addrTop+1);
+ sqlite3VdbeAddOp2(v, OP_Next, iTab, addrTop+1);
VdbeCoverage(v);
/* Step 7: If we reach this point, we know that the result must
@@ -3318,7 +3430,7 @@ static int exprCodeVector(Parse *pParse, Expr *p, int *piFreeable){
#if SQLITE_OMIT_SUBQUERY
iResult = 0;
#else
- iResult = sqlite3CodeSubselect(pParse, p, 0, 0);
+ iResult = sqlite3CodeSubselect(pParse, p);
#endif
}else{
int i;
@@ -3663,7 +3775,7 @@ expr_code_doover:
** arguments past the first non-NULL argument.
*/
if( pDef->funcFlags & SQLITE_FUNC_COALESCE ){
- int endCoalesce = sqlite3VdbeMakeLabel(v);
+ int endCoalesce = sqlite3VdbeMakeLabel(pParse);
assert( nFarg>=2 );
sqlite3ExprCode(pParse, pFarg->a[0].pExpr, target);
for(i=1; i<nFarg; i++){
@@ -3792,14 +3904,14 @@ expr_code_doover:
if( op==TK_SELECT && (nCol = pExpr->x.pSelect->pEList->nExpr)!=1 ){
sqlite3SubselectError(pParse, nCol, 1);
}else{
- return sqlite3CodeSubselect(pParse, pExpr, 0, 0);
+ return sqlite3CodeSubselect(pParse, pExpr);
}
break;
}
case TK_SELECT_COLUMN: {
int n;
if( pExpr->pLeft->iTable==0 ){
- pExpr->pLeft->iTable = sqlite3CodeSubselect(pParse, pExpr->pLeft, 0, 0);
+ pExpr->pLeft->iTable = sqlite3CodeSubselect(pParse, pExpr->pLeft);
}
assert( pExpr->iTable==0 || pExpr->pLeft->op==TK_SELECT );
if( pExpr->iTable
@@ -3811,8 +3923,8 @@ expr_code_doover:
return pExpr->pLeft->iTable + pExpr->iColumn;
}
case TK_IN: {
- int destIfFalse = sqlite3VdbeMakeLabel(v);
- int destIfNull = sqlite3VdbeMakeLabel(v);
+ int destIfFalse = sqlite3VdbeMakeLabel(pParse);
+ int destIfNull = sqlite3VdbeMakeLabel(pParse);
sqlite3VdbeAddOp2(v, OP_Null, 0, target);
sqlite3ExprCodeIN(pParse, pExpr, destIfFalse, destIfNull);
sqlite3VdbeAddOp2(v, OP_Integer, 1, target);
@@ -3952,9 +4064,9 @@ expr_code_doover:
pEList = pExpr->x.pList;
aListelem = pEList->a;
nExpr = pEList->nExpr;
- endLabel = sqlite3VdbeMakeLabel(v);
+ endLabel = sqlite3VdbeMakeLabel(pParse);
if( (pX = pExpr->pLeft)!=0 ){
- tempX = *pX;
+ exprNodeCopy(&tempX, pX);
testcase( pX->op==TK_COLUMN );
exprToRegister(&tempX, exprCodeVector(pParse, &tempX, &regFree1));
testcase( regFree1==0 );
@@ -3975,7 +4087,7 @@ expr_code_doover:
}else{
pTest = aListelem[i].pExpr;
}
- nextCase = sqlite3VdbeMakeLabel(v);
+ nextCase = sqlite3VdbeMakeLabel(pParse);
testcase( pTest->op==TK_COLUMN );
sqlite3ExprIfFalse(pParse, pTest, nextCase, SQLITE_JUMPIFNULL);
testcase( aListelem[i+1].pExpr->op==TK_COLUMN );
@@ -4275,13 +4387,12 @@ static void exprCodeBetween(
Expr exprX; /* The x subexpression */
int regFree1 = 0; /* Temporary use register */
-
memset(&compLeft, 0, sizeof(Expr));
memset(&compRight, 0, sizeof(Expr));
memset(&exprAnd, 0, sizeof(Expr));
assert( !ExprHasProperty(pExpr, EP_xIsSelect) );
- exprX = *pExpr->pLeft;
+ exprNodeCopy(&exprX, pExpr->pLeft);
exprAnd.op = TK_AND;
exprAnd.pLeft = &compLeft;
exprAnd.pRight = &compRight;
@@ -4344,7 +4455,7 @@ void sqlite3ExprIfTrue(Parse *pParse, Expr *pExpr, int dest, int jumpIfNull){
op = pExpr->op;
switch( op ){
case TK_AND: {
- int d2 = sqlite3VdbeMakeLabel(v);
+ int d2 = sqlite3VdbeMakeLabel(pParse);
testcase( jumpIfNull==0 );
sqlite3ExprIfFalse(pParse, pExpr->pLeft, d2,jumpIfNull^SQLITE_JUMPIFNULL);
sqlite3ExprIfTrue(pParse, pExpr->pRight, dest, jumpIfNull);
@@ -4430,7 +4541,7 @@ void sqlite3ExprIfTrue(Parse *pParse, Expr *pExpr, int dest, int jumpIfNull){
}
#ifndef SQLITE_OMIT_SUBQUERY
case TK_IN: {
- int destIfFalse = sqlite3VdbeMakeLabel(v);
+ int destIfFalse = sqlite3VdbeMakeLabel(pParse);
int destIfNull = jumpIfNull ? dest : destIfFalse;
sqlite3ExprCodeIN(pParse, pExpr, destIfFalse, destIfNull);
sqlite3VdbeGoto(v, dest);
@@ -4517,7 +4628,7 @@ void sqlite3ExprIfFalse(Parse *pParse, Expr *pExpr, int dest, int jumpIfNull){
break;
}
case TK_OR: {
- int d2 = sqlite3VdbeMakeLabel(v);
+ int d2 = sqlite3VdbeMakeLabel(pParse);
testcase( jumpIfNull==0 );
sqlite3ExprIfTrue(pParse, pExpr->pLeft, d2, jumpIfNull^SQLITE_JUMPIFNULL);
sqlite3ExprIfFalse(pParse, pExpr->pRight, dest, jumpIfNull);
@@ -4601,7 +4712,7 @@ void sqlite3ExprIfFalse(Parse *pParse, Expr *pExpr, int dest, int jumpIfNull){
if( jumpIfNull ){
sqlite3ExprCodeIN(pParse, pExpr, dest, dest);
}else{
- int destIfNull = sqlite3VdbeMakeLabel(v);
+ int destIfNull = sqlite3VdbeMakeLabel(pParse);
sqlite3ExprCodeIN(pParse, pExpr, dest, destIfNull);
sqlite3VdbeResolveLabel(v, destIfNull);
}
@@ -4875,6 +4986,7 @@ static int impliesNotNullRow(Walker *pWalker, Expr *pExpr){
case TK_ISNOT:
case TK_NOT:
case TK_ISNULL:
+ case TK_NOTNULL:
case TK_IS:
case TK_OR:
case TK_CASE:
@@ -4883,6 +4995,7 @@ static int impliesNotNullRow(Walker *pWalker, Expr *pExpr){
testcase( pExpr->op==TK_ISNOT );
testcase( pExpr->op==TK_NOT );
testcase( pExpr->op==TK_ISNULL );
+ testcase( pExpr->op==TK_NOTNULL );
testcase( pExpr->op==TK_IS );
testcase( pExpr->op==TK_OR );
testcase( pExpr->op==TK_CASE );
@@ -5256,6 +5369,7 @@ void sqlite3ExprAnalyzeAggregates(NameContext *pNC, Expr *pExpr){
w.xSelectCallback2 = analyzeAggregatesInSelectEnd;
w.walkerDepth = 0;
w.u.pNC = pNC;
+ w.pParse = 0;
assert( pNC->pSrcList!=0 );
sqlite3WalkExpr(&w, pExpr);
}
diff --git a/chromium/third_party/sqlite/src/src/fkey.c b/chromium/third_party/sqlite/src/src/fkey.c
index b9aad0c9658..4106d12aaef 100644
--- a/chromium/third_party/sqlite/src/src/fkey.c
+++ b/chromium/third_party/sqlite/src/src/fkey.c
@@ -329,7 +329,7 @@ static void fkLookupParent(
int i; /* Iterator variable */
Vdbe *v = sqlite3GetVdbe(pParse); /* Vdbe to add code to */
int iCur = pParse->nTab - 1; /* Cursor number to use */
- int iOk = sqlite3VdbeMakeLabel(v); /* jump here if parent key found */
+ int iOk = sqlite3VdbeMakeLabel(pParse); /* jump here if parent key found */
sqlite3VdbeVerifyAbortable(v,
(!pFKey->isDeferred
@@ -618,7 +618,6 @@ static void fkScanChildren(
pNe = sqlite3PExpr(pParse, TK_NE, pLeft, pRight);
}else{
Expr *pEq, *pAll = 0;
- Index *pPk = sqlite3PrimaryKeyIndex(pTab);
assert( pIdx!=0 );
for(i=0; i<pIdx->nKeyCol; i++){
i16 iCol = pIdx->aiColumn[i];
@@ -730,7 +729,7 @@ void sqlite3FkDropTable(Parse *pParse, SrcList *pName, Table *pTab){
if( p->isDeferred || (db->flags & SQLITE_DeferFKs) ) break;
}
if( !p ) return;
- iSkip = sqlite3VdbeMakeLabel(v);
+ iSkip = sqlite3VdbeMakeLabel(pParse);
sqlite3VdbeAddOp2(v, OP_FkIfZero, 1, iSkip); VdbeCoverage(v);
}
@@ -1015,7 +1014,7 @@ void sqlite3FkCheck(
/* Create a SrcList structure containing the child table. We need the
** child table as a SrcList for sqlite3WhereBegin() */
- pSrc = sqlite3SrcListAppend(db, 0, 0, 0);
+ pSrc = sqlite3SrcListAppend(pParse, 0, 0, 0);
if( pSrc ){
struct SrcList_item *pItem = pSrc->a;
pItem->pTab = pFKey->pFrom;
@@ -1292,7 +1291,7 @@ static Trigger *fkActionTrigger(
}
pSelect = sqlite3SelectNew(pParse,
sqlite3ExprListAppend(pParse, 0, pRaise),
- sqlite3SrcListAppend(db, 0, &tFrom, 0),
+ sqlite3SrcListAppend(pParse, 0, &tFrom, 0),
pWhere,
0, 0, 0, 0, 0
);
diff --git a/chromium/third_party/sqlite/src/src/func.c b/chromium/third_party/sqlite/src/src/func.c
index 94d94f995ac..b08fa5e5454 100644
--- a/chromium/third_party/sqlite/src/src/func.c
+++ b/chromium/third_party/sqlite/src/src/func.c
@@ -201,6 +201,7 @@ static void instrFunc(
int typeHaystack, typeNeedle;
int N = 1;
int isText;
+ unsigned char firstChar;
UNUSED_PARAMETER(argc);
typeHaystack = sqlite3_value_type(argv[0]);
@@ -219,7 +220,10 @@ static void instrFunc(
isText = 1;
}
if( zNeedle==0 || (nHaystack && zHaystack==0) ) return;
- while( nNeedle<=nHaystack && memcmp(zHaystack, zNeedle, nNeedle)!=0 ){
+ firstChar = zNeedle[0];
+ while( nNeedle<=nHaystack
+ && (zHaystack[0]!=firstChar || memcmp(zHaystack, zNeedle, nNeedle)!=0)
+ ){
N++;
do{
nHaystack--;
@@ -510,11 +514,11 @@ static void randomBlob(
int argc,
sqlite3_value **argv
){
- int n;
+ sqlite3_int64 n;
unsigned char *p;
assert( argc==1 );
UNUSED_PARAMETER(argc);
- n = sqlite3_value_int(argv[0]);
+ n = sqlite3_value_int64(argv[0]);
if( n<1 ){
n = 1;
}
diff --git a/chromium/third_party/sqlite/src/src/global.c b/chromium/third_party/sqlite/src/src/global.c
index 8011df7e564..4e7bc0e946b 100644
--- a/chromium/third_party/sqlite/src/src/global.c
+++ b/chromium/third_party/sqlite/src/src/global.c
@@ -189,6 +189,13 @@ const unsigned char sqlite3CtypeMap[256] = {
#endif
+/* The default maximum size of an in-memory database created using
+** sqlite3_deserialize()
+*/
+#ifndef SQLITE_MEMDB_DEFAULT_MAXSIZE
+# define SQLITE_MEMDB_DEFAULT_MAXSIZE 1073741824
+#endif
+
/*
** The following singleton contains the global configuration for
** the SQLite library.
@@ -236,13 +243,16 @@ SQLITE_WSD struct Sqlite3Config sqlite3Config = {
0, /* xVdbeBranch */
0, /* pVbeBranchArg */
#endif
+#ifdef SQLITE_ENABLE_DESERIALIZE
+ SQLITE_MEMDB_DEFAULT_MAXSIZE, /* mxMemdbSize */
+#endif
#ifndef SQLITE_UNTESTABLE
0, /* xTestCallback */
#endif
0, /* bLocaltimeFault */
0, /* bInternalFunctions */
0x7ffffffe, /* iOnceResetThreshold */
- SQLITE_DEFAULT_SORTERREF_SIZE /* szSorterRef */
+ SQLITE_DEFAULT_SORTERREF_SIZE, /* szSorterRef */
};
/*
diff --git a/chromium/third_party/sqlite/src/src/hash.c b/chromium/third_party/sqlite/src/src/hash.c
index 04f67f67d27..1f0ef154f35 100644
--- a/chromium/third_party/sqlite/src/src/hash.c
+++ b/chromium/third_party/sqlite/src/src/hash.c
@@ -64,20 +64,6 @@ static unsigned int strHash(const char *z){
}
return h;
}
-#ifdef SQLITE_ENABLE_NORMALIZE
-static unsigned int strHashN(const char *z, int n){
- unsigned int h = 0;
- int i;
- for(i=0; i<n; i++){
- /* Knuth multiplicative hashing. (Sorting & Searching, p. 510).
- ** 0x9e3779b1 is 2654435761 which is the closest prime number to
- ** (2**32)*golden_ratio, where golden_ratio = (sqrt(5) - 1)/2. */
- h += sqlite3UpperToLower[z[i]];
- h *= 0x9e3779b1;
- }
- return h;
-}
-#endif /* SQLITE_ENABLE_NORMALIZE */
/* Link pNew element into the hash table pH. If pEntry!=0 then also
@@ -189,40 +175,6 @@ static HashElem *findElementWithHash(
}
return &nullElement;
}
-#ifdef SQLITE_ENABLE_NORMALIZE
-static HashElem *findElementWithHashN(
- const Hash *pH, /* The pH to be searched */
- const char *pKey, /* The key we are searching for */
- int nKey, /* Number of key bytes to use */
- unsigned int *pHash /* Write the hash value here */
-){
- HashElem *elem; /* Used to loop thru the element list */
- int count; /* Number of elements left to test */
- unsigned int h; /* The computed hash */
- static HashElem nullElement = { 0, 0, 0, 0 };
-
- if( pH->ht ){ /*OPTIMIZATION-IF-TRUE*/
- struct _ht *pEntry;
- h = strHashN(pKey, nKey) % pH->htsize;
- pEntry = &pH->ht[h];
- elem = pEntry->chain;
- count = pEntry->count;
- }else{
- h = 0;
- elem = pH->first;
- count = pH->count;
- }
- if( pHash ) *pHash = h;
- while( count-- ){
- assert( elem!=0 );
- if( sqlite3StrNICmp(elem->pKey,pKey,nKey)==0 ){
- return elem;
- }
- elem = elem->next;
- }
- return &nullElement;
-}
-#endif /* SQLITE_ENABLE_NORMALIZE */
/* Remove a single entry from the hash table given a pointer to that
** element and a hash on the element's key.
@@ -267,14 +219,6 @@ void *sqlite3HashFind(const Hash *pH, const char *pKey){
assert( pKey!=0 );
return findElementWithHash(pH, pKey, 0)->data;
}
-#ifdef SQLITE_ENABLE_NORMALIZE
-void *sqlite3HashFindN(const Hash *pH, const char *pKey, int nKey){
- assert( pH!=0 );
- assert( pKey!=0 );
- assert( nKey>=0 );
- return findElementWithHashN(pH, pKey, nKey, 0)->data;
-}
-#endif /* SQLITE_ENABLE_NORMALIZE */
/* Insert an element into the hash table pH. The key is pKey
** and the data is "data".
diff --git a/chromium/third_party/sqlite/src/src/insert.c b/chromium/third_party/sqlite/src/src/insert.c
index b21bf714923..6c358726f8d 100644
--- a/chromium/third_party/sqlite/src/src/insert.c
+++ b/chromium/third_party/sqlite/src/src/insert.c
@@ -319,6 +319,7 @@ void sqlite3AutoincrementBegin(Parse *pParse){
aOp[7].p2 = memId+2;
aOp[7].p1 = memId;
aOp[10].p2 = memId;
+ if( pParse->nTab==0 ) pParse->nTab = 1;
}
}
@@ -825,6 +826,11 @@ void sqlite3Insert(
}
#ifndef SQLITE_OMIT_UPSERT
if( pUpsert ){
+ if( IsVirtual(pTab) ){
+ sqlite3ErrorMsg(pParse, "UPSERT not implemented for virtual table \"%s\"",
+ pTab->zName);
+ goto insert_cleanup;
+ }
pTabList->a[0].iCursor = iDataCur;
pUpsert->pUpsertSrc = pTabList;
pUpsert->regData = regData;
@@ -865,7 +871,7 @@ void sqlite3Insert(
/* Run the BEFORE and INSTEAD OF triggers, if there are any
*/
- endOfLoop = sqlite3VdbeMakeLabel(v);
+ endOfLoop = sqlite3VdbeMakeLabel(pParse);
if( tmask & TRIGGER_BEFORE ){
int regCols = sqlite3GetTempRange(pParse, pTab->nCol+1);
@@ -1347,7 +1353,20 @@ void sqlite3GenerateConstraintChecks(
}
assert( onError==OE_Rollback || onError==OE_Abort || onError==OE_Fail
|| onError==OE_Ignore || onError==OE_Replace );
+ addr1 = 0;
switch( onError ){
+ case OE_Replace: {
+ assert( onError==OE_Replace );
+ addr1 = sqlite3VdbeMakeLabel(pParse);
+ sqlite3VdbeAddOp2(v, OP_NotNull, regNewData+1+i, addr1);
+ VdbeCoverage(v);
+ sqlite3ExprCode(pParse, pTab->aCol[i].pDflt, regNewData+1+i);
+ sqlite3VdbeAddOp2(v, OP_NotNull, regNewData+1+i, addr1);
+ VdbeCoverage(v);
+ onError = OE_Abort;
+ /* Fall through into the OE_Abort case to generate code that runs
+ ** if both the input and the default value are NULL */
+ }
case OE_Abort:
sqlite3MayAbort(pParse);
/* Fall through */
@@ -1360,21 +1379,15 @@ void sqlite3GenerateConstraintChecks(
sqlite3VdbeAppendP4(v, zMsg, P4_DYNAMIC);
sqlite3VdbeChangeP5(v, P5_ConstraintNotNull);
VdbeCoverage(v);
+ if( addr1 ) sqlite3VdbeResolveLabel(v, addr1);
break;
}
- case OE_Ignore: {
+ default: {
+ assert( onError==OE_Ignore );
sqlite3VdbeAddOp2(v, OP_IsNull, regNewData+1+i, ignoreDest);
VdbeCoverage(v);
break;
}
- default: {
- assert( onError==OE_Replace );
- addr1 = sqlite3VdbeAddOp1(v, OP_NotNull, regNewData+1+i);
- VdbeCoverage(v);
- sqlite3ExprCode(pParse, pTab->aCol[i].pDflt, regNewData+1+i);
- sqlite3VdbeJumpHere(v, addr1);
- break;
- }
}
}
@@ -1395,7 +1408,7 @@ void sqlite3GenerateConstraintChecks(
** updated so there is no point it verifying the check constraint */
continue;
}
- allOk = sqlite3VdbeMakeLabel(v);
+ allOk = sqlite3VdbeMakeLabel(pParse);
sqlite3VdbeVerifyAbortable(v, onError);
sqlite3ExprIfTrue(pParse, pExpr, allOk, SQLITE_JUMPIFNULL);
if( onError==OE_Ignore ){
@@ -1462,7 +1475,7 @@ void sqlite3GenerateConstraintChecks(
** exist in the table.
*/
if( pkChng && pPk==0 ){
- int addrRowidOk = sqlite3VdbeMakeLabel(v);
+ int addrRowidOk = sqlite3VdbeMakeLabel(pParse);
/* Figure out what action to take in case of a rowid collision */
onError = pTab->keyConf;
@@ -1612,7 +1625,7 @@ void sqlite3GenerateConstraintChecks(
VdbeComment((v, "Skip upsert subroutine"));
sqlite3VdbeJumpHere(v, upsertJump);
}else{
- addrUniqueOk = sqlite3VdbeMakeLabel(v);
+ addrUniqueOk = sqlite3VdbeMakeLabel(pParse);
}
if( bAffinityDone==0 && (pUpIdx==0 || pUpIdx==pIdx) ){
sqlite3TableAffinity(v, pTab, regNewData+1);
@@ -1695,7 +1708,11 @@ void sqlite3GenerateConstraintChecks(
** (3) There are no secondary indexes on the table
** (4) No delete triggers need to be fired if there is a conflict
** (5) No FK constraint counters need to be updated if a conflict occurs.
- */
+ **
+ ** This is not possible for ENABLE_PREUPDATE_HOOK builds, as the row
+ ** must be explicitly deleted in order to ensure any pre-update hook
+ ** is invoked. */
+#ifndef SQLITE_ENABLE_PREUPDATE_HOOK
if( (ix==0 && pIdx->pNext==0) /* Condition 3 */
&& pPk==pIdx /* Condition 2 */
&& onError==OE_Replace /* Condition 1 */
@@ -1707,6 +1724,7 @@ void sqlite3GenerateConstraintChecks(
sqlite3VdbeResolveLabel(v, addrUniqueOk);
continue;
}
+#endif /* ifndef SQLITE_ENABLE_PREUPDATE_HOOK */
/* Check to see if the new index entry will be unique */
sqlite3VdbeVerifyAbortable(v, onError);
diff --git a/chromium/third_party/sqlite/src/src/legacy.c b/chromium/third_party/sqlite/src/src/legacy.c
index 2efbc52c127..06b8f4e8e91 100644
--- a/chromium/third_party/sqlite/src/src/legacy.c
+++ b/chromium/third_party/sqlite/src/src/legacy.c
@@ -46,7 +46,7 @@ int sqlite3_exec(
sqlite3_mutex_enter(db->mutex);
sqlite3Error(db, SQLITE_OK);
while( rc==SQLITE_OK && zSql[0] ){
- int nCol;
+ int nCol = 0;
char **azVals = 0;
pStmt = 0;
@@ -60,9 +60,7 @@ int sqlite3_exec(
zSql = zLeftover;
continue;
}
-
callbackIsInit = 0;
- nCol = sqlite3_column_count(pStmt);
while( 1 ){
int i;
@@ -73,6 +71,7 @@ int sqlite3_exec(
(SQLITE_DONE==rc && !callbackIsInit
&& db->flags&SQLITE_NullCallback)) ){
if( !callbackIsInit ){
+ nCol = sqlite3_column_count(pStmt);
azCols = sqlite3DbMallocRaw(db, (2*nCol+1)*sizeof(const char*));
if( azCols==0 ){
goto exec_out;
diff --git a/chromium/third_party/sqlite/src/src/loadext.c b/chromium/third_party/sqlite/src/src/loadext.c
index 142a89a52e7..b926ea4c89e 100644
--- a/chromium/third_party/sqlite/src/src/loadext.c
+++ b/chromium/third_party/sqlite/src/src/loadext.c
@@ -650,7 +650,7 @@ int sqlite3_enable_load_extension(sqlite3 *db, int onoff){
if( onoff ){
db->flags |= SQLITE_LoadExtension|SQLITE_LoadExtFunc;
}else{
- db->flags &= ~(SQLITE_LoadExtension|SQLITE_LoadExtFunc);
+ db->flags &= ~(u64)(SQLITE_LoadExtension|SQLITE_LoadExtFunc);
}
sqlite3_mutex_leave(db->mutex);
return SQLITE_OK;
diff --git a/chromium/third_party/sqlite/src/src/main.c b/chromium/third_party/sqlite/src/src/main.c
index 478428ac27c..d58f8c633f8 100644
--- a/chromium/third_party/sqlite/src/src/main.c
+++ b/chromium/third_party/sqlite/src/src/main.c
@@ -653,6 +653,13 @@ int sqlite3_config(int op, ...){
}
#endif /* SQLITE_ENABLE_SORTER_REFERENCES */
+#ifdef SQLITE_ENABLE_DESERIALIZE
+ case SQLITE_CONFIG_MEMDB_MAXSIZE: {
+ sqlite3GlobalConfig.mxMemdbSize = va_arg(ap, sqlite3_int64);
+ break;
+ }
+#endif /* SQLITE_ENABLE_DESERIALIZE */
+
default: {
rc = SQLITE_ERROR;
break;
@@ -843,11 +850,11 @@ int sqlite3_db_config(sqlite3 *db, int op, ...){
if( aFlagOp[i].op==op ){
int onoff = va_arg(ap, int);
int *pRes = va_arg(ap, int*);
- u32 oldFlags = db->flags;
+ u64 oldFlags = db->flags;
if( onoff>0 ){
db->flags |= aFlagOp[i].mask;
}else if( onoff==0 ){
- db->flags &= ~aFlagOp[i].mask;
+ db->flags &= ~(u64)aFlagOp[i].mask;
}
if( oldFlags!=db->flags ){
sqlite3ExpirePreparedStatements(db, 0);
@@ -1310,7 +1317,7 @@ void sqlite3RollbackAll(sqlite3 *db, int tripCode){
/* Any deferred constraint violations have now been resolved. */
db->nDeferredCons = 0;
db->nDeferredImmCons = 0;
- db->flags &= ~SQLITE_DeferFKs;
+ db->flags &= ~(u64)SQLITE_DeferFKs;
/* If one has been configured, invoke the rollback-hook callback */
if( db->xRollbackCallback && (inTrans || !db->autoCommit) ){
@@ -2052,6 +2059,8 @@ void *sqlite3_profile(
pOld = db->pProfileArg;
db->xProfile = xProfile;
db->pProfileArg = pArg;
+ db->mTrace &= SQLITE_TRACE_NONLEGACY_MASK;
+ if( db->xProfile ) db->mTrace |= SQLITE_TRACE_XPROFILE;
sqlite3_mutex_leave(db->mutex);
return pOld;
}
@@ -2403,7 +2412,7 @@ const char *sqlite3_errmsg(sqlite3 *db){
z = sqlite3ErrStr(SQLITE_NOMEM_BKPT);
}else{
testcase( db->pErr==0 );
- z = (char*)sqlite3_value_text(db->pErr);
+ z = db->errCode ? (char*)sqlite3_value_text(db->pErr) : 0;
assert( !db->mallocFailed );
if( z==0 ){
z = sqlite3ErrStr(db->errCode);
@@ -2933,6 +2942,40 @@ int sqlite3ParseUri(
return rc;
}
+#if defined(SQLITE_HAS_CODEC)
+/*
+** Process URI filename query parameters relevant to the SQLite Encryption
+** Extension. Return true if any of the relevant query parameters are
+** seen and return false if not.
+*/
+int sqlite3CodecQueryParameters(
+ sqlite3 *db, /* Database connection */
+ const char *zDb, /* Which schema is being created/attached */
+ const char *zUri /* URI filename */
+){
+ const char *zKey;
+ if( (zKey = sqlite3_uri_parameter(zUri, "hexkey"))!=0 && zKey[0] ){
+ u8 iByte;
+ int i;
+ char zDecoded[40];
+ for(i=0, iByte=0; i<sizeof(zDecoded)*2 && sqlite3Isxdigit(zKey[i]); i++){
+ iByte = (iByte<<4) + sqlite3HexToInt(zKey[i]);
+ if( (i&1)!=0 ) zDecoded[i/2] = iByte;
+ }
+ sqlite3_key_v2(db, zDb, zDecoded, i/2);
+ return 1;
+ }else if( (zKey = sqlite3_uri_parameter(zUri, "key"))!=0 ){
+ sqlite3_key_v2(db, zDb, zKey, sqlite3Strlen30(zKey));
+ return 1;
+ }else if( (zKey = sqlite3_uri_parameter(zUri, "textkey"))!=0 ){
+ sqlite3_key_v2(db, zDb, zKey, -1);
+ return 1;
+ }else{
+ return 0;
+ }
+}
+#endif
+
/*
** This routine does the work of opening a database on behalf of
@@ -3286,26 +3329,13 @@ opendb_out:
}
#endif
#if defined(SQLITE_HAS_CODEC)
- if( rc==SQLITE_OK ){
- const char *zKey;
- if( (zKey = sqlite3_uri_parameter(zOpen, "hexkey"))!=0 && zKey[0] ){
- u8 iByte;
- int i;
- char zDecoded[40];
- for(i=0, iByte=0; i<sizeof(zDecoded)*2 && sqlite3Isxdigit(zKey[i]); i++){
- iByte = (iByte<<4) + sqlite3HexToInt(zKey[i]);
- if( (i&1)!=0 ) zDecoded[i/2] = iByte;
- }
- sqlite3_key_v2(db, 0, zDecoded, i/2);
- }else if( (zKey = sqlite3_uri_parameter(zOpen, "key"))!=0 ){
- sqlite3_key_v2(db, 0, zKey, sqlite3Strlen30(zKey));
- }
- }
+ if( rc==SQLITE_OK ) sqlite3CodecQueryParameters(db, 0, zOpen);
#endif
sqlite3_free(zOpen);
return rc & 0xff;
}
+
/*
** Open a new database handle.
*/
diff --git a/chromium/third_party/sqlite/src/src/memdb.c b/chromium/third_party/sqlite/src/src/memdb.c
index 15b4b277ee3..58da0488918 100644
--- a/chromium/third_party/sqlite/src/src/memdb.c
+++ b/chromium/third_party/sqlite/src/src/memdb.c
@@ -34,7 +34,8 @@ typedef struct MemFile MemFile;
struct MemFile {
sqlite3_file base; /* IO methods */
sqlite3_int64 sz; /* Size of the file */
- sqlite3_int64 szMax; /* Space allocated to aData */
+ sqlite3_int64 szAlloc; /* Space allocated to aData */
+ sqlite3_int64 szMax; /* Maximum allowed size of the file */
unsigned char *aData; /* content of the file */
int nMmap; /* Number of memory mapped pages */
unsigned mFlags; /* Flags */
@@ -160,10 +161,15 @@ static int memdbEnlarge(MemFile *p, sqlite3_int64 newSz){
if( (p->mFlags & SQLITE_DESERIALIZE_RESIZEABLE)==0 || p->nMmap>0 ){
return SQLITE_FULL;
}
+ if( newSz>p->szMax ){
+ return SQLITE_FULL;
+ }
+ newSz *= 2;
+ if( newSz>p->szMax ) newSz = p->szMax;
pNew = sqlite3_realloc64(p->aData, newSz);
if( pNew==0 ) return SQLITE_NOMEM;
p->aData = pNew;
- p->szMax = newSz;
+ p->szAlloc = newSz;
return SQLITE_OK;
}
@@ -177,10 +183,11 @@ static int memdbWrite(
sqlite_int64 iOfst
){
MemFile *p = (MemFile *)pFile;
+ if( NEVER(p->mFlags & SQLITE_DESERIALIZE_READONLY) ) return SQLITE_READONLY;
if( iOfst+iAmt>p->sz ){
int rc;
- if( iOfst+iAmt>p->szMax
- && (rc = memdbEnlarge(p, (iOfst+iAmt)*2))!=SQLITE_OK
+ if( iOfst+iAmt>p->szAlloc
+ && (rc = memdbEnlarge(p, iOfst+iAmt))!=SQLITE_OK
){
return rc;
}
@@ -226,6 +233,11 @@ static int memdbFileSize(sqlite3_file *pFile, sqlite_int64 *pSize){
*/
static int memdbLock(sqlite3_file *pFile, int eLock){
MemFile *p = (MemFile *)pFile;
+ if( eLock>SQLITE_LOCK_SHARED
+ && (p->mFlags & SQLITE_DESERIALIZE_READONLY)!=0
+ ){
+ return SQLITE_READONLY;
+ }
p->eLock = eLock;
return SQLITE_OK;
}
@@ -250,6 +262,19 @@ static int memdbFileControl(sqlite3_file *pFile, int op, void *pArg){
*(char**)pArg = sqlite3_mprintf("memdb(%p,%lld)", p->aData, p->sz);
rc = SQLITE_OK;
}
+ if( op==SQLITE_FCNTL_SIZE_LIMIT ){
+ sqlite3_int64 iLimit = *(sqlite3_int64*)pArg;
+ if( iLimit<p->sz ){
+ if( iLimit<0 ){
+ iLimit = p->szMax;
+ }else{
+ iLimit = p->sz;
+ }
+ }
+ p->szMax = iLimit;
+ *(sqlite3_int64*)pArg = iLimit;
+ rc = SQLITE_OK;
+ }
return rc;
}
@@ -280,8 +305,12 @@ static int memdbFetch(
void **pp
){
MemFile *p = (MemFile *)pFile;
- p->nMmap++;
- *pp = (void*)(p->aData + iOfst);
+ if( iOfst+iAmt>p->sz ){
+ *pp = 0;
+ }else{
+ p->nMmap++;
+ *pp = (void*)(p->aData + iOfst);
+ }
return SQLITE_OK;
}
@@ -311,6 +340,7 @@ static int memdbOpen(
assert( pOutFlags!=0 ); /* True because flags==SQLITE_OPEN_MAIN_DB */
*pOutFlags = flags | SQLITE_OPEN_MEMORY;
p->base.pMethods = &memdb_io_methods;
+ p->szMax = sqlite3GlobalConfig.mxMemdbSize;
return SQLITE_OK;
}
@@ -560,7 +590,11 @@ int sqlite3_deserialize(
}else{
p->aData = pData;
p->sz = szDb;
+ p->szAlloc = szBuf;
p->szMax = szBuf;
+ if( p->szMax<sqlite3GlobalConfig.mxMemdbSize ){
+ p->szMax = sqlite3GlobalConfig.mxMemdbSize;
+ }
p->mFlags = mFlags;
rc = SQLITE_OK;
}
diff --git a/chromium/third_party/sqlite/src/src/pager.c b/chromium/third_party/sqlite/src/src/pager.c
index 771330e9ab2..35f625d2c03 100644
--- a/chromium/third_party/sqlite/src/src/pager.c
+++ b/chromium/third_party/sqlite/src/src/pager.c
@@ -3839,7 +3839,10 @@ int sqlite3PagerMaxPageCount(Pager *pPager, int mxPage){
pPager->mxPgno = mxPage;
}
assert( pPager->eState!=PAGER_OPEN ); /* Called only by OP_MaxPgcnt */
- assert( pPager->mxPgno>=pPager->dbSize ); /* OP_MaxPgcnt enforces this */
+ /* assert( pPager->mxPgno>=pPager->dbSize ); */
+ /* OP_MaxPgcnt ensures that the parameter passed to this function is not
+ ** less than the total number of valid pages in the database. But this
+ ** may be less than Pager.dbSize, and so the assert() above is not valid */
return pPager->mxPgno;
}
diff --git a/chromium/third_party/sqlite/src/src/parse.y b/chromium/third_party/sqlite/src/src/parse.y
index cd38ebf51b5..845aec962fb 100644
--- a/chromium/third_party/sqlite/src/src/parse.y
+++ b/chromium/third_party/sqlite/src/src/parse.y
@@ -664,6 +664,12 @@ seltablist(A) ::= stl_prefix(A) nm(Y) dbnm(D) LP exprlist(E) RP as(Z)
pNew->zName = pOld->zName;
pNew->zDatabase = pOld->zDatabase;
pNew->pSelect = pOld->pSelect;
+ if( pOld->fg.isTabFunc ){
+ pNew->u1.pFuncArg = pOld->u1.pFuncArg;
+ pOld->u1.pFuncArg = 0;
+ pOld->fg.isTabFunc = 0;
+ pNew->fg.isTabFunc = 1;
+ }
pOld->zName = pOld->zDatabase = 0;
pOld->pSelect = 0;
}
@@ -684,26 +690,26 @@ dbnm(A) ::= DOT nm(X). {A = X;}
%type fullname {SrcList*}
%destructor fullname {sqlite3SrcListDelete(pParse->db, $$);}
fullname(A) ::= nm(X). {
- A = sqlite3SrcListAppend(pParse->db,0,&X,0);
+ A = sqlite3SrcListAppend(pParse,0,&X,0);
if( IN_RENAME_OBJECT && A ) sqlite3RenameTokenMap(pParse, A->a[0].zName, &X);
}
fullname(A) ::= nm(X) DOT nm(Y). {
- A = sqlite3SrcListAppend(pParse->db,0,&X,&Y);
+ A = sqlite3SrcListAppend(pParse,0,&X,&Y);
if( IN_RENAME_OBJECT && A ) sqlite3RenameTokenMap(pParse, A->a[0].zName, &Y);
}
%type xfullname {SrcList*}
%destructor xfullname {sqlite3SrcListDelete(pParse->db, $$);}
xfullname(A) ::= nm(X).
- {A = sqlite3SrcListAppend(pParse->db,0,&X,0); /*A-overwrites-X*/}
+ {A = sqlite3SrcListAppend(pParse,0,&X,0); /*A-overwrites-X*/}
xfullname(A) ::= nm(X) DOT nm(Y).
- {A = sqlite3SrcListAppend(pParse->db,0,&X,&Y); /*A-overwrites-X*/}
+ {A = sqlite3SrcListAppend(pParse,0,&X,&Y); /*A-overwrites-X*/}
xfullname(A) ::= nm(X) DOT nm(Y) AS nm(Z). {
- A = sqlite3SrcListAppend(pParse->db,0,&X,&Y); /*A-overwrites-X*/
+ A = sqlite3SrcListAppend(pParse,0,&X,&Y); /*A-overwrites-X*/
if( A ) A->a[0].zAlias = sqlite3NameFromToken(pParse->db, &Z);
}
xfullname(A) ::= nm(X) AS nm(Z). {
- A = sqlite3SrcListAppend(pParse->db,0,&X,0); /*A-overwrites-X*/
+ A = sqlite3SrcListAppend(pParse,0,&X,0); /*A-overwrites-X*/
if( A ) A->a[0].zAlias = sqlite3NameFromToken(pParse->db, &Z);
}
@@ -820,6 +826,10 @@ limit_opt(A) ::= LIMIT expr(X) COMMA expr(Y).
cmd ::= with DELETE FROM xfullname(X) indexed_opt(I) where_opt(W)
orderby_opt(O) limit_opt(L). {
sqlite3SrcListIndexedBy(pParse, X, &I);
+#ifndef SQLITE_ENABLE_UPDATE_DELETE_LIMIT
+ sqlite3ExprListDelete(pParse->db, O); O = 0;
+ sqlite3ExprDelete(pParse->db, L); L = 0;
+#endif
sqlite3DeleteFrom(pParse,X,W,O,L);
}
%endif
@@ -949,8 +959,7 @@ idlist(A) ::= nm(Y).
memcpy(p->u.zToken, t.z, t.n);
p->u.zToken[t.n] = 0;
if( sqlite3Isquote(p->u.zToken[0]) ){
- if( p->u.zToken[0]=='"' ) p->flags |= EP_DblQuoted;
- sqlite3Dequote(p->u.zToken);
+ sqlite3DequoteExpr(p);
}
#if SQLITE_MAX_EXPR_DEPTH>0
p->nHeight = 1;
@@ -1161,8 +1170,10 @@ expr(A) ::= expr(A) between_op(N) expr(X) AND expr(Y). [BETWEEN] {
** simplify to constants 0 (false) and 1 (true), respectively,
** regardless of the value of expr1.
*/
- sqlite3ExprDelete(pParse->db, A);
- A = sqlite3ExprAlloc(pParse->db, TK_INTEGER,&sqlite3IntTokens[N],1);
+ if( IN_RENAME_OBJECT==0 ){
+ sqlite3ExprDelete(pParse->db, A);
+ A = sqlite3ExprAlloc(pParse->db, TK_INTEGER,&sqlite3IntTokens[N],1);
+ }
}else if( Y->nExpr==1 ){
/* Expressions of the form:
**
@@ -1211,7 +1222,7 @@ expr(A) ::= expr(A) between_op(N) expr(X) AND expr(Y). [BETWEEN] {
if( N ) A = sqlite3PExpr(pParse, TK_NOT, A, 0);
}
expr(A) ::= expr(A) in_op(N) nm(Y) dbnm(Z) paren_exprlist(E). [IN] {
- SrcList *pSrc = sqlite3SrcListAppend(pParse->db, 0,&Y,&Z);
+ SrcList *pSrc = sqlite3SrcListAppend(pParse, 0,&Y,&Z);
Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0);
if( E ) sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, E);
A = sqlite3PExpr(pParse, TK_IN, A, 0);
@@ -1282,7 +1293,7 @@ paren_exprlist(A) ::= LP exprlist(X) RP. {A = X;}
cmd ::= createkw(S) uniqueflag(U) INDEX ifnotexists(NE) nm(X) dbnm(D)
ON nm(Y) LP sortlist(Z) RP where_opt(W). {
sqlite3CreateIndex(pParse, &X, &D,
- sqlite3SrcListAppend(pParse->db,0,&Y,0), Z, U,
+ sqlite3SrcListAppend(pParse,0,&Y,0), Z, U,
&S, W, SQLITE_SO_ASC, NE, SQLITE_IDXTYPE_APPDEF);
if( IN_RENAME_OBJECT && pParse->pNewIndex ){
sqlite3RenameTokenMap(pParse, pParse->pNewIndex->zName, &Y);
@@ -1361,8 +1372,12 @@ cmd ::= DROP INDEX ifexists(E) fullname(X). {sqlite3DropIndex(pParse, X, E);}
//
%ifndef SQLITE_OMIT_VACUUM
%ifndef SQLITE_OMIT_ATTACH
-cmd ::= VACUUM. {sqlite3Vacuum(pParse,0);}
-cmd ::= VACUUM nm(X). {sqlite3Vacuum(pParse,&X);}
+%type vinto {Expr*}
+%destructor vinto {sqlite3ExprDelete(pParse->db, $$);}
+cmd ::= VACUUM vinto(Y). {sqlite3Vacuum(pParse,0,Y);}
+cmd ::= VACUUM nm(X) vinto(Y). {sqlite3Vacuum(pParse,&X,Y);}
+vinto(A) ::= INTO expr(X). {A = X;}
+vinto(A) ::= . {A = 0;}
%endif SQLITE_OMIT_ATTACH
%endif SQLITE_OMIT_VACUUM
diff --git a/chromium/third_party/sqlite/src/src/pcache1.c b/chromium/third_party/sqlite/src/src/pcache1.c
index 05ef4bde330..aac42677e42 100644
--- a/chromium/third_party/sqlite/src/src/pcache1.c
+++ b/chromium/third_party/sqlite/src/src/pcache1.c
@@ -92,16 +92,27 @@ typedef struct PGroup PGroup;
** structure. Unless SQLITE_PCACHE_SEPARATE_HEADER is defined, a buffer of
** PgHdr1.pCache->szPage bytes is allocated directly before this structure
** in memory.
+**
+** Note: Variables isBulkLocal and isAnchor were once type "u8". That works,
+** but causes a 2-byte gap in the structure for most architectures (since
+** pointers must be either 4 or 8-byte aligned). As this structure is located
+** in memory directly after the associated page data, if the database is
+** corrupt, code at the b-tree layer may overread the page buffer and
+** read part of this structure before the corruption is detected. This
+** can cause a valgrind error if the unitialized gap is accessed. Using u16
+** ensures there is no such gap, and therefore no bytes of unitialized memory
+** in the structure.
*/
struct PgHdr1 {
sqlite3_pcache_page page; /* Base class. Must be first. pBuf & pExtra */
unsigned int iKey; /* Key value (page number) */
- u8 isBulkLocal; /* This page from bulk local storage */
- u8 isAnchor; /* This is the PGroup.lru element */
+ u16 isBulkLocal; /* This page from bulk local storage */
+ u16 isAnchor; /* This is the PGroup.lru element */
PgHdr1 *pNext; /* Next in hash table chain */
PCache1 *pCache; /* Cache that currently owns this page */
PgHdr1 *pLruNext; /* Next in LRU list of unpinned pages */
PgHdr1 *pLruPrev; /* Previous in LRU list of unpinned pages */
+ /* NB: pLruPrev is only valid if pLruNext!=0 */
};
/*
@@ -302,6 +313,7 @@ static int pcache1InitBulk(PCache1 *pCache){
pX->isBulkLocal = 1;
pX->isAnchor = 0;
pX->pNext = pCache->pFree;
+ pX->pLruPrev = 0; /* Initializing this saves a valgrind error */
pCache->pFree = pX;
zBulk += pCache->szAlloc;
}while( --nBulk );
@@ -574,7 +586,8 @@ static PgHdr1 *pcache1PinPage(PgHdr1 *pPage){
pPage->pLruPrev->pLruNext = pPage->pLruNext;
pPage->pLruNext->pLruPrev = pPage->pLruPrev;
pPage->pLruNext = 0;
- pPage->pLruPrev = 0;
+ /* pPage->pLruPrev = 0;
+ ** No need to clear pLruPrev as it is never accessed if pLruNext is 0 */
assert( pPage->isAnchor==0 );
assert( pPage->pCache->pGroup->lru.isAnchor==1 );
pPage->pCache->nRecyclable--;
@@ -911,8 +924,9 @@ static SQLITE_NOINLINE PgHdr1 *pcache1FetchStage2(
pPage->iKey = iKey;
pPage->pNext = pCache->apHash[h];
pPage->pCache = pCache;
- pPage->pLruPrev = 0;
pPage->pLruNext = 0;
+ /* pPage->pLruPrev = 0;
+ ** No need to clear pLruPrev since it is not accessed when pLruNext==0 */
*(void **)pPage->page.pExtra = 0;
pCache->apHash[h] = pPage;
if( iKey>pCache->iMaxKey ){
@@ -1072,7 +1086,7 @@ static void pcache1Unpin(
/* It is an error to call this function if the page is already
** part of the PGroup LRU list.
*/
- assert( pPage->pLruPrev==0 && pPage->pLruNext==0 );
+ assert( pPage->pLruNext==0 );
assert( PAGE_IS_PINNED(pPage) );
if( reuseUnlikely || pGroup->nPurgeable>pGroup->nMaxPage ){
diff --git a/chromium/third_party/sqlite/src/src/pragma.c b/chromium/third_party/sqlite/src/src/pragma.c
index 264b10d9464..7dec846f22d 100644
--- a/chromium/third_party/sqlite/src/src/pragma.c
+++ b/chromium/third_party/sqlite/src/src/pragma.c
@@ -816,7 +816,7 @@ void sqlite3Pragma(
if( sqlite3GetBoolean(zRight, size!=0) ){
db->flags |= SQLITE_CacheSpill;
}else{
- db->flags &= ~SQLITE_CacheSpill;
+ db->flags &= ~(u64)SQLITE_CacheSpill;
}
setAllPagerFlags(db);
}
@@ -1376,7 +1376,7 @@ void sqlite3Pragma(
x = sqlite3FkLocateIndex(pParse, pParent, pFK, &pIdx, &aiCols);
assert( x==0 );
}
- addrOk = sqlite3VdbeMakeLabel(v);
+ addrOk = sqlite3VdbeMakeLabel(pParse);
/* Generate code to read the child key values into registers
** regRow..regRow+n. If any of the child key values are NULL, this
@@ -1421,19 +1421,6 @@ void sqlite3Pragma(
#endif /* !defined(SQLITE_OMIT_TRIGGER) */
#endif /* !defined(SQLITE_OMIT_FOREIGN_KEY) */
-#ifndef NDEBUG
- case PragTyp_PARSER_TRACE: {
- if( zRight ){
- if( sqlite3GetBoolean(zRight, 0) ){
- sqlite3ParserTrace(stdout, "parser: ");
- }else{
- sqlite3ParserTrace(0, 0);
- }
- }
- }
- break;
-#endif
-
/* Reinstall the LIKE and GLOB functions. The variant of LIKE
** used will be case sensitive or not depending on the RHS.
*/
@@ -1596,8 +1583,8 @@ void sqlite3Pragma(
if( pTab->pCheck && (db->flags & SQLITE_IgnoreChecks)==0 ){
ExprList *pCheck = sqlite3ExprListDup(db, pTab->pCheck, 0);
if( db->mallocFailed==0 ){
- int addrCkFault = sqlite3VdbeMakeLabel(v);
- int addrCkOk = sqlite3VdbeMakeLabel(v);
+ int addrCkFault = sqlite3VdbeMakeLabel(pParse);
+ int addrCkOk = sqlite3VdbeMakeLabel(pParse);
char *zErr;
int k;
pParse->iSelfTab = iDataCur + 1;
@@ -1620,7 +1607,7 @@ void sqlite3Pragma(
/* Validate index entries for the current row */
for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
int jmp2, jmp3, jmp4, jmp5;
- int ckUniq = sqlite3VdbeMakeLabel(v);
+ int ckUniq = sqlite3VdbeMakeLabel(pParse);
if( pPk==pIdx ) continue;
r1 = sqlite3GenerateIndexKey(pParse, pIdx, iDataCur, 0, 0, &jmp3,
pPrior, r1);
@@ -1641,7 +1628,7 @@ void sqlite3Pragma(
** current key. The entry is unique if (1) any column is NULL
** or (2) the next entry has a different key */
if( IsUniqueIndex(pIdx) ){
- int uniqOk = sqlite3VdbeMakeLabel(v);
+ int uniqOk = sqlite3VdbeMakeLabel(pParse);
int jmp6;
int kk;
for(kk=0; kk<pIdx->nKeyCol; kk++){
diff --git a/chromium/third_party/sqlite/src/src/pragma.h b/chromium/third_party/sqlite/src/src/pragma.h
index c16dd2f0878..6dbc995610d 100644
--- a/chromium/third_party/sqlite/src/src/pragma.h
+++ b/chromium/third_party/sqlite/src/src/pragma.h
@@ -49,8 +49,7 @@
#define PragTyp_HEXKEY 41
#define PragTyp_KEY 42
#define PragTyp_LOCK_STATUS 43
-#define PragTyp_PARSER_TRACE 44
-#define PragTyp_STATS 45
+#define PragTyp_STATS 44
/* Property flags associated with various pragma. */
#define PragFlg_NeedSchema 0x01 /* Force schema load before running */
@@ -461,12 +460,14 @@ static const PragmaName aPragmaName[] = {
/* ColNames: */ 0, 0,
/* iArg: */ 0 },
#endif
-#if defined(SQLITE_DEBUG) && !defined(SQLITE_OMIT_PARSER_TRACE)
+#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
+#if defined(SQLITE_DEBUG)
{/* zName: */ "parser_trace",
- /* ePragTyp: */ PragTyp_PARSER_TRACE,
- /* ePragFlg: */ 0,
+ /* ePragTyp: */ PragTyp_FLAG,
+ /* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
/* ColNames: */ 0, 0,
- /* iArg: */ 0 },
+ /* iArg: */ SQLITE_ParserTrace },
+#endif
#endif
#if defined(SQLITE_INTROSPECTION_PRAGMAS)
{/* zName: */ "pragma_list",
diff --git a/chromium/third_party/sqlite/src/src/prepare.c b/chromium/third_party/sqlite/src/src/prepare.c
index 87711315a0c..5f009c28636 100644
--- a/chromium/third_party/sqlite/src/src/prepare.c
+++ b/chromium/third_party/sqlite/src/src/prepare.c
@@ -45,6 +45,19 @@ static void corruptSchema(
}
/*
+** Check to see if any sibling index (another index on the same table)
+** of pIndex has the same root page number, and if it does, return true.
+** This would indicate a corrupt schema.
+*/
+int sqlite3IndexHasDuplicateRootPage(Index *pIndex){
+ Index *p;
+ for(p=pIndex->pTable->pIndex; p; p=p->pNext){
+ if( p->tnum==pIndex->tnum && p!=pIndex ) return 1;
+ }
+ return 0;
+}
+
+/*
** This is the callback routine for the code that initializes the
** database. See sqlite3Init() below for additional information.
** This routine is also called from the OP_ParseSchema opcode of the VDBE.
@@ -65,6 +78,7 @@ int sqlite3InitCallback(void *pInit, int argc, char **argv, char **NotUsed){
UNUSED_PARAMETER2(NotUsed, argc);
assert( sqlite3_mutex_held(db->mutex) );
DbClearProperty(db, iDb, DB_Empty);
+ pData->nInitRow++;
if( db->mallocFailed ){
corruptSchema(pData, argv[0], 0);
return 1;
@@ -121,6 +135,7 @@ int sqlite3InitCallback(void *pInit, int argc, char **argv, char **NotUsed){
if( pIndex==0
|| sqlite3GetInt32(argv[1],&pIndex->tnum)==0
|| pIndex->tnum<2
+ || sqlite3IndexHasDuplicateRootPage(pIndex)
){
corruptSchema(pData, argv[0], pIndex?"invalid rootpage":"orphan index");
}
@@ -172,6 +187,7 @@ int sqlite3InitOne(sqlite3 *db, int iDb, char **pzErrMsg, u32 mFlags){
initData.rc = SQLITE_OK;
initData.pzErrMsg = pzErrMsg;
initData.mInitFlags = mFlags;
+ initData.nInitRow = 0;
sqlite3InitCallback(&initData, 3, (char **)azArg, 0);
if( initData.rc ){
rc = initData.rc;
@@ -289,7 +305,7 @@ int sqlite3InitOne(sqlite3 *db, int iDb, char **pzErrMsg, u32 mFlags){
** indices that the user might have created.
*/
if( iDb==0 && meta[BTREE_FILE_FORMAT-1]>=4 ){
- db->flags &= ~SQLITE_LegacyFileFmt;
+ db->flags &= ~(u64)SQLITE_LegacyFileFmt;
}
/* Read the schema information out of the schema tables
@@ -706,293 +722,6 @@ static int sqlite3LockAndPrepare(
return rc;
}
-#ifdef SQLITE_ENABLE_NORMALIZE
-/*
-** Checks if the specified token is a table, column, or function name,
-** based on the databases associated with the statement being prepared.
-** If the function fails, zero is returned and pRc is filled with the
-** error code.
-*/
-static int shouldTreatAsIdentifier(
- sqlite3 *db, /* Database handle. */
- const char *zToken, /* Pointer to start of token to be checked */
- int nToken, /* Length of token to be checked */
- int *pRc /* Pointer to error code upon failure */
-){
- int bFound = 0; /* Non-zero if token is an identifier name. */
- int i, j; /* Database and column loop indexes. */
- Schema *pSchema; /* Schema for current database. */
- Hash *pHash; /* Hash table of tables for current database. */
- HashElem *e; /* Hash element for hash table iteration. */
- Table *pTab; /* Database table for columns being checked. */
-
- if( sqlite3IsRowidN(zToken, nToken) ){
- return 1;
- }
- if( nToken>0 ){
- int hash = SQLITE_FUNC_HASH(sqlite3UpperToLower[(u8)zToken[0]], nToken);
- if( sqlite3FunctionSearchN(hash, zToken, nToken) ) return 1;
- }
- assert( db!=0 );
- sqlite3_mutex_enter(db->mutex);
- sqlite3BtreeEnterAll(db);
- for(i=0; i<db->nDb; i++){
- pHash = &db->aFunc;
- if( sqlite3HashFindN(pHash, zToken, nToken) ){
- bFound = 1;
- break;
- }
- pSchema = db->aDb[i].pSchema;
- if( pSchema==0 ) continue;
- pHash = &pSchema->tblHash;
- if( sqlite3HashFindN(pHash, zToken, nToken) ){
- bFound = 1;
- break;
- }
- for(e=sqliteHashFirst(pHash); e; e=sqliteHashNext(e)){
- pTab = sqliteHashData(e);
- if( pTab==0 ) continue;
- pHash = pTab->pColHash;
- if( pHash==0 ){
- pTab->pColHash = pHash = sqlite3_malloc(sizeof(Hash));
- if( pHash ){
- sqlite3HashInit(pHash);
- for(j=0; j<pTab->nCol; j++){
- Column *pCol = &pTab->aCol[j];
- sqlite3HashInsert(pHash, pCol->zName, pCol);
- }
- }else{
- *pRc = SQLITE_NOMEM_BKPT;
- bFound = 0;
- goto done;
- }
- }
- if( pHash && sqlite3HashFindN(pHash, zToken, nToken) ){
- bFound = 1;
- goto done;
- }
- }
- }
-done:
- sqlite3BtreeLeaveAll(db);
- sqlite3_mutex_leave(db->mutex);
- return bFound;
-}
-
-/*
-** Attempt to estimate the final output buffer size needed for the fully
-** normalized version of the specified SQL string. This should take into
-** account any potential expansion that could occur (e.g. via IN clauses
-** being expanded, etc). This size returned is the total number of bytes
-** including the NUL terminator.
-*/
-static int estimateNormalizedSize(
- const char *zSql, /* The original SQL string */
- int nSql, /* Length of original SQL string */
- u8 prepFlags /* The flags passed to sqlite3_prepare_v3() */
-){
- int nOut = nSql + 4;
- const char *z = zSql;
- while( nOut<nSql*5 ){
- while( z[0]!=0 && z[0]!='I' && z[0]!='i' ){ z++; }
- if( z[0]==0 ) break;
- z++;
- if( z[0]!='N' && z[0]!='n' ) break;
- z++;
- while( sqlite3Isspace(z[0]) ){ z++; }
- if( z[0]!='(' ) break;
- z++;
- nOut += 5; /* ?,?,? */
- }
- return nOut;
-}
-
-/*
-** Copy the current token into the output buffer while dealing with quoted
-** identifiers. By default, all letters will be converted into lowercase.
-** If the bUpper flag is set, uppercase will be used. The piOut argument
-** will be used to update the target index into the output string.
-*/
-static void copyNormalizedToken(
- const char *zSql, /* The original SQL string */
- int iIn, /* Current index into the original SQL string */
- int nToken, /* Number of bytes in the current token */
- int tokenFlags, /* Flags returned by the tokenizer */
- char *zOut, /* The output string */
- int *piOut /* Pointer to target index into the output string */
-){
- int bQuoted = tokenFlags & SQLITE_TOKEN_QUOTED;
- int bKeyword = tokenFlags & SQLITE_TOKEN_KEYWORD;
- int j = *piOut, k = 0;
- for(; k<nToken; k++){
- if( bQuoted ){
- if( k==0 && iIn>0 ){
- zOut[j++] = '"';
- continue;
- }else if( k==nToken-1 ){
- zOut[j++] = '"';
- continue;
- }
- }
- if( bKeyword ){
- zOut[j++] = sqlite3Toupper(zSql[iIn+k]);
- }else{
- zOut[j++] = sqlite3Tolower(zSql[iIn+k]);
- }
- }
- *piOut = j;
-}
-
-/*
-** Perform normalization of the SQL contained in the prepared statement and
-** store the result in the zNormSql field. The schema for the associated
-** databases are consulted while performing the normalization in order to
-** determine if a token appears to be an identifier. All identifiers are
-** left intact in the normalized SQL and all literals are replaced with a
-** single '?'.
-*/
-void sqlite3Normalize(
- Vdbe *pVdbe, /* VM being reprepared */
- const char *zSql, /* The original SQL string */
- int nSql, /* Size of the input string in bytes */
- u8 prepFlags /* The flags passed to sqlite3_prepare_v3() */
-){
- sqlite3 *db; /* Database handle. */
- char *z; /* The output string */
- int nZ; /* Size of the output string in bytes */
- int i; /* Next character to read from zSql[] */
- int j; /* Next character to fill in on z[] */
- int tokenType = 0; /* Type of the next token */
- int prevTokenType = 0; /* Type of the previous token, except spaces */
- int n; /* Size of the next token */
- int nParen = 0; /* Nesting level of parenthesis */
- Hash inHash; /* Table of parenthesis levels to output index. */
-
- db = sqlite3VdbeDb(pVdbe);
- assert( db!=0 );
- assert( pVdbe->zNormSql==0 );
- if( zSql==0 ) return;
- nZ = estimateNormalizedSize(zSql, nSql, prepFlags);
- z = sqlite3DbMallocRawNN(db, nZ);
- if( z==0 ) return;
- sqlite3HashInit(&inHash);
- for(i=j=0; i<nSql && zSql[i]; i+=n){
- int flags = 0;
- if( tokenType!=TK_SPACE ) prevTokenType = tokenType;
- n = sqlite3GetTokenNormalized((unsigned char*)zSql+i, &tokenType, &flags);
- switch( tokenType ){
- case TK_SPACE: {
- break;
- }
- case TK_ILLEGAL: {
- sqlite3DbFree(db, z);
- sqlite3HashClear(&inHash);
- return;
- }
- case TK_STRING:
- case TK_INTEGER:
- case TK_FLOAT:
- case TK_VARIABLE:
- case TK_BLOB: {
- z[j++] = '?';
- break;
- }
- case TK_LP:
- case TK_RP: {
- if( tokenType==TK_LP ){
- nParen++;
- if( prevTokenType==TK_IN ){
- assert( nParen<nSql );
- sqlite3HashInsert(&inHash, zSql+nParen, SQLITE_INT_TO_PTR(j));
- }
- }else{
- int jj;
- assert( nParen<nSql );
- jj = SQLITE_PTR_TO_INT(sqlite3HashFind(&inHash, zSql+nParen));
- if( jj>0 ){
- sqlite3HashInsert(&inHash, zSql+nParen, 0);
- assert( jj+6<nZ );
- memcpy(z+jj+1, "?,?,?", 5);
- j = jj+6;
- assert( nZ-1-j>=0 );
- assert( nZ-1-j<nZ );
- memset(z+j, 0, nZ-1-j);
- }
- nParen--;
- }
- assert( nParen>=0 );
- /* Fall through */
- }
- case TK_MINUS:
- case TK_SEMI:
- case TK_PLUS:
- case TK_STAR:
- case TK_SLASH:
- case TK_REM:
- case TK_EQ:
- case TK_LE:
- case TK_NE:
- case TK_LSHIFT:
- case TK_LT:
- case TK_RSHIFT:
- case TK_GT:
- case TK_GE:
- case TK_BITOR:
- case TK_CONCAT:
- case TK_COMMA:
- case TK_BITAND:
- case TK_BITNOT:
- case TK_DOT:
- case TK_IN:
- case TK_IS:
- case TK_NOT:
- case TK_NULL:
- case TK_ID: {
- if( tokenType==TK_NULL ){
- if( prevTokenType==TK_IS || prevTokenType==TK_NOT ){
- /* NULL is a keyword in this case, not a literal value */
- }else{
- /* Here the NULL is a literal value */
- z[j++] = '?';
- break;
- }
- }
- if( j>0 && sqlite3IsIdChar(z[j-1]) && sqlite3IsIdChar(zSql[i]) ){
- z[j++] = ' ';
- }
- if( tokenType==TK_ID ){
- int i2 = i, n2 = n, rc = SQLITE_OK;
- if( nParen>0 ){
- assert( nParen<nSql );
- sqlite3HashInsert(&inHash, zSql+nParen, 0);
- }
- if( flags&SQLITE_TOKEN_QUOTED ){ i2++; n2-=2; }
- if( shouldTreatAsIdentifier(db, zSql+i2, n2, &rc)==0 ){
- if( rc!=SQLITE_OK ){
- sqlite3DbFree(db, z);
- sqlite3HashClear(&inHash);
- return;
- }
- if( sqlite3_keyword_check(zSql+i2, n2)==0 ){
- z[j++] = '?';
- break;
- }
- }
- }
- copyNormalizedToken(zSql, i, n, flags, z, &j);
- break;
- }
- }
- }
- assert( j<nZ && "one" );
- while( j>0 && z[j-1]==' ' ){ j--; }
- if( j>0 && z[j-1]!=';' ){ z[j++] = ';'; }
- z[j] = 0;
- assert( j<nZ && "two" );
- pVdbe->zNormSql = z;
- sqlite3HashClear(&inHash);
-}
-#endif /* SQLITE_ENABLE_NORMALIZE */
/*
** Rerun the compilation of a statement after a schema change.
diff --git a/chromium/third_party/sqlite/src/src/printf.c b/chromium/third_party/sqlite/src/src/printf.c
index 8474195d3c9..5c388797072 100644
--- a/chromium/third_party/sqlite/src/src/printf.c
+++ b/chromium/third_party/sqlite/src/src/printf.c
@@ -155,6 +155,27 @@ static char *getTextArg(PrintfArguments *p){
return (char*)sqlite3_value_text(p->apArg[p->nUsed++]);
}
+/*
+** Allocate memory for a temporary buffer needed for printf rendering.
+**
+** If the requested size of the temp buffer is larger than the size
+** of the output buffer in pAccum, then cause an SQLITE_TOOBIG error.
+** Do the size check before the memory allocation to prevent rogue
+** SQL from requesting large allocations using the precision or width
+** field of the printf() function.
+*/
+static char *printfTempBuf(sqlite3_str *pAccum, sqlite3_int64 n){
+ char *z;
+ if( n>pAccum->nAlloc && n>pAccum->mxAlloc ){
+ setStrAccumError(pAccum, SQLITE_TOOBIG);
+ return 0;
+ }
+ z = sqlite3DbMallocRaw(pAccum->db, n);
+ if( z==0 ){
+ setStrAccumError(pAccum, SQLITE_NOMEM);
+ }
+ return z;
+}
/*
** On machines with a small stack size, you can redefine the
@@ -237,6 +258,9 @@ void sqlite3_str_vappendf(
flag_leftjustify = flag_prefix = cThousand =
flag_alternateform = flag_altform2 = flag_zeropad = 0;
done = 0;
+ width = 0;
+ flag_long = 0;
+ precision = -1;
do{
switch( c ){
case '-': flag_leftjustify = 1; break;
@@ -247,80 +271,93 @@ void sqlite3_str_vappendf(
case '0': flag_zeropad = 1; break;
case ',': cThousand = ','; break;
default: done = 1; break;
- }
- }while( !done && (c=(*++fmt))!=0 );
- /* Get the field width */
- if( c=='*' ){
- if( bArgList ){
- width = (int)getIntArg(pArgList);
- }else{
- width = va_arg(ap,int);
- }
- if( width<0 ){
- flag_leftjustify = 1;
- width = width >= -2147483647 ? -width : 0;
- }
- c = *++fmt;
- }else{
- unsigned wx = 0;
- while( c>='0' && c<='9' ){
- wx = wx*10 + c - '0';
- c = *++fmt;
- }
- testcase( wx>0x7fffffff );
- width = wx & 0x7fffffff;
- }
- assert( width>=0 );
+ case 'l': {
+ flag_long = 1;
+ c = *++fmt;
+ if( c=='l' ){
+ c = *++fmt;
+ flag_long = 2;
+ }
+ done = 1;
+ break;
+ }
+ case '1': case '2': case '3': case '4': case '5':
+ case '6': case '7': case '8': case '9': {
+ unsigned wx = c - '0';
+ while( (c = *++fmt)>='0' && c<='9' ){
+ wx = wx*10 + c - '0';
+ }
+ testcase( wx>0x7fffffff );
+ width = wx & 0x7fffffff;
#ifdef SQLITE_PRINTF_PRECISION_LIMIT
- if( width>SQLITE_PRINTF_PRECISION_LIMIT ){
- width = SQLITE_PRINTF_PRECISION_LIMIT;
- }
+ if( width>SQLITE_PRINTF_PRECISION_LIMIT ){
+ width = SQLITE_PRINTF_PRECISION_LIMIT;
+ }
#endif
-
- /* Get the precision */
- if( c=='.' ){
- c = *++fmt;
- if( c=='*' ){
- if( bArgList ){
- precision = (int)getIntArg(pArgList);
- }else{
- precision = va_arg(ap,int);
+ if( c!='.' && c!='l' ){
+ done = 1;
+ }else{
+ fmt--;
+ }
+ break;
}
- c = *++fmt;
- if( precision<0 ){
- precision = precision >= -2147483647 ? -precision : -1;
+ case '*': {
+ if( bArgList ){
+ width = (int)getIntArg(pArgList);
+ }else{
+ width = va_arg(ap,int);
+ }
+ if( width<0 ){
+ flag_leftjustify = 1;
+ width = width >= -2147483647 ? -width : 0;
+ }
+#ifdef SQLITE_PRINTF_PRECISION_LIMIT
+ if( width>SQLITE_PRINTF_PRECISION_LIMIT ){
+ width = SQLITE_PRINTF_PRECISION_LIMIT;
+ }
+#endif
+ if( (c = fmt[1])!='.' && c!='l' ){
+ c = *++fmt;
+ done = 1;
+ }
+ break;
}
- }else{
- unsigned px = 0;
- while( c>='0' && c<='9' ){
- px = px*10 + c - '0';
+ case '.': {
c = *++fmt;
- }
- testcase( px>0x7fffffff );
- precision = px & 0x7fffffff;
- }
- }else{
- precision = -1;
- }
- assert( precision>=(-1) );
+ if( c=='*' ){
+ if( bArgList ){
+ precision = (int)getIntArg(pArgList);
+ }else{
+ precision = va_arg(ap,int);
+ }
+ if( precision<0 ){
+ precision = precision >= -2147483647 ? -precision : -1;
+ }
+ c = *++fmt;
+ }else{
+ unsigned px = 0;
+ while( c>='0' && c<='9' ){
+ px = px*10 + c - '0';
+ c = *++fmt;
+ }
+ testcase( px>0x7fffffff );
+ precision = px & 0x7fffffff;
+ }
#ifdef SQLITE_PRINTF_PRECISION_LIMIT
- if( precision>SQLITE_PRINTF_PRECISION_LIMIT ){
- precision = SQLITE_PRINTF_PRECISION_LIMIT;
- }
+ if( precision>SQLITE_PRINTF_PRECISION_LIMIT ){
+ precision = SQLITE_PRINTF_PRECISION_LIMIT;
+ }
#endif
-
-
- /* Get the conversion type modifier */
- if( c=='l' ){
- flag_long = 1;
- c = *++fmt;
- if( c=='l' ){
- flag_long = 2;
- c = *++fmt;
+ if( c=='l' ){
+ --fmt;
+ }else{
+ done = 1;
+ }
+ break;
+ }
}
- }else{
- flag_long = 0;
- }
+ }while( !done && (c=(*++fmt))!=0 );
+
/* Fetch the info entry for the field */
infop = &fmtinfo[0];
xtype = etINVALID;
@@ -405,12 +442,11 @@ void sqlite3_str_vappendf(
nOut = etBUFSIZE;
zOut = buf;
}else{
- u64 n = (u64)precision + 10 + precision/3;
- zOut = zExtra = sqlite3Malloc( n );
- if( zOut==0 ){
- setStrAccumError(pAccum, SQLITE_NOMEM);
- return;
- }
+ u64 n;
+ n = (u64)precision + 10;
+ if( cThousand ) n += precision/3;
+ zOut = zExtra = printfTempBuf(pAccum, n);
+ if( zOut==0 ) return;
nOut = (int)n;
}
bufpt = &zOut[nOut-1];
@@ -529,12 +565,12 @@ void sqlite3_str_vappendf(
}else{
e2 = exp;
}
- if( MAX(e2,0)+(i64)precision+(i64)width > etBUFSIZE - 15 ){
- bufpt = zExtra
- = sqlite3Malloc( MAX(e2,0)+(i64)precision+(i64)width+15 );
- if( bufpt==0 ){
- setStrAccumError(pAccum, SQLITE_NOMEM);
- return;
+ {
+ i64 szBufNeeded; /* Size of a temporary buffer needed */
+ szBufNeeded = MAX(e2,0)+(i64)precision+(i64)width+15;
+ if( szBufNeeded > etBUFSIZE ){
+ bufpt = zExtra = printfTempBuf(pAccum, szBufNeeded);
+ if( bufpt==0 ) return;
}
}
zOut = bufpt;
@@ -758,11 +794,8 @@ void sqlite3_str_vappendf(
needQuote = !isnull && xtype==etSQLESCAPE2;
n += i + 3;
if( n>etBUFSIZE ){
- bufpt = zExtra = sqlite3Malloc( n );
- if( bufpt==0 ){
- setStrAccumError(pAccum, SQLITE_NOMEM);
- return;
- }
+ bufpt = zExtra = printfTempBuf(pAccum, n);
+ if( bufpt==0 ) return;
}else{
bufpt = buf;
}
diff --git a/chromium/third_party/sqlite/src/src/resolve.c b/chromium/third_party/sqlite/src/src/resolve.c
index 9d03e075d2b..edf1e203440 100644
--- a/chromium/third_party/sqlite/src/src/resolve.c
+++ b/chromium/third_party/sqlite/src/src/resolve.c
@@ -80,7 +80,6 @@ static void resolveAlias(
if( pExpr->op==TK_COLLATE ){
pDup = sqlite3ExprAddCollateString(pParse, pDup, pExpr->u.zToken);
}
- ExprSetProperty(pDup, EP_Alias);
/* Before calling sqlite3ExprDelete(), set the EP_Static flag. This
** prevents ExprDelete() from deleting the Expr structure itself,
@@ -474,6 +473,25 @@ static int lookupName(
if( cnt==0 && zTab==0 ){
assert( pExpr->op==TK_ID );
if( ExprHasProperty(pExpr,EP_DblQuoted) ){
+ /* If a double-quoted identifier does not match any known column name,
+ ** then treat it as a string.
+ **
+ ** This hack was added in the early days of SQLite in a misguided attempt
+ ** to be compatible with MySQL 3.x, which used double-quotes for strings.
+ ** I now sorely regret putting in this hack. The effect of this hack is
+ ** that misspelled identifier names are silently converted into strings
+ ** rather than causing an error, to the frustration of countless
+ ** programmers. To all those frustrated programmers, my apologies.
+ **
+ ** Someday, I hope to get rid of this hack. Unfortunately there is
+ ** a huge amount of legacy SQL that uses it. So for now, we just
+ ** issue a warning.
+ */
+ sqlite3_log(SQLITE_WARNING,
+ "double-quoted string literal: \"%w\"", zCol);
+#ifdef SQLITE_ENABLE_NORMALIZE
+ sqlite3VdbeAddDblquoteStr(db, pParse->pVdbe, zCol);
+#endif
pExpr->op = TK_STRING;
pExpr->y.pTab = 0;
return WRC_Prune;
@@ -840,10 +858,10 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
#ifndef SQLITE_OMIT_WINDOWFUNC
if( pExpr->y.pWin ){
Select *pSel = pNC->pWinSelect;
+ sqlite3WindowUpdate(pParse, pSel->pWinDefn, pExpr->y.pWin, pDef);
sqlite3WalkExprList(pWalker, pExpr->y.pWin->pPartition);
sqlite3WalkExprList(pWalker, pExpr->y.pWin->pOrderBy);
sqlite3WalkExpr(pWalker, pExpr->y.pWin->pFilter);
- sqlite3WindowUpdate(pParse, pSel->pWinDefn, pExpr->y.pWin, pDef);
if( 0==pSel->pWin
|| 0==sqlite3WindowCompare(pParse, pSel->pWin, pExpr->y.pWin)
){
@@ -1120,32 +1138,53 @@ static int resolveCompoundOrderBy(
}else{
iCol = resolveAsName(pParse, pEList, pE);
if( iCol==0 ){
- pDup = sqlite3ExprDup(db, pE, 0);
+ /* Now test if expression pE matches one of the values returned
+ ** by pSelect. In the usual case this is done by duplicating the
+ ** expression, resolving any symbols in it, and then comparing
+ ** it against each expression returned by the SELECT statement.
+ ** Once the comparisons are finished, the duplicate expression
+ ** is deleted.
+ **
+ ** Or, if this is running as part of an ALTER TABLE operation,
+ ** resolve the symbols in the actual expression, not a duplicate.
+ ** And, if one of the comparisons is successful, leave the expression
+ ** as is instead of transforming it to an integer as in the usual
+ ** case. This allows the code in alter.c to modify column
+ ** refererences within the ORDER BY expression as required. */
+ if( IN_RENAME_OBJECT ){
+ pDup = pE;
+ }else{
+ pDup = sqlite3ExprDup(db, pE, 0);
+ }
if( !db->mallocFailed ){
assert(pDup);
iCol = resolveOrderByTermToExprList(pParse, pSelect, pDup);
}
- sqlite3ExprDelete(db, pDup);
+ if( !IN_RENAME_OBJECT ){
+ sqlite3ExprDelete(db, pDup);
+ }
}
}
if( iCol>0 ){
/* Convert the ORDER BY term into an integer column number iCol,
** taking care to preserve the COLLATE clause if it exists */
- Expr *pNew = sqlite3Expr(db, TK_INTEGER, 0);
- if( pNew==0 ) return 1;
- pNew->flags |= EP_IntValue;
- pNew->u.iValue = iCol;
- if( pItem->pExpr==pE ){
- pItem->pExpr = pNew;
- }else{
- Expr *pParent = pItem->pExpr;
- assert( pParent->op==TK_COLLATE );
- while( pParent->pLeft->op==TK_COLLATE ) pParent = pParent->pLeft;
- assert( pParent->pLeft==pE );
- pParent->pLeft = pNew;
+ if( !IN_RENAME_OBJECT ){
+ Expr *pNew = sqlite3Expr(db, TK_INTEGER, 0);
+ if( pNew==0 ) return 1;
+ pNew->flags |= EP_IntValue;
+ pNew->u.iValue = iCol;
+ if( pItem->pExpr==pE ){
+ pItem->pExpr = pNew;
+ }else{
+ Expr *pParent = pItem->pExpr;
+ assert( pParent->op==TK_COLLATE );
+ while( pParent->pLeft->op==TK_COLLATE ) pParent = pParent->pLeft;
+ assert( pParent->pLeft==pE );
+ pParent->pLeft = pNew;
+ }
+ sqlite3ExprDelete(db, pE);
+ pItem->u.x.iOrderByCol = (u16)iCol;
}
- sqlite3ExprDelete(db, pE);
- pItem->u.x.iOrderByCol = (u16)iCol;
pItem->done = 1;
}else{
moreToDo = 1;
@@ -1494,6 +1533,19 @@ static int resolveSelectStep(Walker *pWalker, Select *p){
}
}
+#ifndef SQLITE_OMIT_WINDOWFUNC
+ if( IN_RENAME_OBJECT ){
+ Window *pWin;
+ for(pWin=p->pWinDefn; pWin; pWin=pWin->pNextWin){
+ if( sqlite3ResolveExprListNames(&sNC, pWin->pOrderBy)
+ || sqlite3ResolveExprListNames(&sNC, pWin->pPartition)
+ ){
+ return WRC_Abort;
+ }
+ }
+ }
+#endif
+
/* If this is part of a compound SELECT, check that it has the right
** number of expressions in the select list. */
if( p->pNext && p->pEList->nExpr!=p->pNext->pEList->nExpr ){
@@ -1644,36 +1696,45 @@ void sqlite3ResolveSelectNames(
}
/*
-** Resolve names in expressions that can only reference a single table:
+** Resolve names in expressions that can only reference a single table
+** or which cannot reference any tables at all. Examples:
**
-** * CHECK constraints
-** * WHERE clauses on partial indices
+** (1) CHECK constraints
+** (2) WHERE clauses on partial indices
+** (3) Expressions in indexes on expressions
+** (4) Expression arguments to VACUUM INTO.
**
-** The Expr.iTable value for Expr.op==TK_COLUMN nodes of the expression
-** is set to -1 and the Expr.iColumn value is set to the column number.
+** In all cases except (4), the Expr.iTable value for Expr.op==TK_COLUMN
+** nodes of the expression is set to -1 and the Expr.iColumn value is
+** set to the column number. In case (4), TK_COLUMN nodes cause an error.
**
** Any errors cause an error message to be set in pParse.
*/
-void sqlite3ResolveSelfReference(
+int sqlite3ResolveSelfReference(
Parse *pParse, /* Parsing context */
- Table *pTab, /* The table being referenced */
- int type, /* NC_IsCheck or NC_PartIdx or NC_IdxExpr */
+ Table *pTab, /* The table being referenced, or NULL */
+ int type, /* NC_IsCheck or NC_PartIdx or NC_IdxExpr, or 0 */
Expr *pExpr, /* Expression to resolve. May be NULL. */
ExprList *pList /* Expression list to resolve. May be NULL. */
){
SrcList sSrc; /* Fake SrcList for pParse->pNewTable */
NameContext sNC; /* Name context for pParse->pNewTable */
+ int rc;
- assert( type==NC_IsCheck || type==NC_PartIdx || type==NC_IdxExpr );
+ assert( type==0 || pTab!=0 );
+ assert( type==NC_IsCheck || type==NC_PartIdx || type==NC_IdxExpr || pTab==0 );
memset(&sNC, 0, sizeof(sNC));
memset(&sSrc, 0, sizeof(sSrc));
- sSrc.nSrc = 1;
- sSrc.a[0].zName = pTab->zName;
- sSrc.a[0].pTab = pTab;
- sSrc.a[0].iCursor = -1;
+ if( pTab ){
+ sSrc.nSrc = 1;
+ sSrc.a[0].zName = pTab->zName;
+ sSrc.a[0].pTab = pTab;
+ sSrc.a[0].iCursor = -1;
+ }
sNC.pParse = pParse;
sNC.pSrcList = &sSrc;
sNC.ncFlags = type;
- if( sqlite3ResolveExprNames(&sNC, pExpr) ) return;
- if( pList ) sqlite3ResolveExprListNames(&sNC, pList);
+ if( (rc = sqlite3ResolveExprNames(&sNC, pExpr))!=SQLITE_OK ) return rc;
+ if( pList ) rc = sqlite3ResolveExprListNames(&sNC, pList);
+ return rc;
}
diff --git a/chromium/third_party/sqlite/src/src/select.c b/chromium/third_party/sqlite/src/src/select.c
index c68c1ddc643..eeb6044a976 100644
--- a/chromium/third_party/sqlite/src/src/select.c
+++ b/chromium/third_party/sqlite/src/src/select.c
@@ -631,7 +631,7 @@ static void pushOntoSorter(
}
assert( pSelect->iOffset==0 || pSelect->iLimit!=0 );
iLimit = pSelect->iOffset ? pSelect->iOffset+1 : pSelect->iLimit;
- pSort->labelDone = sqlite3VdbeMakeLabel(v);
+ pSort->labelDone = sqlite3VdbeMakeLabel(pParse);
sqlite3ExprCodeExprList(pParse, pSort->pOrderBy, regBase, regOrigData,
SQLITE_ECEL_DUP | (regOrigData? SQLITE_ECEL_REF : 0));
if( bSeq ){
@@ -670,7 +670,7 @@ static void pushOntoSorter(
pKI->nAllField-pKI->nKeyField-1);
addrJmp = sqlite3VdbeCurrentAddr(v);
sqlite3VdbeAddOp3(v, OP_Jump, addrJmp+1, 0, addrJmp+1); VdbeCoverage(v);
- pSort->labelBkOut = sqlite3VdbeMakeLabel(v);
+ pSort->labelBkOut = sqlite3VdbeMakeLabel(pParse);
pSort->regReturn = ++pParse->nMem;
sqlite3VdbeAddOp2(v, OP_Gosub, pSort->regReturn, pSort->labelBkOut);
sqlite3VdbeAddOp1(v, OP_ResetSorter, pSort->iECursor);
@@ -1417,7 +1417,7 @@ static void generateSortTail(
){
Vdbe *v = pParse->pVdbe; /* The prepared statement */
int addrBreak = pSort->labelDone; /* Jump here to exit loop */
- int addrContinue = sqlite3VdbeMakeLabel(v); /* Jump here for next cycle */
+ int addrContinue = sqlite3VdbeMakeLabel(pParse);/* Jump here for next cycle */
int addr; /* Top of output loop. Jump for Next. */
int addrOnce = 0;
int iTab;
@@ -2083,15 +2083,15 @@ void sqlite3SelectAddColumnTypeAndCollation(
Table *sqlite3ResultSetOfSelect(Parse *pParse, Select *pSelect){
Table *pTab;
sqlite3 *db = pParse->db;
- int savedFlags;
+ u64 savedFlags;
savedFlags = db->flags;
- db->flags &= ~SQLITE_FullColNames;
+ db->flags &= ~(u64)SQLITE_FullColNames;
db->flags |= SQLITE_ShortColNames;
sqlite3SelectPrep(pParse, pSelect, 0);
+ db->flags = savedFlags;
if( pParse->nErr ) return 0;
while( pSelect->pPrior ) pSelect = pSelect->pPrior;
- db->flags = savedFlags;
pTab = sqlite3DbMallocZero(db, sizeof(Table) );
if( pTab==0 ){
return 0;
@@ -2335,7 +2335,7 @@ static void generateWithRecursiveQuery(
if( sqlite3AuthCheck(pParse, SQLITE_RECURSIVE, 0, 0, 0) ) return;
/* Process the LIMIT and OFFSET clauses, if they exist */
- addrBreak = sqlite3VdbeMakeLabel(v);
+ addrBreak = sqlite3VdbeMakeLabel(pParse);
p->nSelectRow = 320; /* 4 billion rows */
computeLimitRegisters(pParse, p, addrBreak);
pLimit = p->pLimit;
@@ -2405,7 +2405,7 @@ static void generateWithRecursiveQuery(
sqlite3VdbeAddOp1(v, OP_Delete, iQueue);
/* Output the single row in Current */
- addrCont = sqlite3VdbeMakeLabel(v);
+ addrCont = sqlite3VdbeMakeLabel(pParse);
codeOffset(v, regOffset, addrCont);
selectInnerLoop(pParse, p, iCurrent,
0, 0, pDest, addrCont, addrBreak);
@@ -2713,8 +2713,8 @@ static int multiSelect(
if( dest.eDest!=priorOp ){
int iCont, iBreak, iStart;
assert( p->pEList );
- iBreak = sqlite3VdbeMakeLabel(v);
- iCont = sqlite3VdbeMakeLabel(v);
+ iBreak = sqlite3VdbeMakeLabel(pParse);
+ iCont = sqlite3VdbeMakeLabel(pParse);
computeLimitRegisters(pParse, p, iBreak);
sqlite3VdbeAddOp2(v, OP_Rewind, unionTab, iBreak); VdbeCoverage(v);
iStart = sqlite3VdbeCurrentAddr(v);
@@ -2782,8 +2782,8 @@ static int multiSelect(
** tables.
*/
assert( p->pEList );
- iBreak = sqlite3VdbeMakeLabel(v);
- iCont = sqlite3VdbeMakeLabel(v);
+ iBreak = sqlite3VdbeMakeLabel(pParse);
+ iCont = sqlite3VdbeMakeLabel(pParse);
computeLimitRegisters(pParse, p, iBreak);
sqlite3VdbeAddOp2(v, OP_Rewind, tab1, iBreak); VdbeCoverage(v);
r1 = sqlite3GetTempReg(pParse);
@@ -2913,7 +2913,7 @@ static int generateOutputSubroutine(
int addr;
addr = sqlite3VdbeCurrentAddr(v);
- iContinue = sqlite3VdbeMakeLabel(v);
+ iContinue = sqlite3VdbeMakeLabel(pParse);
/* Suppress duplicates for UNION, EXCEPT, and INTERSECT
*/
@@ -3150,8 +3150,8 @@ static int multiSelectOrderBy(
db = pParse->db;
v = pParse->pVdbe;
assert( v!=0 ); /* Already thrown the error if VDBE alloc failed */
- labelEnd = sqlite3VdbeMakeLabel(v);
- labelCmpr = sqlite3VdbeMakeLabel(v);
+ labelEnd = sqlite3VdbeMakeLabel(pParse);
+ labelCmpr = sqlite3VdbeMakeLabel(pParse);
/* Patch up the ORDER BY clause
@@ -3467,6 +3467,7 @@ static Expr *substExpr(
ifNullRow.iTable = pSubst->iNewTable;
pCopy = &ifNullRow;
}
+ testcase( ExprHasProperty(pCopy, EP_Subquery) );
pNew = sqlite3ExprDup(db, pCopy, 0);
if( pNew && pSubst->isLeftJoin ){
ExprSetProperty(pNew, EP_CanBeNull);
@@ -3959,11 +3960,9 @@ static int flattenSubquery(
jointype = pSubitem->fg.jointype;
}else{
assert( pParent!=p ); /* 2nd and subsequent times through the loop */
- pSrc = pParent->pSrc = sqlite3SrcListAppend(db, 0, 0, 0);
- if( pSrc==0 ){
- assert( db->mallocFailed );
- break;
- }
+ pSrc = sqlite3SrcListAppend(pParse, 0, 0, 0);
+ if( pSrc==0 ) break;
+ pParent->pSrc = pSrc;
}
/* The subquery uses a single slot of the FROM clause of the outer
@@ -3982,10 +3981,9 @@ static int flattenSubquery(
** for the two elements in the FROM clause of the subquery.
*/
if( nSubSrc>1 ){
- pParent->pSrc = pSrc = sqlite3SrcListEnlarge(db, pSrc, nSubSrc-1,iFrom+1);
- if( db->mallocFailed ){
- break;
- }
+ pSrc = sqlite3SrcListEnlarge(pParse, pSrc, nSubSrc-1,iFrom+1);
+ if( pSrc==0 ) break;
+ pParent->pSrc = pSrc;
}
/* Transfer the FROM clause terms from the subquery into the
@@ -4031,7 +4029,8 @@ static int flattenSubquery(
pParent->pOrderBy = pOrderBy;
pSub->pOrderBy = 0;
}
- pWhere = sqlite3ExprDup(db, pSub->pWhere, 0);
+ pWhere = pSub->pWhere;
+ pSub->pWhere = 0;
if( isLeftJoin>0 ){
setJoinExpr(pWhere, iNewParent);
}
@@ -5334,7 +5333,7 @@ static void updateAccumulator(Parse *pParse, int regAcc, AggInfo *pAggInfo){
regAgg = 0;
}
if( pF->iDistinct>=0 ){
- addrNext = sqlite3VdbeMakeLabel(v);
+ addrNext = sqlite3VdbeMakeLabel(pParse);
testcase( nArg==0 ); /* Error condition */
testcase( nArg>1 ); /* Also an error */
codeDistinct(pParse, pF->iDistinct, addrNext, 1, regAgg);
@@ -5744,6 +5743,7 @@ int sqlite3Select(
}
if( flattenSubquery(pParse, p, i, isAgg) ){
+ if( pParse->nErr ) goto select_end;
/* This subquery can be absorbed into its parent. */
i = -1;
}
@@ -5839,22 +5839,12 @@ int sqlite3Select(
pSub = pItem->pSelect;
if( pSub==0 ) continue;
- /* Sometimes the code for a subquery will be generated more than
- ** once, if the subquery is part of the WHERE clause in a LEFT JOIN,
- ** for example. In that case, do not regenerate the code to manifest
- ** a view or the co-routine to implement a view. The first instance
- ** is sufficient, though the subroutine to manifest the view does need
- ** to be invoked again. */
- if( pItem->addrFillSub ){
- if( pItem->fg.viaCoroutine==0 ){
- /* The subroutine that manifests the view might be a one-time routine,
- ** or it might need to be rerun on each iteration because it
- ** encodes a correlated subquery. */
- testcase( sqlite3VdbeGetOp(v, pItem->addrFillSub)->opcode==OP_Once );
- sqlite3VdbeAddOp2(v, OP_Gosub, pItem->regReturn, pItem->addrFillSub);
- }
- continue;
- }
+ /* The code for a subquery should only be generated once, though it is
+ ** technically harmless for it to be generated multiple times. The
+ ** following assert() will detect if something changes to cause
+ ** the same subquery to be coded multiple times, as a signal to the
+ ** developers to try to optimize the situation. */
+ assert( pItem->addrFillSub==0 );
/* Increment Parse.nHeight by the height of the largest expression
** tree referred to by this, the parent select. The child select
@@ -6042,7 +6032,7 @@ int sqlite3Select(
/* Set the limiter.
*/
- iEnd = sqlite3VdbeMakeLabel(v);
+ iEnd = sqlite3VdbeMakeLabel(pParse);
if( (p->selFlags & SF_FixedLimit)==0 ){
p->nSelectRow = 320; /* 4 billion rows */
}
@@ -6109,9 +6099,9 @@ int sqlite3Select(
assert( p->pEList==pEList );
#ifndef SQLITE_OMIT_WINDOWFUNC
if( pWin ){
- int addrGosub = sqlite3VdbeMakeLabel(v);
- int iCont = sqlite3VdbeMakeLabel(v);
- int iBreak = sqlite3VdbeMakeLabel(v);
+ int addrGosub = sqlite3VdbeMakeLabel(pParse);
+ int iCont = sqlite3VdbeMakeLabel(pParse);
+ int iBreak = sqlite3VdbeMakeLabel(pParse);
int regGosub = ++pParse->nMem;
sqlite3WindowCodeStep(pParse, p, pWInfo, regGosub, addrGosub);
@@ -6186,7 +6176,7 @@ int sqlite3Select(
}
/* Create a label to jump to when we want to abort the query */
- addrEnd = sqlite3VdbeMakeLabel(v);
+ addrEnd = sqlite3VdbeMakeLabel(pParse);
/* Convert TK_COLUMN nodes into TK_AGG_COLUMN and make entries in
** sAggInfo for all TK_AGG_FUNCTION nodes in expressions of the
@@ -6275,9 +6265,9 @@ int sqlite3Select(
iUseFlag = ++pParse->nMem;
iAbortFlag = ++pParse->nMem;
regOutputRow = ++pParse->nMem;
- addrOutputRow = sqlite3VdbeMakeLabel(v);
+ addrOutputRow = sqlite3VdbeMakeLabel(pParse);
regReset = ++pParse->nMem;
- addrReset = sqlite3VdbeMakeLabel(v);
+ addrReset = sqlite3VdbeMakeLabel(pParse);
iAMem = pParse->nMem + 1;
pParse->nMem += pGroupBy->nExpr;
iBMem = pParse->nMem + 1;
diff --git a/chromium/third_party/sqlite/src/src/shell.c.in b/chromium/third_party/sqlite/src/src/shell.c.in
index b13551dc61f..9ccac2b34ee 100644
--- a/chromium/third_party/sqlite/src/src/shell.c.in
+++ b/chromium/third_party/sqlite/src/src/shell.c.in
@@ -138,6 +138,9 @@ typedef unsigned char u8;
# ifndef unlink
# define unlink _unlink
# endif
+# ifndef strdup
+# define strdup _strdup
+# endif
# undef popen
# define popen _popen
# undef pclose
@@ -937,6 +940,7 @@ INCLUDE ../ext/misc/shathree.c
INCLUDE ../ext/misc/fileio.c
INCLUDE ../ext/misc/completion.c
INCLUDE ../ext/misc/appendvfs.c
+INCLUDE ../ext/misc/memtrace.c
#ifdef SQLITE_HAVE_ZLIB
INCLUDE ../ext/misc/zipfile.c
INCLUDE ../ext/misc/sqlar.c
@@ -1002,14 +1006,18 @@ struct ShellState {
u8 autoExplain; /* Automatically turn on .explain mode */
u8 autoEQP; /* Run EXPLAIN QUERY PLAN prior to seach SQL stmt */
u8 autoEQPtest; /* autoEQP is in test mode */
+ u8 autoEQPtrace; /* autoEQP is in trace mode */
u8 statsOn; /* True to display memory stats before each finalize */
u8 scanstatsOn; /* True to display scan stats before each finalize */
u8 openMode; /* SHELL_OPEN_NORMAL, _APPENDVFS, or _ZIPFILE */
u8 doXdgOpen; /* Invoke start/open/xdg-open in output_reset() */
u8 nEqpLevel; /* Depth of the EQP output graph */
+ u8 eTraceType; /* SHELL_TRACE_* value for type of trace */
unsigned mEqpLines; /* Mask of veritical lines in the EQP output graph */
int outCount; /* Revert to stdout when reaching zero */
int cnt; /* Number of records displayed so far */
+ int lineno; /* Line number of last line read from in */
+ FILE *in; /* Read commands from this stream */
FILE *out; /* Write results here */
FILE *traceOut; /* Output for sqlite3_trace() */
int nErr; /* Number of errors seen */
@@ -1020,7 +1028,11 @@ struct ShellState {
int writableSchema; /* True if PRAGMA writable_schema=ON */
int showHeader; /* True to show column names in List or Column mode */
int nCheck; /* Number of ".check" commands run */
+ unsigned nProgress; /* Number of progress callbacks encountered */
+ unsigned mxProgress; /* Maximum progress callbacks before failing */
+ unsigned flgProgress; /* Flags for the progress callback */
unsigned shellFlgs; /* Various flags */
+ sqlite3_int64 szMax; /* --maxsize argument to .open */
char *zDestTable; /* Name of destination table when MODE_Insert */
char *zTempFile; /* Temporary file that might need deleting */
char zTestcase[30]; /* Name of current test case */
@@ -1065,6 +1077,20 @@ struct ShellState {
#define SHELL_OPEN_ZIPFILE 3 /* Use the zipfile virtual table */
#define SHELL_OPEN_READONLY 4 /* Open a normal database read-only */
#define SHELL_OPEN_DESERIALIZE 5 /* Open using sqlite3_deserialize() */
+#define SHELL_OPEN_HEXDB 6 /* Use "dbtotxt" output as data source */
+
+/* Allowed values for ShellState.eTraceType
+*/
+#define SHELL_TRACE_PLAIN 0 /* Show input SQL text */
+#define SHELL_TRACE_EXPANDED 1 /* Show expanded SQL text */
+#define SHELL_TRACE_NORMALIZED 2 /* Show normalized SQL text */
+
+/* Bits in the ShellState.flgProgress variable */
+#define SHELL_PROGRESS_QUIET 0x01 /* Omit announcing every progress callback */
+#define SHELL_PROGRESS_RESET 0x02 /* Reset the count when the progres
+ ** callback limit is reached, and for each
+ ** top-level SQL statement */
+#define SHELL_PROGRESS_ONCE 0x04 /* Cancel the --limit after firing once */
/*
** These are the allowed shellFlgs values
@@ -1766,6 +1792,26 @@ static void eqp_render(ShellState *p){
}
}
+#ifndef SQLITE_OMIT_PROGRESS_CALLBACK
+/*
+** Progress handler callback.
+*/
+static int progress_handler(void *pClientData) {
+ ShellState *p = (ShellState*)pClientData;
+ p->nProgress++;
+ if( p->nProgress>=p->mxProgress && p->mxProgress>0 ){
+ raw_printf(p->out, "Progress limit reached (%u)\n", p->nProgress);
+ if( p->flgProgress & SHELL_PROGRESS_RESET ) p->nProgress = 0;
+ if( p->flgProgress & SHELL_PROGRESS_ONCE ) p->mxProgress = 0;
+ return 1;
+ }
+ if( (p->flgProgress & SHELL_PROGRESS_QUIET)==0 ){
+ raw_printf(p->out, "Progress %u\n", p->nProgress);
+ }
+ return 0;
+}
+#endif /* SQLITE_OMIT_PROGRESS_CALLBACK */
+
/*
** This is the callback routine that the shell
** invokes for each row of a query result.
@@ -3370,6 +3416,7 @@ static const char *(azHelp[]) = {
#endif
".backup ?DB? FILE Backup DB (default \"main\") to FILE",
" --append Use the appendvfs",
+ " --async Write to FILE without a journal and without fsync()",
".bail on|off Stop after hitting an error. Default OFF",
".binary on|off Turn binary output on or off. Default OFF",
".cd DIRECTORY Change the working directory to DIRECTORY",
@@ -3385,7 +3432,13 @@ static const char *(azHelp[]) = {
" --newlines Allow unescaped newline characters in output",
" TABLE is LIKE pattern for the tables to dump",
".echo on|off Turn command echo on or off",
- ".eqp on|off|full Enable or disable automatic EXPLAIN QUERY PLAN",
+ ".eqp on|off|full|... Enable or disable automatic EXPLAIN QUERY PLAN",
+ " Other Modes:",
+#ifdef SQLITE_DEBUG
+ " test Show raw EXPLAIN QUERY PLAN output",
+ " trace Like \"full\" but also enable \"PRAGMA vdbe_trace\"",
+#endif
+ " trigger Like \"full\" but also show trigger bytecode",
".excel Display the output of next command in a spreadsheet",
".exit ?CODE? Exit this program with return-code CODE",
".expert EXPERIMENTAL. Suggest indexes for specified queries",
@@ -3436,6 +3489,8 @@ static const char *(azHelp[]) = {
" --append Use appendvfs to append database to the end of FILE",
#ifdef SQLITE_ENABLE_DESERIALIZE
" --deserialize Load into memory useing sqlite3_deserialize()",
+ " --hexdb Load the output of \"dbtotxt\" as an in-memory database",
+ " --maxsize N Maximum size for --hexdb or --deserialized database",
#endif
" --new Initialize FILE to an empty database",
" --readonly Open FILE readonly",
@@ -3443,6 +3498,13 @@ static const char *(azHelp[]) = {
".output ?FILE? Send output to FILE or stdout if FILE is omitted",
" If FILE begins with '|' then open it as a pipe.",
".print STRING... Print literal STRING",
+#ifndef SQLITE_OMIT_PROGRESS_CALLBACK
+ ".progress N Invoke progress handler after every N opcodes",
+ " --limit N Interrupt after N progress callbacks",
+ " --once Do no more than one progress interrupt",
+ " --quiet|-q No output except at interrupts",
+ " --reset Reset the count for each input and interrupt",
+#endif
".prompt MAIN CONTINUE Replace the standard prompts",
".quit Exit this program",
".read FILE Read input from FILE",
@@ -3492,7 +3554,22 @@ static const char *(azHelp[]) = {
".testcase NAME Begin redirecting output to 'testcase-out.txt'",
".timeout MS Try opening locked tables for MS milliseconds",
".timer on|off Turn SQL timer on or off",
- ".trace FILE|off Output each SQL statement as it is run",
+#ifndef SQLITE_OMIT_TRACE
+ ".trace ?OPTIONS? Output each SQL statement as it is run",
+ " FILE Send output to FILE",
+ " stdout Send output to stdout",
+ " stderr Send output to stderr",
+ " off Disable tracing",
+ " --expanded Expand query parameters",
+#ifdef SQLITE_ENABLE_NORMALIZE
+ " --normalized Normal the SQL statements",
+#endif
+ " --plain Show SQL as it is input",
+ " --stmt Trace statement execution (SQLITE_TRACE_STMT)",
+ " --profile Profile statements (SQLITE_TRACE_PROFILE)",
+ " --row Trace each row (SQLITE_TRACE_ROW)",
+ " --close Trace connection close (SQLITE_TRACE_CLOSE)",
+#endif /* SQLITE_OMIT_TRACE */
".vfsinfo ?AUX? Information about the top-level VFS",
".vfslist List all available VFSes",
".vfsname ?AUX? Print the name of the VFS stack",
@@ -3570,7 +3647,7 @@ static int showHelp(FILE *out, const char *zPattern){
}
/* Forward reference */
-static int process_input(ShellState *p, FILE *in);
+static int process_input(ShellState *p);
/*
** Read the content of file zName into memory obtained from sqlite3_malloc64()
@@ -3700,6 +3777,94 @@ int deduceDatabaseType(const char *zName, int dfltZip){
return rc;
}
+#ifdef SQLITE_ENABLE_DESERIALIZE
+/*
+** Reconstruct an in-memory database using the output from the "dbtotxt"
+** program. Read content from the file in p->zDbFilename. If p->zDbFilename
+** is 0, then read from standard input.
+*/
+static unsigned char *readHexDb(ShellState *p, int *pnData){
+ unsigned char *a = 0;
+ int nLine;
+ int n = 0;
+ int pgsz = 0;
+ int iOffset = 0;
+ int j, k;
+ int rc;
+ FILE *in;
+ unsigned char x[16];
+ char zLine[1000];
+ if( p->zDbFilename ){
+ in = fopen(p->zDbFilename, "r");
+ if( in==0 ){
+ utf8_printf(stderr, "cannot open \"%s\" for reading\n", p->zDbFilename);
+ return 0;
+ }
+ nLine = 0;
+ }else{
+ in = p->in;
+ nLine = p->lineno;
+ }
+ *pnData = 0;
+ nLine++;
+ if( fgets(zLine, sizeof(zLine), in)==0 ) goto readHexDb_error;
+ rc = sscanf(zLine, "| size %d pagesize %d", &n, &pgsz);
+ if( rc!=2 ) goto readHexDb_error;
+ if( n<=0 ) goto readHexDb_error;
+ a = sqlite3_malloc( n );
+ if( a==0 ){
+ utf8_printf(stderr, "Out of memory!\n");
+ goto readHexDb_error;
+ }
+ memset(a, 0, n);
+ if( pgsz<512 || pgsz>65536 || (pgsz & (pgsz-1))!=0 ){
+ utf8_printf(stderr, "invalid pagesize\n");
+ goto readHexDb_error;
+ }
+ for(nLine++; fgets(zLine, sizeof(zLine), in)!=0; nLine++){
+ rc = sscanf(zLine, "| page %d offset %d", &j, &k);
+ if( rc==2 ){
+ iOffset = k;
+ continue;
+ }
+ if( strncmp(zLine, "| end ", 6)==0 ){
+ break;
+ }
+ rc = sscanf(zLine,"| %d: %hhx %hhx %hhx %hhx %hhx %hhx %hhx %hhx"
+ " %hhx %hhx %hhx %hhx %hhx %hhx %hhx %hhx",
+ &j, &x[0], &x[1], &x[2], &x[3], &x[4], &x[5], &x[6], &x[7],
+ &x[8], &x[9], &x[10], &x[11], &x[12], &x[13], &x[14], &x[15]);
+ if( rc==17 ){
+ k = iOffset+j;
+ if( k+16<=n ){
+ memcpy(a+k, x, 16);
+ }
+ }
+ }
+ *pnData = n;
+ if( in!=p->in ){
+ fclose(in);
+ }else{
+ p->lineno = nLine;
+ }
+ return a;
+
+readHexDb_error:
+ if( in!=stdin ){
+ fclose(in);
+ }else{
+ while( fgets(zLine, sizeof(zLine), p->in)!=0 ){
+ nLine++;
+ if(strncmp(zLine, "| end ", 6)==0 ) break;
+ }
+ p->lineno = nLine;
+ }
+ sqlite3_free(a);
+ utf8_printf(stderr,"Error on line %d of --hexdb input\n", nLine);
+ return 0;
+}
+#endif /* SQLITE_ENABLE_DESERIALIZE */
+
/* Flags for open_db().
**
** The default behavior of open_db() is to exit(1) if the database fails to
@@ -3733,6 +3898,7 @@ static void open_db(ShellState *p, int openFlags){
SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE, "apndvfs");
break;
}
+ case SHELL_OPEN_HEXDB:
case SHELL_OPEN_DESERIALIZE: {
sqlite3_open(0, &p->db);
break;
@@ -3755,7 +3921,10 @@ static void open_db(ShellState *p, int openFlags){
if( p->db==0 || SQLITE_OK!=sqlite3_errcode(p->db) ){
utf8_printf(stderr,"Error: unable to open database \"%s\": %s\n",
p->zDbFilename, sqlite3_errmsg(p->db));
- if( openFlags & OPEN_DB_KEEPALIVE ) return;
+ if( openFlags & OPEN_DB_KEEPALIVE ){
+ sqlite3_open(":memory:", &p->db);
+ return;
+ }
exit(1);
}
#ifndef SQLITE_OMIT_LOAD_EXTENSION
@@ -3787,15 +3956,29 @@ static void open_db(ShellState *p, int openFlags){
sqlite3_free(zSql);
}
#ifdef SQLITE_ENABLE_DESERIALIZE
- else if( p->openMode==SHELL_OPEN_DESERIALIZE ){
+ else
+ if( p->openMode==SHELL_OPEN_DESERIALIZE || p->openMode==SHELL_OPEN_HEXDB ){
+ int rc;
int nData = 0;
- unsigned char *aData = (unsigned char*)readFile(p->zDbFilename, &nData);
- int rc = sqlite3_deserialize(p->db, "main", aData, nData, nData,
+ unsigned char *aData;
+ if( p->openMode==SHELL_OPEN_DESERIALIZE ){
+ aData = (unsigned char*)readFile(p->zDbFilename, &nData);
+ }else{
+ aData = readHexDb(p, &nData);
+ if( aData==0 ){
+ utf8_printf(stderr, "Error in hexdb input\n");
+ return;
+ }
+ }
+ rc = sqlite3_deserialize(p->db, "main", aData, nData, nData,
SQLITE_DESERIALIZE_RESIZEABLE |
SQLITE_DESERIALIZE_FREEONCLOSE);
if( rc ){
utf8_printf(stderr, "Error: sqlite3_deserialize() returns %d\n", rc);
}
+ if( p->szMax>0 ){
+ sqlite3_file_control(p->db, "main", SQLITE_FCNTL_SIZE_LIMIT, &p->szMax);
+ }
}
#endif
}
@@ -3999,24 +4182,60 @@ static FILE *output_file_open(const char *zFile, int bTextMode){
return f;
}
-#if !defined(SQLITE_OMIT_TRACE) && !defined(SQLITE_OMIT_FLOATING_POINT)
+#ifndef SQLITE_OMIT_TRACE
/*
** A routine for handling output from sqlite3_trace().
*/
static int sql_trace_callback(
- unsigned mType,
- void *pArg,
- void *pP,
- void *pX
+ unsigned mType, /* The trace type */
+ void *pArg, /* The ShellState pointer */
+ void *pP, /* Usually a pointer to sqlite_stmt */
+ void *pX /* Auxiliary output */
){
- FILE *f = (FILE*)pArg;
- UNUSED_PARAMETER(mType);
- UNUSED_PARAMETER(pP);
- if( f ){
- const char *z = (const char*)pX;
- int i = strlen30(z);
- while( i>0 && z[i-1]==';' ){ i--; }
- utf8_printf(f, "%.*s;\n", i, z);
+ ShellState *p = (ShellState*)pArg;
+ sqlite3_stmt *pStmt;
+ const char *zSql;
+ int nSql;
+ if( p->traceOut==0 ) return 0;
+ if( mType==SQLITE_TRACE_CLOSE ){
+ utf8_printf(p->traceOut, "-- closing database connection\n");
+ return 0;
+ }
+ if( mType!=SQLITE_TRACE_ROW && ((const char*)pX)[0]=='-' ){
+ zSql = (const char*)pX;
+ }else{
+ pStmt = (sqlite3_stmt*)pP;
+ switch( p->eTraceType ){
+ case SHELL_TRACE_EXPANDED: {
+ zSql = sqlite3_expanded_sql(pStmt);
+ break;
+ }
+#ifdef SQLITE_ENABLE_NORMALIZE
+ case SHELL_TRACE_NORMALIZED: {
+ zSql = sqlite3_normalized_sql(pStmt);
+ break;
+ }
+#endif
+ default: {
+ zSql = sqlite3_sql(pStmt);
+ break;
+ }
+ }
+ }
+ if( zSql==0 ) return 0;
+ nSql = strlen30(zSql);
+ while( nSql>0 && zSql[nSql-1]==';' ){ nSql--; }
+ switch( mType ){
+ case SQLITE_TRACE_ROW:
+ case SQLITE_TRACE_STMT: {
+ utf8_printf(p->traceOut, "%.*s;\n", nSql, zSql);
+ break;
+ }
+ case SQLITE_TRACE_PROFILE: {
+ sqlite3_int64 nNanosec = *(sqlite3_int64*)pX;
+ utf8_printf(p->traceOut, "%.*s; -- %lld ns\n", nSql, zSql, nNanosec);
+ break;
+ }
}
return 0;
}
@@ -5583,7 +5802,7 @@ static int arCreateOrUpdateCommand(
}
end_ar_transaction:
if( rc!=SQLITE_OK ){
- arExecSql(pAr, "ROLLBACK TO ar; RELEASE ar;");
+ sqlite3_exec(pAr->db, "ROLLBACK TO ar; RELEASE ar;", 0, 0, 0);
}else{
rc = arExecSql(pAr, "RELEASE ar;");
if( pAr->bZip && pAr->zFile ){
@@ -5782,6 +6001,7 @@ static int do_meta_command(char *zLine, ShellState *p){
sqlite3 *pDest;
sqlite3_backup *pBackup;
int j;
+ int bAsync = 0;
const char *zVfs = 0;
for(j=1; j<nArg; j++){
const char *z = azArg[j];
@@ -5790,6 +6010,9 @@ static int do_meta_command(char *zLine, ShellState *p){
if( strcmp(z, "-append")==0 ){
zVfs = "apndvfs";
}else
+ if( strcmp(z, "-async")==0 ){
+ bAsync = 1;
+ }else
{
utf8_printf(stderr, "unknown option: %s\n", azArg[j]);
return 1;
@@ -5800,7 +6023,7 @@ static int do_meta_command(char *zLine, ShellState *p){
zDb = zDestFile;
zDestFile = azArg[j];
}else{
- raw_printf(stderr, "Usage: .backup ?DB? ?--append? FILENAME\n");
+ raw_printf(stderr, "Usage: .backup ?DB? ?OPTIONS? FILENAME\n");
return 1;
}
}
@@ -5816,6 +6039,10 @@ static int do_meta_command(char *zLine, ShellState *p){
close_db(pDest);
return 1;
}
+ if( bAsync ){
+ sqlite3_exec(pDest, "PRAGMA synchronous=OFF; PRAGMA journal_mode=OFF;",
+ 0, 0, 0);
+ }
open_db(p, 0);
pBackup = sqlite3_backup_init(pDest, "main", p->db, zDb);
if( pBackup==0 ){
@@ -6081,18 +6308,30 @@ static int do_meta_command(char *zLine, ShellState *p){
if( c=='e' && strncmp(azArg[0], "eqp", n)==0 ){
if( nArg==2 ){
p->autoEQPtest = 0;
+ if( p->autoEQPtrace ){
+ if( p->db ) sqlite3_exec(p->db, "PRAGMA vdbe_trace=OFF;", 0, 0, 0);
+ p->autoEQPtrace = 0;
+ }
if( strcmp(azArg[1],"full")==0 ){
p->autoEQP = AUTOEQP_full;
}else if( strcmp(azArg[1],"trigger")==0 ){
p->autoEQP = AUTOEQP_trigger;
+#ifdef SQLITE_DEBUG
}else if( strcmp(azArg[1],"test")==0 ){
p->autoEQP = AUTOEQP_on;
p->autoEQPtest = 1;
+ }else if( strcmp(azArg[1],"trace")==0 ){
+ p->autoEQP = AUTOEQP_full;
+ p->autoEQPtrace = 1;
+ open_db(p, 0);
+ sqlite3_exec(p->db, "SELECT name FROM sqlite_master LIMIT 1", 0, 0, 0);
+ sqlite3_exec(p->db, "PRAGMA vdbe_trace=ON;", 0, 0, 0);
+#endif
}else{
p->autoEQP = (u8)booleanValue(azArg[1]);
}
}else{
- raw_printf(stderr, "Usage: .eqp off|on|trigger|full\n");
+ raw_printf(stderr, "Usage: .eqp off|on|trace|trigger|full\n");
rc = 1;
}
}else
@@ -6666,6 +6905,7 @@ static int do_meta_command(char *zLine, ShellState *p){
sqlite3_free(p->zFreeOnClose);
p->zFreeOnClose = 0;
p->openMode = SHELL_OPEN_UNSPEC;
+ p->szMax = 0;
/* Check for command-line arguments */
for(iName=1; iName<nArg && azArg[iName][0]=='-'; iName++){
const char *z = azArg[iName];
@@ -6682,7 +6922,11 @@ static int do_meta_command(char *zLine, ShellState *p){
#ifdef SQLITE_ENABLE_DESERIALIZE
}else if( optionMatch(z, "deserialize") ){
p->openMode = SHELL_OPEN_DESERIALIZE;
-#endif
+ }else if( optionMatch(z, "hexdb") ){
+ p->openMode = SHELL_OPEN_HEXDB;
+ }else if( optionMatch(z, "maxsize") && iName+1<nArg ){
+ p->szMax = integerValue(azArg[++iName]);
+#endif /* SQLITE_ENABLE_DESERIALIZE */
}else if( z[0]=='-' ){
utf8_printf(stderr, "unknown option: %s\n", z);
rc = 1;
@@ -6691,7 +6935,7 @@ static int do_meta_command(char *zLine, ShellState *p){
}
/* If a filename is specified, try to open it first */
zNewFilename = nArg>iName ? sqlite3_mprintf("%s", azArg[iName]) : 0;
- if( zNewFilename ){
+ if( zNewFilename || p->openMode==SHELL_OPEN_HEXDB ){
if( newFlag ) shellDeleteFile(zNewFilename);
p->zDbFilename = zNewFilename;
open_db(p, OPEN_DB_KEEPALIVE);
@@ -6793,6 +7037,52 @@ static int do_meta_command(char *zLine, ShellState *p){
raw_printf(p->out, "\n");
}else
+#ifndef SQLITE_OMIT_PROGRESS_CALLBACK
+ if( c=='p' && n>=3 && strncmp(azArg[0], "progress", n)==0 ){
+ int i;
+ int nn = 0;
+ p->flgProgress = 0;
+ p->mxProgress = 0;
+ p->nProgress = 0;
+ for(i=1; i<nArg; i++){
+ const char *z = azArg[i];
+ if( z[0]=='-' ){
+ z++;
+ if( z[0]=='-' ) z++;
+ if( strcmp(z,"quiet")==0 || strcmp(z,"q")==0 ){
+ p->flgProgress |= SHELL_PROGRESS_QUIET;
+ continue;
+ }
+ if( strcmp(z,"reset")==0 ){
+ p->flgProgress |= SHELL_PROGRESS_RESET;
+ continue;
+ }
+ if( strcmp(z,"once")==0 ){
+ p->flgProgress |= SHELL_PROGRESS_ONCE;
+ continue;
+ }
+ if( strcmp(z,"limit")==0 ){
+ if( i+1>=nArg ){
+ utf8_printf(stderr, "Error: missing argument on --limit\n");
+ rc = 1;
+ goto meta_command_exit;
+ }else{
+ p->mxProgress = (int)integerValue(azArg[++i]);
+ }
+ continue;
+ }
+ utf8_printf(stderr, "Error: unknown option: \"%s\"\n", azArg[i]);
+ rc = 1;
+ goto meta_command_exit;
+ }else{
+ nn = (int)integerValue(z);
+ }
+ }
+ open_db(p, 0);
+ sqlite3_progress_handler(p->db, nn, progress_handler, p);
+ }else
+#endif /* SQLITE_OMIT_PROGRESS_CALLBACK */
+
if( c=='p' && strncmp(azArg[0], "prompt", n)==0 ){
if( nArg >= 2) {
strncpy(mainPrompt,azArg[1],(int)ArraySize(mainPrompt)-1);
@@ -6807,20 +7097,23 @@ static int do_meta_command(char *zLine, ShellState *p){
}else
if( c=='r' && n>=3 && strncmp(azArg[0], "read", n)==0 ){
- FILE *alt;
+ FILE *inSaved = p->in;
+ int savedLineno = p->lineno;
if( nArg!=2 ){
raw_printf(stderr, "Usage: .read FILE\n");
rc = 1;
goto meta_command_exit;
}
- alt = fopen(azArg[1], "rb");
- if( alt==0 ){
+ p->in = fopen(azArg[1], "rb");
+ if( p->in==0 ){
utf8_printf(stderr,"Error: cannot open \"%s\"\n", azArg[1]);
rc = 1;
}else{
- rc = process_input(p, alt);
- fclose(alt);
+ rc = process_input(p);
+ fclose(p->in);
}
+ p->in = inSaved;
+ p->lineno = savedLineno;
}else
if( c=='r' && n>=3 && strncmp(azArg[0], "restore", n)==0 ){
@@ -7838,23 +8131,55 @@ static int do_meta_command(char *zLine, ShellState *p){
}
}else
+#ifndef SQLITE_OMIT_TRACE
if( c=='t' && strncmp(azArg[0], "trace", n)==0 ){
+ int mType = 0;
+ int jj;
open_db(p, 0);
- if( nArg!=2 ){
- raw_printf(stderr, "Usage: .trace FILE|off\n");
- rc = 1;
- goto meta_command_exit;
+ for(jj=1; jj<nArg; jj++){
+ const char *z = azArg[jj];
+ if( z[0]=='-' ){
+ if( optionMatch(z, "expanded") ){
+ p->eTraceType = SHELL_TRACE_EXPANDED;
+ }
+#ifdef SQLITE_ENABLE_NORMALIZE
+ else if( optionMatch(z, "normalized") ){
+ p->eTraceType = SHELL_TRACE_NORMALIZED;
+ }
+#endif
+ else if( optionMatch(z, "plain") ){
+ p->eTraceType = SHELL_TRACE_PLAIN;
+ }
+ else if( optionMatch(z, "profile") ){
+ mType |= SQLITE_TRACE_PROFILE;
+ }
+ else if( optionMatch(z, "row") ){
+ mType |= SQLITE_TRACE_ROW;
+ }
+ else if( optionMatch(z, "stmt") ){
+ mType |= SQLITE_TRACE_STMT;
+ }
+ else if( optionMatch(z, "close") ){
+ mType |= SQLITE_TRACE_CLOSE;
+ }
+ else {
+ raw_printf(stderr, "Unknown option \"%s\" on \".trace\"\n", z);
+ rc = 1;
+ goto meta_command_exit;
+ }
+ }else{
+ output_file_close(p->traceOut);
+ p->traceOut = output_file_open(azArg[1], 0);
+ }
}
- output_file_close(p->traceOut);
- p->traceOut = output_file_open(azArg[1], 0);
-#if !defined(SQLITE_OMIT_TRACE) && !defined(SQLITE_OMIT_FLOATING_POINT)
if( p->traceOut==0 ){
sqlite3_trace_v2(p->db, 0, 0, 0);
}else{
- sqlite3_trace_v2(p->db, SQLITE_TRACE_STMT, sql_trace_callback,p->traceOut);
+ if( mType==0 ) mType = SQLITE_TRACE_STMT;
+ sqlite3_trace_v2(p->db, mType, sql_trace_callback, p);
}
-#endif
}else
+#endif /* !defined(SQLITE_OMIT_TRACE) */
#if SQLITE_USER_AUTHENTICATION
if( c=='u' && strncmp(azArg[0], "user", n)==0 ){
@@ -8093,6 +8418,7 @@ static int runOneSqlLine(ShellState *p, char *zSql, FILE *in, int startline){
open_db(p, 0);
if( ShellHasFlag(p,SHFLG_Backslash) ) resolve_backslashes(zSql);
+ if( p->flgProgress & SHELL_PROGRESS_RESET ) p->nProgress = 0;
BEGIN_TIMER;
rc = shell_exec(p, zSql, &zErrMsg);
END_TIMER;
@@ -8129,7 +8455,7 @@ static int runOneSqlLine(ShellState *p, char *zSql, FILE *in, int startline){
**
** Return the number of errors.
*/
-static int process_input(ShellState *p, FILE *in){
+static int process_input(ShellState *p){
char *zLine = 0; /* A single input line */
char *zSql = 0; /* Accumulated SQL text */
int nLine; /* Length of current line */
@@ -8138,22 +8464,22 @@ static int process_input(ShellState *p, FILE *in){
int nSqlPrior = 0; /* Bytes of zSql[] used by prior line */
int rc; /* Error code */
int errCnt = 0; /* Number of errors seen */
- int lineno = 0; /* Current line number */
int startline = 0; /* Line number for start of current input */
- while( errCnt==0 || !bail_on_error || (in==0 && stdin_is_interactive) ){
+ p->lineno = 0;
+ while( errCnt==0 || !bail_on_error || (p->in==0 && stdin_is_interactive) ){
fflush(p->out);
- zLine = one_input_line(in, zLine, nSql>0);
+ zLine = one_input_line(p->in, zLine, nSql>0);
if( zLine==0 ){
/* End of input */
- if( in==0 && stdin_is_interactive ) printf("\n");
+ if( p->in==0 && stdin_is_interactive ) printf("\n");
break;
}
if( seenInterrupt ){
- if( in!=0 ) break;
+ if( p->in!=0 ) break;
seenInterrupt = 0;
}
- lineno++;
+ p->lineno++;
if( nSql==0 && _all_whitespace(zLine) ){
if( ShellHasFlag(p, SHFLG_Echo) ) printf("%s\n", zLine);
continue;
@@ -8185,7 +8511,7 @@ static int process_input(ShellState *p, FILE *in){
for(i=0; zLine[i] && IsSpace(zLine[i]); i++){}
assert( nAlloc>0 && zSql!=0 );
memcpy(zSql, zLine+i, nLine+1-i);
- startline = lineno;
+ startline = p->lineno;
nSql = nLine-i;
}else{
zSql[nSql++] = '\n';
@@ -8194,7 +8520,7 @@ static int process_input(ShellState *p, FILE *in){
}
if( nSql && line_contains_semicolon(&zSql[nSqlPrior], nSql-nSqlPrior)
&& sqlite3_complete(zSql) ){
- errCnt += runOneSqlLine(p, zSql, in, startline);
+ errCnt += runOneSqlLine(p, zSql, p->in, startline);
nSql = 0;
if( p->outCount ){
output_reset(p);
@@ -8208,7 +8534,7 @@ static int process_input(ShellState *p, FILE *in){
}
}
if( nSql && !_all_whitespace(zSql) ){
- errCnt += runOneSqlLine(p, zSql, in, startline);
+ errCnt += runOneSqlLine(p, zSql, p->in, startline);
}
free(zSql);
free(zLine);
@@ -8297,7 +8623,8 @@ static void process_sqliterc(
char *home_dir = NULL;
const char *sqliterc = sqliterc_override;
char *zBuf = 0;
- FILE *in = NULL;
+ FILE *inSaved = p->in;
+ int savedLineno = p->lineno;
if (sqliterc == NULL) {
home_dir = find_home_dir(0);
@@ -8309,14 +8636,16 @@ static void process_sqliterc(
zBuf = sqlite3_mprintf("%s/.sqliterc",home_dir);
sqliterc = zBuf;
}
- in = fopen(sqliterc,"rb");
- if( in ){
+ p->in = fopen(sqliterc,"rb");
+ if( p->in ){
if( stdin_is_interactive ){
utf8_printf(stderr,"-- Loading resources from %s\n",sqliterc);
}
- process_input(p,in);
- fclose(in);
+ process_input(p);
+ fclose(p->in);
}
+ p->in = inSaved;
+ p->lineno = savedLineno;
sqlite3_free(zBuf);
}
@@ -8334,6 +8663,9 @@ static const char zOptions[] =
" -column set output mode to 'column'\n"
" -cmd COMMAND run \"COMMAND\" before reading stdin\n"
" -csv set output mode to 'csv'\n"
+#if defined(SQLITE_ENABLE_DESERIALIZE)
+ " -deserialize open the database using sqlite3_deserialize()\n"
+#endif
" -echo print commands before execution\n"
" -init FILENAME read/process named file\n"
" -[no]header turn headers on or off\n"
@@ -8346,6 +8678,10 @@ static const char zOptions[] =
" -line set output mode to 'line'\n"
" -list set output mode to 'list'\n"
" -lookaside SIZE N use N entries of SZ bytes for lookaside memory\n"
+#if defined(SQLITE_ENABLE_DESERIALIZE)
+ " -maxsize N maximum size for a --deserialize database\n"
+#endif
+ " -memtrace trace all memory allocations and deallocations\n"
" -mmap N default mmap size set to N\n"
#ifdef SQLITE_ENABLE_MULTIPLEX
" -multiplex enable the multiplexor VFS\n"
@@ -8666,6 +9002,8 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){
#ifdef SQLITE_ENABLE_DESERIALIZE
}else if( strcmp(z,"-deserialize")==0 ){
data.openMode = SHELL_OPEN_DESERIALIZE;
+ }else if( strcmp(z,"-maxsize")==0 && i+1<argc ){
+ data.szMax = integerValue(argv[++i]);
#endif
}else if( strcmp(z,"-readonly")==0 ){
data.openMode = SHELL_OPEN_READONLY;
@@ -8675,6 +9013,8 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){
** command, so ignore them */
break;
#endif
+ }else if( strcmp(z, "-memtrace")==0 ){
+ sqlite3MemTraceActivate(stderr);
}
}
verify_uninitialized();
@@ -8765,6 +9105,8 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){
#ifdef SQLITE_ENABLE_DESERIALIZE
}else if( strcmp(z,"-deserialize")==0 ){
data.openMode = SHELL_OPEN_DESERIALIZE;
+ }else if( strcmp(z,"-maxsize")==0 && i+1<argc ){
+ data.szMax = integerValue(argv[++i]);
#endif
}else if( strcmp(z,"-readonly")==0 ){
data.openMode = SHELL_OPEN_READONLY;
@@ -8821,6 +9163,8 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){
i+=2;
}else if( strcmp(z,"-mmap")==0 ){
i++;
+ }else if( strcmp(z,"-memtrace")==0 ){
+ i++;
#ifdef SQLITE_ENABLE_SORTER_REFERENCES
}else if( strcmp(z,"-sorterref")==0 ){
i++;
@@ -8938,14 +9282,16 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){
#elif HAVE_LINENOISE
linenoiseSetCompletionCallback(linenoise_completion);
#endif
- rc = process_input(&data, 0);
+ data.in = 0;
+ rc = process_input(&data);
if( zHistory ){
shell_stifle_history(2000);
shell_write_history(zHistory);
free(zHistory);
}
}else{
- rc = process_input(&data, stdin);
+ data.in = stdin;
+ rc = process_input(&data);
}
}
set_table_name(&data, 0);
diff --git a/chromium/third_party/sqlite/src/src/sqlite.h.in b/chromium/third_party/sqlite/src/src/sqlite.h.in
index cf623163eaa..3d6b63e006a 100644
--- a/chromium/third_party/sqlite/src/src/sqlite.h.in
+++ b/chromium/third_party/sqlite/src/src/sqlite.h.in
@@ -823,6 +823,15 @@ struct sqlite3_io_methods {
** file space based on this hint in order to help writes to the database
** file run faster.
**
+** <li>[[SQLITE_FCNTL_SIZE_LIMIT]]
+** The [SQLITE_FCNTL_SIZE_LIMIT] opcode is used by in-memory VFS that
+** implements [sqlite3_deserialize()] to set an upper bound on the size
+** of the in-memory database. The argument is a pointer to a [sqlite3_int64].
+** If the integer pointed to is negative, then it is filled in with the
+** current limit. Otherwise the limit is set to the larger of the value
+** of the integer pointed to and the current database size. The integer
+** pointed to is set to the new limit.
+**
** <li>[[SQLITE_FCNTL_CHUNK_SIZE]]
** The [SQLITE_FCNTL_CHUNK_SIZE] opcode is used to request that the VFS
** extends and truncates the database file in chunks of a size specified
@@ -1131,6 +1140,7 @@ struct sqlite3_io_methods {
#define SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE 33
#define SQLITE_FCNTL_LOCK_TIMEOUT 34
#define SQLITE_FCNTL_DATA_VERSION 35
+#define SQLITE_FCNTL_SIZE_LIMIT 36
/* deprecated names */
#define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE
@@ -1972,6 +1982,17 @@ struct sqlite3_mem_methods {
** negative value for this option restores the default behaviour.
** This option is only available if SQLite is compiled with the
** [SQLITE_ENABLE_SORTER_REFERENCES] compile-time option.
+**
+** [[SQLITE_CONFIG_MEMDB_MAXSIZE]]
+** <dt>SQLITE_CONFIG_MEMDB_MAXSIZE
+** <dd>The SQLITE_CONFIG_MEMDB_MAXSIZE option accepts a single parameter
+** [sqlite3_int64] parameter which is the default maximum size for an in-memory
+** database created using [sqlite3_deserialize()]. This default maximum
+** size can be adjusted up or down for individual databases using the
+** [SQLITE_FCNTL_SIZE_LIMIT] [sqlite3_file_control|file-control]. If this
+** configuration setting is never used, then the default maximum is determined
+** by the [SQLITE_MEMDB_DEFAULT_MAXSIZE] compile-time option. If that
+** compile-time option is not set, then the default maximum is 1073741824.
** </dl>
*/
#define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */
@@ -2002,6 +2023,7 @@ struct sqlite3_mem_methods {
#define SQLITE_CONFIG_STMTJRNL_SPILL 26 /* int nByte */
#define SQLITE_CONFIG_SMALL_MALLOC 27 /* boolean */
#define SQLITE_CONFIG_SORTERREF_SIZE 28 /* int nByte */
+#define SQLITE_CONFIG_MEMDB_MAXSIZE 29 /* sqlite3_int64 */
/*
** CAPI3REF: Database Connection Configuration Options
@@ -2991,9 +3013,9 @@ int sqlite3_set_authorizer(
** time is in units of nanoseconds, however the current implementation
** is only capable of millisecond resolution so the six least significant
** digits in the time are meaningless. Future versions of SQLite
-** might provide greater resolution on the profiler callback. The
-** sqlite3_profile() function is considered experimental and is
-** subject to change in future versions of SQLite.
+** might provide greater resolution on the profiler callback. Invoking
+** either [sqlite3_trace()] or [sqlite3_trace_v2()] will cancel the
+** profile callback.
*/
SQLITE_DEPRECATED void *sqlite3_trace(sqlite3*,
void(*xTrace)(void*,const char*), void*);
@@ -3407,6 +3429,8 @@ int sqlite3_open_v2(
** is not a database file pathname pointer that SQLite passed into the xOpen
** VFS method, then the behavior of this routine is undefined and probably
** undesirable.
+**
+** See the [URI filename] documentation for additional information.
*/
const char *sqlite3_uri_parameter(const char *zFilename, const char *zParam);
int sqlite3_uri_boolean(const char *zFile, const char *zParam, int bDefault);
@@ -3629,14 +3653,13 @@ int sqlite3_limit(sqlite3*, int id, int newVal);
** deplete the limited store of lookaside memory. Future versions of
** SQLite may act on this hint differently.
**
-** [[SQLITE_PREPARE_NORMALIZE]] ^(<dt>SQLITE_PREPARE_NORMALIZE</dt>
-** <dd>The SQLITE_PREPARE_NORMALIZE flag indicates that a normalized
-** representation of the SQL statement should be calculated and then
-** associated with the prepared statement, which can be obtained via
-** the [sqlite3_normalized_sql()] interface.)^ The semantics used to
-** normalize a SQL statement are unspecified and subject to change.
-** At a minimum, literal values will be replaced with suitable
-** placeholders.
+** [[SQLITE_PREPARE_NORMALIZE]] <dt>SQLITE_PREPARE_NORMALIZE</dt>
+** <dd>The SQLITE_PREPARE_NORMALIZE flag is a no-op. This flag used
+** to be required for any prepared statement that wanted to use the
+** [sqlite3_normalized_sql()] interface. However, the
+** [sqlite3_normalized_sql()] interface is now available to all
+** prepared statements, regardless of whether or not they use this
+** flag.
**
** [[SQLITE_PREPARE_NO_VTAB]] <dt>SQLITE_PREPARE_NO_VTAB</dt>
** <dd>The SQLITE_PREPARE_NO_VTAB flag causes the SQL compiler
diff --git a/chromium/third_party/sqlite/src/src/sqliteInt.h b/chromium/third_party/sqlite/src/src/sqliteInt.h
index 1aae87ea13b..467a273a995 100644
--- a/chromium/third_party/sqlite/src/src/sqliteInt.h
+++ b/chromium/third_party/sqlite/src/src/sqliteInt.h
@@ -1356,10 +1356,13 @@ void sqlite3CryptFunc(sqlite3_context*,int,sqlite3_value**);
/* This is an extra SQLITE_TRACE macro that indicates "legacy" tracing
** in the style of sqlite3_trace()
*/
-#define SQLITE_TRACE_LEGACY 0x80
+#define SQLITE_TRACE_LEGACY 0x40 /* Use the legacy xTrace */
+#define SQLITE_TRACE_XPROFILE 0x80 /* Use the legacy xProfile */
#else
-#define SQLITE_TRACE_LEGACY 0
+#define SQLITE_TRACE_LEGACY 0
+#define SQLITE_TRACE_XPROFILE 0
#endif /* SQLITE_OMIT_DEPRECATED */
+#define SQLITE_TRACE_NONLEGACY_MASK 0x0f /* Normal flags */
/*
@@ -1418,8 +1421,10 @@ struct sqlite3 {
void **aExtension; /* Array of shared library handles */
int (*xTrace)(u32,void*,void*,void*); /* Trace function */
void *pTraceArg; /* Argument to the trace function */
+#ifndef SQLITE_OMIT_DEPRECATED
void (*xProfile)(void*,const char*,u64); /* Profiling function */
void *pProfileArg; /* Argument to profile function */
+#endif
void *pCommitArg; /* Argument to xCommitCallback() */
int (*xCommitCallback)(void*); /* Invoked at every commit. */
void *pRollbackArg; /* Argument to xRollbackCallback() */
@@ -1550,6 +1555,7 @@ struct sqlite3 {
#define SQLITE_VdbeTrace HI(0x0004) /* True to trace VDBE execution */
#define SQLITE_VdbeAddopTrace HI(0x0008) /* Trace sqlite3VdbeAddOp() calls */
#define SQLITE_VdbeEQP HI(0x0010) /* Debug EXPLAIN QUERY PLAN */
+#define SQLITE_ParserTrace HI(0x0020) /* PRAGMA parser_trace=ON */
#endif
/*
@@ -1952,9 +1958,6 @@ struct VTable {
struct Table {
char *zName; /* Name of the table or view */
Column *aCol; /* Information about each column */
-#ifdef SQLITE_ENABLE_NORMALIZE
- Hash *pColHash; /* All columns indexed by name */
-#endif
Index *pIndex; /* List of SQL indexes on this table. */
Select *pSelect; /* NULL for tables. Points to definition if a view. */
FKey *pFKey; /* Linked list of all foreign keys in this table */
@@ -2241,7 +2244,7 @@ struct Index {
u16 nKeyCol; /* Number of columns forming the key */
u16 nColumn; /* Number of columns stored in the index */
u8 onError; /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */
- unsigned idxType:2; /* 1==UNIQUE, 2==PRIMARY KEY, 0==CREATE INDEX */
+ unsigned idxType:2; /* 0:Normal 1:UNIQUE, 2:PRIMARY KEY, 3:IPK */
unsigned bUnordered:1; /* Use this index for == or IN queries only */
unsigned uniqNotNull:1; /* True if UNIQUE and NOT NULL for all columns */
unsigned isResized:1; /* True if resizeIndexObject() has been called */
@@ -2266,6 +2269,7 @@ struct Index {
#define SQLITE_IDXTYPE_APPDEF 0 /* Created using CREATE INDEX */
#define SQLITE_IDXTYPE_UNIQUE 1 /* Implements a UNIQUE constraint */
#define SQLITE_IDXTYPE_PRIMARYKEY 2 /* Is the PRIMARY KEY for the table */
+#define SQLITE_IDXTYPE_IPK 3 /* INTEGER PRIMARY KEY index */
/* Return true if index X is a PRIMARY KEY index */
#define IsPrimaryKeyIndex(X) ((X)->idxType==SQLITE_IDXTYPE_PRIMARYKEY)
@@ -2483,6 +2487,10 @@ struct Expr {
Table *pTab; /* TK_COLUMN: Table containing column. Can be NULL
** for a column of an index on an expression */
Window *pWin; /* TK_FUNCTION: Window definition for the func */
+ struct { /* TK_IN, TK_SELECT, and TK_EXISTS */
+ int iAddr; /* Subroutine entry address */
+ int regReturn; /* Register used to hold return address */
+ } sub;
} y;
};
@@ -2514,6 +2522,8 @@ struct Expr {
#define EP_Alias 0x400000 /* Is an alias for a result set column */
#define EP_Leaf 0x800000 /* Expr.pLeft, .pRight, .u.pSelect all NULL */
#define EP_WinFunc 0x1000000 /* TK_FUNCTION with Expr.y.pWin set */
+#define EP_Subrtn 0x2000000 /* Uses Expr.y.sub. TK_IN, _SELECT, or _EXISTS */
+#define EP_Quoted 0x4000000 /* TK_ID was originally quoted */
/*
** The EP_Propagate mask is a set of properties that automatically propagate
@@ -3063,11 +3073,11 @@ struct Parse {
int nErr; /* Number of errors seen */
int nTab; /* Number of previously allocated VDBE cursors */
int nMem; /* Number of memory cells used so far */
- int nOpAlloc; /* Number of slots allocated for Vdbe.aOp[] */
int szOpAlloc; /* Bytes of memory space allocated for Vdbe.aOp[] */
int iSelfTab; /* Table associated with an index on expr, or negative
** of the base register during check-constraint eval */
- int nLabel; /* Number of labels used */
+ int nLabel; /* The *negative* of the number of labels used */
+ int nLabelAlloc; /* Number of slots in aLabel */
int *aLabel; /* Space to hold the labels */
ExprList *pConstExpr;/* Constant expressions */
Token constraintName;/* Name of the constraint currently being parsed */
@@ -3127,7 +3137,9 @@ struct Parse {
Vdbe *pReprepare; /* VM being reprepared (sqlite3Reprepare()) */
const char *zTail; /* All SQL text past the last semicolon parsed */
Table *pNewTable; /* A table being constructed by CREATE TABLE */
- Index *pNewIndex; /* An index being constructed by CREATE INDEX */
+ Index *pNewIndex; /* An index being constructed by CREATE INDEX.
+ ** Also used to hold redundant UNIQUE constraints
+ ** during a RENAME COLUMN */
Trigger *pNewTrigger; /* Trigger under construct by a CREATE TRIGGER */
const char *zAuthContext; /* The 6th parameter to db->xAuth callbacks */
#ifndef SQLITE_OMIT_VIRTUALTABLE
@@ -3355,6 +3367,7 @@ typedef struct {
int iDb; /* 0 for main database. 1 for TEMP, 2.. for ATTACHed */
int rc; /* Result code stored here */
u32 mInitFlags; /* Flags controlling error messages */
+ u32 nInitRow; /* Number of rows processed */
} InitData;
/*
@@ -3415,6 +3428,9 @@ struct Sqlite3Config {
void (*xVdbeBranch)(void*,unsigned iSrcLine,u8 eThis,u8 eMx); /* Callback */
void *pVdbeBranchArg; /* 1st argument */
#endif
+#ifdef SQLITE_ENABLE_DESERIALIZE
+ sqlite3_int64 mxMemdbSize; /* Default max memdb size */
+#endif
#ifndef SQLITE_UNTESTABLE
int (*xTestCallback)(int); /* Invoked by sqlite3FaultSim() */
#endif
@@ -3803,6 +3819,7 @@ char *sqlite3VMPrintf(sqlite3*,const char*, va_list);
void sqlite3SetString(char **, sqlite3*, const char*);
void sqlite3ErrorMsg(Parse*, const char*, ...);
void sqlite3Dequote(char*);
+void sqlite3DequoteExpr(Expr*);
void sqlite3TokenInit(Token*,char*);
int sqlite3KeywordCode(const unsigned char*, int);
int sqlite3RunParser(Parse*, const char*, char **);
@@ -3831,6 +3848,7 @@ void sqlite3ExprListSetName(Parse*,ExprList*,Token*,int);
void sqlite3ExprListSetSpan(Parse*,ExprList*,const char*,const char*);
void sqlite3ExprListDelete(sqlite3*, ExprList*);
u32 sqlite3ExprListFlags(const ExprList*);
+int sqlite3IndexHasDuplicateRootPage(Index*);
int sqlite3Init(sqlite3*, char**);
int sqlite3InitCallback(void*, int, char**, char**);
int sqlite3InitOne(sqlite3*, int, char**, u32);
@@ -3864,6 +3882,11 @@ void sqlite3AddCollateType(Parse*, Token*);
void sqlite3EndTable(Parse*,Token*,Token*,u8,Select*);
int sqlite3ParseUri(const char*,const char*,unsigned int*,
sqlite3_vfs**,char**,char **);
+#ifdef SQLITE_HAS_CODEC
+ int sqlite3CodecQueryParameters(sqlite3*,const char*,const char*);
+#else
+# define sqlite3CodecQueryParameters(A,B,C) 0
+#endif
Btree *sqlite3DbNameToBtree(sqlite3*,const char*);
#ifdef SQLITE_UNTESTABLE
@@ -3916,8 +3939,8 @@ void sqlite3Insert(Parse*, SrcList*, Select*, IdList*, int, Upsert*);
void *sqlite3ArrayAllocate(sqlite3*,void*,int,int*,int*);
IdList *sqlite3IdListAppend(Parse*, IdList*, Token*);
int sqlite3IdListIndex(IdList*,const char*);
-SrcList *sqlite3SrcListEnlarge(sqlite3*, SrcList*, int, int);
-SrcList *sqlite3SrcListAppend(sqlite3*, SrcList*, Token*, Token*);
+SrcList *sqlite3SrcListEnlarge(Parse*, SrcList*, int, int);
+SrcList *sqlite3SrcListAppend(Parse*, SrcList*, Token*, Token*);
SrcList *sqlite3SrcListAppendFromTerm(Parse*, SrcList*, Token*, Token*,
Token*, Select*, Expr*, IdList*);
void sqlite3SrcListIndexedBy(Parse *, SrcList *, Token *);
@@ -3984,8 +4007,8 @@ Table *sqlite3LocateTableItem(Parse*,u32 flags,struct SrcList_item *);
Index *sqlite3FindIndex(sqlite3*,const char*, const char*);
void sqlite3UnlinkAndDeleteTable(sqlite3*,int,const char*);
void sqlite3UnlinkAndDeleteIndex(sqlite3*,int,const char*);
-void sqlite3Vacuum(Parse*,Token*);
-int sqlite3RunVacuum(char**, sqlite3*, int);
+void sqlite3Vacuum(Parse*,Token*,Expr*);
+int sqlite3RunVacuum(char**, sqlite3*, int, sqlite3_value*);
char *sqlite3NameFromToken(sqlite3*, Token*);
int sqlite3ExprCompare(Parse*,Expr*, Expr*, int);
int sqlite3ExprCompareSkip(Expr*, Expr*, int);
@@ -4023,9 +4046,6 @@ int sqlite3ExprIsInteger(Expr*, int*);
int sqlite3ExprCanBeNull(const Expr*);
int sqlite3ExprNeedsNoAffinityChange(const Expr*, char);
int sqlite3IsRowid(const char*);
-#ifdef SQLITE_ENABLE_NORMALIZE
-int sqlite3IsRowidN(const char*, int);
-#endif
void sqlite3GenerateRowDelete(
Parse*,Table*,Trigger*,int,int,int,i16,u8,u8,u8,int);
void sqlite3GenerateRowIndexDelete(Parse*, Table*, int, int, int*, int);
@@ -4052,9 +4072,7 @@ ExprList *sqlite3ExprListDup(sqlite3*,ExprList*,int);
SrcList *sqlite3SrcListDup(sqlite3*,SrcList*,int);
IdList *sqlite3IdListDup(sqlite3*,IdList*);
Select *sqlite3SelectDup(sqlite3*,Select*,int);
-#ifdef SQLITE_ENABLE_NORMALIZE
-FuncDef *sqlite3FunctionSearchN(int,const char*,int);
-#endif
+FuncDef *sqlite3FunctionSearch(int,const char*);
void sqlite3InsertBuiltinFuncs(FuncDef*,int);
FuncDef *sqlite3FindFunction(sqlite3*,const char*,int,u8,u8);
void sqlite3RegisterBuiltinFunctions(void);
@@ -4259,19 +4277,17 @@ void sqlite3AlterFunctions(void);
void sqlite3AlterRenameTable(Parse*, SrcList*, Token*);
void sqlite3AlterRenameColumn(Parse*, SrcList*, Token*, Token*);
int sqlite3GetToken(const unsigned char *, int *);
-#ifdef SQLITE_ENABLE_NORMALIZE
-int sqlite3GetTokenNormalized(const unsigned char *, int *, int *);
-#endif
void sqlite3NestedParse(Parse*, const char*, ...);
void sqlite3ExpirePreparedStatements(sqlite3*, int);
-int sqlite3CodeSubselect(Parse*, Expr *, int, int);
+void sqlite3CodeRhsOfIN(Parse*, Expr*, int, int);
+int sqlite3CodeSubselect(Parse*, Expr*);
void sqlite3SelectPrep(Parse*, Select*, NameContext*);
void sqlite3SelectWrongNumTermsError(Parse *pParse, Select *p);
int sqlite3MatchSpanName(const char*, const char*, const char*, const char*);
int sqlite3ResolveExprNames(NameContext*, Expr*);
int sqlite3ResolveExprListNames(NameContext*, ExprList*);
void sqlite3ResolveSelectNames(Parse*, Select*, NameContext*);
-void sqlite3ResolveSelfReference(Parse*,Table*,int,Expr*,ExprList*);
+int sqlite3ResolveSelfReference(Parse*,Table*,int,Expr*,ExprList*);
int sqlite3ResolveOrderGroupBy(Parse*, Select*, ExprList*, const char*);
void sqlite3ColumnDefault(Vdbe *, Table *, int, int);
void sqlite3AlterFinishAddColumn(Parse *, Token *);
@@ -4420,7 +4436,7 @@ int sqlite3VdbeParameterIndex(Vdbe*, const char*, int);
int sqlite3TransferBindings(sqlite3_stmt *, sqlite3_stmt *);
void sqlite3ParserReset(Parse*);
#ifdef SQLITE_ENABLE_NORMALIZE
-void sqlite3Normalize(Vdbe*, const char*, int, u8);
+char *sqlite3Normalize(Vdbe*, const char*);
#endif
int sqlite3Reprepare(Vdbe*);
void sqlite3ExprListCheckLength(Parse*, ExprList*, const char*);
@@ -4516,7 +4532,7 @@ const char *sqlite3JournalModename(int);
#define IN_INDEX_NOOP_OK 0x0001 /* OK to return IN_INDEX_NOOP */
#define IN_INDEX_MEMBERSHIP 0x0002 /* IN operator used for membership test */
#define IN_INDEX_LOOP 0x0004 /* IN operator used as a loop */
-int sqlite3FindInIndex(Parse *, Expr *, u32, int*, int*);
+int sqlite3FindInIndex(Parse *, Expr *, u32, int*, int*, int*);
int sqlite3JournalOpen(sqlite3_vfs *, const char *, sqlite3_file *, int, int);
int sqlite3JournalSize(sqlite3_vfs *);
diff --git a/chromium/third_party/sqlite/src/src/tclsqlite.c b/chromium/third_party/sqlite/src/src/tclsqlite.c
index 9dd32ef8e19..d3b62d931cf 100644
--- a/chromium/third_party/sqlite/src/src/tclsqlite.c
+++ b/chromium/third_party/sqlite/src/src/tclsqlite.c
@@ -2418,7 +2418,7 @@ static int SQLITE_TCLAPI DbObjCmd(
}
/*
- ** $db deserialize ?DATABASE? VALUE
+ ** $db deserialize ?-maxsize N? ?-readonly BOOL? ?DATABASE? VALUE
**
** Reopen DATABASE (default "main") using the content in $VALUE
*/
@@ -2428,38 +2428,65 @@ static int SQLITE_TCLAPI DbObjCmd(
(char*)0);
rc = TCL_ERROR;
#else
- const char *zSchema;
- Tcl_Obj *pValue;
+ const char *zSchema = 0;
+ Tcl_Obj *pValue = 0;
unsigned char *pBA;
unsigned char *pData;
int len, xrc;
+ sqlite3_int64 mxSize = 0;
+ int i;
+ int isReadonly = 0;
- if( objc==3 ){
- zSchema = 0;
- pValue = objv[2];
- }else if( objc==4 ){
- zSchema = Tcl_GetString(objv[2]);
- pValue = objv[3];
- }else{
+
+ if( objc<3 ){
Tcl_WrongNumArgs(interp, 2, objv, "?DATABASE? VALUE");
rc = TCL_ERROR;
break;
}
+ for(i=2; i<objc-1; i++){
+ const char *z = Tcl_GetString(objv[i]);
+ if( strcmp(z,"-maxsize")==0 && i<objc-2 ){
+ rc = Tcl_GetWideIntFromObj(interp, objv[++i], &mxSize);
+ if( rc ) goto deserialize_error;
+ continue;
+ }
+ if( strcmp(z,"-readonly")==0 && i<objc-2 ){
+ rc = Tcl_GetBooleanFromObj(interp, objv[++i], &isReadonly);
+ if( rc ) goto deserialize_error;
+ continue;
+ }
+ if( zSchema==0 && i==objc-2 && z[0]!='-' ){
+ zSchema = z;
+ continue;
+ }
+ Tcl_AppendResult(interp, "unknown option: ", z, (char*)0);
+ rc = TCL_ERROR;
+ goto deserialize_error;
+ }
+ pValue = objv[objc-1];
pBA = Tcl_GetByteArrayFromObj(pValue, &len);
pData = sqlite3_malloc64( len );
if( pData==0 && len>0 ){
Tcl_AppendResult(interp, "out of memory", (char*)0);
rc = TCL_ERROR;
}else{
+ int flags;
if( len>0 ) memcpy(pData, pBA, len);
- xrc = sqlite3_deserialize(pDb->db, zSchema, pData, len, len,
- SQLITE_DESERIALIZE_FREEONCLOSE |
- SQLITE_DESERIALIZE_RESIZEABLE);
+ if( isReadonly ){
+ flags = SQLITE_DESERIALIZE_FREEONCLOSE | SQLITE_DESERIALIZE_READONLY;
+ }else{
+ flags = SQLITE_DESERIALIZE_FREEONCLOSE | SQLITE_DESERIALIZE_RESIZEABLE;
+ }
+ xrc = sqlite3_deserialize(pDb->db, zSchema, pData, len, len, flags);
if( xrc ){
Tcl_AppendResult(interp, "unable to set MEMDB content", (char*)0);
rc = TCL_ERROR;
}
+ if( mxSize>0 ){
+ sqlite3_file_control(pDb->db, zSchema,SQLITE_FCNTL_SIZE_LIMIT,&mxSize);
+ }
}
+deserialize_error:
#endif
break;
}
diff --git a/chromium/third_party/sqlite/src/src/test1.c b/chromium/third_party/sqlite/src/src/test1.c
index 5d6a01f319f..81d77d96d9b 100644
--- a/chromium/third_party/sqlite/src/src/test1.c
+++ b/chromium/third_party/sqlite/src/src/test1.c
@@ -7141,6 +7141,9 @@ static int SQLITE_TCLAPI tclLoadStaticExtensionCmd(
extern int sqlite3_ieee_init(sqlite3*,char**,const sqlite3_api_routines*);
extern int sqlite3_nextchar_init(sqlite3*,char**,const sqlite3_api_routines*);
extern int sqlite3_percentile_init(sqlite3*,char**,const sqlite3_api_routines*);
+#ifndef SQLITE_OMIT_VIRTUALTABLE
+ extern int sqlite3_prefixes_init(sqlite3*,char**,const sqlite3_api_routines*);
+#endif
extern int sqlite3_regexp_init(sqlite3*,char**,const sqlite3_api_routines*);
extern int sqlite3_remember_init(sqlite3*,char**,const sqlite3_api_routines*);
extern int sqlite3_series_init(sqlite3*,char**,const sqlite3_api_routines*);
@@ -7166,6 +7169,9 @@ static int SQLITE_TCLAPI tclLoadStaticExtensionCmd(
{ "ieee754", sqlite3_ieee_init },
{ "nextchar", sqlite3_nextchar_init },
{ "percentile", sqlite3_percentile_init },
+#ifndef SQLITE_OMIT_VIRTUALTABLE
+ { "prefixes", sqlite3_prefixes_init },
+#endif
{ "regexp", sqlite3_regexp_init },
{ "remember", sqlite3_remember_init },
{ "series", sqlite3_series_init },
@@ -7642,6 +7648,79 @@ static int SQLITE_TCLAPI test_mmap_warm(
}
/*
+** Usage: decode_hexdb TEXT
+**
+** Example: db deserialize [decode_hexdb $output_of_dbtotxt]
+**
+** This routine returns a byte-array for an SQLite database file that
+** is constructed from a text input which is the output of the "dbtotxt"
+** utility.
+*/
+static int SQLITE_TCLAPI test_decode_hexdb(
+ void * clientData,
+ Tcl_Interp *interp,
+ int objc,
+ Tcl_Obj *CONST objv[]
+){
+ const char *zIn = 0;
+ unsigned char *a = 0;
+ int n = 0;
+ int lineno = 0;
+ int i, iNext;
+ int iOffset = 0;
+ int j, k;
+ int rc;
+ unsigned char x[16];
+ if( objc!=2 ){
+ Tcl_WrongNumArgs(interp, 1, objv, "HEXDB");
+ return TCL_ERROR;
+ }
+ zIn = Tcl_GetString(objv[1]);
+ for(i=0; zIn[i]; i=iNext){
+ lineno++;
+ for(iNext=i; zIn[iNext] && zIn[iNext]!='\n'; iNext++){}
+ if( zIn[iNext]=='\n' ) iNext++;
+ while( zIn[i]==' ' || zIn[i]=='\t' ){ i++; }
+ if( a==0 ){
+ int pgsz;
+ rc = sscanf(zIn+i, "| size %d pagesize %d", &n, &pgsz);
+ if( rc!=2 ) continue;
+ if( n<512 ){
+ Tcl_AppendResult(interp, "bad 'size' field", (void*)0);
+ return TCL_ERROR;
+ }
+ a = malloc( n );
+ if( a==0 ){
+ Tcl_AppendResult(interp, "out of memory", (void*)0);
+ return TCL_ERROR;
+ }
+ memset(a, 0, n);
+ continue;
+ }
+ rc = sscanf(zIn+i, "| page %d offset %d", &j, &k);
+ if( rc==2 ){
+ iOffset = k;
+ continue;
+ }
+ rc = sscanf(zIn+i,"| %d: %hhx %hhx %hhx %hhx %hhx %hhx %hhx %hhx"
+ " %hhx %hhx %hhx %hhx %hhx %hhx %hhx %hhx",
+ &j, &x[0], &x[1], &x[2], &x[3], &x[4], &x[5], &x[6], &x[7],
+ &x[8], &x[9], &x[10], &x[11], &x[12], &x[13], &x[14], &x[15]);
+ if( rc==17 ){
+ k = iOffset+j;
+ if( k+16<=n ){
+ memcpy(a+k, x, 16);
+ }
+ continue;
+ }
+ }
+ Tcl_SetObjResult(interp, Tcl_NewByteArrayObj(a, n));
+ free(a);
+ return TCL_OK;
+}
+
+
+/*
** Register commands with the TCL interpreter.
*/
int Sqlitetest1_Init(Tcl_Interp *interp){
@@ -7920,6 +7999,7 @@ int Sqlitetest1_Init(Tcl_Interp *interp){
{ "atomic_batch_write", test_atomic_batch_write, 0 },
{ "sqlite3_mmap_warm", test_mmap_warm, 0 },
{ "sqlite3_config_sorterref", test_config_sorterref, 0 },
+ { "decode_hexdb", test_decode_hexdb, 0 },
};
static int bitmask_size = sizeof(Bitmask)*8;
static int longdouble_size = sizeof(LONGDOUBLE_TYPE);
diff --git a/chromium/third_party/sqlite/src/src/test_journal.c b/chromium/third_party/sqlite/src/src/test_journal.c
index 8ee609797b2..e89ff768d73 100644
--- a/chromium/third_party/sqlite/src/src/test_journal.c
+++ b/chromium/third_party/sqlite/src/src/test_journal.c
@@ -560,7 +560,7 @@ static int jtWrite(
/* The following assert() statements may fail if this layer is used
** with a connection in "PRAGMA synchronous=off" mode. If they
** fail with sync=normal or sync=full, this may indicate problem. */
- assert( pgno<=p->nPage || p->nSync>0 );
+ assert( p->nPage==0 || pgno<=p->nPage || p->nSync>0 );
assert( pgno>p->nPage || sqlite3BitvecTest(p->pWritable, pgno) );
}
}
diff --git a/chromium/third_party/sqlite/src/src/test_vfs.c b/chromium/third_party/sqlite/src/src/test_vfs.c
index e3d35584774..24799a452c9 100644
--- a/chromium/third_party/sqlite/src/src/test_vfs.c
+++ b/chromium/third_party/sqlite/src/src/test_vfs.c
@@ -228,11 +228,13 @@ static int tvfsResultCode(Testvfs *p, int *pRc){
int eCode;
const char *zCode;
} aCode[] = {
- { SQLITE_OK, "SQLITE_OK" },
- { SQLITE_ERROR, "SQLITE_ERROR" },
- { SQLITE_IOERR, "SQLITE_IOERR" },
- { SQLITE_LOCKED, "SQLITE_LOCKED" },
- { SQLITE_BUSY, "SQLITE_BUSY" },
+ { SQLITE_OK, "SQLITE_OK" },
+ { SQLITE_ERROR, "SQLITE_ERROR" },
+ { SQLITE_IOERR, "SQLITE_IOERR" },
+ { SQLITE_LOCKED, "SQLITE_LOCKED" },
+ { SQLITE_BUSY, "SQLITE_BUSY" },
+ { SQLITE_READONLY, "SQLITE_READONLY" },
+ { SQLITE_READONLY_CANTINIT, "SQLITE_READONLY_CANTINIT" },
};
const char *z;
@@ -865,7 +867,7 @@ static int tvfsShmOpen(sqlite3_file *pFile){
pFd->pNext = pBuffer->pFile;
pBuffer->pFile = pFd;
pFd->pShm = pBuffer;
- return SQLITE_OK;
+ return rc;
}
static void tvfsAllocPage(TestvfsBuffer *p, int iPage, int pgsz){
@@ -918,7 +920,9 @@ static int tvfsShmMap(
if( rc==SQLITE_OK && isWrite && !pFd->pShm->aPage[iPage] ){
tvfsAllocPage(pFd->pShm, iPage, pgsz);
}
- *pp = (void volatile *)pFd->pShm->aPage[iPage];
+ if( rc==SQLITE_OK || rc==SQLITE_READONLY ){
+ *pp = (void volatile *)pFd->pShm->aPage[iPage];
+ }
return rc;
}
@@ -1563,8 +1567,115 @@ static int SQLITE_TCLAPI testvfs_cmd(
return TCL_ERROR;
}
+extern int getDbPointer(Tcl_Interp *interp, const char *zA, sqlite3 **ppDb);
+extern const char *sqlite3ErrName(int);
+
+/*
+** tclcmd: vfs_shmlock DB DBNAME (shared|exclusive) (lock|unlock) OFFSET N
+*/
+static int SQLITE_TCLAPI test_vfs_shmlock(
+ void * clientData,
+ Tcl_Interp *interp,
+ int objc,
+ Tcl_Obj *CONST objv[]
+){
+ const char *azArg1[] = {"shared", "exclusive", 0};
+ const char *azArg2[] = {"lock", "unlock", 0};
+ sqlite3 *db = 0;
+ int rc = SQLITE_OK;
+ const char *zDbname = 0;
+ int iArg1 = 0;
+ int iArg2 = 0;
+ int iOffset = 0;
+ int n = 0;
+ sqlite3_file *pFd;
+
+ if( objc!=7 ){
+ Tcl_WrongNumArgs(interp, 1, objv,
+ "DB DBNAME (shared|exclusive) (lock|unlock) OFFSET N"
+ );
+ return TCL_ERROR;
+ }
+
+ zDbname = Tcl_GetString(objv[2]);
+ if( getDbPointer(interp, Tcl_GetString(objv[1]), &db)
+ || Tcl_GetIndexFromObj(interp, objv[3], azArg1, "ARG", 0, &iArg1)
+ || Tcl_GetIndexFromObj(interp, objv[4], azArg2, "ARG", 0, &iArg2)
+ || Tcl_GetIntFromObj(interp, objv[5], &iOffset)
+ || Tcl_GetIntFromObj(interp, objv[6], &n)
+ ){
+ return TCL_ERROR;
+ }
+
+ sqlite3_file_control(db, zDbname, SQLITE_FCNTL_FILE_POINTER, (void*)&pFd);
+ if( pFd==0 ){
+ return TCL_ERROR;
+ }
+ rc = pFd->pMethods->xShmLock(pFd, iOffset, n,
+ (iArg1==0 ? SQLITE_SHM_SHARED : SQLITE_SHM_EXCLUSIVE)
+ | (iArg2==0 ? SQLITE_SHM_LOCK : SQLITE_SHM_UNLOCK)
+ );
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3ErrName(rc), -1));
+ return TCL_OK;
+}
+
+static int SQLITE_TCLAPI test_vfs_set_readmark(
+ void * clientData,
+ Tcl_Interp *interp,
+ int objc,
+ Tcl_Obj *CONST objv[]
+){
+ sqlite3 *db = 0;
+ int rc = SQLITE_OK;
+ const char *zDbname = 0;
+ int iSlot = 0;
+ int iVal = -1;
+ sqlite3_file *pFd;
+ void volatile *pShm = 0;
+ u32 *aShm;
+ int iOff;
+
+ if( objc!=4 && objc!=5 ){
+ Tcl_WrongNumArgs(interp, 1, objv, "DB DBNAME SLOT ?VALUE?");
+ return TCL_ERROR;
+ }
+
+ zDbname = Tcl_GetString(objv[2]);
+ if( getDbPointer(interp, Tcl_GetString(objv[1]), &db)
+ || Tcl_GetIntFromObj(interp, objv[3], &iSlot)
+ || (objc==5 && Tcl_GetIntFromObj(interp, objv[4], &iVal))
+ ){
+ return TCL_ERROR;
+ }
+
+ sqlite3_file_control(db, zDbname, SQLITE_FCNTL_FILE_POINTER, (void*)&pFd);
+ if( pFd==0 ){
+ return TCL_ERROR;
+ }
+ rc = pFd->pMethods->xShmMap(pFd, 0, 32*1024, 0, &pShm);
+ if( rc!=SQLITE_OK ){
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(sqlite3ErrName(rc), -1));
+ return TCL_ERROR;
+ }
+ if( pShm==0 ){
+ Tcl_AppendResult(interp, "*-shm is not yet mapped", 0);
+ return TCL_ERROR;
+ }
+ aShm = (u32*)pShm;
+ iOff = 12*2+1+iSlot;
+
+ if( objc==5 ){
+ aShm[iOff] = iVal;
+ }
+ Tcl_SetObjResult(interp, Tcl_NewIntObj(aShm[iOff]));
+
+ return TCL_OK;
+}
+
int Sqlitetestvfs_Init(Tcl_Interp *interp){
Tcl_CreateObjCommand(interp, "testvfs", testvfs_cmd, 0, 0);
+ Tcl_CreateObjCommand(interp, "vfs_shmlock", test_vfs_shmlock, 0, 0);
+ Tcl_CreateObjCommand(interp, "vfs_set_readmark", test_vfs_set_readmark, 0, 0);
return TCL_OK;
}
diff --git a/chromium/third_party/sqlite/src/src/tokenize.c b/chromium/third_party/sqlite/src/src/tokenize.c
index 4e56a487e54..896c5702579 100644
--- a/chromium/third_party/sqlite/src/src/tokenize.c
+++ b/chromium/third_party/sqlite/src/src/tokenize.c
@@ -545,73 +545,6 @@ int sqlite3GetToken(const unsigned char *z, int *tokenType){
return i;
}
-#ifdef SQLITE_ENABLE_NORMALIZE
-/*
-** Return the length (in bytes) of the token that begins at z[0].
-** Store the token type in *tokenType before returning. If flags has
-** SQLITE_TOKEN_NORMALIZE flag enabled, use the identifier token type
-** for keywords. Add SQLITE_TOKEN_QUOTED to flags if the token was
-** actually a quoted identifier. Add SQLITE_TOKEN_KEYWORD to flags
-** if the token was recognized as a keyword; this is useful when the
-** SQLITE_TOKEN_NORMALIZE flag is used, because it enables the caller
-** to differentiate between a keyword being treated as an identifier
-** (for normalization purposes) and an actual identifier.
-*/
-int sqlite3GetTokenNormalized(
- const unsigned char *z,
- int *tokenType,
- int *flags
-){
- int n;
- unsigned char iClass = aiClass[*z];
- if( iClass==CC_KYWD ){
- int i;
- for(i=1; aiClass[z[i]]<=CC_KYWD; i++){}
- if( IdChar(z[i]) ){
- /* This token started out using characters that can appear in keywords,
- ** but z[i] is a character not allowed within keywords, so this must
- ** be an identifier instead */
- i++;
- while( IdChar(z[i]) ){ i++; }
- *tokenType = TK_ID;
- return i;
- }
- *tokenType = TK_ID;
- n = keywordCode((char*)z, i, tokenType);
- /* If the token is no longer considered to be an identifier, then it is a
- ** keyword of some kind. Make the token back into an identifier and then
- ** set the SQLITE_TOKEN_KEYWORD flag. Several non-identifier tokens are
- ** used verbatim, including IN, IS, NOT, and NULL. */
- switch( *tokenType ){
- case TK_ID: {
- /* do nothing, handled by caller */
- break;
- }
- case TK_IN:
- case TK_IS:
- case TK_NOT:
- case TK_NULL: {
- *flags |= SQLITE_TOKEN_KEYWORD;
- break;
- }
- default: {
- *tokenType = TK_ID;
- *flags |= SQLITE_TOKEN_KEYWORD;
- break;
- }
- }
- }else{
- n = sqlite3GetToken(z, tokenType);
- /* If the token is considered to be an identifier and the character class
- ** of the first character is a quote, set the SQLITE_TOKEN_QUOTED flag. */
- if( *tokenType==TK_ID && (iClass==CC_QUOTE || iClass==CC_QUOTE2) ){
- *flags |= SQLITE_TOKEN_QUOTED;
- }
- }
- return n;
-}
-#endif /* SQLITE_ENABLE_NORMALIZE */
-
/*
** Run the parser on the given SQL string. The parser structure is
** passed in. An SQLITE_ status code is returned. If an error occurs
@@ -639,7 +572,14 @@ int sqlite3RunParser(Parse *pParse, const char *zSql, char **pzErrMsg){
pParse->rc = SQLITE_OK;
pParse->zTail = zSql;
assert( pzErrMsg!=0 );
- /* sqlite3ParserTrace(stdout, "parser: "); */
+#ifdef SQLITE_DEBUG
+ if( db->flags & SQLITE_ParserTrace ){
+ printf("parser: [[[%s]]]\n", zSql);
+ sqlite3ParserTrace(stdout, "parser: ");
+ }else{
+ sqlite3ParserTrace(0, 0);
+ }
+#endif
#ifdef sqlite3Parser_ENGINEALWAYSONSTACK
pEngine = &sEngine;
sqlite3ParserInit(pEngine, pParse);
@@ -781,3 +721,138 @@ int sqlite3RunParser(Parse *pParse, const char *zSql, char **pzErrMsg){
assert( nErr==0 || pParse->rc!=SQLITE_OK );
return nErr;
}
+
+
+#ifdef SQLITE_ENABLE_NORMALIZE
+/*
+** Insert a single space character into pStr if the current string
+** ends with an identifier
+*/
+static void addSpaceSeparator(sqlite3_str *pStr){
+ if( pStr->nChar && sqlite3IsIdChar(pStr->zText[pStr->nChar-1]) ){
+ sqlite3_str_append(pStr, " ", 1);
+ }
+}
+
+/*
+** Compute a normalization of the SQL given by zSql[0..nSql-1]. Return
+** the normalization in space obtained from sqlite3DbMalloc(). Or return
+** NULL if anything goes wrong or if zSql is NULL.
+*/
+char *sqlite3Normalize(
+ Vdbe *pVdbe, /* VM being reprepared */
+ const char *zSql /* The original SQL string */
+){
+ sqlite3 *db; /* The database connection */
+ int i; /* Next unread byte of zSql[] */
+ int n; /* length of current token */
+ int tokenType; /* type of current token */
+ int prevType = 0; /* Previous non-whitespace token */
+ int nParen; /* Number of nested levels of parentheses */
+ int iStartIN; /* Start of RHS of IN operator in z[] */
+ int nParenAtIN; /* Value of nParent at start of RHS of IN operator */
+ int j; /* Bytes of normalized SQL generated so far */
+ sqlite3_str *pStr; /* The normalized SQL string under construction */
+
+ db = sqlite3VdbeDb(pVdbe);
+ tokenType = -1;
+ nParen = iStartIN = nParenAtIN = 0;
+ pStr = sqlite3_str_new(db);
+ assert( pStr!=0 ); /* sqlite3_str_new() never returns NULL */
+ for(i=0; zSql[i] && pStr->accError==0; i+=n){
+ if( tokenType!=TK_SPACE ){
+ prevType = tokenType;
+ }
+ n = sqlite3GetToken((unsigned char*)zSql+i, &tokenType);
+ if( NEVER(n<=0) ) break;
+ switch( tokenType ){
+ case TK_SPACE: {
+ break;
+ }
+ case TK_NULL: {
+ if( prevType==TK_IS || prevType==TK_NOT ){
+ sqlite3_str_append(pStr, " NULL", 5);
+ break;
+ }
+ /* Fall through */
+ }
+ case TK_STRING:
+ case TK_INTEGER:
+ case TK_FLOAT:
+ case TK_VARIABLE:
+ case TK_BLOB: {
+ sqlite3_str_append(pStr, "?", 1);
+ break;
+ }
+ case TK_LP: {
+ nParen++;
+ if( prevType==TK_IN ){
+ iStartIN = pStr->nChar;
+ nParenAtIN = nParen;
+ }
+ sqlite3_str_append(pStr, "(", 1);
+ break;
+ }
+ case TK_RP: {
+ if( iStartIN>0 && nParen==nParenAtIN ){
+ assert( pStr->nChar>=iStartIN );
+ pStr->nChar = iStartIN+1;
+ sqlite3_str_append(pStr, "?,?,?", 5);
+ iStartIN = 0;
+ }
+ nParen--;
+ sqlite3_str_append(pStr, ")", 1);
+ break;
+ }
+ case TK_ID: {
+ iStartIN = 0;
+ j = pStr->nChar;
+ if( sqlite3Isquote(zSql[i]) ){
+ char *zId = sqlite3DbStrNDup(db, zSql+i, n);
+ int nId;
+ int eType = 0;
+ if( zId==0 ) break;
+ sqlite3Dequote(zId);
+ if( zSql[i]=='"' && sqlite3VdbeUsesDoubleQuotedString(pVdbe, zId) ){
+ sqlite3_str_append(pStr, "?", 1);
+ sqlite3DbFree(db, zId);
+ break;
+ }
+ nId = sqlite3Strlen30(zId);
+ if( sqlite3GetToken((u8*)zId, &eType)==nId && eType==TK_ID ){
+ addSpaceSeparator(pStr);
+ sqlite3_str_append(pStr, zId, nId);
+ }else{
+ sqlite3_str_appendf(pStr, "\"%w\"", zId);
+ }
+ sqlite3DbFree(db, zId);
+ }else{
+ addSpaceSeparator(pStr);
+ sqlite3_str_append(pStr, zSql+i, n);
+ }
+ while( j<pStr->nChar ){
+ pStr->zText[j] = sqlite3Tolower(pStr->zText[j]);
+ j++;
+ }
+ break;
+ }
+ case TK_SELECT: {
+ iStartIN = 0;
+ /* fall through */
+ }
+ default: {
+ if( sqlite3IsIdChar(zSql[i]) ) addSpaceSeparator(pStr);
+ j = pStr->nChar;
+ sqlite3_str_append(pStr, zSql+i, n);
+ while( j<pStr->nChar ){
+ pStr->zText[j] = sqlite3Toupper(pStr->zText[j]);
+ j++;
+ }
+ break;
+ }
+ }
+ }
+ if( tokenType!=TK_SEMI ) sqlite3_str_append(pStr, ";", 1);
+ return sqlite3_str_finish(pStr);
+}
+#endif /* SQLITE_ENABLE_NORMALIZE */
diff --git a/chromium/third_party/sqlite/src/src/treeview.c b/chromium/third_party/sqlite/src/src/treeview.c
index e7483dde25f..2cb5197740b 100644
--- a/chromium/third_party/sqlite/src/src/treeview.c
+++ b/chromium/third_party/sqlite/src/src/treeview.c
@@ -138,7 +138,8 @@ void sqlite3TreeViewSrcList(TreeView *pView, const SrcList *pSrc){
sqlite3_str_appendf(&x, " %s", pItem->zName);
}
if( pItem->pTab ){
- sqlite3_str_appendf(&x, " tabname=%Q", pItem->pTab->zName);
+ sqlite3_str_appendf(&x, " tab=%Q nCol=%d ptr=%p",
+ pItem->pTab->zName, pItem->pTab->nCol, pItem->pTab);
}
if( pItem->zAlias ){
sqlite3_str_appendf(&x, " (AS %s)", pItem->zAlias);
diff --git a/chromium/third_party/sqlite/src/src/trigger.c b/chromium/third_party/sqlite/src/src/trigger.c
index 69fddedd914..fba75d8fb4d 100644
--- a/chromium/third_party/sqlite/src/src/trigger.c
+++ b/chromium/third_party/sqlite/src/src/trigger.c
@@ -731,7 +731,7 @@ static SrcList *targetSrcList(
int iDb; /* Index of the database to use */
SrcList *pSrc; /* SrcList to be returned */
- pSrc = sqlite3SrcListAppend(db, 0, 0, 0);
+ pSrc = sqlite3SrcListAppend(pParse, 0, 0, 0);
if( pSrc ){
assert( pSrc->nSrc>0 );
pSrc->a[pSrc->nSrc-1].zName = sqlite3DbStrDup(db, pStep->zTarget);
@@ -944,7 +944,7 @@ static TriggerPrg *codeRowTrigger(
if( SQLITE_OK==sqlite3ResolveExprNames(&sNC, pWhen)
&& db->mallocFailed==0
){
- iEndTrigger = sqlite3VdbeMakeLabel(v);
+ iEndTrigger = sqlite3VdbeMakeLabel(pSubParse);
sqlite3ExprIfFalse(pSubParse, pWhen, iEndTrigger, SQLITE_JUMPIFNULL);
}
sqlite3ExprDelete(db, pWhen);
diff --git a/chromium/third_party/sqlite/src/src/update.c b/chromium/third_party/sqlite/src/src/update.c
index b328d3b229b..98ed29244f2 100644
--- a/chromium/third_party/sqlite/src/src/update.c
+++ b/chromium/third_party/sqlite/src/src/update.c
@@ -354,6 +354,7 @@ void sqlite3Update(
** being updated. Fill in aRegIdx[] with a register number that will hold
** the key for accessing each index.
*/
+ if( onError==OE_Replace ) bReplace = 1;
for(j=0, pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext, j++){
int reg;
if( chngKey || hasFK>1 || pIdx==pPk
@@ -367,9 +368,7 @@ void sqlite3Update(
if( indexColumnIsBeingUpdated(pIdx, i, aXRef, chngRowid) ){
reg = ++pParse->nMem;
pParse->nMem += pIdx->nColumn;
- if( (onError==OE_Replace)
- || (onError==OE_Default && pIdx->onError==OE_Replace)
- ){
+ if( onError==OE_Default && pIdx->onError==OE_Replace ){
bReplace = 1;
}
break;
@@ -441,7 +440,7 @@ void sqlite3Update(
#endif
/* Jump to labelBreak to abandon further processing of this UPDATE */
- labelContinue = labelBreak = sqlite3VdbeMakeLabel(v);
+ labelContinue = labelBreak = sqlite3VdbeMakeLabel(pParse);
/* Not an UPSERT. Normal processing. Begin by
** initialize the count of updated rows */
@@ -576,13 +575,13 @@ void sqlite3Update(
VdbeCoverage(v);
}
if( eOnePass!=ONEPASS_SINGLE ){
- labelContinue = sqlite3VdbeMakeLabel(v);
+ labelContinue = sqlite3VdbeMakeLabel(pParse);
}
sqlite3VdbeAddOp2(v, OP_IsNull, pPk ? regKey : regOldRowid, labelBreak);
VdbeCoverageIf(v, pPk==0);
VdbeCoverageIf(v, pPk!=0);
}else if( pPk ){
- labelContinue = sqlite3VdbeMakeLabel(v);
+ labelContinue = sqlite3VdbeMakeLabel(pParse);
sqlite3VdbeAddOp2(v, OP_Rewind, iEph, labelBreak); VdbeCoverage(v);
addrTop = sqlite3VdbeAddOp2(v, OP_RowData, iEph, regKey);
sqlite3VdbeAddOp4Int(v, OP_NotFound, iDataCur, labelContinue, regKey, 0);
diff --git a/chromium/third_party/sqlite/src/src/util.c b/chromium/third_party/sqlite/src/src/util.c
index 4f700d4d538..7e4bb725280 100644
--- a/chromium/third_party/sqlite/src/src/util.c
+++ b/chromium/third_party/sqlite/src/src/util.c
@@ -238,7 +238,7 @@ void sqlite3ErrorMsg(Parse *pParse, const char *zFormat, ...){
** dequoted string, exclusive of the zero terminator, if dequoting does
** occur.
**
-** 2002-Feb-14: This routine is extended to remove MS-Access style
+** 2002-02-14: This routine is extended to remove MS-Access style
** brackets from around identifiers. For example: "[a-b-c]" becomes
** "a-b-c".
*/
@@ -264,6 +264,11 @@ void sqlite3Dequote(char *z){
}
z[j] = 0;
}
+void sqlite3DequoteExpr(Expr *p){
+ assert( sqlite3Isquote(p->u.zToken[0]) );
+ p->flags |= p->u.zToken[0]=='"' ? EP_Quoted|EP_DblQuoted : EP_Quoted;
+ sqlite3Dequote(p->u.zToken);
+}
/*
** Generate a Token object from a string
diff --git a/chromium/third_party/sqlite/src/src/vacuum.c b/chromium/third_party/sqlite/src/src/vacuum.c
index 6ee545d18fc..8ed587c81f9 100644
--- a/chromium/third_party/sqlite/src/src/vacuum.c
+++ b/chromium/third_party/sqlite/src/src/vacuum.c
@@ -102,16 +102,16 @@ static int execSqlF(sqlite3 *db, char **pzErrMsg, const char *zSql, ...){
** transient would cause the database file to appear to be deleted
** following reboot.
*/
-void sqlite3Vacuum(Parse *pParse, Token *pNm){
+void sqlite3Vacuum(Parse *pParse, Token *pNm, Expr *pInto){
Vdbe *v = sqlite3GetVdbe(pParse);
int iDb = 0;
- if( v==0 ) return;
+ if( v==0 ) goto build_vacuum_end;
if( pNm ){
#ifndef SQLITE_BUG_COMPATIBLE_20160819
/* Default behavior: Report an error if the argument to VACUUM is
** not recognized */
iDb = sqlite3TwoPartName(pParse, pNm, pNm, &pNm);
- if( iDb<0 ) return;
+ if( iDb<0 ) goto build_vacuum_end;
#else
/* When SQLITE_BUG_COMPATIBLE_20160819 is defined, unrecognized arguments
** to VACUUM are silently ignored. This is a back-out of a bug fix that
@@ -123,21 +123,33 @@ void sqlite3Vacuum(Parse *pParse, Token *pNm){
#endif
}
if( iDb!=1 ){
- sqlite3VdbeAddOp1(v, OP_Vacuum, iDb);
+ int iIntoReg = 0;
+ if( pInto && sqlite3ResolveSelfReference(pParse,0,0,pInto,0)==0 ){
+ iIntoReg = ++pParse->nMem;
+ sqlite3ExprCode(pParse, pInto, iIntoReg);
+ }
+ sqlite3VdbeAddOp2(v, OP_Vacuum, iDb, iIntoReg);
sqlite3VdbeUsesBtree(v, iDb);
}
+build_vacuum_end:
+ sqlite3ExprDelete(pParse->db, pInto);
return;
}
/*
** This routine implements the OP_Vacuum opcode of the VDBE.
*/
-int sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db, int iDb){
+int sqlite3RunVacuum(
+ char **pzErrMsg, /* Write error message here */
+ sqlite3 *db, /* Database connection */
+ int iDb, /* Which attached DB to vacuum */
+ sqlite3_value *pOut /* Write results here, if not NULL */
+){
int rc = SQLITE_OK; /* Return code from service routines */
Btree *pMain; /* The database being vacuumed */
Btree *pTemp; /* The temporary database we vacuum into */
- u16 saved_mDbFlags; /* Saved value of db->mDbFlags */
- u32 saved_flags; /* Saved value of db->flags */
+ u32 saved_mDbFlags; /* Saved value of db->mDbFlags */
+ u64 saved_flags; /* Saved value of db->flags */
int saved_nChange; /* Saved value of db->nChange */
int saved_nTotalChange; /* Saved value of db->nTotalChange */
u8 saved_mTrace; /* Saved trace settings */
@@ -146,6 +158,7 @@ int sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db, int iDb){
int nRes; /* Bytes of reserved space at the end of each page */
int nDb; /* Number of attached databases */
const char *zDbMain; /* Schema name of database to vacuum */
+ const char *zOut; /* Name of output file */
if( !db->autoCommit ){
sqlite3SetString(pzErrMsg, db, "cannot VACUUM from within a transaction");
@@ -155,6 +168,15 @@ int sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db, int iDb){
sqlite3SetString(pzErrMsg, db,"cannot VACUUM - SQL statements in progress");
return SQLITE_ERROR;
}
+ if( pOut ){
+ if( sqlite3_value_type(pOut)!=SQLITE_TEXT ){
+ sqlite3SetString(pzErrMsg, db, "non-text filename");
+ return SQLITE_ERROR;
+ }
+ zOut = (const char*)sqlite3_value_text(pOut);
+ }else{
+ zOut = "";
+ }
/* Save the current value of the database flags so that it can be
** restored before returning. Then set the writable-schema flag, and
@@ -166,7 +188,7 @@ int sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db, int iDb){
saved_mTrace = db->mTrace;
db->flags |= SQLITE_WriteSchema | SQLITE_IgnoreChecks;
db->mDbFlags |= DBFLAG_PreferBuiltin | DBFLAG_Vacuum;
- db->flags &= ~(SQLITE_ForeignKeys | SQLITE_ReverseOrder
+ db->flags &= ~(u64)(SQLITE_ForeignKeys | SQLITE_ReverseOrder
| SQLITE_Defensive | SQLITE_CountRows);
db->mTrace = 0;
@@ -189,19 +211,21 @@ int sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db, int iDb){
** to write the journal header file.
*/
nDb = db->nDb;
- rc = execSql(db, pzErrMsg, "ATTACH''AS vacuum_db");
+ rc = execSqlF(db, pzErrMsg, "ATTACH %Q AS vacuum_db", zOut);
if( rc!=SQLITE_OK ) goto end_of_vacuum;
assert( (db->nDb-1)==nDb );
pDb = &db->aDb[nDb];
assert( strcmp(pDb->zDbSName,"vacuum_db")==0 );
pTemp = pDb->pBt;
-
- /* The call to execSql() to attach the temp database has left the file
- ** locked (as there was more than one active statement when the transaction
- ** to read the schema was concluded. Unlock it here so that this doesn't
- ** cause problems for the call to BtreeSetPageSize() below. */
- sqlite3BtreeCommit(pTemp);
-
+ if( pOut ){
+ sqlite3_file *id = sqlite3PagerFile(sqlite3BtreePager(pTemp));
+ i64 sz = 0;
+ if( id->pMethods!=0 && (sqlite3OsFileSize(id, &sz)!=SQLITE_OK || sz>0) ){
+ rc = SQLITE_ERROR;
+ sqlite3SetString(pzErrMsg, db, "output file already exists");
+ goto end_of_vacuum;
+ }
+ }
nRes = sqlite3BtreeGetOptimalReserve(pMain);
/* A VACUUM cannot change the pagesize of an encrypted database. */
@@ -225,7 +249,7 @@ int sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db, int iDb){
*/
rc = execSql(db, pzErrMsg, "BEGIN");
if( rc!=SQLITE_OK ) goto end_of_vacuum;
- rc = sqlite3BtreeBeginTrans(pMain, 2, 0);
+ rc = sqlite3BtreeBeginTrans(pMain, pOut==0 ? 2 : 0, 0);
if( rc!=SQLITE_OK ) goto end_of_vacuum;
/* Do not attempt to change the page size for a WAL database */
@@ -320,7 +344,7 @@ int sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db, int iDb){
};
assert( 1==sqlite3BtreeIsInTrans(pTemp) );
- assert( 1==sqlite3BtreeIsInTrans(pMain) );
+ assert( pOut!=0 || 1==sqlite3BtreeIsInTrans(pMain) );
/* Copy Btree meta values */
for(i=0; i<ArraySize(aCopy); i+=2){
@@ -331,17 +355,23 @@ int sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db, int iDb){
if( NEVER(rc!=SQLITE_OK) ) goto end_of_vacuum;
}
- rc = sqlite3BtreeCopyFile(pMain, pTemp);
+ if( pOut==0 ){
+ rc = sqlite3BtreeCopyFile(pMain, pTemp);
+ }
if( rc!=SQLITE_OK ) goto end_of_vacuum;
rc = sqlite3BtreeCommit(pTemp);
if( rc!=SQLITE_OK ) goto end_of_vacuum;
#ifndef SQLITE_OMIT_AUTOVACUUM
- sqlite3BtreeSetAutoVacuum(pMain, sqlite3BtreeGetAutoVacuum(pTemp));
+ if( pOut==0 ){
+ sqlite3BtreeSetAutoVacuum(pMain, sqlite3BtreeGetAutoVacuum(pTemp));
+ }
#endif
}
assert( rc==SQLITE_OK );
- rc = sqlite3BtreeSetPageSize(pMain, sqlite3BtreeGetPageSize(pTemp), nRes,1);
+ if( pOut==0 ){
+ rc = sqlite3BtreeSetPageSize(pMain, sqlite3BtreeGetPageSize(pTemp), nRes,1);
+ }
end_of_vacuum:
/* Restore the original value of db->flags */
diff --git a/chromium/third_party/sqlite/src/src/vdbe.c b/chromium/third_party/sqlite/src/src/vdbe.c
index ae2ff53d5e2..1d712239562 100644
--- a/chromium/third_party/sqlite/src/src/vdbe.c
+++ b/chromium/third_party/sqlite/src/src/vdbe.c
@@ -240,6 +240,11 @@ static VdbeCursor *allocateCursor(
assert( iCur>=0 && iCur<p->nCursor );
if( p->apCsr[iCur] ){ /*OPTIMIZATION-IF-FALSE*/
+ /* Before calling sqlite3VdbeFreeCursor(), ensure the isEphemeral flag
+ ** is clear. Otherwise, if this is an ephemeral cursor created by
+ ** OP_OpenDup, the cursor will not be closed and will still be part
+ ** of a BtShared.pCursor list. */
+ p->apCsr[iCur]->isEphemeral = 0;
sqlite3VdbeFreeCursor(p, p->apCsr[iCur]);
p->apCsr[iCur] = 0;
}
@@ -380,6 +385,7 @@ void sqlite3ValueApplyAffinity(
static u16 SQLITE_NOINLINE computeNumericType(Mem *pMem){
assert( (pMem->flags & (MEM_Int|MEM_Real))==0 );
assert( (pMem->flags & (MEM_Str|MEM_Blob))!=0 );
+ ExpandBlob(pMem);
if( sqlite3AtoF(pMem->z, &pMem->u.r, pMem->n, pMem->enc)==0 ){
return 0;
}
@@ -1578,8 +1584,8 @@ fp_math:
break;
}
default: {
- iA = (i64)rA;
- iB = (i64)rB;
+ iA = sqlite3VdbeIntValue(pIn1);
+ iB = sqlite3VdbeIntValue(pIn2);
if( iA==0 ) goto arithmetic_result_is_null;
if( iA==-1 ) iA = 1;
rB = (double)(iB % iA);
@@ -1925,7 +1931,8 @@ case OP_Ge: { /* same as TK_GE, jump, in1, in3 */
*/
assert( pOp->opcode==OP_Eq || pOp->opcode==OP_Ne );
assert( (flags1 & MEM_Cleared)==0 );
- assert( (pOp->p5 & SQLITE_JUMPIFNULL)==0 );
+ assert( (pOp->p5 & SQLITE_JUMPIFNULL)==0 || CORRUPT_DB );
+ testcase( (pOp->p5 & SQLITE_JUMPIFNULL)!=0 );
if( (flags1&flags3&MEM_Null)!=0
&& (flags3&MEM_Cleared)==0
){
@@ -3609,7 +3616,8 @@ case OP_OpenDup: {
pCx->isEphemeral = 1;
pCx->pKeyInfo = pOrig->pKeyInfo;
pCx->isTable = pOrig->isTable;
- rc = sqlite3BtreeCursor(pOrig->pBtx, MASTER_ROOT, BTREE_WRCSR,
+ pCx->pgnoRoot = pOrig->pgnoRoot;
+ rc = sqlite3BtreeCursor(pOrig->pBtx, pCx->pgnoRoot, BTREE_WRCSR,
pCx->pKeyInfo, pCx->uc.pCursor);
/* The sqlite3BtreeCursor() routine can only fail for the first cursor
** opened for a database. Since there is already an open cursor when this
@@ -3627,6 +3635,9 @@ case OP_OpenDup: {
** the main database is read-only. The ephemeral
** table is deleted automatically when the cursor is closed.
**
+** If the cursor P1 is already opened on an ephemeral table, the table
+** is cleared (all content is erased).
+**
** P2 is the number of columns in the ephemeral table.
** The cursor points to a BTree table if P4==0 and to a BTree index
** if P4 is not 0. If P4 is not NULL, it points to a KeyInfo structure
@@ -3658,41 +3669,50 @@ case OP_OpenEphemeral: {
SQLITE_OPEN_TRANSIENT_DB;
assert( pOp->p1>=0 );
assert( pOp->p2>=0 );
- pCx = allocateCursor(p, pOp->p1, pOp->p2, -1, CURTYPE_BTREE);
- if( pCx==0 ) goto no_mem;
- pCx->nullRow = 1;
- pCx->isEphemeral = 1;
- rc = sqlite3BtreeOpen(db->pVfs, 0, db, &pCx->pBtx,
- BTREE_OMIT_JOURNAL | BTREE_SINGLE | pOp->p5, vfsFlags);
- if( rc==SQLITE_OK ){
- rc = sqlite3BtreeBeginTrans(pCx->pBtx, 1, 0);
- }
- if( rc==SQLITE_OK ){
- /* If a transient index is required, create it by calling
- ** sqlite3BtreeCreateTable() with the BTREE_BLOBKEY flag before
- ** opening it. If a transient table is required, just use the
- ** automatically created table with root-page 1 (an BLOB_INTKEY table).
- */
- if( (pCx->pKeyInfo = pKeyInfo = pOp->p4.pKeyInfo)!=0 ){
- int pgno;
- assert( pOp->p4type==P4_KEYINFO );
- rc = sqlite3BtreeCreateTable(pCx->pBtx, &pgno, BTREE_BLOBKEY | pOp->p5);
- if( rc==SQLITE_OK ){
- assert( pgno==MASTER_ROOT+1 );
- assert( pKeyInfo->db==db );
- assert( pKeyInfo->enc==ENC(db) );
- rc = sqlite3BtreeCursor(pCx->pBtx, pgno, BTREE_WRCSR,
- pKeyInfo, pCx->uc.pCursor);
+ pCx = p->apCsr[pOp->p1];
+ if( pCx ){
+ /* If the ephermeral table is already open, erase all existing content
+ ** so that the table is empty again, rather than creating a new table. */
+ rc = sqlite3BtreeClearTable(pCx->pBtx, pCx->pgnoRoot, 0);
+ }else{
+ pCx = allocateCursor(p, pOp->p1, pOp->p2, -1, CURTYPE_BTREE);
+ if( pCx==0 ) goto no_mem;
+ pCx->nullRow = 1;
+ pCx->isEphemeral = 1;
+ rc = sqlite3BtreeOpen(db->pVfs, 0, db, &pCx->pBtx,
+ BTREE_OMIT_JOURNAL | BTREE_SINGLE | pOp->p5,
+ vfsFlags);
+ if( rc==SQLITE_OK ){
+ rc = sqlite3BtreeBeginTrans(pCx->pBtx, 1, 0);
+ }
+ if( rc==SQLITE_OK ){
+ /* If a transient index is required, create it by calling
+ ** sqlite3BtreeCreateTable() with the BTREE_BLOBKEY flag before
+ ** opening it. If a transient table is required, just use the
+ ** automatically created table with root-page 1 (an BLOB_INTKEY table).
+ */
+ if( (pCx->pKeyInfo = pKeyInfo = pOp->p4.pKeyInfo)!=0 ){
+ assert( pOp->p4type==P4_KEYINFO );
+ rc = sqlite3BtreeCreateTable(pCx->pBtx, (int*)&pCx->pgnoRoot,
+ BTREE_BLOBKEY | pOp->p5);
+ if( rc==SQLITE_OK ){
+ assert( pCx->pgnoRoot==MASTER_ROOT+1 );
+ assert( pKeyInfo->db==db );
+ assert( pKeyInfo->enc==ENC(db) );
+ rc = sqlite3BtreeCursor(pCx->pBtx, pCx->pgnoRoot, BTREE_WRCSR,
+ pKeyInfo, pCx->uc.pCursor);
+ }
+ pCx->isTable = 0;
+ }else{
+ pCx->pgnoRoot = MASTER_ROOT;
+ rc = sqlite3BtreeCursor(pCx->pBtx, MASTER_ROOT, BTREE_WRCSR,
+ 0, pCx->uc.pCursor);
+ pCx->isTable = 1;
}
- pCx->isTable = 0;
- }else{
- rc = sqlite3BtreeCursor(pCx->pBtx, MASTER_ROOT, BTREE_WRCSR,
- 0, pCx->uc.pCursor);
- pCx->isTable = 1;
}
+ pCx->isOrdered = (pOp->p5!=BTREE_UNORDERED);
}
if( rc ) goto abort_due_to_error;
- pCx->isOrdered = (pOp->p5!=BTREE_UNORDERED);
break;
}
@@ -4342,7 +4362,7 @@ case OP_NotExists: /* jump, in3 */
pC = p->apCsr[pOp->p1];
assert( pC!=0 );
#ifdef SQLITE_DEBUG
- pC->seekOp = OP_SeekRowid;
+ if( pOp->opcode==OP_SeekRowid ) pC->seekOp = OP_SeekRowid;
#endif
assert( pC->isTable );
assert( pC->eCurType==CURTYPE_BTREE );
@@ -5250,7 +5270,7 @@ case OP_Next: /* jump */
assert( pOp->opcode!=OP_Next
|| pC->seekOp==OP_SeekGT || pC->seekOp==OP_SeekGE
|| pC->seekOp==OP_Rewind || pC->seekOp==OP_Found
- || pC->seekOp==OP_NullRow);
+ || pC->seekOp==OP_NullRow|| pC->seekOp==OP_SeekRowid);
assert( pOp->opcode!=OP_Prev
|| pC->seekOp==OP_SeekLT || pC->seekOp==OP_SeekLE
|| pC->seekOp==OP_Last
@@ -5780,9 +5800,16 @@ case OP_ParseSchema: {
assert( db->init.busy==0 );
db->init.busy = 1;
initData.rc = SQLITE_OK;
+ initData.nInitRow = 0;
assert( !db->mallocFailed );
rc = sqlite3_exec(db, zSql, sqlite3InitCallback, &initData, 0);
if( rc==SQLITE_OK ) rc = initData.rc;
+ if( rc==SQLITE_OK && initData.nInitRow==0 ){
+ /* The OP_ParseSchema opcode with a non-NULL P4 argument should parse
+ ** at least one SQL statement. Any less than that indicates that
+ ** the sqlite_master table is corrupt. */
+ rc = SQLITE_CORRUPT_BKPT;
+ }
sqlite3DbFreeNN(db, zSql);
db->init.busy = 0;
}
@@ -6146,6 +6173,17 @@ case OP_Program: { /* jump */
#ifdef SQLITE_ENABLE_STMT_SCANSTATUS
p->anExec = 0;
#endif
+#ifdef SQLITE_DEBUG
+ /* Verify that second and subsequent executions of the same trigger do not
+ ** try to reuse register values from the first use. */
+ {
+ int i;
+ for(i=0; i<p->nMem; i++){
+ aMem[i].pScopyFrom = 0; /* Prevent false-positive AboutToChange() errs */
+ aMem[i].flags |= MEM_Undefined; /* Cause a fault if this reg is reused */
+ }
+ }
+#endif
pOp = &aOp[-1];
break;
@@ -6684,14 +6722,19 @@ case OP_JournalMode: { /* out2 */
#endif /* SQLITE_OMIT_PRAGMA */
#if !defined(SQLITE_OMIT_VACUUM) && !defined(SQLITE_OMIT_ATTACH)
-/* Opcode: Vacuum P1 * * * *
+/* Opcode: Vacuum P1 P2 * * *
**
** Vacuum the entire database P1. P1 is 0 for "main", and 2 or more
** for an attached database. The "temp" database may not be vacuumed.
+**
+** If P2 is not zero, then it is a register holding a string which is
+** the file into which the result of vacuum should be written. When
+** P2 is zero, the vacuum overwrites the original database.
*/
case OP_Vacuum: {
assert( p->readOnly==0 );
- rc = sqlite3RunVacuum(&p->zErrMsg, db, pOp->p1);
+ rc = sqlite3RunVacuum(&p->zErrMsg, db, pOp->p1,
+ pOp->p2 ? &aMem[pOp->p2] : 0);
if( rc ) goto abort_due_to_error;
break;
}
@@ -6843,6 +6886,7 @@ case OP_VDestroy: {
db->nVDestroy++;
rc = sqlite3VtabCallDestroy(db, pOp->p1, pOp->p4.z);
db->nVDestroy--;
+ assert( p->errorAction==OE_Abort && p->usesStmtJournal );
if( rc ) goto abort_due_to_error;
break;
}
@@ -7086,7 +7130,7 @@ case OP_VRename: {
rc = sqlite3VdbeChangeEncoding(pName, SQLITE_UTF8);
if( rc ) goto abort_due_to_error;
rc = pVtab->pModule->xRename(pVtab, pName->z);
- if( isLegacy==0 ) db->flags &= ~SQLITE_LegacyAlter;
+ if( isLegacy==0 ) db->flags &= ~(u64)SQLITE_LegacyAlter;
sqlite3VtabImportErrmsg(p, pVtab);
p->expired = 0;
if( rc ) goto abort_due_to_error;
diff --git a/chromium/third_party/sqlite/src/src/vdbe.h b/chromium/third_party/sqlite/src/src/vdbe.h
index ef422bb2cd4..5522e62e75d 100644
--- a/chromium/third_party/sqlite/src/src/vdbe.h
+++ b/chromium/third_party/sqlite/src/src/vdbe.h
@@ -156,12 +156,11 @@ typedef struct VdbeOpList VdbeOpList;
#endif
/*
-** The following macro converts a relative address in the p2 field
-** of a VdbeOp structure into a negative number so that
-** sqlite3VdbeAddOpList() knows that the address is relative. Calling
-** the macro again restores the address.
+** The following macro converts a label returned by sqlite3VdbeMakeLabel()
+** into an index into the Parse.aLabel[] array that contains the resolved
+** address of that label.
*/
-#define ADDR(X) (-1-(X))
+#define ADDR(X) (~(X))
/*
** The makefile scans the vdbe.c source file and creates the "opcodes.h"
@@ -215,6 +214,12 @@ VdbeOp *sqlite3VdbeAddOpList(Vdbe*, int nOp, VdbeOpList const *aOp,int iLineno);
# define ExplainQueryPlan(P)
# define ExplainQueryPlanPop(P)
# define ExplainQueryPlanParent(P) 0
+# define sqlite3ExplainBreakpoint(A,B) /*no-op*/
+#endif
+#if defined(SQLITE_DEBUG) && !defined(SQLITE_OMIT_EXPLAIN)
+ void sqlite3ExplainBreakpoint(const char*,const char*);
+#else
+# define sqlite3ExplainBreakpoint(A,B) /*no-op*/
#endif
void sqlite3VdbeAddParseSchemaOp(Vdbe*,int,char*);
void sqlite3VdbeChangeOpcode(Vdbe*, u32 addr, u8);
@@ -230,7 +235,7 @@ void sqlite3VdbeAppendP4(Vdbe*, void *pP4, int p4type);
void sqlite3VdbeSetP4KeyInfo(Parse*, Index*);
void sqlite3VdbeUsesBtree(Vdbe*, int);
VdbeOp *sqlite3VdbeGetOp(Vdbe*, int);
-int sqlite3VdbeMakeLabel(Vdbe*);
+int sqlite3VdbeMakeLabel(Parse*);
void sqlite3VdbeRunOnlyOnce(Vdbe*);
void sqlite3VdbeReusable(Vdbe*);
void sqlite3VdbeDelete(Vdbe*);
@@ -251,6 +256,10 @@ void sqlite3VdbeCountChanges(Vdbe*);
sqlite3 *sqlite3VdbeDb(Vdbe*);
u8 sqlite3VdbePrepareFlags(Vdbe*);
void sqlite3VdbeSetSql(Vdbe*, const char *z, int n, u8);
+#ifdef SQLITE_ENABLE_NORMALIZE
+void sqlite3VdbeAddDblquoteStr(sqlite3*,Vdbe*,const char*);
+int sqlite3VdbeUsesDoubleQuotedString(Vdbe*,const char*);
+#endif
void sqlite3VdbeSwap(Vdbe*,Vdbe*);
VdbeOp *sqlite3VdbeTakeOpArray(Vdbe*, int*, int*);
sqlite3_value *sqlite3VdbeGetBoundValue(Vdbe*, int, u8);
diff --git a/chromium/third_party/sqlite/src/src/vdbeInt.h b/chromium/third_party/sqlite/src/src/vdbeInt.h
index 23c5b37cb47..7147547b407 100644
--- a/chromium/third_party/sqlite/src/src/vdbeInt.h
+++ b/chromium/third_party/sqlite/src/src/vdbeInt.h
@@ -335,6 +335,9 @@ struct sqlite3_context {
*/
typedef unsigned bft; /* Bit Field Type */
+/* The ScanStatus object holds a single value for the
+** sqlite3_stmt_scanstatus() interface.
+*/
typedef struct ScanStatus ScanStatus;
struct ScanStatus {
int addrExplain; /* OP_Explain for loop */
@@ -345,6 +348,19 @@ struct ScanStatus {
char *zName; /* Name of table or index */
};
+/* The DblquoteStr object holds the text of a double-quoted
+** string for a prepared statement. A linked list of these objects
+** is constructed during statement parsing and is held on Vdbe.pDblStr.
+** When computing a normalized SQL statement for an SQL statement, that
+** list is consulted for each double-quoted identifier to see if the
+** identifier should really be a string literal.
+*/
+typedef struct DblquoteStr DblquoteStr;
+struct DblquoteStr {
+ DblquoteStr *pNextStr; /* Next string literal in the list */
+ char z[8]; /* Dequoted value for the string */
+};
+
/*
** An instance of the virtual machine. This structure contains the complete
** state of the virtual machine.
@@ -364,28 +380,29 @@ struct Vdbe {
int pc; /* The program counter */
int rc; /* Value to return */
int nChange; /* Number of db changes made since last reset */
- int iStatement; /* Statement number (or 0 if has not opened stmt) */
+ int iStatement; /* Statement number (or 0 if has no opened stmt) */
i64 iCurrentTime; /* Value of julianday('now') for this statement */
i64 nFkConstraint; /* Number of imm. FK constraints this VM */
i64 nStmtDefCons; /* Number of def. constraints when stmt started */
i64 nStmtDefImmCons; /* Number of def. imm constraints when stmt started */
+ Mem *aMem; /* The memory locations */
+ Mem **apArg; /* Arguments to currently executing user function */
+ VdbeCursor **apCsr; /* One element of this array for each open cursor */
+ Mem *aVar; /* Values for the OP_Variable opcode. */
/* When allocating a new Vdbe object, all of the fields below should be
** initialized to zero or NULL */
Op *aOp; /* Space to hold the virtual machine's program */
- Mem *aMem; /* The memory locations */
- Mem **apArg; /* Arguments to currently executing user function */
+ int nOp; /* Number of instructions in the program */
+ int nOpAlloc; /* Slots allocated for aOp[] */
Mem *aColName; /* Column names to return */
Mem *pResultSet; /* Pointer to an array of results */
char *zErrMsg; /* Error message written here */
- VdbeCursor **apCsr; /* One element of this array for each open cursor */
- Mem *aVar; /* Values for the OP_Variable opcode. */
VList *pVList; /* Name of variables */
#ifndef SQLITE_OMIT_TRACE
i64 startTime; /* Time when query started - used for profiling */
#endif
- int nOp; /* Number of instructions in the program */
#ifdef SQLITE_DEBUG
int rcApp; /* errcode set by sqlite3_result_error_code() */
u32 nWrite; /* Number of write operations that have occurred */
@@ -408,6 +425,7 @@ struct Vdbe {
char *zSql; /* Text of the SQL statement that generated this */
#ifdef SQLITE_ENABLE_NORMALIZE
char *zNormSql; /* Normalization of the associated SQL statement */
+ DblquoteStr *pDblStr; /* List of double-quoted string literals */
#endif
void *pFree; /* Free this when deleting the vdbe */
VdbeFrame *pFrame; /* Parent frame */
diff --git a/chromium/third_party/sqlite/src/src/vdbeapi.c b/chromium/third_party/sqlite/src/src/vdbeapi.c
index 7cc7b1bdbf3..5b2f43d6782 100644
--- a/chromium/third_party/sqlite/src/src/vdbeapi.c
+++ b/chromium/third_party/sqlite/src/src/vdbeapi.c
@@ -62,14 +62,16 @@ static SQLITE_NOINLINE void invokeProfileCallback(sqlite3 *db, Vdbe *p){
sqlite3_int64 iNow;
sqlite3_int64 iElapse;
assert( p->startTime>0 );
- assert( db->xProfile!=0 || (db->mTrace & SQLITE_TRACE_PROFILE)!=0 );
+ assert( (db->mTrace & (SQLITE_TRACE_PROFILE|SQLITE_TRACE_XPROFILE))!=0 );
assert( db->init.busy==0 );
assert( p->zSql!=0 );
sqlite3OsCurrentTimeInt64(db->pVfs, &iNow);
iElapse = (iNow - p->startTime)*1000000;
+#ifndef SQLITE_OMIT_DEPRECATED
if( db->xProfile ){
db->xProfile(db->pProfileArg, p->zSql, iElapse);
}
+#endif
if( db->mTrace & SQLITE_TRACE_PROFILE ){
db->xTrace(SQLITE_TRACE_PROFILE, db->pTraceArg, p, (void*)&iElapse);
}
@@ -583,7 +585,7 @@ static int sqlite3Step(Vdbe *p){
return SQLITE_NOMEM_BKPT;
}
- if( p->pc<=0 && p->expired ){
+ if( p->pc<0 && p->expired ){
p->rc = SQLITE_SCHEMA;
rc = SQLITE_ERROR;
goto end_of_step;
@@ -602,7 +604,7 @@ static int sqlite3Step(Vdbe *p){
);
#ifndef SQLITE_OMIT_TRACE
- if( (db->xProfile || (db->mTrace & SQLITE_TRACE_PROFILE)!=0)
+ if( (db->mTrace & (SQLITE_TRACE_PROFILE|SQLITE_TRACE_XPROFILE))!=0
&& !db->init.busy && p->zSql ){
sqlite3OsCurrentTimeInt64(db->pVfs, &p->startTime);
}else{
@@ -629,16 +631,18 @@ static int sqlite3Step(Vdbe *p){
db->nVdbeExec--;
}
+ if( rc!=SQLITE_ROW ){
#ifndef SQLITE_OMIT_TRACE
- /* If the statement completed successfully, invoke the profile callback */
- if( rc!=SQLITE_ROW ) checkProfileCallback(db, p);
+ /* If the statement completed successfully, invoke the profile callback */
+ checkProfileCallback(db, p);
#endif
- if( rc==SQLITE_DONE && db->autoCommit ){
- assert( p->rc==SQLITE_OK );
- p->rc = doWalCallbacks(db);
- if( p->rc!=SQLITE_OK ){
- rc = SQLITE_ERROR;
+ if( rc==SQLITE_DONE && db->autoCommit ){
+ assert( p->rc==SQLITE_OK );
+ p->rc = doWalCallbacks(db);
+ if( p->rc!=SQLITE_OK ){
+ rc = SQLITE_ERROR;
+ }
}
}
@@ -658,9 +662,9 @@ end_of_step:
|| (rc&0xff)==SQLITE_BUSY || rc==SQLITE_MISUSE
);
assert( (p->rc!=SQLITE_ROW && p->rc!=SQLITE_DONE) || p->rc==p->rcApp );
- if( (p->prepFlags & SQLITE_PREPARE_SAVESQL)!=0
- && rc!=SQLITE_ROW
+ if( rc!=SQLITE_ROW
&& rc!=SQLITE_DONE
+ && (p->prepFlags & SQLITE_PREPARE_SAVESQL)!=0
){
/* If this statement was prepared using saved SQL and an
** error has occurred, then return the error code in p->rc to the
@@ -1282,7 +1286,7 @@ static int vdbeUnbind(Vdbe *p, int i){
pVar = &p->aVar[i];
sqlite3VdbeMemRelease(pVar);
pVar->flags = MEM_Null;
- sqlite3Error(p->db, SQLITE_OK);
+ p->db->errCode = SQLITE_OK;
/* If the bit corresponding to this variable in Vdbe.expmask is set, then
** binding a new value to this variable invalidates the current query plan.
@@ -1708,7 +1712,13 @@ char *sqlite3_expanded_sql(sqlite3_stmt *pStmt){
*/
const char *sqlite3_normalized_sql(sqlite3_stmt *pStmt){
Vdbe *p = (Vdbe *)pStmt;
- return p ? p->zNormSql : 0;
+ if( p==0 ) return 0;
+ if( p->zNormSql==0 && ALWAYS(p->zSql!=0) ){
+ sqlite3_mutex_enter(p->db->mutex);
+ p->zNormSql = sqlite3Normalize(p, p->zSql);
+ sqlite3_mutex_leave(p->db->mutex);
+ }
+ return p->zNormSql;
}
#endif /* SQLITE_ENABLE_NORMALIZE */
diff --git a/chromium/third_party/sqlite/src/src/vdbeaux.c b/chromium/third_party/sqlite/src/src/vdbeaux.c
index 13b2e1ef728..ca2f3874106 100644
--- a/chromium/third_party/sqlite/src/src/vdbeaux.c
+++ b/chromium/third_party/sqlite/src/src/vdbeaux.c
@@ -36,7 +36,7 @@ Vdbe *sqlite3VdbeCreate(Parse *pParse){
pParse->pVdbe = p;
assert( pParse->aLabel==0 );
assert( pParse->nLabel==0 );
- assert( pParse->nOpAlloc==0 );
+ assert( p->nOpAlloc==0 );
assert( pParse->szOpAlloc==0 );
sqlite3VdbeAddOp2(p, OP_Init, 0, 1);
return p;
@@ -64,14 +64,44 @@ void sqlite3VdbeSetSql(Vdbe *p, const char *z, int n, u8 prepFlags){
}
assert( p->zSql==0 );
p->zSql = sqlite3DbStrNDup(p->db, z, n);
+}
+
#ifdef SQLITE_ENABLE_NORMALIZE
- assert( p->zNormSql==0 );
- if( p->zSql && (prepFlags & SQLITE_PREPARE_NORMALIZE)!=0 ){
- sqlite3Normalize(p, p->zSql, n, prepFlags);
- assert( p->zNormSql!=0 || p->db->mallocFailed );
+/*
+** Add a new element to the Vdbe->pDblStr list.
+*/
+void sqlite3VdbeAddDblquoteStr(sqlite3 *db, Vdbe *p, const char *z){
+ if( p ){
+ int n = sqlite3Strlen30(z);
+ DblquoteStr *pStr = sqlite3DbMallocRawNN(db,
+ sizeof(*pStr)+n+1-sizeof(pStr->z));
+ if( pStr ){
+ pStr->pNextStr = p->pDblStr;
+ p->pDblStr = pStr;
+ memcpy(pStr->z, z, n+1);
+ }
}
+}
#endif
+
+#ifdef SQLITE_ENABLE_NORMALIZE
+/*
+** zId of length nId is a double-quoted identifier. Check to see if
+** that identifier is really used as a string literal.
+*/
+int sqlite3VdbeUsesDoubleQuotedString(
+ Vdbe *pVdbe, /* The prepared statement */
+ const char *zId /* The double-quoted identifier, already dequoted */
+){
+ DblquoteStr *pStr;
+ assert( zId!=0 );
+ if( pVdbe->pDblStr==0 ) return 0;
+ for(pStr=pVdbe->pDblStr; pStr; pStr=pStr->pNextStr){
+ if( strcmp(zId, pStr->z)==0 ) return 1;
+ }
+ return 0;
}
+#endif
/*
** Swap all content between two VDBE structures.
@@ -92,7 +122,7 @@ void sqlite3VdbeSwap(Vdbe *pA, Vdbe *pB){
zTmp = pA->zSql;
pA->zSql = pB->zSql;
pB->zSql = zTmp;
-#ifdef SQLITE_ENABLE_NORMALIZE
+#if 0
zTmp = pA->zNormSql;
pA->zNormSql = pB->zNormSql;
pB->zNormSql = zTmp;
@@ -109,7 +139,7 @@ void sqlite3VdbeSwap(Vdbe *pA, Vdbe *pB){
** to 1024/sizeof(Op).
**
** If an out-of-memory error occurs while resizing the array, return
-** SQLITE_NOMEM. In this case Vdbe.aOp and Parse.nOpAlloc remain
+** SQLITE_NOMEM. In this case Vdbe.aOp and Vdbe.nOpAlloc remain
** unchanged (this is so that any opcodes already allocated can be
** correctly deallocated along with the rest of the Vdbe).
*/
@@ -125,9 +155,9 @@ static int growOpArray(Vdbe *v, int nOp){
** operation (without SQLITE_TEST_REALLOC_STRESS) is to double the current
** size of the op array or add 1KB of space, whichever is smaller. */
#ifdef SQLITE_TEST_REALLOC_STRESS
- int nNew = (p->nOpAlloc>=512 ? p->nOpAlloc*2 : p->nOpAlloc+nOp);
+ int nNew = (v->nOpAlloc>=512 ? v->nOpAlloc*2 : v->nOpAlloc+nOp);
#else
- int nNew = (p->nOpAlloc ? p->nOpAlloc*2 : (int)(1024/sizeof(Op)));
+ int nNew = (v->nOpAlloc ? v->nOpAlloc*2 : (int)(1024/sizeof(Op)));
UNUSED_PARAMETER(nOp);
#endif
@@ -138,11 +168,11 @@ static int growOpArray(Vdbe *v, int nOp){
}
assert( nOp<=(1024/sizeof(Op)) );
- assert( nNew>=(p->nOpAlloc+nOp) );
+ assert( nNew>=(v->nOpAlloc+nOp) );
pNew = sqlite3DbRealloc(p->db, v->aOp, nNew*sizeof(Op));
if( pNew ){
p->szOpAlloc = sqlite3DbMallocSize(p->db, pNew);
- p->nOpAlloc = p->szOpAlloc/sizeof(Op);
+ v->nOpAlloc = p->szOpAlloc/sizeof(Op);
v->aOp = pNew;
}
return (pNew ? SQLITE_OK : SQLITE_NOMEM_BKPT);
@@ -176,9 +206,9 @@ static void test_addop_breakpoint(void){
** operand.
*/
static SQLITE_NOINLINE int growOp3(Vdbe *p, int op, int p1, int p2, int p3){
- assert( p->pParse->nOpAlloc<=p->nOp );
+ assert( p->nOpAlloc<=p->nOp );
if( growOpArray(p, 1) ) return 1;
- assert( p->pParse->nOpAlloc>p->nOp );
+ assert( p->nOpAlloc>p->nOp );
return sqlite3VdbeAddOp3(p, op, p1, p2, p3);
}
int sqlite3VdbeAddOp3(Vdbe *p, int op, int p1, int p2, int p3){
@@ -188,7 +218,7 @@ int sqlite3VdbeAddOp3(Vdbe *p, int op, int p1, int p2, int p3){
i = p->nOp;
assert( p->magic==VDBE_MAGIC_INIT );
assert( op>=0 && op<0xff );
- if( p->pParse->nOpAlloc<=i ){
+ if( p->nOpAlloc<=i ){
return growOp3(p, op, p1, p2, p3);
}
p->nOp++;
@@ -320,13 +350,29 @@ int sqlite3VdbeExplainParent(Parse *pParse){
}
/*
-** Add a new OP_Explain opcode.
+** Set a debugger breakpoint on the following routine in order to
+** monitor the EXPLAIN QUERY PLAN code generation.
+*/
+#if defined(SQLITE_DEBUG)
+void sqlite3ExplainBreakpoint(const char *z1, const char *z2){
+ (void)z1;
+ (void)z2;
+}
+#endif
+
+/*
+** Add a new OP_ opcode.
**
** If the bPush flag is true, then make this opcode the parent for
** subsequent Explains until sqlite3VdbeExplainPop() is called.
*/
void sqlite3VdbeExplain(Parse *pParse, u8 bPush, const char *zFmt, ...){
- if( pParse->explain==2 ){
+#ifndef SQLITE_DEBUG
+ /* Always include the OP_Explain opcodes if SQLITE_DEBUG is defined.
+ ** But omit them (for performance) during production builds */
+ if( pParse->explain==2 )
+#endif
+ {
char *zMsg;
Vdbe *v;
va_list ap;
@@ -338,7 +384,10 @@ void sqlite3VdbeExplain(Parse *pParse, u8 bPush, const char *zFmt, ...){
iThis = v->nOp;
sqlite3VdbeAddOp4(v, OP_Explain, iThis, pParse->addrExplain, 0,
zMsg, P4_DYNAMIC);
- if( bPush) pParse->addrExplain = iThis;
+ sqlite3ExplainBreakpoint(bPush?"PUSH":"", sqlite3VdbeGetOp(v,-1)->p4.z);
+ if( bPush){
+ pParse->addrExplain = iThis;
+ }
}
}
@@ -346,6 +395,7 @@ void sqlite3VdbeExplain(Parse *pParse, u8 bPush, const char *zFmt, ...){
** Pop the EXPLAIN QUERY PLAN stack one level.
*/
void sqlite3VdbeExplainPop(Parse *pParse){
+ sqlite3ExplainBreakpoint("POP", 0);
pParse->addrExplain = sqlite3VdbeExplainParent(pParse);
}
#endif /* SQLITE_OMIT_EXPLAIN */
@@ -410,21 +460,22 @@ void sqlite3VdbeEndCoroutine(Vdbe *v, int regYield){
** The VDBE knows that a P2 value is a label because labels are
** always negative and P2 values are suppose to be non-negative.
** Hence, a negative P2 value is a label that has yet to be resolved.
+** (Later:) This is only true for opcodes that have the OPFLG_JUMP
+** property.
**
-** Zero is returned if a malloc() fails.
+** Variable usage notes:
+**
+** Parse.aLabel[x] Stores the address that the x-th label resolves
+** into. For testing (SQLITE_DEBUG), unresolved
+** labels stores -1, but that is not required.
+** Parse.nLabelAlloc Number of slots allocated to Parse.aLabel[]
+** Parse.nLabel The *negative* of the number of labels that have
+** been issued. The negative is stored because
+** that gives a performance improvement over storing
+** the equivalent positive value.
*/
-int sqlite3VdbeMakeLabel(Vdbe *v){
- Parse *p = v->pParse;
- int i = p->nLabel++;
- assert( v->magic==VDBE_MAGIC_INIT );
- if( (i & (i-1))==0 ){
- p->aLabel = sqlite3DbReallocOrFree(p->db, p->aLabel,
- (i*2+1)*sizeof(p->aLabel[0]));
- }
- if( p->aLabel ){
- p->aLabel[i] = -1;
- }
- return ADDR(i);
+int sqlite3VdbeMakeLabel(Parse *pParse){
+ return --pParse->nLabel;
}
/*
@@ -432,18 +483,35 @@ int sqlite3VdbeMakeLabel(Vdbe *v){
** be inserted. The parameter "x" must have been obtained from
** a prior call to sqlite3VdbeMakeLabel().
*/
+static SQLITE_NOINLINE void resizeResolveLabel(Parse *p, Vdbe *v, int j){
+ int nNewSize = 10 - p->nLabel;
+ p->aLabel = sqlite3DbReallocOrFree(p->db, p->aLabel,
+ nNewSize*sizeof(p->aLabel[0]));
+ if( p->aLabel==0 ){
+ p->nLabelAlloc = 0;
+ }else{
+#ifdef SQLITE_DEBUG
+ int i;
+ for(i=p->nLabelAlloc; i<nNewSize; i++) p->aLabel[i] = -1;
+#endif
+ p->nLabelAlloc = nNewSize;
+ p->aLabel[j] = v->nOp;
+ }
+}
void sqlite3VdbeResolveLabel(Vdbe *v, int x){
Parse *p = v->pParse;
int j = ADDR(x);
assert( v->magic==VDBE_MAGIC_INIT );
- assert( j<p->nLabel );
+ assert( j<-p->nLabel );
assert( j>=0 );
- if( p->aLabel ){
#ifdef SQLITE_DEBUG
- if( p->db->flags & SQLITE_VdbeAddopTrace ){
- printf("RESOLVE LABEL %d to %d\n", x, v->nOp);
- }
+ if( p->db->flags & SQLITE_VdbeAddopTrace ){
+ printf("RESOLVE LABEL %d to %d\n", x, v->nOp);
+ }
#endif
+ if( p->nLabelAlloc + p->nLabel < 0 ){
+ resizeResolveLabel(p,v,j);
+ }else{
assert( p->aLabel[j]==(-1) ); /* Labels may only be resolved once */
p->aLabel[j] = v->nOp;
}
@@ -568,8 +636,9 @@ int sqlite3VdbeAssertMayAbort(Vdbe *v, int mayAbort){
while( (pOp = opIterNext(&sIter))!=0 ){
int opcode = pOp->opcode;
if( opcode==OP_Destroy || opcode==OP_VUpdate || opcode==OP_VRename
+ || opcode==OP_VDestroy
|| ((opcode==OP_Halt || opcode==OP_HaltIfNull)
- && ((pOp->p1&0xff)==SQLITE_CONSTRAINT && pOp->p2==OE_Abort))
+ && ((pOp->p1)!=SQLITE_OK && pOp->p2==OE_Abort))
){
hasAbort = 1;
break;
@@ -718,7 +787,7 @@ static void resolveP2Values(Vdbe *p, int *pMaxFuncArgs){
** non-jump opcodes less than SQLITE_MX_JUMP_CODE are guaranteed to
** have non-negative values for P2. */
assert( (sqlite3OpcodeProperty[pOp->opcode] & OPFLG_JUMP)!=0 );
- assert( ADDR(pOp->p2)<pParse->nLabel );
+ assert( ADDR(pOp->p2)<-pParse->nLabel );
pOp->p2 = aLabel[ADDR(pOp->p2)];
}
break;
@@ -757,7 +826,7 @@ int sqlite3VdbeCurrentAddr(Vdbe *p){
*/
#if defined(SQLITE_DEBUG) && !defined(SQLITE_TEST_REALLOC_STRESS)
void sqlite3VdbeVerifyNoMallocRequired(Vdbe *p, int N){
- assert( p->nOp + N <= p->pParse->nOpAlloc );
+ assert( p->nOp + N <= p->nOpAlloc );
}
#endif
@@ -829,7 +898,7 @@ VdbeOp *sqlite3VdbeAddOpList(
VdbeOp *pOut, *pFirst;
assert( nOp>0 );
assert( p->magic==VDBE_MAGIC_INIT );
- if( p->nOp + nOp > p->pParse->nOpAlloc && growOpArray(p, nOp) ){
+ if( p->nOp + nOp > p->nOpAlloc && growOpArray(p, nOp) ){
return 0;
}
pFirst = pOut = &p->aOp[p->nOp];
@@ -2151,19 +2220,27 @@ void sqlite3VdbeMakeReady(
** the leftover memory at the end of the opcode array. This can significantly
** reduce the amount of memory held by a prepared statement.
*/
- do {
- x.nNeeded = 0;
- p->aMem = allocSpace(&x, p->aMem, nMem*sizeof(Mem));
- p->aVar = allocSpace(&x, p->aVar, nVar*sizeof(Mem));
- p->apArg = allocSpace(&x, p->apArg, nArg*sizeof(Mem*));
- p->apCsr = allocSpace(&x, p->apCsr, nCursor*sizeof(VdbeCursor*));
+ x.nNeeded = 0;
+ p->aMem = allocSpace(&x, 0, nMem*sizeof(Mem));
+ p->aVar = allocSpace(&x, 0, nVar*sizeof(Mem));
+ p->apArg = allocSpace(&x, 0, nArg*sizeof(Mem*));
+ p->apCsr = allocSpace(&x, 0, nCursor*sizeof(VdbeCursor*));
#ifdef SQLITE_ENABLE_STMT_SCANSTATUS
- p->anExec = allocSpace(&x, p->anExec, p->nOp*sizeof(i64));
+ p->anExec = allocSpace(&x, 0, p->nOp*sizeof(i64));
#endif
- if( x.nNeeded==0 ) break;
+ if( x.nNeeded ){
x.pSpace = p->pFree = sqlite3DbMallocRawNN(db, x.nNeeded);
x.nFree = x.nNeeded;
- }while( !db->mallocFailed );
+ if( !db->mallocFailed ){
+ p->aMem = allocSpace(&x, p->aMem, nMem*sizeof(Mem));
+ p->aVar = allocSpace(&x, p->aVar, nVar*sizeof(Mem));
+ p->apArg = allocSpace(&x, p->apArg, nArg*sizeof(Mem*));
+ p->apCsr = allocSpace(&x, p->apCsr, nCursor*sizeof(VdbeCursor*));
+#ifdef SQLITE_ENABLE_STMT_SCANSTATUS
+ p->anExec = allocSpace(&x, p->anExec, p->nOp*sizeof(i64));
+#endif
+ }
+ }
p->pVList = pParse->pVList;
pParse->pVList = 0;
@@ -2855,7 +2932,7 @@ int sqlite3VdbeHalt(Vdbe *p){
}else{
db->nDeferredCons = 0;
db->nDeferredImmCons = 0;
- db->flags &= ~SQLITE_DeferFKs;
+ db->flags &= ~(u64)SQLITE_DeferFKs;
sqlite3CommitInternalChanges(db);
}
}else{
@@ -3170,6 +3247,13 @@ void sqlite3VdbeClearObject(sqlite3 *db, Vdbe *p){
sqlite3DbFree(db, p->zSql);
#ifdef SQLITE_ENABLE_NORMALIZE
sqlite3DbFree(db, p->zNormSql);
+ {
+ DblquoteStr *pThis, *pNext;
+ for(pThis=p->pDblStr; pThis; pThis=pNext){
+ pNext = pThis->pNextStr;
+ sqlite3DbFree(db, pThis);
+ }
+ }
#endif
#ifdef SQLITE_ENABLE_STMT_SCANSTATUS
{
@@ -3710,7 +3794,7 @@ void sqlite3VdbeRecordUnpack(
UnpackedRecord *p /* Populate this structure before returning. */
){
const unsigned char *aKey = (const unsigned char *)pKey;
- int d;
+ u32 d;
u32 idx; /* Offset in aKey[] to read from */
u16 u; /* Unsigned loop counter */
u32 szHdr;
@@ -3721,7 +3805,7 @@ void sqlite3VdbeRecordUnpack(
idx = getVarint32(aKey, szHdr);
d = szHdr;
u = 0;
- while( idx<szHdr && d<=nKey ){
+ while( idx<szHdr && d<=(u32)nKey ){
u32 serial_type;
idx += getVarint32(&aKey[idx], serial_type);
@@ -3734,7 +3818,7 @@ void sqlite3VdbeRecordUnpack(
pMem++;
if( (++u)>=p->nField ) break;
}
- if( d>nKey && u ){
+ if( d>(u32)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
diff --git a/chromium/third_party/sqlite/src/src/vdbemem.c b/chromium/third_party/sqlite/src/src/vdbemem.c
index 04c8f9440e9..d1abbe3d37c 100644
--- a/chromium/third_party/sqlite/src/src/vdbemem.c
+++ b/chromium/third_party/sqlite/src/src/vdbemem.c
@@ -243,7 +243,7 @@ SQLITE_NOINLINE int sqlite3VdbeMemGrow(Mem *pMem, int n, int bPreserve){
** if unable to complete the resizing.
*/
int sqlite3VdbeMemClearAndResize(Mem *pMem, int szNew){
- assert( szNew>0 );
+ assert( CORRUPT_DB || szNew>0 );
assert( (pMem->flags & MEM_Dyn)==0 || pMem->szMalloc==0 );
if( pMem->szMalloc<szNew ){
return sqlite3VdbeMemGrow(pMem, szNew, 0);
@@ -1124,6 +1124,9 @@ static SQLITE_NOINLINE int vdbeMemFromBtreeResize(
){
int rc;
pMem->flags = MEM_Null;
+ if( sqlite3BtreeMaxRecordSize(pCur)<offset+amt ){
+ return SQLITE_CORRUPT_BKPT;
+ }
if( SQLITE_OK==(rc = sqlite3VdbeMemClearAndResize(pMem, amt+1)) ){
rc = sqlite3BtreePayload(pCur, offset, amt, pMem->z);
if( rc==SQLITE_OK ){
@@ -1530,9 +1533,11 @@ static int valueFromExpr(
}
#endif
else if( op==TK_TRUEFALSE ){
- pVal = valueNew(db, pCtx);
- pVal->flags = MEM_Int;
- pVal->u.i = pExpr->u.zToken[4]==0;
+ pVal = valueNew(db, pCtx);
+ if( pVal ){
+ pVal->flags = MEM_Int;
+ pVal->u.i = pExpr->u.zToken[4]==0;
+ }
}
*ppVal = pVal;
diff --git a/chromium/third_party/sqlite/src/src/vtab.c b/chromium/third_party/sqlite/src/src/vtab.c
index 0062984b3fd..8a4d2a5cbf2 100644
--- a/chromium/third_party/sqlite/src/src/vtab.c
+++ b/chromium/third_party/sqlite/src/src/vtab.c
@@ -1001,6 +1001,7 @@ int sqlite3VtabSavepoint(sqlite3 *db, int op, int iSavepoint){
const sqlite3_module *pMod = pVTab->pMod->pModule;
if( pVTab->pVtab && pMod->iVersion>=2 ){
int (*xMethod)(sqlite3_vtab *, int);
+ sqlite3VtabLock(pVTab);
switch( op ){
case SAVEPOINT_BEGIN:
xMethod = pMod->xSavepoint;
@@ -1016,6 +1017,7 @@ int sqlite3VtabSavepoint(sqlite3 *db, int op, int iSavepoint){
if( xMethod && pVTab->iSavepoint>iSavepoint ){
rc = xMethod(pVTab->pVtab, iSavepoint);
}
+ sqlite3VtabUnlock(pVTab);
}
}
}
diff --git a/chromium/third_party/sqlite/src/src/walker.c b/chromium/third_party/sqlite/src/src/walker.c
index 3d36a8cabf9..8ddeae98c19 100644
--- a/chromium/third_party/sqlite/src/src/walker.c
+++ b/chromium/third_party/sqlite/src/src/walker.c
@@ -17,6 +17,22 @@
#include <string.h>
+#if !defined(SQLITE_OMIT_WINDOWFUNC)
+/*
+** Walk all expressions linked into the list of Window objects passed
+** as the second argument.
+*/
+static int walkWindowList(Walker *pWalker, Window *pList){
+ Window *pWin;
+ for(pWin=pList; pWin; pWin=pWin->pNextWin){
+ if( sqlite3WalkExprList(pWalker, pWin->pOrderBy) ) return WRC_Abort;
+ if( sqlite3WalkExprList(pWalker, pWin->pPartition) ) return WRC_Abort;
+ if( sqlite3WalkExpr(pWalker, pWin->pFilter) ) return WRC_Abort;
+ }
+ return WRC_Continue;
+}
+#endif
+
/*
** Walk an expression tree. Invoke the callback once for each node
** of the expression, while descending. (In other words, the callback
@@ -56,10 +72,7 @@ static SQLITE_NOINLINE int walkExpr(Walker *pWalker, Expr *pExpr){
}
#ifndef SQLITE_OMIT_WINDOWFUNC
if( ExprHasProperty(pExpr, EP_WinFunc) ){
- Window *pWin = pExpr->y.pWin;
- if( sqlite3WalkExprList(pWalker, pWin->pPartition) ) return WRC_Abort;
- if( sqlite3WalkExprList(pWalker, pWin->pOrderBy) ) return WRC_Abort;
- if( sqlite3WalkExpr(pWalker, pWin->pFilter) ) return WRC_Abort;
+ if( walkWindowList(pWalker, pExpr->y.pWin) ) return WRC_Abort;
}
#endif
}
@@ -99,6 +112,16 @@ int sqlite3WalkSelectExpr(Walker *pWalker, Select *p){
if( sqlite3WalkExpr(pWalker, p->pHaving) ) return WRC_Abort;
if( sqlite3WalkExprList(pWalker, p->pOrderBy) ) return WRC_Abort;
if( sqlite3WalkExpr(pWalker, p->pLimit) ) return WRC_Abort;
+#if !defined(SQLITE_OMIT_WINDOWFUNC) && !defined(SQLITE_OMIT_ALTERTABLE)
+ {
+ Parse *pParse = pWalker->pParse;
+ if( pParse && IN_RENAME_OBJECT ){
+ int rc = walkWindowList(pWalker, p->pWinDefn);
+ assert( rc==WRC_Continue );
+ return rc;
+ }
+ }
+#endif
return WRC_Continue;
}
diff --git a/chromium/third_party/sqlite/src/src/where.c b/chromium/third_party/sqlite/src/src/where.c
index 0a264cf14f1..5710b9518e9 100644
--- a/chromium/third_party/sqlite/src/src/where.c
+++ b/chromium/third_party/sqlite/src/src/where.c
@@ -311,6 +311,17 @@ static WhereTerm *whereScanNext(WhereScan *pScan){
}
/*
+** This is whereScanInit() for the case of an index on an expression.
+** It is factored out into a separate tail-recursion subroutine so that
+** the normal whereScanInit() routine, which is a high-runner, does not
+** need to push registers onto the stack as part of its prologue.
+*/
+static SQLITE_NOINLINE WhereTerm *whereScanInitIndexExpr(WhereScan *pScan){
+ pScan->idxaff = sqlite3ExprAffinity(pScan->pIdxExpr);
+ return whereScanNext(pScan);
+}
+
+/*
** Initialize a WHERE clause scanner object. Return a pointer to the
** first match. Return NULL if there are no matches.
**
@@ -342,12 +353,19 @@ static WhereTerm *whereScanInit(
pScan->pIdxExpr = 0;
pScan->idxaff = 0;
pScan->zCollName = 0;
+ pScan->opMask = opMask;
+ pScan->k = 0;
+ pScan->aiCur[0] = iCur;
+ pScan->nEquiv = 1;
+ pScan->iEquiv = 1;
if( pIdx ){
int j = iColumn;
iColumn = pIdx->aiColumn[j];
if( iColumn==XN_EXPR ){
pScan->pIdxExpr = pIdx->aColExpr->a[j].pExpr;
pScan->zCollName = pIdx->azColl[j];
+ pScan->aiColumn[0] = XN_EXPR;
+ return whereScanInitIndexExpr(pScan);
}else if( iColumn==pIdx->pTable->iPKey ){
iColumn = XN_ROWID;
}else if( iColumn>=0 ){
@@ -357,12 +375,7 @@ static WhereTerm *whereScanInit(
}else if( iColumn==XN_EXPR ){
return 0;
}
- pScan->opMask = opMask;
- pScan->k = 0;
- pScan->aiCur[0] = iCur;
pScan->aiColumn[0] = iColumn;
- pScan->nEquiv = 1;
- pScan->iEquiv = 1;
return whereScanNext(pScan);
}
@@ -837,7 +850,7 @@ static void constructAutomaticIndex(
addrTop = sqlite3VdbeAddOp1(v, OP_Rewind, pLevel->iTabCur); VdbeCoverage(v);
}
if( pPartial ){
- iContinue = sqlite3VdbeMakeLabel(v);
+ iContinue = sqlite3VdbeMakeLabel(pParse);
sqlite3ExprIfFalse(pParse, pPartial, iContinue, SQLITE_JUMPIFNULL);
pLoop->wsFlags |= WHERE_PARTIALIDX;
}
@@ -854,6 +867,7 @@ static void constructAutomaticIndex(
translateColumnToCopy(pParse, addrTop, pLevel->iTabCur,
pTabItem->regResult, 1);
sqlite3VdbeGoto(v, addrTop);
+ pTabItem->fg.viaCoroutine = 0;
}else{
sqlite3VdbeAddOp2(v, OP_Next, pLevel->iTabCur, addrTop+1); VdbeCoverage(v);
}
@@ -2209,7 +2223,7 @@ static int whereLoopInsert(WhereLoopBuilder *pBuilder, WhereLoop *pTemplate){
rc = whereLoopXfer(db, p, pTemplate);
if( (p->wsFlags & WHERE_VIRTUALTABLE)==0 ){
Index *pIndex = p->u.btree.pIndex;
- if( pIndex && pIndex->tnum==0 ){
+ if( pIndex && pIndex->idxType==SQLITE_IDXTYPE_IPK ){
p->u.btree.pIndex = 0;
}
}
@@ -2376,8 +2390,8 @@ static int whereRangeVectorLen(
** terms only. If it is modified, this value is restored before this
** function returns.
**
-** If pProbe->tnum==0, that means pIndex is a fake index used for the
-** INTEGER PRIMARY KEY.
+** If pProbe->idxType==SQLITE_IDXTYPE_IPK, that means pIndex is
+** a fake index used for the INTEGER PRIMARY KEY.
*/
static int whereLoopAddBtreeIndex(
WhereLoopBuilder *pBuilder, /* The WhereLoop factory */
@@ -2877,6 +2891,7 @@ static int whereLoopAddBtree(
sPk.onError = OE_Replace;
sPk.pTable = pTab;
sPk.szIdxRow = pTab->szTabRow;
+ sPk.idxType = SQLITE_IDXTYPE_IPK;
aiRowEstPk[0] = pTab->nRowLogEst;
aiRowEstPk[1] = 0;
pFirst = pSrc->pTab->pIndex;
@@ -2967,7 +2982,7 @@ static int whereLoopAddBtree(
b = indexMightHelpWithOrderBy(pBuilder, pProbe, pSrc->iCursor);
/* The ONEPASS_DESIRED flags never occurs together with ORDER BY */
assert( (pWInfo->wctrlFlags & WHERE_ONEPASS_DESIRED)==0 || b==0 );
- if( pProbe->tnum<=0 ){
+ if( pProbe->idxType==SQLITE_IDXTYPE_IPK ){
/* Integer primary key index */
pNew->wsFlags = WHERE_IPK;
@@ -4643,7 +4658,7 @@ WhereInfo *sqlite3WhereBegin(
pWInfo->pResultSet = pResultSet;
pWInfo->aiCurOnePass[0] = pWInfo->aiCurOnePass[1] = -1;
pWInfo->nLevel = nTabList;
- pWInfo->iBreak = pWInfo->iContinue = sqlite3VdbeMakeLabel(v);
+ pWInfo->iBreak = pWInfo->iContinue = sqlite3VdbeMakeLabel(pParse);
pWInfo->wctrlFlags = wctrlFlags;
pWInfo->iLimit = iAuxArg;
pWInfo->savedNQueryLoop = pParse->nQueryLoop;
@@ -4917,9 +4932,10 @@ WhereInfo *sqlite3WhereBegin(
if( (wctrlFlags & WHERE_ONEPASS_DESIRED)!=0 ){
int wsFlags = pWInfo->a[0].pWLoop->wsFlags;
int bOnerow = (wsFlags & WHERE_ONEROW)!=0;
+ assert( !(wsFlags & WHERE_VIRTUALTABLE) || IsVirtual(pTabList->a[0].pTab) );
if( bOnerow || (
0!=(wctrlFlags & WHERE_ONEPASS_MULTIROW)
- && 0==(wsFlags & WHERE_VIRTUALTABLE)
+ && !IsVirtual(pTabList->a[0].pTab)
&& (0==(wsFlags & WHERE_MULTI_OR) || (wctrlFlags & WHERE_DUPLICATES_OK))
)){
pWInfo->eOnePass = bOnerow ? ONEPASS_SINGLE : ONEPASS_MULTI;
@@ -5074,7 +5090,7 @@ WhereInfo *sqlite3WhereBegin(
pParse, pTabList, pLevel, wctrlFlags
);
pLevel->addrBody = sqlite3VdbeCurrentAddr(v);
- notReady = sqlite3WhereCodeOneLoopStart(pWInfo, ii, notReady);
+ notReady = sqlite3WhereCodeOneLoopStart(pParse,v,pWInfo,ii,pLevel,notReady);
pWInfo->iContinue = pLevel->addrCont;
if( (wsFlags&WHERE_MULTI_OR)==0 && (wctrlFlags&WHERE_OR_SUBCLAUSE)==0 ){
sqlite3WhereAddScanStatus(v, pTabList, pLevel, addrExplain);
@@ -5259,6 +5275,29 @@ void sqlite3WhereEnd(WhereInfo *pWInfo){
continue;
}
+#ifdef SQLITE_ENABLE_EARLY_CURSOR_CLOSE
+ /* Close all of the cursors that were opened by sqlite3WhereBegin.
+ ** Except, do not close cursors that will be reused by the OR optimization
+ ** (WHERE_OR_SUBCLAUSE). And do not close the OP_OpenWrite cursors
+ ** created for the ONEPASS optimization.
+ */
+ if( (pTab->tabFlags & TF_Ephemeral)==0
+ && pTab->pSelect==0
+ && (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)==0
+ ){
+ int ws = pLoop->wsFlags;
+ if( pWInfo->eOnePass==ONEPASS_OFF && (ws & WHERE_IDX_ONLY)==0 ){
+ sqlite3VdbeAddOp1(v, OP_Close, pTabItem->iCursor);
+ }
+ if( (ws & WHERE_INDEXED)!=0
+ && (ws & (WHERE_IPK|WHERE_AUTO_INDEX))==0
+ && pLevel->iIdxCur!=pWInfo->aiCurOnePass[1]
+ ){
+ sqlite3VdbeAddOp1(v, OP_Close, pLevel->iIdxCur);
+ }
+ }
+#endif
+
/* If this scan uses an index, make VDBE code substitutions to read data
** from the index instead of from the table where possible. In some cases
** this optimization prevents the table from ever being read, which can
diff --git a/chromium/third_party/sqlite/src/src/whereInt.h b/chromium/third_party/sqlite/src/src/whereInt.h
index 6925e39e1d2..07461a5bac3 100644
--- a/chromium/third_party/sqlite/src/src/whereInt.h
+++ b/chromium/third_party/sqlite/src/src/whereInt.h
@@ -507,8 +507,11 @@ void sqlite3WhereAddScanStatus(
# define sqlite3WhereAddScanStatus(a, b, c, d) ((void)d)
#endif
Bitmask sqlite3WhereCodeOneLoopStart(
+ Parse *pParse, /* Parsing context */
+ Vdbe *v, /* Prepared statement under construction */
WhereInfo *pWInfo, /* Complete information about the WHERE clause */
int iLevel, /* Which level of pWInfo->a[] should be coded */
+ WhereLevel *pLevel, /* The current level pointer */
Bitmask notReady /* Which tables are currently available */
);
diff --git a/chromium/third_party/sqlite/src/src/wherecode.c b/chromium/third_party/sqlite/src/src/wherecode.c
index bbd738b8edd..7a0547d348d 100644
--- a/chromium/third_party/sqlite/src/src/wherecode.c
+++ b/chromium/third_party/sqlite/src/src/wherecode.c
@@ -213,6 +213,7 @@ int sqlite3WhereExplainOneScan(
}
#endif
zMsg = sqlite3StrAccumFinish(&str);
+ sqlite3ExplainBreakpoint("",zMsg);
ret = sqlite3VdbeAddOp4(v, OP_Explain, sqlite3VdbeCurrentAddr(v),
pParse->addrExplain, 0, zMsg,P4_DYNAMIC);
}
@@ -538,16 +539,17 @@ static int codeEqualityTerm(
if( pLoop->aLTerm[i]->pExpr==pX ) nEq++;
}
+ iTab = 0;
if( (pX->flags & EP_xIsSelect)==0 || pX->x.pSelect->pEList->nExpr==1 ){
- eType = sqlite3FindInIndex(pParse, pX, IN_INDEX_LOOP, 0, 0);
+ eType = sqlite3FindInIndex(pParse, pX, IN_INDEX_LOOP, 0, 0, &iTab);
}else{
sqlite3 *db = pParse->db;
pX = removeUnindexableInClauseTerms(pParse, iEq, pLoop, pX);
if( !db->mallocFailed ){
aiMap = (int*)sqlite3DbMallocZero(pParse->db, sizeof(int)*nEq);
- eType = sqlite3FindInIndex(pParse, pX, IN_INDEX_LOOP, 0, aiMap);
- pTerm->pExpr->iTable = pX->iTable;
+ eType = sqlite3FindInIndex(pParse, pX, IN_INDEX_LOOP, 0, aiMap, &iTab);
+ pTerm->pExpr->iTable = iTab;
}
sqlite3ExprDelete(db, pX);
pX = pTerm->pExpr;
@@ -557,7 +559,6 @@ static int codeEqualityTerm(
testcase( bRev );
bRev = !bRev;
}
- iTab = pX->iTable;
sqlite3VdbeAddOp2(v, bRev ? OP_Last : OP_Rewind, iTab, 0);
VdbeCoverageIf(v, bRev);
VdbeCoverageIf(v, !bRev);
@@ -565,7 +566,7 @@ static int codeEqualityTerm(
pLoop->wsFlags |= WHERE_IN_ABLE;
if( pLevel->u.in.nIn==0 ){
- pLevel->addrNxt = sqlite3VdbeMakeLabel(v);
+ pLevel->addrNxt = sqlite3VdbeMakeLabel(pParse);
}
i = pLevel->u.in.nIn;
@@ -1076,7 +1077,9 @@ static void codeExprOrVector(Parse *pParse, Expr *p, int iReg, int nReg){
#ifndef SQLITE_OMIT_SUBQUERY
if( (p->flags & EP_xIsSelect) ){
Vdbe *v = pParse->pVdbe;
- int iSelect = sqlite3CodeSubselect(pParse, p, 0, 0);
+ int iSelect;
+ assert( p->op==TK_SELECT );
+ iSelect = sqlite3CodeSubselect(pParse, p);
sqlite3VdbeAddOp3(v, OP_Copy, iSelect, iReg, nReg-1);
}else
#endif
@@ -1162,22 +1165,21 @@ static void whereIndexExprTrans(
** implementation described by pWInfo.
*/
Bitmask sqlite3WhereCodeOneLoopStart(
+ Parse *pParse, /* Parsing context */
+ Vdbe *v, /* Prepared statement under construction */
WhereInfo *pWInfo, /* Complete information about the WHERE clause */
int iLevel, /* Which level of pWInfo->a[] should be coded */
+ WhereLevel *pLevel, /* The current level pointer */
Bitmask notReady /* Which tables are currently available */
){
int j, k; /* Loop counters */
int iCur; /* The VDBE cursor for the table */
int addrNxt; /* Where to jump to continue with the next IN case */
- int omitTable; /* True if we use the index only */
int bRev; /* True if we need to scan in reverse order */
- WhereLevel *pLevel; /* The where level to be coded */
WhereLoop *pLoop; /* The WhereLoop object being coded */
WhereClause *pWC; /* Decomposition of the entire WHERE clause */
WhereTerm *pTerm; /* A WHERE clause term */
- Parse *pParse; /* Parsing context */
sqlite3 *db; /* Database connection */
- Vdbe *v; /* The prepared stmt under constructions */
struct SrcList_item *pTabItem; /* FROM clause term being coded */
int addrBrk; /* Jump here to break out of the loop */
int addrHalt; /* addrBrk for the outermost loop */
@@ -1187,18 +1189,13 @@ Bitmask sqlite3WhereCodeOneLoopStart(
Index *pIdx = 0; /* Index used by loop (if any) */
int iLoop; /* Iteration of constraint generator loop */
- pParse = pWInfo->pParse;
- v = pParse->pVdbe;
pWC = &pWInfo->sWC;
db = pParse->db;
- pLevel = &pWInfo->a[iLevel];
pLoop = pLevel->pWLoop;
pTabItem = &pWInfo->pTabList->a[pLevel->iFrom];
iCur = pTabItem->iCursor;
pLevel->notReady = notReady & ~sqlite3WhereGetMask(&pWInfo->sMaskSet, iCur);
bRev = (pWInfo->revMask>>iLevel)&1;
- omitTable = (pLoop->wsFlags & WHERE_IDX_ONLY)!=0
- && (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)==0;
VdbeModuleComment((v, "Begin WHERE-loop%d: %s",iLevel,pTabItem->pTab->zName));
/* Create labels for the "break" and "continue" instructions
@@ -1211,8 +1208,8 @@ Bitmask sqlite3WhereCodeOneLoopStart(
** there are no IN operators in the constraints, the "addrNxt" label
** is the same as "addrBrk".
*/
- addrBrk = pLevel->addrBrk = pLevel->addrNxt = sqlite3VdbeMakeLabel(v);
- addrCont = pLevel->addrCont = sqlite3VdbeMakeLabel(v);
+ addrBrk = pLevel->addrBrk = pLevel->addrNxt = sqlite3VdbeMakeLabel(pParse);
+ addrCont = pLevel->addrCont = sqlite3VdbeMakeLabel(pParse);
/* If this is the right table of a LEFT OUTER JOIN, allocate and
** initialize a memory cell that records if this table matches any
@@ -1339,7 +1336,6 @@ Bitmask sqlite3WhereCodeOneLoopStart(
pTerm = pLoop->aLTerm[0];
assert( pTerm!=0 );
assert( pTerm->pExpr!=0 );
- assert( omitTable==0 );
testcase( pTerm->wtFlags & TERM_VIRTUAL );
iReleaseReg = ++pParse->nMem;
iRowidReg = codeEqualityTerm(pParse, pTerm, pLevel, 0, bRev, iReleaseReg);
@@ -1358,7 +1354,6 @@ Bitmask sqlite3WhereCodeOneLoopStart(
int memEndValue = 0;
WhereTerm *pStart, *pEnd;
- assert( omitTable==0 );
j = 0;
pStart = pEnd = 0;
if( pLoop->wsFlags & WHERE_BTM_LIMIT ) pStart = pLoop->aLTerm[j++];
@@ -1522,6 +1517,8 @@ Bitmask sqlite3WhereCodeOneLoopStart(
char *zEndAff = 0; /* Affinity for end of range constraint */
u8 bSeekPastNull = 0; /* True to seek past initial nulls */
u8 bStopAtNull = 0; /* Add condition to terminate at NULLs */
+ int omitTable; /* True if we use the index only */
+
pIdx = pLoop->u.btree.pIndex;
iIdxCur = pLevel->iIdxCur;
@@ -1723,6 +1720,8 @@ Bitmask sqlite3WhereCodeOneLoopStart(
}
/* Seek the table cursor, if required */
+ omitTable = (pLoop->wsFlags & WHERE_IDX_ONLY)!=0
+ && (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)==0;
if( omitTable ){
/* pIdx is a covering index. No need to access the main table. */
}else if( HasRowid(pIdx->pTable) ){
@@ -1757,8 +1756,13 @@ Bitmask sqlite3WhereCodeOneLoopStart(
** the cursor. In this case it is important to do the full evaluation,
** as the result of the expression may not be NULL, even if all table
** column values are. https://www.sqlite.org/src/info/7fa8049685b50b5a
+ **
+ ** Also, do not do this when processing one index an a multi-index
+ ** OR clause, since the transformation will become invalid once we
+ ** move forward to the next index.
+ ** https://sqlite.org/src/info/4e8e4857d32d401f
*/
- if( pLevel->iLeftJoin==0 ){
+ if( pLevel->iLeftJoin==0 && (pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE)==0 ){
whereIndexExprTrans(pIdx, iCur, iIdxCur, pWInfo);
}
@@ -1833,7 +1837,7 @@ Bitmask sqlite3WhereCodeOneLoopStart(
int regReturn = ++pParse->nMem; /* Register used with OP_Gosub */
int regRowset = 0; /* Register for RowSet object */
int regRowid = 0; /* Register holding rowid */
- int iLoopBody = sqlite3VdbeMakeLabel(v); /* Start of loop body */
+ int iLoopBody = sqlite3VdbeMakeLabel(pParse);/* Start of loop body */
int iRetInit; /* Address of regReturn init */
int untestedTerms = 0; /* Some terms not completely tested */
int ii; /* Loop counter */
@@ -1949,6 +1953,7 @@ Bitmask sqlite3WhereCodeOneLoopStart(
pOrExpr = pAndExpr;
}
/* Loop through table entries that match term pOrTerm. */
+ ExplainQueryPlan((pParse, 1, "INDEX %d", ii+1));
WHERETRACE(0xffff, ("Subplan for OR-clause:\n"));
pSubWInfo = sqlite3WhereBegin(pParse, pOrTab, pOrExpr, 0, 0,
wctrlFlags, iCovCur);
@@ -2052,6 +2057,7 @@ Bitmask sqlite3WhereCodeOneLoopStart(
/* Finish the loop through table entries that match term pOrTerm. */
sqlite3WhereEnd(pSubWInfo);
+ ExplainQueryPlanPop(pParse);
}
}
}
diff --git a/chromium/third_party/sqlite/src/src/whereexpr.c b/chromium/third_party/sqlite/src/src/whereexpr.c
index e91f1d72165..db5500cce7a 100644
--- a/chromium/third_party/sqlite/src/src/whereexpr.c
+++ b/chromium/third_party/sqlite/src/src/whereexpr.c
@@ -777,6 +777,7 @@ static void exprAnalyzeOrTerm(
** and column is found but leave okToChngToIN false if not found.
*/
for(j=0; j<2 && !okToChngToIN; j++){
+ Expr *pLeft = 0;
pOrTerm = pOrWc->a;
for(i=pOrWc->nTerm-1; i>=0; i--, pOrTerm++){
assert( pOrTerm->eOperator & WO_EQ );
@@ -800,6 +801,7 @@ static void exprAnalyzeOrTerm(
}
iColumn = pOrTerm->u.leftColumn;
iCursor = pOrTerm->leftCursor;
+ pLeft = pOrTerm->pExpr->pLeft;
break;
}
if( i<0 ){
@@ -819,7 +821,9 @@ static void exprAnalyzeOrTerm(
assert( pOrTerm->eOperator & WO_EQ );
if( pOrTerm->leftCursor!=iCursor ){
pOrTerm->wtFlags &= ~TERM_OR_OK;
- }else if( pOrTerm->u.leftColumn!=iColumn ){
+ }else if( pOrTerm->u.leftColumn!=iColumn || (iColumn==XN_EXPR
+ && sqlite3ExprCompare(pParse, pOrTerm->pExpr->pLeft, pLeft, -1)
+ )){
okToChngToIN = 0;
}else{
int affLeft, affRight;
diff --git a/chromium/third_party/sqlite/src/src/window.c b/chromium/third_party/sqlite/src/src/window.c
index ec3d55cef7e..11b7afed2cd 100644
--- a/chromium/third_party/sqlite/src/src/window.c
+++ b/chromium/third_party/sqlite/src/src/window.c
@@ -823,8 +823,7 @@ int sqlite3WindowRewrite(Parse *pParse, Select *p){
pSub = sqlite3SelectNew(
pParse, pSublist, pSrc, pWhere, pGroupBy, pHaving, pSort, 0, 0
);
- p->pSrc = sqlite3SrcListAppend(db, 0, 0, 0);
- assert( p->pSrc || db->mallocFailed );
+ p->pSrc = sqlite3SrcListAppend(pParse, 0, 0, 0);
if( p->pSrc ){
p->pSrc->a[0].pSelect = pSub;
sqlite3SrcListAssignCursors(pParse, p->pSrc);
@@ -881,6 +880,7 @@ void sqlite3WindowListDelete(sqlite3 *db, Window *p){
*/
static Expr *sqlite3WindowOffsetExpr(Parse *pParse, Expr *pExpr){
if( 0==sqlite3ExprIsConstant(pExpr) ){
+ if( IN_RENAME_OBJECT ) sqlite3RenameExprUnmap(pParse, pExpr);
sqlite3ExprDelete(pParse->db, pExpr);
pExpr = sqlite3ExprAlloc(pParse->db, TK_NULL, 0, 0);
}
@@ -1075,6 +1075,7 @@ static void windowCheckIntValue(Parse *pParse, int reg, int eCond){
VdbeCoverageNeverNullIf(v, eCond==0);
VdbeCoverageNeverNullIf(v, eCond==1);
VdbeCoverageNeverNullIf(v, eCond==2);
+ sqlite3MayAbort(pParse);
sqlite3VdbeAddOp2(v, OP_Halt, SQLITE_ERROR, OE_Abort);
sqlite3VdbeAppendP4(v, (void*)azErr[eCond], P4_STATIC);
sqlite3ReleaseTempReg(pParse, regZero);
@@ -1330,7 +1331,7 @@ static void windowReturnOneRow(
|| pFunc->zName==first_valueName
){
int csr = pWin->csrApp;
- int lbl = sqlite3VdbeMakeLabel(v);
+ int lbl = sqlite3VdbeMakeLabel(pParse);
int tmpReg = sqlite3GetTempReg(pParse);
sqlite3VdbeAddOp2(v, OP_Null, 0, pWin->regResult);
@@ -1353,7 +1354,7 @@ static void windowReturnOneRow(
int nArg = pWin->pOwner->x.pList->nExpr;
int iEph = pMWin->iEphCsr;
int csr = pWin->csrApp;
- int lbl = sqlite3VdbeMakeLabel(v);
+ int lbl = sqlite3VdbeMakeLabel(pParse);
int tmpReg = sqlite3GetTempReg(pParse);
if( nArg<3 ){
@@ -1614,8 +1615,8 @@ static void windowCodeRowExprStep(
/* Allocate register and label for the "flush_partition" sub-routine. */
regFlushPart = ++pParse->nMem;
- lblFlushPart = sqlite3VdbeMakeLabel(v);
- lblFlushDone = sqlite3VdbeMakeLabel(v);
+ lblFlushPart = sqlite3VdbeMakeLabel(pParse);
+ lblFlushDone = sqlite3VdbeMakeLabel(pParse);
regStart = ++pParse->nMem;
regEnd = ++pParse->nMem;
@@ -1725,7 +1726,7 @@ static void windowCodeRowExprStep(
|| pMWin->eStart==TK_PRECEDING
|| pMWin->eStart==TK_FOLLOWING
){
- int lblSkipInverse = sqlite3VdbeMakeLabel(v);;
+ int lblSkipInverse = sqlite3VdbeMakeLabel(pParse);;
if( pMWin->eStart==TK_PRECEDING ){
sqlite3VdbeAddOp3(v, OP_IfPos, regStart, lblSkipInverse, 1);
VdbeCoverage(v);
@@ -1890,13 +1891,13 @@ static void windowCodeCacheStep(
|| (pMWin->eStart==TK_CURRENT && pMWin->eEnd==TK_UNBOUNDED)
);
- lblEmpty = sqlite3VdbeMakeLabel(v);
+ lblEmpty = sqlite3VdbeMakeLabel(pParse);
regNewPeer = pParse->nMem+1;
pParse->nMem += nPeer;
/* Allocate register and label for the "flush_partition" sub-routine. */
regFlushPart = ++pParse->nMem;
- lblFlushPart = sqlite3VdbeMakeLabel(v);
+ lblFlushPart = sqlite3VdbeMakeLabel(pParse);
csrLead = pParse->nTab++;
regCtr = ++pParse->nMem;
@@ -2133,6 +2134,7 @@ Window *sqlite3WindowDup(sqlite3 *db, Expr *pOwner, Window *p){
if( pNew ){
pNew->zName = sqlite3DbStrDup(db, p->zName);
pNew->pFilter = sqlite3ExprDup(db, p->pFilter, 0);
+ pNew->pFunc = p->pFunc;
pNew->pPartition = sqlite3ExprListDup(db, p->pPartition, 0);
pNew->pOrderBy = sqlite3ExprListDup(db, p->pOrderBy, 0);
pNew->eType = p->eType;
diff --git a/chromium/third_party/sqlite/src/tool/dbtotxt.c b/chromium/third_party/sqlite/src/tool/dbtotxt.c
new file mode 100644
index 00000000000..da9abf9ebd4
--- /dev/null
+++ b/chromium/third_party/sqlite/src/tool/dbtotxt.c
@@ -0,0 +1,146 @@
+/*
+** Copyright 2008 D. Richard Hipp and Hipp, Wyrick & Company, Inc.
+** All Rights Reserved
+**
+******************************************************************************
+**
+** This file implements a stand-alone utility program that converts
+** a binary file (usually an SQLite database) into a text format that
+** is compact and friendly to human-readers.
+**
+** Usage:
+**
+** dbtotxt [--pagesize N] FILENAME
+**
+** The translation of the database appears on standard output. If the
+** --pagesize command-line option is omitted, then the page size is taken
+** from the database header.
+**
+** Compactness is achieved by suppressing lines of all zero bytes. This
+** works well at compressing test databases that are mostly empty. But
+** the output will probably be lengthy for a real database containing lots
+** of real content. For maximum compactness, it is suggested that test
+** databases be constructed with "zeroblob()" rather than "randomblob()"
+** used for filler content and with "PRAGMA secure_delete=ON" selected to
+** zero-out deleted content.
+*/
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <ctype.h>
+
+/* Return true if the line is all zeros */
+static int allZero(unsigned char *aLine){
+ int i;
+ for(i=0; i<16 && aLine[i]==0; i++){}
+ return i==16;
+}
+
+int main(int argc, char **argv){
+ int pgsz = 0; /* page size */
+ long szFile; /* Size of the input file in bytes */
+ FILE *in; /* Input file */
+ int i, j; /* Loop counters */
+ int nErr = 0; /* Number of errors */
+ const char *zInputFile = 0; /* Name of the input file */
+ const char *zBaseName = 0; /* Base name of the file */
+ int lastPage = 0; /* Last page number shown */
+ int iPage; /* Current page number */
+ unsigned char aLine[16]; /* A single line of the file */
+ unsigned char aHdr[100]; /* File header */
+ unsigned char bShow[256]; /* Characters ok to display */
+ memset(bShow, '.', sizeof(bShow));
+ for(i=' '; i<='~'; i++){
+ if( i!='{' && i!='}' && i!='"' && i!='\\' ) bShow[i] = i;
+ }
+ for(i=1; i<argc; i++){
+ if( argv[i][0]=='-' ){
+ const char *z = argv[i];
+ z++;
+ if( z[0]=='-' ) z++;
+ if( strcmp(z,"pagesize")==0 ){
+ i++;
+ pgsz = atoi(argv[i]);
+ if( pgsz<512 || pgsz>65536 || (pgsz&(pgsz-1))!=0 ){
+ fprintf(stderr, "Page size must be a power of two between"
+ " 512 and 65536.\n");
+ nErr++;
+ }
+ continue;
+ }
+ fprintf(stderr, "Unknown option: %s\n", argv[i]);
+ nErr++;
+ }else if( zInputFile ){
+ fprintf(stderr, "Already using a different input file: [%s]\n", argv[i]);
+ nErr++;
+ }else{
+ zInputFile = argv[i];
+ }
+ }
+ if( zInputFile==0 ){
+ fprintf(stderr, "No input file specified.\n");
+ nErr++;
+ }
+ if( nErr ){
+ fprintf(stderr, "Usage: %s [--pagesize N] FILENAME\n", argv[0]);
+ exit(1);
+ }
+ in = fopen(zInputFile, "rb");
+ if( in==0 ){
+ fprintf(stderr, "Cannot open input file [%s]\n", zInputFile);
+ exit(1);
+ }
+ fseek(in, 0, SEEK_END);
+ szFile = ftell(in);
+ rewind(in);
+ if( szFile<100 ){
+ fprintf(stderr, "File too short. Minimum size is 100 bytes.\n");
+ exit(1);
+ }
+ if( fread(aHdr, 100, 1, in)!=1 ){
+ fprintf(stderr, "Cannot read file header\n");
+ exit(1);
+ }
+ rewind(in);
+ if( pgsz==0 ){
+ pgsz = (aHdr[16]<<8) | aHdr[17];
+ if( pgsz==1 ) pgsz = 65536;
+ if( pgsz<512 || (pgsz&(pgsz-1))!=0 ){
+ fprintf(stderr, "Invalid page size in header: %d\n", pgsz);
+ exit(1);
+ }
+ }
+ zBaseName = zInputFile;
+ for(i=0; zInputFile[i]; i++){
+ if( zInputFile[i]=='/' && zInputFile[i+1]!=0 ) zBaseName = zInputFile+i+1;
+ }
+ printf("| size %d pagesize %d filename %s\n",(int)szFile,pgsz,zBaseName);
+ for(i=0; i<szFile; i+=16){
+ int got = (int)fread(aLine, 1, 16, in);
+ if( got!=16 ){
+ static int once = 1;
+ if( once ){
+ fprintf(stderr, "Could not read input file starting at byte %d\n",
+ i+got);
+ }
+ memset(aLine+got, 0, 16-got);
+ }
+ if( allZero(aLine) ) continue;
+ iPage = i/pgsz + 1;
+ if( lastPage!=iPage ){
+ printf("| page %d offset %d\n", iPage, (iPage-1)*pgsz);
+ lastPage = iPage;
+ }
+ printf("| %5d:", i-(iPage-1)*pgsz);
+ for(j=0; j<16; j++) printf(" %02x", aLine[j]);
+ printf(" ");
+ for(j=0; j<16; j++){
+ unsigned char c = (unsigned char)aLine[j];
+ fputc( bShow[c], stdout);
+ }
+ fputc('\n', stdout);
+ }
+ fclose(in);
+ printf("| end %s\n", zBaseName);
+ return 0;
+}
diff --git a/chromium/third_party/sqlite/src/tool/dbtotxt.md b/chromium/third_party/sqlite/src/tool/dbtotxt.md
new file mode 100644
index 00000000000..c755843d120
--- /dev/null
+++ b/chromium/third_party/sqlite/src/tool/dbtotxt.md
@@ -0,0 +1,56 @@
+<h1 align="center">The dbtotxt Tool</h1>
+
+The dbtotxt utility program reads an SQLite database file and writes its
+raw binary content to screen as a hex dump for testing and debugging
+purposes.
+
+The hex-dump output is formatted in such a way as to be easily readable
+both by humans and by software. The dbtotxt utility has long been a part
+of the TH3 test suite. The output of dbtotxt can be embedded in TH3 test
+scripts and used to generate very specific database files, perhaps with
+deliberately introduced corruption. The cov1/corrupt*.test modules in
+TH3 make extensive use of dbtotxt.
+
+More recently (2018-12-13) the dbtotxt utility has been added to the SQLite
+core and the command-line shell (CLI) has been augmented to be able to read
+dbtotxt output. The CLI dot-command is:
+
+> .open --hexdb ?OPTIONAL-FILENAME?
+
+If the OPTIONAL-FILENAME is included, then content is read from that file.
+If OPTIONAL-FILENAME is omitted, then the text is taken from the input stream,
+terminated by the "| end" line of the dbtotxt text. This allows small test
+databases to be embedded directly in scripts. Consider this example:
+
+>
+ .open --hexdb
+ | size 8192 pagesize 4096 filename x9.db
+ | page 1 offset 0
+ | 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3.
+ | 16: 10 00 01 01 00 40 20 20 00 00 00 04 00 00 00 02 .....@ ........
+ | 32: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 04 ................
+ | 48: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 ................
+ | 80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04 ................
+ | 96: 00 2e 30 38 0d 00 00 00 01 0f c0 00 0f c0 00 00 ..08............
+ | 4032: 3e 01 06 17 11 11 01 69 74 61 62 6c 65 74 31 74 >......itablet1t
+ | 4048: 31 02 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 1.CREATE TABLE t
+ | 4064: 31 28 78 2c 79 20 44 45 46 41 55 4c 54 20 78 27 1(x,y DEFAULT x'
+ | 4080: 66 66 27 2c 7a 20 44 45 46 41 55 4c 54 20 30 29 ff',z DEFAULT 0)
+ | page 2 offset 4096
+ | 0: 0d 08 14 00 04 00 10 00 0e 05 0a 0f 04 15 00 10 ................
+ | 16: 88 02 03 05 90 04 0e 08 00 00 00 00 00 00 00 00 ................
+ | 1040: 00 00 00 00 ff 87 7c 02 05 8f 78 0e 08 00 00 00 ......|...x.....
+ | 2064: 00 00 00 ff 0c 0a 01 fb 00 00 00 00 00 00 00 00 ................
+ | 2560: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 83 ................
+ | 2576: 78 01 05 87 70 0e 08 00 00 00 00 00 00 00 00 00 x...p...........
+ | 3072: 00 00 00 00 00 00 00 00 00 ff 00 00 01 fb 00 00 ................
+ | 3584: 00 00 00 00 00 83 78 00 05 87 70 0e 08 00 00 00 ......x...p.....
+ | 4080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ff ................
+ | end x9.db
+ SELECT rowid FROM t1;
+ PRAGMA integrity_check;
+
+You can run this script to see that the database file is correctly decoded
+and loaded. Furthermore, you can make subtle corruptions to the input
+database simply by editing the hexadecimal description, then rerun the
+script to verify that SQLite correctly handles the corruption.
diff --git a/chromium/third_party/sqlite/src/tool/index_usage.c b/chromium/third_party/sqlite/src/tool/index_usage.c
new file mode 100644
index 00000000000..7ec5fc1b443
--- /dev/null
+++ b/chromium/third_party/sqlite/src/tool/index_usage.c
@@ -0,0 +1,233 @@
+/*
+** 2018-12-04
+**
+** The author disclaims copyright to this source code. In place of
+** a legal notice, here is a blessing:
+**
+** May you do good and not evil.
+** May you find forgiveness for yourself and forgive others.
+** May you share freely, never taking more than you give.
+**
+*************************************************************************
+**
+** This file implements a utility program used to help determine which
+** indexes in a database schema are used and unused, and how often specific
+** indexes are used.
+*/
+#include "sqlite3.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+#include <string.h>
+
+static void usage(const char *argv0){
+ printf("Usage: %s [OPTIONS] DATABASE LOG\n\n", argv0);
+ printf(
+ "DATABASE is an SQLite database against which various statements\n"
+ "have been run. The SQL text is stored in LOG. LOG is an SQLite\n"
+ "database with this schema:\n"
+ "\n"
+ " CREATE TABLE sqllog(sql TEXT);\n"
+ "\n"
+ "This utility program analyzes statements contained in LOG and prints\n"
+ "a report showing how many times each index in DATABASE is used by the\n"
+ "statements in LOG.\n"
+ "\n"
+ "DATABASE only needs to contain the schema used by the statements in\n"
+ "LOG. The content can be removed from DATABASE.\n"
+ );
+ printf(
+ "\nOPTIONS:\n\n"
+ " --progress N Show a progress message after every N input rows\n"
+ " -q Omit error message when parsing log entries\n"
+ " --using NAME Print SQL statements that use index NAME\n"
+ );
+ printf("\nAnalysis will be done by SQLite version %s dated %.20s\n"
+ "checkin number %.40s. Different versions\n"
+ "of SQLite might use different indexes.\n",
+ sqlite3_libversion(), sqlite3_sourceid(), sqlite3_sourceid()+21);
+ exit(1);
+}
+
+int main(int argc, char **argv){
+ sqlite3 *db = 0; /* The main database */
+ sqlite3_stmt *pStmt = 0; /* a query */
+ char *zSql;
+ int nErr = 0;
+ int rc;
+ int bQuiet = 0;
+ int i, j;
+ const char *zUsing = 0;
+ sqlite3_stmt *pIncrCnt = 0;
+ int nRow = 0;
+ int iProgress = 0;
+
+ for(i=j=1; i<argc; i++){
+ const char *z = argv[i];
+ if( z[0]=='-' ){
+ z++;
+ if( z[0]=='-' ) z++;
+ if( strcmp(z,"progress")==0 ){
+ if( i+1<argc ){
+ iProgress = strtol(argv[++i],0,0);
+ continue;
+ }
+ printf("The --progress option requires an argument\n");
+ exit(0);
+ }
+ if( strcmp(z,"q")==0 ){
+ bQuiet = 1;
+ continue;
+ }
+ if( strcmp(z,"using")==0 ){
+ if( i+1<argc ){
+ zUsing = argv[++i];
+ continue;
+ }
+ printf("The --using option requires an argument\n");
+ exit(0);
+ }
+ if( strcmp(z, "help")==0 || strcmp(z, "?")==0 ){
+ usage(argv[0]);
+ }
+ printf("Unknown command-line option: \"%s\"\n", argv[i]);
+ exit(0);
+ }else{
+ if( j<i ) argv[j++] = argv[i];
+ }
+ }
+ argc = j;
+
+ if( argc!=3 ) usage(argv[0]);
+ rc = sqlite3_open_v2(argv[1], &db, SQLITE_OPEN_READONLY, 0);
+ if( rc ){
+ printf("Cannot open \"%s\" for reading: %s\n", argv[1], sqlite3_errmsg(db));
+ goto errorOut;
+ }
+ rc = sqlite3_prepare_v2(db, "SELECT * FROM sqlite_master", -1, &pStmt, 0);
+ if( rc ){
+ printf("Cannot read the schema from \"%s\" - %s\n", argv[1],
+ sqlite3_errmsg(db));
+ goto errorOut;
+ }
+ sqlite3_finalize(pStmt);
+ pStmt = 0;
+ rc = sqlite3_exec(db,
+ "CREATE TABLE temp.idxu(\n"
+ " tbl TEXT COLLATE nocase,\n"
+ " idx TEXT COLLATE nocase,\n"
+ " cnt INT,\n"
+ " PRIMARY KEY(idx)\n"
+ ") WITHOUT ROWID;", 0, 0, 0);
+ if( rc ){
+ printf("Cannot create the result table - %s\n",
+ sqlite3_errmsg(db));
+ goto errorOut;
+ }
+ rc = sqlite3_exec(db,
+ "INSERT INTO temp.idxu(tbl,idx,cnt)"
+ " SELECT tbl_name, name, 0 FROM sqlite_master"
+ " WHERE type='index' AND sql IS NOT NULL", 0, 0, 0);
+
+ /* Open the LOG database */
+ zSql = sqlite3_mprintf("ATTACH %Q AS log", argv[2]);
+ rc = sqlite3_exec(db, zSql, 0, 0, 0);
+ sqlite3_free(zSql);
+ if( rc ){
+ printf("Cannot open the LOG database \"%s\" - %s\n",
+ argv[2], sqlite3_errmsg(db));
+ goto errorOut;
+ }
+ rc = sqlite3_prepare_v2(db,
+ "SELECT sql, rowid FROM log.sqllog"
+ " WHERE upper(substr(sql,1,5)) NOT IN ('BEGIN','COMMI','ROLLB','PRAGM')",
+ -1, &pStmt, 0);
+ if( rc ){
+ printf("Cannot read the SQLLOG table in the LOG database \"%s\" - %s\n",
+ argv[2], sqlite3_errmsg(db));
+ goto errorOut;
+ }
+
+ rc = sqlite3_prepare_v2(db,
+ "UPDATE temp.idxu SET cnt=cnt+1 WHERE idx=?1",
+ -1, &pIncrCnt, 0);
+ if( rc ){
+ printf("Cannot prepare a statement to increment a counter for "
+ "indexes used\n");
+ goto errorOut;
+ }
+
+ /* Update the counts based on LOG */
+ while( sqlite3_step(pStmt)==SQLITE_ROW ){
+ const char *zLog = (const char*)sqlite3_column_text(pStmt, 0);
+ sqlite3_stmt *pS2;
+ if( zLog==0 ) continue;
+ zSql = sqlite3_mprintf("EXPLAIN QUERY PLAN %s", zLog);
+ rc = sqlite3_prepare_v2(db, zSql, -1, &pS2, 0);
+ sqlite3_free(zSql);
+ if( rc ){
+ if( !bQuiet ){
+ printf("Cannot compile LOG entry %d (%s): %s\n",
+ sqlite3_column_int(pStmt, 1), zLog, sqlite3_errmsg(db));
+ fflush(stdout);
+ }
+ nErr++;
+ }else{
+ nRow++;
+ if( iProgress>0 && (nRow%iProgress)==0 ){
+ printf("%d...\n", nRow);
+ fflush(stdout);
+ }
+ while( sqlite3_step(pS2)==SQLITE_ROW ){
+ const char *zExplain = (const char*)sqlite3_column_text(pS2,3);
+ const char *z1, *z2;
+ int n;
+ /* printf("EXPLAIN: %s\n", zExplain); */
+ z1 = strstr(zExplain, " USING INDEX ");
+ if( z1==0 ) continue;
+ z1 += 13;
+ for(z2=z1+1; z2[0] && z2[1]!='('; z2++){}
+ n = z2 - z1;
+ if( zUsing && sqlite3_strnicmp(zUsing, z1, n)==0 ){
+ printf("Using %s:\n%s\n", zUsing, zLog);
+ fflush(stdout);
+ }
+ sqlite3_bind_text(pIncrCnt,1,z1,n,SQLITE_STATIC);
+ sqlite3_step(pIncrCnt);
+ sqlite3_reset(pIncrCnt);
+ }
+ }
+ sqlite3_finalize(pS2);
+ }
+ sqlite3_finalize(pStmt);
+
+ /* Generate the report */
+ rc = sqlite3_prepare_v2(db,
+ "SELECT tbl, idx, cnt, "
+ " (SELECT group_concat(name,',') FROM pragma_index_info(idx))"
+ " FROM temp.idxu, main.sqlite_master"
+ " WHERE temp.idxu.tbl=main.sqlite_master.tbl_name"
+ " AND temp.idxu.idx=main.sqlite_master.name"
+ " ORDER BY cnt DESC, tbl, idx",
+ -1, &pStmt, 0);
+ if( rc ){
+ printf("Cannot query the result table - %s\n",
+ sqlite3_errmsg(db));
+ goto errorOut;
+ }
+ while( sqlite3_step(pStmt)==SQLITE_ROW ){
+ printf("%10d %s on %s(%s)\n",
+ sqlite3_column_int(pStmt, 2),
+ sqlite3_column_text(pStmt, 1),
+ sqlite3_column_text(pStmt, 0),
+ sqlite3_column_text(pStmt, 3));
+ }
+ sqlite3_finalize(pStmt);
+ pStmt = 0;
+
+errorOut:
+ sqlite3_finalize(pIncrCnt);
+ sqlite3_finalize(pStmt);
+ sqlite3_close(db);
+ return nErr;
+}
diff --git a/chromium/third_party/sqlite/src/tool/lemon.c b/chromium/third_party/sqlite/src/tool/lemon.c
index e7eaaa6eeec..a90bb33f46c 100644
--- a/chromium/third_party/sqlite/src/tool/lemon.c
+++ b/chromium/third_party/sqlite/src/tool/lemon.c
@@ -4590,13 +4590,20 @@ void ReportTable(
tplt_print(out,lemp,lemp->overflow,&lineno);
tplt_xfer(lemp->name,in,out,&lineno);
- /* Generate the table of rule information
+ /* Generate the tables of rule information. yyRuleInfoLhs[] and
+ ** yyRuleInfoNRhs[].
**
** Note: This code depends on the fact that rules are number
** sequentually beginning with 0.
*/
for(i=0, rp=lemp->rule; rp; rp=rp->next, i++){
- fprintf(out," { %4d, %4d }, /* (%d) ",rp->lhs->index,-rp->nrhs,i);
+ fprintf(out," %4d, /* (%d) ", rp->lhs->index, i);
+ rule_print(out, rp);
+ fprintf(out," */\n"); lineno++;
+ }
+ tplt_xfer(lemp->name,in,out,&lineno);
+ for(i=0, rp=lemp->rule; rp; rp=rp->next, i++){
+ fprintf(out," %3d, /* (%d) ", -rp->nrhs, i);
rule_print(out, rp);
fprintf(out," */\n"); lineno++;
}
@@ -4667,6 +4674,7 @@ void ReportTable(
/* Append any addition code the user desires */
tplt_print(out,lemp,lemp->extracode,&lineno);
+ acttab_free(pActtab);
fclose(in);
fclose(out);
return;
diff --git a/chromium/third_party/sqlite/src/tool/lempar.c b/chromium/third_party/sqlite/src/tool/lempar.c
index 2ea791518f7..5a0d56fa36c 100644
--- a/chromium/third_party/sqlite/src/tool/lempar.c
+++ b/chromium/third_party/sqlite/src/tool/lempar.c
@@ -686,13 +686,15 @@ static void yy_shift(
yyTraceShift(yypParser, yyNewState, "Shift");
}
-/* The following table contains information about every rule that
-** is used during the reduce.
-*/
-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[] = {
+/* For rule J, yyRuleInfoLhs[J] contains the symbol on the left-hand side
+** of that rule */
+static const YYCODETYPE yyRuleInfoLhs[] = {
+%%
+};
+
+/* For rule J, yyRuleInfoNRhs[J] contains the negative of the number
+** of symbols on the right-hand side of that rule. */
+static const signed char yyRuleInfoNRhs[] = {
%%
};
@@ -725,7 +727,7 @@ static YYACTIONTYPE yy_reduce(
yymsp = yypParser->yytos;
#ifndef NDEBUG
if( yyTraceFILE && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){
- yysize = yyRuleInfo[yyruleno].nrhs;
+ yysize = yyRuleInfoNRhs[yyruleno];
if( yysize ){
fprintf(yyTraceFILE, "%sReduce %d [%s], go to state %d.\n",
yyTracePrompt,
@@ -740,7 +742,7 @@ static YYACTIONTYPE yy_reduce(
/* Check that the stack is large enough to grow by a single entry
** if the RHS of the rule is empty. This ensures that there is room
** enough on the stack to push the LHS value */
- if( yyRuleInfo[yyruleno].nrhs==0 ){
+ if( yyRuleInfoNRhs[yyruleno]==0 ){
#ifdef YYTRACKMAXSTACKDEPTH
if( (int)(yypParser->yytos - yypParser->yystack)>yypParser->yyhwm ){
yypParser->yyhwm++;
@@ -782,9 +784,9 @@ static YYACTIONTYPE yy_reduce(
%%
/********** End reduce actions ************************************************/
};
- assert( yyruleno<sizeof(yyRuleInfo)/sizeof(yyRuleInfo[0]) );
- yygoto = yyRuleInfo[yyruleno].lhs;
- yysize = yyRuleInfo[yyruleno].nrhs;
+ assert( yyruleno<sizeof(yyRuleInfoLhs)/sizeof(yyRuleInfoLhs[0]) );
+ yygoto = yyRuleInfoLhs[yyruleno];
+ yysize = yyRuleInfoNRhs[yyruleno];
yyact = yy_find_reduce_action(yymsp[yysize].stateno,(YYCODETYPE)yygoto);
/* There are no SHIFTREDUCE actions on nonterminals because the table
diff --git a/chromium/third_party/sqlite/src/tool/mkpragmatab.tcl b/chromium/third_party/sqlite/src/tool/mkpragmatab.tcl
index f6cf7790317..0b3b7ef70ae 100644
--- a/chromium/third_party/sqlite/src/tool/mkpragmatab.tcl
+++ b/chromium/third_party/sqlite/src/tool/mkpragmatab.tcl
@@ -294,7 +294,10 @@ set pragma_def {
IF: !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
NAME: parser_trace
- IF: defined(SQLITE_DEBUG) && !defined(SQLITE_OMIT_PARSER_TRACE)
+ TYPE: FLAG
+ ARG: SQLITE_ParserTrace
+ IF: !defined(SQLITE_OMIT_FLAG_PRAGMAS)
+ IF: defined(SQLITE_DEBUG)
NAME: case_sensitive_like
FLAG: NoColumns