summaryrefslogtreecommitdiff
path: root/chromium/third_party/sqlite/src
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2022-05-17 17:24:03 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2022-06-22 07:51:41 +0000
commit774f54339e5db91f785733232d3950366db65d07 (patch)
tree068e1b47bd1af94d77094ed12b604a6b83d9c22a /chromium/third_party/sqlite/src
parentf7eaed5286974984ba5f9e3189d8f49d03e99f81 (diff)
downloadqtwebengine-chromium-774f54339e5db91f785733232d3950366db65d07.tar.gz
BASELINE: Update Chromium to 102.0.5005.57
Change-Id: I885f714bb40ee724c28f94ca6bd8dbdb39915158 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/third_party/sqlite/src')
-rw-r--r--chromium/third_party/sqlite/src/Makefile.in17
-rw-r--r--chromium/third_party/sqlite/src/Makefile.msc31
-rw-r--r--chromium/third_party/sqlite/src/README.md8
-rw-r--r--chromium/third_party/sqlite/src/VERSION2
-rw-r--r--chromium/third_party/sqlite/src/amalgamation/rename_exports.h556
-rw-r--r--chromium/third_party/sqlite/src/amalgamation/shell/shell.c1159
-rw-r--r--chromium/third_party/sqlite/src/amalgamation/sqlite3.c8942
-rw-r--r--chromium/third_party/sqlite/src/amalgamation/sqlite3.h380
-rw-r--r--chromium/third_party/sqlite/src/amalgamation_dev/rename_exports.h556
-rw-r--r--chromium/third_party/sqlite/src/amalgamation_dev/shell/shell.c1159
-rw-r--r--chromium/third_party/sqlite/src/amalgamation_dev/sqlite3.c9612
-rw-r--r--chromium/third_party/sqlite/src/amalgamation_dev/sqlite3.h380
-rw-r--r--chromium/third_party/sqlite/src/autoconf/Makefile.msc9
-rw-r--r--chromium/third_party/sqlite/src/autoconf/README.txt2
-rw-r--r--chromium/third_party/sqlite/src/autoconf/configure.ac15
-rwxr-xr-xchromium/third_party/sqlite/src/configure60
-rw-r--r--chromium/third_party/sqlite/src/configure.ac25
-rw-r--r--chromium/third_party/sqlite/src/doc/json-enhancements.md144
-rw-r--r--chromium/third_party/sqlite/src/ext/expert/sqlite3expert.c35
-rw-r--r--chromium/third_party/sqlite/src/ext/fts3/fts3.c45
-rw-r--r--chromium/third_party/sqlite/src/ext/fts3/fts3Int.h2
-rw-r--r--chromium/third_party/sqlite/src/ext/fts3/fts3_tokenize_vtab.c6
-rw-r--r--chromium/third_party/sqlite/src/ext/fts3/mkfts3amal.tcl115
-rw-r--r--chromium/third_party/sqlite/src/ext/fts5/fts5_index.c2
-rw-r--r--chromium/third_party/sqlite/src/ext/fts5/fts5_main.c2
-rw-r--r--chromium/third_party/sqlite/src/ext/lsm1/lsm_vtab.c2
-rw-r--r--chromium/third_party/sqlite/src/ext/misc/csv.c2
-rw-r--r--chromium/third_party/sqlite/src/ext/misc/fileio.c3
-rw-r--r--chromium/third_party/sqlite/src/ext/misc/ieee754.c2
-rw-r--r--chromium/third_party/sqlite/src/ext/misc/qpvtab.c461
-rw-r--r--chromium/third_party/sqlite/src/ext/misc/regexp.c10
-rw-r--r--chromium/third_party/sqlite/src/ext/misc/series.c2
-rw-r--r--chromium/third_party/sqlite/src/ext/misc/sha1.c2
-rw-r--r--chromium/third_party/sqlite/src/ext/misc/shathree.c1
-rw-r--r--chromium/third_party/sqlite/src/ext/misc/zipfile.c4
-rw-r--r--chromium/third_party/sqlite/src/ext/rbu/sqlite3rbu.c2
-rw-r--r--chromium/third_party/sqlite/src/ext/repair/sqlite3_checker.c.in1
-rw-r--r--chromium/third_party/sqlite/src/ext/rtree/geopoly.c11
-rw-r--r--chromium/third_party/sqlite/src/ext/rtree/rtreeA.test6
-rw-r--r--chromium/third_party/sqlite/src/ext/rtree/rtreecheck.test4
-rw-r--r--chromium/third_party/sqlite/src/ext/rtree/test_rtreedoc.c4
-rw-r--r--chromium/third_party/sqlite/src/ext/session/session8.test2
-rw-r--r--chromium/third_party/sqlite/src/main.mk22
-rw-r--r--chromium/third_party/sqlite/src/manifest385
-rw-r--r--chromium/third_party/sqlite/src/manifest.uuid2
-rw-r--r--chromium/third_party/sqlite/src/src/alter.c98
-rw-r--r--chromium/third_party/sqlite/src/src/attach.c2
-rw-r--r--chromium/third_party/sqlite/src/src/backup.c5
-rw-r--r--chromium/third_party/sqlite/src/src/btree.c205
-rw-r--r--chromium/third_party/sqlite/src/src/btreeInt.h4
-rw-r--r--chromium/third_party/sqlite/src/src/build.c61
-rw-r--r--chromium/third_party/sqlite/src/src/callback.c1
-rw-r--r--chromium/third_party/sqlite/src/src/ctime.c23
-rw-r--r--chromium/third_party/sqlite/src/src/date.c312
-rw-r--r--chromium/third_party/sqlite/src/src/dbpage.c1
-rw-r--r--chromium/third_party/sqlite/src/src/delete.c20
-rw-r--r--chromium/third_party/sqlite/src/src/expr.c31
-rw-r--r--chromium/third_party/sqlite/src/src/fkey.c21
-rw-r--r--chromium/third_party/sqlite/src/src/func.c124
-rw-r--r--chromium/third_party/sqlite/src/src/global.c1
-rw-r--r--chromium/third_party/sqlite/src/src/insert.c28
-rw-r--r--chromium/third_party/sqlite/src/src/json.c (renamed from chromium/third_party/sqlite/src/ext/misc/json1.c)402
-rw-r--r--chromium/third_party/sqlite/src/src/loadext.c7
-rw-r--r--chromium/third_party/sqlite/src/src/main.c72
-rw-r--r--chromium/third_party/sqlite/src/src/malloc.c11
-rw-r--r--chromium/third_party/sqlite/src/src/memjournal.c26
-rw-r--r--chromium/third_party/sqlite/src/src/pager.c45
-rw-r--r--chromium/third_party/sqlite/src/src/parse.y36
-rw-r--r--chromium/third_party/sqlite/src/src/pcache.c3
-rw-r--r--chromium/third_party/sqlite/src/src/pragma.c4
-rw-r--r--chromium/third_party/sqlite/src/src/prepare.c66
-rw-r--r--chromium/third_party/sqlite/src/src/printf.c58
-rw-r--r--chromium/third_party/sqlite/src/src/resolve.c70
-rw-r--r--chromium/third_party/sqlite/src/src/select.c107
-rw-r--r--chromium/third_party/sqlite/src/src/shell.c.in1102
-rw-r--r--chromium/third_party/sqlite/src/src/sqlite.h.in374
-rw-r--r--chromium/third_party/sqlite/src/src/sqlite3ext.h14
-rw-r--r--chromium/third_party/sqlite/src/src/sqliteInt.h65
-rw-r--r--chromium/third_party/sqlite/src/src/tclsqlite.c48
-rw-r--r--chromium/third_party/sqlite/src/src/test1.c187
-rw-r--r--chromium/third_party/sqlite/src/src/test_bestindex.c195
-rw-r--r--chromium/third_party/sqlite/src/src/test_config.c2
-rw-r--r--chromium/third_party/sqlite/src/src/test_func.c6
-rw-r--r--chromium/third_party/sqlite/src/src/tokenize.c47
-rw-r--r--chromium/third_party/sqlite/src/src/treeview.c2
-rw-r--r--chromium/third_party/sqlite/src/src/trigger.c75
-rw-r--r--chromium/third_party/sqlite/src/src/update.c14
-rw-r--r--chromium/third_party/sqlite/src/src/util.c51
-rw-r--r--chromium/third_party/sqlite/src/src/vdbe.c219
-rw-r--r--chromium/third_party/sqlite/src/src/vdbeInt.h32
-rw-r--r--chromium/third_party/sqlite/src/src/vdbeapi.c69
-rw-r--r--chromium/third_party/sqlite/src/src/vdbeaux.c46
-rw-r--r--chromium/third_party/sqlite/src/src/vdbeblob.c11
-rw-r--r--chromium/third_party/sqlite/src/src/vdbemem.c11
-rw-r--r--chromium/third_party/sqlite/src/src/vdbesort.c3
-rw-r--r--chromium/third_party/sqlite/src/src/vtab.c18
-rw-r--r--chromium/third_party/sqlite/src/src/wal.c6
-rw-r--r--chromium/third_party/sqlite/src/src/where.c818
-rw-r--r--chromium/third_party/sqlite/src/src/whereInt.h34
-rw-r--r--chromium/third_party/sqlite/src/src/wherecode.c264
-rw-r--r--chromium/third_party/sqlite/src/src/whereexpr.c241
-rw-r--r--chromium/third_party/sqlite/src/src/window.c14
-rw-r--r--chromium/third_party/sqlite/src/tool/lemon.c2
-rw-r--r--chromium/third_party/sqlite/src/tool/logest.c5
-rwxr-xr-x[-rw-r--r--]chromium/third_party/sqlite/src/tool/mkctimec.tcl125
-rw-r--r--chromium/third_party/sqlite/src/tool/mksqlite3c.tcl2
-rw-r--r--chromium/third_party/sqlite/src/tool/omittest.tcl1
-rw-r--r--chromium/third_party/sqlite/src/tool/showdb.c6
-rw-r--r--chromium/third_party/sqlite/src/tool/sqldiff.c48
-rw-r--r--chromium/third_party/sqlite/src/tool/vdbe-compress.tcl2
-rw-r--r--chromium/third_party/sqlite/src/tool/warnings.sh4
111 files changed, 19579 insertions, 10620 deletions
diff --git a/chromium/third_party/sqlite/src/Makefile.in b/chromium/third_party/sqlite/src/Makefile.in
index b3ea4628b38..e5d30d030b4 100644
--- a/chromium/third_party/sqlite/src/Makefile.in
+++ b/chromium/third_party/sqlite/src/Makefile.in
@@ -180,7 +180,7 @@ LIBOBJS0 = alter.lo analyze.lo attach.lo auth.lo \
fts3_unicode.lo fts3_unicode2.lo fts3_write.lo \
fts5.lo \
func.lo global.lo hash.lo \
- icu.lo insert.lo json1.lo legacy.lo loadext.lo \
+ icu.lo insert.lo json.lo legacy.lo loadext.lo \
main.lo malloc.lo mem0.lo mem1.lo mem2.lo mem3.lo mem5.lo \
memdb.lo memjournal.lo \
mutex.lo mutex_noop.lo mutex_unix.lo mutex_w32.lo \
@@ -234,6 +234,7 @@ SRC = \
$(TOP)/src/hash.h \
$(TOP)/src/hwtime.h \
$(TOP)/src/insert.c \
+ $(TOP)/src/json.c \
$(TOP)/src/legacy.c \
$(TOP)/src/loadext.c \
$(TOP)/src/main.c \
@@ -366,7 +367,6 @@ SRC += \
$(TOP)/ext/rbu/sqlite3rbu.h \
$(TOP)/ext/rbu/sqlite3rbu.c
SRC += \
- $(TOP)/ext/misc/json1.c \
$(TOP)/ext/misc/stmt.c
# Generated source code files
@@ -460,6 +460,7 @@ TESTSRC += \
$(TOP)/ext/misc/normalize.c \
$(TOP)/ext/misc/percentile.c \
$(TOP)/ext/misc/prefixes.c \
+ $(TOP)/ext/misc/qpvtab.c \
$(TOP)/ext/misc/regexp.c \
$(TOP)/ext/misc/remember.c \
$(TOP)/ext/misc/series.c \
@@ -608,7 +609,7 @@ TESTOPTS = --verbose=file --output=test-out.txt
# Extra compiler options for various shell tools
#
-SHELL_OPT = -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_FTS4
+SHELL_OPT = -DSQLITE_ENABLE_FTS4
#SHELL_OPT += -DSQLITE_ENABLE_FTS5
SHELL_OPT += -DSQLITE_ENABLE_RTREE
SHELL_OPT += -DSQLITE_ENABLE_EXPLAIN_COMMENTS
@@ -618,8 +619,8 @@ SHELL_OPT += -DSQLITE_ENABLE_DBPAGE_VTAB
SHELL_OPT += -DSQLITE_ENABLE_DBSTAT_VTAB
SHELL_OPT += -DSQLITE_ENABLE_BYTECODE_VTAB
SHELL_OPT += -DSQLITE_ENABLE_OFFSET_SQL_FUNC
-FUZZERSHELL_OPT = -DSQLITE_ENABLE_JSON1
-FUZZCHECK_OPT = -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_MEMSYS5 -DSQLITE_OSS_FUZZ
+FUZZERSHELL_OPT =
+FUZZCHECK_OPT = -DSQLITE_ENABLE_MEMSYS5 -DSQLITE_OSS_FUZZ
FUZZCHECK_OPT += -DSQLITE_MAX_MEMORY=50000000
FUZZCHECK_OPT += -DSQLITE_PRINTF_PRECISION_LIMIT=1000
FUZZCHECK_OPT += -DSQLITE_ENABLE_FTS4
@@ -873,6 +874,9 @@ hash.lo: $(TOP)/src/hash.c $(HDR)
insert.lo: $(TOP)/src/insert.c $(HDR)
$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/insert.c
+json.lo: $(TOP)/src/json.c
+ $(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/json.c
+
legacy.lo: $(TOP)/src/legacy.c $(HDR)
$(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/legacy.c
@@ -1176,9 +1180,6 @@ userauth.lo: $(TOP)/ext/userauth/userauth.c $(HDR) $(EXTHDR)
sqlite3session.lo: $(TOP)/ext/session/sqlite3session.c $(HDR) $(EXTHDR)
$(LTCOMPILE) -DSQLITE_CORE -c $(TOP)/ext/session/sqlite3session.c
-json1.lo: $(TOP)/ext/misc/json1.c
- $(LTCOMPILE) -DSQLITE_CORE -c $(TOP)/ext/misc/json1.c
-
stmt.lo: $(TOP)/ext/misc/stmt.c
$(LTCOMPILE) -DSQLITE_CORE -c $(TOP)/ext/misc/stmt.c
diff --git a/chromium/third_party/sqlite/src/Makefile.msc b/chromium/third_party/sqlite/src/Makefile.msc
index 3cbf560d7cf..d67b7f0b864 100644
--- a/chromium/third_party/sqlite/src/Makefile.msc
+++ b/chromium/third_party/sqlite/src/Makefile.msc
@@ -363,7 +363,6 @@ SQLITE_TCL_DEP =
OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_FTS3=1
OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_RTREE=1
OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_GEOPOLY=1
-OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_JSON1=1
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
@@ -580,17 +579,17 @@ RCC = $(RC) -DSQLITE_OS_WIN=1 -I. -I$(TOP) -I$(TOP)\src $(RCOPTS) $(RCCOPTS)
#
!IF $(USE_STDCALL)!=0 || $(FOR_WIN10)!=0
!IF "$(PLATFORM)"=="x86"
-CORE_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall
-SHELL_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall
+CORE_CCONV_OPTS = -Gz -guard:cf -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall
+SHELL_CCONV_OPTS = -Gz -guard:cf -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall
# <<mark>>
-TEST_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall -DINCLUDE_SQLITE_TCL_H=1 -DSQLITE_TCLAPI=__cdecl
+TEST_CCONV_OPTS = -Gz -guard:cf -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall -DINCLUDE_SQLITE_TCL_H=1 -DSQLITE_TCLAPI=__cdecl
# <</mark>>
!ELSE
!IFNDEF PLATFORM
-CORE_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall
-SHELL_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall
+CORE_CCONV_OPTS = -Gz -guard:cf -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall
+SHELL_CCONV_OPTS = -Gz -guard:cf -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall
# <<mark>>
-TEST_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall -DINCLUDE_SQLITE_TCL_H=1 -DSQLITE_TCLAPI=__cdecl
+TEST_CCONV_OPTS = -Gz -guard:cf -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall -DINCLUDE_SQLITE_TCL_H=1 -DSQLITE_TCLAPI=__cdecl
# <</mark>>
!ELSE
CORE_CCONV_OPTS =
@@ -1248,7 +1247,7 @@ LIBOBJS0 = vdbe.lo parse.lo alter.lo analyze.lo attach.lo auth.lo \
fts3_tokenize_vtab.lo fts3_unicode.lo fts3_unicode2.lo fts3_write.lo \
fts5.lo \
func.lo global.lo hash.lo \
- icu.lo insert.lo json1.lo legacy.lo loadext.lo \
+ icu.lo insert.lo json.lo legacy.lo loadext.lo \
main.lo malloc.lo mem0.lo mem1.lo mem2.lo mem3.lo mem5.lo \
memdb.lo memjournal.lo \
mutex.lo mutex_noop.lo mutex_unix.lo mutex_w32.lo \
@@ -1315,6 +1314,7 @@ SRC00 = \
$(TOP)\src\global.c \
$(TOP)\src\hash.c \
$(TOP)\src\insert.c \
+ $(TOP)\src\json.c \
$(TOP)\src\legacy.c \
$(TOP)\src\loadext.c \
$(TOP)\src\main.c \
@@ -1445,7 +1445,6 @@ SRC07 = \
$(TOP)\ext\rtree\rtree.c \
$(TOP)\ext\session\sqlite3session.c \
$(TOP)\ext\rbu\sqlite3rbu.c \
- $(TOP)\ext\misc\json1.c \
$(TOP)\ext\misc\stmt.c
# Extension header files, part 1.
@@ -1579,6 +1578,7 @@ TESTEXT = \
$(TOP)\ext\misc\normalize.c \
$(TOP)\ext\misc\percentile.c \
$(TOP)\ext\misc\prefixes.c \
+ $(TOP)\ext\misc\qpvtab.c \
$(TOP)\ext\misc\regexp.c \
$(TOP)\ext\misc\remember.c \
$(TOP)\ext\misc\series.c \
@@ -1695,9 +1695,9 @@ SHELL_COMPILE_OPTS = $(SHELL_COMPILE_OPTS) -DSQLITE_ENABLE_OFFSET_SQL_FUNC=1
# <<mark>>
# Extra compiler options for various test tools.
#
-MPTESTER_COMPILE_OPTS = -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_FTS5
-FUZZERSHELL_COMPILE_OPTS = -DSQLITE_ENABLE_JSON1
-FUZZCHECK_OPTS = -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_MEMSYS5 -DSQLITE_OSS_FUZZ -DSQLITE_MAX_MEMORY=50000000 -DSQLITE_PRINTF_PRECISION_LIMIT=1000
+MPTESTER_COMPILE_OPTS = -DSQLITE_ENABLE_FTS5
+FUZZERSHELL_COMPILE_OPTS =
+FUZZCHECK_OPTS = -DSQLITE_ENABLE_MEMSYS5 -DSQLITE_OSS_FUZZ -DSQLITE_MAX_MEMORY=50000000 -DSQLITE_PRINTF_PRECISION_LIMIT=1000
FUZZCHECK_OPTS = $(FUZZCHECK_OPTS) -DSQLITE_ENABLE_FTS4
FUZZCHECK_OPTS = $(FUZZCHECK_OPTS) -DSQLITE_ENABLE_FTS5
FUZZCHECK_OPTS = $(FUZZCHECK_OPTS) -DSQLITE_ENABLE_RTREE
@@ -1990,6 +1990,9 @@ hash.lo: $(TOP)\src\hash.c $(HDR)
insert.lo: $(TOP)\src\insert.c $(HDR)
$(LTCOMPILE) $(CORE_COMPILE_OPTS) -c $(TOP)\src\insert.c
+json.lo: $(TOP)\src\json.c $(HDR)
+ $(LTCOMPILE) $(CORE_COMPILE_OPTS) -c $(TOP)\src\json.c
+
legacy.lo: $(TOP)\src\legacy.c $(HDR)
$(LTCOMPILE) $(CORE_COMPILE_OPTS) -c $(TOP)\src\legacy.c
@@ -2298,9 +2301,6 @@ fts3_unicode2.lo: $(TOP)\ext\fts3\fts3_unicode2.c $(HDR) $(EXTHDR)
fts3_write.lo: $(TOP)\ext\fts3\fts3_write.c $(HDR) $(EXTHDR)
$(LTCOMPILE) $(CORE_COMPILE_OPTS) $(NO_WARN) -DSQLITE_CORE -c $(TOP)\ext\fts3\fts3_write.c
-json1.lo: $(TOP)\ext\misc\json1.c $(HDR) $(EXTHDR)
- $(LTCOMPILE) $(CORE_COMPILE_OPTS) $(NO_WARN) -DSQLITE_CORE -c $(TOP)\ext\misc\json1.c
-
stmt.lo: $(TOP)\ext\misc\stmt.c $(HDR) $(EXTHDR)
$(LTCOMPILE) $(CORE_COMPILE_OPTS) $(NO_WARN) -DSQLITE_CORE -c $(TOP)\ext\misc\stmt.c
@@ -2392,7 +2392,6 @@ 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_BYTECODE_VTAB=1
-TESTFIXTURE_FLAGS = $(TESTFIXTURE_FLAGS) -DSQLITE_ENABLE_JSON1=1
TESTFIXTURE_FLAGS = $(TESTFIXTURE_FLAGS) -DSQLITE_CKSUMVFS_STATIC=1
TESTFIXTURE_FLAGS = $(TESTFIXTURE_FLAGS) $(TEST_CCONV_OPTS)
diff --git a/chromium/third_party/sqlite/src/README.md b/chromium/third_party/sqlite/src/README.md
index b79fc67f157..9e8bb2610e9 100644
--- a/chromium/third_party/sqlite/src/README.md
+++ b/chromium/third_party/sqlite/src/README.md
@@ -309,9 +309,11 @@ describes its purpose and role within the larger system.
The `manifest` file at the root directory of the source tree
contains either a SHA3-256 hash (for newer files) or a SHA1 hash (for
older files) for every source file in the repository.
-The SHA3-256 hash of the `manifest`
-file itself is the official name of the version of the source tree that you
-have. The `manifest.uuid` file should contain the SHA3-256 hash of the
+The name of the version of the entire source tree is just the
+SHA3-256 hash of the `manifest` file itself, possibly with the
+last line of that file omitted if the last line begins with
+"`# Remove this line`".
+The `manifest.uuid` file should contain the SHA3-256 hash of the
`manifest` file. If all of the above hash comparisons are correct, then
you can be confident that your source tree is authentic and unadulterated.
diff --git a/chromium/third_party/sqlite/src/VERSION b/chromium/third_party/sqlite/src/VERSION
index 08a0898f890..82310d0c7fc 100644
--- a/chromium/third_party/sqlite/src/VERSION
+++ b/chromium/third_party/sqlite/src/VERSION
@@ -1 +1 @@
-3.37.1
+3.38.1
diff --git a/chromium/third_party/sqlite/src/amalgamation/rename_exports.h b/chromium/third_party/sqlite/src/amalgamation/rename_exports.h
index 5d0e1b84f2f..52396807ea8 100644
--- a/chromium/third_party/sqlite/src/amalgamation/rename_exports.h
+++ b/chromium/third_party/sqlite/src/amalgamation/rename_exports.h
@@ -7,342 +7,348 @@
#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 6068-6070
-#define sqlite3_aggregate_context chrome_sqlite3_aggregate_context // Line 5629
-#define sqlite3_aggregate_count chrome_sqlite3_aggregate_count // Line 5404
-#define sqlite3_auto_extension chrome_sqlite3_auto_extension // Line 6884
-#define sqlite3_autovacuum_pages chrome_sqlite3_autovacuum_pages // Lines 6476-6481
-#define sqlite3_backup_finish chrome_sqlite3_backup_finish // Line 8918
-#define sqlite3_backup_init chrome_sqlite3_backup_init // Lines 8911-8916
-#define sqlite3_backup_pagecount chrome_sqlite3_backup_pagecount // Line 8920
-#define sqlite3_backup_remaining chrome_sqlite3_backup_remaining // Line 8919
-#define sqlite3_backup_step chrome_sqlite3_backup_step // Line 8917
-#define sqlite3_bind_blob chrome_sqlite3_bind_blob // Line 4510
-#define sqlite3_bind_blob64 chrome_sqlite3_bind_blob64 // Lines 4511-4512
-#define sqlite3_bind_double chrome_sqlite3_bind_double // Line 4513
-#define sqlite3_bind_int chrome_sqlite3_bind_int // Line 4514
-#define sqlite3_bind_int64 chrome_sqlite3_bind_int64 // Line 4515
-#define sqlite3_bind_null chrome_sqlite3_bind_null // Line 4516
-#define sqlite3_bind_parameter_count chrome_sqlite3_bind_parameter_count // Line 4545
-#define sqlite3_bind_parameter_index chrome_sqlite3_bind_parameter_index // Line 4591
-#define sqlite3_bind_parameter_name chrome_sqlite3_bind_parameter_name // Line 4573
-#define sqlite3_bind_pointer chrome_sqlite3_bind_pointer // Line 4522
-#define sqlite3_bind_text chrome_sqlite3_bind_text // Line 4517
-#define sqlite3_bind_text16 chrome_sqlite3_bind_text16 // Line 4518
-#define sqlite3_bind_text64 chrome_sqlite3_bind_text64 // Lines 4519-4520
-#define sqlite3_bind_value chrome_sqlite3_bind_value // Line 4521
-#define sqlite3_bind_zeroblob chrome_sqlite3_bind_zeroblob // Line 4523
-#define sqlite3_bind_zeroblob64 chrome_sqlite3_bind_zeroblob64 // Line 4524
-#define sqlite3_blob_bytes chrome_sqlite3_blob_bytes // Line 7462
-#define sqlite3_blob_close chrome_sqlite3_blob_close // Line 7446
-#define sqlite3_blob_open chrome_sqlite3_blob_open // Lines 7390-7398
-#define sqlite3_blob_read chrome_sqlite3_blob_read // Line 7491
-#define sqlite3_blob_reopen chrome_sqlite3_blob_reopen // Line 7423
-#define sqlite3_blob_write chrome_sqlite3_blob_write // Line 7533
+#define sqlite3_activate_cerod chrome_sqlite3_activate_cerod // Lines 6087-6089
+#define sqlite3_aggregate_context chrome_sqlite3_aggregate_context // Line 5648
+#define sqlite3_aggregate_count chrome_sqlite3_aggregate_count // Line 5423
+#define sqlite3_auto_extension chrome_sqlite3_auto_extension // Line 6903
+#define sqlite3_autovacuum_pages chrome_sqlite3_autovacuum_pages // Lines 6495-6500
+#define sqlite3_backup_finish chrome_sqlite3_backup_finish // Line 8982
+#define sqlite3_backup_init chrome_sqlite3_backup_init // Lines 8975-8980
+#define sqlite3_backup_pagecount chrome_sqlite3_backup_pagecount // Line 8984
+#define sqlite3_backup_remaining chrome_sqlite3_backup_remaining // Line 8983
+#define sqlite3_backup_step chrome_sqlite3_backup_step // Line 8981
+#define sqlite3_bind_blob chrome_sqlite3_bind_blob // Line 4525
+#define sqlite3_bind_blob64 chrome_sqlite3_bind_blob64 // Lines 4526-4527
+#define sqlite3_bind_double chrome_sqlite3_bind_double // Line 4528
+#define sqlite3_bind_int chrome_sqlite3_bind_int // Line 4529
+#define sqlite3_bind_int64 chrome_sqlite3_bind_int64 // Line 4530
+#define sqlite3_bind_null chrome_sqlite3_bind_null // Line 4531
+#define sqlite3_bind_parameter_count chrome_sqlite3_bind_parameter_count // Line 4560
+#define sqlite3_bind_parameter_index chrome_sqlite3_bind_parameter_index // Line 4606
+#define sqlite3_bind_parameter_name chrome_sqlite3_bind_parameter_name // Line 4588
+#define sqlite3_bind_pointer chrome_sqlite3_bind_pointer // Line 4537
+#define sqlite3_bind_text chrome_sqlite3_bind_text // Line 4532
+#define sqlite3_bind_text16 chrome_sqlite3_bind_text16 // Line 4533
+#define sqlite3_bind_text64 chrome_sqlite3_bind_text64 // Lines 4534-4535
+#define sqlite3_bind_value chrome_sqlite3_bind_value // Line 4536
+#define sqlite3_bind_zeroblob chrome_sqlite3_bind_zeroblob // Line 4538
+#define sqlite3_bind_zeroblob64 chrome_sqlite3_bind_zeroblob64 // Line 4539
+#define sqlite3_blob_bytes chrome_sqlite3_blob_bytes // Line 7513
+#define sqlite3_blob_close chrome_sqlite3_blob_close // Line 7497
+#define sqlite3_blob_open chrome_sqlite3_blob_open // Lines 7441-7449
+#define sqlite3_blob_read chrome_sqlite3_blob_read // Line 7542
+#define sqlite3_blob_reopen chrome_sqlite3_blob_reopen // Line 7474
+#define sqlite3_blob_write chrome_sqlite3_blob_write // Line 7584
#define sqlite3_busy_handler chrome_sqlite3_busy_handler // Line 2737
#define sqlite3_busy_timeout chrome_sqlite3_busy_timeout // Line 2760
-#define sqlite3_cancel_auto_extension chrome_sqlite3_cancel_auto_extension // Line 6896
+#define sqlite3_cancel_auto_extension chrome_sqlite3_cancel_auto_extension // Line 6915
#define sqlite3_changes chrome_sqlite3_changes // Line 2560
#define sqlite3_changes64 chrome_sqlite3_changes64 // Line 2561
-#define sqlite3_clear_bindings chrome_sqlite3_clear_bindings // Line 4601
+#define sqlite3_clear_bindings chrome_sqlite3_clear_bindings // Line 4616
#define sqlite3_close chrome_sqlite3_close // Line 353
#define sqlite3_close_v2 chrome_sqlite3_close_v2 // Line 354
-#define sqlite3_collation_needed chrome_sqlite3_collation_needed // Lines 6052-6056
-#define sqlite3_collation_needed16 chrome_sqlite3_collation_needed16 // Lines 6057-6061
-#define sqlite3_column_blob chrome_sqlite3_column_blob // Line 5077
-#define sqlite3_column_bytes chrome_sqlite3_column_bytes // Line 5084
-#define sqlite3_column_bytes16 chrome_sqlite3_column_bytes16 // Line 5085
-#define sqlite3_column_count chrome_sqlite3_column_count // Line 4617
-#define sqlite3_column_database_name chrome_sqlite3_column_database_name // Line 4691
-#define sqlite3_column_database_name16 chrome_sqlite3_column_database_name16 // Line 4692
-#define sqlite3_column_decltype chrome_sqlite3_column_decltype // Line 4728
-#define sqlite3_column_decltype16 chrome_sqlite3_column_decltype16 // Line 4729
-#define sqlite3_column_double chrome_sqlite3_column_double // Line 5078
-#define sqlite3_column_int chrome_sqlite3_column_int // Line 5079
-#define sqlite3_column_int64 chrome_sqlite3_column_int64 // Line 5080
-#define sqlite3_column_name chrome_sqlite3_column_name // Line 4646
-#define sqlite3_column_name16 chrome_sqlite3_column_name16 // Line 4647
-#define sqlite3_column_origin_name chrome_sqlite3_column_origin_name // Line 4695
-#define sqlite3_column_origin_name16 chrome_sqlite3_column_origin_name16 // Line 4696
-#define sqlite3_column_table_name chrome_sqlite3_column_table_name // Line 4693
-#define sqlite3_column_table_name16 chrome_sqlite3_column_table_name16 // Line 4694
-#define sqlite3_column_text chrome_sqlite3_column_text // Line 5081
-#define sqlite3_column_text16 chrome_sqlite3_column_text16 // Line 5082
-#define sqlite3_column_type chrome_sqlite3_column_type // Line 5086
-#define sqlite3_column_value chrome_sqlite3_column_value // Line 5083
-#define sqlite3_commit_hook chrome_sqlite3_commit_hook // Line 6415
+#define sqlite3_collation_needed chrome_sqlite3_collation_needed // Lines 6071-6075
+#define sqlite3_collation_needed16 chrome_sqlite3_collation_needed16 // Lines 6076-6080
+#define sqlite3_column_blob chrome_sqlite3_column_blob // Line 5096
+#define sqlite3_column_bytes chrome_sqlite3_column_bytes // Line 5103
+#define sqlite3_column_bytes16 chrome_sqlite3_column_bytes16 // Line 5104
+#define sqlite3_column_count chrome_sqlite3_column_count // Line 4632
+#define sqlite3_column_database_name chrome_sqlite3_column_database_name // Line 4706
+#define sqlite3_column_database_name16 chrome_sqlite3_column_database_name16 // Line 4707
+#define sqlite3_column_decltype chrome_sqlite3_column_decltype // Line 4743
+#define sqlite3_column_decltype16 chrome_sqlite3_column_decltype16 // Line 4744
+#define sqlite3_column_double chrome_sqlite3_column_double // Line 5097
+#define sqlite3_column_int chrome_sqlite3_column_int // Line 5098
+#define sqlite3_column_int64 chrome_sqlite3_column_int64 // Line 5099
+#define sqlite3_column_name chrome_sqlite3_column_name // Line 4661
+#define sqlite3_column_name16 chrome_sqlite3_column_name16 // Line 4662
+#define sqlite3_column_origin_name chrome_sqlite3_column_origin_name // Line 4710
+#define sqlite3_column_origin_name16 chrome_sqlite3_column_origin_name16 // Line 4711
+#define sqlite3_column_table_name chrome_sqlite3_column_table_name // Line 4708
+#define sqlite3_column_table_name16 chrome_sqlite3_column_table_name16 // Line 4709
+#define sqlite3_column_text chrome_sqlite3_column_text // Line 5100
+#define sqlite3_column_text16 chrome_sqlite3_column_text16 // Line 5101
+#define sqlite3_column_type chrome_sqlite3_column_type // Line 5105
+#define sqlite3_column_value chrome_sqlite3_column_value // Line 5102
+#define sqlite3_commit_hook chrome_sqlite3_commit_hook // Line 6434
#define sqlite3_compileoption_get chrome_sqlite3_compileoption_get // Line 214
#define sqlite3_compileoption_used chrome_sqlite3_compileoption_used // Line 213
#define sqlite3_complete chrome_sqlite3_complete // Line 2675
#define sqlite3_complete16 chrome_sqlite3_complete16 // Line 2676
#define sqlite3_config chrome_sqlite3_config // Line 1639
-#define sqlite3_context_db_handle chrome_sqlite3_context_db_handle // Line 5656
-#define sqlite3_create_collation chrome_sqlite3_create_collation // Lines 6002-6008
-#define sqlite3_create_collation16 chrome_sqlite3_create_collation16 // Lines 6017-6023
-#define sqlite3_create_collation_v2 chrome_sqlite3_create_collation_v2 // Lines 6009-6016
+#define sqlite3_context_db_handle chrome_sqlite3_context_db_handle // Line 5675
+#define sqlite3_create_collation chrome_sqlite3_create_collation // Lines 6021-6027
+#define sqlite3_create_collation16 chrome_sqlite3_create_collation16 // Lines 6036-6042
+#define sqlite3_create_collation_v2 chrome_sqlite3_create_collation_v2 // Lines 6028-6035
#define sqlite3_create_filename chrome_sqlite3_create_filename // Lines 3801-3807
-#define sqlite3_create_function chrome_sqlite3_create_function // Lines 5266-5275
-#define sqlite3_create_function16 chrome_sqlite3_create_function16 // Lines 5276-5285
-#define sqlite3_create_function_v2 chrome_sqlite3_create_function_v2 // Lines 5286-5296
-#define sqlite3_create_module chrome_sqlite3_create_module // Lines 7176-7181
-#define sqlite3_create_module_v2 chrome_sqlite3_create_module_v2 // Lines 7182-7188
-#define sqlite3_create_window_function chrome_sqlite3_create_window_function // Lines 5297-5308
-#define sqlite3_data_count chrome_sqlite3_data_count // Line 4834
-#define sqlite3_data_directory chrome_sqlite3_data_directory // Line 6185
+#define sqlite3_create_function chrome_sqlite3_create_function // Lines 5285-5294
+#define sqlite3_create_function16 chrome_sqlite3_create_function16 // Lines 5295-5304
+#define sqlite3_create_function_v2 chrome_sqlite3_create_function_v2 // Lines 5305-5315
+#define sqlite3_create_module chrome_sqlite3_create_module // Lines 7227-7232
+#define sqlite3_create_module_v2 chrome_sqlite3_create_module_v2 // Lines 7233-7239
+#define sqlite3_create_window_function chrome_sqlite3_create_window_function // Lines 5316-5327
+#define sqlite3_data_count chrome_sqlite3_data_count // Line 4849
+#define sqlite3_data_directory chrome_sqlite3_data_directory // Line 6204
#define sqlite3_database_file_object chrome_sqlite3_database_file_object // Line 3754
-#define sqlite3_db_cacheflush chrome_sqlite3_db_cacheflush // Line 9617
+#define sqlite3_db_cacheflush chrome_sqlite3_db_cacheflush // Line 9931
#define sqlite3_db_config chrome_sqlite3_db_config // Line 1658
-#define sqlite3_db_filename chrome_sqlite3_db_filename // Line 6289
-#define sqlite3_db_handle chrome_sqlite3_db_handle // Line 6257
-#define sqlite3_db_mutex chrome_sqlite3_db_mutex // Line 7841
-#define sqlite3_db_readonly chrome_sqlite3_db_readonly // Line 6299
-#define sqlite3_db_release_memory chrome_sqlite3_db_release_memory // Line 6608
-#define sqlite3_db_status chrome_sqlite3_db_status // Line 8268
-#define sqlite3_declare_vtab chrome_sqlite3_declare_vtab // Line 7262
-#define sqlite3_deserialize chrome_sqlite3_deserialize // Lines 10027-10034
-#define sqlite3_drop_modules chrome_sqlite3_drop_modules // Lines 7202-7205
-#define sqlite3_enable_load_extension chrome_sqlite3_enable_load_extension // Line 6846
-#define sqlite3_enable_shared_cache chrome_sqlite3_enable_shared_cache // Line 6578
-#define sqlite3_errcode chrome_sqlite3_errcode // Line 3862
-#define sqlite3_errmsg chrome_sqlite3_errmsg // Line 3864
-#define sqlite3_errmsg16 chrome_sqlite3_errmsg16 // Line 3865
-#define sqlite3_errstr chrome_sqlite3_errstr // Line 3866
+#define sqlite3_db_filename chrome_sqlite3_db_filename // Line 6308
+#define sqlite3_db_handle chrome_sqlite3_db_handle // Line 6276
+#define sqlite3_db_mutex chrome_sqlite3_db_mutex // Line 7892
+#define sqlite3_db_readonly chrome_sqlite3_db_readonly // Line 6318
+#define sqlite3_db_release_memory chrome_sqlite3_db_release_memory // Line 6627
+#define sqlite3_db_status chrome_sqlite3_db_status // Line 8320
+#define sqlite3_declare_vtab chrome_sqlite3_declare_vtab // Line 7313
+#define sqlite3_deserialize chrome_sqlite3_deserialize // Lines 10341-10348
+#define sqlite3_drop_modules chrome_sqlite3_drop_modules // Lines 7253-7256
+#define sqlite3_enable_load_extension chrome_sqlite3_enable_load_extension // Line 6865
+#define sqlite3_enable_shared_cache chrome_sqlite3_enable_shared_cache // Line 6597
+#define sqlite3_errcode chrome_sqlite3_errcode // Line 3870
+#define sqlite3_errmsg chrome_sqlite3_errmsg // Line 3872
+#define sqlite3_errmsg16 chrome_sqlite3_errmsg16 // Line 3873
+#define sqlite3_error_offset chrome_sqlite3_error_offset // Line 3875
+#define sqlite3_errstr chrome_sqlite3_errstr // Line 3874
#define sqlite3_exec chrome_sqlite3_exec // Lines 425-431
-#define sqlite3_expanded_sql chrome_sqlite3_expanded_sql // Line 4231
-#define sqlite3_expired chrome_sqlite3_expired // Line 5405
-#define sqlite3_extended_errcode chrome_sqlite3_extended_errcode // Line 3863
+#define sqlite3_expanded_sql chrome_sqlite3_expanded_sql // Line 4240
+#define sqlite3_expired chrome_sqlite3_expired // Line 5424
+#define sqlite3_extended_errcode chrome_sqlite3_extended_errcode // Line 3871
#define sqlite3_extended_result_codes chrome_sqlite3_extended_result_codes // Line 2427
-#define sqlite3_file_control chrome_sqlite3_file_control // Line 7884
+#define sqlite3_file_control chrome_sqlite3_file_control // Line 7935
#define sqlite3_filename_database chrome_sqlite3_filename_database // Line 3733
#define sqlite3_filename_journal chrome_sqlite3_filename_journal // Line 3734
#define sqlite3_filename_wal chrome_sqlite3_filename_wal // Line 3735
-#define sqlite3_finalize chrome_sqlite3_finalize // Line 5114
+#define sqlite3_finalize chrome_sqlite3_finalize // Line 5133
#define sqlite3_free chrome_sqlite3_free // Line 2969
#define sqlite3_free_filename chrome_sqlite3_free_filename // Line 3808
#define sqlite3_free_table chrome_sqlite3_free_table // Line 2843
-#define sqlite3_get_autocommit chrome_sqlite3_get_autocommit // Line 6244
-#define sqlite3_get_auxdata chrome_sqlite3_get_auxdata // Line 5715
+#define sqlite3_get_autocommit chrome_sqlite3_get_autocommit // Line 6263
+#define sqlite3_get_auxdata chrome_sqlite3_get_auxdata // Line 5734
#define sqlite3_get_table chrome_sqlite3_get_table // Lines 2835-2842
-#define sqlite3_global_recover chrome_sqlite3_global_recover // Line 5407
-#define sqlite3_hard_heap_limit64 chrome_sqlite3_hard_heap_limit64 // Line 6675
+#define sqlite3_global_recover chrome_sqlite3_global_recover // Line 5426
+#define sqlite3_hard_heap_limit64 chrome_sqlite3_hard_heap_limit64 // Line 6694
#define sqlite3_initialize chrome_sqlite3_initialize // Line 1603
#define sqlite3_interrupt chrome_sqlite3_interrupt // Line 2640
-#define sqlite3_keyword_check chrome_sqlite3_keyword_check // Line 7998
-#define sqlite3_keyword_count chrome_sqlite3_keyword_count // Line 7996
-#define sqlite3_keyword_name chrome_sqlite3_keyword_name // Line 7997
+#define sqlite3_keyword_check chrome_sqlite3_keyword_check // Line 8050
+#define sqlite3_keyword_count chrome_sqlite3_keyword_count // Line 8048
+#define sqlite3_keyword_name chrome_sqlite3_keyword_name // Line 8049
#define sqlite3_last_insert_rowid chrome_sqlite3_last_insert_rowid // Line 2489
#define sqlite3_libversion chrome_sqlite3_libversion // Line 186
#define sqlite3_libversion_number chrome_sqlite3_libversion_number // Line 188
-#define sqlite3_limit chrome_sqlite3_limit // Line 3934
-#define sqlite3_load_extension chrome_sqlite3_load_extension // Lines 6814-6819
-#define sqlite3_log chrome_sqlite3_log // Line 9116
+#define sqlite3_limit chrome_sqlite3_limit // Line 3943
+#define sqlite3_load_extension chrome_sqlite3_load_extension // Lines 6833-6838
+#define sqlite3_log chrome_sqlite3_log // Line 9180
#define sqlite3_malloc chrome_sqlite3_malloc // Line 2965
#define sqlite3_malloc64 chrome_sqlite3_malloc64 // Line 2966
-#define sqlite3_memory_alarm chrome_sqlite3_memory_alarm // Lines 5409-5410
+#define sqlite3_memory_alarm chrome_sqlite3_memory_alarm // Lines 5428-5429
#define sqlite3_memory_highwater chrome_sqlite3_memory_highwater // Line 2996
#define sqlite3_memory_used chrome_sqlite3_memory_used // Line 2995
#define sqlite3_mprintf chrome_sqlite3_mprintf // Line 2885
#define sqlite3_msize chrome_sqlite3_msize // Line 2970
-#define sqlite3_mutex_alloc chrome_sqlite3_mutex_alloc // Line 7682
-#define sqlite3_mutex_enter chrome_sqlite3_mutex_enter // Line 7684
-#define sqlite3_mutex_free chrome_sqlite3_mutex_free // Line 7683
-#define sqlite3_mutex_held chrome_sqlite3_mutex_held // Line 7796
-#define sqlite3_mutex_leave chrome_sqlite3_mutex_leave // Line 7686
-#define sqlite3_mutex_notheld chrome_sqlite3_mutex_notheld // Line 7797
-#define sqlite3_mutex_try chrome_sqlite3_mutex_try // Line 7685
-#define sqlite3_next_stmt chrome_sqlite3_next_stmt // Line 6366
-#define sqlite3_normalized_sql chrome_sqlite3_normalized_sql // Line 4233
+#define sqlite3_mutex_alloc chrome_sqlite3_mutex_alloc // Line 7733
+#define sqlite3_mutex_enter chrome_sqlite3_mutex_enter // Line 7735
+#define sqlite3_mutex_free chrome_sqlite3_mutex_free // Line 7734
+#define sqlite3_mutex_held chrome_sqlite3_mutex_held // Line 7847
+#define sqlite3_mutex_leave chrome_sqlite3_mutex_leave // Line 7737
+#define sqlite3_mutex_notheld chrome_sqlite3_mutex_notheld // Line 7848
+#define sqlite3_mutex_try chrome_sqlite3_mutex_try // Line 7736
+#define sqlite3_next_stmt chrome_sqlite3_next_stmt // Line 6385
+#define sqlite3_normalized_sql chrome_sqlite3_normalized_sql // Line 4242
#define sqlite3_open chrome_sqlite3_open // Lines 3620-3623
#define sqlite3_open16 chrome_sqlite3_open16 // Lines 3624-3627
#define sqlite3_open_v2 chrome_sqlite3_open_v2 // Lines 3628-3633
#define sqlite3_os_end chrome_sqlite3_os_end // Line 1606
#define sqlite3_os_init chrome_sqlite3_os_init // Line 1605
-#define sqlite3_overload_function chrome_sqlite3_overload_function // Line 7281
-#define sqlite3_prepare chrome_sqlite3_prepare // Lines 4144-4150
-#define sqlite3_prepare16 chrome_sqlite3_prepare16 // Lines 4166-4172
-#define sqlite3_prepare16_v2 chrome_sqlite3_prepare16_v2 // Lines 4173-4179
-#define sqlite3_prepare16_v3 chrome_sqlite3_prepare16_v3 // Lines 4180-4187
-#define sqlite3_prepare_v2 chrome_sqlite3_prepare_v2 // Lines 4151-4157
-#define sqlite3_prepare_v3 chrome_sqlite3_prepare_v3 // Lines 4158-4165
-#define sqlite3_preupdate_blobwrite chrome_sqlite3_preupdate_blobwrite // Line 9729
-#define sqlite3_preupdate_count chrome_sqlite3_preupdate_count // Line 9726
-#define sqlite3_preupdate_depth chrome_sqlite3_preupdate_depth // Line 9727
-#define sqlite3_preupdate_hook chrome_sqlite3_preupdate_hook // Lines 9712-9724
-#define sqlite3_preupdate_new chrome_sqlite3_preupdate_new // Line 9728
-#define sqlite3_preupdate_old chrome_sqlite3_preupdate_old // Line 9725
+#define sqlite3_overload_function chrome_sqlite3_overload_function // Line 7332
+#define sqlite3_prepare chrome_sqlite3_prepare // Lines 4153-4159
+#define sqlite3_prepare16 chrome_sqlite3_prepare16 // Lines 4175-4181
+#define sqlite3_prepare16_v2 chrome_sqlite3_prepare16_v2 // Lines 4182-4188
+#define sqlite3_prepare16_v3 chrome_sqlite3_prepare16_v3 // Lines 4189-4196
+#define sqlite3_prepare_v2 chrome_sqlite3_prepare_v2 // Lines 4160-4166
+#define sqlite3_prepare_v3 chrome_sqlite3_prepare_v3 // Lines 4167-4174
+#define sqlite3_preupdate_blobwrite chrome_sqlite3_preupdate_blobwrite // Line 10043
+#define sqlite3_preupdate_count chrome_sqlite3_preupdate_count // Line 10040
+#define sqlite3_preupdate_depth chrome_sqlite3_preupdate_depth // Line 10041
+#define sqlite3_preupdate_hook chrome_sqlite3_preupdate_hook // Lines 10026-10038
+#define sqlite3_preupdate_new chrome_sqlite3_preupdate_new // Line 10042
+#define sqlite3_preupdate_old chrome_sqlite3_preupdate_old // Line 10039
#define sqlite3_profile chrome_sqlite3_profile // Lines 3220-3221
#define sqlite3_progress_handler chrome_sqlite3_progress_handler // Line 3348
#define sqlite3_randomness chrome_sqlite3_randomness // Line 3019
#define sqlite3_realloc chrome_sqlite3_realloc // Line 2967
#define sqlite3_realloc64 chrome_sqlite3_realloc64 // Line 2968
-#define sqlite3_release_memory chrome_sqlite3_release_memory // Line 6594
-#define sqlite3_reset chrome_sqlite3_reset // Line 5141
-#define sqlite3_reset_auto_extension chrome_sqlite3_reset_auto_extension // Line 6904
-#define sqlite3_result_blob chrome_sqlite3_result_blob // Line 5883
-#define sqlite3_result_blob64 chrome_sqlite3_result_blob64 // Lines 5884-5885
-#define sqlite3_result_double chrome_sqlite3_result_double // Line 5886
-#define sqlite3_result_error chrome_sqlite3_result_error // Line 5887
-#define sqlite3_result_error16 chrome_sqlite3_result_error16 // Line 5888
-#define sqlite3_result_error_code chrome_sqlite3_result_error_code // Line 5891
-#define sqlite3_result_error_nomem chrome_sqlite3_result_error_nomem // Line 5890
-#define sqlite3_result_error_toobig chrome_sqlite3_result_error_toobig // Line 5889
-#define sqlite3_result_int chrome_sqlite3_result_int // Line 5892
-#define sqlite3_result_int64 chrome_sqlite3_result_int64 // Line 5893
-#define sqlite3_result_null chrome_sqlite3_result_null // Line 5894
-#define sqlite3_result_pointer chrome_sqlite3_result_pointer // Line 5902
-#define sqlite3_result_subtype chrome_sqlite3_result_subtype // Line 5919
-#define sqlite3_result_text chrome_sqlite3_result_text // Line 5895
-#define sqlite3_result_text16 chrome_sqlite3_result_text16 // Line 5898
-#define sqlite3_result_text16be chrome_sqlite3_result_text16be // Line 5900
-#define sqlite3_result_text16le chrome_sqlite3_result_text16le // Line 5899
-#define sqlite3_result_text64 chrome_sqlite3_result_text64 // Lines 5896-5897
-#define sqlite3_result_value chrome_sqlite3_result_value // Line 5901
-#define sqlite3_result_zeroblob chrome_sqlite3_result_zeroblob // Line 5903
-#define sqlite3_result_zeroblob64 chrome_sqlite3_result_zeroblob64 // Line 5904
-#define sqlite3_rollback_hook chrome_sqlite3_rollback_hook // Line 6416
-#define sqlite3_rtree_geometry_callback chrome_sqlite3_rtree_geometry_callback // Lines 10114-10119
-#define sqlite3_rtree_query_callback chrome_sqlite3_rtree_query_callback // Lines 10140-10146
-#define sqlite3_serialize chrome_sqlite3_serialize // Lines 9971-9976
+#define sqlite3_release_memory chrome_sqlite3_release_memory // Line 6613
+#define sqlite3_reset chrome_sqlite3_reset // Line 5160
+#define sqlite3_reset_auto_extension chrome_sqlite3_reset_auto_extension // Line 6923
+#define sqlite3_result_blob chrome_sqlite3_result_blob // Line 5902
+#define sqlite3_result_blob64 chrome_sqlite3_result_blob64 // Lines 5903-5904
+#define sqlite3_result_double chrome_sqlite3_result_double // Line 5905
+#define sqlite3_result_error chrome_sqlite3_result_error // Line 5906
+#define sqlite3_result_error16 chrome_sqlite3_result_error16 // Line 5907
+#define sqlite3_result_error_code chrome_sqlite3_result_error_code // Line 5910
+#define sqlite3_result_error_nomem chrome_sqlite3_result_error_nomem // Line 5909
+#define sqlite3_result_error_toobig chrome_sqlite3_result_error_toobig // Line 5908
+#define sqlite3_result_int chrome_sqlite3_result_int // Line 5911
+#define sqlite3_result_int64 chrome_sqlite3_result_int64 // Line 5912
+#define sqlite3_result_null chrome_sqlite3_result_null // Line 5913
+#define sqlite3_result_pointer chrome_sqlite3_result_pointer // Line 5921
+#define sqlite3_result_subtype chrome_sqlite3_result_subtype // Line 5938
+#define sqlite3_result_text chrome_sqlite3_result_text // Line 5914
+#define sqlite3_result_text16 chrome_sqlite3_result_text16 // Line 5917
+#define sqlite3_result_text16be chrome_sqlite3_result_text16be // Line 5919
+#define sqlite3_result_text16le chrome_sqlite3_result_text16le // Line 5918
+#define sqlite3_result_text64 chrome_sqlite3_result_text64 // Lines 5915-5916
+#define sqlite3_result_value chrome_sqlite3_result_value // Line 5920
+#define sqlite3_result_zeroblob chrome_sqlite3_result_zeroblob // Line 5922
+#define sqlite3_result_zeroblob64 chrome_sqlite3_result_zeroblob64 // Line 5923
+#define sqlite3_rollback_hook chrome_sqlite3_rollback_hook // Line 6435
+#define sqlite3_rtree_geometry_callback chrome_sqlite3_rtree_geometry_callback // Lines 10428-10433
+#define sqlite3_rtree_query_callback chrome_sqlite3_rtree_query_callback // Lines 10454-10460
+#define sqlite3_serialize chrome_sqlite3_serialize // Lines 10285-10290
#define sqlite3_set_authorizer chrome_sqlite3_set_authorizer // Lines 3110-3114
-#define sqlite3_set_auxdata chrome_sqlite3_set_auxdata // Line 5716
+#define sqlite3_set_auxdata chrome_sqlite3_set_auxdata // Line 5735
#define sqlite3_set_last_insert_rowid chrome_sqlite3_set_last_insert_rowid // Line 2499
#define sqlite3_shutdown chrome_sqlite3_shutdown // Line 1604
-#define sqlite3_sleep chrome_sqlite3_sleep // Line 6090
-#define sqlite3_snapshot_cmp chrome_sqlite3_snapshot_cmp // Lines 9905-9908
-#define sqlite3_snapshot_free chrome_sqlite3_snapshot_free // Line 9878
-#define sqlite3_snapshot_get chrome_sqlite3_snapshot_get // Lines 9812-9816
-#define sqlite3_snapshot_open chrome_sqlite3_snapshot_open // Lines 9861-9865
-#define sqlite3_snapshot_recover chrome_sqlite3_snapshot_recover // Line 9933
+#define sqlite3_sleep chrome_sqlite3_sleep // Line 6109
+#define sqlite3_snapshot_cmp chrome_sqlite3_snapshot_cmp // Lines 10219-10222
+#define sqlite3_snapshot_free chrome_sqlite3_snapshot_free // Line 10192
+#define sqlite3_snapshot_get chrome_sqlite3_snapshot_get // Lines 10126-10130
+#define sqlite3_snapshot_open chrome_sqlite3_snapshot_open // Lines 10175-10179
+#define sqlite3_snapshot_recover chrome_sqlite3_snapshot_recover // Line 10247
#define sqlite3_snprintf chrome_sqlite3_snprintf // Line 2887
-#define sqlite3_soft_heap_limit chrome_sqlite3_soft_heap_limit // Line 6686
-#define sqlite3_soft_heap_limit64 chrome_sqlite3_soft_heap_limit64 // Line 6674
+#define sqlite3_soft_heap_limit chrome_sqlite3_soft_heap_limit // Line 6705
+#define sqlite3_soft_heap_limit64 chrome_sqlite3_soft_heap_limit64 // Line 6693
#define sqlite3_sourceid chrome_sqlite3_sourceid // Line 187
-#define sqlite3_sql chrome_sqlite3_sql // Line 4230
-#define sqlite3_status chrome_sqlite3_status // Line 8158
-#define sqlite3_status64 chrome_sqlite3_status64 // Lines 8159-8164
-#define sqlite3_step chrome_sqlite3_step // Line 4813
-#define sqlite3_stmt_busy chrome_sqlite3_stmt_busy // Line 4312
-#define sqlite3_stmt_isexplain chrome_sqlite3_stmt_isexplain // Line 4291
-#define sqlite3_stmt_readonly chrome_sqlite3_stmt_readonly // Line 4279
-#define sqlite3_stmt_scanstatus chrome_sqlite3_stmt_scanstatus // Lines 9568-9573
-#define sqlite3_stmt_scanstatus_reset chrome_sqlite3_stmt_scanstatus_reset // Line 9584
-#define sqlite3_stmt_status chrome_sqlite3_stmt_status // Line 8421
-#define sqlite3_str_append chrome_sqlite3_str_append // Line 8094
-#define sqlite3_str_appendall chrome_sqlite3_str_appendall // Line 8095
-#define sqlite3_str_appendchar chrome_sqlite3_str_appendchar // Line 8096
-#define sqlite3_str_appendf chrome_sqlite3_str_appendf // Line 8092
-#define sqlite3_str_errcode chrome_sqlite3_str_errcode // Line 8128
-#define sqlite3_str_finish chrome_sqlite3_str_finish // Line 8058
-#define sqlite3_str_length chrome_sqlite3_str_length // Line 8129
-#define sqlite3_str_new chrome_sqlite3_str_new // Line 8043
-#define sqlite3_str_reset chrome_sqlite3_str_reset // Line 8097
-#define sqlite3_str_value chrome_sqlite3_str_value // Line 8130
-#define sqlite3_str_vappendf chrome_sqlite3_str_vappendf // Line 8093
-#define sqlite3_strglob chrome_sqlite3_strglob // Line 9070
-#define sqlite3_stricmp chrome_sqlite3_stricmp // Line 9052
-#define sqlite3_strlike chrome_sqlite3_strlike // Line 9093
-#define sqlite3_strnicmp chrome_sqlite3_strnicmp // Line 9053
-#define sqlite3_system_errno chrome_sqlite3_system_errno // Line 9743
-#define sqlite3_table_column_metadata chrome_sqlite3_table_column_metadata // Lines 6758-6768
-#define sqlite3_temp_directory chrome_sqlite3_temp_directory // Line 6148
-#define sqlite3_test_control chrome_sqlite3_test_control // Line 7903
-#define sqlite3_thread_cleanup chrome_sqlite3_thread_cleanup // Line 5408
+#define sqlite3_sql chrome_sqlite3_sql // Line 4239
+#define sqlite3_status chrome_sqlite3_status // Line 8210
+#define sqlite3_status64 chrome_sqlite3_status64 // Lines 8211-8216
+#define sqlite3_step chrome_sqlite3_step // Line 4828
+#define sqlite3_stmt_busy chrome_sqlite3_stmt_busy // Line 4325
+#define sqlite3_stmt_isexplain chrome_sqlite3_stmt_isexplain // Line 4304
+#define sqlite3_stmt_readonly chrome_sqlite3_stmt_readonly // Line 4292
+#define sqlite3_stmt_scanstatus chrome_sqlite3_stmt_scanstatus // Lines 9882-9887
+#define sqlite3_stmt_scanstatus_reset chrome_sqlite3_stmt_scanstatus_reset // Line 9898
+#define sqlite3_stmt_status chrome_sqlite3_stmt_status // Line 8473
+#define sqlite3_str_append chrome_sqlite3_str_append // Line 8146
+#define sqlite3_str_appendall chrome_sqlite3_str_appendall // Line 8147
+#define sqlite3_str_appendchar chrome_sqlite3_str_appendchar // Line 8148
+#define sqlite3_str_appendf chrome_sqlite3_str_appendf // Line 8144
+#define sqlite3_str_errcode chrome_sqlite3_str_errcode // Line 8180
+#define sqlite3_str_finish chrome_sqlite3_str_finish // Line 8110
+#define sqlite3_str_length chrome_sqlite3_str_length // Line 8181
+#define sqlite3_str_new chrome_sqlite3_str_new // Line 8095
+#define sqlite3_str_reset chrome_sqlite3_str_reset // Line 8149
+#define sqlite3_str_value chrome_sqlite3_str_value // Line 8182
+#define sqlite3_str_vappendf chrome_sqlite3_str_vappendf // Line 8145
+#define sqlite3_strglob chrome_sqlite3_strglob // Line 9134
+#define sqlite3_stricmp chrome_sqlite3_stricmp // Line 9116
+#define sqlite3_strlike chrome_sqlite3_strlike // Line 9157
+#define sqlite3_strnicmp chrome_sqlite3_strnicmp // Line 9117
+#define sqlite3_system_errno chrome_sqlite3_system_errno // Line 10057
+#define sqlite3_table_column_metadata chrome_sqlite3_table_column_metadata // Lines 6777-6787
+#define sqlite3_temp_directory chrome_sqlite3_temp_directory // Line 6167
+#define sqlite3_test_control chrome_sqlite3_test_control // Line 7954
+#define sqlite3_thread_cleanup chrome_sqlite3_thread_cleanup // Line 5427
#define sqlite3_threadsafe chrome_sqlite3_threadsafe // Line 256
#define sqlite3_total_changes chrome_sqlite3_total_changes // Line 2602
#define sqlite3_total_changes64 chrome_sqlite3_total_changes64 // Line 2603
#define sqlite3_trace chrome_sqlite3_trace // Lines 3218-3219
#define sqlite3_trace_v2 chrome_sqlite3_trace_v2 // Lines 3309-3314
-#define sqlite3_transfer_bindings chrome_sqlite3_transfer_bindings // Line 5406
-#define sqlite3_txn_state chrome_sqlite3_txn_state // Line 6317
-#define sqlite3_unlock_notify chrome_sqlite3_unlock_notify // Lines 9037-9041
-#define sqlite3_update_hook chrome_sqlite3_update_hook // Lines 6533-6537
+#define sqlite3_transfer_bindings chrome_sqlite3_transfer_bindings // Line 5425
+#define sqlite3_txn_state chrome_sqlite3_txn_state // Line 6336
+#define sqlite3_unlock_notify chrome_sqlite3_unlock_notify // Lines 9101-9105
+#define sqlite3_update_hook chrome_sqlite3_update_hook // Lines 6552-6556
#define sqlite3_uri_boolean chrome_sqlite3_uri_boolean // Line 3702
#define sqlite3_uri_int64 chrome_sqlite3_uri_int64 // Line 3703
#define sqlite3_uri_key chrome_sqlite3_uri_key // Line 3704
#define sqlite3_uri_parameter chrome_sqlite3_uri_parameter // Line 3701
-#define sqlite3_user_data chrome_sqlite3_user_data // Line 5644
-#define sqlite3_value_blob chrome_sqlite3_value_blob // Line 5541
-#define sqlite3_value_bytes chrome_sqlite3_value_bytes // Line 5550
-#define sqlite3_value_bytes16 chrome_sqlite3_value_bytes16 // Line 5551
-#define sqlite3_value_double chrome_sqlite3_value_double // Line 5542
-#define sqlite3_value_dup chrome_sqlite3_value_dup // Line 5583
-#define sqlite3_value_free chrome_sqlite3_value_free // Line 5584
-#define sqlite3_value_frombind chrome_sqlite3_value_frombind // Line 5555
-#define sqlite3_value_int chrome_sqlite3_value_int // Line 5543
-#define sqlite3_value_int64 chrome_sqlite3_value_int64 // Line 5544
-#define sqlite3_value_nochange chrome_sqlite3_value_nochange // Line 5554
-#define sqlite3_value_numeric_type chrome_sqlite3_value_numeric_type // Line 5553
-#define sqlite3_value_pointer chrome_sqlite3_value_pointer // Line 5545
-#define sqlite3_value_subtype chrome_sqlite3_value_subtype // Line 5567
-#define sqlite3_value_text chrome_sqlite3_value_text // Line 5546
-#define sqlite3_value_text16 chrome_sqlite3_value_text16 // Line 5547
-#define sqlite3_value_text16be chrome_sqlite3_value_text16be // Line 5549
-#define sqlite3_value_text16le chrome_sqlite3_value_text16le // Line 5548
-#define sqlite3_value_type chrome_sqlite3_value_type // Line 5552
+#define sqlite3_user_data chrome_sqlite3_user_data // Line 5663
+#define sqlite3_value_blob chrome_sqlite3_value_blob // Line 5560
+#define sqlite3_value_bytes chrome_sqlite3_value_bytes // Line 5569
+#define sqlite3_value_bytes16 chrome_sqlite3_value_bytes16 // Line 5570
+#define sqlite3_value_double chrome_sqlite3_value_double // Line 5561
+#define sqlite3_value_dup chrome_sqlite3_value_dup // Line 5602
+#define sqlite3_value_free chrome_sqlite3_value_free // Line 5603
+#define sqlite3_value_frombind chrome_sqlite3_value_frombind // Line 5574
+#define sqlite3_value_int chrome_sqlite3_value_int // Line 5562
+#define sqlite3_value_int64 chrome_sqlite3_value_int64 // Line 5563
+#define sqlite3_value_nochange chrome_sqlite3_value_nochange // Line 5573
+#define sqlite3_value_numeric_type chrome_sqlite3_value_numeric_type // Line 5572
+#define sqlite3_value_pointer chrome_sqlite3_value_pointer // Line 5564
+#define sqlite3_value_subtype chrome_sqlite3_value_subtype // Line 5586
+#define sqlite3_value_text chrome_sqlite3_value_text // Line 5565
+#define sqlite3_value_text16 chrome_sqlite3_value_text16 // Line 5566
+#define sqlite3_value_text16be chrome_sqlite3_value_text16be // Line 5568
+#define sqlite3_value_text16le chrome_sqlite3_value_text16le // Line 5567
+#define sqlite3_value_type chrome_sqlite3_value_type // Line 5571
#define sqlite3_version chrome_sqlite3_version // Line 185
-#define sqlite3_vfs_find chrome_sqlite3_vfs_find // Line 7564
-#define sqlite3_vfs_register chrome_sqlite3_vfs_register // Line 7565
-#define sqlite3_vfs_unregister chrome_sqlite3_vfs_unregister // Line 7566
+#define sqlite3_vfs_find chrome_sqlite3_vfs_find // Line 7615
+#define sqlite3_vfs_register chrome_sqlite3_vfs_register // Line 7616
+#define sqlite3_vfs_unregister chrome_sqlite3_vfs_unregister // Line 7617
#define sqlite3_vmprintf chrome_sqlite3_vmprintf // Line 2886
#define sqlite3_vsnprintf chrome_sqlite3_vsnprintf // Line 2888
-#define sqlite3_vtab_collation chrome_sqlite3_vtab_collation // Line 9463
-#define sqlite3_vtab_config chrome_sqlite3_vtab_config // Line 9344
-#define sqlite3_vtab_nochange chrome_sqlite3_vtab_nochange // Line 9448
-#define sqlite3_vtab_on_conflict chrome_sqlite3_vtab_on_conflict // Line 9422
-#define sqlite3_wal_autocheckpoint chrome_sqlite3_wal_autocheckpoint // Line 9188
-#define sqlite3_wal_checkpoint chrome_sqlite3_wal_checkpoint // Line 9210
-#define sqlite3_wal_checkpoint_v2 chrome_sqlite3_wal_checkpoint_v2 // Lines 9304-9310
-#define sqlite3_wal_hook chrome_sqlite3_wal_hook // Lines 9153-9157
-#define sqlite3_win32_set_directory chrome_sqlite3_win32_set_directory // Lines 6206-6209
-#define sqlite3_win32_set_directory16 chrome_sqlite3_win32_set_directory16 // Line 6211
-#define sqlite3_win32_set_directory8 chrome_sqlite3_win32_set_directory8 // Line 6210
-#define sqlite3changegroup_add chrome_sqlite3changegroup_add // Line 11188
-#define sqlite3changegroup_add_strm chrome_sqlite3changegroup_add_strm // Lines 11850-11853
-#define sqlite3changegroup_delete chrome_sqlite3changegroup_delete // Line 11225
-#define sqlite3changegroup_new chrome_sqlite3changegroup_new // Line 11110
-#define sqlite3changegroup_output chrome_sqlite3changegroup_output // Lines 11215-11219
-#define sqlite3changegroup_output_strm chrome_sqlite3changegroup_output_strm // Lines 11854-11857
-#define sqlite3changeset_apply chrome_sqlite3changeset_apply // Lines 11385-11399
-#define sqlite3changeset_apply_strm chrome_sqlite3changeset_apply_strm // Lines 11783-11797
-#define sqlite3changeset_apply_v2 chrome_sqlite3changeset_apply_v2 // Lines 11400-11416
-#define sqlite3changeset_apply_v2_strm chrome_sqlite3changeset_apply_v2_strm // Lines 11798-11814
-#define sqlite3changeset_concat chrome_sqlite3changeset_concat // Lines 11056-11063
-#define sqlite3changeset_concat_strm chrome_sqlite3changeset_concat_strm // Lines 11815-11822
-#define sqlite3changeset_conflict chrome_sqlite3changeset_conflict // Lines 10942-10946
-#define sqlite3changeset_finalize chrome_sqlite3changeset_finalize // Line 10995
-#define sqlite3changeset_fk_conflicts chrome_sqlite3changeset_fk_conflicts // Lines 10959-10962
-#define sqlite3changeset_invert chrome_sqlite3changeset_invert // Lines 11025-11028
-#define sqlite3changeset_invert_strm chrome_sqlite3changeset_invert_strm // Lines 11823-11828
-#define sqlite3changeset_new chrome_sqlite3changeset_new // Lines 10914-10918
-#define sqlite3changeset_next chrome_sqlite3changeset_next // Line 10781
-#define sqlite3changeset_old chrome_sqlite3changeset_old // Lines 10880-10884
-#define sqlite3changeset_op chrome_sqlite3changeset_op // Lines 10815-10821
-#define sqlite3changeset_pk chrome_sqlite3changeset_pk // Lines 10849-10853
-#define sqlite3changeset_start chrome_sqlite3changeset_start // Lines 10732-10736
-#define sqlite3changeset_start_strm chrome_sqlite3changeset_start_strm // Lines 11829-11833
-#define sqlite3changeset_start_v2 chrome_sqlite3changeset_start_v2 // Lines 10737-10742
-#define sqlite3changeset_start_v2_strm chrome_sqlite3changeset_start_v2_strm // Lines 11834-11839
-#define sqlite3rebaser_configure chrome_sqlite3rebaser_configure // Lines 11658-11661
-#define sqlite3rebaser_create chrome_sqlite3rebaser_create // Line 11647
-#define sqlite3rebaser_delete chrome_sqlite3rebaser_delete // Line 11691
-#define sqlite3rebaser_rebase chrome_sqlite3rebaser_rebase // Lines 11677-11681
-#define sqlite3rebaser_rebase_strm chrome_sqlite3rebaser_rebase_strm // Lines 11858-11864
-#define sqlite3session_attach chrome_sqlite3session_attach // Lines 10415-10418
-#define sqlite3session_changeset chrome_sqlite3session_changeset // Lines 10544-10548
-#define sqlite3session_changeset_size chrome_sqlite3session_changeset_size // Line 10564
-#define sqlite3session_changeset_strm chrome_sqlite3session_changeset_strm // Lines 11840-11844
-#define sqlite3session_config chrome_sqlite3session_config // Line 11899
-#define sqlite3session_create chrome_sqlite3session_create // Lines 10253-10257
-#define sqlite3session_delete chrome_sqlite3session_delete // Line 10272
-#define sqlite3session_diff chrome_sqlite3session_diff // Lines 10623-10628
-#define sqlite3session_enable chrome_sqlite3session_enable // Line 10325
-#define sqlite3session_indirect chrome_sqlite3session_indirect // Line 10355
-#define sqlite3session_isempty chrome_sqlite3session_isempty // Line 10681
-#define sqlite3session_memory_used chrome_sqlite3session_memory_used // Line 10689
-#define sqlite3session_object_config chrome_sqlite3session_object_config // Line 10301
-#define sqlite3session_patchset chrome_sqlite3session_patchset // Lines 10660-10664
-#define sqlite3session_patchset_strm chrome_sqlite3session_patchset_strm // Lines 11845-11849
-#define sqlite3session_table_filter chrome_sqlite3session_table_filter // Lines 10430-10437
+#define sqlite3_vtab_collation chrome_sqlite3_vtab_collation // Line 9547
+#define sqlite3_vtab_config chrome_sqlite3_vtab_config // Line 9408
+#define sqlite3_vtab_distinct chrome_sqlite3_vtab_distinct // Line 9613
+#define sqlite3_vtab_in chrome_sqlite3_vtab_in // Line 9686
+#define sqlite3_vtab_in_first chrome_sqlite3_vtab_in_first // Line 9734
+#define sqlite3_vtab_in_next chrome_sqlite3_vtab_in_next // Line 9735
+#define sqlite3_vtab_nochange chrome_sqlite3_vtab_nochange // Line 9512
+#define sqlite3_vtab_on_conflict chrome_sqlite3_vtab_on_conflict // Line 9486
+#define sqlite3_vtab_rhs_value chrome_sqlite3_vtab_rhs_value // Line 9777
+#define sqlite3_wal_autocheckpoint chrome_sqlite3_wal_autocheckpoint // Line 9252
+#define sqlite3_wal_checkpoint chrome_sqlite3_wal_checkpoint // Line 9274
+#define sqlite3_wal_checkpoint_v2 chrome_sqlite3_wal_checkpoint_v2 // Lines 9368-9374
+#define sqlite3_wal_hook chrome_sqlite3_wal_hook // Lines 9217-9221
+#define sqlite3_win32_set_directory chrome_sqlite3_win32_set_directory // Lines 6225-6228
+#define sqlite3_win32_set_directory16 chrome_sqlite3_win32_set_directory16 // Line 6230
+#define sqlite3_win32_set_directory8 chrome_sqlite3_win32_set_directory8 // Line 6229
+#define sqlite3changegroup_add chrome_sqlite3changegroup_add // Line 11502
+#define sqlite3changegroup_add_strm chrome_sqlite3changegroup_add_strm // Lines 12164-12167
+#define sqlite3changegroup_delete chrome_sqlite3changegroup_delete // Line 11539
+#define sqlite3changegroup_new chrome_sqlite3changegroup_new // Line 11424
+#define sqlite3changegroup_output chrome_sqlite3changegroup_output // Lines 11529-11533
+#define sqlite3changegroup_output_strm chrome_sqlite3changegroup_output_strm // Lines 12168-12171
+#define sqlite3changeset_apply chrome_sqlite3changeset_apply // Lines 11699-11713
+#define sqlite3changeset_apply_strm chrome_sqlite3changeset_apply_strm // Lines 12097-12111
+#define sqlite3changeset_apply_v2 chrome_sqlite3changeset_apply_v2 // Lines 11714-11730
+#define sqlite3changeset_apply_v2_strm chrome_sqlite3changeset_apply_v2_strm // Lines 12112-12128
+#define sqlite3changeset_concat chrome_sqlite3changeset_concat // Lines 11370-11377
+#define sqlite3changeset_concat_strm chrome_sqlite3changeset_concat_strm // Lines 12129-12136
+#define sqlite3changeset_conflict chrome_sqlite3changeset_conflict // Lines 11256-11260
+#define sqlite3changeset_finalize chrome_sqlite3changeset_finalize // Line 11309
+#define sqlite3changeset_fk_conflicts chrome_sqlite3changeset_fk_conflicts // Lines 11273-11276
+#define sqlite3changeset_invert chrome_sqlite3changeset_invert // Lines 11339-11342
+#define sqlite3changeset_invert_strm chrome_sqlite3changeset_invert_strm // Lines 12137-12142
+#define sqlite3changeset_new chrome_sqlite3changeset_new // Lines 11228-11232
+#define sqlite3changeset_next chrome_sqlite3changeset_next // Line 11095
+#define sqlite3changeset_old chrome_sqlite3changeset_old // Lines 11194-11198
+#define sqlite3changeset_op chrome_sqlite3changeset_op // Lines 11129-11135
+#define sqlite3changeset_pk chrome_sqlite3changeset_pk // Lines 11163-11167
+#define sqlite3changeset_start chrome_sqlite3changeset_start // Lines 11046-11050
+#define sqlite3changeset_start_strm chrome_sqlite3changeset_start_strm // Lines 12143-12147
+#define sqlite3changeset_start_v2 chrome_sqlite3changeset_start_v2 // Lines 11051-11056
+#define sqlite3changeset_start_v2_strm chrome_sqlite3changeset_start_v2_strm // Lines 12148-12153
+#define sqlite3rebaser_configure chrome_sqlite3rebaser_configure // Lines 11972-11975
+#define sqlite3rebaser_create chrome_sqlite3rebaser_create // Line 11961
+#define sqlite3rebaser_delete chrome_sqlite3rebaser_delete // Line 12005
+#define sqlite3rebaser_rebase chrome_sqlite3rebaser_rebase // Lines 11991-11995
+#define sqlite3rebaser_rebase_strm chrome_sqlite3rebaser_rebase_strm // Lines 12172-12178
+#define sqlite3session_attach chrome_sqlite3session_attach // Lines 10729-10732
+#define sqlite3session_changeset chrome_sqlite3session_changeset // Lines 10858-10862
+#define sqlite3session_changeset_size chrome_sqlite3session_changeset_size // Line 10878
+#define sqlite3session_changeset_strm chrome_sqlite3session_changeset_strm // Lines 12154-12158
+#define sqlite3session_config chrome_sqlite3session_config // Line 12213
+#define sqlite3session_create chrome_sqlite3session_create // Lines 10567-10571
+#define sqlite3session_delete chrome_sqlite3session_delete // Line 10586
+#define sqlite3session_diff chrome_sqlite3session_diff // Lines 10937-10942
+#define sqlite3session_enable chrome_sqlite3session_enable // Line 10639
+#define sqlite3session_indirect chrome_sqlite3session_indirect // Line 10669
+#define sqlite3session_isempty chrome_sqlite3session_isempty // Line 10995
+#define sqlite3session_memory_used chrome_sqlite3session_memory_used // Line 11003
+#define sqlite3session_object_config chrome_sqlite3session_object_config // Line 10615
+#define sqlite3session_patchset chrome_sqlite3session_patchset // Lines 10974-10978
+#define sqlite3session_patchset_strm chrome_sqlite3session_patchset_strm // Lines 12159-12163
+#define sqlite3session_table_filter chrome_sqlite3session_table_filter // Lines 10744-10751
#endif // THIRD_PARTY_SQLITE_AMALGAMATION_RENAME_EXPORTS_H_
diff --git a/chromium/third_party/sqlite/src/amalgamation/shell/shell.c b/chromium/third_party/sqlite/src/amalgamation/shell/shell.c
index 26c0ae57174..cf830f13f5a 100644
--- a/chromium/third_party/sqlite/src/amalgamation/shell/shell.c
+++ b/chromium/third_party/sqlite/src/amalgamation/shell/shell.c
@@ -41,10 +41,10 @@
** If SQLITE_CUSTOM_INCLUDE=? is defined, its value names the #include
** file. Note that this macro has a like effect on sqlite3.c compilation.
*/
+# define SHELL_STRINGIFY_(f) #f
+# define SHELL_STRINGIFY(f) SHELL_STRINGIFY_(f)
#ifdef SQLITE_CUSTOM_INCLUDE
-# define INC_STRINGIFY_(f) #f
-# define INC_STRINGIFY(f) INC_STRINGIFY_(f)
-# include INC_STRINGIFY(SQLITE_CUSTOM_INCLUDE)
+# include SHELL_STRINGIFY(SQLITE_CUSTOM_INCLUDE)
#endif
/*
@@ -445,15 +445,6 @@ static sqlite3 *globalDb = 0;
*/
static volatile int seenInterrupt = 0;
-#ifdef SQLITE_DEBUG
-/*
-** Out-of-memory simulator variables
-*/
-static unsigned int oomCounter = 0; /* Simulate OOM when equals 1 */
-static unsigned int oomRepeat = 0; /* Number of OOMs in a row */
-static void*(*defaultMalloc)(int) = 0; /* The low-level malloc routine */
-#endif /* SQLITE_DEBUG */
-
/*
** This is the name of our program. It is set in main(), used
** in a number of other places, mostly for error messages.
@@ -505,48 +496,12 @@ static void shell_out_of_memory(void){
exit(1);
}
-#ifdef SQLITE_DEBUG
-/* This routine is called when a simulated OOM occurs. It is broken
-** out as a separate routine to make it easy to set a breakpoint on
-** the OOM
-*/
-void shellOomFault(void){
- if( oomRepeat>0 ){
- oomRepeat--;
- }else{
- oomCounter--;
- }
-}
-#endif /* SQLITE_DEBUG */
-
-#ifdef SQLITE_DEBUG
-/* This routine is a replacement malloc() that is used to simulate
-** Out-Of-Memory (OOM) errors for testing purposes.
+/* Check a pointer to see if it is NULL. If it is NULL, exit with an
+** out-of-memory error.
*/
-static void *oomMalloc(int nByte){
- if( oomCounter ){
- if( oomCounter==1 ){
- shellOomFault();
- return 0;
- }else{
- oomCounter--;
- }
- }
- return defaultMalloc(nByte);
-}
-#endif /* SQLITE_DEBUG */
-
-#ifdef SQLITE_DEBUG
-/* Register the OOM simulator. This must occur before any memory
-** allocations */
-static void registerOomSimulator(void){
- sqlite3_mem_methods mem;
- sqlite3_config(SQLITE_CONFIG_GETMALLOC, &mem);
- defaultMalloc = mem.xMalloc;
- mem.xMalloc = oomMalloc;
- sqlite3_config(SQLITE_CONFIG_MALLOC, &mem);
+static void shell_check_oom(void *p){
+ if( p==0 ) shell_out_of_memory();
}
-#endif
/*
** Write I/O traces to the following stream.
@@ -703,7 +658,7 @@ static char *local_getline(char *zLine, FILE *in){
if( n+100>nLine ){
nLine = nLine*2 + 100;
zLine = realloc(zLine, nLine);
- if( zLine==0 ) shell_out_of_memory();
+ shell_check_oom(zLine);
}
if( fgets(&zLine[n], nLine - n, in)==0 ){
if( n==0 ){
@@ -730,7 +685,7 @@ static char *local_getline(char *zLine, FILE *in){
int nTrans = strlen30(zTrans)+1;
if( nTrans>nLine ){
zLine = realloc(zLine, nTrans);
- if( zLine==0 ) shell_out_of_memory();
+ shell_check_oom(zLine);
}
memcpy(zLine, zTrans, nTrans);
sqlite3_free(zTrans);
@@ -877,7 +832,7 @@ static void appendText(ShellText *p, char const *zAppend, char quote){
if( p->z==0 || p->n+len>=p->nAlloc ){
p->nAlloc = p->nAlloc*2 + len + 20;
p->z = realloc(p->z, p->nAlloc);
- if( p->z==0 ) shell_out_of_memory();
+ shell_check_oom(p->z);
}
if( quote ){
@@ -932,6 +887,7 @@ static char *shellFakeSchema(
zSql = sqlite3_mprintf("PRAGMA \"%w\".table_info=%Q;",
zSchema ? zSchema : "main", zName);
+ shell_check_oom(zSql);
sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);
sqlite3_free(zSql);
initText(&s);
@@ -948,6 +904,7 @@ static char *shellFakeSchema(
nRow++;
appendText(&s, zDiv, 0);
zDiv = ",";
+ if( zCol==0 ) zCol = "";
cQuote = quoteChar(zCol);
appendText(&s, zCol, cQuote);
}
@@ -971,9 +928,11 @@ static void shellModuleSchema(
int nVal,
sqlite3_value **apVal
){
- const char *zName = (const char*)sqlite3_value_text(apVal[0]);
- char *zFake = shellFakeSchema(sqlite3_context_db_handle(pCtx), 0, zName);
+ const char *zName;
+ char *zFake;
UNUSED_PARAMETER(nVal);
+ zName = (const char*)sqlite3_value_text(apVal[0]);
+ zFake = zName ? shellFakeSchema(sqlite3_context_db_handle(pCtx), 0, zName) : 0;
if( zFake ){
sqlite3_result_text(pCtx, sqlite3_mprintf("/* %s */", zFake),
-1, sqlite3_free);
@@ -1861,6 +1820,7 @@ static void SHA3Update(
unsigned int nData
){
unsigned int i = 0;
+ if( aData==0 ) return;
#if SHA3_BYTEORDER==1234
if( (p->nLoaded % 8)==0 && ((aData - (const unsigned char*)0)&7)==0 ){
for(; i+7<nData; i+=8){
@@ -2519,10 +2479,11 @@ static int writeFile(
mode_t mode, /* MODE parameter passed to writefile() */
sqlite3_int64 mtime /* MTIME parameter (or -1 to not set time) */
){
+ if( zFile==0 ) return 1;
#if !defined(_WIN32) && !defined(WIN32)
if( S_ISLNK(mode) ){
const char *zTo = (const char*)sqlite3_value_text(pData);
- if( symlink(zTo, zFile)<0 ) return 1;
+ if( zTo==0 || symlink(zTo, zFile)<0 ) return 1;
}else
#endif
{
@@ -5490,7 +5451,7 @@ int sqlite3_ieee_init(
SQLITE_EXTENSION_INIT2(pApi);
(void)pzErrMsg; /* Unused parameter */
for(i=0; i<sizeof(aFunc)/sizeof(aFunc[0]) && rc==SQLITE_OK; i++){
- rc = sqlite3_create_function(db, aFunc[i].zFName, aFunc[i].nArg,
+ rc = sqlite3_create_function(db, aFunc[i].zFName, aFunc[i].nArg,
SQLITE_UTF8|SQLITE_INNOCUOUS,
(void*)&aFunc[i].iAux,
aFunc[i].xFunc, 0, 0);
@@ -5888,7 +5849,7 @@ static int seriesBestIndex(
** the preferred case */
pIdxInfo->estimatedCost = (double)(2 - ((idxNum&4)!=0));
pIdxInfo->estimatedRows = 1000;
- if( pIdxInfo->nOrderBy==1 ){
+ if( pIdxInfo->nOrderBy>=1 && pIdxInfo->aOrderBy[0].iColumn==0 ){
if( pIdxInfo->aOrderBy[0].desc ){
idxNum |= 8;
}else{
@@ -6723,13 +6684,15 @@ int sqlite3_regexp_init(
int rc = SQLITE_OK;
SQLITE_EXTENSION_INIT2(pApi);
(void)pzErrMsg; /* Unused */
- rc = sqlite3_create_function(db, "regexp", 2, SQLITE_UTF8|SQLITE_INNOCUOUS,
- 0, re_sql_func, 0, 0);
+ rc = sqlite3_create_function(db, "regexp", 2,
+ SQLITE_UTF8|SQLITE_INNOCUOUS|SQLITE_DETERMINISTIC,
+ 0, re_sql_func, 0, 0);
if( rc==SQLITE_OK ){
/* The regexpi(PATTERN,STRING) function is a case-insensitive version
** of regexp(PATTERN,STRING). */
- rc = sqlite3_create_function(db, "regexpi", 2, SQLITE_UTF8|SQLITE_INNOCUOUS,
- (void*)db, re_sql_func, 0, 0);
+ rc = sqlite3_create_function(db, "regexpi", 2,
+ SQLITE_UTF8|SQLITE_INNOCUOUS|SQLITE_DETERMINISTIC,
+ (void*)db, re_sql_func, 0, 0);
}
return rc;
}
@@ -8677,7 +8640,7 @@ static int zipfileBufferGrow(ZipfileBuffer *pBuf, int nByte){
** SELECT zipfile(name,mode,mtime,data) ...
** SELECT zipfile(name,mode,mtime,data,method) ...
*/
-void zipfileStep(sqlite3_context *pCtx, int nVal, sqlite3_value **apVal){
+static void zipfileStep(sqlite3_context *pCtx, int nVal, sqlite3_value **apVal){
ZipfileCtx *p; /* Aggregate function context */
ZipfileEntry e; /* New entry to add to zip archive */
@@ -8852,7 +8815,7 @@ void zipfileStep(sqlite3_context *pCtx, int nVal, sqlite3_value **apVal){
/*
** xFinalize() callback for zipfile aggregate function.
*/
-void zipfileFinal(sqlite3_context *pCtx){
+static void zipfileFinal(sqlite3_context *pCtx){
ZipfileCtx *p;
ZipfileEOCD eocd;
sqlite3_int64 nZip;
@@ -9941,17 +9904,25 @@ static int idxGetTableInfo(
){
sqlite3_stmt *p1 = 0;
int nCol = 0;
- int nTab = STRLEN(zTab);
- int nByte = sizeof(IdxTable) + nTab + 1;
+ int nTab;
+ int nByte;
IdxTable *pNew = 0;
int rc, rc2;
char *pCsr = 0;
int nPk = 0;
+ *ppOut = 0;
+ if( zTab==0 ) return SQLITE_ERROR;
+ nTab = STRLEN(zTab);
+ nByte = sizeof(IdxTable) + nTab + 1;
rc = idxPrintfPrepareStmt(db, &p1, pzErrmsg, "PRAGMA table_xinfo=%Q", zTab);
while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(p1) ){
const char *zCol = (const char*)sqlite3_column_text(p1, 1);
const char *zColSeq = 0;
+ if( zCol==0 ){
+ rc = SQLITE_ERROR;
+ break;
+ }
nByte += 1 + STRLEN(zCol);
rc = sqlite3_table_column_metadata(
db, "main", zTab, zCol, 0, &zColSeq, 0, 0, 0
@@ -9978,7 +9949,9 @@ static int idxGetTableInfo(
while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(p1) ){
const char *zCol = (const char*)sqlite3_column_text(p1, 1);
const char *zColSeq = 0;
- int nCopy = STRLEN(zCol) + 1;
+ int nCopy;
+ if( zCol==0 ) continue;
+ nCopy = STRLEN(zCol) + 1;
pNew->aCol[nCol].zName = pCsr;
pNew->aCol[nCol].iPk = (sqlite3_column_int(p1, 5)==1 && nPk==1);
memcpy(pCsr, zCol, nCopy);
@@ -10130,6 +10103,7 @@ static int idxFindCompatible(
IdxConstraint *pT = pTail;
sqlite3_stmt *pInfo = 0;
const char *zIdx = (const char*)sqlite3_column_text(pIdxList, 1);
+ if( zIdx==0 ) continue;
/* Zero the IdxConstraint.bFlag values in the pEq list */
for(pIter=pEq; pIter; pIter=pIter->pLink) pIter->bFlag = 0;
@@ -10412,7 +10386,7 @@ static void idxWriteFree(IdxWrite *pTab){
** runs all the queries to see which indexes they prefer, and populates
** IdxStatement.zIdx and IdxStatement.zEQP with the results.
*/
-int idxFindIndexes(
+static int idxFindIndexes(
sqlite3expert *p,
char **pzErr /* OUT: Error message (sqlite3_malloc) */
){
@@ -10541,6 +10515,7 @@ static int idxProcessOneTrigger(
rc = idxPrintfPrepareStmt(p->db, &pSelect, pzErr, zSql, zTab, zTab);
while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pSelect) ){
const char *zCreate = (const char*)sqlite3_column_text(pSelect, 0);
+ if( zCreate==0 ) continue;
rc = sqlite3_exec(p->dbv, zCreate, 0, 0, pzErr);
}
idxFinalize(&rc, pSelect);
@@ -10643,8 +10618,9 @@ static int idxCreateVtabSchema(sqlite3expert *p, char **pzErrmsg){
const char *zName = (const char*)sqlite3_column_text(pSchema, 1);
const char *zSql = (const char*)sqlite3_column_text(pSchema, 2);
+ if( zType==0 || zName==0 ) continue;
if( zType[0]=='v' || zType[1]=='r' ){
- rc = sqlite3_exec(p->dbv, zSql, 0, 0, pzErrmsg);
+ if( zSql ) rc = sqlite3_exec(p->dbv, zSql, 0, 0, pzErrmsg);
}else{
IdxTable *pTab;
rc = idxGetTableInfo(p->db, zName, &pTab, pzErrmsg);
@@ -10781,6 +10757,7 @@ static void idxRemFunc(
case SQLITE_BLOB:
case SQLITE_TEXT: {
int nByte = sqlite3_value_bytes(argv[1]);
+ const void *pData = 0;
if( nByte>pSlot->nByte ){
char *zNew = (char*)sqlite3_realloc(pSlot->z, nByte*2);
if( zNew==0 ){
@@ -10792,9 +10769,11 @@ static void idxRemFunc(
}
pSlot->n = nByte;
if( pSlot->eType==SQLITE_BLOB ){
- memcpy(pSlot->z, sqlite3_value_blob(argv[1]), nByte);
+ pData = sqlite3_value_blob(argv[1]);
+ if( pData ) memcpy(pSlot->z, pData, nByte);
}else{
- memcpy(pSlot->z, sqlite3_value_text(argv[1]), nByte);
+ pData = sqlite3_value_text(argv[1]);
+ memcpy(pSlot->z, pData, nByte);
}
break;
}
@@ -11005,6 +10984,7 @@ static int idxPopulateStat1(sqlite3expert *p, char **pzErr){
i64 iRowid = sqlite3_column_int64(pAllIndex, 0);
const char *zTab = (const char*)sqlite3_column_text(pAllIndex, 1);
const char *zIdx = (const char*)sqlite3_column_text(pAllIndex, 2);
+ if( zTab==0 || zIdx==0 ) continue;
if( p->iSample<100 && iPrev!=iRowid ){
samplectx.target = (double)p->iSample / 100.0;
samplectx.iTarget = p->iSample;
@@ -11071,14 +11051,14 @@ sqlite3expert *sqlite3_expert_new(sqlite3 *db, char **pzErrmsg){
/* Copy the entire schema of database [db] into [dbm]. */
if( rc==SQLITE_OK ){
- sqlite3_stmt *pSql;
+ sqlite3_stmt *pSql = 0;
rc = idxPrintfPrepareStmt(pNew->db, &pSql, pzErrmsg,
"SELECT sql FROM sqlite_schema WHERE name NOT LIKE 'sqlite_%%'"
" AND sql NOT LIKE 'CREATE VIRTUAL %%'"
);
while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pSql) ){
const char *zSql = (const char*)sqlite3_column_text(pSql, 0);
- rc = sqlite3_exec(pNew->dbm, zSql, 0, 0, pzErrmsg);
+ if( zSql ) rc = sqlite3_exec(pNew->dbm, zSql, 0, 0, pzErrmsg);
}
idxFinalize(&rc, pSql);
}
@@ -12165,6 +12145,15 @@ struct EQPGraph {
char zPrefix[100]; /* Graph prefix */
};
+/* Parameters affecting columnar mode result display (defaulting together) */
+typedef struct ColModeOpts {
+ int iWrap; /* In columnar modes, wrap lines reaching this limit */
+ u8 bQuote; /* Quote results for .mode box and table */
+ u8 bWordWrap; /* In columnar modes, wrap at word boundaries */
+} ColModeOpts;
+#define ColModeOpts_default { 60, 0, 0 }
+#define ColModeOpts_default_qbox { 60, 1, 0 }
+
/*
** State information about the database connection is contained in an
** instance of the following structure.
@@ -12183,8 +12172,10 @@ struct ShellState {
u8 eTraceType; /* SHELL_TRACE_* value for type of trace */
u8 bSafeMode; /* True to prohibit unsafe operations */
u8 bSafeModePersist; /* The long-term value of bSafeMode */
+ ColModeOpts cmOpts; /* Option values affecting columnar mode output */
unsigned statsOn; /* True to display memory stats before each finalize */
unsigned mEqpLines; /* Mask of veritical lines in the EQP output graph */
+ int inputNesting; /* Track nesting level of .read and other redirects */
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 */
@@ -12311,6 +12302,8 @@ struct ShellState {
#define MODE_Markdown 14 /* Markdown formatting */
#define MODE_Table 15 /* MySQL-style table formatting */
#define MODE_Box 16 /* Unicode box-drawing characters */
+#define MODE_Count 17 /* Output only a count of the rows of output */
+#define MODE_Off 18 /* No query output shown */
static const char *modeDescr[] = {
"line",
@@ -12329,7 +12322,9 @@ static const char *modeDescr[] = {
"json",
"markdown",
"table",
- "box"
+ "box",
+ "count",
+ "off"
};
/*
@@ -12346,6 +12341,12 @@ static const char *modeDescr[] = {
#define SEP_Record "\x1E"
/*
+** Limit input nesting via .read or any other input redirect.
+** It's not too expensive, so a generous allowance can be made.
+*/
+#define MAX_INPUT_NESTING 25
+
+/*
** A callback for the sqlite3_log() interface.
*/
static void shellLog(void *pArg, int iErrCode, const char *zMsg){
@@ -12829,6 +12830,7 @@ static void output_csv(ShellState *p, const char *z, int bSep){
}
if( i==0 || strstr(z, p->colSeparator)!=0 ){
char *zQuoted = sqlite3_mprintf("\"%w\"", z);
+ shell_check_oom(zQuoted);
utf8_printf(out, "%s", zQuoted);
sqlite3_free(zQuoted);
}else{
@@ -13003,7 +13005,7 @@ static void eqp_append(ShellState *p, int iEqpId, int p2, const char *zText){
utf8_printf(p->out, "%d,%d,%s\n", iEqpId, p2, zText);
}
pNew = sqlite3_malloc64( sizeof(*pNew) + nText );
- if( pNew==0 ) shell_out_of_memory();
+ shell_check_oom(pNew);
pNew->iEqpId = iEqpId;
pNew->iParentId = p2;
memcpy(pNew->zText, zText, nText+1);
@@ -13151,6 +13153,10 @@ static int shell_callback(
if( azArg==0 ) return 0;
switch( p->cMode ){
+ case MODE_Count:
+ case MODE_Off: {
+ break;
+ }
case MODE_Line: {
int w = 5;
if( azArg==0 ) break;
@@ -13220,6 +13226,7 @@ static int shell_callback(
break;
}
z = sqlite3_mprintf("%s", azArg[0]);
+ shell_check_oom(z);
j = 0;
for(i=0; IsSpace(z[i]); i++){}
for(; (c = z[i])!=0; i++){
@@ -13351,6 +13358,7 @@ static int shell_callback(
if( i>0 ) raw_printf(p->out, ",");
if( quoteChar(azCol[i]) ){
char *z = sqlite3_mprintf("\"%w\"", azCol[i]);
+ shell_check_oom(z);
utf8_printf(p->out, "%s", z);
sqlite3_free(z);
}else{
@@ -13382,7 +13390,12 @@ static int shell_callback(
}else if( ur==0xfff0000000000000LL ){
raw_printf(p->out, "-1e999");
}else{
- sqlite3_snprintf(50,z,"%!.20g", r);
+ sqlite3_int64 ir = (sqlite3_int64)r;
+ if( r==(double)ir ){
+ sqlite3_snprintf(50,z,"%lld.0", ir);
+ }else{
+ sqlite3_snprintf(50,z,"%!.20g", r);
+ }
raw_printf(p->out, "%s", z);
}
}else if( aiType && aiType[i]==SQLITE_BLOB && p->pStmt ){
@@ -13596,7 +13609,7 @@ static void set_table_name(ShellState *p, const char *zName){
n = strlen30(zName);
if( cQuote ) n += n+2;
z = p->zDestTable = malloc( n+1 );
- if( z==0 ) shell_out_of_memory();
+ shell_check_oom(z);
n = 0;
if( cQuote ) z[n++] = cQuote;
for(i=0; zName[i]; i++){
@@ -13607,6 +13620,47 @@ static void set_table_name(ShellState *p, const char *zName){
z[n] = 0;
}
+/*
+** Maybe construct two lines of text that point out the position of a
+** syntax error. Return a pointer to the text, in memory obtained from
+** sqlite3_malloc(). Or, if the most recent error does not involve a
+** specific token that we can point to, return an empty string.
+**
+** In all cases, the memory returned is obtained from sqlite3_malloc64()
+** and should be released by the caller invoking sqlite3_free().
+*/
+static char *shell_error_context(const char *zSql, sqlite3 *db){
+ int iOffset;
+ size_t len;
+ char *zCode;
+ char *zMsg;
+ int i;
+ if( db==0
+ || zSql==0
+ || (iOffset = sqlite3_error_offset(db))<0
+ ){
+ return sqlite3_mprintf("");
+ }
+ while( iOffset>50 ){
+ iOffset--;
+ zSql++;
+ while( (zSql[0]&0xc0)==0x80 ){ zSql++; iOffset--; }
+ }
+ len = strlen(zSql);
+ if( len>78 ){
+ len = 78;
+ while( (zSql[len]&0xc0)==0x80 ) len--;
+ }
+ zCode = sqlite3_mprintf("%.*s", len, zSql);
+ for(i=0; zCode[i]; i++){ if( IsSpace(zSql[i]) ) zCode[i] = ' '; }
+ if( iOffset<25 ){
+ zMsg = sqlite3_mprintf("\n %z\n %*s^--- error here", zCode, iOffset, "");
+ }else{
+ zMsg = sqlite3_mprintf("\n %z\n %*serror here ---^", zCode, iOffset-14, "");
+ }
+ return zMsg;
+}
+
/*
** Execute a query statement that will generate SQL output. Print
@@ -13629,8 +13683,10 @@ static int run_table_dump_query(
const char *z;
rc = sqlite3_prepare_v2(p->db, zSelect, -1, &pSelect, 0);
if( rc!=SQLITE_OK || !pSelect ){
- utf8_printf(p->out, "/**** ERROR: (%d) %s *****/\n", rc,
- sqlite3_errmsg(p->db));
+ char *zContext = shell_error_context(zSelect, p->db);
+ utf8_printf(p->out, "/**** ERROR: (%d) %s *****/\n%s", rc,
+ sqlite3_errmsg(p->db), zContext);
+ sqlite3_free(zContext);
if( (rc&0xff)!=SQLITE_CORRUPT ) p->nErr++;
return rc;
}
@@ -13665,12 +13721,25 @@ static int run_table_dump_query(
*/
static char *save_err_msg(
sqlite3 *db, /* Database to query */
- const char *zWhen, /* Qualifier (format) wrapper */
- int rc /* Error code returned from API */
+ const char *zPhase, /* When the error occcurs */
+ int rc, /* Error code returned from API */
+ const char *zSql /* SQL string, or NULL */
){
- if( zWhen==0 )
- zWhen = "%s (%d)";
- return sqlite3_mprintf(zWhen, sqlite3_errmsg(db), rc);
+ char *zErr;
+ char *zContext;
+ sqlite3_str *pStr = sqlite3_str_new(0);
+ sqlite3_str_appendf(pStr, "%s, %s", zPhase, sqlite3_errmsg(db));
+ if( rc>1 ){
+ sqlite3_str_appendf(pStr, " (%d)", rc);
+ }
+ zContext = shell_error_context(zSql, db);
+ if( zContext ){
+ sqlite3_str_appendall(pStr, zContext);
+ sqlite3_free(zContext);
+ }
+ zErr = sqlite3_str_finish(pStr);
+ shell_check_oom(zErr);
+ return zErr;
}
#ifdef __linux__
@@ -13848,6 +13917,7 @@ static int display_stats(
}
if( pArg->pStmt ){
+ int iHit, iMiss;
iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_FULLSCAN_STEP,
bReset);
raw_printf(pArg->out, "Fullscan Steps: %d\n", iCur);
@@ -13855,6 +13925,12 @@ static int display_stats(
raw_printf(pArg->out, "Sort Operations: %d\n", iCur);
iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_AUTOINDEX,bReset);
raw_printf(pArg->out, "Autoindex Inserts: %d\n", iCur);
+ iHit = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_FILTER_HIT, bReset);
+ iMiss = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_FILTER_MISS, bReset);
+ if( iHit || iMiss ){
+ raw_printf(pArg->out, "Bloom filter bypass taken: %d/%d\n",
+ iHit, iHit+iMiss);
+ }
iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_VM_STEP, bReset);
raw_printf(pArg->out, "Virtual Machine Steps: %d\n", iCur);
iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_REPREPARE,bReset);
@@ -14011,9 +14087,9 @@ static void explain_data_prepare(ShellState *p, sqlite3_stmt *pSql){
}
nAlloc += 100;
p->aiIndent = (int*)sqlite3_realloc64(p->aiIndent, nAlloc*sizeof(int));
- if( p->aiIndent==0 ) shell_out_of_memory();
+ shell_check_oom(p->aiIndent);
abYield = (int*)sqlite3_realloc64(abYield, nAlloc*sizeof(int));
- if( abYield==0 ) shell_out_of_memory();
+ shell_check_oom(abYield);
}
abYield[iOp] = str_in_array(zOp, azYield);
p->aiIndent[iOp] = 0;
@@ -14189,7 +14265,134 @@ static void print_box_row_separator(
fputs("\n", p->out);
}
+/*
+** z[] is a line of text that is to be displayed the .mode box or table or
+** similar tabular formats. z[] might contain control characters such
+** as \n, \t, \f, or \r.
+**
+** Compute characters to display on the first line of z[]. Stop at the
+** first \r, \n, or \f. Expand \t into spaces. Return a copy (obtained
+** from malloc()) of that first line, which caller should free sometime.
+** Write anything to display on the next line into *pzTail. If this is
+** the last line, write a NULL into *pzTail. (*pzTail is not allocated.)
+*/
+static char *translateForDisplayAndDup(
+ const unsigned char *z, /* Input text to be transformed */
+ const unsigned char **pzTail, /* OUT: Tail of the input for next line */
+ int mxWidth, /* Max width. 0 means no limit */
+ u8 bWordWrap /* If true, avoid breaking mid-word */
+){
+ int i; /* Input bytes consumed */
+ int j; /* Output bytes generated */
+ int k; /* Input bytes to be displayed */
+ int n; /* Output column number */
+ unsigned char *zOut; /* Output text */
+
+ if( z==0 ){
+ *pzTail = 0;
+ return 0;
+ }
+ if( mxWidth<0 ) mxWidth = -mxWidth;
+ if( mxWidth==0 ) mxWidth = 1000000;
+ i = j = n = 0;
+ while( n<mxWidth ){
+ if( z[i]>=' ' ){
+ n++;
+ do{ i++; j++; }while( (z[i]&0xc0)==0x80 );
+ continue;
+ }
+ if( z[i]=='\t' ){
+ do{
+ n++;
+ j++;
+ }while( (n&7)!=0 && n<mxWidth );
+ i++;
+ continue;
+ }
+ break;
+ }
+ if( n>=mxWidth && bWordWrap ){
+ /* Perhaps try to back up to a better place to break the line */
+ for(k=i; k>i/2; k--){
+ if( isspace(z[k-1]) ) break;
+ }
+ if( k<=i/2 ){
+ for(k=i; k>i/2; k--){
+ if( isalnum(z[k-1])!=isalnum(z[k]) && (z[k]&0xc0)!=0x80 ) break;
+ }
+ }
+ if( k<=i/2 ){
+ k = i;
+ }else{
+ i = k;
+ while( z[i]==' ' ) i++;
+ }
+ }else{
+ k = i;
+ }
+ if( n>=mxWidth && z[i]>=' ' ){
+ *pzTail = &z[i];
+ }else if( z[i]=='\r' && z[i+1]=='\n' ){
+ *pzTail = z[i+2] ? &z[i+2] : 0;
+ }else if( z[i]==0 || z[i+1]==0 ){
+ *pzTail = 0;
+ }else{
+ *pzTail = &z[i+1];
+ }
+ zOut = malloc( j+1 );
+ shell_check_oom(zOut);
+ i = j = n = 0;
+ while( i<k ){
+ if( z[i]>=' ' ){
+ n++;
+ do{ zOut[j++] = z[i++]; }while( (z[i]&0xc0)==0x80 );
+ continue;
+ }
+ if( z[i]=='\t' ){
+ do{
+ n++;
+ zOut[j++] = ' ';
+ }while( (n&7)!=0 && n<mxWidth );
+ i++;
+ continue;
+ }
+ break;
+ }
+ zOut[j] = 0;
+ return (char*)zOut;
+}
+/* Extract the value of the i-th current column for pStmt as an SQL literal
+** value. Memory is obtained from sqlite3_malloc64() and must be freed by
+** the caller.
+*/
+static char *quoted_column(sqlite3_stmt *pStmt, int i){
+ switch( sqlite3_column_type(pStmt, i) ){
+ case SQLITE_NULL: {
+ return sqlite3_mprintf("NULL");
+ }
+ case SQLITE_INTEGER:
+ case SQLITE_FLOAT: {
+ return sqlite3_mprintf("%s",sqlite3_column_text(pStmt,i));
+ }
+ case SQLITE_TEXT: {
+ return sqlite3_mprintf("%Q",sqlite3_column_text(pStmt,i));
+ }
+ case SQLITE_BLOB: {
+ int j;
+ sqlite3_str *pStr = sqlite3_str_new(0);
+ const unsigned char *a = sqlite3_column_blob(pStmt,i);
+ int n = sqlite3_column_bytes(pStmt,i);
+ sqlite3_str_append(pStr, "x'", 2);
+ for(j=0; j<n; j++){
+ sqlite3_str_appendf(pStr, "%02x", a[j]);
+ }
+ sqlite3_str_append(pStr, "'", 1);
+ return sqlite3_str_finish(pStr);
+ }
+ }
+ return 0; /* Not reached */
+}
/*
** Run a prepared statement and output the result in one of the
@@ -14209,12 +14412,19 @@ static void exec_prepared_stmt_columnar(
int nColumn = 0;
char **azData = 0;
sqlite3_int64 nAlloc = 0;
+ char *abRowDiv = 0;
+ const unsigned char *uz;
const char *z;
+ char **azQuoted = 0;
int rc;
sqlite3_int64 i, nData;
int j, nTotal, w, n;
const char *colSep = 0;
const char *rowSep = 0;
+ const unsigned char **azNextLine = 0;
+ int bNextLine = 0;
+ int bMultiLineRowExists = 0;
+ int bw = p->cmOpts.bWordWrap;
rc = sqlite3_step(pStmt);
if( rc!=SQLITE_ROW ) return;
@@ -14222,25 +14432,20 @@ static void exec_prepared_stmt_columnar(
nAlloc = nColumn*4;
if( nAlloc<=0 ) nAlloc = 1;
azData = sqlite3_malloc64( nAlloc*sizeof(char*) );
- if( azData==0 ) shell_out_of_memory();
- for(i=0; i<nColumn; i++){
- azData[i] = strdup(sqlite3_column_name(pStmt,i));
- }
- do{
- if( (nRow+2)*nColumn >= nAlloc ){
- nAlloc *= 2;
- azData = sqlite3_realloc64(azData, nAlloc*sizeof(char*));
- if( azData==0 ) shell_out_of_memory();
- }
- nRow++;
- for(i=0; i<nColumn; i++){
- z = (const char*)sqlite3_column_text(pStmt,i);
- azData[nRow*nColumn + i] = z ? strdup(z) : 0;
- }
- }while( sqlite3_step(pStmt)==SQLITE_ROW );
+ shell_check_oom(azData);
+ azNextLine = sqlite3_malloc64( nColumn*sizeof(char*) );
+ shell_check_oom((void*)azNextLine);
+ memset((void*)azNextLine, 0, nColumn*sizeof(char*) );
+ if( p->cmOpts.bQuote ){
+ azQuoted = sqlite3_malloc64( nColumn*sizeof(char*) );
+ shell_check_oom(azQuoted);
+ memset(azQuoted, 0, nColumn*sizeof(char*) );
+ }
+ abRowDiv = sqlite3_malloc64( nAlloc/nColumn );
+ shell_check_oom(abRowDiv);
if( nColumn>p->nWidth ){
p->colWidth = realloc(p->colWidth, (nColumn+1)*2*sizeof(int));
- if( p->colWidth==0 ) shell_out_of_memory();
+ shell_check_oom(p->colWidth);
for(i=p->nWidth; i<nColumn; i++) p->colWidth[i] = 0;
p->nWidth = nColumn;
p->actualWidth = &p->colWidth[nColumn];
@@ -14251,6 +14456,52 @@ static void exec_prepared_stmt_columnar(
if( w<0 ) w = -w;
p->actualWidth[i] = w;
}
+ for(i=0; i<nColumn; i++){
+ const unsigned char *zNotUsed;
+ int wx = p->colWidth[i];
+ if( wx==0 ){
+ wx = p->cmOpts.iWrap;
+ }
+ if( wx<0 ) wx = -wx;
+ uz = (const unsigned char*)sqlite3_column_name(pStmt,i);
+ azData[i] = translateForDisplayAndDup(uz, &zNotUsed, wx, bw);
+ }
+ do{
+ int useNextLine = bNextLine;
+ bNextLine = 0;
+ if( (nRow+2)*nColumn >= nAlloc ){
+ nAlloc *= 2;
+ azData = sqlite3_realloc64(azData, nAlloc*sizeof(char*));
+ shell_check_oom(azData);
+ abRowDiv = sqlite3_realloc64(abRowDiv, nAlloc/nColumn);
+ shell_check_oom(abRowDiv);
+ }
+ abRowDiv[nRow] = 1;
+ nRow++;
+ for(i=0; i<nColumn; i++){
+ int wx = p->colWidth[i];
+ if( wx==0 ){
+ wx = p->cmOpts.iWrap;
+ }
+ if( wx<0 ) wx = -wx;
+ if( useNextLine ){
+ uz = azNextLine[i];
+ }else if( p->cmOpts.bQuote ){
+ sqlite3_free(azQuoted[i]);
+ azQuoted[i] = quoted_column(pStmt,i);
+ uz = (const unsigned char*)azQuoted[i];
+ }else{
+ uz = (const unsigned char*)sqlite3_column_text(pStmt,i);
+ }
+ azData[nRow*nColumn + i]
+ = translateForDisplayAndDup(uz, &azNextLine[i], wx, bw);
+ if( azNextLine[i] ){
+ bNextLine = 1;
+ abRowDiv[nRow-1] = 0;
+ bMultiLineRowExists = 1;
+ }
+ }
+ }while( bNextLine || sqlite3_step(pStmt)==SQLITE_ROW );
nTotal = nColumn*(nRow+1);
for(i=0; i<nTotal; i++){
z = azData[i];
@@ -14333,6 +14584,15 @@ static void exec_prepared_stmt_columnar(
utf8_width_print(p->out, w, z);
if( j==nColumn-1 ){
utf8_printf(p->out, "%s", rowSep);
+ if( bMultiLineRowExists && abRowDiv[i/nColumn-1] && i+1<nTotal ){
+ if( p->cMode==MODE_Table ){
+ print_row_separator(p, nColumn, "+");
+ }else if( p->cMode==MODE_Box ){
+ print_box_row_separator(p, nColumn, BOX_123, BOX_1234, BOX_134);
+ }else if( p->cMode==MODE_Column ){
+ raw_printf(p->out, "\n");
+ }
+ }
j = -1;
if( seenInterrupt ) goto columnar_end;
}else{
@@ -14351,6 +14611,12 @@ columnar_end:
nData = (nRow+1)*nColumn;
for(i=0; i<nData; i++) free(azData[i]);
sqlite3_free(azData);
+ sqlite3_free((void*)azNextLine);
+ sqlite3_free(abRowDiv);
+ if( azQuoted ){
+ for(i=0; i<nColumn; i++) sqlite3_free(azQuoted[i]);
+ sqlite3_free(azQuoted);
+ }
}
/*
@@ -14361,6 +14627,7 @@ static void exec_prepared_stmt(
sqlite3_stmt *pStmt /* Statment to run */
){
int rc;
+ sqlite3_uint64 nRow = 0;
if( pArg->cMode==MODE_Column
|| pArg->cMode==MODE_Table
@@ -14393,10 +14660,14 @@ static void exec_prepared_stmt(
azCols[i] = (char *)sqlite3_column_name(pStmt, i);
}
do{
+ nRow++;
/* extract the data and data types */
for(i=0; i<nCol; i++){
aiTypes[i] = x = sqlite3_column_type(pStmt, i);
- if( x==SQLITE_BLOB && pArg && pArg->cMode==MODE_Insert ){
+ if( x==SQLITE_BLOB
+ && pArg
+ && (pArg->cMode==MODE_Insert || pArg->cMode==MODE_Quote)
+ ){
azVals[i] = "";
}else{
azVals[i] = (char*)sqlite3_column_text(pStmt, i);
@@ -14420,6 +14691,11 @@ static void exec_prepared_stmt(
sqlite3_free(pData);
if( pArg->cMode==MODE_Json ){
fputs("]\n", pArg->out);
+ }else if( pArg->cMode==MODE_Count ){
+ char zBuf[200];
+ sqlite3_snprintf(sizeof(zBuf), zBuf, "%llu row%s\n",
+ nRow, nRow!=1 ? "s" : "");
+ printf("%s", zBuf);
}
}
}
@@ -14543,7 +14819,7 @@ static int expertDotCommand(
if( rc==SQLITE_OK ){
pState->expert.pExpert = sqlite3_expert_new(pState->db, &zErr);
if( pState->expert.pExpert==0 ){
- raw_printf(stderr, "sqlite3_expert_new: %s\n", zErr);
+ raw_printf(stderr, "sqlite3_expert_new: %s\n", zErr ? zErr : "out of memory");
rc = SQLITE_ERROR;
}else{
sqlite3_expert_config(
@@ -14551,6 +14827,7 @@ static int expertDotCommand(
);
}
}
+ sqlite3_free(zErr);
return rc;
}
@@ -14592,7 +14869,7 @@ static int shell_exec(
rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, &zLeftover);
if( SQLITE_OK != rc ){
if( pzErrMsg ){
- *pzErrMsg = save_err_msg(db, "in prepare, %s (%d)", rc);
+ *pzErrMsg = save_err_msg(db, "in prepare", rc, zSql);
}
}else{
if( !pStmt ){
@@ -14627,6 +14904,7 @@ static int shell_exec(
sqlite3_db_config(db, SQLITE_DBCONFIG_TRIGGER_EQP, 1, 0);
}
zEQP = sqlite3_mprintf("EXPLAIN QUERY PLAN %s", zStmtSql);
+ shell_check_oom(zEQP);
rc = sqlite3_prepare_v2(db, zEQP, -1, &pExplain, 0);
if( rc==SQLITE_OK ){
while( sqlite3_step(pExplain)==SQLITE_ROW ){
@@ -14644,6 +14922,7 @@ static int shell_exec(
if( pArg->autoEQP>=AUTOEQP_full ){
/* Also do an EXPLAIN for ".eqp full" mode */
zEQP = sqlite3_mprintf("EXPLAIN %s", zStmtSql);
+ shell_check_oom(zEQP);
rc = sqlite3_prepare_v2(db, zEQP, -1, &pExplain, 0);
if( rc==SQLITE_OK ){
pArg->cMode = MODE_Explain;
@@ -14706,7 +14985,7 @@ static int shell_exec(
zSql = zLeftover;
while( IsSpace(zSql[0]) ) zSql++;
}else if( pzErrMsg ){
- *pzErrMsg = save_err_msg(db, "stepping, %s (%d)", rc);
+ *pzErrMsg = save_err_msg(db, "stepping", rc, 0);
}
/* clear saved stmt handle */
@@ -14756,6 +15035,7 @@ static char **tableColumnList(ShellState *p, const char *zTab){
int rc;
zSql = sqlite3_mprintf("PRAGMA table_info=%Q", zTab);
+ shell_check_oom(zSql);
rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
sqlite3_free(zSql);
if( rc ) return 0;
@@ -14763,9 +15043,10 @@ static char **tableColumnList(ShellState *p, const char *zTab){
if( nCol>=nAlloc-2 ){
nAlloc = nAlloc*2 + nCol + 10;
azCol = sqlite3_realloc(azCol, nAlloc*sizeof(azCol[0]));
- if( azCol==0 ) shell_out_of_memory();
+ shell_check_oom(azCol);
}
azCol[++nCol] = sqlite3_mprintf("%s", sqlite3_column_text(pStmt, 1));
+ shell_check_oom(azCol[nCol]);
if( sqlite3_column_int(pStmt, 5) ){
nPK++;
if( nPK==1
@@ -14799,6 +15080,7 @@ static char **tableColumnList(ShellState *p, const char *zTab){
*/
zSql = sqlite3_mprintf("SELECT 1 FROM pragma_index_list(%Q)"
" WHERE origin='pk'", zTab);
+ shell_check_oom(zSql);
rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
sqlite3_free(zSql);
if( rc ){
@@ -14890,6 +15172,7 @@ static int dump_callback(void *pArg, int nArg, char **azArg, char **azNotUsed){
"INSERT INTO sqlite_schema(type,name,tbl_name,rootpage,sql)"
"VALUES('table','%q','%q',0,'%q');",
zTable, zTable, zSql);
+ shell_check_oom(zIns);
utf8_printf(p->out, "%s\n", zIns);
sqlite3_free(zIns);
return 0;
@@ -15041,6 +15324,7 @@ static const char *(azHelp[]) = {
".auth ON|OFF Show authorizer callbacks",
#endif
".backup ?DB? FILE Backup DB (default \"main\") to FILE",
+ " Options:",
" --append Use the appendvfs",
" --async Write to FILE without journal and fsync()",
".bail on|off Stop after hitting an error. Default OFF",
@@ -15085,6 +15369,7 @@ static const char *(azHelp[]) = {
" --ascii Use \\037 and \\036 as column and row separators",
" --csv Use , and \\n as column and row separators",
" --skip N Skip the first N rows of input",
+ " --schema S Target table to be S.TABLE",
" -v \"Verbose\" - increase auxiliary output",
" Notes:",
" * If TABLE does not exist, it is created. The first row of input",
@@ -15110,32 +15395,37 @@ static const char *(azHelp[]) = {
".load FILE ?ENTRY? Load an extension library",
#endif
".log FILE|off Turn logging on or off. FILE can be stderr/stdout",
- ".mode MODE ?TABLE? Set output mode",
+ ".mode MODE ?OPTIONS? Set output mode",
" MODE is one of:",
- " ascii Columns/rows delimited by 0x1F and 0x1E",
- " box Tables using unicode box-drawing characters",
- " csv Comma-separated values",
- " column Output in columns. (See .width)",
- " html HTML <table> code",
- " insert SQL insert statements for TABLE",
- " json Results in a JSON array",
- " line One value per line",
- " list Values delimited by \"|\"",
- " markdown Markdown table format",
- " quote Escape answers as for SQL",
- " table ASCII-art table",
- " tabs Tab-separated values",
- " tcl TCL list elements",
- ".nonce STRING Disable safe mode for one command if the nonce matches",
+ " ascii Columns/rows delimited by 0x1F and 0x1E",
+ " box Tables using unicode box-drawing characters",
+ " csv Comma-separated values",
+ " column Output in columns. (See .width)",
+ " html HTML <table> code",
+ " insert SQL insert statements for TABLE",
+ " json Results in a JSON array",
+ " line One value per line",
+ " list Values delimited by \"|\"",
+ " markdown Markdown table format",
+ " qbox Shorthand for \"box --width 60 --quote\"",
+ " quote Escape answers as for SQL",
+ " table ASCII-art table",
+ " tabs Tab-separated values",
+ " tcl TCL list elements",
+ " OPTIONS: (for columnar modes or insert mode):",
+ " --wrap N Wrap output lines to no longer than N characters",
+ " --wordwrap B Wrap or not at word boundaries per B (on/off)",
+ " --ww Shorthand for \"--wordwrap 1\"",
+ " --quote Quote output text as SQL literals",
+ " --noquote Do not quote output text",
+ " TABLE The name of SQL table used for \"insert\" mode",
+ ".nonce STRING Suspend safe mode for one command if nonce matches",
".nullvalue STRING Use STRING in place of NULL values",
".once ?OPTIONS? ?FILE? Output for the next SQL command only to FILE",
" If FILE begins with '|' then open as a pipe",
" --bom Put a UTF8 byte-order mark at the beginning",
" -e Send output to the system text editor",
" -x Send output as CSV to a spreadsheet (same as \".excel\")",
-#ifdef SQLITE_DEBUG
- ".oom ?--repeat M? ?N? Simulate an OOM error on the N-th allocation",
-#endif
".open ?OPTIONS? ?FILE? Close existing database and reopen FILE",
" Options:",
" --append Use appendvfs to append database to the end of FILE",
@@ -15171,7 +15461,8 @@ static const char *(azHelp[]) = {
#endif
".prompt MAIN CONTINUE Replace the standard prompts",
".quit Exit this program",
- ".read FILE Read input from FILE",
+ ".read FILE Read input from FILE or command output",
+ " If FILE begins with \"|\", it is a command that generates the input.",
#if !defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_ENABLE_DBPAGE_VTAB)
".recover Recover as much data as possible from corrupt db.",
" --freelist-corrupt Assume the freelist is corrupt",
@@ -15181,7 +15472,7 @@ static const char *(azHelp[]) = {
" that are not also INTEGER PRIMARY KEYs",
#endif
".restore ?DB? FILE Restore content of DB (default \"main\") from FILE",
- ".save FILE Write in-memory database into FILE",
+ ".save ?OPTIONS? FILE Write database to FILE (an alias for .backup ...)",
".scanstats on|off Turn sqlite3_stmt_scanstatus() metrics on or off",
".schema ?PATTERN? Show the CREATE statements matching PATTERN",
" Options:",
@@ -15291,6 +15582,7 @@ static int showHelp(FILE *out, const char *zPattern){
}else{
/* Look for commands that for which zPattern is an exact prefix */
zPat = sqlite3_mprintf(".%s*", zPattern);
+ shell_check_oom(zPat);
for(i=0; i<ArraySize(azHelp); i++){
if( sqlite3_strglob(zPat, azHelp[i])==0 ){
utf8_printf(out, "%s\n", azHelp[i]);
@@ -15313,6 +15605,7 @@ static int showHelp(FILE *out, const char *zPattern){
/* Look for commands that contain zPattern anywhere. Show the complete
** text of all commands that match. */
zPat = sqlite3_mprintf("%%%s%%", zPattern);
+ shell_check_oom(zPat);
for(i=0; i<ArraySize(azHelp); i++){
if( azHelp[i][0]=='.' ) j = i;
if( sqlite3_strlike(zPat, azHelp[i], 0)==0 ){
@@ -15501,10 +15794,7 @@ static unsigned char *readHexDb(ShellState *p, int *pnData){
if( pgsz<512 || pgsz>65536 || (pgsz&(pgsz-1))!=0 ) goto readHexDb_error;
n = (n+pgsz-1)&~(pgsz-1); /* Round n up to the next multiple of pgsz */
a = sqlite3_malloc( n ? n : 1 );
- if( a==0 ){
- utf8_printf(stderr, "Out of memory!\n");
- goto readHexDb_error;
- }
+ shell_check_oom(a);
memset(a, 0, n);
if( pgsz<512 || pgsz>65536 || (pgsz & (pgsz-1))!=0 ){
utf8_printf(stderr, "invalid pagesize\n");
@@ -15635,7 +15925,7 @@ static void shellEscapeCrnl(
){
const char *zText = (const char*)sqlite3_value_text(argv[0]);
UNUSED_PARAMETER(argc);
- if( zText[0]=='\'' ){
+ if( zText && zText[0]=='\'' ){
int nText = sqlite3_value_bytes(argv[0]);
int i;
char zBuf1[20];
@@ -15812,6 +16102,7 @@ static void open_db(ShellState *p, int openFlags){
if( p->openMode==SHELL_OPEN_ZIPFILE ){
char *zSql = sqlite3_mprintf(
"CREATE VIRTUAL TABLE zip USING zipfile(%Q);", zDbFilename);
+ shell_check_oom(zSql);
sqlite3_exec(p->db, zSql, 0, 0, 0);
sqlite3_free(zSql);
}
@@ -15869,11 +16160,13 @@ static char *readline_completion_generator(const char *text, int state){
sqlite3_finalize(pStmt);
zSql = sqlite3_mprintf("SELECT DISTINCT candidate COLLATE nocase"
" FROM completion(%Q) ORDER BY 1", text);
+ shell_check_oom(zSql);
sqlite3_prepare_v2(globalDb, zSql, -1, &pStmt, 0);
sqlite3_free(zSql);
}
if( sqlite3_step(pStmt)==SQLITE_ROW ){
- zRet = strdup((const char*)sqlite3_column_text(pStmt, 0));
+ const char *z = (const char*)sqlite3_column_text(pStmt,0);
+ zRet = z ? strdup(z) : 0;
}else{
sqlite3_finalize(pStmt);
pStmt = 0;
@@ -15906,13 +16199,14 @@ static void linenoise_completion(const char *zLine, linenoiseCompletions *lc){
zSql = sqlite3_mprintf("SELECT DISTINCT candidate COLLATE nocase"
" FROM completion(%Q,%Q) ORDER BY 1",
&zLine[iStart], zLine);
+ shell_check_oom(zSql);
sqlite3_prepare_v2(globalDb, zSql, -1, &pStmt, 0);
sqlite3_free(zSql);
sqlite3_exec(globalDb, "PRAGMA page_count", 0, 0, 0); /* Load the schema */
while( sqlite3_step(pStmt)==SQLITE_ROW ){
const char *zCompletion = (const char*)sqlite3_column_text(pStmt, 0);
int nCompletion = sqlite3_column_bytes(pStmt, 0);
- if( iStart+nCompletion < sizeof(zBuf)-1 ){
+ if( iStart+nCompletion < sizeof(zBuf)-1 && zCompletion ){
memcpy(zBuf+iStart, zCompletion, nCompletion+1);
linenoiseAddCompletion(lc, zBuf);
}
@@ -16147,7 +16441,7 @@ static void import_append_char(ImportCtx *p, int c){
if( p->n+1>=p->nAlloc ){
p->nAlloc += p->nAlloc + 100;
p->z = sqlite3_realloc64(p->z, p->nAlloc);
- if( p->z==0 ) shell_out_of_memory();
+ shell_check_oom(p->z);
}
p->z[p->n++] = (char)c;
}
@@ -16299,6 +16593,7 @@ static void tryToCloneData(
const int spinRate = 10000;
zQuery = sqlite3_mprintf("SELECT * FROM \"%w\"", zTable);
+ shell_check_oom(zQuery);
rc = sqlite3_prepare_v2(p->db, zQuery, -1, &pQuery, 0);
if( rc ){
utf8_printf(stderr, "Error %d: %s on [%s]\n",
@@ -16308,7 +16603,7 @@ static void tryToCloneData(
}
n = sqlite3_column_count(pQuery);
zInsert = sqlite3_malloc64(200 + nTable + n*3);
- if( zInsert==0 ) shell_out_of_memory();
+ shell_check_oom(zInsert);
sqlite3_snprintf(200+nTable,zInsert,
"INSERT OR IGNORE INTO \"%s\" VALUES(?", zTable);
i = strlen30(zInsert);
@@ -16371,6 +16666,7 @@ static void tryToCloneData(
sqlite3_free(zQuery);
zQuery = sqlite3_mprintf("SELECT * FROM \"%w\" ORDER BY rowid DESC;",
zTable);
+ shell_check_oom(zQuery);
rc = sqlite3_prepare_v2(p->db, zQuery, -1, &pQuery, 0);
if( rc ){
utf8_printf(stderr, "Warning: cannot step \"%s\" backwards", zTable);
@@ -16407,6 +16703,7 @@ static void tryToCloneSchema(
zQuery = sqlite3_mprintf("SELECT name, sql FROM sqlite_schema"
" WHERE %s", zWhere);
+ shell_check_oom(zQuery);
rc = sqlite3_prepare_v2(p->db, zQuery, -1, &pQuery, 0);
if( rc ){
utf8_printf(stderr, "Error: (%d) %s on [%s]\n",
@@ -16417,6 +16714,7 @@ static void tryToCloneSchema(
while( (rc = sqlite3_step(pQuery))==SQLITE_ROW ){
zName = sqlite3_column_text(pQuery, 0);
zSql = sqlite3_column_text(pQuery, 1);
+ if( zName==0 || zSql==0 ) continue;
printf("%s... ", zName); fflush(stdout);
sqlite3_exec(newDb, (const char*)zSql, 0, 0, &zErrMsg);
if( zErrMsg ){
@@ -16434,6 +16732,7 @@ static void tryToCloneSchema(
sqlite3_free(zQuery);
zQuery = sqlite3_mprintf("SELECT name, sql FROM sqlite_schema"
" WHERE %s ORDER BY rowid DESC", zWhere);
+ shell_check_oom(zQuery);
rc = sqlite3_prepare_v2(p->db, zQuery, -1, &pQuery, 0);
if( rc ){
utf8_printf(stderr, "Error: (%d) %s on [%s]\n",
@@ -16444,6 +16743,7 @@ static void tryToCloneSchema(
while( sqlite3_step(pQuery)==SQLITE_ROW ){
zName = sqlite3_column_text(pQuery, 0);
zSql = sqlite3_column_text(pQuery, 1);
+ if( zName==0 || zSql==0 ) continue;
printf("%s... ", zName); fflush(stdout);
sqlite3_exec(newDb, (const char*)zSql, 0, 0, &zErrMsg);
if( zErrMsg ){
@@ -16536,10 +16836,10 @@ static void output_reset(ShellState *p){
/*
** Run an SQL command and return the single integer result.
*/
-static int db_int(ShellState *p, const char *zSql){
+static int db_int(sqlite3 *db, const char *zSql){
sqlite3_stmt *pStmt;
int res = 0;
- sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
+ sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);
if( pStmt && sqlite3_step(pStmt)==SQLITE_ROW ){
res = sqlite3_column_int(pStmt,0);
}
@@ -16644,7 +16944,7 @@ static int shell_dbinfo_command(ShellState *p, int nArg, char **azArg){
}
for(i=0; i<ArraySize(aQuery); i++){
char *zSql = sqlite3_mprintf(aQuery[i].zSql, zSchemaTab);
- int val = db_int(p, zSql);
+ int val = db_int(p->db, zSql);
sqlite3_free(zSql);
utf8_printf(p->out, "%-20s %d\n", aQuery[i].zName, val);
}
@@ -16828,9 +17128,7 @@ static void newTempFile(ShellState *p, const char *zSuffix){
}else{
p->zTempFile = sqlite3_mprintf("%z.%s", p->zTempFile, zSuffix);
}
- if( p->zTempFile==0 ){
- shell_out_of_memory();
- }
+ shell_check_oom(p->zTempFile);
}
@@ -17011,14 +17309,14 @@ static int lintFkeyIndexes(
const char *zCI = (const char*)sqlite3_column_text(pSql, 4);
const char *zParent = (const char*)sqlite3_column_text(pSql, 5);
+ if( zEQP==0 ) continue;
+ if( zGlob==0 ) continue;
rc = sqlite3_prepare_v2(db, zEQP, -1, &pExplain, 0);
if( rc!=SQLITE_OK ) break;
if( SQLITE_ROW==sqlite3_step(pExplain) ){
const char *zPlan = (const char*)sqlite3_column_text(pExplain, 3);
- res = (
- 0==sqlite3_strglob(zGlob, zPlan)
- || 0==sqlite3_strglob(zGlobIPK, zPlan)
- );
+ res = zPlan!=0 && ( 0==sqlite3_strglob(zGlob, zPlan)
+ || 0==sqlite3_strglob(zGlobIPK, zPlan));
}
rc = sqlite3_finalize(pExplain);
if( rc!=SQLITE_OK ) break;
@@ -18010,6 +18308,7 @@ static char *shellMPrintf(int *pRc, const char *zFmt, ...){
return z;
}
+
/*
** When running the ".recover" command, each output table, and the special
** orphaned row table if it is required, is represented by an instance
@@ -18123,6 +18422,7 @@ static RecoverTable *recoverNewTable(
if( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pPkFinder) ){
pTab->iPk = sqlite3_column_int(pPkFinder, 0);
zPk = (const char*)sqlite3_column_text(pPkFinder, 1);
+ if( zPk==0 ){ zPk = "_"; /* Defensive. Should never happen */ }
}
}
@@ -18207,8 +18507,10 @@ static RecoverTable *recoverFindTable(
if( sqlite3_stricmp(zType, "table")==0 ){
zName = (const char*)sqlite3_column_text(pStmt, 1);
zSql = (const char*)sqlite3_column_text(pStmt, 2);
- pRet = recoverNewTable(pRc, zName, zSql, bIntkey, nCol);
- break;
+ if( zName!=0 && zSql!=0 ){
+ pRet = recoverNewTable(pRc, zName, zSql, bIntkey, nCol);
+ break;
+ }
}
}
@@ -18603,6 +18905,221 @@ static int recoverDatabaseCmd(ShellState *pState, int nArg, char **azArg){
}
#endif /* !(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_ENABLE_DBPAGE_VTAB) */
+
+/*
+ * zAutoColumn(zCol, &db, ?) => Maybe init db, add column zCol to it.
+ * zAutoColumn(0, &db, ?) => (db!=0) Form columns spec for CREATE TABLE,
+ * close db and set it to 0, and return the columns spec, to later
+ * be sqlite3_free()'ed by the caller.
+ * The return is 0 when either:
+ * (a) The db was not initialized and zCol==0 (There are no columns.)
+ * (b) zCol!=0 (Column was added, db initialized as needed.)
+ * The 3rd argument, pRenamed, references an out parameter. If the
+ * pointer is non-zero, its referent will be set to a summary of renames
+ * done if renaming was necessary, or set to 0 if none was done. The out
+ * string (if any) must be sqlite3_free()'ed by the caller.
+ */
+#ifdef SHELL_DEBUG
+#define rc_err_oom_die(rc) \
+ if( rc==SQLITE_NOMEM ) shell_check_oom(0); \
+ else if(!(rc==SQLITE_OK||rc==SQLITE_DONE)) \
+ fprintf(stderr,"E:%d\n",rc), assert(0)
+#else
+static void rc_err_oom_die(int rc){
+ if( rc==SQLITE_NOMEM ) shell_check_oom(0);
+ assert(rc==SQLITE_OK||rc==SQLITE_DONE);
+}
+#endif
+
+#ifdef SHELL_COLFIX_DB /* If this is set, the DB can be in a file. */
+static char zCOL_DB[] = SHELL_STRINGIFY(SHELL_COLFIX_DB);
+#else /* Otherwise, memory is faster/better for the transient DB. */
+static const char *zCOL_DB = ":memory:";
+#endif
+
+/* Define character (as C string) to separate generated column ordinal
+ * from protected part of incoming column names. This defaults to "_"
+ * so that incoming column identifiers that did not need not be quoted
+ * remain usable without being quoted. It must be one character.
+ */
+#ifndef SHELL_AUTOCOLUMN_SEP
+# define AUTOCOLUMN_SEP "_"
+#else
+# define AUTOCOLUMN_SEP SHELL_STRINGIFY(SHELL_AUTOCOLUMN_SEP)
+#endif
+
+static char *zAutoColumn(const char *zColNew, sqlite3 **pDb, char **pzRenamed){
+ /* Queries and D{D,M}L used here */
+ static const char * const zTabMake = "\
+CREATE TABLE ColNames(\
+ cpos INTEGER PRIMARY KEY,\
+ name TEXT, nlen INT, chop INT, reps INT, suff TEXT);\
+CREATE VIEW RepeatedNames AS \
+SELECT DISTINCT t.name FROM ColNames t \
+WHERE t.name COLLATE NOCASE IN (\
+ SELECT o.name FROM ColNames o WHERE o.cpos<>t.cpos\
+);\
+";
+ static const char * const zTabFill = "\
+INSERT INTO ColNames(name,nlen,chop,reps,suff)\
+ VALUES(iif(length(?1)>0,?1,'?'),max(length(?1),1),0,0,'')\
+";
+ static const char * const zHasDupes = "\
+SELECT count(DISTINCT (substring(name,1,nlen-chop)||suff) COLLATE NOCASE)\
+ <count(name) FROM ColNames\
+";
+#ifdef SHELL_COLUMN_RENAME_CLEAN
+ static const char * const zDedoctor = "\
+UPDATE ColNames SET chop=iif(\
+ (substring(name,nlen,1) BETWEEN '0' AND '9')\
+ AND (rtrim(name,'0123456790') glob '*"AUTOCOLUMN_SEP"'),\
+ nlen-length(rtrim(name, '"AUTOCOLUMN_SEP"0123456789')),\
+ 0\
+)\
+";
+#endif
+ static const char * const zSetReps = "\
+UPDATE ColNames AS t SET reps=\
+(SELECT count(*) FROM ColNames d \
+ WHERE substring(t.name,1,t.nlen-t.chop)=substring(d.name,1,d.nlen-d.chop)\
+ COLLATE NOCASE\
+)\
+";
+#ifdef SQLITE_ENABLE_MATH_FUNCTIONS
+ static const char * const zColDigits = "\
+SELECT CAST(ceil(log(count(*)+0.5)) AS INT) FROM ColNames \
+";
+#endif
+ static const char * const zRenameRank =
+#ifdef SHELL_COLUMN_RENAME_CLEAN
+ "UPDATE ColNames AS t SET suff="
+ "iif(reps>1, printf('%c%0*d', '"AUTOCOLUMN_SEP"', $1, cpos), '')"
+#else /* ...RENAME_MINIMAL_ONE_PASS */
+"WITH Lzn(nlz) AS (" /* Find minimum extraneous leading 0's for uniqueness */
+" SELECT 0 AS nlz"
+" UNION"
+" SELECT nlz+1 AS nlz FROM Lzn"
+" WHERE EXISTS("
+" SELECT 1"
+" FROM ColNames t, ColNames o"
+" WHERE"
+" iif(t.name IN (SELECT * FROM RepeatedNames),"
+" printf('%s"AUTOCOLUMN_SEP"%s',"
+" t.name, substring(printf('%.*c%0.*d',nlz+1,'0',$1,t.cpos),2)),"
+" t.name"
+" )"
+" ="
+" iif(o.name IN (SELECT * FROM RepeatedNames),"
+" printf('%s"AUTOCOLUMN_SEP"%s',"
+" o.name, substring(printf('%.*c%0.*d',nlz+1,'0',$1,o.cpos),2)),"
+" o.name"
+" )"
+" COLLATE NOCASE"
+" AND o.cpos<>t.cpos"
+" GROUP BY t.cpos"
+" )"
+") UPDATE Colnames AS t SET"
+" chop = 0," /* No chopping, never touch incoming names. */
+" suff = iif(name IN (SELECT * FROM RepeatedNames),"
+" printf('"AUTOCOLUMN_SEP"%s', substring("
+" printf('%.*c%0.*d',(SELECT max(nlz) FROM Lzn)+1,'0',1,t.cpos),2)),"
+" ''"
+" )"
+#endif
+ ;
+ static const char * const zCollectVar = "\
+SELECT\
+ '('||x'0a'\
+ || group_concat(\
+ cname||' TEXT',\
+ ','||iif((cpos-1)%4>0, ' ', x'0a'||' '))\
+ ||')' AS ColsSpec \
+FROM (\
+ SELECT cpos, printf('\"%w\"',printf('%.*s%s', nlen-chop,name,suff)) AS cname \
+ FROM ColNames ORDER BY cpos\
+)";
+ static const char * const zRenamesDone =
+ "SELECT group_concat("
+ " printf('\"%w\" to \"%w\"',name,printf('%.*s%s', nlen-chop, name, suff)),"
+ " ','||x'0a')"
+ "FROM ColNames WHERE suff<>'' OR chop!=0"
+ ;
+ int rc;
+ sqlite3_stmt *pStmt = 0;
+ assert(pDb!=0);
+ if( zColNew ){
+ /* Add initial or additional column. Init db if necessary. */
+ if( *pDb==0 ){
+ if( SQLITE_OK!=sqlite3_open(zCOL_DB, pDb) ) return 0;
+#ifdef SHELL_COLFIX_DB
+ if(*zCOL_DB!=':')
+ sqlite3_exec(*pDb,"drop table if exists ColNames;"
+ "drop view if exists RepeatedNames;",0,0,0);
+#endif
+ rc = sqlite3_exec(*pDb, zTabMake, 0, 0, 0);
+ rc_err_oom_die(rc);
+ }
+ assert(*pDb!=0);
+ rc = sqlite3_prepare_v2(*pDb, zTabFill, -1, &pStmt, 0);
+ rc_err_oom_die(rc);
+ rc = sqlite3_bind_text(pStmt, 1, zColNew, -1, 0);
+ rc_err_oom_die(rc);
+ rc = sqlite3_step(pStmt);
+ rc_err_oom_die(rc);
+ sqlite3_finalize(pStmt);
+ return 0;
+ }else if( *pDb==0 ){
+ return 0;
+ }else{
+ /* Formulate the columns spec, close the DB, zero *pDb. */
+ char *zColsSpec = 0;
+ int hasDupes = db_int(*pDb, zHasDupes);
+#ifdef SQLITE_ENABLE_MATH_FUNCTIONS
+ int nDigits = (hasDupes)? db_int(*pDb, zColDigits) : 0;
+#else
+# define nDigits 2
+#endif
+ if( hasDupes ){
+#ifdef SHELL_COLUMN_RENAME_CLEAN
+ rc = sqlite3_exec(*pDb, zDedoctor, 0, 0, 0);
+ rc_err_oom_die(rc);
+#endif
+ rc = sqlite3_exec(*pDb, zSetReps, 0, 0, 0);
+ rc_err_oom_die(rc);
+ rc = sqlite3_prepare_v2(*pDb, zRenameRank, -1, &pStmt, 0);
+ rc_err_oom_die(rc);
+ sqlite3_bind_int(pStmt, 1, nDigits);
+ rc = sqlite3_step(pStmt);
+ sqlite3_finalize(pStmt);
+ assert(rc==SQLITE_DONE);
+ }
+ assert(db_int(*pDb, zHasDupes)==0); /* Consider: remove this */
+ rc = sqlite3_prepare_v2(*pDb, zCollectVar, -1, &pStmt, 0);
+ rc_err_oom_die(rc);
+ rc = sqlite3_step(pStmt);
+ if( rc==SQLITE_ROW ){
+ zColsSpec = sqlite3_mprintf("%s", sqlite3_column_text(pStmt, 0));
+ }else{
+ zColsSpec = 0;
+ }
+ if( pzRenamed!=0 ){
+ if( !hasDupes ) *pzRenamed = 0;
+ else{
+ sqlite3_finalize(pStmt);
+ if( SQLITE_OK==sqlite3_prepare_v2(*pDb, zRenamesDone, -1, &pStmt, 0)
+ && SQLITE_ROW==sqlite3_step(pStmt) ){
+ *pzRenamed = sqlite3_mprintf("%s", sqlite3_column_text(pStmt, 0));
+ }else
+ *pzRenamed = 0;
+ }
+ }
+ sqlite3_finalize(pStmt);
+ sqlite3_close(*pDb);
+ *pDb = 0;
+ return zColsSpec;
+ }
+}
+
/*
** If an input line begins with "." then invoke this routine to
** process that line.
@@ -18902,8 +19419,9 @@ static int do_meta_command(char *zLine, ShellState *p){
while( sqlite3_step(pStmt)==SQLITE_ROW ){
const char *zSchema = (const char *)sqlite3_column_text(pStmt,1);
const char *zFile = (const char*)sqlite3_column_text(pStmt,2);
+ if( zSchema==0 || zFile==0 ) continue;
azName = sqlite3_realloc(azName, (nName+1)*2*sizeof(char*));
- if( azName==0 ){ shell_out_of_memory(); /* Does not return */ }
+ shell_check_oom(azName);
azName[nName*2] = strdup(zSchema);
azName[nName*2+1] = strdup(zFile);
nName++;
@@ -19159,8 +19677,15 @@ static int do_meta_command(char *zLine, ShellState *p){
#ifndef SQLITE_OMIT_VIRTUALTABLE
if( c=='e' && strncmp(azArg[0], "expert", n)==0 ){
- open_db(p, 0);
- expertDotCommand(p, azArg, nArg);
+ if( p->bSafeMode ){
+ raw_printf(stderr,
+ "Cannot run experimental commands such as \"%s\" in safe mode\n",
+ azArg[0]);
+ rc = 1;
+ }else{
+ open_db(p, 0);
+ expertDotCommand(p, azArg, nArg);
+ }
}else
#endif
@@ -19381,6 +19906,7 @@ static int do_meta_command(char *zLine, ShellState *p){
if( c=='i' && strncmp(azArg[0], "import", n)==0 ){
char *zTable = 0; /* Insert data into this table */
+ char *zSchema = 0; /* within this schema (may default to "main") */
char *zFile = 0; /* Name of file to extra content from */
sqlite3_stmt *pStmt = NULL; /* A statement */
int nCol; /* Number of columns in the table */
@@ -19389,11 +19915,13 @@ static int do_meta_command(char *zLine, ShellState *p){
int needCommit; /* True to COMMIT or ROLLBACK at end */
int nSep; /* Number of bytes in p->colSeparator[] */
char *zSql; /* An SQL statement */
+ char *zFullTabName; /* Table name with schema if applicable */
ImportCtx sCtx; /* Reader context */
char *(SQLITE_CDECL *xRead)(ImportCtx*); /* Func to read one value */
int eVerbose = 0; /* Larger for more console output */
int nSkip = 0; /* Initial lines to skip */
int useOutputMode = 1; /* Use output mode to determine separators */
+ char *zCreate = 0; /* CREATE TABLE statement text */
failIfSafeMode(p, "cannot run .import in safe mode");
memset(&sCtx, 0, sizeof(sCtx));
@@ -19423,6 +19951,8 @@ static int do_meta_command(char *zLine, ShellState *p){
}
}else if( strcmp(z,"-v")==0 ){
eVerbose++;
+ }else if( strcmp(z,"-schema")==0 && i<nArg-1 ){
+ zSchema = azArg[++i];
}else if( strcmp(z,"-skip")==0 && i<nArg-1 ){
nSkip = integerValue(azArg[++i]);
}else if( strcmp(z,"-ascii")==0 ){
@@ -19525,11 +20055,17 @@ static int do_meta_command(char *zLine, ShellState *p){
output_c_string(p->out, zSep);
utf8_printf(p->out, "\n");
}
+ /* Below, resources must be freed before exit. */
while( (nSkip--)>0 ){
while( xRead(&sCtx) && sCtx.cTerm==sCtx.cColSep ){}
}
- zSql = sqlite3_mprintf("SELECT * FROM \"%w\"", zTable);
- if( zSql==0 ){
+ if( zSchema!=0 ){
+ zFullTabName = sqlite3_mprintf("\"%w\".\"%w\"", zSchema, zTable);
+ }else{
+ zFullTabName = sqlite3_mprintf("\"%w\"", zTable);
+ }
+ zSql = sqlite3_mprintf("SELECT * FROM %s", zFullTabName);
+ if( zSql==0 || zFullTabName==0 ){
import_cleanup(&sCtx);
shell_out_of_memory();
}
@@ -19537,43 +20073,51 @@ static int do_meta_command(char *zLine, ShellState *p){
rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
import_append_char(&sCtx, 0); /* To ensure sCtx.z is allocated */
if( rc && sqlite3_strglob("no such table: *", sqlite3_errmsg(p->db))==0 ){
- char *zCreate = sqlite3_mprintf("CREATE TABLE \"%w\"", zTable);
- char cSep = '(';
+ sqlite3 *dbCols = 0;
+ char *zRenames = 0;
+ char *zColDefs;
+ zCreate = sqlite3_mprintf("CREATE TABLE %s", zFullTabName);
while( xRead(&sCtx) ){
- zCreate = sqlite3_mprintf("%z%c\n \"%w\" TEXT", zCreate, cSep, sCtx.z);
- cSep = ',';
+ zAutoColumn(sCtx.z, &dbCols, 0);
if( sCtx.cTerm!=sCtx.cColSep ) break;
}
- if( cSep=='(' ){
+ zColDefs = zAutoColumn(0, &dbCols, &zRenames);
+ if( zRenames!=0 ){
+ utf8_printf((stdin_is_interactive && p->in==stdin)? p->out : stderr,
+ "Columns renamed during .import %s due to duplicates:\n"
+ "%s\n", sCtx.zFile, zRenames);
+ sqlite3_free(zRenames);
+ }
+ assert(dbCols==0);
+ if( zColDefs==0 ){
+ utf8_printf(stderr,"%s: empty file\n", sCtx.zFile);
+ import_fail:
sqlite3_free(zCreate);
+ sqlite3_free(zSql);
+ sqlite3_free(zFullTabName);
import_cleanup(&sCtx);
- utf8_printf(stderr,"%s: empty file\n", sCtx.zFile);
rc = 1;
goto meta_command_exit;
}
- zCreate = sqlite3_mprintf("%z\n)", zCreate);
+ zCreate = sqlite3_mprintf("%z%z\n", zCreate, zColDefs);
if( eVerbose>=1 ){
utf8_printf(p->out, "%s\n", zCreate);
}
rc = sqlite3_exec(p->db, zCreate, 0, 0, 0);
- sqlite3_free(zCreate);
if( rc ){
- utf8_printf(stderr, "CREATE TABLE \"%s\"(...) failed: %s\n", zTable,
- sqlite3_errmsg(p->db));
- import_cleanup(&sCtx);
- rc = 1;
- goto meta_command_exit;
+ utf8_printf(stderr, "%s failed:\n%s\n", zCreate, sqlite3_errmsg(p->db));
+ goto import_fail;
}
+ sqlite3_free(zCreate);
+ zCreate = 0;
rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
}
- sqlite3_free(zSql);
if( rc ){
if (pStmt) sqlite3_finalize(pStmt);
utf8_printf(stderr,"Error: %s\n", sqlite3_errmsg(p->db));
- import_cleanup(&sCtx);
- rc = 1;
- goto meta_command_exit;
+ goto import_fail;
}
+ sqlite3_free(zSql);
nCol = sqlite3_column_count(pStmt);
sqlite3_finalize(pStmt);
pStmt = 0;
@@ -19583,7 +20127,7 @@ static int do_meta_command(char *zLine, ShellState *p){
import_cleanup(&sCtx);
shell_out_of_memory();
}
- sqlite3_snprintf(nByte+20, zSql, "INSERT INTO \"%w\" VALUES(?", zTable);
+ sqlite3_snprintf(nByte+20, zSql, "INSERT INTO %s VALUES(?", zFullTabName);
j = strlen30(zSql);
for(i=1; i<nCol; i++){
zSql[j++] = ',';
@@ -19595,14 +20139,13 @@ static int do_meta_command(char *zLine, ShellState *p){
utf8_printf(p->out, "Insert using: %s\n", zSql);
}
rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
- sqlite3_free(zSql);
if( rc ){
utf8_printf(stderr, "Error: %s\n", sqlite3_errmsg(p->db));
if (pStmt) sqlite3_finalize(pStmt);
- import_cleanup(&sCtx);
- rc = 1;
- goto meta_command_exit;
+ goto import_fail;
}
+ sqlite3_free(zSql);
+ sqlite3_free(zFullTabName);
needCommit = sqlite3_get_autocommit(p->db);
if( needCommit ) sqlite3_exec(p->db, "BEGIN", 0, 0, 0);
do{
@@ -19884,60 +20427,123 @@ static int do_meta_command(char *zLine, ShellState *p){
}else
if( c=='m' && strncmp(azArg[0], "mode", n)==0 ){
- const char *zMode = nArg>=2 ? azArg[1] : "";
- int n2 = strlen30(zMode);
- int c2 = zMode[0];
- if( c2=='l' && n2>2 && strncmp(azArg[1],"lines",n2)==0 ){
+ const char *zMode = 0;
+ const char *zTabname = 0;
+ int i, n2;
+ ColModeOpts cmOpts = ColModeOpts_default;
+ for(i=1; i<nArg; i++){
+ const char *z = azArg[i];
+ if( optionMatch(z,"wrap") && i+1<nArg ){
+ cmOpts.iWrap = integerValue(azArg[++i]);
+ }else if( optionMatch(z,"ww") ){
+ cmOpts.bWordWrap = 1;
+ }else if( optionMatch(z,"wordwrap") && i+1<nArg ){
+ cmOpts.bWordWrap = (u8)booleanValue(azArg[++i]);
+ }else if( optionMatch(z,"quote") ){
+ cmOpts.bQuote = 1;
+ }else if( optionMatch(z,"noquote") ){
+ cmOpts.bQuote = 0;
+ }else if( zMode==0 ){
+ zMode = z;
+ /* Apply defaults for qbox pseudo-mods. If that
+ * overwrites already-set values, user was informed of this.
+ */
+ if( strcmp(z, "qbox")==0 ){
+ ColModeOpts cmo = ColModeOpts_default_qbox;
+ zMode = "box";
+ cmOpts = cmo;
+ }
+ }else if( zTabname==0 ){
+ zTabname = z;
+ }else if( z[0]=='-' ){
+ utf8_printf(stderr, "unknown option: %s\n", z);
+ utf8_printf(stderr, "options:\n"
+ " --noquote\n"
+ " --quote\n"
+ " --wordwrap on/off\n"
+ " --wrap N\n"
+ " --ww\n");
+ rc = 1;
+ goto meta_command_exit;
+ }else{
+ utf8_printf(stderr, "extra argument: \"%s\"\n", z);
+ rc = 1;
+ goto meta_command_exit;
+ }
+ }
+ if( zMode==0 ){
+ if( p->mode==MODE_Column
+ || (p->mode>=MODE_Markdown && p->mode<=MODE_Box)
+ ){
+ raw_printf
+ (p->out,
+ "current output mode: %s --wrap %d --wordwrap %s --%squote\n",
+ modeDescr[p->mode], p->cmOpts.iWrap,
+ p->cmOpts.bWordWrap ? "on" : "off",
+ p->cmOpts.bQuote ? "" : "no");
+ }else{
+ raw_printf(p->out, "current output mode: %s\n", modeDescr[p->mode]);
+ }
+ zMode = modeDescr[p->mode];
+ }
+ n2 = strlen30(zMode);
+ if( strncmp(zMode,"lines",n2)==0 ){
p->mode = MODE_Line;
sqlite3_snprintf(sizeof(p->rowSeparator), p->rowSeparator, SEP_Row);
- }else if( c2=='c' && strncmp(azArg[1],"columns",n2)==0 ){
+ }else if( strncmp(zMode,"columns",n2)==0 ){
p->mode = MODE_Column;
if( (p->shellFlgs & SHFLG_HeaderSet)==0 ){
p->showHeader = 1;
}
sqlite3_snprintf(sizeof(p->rowSeparator), p->rowSeparator, SEP_Row);
- }else if( c2=='l' && n2>2 && strncmp(azArg[1],"list",n2)==0 ){
+ p->cmOpts = cmOpts;
+ }else if( strncmp(zMode,"list",n2)==0 ){
p->mode = MODE_List;
sqlite3_snprintf(sizeof(p->colSeparator), p->colSeparator, SEP_Column);
sqlite3_snprintf(sizeof(p->rowSeparator), p->rowSeparator, SEP_Row);
- }else if( c2=='h' && strncmp(azArg[1],"html",n2)==0 ){
+ }else if( strncmp(zMode,"html",n2)==0 ){
p->mode = MODE_Html;
- }else if( c2=='t' && strncmp(azArg[1],"tcl",n2)==0 ){
+ }else if( strncmp(zMode,"tcl",n2)==0 ){
p->mode = MODE_Tcl;
sqlite3_snprintf(sizeof(p->colSeparator), p->colSeparator, SEP_Space);
sqlite3_snprintf(sizeof(p->rowSeparator), p->rowSeparator, SEP_Row);
- }else if( c2=='c' && strncmp(azArg[1],"csv",n2)==0 ){
+ }else if( strncmp(zMode,"csv",n2)==0 ){
p->mode = MODE_Csv;
sqlite3_snprintf(sizeof(p->colSeparator), p->colSeparator, SEP_Comma);
sqlite3_snprintf(sizeof(p->rowSeparator), p->rowSeparator, SEP_CrLf);
- }else if( c2=='t' && strncmp(azArg[1],"tabs",n2)==0 ){
+ }else if( strncmp(zMode,"tabs",n2)==0 ){
p->mode = MODE_List;
sqlite3_snprintf(sizeof(p->colSeparator), p->colSeparator, SEP_Tab);
- }else if( c2=='i' && strncmp(azArg[1],"insert",n2)==0 ){
+ }else if( strncmp(zMode,"insert",n2)==0 ){
p->mode = MODE_Insert;
- set_table_name(p, nArg>=3 ? azArg[2] : "table");
- }else if( c2=='q' && strncmp(azArg[1],"quote",n2)==0 ){
+ set_table_name(p, zTabname ? zTabname : "table");
+ }else if( strncmp(zMode,"quote",n2)==0 ){
p->mode = MODE_Quote;
sqlite3_snprintf(sizeof(p->colSeparator), p->colSeparator, SEP_Comma);
sqlite3_snprintf(sizeof(p->rowSeparator), p->rowSeparator, SEP_Row);
- }else if( c2=='a' && strncmp(azArg[1],"ascii",n2)==0 ){
+ }else if( strncmp(zMode,"ascii",n2)==0 ){
p->mode = MODE_Ascii;
sqlite3_snprintf(sizeof(p->colSeparator), p->colSeparator, SEP_Unit);
sqlite3_snprintf(sizeof(p->rowSeparator), p->rowSeparator, SEP_Record);
- }else if( c2=='m' && strncmp(azArg[1],"markdown",n2)==0 ){
+ }else if( strncmp(zMode,"markdown",n2)==0 ){
p->mode = MODE_Markdown;
- }else if( c2=='t' && strncmp(azArg[1],"table",n2)==0 ){
+ p->cmOpts = cmOpts;
+ }else if( strncmp(zMode,"table",n2)==0 ){
p->mode = MODE_Table;
- }else if( c2=='b' && strncmp(azArg[1],"box",n2)==0 ){
+ p->cmOpts = cmOpts;
+ }else if( strncmp(zMode,"box",n2)==0 ){
p->mode = MODE_Box;
- }else if( c2=='j' && strncmp(azArg[1],"json",n2)==0 ){
+ p->cmOpts = cmOpts;
+ }else if( strncmp(zMode,"count",n2)==0 ){
+ p->mode = MODE_Count;
+ }else if( strncmp(zMode,"off",n2)==0 ){
+ p->mode = MODE_Off;
+ }else if( strncmp(zMode,"json",n2)==0 ){
p->mode = MODE_Json;
- }else if( nArg==1 ){
- raw_printf(p->out, "current output mode: %s\n", modeDescr[p->mode]);
}else{
raw_printf(stderr, "Error: mode should be one of: "
"ascii box column csv html insert json line list markdown "
- "quote table tabs tcl\n");
+ "qbox quote table tabs tcl\n");
rc = 1;
}
p->cMode = p->mode;
@@ -19948,7 +20554,8 @@ static int do_meta_command(char *zLine, ShellState *p){
raw_printf(stderr, "Usage: .nonce NONCE\n");
rc = 1;
}else if( p->zNonce==0 || strcmp(azArg[1],p->zNonce)!=0 ){
- raw_printf(stderr, "line %d: incorrect nonce: \"%s\"\n", p->lineno, azArg[1]);
+ raw_printf(stderr, "line %d: incorrect nonce: \"%s\"\n",
+ p->lineno, azArg[1]);
exit(1);
}else{
p->bSafeMode = 0;
@@ -19967,35 +20574,8 @@ static int do_meta_command(char *zLine, ShellState *p){
}
}else
-#ifdef SQLITE_DEBUG
- if( c=='o' && strcmp(azArg[0],"oom")==0 ){
- int i;
- for(i=1; i<nArg; i++){
- const char *z = azArg[i];
- if( z[0]=='-' && z[1]=='-' ) z++;
- if( strcmp(z,"-repeat")==0 ){
- if( i==nArg-1 ){
- raw_printf(p->out, "missing argument on \"%s\"\n", azArg[i]);
- rc = 1;
- }else{
- oomRepeat = (int)integerValue(azArg[++i]);
- }
- }else if( IsDigit(z[0]) ){
- oomCounter = (int)integerValue(azArg[i]);
- }else{
- raw_printf(p->out, "unknown argument: \"%s\"\n", azArg[i]);
- raw_printf(p->out, "Usage: .oom [--repeat N] [M]\n");
- rc = 1;
- }
- }
- if( rc==0 ){
- raw_printf(p->out, "oomCounter = %d\n", oomCounter);
- raw_printf(p->out, "oomRepeat = %d\n", oomRepeat);
- }
- }else
-#endif /* SQLITE_DEBUG */
-
if( c=='o' && strncmp(azArg[0], "open", n)==0 && n>=2 ){
+ const char *zFN = 0; /* Pointer to constant filename */
char *zNewFilename = 0; /* Name of the database file to open */
int iName = 1; /* Index in azArg[] of the filename */
int newFlag = 0; /* True to delete file before opening */
@@ -20028,12 +20608,12 @@ static int do_meta_command(char *zLine, ShellState *p){
utf8_printf(stderr, "unknown option: %s\n", z);
rc = 1;
goto meta_command_exit;
- }else if( zNewFilename ){
+ }else if( zFN ){
utf8_printf(stderr, "extra argument: \"%s\"\n", z);
rc = 1;
goto meta_command_exit;
}else{
- zNewFilename = sqlite3_mprintf("%s", z);
+ zFN = z;
}
}
@@ -20049,15 +20629,21 @@ static int do_meta_command(char *zLine, ShellState *p){
p->szMax = 0;
/* If a filename is specified, try to open it first */
- if( zNewFilename || p->openMode==SHELL_OPEN_HEXDB ){
- if( newFlag && !p->bSafeMode ) shellDeleteFile(zNewFilename);
+ if( zFN || p->openMode==SHELL_OPEN_HEXDB ){
+ if( newFlag && zFN && !p->bSafeMode ) shellDeleteFile(zFN);
if( p->bSafeMode
&& p->openMode!=SHELL_OPEN_HEXDB
- && zNewFilename
- && strcmp(zNewFilename,":memory:")!=0
+ && zFN
+ && strcmp(zFN,":memory:")!=0
){
failIfSafeMode(p, "cannot open disk-based database files in safe mode");
}
+ if( zFN ){
+ zNewFilename = sqlite3_mprintf("%s", zFN);
+ shell_check_oom(zNewFilename);
+ }else{
+ zNewFilename = 0;
+ }
p->pAuxDb->zDbFilename = zNewFilename;
open_db(p, OPEN_DB_KEEPALIVE);
if( p->db==0 ){
@@ -20111,7 +20697,7 @@ static int do_meta_command(char *zLine, ShellState *p){
}
}else if( zFile==0 && eMode!='e' && eMode!='x' ){
zFile = sqlite3_mprintf("%s", z);
- if( zFile[0]=='|' ){
+ if( zFile && zFile[0]=='|' ){
while( i+1<nArg ) zFile = sqlite3_mprintf("%z %s", zFile, azArg[++i]);
break;
}
@@ -20124,7 +20710,9 @@ static int do_meta_command(char *zLine, ShellState *p){
goto meta_command_exit;
}
}
- if( zFile==0 ) zFile = sqlite3_mprintf("stdout");
+ if( zFile==0 ){
+ zFile = sqlite3_mprintf("stdout");
+ }
if( bOnce ){
p->outCount = 2;
}else{
@@ -20151,6 +20739,7 @@ static int do_meta_command(char *zLine, ShellState *p){
zFile = sqlite3_mprintf("%s", p->zTempFile);
}
#endif /* SQLITE_NOHAVE_SYSTEM */
+ shell_check_oom(zFile);
if( zFile[0]=='|' ){
#ifdef SQLITE_OMIT_POPEN
raw_printf(stderr, "Error: pipes are not supported in this OS\n");
@@ -20247,7 +20836,7 @@ static int do_meta_command(char *zLine, ShellState *p){
zSql = sqlite3_mprintf(
"REPLACE INTO temp.sqlite_parameters(key,value)"
"VALUES(%Q,%s);", zKey, zValue);
- if( zSql==0 ) shell_out_of_memory();
+ shell_check_oom(zSql);
pStmt = 0;
rx = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
sqlite3_free(zSql);
@@ -20257,7 +20846,7 @@ static int do_meta_command(char *zLine, ShellState *p){
zSql = sqlite3_mprintf(
"REPLACE INTO temp.sqlite_parameters(key,value)"
"VALUES(%Q,%Q);", zKey, zValue);
- if( zSql==0 ) shell_out_of_memory();
+ shell_check_oom(zSql);
rx = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
sqlite3_free(zSql);
if( rx!=SQLITE_OK ){
@@ -20278,7 +20867,7 @@ static int do_meta_command(char *zLine, ShellState *p){
if( nArg==3 && strcmp(azArg[1],"unset")==0 ){
char *zSql = sqlite3_mprintf(
"DELETE FROM temp.sqlite_parameters WHERE key=%Q", azArg[2]);
- if( zSql==0 ) shell_out_of_memory();
+ shell_check_oom(zSql);
sqlite3_exec(p->db, zSql, 0, 0, 0);
sqlite3_free(zSql);
}else
@@ -20504,6 +21093,7 @@ static int do_meta_command(char *zLine, ShellState *p){
" rootpage integer,\n"
" sql text\n"
")", zName);
+ shell_check_oom(new_argv[0]);
new_argv[1] = 0;
new_colv[0] = "sql";
new_colv[1] = 0;
@@ -20555,8 +21145,10 @@ static int do_meta_command(char *zLine, ShellState *p){
appendText(&sSelect, ") WHERE ", 0);
if( zName ){
char *zQarg = sqlite3_mprintf("%Q", zName);
- int bGlob = strchr(zName, '*') != 0 || strchr(zName, '?') != 0 ||
- strchr(zName, '[') != 0;
+ int bGlob;
+ shell_check_oom(zQarg);
+ bGlob = strchr(zName, '*') != 0 || strchr(zName, '?') != 0 ||
+ strchr(zName, '[') != 0;
if( strchr(zName, '.') ){
appendText(&sSelect, "lower(printf('%s.%s',sname,tbl_name))", 0);
}else{
@@ -20719,7 +21311,8 @@ static int do_meta_command(char *zLine, ShellState *p){
exit(1);
}
for(ii=1; ii<nCmd; ii++){
- pSession->azFilter[ii-1] = sqlite3_mprintf("%s", azCmd[ii]);
+ char *x = pSession->azFilter[ii-1] = sqlite3_mprintf("%s", azCmd[ii]);
+ shell_check_oom(x);
}
pSession->nFilter = ii-1;
}
@@ -20791,6 +21384,7 @@ static int do_meta_command(char *zLine, ShellState *p){
sqlite3session_table_filter(pSession->p, session_filter, pSession);
pAuxDb->nSession++;
pSession->zName = sqlite3_mprintf("%s", zName);
+ shell_check_oom(pSession->zName);
}else
/* If no command name matches, show a syntax error */
session_syntax_error:
@@ -20884,11 +21478,12 @@ static int do_meta_command(char *zLine, ShellState *p){
const char *zSql = (const char*)sqlite3_column_text(pStmt, 2);
const char *zAns = (const char*)sqlite3_column_text(pStmt, 3);
+ if( zOp==0 ) continue;
+ if( zSql==0 ) continue;
+ if( zAns==0 ) continue;
k = 0;
if( bVerbose>0 ){
- char *zQuote = sqlite3_mprintf("%q", zSql);
printf("%d: %s %s\n", tno, zOp, zSql);
- sqlite3_free(zQuote);
}
if( strcmp(zOp,"memo")==0 ){
utf8_printf(p->out, "%s\n", zSql);
@@ -21006,6 +21601,7 @@ static int do_meta_command(char *zLine, ShellState *p){
zSep = "VALUES(";
while( SQLITE_ROW==sqlite3_step(pStmt) ){
const char *zTab = (const char*)sqlite3_column_text(pStmt,0);
+ if( zTab==0 ) continue;
if( zLike && sqlite3_strlike(zLike, zTab, 0)!=0 ) continue;
if( strncmp(zTab, "sqlite_",7)!=0 ){
appendText(&sQuery,"SELECT * FROM ", 0);
@@ -21046,6 +21642,7 @@ static int do_meta_command(char *zLine, ShellState *p){
" FROM [sha3sum$query]",
sSql.z, iSize);
}
+ shell_check_oom(zSql);
freeText(&sQuery);
freeText(&sSql);
if( bDebug ){
@@ -21069,11 +21666,11 @@ static int do_meta_command(char *zLine, ShellState *p){
goto meta_command_exit;
}
zCmd = sqlite3_mprintf(strchr(azArg[1],' ')==0?"%s":"\"%s\"", azArg[1]);
- for(i=2; i<nArg; i++){
+ for(i=2; i<nArg && zCmd!=0; i++){
zCmd = sqlite3_mprintf(strchr(azArg[i],' ')==0?"%z %s":"%z \"%s\"",
zCmd, azArg[i]);
}
- x = system(zCmd);
+ x = zCmd!=0 ? system(zCmd) : 1;
sqlite3_free(zCmd);
if( x ) raw_printf(stderr, "System command returns %d\n", x);
}else
@@ -21094,7 +21691,17 @@ static int do_meta_command(char *zLine, ShellState *p){
utf8_printf(p->out, "%12.12s: %s\n","explain",
p->mode==MODE_Explain ? "on" : p->autoExplain ? "auto" : "off");
utf8_printf(p->out,"%12.12s: %s\n","headers", azBool[p->showHeader!=0]);
- utf8_printf(p->out, "%12.12s: %s\n","mode", modeDescr[p->mode]);
+ if( p->mode==MODE_Column
+ || (p->mode>=MODE_Markdown && p->mode<=MODE_Box)
+ ){
+ utf8_printf
+ (p->out, "%12.12s: %s --wrap %d --wordwrap %s --%squote\n", "mode",
+ modeDescr[p->mode], p->cmOpts.iWrap,
+ p->cmOpts.bWordWrap ? "on" : "off",
+ p->cmOpts.bQuote ? "" : "no");
+ }else{
+ utf8_printf(p->out, "%12.12s: %s\n","mode", modeDescr[p->mode]);
+ }
utf8_printf(p->out, "%12.12s: ", "nullvalue");
output_c_string(p->out, p->nullValue);
raw_printf(p->out, "\n");
@@ -21209,12 +21816,12 @@ static int do_meta_command(char *zLine, ShellState *p){
char **azNew;
int n2 = nAlloc*2 + 10;
azNew = sqlite3_realloc64(azResult, sizeof(azResult[0])*n2);
- if( azNew==0 ) shell_out_of_memory();
+ shell_check_oom(azNew);
nAlloc = n2;
azResult = azNew;
}
azResult[nRow] = sqlite3_mprintf("%s", sqlite3_column_text(pStmt, 0));
- if( 0==azResult[nRow] ) shell_out_of_memory();
+ shell_check_oom(azResult[nRow]);
nRow++;
}
if( sqlite3_finalize(pStmt)!=SQLITE_OK ){
@@ -21892,19 +22499,30 @@ static int runOneSqlLine(ShellState *p, char *zSql, FILE *in, int startline){
END_TIMER;
if( rc || zErrMsg ){
char zPrefix[100];
- if( in!=0 || !stdin_is_interactive ){
- sqlite3_snprintf(sizeof(zPrefix), zPrefix,
- "Error: near line %d:", startline);
+ const char *zErrorTail;
+ const char *zErrorType;
+ if( zErrMsg==0 ){
+ zErrorType = "Error";
+ zErrorTail = sqlite3_errmsg(p->db);
+ }else if( strncmp(zErrMsg, "in prepare, ",12)==0 ){
+ zErrorType = "Parse error";
+ zErrorTail = &zErrMsg[12];
+ }else if( strncmp(zErrMsg, "stepping, ", 10)==0 ){
+ zErrorType = "Runtime error";
+ zErrorTail = &zErrMsg[10];
}else{
- sqlite3_snprintf(sizeof(zPrefix), zPrefix, "Error:");
+ zErrorType = "Error";
+ zErrorTail = zErrMsg;
}
- if( zErrMsg!=0 ){
- utf8_printf(stderr, "%s %s\n", zPrefix, zErrMsg);
- sqlite3_free(zErrMsg);
- zErrMsg = 0;
+ if( in!=0 || !stdin_is_interactive ){
+ sqlite3_snprintf(sizeof(zPrefix), zPrefix,
+ "%s near line %d:", zErrorType, startline);
}else{
- utf8_printf(stderr, "%s %s\n", zPrefix, sqlite3_errmsg(p->db));
+ sqlite3_snprintf(sizeof(zPrefix), zPrefix, "%s:", zErrorType);
}
+ utf8_printf(stderr, "%s %s\n", zPrefix, zErrorTail);
+ sqlite3_free(zErrMsg);
+ zErrMsg = 0;
return 1;
}else if( ShellHasFlag(p, SHFLG_CountChanges) ){
char zLineBuf[2000];
@@ -21937,6 +22555,13 @@ static int process_input(ShellState *p){
int startline = 0; /* Line number for start of current input */
QuickScanState qss = QSS_Start; /* Accumulated line status (so far) */
+ if( p->inputNesting==MAX_INPUT_NESTING ){
+ /* This will be more informative in a later version. */
+ utf8_printf(stderr,"Input nesting limit (%d) reached at line %d."
+ " Check recursion.\n", MAX_INPUT_NESTING, p->lineno);
+ return 1;
+ }
+ ++p->inputNesting;
p->lineno = 0;
while( errCnt==0 || !bail_on_error || (p->in==0 && stdin_is_interactive) ){
fflush(p->out);
@@ -21983,7 +22608,7 @@ static int process_input(ShellState *p){
/* Grow buffer by half-again increments when big. */
nAlloc = nSql+(nSql>>1)+nLine+100;
zSql = realloc(zSql, nAlloc);
- if( zSql==0 ) shell_out_of_memory();
+ shell_check_oom(zSql);
}
if( nSql==0 ){
int i;
@@ -22019,6 +22644,7 @@ static int process_input(ShellState *p){
}
free(zSql);
free(zLine);
+ --p->inputNesting;
return errCnt>0;
}
@@ -22115,6 +22741,7 @@ static void process_sqliterc(
return;
}
zBuf = sqlite3_mprintf("%s/.sqliterc",home_dir);
+ shell_check_oom(zBuf);
sqliterc = zBuf;
}
p->in = fopen(sqliterc,"rb");
@@ -22313,10 +22940,6 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){
stdin_is_interactive = isatty(0);
stdout_is_console = isatty(1);
-#ifdef SQLITE_DEBUG
- registerOomSimulator();
-#endif
-
#if !defined(_WIN32_WCE)
if( getenv("SQLITE_DEBUG_BREAK") ){
if( isatty(0) && isatty(2) ){
@@ -22356,16 +22979,16 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){
#if !SQLITE_SHELL_IS_UTF8
sqlite3_initialize();
argvToFree = malloc(sizeof(argv[0])*argc*2);
+ shell_check_oom(argvToFree);
argcToFree = argc;
argv = argvToFree + argc;
- if( argv==0 ) shell_out_of_memory();
for(i=0; i<argc; i++){
char *z = sqlite3_win32_unicode_to_utf8(wargv[i]);
int n;
- if( z==0 ) shell_out_of_memory();
+ shell_check_oom(z);
n = (int)strlen(z);
argv[i] = malloc( n+1 );
- if( argv[i]==0 ) shell_out_of_memory();
+ shell_check_oom(argv[i]);
memcpy(argv[i], z, n+1);
argvToFree[i] = argv[i];
sqlite3_free(z);
@@ -22415,7 +23038,7 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){
readStdin = 0;
nCmd++;
azCmd = realloc(azCmd, sizeof(azCmd[0])*nCmd);
- if( azCmd==0 ) shell_out_of_memory();
+ shell_check_oom(azCmd);
azCmd[nCmd-1] = z;
}
}
diff --git a/chromium/third_party/sqlite/src/amalgamation/sqlite3.c b/chromium/third_party/sqlite/src/amalgamation/sqlite3.c
index f8e53e4064d..4f3bbab24a2 100644
--- a/chromium/third_party/sqlite/src/amalgamation/sqlite3.c
+++ b/chromium/third_party/sqlite/src/amalgamation/sqlite3.c
@@ -1,6 +1,6 @@
/******************************************************************************
** This file is an amalgamation of many separate C source files from SQLite
-** version 3.37.1. By combining all the individual C code files into this
+** version 3.38.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
@@ -452,9 +452,9 @@ extern "C" {
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
** [sqlite_version()] and [sqlite_source_id()].
*/
-#define SQLITE_VERSION "3.37.1"
-#define SQLITE_VERSION_NUMBER 3037001
-#define SQLITE_SOURCE_ID "2021-12-30 15:30:28 378629bf2ea546f73eee84063c5358439a12f7300e433f18c9e1bddd948dea62"
+#define SQLITE_VERSION "3.38.1"
+#define SQLITE_VERSION_NUMBER 3038001
+#define SQLITE_SOURCE_ID "2022-03-12 13:37:29 38c210fdd258658321c85ec9c01a072fda3ada94540e3239d29b34dc547a8cbc"
/*
** CAPI3REF: Run-Time Library Version Numbers
@@ -872,7 +872,7 @@ SQLITE_API int sqlite3_exec(
#define SQLITE_WARNING_AUTOINDEX (SQLITE_WARNING | (1<<8))
#define SQLITE_AUTH_USER (SQLITE_AUTH | (1<<8))
#define SQLITE_OK_LOAD_PERMANENTLY (SQLITE_OK | (1<<8))
-#define SQLITE_OK_SYMLINK (SQLITE_OK | (2<<8))
+#define SQLITE_OK_SYMLINK (SQLITE_OK | (2<<8)) /* internal use only */
/*
** CAPI3REF: Flags For File Open Operations
@@ -4130,13 +4130,14 @@ SQLITE_API void sqlite3_free_filename(char*);
** sqlite3_extended_errcode() might change with each API call.
** Except, there are some interfaces that are guaranteed to never
** change the value of the error code. The error-code preserving
-** interfaces are:
+** interfaces include the following:
**
** <ul>
** <li> sqlite3_errcode()
** <li> sqlite3_extended_errcode()
** <li> sqlite3_errmsg()
** <li> sqlite3_errmsg16()
+** <li> sqlite3_error_offset()
** </ul>
**
** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language
@@ -4151,6 +4152,13 @@ SQLITE_API void sqlite3_free_filename(char*);
** ^(Memory to hold the error message string is managed internally
** and must not be freed by the application)^.
**
+** ^If the most recent error references a specific token in the input
+** SQL, the sqlite3_error_offset() interface returns the byte offset
+** of the start of that token. ^The byte offset returned by
+** sqlite3_error_offset() assumes that the input SQL is UTF8.
+** ^If the most recent error does not reference a specific token in the input
+** SQL, then the sqlite3_error_offset() function returns -1.
+**
** When the serialized [threading mode] is in use, it might be the
** case that a second error occurs on a separate thread in between
** the time of the first error and the call to these interfaces.
@@ -4170,6 +4178,7 @@ SQLITE_API int sqlite3_extended_errcode(sqlite3 *db);
SQLITE_API const char *sqlite3_errmsg(sqlite3*);
SQLITE_API const void *sqlite3_errmsg16(sqlite3*);
SQLITE_API const char *sqlite3_errstr(int);
+SQLITE_API int sqlite3_error_offset(sqlite3 *db);
/*
** CAPI3REF: Prepared Statement Object
@@ -4581,6 +4590,10 @@ SQLITE_API const char *sqlite3_normalized_sql(sqlite3_stmt *pStmt);
** be false. ^Similarly, a CREATE TABLE IF NOT EXISTS statement is a
** read-only no-op if the table already exists, but
** sqlite3_stmt_readonly() still returns false for such a statement.
+**
+** ^If prepared statement X is an [EXPLAIN] or [EXPLAIN QUERY PLAN]
+** statement, then sqlite3_stmt_readonly(X) returns the same value as
+** if the EXPLAIN or EXPLAIN QUERY PLAN prefix were omitted.
*/
SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt);
@@ -4649,6 +4662,8 @@ SQLITE_API int sqlite3_stmt_busy(sqlite3_stmt*);
**
** ^The sqlite3_value objects that are passed as parameters into the
** implementation of [application-defined SQL functions] are protected.
+** ^The sqlite3_value objects returned by [sqlite3_vtab_rhs_value()]
+** are protected.
** ^The sqlite3_value object returned by
** [sqlite3_column_value()] is unprotected.
** Unprotected sqlite3_value objects may only be used as arguments
@@ -5270,6 +5285,10 @@ SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
** even empty strings, are always zero-terminated. ^The return
** value from sqlite3_column_blob() for a zero-length BLOB is a NULL pointer.
**
+** ^Strings returned by sqlite3_column_text16() always have the endianness
+** which is native to the platform, regardless of the text encoding set
+** for the database.
+**
** <b>Warning:</b> ^The object returned by [sqlite3_column_value()] is an
** [unprotected sqlite3_value] object. In a multithreaded environment,
** an unprotected sqlite3_value object may only be used safely with
@@ -5283,7 +5302,7 @@ SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
** [application-defined SQL functions] or [virtual tables], not within
** top-level application code.
**
-** The these routines may attempt to convert the datatype of the result.
+** These routines may attempt to convert the datatype of the result.
** ^For example, if the internal representation is FLOAT and a text result
** is requested, [sqlite3_snprintf()] is used internally to perform the
** conversion automatically. ^(The following table details the conversions
@@ -5308,7 +5327,7 @@ SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
** <tr><td> TEXT <td> BLOB <td> No change
** <tr><td> BLOB <td> INTEGER <td> [CAST] to INTEGER
** <tr><td> BLOB <td> FLOAT <td> [CAST] to REAL
-** <tr><td> BLOB <td> TEXT <td> Add a zero terminator if needed
+** <tr><td> BLOB <td> TEXT <td> [CAST] to TEXT, ensure zero terminator
** </table>
** </blockquote>)^
**
@@ -7428,24 +7447,56 @@ struct sqlite3_index_info {
**
** These macros define the allowed values for the
** [sqlite3_index_info].aConstraint[].op field. Each value represents
-** an operator that is part of a constraint term in the wHERE clause of
+** an operator that is part of a constraint term in the WHERE clause of
** a query that uses a [virtual table].
-*/
-#define SQLITE_INDEX_CONSTRAINT_EQ 2
-#define SQLITE_INDEX_CONSTRAINT_GT 4
-#define SQLITE_INDEX_CONSTRAINT_LE 8
-#define SQLITE_INDEX_CONSTRAINT_LT 16
-#define SQLITE_INDEX_CONSTRAINT_GE 32
-#define SQLITE_INDEX_CONSTRAINT_MATCH 64
-#define SQLITE_INDEX_CONSTRAINT_LIKE 65
-#define SQLITE_INDEX_CONSTRAINT_GLOB 66
-#define SQLITE_INDEX_CONSTRAINT_REGEXP 67
-#define SQLITE_INDEX_CONSTRAINT_NE 68
-#define SQLITE_INDEX_CONSTRAINT_ISNOT 69
-#define SQLITE_INDEX_CONSTRAINT_ISNOTNULL 70
-#define SQLITE_INDEX_CONSTRAINT_ISNULL 71
-#define SQLITE_INDEX_CONSTRAINT_IS 72
-#define SQLITE_INDEX_CONSTRAINT_FUNCTION 150
+**
+** ^The left-hand operand of the operator is given by the corresponding
+** aConstraint[].iColumn field. ^An iColumn of -1 indicates the left-hand
+** operand is the rowid.
+** The SQLITE_INDEX_CONSTRAINT_LIMIT and SQLITE_INDEX_CONSTRAINT_OFFSET
+** operators have no left-hand operand, and so for those operators the
+** corresponding aConstraint[].iColumn is meaningless and should not be
+** used.
+**
+** All operator values from SQLITE_INDEX_CONSTRAINT_FUNCTION through
+** value 255 are reserved to represent functions that are overloaded
+** by the [xFindFunction|xFindFunction method] of the virtual table
+** implementation.
+**
+** The right-hand operands for each constraint might be accessible using
+** the [sqlite3_vtab_rhs_value()] interface. Usually the right-hand
+** operand is only available if it appears as a single constant literal
+** in the input SQL. If the right-hand operand is another column or an
+** expression (even a constant expression) or a parameter, then the
+** sqlite3_vtab_rhs_value() probably will not be able to extract it.
+** ^The SQLITE_INDEX_CONSTRAINT_ISNULL and
+** SQLITE_INDEX_CONSTRAINT_ISNOTNULL operators have no right-hand operand
+** and hence calls to sqlite3_vtab_rhs_value() for those operators will
+** always return SQLITE_NOTFOUND.
+**
+** The collating sequence to be used for comparison can be found using
+** the [sqlite3_vtab_collation()] interface. For most real-world virtual
+** tables, the collating sequence of constraints does not matter (for example
+** because the constraints are numeric) and so the sqlite3_vtab_collation()
+** interface is no commonly needed.
+*/
+#define SQLITE_INDEX_CONSTRAINT_EQ 2
+#define SQLITE_INDEX_CONSTRAINT_GT 4
+#define SQLITE_INDEX_CONSTRAINT_LE 8
+#define SQLITE_INDEX_CONSTRAINT_LT 16
+#define SQLITE_INDEX_CONSTRAINT_GE 32
+#define SQLITE_INDEX_CONSTRAINT_MATCH 64
+#define SQLITE_INDEX_CONSTRAINT_LIKE 65
+#define SQLITE_INDEX_CONSTRAINT_GLOB 66
+#define SQLITE_INDEX_CONSTRAINT_REGEXP 67
+#define SQLITE_INDEX_CONSTRAINT_NE 68
+#define SQLITE_INDEX_CONSTRAINT_ISNOT 69
+#define SQLITE_INDEX_CONSTRAINT_ISNOTNULL 70
+#define SQLITE_INDEX_CONSTRAINT_ISNULL 71
+#define SQLITE_INDEX_CONSTRAINT_IS 72
+#define SQLITE_INDEX_CONSTRAINT_LIMIT 73
+#define SQLITE_INDEX_CONSTRAINT_OFFSET 74
+#define SQLITE_INDEX_CONSTRAINT_FUNCTION 150
/*
** CAPI3REF: Register A Virtual Table Implementation
@@ -7474,7 +7525,7 @@ struct sqlite3_index_info {
** destructor.
**
** ^If the third parameter (the pointer to the sqlite3_module object) is
-** NULL then no new module is create and any existing modules with the
+** NULL then no new module is created and any existing modules with the
** same name are dropped.
**
** See also: [sqlite3_drop_modules()]
@@ -8250,7 +8301,8 @@ SQLITE_API int sqlite3_test_control(int op, ...);
#define SQLITE_TESTCTRL_SEEK_COUNT 30
#define SQLITE_TESTCTRL_TRACEFLAGS 31
#define SQLITE_TESTCTRL_TUNE 32
-#define SQLITE_TESTCTRL_LAST 32 /* Largest TESTCTRL */
+#define SQLITE_TESTCTRL_LOGEST 33
+#define SQLITE_TESTCTRL_LAST 33 /* Largest TESTCTRL */
/*
** CAPI3REF: SQL Keyword Checking
@@ -8773,6 +8825,16 @@ SQLITE_API int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);
** The counter is incremented on the first [sqlite3_step()] call of each
** cycle.
**
+** [[SQLITE_STMTSTATUS_FILTER_MISS]]
+** [[SQLITE_STMTSTATUS_FILTER HIT]]
+** <dt>SQLITE_STMTSTATUS_FILTER_HIT<br>
+** SQLITE_STMTSTATUS_FILTER_MISS</dt>
+** <dd>^SQLITE_STMTSTATUS_FILTER_HIT is the number of times that a join
+** step was bypassed because a Bloom filter returned not-found. The
+** corresponding SQLITE_STMTSTATUS_FILTER_MISS value is the number of
+** times that the Bloom filter returned a find, and thus the join step
+** had to be processed as normal.
+**
** [[SQLITE_STMTSTATUS_MEMUSED]] <dt>SQLITE_STMTSTATUS_MEMUSED</dt>
** <dd>^This is the approximate number of bytes of heap memory
** used to store the prepared statement. ^This value is not actually
@@ -8787,6 +8849,8 @@ SQLITE_API int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);
#define SQLITE_STMTSTATUS_VM_STEP 4
#define SQLITE_STMTSTATUS_REPREPARE 5
#define SQLITE_STMTSTATUS_RUN 6
+#define SQLITE_STMTSTATUS_FILTER_MISS 7
+#define SQLITE_STMTSTATUS_FILTER_HIT 8
#define SQLITE_STMTSTATUS_MEMUSED 99
/*
@@ -9755,20 +9819,270 @@ SQLITE_API int sqlite3_vtab_nochange(sqlite3_context*);
/*
** CAPI3REF: Determine The Collation For a Virtual Table Constraint
+** METHOD: sqlite3_index_info
**
** This function may only be called from within a call to the [xBestIndex]
-** method of a [virtual table].
+** method of a [virtual table]. This function returns a pointer to a string
+** that is the name of the appropriate collation sequence to use for text
+** comparisons on the constraint identified by its arguments.
+**
+** The first argument must be the pointer to the [sqlite3_index_info] object
+** that is the first parameter to the xBestIndex() method. The second argument
+** must be an index into the aConstraint[] array belonging to the
+** sqlite3_index_info structure passed to xBestIndex.
**
-** The first argument must be the sqlite3_index_info object that is the
-** first parameter to the xBestIndex() method. The second argument must be
-** an index into the aConstraint[] array belonging to the sqlite3_index_info
-** structure passed to xBestIndex. This function returns a pointer to a buffer
-** containing the name of the collation sequence for the corresponding
-** constraint.
+** Important:
+** The first parameter must be the same pointer that is passed into the
+** xBestMethod() method. The first parameter may not be a pointer to a
+** different [sqlite3_index_info] object, even an exact copy.
+**
+** The return value is computed as follows:
+**
+** <ol>
+** <li><p> If the constraint comes from a WHERE clause expression that contains
+** a [COLLATE operator], then the name of the collation specified by
+** that COLLATE operator is returned.
+** <li><p> If there is no COLLATE operator, but the column that is the subject
+** of the constraint specifies an alternative collating sequence via
+** a [COLLATE clause] on the column definition within the CREATE TABLE
+** statement that was passed into [sqlite3_declare_vtab()], then the
+** name of that alternative collating sequence is returned.
+** <li><p> Otherwise, "BINARY" is returned.
+** </ol>
*/
SQLITE_API SQLITE_EXPERIMENTAL const char *sqlite3_vtab_collation(sqlite3_index_info*,int);
/*
+** CAPI3REF: Determine if a virtual table query is DISTINCT
+** METHOD: sqlite3_index_info
+**
+** This API may only be used from within an [xBestIndex|xBestIndex method]
+** of a [virtual table] implementation. The result of calling this
+** interface from outside of xBestIndex() is undefined and probably harmful.
+**
+** ^The sqlite3_vtab_distinct() interface returns an integer that is
+** either 0, 1, or 2. The integer returned by sqlite3_vtab_distinct()
+** gives the virtual table additional information about how the query
+** planner wants the output to be ordered. As long as the virtual table
+** can meet the ordering requirements of the query planner, it may set
+** the "orderByConsumed" flag.
+**
+** <ol><li value="0"><p>
+** ^If the sqlite3_vtab_distinct() interface returns 0, that means
+** that the query planner needs the virtual table to return all rows in the
+** sort order defined by the "nOrderBy" and "aOrderBy" fields of the
+** [sqlite3_index_info] object. This is the default expectation. If the
+** virtual table outputs all rows in sorted order, then it is always safe for
+** the xBestIndex method to set the "orderByConsumed" flag, regardless of
+** the return value from sqlite3_vtab_distinct().
+** <li value="1"><p>
+** ^(If the sqlite3_vtab_distinct() interface returns 1, that means
+** that the query planner does not need the rows to be returned in sorted order
+** as long as all rows with the same values in all columns identified by the
+** "aOrderBy" field are adjacent.)^ This mode is used when the query planner
+** is doing a GROUP BY.
+** <li value="2"><p>
+** ^(If the sqlite3_vtab_distinct() interface returns 2, that means
+** that the query planner does not need the rows returned in any particular
+** order, as long as rows with the same values in all "aOrderBy" columns
+** are adjacent.)^ ^(Furthermore, only a single row for each particular
+** combination of values in the columns identified by the "aOrderBy" field
+** needs to be returned.)^ ^It is always ok for two or more rows with the same
+** values in all "aOrderBy" columns to be returned, as long as all such rows
+** are adjacent. ^The virtual table may, if it chooses, omit extra rows
+** that have the same value for all columns identified by "aOrderBy".
+** ^However omitting the extra rows is optional.
+** This mode is used for a DISTINCT query.
+** </ol>
+**
+** ^For the purposes of comparing virtual table output values to see if the
+** values are same value for sorting purposes, two NULL values are considered
+** to be the same. In other words, the comparison operator is "IS"
+** (or "IS NOT DISTINCT FROM") and not "==".
+**
+** If a virtual table implementation is unable to meet the requirements
+** specified above, then it must not set the "orderByConsumed" flag in the
+** [sqlite3_index_info] object or an incorrect answer may result.
+**
+** ^A virtual table implementation is always free to return rows in any order
+** it wants, as long as the "orderByConsumed" flag is not set. ^When the
+** the "orderByConsumed" flag is unset, the query planner will add extra
+** [bytecode] to ensure that the final results returned by the SQL query are
+** ordered correctly. The use of the "orderByConsumed" flag and the
+** sqlite3_vtab_distinct() interface is merely an optimization. ^Careful
+** use of the sqlite3_vtab_distinct() interface and the "orderByConsumed"
+** flag might help queries against a virtual table to run faster. Being
+** overly aggressive and setting the "orderByConsumed" flag when it is not
+** valid to do so, on the other hand, might cause SQLite to return incorrect
+** results.
+*/
+SQLITE_API int sqlite3_vtab_distinct(sqlite3_index_info*);
+
+/*
+** CAPI3REF: Identify and handle IN constraints in xBestIndex
+**
+** This interface may only be used from within an
+** [xBestIndex|xBestIndex() method] of a [virtual table] implementation.
+** The result of invoking this interface from any other context is
+** undefined and probably harmful.
+**
+** ^(A constraint on a virtual table of the form
+** "[IN operator|column IN (...)]" is
+** communicated to the xBestIndex method as a
+** [SQLITE_INDEX_CONSTRAINT_EQ] constraint.)^ If xBestIndex wants to use
+** this constraint, it must set the corresponding
+** aConstraintUsage[].argvIndex to a postive integer. ^(Then, under
+** the usual mode of handling IN operators, SQLite generates [bytecode]
+** that invokes the [xFilter|xFilter() method] once for each value
+** on the right-hand side of the IN operator.)^ Thus the virtual table
+** only sees a single value from the right-hand side of the IN operator
+** at a time.
+**
+** In some cases, however, it would be advantageous for the virtual
+** table to see all values on the right-hand of the IN operator all at
+** once. The sqlite3_vtab_in() interfaces facilitates this in two ways:
+**
+** <ol>
+** <li><p>
+** ^A call to sqlite3_vtab_in(P,N,-1) will return true (non-zero)
+** if and only if the [sqlite3_index_info|P->aConstraint][N] constraint
+** is an [IN operator] that can be processed all at once. ^In other words,
+** sqlite3_vtab_in() with -1 in the third argument is a mechanism
+** by which the virtual table can ask SQLite if all-at-once processing
+** of the IN operator is even possible.
+**
+** <li><p>
+** ^A call to sqlite3_vtab_in(P,N,F) with F==1 or F==0 indicates
+** to SQLite that the virtual table does or does not want to process
+** the IN operator all-at-once, respectively. ^Thus when the third
+** parameter (F) is non-negative, this interface is the mechanism by
+** which the virtual table tells SQLite how it wants to process the
+** IN operator.
+** </ol>
+**
+** ^The sqlite3_vtab_in(P,N,F) interface can be invoked multiple times
+** within the same xBestIndex method call. ^For any given P,N pair,
+** the return value from sqlite3_vtab_in(P,N,F) will always be the same
+** within the same xBestIndex call. ^If the interface returns true
+** (non-zero), that means that the constraint is an IN operator
+** that can be processed all-at-once. ^If the constraint is not an IN
+** operator or cannot be processed all-at-once, then the interface returns
+** false.
+**
+** ^(All-at-once processing of the IN operator is selected if both of the
+** following conditions are met:
+**
+** <ol>
+** <li><p> The P->aConstraintUsage[N].argvIndex value is set to a positive
+** integer. This is how the virtual table tells SQLite that it wants to
+** use the N-th constraint.
+**
+** <li><p> The last call to sqlite3_vtab_in(P,N,F) for which F was
+** non-negative had F>=1.
+** </ol>)^
+**
+** ^If either or both of the conditions above are false, then SQLite uses
+** the traditional one-at-a-time processing strategy for the IN constraint.
+** ^If both conditions are true, then the argvIndex-th parameter to the
+** xFilter method will be an [sqlite3_value] that appears to be NULL,
+** but which can be passed to [sqlite3_vtab_in_first()] and
+** [sqlite3_vtab_in_next()] to find all values on the right-hand side
+** of the IN constraint.
+*/
+SQLITE_API int sqlite3_vtab_in(sqlite3_index_info*, int iCons, int bHandle);
+
+/*
+** CAPI3REF: Find all elements on the right-hand side of an IN constraint.
+**
+** These interfaces are only useful from within the
+** [xFilter|xFilter() method] of a [virtual table] implementation.
+** The result of invoking these interfaces from any other context
+** is undefined and probably harmful.
+**
+** The X parameter in a call to sqlite3_vtab_in_first(X,P) or
+** sqlite3_vtab_in_next(X,P) must be one of the parameters to the
+** xFilter method which invokes these routines, and specifically
+** a parameter that was previously selected for all-at-once IN constraint
+** processing use the [sqlite3_vtab_in()] interface in the
+** [xBestIndex|xBestIndex method]. ^(If the X parameter is not
+** an xFilter argument that was selected for all-at-once IN constraint
+** processing, then these routines return [SQLITE_MISUSE])^ or perhaps
+** exhibit some other undefined or harmful behavior.
+**
+** ^(Use these routines to access all values on the right-hand side
+** of the IN constraint using code like the following:
+**
+** <blockquote><pre>
+** &nbsp; for(rc=sqlite3_vtab_in_first(pList, &pVal);
+** &nbsp; rc==SQLITE_OK && pVal
+** &nbsp; rc=sqlite3_vtab_in_next(pList, &pVal)
+** &nbsp; ){
+** &nbsp; // do something with pVal
+** &nbsp; }
+** &nbsp; if( rc!=SQLITE_OK ){
+** &nbsp; // an error has occurred
+** &nbsp; }
+** </pre></blockquote>)^
+**
+** ^On success, the sqlite3_vtab_in_first(X,P) and sqlite3_vtab_in_next(X,P)
+** routines return SQLITE_OK and set *P to point to the first or next value
+** on the RHS of the IN constraint. ^If there are no more values on the
+** right hand side of the IN constraint, then *P is set to NULL and these
+** routines return [SQLITE_DONE]. ^The return value might be
+** some other value, such as SQLITE_NOMEM, in the event of a malfunction.
+**
+** The *ppOut values returned by these routines are only valid until the
+** next call to either of these routines or until the end of the xFilter
+** method from which these routines were called. If the virtual table
+** implementation needs to retain the *ppOut values for longer, it must make
+** copies. The *ppOut values are [protected sqlite3_value|protected].
+*/
+SQLITE_API int sqlite3_vtab_in_first(sqlite3_value *pVal, sqlite3_value **ppOut);
+SQLITE_API int sqlite3_vtab_in_next(sqlite3_value *pVal, sqlite3_value **ppOut);
+
+/*
+** CAPI3REF: Constraint values in xBestIndex()
+** METHOD: sqlite3_index_info
+**
+** This API may only be used from within the [xBestIndex|xBestIndex method]
+** of a [virtual table] implementation. The result of calling this interface
+** from outside of an xBestIndex method are undefined and probably harmful.
+**
+** ^When the sqlite3_vtab_rhs_value(P,J,V) interface is invoked from within
+** the [xBestIndex] method of a [virtual table] implementation, with P being
+** a copy of the [sqlite3_index_info] object pointer passed into xBestIndex and
+** J being a 0-based index into P->aConstraint[], then this routine
+** attempts to set *V to the value of the right-hand operand of
+** that constraint if the right-hand operand is known. ^If the
+** right-hand operand is not known, then *V is set to a NULL pointer.
+** ^The sqlite3_vtab_rhs_value(P,J,V) interface returns SQLITE_OK if
+** and only if *V is set to a value. ^The sqlite3_vtab_rhs_value(P,J,V)
+** inteface returns SQLITE_NOTFOUND if the right-hand side of the J-th
+** constraint is not available. ^The sqlite3_vtab_rhs_value() interface
+** can return an result code other than SQLITE_OK or SQLITE_NOTFOUND if
+** something goes wrong.
+**
+** The sqlite3_vtab_rhs_value() interface is usually only successful if
+** the right-hand operand of a constraint is a literal value in the original
+** SQL statement. If the right-hand operand is an expression or a reference
+** to some other column or a [host parameter], then sqlite3_vtab_rhs_value()
+** will probably return [SQLITE_NOTFOUND].
+**
+** ^(Some constraints, such as [SQLITE_INDEX_CONSTRAINT_ISNULL] and
+** [SQLITE_INDEX_CONSTRAINT_ISNOTNULL], have no right-hand operand. For such
+** constraints, sqlite3_vtab_rhs_value() always returns SQLITE_NOTFOUND.)^
+**
+** ^The [sqlite3_value] object returned in *V is a protected sqlite3_value
+** and remains valid for the duration of the xBestIndex method call.
+** ^When xBestIndex returns, the sqlite3_value object returned by
+** sqlite3_vtab_rhs_value() is automatically deallocated.
+**
+** The "_rhs_" in the name of this routine is an abbreviation for
+** "Right-Hand Side".
+*/
+SQLITE_API int sqlite3_vtab_rhs_value(sqlite3_index_info*, int, sqlite3_value **ppVal);
+
+/*
** CAPI3REF: Conflict resolution modes
** KEYWORDS: {conflict resolution mode}
**
@@ -13611,75 +13925,76 @@ SQLITE_PRIVATE void sqlite3HashClear(Hash*);
#define TK_SLASH 99
#define TK_REM 100
#define TK_CONCAT 101
-#define TK_COLLATE 102
-#define TK_BITNOT 103
-#define TK_ON 104
-#define TK_INDEXED 105
-#define TK_STRING 106
-#define TK_JOIN_KW 107
-#define TK_CONSTRAINT 108
-#define TK_DEFAULT 109
-#define TK_NULL 110
-#define TK_PRIMARY 111
-#define TK_UNIQUE 112
-#define TK_CHECK 113
-#define TK_REFERENCES 114
-#define TK_AUTOINCR 115
-#define TK_INSERT 116
-#define TK_DELETE 117
-#define TK_UPDATE 118
-#define TK_SET 119
-#define TK_DEFERRABLE 120
-#define TK_FOREIGN 121
-#define TK_DROP 122
-#define TK_UNION 123
-#define TK_ALL 124
-#define TK_EXCEPT 125
-#define TK_INTERSECT 126
-#define TK_SELECT 127
-#define TK_VALUES 128
-#define TK_DISTINCT 129
-#define TK_DOT 130
-#define TK_FROM 131
-#define TK_JOIN 132
-#define TK_USING 133
-#define TK_ORDER 134
-#define TK_GROUP 135
-#define TK_HAVING 136
-#define TK_LIMIT 137
-#define TK_WHERE 138
-#define TK_RETURNING 139
-#define TK_INTO 140
-#define TK_NOTHING 141
-#define TK_FLOAT 142
-#define TK_BLOB 143
-#define TK_INTEGER 144
-#define TK_VARIABLE 145
-#define TK_CASE 146
-#define TK_WHEN 147
-#define TK_THEN 148
-#define TK_ELSE 149
-#define TK_INDEX 150
-#define TK_ALTER 151
-#define TK_ADD 152
-#define TK_COLUMN 153
-#define TK_AGG_FUNCTION 154
-#define TK_AGG_COLUMN 155
-#define TK_TRUEFALSE 156
-#define TK_ISNOT 157
-#define TK_FUNCTION 158
-#define TK_UMINUS 159
-#define TK_UPLUS 160
-#define TK_TRUTH 161
-#define TK_REGISTER 162
-#define TK_VECTOR 163
-#define TK_SELECT_COLUMN 164
-#define TK_IF_NULL_ROW 165
-#define TK_ASTERISK 166
-#define TK_SPAN 167
-#define TK_ERROR 168
-#define TK_SPACE 169
-#define TK_ILLEGAL 170
+#define TK_PTR 102
+#define TK_COLLATE 103
+#define TK_BITNOT 104
+#define TK_ON 105
+#define TK_INDEXED 106
+#define TK_STRING 107
+#define TK_JOIN_KW 108
+#define TK_CONSTRAINT 109
+#define TK_DEFAULT 110
+#define TK_NULL 111
+#define TK_PRIMARY 112
+#define TK_UNIQUE 113
+#define TK_CHECK 114
+#define TK_REFERENCES 115
+#define TK_AUTOINCR 116
+#define TK_INSERT 117
+#define TK_DELETE 118
+#define TK_UPDATE 119
+#define TK_SET 120
+#define TK_DEFERRABLE 121
+#define TK_FOREIGN 122
+#define TK_DROP 123
+#define TK_UNION 124
+#define TK_ALL 125
+#define TK_EXCEPT 126
+#define TK_INTERSECT 127
+#define TK_SELECT 128
+#define TK_VALUES 129
+#define TK_DISTINCT 130
+#define TK_DOT 131
+#define TK_FROM 132
+#define TK_JOIN 133
+#define TK_USING 134
+#define TK_ORDER 135
+#define TK_GROUP 136
+#define TK_HAVING 137
+#define TK_LIMIT 138
+#define TK_WHERE 139
+#define TK_RETURNING 140
+#define TK_INTO 141
+#define TK_NOTHING 142
+#define TK_FLOAT 143
+#define TK_BLOB 144
+#define TK_INTEGER 145
+#define TK_VARIABLE 146
+#define TK_CASE 147
+#define TK_WHEN 148
+#define TK_THEN 149
+#define TK_ELSE 150
+#define TK_INDEX 151
+#define TK_ALTER 152
+#define TK_ADD 153
+#define TK_COLUMN 154
+#define TK_AGG_FUNCTION 155
+#define TK_AGG_COLUMN 156
+#define TK_TRUEFALSE 157
+#define TK_ISNOT 158
+#define TK_FUNCTION 159
+#define TK_UMINUS 160
+#define TK_UPLUS 161
+#define TK_TRUTH 162
+#define TK_REGISTER 163
+#define TK_VECTOR 164
+#define TK_SELECT_COLUMN 165
+#define TK_IF_NULL_ROW 166
+#define TK_ASTERISK 167
+#define TK_SPAN 168
+#define TK_ERROR 169
+#define TK_SPACE 170
+#define TK_ILLEGAL 171
/************** End of parse.h ***********************************************/
/************** Continuing where we left off in sqliteInt.h ******************/
@@ -14321,10 +14636,11 @@ typedef struct With With;
/*
** A bit in a Bitmask
*/
-#define MASKBIT(n) (((Bitmask)1)<<(n))
-#define MASKBIT64(n) (((u64)1)<<(n))
-#define MASKBIT32(n) (((unsigned int)1)<<(n))
-#define ALLBITS ((Bitmask)-1)
+#define MASKBIT(n) (((Bitmask)1)<<(n))
+#define MASKBIT64(n) (((u64)1)<<(n))
+#define MASKBIT32(n) (((unsigned int)1)<<(n))
+#define SMASKBIT32(n) ((n)<=31?((unsigned int)1)<<(n):0)
+#define ALLBITS ((Bitmask)-1)
/* A VList object records a mapping between parameters/variables/wildcards
** in the SQL statement (such as $abc, @pqr, or :xyz) and the integer
@@ -15240,35 +15556,35 @@ typedef struct VdbeOpList VdbeOpList;
#define OP_DecrJumpZero 60 /* jump, synopsis: if (--r[P1])==0 goto P2 */
#define OP_IncrVacuum 61 /* jump */
#define OP_VNext 62 /* jump */
-#define OP_Init 63 /* jump, synopsis: Start at P2 */
-#define OP_PureFunc 64 /* synopsis: r[P3]=func(r[P2@NP]) */
-#define OP_Function 65 /* synopsis: r[P3]=func(r[P2@NP]) */
-#define OP_Return 66
-#define OP_EndCoroutine 67
-#define OP_HaltIfNull 68 /* synopsis: if r[P3]=null halt */
-#define OP_Halt 69
-#define OP_Integer 70 /* synopsis: r[P2]=P1 */
-#define OP_Int64 71 /* synopsis: r[P2]=P4 */
-#define OP_String 72 /* synopsis: r[P2]='P4' (len=P1) */
-#define OP_Null 73 /* synopsis: r[P2..P3]=NULL */
-#define OP_SoftNull 74 /* synopsis: r[P1]=NULL */
-#define OP_Blob 75 /* synopsis: r[P2]=P4 (len=P1) */
-#define OP_Variable 76 /* synopsis: r[P2]=parameter(P1,P4) */
-#define OP_Move 77 /* synopsis: r[P2@P3]=r[P1@P3] */
-#define OP_Copy 78 /* synopsis: r[P2@P3+1]=r[P1@P3+1] */
-#define OP_SCopy 79 /* synopsis: r[P2]=r[P1] */
-#define OP_IntCopy 80 /* synopsis: r[P2]=r[P1] */
-#define OP_ChngCntRow 81 /* synopsis: output=r[P1] */
-#define OP_ResultRow 82 /* synopsis: output=r[P1@P2] */
-#define OP_CollSeq 83
-#define OP_AddImm 84 /* synopsis: r[P1]=r[P1]+P2 */
-#define OP_RealAffinity 85
-#define OP_Cast 86 /* synopsis: affinity(r[P1]) */
-#define OP_Permutation 87
-#define OP_Compare 88 /* synopsis: r[P1@P3] <-> r[P2@P3] */
-#define OP_IsTrue 89 /* synopsis: r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4 */
-#define OP_ZeroOrNull 90 /* synopsis: r[P2] = 0 OR NULL */
-#define OP_Offset 91 /* synopsis: r[P3] = sqlite_offset(P1) */
+#define OP_Filter 63 /* jump, synopsis: if key(P3@P4) not in filter(P1) goto P2 */
+#define OP_Init 64 /* jump, synopsis: Start at P2 */
+#define OP_PureFunc 65 /* synopsis: r[P3]=func(r[P2@NP]) */
+#define OP_Function 66 /* synopsis: r[P3]=func(r[P2@NP]) */
+#define OP_Return 67
+#define OP_EndCoroutine 68
+#define OP_HaltIfNull 69 /* synopsis: if r[P3]=null halt */
+#define OP_Halt 70
+#define OP_Integer 71 /* synopsis: r[P2]=P1 */
+#define OP_Int64 72 /* synopsis: r[P2]=P4 */
+#define OP_String 73 /* synopsis: r[P2]='P4' (len=P1) */
+#define OP_Null 74 /* synopsis: r[P2..P3]=NULL */
+#define OP_SoftNull 75 /* synopsis: r[P1]=NULL */
+#define OP_Blob 76 /* synopsis: r[P2]=P4 (len=P1) */
+#define OP_Variable 77 /* synopsis: r[P2]=parameter(P1,P4) */
+#define OP_Move 78 /* synopsis: r[P2@P3]=r[P1@P3] */
+#define OP_Copy 79 /* synopsis: r[P2@P3+1]=r[P1@P3+1] */
+#define OP_SCopy 80 /* synopsis: r[P2]=r[P1] */
+#define OP_IntCopy 81 /* synopsis: r[P2]=r[P1] */
+#define OP_FkCheck 82
+#define OP_ResultRow 83 /* synopsis: output=r[P1@P2] */
+#define OP_CollSeq 84
+#define OP_AddImm 85 /* synopsis: r[P1]=r[P1]+P2 */
+#define OP_RealAffinity 86
+#define OP_Cast 87 /* synopsis: affinity(r[P1]) */
+#define OP_Permutation 88
+#define OP_Compare 89 /* synopsis: r[P1@P3] <-> r[P2@P3] */
+#define OP_IsTrue 90 /* synopsis: r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4 */
+#define OP_ZeroOrNull 91 /* synopsis: r[P2] = 0 OR NULL */
#define OP_BitAnd 92 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */
#define OP_BitOr 93 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */
#define OP_ShiftLeft 94 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */
@@ -15279,86 +15595,89 @@ typedef struct VdbeOpList VdbeOpList;
#define OP_Divide 99 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */
#define OP_Remainder 100 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */
#define OP_Concat 101 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */
-#define OP_Column 102 /* synopsis: r[P3]=PX */
-#define OP_BitNot 103 /* same as TK_BITNOT, synopsis: r[P2]= ~r[P1] */
-#define OP_TypeCheck 104 /* synopsis: typecheck(r[P1@P2]) */
-#define OP_Affinity 105 /* synopsis: affinity(r[P1@P2]) */
-#define OP_String8 106 /* same as TK_STRING, synopsis: r[P2]='P4' */
-#define OP_MakeRecord 107 /* synopsis: r[P3]=mkrec(r[P1@P2]) */
-#define OP_Count 108 /* synopsis: r[P2]=count() */
-#define OP_ReadCookie 109
-#define OP_SetCookie 110
-#define OP_ReopenIdx 111 /* synopsis: root=P2 iDb=P3 */
-#define OP_OpenRead 112 /* synopsis: root=P2 iDb=P3 */
-#define OP_OpenWrite 113 /* synopsis: root=P2 iDb=P3 */
-#define OP_OpenDup 114
-#define OP_OpenAutoindex 115 /* synopsis: nColumn=P2 */
-#define OP_OpenEphemeral 116 /* synopsis: nColumn=P2 */
-#define OP_SorterOpen 117
-#define OP_SequenceTest 118 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */
-#define OP_OpenPseudo 119 /* synopsis: P3 columns in r[P2] */
-#define OP_Close 120
-#define OP_ColumnsUsed 121
-#define OP_SeekScan 122 /* synopsis: Scan-ahead up to P1 rows */
-#define OP_SeekHit 123 /* synopsis: set P2<=seekHit<=P3 */
-#define OP_Sequence 124 /* synopsis: r[P2]=cursor[P1].ctr++ */
-#define OP_NewRowid 125 /* synopsis: r[P2]=rowid */
-#define OP_Insert 126 /* synopsis: intkey=r[P3] data=r[P2] */
-#define OP_RowCell 127
-#define OP_Delete 128
-#define OP_ResetCount 129
-#define OP_SorterCompare 130 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */
-#define OP_SorterData 131 /* synopsis: r[P2]=data */
-#define OP_RowData 132 /* synopsis: r[P2]=data */
-#define OP_Rowid 133 /* synopsis: r[P2]=rowid */
-#define OP_NullRow 134
-#define OP_SeekEnd 135
-#define OP_IdxInsert 136 /* synopsis: key=r[P2] */
-#define OP_SorterInsert 137 /* synopsis: key=r[P2] */
-#define OP_IdxDelete 138 /* synopsis: key=r[P2@P3] */
-#define OP_DeferredSeek 139 /* synopsis: Move P3 to P1.rowid if needed */
-#define OP_IdxRowid 140 /* synopsis: r[P2]=rowid */
-#define OP_FinishSeek 141
-#define OP_Real 142 /* same as TK_FLOAT, synopsis: r[P2]=P4 */
-#define OP_Destroy 143
-#define OP_Clear 144
-#define OP_ResetSorter 145
-#define OP_CreateBtree 146 /* synopsis: r[P2]=root iDb=P1 flags=P3 */
-#define OP_SqlExec 147
-#define OP_ParseSchema 148
-#define OP_LoadAnalysis 149
-#define OP_DropTable 150
-#define OP_DropIndex 151
-#define OP_DropTrigger 152
-#define OP_IntegrityCk 153
-#define OP_RowSetAdd 154 /* synopsis: rowset(P1)=r[P2] */
-#define OP_Param 155
-#define OP_FkCounter 156 /* synopsis: fkctr[P1]+=P2 */
-#define OP_MemMax 157 /* synopsis: r[P1]=max(r[P1],r[P2]) */
-#define OP_OffsetLimit 158 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */
-#define OP_AggInverse 159 /* synopsis: accum=r[P3] inverse(r[P2@P5]) */
-#define OP_AggStep 160 /* synopsis: accum=r[P3] step(r[P2@P5]) */
-#define OP_AggStep1 161 /* synopsis: accum=r[P3] step(r[P2@P5]) */
-#define OP_AggValue 162 /* synopsis: r[P3]=value N=P2 */
-#define OP_AggFinal 163 /* synopsis: accum=r[P1] N=P2 */
-#define OP_Expire 164
-#define OP_CursorLock 165
-#define OP_CursorUnlock 166
-#define OP_TableLock 167 /* synopsis: iDb=P1 root=P2 write=P3 */
-#define OP_VBegin 168
-#define OP_VCreate 169
-#define OP_VDestroy 170
-#define OP_VOpen 171
-#define OP_VColumn 172 /* synopsis: r[P3]=vcolumn(P2) */
-#define OP_VRename 173
-#define OP_Pagecount 174
-#define OP_MaxPgcnt 175
-#define OP_Trace 176
-#define OP_CursorHint 177
-#define OP_ReleaseReg 178 /* synopsis: release r[P1@P2] mask P3 */
-#define OP_Noop 179
-#define OP_Explain 180
-#define OP_Abortable 181
+#define OP_Offset 102 /* synopsis: r[P3] = sqlite_offset(P1) */
+#define OP_Column 103 /* synopsis: r[P3]=PX */
+#define OP_BitNot 104 /* same as TK_BITNOT, synopsis: r[P2]= ~r[P1] */
+#define OP_TypeCheck 105 /* synopsis: typecheck(r[P1@P2]) */
+#define OP_Affinity 106 /* synopsis: affinity(r[P1@P2]) */
+#define OP_String8 107 /* same as TK_STRING, synopsis: r[P2]='P4' */
+#define OP_MakeRecord 108 /* synopsis: r[P3]=mkrec(r[P1@P2]) */
+#define OP_Count 109 /* synopsis: r[P2]=count() */
+#define OP_ReadCookie 110
+#define OP_SetCookie 111
+#define OP_ReopenIdx 112 /* synopsis: root=P2 iDb=P3 */
+#define OP_OpenRead 113 /* synopsis: root=P2 iDb=P3 */
+#define OP_OpenWrite 114 /* synopsis: root=P2 iDb=P3 */
+#define OP_OpenDup 115
+#define OP_OpenAutoindex 116 /* synopsis: nColumn=P2 */
+#define OP_OpenEphemeral 117 /* synopsis: nColumn=P2 */
+#define OP_SorterOpen 118
+#define OP_SequenceTest 119 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */
+#define OP_OpenPseudo 120 /* synopsis: P3 columns in r[P2] */
+#define OP_Close 121
+#define OP_ColumnsUsed 122
+#define OP_SeekScan 123 /* synopsis: Scan-ahead up to P1 rows */
+#define OP_SeekHit 124 /* synopsis: set P2<=seekHit<=P3 */
+#define OP_Sequence 125 /* synopsis: r[P2]=cursor[P1].ctr++ */
+#define OP_NewRowid 126 /* synopsis: r[P2]=rowid */
+#define OP_Insert 127 /* synopsis: intkey=r[P3] data=r[P2] */
+#define OP_RowCell 128
+#define OP_Delete 129
+#define OP_ResetCount 130
+#define OP_SorterCompare 131 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */
+#define OP_SorterData 132 /* synopsis: r[P2]=data */
+#define OP_RowData 133 /* synopsis: r[P2]=data */
+#define OP_Rowid 134 /* synopsis: r[P2]=rowid */
+#define OP_NullRow 135
+#define OP_SeekEnd 136
+#define OP_IdxInsert 137 /* synopsis: key=r[P2] */
+#define OP_SorterInsert 138 /* synopsis: key=r[P2] */
+#define OP_IdxDelete 139 /* synopsis: key=r[P2@P3] */
+#define OP_DeferredSeek 140 /* synopsis: Move P3 to P1.rowid if needed */
+#define OP_IdxRowid 141 /* synopsis: r[P2]=rowid */
+#define OP_FinishSeek 142
+#define OP_Real 143 /* same as TK_FLOAT, synopsis: r[P2]=P4 */
+#define OP_Destroy 144
+#define OP_Clear 145
+#define OP_ResetSorter 146
+#define OP_CreateBtree 147 /* synopsis: r[P2]=root iDb=P1 flags=P3 */
+#define OP_SqlExec 148
+#define OP_ParseSchema 149
+#define OP_LoadAnalysis 150
+#define OP_DropTable 151
+#define OP_DropIndex 152
+#define OP_DropTrigger 153
+#define OP_IntegrityCk 154
+#define OP_RowSetAdd 155 /* synopsis: rowset(P1)=r[P2] */
+#define OP_Param 156
+#define OP_FkCounter 157 /* synopsis: fkctr[P1]+=P2 */
+#define OP_MemMax 158 /* synopsis: r[P1]=max(r[P1],r[P2]) */
+#define OP_OffsetLimit 159 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */
+#define OP_AggInverse 160 /* synopsis: accum=r[P3] inverse(r[P2@P5]) */
+#define OP_AggStep 161 /* synopsis: accum=r[P3] step(r[P2@P5]) */
+#define OP_AggStep1 162 /* synopsis: accum=r[P3] step(r[P2@P5]) */
+#define OP_AggValue 163 /* synopsis: r[P3]=value N=P2 */
+#define OP_AggFinal 164 /* synopsis: accum=r[P1] N=P2 */
+#define OP_Expire 165
+#define OP_CursorLock 166
+#define OP_CursorUnlock 167
+#define OP_TableLock 168 /* synopsis: iDb=P1 root=P2 write=P3 */
+#define OP_VBegin 169
+#define OP_VCreate 170
+#define OP_VDestroy 171
+#define OP_VOpen 172
+#define OP_VInitIn 173 /* synopsis: r[P2]=ValueList(P1,P3) */
+#define OP_VColumn 174 /* synopsis: r[P3]=vcolumn(P2) */
+#define OP_VRename 175
+#define OP_Pagecount 176
+#define OP_MaxPgcnt 177
+#define OP_FilterAdd 178 /* synopsis: filter(P1) += key(P3@P4) */
+#define OP_Trace 179
+#define OP_CursorHint 180
+#define OP_ReleaseReg 181 /* synopsis: release r[P1@P2] mask P3 */
+#define OP_Noop 182
+#define OP_Explain 183
+#define OP_Abortable 184
/* Properties such as "out2" or "jump" that are specified in
** comments following the "case" for each opcode in the vdbe.c
@@ -15379,21 +15698,22 @@ typedef struct VdbeOpList VdbeOpList;
/* 40 */ 0x01, 0x26, 0x26, 0x01, 0x01, 0x23, 0x0b, 0x01,\
/* 48 */ 0x03, 0x03, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,\
/* 56 */ 0x01, 0x01, 0x03, 0x03, 0x03, 0x01, 0x01, 0x01,\
-/* 64 */ 0x00, 0x00, 0x02, 0x02, 0x08, 0x00, 0x10, 0x10,\
-/* 72 */ 0x10, 0x10, 0x00, 0x10, 0x10, 0x00, 0x00, 0x10,\
-/* 80 */ 0x10, 0x00, 0x00, 0x00, 0x02, 0x02, 0x02, 0x00,\
-/* 88 */ 0x00, 0x12, 0x1e, 0x20, 0x26, 0x26, 0x26, 0x26,\
-/* 96 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x00, 0x12,\
-/* 104 */ 0x00, 0x00, 0x10, 0x00, 0x10, 0x10, 0x00, 0x00,\
+/* 64 */ 0x01, 0x00, 0x00, 0x02, 0x02, 0x08, 0x00, 0x10,\
+/* 72 */ 0x10, 0x10, 0x10, 0x00, 0x10, 0x10, 0x00, 0x00,\
+/* 80 */ 0x10, 0x10, 0x00, 0x00, 0x00, 0x02, 0x02, 0x02,\
+/* 88 */ 0x00, 0x00, 0x12, 0x1e, 0x26, 0x26, 0x26, 0x26,\
+/* 96 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x20, 0x00,\
+/* 104 */ 0x12, 0x00, 0x00, 0x10, 0x00, 0x10, 0x10, 0x00,\
/* 112 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
-/* 120 */ 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,\
-/* 128 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,\
-/* 136 */ 0x04, 0x04, 0x00, 0x00, 0x10, 0x00, 0x10, 0x10,\
-/* 144 */ 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,\
-/* 152 */ 0x00, 0x00, 0x06, 0x10, 0x00, 0x04, 0x1a, 0x00,\
+/* 120 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00,\
+/* 128 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,\
+/* 136 */ 0x00, 0x04, 0x04, 0x00, 0x00, 0x10, 0x00, 0x10,\
+/* 144 */ 0x10, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,\
+/* 152 */ 0x00, 0x00, 0x00, 0x06, 0x10, 0x00, 0x04, 0x1a,\
/* 160 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
-/* 168 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10,\
-/* 176 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,}
+/* 168 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,\
+/* 176 */ 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
+/* 184 */ 0x00,}
/* The resolve3P2Values() routine is able to run faster if it knows
** the value of the largest JUMP opcode. The smaller the maximum
@@ -15401,7 +15721,7 @@ typedef struct VdbeOpList VdbeOpList;
** generated this include file strives to group all JUMP opcodes
** together near the beginning of the list.
*/
-#define SQLITE_MX_JUMP_OPCODE 63 /* Maximum JUMP opcode */
+#define SQLITE_MX_JUMP_OPCODE 64 /* Maximum JUMP opcode */
/************** End of opcodes.h *********************************************/
/************** Continuing where we left off in vdbe.h ***********************/
@@ -16462,6 +16782,7 @@ struct sqlite3 {
u32 nSchemaLock; /* Do not reset the schema when non-zero */
unsigned int openFlags; /* Flags passed to sqlite3_vfs.xOpen() */
int errCode; /* Most recent error code (SQLITE_*) */
+ int errByteOffset; /* Byte offset of error in SQL statement */
int errMask; /* & result codes with this before returning */
int iSysErrno; /* Errno value from last system error */
u32 dbOptFlags; /* Flags to enable/disable optimizations */
@@ -16696,6 +17017,9 @@ struct sqlite3 {
#define SQLITE_SeekScan 0x00020000 /* The OP_SeekScan optimization */
#define SQLITE_OmitOrderBy 0x00040000 /* Omit pointless ORDER BY */
/* TH3 expects this value ^^^^^^^^^^ to be 0x40000. Coordinate any change */
+#define SQLITE_BloomFilter 0x00080000 /* Use a Bloom filter on searches */
+#define SQLITE_BloomPulldown 0x00100000 /* Run Bloom filters early */
+#define SQLITE_BalancedMerge 0x00200000 /* Balance multi-way merges */
#define SQLITE_AllOpts 0xffffffff /* All optimizations */
/*
@@ -16869,7 +17193,7 @@ struct FuncDestructor {
** are interpreted in the same way as the first 4 parameters to
** FUNCTION().
**
-** WFUNCTION(zName, nArg, iArg, xStep, xFinal, xValue, xInverse)
+** WAGGREGATE(zName, nArg, iArg, xStep, xFinal, xValue, xInverse)
** Used to create an aggregate function definition implemented by
** the C functions xStep and xFinal. The first four parameters
** are interpreted in the same way as the first 4 parameters to
@@ -16896,6 +17220,10 @@ struct FuncDestructor {
#define MFUNCTION(zName, nArg, xPtr, xFunc) \
{nArg, SQLITE_FUNC_BUILTIN|SQLITE_FUNC_CONSTANT|SQLITE_UTF8, \
xPtr, 0, xFunc, 0, 0, 0, #zName, {0} }
+#define JFUNCTION(zName, nArg, iArg, xFunc) \
+ {nArg, SQLITE_FUNC_BUILTIN|SQLITE_DETERMINISTIC|SQLITE_INNOCUOUS|\
+ SQLITE_FUNC_CONSTANT|SQLITE_UTF8, \
+ SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, 0, #zName, {0} }
#define INLINE_FUNC(zName, nArg, iArg, mFlags) \
{nArg, SQLITE_FUNC_BUILTIN|\
SQLITE_UTF8|SQLITE_FUNC_INLINE|SQLITE_FUNC_CONSTANT|(mFlags), \
@@ -17750,7 +18078,10 @@ struct Expr {
** TK_VARIABLE: variable number (always >= 1).
** TK_SELECT_COLUMN: column of the result vector */
i16 iAgg; /* Which entry in pAggInfo->aCol[] or ->aFunc[] */
- int iRightJoinTable; /* If EP_FromJoin, the right table of the join */
+ union {
+ int iRightJoinTable; /* If EP_FromJoin, the right table of the join */
+ int iOfst; /* else: start of token from start of statement */
+ } w;
AggInfo *pAggInfo; /* Used by TK_AGG_COLUMN and TK_AGG_FUNCTION */
union {
Table *pTab; /* TK_COLUMN: Table containing column. Can be NULL
@@ -18490,6 +18821,8 @@ struct Parse {
AutoincInfo *pAinc; /* Information about AUTOINCREMENT counters */
Parse *pToplevel; /* Parse structure for main program (or NULL) */
Table *pTriggerTab; /* Table triggers are being coded for */
+ TriggerPrg *pTriggerPrg; /* Linked list of coded triggers */
+ ParseCleanup *pCleanup; /* List of cleanup operations to run after parse */
union {
int addrCrTab; /* Address of OP_CreateBtree on CREATE TABLE */
Returning *pReturning; /* The RETURNING clause */
@@ -18510,6 +18843,7 @@ struct Parse {
**************************************************************************/
int aTempReg[8]; /* Holding area for temporary registers */
+ Parse *pOuterParse; /* Outer Parse object when nested */
Token sNameToken; /* Token with unqualified schema object name */
/************************************************************************
@@ -18544,9 +18878,7 @@ struct Parse {
Token sArg; /* Complete text of a module argument */
Table **apVtabLock; /* Pointer to virtual tables needing locking */
#endif
- TriggerPrg *pTriggerPrg; /* Linked list of coded triggers */
With *pWith; /* Current WITH clause, or NULL */
- ParseCleanup *pCleanup; /* List of cleanup operations to run after parse */
#ifndef SQLITE_OMIT_ALTERTABLE
RenameToken *pRename; /* Tokens subject to renaming by ALTER TABLE */
#endif
@@ -18562,7 +18894,8 @@ struct Parse {
/*
** Sizes and pointers of various parts of the Parse object.
*/
-#define PARSE_HDR_SZ offsetof(Parse,aTempReg) /* Recursive part w/o aColCache*/
+#define PARSE_HDR(X) (((char*)(X))+offsetof(Parse,zErrMsg))
+#define PARSE_HDR_SZ (offsetof(Parse,aTempReg)-offsetof(Parse,zErrMsg)) /* Recursive part w/o aColCache*/
#define PARSE_RECURSE_SZ offsetof(Parse,sLastToken) /* Recursive part */
#define PARSE_TAIL_SZ (sizeof(Parse)-PARSE_RECURSE_SZ) /* Non-recursive part */
#define PARSE_TAIL(X) (((char*)(X))+PARSE_RECURSE_SZ) /* Pointer to tail */
@@ -18857,6 +19190,7 @@ struct Sqlite3Config {
int (*xTestCallback)(int); /* Invoked by sqlite3FaultSim() */
#endif
int bLocaltimeFault; /* True to fail localtime() calls */
+ int (*xAltLocaltime)(const void*,void*); /* Alternative localtime() routine */
int iOnceResetThreshold; /* When to reset OP_Once counters */
u32 szSorterRef; /* Min size in bytes to use sorter-refs */
unsigned int iPrngSeed; /* Alternative fixed seed for the PRNG */
@@ -19337,7 +19671,7 @@ SQLITE_PRIVATE void sqlite3DequoteExpr(Expr*);
SQLITE_PRIVATE void sqlite3DequoteToken(Token*);
SQLITE_PRIVATE void sqlite3TokenInit(Token*,char*);
SQLITE_PRIVATE int sqlite3KeywordCode(const unsigned char*, int);
-SQLITE_PRIVATE int sqlite3RunParser(Parse*, const char*, char **);
+SQLITE_PRIVATE int sqlite3RunParser(Parse*, const char*);
SQLITE_PRIVATE void sqlite3FinishCoding(Parse*);
SQLITE_PRIVATE int sqlite3GetTempReg(Parse*);
SQLITE_PRIVATE void sqlite3ReleaseTempReg(Parse*,int);
@@ -19498,10 +19832,12 @@ SQLITE_PRIVATE void sqlite3OpenTable(Parse*, int iCur, int iDb, Table*, int);
#if defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT) && !defined(SQLITE_OMIT_SUBQUERY)
SQLITE_PRIVATE Expr *sqlite3LimitWhere(Parse*,SrcList*,Expr*,ExprList*,Expr*,char*);
#endif
+SQLITE_PRIVATE void sqlite3CodeChangeCount(Vdbe*,int,const char*);
SQLITE_PRIVATE void sqlite3DeleteFrom(Parse*, SrcList*, Expr*, ExprList*, Expr*);
SQLITE_PRIVATE void sqlite3Update(Parse*, SrcList*, ExprList*,Expr*,int,ExprList*,Expr*,
Upsert*);
-SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(Parse*,SrcList*,Expr*,ExprList*,ExprList*,u16,int);
+SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(Parse*,SrcList*,Expr*,ExprList*,
+ ExprList*,Select*,u16,int);
SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo*);
SQLITE_PRIVATE LogEst sqlite3WhereOutputRowCount(WhereInfo*);
SQLITE_PRIVATE int sqlite3WhereIsDistinct(WhereInfo*);
@@ -19616,9 +19952,14 @@ SQLITE_PRIVATE Select *sqlite3SelectDup(sqlite3*,const Select*,int);
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 sqlite3QuoteValue(StrAccum*,sqlite3_value*);
SQLITE_PRIVATE void sqlite3RegisterBuiltinFunctions(void);
SQLITE_PRIVATE void sqlite3RegisterDateTimeFunctions(void);
+SQLITE_PRIVATE void sqlite3RegisterJsonFunctions(void);
SQLITE_PRIVATE void sqlite3RegisterPerConnectionBuiltinFunctions(sqlite3*);
+#if !defined(SQLITE_OMIT_VIRTUALTABLE) && !defined(SQLITE_OMIT_JSON)
+SQLITE_PRIVATE int sqlite3JsonTableFunctions(sqlite3*);
+#endif
SQLITE_PRIVATE int sqlite3SafetyCheckOk(sqlite3*);
SQLITE_PRIVATE int sqlite3SafetyCheckSickOrOk(sqlite3*);
SQLITE_PRIVATE void sqlite3ChangeCookie(Parse*, int);
@@ -19708,14 +20049,8 @@ SQLITE_PRIVATE int sqlite3Utf8CharLen(const char *pData, int nByte);
SQLITE_PRIVATE u32 sqlite3Utf8Read(const u8**);
SQLITE_PRIVATE LogEst sqlite3LogEst(u64);
SQLITE_PRIVATE LogEst sqlite3LogEstAdd(LogEst,LogEst);
-#ifndef SQLITE_OMIT_VIRTUALTABLE
SQLITE_PRIVATE LogEst sqlite3LogEstFromDouble(double);
-#endif
-#if defined(SQLITE_ENABLE_STMT_SCANSTATUS) || \
- defined(SQLITE_ENABLE_STAT4) || \
- defined(SQLITE_EXPLAIN_ESTIMATED_ROWS)
SQLITE_PRIVATE u64 sqlite3LogEstToInt(LogEst);
-#endif
SQLITE_PRIVATE VList *sqlite3VListAdd(sqlite3*,VList*,const char*,int,int);
SQLITE_PRIVATE const char *sqlite3VListNumToName(VList*,int);
SQLITE_PRIVATE int sqlite3VListNameToNum(VList*,const char*,int);
@@ -19902,17 +20237,20 @@ SQLITE_PRIVATE int sqlite3CreateFunc(sqlite3 *, const char *, int, int, void *,
FuncDestructor *pDestructor
);
SQLITE_PRIVATE void sqlite3NoopDestructor(void*);
-SQLITE_PRIVATE void sqlite3OomFault(sqlite3*);
+SQLITE_PRIVATE void *sqlite3OomFault(sqlite3*);
SQLITE_PRIVATE void sqlite3OomClear(sqlite3*);
SQLITE_PRIVATE int sqlite3ApiExit(sqlite3 *db, int);
SQLITE_PRIVATE int sqlite3OpenTempDatabase(Parse *);
SQLITE_PRIVATE void sqlite3StrAccumInit(StrAccum*, sqlite3*, char*, int, int);
+SQLITE_PRIVATE int sqlite3StrAccumEnlarge(StrAccum*, int);
SQLITE_PRIVATE char *sqlite3StrAccumFinish(StrAccum*);
SQLITE_PRIVATE void sqlite3StrAccumSetError(StrAccum*, u8);
SQLITE_PRIVATE void sqlite3ResultStrAccum(sqlite3_context*,StrAccum*);
SQLITE_PRIVATE void sqlite3SelectDestInit(SelectDest*,int,int);
SQLITE_PRIVATE Expr *sqlite3CreateColumnExpr(sqlite3 *, SrcList *, int, int);
+SQLITE_PRIVATE void sqlite3RecordErrorByteOffset(sqlite3*,const char*);
+SQLITE_PRIVATE void sqlite3RecordErrorOffsetOfExpr(sqlite3*,const Expr*);
SQLITE_PRIVATE void sqlite3BackupRestart(sqlite3_backup *);
SQLITE_PRIVATE void sqlite3BackupUpdate(sqlite3_backup *, Pgno, const u8 *);
@@ -20017,11 +20355,17 @@ SQLITE_PRIVATE int sqlite3VtabCallCreate(sqlite3*, int, const char *, char **);
SQLITE_PRIVATE int sqlite3VtabCallConnect(Parse*, Table*);
SQLITE_PRIVATE int sqlite3VtabCallDestroy(sqlite3*, int, const char *);
SQLITE_PRIVATE int sqlite3VtabBegin(sqlite3 *, VTable *);
+
SQLITE_PRIVATE FuncDef *sqlite3VtabOverloadFunction(sqlite3 *,FuncDef*, int nArg, Expr*);
+#if (defined(SQLITE_ENABLE_DBPAGE_VTAB) || defined(SQLITE_TEST)) \
+ && !defined(SQLITE_OMIT_VIRTUALTABLE)
+SQLITE_PRIVATE void sqlite3VtabWriteAll(sqlite3_index_info*);
+#endif
SQLITE_PRIVATE sqlite3_int64 sqlite3StmtCurrentTime(sqlite3_context*);
SQLITE_PRIVATE int sqlite3VdbeParameterIndex(Vdbe*, const char*, int);
SQLITE_PRIVATE int sqlite3TransferBindings(sqlite3_stmt *, sqlite3_stmt *);
-SQLITE_PRIVATE void sqlite3ParserReset(Parse*);
+SQLITE_PRIVATE void sqlite3ParseObjectInit(Parse*,sqlite3*);
+SQLITE_PRIVATE void sqlite3ParseObjectReset(Parse*);
SQLITE_PRIVATE void *sqlite3ParserAddCleanup(Parse*,void(*)(sqlite3*,void*),void*);
#ifdef SQLITE_ENABLE_NORMALIZE
SQLITE_PRIVATE char *sqlite3Normalize(Vdbe*, const char*);
@@ -20080,6 +20424,7 @@ SQLITE_PRIVATE void sqlite3FkActions(Parse*, Table*, ExprList*, int, int*, int
SQLITE_PRIVATE int sqlite3FkRequired(Parse*, Table*, int*, int);
SQLITE_PRIVATE u32 sqlite3FkOldmask(Parse*, Table*);
SQLITE_PRIVATE FKey *sqlite3FkReferences(Table *);
+SQLITE_PRIVATE void sqlite3FkClearTriggerCache(sqlite3*,int);
#else
#define sqlite3FkActions(a,b,c,d,e,f)
#define sqlite3FkCheck(a,b,c,d,e,f)
@@ -20087,6 +20432,7 @@ SQLITE_PRIVATE FKey *sqlite3FkReferences(Table *);
#define sqlite3FkOldmask(a,b) 0
#define sqlite3FkRequired(a,b,c,d) 0
#define sqlite3FkReferences(a) 0
+ #define sqlite3FkClearTriggerCache(a,b)
#endif
#ifndef SQLITE_OMIT_FOREIGN_KEY
SQLITE_PRIVATE void sqlite3FkDelete(sqlite3 *, Table*);
@@ -20452,6 +20798,14 @@ SQLITE_API extern int sqlite3_open_file_count;
/************** End of os_common.h *******************************************/
/************** Begin file ctime.c *******************************************/
+/* DO NOT EDIT!
+** This file is automatically generated by the script in the canonical
+** SQLite source tree at tool/mkctimec.tcl.
+**
+** To modify this header, edit any of the various lists in that script
+** which specify categories of generated conditionals in this file.
+*/
+
/*
** 2010 February 23
**
@@ -20500,9 +20854,6 @@ SQLITE_API extern int sqlite3_open_file_count;
*/
static const char * const sqlite3azCompileOpt[] = {
-/*
-** BEGIN CODE GENERATED BY tool/mkctime.tcl
-*/
#ifdef SQLITE_32BIT_ROWID
"32BIT_ROWID",
#endif
@@ -20711,9 +21062,6 @@ static const char * const sqlite3azCompileOpt[] = {
#ifdef SQLITE_ENABLE_IOTRACE
"ENABLE_IOTRACE",
#endif
-#ifdef SQLITE_ENABLE_JSON1
- "ENABLE_JSON1",
-#endif
#ifdef SQLITE_ENABLE_LOAD_EXTENSION
"ENABLE_LOAD_EXTENSION",
#endif
@@ -21037,6 +21385,9 @@ static const char * const sqlite3azCompileOpt[] = {
#ifdef SQLITE_OMIT_INTROSPECTION_PRAGMAS
"OMIT_INTROSPECTION_PRAGMAS",
#endif
+#ifdef SQLITE_OMIT_JSON
+ "OMIT_JSON",
+#endif
#ifdef SQLITE_OMIT_LIKE_OPTIMIZATION
"OMIT_LIKE_OPTIMIZATION",
#endif
@@ -21225,10 +21576,8 @@ static const char * const sqlite3azCompileOpt[] = {
#ifdef SQLITE_ZERO_MALLOC
"ZERO_MALLOC",
#endif
-/*
-** END CODE GENERATED BY tool/mkctime.tcl
-*/
-};
+
+} ;
SQLITE_PRIVATE const char **sqlite3CompileOptions(int *pnOpt){
*pnOpt = sizeof(sqlite3azCompileOpt) / sizeof(sqlite3azCompileOpt[0]);
@@ -21527,6 +21876,7 @@ SQLITE_PRIVATE SQLITE_WSD struct Sqlite3Config sqlite3Config = {
0, /* xTestCallback */
#endif
0, /* bLocaltimeFault */
+ 0, /* xAltLocaltime */
0x7ffffffe, /* iOnceResetThreshold */
SQLITE_DEFAULT_SORTERREF_SIZE, /* szSorterRef */
0, /* iPrngSeed */
@@ -21740,7 +22090,7 @@ typedef struct AuxData AuxData;
typedef struct VdbeCursor VdbeCursor;
struct VdbeCursor {
u8 eCurType; /* One of the CURTYPE_* values above */
- i8 iDb; /* Index of cursor database in db->aDb[] (or -1) */
+ i8 iDb; /* Index of cursor database in db->aDb[] */
u8 nullRow; /* True if pointing to a row with no data */
u8 deferredMoveto; /* A call to sqlite3BtreeMoveto() is needed */
u8 isTable; /* True for rowid tables. False for indexes */
@@ -21753,9 +22103,11 @@ struct VdbeCursor {
Bool isOrdered:1; /* True if the table is not BTREE_UNORDERED */
Bool hasBeenDuped:1; /* This cursor was source or target of OP_OpenDup */
u16 seekHit; /* See the OP_SeekHit and OP_IfNoHope opcodes */
- Btree *pBtx; /* Separate file holding temporary table */
+ union { /* pBtx for isEphermeral. pAltMap otherwise */
+ Btree *pBtx; /* Separate file holding temporary table */
+ u32 *aAltMap; /* Mapping from table to index column numbers */
+ } ub;
i64 seqCount; /* Sequence counter */
- u32 *aAltMap; /* Mapping from table to index column numbers */
/* Cached OP_Column parse information is only valid if cacheStatus matches
** Vdbe.cacheCtr. Vdbe.cacheCtr will never take on the value of
@@ -22095,7 +22447,7 @@ struct Vdbe {
bft bIsReader:1; /* True for statements that read */
yDbMask btreeMask; /* Bitmask of db->aDb[] entries referenced */
yDbMask lockMask; /* Subset of btreeMask that requires a lock */
- u32 aCounter[7]; /* Counters used by sqlite3_stmt_status() */
+ u32 aCounter[9]; /* Counters used by sqlite3_stmt_status() */
char *zSql; /* Text of the SQL statement that generated this */
#ifdef SQLITE_ENABLE_NORMALIZE
char *zNormSql; /* Normalization of the associated SQL statement */
@@ -22146,6 +22498,24 @@ struct PreUpdate {
};
/*
+** An instance of this object is used to pass an vector of values into
+** OP_VFilter, the xFilter method of a virtual table. The vector is the
+** set of values on the right-hand side of an IN constraint.
+**
+** The value as passed into xFilter is an sqlite3_value with a "pointer"
+** type, such as is generated by sqlite3_result_pointer() and read by
+** sqlite3_value_pointer. Such values have MEM_Term|MEM_Subtype|MEM_Null
+** and a subtype of 'p'. The sqlite3_vtab_in_first() and _next() interfaces
+** know how to use this object to step through all the values in the
+** right operand of the IN constraint.
+*/
+typedef struct ValueList ValueList;
+struct ValueList {
+ BtCursor *pCsr; /* An ephemeral table holding all values */
+ sqlite3_value *pOut; /* Register to hold each decoded output value */
+};
+
+/*
** Function prototypes
*/
SQLITE_PRIVATE void sqlite3VdbeError(Vdbe*, const char *, ...);
@@ -22157,7 +22527,7 @@ SQLITE_PRIVATE int sqlite3VdbeCursorRestore(VdbeCursor*);
SQLITE_PRIVATE u32 sqlite3VdbeSerialTypeLen(u32);
SQLITE_PRIVATE u8 sqlite3VdbeOneByteSerialTypeLen(u8);
SQLITE_PRIVATE u32 sqlite3VdbeSerialPut(unsigned char*, Mem*, u32);
-SQLITE_PRIVATE u32 sqlite3VdbeSerialGet(const unsigned char*, u32, Mem*);
+SQLITE_PRIVATE void sqlite3VdbeSerialGet(const unsigned char*, u32, Mem*);
SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(sqlite3*, AuxData**, int, int);
int sqlite2BtreeKeyCompare(BtCursor *, const void *, int, int, int *);
@@ -22203,7 +22573,7 @@ SQLITE_PRIVATE int sqlite3VdbeMemSetRowSet(Mem*);
SQLITE_PRIVATE int sqlite3VdbeMemMakeWriteable(Mem*);
SQLITE_PRIVATE int sqlite3VdbeMemStringify(Mem*, u8, u8);
SQLITE_PRIVATE int sqlite3IntFloatCompare(i64,double);
-SQLITE_PRIVATE i64 sqlite3VdbeIntValue(Mem*);
+SQLITE_PRIVATE i64 sqlite3VdbeIntValue(const Mem*);
SQLITE_PRIVATE int sqlite3VdbeMemIntegerify(Mem*);
SQLITE_PRIVATE double sqlite3VdbeRealValue(Mem*);
SQLITE_PRIVATE int sqlite3VdbeBooleanValue(Mem*, int ifNull);
@@ -23181,8 +23551,10 @@ static void clearYMD_HMS_TZ(DateTime *p){
** is available. This routine returns 0 on success and
** non-zero on any kind of error.
**
-** If the sqlite3GlobalConfig.bLocaltimeFault variable is true then this
-** routine will always fail.
+** If the sqlite3GlobalConfig.bLocaltimeFault variable is non-zero then this
+** routine will always fail. If bLocaltimeFault is nonzero and
+** sqlite3GlobalConfig.xAltLocaltime is not NULL, then xAltLocaltime() is
+** invoked in place of the OS-defined localtime() function.
**
** EVIDENCE-OF: R-62172-00036 In this implementation, the standard C
** library function localtime_r() is used to assist in the calculation of
@@ -23198,14 +23570,30 @@ static int osLocaltime(time_t *t, struct tm *pTm){
sqlite3_mutex_enter(mutex);
pX = localtime(t);
#ifndef SQLITE_UNTESTABLE
- if( sqlite3GlobalConfig.bLocaltimeFault ) pX = 0;
+ if( sqlite3GlobalConfig.bLocaltimeFault ){
+ if( sqlite3GlobalConfig.xAltLocaltime!=0
+ && 0==sqlite3GlobalConfig.xAltLocaltime((const void*)t,(void*)pTm)
+ ){
+ pX = pTm;
+ }else{
+ pX = 0;
+ }
+ }
#endif
if( pX ) *pTm = *pX;
+#if SQLITE_THREADSAFE>0
sqlite3_mutex_leave(mutex);
+#endif
rc = pX==0;
#else
#ifndef SQLITE_UNTESTABLE
- if( sqlite3GlobalConfig.bLocaltimeFault ) return 1;
+ if( sqlite3GlobalConfig.bLocaltimeFault ){
+ if( sqlite3GlobalConfig.xAltLocaltime!=0 ){
+ return sqlite3GlobalConfig.xAltLocaltime((const void*)t,(void*)pTm);
+ }else{
+ return 1;
+ }
+ }
#endif
#if HAVE_LOCALTIME_R
rc = localtime_r(t, pTm)==0;
@@ -23220,67 +23608,56 @@ static int osLocaltime(time_t *t, struct tm *pTm){
#ifndef SQLITE_OMIT_LOCALTIME
/*
-** Compute the difference (in milliseconds) between localtime and UTC
-** (a.k.a. GMT) for the time value p where p is in UTC. If no error occurs,
-** return this value and set *pRc to SQLITE_OK.
-**
-** Or, if an error does occur, set *pRc to SQLITE_ERROR. The returned value
-** is undefined in this case.
+** Assuming the input DateTime is UTC, move it to its localtime equivalent.
*/
-static sqlite3_int64 localtimeOffset(
- DateTime *p, /* Date at which to calculate offset */
- sqlite3_context *pCtx, /* Write error here if one occurs */
- int *pRc /* OUT: Error code. SQLITE_OK or ERROR */
+static int toLocaltime(
+ DateTime *p, /* Date at which to calculate offset */
+ sqlite3_context *pCtx /* Write error here if one occurs */
){
- DateTime x, y;
time_t t;
struct tm sLocal;
+ int iYearDiff;
/* Initialize the contents of sLocal to avoid a compiler warning. */
memset(&sLocal, 0, sizeof(sLocal));
- x = *p;
- computeYMD_HMS(&x);
- if( x.Y<1971 || x.Y>=2038 ){
+ computeJD(p);
+ if( p->iJD<2108667600*(i64)100000 /* 1970-01-01 */
+ || p->iJD>2130141456*(i64)100000 /* 2038-01-18 */
+ ){
/* EVIDENCE-OF: R-55269-29598 The localtime_r() C function normally only
** works for years between 1970 and 2037. For dates outside this range,
** SQLite attempts to map the year into an equivalent year within this
** range, do the calculation, then map the year back.
*/
- x.Y = 2000;
- x.M = 1;
- x.D = 1;
- x.h = 0;
- x.m = 0;
- x.s = 0.0;
- } else {
- int s = (int)(x.s + 0.5);
- x.s = s;
+ DateTime x = *p;
+ computeYMD_HMS(&x);
+ iYearDiff = (2000 + x.Y%4) - x.Y;
+ x.Y += iYearDiff;
+ x.validJD = 0;
+ computeJD(&x);
+ t = (time_t)(x.iJD/1000 - 21086676*(i64)10000);
+ }else{
+ iYearDiff = 0;
+ t = (time_t)(p->iJD/1000 - 21086676*(i64)10000);
}
- x.tz = 0;
- x.validJD = 0;
- computeJD(&x);
- t = (time_t)(x.iJD/1000 - 21086676*(i64)10000);
if( osLocaltime(&t, &sLocal) ){
sqlite3_result_error(pCtx, "local time unavailable", -1);
- *pRc = SQLITE_ERROR;
- return 0;
+ return SQLITE_ERROR;
}
- y.Y = sLocal.tm_year + 1900;
- y.M = sLocal.tm_mon + 1;
- y.D = sLocal.tm_mday;
- y.h = sLocal.tm_hour;
- y.m = sLocal.tm_min;
- y.s = sLocal.tm_sec;
- y.validYMD = 1;
- y.validHMS = 1;
- y.validJD = 0;
- y.rawS = 0;
- y.validTZ = 0;
- y.isError = 0;
- computeJD(&y);
- *pRc = SQLITE_OK;
- return y.iJD - x.iJD;
+ p->Y = sLocal.tm_year + 1900 - iYearDiff;
+ p->M = sLocal.tm_mon + 1;
+ p->D = sLocal.tm_mday;
+ p->h = sLocal.tm_hour;
+ p->m = sLocal.tm_min;
+ p->s = sLocal.tm_sec + (p->iJD%1000)*0.001;
+ p->validYMD = 1;
+ p->validHMS = 1;
+ p->validJD = 0;
+ p->rawS = 0;
+ p->validTZ = 0;
+ p->isError = 0;
+ return SQLITE_OK;
}
#endif /* SQLITE_OMIT_LOCALTIME */
@@ -23293,18 +23670,17 @@ static sqlite3_int64 localtimeOffset(
** of several units of time.
*/
static const struct {
- u8 eType; /* Transformation type code */
- u8 nName; /* Length of th name */
- char *zName; /* Name of the transformation */
- double rLimit; /* Maximum NNN value for this transform */
- double rXform; /* Constant used for this transform */
+ u8 nName; /* Length of the name */
+ char zName[7]; /* Name of the transformation */
+ float rLimit; /* Maximum NNN value for this transform */
+ float rXform; /* Constant used for this transform */
} aXformType[] = {
- { 0, 6, "second", 464269060800.0, 1000.0 },
- { 0, 6, "minute", 7737817680.0, 60000.0 },
- { 0, 4, "hour", 128963628.0, 3600000.0 },
- { 0, 3, "day", 5373485.0, 86400000.0 },
- { 1, 5, "month", 176546.0, 2592000000.0 },
- { 2, 4, "year", 14713.0, 31536000000.0 },
+ { 6, "second", 4.6427e+14, 1.0 },
+ { 6, "minute", 7.7379e+12, 60.0 },
+ { 4, "hour", 1.2897e+11, 3600.0 },
+ { 3, "day", 5373485.0, 86400.0 },
+ { 5, "month", 176546.0, 2592000.0 },
+ { 4, "year", 14713.0, 31536000.0 },
};
/*
@@ -23335,11 +23711,55 @@ static int parseModifier(
sqlite3_context *pCtx, /* Function context */
const char *z, /* The text of the modifier */
int n, /* Length of zMod in bytes */
- DateTime *p /* The date/time value to be modified */
+ DateTime *p, /* The date/time value to be modified */
+ int idx /* Parameter index of the modifier */
){
int rc = 1;
double r;
switch(sqlite3UpperToLower[(u8)z[0]] ){
+ case 'a': {
+ /*
+ ** auto
+ **
+ ** If rawS is available, then interpret as a julian day number, or
+ ** a unix timestamp, depending on its magnitude.
+ */
+ if( sqlite3_stricmp(z, "auto")==0 ){
+ if( idx>1 ) return 1; /* IMP: R-33611-57934 */
+ if( !p->rawS || p->validJD ){
+ rc = 0;
+ p->rawS = 0;
+ }else if( p->s>=-21086676*(i64)10000 /* -4713-11-24 12:00:00 */
+ && p->s<=(25340230*(i64)10000)+799 /* 9999-12-31 23:59:59 */
+ ){
+ r = p->s*1000.0 + 210866760000000.0;
+ clearYMD_HMS_TZ(p);
+ p->iJD = (sqlite3_int64)(r + 0.5);
+ p->validJD = 1;
+ p->rawS = 0;
+ rc = 0;
+ }
+ }
+ break;
+ }
+ case 'j': {
+ /*
+ ** julianday
+ **
+ ** Always interpret the prior number as a julian-day value. If this
+ ** is not the first modifier, or if the prior argument is not a numeric
+ ** value in the allowed range of julian day numbers understood by
+ ** SQLite (0..5373484.5) then the result will be NULL.
+ */
+ if( sqlite3_stricmp(z, "julianday")==0 ){
+ if( idx>1 ) return 1; /* IMP: R-31176-64601 */
+ if( p->validJD && p->rawS ){
+ rc = 0;
+ p->rawS = 0;
+ }
+ }
+ break;
+ }
#ifndef SQLITE_OMIT_LOCALTIME
case 'l': {
/* localtime
@@ -23348,9 +23768,7 @@ static int parseModifier(
** show local time.
*/
if( sqlite3_stricmp(z, "localtime")==0 && sqlite3NotPureFunc(pCtx) ){
- computeJD(p);
- p->iJD += localtimeOffset(p, pCtx, &rc);
- clearYMD_HMS_TZ(p);
+ rc = toLocaltime(p, pCtx);
}
break;
}
@@ -23363,6 +23781,7 @@ static int parseModifier(
** seconds since 1970. Convert to a real julian day number.
*/
if( sqlite3_stricmp(z, "unixepoch")==0 && p->rawS ){
+ if( idx>1 ) return 1; /* IMP: R-49255-55373 */
r = p->s*1000.0 + 210866760000000.0;
if( r>=0.0 && r<464269060800000.0 ){
clearYMD_HMS_TZ(p);
@@ -23375,18 +23794,31 @@ static int parseModifier(
#ifndef SQLITE_OMIT_LOCALTIME
else if( sqlite3_stricmp(z, "utc")==0 && sqlite3NotPureFunc(pCtx) ){
if( p->tzSet==0 ){
- sqlite3_int64 c1;
+ i64 iOrigJD; /* Original localtime */
+ i64 iGuess; /* Guess at the corresponding utc time */
+ int cnt = 0; /* Safety to prevent infinite loop */
+ int iErr; /* Guess is off by this much */
+
computeJD(p);
- c1 = localtimeOffset(p, pCtx, &rc);
- if( rc==SQLITE_OK ){
- p->iJD -= c1;
- clearYMD_HMS_TZ(p);
- p->iJD += c1 - localtimeOffset(p, pCtx, &rc);
- }
+ iGuess = iOrigJD = p->iJD;
+ iErr = 0;
+ do{
+ DateTime new;
+ memset(&new, 0, sizeof(new));
+ iGuess -= iErr;
+ new.iJD = iGuess;
+ new.validJD = 1;
+ rc = toLocaltime(&new, pCtx);
+ if( rc ) return rc;
+ computeJD(&new);
+ iErr = new.iJD - iOrigJD;
+ }while( iErr && cnt++<3 );
+ memset(p, 0, sizeof(*p));
+ p->iJD = iGuess;
+ p->validJD = 1;
p->tzSet = 1;
- }else{
- rc = SQLITE_OK;
}
+ rc = SQLITE_OK;
}
#endif
break;
@@ -23502,9 +23934,10 @@ static int parseModifier(
&& sqlite3_strnicmp(aXformType[i].zName, z, n)==0
&& r>-aXformType[i].rLimit && r<aXformType[i].rLimit
){
- switch( aXformType[i].eType ){
- case 1: { /* Special processing to add months */
+ switch( i ){
+ case 4: { /* Special processing to add months */
int x;
+ assert( strcmp(aXformType[i].zName,"month")==0 );
computeYMD_HMS(p);
p->M += (int)r;
x = p->M>0 ? (p->M-1)/12 : (p->M-12)/12;
@@ -23514,8 +23947,9 @@ static int parseModifier(
r -= (int)r;
break;
}
- case 2: { /* Special processing to add years */
+ case 5: { /* Special processing to add years */
int y = (int)r;
+ assert( strcmp(aXformType[i].zName,"year")==0 );
computeYMD_HMS(p);
p->Y += y;
p->validJD = 0;
@@ -23524,7 +23958,7 @@ static int parseModifier(
}
}
computeJD(p);
- p->iJD += (sqlite3_int64)(r*aXformType[i].rXform + rRounder);
+ p->iJD += (sqlite3_int64)(r*1000.0*aXformType[i].rXform + rRounder);
rc = 0;
break;
}
@@ -23574,7 +24008,7 @@ static int isDate(
for(i=1; i<argc; i++){
z = sqlite3_value_text(argv[i]);
n = sqlite3_value_bytes(argv[i]);
- if( z==0 || parseModifier(context, (char*)z, n, p) ) return 1;
+ if( z==0 || parseModifier(context, (char*)z, n, p, i) ) return 1;
}
computeJD(p);
if( p->isError || !validJulianDay(p->iJD) ) return 1;
@@ -23605,6 +24039,24 @@ static void juliandayFunc(
}
/*
+** unixepoch( TIMESTRING, MOD, MOD, ...)
+**
+** Return the number of seconds (including fractional seconds) since
+** the unix epoch of 1970-01-01 00:00:00 GMT.
+*/
+static void unixepochFunc(
+ sqlite3_context *context,
+ int argc,
+ sqlite3_value **argv
+){
+ DateTime x;
+ if( isDate(context, argc, argv, &x)==0 ){
+ computeJD(&x);
+ sqlite3_result_int64(context, x.iJD/1000 - 21086676*(i64)10000);
+ }
+}
+
+/*
** datetime( TIMESTRING, MOD, MOD, ...)
**
** Return YYYY-MM-DD HH:MM:SS
@@ -23616,11 +24068,38 @@ static void datetimeFunc(
){
DateTime x;
if( isDate(context, argc, argv, &x)==0 ){
- char zBuf[100];
+ int Y, s;
+ char zBuf[24];
computeYMD_HMS(&x);
- sqlite3_snprintf(sizeof(zBuf), zBuf, "%04d-%02d-%02d %02d:%02d:%02d",
- x.Y, x.M, x.D, x.h, x.m, (int)(x.s));
- sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT);
+ Y = x.Y;
+ if( Y<0 ) Y = -Y;
+ zBuf[1] = '0' + (Y/1000)%10;
+ zBuf[2] = '0' + (Y/100)%10;
+ zBuf[3] = '0' + (Y/10)%10;
+ zBuf[4] = '0' + (Y)%10;
+ zBuf[5] = '-';
+ zBuf[6] = '0' + (x.M/10)%10;
+ zBuf[7] = '0' + (x.M)%10;
+ zBuf[8] = '-';
+ zBuf[9] = '0' + (x.D/10)%10;
+ zBuf[10] = '0' + (x.D)%10;
+ zBuf[11] = ' ';
+ zBuf[12] = '0' + (x.h/10)%10;
+ zBuf[13] = '0' + (x.h)%10;
+ zBuf[14] = ':';
+ zBuf[15] = '0' + (x.m/10)%10;
+ zBuf[16] = '0' + (x.m)%10;
+ zBuf[17] = ':';
+ s = (int)x.s;
+ zBuf[18] = '0' + (s/10)%10;
+ zBuf[19] = '0' + (s)%10;
+ zBuf[20] = 0;
+ if( x.Y<0 ){
+ zBuf[0] = '-';
+ sqlite3_result_text(context, zBuf, 20, SQLITE_TRANSIENT);
+ }else{
+ sqlite3_result_text(context, &zBuf[1], 19, SQLITE_TRANSIENT);
+ }
}
}
@@ -23636,10 +24115,20 @@ static void timeFunc(
){
DateTime x;
if( isDate(context, argc, argv, &x)==0 ){
- char zBuf[100];
+ int s;
+ char zBuf[16];
computeHMS(&x);
- sqlite3_snprintf(sizeof(zBuf), zBuf, "%02d:%02d:%02d", x.h, x.m, (int)x.s);
- sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT);
+ zBuf[0] = '0' + (x.h/10)%10;
+ zBuf[1] = '0' + (x.h)%10;
+ zBuf[2] = ':';
+ zBuf[3] = '0' + (x.m/10)%10;
+ zBuf[4] = '0' + (x.m)%10;
+ zBuf[5] = ':';
+ s = (int)x.s;
+ zBuf[6] = '0' + (s/10)%10;
+ zBuf[7] = '0' + (s)%10;
+ zBuf[8] = 0;
+ sqlite3_result_text(context, zBuf, 8, SQLITE_TRANSIENT);
}
}
@@ -23655,10 +24144,28 @@ static void dateFunc(
){
DateTime x;
if( isDate(context, argc, argv, &x)==0 ){
- char zBuf[100];
+ int Y;
+ char zBuf[16];
computeYMD(&x);
- sqlite3_snprintf(sizeof(zBuf), zBuf, "%04d-%02d-%02d", x.Y, x.M, x.D);
- sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT);
+ Y = x.Y;
+ if( Y<0 ) Y = -Y;
+ zBuf[1] = '0' + (Y/1000)%10;
+ zBuf[2] = '0' + (Y/100)%10;
+ zBuf[3] = '0' + (Y/10)%10;
+ zBuf[4] = '0' + (Y)%10;
+ zBuf[5] = '-';
+ zBuf[6] = '0' + (x.M/10)%10;
+ zBuf[7] = '0' + (x.M)%10;
+ zBuf[8] = '-';
+ zBuf[9] = '0' + (x.D/10)%10;
+ zBuf[10] = '0' + (x.D)%10;
+ zBuf[11] = 0;
+ if( x.Y<0 ){
+ zBuf[0] = '-';
+ sqlite3_result_text(context, zBuf, 11, SQLITE_TRANSIENT);
+ }else{
+ sqlite3_result_text(context, &zBuf[1], 10, SQLITE_TRANSIENT);
+ }
}
}
@@ -23880,6 +24387,7 @@ SQLITE_PRIVATE void sqlite3RegisterDateTimeFunctions(void){
static FuncDef aDateTimeFuncs[] = {
#ifndef SQLITE_OMIT_DATETIME_FUNCS
PURE_DATE(julianday, -1, 0, 0, juliandayFunc ),
+ PURE_DATE(unixepoch, -1, 0, 0, unixepochFunc ),
PURE_DATE(date, -1, 0, 0, dateFunc ),
PURE_DATE(time, -1, 0, 0, timeFunc ),
PURE_DATE(datetime, -1, 0, 0, datetimeFunc ),
@@ -28825,8 +29333,15 @@ SQLITE_PRIVATE void sqlite3SetString(char **pz, sqlite3 *db, const char *zNew){
** has happened. This routine will set db->mallocFailed, and also
** temporarily disable the lookaside memory allocator and interrupt
** any running VDBEs.
+**
+** Always return a NULL pointer so that this routine can be invoked using
+**
+** return sqlite3OomFault(db);
+**
+** and thereby avoid unnecessary stack frame allocations for the overwhelmingly
+** common case where no OOM occurs.
*/
-SQLITE_PRIVATE void sqlite3OomFault(sqlite3 *db){
+SQLITE_PRIVATE void *sqlite3OomFault(sqlite3 *db){
if( db->mallocFailed==0 && db->bBenignMalloc==0 ){
db->mallocFailed = 1;
if( db->nVdbeExec>0 ){
@@ -28834,9 +29349,11 @@ SQLITE_PRIVATE void sqlite3OomFault(sqlite3 *db){
}
DisableLookaside;
if( db->pParse ){
+ sqlite3ErrorMsg(db->pParse, "out of memory");
db->pParse->rc = SQLITE_NOMEM_BKPT;
}
}
+ return 0;
}
/*
@@ -29745,12 +30262,22 @@ SQLITE_API void sqlite3_str_vappendf(
goto adjust_width_for_utf8;
}
case etTOKEN: {
- Token *pToken;
if( (pAccum->printfFlags & SQLITE_PRINTF_INTERNAL)==0 ) return;
- pToken = va_arg(ap, Token*);
- assert( bArgList==0 );
- if( pToken && pToken->n ){
- sqlite3_str_append(pAccum, (const char*)pToken->z, pToken->n);
+ if( flag_alternateform ){
+ /* %#T means an Expr pointer that uses Expr.u.zToken */
+ Expr *pExpr = va_arg(ap,Expr*);
+ if( ALWAYS(pExpr) && ALWAYS(!ExprHasProperty(pExpr,EP_IntValue)) ){
+ sqlite3_str_appendall(pAccum, (const char*)pExpr->u.zToken);
+ sqlite3RecordErrorOffsetOfExpr(pAccum->db, pExpr);
+ }
+ }else{
+ /* %T means a Token pointer */
+ Token *pToken = va_arg(ap, Token*);
+ assert( bArgList==0 );
+ if( pToken && pToken->n ){
+ sqlite3_str_append(pAccum, (const char*)pToken->z, pToken->n);
+ sqlite3RecordErrorByteOffset(pAccum->db, pToken->z);
+ }
}
length = width = 0;
break;
@@ -29805,6 +30332,42 @@ SQLITE_API void sqlite3_str_vappendf(
}/* End for loop over the format string */
} /* End of function */
+
+/*
+** The z string points to the first character of a token that is
+** associated with an error. If db does not already have an error
+** byte offset recorded, try to compute the error byte offset for
+** z and set the error byte offset in db.
+*/
+SQLITE_PRIVATE void sqlite3RecordErrorByteOffset(sqlite3 *db, const char *z){
+ const Parse *pParse;
+ const char *zText;
+ const char *zEnd;
+ assert( z!=0 );
+ if( NEVER(db==0) ) return;
+ if( db->errByteOffset!=(-2) ) return;
+ pParse = db->pParse;
+ if( NEVER(pParse==0) ) return;
+ zText =pParse->zTail;
+ if( NEVER(zText==0) ) return;
+ zEnd = &zText[strlen(zText)];
+ if( SQLITE_WITHIN(z,zText,zEnd) ){
+ db->errByteOffset = (int)(z-zText);
+ }
+}
+
+/*
+** If pExpr has a byte offset for the start of a token, record that as
+** as the error offset.
+*/
+SQLITE_PRIVATE void sqlite3RecordErrorOffsetOfExpr(sqlite3 *db, const Expr *pExpr){
+ while( pExpr && (ExprHasProperty(pExpr,EP_FromJoin) || pExpr->w.iOfst<=0) ){
+ pExpr = pExpr->pLeft;
+ }
+ if( pExpr==0 ) return;
+ db->errByteOffset = pExpr->w.iOfst;
+}
+
/*
** Enlarge the memory allocation on a StrAccum object so that it is
** able to accept at least N more bytes of text.
@@ -29812,7 +30375,7 @@ SQLITE_API void sqlite3_str_vappendf(
** Return the number of bytes of text that StrAccum is able to accept
** after the attempted enlargement. The value returned might be zero.
*/
-static int sqlite3StrAccumEnlarge(StrAccum *p, int N){
+SQLITE_PRIVATE int sqlite3StrAccumEnlarge(StrAccum *p, int N){
char *zNew;
assert( p->nChar+(i64)N >= p->nAlloc ); /* Only called if really needed */
if( p->accError ){
@@ -30646,7 +31209,7 @@ SQLITE_PRIVATE void sqlite3TreeViewExpr(TreeView *pView, const Expr *pExpr, u8 m
sqlite3_str_appendf(&x, " fg.af=%x.%c",
pExpr->flags, pExpr->affExpr ? pExpr->affExpr : 'n');
if( ExprHasProperty(pExpr, EP_FromJoin) ){
- sqlite3_str_appendf(&x, " iRJT=%d", pExpr->iRightJoinTable);
+ sqlite3_str_appendf(&x, " iRJT=%d", pExpr->w.iRightJoinTable);
}
if( ExprHasProperty(pExpr, EP_FromDDL) ){
sqlite3_str_appendf(&x, " DDL");
@@ -32128,7 +32691,11 @@ static SQLITE_NOINLINE void sqlite3ErrorFinish(sqlite3 *db, int err_code){
SQLITE_PRIVATE void sqlite3Error(sqlite3 *db, int err_code){
assert( db!=0 );
db->errCode = err_code;
- if( err_code || db->pErr ) sqlite3ErrorFinish(db, err_code);
+ if( err_code || db->pErr ){
+ sqlite3ErrorFinish(db, err_code);
+ }else{
+ db->errByteOffset = -1;
+ }
}
/*
@@ -32138,6 +32705,7 @@ SQLITE_PRIVATE void sqlite3Error(sqlite3 *db, int err_code){
SQLITE_PRIVATE void sqlite3ErrorClear(sqlite3 *db){
assert( db!=0 );
db->errCode = SQLITE_OK;
+ db->errByteOffset = -1;
if( db->pErr ) sqlite3ValueSetNull(db->pErr);
}
@@ -32158,17 +32726,8 @@ SQLITE_PRIVATE void sqlite3SystemError(sqlite3 *db, int rc){
** handle "db". The error code is set to "err_code".
**
** If it is not NULL, string zFormat specifies the format of the
-** error string in the style of the printf functions: The following
-** format characters are allowed:
-**
-** %s Insert a string
-** %z A string that should be freed after use
-** %d Insert an integer
-** %T Insert a token
-** %S Insert the first element of a SrcList
-**
-** zFormat and any string tokens that follow it are assumed to be
-** encoded in UTF-8.
+** error string. zFormat and any string tokens that follow it are
+** assumed to be encoded in UTF-8.
**
** To clear the most recent error for sqlite handle "db", sqlite3Error
** should be called with err_code set to SQLITE_OK and zFormat set
@@ -32192,13 +32751,6 @@ SQLITE_PRIVATE void sqlite3ErrorWithMsg(sqlite3 *db, int err_code, const char *z
/*
** Add an error message to pParse->zErrMsg and increment pParse->nErr.
-** The following formatting characters are allowed:
-**
-** %s Insert a string
-** %z A string that should be freed after use
-** %d Insert an integer
-** %T Insert a token
-** %S Insert the first element of a SrcList
**
** This function should be used to report any error that occurs while
** compiling an SQL statement (i.e. within sqlite3_prepare()). The
@@ -32211,11 +32763,19 @@ SQLITE_PRIVATE void sqlite3ErrorMsg(Parse *pParse, const char *zFormat, ...){
char *zMsg;
va_list ap;
sqlite3 *db = pParse->db;
+ assert( db!=0 );
+ assert( db->pParse==pParse );
+ db->errByteOffset = -2;
va_start(ap, zFormat);
zMsg = sqlite3VMPrintf(db, zFormat, ap);
va_end(ap);
+ if( db->errByteOffset<-1 ) db->errByteOffset = -1;
if( db->suppressErr ){
sqlite3DbFree(db, zMsg);
+ if( db->mallocFailed ){
+ pParse->nErr++;
+ pParse->rc = SQLITE_NOMEM;
+ }
}else{
pParse->nErr++;
sqlite3DbFree(db, pParse->zErrMsg);
@@ -33597,7 +34157,6 @@ SQLITE_PRIVATE LogEst sqlite3LogEst(u64 x){
return a[x&7] + y - 10;
}
-#ifndef SQLITE_OMIT_VIRTUALTABLE
/*
** Convert a double into a LogEst
** In other words, compute an approximation for 10*log2(x).
@@ -33612,16 +34171,9 @@ SQLITE_PRIVATE LogEst sqlite3LogEstFromDouble(double x){
e = (a>>52) - 1022;
return e*10;
}
-#endif /* SQLITE_OMIT_VIRTUALTABLE */
-#if defined(SQLITE_ENABLE_STMT_SCANSTATUS) || \
- defined(SQLITE_ENABLE_STAT4) || \
- defined(SQLITE_EXPLAIN_ESTIMATED_ROWS)
/*
** Convert a LogEst into an integer.
-**
-** Note that this routine is only used when one or more of various
-** non-standard compile-time options is enabled.
*/
SQLITE_PRIVATE u64 sqlite3LogEstToInt(LogEst x){
u64 n;
@@ -33629,17 +34181,9 @@ SQLITE_PRIVATE u64 sqlite3LogEstToInt(LogEst x){
x /= 10;
if( n>=5 ) n -= 2;
else if( n>=1 ) n -= 1;
-#if defined(SQLITE_ENABLE_STMT_SCANSTATUS) || \
- defined(SQLITE_EXPLAIN_ESTIMATED_ROWS)
if( x>60 ) return (u64)LARGEST_INT64;
-#else
- /* If only SQLITE_ENABLE_STAT4 is on, then the largest input
- ** possible to this routine is 310, resulting in a maximum x of 31 */
- assert( x<=60 );
-#endif
return x>=3 ? (n+8)<<(x-3) : (n+8)>>(3-x);
}
-#endif /* defined SCANSTAT or STAT4 or ESTIMATED_ROWS */
/*
** Add a new name/number pair to a VList. This might require that the
@@ -34093,35 +34637,35 @@ SQLITE_PRIVATE const char *sqlite3OpcodeName(int i){
/* 60 */ "DecrJumpZero" OpHelp("if (--r[P1])==0 goto P2"),
/* 61 */ "IncrVacuum" OpHelp(""),
/* 62 */ "VNext" OpHelp(""),
- /* 63 */ "Init" OpHelp("Start at P2"),
- /* 64 */ "PureFunc" OpHelp("r[P3]=func(r[P2@NP])"),
- /* 65 */ "Function" OpHelp("r[P3]=func(r[P2@NP])"),
- /* 66 */ "Return" OpHelp(""),
- /* 67 */ "EndCoroutine" OpHelp(""),
- /* 68 */ "HaltIfNull" OpHelp("if r[P3]=null halt"),
- /* 69 */ "Halt" OpHelp(""),
- /* 70 */ "Integer" OpHelp("r[P2]=P1"),
- /* 71 */ "Int64" OpHelp("r[P2]=P4"),
- /* 72 */ "String" OpHelp("r[P2]='P4' (len=P1)"),
- /* 73 */ "Null" OpHelp("r[P2..P3]=NULL"),
- /* 74 */ "SoftNull" OpHelp("r[P1]=NULL"),
- /* 75 */ "Blob" OpHelp("r[P2]=P4 (len=P1)"),
- /* 76 */ "Variable" OpHelp("r[P2]=parameter(P1,P4)"),
- /* 77 */ "Move" OpHelp("r[P2@P3]=r[P1@P3]"),
- /* 78 */ "Copy" OpHelp("r[P2@P3+1]=r[P1@P3+1]"),
- /* 79 */ "SCopy" OpHelp("r[P2]=r[P1]"),
- /* 80 */ "IntCopy" OpHelp("r[P2]=r[P1]"),
- /* 81 */ "ChngCntRow" OpHelp("output=r[P1]"),
- /* 82 */ "ResultRow" OpHelp("output=r[P1@P2]"),
- /* 83 */ "CollSeq" OpHelp(""),
- /* 84 */ "AddImm" OpHelp("r[P1]=r[P1]+P2"),
- /* 85 */ "RealAffinity" OpHelp(""),
- /* 86 */ "Cast" OpHelp("affinity(r[P1])"),
- /* 87 */ "Permutation" OpHelp(""),
- /* 88 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"),
- /* 89 */ "IsTrue" OpHelp("r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4"),
- /* 90 */ "ZeroOrNull" OpHelp("r[P2] = 0 OR NULL"),
- /* 91 */ "Offset" OpHelp("r[P3] = sqlite_offset(P1)"),
+ /* 63 */ "Filter" OpHelp("if key(P3@P4) not in filter(P1) goto P2"),
+ /* 64 */ "Init" OpHelp("Start at P2"),
+ /* 65 */ "PureFunc" OpHelp("r[P3]=func(r[P2@NP])"),
+ /* 66 */ "Function" OpHelp("r[P3]=func(r[P2@NP])"),
+ /* 67 */ "Return" OpHelp(""),
+ /* 68 */ "EndCoroutine" OpHelp(""),
+ /* 69 */ "HaltIfNull" OpHelp("if r[P3]=null halt"),
+ /* 70 */ "Halt" OpHelp(""),
+ /* 71 */ "Integer" OpHelp("r[P2]=P1"),
+ /* 72 */ "Int64" OpHelp("r[P2]=P4"),
+ /* 73 */ "String" OpHelp("r[P2]='P4' (len=P1)"),
+ /* 74 */ "Null" OpHelp("r[P2..P3]=NULL"),
+ /* 75 */ "SoftNull" OpHelp("r[P1]=NULL"),
+ /* 76 */ "Blob" OpHelp("r[P2]=P4 (len=P1)"),
+ /* 77 */ "Variable" OpHelp("r[P2]=parameter(P1,P4)"),
+ /* 78 */ "Move" OpHelp("r[P2@P3]=r[P1@P3]"),
+ /* 79 */ "Copy" OpHelp("r[P2@P3+1]=r[P1@P3+1]"),
+ /* 80 */ "SCopy" OpHelp("r[P2]=r[P1]"),
+ /* 81 */ "IntCopy" OpHelp("r[P2]=r[P1]"),
+ /* 82 */ "FkCheck" OpHelp(""),
+ /* 83 */ "ResultRow" OpHelp("output=r[P1@P2]"),
+ /* 84 */ "CollSeq" OpHelp(""),
+ /* 85 */ "AddImm" OpHelp("r[P1]=r[P1]+P2"),
+ /* 86 */ "RealAffinity" OpHelp(""),
+ /* 87 */ "Cast" OpHelp("affinity(r[P1])"),
+ /* 88 */ "Permutation" OpHelp(""),
+ /* 89 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"),
+ /* 90 */ "IsTrue" OpHelp("r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4"),
+ /* 91 */ "ZeroOrNull" OpHelp("r[P2] = 0 OR NULL"),
/* 92 */ "BitAnd" OpHelp("r[P3]=r[P1]&r[P2]"),
/* 93 */ "BitOr" OpHelp("r[P3]=r[P1]|r[P2]"),
/* 94 */ "ShiftLeft" OpHelp("r[P3]=r[P2]<<r[P1]"),
@@ -34132,86 +34676,89 @@ SQLITE_PRIVATE const char *sqlite3OpcodeName(int i){
/* 99 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"),
/* 100 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"),
/* 101 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"),
- /* 102 */ "Column" OpHelp("r[P3]=PX"),
- /* 103 */ "BitNot" OpHelp("r[P2]= ~r[P1]"),
- /* 104 */ "TypeCheck" OpHelp("typecheck(r[P1@P2])"),
- /* 105 */ "Affinity" OpHelp("affinity(r[P1@P2])"),
- /* 106 */ "String8" OpHelp("r[P2]='P4'"),
- /* 107 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"),
- /* 108 */ "Count" OpHelp("r[P2]=count()"),
- /* 109 */ "ReadCookie" OpHelp(""),
- /* 110 */ "SetCookie" OpHelp(""),
- /* 111 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"),
- /* 112 */ "OpenRead" OpHelp("root=P2 iDb=P3"),
- /* 113 */ "OpenWrite" OpHelp("root=P2 iDb=P3"),
- /* 114 */ "OpenDup" OpHelp(""),
- /* 115 */ "OpenAutoindex" OpHelp("nColumn=P2"),
- /* 116 */ "OpenEphemeral" OpHelp("nColumn=P2"),
- /* 117 */ "SorterOpen" OpHelp(""),
- /* 118 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"),
- /* 119 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"),
- /* 120 */ "Close" OpHelp(""),
- /* 121 */ "ColumnsUsed" OpHelp(""),
- /* 122 */ "SeekScan" OpHelp("Scan-ahead up to P1 rows"),
- /* 123 */ "SeekHit" OpHelp("set P2<=seekHit<=P3"),
- /* 124 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"),
- /* 125 */ "NewRowid" OpHelp("r[P2]=rowid"),
- /* 126 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"),
- /* 127 */ "RowCell" OpHelp(""),
- /* 128 */ "Delete" OpHelp(""),
- /* 129 */ "ResetCount" OpHelp(""),
- /* 130 */ "SorterCompare" OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"),
- /* 131 */ "SorterData" OpHelp("r[P2]=data"),
- /* 132 */ "RowData" OpHelp("r[P2]=data"),
- /* 133 */ "Rowid" OpHelp("r[P2]=rowid"),
- /* 134 */ "NullRow" OpHelp(""),
- /* 135 */ "SeekEnd" OpHelp(""),
- /* 136 */ "IdxInsert" OpHelp("key=r[P2]"),
- /* 137 */ "SorterInsert" OpHelp("key=r[P2]"),
- /* 138 */ "IdxDelete" OpHelp("key=r[P2@P3]"),
- /* 139 */ "DeferredSeek" OpHelp("Move P3 to P1.rowid if needed"),
- /* 140 */ "IdxRowid" OpHelp("r[P2]=rowid"),
- /* 141 */ "FinishSeek" OpHelp(""),
- /* 142 */ "Real" OpHelp("r[P2]=P4"),
- /* 143 */ "Destroy" OpHelp(""),
- /* 144 */ "Clear" OpHelp(""),
- /* 145 */ "ResetSorter" OpHelp(""),
- /* 146 */ "CreateBtree" OpHelp("r[P2]=root iDb=P1 flags=P3"),
- /* 147 */ "SqlExec" OpHelp(""),
- /* 148 */ "ParseSchema" OpHelp(""),
- /* 149 */ "LoadAnalysis" OpHelp(""),
- /* 150 */ "DropTable" OpHelp(""),
- /* 151 */ "DropIndex" OpHelp(""),
- /* 152 */ "DropTrigger" OpHelp(""),
- /* 153 */ "IntegrityCk" OpHelp(""),
- /* 154 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"),
- /* 155 */ "Param" OpHelp(""),
- /* 156 */ "FkCounter" OpHelp("fkctr[P1]+=P2"),
- /* 157 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"),
- /* 158 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"),
- /* 159 */ "AggInverse" OpHelp("accum=r[P3] inverse(r[P2@P5])"),
- /* 160 */ "AggStep" OpHelp("accum=r[P3] step(r[P2@P5])"),
- /* 161 */ "AggStep1" OpHelp("accum=r[P3] step(r[P2@P5])"),
- /* 162 */ "AggValue" OpHelp("r[P3]=value N=P2"),
- /* 163 */ "AggFinal" OpHelp("accum=r[P1] N=P2"),
- /* 164 */ "Expire" OpHelp(""),
- /* 165 */ "CursorLock" OpHelp(""),
- /* 166 */ "CursorUnlock" OpHelp(""),
- /* 167 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"),
- /* 168 */ "VBegin" OpHelp(""),
- /* 169 */ "VCreate" OpHelp(""),
- /* 170 */ "VDestroy" OpHelp(""),
- /* 171 */ "VOpen" OpHelp(""),
- /* 172 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"),
- /* 173 */ "VRename" OpHelp(""),
- /* 174 */ "Pagecount" OpHelp(""),
- /* 175 */ "MaxPgcnt" OpHelp(""),
- /* 176 */ "Trace" OpHelp(""),
- /* 177 */ "CursorHint" OpHelp(""),
- /* 178 */ "ReleaseReg" OpHelp("release r[P1@P2] mask P3"),
- /* 179 */ "Noop" OpHelp(""),
- /* 180 */ "Explain" OpHelp(""),
- /* 181 */ "Abortable" OpHelp(""),
+ /* 102 */ "Offset" OpHelp("r[P3] = sqlite_offset(P1)"),
+ /* 103 */ "Column" OpHelp("r[P3]=PX"),
+ /* 104 */ "BitNot" OpHelp("r[P2]= ~r[P1]"),
+ /* 105 */ "TypeCheck" OpHelp("typecheck(r[P1@P2])"),
+ /* 106 */ "Affinity" OpHelp("affinity(r[P1@P2])"),
+ /* 107 */ "String8" OpHelp("r[P2]='P4'"),
+ /* 108 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"),
+ /* 109 */ "Count" OpHelp("r[P2]=count()"),
+ /* 110 */ "ReadCookie" OpHelp(""),
+ /* 111 */ "SetCookie" OpHelp(""),
+ /* 112 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"),
+ /* 113 */ "OpenRead" OpHelp("root=P2 iDb=P3"),
+ /* 114 */ "OpenWrite" OpHelp("root=P2 iDb=P3"),
+ /* 115 */ "OpenDup" OpHelp(""),
+ /* 116 */ "OpenAutoindex" OpHelp("nColumn=P2"),
+ /* 117 */ "OpenEphemeral" OpHelp("nColumn=P2"),
+ /* 118 */ "SorterOpen" OpHelp(""),
+ /* 119 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"),
+ /* 120 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"),
+ /* 121 */ "Close" OpHelp(""),
+ /* 122 */ "ColumnsUsed" OpHelp(""),
+ /* 123 */ "SeekScan" OpHelp("Scan-ahead up to P1 rows"),
+ /* 124 */ "SeekHit" OpHelp("set P2<=seekHit<=P3"),
+ /* 125 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"),
+ /* 126 */ "NewRowid" OpHelp("r[P2]=rowid"),
+ /* 127 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"),
+ /* 128 */ "RowCell" OpHelp(""),
+ /* 129 */ "Delete" OpHelp(""),
+ /* 130 */ "ResetCount" OpHelp(""),
+ /* 131 */ "SorterCompare" OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"),
+ /* 132 */ "SorterData" OpHelp("r[P2]=data"),
+ /* 133 */ "RowData" OpHelp("r[P2]=data"),
+ /* 134 */ "Rowid" OpHelp("r[P2]=rowid"),
+ /* 135 */ "NullRow" OpHelp(""),
+ /* 136 */ "SeekEnd" OpHelp(""),
+ /* 137 */ "IdxInsert" OpHelp("key=r[P2]"),
+ /* 138 */ "SorterInsert" OpHelp("key=r[P2]"),
+ /* 139 */ "IdxDelete" OpHelp("key=r[P2@P3]"),
+ /* 140 */ "DeferredSeek" OpHelp("Move P3 to P1.rowid if needed"),
+ /* 141 */ "IdxRowid" OpHelp("r[P2]=rowid"),
+ /* 142 */ "FinishSeek" OpHelp(""),
+ /* 143 */ "Real" OpHelp("r[P2]=P4"),
+ /* 144 */ "Destroy" OpHelp(""),
+ /* 145 */ "Clear" OpHelp(""),
+ /* 146 */ "ResetSorter" OpHelp(""),
+ /* 147 */ "CreateBtree" OpHelp("r[P2]=root iDb=P1 flags=P3"),
+ /* 148 */ "SqlExec" OpHelp(""),
+ /* 149 */ "ParseSchema" OpHelp(""),
+ /* 150 */ "LoadAnalysis" OpHelp(""),
+ /* 151 */ "DropTable" OpHelp(""),
+ /* 152 */ "DropIndex" OpHelp(""),
+ /* 153 */ "DropTrigger" OpHelp(""),
+ /* 154 */ "IntegrityCk" OpHelp(""),
+ /* 155 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"),
+ /* 156 */ "Param" OpHelp(""),
+ /* 157 */ "FkCounter" OpHelp("fkctr[P1]+=P2"),
+ /* 158 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"),
+ /* 159 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"),
+ /* 160 */ "AggInverse" OpHelp("accum=r[P3] inverse(r[P2@P5])"),
+ /* 161 */ "AggStep" OpHelp("accum=r[P3] step(r[P2@P5])"),
+ /* 162 */ "AggStep1" OpHelp("accum=r[P3] step(r[P2@P5])"),
+ /* 163 */ "AggValue" OpHelp("r[P3]=value N=P2"),
+ /* 164 */ "AggFinal" OpHelp("accum=r[P1] N=P2"),
+ /* 165 */ "Expire" OpHelp(""),
+ /* 166 */ "CursorLock" OpHelp(""),
+ /* 167 */ "CursorUnlock" OpHelp(""),
+ /* 168 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"),
+ /* 169 */ "VBegin" OpHelp(""),
+ /* 170 */ "VCreate" OpHelp(""),
+ /* 171 */ "VDestroy" OpHelp(""),
+ /* 172 */ "VOpen" OpHelp(""),
+ /* 173 */ "VInitIn" OpHelp("r[P2]=ValueList(P1,P3)"),
+ /* 174 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"),
+ /* 175 */ "VRename" OpHelp(""),
+ /* 176 */ "Pagecount" OpHelp(""),
+ /* 177 */ "MaxPgcnt" OpHelp(""),
+ /* 178 */ "FilterAdd" OpHelp("filter(P1) += key(P3@P4)"),
+ /* 179 */ "Trace" OpHelp(""),
+ /* 180 */ "CursorHint" OpHelp(""),
+ /* 181 */ "ReleaseReg" OpHelp("release r[P1@P2] mask P3"),
+ /* 182 */ "Noop" OpHelp(""),
+ /* 183 */ "Explain" OpHelp(""),
+ /* 184 */ "Abortable" OpHelp(""),
};
return azName[i];
}
@@ -50356,7 +50903,8 @@ SQLITE_PRIVATE void sqlite3PcacheDrop(PgHdr *p){
** make it so.
*/
SQLITE_PRIVATE void sqlite3PcacheMakeDirty(PgHdr *p){
- assert( p->nRef>0 );
+ assert( p->nRef>0 || p->pCache->bPurgeable==0 );
+ testcase( p->nRef==0 );
assert( sqlite3PcachePageSanity(p) );
if( p->flags & (PGHDR_CLEAN|PGHDR_DONT_WRITE) ){ /*OPTIMIZATION-IF-FALSE*/
p->flags &= ~PGHDR_DONT_WRITE;
@@ -55488,6 +56036,9 @@ static int pager_playback(Pager *pPager, int isHot){
goto end_playback;
}
pPager->dbSize = mxPg;
+ if( pPager->mxPgno<mxPg ){
+ pPager->mxPgno = mxPg;
+ }
}
/* Copy original pages out of the journal and back into the
@@ -56544,8 +57095,7 @@ static int pager_wait_on_lock(Pager *pPager, int locktype){
** current database image, in pages, OR
**
** b) if the page content were written at this time, it would not
-** be necessary to write the current content out to the sub-journal
-** (as determined by function subjRequiresPage()).
+** be necessary to write the current content out to the sub-journal.
**
** If the condition asserted by this function were not true, and the
** dirty page were to be discarded from the cache via the pagerStress()
@@ -56560,8 +57110,16 @@ static int pager_wait_on_lock(Pager *pPager, int locktype){
*/
#if defined(SQLITE_DEBUG)
static void assertTruncateConstraintCb(PgHdr *pPg){
+ Pager *pPager = pPg->pPager;
assert( pPg->flags&PGHDR_DIRTY );
- assert( !subjRequiresPage(pPg) || pPg->pgno<=pPg->pPager->dbSize );
+ if( pPg->pgno>pPager->dbSize ){ /* if (a) is false */
+ Pgno pgno = pPg->pgno;
+ int i;
+ for(i=0; i<pPg->pPager->nSavepoint; i++){
+ PagerSavepoint *p = &pPager->aSavepoint[i];
+ assert( p->nOrig<pgno || sqlite3BitvecTestNotNull(p->pInSavepoint,pgno) );
+ }
+ }
}
static void assertTruncateConstraint(Pager *pPager){
sqlite3PcacheIterateDirty(pPager->pPCache, assertTruncateConstraintCb);
@@ -56583,7 +57141,6 @@ static void assertTruncateConstraint(Pager *pPager){
*/
SQLITE_PRIVATE void sqlite3PagerTruncateImage(Pager *pPager, Pgno nPage){
assert( pPager->dbSize>=nPage || CORRUPT_DB );
- testcase( pPager->dbSize<nPage );
assert( pPager->eState>=PAGER_WRITER_CACHEMOD );
pPager->dbSize = nPage;
@@ -57902,7 +58459,7 @@ SQLITE_PRIVATE int sqlite3PagerSharedLock(Pager *pPager){
** may mean that the pager was in the error-state when this
** function was called and the journal file does not exist.
*/
- if( !isOpen(pPager->jfd) ){
+ if( !isOpen(pPager->jfd) && pPager->journalMode!=PAGER_JOURNALMODE_OFF ){
sqlite3_vfs * const pVfs = pPager->pVfs;
int bExists; /* True if journal file exists */
rc = sqlite3OsAccess(
@@ -58304,6 +58861,7 @@ SQLITE_PRIVATE int sqlite3PagerGet(
DbPage **ppPage, /* Write a pointer to the page here */
int flags /* PAGER_GET_XXX flags */
){
+ /* printf("PAGE %u\n", pgno); fflush(stdout); */
return pPager->xGet(pPager, pgno, ppPage, flags);
}
@@ -59909,12 +60467,12 @@ SQLITE_PRIVATE int sqlite3PagerSetJournalMode(Pager *pPager, int eMode){
u8 eOld = pPager->journalMode; /* Prior journalmode */
/* The eMode parameter is always valid */
- assert( eMode==PAGER_JOURNALMODE_DELETE
- || eMode==PAGER_JOURNALMODE_TRUNCATE
- || eMode==PAGER_JOURNALMODE_PERSIST
- || eMode==PAGER_JOURNALMODE_OFF
- || eMode==PAGER_JOURNALMODE_WAL
- || eMode==PAGER_JOURNALMODE_MEMORY );
+ assert( eMode==PAGER_JOURNALMODE_DELETE /* 0 */
+ || eMode==PAGER_JOURNALMODE_PERSIST /* 1 */
+ || eMode==PAGER_JOURNALMODE_OFF /* 2 */
+ || eMode==PAGER_JOURNALMODE_TRUNCATE /* 3 */
+ || eMode==PAGER_JOURNALMODE_MEMORY /* 4 */
+ || eMode==PAGER_JOURNALMODE_WAL /* 5 */ );
/* This routine is only called from the OP_JournalMode opcode, and
** the logic there will never allow a temporary file to be changed
@@ -59951,7 +60509,6 @@ SQLITE_PRIVATE int sqlite3PagerSetJournalMode(Pager *pPager, int eMode){
assert( isOpen(pPager->fd) || pPager->exclusiveMode );
if( !pPager->exclusiveMode && (eOld & 5)==1 && (eMode & 1)==0 ){
-
/* In this case we would like to delete the journal file. If it is
** not possible, then that is not a problem. Deleting the journal file
** here is an optimization only.
@@ -60063,6 +60620,18 @@ SQLITE_PRIVATE int sqlite3PagerCheckpoint(
int *pnCkpt /* OUT: Final number of checkpointed frames */
){
int rc = SQLITE_OK;
+ if( pPager->pWal==0 && pPager->journalMode==PAGER_JOURNALMODE_WAL ){
+ /* This only happens when a database file is zero bytes in size opened and
+ ** then "PRAGMA journal_mode=WAL" is run and then sqlite3_wal_checkpoint()
+ ** is invoked without any intervening transactions. We need to start
+ ** a transaction to initialize pWal. The PRAGMA table_list statement is
+ ** used for this since it starts transactions on every database file,
+ ** including all ATTACHed databases. This seems expensive for a single
+ ** sqlite3_wal_checkpoint() call, but it happens very rarely.
+ ** https://sqlite.org/forum/forumpost/fd0f19d229156939
+ */
+ sqlite3_exec(db, "PRAGMA table_list",0,0,0);
+ }
if( pPager->pWal ){
rc = sqlite3WalCheckpoint(pPager->pWal, db, eMode,
(eMode==SQLITE_CHECKPOINT_PASSIVE ? 0 : pPager->xBusyHandler),
@@ -62962,7 +63531,9 @@ static int walBeginShmUnreliable(Wal *pWal, int *pChanged){
}
/* Allocate a buffer to read frames into */
- szFrame = pWal->hdr.szPage + WAL_FRAME_HDRSIZE;
+ assert( (pWal->szPage & (pWal->szPage-1))==0 );
+ assert( pWal->szPage>=512 && pWal->szPage<=65536 );
+ szFrame = pWal->szPage + WAL_FRAME_HDRSIZE;
aFrame = (u8 *)sqlite3_malloc64(szFrame);
if( aFrame==0 ){
rc = SQLITE_NOMEM_BKPT;
@@ -62976,7 +63547,7 @@ static int walBeginShmUnreliable(Wal *pWal, int *pChanged){
** the caller. */
aSaveCksum[0] = pWal->hdr.aFrameCksum[0];
aSaveCksum[1] = pWal->hdr.aFrameCksum[1];
- for(iOffset=walFrameOffset(pWal->hdr.mxFrame+1, pWal->hdr.szPage);
+ for(iOffset=walFrameOffset(pWal->hdr.mxFrame+1, pWal->szPage);
iOffset+szFrame<=szWal;
iOffset+=szFrame
){
@@ -64827,7 +65398,9 @@ struct MemPage {
u8 *apOvfl[4]; /* Pointers to the body of overflow cells */
BtShared *pBt; /* Pointer to BtShared that this page is part of */
u8 *aData; /* Pointer to disk image of the page data */
- u8 *aDataEnd; /* One byte past the end of usable data */
+ u8 *aDataEnd; /* One byte past the end of the entire page - not just
+ ** the usable space, the entire page. Used to prevent
+ ** corruption-induced of buffer overflow. */
u8 *aCellIdx; /* The cell index area */
u8 *aDataOfst; /* Same as aData for leaves. aData+4 for interior */
DbPage *pDbPage; /* Pager page handle */
@@ -66784,18 +67357,32 @@ static void btreeParseCellPtr(
**
** pIter += getVarint(pIter, (u64*)&pInfo->nKey);
**
- ** The code is inlined to avoid a function call.
+ ** The code is inlined and the loop is unrolled for performance.
+ ** This routine is a high-runner.
*/
iKey = *pIter;
if( iKey>=0x80 ){
- u8 *pEnd = &pIter[7];
- iKey &= 0x7f;
- while(1){
- iKey = (iKey<<7) | (*++pIter & 0x7f);
- if( (*pIter)<0x80 ) break;
- if( pIter>=pEnd ){
- iKey = (iKey<<8) | *++pIter;
- break;
+ u8 x;
+ iKey = ((iKey&0x7f)<<7) | ((x = *++pIter) & 0x7f);
+ if( x>=0x80 ){
+ iKey = (iKey<<7) | ((x =*++pIter) & 0x7f);
+ if( x>=0x80 ){
+ iKey = (iKey<<7) | ((x = *++pIter) & 0x7f);
+ if( x>=0x80 ){
+ iKey = (iKey<<7) | ((x = *++pIter) & 0x7f);
+ if( x>=0x80 ){
+ iKey = (iKey<<7) | ((x = *++pIter) & 0x7f);
+ if( x>=0x80 ){
+ iKey = (iKey<<7) | ((x = *++pIter) & 0x7f);
+ if( x>=0x80 ){
+ iKey = (iKey<<7) | ((x = *++pIter) & 0x7f);
+ if( x>=0x80 ){
+ iKey = (iKey<<8) | (*++pIter);
+ }
+ }
+ }
+ }
+ }
}
}
}
@@ -66805,7 +67392,7 @@ static void btreeParseCellPtr(
pInfo->nPayload = nPayload;
pInfo->pPayload = pIter;
testcase( nPayload==pPage->maxLocal );
- testcase( nPayload==pPage->maxLocal+1 );
+ testcase( nPayload==(u32)pPage->maxLocal+1 );
if( nPayload<=pPage->maxLocal ){
/* This is the (easy) common case where the entire payload fits
** on the local page. No overflow is required.
@@ -66842,7 +67429,7 @@ static void btreeParseCellPtrIndex(
pInfo->nPayload = nPayload;
pInfo->pPayload = pIter;
testcase( nPayload==pPage->maxLocal );
- testcase( nPayload==pPage->maxLocal+1 );
+ testcase( nPayload==(u32)pPage->maxLocal+1 );
if( nPayload<=pPage->maxLocal ){
/* This is the (easy) common case where the entire payload fits
** on the local page. No overflow is required.
@@ -66905,7 +67492,7 @@ static u16 cellSizePtr(MemPage *pPage, u8 *pCell){
while( (*pIter++)&0x80 && pIter<pEnd );
}
testcase( nSize==pPage->maxLocal );
- testcase( nSize==pPage->maxLocal+1 );
+ testcase( nSize==(u32)pPage->maxLocal+1 );
if( nSize<=pPage->maxLocal ){
nSize += (u32)(pIter - pCell);
if( nSize<4 ) nSize = 4;
@@ -66913,7 +67500,7 @@ static u16 cellSizePtr(MemPage *pPage, u8 *pCell){
int minLocal = pPage->minLocal;
nSize = minLocal + (nSize - minLocal) % (pPage->pBt->usableSize - 4);
testcase( nSize==pPage->maxLocal );
- testcase( nSize==pPage->maxLocal+1 );
+ testcase( nSize==(u32)pPage->maxLocal+1 );
if( nSize>pPage->maxLocal ){
nSize = minLocal;
}
@@ -67327,7 +67914,7 @@ static int freeSpace(MemPage *pPage, u16 iStart, u16 iSize){
if( iFreeBlk>pPage->pBt->usableSize-4 ){ /* TH3: corrupt081.100 */
return SQLITE_CORRUPT_PAGE(pPage);
}
- assert( iFreeBlk>iPtr || iFreeBlk==0 );
+ assert( iFreeBlk>iPtr || iFreeBlk==0 || CORRUPT_DB );
/* At this point:
** iFreeBlk: First freeblock after iStart, or zero if none
@@ -67598,7 +68185,7 @@ static int btreeInitPage(MemPage *pPage){
pPage->nOverflow = 0;
pPage->cellOffset = pPage->hdrOffset + 8 + pPage->childPtrSize;
pPage->aCellIdx = data + pPage->childPtrSize + 8;
- pPage->aDataEnd = pPage->aData + pBt->usableSize;
+ pPage->aDataEnd = pPage->aData + pBt->pageSize;
pPage->aDataOfst = pPage->aData + pPage->childPtrSize;
/* EVIDENCE-OF: R-37002-32774 The two-byte integer at offset 3 gives the
** number of cells on the page. */
@@ -67633,7 +68220,7 @@ static void zeroPage(MemPage *pPage, int flags){
u8 hdr = pPage->hdrOffset;
u16 first;
- assert( sqlite3PagerPagenumber(pPage->pDbPage)==pPage->pgno );
+ assert( sqlite3PagerPagenumber(pPage->pDbPage)==pPage->pgno || CORRUPT_DB );
assert( sqlite3PagerGetExtra(pPage->pDbPage) == (void*)pPage );
assert( sqlite3PagerGetData(pPage->pDbPage) == data );
assert( sqlite3PagerIswriteable(pPage->pDbPage) );
@@ -67649,7 +68236,7 @@ static void zeroPage(MemPage *pPage, int flags){
pPage->nFree = (u16)(pBt->usableSize - first);
decodeFlags(pPage, flags);
pPage->cellOffset = first;
- pPage->aDataEnd = &data[pBt->usableSize];
+ pPage->aDataEnd = &data[pBt->pageSize];
pPage->aCellIdx = &data[first];
pPage->aDataOfst = &data[pPage->childPtrSize];
pPage->nOverflow = 0;
@@ -67775,7 +68362,7 @@ static int getAndInitPage(
goto getAndInitPage_error2;
}
}
- assert( (*ppPage)->pgno==pgno );
+ assert( (*ppPage)->pgno==pgno || CORRUPT_DB );
assert( (*ppPage)->aData==sqlite3PagerGetData(pDbPage) );
/* If obtaining a child page for a cursor, we must verify that the page is
@@ -68252,30 +68839,38 @@ static int removeFromSharingList(BtShared *pBt){
** MX_CELL_SIZE(pBt) bytes with a 4-byte prefix for a left-child
** pointer.
*/
-static void allocateTempSpace(BtShared *pBt){
- if( !pBt->pTmpSpace ){
- pBt->pTmpSpace = sqlite3PageMalloc( pBt->pageSize );
-
- /* One of the uses of pBt->pTmpSpace is to format cells before
- ** inserting them into a leaf page (function fillInCell()). If
- ** a cell is less than 4 bytes in size, it is rounded up to 4 bytes
- ** by the various routines that manipulate binary cells. Which
- ** can mean that fillInCell() only initializes the first 2 or 3
- ** bytes of pTmpSpace, but that the first 4 bytes are copied from
- ** it into a database page. This is not actually a problem, but it
- ** does cause a valgrind error when the 1 or 2 bytes of unitialized
- ** data is passed to system call write(). So to avoid this error,
- ** zero the first 4 bytes of temp space here.
- **
- ** Also: Provide four bytes of initialized space before the
- ** beginning of pTmpSpace as an area available to prepend the
- ** left-child pointer to the beginning of a cell.
- */
- if( pBt->pTmpSpace ){
- memset(pBt->pTmpSpace, 0, 8);
- pBt->pTmpSpace += 4;
- }
+static SQLITE_NOINLINE int allocateTempSpace(BtShared *pBt){
+ assert( pBt!=0 );
+ assert( pBt->pTmpSpace==0 );
+ /* This routine is called only by btreeCursor() when allocating the
+ ** first write cursor for the BtShared object */
+ assert( pBt->pCursor!=0 && (pBt->pCursor->curFlags & BTCF_WriteFlag)!=0 );
+ pBt->pTmpSpace = sqlite3PageMalloc( pBt->pageSize );
+ if( pBt->pTmpSpace==0 ){
+ BtCursor *pCur = pBt->pCursor;
+ pBt->pCursor = pCur->pNext; /* Unlink the cursor */
+ memset(pCur, 0, sizeof(*pCur));
+ return SQLITE_NOMEM_BKPT;
}
+
+ /* One of the uses of pBt->pTmpSpace is to format cells before
+ ** inserting them into a leaf page (function fillInCell()). If
+ ** a cell is less than 4 bytes in size, it is rounded up to 4 bytes
+ ** by the various routines that manipulate binary cells. Which
+ ** can mean that fillInCell() only initializes the first 2 or 3
+ ** bytes of pTmpSpace, but that the first 4 bytes are copied from
+ ** it into a database page. This is not actually a problem, but it
+ ** does cause a valgrind error when the 1 or 2 bytes of unitialized
+ ** data is passed to system call write(). So to avoid this error,
+ ** zero the first 4 bytes of temp space here.
+ **
+ ** Also: Provide four bytes of initialized space before the
+ ** beginning of pTmpSpace as an area available to prepend the
+ ** left-child pointer to the beginning of a cell.
+ */
+ memset(pBt->pTmpSpace, 0, 8);
+ pBt->pTmpSpace += 4;
+ return SQLITE_OK;
}
/*
@@ -68772,9 +69367,13 @@ static int lockBtree(BtShared *pBt){
pageSize-usableSize);
return rc;
}
- if( sqlite3WritableSchema(pBt->db)==0 && nPage>nPageFile ){
- rc = SQLITE_CORRUPT_BKPT;
- goto page1_init_failed;
+ if( nPage>nPageFile ){
+ if( sqlite3WritableSchema(pBt->db)==0 ){
+ rc = SQLITE_CORRUPT_BKPT;
+ goto page1_init_failed;
+ }else{
+ nPage = nPageFile;
+ }
}
/* EVIDENCE-OF: R-28312-64704 However, the usable size is not allowed to
** be less than 480. In other words, if the page size is 512, then the
@@ -69804,7 +70403,7 @@ static void btreeSetNPage(BtShared *pBt, MemPage *pPage1){
int nPage = get4byte(&pPage1->aData[28]);
testcase( nPage==0 );
if( nPage==0 ) sqlite3PagerPagecount(pBt->pPager, &nPage);
- testcase( pBt->nPage!=nPage );
+ testcase( pBt->nPage!=(u32)nPage );
pBt->nPage = nPage;
}
@@ -70016,10 +70615,6 @@ static int btreeCursor(
assert( pBt->pPage1 && pBt->pPage1->aData );
assert( wrFlag==0 || (pBt->btsFlags & BTS_READ_ONLY)==0 );
- if( wrFlag ){
- allocateTempSpace(pBt);
- if( pBt->pTmpSpace==0 ) return SQLITE_NOMEM_BKPT;
- }
if( iTable<=1 ){
if( iTable<1 ){
return SQLITE_CORRUPT_BKPT;
@@ -70036,19 +70631,25 @@ static int btreeCursor(
pCur->pKeyInfo = pKeyInfo;
pCur->pBtree = p;
pCur->pBt = pBt;
- pCur->curFlags = wrFlag ? BTCF_WriteFlag : 0;
- pCur->curPagerFlags = wrFlag ? 0 : PAGER_GET_READONLY;
+ pCur->curFlags = 0;
/* If there are two or more cursors on the same btree, then all such
** cursors *must* have the BTCF_Multiple flag set. */
for(pX=pBt->pCursor; pX; pX=pX->pNext){
if( pX->pgnoRoot==iTable ){
pX->curFlags |= BTCF_Multiple;
- pCur->curFlags |= BTCF_Multiple;
+ pCur->curFlags = BTCF_Multiple;
}
}
+ pCur->eState = CURSOR_INVALID;
pCur->pNext = pBt->pCursor;
pBt->pCursor = pCur;
- pCur->eState = CURSOR_INVALID;
+ if( wrFlag ){
+ pCur->curFlags |= BTCF_WriteFlag;
+ pCur->curPagerFlags = 0;
+ if( pBt->pTmpSpace==0 ) return allocateTempSpace(pBt);
+ }else{
+ pCur->curPagerFlags = PAGER_GET_READONLY;
+ }
return SQLITE_OK;
}
static int btreeCursorWithLock(
@@ -70823,7 +71424,7 @@ static int moveToRoot(BtCursor *pCur){
while( --pCur->iPage ){
releasePageNotNull(pCur->apPage[pCur->iPage]);
}
- pCur->pPage = pCur->apPage[0];
+ pRoot = pCur->pPage = pCur->apPage[0];
goto skip_init;
}
}else if( pCur->pgnoRoot==0 ){
@@ -70848,7 +71449,7 @@ static int moveToRoot(BtCursor *pCur){
pCur->curIntKey = pCur->pPage->intKey;
}
pRoot = pCur->pPage;
- assert( pRoot->pgno==pCur->pgnoRoot );
+ assert( pRoot->pgno==pCur->pgnoRoot || CORRUPT_DB );
/* If pCur->pKeyInfo is not NULL, then the caller that opened this cursor
** expected to open it on an index b-tree. Otherwise, if pKeyInfo is
@@ -70870,7 +71471,6 @@ skip_init:
pCur->info.nSize = 0;
pCur->curFlags &= ~(BTCF_AtLast|BTCF_ValidNKey|BTCF_ValidOvfl);
- pRoot = pCur->pPage;
if( pRoot->nCell>0 ){
pCur->eState = CURSOR_VALID;
}else if( !pRoot->leaf ){
@@ -71111,7 +71711,6 @@ SQLITE_PRIVATE int sqlite3BtreeTableMoveto(
upr = pPage->nCell-1;
assert( biasRight==0 || biasRight==1 );
idx = upr>>(1-biasRight); /* idx = biasRight ? upr : (lwr+upr)/2; */
- pCur->ix = (u16)idx;
for(;;){
i64 nCellKey;
pCell = findCellPastPtr(pPage, idx);
@@ -71253,7 +71852,6 @@ SQLITE_PRIVATE int sqlite3BtreeIndexMoveto(
lwr = 0;
upr = pPage->nCell-1;
idx = upr>>1; /* idx = (lwr+upr)/2; */
- pCur->ix = (u16)idx;
for(;;){
int nCell; /* Size of the pCell cell in bytes */
pCell = findCellPastPtr(pPage, idx);
@@ -71945,7 +72543,7 @@ static int freePage2(BtShared *pBt, MemPage *pMemPage, Pgno iPage){
assert( CORRUPT_DB || iPage>1 );
assert( !pMemPage || pMemPage->pgno==iPage );
- if( NEVER(iPage<2) || iPage>pBt->nPage ){
+ if( iPage<2 || iPage>pBt->nPage ){
return SQLITE_CORRUPT_BKPT;
}
if( pMemPage ){
@@ -72369,16 +72967,24 @@ static void dropCell(MemPage *pPage, int idx, int sz, int *pRC){
int hdr; /* Beginning of the header. 0 most pages. 100 page 1 */
if( *pRC ) return;
- assert( idx>=0 && idx<pPage->nCell );
+ assert( idx>=0 );
+ assert( idx<pPage->nCell );
assert( CORRUPT_DB || sz==cellSize(pPage, idx) );
assert( sqlite3PagerIswriteable(pPage->pDbPage) );
assert( sqlite3_mutex_held(pPage->pBt->mutex) );
assert( pPage->nFree>=0 );
data = pPage->aData;
ptr = &pPage->aCellIdx[2*idx];
+ assert( pPage->pBt->usableSize > (u32)(ptr-data) );
pc = get2byte(ptr);
hdr = pPage->hdrOffset;
- testcase( pc==get2byte(&data[hdr+5]) );
+#if 0 /* Not required. Omit for efficiency */
+ if( pc<hdr+pPage->nCell*2 ){
+ *pRC = SQLITE_CORRUPT_BKPT;
+ return;
+ }
+#endif
+ testcase( pc==(u32)get2byte(&data[hdr+5]) );
testcase( pc+sz==pPage->pBt->usableSize );
if( pc+sz > pPage->pBt->usableSize ){
*pRC = SQLITE_CORRUPT_BKPT;
@@ -72670,7 +73276,7 @@ static int rebuildPage(
assert( i<iEnd );
j = get2byte(&aData[hdr+5]);
- if( NEVER(j>(u32)usableSize) ){ j = 0; }
+ if( j>(u32)usableSize ){ j = 0; }
memcpy(&pTmp[j], &aData[j], usableSize - j);
for(k=0; pCArray->ixNx[k]<=i && ALWAYS(k<NB*2); k++){}
@@ -72901,7 +73507,7 @@ static int editPage(
pData = &aData[get2byteNotZero(&aData[hdr+5])];
if( pData<pBegin ) goto editpage_fail;
- if( NEVER(pData>pPg->aDataEnd) ) goto editpage_fail;
+ if( pData>pPg->aDataEnd ) goto editpage_fail;
/* Add cells to the start of the page */
if( iNew<iOld ){
@@ -74511,7 +75117,7 @@ SQLITE_PRIVATE int sqlite3BtreeInsert(
assert( pPage->intKey || pX->nKey>=0 || (flags & BTREE_PREFORMAT) );
assert( pPage->leaf || !pPage->intKey );
if( pPage->nFree<0 ){
- if( NEVER(pCur->eState>CURSOR_INVALID) ){
+ if( pCur->eState>CURSOR_INVALID ){
rc = SQLITE_CORRUPT_BKPT;
}else{
rc = btreeComputeFreeSpace(pPage);
@@ -74777,14 +75383,13 @@ SQLITE_PRIVATE int sqlite3BtreeTransferRow(BtCursor *pDest, BtCursor *pSrc, i64
SQLITE_PRIVATE int sqlite3BtreeDelete(BtCursor *pCur, u8 flags){
Btree *p = pCur->pBtree;
BtShared *pBt = p->pBt;
- int rc; /* Return code */
- MemPage *pPage; /* Page to delete cell from */
- unsigned char *pCell; /* Pointer to cell to delete */
- int iCellIdx; /* Index of cell to delete */
- int iCellDepth; /* Depth of node containing pCell */
- CellInfo info; /* Size of the cell being deleted */
- int bSkipnext = 0; /* Leaf cursor in SKIPNEXT state */
- u8 bPreserve = flags & BTREE_SAVEPOSITION; /* Keep cursor valid */
+ int rc; /* Return code */
+ MemPage *pPage; /* Page to delete cell from */
+ unsigned char *pCell; /* Pointer to cell to delete */
+ int iCellIdx; /* Index of cell to delete */
+ int iCellDepth; /* Depth of node containing pCell */
+ CellInfo info; /* Size of the cell being deleted */
+ u8 bPreserve; /* Keep cursor valid. 2 for CURSOR_SKIPNEXT */
assert( cursorOwnsBtShared(pCur) );
assert( pBt->inTransaction==TRANS_WRITE );
@@ -74803,18 +75408,31 @@ SQLITE_PRIVATE int sqlite3BtreeDelete(BtCursor *pCur, u8 flags){
iCellDepth = pCur->iPage;
iCellIdx = pCur->ix;
pPage = pCur->pPage;
+ if( pPage->nCell<=iCellIdx ){
+ return SQLITE_CORRUPT_BKPT;
+ }
pCell = findCell(pPage, iCellIdx);
- if( pPage->nFree<0 && btreeComputeFreeSpace(pPage) ) return SQLITE_CORRUPT;
+ if( pPage->nFree<0 && btreeComputeFreeSpace(pPage) ){
+ return SQLITE_CORRUPT_BKPT;
+ }
- /* If the bPreserve flag is set to true, then the cursor position must
+ /* If the BTREE_SAVEPOSITION bit is on, then the cursor position must
** be preserved following this delete operation. If the current delete
** will cause a b-tree rebalance, then this is done by saving the cursor
** key and leaving the cursor in CURSOR_REQUIRESEEK state before
** returning.
**
- ** Or, if the current delete will not cause a rebalance, then the cursor
+ ** If the current delete will not cause a rebalance, then the cursor
** will be left in CURSOR_SKIPNEXT state pointing to the entry immediately
- ** before or after the deleted entry. In this case set bSkipnext to true. */
+ ** before or after the deleted entry.
+ **
+ ** The bPreserve value records which path is required:
+ **
+ ** bPreserve==0 Not necessary to save the cursor position
+ ** bPreserve==1 Use CURSOR_REQUIRESEEK to save the cursor position
+ ** bPreserve==2 Cursor won't move. Set CURSOR_SKIPNEXT.
+ */
+ bPreserve = (flags & BTREE_SAVEPOSITION)!=0;
if( bPreserve ){
if( !pPage->leaf
|| (pPage->nFree+cellSizePtr(pPage,pCell)+2)>(int)(pBt->usableSize*2/3)
@@ -74825,7 +75443,7 @@ SQLITE_PRIVATE int sqlite3BtreeDelete(BtCursor *pCur, u8 flags){
rc = saveCursorKey(pCur);
if( rc ) return rc;
}else{
- bSkipnext = 1;
+ bPreserve = 2;
}
}
@@ -74925,8 +75543,8 @@ SQLITE_PRIVATE int sqlite3BtreeDelete(BtCursor *pCur, u8 flags){
}
if( rc==SQLITE_OK ){
- if( bSkipnext ){
- assert( bPreserve && (pCur->iPage==iCellDepth || CORRUPT_DB) );
+ if( bPreserve>1 ){
+ assert( (pCur->iPage==iCellDepth || CORRUPT_DB) );
assert( pPage==pCur->pPage || CORRUPT_DB );
assert( (pPage->nCell>0 || CORRUPT_DB) && iCellIdx<=pPage->nCell );
pCur->eState = CURSOR_SKIPNEXT;
@@ -75136,7 +75754,7 @@ static int clearDatabasePage(
rc = getAndInitPage(pBt, pgno, &pPage, 0, 0);
if( rc ) return rc;
if( (pBt->openFlags & BTREE_SINGLE)==0
- && sqlite3PagerPageRefcount(pPage->pDbPage)!=1
+ && sqlite3PagerPageRefcount(pPage->pDbPage) != (1 + (pgno==1))
){
rc = SQLITE_CORRUPT_BKPT;
goto cleardatabasepage_out;
@@ -76516,14 +77134,13 @@ static Btree *findBtree(sqlite3 *pErrorDb, sqlite3 *pDb, const char *zDb){
if( i==1 ){
Parse sParse;
int rc = 0;
- memset(&sParse, 0, sizeof(sParse));
- sParse.db = pDb;
+ sqlite3ParseObjectInit(&sParse,pDb);
if( sqlite3OpenTempDatabase(&sParse) ){
sqlite3ErrorWithMsg(pErrorDb, sParse.rc, "%s", sParse.zErrMsg);
rc = SQLITE_ERROR;
}
sqlite3DbFree(pErrorDb, sParse.zErrMsg);
- sqlite3ParserReset(&sParse);
+ sqlite3ParseObjectReset(&sParse);
if( rc ){
return 0;
}
@@ -77801,12 +78418,12 @@ static SQLITE_NOINLINE i64 doubleToInt64(double r){
**
** If pMem represents a string value, its encoding might be changed.
*/
-static SQLITE_NOINLINE i64 memIntValue(Mem *pMem){
+static SQLITE_NOINLINE i64 memIntValue(const Mem *pMem){
i64 value = 0;
sqlite3Atoi64(pMem->z, &value, pMem->n, pMem->enc);
return value;
}
-SQLITE_PRIVATE i64 sqlite3VdbeIntValue(Mem *pMem){
+SQLITE_PRIVATE i64 sqlite3VdbeIntValue(const Mem *pMem){
int flags;
assert( pMem!=0 );
assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
@@ -78121,6 +78738,7 @@ SQLITE_PRIVATE void sqlite3VdbeMemSetPointer(
void (*xDestructor)(void*)
){
assert( pMem->flags==MEM_Null );
+ vdbeMemClear(pMem);
pMem->u.zPType = zPType ? zPType : "";
pMem->z = pPtr;
pMem->flags = MEM_Null|MEM_Dyn|MEM_Subtype|MEM_Term;
@@ -78735,11 +79353,7 @@ static int valueFromExpr(
assert( pExpr!=0 );
while( (op = pExpr->op)==TK_UPLUS || op==TK_SPAN ) pExpr = pExpr->pLeft;
-#if defined(SQLITE_ENABLE_STAT4)
if( op==TK_REGISTER ) op = pExpr->op2;
-#else
- if( NEVER(op==TK_REGISTER) ) op = pExpr->op2;
-#endif
/* Compressed expressions only appear when parsing the DEFAULT clause
** on a table column definition, and hence only when pCtx==0. This
@@ -78854,7 +79468,7 @@ static int valueFromExpr(
no_mem:
#ifdef SQLITE_ENABLE_STAT4
- if( pCtx==0 || pCtx->pParse->nErr==0 )
+ if( pCtx==0 || NEVER(pCtx->pParse->nErr==0) )
#endif
sqlite3OomFault(db);
sqlite3DbFree(db, zVal);
@@ -80532,8 +81146,7 @@ SQLITE_PRIVATE void sqlite3VdbeSetP4KeyInfo(Parse *pParse, Index *pIdx){
*/
static void vdbeVComment(Vdbe *p, const char *zFormat, va_list ap){
assert( p->nOp>0 || p->aOp==0 );
- assert( p->aOp==0 || p->aOp[p->nOp-1].zComment==0 || p->db->mallocFailed
- || p->pParse->nErr>0 );
+ assert( p->aOp==0 || p->aOp[p->nOp-1].zComment==0 || p->pParse->nErr>0 );
if( p->nOp ){
assert( p->aOp );
sqlite3DbFree(p->db, p->aOp[p->nOp-1].zComment);
@@ -81624,8 +82237,6 @@ SQLITE_PRIVATE void sqlite3VdbeFreeCursor(Vdbe *p, VdbeCursor *pCx){
if( pCx==0 ){
return;
}
- assert( pCx->pBtx==0 || pCx->eCurType==CURTYPE_BTREE );
- assert( pCx->pBtx==0 || pCx->isEphemeral );
switch( pCx->eCurType ){
case CURTYPE_SORTER: {
sqlite3VdbeSorterClose(p->db, pCx);
@@ -82406,6 +83017,7 @@ SQLITE_PRIVATE int sqlite3VdbeTransferError(Vdbe *p){
sqlite3ValueSetNull(db->pErr);
}
db->errCode = rc;
+ db->errByteOffset = -1;
return rc;
}
@@ -82727,7 +83339,7 @@ SQLITE_PRIVATE int sqlite3VdbeCursorMoveto(VdbeCursor **pp, u32 *piCol){
if( p->deferredMoveto ){
u32 iMap;
assert( !p->isEphemeral );
- if( p->aAltMap && (iMap = p->aAltMap[1+*piCol])>0 && !p->nullRow ){
+ if( p->ub.aAltMap && (iMap = p->ub.aAltMap[1+*piCol])>0 && !p->nullRow ){
*pp = p->pAltCursor;
*piCol = iMap - 1;
return SQLITE_OK;
@@ -83005,14 +83617,14 @@ SQLITE_PRIVATE u32 sqlite3VdbeSerialPut(u8 *buf, Mem *pMem, u32 serial_type){
/*
** Deserialize the data blob pointed to by buf as serial type serial_type
-** and store the result in pMem. Return the number of bytes read.
+** and store the result in pMem.
**
** This function is implemented as two separate routines for performance.
** The few cases that require local variables are broken out into a separate
** routine so that in most cases the overhead of moving the stack pointer
** is avoided.
*/
-static u32 serialGet(
+static void serialGet(
const unsigned char *buf, /* Buffer to deserialize from */
u32 serial_type, /* Serial type to deserialize */
Mem *pMem /* Memory cell to write value into */
@@ -83046,9 +83658,8 @@ static u32 serialGet(
memcpy(&pMem->u.r, &x, sizeof(x));
pMem->flags = IsNaN(x) ? MEM_Null : MEM_Real;
}
- return 8;
}
-SQLITE_PRIVATE u32 sqlite3VdbeSerialGet(
+SQLITE_PRIVATE void sqlite3VdbeSerialGet(
const unsigned char *buf, /* Buffer to deserialize from */
u32 serial_type, /* Serial type to deserialize */
Mem *pMem /* Memory cell to write value into */
@@ -83059,13 +83670,13 @@ SQLITE_PRIVATE u32 sqlite3VdbeSerialGet(
pMem->flags = MEM_Null|MEM_Zero;
pMem->n = 0;
pMem->u.nZero = 0;
- break;
+ return;
}
case 11: /* Reserved for future use */
case 0: { /* Null */
/* EVIDENCE-OF: R-24078-09375 Value is a NULL. */
pMem->flags = MEM_Null;
- break;
+ return;
}
case 1: {
/* EVIDENCE-OF: R-44885-25196 Value is an 8-bit twos-complement
@@ -83073,7 +83684,7 @@ SQLITE_PRIVATE u32 sqlite3VdbeSerialGet(
pMem->u.i = ONE_BYTE_INT(buf);
pMem->flags = MEM_Int;
testcase( pMem->u.i<0 );
- return 1;
+ return;
}
case 2: { /* 2-byte signed integer */
/* EVIDENCE-OF: R-49794-35026 Value is a big-endian 16-bit
@@ -83081,7 +83692,7 @@ SQLITE_PRIVATE u32 sqlite3VdbeSerialGet(
pMem->u.i = TWO_BYTE_INT(buf);
pMem->flags = MEM_Int;
testcase( pMem->u.i<0 );
- return 2;
+ return;
}
case 3: { /* 3-byte signed integer */
/* EVIDENCE-OF: R-37839-54301 Value is a big-endian 24-bit
@@ -83089,7 +83700,7 @@ SQLITE_PRIVATE u32 sqlite3VdbeSerialGet(
pMem->u.i = THREE_BYTE_INT(buf);
pMem->flags = MEM_Int;
testcase( pMem->u.i<0 );
- return 3;
+ return;
}
case 4: { /* 4-byte signed integer */
/* EVIDENCE-OF: R-01849-26079 Value is a big-endian 32-bit
@@ -83101,7 +83712,7 @@ SQLITE_PRIVATE u32 sqlite3VdbeSerialGet(
#endif
pMem->flags = MEM_Int;
testcase( pMem->u.i<0 );
- return 4;
+ return;
}
case 5: { /* 6-byte signed integer */
/* EVIDENCE-OF: R-50385-09674 Value is a big-endian 48-bit
@@ -83109,13 +83720,14 @@ SQLITE_PRIVATE u32 sqlite3VdbeSerialGet(
pMem->u.i = FOUR_BYTE_UINT(buf+2) + (((i64)1)<<32)*TWO_BYTE_INT(buf);
pMem->flags = MEM_Int;
testcase( pMem->u.i<0 );
- return 6;
+ return;
}
case 6: /* 8-byte signed integer */
case 7: { /* IEEE floating point */
/* These use local variables, so do them in a separate routine
** to avoid having to move the frame pointer in the common case */
- return serialGet(buf,serial_type,pMem);
+ serialGet(buf,serial_type,pMem);
+ return;
}
case 8: /* Integer 0 */
case 9: { /* Integer 1 */
@@ -83123,7 +83735,7 @@ SQLITE_PRIVATE u32 sqlite3VdbeSerialGet(
/* EVIDENCE-OF: R-18143-12121 Value is the integer 1. */
pMem->u.i = serial_type-8;
pMem->flags = MEM_Int;
- return 0;
+ return;
}
default: {
/* EVIDENCE-OF: R-14606-31564 Value is a BLOB that is (N-12)/2 bytes in
@@ -83134,10 +83746,10 @@ SQLITE_PRIVATE u32 sqlite3VdbeSerialGet(
pMem->z = (char *)buf;
pMem->n = (serial_type-12)/2;
pMem->flags = aFlag[serial_type&1];
- return pMem->n;
+ return;
}
}
- return 0;
+ return;
}
/*
** This routine is used to allocate sufficient space for an UnpackedRecord
@@ -83200,7 +83812,8 @@ SQLITE_PRIVATE void sqlite3VdbeRecordUnpack(
/* pMem->flags = 0; // sqlite3VdbeSerialGet() will set this for us */
pMem->szMalloc = 0;
pMem->z = 0;
- d += sqlite3VdbeSerialGet(&aKey[d], serial_type, pMem);
+ sqlite3VdbeSerialGet(&aKey[d], serial_type, pMem);
+ d += sqlite3VdbeSerialTypeLen(serial_type);
pMem++;
if( (++u)>=p->nField ) break;
}
@@ -83284,7 +83897,8 @@ static int vdbeRecordCompareDebug(
/* Extract the values to be compared.
*/
- d1 += sqlite3VdbeSerialGet(&aKey1[d1], serial_type1, &mem1);
+ sqlite3VdbeSerialGet(&aKey1[d1], serial_type1, &mem1);
+ d1 += sqlite3VdbeSerialTypeLen(serial_type1);
/* Do the comparison
*/
@@ -84088,7 +84702,7 @@ SQLITE_PRIVATE int sqlite3VdbeIdxRowid(sqlite3 *db, BtCursor *pCur, i64 *rowid){
/* The index entry must begin with a header size */
getVarint32NR((u8*)m.z, szHdr);
testcase( szHdr==3 );
- testcase( szHdr==m.n );
+ testcase( szHdr==(u32)m.n );
testcase( szHdr>0x7fffffff );
assert( m.n>=0 );
if( unlikely(szHdr<3 || szHdr>(unsigned)m.n) ){
@@ -85263,6 +85877,70 @@ SQLITE_API int sqlite3_vtab_nochange(sqlite3_context *p){
}
/*
+** Implementation of sqlite3_vtab_in_first() (if bNext==0) and
+** sqlite3_vtab_in_next() (if bNext!=0).
+*/
+static int valueFromValueList(
+ sqlite3_value *pVal, /* Pointer to the ValueList object */
+ sqlite3_value **ppOut, /* Store the next value from the list here */
+ int bNext /* 1 for _next(). 0 for _first() */
+){
+ int rc;
+ ValueList *pRhs;
+
+ *ppOut = 0;
+ if( pVal==0 ) return SQLITE_MISUSE;
+ pRhs = (ValueList*)sqlite3_value_pointer(pVal, "ValueList");
+ if( pRhs==0 ) return SQLITE_MISUSE;
+ if( bNext ){
+ rc = sqlite3BtreeNext(pRhs->pCsr, 0);
+ }else{
+ int dummy = 0;
+ rc = sqlite3BtreeFirst(pRhs->pCsr, &dummy);
+ assert( rc==SQLITE_OK || sqlite3BtreeEof(pRhs->pCsr) );
+ if( sqlite3BtreeEof(pRhs->pCsr) ) rc = SQLITE_DONE;
+ }
+ if( rc==SQLITE_OK ){
+ u32 sz; /* Size of current row in bytes */
+ Mem sMem; /* Raw content of current row */
+ memset(&sMem, 0, sizeof(sMem));
+ sz = sqlite3BtreePayloadSize(pRhs->pCsr);
+ rc = sqlite3VdbeMemFromBtreeZeroOffset(pRhs->pCsr,(int)sz,&sMem);
+ if( rc==SQLITE_OK ){
+ u8 *zBuf = (u8*)sMem.z;
+ u32 iSerial;
+ sqlite3_value *pOut = pRhs->pOut;
+ int iOff = 1 + getVarint32(&zBuf[1], iSerial);
+ sqlite3VdbeSerialGet(&zBuf[iOff], iSerial, pOut);
+ pOut->enc = ENC(pOut->db);
+ if( (pOut->flags & MEM_Ephem)!=0 && sqlite3VdbeMemMakeWriteable(pOut) ){
+ rc = SQLITE_NOMEM;
+ }else{
+ *ppOut = pOut;
+ }
+ }
+ sqlite3VdbeMemRelease(&sMem);
+ }
+ return rc;
+}
+
+/*
+** Set the iterator value pVal to point to the first value in the set.
+** Set (*ppOut) to point to this value before returning.
+*/
+SQLITE_API int sqlite3_vtab_in_first(sqlite3_value *pVal, sqlite3_value **ppOut){
+ return valueFromValueList(pVal, ppOut, 0);
+}
+
+/*
+** Set the iterator value pVal to point to the next value in the set.
+** Set (*ppOut) to point to this value before returning.
+*/
+SQLITE_API int sqlite3_vtab_in_next(sqlite3_value *pVal, sqlite3_value **ppOut){
+ return valueFromValueList(pVal, ppOut, 1);
+}
+
+/*
** Return the current time for a statement. If the current time
** is requested more than once within the same run of a single prepared
** statement, the exact same time is returned for each invocation regardless
@@ -85946,7 +86624,10 @@ SQLITE_API int sqlite3_bind_value(sqlite3_stmt *pStmt, int i, const sqlite3_valu
break;
}
case SQLITE_FLOAT: {
- rc = sqlite3_bind_double(pStmt, i, pValue->u.r);
+ assert( pValue->flags & (MEM_Real|MEM_IntReal) );
+ rc = sqlite3_bind_double(pStmt, i,
+ (pValue->flags & MEM_Real) ? pValue->u.r : (double)pValue->u.i
+ );
break;
}
case SQLITE_BLOB: {
@@ -86926,7 +87607,6 @@ static VdbeCursor *allocateCursor(
Vdbe *p, /* The virtual machine */
int iCur, /* Index of the new VdbeCursor */
int nField, /* Number of fields in the table or index */
- int iDb, /* Database the cursor belongs to, or -1 */
u8 eCurType /* Type of the new cursor */
){
/* Find the memory cell that will be used to store the blob of memory
@@ -86983,7 +87663,6 @@ static VdbeCursor *allocateCursor(
p->apCsr[iCur] = pCx = (VdbeCursor*)pMem->zMalloc;
memset(pCx, 0, offsetof(VdbeCursor,pAltCursor));
pCx->eCurType = eCurType;
- pCx->iDb = iDb;
pCx->nField = nField;
pCx->aOffset = &pCx->aType[nField];
if( eCurType==CURTYPE_BTREE ){
@@ -87357,6 +88036,29 @@ static Mem *out2Prerelease(Vdbe *p, VdbeOp *pOp){
}
/*
+** Compute a bloom filter hash using pOp->p4.i registers from aMem[] beginning
+** with pOp->p3. Return the hash.
+*/
+static u64 filterHash(const Mem *aMem, const Op *pOp){
+ int i, mx;
+ u64 h = 0;
+
+ assert( pOp->p4type==P4_INT32 );
+ for(i=pOp->p3, mx=i+pOp->p4.i; i<mx; i++){
+ const Mem *p = &aMem[i];
+ if( p->flags & (MEM_Int|MEM_IntReal) ){
+ h += p->u.i;
+ }else if( p->flags & MEM_Real ){
+ h += sqlite3VdbeIntValue(p);
+ }else if( p->flags & (MEM_Str|MEM_Blob) ){
+ h += p->n;
+ if( p->flags & MEM_Zero ) h += p->u.nZero;
+ }
+ }
+ return h;
+}
+
+/*
** Return the symbolic name for the data type of a pMem
*/
static const char *vdbeMemTypeName(Mem *pMem){
@@ -88010,12 +88712,18 @@ case OP_SoftNull: {
** Synopsis: r[P2]=P4 (len=P1)
**
** P4 points to a blob of data P1 bytes long. Store this
-** blob in register P2.
+** blob in register P2. If P4 is a NULL pointer, then construct
+** a zero-filled blob that is P1 bytes long in P2.
*/
case OP_Blob: { /* out2 */
assert( pOp->p1 <= SQLITE_MAX_LENGTH );
pOut = out2Prerelease(p, pOp);
- sqlite3VdbeMemSetStr(pOut, pOp->p4.z, pOp->p1, 0, 0);
+ if( pOp->p4.z==0 ){
+ sqlite3VdbeMemSetZeroBlob(pOut, pOp->p1);
+ if( sqlite3VdbeMemExpandBlob(pOut) ) goto no_mem;
+ }else{
+ sqlite3VdbeMemSetStr(pOut, pOp->p4.z, pOp->p1, 0, 0);
+ }
pOut->enc = encoding;
UPDATE_MAX_BLOBSIZE(pOut);
break;
@@ -88164,24 +88872,22 @@ case OP_IntCopy: { /* out2 */
break;
}
-/* Opcode: ChngCntRow P1 P2 * * *
-** Synopsis: output=r[P1]
+/* Opcode: FkCheck * * * * *
**
-** Output value in register P1 as the chance count for a DML statement,
-** due to the "PRAGMA count_changes=ON" setting. Or, if there was a
-** foreign key error in the statement, trigger the error now.
+** Halt with an SQLITE_CONSTRAINT error if there are any unresolved
+** foreign key constraint violations. If there are no foreign key
+** constraint violations, this is a no-op.
**
-** This opcode is a variant of OP_ResultRow that checks the foreign key
-** immediate constraint count and throws an error if the count is
-** non-zero. The P2 opcode must be 1.
+** FK constraint violations are also checked when the prepared statement
+** exits. This opcode is used to raise foreign key constraint errors prior
+** to returning results such as a row change count or the result of a
+** RETURNING clause.
*/
-case OP_ChngCntRow: {
- assert( pOp->p2==1 );
+case OP_FkCheck: {
if( (rc = sqlite3VdbeCheckFk(p,0))!=SQLITE_OK ){
goto abort_due_to_error;
}
- /* Fall through to the next case, OP_ResultRow */
- /* no break */ deliberate_fall_through
+ break;
}
/* Opcode: ResultRow P1 P2 * * *
@@ -88819,7 +89525,7 @@ case OP_Ge: { /* same as TK_GE, jump, in1, in3 */
sqlite3VdbeMemStringify(pIn1, encoding, 1);
testcase( (flags1&MEM_Dyn) != (pIn1->flags&MEM_Dyn) );
flags1 = (pIn1->flags & ~MEM_TypeMask) | (flags1 & MEM_TypeMask);
- if( NEVER(pIn1==pIn3) ) flags3 = flags1 | MEM_Str;
+ if( pIn1==pIn3 ) flags3 = flags1 | MEM_Str;
}
if( (flags3 & MEM_Str)==0 && (flags3&(MEM_Int|MEM_Real|MEM_IntReal))!=0 ){
testcase( pIn3->flags & MEM_Int );
@@ -89287,10 +89993,18 @@ case OP_Offset: { /* out3 */
assert( pOp->p1>=0 && pOp->p1<p->nCursor );
pC = p->apCsr[pOp->p1];
pOut = &p->aMem[pOp->p3];
- if( NEVER(pC==0) || pC->eCurType!=CURTYPE_BTREE ){
+ if( pC==0 || pC->eCurType!=CURTYPE_BTREE ){
sqlite3VdbeMemSetNull(pOut);
}else{
- sqlite3VdbeMemSetInt64(pOut, sqlite3BtreeOffset(pC->uc.pCursor));
+ if( pC->deferredMoveto ){
+ rc = sqlite3VdbeFinishMoveto(pC);
+ if( rc ) goto abort_due_to_error;
+ }
+ if( sqlite3BtreeEof(pC->uc.pCursor) ){
+ sqlite3VdbeMemSetNull(pOut);
+ }else{
+ sqlite3VdbeMemSetInt64(pOut, sqlite3BtreeOffset(pC->uc.pCursor));
+ }
}
break;
}
@@ -89349,6 +90063,7 @@ case OP_Column: {
assert( pC!=0 );
assert( p2<(u32)pC->nField );
aOffset = pC->aOffset;
+ assert( aOffset==pC->aType+pC->nField );
assert( pC->eCurType!=CURTYPE_VTAB );
assert( pC->eCurType!=CURTYPE_PSEUDO || pC->nullRow );
assert( pC->eCurType!=CURTYPE_SORTER );
@@ -89644,6 +90359,8 @@ case OP_TypeCheck: {
break;
}
case COLTYPE_REAL: {
+ testcase( (pIn1->flags & (MEM_Real|MEM_IntReal))==MEM_Real );
+ testcase( (pIn1->flags & (MEM_Real|MEM_IntReal))==MEM_IntReal );
if( pIn1->flags & MEM_Int ){
/* When applying REAL affinity, if the result is still an MEM_Int
** that will fit in 6 bytes, then change the type to MEM_IntReal
@@ -89661,7 +90378,7 @@ case OP_TypeCheck: {
pIn1->flags |= MEM_Real;
pIn1->flags &= ~MEM_Int;
}
- }else if( (pIn1->flags & MEM_Real)==0 ){
+ }else if( (pIn1->flags & (MEM_Real|MEM_IntReal))==0 ){
goto vdbe_type_error;
}
break;
@@ -89900,7 +90617,7 @@ case OP_MakeRecord: {
testcase( uu==127 ); testcase( uu==128 );
testcase( uu==32767 ); testcase( uu==32768 );
testcase( uu==8388607 ); testcase( uu==8388608 );
- testcase( uu==2147483647 ); testcase( uu==2147483648 );
+ testcase( uu==2147483647 ); testcase( uu==2147483648LL );
testcase( uu==140737488355327LL ); testcase( uu==140737488355328LL );
if( uu<=127 ){
if( (i&1)==i && file_format>=4 ){
@@ -90028,7 +90745,7 @@ case OP_MakeRecord: {
break;
}
-/* Opcode: Count P1 P2 p3 * *
+/* Opcode: Count P1 P2 P3 * *
** Synopsis: r[P2]=count()
**
** Store the number of entries (an integer value) in the table or index
@@ -90498,6 +91215,7 @@ case OP_SetCookie: {
/* When the schema cookie changes, record the new cookie internally */
pDb->pSchema->schema_cookie = pOp->p3 - pOp->p5;
db->mDbFlags |= DBFLAG_SchemaChange;
+ sqlite3FkClearTriggerCache(db, pOp->p1);
}else if( pOp->p2==BTREE_FILE_FORMAT ){
/* Record changes in the file format */
pDb->pSchema->file_format = pOp->p3;
@@ -90675,8 +91393,9 @@ case OP_OpenWrite:
assert( pOp->p1>=0 );
assert( nField>=0 );
testcase( nField==0 ); /* Table with INTEGER PRIMARY KEY and nothing else */
- pCur = allocateCursor(p, pOp->p1, nField, iDb, CURTYPE_BTREE);
+ pCur = allocateCursor(p, pOp->p1, nField, CURTYPE_BTREE);
if( pCur==0 ) goto no_mem;
+ pCur->iDb = iDb;
pCur->nullRow = 1;
pCur->isOrdered = 1;
pCur->pgnoRoot = p2;
@@ -90718,7 +91437,7 @@ case OP_OpenDup: {
assert( pOrig );
assert( pOrig->isEphemeral ); /* Only ephemeral cursors can be duplicated */
- pCx = allocateCursor(p, pOp->p1, pOrig->nField, -1, CURTYPE_BTREE);
+ pCx = allocateCursor(p, pOp->p1, pOrig->nField, CURTYPE_BTREE);
if( pCx==0 ) goto no_mem;
pCx->nullRow = 1;
pCx->isEphemeral = 1;
@@ -90726,10 +91445,10 @@ case OP_OpenDup: {
pCx->isTable = pOrig->isTable;
pCx->pgnoRoot = pOrig->pgnoRoot;
pCx->isOrdered = pOrig->isOrdered;
- pCx->pBtx = pOrig->pBtx;
+ pCx->ub.pBtx = pOrig->ub.pBtx;
pCx->hasBeenDuped = 1;
pOrig->hasBeenDuped = 1;
- rc = sqlite3BtreeCursor(pCx->pBtx, pCx->pgnoRoot, BTREE_WRCSR,
+ rc = sqlite3BtreeCursor(pCx->ub.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
@@ -90802,16 +91521,16 @@ case OP_OpenEphemeral: {
assert( pCx->isEphemeral );
pCx->seqCount = 0;
pCx->cacheStatus = CACHE_STALE;
- rc = sqlite3BtreeClearTable(pCx->pBtx, pCx->pgnoRoot, 0);
+ rc = sqlite3BtreeClearTable(pCx->ub.pBtx, pCx->pgnoRoot, 0);
}else{
- pCx = allocateCursor(p, pOp->p1, pOp->p2, -1, CURTYPE_BTREE);
+ pCx = allocateCursor(p, pOp->p1, pOp->p2, CURTYPE_BTREE);
if( pCx==0 ) goto no_mem;
pCx->isEphemeral = 1;
- rc = sqlite3BtreeOpen(db->pVfs, 0, db, &pCx->pBtx,
+ rc = sqlite3BtreeOpen(db->pVfs, 0, db, &pCx->ub.pBtx,
BTREE_OMIT_JOURNAL | BTREE_SINGLE | pOp->p5,
vfsFlags);
if( rc==SQLITE_OK ){
- rc = sqlite3BtreeBeginTrans(pCx->pBtx, 1, 0);
+ rc = sqlite3BtreeBeginTrans(pCx->ub.pBtx, 1, 0);
if( rc==SQLITE_OK ){
/* If a transient index is required, create it by calling
** sqlite3BtreeCreateTable() with the BTREE_BLOBKEY flag before
@@ -90820,26 +91539,26 @@ case OP_OpenEphemeral: {
*/
if( (pCx->pKeyInfo = pKeyInfo = pOp->p4.pKeyInfo)!=0 ){
assert( pOp->p4type==P4_KEYINFO );
- rc = sqlite3BtreeCreateTable(pCx->pBtx, &pCx->pgnoRoot,
+ rc = sqlite3BtreeCreateTable(pCx->ub.pBtx, &pCx->pgnoRoot,
BTREE_BLOBKEY | pOp->p5);
if( rc==SQLITE_OK ){
assert( pCx->pgnoRoot==SCHEMA_ROOT+1 );
assert( pKeyInfo->db==db );
assert( pKeyInfo->enc==ENC(db) );
- rc = sqlite3BtreeCursor(pCx->pBtx, pCx->pgnoRoot, BTREE_WRCSR,
+ rc = sqlite3BtreeCursor(pCx->ub.pBtx, pCx->pgnoRoot, BTREE_WRCSR,
pKeyInfo, pCx->uc.pCursor);
}
pCx->isTable = 0;
}else{
pCx->pgnoRoot = SCHEMA_ROOT;
- rc = sqlite3BtreeCursor(pCx->pBtx, SCHEMA_ROOT, BTREE_WRCSR,
+ rc = sqlite3BtreeCursor(pCx->ub.pBtx, SCHEMA_ROOT, BTREE_WRCSR,
0, pCx->uc.pCursor);
pCx->isTable = 1;
}
}
pCx->isOrdered = (pOp->p5!=BTREE_UNORDERED);
if( rc ){
- sqlite3BtreeClose(pCx->pBtx);
+ sqlite3BtreeClose(pCx->ub.pBtx);
}
}
}
@@ -90863,7 +91582,7 @@ case OP_SorterOpen: {
assert( pOp->p1>=0 );
assert( pOp->p2>=0 );
- pCx = allocateCursor(p, pOp->p1, pOp->p2, -1, CURTYPE_SORTER);
+ pCx = allocateCursor(p, pOp->p1, pOp->p2, CURTYPE_SORTER);
if( pCx==0 ) goto no_mem;
pCx->pKeyInfo = pOp->p4.pKeyInfo;
assert( pCx->pKeyInfo->db==db );
@@ -90912,7 +91631,7 @@ case OP_OpenPseudo: {
assert( pOp->p1>=0 );
assert( pOp->p3>=0 );
- pCx = allocateCursor(p, pOp->p1, pOp->p3, -1, CURTYPE_PSEUDO);
+ pCx = allocateCursor(p, pOp->p1, pOp->p3, CURTYPE_PSEUDO);
if( pCx==0 ) goto no_mem;
pCx->nullRow = 1;
pCx->seekResult = pOp->p2;
@@ -92364,6 +93083,10 @@ case OP_Rowid: { /* out2 */
** Move the cursor P1 to a null row. Any OP_Column operations
** that occur while the cursor is on the null row will always
** write a NULL.
+**
+** Or, if P1 is a Pseudo-Cursor (a cursor opened using OP_OpenPseudo)
+** just reset the cache for that cursor. This causes the row of
+** content held by the pseudo-cursor to be reparsed.
*/
case OP_NullRow: {
VdbeCursor *pC;
@@ -92852,9 +93575,9 @@ case OP_IdxRowid: { /* out2 */
pTabCur->movetoTarget = rowid;
pTabCur->deferredMoveto = 1;
assert( pOp->p4type==P4_INTARRAY || pOp->p4.ai==0 );
- pTabCur->aAltMap = pOp->p4.ai;
- assert( !pC->isEphemeral );
assert( !pTabCur->isEphemeral );
+ pTabCur->ub.aAltMap = pOp->p4.ai;
+ assert( !pC->isEphemeral );
pTabCur->pAltCursor = pC;
}else{
pOut = out2Prerelease(p, pOp);
@@ -94376,7 +95099,7 @@ case OP_VOpen: {
pVCur->pVtab = pVtab;
/* Initialize vdbe cursor object */
- pCur = allocateCursor(p, pOp->p1, 0, -1, CURTYPE_VTAB);
+ pCur = allocateCursor(p, pOp->p1, 0, CURTYPE_VTAB);
if( pCur ){
pCur->uc.pVCur = pVCur;
pVtab->nRef++;
@@ -94390,6 +95113,34 @@ case OP_VOpen: {
#endif /* SQLITE_OMIT_VIRTUALTABLE */
#ifndef SQLITE_OMIT_VIRTUALTABLE
+/* Opcode: VInitIn P1 P2 P3 * *
+** Synopsis: r[P2]=ValueList(P1,P3)
+**
+** Set register P2 to be a pointer to a ValueList object for cursor P1
+** with cache register P3 and output register P3+1. This ValueList object
+** can be used as the first argument to sqlite3_vtab_in_first() and
+** sqlite3_vtab_in_next() to extract all of the values stored in the P1
+** cursor. Register P3 is used to hold the values returned by
+** sqlite3_vtab_in_first() and sqlite3_vtab_in_next().
+*/
+case OP_VInitIn: { /* out2 */
+ VdbeCursor *pC; /* The cursor containing the RHS values */
+ ValueList *pRhs; /* New ValueList object to put in reg[P2] */
+
+ pC = p->apCsr[pOp->p1];
+ pRhs = sqlite3_malloc64( sizeof(*pRhs) );
+ if( pRhs==0 ) goto no_mem;
+ pRhs->pCsr = pC->uc.pCursor;
+ pRhs->pOut = &aMem[pOp->p3];
+ pOut = out2Prerelease(p, pOp);
+ pOut->flags = MEM_Null;
+ sqlite3VdbeMemSetPointer(pOut, pRhs, "ValueList", sqlite3_free);
+ break;
+}
+#endif /* SQLITE_OMIT_VIRTUALTABLE */
+
+
+#ifndef SQLITE_OMIT_VIRTUALTABLE
/* Opcode: VFilter P1 P2 P3 P4 *
** Synopsis: iplan=r[P3] zplan='P4'
**
@@ -94814,6 +95565,77 @@ case OP_Function: { /* group */
break;
}
+/* Opcode: FilterAdd P1 * P3 P4 *
+** Synopsis: filter(P1) += key(P3@P4)
+**
+** Compute a hash on the P4 registers starting with r[P3] and
+** add that hash to the bloom filter contained in r[P1].
+*/
+case OP_FilterAdd: {
+ u64 h;
+
+ assert( pOp->p1>0 && pOp->p1<=(p->nMem+1 - p->nCursor) );
+ pIn1 = &aMem[pOp->p1];
+ assert( pIn1->flags & MEM_Blob );
+ assert( pIn1->n>0 );
+ h = filterHash(aMem, pOp);
+#ifdef SQLITE_DEBUG
+ if( db->flags&SQLITE_VdbeTrace ){
+ int ii;
+ for(ii=pOp->p3; ii<pOp->p3+pOp->p4.i; ii++){
+ registerTrace(ii, &aMem[ii]);
+ }
+ printf("hash: %llu modulo %d -> %u\n", h, pIn1->n, (int)(h%pIn1->n));
+ }
+#endif
+ h %= pIn1->n;
+ pIn1->z[h/8] |= 1<<(h&7);
+ break;
+}
+
+/* Opcode: Filter P1 P2 P3 P4 *
+** Synopsis: if key(P3@P4) not in filter(P1) goto P2
+**
+** Compute a hash on the key contained in the P4 registers starting
+** with r[P3]. Check to see if that hash is found in the
+** bloom filter hosted by register P1. If it is not present then
+** maybe jump to P2. Otherwise fall through.
+**
+** False negatives are harmless. It is always safe to fall through,
+** even if the value is in the bloom filter. A false negative causes
+** more CPU cycles to be used, but it should still yield the correct
+** answer. However, an incorrect answer may well arise from a
+** false positive - if the jump is taken when it should fall through.
+*/
+case OP_Filter: { /* jump */
+ u64 h;
+
+ assert( pOp->p1>0 && pOp->p1<=(p->nMem+1 - p->nCursor) );
+ pIn1 = &aMem[pOp->p1];
+ assert( (pIn1->flags & MEM_Blob)!=0 );
+ assert( pIn1->n >= 1 );
+ h = filterHash(aMem, pOp);
+#ifdef SQLITE_DEBUG
+ if( db->flags&SQLITE_VdbeTrace ){
+ int ii;
+ for(ii=pOp->p3; ii<pOp->p3+pOp->p4.i; ii++){
+ registerTrace(ii, &aMem[ii]);
+ }
+ printf("hash: %llu modulo %d -> %u\n", h, pIn1->n, (int)(h%pIn1->n));
+ }
+#endif
+ h %= pIn1->n;
+ if( (pIn1->z[h/8] & (1<<(h&7)))==0 ){
+ VdbeBranchTaken(1, 2);
+ p->aCounter[SQLITE_STMTSTATUS_FILTER_HIT]++;
+ goto jump_to_p2;
+ }else{
+ p->aCounter[SQLITE_STMTSTATUS_FILTER_MISS]++;
+ VdbeBranchTaken(0, 2);
+ }
+ break;
+}
+
/* Opcode: Trace P1 P2 * P4 *
**
** Write P4 on the statement trace output if statement tracing is
@@ -95304,10 +96126,9 @@ SQLITE_API int sqlite3_blob_open(
sqlite3_mutex_enter(db->mutex);
pBlob = (Incrblob *)sqlite3DbMallocZero(db, sizeof(Incrblob));
- do {
- memset(&sParse, 0, sizeof(Parse));
+ while(1){
+ sqlite3ParseObjectInit(&sParse,db);
if( !pBlob ) goto blob_open_out;
- sParse.db = db;
sqlite3DbFree(db, zErr);
zErr = 0;
@@ -95484,7 +96305,9 @@ SQLITE_API int sqlite3_blob_open(
goto blob_open_out;
}
rc = blobSeekToRow(pBlob, iRow, &zErr);
- } while( (++nAttempt)<SQLITE_MAX_SCHEMA_RETRY && rc==SQLITE_SCHEMA );
+ if( (++nAttempt)>=SQLITE_MAX_SCHEMA_RETRY || rc!=SQLITE_SCHEMA ) break;
+ sqlite3ParseObjectReset(&sParse);
+ }
blob_open_out:
if( rc==SQLITE_OK && db->mallocFailed==0 ){
@@ -95495,7 +96318,7 @@ blob_open_out:
}
sqlite3ErrorWithMsg(db, rc, (zErr ? "%s" : 0), zErr);
sqlite3DbFree(db, zErr);
- sqlite3ParserReset(&sParse);
+ sqlite3ParseObjectReset(&sParse);
rc = sqlite3ApiExit(db, rc);
sqlite3_mutex_leave(db->mutex);
return rc;
@@ -96630,7 +97453,8 @@ SQLITE_PRIVATE int sqlite3VdbeSorterInit(
}
#endif
- assert( pCsr->pKeyInfo && pCsr->pBtx==0 );
+ assert( pCsr->pKeyInfo );
+ assert( !pCsr->isEphemeral );
assert( pCsr->eCurType==CURTYPE_SORTER );
szKeyInfo = sizeof(KeyInfo) + (pCsr->pKeyInfo->nKeyField-1)*sizeof(CollSeq*);
sz = sizeof(VdbeSorter) + nWorker * sizeof(SortSubtask);
@@ -99043,6 +99867,9 @@ static int memjrnlCreateFile(MemJournal *p){
}
+/* Forward reference */
+static int memjrnlTruncate(sqlite3_file *pJfd, sqlite_int64 size);
+
/*
** Write data to the file.
*/
@@ -99073,22 +99900,20 @@ static int memjrnlWrite(
** the in-memory journal is being used by a connection using the
** atomic-write optimization. In this case the first 28 bytes of the
** journal file may be written as part of committing the transaction. */
- assert( iOfst==p->endpoint.iOffset || iOfst==0 );
-#if defined(SQLITE_ENABLE_ATOMIC_WRITE) \
- || defined(SQLITE_ENABLE_BATCH_ATOMIC_WRITE)
+ assert( iOfst<=p->endpoint.iOffset );
+ if( iOfst>0 && iOfst!=p->endpoint.iOffset ){
+ memjrnlTruncate(pJfd, iOfst);
+ }
if( iOfst==0 && p->pFirst ){
assert( p->nChunkSize>iAmt );
memcpy((u8*)p->pFirst->zChunk, zBuf, iAmt);
- }else
-#else
- assert( iOfst>0 || p->pFirst==0 );
-#endif
- {
+ }else{
while( nWrite>0 ){
FileChunk *pChunk = p->endpoint.pChunk;
int iChunkOffset = (int)(p->endpoint.iOffset%p->nChunkSize);
int iSpace = MIN(nWrite, p->nChunkSize - iChunkOffset);
+ assert( pChunk!=0 || iChunkOffset==0 );
if( iChunkOffset==0 ){
/* New chunk is required to extend the file. */
FileChunk *pNew = sqlite3_malloc(fileChunkSize(p->nChunkSize));
@@ -99103,10 +99928,11 @@ static int memjrnlWrite(
assert( !p->pFirst );
p->pFirst = pNew;
}
- p->endpoint.pChunk = pNew;
+ pChunk = p->endpoint.pChunk = pNew;
}
- memcpy((u8*)p->endpoint.pChunk->zChunk + iChunkOffset, zWrite, iSpace);
+ assert( pChunk!=0 );
+ memcpy((u8*)pChunk->zChunk + iChunkOffset, zWrite, iSpace);
zWrite += iSpace;
nWrite -= iSpace;
p->endpoint.iOffset += iSpace;
@@ -99130,7 +99956,7 @@ static int memjrnlTruncate(sqlite3_file *pJfd, sqlite_int64 size){
p->pFirst = 0;
}else{
i64 iOff = p->nChunkSize;
- for(pIter=p->pFirst; ALWAYS(pIter) && iOff<=size; pIter=pIter->pNext){
+ for(pIter=p->pFirst; ALWAYS(pIter) && iOff<size; pIter=pIter->pNext){
iOff += p->nChunkSize;
}
if( ALWAYS(pIter) ){
@@ -99884,8 +100710,9 @@ static int lookupName(
}
if( hit || zTab==0 ) continue;
}
- if( zDb && pTab->pSchema!=pSchema ){
- continue;
+ if( zDb ){
+ if( pTab->pSchema!=pSchema ) continue;
+ if( pSchema==0 && strcmp(zDb,"*")!=0 ) continue;
}
if( zTab ){
const char *zTabName = pItem->zAlias ? pItem->zAlias : pTab->zName;
@@ -100016,6 +100843,7 @@ static int lookupName(
pExpr->y.pTab = pTab;
if( pParse->bReturning ){
eNewExprOp = TK_REGISTER;
+ pExpr->op2 = TK_COLUMN;
pExpr->iTable = pNC->uNC.iBaseReg + (pTab->nCol+1)*pExpr->iTable +
sqlite3TableColumnToStorage(pTab, iCol) + 1;
}else{
@@ -100182,6 +101010,7 @@ static int lookupName(
}else{
sqlite3ErrorMsg(pParse, "%s: %s", zErr, zCol);
}
+ sqlite3RecordErrorOffsetOfExpr(pParse->db, pExpr);
pParse->checkSchema = 1;
pTopNC->nNcErr++;
}
@@ -100290,7 +101119,8 @@ static void notValidImpl(
Parse *pParse, /* Leave error message here */
NameContext *pNC, /* The name context */
const char *zMsg, /* Type of error */
- Expr *pExpr /* Invalidate this expression on error */
+ Expr *pExpr, /* Invalidate this expression on error */
+ Expr *pError /* Associate error with this expression */
){
const char *zIn = "partial index WHERE clauses";
if( pNC->ncFlags & NC_IdxExpr ) zIn = "index expressions";
@@ -100302,10 +101132,11 @@ static void notValidImpl(
#endif
sqlite3ErrorMsg(pParse, "%s prohibited in %s", zMsg, zIn);
if( pExpr ) pExpr->op = TK_NULL;
+ sqlite3RecordErrorOffsetOfExpr(pParse->db, pError);
}
-#define sqlite3ResolveNotValid(P,N,M,X,E) \
+#define sqlite3ResolveNotValid(P,N,M,X,E,R) \
assert( ((X)&~(NC_IsCheck|NC_PartIdx|NC_IdxExpr|NC_GenCol))==0 ); \
- if( ((N)->ncFlags & (X))!=0 ) notValidImpl(P,N,M,E);
+ if( ((N)->ncFlags & (X))!=0 ) notValidImpl(P,N,M,E,R);
/*
** Expression p should encode a floating point value between 1.0 and 0.0.
@@ -100440,7 +101271,7 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
testcase( pNC->ncFlags & NC_IdxExpr );
testcase( pNC->ncFlags & NC_GenCol );
sqlite3ResolveNotValid(pParse, pNC, "the \".\" operator",
- NC_IdxExpr|NC_GenCol, 0);
+ NC_IdxExpr|NC_GenCol, 0, pExpr);
pRight = pExpr->pRight;
if( pRight->op==TK_ID ){
zDb = 0;
@@ -100471,7 +101302,6 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
int no_such_func = 0; /* True if no such function exists */
int wrong_num_args = 0; /* True if wrong number of arguments */
int is_agg = 0; /* True if is an aggregate function */
- int nId; /* Number of characters in function name */
const char *zId; /* The function name. */
FuncDef *pDef; /* Information about the function */
u8 enc = ENC(pParse->db); /* The database encoding */
@@ -100481,7 +101311,6 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
#endif
assert( !ExprHasProperty(pExpr, EP_xIsSelect|EP_IntValue) );
zId = pExpr->u.zToken;
- nId = sqlite3Strlen30(zId);
pDef = sqlite3FindFunction(pParse->db, zId, n, enc, 0);
if( pDef==0 ){
pDef = sqlite3FindFunction(pParse->db, zId, -2, enc, 0);
@@ -100498,8 +101327,8 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
pExpr->iTable = exprProbability(pList->a[1].pExpr);
if( pExpr->iTable<0 ){
sqlite3ErrorMsg(pParse,
- "second argument to likelihood() must be a "
- "constant between 0.0 and 1.0");
+ "second argument to %#T() must be a "
+ "constant between 0.0 and 1.0", pExpr);
pNC->nNcErr++;
}
}else{
@@ -100520,8 +101349,8 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
int auth = sqlite3AuthCheck(pParse, SQLITE_FUNCTION, 0,pDef->zName,0);
if( auth!=SQLITE_OK ){
if( auth==SQLITE_DENY ){
- sqlite3ErrorMsg(pParse, "not authorized to use function: %s",
- pDef->zName);
+ sqlite3ErrorMsg(pParse, "not authorized to use function: %#T",
+ pExpr);
pNC->nNcErr++;
}
pExpr->op = TK_NULL;
@@ -100544,7 +101373,7 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
** in a CHECK constraint. SQLServer, MySQL, and PostgreSQL all
** all this. */
sqlite3ResolveNotValid(pParse, pNC, "non-deterministic functions",
- NC_IdxExpr|NC_PartIdx|NC_GenCol, 0);
+ NC_IdxExpr|NC_PartIdx|NC_GenCol, 0, pExpr);
}else{
assert( (NC_SelfRef & 0xff)==NC_SelfRef ); /* Must fit in 8 bits */
pExpr->op2 = pNC->ncFlags & NC_SelfRef;
@@ -100557,7 +101386,7 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
/* Internal-use-only functions are disallowed unless the
** SQL is being compiled using sqlite3NestedParse() or
** the SQLITE_TESTCTRL_INTERNAL_FUNCTIONS test-control has be
- ** used to activate internal functionsn for testing purposes */
+ ** used to activate internal functions for testing purposes */
no_such_func = 1;
pDef = 0;
}else
@@ -100576,7 +101405,7 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
);
if( pDef && pDef->xValue==0 && pWin ){
sqlite3ErrorMsg(pParse,
- "%.*s() may not be used as a window function", nId, zId
+ "%#T() may not be used as a window function", pExpr
);
pNC->nNcErr++;
}else if(
@@ -100590,13 +101419,13 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
}else{
zType = "aggregate";
}
- sqlite3ErrorMsg(pParse, "misuse of %s function %.*s()",zType,nId,zId);
+ sqlite3ErrorMsg(pParse, "misuse of %s function %#T()",zType,pExpr);
pNC->nNcErr++;
is_agg = 0;
}
#else
if( (is_agg && (pNC->ncFlags & NC_AllowAgg)==0) ){
- sqlite3ErrorMsg(pParse,"misuse of aggregate function %.*s()",nId,zId);
+ sqlite3ErrorMsg(pParse,"misuse of aggregate function %#T()",pExpr);
pNC->nNcErr++;
is_agg = 0;
}
@@ -100606,18 +101435,18 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
&& pParse->explain==0
#endif
){
- sqlite3ErrorMsg(pParse, "no such function: %.*s", nId, zId);
+ sqlite3ErrorMsg(pParse, "no such function: %#T", pExpr);
pNC->nNcErr++;
}else if( wrong_num_args ){
- sqlite3ErrorMsg(pParse,"wrong number of arguments to function %.*s()",
- nId, zId);
+ sqlite3ErrorMsg(pParse,"wrong number of arguments to function %#T()",
+ pExpr);
pNC->nNcErr++;
}
#ifndef SQLITE_OMIT_WINDOWFUNC
else if( is_agg==0 && ExprHasProperty(pExpr, EP_WinFunc) ){
sqlite3ErrorMsg(pParse,
- "FILTER may not be used with non-aggregate %.*s()",
- nId, zId
+ "FILTER may not be used with non-aggregate %#T()",
+ pExpr
);
pNC->nNcErr++;
}
@@ -100702,7 +101531,7 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
testcase( pNC->ncFlags & NC_IdxExpr );
testcase( pNC->ncFlags & NC_GenCol );
if( pNC->ncFlags & NC_SelfRef ){
- notValidImpl(pParse, pNC, "subqueries", pExpr);
+ notValidImpl(pParse, pNC, "subqueries", pExpr, pExpr);
}else{
sqlite3WalkSelect(pWalker, pExpr->x.pSelect);
}
@@ -100720,7 +101549,7 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
testcase( pNC->ncFlags & NC_IdxExpr );
testcase( pNC->ncFlags & NC_GenCol );
sqlite3ResolveNotValid(pParse, pNC, "parameters",
- NC_IsCheck|NC_PartIdx|NC_IdxExpr|NC_GenCol, pExpr);
+ NC_IsCheck|NC_PartIdx|NC_IdxExpr|NC_GenCol, pExpr, pExpr);
break;
}
case TK_IS:
@@ -100772,11 +101601,13 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
testcase( pExpr->op==TK_ISNOT );
testcase( pExpr->op==TK_BETWEEN );
sqlite3ErrorMsg(pParse, "row value misused");
+ sqlite3RecordErrorOffsetOfExpr(pParse->db, pExpr);
}
break;
}
}
- return (pParse->nErr || pParse->db->mallocFailed) ? WRC_Abort : WRC_Continue;
+ assert( pParse->db->mallocFailed==0 || pParse->nErr!=0 );
+ return pParse->nErr ? WRC_Abort : WRC_Continue;
}
/*
@@ -100884,11 +101715,13 @@ static void resolveOutOfRangeError(
Parse *pParse, /* The error context into which to write the error */
const char *zType, /* "ORDER" or "GROUP" */
int i, /* The index (1-based) of the term out of range */
- int mx /* Largest permissible value of i */
+ int mx, /* Largest permissible value of i */
+ Expr *pError /* Associate the error with the expression */
){
sqlite3ErrorMsg(pParse,
"%r %s BY term out of range - should be "
"between 1 and %d", i, zType, mx);
+ sqlite3RecordErrorOffsetOfExpr(pParse->db, pError);
}
/*
@@ -100944,7 +101777,7 @@ static int resolveCompoundOrderBy(
if( NEVER(pE==0) ) continue;
if( sqlite3ExprIsInteger(pE, &iCol) ){
if( iCol<=0 || iCol>pEList->nExpr ){
- resolveOutOfRangeError(pParse, "ORDER", i+1, pEList->nExpr);
+ resolveOutOfRangeError(pParse, "ORDER", i+1, pEList->nExpr, pE);
return 1;
}
}else{
@@ -101040,7 +101873,7 @@ SQLITE_PRIVATE int sqlite3ResolveOrderGroupBy(
for(i=0, pItem=pOrderBy->a; i<pOrderBy->nExpr; i++, pItem++){
if( pItem->u.x.iOrderByCol ){
if( pItem->u.x.iOrderByCol>pEList->nExpr ){
- resolveOutOfRangeError(pParse, zType, i+1, pEList->nExpr);
+ resolveOutOfRangeError(pParse, zType, i+1, pEList->nExpr, 0);
return 1;
}
resolveAlias(pParse, pEList, pItem->u.x.iOrderByCol-1, pItem->pExpr,0);
@@ -101132,7 +101965,7 @@ static int resolveOrderGroupBy(
** number so that sqlite3ResolveOrderGroupBy() will convert the
** order-by term to a copy of the result-set expression */
if( iCol<1 || iCol>0xffff ){
- resolveOutOfRangeError(pParse, zType, i+1, nResult);
+ resolveOutOfRangeError(pParse, zType, i+1, nResult, pE2);
return 1;
}
pItem->u.x.iOrderByCol = (u16)iCol;
@@ -101190,7 +102023,7 @@ static int resolveSelectStep(Walker *pWalker, Select *p){
*/
if( (p->selFlags & SF_Expanded)==0 ){
sqlite3SelectPrep(pParse, p, pOuterNC);
- return (pParse->nErr || db->mallocFailed) ? WRC_Abort : WRC_Prune;
+ return pParse->nErr ? WRC_Abort : WRC_Prune;
}
isCompound = p->pPrior!=0;
@@ -101238,7 +102071,8 @@ static int resolveSelectStep(Walker *pWalker, Select *p){
if( pItem->zName ) pParse->zAuthContext = pItem->zName;
sqlite3ResolveSelectNames(pParse, pItem->pSelect, pOuterNC);
pParse->zAuthContext = zSavedContext;
- if( pParse->nErr || db->mallocFailed ) return WRC_Abort;
+ if( pParse->nErr ) return WRC_Abort;
+ assert( db->mallocFailed==0 );
/* If the number of references to the outer context changed when
** expressions in the sub-select were resolved, the sub-select
@@ -102384,9 +103218,8 @@ static void heightOfSelect(const Select *pSelect, int *pnHeight){
** if appropriate.
*/
static void exprSetHeight(Expr *p){
- int nHeight = 0;
- heightOfExpr(p->pLeft, &nHeight);
- heightOfExpr(p->pRight, &nHeight);
+ int nHeight = p->pLeft ? p->pLeft->nHeight : 0;
+ if( p->pRight && p->pRight->nHeight>nHeight ) nHeight = p->pRight->nHeight;
if( ExprUseXSelect(p) ){
heightOfSelect(p->x.pSelect, &nHeight);
}else if( p->x.pList ){
@@ -102685,6 +103518,7 @@ SQLITE_PRIVATE Expr *sqlite3ExprFunction(
sqlite3ExprListDelete(db, pList); /* Avoid memory leak when malloc fails */
return 0;
}
+ pNew->w.iOfst = (int)(pToken->z - pParse->zTail);
if( pList
&& pList->nExpr > pParse->db->aLimit[SQLITE_LIMIT_FUNCTION_ARG]
&& !pParse->nested
@@ -102728,7 +103562,7 @@ SQLITE_PRIVATE void sqlite3ExprFunctionUsable(
** SQLITE_DBCONFIG_TRUSTED_SCHEMA is off (meaning
** that the schema is possibly tainted).
*/
- sqlite3ErrorMsg(pParse, "unsafe use of %s()", pDef->zName);
+ sqlite3ErrorMsg(pParse, "unsafe use of %#T()", pExpr);
}
}
}
@@ -102784,6 +103618,7 @@ SQLITE_PRIVATE void sqlite3ExprAssignVarNumber(Parse *pParse, Expr *pExpr, u32 n
if( bOk==0 || i<1 || i>db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER] ){
sqlite3ErrorMsg(pParse, "variable number must be between ?1 and ?%d",
db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER]);
+ sqlite3RecordErrorOffsetOfExpr(pParse->db, pExpr);
return;
}
x = (ynVar)i;
@@ -102811,6 +103646,7 @@ SQLITE_PRIVATE void sqlite3ExprAssignVarNumber(Parse *pParse, Expr *pExpr, u32 n
pExpr->iColumn = x;
if( x>db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER] ){
sqlite3ErrorMsg(pParse, "too many SQL variables");
+ sqlite3RecordErrorOffsetOfExpr(pParse->db, pExpr);
}
}
@@ -104418,8 +105254,7 @@ SQLITE_PRIVATE int sqlite3FindInIndex(
CollSeq *pReq = sqlite3BinaryCompareCollSeq(pParse, pLhs, pRhs);
int j;
- assert( pReq!=0 || pRhs->iColumn==XN_ROWID
- || pParse->nErr || db->mallocFailed );
+ assert( pReq!=0 || pRhs->iColumn==XN_ROWID || pParse->nErr );
for(j=0; j<nExpr; j++){
if( pIdx->aiColumn[j]!=pRhs->iColumn ) continue;
assert( pIdx->azColl[j] );
@@ -104895,10 +105730,8 @@ SQLITE_PRIVATE int sqlite3CodeSubselect(Parse *pParse, Expr *pExpr){
}
pSel->iLimit = 0;
if( sqlite3Select(pParse, pSel, &dest) ){
- if( pParse->nErr ){
- pExpr->op2 = pExpr->op;
- pExpr->op = TK_ERROR;
- }
+ pExpr->op2 = pExpr->op;
+ pExpr->op = TK_ERROR;
return 0;
}
pExpr->iTable = rReg = dest.iSDParm;
@@ -105115,10 +105948,9 @@ static void sqlite3ExprCodeIN(
}else{
destStep2 = destStep6 = sqlite3VdbeMakeLabel(pParse);
}
- if( pParse->nErr ) goto sqlite3ExprCodeIN_finished;
for(i=0; i<nVector; i++){
Expr *p = sqlite3VectorFieldSubexpr(pExpr->pLeft, i);
- if( pParse->db->mallocFailed ) goto sqlite3ExprCodeIN_oom_error;
+ if( pParse->nErr ) goto sqlite3ExprCodeIN_oom_error;
if( sqlite3ExprCanBeNull(p) ){
sqlite3VdbeAddOp2(v, OP_IsNull, rLhs+i, destStep2);
VdbeCoverage(v);
@@ -105256,11 +106088,12 @@ static void codeInteger(Parse *pParse, Expr *pExpr, int negFlag, int iMem){
c = sqlite3DecOrHexToI64(z, &value);
if( (c==3 && !negFlag) || (c==2) || (negFlag && value==SMALLEST_INT64)){
#ifdef SQLITE_OMIT_FLOATING_POINT
- sqlite3ErrorMsg(pParse, "oversized integer: %s%s", negFlag ? "-" : "", z);
+ sqlite3ErrorMsg(pParse, "oversized integer: %s%#T", negFlag?"-":"",pExpr);
#else
#ifndef SQLITE_OMIT_HEX_INTEGER
if( sqlite3_strnicmp(z,"0x",2)==0 ){
- sqlite3ErrorMsg(pParse, "hex literal too big: %s%s", negFlag?"-":"",z);
+ sqlite3ErrorMsg(pParse, "hex literal too big: %s%#T",
+ negFlag?"-":"",pExpr);
}else
#endif
{
@@ -105936,7 +106769,7 @@ expr_code_doover:
|| NEVER(pExpr->iAgg>=pInfo->nFunc)
){
assert( !ExprHasProperty(pExpr, EP_IntValue) );
- sqlite3ErrorMsg(pParse, "misuse of aggregate: %s()", pExpr->u.zToken);
+ sqlite3ErrorMsg(pParse, "misuse of aggregate: %#T()", pExpr);
}else{
return pInfo->aFunc[pExpr->iAgg].iMem;
}
@@ -105977,7 +106810,7 @@ expr_code_doover:
}
#endif
if( pDef==0 || pDef->xFinalize!=0 ){
- sqlite3ErrorMsg(pParse, "unknown function: %s()", zId);
+ sqlite3ErrorMsg(pParse, "unknown function: %#T()", pExpr);
break;
}
if( pDef->funcFlags & SQLITE_FUNC_INLINE ){
@@ -108293,7 +109126,9 @@ SQLITE_PRIVATE void sqlite3AlterFinishAddColumn(Parse *pParse, Token *pColDef){
int r1; /* Temporary registers */
db = pParse->db;
- if( pParse->nErr || db->mallocFailed ) return;
+ assert( db->pParse==pParse );
+ if( pParse->nErr ) return;
+ assert( db->mallocFailed==0 );
pNew = pParse->pNewTable;
assert( pNew );
@@ -108419,7 +109254,7 @@ SQLITE_PRIVATE void sqlite3AlterFinishAddColumn(Parse *pParse, Token *pColDef){
" THEN raise(ABORT,'CHECK constraint failed')"
" ELSE raise(ABORT,'NOT NULL constraint failed')"
" END"
- " FROM pragma_quick_check(\"%w\",\"%w\")"
+ " FROM pragma_quick_check(%Q,%Q)"
" WHERE quick_check GLOB 'CHECK*' OR quick_check GLOB 'NULL*'",
zTab, zDb
);
@@ -108598,7 +109433,7 @@ SQLITE_PRIVATE void sqlite3AlterRenameColumn(
if( 0==sqlite3StrICmp(pTab->aCol[iCol].zCnName, zOld) ) break;
}
if( iCol==pTab->nCol ){
- sqlite3ErrorMsg(pParse, "no such column: \"%s\"", zOld);
+ sqlite3ErrorMsg(pParse, "no such column: \"%T\"", pOld);
goto exit_rename_column;
}
@@ -108704,7 +109539,9 @@ struct RenameCtx {
** following a valid object, it may not be used in comparison operations.
*/
static void renameTokenCheckAll(Parse *pParse, const void *pPtr){
- if( pParse->nErr==0 && pParse->db->mallocFailed==0 ){
+ assert( pParse==pParse->db->pParse );
+ assert( pParse->db->mallocFailed==0 || pParse->nErr!=0 );
+ if( pParse->nErr==0 ){
const RenameToken *p;
u8 i = 0;
for(p=pParse->pRename; p; p=p->pNext){
@@ -109026,12 +109863,12 @@ static void renameColumnParseError(
const char *zN = (const char*)sqlite3_value_text(pObject);
char *zErr;
- zErr = sqlite3_mprintf("error in %s %s%s%s: %s",
+ zErr = sqlite3MPrintf(pParse->db, "error in %s %s%s%s: %s",
zT, zN, (zWhen[0] ? " " : ""), zWhen,
pParse->zErrMsg
);
sqlite3_result_error(pCtx, zErr, -1);
- sqlite3_free(zErr);
+ sqlite3DbFree(pParse->db, zErr);
}
/*
@@ -109095,24 +109932,22 @@ static int renameParseSql(
int bTemp /* True if SQL is from temp schema */
){
int rc;
- char *zErr = 0;
+ sqlite3ParseObjectInit(p, db);
+ if( zSql==0 ){
+ return SQLITE_NOMEM;
+ }
+ if( sqlite3StrNICmp(zSql,"CREATE ",7)!=0 ){
+ return SQLITE_CORRUPT_BKPT;
+ }
db->init.iDb = bTemp ? 1 : sqlite3FindDbName(db, zDb);
-
- /* Parse the SQL statement passed as the first argument. If no error
- ** occurs and the parse does not result in a new table, index or
- ** trigger object, the database must be corrupt. */
- memset(p, 0, sizeof(Parse));
p->eParseMode = PARSE_MODE_RENAME;
p->db = db;
p->nQueryLoop = 1;
- rc = zSql ? sqlite3RunParser(p, zSql, &zErr) : SQLITE_NOMEM;
- assert( p->zErrMsg==0 );
- assert( rc!=SQLITE_OK || zErr==0 );
- p->zErrMsg = zErr;
+ rc = sqlite3RunParser(p, zSql);
if( db->mallocFailed ) rc = SQLITE_NOMEM;
if( rc==SQLITE_OK
- && p->pNewTable==0 && p->pNewIndex==0 && p->pNewTrigger==0
+ && NEVER(p->pNewTable==0 && p->pNewIndex==0 && p->pNewTrigger==0)
){
rc = SQLITE_CORRUPT_BKPT;
}
@@ -109390,13 +110225,13 @@ static void renameParseCleanup(Parse *pParse){
sqlite3DeleteTrigger(db, pParse->pNewTrigger);
sqlite3DbFree(db, pParse->zErrMsg);
renameTokenFree(db, pParse->pRename);
- sqlite3ParserReset(pParse);
+ sqlite3ParseObjectReset(pParse);
}
/*
** SQL function:
**
-** sqlite_rename_column(zSql, iCol, bQuote, zNew, zTable, zOld)
+** sqlite_rename_column(SQL,TYPE,OBJ,DB,TABLE,COL,NEWNAME,QUOTE,TEMP)
**
** 0. zSql: SQL statement to rewrite
** 1. type: Type of object ("table", "view" etc.)
@@ -109414,7 +110249,8 @@ static void renameParseCleanup(Parse *pParse){
**
** This function is used internally by the ALTER TABLE RENAME COLUMN command.
** It is only accessible to SQL created using sqlite3NestedParse(). It is
-** not reachable from ordinary SQL passed into sqlite3_prepare().
+** not reachable from ordinary SQL passed into sqlite3_prepare() unless the
+** SQLITE_TESTCTRL_INTERNAL_FUNCTIONS test setting is enabled.
*/
static void renameColumnFunc(
sqlite3_context *context,
@@ -109563,7 +110399,9 @@ static void renameColumnFunc(
renameColumnFunc_done:
if( rc!=SQLITE_OK ){
- if( sParse.zErrMsg ){
+ if( rc==SQLITE_ERROR && sqlite3WritableSchema(db) ){
+ sqlite3_result_value(context, argv[0]);
+ }else if( sParse.zErrMsg ){
renameColumnParseError(context, "", argv[1], argv[2], &sParse);
}else{
sqlite3_result_error_code(context, rc);
@@ -109762,7 +110600,9 @@ static void renameTableFunc(
rc = renameEditSql(context, &sCtx, zInput, zNew, bQuote);
}
if( rc!=SQLITE_OK ){
- if( sParse.zErrMsg ){
+ if( rc==SQLITE_ERROR && sqlite3WritableSchema(db) ){
+ sqlite3_result_value(context, argv[3]);
+ }else if( sParse.zErrMsg ){
renameColumnParseError(context, "", argv[1], argv[2], &sParse);
}else{
sqlite3_result_error_code(context, rc);
@@ -109787,10 +110627,10 @@ static int renameQuotefixExprCb(Walker *pWalker, Expr *pExpr){
return WRC_Continue;
}
-/*
-** The implementation of an SQL scalar function that rewrites DDL statements
-** so that any string literals that use double-quotes are modified so that
-** they use single quotes.
+/* SQL function: sqlite_rename_quotefix(DB,SQL)
+**
+** Rewrite the DDL statement "SQL" so that any string literals that use
+** double-quotes use single quotes instead.
**
** Two arguments must be passed:
**
@@ -109809,6 +110649,10 @@ static int renameQuotefixExprCb(Walker *pWalker, Expr *pExpr){
** returns the string:
**
** CREATE VIEW v1 AS SELECT "a", 'string' FROM t1
+**
+** If there is a error in the input SQL, then raise an error, except
+** if PRAGMA writable_schema=ON, then just return the input string
+** unmodified following an error.
*/
static void renameQuotefixFunc(
sqlite3_context *context,
@@ -109883,7 +110727,11 @@ static void renameQuotefixFunc(
renameTokenFree(db, sCtx.pList);
}
if( rc!=SQLITE_OK ){
- sqlite3_result_error_code(context, rc);
+ if( sqlite3WritableSchema(db) && rc==SQLITE_ERROR ){
+ sqlite3_result_value(context, argv[1]);
+ }else{
+ sqlite3_result_error_code(context, rc);
+ }
}
renameParseCleanup(&sParse);
}
@@ -109895,7 +110743,8 @@ static void renameQuotefixFunc(
sqlite3BtreeLeaveAll(db);
}
-/*
+/* Function: sqlite_rename_test(DB,SQL,TYPE,NAME,ISTEMP,WHEN,DQS)
+**
** An SQL user function that checks that there are no parse or symbol
** resolution problems in a CREATE TRIGGER|TABLE|VIEW|INDEX statement.
** After an ALTER TABLE .. RENAME operation is performed and the schema
@@ -109910,11 +110759,13 @@ static void renameQuotefixFunc(
** 5: "when" part of error message.
** 6: True to disable the DQS quirk when parsing SQL.
**
-** Unless it finds an error, this function normally returns NULL. However, it
-** returns integer value 1 if:
+** The return value is computed as follows:
**
-** * the SQL argument creates a trigger, and
-** * the table that the trigger is attached to is in database zDb.
+** A. If an error is seen and not in PRAGMA writable_schema=ON mode,
+** then raise the error.
+** B. Else if a trigger is created and the the table that the trigger is
+** attached to is in database zDb, then return 1.
+** C. Otherwise return NULL.
*/
static void renameTableTest(
sqlite3_context *context,
@@ -109959,12 +110810,16 @@ static void renameTableTest(
if( rc==SQLITE_OK ){
int i1 = sqlite3SchemaToIndex(db, sParse.pNewTrigger->pTabSchema);
int i2 = sqlite3FindDbName(db, zDb);
- if( i1==i2 ) sqlite3_result_int(context, 1);
+ if( i1==i2 ){
+ /* Handle output case B */
+ sqlite3_result_int(context, 1);
+ }
}
}
}
- if( rc!=SQLITE_OK && zWhen ){
+ if( rc!=SQLITE_OK && zWhen && !sqlite3WritableSchema(db) ){
+ /* Output case A */
renameColumnParseError(context, zWhen, argv[2], argv[3],&sParse);
}
renameParseCleanup(&sParse);
@@ -110080,7 +110935,7 @@ SQLITE_PRIVATE void sqlite3AlterDropColumn(Parse *pParse, SrcList *pSrc, const T
}
iCol = sqlite3ColumnIndex(pTab, zCol);
if( iCol<0 ){
- sqlite3ErrorMsg(pParse, "no such column: \"%s\"", zCol);
+ sqlite3ErrorMsg(pParse, "no such column: \"%T\"", pName);
goto exit_drop_column;
}
@@ -110104,6 +110959,12 @@ SQLITE_PRIVATE void sqlite3AlterDropColumn(Parse *pParse, SrcList *pSrc, const T
iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
assert( iDb>=0 );
zDb = db->aDb[iDb].zDbSName;
+#ifndef SQLITE_OMIT_AUTHORIZATION
+ /* Invoke the authorization callback. */
+ if( sqlite3AuthCheck(pParse, SQLITE_ALTER_TABLE, zDb, pTab->zName, zCol) ){
+ goto exit_drop_column;
+ }
+#endif
renameTestSchema(pParse, zDb, iDb==1, "", 0);
renameFixQuotes(pParse, zDb, iDb==1);
sqlite3NestedParse(pParse,
@@ -112491,7 +113352,7 @@ static void codeAttach(
}
#ifndef SQLITE_OMIT_AUTHORIZATION
- if( pAuthArg ){
+ if( ALWAYS(pAuthArg) ){
char *zAuthArg;
if( pAuthArg->op==TK_STRING ){
assert( !ExprHasProperty(pAuthArg, EP_IntValue) );
@@ -113152,11 +114013,13 @@ SQLITE_PRIVATE void sqlite3FinishCoding(Parse *pParse){
assert( pParse->pToplevel==0 );
db = pParse->db;
+ assert( db->pParse==pParse );
if( pParse->nested ) return;
- if( db->mallocFailed || pParse->nErr ){
- if( pParse->rc==SQLITE_OK ) pParse->rc = SQLITE_ERROR;
+ if( pParse->nErr ){
+ if( db->mallocFailed ) pParse->rc = SQLITE_NOMEM;
return;
}
+ assert( db->mallocFailed==0 );
/* Begin by generating some termination code at the end of the
** vdbe program
@@ -113179,9 +114042,10 @@ SQLITE_PRIVATE void sqlite3FinishCoding(Parse *pParse){
int i;
int reg;
- if( pReturning->nRetCol==0 ){
+ if( NEVER(pReturning->nRetCol==0) ){
assert( CORRUPT_DB );
}else{
+ sqlite3VdbeAddOp0(v, OP_FkCheck);
addrRewind =
sqlite3VdbeAddOp1(v, OP_Rewind, pReturning->iRetCur);
VdbeCoverage(v);
@@ -113274,7 +114138,7 @@ SQLITE_PRIVATE void sqlite3FinishCoding(Parse *pParse){
if( pParse->bReturning ){
Returning *pRet = pParse->u1.pReturning;
- if( pRet->nRetCol==0 ){
+ if( NEVER(pRet->nRetCol==0) ){
assert( CORRUPT_DB );
}else{
sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pRet->iRetCur, pRet->nRetCol);
@@ -113288,7 +114152,9 @@ SQLITE_PRIVATE void sqlite3FinishCoding(Parse *pParse){
/* Get the VDBE program ready for execution
*/
- if( v && pParse->nErr==0 && !db->mallocFailed ){
+ assert( v!=0 || pParse->nErr );
+ assert( db->mallocFailed==0 || pParse->nErr );
+ if( pParse->nErr==0 ){
/* A minimum of one cursor is required if autoincrement is used
* See ticket [a696379c1f08866] */
assert( pParse->pAinc==0 || pParse->nTab>0 );
@@ -113315,7 +114181,6 @@ SQLITE_PRIVATE void sqlite3FinishCoding(Parse *pParse){
SQLITE_PRIVATE void sqlite3NestedParse(Parse *pParse, const char *zFormat, ...){
va_list ap;
char *zSql;
- char *zErrMsg = 0;
sqlite3 *db = pParse->db;
u32 savedDbFlags = db->mDbFlags;
char saveBuf[PARSE_TAIL_SZ];
@@ -113337,9 +114202,10 @@ SQLITE_PRIVATE void sqlite3NestedParse(Parse *pParse, const char *zFormat, ...){
memcpy(saveBuf, PARSE_TAIL(pParse), PARSE_TAIL_SZ);
memset(PARSE_TAIL(pParse), 0, PARSE_TAIL_SZ);
db->mDbFlags |= DBFLAG_PreferBuiltin;
- sqlite3RunParser(pParse, zSql, &zErrMsg);
+ sqlite3RunParser(pParse, zSql);
+ sqlite3DbFree(db, pParse->zErrMsg);
+ pParse->zErrMsg = 0;
db->mDbFlags = savedDbFlags;
- sqlite3DbFree(db, zErrMsg);
sqlite3DbFree(db, zSql);
memcpy(PARSE_TAIL(pParse), saveBuf, PARSE_TAIL_SZ);
pParse->nested--;
@@ -114299,7 +115165,8 @@ SQLITE_PRIVATE void sqlite3StartTable(
pTable = sqlite3FindTable(db, zName, zDb);
if( pTable ){
if( !noErr ){
- sqlite3ErrorMsg(pParse, "table %T already exists", pName);
+ sqlite3ErrorMsg(pParse, "%s %T already exists",
+ (IsView(pTable)? "view" : "table"), pName);
}else{
assert( !db->init.busy || CORRUPT_DB );
sqlite3CodeVerifySchema(pParse, iDb);
@@ -115394,10 +116261,11 @@ static void convertToWithoutRowidTable(Parse *pParse, Table *pTab){
pTab->iPKey = -1;
sqlite3CreateIndex(pParse, 0, 0, 0, pList, pTab->keyConf, 0, 0, 0, 0,
SQLITE_IDXTYPE_PRIMARYKEY);
- if( db->mallocFailed || pParse->nErr ){
+ if( pParse->nErr ){
pTab->tabFlags &= ~TF_WithoutRowid;
return;
}
+ assert( db->mallocFailed==0 );
pPk = sqlite3PrimaryKeyIndex(pTab);
assert( pPk->nKeyCol==1 );
}else{
@@ -115828,6 +116696,11 @@ SQLITE_PRIVATE void sqlite3EndTable(
int addrInsLoop; /* Top of the loop for inserting rows */
Table *pSelTab; /* A table that describes the SELECT results */
+ if( IN_SPECIAL_PARSE ){
+ pParse->rc = SQLITE_ERROR;
+ pParse->nErr++;
+ return;
+ }
regYield = ++pParse->nMem;
regRec = ++pParse->nMem;
regRowid = ++pParse->nMem;
@@ -116138,10 +117011,10 @@ SQLITE_PRIVATE int sqlite3ViewGetColumnNames(Parse *pParse, Table *pTable){
*/
sqlite3ColumnsFromExprList(pParse, pTable->pCheck,
&pTable->nCol, &pTable->aCol);
- if( db->mallocFailed==0
- && pParse->nErr==0
+ if( pParse->nErr==0
&& pTable->nCol==pSel->pEList->nExpr
){
+ assert( db->mallocFailed==0 );
sqlite3SelectAddColumnTypeAndCollation(pParse, pTable, pSel,
SQLITE_AFF_NONE);
}
@@ -116760,7 +117633,7 @@ static void sqlite3RefillIndex(Parse *pParse, Index *pIndex, int memRootPage){
tnum = pIndex->tnum;
}
pKey = sqlite3KeyInfoOfIndex(pParse, pIndex);
- assert( pKey!=0 || db->mallocFailed || pParse->nErr );
+ assert( pKey!=0 || pParse->nErr );
/* Open the sorter cursor if we are to use one. */
iSorter = pParse->nTab++;
@@ -116924,9 +117797,11 @@ SQLITE_PRIVATE void sqlite3CreateIndex(
char *zExtra = 0; /* Extra space after the Index object */
Index *pPk = 0; /* PRIMARY KEY index for WITHOUT ROWID tables */
- if( db->mallocFailed || pParse->nErr>0 ){
+ assert( db->pParse==pParse );
+ if( pParse->nErr ){
goto exit_create_index;
}
+ assert( db->mallocFailed==0 );
if( IN_DECLARE_VTAB && idxType!=SQLITE_IDXTYPE_PRIMARYKEY ){
goto exit_create_index;
}
@@ -116990,7 +117865,6 @@ SQLITE_PRIVATE void sqlite3CreateIndex(
pDb = &db->aDb[iDb];
assert( pTab!=0 );
- assert( pParse->nErr==0 );
if( sqlite3StrNICmp(pTab->zName, "sqlite_", 7)==0
&& db->init.busy==0
&& pTblName!=0
@@ -117414,13 +118288,13 @@ SQLITE_PRIVATE void sqlite3CreateIndex(
/* Add an entry in sqlite_schema for this index
*/
sqlite3NestedParse(pParse,
- "INSERT INTO %Q." LEGACY_SCHEMA_TABLE " VALUES('index',%Q,%Q,#%d,%Q);",
- db->aDb[iDb].zDbSName,
- pIndex->zName,
- pTab->zName,
- iMem,
- zStmt
- );
+ "INSERT INTO %Q." LEGACY_SCHEMA_TABLE " VALUES('index',%Q,%Q,#%d,%Q);",
+ db->aDb[iDb].zDbSName,
+ pIndex->zName,
+ pTab->zName,
+ iMem,
+ zStmt
+ );
sqlite3DbFree(db, zStmt);
/* Fill the index with data and reparse the schema. Code an OP_Expire
@@ -117554,10 +118428,10 @@ SQLITE_PRIVATE void sqlite3DropIndex(Parse *pParse, SrcList *pName, int ifExists
sqlite3 *db = pParse->db;
int iDb;
- assert( pParse->nErr==0 ); /* Never called with prior errors */
if( db->mallocFailed ){
goto exit_drop_index;
}
+ assert( pParse->nErr==0 ); /* Never called with prior non-OOM errors */
assert( pName->nSrc==1 );
if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){
goto exit_drop_index;
@@ -117968,7 +118842,7 @@ SQLITE_PRIVATE SrcList *sqlite3SrcListAppendFromTerm(
pItem->pUsing = pUsing;
return p;
- append_from_error:
+append_from_error:
assert( p==0 );
sqlite3ExprDelete(db, pOn);
sqlite3IdListDelete(db, pUsing);
@@ -118998,7 +119872,6 @@ SQLITE_PRIVATE void sqlite3InsertBuiltinFuncs(
const char *zName = aDef[i].zName;
int nName = sqlite3Strlen30(zName);
int h = SQLITE_FUNC_HASH(zName[0], nName);
- assert( zName[0]>='a' && zName[0]<='z' );
assert( aDef[i].funcFlags & SQLITE_FUNC_BUILTIN );
pOther = sqlite3FunctionSearch(h, zName);
if( pOther ){
@@ -119225,6 +120098,16 @@ SQLITE_PRIVATE Table *sqlite3SrcListLookup(Parse *pParse, SrcList *pSrc){
return pTab;
}
+/* Generate byte-code that will report the number of rows modified
+** by a DELETE, INSERT, or UPDATE statement.
+*/
+SQLITE_PRIVATE void sqlite3CodeChangeCount(Vdbe *v, int regCounter, const char *zColName){
+ sqlite3VdbeAddOp0(v, OP_FkCheck);
+ sqlite3VdbeAddOp2(v, OP_ResultRow, regCounter, 1);
+ sqlite3VdbeSetNumCols(v, 1);
+ sqlite3VdbeSetColName(v, 0, COLNAME_NAME, zColName, SQLITE_STATIC);
+}
+
/* Return true if table pTab is read-only.
**
** A table is read-only if any of the following are true:
@@ -119464,9 +120347,11 @@ SQLITE_PRIVATE void sqlite3DeleteFrom(
memset(&sContext, 0, sizeof(sContext));
db = pParse->db;
- if( pParse->nErr || db->mallocFailed ){
+ assert( db->pParse==pParse );
+ if( pParse->nErr ){
goto delete_from_cleanup;
}
+ assert( db->mallocFailed==0 );
assert( pTabList->nSrc==1 );
@@ -119647,7 +120532,7 @@ SQLITE_PRIVATE void sqlite3DeleteFrom(
** ONEPASS_SINGLE: One-pass approach - at most one row deleted.
** ONEPASS_MULTI: One-pass approach - any number of rows may be deleted.
*/
- pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, 0, 0, wcf, iTabCur+1);
+ pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, 0, 0,0,wcf,iTabCur+1);
if( pWInfo==0 ) goto delete_from_cleanup;
eOnePass = sqlite3WhereOkOnePass(pWInfo, aiCurOnePass);
assert( IsVirtual(pTab)==0 || eOnePass!=ONEPASS_MULTI );
@@ -119800,9 +120685,7 @@ SQLITE_PRIVATE void sqlite3DeleteFrom(
** invoke the callback function.
*/
if( memCnt ){
- sqlite3VdbeAddOp2(v, OP_ChngCntRow, memCnt, 1);
- sqlite3VdbeSetNumCols(v, 1);
- sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "rows deleted", SQLITE_STATIC);
+ sqlite3CodeChangeCount(v, memCnt, "rows deleted");
}
delete_from_cleanup:
@@ -120253,6 +121136,18 @@ static void typeofFunc(
sqlite3_result_text(context, azType[i], -1, SQLITE_STATIC);
}
+/* subtype(X)
+**
+** Return the subtype of X
+*/
+static void subtypeFunc(
+ sqlite3_context *context,
+ int argc,
+ sqlite3_value **argv
+){
+ UNUSED_PARAMETER(argc);
+ sqlite3_result_int(context, sqlite3_value_subtype(argv[0]));
+}
/*
** Implementation of the length() function
@@ -120414,7 +121309,7 @@ endInstrOOM:
}
/*
-** Implementation of the printf() function.
+** Implementation of the printf() (a.k.a. format()) SQL function.
*/
static void printfFunc(
sqlite3_context *context,
@@ -121183,39 +122078,42 @@ static const char hexdigits[] = {
};
/*
-** Implementation of the QUOTE() function. This function takes a single
-** argument. If the argument is numeric, the return value is the same as
-** the argument. If the argument is NULL, the return value is the string
-** "NULL". Otherwise, the argument is enclosed in single quotes with
-** single-quote escapes.
+** Append to pStr text that is the SQL literal representation of the
+** value contained in pValue.
*/
-static void quoteFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
- assert( argc==1 );
- UNUSED_PARAMETER(argc);
- switch( sqlite3_value_type(argv[0]) ){
+SQLITE_PRIVATE void sqlite3QuoteValue(StrAccum *pStr, sqlite3_value *pValue){
+ /* As currently implemented, the string must be initially empty.
+ ** we might relax this requirement in the future, but that will
+ ** require enhancements to the implementation. */
+ assert( pStr!=0 && pStr->nChar==0 );
+
+ switch( sqlite3_value_type(pValue) ){
case SQLITE_FLOAT: {
double r1, r2;
- char zBuf[50];
- r1 = sqlite3_value_double(argv[0]);
- sqlite3_snprintf(sizeof(zBuf), zBuf, "%!.15g", r1);
- sqlite3AtoF(zBuf, &r2, 20, SQLITE_UTF8);
- if( r1!=r2 ){
- sqlite3_snprintf(sizeof(zBuf), zBuf, "%!.20e", r1);
+ const char *zVal;
+ r1 = sqlite3_value_double(pValue);
+ sqlite3_str_appendf(pStr, "%!.15g", r1);
+ zVal = sqlite3_str_value(pStr);
+ if( zVal ){
+ sqlite3AtoF(zVal, &r2, pStr->nChar, SQLITE_UTF8);
+ if( r1!=r2 ){
+ sqlite3_str_reset(pStr);
+ sqlite3_str_appendf(pStr, "%!.20e", r1);
+ }
}
- sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT);
break;
}
case SQLITE_INTEGER: {
- sqlite3_result_value(context, argv[0]);
+ sqlite3_str_appendf(pStr, "%lld", sqlite3_value_int64(pValue));
break;
}
case SQLITE_BLOB: {
- char *zText = 0;
- char const *zBlob = sqlite3_value_blob(argv[0]);
- int nBlob = sqlite3_value_bytes(argv[0]);
- assert( zBlob==sqlite3_value_blob(argv[0]) ); /* No encoding change */
- zText = (char *)contextMalloc(context, (2*(i64)nBlob)+4);
- if( zText ){
+ char const *zBlob = sqlite3_value_blob(pValue);
+ int nBlob = sqlite3_value_bytes(pValue);
+ assert( zBlob==sqlite3_value_blob(pValue) ); /* No encoding change */
+ sqlite3StrAccumEnlarge(pStr, nBlob*2 + 4);
+ if( pStr->accError==0 ){
+ char *zText = pStr->zText;
int i;
for(i=0; i<nBlob; i++){
zText[(i*2)+2] = hexdigits[(zBlob[i]>>4)&0x0F];
@@ -121225,43 +122123,49 @@ static void quoteFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
zText[(nBlob*2)+3] = '\0';
zText[0] = 'X';
zText[1] = '\'';
- sqlite3_result_text(context, zText, -1, SQLITE_TRANSIENT);
- sqlite3_free(zText);
+ pStr->nChar = nBlob*2 + 3;
}
break;
}
case SQLITE_TEXT: {
- int i,j;
- u64 n;
- const unsigned char *zArg = sqlite3_value_text(argv[0]);
- char *z;
-
- if( zArg==0 ) return;
- for(i=0, n=0; zArg[i]; i++){ if( zArg[i]=='\'' ) n++; }
- z = contextMalloc(context, ((i64)i)+((i64)n)+3);
- if( z ){
- z[0] = '\'';
- for(i=0, j=1; zArg[i]; i++){
- z[j++] = zArg[i];
- if( zArg[i]=='\'' ){
- z[j++] = '\'';
- }
- }
- z[j++] = '\'';
- z[j] = 0;
- sqlite3_result_text(context, z, j, sqlite3_free);
- }
+ const unsigned char *zArg = sqlite3_value_text(pValue);
+ sqlite3_str_appendf(pStr, "%Q", zArg);
break;
}
default: {
- assert( sqlite3_value_type(argv[0])==SQLITE_NULL );
- sqlite3_result_text(context, "NULL", 4, SQLITE_STATIC);
+ assert( sqlite3_value_type(pValue)==SQLITE_NULL );
+ sqlite3_str_append(pStr, "NULL", 4);
break;
}
}
}
/*
+** Implementation of the QUOTE() function.
+**
+** The quote(X) function returns the text of an SQL literal which is the
+** value of its argument suitable for inclusion into an SQL statement.
+** Strings are surrounded by single-quotes with escapes on interior quotes
+** as needed. BLOBs are encoded as hexadecimal literals. Strings with
+** embedded NUL characters cannot be represented as string literals in SQL
+** and hence the returned string literal is truncated prior to the first NUL.
+*/
+static void quoteFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
+ sqlite3_str str;
+ sqlite3 *db = sqlite3_context_db_handle(context);
+ assert( argc==1 );
+ UNUSED_PARAMETER(argc);
+ sqlite3StrAccumInit(&str, db, 0, 0, db->aLimit[SQLITE_LIMIT_LENGTH]);
+ sqlite3QuoteValue(&str,argv[0]);
+ sqlite3_result_text(context, sqlite3StrAccumFinish(&str), str.nChar,
+ SQLITE_DYNAMIC);
+ if( str.accError!=SQLITE_OK ){
+ sqlite3_result_null(context);
+ sqlite3_result_error_code(context, str.accError);
+ }
+}
+
+/*
** The unicode() function. Return the integer unicode code-point value
** for the first character of the input string.
*/
@@ -122376,8 +123280,8 @@ SQLITE_PRIVATE void sqlite3RegisterBuiltinFunctions(void){
INLINE_FUNC(likelihood, 2, INLINEFUNC_unlikely, SQLITE_FUNC_UNLIKELY),
INLINE_FUNC(likely, 1, INLINEFUNC_unlikely, SQLITE_FUNC_UNLIKELY),
#ifdef SQLITE_ENABLE_OFFSET_SQL_FUNC
- FUNCTION2(sqlite_offset, 1, 0, 0, noopFunc, SQLITE_FUNC_OFFSET|
- SQLITE_FUNC_TYPEOF),
+ {1, SQLITE_FUNC_BUILTIN|SQLITE_UTF8|SQLITE_FUNC_OFFSET|SQLITE_FUNC_TYPEOF,
+ 0, 0, noopFunc, 0, 0, 0, "sqlite_offset", {0} },
#endif
FUNCTION(ltrim, 1, 1, 0, trimFunc ),
FUNCTION(ltrim, 2, 1, 0, trimFunc ),
@@ -122394,9 +123298,11 @@ SQLITE_PRIVATE void sqlite3RegisterBuiltinFunctions(void){
WAGGREGATE(max, 1, 1, 1, minmaxStep, minMaxFinalize, minMaxValue, 0,
SQLITE_FUNC_MINMAX|SQLITE_FUNC_ANYORDER ),
FUNCTION2(typeof, 1, 0, 0, typeofFunc, SQLITE_FUNC_TYPEOF),
+ FUNCTION2(subtype, 1, 0, 0, subtypeFunc, SQLITE_FUNC_TYPEOF),
FUNCTION2(length, 1, 0, 0, lengthFunc, SQLITE_FUNC_LENGTH),
FUNCTION(instr, 2, 0, 0, instrFunc ),
FUNCTION(printf, -1, 0, 0, printfFunc ),
+ FUNCTION(format, -1, 0, 0, printfFunc ),
FUNCTION(unicode, 1, 0, 0, unicodeFunc ),
FUNCTION(char, -1, 0, 0, charFunc ),
FUNCTION(abs, 1, 0, 0, absFunc ),
@@ -122495,6 +123401,7 @@ SQLITE_PRIVATE void sqlite3RegisterBuiltinFunctions(void){
#endif
sqlite3WindowFunctions();
sqlite3RegisterDateTimeFunctions();
+ sqlite3RegisterJsonFunctions();
sqlite3InsertBuiltinFuncs(aBuiltinFunc, ArraySize(aBuiltinFunc));
#if 0 /* Enable to print out how the built-in functions are hashed */
@@ -123170,7 +124077,7 @@ static void fkScanChildren(
** clause. For each row found, increment either the deferred or immediate
** foreign key constraint counter. */
if( pParse->nErr==0 ){
- pWInfo = sqlite3WhereBegin(pParse, pSrc, pWhere, 0, 0, 0, 0);
+ pWInfo = sqlite3WhereBegin(pParse, pSrc, pWhere, 0, 0, 0, 0, 0);
sqlite3VdbeAddOp2(v, OP_FkCounter, pFKey->isDeferred, nIncr);
if( pWInfo ){
sqlite3WhereEnd(pWInfo);
@@ -123222,6 +124129,25 @@ static void fkTriggerDelete(sqlite3 *dbMem, Trigger *p){
}
/*
+** Clear the apTrigger[] cache of CASCADE triggers for all foreign keys
+** in a particular database. This needs to happen when the schema
+** changes.
+*/
+SQLITE_PRIVATE void sqlite3FkClearTriggerCache(sqlite3 *db, int iDb){
+ HashElem *k;
+ Hash *pHash = &db->aDb[iDb].pSchema->tblHash;
+ for(k=sqliteHashFirst(pHash); k; k=sqliteHashNext(k)){
+ Table *pTab = sqliteHashData(k);
+ FKey *pFKey;
+ if( !IsOrdinaryTable(pTab) ) continue;
+ for(pFKey=pTab->u.tab.pFKey; pFKey; pFKey=pFKey->pNextFrom){
+ fkTriggerDelete(db, pFKey->apTrigger[0]); pFKey->apTrigger[0] = 0;
+ fkTriggerDelete(db, pFKey->apTrigger[1]); pFKey->apTrigger[1] = 0;
+ }
+ }
+}
+
+/*
** This function is called to generate code that runs when table pTab is
** being dropped from the database. The SrcList passed as the second argument
** to this function contains a single entry guaranteed to resolve to
@@ -124021,7 +124947,7 @@ SQLITE_PRIVATE void sqlite3OpenTable(
}else{
Index *pPk = sqlite3PrimaryKeyIndex(pTab);
assert( pPk!=0 );
- assert( pPk->tnum==pTab->tnum );
+ assert( pPk->tnum==pTab->tnum || CORRUPT_DB );
sqlite3VdbeAddOp3(v, opcode, iCur, pPk->tnum, iDb);
sqlite3VdbeSetP4KeyInfo(pParse, pPk);
VdbeComment((v, "%s", pTab->zName));
@@ -124693,9 +125619,11 @@ SQLITE_PRIVATE void sqlite3Insert(
#endif
db = pParse->db;
- if( pParse->nErr || db->mallocFailed ){
+ assert( db->pParse==pParse );
+ if( pParse->nErr ){
goto insert_cleanup;
}
+ assert( db->mallocFailed==0 );
dest.iSDParm = 0; /* Suppress a harmless compiler warning */
/* If the Select object is really just a simple VALUES() list with a
@@ -124771,7 +125699,11 @@ SQLITE_PRIVATE void sqlite3Insert(
**
** This is the 2nd template.
*/
- if( pColumn==0 && xferOptimization(pParse, pTab, pSelect, onError, iDb) ){
+ if( pColumn==0
+ && pSelect!=0
+ && pTrigger==0
+ && xferOptimization(pParse, pTab, pSelect, onError, iDb)
+ ){
assert( !pTrigger );
assert( pList==0 );
goto insert_end;
@@ -124871,7 +125803,9 @@ SQLITE_PRIVATE void sqlite3Insert(
dest.nSdst = pTab->nCol;
rc = sqlite3Select(pParse, pSelect, &dest);
regFromSelect = dest.iSdst;
- if( rc || db->mallocFailed || pParse->nErr ) goto insert_cleanup;
+ assert( db->pParse==pParse );
+ if( rc || pParse->nErr ) goto insert_cleanup;
+ assert( db->mallocFailed==0 );
sqlite3VdbeEndCoroutine(v, regYield);
sqlite3VdbeJumpHere(v, addrTop - 1); /* label B: */
assert( pSelect->pEList );
@@ -125360,9 +126294,7 @@ insert_end:
** invoke the callback function.
*/
if( regRowCount ){
- sqlite3VdbeAddOp2(v, OP_ChngCntRow, regRowCount, 1);
- sqlite3VdbeSetNumCols(v, 1);
- sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "rows inserted", SQLITE_STATIC);
+ sqlite3CodeChangeCount(v, regRowCount, "rows inserted");
}
insert_cleanup:
@@ -126527,7 +127459,6 @@ SQLITE_PRIVATE void sqlite3CompleteInsertion(
}
pik_flags = (useSeekResult ? OPFLAG_USESEEKRESULT : 0);
if( IsPrimaryKeyIndex(pIdx) && !HasRowid(pTab) ){
- assert( pParse->nested==0 );
pik_flags |= OPFLAG_NCHANGE;
pik_flags |= (update_flags & OPFLAG_SAVEPOSITION);
if( update_flags==0 ){
@@ -126743,18 +127674,13 @@ static int xferOptimization(
int destHasUniqueIdx = 0; /* True if pDest has a UNIQUE index */
int regData, regRowid; /* Registers holding data and rowid */
- if( pSelect==0 ){
- return 0; /* Must be of the form INSERT INTO ... SELECT ... */
- }
+ assert( pSelect!=0 );
if( pParse->pWith || pSelect->pWith ){
/* Do not attempt to process this query if there are an WITH clauses
** attached to it. Proceeding may generate a false "no such table: xxx"
** error if pSelect reads from a CTE named "xxx". */
return 0;
}
- if( sqlite3TriggerList(pParse, pDest) ){
- return 0; /* tab1 must not have triggers */
- }
#ifndef SQLITE_OMIT_VIRTUALTABLE
if( IsVirtual(pDest) ){
return 0; /* tab1 must not be a virtual table */
@@ -127617,6 +128543,13 @@ struct sqlite3_api_routines {
int (*autovacuum_pages)(sqlite3*,
unsigned int(*)(void*,const char*,unsigned int,unsigned int,unsigned int),
void*, void(*)(void*));
+ /* Version 3.38.0 and later */
+ int (*error_offset)(sqlite3*);
+ int (*vtab_rhs_value)(sqlite3_index_info*,int,sqlite3_value**);
+ int (*vtab_distinct)(sqlite3_index_info*);
+ int (*vtab_in)(sqlite3_index_info*,int,int);
+ int (*vtab_in_first)(sqlite3_value*,sqlite3_value**);
+ int (*vtab_in_next)(sqlite3_value*,sqlite3_value**);
};
/*
@@ -127928,6 +128861,13 @@ typedef int (*sqlite3_loadext_entry)(
#define sqlite3_total_changes64 sqlite3_api->total_changes64
/* Version 3.37.0 and later */
#define sqlite3_autovacuum_pages sqlite3_api->autovacuum_pages
+/* Version 3.38.0 and later */
+#define sqlite3_error_offset sqlite3_api->error_offset
+#define sqlite3_vtab_rhs_value sqlite3_api->vtab_rhs_value
+#define sqlite3_vtab_distinct sqlite3_api->vtab_distinct
+#define sqlite3_vtab_in sqlite3_api->vtab_in
+#define sqlite3_vtab_in_first sqlite3_api->vtab_in_first
+#define sqlite3_vtab_in_next sqlite3_api->vtab_in_next
#endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */
#if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)
@@ -128417,6 +129357,13 @@ static const sqlite3_api_routines sqlite3Apis = {
sqlite3_total_changes64,
/* Version 3.37.0 and later */
sqlite3_autovacuum_pages,
+ /* Version 3.38.0 and later */
+ sqlite3_error_offset,
+ sqlite3_vtab_rhs_value,
+ sqlite3_vtab_distinct,
+ sqlite3_vtab_in,
+ sqlite3_vtab_in_first,
+ sqlite3_vtab_in_next
};
/* True if x is the directory separator character
@@ -130718,6 +131665,10 @@ SQLITE_PRIVATE void sqlite3Pragma(
(void)sqlite3_finalize(pDummy);
sqlite3DbFree(db, zSql);
}
+ if( db->mallocFailed ){
+ sqlite3ErrorMsg(db->pParse, "out of memory");
+ db->pParse->rc = SQLITE_NOMEM_BKPT;
+ }
pHash = &db->aDb[ii].pSchema->tblHash;
break;
}
@@ -132754,8 +133705,14 @@ SQLITE_PRIVATE int sqlite3SchemaToIndex(sqlite3 *db, Schema *pSchema){
/*
** Free all memory allocations in the pParse object
*/
-SQLITE_PRIVATE void sqlite3ParserReset(Parse *pParse){
+SQLITE_PRIVATE void sqlite3ParseObjectReset(Parse *pParse){
sqlite3 *db = pParse->db;
+ assert( db!=0 );
+ assert( db->pParse==pParse );
+ assert( pParse->nested==0 );
+#ifndef SQLITE_OMIT_SHARED_CACHE
+ sqlite3DbFree(db, pParse->aTableLock);
+#endif
while( pParse->pCleanup ){
ParseCleanup *pCleanup = pParse->pCleanup;
pParse->pCleanup = pCleanup->pNext;
@@ -132766,11 +133723,12 @@ SQLITE_PRIVATE void sqlite3ParserReset(Parse *pParse){
if( pParse->pConstExpr ){
sqlite3ExprListDelete(db, pParse->pConstExpr);
}
- if( db ){
- assert( db->lookaside.bDisable >= pParse->disableLookaside );
- db->lookaside.bDisable -= pParse->disableLookaside;
- db->lookaside.sz = db->lookaside.bDisable ? 0 : db->lookaside.szTrue;
- }
+ assert( db->lookaside.bDisable >= pParse->disableLookaside );
+ db->lookaside.bDisable -= pParse->disableLookaside;
+ db->lookaside.sz = db->lookaside.bDisable ? 0 : db->lookaside.szTrue;
+ assert( pParse->db->pParse==pParse );
+ db->pParse = pParse->pOuterParse;
+ pParse->db = 0;
pParse->disableLookaside = 0;
}
@@ -132783,7 +133741,7 @@ SQLITE_PRIVATE void sqlite3ParserReset(Parse *pParse){
** cost for this mechansim (an extra malloc), so it should not be used
** for common cleanups that happen on most calls. But for less
** common cleanups, we save a single NULL-pointer comparison in
-** sqlite3ParserReset(), which reduces the total CPU cycle count.
+** sqlite3ParseObjectReset(), which reduces the total CPU cycle count.
**
** If a memory allocation error occurs, then the cleanup happens immediately.
** When either SQLITE_DEBUG or SQLITE_COVERAGE_TEST are defined, the
@@ -132824,6 +133782,25 @@ SQLITE_PRIVATE void *sqlite3ParserAddCleanup(
}
/*
+** Turn bulk memory into a valid Parse object and link that Parse object
+** into database connection db.
+**
+** Call sqlite3ParseObjectReset() to undo this operation.
+**
+** Caution: Do not confuse this routine with sqlite3ParseObjectInit() which
+** is generated by Lemon.
+*/
+SQLITE_PRIVATE void sqlite3ParseObjectInit(Parse *pParse, sqlite3 *db){
+ memset(PARSE_HDR(pParse), 0, PARSE_HDR_SZ);
+ memset(PARSE_TAIL(pParse), 0, PARSE_TAIL_SZ);
+ assert( db->pParse!=pParse );
+ pParse->pOuterParse = db->pParse;
+ db->pParse = pParse;
+ pParse->db = db;
+ if( db->mallocFailed ) sqlite3ErrorMsg(pParse, "out of memory");
+}
+
+/*
** Compile the UTF-8 encoded SQL statement zSql into a statement handle.
*/
static int sqlite3Prepare(
@@ -132835,16 +133812,19 @@ static int sqlite3Prepare(
sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
const char **pzTail /* OUT: End of parsed string */
){
- char *zErrMsg = 0; /* Error message */
int rc = SQLITE_OK; /* Result code */
int i; /* Loop counter */
Parse sParse; /* Parsing context */
- memset(&sParse, 0, PARSE_HDR_SZ);
+ /* sqlite3ParseObjectInit(&sParse, db); // inlined for performance */
+ memset(PARSE_HDR(&sParse), 0, PARSE_HDR_SZ);
memset(PARSE_TAIL(&sParse), 0, PARSE_TAIL_SZ);
+ sParse.pOuterParse = db->pParse;
+ db->pParse = &sParse;
+ sParse.db = db;
sParse.pReprepare = pReprepare;
assert( ppStmt && *ppStmt==0 );
- /* assert( !db->mallocFailed ); // not true with SQLITE_USE_ALLOCA */
+ if( db->mallocFailed ) sqlite3ErrorMsg(&sParse, "out of memory");
assert( sqlite3_mutex_held(db->mutex) );
/* For a long-term use prepared statement avoid the use of
@@ -132897,7 +133877,6 @@ static int sqlite3Prepare(
sqlite3VtabUnlockList(db);
- sParse.db = db;
if( nBytes>=0 && (nBytes==0 || zSql[nBytes-1]!=0) ){
char *zSqlCopy;
int mxLen = db->aLimit[SQLITE_LIMIT_SQL_LENGTH];
@@ -132910,14 +133889,14 @@ static int sqlite3Prepare(
}
zSqlCopy = sqlite3DbStrNDup(db, zSql, nBytes);
if( zSqlCopy ){
- sqlite3RunParser(&sParse, zSqlCopy, &zErrMsg);
+ sqlite3RunParser(&sParse, zSqlCopy);
sParse.zTail = &zSql[sParse.zTail-zSqlCopy];
sqlite3DbFree(db, zSqlCopy);
}else{
sParse.zTail = &zSql[nBytes];
}
}else{
- sqlite3RunParser(&sParse, zSql, &zErrMsg);
+ sqlite3RunParser(&sParse, zSql);
}
assert( 0==sParse.nQueryLoop );
@@ -132933,7 +133912,7 @@ static int sqlite3Prepare(
sParse.checkSchema = 0;
}
if( sParse.rc!=SQLITE_OK && sParse.rc!=SQLITE_DONE ){
- if( sParse.checkSchema ){
+ if( sParse.checkSchema && db->init.busy==0 ){
schemaIsValid(&sParse);
}
if( sParse.pVdbe ){
@@ -132941,14 +133920,14 @@ static int sqlite3Prepare(
}
assert( 0==(*ppStmt) );
rc = sParse.rc;
- if( zErrMsg ){
- sqlite3ErrorWithMsg(db, rc, "%s", zErrMsg);
- sqlite3DbFree(db, zErrMsg);
+ if( sParse.zErrMsg ){
+ sqlite3ErrorWithMsg(db, rc, "%s", sParse.zErrMsg);
+ sqlite3DbFree(db, sParse.zErrMsg);
}else{
sqlite3Error(db, rc);
}
}else{
- assert( zErrMsg==0 );
+ assert( sParse.zErrMsg==0 );
*ppStmt = (sqlite3_stmt*)sParse.pVdbe;
rc = SQLITE_OK;
sqlite3ErrorClear(db);
@@ -132964,7 +133943,7 @@ static int sqlite3Prepare(
end_prepare:
- sqlite3ParserReset(&sParse);
+ sqlite3ParseObjectReset(&sParse);
return rc;
}
static int sqlite3LockAndPrepare(
@@ -133569,14 +134548,14 @@ static void addWhereTerm(
ExprSetProperty(pEq, EP_FromJoin);
assert( !ExprHasProperty(pEq, EP_TokenOnly|EP_Reduced) );
ExprSetVVAProperty(pEq, EP_NoReduce);
- pEq->iRightJoinTable = pE2->iTable;
+ pEq->w.iRightJoinTable = pE2->iTable;
}
*ppWhere = sqlite3ExprAnd(pParse, *ppWhere, pEq);
}
/*
** Set the EP_FromJoin property on all terms of the given expression.
-** And set the Expr.iRightJoinTable to iTable for every term in the
+** And set the Expr.w.iRightJoinTable to iTable for every term in the
** expression.
**
** The EP_FromJoin property is used on terms of an expression to tell
@@ -133586,8 +134565,8 @@ static void addWhereTerm(
** WHERE clause during join processing but we need to remember that they
** originated in the ON or USING clause.
**
-** The Expr.iRightJoinTable tells the WHERE clause processing that the
-** expression depends on table iRightJoinTable even if that table is not
+** The Expr.w.iRightJoinTable tells the WHERE clause processing that the
+** expression depends on table w.iRightJoinTable even if that table is not
** explicitly mentioned in the expression. That information is needed
** for cases like this:
**
@@ -133605,7 +134584,7 @@ SQLITE_PRIVATE void sqlite3SetJoinExpr(Expr *p, int iTable){
ExprSetProperty(p, EP_FromJoin);
assert( !ExprHasProperty(p, EP_TokenOnly|EP_Reduced) );
ExprSetVVAProperty(p, EP_NoReduce);
- p->iRightJoinTable = iTable;
+ p->w.iRightJoinTable = iTable;
if( p->op==TK_FUNCTION ){
assert( ExprUseXList(p) );
if( p->x.pList ){
@@ -133621,7 +134600,7 @@ SQLITE_PRIVATE void sqlite3SetJoinExpr(Expr *p, int iTable){
}
/* Undo the work of sqlite3SetJoinExpr(). In the expression p, convert every
-** term that is marked with EP_FromJoin and iRightJoinTable==iTable into
+** term that is marked with EP_FromJoin and w.iRightJoinTable==iTable into
** an ordinary term that omits the EP_FromJoin mark.
**
** This happens when a LEFT JOIN is simplified into an ordinary JOIN.
@@ -133629,7 +134608,7 @@ SQLITE_PRIVATE void sqlite3SetJoinExpr(Expr *p, int iTable){
static void unsetJoinExpr(Expr *p, int iTable){
while( p ){
if( ExprHasProperty(p, EP_FromJoin)
- && (iTable<0 || p->iRightJoinTable==iTable) ){
+ && (iTable<0 || p->w.iRightJoinTable==iTable) ){
ExprClearProperty(p, EP_FromJoin);
}
if( p->op==TK_COLUMN && p->iTable==iTable ){
@@ -134619,7 +135598,7 @@ SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoAlloc(sqlite3 *db, int N, int X){
p->nRef = 1;
memset(&p[1], 0, nExtra);
}else{
- sqlite3OomFault(db);
+ return (KeyInfo*)sqlite3OomFault(db);
}
return p;
}
@@ -134790,6 +135769,9 @@ static void generateSortTail(
iTab = pSort->iECursor;
if( eDest==SRT_Output || eDest==SRT_Coroutine || eDest==SRT_Mem ){
+ if( eDest==SRT_Mem && p->iOffset ){
+ sqlite3VdbeAddOp2(v, OP_Null, 0, pDest->iSdst);
+ }
regRowid = 0;
regRow = pDest->iSdst;
}else{
@@ -136511,6 +137493,8 @@ static int multiSelectOrderBy(
){
int i, j; /* Loop counters */
Select *pPrior; /* Another SELECT immediately to our left */
+ Select *pSplit; /* Left-most SELECT in the right-hand group */
+ int nSelect; /* Number of SELECT statements in the compound */
Vdbe *v; /* Generate code to this VDBE */
SelectDest destA; /* Destination for coroutine A */
SelectDest destB; /* Destination for coroutine B */
@@ -136556,8 +137540,7 @@ static int multiSelectOrderBy(
/* Patch up the ORDER BY clause
*/
op = p->op;
- pPrior = p->pPrior;
- assert( pPrior->pOrderBy==0 );
+ assert( p->pPrior->pOrderBy==0 );
pOrderBy = p->pOrderBy;
assert( pOrderBy );
nOrderBy = pOrderBy->nExpr;
@@ -136607,11 +137590,6 @@ static int multiSelectOrderBy(
pKeyMerge = 0;
}
- /* Reattach the ORDER BY clause to the query.
- */
- p->pOrderBy = pOrderBy;
- pPrior->pOrderBy = sqlite3ExprListDup(pParse->db, pOrderBy, 0);
-
/* Allocate a range of temporary registers and the KeyInfo needed
** for the logic that removes duplicate result rows when the
** operator is UNION, EXCEPT, or INTERSECT (but not UNION ALL).
@@ -136636,12 +137614,30 @@ static int multiSelectOrderBy(
/* Separate the left and the right query from one another
*/
- p->pPrior = 0;
+ nSelect = 1;
+ if( (op==TK_ALL || op==TK_UNION)
+ && OptimizationEnabled(db, SQLITE_BalancedMerge)
+ ){
+ for(pSplit=p; pSplit->pPrior!=0 && pSplit->op==op; pSplit=pSplit->pPrior){
+ nSelect++;
+ assert( pSplit->pPrior->pNext==pSplit );
+ }
+ }
+ if( nSelect<=3 ){
+ pSplit = p;
+ }else{
+ pSplit = p;
+ for(i=2; i<nSelect; i+=2){ pSplit = pSplit->pPrior; }
+ }
+ pPrior = pSplit->pPrior;
+ assert( pPrior!=0 );
+ pSplit->pPrior = 0;
pPrior->pNext = 0;
+ assert( p->pOrderBy == pOrderBy );
+ assert( pOrderBy!=0 || db->mallocFailed );
+ pPrior->pOrderBy = sqlite3ExprListDup(pParse->db, pOrderBy, 0);
sqlite3ResolveOrderGroupBy(pParse, p, p->pOrderBy, "ORDER");
- if( pPrior->pPrior==0 ){
- sqlite3ResolveOrderGroupBy(pParse, pPrior, pPrior->pOrderBy, "ORDER");
- }
+ sqlite3ResolveOrderGroupBy(pParse, pPrior, pPrior->pOrderBy, "ORDER");
/* Compute the limit registers */
computeLimitRegisters(pParse, p, labelEnd);
@@ -136792,12 +137788,11 @@ static int multiSelectOrderBy(
/* Reassembly the compound query so that it will be freed correctly
** by the calling function */
- if( p->pPrior ){
- sqlite3SelectDelete(db, p->pPrior);
+ if( pSplit->pPrior ){
+ sqlite3SelectDelete(db, pSplit->pPrior);
}
- p->pPrior = pPrior;
- pPrior->pNext = p;
-
+ pSplit->pPrior = pPrior;
+ pPrior->pNext = pSplit;
sqlite3ExprListDelete(db, pPrior->pOrderBy);
pPrior->pOrderBy = 0;
@@ -136847,9 +137842,9 @@ static Expr *substExpr(
){
if( pExpr==0 ) return 0;
if( ExprHasProperty(pExpr, EP_FromJoin)
- && pExpr->iRightJoinTable==pSubst->iTable
+ && pExpr->w.iRightJoinTable==pSubst->iTable
){
- pExpr->iRightJoinTable = pSubst->iNewTable;
+ pExpr->w.iRightJoinTable = pSubst->iNewTable;
}
if( pExpr->op==TK_COLUMN
&& pExpr->iTable==pSubst->iTable
@@ -136888,7 +137883,7 @@ static Expr *substExpr(
ExprSetProperty(pNew, EP_CanBeNull);
}
if( ExprHasProperty(pExpr,EP_FromJoin) ){
- sqlite3SetJoinExpr(pNew, pExpr->iRightJoinTable);
+ sqlite3SetJoinExpr(pNew, pExpr->w.iRightJoinTable);
}
sqlite3ExprDelete(db, pExpr);
pExpr = pNew;
@@ -137053,7 +138048,7 @@ static int renumberCursorsCb(Walker *pWalker, Expr *pExpr){
renumberCursorDoMapping(pWalker, &pExpr->iTable);
}
if( ExprHasProperty(pExpr, EP_FromJoin) ){
- renumberCursorDoMapping(pWalker, &pExpr->iRightJoinTable);
+ renumberCursorDoMapping(pWalker, &pExpr->w.iRightJoinTable);
}
return WRC_Continue;
}
@@ -138063,11 +139058,13 @@ static int pushDownWhereTerms(
}
if( isLeftJoin
&& (ExprHasProperty(pWhere,EP_FromJoin)==0
- || pWhere->iRightJoinTable!=iCursor)
+ || pWhere->w.iRightJoinTable!=iCursor)
){
return 0; /* restriction (4) */
}
- if( ExprHasProperty(pWhere,EP_FromJoin) && pWhere->iRightJoinTable!=iCursor ){
+ if( ExprHasProperty(pWhere,EP_FromJoin)
+ && pWhere->w.iRightJoinTable!=iCursor
+ ){
return 0; /* restriction (5) */
}
if( sqlite3ExprIsTableConstant(pWhere, iCursor) ){
@@ -138787,7 +139784,8 @@ static int selectExpander(Walker *pWalker, Select *p){
/* Process NATURAL keywords, and ON and USING clauses of joins.
*/
- if( pParse->nErr || db->mallocFailed || sqliteProcessJoin(pParse, p) ){
+ assert( db->mallocFailed==0 || pParse->nErr!=0 );
+ if( pParse->nErr || sqliteProcessJoin(pParse, p) ){
return WRC_Abort;
}
@@ -139084,12 +140082,13 @@ SQLITE_PRIVATE void sqlite3SelectPrep(
NameContext *pOuterNC /* Name context for container */
){
assert( p!=0 || pParse->db->mallocFailed );
+ assert( pParse->db->pParse==pParse );
if( pParse->db->mallocFailed ) return;
if( p->selFlags & SF_HasTypeInfo ) return;
sqlite3SelectExpand(pParse, p);
- if( pParse->nErr || pParse->db->mallocFailed ) return;
+ if( pParse->nErr ) return;
sqlite3ResolveSelectNames(pParse, p, pOuterNC);
- if( pParse->nErr || pParse->db->mallocFailed ) return;
+ if( pParse->nErr ) return;
sqlite3SelectAddTypeInfo(pParse, p);
}
@@ -139106,8 +140105,10 @@ static void resetAccumulator(Parse *pParse, AggInfo *pAggInfo){
int i;
struct AggInfo_func *pFunc;
int nReg = pAggInfo->nFunc + pAggInfo->nColumn;
+ assert( pParse->db->pParse==pParse );
+ assert( pParse->db->mallocFailed==0 || pParse->nErr!=0 );
if( nReg==0 ) return;
- if( pParse->nErr || pParse->db->mallocFailed ) return;
+ if( pParse->nErr ) return;
#ifdef SQLITE_DEBUG
/* Verify that all AggInfo registers are within the range specified by
** AggInfo.mnReg..AggInfo.mxReg */
@@ -139530,10 +140531,12 @@ SQLITE_PRIVATE int sqlite3Select(
u8 minMaxFlag; /* Flag for min/max queries */
db = pParse->db;
+ assert( pParse==db->pParse );
v = sqlite3GetVdbe(pParse);
- if( p==0 || db->mallocFailed || pParse->nErr ){
+ if( p==0 || pParse->nErr ){
return 1;
}
+ assert( db->mallocFailed==0 );
if( sqlite3AuthCheck(pParse, SQLITE_SELECT, 0, 0, 0) ) return 1;
#if SELECTTRACE_ENABLED
SELECTTRACE(1,pParse,p, ("begin processing:\n", pParse->addrExplain));
@@ -139568,9 +140571,10 @@ SQLITE_PRIVATE int sqlite3Select(
p->selFlags |= SF_NoopOrderBy;
}
sqlite3SelectPrep(pParse, p, 0);
- if( pParse->nErr || db->mallocFailed ){
+ if( pParse->nErr ){
goto select_end;
}
+ assert( db->mallocFailed==0 );
assert( p->pEList!=0 );
#if SELECTTRACE_ENABLED
if( sqlite3SelectTrace & 0x104 ){
@@ -139614,7 +140618,7 @@ SQLITE_PRIVATE int sqlite3Select(
#ifndef SQLITE_OMIT_WINDOWFUNC
if( sqlite3WindowRewrite(pParse, p) ){
- assert( db->mallocFailed || pParse->nErr>0 );
+ assert( pParse->nErr );
goto select_end;
}
#if SELECTTRACE_ENABLED
@@ -140090,7 +141094,7 @@ SQLITE_PRIVATE int sqlite3Select(
/* Begin the database scan. */
SELECTTRACE(1,pParse,p,("WhereBegin\n"));
pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, sSort.pOrderBy,
- p->pEList, wctrlFlags, p->nSelectRow);
+ p->pEList, p, wctrlFlags, p->nSelectRow);
if( pWInfo==0 ) goto select_end;
if( sqlite3WhereOutputRowCount(pWInfo) < p->nSelectRow ){
p->nSelectRow = sqlite3WhereOutputRowCount(pWInfo);
@@ -140354,7 +141358,7 @@ SQLITE_PRIVATE int sqlite3Select(
sqlite3VdbeAddOp2(v, OP_Gosub, regReset, addrReset);
SELECTTRACE(1,pParse,p,("WhereBegin\n"));
pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, pGroupBy, pDistinct,
- WHERE_GROUPBY | (orderByGrp ? WHERE_SORTBYGROUP : 0) | distFlag, 0
+ 0, (WHERE_GROUPBY|(orderByGrp ? WHERE_SORTBYGROUP : 0)|distFlag), 0
);
if( pWInfo==0 ){
sqlite3ExprListDelete(db, pDistinct);
@@ -140652,7 +141656,7 @@ SQLITE_PRIVATE int sqlite3Select(
SELECTTRACE(1,pParse,p,("WhereBegin\n"));
pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, pMinMaxOrderBy,
- pDistinct, minMaxFlag|distFlag, 0);
+ pDistinct, 0, minMaxFlag|distFlag, 0);
if( pWInfo==0 ){
goto select_end;
}
@@ -140709,7 +141713,7 @@ SQLITE_PRIVATE int sqlite3Select(
*/
select_end:
assert( db->mallocFailed==0 || db->mallocFailed==1 );
- pParse->nErr += db->mallocFailed;
+ assert( db->mallocFailed==0 || pParse->nErr!=0 );
sqlite3ExprListDelete(db, pMinMaxOrderBy);
#ifdef SQLITE_DEBUG
if( pAggInfo && !db->mallocFailed ){
@@ -141389,6 +142393,7 @@ static TriggerStep *triggerStepAllocate(
sqlite3 *db = pParse->db;
TriggerStep *pTriggerStep;
+ if( pParse->nErr ) return 0;
pTriggerStep = sqlite3DbMallocZero(db, sizeof(TriggerStep) + pName->n + 1);
if( pTriggerStep ){
char *z = (char*)&pTriggerStep[1];
@@ -141861,6 +142866,7 @@ static void codeReturningTrigger(
assert( v!=0 );
assert( pParse->bReturning );
+ assert( db->pParse==pParse );
pReturning = pParse->u1.pReturning;
assert( pTrigger == &(pReturning->retTrig) );
memset(&sSelect, 0, sizeof(sSelect));
@@ -141871,12 +142877,13 @@ static void codeReturningTrigger(
sFrom.a[0].pTab = pTab;
sFrom.a[0].iCursor = -1;
sqlite3SelectPrep(pParse, &sSelect, 0);
- if( db->mallocFailed==0 && pParse->nErr==0 ){
+ if( pParse->nErr==0 ){
+ assert( db->mallocFailed==0 );
sqlite3GenerateColumnNames(pParse, &sSelect);
}
sqlite3ExprListDelete(db, sSelect.pEList);
pNew = sqlite3ExpandReturning(pParse, pReturning->pReturnEL, pTab);
- if( pNew ){
+ if( !db->mallocFailed ){
NameContext sNC;
memset(&sNC, 0, sizeof(sNC));
if( pReturning->nRetCol==0 ){
@@ -141888,7 +142895,9 @@ static void codeReturningTrigger(
sNC.ncFlags = NC_UBaseReg;
pParse->eTriggerOp = pTrigger->op;
pParse->pTriggerTab = pTab;
- if( sqlite3ResolveExprListNames(&sNC, pNew)==SQLITE_OK ){
+ if( sqlite3ResolveExprListNames(&sNC, pNew)==SQLITE_OK
+ && ALWAYS(!db->mallocFailed)
+ ){
int i;
int nCol = pNew->nExpr;
int reg = pParse->nMem+1;
@@ -141896,16 +142905,20 @@ static void codeReturningTrigger(
pReturning->iRetReg = reg;
for(i=0; i<nCol; i++){
Expr *pCol = pNew->a[i].pExpr;
+ assert( pCol!=0 ); /* Due to !db->mallocFailed ~9 lines above */
sqlite3ExprCodeFactorable(pParse, pCol, reg+i);
+ if( sqlite3ExprAffinity(pCol)==SQLITE_AFF_REAL ){
+ sqlite3VdbeAddOp1(v, OP_RealAffinity, reg+i);
+ }
}
sqlite3VdbeAddOp3(v, OP_MakeRecord, reg, i, reg+i);
sqlite3VdbeAddOp2(v, OP_NewRowid, pReturning->iRetCur, reg+i+1);
sqlite3VdbeAddOp3(v, OP_Insert, pReturning->iRetCur, reg+i, reg+i+1);
}
- sqlite3ExprListDelete(db, pNew);
- pParse->eTriggerOp = 0;
- pParse->pTriggerTab = 0;
}
+ sqlite3ExprListDelete(db, pNew);
+ pParse->eTriggerOp = 0;
+ pParse->pTriggerTab = 0;
}
@@ -142047,8 +143060,8 @@ static TriggerPrg *codeRowTrigger(
Vdbe *v; /* Temporary VM */
NameContext sNC; /* Name context for sub-vdbe */
SubProgram *pProgram = 0; /* Sub-vdbe for trigger program */
- Parse *pSubParse; /* Parse context for sub-vdbe */
int iEndTrigger = 0; /* Label to jump to if WHEN is false */
+ Parse sSubParse; /* Parse context for sub-vdbe */
assert( pTrigger->zName==0 || pTab==tableOfTrigger(pTrigger) );
assert( pTop->pVdbe );
@@ -142070,19 +143083,17 @@ static TriggerPrg *codeRowTrigger(
/* Allocate and populate a new Parse context to use for coding the
** trigger sub-program. */
- pSubParse = sqlite3StackAllocZero(db, sizeof(Parse));
- if( !pSubParse ) return 0;
+ sqlite3ParseObjectInit(&sSubParse, db);
memset(&sNC, 0, sizeof(sNC));
- sNC.pParse = pSubParse;
- pSubParse->db = db;
- pSubParse->pTriggerTab = pTab;
- pSubParse->pToplevel = pTop;
- pSubParse->zAuthContext = pTrigger->zName;
- pSubParse->eTriggerOp = pTrigger->op;
- pSubParse->nQueryLoop = pParse->nQueryLoop;
- pSubParse->disableVtab = pParse->disableVtab;
-
- v = sqlite3GetVdbe(pSubParse);
+ sNC.pParse = &sSubParse;
+ sSubParse.pTriggerTab = pTab;
+ sSubParse.pToplevel = pTop;
+ sSubParse.zAuthContext = pTrigger->zName;
+ sSubParse.eTriggerOp = pTrigger->op;
+ sSubParse.nQueryLoop = pParse->nQueryLoop;
+ sSubParse.disableVtab = pParse->disableVtab;
+
+ v = sqlite3GetVdbe(&sSubParse);
if( v ){
VdbeComment((v, "Start: %s.%s (%s %s%s%s ON %s)",
pTrigger->zName, onErrorText(orconf),
@@ -142108,14 +143119,14 @@ static TriggerPrg *codeRowTrigger(
if( db->mallocFailed==0
&& SQLITE_OK==sqlite3ResolveExprNames(&sNC, pWhen)
){
- iEndTrigger = sqlite3VdbeMakeLabel(pSubParse);
- sqlite3ExprIfFalse(pSubParse, pWhen, iEndTrigger, SQLITE_JUMPIFNULL);
+ iEndTrigger = sqlite3VdbeMakeLabel(&sSubParse);
+ sqlite3ExprIfFalse(&sSubParse, pWhen, iEndTrigger, SQLITE_JUMPIFNULL);
}
sqlite3ExprDelete(db, pWhen);
}
/* Code the trigger program into the sub-vdbe. */
- codeTriggerProgram(pSubParse, pTrigger->step_list, orconf);
+ codeTriggerProgram(&sSubParse, pTrigger->step_list, orconf);
/* Insert an OP_Halt at the end of the sub-program. */
if( iEndTrigger ){
@@ -142123,23 +143134,24 @@ static TriggerPrg *codeRowTrigger(
}
sqlite3VdbeAddOp0(v, OP_Halt);
VdbeComment((v, "End: %s.%s", pTrigger->zName, onErrorText(orconf)));
+ transferParseError(pParse, &sSubParse);
- transferParseError(pParse, pSubParse);
- if( db->mallocFailed==0 && pParse->nErr==0 ){
+ if( pParse->nErr==0 ){
+ assert( db->mallocFailed==0 );
pProgram->aOp = sqlite3VdbeTakeOpArray(v, &pProgram->nOp, &pTop->nMaxArg);
}
- pProgram->nMem = pSubParse->nMem;
- pProgram->nCsr = pSubParse->nTab;
+ pProgram->nMem = sSubParse.nMem;
+ pProgram->nCsr = sSubParse.nTab;
pProgram->token = (void *)pTrigger;
- pPrg->aColmask[0] = pSubParse->oldmask;
- pPrg->aColmask[1] = pSubParse->newmask;
+ pPrg->aColmask[0] = sSubParse.oldmask;
+ pPrg->aColmask[1] = sSubParse.newmask;
sqlite3VdbeDelete(v);
+ }else{
+ transferParseError(pParse, &sSubParse);
}
- assert( !pSubParse->pTriggerPrg && !pSubParse->nMaxArg );
- sqlite3ParserReset(pSubParse);
- sqlite3StackFree(db, pSubParse);
-
+ assert( !sSubParse.pTriggerPrg && !sSubParse.nMaxArg );
+ sqlite3ParseObjectReset(&sSubParse);
return pPrg;
}
@@ -142172,6 +143184,7 @@ static TriggerPrg *getRowTrigger(
/* If an existing TriggerPrg could not be located, create a new one. */
if( !pPrg ){
pPrg = codeRowTrigger(pParse, pTrigger, pTab, orconf);
+ pParse->db->errByteOffset = -1;
}
return pPrg;
@@ -142194,7 +143207,7 @@ SQLITE_PRIVATE void sqlite3CodeRowTriggerDirect(
Vdbe *v = sqlite3GetVdbe(pParse); /* Main VM */
TriggerPrg *pPrg;
pPrg = getRowTrigger(pParse, p, pTab, orconf);
- assert( pPrg || pParse->nErr || pParse->db->mallocFailed );
+ assert( pPrg || pParse->nErr );
/* Code the OP_Program opcode in the parent VDBE. P4 of the OP_Program
** is a pointer to the sub-vdbe containing the trigger program. */
@@ -142712,9 +143725,11 @@ SQLITE_PRIVATE void sqlite3Update(
memset(&sContext, 0, sizeof(sContext));
db = pParse->db;
- if( pParse->nErr || db->mallocFailed ){
+ assert( db->pParse==pParse );
+ if( pParse->nErr ){
goto update_cleanup;
}
+ assert( db->mallocFailed==0 );
/* Locate the table which we want to update.
*/
@@ -143086,7 +144101,7 @@ SQLITE_PRIVATE void sqlite3Update(
if( !pParse->nested && !pTrigger && !hasFK && !chngKey && !bReplace ){
flags |= WHERE_ONEPASS_MULTIROW;
}
- pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, 0, 0, flags,iIdxCur);
+ pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere,0,0,0,flags,iIdxCur);
if( pWInfo==0 ) goto update_cleanup;
/* A one-pass strategy that might update more than one row may not
@@ -143486,9 +144501,7 @@ SQLITE_PRIVATE void sqlite3Update(
** that information.
*/
if( regRowCount ){
- sqlite3VdbeAddOp2(v, OP_ChngCntRow, regRowCount, 1);
- sqlite3VdbeSetNumCols(v, 1);
- sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "rows updated", SQLITE_STATIC);
+ sqlite3CodeChangeCount(v, regRowCount, "rows updated");
}
update_cleanup:
@@ -143610,7 +144623,9 @@ static void updateVirtualTable(
regRowid = ++pParse->nMem;
/* Start scanning the virtual table */
- pWInfo = sqlite3WhereBegin(pParse, pSrc,pWhere,0,0,WHERE_ONEPASS_DESIRED,0);
+ pWInfo = sqlite3WhereBegin(
+ pParse, pSrc, pWhere, 0, 0, 0, WHERE_ONEPASS_DESIRED, 0
+ );
if( pWInfo==0 ) return;
/* Populate the argument registers. */
@@ -145237,7 +146252,6 @@ SQLITE_API int sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable){
VtabCtx *pCtx;
int rc = SQLITE_OK;
Table *pTab;
- char *zErr = 0;
Parse sParse;
int initBusy;
@@ -145256,9 +146270,8 @@ SQLITE_API int sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable){
pTab = pCtx->pTab;
assert( IsVirtual(pTab) );
- memset(&sParse, 0, sizeof(sParse));
+ sqlite3ParseObjectInit(&sParse, db);
sParse.eParseMode = PARSE_MODE_DECLARE_VTAB;
- sParse.db = db;
/* We should never be able to reach this point while loading the
** schema. Nevertheless, defend against that (turn off db->init.busy)
** in case a bug arises. */
@@ -145266,11 +146279,12 @@ SQLITE_API int sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable){
initBusy = db->init.busy;
db->init.busy = 0;
sParse.nQueryLoop = 1;
- if( SQLITE_OK==sqlite3RunParser(&sParse, zCreateTable, &zErr)
- && sParse.pNewTable
- && !db->mallocFailed
+ if( SQLITE_OK==sqlite3RunParser(&sParse, zCreateTable)
+ && ALWAYS(sParse.pNewTable!=0)
+ && ALWAYS(!db->mallocFailed)
&& IsOrdinaryTable(sParse.pNewTable)
){
+ assert( sParse.zErrMsg==0 );
if( !pTab->aCol ){
Table *pNew = sParse.pNewTable;
Index *pIdx;
@@ -145300,8 +146314,9 @@ SQLITE_API int sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable){
}
pCtx->bDeclared = 1;
}else{
- sqlite3ErrorWithMsg(db, SQLITE_ERROR, (zErr ? "%s" : 0), zErr);
- sqlite3DbFree(db, zErr);
+ sqlite3ErrorWithMsg(db, SQLITE_ERROR,
+ (sParse.zErrMsg ? "%s" : 0), sParse.zErrMsg);
+ sqlite3DbFree(db, sParse.zErrMsg);
rc = SQLITE_ERROR;
}
sParse.eParseMode = PARSE_MODE_NORMAL;
@@ -145310,7 +146325,7 @@ SQLITE_API int sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable){
sqlite3VdbeFinalize(sParse.pVdbe);
}
sqlite3DeleteTable(db, sParse.pNewTable);
- sqlite3ParserReset(&sParse);
+ sqlite3ParseObjectReset(&sParse);
db->init.busy = initBusy;
assert( (rc&0xff)==rc );
@@ -145862,6 +146877,7 @@ struct WhereLevel {
u32 iLikeRepCntr; /* LIKE range processing counter register (times 2) */
int addrLikeRep; /* LIKE range processing address */
#endif
+ int regFilter; /* Bloom filter */
u8 iFrom; /* Which entry in the FROM clause */
u8 op, p3, p5; /* Opcode, P3 & P5 of the opcode that ends the loop */
int p1, p2; /* Operands of the opcode used to end the loop */
@@ -145920,10 +146936,12 @@ struct WhereLoop {
} btree;
struct { /* Information for virtual tables */
int idxNum; /* Index number */
- u8 needFree; /* True if sqlite3_free(idxStr) is needed */
+ u32 needFree : 1; /* True if sqlite3_free(idxStr) is needed */
+ u32 bOmitOffset : 1; /* True to let virtual table handle offset */
i8 isOrdered; /* True if satisfies ORDER BY */
u16 omitMask; /* Terms that may be omitted */
char *idxStr; /* Index identifier string */
+ u32 mHandleIn; /* Terms to handle as IN(...) instead of == */
} vtab;
} u;
u32 wsFlags; /* WHERE_* flags describing the plan */
@@ -146067,7 +147085,7 @@ struct WhereTerm {
#define TERM_COPIED 0x0008 /* Has a child */
#define TERM_ORINFO 0x0010 /* Need to free the WhereTerm.u.pOrInfo object */
#define TERM_ANDINFO 0x0020 /* Need to free the WhereTerm.u.pAndInfo obj */
-#define TERM_OR_OK 0x0040 /* Used during OR-clause processing */
+#define TERM_OK 0x0040 /* Used during OR-clause processing */
#define TERM_VNULL 0x0080 /* Manufactured x>NULL or x<=NULL term */
#define TERM_LIKEOPT 0x0100 /* Virtual terms from the LIKE optimization */
#define TERM_LIKECOND 0x0200 /* Conditionally this LIKE operator term */
@@ -146080,6 +147098,7 @@ struct WhereTerm {
#else
# define TERM_HIGHTRUTH 0 /* Only used with STAT4 */
#endif
+#define TERM_SLICE 0x8000 /* One slice of a row-value/vector comparison */
/*
** An instance of the WhereScan object is used as an iterator for locating
@@ -146090,11 +147109,11 @@ struct WhereScan {
WhereClause *pWC; /* WhereClause currently being scanned */
const char *zCollName; /* Required collating sequence, if not NULL */
Expr *pIdxExpr; /* Search for this index expression */
+ int k; /* Resume scanning at this->pWC->a[this->k] */
+ u32 opMask; /* Acceptable operators */
char idxaff; /* Must match this affinity, if zCollName!=NULL */
+ unsigned char iEquiv; /* Current slot in aiCur[] and aiColumn[] */
unsigned char nEquiv; /* Number of entries in aiCur[] and aiColumn[] */
- unsigned char iEquiv; /* Next unused slot in aiCur[] and aiColumn[] */
- u32 opMask; /* Acceptable operators */
- int k; /* Resume scanning at this->pWC->a[this->k] */
int aiCur[11]; /* Cursors in the equivalence class */
i16 aiColumn[11]; /* Corresponding column number in the eq-class */
};
@@ -146118,6 +147137,7 @@ struct WhereClause {
u8 hasOr; /* True if any a[].eOperator is WO_OR */
int nTerm; /* Number of terms */
int nSlot; /* Number of entries in a[] */
+ int nBase; /* Number of terms through the last non-Virtual */
WhereTerm *a; /* Each a[] describes a term of the WHERE cluase */
#if defined(SQLITE_SMALL_STACK)
WhereTerm aStatic[1]; /* Initial static space for a[] */
@@ -146176,18 +147196,12 @@ struct WhereMaskSet {
};
/*
-** Initialize a WhereMaskSet object
-*/
-#define initMaskSet(P) (P)->n=0
-
-/*
** This object is a convenience wrapper holding all information needed
** to construct WhereLoop objects for a particular query.
*/
struct WhereLoopBuilder {
WhereInfo *pWInfo; /* Information about this WHERE */
WhereClause *pWC; /* WHERE clause terms */
- ExprList *pOrderBy; /* ORDER BY clause */
WhereLoop *pNew; /* Template WhereLoop */
WhereOrSet *pOrSet; /* Record best loops here, if not NULL */
#ifdef SQLITE_ENABLE_STAT4
@@ -146255,6 +147269,9 @@ struct WhereInfo {
ExprList *pOrderBy; /* The ORDER BY clause or NULL */
ExprList *pResultSet; /* Result set of the query */
Expr *pWhere; /* The complete WHERE clause */
+#ifndef SQLITE_OMIT_VIRTUALTABLE
+ Select *pLimit; /* Used to access LIMIT expr/registers for vtabs */
+#endif
int aiCurOnePass[2]; /* OP_OpenWrite cursors for the ONEPASS opt */
int iContinue; /* Jump here to continue with next record */
int iBreak; /* Jump here to break out of the loop */
@@ -146308,8 +147325,14 @@ SQLITE_PRIVATE int sqlite3WhereExplainOneScan(
WhereLevel *pLevel, /* Scan to write OP_Explain opcode for */
u16 wctrlFlags /* Flags passed to sqlite3WhereBegin() */
);
+SQLITE_PRIVATE int sqlite3WhereExplainBloomFilter(
+ const Parse *pParse, /* Parse context */
+ const WhereInfo *pWInfo, /* WHERE clause */
+ const WhereLevel *pLevel /* Bloom filter on this level */
+);
#else
# define sqlite3WhereExplainOneScan(u,v,w,x) 0
+# define sqlite3WhereExplainBloomFilter(u,v,w) 0
#endif /* SQLITE_OMIT_EXPLAIN */
#ifdef SQLITE_ENABLE_STMT_SCANSTATUS
SQLITE_PRIVATE void sqlite3WhereAddScanStatus(
@@ -146334,6 +147357,7 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(
SQLITE_PRIVATE void sqlite3WhereClauseInit(WhereClause*,WhereInfo*);
SQLITE_PRIVATE void sqlite3WhereClauseClear(WhereClause*);
SQLITE_PRIVATE void sqlite3WhereSplit(WhereClause*,Expr*,u8);
+SQLITE_PRIVATE void sqlite3WhereAddLimit(WhereClause*, Select*);
SQLITE_PRIVATE Bitmask sqlite3WhereExprUsage(WhereMaskSet*, Expr*);
SQLITE_PRIVATE Bitmask sqlite3WhereExprUsageNN(WhereMaskSet*, Expr*);
SQLITE_PRIVATE Bitmask sqlite3WhereExprListUsage(WhereMaskSet*, ExprList*);
@@ -146402,6 +147426,9 @@ SQLITE_PRIVATE void sqlite3WhereTabFuncArgs(Parse*, SrcItem*, WhereClause*);
#define WHERE_BIGNULL_SORT 0x00080000 /* Column nEq of index is BIGNULL */
#define WHERE_IN_SEEKSCAN 0x00100000 /* Seek-scan optimization for IN */
#define WHERE_TRANSCONS 0x00200000 /* Uses a transitive constraint */
+#define WHERE_BLOOMFILTER 0x00400000 /* Consider using a Bloom-filter */
+#define WHERE_SELFCULL 0x00800000 /* nOut reduced by extra WHERE terms */
+#define WHERE_OMIT_OFFSET 0x01000000 /* Set offset counter to zero */
#endif /* !defined(SQLITE_WHEREINT_H) */
@@ -146564,19 +147591,27 @@ SQLITE_PRIVATE int sqlite3WhereExplainOneScan(
explainIndexRange(&str, pLoop);
}
}else if( (flags & WHERE_IPK)!=0 && (flags & WHERE_CONSTRAINT)!=0 ){
- const char *zRangeOp;
+ char cRangeOp;
+#if 0 /* Better output, but breaks many tests */
+ const Table *pTab = pItem->pTab;
+ const char *zRowid = pTab->iPKey>=0 ? pTab->aCol[pTab->iPKey].zCnName:
+ "rowid";
+#else
+ const char *zRowid = "rowid";
+#endif
+ sqlite3_str_appendf(&str, " USING INTEGER PRIMARY KEY (%s", zRowid);
if( flags&(WHERE_COLUMN_EQ|WHERE_COLUMN_IN) ){
- zRangeOp = "=";
+ cRangeOp = '=';
}else if( (flags&WHERE_BOTH_LIMIT)==WHERE_BOTH_LIMIT ){
- zRangeOp = ">? AND rowid<";
+ sqlite3_str_appendf(&str, ">? AND %s", zRowid);
+ cRangeOp = '<';
}else if( flags&WHERE_BTM_LIMIT ){
- zRangeOp = ">";
+ cRangeOp = '>';
}else{
assert( flags&WHERE_TOP_LIMIT);
- zRangeOp = "<";
+ cRangeOp = '<';
}
- sqlite3_str_appendf(&str,
- " USING INTEGER PRIMARY KEY (rowid%s?)",zRangeOp);
+ sqlite3_str_appendf(&str, "%c?)", cRangeOp);
}
#ifndef SQLITE_OMIT_VIRTUALTABLE
else if( (flags & WHERE_VIRTUALTABLE)!=0 ){
@@ -146599,6 +147634,56 @@ SQLITE_PRIVATE int sqlite3WhereExplainOneScan(
}
return ret;
}
+
+/*
+** Add a single OP_Explain opcode that describes a Bloom filter.
+**
+** Or if not processing EXPLAIN QUERY PLAN and not in a SQLITE_DEBUG and/or
+** SQLITE_ENABLE_STMT_SCANSTATUS build, then OP_Explain opcodes are not
+** required and this routine is a no-op.
+**
+** If an OP_Explain opcode is added to the VM, its address is returned.
+** Otherwise, if no OP_Explain is coded, zero is returned.
+*/
+SQLITE_PRIVATE int sqlite3WhereExplainBloomFilter(
+ const Parse *pParse, /* Parse context */
+ const WhereInfo *pWInfo, /* WHERE clause */
+ const WhereLevel *pLevel /* Bloom filter on this level */
+){
+ int ret = 0;
+ SrcItem *pItem = &pWInfo->pTabList->a[pLevel->iFrom];
+ Vdbe *v = pParse->pVdbe; /* VM being constructed */
+ sqlite3 *db = pParse->db; /* Database handle */
+ char *zMsg; /* Text to add to EQP output */
+ int i; /* Loop counter */
+ WhereLoop *pLoop; /* The where loop */
+ StrAccum str; /* EQP output string */
+ char zBuf[100]; /* Initial space for EQP output string */
+
+ sqlite3StrAccumInit(&str, db, zBuf, sizeof(zBuf), SQLITE_MAX_LENGTH);
+ str.printfFlags = SQLITE_PRINTF_INTERNAL;
+ sqlite3_str_appendf(&str, "BLOOM FILTER ON %S (", pItem);
+ pLoop = pLevel->pWLoop;
+ if( pLoop->wsFlags & WHERE_IPK ){
+ const Table *pTab = pItem->pTab;
+ if( pTab->iPKey>=0 ){
+ sqlite3_str_appendf(&str, "%s=?", pTab->aCol[pTab->iPKey].zCnName);
+ }else{
+ sqlite3_str_appendf(&str, "rowid=?");
+ }
+ }else{
+ for(i=pLoop->nSkip; i<pLoop->u.btree.nEq; i++){
+ const char *z = explainIndexColumnName(pLoop->u.btree.pIndex, i);
+ if( i>pLoop->nSkip ) sqlite3_str_append(&str, " AND ", 5);
+ sqlite3_str_appendf(&str, "%s=?", z);
+ }
+ }
+ sqlite3_str_append(&str, ")", 1);
+ zMsg = sqlite3StrAccumFinish(&str);
+ ret = sqlite3VdbeAddOp4(v, OP_Explain, sqlite3VdbeCurrentAddr(v),
+ pParse->addrExplain, 0, zMsg,P4_DYNAMIC);
+ return ret;
+}
#endif /* SQLITE_OMIT_EXPLAIN */
#ifdef SQLITE_ENABLE_STMT_SCANSTATUS
@@ -147122,6 +148207,7 @@ static int codeAllEqualityTerms(
VdbeCoverageIf(v, bRev!=0);
VdbeComment((v, "begin skip-scan on %s", pIdx->zName));
j = sqlite3VdbeAddOp0(v, OP_Goto);
+ assert( pLevel->addrSkip==0 );
pLevel->addrSkip = sqlite3VdbeAddOp4Int(v, (bRev?OP_SeekLT:OP_SeekGT),
iIdxCur, 0, regBase, nSkip);
VdbeCoverageIf(v, bRev==0);
@@ -147154,6 +148240,9 @@ static int codeAllEqualityTerms(
sqlite3VdbeAddOp2(v, OP_Copy, r1, regBase+j);
}
}
+ }
+ for(j=nSkip; j<nEq; j++){
+ pTerm = pLoop->aLTerm[j];
if( pTerm->eOperator & WO_IN ){
if( pTerm->pExpr->flags & EP_xIsSelect ){
/* No affinity ever needs to be (or should be) applied to a value
@@ -147168,7 +148257,8 @@ static int codeAllEqualityTerms(
sqlite3VdbeAddOp2(v, OP_IsNull, regBase+j, pLevel->addrBrk);
VdbeCoverage(v);
}
- if( pParse->db->mallocFailed==0 && pParse->nErr==0 ){
+ if( pParse->nErr==0 ){
+ assert( pParse->db->mallocFailed==0 );
if( sqlite3CompareAffinity(pRight, zAff[j])==SQLITE_AFF_BLOB ){
zAff[j] = SQLITE_AFF_BLOB;
}
@@ -147358,7 +148448,7 @@ static void codeCursorHint(
sWalker.pParse = pParse;
sWalker.u.pCCurHint = &sHint;
pWC = &pWInfo->sWC;
- for(i=0; i<pWC->nTerm; i++){
+ for(i=0; i<pWC->nBase; i++){
pTerm = &pWC->a[i];
if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
if( pTerm->prereqAll & pLevel->notReady ) continue;
@@ -147388,7 +148478,7 @@ static void codeCursorHint(
if( pTabItem->fg.jointype & JT_LEFT ){
Expr *pExpr = pTerm->pExpr;
if( !ExprHasProperty(pExpr, EP_FromJoin)
- || pExpr->iRightJoinTable!=pTabItem->iCursor
+ || pExpr->w.iRightJoinTable!=pTabItem->iCursor
){
sWalker.eCode = 0;
sWalker.xExprCallback = codeCursorHintIsOrFunction;
@@ -147690,6 +148780,65 @@ static void whereApplyPartialIndexConstraints(
}
/*
+** This routine is called right after An OP_Filter has been generated and
+** before the corresponding index search has been performed. This routine
+** checks to see if there are additional Bloom filters in inner loops that
+** can be checked prior to doing the index lookup. If there are available
+** inner-loop Bloom filters, then evaluate those filters now, before the
+** index lookup. The idea is that a Bloom filter check is way faster than
+** an index lookup, and the Bloom filter might return false, meaning that
+** the index lookup can be skipped.
+**
+** We know that an inner loop uses a Bloom filter because it has the
+** WhereLevel.regFilter set. If an inner-loop Bloom filter is checked,
+** then clear the WhereLevel.regFilter value to prevent the Bloom filter
+** from being checked a second time when the inner loop is evaluated.
+*/
+static SQLITE_NOINLINE void filterPullDown(
+ Parse *pParse, /* Parsing context */
+ WhereInfo *pWInfo, /* Complete information about the WHERE clause */
+ int iLevel, /* Which level of pWInfo->a[] should be coded */
+ int addrNxt, /* Jump here to bypass inner loops */
+ Bitmask notReady /* Loops that are not ready */
+){
+ while( ++iLevel < pWInfo->nLevel ){
+ WhereLevel *pLevel = &pWInfo->a[iLevel];
+ WhereLoop *pLoop = pLevel->pWLoop;
+ if( pLevel->regFilter==0 ) continue;
+ if( pLevel->pWLoop->nSkip ) continue;
+ /* ,--- Because sqlite3ConstructBloomFilter() has will not have set
+ ** vvvvv--' pLevel->regFilter if this were true. */
+ if( NEVER(pLoop->prereq & notReady) ) continue;
+ if( pLoop->wsFlags & WHERE_IPK ){
+ WhereTerm *pTerm = pLoop->aLTerm[0];
+ int regRowid;
+ assert( pTerm!=0 );
+ assert( pTerm->pExpr!=0 );
+ testcase( pTerm->wtFlags & TERM_VIRTUAL );
+ regRowid = sqlite3GetTempReg(pParse);
+ regRowid = codeEqualityTerm(pParse, pTerm, pLevel, 0, 0, regRowid);
+ sqlite3VdbeAddOp4Int(pParse->pVdbe, OP_Filter, pLevel->regFilter,
+ addrNxt, regRowid, 1);
+ VdbeCoverage(pParse->pVdbe);
+ }else{
+ u16 nEq = pLoop->u.btree.nEq;
+ int r1;
+ char *zStartAff;
+
+ assert( pLoop->wsFlags & WHERE_INDEXED );
+ assert( (pLoop->wsFlags & WHERE_COLUMN_IN)==0 );
+ r1 = codeAllEqualityTerms(pParse,pLevel,0,0,&zStartAff);
+ codeApplyAffinity(pParse, r1, nEq, zStartAff);
+ sqlite3DbFree(pParse->db, zStartAff);
+ sqlite3VdbeAddOp4Int(pParse->pVdbe, OP_Filter, pLevel->regFilter,
+ addrNxt, r1, nEq);
+ VdbeCoverage(pParse->pVdbe);
+ }
+ pLevel->regFilter = 0;
+ }
+}
+
+/*
** Generate code for the start of the iLevel-th loop in the WHERE clause
** implementation described by pWInfo.
*/
@@ -147791,7 +148940,6 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(
int iReg; /* P3 Value for OP_VFilter */
int addrNotFound;
int nConstraint = pLoop->nLTerm;
- int iIn; /* Counter for IN constraints */
iReg = sqlite3GetTempRange(pParse, nConstraint+2);
addrNotFound = pLevel->addrBrk;
@@ -147800,11 +148948,27 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(
pTerm = pLoop->aLTerm[j];
if( NEVER(pTerm==0) ) continue;
if( pTerm->eOperator & WO_IN ){
- codeEqualityTerm(pParse, pTerm, pLevel, j, bRev, iTarget);
- addrNotFound = pLevel->addrNxt;
+ if( SMASKBIT32(j) & pLoop->u.vtab.mHandleIn ){
+ int iTab = pParse->nTab++;
+ int iCache = ++pParse->nMem;
+ sqlite3CodeRhsOfIN(pParse, pTerm->pExpr, iTab);
+ sqlite3VdbeAddOp3(v, OP_VInitIn, iTab, iTarget, iCache);
+ }else{
+ codeEqualityTerm(pParse, pTerm, pLevel, j, bRev, iTarget);
+ addrNotFound = pLevel->addrNxt;
+ }
}else{
Expr *pRight = pTerm->pExpr->pRight;
codeExprOrVector(pParse, pRight, iTarget, 1);
+ if( pTerm->eMatchOp==SQLITE_INDEX_CONSTRAINT_OFFSET
+ && pLoop->u.vtab.bOmitOffset
+ ){
+ assert( pTerm->eOperator==WO_AUX );
+ assert( pWInfo->pLimit!=0 );
+ assert( pWInfo->pLimit->iOffset>0 );
+ sqlite3VdbeAddOp2(v, OP_Integer, 0, pWInfo->pLimit->iOffset);
+ VdbeComment((v,"Zero OFFSET counter"));
+ }
}
}
sqlite3VdbeAddOp2(v, OP_Integer, pLoop->u.vtab.idxNum, iReg);
@@ -147821,44 +148985,54 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(
pLevel->op = pWInfo->eOnePass ? OP_Noop : OP_VNext;
pLevel->p2 = sqlite3VdbeCurrentAddr(v);
assert( (pLoop->wsFlags & WHERE_MULTI_OR)==0 );
- if( pLoop->wsFlags & WHERE_IN_ABLE ){
- iIn = pLevel->u.in.nIn;
- }else{
- iIn = 0;
- }
- for(j=nConstraint-1; j>=0; j--){
+
+ for(j=0; j<nConstraint; j++){
pTerm = pLoop->aLTerm[j];
- if( (pTerm->eOperator & WO_IN)!=0 ) iIn--;
if( j<16 && (pLoop->u.vtab.omitMask>>j)&1 ){
disableTerm(pLevel, pTerm);
- }else if( (pTerm->eOperator & WO_IN)!=0
- && sqlite3ExprVectorSize(pTerm->pExpr->pLeft)==1
+ continue;
+ }
+ if( (pTerm->eOperator & WO_IN)!=0
+ && (SMASKBIT32(j) & pLoop->u.vtab.mHandleIn)==0
+ && !db->mallocFailed
){
Expr *pCompare; /* The comparison operator */
Expr *pRight; /* RHS of the comparison */
VdbeOp *pOp; /* Opcode to access the value of the IN constraint */
+ int iIn; /* IN loop corresponding to the j-th constraint */
/* Reload the constraint value into reg[iReg+j+2]. The same value
** was loaded into the same register prior to the OP_VFilter, but
** the xFilter implementation might have changed the datatype or
- ** encoding of the value in the register, so it *must* be reloaded. */
- assert( pLevel->u.in.aInLoop!=0 || db->mallocFailed );
- if( !db->mallocFailed ){
- assert( iIn>=0 && iIn<pLevel->u.in.nIn );
+ ** encoding of the value in the register, so it *must* be reloaded.
+ */
+ for(iIn=0; ALWAYS(iIn<pLevel->u.in.nIn); iIn++){
pOp = sqlite3VdbeGetOp(v, pLevel->u.in.aInLoop[iIn].addrInTop);
- assert( pOp->opcode==OP_Column || pOp->opcode==OP_Rowid );
- assert( pOp->opcode!=OP_Column || pOp->p3==iReg+j+2 );
- assert( pOp->opcode!=OP_Rowid || pOp->p2==iReg+j+2 );
- testcase( pOp->opcode==OP_Rowid );
- sqlite3VdbeAddOp3(v, pOp->opcode, pOp->p1, pOp->p2, pOp->p3);
+ if( (pOp->opcode==OP_Column && pOp->p3==iReg+j+2)
+ || (pOp->opcode==OP_Rowid && pOp->p2==iReg+j+2)
+ ){
+ testcase( pOp->opcode==OP_Rowid );
+ sqlite3VdbeAddOp3(v, pOp->opcode, pOp->p1, pOp->p2, pOp->p3);
+ break;
+ }
}
/* Generate code that will continue to the next row if
- ** the IN constraint is not satisfied */
+ ** the IN constraint is not satisfied
+ */
pCompare = sqlite3PExpr(pParse, TK_EQ, 0, 0);
- assert( pCompare!=0 || db->mallocFailed );
- if( pCompare ){
- pCompare->pLeft = pTerm->pExpr->pLeft;
+ if( !db->mallocFailed ){
+ int iFld = pTerm->u.x.iField;
+ Expr *pLeft = pTerm->pExpr->pLeft;
+ assert( pLeft!=0 );
+ if( iFld>0 ){
+ assert( pLeft->op==TK_VECTOR );
+ assert( ExprUseXList(pLeft) );
+ assert( iFld<=pLeft->x.pList->nExpr );
+ pCompare->pLeft = pLeft->x.pList->a[iFld-1].pExpr;
+ }else{
+ pCompare->pLeft = pLeft;
+ }
pCompare->pRight = pRight = sqlite3Expr(db, TK_REGISTER, 0);
if( pRight ){
pRight->iTable = iReg+j+2;
@@ -147867,11 +149041,11 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(
);
}
pCompare->pLeft = 0;
- sqlite3ExprDelete(db, pCompare);
}
+ sqlite3ExprDelete(db, pCompare);
}
}
- assert( iIn==0 || db->mallocFailed );
+
/* These registers need to be preserved in case there is an IN operator
** loop. So we could deallocate the registers here (and potentially
** reuse them later) if (pLoop->wsFlags & WHERE_IN_ABLE)==0. But it seems
@@ -147899,6 +149073,12 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(
iRowidReg = codeEqualityTerm(pParse, pTerm, pLevel, 0, bRev, iReleaseReg);
if( iRowidReg!=iReleaseReg ) sqlite3ReleaseTempReg(pParse, iReleaseReg);
addrNxt = pLevel->addrNxt;
+ if( pLevel->regFilter ){
+ sqlite3VdbeAddOp4Int(v, OP_Filter, pLevel->regFilter, addrNxt,
+ iRowidReg, 1);
+ VdbeCoverage(v);
+ filterPullDown(pParse, pWInfo, iLevel, addrNxt, notReady);
+ }
sqlite3VdbeAddOp3(v, OP_SeekRowid, iCur, addrNxt, iRowidReg);
VdbeCoverage(v);
pLevel->op = OP_Noop;
@@ -148224,6 +149404,12 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(
sqlite3VdbeAddOp2(v, OP_Integer, 1, regBignull);
VdbeComment((v, "NULL-scan pass ctr"));
}
+ if( pLevel->regFilter ){
+ sqlite3VdbeAddOp4Int(v, OP_Filter, pLevel->regFilter, addrNxt,
+ regBase, nEq);
+ VdbeCoverage(v);
+ filterPullDown(pParse, pWInfo, iLevel, addrNxt, notReady);
+ }
op = aStartOp[(start_constraints<<2) + (startEq<<1) + bRev];
assert( op!=0 );
@@ -148551,7 +149737,7 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(
iRetInit = sqlite3VdbeAddOp2(v, OP_Integer, 0, regReturn);
/* If the original WHERE clause is z of the form: (x1 OR x2 OR ...) AND y
- ** Then for every term xN, evaluate as the subexpression: xN AND z
+ ** Then for every term xN, evaluate as the subexpression: xN AND y
** That way, terms in y that are factored into the disjunction will
** be picked up by the recursive calls to sqlite3WhereBegin() below.
**
@@ -148563,6 +149749,20 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(
** This optimization also only applies if the (x1 OR x2 OR ...) term
** is not contained in the ON clause of a LEFT JOIN.
** See ticket http://www.sqlite.org/src/info/f2369304e4
+ **
+ ** 2022-02-04: Do not push down slices of a row-value comparison.
+ ** In other words, "w" or "y" may not be a slice of a vector. Otherwise,
+ ** the initialization of the right-hand operand of the vector comparison
+ ** might not occur, or might occur only in an OR branch that is not
+ ** taken. dbsqlfuzz 80a9fade844b4fb43564efc972bcb2c68270f5d1.
+ **
+ ** 2022-03-03: Do not push down expressions that involve subqueries.
+ ** The subquery might get coded as a subroutine. Any table-references
+ ** in the subquery might be resolved to index-references for the index on
+ ** the OR branch in which the subroutine is coded. But if the subroutine
+ ** is invoked from a different OR branch that uses a different index, such
+ ** index-references will not work. tag-20220303a
+ ** https://sqlite.org/forum/forumpost/36937b197273d403
*/
if( pWC->nTerm>1 ){
int iTerm;
@@ -148571,9 +149771,12 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(
if( &pWC->a[iTerm] == pTerm ) continue;
testcase( pWC->a[iTerm].wtFlags & TERM_VIRTUAL );
testcase( pWC->a[iTerm].wtFlags & TERM_CODED );
- if( (pWC->a[iTerm].wtFlags & (TERM_VIRTUAL|TERM_CODED))!=0 ) continue;
+ testcase( pWC->a[iTerm].wtFlags & TERM_SLICE );
+ if( (pWC->a[iTerm].wtFlags & (TERM_VIRTUAL|TERM_CODED|TERM_SLICE))!=0 ){
+ continue;
+ }
if( (pWC->a[iTerm].eOperator & WO_ALL)==0 ) continue;
- testcase( pWC->a[iTerm].wtFlags & TERM_ORINFO );
+ if( ExprHasProperty(pExpr, EP_Subquery) ) continue; /* tag-20220303a */
pExpr = sqlite3ExprDup(db, pExpr, 0);
pAndExpr = sqlite3ExprAnd(pParse, pAndExpr, pExpr);
}
@@ -148614,9 +149817,9 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(
/* 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,
+ pSubWInfo = sqlite3WhereBegin(pParse, pOrTab, pOrExpr, 0, 0, 0,
WHERE_OR_SUBCLAUSE, iCovCur);
- assert( pSubWInfo || pParse->nErr || db->mallocFailed );
+ assert( pSubWInfo || pParse->nErr );
if( pSubWInfo ){
WhereLoop *pSubLoop;
int addrExplain = sqlite3WhereExplainOneScan(
@@ -148855,7 +150058,7 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(
** then we cannot use the "t1.a=t2.b" constraint, but we can code
** the implied "t1.a=123" constraint.
*/
- for(pTerm=pWC->a, j=pWC->nTerm; j>0; j--, pTerm++){
+ for(pTerm=pWC->a, j=pWC->nBase; j>0; j--, pTerm++){
Expr *pE, sEAlt;
WhereTerm *pAlt;
if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
@@ -148900,7 +150103,7 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(
pLevel->addrFirst = sqlite3VdbeCurrentAddr(v);
sqlite3VdbeAddOp2(v, OP_Integer, 1, pLevel->iLeftJoin);
VdbeComment((v, "record LEFT JOIN hit"));
- for(pTerm=pWC->a, j=0; j<pWC->nTerm; j++, pTerm++){
+ for(pTerm=pWC->a, j=0; j<pWC->nBase; j++, pTerm++){
testcase( pTerm->wtFlags & TERM_VIRTUAL );
testcase( pTerm->wtFlags & TERM_CODED );
if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
@@ -149011,6 +150214,7 @@ static int whereClauseInsert(WhereClause *pWC, Expr *p, u16 wtFlags){
pWC->nSlot = sqlite3DbMallocSize(db, pWC->a)/sizeof(pWC->a[0]);
}
pTerm = &pWC->a[idx = pWC->nTerm++];
+ if( (wtFlags & TERM_VIRTUAL)==0 ) pWC->nBase = pWC->nTerm;
if( p && ExprHasProperty(p, EP_Unlikely) ){
pTerm->truthProb = sqlite3LogEst(p->iTable) - 270;
}else{
@@ -149353,7 +150557,7 @@ static int isAuxiliaryVtabOperator(
assert( pVtab!=0 );
assert( pVtab->pModule!=0 );
assert( !ExprHasProperty(pExpr, EP_IntValue) );
- pMod = (sqlite3_module *)pVtab->pModule;
+ pMod = (sqlite3_module *)pVtab->pModule;
if( pMod->xFindFunction!=0 ){
i = pMod->xFindFunction(pVtab,2, pExpr->u.zToken, &xNotUsed, &pNotUsed);
if( i>=SQLITE_INDEX_CONSTRAINT_FUNCTION ){
@@ -149397,7 +150601,7 @@ static int isAuxiliaryVtabOperator(
static void transferJoinMarkings(Expr *pDerived, Expr *pBase){
if( pDerived ){
pDerived->flags |= pBase->flags & EP_FromJoin;
- pDerived->iRightJoinTable = pBase->iRightJoinTable;
+ pDerived->w.iRightJoinTable = pBase->w.iRightJoinTable;
}
}
@@ -149727,7 +150931,7 @@ static void exprAnalyzeOrTerm(
pOrTerm = pOrWc->a;
for(i=pOrWc->nTerm-1; i>=0; i--, pOrTerm++){
assert( pOrTerm->eOperator & WO_EQ );
- pOrTerm->wtFlags &= ~TERM_OR_OK;
+ pOrTerm->wtFlags &= ~TERM_OK;
if( pOrTerm->leftCursor==iCursor ){
/* This is the 2-bit case and we are on the second iteration and
** current term is from the first iteration. So skip this term. */
@@ -149768,7 +150972,7 @@ static void exprAnalyzeOrTerm(
assert( pOrTerm->eOperator & WO_EQ );
assert( (pOrTerm->eOperator & (WO_OR|WO_AND))==0 );
if( pOrTerm->leftCursor!=iCursor ){
- pOrTerm->wtFlags &= ~TERM_OR_OK;
+ pOrTerm->wtFlags &= ~TERM_OK;
}else if( pOrTerm->u.x.leftColumn!=iColumn || (iColumn==XN_EXPR
&& sqlite3ExprCompare(pParse, pOrTerm->pExpr->pLeft, pLeft, -1)
)){
@@ -149784,7 +150988,7 @@ static void exprAnalyzeOrTerm(
if( affRight!=0 && affRight!=affLeft ){
okToChngToIN = 0;
}else{
- pOrTerm->wtFlags |= TERM_OR_OK;
+ pOrTerm->wtFlags |= TERM_OK;
}
}
}
@@ -149801,7 +151005,7 @@ static void exprAnalyzeOrTerm(
Expr *pNew; /* The complete IN operator */
for(i=pOrWc->nTerm-1, pOrTerm=pOrWc->a; i>=0; i--, pOrTerm++){
- if( (pOrTerm->wtFlags & TERM_OR_OK)==0 ) continue;
+ if( (pOrTerm->wtFlags & TERM_OK)==0 ) continue;
assert( pOrTerm->eOperator & WO_EQ );
assert( (pOrTerm->eOperator & (WO_OR|WO_AND))==0 );
assert( pOrTerm->leftCursor==iCursor );
@@ -150002,10 +151206,13 @@ static void exprAnalyze(
if( db->mallocFailed ){
return;
}
+ assert( pWC->nTerm > idxTerm );
pTerm = &pWC->a[idxTerm];
pMaskSet = &pWInfo->sMaskSet;
pExpr = pTerm->pExpr;
+ assert( pExpr!=0 ); /* Because malloc() has not failed */
assert( pExpr->op!=TK_AS && pExpr->op!=TK_COLLATE );
+ pMaskSet->bVarSelect = 0;
prereqLeft = sqlite3WhereExprUsage(pMaskSet, pExpr->pLeft);
op = pExpr->op;
if( op==TK_IN ){
@@ -150016,16 +151223,30 @@ static void exprAnalyze(
}else{
pTerm->prereqRight = sqlite3WhereExprListUsage(pMaskSet, pExpr->x.pList);
}
- }else if( op==TK_ISNULL ){
- pTerm->prereqRight = 0;
+ prereqAll = prereqLeft | pTerm->prereqRight;
}else{
pTerm->prereqRight = sqlite3WhereExprUsage(pMaskSet, pExpr->pRight);
+ if( pExpr->pLeft==0
+ || ExprHasProperty(pExpr, EP_xIsSelect|EP_IfNullRow)
+ || pExpr->x.pList!=0
+ ){
+ prereqAll = sqlite3WhereExprUsageNN(pMaskSet, pExpr);
+ }else{
+ prereqAll = prereqLeft | pTerm->prereqRight;
+ }
}
- pMaskSet->bVarSelect = 0;
- prereqAll = sqlite3WhereExprUsageNN(pMaskSet, pExpr);
if( pMaskSet->bVarSelect ) pTerm->wtFlags |= TERM_VARSELECT;
+
+#ifdef SQLITE_DEBUG
+ if( prereqAll!=sqlite3WhereExprUsageNN(pMaskSet, pExpr) ){
+ printf("\n*** Incorrect prereqAll computed for:\n");
+ sqlite3TreeViewExpr(0,pExpr,0);
+ abort();
+ }
+#endif
+
if( ExprHasProperty(pExpr, EP_FromJoin) ){
- Bitmask x = sqlite3WhereGetMask(pMaskSet, pExpr->iRightJoinTable);
+ Bitmask x = sqlite3WhereGetMask(pMaskSet, pExpr->w.iRightJoinTable);
prereqAll |= x;
extraRight = x-1; /* ON clause terms may not be used with an index
** on left table of a LEFT JOIN. Ticket #3015 */
@@ -150293,7 +151514,10 @@ static void exprAnalyze(
** no longer used.
**
** This is only required if at least one side of the comparison operation
- ** is not a sub-select. */
+ ** is not a sub-select.
+ **
+ ** tag-20220128a
+ */
if( (pExpr->op==TK_EQ || pExpr->op==TK_IS)
&& (nLeft = sqlite3ExprVectorSize(pExpr->pLeft))>1
&& sqlite3ExprVectorSize(pExpr->pRight)==nLeft
@@ -150310,7 +151534,7 @@ static void exprAnalyze(
pNew = sqlite3PExpr(pParse, pExpr->op, pLeft, pRight);
transferJoinMarkings(pNew, pExpr);
- idxNew = whereClauseInsert(pWC, pNew, TERM_DYNAMIC);
+ idxNew = whereClauseInsert(pWC, pNew, TERM_DYNAMIC|TERM_SLICE);
exprAnalyze(pSrc, pWC, idxNew);
}
pTerm = &pWC->a[idxTerm];
@@ -150340,7 +151564,7 @@ static void exprAnalyze(
int i;
for(i=0; i<sqlite3ExprVectorSize(pExpr->pLeft); i++){
int idxNew;
- idxNew = whereClauseInsert(pWC, pExpr, TERM_VIRTUAL);
+ idxNew = whereClauseInsert(pWC, pExpr, TERM_VIRTUAL|TERM_SLICE);
pWC->a[idxNew].u.x.iField = i+1;
exprAnalyze(pSrc, pWC, idxNew);
markTermAsChild(pWC, idxNew, idxTerm);
@@ -150373,7 +151597,7 @@ static void exprAnalyze(
0, sqlite3ExprDup(db, pRight, 0));
if( ExprHasProperty(pExpr, EP_FromJoin) && pNewExpr ){
ExprSetProperty(pNewExpr, EP_FromJoin);
- pNewExpr->iRightJoinTable = pExpr->iRightJoinTable;
+ pNewExpr->w.iRightJoinTable = pExpr->w.iRightJoinTable;
}
idxNew = whereClauseInsert(pWC, pNewExpr, TERM_VIRTUAL|TERM_DYNAMIC);
testcase( idxNew==0 );
@@ -150437,6 +151661,113 @@ SQLITE_PRIVATE void sqlite3WhereSplit(WhereClause *pWC, Expr *pExpr, u8 op){
}
/*
+** Add either a LIMIT (if eMatchOp==SQLITE_INDEX_CONSTRAINT_LIMIT) or
+** OFFSET (if eMatchOp==SQLITE_INDEX_CONSTRAINT_OFFSET) term to the
+** where-clause passed as the first argument. The value for the term
+** is found in register iReg.
+**
+** In the common case where the value is a simple integer
+** (example: "LIMIT 5 OFFSET 10") then the expression codes as a
+** TK_INTEGER so that it will be available to sqlite3_vtab_rhs_value().
+** If not, then it codes as a TK_REGISTER expression.
+*/
+static void whereAddLimitExpr(
+ WhereClause *pWC, /* Add the constraint to this WHERE clause */
+ int iReg, /* Register that will hold value of the limit/offset */
+ Expr *pExpr, /* Expression that defines the limit/offset */
+ int iCsr, /* Cursor to which the constraint applies */
+ int eMatchOp /* SQLITE_INDEX_CONSTRAINT_LIMIT or _OFFSET */
+){
+ Parse *pParse = pWC->pWInfo->pParse;
+ sqlite3 *db = pParse->db;
+ Expr *pNew;
+ int iVal = 0;
+
+ if( sqlite3ExprIsInteger(pExpr, &iVal) && iVal>=0 ){
+ Expr *pVal = sqlite3Expr(db, TK_INTEGER, 0);
+ if( pVal==0 ) return;
+ ExprSetProperty(pVal, EP_IntValue);
+ pVal->u.iValue = iVal;
+ pNew = sqlite3PExpr(pParse, TK_MATCH, 0, pVal);
+ }else{
+ Expr *pVal = sqlite3Expr(db, TK_REGISTER, 0);
+ if( pVal==0 ) return;
+ pVal->iTable = iReg;
+ pNew = sqlite3PExpr(pParse, TK_MATCH, 0, pVal);
+ }
+ if( pNew ){
+ WhereTerm *pTerm;
+ int idx;
+ idx = whereClauseInsert(pWC, pNew, TERM_DYNAMIC|TERM_VIRTUAL);
+ pTerm = &pWC->a[idx];
+ pTerm->leftCursor = iCsr;
+ pTerm->eOperator = WO_AUX;
+ pTerm->eMatchOp = eMatchOp;
+ }
+}
+
+/*
+** Possibly add terms corresponding to the LIMIT and OFFSET clauses of the
+** SELECT statement passed as the second argument. These terms are only
+** added if:
+**
+** 1. The SELECT statement has a LIMIT clause, and
+** 2. The SELECT statement is not an aggregate or DISTINCT query, and
+** 3. The SELECT statement has exactly one object in its from clause, and
+** that object is a virtual table, and
+** 4. There are no terms in the WHERE clause that will not be passed
+** to the virtual table xBestIndex method.
+** 5. The ORDER BY clause, if any, will be made available to the xBestIndex
+** method.
+**
+** LIMIT and OFFSET terms are ignored by most of the planner code. They
+** exist only so that they may be passed to the xBestIndex method of the
+** single virtual table in the FROM clause of the SELECT.
+*/
+SQLITE_PRIVATE void sqlite3WhereAddLimit(WhereClause *pWC, Select *p){
+ assert( p==0 || (p->pGroupBy==0 && (p->selFlags & SF_Aggregate)==0) );
+ if( (p && p->pLimit) /* 1 */
+ && (p->selFlags & (SF_Distinct|SF_Aggregate))==0 /* 2 */
+ && (p->pSrc->nSrc==1 && IsVirtual(p->pSrc->a[0].pTab)) /* 3 */
+ ){
+ ExprList *pOrderBy = p->pOrderBy;
+ int iCsr = p->pSrc->a[0].iCursor;
+ int ii;
+
+ /* Check condition (4). Return early if it is not met. */
+ for(ii=0; ii<pWC->nTerm; ii++){
+ if( pWC->a[ii].wtFlags & TERM_CODED ){
+ /* This term is a vector operation that has been decomposed into
+ ** other, subsequent terms. It can be ignored. See tag-20220128a */
+ assert( pWC->a[ii].wtFlags & TERM_VIRTUAL );
+ assert( pWC->a[ii].eOperator==0 );
+ continue;
+ }
+ if( pWC->a[ii].leftCursor!=iCsr ) return;
+ }
+
+ /* Check condition (5). Return early if it is not met. */
+ if( pOrderBy ){
+ for(ii=0; ii<pOrderBy->nExpr; ii++){
+ Expr *pExpr = pOrderBy->a[ii].pExpr;
+ if( pExpr->op!=TK_COLUMN ) return;
+ if( pExpr->iTable!=iCsr ) return;
+ if( pOrderBy->a[ii].sortFlags & KEYINFO_ORDER_BIGNULL ) return;
+ }
+ }
+
+ /* All conditions are met. Add the terms to the where-clause object. */
+ assert( p->pLimit->op==TK_LIMIT );
+ whereAddLimitExpr(pWC, p->iLimit, p->pLimit->pLeft,
+ iCsr, SQLITE_INDEX_CONSTRAINT_LIMIT);
+ if( p->iOffset>0 ){
+ whereAddLimitExpr(pWC, p->iOffset, p->pLimit->pRight,
+ iCsr, SQLITE_INDEX_CONSTRAINT_OFFSET);
+ }
+ }
+}
+
+/*
** Initialize a preallocated WhereClause structure.
*/
SQLITE_PRIVATE void sqlite3WhereClauseInit(
@@ -150447,6 +151778,7 @@ SQLITE_PRIVATE void sqlite3WhereClauseInit(
pWC->hasOr = 0;
pWC->pOuter = 0;
pWC->nTerm = 0;
+ pWC->nBase = 0;
pWC->nSlot = ArraySize(pWC->aStatic);
pWC->a = pWC->aStatic;
}
@@ -150457,17 +151789,34 @@ SQLITE_PRIVATE void sqlite3WhereClauseInit(
** sqlite3WhereClauseInit().
*/
SQLITE_PRIVATE void sqlite3WhereClauseClear(WhereClause *pWC){
- int i;
- WhereTerm *a;
sqlite3 *db = pWC->pWInfo->pParse->db;
- for(i=pWC->nTerm-1, a=pWC->a; i>=0; i--, a++){
- if( a->wtFlags & TERM_DYNAMIC ){
- sqlite3ExprDelete(db, a->pExpr);
+ assert( pWC->nTerm>=pWC->nBase );
+ if( pWC->nTerm>0 ){
+ WhereTerm *a = pWC->a;
+ WhereTerm *aLast = &pWC->a[pWC->nTerm-1];
+#ifdef SQLITE_DEBUG
+ int i;
+ /* Verify that every term past pWC->nBase is virtual */
+ for(i=pWC->nBase; i<pWC->nTerm; i++){
+ assert( (pWC->a[i].wtFlags & TERM_VIRTUAL)!=0 );
}
- if( a->wtFlags & TERM_ORINFO ){
- whereOrInfoDelete(db, a->u.pOrInfo);
- }else if( a->wtFlags & TERM_ANDINFO ){
- whereAndInfoDelete(db, a->u.pAndInfo);
+#endif
+ while(1){
+ assert( a->eMatchOp==0 || a->eOperator==WO_AUX );
+ if( a->wtFlags & TERM_DYNAMIC ){
+ sqlite3ExprDelete(db, a->pExpr);
+ }
+ if( a->wtFlags & (TERM_ORINFO|TERM_ANDINFO) ){
+ if( a->wtFlags & TERM_ORINFO ){
+ assert( (a->wtFlags & TERM_ANDINFO)==0 );
+ whereOrInfoDelete(db, a->u.pOrInfo);
+ }else{
+ assert( (a->wtFlags & TERM_ANDINFO)!=0 );
+ whereAndInfoDelete(db, a->u.pAndInfo);
+ }
+ }
+ if( a==aLast ) break;
+ a++;
}
}
if( pWC->a!=pWC->aStatic ){
@@ -150480,15 +151829,38 @@ SQLITE_PRIVATE void sqlite3WhereClauseClear(WhereClause *pWC){
** These routines walk (recursively) an expression tree and generate
** a bitmask indicating which tables are used in that expression
** tree.
+**
+** sqlite3WhereExprUsage(MaskSet, Expr) ->
+**
+** Return a Bitmask of all tables referenced by Expr. Expr can be
+** be NULL, in which case 0 is returned.
+**
+** sqlite3WhereExprUsageNN(MaskSet, Expr) ->
+**
+** Same as sqlite3WhereExprUsage() except that Expr must not be
+** NULL. The "NN" suffix on the name stands for "Not Null".
+**
+** sqlite3WhereExprListUsage(MaskSet, ExprList) ->
+**
+** Return a Bitmask of all tables referenced by every expression
+** in the expression list ExprList. ExprList can be NULL, in which
+** case 0 is returned.
+**
+** sqlite3WhereExprUsageFull(MaskSet, ExprList) ->
+**
+** Internal use only. Called only by sqlite3WhereExprUsageNN() for
+** complex expressions that require pushing register values onto
+** the stack. Many calls to sqlite3WhereExprUsageNN() do not need
+** the more complex analysis done by this routine. Hence, the
+** computations done by this routine are broken out into a separate
+** "no-inline" function to avoid the stack push overhead in the
+** common case where it is not needed.
*/
-SQLITE_PRIVATE Bitmask sqlite3WhereExprUsageNN(WhereMaskSet *pMaskSet, Expr *p){
+static SQLITE_NOINLINE Bitmask sqlite3WhereExprUsageFull(
+ WhereMaskSet *pMaskSet,
+ Expr *p
+){
Bitmask mask;
- if( p->op==TK_COLUMN && !ExprHasProperty(p, EP_FixedCol) ){
- return sqlite3WhereGetMask(pMaskSet, p->iTable);
- }else if( ExprHasProperty(p, EP_TokenOnly|EP_Leaf) ){
- assert( p->op!=TK_IF_NULL_ROW );
- return 0;
- }
mask = (p->op==TK_IF_NULL_ROW) ? sqlite3WhereGetMask(pMaskSet, p->iTable) : 0;
if( p->pLeft ) mask |= sqlite3WhereExprUsageNN(pMaskSet, p->pLeft);
if( p->pRight ){
@@ -150510,6 +151882,15 @@ SQLITE_PRIVATE Bitmask sqlite3WhereExprUsageNN(WhereMaskSet *pMaskSet, Expr *p){
#endif
return mask;
}
+SQLITE_PRIVATE Bitmask sqlite3WhereExprUsageNN(WhereMaskSet *pMaskSet, Expr *p){
+ if( p->op==TK_COLUMN && !ExprHasProperty(p, EP_FixedCol) ){
+ return sqlite3WhereGetMask(pMaskSet, p->iTable);
+ }else if( ExprHasProperty(p, EP_TokenOnly|EP_Leaf) ){
+ assert( p->op!=TK_IF_NULL_ROW );
+ return 0;
+ }
+ return sqlite3WhereExprUsageFull(pMaskSet, p);
+}
SQLITE_PRIVATE Bitmask sqlite3WhereExprUsage(WhereMaskSet *pMaskSet, Expr *p){
return p ? sqlite3WhereExprUsageNN(pMaskSet,p) : 0;
}
@@ -150579,6 +151960,7 @@ SQLITE_PRIVATE void sqlite3WhereTabFuncArgs(
pColRef->iColumn = k++;
assert( ExprUseYTab(pColRef) );
pColRef->y.pTab = pTab;
+ pItem->colUsed |= sqlite3ExprColUsed(pColRef);
pRhs = sqlite3PExpr(pParse, TK_UPLUS,
sqlite3ExprDup(pParse->db, pArgs->a[j].pExpr, 0), 0);
pTerm = sqlite3PExpr(pParse, TK_EQ, pColRef, pRhs);
@@ -150623,8 +152005,14 @@ SQLITE_PRIVATE void sqlite3WhereTabFuncArgs(
*/
typedef struct HiddenIndexInfo HiddenIndexInfo;
struct HiddenIndexInfo {
- WhereClause *pWC; /* The Where clause being analyzed */
- Parse *pParse; /* The parsing context */
+ WhereClause *pWC; /* The Where clause being analyzed */
+ Parse *pParse; /* The parsing context */
+ int eDistinct; /* Value to return from sqlite3_vtab_distinct() */
+ u32 mIn; /* Mask of terms that are <col> IN (...) */
+ u32 mHandleIn; /* Terms that vtab will handle as <col> IN (...) */
+ sqlite3_value *aRhs[1]; /* RHS values for constraints. MUST BE LAST
+ ** because extra space is allocated to hold up
+ ** to nTerm such values */
};
/* Forward declaration of methods */
@@ -150827,7 +152215,12 @@ whereOrInsert_done:
SQLITE_PRIVATE Bitmask sqlite3WhereGetMask(WhereMaskSet *pMaskSet, int iCursor){
int i;
assert( pMaskSet->n<=(int)sizeof(Bitmask)*8 );
- for(i=0; i<pMaskSet->n; i++){
+ assert( pMaskSet->n>0 || pMaskSet->ix[0]<0 );
+ assert( iCursor>=-1 );
+ if( pMaskSet->ix[0]==iCursor ){
+ return 1;
+ }
+ for(i=1; i<pMaskSet->n; i++){
if( pMaskSet->ix[i]==iCursor ){
return MASKBIT(i);
}
@@ -151012,16 +152405,16 @@ static WhereTerm *whereScanInit(
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 ){
+ if( iColumn==pIdx->pTable->iPKey ){
iColumn = XN_ROWID;
}else if( iColumn>=0 ){
pScan->idxaff = pIdx->pTable->aCol[iColumn].affinity;
pScan->zCollName = pIdx->azColl[j];
+ }else 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==XN_EXPR ){
return 0;
@@ -151264,12 +152657,14 @@ static void whereTraceIndexInfoInputs(sqlite3_index_info *p){
int i;
if( !sqlite3WhereTrace ) return;
for(i=0; i<p->nConstraint; i++){
- sqlite3DebugPrintf(" constraint[%d]: col=%d termid=%d op=%d usabled=%d\n",
+ sqlite3DebugPrintf(
+ " constraint[%d]: col=%d termid=%d op=%d usabled=%d collseq=%s\n",
i,
p->aConstraint[i].iColumn,
p->aConstraint[i].iTermOffset,
p->aConstraint[i].op,
- p->aConstraint[i].usable);
+ p->aConstraint[i].usable,
+ sqlite3_vtab_collation(p,i));
}
for(i=0; i<p->nOrderBy; i++){
sqlite3DebugPrintf(" orderby[%d]: col=%d desc=%d\n",
@@ -151305,9 +152700,9 @@ static void whereTraceIndexInfoOutputs(sqlite3_index_info *p){
** index existed.
*/
static int termCanDriveIndex(
- WhereTerm *pTerm, /* WHERE clause term to check */
- SrcItem *pSrc, /* Table we are trying to access */
- Bitmask notReady /* Tables in outer loops of the join */
+ const WhereTerm *pTerm, /* WHERE clause term to check */
+ const SrcItem *pSrc, /* Table we are trying to access */
+ const Bitmask notReady /* Tables in outer loops of the join */
){
char aff;
if( pTerm->leftCursor!=pSrc->iCursor ) return 0;
@@ -151338,11 +152733,11 @@ static int termCanDriveIndex(
** and to set up the WhereLevel object pLevel so that the code generator
** makes use of the automatic index.
*/
-static void constructAutomaticIndex(
+static SQLITE_NOINLINE void constructAutomaticIndex(
Parse *pParse, /* The parsing context */
- WhereClause *pWC, /* The WHERE clause */
- SrcItem *pSrc, /* The FROM clause term to get the next index */
- Bitmask notReady, /* Mask of cursors that are not available */
+ const WhereClause *pWC, /* The WHERE clause */
+ const SrcItem *pSrc, /* The FROM clause term to get the next index */
+ const Bitmask notReady, /* Mask of cursors that are not available */
WhereLevel *pLevel /* Write new index here */
){
int nKeyCol; /* Number of columns in the constructed index */
@@ -151384,13 +152779,13 @@ static void constructAutomaticIndex(
idxCols = 0;
for(pTerm=pWC->a; pTerm<pWCEnd; pTerm++){
Expr *pExpr = pTerm->pExpr;
- assert( !ExprHasProperty(pExpr, EP_FromJoin) /* prereq always non-zero */
- || pExpr->iRightJoinTable!=pSrc->iCursor /* for the right-hand */
- || pLoop->prereq!=0 ); /* table of a LEFT JOIN */
- if( pLoop->prereq==0
- && (pTerm->wtFlags & TERM_VIRTUAL)==0
- && !ExprHasProperty(pExpr, EP_FromJoin)
- && sqlite3ExprIsTableConstant(pExpr, pSrc->iCursor) ){
+ /* Make the automatic index a partial index if there are terms in the
+ ** WHERE clause (or the ON clause of a LEFT join) that constrain which
+ ** rows of the target table (pSrc) that can be used. */
+ if( (pTerm->wtFlags & TERM_VIRTUAL)==0
+ && ((pSrc->fg.jointype&JT_LEFT)==0 || ExprHasProperty(pExpr,EP_FromJoin))
+ && sqlite3ExprIsTableConstant(pExpr, pSrc->iCursor)
+ ){
pPartial = sqlite3ExprAnd(pParse, pPartial,
sqlite3ExprDup(pParse->db, pExpr, 0));
}
@@ -151497,6 +152892,10 @@ static void constructAutomaticIndex(
sqlite3VdbeAddOp2(v, OP_OpenAutoindex, pLevel->iIdxCur, nKeyCol+1);
sqlite3VdbeSetP4KeyInfo(pParse, pIdx);
VdbeComment((v, "for %s", pTable->zName));
+ if( OptimizationEnabled(pParse->db, SQLITE_BloomFilter) ){
+ pLevel->regFilter = ++pParse->nMem;
+ sqlite3VdbeAddOp2(v, OP_Blob, 10000, pLevel->regFilter);
+ }
/* Fill the automatic index with content */
pTabItem = &pWC->pWInfo->pTabList->a[pLevel->iFrom];
@@ -151519,6 +152918,10 @@ static void constructAutomaticIndex(
regBase = sqlite3GenerateIndexKey(
pParse, pIdx, pLevel->iTabCur, regRecord, 0, 0, 0, 0
);
+ if( pLevel->regFilter ){
+ sqlite3VdbeAddOp4Int(v, OP_FilterAdd, pLevel->regFilter, 0,
+ regBase, pLoop->u.btree.nEq);
+ }
sqlite3VdbeAddOp2(v, OP_IdxInsert, pLevel->iIdxCur, regRecord);
sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT);
if( pPartial ) sqlite3VdbeResolveLabel(v, iContinue);
@@ -151545,22 +152948,149 @@ end_auto_index_create:
}
#endif /* SQLITE_OMIT_AUTOMATIC_INDEX */
+/*
+** Generate bytecode that will initialize a Bloom filter that is appropriate
+** for pLevel.
+**
+** If there are inner loops within pLevel that have the WHERE_BLOOMFILTER
+** flag set, initialize a Bloomfilter for them as well. Except don't do
+** this recursive initialization if the SQLITE_BloomPulldown optimization has
+** been turned off.
+**
+** When the Bloom filter is initialized, the WHERE_BLOOMFILTER flag is cleared
+** from the loop, but the regFilter value is set to a register that implements
+** the Bloom filter. When regFilter is positive, the
+** sqlite3WhereCodeOneLoopStart() will generate code to test the Bloom filter
+** and skip the subsequence B-Tree seek if the Bloom filter indicates that
+** no matching rows exist.
+**
+** This routine may only be called if it has previously been determined that
+** the loop would benefit from a Bloom filter, and the WHERE_BLOOMFILTER bit
+** is set.
+*/
+static SQLITE_NOINLINE void sqlite3ConstructBloomFilter(
+ WhereInfo *pWInfo, /* The WHERE clause */
+ int iLevel, /* Index in pWInfo->a[] that is pLevel */
+ WhereLevel *pLevel, /* Make a Bloom filter for this FROM term */
+ Bitmask notReady /* Loops that are not ready */
+){
+ int addrOnce; /* Address of opening OP_Once */
+ int addrTop; /* Address of OP_Rewind */
+ int addrCont; /* Jump here to skip a row */
+ const WhereTerm *pTerm; /* For looping over WHERE clause terms */
+ const WhereTerm *pWCEnd; /* Last WHERE clause term */
+ Parse *pParse = pWInfo->pParse; /* Parsing context */
+ Vdbe *v = pParse->pVdbe; /* VDBE under construction */
+ WhereLoop *pLoop = pLevel->pWLoop; /* The loop being coded */
+ int iCur; /* Cursor for table getting the filter */
+
+ assert( pLoop!=0 );
+ assert( v!=0 );
+ assert( pLoop->wsFlags & WHERE_BLOOMFILTER );
+
+ addrOnce = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v);
+ do{
+ const SrcItem *pItem;
+ const Table *pTab;
+ u64 sz;
+ sqlite3WhereExplainBloomFilter(pParse, pWInfo, pLevel);
+ addrCont = sqlite3VdbeMakeLabel(pParse);
+ iCur = pLevel->iTabCur;
+ pLevel->regFilter = ++pParse->nMem;
+
+ /* The Bloom filter is a Blob held in a register. Initialize it
+ ** to zero-filled blob of at least 80K bits, but maybe more if the
+ ** estimated size of the table is larger. We could actually
+ ** measure the size of the table at run-time using OP_Count with
+ ** P3==1 and use that value to initialize the blob. But that makes
+ ** testing complicated. By basing the blob size on the value in the
+ ** sqlite_stat1 table, testing is much easier.
+ */
+ pItem = &pWInfo->pTabList->a[pLevel->iFrom];
+ assert( pItem!=0 );
+ pTab = pItem->pTab;
+ assert( pTab!=0 );
+ sz = sqlite3LogEstToInt(pTab->nRowLogEst);
+ if( sz<10000 ){
+ sz = 10000;
+ }else if( sz>10000000 ){
+ sz = 10000000;
+ }
+ sqlite3VdbeAddOp2(v, OP_Blob, (int)sz, pLevel->regFilter);
+
+ addrTop = sqlite3VdbeAddOp1(v, OP_Rewind, iCur); VdbeCoverage(v);
+ pWCEnd = &pWInfo->sWC.a[pWInfo->sWC.nTerm];
+ for(pTerm=pWInfo->sWC.a; pTerm<pWCEnd; pTerm++){
+ Expr *pExpr = pTerm->pExpr;
+ if( (pTerm->wtFlags & TERM_VIRTUAL)==0
+ && sqlite3ExprIsTableConstant(pExpr, iCur)
+ ){
+ sqlite3ExprIfFalse(pParse, pTerm->pExpr, addrCont, SQLITE_JUMPIFNULL);
+ }
+ }
+ if( pLoop->wsFlags & WHERE_IPK ){
+ int r1 = sqlite3GetTempReg(pParse);
+ sqlite3VdbeAddOp2(v, OP_Rowid, iCur, r1);
+ sqlite3VdbeAddOp4Int(v, OP_FilterAdd, pLevel->regFilter, 0, r1, 1);
+ sqlite3ReleaseTempReg(pParse, r1);
+ }else{
+ Index *pIdx = pLoop->u.btree.pIndex;
+ int n = pLoop->u.btree.nEq;
+ int r1 = sqlite3GetTempRange(pParse, n);
+ int jj;
+ for(jj=0; jj<n; jj++){
+ int iCol = pIdx->aiColumn[jj];
+ assert( pIdx->pTable==pItem->pTab );
+ sqlite3ExprCodeGetColumnOfTable(v, pIdx->pTable, iCur, iCol,r1+jj);
+ }
+ sqlite3VdbeAddOp4Int(v, OP_FilterAdd, pLevel->regFilter, 0, r1, n);
+ sqlite3ReleaseTempRange(pParse, r1, n);
+ }
+ sqlite3VdbeResolveLabel(v, addrCont);
+ sqlite3VdbeAddOp2(v, OP_Next, pLevel->iTabCur, addrTop+1);
+ VdbeCoverage(v);
+ sqlite3VdbeJumpHere(v, addrTop);
+ pLoop->wsFlags &= ~WHERE_BLOOMFILTER;
+ if( OptimizationDisabled(pParse->db, SQLITE_BloomPulldown) ) break;
+ while( ++iLevel < pWInfo->nLevel ){
+ const SrcItem *pTabItem;
+ pLevel = &pWInfo->a[iLevel];
+ pTabItem = &pWInfo->pTabList->a[pLevel->iFrom];
+ if( pTabItem->fg.jointype & JT_LEFT ) continue;
+ pLoop = pLevel->pWLoop;
+ if( NEVER(pLoop==0) ) continue;
+ if( pLoop->prereq & notReady ) continue;
+ if( (pLoop->wsFlags & (WHERE_BLOOMFILTER|WHERE_COLUMN_IN))
+ ==WHERE_BLOOMFILTER
+ ){
+ /* This is a candidate for bloom-filter pull-down (early evaluation).
+ ** The test that WHERE_COLUMN_IN is omitted is important, as we are
+ ** not able to do early evaluation of bloom filters that make use of
+ ** the IN operator */
+ break;
+ }
+ }
+ }while( iLevel < pWInfo->nLevel );
+ sqlite3VdbeJumpHere(v, addrOnce);
+}
+
+
#ifndef SQLITE_OMIT_VIRTUALTABLE
/*
** Allocate and populate an sqlite3_index_info structure. It is the
** responsibility of the caller to eventually release the structure
-** by passing the pointer returned by this function to sqlite3_free().
+** by passing the pointer returned by this function to freeIndexInfo().
*/
static sqlite3_index_info *allocateIndexInfo(
- Parse *pParse, /* The parsing context */
+ WhereInfo *pWInfo, /* The WHERE clause */
WhereClause *pWC, /* The WHERE clause being analyzed */
Bitmask mUnusable, /* Ignore terms with these prereqs */
SrcItem *pSrc, /* The FROM clause term that is the vtab */
- ExprList *pOrderBy, /* The ORDER BY clause */
u16 *pmNoOmit /* Mask of terms not to omit */
){
int i, j;
int nTerm;
+ Parse *pParse = pWInfo->pParse;
struct sqlite3_index_constraint *pIdxCons;
struct sqlite3_index_orderby *pIdxOrderBy;
struct sqlite3_index_constraint_usage *pUsage;
@@ -151569,10 +153099,21 @@ static sqlite3_index_info *allocateIndexInfo(
int nOrderBy;
sqlite3_index_info *pIdxInfo;
u16 mNoOmit = 0;
+ const Table *pTab;
+ int eDistinct = 0;
+ ExprList *pOrderBy = pWInfo->pOrderBy;
- /* Count the number of possible WHERE clause constraints referring
- ** to this virtual table */
+ assert( pSrc!=0 );
+ pTab = pSrc->pTab;
+ assert( pTab!=0 );
+ assert( IsVirtual(pTab) );
+
+ /* Find all WHERE clause constraints referring to this virtual table.
+ ** Mark each term with the TERM_OK flag. Set nTerm to the number of
+ ** terms found.
+ */
for(i=nTerm=0, pTerm=pWC->a; i<pWC->nTerm; i++, pTerm++){
+ pTerm->wtFlags &= ~TERM_OK;
if( pTerm->leftCursor != pSrc->iCursor ) continue;
if( pTerm->prereqRight & mUnusable ) continue;
assert( IsPowerOfTwo(pTerm->eOperator & ~WO_EQUIV) );
@@ -151582,9 +153123,21 @@ static sqlite3_index_info *allocateIndexInfo(
testcase( pTerm->eOperator & WO_ALL );
if( (pTerm->eOperator & ~(WO_EQUIV))==0 ) continue;
if( pTerm->wtFlags & TERM_VNULL ) continue;
+
assert( (pTerm->eOperator & (WO_OR|WO_AND))==0 );
- assert( pTerm->u.x.leftColumn>=(-1) );
+ assert( pTerm->u.x.leftColumn>=XN_ROWID );
+ assert( pTerm->u.x.leftColumn<pTab->nCol );
+
+ /* tag-20191211-002: WHERE-clause constraints are not useful to the
+ ** right-hand table of a LEFT JOIN. See tag-20191211-001 for the
+ ** equivalent restriction for ordinary tables. */
+ if( (pSrc->fg.jointype & JT_LEFT)!=0
+ && !ExprHasProperty(pTerm->pExpr, EP_FromJoin)
+ ){
+ continue;
+ }
nTerm++;
+ pTerm->wtFlags |= TERM_OK;
}
/* If the ORDER BY clause contains only columns in the current
@@ -151596,11 +153149,47 @@ static sqlite3_index_info *allocateIndexInfo(
int n = pOrderBy->nExpr;
for(i=0; i<n; i++){
Expr *pExpr = pOrderBy->a[i].pExpr;
- if( pExpr->op!=TK_COLUMN || pExpr->iTable!=pSrc->iCursor ) break;
+ Expr *pE2;
+
+ /* Skip over constant terms in the ORDER BY clause */
+ if( sqlite3ExprIsConstant(pExpr) ){
+ continue;
+ }
+
+ /* Virtual tables are unable to deal with NULLS FIRST */
if( pOrderBy->a[i].sortFlags & KEYINFO_ORDER_BIGNULL ) break;
+
+ /* First case - a direct column references without a COLLATE operator */
+ if( pExpr->op==TK_COLUMN && pExpr->iTable==pSrc->iCursor ){
+ assert( pExpr->iColumn>=XN_ROWID && pExpr->iColumn<pTab->nCol );
+ continue;
+ }
+
+ /* 2nd case - a column reference with a COLLATE operator. Only match
+ ** of the COLLATE operator matches the collation of the column. */
+ if( pExpr->op==TK_COLLATE
+ && (pE2 = pExpr->pLeft)->op==TK_COLUMN
+ && pE2->iTable==pSrc->iCursor
+ ){
+ const char *zColl; /* The collating sequence name */
+ assert( !ExprHasProperty(pExpr, EP_IntValue) );
+ assert( pExpr->u.zToken!=0 );
+ assert( pE2->iColumn>=XN_ROWID && pE2->iColumn<pTab->nCol );
+ pExpr->iColumn = pE2->iColumn;
+ if( pE2->iColumn<0 ) continue; /* Collseq does not matter for rowid */
+ zColl = sqlite3ColumnColl(&pTab->aCol[pE2->iColumn]);
+ if( zColl==0 ) zColl = sqlite3StrBINARY;
+ if( sqlite3_stricmp(pExpr->u.zToken, zColl)==0 ) continue;
+ }
+
+ /* No matches cause a break out of the loop */
+ break;
}
- if( i==n){
+ if( i==n ){
nOrderBy = n;
+ if( (pWInfo->wctrlFlags & (WHERE_GROUPBY|WHERE_DISTINCTBY)) ){
+ eDistinct = 1 + ((pWInfo->wctrlFlags & WHERE_DISTINCTBY)!=0);
+ }
}
}
@@ -151608,47 +153197,35 @@ static sqlite3_index_info *allocateIndexInfo(
*/
pIdxInfo = sqlite3DbMallocZero(pParse->db, sizeof(*pIdxInfo)
+ (sizeof(*pIdxCons) + sizeof(*pUsage))*nTerm
- + sizeof(*pIdxOrderBy)*nOrderBy + sizeof(*pHidden) );
+ + sizeof(*pIdxOrderBy)*nOrderBy + sizeof(*pHidden)
+ + sizeof(sqlite3_value*)*nTerm );
if( pIdxInfo==0 ){
sqlite3ErrorMsg(pParse, "out of memory");
return 0;
}
pHidden = (struct HiddenIndexInfo*)&pIdxInfo[1];
- pIdxCons = (struct sqlite3_index_constraint*)&pHidden[1];
+ pIdxCons = (struct sqlite3_index_constraint*)&pHidden->aRhs[nTerm];
pIdxOrderBy = (struct sqlite3_index_orderby*)&pIdxCons[nTerm];
pUsage = (struct sqlite3_index_constraint_usage*)&pIdxOrderBy[nOrderBy];
- pIdxInfo->nOrderBy = nOrderBy;
pIdxInfo->aConstraint = pIdxCons;
pIdxInfo->aOrderBy = pIdxOrderBy;
pIdxInfo->aConstraintUsage = pUsage;
pHidden->pWC = pWC;
pHidden->pParse = pParse;
+ pHidden->eDistinct = eDistinct;
+ pHidden->mIn = 0;
for(i=j=0, pTerm=pWC->a; i<pWC->nTerm; i++, pTerm++){
u16 op;
- if( pTerm->leftCursor != pSrc->iCursor ) continue;
- if( pTerm->prereqRight & mUnusable ) continue;
- assert( IsPowerOfTwo(pTerm->eOperator & ~WO_EQUIV) );
- testcase( pTerm->eOperator & WO_IN );
- testcase( pTerm->eOperator & WO_IS );
- testcase( pTerm->eOperator & WO_ISNULL );
- testcase( pTerm->eOperator & WO_ALL );
- if( (pTerm->eOperator & ~(WO_EQUIV))==0 ) continue;
- if( pTerm->wtFlags & TERM_VNULL ) continue;
-
- /* tag-20191211-002: WHERE-clause constraints are not useful to the
- ** right-hand table of a LEFT JOIN. See tag-20191211-001 for the
- ** equivalent restriction for ordinary tables. */
- if( (pSrc->fg.jointype & JT_LEFT)!=0
- && !ExprHasProperty(pTerm->pExpr, EP_FromJoin)
- ){
- continue;
- }
- assert( (pTerm->eOperator & (WO_OR|WO_AND))==0 );
- assert( pTerm->u.x.leftColumn>=(-1) );
+ if( (pTerm->wtFlags & TERM_OK)==0 ) continue;
pIdxCons[j].iColumn = pTerm->u.x.leftColumn;
pIdxCons[j].iTermOffset = i;
op = pTerm->eOperator & WO_ALL;
- if( op==WO_IN ) op = WO_EQ;
+ if( op==WO_IN ){
+ if( (pTerm->wtFlags & TERM_SLICE)==0 ){
+ pHidden->mIn |= SMASKBIT32(j);
+ }
+ op = WO_EQ;
+ }
if( op==WO_AUX ){
pIdxCons[j].op = pTerm->eMatchOp;
}else if( op & (WO_ISNULL|WO_IS) ){
@@ -151681,18 +153258,43 @@ static sqlite3_index_info *allocateIndexInfo(
j++;
}
+ assert( j==nTerm );
pIdxInfo->nConstraint = j;
- for(i=0; i<nOrderBy; i++){
+ for(i=j=0; i<nOrderBy; i++){
Expr *pExpr = pOrderBy->a[i].pExpr;
- pIdxOrderBy[i].iColumn = pExpr->iColumn;
- pIdxOrderBy[i].desc = pOrderBy->a[i].sortFlags & KEYINFO_ORDER_DESC;
+ if( sqlite3ExprIsConstant(pExpr) ) continue;
+ assert( pExpr->op==TK_COLUMN
+ || (pExpr->op==TK_COLLATE && pExpr->pLeft->op==TK_COLUMN
+ && pExpr->iColumn==pExpr->pLeft->iColumn) );
+ pIdxOrderBy[j].iColumn = pExpr->iColumn;
+ pIdxOrderBy[j].desc = pOrderBy->a[i].sortFlags & KEYINFO_ORDER_DESC;
+ j++;
}
+ pIdxInfo->nOrderBy = j;
*pmNoOmit = mNoOmit;
return pIdxInfo;
}
/*
+** Free an sqlite3_index_info structure allocated by allocateIndexInfo()
+** and possibly modified by xBestIndex methods.
+*/
+static void freeIndexInfo(sqlite3 *db, sqlite3_index_info *pIdxInfo){
+ HiddenIndexInfo *pHidden;
+ int i;
+ assert( pIdxInfo!=0 );
+ pHidden = (HiddenIndexInfo*)&pIdxInfo[1];
+ assert( pHidden->pParse!=0 );
+ assert( pHidden->pParse->db==db );
+ for(i=0; i<pIdxInfo->nConstraint; i++){
+ sqlite3ValueFree(pHidden->aRhs[i]); /* IMP: R-14553-25174 */
+ pHidden->aRhs[i] = 0;
+ }
+ sqlite3DbFree(db, pIdxInfo);
+}
+
+/*
** The table object reference passed as the second argument to this function
** must represent a virtual table. This function invokes the xBestIndex()
** method of the virtual table with the sqlite3_index_info object that
@@ -151713,7 +153315,9 @@ static int vtabBestIndex(Parse *pParse, Table *pTab, sqlite3_index_info *p){
int rc;
whereTraceIndexInfoInputs(p);
+ pParse->db->nSchemaLock++;
rc = pVtab->pModule->xBestIndex(pVtab, p);
+ pParse->db->nSchemaLock--;
whereTraceIndexInfoOutputs(p);
if( rc!=SQLITE_OK && rc!=SQLITE_CONSTRAINT ){
@@ -152487,9 +154091,9 @@ SQLITE_PRIVATE void sqlite3WhereLoopPrint(WhereLoop *p, WhereClause *pWC){
sqlite3_free(z);
}
if( p->wsFlags & WHERE_SKIPSCAN ){
- sqlite3DebugPrintf(" f %05x %d-%d", p->wsFlags, p->nLTerm,p->nSkip);
+ sqlite3DebugPrintf(" f %06x %d-%d", p->wsFlags, p->nLTerm,p->nSkip);
}else{
- sqlite3DebugPrintf(" f %05x N %d", p->wsFlags, p->nLTerm);
+ sqlite3DebugPrintf(" f %06x N %d", p->wsFlags, p->nLTerm);
}
sqlite3DebugPrintf(" cost %d,%d,%d\n", p->rSetup, p->rRun, p->nOut);
if( p->nLTerm && (sqlite3WhereTrace & 0x100)!=0 ){
@@ -152949,11 +154553,11 @@ static void whereLoopOutputAdjust(
LogEst iReduce = 0; /* pLoop->nOut should not exceed nRow-iReduce */
assert( (pLoop->wsFlags & WHERE_AUTO_INDEX)==0 );
- for(i=pWC->nTerm, pTerm=pWC->a; i>0; i--, pTerm++){
+ for(i=pWC->nBase, pTerm=pWC->a; i>0; i--, pTerm++){
assert( pTerm!=0 );
- if( (pTerm->wtFlags & TERM_VIRTUAL)!=0 ) break;
- if( (pTerm->prereqAll & pLoop->maskSelf)==0 ) continue;
if( (pTerm->prereqAll & notAllowed)!=0 ) continue;
+ if( (pTerm->prereqAll & pLoop->maskSelf)==0 ) continue;
+ if( (pTerm->wtFlags & TERM_VIRTUAL)!=0 ) continue;
for(j=pLoop->nLTerm-1; j>=0; j--){
pX = pLoop->aLTerm[j];
if( pX==0 ) continue;
@@ -152961,6 +154565,13 @@ static void whereLoopOutputAdjust(
if( pX->iParent>=0 && (&pWC->a[pX->iParent])==pTerm ) break;
}
if( j<0 ){
+ if( pLoop->maskSelf==pTerm->prereqAll ){
+ /* If there are extra terms in the WHERE clause not used by an index
+ ** that depend only on the table being scanned, and that will tend to
+ ** cause many rows to be omitted, then mark that table as
+ ** "self-culling". */
+ pLoop->wsFlags |= WHERE_SELFCULL;
+ }
if( pTerm->truthProb<=0 ){
/* If a truth probability is specified using the likelihood() hints,
** then use the probability provided by the application. */
@@ -152988,7 +154599,9 @@ static void whereLoopOutputAdjust(
}
}
}
- if( pLoop->nOut > nRow-iReduce ) pLoop->nOut = nRow - iReduce;
+ if( pLoop->nOut > nRow-iReduce ){
+ pLoop->nOut = nRow - iReduce;
+ }
}
/*
@@ -153533,7 +155146,7 @@ static int whereUsablePartialIndex(
for(i=0, pTerm=pWC->a; i<pWC->nTerm; i++, pTerm++){
Expr *pExpr;
pExpr = pTerm->pExpr;
- if( (!ExprHasProperty(pExpr, EP_FromJoin) || pExpr->iRightJoinTable==iTab)
+ if( (!ExprHasProperty(pExpr, EP_FromJoin) || pExpr->w.iRightJoinTable==iTab)
&& (isLeft==0 || ExprHasProperty(pExpr, EP_FromJoin))
&& sqlite3ExprImpliesExpr(pParse, pExpr, pWhere, iTab)
&& (pTerm->wtFlags & TERM_VNULL)==0
@@ -153836,6 +155449,15 @@ static int whereLoopAddBtree(
#ifndef SQLITE_OMIT_VIRTUALTABLE
/*
+** Return true if pTerm is a virtual table LIMIT or OFFSET term.
+*/
+static int isLimitTerm(WhereTerm *pTerm){
+ assert( pTerm->eOperator==WO_AUX || pTerm->eMatchOp==0 );
+ return pTerm->eMatchOp>=SQLITE_INDEX_CONSTRAINT_LIMIT
+ && pTerm->eMatchOp<=SQLITE_INDEX_CONSTRAINT_OFFSET;
+}
+
+/*
** Argument pIdxInfo is already populated with all constraints that may
** be used by the virtual table identified by pBuilder->pNew->iTab. This
** function marks a subset of those constraints usable, invokes the
@@ -153862,9 +155484,11 @@ static int whereLoopAddVirtualOne(
u16 mExclude, /* Exclude terms using these operators */
sqlite3_index_info *pIdxInfo, /* Populated object for xBestIndex */
u16 mNoOmit, /* Do not omit these constraints */
- int *pbIn /* OUT: True if plan uses an IN(...) op */
+ int *pbIn, /* OUT: True if plan uses an IN(...) op */
+ int *pbRetryLimit /* OUT: Retry without LIMIT/OFFSET */
){
WhereClause *pWC = pBuilder->pWC;
+ HiddenIndexInfo *pHidden = (HiddenIndexInfo*)&pIdxInfo[1];
struct sqlite3_index_constraint *pIdxCons;
struct sqlite3_index_constraint_usage *pUsage = pIdxInfo->aConstraintUsage;
int i;
@@ -153887,6 +155511,7 @@ static int whereLoopAddVirtualOne(
pIdxCons->usable = 0;
if( (pTerm->prereqRight & mUsable)==pTerm->prereqRight
&& (pTerm->eOperator & mExclude)==0
+ && (pbRetryLimit || !isLimitTerm(pTerm))
){
pIdxCons->usable = 1;
}
@@ -153902,6 +155527,7 @@ static int whereLoopAddVirtualOne(
pIdxInfo->estimatedRows = 25;
pIdxInfo->idxFlags = 0;
pIdxInfo->colUsed = (sqlite3_int64)pSrc->colUsed;
+ pHidden->mHandleIn = 0;
/* Invoke the virtual table xBestIndex() method */
rc = vtabBestIndex(pParse, pSrc->pTab, pIdxInfo);
@@ -153919,8 +155545,8 @@ static int whereLoopAddVirtualOne(
mxTerm = -1;
assert( pNew->nLSlot>=nConstraint );
- for(i=0; i<nConstraint; i++) pNew->aLTerm[i] = 0;
- pNew->u.vtab.omitMask = 0;
+ memset(pNew->aLTerm, 0, sizeof(pNew->aLTerm[0])*nConstraint );
+ memset(&pNew->u.vtab, 0, sizeof(pNew->u.vtab));
pIdxCons = *(struct sqlite3_index_constraint**)&pIdxInfo->aConstraint;
for(i=0; i<nConstraint; i++, pIdxCons++){
int iTerm;
@@ -153954,8 +155580,13 @@ static int whereLoopAddVirtualOne(
}else{
testcase( i!=iTerm );
}
+ if( pTerm->eMatchOp==SQLITE_INDEX_CONSTRAINT_OFFSET ){
+ pNew->u.vtab.bOmitOffset = 1;
+ }
}
- if( (pTerm->eOperator & WO_IN)!=0 ){
+ if( SMASKBIT32(i) & pHidden->mHandleIn ){
+ pNew->u.vtab.mHandleIn |= MASKBIT32(iTerm);
+ }else if( (pTerm->eOperator & WO_IN)!=0 ){
/* A virtual table that is constrained by an IN clause may not
** consume the ORDER BY clause because (1) the order of IN terms
** is not necessarily related to the order of output terms and
@@ -153965,6 +155596,21 @@ static int whereLoopAddVirtualOne(
pIdxInfo->idxFlags &= ~SQLITE_INDEX_SCAN_UNIQUE;
*pbIn = 1; assert( (mExclude & WO_IN)==0 );
}
+
+ if( isLimitTerm(pTerm) && *pbIn ){
+ /* If there is an IN(...) term handled as an == (separate call to
+ ** xFilter for each value on the RHS of the IN) and a LIMIT or
+ ** OFFSET term handled as well, the plan is unusable. Set output
+ ** variable *pbRetryLimit to true to tell the caller to retry with
+ ** LIMIT and OFFSET disabled. */
+ if( pIdxInfo->needToFreeIdxStr ){
+ sqlite3_free(pIdxInfo->idxStr);
+ pIdxInfo->idxStr = 0;
+ pIdxInfo->needToFreeIdxStr = 0;
+ }
+ *pbRetryLimit = 1;
+ return SQLITE_OK;
+ }
}
}
@@ -154009,11 +155655,19 @@ static int whereLoopAddVirtualOne(
}
/*
-** If this function is invoked from within an xBestIndex() callback, it
-** returns a pointer to a buffer containing the name of the collation
-** sequence associated with element iCons of the sqlite3_index_info.aConstraint
-** array. Or, if iCons is out of range or there is no active xBestIndex
-** call, return NULL.
+** Return the collating sequence for a constraint passed into xBestIndex.
+**
+** pIdxInfo must be an sqlite3_index_info structure passed into xBestIndex.
+** This routine depends on there being a HiddenIndexInfo structure immediately
+** following the sqlite3_index_info structure.
+**
+** Return a pointer to the collation name:
+**
+** 1. If there is an explicit COLLATE operator on the constaint, return it.
+**
+** 2. Else, if the column has an alternative collation, return that.
+**
+** 3. Otherwise, return "BINARY".
*/
SQLITE_API const char *sqlite3_vtab_collation(sqlite3_index_info *pIdxInfo, int iCons){
HiddenIndexInfo *pHidden = (HiddenIndexInfo*)&pIdxInfo[1];
@@ -154031,6 +155685,88 @@ SQLITE_API const char *sqlite3_vtab_collation(sqlite3_index_info *pIdxInfo, int
}
/*
+** Return true if constraint iCons is really an IN(...) constraint, or
+** false otherwise. If iCons is an IN(...) constraint, set (if bHandle!=0)
+** or clear (if bHandle==0) the flag to handle it using an iterator.
+*/
+SQLITE_API int sqlite3_vtab_in(sqlite3_index_info *pIdxInfo, int iCons, int bHandle){
+ HiddenIndexInfo *pHidden = (HiddenIndexInfo*)&pIdxInfo[1];
+ u32 m = SMASKBIT32(iCons);
+ if( m & pHidden->mIn ){
+ if( bHandle==0 ){
+ pHidden->mHandleIn &= ~m;
+ }else if( bHandle>0 ){
+ pHidden->mHandleIn |= m;
+ }
+ return 1;
+ }
+ return 0;
+}
+
+/*
+** This interface is callable from within the xBestIndex callback only.
+**
+** If possible, set (*ppVal) to point to an object containing the value
+** on the right-hand-side of constraint iCons.
+*/
+SQLITE_API int sqlite3_vtab_rhs_value(
+ sqlite3_index_info *pIdxInfo, /* Copy of first argument to xBestIndex */
+ int iCons, /* Constraint for which RHS is wanted */
+ sqlite3_value **ppVal /* Write value extracted here */
+){
+ HiddenIndexInfo *pH = (HiddenIndexInfo*)&pIdxInfo[1];
+ sqlite3_value *pVal = 0;
+ int rc = SQLITE_OK;
+ if( iCons<0 || iCons>=pIdxInfo->nConstraint ){
+ rc = SQLITE_MISUSE; /* EV: R-30545-25046 */
+ }else{
+ if( pH->aRhs[iCons]==0 ){
+ WhereTerm *pTerm = &pH->pWC->a[pIdxInfo->aConstraint[iCons].iTermOffset];
+ rc = sqlite3ValueFromExpr(
+ pH->pParse->db, pTerm->pExpr->pRight, ENC(pH->pParse->db),
+ SQLITE_AFF_BLOB, &pH->aRhs[iCons]
+ );
+ testcase( rc!=SQLITE_OK );
+ }
+ pVal = pH->aRhs[iCons];
+ }
+ *ppVal = pVal;
+
+ if( rc==SQLITE_OK && pVal==0 ){ /* IMP: R-19933-32160 */
+ rc = SQLITE_NOTFOUND; /* IMP: R-36424-56542 */
+ }
+
+ return rc;
+}
+
+/*
+** Return true if ORDER BY clause may be handled as DISTINCT.
+*/
+SQLITE_API int sqlite3_vtab_distinct(sqlite3_index_info *pIdxInfo){
+ HiddenIndexInfo *pHidden = (HiddenIndexInfo*)&pIdxInfo[1];
+ assert( pHidden->eDistinct==0
+ || pHidden->eDistinct==1
+ || pHidden->eDistinct==2 );
+ return pHidden->eDistinct;
+}
+
+#if (defined(SQLITE_ENABLE_DBPAGE_VTAB) || defined(SQLITE_TEST)) \
+ && !defined(SQLITE_OMIT_VIRTUALTABLE)
+/*
+** Cause the prepared statement that is associated with a call to
+** xBestIndex to open write transactions on all attached schemas.
+** This is used by the (built-in) sqlite_dbpage virtual table.
+*/
+SQLITE_PRIVATE void sqlite3VtabWriteAll(sqlite3_index_info *pIdxInfo){
+ HiddenIndexInfo *pHidden = (HiddenIndexInfo*)&pIdxInfo[1];
+ Parse *pParse = pHidden->pParse;
+ int nDb = pParse->db->nDb;
+ int i;
+ for(i=0; i<nDb; i++) sqlite3BeginWriteOperation(pParse, 0, i);
+}
+#endif
+
+/*
** Add all WhereLoop objects for a table of the join identified by
** pBuilder->pNew->iTab. That table is guaranteed to be a virtual table.
**
@@ -154071,6 +155807,7 @@ static int whereLoopAddVirtual(
WhereLoop *pNew;
Bitmask mBest; /* Tables used by best possible plan */
u16 mNoOmit;
+ int bRetry = 0; /* True to retry with LIMIT/OFFSET disabled */
assert( (mPrereq & mUnusable)==0 );
pWInfo = pBuilder->pWInfo;
@@ -154079,8 +155816,7 @@ static int whereLoopAddVirtual(
pNew = pBuilder->pNew;
pSrc = &pWInfo->pTabList->a[pNew->iTab];
assert( IsVirtual(pSrc->pTab) );
- p = allocateIndexInfo(pParse, pWC, mUnusable, pSrc, pBuilder->pOrderBy,
- &mNoOmit);
+ p = allocateIndexInfo(pWInfo, pWC, mUnusable, pSrc, &mNoOmit);
if( p==0 ) return SQLITE_NOMEM_BKPT;
pNew->rSetup = 0;
pNew->wsFlags = WHERE_VIRTUALTABLE;
@@ -154088,14 +155824,22 @@ static int whereLoopAddVirtual(
pNew->u.vtab.needFree = 0;
nConstraint = p->nConstraint;
if( whereLoopResize(pParse->db, pNew, nConstraint) ){
- sqlite3DbFree(pParse->db, p);
+ freeIndexInfo(pParse->db, p);
return SQLITE_NOMEM_BKPT;
}
/* First call xBestIndex() with all constraints usable. */
WHERETRACE(0x800, ("BEGIN %s.addVirtual()\n", pSrc->pTab->zName));
WHERETRACE(0x40, (" VirtualOne: all usable\n"));
- rc = whereLoopAddVirtualOne(pBuilder, mPrereq, ALLBITS, 0, p, mNoOmit, &bIn);
+ rc = whereLoopAddVirtualOne(
+ pBuilder, mPrereq, ALLBITS, 0, p, mNoOmit, &bIn, &bRetry
+ );
+ if( bRetry ){
+ assert( rc==SQLITE_OK );
+ rc = whereLoopAddVirtualOne(
+ pBuilder, mPrereq, ALLBITS, 0, p, mNoOmit, &bIn, 0
+ );
+ }
/* If the call to xBestIndex() with all terms enabled produced a plan
** that does not require any source tables (IOW: a plan with mBest==0)
@@ -154113,7 +155857,7 @@ static int whereLoopAddVirtual(
if( bIn ){
WHERETRACE(0x40, (" VirtualOne: all usable w/o IN\n"));
rc = whereLoopAddVirtualOne(
- pBuilder, mPrereq, ALLBITS, WO_IN, p, mNoOmit, &bIn);
+ pBuilder, mPrereq, ALLBITS, WO_IN, p, mNoOmit, &bIn, 0);
assert( bIn==0 );
mBestNoIn = pNew->prereq & ~mPrereq;
if( mBestNoIn==0 ){
@@ -154140,7 +155884,7 @@ static int whereLoopAddVirtual(
WHERETRACE(0x40, (" VirtualOne: mPrev=%04llx mNext=%04llx\n",
(sqlite3_uint64)mPrev, (sqlite3_uint64)mNext));
rc = whereLoopAddVirtualOne(
- pBuilder, mPrereq, mNext|mPrereq, 0, p, mNoOmit, &bIn);
+ pBuilder, mPrereq, mNext|mPrereq, 0, p, mNoOmit, &bIn, 0);
if( pNew->prereq==mPrereq ){
seenZero = 1;
if( bIn==0 ) seenZeroNoIN = 1;
@@ -154153,7 +155897,7 @@ static int whereLoopAddVirtual(
if( rc==SQLITE_OK && seenZero==0 ){
WHERETRACE(0x40, (" VirtualOne: all disabled\n"));
rc = whereLoopAddVirtualOne(
- pBuilder, mPrereq, mPrereq, 0, p, mNoOmit, &bIn);
+ pBuilder, mPrereq, mPrereq, 0, p, mNoOmit, &bIn, 0);
if( bIn==0 ) seenZeroNoIN = 1;
}
@@ -154163,12 +155907,12 @@ static int whereLoopAddVirtual(
if( rc==SQLITE_OK && seenZeroNoIN==0 ){
WHERETRACE(0x40, (" VirtualOne: all disabled and w/o IN\n"));
rc = whereLoopAddVirtualOne(
- pBuilder, mPrereq, mPrereq, WO_IN, p, mNoOmit, &bIn);
+ pBuilder, mPrereq, mPrereq, WO_IN, p, mNoOmit, &bIn, 0);
}
}
if( p->needToFreeIdxStr ) sqlite3_free(p->idxStr);
- sqlite3DbFreeNN(pParse->db, p);
+ freeIndexInfo(pParse->db, p);
WHERETRACE(0x800, ("END %s.addVirtual(), rc=%d\n", pSrc->pTab->zName, rc));
return rc;
}
@@ -154212,7 +155956,6 @@ static int whereLoopAddOr(
int i, j;
sSubBuild = *pBuilder;
- sSubBuild.pOrderBy = 0;
sSubBuild.pOrSet = &sCur;
WHERETRACE(0x200, ("Begin processing OR-clause %p\n", pTerm));
@@ -154224,6 +155967,7 @@ static int whereLoopAddOr(
tempWC.pOuter = pWC;
tempWC.op = TK_AND;
tempWC.nTerm = 1;
+ tempWC.nBase = 1;
tempWC.a = pOrTerm;
sSubBuild.pWC = &tempWC;
}else{
@@ -155331,6 +157075,150 @@ static void showAllWhereLoops(WhereInfo *pWInfo, WhereClause *pWC){
# define WHERETRACE_ALL_LOOPS(W,C)
#endif
+/* Attempt to omit tables from a join that do not affect the result.
+** For a table to not affect the result, the following must be true:
+**
+** 1) The query must not be an aggregate.
+** 2) The table must be the RHS of a LEFT JOIN.
+** 3) Either the query must be DISTINCT, or else the ON or USING clause
+** must contain a constraint that limits the scan of the table to
+** at most a single row.
+** 4) The table must not be referenced by any part of the query apart
+** from its own USING or ON clause.
+**
+** For example, given:
+**
+** CREATE TABLE t1(ipk INTEGER PRIMARY KEY, v1);
+** CREATE TABLE t2(ipk INTEGER PRIMARY KEY, v2);
+** CREATE TABLE t3(ipk INTEGER PRIMARY KEY, v3);
+**
+** then table t2 can be omitted from the following:
+**
+** SELECT v1, v3 FROM t1
+** LEFT JOIN t2 ON (t1.ipk=t2.ipk)
+** LEFT JOIN t3 ON (t1.ipk=t3.ipk)
+**
+** or from:
+**
+** SELECT DISTINCT v1, v3 FROM t1
+** LEFT JOIN t2
+** LEFT JOIN t3 ON (t1.ipk=t3.ipk)
+*/
+static SQLITE_NOINLINE Bitmask whereOmitNoopJoin(
+ WhereInfo *pWInfo,
+ Bitmask notReady
+){
+ int i;
+ Bitmask tabUsed;
+
+ /* Preconditions checked by the caller */
+ assert( pWInfo->nLevel>=2 );
+ assert( OptimizationEnabled(pWInfo->pParse->db, SQLITE_OmitNoopJoin) );
+
+ /* These two preconditions checked by the caller combine to guarantee
+ ** condition (1) of the header comment */
+ assert( pWInfo->pResultSet!=0 );
+ assert( 0==(pWInfo->wctrlFlags & WHERE_AGG_DISTINCT) );
+
+ tabUsed = sqlite3WhereExprListUsage(&pWInfo->sMaskSet, pWInfo->pResultSet);
+ if( pWInfo->pOrderBy ){
+ tabUsed |= sqlite3WhereExprListUsage(&pWInfo->sMaskSet, pWInfo->pOrderBy);
+ }
+ for(i=pWInfo->nLevel-1; i>=1; i--){
+ WhereTerm *pTerm, *pEnd;
+ SrcItem *pItem;
+ WhereLoop *pLoop;
+ pLoop = pWInfo->a[i].pWLoop;
+ pItem = &pWInfo->pTabList->a[pLoop->iTab];
+ if( (pItem->fg.jointype & JT_LEFT)==0 ) continue;
+ if( (pWInfo->wctrlFlags & WHERE_WANT_DISTINCT)==0
+ && (pLoop->wsFlags & WHERE_ONEROW)==0
+ ){
+ continue;
+ }
+ if( (tabUsed & pLoop->maskSelf)!=0 ) continue;
+ pEnd = pWInfo->sWC.a + pWInfo->sWC.nTerm;
+ for(pTerm=pWInfo->sWC.a; pTerm<pEnd; pTerm++){
+ if( (pTerm->prereqAll & pLoop->maskSelf)!=0 ){
+ if( !ExprHasProperty(pTerm->pExpr, EP_FromJoin)
+ || pTerm->pExpr->w.iRightJoinTable!=pItem->iCursor
+ ){
+ break;
+ }
+ }
+ }
+ if( pTerm<pEnd ) continue;
+ WHERETRACE(0xffff, ("-> drop loop %c not used\n", pLoop->cId));
+ notReady &= ~pLoop->maskSelf;
+ for(pTerm=pWInfo->sWC.a; pTerm<pEnd; pTerm++){
+ if( (pTerm->prereqAll & pLoop->maskSelf)!=0 ){
+ pTerm->wtFlags |= TERM_CODED;
+ }
+ }
+ if( i!=pWInfo->nLevel-1 ){
+ int nByte = (pWInfo->nLevel-1-i) * sizeof(WhereLevel);
+ memmove(&pWInfo->a[i], &pWInfo->a[i+1], nByte);
+ }
+ pWInfo->nLevel--;
+ assert( pWInfo->nLevel>0 );
+ }
+ return notReady;
+}
+
+/*
+** Check to see if there are any SEARCH loops that might benefit from
+** using a Bloom filter. Consider a Bloom filter if:
+**
+** (1) The SEARCH happens more than N times where N is the number
+** of rows in the table that is being considered for the Bloom
+** filter.
+** (2) Some searches are expected to find zero rows. (This is determined
+** by the WHERE_SELFCULL flag on the term.)
+** (3) Bloom-filter processing is not disabled. (Checked by the
+** caller.)
+** (4) The size of the table being searched is known by ANALYZE.
+**
+** This block of code merely checks to see if a Bloom filter would be
+** appropriate, and if so sets the WHERE_BLOOMFILTER flag on the
+** WhereLoop. The implementation of the Bloom filter comes further
+** down where the code for each WhereLoop is generated.
+*/
+static SQLITE_NOINLINE void whereCheckIfBloomFilterIsUseful(
+ const WhereInfo *pWInfo
+){
+ int i;
+ LogEst nSearch;
+
+ assert( pWInfo->nLevel>=2 );
+ assert( OptimizationEnabled(pWInfo->pParse->db, SQLITE_BloomFilter) );
+ nSearch = pWInfo->a[0].pWLoop->nOut;
+ for(i=1; i<pWInfo->nLevel; i++){
+ WhereLoop *pLoop = pWInfo->a[i].pWLoop;
+ const unsigned int reqFlags = (WHERE_SELFCULL|WHERE_COLUMN_EQ);
+ if( (pLoop->wsFlags & reqFlags)==reqFlags
+ /* vvvvvv--- Always the case if WHERE_COLUMN_EQ is defined */
+ && ALWAYS((pLoop->wsFlags & (WHERE_IPK|WHERE_INDEXED))!=0)
+ ){
+ SrcItem *pItem = &pWInfo->pTabList->a[pLoop->iTab];
+ Table *pTab = pItem->pTab;
+ pTab->tabFlags |= TF_StatsUsed;
+ if( nSearch > pTab->nRowLogEst
+ && (pTab->tabFlags & TF_HasStat1)!=0
+ ){
+ testcase( pItem->fg.jointype & JT_LEFT );
+ pLoop->wsFlags |= WHERE_BLOOMFILTER;
+ pLoop->wsFlags &= ~WHERE_IDX_ONLY;
+ WHERETRACE(0xffff, (
+ "-> use Bloom-filter on loop %c because there are ~%.1e "
+ "lookups into %s which has only ~%.1e rows\n",
+ pLoop->cId, (double)sqlite3LogEstToInt(nSearch), pTab->zName,
+ (double)sqlite3LogEstToInt(pTab->nRowLogEst)));
+ }
+ }
+ nSearch += pLoop->nOut;
+ }
+}
+
/*
** Generate the beginning of the loop used for WHERE clause processing.
** The return value is a pointer to an opaque structure that contains
@@ -155425,6 +157313,7 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
Expr *pWhere, /* The WHERE clause */
ExprList *pOrderBy, /* An ORDER BY (or GROUP BY) clause, or NULL */
ExprList *pResultSet, /* Query result set. Req'd for DISTINCT */
+ Select *pLimit, /* Use this LIMIT/OFFSET clause, if any */
u16 wctrlFlags, /* The WHERE_* flags defined in sqliteInt.h */
int iAuxArg /* If WHERE_OR_SUBCLAUSE is set, index cursor number
** If WHERE_USE_LIMIT, then the limit amount */
@@ -155459,13 +157348,6 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
/* An ORDER/GROUP BY clause of more than 63 terms cannot be optimized */
testcase( pOrderBy && pOrderBy->nExpr==BMS-1 );
if( pOrderBy && pOrderBy->nExpr>=BMS ) pOrderBy = 0;
- sWLB.pOrderBy = pOrderBy;
-
- /* Disable the DISTINCT optimization if SQLITE_DistinctOpt is set via
- ** sqlite3_test_ctrl(SQLITE_TESTCTRL_OPTIMIZATIONS,...) */
- if( OptimizationDisabled(db, SQLITE_DistinctOpt) ){
- wctrlFlags &= ~WHERE_WANT_DISTINCT;
- }
/* The number of tables in the FROM clause is limited by the number of
** bits in a Bitmask
@@ -155508,11 +157390,18 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
pWInfo->wctrlFlags = wctrlFlags;
pWInfo->iLimit = iAuxArg;
pWInfo->savedNQueryLoop = pParse->nQueryLoop;
+#ifndef SQLITE_OMIT_VIRTUALTABLE
+ pWInfo->pLimit = pLimit;
+#endif
memset(&pWInfo->nOBSat, 0,
offsetof(WhereInfo,sWC) - offsetof(WhereInfo,nOBSat));
memset(&pWInfo->a[0], 0, sizeof(WhereLoop)+nTabList*sizeof(WhereLevel));
assert( pWInfo->eOnePass==ONEPASS_OFF ); /* ONEPASS defaults to OFF */
pMaskSet = &pWInfo->sMaskSet;
+ pMaskSet->n = 0;
+ pMaskSet->ix[0] = -99; /* Initialize ix[0] to a value that can never be
+ ** a valid cursor number, to avoid an initial
+ ** test for pMaskSet->n==0 in sqlite3WhereGetMask() */
sWLB.pWInfo = pWInfo;
sWLB.pWC = &pWInfo->sWC;
sWLB.pNew = (WhereLoop*)(((char*)pWInfo)+nByteWInfo);
@@ -155525,7 +157414,6 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
/* Split the WHERE clause into separate subexpressions where each
** subexpression is separated by an AND operator.
*/
- initMaskSet(pMaskSet);
sqlite3WhereClauseInit(&pWInfo->sWC, pWInfo);
sqlite3WhereSplit(&pWInfo->sWC, pWhere, TK_AND);
@@ -155533,7 +157421,9 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
*/
if( nTabList==0 ){
if( pOrderBy ) pWInfo->nOBSat = pOrderBy->nExpr;
- if( wctrlFlags & WHERE_WANT_DISTINCT ){
+ if( (wctrlFlags & WHERE_WANT_DISTINCT)!=0
+ && OptimizationEnabled(db, SQLITE_DistinctOpt)
+ ){
pWInfo->eDistinct = WHERE_DISTINCT_UNIQUE;
}
ExplainQueryPlan((pParse, 0, "SCAN CONSTANT ROW"));
@@ -155571,6 +157461,7 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
/* Analyze all of the subexpressions. */
sqlite3WhereExprAnalyze(pTabList, &pWInfo->sWC);
+ sqlite3WhereAddLimit(&pWInfo->sWC, pLimit);
if( db->mallocFailed ) goto whereBeginError;
/* Special case: WHERE terms that do not refer to any tables in the join
@@ -155584,7 +157475,7 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
** FROM ... WHERE random()>0; -- eval random() once per row
** FROM ... WHERE (SELECT random())>0; -- eval random() once overall
*/
- for(ii=0; ii<sWLB.pWC->nTerm; ii++){
+ for(ii=0; ii<sWLB.pWC->nBase; ii++){
WhereTerm *pT = &sWLB.pWC->a[ii];
if( pT->wtFlags & TERM_VIRTUAL ) continue;
if( pT->prereqAll==0 && (nTabList==0 || exprIsDeterministic(pT->pExpr)) ){
@@ -155594,7 +157485,12 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
}
if( wctrlFlags & WHERE_WANT_DISTINCT ){
- if( isDistinctRedundant(pParse, pTabList, &pWInfo->sWC, pResultSet) ){
+ if( OptimizationDisabled(db, SQLITE_DistinctOpt) ){
+ /* Disable the DISTINCT optimization if SQLITE_DistinctOpt is set via
+ ** sqlite3_test_ctrl(SQLITE_TESTCTRL_OPTIMIZATIONS,...) */
+ wctrlFlags &= ~WHERE_WANT_DISTINCT;
+ pWInfo->wctrlFlags &= ~WHERE_WANT_DISTINCT;
+ }else if( isDistinctRedundant(pParse, pTabList, &pWInfo->sWC, pResultSet) ){
/* The DISTINCT marking is pointless. Ignore it. */
pWInfo->eDistinct = WHERE_DISTINCT_UNIQUE;
}else if( pOrderBy==0 ){
@@ -155665,9 +157561,10 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
if( pWInfo->pOrderBy==0 && (db->flags & SQLITE_ReverseOrder)!=0 ){
pWInfo->revMask = ALLBITS;
}
- if( pParse->nErr || db->mallocFailed ){
+ if( pParse->nErr ){
goto whereBeginError;
}
+ assert( db->mallocFailed==0 );
#ifdef WHERETRACE_ENABLED
if( sqlite3WhereTrace ){
sqlite3DebugPrintf("---- Solution nRow=%d", pWInfo->nRowOut);
@@ -155695,34 +157592,15 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
}
#endif
- /* Attempt to omit tables from the join that do not affect the result.
- ** For a table to not affect the result, the following must be true:
- **
- ** 1) The query must not be an aggregate.
- ** 2) The table must be the RHS of a LEFT JOIN.
- ** 3) Either the query must be DISTINCT, or else the ON or USING clause
- ** must contain a constraint that limits the scan of the table to
- ** at most a single row.
- ** 4) The table must not be referenced by any part of the query apart
- ** from its own USING or ON clause.
+ /* Attempt to omit tables from a join that do not affect the result.
+ ** See the comment on whereOmitNoopJoin() for further information.
**
- ** For example, given:
- **
- ** CREATE TABLE t1(ipk INTEGER PRIMARY KEY, v1);
- ** CREATE TABLE t2(ipk INTEGER PRIMARY KEY, v2);
- ** CREATE TABLE t3(ipk INTEGER PRIMARY KEY, v3);
- **
- ** then table t2 can be omitted from the following:
- **
- ** SELECT v1, v3 FROM t1
- ** LEFT JOIN t2 ON (t1.ipk=t2.ipk)
- ** LEFT JOIN t3 ON (t1.ipk=t3.ipk)
- **
- ** or from:
- **
- ** SELECT DISTINCT v1, v3 FROM t1
- ** LEFT JOIN t2
- ** LEFT JOIN t3 ON (t1.ipk=t3.ipk)
+ ** This query optimization is factored out into a separate "no-inline"
+ ** procedure to keep the sqlite3WhereBegin() procedure from becoming
+ ** too large. If sqlite3WhereBegin() becomes too large, that prevents
+ ** some C-compiler optimizers from in-lining the
+ ** sqlite3WhereCodeOneLoopStart() procedure, and it is important to
+ ** in-line sqlite3WhereCodeOneLoopStart() for performance reasons.
*/
notReady = ~(Bitmask)0;
if( pWInfo->nLevel>=2
@@ -155730,49 +157608,20 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
&& 0==(wctrlFlags & WHERE_AGG_DISTINCT) /* condition (1) above */
&& OptimizationEnabled(db, SQLITE_OmitNoopJoin)
){
- int i;
- Bitmask tabUsed = sqlite3WhereExprListUsage(pMaskSet, pResultSet);
- if( sWLB.pOrderBy ){
- tabUsed |= sqlite3WhereExprListUsage(pMaskSet, sWLB.pOrderBy);
- }
- for(i=pWInfo->nLevel-1; i>=1; i--){
- WhereTerm *pTerm, *pEnd;
- SrcItem *pItem;
- pLoop = pWInfo->a[i].pWLoop;
- pItem = &pWInfo->pTabList->a[pLoop->iTab];
- if( (pItem->fg.jointype & JT_LEFT)==0 ) continue;
- if( (wctrlFlags & WHERE_WANT_DISTINCT)==0
- && (pLoop->wsFlags & WHERE_ONEROW)==0
- ){
- continue;
- }
- if( (tabUsed & pLoop->maskSelf)!=0 ) continue;
- pEnd = sWLB.pWC->a + sWLB.pWC->nTerm;
- for(pTerm=sWLB.pWC->a; pTerm<pEnd; pTerm++){
- if( (pTerm->prereqAll & pLoop->maskSelf)!=0 ){
- if( !ExprHasProperty(pTerm->pExpr, EP_FromJoin)
- || pTerm->pExpr->iRightJoinTable!=pItem->iCursor
- ){
- break;
- }
- }
- }
- if( pTerm<pEnd ) continue;
- WHERETRACE(0xffff, ("-> drop loop %c not used\n", pLoop->cId));
- notReady &= ~pLoop->maskSelf;
- for(pTerm=sWLB.pWC->a; pTerm<pEnd; pTerm++){
- if( (pTerm->prereqAll & pLoop->maskSelf)!=0 ){
- pTerm->wtFlags |= TERM_CODED;
- }
- }
- if( i!=pWInfo->nLevel-1 ){
- int nByte = (pWInfo->nLevel-1-i) * sizeof(WhereLevel);
- memmove(&pWInfo->a[i], &pWInfo->a[i+1], nByte);
- }
- pWInfo->nLevel--;
- nTabList--;
- }
+ notReady = whereOmitNoopJoin(pWInfo, notReady);
+ nTabList = pWInfo->nLevel;
+ assert( nTabList>0 );
}
+
+ /* Check to see if there are any SEARCH loops that might benefit from
+ ** using a Bloom filter.
+ */
+ if( pWInfo->nLevel>=2
+ && OptimizationEnabled(db, SQLITE_BloomFilter)
+ ){
+ whereCheckIfBloomFilterIsUseful(pWInfo);
+ }
+
#if defined(WHERETRACE_ENABLED)
if( sqlite3WhereTrace & 0x100 ){ /* Display all terms of the WHERE clause */
sqlite3DebugPrintf("---- WHERE clause at end of analysis:\n");
@@ -155859,6 +157708,7 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
if( pWInfo->eOnePass==ONEPASS_OFF
&& pTab->nCol<BMS
&& (pTab->tabFlags & (TF_HasGenerated|TF_WithoutRowid))==0
+ && (pLoop->wsFlags & (WHERE_AUTO_INDEX|WHERE_BLOOMFILTER))==0
){
/* If we know that only a prefix of the record will be used,
** it is advantageous to reduce the "column count" field in
@@ -155961,13 +157811,17 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
if( pParse->nErr ) goto whereBeginError;
pLevel = &pWInfo->a[ii];
wsFlags = pLevel->pWLoop->wsFlags;
+ if( (wsFlags & (WHERE_AUTO_INDEX|WHERE_BLOOMFILTER))!=0 ){
+ if( (wsFlags & WHERE_AUTO_INDEX)!=0 ){
#ifndef SQLITE_OMIT_AUTOMATIC_INDEX
- if( (pLevel->pWLoop->wsFlags & WHERE_AUTO_INDEX)!=0 ){
- constructAutomaticIndex(pParse, &pWInfo->sWC,
- &pTabList->a[pLevel->iFrom], notReady, pLevel);
+ constructAutomaticIndex(pParse, &pWInfo->sWC,
+ &pTabList->a[pLevel->iFrom], notReady, pLevel);
+#endif
+ }else{
+ sqlite3ConstructBloomFilter(pWInfo, ii, pLevel, notReady);
+ }
if( db->mallocFailed ) goto whereBeginError;
}
-#endif
addrExplain = sqlite3WhereExplainOneScan(
pParse, pTabList, pLevel, wctrlFlags
);
@@ -156271,6 +158125,10 @@ SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo *pWInfo){
Index *pPk = sqlite3PrimaryKeyIndex(pTab);
x = pPk->aiColumn[x];
assert( x>=0 );
+#ifdef SQLITE_ENABLE_OFFSET_SQL_FUNC
+ }else if( pOp->opcode==OP_Offset ){
+ /* Do not need to translate the column number */
+#endif
}else{
testcase( x!=sqlite3StorageColumnToTable(pTab,x) );
x = sqlite3StorageColumnToTable(pTab,x);
@@ -157270,7 +159128,11 @@ static int disallowAggregatesInOrderByCb(Walker *pWalker, Expr *pExpr){
*/
SQLITE_PRIVATE int sqlite3WindowRewrite(Parse *pParse, Select *p){
int rc = SQLITE_OK;
- if( p->pWin && p->pPrior==0 && ALWAYS((p->selFlags & SF_WinRewrite)==0) ){
+ if( p->pWin
+ && p->pPrior==0
+ && ALWAYS((p->selFlags & SF_WinRewrite)==0)
+ && ALWAYS(!IN_RENAME_OBJECT)
+ ){
Vdbe *v = sqlite3GetVdbe(pParse);
sqlite3 *db = pParse->db;
Select *pSub = 0; /* The subquery */
@@ -157345,6 +159207,7 @@ SQLITE_PRIVATE int sqlite3WindowRewrite(Parse *pParse, Select *p){
for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
ExprList *pArgs;
assert( ExprUseXList(pWin->pOwner) );
+ assert( pWin->pFunc!=0 );
pArgs = pWin->pOwner->x.pList;
if( pWin->pFunc->funcFlags & SQLITE_FUNC_SUBTYPE ){
selectWindowRewriteEList(pParse, pMWin, pSrc, pArgs, pTab, &pSublist);
@@ -157419,12 +159282,7 @@ SQLITE_PRIVATE int sqlite3WindowRewrite(Parse *pParse, Select *p){
sqlite3ParserAddCleanup(pParse, sqlite3DbFree, pTab);
}
- if( rc ){
- if( pParse->nErr==0 ){
- assert( pParse->db->mallocFailed );
- sqlite3ErrorToParser(pParse->db, SQLITE_NOMEM);
- }
- }
+ assert( rc==SQLITE_OK || pParse->nErr!=0 );
return rc;
}
@@ -159572,10 +161430,7 @@ static void updateDeleteLimitError(
}
- /* Construct a new Expr object from a single identifier. Use the
- ** new Expr to populate pOut. Set the span of pOut to be the identifier
- ** that created the expression.
- */
+ /* Construct a new Expr object from a single token */
static Expr *tokenExpr(Parse *pParse, int op, Token t){
Expr *p = sqlite3DbMallocRawNN(pParse->db, sizeof(Expr)+t.n+1);
if( p ){
@@ -159595,6 +161450,7 @@ static void updateDeleteLimitError(
p->u.zToken = (char*)&p[1];
memcpy(p->u.zToken, t.z, t.n);
p->u.zToken[t.n] = 0;
+ p->w.iOfst = (int)(t.z - pParse->zTail);
if( sqlite3Isquote(p->u.zToken[0]) ){
sqlite3DequoteExpr(p);
}
@@ -159751,75 +161607,76 @@ static void updateDeleteLimitError(
#define TK_SLASH 99
#define TK_REM 100
#define TK_CONCAT 101
-#define TK_COLLATE 102
-#define TK_BITNOT 103
-#define TK_ON 104
-#define TK_INDEXED 105
-#define TK_STRING 106
-#define TK_JOIN_KW 107
-#define TK_CONSTRAINT 108
-#define TK_DEFAULT 109
-#define TK_NULL 110
-#define TK_PRIMARY 111
-#define TK_UNIQUE 112
-#define TK_CHECK 113
-#define TK_REFERENCES 114
-#define TK_AUTOINCR 115
-#define TK_INSERT 116
-#define TK_DELETE 117
-#define TK_UPDATE 118
-#define TK_SET 119
-#define TK_DEFERRABLE 120
-#define TK_FOREIGN 121
-#define TK_DROP 122
-#define TK_UNION 123
-#define TK_ALL 124
-#define TK_EXCEPT 125
-#define TK_INTERSECT 126
-#define TK_SELECT 127
-#define TK_VALUES 128
-#define TK_DISTINCT 129
-#define TK_DOT 130
-#define TK_FROM 131
-#define TK_JOIN 132
-#define TK_USING 133
-#define TK_ORDER 134
-#define TK_GROUP 135
-#define TK_HAVING 136
-#define TK_LIMIT 137
-#define TK_WHERE 138
-#define TK_RETURNING 139
-#define TK_INTO 140
-#define TK_NOTHING 141
-#define TK_FLOAT 142
-#define TK_BLOB 143
-#define TK_INTEGER 144
-#define TK_VARIABLE 145
-#define TK_CASE 146
-#define TK_WHEN 147
-#define TK_THEN 148
-#define TK_ELSE 149
-#define TK_INDEX 150
-#define TK_ALTER 151
-#define TK_ADD 152
-#define TK_COLUMN 153
-#define TK_AGG_FUNCTION 154
-#define TK_AGG_COLUMN 155
-#define TK_TRUEFALSE 156
-#define TK_ISNOT 157
-#define TK_FUNCTION 158
-#define TK_UMINUS 159
-#define TK_UPLUS 160
-#define TK_TRUTH 161
-#define TK_REGISTER 162
-#define TK_VECTOR 163
-#define TK_SELECT_COLUMN 164
-#define TK_IF_NULL_ROW 165
-#define TK_ASTERISK 166
-#define TK_SPAN 167
-#define TK_ERROR 168
-#define TK_SPACE 169
-#define TK_ILLEGAL 170
+#define TK_PTR 102
+#define TK_COLLATE 103
+#define TK_BITNOT 104
+#define TK_ON 105
+#define TK_INDEXED 106
+#define TK_STRING 107
+#define TK_JOIN_KW 108
+#define TK_CONSTRAINT 109
+#define TK_DEFAULT 110
+#define TK_NULL 111
+#define TK_PRIMARY 112
+#define TK_UNIQUE 113
+#define TK_CHECK 114
+#define TK_REFERENCES 115
+#define TK_AUTOINCR 116
+#define TK_INSERT 117
+#define TK_DELETE 118
+#define TK_UPDATE 119
+#define TK_SET 120
+#define TK_DEFERRABLE 121
+#define TK_FOREIGN 122
+#define TK_DROP 123
+#define TK_UNION 124
+#define TK_ALL 125
+#define TK_EXCEPT 126
+#define TK_INTERSECT 127
+#define TK_SELECT 128
+#define TK_VALUES 129
+#define TK_DISTINCT 130
+#define TK_DOT 131
+#define TK_FROM 132
+#define TK_JOIN 133
+#define TK_USING 134
+#define TK_ORDER 135
+#define TK_GROUP 136
+#define TK_HAVING 137
+#define TK_LIMIT 138
+#define TK_WHERE 139
+#define TK_RETURNING 140
+#define TK_INTO 141
+#define TK_NOTHING 142
+#define TK_FLOAT 143
+#define TK_BLOB 144
+#define TK_INTEGER 145
+#define TK_VARIABLE 146
+#define TK_CASE 147
+#define TK_WHEN 148
+#define TK_THEN 149
+#define TK_ELSE 150
+#define TK_INDEX 151
+#define TK_ALTER 152
+#define TK_ADD 153
+#define TK_COLUMN 154
+#define TK_AGG_FUNCTION 155
+#define TK_AGG_COLUMN 156
+#define TK_TRUEFALSE 157
+#define TK_ISNOT 158
+#define TK_FUNCTION 159
+#define TK_UMINUS 160
+#define TK_UPLUS 161
+#define TK_TRUTH 162
+#define TK_REGISTER 163
+#define TK_VECTOR 164
+#define TK_SELECT_COLUMN 165
+#define TK_IF_NULL_ROW 166
+#define TK_ASTERISK 167
+#define TK_SPAN 168
+#define TK_ERROR 169
+#define TK_SPACE 170
+#define TK_ILLEGAL 171
#endif
/**************** End token definitions ***************************************/
@@ -159879,28 +161736,28 @@ static void updateDeleteLimitError(
#endif
/************* Begin control #defines *****************************************/
#define YYCODETYPE unsigned short int
-#define YYNOCODE 289
+#define YYNOCODE 290
#define YYACTIONTYPE unsigned short int
#define YYWILDCARD 91
#define sqlite3ParserTOKENTYPE Token
typedef union {
int yyinit;
sqlite3ParserTOKENTYPE yy0;
- With* yy23;
- const char* yy70;
- struct TrigEvent yy96;
- SrcList* yy155;
- u32 yy213;
- Upsert* yy232;
- Cte* yy259;
- struct {int value; int mask;} yy277;
- int yy332;
- ExprList* yy368;
- IdList* yy374;
- TriggerStep* yy387;
- Select* yy433;
- Expr* yy454;
- u8 yy478;
+ Upsert* yy38;
+ IdList* yy80;
+ const char* yy116;
+ Expr* yy122;
+ TriggerStep* yy207;
+ u32 yy227;
+ With* yy231;
+ SrcList* yy247;
+ Select* yy279;
+ ExprList* yy322;
+ struct {int value; int mask;} yy347;
+ int yy452;
+ u8 yy458;
+ struct TrigEvent yy470;
+ Cte* yy559;
} YYMINORTYPE;
#ifndef YYSTACKDEPTH
#define YYSTACKDEPTH 100
@@ -159916,18 +161773,18 @@ typedef union {
#define sqlite3ParserCTX_FETCH Parse *pParse=yypParser->pParse;
#define sqlite3ParserCTX_STORE yypParser->pParse=pParse;
#define YYFALLBACK 1
-#define YYNSTATE 517
-#define YYNRULE 360
-#define YYNRULE_WITH_ACTION 299
-#define YYNTOKEN 171
-#define YY_MAX_SHIFT 516
-#define YY_MIN_SHIFTREDUCE 742
-#define YY_MAX_SHIFTREDUCE 1101
-#define YY_ERROR_ACTION 1102
-#define YY_ACCEPT_ACTION 1103
-#define YY_NO_ACTION 1104
-#define YY_MIN_REDUCE 1105
-#define YY_MAX_REDUCE 1464
+#define YYNSTATE 519
+#define YYNRULE 361
+#define YYNRULE_WITH_ACTION 300
+#define YYNTOKEN 172
+#define YY_MAX_SHIFT 518
+#define YY_MIN_SHIFTREDUCE 744
+#define YY_MAX_SHIFTREDUCE 1104
+#define YY_ERROR_ACTION 1105
+#define YY_ACCEPT_ACTION 1106
+#define YY_NO_ACTION 1107
+#define YY_MIN_REDUCE 1108
+#define YY_MAX_REDUCE 1468
/************* End control #defines *******************************************/
#define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])))
@@ -159994,529 +161851,535 @@ typedef union {
** yy_default[] Default action for each state.
**
*********** Begin parsing tables **********************************************/
-#define YY_ACTTAB_COUNT (1736)
+#define YY_ACTTAB_COUNT (1763)
static const YYACTIONTYPE yy_action[] = {
- /* 0 */ 102, 99, 196, 102, 99, 196, 480, 1127, 510, 418,
- /* 10 */ 1174, 510, 1153, 504, 504, 504, 372, 513, 370, 513,
- /* 20 */ 1174, 1380, 1460, 358, 341, 242, 242, 342, 875, 12,
- /* 30 */ 12, 58, 58, 372, 43, 43, 876, 507, 481, 86,
- /* 40 */ 362, 109, 110, 100, 1079, 1079, 949, 952, 942, 942,
- /* 50 */ 107, 107, 108, 108, 108, 108, 1179, 1179, 109, 110,
- /* 60 */ 100, 1079, 1079, 949, 952, 942, 942, 107, 107, 108,
- /* 70 */ 108, 108, 108, 248, 248, 248, 248, 102, 99, 196,
- /* 80 */ 102, 99, 196, 357, 1099, 507, 111, 507, 414, 224,
- /* 90 */ 193, 345, 106, 106, 106, 106, 105, 105, 104, 104,
- /* 100 */ 104, 103, 407, 372, 433, 1278, 414, 413, 407, 106,
- /* 110 */ 106, 106, 106, 105, 105, 104, 104, 104, 103, 407,
- /* 120 */ 108, 108, 108, 108, 101, 405, 405, 405, 109, 110,
- /* 130 */ 100, 1079, 1079, 949, 952, 942, 942, 107, 107, 108,
- /* 140 */ 108, 108, 108, 106, 106, 106, 106, 105, 105, 104,
- /* 150 */ 104, 104, 103, 407, 68, 1100, 235, 167, 426, 301,
- /* 160 */ 106, 106, 106, 106, 105, 105, 104, 104, 104, 103,
- /* 170 */ 407, 372, 245, 1349, 860, 387, 69, 414, 1136, 106,
- /* 180 */ 106, 106, 106, 105, 105, 104, 104, 104, 103, 407,
- /* 190 */ 1055, 1349, 1351, 372, 313, 1055, 109, 110, 100, 1079,
- /* 200 */ 1079, 949, 952, 942, 942, 107, 107, 108, 108, 108,
- /* 210 */ 108, 105, 105, 104, 104, 104, 103, 407, 109, 110,
- /* 220 */ 100, 1079, 1079, 949, 952, 942, 942, 107, 107, 108,
- /* 230 */ 108, 108, 108, 104, 104, 104, 103, 407, 1055, 1056,
- /* 240 */ 1057, 103, 407, 1055, 1056, 1057, 1139, 106, 106, 106,
- /* 250 */ 106, 105, 105, 104, 104, 104, 103, 407, 308, 195,
- /* 260 */ 311, 1138, 1349, 8, 372, 1055, 1177, 1177, 315, 106,
- /* 270 */ 106, 106, 106, 105, 105, 104, 104, 104, 103, 407,
- /* 280 */ 108, 108, 108, 108, 860, 939, 939, 950, 953, 109,
- /* 290 */ 110, 100, 1079, 1079, 949, 952, 942, 942, 107, 107,
- /* 300 */ 108, 108, 108, 108, 217, 284, 841, 465, 462, 461,
- /* 310 */ 124, 1431, 435, 1055, 1056, 1057, 182, 460, 431, 243,
- /* 320 */ 106, 106, 106, 106, 105, 105, 104, 104, 104, 103,
- /* 330 */ 407, 510, 441, 372, 176, 1055, 437, 466, 415, 425,
- /* 340 */ 106, 106, 106, 106, 105, 105, 104, 104, 104, 103,
- /* 350 */ 407, 943, 329, 184, 59, 59, 277, 501, 109, 110,
- /* 360 */ 100, 1079, 1079, 949, 952, 942, 942, 107, 107, 108,
- /* 370 */ 108, 108, 108, 509, 404, 403, 416, 510, 102, 99,
- /* 380 */ 196, 510, 1083, 1055, 1056, 1057, 256, 1085, 493, 452,
- /* 390 */ 492, 391, 475, 1344, 911, 1084, 404, 403, 1425, 482,
- /* 400 */ 59, 59, 124, 168, 39, 39, 1146, 1209, 510, 106,
- /* 410 */ 106, 106, 106, 105, 105, 104, 104, 104, 103, 407,
- /* 420 */ 1086, 1127, 1086, 248, 248, 8, 372, 248, 248, 260,
- /* 430 */ 781, 9, 9, 1125, 1379, 507, 492, 299, 1055, 507,
- /* 440 */ 476, 1055, 1086, 372, 1086, 494, 385, 774, 277, 501,
- /* 450 */ 124, 109, 110, 100, 1079, 1079, 949, 952, 942, 942,
- /* 460 */ 107, 107, 108, 108, 108, 108, 376, 992, 109, 110,
- /* 470 */ 100, 1079, 1079, 949, 952, 942, 942, 107, 107, 108,
- /* 480 */ 108, 108, 108, 357, 1031, 1055, 1055, 1056, 1057, 1055,
- /* 490 */ 1056, 1057, 510, 331, 1055, 994, 277, 501, 331, 994,
- /* 500 */ 127, 442, 106, 106, 106, 106, 105, 105, 104, 104,
- /* 510 */ 104, 103, 407, 200, 510, 9, 9, 340, 177, 106,
- /* 520 */ 106, 106, 106, 105, 105, 104, 104, 104, 103, 407,
- /* 530 */ 390, 360, 447, 1055, 1056, 1057, 372, 9, 9, 1278,
- /* 540 */ 930, 135, 1055, 1056, 1057, 217, 137, 446, 465, 462,
- /* 550 */ 461, 443, 392, 372, 911, 1100, 331, 916, 460, 1094,
- /* 560 */ 452, 109, 110, 100, 1079, 1079, 949, 952, 942, 942,
- /* 570 */ 107, 107, 108, 108, 108, 108, 426, 301, 109, 110,
- /* 580 */ 100, 1079, 1079, 949, 952, 942, 942, 107, 107, 108,
- /* 590 */ 108, 108, 108, 1055, 85, 1013, 435, 299, 421, 287,
- /* 600 */ 452, 510, 1402, 1055, 134, 380, 1157, 1402, 130, 388,
- /* 610 */ 1014, 329, 106, 106, 106, 106, 105, 105, 104, 104,
- /* 620 */ 104, 103, 407, 441, 59, 59, 1015, 177, 4, 106,
- /* 630 */ 106, 106, 106, 105, 105, 104, 104, 104, 103, 407,
- /* 640 */ 371, 1055, 1056, 1057, 510, 1343, 372, 817, 382, 174,
- /* 650 */ 399, 1055, 1056, 1057, 997, 997, 449, 190, 1059, 818,
- /* 660 */ 492, 410, 269, 372, 269, 1402, 1055, 59, 59, 491,
- /* 670 */ 261, 109, 110, 100, 1079, 1079, 949, 952, 942, 942,
- /* 680 */ 107, 107, 108, 108, 108, 108, 71, 788, 109, 110,
- /* 690 */ 100, 1079, 1079, 949, 952, 942, 942, 107, 107, 108,
- /* 700 */ 108, 108, 108, 492, 1013, 396, 508, 1059, 831, 831,
- /* 710 */ 319, 1430, 474, 806, 1055, 1056, 1057, 286, 1055, 1014,
- /* 720 */ 298, 382, 106, 106, 106, 106, 105, 105, 104, 104,
- /* 730 */ 104, 103, 407, 1055, 479, 1015, 777, 435, 486, 106,
- /* 740 */ 106, 106, 106, 105, 105, 104, 104, 104, 103, 407,
- /* 750 */ 1404, 1044, 252, 510, 277, 501, 498, 355, 355, 354,
- /* 760 */ 237, 352, 177, 427, 754, 331, 1055, 1056, 1057, 929,
- /* 770 */ 351, 254, 929, 83, 468, 365, 44, 44, 88, 282,
- /* 780 */ 265, 1055, 1056, 1057, 777, 922, 296, 281, 922, 921,
- /* 790 */ 257, 393, 921, 862, 2, 91, 435, 234, 251, 327,
- /* 800 */ 471, 322, 470, 222, 473, 1036, 248, 248, 861, 318,
- /* 810 */ 510, 264, 372, 136, 1278, 248, 248, 178, 507, 194,
- /* 820 */ 201, 921, 921, 923, 921, 921, 923, 507, 146, 372,
- /* 830 */ 836, 122, 1055, 59, 59, 835, 344, 109, 110, 100,
- /* 840 */ 1079, 1079, 949, 952, 942, 942, 107, 107, 108, 108,
- /* 850 */ 108, 108, 1128, 378, 109, 110, 100, 1079, 1079, 949,
- /* 860 */ 952, 942, 942, 107, 107, 108, 108, 108, 108, 487,
- /* 870 */ 266, 452, 373, 1156, 1402, 1278, 510, 277, 501, 510,
- /* 880 */ 1055, 1056, 1057, 1185, 389, 113, 1386, 331, 106, 106,
- /* 890 */ 106, 106, 105, 105, 104, 104, 104, 103, 407, 59,
- /* 900 */ 59, 412, 9, 9, 510, 106, 106, 106, 106, 105,
- /* 910 */ 105, 104, 104, 104, 103, 407, 1186, 268, 248, 248,
- /* 920 */ 510, 291, 372, 1032, 1458, 382, 1458, 9, 9, 836,
- /* 930 */ 507, 745, 746, 747, 835, 402, 441, 1032, 1459, 372,
- /* 940 */ 1459, 452, 489, 59, 59, 448, 227, 109, 98, 100,
- /* 950 */ 1079, 1079, 949, 952, 942, 942, 107, 107, 108, 108,
- /* 960 */ 108, 108, 369, 368, 253, 110, 100, 1079, 1079, 949,
- /* 970 */ 952, 942, 942, 107, 107, 108, 108, 108, 108, 406,
- /* 980 */ 249, 249, 1076, 1155, 457, 288, 1182, 290, 757, 452,
- /* 990 */ 1388, 1123, 507, 477, 259, 1030, 1403, 280, 106, 106,
- /* 1000 */ 106, 106, 105, 105, 104, 104, 104, 103, 407, 1030,
- /* 1010 */ 495, 797, 221, 202, 1278, 106, 106, 106, 106, 105,
- /* 1020 */ 105, 104, 104, 104, 103, 407, 248, 248, 248, 248,
- /* 1030 */ 190, 1076, 372, 267, 306, 411, 132, 5, 507, 227,
- /* 1040 */ 507, 503, 378, 469, 497, 248, 248, 220, 219, 218,
- /* 1050 */ 424, 379, 154, 798, 1075, 277, 501, 507, 289, 100,
- /* 1060 */ 1079, 1079, 949, 952, 942, 942, 107, 107, 108, 108,
- /* 1070 */ 108, 108, 377, 510, 769, 1076, 510, 1384, 95, 502,
- /* 1080 */ 510, 3, 972, 510, 400, 419, 247, 193, 318, 860,
- /* 1090 */ 1191, 283, 72, 181, 370, 505, 11, 11, 394, 32,
- /* 1100 */ 32, 507, 510, 45, 45, 13, 33, 33, 106, 106,
- /* 1110 */ 106, 106, 105, 105, 104, 104, 104, 103, 407, 408,
- /* 1120 */ 1336, 221, 204, 769, 1076, 46, 46, 1222, 483, 95,
- /* 1130 */ 502, 510, 3, 499, 1221, 1405, 516, 1105, 510, 185,
- /* 1140 */ 428, 439, 278, 124, 128, 383, 505, 95, 502, 370,
- /* 1150 */ 3, 1187, 929, 510, 47, 47, 510, 453, 93, 93,
- /* 1160 */ 22, 48, 48, 185, 505, 94, 432, 408, 512, 511,
- /* 1170 */ 408, 420, 921, 276, 195, 370, 49, 49, 1391, 50,
- /* 1180 */ 50, 377, 370, 784, 499, 875, 248, 248, 408, 277,
- /* 1190 */ 501, 510, 23, 876, 92, 133, 90, 28, 507, 860,
- /* 1200 */ 292, 510, 499, 929, 921, 921, 923, 924, 19, 93,
- /* 1210 */ 93, 840, 205, 1368, 34, 34, 94, 484, 408, 512,
- /* 1220 */ 511, 929, 1367, 921, 35, 35, 429, 93, 93, 510,
- /* 1230 */ 440, 1027, 784, 359, 94, 444, 408, 512, 511, 510,
- /* 1240 */ 979, 921, 510, 409, 87, 502, 510, 3, 510, 262,
- /* 1250 */ 878, 879, 36, 36, 326, 921, 921, 923, 924, 19,
- /* 1260 */ 510, 505, 38, 38, 325, 51, 51, 510, 250, 52,
- /* 1270 */ 52, 53, 53, 921, 921, 923, 924, 19, 303, 297,
- /* 1280 */ 913, 85, 226, 10, 10, 408, 179, 1044, 252, 979,
- /* 1290 */ 54, 54, 925, 355, 355, 354, 237, 352, 510, 499,
- /* 1300 */ 754, 1103, 1, 1, 516, 1105, 796, 795, 274, 434,
- /* 1310 */ 278, 226, 128, 1218, 307, 282, 510, 310, 929, 1187,
- /* 1320 */ 312, 115, 115, 281, 93, 93, 510, 314, 1170, 510,
- /* 1330 */ 436, 94, 226, 408, 512, 511, 240, 510, 921, 55,
- /* 1340 */ 55, 925, 302, 458, 85, 223, 316, 1154, 85, 40,
- /* 1350 */ 40, 321, 56, 56, 248, 248, 201, 330, 510, 1230,
- /* 1360 */ 57, 57, 1277, 510, 146, 510, 507, 122, 510, 1205,
- /* 1370 */ 921, 921, 923, 924, 19, 803, 804, 510, 1216, 1418,
- /* 1380 */ 205, 41, 41, 510, 496, 1283, 141, 141, 142, 142,
- /* 1390 */ 1135, 64, 64, 510, 975, 510, 223, 510, 1126, 510,
- /* 1400 */ 42, 42, 510, 869, 510, 226, 60, 60, 373, 1114,
- /* 1410 */ 833, 409, 97, 277, 501, 510, 116, 116, 61, 61,
- /* 1420 */ 117, 117, 118, 118, 510, 114, 114, 140, 140, 1113,
- /* 1430 */ 991, 510, 991, 990, 510, 990, 510, 412, 139, 139,
- /* 1440 */ 510, 767, 510, 131, 510, 1115, 510, 123, 123, 510,
- /* 1450 */ 1411, 834, 1202, 97, 121, 121, 187, 119, 119, 120,
- /* 1460 */ 120, 333, 335, 63, 63, 65, 65, 62, 62, 31,
- /* 1470 */ 31, 337, 37, 37, 356, 7, 199, 417, 1259, 258,
- /* 1480 */ 1264, 1252, 255, 463, 294, 295, 263, 191, 1269, 1153,
- /* 1490 */ 438, 300, 500, 1268, 363, 350, 324, 1340, 1339, 1414,
- /* 1500 */ 1094, 1091, 186, 229, 381, 71, 339, 183, 165, 1345,
- /* 1510 */ 151, 422, 160, 423, 158, 456, 207, 83, 161, 67,
- /* 1520 */ 156, 197, 70, 162, 25, 1265, 163, 1273, 361, 445,
- /* 1530 */ 430, 1271, 1270, 364, 26, 169, 1334, 211, 77, 451,
- /* 1540 */ 241, 213, 173, 454, 309, 214, 366, 1116, 215, 472,
- /* 1550 */ 1356, 1173, 1172, 305, 1171, 395, 79, 1164, 788, 1429,
- /* 1560 */ 367, 1428, 397, 1143, 398, 272, 485, 82, 1142, 323,
- /* 1570 */ 1163, 478, 1141, 1427, 273, 1213, 1214, 332, 328, 334,
- /* 1580 */ 228, 1212, 336, 401, 1211, 338, 6, 1320, 343, 112,
- /* 1590 */ 490, 1237, 1236, 89, 84, 488, 275, 24, 514, 1049,
- /* 1600 */ 239, 236, 1195, 238, 515, 1111, 1106, 374, 348, 346,
- /* 1610 */ 347, 349, 143, 1372, 1373, 375, 1371, 1370, 144, 129,
- /* 1620 */ 270, 180, 188, 279, 189, 198, 145, 126, 66, 155,
- /* 1630 */ 989, 987, 285, 147, 157, 820, 159, 1075, 203, 206,
- /* 1640 */ 293, 1003, 164, 148, 149, 384, 386, 166, 150, 73,
- /* 1650 */ 74, 75, 76, 1006, 208, 1002, 209, 138, 14, 210,
- /* 1660 */ 304, 995, 170, 226, 450, 1088, 212, 171, 27, 756,
- /* 1670 */ 325, 216, 455, 459, 464, 799, 172, 78, 15, 786,
- /* 1680 */ 317, 16, 320, 80, 29, 152, 271, 928, 927, 467,
- /* 1690 */ 955, 81, 1038, 244, 192, 1037, 246, 868, 175, 97,
- /* 1700 */ 863, 231, 225, 85, 970, 17, 18, 956, 954, 958,
- /* 1710 */ 1012, 959, 1011, 230, 20, 30, 506, 926, 768, 96,
- /* 1720 */ 21, 232, 353, 1045, 153, 233, 1420, 125, 830, 1104,
- /* 1730 */ 1104, 1104, 1104, 1104, 1104, 1419,
+ /* 0 */ 103, 99, 198, 103, 99, 198, 482, 1130, 512, 1139,
+ /* 10 */ 1177, 512, 1156, 506, 506, 506, 374, 515, 1281, 515,
+ /* 20 */ 1177, 1384, 1464, 360, 343, 244, 244, 344, 877, 12,
+ /* 30 */ 12, 58, 58, 374, 43, 43, 878, 509, 483, 86,
+ /* 40 */ 364, 110, 111, 101, 1082, 1082, 952, 955, 944, 944,
+ /* 50 */ 108, 108, 109, 109, 109, 109, 481, 333, 110, 111,
+ /* 60 */ 101, 1082, 1082, 952, 955, 944, 944, 108, 108, 109,
+ /* 70 */ 109, 109, 109, 250, 250, 250, 250, 103, 99, 198,
+ /* 80 */ 103, 99, 198, 512, 1142, 509, 112, 509, 389, 226,
+ /* 90 */ 195, 347, 107, 107, 107, 107, 106, 106, 105, 105,
+ /* 100 */ 105, 104, 100, 409, 435, 136, 9, 9, 1281, 107,
+ /* 110 */ 107, 107, 107, 106, 106, 105, 105, 105, 104, 100,
+ /* 120 */ 409, 387, 8, 1058, 428, 303, 374, 1039, 125, 286,
+ /* 130 */ 106, 106, 105, 105, 105, 104, 100, 409, 128, 109,
+ /* 140 */ 109, 109, 109, 102, 105, 105, 105, 104, 100, 409,
+ /* 150 */ 1062, 110, 111, 101, 1082, 1082, 952, 955, 944, 944,
+ /* 160 */ 108, 108, 109, 109, 109, 109, 1406, 125, 941, 941,
+ /* 170 */ 953, 956, 1058, 1059, 1060, 279, 503, 68, 390, 107,
+ /* 180 */ 107, 107, 107, 106, 106, 105, 105, 105, 104, 100,
+ /* 190 */ 409, 406, 405, 178, 374, 247, 417, 862, 427, 69,
+ /* 200 */ 1062, 169, 107, 107, 107, 107, 106, 106, 105, 105,
+ /* 210 */ 105, 104, 100, 409, 279, 503, 374, 1348, 293, 110,
+ /* 220 */ 111, 101, 1082, 1082, 952, 955, 944, 944, 108, 108,
+ /* 230 */ 109, 109, 109, 109, 409, 945, 1182, 1182, 1089, 1058,
+ /* 240 */ 1089, 110, 111, 101, 1082, 1082, 952, 955, 944, 944,
+ /* 250 */ 108, 108, 109, 109, 109, 109, 107, 107, 107, 107,
+ /* 260 */ 106, 106, 105, 105, 105, 104, 100, 409, 192, 437,
+ /* 270 */ 107, 107, 107, 107, 106, 106, 105, 105, 105, 104,
+ /* 280 */ 100, 409, 290, 197, 292, 1141, 1058, 374, 1058, 1059,
+ /* 290 */ 1060, 317, 107, 107, 107, 107, 106, 106, 105, 105,
+ /* 300 */ 105, 104, 100, 409, 109, 109, 109, 109, 862, 407,
+ /* 310 */ 407, 407, 110, 111, 101, 1082, 1082, 952, 955, 944,
+ /* 320 */ 944, 108, 108, 109, 109, 109, 109, 843, 384, 219,
+ /* 330 */ 1058, 913, 467, 464, 463, 1058, 1059, 1060, 1180, 1180,
+ /* 340 */ 184, 437, 462, 258, 107, 107, 107, 107, 106, 106,
+ /* 350 */ 105, 105, 105, 104, 100, 409, 291, 374, 245, 1058,
+ /* 360 */ 1281, 468, 384, 107, 107, 107, 107, 106, 106, 105,
+ /* 370 */ 105, 105, 104, 100, 409, 301, 423, 289, 187, 1058,
+ /* 380 */ 1059, 1060, 110, 111, 101, 1082, 1082, 952, 955, 944,
+ /* 390 */ 944, 108, 108, 109, 109, 109, 109, 288, 406, 405,
+ /* 400 */ 512, 454, 512, 1429, 176, 512, 1058, 1086, 1058, 1059,
+ /* 410 */ 1060, 1149, 1088, 495, 71, 263, 477, 103, 99, 198,
+ /* 420 */ 1087, 131, 229, 59, 59, 59, 59, 454, 39, 39,
+ /* 430 */ 391, 259, 237, 107, 107, 107, 107, 106, 106, 105,
+ /* 440 */ 105, 105, 104, 100, 409, 1089, 1383, 1089, 250, 250,
+ /* 450 */ 374, 250, 250, 1281, 783, 1058, 1059, 1060, 1079, 494,
+ /* 460 */ 509, 494, 439, 509, 478, 913, 1058, 374, 484, 443,
+ /* 470 */ 496, 776, 1347, 125, 170, 110, 111, 101, 1082, 1082,
+ /* 480 */ 952, 955, 944, 944, 108, 108, 109, 109, 109, 109,
+ /* 490 */ 511, 437, 110, 111, 101, 1082, 1082, 952, 955, 944,
+ /* 500 */ 944, 108, 108, 109, 109, 109, 109, 1016, 1079, 301,
+ /* 510 */ 279, 503, 1058, 251, 251, 1058, 1059, 1060, 1058, 331,
+ /* 520 */ 279, 503, 1017, 450, 333, 509, 107, 107, 107, 107,
+ /* 530 */ 106, 106, 105, 105, 105, 104, 100, 409, 1018, 510,
+ /* 540 */ 4, 833, 833, 107, 107, 107, 107, 106, 106, 105,
+ /* 550 */ 105, 105, 104, 100, 409, 759, 512, 114, 393, 819,
+ /* 560 */ 374, 1058, 1059, 1060, 932, 266, 262, 1058, 1059, 1060,
+ /* 570 */ 219, 820, 139, 467, 464, 463, 454, 374, 1058, 44,
+ /* 580 */ 44, 918, 1281, 462, 2, 110, 111, 101, 1082, 1082,
+ /* 590 */ 952, 955, 944, 944, 108, 108, 109, 109, 109, 109,
+ /* 600 */ 512, 416, 110, 111, 101, 1082, 1082, 952, 955, 944,
+ /* 610 */ 944, 108, 108, 109, 109, 109, 109, 426, 8, 416,
+ /* 620 */ 415, 1189, 1058, 11, 11, 512, 333, 1058, 1059, 1060,
+ /* 630 */ 256, 1058, 202, 1406, 371, 370, 107, 107, 107, 107,
+ /* 640 */ 106, 106, 105, 105, 105, 104, 100, 409, 59, 59,
+ /* 650 */ 975, 512, 402, 107, 107, 107, 107, 106, 106, 105,
+ /* 660 */ 105, 105, 104, 100, 409, 250, 250, 1130, 512, 384,
+ /* 670 */ 374, 1058, 1059, 1060, 9, 9, 433, 509, 1097, 1128,
+ /* 680 */ 1058, 1059, 1060, 1058, 494, 454, 1435, 374, 1340, 392,
+ /* 690 */ 416, 59, 59, 493, 444, 110, 111, 101, 1082, 1082,
+ /* 700 */ 952, 955, 944, 944, 108, 108, 109, 109, 109, 109,
+ /* 710 */ 1353, 186, 110, 111, 101, 1082, 1082, 952, 955, 944,
+ /* 720 */ 944, 108, 108, 109, 109, 109, 109, 494, 1353, 1355,
+ /* 730 */ 382, 179, 1058, 1059, 1060, 1407, 476, 223, 261, 353,
+ /* 740 */ 267, 333, 342, 333, 367, 1058, 107, 107, 107, 107,
+ /* 750 */ 106, 106, 105, 105, 105, 104, 100, 409, 799, 864,
+ /* 760 */ 512, 475, 488, 107, 107, 107, 107, 106, 106, 105,
+ /* 770 */ 105, 105, 104, 100, 409, 250, 250, 1434, 512, 808,
+ /* 780 */ 374, 359, 1102, 32, 32, 180, 412, 509, 838, 135,
+ /* 790 */ 471, 137, 995, 837, 1058, 1059, 1060, 374, 379, 1353,
+ /* 800 */ 800, 59, 59, 88, 1188, 110, 111, 101, 1082, 1082,
+ /* 810 */ 952, 955, 944, 944, 108, 108, 109, 109, 109, 109,
+ /* 820 */ 91, 863, 110, 111, 101, 1082, 1082, 952, 955, 944,
+ /* 830 */ 944, 108, 108, 109, 109, 109, 109, 489, 1194, 250,
+ /* 840 */ 250, 179, 1035, 1462, 454, 1462, 396, 196, 512, 509,
+ /* 850 */ 1406, 509, 1406, 1103, 362, 22, 107, 107, 107, 107,
+ /* 860 */ 106, 106, 105, 105, 105, 104, 100, 409, 5, 1078,
+ /* 870 */ 229, 9, 9, 107, 107, 107, 107, 106, 106, 105,
+ /* 880 */ 105, 105, 104, 100, 409, 437, 394, 23, 512, 1185,
+ /* 890 */ 374, 1035, 1463, 346, 1463, 179, 104, 100, 409, 747,
+ /* 900 */ 748, 749, 428, 303, 443, 838, 1079, 374, 373, 443,
+ /* 910 */ 837, 59, 59, 1126, 1033, 110, 98, 101, 1082, 1082,
+ /* 920 */ 952, 955, 944, 944, 108, 108, 109, 109, 109, 109,
+ /* 930 */ 271, 512, 271, 111, 101, 1082, 1082, 952, 955, 944,
+ /* 940 */ 944, 108, 108, 109, 109, 109, 109, 404, 250, 250,
+ /* 950 */ 1000, 1000, 451, 1390, 45, 45, 1079, 85, 512, 268,
+ /* 960 */ 509, 133, 92, 1033, 90, 454, 107, 107, 107, 107,
+ /* 970 */ 106, 106, 105, 105, 105, 104, 100, 409, 479, 187,
+ /* 980 */ 512, 9, 9, 107, 107, 107, 107, 106, 106, 105,
+ /* 990 */ 105, 105, 104, 100, 409, 512, 491, 1392, 512, 771,
+ /* 1000 */ 374, 300, 398, 33, 33, 862, 269, 321, 997, 378,
+ /* 1010 */ 308, 413, 997, 250, 250, 1131, 380, 512, 46, 46,
+ /* 1020 */ 512, 59, 59, 331, 134, 509, 28, 101, 1082, 1082,
+ /* 1030 */ 952, 955, 944, 944, 108, 108, 109, 109, 109, 109,
+ /* 1040 */ 47, 47, 512, 48, 48, 449, 485, 95, 504, 771,
+ /* 1050 */ 3, 790, 1106, 1, 1, 518, 1108, 408, 222, 221,
+ /* 1060 */ 220, 280, 401, 129, 507, 49, 49, 441, 497, 429,
+ /* 1070 */ 1190, 470, 192, 505, 380, 1388, 107, 107, 107, 107,
+ /* 1080 */ 106, 106, 105, 105, 105, 104, 100, 409, 410, 395,
+ /* 1090 */ 448, 197, 298, 1016, 445, 236, 253, 329, 473, 324,
+ /* 1100 */ 472, 224, 501, 250, 250, 250, 250, 320, 1017, 1030,
+ /* 1110 */ 512, 361, 125, 420, 779, 509, 862, 509, 285, 359,
+ /* 1120 */ 1034, 931, 372, 459, 1018, 279, 503, 93, 93, 95,
+ /* 1130 */ 504, 207, 3, 50, 50, 94, 486, 410, 514, 513,
+ /* 1140 */ 381, 156, 923, 204, 931, 500, 507, 931, 512, 95,
+ /* 1150 */ 504, 223, 3, 249, 195, 13, 512, 442, 512, 279,
+ /* 1160 */ 503, 924, 411, 779, 924, 923, 507, 1225, 923, 512,
+ /* 1170 */ 410, 9, 9, 1224, 923, 923, 925, 926, 19, 34,
+ /* 1180 */ 34, 35, 35, 512, 501, 421, 270, 430, 315, 83,
+ /* 1190 */ 410, 1103, 36, 36, 372, 385, 372, 923, 923, 925,
+ /* 1200 */ 923, 923, 925, 931, 501, 434, 38, 38, 512, 93,
+ /* 1210 */ 93, 842, 379, 422, 372, 798, 797, 94, 877, 410,
+ /* 1220 */ 514, 513, 418, 931, 923, 278, 878, 512, 320, 93,
+ /* 1230 */ 93, 51, 51, 994, 372, 994, 255, 94, 1395, 410,
+ /* 1240 */ 514, 513, 294, 512, 923, 512, 87, 504, 512, 3,
+ /* 1250 */ 52, 52, 310, 206, 313, 1372, 923, 923, 925, 926,
+ /* 1260 */ 19, 512, 1371, 507, 72, 183, 53, 53, 10, 10,
+ /* 1270 */ 282, 54, 54, 512, 252, 512, 923, 923, 925, 926,
+ /* 1280 */ 19, 1408, 1047, 254, 116, 116, 1160, 410, 357, 357,
+ /* 1290 */ 356, 239, 354, 446, 786, 756, 55, 55, 40, 40,
+ /* 1300 */ 305, 501, 431, 805, 806, 1409, 518, 1108, 1221, 299,
+ /* 1310 */ 284, 85, 280, 915, 129, 228, 309, 982, 283, 512,
+ /* 1320 */ 931, 1190, 1047, 254, 512, 264, 93, 93, 357, 357,
+ /* 1330 */ 356, 239, 354, 312, 94, 756, 410, 514, 513, 314,
+ /* 1340 */ 512, 923, 56, 56, 786, 316, 512, 57, 57, 1173,
+ /* 1350 */ 284, 203, 436, 1159, 228, 512, 250, 250, 283, 148,
+ /* 1360 */ 512, 328, 124, 41, 41, 1158, 512, 982, 509, 143,
+ /* 1370 */ 143, 327, 512, 923, 923, 925, 926, 19, 144, 144,
+ /* 1380 */ 880, 881, 207, 64, 64, 438, 1422, 228, 512, 42,
+ /* 1390 */ 42, 203, 512, 1157, 323, 60, 60, 512, 332, 148,
+ /* 1400 */ 512, 1212, 124, 512, 375, 1233, 304, 512, 85, 279,
+ /* 1410 */ 503, 117, 117, 411, 1280, 61, 61, 512, 927, 512,
+ /* 1420 */ 141, 141, 1208, 118, 118, 276, 119, 119, 512, 499,
+ /* 1430 */ 115, 115, 460, 414, 225, 1219, 512, 318, 512, 85,
+ /* 1440 */ 142, 142, 138, 138, 375, 978, 512, 225, 512, 279,
+ /* 1450 */ 503, 123, 123, 512, 871, 512, 228, 512, 498, 122,
+ /* 1460 */ 122, 120, 120, 512, 835, 993, 97, 993, 927, 121,
+ /* 1470 */ 121, 63, 63, 414, 1286, 1138, 65, 65, 62, 62,
+ /* 1480 */ 31, 31, 769, 836, 132, 97, 37, 37, 1129, 1117,
+ /* 1490 */ 1116, 1118, 1415, 181, 455, 7, 242, 358, 1205, 1262,
+ /* 1500 */ 189, 335, 337, 339, 201, 1255, 257, 1267, 419, 296,
+ /* 1510 */ 1272, 302, 260, 440, 297, 265, 193, 1156, 352, 188,
+ /* 1520 */ 465, 326, 1344, 1343, 1418, 1097, 1271, 365, 1094, 341,
+ /* 1530 */ 231, 383, 71, 158, 185, 167, 502, 153, 424, 160,
+ /* 1540 */ 425, 458, 209, 83, 447, 1268, 162, 25, 163, 164,
+ /* 1550 */ 165, 1274, 213, 26, 199, 67, 363, 1276, 1349, 1273,
+ /* 1560 */ 432, 366, 1338, 171, 70, 453, 77, 243, 215, 175,
+ /* 1570 */ 456, 311, 216, 368, 1119, 217, 474, 1360, 307, 1176,
+ /* 1580 */ 1175, 1174, 397, 1167, 79, 790, 1146, 369, 1433, 1432,
+ /* 1590 */ 1145, 399, 400, 325, 487, 1216, 480, 1144, 334, 1431,
+ /* 1600 */ 274, 275, 82, 330, 336, 1166, 1217, 230, 1215, 338,
+ /* 1610 */ 403, 6, 1324, 345, 1214, 277, 340, 113, 89, 1240,
+ /* 1620 */ 492, 84, 1239, 490, 24, 516, 1052, 238, 240, 241,
+ /* 1630 */ 517, 1114, 349, 1198, 350, 348, 1109, 351, 145, 1376,
+ /* 1640 */ 1377, 1375, 376, 377, 146, 1374, 130, 272, 147, 190,
+ /* 1650 */ 191, 182, 281, 66, 200, 992, 127, 157, 990, 287,
+ /* 1660 */ 159, 149, 1078, 161, 822, 205, 208, 295, 1006, 166,
+ /* 1670 */ 386, 150, 151, 388, 168, 73, 74, 152, 75, 76,
+ /* 1680 */ 1009, 210, 1005, 14, 211, 140, 212, 306, 998, 172,
+ /* 1690 */ 228, 452, 1091, 214, 173, 27, 758, 327, 457, 218,
+ /* 1700 */ 461, 466, 788, 174, 78, 15, 154, 319, 16, 322,
+ /* 1710 */ 930, 80, 29, 273, 929, 469, 801, 958, 81, 1041,
+ /* 1720 */ 246, 194, 248, 1040, 870, 177, 227, 865, 233, 97,
+ /* 1730 */ 85, 973, 17, 959, 18, 957, 961, 1015, 962, 1014,
+ /* 1740 */ 232, 20, 30, 508, 928, 770, 96, 21, 832, 355,
+ /* 1750 */ 234, 155, 126, 235, 1048, 1107, 1107, 1107, 1107, 1107,
+ /* 1760 */ 1107, 1424, 1423,
};
static const YYCODETYPE yy_lookahead[] = {
- /* 0 */ 257, 258, 259, 257, 258, 259, 178, 178, 178, 229,
- /* 10 */ 208, 178, 210, 195, 196, 197, 16, 188, 238, 190,
- /* 20 */ 218, 278, 284, 285, 204, 224, 225, 204, 28, 201,
- /* 30 */ 202, 201, 202, 16, 201, 202, 36, 236, 189, 22,
- /* 40 */ 189, 41, 42, 43, 44, 45, 46, 47, 48, 49,
- /* 50 */ 50, 51, 52, 53, 54, 55, 220, 221, 41, 42,
+ /* 0 */ 258, 259, 260, 258, 259, 260, 179, 179, 179, 202,
+ /* 10 */ 209, 179, 211, 196, 197, 198, 16, 189, 179, 191,
+ /* 20 */ 219, 279, 285, 286, 205, 225, 226, 205, 28, 202,
+ /* 30 */ 203, 202, 203, 16, 202, 203, 36, 237, 190, 22,
+ /* 40 */ 190, 41, 42, 43, 44, 45, 46, 47, 48, 49,
+ /* 50 */ 50, 51, 52, 53, 54, 55, 16, 179, 41, 42,
/* 60 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
- /* 70 */ 53, 54, 55, 224, 225, 224, 225, 257, 258, 259,
- /* 80 */ 257, 258, 259, 19, 20, 236, 69, 236, 178, 240,
- /* 90 */ 241, 261, 92, 93, 94, 95, 96, 97, 98, 99,
- /* 100 */ 100, 101, 102, 16, 253, 178, 196, 197, 102, 92,
+ /* 70 */ 53, 54, 55, 225, 226, 225, 226, 258, 259, 260,
+ /* 80 */ 258, 259, 260, 179, 202, 237, 69, 237, 249, 241,
+ /* 90 */ 242, 262, 92, 93, 94, 95, 96, 97, 98, 99,
+ /* 100 */ 100, 101, 102, 103, 254, 227, 202, 203, 179, 92,
/* 110 */ 93, 94, 95, 96, 97, 98, 99, 100, 101, 102,
- /* 120 */ 52, 53, 54, 55, 56, 195, 196, 197, 41, 42,
- /* 130 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
- /* 140 */ 53, 54, 55, 92, 93, 94, 95, 96, 97, 98,
- /* 150 */ 99, 100, 101, 102, 67, 91, 23, 19, 117, 118,
- /* 160 */ 92, 93, 94, 95, 96, 97, 98, 99, 100, 101,
- /* 170 */ 102, 16, 20, 178, 22, 248, 21, 267, 201, 92,
+ /* 120 */ 103, 217, 199, 57, 118, 119, 16, 87, 81, 179,
+ /* 130 */ 96, 97, 98, 99, 100, 101, 102, 103, 72, 52,
+ /* 140 */ 53, 54, 55, 56, 98, 99, 100, 101, 102, 103,
+ /* 150 */ 57, 41, 42, 43, 44, 45, 46, 47, 48, 49,
+ /* 160 */ 50, 51, 52, 53, 54, 55, 288, 81, 44, 45,
+ /* 170 */ 46, 47, 106, 107, 108, 128, 129, 67, 249, 92,
/* 180 */ 93, 94, 95, 96, 97, 98, 99, 100, 101, 102,
- /* 190 */ 57, 196, 197, 16, 13, 57, 41, 42, 43, 44,
- /* 200 */ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
- /* 210 */ 55, 96, 97, 98, 99, 100, 101, 102, 41, 42,
- /* 220 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
- /* 230 */ 53, 54, 55, 98, 99, 100, 101, 102, 105, 106,
- /* 240 */ 107, 101, 102, 105, 106, 107, 201, 92, 93, 94,
- /* 250 */ 95, 96, 97, 98, 99, 100, 101, 102, 77, 107,
- /* 260 */ 79, 201, 267, 198, 16, 57, 220, 221, 20, 92,
- /* 270 */ 93, 94, 95, 96, 97, 98, 99, 100, 101, 102,
- /* 280 */ 52, 53, 54, 55, 132, 44, 45, 46, 47, 41,
- /* 290 */ 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
- /* 300 */ 52, 53, 54, 55, 108, 178, 98, 111, 112, 113,
- /* 310 */ 81, 215, 178, 105, 106, 107, 139, 121, 104, 198,
- /* 320 */ 92, 93, 94, 95, 96, 97, 98, 99, 100, 101,
- /* 330 */ 102, 178, 178, 16, 269, 57, 178, 20, 109, 274,
- /* 340 */ 92, 93, 94, 95, 96, 97, 98, 99, 100, 101,
- /* 350 */ 102, 110, 178, 139, 201, 202, 127, 128, 41, 42,
- /* 360 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
- /* 370 */ 53, 54, 55, 178, 96, 97, 253, 178, 257, 258,
- /* 380 */ 259, 178, 104, 105, 106, 107, 252, 109, 189, 178,
- /* 390 */ 237, 217, 189, 266, 73, 117, 96, 97, 200, 246,
- /* 400 */ 201, 202, 81, 19, 201, 202, 208, 242, 178, 92,
- /* 410 */ 93, 94, 95, 96, 97, 98, 99, 100, 101, 102,
- /* 420 */ 142, 178, 144, 224, 225, 198, 16, 224, 225, 275,
- /* 430 */ 20, 201, 202, 190, 223, 236, 237, 116, 57, 236,
- /* 440 */ 237, 57, 142, 16, 144, 246, 216, 20, 127, 128,
- /* 450 */ 81, 41, 42, 43, 44, 45, 46, 47, 48, 49,
- /* 460 */ 50, 51, 52, 53, 54, 55, 183, 8, 41, 42,
- /* 470 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
- /* 480 */ 53, 54, 55, 19, 20, 57, 105, 106, 107, 105,
- /* 490 */ 106, 107, 178, 178, 57, 26, 127, 128, 178, 30,
- /* 500 */ 72, 274, 92, 93, 94, 95, 96, 97, 98, 99,
- /* 510 */ 100, 101, 102, 12, 178, 201, 202, 178, 178, 92,
- /* 520 */ 93, 94, 95, 96, 97, 98, 99, 100, 101, 102,
- /* 530 */ 216, 191, 63, 105, 106, 107, 16, 201, 202, 178,
- /* 540 */ 20, 226, 105, 106, 107, 108, 226, 264, 111, 112,
- /* 550 */ 113, 268, 216, 16, 73, 91, 178, 20, 121, 58,
- /* 560 */ 178, 41, 42, 43, 44, 45, 46, 47, 48, 49,
- /* 570 */ 50, 51, 52, 53, 54, 55, 117, 118, 41, 42,
- /* 580 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
- /* 590 */ 53, 54, 55, 57, 22, 9, 178, 116, 117, 118,
- /* 600 */ 178, 178, 287, 57, 226, 223, 211, 287, 72, 248,
- /* 610 */ 24, 178, 92, 93, 94, 95, 96, 97, 98, 99,
- /* 620 */ 100, 101, 102, 178, 201, 202, 40, 178, 19, 92,
- /* 630 */ 93, 94, 95, 96, 97, 98, 99, 100, 101, 102,
- /* 640 */ 191, 105, 106, 107, 178, 223, 16, 61, 178, 22,
- /* 650 */ 217, 105, 106, 107, 116, 117, 118, 22, 57, 73,
- /* 660 */ 237, 279, 213, 16, 215, 287, 57, 201, 202, 246,
- /* 670 */ 252, 41, 42, 43, 44, 45, 46, 47, 48, 49,
- /* 680 */ 50, 51, 52, 53, 54, 55, 140, 115, 41, 42,
- /* 690 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
- /* 700 */ 53, 54, 55, 237, 9, 16, 123, 106, 125, 126,
- /* 710 */ 21, 20, 246, 22, 105, 106, 107, 247, 57, 24,
- /* 720 */ 275, 178, 92, 93, 94, 95, 96, 97, 98, 99,
- /* 730 */ 100, 101, 102, 57, 16, 40, 57, 178, 178, 92,
- /* 740 */ 93, 94, 95, 96, 97, 98, 99, 100, 101, 102,
- /* 750 */ 0, 1, 2, 178, 127, 128, 61, 7, 8, 9,
- /* 760 */ 10, 11, 178, 118, 14, 178, 105, 106, 107, 90,
- /* 770 */ 186, 189, 90, 138, 85, 191, 201, 202, 148, 29,
- /* 780 */ 189, 105, 106, 107, 105, 106, 141, 37, 106, 110,
- /* 790 */ 247, 102, 110, 132, 19, 148, 178, 108, 109, 110,
- /* 800 */ 111, 112, 113, 114, 98, 87, 224, 225, 132, 120,
- /* 810 */ 178, 252, 16, 226, 178, 224, 225, 21, 236, 178,
- /* 820 */ 70, 142, 143, 144, 142, 143, 144, 236, 78, 16,
- /* 830 */ 124, 81, 57, 201, 202, 129, 178, 41, 42, 43,
- /* 840 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
- /* 850 */ 54, 55, 193, 194, 41, 42, 43, 44, 45, 46,
- /* 860 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 237,
- /* 870 */ 252, 178, 122, 211, 287, 178, 178, 127, 128, 178,
- /* 880 */ 105, 106, 107, 189, 248, 19, 178, 178, 92, 93,
- /* 890 */ 94, 95, 96, 97, 98, 99, 100, 101, 102, 201,
- /* 900 */ 202, 151, 201, 202, 178, 92, 93, 94, 95, 96,
- /* 910 */ 97, 98, 99, 100, 101, 102, 223, 216, 224, 225,
- /* 920 */ 178, 13, 16, 19, 20, 178, 22, 201, 202, 124,
- /* 930 */ 236, 4, 5, 6, 129, 237, 178, 19, 20, 16,
- /* 940 */ 22, 178, 216, 201, 202, 248, 21, 41, 42, 43,
- /* 950 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
- /* 960 */ 54, 55, 96, 97, 89, 42, 43, 44, 45, 46,
- /* 970 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 237,
- /* 980 */ 224, 225, 57, 211, 16, 77, 223, 79, 18, 178,
- /* 990 */ 178, 189, 236, 189, 247, 91, 287, 122, 92, 93,
- /* 1000 */ 94, 95, 96, 97, 98, 99, 100, 101, 102, 91,
- /* 1010 */ 189, 32, 44, 21, 178, 92, 93, 94, 95, 96,
- /* 1020 */ 97, 98, 99, 100, 101, 102, 224, 225, 224, 225,
- /* 1030 */ 22, 106, 16, 275, 223, 178, 19, 19, 236, 21,
- /* 1040 */ 236, 193, 194, 64, 221, 224, 225, 116, 117, 118,
- /* 1050 */ 80, 282, 283, 74, 22, 127, 128, 236, 150, 43,
- /* 1060 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
- /* 1070 */ 54, 55, 104, 178, 57, 57, 178, 178, 16, 17,
- /* 1080 */ 178, 19, 112, 178, 248, 229, 240, 241, 120, 22,
- /* 1090 */ 225, 178, 138, 139, 238, 33, 201, 202, 119, 201,
- /* 1100 */ 202, 236, 178, 201, 202, 19, 201, 202, 92, 93,
- /* 1110 */ 94, 95, 96, 97, 98, 99, 100, 101, 102, 57,
- /* 1120 */ 150, 44, 130, 106, 106, 201, 202, 178, 16, 16,
- /* 1130 */ 17, 178, 19, 71, 178, 173, 174, 175, 178, 131,
- /* 1140 */ 229, 16, 180, 81, 182, 59, 33, 16, 17, 238,
- /* 1150 */ 19, 189, 90, 178, 201, 202, 178, 271, 96, 97,
- /* 1160 */ 19, 201, 202, 131, 33, 103, 229, 105, 106, 107,
- /* 1170 */ 57, 178, 110, 229, 107, 238, 201, 202, 178, 201,
- /* 1180 */ 202, 104, 238, 57, 71, 28, 224, 225, 57, 127,
- /* 1190 */ 128, 178, 51, 36, 147, 19, 149, 21, 236, 132,
- /* 1200 */ 178, 178, 71, 90, 142, 143, 144, 145, 146, 96,
- /* 1210 */ 97, 98, 250, 178, 201, 202, 103, 105, 105, 106,
- /* 1220 */ 107, 90, 178, 110, 201, 202, 118, 96, 97, 178,
- /* 1230 */ 105, 20, 106, 22, 103, 178, 105, 106, 107, 178,
- /* 1240 */ 57, 110, 178, 281, 16, 17, 178, 19, 178, 141,
- /* 1250 */ 83, 84, 201, 202, 110, 142, 143, 144, 145, 146,
- /* 1260 */ 178, 33, 201, 202, 120, 201, 202, 178, 19, 201,
- /* 1270 */ 202, 201, 202, 142, 143, 144, 145, 146, 178, 20,
- /* 1280 */ 20, 22, 22, 201, 202, 57, 227, 1, 2, 106,
- /* 1290 */ 201, 202, 57, 7, 8, 9, 10, 11, 178, 71,
- /* 1300 */ 14, 171, 172, 173, 174, 175, 109, 110, 239, 20,
- /* 1310 */ 180, 22, 182, 178, 178, 29, 178, 178, 90, 189,
- /* 1320 */ 178, 201, 202, 37, 96, 97, 178, 178, 178, 178,
- /* 1330 */ 20, 103, 22, 105, 106, 107, 270, 178, 110, 201,
- /* 1340 */ 202, 106, 20, 20, 22, 22, 20, 178, 22, 201,
- /* 1350 */ 202, 178, 201, 202, 224, 225, 70, 178, 178, 178,
- /* 1360 */ 201, 202, 178, 178, 78, 178, 236, 81, 178, 178,
- /* 1370 */ 142, 143, 144, 145, 146, 4, 5, 178, 178, 130,
- /* 1380 */ 250, 201, 202, 178, 178, 178, 201, 202, 201, 202,
- /* 1390 */ 178, 201, 202, 178, 20, 178, 22, 178, 178, 178,
- /* 1400 */ 201, 202, 178, 20, 178, 22, 201, 202, 122, 178,
- /* 1410 */ 20, 281, 22, 127, 128, 178, 201, 202, 201, 202,
- /* 1420 */ 201, 202, 201, 202, 178, 201, 202, 201, 202, 178,
- /* 1430 */ 142, 178, 144, 142, 178, 144, 178, 151, 201, 202,
- /* 1440 */ 178, 20, 178, 22, 178, 178, 178, 201, 202, 178,
- /* 1450 */ 178, 20, 239, 22, 201, 202, 199, 201, 202, 201,
- /* 1460 */ 202, 239, 239, 201, 202, 201, 202, 201, 202, 201,
- /* 1470 */ 202, 239, 201, 202, 176, 228, 280, 243, 251, 243,
- /* 1480 */ 255, 251, 230, 205, 276, 231, 231, 214, 255, 210,
- /* 1490 */ 276, 230, 263, 255, 255, 230, 204, 204, 204, 181,
- /* 1500 */ 58, 35, 228, 130, 185, 140, 243, 139, 19, 266,
- /* 1510 */ 41, 15, 222, 185, 219, 15, 184, 138, 222, 277,
- /* 1520 */ 280, 280, 277, 222, 254, 256, 222, 219, 231, 185,
- /* 1530 */ 231, 256, 256, 231, 254, 219, 231, 184, 147, 60,
- /* 1540 */ 185, 184, 19, 206, 185, 184, 206, 185, 184, 104,
- /* 1550 */ 273, 203, 203, 272, 203, 62, 19, 212, 115, 209,
- /* 1560 */ 206, 209, 21, 203, 102, 265, 133, 104, 205, 203,
- /* 1570 */ 212, 288, 203, 203, 265, 245, 245, 244, 206, 244,
- /* 1580 */ 185, 245, 244, 82, 245, 244, 19, 260, 185, 137,
- /* 1590 */ 134, 249, 249, 147, 136, 135, 262, 22, 187, 10,
- /* 1600 */ 3, 179, 235, 179, 177, 177, 177, 286, 232, 234,
- /* 1610 */ 233, 231, 192, 198, 198, 286, 198, 198, 192, 207,
- /* 1620 */ 207, 19, 199, 152, 199, 12, 192, 13, 198, 283,
- /* 1630 */ 20, 20, 128, 119, 140, 17, 131, 22, 21, 133,
- /* 1640 */ 13, 1, 131, 119, 119, 59, 34, 140, 119, 51,
- /* 1650 */ 51, 51, 51, 105, 31, 1, 130, 2, 19, 104,
- /* 1660 */ 150, 68, 68, 22, 38, 75, 130, 104, 21, 17,
- /* 1670 */ 120, 114, 16, 67, 67, 25, 19, 19, 19, 57,
- /* 1680 */ 20, 19, 21, 19, 19, 34, 67, 20, 20, 86,
- /* 1690 */ 20, 22, 20, 20, 130, 87, 20, 105, 19, 22,
- /* 1700 */ 132, 19, 31, 22, 20, 31, 31, 20, 20, 20,
- /* 1710 */ 20, 8, 20, 22, 19, 19, 22, 20, 20, 19,
- /* 1720 */ 19, 130, 12, 1, 22, 130, 130, 20, 124, 289,
- /* 1730 */ 289, 289, 289, 289, 289, 130, 289, 289, 289, 289,
- /* 1740 */ 289, 289, 289, 289, 289, 289, 289, 289, 289, 289,
- /* 1750 */ 289, 289, 289, 289, 289, 289, 289, 289, 289, 289,
- /* 1760 */ 289, 289, 289, 289, 289, 289, 289, 289, 289, 289,
- /* 1770 */ 289, 289, 289, 289, 289, 289, 289, 289, 289, 289,
- /* 1780 */ 289, 289, 289, 289, 289, 289, 289, 289, 289, 289,
- /* 1790 */ 289, 289, 289, 289, 289, 289, 289, 289, 289, 289,
- /* 1800 */ 289, 289, 289, 289, 289, 289, 289, 289, 289, 289,
- /* 1810 */ 289, 289, 289, 289, 289, 289, 289, 289, 289, 289,
- /* 1820 */ 289, 289, 289, 289, 289, 289, 289, 289, 289, 289,
- /* 1830 */ 289, 289, 289, 289, 289, 289, 289, 289, 289, 289,
- /* 1840 */ 289, 289, 289, 289, 289, 289, 289, 289, 289, 289,
- /* 1850 */ 289, 289, 289, 289, 289, 289, 289, 289, 289, 289,
- /* 1860 */ 289, 289, 289, 289, 289, 289, 289, 289, 289, 289,
- /* 1870 */ 289, 289, 289, 289, 289, 289, 289, 289, 289, 289,
- /* 1880 */ 289, 289, 289, 289, 289, 289, 289, 289, 289, 289,
- /* 1890 */ 289, 289, 289, 289, 289, 289, 289, 289, 289, 289,
- /* 1900 */ 289, 289, 289, 289, 289, 289, 289,
+ /* 190 */ 103, 96, 97, 270, 16, 20, 110, 22, 275, 21,
+ /* 200 */ 107, 19, 92, 93, 94, 95, 96, 97, 98, 99,
+ /* 210 */ 100, 101, 102, 103, 128, 129, 16, 267, 13, 41,
+ /* 220 */ 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
+ /* 230 */ 52, 53, 54, 55, 103, 111, 221, 222, 143, 57,
+ /* 240 */ 145, 41, 42, 43, 44, 45, 46, 47, 48, 49,
+ /* 250 */ 50, 51, 52, 53, 54, 55, 92, 93, 94, 95,
+ /* 260 */ 96, 97, 98, 99, 100, 101, 102, 103, 22, 179,
+ /* 270 */ 92, 93, 94, 95, 96, 97, 98, 99, 100, 101,
+ /* 280 */ 102, 103, 77, 108, 79, 202, 57, 16, 106, 107,
+ /* 290 */ 108, 20, 92, 93, 94, 95, 96, 97, 98, 99,
+ /* 300 */ 100, 101, 102, 103, 52, 53, 54, 55, 133, 196,
+ /* 310 */ 197, 198, 41, 42, 43, 44, 45, 46, 47, 48,
+ /* 320 */ 49, 50, 51, 52, 53, 54, 55, 98, 179, 109,
+ /* 330 */ 57, 73, 112, 113, 114, 106, 107, 108, 221, 222,
+ /* 340 */ 140, 179, 122, 253, 92, 93, 94, 95, 96, 97,
+ /* 350 */ 98, 99, 100, 101, 102, 103, 151, 16, 199, 57,
+ /* 360 */ 179, 20, 179, 92, 93, 94, 95, 96, 97, 98,
+ /* 370 */ 99, 100, 101, 102, 103, 117, 118, 119, 132, 106,
+ /* 380 */ 107, 108, 41, 42, 43, 44, 45, 46, 47, 48,
+ /* 390 */ 49, 50, 51, 52, 53, 54, 55, 248, 96, 97,
+ /* 400 */ 179, 179, 179, 201, 22, 179, 57, 105, 106, 107,
+ /* 410 */ 108, 209, 110, 190, 141, 253, 190, 258, 259, 260,
+ /* 420 */ 118, 72, 21, 202, 203, 202, 203, 179, 202, 203,
+ /* 430 */ 249, 248, 23, 92, 93, 94, 95, 96, 97, 98,
+ /* 440 */ 99, 100, 101, 102, 103, 143, 224, 145, 225, 226,
+ /* 450 */ 16, 225, 226, 179, 20, 106, 107, 108, 57, 238,
+ /* 460 */ 237, 238, 179, 237, 238, 73, 57, 16, 247, 179,
+ /* 470 */ 247, 20, 224, 81, 19, 41, 42, 43, 44, 45,
+ /* 480 */ 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
+ /* 490 */ 179, 179, 41, 42, 43, 44, 45, 46, 47, 48,
+ /* 500 */ 49, 50, 51, 52, 53, 54, 55, 9, 107, 117,
+ /* 510 */ 128, 129, 57, 225, 226, 106, 107, 108, 57, 179,
+ /* 520 */ 128, 129, 24, 249, 179, 237, 92, 93, 94, 95,
+ /* 530 */ 96, 97, 98, 99, 100, 101, 102, 103, 40, 124,
+ /* 540 */ 19, 126, 127, 92, 93, 94, 95, 96, 97, 98,
+ /* 550 */ 99, 100, 101, 102, 103, 18, 179, 19, 218, 61,
+ /* 560 */ 16, 106, 107, 108, 20, 253, 276, 106, 107, 108,
+ /* 570 */ 109, 73, 227, 112, 113, 114, 179, 16, 57, 202,
+ /* 580 */ 203, 20, 179, 122, 19, 41, 42, 43, 44, 45,
+ /* 590 */ 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
+ /* 600 */ 179, 179, 41, 42, 43, 44, 45, 46, 47, 48,
+ /* 610 */ 49, 50, 51, 52, 53, 54, 55, 80, 199, 197,
+ /* 620 */ 198, 224, 57, 202, 203, 179, 179, 106, 107, 108,
+ /* 630 */ 190, 57, 12, 288, 96, 97, 92, 93, 94, 95,
+ /* 640 */ 96, 97, 98, 99, 100, 101, 102, 103, 202, 203,
+ /* 650 */ 113, 179, 249, 92, 93, 94, 95, 96, 97, 98,
+ /* 660 */ 99, 100, 101, 102, 103, 225, 226, 179, 179, 179,
+ /* 670 */ 16, 106, 107, 108, 202, 203, 105, 237, 58, 191,
+ /* 680 */ 106, 107, 108, 57, 238, 179, 216, 16, 151, 217,
+ /* 690 */ 268, 202, 203, 247, 275, 41, 42, 43, 44, 45,
+ /* 700 */ 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
+ /* 710 */ 179, 140, 41, 42, 43, 44, 45, 46, 47, 48,
+ /* 720 */ 49, 50, 51, 52, 53, 54, 55, 238, 197, 198,
+ /* 730 */ 224, 179, 106, 107, 108, 288, 247, 44, 248, 187,
+ /* 740 */ 190, 179, 179, 179, 192, 57, 92, 93, 94, 95,
+ /* 750 */ 96, 97, 98, 99, 100, 101, 102, 103, 32, 133,
+ /* 760 */ 179, 98, 179, 92, 93, 94, 95, 96, 97, 98,
+ /* 770 */ 99, 100, 101, 102, 103, 225, 226, 20, 179, 22,
+ /* 780 */ 16, 19, 20, 202, 203, 21, 280, 237, 125, 227,
+ /* 790 */ 64, 227, 8, 130, 106, 107, 108, 16, 105, 268,
+ /* 800 */ 74, 202, 203, 149, 190, 41, 42, 43, 44, 45,
+ /* 810 */ 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
+ /* 820 */ 149, 133, 41, 42, 43, 44, 45, 46, 47, 48,
+ /* 830 */ 49, 50, 51, 52, 53, 54, 55, 238, 226, 225,
+ /* 840 */ 226, 179, 19, 20, 179, 22, 120, 179, 179, 237,
+ /* 850 */ 288, 237, 288, 91, 192, 19, 92, 93, 94, 95,
+ /* 860 */ 96, 97, 98, 99, 100, 101, 102, 103, 19, 22,
+ /* 870 */ 21, 202, 203, 92, 93, 94, 95, 96, 97, 98,
+ /* 880 */ 99, 100, 101, 102, 103, 179, 217, 51, 179, 224,
+ /* 890 */ 16, 19, 20, 179, 22, 179, 101, 102, 103, 4,
+ /* 900 */ 5, 6, 118, 119, 179, 125, 57, 16, 192, 179,
+ /* 910 */ 130, 202, 203, 190, 91, 41, 42, 43, 44, 45,
+ /* 920 */ 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
+ /* 930 */ 214, 179, 216, 42, 43, 44, 45, 46, 47, 48,
+ /* 940 */ 49, 50, 51, 52, 53, 54, 55, 238, 225, 226,
+ /* 950 */ 117, 118, 119, 179, 202, 203, 107, 22, 179, 253,
+ /* 960 */ 237, 19, 148, 91, 150, 179, 92, 93, 94, 95,
+ /* 970 */ 96, 97, 98, 99, 100, 101, 102, 103, 190, 132,
+ /* 980 */ 179, 202, 203, 92, 93, 94, 95, 96, 97, 98,
+ /* 990 */ 99, 100, 101, 102, 103, 179, 217, 179, 179, 57,
+ /* 1000 */ 16, 276, 16, 202, 203, 22, 276, 21, 26, 184,
+ /* 1010 */ 224, 179, 30, 225, 226, 194, 195, 179, 202, 203,
+ /* 1020 */ 179, 202, 203, 179, 19, 237, 21, 43, 44, 45,
+ /* 1030 */ 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
+ /* 1040 */ 202, 203, 179, 202, 203, 63, 16, 16, 17, 107,
+ /* 1050 */ 19, 116, 172, 173, 174, 175, 176, 238, 117, 118,
+ /* 1060 */ 119, 181, 218, 183, 33, 202, 203, 16, 190, 119,
+ /* 1070 */ 190, 85, 22, 194, 195, 179, 92, 93, 94, 95,
+ /* 1080 */ 96, 97, 98, 99, 100, 101, 102, 103, 57, 103,
+ /* 1090 */ 265, 108, 142, 9, 269, 109, 110, 111, 112, 113,
+ /* 1100 */ 114, 115, 71, 225, 226, 225, 226, 121, 24, 20,
+ /* 1110 */ 179, 22, 81, 230, 57, 237, 133, 237, 179, 19,
+ /* 1120 */ 20, 90, 239, 16, 40, 128, 129, 96, 97, 16,
+ /* 1130 */ 17, 251, 19, 202, 203, 104, 106, 106, 107, 108,
+ /* 1140 */ 283, 284, 111, 21, 90, 61, 33, 90, 179, 16,
+ /* 1150 */ 17, 44, 19, 241, 242, 19, 179, 106, 179, 128,
+ /* 1160 */ 129, 107, 282, 106, 107, 111, 33, 179, 111, 179,
+ /* 1170 */ 57, 202, 203, 179, 143, 144, 145, 146, 147, 202,
+ /* 1180 */ 203, 202, 203, 179, 71, 230, 217, 230, 13, 139,
+ /* 1190 */ 57, 91, 202, 203, 239, 59, 239, 143, 144, 145,
+ /* 1200 */ 143, 144, 145, 90, 71, 230, 202, 203, 179, 96,
+ /* 1210 */ 97, 98, 105, 179, 239, 110, 111, 104, 28, 106,
+ /* 1220 */ 107, 108, 254, 90, 111, 230, 36, 179, 121, 96,
+ /* 1230 */ 97, 202, 203, 143, 239, 145, 89, 104, 179, 106,
+ /* 1240 */ 107, 108, 179, 179, 111, 179, 16, 17, 179, 19,
+ /* 1250 */ 202, 203, 77, 131, 79, 179, 143, 144, 145, 146,
+ /* 1260 */ 147, 179, 179, 33, 139, 140, 202, 203, 202, 203,
+ /* 1270 */ 123, 202, 203, 179, 19, 179, 143, 144, 145, 146,
+ /* 1280 */ 147, 0, 1, 2, 202, 203, 212, 57, 7, 8,
+ /* 1290 */ 9, 10, 11, 179, 57, 14, 202, 203, 202, 203,
+ /* 1300 */ 179, 71, 119, 4, 5, 174, 175, 176, 179, 20,
+ /* 1310 */ 29, 22, 181, 20, 183, 22, 179, 57, 37, 179,
+ /* 1320 */ 90, 190, 1, 2, 179, 142, 96, 97, 7, 8,
+ /* 1330 */ 9, 10, 11, 179, 104, 14, 106, 107, 108, 179,
+ /* 1340 */ 179, 111, 202, 203, 107, 179, 179, 202, 203, 179,
+ /* 1350 */ 29, 70, 20, 212, 22, 179, 225, 226, 37, 78,
+ /* 1360 */ 179, 111, 81, 202, 203, 212, 179, 107, 237, 202,
+ /* 1370 */ 203, 121, 179, 143, 144, 145, 146, 147, 202, 203,
+ /* 1380 */ 83, 84, 251, 202, 203, 20, 131, 22, 179, 202,
+ /* 1390 */ 203, 70, 179, 179, 179, 202, 203, 179, 179, 78,
+ /* 1400 */ 179, 243, 81, 179, 123, 179, 20, 179, 22, 128,
+ /* 1410 */ 129, 202, 203, 282, 179, 202, 203, 179, 57, 179,
+ /* 1420 */ 202, 203, 179, 202, 203, 240, 202, 203, 179, 222,
+ /* 1430 */ 202, 203, 20, 152, 22, 179, 179, 20, 179, 22,
+ /* 1440 */ 202, 203, 202, 203, 123, 20, 179, 22, 179, 128,
+ /* 1450 */ 129, 202, 203, 179, 20, 179, 22, 179, 179, 202,
+ /* 1460 */ 203, 202, 203, 179, 20, 143, 22, 145, 107, 202,
+ /* 1470 */ 203, 202, 203, 152, 179, 179, 202, 203, 202, 203,
+ /* 1480 */ 202, 203, 20, 20, 22, 22, 202, 203, 179, 179,
+ /* 1490 */ 179, 179, 179, 228, 272, 229, 271, 177, 240, 252,
+ /* 1500 */ 200, 240, 240, 240, 281, 252, 231, 256, 244, 277,
+ /* 1510 */ 256, 231, 244, 277, 232, 232, 215, 211, 231, 229,
+ /* 1520 */ 206, 205, 205, 205, 182, 58, 256, 256, 35, 244,
+ /* 1530 */ 131, 186, 141, 281, 140, 19, 264, 41, 15, 220,
+ /* 1540 */ 186, 15, 185, 139, 186, 257, 223, 255, 223, 223,
+ /* 1550 */ 223, 257, 185, 255, 281, 278, 232, 220, 267, 257,
+ /* 1560 */ 232, 232, 232, 220, 278, 60, 148, 186, 185, 19,
+ /* 1570 */ 207, 186, 185, 207, 186, 185, 105, 274, 273, 204,
+ /* 1580 */ 204, 204, 62, 213, 19, 116, 204, 207, 210, 210,
+ /* 1590 */ 206, 21, 103, 204, 134, 246, 289, 204, 245, 204,
+ /* 1600 */ 266, 266, 105, 207, 245, 213, 246, 186, 246, 245,
+ /* 1610 */ 82, 19, 261, 186, 246, 263, 245, 138, 148, 250,
+ /* 1620 */ 135, 137, 250, 136, 22, 188, 10, 180, 180, 3,
+ /* 1630 */ 178, 178, 234, 236, 233, 235, 178, 232, 193, 199,
+ /* 1640 */ 199, 199, 287, 287, 193, 199, 208, 208, 193, 200,
+ /* 1650 */ 200, 19, 153, 199, 12, 20, 13, 284, 20, 129,
+ /* 1660 */ 141, 120, 22, 132, 17, 21, 134, 13, 1, 132,
+ /* 1670 */ 59, 120, 120, 34, 141, 51, 51, 120, 51, 51,
+ /* 1680 */ 106, 31, 1, 19, 131, 2, 105, 151, 68, 68,
+ /* 1690 */ 22, 38, 75, 131, 105, 21, 17, 121, 16, 115,
+ /* 1700 */ 67, 67, 57, 19, 19, 19, 34, 20, 19, 21,
+ /* 1710 */ 20, 19, 19, 67, 20, 86, 25, 20, 22, 20,
+ /* 1720 */ 20, 131, 20, 87, 106, 19, 31, 133, 19, 22,
+ /* 1730 */ 22, 20, 31, 20, 31, 20, 20, 20, 8, 20,
+ /* 1740 */ 22, 19, 19, 22, 20, 20, 19, 19, 125, 12,
+ /* 1750 */ 131, 22, 20, 131, 1, 290, 290, 290, 290, 290,
+ /* 1760 */ 290, 131, 131, 290, 290, 290, 290, 290, 290, 290,
+ /* 1770 */ 290, 290, 290, 290, 290, 290, 290, 290, 290, 290,
+ /* 1780 */ 290, 290, 290, 290, 290, 290, 290, 290, 290, 290,
+ /* 1790 */ 290, 290, 290, 290, 290, 290, 290, 290, 290, 290,
+ /* 1800 */ 290, 290, 290, 290, 290, 290, 290, 290, 290, 290,
+ /* 1810 */ 290, 290, 290, 290, 290, 290, 290, 290, 290, 290,
+ /* 1820 */ 290, 290, 290, 290, 290, 290, 290, 290, 290, 290,
+ /* 1830 */ 290, 290, 290, 290, 290, 290, 290, 290, 290, 290,
+ /* 1840 */ 290, 290, 290, 290, 290, 290, 290, 290, 290, 290,
+ /* 1850 */ 290, 290, 290, 290, 290, 290, 290, 290, 290, 290,
+ /* 1860 */ 290, 290, 290, 290, 290, 290, 290, 290, 290, 290,
+ /* 1870 */ 290, 290, 290, 290, 290, 290, 290, 290, 290, 290,
+ /* 1880 */ 290, 290, 290, 290, 290, 290, 290, 290, 290, 290,
+ /* 1890 */ 290, 290, 290, 290, 290, 290, 290, 290, 290, 290,
+ /* 1900 */ 290, 290, 290, 290, 290, 290, 290, 290, 290, 290,
+ /* 1910 */ 290, 290, 290, 290, 290, 290, 290, 290, 290, 290,
+ /* 1920 */ 290, 290, 290, 290, 290, 290, 290, 290, 290, 290,
+ /* 1930 */ 290, 290, 290, 290, 290,
};
-#define YY_SHIFT_COUNT (516)
+#define YY_SHIFT_COUNT (518)
#define YY_SHIFT_MIN (0)
-#define YY_SHIFT_MAX (1722)
+#define YY_SHIFT_MAX (1753)
static const unsigned short int yy_shift_ofst[] = {
- /* 0 */ 1286, 750, 1062, 1062, 369, 1131, 1131, 1131, 321, 0,
- /* 10 */ 0, 87, 813, 1131, 1131, 1131, 1131, 1131, 1131, 1131,
- /* 20 */ 1131, 1131, 278, 278, 437, 229, 369, 369, 369, 369,
- /* 30 */ 369, 17, 155, 177, 248, 317, 410, 427, 520, 537,
- /* 40 */ 630, 647, 796, 813, 813, 813, 813, 813, 813, 813,
- /* 50 */ 813, 813, 813, 813, 813, 813, 813, 813, 813, 813,
- /* 60 */ 813, 906, 813, 923, 1016, 1016, 1113, 1131, 1131, 1131,
- /* 70 */ 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131,
- /* 80 */ 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131,
- /* 90 */ 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131,
- /* 100 */ 1228, 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131, 1131,
- /* 110 */ 1131, 1131, 1131, 1131, 68, 228, 228, 228, 228, 228,
- /* 120 */ 51, 115, 428, 135, 536, 133, 381, 381, 970, 968,
- /* 130 */ 381, 300, 300, 381, 627, 627, 627, 627, 41, 140,
- /* 140 */ 6, 1736, 1736, 689, 689, 689, 546, 138, 138, 138,
- /* 150 */ 138, 586, 586, 133, 904, 918, 381, 381, 381, 381,
- /* 160 */ 381, 381, 381, 381, 381, 381, 381, 381, 381, 381,
- /* 170 */ 381, 381, 381, 381, 381, 381, 459, 601, 601, 928,
- /* 180 */ 1736, 1736, 1736, 1736, 1736, 1736, 1736, 679, 682, 682,
- /* 190 */ 384, 196, 208, 609, 661, 676, 775, 381, 381, 381,
- /* 200 */ 381, 381, 381, 381, 381, 481, 381, 381, 381, 381,
- /* 210 */ 381, 381, 381, 381, 381, 381, 381, 381, 979, 979,
- /* 220 */ 979, 381, 381, 381, 152, 381, 381, 381, 1018, 381,
- /* 230 */ 381, 695, 381, 381, 381, 381, 381, 381, 381, 381,
- /* 240 */ 538, 469, 583, 925, 925, 925, 925, 1067, 583, 583,
- /* 250 */ 706, 866, 927, 501, 214, 954, 1008, 1112, 954, 1112,
- /* 260 */ 1125, 635, 214, 214, 635, 214, 1008, 1125, 572, 691,
- /* 270 */ 1077, 1157, 1157, 1157, 1112, 1047, 1032, 805, 1176, 1442,
- /* 280 */ 1442, 1466, 1466, 1373, 1365, 1368, 1489, 1469, 1496, 1496,
- /* 290 */ 1496, 1496, 1373, 1500, 1379, 1368, 1368, 1379, 1489, 1469,
- /* 300 */ 1379, 1469, 1379, 1373, 1500, 1391, 1479, 1373, 1500, 1523,
- /* 310 */ 1373, 1500, 1373, 1500, 1523, 1445, 1445, 1445, 1493, 1537,
- /* 320 */ 1537, 1523, 1445, 1443, 1445, 1493, 1445, 1445, 1541, 1462,
- /* 330 */ 1462, 1523, 1433, 1463, 1433, 1463, 1433, 1463, 1433, 1463,
- /* 340 */ 1373, 1501, 1501, 1567, 1373, 1446, 1452, 1456, 1458, 1460,
- /* 350 */ 1379, 1575, 1589, 1589, 1597, 1597, 1597, 1736, 1736, 1736,
- /* 360 */ 1736, 1736, 1736, 1736, 1736, 1736, 1736, 1736, 1736, 1736,
- /* 370 */ 1736, 1736, 241, 908, 64, 464, 181, 931, 1017, 1211,
- /* 380 */ 875, 1141, 992, 645, 1108, 1259, 1086, 1260, 1289, 1310,
- /* 390 */ 1322, 1323, 1326, 1126, 1197, 1371, 1144, 718, 1183, 1374,
- /* 400 */ 1383, 1167, 1390, 1288, 1291, 1421, 1431, 1235, 1249, 1602,
- /* 410 */ 1471, 1613, 1614, 1610, 1611, 1504, 1494, 1514, 1615, 1615,
- /* 420 */ 1617, 1505, 1618, 1506, 1627, 1640, 1511, 1524, 1615, 1525,
- /* 430 */ 1586, 1612, 1615, 1507, 1598, 1599, 1600, 1601, 1529, 1548,
- /* 440 */ 1623, 1526, 1654, 1655, 1639, 1555, 1510, 1593, 1641, 1594,
- /* 450 */ 1590, 1626, 1536, 1563, 1647, 1652, 1656, 1550, 1557, 1657,
- /* 460 */ 1606, 1658, 1659, 1660, 1662, 1607, 1622, 1661, 1603, 1650,
- /* 470 */ 1664, 1619, 1651, 1667, 1668, 1670, 1669, 1672, 1665, 1608,
- /* 480 */ 1564, 1673, 1676, 1592, 1671, 1679, 1568, 1677, 1674, 1681,
- /* 490 */ 1675, 1684, 1677, 1687, 1688, 1689, 1690, 1691, 1692, 1682,
- /* 500 */ 1703, 1695, 1696, 1697, 1698, 1700, 1701, 1694, 1604, 1591,
- /* 510 */ 1595, 1596, 1605, 1702, 1707, 1710, 1722,
+ /* 0 */ 1321, 1281, 1031, 1031, 47, 1133, 1133, 1133, 392, 0,
+ /* 10 */ 0, 110, 781, 1133, 1133, 1133, 1133, 1133, 1133, 1133,
+ /* 20 */ 1133, 1133, 302, 302, 461, 86, 47, 47, 47, 47,
+ /* 30 */ 47, 17, 178, 200, 271, 341, 434, 451, 544, 561,
+ /* 40 */ 654, 671, 764, 781, 781, 781, 781, 781, 781, 781,
+ /* 50 */ 781, 781, 781, 781, 781, 781, 781, 781, 781, 781,
+ /* 60 */ 781, 874, 781, 891, 984, 984, 1113, 1133, 1133, 1133,
+ /* 70 */ 1133, 1133, 1133, 1133, 1133, 1133, 1133, 1133, 1133, 1133,
+ /* 80 */ 1133, 1133, 1133, 1133, 1133, 1133, 1133, 1133, 1133, 1133,
+ /* 90 */ 1133, 1133, 1133, 1133, 1133, 1133, 1133, 1133, 1133, 1133,
+ /* 100 */ 1133, 1230, 1133, 1133, 1133, 1133, 1133, 1133, 1133, 1133,
+ /* 110 */ 1133, 1133, 1133, 1133, 1133, 87, 252, 252, 252, 252,
+ /* 120 */ 252, 164, 34, 46, 66, 349, 409, 574, 574, 537,
+ /* 130 */ 1107, 574, 95, 95, 574, 382, 382, 382, 795, 382,
+ /* 140 */ 6, 131, 131, 1763, 1763, 986, 986, 986, 273, 182,
+ /* 150 */ 182, 182, 182, 498, 498, 409, 823, 872, 574, 574,
+ /* 160 */ 574, 574, 574, 574, 574, 574, 574, 574, 574, 574,
+ /* 170 */ 574, 574, 574, 574, 574, 574, 574, 574, 784, 93,
+ /* 180 */ 93, 997, 1763, 1763, 1763, 1763, 1763, 1763, 1763, 1057,
+ /* 190 */ 1054, 1054, 455, 220, 229, 521, 626, 688, 565, 574,
+ /* 200 */ 574, 574, 574, 574, 574, 574, 574, 258, 574, 574,
+ /* 210 */ 574, 574, 574, 574, 574, 574, 574, 574, 574, 574,
+ /* 220 */ 726, 726, 726, 574, 574, 574, 175, 574, 574, 574,
+ /* 230 */ 849, 574, 574, 1084, 574, 574, 574, 574, 574, 574,
+ /* 240 */ 574, 574, 833, 982, 415, 401, 401, 401, 401, 983,
+ /* 250 */ 415, 415, 663, 538, 895, 620, 571, 1125, 246, 1030,
+ /* 260 */ 1125, 1030, 1051, 1050, 571, 571, 1050, 571, 246, 1051,
+ /* 270 */ 935, 757, 693, 1190, 1190, 1190, 1030, 814, 847, 780,
+ /* 280 */ 1005, 1467, 1467, 1493, 1493, 1399, 1391, 1394, 1516, 1496,
+ /* 290 */ 1523, 1523, 1523, 1523, 1399, 1526, 1404, 1394, 1394, 1404,
+ /* 300 */ 1516, 1496, 1404, 1496, 1404, 1399, 1526, 1418, 1505, 1399,
+ /* 310 */ 1526, 1550, 1399, 1526, 1399, 1526, 1550, 1471, 1471, 1471,
+ /* 320 */ 1520, 1565, 1565, 1550, 1471, 1469, 1471, 1520, 1471, 1471,
+ /* 330 */ 1570, 1489, 1489, 1550, 1460, 1497, 1460, 1497, 1460, 1497,
+ /* 340 */ 1460, 1497, 1399, 1528, 1528, 1592, 1399, 1470, 1479, 1485,
+ /* 350 */ 1484, 1487, 1404, 1602, 1616, 1616, 1626, 1626, 1626, 1763,
+ /* 360 */ 1763, 1763, 1763, 1763, 1763, 1763, 1763, 1763, 1763, 1763,
+ /* 370 */ 1763, 1763, 1763, 1763, 124, 205, 762, 1100, 1175, 941,
+ /* 380 */ 942, 1089, 1147, 836, 1122, 950, 1183, 1289, 1136, 1293,
+ /* 390 */ 1332, 1365, 1386, 1412, 1417, 1237, 1105, 1299, 1250, 40,
+ /* 400 */ 1260, 1425, 1434, 1297, 1444, 1090, 1322, 1462, 1463, 1361,
+ /* 410 */ 1255, 1632, 1499, 1642, 1643, 1635, 1638, 1530, 1519, 1541,
+ /* 420 */ 1640, 1640, 1644, 1531, 1647, 1532, 1654, 1667, 1537, 1551,
+ /* 430 */ 1640, 1552, 1611, 1639, 1640, 1533, 1624, 1625, 1627, 1628,
+ /* 440 */ 1557, 1574, 1650, 1553, 1681, 1683, 1664, 1581, 1536, 1620,
+ /* 450 */ 1668, 1621, 1617, 1653, 1562, 1589, 1674, 1679, 1682, 1576,
+ /* 460 */ 1584, 1684, 1633, 1685, 1686, 1687, 1689, 1634, 1645, 1688,
+ /* 470 */ 1629, 1691, 1692, 1646, 1672, 1690, 1694, 1697, 1696, 1699,
+ /* 480 */ 1693, 1636, 1590, 1700, 1702, 1618, 1695, 1706, 1594, 1707,
+ /* 490 */ 1701, 1708, 1703, 1711, 1707, 1713, 1715, 1716, 1717, 1718,
+ /* 500 */ 1719, 1709, 1730, 1722, 1723, 1724, 1725, 1727, 1728, 1721,
+ /* 510 */ 1623, 1619, 1622, 1630, 1631, 1729, 1732, 1737, 1753,
};
-#define YY_REDUCE_COUNT (371)
-#define YY_REDUCE_MIN (-262)
-#define YY_REDUCE_MAX (1434)
+#define YY_REDUCE_COUNT (373)
+#define YY_REDUCE_MIN (-263)
+#define YY_REDUCE_MAX (1458)
static const short yy_reduce_ofst[] = {
- /* 0 */ 1130, 962, 199, 203, -151, 153, 423, 466, -149, -180,
- /* 10 */ -177, -257, 121, 230, 314, 336, 701, 632, 726, -170,
- /* 20 */ 698, 742, -90, -5, 449, 582, 591, 694, 802, 804,
- /* 30 */ 821, -254, -254, -254, -254, -254, -254, -254, -254, -254,
- /* 40 */ -254, -254, -254, -254, -254, -254, -254, -254, -254, -254,
- /* 50 */ -254, -254, -254, -254, -254, -254, -254, -254, -254, -254,
- /* 60 */ -254, -254, -254, -254, -254, -254, -172, -167, 575, 895,
- /* 70 */ 898, 902, 905, 924, 953, 960, 975, 978, 1013, 1023,
- /* 80 */ 1051, 1061, 1064, 1068, 1070, 1082, 1089, 1120, 1138, 1148,
- /* 90 */ 1151, 1159, 1180, 1185, 1187, 1190, 1199, 1205, 1215, 1217,
- /* 100 */ 1219, 1221, 1224, 1226, 1237, 1246, 1253, 1256, 1258, 1262,
- /* 110 */ 1264, 1266, 1268, 1271, -254, -254, -254, -254, -254, -254,
- /* 120 */ -254, -254, 315, -254, 320, -171, 382, 378, 283, -198,
- /* 130 */ 587, -182, -70, 584, -199, 756, -199, 756, 65, -254,
- /* 140 */ -254, -254, -254, 198, 198, 198, 127, 134, 418, 559,
- /* 150 */ 618, -164, 46, 243, -262, -262, 340, 470, 543, 747,
- /* 160 */ 211, 422, 693, 763, 154, -73, 445, 361, 636, 758,
- /* 170 */ 697, 811, 174, 433, 709, 836, 227, 659, 848, 865,
- /* 180 */ 769, -220, 856, 911, 937, 846, 944, -23, 45, 60,
- /* 190 */ 158, 96, 195, 339, 560, 641, 658, 708, 812, 857,
- /* 200 */ 899, 913, 949, 956, 993, 123, 1000, 1022, 1035, 1044,
- /* 210 */ 1057, 1100, 1135, 1136, 1139, 1142, 1149, 1150, 395, 662,
- /* 220 */ 772, 1169, 1173, 1179, 165, 1181, 1184, 1191, 1069, 1200,
- /* 230 */ 1206, 823, 1207, 195, 1212, 1220, 1231, 1251, 1267, 1272,
- /* 240 */ 886, 1066, 1059, 1213, 1222, 1223, 1232, 165, 1059, 1059,
- /* 250 */ 1247, 1257, 1298, 1196, 1225, 1227, 1252, 1234, 1230, 1236,
- /* 260 */ 1208, 1254, 1233, 1238, 1255, 1239, 1261, 1214, 1278, 1273,
- /* 270 */ 1279, 1292, 1293, 1294, 1263, 1229, 1265, 1274, 1318, 1240,
- /* 280 */ 1241, 1242, 1245, 1319, 1243, 1269, 1270, 1295, 1290, 1296,
- /* 290 */ 1301, 1304, 1328, 1332, 1297, 1275, 1276, 1299, 1280, 1308,
- /* 300 */ 1302, 1316, 1305, 1344, 1353, 1277, 1281, 1355, 1357, 1337,
- /* 310 */ 1359, 1361, 1362, 1364, 1340, 1348, 1349, 1351, 1345, 1350,
- /* 320 */ 1352, 1354, 1360, 1363, 1366, 1358, 1369, 1370, 1283, 1300,
- /* 330 */ 1309, 1372, 1330, 1333, 1331, 1335, 1336, 1338, 1339, 1341,
- /* 340 */ 1395, 1342, 1343, 1327, 1403, 1334, 1367, 1375, 1377, 1376,
- /* 350 */ 1380, 1411, 1422, 1424, 1427, 1428, 1429, 1321, 1329, 1346,
- /* 360 */ 1420, 1415, 1416, 1418, 1419, 1426, 1412, 1413, 1423, 1425,
- /* 370 */ 1430, 1434,
+ /* 0 */ 880, 1131, 223, 226, -152, 221, 446, 489, -150, -181,
+ /* 10 */ -178, -258, 159, -96, 472, 669, 969, 599, 779, -171,
+ /* 20 */ 709, 819, 422, 531, 716, 440, 550, 614, 723, 788,
+ /* 30 */ 878, -255, -255, -255, -255, -255, -255, -255, -255, -255,
+ /* 40 */ -255, -255, -255, -255, -255, -255, -255, -255, -255, -255,
+ /* 50 */ -255, -255, -255, -255, -255, -255, -255, -255, -255, -255,
+ /* 60 */ -255, -255, -255, -255, -255, -255, -173, -168, 377, 421,
+ /* 70 */ 581, 752, 801, 816, 838, 841, 863, 931, 977, 979,
+ /* 80 */ 990, 1004, 1029, 1048, 1064, 1066, 1069, 1082, 1094, 1096,
+ /* 90 */ 1140, 1145, 1161, 1167, 1176, 1181, 1187, 1193, 1209, 1213,
+ /* 100 */ 1218, 1221, 1224, 1228, 1238, 1240, 1249, 1257, 1259, 1267,
+ /* 110 */ 1269, 1274, 1276, 1278, 1284, -255, -255, -255, -255, -255,
+ /* 120 */ -255, -255, -255, -255, -122, 345, -172, 506, 562, 825,
+ /* 130 */ -199, 564, -183, 113, 552, -200, 288, -200, -255, 288,
+ /* 140 */ -77, -255, -255, -255, -255, 202, 202, 202, -50, 90,
+ /* 150 */ 162, 312, 706, 15, 117, 488, -263, -263, 662, 149,
+ /* 160 */ 183, 490, 222, 248, 397, 665, 290, -161, 725, -71,
+ /* 170 */ 181, 730, 274, 786, 340, 844, 447, 403, 419, 821,
+ /* 180 */ 879, 612, 857, 883, 955, 957, 975, 912, 995, -193,
+ /* 190 */ -118, 83, 283, 470, 311, 563, 583, 668, 714, 774,
+ /* 200 */ 818, 832, 896, 939, 988, 994, 1034, 968, 1059, 1063,
+ /* 210 */ 1076, 1083, 1114, 1121, 1129, 1137, 1154, 1160, 1166, 1170,
+ /* 220 */ 1074, 1141, 1153, 1214, 1215, 1219, 1158, 1226, 1235, 1243,
+ /* 230 */ 1185, 1256, 1279, 1207, 1295, 311, 1296, 1309, 1310, 1311,
+ /* 240 */ 1312, 1313, 1222, 1225, 1265, 1258, 1261, 1262, 1263, 1158,
+ /* 250 */ 1265, 1265, 1266, 1300, 1320, 1223, 1251, 1247, 1275, 1264,
+ /* 260 */ 1253, 1268, 1232, 1282, 1254, 1270, 1283, 1271, 1280, 1236,
+ /* 270 */ 1314, 1301, 1306, 1316, 1317, 1318, 1285, 1272, 1287, 1290,
+ /* 280 */ 1342, 1252, 1273, 1277, 1286, 1345, 1291, 1288, 1292, 1319,
+ /* 290 */ 1323, 1325, 1326, 1327, 1354, 1357, 1324, 1294, 1302, 1328,
+ /* 300 */ 1298, 1337, 1329, 1343, 1330, 1358, 1367, 1303, 1305, 1381,
+ /* 310 */ 1383, 1363, 1385, 1387, 1388, 1390, 1366, 1375, 1376, 1377,
+ /* 320 */ 1370, 1378, 1379, 1380, 1382, 1384, 1389, 1392, 1393, 1395,
+ /* 330 */ 1307, 1334, 1335, 1396, 1349, 1353, 1360, 1359, 1362, 1364,
+ /* 340 */ 1368, 1371, 1421, 1369, 1372, 1351, 1427, 1352, 1397, 1400,
+ /* 350 */ 1398, 1401, 1405, 1437, 1447, 1448, 1452, 1453, 1458, 1355,
+ /* 360 */ 1356, 1373, 1445, 1440, 1441, 1442, 1446, 1451, 1438, 1439,
+ /* 370 */ 1449, 1450, 1454, 1455,
};
static const YYACTIONTYPE yy_default[] = {
- /* 0 */ 1464, 1464, 1329, 1102, 1210, 1329, 1329, 1329, 1102, 1240,
- /* 10 */ 1240, 1382, 1133, 1102, 1102, 1102, 1102, 1102, 1102, 1328,
- /* 20 */ 1102, 1102, 1102, 1102, 1102, 1102, 1102, 1102, 1102, 1102,
- /* 30 */ 1102, 1249, 1102, 1256, 1102, 1102, 1102, 1102, 1330, 1331,
- /* 40 */ 1102, 1102, 1102, 1381, 1383, 1346, 1263, 1262, 1261, 1260,
- /* 50 */ 1364, 1227, 1254, 1247, 1251, 1324, 1325, 1323, 1327, 1331,
- /* 60 */ 1330, 1102, 1250, 1295, 1309, 1294, 1102, 1102, 1102, 1102,
- /* 70 */ 1102, 1102, 1102, 1102, 1102, 1102, 1102, 1102, 1102, 1102,
- /* 80 */ 1102, 1102, 1102, 1102, 1102, 1102, 1102, 1102, 1102, 1102,
- /* 90 */ 1102, 1102, 1102, 1102, 1102, 1102, 1102, 1102, 1102, 1102,
- /* 100 */ 1102, 1102, 1102, 1102, 1102, 1102, 1102, 1102, 1102, 1102,
- /* 110 */ 1102, 1102, 1102, 1102, 1303, 1308, 1314, 1307, 1304, 1297,
- /* 120 */ 1296, 1298, 1102, 1299, 1102, 1124, 1102, 1102, 1121, 1175,
- /* 130 */ 1102, 1102, 1102, 1102, 1397, 1396, 1102, 1102, 1133, 1300,
- /* 140 */ 1301, 1311, 1310, 1385, 1417, 1416, 1347, 1102, 1102, 1102,
- /* 150 */ 1102, 1102, 1102, 1102, 1102, 1102, 1102, 1102, 1102, 1102,
- /* 160 */ 1102, 1102, 1102, 1102, 1102, 1102, 1102, 1102, 1102, 1102,
- /* 170 */ 1102, 1102, 1102, 1102, 1102, 1102, 1133, 1129, 1129, 1102,
- /* 180 */ 1392, 1201, 1201, 1201, 1201, 1210, 1201, 1102, 1102, 1102,
- /* 190 */ 1102, 1102, 1102, 1102, 1102, 1102, 1102, 1102, 1102, 1102,
- /* 200 */ 1102, 1102, 1102, 1102, 1102, 1102, 1102, 1102, 1102, 1102,
- /* 210 */ 1102, 1102, 1102, 1102, 1102, 1102, 1102, 1102, 1102, 1102,
- /* 220 */ 1102, 1102, 1102, 1102, 1102, 1102, 1102, 1102, 1206, 1102,
- /* 230 */ 1102, 1102, 1102, 1102, 1102, 1102, 1102, 1102, 1102, 1410,
- /* 240 */ 1102, 1359, 1189, 1206, 1206, 1206, 1206, 1208, 1190, 1188,
- /* 250 */ 1200, 1134, 1107, 1456, 1266, 1255, 1207, 1229, 1255, 1229,
- /* 260 */ 1453, 1253, 1266, 1266, 1253, 1266, 1207, 1453, 1150, 1433,
- /* 270 */ 1145, 1240, 1240, 1240, 1229, 1326, 1207, 1200, 1102, 1456,
- /* 280 */ 1456, 1455, 1455, 1215, 1347, 1440, 1275, 1178, 1184, 1184,
- /* 290 */ 1184, 1184, 1215, 1118, 1253, 1440, 1440, 1253, 1275, 1178,
- /* 300 */ 1253, 1178, 1253, 1215, 1118, 1363, 1450, 1215, 1118, 1337,
- /* 310 */ 1215, 1118, 1215, 1118, 1337, 1176, 1176, 1176, 1165, 1102,
- /* 320 */ 1102, 1337, 1176, 1150, 1176, 1165, 1176, 1176, 1102, 1341,
- /* 330 */ 1341, 1337, 1233, 1228, 1233, 1228, 1233, 1228, 1233, 1228,
- /* 340 */ 1215, 1243, 1243, 1332, 1215, 1102, 1248, 1234, 1246, 1244,
- /* 350 */ 1253, 1168, 1413, 1413, 1409, 1409, 1409, 1461, 1461, 1392,
- /* 360 */ 1426, 1133, 1133, 1133, 1133, 1426, 1152, 1152, 1134, 1134,
- /* 370 */ 1133, 1426, 1102, 1102, 1102, 1102, 1102, 1102, 1421, 1102,
- /* 380 */ 1387, 1348, 1219, 1102, 1102, 1102, 1102, 1102, 1102, 1102,
- /* 390 */ 1102, 1102, 1102, 1102, 1102, 1102, 1102, 1398, 1102, 1102,
- /* 400 */ 1102, 1102, 1102, 1102, 1102, 1102, 1102, 1102, 1280, 1389,
- /* 410 */ 1102, 1102, 1102, 1102, 1102, 1102, 1102, 1102, 1257, 1258,
- /* 420 */ 1220, 1102, 1102, 1102, 1102, 1102, 1102, 1102, 1272, 1102,
- /* 430 */ 1102, 1102, 1267, 1102, 1102, 1102, 1102, 1102, 1102, 1102,
- /* 440 */ 1102, 1452, 1102, 1102, 1102, 1102, 1102, 1102, 1362, 1361,
- /* 450 */ 1102, 1102, 1217, 1102, 1102, 1102, 1102, 1102, 1102, 1102,
- /* 460 */ 1102, 1102, 1102, 1102, 1102, 1102, 1148, 1102, 1102, 1102,
- /* 470 */ 1102, 1102, 1102, 1102, 1102, 1102, 1102, 1102, 1102, 1102,
- /* 480 */ 1102, 1102, 1102, 1102, 1102, 1102, 1102, 1245, 1102, 1235,
- /* 490 */ 1102, 1102, 1443, 1102, 1102, 1102, 1102, 1102, 1102, 1102,
- /* 500 */ 1102, 1102, 1102, 1102, 1102, 1102, 1102, 1437, 1192, 1282,
- /* 510 */ 1102, 1281, 1285, 1122, 1102, 1112, 1102,
+ /* 0 */ 1468, 1468, 1333, 1105, 1213, 1333, 1333, 1333, 1105, 1243,
+ /* 10 */ 1243, 1386, 1136, 1105, 1105, 1105, 1105, 1105, 1105, 1332,
+ /* 20 */ 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1105,
+ /* 30 */ 1105, 1252, 1105, 1259, 1105, 1105, 1105, 1105, 1334, 1335,
+ /* 40 */ 1105, 1105, 1105, 1385, 1387, 1350, 1266, 1265, 1264, 1263,
+ /* 50 */ 1368, 1230, 1257, 1250, 1254, 1328, 1329, 1327, 1331, 1335,
+ /* 60 */ 1334, 1105, 1253, 1298, 1312, 1297, 1105, 1105, 1105, 1105,
+ /* 70 */ 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1105,
+ /* 80 */ 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1105,
+ /* 90 */ 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1105,
+ /* 100 */ 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1105,
+ /* 110 */ 1105, 1105, 1105, 1105, 1105, 1306, 1311, 1318, 1310, 1307,
+ /* 120 */ 1300, 1299, 1301, 1302, 1105, 1105, 1127, 1105, 1105, 1124,
+ /* 130 */ 1178, 1105, 1105, 1105, 1105, 1401, 1400, 1105, 1303, 1105,
+ /* 140 */ 1136, 1315, 1304, 1314, 1313, 1389, 1421, 1420, 1351, 1105,
+ /* 150 */ 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1105,
+ /* 160 */ 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1105,
+ /* 170 */ 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1136, 1132,
+ /* 180 */ 1132, 1105, 1396, 1204, 1204, 1204, 1204, 1213, 1204, 1105,
+ /* 190 */ 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1105,
+ /* 200 */ 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1105,
+ /* 210 */ 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1105,
+ /* 220 */ 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1105,
+ /* 230 */ 1209, 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1105,
+ /* 240 */ 1105, 1414, 1105, 1363, 1192, 1209, 1209, 1209, 1209, 1211,
+ /* 250 */ 1193, 1191, 1203, 1137, 1110, 1460, 1269, 1258, 1210, 1232,
+ /* 260 */ 1258, 1232, 1457, 1256, 1269, 1269, 1256, 1269, 1210, 1457,
+ /* 270 */ 1153, 1437, 1148, 1243, 1243, 1243, 1232, 1330, 1210, 1203,
+ /* 280 */ 1105, 1460, 1460, 1459, 1459, 1218, 1351, 1444, 1278, 1181,
+ /* 290 */ 1187, 1187, 1187, 1187, 1218, 1121, 1256, 1444, 1444, 1256,
+ /* 300 */ 1278, 1181, 1256, 1181, 1256, 1218, 1121, 1367, 1454, 1218,
+ /* 310 */ 1121, 1341, 1218, 1121, 1218, 1121, 1341, 1179, 1179, 1179,
+ /* 320 */ 1168, 1105, 1105, 1341, 1179, 1153, 1179, 1168, 1179, 1179,
+ /* 330 */ 1105, 1345, 1345, 1341, 1236, 1231, 1236, 1231, 1236, 1231,
+ /* 340 */ 1236, 1231, 1218, 1246, 1246, 1336, 1218, 1105, 1251, 1237,
+ /* 350 */ 1249, 1247, 1256, 1171, 1417, 1417, 1413, 1413, 1413, 1465,
+ /* 360 */ 1465, 1396, 1430, 1136, 1136, 1136, 1136, 1430, 1155, 1155,
+ /* 370 */ 1137, 1137, 1136, 1430, 1105, 1105, 1105, 1105, 1105, 1105,
+ /* 380 */ 1425, 1105, 1391, 1352, 1222, 1105, 1105, 1105, 1105, 1105,
+ /* 390 */ 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1402,
+ /* 400 */ 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1105,
+ /* 410 */ 1283, 1393, 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1105,
+ /* 420 */ 1260, 1261, 1223, 1105, 1105, 1105, 1105, 1105, 1105, 1105,
+ /* 430 */ 1275, 1105, 1105, 1105, 1270, 1105, 1105, 1105, 1105, 1105,
+ /* 440 */ 1105, 1105, 1105, 1456, 1105, 1105, 1105, 1105, 1105, 1105,
+ /* 450 */ 1366, 1365, 1105, 1105, 1220, 1105, 1105, 1105, 1105, 1105,
+ /* 460 */ 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1151, 1105,
+ /* 470 */ 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1105,
+ /* 480 */ 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1248,
+ /* 490 */ 1105, 1238, 1105, 1105, 1447, 1105, 1105, 1105, 1105, 1105,
+ /* 500 */ 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1441,
+ /* 510 */ 1195, 1285, 1105, 1284, 1288, 1125, 1105, 1115, 1105,
};
/********** End of lemon-generated parsing tables *****************************/
@@ -160638,6 +162501,7 @@ static const YYCODETYPE yyFallback[] = {
0, /* SLASH => nothing */
0, /* REM => nothing */
0, /* CONCAT => nothing */
+ 0, /* PTR => nothing */
0, /* COLLATE => nothing */
0, /* BITNOT => nothing */
0, /* ON => nothing */
@@ -160897,193 +162761,194 @@ static const char *const yyTokenName[] = {
/* 99 */ "SLASH",
/* 100 */ "REM",
/* 101 */ "CONCAT",
- /* 102 */ "COLLATE",
- /* 103 */ "BITNOT",
- /* 104 */ "ON",
- /* 105 */ "INDEXED",
- /* 106 */ "STRING",
- /* 107 */ "JOIN_KW",
- /* 108 */ "CONSTRAINT",
- /* 109 */ "DEFAULT",
- /* 110 */ "NULL",
- /* 111 */ "PRIMARY",
- /* 112 */ "UNIQUE",
- /* 113 */ "CHECK",
- /* 114 */ "REFERENCES",
- /* 115 */ "AUTOINCR",
- /* 116 */ "INSERT",
- /* 117 */ "DELETE",
- /* 118 */ "UPDATE",
- /* 119 */ "SET",
- /* 120 */ "DEFERRABLE",
- /* 121 */ "FOREIGN",
- /* 122 */ "DROP",
- /* 123 */ "UNION",
- /* 124 */ "ALL",
- /* 125 */ "EXCEPT",
- /* 126 */ "INTERSECT",
- /* 127 */ "SELECT",
- /* 128 */ "VALUES",
- /* 129 */ "DISTINCT",
- /* 130 */ "DOT",
- /* 131 */ "FROM",
- /* 132 */ "JOIN",
- /* 133 */ "USING",
- /* 134 */ "ORDER",
- /* 135 */ "GROUP",
- /* 136 */ "HAVING",
- /* 137 */ "LIMIT",
- /* 138 */ "WHERE",
- /* 139 */ "RETURNING",
- /* 140 */ "INTO",
- /* 141 */ "NOTHING",
- /* 142 */ "FLOAT",
- /* 143 */ "BLOB",
- /* 144 */ "INTEGER",
- /* 145 */ "VARIABLE",
- /* 146 */ "CASE",
- /* 147 */ "WHEN",
- /* 148 */ "THEN",
- /* 149 */ "ELSE",
- /* 150 */ "INDEX",
- /* 151 */ "ALTER",
- /* 152 */ "ADD",
- /* 153 */ "COLUMN",
- /* 154 */ "AGG_FUNCTION",
- /* 155 */ "AGG_COLUMN",
- /* 156 */ "TRUEFALSE",
- /* 157 */ "ISNOT",
- /* 158 */ "FUNCTION",
- /* 159 */ "UMINUS",
- /* 160 */ "UPLUS",
- /* 161 */ "TRUTH",
- /* 162 */ "REGISTER",
- /* 163 */ "VECTOR",
- /* 164 */ "SELECT_COLUMN",
- /* 165 */ "IF_NULL_ROW",
- /* 166 */ "ASTERISK",
- /* 167 */ "SPAN",
- /* 168 */ "ERROR",
- /* 169 */ "SPACE",
- /* 170 */ "ILLEGAL",
- /* 171 */ "input",
- /* 172 */ "cmdlist",
- /* 173 */ "ecmd",
- /* 174 */ "cmdx",
- /* 175 */ "cmd",
- /* 176 */ "transtype",
- /* 177 */ "trans_opt",
- /* 178 */ "nm",
- /* 179 */ "savepoint_opt",
- /* 180 */ "create_table",
- /* 181 */ "create_table_args",
- /* 182 */ "createkw",
- /* 183 */ "temp",
- /* 184 */ "ifnotexists",
- /* 185 */ "dbnm",
- /* 186 */ "columnlist",
- /* 187 */ "conslist_opt",
- /* 188 */ "table_option_set",
- /* 189 */ "select",
- /* 190 */ "table_option",
- /* 191 */ "columnname",
- /* 192 */ "carglist",
- /* 193 */ "typetoken",
- /* 194 */ "typename",
- /* 195 */ "signed",
- /* 196 */ "plus_num",
- /* 197 */ "minus_num",
- /* 198 */ "scanpt",
- /* 199 */ "scantok",
- /* 200 */ "ccons",
- /* 201 */ "term",
- /* 202 */ "expr",
- /* 203 */ "onconf",
- /* 204 */ "sortorder",
- /* 205 */ "autoinc",
- /* 206 */ "eidlist_opt",
- /* 207 */ "refargs",
- /* 208 */ "defer_subclause",
- /* 209 */ "generated",
- /* 210 */ "refarg",
- /* 211 */ "refact",
- /* 212 */ "init_deferred_pred_opt",
- /* 213 */ "conslist",
- /* 214 */ "tconscomma",
- /* 215 */ "tcons",
- /* 216 */ "sortlist",
- /* 217 */ "eidlist",
- /* 218 */ "defer_subclause_opt",
- /* 219 */ "orconf",
- /* 220 */ "resolvetype",
- /* 221 */ "raisetype",
- /* 222 */ "ifexists",
- /* 223 */ "fullname",
- /* 224 */ "selectnowith",
- /* 225 */ "oneselect",
- /* 226 */ "wqlist",
- /* 227 */ "multiselect_op",
- /* 228 */ "distinct",
- /* 229 */ "selcollist",
- /* 230 */ "from",
- /* 231 */ "where_opt",
- /* 232 */ "groupby_opt",
- /* 233 */ "having_opt",
- /* 234 */ "orderby_opt",
- /* 235 */ "limit_opt",
- /* 236 */ "values",
- /* 237 */ "nexprlist",
- /* 238 */ "sclp",
- /* 239 */ "as",
- /* 240 */ "seltablist",
- /* 241 */ "stl_prefix",
- /* 242 */ "joinop",
- /* 243 */ "indexed_opt",
- /* 244 */ "on_opt",
- /* 245 */ "using_opt",
- /* 246 */ "exprlist",
- /* 247 */ "xfullname",
- /* 248 */ "idlist",
- /* 249 */ "nulls",
- /* 250 */ "with",
- /* 251 */ "where_opt_ret",
- /* 252 */ "setlist",
- /* 253 */ "insert_cmd",
- /* 254 */ "idlist_opt",
- /* 255 */ "upsert",
- /* 256 */ "returning",
- /* 257 */ "likeop",
- /* 258 */ "between_op",
- /* 259 */ "in_op",
- /* 260 */ "paren_exprlist",
- /* 261 */ "case_operand",
- /* 262 */ "case_exprlist",
- /* 263 */ "case_else",
- /* 264 */ "uniqueflag",
- /* 265 */ "collate",
- /* 266 */ "vinto",
- /* 267 */ "nmnum",
- /* 268 */ "trigger_decl",
- /* 269 */ "trigger_cmd_list",
- /* 270 */ "trigger_time",
- /* 271 */ "trigger_event",
- /* 272 */ "foreach_clause",
- /* 273 */ "when_clause",
- /* 274 */ "trigger_cmd",
- /* 275 */ "trnm",
- /* 276 */ "tridxby",
- /* 277 */ "database_kw_opt",
- /* 278 */ "key_opt",
- /* 279 */ "add_column_fullname",
- /* 280 */ "kwcolumn_opt",
- /* 281 */ "create_vtab",
- /* 282 */ "vtabarglist",
- /* 283 */ "vtabarg",
- /* 284 */ "vtabargtoken",
- /* 285 */ "lp",
- /* 286 */ "anylist",
- /* 287 */ "wqitem",
- /* 288 */ "wqas",
+ /* 102 */ "PTR",
+ /* 103 */ "COLLATE",
+ /* 104 */ "BITNOT",
+ /* 105 */ "ON",
+ /* 106 */ "INDEXED",
+ /* 107 */ "STRING",
+ /* 108 */ "JOIN_KW",
+ /* 109 */ "CONSTRAINT",
+ /* 110 */ "DEFAULT",
+ /* 111 */ "NULL",
+ /* 112 */ "PRIMARY",
+ /* 113 */ "UNIQUE",
+ /* 114 */ "CHECK",
+ /* 115 */ "REFERENCES",
+ /* 116 */ "AUTOINCR",
+ /* 117 */ "INSERT",
+ /* 118 */ "DELETE",
+ /* 119 */ "UPDATE",
+ /* 120 */ "SET",
+ /* 121 */ "DEFERRABLE",
+ /* 122 */ "FOREIGN",
+ /* 123 */ "DROP",
+ /* 124 */ "UNION",
+ /* 125 */ "ALL",
+ /* 126 */ "EXCEPT",
+ /* 127 */ "INTERSECT",
+ /* 128 */ "SELECT",
+ /* 129 */ "VALUES",
+ /* 130 */ "DISTINCT",
+ /* 131 */ "DOT",
+ /* 132 */ "FROM",
+ /* 133 */ "JOIN",
+ /* 134 */ "USING",
+ /* 135 */ "ORDER",
+ /* 136 */ "GROUP",
+ /* 137 */ "HAVING",
+ /* 138 */ "LIMIT",
+ /* 139 */ "WHERE",
+ /* 140 */ "RETURNING",
+ /* 141 */ "INTO",
+ /* 142 */ "NOTHING",
+ /* 143 */ "FLOAT",
+ /* 144 */ "BLOB",
+ /* 145 */ "INTEGER",
+ /* 146 */ "VARIABLE",
+ /* 147 */ "CASE",
+ /* 148 */ "WHEN",
+ /* 149 */ "THEN",
+ /* 150 */ "ELSE",
+ /* 151 */ "INDEX",
+ /* 152 */ "ALTER",
+ /* 153 */ "ADD",
+ /* 154 */ "COLUMN",
+ /* 155 */ "AGG_FUNCTION",
+ /* 156 */ "AGG_COLUMN",
+ /* 157 */ "TRUEFALSE",
+ /* 158 */ "ISNOT",
+ /* 159 */ "FUNCTION",
+ /* 160 */ "UMINUS",
+ /* 161 */ "UPLUS",
+ /* 162 */ "TRUTH",
+ /* 163 */ "REGISTER",
+ /* 164 */ "VECTOR",
+ /* 165 */ "SELECT_COLUMN",
+ /* 166 */ "IF_NULL_ROW",
+ /* 167 */ "ASTERISK",
+ /* 168 */ "SPAN",
+ /* 169 */ "ERROR",
+ /* 170 */ "SPACE",
+ /* 171 */ "ILLEGAL",
+ /* 172 */ "input",
+ /* 173 */ "cmdlist",
+ /* 174 */ "ecmd",
+ /* 175 */ "cmdx",
+ /* 176 */ "cmd",
+ /* 177 */ "transtype",
+ /* 178 */ "trans_opt",
+ /* 179 */ "nm",
+ /* 180 */ "savepoint_opt",
+ /* 181 */ "create_table",
+ /* 182 */ "create_table_args",
+ /* 183 */ "createkw",
+ /* 184 */ "temp",
+ /* 185 */ "ifnotexists",
+ /* 186 */ "dbnm",
+ /* 187 */ "columnlist",
+ /* 188 */ "conslist_opt",
+ /* 189 */ "table_option_set",
+ /* 190 */ "select",
+ /* 191 */ "table_option",
+ /* 192 */ "columnname",
+ /* 193 */ "carglist",
+ /* 194 */ "typetoken",
+ /* 195 */ "typename",
+ /* 196 */ "signed",
+ /* 197 */ "plus_num",
+ /* 198 */ "minus_num",
+ /* 199 */ "scanpt",
+ /* 200 */ "scantok",
+ /* 201 */ "ccons",
+ /* 202 */ "term",
+ /* 203 */ "expr",
+ /* 204 */ "onconf",
+ /* 205 */ "sortorder",
+ /* 206 */ "autoinc",
+ /* 207 */ "eidlist_opt",
+ /* 208 */ "refargs",
+ /* 209 */ "defer_subclause",
+ /* 210 */ "generated",
+ /* 211 */ "refarg",
+ /* 212 */ "refact",
+ /* 213 */ "init_deferred_pred_opt",
+ /* 214 */ "conslist",
+ /* 215 */ "tconscomma",
+ /* 216 */ "tcons",
+ /* 217 */ "sortlist",
+ /* 218 */ "eidlist",
+ /* 219 */ "defer_subclause_opt",
+ /* 220 */ "orconf",
+ /* 221 */ "resolvetype",
+ /* 222 */ "raisetype",
+ /* 223 */ "ifexists",
+ /* 224 */ "fullname",
+ /* 225 */ "selectnowith",
+ /* 226 */ "oneselect",
+ /* 227 */ "wqlist",
+ /* 228 */ "multiselect_op",
+ /* 229 */ "distinct",
+ /* 230 */ "selcollist",
+ /* 231 */ "from",
+ /* 232 */ "where_opt",
+ /* 233 */ "groupby_opt",
+ /* 234 */ "having_opt",
+ /* 235 */ "orderby_opt",
+ /* 236 */ "limit_opt",
+ /* 237 */ "values",
+ /* 238 */ "nexprlist",
+ /* 239 */ "sclp",
+ /* 240 */ "as",
+ /* 241 */ "seltablist",
+ /* 242 */ "stl_prefix",
+ /* 243 */ "joinop",
+ /* 244 */ "indexed_opt",
+ /* 245 */ "on_opt",
+ /* 246 */ "using_opt",
+ /* 247 */ "exprlist",
+ /* 248 */ "xfullname",
+ /* 249 */ "idlist",
+ /* 250 */ "nulls",
+ /* 251 */ "with",
+ /* 252 */ "where_opt_ret",
+ /* 253 */ "setlist",
+ /* 254 */ "insert_cmd",
+ /* 255 */ "idlist_opt",
+ /* 256 */ "upsert",
+ /* 257 */ "returning",
+ /* 258 */ "likeop",
+ /* 259 */ "between_op",
+ /* 260 */ "in_op",
+ /* 261 */ "paren_exprlist",
+ /* 262 */ "case_operand",
+ /* 263 */ "case_exprlist",
+ /* 264 */ "case_else",
+ /* 265 */ "uniqueflag",
+ /* 266 */ "collate",
+ /* 267 */ "vinto",
+ /* 268 */ "nmnum",
+ /* 269 */ "trigger_decl",
+ /* 270 */ "trigger_cmd_list",
+ /* 271 */ "trigger_time",
+ /* 272 */ "trigger_event",
+ /* 273 */ "foreach_clause",
+ /* 274 */ "when_clause",
+ /* 275 */ "trigger_cmd",
+ /* 276 */ "trnm",
+ /* 277 */ "tridxby",
+ /* 278 */ "database_kw_opt",
+ /* 279 */ "key_opt",
+ /* 280 */ "add_column_fullname",
+ /* 281 */ "kwcolumn_opt",
+ /* 282 */ "create_vtab",
+ /* 283 */ "vtabarglist",
+ /* 284 */ "vtabarg",
+ /* 285 */ "vtabargtoken",
+ /* 286 */ "lp",
+ /* 287 */ "anylist",
+ /* 288 */ "wqitem",
+ /* 289 */ "wqas",
};
#endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */
@@ -161298,159 +163163,160 @@ static const char *const yyRuleName[] = {
/* 204 */ "expr ::= NOT expr",
/* 205 */ "expr ::= BITNOT expr",
/* 206 */ "expr ::= PLUS|MINUS expr",
- /* 207 */ "between_op ::= BETWEEN",
- /* 208 */ "between_op ::= NOT BETWEEN",
- /* 209 */ "expr ::= expr between_op expr AND expr",
- /* 210 */ "in_op ::= IN",
- /* 211 */ "in_op ::= NOT IN",
- /* 212 */ "expr ::= expr in_op LP exprlist RP",
- /* 213 */ "expr ::= LP select RP",
- /* 214 */ "expr ::= expr in_op LP select RP",
- /* 215 */ "expr ::= expr in_op nm dbnm paren_exprlist",
- /* 216 */ "expr ::= EXISTS LP select RP",
- /* 217 */ "expr ::= CASE case_operand case_exprlist case_else END",
- /* 218 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr",
- /* 219 */ "case_exprlist ::= WHEN expr THEN expr",
- /* 220 */ "case_else ::= ELSE expr",
- /* 221 */ "case_else ::=",
- /* 222 */ "case_operand ::= expr",
- /* 223 */ "case_operand ::=",
- /* 224 */ "exprlist ::=",
- /* 225 */ "nexprlist ::= nexprlist COMMA expr",
- /* 226 */ "nexprlist ::= expr",
- /* 227 */ "paren_exprlist ::=",
- /* 228 */ "paren_exprlist ::= LP exprlist RP",
- /* 229 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt",
- /* 230 */ "uniqueflag ::= UNIQUE",
- /* 231 */ "uniqueflag ::=",
- /* 232 */ "eidlist_opt ::=",
- /* 233 */ "eidlist_opt ::= LP eidlist RP",
- /* 234 */ "eidlist ::= eidlist COMMA nm collate sortorder",
- /* 235 */ "eidlist ::= nm collate sortorder",
- /* 236 */ "collate ::=",
- /* 237 */ "collate ::= COLLATE ID|STRING",
- /* 238 */ "cmd ::= DROP INDEX ifexists fullname",
- /* 239 */ "cmd ::= VACUUM vinto",
- /* 240 */ "cmd ::= VACUUM nm vinto",
- /* 241 */ "vinto ::= INTO expr",
- /* 242 */ "vinto ::=",
- /* 243 */ "cmd ::= PRAGMA nm dbnm",
- /* 244 */ "cmd ::= PRAGMA nm dbnm EQ nmnum",
- /* 245 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP",
- /* 246 */ "cmd ::= PRAGMA nm dbnm EQ minus_num",
- /* 247 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP",
- /* 248 */ "plus_num ::= PLUS INTEGER|FLOAT",
- /* 249 */ "minus_num ::= MINUS INTEGER|FLOAT",
- /* 250 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
- /* 251 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
- /* 252 */ "trigger_time ::= BEFORE|AFTER",
- /* 253 */ "trigger_time ::= INSTEAD OF",
- /* 254 */ "trigger_time ::=",
- /* 255 */ "trigger_event ::= DELETE|INSERT",
- /* 256 */ "trigger_event ::= UPDATE",
- /* 257 */ "trigger_event ::= UPDATE OF idlist",
- /* 258 */ "when_clause ::=",
- /* 259 */ "when_clause ::= WHEN expr",
- /* 260 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
- /* 261 */ "trigger_cmd_list ::= trigger_cmd SEMI",
- /* 262 */ "trnm ::= nm DOT nm",
- /* 263 */ "tridxby ::= INDEXED BY nm",
- /* 264 */ "tridxby ::= NOT INDEXED",
- /* 265 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt",
- /* 266 */ "trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt",
- /* 267 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt",
- /* 268 */ "trigger_cmd ::= scanpt select scanpt",
- /* 269 */ "expr ::= RAISE LP IGNORE RP",
- /* 270 */ "expr ::= RAISE LP raisetype COMMA nm RP",
- /* 271 */ "raisetype ::= ROLLBACK",
- /* 272 */ "raisetype ::= ABORT",
- /* 273 */ "raisetype ::= FAIL",
- /* 274 */ "cmd ::= DROP TRIGGER ifexists fullname",
- /* 275 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
- /* 276 */ "cmd ::= DETACH database_kw_opt expr",
- /* 277 */ "key_opt ::=",
- /* 278 */ "key_opt ::= KEY expr",
- /* 279 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
- /* 280 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist",
- /* 281 */ "cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm",
- /* 282 */ "add_column_fullname ::= fullname",
- /* 283 */ "cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm",
- /* 284 */ "cmd ::= create_vtab",
- /* 285 */ "cmd ::= create_vtab LP vtabarglist RP",
- /* 286 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
- /* 287 */ "vtabarg ::=",
- /* 288 */ "vtabargtoken ::= ANY",
- /* 289 */ "vtabargtoken ::= lp anylist RP",
- /* 290 */ "lp ::= LP",
- /* 291 */ "with ::= WITH wqlist",
- /* 292 */ "with ::= WITH RECURSIVE wqlist",
- /* 293 */ "wqas ::= AS",
- /* 294 */ "wqas ::= AS MATERIALIZED",
- /* 295 */ "wqas ::= AS NOT MATERIALIZED",
- /* 296 */ "wqitem ::= nm eidlist_opt wqas LP select RP",
- /* 297 */ "wqlist ::= wqitem",
- /* 298 */ "wqlist ::= wqlist COMMA wqitem",
- /* 299 */ "input ::= cmdlist",
- /* 300 */ "cmdlist ::= cmdlist ecmd",
- /* 301 */ "cmdlist ::= ecmd",
- /* 302 */ "ecmd ::= SEMI",
- /* 303 */ "ecmd ::= cmdx SEMI",
- /* 304 */ "trans_opt ::=",
- /* 305 */ "trans_opt ::= TRANSACTION",
- /* 306 */ "trans_opt ::= TRANSACTION nm",
- /* 307 */ "savepoint_opt ::= SAVEPOINT",
- /* 308 */ "savepoint_opt ::=",
- /* 309 */ "cmd ::= create_table create_table_args",
- /* 310 */ "table_option_set ::= table_option",
- /* 311 */ "columnlist ::= columnlist COMMA columnname carglist",
- /* 312 */ "columnlist ::= columnname carglist",
- /* 313 */ "nm ::= ID|INDEXED",
- /* 314 */ "nm ::= STRING",
- /* 315 */ "nm ::= JOIN_KW",
- /* 316 */ "typetoken ::= typename",
- /* 317 */ "typename ::= ID|STRING",
- /* 318 */ "signed ::= plus_num",
- /* 319 */ "signed ::= minus_num",
- /* 320 */ "carglist ::= carglist ccons",
- /* 321 */ "carglist ::=",
- /* 322 */ "ccons ::= NULL onconf",
- /* 323 */ "ccons ::= GENERATED ALWAYS AS generated",
- /* 324 */ "ccons ::= AS generated",
- /* 325 */ "conslist_opt ::= COMMA conslist",
- /* 326 */ "conslist ::= conslist tconscomma tcons",
- /* 327 */ "conslist ::= tcons",
- /* 328 */ "tconscomma ::=",
- /* 329 */ "defer_subclause_opt ::= defer_subclause",
- /* 330 */ "resolvetype ::= raisetype",
- /* 331 */ "selectnowith ::= oneselect",
- /* 332 */ "oneselect ::= values",
- /* 333 */ "sclp ::= selcollist COMMA",
- /* 334 */ "as ::= ID|STRING",
- /* 335 */ "returning ::=",
- /* 336 */ "expr ::= term",
- /* 337 */ "likeop ::= LIKE_KW|MATCH",
- /* 338 */ "exprlist ::= nexprlist",
- /* 339 */ "nmnum ::= plus_num",
- /* 340 */ "nmnum ::= nm",
- /* 341 */ "nmnum ::= ON",
- /* 342 */ "nmnum ::= DELETE",
- /* 343 */ "nmnum ::= DEFAULT",
- /* 344 */ "plus_num ::= INTEGER|FLOAT",
- /* 345 */ "foreach_clause ::=",
- /* 346 */ "foreach_clause ::= FOR EACH ROW",
- /* 347 */ "trnm ::= nm",
- /* 348 */ "tridxby ::=",
- /* 349 */ "database_kw_opt ::= DATABASE",
- /* 350 */ "database_kw_opt ::=",
- /* 351 */ "kwcolumn_opt ::=",
- /* 352 */ "kwcolumn_opt ::= COLUMNKW",
- /* 353 */ "vtabarglist ::= vtabarg",
- /* 354 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
- /* 355 */ "vtabarg ::= vtabarg vtabargtoken",
- /* 356 */ "anylist ::=",
- /* 357 */ "anylist ::= anylist LP anylist RP",
- /* 358 */ "anylist ::= anylist ANY",
- /* 359 */ "with ::=",
+ /* 207 */ "expr ::= expr PTR expr",
+ /* 208 */ "between_op ::= BETWEEN",
+ /* 209 */ "between_op ::= NOT BETWEEN",
+ /* 210 */ "expr ::= expr between_op expr AND expr",
+ /* 211 */ "in_op ::= IN",
+ /* 212 */ "in_op ::= NOT IN",
+ /* 213 */ "expr ::= expr in_op LP exprlist RP",
+ /* 214 */ "expr ::= LP select RP",
+ /* 215 */ "expr ::= expr in_op LP select RP",
+ /* 216 */ "expr ::= expr in_op nm dbnm paren_exprlist",
+ /* 217 */ "expr ::= EXISTS LP select RP",
+ /* 218 */ "expr ::= CASE case_operand case_exprlist case_else END",
+ /* 219 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr",
+ /* 220 */ "case_exprlist ::= WHEN expr THEN expr",
+ /* 221 */ "case_else ::= ELSE expr",
+ /* 222 */ "case_else ::=",
+ /* 223 */ "case_operand ::= expr",
+ /* 224 */ "case_operand ::=",
+ /* 225 */ "exprlist ::=",
+ /* 226 */ "nexprlist ::= nexprlist COMMA expr",
+ /* 227 */ "nexprlist ::= expr",
+ /* 228 */ "paren_exprlist ::=",
+ /* 229 */ "paren_exprlist ::= LP exprlist RP",
+ /* 230 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt",
+ /* 231 */ "uniqueflag ::= UNIQUE",
+ /* 232 */ "uniqueflag ::=",
+ /* 233 */ "eidlist_opt ::=",
+ /* 234 */ "eidlist_opt ::= LP eidlist RP",
+ /* 235 */ "eidlist ::= eidlist COMMA nm collate sortorder",
+ /* 236 */ "eidlist ::= nm collate sortorder",
+ /* 237 */ "collate ::=",
+ /* 238 */ "collate ::= COLLATE ID|STRING",
+ /* 239 */ "cmd ::= DROP INDEX ifexists fullname",
+ /* 240 */ "cmd ::= VACUUM vinto",
+ /* 241 */ "cmd ::= VACUUM nm vinto",
+ /* 242 */ "vinto ::= INTO expr",
+ /* 243 */ "vinto ::=",
+ /* 244 */ "cmd ::= PRAGMA nm dbnm",
+ /* 245 */ "cmd ::= PRAGMA nm dbnm EQ nmnum",
+ /* 246 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP",
+ /* 247 */ "cmd ::= PRAGMA nm dbnm EQ minus_num",
+ /* 248 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP",
+ /* 249 */ "plus_num ::= PLUS INTEGER|FLOAT",
+ /* 250 */ "minus_num ::= MINUS INTEGER|FLOAT",
+ /* 251 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
+ /* 252 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
+ /* 253 */ "trigger_time ::= BEFORE|AFTER",
+ /* 254 */ "trigger_time ::= INSTEAD OF",
+ /* 255 */ "trigger_time ::=",
+ /* 256 */ "trigger_event ::= DELETE|INSERT",
+ /* 257 */ "trigger_event ::= UPDATE",
+ /* 258 */ "trigger_event ::= UPDATE OF idlist",
+ /* 259 */ "when_clause ::=",
+ /* 260 */ "when_clause ::= WHEN expr",
+ /* 261 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
+ /* 262 */ "trigger_cmd_list ::= trigger_cmd SEMI",
+ /* 263 */ "trnm ::= nm DOT nm",
+ /* 264 */ "tridxby ::= INDEXED BY nm",
+ /* 265 */ "tridxby ::= NOT INDEXED",
+ /* 266 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt",
+ /* 267 */ "trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt",
+ /* 268 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt",
+ /* 269 */ "trigger_cmd ::= scanpt select scanpt",
+ /* 270 */ "expr ::= RAISE LP IGNORE RP",
+ /* 271 */ "expr ::= RAISE LP raisetype COMMA nm RP",
+ /* 272 */ "raisetype ::= ROLLBACK",
+ /* 273 */ "raisetype ::= ABORT",
+ /* 274 */ "raisetype ::= FAIL",
+ /* 275 */ "cmd ::= DROP TRIGGER ifexists fullname",
+ /* 276 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
+ /* 277 */ "cmd ::= DETACH database_kw_opt expr",
+ /* 278 */ "key_opt ::=",
+ /* 279 */ "key_opt ::= KEY expr",
+ /* 280 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
+ /* 281 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist",
+ /* 282 */ "cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm",
+ /* 283 */ "add_column_fullname ::= fullname",
+ /* 284 */ "cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm",
+ /* 285 */ "cmd ::= create_vtab",
+ /* 286 */ "cmd ::= create_vtab LP vtabarglist RP",
+ /* 287 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
+ /* 288 */ "vtabarg ::=",
+ /* 289 */ "vtabargtoken ::= ANY",
+ /* 290 */ "vtabargtoken ::= lp anylist RP",
+ /* 291 */ "lp ::= LP",
+ /* 292 */ "with ::= WITH wqlist",
+ /* 293 */ "with ::= WITH RECURSIVE wqlist",
+ /* 294 */ "wqas ::= AS",
+ /* 295 */ "wqas ::= AS MATERIALIZED",
+ /* 296 */ "wqas ::= AS NOT MATERIALIZED",
+ /* 297 */ "wqitem ::= nm eidlist_opt wqas LP select RP",
+ /* 298 */ "wqlist ::= wqitem",
+ /* 299 */ "wqlist ::= wqlist COMMA wqitem",
+ /* 300 */ "input ::= cmdlist",
+ /* 301 */ "cmdlist ::= cmdlist ecmd",
+ /* 302 */ "cmdlist ::= ecmd",
+ /* 303 */ "ecmd ::= SEMI",
+ /* 304 */ "ecmd ::= cmdx SEMI",
+ /* 305 */ "trans_opt ::=",
+ /* 306 */ "trans_opt ::= TRANSACTION",
+ /* 307 */ "trans_opt ::= TRANSACTION nm",
+ /* 308 */ "savepoint_opt ::= SAVEPOINT",
+ /* 309 */ "savepoint_opt ::=",
+ /* 310 */ "cmd ::= create_table create_table_args",
+ /* 311 */ "table_option_set ::= table_option",
+ /* 312 */ "columnlist ::= columnlist COMMA columnname carglist",
+ /* 313 */ "columnlist ::= columnname carglist",
+ /* 314 */ "nm ::= ID|INDEXED",
+ /* 315 */ "nm ::= STRING",
+ /* 316 */ "nm ::= JOIN_KW",
+ /* 317 */ "typetoken ::= typename",
+ /* 318 */ "typename ::= ID|STRING",
+ /* 319 */ "signed ::= plus_num",
+ /* 320 */ "signed ::= minus_num",
+ /* 321 */ "carglist ::= carglist ccons",
+ /* 322 */ "carglist ::=",
+ /* 323 */ "ccons ::= NULL onconf",
+ /* 324 */ "ccons ::= GENERATED ALWAYS AS generated",
+ /* 325 */ "ccons ::= AS generated",
+ /* 326 */ "conslist_opt ::= COMMA conslist",
+ /* 327 */ "conslist ::= conslist tconscomma tcons",
+ /* 328 */ "conslist ::= tcons",
+ /* 329 */ "tconscomma ::=",
+ /* 330 */ "defer_subclause_opt ::= defer_subclause",
+ /* 331 */ "resolvetype ::= raisetype",
+ /* 332 */ "selectnowith ::= oneselect",
+ /* 333 */ "oneselect ::= values",
+ /* 334 */ "sclp ::= selcollist COMMA",
+ /* 335 */ "as ::= ID|STRING",
+ /* 336 */ "returning ::=",
+ /* 337 */ "expr ::= term",
+ /* 338 */ "likeop ::= LIKE_KW|MATCH",
+ /* 339 */ "exprlist ::= nexprlist",
+ /* 340 */ "nmnum ::= plus_num",
+ /* 341 */ "nmnum ::= nm",
+ /* 342 */ "nmnum ::= ON",
+ /* 343 */ "nmnum ::= DELETE",
+ /* 344 */ "nmnum ::= DEFAULT",
+ /* 345 */ "plus_num ::= INTEGER|FLOAT",
+ /* 346 */ "foreach_clause ::=",
+ /* 347 */ "foreach_clause ::= FOR EACH ROW",
+ /* 348 */ "trnm ::= nm",
+ /* 349 */ "tridxby ::=",
+ /* 350 */ "database_kw_opt ::= DATABASE",
+ /* 351 */ "database_kw_opt ::=",
+ /* 352 */ "kwcolumn_opt ::=",
+ /* 353 */ "kwcolumn_opt ::= COLUMNKW",
+ /* 354 */ "vtabarglist ::= vtabarg",
+ /* 355 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
+ /* 356 */ "vtabarg ::= vtabarg vtabargtoken",
+ /* 357 */ "anylist ::=",
+ /* 358 */ "anylist ::= anylist LP anylist RP",
+ /* 359 */ "anylist ::= anylist ANY",
+ /* 360 */ "with ::=",
};
#endif /* NDEBUG */
@@ -161576,75 +163442,75 @@ static void yy_destructor(
** inside the C code.
*/
/********* Begin destructor definitions ***************************************/
- case 189: /* select */
- case 224: /* selectnowith */
- case 225: /* oneselect */
- case 236: /* values */
+ case 190: /* select */
+ case 225: /* selectnowith */
+ case 226: /* oneselect */
+ case 237: /* values */
{
-sqlite3SelectDelete(pParse->db, (yypminor->yy433));
-}
- break;
- case 201: /* term */
- case 202: /* expr */
- case 231: /* where_opt */
- case 233: /* having_opt */
- case 244: /* on_opt */
- case 251: /* where_opt_ret */
- case 261: /* case_operand */
- case 263: /* case_else */
- case 266: /* vinto */
- case 273: /* when_clause */
- case 278: /* key_opt */
+sqlite3SelectDelete(pParse->db, (yypminor->yy279));
+}
+ break;
+ case 202: /* term */
+ case 203: /* expr */
+ case 232: /* where_opt */
+ case 234: /* having_opt */
+ case 245: /* on_opt */
+ case 252: /* where_opt_ret */
+ case 262: /* case_operand */
+ case 264: /* case_else */
+ case 267: /* vinto */
+ case 274: /* when_clause */
+ case 279: /* key_opt */
{
-sqlite3ExprDelete(pParse->db, (yypminor->yy454));
-}
- break;
- case 206: /* eidlist_opt */
- case 216: /* sortlist */
- case 217: /* eidlist */
- case 229: /* selcollist */
- case 232: /* groupby_opt */
- case 234: /* orderby_opt */
- case 237: /* nexprlist */
- case 238: /* sclp */
- case 246: /* exprlist */
- case 252: /* setlist */
- case 260: /* paren_exprlist */
- case 262: /* case_exprlist */
+sqlite3ExprDelete(pParse->db, (yypminor->yy122));
+}
+ break;
+ case 207: /* eidlist_opt */
+ case 217: /* sortlist */
+ case 218: /* eidlist */
+ case 230: /* selcollist */
+ case 233: /* groupby_opt */
+ case 235: /* orderby_opt */
+ case 238: /* nexprlist */
+ case 239: /* sclp */
+ case 247: /* exprlist */
+ case 253: /* setlist */
+ case 261: /* paren_exprlist */
+ case 263: /* case_exprlist */
{
-sqlite3ExprListDelete(pParse->db, (yypminor->yy368));
+sqlite3ExprListDelete(pParse->db, (yypminor->yy322));
}
break;
- case 223: /* fullname */
- case 230: /* from */
- case 240: /* seltablist */
- case 241: /* stl_prefix */
- case 247: /* xfullname */
+ case 224: /* fullname */
+ case 231: /* from */
+ case 241: /* seltablist */
+ case 242: /* stl_prefix */
+ case 248: /* xfullname */
{
-sqlite3SrcListDelete(pParse->db, (yypminor->yy155));
+sqlite3SrcListDelete(pParse->db, (yypminor->yy247));
}
break;
- case 226: /* wqlist */
+ case 227: /* wqlist */
{
-sqlite3WithDelete(pParse->db, (yypminor->yy23));
+sqlite3WithDelete(pParse->db, (yypminor->yy231));
}
break;
- case 245: /* using_opt */
- case 248: /* idlist */
- case 254: /* idlist_opt */
+ case 246: /* using_opt */
+ case 249: /* idlist */
+ case 255: /* idlist_opt */
{
-sqlite3IdListDelete(pParse->db, (yypminor->yy374));
+sqlite3IdListDelete(pParse->db, (yypminor->yy80));
}
break;
- case 269: /* trigger_cmd_list */
- case 274: /* trigger_cmd */
+ case 270: /* trigger_cmd_list */
+ case 275: /* trigger_cmd */
{
-sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy387));
+sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy207));
}
break;
- case 271: /* trigger_event */
+ case 272: /* trigger_event */
{
-sqlite3IdListDelete(pParse->db, (yypminor->yy96).b);
+sqlite3IdListDelete(pParse->db, (yypminor->yy470).b);
}
break;
/********* End destructor definitions *****************************************/
@@ -161935,366 +163801,367 @@ static void yy_shift(
/* For rule J, yyRuleInfoLhs[J] contains the symbol on the left-hand side
** of that rule */
static const YYCODETYPE yyRuleInfoLhs[] = {
- 174, /* (0) cmdx ::= cmd */
- 175, /* (1) cmd ::= BEGIN transtype trans_opt */
- 176, /* (2) transtype ::= */
- 176, /* (3) transtype ::= DEFERRED */
- 176, /* (4) transtype ::= IMMEDIATE */
- 176, /* (5) transtype ::= EXCLUSIVE */
- 175, /* (6) cmd ::= COMMIT|END trans_opt */
- 175, /* (7) cmd ::= ROLLBACK trans_opt */
- 175, /* (8) cmd ::= SAVEPOINT nm */
- 175, /* (9) cmd ::= RELEASE savepoint_opt nm */
- 175, /* (10) cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */
- 180, /* (11) create_table ::= createkw temp TABLE ifnotexists nm dbnm */
- 182, /* (12) createkw ::= CREATE */
- 184, /* (13) ifnotexists ::= */
- 184, /* (14) ifnotexists ::= IF NOT EXISTS */
- 183, /* (15) temp ::= TEMP */
- 183, /* (16) temp ::= */
- 181, /* (17) create_table_args ::= LP columnlist conslist_opt RP table_option_set */
- 181, /* (18) create_table_args ::= AS select */
- 188, /* (19) table_option_set ::= */
- 188, /* (20) table_option_set ::= table_option_set COMMA table_option */
- 190, /* (21) table_option ::= WITHOUT nm */
- 190, /* (22) table_option ::= nm */
- 191, /* (23) columnname ::= nm typetoken */
- 193, /* (24) typetoken ::= */
- 193, /* (25) typetoken ::= typename LP signed RP */
- 193, /* (26) typetoken ::= typename LP signed COMMA signed RP */
- 194, /* (27) typename ::= typename ID|STRING */
- 198, /* (28) scanpt ::= */
- 199, /* (29) scantok ::= */
- 200, /* (30) ccons ::= CONSTRAINT nm */
- 200, /* (31) ccons ::= DEFAULT scantok term */
- 200, /* (32) ccons ::= DEFAULT LP expr RP */
- 200, /* (33) ccons ::= DEFAULT PLUS scantok term */
- 200, /* (34) ccons ::= DEFAULT MINUS scantok term */
- 200, /* (35) ccons ::= DEFAULT scantok ID|INDEXED */
- 200, /* (36) ccons ::= NOT NULL onconf */
- 200, /* (37) ccons ::= PRIMARY KEY sortorder onconf autoinc */
- 200, /* (38) ccons ::= UNIQUE onconf */
- 200, /* (39) ccons ::= CHECK LP expr RP */
- 200, /* (40) ccons ::= REFERENCES nm eidlist_opt refargs */
- 200, /* (41) ccons ::= defer_subclause */
- 200, /* (42) ccons ::= COLLATE ID|STRING */
- 209, /* (43) generated ::= LP expr RP */
- 209, /* (44) generated ::= LP expr RP ID */
- 205, /* (45) autoinc ::= */
- 205, /* (46) autoinc ::= AUTOINCR */
- 207, /* (47) refargs ::= */
- 207, /* (48) refargs ::= refargs refarg */
- 210, /* (49) refarg ::= MATCH nm */
- 210, /* (50) refarg ::= ON INSERT refact */
- 210, /* (51) refarg ::= ON DELETE refact */
- 210, /* (52) refarg ::= ON UPDATE refact */
- 211, /* (53) refact ::= SET NULL */
- 211, /* (54) refact ::= SET DEFAULT */
- 211, /* (55) refact ::= CASCADE */
- 211, /* (56) refact ::= RESTRICT */
- 211, /* (57) refact ::= NO ACTION */
- 208, /* (58) defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
- 208, /* (59) defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
- 212, /* (60) init_deferred_pred_opt ::= */
- 212, /* (61) init_deferred_pred_opt ::= INITIALLY DEFERRED */
- 212, /* (62) init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
- 187, /* (63) conslist_opt ::= */
- 214, /* (64) tconscomma ::= COMMA */
- 215, /* (65) tcons ::= CONSTRAINT nm */
- 215, /* (66) tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
- 215, /* (67) tcons ::= UNIQUE LP sortlist RP onconf */
- 215, /* (68) tcons ::= CHECK LP expr RP onconf */
- 215, /* (69) tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
- 218, /* (70) defer_subclause_opt ::= */
- 203, /* (71) onconf ::= */
- 203, /* (72) onconf ::= ON CONFLICT resolvetype */
- 219, /* (73) orconf ::= */
- 219, /* (74) orconf ::= OR resolvetype */
- 220, /* (75) resolvetype ::= IGNORE */
- 220, /* (76) resolvetype ::= REPLACE */
- 175, /* (77) cmd ::= DROP TABLE ifexists fullname */
- 222, /* (78) ifexists ::= IF EXISTS */
- 222, /* (79) ifexists ::= */
- 175, /* (80) cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
- 175, /* (81) cmd ::= DROP VIEW ifexists fullname */
- 175, /* (82) cmd ::= select */
- 189, /* (83) select ::= WITH wqlist selectnowith */
- 189, /* (84) select ::= WITH RECURSIVE wqlist selectnowith */
- 189, /* (85) select ::= selectnowith */
- 224, /* (86) selectnowith ::= selectnowith multiselect_op oneselect */
- 227, /* (87) multiselect_op ::= UNION */
- 227, /* (88) multiselect_op ::= UNION ALL */
- 227, /* (89) multiselect_op ::= EXCEPT|INTERSECT */
- 225, /* (90) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
- 236, /* (91) values ::= VALUES LP nexprlist RP */
- 236, /* (92) values ::= values COMMA LP nexprlist RP */
- 228, /* (93) distinct ::= DISTINCT */
- 228, /* (94) distinct ::= ALL */
- 228, /* (95) distinct ::= */
- 238, /* (96) sclp ::= */
- 229, /* (97) selcollist ::= sclp scanpt expr scanpt as */
- 229, /* (98) selcollist ::= sclp scanpt STAR */
- 229, /* (99) selcollist ::= sclp scanpt nm DOT STAR */
- 239, /* (100) as ::= AS nm */
- 239, /* (101) as ::= */
- 230, /* (102) from ::= */
- 230, /* (103) from ::= FROM seltablist */
- 241, /* (104) stl_prefix ::= seltablist joinop */
- 241, /* (105) stl_prefix ::= */
- 240, /* (106) seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
- 240, /* (107) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
- 240, /* (108) seltablist ::= stl_prefix LP select RP as on_opt using_opt */
- 240, /* (109) seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
- 185, /* (110) dbnm ::= */
- 185, /* (111) dbnm ::= DOT nm */
- 223, /* (112) fullname ::= nm */
- 223, /* (113) fullname ::= nm DOT nm */
- 247, /* (114) xfullname ::= nm */
- 247, /* (115) xfullname ::= nm DOT nm */
- 247, /* (116) xfullname ::= nm DOT nm AS nm */
- 247, /* (117) xfullname ::= nm AS nm */
- 242, /* (118) joinop ::= COMMA|JOIN */
- 242, /* (119) joinop ::= JOIN_KW JOIN */
- 242, /* (120) joinop ::= JOIN_KW nm JOIN */
- 242, /* (121) joinop ::= JOIN_KW nm nm JOIN */
- 244, /* (122) on_opt ::= ON expr */
- 244, /* (123) on_opt ::= */
- 243, /* (124) indexed_opt ::= */
- 243, /* (125) indexed_opt ::= INDEXED BY nm */
- 243, /* (126) indexed_opt ::= NOT INDEXED */
- 245, /* (127) using_opt ::= USING LP idlist RP */
- 245, /* (128) using_opt ::= */
- 234, /* (129) orderby_opt ::= */
- 234, /* (130) orderby_opt ::= ORDER BY sortlist */
- 216, /* (131) sortlist ::= sortlist COMMA expr sortorder nulls */
- 216, /* (132) sortlist ::= expr sortorder nulls */
- 204, /* (133) sortorder ::= ASC */
- 204, /* (134) sortorder ::= DESC */
- 204, /* (135) sortorder ::= */
- 249, /* (136) nulls ::= NULLS FIRST */
- 249, /* (137) nulls ::= NULLS LAST */
- 249, /* (138) nulls ::= */
- 232, /* (139) groupby_opt ::= */
- 232, /* (140) groupby_opt ::= GROUP BY nexprlist */
- 233, /* (141) having_opt ::= */
- 233, /* (142) having_opt ::= HAVING expr */
- 235, /* (143) limit_opt ::= */
- 235, /* (144) limit_opt ::= LIMIT expr */
- 235, /* (145) limit_opt ::= LIMIT expr OFFSET expr */
- 235, /* (146) limit_opt ::= LIMIT expr COMMA expr */
- 175, /* (147) cmd ::= with DELETE FROM xfullname indexed_opt where_opt_ret */
- 231, /* (148) where_opt ::= */
- 231, /* (149) where_opt ::= WHERE expr */
- 251, /* (150) where_opt_ret ::= */
- 251, /* (151) where_opt_ret ::= WHERE expr */
- 251, /* (152) where_opt_ret ::= RETURNING selcollist */
- 251, /* (153) where_opt_ret ::= WHERE expr RETURNING selcollist */
- 175, /* (154) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist from where_opt_ret */
- 252, /* (155) setlist ::= setlist COMMA nm EQ expr */
- 252, /* (156) setlist ::= setlist COMMA LP idlist RP EQ expr */
- 252, /* (157) setlist ::= nm EQ expr */
- 252, /* (158) setlist ::= LP idlist RP EQ expr */
- 175, /* (159) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
- 175, /* (160) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES returning */
- 255, /* (161) upsert ::= */
- 255, /* (162) upsert ::= RETURNING selcollist */
- 255, /* (163) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt upsert */
- 255, /* (164) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING upsert */
- 255, /* (165) upsert ::= ON CONFLICT DO NOTHING returning */
- 255, /* (166) upsert ::= ON CONFLICT DO UPDATE SET setlist where_opt returning */
- 256, /* (167) returning ::= RETURNING selcollist */
- 253, /* (168) insert_cmd ::= INSERT orconf */
- 253, /* (169) insert_cmd ::= REPLACE */
- 254, /* (170) idlist_opt ::= */
- 254, /* (171) idlist_opt ::= LP idlist RP */
- 248, /* (172) idlist ::= idlist COMMA nm */
- 248, /* (173) idlist ::= nm */
- 202, /* (174) expr ::= LP expr RP */
- 202, /* (175) expr ::= ID|INDEXED */
- 202, /* (176) expr ::= JOIN_KW */
- 202, /* (177) expr ::= nm DOT nm */
- 202, /* (178) expr ::= nm DOT nm DOT nm */
- 201, /* (179) term ::= NULL|FLOAT|BLOB */
- 201, /* (180) term ::= STRING */
- 201, /* (181) term ::= INTEGER */
- 202, /* (182) expr ::= VARIABLE */
- 202, /* (183) expr ::= expr COLLATE ID|STRING */
- 202, /* (184) expr ::= CAST LP expr AS typetoken RP */
- 202, /* (185) expr ::= ID|INDEXED LP distinct exprlist RP */
- 202, /* (186) expr ::= ID|INDEXED LP STAR RP */
- 201, /* (187) term ::= CTIME_KW */
- 202, /* (188) expr ::= LP nexprlist COMMA expr RP */
- 202, /* (189) expr ::= expr AND expr */
- 202, /* (190) expr ::= expr OR expr */
- 202, /* (191) expr ::= expr LT|GT|GE|LE expr */
- 202, /* (192) expr ::= expr EQ|NE expr */
- 202, /* (193) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */
- 202, /* (194) expr ::= expr PLUS|MINUS expr */
- 202, /* (195) expr ::= expr STAR|SLASH|REM expr */
- 202, /* (196) expr ::= expr CONCAT expr */
- 257, /* (197) likeop ::= NOT LIKE_KW|MATCH */
- 202, /* (198) expr ::= expr likeop expr */
- 202, /* (199) expr ::= expr likeop expr ESCAPE expr */
- 202, /* (200) expr ::= expr ISNULL|NOTNULL */
- 202, /* (201) expr ::= expr NOT NULL */
- 202, /* (202) expr ::= expr IS expr */
- 202, /* (203) expr ::= expr IS NOT expr */
- 202, /* (204) expr ::= NOT expr */
- 202, /* (205) expr ::= BITNOT expr */
- 202, /* (206) expr ::= PLUS|MINUS expr */
- 258, /* (207) between_op ::= BETWEEN */
- 258, /* (208) between_op ::= NOT BETWEEN */
- 202, /* (209) expr ::= expr between_op expr AND expr */
- 259, /* (210) in_op ::= IN */
- 259, /* (211) in_op ::= NOT IN */
- 202, /* (212) expr ::= expr in_op LP exprlist RP */
- 202, /* (213) expr ::= LP select RP */
- 202, /* (214) expr ::= expr in_op LP select RP */
- 202, /* (215) expr ::= expr in_op nm dbnm paren_exprlist */
- 202, /* (216) expr ::= EXISTS LP select RP */
- 202, /* (217) expr ::= CASE case_operand case_exprlist case_else END */
- 262, /* (218) case_exprlist ::= case_exprlist WHEN expr THEN expr */
- 262, /* (219) case_exprlist ::= WHEN expr THEN expr */
- 263, /* (220) case_else ::= ELSE expr */
- 263, /* (221) case_else ::= */
- 261, /* (222) case_operand ::= expr */
- 261, /* (223) case_operand ::= */
- 246, /* (224) exprlist ::= */
- 237, /* (225) nexprlist ::= nexprlist COMMA expr */
- 237, /* (226) nexprlist ::= expr */
- 260, /* (227) paren_exprlist ::= */
- 260, /* (228) paren_exprlist ::= LP exprlist RP */
- 175, /* (229) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
- 264, /* (230) uniqueflag ::= UNIQUE */
- 264, /* (231) uniqueflag ::= */
- 206, /* (232) eidlist_opt ::= */
- 206, /* (233) eidlist_opt ::= LP eidlist RP */
- 217, /* (234) eidlist ::= eidlist COMMA nm collate sortorder */
- 217, /* (235) eidlist ::= nm collate sortorder */
- 265, /* (236) collate ::= */
- 265, /* (237) collate ::= COLLATE ID|STRING */
- 175, /* (238) cmd ::= DROP INDEX ifexists fullname */
- 175, /* (239) cmd ::= VACUUM vinto */
- 175, /* (240) cmd ::= VACUUM nm vinto */
- 266, /* (241) vinto ::= INTO expr */
- 266, /* (242) vinto ::= */
- 175, /* (243) cmd ::= PRAGMA nm dbnm */
- 175, /* (244) cmd ::= PRAGMA nm dbnm EQ nmnum */
- 175, /* (245) cmd ::= PRAGMA nm dbnm LP nmnum RP */
- 175, /* (246) cmd ::= PRAGMA nm dbnm EQ minus_num */
- 175, /* (247) cmd ::= PRAGMA nm dbnm LP minus_num RP */
- 196, /* (248) plus_num ::= PLUS INTEGER|FLOAT */
- 197, /* (249) minus_num ::= MINUS INTEGER|FLOAT */
- 175, /* (250) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
- 268, /* (251) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
- 270, /* (252) trigger_time ::= BEFORE|AFTER */
- 270, /* (253) trigger_time ::= INSTEAD OF */
- 270, /* (254) trigger_time ::= */
- 271, /* (255) trigger_event ::= DELETE|INSERT */
- 271, /* (256) trigger_event ::= UPDATE */
- 271, /* (257) trigger_event ::= UPDATE OF idlist */
- 273, /* (258) when_clause ::= */
- 273, /* (259) when_clause ::= WHEN expr */
- 269, /* (260) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
- 269, /* (261) trigger_cmd_list ::= trigger_cmd SEMI */
- 275, /* (262) trnm ::= nm DOT nm */
- 276, /* (263) tridxby ::= INDEXED BY nm */
- 276, /* (264) tridxby ::= NOT INDEXED */
- 274, /* (265) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */
- 274, /* (266) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
- 274, /* (267) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
- 274, /* (268) trigger_cmd ::= scanpt select scanpt */
- 202, /* (269) expr ::= RAISE LP IGNORE RP */
- 202, /* (270) expr ::= RAISE LP raisetype COMMA nm RP */
- 221, /* (271) raisetype ::= ROLLBACK */
- 221, /* (272) raisetype ::= ABORT */
- 221, /* (273) raisetype ::= FAIL */
- 175, /* (274) cmd ::= DROP TRIGGER ifexists fullname */
- 175, /* (275) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
- 175, /* (276) cmd ::= DETACH database_kw_opt expr */
- 278, /* (277) key_opt ::= */
- 278, /* (278) key_opt ::= KEY expr */
- 175, /* (279) cmd ::= ALTER TABLE fullname RENAME TO nm */
- 175, /* (280) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
- 175, /* (281) cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */
- 279, /* (282) add_column_fullname ::= fullname */
- 175, /* (283) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
- 175, /* (284) cmd ::= create_vtab */
- 175, /* (285) cmd ::= create_vtab LP vtabarglist RP */
- 281, /* (286) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
- 283, /* (287) vtabarg ::= */
- 284, /* (288) vtabargtoken ::= ANY */
- 284, /* (289) vtabargtoken ::= lp anylist RP */
- 285, /* (290) lp ::= LP */
- 250, /* (291) with ::= WITH wqlist */
- 250, /* (292) with ::= WITH RECURSIVE wqlist */
- 288, /* (293) wqas ::= AS */
- 288, /* (294) wqas ::= AS MATERIALIZED */
- 288, /* (295) wqas ::= AS NOT MATERIALIZED */
- 287, /* (296) wqitem ::= nm eidlist_opt wqas LP select RP */
- 226, /* (297) wqlist ::= wqitem */
- 226, /* (298) wqlist ::= wqlist COMMA wqitem */
- 171, /* (299) input ::= cmdlist */
- 172, /* (300) cmdlist ::= cmdlist ecmd */
- 172, /* (301) cmdlist ::= ecmd */
- 173, /* (302) ecmd ::= SEMI */
- 173, /* (303) ecmd ::= cmdx SEMI */
- 177, /* (304) trans_opt ::= */
- 177, /* (305) trans_opt ::= TRANSACTION */
- 177, /* (306) trans_opt ::= TRANSACTION nm */
- 179, /* (307) savepoint_opt ::= SAVEPOINT */
- 179, /* (308) savepoint_opt ::= */
- 175, /* (309) cmd ::= create_table create_table_args */
- 188, /* (310) table_option_set ::= table_option */
- 186, /* (311) columnlist ::= columnlist COMMA columnname carglist */
- 186, /* (312) columnlist ::= columnname carglist */
- 178, /* (313) nm ::= ID|INDEXED */
- 178, /* (314) nm ::= STRING */
- 178, /* (315) nm ::= JOIN_KW */
- 193, /* (316) typetoken ::= typename */
- 194, /* (317) typename ::= ID|STRING */
- 195, /* (318) signed ::= plus_num */
- 195, /* (319) signed ::= minus_num */
- 192, /* (320) carglist ::= carglist ccons */
- 192, /* (321) carglist ::= */
- 200, /* (322) ccons ::= NULL onconf */
- 200, /* (323) ccons ::= GENERATED ALWAYS AS generated */
- 200, /* (324) ccons ::= AS generated */
- 187, /* (325) conslist_opt ::= COMMA conslist */
- 213, /* (326) conslist ::= conslist tconscomma tcons */
- 213, /* (327) conslist ::= tcons */
- 214, /* (328) tconscomma ::= */
- 218, /* (329) defer_subclause_opt ::= defer_subclause */
- 220, /* (330) resolvetype ::= raisetype */
- 224, /* (331) selectnowith ::= oneselect */
- 225, /* (332) oneselect ::= values */
- 238, /* (333) sclp ::= selcollist COMMA */
- 239, /* (334) as ::= ID|STRING */
- 256, /* (335) returning ::= */
- 202, /* (336) expr ::= term */
- 257, /* (337) likeop ::= LIKE_KW|MATCH */
- 246, /* (338) exprlist ::= nexprlist */
- 267, /* (339) nmnum ::= plus_num */
- 267, /* (340) nmnum ::= nm */
- 267, /* (341) nmnum ::= ON */
- 267, /* (342) nmnum ::= DELETE */
- 267, /* (343) nmnum ::= DEFAULT */
- 196, /* (344) plus_num ::= INTEGER|FLOAT */
- 272, /* (345) foreach_clause ::= */
- 272, /* (346) foreach_clause ::= FOR EACH ROW */
- 275, /* (347) trnm ::= nm */
- 276, /* (348) tridxby ::= */
- 277, /* (349) database_kw_opt ::= DATABASE */
- 277, /* (350) database_kw_opt ::= */
- 280, /* (351) kwcolumn_opt ::= */
- 280, /* (352) kwcolumn_opt ::= COLUMNKW */
- 282, /* (353) vtabarglist ::= vtabarg */
- 282, /* (354) vtabarglist ::= vtabarglist COMMA vtabarg */
- 283, /* (355) vtabarg ::= vtabarg vtabargtoken */
- 286, /* (356) anylist ::= */
- 286, /* (357) anylist ::= anylist LP anylist RP */
- 286, /* (358) anylist ::= anylist ANY */
- 250, /* (359) with ::= */
+ 175, /* (0) cmdx ::= cmd */
+ 176, /* (1) cmd ::= BEGIN transtype trans_opt */
+ 177, /* (2) transtype ::= */
+ 177, /* (3) transtype ::= DEFERRED */
+ 177, /* (4) transtype ::= IMMEDIATE */
+ 177, /* (5) transtype ::= EXCLUSIVE */
+ 176, /* (6) cmd ::= COMMIT|END trans_opt */
+ 176, /* (7) cmd ::= ROLLBACK trans_opt */
+ 176, /* (8) cmd ::= SAVEPOINT nm */
+ 176, /* (9) cmd ::= RELEASE savepoint_opt nm */
+ 176, /* (10) cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */
+ 181, /* (11) create_table ::= createkw temp TABLE ifnotexists nm dbnm */
+ 183, /* (12) createkw ::= CREATE */
+ 185, /* (13) ifnotexists ::= */
+ 185, /* (14) ifnotexists ::= IF NOT EXISTS */
+ 184, /* (15) temp ::= TEMP */
+ 184, /* (16) temp ::= */
+ 182, /* (17) create_table_args ::= LP columnlist conslist_opt RP table_option_set */
+ 182, /* (18) create_table_args ::= AS select */
+ 189, /* (19) table_option_set ::= */
+ 189, /* (20) table_option_set ::= table_option_set COMMA table_option */
+ 191, /* (21) table_option ::= WITHOUT nm */
+ 191, /* (22) table_option ::= nm */
+ 192, /* (23) columnname ::= nm typetoken */
+ 194, /* (24) typetoken ::= */
+ 194, /* (25) typetoken ::= typename LP signed RP */
+ 194, /* (26) typetoken ::= typename LP signed COMMA signed RP */
+ 195, /* (27) typename ::= typename ID|STRING */
+ 199, /* (28) scanpt ::= */
+ 200, /* (29) scantok ::= */
+ 201, /* (30) ccons ::= CONSTRAINT nm */
+ 201, /* (31) ccons ::= DEFAULT scantok term */
+ 201, /* (32) ccons ::= DEFAULT LP expr RP */
+ 201, /* (33) ccons ::= DEFAULT PLUS scantok term */
+ 201, /* (34) ccons ::= DEFAULT MINUS scantok term */
+ 201, /* (35) ccons ::= DEFAULT scantok ID|INDEXED */
+ 201, /* (36) ccons ::= NOT NULL onconf */
+ 201, /* (37) ccons ::= PRIMARY KEY sortorder onconf autoinc */
+ 201, /* (38) ccons ::= UNIQUE onconf */
+ 201, /* (39) ccons ::= CHECK LP expr RP */
+ 201, /* (40) ccons ::= REFERENCES nm eidlist_opt refargs */
+ 201, /* (41) ccons ::= defer_subclause */
+ 201, /* (42) ccons ::= COLLATE ID|STRING */
+ 210, /* (43) generated ::= LP expr RP */
+ 210, /* (44) generated ::= LP expr RP ID */
+ 206, /* (45) autoinc ::= */
+ 206, /* (46) autoinc ::= AUTOINCR */
+ 208, /* (47) refargs ::= */
+ 208, /* (48) refargs ::= refargs refarg */
+ 211, /* (49) refarg ::= MATCH nm */
+ 211, /* (50) refarg ::= ON INSERT refact */
+ 211, /* (51) refarg ::= ON DELETE refact */
+ 211, /* (52) refarg ::= ON UPDATE refact */
+ 212, /* (53) refact ::= SET NULL */
+ 212, /* (54) refact ::= SET DEFAULT */
+ 212, /* (55) refact ::= CASCADE */
+ 212, /* (56) refact ::= RESTRICT */
+ 212, /* (57) refact ::= NO ACTION */
+ 209, /* (58) defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
+ 209, /* (59) defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
+ 213, /* (60) init_deferred_pred_opt ::= */
+ 213, /* (61) init_deferred_pred_opt ::= INITIALLY DEFERRED */
+ 213, /* (62) init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
+ 188, /* (63) conslist_opt ::= */
+ 215, /* (64) tconscomma ::= COMMA */
+ 216, /* (65) tcons ::= CONSTRAINT nm */
+ 216, /* (66) tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
+ 216, /* (67) tcons ::= UNIQUE LP sortlist RP onconf */
+ 216, /* (68) tcons ::= CHECK LP expr RP onconf */
+ 216, /* (69) tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
+ 219, /* (70) defer_subclause_opt ::= */
+ 204, /* (71) onconf ::= */
+ 204, /* (72) onconf ::= ON CONFLICT resolvetype */
+ 220, /* (73) orconf ::= */
+ 220, /* (74) orconf ::= OR resolvetype */
+ 221, /* (75) resolvetype ::= IGNORE */
+ 221, /* (76) resolvetype ::= REPLACE */
+ 176, /* (77) cmd ::= DROP TABLE ifexists fullname */
+ 223, /* (78) ifexists ::= IF EXISTS */
+ 223, /* (79) ifexists ::= */
+ 176, /* (80) cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
+ 176, /* (81) cmd ::= DROP VIEW ifexists fullname */
+ 176, /* (82) cmd ::= select */
+ 190, /* (83) select ::= WITH wqlist selectnowith */
+ 190, /* (84) select ::= WITH RECURSIVE wqlist selectnowith */
+ 190, /* (85) select ::= selectnowith */
+ 225, /* (86) selectnowith ::= selectnowith multiselect_op oneselect */
+ 228, /* (87) multiselect_op ::= UNION */
+ 228, /* (88) multiselect_op ::= UNION ALL */
+ 228, /* (89) multiselect_op ::= EXCEPT|INTERSECT */
+ 226, /* (90) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
+ 237, /* (91) values ::= VALUES LP nexprlist RP */
+ 237, /* (92) values ::= values COMMA LP nexprlist RP */
+ 229, /* (93) distinct ::= DISTINCT */
+ 229, /* (94) distinct ::= ALL */
+ 229, /* (95) distinct ::= */
+ 239, /* (96) sclp ::= */
+ 230, /* (97) selcollist ::= sclp scanpt expr scanpt as */
+ 230, /* (98) selcollist ::= sclp scanpt STAR */
+ 230, /* (99) selcollist ::= sclp scanpt nm DOT STAR */
+ 240, /* (100) as ::= AS nm */
+ 240, /* (101) as ::= */
+ 231, /* (102) from ::= */
+ 231, /* (103) from ::= FROM seltablist */
+ 242, /* (104) stl_prefix ::= seltablist joinop */
+ 242, /* (105) stl_prefix ::= */
+ 241, /* (106) seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
+ 241, /* (107) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
+ 241, /* (108) seltablist ::= stl_prefix LP select RP as on_opt using_opt */
+ 241, /* (109) seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
+ 186, /* (110) dbnm ::= */
+ 186, /* (111) dbnm ::= DOT nm */
+ 224, /* (112) fullname ::= nm */
+ 224, /* (113) fullname ::= nm DOT nm */
+ 248, /* (114) xfullname ::= nm */
+ 248, /* (115) xfullname ::= nm DOT nm */
+ 248, /* (116) xfullname ::= nm DOT nm AS nm */
+ 248, /* (117) xfullname ::= nm AS nm */
+ 243, /* (118) joinop ::= COMMA|JOIN */
+ 243, /* (119) joinop ::= JOIN_KW JOIN */
+ 243, /* (120) joinop ::= JOIN_KW nm JOIN */
+ 243, /* (121) joinop ::= JOIN_KW nm nm JOIN */
+ 245, /* (122) on_opt ::= ON expr */
+ 245, /* (123) on_opt ::= */
+ 244, /* (124) indexed_opt ::= */
+ 244, /* (125) indexed_opt ::= INDEXED BY nm */
+ 244, /* (126) indexed_opt ::= NOT INDEXED */
+ 246, /* (127) using_opt ::= USING LP idlist RP */
+ 246, /* (128) using_opt ::= */
+ 235, /* (129) orderby_opt ::= */
+ 235, /* (130) orderby_opt ::= ORDER BY sortlist */
+ 217, /* (131) sortlist ::= sortlist COMMA expr sortorder nulls */
+ 217, /* (132) sortlist ::= expr sortorder nulls */
+ 205, /* (133) sortorder ::= ASC */
+ 205, /* (134) sortorder ::= DESC */
+ 205, /* (135) sortorder ::= */
+ 250, /* (136) nulls ::= NULLS FIRST */
+ 250, /* (137) nulls ::= NULLS LAST */
+ 250, /* (138) nulls ::= */
+ 233, /* (139) groupby_opt ::= */
+ 233, /* (140) groupby_opt ::= GROUP BY nexprlist */
+ 234, /* (141) having_opt ::= */
+ 234, /* (142) having_opt ::= HAVING expr */
+ 236, /* (143) limit_opt ::= */
+ 236, /* (144) limit_opt ::= LIMIT expr */
+ 236, /* (145) limit_opt ::= LIMIT expr OFFSET expr */
+ 236, /* (146) limit_opt ::= LIMIT expr COMMA expr */
+ 176, /* (147) cmd ::= with DELETE FROM xfullname indexed_opt where_opt_ret */
+ 232, /* (148) where_opt ::= */
+ 232, /* (149) where_opt ::= WHERE expr */
+ 252, /* (150) where_opt_ret ::= */
+ 252, /* (151) where_opt_ret ::= WHERE expr */
+ 252, /* (152) where_opt_ret ::= RETURNING selcollist */
+ 252, /* (153) where_opt_ret ::= WHERE expr RETURNING selcollist */
+ 176, /* (154) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist from where_opt_ret */
+ 253, /* (155) setlist ::= setlist COMMA nm EQ expr */
+ 253, /* (156) setlist ::= setlist COMMA LP idlist RP EQ expr */
+ 253, /* (157) setlist ::= nm EQ expr */
+ 253, /* (158) setlist ::= LP idlist RP EQ expr */
+ 176, /* (159) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
+ 176, /* (160) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES returning */
+ 256, /* (161) upsert ::= */
+ 256, /* (162) upsert ::= RETURNING selcollist */
+ 256, /* (163) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt upsert */
+ 256, /* (164) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING upsert */
+ 256, /* (165) upsert ::= ON CONFLICT DO NOTHING returning */
+ 256, /* (166) upsert ::= ON CONFLICT DO UPDATE SET setlist where_opt returning */
+ 257, /* (167) returning ::= RETURNING selcollist */
+ 254, /* (168) insert_cmd ::= INSERT orconf */
+ 254, /* (169) insert_cmd ::= REPLACE */
+ 255, /* (170) idlist_opt ::= */
+ 255, /* (171) idlist_opt ::= LP idlist RP */
+ 249, /* (172) idlist ::= idlist COMMA nm */
+ 249, /* (173) idlist ::= nm */
+ 203, /* (174) expr ::= LP expr RP */
+ 203, /* (175) expr ::= ID|INDEXED */
+ 203, /* (176) expr ::= JOIN_KW */
+ 203, /* (177) expr ::= nm DOT nm */
+ 203, /* (178) expr ::= nm DOT nm DOT nm */
+ 202, /* (179) term ::= NULL|FLOAT|BLOB */
+ 202, /* (180) term ::= STRING */
+ 202, /* (181) term ::= INTEGER */
+ 203, /* (182) expr ::= VARIABLE */
+ 203, /* (183) expr ::= expr COLLATE ID|STRING */
+ 203, /* (184) expr ::= CAST LP expr AS typetoken RP */
+ 203, /* (185) expr ::= ID|INDEXED LP distinct exprlist RP */
+ 203, /* (186) expr ::= ID|INDEXED LP STAR RP */
+ 202, /* (187) term ::= CTIME_KW */
+ 203, /* (188) expr ::= LP nexprlist COMMA expr RP */
+ 203, /* (189) expr ::= expr AND expr */
+ 203, /* (190) expr ::= expr OR expr */
+ 203, /* (191) expr ::= expr LT|GT|GE|LE expr */
+ 203, /* (192) expr ::= expr EQ|NE expr */
+ 203, /* (193) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */
+ 203, /* (194) expr ::= expr PLUS|MINUS expr */
+ 203, /* (195) expr ::= expr STAR|SLASH|REM expr */
+ 203, /* (196) expr ::= expr CONCAT expr */
+ 258, /* (197) likeop ::= NOT LIKE_KW|MATCH */
+ 203, /* (198) expr ::= expr likeop expr */
+ 203, /* (199) expr ::= expr likeop expr ESCAPE expr */
+ 203, /* (200) expr ::= expr ISNULL|NOTNULL */
+ 203, /* (201) expr ::= expr NOT NULL */
+ 203, /* (202) expr ::= expr IS expr */
+ 203, /* (203) expr ::= expr IS NOT expr */
+ 203, /* (204) expr ::= NOT expr */
+ 203, /* (205) expr ::= BITNOT expr */
+ 203, /* (206) expr ::= PLUS|MINUS expr */
+ 203, /* (207) expr ::= expr PTR expr */
+ 259, /* (208) between_op ::= BETWEEN */
+ 259, /* (209) between_op ::= NOT BETWEEN */
+ 203, /* (210) expr ::= expr between_op expr AND expr */
+ 260, /* (211) in_op ::= IN */
+ 260, /* (212) in_op ::= NOT IN */
+ 203, /* (213) expr ::= expr in_op LP exprlist RP */
+ 203, /* (214) expr ::= LP select RP */
+ 203, /* (215) expr ::= expr in_op LP select RP */
+ 203, /* (216) expr ::= expr in_op nm dbnm paren_exprlist */
+ 203, /* (217) expr ::= EXISTS LP select RP */
+ 203, /* (218) expr ::= CASE case_operand case_exprlist case_else END */
+ 263, /* (219) case_exprlist ::= case_exprlist WHEN expr THEN expr */
+ 263, /* (220) case_exprlist ::= WHEN expr THEN expr */
+ 264, /* (221) case_else ::= ELSE expr */
+ 264, /* (222) case_else ::= */
+ 262, /* (223) case_operand ::= expr */
+ 262, /* (224) case_operand ::= */
+ 247, /* (225) exprlist ::= */
+ 238, /* (226) nexprlist ::= nexprlist COMMA expr */
+ 238, /* (227) nexprlist ::= expr */
+ 261, /* (228) paren_exprlist ::= */
+ 261, /* (229) paren_exprlist ::= LP exprlist RP */
+ 176, /* (230) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
+ 265, /* (231) uniqueflag ::= UNIQUE */
+ 265, /* (232) uniqueflag ::= */
+ 207, /* (233) eidlist_opt ::= */
+ 207, /* (234) eidlist_opt ::= LP eidlist RP */
+ 218, /* (235) eidlist ::= eidlist COMMA nm collate sortorder */
+ 218, /* (236) eidlist ::= nm collate sortorder */
+ 266, /* (237) collate ::= */
+ 266, /* (238) collate ::= COLLATE ID|STRING */
+ 176, /* (239) cmd ::= DROP INDEX ifexists fullname */
+ 176, /* (240) cmd ::= VACUUM vinto */
+ 176, /* (241) cmd ::= VACUUM nm vinto */
+ 267, /* (242) vinto ::= INTO expr */
+ 267, /* (243) vinto ::= */
+ 176, /* (244) cmd ::= PRAGMA nm dbnm */
+ 176, /* (245) cmd ::= PRAGMA nm dbnm EQ nmnum */
+ 176, /* (246) cmd ::= PRAGMA nm dbnm LP nmnum RP */
+ 176, /* (247) cmd ::= PRAGMA nm dbnm EQ minus_num */
+ 176, /* (248) cmd ::= PRAGMA nm dbnm LP minus_num RP */
+ 197, /* (249) plus_num ::= PLUS INTEGER|FLOAT */
+ 198, /* (250) minus_num ::= MINUS INTEGER|FLOAT */
+ 176, /* (251) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
+ 269, /* (252) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
+ 271, /* (253) trigger_time ::= BEFORE|AFTER */
+ 271, /* (254) trigger_time ::= INSTEAD OF */
+ 271, /* (255) trigger_time ::= */
+ 272, /* (256) trigger_event ::= DELETE|INSERT */
+ 272, /* (257) trigger_event ::= UPDATE */
+ 272, /* (258) trigger_event ::= UPDATE OF idlist */
+ 274, /* (259) when_clause ::= */
+ 274, /* (260) when_clause ::= WHEN expr */
+ 270, /* (261) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
+ 270, /* (262) trigger_cmd_list ::= trigger_cmd SEMI */
+ 276, /* (263) trnm ::= nm DOT nm */
+ 277, /* (264) tridxby ::= INDEXED BY nm */
+ 277, /* (265) tridxby ::= NOT INDEXED */
+ 275, /* (266) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */
+ 275, /* (267) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
+ 275, /* (268) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
+ 275, /* (269) trigger_cmd ::= scanpt select scanpt */
+ 203, /* (270) expr ::= RAISE LP IGNORE RP */
+ 203, /* (271) expr ::= RAISE LP raisetype COMMA nm RP */
+ 222, /* (272) raisetype ::= ROLLBACK */
+ 222, /* (273) raisetype ::= ABORT */
+ 222, /* (274) raisetype ::= FAIL */
+ 176, /* (275) cmd ::= DROP TRIGGER ifexists fullname */
+ 176, /* (276) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
+ 176, /* (277) cmd ::= DETACH database_kw_opt expr */
+ 279, /* (278) key_opt ::= */
+ 279, /* (279) key_opt ::= KEY expr */
+ 176, /* (280) cmd ::= ALTER TABLE fullname RENAME TO nm */
+ 176, /* (281) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
+ 176, /* (282) cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */
+ 280, /* (283) add_column_fullname ::= fullname */
+ 176, /* (284) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
+ 176, /* (285) cmd ::= create_vtab */
+ 176, /* (286) cmd ::= create_vtab LP vtabarglist RP */
+ 282, /* (287) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
+ 284, /* (288) vtabarg ::= */
+ 285, /* (289) vtabargtoken ::= ANY */
+ 285, /* (290) vtabargtoken ::= lp anylist RP */
+ 286, /* (291) lp ::= LP */
+ 251, /* (292) with ::= WITH wqlist */
+ 251, /* (293) with ::= WITH RECURSIVE wqlist */
+ 289, /* (294) wqas ::= AS */
+ 289, /* (295) wqas ::= AS MATERIALIZED */
+ 289, /* (296) wqas ::= AS NOT MATERIALIZED */
+ 288, /* (297) wqitem ::= nm eidlist_opt wqas LP select RP */
+ 227, /* (298) wqlist ::= wqitem */
+ 227, /* (299) wqlist ::= wqlist COMMA wqitem */
+ 172, /* (300) input ::= cmdlist */
+ 173, /* (301) cmdlist ::= cmdlist ecmd */
+ 173, /* (302) cmdlist ::= ecmd */
+ 174, /* (303) ecmd ::= SEMI */
+ 174, /* (304) ecmd ::= cmdx SEMI */
+ 178, /* (305) trans_opt ::= */
+ 178, /* (306) trans_opt ::= TRANSACTION */
+ 178, /* (307) trans_opt ::= TRANSACTION nm */
+ 180, /* (308) savepoint_opt ::= SAVEPOINT */
+ 180, /* (309) savepoint_opt ::= */
+ 176, /* (310) cmd ::= create_table create_table_args */
+ 189, /* (311) table_option_set ::= table_option */
+ 187, /* (312) columnlist ::= columnlist COMMA columnname carglist */
+ 187, /* (313) columnlist ::= columnname carglist */
+ 179, /* (314) nm ::= ID|INDEXED */
+ 179, /* (315) nm ::= STRING */
+ 179, /* (316) nm ::= JOIN_KW */
+ 194, /* (317) typetoken ::= typename */
+ 195, /* (318) typename ::= ID|STRING */
+ 196, /* (319) signed ::= plus_num */
+ 196, /* (320) signed ::= minus_num */
+ 193, /* (321) carglist ::= carglist ccons */
+ 193, /* (322) carglist ::= */
+ 201, /* (323) ccons ::= NULL onconf */
+ 201, /* (324) ccons ::= GENERATED ALWAYS AS generated */
+ 201, /* (325) ccons ::= AS generated */
+ 188, /* (326) conslist_opt ::= COMMA conslist */
+ 214, /* (327) conslist ::= conslist tconscomma tcons */
+ 214, /* (328) conslist ::= tcons */
+ 215, /* (329) tconscomma ::= */
+ 219, /* (330) defer_subclause_opt ::= defer_subclause */
+ 221, /* (331) resolvetype ::= raisetype */
+ 225, /* (332) selectnowith ::= oneselect */
+ 226, /* (333) oneselect ::= values */
+ 239, /* (334) sclp ::= selcollist COMMA */
+ 240, /* (335) as ::= ID|STRING */
+ 257, /* (336) returning ::= */
+ 203, /* (337) expr ::= term */
+ 258, /* (338) likeop ::= LIKE_KW|MATCH */
+ 247, /* (339) exprlist ::= nexprlist */
+ 268, /* (340) nmnum ::= plus_num */
+ 268, /* (341) nmnum ::= nm */
+ 268, /* (342) nmnum ::= ON */
+ 268, /* (343) nmnum ::= DELETE */
+ 268, /* (344) nmnum ::= DEFAULT */
+ 197, /* (345) plus_num ::= INTEGER|FLOAT */
+ 273, /* (346) foreach_clause ::= */
+ 273, /* (347) foreach_clause ::= FOR EACH ROW */
+ 276, /* (348) trnm ::= nm */
+ 277, /* (349) tridxby ::= */
+ 278, /* (350) database_kw_opt ::= DATABASE */
+ 278, /* (351) database_kw_opt ::= */
+ 281, /* (352) kwcolumn_opt ::= */
+ 281, /* (353) kwcolumn_opt ::= COLUMNKW */
+ 283, /* (354) vtabarglist ::= vtabarg */
+ 283, /* (355) vtabarglist ::= vtabarglist COMMA vtabarg */
+ 284, /* (356) vtabarg ::= vtabarg vtabargtoken */
+ 287, /* (357) anylist ::= */
+ 287, /* (358) anylist ::= anylist LP anylist RP */
+ 287, /* (359) anylist ::= anylist ANY */
+ 251, /* (360) with ::= */
};
/* For rule J, yyRuleInfoNRhs[J] contains the negative of the number
@@ -162507,159 +164374,160 @@ static const signed char yyRuleInfoNRhs[] = {
-2, /* (204) expr ::= NOT expr */
-2, /* (205) expr ::= BITNOT expr */
-2, /* (206) expr ::= PLUS|MINUS expr */
- -1, /* (207) between_op ::= BETWEEN */
- -2, /* (208) between_op ::= NOT BETWEEN */
- -5, /* (209) expr ::= expr between_op expr AND expr */
- -1, /* (210) in_op ::= IN */
- -2, /* (211) in_op ::= NOT IN */
- -5, /* (212) expr ::= expr in_op LP exprlist RP */
- -3, /* (213) expr ::= LP select RP */
- -5, /* (214) expr ::= expr in_op LP select RP */
- -5, /* (215) expr ::= expr in_op nm dbnm paren_exprlist */
- -4, /* (216) expr ::= EXISTS LP select RP */
- -5, /* (217) expr ::= CASE case_operand case_exprlist case_else END */
- -5, /* (218) case_exprlist ::= case_exprlist WHEN expr THEN expr */
- -4, /* (219) case_exprlist ::= WHEN expr THEN expr */
- -2, /* (220) case_else ::= ELSE expr */
- 0, /* (221) case_else ::= */
- -1, /* (222) case_operand ::= expr */
- 0, /* (223) case_operand ::= */
- 0, /* (224) exprlist ::= */
- -3, /* (225) nexprlist ::= nexprlist COMMA expr */
- -1, /* (226) nexprlist ::= expr */
- 0, /* (227) paren_exprlist ::= */
- -3, /* (228) paren_exprlist ::= LP exprlist RP */
- -12, /* (229) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
- -1, /* (230) uniqueflag ::= UNIQUE */
- 0, /* (231) uniqueflag ::= */
- 0, /* (232) eidlist_opt ::= */
- -3, /* (233) eidlist_opt ::= LP eidlist RP */
- -5, /* (234) eidlist ::= eidlist COMMA nm collate sortorder */
- -3, /* (235) eidlist ::= nm collate sortorder */
- 0, /* (236) collate ::= */
- -2, /* (237) collate ::= COLLATE ID|STRING */
- -4, /* (238) cmd ::= DROP INDEX ifexists fullname */
- -2, /* (239) cmd ::= VACUUM vinto */
- -3, /* (240) cmd ::= VACUUM nm vinto */
- -2, /* (241) vinto ::= INTO expr */
- 0, /* (242) vinto ::= */
- -3, /* (243) cmd ::= PRAGMA nm dbnm */
- -5, /* (244) cmd ::= PRAGMA nm dbnm EQ nmnum */
- -6, /* (245) cmd ::= PRAGMA nm dbnm LP nmnum RP */
- -5, /* (246) cmd ::= PRAGMA nm dbnm EQ minus_num */
- -6, /* (247) cmd ::= PRAGMA nm dbnm LP minus_num RP */
- -2, /* (248) plus_num ::= PLUS INTEGER|FLOAT */
- -2, /* (249) minus_num ::= MINUS INTEGER|FLOAT */
- -5, /* (250) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
- -11, /* (251) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
- -1, /* (252) trigger_time ::= BEFORE|AFTER */
- -2, /* (253) trigger_time ::= INSTEAD OF */
- 0, /* (254) trigger_time ::= */
- -1, /* (255) trigger_event ::= DELETE|INSERT */
- -1, /* (256) trigger_event ::= UPDATE */
- -3, /* (257) trigger_event ::= UPDATE OF idlist */
- 0, /* (258) when_clause ::= */
- -2, /* (259) when_clause ::= WHEN expr */
- -3, /* (260) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
- -2, /* (261) trigger_cmd_list ::= trigger_cmd SEMI */
- -3, /* (262) trnm ::= nm DOT nm */
- -3, /* (263) tridxby ::= INDEXED BY nm */
- -2, /* (264) tridxby ::= NOT INDEXED */
- -9, /* (265) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */
- -8, /* (266) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
- -6, /* (267) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
- -3, /* (268) trigger_cmd ::= scanpt select scanpt */
- -4, /* (269) expr ::= RAISE LP IGNORE RP */
- -6, /* (270) expr ::= RAISE LP raisetype COMMA nm RP */
- -1, /* (271) raisetype ::= ROLLBACK */
- -1, /* (272) raisetype ::= ABORT */
- -1, /* (273) raisetype ::= FAIL */
- -4, /* (274) cmd ::= DROP TRIGGER ifexists fullname */
- -6, /* (275) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
- -3, /* (276) cmd ::= DETACH database_kw_opt expr */
- 0, /* (277) key_opt ::= */
- -2, /* (278) key_opt ::= KEY expr */
- -6, /* (279) cmd ::= ALTER TABLE fullname RENAME TO nm */
- -7, /* (280) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
- -6, /* (281) cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */
- -1, /* (282) add_column_fullname ::= fullname */
- -8, /* (283) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
- -1, /* (284) cmd ::= create_vtab */
- -4, /* (285) cmd ::= create_vtab LP vtabarglist RP */
- -8, /* (286) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
- 0, /* (287) vtabarg ::= */
- -1, /* (288) vtabargtoken ::= ANY */
- -3, /* (289) vtabargtoken ::= lp anylist RP */
- -1, /* (290) lp ::= LP */
- -2, /* (291) with ::= WITH wqlist */
- -3, /* (292) with ::= WITH RECURSIVE wqlist */
- -1, /* (293) wqas ::= AS */
- -2, /* (294) wqas ::= AS MATERIALIZED */
- -3, /* (295) wqas ::= AS NOT MATERIALIZED */
- -6, /* (296) wqitem ::= nm eidlist_opt wqas LP select RP */
- -1, /* (297) wqlist ::= wqitem */
- -3, /* (298) wqlist ::= wqlist COMMA wqitem */
- -1, /* (299) input ::= cmdlist */
- -2, /* (300) cmdlist ::= cmdlist ecmd */
- -1, /* (301) cmdlist ::= ecmd */
- -1, /* (302) ecmd ::= SEMI */
- -2, /* (303) ecmd ::= cmdx SEMI */
- 0, /* (304) trans_opt ::= */
- -1, /* (305) trans_opt ::= TRANSACTION */
- -2, /* (306) trans_opt ::= TRANSACTION nm */
- -1, /* (307) savepoint_opt ::= SAVEPOINT */
- 0, /* (308) savepoint_opt ::= */
- -2, /* (309) cmd ::= create_table create_table_args */
- -1, /* (310) table_option_set ::= table_option */
- -4, /* (311) columnlist ::= columnlist COMMA columnname carglist */
- -2, /* (312) columnlist ::= columnname carglist */
- -1, /* (313) nm ::= ID|INDEXED */
- -1, /* (314) nm ::= STRING */
- -1, /* (315) nm ::= JOIN_KW */
- -1, /* (316) typetoken ::= typename */
- -1, /* (317) typename ::= ID|STRING */
- -1, /* (318) signed ::= plus_num */
- -1, /* (319) signed ::= minus_num */
- -2, /* (320) carglist ::= carglist ccons */
- 0, /* (321) carglist ::= */
- -2, /* (322) ccons ::= NULL onconf */
- -4, /* (323) ccons ::= GENERATED ALWAYS AS generated */
- -2, /* (324) ccons ::= AS generated */
- -2, /* (325) conslist_opt ::= COMMA conslist */
- -3, /* (326) conslist ::= conslist tconscomma tcons */
- -1, /* (327) conslist ::= tcons */
- 0, /* (328) tconscomma ::= */
- -1, /* (329) defer_subclause_opt ::= defer_subclause */
- -1, /* (330) resolvetype ::= raisetype */
- -1, /* (331) selectnowith ::= oneselect */
- -1, /* (332) oneselect ::= values */
- -2, /* (333) sclp ::= selcollist COMMA */
- -1, /* (334) as ::= ID|STRING */
- 0, /* (335) returning ::= */
- -1, /* (336) expr ::= term */
- -1, /* (337) likeop ::= LIKE_KW|MATCH */
- -1, /* (338) exprlist ::= nexprlist */
- -1, /* (339) nmnum ::= plus_num */
- -1, /* (340) nmnum ::= nm */
- -1, /* (341) nmnum ::= ON */
- -1, /* (342) nmnum ::= DELETE */
- -1, /* (343) nmnum ::= DEFAULT */
- -1, /* (344) plus_num ::= INTEGER|FLOAT */
- 0, /* (345) foreach_clause ::= */
- -3, /* (346) foreach_clause ::= FOR EACH ROW */
- -1, /* (347) trnm ::= nm */
- 0, /* (348) tridxby ::= */
- -1, /* (349) database_kw_opt ::= DATABASE */
- 0, /* (350) database_kw_opt ::= */
- 0, /* (351) kwcolumn_opt ::= */
- -1, /* (352) kwcolumn_opt ::= COLUMNKW */
- -1, /* (353) vtabarglist ::= vtabarg */
- -3, /* (354) vtabarglist ::= vtabarglist COMMA vtabarg */
- -2, /* (355) vtabarg ::= vtabarg vtabargtoken */
- 0, /* (356) anylist ::= */
- -4, /* (357) anylist ::= anylist LP anylist RP */
- -2, /* (358) anylist ::= anylist ANY */
- 0, /* (359) with ::= */
+ -3, /* (207) expr ::= expr PTR expr */
+ -1, /* (208) between_op ::= BETWEEN */
+ -2, /* (209) between_op ::= NOT BETWEEN */
+ -5, /* (210) expr ::= expr between_op expr AND expr */
+ -1, /* (211) in_op ::= IN */
+ -2, /* (212) in_op ::= NOT IN */
+ -5, /* (213) expr ::= expr in_op LP exprlist RP */
+ -3, /* (214) expr ::= LP select RP */
+ -5, /* (215) expr ::= expr in_op LP select RP */
+ -5, /* (216) expr ::= expr in_op nm dbnm paren_exprlist */
+ -4, /* (217) expr ::= EXISTS LP select RP */
+ -5, /* (218) expr ::= CASE case_operand case_exprlist case_else END */
+ -5, /* (219) case_exprlist ::= case_exprlist WHEN expr THEN expr */
+ -4, /* (220) case_exprlist ::= WHEN expr THEN expr */
+ -2, /* (221) case_else ::= ELSE expr */
+ 0, /* (222) case_else ::= */
+ -1, /* (223) case_operand ::= expr */
+ 0, /* (224) case_operand ::= */
+ 0, /* (225) exprlist ::= */
+ -3, /* (226) nexprlist ::= nexprlist COMMA expr */
+ -1, /* (227) nexprlist ::= expr */
+ 0, /* (228) paren_exprlist ::= */
+ -3, /* (229) paren_exprlist ::= LP exprlist RP */
+ -12, /* (230) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
+ -1, /* (231) uniqueflag ::= UNIQUE */
+ 0, /* (232) uniqueflag ::= */
+ 0, /* (233) eidlist_opt ::= */
+ -3, /* (234) eidlist_opt ::= LP eidlist RP */
+ -5, /* (235) eidlist ::= eidlist COMMA nm collate sortorder */
+ -3, /* (236) eidlist ::= nm collate sortorder */
+ 0, /* (237) collate ::= */
+ -2, /* (238) collate ::= COLLATE ID|STRING */
+ -4, /* (239) cmd ::= DROP INDEX ifexists fullname */
+ -2, /* (240) cmd ::= VACUUM vinto */
+ -3, /* (241) cmd ::= VACUUM nm vinto */
+ -2, /* (242) vinto ::= INTO expr */
+ 0, /* (243) vinto ::= */
+ -3, /* (244) cmd ::= PRAGMA nm dbnm */
+ -5, /* (245) cmd ::= PRAGMA nm dbnm EQ nmnum */
+ -6, /* (246) cmd ::= PRAGMA nm dbnm LP nmnum RP */
+ -5, /* (247) cmd ::= PRAGMA nm dbnm EQ minus_num */
+ -6, /* (248) cmd ::= PRAGMA nm dbnm LP minus_num RP */
+ -2, /* (249) plus_num ::= PLUS INTEGER|FLOAT */
+ -2, /* (250) minus_num ::= MINUS INTEGER|FLOAT */
+ -5, /* (251) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
+ -11, /* (252) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
+ -1, /* (253) trigger_time ::= BEFORE|AFTER */
+ -2, /* (254) trigger_time ::= INSTEAD OF */
+ 0, /* (255) trigger_time ::= */
+ -1, /* (256) trigger_event ::= DELETE|INSERT */
+ -1, /* (257) trigger_event ::= UPDATE */
+ -3, /* (258) trigger_event ::= UPDATE OF idlist */
+ 0, /* (259) when_clause ::= */
+ -2, /* (260) when_clause ::= WHEN expr */
+ -3, /* (261) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
+ -2, /* (262) trigger_cmd_list ::= trigger_cmd SEMI */
+ -3, /* (263) trnm ::= nm DOT nm */
+ -3, /* (264) tridxby ::= INDEXED BY nm */
+ -2, /* (265) tridxby ::= NOT INDEXED */
+ -9, /* (266) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */
+ -8, /* (267) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
+ -6, /* (268) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
+ -3, /* (269) trigger_cmd ::= scanpt select scanpt */
+ -4, /* (270) expr ::= RAISE LP IGNORE RP */
+ -6, /* (271) expr ::= RAISE LP raisetype COMMA nm RP */
+ -1, /* (272) raisetype ::= ROLLBACK */
+ -1, /* (273) raisetype ::= ABORT */
+ -1, /* (274) raisetype ::= FAIL */
+ -4, /* (275) cmd ::= DROP TRIGGER ifexists fullname */
+ -6, /* (276) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
+ -3, /* (277) cmd ::= DETACH database_kw_opt expr */
+ 0, /* (278) key_opt ::= */
+ -2, /* (279) key_opt ::= KEY expr */
+ -6, /* (280) cmd ::= ALTER TABLE fullname RENAME TO nm */
+ -7, /* (281) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
+ -6, /* (282) cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */
+ -1, /* (283) add_column_fullname ::= fullname */
+ -8, /* (284) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
+ -1, /* (285) cmd ::= create_vtab */
+ -4, /* (286) cmd ::= create_vtab LP vtabarglist RP */
+ -8, /* (287) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
+ 0, /* (288) vtabarg ::= */
+ -1, /* (289) vtabargtoken ::= ANY */
+ -3, /* (290) vtabargtoken ::= lp anylist RP */
+ -1, /* (291) lp ::= LP */
+ -2, /* (292) with ::= WITH wqlist */
+ -3, /* (293) with ::= WITH RECURSIVE wqlist */
+ -1, /* (294) wqas ::= AS */
+ -2, /* (295) wqas ::= AS MATERIALIZED */
+ -3, /* (296) wqas ::= AS NOT MATERIALIZED */
+ -6, /* (297) wqitem ::= nm eidlist_opt wqas LP select RP */
+ -1, /* (298) wqlist ::= wqitem */
+ -3, /* (299) wqlist ::= wqlist COMMA wqitem */
+ -1, /* (300) input ::= cmdlist */
+ -2, /* (301) cmdlist ::= cmdlist ecmd */
+ -1, /* (302) cmdlist ::= ecmd */
+ -1, /* (303) ecmd ::= SEMI */
+ -2, /* (304) ecmd ::= cmdx SEMI */
+ 0, /* (305) trans_opt ::= */
+ -1, /* (306) trans_opt ::= TRANSACTION */
+ -2, /* (307) trans_opt ::= TRANSACTION nm */
+ -1, /* (308) savepoint_opt ::= SAVEPOINT */
+ 0, /* (309) savepoint_opt ::= */
+ -2, /* (310) cmd ::= create_table create_table_args */
+ -1, /* (311) table_option_set ::= table_option */
+ -4, /* (312) columnlist ::= columnlist COMMA columnname carglist */
+ -2, /* (313) columnlist ::= columnname carglist */
+ -1, /* (314) nm ::= ID|INDEXED */
+ -1, /* (315) nm ::= STRING */
+ -1, /* (316) nm ::= JOIN_KW */
+ -1, /* (317) typetoken ::= typename */
+ -1, /* (318) typename ::= ID|STRING */
+ -1, /* (319) signed ::= plus_num */
+ -1, /* (320) signed ::= minus_num */
+ -2, /* (321) carglist ::= carglist ccons */
+ 0, /* (322) carglist ::= */
+ -2, /* (323) ccons ::= NULL onconf */
+ -4, /* (324) ccons ::= GENERATED ALWAYS AS generated */
+ -2, /* (325) ccons ::= AS generated */
+ -2, /* (326) conslist_opt ::= COMMA conslist */
+ -3, /* (327) conslist ::= conslist tconscomma tcons */
+ -1, /* (328) conslist ::= tcons */
+ 0, /* (329) tconscomma ::= */
+ -1, /* (330) defer_subclause_opt ::= defer_subclause */
+ -1, /* (331) resolvetype ::= raisetype */
+ -1, /* (332) selectnowith ::= oneselect */
+ -1, /* (333) oneselect ::= values */
+ -2, /* (334) sclp ::= selcollist COMMA */
+ -1, /* (335) as ::= ID|STRING */
+ 0, /* (336) returning ::= */
+ -1, /* (337) expr ::= term */
+ -1, /* (338) likeop ::= LIKE_KW|MATCH */
+ -1, /* (339) exprlist ::= nexprlist */
+ -1, /* (340) nmnum ::= plus_num */
+ -1, /* (341) nmnum ::= nm */
+ -1, /* (342) nmnum ::= ON */
+ -1, /* (343) nmnum ::= DELETE */
+ -1, /* (344) nmnum ::= DEFAULT */
+ -1, /* (345) plus_num ::= INTEGER|FLOAT */
+ 0, /* (346) foreach_clause ::= */
+ -3, /* (347) foreach_clause ::= FOR EACH ROW */
+ -1, /* (348) trnm ::= nm */
+ 0, /* (349) tridxby ::= */
+ -1, /* (350) database_kw_opt ::= DATABASE */
+ 0, /* (351) database_kw_opt ::= */
+ 0, /* (352) kwcolumn_opt ::= */
+ -1, /* (353) kwcolumn_opt ::= COLUMNKW */
+ -1, /* (354) vtabarglist ::= vtabarg */
+ -3, /* (355) vtabarglist ::= vtabarglist COMMA vtabarg */
+ -2, /* (356) vtabarg ::= vtabarg vtabargtoken */
+ 0, /* (357) anylist ::= */
+ -4, /* (358) anylist ::= anylist LP anylist RP */
+ -2, /* (359) anylist ::= anylist ANY */
+ 0, /* (360) with ::= */
};
static void yy_accept(yyParser*); /* Forward Declaration */
@@ -162705,15 +164573,15 @@ static YYACTIONTYPE yy_reduce(
{ sqlite3FinishCoding(pParse); }
break;
case 1: /* cmd ::= BEGIN transtype trans_opt */
-{sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy332);}
+{sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy452);}
break;
case 2: /* transtype ::= */
-{yymsp[1].minor.yy332 = TK_DEFERRED;}
+{yymsp[1].minor.yy452 = TK_DEFERRED;}
break;
case 3: /* transtype ::= DEFERRED */
case 4: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==4);
case 5: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==5);
-{yymsp[0].minor.yy332 = yymsp[0].major; /*A-overwrites-X*/}
+{yymsp[0].minor.yy452 = yymsp[0].major; /*A-overwrites-X*/}
break;
case 6: /* cmd ::= COMMIT|END trans_opt */
case 7: /* cmd ::= ROLLBACK trans_opt */ yytestcase(yyruleno==7);
@@ -162736,7 +164604,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.yy332,0,0,yymsp[-2].minor.yy332);
+ sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy452,0,0,yymsp[-2].minor.yy452);
}
break;
case 12: /* createkw ::= CREATE */
@@ -162749,39 +164617,39 @@ static YYACTIONTYPE yy_reduce(
case 70: /* defer_subclause_opt ::= */ yytestcase(yyruleno==70);
case 79: /* ifexists ::= */ yytestcase(yyruleno==79);
case 95: /* distinct ::= */ yytestcase(yyruleno==95);
- case 236: /* collate ::= */ yytestcase(yyruleno==236);
-{yymsp[1].minor.yy332 = 0;}
+ case 237: /* collate ::= */ yytestcase(yyruleno==237);
+{yymsp[1].minor.yy452 = 0;}
break;
case 14: /* ifnotexists ::= IF NOT EXISTS */
-{yymsp[-2].minor.yy332 = 1;}
+{yymsp[-2].minor.yy452 = 1;}
break;
case 15: /* temp ::= TEMP */
-{yymsp[0].minor.yy332 = pParse->db->init.busy==0;}
+{yymsp[0].minor.yy452 = pParse->db->init.busy==0;}
break;
case 17: /* create_table_args ::= LP columnlist conslist_opt RP table_option_set */
{
- sqlite3EndTable(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,yymsp[0].minor.yy213,0);
+ sqlite3EndTable(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,yymsp[0].minor.yy227,0);
}
break;
case 18: /* create_table_args ::= AS select */
{
- sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy433);
- sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy433);
+ sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy279);
+ sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy279);
}
break;
case 19: /* table_option_set ::= */
-{yymsp[1].minor.yy213 = 0;}
+{yymsp[1].minor.yy227 = 0;}
break;
case 20: /* table_option_set ::= table_option_set COMMA table_option */
-{yylhsminor.yy213 = yymsp[-2].minor.yy213|yymsp[0].minor.yy213;}
- yymsp[-2].minor.yy213 = yylhsminor.yy213;
+{yylhsminor.yy227 = yymsp[-2].minor.yy227|yymsp[0].minor.yy227;}
+ yymsp[-2].minor.yy227 = yylhsminor.yy227;
break;
case 21: /* table_option ::= WITHOUT nm */
{
if( yymsp[0].minor.yy0.n==5 && sqlite3_strnicmp(yymsp[0].minor.yy0.z,"rowid",5)==0 ){
- yymsp[-1].minor.yy213 = TF_WithoutRowid | TF_NoVisibleRowid;
+ yymsp[-1].minor.yy227 = TF_WithoutRowid | TF_NoVisibleRowid;
}else{
- yymsp[-1].minor.yy213 = 0;
+ yymsp[-1].minor.yy227 = 0;
sqlite3ErrorMsg(pParse, "unknown table option: %.*s", yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.z);
}
}
@@ -162789,13 +164657,13 @@ static YYACTIONTYPE yy_reduce(
case 22: /* table_option ::= nm */
{
if( yymsp[0].minor.yy0.n==6 && sqlite3_strnicmp(yymsp[0].minor.yy0.z,"strict",6)==0 ){
- yylhsminor.yy213 = TF_Strict;
+ yylhsminor.yy227 = TF_Strict;
}else{
- yylhsminor.yy213 = 0;
+ yylhsminor.yy227 = 0;
sqlite3ErrorMsg(pParse, "unknown table option: %.*s", yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.z);
}
}
- yymsp[0].minor.yy213 = yylhsminor.yy213;
+ yymsp[0].minor.yy227 = yylhsminor.yy227;
break;
case 23: /* columnname ::= nm typetoken */
{sqlite3AddColumn(pParse,yymsp[-1].minor.yy0,yymsp[0].minor.yy0);}
@@ -162821,7 +164689,7 @@ static YYACTIONTYPE yy_reduce(
case 28: /* scanpt ::= */
{
assert( yyLookahead!=YYNOCODE );
- yymsp[1].minor.yy70 = yyLookaheadToken.z;
+ yymsp[1].minor.yy116 = yyLookaheadToken.z;
}
break;
case 29: /* scantok ::= */
@@ -162835,17 +164703,17 @@ static YYACTIONTYPE yy_reduce(
{pParse->constraintName = yymsp[0].minor.yy0;}
break;
case 31: /* ccons ::= DEFAULT scantok term */
-{sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy454,yymsp[-1].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);}
+{sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy122,yymsp[-1].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);}
break;
case 32: /* ccons ::= DEFAULT LP expr RP */
-{sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy454,yymsp[-2].minor.yy0.z+1,yymsp[0].minor.yy0.z);}
+{sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy122,yymsp[-2].minor.yy0.z+1,yymsp[0].minor.yy0.z);}
break;
case 33: /* ccons ::= DEFAULT PLUS scantok term */
-{sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy454,yymsp[-2].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);}
+{sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy122,yymsp[-2].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);}
break;
case 34: /* ccons ::= DEFAULT MINUS scantok term */
{
- Expr *p = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy454, 0);
+ Expr *p = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy122, 0);
sqlite3AddDefaultValue(pParse,p,yymsp[-2].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);
}
break;
@@ -162860,161 +164728,161 @@ static YYACTIONTYPE yy_reduce(
}
break;
case 36: /* ccons ::= NOT NULL onconf */
-{sqlite3AddNotNull(pParse, yymsp[0].minor.yy332);}
+{sqlite3AddNotNull(pParse, yymsp[0].minor.yy452);}
break;
case 37: /* ccons ::= PRIMARY KEY sortorder onconf autoinc */
-{sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy332,yymsp[0].minor.yy332,yymsp[-2].minor.yy332);}
+{sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy452,yymsp[0].minor.yy452,yymsp[-2].minor.yy452);}
break;
case 38: /* ccons ::= UNIQUE onconf */
-{sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy332,0,0,0,0,
+{sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy452,0,0,0,0,
SQLITE_IDXTYPE_UNIQUE);}
break;
case 39: /* ccons ::= CHECK LP expr RP */
-{sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy454,yymsp[-2].minor.yy0.z,yymsp[0].minor.yy0.z);}
+{sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy122,yymsp[-2].minor.yy0.z,yymsp[0].minor.yy0.z);}
break;
case 40: /* ccons ::= REFERENCES nm eidlist_opt refargs */
-{sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy368,yymsp[0].minor.yy332);}
+{sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy322,yymsp[0].minor.yy452);}
break;
case 41: /* ccons ::= defer_subclause */
-{sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy332);}
+{sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy452);}
break;
case 42: /* ccons ::= COLLATE ID|STRING */
{sqlite3AddCollateType(pParse, &yymsp[0].minor.yy0);}
break;
case 43: /* generated ::= LP expr RP */
-{sqlite3AddGenerated(pParse,yymsp[-1].minor.yy454,0);}
+{sqlite3AddGenerated(pParse,yymsp[-1].minor.yy122,0);}
break;
case 44: /* generated ::= LP expr RP ID */
-{sqlite3AddGenerated(pParse,yymsp[-2].minor.yy454,&yymsp[0].minor.yy0);}
+{sqlite3AddGenerated(pParse,yymsp[-2].minor.yy122,&yymsp[0].minor.yy0);}
break;
case 46: /* autoinc ::= AUTOINCR */
-{yymsp[0].minor.yy332 = 1;}
+{yymsp[0].minor.yy452 = 1;}
break;
case 47: /* refargs ::= */
-{ yymsp[1].minor.yy332 = OE_None*0x0101; /* EV: R-19803-45884 */}
+{ yymsp[1].minor.yy452 = OE_None*0x0101; /* EV: R-19803-45884 */}
break;
case 48: /* refargs ::= refargs refarg */
-{ yymsp[-1].minor.yy332 = (yymsp[-1].minor.yy332 & ~yymsp[0].minor.yy277.mask) | yymsp[0].minor.yy277.value; }
+{ yymsp[-1].minor.yy452 = (yymsp[-1].minor.yy452 & ~yymsp[0].minor.yy347.mask) | yymsp[0].minor.yy347.value; }
break;
case 49: /* refarg ::= MATCH nm */
-{ yymsp[-1].minor.yy277.value = 0; yymsp[-1].minor.yy277.mask = 0x000000; }
+{ yymsp[-1].minor.yy347.value = 0; yymsp[-1].minor.yy347.mask = 0x000000; }
break;
case 50: /* refarg ::= ON INSERT refact */
-{ yymsp[-2].minor.yy277.value = 0; yymsp[-2].minor.yy277.mask = 0x000000; }
+{ yymsp[-2].minor.yy347.value = 0; yymsp[-2].minor.yy347.mask = 0x000000; }
break;
case 51: /* refarg ::= ON DELETE refact */
-{ yymsp[-2].minor.yy277.value = yymsp[0].minor.yy332; yymsp[-2].minor.yy277.mask = 0x0000ff; }
+{ yymsp[-2].minor.yy347.value = yymsp[0].minor.yy452; yymsp[-2].minor.yy347.mask = 0x0000ff; }
break;
case 52: /* refarg ::= ON UPDATE refact */
-{ yymsp[-2].minor.yy277.value = yymsp[0].minor.yy332<<8; yymsp[-2].minor.yy277.mask = 0x00ff00; }
+{ yymsp[-2].minor.yy347.value = yymsp[0].minor.yy452<<8; yymsp[-2].minor.yy347.mask = 0x00ff00; }
break;
case 53: /* refact ::= SET NULL */
-{ yymsp[-1].minor.yy332 = OE_SetNull; /* EV: R-33326-45252 */}
+{ yymsp[-1].minor.yy452 = OE_SetNull; /* EV: R-33326-45252 */}
break;
case 54: /* refact ::= SET DEFAULT */
-{ yymsp[-1].minor.yy332 = OE_SetDflt; /* EV: R-33326-45252 */}
+{ yymsp[-1].minor.yy452 = OE_SetDflt; /* EV: R-33326-45252 */}
break;
case 55: /* refact ::= CASCADE */
-{ yymsp[0].minor.yy332 = OE_Cascade; /* EV: R-33326-45252 */}
+{ yymsp[0].minor.yy452 = OE_Cascade; /* EV: R-33326-45252 */}
break;
case 56: /* refact ::= RESTRICT */
-{ yymsp[0].minor.yy332 = OE_Restrict; /* EV: R-33326-45252 */}
+{ yymsp[0].minor.yy452 = OE_Restrict; /* EV: R-33326-45252 */}
break;
case 57: /* refact ::= NO ACTION */
-{ yymsp[-1].minor.yy332 = OE_None; /* EV: R-33326-45252 */}
+{ yymsp[-1].minor.yy452 = OE_None; /* EV: R-33326-45252 */}
break;
case 58: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
-{yymsp[-2].minor.yy332 = 0;}
+{yymsp[-2].minor.yy452 = 0;}
break;
case 59: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
case 74: /* orconf ::= OR resolvetype */ yytestcase(yyruleno==74);
case 168: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==168);
-{yymsp[-1].minor.yy332 = yymsp[0].minor.yy332;}
+{yymsp[-1].minor.yy452 = yymsp[0].minor.yy452;}
break;
case 61: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */
case 78: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==78);
- case 208: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==208);
- case 211: /* in_op ::= NOT IN */ yytestcase(yyruleno==211);
- case 237: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==237);
-{yymsp[-1].minor.yy332 = 1;}
+ case 209: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==209);
+ case 212: /* in_op ::= NOT IN */ yytestcase(yyruleno==212);
+ case 238: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==238);
+{yymsp[-1].minor.yy452 = 1;}
break;
case 62: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
-{yymsp[-1].minor.yy332 = 0;}
+{yymsp[-1].minor.yy452 = 0;}
break;
case 64: /* tconscomma ::= COMMA */
{pParse->constraintName.n = 0;}
break;
case 66: /* tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
-{sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy368,yymsp[0].minor.yy332,yymsp[-2].minor.yy332,0);}
+{sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy322,yymsp[0].minor.yy452,yymsp[-2].minor.yy452,0);}
break;
case 67: /* tcons ::= UNIQUE LP sortlist RP onconf */
-{sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy368,yymsp[0].minor.yy332,0,0,0,0,
+{sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy322,yymsp[0].minor.yy452,0,0,0,0,
SQLITE_IDXTYPE_UNIQUE);}
break;
case 68: /* tcons ::= CHECK LP expr RP onconf */
-{sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy454,yymsp[-3].minor.yy0.z,yymsp[-1].minor.yy0.z);}
+{sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy122,yymsp[-3].minor.yy0.z,yymsp[-1].minor.yy0.z);}
break;
case 69: /* tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
{
- sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy368, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy368, yymsp[-1].minor.yy332);
- sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy332);
+ sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy322, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy322, yymsp[-1].minor.yy452);
+ sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy452);
}
break;
case 71: /* onconf ::= */
case 73: /* orconf ::= */ yytestcase(yyruleno==73);
-{yymsp[1].minor.yy332 = OE_Default;}
+{yymsp[1].minor.yy452 = OE_Default;}
break;
case 72: /* onconf ::= ON CONFLICT resolvetype */
-{yymsp[-2].minor.yy332 = yymsp[0].minor.yy332;}
+{yymsp[-2].minor.yy452 = yymsp[0].minor.yy452;}
break;
case 75: /* resolvetype ::= IGNORE */
-{yymsp[0].minor.yy332 = OE_Ignore;}
+{yymsp[0].minor.yy452 = OE_Ignore;}
break;
case 76: /* resolvetype ::= REPLACE */
case 169: /* insert_cmd ::= REPLACE */ yytestcase(yyruleno==169);
-{yymsp[0].minor.yy332 = OE_Replace;}
+{yymsp[0].minor.yy452 = OE_Replace;}
break;
case 77: /* cmd ::= DROP TABLE ifexists fullname */
{
- sqlite3DropTable(pParse, yymsp[0].minor.yy155, 0, yymsp[-1].minor.yy332);
+ sqlite3DropTable(pParse, yymsp[0].minor.yy247, 0, yymsp[-1].minor.yy452);
}
break;
case 80: /* 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.yy368, yymsp[0].minor.yy433, yymsp[-7].minor.yy332, yymsp[-5].minor.yy332);
+ sqlite3CreateView(pParse, &yymsp[-8].minor.yy0, &yymsp[-4].minor.yy0, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy322, yymsp[0].minor.yy279, yymsp[-7].minor.yy452, yymsp[-5].minor.yy452);
}
break;
case 81: /* cmd ::= DROP VIEW ifexists fullname */
{
- sqlite3DropTable(pParse, yymsp[0].minor.yy155, 1, yymsp[-1].minor.yy332);
+ sqlite3DropTable(pParse, yymsp[0].minor.yy247, 1, yymsp[-1].minor.yy452);
}
break;
case 82: /* cmd ::= select */
{
SelectDest dest = {SRT_Output, 0, 0, 0, 0, 0, 0};
- sqlite3Select(pParse, yymsp[0].minor.yy433, &dest);
- sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy433);
+ sqlite3Select(pParse, yymsp[0].minor.yy279, &dest);
+ sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy279);
}
break;
case 83: /* select ::= WITH wqlist selectnowith */
-{yymsp[-2].minor.yy433 = attachWithToSelect(pParse,yymsp[0].minor.yy433,yymsp[-1].minor.yy23);}
+{yymsp[-2].minor.yy279 = attachWithToSelect(pParse,yymsp[0].minor.yy279,yymsp[-1].minor.yy231);}
break;
case 84: /* select ::= WITH RECURSIVE wqlist selectnowith */
-{yymsp[-3].minor.yy433 = attachWithToSelect(pParse,yymsp[0].minor.yy433,yymsp[-1].minor.yy23);}
+{yymsp[-3].minor.yy279 = attachWithToSelect(pParse,yymsp[0].minor.yy279,yymsp[-1].minor.yy231);}
break;
case 85: /* select ::= selectnowith */
{
- Select *p = yymsp[0].minor.yy433;
+ Select *p = yymsp[0].minor.yy279;
if( p ){
parserDoubleLinkSelect(pParse, p);
}
- yymsp[0].minor.yy433 = p; /*A-overwrites-X*/
+ yymsp[0].minor.yy279 = p; /*A-overwrites-X*/
}
break;
case 86: /* selectnowith ::= selectnowith multiselect_op oneselect */
{
- Select *pRhs = yymsp[0].minor.yy433;
- Select *pLhs = yymsp[-2].minor.yy433;
+ Select *pRhs = yymsp[0].minor.yy279;
+ Select *pLhs = yymsp[-2].minor.yy279;
if( pRhs && pRhs->pPrior ){
SrcList *pFrom;
Token x;
@@ -163024,130 +164892,130 @@ static YYACTIONTYPE yy_reduce(
pRhs = sqlite3SelectNew(pParse,0,pFrom,0,0,0,0,0,0);
}
if( pRhs ){
- pRhs->op = (u8)yymsp[-1].minor.yy332;
+ pRhs->op = (u8)yymsp[-1].minor.yy452;
pRhs->pPrior = pLhs;
if( ALWAYS(pLhs) ) pLhs->selFlags &= ~SF_MultiValue;
pRhs->selFlags &= ~SF_MultiValue;
- if( yymsp[-1].minor.yy332!=TK_ALL ) pParse->hasCompound = 1;
+ if( yymsp[-1].minor.yy452!=TK_ALL ) pParse->hasCompound = 1;
}else{
sqlite3SelectDelete(pParse->db, pLhs);
}
- yymsp[-2].minor.yy433 = pRhs;
+ yymsp[-2].minor.yy279 = pRhs;
}
break;
case 87: /* multiselect_op ::= UNION */
case 89: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==89);
-{yymsp[0].minor.yy332 = yymsp[0].major; /*A-overwrites-OP*/}
+{yymsp[0].minor.yy452 = yymsp[0].major; /*A-overwrites-OP*/}
break;
case 88: /* multiselect_op ::= UNION ALL */
-{yymsp[-1].minor.yy332 = TK_ALL;}
+{yymsp[-1].minor.yy452 = TK_ALL;}
break;
case 90: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
{
- yymsp[-8].minor.yy433 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy368,yymsp[-5].minor.yy155,yymsp[-4].minor.yy454,yymsp[-3].minor.yy368,yymsp[-2].minor.yy454,yymsp[-1].minor.yy368,yymsp[-7].minor.yy332,yymsp[0].minor.yy454);
+ yymsp[-8].minor.yy279 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy322,yymsp[-5].minor.yy247,yymsp[-4].minor.yy122,yymsp[-3].minor.yy322,yymsp[-2].minor.yy122,yymsp[-1].minor.yy322,yymsp[-7].minor.yy452,yymsp[0].minor.yy122);
}
break;
case 91: /* values ::= VALUES LP nexprlist RP */
{
- yymsp[-3].minor.yy433 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy368,0,0,0,0,0,SF_Values,0);
+ yymsp[-3].minor.yy279 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy322,0,0,0,0,0,SF_Values,0);
}
break;
case 92: /* values ::= values COMMA LP nexprlist RP */
{
- Select *pRight, *pLeft = yymsp[-4].minor.yy433;
- pRight = sqlite3SelectNew(pParse,yymsp[-1].minor.yy368,0,0,0,0,0,SF_Values|SF_MultiValue,0);
+ Select *pRight, *pLeft = yymsp[-4].minor.yy279;
+ pRight = sqlite3SelectNew(pParse,yymsp[-1].minor.yy322,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.yy433 = pRight;
+ yymsp[-4].minor.yy279 = pRight;
}else{
- yymsp[-4].minor.yy433 = pLeft;
+ yymsp[-4].minor.yy279 = pLeft;
}
}
break;
case 93: /* distinct ::= DISTINCT */
-{yymsp[0].minor.yy332 = SF_Distinct;}
+{yymsp[0].minor.yy452 = SF_Distinct;}
break;
case 94: /* distinct ::= ALL */
-{yymsp[0].minor.yy332 = SF_All;}
+{yymsp[0].minor.yy452 = SF_All;}
break;
case 96: /* sclp ::= */
case 129: /* orderby_opt ::= */ yytestcase(yyruleno==129);
case 139: /* groupby_opt ::= */ yytestcase(yyruleno==139);
- case 224: /* exprlist ::= */ yytestcase(yyruleno==224);
- case 227: /* paren_exprlist ::= */ yytestcase(yyruleno==227);
- case 232: /* eidlist_opt ::= */ yytestcase(yyruleno==232);
-{yymsp[1].minor.yy368 = 0;}
+ case 225: /* exprlist ::= */ yytestcase(yyruleno==225);
+ case 228: /* paren_exprlist ::= */ yytestcase(yyruleno==228);
+ case 233: /* eidlist_opt ::= */ yytestcase(yyruleno==233);
+{yymsp[1].minor.yy322 = 0;}
break;
case 97: /* selcollist ::= sclp scanpt expr scanpt as */
{
- yymsp[-4].minor.yy368 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy368, yymsp[-2].minor.yy454);
- if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy368, &yymsp[0].minor.yy0, 1);
- sqlite3ExprListSetSpan(pParse,yymsp[-4].minor.yy368,yymsp[-3].minor.yy70,yymsp[-1].minor.yy70);
+ yymsp[-4].minor.yy322 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy322, yymsp[-2].minor.yy122);
+ if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy322, &yymsp[0].minor.yy0, 1);
+ sqlite3ExprListSetSpan(pParse,yymsp[-4].minor.yy322,yymsp[-3].minor.yy116,yymsp[-1].minor.yy116);
}
break;
case 98: /* selcollist ::= sclp scanpt STAR */
{
Expr *p = sqlite3Expr(pParse->db, TK_ASTERISK, 0);
- yymsp[-2].minor.yy368 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy368, p);
+ yymsp[-2].minor.yy322 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy322, p);
}
break;
case 99: /* selcollist ::= sclp scanpt nm DOT STAR */
{
Expr *pRight = sqlite3PExpr(pParse, TK_ASTERISK, 0, 0);
- Expr *pLeft = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
+ Expr *pLeft = tokenExpr(pParse, TK_ID, yymsp[-2].minor.yy0);
Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight);
- yymsp[-4].minor.yy368 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy368, pDot);
+ yymsp[-4].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy322, pDot);
}
break;
case 100: /* as ::= AS nm */
case 111: /* dbnm ::= DOT nm */ yytestcase(yyruleno==111);
- case 248: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==248);
- case 249: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==249);
+ case 249: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==249);
+ case 250: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==250);
{yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;}
break;
case 102: /* from ::= */
case 105: /* stl_prefix ::= */ yytestcase(yyruleno==105);
-{yymsp[1].minor.yy155 = 0;}
+{yymsp[1].minor.yy247 = 0;}
break;
case 103: /* from ::= FROM seltablist */
{
- yymsp[-1].minor.yy155 = yymsp[0].minor.yy155;
- sqlite3SrcListShiftJoinType(yymsp[-1].minor.yy155);
+ yymsp[-1].minor.yy247 = yymsp[0].minor.yy247;
+ sqlite3SrcListShiftJoinType(yymsp[-1].minor.yy247);
}
break;
case 104: /* stl_prefix ::= seltablist joinop */
{
- if( ALWAYS(yymsp[-1].minor.yy155 && yymsp[-1].minor.yy155->nSrc>0) ) yymsp[-1].minor.yy155->a[yymsp[-1].minor.yy155->nSrc-1].fg.jointype = (u8)yymsp[0].minor.yy332;
+ if( ALWAYS(yymsp[-1].minor.yy247 && yymsp[-1].minor.yy247->nSrc>0) ) yymsp[-1].minor.yy247->a[yymsp[-1].minor.yy247->nSrc-1].fg.jointype = (u8)yymsp[0].minor.yy452;
}
break;
case 106: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
{
- yymsp[-6].minor.yy155 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy155,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy454,yymsp[0].minor.yy374);
- sqlite3SrcListIndexedBy(pParse, yymsp[-6].minor.yy155, &yymsp[-2].minor.yy0);
+ yymsp[-6].minor.yy247 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy247,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy122,yymsp[0].minor.yy80);
+ sqlite3SrcListIndexedBy(pParse, yymsp[-6].minor.yy247, &yymsp[-2].minor.yy0);
}
break;
case 107: /* seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
{
- yymsp[-8].minor.yy155 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-8].minor.yy155,&yymsp[-7].minor.yy0,&yymsp[-6].minor.yy0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy454,yymsp[0].minor.yy374);
- sqlite3SrcListFuncArgs(pParse, yymsp[-8].minor.yy155, yymsp[-4].minor.yy368);
+ yymsp[-8].minor.yy247 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-8].minor.yy247,&yymsp[-7].minor.yy0,&yymsp[-6].minor.yy0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy122,yymsp[0].minor.yy80);
+ sqlite3SrcListFuncArgs(pParse, yymsp[-8].minor.yy247, yymsp[-4].minor.yy322);
}
break;
case 108: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */
{
- yymsp[-6].minor.yy155 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy155,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy433,yymsp[-1].minor.yy454,yymsp[0].minor.yy374);
+ yymsp[-6].minor.yy247 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy247,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy279,yymsp[-1].minor.yy122,yymsp[0].minor.yy80);
}
break;
case 109: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
{
- if( yymsp[-6].minor.yy155==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy454==0 && yymsp[0].minor.yy374==0 ){
- yymsp[-6].minor.yy155 = yymsp[-4].minor.yy155;
- }else if( yymsp[-4].minor.yy155->nSrc==1 ){
- yymsp[-6].minor.yy155 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy155,0,0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy454,yymsp[0].minor.yy374);
- if( yymsp[-6].minor.yy155 ){
- SrcItem *pNew = &yymsp[-6].minor.yy155->a[yymsp[-6].minor.yy155->nSrc-1];
- SrcItem *pOld = yymsp[-4].minor.yy155->a;
+ if( yymsp[-6].minor.yy247==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy122==0 && yymsp[0].minor.yy80==0 ){
+ yymsp[-6].minor.yy247 = yymsp[-4].minor.yy247;
+ }else if( yymsp[-4].minor.yy247->nSrc==1 ){
+ yymsp[-6].minor.yy247 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy247,0,0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy122,yymsp[0].minor.yy80);
+ if( yymsp[-6].minor.yy247 ){
+ SrcItem *pNew = &yymsp[-6].minor.yy247->a[yymsp[-6].minor.yy247->nSrc-1];
+ SrcItem *pOld = yymsp[-4].minor.yy247->a;
pNew->zName = pOld->zName;
pNew->zDatabase = pOld->zDatabase;
pNew->pSelect = pOld->pSelect;
@@ -163160,12 +165028,12 @@ static YYACTIONTYPE yy_reduce(
pOld->zName = pOld->zDatabase = 0;
pOld->pSelect = 0;
}
- sqlite3SrcListDelete(pParse->db, yymsp[-4].minor.yy155);
+ sqlite3SrcListDelete(pParse->db, yymsp[-4].minor.yy247);
}else{
Select *pSubquery;
- sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy155);
- pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy155,0,0,0,0,SF_NestedFrom,0);
- yymsp[-6].minor.yy155 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy155,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy454,yymsp[0].minor.yy374);
+ sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy247);
+ pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy247,0,0,0,0,SF_NestedFrom,0);
+ yymsp[-6].minor.yy247 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy247,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy122,yymsp[0].minor.yy80);
}
}
break;
@@ -163175,65 +165043,65 @@ static YYACTIONTYPE yy_reduce(
break;
case 112: /* fullname ::= nm */
{
- yylhsminor.yy155 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0);
- if( IN_RENAME_OBJECT && yylhsminor.yy155 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy155->a[0].zName, &yymsp[0].minor.yy0);
+ yylhsminor.yy247 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0);
+ if( IN_RENAME_OBJECT && yylhsminor.yy247 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy247->a[0].zName, &yymsp[0].minor.yy0);
}
- yymsp[0].minor.yy155 = yylhsminor.yy155;
+ yymsp[0].minor.yy247 = yylhsminor.yy247;
break;
case 113: /* fullname ::= nm DOT nm */
{
- yylhsminor.yy155 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);
- if( IN_RENAME_OBJECT && yylhsminor.yy155 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy155->a[0].zName, &yymsp[0].minor.yy0);
+ yylhsminor.yy247 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);
+ if( IN_RENAME_OBJECT && yylhsminor.yy247 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy247->a[0].zName, &yymsp[0].minor.yy0);
}
- yymsp[-2].minor.yy155 = yylhsminor.yy155;
+ yymsp[-2].minor.yy247 = yylhsminor.yy247;
break;
case 114: /* xfullname ::= nm */
-{yymsp[0].minor.yy155 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0); /*A-overwrites-X*/}
+{yymsp[0].minor.yy247 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0); /*A-overwrites-X*/}
break;
case 115: /* xfullname ::= nm DOT nm */
-{yymsp[-2].minor.yy155 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/}
+{yymsp[-2].minor.yy247 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/}
break;
case 116: /* xfullname ::= nm DOT nm AS nm */
{
- yymsp[-4].minor.yy155 = sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,&yymsp[-2].minor.yy0); /*A-overwrites-X*/
- if( yymsp[-4].minor.yy155 ) yymsp[-4].minor.yy155->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
+ yymsp[-4].minor.yy247 = sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,&yymsp[-2].minor.yy0); /*A-overwrites-X*/
+ if( yymsp[-4].minor.yy247 ) yymsp[-4].minor.yy247->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
}
break;
case 117: /* xfullname ::= nm AS nm */
{
- yymsp[-2].minor.yy155 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,0); /*A-overwrites-X*/
- if( yymsp[-2].minor.yy155 ) yymsp[-2].minor.yy155->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
+ yymsp[-2].minor.yy247 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,0); /*A-overwrites-X*/
+ if( yymsp[-2].minor.yy247 ) yymsp[-2].minor.yy247->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
}
break;
case 118: /* joinop ::= COMMA|JOIN */
-{ yymsp[0].minor.yy332 = JT_INNER; }
+{ yymsp[0].minor.yy452 = JT_INNER; }
break;
case 119: /* joinop ::= JOIN_KW JOIN */
-{yymsp[-1].minor.yy332 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); /*X-overwrites-A*/}
+{yymsp[-1].minor.yy452 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); /*X-overwrites-A*/}
break;
case 120: /* joinop ::= JOIN_KW nm JOIN */
-{yymsp[-2].minor.yy332 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/}
+{yymsp[-2].minor.yy452 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/}
break;
case 121: /* joinop ::= JOIN_KW nm nm JOIN */
-{yymsp[-3].minor.yy332 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/}
+{yymsp[-3].minor.yy452 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/}
break;
case 122: /* on_opt ::= ON expr */
case 142: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==142);
case 149: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==149);
case 151: /* where_opt_ret ::= WHERE expr */ yytestcase(yyruleno==151);
- case 220: /* case_else ::= ELSE expr */ yytestcase(yyruleno==220);
- case 241: /* vinto ::= INTO expr */ yytestcase(yyruleno==241);
-{yymsp[-1].minor.yy454 = yymsp[0].minor.yy454;}
+ case 221: /* case_else ::= ELSE expr */ yytestcase(yyruleno==221);
+ case 242: /* vinto ::= INTO expr */ yytestcase(yyruleno==242);
+{yymsp[-1].minor.yy122 = yymsp[0].minor.yy122;}
break;
case 123: /* on_opt ::= */
case 141: /* having_opt ::= */ yytestcase(yyruleno==141);
case 143: /* limit_opt ::= */ yytestcase(yyruleno==143);
case 148: /* where_opt ::= */ yytestcase(yyruleno==148);
case 150: /* where_opt_ret ::= */ yytestcase(yyruleno==150);
- case 221: /* case_else ::= */ yytestcase(yyruleno==221);
- case 223: /* case_operand ::= */ yytestcase(yyruleno==223);
- case 242: /* vinto ::= */ yytestcase(yyruleno==242);
-{yymsp[1].minor.yy454 = 0;}
+ case 222: /* case_else ::= */ yytestcase(yyruleno==222);
+ case 224: /* case_operand ::= */ yytestcase(yyruleno==224);
+ case 243: /* vinto ::= */ yytestcase(yyruleno==243);
+{yymsp[1].minor.yy122 = 0;}
break;
case 125: /* indexed_opt ::= INDEXED BY nm */
{yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;}
@@ -163242,185 +165110,181 @@ static YYACTIONTYPE yy_reduce(
{yymsp[-1].minor.yy0.z=0; yymsp[-1].minor.yy0.n=1;}
break;
case 127: /* using_opt ::= USING LP idlist RP */
-{yymsp[-3].minor.yy374 = yymsp[-1].minor.yy374;}
+{yymsp[-3].minor.yy80 = yymsp[-1].minor.yy80;}
break;
case 128: /* using_opt ::= */
case 170: /* idlist_opt ::= */ yytestcase(yyruleno==170);
-{yymsp[1].minor.yy374 = 0;}
+{yymsp[1].minor.yy80 = 0;}
break;
case 130: /* orderby_opt ::= ORDER BY sortlist */
case 140: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==140);
-{yymsp[-2].minor.yy368 = yymsp[0].minor.yy368;}
+{yymsp[-2].minor.yy322 = yymsp[0].minor.yy322;}
break;
case 131: /* sortlist ::= sortlist COMMA expr sortorder nulls */
{
- yymsp[-4].minor.yy368 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy368,yymsp[-2].minor.yy454);
- sqlite3ExprListSetSortOrder(yymsp[-4].minor.yy368,yymsp[-1].minor.yy332,yymsp[0].minor.yy332);
+ yymsp[-4].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy322,yymsp[-2].minor.yy122);
+ sqlite3ExprListSetSortOrder(yymsp[-4].minor.yy322,yymsp[-1].minor.yy452,yymsp[0].minor.yy452);
}
break;
case 132: /* sortlist ::= expr sortorder nulls */
{
- yymsp[-2].minor.yy368 = sqlite3ExprListAppend(pParse,0,yymsp[-2].minor.yy454); /*A-overwrites-Y*/
- sqlite3ExprListSetSortOrder(yymsp[-2].minor.yy368,yymsp[-1].minor.yy332,yymsp[0].minor.yy332);
+ yymsp[-2].minor.yy322 = sqlite3ExprListAppend(pParse,0,yymsp[-2].minor.yy122); /*A-overwrites-Y*/
+ sqlite3ExprListSetSortOrder(yymsp[-2].minor.yy322,yymsp[-1].minor.yy452,yymsp[0].minor.yy452);
}
break;
case 133: /* sortorder ::= ASC */
-{yymsp[0].minor.yy332 = SQLITE_SO_ASC;}
+{yymsp[0].minor.yy452 = SQLITE_SO_ASC;}
break;
case 134: /* sortorder ::= DESC */
-{yymsp[0].minor.yy332 = SQLITE_SO_DESC;}
+{yymsp[0].minor.yy452 = SQLITE_SO_DESC;}
break;
case 135: /* sortorder ::= */
case 138: /* nulls ::= */ yytestcase(yyruleno==138);
-{yymsp[1].minor.yy332 = SQLITE_SO_UNDEFINED;}
+{yymsp[1].minor.yy452 = SQLITE_SO_UNDEFINED;}
break;
case 136: /* nulls ::= NULLS FIRST */
-{yymsp[-1].minor.yy332 = SQLITE_SO_ASC;}
+{yymsp[-1].minor.yy452 = SQLITE_SO_ASC;}
break;
case 137: /* nulls ::= NULLS LAST */
-{yymsp[-1].minor.yy332 = SQLITE_SO_DESC;}
+{yymsp[-1].minor.yy452 = SQLITE_SO_DESC;}
break;
case 144: /* limit_opt ::= LIMIT expr */
-{yymsp[-1].minor.yy454 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy454,0);}
+{yymsp[-1].minor.yy122 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy122,0);}
break;
case 145: /* limit_opt ::= LIMIT expr OFFSET expr */
-{yymsp[-3].minor.yy454 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[-2].minor.yy454,yymsp[0].minor.yy454);}
+{yymsp[-3].minor.yy122 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[-2].minor.yy122,yymsp[0].minor.yy122);}
break;
case 146: /* limit_opt ::= LIMIT expr COMMA expr */
-{yymsp[-3].minor.yy454 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy454,yymsp[-2].minor.yy454);}
+{yymsp[-3].minor.yy122 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy122,yymsp[-2].minor.yy122);}
break;
case 147: /* cmd ::= with DELETE FROM xfullname indexed_opt where_opt_ret */
{
- sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy155, &yymsp[-1].minor.yy0);
- sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy155,yymsp[0].minor.yy454,0,0);
+ sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy247, &yymsp[-1].minor.yy0);
+ sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy247,yymsp[0].minor.yy122,0,0);
}
break;
case 152: /* where_opt_ret ::= RETURNING selcollist */
-{sqlite3AddReturning(pParse,yymsp[0].minor.yy368); yymsp[-1].minor.yy454 = 0;}
+{sqlite3AddReturning(pParse,yymsp[0].minor.yy322); yymsp[-1].minor.yy122 = 0;}
break;
case 153: /* where_opt_ret ::= WHERE expr RETURNING selcollist */
-{sqlite3AddReturning(pParse,yymsp[0].minor.yy368); yymsp[-3].minor.yy454 = yymsp[-2].minor.yy454;}
+{sqlite3AddReturning(pParse,yymsp[0].minor.yy322); yymsp[-3].minor.yy122 = yymsp[-2].minor.yy122;}
break;
case 154: /* cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist from where_opt_ret */
{
- sqlite3SrcListIndexedBy(pParse, yymsp[-5].minor.yy155, &yymsp[-4].minor.yy0);
- sqlite3ExprListCheckLength(pParse,yymsp[-2].minor.yy368,"set list");
- yymsp[-5].minor.yy155 = sqlite3SrcListAppendList(pParse, yymsp[-5].minor.yy155, yymsp[-1].minor.yy155);
- sqlite3Update(pParse,yymsp[-5].minor.yy155,yymsp[-2].minor.yy368,yymsp[0].minor.yy454,yymsp[-6].minor.yy332,0,0,0);
+ sqlite3SrcListIndexedBy(pParse, yymsp[-5].minor.yy247, &yymsp[-4].minor.yy0);
+ sqlite3ExprListCheckLength(pParse,yymsp[-2].minor.yy322,"set list");
+ yymsp[-5].minor.yy247 = sqlite3SrcListAppendList(pParse, yymsp[-5].minor.yy247, yymsp[-1].minor.yy247);
+ sqlite3Update(pParse,yymsp[-5].minor.yy247,yymsp[-2].minor.yy322,yymsp[0].minor.yy122,yymsp[-6].minor.yy452,0,0,0);
}
break;
case 155: /* setlist ::= setlist COMMA nm EQ expr */
{
- yymsp[-4].minor.yy368 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy368, yymsp[0].minor.yy454);
- sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy368, &yymsp[-2].minor.yy0, 1);
+ yymsp[-4].minor.yy322 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy322, yymsp[0].minor.yy122);
+ sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy322, &yymsp[-2].minor.yy0, 1);
}
break;
case 156: /* setlist ::= setlist COMMA LP idlist RP EQ expr */
{
- yymsp[-6].minor.yy368 = sqlite3ExprListAppendVector(pParse, yymsp[-6].minor.yy368, yymsp[-3].minor.yy374, yymsp[0].minor.yy454);
+ yymsp[-6].minor.yy322 = sqlite3ExprListAppendVector(pParse, yymsp[-6].minor.yy322, yymsp[-3].minor.yy80, yymsp[0].minor.yy122);
}
break;
case 157: /* setlist ::= nm EQ expr */
{
- yylhsminor.yy368 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy454);
- sqlite3ExprListSetName(pParse, yylhsminor.yy368, &yymsp[-2].minor.yy0, 1);
+ yylhsminor.yy322 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy122);
+ sqlite3ExprListSetName(pParse, yylhsminor.yy322, &yymsp[-2].minor.yy0, 1);
}
- yymsp[-2].minor.yy368 = yylhsminor.yy368;
+ yymsp[-2].minor.yy322 = yylhsminor.yy322;
break;
case 158: /* setlist ::= LP idlist RP EQ expr */
{
- yymsp[-4].minor.yy368 = sqlite3ExprListAppendVector(pParse, 0, yymsp[-3].minor.yy374, yymsp[0].minor.yy454);
+ yymsp[-4].minor.yy322 = sqlite3ExprListAppendVector(pParse, 0, yymsp[-3].minor.yy80, yymsp[0].minor.yy122);
}
break;
case 159: /* cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
{
- sqlite3Insert(pParse, yymsp[-3].minor.yy155, yymsp[-1].minor.yy433, yymsp[-2].minor.yy374, yymsp[-5].minor.yy332, yymsp[0].minor.yy232);
+ sqlite3Insert(pParse, yymsp[-3].minor.yy247, yymsp[-1].minor.yy279, yymsp[-2].minor.yy80, yymsp[-5].minor.yy452, yymsp[0].minor.yy38);
}
break;
case 160: /* cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES returning */
{
- sqlite3Insert(pParse, yymsp[-4].minor.yy155, 0, yymsp[-3].minor.yy374, yymsp[-6].minor.yy332, 0);
+ sqlite3Insert(pParse, yymsp[-4].minor.yy247, 0, yymsp[-3].minor.yy80, yymsp[-6].minor.yy452, 0);
}
break;
case 161: /* upsert ::= */
-{ yymsp[1].minor.yy232 = 0; }
+{ yymsp[1].minor.yy38 = 0; }
break;
case 162: /* upsert ::= RETURNING selcollist */
-{ yymsp[-1].minor.yy232 = 0; sqlite3AddReturning(pParse,yymsp[0].minor.yy368); }
+{ yymsp[-1].minor.yy38 = 0; sqlite3AddReturning(pParse,yymsp[0].minor.yy322); }
break;
case 163: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt upsert */
-{ yymsp[-11].minor.yy232 = sqlite3UpsertNew(pParse->db,yymsp[-8].minor.yy368,yymsp[-6].minor.yy454,yymsp[-2].minor.yy368,yymsp[-1].minor.yy454,yymsp[0].minor.yy232);}
+{ yymsp[-11].minor.yy38 = sqlite3UpsertNew(pParse->db,yymsp[-8].minor.yy322,yymsp[-6].minor.yy122,yymsp[-2].minor.yy322,yymsp[-1].minor.yy122,yymsp[0].minor.yy38);}
break;
case 164: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING upsert */
-{ yymsp[-8].minor.yy232 = sqlite3UpsertNew(pParse->db,yymsp[-5].minor.yy368,yymsp[-3].minor.yy454,0,0,yymsp[0].minor.yy232); }
+{ yymsp[-8].minor.yy38 = sqlite3UpsertNew(pParse->db,yymsp[-5].minor.yy322,yymsp[-3].minor.yy122,0,0,yymsp[0].minor.yy38); }
break;
case 165: /* upsert ::= ON CONFLICT DO NOTHING returning */
-{ yymsp[-4].minor.yy232 = sqlite3UpsertNew(pParse->db,0,0,0,0,0); }
+{ yymsp[-4].minor.yy38 = sqlite3UpsertNew(pParse->db,0,0,0,0,0); }
break;
case 166: /* upsert ::= ON CONFLICT DO UPDATE SET setlist where_opt returning */
-{ yymsp[-7].minor.yy232 = sqlite3UpsertNew(pParse->db,0,0,yymsp[-2].minor.yy368,yymsp[-1].minor.yy454,0);}
+{ yymsp[-7].minor.yy38 = sqlite3UpsertNew(pParse->db,0,0,yymsp[-2].minor.yy322,yymsp[-1].minor.yy122,0);}
break;
case 167: /* returning ::= RETURNING selcollist */
-{sqlite3AddReturning(pParse,yymsp[0].minor.yy368);}
+{sqlite3AddReturning(pParse,yymsp[0].minor.yy322);}
break;
case 171: /* idlist_opt ::= LP idlist RP */
-{yymsp[-2].minor.yy374 = yymsp[-1].minor.yy374;}
+{yymsp[-2].minor.yy80 = yymsp[-1].minor.yy80;}
break;
case 172: /* idlist ::= idlist COMMA nm */
-{yymsp[-2].minor.yy374 = sqlite3IdListAppend(pParse,yymsp[-2].minor.yy374,&yymsp[0].minor.yy0);}
+{yymsp[-2].minor.yy80 = sqlite3IdListAppend(pParse,yymsp[-2].minor.yy80,&yymsp[0].minor.yy0);}
break;
case 173: /* idlist ::= nm */
-{yymsp[0].minor.yy374 = sqlite3IdListAppend(pParse,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/}
+{yymsp[0].minor.yy80 = sqlite3IdListAppend(pParse,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/}
break;
case 174: /* expr ::= LP expr RP */
-{yymsp[-2].minor.yy454 = yymsp[-1].minor.yy454;}
+{yymsp[-2].minor.yy122 = yymsp[-1].minor.yy122;}
break;
case 175: /* expr ::= ID|INDEXED */
case 176: /* expr ::= JOIN_KW */ yytestcase(yyruleno==176);
-{yymsp[0].minor.yy454=tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/}
+{yymsp[0].minor.yy122=tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/}
break;
case 177: /* expr ::= nm DOT nm */
{
- Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
- Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[0].minor.yy0, 1);
- if( IN_RENAME_OBJECT ){
- sqlite3RenameTokenMap(pParse, (void*)temp2, &yymsp[0].minor.yy0);
- sqlite3RenameTokenMap(pParse, (void*)temp1, &yymsp[-2].minor.yy0);
- }
- yylhsminor.yy454 = sqlite3PExpr(pParse, TK_DOT, temp1, temp2);
+ Expr *temp1 = tokenExpr(pParse,TK_ID,yymsp[-2].minor.yy0);
+ Expr *temp2 = tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0);
+ yylhsminor.yy122 = sqlite3PExpr(pParse, TK_DOT, temp1, temp2);
}
- yymsp[-2].minor.yy454 = yylhsminor.yy454;
+ yymsp[-2].minor.yy122 = yylhsminor.yy122;
break;
case 178: /* expr ::= nm DOT nm DOT nm */
{
- Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-4].minor.yy0, 1);
- Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
- Expr *temp3 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[0].minor.yy0, 1);
+ Expr *temp1 = tokenExpr(pParse,TK_ID,yymsp[-4].minor.yy0);
+ Expr *temp2 = tokenExpr(pParse,TK_ID,yymsp[-2].minor.yy0);
+ Expr *temp3 = tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0);
Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3);
if( IN_RENAME_OBJECT ){
- sqlite3RenameTokenMap(pParse, (void*)temp3, &yymsp[0].minor.yy0);
- sqlite3RenameTokenMap(pParse, (void*)temp2, &yymsp[-2].minor.yy0);
+ sqlite3RenameTokenRemap(pParse, 0, temp1);
}
- yylhsminor.yy454 = sqlite3PExpr(pParse, TK_DOT, temp1, temp4);
+ yylhsminor.yy122 = sqlite3PExpr(pParse, TK_DOT, temp1, temp4);
}
- yymsp[-4].minor.yy454 = yylhsminor.yy454;
+ yymsp[-4].minor.yy122 = yylhsminor.yy122;
break;
case 179: /* term ::= NULL|FLOAT|BLOB */
case 180: /* term ::= STRING */ yytestcase(yyruleno==180);
-{yymsp[0].minor.yy454=tokenExpr(pParse,yymsp[0].major,yymsp[0].minor.yy0); /*A-overwrites-X*/}
+{yymsp[0].minor.yy122=tokenExpr(pParse,yymsp[0].major,yymsp[0].minor.yy0); /*A-overwrites-X*/}
break;
case 181: /* term ::= INTEGER */
{
- yylhsminor.yy454 = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &yymsp[0].minor.yy0, 1);
+ yylhsminor.yy122 = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &yymsp[0].minor.yy0, 1);
+ if( yylhsminor.yy122 ) yylhsminor.yy122->w.iOfst = (int)(yymsp[0].minor.yy0.z - pParse->zTail);
}
- yymsp[0].minor.yy454 = yylhsminor.yy454;
+ yymsp[0].minor.yy122 = yylhsminor.yy122;
break;
case 182: /* 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.yy454 = tokenExpr(pParse, TK_VARIABLE, yymsp[0].minor.yy0);
- sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy454, n);
+ yymsp[0].minor.yy122 = tokenExpr(pParse, TK_VARIABLE, yymsp[0].minor.yy0);
+ sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy122, 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
@@ -163429,51 +165293,51 @@ static YYACTIONTYPE yy_reduce(
assert( t.n>=2 );
if( pParse->nested==0 ){
sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", &t);
- yymsp[0].minor.yy454 = 0;
+ yymsp[0].minor.yy122 = 0;
}else{
- yymsp[0].minor.yy454 = sqlite3PExpr(pParse, TK_REGISTER, 0, 0);
- if( yymsp[0].minor.yy454 ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy454->iTable);
+ yymsp[0].minor.yy122 = sqlite3PExpr(pParse, TK_REGISTER, 0, 0);
+ if( yymsp[0].minor.yy122 ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy122->iTable);
}
}
}
break;
case 183: /* expr ::= expr COLLATE ID|STRING */
{
- yymsp[-2].minor.yy454 = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy454, &yymsp[0].minor.yy0, 1);
+ yymsp[-2].minor.yy122 = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy122, &yymsp[0].minor.yy0, 1);
}
break;
case 184: /* expr ::= CAST LP expr AS typetoken RP */
{
- yymsp[-5].minor.yy454 = sqlite3ExprAlloc(pParse->db, TK_CAST, &yymsp[-1].minor.yy0, 1);
- sqlite3ExprAttachSubtrees(pParse->db, yymsp[-5].minor.yy454, yymsp[-3].minor.yy454, 0);
+ yymsp[-5].minor.yy122 = sqlite3ExprAlloc(pParse->db, TK_CAST, &yymsp[-1].minor.yy0, 1);
+ sqlite3ExprAttachSubtrees(pParse->db, yymsp[-5].minor.yy122, yymsp[-3].minor.yy122, 0);
}
break;
case 185: /* expr ::= ID|INDEXED LP distinct exprlist RP */
{
- yylhsminor.yy454 = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy368, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy332);
+ yylhsminor.yy122 = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy322, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy452);
}
- yymsp[-4].minor.yy454 = yylhsminor.yy454;
+ yymsp[-4].minor.yy122 = yylhsminor.yy122;
break;
case 186: /* expr ::= ID|INDEXED LP STAR RP */
{
- yylhsminor.yy454 = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0, 0);
+ yylhsminor.yy122 = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0, 0);
}
- yymsp[-3].minor.yy454 = yylhsminor.yy454;
+ yymsp[-3].minor.yy122 = yylhsminor.yy122;
break;
case 187: /* term ::= CTIME_KW */
{
- yylhsminor.yy454 = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0, 0);
+ yylhsminor.yy122 = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0, 0);
}
- yymsp[0].minor.yy454 = yylhsminor.yy454;
+ yymsp[0].minor.yy122 = yylhsminor.yy122;
break;
case 188: /* expr ::= LP nexprlist COMMA expr RP */
{
- ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy368, yymsp[-1].minor.yy454);
- yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_VECTOR, 0, 0);
- if( yymsp[-4].minor.yy454 ){
- yymsp[-4].minor.yy454->x.pList = pList;
+ ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy322, yymsp[-1].minor.yy122);
+ yymsp[-4].minor.yy122 = sqlite3PExpr(pParse, TK_VECTOR, 0, 0);
+ if( yymsp[-4].minor.yy122 ){
+ yymsp[-4].minor.yy122->x.pList = pList;
if( ALWAYS(pList->nExpr) ){
- yymsp[-4].minor.yy454->flags |= pList->a[0].pExpr->flags & EP_Propagate;
+ yymsp[-4].minor.yy122->flags |= pList->a[0].pExpr->flags & EP_Propagate;
}
}else{
sqlite3ExprListDelete(pParse->db, pList);
@@ -163481,7 +165345,7 @@ static YYACTIONTYPE yy_reduce(
}
break;
case 189: /* expr ::= expr AND expr */
-{yymsp[-2].minor.yy454=sqlite3ExprAnd(pParse,yymsp[-2].minor.yy454,yymsp[0].minor.yy454);}
+{yymsp[-2].minor.yy122=sqlite3ExprAnd(pParse,yymsp[-2].minor.yy122,yymsp[0].minor.yy122);}
break;
case 190: /* expr ::= expr OR expr */
case 191: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==191);
@@ -163490,7 +165354,7 @@ static YYACTIONTYPE yy_reduce(
case 194: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==194);
case 195: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==195);
case 196: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==196);
-{yymsp[-2].minor.yy454=sqlite3PExpr(pParse,yymsp[-1].major,yymsp[-2].minor.yy454,yymsp[0].minor.yy454);}
+{yymsp[-2].minor.yy122=sqlite3PExpr(pParse,yymsp[-1].major,yymsp[-2].minor.yy122,yymsp[0].minor.yy122);}
break;
case 197: /* 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*/}
@@ -163500,11 +165364,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.yy454);
- pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy454);
- yymsp[-2].minor.yy454 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0, 0);
- if( bNot ) yymsp[-2].minor.yy454 = sqlite3PExpr(pParse, TK_NOT, yymsp[-2].minor.yy454, 0);
- if( yymsp[-2].minor.yy454 ) yymsp[-2].minor.yy454->flags |= EP_InfixFunc;
+ pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy122);
+ pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy122);
+ yymsp[-2].minor.yy122 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0, 0);
+ if( bNot ) yymsp[-2].minor.yy122 = sqlite3PExpr(pParse, TK_NOT, yymsp[-2].minor.yy122, 0);
+ if( yymsp[-2].minor.yy122 ) yymsp[-2].minor.yy122->flags |= EP_InfixFunc;
}
break;
case 199: /* expr ::= expr likeop expr ESCAPE expr */
@@ -163512,62 +165376,70 @@ 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.yy454);
- pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy454);
- pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy454);
- yymsp[-4].minor.yy454 = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy0, 0);
- if( bNot ) yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy454, 0);
- if( yymsp[-4].minor.yy454 ) yymsp[-4].minor.yy454->flags |= EP_InfixFunc;
+ pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy122);
+ pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy122);
+ pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy122);
+ yymsp[-4].minor.yy122 = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy0, 0);
+ if( bNot ) yymsp[-4].minor.yy122 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy122, 0);
+ if( yymsp[-4].minor.yy122 ) yymsp[-4].minor.yy122->flags |= EP_InfixFunc;
}
break;
case 200: /* expr ::= expr ISNULL|NOTNULL */
-{yymsp[-1].minor.yy454 = sqlite3PExpr(pParse,yymsp[0].major,yymsp[-1].minor.yy454,0);}
+{yymsp[-1].minor.yy122 = sqlite3PExpr(pParse,yymsp[0].major,yymsp[-1].minor.yy122,0);}
break;
case 201: /* expr ::= expr NOT NULL */
-{yymsp[-2].minor.yy454 = sqlite3PExpr(pParse,TK_NOTNULL,yymsp[-2].minor.yy454,0);}
+{yymsp[-2].minor.yy122 = sqlite3PExpr(pParse,TK_NOTNULL,yymsp[-2].minor.yy122,0);}
break;
case 202: /* expr ::= expr IS expr */
{
- yymsp[-2].minor.yy454 = sqlite3PExpr(pParse,TK_IS,yymsp[-2].minor.yy454,yymsp[0].minor.yy454);
- binaryToUnaryIfNull(pParse, yymsp[0].minor.yy454, yymsp[-2].minor.yy454, TK_ISNULL);
+ yymsp[-2].minor.yy122 = sqlite3PExpr(pParse,TK_IS,yymsp[-2].minor.yy122,yymsp[0].minor.yy122);
+ binaryToUnaryIfNull(pParse, yymsp[0].minor.yy122, yymsp[-2].minor.yy122, TK_ISNULL);
}
break;
case 203: /* expr ::= expr IS NOT expr */
{
- yymsp[-3].minor.yy454 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-3].minor.yy454,yymsp[0].minor.yy454);
- binaryToUnaryIfNull(pParse, yymsp[0].minor.yy454, yymsp[-3].minor.yy454, TK_NOTNULL);
+ yymsp[-3].minor.yy122 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-3].minor.yy122,yymsp[0].minor.yy122);
+ binaryToUnaryIfNull(pParse, yymsp[0].minor.yy122, yymsp[-3].minor.yy122, TK_NOTNULL);
}
break;
case 204: /* expr ::= NOT expr */
case 205: /* expr ::= BITNOT expr */ yytestcase(yyruleno==205);
-{yymsp[-1].minor.yy454 = sqlite3PExpr(pParse, yymsp[-1].major, yymsp[0].minor.yy454, 0);/*A-overwrites-B*/}
+{yymsp[-1].minor.yy122 = sqlite3PExpr(pParse, yymsp[-1].major, yymsp[0].minor.yy122, 0);/*A-overwrites-B*/}
break;
case 206: /* expr ::= PLUS|MINUS expr */
{
- yymsp[-1].minor.yy454 = sqlite3PExpr(pParse, yymsp[-1].major==TK_PLUS ? TK_UPLUS : TK_UMINUS, yymsp[0].minor.yy454, 0);
+ yymsp[-1].minor.yy122 = sqlite3PExpr(pParse, yymsp[-1].major==TK_PLUS ? TK_UPLUS : TK_UMINUS, yymsp[0].minor.yy122, 0);
/*A-overwrites-B*/
}
break;
- case 207: /* between_op ::= BETWEEN */
- case 210: /* in_op ::= IN */ yytestcase(yyruleno==210);
-{yymsp[0].minor.yy332 = 0;}
+ case 207: /* expr ::= expr PTR expr */
+{
+ ExprList *pList = sqlite3ExprListAppend(pParse, 0, yymsp[-2].minor.yy122);
+ pList = sqlite3ExprListAppend(pParse, pList, yymsp[0].minor.yy122);
+ yylhsminor.yy122 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0, 0);
+}
+ yymsp[-2].minor.yy122 = yylhsminor.yy122;
+ break;
+ case 208: /* between_op ::= BETWEEN */
+ case 211: /* in_op ::= IN */ yytestcase(yyruleno==211);
+{yymsp[0].minor.yy452 = 0;}
break;
- case 209: /* expr ::= expr between_op expr AND expr */
+ case 210: /* expr ::= expr between_op expr AND expr */
{
- ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy454);
- pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy454);
- yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy454, 0);
- if( yymsp[-4].minor.yy454 ){
- yymsp[-4].minor.yy454->x.pList = pList;
+ ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy122);
+ pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy122);
+ yymsp[-4].minor.yy122 = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy122, 0);
+ if( yymsp[-4].minor.yy122 ){
+ yymsp[-4].minor.yy122->x.pList = pList;
}else{
sqlite3ExprListDelete(pParse->db, pList);
}
- if( yymsp[-3].minor.yy332 ) yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy454, 0);
+ if( yymsp[-3].minor.yy452 ) yymsp[-4].minor.yy122 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy122, 0);
}
break;
- case 212: /* expr ::= expr in_op LP exprlist RP */
+ case 213: /* expr ::= expr in_op LP exprlist RP */
{
- if( yymsp[-1].minor.yy368==0 ){
+ if( yymsp[-1].minor.yy322==0 ){
/* Expressions of the form
**
** expr1 IN ()
@@ -163576,205 +165448,205 @@ static YYACTIONTYPE yy_reduce(
** simplify to constants 0 (false) and 1 (true), respectively,
** regardless of the value of expr1.
*/
- sqlite3ExprUnmapAndDelete(pParse, yymsp[-4].minor.yy454);
- yymsp[-4].minor.yy454 = sqlite3Expr(pParse->db, TK_INTEGER, yymsp[-3].minor.yy332 ? "1" : "0");
+ sqlite3ExprUnmapAndDelete(pParse, yymsp[-4].minor.yy122);
+ yymsp[-4].minor.yy122 = sqlite3Expr(pParse->db, TK_INTEGER, yymsp[-3].minor.yy452 ? "1" : "0");
}else{
- Expr *pRHS = yymsp[-1].minor.yy368->a[0].pExpr;
- if( yymsp[-1].minor.yy368->nExpr==1 && sqlite3ExprIsConstant(pRHS) && yymsp[-4].minor.yy454->op!=TK_VECTOR ){
- yymsp[-1].minor.yy368->a[0].pExpr = 0;
- sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy368);
+ Expr *pRHS = yymsp[-1].minor.yy322->a[0].pExpr;
+ if( yymsp[-1].minor.yy322->nExpr==1 && sqlite3ExprIsConstant(pRHS) && yymsp[-4].minor.yy122->op!=TK_VECTOR ){
+ yymsp[-1].minor.yy322->a[0].pExpr = 0;
+ sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy322);
pRHS = sqlite3PExpr(pParse, TK_UPLUS, pRHS, 0);
- yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_EQ, yymsp[-4].minor.yy454, pRHS);
+ yymsp[-4].minor.yy122 = sqlite3PExpr(pParse, TK_EQ, yymsp[-4].minor.yy122, pRHS);
}else{
- yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy454, 0);
- if( yymsp[-4].minor.yy454==0 ){
- sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy368);
- }else if( yymsp[-4].minor.yy454->pLeft->op==TK_VECTOR ){
- int nExpr = yymsp[-4].minor.yy454->pLeft->x.pList->nExpr;
- Select *pSelectRHS = sqlite3ExprListToValues(pParse, nExpr, yymsp[-1].minor.yy368);
+ yymsp[-4].minor.yy122 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy122, 0);
+ if( yymsp[-4].minor.yy122==0 ){
+ sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy322);
+ }else if( yymsp[-4].minor.yy122->pLeft->op==TK_VECTOR ){
+ int nExpr = yymsp[-4].minor.yy122->pLeft->x.pList->nExpr;
+ Select *pSelectRHS = sqlite3ExprListToValues(pParse, nExpr, yymsp[-1].minor.yy322);
if( pSelectRHS ){
parserDoubleLinkSelect(pParse, pSelectRHS);
- sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy454, pSelectRHS);
+ sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy122, pSelectRHS);
}
}else{
- yymsp[-4].minor.yy454->x.pList = yymsp[-1].minor.yy368;
- sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy454);
+ yymsp[-4].minor.yy122->x.pList = yymsp[-1].minor.yy322;
+ sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy122);
}
}
- if( yymsp[-3].minor.yy332 ) yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy454, 0);
+ if( yymsp[-3].minor.yy452 ) yymsp[-4].minor.yy122 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy122, 0);
}
}
break;
- case 213: /* expr ::= LP select RP */
+ case 214: /* expr ::= LP select RP */
{
- yymsp[-2].minor.yy454 = sqlite3PExpr(pParse, TK_SELECT, 0, 0);
- sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy454, yymsp[-1].minor.yy433);
+ yymsp[-2].minor.yy122 = sqlite3PExpr(pParse, TK_SELECT, 0, 0);
+ sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy122, yymsp[-1].minor.yy279);
}
break;
- case 214: /* expr ::= expr in_op LP select RP */
+ case 215: /* expr ::= expr in_op LP select RP */
{
- yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy454, 0);
- sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy454, yymsp[-1].minor.yy433);
- if( yymsp[-3].minor.yy332 ) yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy454, 0);
+ yymsp[-4].minor.yy122 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy122, 0);
+ sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy122, yymsp[-1].minor.yy279);
+ if( yymsp[-3].minor.yy452 ) yymsp[-4].minor.yy122 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy122, 0);
}
break;
- case 215: /* expr ::= expr in_op nm dbnm paren_exprlist */
+ case 216: /* expr ::= expr in_op nm dbnm paren_exprlist */
{
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.yy368 ) sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy368);
- yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy454, 0);
- sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy454, pSelect);
- if( yymsp[-3].minor.yy332 ) yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy454, 0);
+ if( yymsp[0].minor.yy322 ) sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy322);
+ yymsp[-4].minor.yy122 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy122, 0);
+ sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy122, pSelect);
+ if( yymsp[-3].minor.yy452 ) yymsp[-4].minor.yy122 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy122, 0);
}
break;
- case 216: /* expr ::= EXISTS LP select RP */
+ case 217: /* expr ::= EXISTS LP select RP */
{
Expr *p;
- p = yymsp[-3].minor.yy454 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0);
- sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy433);
+ p = yymsp[-3].minor.yy122 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0);
+ sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy279);
}
break;
- case 217: /* expr ::= CASE case_operand case_exprlist case_else END */
+ case 218: /* expr ::= CASE case_operand case_exprlist case_else END */
{
- yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy454, 0);
- if( yymsp[-4].minor.yy454 ){
- yymsp[-4].minor.yy454->x.pList = yymsp[-1].minor.yy454 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy368,yymsp[-1].minor.yy454) : yymsp[-2].minor.yy368;
- sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy454);
+ yymsp[-4].minor.yy122 = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy122, 0);
+ if( yymsp[-4].minor.yy122 ){
+ yymsp[-4].minor.yy122->x.pList = yymsp[-1].minor.yy122 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy322,yymsp[-1].minor.yy122) : yymsp[-2].minor.yy322;
+ sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy122);
}else{
- sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy368);
- sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy454);
+ sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy322);
+ sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy122);
}
}
break;
- case 218: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
+ case 219: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
{
- yymsp[-4].minor.yy368 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy368, yymsp[-2].minor.yy454);
- yymsp[-4].minor.yy368 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy368, yymsp[0].minor.yy454);
+ yymsp[-4].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy322, yymsp[-2].minor.yy122);
+ yymsp[-4].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy322, yymsp[0].minor.yy122);
}
break;
- case 219: /* case_exprlist ::= WHEN expr THEN expr */
+ case 220: /* case_exprlist ::= WHEN expr THEN expr */
{
- yymsp[-3].minor.yy368 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy454);
- yymsp[-3].minor.yy368 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy368, yymsp[0].minor.yy454);
+ yymsp[-3].minor.yy322 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy122);
+ yymsp[-3].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy322, yymsp[0].minor.yy122);
}
break;
- case 222: /* case_operand ::= expr */
-{yymsp[0].minor.yy454 = yymsp[0].minor.yy454; /*A-overwrites-X*/}
+ case 223: /* case_operand ::= expr */
+{yymsp[0].minor.yy122 = yymsp[0].minor.yy122; /*A-overwrites-X*/}
break;
- case 225: /* nexprlist ::= nexprlist COMMA expr */
-{yymsp[-2].minor.yy368 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy368,yymsp[0].minor.yy454);}
+ case 226: /* nexprlist ::= nexprlist COMMA expr */
+{yymsp[-2].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy322,yymsp[0].minor.yy122);}
break;
- case 226: /* nexprlist ::= expr */
-{yymsp[0].minor.yy368 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy454); /*A-overwrites-Y*/}
+ case 227: /* nexprlist ::= expr */
+{yymsp[0].minor.yy322 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy122); /*A-overwrites-Y*/}
break;
- case 228: /* paren_exprlist ::= LP exprlist RP */
- case 233: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==233);
-{yymsp[-2].minor.yy368 = yymsp[-1].minor.yy368;}
+ case 229: /* paren_exprlist ::= LP exprlist RP */
+ case 234: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==234);
+{yymsp[-2].minor.yy322 = yymsp[-1].minor.yy322;}
break;
- case 229: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
+ case 230: /* 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,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy368, yymsp[-10].minor.yy332,
- &yymsp[-11].minor.yy0, yymsp[0].minor.yy454, SQLITE_SO_ASC, yymsp[-8].minor.yy332, SQLITE_IDXTYPE_APPDEF);
+ sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy322, yymsp[-10].minor.yy452,
+ &yymsp[-11].minor.yy0, yymsp[0].minor.yy122, SQLITE_SO_ASC, yymsp[-8].minor.yy452, SQLITE_IDXTYPE_APPDEF);
if( IN_RENAME_OBJECT && pParse->pNewIndex ){
sqlite3RenameTokenMap(pParse, pParse->pNewIndex->zName, &yymsp[-4].minor.yy0);
}
}
break;
- case 230: /* uniqueflag ::= UNIQUE */
- case 272: /* raisetype ::= ABORT */ yytestcase(yyruleno==272);
-{yymsp[0].minor.yy332 = OE_Abort;}
+ case 231: /* uniqueflag ::= UNIQUE */
+ case 273: /* raisetype ::= ABORT */ yytestcase(yyruleno==273);
+{yymsp[0].minor.yy452 = OE_Abort;}
break;
- case 231: /* uniqueflag ::= */
-{yymsp[1].minor.yy332 = OE_None;}
+ case 232: /* uniqueflag ::= */
+{yymsp[1].minor.yy452 = OE_None;}
break;
- case 234: /* eidlist ::= eidlist COMMA nm collate sortorder */
+ case 235: /* eidlist ::= eidlist COMMA nm collate sortorder */
{
- yymsp[-4].minor.yy368 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy368, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy332, yymsp[0].minor.yy332);
+ yymsp[-4].minor.yy322 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy322, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy452, yymsp[0].minor.yy452);
}
break;
- case 235: /* eidlist ::= nm collate sortorder */
+ case 236: /* eidlist ::= nm collate sortorder */
{
- yymsp[-2].minor.yy368 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy332, yymsp[0].minor.yy332); /*A-overwrites-Y*/
+ yymsp[-2].minor.yy322 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy452, yymsp[0].minor.yy452); /*A-overwrites-Y*/
}
break;
- case 238: /* cmd ::= DROP INDEX ifexists fullname */
-{sqlite3DropIndex(pParse, yymsp[0].minor.yy155, yymsp[-1].minor.yy332);}
+ case 239: /* cmd ::= DROP INDEX ifexists fullname */
+{sqlite3DropIndex(pParse, yymsp[0].minor.yy247, yymsp[-1].minor.yy452);}
break;
- case 239: /* cmd ::= VACUUM vinto */
-{sqlite3Vacuum(pParse,0,yymsp[0].minor.yy454);}
+ case 240: /* cmd ::= VACUUM vinto */
+{sqlite3Vacuum(pParse,0,yymsp[0].minor.yy122);}
break;
- case 240: /* cmd ::= VACUUM nm vinto */
-{sqlite3Vacuum(pParse,&yymsp[-1].minor.yy0,yymsp[0].minor.yy454);}
+ case 241: /* cmd ::= VACUUM nm vinto */
+{sqlite3Vacuum(pParse,&yymsp[-1].minor.yy0,yymsp[0].minor.yy122);}
break;
- case 243: /* cmd ::= PRAGMA nm dbnm */
+ case 244: /* cmd ::= PRAGMA nm dbnm */
{sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);}
break;
- case 244: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
+ case 245: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
{sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);}
break;
- case 245: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
+ case 246: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
{sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);}
break;
- case 246: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
+ case 247: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
{sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);}
break;
- case 247: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */
+ case 248: /* 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 250: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
+ case 251: /* 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.yy387, &all);
+ sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy207, &all);
}
break;
- case 251: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
+ case 252: /* 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.yy332, yymsp[-4].minor.yy96.a, yymsp[-4].minor.yy96.b, yymsp[-2].minor.yy155, yymsp[0].minor.yy454, yymsp[-10].minor.yy332, yymsp[-8].minor.yy332);
+ sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy452, yymsp[-4].minor.yy470.a, yymsp[-4].minor.yy470.b, yymsp[-2].minor.yy247, yymsp[0].minor.yy122, yymsp[-10].minor.yy452, yymsp[-8].minor.yy452);
yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/
}
break;
- case 252: /* trigger_time ::= BEFORE|AFTER */
-{ yymsp[0].minor.yy332 = yymsp[0].major; /*A-overwrites-X*/ }
+ case 253: /* trigger_time ::= BEFORE|AFTER */
+{ yymsp[0].minor.yy452 = yymsp[0].major; /*A-overwrites-X*/ }
break;
- case 253: /* trigger_time ::= INSTEAD OF */
-{ yymsp[-1].minor.yy332 = TK_INSTEAD;}
+ case 254: /* trigger_time ::= INSTEAD OF */
+{ yymsp[-1].minor.yy452 = TK_INSTEAD;}
break;
- case 254: /* trigger_time ::= */
-{ yymsp[1].minor.yy332 = TK_BEFORE; }
+ case 255: /* trigger_time ::= */
+{ yymsp[1].minor.yy452 = TK_BEFORE; }
break;
- case 255: /* trigger_event ::= DELETE|INSERT */
- case 256: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==256);
-{yymsp[0].minor.yy96.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy96.b = 0;}
+ case 256: /* trigger_event ::= DELETE|INSERT */
+ case 257: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==257);
+{yymsp[0].minor.yy470.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy470.b = 0;}
break;
- case 257: /* trigger_event ::= UPDATE OF idlist */
-{yymsp[-2].minor.yy96.a = TK_UPDATE; yymsp[-2].minor.yy96.b = yymsp[0].minor.yy374;}
+ case 258: /* trigger_event ::= UPDATE OF idlist */
+{yymsp[-2].minor.yy470.a = TK_UPDATE; yymsp[-2].minor.yy470.b = yymsp[0].minor.yy80;}
break;
- case 258: /* when_clause ::= */
- case 277: /* key_opt ::= */ yytestcase(yyruleno==277);
-{ yymsp[1].minor.yy454 = 0; }
+ case 259: /* when_clause ::= */
+ case 278: /* key_opt ::= */ yytestcase(yyruleno==278);
+{ yymsp[1].minor.yy122 = 0; }
break;
- case 259: /* when_clause ::= WHEN expr */
- case 278: /* key_opt ::= KEY expr */ yytestcase(yyruleno==278);
-{ yymsp[-1].minor.yy454 = yymsp[0].minor.yy454; }
+ case 260: /* when_clause ::= WHEN expr */
+ case 279: /* key_opt ::= KEY expr */ yytestcase(yyruleno==279);
+{ yymsp[-1].minor.yy122 = yymsp[0].minor.yy122; }
break;
- case 260: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
+ case 261: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
{
- assert( yymsp[-2].minor.yy387!=0 );
- yymsp[-2].minor.yy387->pLast->pNext = yymsp[-1].minor.yy387;
- yymsp[-2].minor.yy387->pLast = yymsp[-1].minor.yy387;
+ assert( yymsp[-2].minor.yy207!=0 );
+ yymsp[-2].minor.yy207->pLast->pNext = yymsp[-1].minor.yy207;
+ yymsp[-2].minor.yy207->pLast = yymsp[-1].minor.yy207;
}
break;
- case 261: /* trigger_cmd_list ::= trigger_cmd SEMI */
+ case 262: /* trigger_cmd_list ::= trigger_cmd SEMI */
{
- assert( yymsp[-1].minor.yy387!=0 );
- yymsp[-1].minor.yy387->pLast = yymsp[-1].minor.yy387;
+ assert( yymsp[-1].minor.yy207!=0 );
+ yymsp[-1].minor.yy207->pLast = yymsp[-1].minor.yy207;
}
break;
- case 262: /* trnm ::= nm DOT nm */
+ case 263: /* trnm ::= nm DOT nm */
{
yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;
sqlite3ErrorMsg(pParse,
@@ -163782,211 +165654,211 @@ static YYACTIONTYPE yy_reduce(
"statements within triggers");
}
break;
- case 263: /* tridxby ::= INDEXED BY nm */
+ case 264: /* tridxby ::= INDEXED BY nm */
{
sqlite3ErrorMsg(pParse,
"the INDEXED BY clause is not allowed on UPDATE or DELETE statements "
"within triggers");
}
break;
- case 264: /* tridxby ::= NOT INDEXED */
+ case 265: /* tridxby ::= NOT INDEXED */
{
sqlite3ErrorMsg(pParse,
"the NOT INDEXED clause is not allowed on UPDATE or DELETE statements "
"within triggers");
}
break;
- case 265: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */
-{yylhsminor.yy387 = sqlite3TriggerUpdateStep(pParse, &yymsp[-6].minor.yy0, yymsp[-2].minor.yy155, yymsp[-3].minor.yy368, yymsp[-1].minor.yy454, yymsp[-7].minor.yy332, yymsp[-8].minor.yy0.z, yymsp[0].minor.yy70);}
- yymsp[-8].minor.yy387 = yylhsminor.yy387;
+ case 266: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */
+{yylhsminor.yy207 = sqlite3TriggerUpdateStep(pParse, &yymsp[-6].minor.yy0, yymsp[-2].minor.yy247, yymsp[-3].minor.yy322, yymsp[-1].minor.yy122, yymsp[-7].minor.yy452, yymsp[-8].minor.yy0.z, yymsp[0].minor.yy116);}
+ yymsp[-8].minor.yy207 = yylhsminor.yy207;
break;
- case 266: /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
+ case 267: /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
{
- yylhsminor.yy387 = sqlite3TriggerInsertStep(pParse,&yymsp[-4].minor.yy0,yymsp[-3].minor.yy374,yymsp[-2].minor.yy433,yymsp[-6].minor.yy332,yymsp[-1].minor.yy232,yymsp[-7].minor.yy70,yymsp[0].minor.yy70);/*yylhsminor.yy387-overwrites-yymsp[-6].minor.yy332*/
+ yylhsminor.yy207 = sqlite3TriggerInsertStep(pParse,&yymsp[-4].minor.yy0,yymsp[-3].minor.yy80,yymsp[-2].minor.yy279,yymsp[-6].minor.yy452,yymsp[-1].minor.yy38,yymsp[-7].minor.yy116,yymsp[0].minor.yy116);/*yylhsminor.yy207-overwrites-yymsp[-6].minor.yy452*/
}
- yymsp[-7].minor.yy387 = yylhsminor.yy387;
+ yymsp[-7].minor.yy207 = yylhsminor.yy207;
break;
- case 267: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
-{yylhsminor.yy387 = sqlite3TriggerDeleteStep(pParse, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy454, yymsp[-5].minor.yy0.z, yymsp[0].minor.yy70);}
- yymsp[-5].minor.yy387 = yylhsminor.yy387;
+ case 268: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
+{yylhsminor.yy207 = sqlite3TriggerDeleteStep(pParse, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy122, yymsp[-5].minor.yy0.z, yymsp[0].minor.yy116);}
+ yymsp[-5].minor.yy207 = yylhsminor.yy207;
break;
- case 268: /* trigger_cmd ::= scanpt select scanpt */
-{yylhsminor.yy387 = sqlite3TriggerSelectStep(pParse->db, yymsp[-1].minor.yy433, yymsp[-2].minor.yy70, yymsp[0].minor.yy70); /*yylhsminor.yy387-overwrites-yymsp[-1].minor.yy433*/}
- yymsp[-2].minor.yy387 = yylhsminor.yy387;
+ case 269: /* trigger_cmd ::= scanpt select scanpt */
+{yylhsminor.yy207 = sqlite3TriggerSelectStep(pParse->db, yymsp[-1].minor.yy279, yymsp[-2].minor.yy116, yymsp[0].minor.yy116); /*yylhsminor.yy207-overwrites-yymsp[-1].minor.yy279*/}
+ yymsp[-2].minor.yy207 = yylhsminor.yy207;
break;
- case 269: /* expr ::= RAISE LP IGNORE RP */
+ case 270: /* expr ::= RAISE LP IGNORE RP */
{
- yymsp[-3].minor.yy454 = sqlite3PExpr(pParse, TK_RAISE, 0, 0);
- if( yymsp[-3].minor.yy454 ){
- yymsp[-3].minor.yy454->affExpr = OE_Ignore;
+ yymsp[-3].minor.yy122 = sqlite3PExpr(pParse, TK_RAISE, 0, 0);
+ if( yymsp[-3].minor.yy122 ){
+ yymsp[-3].minor.yy122->affExpr = OE_Ignore;
}
}
break;
- case 270: /* expr ::= RAISE LP raisetype COMMA nm RP */
+ case 271: /* expr ::= RAISE LP raisetype COMMA nm RP */
{
- yymsp[-5].minor.yy454 = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1);
- if( yymsp[-5].minor.yy454 ) {
- yymsp[-5].minor.yy454->affExpr = (char)yymsp[-3].minor.yy332;
+ yymsp[-5].minor.yy122 = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1);
+ if( yymsp[-5].minor.yy122 ) {
+ yymsp[-5].minor.yy122->affExpr = (char)yymsp[-3].minor.yy452;
}
}
break;
- case 271: /* raisetype ::= ROLLBACK */
-{yymsp[0].minor.yy332 = OE_Rollback;}
+ case 272: /* raisetype ::= ROLLBACK */
+{yymsp[0].minor.yy452 = OE_Rollback;}
break;
- case 273: /* raisetype ::= FAIL */
-{yymsp[0].minor.yy332 = OE_Fail;}
+ case 274: /* raisetype ::= FAIL */
+{yymsp[0].minor.yy452 = OE_Fail;}
break;
- case 274: /* cmd ::= DROP TRIGGER ifexists fullname */
+ case 275: /* cmd ::= DROP TRIGGER ifexists fullname */
{
- sqlite3DropTrigger(pParse,yymsp[0].minor.yy155,yymsp[-1].minor.yy332);
+ sqlite3DropTrigger(pParse,yymsp[0].minor.yy247,yymsp[-1].minor.yy452);
}
break;
- case 275: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
+ case 276: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
{
- sqlite3Attach(pParse, yymsp[-3].minor.yy454, yymsp[-1].minor.yy454, yymsp[0].minor.yy454);
+ sqlite3Attach(pParse, yymsp[-3].minor.yy122, yymsp[-1].minor.yy122, yymsp[0].minor.yy122);
}
break;
- case 276: /* cmd ::= DETACH database_kw_opt expr */
+ case 277: /* cmd ::= DETACH database_kw_opt expr */
{
- sqlite3Detach(pParse, yymsp[0].minor.yy454);
+ sqlite3Detach(pParse, yymsp[0].minor.yy122);
}
break;
- case 279: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
+ case 280: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
{
- sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy155,&yymsp[0].minor.yy0);
+ sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy247,&yymsp[0].minor.yy0);
}
break;
- case 280: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
+ case 281: /* 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 281: /* cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */
+ case 282: /* cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */
{
- sqlite3AlterDropColumn(pParse, yymsp[-3].minor.yy155, &yymsp[0].minor.yy0);
+ sqlite3AlterDropColumn(pParse, yymsp[-3].minor.yy247, &yymsp[0].minor.yy0);
}
break;
- case 282: /* add_column_fullname ::= fullname */
+ case 283: /* add_column_fullname ::= fullname */
{
disableLookaside(pParse);
- sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy155);
+ sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy247);
}
break;
- case 283: /* cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
+ case 284: /* cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
{
- sqlite3AlterRenameColumn(pParse, yymsp[-5].minor.yy155, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);
+ sqlite3AlterRenameColumn(pParse, yymsp[-5].minor.yy247, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);
}
break;
- case 284: /* cmd ::= create_vtab */
+ case 285: /* cmd ::= create_vtab */
{sqlite3VtabFinishParse(pParse,0);}
break;
- case 285: /* cmd ::= create_vtab LP vtabarglist RP */
+ case 286: /* cmd ::= create_vtab LP vtabarglist RP */
{sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}
break;
- case 286: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
+ case 287: /* 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.yy332);
+ sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy452);
}
break;
- case 287: /* vtabarg ::= */
+ case 288: /* vtabarg ::= */
{sqlite3VtabArgInit(pParse);}
break;
- case 288: /* vtabargtoken ::= ANY */
- case 289: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==289);
- case 290: /* lp ::= LP */ yytestcase(yyruleno==290);
+ case 289: /* vtabargtoken ::= ANY */
+ case 290: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==290);
+ case 291: /* lp ::= LP */ yytestcase(yyruleno==291);
{sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}
break;
- case 291: /* with ::= WITH wqlist */
- case 292: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==292);
-{ sqlite3WithPush(pParse, yymsp[0].minor.yy23, 1); }
+ case 292: /* with ::= WITH wqlist */
+ case 293: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==293);
+{ sqlite3WithPush(pParse, yymsp[0].minor.yy231, 1); }
break;
- case 293: /* wqas ::= AS */
-{yymsp[0].minor.yy478 = M10d_Any;}
+ case 294: /* wqas ::= AS */
+{yymsp[0].minor.yy458 = M10d_Any;}
break;
- case 294: /* wqas ::= AS MATERIALIZED */
-{yymsp[-1].minor.yy478 = M10d_Yes;}
+ case 295: /* wqas ::= AS MATERIALIZED */
+{yymsp[-1].minor.yy458 = M10d_Yes;}
break;
- case 295: /* wqas ::= AS NOT MATERIALIZED */
-{yymsp[-2].minor.yy478 = M10d_No;}
+ case 296: /* wqas ::= AS NOT MATERIALIZED */
+{yymsp[-2].minor.yy458 = M10d_No;}
break;
- case 296: /* wqitem ::= nm eidlist_opt wqas LP select RP */
+ case 297: /* wqitem ::= nm eidlist_opt wqas LP select RP */
{
- yymsp[-5].minor.yy259 = sqlite3CteNew(pParse, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy368, yymsp[-1].minor.yy433, yymsp[-3].minor.yy478); /*A-overwrites-X*/
+ yymsp[-5].minor.yy559 = sqlite3CteNew(pParse, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy322, yymsp[-1].minor.yy279, yymsp[-3].minor.yy458); /*A-overwrites-X*/
}
break;
- case 297: /* wqlist ::= wqitem */
+ case 298: /* wqlist ::= wqitem */
{
- yymsp[0].minor.yy23 = sqlite3WithAdd(pParse, 0, yymsp[0].minor.yy259); /*A-overwrites-X*/
+ yymsp[0].minor.yy231 = sqlite3WithAdd(pParse, 0, yymsp[0].minor.yy559); /*A-overwrites-X*/
}
break;
- case 298: /* wqlist ::= wqlist COMMA wqitem */
+ case 299: /* wqlist ::= wqlist COMMA wqitem */
{
- yymsp[-2].minor.yy23 = sqlite3WithAdd(pParse, yymsp[-2].minor.yy23, yymsp[0].minor.yy259);
+ yymsp[-2].minor.yy231 = sqlite3WithAdd(pParse, yymsp[-2].minor.yy231, yymsp[0].minor.yy559);
}
break;
default:
- /* (299) input ::= cmdlist */ yytestcase(yyruleno==299);
- /* (300) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==300);
- /* (301) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=301);
- /* (302) ecmd ::= SEMI */ yytestcase(yyruleno==302);
- /* (303) ecmd ::= cmdx SEMI */ yytestcase(yyruleno==303);
- /* (304) trans_opt ::= */ yytestcase(yyruleno==304);
- /* (305) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==305);
- /* (306) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==306);
- /* (307) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==307);
- /* (308) savepoint_opt ::= */ yytestcase(yyruleno==308);
- /* (309) cmd ::= create_table create_table_args */ yytestcase(yyruleno==309);
- /* (310) table_option_set ::= table_option (OPTIMIZED OUT) */ assert(yyruleno!=310);
- /* (311) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==311);
- /* (312) columnlist ::= columnname carglist */ yytestcase(yyruleno==312);
- /* (313) nm ::= ID|INDEXED */ yytestcase(yyruleno==313);
- /* (314) nm ::= STRING */ yytestcase(yyruleno==314);
- /* (315) nm ::= JOIN_KW */ yytestcase(yyruleno==315);
- /* (316) typetoken ::= typename */ yytestcase(yyruleno==316);
- /* (317) typename ::= ID|STRING */ yytestcase(yyruleno==317);
- /* (318) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=318);
- /* (319) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=319);
- /* (320) carglist ::= carglist ccons */ yytestcase(yyruleno==320);
- /* (321) carglist ::= */ yytestcase(yyruleno==321);
- /* (322) ccons ::= NULL onconf */ yytestcase(yyruleno==322);
- /* (323) ccons ::= GENERATED ALWAYS AS generated */ yytestcase(yyruleno==323);
- /* (324) ccons ::= AS generated */ yytestcase(yyruleno==324);
- /* (325) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==325);
- /* (326) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==326);
- /* (327) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=327);
- /* (328) tconscomma ::= */ yytestcase(yyruleno==328);
- /* (329) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=329);
- /* (330) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=330);
- /* (331) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=331);
- /* (332) oneselect ::= values */ yytestcase(yyruleno==332);
- /* (333) sclp ::= selcollist COMMA */ yytestcase(yyruleno==333);
- /* (334) as ::= ID|STRING */ yytestcase(yyruleno==334);
- /* (335) returning ::= */ yytestcase(yyruleno==335);
- /* (336) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=336);
- /* (337) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==337);
- /* (338) exprlist ::= nexprlist */ yytestcase(yyruleno==338);
- /* (339) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=339);
- /* (340) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=340);
- /* (341) nmnum ::= ON */ yytestcase(yyruleno==341);
- /* (342) nmnum ::= DELETE */ yytestcase(yyruleno==342);
- /* (343) nmnum ::= DEFAULT */ yytestcase(yyruleno==343);
- /* (344) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==344);
- /* (345) foreach_clause ::= */ yytestcase(yyruleno==345);
- /* (346) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==346);
- /* (347) trnm ::= nm */ yytestcase(yyruleno==347);
- /* (348) tridxby ::= */ yytestcase(yyruleno==348);
- /* (349) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==349);
- /* (350) database_kw_opt ::= */ yytestcase(yyruleno==350);
- /* (351) kwcolumn_opt ::= */ yytestcase(yyruleno==351);
- /* (352) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==352);
- /* (353) vtabarglist ::= vtabarg */ yytestcase(yyruleno==353);
- /* (354) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==354);
- /* (355) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==355);
- /* (356) anylist ::= */ yytestcase(yyruleno==356);
- /* (357) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==357);
- /* (358) anylist ::= anylist ANY */ yytestcase(yyruleno==358);
- /* (359) with ::= */ yytestcase(yyruleno==359);
+ /* (300) input ::= cmdlist */ yytestcase(yyruleno==300);
+ /* (301) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==301);
+ /* (302) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=302);
+ /* (303) ecmd ::= SEMI */ yytestcase(yyruleno==303);
+ /* (304) ecmd ::= cmdx SEMI */ yytestcase(yyruleno==304);
+ /* (305) trans_opt ::= */ yytestcase(yyruleno==305);
+ /* (306) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==306);
+ /* (307) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==307);
+ /* (308) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==308);
+ /* (309) savepoint_opt ::= */ yytestcase(yyruleno==309);
+ /* (310) cmd ::= create_table create_table_args */ yytestcase(yyruleno==310);
+ /* (311) table_option_set ::= table_option (OPTIMIZED OUT) */ assert(yyruleno!=311);
+ /* (312) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==312);
+ /* (313) columnlist ::= columnname carglist */ yytestcase(yyruleno==313);
+ /* (314) nm ::= ID|INDEXED */ yytestcase(yyruleno==314);
+ /* (315) nm ::= STRING */ yytestcase(yyruleno==315);
+ /* (316) nm ::= JOIN_KW */ yytestcase(yyruleno==316);
+ /* (317) typetoken ::= typename */ yytestcase(yyruleno==317);
+ /* (318) typename ::= ID|STRING */ yytestcase(yyruleno==318);
+ /* (319) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=319);
+ /* (320) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=320);
+ /* (321) carglist ::= carglist ccons */ yytestcase(yyruleno==321);
+ /* (322) carglist ::= */ yytestcase(yyruleno==322);
+ /* (323) ccons ::= NULL onconf */ yytestcase(yyruleno==323);
+ /* (324) ccons ::= GENERATED ALWAYS AS generated */ yytestcase(yyruleno==324);
+ /* (325) ccons ::= AS generated */ yytestcase(yyruleno==325);
+ /* (326) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==326);
+ /* (327) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==327);
+ /* (328) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=328);
+ /* (329) tconscomma ::= */ yytestcase(yyruleno==329);
+ /* (330) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=330);
+ /* (331) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=331);
+ /* (332) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=332);
+ /* (333) oneselect ::= values */ yytestcase(yyruleno==333);
+ /* (334) sclp ::= selcollist COMMA */ yytestcase(yyruleno==334);
+ /* (335) as ::= ID|STRING */ yytestcase(yyruleno==335);
+ /* (336) returning ::= */ yytestcase(yyruleno==336);
+ /* (337) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=337);
+ /* (338) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==338);
+ /* (339) exprlist ::= nexprlist */ yytestcase(yyruleno==339);
+ /* (340) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=340);
+ /* (341) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=341);
+ /* (342) nmnum ::= ON */ yytestcase(yyruleno==342);
+ /* (343) nmnum ::= DELETE */ yytestcase(yyruleno==343);
+ /* (344) nmnum ::= DEFAULT */ yytestcase(yyruleno==344);
+ /* (345) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==345);
+ /* (346) foreach_clause ::= */ yytestcase(yyruleno==346);
+ /* (347) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==347);
+ /* (348) trnm ::= nm */ yytestcase(yyruleno==348);
+ /* (349) tridxby ::= */ yytestcase(yyruleno==349);
+ /* (350) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==350);
+ /* (351) database_kw_opt ::= */ yytestcase(yyruleno==351);
+ /* (352) kwcolumn_opt ::= */ yytestcase(yyruleno==352);
+ /* (353) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==353);
+ /* (354) vtabarglist ::= vtabarg */ yytestcase(yyruleno==354);
+ /* (355) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==355);
+ /* (356) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==356);
+ /* (357) anylist ::= */ yytestcase(yyruleno==357);
+ /* (358) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==358);
+ /* (359) anylist ::= anylist ANY */ yytestcase(yyruleno==359);
+ /* (360) with ::= */ yytestcase(yyruleno==360);
break;
/********** End reduce actions ************************************************/
};
@@ -165073,6 +166945,9 @@ SQLITE_PRIVATE int sqlite3GetToken(const unsigned char *z, int *tokenType){
for(i=2; (c=z[i])!=0 && c!='\n'; i++){}
*tokenType = TK_SPACE; /* IMP: R-22934-25134 */
return i;
+ }else if( z[1]=='>' ){
+ *tokenType = TK_PTR;
+ return 2 + (z[2]=='>');
}
*tokenType = TK_MINUS;
return 1;
@@ -165342,13 +167217,9 @@ SQLITE_PRIVATE int sqlite3GetToken(const unsigned char *z, int *tokenType){
}
/*
-** Run the parser on the given SQL string. The parser structure is
-** passed in. An SQLITE_ status code is returned. If an error occurs
-** then an and attempt is made to write an error message into
-** memory obtained from sqlite3_malloc() and to make *pzErrMsg point to that
-** error message.
+** Run the parser on the given SQL string.
*/
-SQLITE_PRIVATE int sqlite3RunParser(Parse *pParse, const char *zSql, char **pzErrMsg){
+SQLITE_PRIVATE int sqlite3RunParser(Parse *pParse, const char *zSql){
int nErr = 0; /* Number of errors encountered */
void *pEngine; /* The LEMON-generated LALR(1) parser */
int n = 0; /* Length of the next token token */
@@ -165369,7 +167240,6 @@ SQLITE_PRIVATE int sqlite3RunParser(Parse *pParse, const char *zSql, char **pzEr
}
pParse->rc = SQLITE_OK;
pParse->zTail = zSql;
- assert( pzErrMsg!=0 );
#ifdef SQLITE_DEBUG
if( db->flags & SQLITE_ParserTrace ){
printf("parser: [[[%s]]]\n", zSql);
@@ -165412,6 +167282,7 @@ SQLITE_PRIVATE int sqlite3RunParser(Parse *pParse, const char *zSql, char **pzEr
#endif /* SQLITE_OMIT_WINDOWFUNC */
if( AtomicLoad(&db->u1.isInterrupted) ){
pParse->rc = SQLITE_INTERRUPT;
+ pParse->nErr++;
break;
}
if( tokenType==TK_SPACE ){
@@ -165441,7 +167312,10 @@ SQLITE_PRIVATE int sqlite3RunParser(Parse *pParse, const char *zSql, char **pzEr
tokenType = analyzeFilterKeyword((const u8*)&zSql[6], lastTokenParsed);
#endif /* SQLITE_OMIT_WINDOWFUNC */
}else{
- sqlite3ErrorMsg(pParse, "unrecognized token: \"%.*s\"", n, zSql);
+ Token x;
+ x.z = zSql;
+ x.n = n;
+ sqlite3ErrorMsg(pParse, "unrecognized token: \"%T\"", &x);
break;
}
}
@@ -165469,41 +167343,26 @@ SQLITE_PRIVATE int sqlite3RunParser(Parse *pParse, const char *zSql, char **pzEr
if( db->mallocFailed ){
pParse->rc = SQLITE_NOMEM_BKPT;
}
- if( pParse->rc!=SQLITE_OK && pParse->rc!=SQLITE_DONE && pParse->zErrMsg==0 ){
- pParse->zErrMsg = sqlite3MPrintf(db, "%s", sqlite3ErrStr(pParse->rc));
- }
- assert( pzErrMsg!=0 );
- if( pParse->zErrMsg ){
- *pzErrMsg = pParse->zErrMsg;
- sqlite3_log(pParse->rc, "%s in \"%s\"",
- *pzErrMsg, pParse->zTail);
- pParse->zErrMsg = 0;
+ if( pParse->zErrMsg || (pParse->rc!=SQLITE_OK && pParse->rc!=SQLITE_DONE) ){
+ if( pParse->zErrMsg==0 ){
+ pParse->zErrMsg = sqlite3MPrintf(db, "%s", sqlite3ErrStr(pParse->rc));
+ }
+ sqlite3_log(pParse->rc, "%s in \"%s\"", pParse->zErrMsg, pParse->zTail);
nErr++;
}
pParse->zTail = zSql;
- if( pParse->pVdbe && pParse->nErr>0 && pParse->nested==0 ){
- sqlite3VdbeDelete(pParse->pVdbe);
- pParse->pVdbe = 0;
- }
-#ifndef SQLITE_OMIT_SHARED_CACHE
- if( pParse->nested==0 ){
- sqlite3DbFree(db, pParse->aTableLock);
- pParse->aTableLock = 0;
- pParse->nTableLock = 0;
- }
-#endif
#ifndef SQLITE_OMIT_VIRTUALTABLE
sqlite3_free(pParse->apVtabLock);
#endif
- if( !IN_SPECIAL_PARSE ){
+ if( pParse->pNewTable && !IN_SPECIAL_PARSE ){
/* If the pParse->declareVtab flag is set, do not delete any table
** structure built up in pParse->pNewTable. The calling code (see vtab.c)
** will take responsibility for freeing the Table structure.
*/
sqlite3DeleteTable(db, pParse->pNewTable);
}
- if( !IN_RENAME_OBJECT ){
+ if( pParse->pNewTrigger && !IN_RENAME_OBJECT ){
sqlite3DeleteTrigger(db, pParse->pNewTrigger);
}
sqlite3DbFree(db, pParse->pVList);
@@ -166088,9 +167947,6 @@ SQLITE_PRIVATE int sqlite3Fts2Init(sqlite3*);
#ifdef SQLITE_ENABLE_FTS5
SQLITE_PRIVATE int sqlite3Fts5Init(sqlite3*);
#endif
-#ifdef SQLITE_ENABLE_JSON1
-SQLITE_PRIVATE int sqlite3Json1Init(sqlite3*);
-#endif
#ifdef SQLITE_ENABLE_STMTVTAB
SQLITE_PRIVATE int sqlite3StmtVtabInit(sqlite3*);
#endif
@@ -166125,8 +167981,8 @@ static int (*const sqlite3BuiltinExtensions[])(sqlite3*) = {
sqlite3DbstatRegister,
#endif
sqlite3TestExtInit,
-#ifdef SQLITE_ENABLE_JSON1
- sqlite3Json1Init,
+#if !defined(SQLITE_OMIT_VIRTUALTABLE) && !defined(SQLITE_OMIT_JSON)
+ sqlite3JsonTableFunctions,
#endif
#ifdef SQLITE_ENABLE_STMTVTAB
sqlite3StmtVtabInit,
@@ -168635,6 +170491,19 @@ SQLITE_API const char *sqlite3_errmsg(sqlite3 *db){
return z;
}
+/*
+** Return the byte offset of the most recent error
+*/
+SQLITE_API int sqlite3_error_offset(sqlite3 *db){
+ int iOffset = -1;
+ if( db && sqlite3SafetyCheckSickOrOk(db) && db->errCode ){
+ sqlite3_mutex_enter(db->mutex);
+ iOffset = db->errByteOffset;
+ sqlite3_mutex_leave(db->mutex);
+ }
+ return iOffset;
+}
+
#ifndef SQLITE_OMIT_UTF16
/*
** Return UTF-16 encoded English language explanation of the most recent
@@ -170057,12 +171926,16 @@ SQLITE_API int sqlite3_test_control(int op, ...){
** sqlite3_test_control().
*/
case SQLITE_TESTCTRL_FAULT_INSTALL: {
- /* MSVC is picky about pulling func ptrs from va lists.
- ** http://support.microsoft.com/kb/47961
+ /* A bug in MSVC prevents it from understanding pointers to functions
+ ** types in the second argument to va_arg(). Work around the problem
+ ** using a typedef.
+ ** http://support.microsoft.com/kb/47961 <-- dead hyperlink
+ ** Search at http://web.archive.org/ to find the 2015-03-16 archive
+ ** of the link above to see the original text.
** sqlite3GlobalConfig.xTestCallback = va_arg(ap, int(*)(int));
*/
- typedef int(*TESTCALLBACKFUNC_t)(int);
- sqlite3GlobalConfig.xTestCallback = va_arg(ap, TESTCALLBACKFUNC_t);
+ typedef int(*sqlite3FaultFuncType)(int);
+ sqlite3GlobalConfig.xTestCallback = va_arg(ap, sqlite3FaultFuncType);
rc = sqlite3FaultSim(0);
break;
}
@@ -170189,13 +172062,27 @@ SQLITE_API int sqlite3_test_control(int op, ...){
break;
}
- /* sqlite3_test_control(SQLITE_TESTCTRL_LOCALTIME_FAULT, int onoff);
+ /* sqlite3_test_control(SQLITE_TESTCTRL_LOCALTIME_FAULT, onoff, xAlt);
+ **
+ ** If parameter onoff is 1, subsequent calls to localtime() fail.
+ ** If 2, then invoke xAlt() instead of localtime(). If 0, normal
+ ** processing.
+ **
+ ** xAlt arguments are void pointers, but they really want to be:
**
- ** If parameter onoff is non-zero, subsequent calls to localtime()
- ** and its variants fail. If onoff is zero, undo this setting.
+ ** int xAlt(const time_t*, struct tm*);
+ **
+ ** xAlt should write results in to struct tm object of its 2nd argument
+ ** and return zero on success, or return non-zero on failure.
*/
case SQLITE_TESTCTRL_LOCALTIME_FAULT: {
sqlite3GlobalConfig.bLocaltimeFault = va_arg(ap, int);
+ if( sqlite3GlobalConfig.bLocaltimeFault==2 ){
+ typedef int(*sqlite3LocaltimeType)(const void*,void*);
+ sqlite3GlobalConfig.xAltLocaltime = va_arg(ap, sqlite3LocaltimeType);
+ }else{
+ sqlite3GlobalConfig.xAltLocaltime = 0;
+ }
break;
}
@@ -170385,6 +172272,26 @@ SQLITE_API int sqlite3_test_control(int op, ...){
break;
}
+ /* sqlite3_test_control(SQLITE_TESTCTRL_LOGEST,
+ ** double fIn, // Input value
+ ** int *pLogEst, // sqlite3LogEstFromDouble(fIn)
+ ** u64 *pInt, // sqlite3LogEstToInt(*pLogEst)
+ ** int *pLogEst2 // sqlite3LogEst(*pInt)
+ ** );
+ **
+ ** Test access for the LogEst conversion routines.
+ */
+ case SQLITE_TESTCTRL_LOGEST: {
+ double rIn = va_arg(ap, double);
+ LogEst rLogEst = sqlite3LogEstFromDouble(rIn);
+ u64 iInt = sqlite3LogEstToInt(rLogEst);
+ va_arg(ap, int*)[0] = rLogEst;
+ va_arg(ap, u64*)[0] = iInt;
+ va_arg(ap, int*)[0] = sqlite3LogEst(iInt);
+ break;
+ }
+
+
#if defined(SQLITE_DEBUG) && !defined(SQLITE_OMIT_WSD)
/* sqlite3_test_control(SQLITE_TESTCTRL_TUNE, id, *piValue)
**
@@ -172365,7 +174272,7 @@ SQLITE_PRIVATE int sqlite3Fts3MsrOvfl(Fts3Cursor *, Fts3MultiSegReader *, int *)
SQLITE_PRIVATE int sqlite3Fts3MsrIncrRestart(Fts3MultiSegReader *pCsr);
/* fts3_tokenize_vtab.c */
-SQLITE_PRIVATE int sqlite3Fts3InitTok(sqlite3*, Fts3Hash *);
+SQLITE_PRIVATE int sqlite3Fts3InitTok(sqlite3*, Fts3Hash *, void(*xDestroy)(void*));
/* fts3_unicode2.c (functions generated by parsing unicode text files) */
#ifndef SQLITE_DISABLE_FTS3_UNICODE
@@ -172398,6 +174305,12 @@ SQLITE_PRIVATE int sqlite3FtsUnicodeIsdiacritic(int);
SQLITE_EXTENSION_INIT1
#endif
+typedef struct Fts3HashWrapper Fts3HashWrapper;
+struct Fts3HashWrapper {
+ Fts3Hash hash; /* Hash table */
+ int nRef; /* Number of pointers to this object */
+};
+
static int fts3EvalNext(Fts3Cursor *pCsr);
static int fts3EvalStart(Fts3Cursor *pCsr);
static int fts3TermSegReaderCursor(
@@ -173262,7 +175175,7 @@ static int fts3InitVtab(
sqlite3_vtab **ppVTab, /* Write the resulting vtab structure here */
char **pzErr /* Write any error message here */
){
- Fts3Hash *pHash = (Fts3Hash *)pAux;
+ Fts3Hash *pHash = &((Fts3HashWrapper*)pAux)->hash;
Fts3Table *p = 0; /* Pointer to allocated vtab */
int rc = SQLITE_OK; /* Return code */
int i; /* Iterator variable */
@@ -176097,9 +178010,12 @@ static const sqlite3_module fts3Module = {
** allocated for the tokenizer hash table.
*/
static void hashDestroy(void *p){
- Fts3Hash *pHash = (Fts3Hash *)p;
- sqlite3Fts3HashClear(pHash);
- sqlite3_free(pHash);
+ Fts3HashWrapper *pHash = (Fts3HashWrapper *)p;
+ pHash->nRef--;
+ if( pHash->nRef<=0 ){
+ sqlite3Fts3HashClear(&pHash->hash);
+ sqlite3_free(pHash);
+ }
}
/*
@@ -176129,7 +178045,7 @@ SQLITE_PRIVATE void sqlite3Fts3IcuTokenizerModule(sqlite3_tokenizer_module const
*/
SQLITE_PRIVATE int sqlite3Fts3Init(sqlite3 *db){
int rc = SQLITE_OK;
- Fts3Hash *pHash = 0;
+ Fts3HashWrapper *pHash = 0;
const sqlite3_tokenizer_module *pSimple = 0;
const sqlite3_tokenizer_module *pPorter = 0;
#ifndef SQLITE_DISABLE_FTS3_UNICODE
@@ -176157,23 +178073,24 @@ SQLITE_PRIVATE int sqlite3Fts3Init(sqlite3 *db){
sqlite3Fts3PorterTokenizerModule(&pPorter);
/* Allocate and initialize the hash-table used to store tokenizers. */
- pHash = sqlite3_malloc(sizeof(Fts3Hash));
+ pHash = sqlite3_malloc(sizeof(Fts3HashWrapper));
if( !pHash ){
rc = SQLITE_NOMEM;
}else{
- sqlite3Fts3HashInit(pHash, FTS3_HASH_STRING, 1);
+ sqlite3Fts3HashInit(&pHash->hash, FTS3_HASH_STRING, 1);
+ pHash->nRef = 0;
}
/* Load the built-in tokenizers into the hash table */
if( rc==SQLITE_OK ){
- if( sqlite3Fts3HashInsert(pHash, "simple", 7, (void *)pSimple)
- || sqlite3Fts3HashInsert(pHash, "porter", 7, (void *)pPorter)
+ if( sqlite3Fts3HashInsert(&pHash->hash, "simple", 7, (void *)pSimple)
+ || sqlite3Fts3HashInsert(&pHash->hash, "porter", 7, (void *)pPorter)
#ifndef SQLITE_DISABLE_FTS3_UNICODE
- || sqlite3Fts3HashInsert(pHash, "unicode61", 10, (void *)pUnicode)
+ || sqlite3Fts3HashInsert(&pHash->hash, "unicode61", 10, (void *)pUnicode)
#endif
#ifdef SQLITE_ENABLE_ICU
- || (pIcu && sqlite3Fts3HashInsert(pHash, "icu", 4, (void *)pIcu))
+ || (pIcu && sqlite3Fts3HashInsert(&pHash->hash, "icu", 4, (void *)pIcu))
#endif
){
rc = SQLITE_NOMEM;
@@ -176182,7 +178099,7 @@ SQLITE_PRIVATE int sqlite3Fts3Init(sqlite3 *db){
#ifdef SQLITE_TEST
if( rc==SQLITE_OK ){
- rc = sqlite3Fts3ExprInitTestInterface(db, pHash);
+ rc = sqlite3Fts3ExprInitTestInterface(db, &pHash->hash);
}
#endif
@@ -176191,23 +178108,26 @@ SQLITE_PRIVATE int sqlite3Fts3Init(sqlite3 *db){
** module with sqlite.
*/
if( SQLITE_OK==rc
- && SQLITE_OK==(rc = sqlite3Fts3InitHashTable(db, pHash, "fts3_tokenizer"))
+ && SQLITE_OK==(rc=sqlite3Fts3InitHashTable(db,&pHash->hash,"fts3_tokenizer"))
&& 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))
&& SQLITE_OK==(rc = sqlite3_overload_function(db, "matchinfo", 2))
&& SQLITE_OK==(rc = sqlite3_overload_function(db, "optimize", 1))
){
+ pHash->nRef++;
rc = sqlite3_create_module_v2(
db, "fts3", &fts3Module, (void *)pHash, hashDestroy
);
if( rc==SQLITE_OK ){
+ pHash->nRef++;
rc = sqlite3_create_module_v2(
- db, "fts4", &fts3Module, (void *)pHash, 0
+ db, "fts4", &fts3Module, (void *)pHash, hashDestroy
);
}
if( rc==SQLITE_OK ){
- rc = sqlite3Fts3InitTok(db, (void *)pHash);
+ pHash->nRef++;
+ rc = sqlite3Fts3InitTok(db, (void *)pHash, hashDestroy);
}
return rc;
}
@@ -176216,7 +178136,7 @@ SQLITE_PRIVATE int sqlite3Fts3Init(sqlite3 *db){
/* An error has occurred. Delete the hash table and return the error code. */
assert( rc!=SQLITE_OK );
if( pHash ){
- sqlite3Fts3HashClear(pHash);
+ sqlite3Fts3HashClear(&pHash->hash);
sqlite3_free(pHash);
}
return rc;
@@ -182280,7 +184200,7 @@ static int fts3tokRowidMethod(
** Register the fts3tok module with database connection db. Return SQLITE_OK
** if successful or an error code if sqlite3_create_module() fails.
*/
-SQLITE_PRIVATE int sqlite3Fts3InitTok(sqlite3 *db, Fts3Hash *pHash){
+SQLITE_PRIVATE int sqlite3Fts3InitTok(sqlite3 *db, Fts3Hash *pHash, void(*xDestroy)(void*)){
static const sqlite3_module fts3tok_module = {
0, /* iVersion */
fts3tokConnectMethod, /* xCreate */
@@ -182309,7 +184229,9 @@ SQLITE_PRIVATE int sqlite3Fts3InitTok(sqlite3 *db, Fts3Hash *pHash){
};
int rc; /* Return code */
- rc = sqlite3_create_module(db, "fts3tokenize", &fts3tok_module, (void*)pHash);
+ rc = sqlite3_create_module_v2(
+ db, "fts3tokenize", &fts3tok_module, (void*)pHash, xDestroy
+ );
return rc;
}
@@ -190668,7 +192590,7 @@ SQLITE_PRIVATE int sqlite3FtsUnicodeFold(int c, int eRemoveDiacritic){
#endif /* !defined(SQLITE_DISABLE_FTS3_UNICODE) */
/************** End of fts3_unicode2.c ***************************************/
-/************** Begin file json1.c *******************************************/
+/************** Begin file json.c ********************************************/
/*
** 2015-08-12
**
@@ -190681,10 +192603,10 @@ SQLITE_PRIVATE int sqlite3FtsUnicodeFold(int c, int eRemoveDiacritic){
**
******************************************************************************
**
-** This SQLite extension implements JSON functions. The interface is
-** modeled after MySQL JSON functions:
+** This SQLite JSON functions.
**
-** https://dev.mysql.com/doc/refman/5.7/en/json.html
+** This file began as an extension in ext/misc/json1.c in 2015. That
+** extension proved so useful that it has now been moved into the core.
**
** For the time being, all JSON is stored as pure text. (We might add
** a JSONB type in the future which stores a binary encoding of JSON in
@@ -190692,48 +192614,8 @@ SQLITE_PRIVATE int sqlite3FtsUnicodeFold(int c, int eRemoveDiacritic){
** This implementation parses JSON text at 250 MB/s, so it is hard to see
** how JSONB might improve on that.)
*/
-#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_JSON1)
-#if !defined(SQLITEINT_H)
-/* #include "sqlite3ext.h" */
-#endif
-SQLITE_EXTENSION_INIT1
-/* #include <assert.h> */
-/* #include <string.h> */
-/* #include <stdlib.h> */
-/* #include <stdarg.h> */
-
-/* Mark a function parameter as unused, to suppress nuisance compiler
-** warnings. */
-#ifndef UNUSED_PARAM
-# define UNUSED_PARAM(X) (void)(X)
-#endif
-
-#ifndef LARGEST_INT64
-# define LARGEST_INT64 (0xffffffff|(((sqlite3_int64)0x7fffffff)<<32))
-# define SMALLEST_INT64 (((sqlite3_int64)-1) - LARGEST_INT64)
-#endif
-
-#ifndef deliberate_fall_through
-# define deliberate_fall_through
-#endif
-
-/*
-** Versions of isspace(), isalnum() and isdigit() to which it is safe
-** to pass signed char values.
-*/
-#ifdef sqlite3Isdigit
- /* Use the SQLite core versions if this routine is part of the
- ** SQLite amalgamation */
-# define safe_isdigit(x) sqlite3Isdigit(x)
-# define safe_isalnum(x) sqlite3Isalnum(x)
-# define safe_isxdigit(x) sqlite3Isxdigit(x)
-#else
- /* Use the standard library for separate compilation */
-#include <ctype.h> /* amalgamator: keep */
-# define safe_isdigit(x) isdigit((unsigned char)(x))
-# define safe_isalnum(x) isalnum((unsigned char)(x))
-# define safe_isxdigit(x) isxdigit((unsigned char)(x))
-#endif
+#ifndef SQLITE_OMIT_JSON
+/* #include "sqliteInt.h" */
/*
** Growing our own isspace() routine this way is twice as fast as
@@ -190758,44 +192640,14 @@ static const char jsonIsSpace[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
};
-#define safe_isspace(x) (jsonIsSpace[(unsigned char)x])
+#define fast_isspace(x) (jsonIsSpace[(unsigned char)x])
-#ifndef SQLITE_AMALGAMATION
- /* Unsigned integer types. These are already defined in the sqliteInt.h,
- ** but the definitions need to be repeated for separate compilation. */
- typedef sqlite3_uint64 u64;
- typedef unsigned int u32;
- typedef unsigned short int u16;
- typedef unsigned char u8;
-# if defined(SQLITE_COVERAGE_TEST) || defined(SQLITE_MUTATION_TEST)
-# define SQLITE_OMIT_AUXILIARY_SAFETY_CHECKS 1
-# endif
-# if defined(SQLITE_OMIT_AUXILIARY_SAFETY_CHECKS)
-# define ALWAYS(X) (1)
-# define NEVER(X) (0)
-# elif !defined(NDEBUG)
-# define ALWAYS(X) ((X)?1:(assert(0),0))
-# define NEVER(X) ((X)?(assert(0),1):0)
-# else
-# define ALWAYS(X) (X)
-# define NEVER(X) (X)
-# endif
-# define testcase(X)
-#endif
#if !defined(SQLITE_DEBUG) && !defined(SQLITE_COVERAGE_TEST)
# define VVA(X)
#else
# define VVA(X) X
#endif
-/*
-** Some of the testcase() macros in this file are problematic for gcov
-** in that they generate false-miss errors randomly. This is a gcov problem,
-** not a problem in this case. But to work around it, we disable the
-** problematic test cases for production builds.
-*/
-#define json_testcase(X)
-
/* Objects */
typedef struct JsonString JsonString;
typedef struct JsonNode JsonNode;
@@ -191253,10 +193105,10 @@ static u8 jsonHexToInt(int h){
*/
static u32 jsonHexToInt4(const char *z){
u32 v;
- assert( safe_isxdigit(z[0]) );
- assert( safe_isxdigit(z[1]) );
- assert( safe_isxdigit(z[2]) );
- assert( safe_isxdigit(z[3]) );
+ assert( sqlite3Isxdigit(z[0]) );
+ assert( sqlite3Isxdigit(z[1]) );
+ assert( sqlite3Isxdigit(z[2]) );
+ assert( sqlite3Isxdigit(z[3]) );
v = (jsonHexToInt(z[0])<<12)
+ (jsonHexToInt(z[1])<<8)
+ (jsonHexToInt(z[2])<<4)
@@ -191491,7 +193343,7 @@ static int jsonParseAddNode(
*/
static int jsonIs4Hex(const char *z){
int i;
- for(i=0; i<4; i++) if( !safe_isxdigit(z[i]) ) return 0;
+ for(i=0; i<4; i++) if( !sqlite3Isxdigit(z[i]) ) return 0;
return 1;
}
@@ -191510,13 +193362,13 @@ static int jsonParseValue(JsonParse *pParse, u32 i){
int x;
JsonNode *pNode;
const char *z = pParse->zJson;
- while( safe_isspace(z[i]) ){ i++; }
+ while( fast_isspace(z[i]) ){ i++; }
if( (c = z[i])=='{' ){
/* Parse object */
iThis = jsonParseAddNode(pParse, JSON_OBJECT, 0, 0);
if( iThis<0 ) return -1;
for(j=i+1;;j++){
- while( safe_isspace(z[j]) ){ j++; }
+ while( fast_isspace(z[j]) ){ j++; }
if( ++pParse->iDepth > JSON_MAX_DEPTH ) return -1;
x = jsonParseValue(pParse, j);
if( x<0 ){
@@ -191529,14 +193381,14 @@ static int jsonParseValue(JsonParse *pParse, u32 i){
if( pNode->eType!=JSON_STRING ) return -1;
pNode->jnFlags |= JNODE_LABEL;
j = x;
- while( safe_isspace(z[j]) ){ j++; }
+ while( fast_isspace(z[j]) ){ j++; }
if( z[j]!=':' ) return -1;
j++;
x = jsonParseValue(pParse, j);
pParse->iDepth--;
if( x<0 ) return -1;
j = x;
- while( safe_isspace(z[j]) ){ j++; }
+ while( fast_isspace(z[j]) ){ j++; }
c = z[j];
if( c==',' ) continue;
if( c!='}' ) return -1;
@@ -191550,7 +193402,7 @@ static int jsonParseValue(JsonParse *pParse, u32 i){
if( iThis<0 ) return -1;
memset(&pParse->aNode[iThis].u, 0, sizeof(pParse->aNode[iThis].u));
for(j=i+1;;j++){
- while( safe_isspace(z[j]) ){ j++; }
+ while( fast_isspace(z[j]) ){ j++; }
if( ++pParse->iDepth > JSON_MAX_DEPTH ) return -1;
x = jsonParseValue(pParse, j);
pParse->iDepth--;
@@ -191559,7 +193411,7 @@ static int jsonParseValue(JsonParse *pParse, u32 i){
return -1;
}
j = x;
- while( safe_isspace(z[j]) ){ j++; }
+ while( fast_isspace(z[j]) ){ j++; }
c = z[j];
if( c==',' ) continue;
if( c!=']' ) return -1;
@@ -191596,17 +193448,17 @@ static int jsonParseValue(JsonParse *pParse, u32 i){
return j+1;
}else if( c=='n'
&& strncmp(z+i,"null",4)==0
- && !safe_isalnum(z[i+4]) ){
+ && !sqlite3Isalnum(z[i+4]) ){
jsonParseAddNode(pParse, JSON_NULL, 0, 0);
return i+4;
}else if( c=='t'
&& strncmp(z+i,"true",4)==0
- && !safe_isalnum(z[i+4]) ){
+ && !sqlite3Isalnum(z[i+4]) ){
jsonParseAddNode(pParse, JSON_TRUE, 0, 0);
return i+4;
}else if( c=='f'
&& strncmp(z+i,"false",5)==0
- && !safe_isalnum(z[i+5]) ){
+ && !sqlite3Isalnum(z[i+5]) ){
jsonParseAddNode(pParse, JSON_FALSE, 0, 0);
return i+5;
}else if( c=='-' || (c>='0' && c<='9') ){
@@ -191677,7 +193529,7 @@ static int jsonParse(
if( pParse->oom ) i = -1;
if( i>0 ){
assert( pParse->iDepth==0 );
- while( safe_isspace(zJson[i]) ) i++;
+ while( fast_isspace(zJson[i]) ) i++;
if( zJson[i] ) i = -1;
}
if( i<=0 ){
@@ -191905,7 +193757,7 @@ static JsonNode *jsonLookupStep(
}else if( zPath[0]=='[' ){
i = 0;
j = 1;
- while( safe_isdigit(zPath[j]) ){
+ while( sqlite3Isdigit(zPath[j]) ){
i = i*10 + zPath[j] - '0';
j++;
}
@@ -191926,13 +193778,13 @@ static JsonNode *jsonLookupStep(
j = 1;
}
j = 2;
- if( zPath[2]=='-' && safe_isdigit(zPath[3]) ){
+ if( zPath[2]=='-' && sqlite3Isdigit(zPath[3]) ){
unsigned int x = 0;
j = 3;
do{
x = x*10 + zPath[j] - '0';
j++;
- }while( safe_isdigit(zPath[j]) );
+ }while( sqlite3Isdigit(zPath[j]) );
if( x>i ) return 0;
i -= x;
}
@@ -192151,7 +194003,7 @@ static void jsonTest1Func(
int argc,
sqlite3_value **argv
){
- UNUSED_PARAM(argc);
+ UNUSED_PARAMETER(argc);
sqlite3_result_int(ctx, sqlite3_value_subtype(argv[0])==JSON_SUBTYPE);
}
#endif /* SQLITE_DEBUG */
@@ -192172,7 +194024,7 @@ static void jsonQuoteFunc(
sqlite3_value **argv
){
JsonString jx;
- UNUSED_PARAM(argc);
+ UNUSED_PARAMETER(argc);
jsonInit(&jx, ctx);
jsonAppendValue(&jx, argv[0]);
@@ -192244,12 +194096,33 @@ static void jsonArrayLengthFunc(
}
/*
+** Bit values for the flags passed into jsonExtractFunc() or
+** jsonSetFunc() via the user-data value.
+*/
+#define JSON_JSON 0x01 /* Result is always JSON */
+#define JSON_SQL 0x02 /* Result is always SQL */
+#define JSON_ABPATH 0x03 /* Allow abbreviated JSON path specs */
+#define JSON_ISSET 0x04 /* json_set(), not json_insert() */
+
+/*
** json_extract(JSON, PATH, ...)
+** "->"(JSON,PATH)
+** "->>"(JSON,PATH)
**
-** Return the element described by PATH. Return NULL if there is no
-** PATH element. If there are multiple PATHs, then return a JSON array
-** with the result from each path. Throw an error if the JSON or any PATH
-** is malformed.
+** Return the element described by PATH. Return NULL if that PATH element
+** is not found.
+**
+** If JSON_JSON is set or if more that one PATH argument is supplied then
+** always return a JSON representation of the result. If JSON_SQL is set,
+** then always return an SQL representation of the result. If neither flag
+** is present and argc==2, then return JSON for objects and arrays and SQL
+** for all other values.
+**
+** When multiple PATH arguments are supplied, the result is a JSON array
+** containing the result of each PATH.
+**
+** Abbreviated JSON path expressions are allows if JSON_ABPATH, for
+** compatibility with PG.
*/
static void jsonExtractFunc(
sqlite3_context *ctx,
@@ -192259,35 +194132,77 @@ static void jsonExtractFunc(
JsonParse *p; /* The parse */
JsonNode *pNode;
const char *zPath;
+ int flags = SQLITE_PTR_TO_INT(sqlite3_user_data(ctx));
JsonString jx;
- int i;
if( argc<2 ) return;
p = jsonParseCached(ctx, argv, ctx);
if( p==0 ) return;
- jsonInit(&jx, ctx);
- jsonAppendChar(&jx, '[');
- for(i=1; i<argc; i++){
- zPath = (const char*)sqlite3_value_text(argv[i]);
- pNode = jsonLookup(p, zPath, 0, ctx);
- if( p->nErr ) break;
- if( argc>2 ){
+ if( argc==2 ){
+ /* With a single PATH argument */
+ zPath = (const char*)sqlite3_value_text(argv[1]);
+ if( zPath==0 ) return;
+ if( flags & JSON_ABPATH ){
+ if( zPath[0]!='$' ){
+ /* The -> and ->> operators accept abbreviated PATH arguments. This
+ ** is mostly for compatibility with PostgreSQL, but also for
+ ** convenience.
+ **
+ ** NUMBER ==> $[NUMBER] // PG compatible
+ ** LABEL ==> $.LABEL // PG compatible
+ ** [NUMBER] ==> $[NUMBER] // Not PG. Purely for convenience
+ */
+ jsonInit(&jx, ctx);
+ if( sqlite3Isdigit(zPath[0]) ){
+ jsonAppendRaw(&jx, "$[", 2);
+ jsonAppendRaw(&jx, zPath, (int)strlen(zPath));
+ jsonAppendRaw(&jx, "]", 2);
+ }else{
+ jsonAppendRaw(&jx, "$.", 1 + (zPath[0]!='['));
+ jsonAppendRaw(&jx, zPath, (int)strlen(zPath));
+ jsonAppendChar(&jx, 0);
+ }
+ pNode = jx.bErr ? 0 : jsonLookup(p, jx.zBuf, 0, ctx);
+ jsonReset(&jx);
+ }else{
+ pNode = jsonLookup(p, zPath, 0, ctx);
+ }
+ if( pNode ){
+ if( flags & JSON_JSON ){
+ jsonReturnJson(pNode, ctx, 0);
+ }else{
+ jsonReturn(pNode, ctx, 0);
+ sqlite3_result_subtype(ctx, 0);
+ }
+ }
+ }else{
+ pNode = jsonLookup(p, zPath, 0, ctx);
+ if( p->nErr==0 && pNode ) jsonReturn(pNode, ctx, 0);
+ }
+ }else{
+ /* Two or more PATH arguments results in a JSON array with each
+ ** element of the array being the value selected by one of the PATHs */
+ int i;
+ jsonInit(&jx, ctx);
+ jsonAppendChar(&jx, '[');
+ for(i=1; i<argc; i++){
+ zPath = (const char*)sqlite3_value_text(argv[i]);
+ pNode = jsonLookup(p, zPath, 0, ctx);
+ if( p->nErr ) break;
jsonAppendSeparator(&jx);
if( pNode ){
jsonRenderNode(pNode, &jx, 0);
}else{
jsonAppendRaw(&jx, "null", 4);
}
- }else if( pNode ){
- jsonReturn(pNode, ctx, 0);
}
+ if( i==argc ){
+ jsonAppendChar(&jx, ']');
+ jsonResult(&jx);
+ sqlite3_result_subtype(ctx, JSON_SUBTYPE);
+ }
+ jsonReset(&jx);
}
- if( argc>2 && i==argc ){
- jsonAppendChar(&jx, ']');
- jsonResult(&jx);
- sqlite3_result_subtype(ctx, JSON_SUBTYPE);
- }
- jsonReset(&jx);
}
/* This is the RFC 7396 MergePatch algorithm.
@@ -192383,7 +194298,7 @@ static void jsonPatchFunc(
JsonParse y; /* The patch */
JsonNode *pResult; /* The result of the merge */
- UNUSED_PARAM(argc);
+ UNUSED_PARAMETER(argc);
if( jsonParse(&x, ctx, (const char*)sqlite3_value_text(argv[0])) ) return;
if( jsonParse(&y, ctx, (const char*)sqlite3_value_text(argv[1])) ){
jsonParseReset(&x);
@@ -192504,7 +194419,7 @@ static void jsonReplaceFunc(
if( x.nErr ) goto replace_err;
if( pNode ){
assert( pNode->eU==0 || pNode->eU==1 || pNode->eU==4 );
- json_testcase( pNode->eU!=0 && pNode->eU!=1 );
+ testcase( pNode->eU!=0 && pNode->eU!=1 );
pNode->jnFlags |= (u8)JNODE_REPLACE;
VVA( pNode->eU = 4 );
pNode->u.iReplace = i + 1;
@@ -192520,6 +194435,7 @@ replace_err:
jsonParseReset(&x);
}
+
/*
** json_set(JSON, PATH, VALUE, ...)
**
@@ -192542,7 +194458,7 @@ static void jsonSetFunc(
const char *zPath;
u32 i;
int bApnd;
- int bIsSet = *(int*)sqlite3_user_data(ctx);
+ int bIsSet = sqlite3_user_data(ctx)!=0;
if( argc<1 ) return;
if( (argc&1)==0 ) {
@@ -192561,8 +194477,8 @@ static void jsonSetFunc(
}else if( x.nErr ){
goto jsonSetDone;
}else if( pNode && (bApnd || bIsSet) ){
- json_testcase( pNode->eU!=0 && pNode->eU!=1 && pNode->eU!=4 );
- assert( pNode->eU!=3 || pNode->eU!=5 );
+ testcase( pNode->eU!=0 && pNode->eU!=1 );
+ assert( pNode->eU!=3 && pNode->eU!=5 );
VVA( pNode->eU = 4 );
pNode->jnFlags |= (u8)JNODE_REPLACE;
pNode->u.iReplace = i + 1;
@@ -192582,8 +194498,8 @@ jsonSetDone:
** json_type(JSON)
** json_type(JSON, PATH)
**
-** Return the top-level "type" of a JSON string. Throw an error if
-** either the JSON or PATH inputs are not well-formed.
+** Return the top-level "type" of a JSON string. json_type() raises an
+** error if either the JSON or PATH inputs are not well-formed.
*/
static void jsonTypeFunc(
sqlite3_context *ctx,
@@ -192619,7 +194535,7 @@ static void jsonValidFunc(
sqlite3_value **argv
){
JsonParse *p; /* The parse */
- UNUSED_PARAM(argc);
+ UNUSED_PARAMETER(argc);
p = jsonParseCached(ctx, argv, 0);
sqlite3_result_int(ctx, p!=0);
}
@@ -192639,7 +194555,7 @@ static void jsonArrayStep(
sqlite3_value **argv
){
JsonString *pStr;
- UNUSED_PARAM(argc);
+ UNUSED_PARAMETER(argc);
pStr = (JsonString*)sqlite3_aggregate_context(ctx, sizeof(*pStr));
if( pStr ){
if( pStr->zBuf==0 ){
@@ -192699,8 +194615,8 @@ static void jsonGroupInverse(
char *z;
char c;
JsonString *pStr;
- UNUSED_PARAM(argc);
- UNUSED_PARAM(argv);
+ UNUSED_PARAMETER(argc);
+ UNUSED_PARAMETER(argv);
pStr = (JsonString*)sqlite3_aggregate_context(ctx, 0);
#ifdef NEVER
/* pStr is always non-NULL since jsonArrayStep() or jsonObjectStep() will
@@ -192744,7 +194660,7 @@ static void jsonObjectStep(
JsonString *pStr;
const char *z;
u32 n;
- UNUSED_PARAM(argc);
+ UNUSED_PARAMETER(argc);
pStr = (JsonString*)sqlite3_aggregate_context(ctx, sizeof(*pStr));
if( pStr ){
if( pStr->zBuf==0 ){
@@ -192835,10 +194751,10 @@ static int jsonEachConnect(
#define JEACH_JSON 8
#define JEACH_ROOT 9
- UNUSED_PARAM(pzErr);
- UNUSED_PARAM(argv);
- UNUSED_PARAM(argc);
- UNUSED_PARAM(pAux);
+ UNUSED_PARAMETER(pzErr);
+ UNUSED_PARAMETER(argv);
+ UNUSED_PARAMETER(argc);
+ UNUSED_PARAMETER(pAux);
rc = sqlite3_declare_vtab(db,
"CREATE TABLE x(key,value,type,atom,id,parent,fullkey,path,"
"json HIDDEN,root HIDDEN)");
@@ -192861,7 +194777,7 @@ static int jsonEachDisconnect(sqlite3_vtab *pVtab){
static int jsonEachOpenEach(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor){
JsonEachCursor *pCur;
- UNUSED_PARAM(p);
+ UNUSED_PARAMETER(p);
pCur = sqlite3_malloc( sizeof(*pCur) );
if( pCur==0 ) return SQLITE_NOMEM;
memset(pCur, 0, sizeof(*pCur));
@@ -192921,7 +194837,7 @@ static int jsonEachNext(sqlite3_vtab_cursor *cur){
p->eType = pUp->eType;
if( pUp->eType==JSON_ARRAY ){
assert( pUp->eU==0 || pUp->eU==3 );
- json_testcase( pUp->eU==3 );
+ testcase( pUp->eU==3 );
VVA( pUp->eU = 3 );
if( iUp==p->i-1 ){
pUp->u.iKey = 0;
@@ -193108,7 +195024,7 @@ static int jsonEachBestIndex(
/* This implementation assumes that JSON and ROOT are the last two
** columns in the table */
assert( JEACH_ROOT == JEACH_JSON+1 );
- UNUSED_PARAM(tab);
+ UNUSED_PARAMETER(tab);
aIdx[0] = aIdx[1] = -1;
pConstraint = pIdxInfo->aConstraint;
for(i=0; i<pIdxInfo->nConstraint; i++, pConstraint++){
@@ -193164,8 +195080,8 @@ static int jsonEachFilter(
const char *zRoot = 0;
sqlite3_int64 n;
- UNUSED_PARAM(idxStr);
- UNUSED_PARAM(argc);
+ UNUSED_PARAMETER(idxStr);
+ UNUSED_PARAMETER(argc);
jsonEachCursorReset(p);
if( idxNum==0 ) return SQLITE_OK;
z = (const char*)sqlite3_value_text(argv[0]);
@@ -193290,108 +195206,68 @@ static sqlite3_module jsonTreeModule = {
0 /* xShadowName */
};
#endif /* SQLITE_OMIT_VIRTUALTABLE */
-
-/****************************************************************************
-** The following routines are the only publically visible identifiers in this
-** file. Call the following routines in order to register the various SQL
-** functions and the virtual table implemented by this file.
-****************************************************************************/
-
-SQLITE_PRIVATE int sqlite3Json1Init(sqlite3 *db){
- int rc = SQLITE_OK;
- unsigned int i;
- static const struct {
- const char *zName;
- int nArg;
- int flag;
- void (*xFunc)(sqlite3_context*,int,sqlite3_value**);
- } aFunc[] = {
- { "json", 1, 0, jsonRemoveFunc },
- { "json_array", -1, 0, jsonArrayFunc },
- { "json_array_length", 1, 0, jsonArrayLengthFunc },
- { "json_array_length", 2, 0, jsonArrayLengthFunc },
- { "json_extract", -1, 0, jsonExtractFunc },
- { "json_insert", -1, 0, jsonSetFunc },
- { "json_object", -1, 0, jsonObjectFunc },
- { "json_patch", 2, 0, jsonPatchFunc },
- { "json_quote", 1, 0, jsonQuoteFunc },
- { "json_remove", -1, 0, jsonRemoveFunc },
- { "json_replace", -1, 0, jsonReplaceFunc },
- { "json_set", -1, 1, jsonSetFunc },
- { "json_type", 1, 0, jsonTypeFunc },
- { "json_type", 2, 0, jsonTypeFunc },
- { "json_valid", 1, 0, jsonValidFunc },
-
+#endif /* !defined(SQLITE_OMIT_JSON) */
+
+/*
+** Register JSON functions.
+*/
+SQLITE_PRIVATE void sqlite3RegisterJsonFunctions(void){
+#ifndef SQLITE_OMIT_JSON
+ static FuncDef aJsonFunc[] = {
+ JFUNCTION(json, 1, 0, jsonRemoveFunc),
+ JFUNCTION(json_array, -1, 0, jsonArrayFunc),
+ JFUNCTION(json_array_length, 1, 0, jsonArrayLengthFunc),
+ JFUNCTION(json_array_length, 2, 0, jsonArrayLengthFunc),
+ JFUNCTION(json_extract, -1, 0, jsonExtractFunc),
+ JFUNCTION(->, 2, JSON_JSON, jsonExtractFunc),
+ JFUNCTION(->>, 2, JSON_SQL, jsonExtractFunc),
+ JFUNCTION(json_insert, -1, 0, jsonSetFunc),
+ JFUNCTION(json_object, -1, 0, jsonObjectFunc),
+ JFUNCTION(json_patch, 2, 0, jsonPatchFunc),
+ JFUNCTION(json_quote, 1, 0, jsonQuoteFunc),
+ JFUNCTION(json_remove, -1, 0, jsonRemoveFunc),
+ JFUNCTION(json_replace, -1, 0, jsonReplaceFunc),
+ JFUNCTION(json_set, -1, JSON_ISSET, jsonSetFunc),
+ JFUNCTION(json_type, 1, 0, jsonTypeFunc),
+ JFUNCTION(json_type, 2, 0, jsonTypeFunc),
+ JFUNCTION(json_valid, 1, 0, jsonValidFunc),
#if SQLITE_DEBUG
- /* DEBUG and TESTING functions */
- { "json_parse", 1, 0, jsonParseFunc },
- { "json_test1", 1, 0, jsonTest1Func },
-#endif
- };
- static const struct {
- const char *zName;
- int nArg;
- void (*xStep)(sqlite3_context*,int,sqlite3_value**);
- void (*xFinal)(sqlite3_context*);
- void (*xValue)(sqlite3_context*);
- } aAgg[] = {
- { "json_group_array", 1,
- jsonArrayStep, jsonArrayFinal, jsonArrayValue },
- { "json_group_object", 2,
- jsonObjectStep, jsonObjectFinal, jsonObjectValue },
+ JFUNCTION(json_parse, 1, 0, jsonParseFunc),
+ JFUNCTION(json_test1, 1, 0, jsonTest1Func),
+#endif
+ WAGGREGATE(json_group_array, 1, 0, 0,
+ jsonArrayStep, jsonArrayFinal, jsonArrayValue, jsonGroupInverse,
+ SQLITE_SUBTYPE|SQLITE_UTF8|SQLITE_DETERMINISTIC|SQLITE_INNOCUOUS),
+ WAGGREGATE(json_group_object, 2, 0, 0,
+ jsonObjectStep, jsonObjectFinal, jsonObjectValue, jsonGroupInverse,
+ SQLITE_SUBTYPE|SQLITE_UTF8|SQLITE_DETERMINISTIC|SQLITE_INNOCUOUS)
};
-#ifndef SQLITE_OMIT_VIRTUALTABLE
+ sqlite3InsertBuiltinFuncs(aJsonFunc, ArraySize(aJsonFunc));
+#endif
+}
+
+#if !defined(SQLITE_OMIT_VIRTUALTABLE) && !defined(SQLITE_OMIT_JSON)
+/*
+** Register the JSON table-valued functions
+*/
+SQLITE_PRIVATE int sqlite3JsonTableFunctions(sqlite3 *db){
+ int rc = SQLITE_OK;
static const struct {
- const char *zName;
- sqlite3_module *pModule;
+ const char *zName;
+ sqlite3_module *pModule;
} aMod[] = {
{ "json_each", &jsonEachModule },
{ "json_tree", &jsonTreeModule },
};
-#endif
- static const int enc =
- SQLITE_UTF8 |
- SQLITE_DETERMINISTIC |
- SQLITE_INNOCUOUS;
- for(i=0; i<sizeof(aFunc)/sizeof(aFunc[0]) && rc==SQLITE_OK; i++){
- rc = sqlite3_create_function(db, aFunc[i].zName, aFunc[i].nArg, enc,
- (void*)&aFunc[i].flag,
- aFunc[i].xFunc, 0, 0);
- }
-#ifndef SQLITE_OMIT_WINDOWFUNC
- for(i=0; i<sizeof(aAgg)/sizeof(aAgg[0]) && rc==SQLITE_OK; i++){
- rc = sqlite3_create_window_function(db, aAgg[i].zName, aAgg[i].nArg,
- SQLITE_SUBTYPE | enc, 0,
- aAgg[i].xStep, aAgg[i].xFinal,
- aAgg[i].xValue, jsonGroupInverse, 0);
- }
-#endif
-#ifndef SQLITE_OMIT_VIRTUALTABLE
+ unsigned int i;
for(i=0; i<sizeof(aMod)/sizeof(aMod[0]) && rc==SQLITE_OK; i++){
rc = sqlite3_create_module(db, aMod[i].zName, aMod[i].pModule, 0);
}
-#endif
return rc;
}
+#endif /* !defined(SQLITE_OMIT_VIRTUALTABLE) && !defined(SQLITE_OMIT_JSON) */
-
-#ifndef SQLITE_CORE
-#ifdef _WIN32
-__declspec(dllexport)
-#endif
-SQLITE_API int sqlite3_json_init(
- sqlite3 *db,
- char **pzErrMsg,
- const sqlite3_api_routines *pApi
-){
- SQLITE_EXTENSION_INIT2(pApi);
- (void)pzErrMsg; /* Unused parameter */
- return sqlite3Json1Init(db);
-}
-#endif
-#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_JSON1) */
-
-/************** End of json1.c ***********************************************/
+/************** End of json.c ************************************************/
/************** Begin file rtree.c *******************************************/
/*
** 2001 September 15
@@ -197825,11 +199701,7 @@ static void rtreecheck(
# define GEODEBUG(X)
#endif
-#ifndef JSON_NULL /* The following stuff repeats things found in json1 */
-/*
-** Versions of isspace(), isalnum() and isdigit() to which it is safe
-** to pass signed char values.
-*/
+/* Character class routines */
#ifdef sqlite3Isdigit
/* Use the SQLite core versions if this routine is part of the
** SQLite amalgamation */
@@ -197844,6 +199716,7 @@ static void rtreecheck(
# define safe_isxdigit(x) isxdigit((unsigned char)(x))
#endif
+#ifndef JSON_NULL /* The following stuff repeats things found in json1 */
/*
** Growing our own isspace() routine this way is twice as fast as
** the library isspace() function.
@@ -197866,7 +199739,7 @@ static const char geopolyIsSpace[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
};
-#define safe_isspace(x) (geopolyIsSpace[(unsigned char)x])
+#define fast_isspace(x) (geopolyIsSpace[(unsigned char)x])
#endif /* JSON NULL - back to original code */
/* Compiler and version */
@@ -197955,7 +199828,7 @@ static void geopolySwab32(unsigned char *a){
/* Skip whitespace. Return the next non-whitespace character. */
static char geopolySkipSpace(GeoParse *p){
- while( safe_isspace(p->z[0]) ) p->z++;
+ while( fast_isspace(p->z[0]) ) p->z++;
return p->z[0];
}
@@ -202795,7 +204668,7 @@ static char *rbuVacuumTableStart(
** the caller has to use an OFFSET clause to extract only the required
** rows from the sourct table, just as it does for an RBU update operation.
*/
-char *rbuVacuumIndexStart(
+static char *rbuVacuumIndexStart(
sqlite3rbu *p, /* RBU handle */
RbuObjIter *pIter /* RBU iterator object */
){
@@ -207640,6 +209513,7 @@ static int dbpageBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){
){
pIdxInfo->orderByConsumed = 1;
}
+ sqlite3VtabWriteAll(pIdxInfo);
return SQLITE_OK;
}
@@ -227935,7 +229809,7 @@ static int sqlite3Fts5IndexQuery(
if( sqlite3Fts5BufferSize(&p->rc, &buf, nToken+1)==0 ){
int iIdx = 0; /* Index to search */
int iPrefixIdx = 0; /* +1 prefix index */
- if( nToken ) memcpy(&buf.p[1], pToken, nToken);
+ if( nToken>0 ) memcpy(&buf.p[1], pToken, nToken);
/* Figure out which index to search and set iIdx accordingly. If this
** is a prefix query for which there is no prefix index, set iIdx to
@@ -229994,7 +231868,7 @@ static int fts5SorterNext(Fts5Cursor *pCsr){
rc = sqlite3_step(pSorter->pStmt);
if( rc==SQLITE_DONE ){
rc = SQLITE_OK;
- CsrFlagSet(pCsr, FTS5CSR_EOF);
+ CsrFlagSet(pCsr, FTS5CSR_EOF|FTS5CSR_REQUIRE_CONTENT);
}else if( rc==SQLITE_ROW ){
const u8 *a;
const u8 *aBlob;
@@ -231983,7 +233857,7 @@ static void fts5SourceIdFunc(
){
assert( nArg==0 );
UNUSED_PARAM2(nArg, apUnused);
- sqlite3_result_text(pCtx, "fts5: 2021-12-30 15:30:28 378629bf2ea546f73eee84063c5358439a12f7300e433f18c9e1bddd948dea62", -1, SQLITE_TRANSIENT);
+ sqlite3_result_text(pCtx, "fts5: 2022-03-12 13:37:29 38c210fdd258658321c85ec9c01a072fda3ada94540e3239d29b34dc547a8cbc", -1, SQLITE_TRANSIENT);
}
/*
diff --git a/chromium/third_party/sqlite/src/amalgamation/sqlite3.h b/chromium/third_party/sqlite/src/amalgamation/sqlite3.h
index 393e9d206cb..d7f21648941 100644
--- a/chromium/third_party/sqlite/src/amalgamation/sqlite3.h
+++ b/chromium/third_party/sqlite/src/amalgamation/sqlite3.h
@@ -146,9 +146,9 @@ extern "C" {
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
** [sqlite_version()] and [sqlite_source_id()].
*/
-#define SQLITE_VERSION "3.37.1"
-#define SQLITE_VERSION_NUMBER 3037001
-#define SQLITE_SOURCE_ID "2021-12-30 15:30:28 378629bf2ea546f73eee84063c5358439a12f7300e433f18c9e1bddd948dea62"
+#define SQLITE_VERSION "3.38.1"
+#define SQLITE_VERSION_NUMBER 3038001
+#define SQLITE_SOURCE_ID "2022-03-12 13:37:29 38c210fdd258658321c85ec9c01a072fda3ada94540e3239d29b34dc547a8cbc"
/*
** CAPI3REF: Run-Time Library Version Numbers
@@ -566,7 +566,7 @@ SQLITE_API int sqlite3_exec(
#define SQLITE_WARNING_AUTOINDEX (SQLITE_WARNING | (1<<8))
#define SQLITE_AUTH_USER (SQLITE_AUTH | (1<<8))
#define SQLITE_OK_LOAD_PERMANENTLY (SQLITE_OK | (1<<8))
-#define SQLITE_OK_SYMLINK (SQLITE_OK | (2<<8))
+#define SQLITE_OK_SYMLINK (SQLITE_OK | (2<<8)) /* internal use only */
/*
** CAPI3REF: Flags For File Open Operations
@@ -3824,13 +3824,14 @@ SQLITE_API void sqlite3_free_filename(char*);
** sqlite3_extended_errcode() might change with each API call.
** Except, there are some interfaces that are guaranteed to never
** change the value of the error code. The error-code preserving
-** interfaces are:
+** interfaces include the following:
**
** <ul>
** <li> sqlite3_errcode()
** <li> sqlite3_extended_errcode()
** <li> sqlite3_errmsg()
** <li> sqlite3_errmsg16()
+** <li> sqlite3_error_offset()
** </ul>
**
** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language
@@ -3845,6 +3846,13 @@ SQLITE_API void sqlite3_free_filename(char*);
** ^(Memory to hold the error message string is managed internally
** and must not be freed by the application)^.
**
+** ^If the most recent error references a specific token in the input
+** SQL, the sqlite3_error_offset() interface returns the byte offset
+** of the start of that token. ^The byte offset returned by
+** sqlite3_error_offset() assumes that the input SQL is UTF8.
+** ^If the most recent error does not reference a specific token in the input
+** SQL, then the sqlite3_error_offset() function returns -1.
+**
** When the serialized [threading mode] is in use, it might be the
** case that a second error occurs on a separate thread in between
** the time of the first error and the call to these interfaces.
@@ -3864,6 +3872,7 @@ SQLITE_API int sqlite3_extended_errcode(sqlite3 *db);
SQLITE_API const char *sqlite3_errmsg(sqlite3*);
SQLITE_API const void *sqlite3_errmsg16(sqlite3*);
SQLITE_API const char *sqlite3_errstr(int);
+SQLITE_API int sqlite3_error_offset(sqlite3 *db);
/*
** CAPI3REF: Prepared Statement Object
@@ -4275,6 +4284,10 @@ SQLITE_API const char *sqlite3_normalized_sql(sqlite3_stmt *pStmt);
** be false. ^Similarly, a CREATE TABLE IF NOT EXISTS statement is a
** read-only no-op if the table already exists, but
** sqlite3_stmt_readonly() still returns false for such a statement.
+**
+** ^If prepared statement X is an [EXPLAIN] or [EXPLAIN QUERY PLAN]
+** statement, then sqlite3_stmt_readonly(X) returns the same value as
+** if the EXPLAIN or EXPLAIN QUERY PLAN prefix were omitted.
*/
SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt);
@@ -4343,6 +4356,8 @@ SQLITE_API int sqlite3_stmt_busy(sqlite3_stmt*);
**
** ^The sqlite3_value objects that are passed as parameters into the
** implementation of [application-defined SQL functions] are protected.
+** ^The sqlite3_value objects returned by [sqlite3_vtab_rhs_value()]
+** are protected.
** ^The sqlite3_value object returned by
** [sqlite3_column_value()] is unprotected.
** Unprotected sqlite3_value objects may only be used as arguments
@@ -4964,6 +4979,10 @@ SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
** even empty strings, are always zero-terminated. ^The return
** value from sqlite3_column_blob() for a zero-length BLOB is a NULL pointer.
**
+** ^Strings returned by sqlite3_column_text16() always have the endianness
+** which is native to the platform, regardless of the text encoding set
+** for the database.
+**
** <b>Warning:</b> ^The object returned by [sqlite3_column_value()] is an
** [unprotected sqlite3_value] object. In a multithreaded environment,
** an unprotected sqlite3_value object may only be used safely with
@@ -4977,7 +4996,7 @@ SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
** [application-defined SQL functions] or [virtual tables], not within
** top-level application code.
**
-** The these routines may attempt to convert the datatype of the result.
+** These routines may attempt to convert the datatype of the result.
** ^For example, if the internal representation is FLOAT and a text result
** is requested, [sqlite3_snprintf()] is used internally to perform the
** conversion automatically. ^(The following table details the conversions
@@ -5002,7 +5021,7 @@ SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
** <tr><td> TEXT <td> BLOB <td> No change
** <tr><td> BLOB <td> INTEGER <td> [CAST] to INTEGER
** <tr><td> BLOB <td> FLOAT <td> [CAST] to REAL
-** <tr><td> BLOB <td> TEXT <td> Add a zero terminator if needed
+** <tr><td> BLOB <td> TEXT <td> [CAST] to TEXT, ensure zero terminator
** </table>
** </blockquote>)^
**
@@ -7122,24 +7141,56 @@ struct sqlite3_index_info {
**
** These macros define the allowed values for the
** [sqlite3_index_info].aConstraint[].op field. Each value represents
-** an operator that is part of a constraint term in the wHERE clause of
+** an operator that is part of a constraint term in the WHERE clause of
** a query that uses a [virtual table].
-*/
-#define SQLITE_INDEX_CONSTRAINT_EQ 2
-#define SQLITE_INDEX_CONSTRAINT_GT 4
-#define SQLITE_INDEX_CONSTRAINT_LE 8
-#define SQLITE_INDEX_CONSTRAINT_LT 16
-#define SQLITE_INDEX_CONSTRAINT_GE 32
-#define SQLITE_INDEX_CONSTRAINT_MATCH 64
-#define SQLITE_INDEX_CONSTRAINT_LIKE 65
-#define SQLITE_INDEX_CONSTRAINT_GLOB 66
-#define SQLITE_INDEX_CONSTRAINT_REGEXP 67
-#define SQLITE_INDEX_CONSTRAINT_NE 68
-#define SQLITE_INDEX_CONSTRAINT_ISNOT 69
-#define SQLITE_INDEX_CONSTRAINT_ISNOTNULL 70
-#define SQLITE_INDEX_CONSTRAINT_ISNULL 71
-#define SQLITE_INDEX_CONSTRAINT_IS 72
-#define SQLITE_INDEX_CONSTRAINT_FUNCTION 150
+**
+** ^The left-hand operand of the operator is given by the corresponding
+** aConstraint[].iColumn field. ^An iColumn of -1 indicates the left-hand
+** operand is the rowid.
+** The SQLITE_INDEX_CONSTRAINT_LIMIT and SQLITE_INDEX_CONSTRAINT_OFFSET
+** operators have no left-hand operand, and so for those operators the
+** corresponding aConstraint[].iColumn is meaningless and should not be
+** used.
+**
+** All operator values from SQLITE_INDEX_CONSTRAINT_FUNCTION through
+** value 255 are reserved to represent functions that are overloaded
+** by the [xFindFunction|xFindFunction method] of the virtual table
+** implementation.
+**
+** The right-hand operands for each constraint might be accessible using
+** the [sqlite3_vtab_rhs_value()] interface. Usually the right-hand
+** operand is only available if it appears as a single constant literal
+** in the input SQL. If the right-hand operand is another column or an
+** expression (even a constant expression) or a parameter, then the
+** sqlite3_vtab_rhs_value() probably will not be able to extract it.
+** ^The SQLITE_INDEX_CONSTRAINT_ISNULL and
+** SQLITE_INDEX_CONSTRAINT_ISNOTNULL operators have no right-hand operand
+** and hence calls to sqlite3_vtab_rhs_value() for those operators will
+** always return SQLITE_NOTFOUND.
+**
+** The collating sequence to be used for comparison can be found using
+** the [sqlite3_vtab_collation()] interface. For most real-world virtual
+** tables, the collating sequence of constraints does not matter (for example
+** because the constraints are numeric) and so the sqlite3_vtab_collation()
+** interface is no commonly needed.
+*/
+#define SQLITE_INDEX_CONSTRAINT_EQ 2
+#define SQLITE_INDEX_CONSTRAINT_GT 4
+#define SQLITE_INDEX_CONSTRAINT_LE 8
+#define SQLITE_INDEX_CONSTRAINT_LT 16
+#define SQLITE_INDEX_CONSTRAINT_GE 32
+#define SQLITE_INDEX_CONSTRAINT_MATCH 64
+#define SQLITE_INDEX_CONSTRAINT_LIKE 65
+#define SQLITE_INDEX_CONSTRAINT_GLOB 66
+#define SQLITE_INDEX_CONSTRAINT_REGEXP 67
+#define SQLITE_INDEX_CONSTRAINT_NE 68
+#define SQLITE_INDEX_CONSTRAINT_ISNOT 69
+#define SQLITE_INDEX_CONSTRAINT_ISNOTNULL 70
+#define SQLITE_INDEX_CONSTRAINT_ISNULL 71
+#define SQLITE_INDEX_CONSTRAINT_IS 72
+#define SQLITE_INDEX_CONSTRAINT_LIMIT 73
+#define SQLITE_INDEX_CONSTRAINT_OFFSET 74
+#define SQLITE_INDEX_CONSTRAINT_FUNCTION 150
/*
** CAPI3REF: Register A Virtual Table Implementation
@@ -7168,7 +7219,7 @@ struct sqlite3_index_info {
** destructor.
**
** ^If the third parameter (the pointer to the sqlite3_module object) is
-** NULL then no new module is create and any existing modules with the
+** NULL then no new module is created and any existing modules with the
** same name are dropped.
**
** See also: [sqlite3_drop_modules()]
@@ -7944,7 +7995,8 @@ SQLITE_API int sqlite3_test_control(int op, ...);
#define SQLITE_TESTCTRL_SEEK_COUNT 30
#define SQLITE_TESTCTRL_TRACEFLAGS 31
#define SQLITE_TESTCTRL_TUNE 32
-#define SQLITE_TESTCTRL_LAST 32 /* Largest TESTCTRL */
+#define SQLITE_TESTCTRL_LOGEST 33
+#define SQLITE_TESTCTRL_LAST 33 /* Largest TESTCTRL */
/*
** CAPI3REF: SQL Keyword Checking
@@ -8467,6 +8519,16 @@ SQLITE_API int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);
** The counter is incremented on the first [sqlite3_step()] call of each
** cycle.
**
+** [[SQLITE_STMTSTATUS_FILTER_MISS]]
+** [[SQLITE_STMTSTATUS_FILTER HIT]]
+** <dt>SQLITE_STMTSTATUS_FILTER_HIT<br>
+** SQLITE_STMTSTATUS_FILTER_MISS</dt>
+** <dd>^SQLITE_STMTSTATUS_FILTER_HIT is the number of times that a join
+** step was bypassed because a Bloom filter returned not-found. The
+** corresponding SQLITE_STMTSTATUS_FILTER_MISS value is the number of
+** times that the Bloom filter returned a find, and thus the join step
+** had to be processed as normal.
+**
** [[SQLITE_STMTSTATUS_MEMUSED]] <dt>SQLITE_STMTSTATUS_MEMUSED</dt>
** <dd>^This is the approximate number of bytes of heap memory
** used to store the prepared statement. ^This value is not actually
@@ -8481,6 +8543,8 @@ SQLITE_API int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);
#define SQLITE_STMTSTATUS_VM_STEP 4
#define SQLITE_STMTSTATUS_REPREPARE 5
#define SQLITE_STMTSTATUS_RUN 6
+#define SQLITE_STMTSTATUS_FILTER_MISS 7
+#define SQLITE_STMTSTATUS_FILTER_HIT 8
#define SQLITE_STMTSTATUS_MEMUSED 99
/*
@@ -9449,20 +9513,270 @@ SQLITE_API int sqlite3_vtab_nochange(sqlite3_context*);
/*
** CAPI3REF: Determine The Collation For a Virtual Table Constraint
+** METHOD: sqlite3_index_info
**
** This function may only be called from within a call to the [xBestIndex]
-** method of a [virtual table].
+** method of a [virtual table]. This function returns a pointer to a string
+** that is the name of the appropriate collation sequence to use for text
+** comparisons on the constraint identified by its arguments.
+**
+** The first argument must be the pointer to the [sqlite3_index_info] object
+** that is the first parameter to the xBestIndex() method. The second argument
+** must be an index into the aConstraint[] array belonging to the
+** sqlite3_index_info structure passed to xBestIndex.
+**
+** Important:
+** The first parameter must be the same pointer that is passed into the
+** xBestMethod() method. The first parameter may not be a pointer to a
+** different [sqlite3_index_info] object, even an exact copy.
+**
+** The return value is computed as follows:
**
-** The first argument must be the sqlite3_index_info object that is the
-** first parameter to the xBestIndex() method. The second argument must be
-** an index into the aConstraint[] array belonging to the sqlite3_index_info
-** structure passed to xBestIndex. This function returns a pointer to a buffer
-** containing the name of the collation sequence for the corresponding
-** constraint.
+** <ol>
+** <li><p> If the constraint comes from a WHERE clause expression that contains
+** a [COLLATE operator], then the name of the collation specified by
+** that COLLATE operator is returned.
+** <li><p> If there is no COLLATE operator, but the column that is the subject
+** of the constraint specifies an alternative collating sequence via
+** a [COLLATE clause] on the column definition within the CREATE TABLE
+** statement that was passed into [sqlite3_declare_vtab()], then the
+** name of that alternative collating sequence is returned.
+** <li><p> Otherwise, "BINARY" is returned.
+** </ol>
*/
SQLITE_API SQLITE_EXPERIMENTAL const char *sqlite3_vtab_collation(sqlite3_index_info*,int);
/*
+** CAPI3REF: Determine if a virtual table query is DISTINCT
+** METHOD: sqlite3_index_info
+**
+** This API may only be used from within an [xBestIndex|xBestIndex method]
+** of a [virtual table] implementation. The result of calling this
+** interface from outside of xBestIndex() is undefined and probably harmful.
+**
+** ^The sqlite3_vtab_distinct() interface returns an integer that is
+** either 0, 1, or 2. The integer returned by sqlite3_vtab_distinct()
+** gives the virtual table additional information about how the query
+** planner wants the output to be ordered. As long as the virtual table
+** can meet the ordering requirements of the query planner, it may set
+** the "orderByConsumed" flag.
+**
+** <ol><li value="0"><p>
+** ^If the sqlite3_vtab_distinct() interface returns 0, that means
+** that the query planner needs the virtual table to return all rows in the
+** sort order defined by the "nOrderBy" and "aOrderBy" fields of the
+** [sqlite3_index_info] object. This is the default expectation. If the
+** virtual table outputs all rows in sorted order, then it is always safe for
+** the xBestIndex method to set the "orderByConsumed" flag, regardless of
+** the return value from sqlite3_vtab_distinct().
+** <li value="1"><p>
+** ^(If the sqlite3_vtab_distinct() interface returns 1, that means
+** that the query planner does not need the rows to be returned in sorted order
+** as long as all rows with the same values in all columns identified by the
+** "aOrderBy" field are adjacent.)^ This mode is used when the query planner
+** is doing a GROUP BY.
+** <li value="2"><p>
+** ^(If the sqlite3_vtab_distinct() interface returns 2, that means
+** that the query planner does not need the rows returned in any particular
+** order, as long as rows with the same values in all "aOrderBy" columns
+** are adjacent.)^ ^(Furthermore, only a single row for each particular
+** combination of values in the columns identified by the "aOrderBy" field
+** needs to be returned.)^ ^It is always ok for two or more rows with the same
+** values in all "aOrderBy" columns to be returned, as long as all such rows
+** are adjacent. ^The virtual table may, if it chooses, omit extra rows
+** that have the same value for all columns identified by "aOrderBy".
+** ^However omitting the extra rows is optional.
+** This mode is used for a DISTINCT query.
+** </ol>
+**
+** ^For the purposes of comparing virtual table output values to see if the
+** values are same value for sorting purposes, two NULL values are considered
+** to be the same. In other words, the comparison operator is "IS"
+** (or "IS NOT DISTINCT FROM") and not "==".
+**
+** If a virtual table implementation is unable to meet the requirements
+** specified above, then it must not set the "orderByConsumed" flag in the
+** [sqlite3_index_info] object or an incorrect answer may result.
+**
+** ^A virtual table implementation is always free to return rows in any order
+** it wants, as long as the "orderByConsumed" flag is not set. ^When the
+** the "orderByConsumed" flag is unset, the query planner will add extra
+** [bytecode] to ensure that the final results returned by the SQL query are
+** ordered correctly. The use of the "orderByConsumed" flag and the
+** sqlite3_vtab_distinct() interface is merely an optimization. ^Careful
+** use of the sqlite3_vtab_distinct() interface and the "orderByConsumed"
+** flag might help queries against a virtual table to run faster. Being
+** overly aggressive and setting the "orderByConsumed" flag when it is not
+** valid to do so, on the other hand, might cause SQLite to return incorrect
+** results.
+*/
+SQLITE_API int sqlite3_vtab_distinct(sqlite3_index_info*);
+
+/*
+** CAPI3REF: Identify and handle IN constraints in xBestIndex
+**
+** This interface may only be used from within an
+** [xBestIndex|xBestIndex() method] of a [virtual table] implementation.
+** The result of invoking this interface from any other context is
+** undefined and probably harmful.
+**
+** ^(A constraint on a virtual table of the form
+** "[IN operator|column IN (...)]" is
+** communicated to the xBestIndex method as a
+** [SQLITE_INDEX_CONSTRAINT_EQ] constraint.)^ If xBestIndex wants to use
+** this constraint, it must set the corresponding
+** aConstraintUsage[].argvIndex to a postive integer. ^(Then, under
+** the usual mode of handling IN operators, SQLite generates [bytecode]
+** that invokes the [xFilter|xFilter() method] once for each value
+** on the right-hand side of the IN operator.)^ Thus the virtual table
+** only sees a single value from the right-hand side of the IN operator
+** at a time.
+**
+** In some cases, however, it would be advantageous for the virtual
+** table to see all values on the right-hand of the IN operator all at
+** once. The sqlite3_vtab_in() interfaces facilitates this in two ways:
+**
+** <ol>
+** <li><p>
+** ^A call to sqlite3_vtab_in(P,N,-1) will return true (non-zero)
+** if and only if the [sqlite3_index_info|P->aConstraint][N] constraint
+** is an [IN operator] that can be processed all at once. ^In other words,
+** sqlite3_vtab_in() with -1 in the third argument is a mechanism
+** by which the virtual table can ask SQLite if all-at-once processing
+** of the IN operator is even possible.
+**
+** <li><p>
+** ^A call to sqlite3_vtab_in(P,N,F) with F==1 or F==0 indicates
+** to SQLite that the virtual table does or does not want to process
+** the IN operator all-at-once, respectively. ^Thus when the third
+** parameter (F) is non-negative, this interface is the mechanism by
+** which the virtual table tells SQLite how it wants to process the
+** IN operator.
+** </ol>
+**
+** ^The sqlite3_vtab_in(P,N,F) interface can be invoked multiple times
+** within the same xBestIndex method call. ^For any given P,N pair,
+** the return value from sqlite3_vtab_in(P,N,F) will always be the same
+** within the same xBestIndex call. ^If the interface returns true
+** (non-zero), that means that the constraint is an IN operator
+** that can be processed all-at-once. ^If the constraint is not an IN
+** operator or cannot be processed all-at-once, then the interface returns
+** false.
+**
+** ^(All-at-once processing of the IN operator is selected if both of the
+** following conditions are met:
+**
+** <ol>
+** <li><p> The P->aConstraintUsage[N].argvIndex value is set to a positive
+** integer. This is how the virtual table tells SQLite that it wants to
+** use the N-th constraint.
+**
+** <li><p> The last call to sqlite3_vtab_in(P,N,F) for which F was
+** non-negative had F>=1.
+** </ol>)^
+**
+** ^If either or both of the conditions above are false, then SQLite uses
+** the traditional one-at-a-time processing strategy for the IN constraint.
+** ^If both conditions are true, then the argvIndex-th parameter to the
+** xFilter method will be an [sqlite3_value] that appears to be NULL,
+** but which can be passed to [sqlite3_vtab_in_first()] and
+** [sqlite3_vtab_in_next()] to find all values on the right-hand side
+** of the IN constraint.
+*/
+SQLITE_API int sqlite3_vtab_in(sqlite3_index_info*, int iCons, int bHandle);
+
+/*
+** CAPI3REF: Find all elements on the right-hand side of an IN constraint.
+**
+** These interfaces are only useful from within the
+** [xFilter|xFilter() method] of a [virtual table] implementation.
+** The result of invoking these interfaces from any other context
+** is undefined and probably harmful.
+**
+** The X parameter in a call to sqlite3_vtab_in_first(X,P) or
+** sqlite3_vtab_in_next(X,P) must be one of the parameters to the
+** xFilter method which invokes these routines, and specifically
+** a parameter that was previously selected for all-at-once IN constraint
+** processing use the [sqlite3_vtab_in()] interface in the
+** [xBestIndex|xBestIndex method]. ^(If the X parameter is not
+** an xFilter argument that was selected for all-at-once IN constraint
+** processing, then these routines return [SQLITE_MISUSE])^ or perhaps
+** exhibit some other undefined or harmful behavior.
+**
+** ^(Use these routines to access all values on the right-hand side
+** of the IN constraint using code like the following:
+**
+** <blockquote><pre>
+** &nbsp; for(rc=sqlite3_vtab_in_first(pList, &pVal);
+** &nbsp; rc==SQLITE_OK && pVal
+** &nbsp; rc=sqlite3_vtab_in_next(pList, &pVal)
+** &nbsp; ){
+** &nbsp; // do something with pVal
+** &nbsp; }
+** &nbsp; if( rc!=SQLITE_OK ){
+** &nbsp; // an error has occurred
+** &nbsp; }
+** </pre></blockquote>)^
+**
+** ^On success, the sqlite3_vtab_in_first(X,P) and sqlite3_vtab_in_next(X,P)
+** routines return SQLITE_OK and set *P to point to the first or next value
+** on the RHS of the IN constraint. ^If there are no more values on the
+** right hand side of the IN constraint, then *P is set to NULL and these
+** routines return [SQLITE_DONE]. ^The return value might be
+** some other value, such as SQLITE_NOMEM, in the event of a malfunction.
+**
+** The *ppOut values returned by these routines are only valid until the
+** next call to either of these routines or until the end of the xFilter
+** method from which these routines were called. If the virtual table
+** implementation needs to retain the *ppOut values for longer, it must make
+** copies. The *ppOut values are [protected sqlite3_value|protected].
+*/
+SQLITE_API int sqlite3_vtab_in_first(sqlite3_value *pVal, sqlite3_value **ppOut);
+SQLITE_API int sqlite3_vtab_in_next(sqlite3_value *pVal, sqlite3_value **ppOut);
+
+/*
+** CAPI3REF: Constraint values in xBestIndex()
+** METHOD: sqlite3_index_info
+**
+** This API may only be used from within the [xBestIndex|xBestIndex method]
+** of a [virtual table] implementation. The result of calling this interface
+** from outside of an xBestIndex method are undefined and probably harmful.
+**
+** ^When the sqlite3_vtab_rhs_value(P,J,V) interface is invoked from within
+** the [xBestIndex] method of a [virtual table] implementation, with P being
+** a copy of the [sqlite3_index_info] object pointer passed into xBestIndex and
+** J being a 0-based index into P->aConstraint[], then this routine
+** attempts to set *V to the value of the right-hand operand of
+** that constraint if the right-hand operand is known. ^If the
+** right-hand operand is not known, then *V is set to a NULL pointer.
+** ^The sqlite3_vtab_rhs_value(P,J,V) interface returns SQLITE_OK if
+** and only if *V is set to a value. ^The sqlite3_vtab_rhs_value(P,J,V)
+** inteface returns SQLITE_NOTFOUND if the right-hand side of the J-th
+** constraint is not available. ^The sqlite3_vtab_rhs_value() interface
+** can return an result code other than SQLITE_OK or SQLITE_NOTFOUND if
+** something goes wrong.
+**
+** The sqlite3_vtab_rhs_value() interface is usually only successful if
+** the right-hand operand of a constraint is a literal value in the original
+** SQL statement. If the right-hand operand is an expression or a reference
+** to some other column or a [host parameter], then sqlite3_vtab_rhs_value()
+** will probably return [SQLITE_NOTFOUND].
+**
+** ^(Some constraints, such as [SQLITE_INDEX_CONSTRAINT_ISNULL] and
+** [SQLITE_INDEX_CONSTRAINT_ISNOTNULL], have no right-hand operand. For such
+** constraints, sqlite3_vtab_rhs_value() always returns SQLITE_NOTFOUND.)^
+**
+** ^The [sqlite3_value] object returned in *V is a protected sqlite3_value
+** and remains valid for the duration of the xBestIndex method call.
+** ^When xBestIndex returns, the sqlite3_value object returned by
+** sqlite3_vtab_rhs_value() is automatically deallocated.
+**
+** The "_rhs_" in the name of this routine is an abbreviation for
+** "Right-Hand Side".
+*/
+SQLITE_API int sqlite3_vtab_rhs_value(sqlite3_index_info*, int, sqlite3_value **ppVal);
+
+/*
** CAPI3REF: Conflict resolution modes
** KEYWORDS: {conflict resolution mode}
**
diff --git a/chromium/third_party/sqlite/src/amalgamation_dev/rename_exports.h b/chromium/third_party/sqlite/src/amalgamation_dev/rename_exports.h
index 5d0e1b84f2f..52396807ea8 100644
--- a/chromium/third_party/sqlite/src/amalgamation_dev/rename_exports.h
+++ b/chromium/third_party/sqlite/src/amalgamation_dev/rename_exports.h
@@ -7,342 +7,348 @@
#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 6068-6070
-#define sqlite3_aggregate_context chrome_sqlite3_aggregate_context // Line 5629
-#define sqlite3_aggregate_count chrome_sqlite3_aggregate_count // Line 5404
-#define sqlite3_auto_extension chrome_sqlite3_auto_extension // Line 6884
-#define sqlite3_autovacuum_pages chrome_sqlite3_autovacuum_pages // Lines 6476-6481
-#define sqlite3_backup_finish chrome_sqlite3_backup_finish // Line 8918
-#define sqlite3_backup_init chrome_sqlite3_backup_init // Lines 8911-8916
-#define sqlite3_backup_pagecount chrome_sqlite3_backup_pagecount // Line 8920
-#define sqlite3_backup_remaining chrome_sqlite3_backup_remaining // Line 8919
-#define sqlite3_backup_step chrome_sqlite3_backup_step // Line 8917
-#define sqlite3_bind_blob chrome_sqlite3_bind_blob // Line 4510
-#define sqlite3_bind_blob64 chrome_sqlite3_bind_blob64 // Lines 4511-4512
-#define sqlite3_bind_double chrome_sqlite3_bind_double // Line 4513
-#define sqlite3_bind_int chrome_sqlite3_bind_int // Line 4514
-#define sqlite3_bind_int64 chrome_sqlite3_bind_int64 // Line 4515
-#define sqlite3_bind_null chrome_sqlite3_bind_null // Line 4516
-#define sqlite3_bind_parameter_count chrome_sqlite3_bind_parameter_count // Line 4545
-#define sqlite3_bind_parameter_index chrome_sqlite3_bind_parameter_index // Line 4591
-#define sqlite3_bind_parameter_name chrome_sqlite3_bind_parameter_name // Line 4573
-#define sqlite3_bind_pointer chrome_sqlite3_bind_pointer // Line 4522
-#define sqlite3_bind_text chrome_sqlite3_bind_text // Line 4517
-#define sqlite3_bind_text16 chrome_sqlite3_bind_text16 // Line 4518
-#define sqlite3_bind_text64 chrome_sqlite3_bind_text64 // Lines 4519-4520
-#define sqlite3_bind_value chrome_sqlite3_bind_value // Line 4521
-#define sqlite3_bind_zeroblob chrome_sqlite3_bind_zeroblob // Line 4523
-#define sqlite3_bind_zeroblob64 chrome_sqlite3_bind_zeroblob64 // Line 4524
-#define sqlite3_blob_bytes chrome_sqlite3_blob_bytes // Line 7462
-#define sqlite3_blob_close chrome_sqlite3_blob_close // Line 7446
-#define sqlite3_blob_open chrome_sqlite3_blob_open // Lines 7390-7398
-#define sqlite3_blob_read chrome_sqlite3_blob_read // Line 7491
-#define sqlite3_blob_reopen chrome_sqlite3_blob_reopen // Line 7423
-#define sqlite3_blob_write chrome_sqlite3_blob_write // Line 7533
+#define sqlite3_activate_cerod chrome_sqlite3_activate_cerod // Lines 6087-6089
+#define sqlite3_aggregate_context chrome_sqlite3_aggregate_context // Line 5648
+#define sqlite3_aggregate_count chrome_sqlite3_aggregate_count // Line 5423
+#define sqlite3_auto_extension chrome_sqlite3_auto_extension // Line 6903
+#define sqlite3_autovacuum_pages chrome_sqlite3_autovacuum_pages // Lines 6495-6500
+#define sqlite3_backup_finish chrome_sqlite3_backup_finish // Line 8982
+#define sqlite3_backup_init chrome_sqlite3_backup_init // Lines 8975-8980
+#define sqlite3_backup_pagecount chrome_sqlite3_backup_pagecount // Line 8984
+#define sqlite3_backup_remaining chrome_sqlite3_backup_remaining // Line 8983
+#define sqlite3_backup_step chrome_sqlite3_backup_step // Line 8981
+#define sqlite3_bind_blob chrome_sqlite3_bind_blob // Line 4525
+#define sqlite3_bind_blob64 chrome_sqlite3_bind_blob64 // Lines 4526-4527
+#define sqlite3_bind_double chrome_sqlite3_bind_double // Line 4528
+#define sqlite3_bind_int chrome_sqlite3_bind_int // Line 4529
+#define sqlite3_bind_int64 chrome_sqlite3_bind_int64 // Line 4530
+#define sqlite3_bind_null chrome_sqlite3_bind_null // Line 4531
+#define sqlite3_bind_parameter_count chrome_sqlite3_bind_parameter_count // Line 4560
+#define sqlite3_bind_parameter_index chrome_sqlite3_bind_parameter_index // Line 4606
+#define sqlite3_bind_parameter_name chrome_sqlite3_bind_parameter_name // Line 4588
+#define sqlite3_bind_pointer chrome_sqlite3_bind_pointer // Line 4537
+#define sqlite3_bind_text chrome_sqlite3_bind_text // Line 4532
+#define sqlite3_bind_text16 chrome_sqlite3_bind_text16 // Line 4533
+#define sqlite3_bind_text64 chrome_sqlite3_bind_text64 // Lines 4534-4535
+#define sqlite3_bind_value chrome_sqlite3_bind_value // Line 4536
+#define sqlite3_bind_zeroblob chrome_sqlite3_bind_zeroblob // Line 4538
+#define sqlite3_bind_zeroblob64 chrome_sqlite3_bind_zeroblob64 // Line 4539
+#define sqlite3_blob_bytes chrome_sqlite3_blob_bytes // Line 7513
+#define sqlite3_blob_close chrome_sqlite3_blob_close // Line 7497
+#define sqlite3_blob_open chrome_sqlite3_blob_open // Lines 7441-7449
+#define sqlite3_blob_read chrome_sqlite3_blob_read // Line 7542
+#define sqlite3_blob_reopen chrome_sqlite3_blob_reopen // Line 7474
+#define sqlite3_blob_write chrome_sqlite3_blob_write // Line 7584
#define sqlite3_busy_handler chrome_sqlite3_busy_handler // Line 2737
#define sqlite3_busy_timeout chrome_sqlite3_busy_timeout // Line 2760
-#define sqlite3_cancel_auto_extension chrome_sqlite3_cancel_auto_extension // Line 6896
+#define sqlite3_cancel_auto_extension chrome_sqlite3_cancel_auto_extension // Line 6915
#define sqlite3_changes chrome_sqlite3_changes // Line 2560
#define sqlite3_changes64 chrome_sqlite3_changes64 // Line 2561
-#define sqlite3_clear_bindings chrome_sqlite3_clear_bindings // Line 4601
+#define sqlite3_clear_bindings chrome_sqlite3_clear_bindings // Line 4616
#define sqlite3_close chrome_sqlite3_close // Line 353
#define sqlite3_close_v2 chrome_sqlite3_close_v2 // Line 354
-#define sqlite3_collation_needed chrome_sqlite3_collation_needed // Lines 6052-6056
-#define sqlite3_collation_needed16 chrome_sqlite3_collation_needed16 // Lines 6057-6061
-#define sqlite3_column_blob chrome_sqlite3_column_blob // Line 5077
-#define sqlite3_column_bytes chrome_sqlite3_column_bytes // Line 5084
-#define sqlite3_column_bytes16 chrome_sqlite3_column_bytes16 // Line 5085
-#define sqlite3_column_count chrome_sqlite3_column_count // Line 4617
-#define sqlite3_column_database_name chrome_sqlite3_column_database_name // Line 4691
-#define sqlite3_column_database_name16 chrome_sqlite3_column_database_name16 // Line 4692
-#define sqlite3_column_decltype chrome_sqlite3_column_decltype // Line 4728
-#define sqlite3_column_decltype16 chrome_sqlite3_column_decltype16 // Line 4729
-#define sqlite3_column_double chrome_sqlite3_column_double // Line 5078
-#define sqlite3_column_int chrome_sqlite3_column_int // Line 5079
-#define sqlite3_column_int64 chrome_sqlite3_column_int64 // Line 5080
-#define sqlite3_column_name chrome_sqlite3_column_name // Line 4646
-#define sqlite3_column_name16 chrome_sqlite3_column_name16 // Line 4647
-#define sqlite3_column_origin_name chrome_sqlite3_column_origin_name // Line 4695
-#define sqlite3_column_origin_name16 chrome_sqlite3_column_origin_name16 // Line 4696
-#define sqlite3_column_table_name chrome_sqlite3_column_table_name // Line 4693
-#define sqlite3_column_table_name16 chrome_sqlite3_column_table_name16 // Line 4694
-#define sqlite3_column_text chrome_sqlite3_column_text // Line 5081
-#define sqlite3_column_text16 chrome_sqlite3_column_text16 // Line 5082
-#define sqlite3_column_type chrome_sqlite3_column_type // Line 5086
-#define sqlite3_column_value chrome_sqlite3_column_value // Line 5083
-#define sqlite3_commit_hook chrome_sqlite3_commit_hook // Line 6415
+#define sqlite3_collation_needed chrome_sqlite3_collation_needed // Lines 6071-6075
+#define sqlite3_collation_needed16 chrome_sqlite3_collation_needed16 // Lines 6076-6080
+#define sqlite3_column_blob chrome_sqlite3_column_blob // Line 5096
+#define sqlite3_column_bytes chrome_sqlite3_column_bytes // Line 5103
+#define sqlite3_column_bytes16 chrome_sqlite3_column_bytes16 // Line 5104
+#define sqlite3_column_count chrome_sqlite3_column_count // Line 4632
+#define sqlite3_column_database_name chrome_sqlite3_column_database_name // Line 4706
+#define sqlite3_column_database_name16 chrome_sqlite3_column_database_name16 // Line 4707
+#define sqlite3_column_decltype chrome_sqlite3_column_decltype // Line 4743
+#define sqlite3_column_decltype16 chrome_sqlite3_column_decltype16 // Line 4744
+#define sqlite3_column_double chrome_sqlite3_column_double // Line 5097
+#define sqlite3_column_int chrome_sqlite3_column_int // Line 5098
+#define sqlite3_column_int64 chrome_sqlite3_column_int64 // Line 5099
+#define sqlite3_column_name chrome_sqlite3_column_name // Line 4661
+#define sqlite3_column_name16 chrome_sqlite3_column_name16 // Line 4662
+#define sqlite3_column_origin_name chrome_sqlite3_column_origin_name // Line 4710
+#define sqlite3_column_origin_name16 chrome_sqlite3_column_origin_name16 // Line 4711
+#define sqlite3_column_table_name chrome_sqlite3_column_table_name // Line 4708
+#define sqlite3_column_table_name16 chrome_sqlite3_column_table_name16 // Line 4709
+#define sqlite3_column_text chrome_sqlite3_column_text // Line 5100
+#define sqlite3_column_text16 chrome_sqlite3_column_text16 // Line 5101
+#define sqlite3_column_type chrome_sqlite3_column_type // Line 5105
+#define sqlite3_column_value chrome_sqlite3_column_value // Line 5102
+#define sqlite3_commit_hook chrome_sqlite3_commit_hook // Line 6434
#define sqlite3_compileoption_get chrome_sqlite3_compileoption_get // Line 214
#define sqlite3_compileoption_used chrome_sqlite3_compileoption_used // Line 213
#define sqlite3_complete chrome_sqlite3_complete // Line 2675
#define sqlite3_complete16 chrome_sqlite3_complete16 // Line 2676
#define sqlite3_config chrome_sqlite3_config // Line 1639
-#define sqlite3_context_db_handle chrome_sqlite3_context_db_handle // Line 5656
-#define sqlite3_create_collation chrome_sqlite3_create_collation // Lines 6002-6008
-#define sqlite3_create_collation16 chrome_sqlite3_create_collation16 // Lines 6017-6023
-#define sqlite3_create_collation_v2 chrome_sqlite3_create_collation_v2 // Lines 6009-6016
+#define sqlite3_context_db_handle chrome_sqlite3_context_db_handle // Line 5675
+#define sqlite3_create_collation chrome_sqlite3_create_collation // Lines 6021-6027
+#define sqlite3_create_collation16 chrome_sqlite3_create_collation16 // Lines 6036-6042
+#define sqlite3_create_collation_v2 chrome_sqlite3_create_collation_v2 // Lines 6028-6035
#define sqlite3_create_filename chrome_sqlite3_create_filename // Lines 3801-3807
-#define sqlite3_create_function chrome_sqlite3_create_function // Lines 5266-5275
-#define sqlite3_create_function16 chrome_sqlite3_create_function16 // Lines 5276-5285
-#define sqlite3_create_function_v2 chrome_sqlite3_create_function_v2 // Lines 5286-5296
-#define sqlite3_create_module chrome_sqlite3_create_module // Lines 7176-7181
-#define sqlite3_create_module_v2 chrome_sqlite3_create_module_v2 // Lines 7182-7188
-#define sqlite3_create_window_function chrome_sqlite3_create_window_function // Lines 5297-5308
-#define sqlite3_data_count chrome_sqlite3_data_count // Line 4834
-#define sqlite3_data_directory chrome_sqlite3_data_directory // Line 6185
+#define sqlite3_create_function chrome_sqlite3_create_function // Lines 5285-5294
+#define sqlite3_create_function16 chrome_sqlite3_create_function16 // Lines 5295-5304
+#define sqlite3_create_function_v2 chrome_sqlite3_create_function_v2 // Lines 5305-5315
+#define sqlite3_create_module chrome_sqlite3_create_module // Lines 7227-7232
+#define sqlite3_create_module_v2 chrome_sqlite3_create_module_v2 // Lines 7233-7239
+#define sqlite3_create_window_function chrome_sqlite3_create_window_function // Lines 5316-5327
+#define sqlite3_data_count chrome_sqlite3_data_count // Line 4849
+#define sqlite3_data_directory chrome_sqlite3_data_directory // Line 6204
#define sqlite3_database_file_object chrome_sqlite3_database_file_object // Line 3754
-#define sqlite3_db_cacheflush chrome_sqlite3_db_cacheflush // Line 9617
+#define sqlite3_db_cacheflush chrome_sqlite3_db_cacheflush // Line 9931
#define sqlite3_db_config chrome_sqlite3_db_config // Line 1658
-#define sqlite3_db_filename chrome_sqlite3_db_filename // Line 6289
-#define sqlite3_db_handle chrome_sqlite3_db_handle // Line 6257
-#define sqlite3_db_mutex chrome_sqlite3_db_mutex // Line 7841
-#define sqlite3_db_readonly chrome_sqlite3_db_readonly // Line 6299
-#define sqlite3_db_release_memory chrome_sqlite3_db_release_memory // Line 6608
-#define sqlite3_db_status chrome_sqlite3_db_status // Line 8268
-#define sqlite3_declare_vtab chrome_sqlite3_declare_vtab // Line 7262
-#define sqlite3_deserialize chrome_sqlite3_deserialize // Lines 10027-10034
-#define sqlite3_drop_modules chrome_sqlite3_drop_modules // Lines 7202-7205
-#define sqlite3_enable_load_extension chrome_sqlite3_enable_load_extension // Line 6846
-#define sqlite3_enable_shared_cache chrome_sqlite3_enable_shared_cache // Line 6578
-#define sqlite3_errcode chrome_sqlite3_errcode // Line 3862
-#define sqlite3_errmsg chrome_sqlite3_errmsg // Line 3864
-#define sqlite3_errmsg16 chrome_sqlite3_errmsg16 // Line 3865
-#define sqlite3_errstr chrome_sqlite3_errstr // Line 3866
+#define sqlite3_db_filename chrome_sqlite3_db_filename // Line 6308
+#define sqlite3_db_handle chrome_sqlite3_db_handle // Line 6276
+#define sqlite3_db_mutex chrome_sqlite3_db_mutex // Line 7892
+#define sqlite3_db_readonly chrome_sqlite3_db_readonly // Line 6318
+#define sqlite3_db_release_memory chrome_sqlite3_db_release_memory // Line 6627
+#define sqlite3_db_status chrome_sqlite3_db_status // Line 8320
+#define sqlite3_declare_vtab chrome_sqlite3_declare_vtab // Line 7313
+#define sqlite3_deserialize chrome_sqlite3_deserialize // Lines 10341-10348
+#define sqlite3_drop_modules chrome_sqlite3_drop_modules // Lines 7253-7256
+#define sqlite3_enable_load_extension chrome_sqlite3_enable_load_extension // Line 6865
+#define sqlite3_enable_shared_cache chrome_sqlite3_enable_shared_cache // Line 6597
+#define sqlite3_errcode chrome_sqlite3_errcode // Line 3870
+#define sqlite3_errmsg chrome_sqlite3_errmsg // Line 3872
+#define sqlite3_errmsg16 chrome_sqlite3_errmsg16 // Line 3873
+#define sqlite3_error_offset chrome_sqlite3_error_offset // Line 3875
+#define sqlite3_errstr chrome_sqlite3_errstr // Line 3874
#define sqlite3_exec chrome_sqlite3_exec // Lines 425-431
-#define sqlite3_expanded_sql chrome_sqlite3_expanded_sql // Line 4231
-#define sqlite3_expired chrome_sqlite3_expired // Line 5405
-#define sqlite3_extended_errcode chrome_sqlite3_extended_errcode // Line 3863
+#define sqlite3_expanded_sql chrome_sqlite3_expanded_sql // Line 4240
+#define sqlite3_expired chrome_sqlite3_expired // Line 5424
+#define sqlite3_extended_errcode chrome_sqlite3_extended_errcode // Line 3871
#define sqlite3_extended_result_codes chrome_sqlite3_extended_result_codes // Line 2427
-#define sqlite3_file_control chrome_sqlite3_file_control // Line 7884
+#define sqlite3_file_control chrome_sqlite3_file_control // Line 7935
#define sqlite3_filename_database chrome_sqlite3_filename_database // Line 3733
#define sqlite3_filename_journal chrome_sqlite3_filename_journal // Line 3734
#define sqlite3_filename_wal chrome_sqlite3_filename_wal // Line 3735
-#define sqlite3_finalize chrome_sqlite3_finalize // Line 5114
+#define sqlite3_finalize chrome_sqlite3_finalize // Line 5133
#define sqlite3_free chrome_sqlite3_free // Line 2969
#define sqlite3_free_filename chrome_sqlite3_free_filename // Line 3808
#define sqlite3_free_table chrome_sqlite3_free_table // Line 2843
-#define sqlite3_get_autocommit chrome_sqlite3_get_autocommit // Line 6244
-#define sqlite3_get_auxdata chrome_sqlite3_get_auxdata // Line 5715
+#define sqlite3_get_autocommit chrome_sqlite3_get_autocommit // Line 6263
+#define sqlite3_get_auxdata chrome_sqlite3_get_auxdata // Line 5734
#define sqlite3_get_table chrome_sqlite3_get_table // Lines 2835-2842
-#define sqlite3_global_recover chrome_sqlite3_global_recover // Line 5407
-#define sqlite3_hard_heap_limit64 chrome_sqlite3_hard_heap_limit64 // Line 6675
+#define sqlite3_global_recover chrome_sqlite3_global_recover // Line 5426
+#define sqlite3_hard_heap_limit64 chrome_sqlite3_hard_heap_limit64 // Line 6694
#define sqlite3_initialize chrome_sqlite3_initialize // Line 1603
#define sqlite3_interrupt chrome_sqlite3_interrupt // Line 2640
-#define sqlite3_keyword_check chrome_sqlite3_keyword_check // Line 7998
-#define sqlite3_keyword_count chrome_sqlite3_keyword_count // Line 7996
-#define sqlite3_keyword_name chrome_sqlite3_keyword_name // Line 7997
+#define sqlite3_keyword_check chrome_sqlite3_keyword_check // Line 8050
+#define sqlite3_keyword_count chrome_sqlite3_keyword_count // Line 8048
+#define sqlite3_keyword_name chrome_sqlite3_keyword_name // Line 8049
#define sqlite3_last_insert_rowid chrome_sqlite3_last_insert_rowid // Line 2489
#define sqlite3_libversion chrome_sqlite3_libversion // Line 186
#define sqlite3_libversion_number chrome_sqlite3_libversion_number // Line 188
-#define sqlite3_limit chrome_sqlite3_limit // Line 3934
-#define sqlite3_load_extension chrome_sqlite3_load_extension // Lines 6814-6819
-#define sqlite3_log chrome_sqlite3_log // Line 9116
+#define sqlite3_limit chrome_sqlite3_limit // Line 3943
+#define sqlite3_load_extension chrome_sqlite3_load_extension // Lines 6833-6838
+#define sqlite3_log chrome_sqlite3_log // Line 9180
#define sqlite3_malloc chrome_sqlite3_malloc // Line 2965
#define sqlite3_malloc64 chrome_sqlite3_malloc64 // Line 2966
-#define sqlite3_memory_alarm chrome_sqlite3_memory_alarm // Lines 5409-5410
+#define sqlite3_memory_alarm chrome_sqlite3_memory_alarm // Lines 5428-5429
#define sqlite3_memory_highwater chrome_sqlite3_memory_highwater // Line 2996
#define sqlite3_memory_used chrome_sqlite3_memory_used // Line 2995
#define sqlite3_mprintf chrome_sqlite3_mprintf // Line 2885
#define sqlite3_msize chrome_sqlite3_msize // Line 2970
-#define sqlite3_mutex_alloc chrome_sqlite3_mutex_alloc // Line 7682
-#define sqlite3_mutex_enter chrome_sqlite3_mutex_enter // Line 7684
-#define sqlite3_mutex_free chrome_sqlite3_mutex_free // Line 7683
-#define sqlite3_mutex_held chrome_sqlite3_mutex_held // Line 7796
-#define sqlite3_mutex_leave chrome_sqlite3_mutex_leave // Line 7686
-#define sqlite3_mutex_notheld chrome_sqlite3_mutex_notheld // Line 7797
-#define sqlite3_mutex_try chrome_sqlite3_mutex_try // Line 7685
-#define sqlite3_next_stmt chrome_sqlite3_next_stmt // Line 6366
-#define sqlite3_normalized_sql chrome_sqlite3_normalized_sql // Line 4233
+#define sqlite3_mutex_alloc chrome_sqlite3_mutex_alloc // Line 7733
+#define sqlite3_mutex_enter chrome_sqlite3_mutex_enter // Line 7735
+#define sqlite3_mutex_free chrome_sqlite3_mutex_free // Line 7734
+#define sqlite3_mutex_held chrome_sqlite3_mutex_held // Line 7847
+#define sqlite3_mutex_leave chrome_sqlite3_mutex_leave // Line 7737
+#define sqlite3_mutex_notheld chrome_sqlite3_mutex_notheld // Line 7848
+#define sqlite3_mutex_try chrome_sqlite3_mutex_try // Line 7736
+#define sqlite3_next_stmt chrome_sqlite3_next_stmt // Line 6385
+#define sqlite3_normalized_sql chrome_sqlite3_normalized_sql // Line 4242
#define sqlite3_open chrome_sqlite3_open // Lines 3620-3623
#define sqlite3_open16 chrome_sqlite3_open16 // Lines 3624-3627
#define sqlite3_open_v2 chrome_sqlite3_open_v2 // Lines 3628-3633
#define sqlite3_os_end chrome_sqlite3_os_end // Line 1606
#define sqlite3_os_init chrome_sqlite3_os_init // Line 1605
-#define sqlite3_overload_function chrome_sqlite3_overload_function // Line 7281
-#define sqlite3_prepare chrome_sqlite3_prepare // Lines 4144-4150
-#define sqlite3_prepare16 chrome_sqlite3_prepare16 // Lines 4166-4172
-#define sqlite3_prepare16_v2 chrome_sqlite3_prepare16_v2 // Lines 4173-4179
-#define sqlite3_prepare16_v3 chrome_sqlite3_prepare16_v3 // Lines 4180-4187
-#define sqlite3_prepare_v2 chrome_sqlite3_prepare_v2 // Lines 4151-4157
-#define sqlite3_prepare_v3 chrome_sqlite3_prepare_v3 // Lines 4158-4165
-#define sqlite3_preupdate_blobwrite chrome_sqlite3_preupdate_blobwrite // Line 9729
-#define sqlite3_preupdate_count chrome_sqlite3_preupdate_count // Line 9726
-#define sqlite3_preupdate_depth chrome_sqlite3_preupdate_depth // Line 9727
-#define sqlite3_preupdate_hook chrome_sqlite3_preupdate_hook // Lines 9712-9724
-#define sqlite3_preupdate_new chrome_sqlite3_preupdate_new // Line 9728
-#define sqlite3_preupdate_old chrome_sqlite3_preupdate_old // Line 9725
+#define sqlite3_overload_function chrome_sqlite3_overload_function // Line 7332
+#define sqlite3_prepare chrome_sqlite3_prepare // Lines 4153-4159
+#define sqlite3_prepare16 chrome_sqlite3_prepare16 // Lines 4175-4181
+#define sqlite3_prepare16_v2 chrome_sqlite3_prepare16_v2 // Lines 4182-4188
+#define sqlite3_prepare16_v3 chrome_sqlite3_prepare16_v3 // Lines 4189-4196
+#define sqlite3_prepare_v2 chrome_sqlite3_prepare_v2 // Lines 4160-4166
+#define sqlite3_prepare_v3 chrome_sqlite3_prepare_v3 // Lines 4167-4174
+#define sqlite3_preupdate_blobwrite chrome_sqlite3_preupdate_blobwrite // Line 10043
+#define sqlite3_preupdate_count chrome_sqlite3_preupdate_count // Line 10040
+#define sqlite3_preupdate_depth chrome_sqlite3_preupdate_depth // Line 10041
+#define sqlite3_preupdate_hook chrome_sqlite3_preupdate_hook // Lines 10026-10038
+#define sqlite3_preupdate_new chrome_sqlite3_preupdate_new // Line 10042
+#define sqlite3_preupdate_old chrome_sqlite3_preupdate_old // Line 10039
#define sqlite3_profile chrome_sqlite3_profile // Lines 3220-3221
#define sqlite3_progress_handler chrome_sqlite3_progress_handler // Line 3348
#define sqlite3_randomness chrome_sqlite3_randomness // Line 3019
#define sqlite3_realloc chrome_sqlite3_realloc // Line 2967
#define sqlite3_realloc64 chrome_sqlite3_realloc64 // Line 2968
-#define sqlite3_release_memory chrome_sqlite3_release_memory // Line 6594
-#define sqlite3_reset chrome_sqlite3_reset // Line 5141
-#define sqlite3_reset_auto_extension chrome_sqlite3_reset_auto_extension // Line 6904
-#define sqlite3_result_blob chrome_sqlite3_result_blob // Line 5883
-#define sqlite3_result_blob64 chrome_sqlite3_result_blob64 // Lines 5884-5885
-#define sqlite3_result_double chrome_sqlite3_result_double // Line 5886
-#define sqlite3_result_error chrome_sqlite3_result_error // Line 5887
-#define sqlite3_result_error16 chrome_sqlite3_result_error16 // Line 5888
-#define sqlite3_result_error_code chrome_sqlite3_result_error_code // Line 5891
-#define sqlite3_result_error_nomem chrome_sqlite3_result_error_nomem // Line 5890
-#define sqlite3_result_error_toobig chrome_sqlite3_result_error_toobig // Line 5889
-#define sqlite3_result_int chrome_sqlite3_result_int // Line 5892
-#define sqlite3_result_int64 chrome_sqlite3_result_int64 // Line 5893
-#define sqlite3_result_null chrome_sqlite3_result_null // Line 5894
-#define sqlite3_result_pointer chrome_sqlite3_result_pointer // Line 5902
-#define sqlite3_result_subtype chrome_sqlite3_result_subtype // Line 5919
-#define sqlite3_result_text chrome_sqlite3_result_text // Line 5895
-#define sqlite3_result_text16 chrome_sqlite3_result_text16 // Line 5898
-#define sqlite3_result_text16be chrome_sqlite3_result_text16be // Line 5900
-#define sqlite3_result_text16le chrome_sqlite3_result_text16le // Line 5899
-#define sqlite3_result_text64 chrome_sqlite3_result_text64 // Lines 5896-5897
-#define sqlite3_result_value chrome_sqlite3_result_value // Line 5901
-#define sqlite3_result_zeroblob chrome_sqlite3_result_zeroblob // Line 5903
-#define sqlite3_result_zeroblob64 chrome_sqlite3_result_zeroblob64 // Line 5904
-#define sqlite3_rollback_hook chrome_sqlite3_rollback_hook // Line 6416
-#define sqlite3_rtree_geometry_callback chrome_sqlite3_rtree_geometry_callback // Lines 10114-10119
-#define sqlite3_rtree_query_callback chrome_sqlite3_rtree_query_callback // Lines 10140-10146
-#define sqlite3_serialize chrome_sqlite3_serialize // Lines 9971-9976
+#define sqlite3_release_memory chrome_sqlite3_release_memory // Line 6613
+#define sqlite3_reset chrome_sqlite3_reset // Line 5160
+#define sqlite3_reset_auto_extension chrome_sqlite3_reset_auto_extension // Line 6923
+#define sqlite3_result_blob chrome_sqlite3_result_blob // Line 5902
+#define sqlite3_result_blob64 chrome_sqlite3_result_blob64 // Lines 5903-5904
+#define sqlite3_result_double chrome_sqlite3_result_double // Line 5905
+#define sqlite3_result_error chrome_sqlite3_result_error // Line 5906
+#define sqlite3_result_error16 chrome_sqlite3_result_error16 // Line 5907
+#define sqlite3_result_error_code chrome_sqlite3_result_error_code // Line 5910
+#define sqlite3_result_error_nomem chrome_sqlite3_result_error_nomem // Line 5909
+#define sqlite3_result_error_toobig chrome_sqlite3_result_error_toobig // Line 5908
+#define sqlite3_result_int chrome_sqlite3_result_int // Line 5911
+#define sqlite3_result_int64 chrome_sqlite3_result_int64 // Line 5912
+#define sqlite3_result_null chrome_sqlite3_result_null // Line 5913
+#define sqlite3_result_pointer chrome_sqlite3_result_pointer // Line 5921
+#define sqlite3_result_subtype chrome_sqlite3_result_subtype // Line 5938
+#define sqlite3_result_text chrome_sqlite3_result_text // Line 5914
+#define sqlite3_result_text16 chrome_sqlite3_result_text16 // Line 5917
+#define sqlite3_result_text16be chrome_sqlite3_result_text16be // Line 5919
+#define sqlite3_result_text16le chrome_sqlite3_result_text16le // Line 5918
+#define sqlite3_result_text64 chrome_sqlite3_result_text64 // Lines 5915-5916
+#define sqlite3_result_value chrome_sqlite3_result_value // Line 5920
+#define sqlite3_result_zeroblob chrome_sqlite3_result_zeroblob // Line 5922
+#define sqlite3_result_zeroblob64 chrome_sqlite3_result_zeroblob64 // Line 5923
+#define sqlite3_rollback_hook chrome_sqlite3_rollback_hook // Line 6435
+#define sqlite3_rtree_geometry_callback chrome_sqlite3_rtree_geometry_callback // Lines 10428-10433
+#define sqlite3_rtree_query_callback chrome_sqlite3_rtree_query_callback // Lines 10454-10460
+#define sqlite3_serialize chrome_sqlite3_serialize // Lines 10285-10290
#define sqlite3_set_authorizer chrome_sqlite3_set_authorizer // Lines 3110-3114
-#define sqlite3_set_auxdata chrome_sqlite3_set_auxdata // Line 5716
+#define sqlite3_set_auxdata chrome_sqlite3_set_auxdata // Line 5735
#define sqlite3_set_last_insert_rowid chrome_sqlite3_set_last_insert_rowid // Line 2499
#define sqlite3_shutdown chrome_sqlite3_shutdown // Line 1604
-#define sqlite3_sleep chrome_sqlite3_sleep // Line 6090
-#define sqlite3_snapshot_cmp chrome_sqlite3_snapshot_cmp // Lines 9905-9908
-#define sqlite3_snapshot_free chrome_sqlite3_snapshot_free // Line 9878
-#define sqlite3_snapshot_get chrome_sqlite3_snapshot_get // Lines 9812-9816
-#define sqlite3_snapshot_open chrome_sqlite3_snapshot_open // Lines 9861-9865
-#define sqlite3_snapshot_recover chrome_sqlite3_snapshot_recover // Line 9933
+#define sqlite3_sleep chrome_sqlite3_sleep // Line 6109
+#define sqlite3_snapshot_cmp chrome_sqlite3_snapshot_cmp // Lines 10219-10222
+#define sqlite3_snapshot_free chrome_sqlite3_snapshot_free // Line 10192
+#define sqlite3_snapshot_get chrome_sqlite3_snapshot_get // Lines 10126-10130
+#define sqlite3_snapshot_open chrome_sqlite3_snapshot_open // Lines 10175-10179
+#define sqlite3_snapshot_recover chrome_sqlite3_snapshot_recover // Line 10247
#define sqlite3_snprintf chrome_sqlite3_snprintf // Line 2887
-#define sqlite3_soft_heap_limit chrome_sqlite3_soft_heap_limit // Line 6686
-#define sqlite3_soft_heap_limit64 chrome_sqlite3_soft_heap_limit64 // Line 6674
+#define sqlite3_soft_heap_limit chrome_sqlite3_soft_heap_limit // Line 6705
+#define sqlite3_soft_heap_limit64 chrome_sqlite3_soft_heap_limit64 // Line 6693
#define sqlite3_sourceid chrome_sqlite3_sourceid // Line 187
-#define sqlite3_sql chrome_sqlite3_sql // Line 4230
-#define sqlite3_status chrome_sqlite3_status // Line 8158
-#define sqlite3_status64 chrome_sqlite3_status64 // Lines 8159-8164
-#define sqlite3_step chrome_sqlite3_step // Line 4813
-#define sqlite3_stmt_busy chrome_sqlite3_stmt_busy // Line 4312
-#define sqlite3_stmt_isexplain chrome_sqlite3_stmt_isexplain // Line 4291
-#define sqlite3_stmt_readonly chrome_sqlite3_stmt_readonly // Line 4279
-#define sqlite3_stmt_scanstatus chrome_sqlite3_stmt_scanstatus // Lines 9568-9573
-#define sqlite3_stmt_scanstatus_reset chrome_sqlite3_stmt_scanstatus_reset // Line 9584
-#define sqlite3_stmt_status chrome_sqlite3_stmt_status // Line 8421
-#define sqlite3_str_append chrome_sqlite3_str_append // Line 8094
-#define sqlite3_str_appendall chrome_sqlite3_str_appendall // Line 8095
-#define sqlite3_str_appendchar chrome_sqlite3_str_appendchar // Line 8096
-#define sqlite3_str_appendf chrome_sqlite3_str_appendf // Line 8092
-#define sqlite3_str_errcode chrome_sqlite3_str_errcode // Line 8128
-#define sqlite3_str_finish chrome_sqlite3_str_finish // Line 8058
-#define sqlite3_str_length chrome_sqlite3_str_length // Line 8129
-#define sqlite3_str_new chrome_sqlite3_str_new // Line 8043
-#define sqlite3_str_reset chrome_sqlite3_str_reset // Line 8097
-#define sqlite3_str_value chrome_sqlite3_str_value // Line 8130
-#define sqlite3_str_vappendf chrome_sqlite3_str_vappendf // Line 8093
-#define sqlite3_strglob chrome_sqlite3_strglob // Line 9070
-#define sqlite3_stricmp chrome_sqlite3_stricmp // Line 9052
-#define sqlite3_strlike chrome_sqlite3_strlike // Line 9093
-#define sqlite3_strnicmp chrome_sqlite3_strnicmp // Line 9053
-#define sqlite3_system_errno chrome_sqlite3_system_errno // Line 9743
-#define sqlite3_table_column_metadata chrome_sqlite3_table_column_metadata // Lines 6758-6768
-#define sqlite3_temp_directory chrome_sqlite3_temp_directory // Line 6148
-#define sqlite3_test_control chrome_sqlite3_test_control // Line 7903
-#define sqlite3_thread_cleanup chrome_sqlite3_thread_cleanup // Line 5408
+#define sqlite3_sql chrome_sqlite3_sql // Line 4239
+#define sqlite3_status chrome_sqlite3_status // Line 8210
+#define sqlite3_status64 chrome_sqlite3_status64 // Lines 8211-8216
+#define sqlite3_step chrome_sqlite3_step // Line 4828
+#define sqlite3_stmt_busy chrome_sqlite3_stmt_busy // Line 4325
+#define sqlite3_stmt_isexplain chrome_sqlite3_stmt_isexplain // Line 4304
+#define sqlite3_stmt_readonly chrome_sqlite3_stmt_readonly // Line 4292
+#define sqlite3_stmt_scanstatus chrome_sqlite3_stmt_scanstatus // Lines 9882-9887
+#define sqlite3_stmt_scanstatus_reset chrome_sqlite3_stmt_scanstatus_reset // Line 9898
+#define sqlite3_stmt_status chrome_sqlite3_stmt_status // Line 8473
+#define sqlite3_str_append chrome_sqlite3_str_append // Line 8146
+#define sqlite3_str_appendall chrome_sqlite3_str_appendall // Line 8147
+#define sqlite3_str_appendchar chrome_sqlite3_str_appendchar // Line 8148
+#define sqlite3_str_appendf chrome_sqlite3_str_appendf // Line 8144
+#define sqlite3_str_errcode chrome_sqlite3_str_errcode // Line 8180
+#define sqlite3_str_finish chrome_sqlite3_str_finish // Line 8110
+#define sqlite3_str_length chrome_sqlite3_str_length // Line 8181
+#define sqlite3_str_new chrome_sqlite3_str_new // Line 8095
+#define sqlite3_str_reset chrome_sqlite3_str_reset // Line 8149
+#define sqlite3_str_value chrome_sqlite3_str_value // Line 8182
+#define sqlite3_str_vappendf chrome_sqlite3_str_vappendf // Line 8145
+#define sqlite3_strglob chrome_sqlite3_strglob // Line 9134
+#define sqlite3_stricmp chrome_sqlite3_stricmp // Line 9116
+#define sqlite3_strlike chrome_sqlite3_strlike // Line 9157
+#define sqlite3_strnicmp chrome_sqlite3_strnicmp // Line 9117
+#define sqlite3_system_errno chrome_sqlite3_system_errno // Line 10057
+#define sqlite3_table_column_metadata chrome_sqlite3_table_column_metadata // Lines 6777-6787
+#define sqlite3_temp_directory chrome_sqlite3_temp_directory // Line 6167
+#define sqlite3_test_control chrome_sqlite3_test_control // Line 7954
+#define sqlite3_thread_cleanup chrome_sqlite3_thread_cleanup // Line 5427
#define sqlite3_threadsafe chrome_sqlite3_threadsafe // Line 256
#define sqlite3_total_changes chrome_sqlite3_total_changes // Line 2602
#define sqlite3_total_changes64 chrome_sqlite3_total_changes64 // Line 2603
#define sqlite3_trace chrome_sqlite3_trace // Lines 3218-3219
#define sqlite3_trace_v2 chrome_sqlite3_trace_v2 // Lines 3309-3314
-#define sqlite3_transfer_bindings chrome_sqlite3_transfer_bindings // Line 5406
-#define sqlite3_txn_state chrome_sqlite3_txn_state // Line 6317
-#define sqlite3_unlock_notify chrome_sqlite3_unlock_notify // Lines 9037-9041
-#define sqlite3_update_hook chrome_sqlite3_update_hook // Lines 6533-6537
+#define sqlite3_transfer_bindings chrome_sqlite3_transfer_bindings // Line 5425
+#define sqlite3_txn_state chrome_sqlite3_txn_state // Line 6336
+#define sqlite3_unlock_notify chrome_sqlite3_unlock_notify // Lines 9101-9105
+#define sqlite3_update_hook chrome_sqlite3_update_hook // Lines 6552-6556
#define sqlite3_uri_boolean chrome_sqlite3_uri_boolean // Line 3702
#define sqlite3_uri_int64 chrome_sqlite3_uri_int64 // Line 3703
#define sqlite3_uri_key chrome_sqlite3_uri_key // Line 3704
#define sqlite3_uri_parameter chrome_sqlite3_uri_parameter // Line 3701
-#define sqlite3_user_data chrome_sqlite3_user_data // Line 5644
-#define sqlite3_value_blob chrome_sqlite3_value_blob // Line 5541
-#define sqlite3_value_bytes chrome_sqlite3_value_bytes // Line 5550
-#define sqlite3_value_bytes16 chrome_sqlite3_value_bytes16 // Line 5551
-#define sqlite3_value_double chrome_sqlite3_value_double // Line 5542
-#define sqlite3_value_dup chrome_sqlite3_value_dup // Line 5583
-#define sqlite3_value_free chrome_sqlite3_value_free // Line 5584
-#define sqlite3_value_frombind chrome_sqlite3_value_frombind // Line 5555
-#define sqlite3_value_int chrome_sqlite3_value_int // Line 5543
-#define sqlite3_value_int64 chrome_sqlite3_value_int64 // Line 5544
-#define sqlite3_value_nochange chrome_sqlite3_value_nochange // Line 5554
-#define sqlite3_value_numeric_type chrome_sqlite3_value_numeric_type // Line 5553
-#define sqlite3_value_pointer chrome_sqlite3_value_pointer // Line 5545
-#define sqlite3_value_subtype chrome_sqlite3_value_subtype // Line 5567
-#define sqlite3_value_text chrome_sqlite3_value_text // Line 5546
-#define sqlite3_value_text16 chrome_sqlite3_value_text16 // Line 5547
-#define sqlite3_value_text16be chrome_sqlite3_value_text16be // Line 5549
-#define sqlite3_value_text16le chrome_sqlite3_value_text16le // Line 5548
-#define sqlite3_value_type chrome_sqlite3_value_type // Line 5552
+#define sqlite3_user_data chrome_sqlite3_user_data // Line 5663
+#define sqlite3_value_blob chrome_sqlite3_value_blob // Line 5560
+#define sqlite3_value_bytes chrome_sqlite3_value_bytes // Line 5569
+#define sqlite3_value_bytes16 chrome_sqlite3_value_bytes16 // Line 5570
+#define sqlite3_value_double chrome_sqlite3_value_double // Line 5561
+#define sqlite3_value_dup chrome_sqlite3_value_dup // Line 5602
+#define sqlite3_value_free chrome_sqlite3_value_free // Line 5603
+#define sqlite3_value_frombind chrome_sqlite3_value_frombind // Line 5574
+#define sqlite3_value_int chrome_sqlite3_value_int // Line 5562
+#define sqlite3_value_int64 chrome_sqlite3_value_int64 // Line 5563
+#define sqlite3_value_nochange chrome_sqlite3_value_nochange // Line 5573
+#define sqlite3_value_numeric_type chrome_sqlite3_value_numeric_type // Line 5572
+#define sqlite3_value_pointer chrome_sqlite3_value_pointer // Line 5564
+#define sqlite3_value_subtype chrome_sqlite3_value_subtype // Line 5586
+#define sqlite3_value_text chrome_sqlite3_value_text // Line 5565
+#define sqlite3_value_text16 chrome_sqlite3_value_text16 // Line 5566
+#define sqlite3_value_text16be chrome_sqlite3_value_text16be // Line 5568
+#define sqlite3_value_text16le chrome_sqlite3_value_text16le // Line 5567
+#define sqlite3_value_type chrome_sqlite3_value_type // Line 5571
#define sqlite3_version chrome_sqlite3_version // Line 185
-#define sqlite3_vfs_find chrome_sqlite3_vfs_find // Line 7564
-#define sqlite3_vfs_register chrome_sqlite3_vfs_register // Line 7565
-#define sqlite3_vfs_unregister chrome_sqlite3_vfs_unregister // Line 7566
+#define sqlite3_vfs_find chrome_sqlite3_vfs_find // Line 7615
+#define sqlite3_vfs_register chrome_sqlite3_vfs_register // Line 7616
+#define sqlite3_vfs_unregister chrome_sqlite3_vfs_unregister // Line 7617
#define sqlite3_vmprintf chrome_sqlite3_vmprintf // Line 2886
#define sqlite3_vsnprintf chrome_sqlite3_vsnprintf // Line 2888
-#define sqlite3_vtab_collation chrome_sqlite3_vtab_collation // Line 9463
-#define sqlite3_vtab_config chrome_sqlite3_vtab_config // Line 9344
-#define sqlite3_vtab_nochange chrome_sqlite3_vtab_nochange // Line 9448
-#define sqlite3_vtab_on_conflict chrome_sqlite3_vtab_on_conflict // Line 9422
-#define sqlite3_wal_autocheckpoint chrome_sqlite3_wal_autocheckpoint // Line 9188
-#define sqlite3_wal_checkpoint chrome_sqlite3_wal_checkpoint // Line 9210
-#define sqlite3_wal_checkpoint_v2 chrome_sqlite3_wal_checkpoint_v2 // Lines 9304-9310
-#define sqlite3_wal_hook chrome_sqlite3_wal_hook // Lines 9153-9157
-#define sqlite3_win32_set_directory chrome_sqlite3_win32_set_directory // Lines 6206-6209
-#define sqlite3_win32_set_directory16 chrome_sqlite3_win32_set_directory16 // Line 6211
-#define sqlite3_win32_set_directory8 chrome_sqlite3_win32_set_directory8 // Line 6210
-#define sqlite3changegroup_add chrome_sqlite3changegroup_add // Line 11188
-#define sqlite3changegroup_add_strm chrome_sqlite3changegroup_add_strm // Lines 11850-11853
-#define sqlite3changegroup_delete chrome_sqlite3changegroup_delete // Line 11225
-#define sqlite3changegroup_new chrome_sqlite3changegroup_new // Line 11110
-#define sqlite3changegroup_output chrome_sqlite3changegroup_output // Lines 11215-11219
-#define sqlite3changegroup_output_strm chrome_sqlite3changegroup_output_strm // Lines 11854-11857
-#define sqlite3changeset_apply chrome_sqlite3changeset_apply // Lines 11385-11399
-#define sqlite3changeset_apply_strm chrome_sqlite3changeset_apply_strm // Lines 11783-11797
-#define sqlite3changeset_apply_v2 chrome_sqlite3changeset_apply_v2 // Lines 11400-11416
-#define sqlite3changeset_apply_v2_strm chrome_sqlite3changeset_apply_v2_strm // Lines 11798-11814
-#define sqlite3changeset_concat chrome_sqlite3changeset_concat // Lines 11056-11063
-#define sqlite3changeset_concat_strm chrome_sqlite3changeset_concat_strm // Lines 11815-11822
-#define sqlite3changeset_conflict chrome_sqlite3changeset_conflict // Lines 10942-10946
-#define sqlite3changeset_finalize chrome_sqlite3changeset_finalize // Line 10995
-#define sqlite3changeset_fk_conflicts chrome_sqlite3changeset_fk_conflicts // Lines 10959-10962
-#define sqlite3changeset_invert chrome_sqlite3changeset_invert // Lines 11025-11028
-#define sqlite3changeset_invert_strm chrome_sqlite3changeset_invert_strm // Lines 11823-11828
-#define sqlite3changeset_new chrome_sqlite3changeset_new // Lines 10914-10918
-#define sqlite3changeset_next chrome_sqlite3changeset_next // Line 10781
-#define sqlite3changeset_old chrome_sqlite3changeset_old // Lines 10880-10884
-#define sqlite3changeset_op chrome_sqlite3changeset_op // Lines 10815-10821
-#define sqlite3changeset_pk chrome_sqlite3changeset_pk // Lines 10849-10853
-#define sqlite3changeset_start chrome_sqlite3changeset_start // Lines 10732-10736
-#define sqlite3changeset_start_strm chrome_sqlite3changeset_start_strm // Lines 11829-11833
-#define sqlite3changeset_start_v2 chrome_sqlite3changeset_start_v2 // Lines 10737-10742
-#define sqlite3changeset_start_v2_strm chrome_sqlite3changeset_start_v2_strm // Lines 11834-11839
-#define sqlite3rebaser_configure chrome_sqlite3rebaser_configure // Lines 11658-11661
-#define sqlite3rebaser_create chrome_sqlite3rebaser_create // Line 11647
-#define sqlite3rebaser_delete chrome_sqlite3rebaser_delete // Line 11691
-#define sqlite3rebaser_rebase chrome_sqlite3rebaser_rebase // Lines 11677-11681
-#define sqlite3rebaser_rebase_strm chrome_sqlite3rebaser_rebase_strm // Lines 11858-11864
-#define sqlite3session_attach chrome_sqlite3session_attach // Lines 10415-10418
-#define sqlite3session_changeset chrome_sqlite3session_changeset // Lines 10544-10548
-#define sqlite3session_changeset_size chrome_sqlite3session_changeset_size // Line 10564
-#define sqlite3session_changeset_strm chrome_sqlite3session_changeset_strm // Lines 11840-11844
-#define sqlite3session_config chrome_sqlite3session_config // Line 11899
-#define sqlite3session_create chrome_sqlite3session_create // Lines 10253-10257
-#define sqlite3session_delete chrome_sqlite3session_delete // Line 10272
-#define sqlite3session_diff chrome_sqlite3session_diff // Lines 10623-10628
-#define sqlite3session_enable chrome_sqlite3session_enable // Line 10325
-#define sqlite3session_indirect chrome_sqlite3session_indirect // Line 10355
-#define sqlite3session_isempty chrome_sqlite3session_isempty // Line 10681
-#define sqlite3session_memory_used chrome_sqlite3session_memory_used // Line 10689
-#define sqlite3session_object_config chrome_sqlite3session_object_config // Line 10301
-#define sqlite3session_patchset chrome_sqlite3session_patchset // Lines 10660-10664
-#define sqlite3session_patchset_strm chrome_sqlite3session_patchset_strm // Lines 11845-11849
-#define sqlite3session_table_filter chrome_sqlite3session_table_filter // Lines 10430-10437
+#define sqlite3_vtab_collation chrome_sqlite3_vtab_collation // Line 9547
+#define sqlite3_vtab_config chrome_sqlite3_vtab_config // Line 9408
+#define sqlite3_vtab_distinct chrome_sqlite3_vtab_distinct // Line 9613
+#define sqlite3_vtab_in chrome_sqlite3_vtab_in // Line 9686
+#define sqlite3_vtab_in_first chrome_sqlite3_vtab_in_first // Line 9734
+#define sqlite3_vtab_in_next chrome_sqlite3_vtab_in_next // Line 9735
+#define sqlite3_vtab_nochange chrome_sqlite3_vtab_nochange // Line 9512
+#define sqlite3_vtab_on_conflict chrome_sqlite3_vtab_on_conflict // Line 9486
+#define sqlite3_vtab_rhs_value chrome_sqlite3_vtab_rhs_value // Line 9777
+#define sqlite3_wal_autocheckpoint chrome_sqlite3_wal_autocheckpoint // Line 9252
+#define sqlite3_wal_checkpoint chrome_sqlite3_wal_checkpoint // Line 9274
+#define sqlite3_wal_checkpoint_v2 chrome_sqlite3_wal_checkpoint_v2 // Lines 9368-9374
+#define sqlite3_wal_hook chrome_sqlite3_wal_hook // Lines 9217-9221
+#define sqlite3_win32_set_directory chrome_sqlite3_win32_set_directory // Lines 6225-6228
+#define sqlite3_win32_set_directory16 chrome_sqlite3_win32_set_directory16 // Line 6230
+#define sqlite3_win32_set_directory8 chrome_sqlite3_win32_set_directory8 // Line 6229
+#define sqlite3changegroup_add chrome_sqlite3changegroup_add // Line 11502
+#define sqlite3changegroup_add_strm chrome_sqlite3changegroup_add_strm // Lines 12164-12167
+#define sqlite3changegroup_delete chrome_sqlite3changegroup_delete // Line 11539
+#define sqlite3changegroup_new chrome_sqlite3changegroup_new // Line 11424
+#define sqlite3changegroup_output chrome_sqlite3changegroup_output // Lines 11529-11533
+#define sqlite3changegroup_output_strm chrome_sqlite3changegroup_output_strm // Lines 12168-12171
+#define sqlite3changeset_apply chrome_sqlite3changeset_apply // Lines 11699-11713
+#define sqlite3changeset_apply_strm chrome_sqlite3changeset_apply_strm // Lines 12097-12111
+#define sqlite3changeset_apply_v2 chrome_sqlite3changeset_apply_v2 // Lines 11714-11730
+#define sqlite3changeset_apply_v2_strm chrome_sqlite3changeset_apply_v2_strm // Lines 12112-12128
+#define sqlite3changeset_concat chrome_sqlite3changeset_concat // Lines 11370-11377
+#define sqlite3changeset_concat_strm chrome_sqlite3changeset_concat_strm // Lines 12129-12136
+#define sqlite3changeset_conflict chrome_sqlite3changeset_conflict // Lines 11256-11260
+#define sqlite3changeset_finalize chrome_sqlite3changeset_finalize // Line 11309
+#define sqlite3changeset_fk_conflicts chrome_sqlite3changeset_fk_conflicts // Lines 11273-11276
+#define sqlite3changeset_invert chrome_sqlite3changeset_invert // Lines 11339-11342
+#define sqlite3changeset_invert_strm chrome_sqlite3changeset_invert_strm // Lines 12137-12142
+#define sqlite3changeset_new chrome_sqlite3changeset_new // Lines 11228-11232
+#define sqlite3changeset_next chrome_sqlite3changeset_next // Line 11095
+#define sqlite3changeset_old chrome_sqlite3changeset_old // Lines 11194-11198
+#define sqlite3changeset_op chrome_sqlite3changeset_op // Lines 11129-11135
+#define sqlite3changeset_pk chrome_sqlite3changeset_pk // Lines 11163-11167
+#define sqlite3changeset_start chrome_sqlite3changeset_start // Lines 11046-11050
+#define sqlite3changeset_start_strm chrome_sqlite3changeset_start_strm // Lines 12143-12147
+#define sqlite3changeset_start_v2 chrome_sqlite3changeset_start_v2 // Lines 11051-11056
+#define sqlite3changeset_start_v2_strm chrome_sqlite3changeset_start_v2_strm // Lines 12148-12153
+#define sqlite3rebaser_configure chrome_sqlite3rebaser_configure // Lines 11972-11975
+#define sqlite3rebaser_create chrome_sqlite3rebaser_create // Line 11961
+#define sqlite3rebaser_delete chrome_sqlite3rebaser_delete // Line 12005
+#define sqlite3rebaser_rebase chrome_sqlite3rebaser_rebase // Lines 11991-11995
+#define sqlite3rebaser_rebase_strm chrome_sqlite3rebaser_rebase_strm // Lines 12172-12178
+#define sqlite3session_attach chrome_sqlite3session_attach // Lines 10729-10732
+#define sqlite3session_changeset chrome_sqlite3session_changeset // Lines 10858-10862
+#define sqlite3session_changeset_size chrome_sqlite3session_changeset_size // Line 10878
+#define sqlite3session_changeset_strm chrome_sqlite3session_changeset_strm // Lines 12154-12158
+#define sqlite3session_config chrome_sqlite3session_config // Line 12213
+#define sqlite3session_create chrome_sqlite3session_create // Lines 10567-10571
+#define sqlite3session_delete chrome_sqlite3session_delete // Line 10586
+#define sqlite3session_diff chrome_sqlite3session_diff // Lines 10937-10942
+#define sqlite3session_enable chrome_sqlite3session_enable // Line 10639
+#define sqlite3session_indirect chrome_sqlite3session_indirect // Line 10669
+#define sqlite3session_isempty chrome_sqlite3session_isempty // Line 10995
+#define sqlite3session_memory_used chrome_sqlite3session_memory_used // Line 11003
+#define sqlite3session_object_config chrome_sqlite3session_object_config // Line 10615
+#define sqlite3session_patchset chrome_sqlite3session_patchset // Lines 10974-10978
+#define sqlite3session_patchset_strm chrome_sqlite3session_patchset_strm // Lines 12159-12163
+#define sqlite3session_table_filter chrome_sqlite3session_table_filter // Lines 10744-10751
#endif // THIRD_PARTY_SQLITE_AMALGAMATION_RENAME_EXPORTS_H_
diff --git a/chromium/third_party/sqlite/src/amalgamation_dev/shell/shell.c b/chromium/third_party/sqlite/src/amalgamation_dev/shell/shell.c
index 26c0ae57174..cf830f13f5a 100644
--- a/chromium/third_party/sqlite/src/amalgamation_dev/shell/shell.c
+++ b/chromium/third_party/sqlite/src/amalgamation_dev/shell/shell.c
@@ -41,10 +41,10 @@
** If SQLITE_CUSTOM_INCLUDE=? is defined, its value names the #include
** file. Note that this macro has a like effect on sqlite3.c compilation.
*/
+# define SHELL_STRINGIFY_(f) #f
+# define SHELL_STRINGIFY(f) SHELL_STRINGIFY_(f)
#ifdef SQLITE_CUSTOM_INCLUDE
-# define INC_STRINGIFY_(f) #f
-# define INC_STRINGIFY(f) INC_STRINGIFY_(f)
-# include INC_STRINGIFY(SQLITE_CUSTOM_INCLUDE)
+# include SHELL_STRINGIFY(SQLITE_CUSTOM_INCLUDE)
#endif
/*
@@ -445,15 +445,6 @@ static sqlite3 *globalDb = 0;
*/
static volatile int seenInterrupt = 0;
-#ifdef SQLITE_DEBUG
-/*
-** Out-of-memory simulator variables
-*/
-static unsigned int oomCounter = 0; /* Simulate OOM when equals 1 */
-static unsigned int oomRepeat = 0; /* Number of OOMs in a row */
-static void*(*defaultMalloc)(int) = 0; /* The low-level malloc routine */
-#endif /* SQLITE_DEBUG */
-
/*
** This is the name of our program. It is set in main(), used
** in a number of other places, mostly for error messages.
@@ -505,48 +496,12 @@ static void shell_out_of_memory(void){
exit(1);
}
-#ifdef SQLITE_DEBUG
-/* This routine is called when a simulated OOM occurs. It is broken
-** out as a separate routine to make it easy to set a breakpoint on
-** the OOM
-*/
-void shellOomFault(void){
- if( oomRepeat>0 ){
- oomRepeat--;
- }else{
- oomCounter--;
- }
-}
-#endif /* SQLITE_DEBUG */
-
-#ifdef SQLITE_DEBUG
-/* This routine is a replacement malloc() that is used to simulate
-** Out-Of-Memory (OOM) errors for testing purposes.
+/* Check a pointer to see if it is NULL. If it is NULL, exit with an
+** out-of-memory error.
*/
-static void *oomMalloc(int nByte){
- if( oomCounter ){
- if( oomCounter==1 ){
- shellOomFault();
- return 0;
- }else{
- oomCounter--;
- }
- }
- return defaultMalloc(nByte);
-}
-#endif /* SQLITE_DEBUG */
-
-#ifdef SQLITE_DEBUG
-/* Register the OOM simulator. This must occur before any memory
-** allocations */
-static void registerOomSimulator(void){
- sqlite3_mem_methods mem;
- sqlite3_config(SQLITE_CONFIG_GETMALLOC, &mem);
- defaultMalloc = mem.xMalloc;
- mem.xMalloc = oomMalloc;
- sqlite3_config(SQLITE_CONFIG_MALLOC, &mem);
+static void shell_check_oom(void *p){
+ if( p==0 ) shell_out_of_memory();
}
-#endif
/*
** Write I/O traces to the following stream.
@@ -703,7 +658,7 @@ static char *local_getline(char *zLine, FILE *in){
if( n+100>nLine ){
nLine = nLine*2 + 100;
zLine = realloc(zLine, nLine);
- if( zLine==0 ) shell_out_of_memory();
+ shell_check_oom(zLine);
}
if( fgets(&zLine[n], nLine - n, in)==0 ){
if( n==0 ){
@@ -730,7 +685,7 @@ static char *local_getline(char *zLine, FILE *in){
int nTrans = strlen30(zTrans)+1;
if( nTrans>nLine ){
zLine = realloc(zLine, nTrans);
- if( zLine==0 ) shell_out_of_memory();
+ shell_check_oom(zLine);
}
memcpy(zLine, zTrans, nTrans);
sqlite3_free(zTrans);
@@ -877,7 +832,7 @@ static void appendText(ShellText *p, char const *zAppend, char quote){
if( p->z==0 || p->n+len>=p->nAlloc ){
p->nAlloc = p->nAlloc*2 + len + 20;
p->z = realloc(p->z, p->nAlloc);
- if( p->z==0 ) shell_out_of_memory();
+ shell_check_oom(p->z);
}
if( quote ){
@@ -932,6 +887,7 @@ static char *shellFakeSchema(
zSql = sqlite3_mprintf("PRAGMA \"%w\".table_info=%Q;",
zSchema ? zSchema : "main", zName);
+ shell_check_oom(zSql);
sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);
sqlite3_free(zSql);
initText(&s);
@@ -948,6 +904,7 @@ static char *shellFakeSchema(
nRow++;
appendText(&s, zDiv, 0);
zDiv = ",";
+ if( zCol==0 ) zCol = "";
cQuote = quoteChar(zCol);
appendText(&s, zCol, cQuote);
}
@@ -971,9 +928,11 @@ static void shellModuleSchema(
int nVal,
sqlite3_value **apVal
){
- const char *zName = (const char*)sqlite3_value_text(apVal[0]);
- char *zFake = shellFakeSchema(sqlite3_context_db_handle(pCtx), 0, zName);
+ const char *zName;
+ char *zFake;
UNUSED_PARAMETER(nVal);
+ zName = (const char*)sqlite3_value_text(apVal[0]);
+ zFake = zName ? shellFakeSchema(sqlite3_context_db_handle(pCtx), 0, zName) : 0;
if( zFake ){
sqlite3_result_text(pCtx, sqlite3_mprintf("/* %s */", zFake),
-1, sqlite3_free);
@@ -1861,6 +1820,7 @@ static void SHA3Update(
unsigned int nData
){
unsigned int i = 0;
+ if( aData==0 ) return;
#if SHA3_BYTEORDER==1234
if( (p->nLoaded % 8)==0 && ((aData - (const unsigned char*)0)&7)==0 ){
for(; i+7<nData; i+=8){
@@ -2519,10 +2479,11 @@ static int writeFile(
mode_t mode, /* MODE parameter passed to writefile() */
sqlite3_int64 mtime /* MTIME parameter (or -1 to not set time) */
){
+ if( zFile==0 ) return 1;
#if !defined(_WIN32) && !defined(WIN32)
if( S_ISLNK(mode) ){
const char *zTo = (const char*)sqlite3_value_text(pData);
- if( symlink(zTo, zFile)<0 ) return 1;
+ if( zTo==0 || symlink(zTo, zFile)<0 ) return 1;
}else
#endif
{
@@ -5490,7 +5451,7 @@ int sqlite3_ieee_init(
SQLITE_EXTENSION_INIT2(pApi);
(void)pzErrMsg; /* Unused parameter */
for(i=0; i<sizeof(aFunc)/sizeof(aFunc[0]) && rc==SQLITE_OK; i++){
- rc = sqlite3_create_function(db, aFunc[i].zFName, aFunc[i].nArg,
+ rc = sqlite3_create_function(db, aFunc[i].zFName, aFunc[i].nArg,
SQLITE_UTF8|SQLITE_INNOCUOUS,
(void*)&aFunc[i].iAux,
aFunc[i].xFunc, 0, 0);
@@ -5888,7 +5849,7 @@ static int seriesBestIndex(
** the preferred case */
pIdxInfo->estimatedCost = (double)(2 - ((idxNum&4)!=0));
pIdxInfo->estimatedRows = 1000;
- if( pIdxInfo->nOrderBy==1 ){
+ if( pIdxInfo->nOrderBy>=1 && pIdxInfo->aOrderBy[0].iColumn==0 ){
if( pIdxInfo->aOrderBy[0].desc ){
idxNum |= 8;
}else{
@@ -6723,13 +6684,15 @@ int sqlite3_regexp_init(
int rc = SQLITE_OK;
SQLITE_EXTENSION_INIT2(pApi);
(void)pzErrMsg; /* Unused */
- rc = sqlite3_create_function(db, "regexp", 2, SQLITE_UTF8|SQLITE_INNOCUOUS,
- 0, re_sql_func, 0, 0);
+ rc = sqlite3_create_function(db, "regexp", 2,
+ SQLITE_UTF8|SQLITE_INNOCUOUS|SQLITE_DETERMINISTIC,
+ 0, re_sql_func, 0, 0);
if( rc==SQLITE_OK ){
/* The regexpi(PATTERN,STRING) function is a case-insensitive version
** of regexp(PATTERN,STRING). */
- rc = sqlite3_create_function(db, "regexpi", 2, SQLITE_UTF8|SQLITE_INNOCUOUS,
- (void*)db, re_sql_func, 0, 0);
+ rc = sqlite3_create_function(db, "regexpi", 2,
+ SQLITE_UTF8|SQLITE_INNOCUOUS|SQLITE_DETERMINISTIC,
+ (void*)db, re_sql_func, 0, 0);
}
return rc;
}
@@ -8677,7 +8640,7 @@ static int zipfileBufferGrow(ZipfileBuffer *pBuf, int nByte){
** SELECT zipfile(name,mode,mtime,data) ...
** SELECT zipfile(name,mode,mtime,data,method) ...
*/
-void zipfileStep(sqlite3_context *pCtx, int nVal, sqlite3_value **apVal){
+static void zipfileStep(sqlite3_context *pCtx, int nVal, sqlite3_value **apVal){
ZipfileCtx *p; /* Aggregate function context */
ZipfileEntry e; /* New entry to add to zip archive */
@@ -8852,7 +8815,7 @@ void zipfileStep(sqlite3_context *pCtx, int nVal, sqlite3_value **apVal){
/*
** xFinalize() callback for zipfile aggregate function.
*/
-void zipfileFinal(sqlite3_context *pCtx){
+static void zipfileFinal(sqlite3_context *pCtx){
ZipfileCtx *p;
ZipfileEOCD eocd;
sqlite3_int64 nZip;
@@ -9941,17 +9904,25 @@ static int idxGetTableInfo(
){
sqlite3_stmt *p1 = 0;
int nCol = 0;
- int nTab = STRLEN(zTab);
- int nByte = sizeof(IdxTable) + nTab + 1;
+ int nTab;
+ int nByte;
IdxTable *pNew = 0;
int rc, rc2;
char *pCsr = 0;
int nPk = 0;
+ *ppOut = 0;
+ if( zTab==0 ) return SQLITE_ERROR;
+ nTab = STRLEN(zTab);
+ nByte = sizeof(IdxTable) + nTab + 1;
rc = idxPrintfPrepareStmt(db, &p1, pzErrmsg, "PRAGMA table_xinfo=%Q", zTab);
while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(p1) ){
const char *zCol = (const char*)sqlite3_column_text(p1, 1);
const char *zColSeq = 0;
+ if( zCol==0 ){
+ rc = SQLITE_ERROR;
+ break;
+ }
nByte += 1 + STRLEN(zCol);
rc = sqlite3_table_column_metadata(
db, "main", zTab, zCol, 0, &zColSeq, 0, 0, 0
@@ -9978,7 +9949,9 @@ static int idxGetTableInfo(
while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(p1) ){
const char *zCol = (const char*)sqlite3_column_text(p1, 1);
const char *zColSeq = 0;
- int nCopy = STRLEN(zCol) + 1;
+ int nCopy;
+ if( zCol==0 ) continue;
+ nCopy = STRLEN(zCol) + 1;
pNew->aCol[nCol].zName = pCsr;
pNew->aCol[nCol].iPk = (sqlite3_column_int(p1, 5)==1 && nPk==1);
memcpy(pCsr, zCol, nCopy);
@@ -10130,6 +10103,7 @@ static int idxFindCompatible(
IdxConstraint *pT = pTail;
sqlite3_stmt *pInfo = 0;
const char *zIdx = (const char*)sqlite3_column_text(pIdxList, 1);
+ if( zIdx==0 ) continue;
/* Zero the IdxConstraint.bFlag values in the pEq list */
for(pIter=pEq; pIter; pIter=pIter->pLink) pIter->bFlag = 0;
@@ -10412,7 +10386,7 @@ static void idxWriteFree(IdxWrite *pTab){
** runs all the queries to see which indexes they prefer, and populates
** IdxStatement.zIdx and IdxStatement.zEQP with the results.
*/
-int idxFindIndexes(
+static int idxFindIndexes(
sqlite3expert *p,
char **pzErr /* OUT: Error message (sqlite3_malloc) */
){
@@ -10541,6 +10515,7 @@ static int idxProcessOneTrigger(
rc = idxPrintfPrepareStmt(p->db, &pSelect, pzErr, zSql, zTab, zTab);
while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pSelect) ){
const char *zCreate = (const char*)sqlite3_column_text(pSelect, 0);
+ if( zCreate==0 ) continue;
rc = sqlite3_exec(p->dbv, zCreate, 0, 0, pzErr);
}
idxFinalize(&rc, pSelect);
@@ -10643,8 +10618,9 @@ static int idxCreateVtabSchema(sqlite3expert *p, char **pzErrmsg){
const char *zName = (const char*)sqlite3_column_text(pSchema, 1);
const char *zSql = (const char*)sqlite3_column_text(pSchema, 2);
+ if( zType==0 || zName==0 ) continue;
if( zType[0]=='v' || zType[1]=='r' ){
- rc = sqlite3_exec(p->dbv, zSql, 0, 0, pzErrmsg);
+ if( zSql ) rc = sqlite3_exec(p->dbv, zSql, 0, 0, pzErrmsg);
}else{
IdxTable *pTab;
rc = idxGetTableInfo(p->db, zName, &pTab, pzErrmsg);
@@ -10781,6 +10757,7 @@ static void idxRemFunc(
case SQLITE_BLOB:
case SQLITE_TEXT: {
int nByte = sqlite3_value_bytes(argv[1]);
+ const void *pData = 0;
if( nByte>pSlot->nByte ){
char *zNew = (char*)sqlite3_realloc(pSlot->z, nByte*2);
if( zNew==0 ){
@@ -10792,9 +10769,11 @@ static void idxRemFunc(
}
pSlot->n = nByte;
if( pSlot->eType==SQLITE_BLOB ){
- memcpy(pSlot->z, sqlite3_value_blob(argv[1]), nByte);
+ pData = sqlite3_value_blob(argv[1]);
+ if( pData ) memcpy(pSlot->z, pData, nByte);
}else{
- memcpy(pSlot->z, sqlite3_value_text(argv[1]), nByte);
+ pData = sqlite3_value_text(argv[1]);
+ memcpy(pSlot->z, pData, nByte);
}
break;
}
@@ -11005,6 +10984,7 @@ static int idxPopulateStat1(sqlite3expert *p, char **pzErr){
i64 iRowid = sqlite3_column_int64(pAllIndex, 0);
const char *zTab = (const char*)sqlite3_column_text(pAllIndex, 1);
const char *zIdx = (const char*)sqlite3_column_text(pAllIndex, 2);
+ if( zTab==0 || zIdx==0 ) continue;
if( p->iSample<100 && iPrev!=iRowid ){
samplectx.target = (double)p->iSample / 100.0;
samplectx.iTarget = p->iSample;
@@ -11071,14 +11051,14 @@ sqlite3expert *sqlite3_expert_new(sqlite3 *db, char **pzErrmsg){
/* Copy the entire schema of database [db] into [dbm]. */
if( rc==SQLITE_OK ){
- sqlite3_stmt *pSql;
+ sqlite3_stmt *pSql = 0;
rc = idxPrintfPrepareStmt(pNew->db, &pSql, pzErrmsg,
"SELECT sql FROM sqlite_schema WHERE name NOT LIKE 'sqlite_%%'"
" AND sql NOT LIKE 'CREATE VIRTUAL %%'"
);
while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pSql) ){
const char *zSql = (const char*)sqlite3_column_text(pSql, 0);
- rc = sqlite3_exec(pNew->dbm, zSql, 0, 0, pzErrmsg);
+ if( zSql ) rc = sqlite3_exec(pNew->dbm, zSql, 0, 0, pzErrmsg);
}
idxFinalize(&rc, pSql);
}
@@ -12165,6 +12145,15 @@ struct EQPGraph {
char zPrefix[100]; /* Graph prefix */
};
+/* Parameters affecting columnar mode result display (defaulting together) */
+typedef struct ColModeOpts {
+ int iWrap; /* In columnar modes, wrap lines reaching this limit */
+ u8 bQuote; /* Quote results for .mode box and table */
+ u8 bWordWrap; /* In columnar modes, wrap at word boundaries */
+} ColModeOpts;
+#define ColModeOpts_default { 60, 0, 0 }
+#define ColModeOpts_default_qbox { 60, 1, 0 }
+
/*
** State information about the database connection is contained in an
** instance of the following structure.
@@ -12183,8 +12172,10 @@ struct ShellState {
u8 eTraceType; /* SHELL_TRACE_* value for type of trace */
u8 bSafeMode; /* True to prohibit unsafe operations */
u8 bSafeModePersist; /* The long-term value of bSafeMode */
+ ColModeOpts cmOpts; /* Option values affecting columnar mode output */
unsigned statsOn; /* True to display memory stats before each finalize */
unsigned mEqpLines; /* Mask of veritical lines in the EQP output graph */
+ int inputNesting; /* Track nesting level of .read and other redirects */
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 */
@@ -12311,6 +12302,8 @@ struct ShellState {
#define MODE_Markdown 14 /* Markdown formatting */
#define MODE_Table 15 /* MySQL-style table formatting */
#define MODE_Box 16 /* Unicode box-drawing characters */
+#define MODE_Count 17 /* Output only a count of the rows of output */
+#define MODE_Off 18 /* No query output shown */
static const char *modeDescr[] = {
"line",
@@ -12329,7 +12322,9 @@ static const char *modeDescr[] = {
"json",
"markdown",
"table",
- "box"
+ "box",
+ "count",
+ "off"
};
/*
@@ -12346,6 +12341,12 @@ static const char *modeDescr[] = {
#define SEP_Record "\x1E"
/*
+** Limit input nesting via .read or any other input redirect.
+** It's not too expensive, so a generous allowance can be made.
+*/
+#define MAX_INPUT_NESTING 25
+
+/*
** A callback for the sqlite3_log() interface.
*/
static void shellLog(void *pArg, int iErrCode, const char *zMsg){
@@ -12829,6 +12830,7 @@ static void output_csv(ShellState *p, const char *z, int bSep){
}
if( i==0 || strstr(z, p->colSeparator)!=0 ){
char *zQuoted = sqlite3_mprintf("\"%w\"", z);
+ shell_check_oom(zQuoted);
utf8_printf(out, "%s", zQuoted);
sqlite3_free(zQuoted);
}else{
@@ -13003,7 +13005,7 @@ static void eqp_append(ShellState *p, int iEqpId, int p2, const char *zText){
utf8_printf(p->out, "%d,%d,%s\n", iEqpId, p2, zText);
}
pNew = sqlite3_malloc64( sizeof(*pNew) + nText );
- if( pNew==0 ) shell_out_of_memory();
+ shell_check_oom(pNew);
pNew->iEqpId = iEqpId;
pNew->iParentId = p2;
memcpy(pNew->zText, zText, nText+1);
@@ -13151,6 +13153,10 @@ static int shell_callback(
if( azArg==0 ) return 0;
switch( p->cMode ){
+ case MODE_Count:
+ case MODE_Off: {
+ break;
+ }
case MODE_Line: {
int w = 5;
if( azArg==0 ) break;
@@ -13220,6 +13226,7 @@ static int shell_callback(
break;
}
z = sqlite3_mprintf("%s", azArg[0]);
+ shell_check_oom(z);
j = 0;
for(i=0; IsSpace(z[i]); i++){}
for(; (c = z[i])!=0; i++){
@@ -13351,6 +13358,7 @@ static int shell_callback(
if( i>0 ) raw_printf(p->out, ",");
if( quoteChar(azCol[i]) ){
char *z = sqlite3_mprintf("\"%w\"", azCol[i]);
+ shell_check_oom(z);
utf8_printf(p->out, "%s", z);
sqlite3_free(z);
}else{
@@ -13382,7 +13390,12 @@ static int shell_callback(
}else if( ur==0xfff0000000000000LL ){
raw_printf(p->out, "-1e999");
}else{
- sqlite3_snprintf(50,z,"%!.20g", r);
+ sqlite3_int64 ir = (sqlite3_int64)r;
+ if( r==(double)ir ){
+ sqlite3_snprintf(50,z,"%lld.0", ir);
+ }else{
+ sqlite3_snprintf(50,z,"%!.20g", r);
+ }
raw_printf(p->out, "%s", z);
}
}else if( aiType && aiType[i]==SQLITE_BLOB && p->pStmt ){
@@ -13596,7 +13609,7 @@ static void set_table_name(ShellState *p, const char *zName){
n = strlen30(zName);
if( cQuote ) n += n+2;
z = p->zDestTable = malloc( n+1 );
- if( z==0 ) shell_out_of_memory();
+ shell_check_oom(z);
n = 0;
if( cQuote ) z[n++] = cQuote;
for(i=0; zName[i]; i++){
@@ -13607,6 +13620,47 @@ static void set_table_name(ShellState *p, const char *zName){
z[n] = 0;
}
+/*
+** Maybe construct two lines of text that point out the position of a
+** syntax error. Return a pointer to the text, in memory obtained from
+** sqlite3_malloc(). Or, if the most recent error does not involve a
+** specific token that we can point to, return an empty string.
+**
+** In all cases, the memory returned is obtained from sqlite3_malloc64()
+** and should be released by the caller invoking sqlite3_free().
+*/
+static char *shell_error_context(const char *zSql, sqlite3 *db){
+ int iOffset;
+ size_t len;
+ char *zCode;
+ char *zMsg;
+ int i;
+ if( db==0
+ || zSql==0
+ || (iOffset = sqlite3_error_offset(db))<0
+ ){
+ return sqlite3_mprintf("");
+ }
+ while( iOffset>50 ){
+ iOffset--;
+ zSql++;
+ while( (zSql[0]&0xc0)==0x80 ){ zSql++; iOffset--; }
+ }
+ len = strlen(zSql);
+ if( len>78 ){
+ len = 78;
+ while( (zSql[len]&0xc0)==0x80 ) len--;
+ }
+ zCode = sqlite3_mprintf("%.*s", len, zSql);
+ for(i=0; zCode[i]; i++){ if( IsSpace(zSql[i]) ) zCode[i] = ' '; }
+ if( iOffset<25 ){
+ zMsg = sqlite3_mprintf("\n %z\n %*s^--- error here", zCode, iOffset, "");
+ }else{
+ zMsg = sqlite3_mprintf("\n %z\n %*serror here ---^", zCode, iOffset-14, "");
+ }
+ return zMsg;
+}
+
/*
** Execute a query statement that will generate SQL output. Print
@@ -13629,8 +13683,10 @@ static int run_table_dump_query(
const char *z;
rc = sqlite3_prepare_v2(p->db, zSelect, -1, &pSelect, 0);
if( rc!=SQLITE_OK || !pSelect ){
- utf8_printf(p->out, "/**** ERROR: (%d) %s *****/\n", rc,
- sqlite3_errmsg(p->db));
+ char *zContext = shell_error_context(zSelect, p->db);
+ utf8_printf(p->out, "/**** ERROR: (%d) %s *****/\n%s", rc,
+ sqlite3_errmsg(p->db), zContext);
+ sqlite3_free(zContext);
if( (rc&0xff)!=SQLITE_CORRUPT ) p->nErr++;
return rc;
}
@@ -13665,12 +13721,25 @@ static int run_table_dump_query(
*/
static char *save_err_msg(
sqlite3 *db, /* Database to query */
- const char *zWhen, /* Qualifier (format) wrapper */
- int rc /* Error code returned from API */
+ const char *zPhase, /* When the error occcurs */
+ int rc, /* Error code returned from API */
+ const char *zSql /* SQL string, or NULL */
){
- if( zWhen==0 )
- zWhen = "%s (%d)";
- return sqlite3_mprintf(zWhen, sqlite3_errmsg(db), rc);
+ char *zErr;
+ char *zContext;
+ sqlite3_str *pStr = sqlite3_str_new(0);
+ sqlite3_str_appendf(pStr, "%s, %s", zPhase, sqlite3_errmsg(db));
+ if( rc>1 ){
+ sqlite3_str_appendf(pStr, " (%d)", rc);
+ }
+ zContext = shell_error_context(zSql, db);
+ if( zContext ){
+ sqlite3_str_appendall(pStr, zContext);
+ sqlite3_free(zContext);
+ }
+ zErr = sqlite3_str_finish(pStr);
+ shell_check_oom(zErr);
+ return zErr;
}
#ifdef __linux__
@@ -13848,6 +13917,7 @@ static int display_stats(
}
if( pArg->pStmt ){
+ int iHit, iMiss;
iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_FULLSCAN_STEP,
bReset);
raw_printf(pArg->out, "Fullscan Steps: %d\n", iCur);
@@ -13855,6 +13925,12 @@ static int display_stats(
raw_printf(pArg->out, "Sort Operations: %d\n", iCur);
iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_AUTOINDEX,bReset);
raw_printf(pArg->out, "Autoindex Inserts: %d\n", iCur);
+ iHit = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_FILTER_HIT, bReset);
+ iMiss = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_FILTER_MISS, bReset);
+ if( iHit || iMiss ){
+ raw_printf(pArg->out, "Bloom filter bypass taken: %d/%d\n",
+ iHit, iHit+iMiss);
+ }
iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_VM_STEP, bReset);
raw_printf(pArg->out, "Virtual Machine Steps: %d\n", iCur);
iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_REPREPARE,bReset);
@@ -14011,9 +14087,9 @@ static void explain_data_prepare(ShellState *p, sqlite3_stmt *pSql){
}
nAlloc += 100;
p->aiIndent = (int*)sqlite3_realloc64(p->aiIndent, nAlloc*sizeof(int));
- if( p->aiIndent==0 ) shell_out_of_memory();
+ shell_check_oom(p->aiIndent);
abYield = (int*)sqlite3_realloc64(abYield, nAlloc*sizeof(int));
- if( abYield==0 ) shell_out_of_memory();
+ shell_check_oom(abYield);
}
abYield[iOp] = str_in_array(zOp, azYield);
p->aiIndent[iOp] = 0;
@@ -14189,7 +14265,134 @@ static void print_box_row_separator(
fputs("\n", p->out);
}
+/*
+** z[] is a line of text that is to be displayed the .mode box or table or
+** similar tabular formats. z[] might contain control characters such
+** as \n, \t, \f, or \r.
+**
+** Compute characters to display on the first line of z[]. Stop at the
+** first \r, \n, or \f. Expand \t into spaces. Return a copy (obtained
+** from malloc()) of that first line, which caller should free sometime.
+** Write anything to display on the next line into *pzTail. If this is
+** the last line, write a NULL into *pzTail. (*pzTail is not allocated.)
+*/
+static char *translateForDisplayAndDup(
+ const unsigned char *z, /* Input text to be transformed */
+ const unsigned char **pzTail, /* OUT: Tail of the input for next line */
+ int mxWidth, /* Max width. 0 means no limit */
+ u8 bWordWrap /* If true, avoid breaking mid-word */
+){
+ int i; /* Input bytes consumed */
+ int j; /* Output bytes generated */
+ int k; /* Input bytes to be displayed */
+ int n; /* Output column number */
+ unsigned char *zOut; /* Output text */
+
+ if( z==0 ){
+ *pzTail = 0;
+ return 0;
+ }
+ if( mxWidth<0 ) mxWidth = -mxWidth;
+ if( mxWidth==0 ) mxWidth = 1000000;
+ i = j = n = 0;
+ while( n<mxWidth ){
+ if( z[i]>=' ' ){
+ n++;
+ do{ i++; j++; }while( (z[i]&0xc0)==0x80 );
+ continue;
+ }
+ if( z[i]=='\t' ){
+ do{
+ n++;
+ j++;
+ }while( (n&7)!=0 && n<mxWidth );
+ i++;
+ continue;
+ }
+ break;
+ }
+ if( n>=mxWidth && bWordWrap ){
+ /* Perhaps try to back up to a better place to break the line */
+ for(k=i; k>i/2; k--){
+ if( isspace(z[k-1]) ) break;
+ }
+ if( k<=i/2 ){
+ for(k=i; k>i/2; k--){
+ if( isalnum(z[k-1])!=isalnum(z[k]) && (z[k]&0xc0)!=0x80 ) break;
+ }
+ }
+ if( k<=i/2 ){
+ k = i;
+ }else{
+ i = k;
+ while( z[i]==' ' ) i++;
+ }
+ }else{
+ k = i;
+ }
+ if( n>=mxWidth && z[i]>=' ' ){
+ *pzTail = &z[i];
+ }else if( z[i]=='\r' && z[i+1]=='\n' ){
+ *pzTail = z[i+2] ? &z[i+2] : 0;
+ }else if( z[i]==0 || z[i+1]==0 ){
+ *pzTail = 0;
+ }else{
+ *pzTail = &z[i+1];
+ }
+ zOut = malloc( j+1 );
+ shell_check_oom(zOut);
+ i = j = n = 0;
+ while( i<k ){
+ if( z[i]>=' ' ){
+ n++;
+ do{ zOut[j++] = z[i++]; }while( (z[i]&0xc0)==0x80 );
+ continue;
+ }
+ if( z[i]=='\t' ){
+ do{
+ n++;
+ zOut[j++] = ' ';
+ }while( (n&7)!=0 && n<mxWidth );
+ i++;
+ continue;
+ }
+ break;
+ }
+ zOut[j] = 0;
+ return (char*)zOut;
+}
+/* Extract the value of the i-th current column for pStmt as an SQL literal
+** value. Memory is obtained from sqlite3_malloc64() and must be freed by
+** the caller.
+*/
+static char *quoted_column(sqlite3_stmt *pStmt, int i){
+ switch( sqlite3_column_type(pStmt, i) ){
+ case SQLITE_NULL: {
+ return sqlite3_mprintf("NULL");
+ }
+ case SQLITE_INTEGER:
+ case SQLITE_FLOAT: {
+ return sqlite3_mprintf("%s",sqlite3_column_text(pStmt,i));
+ }
+ case SQLITE_TEXT: {
+ return sqlite3_mprintf("%Q",sqlite3_column_text(pStmt,i));
+ }
+ case SQLITE_BLOB: {
+ int j;
+ sqlite3_str *pStr = sqlite3_str_new(0);
+ const unsigned char *a = sqlite3_column_blob(pStmt,i);
+ int n = sqlite3_column_bytes(pStmt,i);
+ sqlite3_str_append(pStr, "x'", 2);
+ for(j=0; j<n; j++){
+ sqlite3_str_appendf(pStr, "%02x", a[j]);
+ }
+ sqlite3_str_append(pStr, "'", 1);
+ return sqlite3_str_finish(pStr);
+ }
+ }
+ return 0; /* Not reached */
+}
/*
** Run a prepared statement and output the result in one of the
@@ -14209,12 +14412,19 @@ static void exec_prepared_stmt_columnar(
int nColumn = 0;
char **azData = 0;
sqlite3_int64 nAlloc = 0;
+ char *abRowDiv = 0;
+ const unsigned char *uz;
const char *z;
+ char **azQuoted = 0;
int rc;
sqlite3_int64 i, nData;
int j, nTotal, w, n;
const char *colSep = 0;
const char *rowSep = 0;
+ const unsigned char **azNextLine = 0;
+ int bNextLine = 0;
+ int bMultiLineRowExists = 0;
+ int bw = p->cmOpts.bWordWrap;
rc = sqlite3_step(pStmt);
if( rc!=SQLITE_ROW ) return;
@@ -14222,25 +14432,20 @@ static void exec_prepared_stmt_columnar(
nAlloc = nColumn*4;
if( nAlloc<=0 ) nAlloc = 1;
azData = sqlite3_malloc64( nAlloc*sizeof(char*) );
- if( azData==0 ) shell_out_of_memory();
- for(i=0; i<nColumn; i++){
- azData[i] = strdup(sqlite3_column_name(pStmt,i));
- }
- do{
- if( (nRow+2)*nColumn >= nAlloc ){
- nAlloc *= 2;
- azData = sqlite3_realloc64(azData, nAlloc*sizeof(char*));
- if( azData==0 ) shell_out_of_memory();
- }
- nRow++;
- for(i=0; i<nColumn; i++){
- z = (const char*)sqlite3_column_text(pStmt,i);
- azData[nRow*nColumn + i] = z ? strdup(z) : 0;
- }
- }while( sqlite3_step(pStmt)==SQLITE_ROW );
+ shell_check_oom(azData);
+ azNextLine = sqlite3_malloc64( nColumn*sizeof(char*) );
+ shell_check_oom((void*)azNextLine);
+ memset((void*)azNextLine, 0, nColumn*sizeof(char*) );
+ if( p->cmOpts.bQuote ){
+ azQuoted = sqlite3_malloc64( nColumn*sizeof(char*) );
+ shell_check_oom(azQuoted);
+ memset(azQuoted, 0, nColumn*sizeof(char*) );
+ }
+ abRowDiv = sqlite3_malloc64( nAlloc/nColumn );
+ shell_check_oom(abRowDiv);
if( nColumn>p->nWidth ){
p->colWidth = realloc(p->colWidth, (nColumn+1)*2*sizeof(int));
- if( p->colWidth==0 ) shell_out_of_memory();
+ shell_check_oom(p->colWidth);
for(i=p->nWidth; i<nColumn; i++) p->colWidth[i] = 0;
p->nWidth = nColumn;
p->actualWidth = &p->colWidth[nColumn];
@@ -14251,6 +14456,52 @@ static void exec_prepared_stmt_columnar(
if( w<0 ) w = -w;
p->actualWidth[i] = w;
}
+ for(i=0; i<nColumn; i++){
+ const unsigned char *zNotUsed;
+ int wx = p->colWidth[i];
+ if( wx==0 ){
+ wx = p->cmOpts.iWrap;
+ }
+ if( wx<0 ) wx = -wx;
+ uz = (const unsigned char*)sqlite3_column_name(pStmt,i);
+ azData[i] = translateForDisplayAndDup(uz, &zNotUsed, wx, bw);
+ }
+ do{
+ int useNextLine = bNextLine;
+ bNextLine = 0;
+ if( (nRow+2)*nColumn >= nAlloc ){
+ nAlloc *= 2;
+ azData = sqlite3_realloc64(azData, nAlloc*sizeof(char*));
+ shell_check_oom(azData);
+ abRowDiv = sqlite3_realloc64(abRowDiv, nAlloc/nColumn);
+ shell_check_oom(abRowDiv);
+ }
+ abRowDiv[nRow] = 1;
+ nRow++;
+ for(i=0; i<nColumn; i++){
+ int wx = p->colWidth[i];
+ if( wx==0 ){
+ wx = p->cmOpts.iWrap;
+ }
+ if( wx<0 ) wx = -wx;
+ if( useNextLine ){
+ uz = azNextLine[i];
+ }else if( p->cmOpts.bQuote ){
+ sqlite3_free(azQuoted[i]);
+ azQuoted[i] = quoted_column(pStmt,i);
+ uz = (const unsigned char*)azQuoted[i];
+ }else{
+ uz = (const unsigned char*)sqlite3_column_text(pStmt,i);
+ }
+ azData[nRow*nColumn + i]
+ = translateForDisplayAndDup(uz, &azNextLine[i], wx, bw);
+ if( azNextLine[i] ){
+ bNextLine = 1;
+ abRowDiv[nRow-1] = 0;
+ bMultiLineRowExists = 1;
+ }
+ }
+ }while( bNextLine || sqlite3_step(pStmt)==SQLITE_ROW );
nTotal = nColumn*(nRow+1);
for(i=0; i<nTotal; i++){
z = azData[i];
@@ -14333,6 +14584,15 @@ static void exec_prepared_stmt_columnar(
utf8_width_print(p->out, w, z);
if( j==nColumn-1 ){
utf8_printf(p->out, "%s", rowSep);
+ if( bMultiLineRowExists && abRowDiv[i/nColumn-1] && i+1<nTotal ){
+ if( p->cMode==MODE_Table ){
+ print_row_separator(p, nColumn, "+");
+ }else if( p->cMode==MODE_Box ){
+ print_box_row_separator(p, nColumn, BOX_123, BOX_1234, BOX_134);
+ }else if( p->cMode==MODE_Column ){
+ raw_printf(p->out, "\n");
+ }
+ }
j = -1;
if( seenInterrupt ) goto columnar_end;
}else{
@@ -14351,6 +14611,12 @@ columnar_end:
nData = (nRow+1)*nColumn;
for(i=0; i<nData; i++) free(azData[i]);
sqlite3_free(azData);
+ sqlite3_free((void*)azNextLine);
+ sqlite3_free(abRowDiv);
+ if( azQuoted ){
+ for(i=0; i<nColumn; i++) sqlite3_free(azQuoted[i]);
+ sqlite3_free(azQuoted);
+ }
}
/*
@@ -14361,6 +14627,7 @@ static void exec_prepared_stmt(
sqlite3_stmt *pStmt /* Statment to run */
){
int rc;
+ sqlite3_uint64 nRow = 0;
if( pArg->cMode==MODE_Column
|| pArg->cMode==MODE_Table
@@ -14393,10 +14660,14 @@ static void exec_prepared_stmt(
azCols[i] = (char *)sqlite3_column_name(pStmt, i);
}
do{
+ nRow++;
/* extract the data and data types */
for(i=0; i<nCol; i++){
aiTypes[i] = x = sqlite3_column_type(pStmt, i);
- if( x==SQLITE_BLOB && pArg && pArg->cMode==MODE_Insert ){
+ if( x==SQLITE_BLOB
+ && pArg
+ && (pArg->cMode==MODE_Insert || pArg->cMode==MODE_Quote)
+ ){
azVals[i] = "";
}else{
azVals[i] = (char*)sqlite3_column_text(pStmt, i);
@@ -14420,6 +14691,11 @@ static void exec_prepared_stmt(
sqlite3_free(pData);
if( pArg->cMode==MODE_Json ){
fputs("]\n", pArg->out);
+ }else if( pArg->cMode==MODE_Count ){
+ char zBuf[200];
+ sqlite3_snprintf(sizeof(zBuf), zBuf, "%llu row%s\n",
+ nRow, nRow!=1 ? "s" : "");
+ printf("%s", zBuf);
}
}
}
@@ -14543,7 +14819,7 @@ static int expertDotCommand(
if( rc==SQLITE_OK ){
pState->expert.pExpert = sqlite3_expert_new(pState->db, &zErr);
if( pState->expert.pExpert==0 ){
- raw_printf(stderr, "sqlite3_expert_new: %s\n", zErr);
+ raw_printf(stderr, "sqlite3_expert_new: %s\n", zErr ? zErr : "out of memory");
rc = SQLITE_ERROR;
}else{
sqlite3_expert_config(
@@ -14551,6 +14827,7 @@ static int expertDotCommand(
);
}
}
+ sqlite3_free(zErr);
return rc;
}
@@ -14592,7 +14869,7 @@ static int shell_exec(
rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, &zLeftover);
if( SQLITE_OK != rc ){
if( pzErrMsg ){
- *pzErrMsg = save_err_msg(db, "in prepare, %s (%d)", rc);
+ *pzErrMsg = save_err_msg(db, "in prepare", rc, zSql);
}
}else{
if( !pStmt ){
@@ -14627,6 +14904,7 @@ static int shell_exec(
sqlite3_db_config(db, SQLITE_DBCONFIG_TRIGGER_EQP, 1, 0);
}
zEQP = sqlite3_mprintf("EXPLAIN QUERY PLAN %s", zStmtSql);
+ shell_check_oom(zEQP);
rc = sqlite3_prepare_v2(db, zEQP, -1, &pExplain, 0);
if( rc==SQLITE_OK ){
while( sqlite3_step(pExplain)==SQLITE_ROW ){
@@ -14644,6 +14922,7 @@ static int shell_exec(
if( pArg->autoEQP>=AUTOEQP_full ){
/* Also do an EXPLAIN for ".eqp full" mode */
zEQP = sqlite3_mprintf("EXPLAIN %s", zStmtSql);
+ shell_check_oom(zEQP);
rc = sqlite3_prepare_v2(db, zEQP, -1, &pExplain, 0);
if( rc==SQLITE_OK ){
pArg->cMode = MODE_Explain;
@@ -14706,7 +14985,7 @@ static int shell_exec(
zSql = zLeftover;
while( IsSpace(zSql[0]) ) zSql++;
}else if( pzErrMsg ){
- *pzErrMsg = save_err_msg(db, "stepping, %s (%d)", rc);
+ *pzErrMsg = save_err_msg(db, "stepping", rc, 0);
}
/* clear saved stmt handle */
@@ -14756,6 +15035,7 @@ static char **tableColumnList(ShellState *p, const char *zTab){
int rc;
zSql = sqlite3_mprintf("PRAGMA table_info=%Q", zTab);
+ shell_check_oom(zSql);
rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
sqlite3_free(zSql);
if( rc ) return 0;
@@ -14763,9 +15043,10 @@ static char **tableColumnList(ShellState *p, const char *zTab){
if( nCol>=nAlloc-2 ){
nAlloc = nAlloc*2 + nCol + 10;
azCol = sqlite3_realloc(azCol, nAlloc*sizeof(azCol[0]));
- if( azCol==0 ) shell_out_of_memory();
+ shell_check_oom(azCol);
}
azCol[++nCol] = sqlite3_mprintf("%s", sqlite3_column_text(pStmt, 1));
+ shell_check_oom(azCol[nCol]);
if( sqlite3_column_int(pStmt, 5) ){
nPK++;
if( nPK==1
@@ -14799,6 +15080,7 @@ static char **tableColumnList(ShellState *p, const char *zTab){
*/
zSql = sqlite3_mprintf("SELECT 1 FROM pragma_index_list(%Q)"
" WHERE origin='pk'", zTab);
+ shell_check_oom(zSql);
rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
sqlite3_free(zSql);
if( rc ){
@@ -14890,6 +15172,7 @@ static int dump_callback(void *pArg, int nArg, char **azArg, char **azNotUsed){
"INSERT INTO sqlite_schema(type,name,tbl_name,rootpage,sql)"
"VALUES('table','%q','%q',0,'%q');",
zTable, zTable, zSql);
+ shell_check_oom(zIns);
utf8_printf(p->out, "%s\n", zIns);
sqlite3_free(zIns);
return 0;
@@ -15041,6 +15324,7 @@ static const char *(azHelp[]) = {
".auth ON|OFF Show authorizer callbacks",
#endif
".backup ?DB? FILE Backup DB (default \"main\") to FILE",
+ " Options:",
" --append Use the appendvfs",
" --async Write to FILE without journal and fsync()",
".bail on|off Stop after hitting an error. Default OFF",
@@ -15085,6 +15369,7 @@ static const char *(azHelp[]) = {
" --ascii Use \\037 and \\036 as column and row separators",
" --csv Use , and \\n as column and row separators",
" --skip N Skip the first N rows of input",
+ " --schema S Target table to be S.TABLE",
" -v \"Verbose\" - increase auxiliary output",
" Notes:",
" * If TABLE does not exist, it is created. The first row of input",
@@ -15110,32 +15395,37 @@ static const char *(azHelp[]) = {
".load FILE ?ENTRY? Load an extension library",
#endif
".log FILE|off Turn logging on or off. FILE can be stderr/stdout",
- ".mode MODE ?TABLE? Set output mode",
+ ".mode MODE ?OPTIONS? Set output mode",
" MODE is one of:",
- " ascii Columns/rows delimited by 0x1F and 0x1E",
- " box Tables using unicode box-drawing characters",
- " csv Comma-separated values",
- " column Output in columns. (See .width)",
- " html HTML <table> code",
- " insert SQL insert statements for TABLE",
- " json Results in a JSON array",
- " line One value per line",
- " list Values delimited by \"|\"",
- " markdown Markdown table format",
- " quote Escape answers as for SQL",
- " table ASCII-art table",
- " tabs Tab-separated values",
- " tcl TCL list elements",
- ".nonce STRING Disable safe mode for one command if the nonce matches",
+ " ascii Columns/rows delimited by 0x1F and 0x1E",
+ " box Tables using unicode box-drawing characters",
+ " csv Comma-separated values",
+ " column Output in columns. (See .width)",
+ " html HTML <table> code",
+ " insert SQL insert statements for TABLE",
+ " json Results in a JSON array",
+ " line One value per line",
+ " list Values delimited by \"|\"",
+ " markdown Markdown table format",
+ " qbox Shorthand for \"box --width 60 --quote\"",
+ " quote Escape answers as for SQL",
+ " table ASCII-art table",
+ " tabs Tab-separated values",
+ " tcl TCL list elements",
+ " OPTIONS: (for columnar modes or insert mode):",
+ " --wrap N Wrap output lines to no longer than N characters",
+ " --wordwrap B Wrap or not at word boundaries per B (on/off)",
+ " --ww Shorthand for \"--wordwrap 1\"",
+ " --quote Quote output text as SQL literals",
+ " --noquote Do not quote output text",
+ " TABLE The name of SQL table used for \"insert\" mode",
+ ".nonce STRING Suspend safe mode for one command if nonce matches",
".nullvalue STRING Use STRING in place of NULL values",
".once ?OPTIONS? ?FILE? Output for the next SQL command only to FILE",
" If FILE begins with '|' then open as a pipe",
" --bom Put a UTF8 byte-order mark at the beginning",
" -e Send output to the system text editor",
" -x Send output as CSV to a spreadsheet (same as \".excel\")",
-#ifdef SQLITE_DEBUG
- ".oom ?--repeat M? ?N? Simulate an OOM error on the N-th allocation",
-#endif
".open ?OPTIONS? ?FILE? Close existing database and reopen FILE",
" Options:",
" --append Use appendvfs to append database to the end of FILE",
@@ -15171,7 +15461,8 @@ static const char *(azHelp[]) = {
#endif
".prompt MAIN CONTINUE Replace the standard prompts",
".quit Exit this program",
- ".read FILE Read input from FILE",
+ ".read FILE Read input from FILE or command output",
+ " If FILE begins with \"|\", it is a command that generates the input.",
#if !defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_ENABLE_DBPAGE_VTAB)
".recover Recover as much data as possible from corrupt db.",
" --freelist-corrupt Assume the freelist is corrupt",
@@ -15181,7 +15472,7 @@ static const char *(azHelp[]) = {
" that are not also INTEGER PRIMARY KEYs",
#endif
".restore ?DB? FILE Restore content of DB (default \"main\") from FILE",
- ".save FILE Write in-memory database into FILE",
+ ".save ?OPTIONS? FILE Write database to FILE (an alias for .backup ...)",
".scanstats on|off Turn sqlite3_stmt_scanstatus() metrics on or off",
".schema ?PATTERN? Show the CREATE statements matching PATTERN",
" Options:",
@@ -15291,6 +15582,7 @@ static int showHelp(FILE *out, const char *zPattern){
}else{
/* Look for commands that for which zPattern is an exact prefix */
zPat = sqlite3_mprintf(".%s*", zPattern);
+ shell_check_oom(zPat);
for(i=0; i<ArraySize(azHelp); i++){
if( sqlite3_strglob(zPat, azHelp[i])==0 ){
utf8_printf(out, "%s\n", azHelp[i]);
@@ -15313,6 +15605,7 @@ static int showHelp(FILE *out, const char *zPattern){
/* Look for commands that contain zPattern anywhere. Show the complete
** text of all commands that match. */
zPat = sqlite3_mprintf("%%%s%%", zPattern);
+ shell_check_oom(zPat);
for(i=0; i<ArraySize(azHelp); i++){
if( azHelp[i][0]=='.' ) j = i;
if( sqlite3_strlike(zPat, azHelp[i], 0)==0 ){
@@ -15501,10 +15794,7 @@ static unsigned char *readHexDb(ShellState *p, int *pnData){
if( pgsz<512 || pgsz>65536 || (pgsz&(pgsz-1))!=0 ) goto readHexDb_error;
n = (n+pgsz-1)&~(pgsz-1); /* Round n up to the next multiple of pgsz */
a = sqlite3_malloc( n ? n : 1 );
- if( a==0 ){
- utf8_printf(stderr, "Out of memory!\n");
- goto readHexDb_error;
- }
+ shell_check_oom(a);
memset(a, 0, n);
if( pgsz<512 || pgsz>65536 || (pgsz & (pgsz-1))!=0 ){
utf8_printf(stderr, "invalid pagesize\n");
@@ -15635,7 +15925,7 @@ static void shellEscapeCrnl(
){
const char *zText = (const char*)sqlite3_value_text(argv[0]);
UNUSED_PARAMETER(argc);
- if( zText[0]=='\'' ){
+ if( zText && zText[0]=='\'' ){
int nText = sqlite3_value_bytes(argv[0]);
int i;
char zBuf1[20];
@@ -15812,6 +16102,7 @@ static void open_db(ShellState *p, int openFlags){
if( p->openMode==SHELL_OPEN_ZIPFILE ){
char *zSql = sqlite3_mprintf(
"CREATE VIRTUAL TABLE zip USING zipfile(%Q);", zDbFilename);
+ shell_check_oom(zSql);
sqlite3_exec(p->db, zSql, 0, 0, 0);
sqlite3_free(zSql);
}
@@ -15869,11 +16160,13 @@ static char *readline_completion_generator(const char *text, int state){
sqlite3_finalize(pStmt);
zSql = sqlite3_mprintf("SELECT DISTINCT candidate COLLATE nocase"
" FROM completion(%Q) ORDER BY 1", text);
+ shell_check_oom(zSql);
sqlite3_prepare_v2(globalDb, zSql, -1, &pStmt, 0);
sqlite3_free(zSql);
}
if( sqlite3_step(pStmt)==SQLITE_ROW ){
- zRet = strdup((const char*)sqlite3_column_text(pStmt, 0));
+ const char *z = (const char*)sqlite3_column_text(pStmt,0);
+ zRet = z ? strdup(z) : 0;
}else{
sqlite3_finalize(pStmt);
pStmt = 0;
@@ -15906,13 +16199,14 @@ static void linenoise_completion(const char *zLine, linenoiseCompletions *lc){
zSql = sqlite3_mprintf("SELECT DISTINCT candidate COLLATE nocase"
" FROM completion(%Q,%Q) ORDER BY 1",
&zLine[iStart], zLine);
+ shell_check_oom(zSql);
sqlite3_prepare_v2(globalDb, zSql, -1, &pStmt, 0);
sqlite3_free(zSql);
sqlite3_exec(globalDb, "PRAGMA page_count", 0, 0, 0); /* Load the schema */
while( sqlite3_step(pStmt)==SQLITE_ROW ){
const char *zCompletion = (const char*)sqlite3_column_text(pStmt, 0);
int nCompletion = sqlite3_column_bytes(pStmt, 0);
- if( iStart+nCompletion < sizeof(zBuf)-1 ){
+ if( iStart+nCompletion < sizeof(zBuf)-1 && zCompletion ){
memcpy(zBuf+iStart, zCompletion, nCompletion+1);
linenoiseAddCompletion(lc, zBuf);
}
@@ -16147,7 +16441,7 @@ static void import_append_char(ImportCtx *p, int c){
if( p->n+1>=p->nAlloc ){
p->nAlloc += p->nAlloc + 100;
p->z = sqlite3_realloc64(p->z, p->nAlloc);
- if( p->z==0 ) shell_out_of_memory();
+ shell_check_oom(p->z);
}
p->z[p->n++] = (char)c;
}
@@ -16299,6 +16593,7 @@ static void tryToCloneData(
const int spinRate = 10000;
zQuery = sqlite3_mprintf("SELECT * FROM \"%w\"", zTable);
+ shell_check_oom(zQuery);
rc = sqlite3_prepare_v2(p->db, zQuery, -1, &pQuery, 0);
if( rc ){
utf8_printf(stderr, "Error %d: %s on [%s]\n",
@@ -16308,7 +16603,7 @@ static void tryToCloneData(
}
n = sqlite3_column_count(pQuery);
zInsert = sqlite3_malloc64(200 + nTable + n*3);
- if( zInsert==0 ) shell_out_of_memory();
+ shell_check_oom(zInsert);
sqlite3_snprintf(200+nTable,zInsert,
"INSERT OR IGNORE INTO \"%s\" VALUES(?", zTable);
i = strlen30(zInsert);
@@ -16371,6 +16666,7 @@ static void tryToCloneData(
sqlite3_free(zQuery);
zQuery = sqlite3_mprintf("SELECT * FROM \"%w\" ORDER BY rowid DESC;",
zTable);
+ shell_check_oom(zQuery);
rc = sqlite3_prepare_v2(p->db, zQuery, -1, &pQuery, 0);
if( rc ){
utf8_printf(stderr, "Warning: cannot step \"%s\" backwards", zTable);
@@ -16407,6 +16703,7 @@ static void tryToCloneSchema(
zQuery = sqlite3_mprintf("SELECT name, sql FROM sqlite_schema"
" WHERE %s", zWhere);
+ shell_check_oom(zQuery);
rc = sqlite3_prepare_v2(p->db, zQuery, -1, &pQuery, 0);
if( rc ){
utf8_printf(stderr, "Error: (%d) %s on [%s]\n",
@@ -16417,6 +16714,7 @@ static void tryToCloneSchema(
while( (rc = sqlite3_step(pQuery))==SQLITE_ROW ){
zName = sqlite3_column_text(pQuery, 0);
zSql = sqlite3_column_text(pQuery, 1);
+ if( zName==0 || zSql==0 ) continue;
printf("%s... ", zName); fflush(stdout);
sqlite3_exec(newDb, (const char*)zSql, 0, 0, &zErrMsg);
if( zErrMsg ){
@@ -16434,6 +16732,7 @@ static void tryToCloneSchema(
sqlite3_free(zQuery);
zQuery = sqlite3_mprintf("SELECT name, sql FROM sqlite_schema"
" WHERE %s ORDER BY rowid DESC", zWhere);
+ shell_check_oom(zQuery);
rc = sqlite3_prepare_v2(p->db, zQuery, -1, &pQuery, 0);
if( rc ){
utf8_printf(stderr, "Error: (%d) %s on [%s]\n",
@@ -16444,6 +16743,7 @@ static void tryToCloneSchema(
while( sqlite3_step(pQuery)==SQLITE_ROW ){
zName = sqlite3_column_text(pQuery, 0);
zSql = sqlite3_column_text(pQuery, 1);
+ if( zName==0 || zSql==0 ) continue;
printf("%s... ", zName); fflush(stdout);
sqlite3_exec(newDb, (const char*)zSql, 0, 0, &zErrMsg);
if( zErrMsg ){
@@ -16536,10 +16836,10 @@ static void output_reset(ShellState *p){
/*
** Run an SQL command and return the single integer result.
*/
-static int db_int(ShellState *p, const char *zSql){
+static int db_int(sqlite3 *db, const char *zSql){
sqlite3_stmt *pStmt;
int res = 0;
- sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
+ sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);
if( pStmt && sqlite3_step(pStmt)==SQLITE_ROW ){
res = sqlite3_column_int(pStmt,0);
}
@@ -16644,7 +16944,7 @@ static int shell_dbinfo_command(ShellState *p, int nArg, char **azArg){
}
for(i=0; i<ArraySize(aQuery); i++){
char *zSql = sqlite3_mprintf(aQuery[i].zSql, zSchemaTab);
- int val = db_int(p, zSql);
+ int val = db_int(p->db, zSql);
sqlite3_free(zSql);
utf8_printf(p->out, "%-20s %d\n", aQuery[i].zName, val);
}
@@ -16828,9 +17128,7 @@ static void newTempFile(ShellState *p, const char *zSuffix){
}else{
p->zTempFile = sqlite3_mprintf("%z.%s", p->zTempFile, zSuffix);
}
- if( p->zTempFile==0 ){
- shell_out_of_memory();
- }
+ shell_check_oom(p->zTempFile);
}
@@ -17011,14 +17309,14 @@ static int lintFkeyIndexes(
const char *zCI = (const char*)sqlite3_column_text(pSql, 4);
const char *zParent = (const char*)sqlite3_column_text(pSql, 5);
+ if( zEQP==0 ) continue;
+ if( zGlob==0 ) continue;
rc = sqlite3_prepare_v2(db, zEQP, -1, &pExplain, 0);
if( rc!=SQLITE_OK ) break;
if( SQLITE_ROW==sqlite3_step(pExplain) ){
const char *zPlan = (const char*)sqlite3_column_text(pExplain, 3);
- res = (
- 0==sqlite3_strglob(zGlob, zPlan)
- || 0==sqlite3_strglob(zGlobIPK, zPlan)
- );
+ res = zPlan!=0 && ( 0==sqlite3_strglob(zGlob, zPlan)
+ || 0==sqlite3_strglob(zGlobIPK, zPlan));
}
rc = sqlite3_finalize(pExplain);
if( rc!=SQLITE_OK ) break;
@@ -18010,6 +18308,7 @@ static char *shellMPrintf(int *pRc, const char *zFmt, ...){
return z;
}
+
/*
** When running the ".recover" command, each output table, and the special
** orphaned row table if it is required, is represented by an instance
@@ -18123,6 +18422,7 @@ static RecoverTable *recoverNewTable(
if( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pPkFinder) ){
pTab->iPk = sqlite3_column_int(pPkFinder, 0);
zPk = (const char*)sqlite3_column_text(pPkFinder, 1);
+ if( zPk==0 ){ zPk = "_"; /* Defensive. Should never happen */ }
}
}
@@ -18207,8 +18507,10 @@ static RecoverTable *recoverFindTable(
if( sqlite3_stricmp(zType, "table")==0 ){
zName = (const char*)sqlite3_column_text(pStmt, 1);
zSql = (const char*)sqlite3_column_text(pStmt, 2);
- pRet = recoverNewTable(pRc, zName, zSql, bIntkey, nCol);
- break;
+ if( zName!=0 && zSql!=0 ){
+ pRet = recoverNewTable(pRc, zName, zSql, bIntkey, nCol);
+ break;
+ }
}
}
@@ -18603,6 +18905,221 @@ static int recoverDatabaseCmd(ShellState *pState, int nArg, char **azArg){
}
#endif /* !(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_ENABLE_DBPAGE_VTAB) */
+
+/*
+ * zAutoColumn(zCol, &db, ?) => Maybe init db, add column zCol to it.
+ * zAutoColumn(0, &db, ?) => (db!=0) Form columns spec for CREATE TABLE,
+ * close db and set it to 0, and return the columns spec, to later
+ * be sqlite3_free()'ed by the caller.
+ * The return is 0 when either:
+ * (a) The db was not initialized and zCol==0 (There are no columns.)
+ * (b) zCol!=0 (Column was added, db initialized as needed.)
+ * The 3rd argument, pRenamed, references an out parameter. If the
+ * pointer is non-zero, its referent will be set to a summary of renames
+ * done if renaming was necessary, or set to 0 if none was done. The out
+ * string (if any) must be sqlite3_free()'ed by the caller.
+ */
+#ifdef SHELL_DEBUG
+#define rc_err_oom_die(rc) \
+ if( rc==SQLITE_NOMEM ) shell_check_oom(0); \
+ else if(!(rc==SQLITE_OK||rc==SQLITE_DONE)) \
+ fprintf(stderr,"E:%d\n",rc), assert(0)
+#else
+static void rc_err_oom_die(int rc){
+ if( rc==SQLITE_NOMEM ) shell_check_oom(0);
+ assert(rc==SQLITE_OK||rc==SQLITE_DONE);
+}
+#endif
+
+#ifdef SHELL_COLFIX_DB /* If this is set, the DB can be in a file. */
+static char zCOL_DB[] = SHELL_STRINGIFY(SHELL_COLFIX_DB);
+#else /* Otherwise, memory is faster/better for the transient DB. */
+static const char *zCOL_DB = ":memory:";
+#endif
+
+/* Define character (as C string) to separate generated column ordinal
+ * from protected part of incoming column names. This defaults to "_"
+ * so that incoming column identifiers that did not need not be quoted
+ * remain usable without being quoted. It must be one character.
+ */
+#ifndef SHELL_AUTOCOLUMN_SEP
+# define AUTOCOLUMN_SEP "_"
+#else
+# define AUTOCOLUMN_SEP SHELL_STRINGIFY(SHELL_AUTOCOLUMN_SEP)
+#endif
+
+static char *zAutoColumn(const char *zColNew, sqlite3 **pDb, char **pzRenamed){
+ /* Queries and D{D,M}L used here */
+ static const char * const zTabMake = "\
+CREATE TABLE ColNames(\
+ cpos INTEGER PRIMARY KEY,\
+ name TEXT, nlen INT, chop INT, reps INT, suff TEXT);\
+CREATE VIEW RepeatedNames AS \
+SELECT DISTINCT t.name FROM ColNames t \
+WHERE t.name COLLATE NOCASE IN (\
+ SELECT o.name FROM ColNames o WHERE o.cpos<>t.cpos\
+);\
+";
+ static const char * const zTabFill = "\
+INSERT INTO ColNames(name,nlen,chop,reps,suff)\
+ VALUES(iif(length(?1)>0,?1,'?'),max(length(?1),1),0,0,'')\
+";
+ static const char * const zHasDupes = "\
+SELECT count(DISTINCT (substring(name,1,nlen-chop)||suff) COLLATE NOCASE)\
+ <count(name) FROM ColNames\
+";
+#ifdef SHELL_COLUMN_RENAME_CLEAN
+ static const char * const zDedoctor = "\
+UPDATE ColNames SET chop=iif(\
+ (substring(name,nlen,1) BETWEEN '0' AND '9')\
+ AND (rtrim(name,'0123456790') glob '*"AUTOCOLUMN_SEP"'),\
+ nlen-length(rtrim(name, '"AUTOCOLUMN_SEP"0123456789')),\
+ 0\
+)\
+";
+#endif
+ static const char * const zSetReps = "\
+UPDATE ColNames AS t SET reps=\
+(SELECT count(*) FROM ColNames d \
+ WHERE substring(t.name,1,t.nlen-t.chop)=substring(d.name,1,d.nlen-d.chop)\
+ COLLATE NOCASE\
+)\
+";
+#ifdef SQLITE_ENABLE_MATH_FUNCTIONS
+ static const char * const zColDigits = "\
+SELECT CAST(ceil(log(count(*)+0.5)) AS INT) FROM ColNames \
+";
+#endif
+ static const char * const zRenameRank =
+#ifdef SHELL_COLUMN_RENAME_CLEAN
+ "UPDATE ColNames AS t SET suff="
+ "iif(reps>1, printf('%c%0*d', '"AUTOCOLUMN_SEP"', $1, cpos), '')"
+#else /* ...RENAME_MINIMAL_ONE_PASS */
+"WITH Lzn(nlz) AS (" /* Find minimum extraneous leading 0's for uniqueness */
+" SELECT 0 AS nlz"
+" UNION"
+" SELECT nlz+1 AS nlz FROM Lzn"
+" WHERE EXISTS("
+" SELECT 1"
+" FROM ColNames t, ColNames o"
+" WHERE"
+" iif(t.name IN (SELECT * FROM RepeatedNames),"
+" printf('%s"AUTOCOLUMN_SEP"%s',"
+" t.name, substring(printf('%.*c%0.*d',nlz+1,'0',$1,t.cpos),2)),"
+" t.name"
+" )"
+" ="
+" iif(o.name IN (SELECT * FROM RepeatedNames),"
+" printf('%s"AUTOCOLUMN_SEP"%s',"
+" o.name, substring(printf('%.*c%0.*d',nlz+1,'0',$1,o.cpos),2)),"
+" o.name"
+" )"
+" COLLATE NOCASE"
+" AND o.cpos<>t.cpos"
+" GROUP BY t.cpos"
+" )"
+") UPDATE Colnames AS t SET"
+" chop = 0," /* No chopping, never touch incoming names. */
+" suff = iif(name IN (SELECT * FROM RepeatedNames),"
+" printf('"AUTOCOLUMN_SEP"%s', substring("
+" printf('%.*c%0.*d',(SELECT max(nlz) FROM Lzn)+1,'0',1,t.cpos),2)),"
+" ''"
+" )"
+#endif
+ ;
+ static const char * const zCollectVar = "\
+SELECT\
+ '('||x'0a'\
+ || group_concat(\
+ cname||' TEXT',\
+ ','||iif((cpos-1)%4>0, ' ', x'0a'||' '))\
+ ||')' AS ColsSpec \
+FROM (\
+ SELECT cpos, printf('\"%w\"',printf('%.*s%s', nlen-chop,name,suff)) AS cname \
+ FROM ColNames ORDER BY cpos\
+)";
+ static const char * const zRenamesDone =
+ "SELECT group_concat("
+ " printf('\"%w\" to \"%w\"',name,printf('%.*s%s', nlen-chop, name, suff)),"
+ " ','||x'0a')"
+ "FROM ColNames WHERE suff<>'' OR chop!=0"
+ ;
+ int rc;
+ sqlite3_stmt *pStmt = 0;
+ assert(pDb!=0);
+ if( zColNew ){
+ /* Add initial or additional column. Init db if necessary. */
+ if( *pDb==0 ){
+ if( SQLITE_OK!=sqlite3_open(zCOL_DB, pDb) ) return 0;
+#ifdef SHELL_COLFIX_DB
+ if(*zCOL_DB!=':')
+ sqlite3_exec(*pDb,"drop table if exists ColNames;"
+ "drop view if exists RepeatedNames;",0,0,0);
+#endif
+ rc = sqlite3_exec(*pDb, zTabMake, 0, 0, 0);
+ rc_err_oom_die(rc);
+ }
+ assert(*pDb!=0);
+ rc = sqlite3_prepare_v2(*pDb, zTabFill, -1, &pStmt, 0);
+ rc_err_oom_die(rc);
+ rc = sqlite3_bind_text(pStmt, 1, zColNew, -1, 0);
+ rc_err_oom_die(rc);
+ rc = sqlite3_step(pStmt);
+ rc_err_oom_die(rc);
+ sqlite3_finalize(pStmt);
+ return 0;
+ }else if( *pDb==0 ){
+ return 0;
+ }else{
+ /* Formulate the columns spec, close the DB, zero *pDb. */
+ char *zColsSpec = 0;
+ int hasDupes = db_int(*pDb, zHasDupes);
+#ifdef SQLITE_ENABLE_MATH_FUNCTIONS
+ int nDigits = (hasDupes)? db_int(*pDb, zColDigits) : 0;
+#else
+# define nDigits 2
+#endif
+ if( hasDupes ){
+#ifdef SHELL_COLUMN_RENAME_CLEAN
+ rc = sqlite3_exec(*pDb, zDedoctor, 0, 0, 0);
+ rc_err_oom_die(rc);
+#endif
+ rc = sqlite3_exec(*pDb, zSetReps, 0, 0, 0);
+ rc_err_oom_die(rc);
+ rc = sqlite3_prepare_v2(*pDb, zRenameRank, -1, &pStmt, 0);
+ rc_err_oom_die(rc);
+ sqlite3_bind_int(pStmt, 1, nDigits);
+ rc = sqlite3_step(pStmt);
+ sqlite3_finalize(pStmt);
+ assert(rc==SQLITE_DONE);
+ }
+ assert(db_int(*pDb, zHasDupes)==0); /* Consider: remove this */
+ rc = sqlite3_prepare_v2(*pDb, zCollectVar, -1, &pStmt, 0);
+ rc_err_oom_die(rc);
+ rc = sqlite3_step(pStmt);
+ if( rc==SQLITE_ROW ){
+ zColsSpec = sqlite3_mprintf("%s", sqlite3_column_text(pStmt, 0));
+ }else{
+ zColsSpec = 0;
+ }
+ if( pzRenamed!=0 ){
+ if( !hasDupes ) *pzRenamed = 0;
+ else{
+ sqlite3_finalize(pStmt);
+ if( SQLITE_OK==sqlite3_prepare_v2(*pDb, zRenamesDone, -1, &pStmt, 0)
+ && SQLITE_ROW==sqlite3_step(pStmt) ){
+ *pzRenamed = sqlite3_mprintf("%s", sqlite3_column_text(pStmt, 0));
+ }else
+ *pzRenamed = 0;
+ }
+ }
+ sqlite3_finalize(pStmt);
+ sqlite3_close(*pDb);
+ *pDb = 0;
+ return zColsSpec;
+ }
+}
+
/*
** If an input line begins with "." then invoke this routine to
** process that line.
@@ -18902,8 +19419,9 @@ static int do_meta_command(char *zLine, ShellState *p){
while( sqlite3_step(pStmt)==SQLITE_ROW ){
const char *zSchema = (const char *)sqlite3_column_text(pStmt,1);
const char *zFile = (const char*)sqlite3_column_text(pStmt,2);
+ if( zSchema==0 || zFile==0 ) continue;
azName = sqlite3_realloc(azName, (nName+1)*2*sizeof(char*));
- if( azName==0 ){ shell_out_of_memory(); /* Does not return */ }
+ shell_check_oom(azName);
azName[nName*2] = strdup(zSchema);
azName[nName*2+1] = strdup(zFile);
nName++;
@@ -19159,8 +19677,15 @@ static int do_meta_command(char *zLine, ShellState *p){
#ifndef SQLITE_OMIT_VIRTUALTABLE
if( c=='e' && strncmp(azArg[0], "expert", n)==0 ){
- open_db(p, 0);
- expertDotCommand(p, azArg, nArg);
+ if( p->bSafeMode ){
+ raw_printf(stderr,
+ "Cannot run experimental commands such as \"%s\" in safe mode\n",
+ azArg[0]);
+ rc = 1;
+ }else{
+ open_db(p, 0);
+ expertDotCommand(p, azArg, nArg);
+ }
}else
#endif
@@ -19381,6 +19906,7 @@ static int do_meta_command(char *zLine, ShellState *p){
if( c=='i' && strncmp(azArg[0], "import", n)==0 ){
char *zTable = 0; /* Insert data into this table */
+ char *zSchema = 0; /* within this schema (may default to "main") */
char *zFile = 0; /* Name of file to extra content from */
sqlite3_stmt *pStmt = NULL; /* A statement */
int nCol; /* Number of columns in the table */
@@ -19389,11 +19915,13 @@ static int do_meta_command(char *zLine, ShellState *p){
int needCommit; /* True to COMMIT or ROLLBACK at end */
int nSep; /* Number of bytes in p->colSeparator[] */
char *zSql; /* An SQL statement */
+ char *zFullTabName; /* Table name with schema if applicable */
ImportCtx sCtx; /* Reader context */
char *(SQLITE_CDECL *xRead)(ImportCtx*); /* Func to read one value */
int eVerbose = 0; /* Larger for more console output */
int nSkip = 0; /* Initial lines to skip */
int useOutputMode = 1; /* Use output mode to determine separators */
+ char *zCreate = 0; /* CREATE TABLE statement text */
failIfSafeMode(p, "cannot run .import in safe mode");
memset(&sCtx, 0, sizeof(sCtx));
@@ -19423,6 +19951,8 @@ static int do_meta_command(char *zLine, ShellState *p){
}
}else if( strcmp(z,"-v")==0 ){
eVerbose++;
+ }else if( strcmp(z,"-schema")==0 && i<nArg-1 ){
+ zSchema = azArg[++i];
}else if( strcmp(z,"-skip")==0 && i<nArg-1 ){
nSkip = integerValue(azArg[++i]);
}else if( strcmp(z,"-ascii")==0 ){
@@ -19525,11 +20055,17 @@ static int do_meta_command(char *zLine, ShellState *p){
output_c_string(p->out, zSep);
utf8_printf(p->out, "\n");
}
+ /* Below, resources must be freed before exit. */
while( (nSkip--)>0 ){
while( xRead(&sCtx) && sCtx.cTerm==sCtx.cColSep ){}
}
- zSql = sqlite3_mprintf("SELECT * FROM \"%w\"", zTable);
- if( zSql==0 ){
+ if( zSchema!=0 ){
+ zFullTabName = sqlite3_mprintf("\"%w\".\"%w\"", zSchema, zTable);
+ }else{
+ zFullTabName = sqlite3_mprintf("\"%w\"", zTable);
+ }
+ zSql = sqlite3_mprintf("SELECT * FROM %s", zFullTabName);
+ if( zSql==0 || zFullTabName==0 ){
import_cleanup(&sCtx);
shell_out_of_memory();
}
@@ -19537,43 +20073,51 @@ static int do_meta_command(char *zLine, ShellState *p){
rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
import_append_char(&sCtx, 0); /* To ensure sCtx.z is allocated */
if( rc && sqlite3_strglob("no such table: *", sqlite3_errmsg(p->db))==0 ){
- char *zCreate = sqlite3_mprintf("CREATE TABLE \"%w\"", zTable);
- char cSep = '(';
+ sqlite3 *dbCols = 0;
+ char *zRenames = 0;
+ char *zColDefs;
+ zCreate = sqlite3_mprintf("CREATE TABLE %s", zFullTabName);
while( xRead(&sCtx) ){
- zCreate = sqlite3_mprintf("%z%c\n \"%w\" TEXT", zCreate, cSep, sCtx.z);
- cSep = ',';
+ zAutoColumn(sCtx.z, &dbCols, 0);
if( sCtx.cTerm!=sCtx.cColSep ) break;
}
- if( cSep=='(' ){
+ zColDefs = zAutoColumn(0, &dbCols, &zRenames);
+ if( zRenames!=0 ){
+ utf8_printf((stdin_is_interactive && p->in==stdin)? p->out : stderr,
+ "Columns renamed during .import %s due to duplicates:\n"
+ "%s\n", sCtx.zFile, zRenames);
+ sqlite3_free(zRenames);
+ }
+ assert(dbCols==0);
+ if( zColDefs==0 ){
+ utf8_printf(stderr,"%s: empty file\n", sCtx.zFile);
+ import_fail:
sqlite3_free(zCreate);
+ sqlite3_free(zSql);
+ sqlite3_free(zFullTabName);
import_cleanup(&sCtx);
- utf8_printf(stderr,"%s: empty file\n", sCtx.zFile);
rc = 1;
goto meta_command_exit;
}
- zCreate = sqlite3_mprintf("%z\n)", zCreate);
+ zCreate = sqlite3_mprintf("%z%z\n", zCreate, zColDefs);
if( eVerbose>=1 ){
utf8_printf(p->out, "%s\n", zCreate);
}
rc = sqlite3_exec(p->db, zCreate, 0, 0, 0);
- sqlite3_free(zCreate);
if( rc ){
- utf8_printf(stderr, "CREATE TABLE \"%s\"(...) failed: %s\n", zTable,
- sqlite3_errmsg(p->db));
- import_cleanup(&sCtx);
- rc = 1;
- goto meta_command_exit;
+ utf8_printf(stderr, "%s failed:\n%s\n", zCreate, sqlite3_errmsg(p->db));
+ goto import_fail;
}
+ sqlite3_free(zCreate);
+ zCreate = 0;
rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
}
- sqlite3_free(zSql);
if( rc ){
if (pStmt) sqlite3_finalize(pStmt);
utf8_printf(stderr,"Error: %s\n", sqlite3_errmsg(p->db));
- import_cleanup(&sCtx);
- rc = 1;
- goto meta_command_exit;
+ goto import_fail;
}
+ sqlite3_free(zSql);
nCol = sqlite3_column_count(pStmt);
sqlite3_finalize(pStmt);
pStmt = 0;
@@ -19583,7 +20127,7 @@ static int do_meta_command(char *zLine, ShellState *p){
import_cleanup(&sCtx);
shell_out_of_memory();
}
- sqlite3_snprintf(nByte+20, zSql, "INSERT INTO \"%w\" VALUES(?", zTable);
+ sqlite3_snprintf(nByte+20, zSql, "INSERT INTO %s VALUES(?", zFullTabName);
j = strlen30(zSql);
for(i=1; i<nCol; i++){
zSql[j++] = ',';
@@ -19595,14 +20139,13 @@ static int do_meta_command(char *zLine, ShellState *p){
utf8_printf(p->out, "Insert using: %s\n", zSql);
}
rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
- sqlite3_free(zSql);
if( rc ){
utf8_printf(stderr, "Error: %s\n", sqlite3_errmsg(p->db));
if (pStmt) sqlite3_finalize(pStmt);
- import_cleanup(&sCtx);
- rc = 1;
- goto meta_command_exit;
+ goto import_fail;
}
+ sqlite3_free(zSql);
+ sqlite3_free(zFullTabName);
needCommit = sqlite3_get_autocommit(p->db);
if( needCommit ) sqlite3_exec(p->db, "BEGIN", 0, 0, 0);
do{
@@ -19884,60 +20427,123 @@ static int do_meta_command(char *zLine, ShellState *p){
}else
if( c=='m' && strncmp(azArg[0], "mode", n)==0 ){
- const char *zMode = nArg>=2 ? azArg[1] : "";
- int n2 = strlen30(zMode);
- int c2 = zMode[0];
- if( c2=='l' && n2>2 && strncmp(azArg[1],"lines",n2)==0 ){
+ const char *zMode = 0;
+ const char *zTabname = 0;
+ int i, n2;
+ ColModeOpts cmOpts = ColModeOpts_default;
+ for(i=1; i<nArg; i++){
+ const char *z = azArg[i];
+ if( optionMatch(z,"wrap") && i+1<nArg ){
+ cmOpts.iWrap = integerValue(azArg[++i]);
+ }else if( optionMatch(z,"ww") ){
+ cmOpts.bWordWrap = 1;
+ }else if( optionMatch(z,"wordwrap") && i+1<nArg ){
+ cmOpts.bWordWrap = (u8)booleanValue(azArg[++i]);
+ }else if( optionMatch(z,"quote") ){
+ cmOpts.bQuote = 1;
+ }else if( optionMatch(z,"noquote") ){
+ cmOpts.bQuote = 0;
+ }else if( zMode==0 ){
+ zMode = z;
+ /* Apply defaults for qbox pseudo-mods. If that
+ * overwrites already-set values, user was informed of this.
+ */
+ if( strcmp(z, "qbox")==0 ){
+ ColModeOpts cmo = ColModeOpts_default_qbox;
+ zMode = "box";
+ cmOpts = cmo;
+ }
+ }else if( zTabname==0 ){
+ zTabname = z;
+ }else if( z[0]=='-' ){
+ utf8_printf(stderr, "unknown option: %s\n", z);
+ utf8_printf(stderr, "options:\n"
+ " --noquote\n"
+ " --quote\n"
+ " --wordwrap on/off\n"
+ " --wrap N\n"
+ " --ww\n");
+ rc = 1;
+ goto meta_command_exit;
+ }else{
+ utf8_printf(stderr, "extra argument: \"%s\"\n", z);
+ rc = 1;
+ goto meta_command_exit;
+ }
+ }
+ if( zMode==0 ){
+ if( p->mode==MODE_Column
+ || (p->mode>=MODE_Markdown && p->mode<=MODE_Box)
+ ){
+ raw_printf
+ (p->out,
+ "current output mode: %s --wrap %d --wordwrap %s --%squote\n",
+ modeDescr[p->mode], p->cmOpts.iWrap,
+ p->cmOpts.bWordWrap ? "on" : "off",
+ p->cmOpts.bQuote ? "" : "no");
+ }else{
+ raw_printf(p->out, "current output mode: %s\n", modeDescr[p->mode]);
+ }
+ zMode = modeDescr[p->mode];
+ }
+ n2 = strlen30(zMode);
+ if( strncmp(zMode,"lines",n2)==0 ){
p->mode = MODE_Line;
sqlite3_snprintf(sizeof(p->rowSeparator), p->rowSeparator, SEP_Row);
- }else if( c2=='c' && strncmp(azArg[1],"columns",n2)==0 ){
+ }else if( strncmp(zMode,"columns",n2)==0 ){
p->mode = MODE_Column;
if( (p->shellFlgs & SHFLG_HeaderSet)==0 ){
p->showHeader = 1;
}
sqlite3_snprintf(sizeof(p->rowSeparator), p->rowSeparator, SEP_Row);
- }else if( c2=='l' && n2>2 && strncmp(azArg[1],"list",n2)==0 ){
+ p->cmOpts = cmOpts;
+ }else if( strncmp(zMode,"list",n2)==0 ){
p->mode = MODE_List;
sqlite3_snprintf(sizeof(p->colSeparator), p->colSeparator, SEP_Column);
sqlite3_snprintf(sizeof(p->rowSeparator), p->rowSeparator, SEP_Row);
- }else if( c2=='h' && strncmp(azArg[1],"html",n2)==0 ){
+ }else if( strncmp(zMode,"html",n2)==0 ){
p->mode = MODE_Html;
- }else if( c2=='t' && strncmp(azArg[1],"tcl",n2)==0 ){
+ }else if( strncmp(zMode,"tcl",n2)==0 ){
p->mode = MODE_Tcl;
sqlite3_snprintf(sizeof(p->colSeparator), p->colSeparator, SEP_Space);
sqlite3_snprintf(sizeof(p->rowSeparator), p->rowSeparator, SEP_Row);
- }else if( c2=='c' && strncmp(azArg[1],"csv",n2)==0 ){
+ }else if( strncmp(zMode,"csv",n2)==0 ){
p->mode = MODE_Csv;
sqlite3_snprintf(sizeof(p->colSeparator), p->colSeparator, SEP_Comma);
sqlite3_snprintf(sizeof(p->rowSeparator), p->rowSeparator, SEP_CrLf);
- }else if( c2=='t' && strncmp(azArg[1],"tabs",n2)==0 ){
+ }else if( strncmp(zMode,"tabs",n2)==0 ){
p->mode = MODE_List;
sqlite3_snprintf(sizeof(p->colSeparator), p->colSeparator, SEP_Tab);
- }else if( c2=='i' && strncmp(azArg[1],"insert",n2)==0 ){
+ }else if( strncmp(zMode,"insert",n2)==0 ){
p->mode = MODE_Insert;
- set_table_name(p, nArg>=3 ? azArg[2] : "table");
- }else if( c2=='q' && strncmp(azArg[1],"quote",n2)==0 ){
+ set_table_name(p, zTabname ? zTabname : "table");
+ }else if( strncmp(zMode,"quote",n2)==0 ){
p->mode = MODE_Quote;
sqlite3_snprintf(sizeof(p->colSeparator), p->colSeparator, SEP_Comma);
sqlite3_snprintf(sizeof(p->rowSeparator), p->rowSeparator, SEP_Row);
- }else if( c2=='a' && strncmp(azArg[1],"ascii",n2)==0 ){
+ }else if( strncmp(zMode,"ascii",n2)==0 ){
p->mode = MODE_Ascii;
sqlite3_snprintf(sizeof(p->colSeparator), p->colSeparator, SEP_Unit);
sqlite3_snprintf(sizeof(p->rowSeparator), p->rowSeparator, SEP_Record);
- }else if( c2=='m' && strncmp(azArg[1],"markdown",n2)==0 ){
+ }else if( strncmp(zMode,"markdown",n2)==0 ){
p->mode = MODE_Markdown;
- }else if( c2=='t' && strncmp(azArg[1],"table",n2)==0 ){
+ p->cmOpts = cmOpts;
+ }else if( strncmp(zMode,"table",n2)==0 ){
p->mode = MODE_Table;
- }else if( c2=='b' && strncmp(azArg[1],"box",n2)==0 ){
+ p->cmOpts = cmOpts;
+ }else if( strncmp(zMode,"box",n2)==0 ){
p->mode = MODE_Box;
- }else if( c2=='j' && strncmp(azArg[1],"json",n2)==0 ){
+ p->cmOpts = cmOpts;
+ }else if( strncmp(zMode,"count",n2)==0 ){
+ p->mode = MODE_Count;
+ }else if( strncmp(zMode,"off",n2)==0 ){
+ p->mode = MODE_Off;
+ }else if( strncmp(zMode,"json",n2)==0 ){
p->mode = MODE_Json;
- }else if( nArg==1 ){
- raw_printf(p->out, "current output mode: %s\n", modeDescr[p->mode]);
}else{
raw_printf(stderr, "Error: mode should be one of: "
"ascii box column csv html insert json line list markdown "
- "quote table tabs tcl\n");
+ "qbox quote table tabs tcl\n");
rc = 1;
}
p->cMode = p->mode;
@@ -19948,7 +20554,8 @@ static int do_meta_command(char *zLine, ShellState *p){
raw_printf(stderr, "Usage: .nonce NONCE\n");
rc = 1;
}else if( p->zNonce==0 || strcmp(azArg[1],p->zNonce)!=0 ){
- raw_printf(stderr, "line %d: incorrect nonce: \"%s\"\n", p->lineno, azArg[1]);
+ raw_printf(stderr, "line %d: incorrect nonce: \"%s\"\n",
+ p->lineno, azArg[1]);
exit(1);
}else{
p->bSafeMode = 0;
@@ -19967,35 +20574,8 @@ static int do_meta_command(char *zLine, ShellState *p){
}
}else
-#ifdef SQLITE_DEBUG
- if( c=='o' && strcmp(azArg[0],"oom")==0 ){
- int i;
- for(i=1; i<nArg; i++){
- const char *z = azArg[i];
- if( z[0]=='-' && z[1]=='-' ) z++;
- if( strcmp(z,"-repeat")==0 ){
- if( i==nArg-1 ){
- raw_printf(p->out, "missing argument on \"%s\"\n", azArg[i]);
- rc = 1;
- }else{
- oomRepeat = (int)integerValue(azArg[++i]);
- }
- }else if( IsDigit(z[0]) ){
- oomCounter = (int)integerValue(azArg[i]);
- }else{
- raw_printf(p->out, "unknown argument: \"%s\"\n", azArg[i]);
- raw_printf(p->out, "Usage: .oom [--repeat N] [M]\n");
- rc = 1;
- }
- }
- if( rc==0 ){
- raw_printf(p->out, "oomCounter = %d\n", oomCounter);
- raw_printf(p->out, "oomRepeat = %d\n", oomRepeat);
- }
- }else
-#endif /* SQLITE_DEBUG */
-
if( c=='o' && strncmp(azArg[0], "open", n)==0 && n>=2 ){
+ const char *zFN = 0; /* Pointer to constant filename */
char *zNewFilename = 0; /* Name of the database file to open */
int iName = 1; /* Index in azArg[] of the filename */
int newFlag = 0; /* True to delete file before opening */
@@ -20028,12 +20608,12 @@ static int do_meta_command(char *zLine, ShellState *p){
utf8_printf(stderr, "unknown option: %s\n", z);
rc = 1;
goto meta_command_exit;
- }else if( zNewFilename ){
+ }else if( zFN ){
utf8_printf(stderr, "extra argument: \"%s\"\n", z);
rc = 1;
goto meta_command_exit;
}else{
- zNewFilename = sqlite3_mprintf("%s", z);
+ zFN = z;
}
}
@@ -20049,15 +20629,21 @@ static int do_meta_command(char *zLine, ShellState *p){
p->szMax = 0;
/* If a filename is specified, try to open it first */
- if( zNewFilename || p->openMode==SHELL_OPEN_HEXDB ){
- if( newFlag && !p->bSafeMode ) shellDeleteFile(zNewFilename);
+ if( zFN || p->openMode==SHELL_OPEN_HEXDB ){
+ if( newFlag && zFN && !p->bSafeMode ) shellDeleteFile(zFN);
if( p->bSafeMode
&& p->openMode!=SHELL_OPEN_HEXDB
- && zNewFilename
- && strcmp(zNewFilename,":memory:")!=0
+ && zFN
+ && strcmp(zFN,":memory:")!=0
){
failIfSafeMode(p, "cannot open disk-based database files in safe mode");
}
+ if( zFN ){
+ zNewFilename = sqlite3_mprintf("%s", zFN);
+ shell_check_oom(zNewFilename);
+ }else{
+ zNewFilename = 0;
+ }
p->pAuxDb->zDbFilename = zNewFilename;
open_db(p, OPEN_DB_KEEPALIVE);
if( p->db==0 ){
@@ -20111,7 +20697,7 @@ static int do_meta_command(char *zLine, ShellState *p){
}
}else if( zFile==0 && eMode!='e' && eMode!='x' ){
zFile = sqlite3_mprintf("%s", z);
- if( zFile[0]=='|' ){
+ if( zFile && zFile[0]=='|' ){
while( i+1<nArg ) zFile = sqlite3_mprintf("%z %s", zFile, azArg[++i]);
break;
}
@@ -20124,7 +20710,9 @@ static int do_meta_command(char *zLine, ShellState *p){
goto meta_command_exit;
}
}
- if( zFile==0 ) zFile = sqlite3_mprintf("stdout");
+ if( zFile==0 ){
+ zFile = sqlite3_mprintf("stdout");
+ }
if( bOnce ){
p->outCount = 2;
}else{
@@ -20151,6 +20739,7 @@ static int do_meta_command(char *zLine, ShellState *p){
zFile = sqlite3_mprintf("%s", p->zTempFile);
}
#endif /* SQLITE_NOHAVE_SYSTEM */
+ shell_check_oom(zFile);
if( zFile[0]=='|' ){
#ifdef SQLITE_OMIT_POPEN
raw_printf(stderr, "Error: pipes are not supported in this OS\n");
@@ -20247,7 +20836,7 @@ static int do_meta_command(char *zLine, ShellState *p){
zSql = sqlite3_mprintf(
"REPLACE INTO temp.sqlite_parameters(key,value)"
"VALUES(%Q,%s);", zKey, zValue);
- if( zSql==0 ) shell_out_of_memory();
+ shell_check_oom(zSql);
pStmt = 0;
rx = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
sqlite3_free(zSql);
@@ -20257,7 +20846,7 @@ static int do_meta_command(char *zLine, ShellState *p){
zSql = sqlite3_mprintf(
"REPLACE INTO temp.sqlite_parameters(key,value)"
"VALUES(%Q,%Q);", zKey, zValue);
- if( zSql==0 ) shell_out_of_memory();
+ shell_check_oom(zSql);
rx = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
sqlite3_free(zSql);
if( rx!=SQLITE_OK ){
@@ -20278,7 +20867,7 @@ static int do_meta_command(char *zLine, ShellState *p){
if( nArg==3 && strcmp(azArg[1],"unset")==0 ){
char *zSql = sqlite3_mprintf(
"DELETE FROM temp.sqlite_parameters WHERE key=%Q", azArg[2]);
- if( zSql==0 ) shell_out_of_memory();
+ shell_check_oom(zSql);
sqlite3_exec(p->db, zSql, 0, 0, 0);
sqlite3_free(zSql);
}else
@@ -20504,6 +21093,7 @@ static int do_meta_command(char *zLine, ShellState *p){
" rootpage integer,\n"
" sql text\n"
")", zName);
+ shell_check_oom(new_argv[0]);
new_argv[1] = 0;
new_colv[0] = "sql";
new_colv[1] = 0;
@@ -20555,8 +21145,10 @@ static int do_meta_command(char *zLine, ShellState *p){
appendText(&sSelect, ") WHERE ", 0);
if( zName ){
char *zQarg = sqlite3_mprintf("%Q", zName);
- int bGlob = strchr(zName, '*') != 0 || strchr(zName, '?') != 0 ||
- strchr(zName, '[') != 0;
+ int bGlob;
+ shell_check_oom(zQarg);
+ bGlob = strchr(zName, '*') != 0 || strchr(zName, '?') != 0 ||
+ strchr(zName, '[') != 0;
if( strchr(zName, '.') ){
appendText(&sSelect, "lower(printf('%s.%s',sname,tbl_name))", 0);
}else{
@@ -20719,7 +21311,8 @@ static int do_meta_command(char *zLine, ShellState *p){
exit(1);
}
for(ii=1; ii<nCmd; ii++){
- pSession->azFilter[ii-1] = sqlite3_mprintf("%s", azCmd[ii]);
+ char *x = pSession->azFilter[ii-1] = sqlite3_mprintf("%s", azCmd[ii]);
+ shell_check_oom(x);
}
pSession->nFilter = ii-1;
}
@@ -20791,6 +21384,7 @@ static int do_meta_command(char *zLine, ShellState *p){
sqlite3session_table_filter(pSession->p, session_filter, pSession);
pAuxDb->nSession++;
pSession->zName = sqlite3_mprintf("%s", zName);
+ shell_check_oom(pSession->zName);
}else
/* If no command name matches, show a syntax error */
session_syntax_error:
@@ -20884,11 +21478,12 @@ static int do_meta_command(char *zLine, ShellState *p){
const char *zSql = (const char*)sqlite3_column_text(pStmt, 2);
const char *zAns = (const char*)sqlite3_column_text(pStmt, 3);
+ if( zOp==0 ) continue;
+ if( zSql==0 ) continue;
+ if( zAns==0 ) continue;
k = 0;
if( bVerbose>0 ){
- char *zQuote = sqlite3_mprintf("%q", zSql);
printf("%d: %s %s\n", tno, zOp, zSql);
- sqlite3_free(zQuote);
}
if( strcmp(zOp,"memo")==0 ){
utf8_printf(p->out, "%s\n", zSql);
@@ -21006,6 +21601,7 @@ static int do_meta_command(char *zLine, ShellState *p){
zSep = "VALUES(";
while( SQLITE_ROW==sqlite3_step(pStmt) ){
const char *zTab = (const char*)sqlite3_column_text(pStmt,0);
+ if( zTab==0 ) continue;
if( zLike && sqlite3_strlike(zLike, zTab, 0)!=0 ) continue;
if( strncmp(zTab, "sqlite_",7)!=0 ){
appendText(&sQuery,"SELECT * FROM ", 0);
@@ -21046,6 +21642,7 @@ static int do_meta_command(char *zLine, ShellState *p){
" FROM [sha3sum$query]",
sSql.z, iSize);
}
+ shell_check_oom(zSql);
freeText(&sQuery);
freeText(&sSql);
if( bDebug ){
@@ -21069,11 +21666,11 @@ static int do_meta_command(char *zLine, ShellState *p){
goto meta_command_exit;
}
zCmd = sqlite3_mprintf(strchr(azArg[1],' ')==0?"%s":"\"%s\"", azArg[1]);
- for(i=2; i<nArg; i++){
+ for(i=2; i<nArg && zCmd!=0; i++){
zCmd = sqlite3_mprintf(strchr(azArg[i],' ')==0?"%z %s":"%z \"%s\"",
zCmd, azArg[i]);
}
- x = system(zCmd);
+ x = zCmd!=0 ? system(zCmd) : 1;
sqlite3_free(zCmd);
if( x ) raw_printf(stderr, "System command returns %d\n", x);
}else
@@ -21094,7 +21691,17 @@ static int do_meta_command(char *zLine, ShellState *p){
utf8_printf(p->out, "%12.12s: %s\n","explain",
p->mode==MODE_Explain ? "on" : p->autoExplain ? "auto" : "off");
utf8_printf(p->out,"%12.12s: %s\n","headers", azBool[p->showHeader!=0]);
- utf8_printf(p->out, "%12.12s: %s\n","mode", modeDescr[p->mode]);
+ if( p->mode==MODE_Column
+ || (p->mode>=MODE_Markdown && p->mode<=MODE_Box)
+ ){
+ utf8_printf
+ (p->out, "%12.12s: %s --wrap %d --wordwrap %s --%squote\n", "mode",
+ modeDescr[p->mode], p->cmOpts.iWrap,
+ p->cmOpts.bWordWrap ? "on" : "off",
+ p->cmOpts.bQuote ? "" : "no");
+ }else{
+ utf8_printf(p->out, "%12.12s: %s\n","mode", modeDescr[p->mode]);
+ }
utf8_printf(p->out, "%12.12s: ", "nullvalue");
output_c_string(p->out, p->nullValue);
raw_printf(p->out, "\n");
@@ -21209,12 +21816,12 @@ static int do_meta_command(char *zLine, ShellState *p){
char **azNew;
int n2 = nAlloc*2 + 10;
azNew = sqlite3_realloc64(azResult, sizeof(azResult[0])*n2);
- if( azNew==0 ) shell_out_of_memory();
+ shell_check_oom(azNew);
nAlloc = n2;
azResult = azNew;
}
azResult[nRow] = sqlite3_mprintf("%s", sqlite3_column_text(pStmt, 0));
- if( 0==azResult[nRow] ) shell_out_of_memory();
+ shell_check_oom(azResult[nRow]);
nRow++;
}
if( sqlite3_finalize(pStmt)!=SQLITE_OK ){
@@ -21892,19 +22499,30 @@ static int runOneSqlLine(ShellState *p, char *zSql, FILE *in, int startline){
END_TIMER;
if( rc || zErrMsg ){
char zPrefix[100];
- if( in!=0 || !stdin_is_interactive ){
- sqlite3_snprintf(sizeof(zPrefix), zPrefix,
- "Error: near line %d:", startline);
+ const char *zErrorTail;
+ const char *zErrorType;
+ if( zErrMsg==0 ){
+ zErrorType = "Error";
+ zErrorTail = sqlite3_errmsg(p->db);
+ }else if( strncmp(zErrMsg, "in prepare, ",12)==0 ){
+ zErrorType = "Parse error";
+ zErrorTail = &zErrMsg[12];
+ }else if( strncmp(zErrMsg, "stepping, ", 10)==0 ){
+ zErrorType = "Runtime error";
+ zErrorTail = &zErrMsg[10];
}else{
- sqlite3_snprintf(sizeof(zPrefix), zPrefix, "Error:");
+ zErrorType = "Error";
+ zErrorTail = zErrMsg;
}
- if( zErrMsg!=0 ){
- utf8_printf(stderr, "%s %s\n", zPrefix, zErrMsg);
- sqlite3_free(zErrMsg);
- zErrMsg = 0;
+ if( in!=0 || !stdin_is_interactive ){
+ sqlite3_snprintf(sizeof(zPrefix), zPrefix,
+ "%s near line %d:", zErrorType, startline);
}else{
- utf8_printf(stderr, "%s %s\n", zPrefix, sqlite3_errmsg(p->db));
+ sqlite3_snprintf(sizeof(zPrefix), zPrefix, "%s:", zErrorType);
}
+ utf8_printf(stderr, "%s %s\n", zPrefix, zErrorTail);
+ sqlite3_free(zErrMsg);
+ zErrMsg = 0;
return 1;
}else if( ShellHasFlag(p, SHFLG_CountChanges) ){
char zLineBuf[2000];
@@ -21937,6 +22555,13 @@ static int process_input(ShellState *p){
int startline = 0; /* Line number for start of current input */
QuickScanState qss = QSS_Start; /* Accumulated line status (so far) */
+ if( p->inputNesting==MAX_INPUT_NESTING ){
+ /* This will be more informative in a later version. */
+ utf8_printf(stderr,"Input nesting limit (%d) reached at line %d."
+ " Check recursion.\n", MAX_INPUT_NESTING, p->lineno);
+ return 1;
+ }
+ ++p->inputNesting;
p->lineno = 0;
while( errCnt==0 || !bail_on_error || (p->in==0 && stdin_is_interactive) ){
fflush(p->out);
@@ -21983,7 +22608,7 @@ static int process_input(ShellState *p){
/* Grow buffer by half-again increments when big. */
nAlloc = nSql+(nSql>>1)+nLine+100;
zSql = realloc(zSql, nAlloc);
- if( zSql==0 ) shell_out_of_memory();
+ shell_check_oom(zSql);
}
if( nSql==0 ){
int i;
@@ -22019,6 +22644,7 @@ static int process_input(ShellState *p){
}
free(zSql);
free(zLine);
+ --p->inputNesting;
return errCnt>0;
}
@@ -22115,6 +22741,7 @@ static void process_sqliterc(
return;
}
zBuf = sqlite3_mprintf("%s/.sqliterc",home_dir);
+ shell_check_oom(zBuf);
sqliterc = zBuf;
}
p->in = fopen(sqliterc,"rb");
@@ -22313,10 +22940,6 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){
stdin_is_interactive = isatty(0);
stdout_is_console = isatty(1);
-#ifdef SQLITE_DEBUG
- registerOomSimulator();
-#endif
-
#if !defined(_WIN32_WCE)
if( getenv("SQLITE_DEBUG_BREAK") ){
if( isatty(0) && isatty(2) ){
@@ -22356,16 +22979,16 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){
#if !SQLITE_SHELL_IS_UTF8
sqlite3_initialize();
argvToFree = malloc(sizeof(argv[0])*argc*2);
+ shell_check_oom(argvToFree);
argcToFree = argc;
argv = argvToFree + argc;
- if( argv==0 ) shell_out_of_memory();
for(i=0; i<argc; i++){
char *z = sqlite3_win32_unicode_to_utf8(wargv[i]);
int n;
- if( z==0 ) shell_out_of_memory();
+ shell_check_oom(z);
n = (int)strlen(z);
argv[i] = malloc( n+1 );
- if( argv[i]==0 ) shell_out_of_memory();
+ shell_check_oom(argv[i]);
memcpy(argv[i], z, n+1);
argvToFree[i] = argv[i];
sqlite3_free(z);
@@ -22415,7 +23038,7 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){
readStdin = 0;
nCmd++;
azCmd = realloc(azCmd, sizeof(azCmd[0])*nCmd);
- if( azCmd==0 ) shell_out_of_memory();
+ shell_check_oom(azCmd);
azCmd[nCmd-1] = z;
}
}
diff --git a/chromium/third_party/sqlite/src/amalgamation_dev/sqlite3.c b/chromium/third_party/sqlite/src/amalgamation_dev/sqlite3.c
index fba450a7346..c04763e6a39 100644
--- a/chromium/third_party/sqlite/src/amalgamation_dev/sqlite3.c
+++ b/chromium/third_party/sqlite/src/amalgamation_dev/sqlite3.c
@@ -1,6 +1,6 @@
/******************************************************************************
** This file is an amalgamation of many separate C source files from SQLite
-** version 3.37.1. By combining all the individual C code files into this
+** version 3.38.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
@@ -452,9 +452,9 @@ extern "C" {
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
** [sqlite_version()] and [sqlite_source_id()].
*/
-#define SQLITE_VERSION "3.37.1"
-#define SQLITE_VERSION_NUMBER 3037001
-#define SQLITE_SOURCE_ID "2021-12-30 15:30:28 378629bf2ea546f73eee84063c5358439a12f7300e433f18c9e1bddd948dea62"
+#define SQLITE_VERSION "3.38.1"
+#define SQLITE_VERSION_NUMBER 3038001
+#define SQLITE_SOURCE_ID "2022-03-12 13:37:29 38c210fdd258658321c85ec9c01a072fda3ada94540e3239d29b34dc547a8cbc"
/*
** CAPI3REF: Run-Time Library Version Numbers
@@ -872,7 +872,7 @@ SQLITE_API int sqlite3_exec(
#define SQLITE_WARNING_AUTOINDEX (SQLITE_WARNING | (1<<8))
#define SQLITE_AUTH_USER (SQLITE_AUTH | (1<<8))
#define SQLITE_OK_LOAD_PERMANENTLY (SQLITE_OK | (1<<8))
-#define SQLITE_OK_SYMLINK (SQLITE_OK | (2<<8))
+#define SQLITE_OK_SYMLINK (SQLITE_OK | (2<<8)) /* internal use only */
/*
** CAPI3REF: Flags For File Open Operations
@@ -4130,13 +4130,14 @@ SQLITE_API void sqlite3_free_filename(char*);
** sqlite3_extended_errcode() might change with each API call.
** Except, there are some interfaces that are guaranteed to never
** change the value of the error code. The error-code preserving
-** interfaces are:
+** interfaces include the following:
**
** <ul>
** <li> sqlite3_errcode()
** <li> sqlite3_extended_errcode()
** <li> sqlite3_errmsg()
** <li> sqlite3_errmsg16()
+** <li> sqlite3_error_offset()
** </ul>
**
** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language
@@ -4151,6 +4152,13 @@ SQLITE_API void sqlite3_free_filename(char*);
** ^(Memory to hold the error message string is managed internally
** and must not be freed by the application)^.
**
+** ^If the most recent error references a specific token in the input
+** SQL, the sqlite3_error_offset() interface returns the byte offset
+** of the start of that token. ^The byte offset returned by
+** sqlite3_error_offset() assumes that the input SQL is UTF8.
+** ^If the most recent error does not reference a specific token in the input
+** SQL, then the sqlite3_error_offset() function returns -1.
+**
** When the serialized [threading mode] is in use, it might be the
** case that a second error occurs on a separate thread in between
** the time of the first error and the call to these interfaces.
@@ -4170,6 +4178,7 @@ SQLITE_API int sqlite3_extended_errcode(sqlite3 *db);
SQLITE_API const char *sqlite3_errmsg(sqlite3*);
SQLITE_API const void *sqlite3_errmsg16(sqlite3*);
SQLITE_API const char *sqlite3_errstr(int);
+SQLITE_API int sqlite3_error_offset(sqlite3 *db);
/*
** CAPI3REF: Prepared Statement Object
@@ -4581,6 +4590,10 @@ SQLITE_API const char *sqlite3_normalized_sql(sqlite3_stmt *pStmt);
** be false. ^Similarly, a CREATE TABLE IF NOT EXISTS statement is a
** read-only no-op if the table already exists, but
** sqlite3_stmt_readonly() still returns false for such a statement.
+**
+** ^If prepared statement X is an [EXPLAIN] or [EXPLAIN QUERY PLAN]
+** statement, then sqlite3_stmt_readonly(X) returns the same value as
+** if the EXPLAIN or EXPLAIN QUERY PLAN prefix were omitted.
*/
SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt);
@@ -4649,6 +4662,8 @@ SQLITE_API int sqlite3_stmt_busy(sqlite3_stmt*);
**
** ^The sqlite3_value objects that are passed as parameters into the
** implementation of [application-defined SQL functions] are protected.
+** ^The sqlite3_value objects returned by [sqlite3_vtab_rhs_value()]
+** are protected.
** ^The sqlite3_value object returned by
** [sqlite3_column_value()] is unprotected.
** Unprotected sqlite3_value objects may only be used as arguments
@@ -5270,6 +5285,10 @@ SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
** even empty strings, are always zero-terminated. ^The return
** value from sqlite3_column_blob() for a zero-length BLOB is a NULL pointer.
**
+** ^Strings returned by sqlite3_column_text16() always have the endianness
+** which is native to the platform, regardless of the text encoding set
+** for the database.
+**
** <b>Warning:</b> ^The object returned by [sqlite3_column_value()] is an
** [unprotected sqlite3_value] object. In a multithreaded environment,
** an unprotected sqlite3_value object may only be used safely with
@@ -5283,7 +5302,7 @@ SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
** [application-defined SQL functions] or [virtual tables], not within
** top-level application code.
**
-** The these routines may attempt to convert the datatype of the result.
+** These routines may attempt to convert the datatype of the result.
** ^For example, if the internal representation is FLOAT and a text result
** is requested, [sqlite3_snprintf()] is used internally to perform the
** conversion automatically. ^(The following table details the conversions
@@ -5308,7 +5327,7 @@ SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
** <tr><td> TEXT <td> BLOB <td> No change
** <tr><td> BLOB <td> INTEGER <td> [CAST] to INTEGER
** <tr><td> BLOB <td> FLOAT <td> [CAST] to REAL
-** <tr><td> BLOB <td> TEXT <td> Add a zero terminator if needed
+** <tr><td> BLOB <td> TEXT <td> [CAST] to TEXT, ensure zero terminator
** </table>
** </blockquote>)^
**
@@ -7428,24 +7447,56 @@ struct sqlite3_index_info {
**
** These macros define the allowed values for the
** [sqlite3_index_info].aConstraint[].op field. Each value represents
-** an operator that is part of a constraint term in the wHERE clause of
+** an operator that is part of a constraint term in the WHERE clause of
** a query that uses a [virtual table].
-*/
-#define SQLITE_INDEX_CONSTRAINT_EQ 2
-#define SQLITE_INDEX_CONSTRAINT_GT 4
-#define SQLITE_INDEX_CONSTRAINT_LE 8
-#define SQLITE_INDEX_CONSTRAINT_LT 16
-#define SQLITE_INDEX_CONSTRAINT_GE 32
-#define SQLITE_INDEX_CONSTRAINT_MATCH 64
-#define SQLITE_INDEX_CONSTRAINT_LIKE 65
-#define SQLITE_INDEX_CONSTRAINT_GLOB 66
-#define SQLITE_INDEX_CONSTRAINT_REGEXP 67
-#define SQLITE_INDEX_CONSTRAINT_NE 68
-#define SQLITE_INDEX_CONSTRAINT_ISNOT 69
-#define SQLITE_INDEX_CONSTRAINT_ISNOTNULL 70
-#define SQLITE_INDEX_CONSTRAINT_ISNULL 71
-#define SQLITE_INDEX_CONSTRAINT_IS 72
-#define SQLITE_INDEX_CONSTRAINT_FUNCTION 150
+**
+** ^The left-hand operand of the operator is given by the corresponding
+** aConstraint[].iColumn field. ^An iColumn of -1 indicates the left-hand
+** operand is the rowid.
+** The SQLITE_INDEX_CONSTRAINT_LIMIT and SQLITE_INDEX_CONSTRAINT_OFFSET
+** operators have no left-hand operand, and so for those operators the
+** corresponding aConstraint[].iColumn is meaningless and should not be
+** used.
+**
+** All operator values from SQLITE_INDEX_CONSTRAINT_FUNCTION through
+** value 255 are reserved to represent functions that are overloaded
+** by the [xFindFunction|xFindFunction method] of the virtual table
+** implementation.
+**
+** The right-hand operands for each constraint might be accessible using
+** the [sqlite3_vtab_rhs_value()] interface. Usually the right-hand
+** operand is only available if it appears as a single constant literal
+** in the input SQL. If the right-hand operand is another column or an
+** expression (even a constant expression) or a parameter, then the
+** sqlite3_vtab_rhs_value() probably will not be able to extract it.
+** ^The SQLITE_INDEX_CONSTRAINT_ISNULL and
+** SQLITE_INDEX_CONSTRAINT_ISNOTNULL operators have no right-hand operand
+** and hence calls to sqlite3_vtab_rhs_value() for those operators will
+** always return SQLITE_NOTFOUND.
+**
+** The collating sequence to be used for comparison can be found using
+** the [sqlite3_vtab_collation()] interface. For most real-world virtual
+** tables, the collating sequence of constraints does not matter (for example
+** because the constraints are numeric) and so the sqlite3_vtab_collation()
+** interface is no commonly needed.
+*/
+#define SQLITE_INDEX_CONSTRAINT_EQ 2
+#define SQLITE_INDEX_CONSTRAINT_GT 4
+#define SQLITE_INDEX_CONSTRAINT_LE 8
+#define SQLITE_INDEX_CONSTRAINT_LT 16
+#define SQLITE_INDEX_CONSTRAINT_GE 32
+#define SQLITE_INDEX_CONSTRAINT_MATCH 64
+#define SQLITE_INDEX_CONSTRAINT_LIKE 65
+#define SQLITE_INDEX_CONSTRAINT_GLOB 66
+#define SQLITE_INDEX_CONSTRAINT_REGEXP 67
+#define SQLITE_INDEX_CONSTRAINT_NE 68
+#define SQLITE_INDEX_CONSTRAINT_ISNOT 69
+#define SQLITE_INDEX_CONSTRAINT_ISNOTNULL 70
+#define SQLITE_INDEX_CONSTRAINT_ISNULL 71
+#define SQLITE_INDEX_CONSTRAINT_IS 72
+#define SQLITE_INDEX_CONSTRAINT_LIMIT 73
+#define SQLITE_INDEX_CONSTRAINT_OFFSET 74
+#define SQLITE_INDEX_CONSTRAINT_FUNCTION 150
/*
** CAPI3REF: Register A Virtual Table Implementation
@@ -7474,7 +7525,7 @@ struct sqlite3_index_info {
** destructor.
**
** ^If the third parameter (the pointer to the sqlite3_module object) is
-** NULL then no new module is create and any existing modules with the
+** NULL then no new module is created and any existing modules with the
** same name are dropped.
**
** See also: [sqlite3_drop_modules()]
@@ -8250,7 +8301,8 @@ SQLITE_API int sqlite3_test_control(int op, ...);
#define SQLITE_TESTCTRL_SEEK_COUNT 30
#define SQLITE_TESTCTRL_TRACEFLAGS 31
#define SQLITE_TESTCTRL_TUNE 32
-#define SQLITE_TESTCTRL_LAST 32 /* Largest TESTCTRL */
+#define SQLITE_TESTCTRL_LOGEST 33
+#define SQLITE_TESTCTRL_LAST 33 /* Largest TESTCTRL */
/*
** CAPI3REF: SQL Keyword Checking
@@ -8773,6 +8825,16 @@ SQLITE_API int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);
** The counter is incremented on the first [sqlite3_step()] call of each
** cycle.
**
+** [[SQLITE_STMTSTATUS_FILTER_MISS]]
+** [[SQLITE_STMTSTATUS_FILTER HIT]]
+** <dt>SQLITE_STMTSTATUS_FILTER_HIT<br>
+** SQLITE_STMTSTATUS_FILTER_MISS</dt>
+** <dd>^SQLITE_STMTSTATUS_FILTER_HIT is the number of times that a join
+** step was bypassed because a Bloom filter returned not-found. The
+** corresponding SQLITE_STMTSTATUS_FILTER_MISS value is the number of
+** times that the Bloom filter returned a find, and thus the join step
+** had to be processed as normal.
+**
** [[SQLITE_STMTSTATUS_MEMUSED]] <dt>SQLITE_STMTSTATUS_MEMUSED</dt>
** <dd>^This is the approximate number of bytes of heap memory
** used to store the prepared statement. ^This value is not actually
@@ -8787,6 +8849,8 @@ SQLITE_API int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);
#define SQLITE_STMTSTATUS_VM_STEP 4
#define SQLITE_STMTSTATUS_REPREPARE 5
#define SQLITE_STMTSTATUS_RUN 6
+#define SQLITE_STMTSTATUS_FILTER_MISS 7
+#define SQLITE_STMTSTATUS_FILTER_HIT 8
#define SQLITE_STMTSTATUS_MEMUSED 99
/*
@@ -9755,20 +9819,270 @@ SQLITE_API int sqlite3_vtab_nochange(sqlite3_context*);
/*
** CAPI3REF: Determine The Collation For a Virtual Table Constraint
+** METHOD: sqlite3_index_info
**
** This function may only be called from within a call to the [xBestIndex]
-** method of a [virtual table].
+** method of a [virtual table]. This function returns a pointer to a string
+** that is the name of the appropriate collation sequence to use for text
+** comparisons on the constraint identified by its arguments.
+**
+** The first argument must be the pointer to the [sqlite3_index_info] object
+** that is the first parameter to the xBestIndex() method. The second argument
+** must be an index into the aConstraint[] array belonging to the
+** sqlite3_index_info structure passed to xBestIndex.
**
-** The first argument must be the sqlite3_index_info object that is the
-** first parameter to the xBestIndex() method. The second argument must be
-** an index into the aConstraint[] array belonging to the sqlite3_index_info
-** structure passed to xBestIndex. This function returns a pointer to a buffer
-** containing the name of the collation sequence for the corresponding
-** constraint.
+** Important:
+** The first parameter must be the same pointer that is passed into the
+** xBestMethod() method. The first parameter may not be a pointer to a
+** different [sqlite3_index_info] object, even an exact copy.
+**
+** The return value is computed as follows:
+**
+** <ol>
+** <li><p> If the constraint comes from a WHERE clause expression that contains
+** a [COLLATE operator], then the name of the collation specified by
+** that COLLATE operator is returned.
+** <li><p> If there is no COLLATE operator, but the column that is the subject
+** of the constraint specifies an alternative collating sequence via
+** a [COLLATE clause] on the column definition within the CREATE TABLE
+** statement that was passed into [sqlite3_declare_vtab()], then the
+** name of that alternative collating sequence is returned.
+** <li><p> Otherwise, "BINARY" is returned.
+** </ol>
*/
SQLITE_API SQLITE_EXPERIMENTAL const char *sqlite3_vtab_collation(sqlite3_index_info*,int);
/*
+** CAPI3REF: Determine if a virtual table query is DISTINCT
+** METHOD: sqlite3_index_info
+**
+** This API may only be used from within an [xBestIndex|xBestIndex method]
+** of a [virtual table] implementation. The result of calling this
+** interface from outside of xBestIndex() is undefined and probably harmful.
+**
+** ^The sqlite3_vtab_distinct() interface returns an integer that is
+** either 0, 1, or 2. The integer returned by sqlite3_vtab_distinct()
+** gives the virtual table additional information about how the query
+** planner wants the output to be ordered. As long as the virtual table
+** can meet the ordering requirements of the query planner, it may set
+** the "orderByConsumed" flag.
+**
+** <ol><li value="0"><p>
+** ^If the sqlite3_vtab_distinct() interface returns 0, that means
+** that the query planner needs the virtual table to return all rows in the
+** sort order defined by the "nOrderBy" and "aOrderBy" fields of the
+** [sqlite3_index_info] object. This is the default expectation. If the
+** virtual table outputs all rows in sorted order, then it is always safe for
+** the xBestIndex method to set the "orderByConsumed" flag, regardless of
+** the return value from sqlite3_vtab_distinct().
+** <li value="1"><p>
+** ^(If the sqlite3_vtab_distinct() interface returns 1, that means
+** that the query planner does not need the rows to be returned in sorted order
+** as long as all rows with the same values in all columns identified by the
+** "aOrderBy" field are adjacent.)^ This mode is used when the query planner
+** is doing a GROUP BY.
+** <li value="2"><p>
+** ^(If the sqlite3_vtab_distinct() interface returns 2, that means
+** that the query planner does not need the rows returned in any particular
+** order, as long as rows with the same values in all "aOrderBy" columns
+** are adjacent.)^ ^(Furthermore, only a single row for each particular
+** combination of values in the columns identified by the "aOrderBy" field
+** needs to be returned.)^ ^It is always ok for two or more rows with the same
+** values in all "aOrderBy" columns to be returned, as long as all such rows
+** are adjacent. ^The virtual table may, if it chooses, omit extra rows
+** that have the same value for all columns identified by "aOrderBy".
+** ^However omitting the extra rows is optional.
+** This mode is used for a DISTINCT query.
+** </ol>
+**
+** ^For the purposes of comparing virtual table output values to see if the
+** values are same value for sorting purposes, two NULL values are considered
+** to be the same. In other words, the comparison operator is "IS"
+** (or "IS NOT DISTINCT FROM") and not "==".
+**
+** If a virtual table implementation is unable to meet the requirements
+** specified above, then it must not set the "orderByConsumed" flag in the
+** [sqlite3_index_info] object or an incorrect answer may result.
+**
+** ^A virtual table implementation is always free to return rows in any order
+** it wants, as long as the "orderByConsumed" flag is not set. ^When the
+** the "orderByConsumed" flag is unset, the query planner will add extra
+** [bytecode] to ensure that the final results returned by the SQL query are
+** ordered correctly. The use of the "orderByConsumed" flag and the
+** sqlite3_vtab_distinct() interface is merely an optimization. ^Careful
+** use of the sqlite3_vtab_distinct() interface and the "orderByConsumed"
+** flag might help queries against a virtual table to run faster. Being
+** overly aggressive and setting the "orderByConsumed" flag when it is not
+** valid to do so, on the other hand, might cause SQLite to return incorrect
+** results.
+*/
+SQLITE_API int sqlite3_vtab_distinct(sqlite3_index_info*);
+
+/*
+** CAPI3REF: Identify and handle IN constraints in xBestIndex
+**
+** This interface may only be used from within an
+** [xBestIndex|xBestIndex() method] of a [virtual table] implementation.
+** The result of invoking this interface from any other context is
+** undefined and probably harmful.
+**
+** ^(A constraint on a virtual table of the form
+** "[IN operator|column IN (...)]" is
+** communicated to the xBestIndex method as a
+** [SQLITE_INDEX_CONSTRAINT_EQ] constraint.)^ If xBestIndex wants to use
+** this constraint, it must set the corresponding
+** aConstraintUsage[].argvIndex to a postive integer. ^(Then, under
+** the usual mode of handling IN operators, SQLite generates [bytecode]
+** that invokes the [xFilter|xFilter() method] once for each value
+** on the right-hand side of the IN operator.)^ Thus the virtual table
+** only sees a single value from the right-hand side of the IN operator
+** at a time.
+**
+** In some cases, however, it would be advantageous for the virtual
+** table to see all values on the right-hand of the IN operator all at
+** once. The sqlite3_vtab_in() interfaces facilitates this in two ways:
+**
+** <ol>
+** <li><p>
+** ^A call to sqlite3_vtab_in(P,N,-1) will return true (non-zero)
+** if and only if the [sqlite3_index_info|P->aConstraint][N] constraint
+** is an [IN operator] that can be processed all at once. ^In other words,
+** sqlite3_vtab_in() with -1 in the third argument is a mechanism
+** by which the virtual table can ask SQLite if all-at-once processing
+** of the IN operator is even possible.
+**
+** <li><p>
+** ^A call to sqlite3_vtab_in(P,N,F) with F==1 or F==0 indicates
+** to SQLite that the virtual table does or does not want to process
+** the IN operator all-at-once, respectively. ^Thus when the third
+** parameter (F) is non-negative, this interface is the mechanism by
+** which the virtual table tells SQLite how it wants to process the
+** IN operator.
+** </ol>
+**
+** ^The sqlite3_vtab_in(P,N,F) interface can be invoked multiple times
+** within the same xBestIndex method call. ^For any given P,N pair,
+** the return value from sqlite3_vtab_in(P,N,F) will always be the same
+** within the same xBestIndex call. ^If the interface returns true
+** (non-zero), that means that the constraint is an IN operator
+** that can be processed all-at-once. ^If the constraint is not an IN
+** operator or cannot be processed all-at-once, then the interface returns
+** false.
+**
+** ^(All-at-once processing of the IN operator is selected if both of the
+** following conditions are met:
+**
+** <ol>
+** <li><p> The P->aConstraintUsage[N].argvIndex value is set to a positive
+** integer. This is how the virtual table tells SQLite that it wants to
+** use the N-th constraint.
+**
+** <li><p> The last call to sqlite3_vtab_in(P,N,F) for which F was
+** non-negative had F>=1.
+** </ol>)^
+**
+** ^If either or both of the conditions above are false, then SQLite uses
+** the traditional one-at-a-time processing strategy for the IN constraint.
+** ^If both conditions are true, then the argvIndex-th parameter to the
+** xFilter method will be an [sqlite3_value] that appears to be NULL,
+** but which can be passed to [sqlite3_vtab_in_first()] and
+** [sqlite3_vtab_in_next()] to find all values on the right-hand side
+** of the IN constraint.
+*/
+SQLITE_API int sqlite3_vtab_in(sqlite3_index_info*, int iCons, int bHandle);
+
+/*
+** CAPI3REF: Find all elements on the right-hand side of an IN constraint.
+**
+** These interfaces are only useful from within the
+** [xFilter|xFilter() method] of a [virtual table] implementation.
+** The result of invoking these interfaces from any other context
+** is undefined and probably harmful.
+**
+** The X parameter in a call to sqlite3_vtab_in_first(X,P) or
+** sqlite3_vtab_in_next(X,P) must be one of the parameters to the
+** xFilter method which invokes these routines, and specifically
+** a parameter that was previously selected for all-at-once IN constraint
+** processing use the [sqlite3_vtab_in()] interface in the
+** [xBestIndex|xBestIndex method]. ^(If the X parameter is not
+** an xFilter argument that was selected for all-at-once IN constraint
+** processing, then these routines return [SQLITE_MISUSE])^ or perhaps
+** exhibit some other undefined or harmful behavior.
+**
+** ^(Use these routines to access all values on the right-hand side
+** of the IN constraint using code like the following:
+**
+** <blockquote><pre>
+** &nbsp; for(rc=sqlite3_vtab_in_first(pList, &pVal);
+** &nbsp; rc==SQLITE_OK && pVal
+** &nbsp; rc=sqlite3_vtab_in_next(pList, &pVal)
+** &nbsp; ){
+** &nbsp; // do something with pVal
+** &nbsp; }
+** &nbsp; if( rc!=SQLITE_OK ){
+** &nbsp; // an error has occurred
+** &nbsp; }
+** </pre></blockquote>)^
+**
+** ^On success, the sqlite3_vtab_in_first(X,P) and sqlite3_vtab_in_next(X,P)
+** routines return SQLITE_OK and set *P to point to the first or next value
+** on the RHS of the IN constraint. ^If there are no more values on the
+** right hand side of the IN constraint, then *P is set to NULL and these
+** routines return [SQLITE_DONE]. ^The return value might be
+** some other value, such as SQLITE_NOMEM, in the event of a malfunction.
+**
+** The *ppOut values returned by these routines are only valid until the
+** next call to either of these routines or until the end of the xFilter
+** method from which these routines were called. If the virtual table
+** implementation needs to retain the *ppOut values for longer, it must make
+** copies. The *ppOut values are [protected sqlite3_value|protected].
+*/
+SQLITE_API int sqlite3_vtab_in_first(sqlite3_value *pVal, sqlite3_value **ppOut);
+SQLITE_API int sqlite3_vtab_in_next(sqlite3_value *pVal, sqlite3_value **ppOut);
+
+/*
+** CAPI3REF: Constraint values in xBestIndex()
+** METHOD: sqlite3_index_info
+**
+** This API may only be used from within the [xBestIndex|xBestIndex method]
+** of a [virtual table] implementation. The result of calling this interface
+** from outside of an xBestIndex method are undefined and probably harmful.
+**
+** ^When the sqlite3_vtab_rhs_value(P,J,V) interface is invoked from within
+** the [xBestIndex] method of a [virtual table] implementation, with P being
+** a copy of the [sqlite3_index_info] object pointer passed into xBestIndex and
+** J being a 0-based index into P->aConstraint[], then this routine
+** attempts to set *V to the value of the right-hand operand of
+** that constraint if the right-hand operand is known. ^If the
+** right-hand operand is not known, then *V is set to a NULL pointer.
+** ^The sqlite3_vtab_rhs_value(P,J,V) interface returns SQLITE_OK if
+** and only if *V is set to a value. ^The sqlite3_vtab_rhs_value(P,J,V)
+** inteface returns SQLITE_NOTFOUND if the right-hand side of the J-th
+** constraint is not available. ^The sqlite3_vtab_rhs_value() interface
+** can return an result code other than SQLITE_OK or SQLITE_NOTFOUND if
+** something goes wrong.
+**
+** The sqlite3_vtab_rhs_value() interface is usually only successful if
+** the right-hand operand of a constraint is a literal value in the original
+** SQL statement. If the right-hand operand is an expression or a reference
+** to some other column or a [host parameter], then sqlite3_vtab_rhs_value()
+** will probably return [SQLITE_NOTFOUND].
+**
+** ^(Some constraints, such as [SQLITE_INDEX_CONSTRAINT_ISNULL] and
+** [SQLITE_INDEX_CONSTRAINT_ISNOTNULL], have no right-hand operand. For such
+** constraints, sqlite3_vtab_rhs_value() always returns SQLITE_NOTFOUND.)^
+**
+** ^The [sqlite3_value] object returned in *V is a protected sqlite3_value
+** and remains valid for the duration of the xBestIndex method call.
+** ^When xBestIndex returns, the sqlite3_value object returned by
+** sqlite3_vtab_rhs_value() is automatically deallocated.
+**
+** The "_rhs_" in the name of this routine is an abbreviation for
+** "Right-Hand Side".
+*/
+SQLITE_API int sqlite3_vtab_rhs_value(sqlite3_index_info*, int, sqlite3_value **ppVal);
+
+/*
** CAPI3REF: Conflict resolution modes
** KEYWORDS: {conflict resolution mode}
**
@@ -13621,78 +13935,79 @@ SQLITE_PRIVATE void sqlite3HashClear(Hash*);
#define TK_SLASH 109
#define TK_REM 110
#define TK_CONCAT 111
-#define TK_COLLATE 112
-#define TK_BITNOT 113
-#define TK_ON 114
-#define TK_INDEXED 115
-#define TK_STRING 116
-#define TK_JOIN_KW 117
-#define TK_CONSTRAINT 118
-#define TK_DEFAULT 119
-#define TK_NULL 120
-#define TK_PRIMARY 121
-#define TK_UNIQUE 122
-#define TK_CHECK 123
-#define TK_REFERENCES 124
-#define TK_AUTOINCR 125
-#define TK_INSERT 126
-#define TK_DELETE 127
-#define TK_UPDATE 128
-#define TK_SET 129
-#define TK_DEFERRABLE 130
-#define TK_FOREIGN 131
-#define TK_DROP 132
-#define TK_UNION 133
-#define TK_ALL 134
-#define TK_EXCEPT 135
-#define TK_INTERSECT 136
-#define TK_SELECT 137
-#define TK_VALUES 138
-#define TK_DISTINCT 139
-#define TK_DOT 140
-#define TK_FROM 141
-#define TK_JOIN 142
-#define TK_USING 143
-#define TK_ORDER 144
-#define TK_GROUP 145
-#define TK_HAVING 146
-#define TK_LIMIT 147
-#define TK_WHERE 148
-#define TK_RETURNING 149
-#define TK_INTO 150
-#define TK_NOTHING 151
-#define TK_FLOAT 152
-#define TK_BLOB 153
-#define TK_INTEGER 154
-#define TK_VARIABLE 155
-#define TK_CASE 156
-#define TK_WHEN 157
-#define TK_THEN 158
-#define TK_ELSE 159
-#define TK_INDEX 160
-#define TK_ALTER 161
-#define TK_ADD 162
-#define TK_WINDOW 163
-#define TK_OVER 164
-#define TK_FILTER 165
-#define TK_COLUMN 166
-#define TK_AGG_FUNCTION 167
-#define TK_AGG_COLUMN 168
-#define TK_TRUEFALSE 169
-#define TK_ISNOT 170
-#define TK_FUNCTION 171
-#define TK_UMINUS 172
-#define TK_UPLUS 173
-#define TK_TRUTH 174
-#define TK_REGISTER 175
-#define TK_VECTOR 176
-#define TK_SELECT_COLUMN 177
-#define TK_IF_NULL_ROW 178
-#define TK_ASTERISK 179
-#define TK_SPAN 180
-#define TK_ERROR 181
-#define TK_SPACE 182
-#define TK_ILLEGAL 183
+#define TK_PTR 112
+#define TK_COLLATE 113
+#define TK_BITNOT 114
+#define TK_ON 115
+#define TK_INDEXED 116
+#define TK_STRING 117
+#define TK_JOIN_KW 118
+#define TK_CONSTRAINT 119
+#define TK_DEFAULT 120
+#define TK_NULL 121
+#define TK_PRIMARY 122
+#define TK_UNIQUE 123
+#define TK_CHECK 124
+#define TK_REFERENCES 125
+#define TK_AUTOINCR 126
+#define TK_INSERT 127
+#define TK_DELETE 128
+#define TK_UPDATE 129
+#define TK_SET 130
+#define TK_DEFERRABLE 131
+#define TK_FOREIGN 132
+#define TK_DROP 133
+#define TK_UNION 134
+#define TK_ALL 135
+#define TK_EXCEPT 136
+#define TK_INTERSECT 137
+#define TK_SELECT 138
+#define TK_VALUES 139
+#define TK_DISTINCT 140
+#define TK_DOT 141
+#define TK_FROM 142
+#define TK_JOIN 143
+#define TK_USING 144
+#define TK_ORDER 145
+#define TK_GROUP 146
+#define TK_HAVING 147
+#define TK_LIMIT 148
+#define TK_WHERE 149
+#define TK_RETURNING 150
+#define TK_INTO 151
+#define TK_NOTHING 152
+#define TK_FLOAT 153
+#define TK_BLOB 154
+#define TK_INTEGER 155
+#define TK_VARIABLE 156
+#define TK_CASE 157
+#define TK_WHEN 158
+#define TK_THEN 159
+#define TK_ELSE 160
+#define TK_INDEX 161
+#define TK_ALTER 162
+#define TK_ADD 163
+#define TK_WINDOW 164
+#define TK_OVER 165
+#define TK_FILTER 166
+#define TK_COLUMN 167
+#define TK_AGG_FUNCTION 168
+#define TK_AGG_COLUMN 169
+#define TK_TRUEFALSE 170
+#define TK_ISNOT 171
+#define TK_FUNCTION 172
+#define TK_UMINUS 173
+#define TK_UPLUS 174
+#define TK_TRUTH 175
+#define TK_REGISTER 176
+#define TK_VECTOR 177
+#define TK_SELECT_COLUMN 178
+#define TK_IF_NULL_ROW 179
+#define TK_ASTERISK 180
+#define TK_SPAN 181
+#define TK_ERROR 182
+#define TK_SPACE 183
+#define TK_ILLEGAL 184
/************** End of parse.h ***********************************************/
/************** Continuing where we left off in sqliteInt.h ******************/
@@ -14334,10 +14649,11 @@ typedef struct With With;
/*
** A bit in a Bitmask
*/
-#define MASKBIT(n) (((Bitmask)1)<<(n))
-#define MASKBIT64(n) (((u64)1)<<(n))
-#define MASKBIT32(n) (((unsigned int)1)<<(n))
-#define ALLBITS ((Bitmask)-1)
+#define MASKBIT(n) (((Bitmask)1)<<(n))
+#define MASKBIT64(n) (((u64)1)<<(n))
+#define MASKBIT32(n) (((unsigned int)1)<<(n))
+#define SMASKBIT32(n) ((n)<=31?((unsigned int)1)<<(n):0)
+#define ALLBITS ((Bitmask)-1)
/* A VList object records a mapping between parameters/variables/wildcards
** in the SQL statement (such as $abc, @pqr, or :xyz) and the integer
@@ -15253,45 +15569,45 @@ typedef struct VdbeOpList VdbeOpList;
#define OP_DecrJumpZero 60 /* jump, synopsis: if (--r[P1])==0 goto P2 */
#define OP_IncrVacuum 61 /* jump */
#define OP_VNext 62 /* jump */
-#define OP_Init 63 /* jump, synopsis: Start at P2 */
-#define OP_PureFunc 64 /* synopsis: r[P3]=func(r[P2@NP]) */
-#define OP_Function 65 /* synopsis: r[P3]=func(r[P2@NP]) */
-#define OP_Return 66
-#define OP_EndCoroutine 67
-#define OP_HaltIfNull 68 /* synopsis: if r[P3]=null halt */
-#define OP_Halt 69
-#define OP_Integer 70 /* synopsis: r[P2]=P1 */
-#define OP_Int64 71 /* synopsis: r[P2]=P4 */
-#define OP_String 72 /* synopsis: r[P2]='P4' (len=P1) */
-#define OP_Null 73 /* synopsis: r[P2..P3]=NULL */
-#define OP_SoftNull 74 /* synopsis: r[P1]=NULL */
-#define OP_Blob 75 /* synopsis: r[P2]=P4 (len=P1) */
-#define OP_Variable 76 /* synopsis: r[P2]=parameter(P1,P4) */
-#define OP_Move 77 /* synopsis: r[P2@P3]=r[P1@P3] */
-#define OP_Copy 78 /* synopsis: r[P2@P3+1]=r[P1@P3+1] */
-#define OP_SCopy 79 /* synopsis: r[P2]=r[P1] */
-#define OP_IntCopy 80 /* synopsis: r[P2]=r[P1] */
-#define OP_ChngCntRow 81 /* synopsis: output=r[P1] */
-#define OP_ResultRow 82 /* synopsis: output=r[P1@P2] */
-#define OP_CollSeq 83
-#define OP_AddImm 84 /* synopsis: r[P1]=r[P1]+P2 */
-#define OP_RealAffinity 85
-#define OP_Cast 86 /* synopsis: affinity(r[P1]) */
-#define OP_Permutation 87
-#define OP_Compare 88 /* synopsis: r[P1@P3] <-> r[P2@P3] */
-#define OP_IsTrue 89 /* synopsis: r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4 */
-#define OP_ZeroOrNull 90 /* synopsis: r[P2] = 0 OR NULL */
-#define OP_Offset 91 /* synopsis: r[P3] = sqlite_offset(P1) */
-#define OP_Column 92 /* synopsis: r[P3]=PX */
-#define OP_TypeCheck 93 /* synopsis: typecheck(r[P1@P2]) */
-#define OP_Affinity 94 /* synopsis: affinity(r[P1@P2]) */
-#define OP_MakeRecord 95 /* synopsis: r[P3]=mkrec(r[P1@P2]) */
-#define OP_Count 96 /* synopsis: r[P2]=count() */
-#define OP_ReadCookie 97
-#define OP_SetCookie 98
-#define OP_ReopenIdx 99 /* synopsis: root=P2 iDb=P3 */
-#define OP_OpenRead 100 /* synopsis: root=P2 iDb=P3 */
-#define OP_OpenWrite 101 /* synopsis: root=P2 iDb=P3 */
+#define OP_Filter 63 /* jump, synopsis: if key(P3@P4) not in filter(P1) goto P2 */
+#define OP_Init 64 /* jump, synopsis: Start at P2 */
+#define OP_PureFunc 65 /* synopsis: r[P3]=func(r[P2@NP]) */
+#define OP_Function 66 /* synopsis: r[P3]=func(r[P2@NP]) */
+#define OP_Return 67
+#define OP_EndCoroutine 68
+#define OP_HaltIfNull 69 /* synopsis: if r[P3]=null halt */
+#define OP_Halt 70
+#define OP_Integer 71 /* synopsis: r[P2]=P1 */
+#define OP_Int64 72 /* synopsis: r[P2]=P4 */
+#define OP_String 73 /* synopsis: r[P2]='P4' (len=P1) */
+#define OP_Null 74 /* synopsis: r[P2..P3]=NULL */
+#define OP_SoftNull 75 /* synopsis: r[P1]=NULL */
+#define OP_Blob 76 /* synopsis: r[P2]=P4 (len=P1) */
+#define OP_Variable 77 /* synopsis: r[P2]=parameter(P1,P4) */
+#define OP_Move 78 /* synopsis: r[P2@P3]=r[P1@P3] */
+#define OP_Copy 79 /* synopsis: r[P2@P3+1]=r[P1@P3+1] */
+#define OP_SCopy 80 /* synopsis: r[P2]=r[P1] */
+#define OP_IntCopy 81 /* synopsis: r[P2]=r[P1] */
+#define OP_FkCheck 82
+#define OP_ResultRow 83 /* synopsis: output=r[P1@P2] */
+#define OP_CollSeq 84
+#define OP_AddImm 85 /* synopsis: r[P1]=r[P1]+P2 */
+#define OP_RealAffinity 86
+#define OP_Cast 87 /* synopsis: affinity(r[P1]) */
+#define OP_Permutation 88
+#define OP_Compare 89 /* synopsis: r[P1@P3] <-> r[P2@P3] */
+#define OP_IsTrue 90 /* synopsis: r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4 */
+#define OP_ZeroOrNull 91 /* synopsis: r[P2] = 0 OR NULL */
+#define OP_Offset 92 /* synopsis: r[P3] = sqlite_offset(P1) */
+#define OP_Column 93 /* synopsis: r[P3]=PX */
+#define OP_TypeCheck 94 /* synopsis: typecheck(r[P1@P2]) */
+#define OP_Affinity 95 /* synopsis: affinity(r[P1@P2]) */
+#define OP_MakeRecord 96 /* synopsis: r[P3]=mkrec(r[P1@P2]) */
+#define OP_Count 97 /* synopsis: r[P2]=count() */
+#define OP_ReadCookie 98
+#define OP_SetCookie 99
+#define OP_ReopenIdx 100 /* synopsis: root=P2 iDb=P3 */
+#define OP_OpenRead 101 /* synopsis: root=P2 iDb=P3 */
#define OP_BitAnd 102 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */
#define OP_BitOr 103 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */
#define OP_ShiftLeft 104 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */
@@ -15302,76 +15618,79 @@ typedef struct VdbeOpList VdbeOpList;
#define OP_Divide 109 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */
#define OP_Remainder 110 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */
#define OP_Concat 111 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */
-#define OP_OpenDup 112
-#define OP_BitNot 113 /* same as TK_BITNOT, synopsis: r[P2]= ~r[P1] */
-#define OP_OpenAutoindex 114 /* synopsis: nColumn=P2 */
-#define OP_OpenEphemeral 115 /* synopsis: nColumn=P2 */
-#define OP_String8 116 /* same as TK_STRING, synopsis: r[P2]='P4' */
-#define OP_SorterOpen 117
-#define OP_SequenceTest 118 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */
-#define OP_OpenPseudo 119 /* synopsis: P3 columns in r[P2] */
-#define OP_Close 120
-#define OP_ColumnsUsed 121
-#define OP_SeekScan 122 /* synopsis: Scan-ahead up to P1 rows */
-#define OP_SeekHit 123 /* synopsis: set P2<=seekHit<=P3 */
-#define OP_Sequence 124 /* synopsis: r[P2]=cursor[P1].ctr++ */
-#define OP_NewRowid 125 /* synopsis: r[P2]=rowid */
-#define OP_Insert 126 /* synopsis: intkey=r[P3] data=r[P2] */
-#define OP_RowCell 127
-#define OP_Delete 128
-#define OP_ResetCount 129
-#define OP_SorterCompare 130 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */
-#define OP_SorterData 131 /* synopsis: r[P2]=data */
-#define OP_RowData 132 /* synopsis: r[P2]=data */
-#define OP_Rowid 133 /* synopsis: r[P2]=rowid */
-#define OP_NullRow 134
-#define OP_SeekEnd 135
-#define OP_IdxInsert 136 /* synopsis: key=r[P2] */
-#define OP_SorterInsert 137 /* synopsis: key=r[P2] */
-#define OP_IdxDelete 138 /* synopsis: key=r[P2@P3] */
-#define OP_DeferredSeek 139 /* synopsis: Move P3 to P1.rowid if needed */
-#define OP_IdxRowid 140 /* synopsis: r[P2]=rowid */
-#define OP_FinishSeek 141
-#define OP_Destroy 142
-#define OP_Clear 143
-#define OP_ResetSorter 144
-#define OP_CreateBtree 145 /* synopsis: r[P2]=root iDb=P1 flags=P3 */
-#define OP_SqlExec 146
-#define OP_ParseSchema 147
-#define OP_LoadAnalysis 148
-#define OP_DropTable 149
-#define OP_DropIndex 150
-#define OP_DropTrigger 151
-#define OP_Real 152 /* same as TK_FLOAT, synopsis: r[P2]=P4 */
-#define OP_IntegrityCk 153
-#define OP_RowSetAdd 154 /* synopsis: rowset(P1)=r[P2] */
-#define OP_Param 155
-#define OP_FkCounter 156 /* synopsis: fkctr[P1]+=P2 */
-#define OP_MemMax 157 /* synopsis: r[P1]=max(r[P1],r[P2]) */
-#define OP_OffsetLimit 158 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */
-#define OP_AggInverse 159 /* synopsis: accum=r[P3] inverse(r[P2@P5]) */
-#define OP_AggStep 160 /* synopsis: accum=r[P3] step(r[P2@P5]) */
-#define OP_AggStep1 161 /* synopsis: accum=r[P3] step(r[P2@P5]) */
-#define OP_AggValue 162 /* synopsis: r[P3]=value N=P2 */
-#define OP_AggFinal 163 /* synopsis: accum=r[P1] N=P2 */
-#define OP_Expire 164
-#define OP_CursorLock 165
-#define OP_CursorUnlock 166
-#define OP_TableLock 167 /* synopsis: iDb=P1 root=P2 write=P3 */
-#define OP_VBegin 168
-#define OP_VCreate 169
-#define OP_VDestroy 170
-#define OP_VOpen 171
-#define OP_VColumn 172 /* synopsis: r[P3]=vcolumn(P2) */
-#define OP_VRename 173
-#define OP_Pagecount 174
-#define OP_MaxPgcnt 175
-#define OP_Trace 176
-#define OP_CursorHint 177
-#define OP_ReleaseReg 178 /* synopsis: release r[P1@P2] mask P3 */
-#define OP_Noop 179
-#define OP_Explain 180
-#define OP_Abortable 181
+#define OP_OpenWrite 112 /* synopsis: root=P2 iDb=P3 */
+#define OP_OpenDup 113
+#define OP_BitNot 114 /* same as TK_BITNOT, synopsis: r[P2]= ~r[P1] */
+#define OP_OpenAutoindex 115 /* synopsis: nColumn=P2 */
+#define OP_OpenEphemeral 116 /* synopsis: nColumn=P2 */
+#define OP_String8 117 /* same as TK_STRING, synopsis: r[P2]='P4' */
+#define OP_SorterOpen 118
+#define OP_SequenceTest 119 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */
+#define OP_OpenPseudo 120 /* synopsis: P3 columns in r[P2] */
+#define OP_Close 121
+#define OP_ColumnsUsed 122
+#define OP_SeekScan 123 /* synopsis: Scan-ahead up to P1 rows */
+#define OP_SeekHit 124 /* synopsis: set P2<=seekHit<=P3 */
+#define OP_Sequence 125 /* synopsis: r[P2]=cursor[P1].ctr++ */
+#define OP_NewRowid 126 /* synopsis: r[P2]=rowid */
+#define OP_Insert 127 /* synopsis: intkey=r[P3] data=r[P2] */
+#define OP_RowCell 128
+#define OP_Delete 129
+#define OP_ResetCount 130
+#define OP_SorterCompare 131 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */
+#define OP_SorterData 132 /* synopsis: r[P2]=data */
+#define OP_RowData 133 /* synopsis: r[P2]=data */
+#define OP_Rowid 134 /* synopsis: r[P2]=rowid */
+#define OP_NullRow 135
+#define OP_SeekEnd 136
+#define OP_IdxInsert 137 /* synopsis: key=r[P2] */
+#define OP_SorterInsert 138 /* synopsis: key=r[P2] */
+#define OP_IdxDelete 139 /* synopsis: key=r[P2@P3] */
+#define OP_DeferredSeek 140 /* synopsis: Move P3 to P1.rowid if needed */
+#define OP_IdxRowid 141 /* synopsis: r[P2]=rowid */
+#define OP_FinishSeek 142
+#define OP_Destroy 143
+#define OP_Clear 144
+#define OP_ResetSorter 145
+#define OP_CreateBtree 146 /* synopsis: r[P2]=root iDb=P1 flags=P3 */
+#define OP_SqlExec 147
+#define OP_ParseSchema 148
+#define OP_LoadAnalysis 149
+#define OP_DropTable 150
+#define OP_DropIndex 151
+#define OP_DropTrigger 152
+#define OP_Real 153 /* same as TK_FLOAT, synopsis: r[P2]=P4 */
+#define OP_IntegrityCk 154
+#define OP_RowSetAdd 155 /* synopsis: rowset(P1)=r[P2] */
+#define OP_Param 156
+#define OP_FkCounter 157 /* synopsis: fkctr[P1]+=P2 */
+#define OP_MemMax 158 /* synopsis: r[P1]=max(r[P1],r[P2]) */
+#define OP_OffsetLimit 159 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */
+#define OP_AggInverse 160 /* synopsis: accum=r[P3] inverse(r[P2@P5]) */
+#define OP_AggStep 161 /* synopsis: accum=r[P3] step(r[P2@P5]) */
+#define OP_AggStep1 162 /* synopsis: accum=r[P3] step(r[P2@P5]) */
+#define OP_AggValue 163 /* synopsis: r[P3]=value N=P2 */
+#define OP_AggFinal 164 /* synopsis: accum=r[P1] N=P2 */
+#define OP_Expire 165
+#define OP_CursorLock 166
+#define OP_CursorUnlock 167
+#define OP_TableLock 168 /* synopsis: iDb=P1 root=P2 write=P3 */
+#define OP_VBegin 169
+#define OP_VCreate 170
+#define OP_VDestroy 171
+#define OP_VOpen 172
+#define OP_VInitIn 173 /* synopsis: r[P2]=ValueList(P1,P3) */
+#define OP_VColumn 174 /* synopsis: r[P3]=vcolumn(P2) */
+#define OP_VRename 175
+#define OP_Pagecount 176
+#define OP_MaxPgcnt 177
+#define OP_FilterAdd 178 /* synopsis: filter(P1) += key(P3@P4) */
+#define OP_Trace 179
+#define OP_CursorHint 180
+#define OP_ReleaseReg 181 /* synopsis: release r[P1@P2] mask P3 */
+#define OP_Noop 182
+#define OP_Explain 183
+#define OP_Abortable 184
/* Properties such as "out2" or "jump" that are specified in
** comments following the "case" for each opcode in the vdbe.c
@@ -15392,21 +15711,22 @@ typedef struct VdbeOpList VdbeOpList;
/* 40 */ 0x01, 0x01, 0x01, 0x26, 0x26, 0x23, 0x0b, 0x01,\
/* 48 */ 0x01, 0x03, 0x03, 0x03, 0x0b, 0x0b, 0x0b, 0x0b,\
/* 56 */ 0x0b, 0x0b, 0x01, 0x03, 0x03, 0x01, 0x01, 0x01,\
-/* 64 */ 0x00, 0x00, 0x02, 0x02, 0x08, 0x00, 0x10, 0x10,\
-/* 72 */ 0x10, 0x10, 0x00, 0x10, 0x10, 0x00, 0x00, 0x10,\
-/* 80 */ 0x10, 0x00, 0x00, 0x00, 0x02, 0x02, 0x02, 0x00,\
-/* 88 */ 0x00, 0x12, 0x1e, 0x20, 0x00, 0x00, 0x00, 0x00,\
-/* 96 */ 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x26, 0x26,\
+/* 64 */ 0x01, 0x00, 0x00, 0x02, 0x02, 0x08, 0x00, 0x10,\
+/* 72 */ 0x10, 0x10, 0x10, 0x00, 0x10, 0x10, 0x00, 0x00,\
+/* 80 */ 0x10, 0x10, 0x00, 0x00, 0x00, 0x02, 0x02, 0x02,\
+/* 88 */ 0x00, 0x00, 0x12, 0x1e, 0x20, 0x00, 0x00, 0x00,\
+/* 96 */ 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x26, 0x26,\
/* 104 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26,\
-/* 112 */ 0x00, 0x12, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,\
-/* 120 */ 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00,\
-/* 128 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,\
-/* 136 */ 0x04, 0x04, 0x00, 0x00, 0x10, 0x00, 0x10, 0x00,\
-/* 144 */ 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
-/* 152 */ 0x10, 0x00, 0x06, 0x10, 0x00, 0x04, 0x1a, 0x00,\
+/* 112 */ 0x00, 0x00, 0x12, 0x00, 0x00, 0x10, 0x00, 0x00,\
+/* 120 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00,\
+/* 128 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,\
+/* 136 */ 0x00, 0x04, 0x04, 0x00, 0x00, 0x10, 0x00, 0x10,\
+/* 144 */ 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,\
+/* 152 */ 0x00, 0x10, 0x00, 0x06, 0x10, 0x00, 0x04, 0x1a,\
/* 160 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
-/* 168 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10,\
-/* 176 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,}
+/* 168 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,\
+/* 176 */ 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
+/* 184 */ 0x00,}
/* The resolve3P2Values() routine is able to run faster if it knows
** the value of the largest JUMP opcode. The smaller the maximum
@@ -15414,7 +15734,7 @@ typedef struct VdbeOpList VdbeOpList;
** generated this include file strives to group all JUMP opcodes
** together near the beginning of the list.
*/
-#define SQLITE_MX_JUMP_OPCODE 63 /* Maximum JUMP opcode */
+#define SQLITE_MX_JUMP_OPCODE 64 /* Maximum JUMP opcode */
/************** End of opcodes.h *********************************************/
/************** Continuing where we left off in vdbe.h ***********************/
@@ -16475,6 +16795,7 @@ struct sqlite3 {
u32 nSchemaLock; /* Do not reset the schema when non-zero */
unsigned int openFlags; /* Flags passed to sqlite3_vfs.xOpen() */
int errCode; /* Most recent error code (SQLITE_*) */
+ int errByteOffset; /* Byte offset of error in SQL statement */
int errMask; /* & result codes with this before returning */
int iSysErrno; /* Errno value from last system error */
u32 dbOptFlags; /* Flags to enable/disable optimizations */
@@ -16709,6 +17030,9 @@ struct sqlite3 {
#define SQLITE_SeekScan 0x00020000 /* The OP_SeekScan optimization */
#define SQLITE_OmitOrderBy 0x00040000 /* Omit pointless ORDER BY */
/* TH3 expects this value ^^^^^^^^^^ to be 0x40000. Coordinate any change */
+#define SQLITE_BloomFilter 0x00080000 /* Use a Bloom filter on searches */
+#define SQLITE_BloomPulldown 0x00100000 /* Run Bloom filters early */
+#define SQLITE_BalancedMerge 0x00200000 /* Balance multi-way merges */
#define SQLITE_AllOpts 0xffffffff /* All optimizations */
/*
@@ -16882,7 +17206,7 @@ struct FuncDestructor {
** are interpreted in the same way as the first 4 parameters to
** FUNCTION().
**
-** WFUNCTION(zName, nArg, iArg, xStep, xFinal, xValue, xInverse)
+** WAGGREGATE(zName, nArg, iArg, xStep, xFinal, xValue, xInverse)
** Used to create an aggregate function definition implemented by
** the C functions xStep and xFinal. The first four parameters
** are interpreted in the same way as the first 4 parameters to
@@ -16909,6 +17233,10 @@ struct FuncDestructor {
#define MFUNCTION(zName, nArg, xPtr, xFunc) \
{nArg, SQLITE_FUNC_BUILTIN|SQLITE_FUNC_CONSTANT|SQLITE_UTF8, \
xPtr, 0, xFunc, 0, 0, 0, #zName, {0} }
+#define JFUNCTION(zName, nArg, iArg, xFunc) \
+ {nArg, SQLITE_FUNC_BUILTIN|SQLITE_DETERMINISTIC|SQLITE_INNOCUOUS|\
+ SQLITE_FUNC_CONSTANT|SQLITE_UTF8, \
+ SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, 0, #zName, {0} }
#define INLINE_FUNC(zName, nArg, iArg, mFlags) \
{nArg, SQLITE_FUNC_BUILTIN|\
SQLITE_UTF8|SQLITE_FUNC_INLINE|SQLITE_FUNC_CONSTANT|(mFlags), \
@@ -17763,7 +18091,10 @@ struct Expr {
** TK_VARIABLE: variable number (always >= 1).
** TK_SELECT_COLUMN: column of the result vector */
i16 iAgg; /* Which entry in pAggInfo->aCol[] or ->aFunc[] */
- int iRightJoinTable; /* If EP_FromJoin, the right table of the join */
+ union {
+ int iRightJoinTable; /* If EP_FromJoin, the right table of the join */
+ int iOfst; /* else: start of token from start of statement */
+ } w;
AggInfo *pAggInfo; /* Used by TK_AGG_COLUMN and TK_AGG_FUNCTION */
union {
Table *pTab; /* TK_COLUMN: Table containing column. Can be NULL
@@ -18503,6 +18834,8 @@ struct Parse {
AutoincInfo *pAinc; /* Information about AUTOINCREMENT counters */
Parse *pToplevel; /* Parse structure for main program (or NULL) */
Table *pTriggerTab; /* Table triggers are being coded for */
+ TriggerPrg *pTriggerPrg; /* Linked list of coded triggers */
+ ParseCleanup *pCleanup; /* List of cleanup operations to run after parse */
union {
int addrCrTab; /* Address of OP_CreateBtree on CREATE TABLE */
Returning *pReturning; /* The RETURNING clause */
@@ -18523,6 +18856,7 @@ struct Parse {
**************************************************************************/
int aTempReg[8]; /* Holding area for temporary registers */
+ Parse *pOuterParse; /* Outer Parse object when nested */
Token sNameToken; /* Token with unqualified schema object name */
/************************************************************************
@@ -18557,9 +18891,7 @@ struct Parse {
Token sArg; /* Complete text of a module argument */
Table **apVtabLock; /* Pointer to virtual tables needing locking */
#endif
- TriggerPrg *pTriggerPrg; /* Linked list of coded triggers */
With *pWith; /* Current WITH clause, or NULL */
- ParseCleanup *pCleanup; /* List of cleanup operations to run after parse */
#ifndef SQLITE_OMIT_ALTERTABLE
RenameToken *pRename; /* Tokens subject to renaming by ALTER TABLE */
#endif
@@ -18575,7 +18907,8 @@ struct Parse {
/*
** Sizes and pointers of various parts of the Parse object.
*/
-#define PARSE_HDR_SZ offsetof(Parse,aTempReg) /* Recursive part w/o aColCache*/
+#define PARSE_HDR(X) (((char*)(X))+offsetof(Parse,zErrMsg))
+#define PARSE_HDR_SZ (offsetof(Parse,aTempReg)-offsetof(Parse,zErrMsg)) /* Recursive part w/o aColCache*/
#define PARSE_RECURSE_SZ offsetof(Parse,sLastToken) /* Recursive part */
#define PARSE_TAIL_SZ (sizeof(Parse)-PARSE_RECURSE_SZ) /* Non-recursive part */
#define PARSE_TAIL(X) (((char*)(X))+PARSE_RECURSE_SZ) /* Pointer to tail */
@@ -18870,6 +19203,7 @@ struct Sqlite3Config {
int (*xTestCallback)(int); /* Invoked by sqlite3FaultSim() */
#endif
int bLocaltimeFault; /* True to fail localtime() calls */
+ int (*xAltLocaltime)(const void*,void*); /* Alternative localtime() routine */
int iOnceResetThreshold; /* When to reset OP_Once counters */
u32 szSorterRef; /* Min size in bytes to use sorter-refs */
unsigned int iPrngSeed; /* Alternative fixed seed for the PRNG */
@@ -19350,7 +19684,7 @@ SQLITE_PRIVATE void sqlite3DequoteExpr(Expr*);
SQLITE_PRIVATE void sqlite3DequoteToken(Token*);
SQLITE_PRIVATE void sqlite3TokenInit(Token*,char*);
SQLITE_PRIVATE int sqlite3KeywordCode(const unsigned char*, int);
-SQLITE_PRIVATE int sqlite3RunParser(Parse*, const char*, char **);
+SQLITE_PRIVATE int sqlite3RunParser(Parse*, const char*);
SQLITE_PRIVATE void sqlite3FinishCoding(Parse*);
SQLITE_PRIVATE int sqlite3GetTempReg(Parse*);
SQLITE_PRIVATE void sqlite3ReleaseTempReg(Parse*,int);
@@ -19511,10 +19845,12 @@ SQLITE_PRIVATE void sqlite3OpenTable(Parse*, int iCur, int iDb, Table*, int);
#if defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT) && !defined(SQLITE_OMIT_SUBQUERY)
SQLITE_PRIVATE Expr *sqlite3LimitWhere(Parse*,SrcList*,Expr*,ExprList*,Expr*,char*);
#endif
+SQLITE_PRIVATE void sqlite3CodeChangeCount(Vdbe*,int,const char*);
SQLITE_PRIVATE void sqlite3DeleteFrom(Parse*, SrcList*, Expr*, ExprList*, Expr*);
SQLITE_PRIVATE void sqlite3Update(Parse*, SrcList*, ExprList*,Expr*,int,ExprList*,Expr*,
Upsert*);
-SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(Parse*,SrcList*,Expr*,ExprList*,ExprList*,u16,int);
+SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(Parse*,SrcList*,Expr*,ExprList*,
+ ExprList*,Select*,u16,int);
SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo*);
SQLITE_PRIVATE LogEst sqlite3WhereOutputRowCount(WhereInfo*);
SQLITE_PRIVATE int sqlite3WhereIsDistinct(WhereInfo*);
@@ -19629,9 +19965,14 @@ SQLITE_PRIVATE Select *sqlite3SelectDup(sqlite3*,const Select*,int);
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 sqlite3QuoteValue(StrAccum*,sqlite3_value*);
SQLITE_PRIVATE void sqlite3RegisterBuiltinFunctions(void);
SQLITE_PRIVATE void sqlite3RegisterDateTimeFunctions(void);
+SQLITE_PRIVATE void sqlite3RegisterJsonFunctions(void);
SQLITE_PRIVATE void sqlite3RegisterPerConnectionBuiltinFunctions(sqlite3*);
+#if !defined(SQLITE_OMIT_VIRTUALTABLE) && !defined(SQLITE_OMIT_JSON)
+SQLITE_PRIVATE int sqlite3JsonTableFunctions(sqlite3*);
+#endif
SQLITE_PRIVATE int sqlite3SafetyCheckOk(sqlite3*);
SQLITE_PRIVATE int sqlite3SafetyCheckSickOrOk(sqlite3*);
SQLITE_PRIVATE void sqlite3ChangeCookie(Parse*, int);
@@ -19721,14 +20062,8 @@ SQLITE_PRIVATE int sqlite3Utf8CharLen(const char *pData, int nByte);
SQLITE_PRIVATE u32 sqlite3Utf8Read(const u8**);
SQLITE_PRIVATE LogEst sqlite3LogEst(u64);
SQLITE_PRIVATE LogEst sqlite3LogEstAdd(LogEst,LogEst);
-#ifndef SQLITE_OMIT_VIRTUALTABLE
SQLITE_PRIVATE LogEst sqlite3LogEstFromDouble(double);
-#endif
-#if defined(SQLITE_ENABLE_STMT_SCANSTATUS) || \
- defined(SQLITE_ENABLE_STAT4) || \
- defined(SQLITE_EXPLAIN_ESTIMATED_ROWS)
SQLITE_PRIVATE u64 sqlite3LogEstToInt(LogEst);
-#endif
SQLITE_PRIVATE VList *sqlite3VListAdd(sqlite3*,VList*,const char*,int,int);
SQLITE_PRIVATE const char *sqlite3VListNumToName(VList*,int);
SQLITE_PRIVATE int sqlite3VListNameToNum(VList*,const char*,int);
@@ -19915,17 +20250,20 @@ SQLITE_PRIVATE int sqlite3CreateFunc(sqlite3 *, const char *, int, int, void *,
FuncDestructor *pDestructor
);
SQLITE_PRIVATE void sqlite3NoopDestructor(void*);
-SQLITE_PRIVATE void sqlite3OomFault(sqlite3*);
+SQLITE_PRIVATE void *sqlite3OomFault(sqlite3*);
SQLITE_PRIVATE void sqlite3OomClear(sqlite3*);
SQLITE_PRIVATE int sqlite3ApiExit(sqlite3 *db, int);
SQLITE_PRIVATE int sqlite3OpenTempDatabase(Parse *);
SQLITE_PRIVATE void sqlite3StrAccumInit(StrAccum*, sqlite3*, char*, int, int);
+SQLITE_PRIVATE int sqlite3StrAccumEnlarge(StrAccum*, int);
SQLITE_PRIVATE char *sqlite3StrAccumFinish(StrAccum*);
SQLITE_PRIVATE void sqlite3StrAccumSetError(StrAccum*, u8);
SQLITE_PRIVATE void sqlite3ResultStrAccum(sqlite3_context*,StrAccum*);
SQLITE_PRIVATE void sqlite3SelectDestInit(SelectDest*,int,int);
SQLITE_PRIVATE Expr *sqlite3CreateColumnExpr(sqlite3 *, SrcList *, int, int);
+SQLITE_PRIVATE void sqlite3RecordErrorByteOffset(sqlite3*,const char*);
+SQLITE_PRIVATE void sqlite3RecordErrorOffsetOfExpr(sqlite3*,const Expr*);
SQLITE_PRIVATE void sqlite3BackupRestart(sqlite3_backup *);
SQLITE_PRIVATE void sqlite3BackupUpdate(sqlite3_backup *, Pgno, const u8 *);
@@ -20030,11 +20368,17 @@ SQLITE_PRIVATE int sqlite3VtabCallCreate(sqlite3*, int, const char *, char **);
SQLITE_PRIVATE int sqlite3VtabCallConnect(Parse*, Table*);
SQLITE_PRIVATE int sqlite3VtabCallDestroy(sqlite3*, int, const char *);
SQLITE_PRIVATE int sqlite3VtabBegin(sqlite3 *, VTable *);
+
SQLITE_PRIVATE FuncDef *sqlite3VtabOverloadFunction(sqlite3 *,FuncDef*, int nArg, Expr*);
+#if (defined(SQLITE_ENABLE_DBPAGE_VTAB) || defined(SQLITE_TEST)) \
+ && !defined(SQLITE_OMIT_VIRTUALTABLE)
+SQLITE_PRIVATE void sqlite3VtabWriteAll(sqlite3_index_info*);
+#endif
SQLITE_PRIVATE sqlite3_int64 sqlite3StmtCurrentTime(sqlite3_context*);
SQLITE_PRIVATE int sqlite3VdbeParameterIndex(Vdbe*, const char*, int);
SQLITE_PRIVATE int sqlite3TransferBindings(sqlite3_stmt *, sqlite3_stmt *);
-SQLITE_PRIVATE void sqlite3ParserReset(Parse*);
+SQLITE_PRIVATE void sqlite3ParseObjectInit(Parse*,sqlite3*);
+SQLITE_PRIVATE void sqlite3ParseObjectReset(Parse*);
SQLITE_PRIVATE void *sqlite3ParserAddCleanup(Parse*,void(*)(sqlite3*,void*),void*);
#ifdef SQLITE_ENABLE_NORMALIZE
SQLITE_PRIVATE char *sqlite3Normalize(Vdbe*, const char*);
@@ -20093,6 +20437,7 @@ SQLITE_PRIVATE void sqlite3FkActions(Parse*, Table*, ExprList*, int, int*, int
SQLITE_PRIVATE int sqlite3FkRequired(Parse*, Table*, int*, int);
SQLITE_PRIVATE u32 sqlite3FkOldmask(Parse*, Table*);
SQLITE_PRIVATE FKey *sqlite3FkReferences(Table *);
+SQLITE_PRIVATE void sqlite3FkClearTriggerCache(sqlite3*,int);
#else
#define sqlite3FkActions(a,b,c,d,e,f)
#define sqlite3FkCheck(a,b,c,d,e,f)
@@ -20100,6 +20445,7 @@ SQLITE_PRIVATE FKey *sqlite3FkReferences(Table *);
#define sqlite3FkOldmask(a,b) 0
#define sqlite3FkRequired(a,b,c,d) 0
#define sqlite3FkReferences(a) 0
+ #define sqlite3FkClearTriggerCache(a,b)
#endif
#ifndef SQLITE_OMIT_FOREIGN_KEY
SQLITE_PRIVATE void sqlite3FkDelete(sqlite3 *, Table*);
@@ -20465,6 +20811,14 @@ SQLITE_API extern int sqlite3_open_file_count;
/************** End of os_common.h *******************************************/
/************** Begin file ctime.c *******************************************/
+/* DO NOT EDIT!
+** This file is automatically generated by the script in the canonical
+** SQLite source tree at tool/mkctimec.tcl.
+**
+** To modify this header, edit any of the various lists in that script
+** which specify categories of generated conditionals in this file.
+*/
+
/*
** 2010 February 23
**
@@ -20513,9 +20867,6 @@ SQLITE_API extern int sqlite3_open_file_count;
*/
static const char * const sqlite3azCompileOpt[] = {
-/*
-** BEGIN CODE GENERATED BY tool/mkctime.tcl
-*/
#ifdef SQLITE_32BIT_ROWID
"32BIT_ROWID",
#endif
@@ -20724,9 +21075,6 @@ static const char * const sqlite3azCompileOpt[] = {
#ifdef SQLITE_ENABLE_IOTRACE
"ENABLE_IOTRACE",
#endif
-#ifdef SQLITE_ENABLE_JSON1
- "ENABLE_JSON1",
-#endif
#ifdef SQLITE_ENABLE_LOAD_EXTENSION
"ENABLE_LOAD_EXTENSION",
#endif
@@ -21050,6 +21398,9 @@ static const char * const sqlite3azCompileOpt[] = {
#ifdef SQLITE_OMIT_INTROSPECTION_PRAGMAS
"OMIT_INTROSPECTION_PRAGMAS",
#endif
+#ifdef SQLITE_OMIT_JSON
+ "OMIT_JSON",
+#endif
#ifdef SQLITE_OMIT_LIKE_OPTIMIZATION
"OMIT_LIKE_OPTIMIZATION",
#endif
@@ -21238,10 +21589,8 @@ static const char * const sqlite3azCompileOpt[] = {
#ifdef SQLITE_ZERO_MALLOC
"ZERO_MALLOC",
#endif
-/*
-** END CODE GENERATED BY tool/mkctime.tcl
-*/
-};
+
+} ;
SQLITE_PRIVATE const char **sqlite3CompileOptions(int *pnOpt){
*pnOpt = sizeof(sqlite3azCompileOpt) / sizeof(sqlite3azCompileOpt[0]);
@@ -21540,6 +21889,7 @@ SQLITE_PRIVATE SQLITE_WSD struct Sqlite3Config sqlite3Config = {
0, /* xTestCallback */
#endif
0, /* bLocaltimeFault */
+ 0, /* xAltLocaltime */
0x7ffffffe, /* iOnceResetThreshold */
SQLITE_DEFAULT_SORTERREF_SIZE, /* szSorterRef */
0, /* iPrngSeed */
@@ -21753,7 +22103,7 @@ typedef struct AuxData AuxData;
typedef struct VdbeCursor VdbeCursor;
struct VdbeCursor {
u8 eCurType; /* One of the CURTYPE_* values above */
- i8 iDb; /* Index of cursor database in db->aDb[] (or -1) */
+ i8 iDb; /* Index of cursor database in db->aDb[] */
u8 nullRow; /* True if pointing to a row with no data */
u8 deferredMoveto; /* A call to sqlite3BtreeMoveto() is needed */
u8 isTable; /* True for rowid tables. False for indexes */
@@ -21766,9 +22116,11 @@ struct VdbeCursor {
Bool isOrdered:1; /* True if the table is not BTREE_UNORDERED */
Bool hasBeenDuped:1; /* This cursor was source or target of OP_OpenDup */
u16 seekHit; /* See the OP_SeekHit and OP_IfNoHope opcodes */
- Btree *pBtx; /* Separate file holding temporary table */
+ union { /* pBtx for isEphermeral. pAltMap otherwise */
+ Btree *pBtx; /* Separate file holding temporary table */
+ u32 *aAltMap; /* Mapping from table to index column numbers */
+ } ub;
i64 seqCount; /* Sequence counter */
- u32 *aAltMap; /* Mapping from table to index column numbers */
/* Cached OP_Column parse information is only valid if cacheStatus matches
** Vdbe.cacheCtr. Vdbe.cacheCtr will never take on the value of
@@ -22108,7 +22460,7 @@ struct Vdbe {
bft bIsReader:1; /* True for statements that read */
yDbMask btreeMask; /* Bitmask of db->aDb[] entries referenced */
yDbMask lockMask; /* Subset of btreeMask that requires a lock */
- u32 aCounter[7]; /* Counters used by sqlite3_stmt_status() */
+ u32 aCounter[9]; /* Counters used by sqlite3_stmt_status() */
char *zSql; /* Text of the SQL statement that generated this */
#ifdef SQLITE_ENABLE_NORMALIZE
char *zNormSql; /* Normalization of the associated SQL statement */
@@ -22159,6 +22511,24 @@ struct PreUpdate {
};
/*
+** An instance of this object is used to pass an vector of values into
+** OP_VFilter, the xFilter method of a virtual table. The vector is the
+** set of values on the right-hand side of an IN constraint.
+**
+** The value as passed into xFilter is an sqlite3_value with a "pointer"
+** type, such as is generated by sqlite3_result_pointer() and read by
+** sqlite3_value_pointer. Such values have MEM_Term|MEM_Subtype|MEM_Null
+** and a subtype of 'p'. The sqlite3_vtab_in_first() and _next() interfaces
+** know how to use this object to step through all the values in the
+** right operand of the IN constraint.
+*/
+typedef struct ValueList ValueList;
+struct ValueList {
+ BtCursor *pCsr; /* An ephemeral table holding all values */
+ sqlite3_value *pOut; /* Register to hold each decoded output value */
+};
+
+/*
** Function prototypes
*/
SQLITE_PRIVATE void sqlite3VdbeError(Vdbe*, const char *, ...);
@@ -22170,7 +22540,7 @@ SQLITE_PRIVATE int sqlite3VdbeCursorRestore(VdbeCursor*);
SQLITE_PRIVATE u32 sqlite3VdbeSerialTypeLen(u32);
SQLITE_PRIVATE u8 sqlite3VdbeOneByteSerialTypeLen(u8);
SQLITE_PRIVATE u32 sqlite3VdbeSerialPut(unsigned char*, Mem*, u32);
-SQLITE_PRIVATE u32 sqlite3VdbeSerialGet(const unsigned char*, u32, Mem*);
+SQLITE_PRIVATE void sqlite3VdbeSerialGet(const unsigned char*, u32, Mem*);
SQLITE_PRIVATE void sqlite3VdbeDeleteAuxData(sqlite3*, AuxData**, int, int);
int sqlite2BtreeKeyCompare(BtCursor *, const void *, int, int, int *);
@@ -22216,7 +22586,7 @@ SQLITE_PRIVATE int sqlite3VdbeMemSetRowSet(Mem*);
SQLITE_PRIVATE int sqlite3VdbeMemMakeWriteable(Mem*);
SQLITE_PRIVATE int sqlite3VdbeMemStringify(Mem*, u8, u8);
SQLITE_PRIVATE int sqlite3IntFloatCompare(i64,double);
-SQLITE_PRIVATE i64 sqlite3VdbeIntValue(Mem*);
+SQLITE_PRIVATE i64 sqlite3VdbeIntValue(const Mem*);
SQLITE_PRIVATE int sqlite3VdbeMemIntegerify(Mem*);
SQLITE_PRIVATE double sqlite3VdbeRealValue(Mem*);
SQLITE_PRIVATE int sqlite3VdbeBooleanValue(Mem*, int ifNull);
@@ -23194,8 +23564,10 @@ static void clearYMD_HMS_TZ(DateTime *p){
** is available. This routine returns 0 on success and
** non-zero on any kind of error.
**
-** If the sqlite3GlobalConfig.bLocaltimeFault variable is true then this
-** routine will always fail.
+** If the sqlite3GlobalConfig.bLocaltimeFault variable is non-zero then this
+** routine will always fail. If bLocaltimeFault is nonzero and
+** sqlite3GlobalConfig.xAltLocaltime is not NULL, then xAltLocaltime() is
+** invoked in place of the OS-defined localtime() function.
**
** EVIDENCE-OF: R-62172-00036 In this implementation, the standard C
** library function localtime_r() is used to assist in the calculation of
@@ -23211,14 +23583,30 @@ static int osLocaltime(time_t *t, struct tm *pTm){
sqlite3_mutex_enter(mutex);
pX = localtime(t);
#ifndef SQLITE_UNTESTABLE
- if( sqlite3GlobalConfig.bLocaltimeFault ) pX = 0;
+ if( sqlite3GlobalConfig.bLocaltimeFault ){
+ if( sqlite3GlobalConfig.xAltLocaltime!=0
+ && 0==sqlite3GlobalConfig.xAltLocaltime((const void*)t,(void*)pTm)
+ ){
+ pX = pTm;
+ }else{
+ pX = 0;
+ }
+ }
#endif
if( pX ) *pTm = *pX;
+#if SQLITE_THREADSAFE>0
sqlite3_mutex_leave(mutex);
+#endif
rc = pX==0;
#else
#ifndef SQLITE_UNTESTABLE
- if( sqlite3GlobalConfig.bLocaltimeFault ) return 1;
+ if( sqlite3GlobalConfig.bLocaltimeFault ){
+ if( sqlite3GlobalConfig.xAltLocaltime!=0 ){
+ return sqlite3GlobalConfig.xAltLocaltime((const void*)t,(void*)pTm);
+ }else{
+ return 1;
+ }
+ }
#endif
#if HAVE_LOCALTIME_R
rc = localtime_r(t, pTm)==0;
@@ -23233,67 +23621,56 @@ static int osLocaltime(time_t *t, struct tm *pTm){
#ifndef SQLITE_OMIT_LOCALTIME
/*
-** Compute the difference (in milliseconds) between localtime and UTC
-** (a.k.a. GMT) for the time value p where p is in UTC. If no error occurs,
-** return this value and set *pRc to SQLITE_OK.
-**
-** Or, if an error does occur, set *pRc to SQLITE_ERROR. The returned value
-** is undefined in this case.
+** Assuming the input DateTime is UTC, move it to its localtime equivalent.
*/
-static sqlite3_int64 localtimeOffset(
- DateTime *p, /* Date at which to calculate offset */
- sqlite3_context *pCtx, /* Write error here if one occurs */
- int *pRc /* OUT: Error code. SQLITE_OK or ERROR */
+static int toLocaltime(
+ DateTime *p, /* Date at which to calculate offset */
+ sqlite3_context *pCtx /* Write error here if one occurs */
){
- DateTime x, y;
time_t t;
struct tm sLocal;
+ int iYearDiff;
/* Initialize the contents of sLocal to avoid a compiler warning. */
memset(&sLocal, 0, sizeof(sLocal));
- x = *p;
- computeYMD_HMS(&x);
- if( x.Y<1971 || x.Y>=2038 ){
+ computeJD(p);
+ if( p->iJD<2108667600*(i64)100000 /* 1970-01-01 */
+ || p->iJD>2130141456*(i64)100000 /* 2038-01-18 */
+ ){
/* EVIDENCE-OF: R-55269-29598 The localtime_r() C function normally only
** works for years between 1970 and 2037. For dates outside this range,
** SQLite attempts to map the year into an equivalent year within this
** range, do the calculation, then map the year back.
*/
- x.Y = 2000;
- x.M = 1;
- x.D = 1;
- x.h = 0;
- x.m = 0;
- x.s = 0.0;
- } else {
- int s = (int)(x.s + 0.5);
- x.s = s;
+ DateTime x = *p;
+ computeYMD_HMS(&x);
+ iYearDiff = (2000 + x.Y%4) - x.Y;
+ x.Y += iYearDiff;
+ x.validJD = 0;
+ computeJD(&x);
+ t = (time_t)(x.iJD/1000 - 21086676*(i64)10000);
+ }else{
+ iYearDiff = 0;
+ t = (time_t)(p->iJD/1000 - 21086676*(i64)10000);
}
- x.tz = 0;
- x.validJD = 0;
- computeJD(&x);
- t = (time_t)(x.iJD/1000 - 21086676*(i64)10000);
if( osLocaltime(&t, &sLocal) ){
sqlite3_result_error(pCtx, "local time unavailable", -1);
- *pRc = SQLITE_ERROR;
- return 0;
+ return SQLITE_ERROR;
}
- y.Y = sLocal.tm_year + 1900;
- y.M = sLocal.tm_mon + 1;
- y.D = sLocal.tm_mday;
- y.h = sLocal.tm_hour;
- y.m = sLocal.tm_min;
- y.s = sLocal.tm_sec;
- y.validYMD = 1;
- y.validHMS = 1;
- y.validJD = 0;
- y.rawS = 0;
- y.validTZ = 0;
- y.isError = 0;
- computeJD(&y);
- *pRc = SQLITE_OK;
- return y.iJD - x.iJD;
+ p->Y = sLocal.tm_year + 1900 - iYearDiff;
+ p->M = sLocal.tm_mon + 1;
+ p->D = sLocal.tm_mday;
+ p->h = sLocal.tm_hour;
+ p->m = sLocal.tm_min;
+ p->s = sLocal.tm_sec + (p->iJD%1000)*0.001;
+ p->validYMD = 1;
+ p->validHMS = 1;
+ p->validJD = 0;
+ p->rawS = 0;
+ p->validTZ = 0;
+ p->isError = 0;
+ return SQLITE_OK;
}
#endif /* SQLITE_OMIT_LOCALTIME */
@@ -23306,18 +23683,17 @@ static sqlite3_int64 localtimeOffset(
** of several units of time.
*/
static const struct {
- u8 eType; /* Transformation type code */
- u8 nName; /* Length of th name */
- char *zName; /* Name of the transformation */
- double rLimit; /* Maximum NNN value for this transform */
- double rXform; /* Constant used for this transform */
+ u8 nName; /* Length of the name */
+ char zName[7]; /* Name of the transformation */
+ float rLimit; /* Maximum NNN value for this transform */
+ float rXform; /* Constant used for this transform */
} aXformType[] = {
- { 0, 6, "second", 464269060800.0, 1000.0 },
- { 0, 6, "minute", 7737817680.0, 60000.0 },
- { 0, 4, "hour", 128963628.0, 3600000.0 },
- { 0, 3, "day", 5373485.0, 86400000.0 },
- { 1, 5, "month", 176546.0, 2592000000.0 },
- { 2, 4, "year", 14713.0, 31536000000.0 },
+ { 6, "second", 4.6427e+14, 1.0 },
+ { 6, "minute", 7.7379e+12, 60.0 },
+ { 4, "hour", 1.2897e+11, 3600.0 },
+ { 3, "day", 5373485.0, 86400.0 },
+ { 5, "month", 176546.0, 2592000.0 },
+ { 4, "year", 14713.0, 31536000.0 },
};
/*
@@ -23348,11 +23724,55 @@ static int parseModifier(
sqlite3_context *pCtx, /* Function context */
const char *z, /* The text of the modifier */
int n, /* Length of zMod in bytes */
- DateTime *p /* The date/time value to be modified */
+ DateTime *p, /* The date/time value to be modified */
+ int idx /* Parameter index of the modifier */
){
int rc = 1;
double r;
switch(sqlite3UpperToLower[(u8)z[0]] ){
+ case 'a': {
+ /*
+ ** auto
+ **
+ ** If rawS is available, then interpret as a julian day number, or
+ ** a unix timestamp, depending on its magnitude.
+ */
+ if( sqlite3_stricmp(z, "auto")==0 ){
+ if( idx>1 ) return 1; /* IMP: R-33611-57934 */
+ if( !p->rawS || p->validJD ){
+ rc = 0;
+ p->rawS = 0;
+ }else if( p->s>=-21086676*(i64)10000 /* -4713-11-24 12:00:00 */
+ && p->s<=(25340230*(i64)10000)+799 /* 9999-12-31 23:59:59 */
+ ){
+ r = p->s*1000.0 + 210866760000000.0;
+ clearYMD_HMS_TZ(p);
+ p->iJD = (sqlite3_int64)(r + 0.5);
+ p->validJD = 1;
+ p->rawS = 0;
+ rc = 0;
+ }
+ }
+ break;
+ }
+ case 'j': {
+ /*
+ ** julianday
+ **
+ ** Always interpret the prior number as a julian-day value. If this
+ ** is not the first modifier, or if the prior argument is not a numeric
+ ** value in the allowed range of julian day numbers understood by
+ ** SQLite (0..5373484.5) then the result will be NULL.
+ */
+ if( sqlite3_stricmp(z, "julianday")==0 ){
+ if( idx>1 ) return 1; /* IMP: R-31176-64601 */
+ if( p->validJD && p->rawS ){
+ rc = 0;
+ p->rawS = 0;
+ }
+ }
+ break;
+ }
#ifndef SQLITE_OMIT_LOCALTIME
case 'l': {
/* localtime
@@ -23361,9 +23781,7 @@ static int parseModifier(
** show local time.
*/
if( sqlite3_stricmp(z, "localtime")==0 && sqlite3NotPureFunc(pCtx) ){
- computeJD(p);
- p->iJD += localtimeOffset(p, pCtx, &rc);
- clearYMD_HMS_TZ(p);
+ rc = toLocaltime(p, pCtx);
}
break;
}
@@ -23376,6 +23794,7 @@ static int parseModifier(
** seconds since 1970. Convert to a real julian day number.
*/
if( sqlite3_stricmp(z, "unixepoch")==0 && p->rawS ){
+ if( idx>1 ) return 1; /* IMP: R-49255-55373 */
r = p->s*1000.0 + 210866760000000.0;
if( r>=0.0 && r<464269060800000.0 ){
clearYMD_HMS_TZ(p);
@@ -23388,18 +23807,31 @@ static int parseModifier(
#ifndef SQLITE_OMIT_LOCALTIME
else if( sqlite3_stricmp(z, "utc")==0 && sqlite3NotPureFunc(pCtx) ){
if( p->tzSet==0 ){
- sqlite3_int64 c1;
+ i64 iOrigJD; /* Original localtime */
+ i64 iGuess; /* Guess at the corresponding utc time */
+ int cnt = 0; /* Safety to prevent infinite loop */
+ int iErr; /* Guess is off by this much */
+
computeJD(p);
- c1 = localtimeOffset(p, pCtx, &rc);
- if( rc==SQLITE_OK ){
- p->iJD -= c1;
- clearYMD_HMS_TZ(p);
- p->iJD += c1 - localtimeOffset(p, pCtx, &rc);
- }
+ iGuess = iOrigJD = p->iJD;
+ iErr = 0;
+ do{
+ DateTime new;
+ memset(&new, 0, sizeof(new));
+ iGuess -= iErr;
+ new.iJD = iGuess;
+ new.validJD = 1;
+ rc = toLocaltime(&new, pCtx);
+ if( rc ) return rc;
+ computeJD(&new);
+ iErr = new.iJD - iOrigJD;
+ }while( iErr && cnt++<3 );
+ memset(p, 0, sizeof(*p));
+ p->iJD = iGuess;
+ p->validJD = 1;
p->tzSet = 1;
- }else{
- rc = SQLITE_OK;
}
+ rc = SQLITE_OK;
}
#endif
break;
@@ -23515,9 +23947,10 @@ static int parseModifier(
&& sqlite3_strnicmp(aXformType[i].zName, z, n)==0
&& r>-aXformType[i].rLimit && r<aXformType[i].rLimit
){
- switch( aXformType[i].eType ){
- case 1: { /* Special processing to add months */
+ switch( i ){
+ case 4: { /* Special processing to add months */
int x;
+ assert( strcmp(aXformType[i].zName,"month")==0 );
computeYMD_HMS(p);
p->M += (int)r;
x = p->M>0 ? (p->M-1)/12 : (p->M-12)/12;
@@ -23527,8 +23960,9 @@ static int parseModifier(
r -= (int)r;
break;
}
- case 2: { /* Special processing to add years */
+ case 5: { /* Special processing to add years */
int y = (int)r;
+ assert( strcmp(aXformType[i].zName,"year")==0 );
computeYMD_HMS(p);
p->Y += y;
p->validJD = 0;
@@ -23537,7 +23971,7 @@ static int parseModifier(
}
}
computeJD(p);
- p->iJD += (sqlite3_int64)(r*aXformType[i].rXform + rRounder);
+ p->iJD += (sqlite3_int64)(r*1000.0*aXformType[i].rXform + rRounder);
rc = 0;
break;
}
@@ -23587,7 +24021,7 @@ static int isDate(
for(i=1; i<argc; i++){
z = sqlite3_value_text(argv[i]);
n = sqlite3_value_bytes(argv[i]);
- if( z==0 || parseModifier(context, (char*)z, n, p) ) return 1;
+ if( z==0 || parseModifier(context, (char*)z, n, p, i) ) return 1;
}
computeJD(p);
if( p->isError || !validJulianDay(p->iJD) ) return 1;
@@ -23618,6 +24052,24 @@ static void juliandayFunc(
}
/*
+** unixepoch( TIMESTRING, MOD, MOD, ...)
+**
+** Return the number of seconds (including fractional seconds) since
+** the unix epoch of 1970-01-01 00:00:00 GMT.
+*/
+static void unixepochFunc(
+ sqlite3_context *context,
+ int argc,
+ sqlite3_value **argv
+){
+ DateTime x;
+ if( isDate(context, argc, argv, &x)==0 ){
+ computeJD(&x);
+ sqlite3_result_int64(context, x.iJD/1000 - 21086676*(i64)10000);
+ }
+}
+
+/*
** datetime( TIMESTRING, MOD, MOD, ...)
**
** Return YYYY-MM-DD HH:MM:SS
@@ -23629,11 +24081,38 @@ static void datetimeFunc(
){
DateTime x;
if( isDate(context, argc, argv, &x)==0 ){
- char zBuf[100];
+ int Y, s;
+ char zBuf[24];
computeYMD_HMS(&x);
- sqlite3_snprintf(sizeof(zBuf), zBuf, "%04d-%02d-%02d %02d:%02d:%02d",
- x.Y, x.M, x.D, x.h, x.m, (int)(x.s));
- sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT);
+ Y = x.Y;
+ if( Y<0 ) Y = -Y;
+ zBuf[1] = '0' + (Y/1000)%10;
+ zBuf[2] = '0' + (Y/100)%10;
+ zBuf[3] = '0' + (Y/10)%10;
+ zBuf[4] = '0' + (Y)%10;
+ zBuf[5] = '-';
+ zBuf[6] = '0' + (x.M/10)%10;
+ zBuf[7] = '0' + (x.M)%10;
+ zBuf[8] = '-';
+ zBuf[9] = '0' + (x.D/10)%10;
+ zBuf[10] = '0' + (x.D)%10;
+ zBuf[11] = ' ';
+ zBuf[12] = '0' + (x.h/10)%10;
+ zBuf[13] = '0' + (x.h)%10;
+ zBuf[14] = ':';
+ zBuf[15] = '0' + (x.m/10)%10;
+ zBuf[16] = '0' + (x.m)%10;
+ zBuf[17] = ':';
+ s = (int)x.s;
+ zBuf[18] = '0' + (s/10)%10;
+ zBuf[19] = '0' + (s)%10;
+ zBuf[20] = 0;
+ if( x.Y<0 ){
+ zBuf[0] = '-';
+ sqlite3_result_text(context, zBuf, 20, SQLITE_TRANSIENT);
+ }else{
+ sqlite3_result_text(context, &zBuf[1], 19, SQLITE_TRANSIENT);
+ }
}
}
@@ -23649,10 +24128,20 @@ static void timeFunc(
){
DateTime x;
if( isDate(context, argc, argv, &x)==0 ){
- char zBuf[100];
+ int s;
+ char zBuf[16];
computeHMS(&x);
- sqlite3_snprintf(sizeof(zBuf), zBuf, "%02d:%02d:%02d", x.h, x.m, (int)x.s);
- sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT);
+ zBuf[0] = '0' + (x.h/10)%10;
+ zBuf[1] = '0' + (x.h)%10;
+ zBuf[2] = ':';
+ zBuf[3] = '0' + (x.m/10)%10;
+ zBuf[4] = '0' + (x.m)%10;
+ zBuf[5] = ':';
+ s = (int)x.s;
+ zBuf[6] = '0' + (s/10)%10;
+ zBuf[7] = '0' + (s)%10;
+ zBuf[8] = 0;
+ sqlite3_result_text(context, zBuf, 8, SQLITE_TRANSIENT);
}
}
@@ -23668,10 +24157,28 @@ static void dateFunc(
){
DateTime x;
if( isDate(context, argc, argv, &x)==0 ){
- char zBuf[100];
+ int Y;
+ char zBuf[16];
computeYMD(&x);
- sqlite3_snprintf(sizeof(zBuf), zBuf, "%04d-%02d-%02d", x.Y, x.M, x.D);
- sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT);
+ Y = x.Y;
+ if( Y<0 ) Y = -Y;
+ zBuf[1] = '0' + (Y/1000)%10;
+ zBuf[2] = '0' + (Y/100)%10;
+ zBuf[3] = '0' + (Y/10)%10;
+ zBuf[4] = '0' + (Y)%10;
+ zBuf[5] = '-';
+ zBuf[6] = '0' + (x.M/10)%10;
+ zBuf[7] = '0' + (x.M)%10;
+ zBuf[8] = '-';
+ zBuf[9] = '0' + (x.D/10)%10;
+ zBuf[10] = '0' + (x.D)%10;
+ zBuf[11] = 0;
+ if( x.Y<0 ){
+ zBuf[0] = '-';
+ sqlite3_result_text(context, zBuf, 11, SQLITE_TRANSIENT);
+ }else{
+ sqlite3_result_text(context, &zBuf[1], 10, SQLITE_TRANSIENT);
+ }
}
}
@@ -23893,6 +24400,7 @@ SQLITE_PRIVATE void sqlite3RegisterDateTimeFunctions(void){
static FuncDef aDateTimeFuncs[] = {
#ifndef SQLITE_OMIT_DATETIME_FUNCS
PURE_DATE(julianday, -1, 0, 0, juliandayFunc ),
+ PURE_DATE(unixepoch, -1, 0, 0, unixepochFunc ),
PURE_DATE(date, -1, 0, 0, dateFunc ),
PURE_DATE(time, -1, 0, 0, timeFunc ),
PURE_DATE(datetime, -1, 0, 0, datetimeFunc ),
@@ -28838,8 +29346,15 @@ SQLITE_PRIVATE void sqlite3SetString(char **pz, sqlite3 *db, const char *zNew){
** has happened. This routine will set db->mallocFailed, and also
** temporarily disable the lookaside memory allocator and interrupt
** any running VDBEs.
+**
+** Always return a NULL pointer so that this routine can be invoked using
+**
+** return sqlite3OomFault(db);
+**
+** and thereby avoid unnecessary stack frame allocations for the overwhelmingly
+** common case where no OOM occurs.
*/
-SQLITE_PRIVATE void sqlite3OomFault(sqlite3 *db){
+SQLITE_PRIVATE void *sqlite3OomFault(sqlite3 *db){
if( db->mallocFailed==0 && db->bBenignMalloc==0 ){
db->mallocFailed = 1;
if( db->nVdbeExec>0 ){
@@ -28847,9 +29362,11 @@ SQLITE_PRIVATE void sqlite3OomFault(sqlite3 *db){
}
DisableLookaside;
if( db->pParse ){
+ sqlite3ErrorMsg(db->pParse, "out of memory");
db->pParse->rc = SQLITE_NOMEM_BKPT;
}
}
+ return 0;
}
/*
@@ -29758,12 +30275,22 @@ SQLITE_API void sqlite3_str_vappendf(
goto adjust_width_for_utf8;
}
case etTOKEN: {
- Token *pToken;
if( (pAccum->printfFlags & SQLITE_PRINTF_INTERNAL)==0 ) return;
- pToken = va_arg(ap, Token*);
- assert( bArgList==0 );
- if( pToken && pToken->n ){
- sqlite3_str_append(pAccum, (const char*)pToken->z, pToken->n);
+ if( flag_alternateform ){
+ /* %#T means an Expr pointer that uses Expr.u.zToken */
+ Expr *pExpr = va_arg(ap,Expr*);
+ if( ALWAYS(pExpr) && ALWAYS(!ExprHasProperty(pExpr,EP_IntValue)) ){
+ sqlite3_str_appendall(pAccum, (const char*)pExpr->u.zToken);
+ sqlite3RecordErrorOffsetOfExpr(pAccum->db, pExpr);
+ }
+ }else{
+ /* %T means a Token pointer */
+ Token *pToken = va_arg(ap, Token*);
+ assert( bArgList==0 );
+ if( pToken && pToken->n ){
+ sqlite3_str_append(pAccum, (const char*)pToken->z, pToken->n);
+ sqlite3RecordErrorByteOffset(pAccum->db, pToken->z);
+ }
}
length = width = 0;
break;
@@ -29818,6 +30345,42 @@ SQLITE_API void sqlite3_str_vappendf(
}/* End for loop over the format string */
} /* End of function */
+
+/*
+** The z string points to the first character of a token that is
+** associated with an error. If db does not already have an error
+** byte offset recorded, try to compute the error byte offset for
+** z and set the error byte offset in db.
+*/
+SQLITE_PRIVATE void sqlite3RecordErrorByteOffset(sqlite3 *db, const char *z){
+ const Parse *pParse;
+ const char *zText;
+ const char *zEnd;
+ assert( z!=0 );
+ if( NEVER(db==0) ) return;
+ if( db->errByteOffset!=(-2) ) return;
+ pParse = db->pParse;
+ if( NEVER(pParse==0) ) return;
+ zText =pParse->zTail;
+ if( NEVER(zText==0) ) return;
+ zEnd = &zText[strlen(zText)];
+ if( SQLITE_WITHIN(z,zText,zEnd) ){
+ db->errByteOffset = (int)(z-zText);
+ }
+}
+
+/*
+** If pExpr has a byte offset for the start of a token, record that as
+** as the error offset.
+*/
+SQLITE_PRIVATE void sqlite3RecordErrorOffsetOfExpr(sqlite3 *db, const Expr *pExpr){
+ while( pExpr && (ExprHasProperty(pExpr,EP_FromJoin) || pExpr->w.iOfst<=0) ){
+ pExpr = pExpr->pLeft;
+ }
+ if( pExpr==0 ) return;
+ db->errByteOffset = pExpr->w.iOfst;
+}
+
/*
** Enlarge the memory allocation on a StrAccum object so that it is
** able to accept at least N more bytes of text.
@@ -29825,7 +30388,7 @@ SQLITE_API void sqlite3_str_vappendf(
** Return the number of bytes of text that StrAccum is able to accept
** after the attempted enlargement. The value returned might be zero.
*/
-static int sqlite3StrAccumEnlarge(StrAccum *p, int N){
+SQLITE_PRIVATE int sqlite3StrAccumEnlarge(StrAccum *p, int N){
char *zNew;
assert( p->nChar+(i64)N >= p->nAlloc ); /* Only called if really needed */
if( p->accError ){
@@ -30659,7 +31222,7 @@ SQLITE_PRIVATE void sqlite3TreeViewExpr(TreeView *pView, const Expr *pExpr, u8 m
sqlite3_str_appendf(&x, " fg.af=%x.%c",
pExpr->flags, pExpr->affExpr ? pExpr->affExpr : 'n');
if( ExprHasProperty(pExpr, EP_FromJoin) ){
- sqlite3_str_appendf(&x, " iRJT=%d", pExpr->iRightJoinTable);
+ sqlite3_str_appendf(&x, " iRJT=%d", pExpr->w.iRightJoinTable);
}
if( ExprHasProperty(pExpr, EP_FromDDL) ){
sqlite3_str_appendf(&x, " DDL");
@@ -32141,7 +32704,11 @@ static SQLITE_NOINLINE void sqlite3ErrorFinish(sqlite3 *db, int err_code){
SQLITE_PRIVATE void sqlite3Error(sqlite3 *db, int err_code){
assert( db!=0 );
db->errCode = err_code;
- if( err_code || db->pErr ) sqlite3ErrorFinish(db, err_code);
+ if( err_code || db->pErr ){
+ sqlite3ErrorFinish(db, err_code);
+ }else{
+ db->errByteOffset = -1;
+ }
}
/*
@@ -32151,6 +32718,7 @@ SQLITE_PRIVATE void sqlite3Error(sqlite3 *db, int err_code){
SQLITE_PRIVATE void sqlite3ErrorClear(sqlite3 *db){
assert( db!=0 );
db->errCode = SQLITE_OK;
+ db->errByteOffset = -1;
if( db->pErr ) sqlite3ValueSetNull(db->pErr);
}
@@ -32171,17 +32739,8 @@ SQLITE_PRIVATE void sqlite3SystemError(sqlite3 *db, int rc){
** handle "db". The error code is set to "err_code".
**
** If it is not NULL, string zFormat specifies the format of the
-** error string in the style of the printf functions: The following
-** format characters are allowed:
-**
-** %s Insert a string
-** %z A string that should be freed after use
-** %d Insert an integer
-** %T Insert a token
-** %S Insert the first element of a SrcList
-**
-** zFormat and any string tokens that follow it are assumed to be
-** encoded in UTF-8.
+** error string. zFormat and any string tokens that follow it are
+** assumed to be encoded in UTF-8.
**
** To clear the most recent error for sqlite handle "db", sqlite3Error
** should be called with err_code set to SQLITE_OK and zFormat set
@@ -32205,13 +32764,6 @@ SQLITE_PRIVATE void sqlite3ErrorWithMsg(sqlite3 *db, int err_code, const char *z
/*
** Add an error message to pParse->zErrMsg and increment pParse->nErr.
-** The following formatting characters are allowed:
-**
-** %s Insert a string
-** %z A string that should be freed after use
-** %d Insert an integer
-** %T Insert a token
-** %S Insert the first element of a SrcList
**
** This function should be used to report any error that occurs while
** compiling an SQL statement (i.e. within sqlite3_prepare()). The
@@ -32224,11 +32776,19 @@ SQLITE_PRIVATE void sqlite3ErrorMsg(Parse *pParse, const char *zFormat, ...){
char *zMsg;
va_list ap;
sqlite3 *db = pParse->db;
+ assert( db!=0 );
+ assert( db->pParse==pParse );
+ db->errByteOffset = -2;
va_start(ap, zFormat);
zMsg = sqlite3VMPrintf(db, zFormat, ap);
va_end(ap);
+ if( db->errByteOffset<-1 ) db->errByteOffset = -1;
if( db->suppressErr ){
sqlite3DbFree(db, zMsg);
+ if( db->mallocFailed ){
+ pParse->nErr++;
+ pParse->rc = SQLITE_NOMEM;
+ }
}else{
pParse->nErr++;
sqlite3DbFree(db, pParse->zErrMsg);
@@ -33610,7 +34170,6 @@ SQLITE_PRIVATE LogEst sqlite3LogEst(u64 x){
return a[x&7] + y - 10;
}
-#ifndef SQLITE_OMIT_VIRTUALTABLE
/*
** Convert a double into a LogEst
** In other words, compute an approximation for 10*log2(x).
@@ -33625,16 +34184,9 @@ SQLITE_PRIVATE LogEst sqlite3LogEstFromDouble(double x){
e = (a>>52) - 1022;
return e*10;
}
-#endif /* SQLITE_OMIT_VIRTUALTABLE */
-#if defined(SQLITE_ENABLE_STMT_SCANSTATUS) || \
- defined(SQLITE_ENABLE_STAT4) || \
- defined(SQLITE_EXPLAIN_ESTIMATED_ROWS)
/*
** Convert a LogEst into an integer.
-**
-** Note that this routine is only used when one or more of various
-** non-standard compile-time options is enabled.
*/
SQLITE_PRIVATE u64 sqlite3LogEstToInt(LogEst x){
u64 n;
@@ -33642,17 +34194,9 @@ SQLITE_PRIVATE u64 sqlite3LogEstToInt(LogEst x){
x /= 10;
if( n>=5 ) n -= 2;
else if( n>=1 ) n -= 1;
-#if defined(SQLITE_ENABLE_STMT_SCANSTATUS) || \
- defined(SQLITE_EXPLAIN_ESTIMATED_ROWS)
if( x>60 ) return (u64)LARGEST_INT64;
-#else
- /* If only SQLITE_ENABLE_STAT4 is on, then the largest input
- ** possible to this routine is 310, resulting in a maximum x of 31 */
- assert( x<=60 );
-#endif
return x>=3 ? (n+8)<<(x-3) : (n+8)>>(3-x);
}
-#endif /* defined SCANSTAT or STAT4 or ESTIMATED_ROWS */
/*
** Add a new name/number pair to a VList. This might require that the
@@ -34106,45 +34650,45 @@ SQLITE_PRIVATE const char *sqlite3OpcodeName(int i){
/* 60 */ "DecrJumpZero" OpHelp("if (--r[P1])==0 goto P2"),
/* 61 */ "IncrVacuum" OpHelp(""),
/* 62 */ "VNext" OpHelp(""),
- /* 63 */ "Init" OpHelp("Start at P2"),
- /* 64 */ "PureFunc" OpHelp("r[P3]=func(r[P2@NP])"),
- /* 65 */ "Function" OpHelp("r[P3]=func(r[P2@NP])"),
- /* 66 */ "Return" OpHelp(""),
- /* 67 */ "EndCoroutine" OpHelp(""),
- /* 68 */ "HaltIfNull" OpHelp("if r[P3]=null halt"),
- /* 69 */ "Halt" OpHelp(""),
- /* 70 */ "Integer" OpHelp("r[P2]=P1"),
- /* 71 */ "Int64" OpHelp("r[P2]=P4"),
- /* 72 */ "String" OpHelp("r[P2]='P4' (len=P1)"),
- /* 73 */ "Null" OpHelp("r[P2..P3]=NULL"),
- /* 74 */ "SoftNull" OpHelp("r[P1]=NULL"),
- /* 75 */ "Blob" OpHelp("r[P2]=P4 (len=P1)"),
- /* 76 */ "Variable" OpHelp("r[P2]=parameter(P1,P4)"),
- /* 77 */ "Move" OpHelp("r[P2@P3]=r[P1@P3]"),
- /* 78 */ "Copy" OpHelp("r[P2@P3+1]=r[P1@P3+1]"),
- /* 79 */ "SCopy" OpHelp("r[P2]=r[P1]"),
- /* 80 */ "IntCopy" OpHelp("r[P2]=r[P1]"),
- /* 81 */ "ChngCntRow" OpHelp("output=r[P1]"),
- /* 82 */ "ResultRow" OpHelp("output=r[P1@P2]"),
- /* 83 */ "CollSeq" OpHelp(""),
- /* 84 */ "AddImm" OpHelp("r[P1]=r[P1]+P2"),
- /* 85 */ "RealAffinity" OpHelp(""),
- /* 86 */ "Cast" OpHelp("affinity(r[P1])"),
- /* 87 */ "Permutation" OpHelp(""),
- /* 88 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"),
- /* 89 */ "IsTrue" OpHelp("r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4"),
- /* 90 */ "ZeroOrNull" OpHelp("r[P2] = 0 OR NULL"),
- /* 91 */ "Offset" OpHelp("r[P3] = sqlite_offset(P1)"),
- /* 92 */ "Column" OpHelp("r[P3]=PX"),
- /* 93 */ "TypeCheck" OpHelp("typecheck(r[P1@P2])"),
- /* 94 */ "Affinity" OpHelp("affinity(r[P1@P2])"),
- /* 95 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"),
- /* 96 */ "Count" OpHelp("r[P2]=count()"),
- /* 97 */ "ReadCookie" OpHelp(""),
- /* 98 */ "SetCookie" OpHelp(""),
- /* 99 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"),
- /* 100 */ "OpenRead" OpHelp("root=P2 iDb=P3"),
- /* 101 */ "OpenWrite" OpHelp("root=P2 iDb=P3"),
+ /* 63 */ "Filter" OpHelp("if key(P3@P4) not in filter(P1) goto P2"),
+ /* 64 */ "Init" OpHelp("Start at P2"),
+ /* 65 */ "PureFunc" OpHelp("r[P3]=func(r[P2@NP])"),
+ /* 66 */ "Function" OpHelp("r[P3]=func(r[P2@NP])"),
+ /* 67 */ "Return" OpHelp(""),
+ /* 68 */ "EndCoroutine" OpHelp(""),
+ /* 69 */ "HaltIfNull" OpHelp("if r[P3]=null halt"),
+ /* 70 */ "Halt" OpHelp(""),
+ /* 71 */ "Integer" OpHelp("r[P2]=P1"),
+ /* 72 */ "Int64" OpHelp("r[P2]=P4"),
+ /* 73 */ "String" OpHelp("r[P2]='P4' (len=P1)"),
+ /* 74 */ "Null" OpHelp("r[P2..P3]=NULL"),
+ /* 75 */ "SoftNull" OpHelp("r[P1]=NULL"),
+ /* 76 */ "Blob" OpHelp("r[P2]=P4 (len=P1)"),
+ /* 77 */ "Variable" OpHelp("r[P2]=parameter(P1,P4)"),
+ /* 78 */ "Move" OpHelp("r[P2@P3]=r[P1@P3]"),
+ /* 79 */ "Copy" OpHelp("r[P2@P3+1]=r[P1@P3+1]"),
+ /* 80 */ "SCopy" OpHelp("r[P2]=r[P1]"),
+ /* 81 */ "IntCopy" OpHelp("r[P2]=r[P1]"),
+ /* 82 */ "FkCheck" OpHelp(""),
+ /* 83 */ "ResultRow" OpHelp("output=r[P1@P2]"),
+ /* 84 */ "CollSeq" OpHelp(""),
+ /* 85 */ "AddImm" OpHelp("r[P1]=r[P1]+P2"),
+ /* 86 */ "RealAffinity" OpHelp(""),
+ /* 87 */ "Cast" OpHelp("affinity(r[P1])"),
+ /* 88 */ "Permutation" OpHelp(""),
+ /* 89 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"),
+ /* 90 */ "IsTrue" OpHelp("r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4"),
+ /* 91 */ "ZeroOrNull" OpHelp("r[P2] = 0 OR NULL"),
+ /* 92 */ "Offset" OpHelp("r[P3] = sqlite_offset(P1)"),
+ /* 93 */ "Column" OpHelp("r[P3]=PX"),
+ /* 94 */ "TypeCheck" OpHelp("typecheck(r[P1@P2])"),
+ /* 95 */ "Affinity" OpHelp("affinity(r[P1@P2])"),
+ /* 96 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"),
+ /* 97 */ "Count" OpHelp("r[P2]=count()"),
+ /* 98 */ "ReadCookie" OpHelp(""),
+ /* 99 */ "SetCookie" OpHelp(""),
+ /* 100 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"),
+ /* 101 */ "OpenRead" OpHelp("root=P2 iDb=P3"),
/* 102 */ "BitAnd" OpHelp("r[P3]=r[P1]&r[P2]"),
/* 103 */ "BitOr" OpHelp("r[P3]=r[P1]|r[P2]"),
/* 104 */ "ShiftLeft" OpHelp("r[P3]=r[P2]<<r[P1]"),
@@ -34155,76 +34699,79 @@ SQLITE_PRIVATE const char *sqlite3OpcodeName(int i){
/* 109 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"),
/* 110 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"),
/* 111 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"),
- /* 112 */ "OpenDup" OpHelp(""),
- /* 113 */ "BitNot" OpHelp("r[P2]= ~r[P1]"),
- /* 114 */ "OpenAutoindex" OpHelp("nColumn=P2"),
- /* 115 */ "OpenEphemeral" OpHelp("nColumn=P2"),
- /* 116 */ "String8" OpHelp("r[P2]='P4'"),
- /* 117 */ "SorterOpen" OpHelp(""),
- /* 118 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"),
- /* 119 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"),
- /* 120 */ "Close" OpHelp(""),
- /* 121 */ "ColumnsUsed" OpHelp(""),
- /* 122 */ "SeekScan" OpHelp("Scan-ahead up to P1 rows"),
- /* 123 */ "SeekHit" OpHelp("set P2<=seekHit<=P3"),
- /* 124 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"),
- /* 125 */ "NewRowid" OpHelp("r[P2]=rowid"),
- /* 126 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"),
- /* 127 */ "RowCell" OpHelp(""),
- /* 128 */ "Delete" OpHelp(""),
- /* 129 */ "ResetCount" OpHelp(""),
- /* 130 */ "SorterCompare" OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"),
- /* 131 */ "SorterData" OpHelp("r[P2]=data"),
- /* 132 */ "RowData" OpHelp("r[P2]=data"),
- /* 133 */ "Rowid" OpHelp("r[P2]=rowid"),
- /* 134 */ "NullRow" OpHelp(""),
- /* 135 */ "SeekEnd" OpHelp(""),
- /* 136 */ "IdxInsert" OpHelp("key=r[P2]"),
- /* 137 */ "SorterInsert" OpHelp("key=r[P2]"),
- /* 138 */ "IdxDelete" OpHelp("key=r[P2@P3]"),
- /* 139 */ "DeferredSeek" OpHelp("Move P3 to P1.rowid if needed"),
- /* 140 */ "IdxRowid" OpHelp("r[P2]=rowid"),
- /* 141 */ "FinishSeek" OpHelp(""),
- /* 142 */ "Destroy" OpHelp(""),
- /* 143 */ "Clear" OpHelp(""),
- /* 144 */ "ResetSorter" OpHelp(""),
- /* 145 */ "CreateBtree" OpHelp("r[P2]=root iDb=P1 flags=P3"),
- /* 146 */ "SqlExec" OpHelp(""),
- /* 147 */ "ParseSchema" OpHelp(""),
- /* 148 */ "LoadAnalysis" OpHelp(""),
- /* 149 */ "DropTable" OpHelp(""),
- /* 150 */ "DropIndex" OpHelp(""),
- /* 151 */ "DropTrigger" OpHelp(""),
- /* 152 */ "Real" OpHelp("r[P2]=P4"),
- /* 153 */ "IntegrityCk" OpHelp(""),
- /* 154 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"),
- /* 155 */ "Param" OpHelp(""),
- /* 156 */ "FkCounter" OpHelp("fkctr[P1]+=P2"),
- /* 157 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"),
- /* 158 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"),
- /* 159 */ "AggInverse" OpHelp("accum=r[P3] inverse(r[P2@P5])"),
- /* 160 */ "AggStep" OpHelp("accum=r[P3] step(r[P2@P5])"),
- /* 161 */ "AggStep1" OpHelp("accum=r[P3] step(r[P2@P5])"),
- /* 162 */ "AggValue" OpHelp("r[P3]=value N=P2"),
- /* 163 */ "AggFinal" OpHelp("accum=r[P1] N=P2"),
- /* 164 */ "Expire" OpHelp(""),
- /* 165 */ "CursorLock" OpHelp(""),
- /* 166 */ "CursorUnlock" OpHelp(""),
- /* 167 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"),
- /* 168 */ "VBegin" OpHelp(""),
- /* 169 */ "VCreate" OpHelp(""),
- /* 170 */ "VDestroy" OpHelp(""),
- /* 171 */ "VOpen" OpHelp(""),
- /* 172 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"),
- /* 173 */ "VRename" OpHelp(""),
- /* 174 */ "Pagecount" OpHelp(""),
- /* 175 */ "MaxPgcnt" OpHelp(""),
- /* 176 */ "Trace" OpHelp(""),
- /* 177 */ "CursorHint" OpHelp(""),
- /* 178 */ "ReleaseReg" OpHelp("release r[P1@P2] mask P3"),
- /* 179 */ "Noop" OpHelp(""),
- /* 180 */ "Explain" OpHelp(""),
- /* 181 */ "Abortable" OpHelp(""),
+ /* 112 */ "OpenWrite" OpHelp("root=P2 iDb=P3"),
+ /* 113 */ "OpenDup" OpHelp(""),
+ /* 114 */ "BitNot" OpHelp("r[P2]= ~r[P1]"),
+ /* 115 */ "OpenAutoindex" OpHelp("nColumn=P2"),
+ /* 116 */ "OpenEphemeral" OpHelp("nColumn=P2"),
+ /* 117 */ "String8" OpHelp("r[P2]='P4'"),
+ /* 118 */ "SorterOpen" OpHelp(""),
+ /* 119 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"),
+ /* 120 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"),
+ /* 121 */ "Close" OpHelp(""),
+ /* 122 */ "ColumnsUsed" OpHelp(""),
+ /* 123 */ "SeekScan" OpHelp("Scan-ahead up to P1 rows"),
+ /* 124 */ "SeekHit" OpHelp("set P2<=seekHit<=P3"),
+ /* 125 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"),
+ /* 126 */ "NewRowid" OpHelp("r[P2]=rowid"),
+ /* 127 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"),
+ /* 128 */ "RowCell" OpHelp(""),
+ /* 129 */ "Delete" OpHelp(""),
+ /* 130 */ "ResetCount" OpHelp(""),
+ /* 131 */ "SorterCompare" OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"),
+ /* 132 */ "SorterData" OpHelp("r[P2]=data"),
+ /* 133 */ "RowData" OpHelp("r[P2]=data"),
+ /* 134 */ "Rowid" OpHelp("r[P2]=rowid"),
+ /* 135 */ "NullRow" OpHelp(""),
+ /* 136 */ "SeekEnd" OpHelp(""),
+ /* 137 */ "IdxInsert" OpHelp("key=r[P2]"),
+ /* 138 */ "SorterInsert" OpHelp("key=r[P2]"),
+ /* 139 */ "IdxDelete" OpHelp("key=r[P2@P3]"),
+ /* 140 */ "DeferredSeek" OpHelp("Move P3 to P1.rowid if needed"),
+ /* 141 */ "IdxRowid" OpHelp("r[P2]=rowid"),
+ /* 142 */ "FinishSeek" OpHelp(""),
+ /* 143 */ "Destroy" OpHelp(""),
+ /* 144 */ "Clear" OpHelp(""),
+ /* 145 */ "ResetSorter" OpHelp(""),
+ /* 146 */ "CreateBtree" OpHelp("r[P2]=root iDb=P1 flags=P3"),
+ /* 147 */ "SqlExec" OpHelp(""),
+ /* 148 */ "ParseSchema" OpHelp(""),
+ /* 149 */ "LoadAnalysis" OpHelp(""),
+ /* 150 */ "DropTable" OpHelp(""),
+ /* 151 */ "DropIndex" OpHelp(""),
+ /* 152 */ "DropTrigger" OpHelp(""),
+ /* 153 */ "Real" OpHelp("r[P2]=P4"),
+ /* 154 */ "IntegrityCk" OpHelp(""),
+ /* 155 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"),
+ /* 156 */ "Param" OpHelp(""),
+ /* 157 */ "FkCounter" OpHelp("fkctr[P1]+=P2"),
+ /* 158 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"),
+ /* 159 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"),
+ /* 160 */ "AggInverse" OpHelp("accum=r[P3] inverse(r[P2@P5])"),
+ /* 161 */ "AggStep" OpHelp("accum=r[P3] step(r[P2@P5])"),
+ /* 162 */ "AggStep1" OpHelp("accum=r[P3] step(r[P2@P5])"),
+ /* 163 */ "AggValue" OpHelp("r[P3]=value N=P2"),
+ /* 164 */ "AggFinal" OpHelp("accum=r[P1] N=P2"),
+ /* 165 */ "Expire" OpHelp(""),
+ /* 166 */ "CursorLock" OpHelp(""),
+ /* 167 */ "CursorUnlock" OpHelp(""),
+ /* 168 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"),
+ /* 169 */ "VBegin" OpHelp(""),
+ /* 170 */ "VCreate" OpHelp(""),
+ /* 171 */ "VDestroy" OpHelp(""),
+ /* 172 */ "VOpen" OpHelp(""),
+ /* 173 */ "VInitIn" OpHelp("r[P2]=ValueList(P1,P3)"),
+ /* 174 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"),
+ /* 175 */ "VRename" OpHelp(""),
+ /* 176 */ "Pagecount" OpHelp(""),
+ /* 177 */ "MaxPgcnt" OpHelp(""),
+ /* 178 */ "FilterAdd" OpHelp("filter(P1) += key(P3@P4)"),
+ /* 179 */ "Trace" OpHelp(""),
+ /* 180 */ "CursorHint" OpHelp(""),
+ /* 181 */ "ReleaseReg" OpHelp("release r[P1@P2] mask P3"),
+ /* 182 */ "Noop" OpHelp(""),
+ /* 183 */ "Explain" OpHelp(""),
+ /* 184 */ "Abortable" OpHelp(""),
};
return azName[i];
}
@@ -50369,7 +50916,8 @@ SQLITE_PRIVATE void sqlite3PcacheDrop(PgHdr *p){
** make it so.
*/
SQLITE_PRIVATE void sqlite3PcacheMakeDirty(PgHdr *p){
- assert( p->nRef>0 );
+ assert( p->nRef>0 || p->pCache->bPurgeable==0 );
+ testcase( p->nRef==0 );
assert( sqlite3PcachePageSanity(p) );
if( p->flags & (PGHDR_CLEAN|PGHDR_DONT_WRITE) ){ /*OPTIMIZATION-IF-FALSE*/
p->flags &= ~PGHDR_DONT_WRITE;
@@ -55501,6 +56049,9 @@ static int pager_playback(Pager *pPager, int isHot){
goto end_playback;
}
pPager->dbSize = mxPg;
+ if( pPager->mxPgno<mxPg ){
+ pPager->mxPgno = mxPg;
+ }
}
/* Copy original pages out of the journal and back into the
@@ -56557,8 +57108,7 @@ static int pager_wait_on_lock(Pager *pPager, int locktype){
** current database image, in pages, OR
**
** b) if the page content were written at this time, it would not
-** be necessary to write the current content out to the sub-journal
-** (as determined by function subjRequiresPage()).
+** be necessary to write the current content out to the sub-journal.
**
** If the condition asserted by this function were not true, and the
** dirty page were to be discarded from the cache via the pagerStress()
@@ -56573,8 +57123,16 @@ static int pager_wait_on_lock(Pager *pPager, int locktype){
*/
#if defined(SQLITE_DEBUG)
static void assertTruncateConstraintCb(PgHdr *pPg){
+ Pager *pPager = pPg->pPager;
assert( pPg->flags&PGHDR_DIRTY );
- assert( !subjRequiresPage(pPg) || pPg->pgno<=pPg->pPager->dbSize );
+ if( pPg->pgno>pPager->dbSize ){ /* if (a) is false */
+ Pgno pgno = pPg->pgno;
+ int i;
+ for(i=0; i<pPg->pPager->nSavepoint; i++){
+ PagerSavepoint *p = &pPager->aSavepoint[i];
+ assert( p->nOrig<pgno || sqlite3BitvecTestNotNull(p->pInSavepoint,pgno) );
+ }
+ }
}
static void assertTruncateConstraint(Pager *pPager){
sqlite3PcacheIterateDirty(pPager->pPCache, assertTruncateConstraintCb);
@@ -56596,7 +57154,6 @@ static void assertTruncateConstraint(Pager *pPager){
*/
SQLITE_PRIVATE void sqlite3PagerTruncateImage(Pager *pPager, Pgno nPage){
assert( pPager->dbSize>=nPage || CORRUPT_DB );
- testcase( pPager->dbSize<nPage );
assert( pPager->eState>=PAGER_WRITER_CACHEMOD );
pPager->dbSize = nPage;
@@ -57915,7 +58472,7 @@ SQLITE_PRIVATE int sqlite3PagerSharedLock(Pager *pPager){
** may mean that the pager was in the error-state when this
** function was called and the journal file does not exist.
*/
- if( !isOpen(pPager->jfd) ){
+ if( !isOpen(pPager->jfd) && pPager->journalMode!=PAGER_JOURNALMODE_OFF ){
sqlite3_vfs * const pVfs = pPager->pVfs;
int bExists; /* True if journal file exists */
rc = sqlite3OsAccess(
@@ -58317,6 +58874,7 @@ SQLITE_PRIVATE int sqlite3PagerGet(
DbPage **ppPage, /* Write a pointer to the page here */
int flags /* PAGER_GET_XXX flags */
){
+ /* printf("PAGE %u\n", pgno); fflush(stdout); */
return pPager->xGet(pPager, pgno, ppPage, flags);
}
@@ -59922,12 +60480,12 @@ SQLITE_PRIVATE int sqlite3PagerSetJournalMode(Pager *pPager, int eMode){
u8 eOld = pPager->journalMode; /* Prior journalmode */
/* The eMode parameter is always valid */
- assert( eMode==PAGER_JOURNALMODE_DELETE
- || eMode==PAGER_JOURNALMODE_TRUNCATE
- || eMode==PAGER_JOURNALMODE_PERSIST
- || eMode==PAGER_JOURNALMODE_OFF
- || eMode==PAGER_JOURNALMODE_WAL
- || eMode==PAGER_JOURNALMODE_MEMORY );
+ assert( eMode==PAGER_JOURNALMODE_DELETE /* 0 */
+ || eMode==PAGER_JOURNALMODE_PERSIST /* 1 */
+ || eMode==PAGER_JOURNALMODE_OFF /* 2 */
+ || eMode==PAGER_JOURNALMODE_TRUNCATE /* 3 */
+ || eMode==PAGER_JOURNALMODE_MEMORY /* 4 */
+ || eMode==PAGER_JOURNALMODE_WAL /* 5 */ );
/* This routine is only called from the OP_JournalMode opcode, and
** the logic there will never allow a temporary file to be changed
@@ -59964,7 +60522,6 @@ SQLITE_PRIVATE int sqlite3PagerSetJournalMode(Pager *pPager, int eMode){
assert( isOpen(pPager->fd) || pPager->exclusiveMode );
if( !pPager->exclusiveMode && (eOld & 5)==1 && (eMode & 1)==0 ){
-
/* In this case we would like to delete the journal file. If it is
** not possible, then that is not a problem. Deleting the journal file
** here is an optimization only.
@@ -60076,6 +60633,18 @@ SQLITE_PRIVATE int sqlite3PagerCheckpoint(
int *pnCkpt /* OUT: Final number of checkpointed frames */
){
int rc = SQLITE_OK;
+ if( pPager->pWal==0 && pPager->journalMode==PAGER_JOURNALMODE_WAL ){
+ /* This only happens when a database file is zero bytes in size opened and
+ ** then "PRAGMA journal_mode=WAL" is run and then sqlite3_wal_checkpoint()
+ ** is invoked without any intervening transactions. We need to start
+ ** a transaction to initialize pWal. The PRAGMA table_list statement is
+ ** used for this since it starts transactions on every database file,
+ ** including all ATTACHed databases. This seems expensive for a single
+ ** sqlite3_wal_checkpoint() call, but it happens very rarely.
+ ** https://sqlite.org/forum/forumpost/fd0f19d229156939
+ */
+ sqlite3_exec(db, "PRAGMA table_list",0,0,0);
+ }
if( pPager->pWal ){
rc = sqlite3WalCheckpoint(pPager->pWal, db, eMode,
(eMode==SQLITE_CHECKPOINT_PASSIVE ? 0 : pPager->xBusyHandler),
@@ -62975,7 +63544,9 @@ static int walBeginShmUnreliable(Wal *pWal, int *pChanged){
}
/* Allocate a buffer to read frames into */
- szFrame = pWal->hdr.szPage + WAL_FRAME_HDRSIZE;
+ assert( (pWal->szPage & (pWal->szPage-1))==0 );
+ assert( pWal->szPage>=512 && pWal->szPage<=65536 );
+ szFrame = pWal->szPage + WAL_FRAME_HDRSIZE;
aFrame = (u8 *)sqlite3_malloc64(szFrame);
if( aFrame==0 ){
rc = SQLITE_NOMEM_BKPT;
@@ -62989,7 +63560,7 @@ static int walBeginShmUnreliable(Wal *pWal, int *pChanged){
** the caller. */
aSaveCksum[0] = pWal->hdr.aFrameCksum[0];
aSaveCksum[1] = pWal->hdr.aFrameCksum[1];
- for(iOffset=walFrameOffset(pWal->hdr.mxFrame+1, pWal->hdr.szPage);
+ for(iOffset=walFrameOffset(pWal->hdr.mxFrame+1, pWal->szPage);
iOffset+szFrame<=szWal;
iOffset+=szFrame
){
@@ -64840,7 +65411,9 @@ struct MemPage {
u8 *apOvfl[4]; /* Pointers to the body of overflow cells */
BtShared *pBt; /* Pointer to BtShared that this page is part of */
u8 *aData; /* Pointer to disk image of the page data */
- u8 *aDataEnd; /* One byte past the end of usable data */
+ u8 *aDataEnd; /* One byte past the end of the entire page - not just
+ ** the usable space, the entire page. Used to prevent
+ ** corruption-induced of buffer overflow. */
u8 *aCellIdx; /* The cell index area */
u8 *aDataOfst; /* Same as aData for leaves. aData+4 for interior */
DbPage *pDbPage; /* Pager page handle */
@@ -66797,18 +67370,32 @@ static void btreeParseCellPtr(
**
** pIter += getVarint(pIter, (u64*)&pInfo->nKey);
**
- ** The code is inlined to avoid a function call.
+ ** The code is inlined and the loop is unrolled for performance.
+ ** This routine is a high-runner.
*/
iKey = *pIter;
if( iKey>=0x80 ){
- u8 *pEnd = &pIter[7];
- iKey &= 0x7f;
- while(1){
- iKey = (iKey<<7) | (*++pIter & 0x7f);
- if( (*pIter)<0x80 ) break;
- if( pIter>=pEnd ){
- iKey = (iKey<<8) | *++pIter;
- break;
+ u8 x;
+ iKey = ((iKey&0x7f)<<7) | ((x = *++pIter) & 0x7f);
+ if( x>=0x80 ){
+ iKey = (iKey<<7) | ((x =*++pIter) & 0x7f);
+ if( x>=0x80 ){
+ iKey = (iKey<<7) | ((x = *++pIter) & 0x7f);
+ if( x>=0x80 ){
+ iKey = (iKey<<7) | ((x = *++pIter) & 0x7f);
+ if( x>=0x80 ){
+ iKey = (iKey<<7) | ((x = *++pIter) & 0x7f);
+ if( x>=0x80 ){
+ iKey = (iKey<<7) | ((x = *++pIter) & 0x7f);
+ if( x>=0x80 ){
+ iKey = (iKey<<7) | ((x = *++pIter) & 0x7f);
+ if( x>=0x80 ){
+ iKey = (iKey<<8) | (*++pIter);
+ }
+ }
+ }
+ }
+ }
}
}
}
@@ -66818,7 +67405,7 @@ static void btreeParseCellPtr(
pInfo->nPayload = nPayload;
pInfo->pPayload = pIter;
testcase( nPayload==pPage->maxLocal );
- testcase( nPayload==pPage->maxLocal+1 );
+ testcase( nPayload==(u32)pPage->maxLocal+1 );
if( nPayload<=pPage->maxLocal ){
/* This is the (easy) common case where the entire payload fits
** on the local page. No overflow is required.
@@ -66855,7 +67442,7 @@ static void btreeParseCellPtrIndex(
pInfo->nPayload = nPayload;
pInfo->pPayload = pIter;
testcase( nPayload==pPage->maxLocal );
- testcase( nPayload==pPage->maxLocal+1 );
+ testcase( nPayload==(u32)pPage->maxLocal+1 );
if( nPayload<=pPage->maxLocal ){
/* This is the (easy) common case where the entire payload fits
** on the local page. No overflow is required.
@@ -66918,7 +67505,7 @@ static u16 cellSizePtr(MemPage *pPage, u8 *pCell){
while( (*pIter++)&0x80 && pIter<pEnd );
}
testcase( nSize==pPage->maxLocal );
- testcase( nSize==pPage->maxLocal+1 );
+ testcase( nSize==(u32)pPage->maxLocal+1 );
if( nSize<=pPage->maxLocal ){
nSize += (u32)(pIter - pCell);
if( nSize<4 ) nSize = 4;
@@ -66926,7 +67513,7 @@ static u16 cellSizePtr(MemPage *pPage, u8 *pCell){
int minLocal = pPage->minLocal;
nSize = minLocal + (nSize - minLocal) % (pPage->pBt->usableSize - 4);
testcase( nSize==pPage->maxLocal );
- testcase( nSize==pPage->maxLocal+1 );
+ testcase( nSize==(u32)pPage->maxLocal+1 );
if( nSize>pPage->maxLocal ){
nSize = minLocal;
}
@@ -67340,7 +67927,7 @@ static int freeSpace(MemPage *pPage, u16 iStart, u16 iSize){
if( iFreeBlk>pPage->pBt->usableSize-4 ){ /* TH3: corrupt081.100 */
return SQLITE_CORRUPT_PAGE(pPage);
}
- assert( iFreeBlk>iPtr || iFreeBlk==0 );
+ assert( iFreeBlk>iPtr || iFreeBlk==0 || CORRUPT_DB );
/* At this point:
** iFreeBlk: First freeblock after iStart, or zero if none
@@ -67611,7 +68198,7 @@ static int btreeInitPage(MemPage *pPage){
pPage->nOverflow = 0;
pPage->cellOffset = pPage->hdrOffset + 8 + pPage->childPtrSize;
pPage->aCellIdx = data + pPage->childPtrSize + 8;
- pPage->aDataEnd = pPage->aData + pBt->usableSize;
+ pPage->aDataEnd = pPage->aData + pBt->pageSize;
pPage->aDataOfst = pPage->aData + pPage->childPtrSize;
/* EVIDENCE-OF: R-37002-32774 The two-byte integer at offset 3 gives the
** number of cells on the page. */
@@ -67646,7 +68233,7 @@ static void zeroPage(MemPage *pPage, int flags){
u8 hdr = pPage->hdrOffset;
u16 first;
- assert( sqlite3PagerPagenumber(pPage->pDbPage)==pPage->pgno );
+ assert( sqlite3PagerPagenumber(pPage->pDbPage)==pPage->pgno || CORRUPT_DB );
assert( sqlite3PagerGetExtra(pPage->pDbPage) == (void*)pPage );
assert( sqlite3PagerGetData(pPage->pDbPage) == data );
assert( sqlite3PagerIswriteable(pPage->pDbPage) );
@@ -67662,7 +68249,7 @@ static void zeroPage(MemPage *pPage, int flags){
pPage->nFree = (u16)(pBt->usableSize - first);
decodeFlags(pPage, flags);
pPage->cellOffset = first;
- pPage->aDataEnd = &data[pBt->usableSize];
+ pPage->aDataEnd = &data[pBt->pageSize];
pPage->aCellIdx = &data[first];
pPage->aDataOfst = &data[pPage->childPtrSize];
pPage->nOverflow = 0;
@@ -67788,7 +68375,7 @@ static int getAndInitPage(
goto getAndInitPage_error2;
}
}
- assert( (*ppPage)->pgno==pgno );
+ assert( (*ppPage)->pgno==pgno || CORRUPT_DB );
assert( (*ppPage)->aData==sqlite3PagerGetData(pDbPage) );
/* If obtaining a child page for a cursor, we must verify that the page is
@@ -68265,30 +68852,38 @@ static int removeFromSharingList(BtShared *pBt){
** MX_CELL_SIZE(pBt) bytes with a 4-byte prefix for a left-child
** pointer.
*/
-static void allocateTempSpace(BtShared *pBt){
- if( !pBt->pTmpSpace ){
- pBt->pTmpSpace = sqlite3PageMalloc( pBt->pageSize );
-
- /* One of the uses of pBt->pTmpSpace is to format cells before
- ** inserting them into a leaf page (function fillInCell()). If
- ** a cell is less than 4 bytes in size, it is rounded up to 4 bytes
- ** by the various routines that manipulate binary cells. Which
- ** can mean that fillInCell() only initializes the first 2 or 3
- ** bytes of pTmpSpace, but that the first 4 bytes are copied from
- ** it into a database page. This is not actually a problem, but it
- ** does cause a valgrind error when the 1 or 2 bytes of unitialized
- ** data is passed to system call write(). So to avoid this error,
- ** zero the first 4 bytes of temp space here.
- **
- ** Also: Provide four bytes of initialized space before the
- ** beginning of pTmpSpace as an area available to prepend the
- ** left-child pointer to the beginning of a cell.
- */
- if( pBt->pTmpSpace ){
- memset(pBt->pTmpSpace, 0, 8);
- pBt->pTmpSpace += 4;
- }
+static SQLITE_NOINLINE int allocateTempSpace(BtShared *pBt){
+ assert( pBt!=0 );
+ assert( pBt->pTmpSpace==0 );
+ /* This routine is called only by btreeCursor() when allocating the
+ ** first write cursor for the BtShared object */
+ assert( pBt->pCursor!=0 && (pBt->pCursor->curFlags & BTCF_WriteFlag)!=0 );
+ pBt->pTmpSpace = sqlite3PageMalloc( pBt->pageSize );
+ if( pBt->pTmpSpace==0 ){
+ BtCursor *pCur = pBt->pCursor;
+ pBt->pCursor = pCur->pNext; /* Unlink the cursor */
+ memset(pCur, 0, sizeof(*pCur));
+ return SQLITE_NOMEM_BKPT;
}
+
+ /* One of the uses of pBt->pTmpSpace is to format cells before
+ ** inserting them into a leaf page (function fillInCell()). If
+ ** a cell is less than 4 bytes in size, it is rounded up to 4 bytes
+ ** by the various routines that manipulate binary cells. Which
+ ** can mean that fillInCell() only initializes the first 2 or 3
+ ** bytes of pTmpSpace, but that the first 4 bytes are copied from
+ ** it into a database page. This is not actually a problem, but it
+ ** does cause a valgrind error when the 1 or 2 bytes of unitialized
+ ** data is passed to system call write(). So to avoid this error,
+ ** zero the first 4 bytes of temp space here.
+ **
+ ** Also: Provide four bytes of initialized space before the
+ ** beginning of pTmpSpace as an area available to prepend the
+ ** left-child pointer to the beginning of a cell.
+ */
+ memset(pBt->pTmpSpace, 0, 8);
+ pBt->pTmpSpace += 4;
+ return SQLITE_OK;
}
/*
@@ -68785,9 +69380,13 @@ static int lockBtree(BtShared *pBt){
pageSize-usableSize);
return rc;
}
- if( sqlite3WritableSchema(pBt->db)==0 && nPage>nPageFile ){
- rc = SQLITE_CORRUPT_BKPT;
- goto page1_init_failed;
+ if( nPage>nPageFile ){
+ if( sqlite3WritableSchema(pBt->db)==0 ){
+ rc = SQLITE_CORRUPT_BKPT;
+ goto page1_init_failed;
+ }else{
+ nPage = nPageFile;
+ }
}
/* EVIDENCE-OF: R-28312-64704 However, the usable size is not allowed to
** be less than 480. In other words, if the page size is 512, then the
@@ -69817,7 +70416,7 @@ static void btreeSetNPage(BtShared *pBt, MemPage *pPage1){
int nPage = get4byte(&pPage1->aData[28]);
testcase( nPage==0 );
if( nPage==0 ) sqlite3PagerPagecount(pBt->pPager, &nPage);
- testcase( pBt->nPage!=nPage );
+ testcase( pBt->nPage!=(u32)nPage );
pBt->nPage = nPage;
}
@@ -70029,10 +70628,6 @@ static int btreeCursor(
assert( pBt->pPage1 && pBt->pPage1->aData );
assert( wrFlag==0 || (pBt->btsFlags & BTS_READ_ONLY)==0 );
- if( wrFlag ){
- allocateTempSpace(pBt);
- if( pBt->pTmpSpace==0 ) return SQLITE_NOMEM_BKPT;
- }
if( iTable<=1 ){
if( iTable<1 ){
return SQLITE_CORRUPT_BKPT;
@@ -70049,19 +70644,25 @@ static int btreeCursor(
pCur->pKeyInfo = pKeyInfo;
pCur->pBtree = p;
pCur->pBt = pBt;
- pCur->curFlags = wrFlag ? BTCF_WriteFlag : 0;
- pCur->curPagerFlags = wrFlag ? 0 : PAGER_GET_READONLY;
+ pCur->curFlags = 0;
/* If there are two or more cursors on the same btree, then all such
** cursors *must* have the BTCF_Multiple flag set. */
for(pX=pBt->pCursor; pX; pX=pX->pNext){
if( pX->pgnoRoot==iTable ){
pX->curFlags |= BTCF_Multiple;
- pCur->curFlags |= BTCF_Multiple;
+ pCur->curFlags = BTCF_Multiple;
}
}
+ pCur->eState = CURSOR_INVALID;
pCur->pNext = pBt->pCursor;
pBt->pCursor = pCur;
- pCur->eState = CURSOR_INVALID;
+ if( wrFlag ){
+ pCur->curFlags |= BTCF_WriteFlag;
+ pCur->curPagerFlags = 0;
+ if( pBt->pTmpSpace==0 ) return allocateTempSpace(pBt);
+ }else{
+ pCur->curPagerFlags = PAGER_GET_READONLY;
+ }
return SQLITE_OK;
}
static int btreeCursorWithLock(
@@ -70836,7 +71437,7 @@ static int moveToRoot(BtCursor *pCur){
while( --pCur->iPage ){
releasePageNotNull(pCur->apPage[pCur->iPage]);
}
- pCur->pPage = pCur->apPage[0];
+ pRoot = pCur->pPage = pCur->apPage[0];
goto skip_init;
}
}else if( pCur->pgnoRoot==0 ){
@@ -70861,7 +71462,7 @@ static int moveToRoot(BtCursor *pCur){
pCur->curIntKey = pCur->pPage->intKey;
}
pRoot = pCur->pPage;
- assert( pRoot->pgno==pCur->pgnoRoot );
+ assert( pRoot->pgno==pCur->pgnoRoot || CORRUPT_DB );
/* If pCur->pKeyInfo is not NULL, then the caller that opened this cursor
** expected to open it on an index b-tree. Otherwise, if pKeyInfo is
@@ -70883,7 +71484,6 @@ skip_init:
pCur->info.nSize = 0;
pCur->curFlags &= ~(BTCF_AtLast|BTCF_ValidNKey|BTCF_ValidOvfl);
- pRoot = pCur->pPage;
if( pRoot->nCell>0 ){
pCur->eState = CURSOR_VALID;
}else if( !pRoot->leaf ){
@@ -71124,7 +71724,6 @@ SQLITE_PRIVATE int sqlite3BtreeTableMoveto(
upr = pPage->nCell-1;
assert( biasRight==0 || biasRight==1 );
idx = upr>>(1-biasRight); /* idx = biasRight ? upr : (lwr+upr)/2; */
- pCur->ix = (u16)idx;
for(;;){
i64 nCellKey;
pCell = findCellPastPtr(pPage, idx);
@@ -71266,7 +71865,6 @@ SQLITE_PRIVATE int sqlite3BtreeIndexMoveto(
lwr = 0;
upr = pPage->nCell-1;
idx = upr>>1; /* idx = (lwr+upr)/2; */
- pCur->ix = (u16)idx;
for(;;){
int nCell; /* Size of the pCell cell in bytes */
pCell = findCellPastPtr(pPage, idx);
@@ -71958,7 +72556,7 @@ static int freePage2(BtShared *pBt, MemPage *pMemPage, Pgno iPage){
assert( CORRUPT_DB || iPage>1 );
assert( !pMemPage || pMemPage->pgno==iPage );
- if( NEVER(iPage<2) || iPage>pBt->nPage ){
+ if( iPage<2 || iPage>pBt->nPage ){
return SQLITE_CORRUPT_BKPT;
}
if( pMemPage ){
@@ -72382,16 +72980,24 @@ static void dropCell(MemPage *pPage, int idx, int sz, int *pRC){
int hdr; /* Beginning of the header. 0 most pages. 100 page 1 */
if( *pRC ) return;
- assert( idx>=0 && idx<pPage->nCell );
+ assert( idx>=0 );
+ assert( idx<pPage->nCell );
assert( CORRUPT_DB || sz==cellSize(pPage, idx) );
assert( sqlite3PagerIswriteable(pPage->pDbPage) );
assert( sqlite3_mutex_held(pPage->pBt->mutex) );
assert( pPage->nFree>=0 );
data = pPage->aData;
ptr = &pPage->aCellIdx[2*idx];
+ assert( pPage->pBt->usableSize > (u32)(ptr-data) );
pc = get2byte(ptr);
hdr = pPage->hdrOffset;
- testcase( pc==get2byte(&data[hdr+5]) );
+#if 0 /* Not required. Omit for efficiency */
+ if( pc<hdr+pPage->nCell*2 ){
+ *pRC = SQLITE_CORRUPT_BKPT;
+ return;
+ }
+#endif
+ testcase( pc==(u32)get2byte(&data[hdr+5]) );
testcase( pc+sz==pPage->pBt->usableSize );
if( pc+sz > pPage->pBt->usableSize ){
*pRC = SQLITE_CORRUPT_BKPT;
@@ -72683,7 +73289,7 @@ static int rebuildPage(
assert( i<iEnd );
j = get2byte(&aData[hdr+5]);
- if( NEVER(j>(u32)usableSize) ){ j = 0; }
+ if( j>(u32)usableSize ){ j = 0; }
memcpy(&pTmp[j], &aData[j], usableSize - j);
for(k=0; pCArray->ixNx[k]<=i && ALWAYS(k<NB*2); k++){}
@@ -72914,7 +73520,7 @@ static int editPage(
pData = &aData[get2byteNotZero(&aData[hdr+5])];
if( pData<pBegin ) goto editpage_fail;
- if( NEVER(pData>pPg->aDataEnd) ) goto editpage_fail;
+ if( pData>pPg->aDataEnd ) goto editpage_fail;
/* Add cells to the start of the page */
if( iNew<iOld ){
@@ -74524,7 +75130,7 @@ SQLITE_PRIVATE int sqlite3BtreeInsert(
assert( pPage->intKey || pX->nKey>=0 || (flags & BTREE_PREFORMAT) );
assert( pPage->leaf || !pPage->intKey );
if( pPage->nFree<0 ){
- if( NEVER(pCur->eState>CURSOR_INVALID) ){
+ if( pCur->eState>CURSOR_INVALID ){
rc = SQLITE_CORRUPT_BKPT;
}else{
rc = btreeComputeFreeSpace(pPage);
@@ -74790,14 +75396,13 @@ SQLITE_PRIVATE int sqlite3BtreeTransferRow(BtCursor *pDest, BtCursor *pSrc, i64
SQLITE_PRIVATE int sqlite3BtreeDelete(BtCursor *pCur, u8 flags){
Btree *p = pCur->pBtree;
BtShared *pBt = p->pBt;
- int rc; /* Return code */
- MemPage *pPage; /* Page to delete cell from */
- unsigned char *pCell; /* Pointer to cell to delete */
- int iCellIdx; /* Index of cell to delete */
- int iCellDepth; /* Depth of node containing pCell */
- CellInfo info; /* Size of the cell being deleted */
- int bSkipnext = 0; /* Leaf cursor in SKIPNEXT state */
- u8 bPreserve = flags & BTREE_SAVEPOSITION; /* Keep cursor valid */
+ int rc; /* Return code */
+ MemPage *pPage; /* Page to delete cell from */
+ unsigned char *pCell; /* Pointer to cell to delete */
+ int iCellIdx; /* Index of cell to delete */
+ int iCellDepth; /* Depth of node containing pCell */
+ CellInfo info; /* Size of the cell being deleted */
+ u8 bPreserve; /* Keep cursor valid. 2 for CURSOR_SKIPNEXT */
assert( cursorOwnsBtShared(pCur) );
assert( pBt->inTransaction==TRANS_WRITE );
@@ -74816,18 +75421,31 @@ SQLITE_PRIVATE int sqlite3BtreeDelete(BtCursor *pCur, u8 flags){
iCellDepth = pCur->iPage;
iCellIdx = pCur->ix;
pPage = pCur->pPage;
+ if( pPage->nCell<=iCellIdx ){
+ return SQLITE_CORRUPT_BKPT;
+ }
pCell = findCell(pPage, iCellIdx);
- if( pPage->nFree<0 && btreeComputeFreeSpace(pPage) ) return SQLITE_CORRUPT;
+ if( pPage->nFree<0 && btreeComputeFreeSpace(pPage) ){
+ return SQLITE_CORRUPT_BKPT;
+ }
- /* If the bPreserve flag is set to true, then the cursor position must
+ /* If the BTREE_SAVEPOSITION bit is on, then the cursor position must
** be preserved following this delete operation. If the current delete
** will cause a b-tree rebalance, then this is done by saving the cursor
** key and leaving the cursor in CURSOR_REQUIRESEEK state before
** returning.
**
- ** Or, if the current delete will not cause a rebalance, then the cursor
+ ** If the current delete will not cause a rebalance, then the cursor
** will be left in CURSOR_SKIPNEXT state pointing to the entry immediately
- ** before or after the deleted entry. In this case set bSkipnext to true. */
+ ** before or after the deleted entry.
+ **
+ ** The bPreserve value records which path is required:
+ **
+ ** bPreserve==0 Not necessary to save the cursor position
+ ** bPreserve==1 Use CURSOR_REQUIRESEEK to save the cursor position
+ ** bPreserve==2 Cursor won't move. Set CURSOR_SKIPNEXT.
+ */
+ bPreserve = (flags & BTREE_SAVEPOSITION)!=0;
if( bPreserve ){
if( !pPage->leaf
|| (pPage->nFree+cellSizePtr(pPage,pCell)+2)>(int)(pBt->usableSize*2/3)
@@ -74838,7 +75456,7 @@ SQLITE_PRIVATE int sqlite3BtreeDelete(BtCursor *pCur, u8 flags){
rc = saveCursorKey(pCur);
if( rc ) return rc;
}else{
- bSkipnext = 1;
+ bPreserve = 2;
}
}
@@ -74938,8 +75556,8 @@ SQLITE_PRIVATE int sqlite3BtreeDelete(BtCursor *pCur, u8 flags){
}
if( rc==SQLITE_OK ){
- if( bSkipnext ){
- assert( bPreserve && (pCur->iPage==iCellDepth || CORRUPT_DB) );
+ if( bPreserve>1 ){
+ assert( (pCur->iPage==iCellDepth || CORRUPT_DB) );
assert( pPage==pCur->pPage || CORRUPT_DB );
assert( (pPage->nCell>0 || CORRUPT_DB) && iCellIdx<=pPage->nCell );
pCur->eState = CURSOR_SKIPNEXT;
@@ -75149,7 +75767,7 @@ static int clearDatabasePage(
rc = getAndInitPage(pBt, pgno, &pPage, 0, 0);
if( rc ) return rc;
if( (pBt->openFlags & BTREE_SINGLE)==0
- && sqlite3PagerPageRefcount(pPage->pDbPage)!=1
+ && sqlite3PagerPageRefcount(pPage->pDbPage) != (1 + (pgno==1))
){
rc = SQLITE_CORRUPT_BKPT;
goto cleardatabasepage_out;
@@ -76529,14 +77147,13 @@ static Btree *findBtree(sqlite3 *pErrorDb, sqlite3 *pDb, const char *zDb){
if( i==1 ){
Parse sParse;
int rc = 0;
- memset(&sParse, 0, sizeof(sParse));
- sParse.db = pDb;
+ sqlite3ParseObjectInit(&sParse,pDb);
if( sqlite3OpenTempDatabase(&sParse) ){
sqlite3ErrorWithMsg(pErrorDb, sParse.rc, "%s", sParse.zErrMsg);
rc = SQLITE_ERROR;
}
sqlite3DbFree(pErrorDb, sParse.zErrMsg);
- sqlite3ParserReset(&sParse);
+ sqlite3ParseObjectReset(&sParse);
if( rc ){
return 0;
}
@@ -77814,12 +78431,12 @@ static SQLITE_NOINLINE i64 doubleToInt64(double r){
**
** If pMem represents a string value, its encoding might be changed.
*/
-static SQLITE_NOINLINE i64 memIntValue(Mem *pMem){
+static SQLITE_NOINLINE i64 memIntValue(const Mem *pMem){
i64 value = 0;
sqlite3Atoi64(pMem->z, &value, pMem->n, pMem->enc);
return value;
}
-SQLITE_PRIVATE i64 sqlite3VdbeIntValue(Mem *pMem){
+SQLITE_PRIVATE i64 sqlite3VdbeIntValue(const Mem *pMem){
int flags;
assert( pMem!=0 );
assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
@@ -78134,6 +78751,7 @@ SQLITE_PRIVATE void sqlite3VdbeMemSetPointer(
void (*xDestructor)(void*)
){
assert( pMem->flags==MEM_Null );
+ vdbeMemClear(pMem);
pMem->u.zPType = zPType ? zPType : "";
pMem->z = pPtr;
pMem->flags = MEM_Null|MEM_Dyn|MEM_Subtype|MEM_Term;
@@ -78748,11 +79366,7 @@ static int valueFromExpr(
assert( pExpr!=0 );
while( (op = pExpr->op)==TK_UPLUS || op==TK_SPAN ) pExpr = pExpr->pLeft;
-#if defined(SQLITE_ENABLE_STAT4)
if( op==TK_REGISTER ) op = pExpr->op2;
-#else
- if( NEVER(op==TK_REGISTER) ) op = pExpr->op2;
-#endif
/* Compressed expressions only appear when parsing the DEFAULT clause
** on a table column definition, and hence only when pCtx==0. This
@@ -78867,7 +79481,7 @@ static int valueFromExpr(
no_mem:
#ifdef SQLITE_ENABLE_STAT4
- if( pCtx==0 || pCtx->pParse->nErr==0 )
+ if( pCtx==0 || NEVER(pCtx->pParse->nErr==0) )
#endif
sqlite3OomFault(db);
sqlite3DbFree(db, zVal);
@@ -80545,8 +81159,7 @@ SQLITE_PRIVATE void sqlite3VdbeSetP4KeyInfo(Parse *pParse, Index *pIdx){
*/
static void vdbeVComment(Vdbe *p, const char *zFormat, va_list ap){
assert( p->nOp>0 || p->aOp==0 );
- assert( p->aOp==0 || p->aOp[p->nOp-1].zComment==0 || p->db->mallocFailed
- || p->pParse->nErr>0 );
+ assert( p->aOp==0 || p->aOp[p->nOp-1].zComment==0 || p->pParse->nErr>0 );
if( p->nOp ){
assert( p->aOp );
sqlite3DbFree(p->db, p->aOp[p->nOp-1].zComment);
@@ -81637,8 +82250,6 @@ SQLITE_PRIVATE void sqlite3VdbeFreeCursor(Vdbe *p, VdbeCursor *pCx){
if( pCx==0 ){
return;
}
- assert( pCx->pBtx==0 || pCx->eCurType==CURTYPE_BTREE );
- assert( pCx->pBtx==0 || pCx->isEphemeral );
switch( pCx->eCurType ){
case CURTYPE_SORTER: {
sqlite3VdbeSorterClose(p->db, pCx);
@@ -82419,6 +83030,7 @@ SQLITE_PRIVATE int sqlite3VdbeTransferError(Vdbe *p){
sqlite3ValueSetNull(db->pErr);
}
db->errCode = rc;
+ db->errByteOffset = -1;
return rc;
}
@@ -82740,7 +83352,7 @@ SQLITE_PRIVATE int sqlite3VdbeCursorMoveto(VdbeCursor **pp, u32 *piCol){
if( p->deferredMoveto ){
u32 iMap;
assert( !p->isEphemeral );
- if( p->aAltMap && (iMap = p->aAltMap[1+*piCol])>0 && !p->nullRow ){
+ if( p->ub.aAltMap && (iMap = p->ub.aAltMap[1+*piCol])>0 && !p->nullRow ){
*pp = p->pAltCursor;
*piCol = iMap - 1;
return SQLITE_OK;
@@ -83018,14 +83630,14 @@ SQLITE_PRIVATE u32 sqlite3VdbeSerialPut(u8 *buf, Mem *pMem, u32 serial_type){
/*
** Deserialize the data blob pointed to by buf as serial type serial_type
-** and store the result in pMem. Return the number of bytes read.
+** and store the result in pMem.
**
** This function is implemented as two separate routines for performance.
** The few cases that require local variables are broken out into a separate
** routine so that in most cases the overhead of moving the stack pointer
** is avoided.
*/
-static u32 serialGet(
+static void serialGet(
const unsigned char *buf, /* Buffer to deserialize from */
u32 serial_type, /* Serial type to deserialize */
Mem *pMem /* Memory cell to write value into */
@@ -83059,9 +83671,8 @@ static u32 serialGet(
memcpy(&pMem->u.r, &x, sizeof(x));
pMem->flags = IsNaN(x) ? MEM_Null : MEM_Real;
}
- return 8;
}
-SQLITE_PRIVATE u32 sqlite3VdbeSerialGet(
+SQLITE_PRIVATE void sqlite3VdbeSerialGet(
const unsigned char *buf, /* Buffer to deserialize from */
u32 serial_type, /* Serial type to deserialize */
Mem *pMem /* Memory cell to write value into */
@@ -83072,13 +83683,13 @@ SQLITE_PRIVATE u32 sqlite3VdbeSerialGet(
pMem->flags = MEM_Null|MEM_Zero;
pMem->n = 0;
pMem->u.nZero = 0;
- break;
+ return;
}
case 11: /* Reserved for future use */
case 0: { /* Null */
/* EVIDENCE-OF: R-24078-09375 Value is a NULL. */
pMem->flags = MEM_Null;
- break;
+ return;
}
case 1: {
/* EVIDENCE-OF: R-44885-25196 Value is an 8-bit twos-complement
@@ -83086,7 +83697,7 @@ SQLITE_PRIVATE u32 sqlite3VdbeSerialGet(
pMem->u.i = ONE_BYTE_INT(buf);
pMem->flags = MEM_Int;
testcase( pMem->u.i<0 );
- return 1;
+ return;
}
case 2: { /* 2-byte signed integer */
/* EVIDENCE-OF: R-49794-35026 Value is a big-endian 16-bit
@@ -83094,7 +83705,7 @@ SQLITE_PRIVATE u32 sqlite3VdbeSerialGet(
pMem->u.i = TWO_BYTE_INT(buf);
pMem->flags = MEM_Int;
testcase( pMem->u.i<0 );
- return 2;
+ return;
}
case 3: { /* 3-byte signed integer */
/* EVIDENCE-OF: R-37839-54301 Value is a big-endian 24-bit
@@ -83102,7 +83713,7 @@ SQLITE_PRIVATE u32 sqlite3VdbeSerialGet(
pMem->u.i = THREE_BYTE_INT(buf);
pMem->flags = MEM_Int;
testcase( pMem->u.i<0 );
- return 3;
+ return;
}
case 4: { /* 4-byte signed integer */
/* EVIDENCE-OF: R-01849-26079 Value is a big-endian 32-bit
@@ -83114,7 +83725,7 @@ SQLITE_PRIVATE u32 sqlite3VdbeSerialGet(
#endif
pMem->flags = MEM_Int;
testcase( pMem->u.i<0 );
- return 4;
+ return;
}
case 5: { /* 6-byte signed integer */
/* EVIDENCE-OF: R-50385-09674 Value is a big-endian 48-bit
@@ -83122,13 +83733,14 @@ SQLITE_PRIVATE u32 sqlite3VdbeSerialGet(
pMem->u.i = FOUR_BYTE_UINT(buf+2) + (((i64)1)<<32)*TWO_BYTE_INT(buf);
pMem->flags = MEM_Int;
testcase( pMem->u.i<0 );
- return 6;
+ return;
}
case 6: /* 8-byte signed integer */
case 7: { /* IEEE floating point */
/* These use local variables, so do them in a separate routine
** to avoid having to move the frame pointer in the common case */
- return serialGet(buf,serial_type,pMem);
+ serialGet(buf,serial_type,pMem);
+ return;
}
case 8: /* Integer 0 */
case 9: { /* Integer 1 */
@@ -83136,7 +83748,7 @@ SQLITE_PRIVATE u32 sqlite3VdbeSerialGet(
/* EVIDENCE-OF: R-18143-12121 Value is the integer 1. */
pMem->u.i = serial_type-8;
pMem->flags = MEM_Int;
- return 0;
+ return;
}
default: {
/* EVIDENCE-OF: R-14606-31564 Value is a BLOB that is (N-12)/2 bytes in
@@ -83147,10 +83759,10 @@ SQLITE_PRIVATE u32 sqlite3VdbeSerialGet(
pMem->z = (char *)buf;
pMem->n = (serial_type-12)/2;
pMem->flags = aFlag[serial_type&1];
- return pMem->n;
+ return;
}
}
- return 0;
+ return;
}
/*
** This routine is used to allocate sufficient space for an UnpackedRecord
@@ -83213,7 +83825,8 @@ SQLITE_PRIVATE void sqlite3VdbeRecordUnpack(
/* pMem->flags = 0; // sqlite3VdbeSerialGet() will set this for us */
pMem->szMalloc = 0;
pMem->z = 0;
- d += sqlite3VdbeSerialGet(&aKey[d], serial_type, pMem);
+ sqlite3VdbeSerialGet(&aKey[d], serial_type, pMem);
+ d += sqlite3VdbeSerialTypeLen(serial_type);
pMem++;
if( (++u)>=p->nField ) break;
}
@@ -83297,7 +83910,8 @@ static int vdbeRecordCompareDebug(
/* Extract the values to be compared.
*/
- d1 += sqlite3VdbeSerialGet(&aKey1[d1], serial_type1, &mem1);
+ sqlite3VdbeSerialGet(&aKey1[d1], serial_type1, &mem1);
+ d1 += sqlite3VdbeSerialTypeLen(serial_type1);
/* Do the comparison
*/
@@ -84101,7 +84715,7 @@ SQLITE_PRIVATE int sqlite3VdbeIdxRowid(sqlite3 *db, BtCursor *pCur, i64 *rowid){
/* The index entry must begin with a header size */
getVarint32NR((u8*)m.z, szHdr);
testcase( szHdr==3 );
- testcase( szHdr==m.n );
+ testcase( szHdr==(u32)m.n );
testcase( szHdr>0x7fffffff );
assert( m.n>=0 );
if( unlikely(szHdr<3 || szHdr>(unsigned)m.n) ){
@@ -85276,6 +85890,70 @@ SQLITE_API int sqlite3_vtab_nochange(sqlite3_context *p){
}
/*
+** Implementation of sqlite3_vtab_in_first() (if bNext==0) and
+** sqlite3_vtab_in_next() (if bNext!=0).
+*/
+static int valueFromValueList(
+ sqlite3_value *pVal, /* Pointer to the ValueList object */
+ sqlite3_value **ppOut, /* Store the next value from the list here */
+ int bNext /* 1 for _next(). 0 for _first() */
+){
+ int rc;
+ ValueList *pRhs;
+
+ *ppOut = 0;
+ if( pVal==0 ) return SQLITE_MISUSE;
+ pRhs = (ValueList*)sqlite3_value_pointer(pVal, "ValueList");
+ if( pRhs==0 ) return SQLITE_MISUSE;
+ if( bNext ){
+ rc = sqlite3BtreeNext(pRhs->pCsr, 0);
+ }else{
+ int dummy = 0;
+ rc = sqlite3BtreeFirst(pRhs->pCsr, &dummy);
+ assert( rc==SQLITE_OK || sqlite3BtreeEof(pRhs->pCsr) );
+ if( sqlite3BtreeEof(pRhs->pCsr) ) rc = SQLITE_DONE;
+ }
+ if( rc==SQLITE_OK ){
+ u32 sz; /* Size of current row in bytes */
+ Mem sMem; /* Raw content of current row */
+ memset(&sMem, 0, sizeof(sMem));
+ sz = sqlite3BtreePayloadSize(pRhs->pCsr);
+ rc = sqlite3VdbeMemFromBtreeZeroOffset(pRhs->pCsr,(int)sz,&sMem);
+ if( rc==SQLITE_OK ){
+ u8 *zBuf = (u8*)sMem.z;
+ u32 iSerial;
+ sqlite3_value *pOut = pRhs->pOut;
+ int iOff = 1 + getVarint32(&zBuf[1], iSerial);
+ sqlite3VdbeSerialGet(&zBuf[iOff], iSerial, pOut);
+ pOut->enc = ENC(pOut->db);
+ if( (pOut->flags & MEM_Ephem)!=0 && sqlite3VdbeMemMakeWriteable(pOut) ){
+ rc = SQLITE_NOMEM;
+ }else{
+ *ppOut = pOut;
+ }
+ }
+ sqlite3VdbeMemRelease(&sMem);
+ }
+ return rc;
+}
+
+/*
+** Set the iterator value pVal to point to the first value in the set.
+** Set (*ppOut) to point to this value before returning.
+*/
+SQLITE_API int sqlite3_vtab_in_first(sqlite3_value *pVal, sqlite3_value **ppOut){
+ return valueFromValueList(pVal, ppOut, 0);
+}
+
+/*
+** Set the iterator value pVal to point to the next value in the set.
+** Set (*ppOut) to point to this value before returning.
+*/
+SQLITE_API int sqlite3_vtab_in_next(sqlite3_value *pVal, sqlite3_value **ppOut){
+ return valueFromValueList(pVal, ppOut, 1);
+}
+
+/*
** Return the current time for a statement. If the current time
** is requested more than once within the same run of a single prepared
** statement, the exact same time is returned for each invocation regardless
@@ -85959,7 +86637,10 @@ SQLITE_API int sqlite3_bind_value(sqlite3_stmt *pStmt, int i, const sqlite3_valu
break;
}
case SQLITE_FLOAT: {
- rc = sqlite3_bind_double(pStmt, i, pValue->u.r);
+ assert( pValue->flags & (MEM_Real|MEM_IntReal) );
+ rc = sqlite3_bind_double(pStmt, i,
+ (pValue->flags & MEM_Real) ? pValue->u.r : (double)pValue->u.i
+ );
break;
}
case SQLITE_BLOB: {
@@ -86939,7 +87620,6 @@ static VdbeCursor *allocateCursor(
Vdbe *p, /* The virtual machine */
int iCur, /* Index of the new VdbeCursor */
int nField, /* Number of fields in the table or index */
- int iDb, /* Database the cursor belongs to, or -1 */
u8 eCurType /* Type of the new cursor */
){
/* Find the memory cell that will be used to store the blob of memory
@@ -86996,7 +87676,6 @@ static VdbeCursor *allocateCursor(
p->apCsr[iCur] = pCx = (VdbeCursor*)pMem->zMalloc;
memset(pCx, 0, offsetof(VdbeCursor,pAltCursor));
pCx->eCurType = eCurType;
- pCx->iDb = iDb;
pCx->nField = nField;
pCx->aOffset = &pCx->aType[nField];
if( eCurType==CURTYPE_BTREE ){
@@ -87370,6 +88049,29 @@ static Mem *out2Prerelease(Vdbe *p, VdbeOp *pOp){
}
/*
+** Compute a bloom filter hash using pOp->p4.i registers from aMem[] beginning
+** with pOp->p3. Return the hash.
+*/
+static u64 filterHash(const Mem *aMem, const Op *pOp){
+ int i, mx;
+ u64 h = 0;
+
+ assert( pOp->p4type==P4_INT32 );
+ for(i=pOp->p3, mx=i+pOp->p4.i; i<mx; i++){
+ const Mem *p = &aMem[i];
+ if( p->flags & (MEM_Int|MEM_IntReal) ){
+ h += p->u.i;
+ }else if( p->flags & MEM_Real ){
+ h += sqlite3VdbeIntValue(p);
+ }else if( p->flags & (MEM_Str|MEM_Blob) ){
+ h += p->n;
+ if( p->flags & MEM_Zero ) h += p->u.nZero;
+ }
+ }
+ return h;
+}
+
+/*
** Return the symbolic name for the data type of a pMem
*/
static const char *vdbeMemTypeName(Mem *pMem){
@@ -88023,12 +88725,18 @@ case OP_SoftNull: {
** Synopsis: r[P2]=P4 (len=P1)
**
** P4 points to a blob of data P1 bytes long. Store this
-** blob in register P2.
+** blob in register P2. If P4 is a NULL pointer, then construct
+** a zero-filled blob that is P1 bytes long in P2.
*/
case OP_Blob: { /* out2 */
assert( pOp->p1 <= SQLITE_MAX_LENGTH );
pOut = out2Prerelease(p, pOp);
- sqlite3VdbeMemSetStr(pOut, pOp->p4.z, pOp->p1, 0, 0);
+ if( pOp->p4.z==0 ){
+ sqlite3VdbeMemSetZeroBlob(pOut, pOp->p1);
+ if( sqlite3VdbeMemExpandBlob(pOut) ) goto no_mem;
+ }else{
+ sqlite3VdbeMemSetStr(pOut, pOp->p4.z, pOp->p1, 0, 0);
+ }
pOut->enc = encoding;
UPDATE_MAX_BLOBSIZE(pOut);
break;
@@ -88177,24 +88885,22 @@ case OP_IntCopy: { /* out2 */
break;
}
-/* Opcode: ChngCntRow P1 P2 * * *
-** Synopsis: output=r[P1]
+/* Opcode: FkCheck * * * * *
**
-** Output value in register P1 as the chance count for a DML statement,
-** due to the "PRAGMA count_changes=ON" setting. Or, if there was a
-** foreign key error in the statement, trigger the error now.
+** Halt with an SQLITE_CONSTRAINT error if there are any unresolved
+** foreign key constraint violations. If there are no foreign key
+** constraint violations, this is a no-op.
**
-** This opcode is a variant of OP_ResultRow that checks the foreign key
-** immediate constraint count and throws an error if the count is
-** non-zero. The P2 opcode must be 1.
+** FK constraint violations are also checked when the prepared statement
+** exits. This opcode is used to raise foreign key constraint errors prior
+** to returning results such as a row change count or the result of a
+** RETURNING clause.
*/
-case OP_ChngCntRow: {
- assert( pOp->p2==1 );
+case OP_FkCheck: {
if( (rc = sqlite3VdbeCheckFk(p,0))!=SQLITE_OK ){
goto abort_due_to_error;
}
- /* Fall through to the next case, OP_ResultRow */
- /* no break */ deliberate_fall_through
+ break;
}
/* Opcode: ResultRow P1 P2 * * *
@@ -88832,7 +89538,7 @@ case OP_Ge: { /* same as TK_GE, jump, in1, in3 */
sqlite3VdbeMemStringify(pIn1, encoding, 1);
testcase( (flags1&MEM_Dyn) != (pIn1->flags&MEM_Dyn) );
flags1 = (pIn1->flags & ~MEM_TypeMask) | (flags1 & MEM_TypeMask);
- if( NEVER(pIn1==pIn3) ) flags3 = flags1 | MEM_Str;
+ if( pIn1==pIn3 ) flags3 = flags1 | MEM_Str;
}
if( (flags3 & MEM_Str)==0 && (flags3&(MEM_Int|MEM_Real|MEM_IntReal))!=0 ){
testcase( pIn3->flags & MEM_Int );
@@ -89300,10 +90006,18 @@ case OP_Offset: { /* out3 */
assert( pOp->p1>=0 && pOp->p1<p->nCursor );
pC = p->apCsr[pOp->p1];
pOut = &p->aMem[pOp->p3];
- if( NEVER(pC==0) || pC->eCurType!=CURTYPE_BTREE ){
+ if( pC==0 || pC->eCurType!=CURTYPE_BTREE ){
sqlite3VdbeMemSetNull(pOut);
}else{
- sqlite3VdbeMemSetInt64(pOut, sqlite3BtreeOffset(pC->uc.pCursor));
+ if( pC->deferredMoveto ){
+ rc = sqlite3VdbeFinishMoveto(pC);
+ if( rc ) goto abort_due_to_error;
+ }
+ if( sqlite3BtreeEof(pC->uc.pCursor) ){
+ sqlite3VdbeMemSetNull(pOut);
+ }else{
+ sqlite3VdbeMemSetInt64(pOut, sqlite3BtreeOffset(pC->uc.pCursor));
+ }
}
break;
}
@@ -89362,6 +90076,7 @@ case OP_Column: {
assert( pC!=0 );
assert( p2<(u32)pC->nField );
aOffset = pC->aOffset;
+ assert( aOffset==pC->aType+pC->nField );
assert( pC->eCurType!=CURTYPE_VTAB );
assert( pC->eCurType!=CURTYPE_PSEUDO || pC->nullRow );
assert( pC->eCurType!=CURTYPE_SORTER );
@@ -89657,6 +90372,8 @@ case OP_TypeCheck: {
break;
}
case COLTYPE_REAL: {
+ testcase( (pIn1->flags & (MEM_Real|MEM_IntReal))==MEM_Real );
+ testcase( (pIn1->flags & (MEM_Real|MEM_IntReal))==MEM_IntReal );
if( pIn1->flags & MEM_Int ){
/* When applying REAL affinity, if the result is still an MEM_Int
** that will fit in 6 bytes, then change the type to MEM_IntReal
@@ -89674,7 +90391,7 @@ case OP_TypeCheck: {
pIn1->flags |= MEM_Real;
pIn1->flags &= ~MEM_Int;
}
- }else if( (pIn1->flags & MEM_Real)==0 ){
+ }else if( (pIn1->flags & (MEM_Real|MEM_IntReal))==0 ){
goto vdbe_type_error;
}
break;
@@ -89913,7 +90630,7 @@ case OP_MakeRecord: {
testcase( uu==127 ); testcase( uu==128 );
testcase( uu==32767 ); testcase( uu==32768 );
testcase( uu==8388607 ); testcase( uu==8388608 );
- testcase( uu==2147483647 ); testcase( uu==2147483648 );
+ testcase( uu==2147483647 ); testcase( uu==2147483648LL );
testcase( uu==140737488355327LL ); testcase( uu==140737488355328LL );
if( uu<=127 ){
if( (i&1)==i && file_format>=4 ){
@@ -90041,7 +90758,7 @@ case OP_MakeRecord: {
break;
}
-/* Opcode: Count P1 P2 p3 * *
+/* Opcode: Count P1 P2 P3 * *
** Synopsis: r[P2]=count()
**
** Store the number of entries (an integer value) in the table or index
@@ -90511,6 +91228,7 @@ case OP_SetCookie: {
/* When the schema cookie changes, record the new cookie internally */
pDb->pSchema->schema_cookie = pOp->p3 - pOp->p5;
db->mDbFlags |= DBFLAG_SchemaChange;
+ sqlite3FkClearTriggerCache(db, pOp->p1);
}else if( pOp->p2==BTREE_FILE_FORMAT ){
/* Record changes in the file format */
pDb->pSchema->file_format = pOp->p3;
@@ -90688,8 +91406,9 @@ case OP_OpenWrite:
assert( pOp->p1>=0 );
assert( nField>=0 );
testcase( nField==0 ); /* Table with INTEGER PRIMARY KEY and nothing else */
- pCur = allocateCursor(p, pOp->p1, nField, iDb, CURTYPE_BTREE);
+ pCur = allocateCursor(p, pOp->p1, nField, CURTYPE_BTREE);
if( pCur==0 ) goto no_mem;
+ pCur->iDb = iDb;
pCur->nullRow = 1;
pCur->isOrdered = 1;
pCur->pgnoRoot = p2;
@@ -90731,7 +91450,7 @@ case OP_OpenDup: {
assert( pOrig );
assert( pOrig->isEphemeral ); /* Only ephemeral cursors can be duplicated */
- pCx = allocateCursor(p, pOp->p1, pOrig->nField, -1, CURTYPE_BTREE);
+ pCx = allocateCursor(p, pOp->p1, pOrig->nField, CURTYPE_BTREE);
if( pCx==0 ) goto no_mem;
pCx->nullRow = 1;
pCx->isEphemeral = 1;
@@ -90739,10 +91458,10 @@ case OP_OpenDup: {
pCx->isTable = pOrig->isTable;
pCx->pgnoRoot = pOrig->pgnoRoot;
pCx->isOrdered = pOrig->isOrdered;
- pCx->pBtx = pOrig->pBtx;
+ pCx->ub.pBtx = pOrig->ub.pBtx;
pCx->hasBeenDuped = 1;
pOrig->hasBeenDuped = 1;
- rc = sqlite3BtreeCursor(pCx->pBtx, pCx->pgnoRoot, BTREE_WRCSR,
+ rc = sqlite3BtreeCursor(pCx->ub.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
@@ -90815,16 +91534,16 @@ case OP_OpenEphemeral: {
assert( pCx->isEphemeral );
pCx->seqCount = 0;
pCx->cacheStatus = CACHE_STALE;
- rc = sqlite3BtreeClearTable(pCx->pBtx, pCx->pgnoRoot, 0);
+ rc = sqlite3BtreeClearTable(pCx->ub.pBtx, pCx->pgnoRoot, 0);
}else{
- pCx = allocateCursor(p, pOp->p1, pOp->p2, -1, CURTYPE_BTREE);
+ pCx = allocateCursor(p, pOp->p1, pOp->p2, CURTYPE_BTREE);
if( pCx==0 ) goto no_mem;
pCx->isEphemeral = 1;
- rc = sqlite3BtreeOpen(db->pVfs, 0, db, &pCx->pBtx,
+ rc = sqlite3BtreeOpen(db->pVfs, 0, db, &pCx->ub.pBtx,
BTREE_OMIT_JOURNAL | BTREE_SINGLE | pOp->p5,
vfsFlags);
if( rc==SQLITE_OK ){
- rc = sqlite3BtreeBeginTrans(pCx->pBtx, 1, 0);
+ rc = sqlite3BtreeBeginTrans(pCx->ub.pBtx, 1, 0);
if( rc==SQLITE_OK ){
/* If a transient index is required, create it by calling
** sqlite3BtreeCreateTable() with the BTREE_BLOBKEY flag before
@@ -90833,26 +91552,26 @@ case OP_OpenEphemeral: {
*/
if( (pCx->pKeyInfo = pKeyInfo = pOp->p4.pKeyInfo)!=0 ){
assert( pOp->p4type==P4_KEYINFO );
- rc = sqlite3BtreeCreateTable(pCx->pBtx, &pCx->pgnoRoot,
+ rc = sqlite3BtreeCreateTable(pCx->ub.pBtx, &pCx->pgnoRoot,
BTREE_BLOBKEY | pOp->p5);
if( rc==SQLITE_OK ){
assert( pCx->pgnoRoot==SCHEMA_ROOT+1 );
assert( pKeyInfo->db==db );
assert( pKeyInfo->enc==ENC(db) );
- rc = sqlite3BtreeCursor(pCx->pBtx, pCx->pgnoRoot, BTREE_WRCSR,
+ rc = sqlite3BtreeCursor(pCx->ub.pBtx, pCx->pgnoRoot, BTREE_WRCSR,
pKeyInfo, pCx->uc.pCursor);
}
pCx->isTable = 0;
}else{
pCx->pgnoRoot = SCHEMA_ROOT;
- rc = sqlite3BtreeCursor(pCx->pBtx, SCHEMA_ROOT, BTREE_WRCSR,
+ rc = sqlite3BtreeCursor(pCx->ub.pBtx, SCHEMA_ROOT, BTREE_WRCSR,
0, pCx->uc.pCursor);
pCx->isTable = 1;
}
}
pCx->isOrdered = (pOp->p5!=BTREE_UNORDERED);
if( rc ){
- sqlite3BtreeClose(pCx->pBtx);
+ sqlite3BtreeClose(pCx->ub.pBtx);
}
}
}
@@ -90876,7 +91595,7 @@ case OP_SorterOpen: {
assert( pOp->p1>=0 );
assert( pOp->p2>=0 );
- pCx = allocateCursor(p, pOp->p1, pOp->p2, -1, CURTYPE_SORTER);
+ pCx = allocateCursor(p, pOp->p1, pOp->p2, CURTYPE_SORTER);
if( pCx==0 ) goto no_mem;
pCx->pKeyInfo = pOp->p4.pKeyInfo;
assert( pCx->pKeyInfo->db==db );
@@ -90925,7 +91644,7 @@ case OP_OpenPseudo: {
assert( pOp->p1>=0 );
assert( pOp->p3>=0 );
- pCx = allocateCursor(p, pOp->p1, pOp->p3, -1, CURTYPE_PSEUDO);
+ pCx = allocateCursor(p, pOp->p1, pOp->p3, CURTYPE_PSEUDO);
if( pCx==0 ) goto no_mem;
pCx->nullRow = 1;
pCx->seekResult = pOp->p2;
@@ -92377,6 +93096,10 @@ case OP_Rowid: { /* out2 */
** Move the cursor P1 to a null row. Any OP_Column operations
** that occur while the cursor is on the null row will always
** write a NULL.
+**
+** Or, if P1 is a Pseudo-Cursor (a cursor opened using OP_OpenPseudo)
+** just reset the cache for that cursor. This causes the row of
+** content held by the pseudo-cursor to be reparsed.
*/
case OP_NullRow: {
VdbeCursor *pC;
@@ -92865,9 +93588,9 @@ case OP_IdxRowid: { /* out2 */
pTabCur->movetoTarget = rowid;
pTabCur->deferredMoveto = 1;
assert( pOp->p4type==P4_INTARRAY || pOp->p4.ai==0 );
- pTabCur->aAltMap = pOp->p4.ai;
- assert( !pC->isEphemeral );
assert( !pTabCur->isEphemeral );
+ pTabCur->ub.aAltMap = pOp->p4.ai;
+ assert( !pC->isEphemeral );
pTabCur->pAltCursor = pC;
}else{
pOut = out2Prerelease(p, pOp);
@@ -94389,7 +95112,7 @@ case OP_VOpen: {
pVCur->pVtab = pVtab;
/* Initialize vdbe cursor object */
- pCur = allocateCursor(p, pOp->p1, 0, -1, CURTYPE_VTAB);
+ pCur = allocateCursor(p, pOp->p1, 0, CURTYPE_VTAB);
if( pCur ){
pCur->uc.pVCur = pVCur;
pVtab->nRef++;
@@ -94403,6 +95126,34 @@ case OP_VOpen: {
#endif /* SQLITE_OMIT_VIRTUALTABLE */
#ifndef SQLITE_OMIT_VIRTUALTABLE
+/* Opcode: VInitIn P1 P2 P3 * *
+** Synopsis: r[P2]=ValueList(P1,P3)
+**
+** Set register P2 to be a pointer to a ValueList object for cursor P1
+** with cache register P3 and output register P3+1. This ValueList object
+** can be used as the first argument to sqlite3_vtab_in_first() and
+** sqlite3_vtab_in_next() to extract all of the values stored in the P1
+** cursor. Register P3 is used to hold the values returned by
+** sqlite3_vtab_in_first() and sqlite3_vtab_in_next().
+*/
+case OP_VInitIn: { /* out2 */
+ VdbeCursor *pC; /* The cursor containing the RHS values */
+ ValueList *pRhs; /* New ValueList object to put in reg[P2] */
+
+ pC = p->apCsr[pOp->p1];
+ pRhs = sqlite3_malloc64( sizeof(*pRhs) );
+ if( pRhs==0 ) goto no_mem;
+ pRhs->pCsr = pC->uc.pCursor;
+ pRhs->pOut = &aMem[pOp->p3];
+ pOut = out2Prerelease(p, pOp);
+ pOut->flags = MEM_Null;
+ sqlite3VdbeMemSetPointer(pOut, pRhs, "ValueList", sqlite3_free);
+ break;
+}
+#endif /* SQLITE_OMIT_VIRTUALTABLE */
+
+
+#ifndef SQLITE_OMIT_VIRTUALTABLE
/* Opcode: VFilter P1 P2 P3 P4 *
** Synopsis: iplan=r[P3] zplan='P4'
**
@@ -94827,6 +95578,77 @@ case OP_Function: { /* group */
break;
}
+/* Opcode: FilterAdd P1 * P3 P4 *
+** Synopsis: filter(P1) += key(P3@P4)
+**
+** Compute a hash on the P4 registers starting with r[P3] and
+** add that hash to the bloom filter contained in r[P1].
+*/
+case OP_FilterAdd: {
+ u64 h;
+
+ assert( pOp->p1>0 && pOp->p1<=(p->nMem+1 - p->nCursor) );
+ pIn1 = &aMem[pOp->p1];
+ assert( pIn1->flags & MEM_Blob );
+ assert( pIn1->n>0 );
+ h = filterHash(aMem, pOp);
+#ifdef SQLITE_DEBUG
+ if( db->flags&SQLITE_VdbeTrace ){
+ int ii;
+ for(ii=pOp->p3; ii<pOp->p3+pOp->p4.i; ii++){
+ registerTrace(ii, &aMem[ii]);
+ }
+ printf("hash: %llu modulo %d -> %u\n", h, pIn1->n, (int)(h%pIn1->n));
+ }
+#endif
+ h %= pIn1->n;
+ pIn1->z[h/8] |= 1<<(h&7);
+ break;
+}
+
+/* Opcode: Filter P1 P2 P3 P4 *
+** Synopsis: if key(P3@P4) not in filter(P1) goto P2
+**
+** Compute a hash on the key contained in the P4 registers starting
+** with r[P3]. Check to see if that hash is found in the
+** bloom filter hosted by register P1. If it is not present then
+** maybe jump to P2. Otherwise fall through.
+**
+** False negatives are harmless. It is always safe to fall through,
+** even if the value is in the bloom filter. A false negative causes
+** more CPU cycles to be used, but it should still yield the correct
+** answer. However, an incorrect answer may well arise from a
+** false positive - if the jump is taken when it should fall through.
+*/
+case OP_Filter: { /* jump */
+ u64 h;
+
+ assert( pOp->p1>0 && pOp->p1<=(p->nMem+1 - p->nCursor) );
+ pIn1 = &aMem[pOp->p1];
+ assert( (pIn1->flags & MEM_Blob)!=0 );
+ assert( pIn1->n >= 1 );
+ h = filterHash(aMem, pOp);
+#ifdef SQLITE_DEBUG
+ if( db->flags&SQLITE_VdbeTrace ){
+ int ii;
+ for(ii=pOp->p3; ii<pOp->p3+pOp->p4.i; ii++){
+ registerTrace(ii, &aMem[ii]);
+ }
+ printf("hash: %llu modulo %d -> %u\n", h, pIn1->n, (int)(h%pIn1->n));
+ }
+#endif
+ h %= pIn1->n;
+ if( (pIn1->z[h/8] & (1<<(h&7)))==0 ){
+ VdbeBranchTaken(1, 2);
+ p->aCounter[SQLITE_STMTSTATUS_FILTER_HIT]++;
+ goto jump_to_p2;
+ }else{
+ p->aCounter[SQLITE_STMTSTATUS_FILTER_MISS]++;
+ VdbeBranchTaken(0, 2);
+ }
+ break;
+}
+
/* Opcode: Trace P1 P2 * P4 *
**
** Write P4 on the statement trace output if statement tracing is
@@ -95317,10 +96139,9 @@ SQLITE_API int sqlite3_blob_open(
sqlite3_mutex_enter(db->mutex);
pBlob = (Incrblob *)sqlite3DbMallocZero(db, sizeof(Incrblob));
- do {
- memset(&sParse, 0, sizeof(Parse));
+ while(1){
+ sqlite3ParseObjectInit(&sParse,db);
if( !pBlob ) goto blob_open_out;
- sParse.db = db;
sqlite3DbFree(db, zErr);
zErr = 0;
@@ -95497,7 +96318,9 @@ SQLITE_API int sqlite3_blob_open(
goto blob_open_out;
}
rc = blobSeekToRow(pBlob, iRow, &zErr);
- } while( (++nAttempt)<SQLITE_MAX_SCHEMA_RETRY && rc==SQLITE_SCHEMA );
+ if( (++nAttempt)>=SQLITE_MAX_SCHEMA_RETRY || rc!=SQLITE_SCHEMA ) break;
+ sqlite3ParseObjectReset(&sParse);
+ }
blob_open_out:
if( rc==SQLITE_OK && db->mallocFailed==0 ){
@@ -95508,7 +96331,7 @@ blob_open_out:
}
sqlite3ErrorWithMsg(db, rc, (zErr ? "%s" : 0), zErr);
sqlite3DbFree(db, zErr);
- sqlite3ParserReset(&sParse);
+ sqlite3ParseObjectReset(&sParse);
rc = sqlite3ApiExit(db, rc);
sqlite3_mutex_leave(db->mutex);
return rc;
@@ -96643,7 +97466,8 @@ SQLITE_PRIVATE int sqlite3VdbeSorterInit(
}
#endif
- assert( pCsr->pKeyInfo && pCsr->pBtx==0 );
+ assert( pCsr->pKeyInfo );
+ assert( !pCsr->isEphemeral );
assert( pCsr->eCurType==CURTYPE_SORTER );
szKeyInfo = sizeof(KeyInfo) + (pCsr->pKeyInfo->nKeyField-1)*sizeof(CollSeq*);
sz = sizeof(VdbeSorter) + nWorker * sizeof(SortSubtask);
@@ -99056,6 +99880,9 @@ static int memjrnlCreateFile(MemJournal *p){
}
+/* Forward reference */
+static int memjrnlTruncate(sqlite3_file *pJfd, sqlite_int64 size);
+
/*
** Write data to the file.
*/
@@ -99086,22 +99913,20 @@ static int memjrnlWrite(
** the in-memory journal is being used by a connection using the
** atomic-write optimization. In this case the first 28 bytes of the
** journal file may be written as part of committing the transaction. */
- assert( iOfst==p->endpoint.iOffset || iOfst==0 );
-#if defined(SQLITE_ENABLE_ATOMIC_WRITE) \
- || defined(SQLITE_ENABLE_BATCH_ATOMIC_WRITE)
+ assert( iOfst<=p->endpoint.iOffset );
+ if( iOfst>0 && iOfst!=p->endpoint.iOffset ){
+ memjrnlTruncate(pJfd, iOfst);
+ }
if( iOfst==0 && p->pFirst ){
assert( p->nChunkSize>iAmt );
memcpy((u8*)p->pFirst->zChunk, zBuf, iAmt);
- }else
-#else
- assert( iOfst>0 || p->pFirst==0 );
-#endif
- {
+ }else{
while( nWrite>0 ){
FileChunk *pChunk = p->endpoint.pChunk;
int iChunkOffset = (int)(p->endpoint.iOffset%p->nChunkSize);
int iSpace = MIN(nWrite, p->nChunkSize - iChunkOffset);
+ assert( pChunk!=0 || iChunkOffset==0 );
if( iChunkOffset==0 ){
/* New chunk is required to extend the file. */
FileChunk *pNew = sqlite3_malloc(fileChunkSize(p->nChunkSize));
@@ -99116,10 +99941,11 @@ static int memjrnlWrite(
assert( !p->pFirst );
p->pFirst = pNew;
}
- p->endpoint.pChunk = pNew;
+ pChunk = p->endpoint.pChunk = pNew;
}
- memcpy((u8*)p->endpoint.pChunk->zChunk + iChunkOffset, zWrite, iSpace);
+ assert( pChunk!=0 );
+ memcpy((u8*)pChunk->zChunk + iChunkOffset, zWrite, iSpace);
zWrite += iSpace;
nWrite -= iSpace;
p->endpoint.iOffset += iSpace;
@@ -99143,7 +99969,7 @@ static int memjrnlTruncate(sqlite3_file *pJfd, sqlite_int64 size){
p->pFirst = 0;
}else{
i64 iOff = p->nChunkSize;
- for(pIter=p->pFirst; ALWAYS(pIter) && iOff<=size; pIter=pIter->pNext){
+ for(pIter=p->pFirst; ALWAYS(pIter) && iOff<size; pIter=pIter->pNext){
iOff += p->nChunkSize;
}
if( ALWAYS(pIter) ){
@@ -99897,8 +100723,9 @@ static int lookupName(
}
if( hit || zTab==0 ) continue;
}
- if( zDb && pTab->pSchema!=pSchema ){
- continue;
+ if( zDb ){
+ if( pTab->pSchema!=pSchema ) continue;
+ if( pSchema==0 && strcmp(zDb,"*")!=0 ) continue;
}
if( zTab ){
const char *zTabName = pItem->zAlias ? pItem->zAlias : pTab->zName;
@@ -100029,6 +100856,7 @@ static int lookupName(
pExpr->y.pTab = pTab;
if( pParse->bReturning ){
eNewExprOp = TK_REGISTER;
+ pExpr->op2 = TK_COLUMN;
pExpr->iTable = pNC->uNC.iBaseReg + (pTab->nCol+1)*pExpr->iTable +
sqlite3TableColumnToStorage(pTab, iCol) + 1;
}else{
@@ -100195,6 +101023,7 @@ static int lookupName(
}else{
sqlite3ErrorMsg(pParse, "%s: %s", zErr, zCol);
}
+ sqlite3RecordErrorOffsetOfExpr(pParse->db, pExpr);
pParse->checkSchema = 1;
pTopNC->nNcErr++;
}
@@ -100303,7 +101132,8 @@ static void notValidImpl(
Parse *pParse, /* Leave error message here */
NameContext *pNC, /* The name context */
const char *zMsg, /* Type of error */
- Expr *pExpr /* Invalidate this expression on error */
+ Expr *pExpr, /* Invalidate this expression on error */
+ Expr *pError /* Associate error with this expression */
){
const char *zIn = "partial index WHERE clauses";
if( pNC->ncFlags & NC_IdxExpr ) zIn = "index expressions";
@@ -100315,10 +101145,11 @@ static void notValidImpl(
#endif
sqlite3ErrorMsg(pParse, "%s prohibited in %s", zMsg, zIn);
if( pExpr ) pExpr->op = TK_NULL;
+ sqlite3RecordErrorOffsetOfExpr(pParse->db, pError);
}
-#define sqlite3ResolveNotValid(P,N,M,X,E) \
+#define sqlite3ResolveNotValid(P,N,M,X,E,R) \
assert( ((X)&~(NC_IsCheck|NC_PartIdx|NC_IdxExpr|NC_GenCol))==0 ); \
- if( ((N)->ncFlags & (X))!=0 ) notValidImpl(P,N,M,E);
+ if( ((N)->ncFlags & (X))!=0 ) notValidImpl(P,N,M,E,R);
/*
** Expression p should encode a floating point value between 1.0 and 0.0.
@@ -100453,7 +101284,7 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
testcase( pNC->ncFlags & NC_IdxExpr );
testcase( pNC->ncFlags & NC_GenCol );
sqlite3ResolveNotValid(pParse, pNC, "the \".\" operator",
- NC_IdxExpr|NC_GenCol, 0);
+ NC_IdxExpr|NC_GenCol, 0, pExpr);
pRight = pExpr->pRight;
if( pRight->op==TK_ID ){
zDb = 0;
@@ -100484,7 +101315,6 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
int no_such_func = 0; /* True if no such function exists */
int wrong_num_args = 0; /* True if wrong number of arguments */
int is_agg = 0; /* True if is an aggregate function */
- int nId; /* Number of characters in function name */
const char *zId; /* The function name. */
FuncDef *pDef; /* Information about the function */
u8 enc = ENC(pParse->db); /* The database encoding */
@@ -100494,7 +101324,6 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
#endif
assert( !ExprHasProperty(pExpr, EP_xIsSelect|EP_IntValue) );
zId = pExpr->u.zToken;
- nId = sqlite3Strlen30(zId);
pDef = sqlite3FindFunction(pParse->db, zId, n, enc, 0);
if( pDef==0 ){
pDef = sqlite3FindFunction(pParse->db, zId, -2, enc, 0);
@@ -100511,8 +101340,8 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
pExpr->iTable = exprProbability(pList->a[1].pExpr);
if( pExpr->iTable<0 ){
sqlite3ErrorMsg(pParse,
- "second argument to likelihood() must be a "
- "constant between 0.0 and 1.0");
+ "second argument to %#T() must be a "
+ "constant between 0.0 and 1.0", pExpr);
pNC->nNcErr++;
}
}else{
@@ -100533,8 +101362,8 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
int auth = sqlite3AuthCheck(pParse, SQLITE_FUNCTION, 0,pDef->zName,0);
if( auth!=SQLITE_OK ){
if( auth==SQLITE_DENY ){
- sqlite3ErrorMsg(pParse, "not authorized to use function: %s",
- pDef->zName);
+ sqlite3ErrorMsg(pParse, "not authorized to use function: %#T",
+ pExpr);
pNC->nNcErr++;
}
pExpr->op = TK_NULL;
@@ -100557,7 +101386,7 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
** in a CHECK constraint. SQLServer, MySQL, and PostgreSQL all
** all this. */
sqlite3ResolveNotValid(pParse, pNC, "non-deterministic functions",
- NC_IdxExpr|NC_PartIdx|NC_GenCol, 0);
+ NC_IdxExpr|NC_PartIdx|NC_GenCol, 0, pExpr);
}else{
assert( (NC_SelfRef & 0xff)==NC_SelfRef ); /* Must fit in 8 bits */
pExpr->op2 = pNC->ncFlags & NC_SelfRef;
@@ -100570,7 +101399,7 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
/* Internal-use-only functions are disallowed unless the
** SQL is being compiled using sqlite3NestedParse() or
** the SQLITE_TESTCTRL_INTERNAL_FUNCTIONS test-control has be
- ** used to activate internal functionsn for testing purposes */
+ ** used to activate internal functions for testing purposes */
no_such_func = 1;
pDef = 0;
}else
@@ -100589,7 +101418,7 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
);
if( pDef && pDef->xValue==0 && pWin ){
sqlite3ErrorMsg(pParse,
- "%.*s() may not be used as a window function", nId, zId
+ "%#T() may not be used as a window function", pExpr
);
pNC->nNcErr++;
}else if(
@@ -100603,13 +101432,13 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
}else{
zType = "aggregate";
}
- sqlite3ErrorMsg(pParse, "misuse of %s function %.*s()",zType,nId,zId);
+ sqlite3ErrorMsg(pParse, "misuse of %s function %#T()",zType,pExpr);
pNC->nNcErr++;
is_agg = 0;
}
#else
if( (is_agg && (pNC->ncFlags & NC_AllowAgg)==0) ){
- sqlite3ErrorMsg(pParse,"misuse of aggregate function %.*s()",nId,zId);
+ sqlite3ErrorMsg(pParse,"misuse of aggregate function %#T()",pExpr);
pNC->nNcErr++;
is_agg = 0;
}
@@ -100619,18 +101448,18 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
&& pParse->explain==0
#endif
){
- sqlite3ErrorMsg(pParse, "no such function: %.*s", nId, zId);
+ sqlite3ErrorMsg(pParse, "no such function: %#T", pExpr);
pNC->nNcErr++;
}else if( wrong_num_args ){
- sqlite3ErrorMsg(pParse,"wrong number of arguments to function %.*s()",
- nId, zId);
+ sqlite3ErrorMsg(pParse,"wrong number of arguments to function %#T()",
+ pExpr);
pNC->nNcErr++;
}
#ifndef SQLITE_OMIT_WINDOWFUNC
else if( is_agg==0 && ExprHasProperty(pExpr, EP_WinFunc) ){
sqlite3ErrorMsg(pParse,
- "FILTER may not be used with non-aggregate %.*s()",
- nId, zId
+ "FILTER may not be used with non-aggregate %#T()",
+ pExpr
);
pNC->nNcErr++;
}
@@ -100715,7 +101544,7 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
testcase( pNC->ncFlags & NC_IdxExpr );
testcase( pNC->ncFlags & NC_GenCol );
if( pNC->ncFlags & NC_SelfRef ){
- notValidImpl(pParse, pNC, "subqueries", pExpr);
+ notValidImpl(pParse, pNC, "subqueries", pExpr, pExpr);
}else{
sqlite3WalkSelect(pWalker, pExpr->x.pSelect);
}
@@ -100733,7 +101562,7 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
testcase( pNC->ncFlags & NC_IdxExpr );
testcase( pNC->ncFlags & NC_GenCol );
sqlite3ResolveNotValid(pParse, pNC, "parameters",
- NC_IsCheck|NC_PartIdx|NC_IdxExpr|NC_GenCol, pExpr);
+ NC_IsCheck|NC_PartIdx|NC_IdxExpr|NC_GenCol, pExpr, pExpr);
break;
}
case TK_IS:
@@ -100785,11 +101614,13 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
testcase( pExpr->op==TK_ISNOT );
testcase( pExpr->op==TK_BETWEEN );
sqlite3ErrorMsg(pParse, "row value misused");
+ sqlite3RecordErrorOffsetOfExpr(pParse->db, pExpr);
}
break;
}
}
- return (pParse->nErr || pParse->db->mallocFailed) ? WRC_Abort : WRC_Continue;
+ assert( pParse->db->mallocFailed==0 || pParse->nErr!=0 );
+ return pParse->nErr ? WRC_Abort : WRC_Continue;
}
/*
@@ -100897,11 +101728,13 @@ static void resolveOutOfRangeError(
Parse *pParse, /* The error context into which to write the error */
const char *zType, /* "ORDER" or "GROUP" */
int i, /* The index (1-based) of the term out of range */
- int mx /* Largest permissible value of i */
+ int mx, /* Largest permissible value of i */
+ Expr *pError /* Associate the error with the expression */
){
sqlite3ErrorMsg(pParse,
"%r %s BY term out of range - should be "
"between 1 and %d", i, zType, mx);
+ sqlite3RecordErrorOffsetOfExpr(pParse->db, pError);
}
/*
@@ -100957,7 +101790,7 @@ static int resolveCompoundOrderBy(
if( NEVER(pE==0) ) continue;
if( sqlite3ExprIsInteger(pE, &iCol) ){
if( iCol<=0 || iCol>pEList->nExpr ){
- resolveOutOfRangeError(pParse, "ORDER", i+1, pEList->nExpr);
+ resolveOutOfRangeError(pParse, "ORDER", i+1, pEList->nExpr, pE);
return 1;
}
}else{
@@ -101053,7 +101886,7 @@ SQLITE_PRIVATE int sqlite3ResolveOrderGroupBy(
for(i=0, pItem=pOrderBy->a; i<pOrderBy->nExpr; i++, pItem++){
if( pItem->u.x.iOrderByCol ){
if( pItem->u.x.iOrderByCol>pEList->nExpr ){
- resolveOutOfRangeError(pParse, zType, i+1, pEList->nExpr);
+ resolveOutOfRangeError(pParse, zType, i+1, pEList->nExpr, 0);
return 1;
}
resolveAlias(pParse, pEList, pItem->u.x.iOrderByCol-1, pItem->pExpr,0);
@@ -101145,7 +101978,7 @@ static int resolveOrderGroupBy(
** number so that sqlite3ResolveOrderGroupBy() will convert the
** order-by term to a copy of the result-set expression */
if( iCol<1 || iCol>0xffff ){
- resolveOutOfRangeError(pParse, zType, i+1, nResult);
+ resolveOutOfRangeError(pParse, zType, i+1, nResult, pE2);
return 1;
}
pItem->u.x.iOrderByCol = (u16)iCol;
@@ -101203,7 +102036,7 @@ static int resolveSelectStep(Walker *pWalker, Select *p){
*/
if( (p->selFlags & SF_Expanded)==0 ){
sqlite3SelectPrep(pParse, p, pOuterNC);
- return (pParse->nErr || db->mallocFailed) ? WRC_Abort : WRC_Prune;
+ return pParse->nErr ? WRC_Abort : WRC_Prune;
}
isCompound = p->pPrior!=0;
@@ -101251,7 +102084,8 @@ static int resolveSelectStep(Walker *pWalker, Select *p){
if( pItem->zName ) pParse->zAuthContext = pItem->zName;
sqlite3ResolveSelectNames(pParse, pItem->pSelect, pOuterNC);
pParse->zAuthContext = zSavedContext;
- if( pParse->nErr || db->mallocFailed ) return WRC_Abort;
+ if( pParse->nErr ) return WRC_Abort;
+ assert( db->mallocFailed==0 );
/* If the number of references to the outer context changed when
** expressions in the sub-select were resolved, the sub-select
@@ -102397,9 +103231,8 @@ static void heightOfSelect(const Select *pSelect, int *pnHeight){
** if appropriate.
*/
static void exprSetHeight(Expr *p){
- int nHeight = 0;
- heightOfExpr(p->pLeft, &nHeight);
- heightOfExpr(p->pRight, &nHeight);
+ int nHeight = p->pLeft ? p->pLeft->nHeight : 0;
+ if( p->pRight && p->pRight->nHeight>nHeight ) nHeight = p->pRight->nHeight;
if( ExprUseXSelect(p) ){
heightOfSelect(p->x.pSelect, &nHeight);
}else if( p->x.pList ){
@@ -102698,6 +103531,7 @@ SQLITE_PRIVATE Expr *sqlite3ExprFunction(
sqlite3ExprListDelete(db, pList); /* Avoid memory leak when malloc fails */
return 0;
}
+ pNew->w.iOfst = (int)(pToken->z - pParse->zTail);
if( pList
&& pList->nExpr > pParse->db->aLimit[SQLITE_LIMIT_FUNCTION_ARG]
&& !pParse->nested
@@ -102741,7 +103575,7 @@ SQLITE_PRIVATE void sqlite3ExprFunctionUsable(
** SQLITE_DBCONFIG_TRUSTED_SCHEMA is off (meaning
** that the schema is possibly tainted).
*/
- sqlite3ErrorMsg(pParse, "unsafe use of %s()", pDef->zName);
+ sqlite3ErrorMsg(pParse, "unsafe use of %#T()", pExpr);
}
}
}
@@ -102797,6 +103631,7 @@ SQLITE_PRIVATE void sqlite3ExprAssignVarNumber(Parse *pParse, Expr *pExpr, u32 n
if( bOk==0 || i<1 || i>db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER] ){
sqlite3ErrorMsg(pParse, "variable number must be between ?1 and ?%d",
db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER]);
+ sqlite3RecordErrorOffsetOfExpr(pParse->db, pExpr);
return;
}
x = (ynVar)i;
@@ -102824,6 +103659,7 @@ SQLITE_PRIVATE void sqlite3ExprAssignVarNumber(Parse *pParse, Expr *pExpr, u32 n
pExpr->iColumn = x;
if( x>db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER] ){
sqlite3ErrorMsg(pParse, "too many SQL variables");
+ sqlite3RecordErrorOffsetOfExpr(pParse->db, pExpr);
}
}
@@ -104431,8 +105267,7 @@ SQLITE_PRIVATE int sqlite3FindInIndex(
CollSeq *pReq = sqlite3BinaryCompareCollSeq(pParse, pLhs, pRhs);
int j;
- assert( pReq!=0 || pRhs->iColumn==XN_ROWID
- || pParse->nErr || db->mallocFailed );
+ assert( pReq!=0 || pRhs->iColumn==XN_ROWID || pParse->nErr );
for(j=0; j<nExpr; j++){
if( pIdx->aiColumn[j]!=pRhs->iColumn ) continue;
assert( pIdx->azColl[j] );
@@ -104908,10 +105743,8 @@ SQLITE_PRIVATE int sqlite3CodeSubselect(Parse *pParse, Expr *pExpr){
}
pSel->iLimit = 0;
if( sqlite3Select(pParse, pSel, &dest) ){
- if( pParse->nErr ){
- pExpr->op2 = pExpr->op;
- pExpr->op = TK_ERROR;
- }
+ pExpr->op2 = pExpr->op;
+ pExpr->op = TK_ERROR;
return 0;
}
pExpr->iTable = rReg = dest.iSDParm;
@@ -105128,10 +105961,9 @@ static void sqlite3ExprCodeIN(
}else{
destStep2 = destStep6 = sqlite3VdbeMakeLabel(pParse);
}
- if( pParse->nErr ) goto sqlite3ExprCodeIN_finished;
for(i=0; i<nVector; i++){
Expr *p = sqlite3VectorFieldSubexpr(pExpr->pLeft, i);
- if( pParse->db->mallocFailed ) goto sqlite3ExprCodeIN_oom_error;
+ if( pParse->nErr ) goto sqlite3ExprCodeIN_oom_error;
if( sqlite3ExprCanBeNull(p) ){
sqlite3VdbeAddOp2(v, OP_IsNull, rLhs+i, destStep2);
VdbeCoverage(v);
@@ -105269,11 +106101,12 @@ static void codeInteger(Parse *pParse, Expr *pExpr, int negFlag, int iMem){
c = sqlite3DecOrHexToI64(z, &value);
if( (c==3 && !negFlag) || (c==2) || (negFlag && value==SMALLEST_INT64)){
#ifdef SQLITE_OMIT_FLOATING_POINT
- sqlite3ErrorMsg(pParse, "oversized integer: %s%s", negFlag ? "-" : "", z);
+ sqlite3ErrorMsg(pParse, "oversized integer: %s%#T", negFlag?"-":"",pExpr);
#else
#ifndef SQLITE_OMIT_HEX_INTEGER
if( sqlite3_strnicmp(z,"0x",2)==0 ){
- sqlite3ErrorMsg(pParse, "hex literal too big: %s%s", negFlag?"-":"",z);
+ sqlite3ErrorMsg(pParse, "hex literal too big: %s%#T",
+ negFlag?"-":"",pExpr);
}else
#endif
{
@@ -105949,7 +106782,7 @@ expr_code_doover:
|| NEVER(pExpr->iAgg>=pInfo->nFunc)
){
assert( !ExprHasProperty(pExpr, EP_IntValue) );
- sqlite3ErrorMsg(pParse, "misuse of aggregate: %s()", pExpr->u.zToken);
+ sqlite3ErrorMsg(pParse, "misuse of aggregate: %#T()", pExpr);
}else{
return pInfo->aFunc[pExpr->iAgg].iMem;
}
@@ -105990,7 +106823,7 @@ expr_code_doover:
}
#endif
if( pDef==0 || pDef->xFinalize!=0 ){
- sqlite3ErrorMsg(pParse, "unknown function: %s()", zId);
+ sqlite3ErrorMsg(pParse, "unknown function: %#T()", pExpr);
break;
}
if( pDef->funcFlags & SQLITE_FUNC_INLINE ){
@@ -108306,7 +109139,9 @@ SQLITE_PRIVATE void sqlite3AlterFinishAddColumn(Parse *pParse, Token *pColDef){
int r1; /* Temporary registers */
db = pParse->db;
- if( pParse->nErr || db->mallocFailed ) return;
+ assert( db->pParse==pParse );
+ if( pParse->nErr ) return;
+ assert( db->mallocFailed==0 );
pNew = pParse->pNewTable;
assert( pNew );
@@ -108432,7 +109267,7 @@ SQLITE_PRIVATE void sqlite3AlterFinishAddColumn(Parse *pParse, Token *pColDef){
" THEN raise(ABORT,'CHECK constraint failed')"
" ELSE raise(ABORT,'NOT NULL constraint failed')"
" END"
- " FROM pragma_quick_check(\"%w\",\"%w\")"
+ " FROM pragma_quick_check(%Q,%Q)"
" WHERE quick_check GLOB 'CHECK*' OR quick_check GLOB 'NULL*'",
zTab, zDb
);
@@ -108611,7 +109446,7 @@ SQLITE_PRIVATE void sqlite3AlterRenameColumn(
if( 0==sqlite3StrICmp(pTab->aCol[iCol].zCnName, zOld) ) break;
}
if( iCol==pTab->nCol ){
- sqlite3ErrorMsg(pParse, "no such column: \"%s\"", zOld);
+ sqlite3ErrorMsg(pParse, "no such column: \"%T\"", pOld);
goto exit_rename_column;
}
@@ -108717,7 +109552,9 @@ struct RenameCtx {
** following a valid object, it may not be used in comparison operations.
*/
static void renameTokenCheckAll(Parse *pParse, const void *pPtr){
- if( pParse->nErr==0 && pParse->db->mallocFailed==0 ){
+ assert( pParse==pParse->db->pParse );
+ assert( pParse->db->mallocFailed==0 || pParse->nErr!=0 );
+ if( pParse->nErr==0 ){
const RenameToken *p;
u8 i = 0;
for(p=pParse->pRename; p; p=p->pNext){
@@ -109039,12 +109876,12 @@ static void renameColumnParseError(
const char *zN = (const char*)sqlite3_value_text(pObject);
char *zErr;
- zErr = sqlite3_mprintf("error in %s %s%s%s: %s",
+ zErr = sqlite3MPrintf(pParse->db, "error in %s %s%s%s: %s",
zT, zN, (zWhen[0] ? " " : ""), zWhen,
pParse->zErrMsg
);
sqlite3_result_error(pCtx, zErr, -1);
- sqlite3_free(zErr);
+ sqlite3DbFree(pParse->db, zErr);
}
/*
@@ -109108,24 +109945,22 @@ static int renameParseSql(
int bTemp /* True if SQL is from temp schema */
){
int rc;
- char *zErr = 0;
+ sqlite3ParseObjectInit(p, db);
+ if( zSql==0 ){
+ return SQLITE_NOMEM;
+ }
+ if( sqlite3StrNICmp(zSql,"CREATE ",7)!=0 ){
+ return SQLITE_CORRUPT_BKPT;
+ }
db->init.iDb = bTemp ? 1 : sqlite3FindDbName(db, zDb);
-
- /* Parse the SQL statement passed as the first argument. If no error
- ** occurs and the parse does not result in a new table, index or
- ** trigger object, the database must be corrupt. */
- memset(p, 0, sizeof(Parse));
p->eParseMode = PARSE_MODE_RENAME;
p->db = db;
p->nQueryLoop = 1;
- rc = zSql ? sqlite3RunParser(p, zSql, &zErr) : SQLITE_NOMEM;
- assert( p->zErrMsg==0 );
- assert( rc!=SQLITE_OK || zErr==0 );
- p->zErrMsg = zErr;
+ rc = sqlite3RunParser(p, zSql);
if( db->mallocFailed ) rc = SQLITE_NOMEM;
if( rc==SQLITE_OK
- && p->pNewTable==0 && p->pNewIndex==0 && p->pNewTrigger==0
+ && NEVER(p->pNewTable==0 && p->pNewIndex==0 && p->pNewTrigger==0)
){
rc = SQLITE_CORRUPT_BKPT;
}
@@ -109403,13 +110238,13 @@ static void renameParseCleanup(Parse *pParse){
sqlite3DeleteTrigger(db, pParse->pNewTrigger);
sqlite3DbFree(db, pParse->zErrMsg);
renameTokenFree(db, pParse->pRename);
- sqlite3ParserReset(pParse);
+ sqlite3ParseObjectReset(pParse);
}
/*
** SQL function:
**
-** sqlite_rename_column(zSql, iCol, bQuote, zNew, zTable, zOld)
+** sqlite_rename_column(SQL,TYPE,OBJ,DB,TABLE,COL,NEWNAME,QUOTE,TEMP)
**
** 0. zSql: SQL statement to rewrite
** 1. type: Type of object ("table", "view" etc.)
@@ -109427,7 +110262,8 @@ static void renameParseCleanup(Parse *pParse){
**
** This function is used internally by the ALTER TABLE RENAME COLUMN command.
** It is only accessible to SQL created using sqlite3NestedParse(). It is
-** not reachable from ordinary SQL passed into sqlite3_prepare().
+** not reachable from ordinary SQL passed into sqlite3_prepare() unless the
+** SQLITE_TESTCTRL_INTERNAL_FUNCTIONS test setting is enabled.
*/
static void renameColumnFunc(
sqlite3_context *context,
@@ -109576,7 +110412,9 @@ static void renameColumnFunc(
renameColumnFunc_done:
if( rc!=SQLITE_OK ){
- if( sParse.zErrMsg ){
+ if( rc==SQLITE_ERROR && sqlite3WritableSchema(db) ){
+ sqlite3_result_value(context, argv[0]);
+ }else if( sParse.zErrMsg ){
renameColumnParseError(context, "", argv[1], argv[2], &sParse);
}else{
sqlite3_result_error_code(context, rc);
@@ -109775,7 +110613,9 @@ static void renameTableFunc(
rc = renameEditSql(context, &sCtx, zInput, zNew, bQuote);
}
if( rc!=SQLITE_OK ){
- if( sParse.zErrMsg ){
+ if( rc==SQLITE_ERROR && sqlite3WritableSchema(db) ){
+ sqlite3_result_value(context, argv[3]);
+ }else if( sParse.zErrMsg ){
renameColumnParseError(context, "", argv[1], argv[2], &sParse);
}else{
sqlite3_result_error_code(context, rc);
@@ -109800,10 +110640,10 @@ static int renameQuotefixExprCb(Walker *pWalker, Expr *pExpr){
return WRC_Continue;
}
-/*
-** The implementation of an SQL scalar function that rewrites DDL statements
-** so that any string literals that use double-quotes are modified so that
-** they use single quotes.
+/* SQL function: sqlite_rename_quotefix(DB,SQL)
+**
+** Rewrite the DDL statement "SQL" so that any string literals that use
+** double-quotes use single quotes instead.
**
** Two arguments must be passed:
**
@@ -109822,6 +110662,10 @@ static int renameQuotefixExprCb(Walker *pWalker, Expr *pExpr){
** returns the string:
**
** CREATE VIEW v1 AS SELECT "a", 'string' FROM t1
+**
+** If there is a error in the input SQL, then raise an error, except
+** if PRAGMA writable_schema=ON, then just return the input string
+** unmodified following an error.
*/
static void renameQuotefixFunc(
sqlite3_context *context,
@@ -109896,7 +110740,11 @@ static void renameQuotefixFunc(
renameTokenFree(db, sCtx.pList);
}
if( rc!=SQLITE_OK ){
- sqlite3_result_error_code(context, rc);
+ if( sqlite3WritableSchema(db) && rc==SQLITE_ERROR ){
+ sqlite3_result_value(context, argv[1]);
+ }else{
+ sqlite3_result_error_code(context, rc);
+ }
}
renameParseCleanup(&sParse);
}
@@ -109908,7 +110756,8 @@ static void renameQuotefixFunc(
sqlite3BtreeLeaveAll(db);
}
-/*
+/* Function: sqlite_rename_test(DB,SQL,TYPE,NAME,ISTEMP,WHEN,DQS)
+**
** An SQL user function that checks that there are no parse or symbol
** resolution problems in a CREATE TRIGGER|TABLE|VIEW|INDEX statement.
** After an ALTER TABLE .. RENAME operation is performed and the schema
@@ -109923,11 +110772,13 @@ static void renameQuotefixFunc(
** 5: "when" part of error message.
** 6: True to disable the DQS quirk when parsing SQL.
**
-** Unless it finds an error, this function normally returns NULL. However, it
-** returns integer value 1 if:
+** The return value is computed as follows:
**
-** * the SQL argument creates a trigger, and
-** * the table that the trigger is attached to is in database zDb.
+** A. If an error is seen and not in PRAGMA writable_schema=ON mode,
+** then raise the error.
+** B. Else if a trigger is created and the the table that the trigger is
+** attached to is in database zDb, then return 1.
+** C. Otherwise return NULL.
*/
static void renameTableTest(
sqlite3_context *context,
@@ -109972,12 +110823,16 @@ static void renameTableTest(
if( rc==SQLITE_OK ){
int i1 = sqlite3SchemaToIndex(db, sParse.pNewTrigger->pTabSchema);
int i2 = sqlite3FindDbName(db, zDb);
- if( i1==i2 ) sqlite3_result_int(context, 1);
+ if( i1==i2 ){
+ /* Handle output case B */
+ sqlite3_result_int(context, 1);
+ }
}
}
}
- if( rc!=SQLITE_OK && zWhen ){
+ if( rc!=SQLITE_OK && zWhen && !sqlite3WritableSchema(db) ){
+ /* Output case A */
renameColumnParseError(context, zWhen, argv[2], argv[3],&sParse);
}
renameParseCleanup(&sParse);
@@ -110093,7 +110948,7 @@ SQLITE_PRIVATE void sqlite3AlterDropColumn(Parse *pParse, SrcList *pSrc, const T
}
iCol = sqlite3ColumnIndex(pTab, zCol);
if( iCol<0 ){
- sqlite3ErrorMsg(pParse, "no such column: \"%s\"", zCol);
+ sqlite3ErrorMsg(pParse, "no such column: \"%T\"", pName);
goto exit_drop_column;
}
@@ -110117,6 +110972,12 @@ SQLITE_PRIVATE void sqlite3AlterDropColumn(Parse *pParse, SrcList *pSrc, const T
iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
assert( iDb>=0 );
zDb = db->aDb[iDb].zDbSName;
+#ifndef SQLITE_OMIT_AUTHORIZATION
+ /* Invoke the authorization callback. */
+ if( sqlite3AuthCheck(pParse, SQLITE_ALTER_TABLE, zDb, pTab->zName, zCol) ){
+ goto exit_drop_column;
+ }
+#endif
renameTestSchema(pParse, zDb, iDb==1, "", 0);
renameFixQuotes(pParse, zDb, iDb==1);
sqlite3NestedParse(pParse,
@@ -112504,7 +113365,7 @@ static void codeAttach(
}
#ifndef SQLITE_OMIT_AUTHORIZATION
- if( pAuthArg ){
+ if( ALWAYS(pAuthArg) ){
char *zAuthArg;
if( pAuthArg->op==TK_STRING ){
assert( !ExprHasProperty(pAuthArg, EP_IntValue) );
@@ -113165,11 +114026,13 @@ SQLITE_PRIVATE void sqlite3FinishCoding(Parse *pParse){
assert( pParse->pToplevel==0 );
db = pParse->db;
+ assert( db->pParse==pParse );
if( pParse->nested ) return;
- if( db->mallocFailed || pParse->nErr ){
- if( pParse->rc==SQLITE_OK ) pParse->rc = SQLITE_ERROR;
+ if( pParse->nErr ){
+ if( db->mallocFailed ) pParse->rc = SQLITE_NOMEM;
return;
}
+ assert( db->mallocFailed==0 );
/* Begin by generating some termination code at the end of the
** vdbe program
@@ -113192,9 +114055,10 @@ SQLITE_PRIVATE void sqlite3FinishCoding(Parse *pParse){
int i;
int reg;
- if( pReturning->nRetCol==0 ){
+ if( NEVER(pReturning->nRetCol==0) ){
assert( CORRUPT_DB );
}else{
+ sqlite3VdbeAddOp0(v, OP_FkCheck);
addrRewind =
sqlite3VdbeAddOp1(v, OP_Rewind, pReturning->iRetCur);
VdbeCoverage(v);
@@ -113287,7 +114151,7 @@ SQLITE_PRIVATE void sqlite3FinishCoding(Parse *pParse){
if( pParse->bReturning ){
Returning *pRet = pParse->u1.pReturning;
- if( pRet->nRetCol==0 ){
+ if( NEVER(pRet->nRetCol==0) ){
assert( CORRUPT_DB );
}else{
sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pRet->iRetCur, pRet->nRetCol);
@@ -113301,7 +114165,9 @@ SQLITE_PRIVATE void sqlite3FinishCoding(Parse *pParse){
/* Get the VDBE program ready for execution
*/
- if( v && pParse->nErr==0 && !db->mallocFailed ){
+ assert( v!=0 || pParse->nErr );
+ assert( db->mallocFailed==0 || pParse->nErr );
+ if( pParse->nErr==0 ){
/* A minimum of one cursor is required if autoincrement is used
* See ticket [a696379c1f08866] */
assert( pParse->pAinc==0 || pParse->nTab>0 );
@@ -113328,7 +114194,6 @@ SQLITE_PRIVATE void sqlite3FinishCoding(Parse *pParse){
SQLITE_PRIVATE void sqlite3NestedParse(Parse *pParse, const char *zFormat, ...){
va_list ap;
char *zSql;
- char *zErrMsg = 0;
sqlite3 *db = pParse->db;
u32 savedDbFlags = db->mDbFlags;
char saveBuf[PARSE_TAIL_SZ];
@@ -113350,9 +114215,10 @@ SQLITE_PRIVATE void sqlite3NestedParse(Parse *pParse, const char *zFormat, ...){
memcpy(saveBuf, PARSE_TAIL(pParse), PARSE_TAIL_SZ);
memset(PARSE_TAIL(pParse), 0, PARSE_TAIL_SZ);
db->mDbFlags |= DBFLAG_PreferBuiltin;
- sqlite3RunParser(pParse, zSql, &zErrMsg);
+ sqlite3RunParser(pParse, zSql);
+ sqlite3DbFree(db, pParse->zErrMsg);
+ pParse->zErrMsg = 0;
db->mDbFlags = savedDbFlags;
- sqlite3DbFree(db, zErrMsg);
sqlite3DbFree(db, zSql);
memcpy(PARSE_TAIL(pParse), saveBuf, PARSE_TAIL_SZ);
pParse->nested--;
@@ -114312,7 +115178,8 @@ SQLITE_PRIVATE void sqlite3StartTable(
pTable = sqlite3FindTable(db, zName, zDb);
if( pTable ){
if( !noErr ){
- sqlite3ErrorMsg(pParse, "table %T already exists", pName);
+ sqlite3ErrorMsg(pParse, "%s %T already exists",
+ (IsView(pTable)? "view" : "table"), pName);
}else{
assert( !db->init.busy || CORRUPT_DB );
sqlite3CodeVerifySchema(pParse, iDb);
@@ -115407,10 +116274,11 @@ static void convertToWithoutRowidTable(Parse *pParse, Table *pTab){
pTab->iPKey = -1;
sqlite3CreateIndex(pParse, 0, 0, 0, pList, pTab->keyConf, 0, 0, 0, 0,
SQLITE_IDXTYPE_PRIMARYKEY);
- if( db->mallocFailed || pParse->nErr ){
+ if( pParse->nErr ){
pTab->tabFlags &= ~TF_WithoutRowid;
return;
}
+ assert( db->mallocFailed==0 );
pPk = sqlite3PrimaryKeyIndex(pTab);
assert( pPk->nKeyCol==1 );
}else{
@@ -115841,6 +116709,11 @@ SQLITE_PRIVATE void sqlite3EndTable(
int addrInsLoop; /* Top of the loop for inserting rows */
Table *pSelTab; /* A table that describes the SELECT results */
+ if( IN_SPECIAL_PARSE ){
+ pParse->rc = SQLITE_ERROR;
+ pParse->nErr++;
+ return;
+ }
regYield = ++pParse->nMem;
regRec = ++pParse->nMem;
regRowid = ++pParse->nMem;
@@ -116151,10 +117024,10 @@ SQLITE_PRIVATE int sqlite3ViewGetColumnNames(Parse *pParse, Table *pTable){
*/
sqlite3ColumnsFromExprList(pParse, pTable->pCheck,
&pTable->nCol, &pTable->aCol);
- if( db->mallocFailed==0
- && pParse->nErr==0
+ if( pParse->nErr==0
&& pTable->nCol==pSel->pEList->nExpr
){
+ assert( db->mallocFailed==0 );
sqlite3SelectAddColumnTypeAndCollation(pParse, pTable, pSel,
SQLITE_AFF_NONE);
}
@@ -116773,7 +117646,7 @@ static void sqlite3RefillIndex(Parse *pParse, Index *pIndex, int memRootPage){
tnum = pIndex->tnum;
}
pKey = sqlite3KeyInfoOfIndex(pParse, pIndex);
- assert( pKey!=0 || db->mallocFailed || pParse->nErr );
+ assert( pKey!=0 || pParse->nErr );
/* Open the sorter cursor if we are to use one. */
iSorter = pParse->nTab++;
@@ -116937,9 +117810,11 @@ SQLITE_PRIVATE void sqlite3CreateIndex(
char *zExtra = 0; /* Extra space after the Index object */
Index *pPk = 0; /* PRIMARY KEY index for WITHOUT ROWID tables */
- if( db->mallocFailed || pParse->nErr>0 ){
+ assert( db->pParse==pParse );
+ if( pParse->nErr ){
goto exit_create_index;
}
+ assert( db->mallocFailed==0 );
if( IN_DECLARE_VTAB && idxType!=SQLITE_IDXTYPE_PRIMARYKEY ){
goto exit_create_index;
}
@@ -117003,7 +117878,6 @@ SQLITE_PRIVATE void sqlite3CreateIndex(
pDb = &db->aDb[iDb];
assert( pTab!=0 );
- assert( pParse->nErr==0 );
if( sqlite3StrNICmp(pTab->zName, "sqlite_", 7)==0
&& db->init.busy==0
&& pTblName!=0
@@ -117427,13 +118301,13 @@ SQLITE_PRIVATE void sqlite3CreateIndex(
/* Add an entry in sqlite_schema for this index
*/
sqlite3NestedParse(pParse,
- "INSERT INTO %Q." LEGACY_SCHEMA_TABLE " VALUES('index',%Q,%Q,#%d,%Q);",
- db->aDb[iDb].zDbSName,
- pIndex->zName,
- pTab->zName,
- iMem,
- zStmt
- );
+ "INSERT INTO %Q." LEGACY_SCHEMA_TABLE " VALUES('index',%Q,%Q,#%d,%Q);",
+ db->aDb[iDb].zDbSName,
+ pIndex->zName,
+ pTab->zName,
+ iMem,
+ zStmt
+ );
sqlite3DbFree(db, zStmt);
/* Fill the index with data and reparse the schema. Code an OP_Expire
@@ -117567,10 +118441,10 @@ SQLITE_PRIVATE void sqlite3DropIndex(Parse *pParse, SrcList *pName, int ifExists
sqlite3 *db = pParse->db;
int iDb;
- assert( pParse->nErr==0 ); /* Never called with prior errors */
if( db->mallocFailed ){
goto exit_drop_index;
}
+ assert( pParse->nErr==0 ); /* Never called with prior non-OOM errors */
assert( pName->nSrc==1 );
if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){
goto exit_drop_index;
@@ -117981,7 +118855,7 @@ SQLITE_PRIVATE SrcList *sqlite3SrcListAppendFromTerm(
pItem->pUsing = pUsing;
return p;
- append_from_error:
+append_from_error:
assert( p==0 );
sqlite3ExprDelete(db, pOn);
sqlite3IdListDelete(db, pUsing);
@@ -119011,7 +119885,6 @@ SQLITE_PRIVATE void sqlite3InsertBuiltinFuncs(
const char *zName = aDef[i].zName;
int nName = sqlite3Strlen30(zName);
int h = SQLITE_FUNC_HASH(zName[0], nName);
- assert( zName[0]>='a' && zName[0]<='z' );
assert( aDef[i].funcFlags & SQLITE_FUNC_BUILTIN );
pOther = sqlite3FunctionSearch(h, zName);
if( pOther ){
@@ -119238,6 +120111,16 @@ SQLITE_PRIVATE Table *sqlite3SrcListLookup(Parse *pParse, SrcList *pSrc){
return pTab;
}
+/* Generate byte-code that will report the number of rows modified
+** by a DELETE, INSERT, or UPDATE statement.
+*/
+SQLITE_PRIVATE void sqlite3CodeChangeCount(Vdbe *v, int regCounter, const char *zColName){
+ sqlite3VdbeAddOp0(v, OP_FkCheck);
+ sqlite3VdbeAddOp2(v, OP_ResultRow, regCounter, 1);
+ sqlite3VdbeSetNumCols(v, 1);
+ sqlite3VdbeSetColName(v, 0, COLNAME_NAME, zColName, SQLITE_STATIC);
+}
+
/* Return true if table pTab is read-only.
**
** A table is read-only if any of the following are true:
@@ -119477,9 +120360,11 @@ SQLITE_PRIVATE void sqlite3DeleteFrom(
memset(&sContext, 0, sizeof(sContext));
db = pParse->db;
- if( pParse->nErr || db->mallocFailed ){
+ assert( db->pParse==pParse );
+ if( pParse->nErr ){
goto delete_from_cleanup;
}
+ assert( db->mallocFailed==0 );
assert( pTabList->nSrc==1 );
@@ -119660,7 +120545,7 @@ SQLITE_PRIVATE void sqlite3DeleteFrom(
** ONEPASS_SINGLE: One-pass approach - at most one row deleted.
** ONEPASS_MULTI: One-pass approach - any number of rows may be deleted.
*/
- pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, 0, 0, wcf, iTabCur+1);
+ pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, 0, 0,0,wcf,iTabCur+1);
if( pWInfo==0 ) goto delete_from_cleanup;
eOnePass = sqlite3WhereOkOnePass(pWInfo, aiCurOnePass);
assert( IsVirtual(pTab)==0 || eOnePass!=ONEPASS_MULTI );
@@ -119813,9 +120698,7 @@ SQLITE_PRIVATE void sqlite3DeleteFrom(
** invoke the callback function.
*/
if( memCnt ){
- sqlite3VdbeAddOp2(v, OP_ChngCntRow, memCnt, 1);
- sqlite3VdbeSetNumCols(v, 1);
- sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "rows deleted", SQLITE_STATIC);
+ sqlite3CodeChangeCount(v, memCnt, "rows deleted");
}
delete_from_cleanup:
@@ -120266,6 +121149,18 @@ static void typeofFunc(
sqlite3_result_text(context, azType[i], -1, SQLITE_STATIC);
}
+/* subtype(X)
+**
+** Return the subtype of X
+*/
+static void subtypeFunc(
+ sqlite3_context *context,
+ int argc,
+ sqlite3_value **argv
+){
+ UNUSED_PARAMETER(argc);
+ sqlite3_result_int(context, sqlite3_value_subtype(argv[0]));
+}
/*
** Implementation of the length() function
@@ -120427,7 +121322,7 @@ endInstrOOM:
}
/*
-** Implementation of the printf() function.
+** Implementation of the printf() (a.k.a. format()) SQL function.
*/
static void printfFunc(
sqlite3_context *context,
@@ -121196,39 +122091,42 @@ static const char hexdigits[] = {
};
/*
-** Implementation of the QUOTE() function. This function takes a single
-** argument. If the argument is numeric, the return value is the same as
-** the argument. If the argument is NULL, the return value is the string
-** "NULL". Otherwise, the argument is enclosed in single quotes with
-** single-quote escapes.
+** Append to pStr text that is the SQL literal representation of the
+** value contained in pValue.
*/
-static void quoteFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
- assert( argc==1 );
- UNUSED_PARAMETER(argc);
- switch( sqlite3_value_type(argv[0]) ){
+SQLITE_PRIVATE void sqlite3QuoteValue(StrAccum *pStr, sqlite3_value *pValue){
+ /* As currently implemented, the string must be initially empty.
+ ** we might relax this requirement in the future, but that will
+ ** require enhancements to the implementation. */
+ assert( pStr!=0 && pStr->nChar==0 );
+
+ switch( sqlite3_value_type(pValue) ){
case SQLITE_FLOAT: {
double r1, r2;
- char zBuf[50];
- r1 = sqlite3_value_double(argv[0]);
- sqlite3_snprintf(sizeof(zBuf), zBuf, "%!.15g", r1);
- sqlite3AtoF(zBuf, &r2, 20, SQLITE_UTF8);
- if( r1!=r2 ){
- sqlite3_snprintf(sizeof(zBuf), zBuf, "%!.20e", r1);
+ const char *zVal;
+ r1 = sqlite3_value_double(pValue);
+ sqlite3_str_appendf(pStr, "%!.15g", r1);
+ zVal = sqlite3_str_value(pStr);
+ if( zVal ){
+ sqlite3AtoF(zVal, &r2, pStr->nChar, SQLITE_UTF8);
+ if( r1!=r2 ){
+ sqlite3_str_reset(pStr);
+ sqlite3_str_appendf(pStr, "%!.20e", r1);
+ }
}
- sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT);
break;
}
case SQLITE_INTEGER: {
- sqlite3_result_value(context, argv[0]);
+ sqlite3_str_appendf(pStr, "%lld", sqlite3_value_int64(pValue));
break;
}
case SQLITE_BLOB: {
- char *zText = 0;
- char const *zBlob = sqlite3_value_blob(argv[0]);
- int nBlob = sqlite3_value_bytes(argv[0]);
- assert( zBlob==sqlite3_value_blob(argv[0]) ); /* No encoding change */
- zText = (char *)contextMalloc(context, (2*(i64)nBlob)+4);
- if( zText ){
+ char const *zBlob = sqlite3_value_blob(pValue);
+ int nBlob = sqlite3_value_bytes(pValue);
+ assert( zBlob==sqlite3_value_blob(pValue) ); /* No encoding change */
+ sqlite3StrAccumEnlarge(pStr, nBlob*2 + 4);
+ if( pStr->accError==0 ){
+ char *zText = pStr->zText;
int i;
for(i=0; i<nBlob; i++){
zText[(i*2)+2] = hexdigits[(zBlob[i]>>4)&0x0F];
@@ -121238,43 +122136,49 @@ static void quoteFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
zText[(nBlob*2)+3] = '\0';
zText[0] = 'X';
zText[1] = '\'';
- sqlite3_result_text(context, zText, -1, SQLITE_TRANSIENT);
- sqlite3_free(zText);
+ pStr->nChar = nBlob*2 + 3;
}
break;
}
case SQLITE_TEXT: {
- int i,j;
- u64 n;
- const unsigned char *zArg = sqlite3_value_text(argv[0]);
- char *z;
-
- if( zArg==0 ) return;
- for(i=0, n=0; zArg[i]; i++){ if( zArg[i]=='\'' ) n++; }
- z = contextMalloc(context, ((i64)i)+((i64)n)+3);
- if( z ){
- z[0] = '\'';
- for(i=0, j=1; zArg[i]; i++){
- z[j++] = zArg[i];
- if( zArg[i]=='\'' ){
- z[j++] = '\'';
- }
- }
- z[j++] = '\'';
- z[j] = 0;
- sqlite3_result_text(context, z, j, sqlite3_free);
- }
+ const unsigned char *zArg = sqlite3_value_text(pValue);
+ sqlite3_str_appendf(pStr, "%Q", zArg);
break;
}
default: {
- assert( sqlite3_value_type(argv[0])==SQLITE_NULL );
- sqlite3_result_text(context, "NULL", 4, SQLITE_STATIC);
+ assert( sqlite3_value_type(pValue)==SQLITE_NULL );
+ sqlite3_str_append(pStr, "NULL", 4);
break;
}
}
}
/*
+** Implementation of the QUOTE() function.
+**
+** The quote(X) function returns the text of an SQL literal which is the
+** value of its argument suitable for inclusion into an SQL statement.
+** Strings are surrounded by single-quotes with escapes on interior quotes
+** as needed. BLOBs are encoded as hexadecimal literals. Strings with
+** embedded NUL characters cannot be represented as string literals in SQL
+** and hence the returned string literal is truncated prior to the first NUL.
+*/
+static void quoteFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
+ sqlite3_str str;
+ sqlite3 *db = sqlite3_context_db_handle(context);
+ assert( argc==1 );
+ UNUSED_PARAMETER(argc);
+ sqlite3StrAccumInit(&str, db, 0, 0, db->aLimit[SQLITE_LIMIT_LENGTH]);
+ sqlite3QuoteValue(&str,argv[0]);
+ sqlite3_result_text(context, sqlite3StrAccumFinish(&str), str.nChar,
+ SQLITE_DYNAMIC);
+ if( str.accError!=SQLITE_OK ){
+ sqlite3_result_null(context);
+ sqlite3_result_error_code(context, str.accError);
+ }
+}
+
+/*
** The unicode() function. Return the integer unicode code-point value
** for the first character of the input string.
*/
@@ -122389,8 +123293,8 @@ SQLITE_PRIVATE void sqlite3RegisterBuiltinFunctions(void){
INLINE_FUNC(likelihood, 2, INLINEFUNC_unlikely, SQLITE_FUNC_UNLIKELY),
INLINE_FUNC(likely, 1, INLINEFUNC_unlikely, SQLITE_FUNC_UNLIKELY),
#ifdef SQLITE_ENABLE_OFFSET_SQL_FUNC
- FUNCTION2(sqlite_offset, 1, 0, 0, noopFunc, SQLITE_FUNC_OFFSET|
- SQLITE_FUNC_TYPEOF),
+ {1, SQLITE_FUNC_BUILTIN|SQLITE_UTF8|SQLITE_FUNC_OFFSET|SQLITE_FUNC_TYPEOF,
+ 0, 0, noopFunc, 0, 0, 0, "sqlite_offset", {0} },
#endif
FUNCTION(ltrim, 1, 1, 0, trimFunc ),
FUNCTION(ltrim, 2, 1, 0, trimFunc ),
@@ -122407,9 +123311,11 @@ SQLITE_PRIVATE void sqlite3RegisterBuiltinFunctions(void){
WAGGREGATE(max, 1, 1, 1, minmaxStep, minMaxFinalize, minMaxValue, 0,
SQLITE_FUNC_MINMAX|SQLITE_FUNC_ANYORDER ),
FUNCTION2(typeof, 1, 0, 0, typeofFunc, SQLITE_FUNC_TYPEOF),
+ FUNCTION2(subtype, 1, 0, 0, subtypeFunc, SQLITE_FUNC_TYPEOF),
FUNCTION2(length, 1, 0, 0, lengthFunc, SQLITE_FUNC_LENGTH),
FUNCTION(instr, 2, 0, 0, instrFunc ),
FUNCTION(printf, -1, 0, 0, printfFunc ),
+ FUNCTION(format, -1, 0, 0, printfFunc ),
FUNCTION(unicode, 1, 0, 0, unicodeFunc ),
FUNCTION(char, -1, 0, 0, charFunc ),
FUNCTION(abs, 1, 0, 0, absFunc ),
@@ -122508,6 +123414,7 @@ SQLITE_PRIVATE void sqlite3RegisterBuiltinFunctions(void){
#endif
sqlite3WindowFunctions();
sqlite3RegisterDateTimeFunctions();
+ sqlite3RegisterJsonFunctions();
sqlite3InsertBuiltinFuncs(aBuiltinFunc, ArraySize(aBuiltinFunc));
#if 0 /* Enable to print out how the built-in functions are hashed */
@@ -123183,7 +124090,7 @@ static void fkScanChildren(
** clause. For each row found, increment either the deferred or immediate
** foreign key constraint counter. */
if( pParse->nErr==0 ){
- pWInfo = sqlite3WhereBegin(pParse, pSrc, pWhere, 0, 0, 0, 0);
+ pWInfo = sqlite3WhereBegin(pParse, pSrc, pWhere, 0, 0, 0, 0, 0);
sqlite3VdbeAddOp2(v, OP_FkCounter, pFKey->isDeferred, nIncr);
if( pWInfo ){
sqlite3WhereEnd(pWInfo);
@@ -123235,6 +124142,25 @@ static void fkTriggerDelete(sqlite3 *dbMem, Trigger *p){
}
/*
+** Clear the apTrigger[] cache of CASCADE triggers for all foreign keys
+** in a particular database. This needs to happen when the schema
+** changes.
+*/
+SQLITE_PRIVATE void sqlite3FkClearTriggerCache(sqlite3 *db, int iDb){
+ HashElem *k;
+ Hash *pHash = &db->aDb[iDb].pSchema->tblHash;
+ for(k=sqliteHashFirst(pHash); k; k=sqliteHashNext(k)){
+ Table *pTab = sqliteHashData(k);
+ FKey *pFKey;
+ if( !IsOrdinaryTable(pTab) ) continue;
+ for(pFKey=pTab->u.tab.pFKey; pFKey; pFKey=pFKey->pNextFrom){
+ fkTriggerDelete(db, pFKey->apTrigger[0]); pFKey->apTrigger[0] = 0;
+ fkTriggerDelete(db, pFKey->apTrigger[1]); pFKey->apTrigger[1] = 0;
+ }
+ }
+}
+
+/*
** This function is called to generate code that runs when table pTab is
** being dropped from the database. The SrcList passed as the second argument
** to this function contains a single entry guaranteed to resolve to
@@ -124034,7 +124960,7 @@ SQLITE_PRIVATE void sqlite3OpenTable(
}else{
Index *pPk = sqlite3PrimaryKeyIndex(pTab);
assert( pPk!=0 );
- assert( pPk->tnum==pTab->tnum );
+ assert( pPk->tnum==pTab->tnum || CORRUPT_DB );
sqlite3VdbeAddOp3(v, opcode, iCur, pPk->tnum, iDb);
sqlite3VdbeSetP4KeyInfo(pParse, pPk);
VdbeComment((v, "%s", pTab->zName));
@@ -124706,9 +125632,11 @@ SQLITE_PRIVATE void sqlite3Insert(
#endif
db = pParse->db;
- if( pParse->nErr || db->mallocFailed ){
+ assert( db->pParse==pParse );
+ if( pParse->nErr ){
goto insert_cleanup;
}
+ assert( db->mallocFailed==0 );
dest.iSDParm = 0; /* Suppress a harmless compiler warning */
/* If the Select object is really just a simple VALUES() list with a
@@ -124784,7 +125712,11 @@ SQLITE_PRIVATE void sqlite3Insert(
**
** This is the 2nd template.
*/
- if( pColumn==0 && xferOptimization(pParse, pTab, pSelect, onError, iDb) ){
+ if( pColumn==0
+ && pSelect!=0
+ && pTrigger==0
+ && xferOptimization(pParse, pTab, pSelect, onError, iDb)
+ ){
assert( !pTrigger );
assert( pList==0 );
goto insert_end;
@@ -124884,7 +125816,9 @@ SQLITE_PRIVATE void sqlite3Insert(
dest.nSdst = pTab->nCol;
rc = sqlite3Select(pParse, pSelect, &dest);
regFromSelect = dest.iSdst;
- if( rc || db->mallocFailed || pParse->nErr ) goto insert_cleanup;
+ assert( db->pParse==pParse );
+ if( rc || pParse->nErr ) goto insert_cleanup;
+ assert( db->mallocFailed==0 );
sqlite3VdbeEndCoroutine(v, regYield);
sqlite3VdbeJumpHere(v, addrTop - 1); /* label B: */
assert( pSelect->pEList );
@@ -125373,9 +126307,7 @@ insert_end:
** invoke the callback function.
*/
if( regRowCount ){
- sqlite3VdbeAddOp2(v, OP_ChngCntRow, regRowCount, 1);
- sqlite3VdbeSetNumCols(v, 1);
- sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "rows inserted", SQLITE_STATIC);
+ sqlite3CodeChangeCount(v, regRowCount, "rows inserted");
}
insert_cleanup:
@@ -126540,7 +127472,6 @@ SQLITE_PRIVATE void sqlite3CompleteInsertion(
}
pik_flags = (useSeekResult ? OPFLAG_USESEEKRESULT : 0);
if( IsPrimaryKeyIndex(pIdx) && !HasRowid(pTab) ){
- assert( pParse->nested==0 );
pik_flags |= OPFLAG_NCHANGE;
pik_flags |= (update_flags & OPFLAG_SAVEPOSITION);
if( update_flags==0 ){
@@ -126756,18 +127687,13 @@ static int xferOptimization(
int destHasUniqueIdx = 0; /* True if pDest has a UNIQUE index */
int regData, regRowid; /* Registers holding data and rowid */
- if( pSelect==0 ){
- return 0; /* Must be of the form INSERT INTO ... SELECT ... */
- }
+ assert( pSelect!=0 );
if( pParse->pWith || pSelect->pWith ){
/* Do not attempt to process this query if there are an WITH clauses
** attached to it. Proceeding may generate a false "no such table: xxx"
** error if pSelect reads from a CTE named "xxx". */
return 0;
}
- if( sqlite3TriggerList(pParse, pDest) ){
- return 0; /* tab1 must not have triggers */
- }
#ifndef SQLITE_OMIT_VIRTUALTABLE
if( IsVirtual(pDest) ){
return 0; /* tab1 must not be a virtual table */
@@ -127630,6 +128556,13 @@ struct sqlite3_api_routines {
int (*autovacuum_pages)(sqlite3*,
unsigned int(*)(void*,const char*,unsigned int,unsigned int,unsigned int),
void*, void(*)(void*));
+ /* Version 3.38.0 and later */
+ int (*error_offset)(sqlite3*);
+ int (*vtab_rhs_value)(sqlite3_index_info*,int,sqlite3_value**);
+ int (*vtab_distinct)(sqlite3_index_info*);
+ int (*vtab_in)(sqlite3_index_info*,int,int);
+ int (*vtab_in_first)(sqlite3_value*,sqlite3_value**);
+ int (*vtab_in_next)(sqlite3_value*,sqlite3_value**);
};
/*
@@ -127941,6 +128874,13 @@ typedef int (*sqlite3_loadext_entry)(
#define sqlite3_total_changes64 sqlite3_api->total_changes64
/* Version 3.37.0 and later */
#define sqlite3_autovacuum_pages sqlite3_api->autovacuum_pages
+/* Version 3.38.0 and later */
+#define sqlite3_error_offset sqlite3_api->error_offset
+#define sqlite3_vtab_rhs_value sqlite3_api->vtab_rhs_value
+#define sqlite3_vtab_distinct sqlite3_api->vtab_distinct
+#define sqlite3_vtab_in sqlite3_api->vtab_in
+#define sqlite3_vtab_in_first sqlite3_api->vtab_in_first
+#define sqlite3_vtab_in_next sqlite3_api->vtab_in_next
#endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */
#if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)
@@ -128430,6 +129370,13 @@ static const sqlite3_api_routines sqlite3Apis = {
sqlite3_total_changes64,
/* Version 3.37.0 and later */
sqlite3_autovacuum_pages,
+ /* Version 3.38.0 and later */
+ sqlite3_error_offset,
+ sqlite3_vtab_rhs_value,
+ sqlite3_vtab_distinct,
+ sqlite3_vtab_in,
+ sqlite3_vtab_in_first,
+ sqlite3_vtab_in_next
};
/* True if x is the directory separator character
@@ -130731,6 +131678,10 @@ SQLITE_PRIVATE void sqlite3Pragma(
(void)sqlite3_finalize(pDummy);
sqlite3DbFree(db, zSql);
}
+ if( db->mallocFailed ){
+ sqlite3ErrorMsg(db->pParse, "out of memory");
+ db->pParse->rc = SQLITE_NOMEM_BKPT;
+ }
pHash = &db->aDb[ii].pSchema->tblHash;
break;
}
@@ -132767,8 +133718,14 @@ SQLITE_PRIVATE int sqlite3SchemaToIndex(sqlite3 *db, Schema *pSchema){
/*
** Free all memory allocations in the pParse object
*/
-SQLITE_PRIVATE void sqlite3ParserReset(Parse *pParse){
+SQLITE_PRIVATE void sqlite3ParseObjectReset(Parse *pParse){
sqlite3 *db = pParse->db;
+ assert( db!=0 );
+ assert( db->pParse==pParse );
+ assert( pParse->nested==0 );
+#ifndef SQLITE_OMIT_SHARED_CACHE
+ sqlite3DbFree(db, pParse->aTableLock);
+#endif
while( pParse->pCleanup ){
ParseCleanup *pCleanup = pParse->pCleanup;
pParse->pCleanup = pCleanup->pNext;
@@ -132779,11 +133736,12 @@ SQLITE_PRIVATE void sqlite3ParserReset(Parse *pParse){
if( pParse->pConstExpr ){
sqlite3ExprListDelete(db, pParse->pConstExpr);
}
- if( db ){
- assert( db->lookaside.bDisable >= pParse->disableLookaside );
- db->lookaside.bDisable -= pParse->disableLookaside;
- db->lookaside.sz = db->lookaside.bDisable ? 0 : db->lookaside.szTrue;
- }
+ assert( db->lookaside.bDisable >= pParse->disableLookaside );
+ db->lookaside.bDisable -= pParse->disableLookaside;
+ db->lookaside.sz = db->lookaside.bDisable ? 0 : db->lookaside.szTrue;
+ assert( pParse->db->pParse==pParse );
+ db->pParse = pParse->pOuterParse;
+ pParse->db = 0;
pParse->disableLookaside = 0;
}
@@ -132796,7 +133754,7 @@ SQLITE_PRIVATE void sqlite3ParserReset(Parse *pParse){
** cost for this mechansim (an extra malloc), so it should not be used
** for common cleanups that happen on most calls. But for less
** common cleanups, we save a single NULL-pointer comparison in
-** sqlite3ParserReset(), which reduces the total CPU cycle count.
+** sqlite3ParseObjectReset(), which reduces the total CPU cycle count.
**
** If a memory allocation error occurs, then the cleanup happens immediately.
** When either SQLITE_DEBUG or SQLITE_COVERAGE_TEST are defined, the
@@ -132837,6 +133795,25 @@ SQLITE_PRIVATE void *sqlite3ParserAddCleanup(
}
/*
+** Turn bulk memory into a valid Parse object and link that Parse object
+** into database connection db.
+**
+** Call sqlite3ParseObjectReset() to undo this operation.
+**
+** Caution: Do not confuse this routine with sqlite3ParseObjectInit() which
+** is generated by Lemon.
+*/
+SQLITE_PRIVATE void sqlite3ParseObjectInit(Parse *pParse, sqlite3 *db){
+ memset(PARSE_HDR(pParse), 0, PARSE_HDR_SZ);
+ memset(PARSE_TAIL(pParse), 0, PARSE_TAIL_SZ);
+ assert( db->pParse!=pParse );
+ pParse->pOuterParse = db->pParse;
+ db->pParse = pParse;
+ pParse->db = db;
+ if( db->mallocFailed ) sqlite3ErrorMsg(pParse, "out of memory");
+}
+
+/*
** Compile the UTF-8 encoded SQL statement zSql into a statement handle.
*/
static int sqlite3Prepare(
@@ -132848,16 +133825,19 @@ static int sqlite3Prepare(
sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
const char **pzTail /* OUT: End of parsed string */
){
- char *zErrMsg = 0; /* Error message */
int rc = SQLITE_OK; /* Result code */
int i; /* Loop counter */
Parse sParse; /* Parsing context */
- memset(&sParse, 0, PARSE_HDR_SZ);
+ /* sqlite3ParseObjectInit(&sParse, db); // inlined for performance */
+ memset(PARSE_HDR(&sParse), 0, PARSE_HDR_SZ);
memset(PARSE_TAIL(&sParse), 0, PARSE_TAIL_SZ);
+ sParse.pOuterParse = db->pParse;
+ db->pParse = &sParse;
+ sParse.db = db;
sParse.pReprepare = pReprepare;
assert( ppStmt && *ppStmt==0 );
- /* assert( !db->mallocFailed ); // not true with SQLITE_USE_ALLOCA */
+ if( db->mallocFailed ) sqlite3ErrorMsg(&sParse, "out of memory");
assert( sqlite3_mutex_held(db->mutex) );
/* For a long-term use prepared statement avoid the use of
@@ -132910,7 +133890,6 @@ static int sqlite3Prepare(
sqlite3VtabUnlockList(db);
- sParse.db = db;
if( nBytes>=0 && (nBytes==0 || zSql[nBytes-1]!=0) ){
char *zSqlCopy;
int mxLen = db->aLimit[SQLITE_LIMIT_SQL_LENGTH];
@@ -132923,14 +133902,14 @@ static int sqlite3Prepare(
}
zSqlCopy = sqlite3DbStrNDup(db, zSql, nBytes);
if( zSqlCopy ){
- sqlite3RunParser(&sParse, zSqlCopy, &zErrMsg);
+ sqlite3RunParser(&sParse, zSqlCopy);
sParse.zTail = &zSql[sParse.zTail-zSqlCopy];
sqlite3DbFree(db, zSqlCopy);
}else{
sParse.zTail = &zSql[nBytes];
}
}else{
- sqlite3RunParser(&sParse, zSql, &zErrMsg);
+ sqlite3RunParser(&sParse, zSql);
}
assert( 0==sParse.nQueryLoop );
@@ -132946,7 +133925,7 @@ static int sqlite3Prepare(
sParse.checkSchema = 0;
}
if( sParse.rc!=SQLITE_OK && sParse.rc!=SQLITE_DONE ){
- if( sParse.checkSchema ){
+ if( sParse.checkSchema && db->init.busy==0 ){
schemaIsValid(&sParse);
}
if( sParse.pVdbe ){
@@ -132954,14 +133933,14 @@ static int sqlite3Prepare(
}
assert( 0==(*ppStmt) );
rc = sParse.rc;
- if( zErrMsg ){
- sqlite3ErrorWithMsg(db, rc, "%s", zErrMsg);
- sqlite3DbFree(db, zErrMsg);
+ if( sParse.zErrMsg ){
+ sqlite3ErrorWithMsg(db, rc, "%s", sParse.zErrMsg);
+ sqlite3DbFree(db, sParse.zErrMsg);
}else{
sqlite3Error(db, rc);
}
}else{
- assert( zErrMsg==0 );
+ assert( sParse.zErrMsg==0 );
*ppStmt = (sqlite3_stmt*)sParse.pVdbe;
rc = SQLITE_OK;
sqlite3ErrorClear(db);
@@ -132977,7 +133956,7 @@ static int sqlite3Prepare(
end_prepare:
- sqlite3ParserReset(&sParse);
+ sqlite3ParseObjectReset(&sParse);
return rc;
}
static int sqlite3LockAndPrepare(
@@ -133582,14 +134561,14 @@ static void addWhereTerm(
ExprSetProperty(pEq, EP_FromJoin);
assert( !ExprHasProperty(pEq, EP_TokenOnly|EP_Reduced) );
ExprSetVVAProperty(pEq, EP_NoReduce);
- pEq->iRightJoinTable = pE2->iTable;
+ pEq->w.iRightJoinTable = pE2->iTable;
}
*ppWhere = sqlite3ExprAnd(pParse, *ppWhere, pEq);
}
/*
** Set the EP_FromJoin property on all terms of the given expression.
-** And set the Expr.iRightJoinTable to iTable for every term in the
+** And set the Expr.w.iRightJoinTable to iTable for every term in the
** expression.
**
** The EP_FromJoin property is used on terms of an expression to tell
@@ -133599,8 +134578,8 @@ static void addWhereTerm(
** WHERE clause during join processing but we need to remember that they
** originated in the ON or USING clause.
**
-** The Expr.iRightJoinTable tells the WHERE clause processing that the
-** expression depends on table iRightJoinTable even if that table is not
+** The Expr.w.iRightJoinTable tells the WHERE clause processing that the
+** expression depends on table w.iRightJoinTable even if that table is not
** explicitly mentioned in the expression. That information is needed
** for cases like this:
**
@@ -133618,7 +134597,7 @@ SQLITE_PRIVATE void sqlite3SetJoinExpr(Expr *p, int iTable){
ExprSetProperty(p, EP_FromJoin);
assert( !ExprHasProperty(p, EP_TokenOnly|EP_Reduced) );
ExprSetVVAProperty(p, EP_NoReduce);
- p->iRightJoinTable = iTable;
+ p->w.iRightJoinTable = iTable;
if( p->op==TK_FUNCTION ){
assert( ExprUseXList(p) );
if( p->x.pList ){
@@ -133634,7 +134613,7 @@ SQLITE_PRIVATE void sqlite3SetJoinExpr(Expr *p, int iTable){
}
/* Undo the work of sqlite3SetJoinExpr(). In the expression p, convert every
-** term that is marked with EP_FromJoin and iRightJoinTable==iTable into
+** term that is marked with EP_FromJoin and w.iRightJoinTable==iTable into
** an ordinary term that omits the EP_FromJoin mark.
**
** This happens when a LEFT JOIN is simplified into an ordinary JOIN.
@@ -133642,7 +134621,7 @@ SQLITE_PRIVATE void sqlite3SetJoinExpr(Expr *p, int iTable){
static void unsetJoinExpr(Expr *p, int iTable){
while( p ){
if( ExprHasProperty(p, EP_FromJoin)
- && (iTable<0 || p->iRightJoinTable==iTable) ){
+ && (iTable<0 || p->w.iRightJoinTable==iTable) ){
ExprClearProperty(p, EP_FromJoin);
}
if( p->op==TK_COLUMN && p->iTable==iTable ){
@@ -134632,7 +135611,7 @@ SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoAlloc(sqlite3 *db, int N, int X){
p->nRef = 1;
memset(&p[1], 0, nExtra);
}else{
- sqlite3OomFault(db);
+ return (KeyInfo*)sqlite3OomFault(db);
}
return p;
}
@@ -134803,6 +135782,9 @@ static void generateSortTail(
iTab = pSort->iECursor;
if( eDest==SRT_Output || eDest==SRT_Coroutine || eDest==SRT_Mem ){
+ if( eDest==SRT_Mem && p->iOffset ){
+ sqlite3VdbeAddOp2(v, OP_Null, 0, pDest->iSdst);
+ }
regRowid = 0;
regRow = pDest->iSdst;
}else{
@@ -136524,6 +137506,8 @@ static int multiSelectOrderBy(
){
int i, j; /* Loop counters */
Select *pPrior; /* Another SELECT immediately to our left */
+ Select *pSplit; /* Left-most SELECT in the right-hand group */
+ int nSelect; /* Number of SELECT statements in the compound */
Vdbe *v; /* Generate code to this VDBE */
SelectDest destA; /* Destination for coroutine A */
SelectDest destB; /* Destination for coroutine B */
@@ -136569,8 +137553,7 @@ static int multiSelectOrderBy(
/* Patch up the ORDER BY clause
*/
op = p->op;
- pPrior = p->pPrior;
- assert( pPrior->pOrderBy==0 );
+ assert( p->pPrior->pOrderBy==0 );
pOrderBy = p->pOrderBy;
assert( pOrderBy );
nOrderBy = pOrderBy->nExpr;
@@ -136620,11 +137603,6 @@ static int multiSelectOrderBy(
pKeyMerge = 0;
}
- /* Reattach the ORDER BY clause to the query.
- */
- p->pOrderBy = pOrderBy;
- pPrior->pOrderBy = sqlite3ExprListDup(pParse->db, pOrderBy, 0);
-
/* Allocate a range of temporary registers and the KeyInfo needed
** for the logic that removes duplicate result rows when the
** operator is UNION, EXCEPT, or INTERSECT (but not UNION ALL).
@@ -136649,12 +137627,30 @@ static int multiSelectOrderBy(
/* Separate the left and the right query from one another
*/
- p->pPrior = 0;
+ nSelect = 1;
+ if( (op==TK_ALL || op==TK_UNION)
+ && OptimizationEnabled(db, SQLITE_BalancedMerge)
+ ){
+ for(pSplit=p; pSplit->pPrior!=0 && pSplit->op==op; pSplit=pSplit->pPrior){
+ nSelect++;
+ assert( pSplit->pPrior->pNext==pSplit );
+ }
+ }
+ if( nSelect<=3 ){
+ pSplit = p;
+ }else{
+ pSplit = p;
+ for(i=2; i<nSelect; i+=2){ pSplit = pSplit->pPrior; }
+ }
+ pPrior = pSplit->pPrior;
+ assert( pPrior!=0 );
+ pSplit->pPrior = 0;
pPrior->pNext = 0;
+ assert( p->pOrderBy == pOrderBy );
+ assert( pOrderBy!=0 || db->mallocFailed );
+ pPrior->pOrderBy = sqlite3ExprListDup(pParse->db, pOrderBy, 0);
sqlite3ResolveOrderGroupBy(pParse, p, p->pOrderBy, "ORDER");
- if( pPrior->pPrior==0 ){
- sqlite3ResolveOrderGroupBy(pParse, pPrior, pPrior->pOrderBy, "ORDER");
- }
+ sqlite3ResolveOrderGroupBy(pParse, pPrior, pPrior->pOrderBy, "ORDER");
/* Compute the limit registers */
computeLimitRegisters(pParse, p, labelEnd);
@@ -136805,12 +137801,11 @@ static int multiSelectOrderBy(
/* Reassembly the compound query so that it will be freed correctly
** by the calling function */
- if( p->pPrior ){
- sqlite3SelectDelete(db, p->pPrior);
+ if( pSplit->pPrior ){
+ sqlite3SelectDelete(db, pSplit->pPrior);
}
- p->pPrior = pPrior;
- pPrior->pNext = p;
-
+ pSplit->pPrior = pPrior;
+ pPrior->pNext = pSplit;
sqlite3ExprListDelete(db, pPrior->pOrderBy);
pPrior->pOrderBy = 0;
@@ -136860,9 +137855,9 @@ static Expr *substExpr(
){
if( pExpr==0 ) return 0;
if( ExprHasProperty(pExpr, EP_FromJoin)
- && pExpr->iRightJoinTable==pSubst->iTable
+ && pExpr->w.iRightJoinTable==pSubst->iTable
){
- pExpr->iRightJoinTable = pSubst->iNewTable;
+ pExpr->w.iRightJoinTable = pSubst->iNewTable;
}
if( pExpr->op==TK_COLUMN
&& pExpr->iTable==pSubst->iTable
@@ -136901,7 +137896,7 @@ static Expr *substExpr(
ExprSetProperty(pNew, EP_CanBeNull);
}
if( ExprHasProperty(pExpr,EP_FromJoin) ){
- sqlite3SetJoinExpr(pNew, pExpr->iRightJoinTable);
+ sqlite3SetJoinExpr(pNew, pExpr->w.iRightJoinTable);
}
sqlite3ExprDelete(db, pExpr);
pExpr = pNew;
@@ -137066,7 +138061,7 @@ static int renumberCursorsCb(Walker *pWalker, Expr *pExpr){
renumberCursorDoMapping(pWalker, &pExpr->iTable);
}
if( ExprHasProperty(pExpr, EP_FromJoin) ){
- renumberCursorDoMapping(pWalker, &pExpr->iRightJoinTable);
+ renumberCursorDoMapping(pWalker, &pExpr->w.iRightJoinTable);
}
return WRC_Continue;
}
@@ -138076,11 +139071,13 @@ static int pushDownWhereTerms(
}
if( isLeftJoin
&& (ExprHasProperty(pWhere,EP_FromJoin)==0
- || pWhere->iRightJoinTable!=iCursor)
+ || pWhere->w.iRightJoinTable!=iCursor)
){
return 0; /* restriction (4) */
}
- if( ExprHasProperty(pWhere,EP_FromJoin) && pWhere->iRightJoinTable!=iCursor ){
+ if( ExprHasProperty(pWhere,EP_FromJoin)
+ && pWhere->w.iRightJoinTable!=iCursor
+ ){
return 0; /* restriction (5) */
}
if( sqlite3ExprIsTableConstant(pWhere, iCursor) ){
@@ -138800,7 +139797,8 @@ static int selectExpander(Walker *pWalker, Select *p){
/* Process NATURAL keywords, and ON and USING clauses of joins.
*/
- if( pParse->nErr || db->mallocFailed || sqliteProcessJoin(pParse, p) ){
+ assert( db->mallocFailed==0 || pParse->nErr!=0 );
+ if( pParse->nErr || sqliteProcessJoin(pParse, p) ){
return WRC_Abort;
}
@@ -139097,12 +140095,13 @@ SQLITE_PRIVATE void sqlite3SelectPrep(
NameContext *pOuterNC /* Name context for container */
){
assert( p!=0 || pParse->db->mallocFailed );
+ assert( pParse->db->pParse==pParse );
if( pParse->db->mallocFailed ) return;
if( p->selFlags & SF_HasTypeInfo ) return;
sqlite3SelectExpand(pParse, p);
- if( pParse->nErr || pParse->db->mallocFailed ) return;
+ if( pParse->nErr ) return;
sqlite3ResolveSelectNames(pParse, p, pOuterNC);
- if( pParse->nErr || pParse->db->mallocFailed ) return;
+ if( pParse->nErr ) return;
sqlite3SelectAddTypeInfo(pParse, p);
}
@@ -139119,8 +140118,10 @@ static void resetAccumulator(Parse *pParse, AggInfo *pAggInfo){
int i;
struct AggInfo_func *pFunc;
int nReg = pAggInfo->nFunc + pAggInfo->nColumn;
+ assert( pParse->db->pParse==pParse );
+ assert( pParse->db->mallocFailed==0 || pParse->nErr!=0 );
if( nReg==0 ) return;
- if( pParse->nErr || pParse->db->mallocFailed ) return;
+ if( pParse->nErr ) return;
#ifdef SQLITE_DEBUG
/* Verify that all AggInfo registers are within the range specified by
** AggInfo.mnReg..AggInfo.mxReg */
@@ -139543,10 +140544,12 @@ SQLITE_PRIVATE int sqlite3Select(
u8 minMaxFlag; /* Flag for min/max queries */
db = pParse->db;
+ assert( pParse==db->pParse );
v = sqlite3GetVdbe(pParse);
- if( p==0 || db->mallocFailed || pParse->nErr ){
+ if( p==0 || pParse->nErr ){
return 1;
}
+ assert( db->mallocFailed==0 );
if( sqlite3AuthCheck(pParse, SQLITE_SELECT, 0, 0, 0) ) return 1;
#if SELECTTRACE_ENABLED
SELECTTRACE(1,pParse,p, ("begin processing:\n", pParse->addrExplain));
@@ -139581,9 +140584,10 @@ SQLITE_PRIVATE int sqlite3Select(
p->selFlags |= SF_NoopOrderBy;
}
sqlite3SelectPrep(pParse, p, 0);
- if( pParse->nErr || db->mallocFailed ){
+ if( pParse->nErr ){
goto select_end;
}
+ assert( db->mallocFailed==0 );
assert( p->pEList!=0 );
#if SELECTTRACE_ENABLED
if( sqlite3SelectTrace & 0x104 ){
@@ -139627,7 +140631,7 @@ SQLITE_PRIVATE int sqlite3Select(
#ifndef SQLITE_OMIT_WINDOWFUNC
if( sqlite3WindowRewrite(pParse, p) ){
- assert( db->mallocFailed || pParse->nErr>0 );
+ assert( pParse->nErr );
goto select_end;
}
#if SELECTTRACE_ENABLED
@@ -140103,7 +141107,7 @@ SQLITE_PRIVATE int sqlite3Select(
/* Begin the database scan. */
SELECTTRACE(1,pParse,p,("WhereBegin\n"));
pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, sSort.pOrderBy,
- p->pEList, wctrlFlags, p->nSelectRow);
+ p->pEList, p, wctrlFlags, p->nSelectRow);
if( pWInfo==0 ) goto select_end;
if( sqlite3WhereOutputRowCount(pWInfo) < p->nSelectRow ){
p->nSelectRow = sqlite3WhereOutputRowCount(pWInfo);
@@ -140367,7 +141371,7 @@ SQLITE_PRIVATE int sqlite3Select(
sqlite3VdbeAddOp2(v, OP_Gosub, regReset, addrReset);
SELECTTRACE(1,pParse,p,("WhereBegin\n"));
pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, pGroupBy, pDistinct,
- WHERE_GROUPBY | (orderByGrp ? WHERE_SORTBYGROUP : 0) | distFlag, 0
+ 0, (WHERE_GROUPBY|(orderByGrp ? WHERE_SORTBYGROUP : 0)|distFlag), 0
);
if( pWInfo==0 ){
sqlite3ExprListDelete(db, pDistinct);
@@ -140665,7 +141669,7 @@ SQLITE_PRIVATE int sqlite3Select(
SELECTTRACE(1,pParse,p,("WhereBegin\n"));
pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, pMinMaxOrderBy,
- pDistinct, minMaxFlag|distFlag, 0);
+ pDistinct, 0, minMaxFlag|distFlag, 0);
if( pWInfo==0 ){
goto select_end;
}
@@ -140722,7 +141726,7 @@ SQLITE_PRIVATE int sqlite3Select(
*/
select_end:
assert( db->mallocFailed==0 || db->mallocFailed==1 );
- pParse->nErr += db->mallocFailed;
+ assert( db->mallocFailed==0 || pParse->nErr!=0 );
sqlite3ExprListDelete(db, pMinMaxOrderBy);
#ifdef SQLITE_DEBUG
if( pAggInfo && !db->mallocFailed ){
@@ -141402,6 +142406,7 @@ static TriggerStep *triggerStepAllocate(
sqlite3 *db = pParse->db;
TriggerStep *pTriggerStep;
+ if( pParse->nErr ) return 0;
pTriggerStep = sqlite3DbMallocZero(db, sizeof(TriggerStep) + pName->n + 1);
if( pTriggerStep ){
char *z = (char*)&pTriggerStep[1];
@@ -141874,6 +142879,7 @@ static void codeReturningTrigger(
assert( v!=0 );
assert( pParse->bReturning );
+ assert( db->pParse==pParse );
pReturning = pParse->u1.pReturning;
assert( pTrigger == &(pReturning->retTrig) );
memset(&sSelect, 0, sizeof(sSelect));
@@ -141884,12 +142890,13 @@ static void codeReturningTrigger(
sFrom.a[0].pTab = pTab;
sFrom.a[0].iCursor = -1;
sqlite3SelectPrep(pParse, &sSelect, 0);
- if( db->mallocFailed==0 && pParse->nErr==0 ){
+ if( pParse->nErr==0 ){
+ assert( db->mallocFailed==0 );
sqlite3GenerateColumnNames(pParse, &sSelect);
}
sqlite3ExprListDelete(db, sSelect.pEList);
pNew = sqlite3ExpandReturning(pParse, pReturning->pReturnEL, pTab);
- if( pNew ){
+ if( !db->mallocFailed ){
NameContext sNC;
memset(&sNC, 0, sizeof(sNC));
if( pReturning->nRetCol==0 ){
@@ -141901,7 +142908,9 @@ static void codeReturningTrigger(
sNC.ncFlags = NC_UBaseReg;
pParse->eTriggerOp = pTrigger->op;
pParse->pTriggerTab = pTab;
- if( sqlite3ResolveExprListNames(&sNC, pNew)==SQLITE_OK ){
+ if( sqlite3ResolveExprListNames(&sNC, pNew)==SQLITE_OK
+ && ALWAYS(!db->mallocFailed)
+ ){
int i;
int nCol = pNew->nExpr;
int reg = pParse->nMem+1;
@@ -141909,16 +142918,20 @@ static void codeReturningTrigger(
pReturning->iRetReg = reg;
for(i=0; i<nCol; i++){
Expr *pCol = pNew->a[i].pExpr;
+ assert( pCol!=0 ); /* Due to !db->mallocFailed ~9 lines above */
sqlite3ExprCodeFactorable(pParse, pCol, reg+i);
+ if( sqlite3ExprAffinity(pCol)==SQLITE_AFF_REAL ){
+ sqlite3VdbeAddOp1(v, OP_RealAffinity, reg+i);
+ }
}
sqlite3VdbeAddOp3(v, OP_MakeRecord, reg, i, reg+i);
sqlite3VdbeAddOp2(v, OP_NewRowid, pReturning->iRetCur, reg+i+1);
sqlite3VdbeAddOp3(v, OP_Insert, pReturning->iRetCur, reg+i, reg+i+1);
}
- sqlite3ExprListDelete(db, pNew);
- pParse->eTriggerOp = 0;
- pParse->pTriggerTab = 0;
}
+ sqlite3ExprListDelete(db, pNew);
+ pParse->eTriggerOp = 0;
+ pParse->pTriggerTab = 0;
}
@@ -142060,8 +143073,8 @@ static TriggerPrg *codeRowTrigger(
Vdbe *v; /* Temporary VM */
NameContext sNC; /* Name context for sub-vdbe */
SubProgram *pProgram = 0; /* Sub-vdbe for trigger program */
- Parse *pSubParse; /* Parse context for sub-vdbe */
int iEndTrigger = 0; /* Label to jump to if WHEN is false */
+ Parse sSubParse; /* Parse context for sub-vdbe */
assert( pTrigger->zName==0 || pTab==tableOfTrigger(pTrigger) );
assert( pTop->pVdbe );
@@ -142083,19 +143096,17 @@ static TriggerPrg *codeRowTrigger(
/* Allocate and populate a new Parse context to use for coding the
** trigger sub-program. */
- pSubParse = sqlite3StackAllocZero(db, sizeof(Parse));
- if( !pSubParse ) return 0;
+ sqlite3ParseObjectInit(&sSubParse, db);
memset(&sNC, 0, sizeof(sNC));
- sNC.pParse = pSubParse;
- pSubParse->db = db;
- pSubParse->pTriggerTab = pTab;
- pSubParse->pToplevel = pTop;
- pSubParse->zAuthContext = pTrigger->zName;
- pSubParse->eTriggerOp = pTrigger->op;
- pSubParse->nQueryLoop = pParse->nQueryLoop;
- pSubParse->disableVtab = pParse->disableVtab;
-
- v = sqlite3GetVdbe(pSubParse);
+ sNC.pParse = &sSubParse;
+ sSubParse.pTriggerTab = pTab;
+ sSubParse.pToplevel = pTop;
+ sSubParse.zAuthContext = pTrigger->zName;
+ sSubParse.eTriggerOp = pTrigger->op;
+ sSubParse.nQueryLoop = pParse->nQueryLoop;
+ sSubParse.disableVtab = pParse->disableVtab;
+
+ v = sqlite3GetVdbe(&sSubParse);
if( v ){
VdbeComment((v, "Start: %s.%s (%s %s%s%s ON %s)",
pTrigger->zName, onErrorText(orconf),
@@ -142121,14 +143132,14 @@ static TriggerPrg *codeRowTrigger(
if( db->mallocFailed==0
&& SQLITE_OK==sqlite3ResolveExprNames(&sNC, pWhen)
){
- iEndTrigger = sqlite3VdbeMakeLabel(pSubParse);
- sqlite3ExprIfFalse(pSubParse, pWhen, iEndTrigger, SQLITE_JUMPIFNULL);
+ iEndTrigger = sqlite3VdbeMakeLabel(&sSubParse);
+ sqlite3ExprIfFalse(&sSubParse, pWhen, iEndTrigger, SQLITE_JUMPIFNULL);
}
sqlite3ExprDelete(db, pWhen);
}
/* Code the trigger program into the sub-vdbe. */
- codeTriggerProgram(pSubParse, pTrigger->step_list, orconf);
+ codeTriggerProgram(&sSubParse, pTrigger->step_list, orconf);
/* Insert an OP_Halt at the end of the sub-program. */
if( iEndTrigger ){
@@ -142136,23 +143147,24 @@ static TriggerPrg *codeRowTrigger(
}
sqlite3VdbeAddOp0(v, OP_Halt);
VdbeComment((v, "End: %s.%s", pTrigger->zName, onErrorText(orconf)));
+ transferParseError(pParse, &sSubParse);
- transferParseError(pParse, pSubParse);
- if( db->mallocFailed==0 && pParse->nErr==0 ){
+ if( pParse->nErr==0 ){
+ assert( db->mallocFailed==0 );
pProgram->aOp = sqlite3VdbeTakeOpArray(v, &pProgram->nOp, &pTop->nMaxArg);
}
- pProgram->nMem = pSubParse->nMem;
- pProgram->nCsr = pSubParse->nTab;
+ pProgram->nMem = sSubParse.nMem;
+ pProgram->nCsr = sSubParse.nTab;
pProgram->token = (void *)pTrigger;
- pPrg->aColmask[0] = pSubParse->oldmask;
- pPrg->aColmask[1] = pSubParse->newmask;
+ pPrg->aColmask[0] = sSubParse.oldmask;
+ pPrg->aColmask[1] = sSubParse.newmask;
sqlite3VdbeDelete(v);
+ }else{
+ transferParseError(pParse, &sSubParse);
}
- assert( !pSubParse->pTriggerPrg && !pSubParse->nMaxArg );
- sqlite3ParserReset(pSubParse);
- sqlite3StackFree(db, pSubParse);
-
+ assert( !sSubParse.pTriggerPrg && !sSubParse.nMaxArg );
+ sqlite3ParseObjectReset(&sSubParse);
return pPrg;
}
@@ -142185,6 +143197,7 @@ static TriggerPrg *getRowTrigger(
/* If an existing TriggerPrg could not be located, create a new one. */
if( !pPrg ){
pPrg = codeRowTrigger(pParse, pTrigger, pTab, orconf);
+ pParse->db->errByteOffset = -1;
}
return pPrg;
@@ -142207,7 +143220,7 @@ SQLITE_PRIVATE void sqlite3CodeRowTriggerDirect(
Vdbe *v = sqlite3GetVdbe(pParse); /* Main VM */
TriggerPrg *pPrg;
pPrg = getRowTrigger(pParse, p, pTab, orconf);
- assert( pPrg || pParse->nErr || pParse->db->mallocFailed );
+ assert( pPrg || pParse->nErr );
/* Code the OP_Program opcode in the parent VDBE. P4 of the OP_Program
** is a pointer to the sub-vdbe containing the trigger program. */
@@ -142725,9 +143738,11 @@ SQLITE_PRIVATE void sqlite3Update(
memset(&sContext, 0, sizeof(sContext));
db = pParse->db;
- if( pParse->nErr || db->mallocFailed ){
+ assert( db->pParse==pParse );
+ if( pParse->nErr ){
goto update_cleanup;
}
+ assert( db->mallocFailed==0 );
/* Locate the table which we want to update.
*/
@@ -143099,7 +144114,7 @@ SQLITE_PRIVATE void sqlite3Update(
if( !pParse->nested && !pTrigger && !hasFK && !chngKey && !bReplace ){
flags |= WHERE_ONEPASS_MULTIROW;
}
- pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, 0, 0, flags,iIdxCur);
+ pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere,0,0,0,flags,iIdxCur);
if( pWInfo==0 ) goto update_cleanup;
/* A one-pass strategy that might update more than one row may not
@@ -143499,9 +144514,7 @@ SQLITE_PRIVATE void sqlite3Update(
** that information.
*/
if( regRowCount ){
- sqlite3VdbeAddOp2(v, OP_ChngCntRow, regRowCount, 1);
- sqlite3VdbeSetNumCols(v, 1);
- sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "rows updated", SQLITE_STATIC);
+ sqlite3CodeChangeCount(v, regRowCount, "rows updated");
}
update_cleanup:
@@ -143623,7 +144636,9 @@ static void updateVirtualTable(
regRowid = ++pParse->nMem;
/* Start scanning the virtual table */
- pWInfo = sqlite3WhereBegin(pParse, pSrc,pWhere,0,0,WHERE_ONEPASS_DESIRED,0);
+ pWInfo = sqlite3WhereBegin(
+ pParse, pSrc, pWhere, 0, 0, 0, WHERE_ONEPASS_DESIRED, 0
+ );
if( pWInfo==0 ) return;
/* Populate the argument registers. */
@@ -145250,7 +146265,6 @@ SQLITE_API int sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable){
VtabCtx *pCtx;
int rc = SQLITE_OK;
Table *pTab;
- char *zErr = 0;
Parse sParse;
int initBusy;
@@ -145269,9 +146283,8 @@ SQLITE_API int sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable){
pTab = pCtx->pTab;
assert( IsVirtual(pTab) );
- memset(&sParse, 0, sizeof(sParse));
+ sqlite3ParseObjectInit(&sParse, db);
sParse.eParseMode = PARSE_MODE_DECLARE_VTAB;
- sParse.db = db;
/* We should never be able to reach this point while loading the
** schema. Nevertheless, defend against that (turn off db->init.busy)
** in case a bug arises. */
@@ -145279,11 +146292,12 @@ SQLITE_API int sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable){
initBusy = db->init.busy;
db->init.busy = 0;
sParse.nQueryLoop = 1;
- if( SQLITE_OK==sqlite3RunParser(&sParse, zCreateTable, &zErr)
- && sParse.pNewTable
- && !db->mallocFailed
+ if( SQLITE_OK==sqlite3RunParser(&sParse, zCreateTable)
+ && ALWAYS(sParse.pNewTable!=0)
+ && ALWAYS(!db->mallocFailed)
&& IsOrdinaryTable(sParse.pNewTable)
){
+ assert( sParse.zErrMsg==0 );
if( !pTab->aCol ){
Table *pNew = sParse.pNewTable;
Index *pIdx;
@@ -145313,8 +146327,9 @@ SQLITE_API int sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable){
}
pCtx->bDeclared = 1;
}else{
- sqlite3ErrorWithMsg(db, SQLITE_ERROR, (zErr ? "%s" : 0), zErr);
- sqlite3DbFree(db, zErr);
+ sqlite3ErrorWithMsg(db, SQLITE_ERROR,
+ (sParse.zErrMsg ? "%s" : 0), sParse.zErrMsg);
+ sqlite3DbFree(db, sParse.zErrMsg);
rc = SQLITE_ERROR;
}
sParse.eParseMode = PARSE_MODE_NORMAL;
@@ -145323,7 +146338,7 @@ SQLITE_API int sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable){
sqlite3VdbeFinalize(sParse.pVdbe);
}
sqlite3DeleteTable(db, sParse.pNewTable);
- sqlite3ParserReset(&sParse);
+ sqlite3ParseObjectReset(&sParse);
db->init.busy = initBusy;
assert( (rc&0xff)==rc );
@@ -145875,6 +146890,7 @@ struct WhereLevel {
u32 iLikeRepCntr; /* LIKE range processing counter register (times 2) */
int addrLikeRep; /* LIKE range processing address */
#endif
+ int regFilter; /* Bloom filter */
u8 iFrom; /* Which entry in the FROM clause */
u8 op, p3, p5; /* Opcode, P3 & P5 of the opcode that ends the loop */
int p1, p2; /* Operands of the opcode used to end the loop */
@@ -145933,10 +146949,12 @@ struct WhereLoop {
} btree;
struct { /* Information for virtual tables */
int idxNum; /* Index number */
- u8 needFree; /* True if sqlite3_free(idxStr) is needed */
+ u32 needFree : 1; /* True if sqlite3_free(idxStr) is needed */
+ u32 bOmitOffset : 1; /* True to let virtual table handle offset */
i8 isOrdered; /* True if satisfies ORDER BY */
u16 omitMask; /* Terms that may be omitted */
char *idxStr; /* Index identifier string */
+ u32 mHandleIn; /* Terms to handle as IN(...) instead of == */
} vtab;
} u;
u32 wsFlags; /* WHERE_* flags describing the plan */
@@ -146080,7 +147098,7 @@ struct WhereTerm {
#define TERM_COPIED 0x0008 /* Has a child */
#define TERM_ORINFO 0x0010 /* Need to free the WhereTerm.u.pOrInfo object */
#define TERM_ANDINFO 0x0020 /* Need to free the WhereTerm.u.pAndInfo obj */
-#define TERM_OR_OK 0x0040 /* Used during OR-clause processing */
+#define TERM_OK 0x0040 /* Used during OR-clause processing */
#define TERM_VNULL 0x0080 /* Manufactured x>NULL or x<=NULL term */
#define TERM_LIKEOPT 0x0100 /* Virtual terms from the LIKE optimization */
#define TERM_LIKECOND 0x0200 /* Conditionally this LIKE operator term */
@@ -146093,6 +147111,7 @@ struct WhereTerm {
#else
# define TERM_HIGHTRUTH 0 /* Only used with STAT4 */
#endif
+#define TERM_SLICE 0x8000 /* One slice of a row-value/vector comparison */
/*
** An instance of the WhereScan object is used as an iterator for locating
@@ -146103,11 +147122,11 @@ struct WhereScan {
WhereClause *pWC; /* WhereClause currently being scanned */
const char *zCollName; /* Required collating sequence, if not NULL */
Expr *pIdxExpr; /* Search for this index expression */
+ int k; /* Resume scanning at this->pWC->a[this->k] */
+ u32 opMask; /* Acceptable operators */
char idxaff; /* Must match this affinity, if zCollName!=NULL */
+ unsigned char iEquiv; /* Current slot in aiCur[] and aiColumn[] */
unsigned char nEquiv; /* Number of entries in aiCur[] and aiColumn[] */
- unsigned char iEquiv; /* Next unused slot in aiCur[] and aiColumn[] */
- u32 opMask; /* Acceptable operators */
- int k; /* Resume scanning at this->pWC->a[this->k] */
int aiCur[11]; /* Cursors in the equivalence class */
i16 aiColumn[11]; /* Corresponding column number in the eq-class */
};
@@ -146131,6 +147150,7 @@ struct WhereClause {
u8 hasOr; /* True if any a[].eOperator is WO_OR */
int nTerm; /* Number of terms */
int nSlot; /* Number of entries in a[] */
+ int nBase; /* Number of terms through the last non-Virtual */
WhereTerm *a; /* Each a[] describes a term of the WHERE cluase */
#if defined(SQLITE_SMALL_STACK)
WhereTerm aStatic[1]; /* Initial static space for a[] */
@@ -146189,18 +147209,12 @@ struct WhereMaskSet {
};
/*
-** Initialize a WhereMaskSet object
-*/
-#define initMaskSet(P) (P)->n=0
-
-/*
** This object is a convenience wrapper holding all information needed
** to construct WhereLoop objects for a particular query.
*/
struct WhereLoopBuilder {
WhereInfo *pWInfo; /* Information about this WHERE */
WhereClause *pWC; /* WHERE clause terms */
- ExprList *pOrderBy; /* ORDER BY clause */
WhereLoop *pNew; /* Template WhereLoop */
WhereOrSet *pOrSet; /* Record best loops here, if not NULL */
#ifdef SQLITE_ENABLE_STAT4
@@ -146268,6 +147282,9 @@ struct WhereInfo {
ExprList *pOrderBy; /* The ORDER BY clause or NULL */
ExprList *pResultSet; /* Result set of the query */
Expr *pWhere; /* The complete WHERE clause */
+#ifndef SQLITE_OMIT_VIRTUALTABLE
+ Select *pLimit; /* Used to access LIMIT expr/registers for vtabs */
+#endif
int aiCurOnePass[2]; /* OP_OpenWrite cursors for the ONEPASS opt */
int iContinue; /* Jump here to continue with next record */
int iBreak; /* Jump here to break out of the loop */
@@ -146321,8 +147338,14 @@ SQLITE_PRIVATE int sqlite3WhereExplainOneScan(
WhereLevel *pLevel, /* Scan to write OP_Explain opcode for */
u16 wctrlFlags /* Flags passed to sqlite3WhereBegin() */
);
+SQLITE_PRIVATE int sqlite3WhereExplainBloomFilter(
+ const Parse *pParse, /* Parse context */
+ const WhereInfo *pWInfo, /* WHERE clause */
+ const WhereLevel *pLevel /* Bloom filter on this level */
+);
#else
# define sqlite3WhereExplainOneScan(u,v,w,x) 0
+# define sqlite3WhereExplainBloomFilter(u,v,w) 0
#endif /* SQLITE_OMIT_EXPLAIN */
#ifdef SQLITE_ENABLE_STMT_SCANSTATUS
SQLITE_PRIVATE void sqlite3WhereAddScanStatus(
@@ -146347,6 +147370,7 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(
SQLITE_PRIVATE void sqlite3WhereClauseInit(WhereClause*,WhereInfo*);
SQLITE_PRIVATE void sqlite3WhereClauseClear(WhereClause*);
SQLITE_PRIVATE void sqlite3WhereSplit(WhereClause*,Expr*,u8);
+SQLITE_PRIVATE void sqlite3WhereAddLimit(WhereClause*, Select*);
SQLITE_PRIVATE Bitmask sqlite3WhereExprUsage(WhereMaskSet*, Expr*);
SQLITE_PRIVATE Bitmask sqlite3WhereExprUsageNN(WhereMaskSet*, Expr*);
SQLITE_PRIVATE Bitmask sqlite3WhereExprListUsage(WhereMaskSet*, ExprList*);
@@ -146415,6 +147439,9 @@ SQLITE_PRIVATE void sqlite3WhereTabFuncArgs(Parse*, SrcItem*, WhereClause*);
#define WHERE_BIGNULL_SORT 0x00080000 /* Column nEq of index is BIGNULL */
#define WHERE_IN_SEEKSCAN 0x00100000 /* Seek-scan optimization for IN */
#define WHERE_TRANSCONS 0x00200000 /* Uses a transitive constraint */
+#define WHERE_BLOOMFILTER 0x00400000 /* Consider using a Bloom-filter */
+#define WHERE_SELFCULL 0x00800000 /* nOut reduced by extra WHERE terms */
+#define WHERE_OMIT_OFFSET 0x01000000 /* Set offset counter to zero */
#endif /* !defined(SQLITE_WHEREINT_H) */
@@ -146577,19 +147604,27 @@ SQLITE_PRIVATE int sqlite3WhereExplainOneScan(
explainIndexRange(&str, pLoop);
}
}else if( (flags & WHERE_IPK)!=0 && (flags & WHERE_CONSTRAINT)!=0 ){
- const char *zRangeOp;
+ char cRangeOp;
+#if 0 /* Better output, but breaks many tests */
+ const Table *pTab = pItem->pTab;
+ const char *zRowid = pTab->iPKey>=0 ? pTab->aCol[pTab->iPKey].zCnName:
+ "rowid";
+#else
+ const char *zRowid = "rowid";
+#endif
+ sqlite3_str_appendf(&str, " USING INTEGER PRIMARY KEY (%s", zRowid);
if( flags&(WHERE_COLUMN_EQ|WHERE_COLUMN_IN) ){
- zRangeOp = "=";
+ cRangeOp = '=';
}else if( (flags&WHERE_BOTH_LIMIT)==WHERE_BOTH_LIMIT ){
- zRangeOp = ">? AND rowid<";
+ sqlite3_str_appendf(&str, ">? AND %s", zRowid);
+ cRangeOp = '<';
}else if( flags&WHERE_BTM_LIMIT ){
- zRangeOp = ">";
+ cRangeOp = '>';
}else{
assert( flags&WHERE_TOP_LIMIT);
- zRangeOp = "<";
+ cRangeOp = '<';
}
- sqlite3_str_appendf(&str,
- " USING INTEGER PRIMARY KEY (rowid%s?)",zRangeOp);
+ sqlite3_str_appendf(&str, "%c?)", cRangeOp);
}
#ifndef SQLITE_OMIT_VIRTUALTABLE
else if( (flags & WHERE_VIRTUALTABLE)!=0 ){
@@ -146612,6 +147647,56 @@ SQLITE_PRIVATE int sqlite3WhereExplainOneScan(
}
return ret;
}
+
+/*
+** Add a single OP_Explain opcode that describes a Bloom filter.
+**
+** Or if not processing EXPLAIN QUERY PLAN and not in a SQLITE_DEBUG and/or
+** SQLITE_ENABLE_STMT_SCANSTATUS build, then OP_Explain opcodes are not
+** required and this routine is a no-op.
+**
+** If an OP_Explain opcode is added to the VM, its address is returned.
+** Otherwise, if no OP_Explain is coded, zero is returned.
+*/
+SQLITE_PRIVATE int sqlite3WhereExplainBloomFilter(
+ const Parse *pParse, /* Parse context */
+ const WhereInfo *pWInfo, /* WHERE clause */
+ const WhereLevel *pLevel /* Bloom filter on this level */
+){
+ int ret = 0;
+ SrcItem *pItem = &pWInfo->pTabList->a[pLevel->iFrom];
+ Vdbe *v = pParse->pVdbe; /* VM being constructed */
+ sqlite3 *db = pParse->db; /* Database handle */
+ char *zMsg; /* Text to add to EQP output */
+ int i; /* Loop counter */
+ WhereLoop *pLoop; /* The where loop */
+ StrAccum str; /* EQP output string */
+ char zBuf[100]; /* Initial space for EQP output string */
+
+ sqlite3StrAccumInit(&str, db, zBuf, sizeof(zBuf), SQLITE_MAX_LENGTH);
+ str.printfFlags = SQLITE_PRINTF_INTERNAL;
+ sqlite3_str_appendf(&str, "BLOOM FILTER ON %S (", pItem);
+ pLoop = pLevel->pWLoop;
+ if( pLoop->wsFlags & WHERE_IPK ){
+ const Table *pTab = pItem->pTab;
+ if( pTab->iPKey>=0 ){
+ sqlite3_str_appendf(&str, "%s=?", pTab->aCol[pTab->iPKey].zCnName);
+ }else{
+ sqlite3_str_appendf(&str, "rowid=?");
+ }
+ }else{
+ for(i=pLoop->nSkip; i<pLoop->u.btree.nEq; i++){
+ const char *z = explainIndexColumnName(pLoop->u.btree.pIndex, i);
+ if( i>pLoop->nSkip ) sqlite3_str_append(&str, " AND ", 5);
+ sqlite3_str_appendf(&str, "%s=?", z);
+ }
+ }
+ sqlite3_str_append(&str, ")", 1);
+ zMsg = sqlite3StrAccumFinish(&str);
+ ret = sqlite3VdbeAddOp4(v, OP_Explain, sqlite3VdbeCurrentAddr(v),
+ pParse->addrExplain, 0, zMsg,P4_DYNAMIC);
+ return ret;
+}
#endif /* SQLITE_OMIT_EXPLAIN */
#ifdef SQLITE_ENABLE_STMT_SCANSTATUS
@@ -147135,6 +148220,7 @@ static int codeAllEqualityTerms(
VdbeCoverageIf(v, bRev!=0);
VdbeComment((v, "begin skip-scan on %s", pIdx->zName));
j = sqlite3VdbeAddOp0(v, OP_Goto);
+ assert( pLevel->addrSkip==0 );
pLevel->addrSkip = sqlite3VdbeAddOp4Int(v, (bRev?OP_SeekLT:OP_SeekGT),
iIdxCur, 0, regBase, nSkip);
VdbeCoverageIf(v, bRev==0);
@@ -147167,6 +148253,9 @@ static int codeAllEqualityTerms(
sqlite3VdbeAddOp2(v, OP_Copy, r1, regBase+j);
}
}
+ }
+ for(j=nSkip; j<nEq; j++){
+ pTerm = pLoop->aLTerm[j];
if( pTerm->eOperator & WO_IN ){
if( pTerm->pExpr->flags & EP_xIsSelect ){
/* No affinity ever needs to be (or should be) applied to a value
@@ -147181,7 +148270,8 @@ static int codeAllEqualityTerms(
sqlite3VdbeAddOp2(v, OP_IsNull, regBase+j, pLevel->addrBrk);
VdbeCoverage(v);
}
- if( pParse->db->mallocFailed==0 && pParse->nErr==0 ){
+ if( pParse->nErr==0 ){
+ assert( pParse->db->mallocFailed==0 );
if( sqlite3CompareAffinity(pRight, zAff[j])==SQLITE_AFF_BLOB ){
zAff[j] = SQLITE_AFF_BLOB;
}
@@ -147371,7 +148461,7 @@ static void codeCursorHint(
sWalker.pParse = pParse;
sWalker.u.pCCurHint = &sHint;
pWC = &pWInfo->sWC;
- for(i=0; i<pWC->nTerm; i++){
+ for(i=0; i<pWC->nBase; i++){
pTerm = &pWC->a[i];
if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
if( pTerm->prereqAll & pLevel->notReady ) continue;
@@ -147401,7 +148491,7 @@ static void codeCursorHint(
if( pTabItem->fg.jointype & JT_LEFT ){
Expr *pExpr = pTerm->pExpr;
if( !ExprHasProperty(pExpr, EP_FromJoin)
- || pExpr->iRightJoinTable!=pTabItem->iCursor
+ || pExpr->w.iRightJoinTable!=pTabItem->iCursor
){
sWalker.eCode = 0;
sWalker.xExprCallback = codeCursorHintIsOrFunction;
@@ -147703,6 +148793,65 @@ static void whereApplyPartialIndexConstraints(
}
/*
+** This routine is called right after An OP_Filter has been generated and
+** before the corresponding index search has been performed. This routine
+** checks to see if there are additional Bloom filters in inner loops that
+** can be checked prior to doing the index lookup. If there are available
+** inner-loop Bloom filters, then evaluate those filters now, before the
+** index lookup. The idea is that a Bloom filter check is way faster than
+** an index lookup, and the Bloom filter might return false, meaning that
+** the index lookup can be skipped.
+**
+** We know that an inner loop uses a Bloom filter because it has the
+** WhereLevel.regFilter set. If an inner-loop Bloom filter is checked,
+** then clear the WhereLevel.regFilter value to prevent the Bloom filter
+** from being checked a second time when the inner loop is evaluated.
+*/
+static SQLITE_NOINLINE void filterPullDown(
+ Parse *pParse, /* Parsing context */
+ WhereInfo *pWInfo, /* Complete information about the WHERE clause */
+ int iLevel, /* Which level of pWInfo->a[] should be coded */
+ int addrNxt, /* Jump here to bypass inner loops */
+ Bitmask notReady /* Loops that are not ready */
+){
+ while( ++iLevel < pWInfo->nLevel ){
+ WhereLevel *pLevel = &pWInfo->a[iLevel];
+ WhereLoop *pLoop = pLevel->pWLoop;
+ if( pLevel->regFilter==0 ) continue;
+ if( pLevel->pWLoop->nSkip ) continue;
+ /* ,--- Because sqlite3ConstructBloomFilter() has will not have set
+ ** vvvvv--' pLevel->regFilter if this were true. */
+ if( NEVER(pLoop->prereq & notReady) ) continue;
+ if( pLoop->wsFlags & WHERE_IPK ){
+ WhereTerm *pTerm = pLoop->aLTerm[0];
+ int regRowid;
+ assert( pTerm!=0 );
+ assert( pTerm->pExpr!=0 );
+ testcase( pTerm->wtFlags & TERM_VIRTUAL );
+ regRowid = sqlite3GetTempReg(pParse);
+ regRowid = codeEqualityTerm(pParse, pTerm, pLevel, 0, 0, regRowid);
+ sqlite3VdbeAddOp4Int(pParse->pVdbe, OP_Filter, pLevel->regFilter,
+ addrNxt, regRowid, 1);
+ VdbeCoverage(pParse->pVdbe);
+ }else{
+ u16 nEq = pLoop->u.btree.nEq;
+ int r1;
+ char *zStartAff;
+
+ assert( pLoop->wsFlags & WHERE_INDEXED );
+ assert( (pLoop->wsFlags & WHERE_COLUMN_IN)==0 );
+ r1 = codeAllEqualityTerms(pParse,pLevel,0,0,&zStartAff);
+ codeApplyAffinity(pParse, r1, nEq, zStartAff);
+ sqlite3DbFree(pParse->db, zStartAff);
+ sqlite3VdbeAddOp4Int(pParse->pVdbe, OP_Filter, pLevel->regFilter,
+ addrNxt, r1, nEq);
+ VdbeCoverage(pParse->pVdbe);
+ }
+ pLevel->regFilter = 0;
+ }
+}
+
+/*
** Generate code for the start of the iLevel-th loop in the WHERE clause
** implementation described by pWInfo.
*/
@@ -147804,7 +148953,6 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(
int iReg; /* P3 Value for OP_VFilter */
int addrNotFound;
int nConstraint = pLoop->nLTerm;
- int iIn; /* Counter for IN constraints */
iReg = sqlite3GetTempRange(pParse, nConstraint+2);
addrNotFound = pLevel->addrBrk;
@@ -147813,11 +148961,27 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(
pTerm = pLoop->aLTerm[j];
if( NEVER(pTerm==0) ) continue;
if( pTerm->eOperator & WO_IN ){
- codeEqualityTerm(pParse, pTerm, pLevel, j, bRev, iTarget);
- addrNotFound = pLevel->addrNxt;
+ if( SMASKBIT32(j) & pLoop->u.vtab.mHandleIn ){
+ int iTab = pParse->nTab++;
+ int iCache = ++pParse->nMem;
+ sqlite3CodeRhsOfIN(pParse, pTerm->pExpr, iTab);
+ sqlite3VdbeAddOp3(v, OP_VInitIn, iTab, iTarget, iCache);
+ }else{
+ codeEqualityTerm(pParse, pTerm, pLevel, j, bRev, iTarget);
+ addrNotFound = pLevel->addrNxt;
+ }
}else{
Expr *pRight = pTerm->pExpr->pRight;
codeExprOrVector(pParse, pRight, iTarget, 1);
+ if( pTerm->eMatchOp==SQLITE_INDEX_CONSTRAINT_OFFSET
+ && pLoop->u.vtab.bOmitOffset
+ ){
+ assert( pTerm->eOperator==WO_AUX );
+ assert( pWInfo->pLimit!=0 );
+ assert( pWInfo->pLimit->iOffset>0 );
+ sqlite3VdbeAddOp2(v, OP_Integer, 0, pWInfo->pLimit->iOffset);
+ VdbeComment((v,"Zero OFFSET counter"));
+ }
}
}
sqlite3VdbeAddOp2(v, OP_Integer, pLoop->u.vtab.idxNum, iReg);
@@ -147834,44 +148998,54 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(
pLevel->op = pWInfo->eOnePass ? OP_Noop : OP_VNext;
pLevel->p2 = sqlite3VdbeCurrentAddr(v);
assert( (pLoop->wsFlags & WHERE_MULTI_OR)==0 );
- if( pLoop->wsFlags & WHERE_IN_ABLE ){
- iIn = pLevel->u.in.nIn;
- }else{
- iIn = 0;
- }
- for(j=nConstraint-1; j>=0; j--){
+
+ for(j=0; j<nConstraint; j++){
pTerm = pLoop->aLTerm[j];
- if( (pTerm->eOperator & WO_IN)!=0 ) iIn--;
if( j<16 && (pLoop->u.vtab.omitMask>>j)&1 ){
disableTerm(pLevel, pTerm);
- }else if( (pTerm->eOperator & WO_IN)!=0
- && sqlite3ExprVectorSize(pTerm->pExpr->pLeft)==1
+ continue;
+ }
+ if( (pTerm->eOperator & WO_IN)!=0
+ && (SMASKBIT32(j) & pLoop->u.vtab.mHandleIn)==0
+ && !db->mallocFailed
){
Expr *pCompare; /* The comparison operator */
Expr *pRight; /* RHS of the comparison */
VdbeOp *pOp; /* Opcode to access the value of the IN constraint */
+ int iIn; /* IN loop corresponding to the j-th constraint */
/* Reload the constraint value into reg[iReg+j+2]. The same value
** was loaded into the same register prior to the OP_VFilter, but
** the xFilter implementation might have changed the datatype or
- ** encoding of the value in the register, so it *must* be reloaded. */
- assert( pLevel->u.in.aInLoop!=0 || db->mallocFailed );
- if( !db->mallocFailed ){
- assert( iIn>=0 && iIn<pLevel->u.in.nIn );
+ ** encoding of the value in the register, so it *must* be reloaded.
+ */
+ for(iIn=0; ALWAYS(iIn<pLevel->u.in.nIn); iIn++){
pOp = sqlite3VdbeGetOp(v, pLevel->u.in.aInLoop[iIn].addrInTop);
- assert( pOp->opcode==OP_Column || pOp->opcode==OP_Rowid );
- assert( pOp->opcode!=OP_Column || pOp->p3==iReg+j+2 );
- assert( pOp->opcode!=OP_Rowid || pOp->p2==iReg+j+2 );
- testcase( pOp->opcode==OP_Rowid );
- sqlite3VdbeAddOp3(v, pOp->opcode, pOp->p1, pOp->p2, pOp->p3);
+ if( (pOp->opcode==OP_Column && pOp->p3==iReg+j+2)
+ || (pOp->opcode==OP_Rowid && pOp->p2==iReg+j+2)
+ ){
+ testcase( pOp->opcode==OP_Rowid );
+ sqlite3VdbeAddOp3(v, pOp->opcode, pOp->p1, pOp->p2, pOp->p3);
+ break;
+ }
}
/* Generate code that will continue to the next row if
- ** the IN constraint is not satisfied */
+ ** the IN constraint is not satisfied
+ */
pCompare = sqlite3PExpr(pParse, TK_EQ, 0, 0);
- assert( pCompare!=0 || db->mallocFailed );
- if( pCompare ){
- pCompare->pLeft = pTerm->pExpr->pLeft;
+ if( !db->mallocFailed ){
+ int iFld = pTerm->u.x.iField;
+ Expr *pLeft = pTerm->pExpr->pLeft;
+ assert( pLeft!=0 );
+ if( iFld>0 ){
+ assert( pLeft->op==TK_VECTOR );
+ assert( ExprUseXList(pLeft) );
+ assert( iFld<=pLeft->x.pList->nExpr );
+ pCompare->pLeft = pLeft->x.pList->a[iFld-1].pExpr;
+ }else{
+ pCompare->pLeft = pLeft;
+ }
pCompare->pRight = pRight = sqlite3Expr(db, TK_REGISTER, 0);
if( pRight ){
pRight->iTable = iReg+j+2;
@@ -147880,11 +149054,11 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(
);
}
pCompare->pLeft = 0;
- sqlite3ExprDelete(db, pCompare);
}
+ sqlite3ExprDelete(db, pCompare);
}
}
- assert( iIn==0 || db->mallocFailed );
+
/* These registers need to be preserved in case there is an IN operator
** loop. So we could deallocate the registers here (and potentially
** reuse them later) if (pLoop->wsFlags & WHERE_IN_ABLE)==0. But it seems
@@ -147912,6 +149086,12 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(
iRowidReg = codeEqualityTerm(pParse, pTerm, pLevel, 0, bRev, iReleaseReg);
if( iRowidReg!=iReleaseReg ) sqlite3ReleaseTempReg(pParse, iReleaseReg);
addrNxt = pLevel->addrNxt;
+ if( pLevel->regFilter ){
+ sqlite3VdbeAddOp4Int(v, OP_Filter, pLevel->regFilter, addrNxt,
+ iRowidReg, 1);
+ VdbeCoverage(v);
+ filterPullDown(pParse, pWInfo, iLevel, addrNxt, notReady);
+ }
sqlite3VdbeAddOp3(v, OP_SeekRowid, iCur, addrNxt, iRowidReg);
VdbeCoverage(v);
pLevel->op = OP_Noop;
@@ -148237,6 +149417,12 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(
sqlite3VdbeAddOp2(v, OP_Integer, 1, regBignull);
VdbeComment((v, "NULL-scan pass ctr"));
}
+ if( pLevel->regFilter ){
+ sqlite3VdbeAddOp4Int(v, OP_Filter, pLevel->regFilter, addrNxt,
+ regBase, nEq);
+ VdbeCoverage(v);
+ filterPullDown(pParse, pWInfo, iLevel, addrNxt, notReady);
+ }
op = aStartOp[(start_constraints<<2) + (startEq<<1) + bRev];
assert( op!=0 );
@@ -148564,7 +149750,7 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(
iRetInit = sqlite3VdbeAddOp2(v, OP_Integer, 0, regReturn);
/* If the original WHERE clause is z of the form: (x1 OR x2 OR ...) AND y
- ** Then for every term xN, evaluate as the subexpression: xN AND z
+ ** Then for every term xN, evaluate as the subexpression: xN AND y
** That way, terms in y that are factored into the disjunction will
** be picked up by the recursive calls to sqlite3WhereBegin() below.
**
@@ -148576,6 +149762,20 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(
** This optimization also only applies if the (x1 OR x2 OR ...) term
** is not contained in the ON clause of a LEFT JOIN.
** See ticket http://www.sqlite.org/src/info/f2369304e4
+ **
+ ** 2022-02-04: Do not push down slices of a row-value comparison.
+ ** In other words, "w" or "y" may not be a slice of a vector. Otherwise,
+ ** the initialization of the right-hand operand of the vector comparison
+ ** might not occur, or might occur only in an OR branch that is not
+ ** taken. dbsqlfuzz 80a9fade844b4fb43564efc972bcb2c68270f5d1.
+ **
+ ** 2022-03-03: Do not push down expressions that involve subqueries.
+ ** The subquery might get coded as a subroutine. Any table-references
+ ** in the subquery might be resolved to index-references for the index on
+ ** the OR branch in which the subroutine is coded. But if the subroutine
+ ** is invoked from a different OR branch that uses a different index, such
+ ** index-references will not work. tag-20220303a
+ ** https://sqlite.org/forum/forumpost/36937b197273d403
*/
if( pWC->nTerm>1 ){
int iTerm;
@@ -148584,9 +149784,12 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(
if( &pWC->a[iTerm] == pTerm ) continue;
testcase( pWC->a[iTerm].wtFlags & TERM_VIRTUAL );
testcase( pWC->a[iTerm].wtFlags & TERM_CODED );
- if( (pWC->a[iTerm].wtFlags & (TERM_VIRTUAL|TERM_CODED))!=0 ) continue;
+ testcase( pWC->a[iTerm].wtFlags & TERM_SLICE );
+ if( (pWC->a[iTerm].wtFlags & (TERM_VIRTUAL|TERM_CODED|TERM_SLICE))!=0 ){
+ continue;
+ }
if( (pWC->a[iTerm].eOperator & WO_ALL)==0 ) continue;
- testcase( pWC->a[iTerm].wtFlags & TERM_ORINFO );
+ if( ExprHasProperty(pExpr, EP_Subquery) ) continue; /* tag-20220303a */
pExpr = sqlite3ExprDup(db, pExpr, 0);
pAndExpr = sqlite3ExprAnd(pParse, pAndExpr, pExpr);
}
@@ -148627,9 +149830,9 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(
/* 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,
+ pSubWInfo = sqlite3WhereBegin(pParse, pOrTab, pOrExpr, 0, 0, 0,
WHERE_OR_SUBCLAUSE, iCovCur);
- assert( pSubWInfo || pParse->nErr || db->mallocFailed );
+ assert( pSubWInfo || pParse->nErr );
if( pSubWInfo ){
WhereLoop *pSubLoop;
int addrExplain = sqlite3WhereExplainOneScan(
@@ -148868,7 +150071,7 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(
** then we cannot use the "t1.a=t2.b" constraint, but we can code
** the implied "t1.a=123" constraint.
*/
- for(pTerm=pWC->a, j=pWC->nTerm; j>0; j--, pTerm++){
+ for(pTerm=pWC->a, j=pWC->nBase; j>0; j--, pTerm++){
Expr *pE, sEAlt;
WhereTerm *pAlt;
if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
@@ -148913,7 +150116,7 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(
pLevel->addrFirst = sqlite3VdbeCurrentAddr(v);
sqlite3VdbeAddOp2(v, OP_Integer, 1, pLevel->iLeftJoin);
VdbeComment((v, "record LEFT JOIN hit"));
- for(pTerm=pWC->a, j=0; j<pWC->nTerm; j++, pTerm++){
+ for(pTerm=pWC->a, j=0; j<pWC->nBase; j++, pTerm++){
testcase( pTerm->wtFlags & TERM_VIRTUAL );
testcase( pTerm->wtFlags & TERM_CODED );
if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
@@ -149024,6 +150227,7 @@ static int whereClauseInsert(WhereClause *pWC, Expr *p, u16 wtFlags){
pWC->nSlot = sqlite3DbMallocSize(db, pWC->a)/sizeof(pWC->a[0]);
}
pTerm = &pWC->a[idx = pWC->nTerm++];
+ if( (wtFlags & TERM_VIRTUAL)==0 ) pWC->nBase = pWC->nTerm;
if( p && ExprHasProperty(p, EP_Unlikely) ){
pTerm->truthProb = sqlite3LogEst(p->iTable) - 270;
}else{
@@ -149366,7 +150570,7 @@ static int isAuxiliaryVtabOperator(
assert( pVtab!=0 );
assert( pVtab->pModule!=0 );
assert( !ExprHasProperty(pExpr, EP_IntValue) );
- pMod = (sqlite3_module *)pVtab->pModule;
+ pMod = (sqlite3_module *)pVtab->pModule;
if( pMod->xFindFunction!=0 ){
i = pMod->xFindFunction(pVtab,2, pExpr->u.zToken, &xNotUsed, &pNotUsed);
if( i>=SQLITE_INDEX_CONSTRAINT_FUNCTION ){
@@ -149410,7 +150614,7 @@ static int isAuxiliaryVtabOperator(
static void transferJoinMarkings(Expr *pDerived, Expr *pBase){
if( pDerived ){
pDerived->flags |= pBase->flags & EP_FromJoin;
- pDerived->iRightJoinTable = pBase->iRightJoinTable;
+ pDerived->w.iRightJoinTable = pBase->w.iRightJoinTable;
}
}
@@ -149740,7 +150944,7 @@ static void exprAnalyzeOrTerm(
pOrTerm = pOrWc->a;
for(i=pOrWc->nTerm-1; i>=0; i--, pOrTerm++){
assert( pOrTerm->eOperator & WO_EQ );
- pOrTerm->wtFlags &= ~TERM_OR_OK;
+ pOrTerm->wtFlags &= ~TERM_OK;
if( pOrTerm->leftCursor==iCursor ){
/* This is the 2-bit case and we are on the second iteration and
** current term is from the first iteration. So skip this term. */
@@ -149781,7 +150985,7 @@ static void exprAnalyzeOrTerm(
assert( pOrTerm->eOperator & WO_EQ );
assert( (pOrTerm->eOperator & (WO_OR|WO_AND))==0 );
if( pOrTerm->leftCursor!=iCursor ){
- pOrTerm->wtFlags &= ~TERM_OR_OK;
+ pOrTerm->wtFlags &= ~TERM_OK;
}else if( pOrTerm->u.x.leftColumn!=iColumn || (iColumn==XN_EXPR
&& sqlite3ExprCompare(pParse, pOrTerm->pExpr->pLeft, pLeft, -1)
)){
@@ -149797,7 +151001,7 @@ static void exprAnalyzeOrTerm(
if( affRight!=0 && affRight!=affLeft ){
okToChngToIN = 0;
}else{
- pOrTerm->wtFlags |= TERM_OR_OK;
+ pOrTerm->wtFlags |= TERM_OK;
}
}
}
@@ -149814,7 +151018,7 @@ static void exprAnalyzeOrTerm(
Expr *pNew; /* The complete IN operator */
for(i=pOrWc->nTerm-1, pOrTerm=pOrWc->a; i>=0; i--, pOrTerm++){
- if( (pOrTerm->wtFlags & TERM_OR_OK)==0 ) continue;
+ if( (pOrTerm->wtFlags & TERM_OK)==0 ) continue;
assert( pOrTerm->eOperator & WO_EQ );
assert( (pOrTerm->eOperator & (WO_OR|WO_AND))==0 );
assert( pOrTerm->leftCursor==iCursor );
@@ -150015,10 +151219,13 @@ static void exprAnalyze(
if( db->mallocFailed ){
return;
}
+ assert( pWC->nTerm > idxTerm );
pTerm = &pWC->a[idxTerm];
pMaskSet = &pWInfo->sMaskSet;
pExpr = pTerm->pExpr;
+ assert( pExpr!=0 ); /* Because malloc() has not failed */
assert( pExpr->op!=TK_AS && pExpr->op!=TK_COLLATE );
+ pMaskSet->bVarSelect = 0;
prereqLeft = sqlite3WhereExprUsage(pMaskSet, pExpr->pLeft);
op = pExpr->op;
if( op==TK_IN ){
@@ -150029,16 +151236,30 @@ static void exprAnalyze(
}else{
pTerm->prereqRight = sqlite3WhereExprListUsage(pMaskSet, pExpr->x.pList);
}
- }else if( op==TK_ISNULL ){
- pTerm->prereqRight = 0;
+ prereqAll = prereqLeft | pTerm->prereqRight;
}else{
pTerm->prereqRight = sqlite3WhereExprUsage(pMaskSet, pExpr->pRight);
+ if( pExpr->pLeft==0
+ || ExprHasProperty(pExpr, EP_xIsSelect|EP_IfNullRow)
+ || pExpr->x.pList!=0
+ ){
+ prereqAll = sqlite3WhereExprUsageNN(pMaskSet, pExpr);
+ }else{
+ prereqAll = prereqLeft | pTerm->prereqRight;
+ }
}
- pMaskSet->bVarSelect = 0;
- prereqAll = sqlite3WhereExprUsageNN(pMaskSet, pExpr);
if( pMaskSet->bVarSelect ) pTerm->wtFlags |= TERM_VARSELECT;
+
+#ifdef SQLITE_DEBUG
+ if( prereqAll!=sqlite3WhereExprUsageNN(pMaskSet, pExpr) ){
+ printf("\n*** Incorrect prereqAll computed for:\n");
+ sqlite3TreeViewExpr(0,pExpr,0);
+ abort();
+ }
+#endif
+
if( ExprHasProperty(pExpr, EP_FromJoin) ){
- Bitmask x = sqlite3WhereGetMask(pMaskSet, pExpr->iRightJoinTable);
+ Bitmask x = sqlite3WhereGetMask(pMaskSet, pExpr->w.iRightJoinTable);
prereqAll |= x;
extraRight = x-1; /* ON clause terms may not be used with an index
** on left table of a LEFT JOIN. Ticket #3015 */
@@ -150306,7 +151527,10 @@ static void exprAnalyze(
** no longer used.
**
** This is only required if at least one side of the comparison operation
- ** is not a sub-select. */
+ ** is not a sub-select.
+ **
+ ** tag-20220128a
+ */
if( (pExpr->op==TK_EQ || pExpr->op==TK_IS)
&& (nLeft = sqlite3ExprVectorSize(pExpr->pLeft))>1
&& sqlite3ExprVectorSize(pExpr->pRight)==nLeft
@@ -150323,7 +151547,7 @@ static void exprAnalyze(
pNew = sqlite3PExpr(pParse, pExpr->op, pLeft, pRight);
transferJoinMarkings(pNew, pExpr);
- idxNew = whereClauseInsert(pWC, pNew, TERM_DYNAMIC);
+ idxNew = whereClauseInsert(pWC, pNew, TERM_DYNAMIC|TERM_SLICE);
exprAnalyze(pSrc, pWC, idxNew);
}
pTerm = &pWC->a[idxTerm];
@@ -150353,7 +151577,7 @@ static void exprAnalyze(
int i;
for(i=0; i<sqlite3ExprVectorSize(pExpr->pLeft); i++){
int idxNew;
- idxNew = whereClauseInsert(pWC, pExpr, TERM_VIRTUAL);
+ idxNew = whereClauseInsert(pWC, pExpr, TERM_VIRTUAL|TERM_SLICE);
pWC->a[idxNew].u.x.iField = i+1;
exprAnalyze(pSrc, pWC, idxNew);
markTermAsChild(pWC, idxNew, idxTerm);
@@ -150386,7 +151610,7 @@ static void exprAnalyze(
0, sqlite3ExprDup(db, pRight, 0));
if( ExprHasProperty(pExpr, EP_FromJoin) && pNewExpr ){
ExprSetProperty(pNewExpr, EP_FromJoin);
- pNewExpr->iRightJoinTable = pExpr->iRightJoinTable;
+ pNewExpr->w.iRightJoinTable = pExpr->w.iRightJoinTable;
}
idxNew = whereClauseInsert(pWC, pNewExpr, TERM_VIRTUAL|TERM_DYNAMIC);
testcase( idxNew==0 );
@@ -150450,6 +151674,113 @@ SQLITE_PRIVATE void sqlite3WhereSplit(WhereClause *pWC, Expr *pExpr, u8 op){
}
/*
+** Add either a LIMIT (if eMatchOp==SQLITE_INDEX_CONSTRAINT_LIMIT) or
+** OFFSET (if eMatchOp==SQLITE_INDEX_CONSTRAINT_OFFSET) term to the
+** where-clause passed as the first argument. The value for the term
+** is found in register iReg.
+**
+** In the common case where the value is a simple integer
+** (example: "LIMIT 5 OFFSET 10") then the expression codes as a
+** TK_INTEGER so that it will be available to sqlite3_vtab_rhs_value().
+** If not, then it codes as a TK_REGISTER expression.
+*/
+static void whereAddLimitExpr(
+ WhereClause *pWC, /* Add the constraint to this WHERE clause */
+ int iReg, /* Register that will hold value of the limit/offset */
+ Expr *pExpr, /* Expression that defines the limit/offset */
+ int iCsr, /* Cursor to which the constraint applies */
+ int eMatchOp /* SQLITE_INDEX_CONSTRAINT_LIMIT or _OFFSET */
+){
+ Parse *pParse = pWC->pWInfo->pParse;
+ sqlite3 *db = pParse->db;
+ Expr *pNew;
+ int iVal = 0;
+
+ if( sqlite3ExprIsInteger(pExpr, &iVal) && iVal>=0 ){
+ Expr *pVal = sqlite3Expr(db, TK_INTEGER, 0);
+ if( pVal==0 ) return;
+ ExprSetProperty(pVal, EP_IntValue);
+ pVal->u.iValue = iVal;
+ pNew = sqlite3PExpr(pParse, TK_MATCH, 0, pVal);
+ }else{
+ Expr *pVal = sqlite3Expr(db, TK_REGISTER, 0);
+ if( pVal==0 ) return;
+ pVal->iTable = iReg;
+ pNew = sqlite3PExpr(pParse, TK_MATCH, 0, pVal);
+ }
+ if( pNew ){
+ WhereTerm *pTerm;
+ int idx;
+ idx = whereClauseInsert(pWC, pNew, TERM_DYNAMIC|TERM_VIRTUAL);
+ pTerm = &pWC->a[idx];
+ pTerm->leftCursor = iCsr;
+ pTerm->eOperator = WO_AUX;
+ pTerm->eMatchOp = eMatchOp;
+ }
+}
+
+/*
+** Possibly add terms corresponding to the LIMIT and OFFSET clauses of the
+** SELECT statement passed as the second argument. These terms are only
+** added if:
+**
+** 1. The SELECT statement has a LIMIT clause, and
+** 2. The SELECT statement is not an aggregate or DISTINCT query, and
+** 3. The SELECT statement has exactly one object in its from clause, and
+** that object is a virtual table, and
+** 4. There are no terms in the WHERE clause that will not be passed
+** to the virtual table xBestIndex method.
+** 5. The ORDER BY clause, if any, will be made available to the xBestIndex
+** method.
+**
+** LIMIT and OFFSET terms are ignored by most of the planner code. They
+** exist only so that they may be passed to the xBestIndex method of the
+** single virtual table in the FROM clause of the SELECT.
+*/
+SQLITE_PRIVATE void sqlite3WhereAddLimit(WhereClause *pWC, Select *p){
+ assert( p==0 || (p->pGroupBy==0 && (p->selFlags & SF_Aggregate)==0) );
+ if( (p && p->pLimit) /* 1 */
+ && (p->selFlags & (SF_Distinct|SF_Aggregate))==0 /* 2 */
+ && (p->pSrc->nSrc==1 && IsVirtual(p->pSrc->a[0].pTab)) /* 3 */
+ ){
+ ExprList *pOrderBy = p->pOrderBy;
+ int iCsr = p->pSrc->a[0].iCursor;
+ int ii;
+
+ /* Check condition (4). Return early if it is not met. */
+ for(ii=0; ii<pWC->nTerm; ii++){
+ if( pWC->a[ii].wtFlags & TERM_CODED ){
+ /* This term is a vector operation that has been decomposed into
+ ** other, subsequent terms. It can be ignored. See tag-20220128a */
+ assert( pWC->a[ii].wtFlags & TERM_VIRTUAL );
+ assert( pWC->a[ii].eOperator==0 );
+ continue;
+ }
+ if( pWC->a[ii].leftCursor!=iCsr ) return;
+ }
+
+ /* Check condition (5). Return early if it is not met. */
+ if( pOrderBy ){
+ for(ii=0; ii<pOrderBy->nExpr; ii++){
+ Expr *pExpr = pOrderBy->a[ii].pExpr;
+ if( pExpr->op!=TK_COLUMN ) return;
+ if( pExpr->iTable!=iCsr ) return;
+ if( pOrderBy->a[ii].sortFlags & KEYINFO_ORDER_BIGNULL ) return;
+ }
+ }
+
+ /* All conditions are met. Add the terms to the where-clause object. */
+ assert( p->pLimit->op==TK_LIMIT );
+ whereAddLimitExpr(pWC, p->iLimit, p->pLimit->pLeft,
+ iCsr, SQLITE_INDEX_CONSTRAINT_LIMIT);
+ if( p->iOffset>0 ){
+ whereAddLimitExpr(pWC, p->iOffset, p->pLimit->pRight,
+ iCsr, SQLITE_INDEX_CONSTRAINT_OFFSET);
+ }
+ }
+}
+
+/*
** Initialize a preallocated WhereClause structure.
*/
SQLITE_PRIVATE void sqlite3WhereClauseInit(
@@ -150460,6 +151791,7 @@ SQLITE_PRIVATE void sqlite3WhereClauseInit(
pWC->hasOr = 0;
pWC->pOuter = 0;
pWC->nTerm = 0;
+ pWC->nBase = 0;
pWC->nSlot = ArraySize(pWC->aStatic);
pWC->a = pWC->aStatic;
}
@@ -150470,17 +151802,34 @@ SQLITE_PRIVATE void sqlite3WhereClauseInit(
** sqlite3WhereClauseInit().
*/
SQLITE_PRIVATE void sqlite3WhereClauseClear(WhereClause *pWC){
- int i;
- WhereTerm *a;
sqlite3 *db = pWC->pWInfo->pParse->db;
- for(i=pWC->nTerm-1, a=pWC->a; i>=0; i--, a++){
- if( a->wtFlags & TERM_DYNAMIC ){
- sqlite3ExprDelete(db, a->pExpr);
+ assert( pWC->nTerm>=pWC->nBase );
+ if( pWC->nTerm>0 ){
+ WhereTerm *a = pWC->a;
+ WhereTerm *aLast = &pWC->a[pWC->nTerm-1];
+#ifdef SQLITE_DEBUG
+ int i;
+ /* Verify that every term past pWC->nBase is virtual */
+ for(i=pWC->nBase; i<pWC->nTerm; i++){
+ assert( (pWC->a[i].wtFlags & TERM_VIRTUAL)!=0 );
}
- if( a->wtFlags & TERM_ORINFO ){
- whereOrInfoDelete(db, a->u.pOrInfo);
- }else if( a->wtFlags & TERM_ANDINFO ){
- whereAndInfoDelete(db, a->u.pAndInfo);
+#endif
+ while(1){
+ assert( a->eMatchOp==0 || a->eOperator==WO_AUX );
+ if( a->wtFlags & TERM_DYNAMIC ){
+ sqlite3ExprDelete(db, a->pExpr);
+ }
+ if( a->wtFlags & (TERM_ORINFO|TERM_ANDINFO) ){
+ if( a->wtFlags & TERM_ORINFO ){
+ assert( (a->wtFlags & TERM_ANDINFO)==0 );
+ whereOrInfoDelete(db, a->u.pOrInfo);
+ }else{
+ assert( (a->wtFlags & TERM_ANDINFO)!=0 );
+ whereAndInfoDelete(db, a->u.pAndInfo);
+ }
+ }
+ if( a==aLast ) break;
+ a++;
}
}
if( pWC->a!=pWC->aStatic ){
@@ -150493,15 +151842,38 @@ SQLITE_PRIVATE void sqlite3WhereClauseClear(WhereClause *pWC){
** These routines walk (recursively) an expression tree and generate
** a bitmask indicating which tables are used in that expression
** tree.
+**
+** sqlite3WhereExprUsage(MaskSet, Expr) ->
+**
+** Return a Bitmask of all tables referenced by Expr. Expr can be
+** be NULL, in which case 0 is returned.
+**
+** sqlite3WhereExprUsageNN(MaskSet, Expr) ->
+**
+** Same as sqlite3WhereExprUsage() except that Expr must not be
+** NULL. The "NN" suffix on the name stands for "Not Null".
+**
+** sqlite3WhereExprListUsage(MaskSet, ExprList) ->
+**
+** Return a Bitmask of all tables referenced by every expression
+** in the expression list ExprList. ExprList can be NULL, in which
+** case 0 is returned.
+**
+** sqlite3WhereExprUsageFull(MaskSet, ExprList) ->
+**
+** Internal use only. Called only by sqlite3WhereExprUsageNN() for
+** complex expressions that require pushing register values onto
+** the stack. Many calls to sqlite3WhereExprUsageNN() do not need
+** the more complex analysis done by this routine. Hence, the
+** computations done by this routine are broken out into a separate
+** "no-inline" function to avoid the stack push overhead in the
+** common case where it is not needed.
*/
-SQLITE_PRIVATE Bitmask sqlite3WhereExprUsageNN(WhereMaskSet *pMaskSet, Expr *p){
+static SQLITE_NOINLINE Bitmask sqlite3WhereExprUsageFull(
+ WhereMaskSet *pMaskSet,
+ Expr *p
+){
Bitmask mask;
- if( p->op==TK_COLUMN && !ExprHasProperty(p, EP_FixedCol) ){
- return sqlite3WhereGetMask(pMaskSet, p->iTable);
- }else if( ExprHasProperty(p, EP_TokenOnly|EP_Leaf) ){
- assert( p->op!=TK_IF_NULL_ROW );
- return 0;
- }
mask = (p->op==TK_IF_NULL_ROW) ? sqlite3WhereGetMask(pMaskSet, p->iTable) : 0;
if( p->pLeft ) mask |= sqlite3WhereExprUsageNN(pMaskSet, p->pLeft);
if( p->pRight ){
@@ -150523,6 +151895,15 @@ SQLITE_PRIVATE Bitmask sqlite3WhereExprUsageNN(WhereMaskSet *pMaskSet, Expr *p){
#endif
return mask;
}
+SQLITE_PRIVATE Bitmask sqlite3WhereExprUsageNN(WhereMaskSet *pMaskSet, Expr *p){
+ if( p->op==TK_COLUMN && !ExprHasProperty(p, EP_FixedCol) ){
+ return sqlite3WhereGetMask(pMaskSet, p->iTable);
+ }else if( ExprHasProperty(p, EP_TokenOnly|EP_Leaf) ){
+ assert( p->op!=TK_IF_NULL_ROW );
+ return 0;
+ }
+ return sqlite3WhereExprUsageFull(pMaskSet, p);
+}
SQLITE_PRIVATE Bitmask sqlite3WhereExprUsage(WhereMaskSet *pMaskSet, Expr *p){
return p ? sqlite3WhereExprUsageNN(pMaskSet,p) : 0;
}
@@ -150592,6 +151973,7 @@ SQLITE_PRIVATE void sqlite3WhereTabFuncArgs(
pColRef->iColumn = k++;
assert( ExprUseYTab(pColRef) );
pColRef->y.pTab = pTab;
+ pItem->colUsed |= sqlite3ExprColUsed(pColRef);
pRhs = sqlite3PExpr(pParse, TK_UPLUS,
sqlite3ExprDup(pParse->db, pArgs->a[j].pExpr, 0), 0);
pTerm = sqlite3PExpr(pParse, TK_EQ, pColRef, pRhs);
@@ -150636,8 +152018,14 @@ SQLITE_PRIVATE void sqlite3WhereTabFuncArgs(
*/
typedef struct HiddenIndexInfo HiddenIndexInfo;
struct HiddenIndexInfo {
- WhereClause *pWC; /* The Where clause being analyzed */
- Parse *pParse; /* The parsing context */
+ WhereClause *pWC; /* The Where clause being analyzed */
+ Parse *pParse; /* The parsing context */
+ int eDistinct; /* Value to return from sqlite3_vtab_distinct() */
+ u32 mIn; /* Mask of terms that are <col> IN (...) */
+ u32 mHandleIn; /* Terms that vtab will handle as <col> IN (...) */
+ sqlite3_value *aRhs[1]; /* RHS values for constraints. MUST BE LAST
+ ** because extra space is allocated to hold up
+ ** to nTerm such values */
};
/* Forward declaration of methods */
@@ -150840,7 +152228,12 @@ whereOrInsert_done:
SQLITE_PRIVATE Bitmask sqlite3WhereGetMask(WhereMaskSet *pMaskSet, int iCursor){
int i;
assert( pMaskSet->n<=(int)sizeof(Bitmask)*8 );
- for(i=0; i<pMaskSet->n; i++){
+ assert( pMaskSet->n>0 || pMaskSet->ix[0]<0 );
+ assert( iCursor>=-1 );
+ if( pMaskSet->ix[0]==iCursor ){
+ return 1;
+ }
+ for(i=1; i<pMaskSet->n; i++){
if( pMaskSet->ix[i]==iCursor ){
return MASKBIT(i);
}
@@ -151025,16 +152418,16 @@ static WhereTerm *whereScanInit(
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 ){
+ if( iColumn==pIdx->pTable->iPKey ){
iColumn = XN_ROWID;
}else if( iColumn>=0 ){
pScan->idxaff = pIdx->pTable->aCol[iColumn].affinity;
pScan->zCollName = pIdx->azColl[j];
+ }else 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==XN_EXPR ){
return 0;
@@ -151277,12 +152670,14 @@ static void whereTraceIndexInfoInputs(sqlite3_index_info *p){
int i;
if( !sqlite3WhereTrace ) return;
for(i=0; i<p->nConstraint; i++){
- sqlite3DebugPrintf(" constraint[%d]: col=%d termid=%d op=%d usabled=%d\n",
+ sqlite3DebugPrintf(
+ " constraint[%d]: col=%d termid=%d op=%d usabled=%d collseq=%s\n",
i,
p->aConstraint[i].iColumn,
p->aConstraint[i].iTermOffset,
p->aConstraint[i].op,
- p->aConstraint[i].usable);
+ p->aConstraint[i].usable,
+ sqlite3_vtab_collation(p,i));
}
for(i=0; i<p->nOrderBy; i++){
sqlite3DebugPrintf(" orderby[%d]: col=%d desc=%d\n",
@@ -151318,9 +152713,9 @@ static void whereTraceIndexInfoOutputs(sqlite3_index_info *p){
** index existed.
*/
static int termCanDriveIndex(
- WhereTerm *pTerm, /* WHERE clause term to check */
- SrcItem *pSrc, /* Table we are trying to access */
- Bitmask notReady /* Tables in outer loops of the join */
+ const WhereTerm *pTerm, /* WHERE clause term to check */
+ const SrcItem *pSrc, /* Table we are trying to access */
+ const Bitmask notReady /* Tables in outer loops of the join */
){
char aff;
if( pTerm->leftCursor!=pSrc->iCursor ) return 0;
@@ -151351,11 +152746,11 @@ static int termCanDriveIndex(
** and to set up the WhereLevel object pLevel so that the code generator
** makes use of the automatic index.
*/
-static void constructAutomaticIndex(
+static SQLITE_NOINLINE void constructAutomaticIndex(
Parse *pParse, /* The parsing context */
- WhereClause *pWC, /* The WHERE clause */
- SrcItem *pSrc, /* The FROM clause term to get the next index */
- Bitmask notReady, /* Mask of cursors that are not available */
+ const WhereClause *pWC, /* The WHERE clause */
+ const SrcItem *pSrc, /* The FROM clause term to get the next index */
+ const Bitmask notReady, /* Mask of cursors that are not available */
WhereLevel *pLevel /* Write new index here */
){
int nKeyCol; /* Number of columns in the constructed index */
@@ -151397,13 +152792,13 @@ static void constructAutomaticIndex(
idxCols = 0;
for(pTerm=pWC->a; pTerm<pWCEnd; pTerm++){
Expr *pExpr = pTerm->pExpr;
- assert( !ExprHasProperty(pExpr, EP_FromJoin) /* prereq always non-zero */
- || pExpr->iRightJoinTable!=pSrc->iCursor /* for the right-hand */
- || pLoop->prereq!=0 ); /* table of a LEFT JOIN */
- if( pLoop->prereq==0
- && (pTerm->wtFlags & TERM_VIRTUAL)==0
- && !ExprHasProperty(pExpr, EP_FromJoin)
- && sqlite3ExprIsTableConstant(pExpr, pSrc->iCursor) ){
+ /* Make the automatic index a partial index if there are terms in the
+ ** WHERE clause (or the ON clause of a LEFT join) that constrain which
+ ** rows of the target table (pSrc) that can be used. */
+ if( (pTerm->wtFlags & TERM_VIRTUAL)==0
+ && ((pSrc->fg.jointype&JT_LEFT)==0 || ExprHasProperty(pExpr,EP_FromJoin))
+ && sqlite3ExprIsTableConstant(pExpr, pSrc->iCursor)
+ ){
pPartial = sqlite3ExprAnd(pParse, pPartial,
sqlite3ExprDup(pParse->db, pExpr, 0));
}
@@ -151510,6 +152905,10 @@ static void constructAutomaticIndex(
sqlite3VdbeAddOp2(v, OP_OpenAutoindex, pLevel->iIdxCur, nKeyCol+1);
sqlite3VdbeSetP4KeyInfo(pParse, pIdx);
VdbeComment((v, "for %s", pTable->zName));
+ if( OptimizationEnabled(pParse->db, SQLITE_BloomFilter) ){
+ pLevel->regFilter = ++pParse->nMem;
+ sqlite3VdbeAddOp2(v, OP_Blob, 10000, pLevel->regFilter);
+ }
/* Fill the automatic index with content */
pTabItem = &pWC->pWInfo->pTabList->a[pLevel->iFrom];
@@ -151532,6 +152931,10 @@ static void constructAutomaticIndex(
regBase = sqlite3GenerateIndexKey(
pParse, pIdx, pLevel->iTabCur, regRecord, 0, 0, 0, 0
);
+ if( pLevel->regFilter ){
+ sqlite3VdbeAddOp4Int(v, OP_FilterAdd, pLevel->regFilter, 0,
+ regBase, pLoop->u.btree.nEq);
+ }
sqlite3VdbeAddOp2(v, OP_IdxInsert, pLevel->iIdxCur, regRecord);
sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT);
if( pPartial ) sqlite3VdbeResolveLabel(v, iContinue);
@@ -151558,22 +152961,149 @@ end_auto_index_create:
}
#endif /* SQLITE_OMIT_AUTOMATIC_INDEX */
+/*
+** Generate bytecode that will initialize a Bloom filter that is appropriate
+** for pLevel.
+**
+** If there are inner loops within pLevel that have the WHERE_BLOOMFILTER
+** flag set, initialize a Bloomfilter for them as well. Except don't do
+** this recursive initialization if the SQLITE_BloomPulldown optimization has
+** been turned off.
+**
+** When the Bloom filter is initialized, the WHERE_BLOOMFILTER flag is cleared
+** from the loop, but the regFilter value is set to a register that implements
+** the Bloom filter. When regFilter is positive, the
+** sqlite3WhereCodeOneLoopStart() will generate code to test the Bloom filter
+** and skip the subsequence B-Tree seek if the Bloom filter indicates that
+** no matching rows exist.
+**
+** This routine may only be called if it has previously been determined that
+** the loop would benefit from a Bloom filter, and the WHERE_BLOOMFILTER bit
+** is set.
+*/
+static SQLITE_NOINLINE void sqlite3ConstructBloomFilter(
+ WhereInfo *pWInfo, /* The WHERE clause */
+ int iLevel, /* Index in pWInfo->a[] that is pLevel */
+ WhereLevel *pLevel, /* Make a Bloom filter for this FROM term */
+ Bitmask notReady /* Loops that are not ready */
+){
+ int addrOnce; /* Address of opening OP_Once */
+ int addrTop; /* Address of OP_Rewind */
+ int addrCont; /* Jump here to skip a row */
+ const WhereTerm *pTerm; /* For looping over WHERE clause terms */
+ const WhereTerm *pWCEnd; /* Last WHERE clause term */
+ Parse *pParse = pWInfo->pParse; /* Parsing context */
+ Vdbe *v = pParse->pVdbe; /* VDBE under construction */
+ WhereLoop *pLoop = pLevel->pWLoop; /* The loop being coded */
+ int iCur; /* Cursor for table getting the filter */
+
+ assert( pLoop!=0 );
+ assert( v!=0 );
+ assert( pLoop->wsFlags & WHERE_BLOOMFILTER );
+
+ addrOnce = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v);
+ do{
+ const SrcItem *pItem;
+ const Table *pTab;
+ u64 sz;
+ sqlite3WhereExplainBloomFilter(pParse, pWInfo, pLevel);
+ addrCont = sqlite3VdbeMakeLabel(pParse);
+ iCur = pLevel->iTabCur;
+ pLevel->regFilter = ++pParse->nMem;
+
+ /* The Bloom filter is a Blob held in a register. Initialize it
+ ** to zero-filled blob of at least 80K bits, but maybe more if the
+ ** estimated size of the table is larger. We could actually
+ ** measure the size of the table at run-time using OP_Count with
+ ** P3==1 and use that value to initialize the blob. But that makes
+ ** testing complicated. By basing the blob size on the value in the
+ ** sqlite_stat1 table, testing is much easier.
+ */
+ pItem = &pWInfo->pTabList->a[pLevel->iFrom];
+ assert( pItem!=0 );
+ pTab = pItem->pTab;
+ assert( pTab!=0 );
+ sz = sqlite3LogEstToInt(pTab->nRowLogEst);
+ if( sz<10000 ){
+ sz = 10000;
+ }else if( sz>10000000 ){
+ sz = 10000000;
+ }
+ sqlite3VdbeAddOp2(v, OP_Blob, (int)sz, pLevel->regFilter);
+
+ addrTop = sqlite3VdbeAddOp1(v, OP_Rewind, iCur); VdbeCoverage(v);
+ pWCEnd = &pWInfo->sWC.a[pWInfo->sWC.nTerm];
+ for(pTerm=pWInfo->sWC.a; pTerm<pWCEnd; pTerm++){
+ Expr *pExpr = pTerm->pExpr;
+ if( (pTerm->wtFlags & TERM_VIRTUAL)==0
+ && sqlite3ExprIsTableConstant(pExpr, iCur)
+ ){
+ sqlite3ExprIfFalse(pParse, pTerm->pExpr, addrCont, SQLITE_JUMPIFNULL);
+ }
+ }
+ if( pLoop->wsFlags & WHERE_IPK ){
+ int r1 = sqlite3GetTempReg(pParse);
+ sqlite3VdbeAddOp2(v, OP_Rowid, iCur, r1);
+ sqlite3VdbeAddOp4Int(v, OP_FilterAdd, pLevel->regFilter, 0, r1, 1);
+ sqlite3ReleaseTempReg(pParse, r1);
+ }else{
+ Index *pIdx = pLoop->u.btree.pIndex;
+ int n = pLoop->u.btree.nEq;
+ int r1 = sqlite3GetTempRange(pParse, n);
+ int jj;
+ for(jj=0; jj<n; jj++){
+ int iCol = pIdx->aiColumn[jj];
+ assert( pIdx->pTable==pItem->pTab );
+ sqlite3ExprCodeGetColumnOfTable(v, pIdx->pTable, iCur, iCol,r1+jj);
+ }
+ sqlite3VdbeAddOp4Int(v, OP_FilterAdd, pLevel->regFilter, 0, r1, n);
+ sqlite3ReleaseTempRange(pParse, r1, n);
+ }
+ sqlite3VdbeResolveLabel(v, addrCont);
+ sqlite3VdbeAddOp2(v, OP_Next, pLevel->iTabCur, addrTop+1);
+ VdbeCoverage(v);
+ sqlite3VdbeJumpHere(v, addrTop);
+ pLoop->wsFlags &= ~WHERE_BLOOMFILTER;
+ if( OptimizationDisabled(pParse->db, SQLITE_BloomPulldown) ) break;
+ while( ++iLevel < pWInfo->nLevel ){
+ const SrcItem *pTabItem;
+ pLevel = &pWInfo->a[iLevel];
+ pTabItem = &pWInfo->pTabList->a[pLevel->iFrom];
+ if( pTabItem->fg.jointype & JT_LEFT ) continue;
+ pLoop = pLevel->pWLoop;
+ if( NEVER(pLoop==0) ) continue;
+ if( pLoop->prereq & notReady ) continue;
+ if( (pLoop->wsFlags & (WHERE_BLOOMFILTER|WHERE_COLUMN_IN))
+ ==WHERE_BLOOMFILTER
+ ){
+ /* This is a candidate for bloom-filter pull-down (early evaluation).
+ ** The test that WHERE_COLUMN_IN is omitted is important, as we are
+ ** not able to do early evaluation of bloom filters that make use of
+ ** the IN operator */
+ break;
+ }
+ }
+ }while( iLevel < pWInfo->nLevel );
+ sqlite3VdbeJumpHere(v, addrOnce);
+}
+
+
#ifndef SQLITE_OMIT_VIRTUALTABLE
/*
** Allocate and populate an sqlite3_index_info structure. It is the
** responsibility of the caller to eventually release the structure
-** by passing the pointer returned by this function to sqlite3_free().
+** by passing the pointer returned by this function to freeIndexInfo().
*/
static sqlite3_index_info *allocateIndexInfo(
- Parse *pParse, /* The parsing context */
+ WhereInfo *pWInfo, /* The WHERE clause */
WhereClause *pWC, /* The WHERE clause being analyzed */
Bitmask mUnusable, /* Ignore terms with these prereqs */
SrcItem *pSrc, /* The FROM clause term that is the vtab */
- ExprList *pOrderBy, /* The ORDER BY clause */
u16 *pmNoOmit /* Mask of terms not to omit */
){
int i, j;
int nTerm;
+ Parse *pParse = pWInfo->pParse;
struct sqlite3_index_constraint *pIdxCons;
struct sqlite3_index_orderby *pIdxOrderBy;
struct sqlite3_index_constraint_usage *pUsage;
@@ -151582,10 +153112,21 @@ static sqlite3_index_info *allocateIndexInfo(
int nOrderBy;
sqlite3_index_info *pIdxInfo;
u16 mNoOmit = 0;
+ const Table *pTab;
+ int eDistinct = 0;
+ ExprList *pOrderBy = pWInfo->pOrderBy;
- /* Count the number of possible WHERE clause constraints referring
- ** to this virtual table */
+ assert( pSrc!=0 );
+ pTab = pSrc->pTab;
+ assert( pTab!=0 );
+ assert( IsVirtual(pTab) );
+
+ /* Find all WHERE clause constraints referring to this virtual table.
+ ** Mark each term with the TERM_OK flag. Set nTerm to the number of
+ ** terms found.
+ */
for(i=nTerm=0, pTerm=pWC->a; i<pWC->nTerm; i++, pTerm++){
+ pTerm->wtFlags &= ~TERM_OK;
if( pTerm->leftCursor != pSrc->iCursor ) continue;
if( pTerm->prereqRight & mUnusable ) continue;
assert( IsPowerOfTwo(pTerm->eOperator & ~WO_EQUIV) );
@@ -151595,9 +153136,21 @@ static sqlite3_index_info *allocateIndexInfo(
testcase( pTerm->eOperator & WO_ALL );
if( (pTerm->eOperator & ~(WO_EQUIV))==0 ) continue;
if( pTerm->wtFlags & TERM_VNULL ) continue;
+
assert( (pTerm->eOperator & (WO_OR|WO_AND))==0 );
- assert( pTerm->u.x.leftColumn>=(-1) );
+ assert( pTerm->u.x.leftColumn>=XN_ROWID );
+ assert( pTerm->u.x.leftColumn<pTab->nCol );
+
+ /* tag-20191211-002: WHERE-clause constraints are not useful to the
+ ** right-hand table of a LEFT JOIN. See tag-20191211-001 for the
+ ** equivalent restriction for ordinary tables. */
+ if( (pSrc->fg.jointype & JT_LEFT)!=0
+ && !ExprHasProperty(pTerm->pExpr, EP_FromJoin)
+ ){
+ continue;
+ }
nTerm++;
+ pTerm->wtFlags |= TERM_OK;
}
/* If the ORDER BY clause contains only columns in the current
@@ -151609,11 +153162,47 @@ static sqlite3_index_info *allocateIndexInfo(
int n = pOrderBy->nExpr;
for(i=0; i<n; i++){
Expr *pExpr = pOrderBy->a[i].pExpr;
- if( pExpr->op!=TK_COLUMN || pExpr->iTable!=pSrc->iCursor ) break;
+ Expr *pE2;
+
+ /* Skip over constant terms in the ORDER BY clause */
+ if( sqlite3ExprIsConstant(pExpr) ){
+ continue;
+ }
+
+ /* Virtual tables are unable to deal with NULLS FIRST */
if( pOrderBy->a[i].sortFlags & KEYINFO_ORDER_BIGNULL ) break;
+
+ /* First case - a direct column references without a COLLATE operator */
+ if( pExpr->op==TK_COLUMN && pExpr->iTable==pSrc->iCursor ){
+ assert( pExpr->iColumn>=XN_ROWID && pExpr->iColumn<pTab->nCol );
+ continue;
+ }
+
+ /* 2nd case - a column reference with a COLLATE operator. Only match
+ ** of the COLLATE operator matches the collation of the column. */
+ if( pExpr->op==TK_COLLATE
+ && (pE2 = pExpr->pLeft)->op==TK_COLUMN
+ && pE2->iTable==pSrc->iCursor
+ ){
+ const char *zColl; /* The collating sequence name */
+ assert( !ExprHasProperty(pExpr, EP_IntValue) );
+ assert( pExpr->u.zToken!=0 );
+ assert( pE2->iColumn>=XN_ROWID && pE2->iColumn<pTab->nCol );
+ pExpr->iColumn = pE2->iColumn;
+ if( pE2->iColumn<0 ) continue; /* Collseq does not matter for rowid */
+ zColl = sqlite3ColumnColl(&pTab->aCol[pE2->iColumn]);
+ if( zColl==0 ) zColl = sqlite3StrBINARY;
+ if( sqlite3_stricmp(pExpr->u.zToken, zColl)==0 ) continue;
+ }
+
+ /* No matches cause a break out of the loop */
+ break;
}
- if( i==n){
+ if( i==n ){
nOrderBy = n;
+ if( (pWInfo->wctrlFlags & (WHERE_GROUPBY|WHERE_DISTINCTBY)) ){
+ eDistinct = 1 + ((pWInfo->wctrlFlags & WHERE_DISTINCTBY)!=0);
+ }
}
}
@@ -151621,47 +153210,35 @@ static sqlite3_index_info *allocateIndexInfo(
*/
pIdxInfo = sqlite3DbMallocZero(pParse->db, sizeof(*pIdxInfo)
+ (sizeof(*pIdxCons) + sizeof(*pUsage))*nTerm
- + sizeof(*pIdxOrderBy)*nOrderBy + sizeof(*pHidden) );
+ + sizeof(*pIdxOrderBy)*nOrderBy + sizeof(*pHidden)
+ + sizeof(sqlite3_value*)*nTerm );
if( pIdxInfo==0 ){
sqlite3ErrorMsg(pParse, "out of memory");
return 0;
}
pHidden = (struct HiddenIndexInfo*)&pIdxInfo[1];
- pIdxCons = (struct sqlite3_index_constraint*)&pHidden[1];
+ pIdxCons = (struct sqlite3_index_constraint*)&pHidden->aRhs[nTerm];
pIdxOrderBy = (struct sqlite3_index_orderby*)&pIdxCons[nTerm];
pUsage = (struct sqlite3_index_constraint_usage*)&pIdxOrderBy[nOrderBy];
- pIdxInfo->nOrderBy = nOrderBy;
pIdxInfo->aConstraint = pIdxCons;
pIdxInfo->aOrderBy = pIdxOrderBy;
pIdxInfo->aConstraintUsage = pUsage;
pHidden->pWC = pWC;
pHidden->pParse = pParse;
+ pHidden->eDistinct = eDistinct;
+ pHidden->mIn = 0;
for(i=j=0, pTerm=pWC->a; i<pWC->nTerm; i++, pTerm++){
u16 op;
- if( pTerm->leftCursor != pSrc->iCursor ) continue;
- if( pTerm->prereqRight & mUnusable ) continue;
- assert( IsPowerOfTwo(pTerm->eOperator & ~WO_EQUIV) );
- testcase( pTerm->eOperator & WO_IN );
- testcase( pTerm->eOperator & WO_IS );
- testcase( pTerm->eOperator & WO_ISNULL );
- testcase( pTerm->eOperator & WO_ALL );
- if( (pTerm->eOperator & ~(WO_EQUIV))==0 ) continue;
- if( pTerm->wtFlags & TERM_VNULL ) continue;
-
- /* tag-20191211-002: WHERE-clause constraints are not useful to the
- ** right-hand table of a LEFT JOIN. See tag-20191211-001 for the
- ** equivalent restriction for ordinary tables. */
- if( (pSrc->fg.jointype & JT_LEFT)!=0
- && !ExprHasProperty(pTerm->pExpr, EP_FromJoin)
- ){
- continue;
- }
- assert( (pTerm->eOperator & (WO_OR|WO_AND))==0 );
- assert( pTerm->u.x.leftColumn>=(-1) );
+ if( (pTerm->wtFlags & TERM_OK)==0 ) continue;
pIdxCons[j].iColumn = pTerm->u.x.leftColumn;
pIdxCons[j].iTermOffset = i;
op = pTerm->eOperator & WO_ALL;
- if( op==WO_IN ) op = WO_EQ;
+ if( op==WO_IN ){
+ if( (pTerm->wtFlags & TERM_SLICE)==0 ){
+ pHidden->mIn |= SMASKBIT32(j);
+ }
+ op = WO_EQ;
+ }
if( op==WO_AUX ){
pIdxCons[j].op = pTerm->eMatchOp;
}else if( op & (WO_ISNULL|WO_IS) ){
@@ -151694,18 +153271,43 @@ static sqlite3_index_info *allocateIndexInfo(
j++;
}
+ assert( j==nTerm );
pIdxInfo->nConstraint = j;
- for(i=0; i<nOrderBy; i++){
+ for(i=j=0; i<nOrderBy; i++){
Expr *pExpr = pOrderBy->a[i].pExpr;
- pIdxOrderBy[i].iColumn = pExpr->iColumn;
- pIdxOrderBy[i].desc = pOrderBy->a[i].sortFlags & KEYINFO_ORDER_DESC;
+ if( sqlite3ExprIsConstant(pExpr) ) continue;
+ assert( pExpr->op==TK_COLUMN
+ || (pExpr->op==TK_COLLATE && pExpr->pLeft->op==TK_COLUMN
+ && pExpr->iColumn==pExpr->pLeft->iColumn) );
+ pIdxOrderBy[j].iColumn = pExpr->iColumn;
+ pIdxOrderBy[j].desc = pOrderBy->a[i].sortFlags & KEYINFO_ORDER_DESC;
+ j++;
}
+ pIdxInfo->nOrderBy = j;
*pmNoOmit = mNoOmit;
return pIdxInfo;
}
/*
+** Free an sqlite3_index_info structure allocated by allocateIndexInfo()
+** and possibly modified by xBestIndex methods.
+*/
+static void freeIndexInfo(sqlite3 *db, sqlite3_index_info *pIdxInfo){
+ HiddenIndexInfo *pHidden;
+ int i;
+ assert( pIdxInfo!=0 );
+ pHidden = (HiddenIndexInfo*)&pIdxInfo[1];
+ assert( pHidden->pParse!=0 );
+ assert( pHidden->pParse->db==db );
+ for(i=0; i<pIdxInfo->nConstraint; i++){
+ sqlite3ValueFree(pHidden->aRhs[i]); /* IMP: R-14553-25174 */
+ pHidden->aRhs[i] = 0;
+ }
+ sqlite3DbFree(db, pIdxInfo);
+}
+
+/*
** The table object reference passed as the second argument to this function
** must represent a virtual table. This function invokes the xBestIndex()
** method of the virtual table with the sqlite3_index_info object that
@@ -151726,7 +153328,9 @@ static int vtabBestIndex(Parse *pParse, Table *pTab, sqlite3_index_info *p){
int rc;
whereTraceIndexInfoInputs(p);
+ pParse->db->nSchemaLock++;
rc = pVtab->pModule->xBestIndex(pVtab, p);
+ pParse->db->nSchemaLock--;
whereTraceIndexInfoOutputs(p);
if( rc!=SQLITE_OK && rc!=SQLITE_CONSTRAINT ){
@@ -152500,9 +154104,9 @@ SQLITE_PRIVATE void sqlite3WhereLoopPrint(WhereLoop *p, WhereClause *pWC){
sqlite3_free(z);
}
if( p->wsFlags & WHERE_SKIPSCAN ){
- sqlite3DebugPrintf(" f %05x %d-%d", p->wsFlags, p->nLTerm,p->nSkip);
+ sqlite3DebugPrintf(" f %06x %d-%d", p->wsFlags, p->nLTerm,p->nSkip);
}else{
- sqlite3DebugPrintf(" f %05x N %d", p->wsFlags, p->nLTerm);
+ sqlite3DebugPrintf(" f %06x N %d", p->wsFlags, p->nLTerm);
}
sqlite3DebugPrintf(" cost %d,%d,%d\n", p->rSetup, p->rRun, p->nOut);
if( p->nLTerm && (sqlite3WhereTrace & 0x100)!=0 ){
@@ -152962,11 +154566,11 @@ static void whereLoopOutputAdjust(
LogEst iReduce = 0; /* pLoop->nOut should not exceed nRow-iReduce */
assert( (pLoop->wsFlags & WHERE_AUTO_INDEX)==0 );
- for(i=pWC->nTerm, pTerm=pWC->a; i>0; i--, pTerm++){
+ for(i=pWC->nBase, pTerm=pWC->a; i>0; i--, pTerm++){
assert( pTerm!=0 );
- if( (pTerm->wtFlags & TERM_VIRTUAL)!=0 ) break;
- if( (pTerm->prereqAll & pLoop->maskSelf)==0 ) continue;
if( (pTerm->prereqAll & notAllowed)!=0 ) continue;
+ if( (pTerm->prereqAll & pLoop->maskSelf)==0 ) continue;
+ if( (pTerm->wtFlags & TERM_VIRTUAL)!=0 ) continue;
for(j=pLoop->nLTerm-1; j>=0; j--){
pX = pLoop->aLTerm[j];
if( pX==0 ) continue;
@@ -152974,6 +154578,13 @@ static void whereLoopOutputAdjust(
if( pX->iParent>=0 && (&pWC->a[pX->iParent])==pTerm ) break;
}
if( j<0 ){
+ if( pLoop->maskSelf==pTerm->prereqAll ){
+ /* If there are extra terms in the WHERE clause not used by an index
+ ** that depend only on the table being scanned, and that will tend to
+ ** cause many rows to be omitted, then mark that table as
+ ** "self-culling". */
+ pLoop->wsFlags |= WHERE_SELFCULL;
+ }
if( pTerm->truthProb<=0 ){
/* If a truth probability is specified using the likelihood() hints,
** then use the probability provided by the application. */
@@ -153001,7 +154612,9 @@ static void whereLoopOutputAdjust(
}
}
}
- if( pLoop->nOut > nRow-iReduce ) pLoop->nOut = nRow - iReduce;
+ if( pLoop->nOut > nRow-iReduce ){
+ pLoop->nOut = nRow - iReduce;
+ }
}
/*
@@ -153546,7 +155159,7 @@ static int whereUsablePartialIndex(
for(i=0, pTerm=pWC->a; i<pWC->nTerm; i++, pTerm++){
Expr *pExpr;
pExpr = pTerm->pExpr;
- if( (!ExprHasProperty(pExpr, EP_FromJoin) || pExpr->iRightJoinTable==iTab)
+ if( (!ExprHasProperty(pExpr, EP_FromJoin) || pExpr->w.iRightJoinTable==iTab)
&& (isLeft==0 || ExprHasProperty(pExpr, EP_FromJoin))
&& sqlite3ExprImpliesExpr(pParse, pExpr, pWhere, iTab)
&& (pTerm->wtFlags & TERM_VNULL)==0
@@ -153849,6 +155462,15 @@ static int whereLoopAddBtree(
#ifndef SQLITE_OMIT_VIRTUALTABLE
/*
+** Return true if pTerm is a virtual table LIMIT or OFFSET term.
+*/
+static int isLimitTerm(WhereTerm *pTerm){
+ assert( pTerm->eOperator==WO_AUX || pTerm->eMatchOp==0 );
+ return pTerm->eMatchOp>=SQLITE_INDEX_CONSTRAINT_LIMIT
+ && pTerm->eMatchOp<=SQLITE_INDEX_CONSTRAINT_OFFSET;
+}
+
+/*
** Argument pIdxInfo is already populated with all constraints that may
** be used by the virtual table identified by pBuilder->pNew->iTab. This
** function marks a subset of those constraints usable, invokes the
@@ -153875,9 +155497,11 @@ static int whereLoopAddVirtualOne(
u16 mExclude, /* Exclude terms using these operators */
sqlite3_index_info *pIdxInfo, /* Populated object for xBestIndex */
u16 mNoOmit, /* Do not omit these constraints */
- int *pbIn /* OUT: True if plan uses an IN(...) op */
+ int *pbIn, /* OUT: True if plan uses an IN(...) op */
+ int *pbRetryLimit /* OUT: Retry without LIMIT/OFFSET */
){
WhereClause *pWC = pBuilder->pWC;
+ HiddenIndexInfo *pHidden = (HiddenIndexInfo*)&pIdxInfo[1];
struct sqlite3_index_constraint *pIdxCons;
struct sqlite3_index_constraint_usage *pUsage = pIdxInfo->aConstraintUsage;
int i;
@@ -153900,6 +155524,7 @@ static int whereLoopAddVirtualOne(
pIdxCons->usable = 0;
if( (pTerm->prereqRight & mUsable)==pTerm->prereqRight
&& (pTerm->eOperator & mExclude)==0
+ && (pbRetryLimit || !isLimitTerm(pTerm))
){
pIdxCons->usable = 1;
}
@@ -153915,6 +155540,7 @@ static int whereLoopAddVirtualOne(
pIdxInfo->estimatedRows = 25;
pIdxInfo->idxFlags = 0;
pIdxInfo->colUsed = (sqlite3_int64)pSrc->colUsed;
+ pHidden->mHandleIn = 0;
/* Invoke the virtual table xBestIndex() method */
rc = vtabBestIndex(pParse, pSrc->pTab, pIdxInfo);
@@ -153932,8 +155558,8 @@ static int whereLoopAddVirtualOne(
mxTerm = -1;
assert( pNew->nLSlot>=nConstraint );
- for(i=0; i<nConstraint; i++) pNew->aLTerm[i] = 0;
- pNew->u.vtab.omitMask = 0;
+ memset(pNew->aLTerm, 0, sizeof(pNew->aLTerm[0])*nConstraint );
+ memset(&pNew->u.vtab, 0, sizeof(pNew->u.vtab));
pIdxCons = *(struct sqlite3_index_constraint**)&pIdxInfo->aConstraint;
for(i=0; i<nConstraint; i++, pIdxCons++){
int iTerm;
@@ -153967,8 +155593,13 @@ static int whereLoopAddVirtualOne(
}else{
testcase( i!=iTerm );
}
+ if( pTerm->eMatchOp==SQLITE_INDEX_CONSTRAINT_OFFSET ){
+ pNew->u.vtab.bOmitOffset = 1;
+ }
}
- if( (pTerm->eOperator & WO_IN)!=0 ){
+ if( SMASKBIT32(i) & pHidden->mHandleIn ){
+ pNew->u.vtab.mHandleIn |= MASKBIT32(iTerm);
+ }else if( (pTerm->eOperator & WO_IN)!=0 ){
/* A virtual table that is constrained by an IN clause may not
** consume the ORDER BY clause because (1) the order of IN terms
** is not necessarily related to the order of output terms and
@@ -153978,6 +155609,21 @@ static int whereLoopAddVirtualOne(
pIdxInfo->idxFlags &= ~SQLITE_INDEX_SCAN_UNIQUE;
*pbIn = 1; assert( (mExclude & WO_IN)==0 );
}
+
+ if( isLimitTerm(pTerm) && *pbIn ){
+ /* If there is an IN(...) term handled as an == (separate call to
+ ** xFilter for each value on the RHS of the IN) and a LIMIT or
+ ** OFFSET term handled as well, the plan is unusable. Set output
+ ** variable *pbRetryLimit to true to tell the caller to retry with
+ ** LIMIT and OFFSET disabled. */
+ if( pIdxInfo->needToFreeIdxStr ){
+ sqlite3_free(pIdxInfo->idxStr);
+ pIdxInfo->idxStr = 0;
+ pIdxInfo->needToFreeIdxStr = 0;
+ }
+ *pbRetryLimit = 1;
+ return SQLITE_OK;
+ }
}
}
@@ -154022,11 +155668,19 @@ static int whereLoopAddVirtualOne(
}
/*
-** If this function is invoked from within an xBestIndex() callback, it
-** returns a pointer to a buffer containing the name of the collation
-** sequence associated with element iCons of the sqlite3_index_info.aConstraint
-** array. Or, if iCons is out of range or there is no active xBestIndex
-** call, return NULL.
+** Return the collating sequence for a constraint passed into xBestIndex.
+**
+** pIdxInfo must be an sqlite3_index_info structure passed into xBestIndex.
+** This routine depends on there being a HiddenIndexInfo structure immediately
+** following the sqlite3_index_info structure.
+**
+** Return a pointer to the collation name:
+**
+** 1. If there is an explicit COLLATE operator on the constaint, return it.
+**
+** 2. Else, if the column has an alternative collation, return that.
+**
+** 3. Otherwise, return "BINARY".
*/
SQLITE_API const char *sqlite3_vtab_collation(sqlite3_index_info *pIdxInfo, int iCons){
HiddenIndexInfo *pHidden = (HiddenIndexInfo*)&pIdxInfo[1];
@@ -154044,6 +155698,88 @@ SQLITE_API const char *sqlite3_vtab_collation(sqlite3_index_info *pIdxInfo, int
}
/*
+** Return true if constraint iCons is really an IN(...) constraint, or
+** false otherwise. If iCons is an IN(...) constraint, set (if bHandle!=0)
+** or clear (if bHandle==0) the flag to handle it using an iterator.
+*/
+SQLITE_API int sqlite3_vtab_in(sqlite3_index_info *pIdxInfo, int iCons, int bHandle){
+ HiddenIndexInfo *pHidden = (HiddenIndexInfo*)&pIdxInfo[1];
+ u32 m = SMASKBIT32(iCons);
+ if( m & pHidden->mIn ){
+ if( bHandle==0 ){
+ pHidden->mHandleIn &= ~m;
+ }else if( bHandle>0 ){
+ pHidden->mHandleIn |= m;
+ }
+ return 1;
+ }
+ return 0;
+}
+
+/*
+** This interface is callable from within the xBestIndex callback only.
+**
+** If possible, set (*ppVal) to point to an object containing the value
+** on the right-hand-side of constraint iCons.
+*/
+SQLITE_API int sqlite3_vtab_rhs_value(
+ sqlite3_index_info *pIdxInfo, /* Copy of first argument to xBestIndex */
+ int iCons, /* Constraint for which RHS is wanted */
+ sqlite3_value **ppVal /* Write value extracted here */
+){
+ HiddenIndexInfo *pH = (HiddenIndexInfo*)&pIdxInfo[1];
+ sqlite3_value *pVal = 0;
+ int rc = SQLITE_OK;
+ if( iCons<0 || iCons>=pIdxInfo->nConstraint ){
+ rc = SQLITE_MISUSE; /* EV: R-30545-25046 */
+ }else{
+ if( pH->aRhs[iCons]==0 ){
+ WhereTerm *pTerm = &pH->pWC->a[pIdxInfo->aConstraint[iCons].iTermOffset];
+ rc = sqlite3ValueFromExpr(
+ pH->pParse->db, pTerm->pExpr->pRight, ENC(pH->pParse->db),
+ SQLITE_AFF_BLOB, &pH->aRhs[iCons]
+ );
+ testcase( rc!=SQLITE_OK );
+ }
+ pVal = pH->aRhs[iCons];
+ }
+ *ppVal = pVal;
+
+ if( rc==SQLITE_OK && pVal==0 ){ /* IMP: R-19933-32160 */
+ rc = SQLITE_NOTFOUND; /* IMP: R-36424-56542 */
+ }
+
+ return rc;
+}
+
+/*
+** Return true if ORDER BY clause may be handled as DISTINCT.
+*/
+SQLITE_API int sqlite3_vtab_distinct(sqlite3_index_info *pIdxInfo){
+ HiddenIndexInfo *pHidden = (HiddenIndexInfo*)&pIdxInfo[1];
+ assert( pHidden->eDistinct==0
+ || pHidden->eDistinct==1
+ || pHidden->eDistinct==2 );
+ return pHidden->eDistinct;
+}
+
+#if (defined(SQLITE_ENABLE_DBPAGE_VTAB) || defined(SQLITE_TEST)) \
+ && !defined(SQLITE_OMIT_VIRTUALTABLE)
+/*
+** Cause the prepared statement that is associated with a call to
+** xBestIndex to open write transactions on all attached schemas.
+** This is used by the (built-in) sqlite_dbpage virtual table.
+*/
+SQLITE_PRIVATE void sqlite3VtabWriteAll(sqlite3_index_info *pIdxInfo){
+ HiddenIndexInfo *pHidden = (HiddenIndexInfo*)&pIdxInfo[1];
+ Parse *pParse = pHidden->pParse;
+ int nDb = pParse->db->nDb;
+ int i;
+ for(i=0; i<nDb; i++) sqlite3BeginWriteOperation(pParse, 0, i);
+}
+#endif
+
+/*
** Add all WhereLoop objects for a table of the join identified by
** pBuilder->pNew->iTab. That table is guaranteed to be a virtual table.
**
@@ -154084,6 +155820,7 @@ static int whereLoopAddVirtual(
WhereLoop *pNew;
Bitmask mBest; /* Tables used by best possible plan */
u16 mNoOmit;
+ int bRetry = 0; /* True to retry with LIMIT/OFFSET disabled */
assert( (mPrereq & mUnusable)==0 );
pWInfo = pBuilder->pWInfo;
@@ -154092,8 +155829,7 @@ static int whereLoopAddVirtual(
pNew = pBuilder->pNew;
pSrc = &pWInfo->pTabList->a[pNew->iTab];
assert( IsVirtual(pSrc->pTab) );
- p = allocateIndexInfo(pParse, pWC, mUnusable, pSrc, pBuilder->pOrderBy,
- &mNoOmit);
+ p = allocateIndexInfo(pWInfo, pWC, mUnusable, pSrc, &mNoOmit);
if( p==0 ) return SQLITE_NOMEM_BKPT;
pNew->rSetup = 0;
pNew->wsFlags = WHERE_VIRTUALTABLE;
@@ -154101,14 +155837,22 @@ static int whereLoopAddVirtual(
pNew->u.vtab.needFree = 0;
nConstraint = p->nConstraint;
if( whereLoopResize(pParse->db, pNew, nConstraint) ){
- sqlite3DbFree(pParse->db, p);
+ freeIndexInfo(pParse->db, p);
return SQLITE_NOMEM_BKPT;
}
/* First call xBestIndex() with all constraints usable. */
WHERETRACE(0x800, ("BEGIN %s.addVirtual()\n", pSrc->pTab->zName));
WHERETRACE(0x40, (" VirtualOne: all usable\n"));
- rc = whereLoopAddVirtualOne(pBuilder, mPrereq, ALLBITS, 0, p, mNoOmit, &bIn);
+ rc = whereLoopAddVirtualOne(
+ pBuilder, mPrereq, ALLBITS, 0, p, mNoOmit, &bIn, &bRetry
+ );
+ if( bRetry ){
+ assert( rc==SQLITE_OK );
+ rc = whereLoopAddVirtualOne(
+ pBuilder, mPrereq, ALLBITS, 0, p, mNoOmit, &bIn, 0
+ );
+ }
/* If the call to xBestIndex() with all terms enabled produced a plan
** that does not require any source tables (IOW: a plan with mBest==0)
@@ -154126,7 +155870,7 @@ static int whereLoopAddVirtual(
if( bIn ){
WHERETRACE(0x40, (" VirtualOne: all usable w/o IN\n"));
rc = whereLoopAddVirtualOne(
- pBuilder, mPrereq, ALLBITS, WO_IN, p, mNoOmit, &bIn);
+ pBuilder, mPrereq, ALLBITS, WO_IN, p, mNoOmit, &bIn, 0);
assert( bIn==0 );
mBestNoIn = pNew->prereq & ~mPrereq;
if( mBestNoIn==0 ){
@@ -154153,7 +155897,7 @@ static int whereLoopAddVirtual(
WHERETRACE(0x40, (" VirtualOne: mPrev=%04llx mNext=%04llx\n",
(sqlite3_uint64)mPrev, (sqlite3_uint64)mNext));
rc = whereLoopAddVirtualOne(
- pBuilder, mPrereq, mNext|mPrereq, 0, p, mNoOmit, &bIn);
+ pBuilder, mPrereq, mNext|mPrereq, 0, p, mNoOmit, &bIn, 0);
if( pNew->prereq==mPrereq ){
seenZero = 1;
if( bIn==0 ) seenZeroNoIN = 1;
@@ -154166,7 +155910,7 @@ static int whereLoopAddVirtual(
if( rc==SQLITE_OK && seenZero==0 ){
WHERETRACE(0x40, (" VirtualOne: all disabled\n"));
rc = whereLoopAddVirtualOne(
- pBuilder, mPrereq, mPrereq, 0, p, mNoOmit, &bIn);
+ pBuilder, mPrereq, mPrereq, 0, p, mNoOmit, &bIn, 0);
if( bIn==0 ) seenZeroNoIN = 1;
}
@@ -154176,12 +155920,12 @@ static int whereLoopAddVirtual(
if( rc==SQLITE_OK && seenZeroNoIN==0 ){
WHERETRACE(0x40, (" VirtualOne: all disabled and w/o IN\n"));
rc = whereLoopAddVirtualOne(
- pBuilder, mPrereq, mPrereq, WO_IN, p, mNoOmit, &bIn);
+ pBuilder, mPrereq, mPrereq, WO_IN, p, mNoOmit, &bIn, 0);
}
}
if( p->needToFreeIdxStr ) sqlite3_free(p->idxStr);
- sqlite3DbFreeNN(pParse->db, p);
+ freeIndexInfo(pParse->db, p);
WHERETRACE(0x800, ("END %s.addVirtual(), rc=%d\n", pSrc->pTab->zName, rc));
return rc;
}
@@ -154225,7 +155969,6 @@ static int whereLoopAddOr(
int i, j;
sSubBuild = *pBuilder;
- sSubBuild.pOrderBy = 0;
sSubBuild.pOrSet = &sCur;
WHERETRACE(0x200, ("Begin processing OR-clause %p\n", pTerm));
@@ -154237,6 +155980,7 @@ static int whereLoopAddOr(
tempWC.pOuter = pWC;
tempWC.op = TK_AND;
tempWC.nTerm = 1;
+ tempWC.nBase = 1;
tempWC.a = pOrTerm;
sSubBuild.pWC = &tempWC;
}else{
@@ -155344,6 +157088,150 @@ static void showAllWhereLoops(WhereInfo *pWInfo, WhereClause *pWC){
# define WHERETRACE_ALL_LOOPS(W,C)
#endif
+/* Attempt to omit tables from a join that do not affect the result.
+** For a table to not affect the result, the following must be true:
+**
+** 1) The query must not be an aggregate.
+** 2) The table must be the RHS of a LEFT JOIN.
+** 3) Either the query must be DISTINCT, or else the ON or USING clause
+** must contain a constraint that limits the scan of the table to
+** at most a single row.
+** 4) The table must not be referenced by any part of the query apart
+** from its own USING or ON clause.
+**
+** For example, given:
+**
+** CREATE TABLE t1(ipk INTEGER PRIMARY KEY, v1);
+** CREATE TABLE t2(ipk INTEGER PRIMARY KEY, v2);
+** CREATE TABLE t3(ipk INTEGER PRIMARY KEY, v3);
+**
+** then table t2 can be omitted from the following:
+**
+** SELECT v1, v3 FROM t1
+** LEFT JOIN t2 ON (t1.ipk=t2.ipk)
+** LEFT JOIN t3 ON (t1.ipk=t3.ipk)
+**
+** or from:
+**
+** SELECT DISTINCT v1, v3 FROM t1
+** LEFT JOIN t2
+** LEFT JOIN t3 ON (t1.ipk=t3.ipk)
+*/
+static SQLITE_NOINLINE Bitmask whereOmitNoopJoin(
+ WhereInfo *pWInfo,
+ Bitmask notReady
+){
+ int i;
+ Bitmask tabUsed;
+
+ /* Preconditions checked by the caller */
+ assert( pWInfo->nLevel>=2 );
+ assert( OptimizationEnabled(pWInfo->pParse->db, SQLITE_OmitNoopJoin) );
+
+ /* These two preconditions checked by the caller combine to guarantee
+ ** condition (1) of the header comment */
+ assert( pWInfo->pResultSet!=0 );
+ assert( 0==(pWInfo->wctrlFlags & WHERE_AGG_DISTINCT) );
+
+ tabUsed = sqlite3WhereExprListUsage(&pWInfo->sMaskSet, pWInfo->pResultSet);
+ if( pWInfo->pOrderBy ){
+ tabUsed |= sqlite3WhereExprListUsage(&pWInfo->sMaskSet, pWInfo->pOrderBy);
+ }
+ for(i=pWInfo->nLevel-1; i>=1; i--){
+ WhereTerm *pTerm, *pEnd;
+ SrcItem *pItem;
+ WhereLoop *pLoop;
+ pLoop = pWInfo->a[i].pWLoop;
+ pItem = &pWInfo->pTabList->a[pLoop->iTab];
+ if( (pItem->fg.jointype & JT_LEFT)==0 ) continue;
+ if( (pWInfo->wctrlFlags & WHERE_WANT_DISTINCT)==0
+ && (pLoop->wsFlags & WHERE_ONEROW)==0
+ ){
+ continue;
+ }
+ if( (tabUsed & pLoop->maskSelf)!=0 ) continue;
+ pEnd = pWInfo->sWC.a + pWInfo->sWC.nTerm;
+ for(pTerm=pWInfo->sWC.a; pTerm<pEnd; pTerm++){
+ if( (pTerm->prereqAll & pLoop->maskSelf)!=0 ){
+ if( !ExprHasProperty(pTerm->pExpr, EP_FromJoin)
+ || pTerm->pExpr->w.iRightJoinTable!=pItem->iCursor
+ ){
+ break;
+ }
+ }
+ }
+ if( pTerm<pEnd ) continue;
+ WHERETRACE(0xffff, ("-> drop loop %c not used\n", pLoop->cId));
+ notReady &= ~pLoop->maskSelf;
+ for(pTerm=pWInfo->sWC.a; pTerm<pEnd; pTerm++){
+ if( (pTerm->prereqAll & pLoop->maskSelf)!=0 ){
+ pTerm->wtFlags |= TERM_CODED;
+ }
+ }
+ if( i!=pWInfo->nLevel-1 ){
+ int nByte = (pWInfo->nLevel-1-i) * sizeof(WhereLevel);
+ memmove(&pWInfo->a[i], &pWInfo->a[i+1], nByte);
+ }
+ pWInfo->nLevel--;
+ assert( pWInfo->nLevel>0 );
+ }
+ return notReady;
+}
+
+/*
+** Check to see if there are any SEARCH loops that might benefit from
+** using a Bloom filter. Consider a Bloom filter if:
+**
+** (1) The SEARCH happens more than N times where N is the number
+** of rows in the table that is being considered for the Bloom
+** filter.
+** (2) Some searches are expected to find zero rows. (This is determined
+** by the WHERE_SELFCULL flag on the term.)
+** (3) Bloom-filter processing is not disabled. (Checked by the
+** caller.)
+** (4) The size of the table being searched is known by ANALYZE.
+**
+** This block of code merely checks to see if a Bloom filter would be
+** appropriate, and if so sets the WHERE_BLOOMFILTER flag on the
+** WhereLoop. The implementation of the Bloom filter comes further
+** down where the code for each WhereLoop is generated.
+*/
+static SQLITE_NOINLINE void whereCheckIfBloomFilterIsUseful(
+ const WhereInfo *pWInfo
+){
+ int i;
+ LogEst nSearch;
+
+ assert( pWInfo->nLevel>=2 );
+ assert( OptimizationEnabled(pWInfo->pParse->db, SQLITE_BloomFilter) );
+ nSearch = pWInfo->a[0].pWLoop->nOut;
+ for(i=1; i<pWInfo->nLevel; i++){
+ WhereLoop *pLoop = pWInfo->a[i].pWLoop;
+ const unsigned int reqFlags = (WHERE_SELFCULL|WHERE_COLUMN_EQ);
+ if( (pLoop->wsFlags & reqFlags)==reqFlags
+ /* vvvvvv--- Always the case if WHERE_COLUMN_EQ is defined */
+ && ALWAYS((pLoop->wsFlags & (WHERE_IPK|WHERE_INDEXED))!=0)
+ ){
+ SrcItem *pItem = &pWInfo->pTabList->a[pLoop->iTab];
+ Table *pTab = pItem->pTab;
+ pTab->tabFlags |= TF_StatsUsed;
+ if( nSearch > pTab->nRowLogEst
+ && (pTab->tabFlags & TF_HasStat1)!=0
+ ){
+ testcase( pItem->fg.jointype & JT_LEFT );
+ pLoop->wsFlags |= WHERE_BLOOMFILTER;
+ pLoop->wsFlags &= ~WHERE_IDX_ONLY;
+ WHERETRACE(0xffff, (
+ "-> use Bloom-filter on loop %c because there are ~%.1e "
+ "lookups into %s which has only ~%.1e rows\n",
+ pLoop->cId, (double)sqlite3LogEstToInt(nSearch), pTab->zName,
+ (double)sqlite3LogEstToInt(pTab->nRowLogEst)));
+ }
+ }
+ nSearch += pLoop->nOut;
+ }
+}
+
/*
** Generate the beginning of the loop used for WHERE clause processing.
** The return value is a pointer to an opaque structure that contains
@@ -155438,6 +157326,7 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
Expr *pWhere, /* The WHERE clause */
ExprList *pOrderBy, /* An ORDER BY (or GROUP BY) clause, or NULL */
ExprList *pResultSet, /* Query result set. Req'd for DISTINCT */
+ Select *pLimit, /* Use this LIMIT/OFFSET clause, if any */
u16 wctrlFlags, /* The WHERE_* flags defined in sqliteInt.h */
int iAuxArg /* If WHERE_OR_SUBCLAUSE is set, index cursor number
** If WHERE_USE_LIMIT, then the limit amount */
@@ -155472,13 +157361,6 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
/* An ORDER/GROUP BY clause of more than 63 terms cannot be optimized */
testcase( pOrderBy && pOrderBy->nExpr==BMS-1 );
if( pOrderBy && pOrderBy->nExpr>=BMS ) pOrderBy = 0;
- sWLB.pOrderBy = pOrderBy;
-
- /* Disable the DISTINCT optimization if SQLITE_DistinctOpt is set via
- ** sqlite3_test_ctrl(SQLITE_TESTCTRL_OPTIMIZATIONS,...) */
- if( OptimizationDisabled(db, SQLITE_DistinctOpt) ){
- wctrlFlags &= ~WHERE_WANT_DISTINCT;
- }
/* The number of tables in the FROM clause is limited by the number of
** bits in a Bitmask
@@ -155521,11 +157403,18 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
pWInfo->wctrlFlags = wctrlFlags;
pWInfo->iLimit = iAuxArg;
pWInfo->savedNQueryLoop = pParse->nQueryLoop;
+#ifndef SQLITE_OMIT_VIRTUALTABLE
+ pWInfo->pLimit = pLimit;
+#endif
memset(&pWInfo->nOBSat, 0,
offsetof(WhereInfo,sWC) - offsetof(WhereInfo,nOBSat));
memset(&pWInfo->a[0], 0, sizeof(WhereLoop)+nTabList*sizeof(WhereLevel));
assert( pWInfo->eOnePass==ONEPASS_OFF ); /* ONEPASS defaults to OFF */
pMaskSet = &pWInfo->sMaskSet;
+ pMaskSet->n = 0;
+ pMaskSet->ix[0] = -99; /* Initialize ix[0] to a value that can never be
+ ** a valid cursor number, to avoid an initial
+ ** test for pMaskSet->n==0 in sqlite3WhereGetMask() */
sWLB.pWInfo = pWInfo;
sWLB.pWC = &pWInfo->sWC;
sWLB.pNew = (WhereLoop*)(((char*)pWInfo)+nByteWInfo);
@@ -155538,7 +157427,6 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
/* Split the WHERE clause into separate subexpressions where each
** subexpression is separated by an AND operator.
*/
- initMaskSet(pMaskSet);
sqlite3WhereClauseInit(&pWInfo->sWC, pWInfo);
sqlite3WhereSplit(&pWInfo->sWC, pWhere, TK_AND);
@@ -155546,7 +157434,9 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
*/
if( nTabList==0 ){
if( pOrderBy ) pWInfo->nOBSat = pOrderBy->nExpr;
- if( wctrlFlags & WHERE_WANT_DISTINCT ){
+ if( (wctrlFlags & WHERE_WANT_DISTINCT)!=0
+ && OptimizationEnabled(db, SQLITE_DistinctOpt)
+ ){
pWInfo->eDistinct = WHERE_DISTINCT_UNIQUE;
}
ExplainQueryPlan((pParse, 0, "SCAN CONSTANT ROW"));
@@ -155584,6 +157474,7 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
/* Analyze all of the subexpressions. */
sqlite3WhereExprAnalyze(pTabList, &pWInfo->sWC);
+ sqlite3WhereAddLimit(&pWInfo->sWC, pLimit);
if( db->mallocFailed ) goto whereBeginError;
/* Special case: WHERE terms that do not refer to any tables in the join
@@ -155597,7 +157488,7 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
** FROM ... WHERE random()>0; -- eval random() once per row
** FROM ... WHERE (SELECT random())>0; -- eval random() once overall
*/
- for(ii=0; ii<sWLB.pWC->nTerm; ii++){
+ for(ii=0; ii<sWLB.pWC->nBase; ii++){
WhereTerm *pT = &sWLB.pWC->a[ii];
if( pT->wtFlags & TERM_VIRTUAL ) continue;
if( pT->prereqAll==0 && (nTabList==0 || exprIsDeterministic(pT->pExpr)) ){
@@ -155607,7 +157498,12 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
}
if( wctrlFlags & WHERE_WANT_DISTINCT ){
- if( isDistinctRedundant(pParse, pTabList, &pWInfo->sWC, pResultSet) ){
+ if( OptimizationDisabled(db, SQLITE_DistinctOpt) ){
+ /* Disable the DISTINCT optimization if SQLITE_DistinctOpt is set via
+ ** sqlite3_test_ctrl(SQLITE_TESTCTRL_OPTIMIZATIONS,...) */
+ wctrlFlags &= ~WHERE_WANT_DISTINCT;
+ pWInfo->wctrlFlags &= ~WHERE_WANT_DISTINCT;
+ }else if( isDistinctRedundant(pParse, pTabList, &pWInfo->sWC, pResultSet) ){
/* The DISTINCT marking is pointless. Ignore it. */
pWInfo->eDistinct = WHERE_DISTINCT_UNIQUE;
}else if( pOrderBy==0 ){
@@ -155678,9 +157574,10 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
if( pWInfo->pOrderBy==0 && (db->flags & SQLITE_ReverseOrder)!=0 ){
pWInfo->revMask = ALLBITS;
}
- if( pParse->nErr || db->mallocFailed ){
+ if( pParse->nErr ){
goto whereBeginError;
}
+ assert( db->mallocFailed==0 );
#ifdef WHERETRACE_ENABLED
if( sqlite3WhereTrace ){
sqlite3DebugPrintf("---- Solution nRow=%d", pWInfo->nRowOut);
@@ -155708,34 +157605,15 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
}
#endif
- /* Attempt to omit tables from the join that do not affect the result.
- ** For a table to not affect the result, the following must be true:
- **
- ** 1) The query must not be an aggregate.
- ** 2) The table must be the RHS of a LEFT JOIN.
- ** 3) Either the query must be DISTINCT, or else the ON or USING clause
- ** must contain a constraint that limits the scan of the table to
- ** at most a single row.
- ** 4) The table must not be referenced by any part of the query apart
- ** from its own USING or ON clause.
+ /* Attempt to omit tables from a join that do not affect the result.
+ ** See the comment on whereOmitNoopJoin() for further information.
**
- ** For example, given:
- **
- ** CREATE TABLE t1(ipk INTEGER PRIMARY KEY, v1);
- ** CREATE TABLE t2(ipk INTEGER PRIMARY KEY, v2);
- ** CREATE TABLE t3(ipk INTEGER PRIMARY KEY, v3);
- **
- ** then table t2 can be omitted from the following:
- **
- ** SELECT v1, v3 FROM t1
- ** LEFT JOIN t2 ON (t1.ipk=t2.ipk)
- ** LEFT JOIN t3 ON (t1.ipk=t3.ipk)
- **
- ** or from:
- **
- ** SELECT DISTINCT v1, v3 FROM t1
- ** LEFT JOIN t2
- ** LEFT JOIN t3 ON (t1.ipk=t3.ipk)
+ ** This query optimization is factored out into a separate "no-inline"
+ ** procedure to keep the sqlite3WhereBegin() procedure from becoming
+ ** too large. If sqlite3WhereBegin() becomes too large, that prevents
+ ** some C-compiler optimizers from in-lining the
+ ** sqlite3WhereCodeOneLoopStart() procedure, and it is important to
+ ** in-line sqlite3WhereCodeOneLoopStart() for performance reasons.
*/
notReady = ~(Bitmask)0;
if( pWInfo->nLevel>=2
@@ -155743,49 +157621,20 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
&& 0==(wctrlFlags & WHERE_AGG_DISTINCT) /* condition (1) above */
&& OptimizationEnabled(db, SQLITE_OmitNoopJoin)
){
- int i;
- Bitmask tabUsed = sqlite3WhereExprListUsage(pMaskSet, pResultSet);
- if( sWLB.pOrderBy ){
- tabUsed |= sqlite3WhereExprListUsage(pMaskSet, sWLB.pOrderBy);
- }
- for(i=pWInfo->nLevel-1; i>=1; i--){
- WhereTerm *pTerm, *pEnd;
- SrcItem *pItem;
- pLoop = pWInfo->a[i].pWLoop;
- pItem = &pWInfo->pTabList->a[pLoop->iTab];
- if( (pItem->fg.jointype & JT_LEFT)==0 ) continue;
- if( (wctrlFlags & WHERE_WANT_DISTINCT)==0
- && (pLoop->wsFlags & WHERE_ONEROW)==0
- ){
- continue;
- }
- if( (tabUsed & pLoop->maskSelf)!=0 ) continue;
- pEnd = sWLB.pWC->a + sWLB.pWC->nTerm;
- for(pTerm=sWLB.pWC->a; pTerm<pEnd; pTerm++){
- if( (pTerm->prereqAll & pLoop->maskSelf)!=0 ){
- if( !ExprHasProperty(pTerm->pExpr, EP_FromJoin)
- || pTerm->pExpr->iRightJoinTable!=pItem->iCursor
- ){
- break;
- }
- }
- }
- if( pTerm<pEnd ) continue;
- WHERETRACE(0xffff, ("-> drop loop %c not used\n", pLoop->cId));
- notReady &= ~pLoop->maskSelf;
- for(pTerm=sWLB.pWC->a; pTerm<pEnd; pTerm++){
- if( (pTerm->prereqAll & pLoop->maskSelf)!=0 ){
- pTerm->wtFlags |= TERM_CODED;
- }
- }
- if( i!=pWInfo->nLevel-1 ){
- int nByte = (pWInfo->nLevel-1-i) * sizeof(WhereLevel);
- memmove(&pWInfo->a[i], &pWInfo->a[i+1], nByte);
- }
- pWInfo->nLevel--;
- nTabList--;
- }
+ notReady = whereOmitNoopJoin(pWInfo, notReady);
+ nTabList = pWInfo->nLevel;
+ assert( nTabList>0 );
}
+
+ /* Check to see if there are any SEARCH loops that might benefit from
+ ** using a Bloom filter.
+ */
+ if( pWInfo->nLevel>=2
+ && OptimizationEnabled(db, SQLITE_BloomFilter)
+ ){
+ whereCheckIfBloomFilterIsUseful(pWInfo);
+ }
+
#if defined(WHERETRACE_ENABLED)
if( sqlite3WhereTrace & 0x100 ){ /* Display all terms of the WHERE clause */
sqlite3DebugPrintf("---- WHERE clause at end of analysis:\n");
@@ -155872,6 +157721,7 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
if( pWInfo->eOnePass==ONEPASS_OFF
&& pTab->nCol<BMS
&& (pTab->tabFlags & (TF_HasGenerated|TF_WithoutRowid))==0
+ && (pLoop->wsFlags & (WHERE_AUTO_INDEX|WHERE_BLOOMFILTER))==0
){
/* If we know that only a prefix of the record will be used,
** it is advantageous to reduce the "column count" field in
@@ -155974,13 +157824,17 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
if( pParse->nErr ) goto whereBeginError;
pLevel = &pWInfo->a[ii];
wsFlags = pLevel->pWLoop->wsFlags;
+ if( (wsFlags & (WHERE_AUTO_INDEX|WHERE_BLOOMFILTER))!=0 ){
+ if( (wsFlags & WHERE_AUTO_INDEX)!=0 ){
#ifndef SQLITE_OMIT_AUTOMATIC_INDEX
- if( (pLevel->pWLoop->wsFlags & WHERE_AUTO_INDEX)!=0 ){
- constructAutomaticIndex(pParse, &pWInfo->sWC,
- &pTabList->a[pLevel->iFrom], notReady, pLevel);
+ constructAutomaticIndex(pParse, &pWInfo->sWC,
+ &pTabList->a[pLevel->iFrom], notReady, pLevel);
+#endif
+ }else{
+ sqlite3ConstructBloomFilter(pWInfo, ii, pLevel, notReady);
+ }
if( db->mallocFailed ) goto whereBeginError;
}
-#endif
addrExplain = sqlite3WhereExplainOneScan(
pParse, pTabList, pLevel, wctrlFlags
);
@@ -156284,6 +158138,10 @@ SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo *pWInfo){
Index *pPk = sqlite3PrimaryKeyIndex(pTab);
x = pPk->aiColumn[x];
assert( x>=0 );
+#ifdef SQLITE_ENABLE_OFFSET_SQL_FUNC
+ }else if( pOp->opcode==OP_Offset ){
+ /* Do not need to translate the column number */
+#endif
}else{
testcase( x!=sqlite3StorageColumnToTable(pTab,x) );
x = sqlite3StorageColumnToTable(pTab,x);
@@ -157283,7 +159141,11 @@ static int disallowAggregatesInOrderByCb(Walker *pWalker, Expr *pExpr){
*/
SQLITE_PRIVATE int sqlite3WindowRewrite(Parse *pParse, Select *p){
int rc = SQLITE_OK;
- if( p->pWin && p->pPrior==0 && ALWAYS((p->selFlags & SF_WinRewrite)==0) ){
+ if( p->pWin
+ && p->pPrior==0
+ && ALWAYS((p->selFlags & SF_WinRewrite)==0)
+ && ALWAYS(!IN_RENAME_OBJECT)
+ ){
Vdbe *v = sqlite3GetVdbe(pParse);
sqlite3 *db = pParse->db;
Select *pSub = 0; /* The subquery */
@@ -157358,6 +159220,7 @@ SQLITE_PRIVATE int sqlite3WindowRewrite(Parse *pParse, Select *p){
for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
ExprList *pArgs;
assert( ExprUseXList(pWin->pOwner) );
+ assert( pWin->pFunc!=0 );
pArgs = pWin->pOwner->x.pList;
if( pWin->pFunc->funcFlags & SQLITE_FUNC_SUBTYPE ){
selectWindowRewriteEList(pParse, pMWin, pSrc, pArgs, pTab, &pSublist);
@@ -157432,12 +159295,7 @@ SQLITE_PRIVATE int sqlite3WindowRewrite(Parse *pParse, Select *p){
sqlite3ParserAddCleanup(pParse, sqlite3DbFree, pTab);
}
- if( rc ){
- if( pParse->nErr==0 ){
- assert( pParse->db->mallocFailed );
- sqlite3ErrorToParser(pParse->db, SQLITE_NOMEM);
- }
- }
+ assert( rc==SQLITE_OK || pParse->nErr!=0 );
return rc;
}
@@ -159585,10 +161443,7 @@ static void updateDeleteLimitError(
}
- /* Construct a new Expr object from a single identifier. Use the
- ** new Expr to populate pOut. Set the span of pOut to be the identifier
- ** that created the expression.
- */
+ /* Construct a new Expr object from a single token */
static Expr *tokenExpr(Parse *pParse, int op, Token t){
Expr *p = sqlite3DbMallocRawNN(pParse->db, sizeof(Expr)+t.n+1);
if( p ){
@@ -159608,6 +161463,7 @@ static void updateDeleteLimitError(
p->u.zToken = (char*)&p[1];
memcpy(p->u.zToken, t.z, t.n);
p->u.zToken[t.n] = 0;
+ p->w.iOfst = (int)(t.z - pParse->zTail);
if( sqlite3Isquote(p->u.zToken[0]) ){
sqlite3DequoteExpr(p);
}
@@ -159774,78 +161630,79 @@ static void updateDeleteLimitError(
#define TK_SLASH 109
#define TK_REM 110
#define TK_CONCAT 111
-#define TK_COLLATE 112
-#define TK_BITNOT 113
-#define TK_ON 114
-#define TK_INDEXED 115
-#define TK_STRING 116
-#define TK_JOIN_KW 117
-#define TK_CONSTRAINT 118
-#define TK_DEFAULT 119
-#define TK_NULL 120
-#define TK_PRIMARY 121
-#define TK_UNIQUE 122
-#define TK_CHECK 123
-#define TK_REFERENCES 124
-#define TK_AUTOINCR 125
-#define TK_INSERT 126
-#define TK_DELETE 127
-#define TK_UPDATE 128
-#define TK_SET 129
-#define TK_DEFERRABLE 130
-#define TK_FOREIGN 131
-#define TK_DROP 132
-#define TK_UNION 133
-#define TK_ALL 134
-#define TK_EXCEPT 135
-#define TK_INTERSECT 136
-#define TK_SELECT 137
-#define TK_VALUES 138
-#define TK_DISTINCT 139
-#define TK_DOT 140
-#define TK_FROM 141
-#define TK_JOIN 142
-#define TK_USING 143
-#define TK_ORDER 144
-#define TK_GROUP 145
-#define TK_HAVING 146
-#define TK_LIMIT 147
-#define TK_WHERE 148
-#define TK_RETURNING 149
-#define TK_INTO 150
-#define TK_NOTHING 151
-#define TK_FLOAT 152
-#define TK_BLOB 153
-#define TK_INTEGER 154
-#define TK_VARIABLE 155
-#define TK_CASE 156
-#define TK_WHEN 157
-#define TK_THEN 158
-#define TK_ELSE 159
-#define TK_INDEX 160
-#define TK_ALTER 161
-#define TK_ADD 162
-#define TK_WINDOW 163
-#define TK_OVER 164
-#define TK_FILTER 165
-#define TK_COLUMN 166
-#define TK_AGG_FUNCTION 167
-#define TK_AGG_COLUMN 168
-#define TK_TRUEFALSE 169
-#define TK_ISNOT 170
-#define TK_FUNCTION 171
-#define TK_UMINUS 172
-#define TK_UPLUS 173
-#define TK_TRUTH 174
-#define TK_REGISTER 175
-#define TK_VECTOR 176
-#define TK_SELECT_COLUMN 177
-#define TK_IF_NULL_ROW 178
-#define TK_ASTERISK 179
-#define TK_SPAN 180
-#define TK_ERROR 181
-#define TK_SPACE 182
-#define TK_ILLEGAL 183
+#define TK_PTR 112
+#define TK_COLLATE 113
+#define TK_BITNOT 114
+#define TK_ON 115
+#define TK_INDEXED 116
+#define TK_STRING 117
+#define TK_JOIN_KW 118
+#define TK_CONSTRAINT 119
+#define TK_DEFAULT 120
+#define TK_NULL 121
+#define TK_PRIMARY 122
+#define TK_UNIQUE 123
+#define TK_CHECK 124
+#define TK_REFERENCES 125
+#define TK_AUTOINCR 126
+#define TK_INSERT 127
+#define TK_DELETE 128
+#define TK_UPDATE 129
+#define TK_SET 130
+#define TK_DEFERRABLE 131
+#define TK_FOREIGN 132
+#define TK_DROP 133
+#define TK_UNION 134
+#define TK_ALL 135
+#define TK_EXCEPT 136
+#define TK_INTERSECT 137
+#define TK_SELECT 138
+#define TK_VALUES 139
+#define TK_DISTINCT 140
+#define TK_DOT 141
+#define TK_FROM 142
+#define TK_JOIN 143
+#define TK_USING 144
+#define TK_ORDER 145
+#define TK_GROUP 146
+#define TK_HAVING 147
+#define TK_LIMIT 148
+#define TK_WHERE 149
+#define TK_RETURNING 150
+#define TK_INTO 151
+#define TK_NOTHING 152
+#define TK_FLOAT 153
+#define TK_BLOB 154
+#define TK_INTEGER 155
+#define TK_VARIABLE 156
+#define TK_CASE 157
+#define TK_WHEN 158
+#define TK_THEN 159
+#define TK_ELSE 160
+#define TK_INDEX 161
+#define TK_ALTER 162
+#define TK_ADD 163
+#define TK_WINDOW 164
+#define TK_OVER 165
+#define TK_FILTER 166
+#define TK_COLUMN 167
+#define TK_AGG_FUNCTION 168
+#define TK_AGG_COLUMN 169
+#define TK_TRUEFALSE 170
+#define TK_ISNOT 171
+#define TK_FUNCTION 172
+#define TK_UMINUS 173
+#define TK_UPLUS 174
+#define TK_TRUTH 175
+#define TK_REGISTER 176
+#define TK_VECTOR 177
+#define TK_SELECT_COLUMN 178
+#define TK_IF_NULL_ROW 179
+#define TK_ASTERISK 180
+#define TK_SPAN 181
+#define TK_ERROR 182
+#define TK_SPACE 183
+#define TK_ILLEGAL 184
#endif
/**************** End token definitions ***************************************/
@@ -159905,30 +161762,30 @@ static void updateDeleteLimitError(
#endif
/************* Begin control #defines *****************************************/
#define YYCODETYPE unsigned short int
-#define YYNOCODE 318
+#define YYNOCODE 319
#define YYACTIONTYPE unsigned short int
#define YYWILDCARD 101
#define sqlite3ParserTOKENTYPE Token
typedef union {
int yyinit;
sqlite3ParserTOKENTYPE yy0;
- With* yy43;
- u32 yy51;
- int yy64;
- struct FrameBound yy81;
- struct {int value; int mask;} yy83;
- TriggerStep* yy95;
- Upsert* yy138;
- IdList* yy240;
- Cte* yy255;
- Select* yy303;
- Window* yy375;
- u8 yy534;
- ExprList* yy562;
- struct TrigEvent yy570;
- const char* yy600;
- SrcList* yy607;
- Expr* yy626;
+ TriggerStep* yy33;
+ Window* yy41;
+ Select* yy47;
+ SrcList* yy131;
+ struct TrigEvent yy180;
+ struct {int value; int mask;} yy231;
+ IdList* yy254;
+ u32 yy285;
+ ExprList* yy322;
+ Cte* yy385;
+ int yy394;
+ Upsert* yy444;
+ u8 yy516;
+ With* yy521;
+ const char* yy522;
+ Expr* yy528;
+ struct FrameBound yy595;
} YYMINORTYPE;
#ifndef YYSTACKDEPTH
#define YYSTACKDEPTH 100
@@ -159944,18 +161801,18 @@ typedef union {
#define sqlite3ParserCTX_FETCH Parse *pParse=yypParser->pParse;
#define sqlite3ParserCTX_STORE yypParser->pParse=pParse;
#define YYFALLBACK 1
-#define YYNSTATE 572
-#define YYNRULE 401
-#define YYNRULE_WITH_ACTION 339
-#define YYNTOKEN 184
-#define YY_MAX_SHIFT 571
-#define YY_MIN_SHIFTREDUCE 829
-#define YY_MAX_SHIFTREDUCE 1229
-#define YY_ERROR_ACTION 1230
-#define YY_ACCEPT_ACTION 1231
-#define YY_NO_ACTION 1232
-#define YY_MIN_REDUCE 1233
-#define YY_MAX_REDUCE 1633
+#define YYNSTATE 574
+#define YYNRULE 402
+#define YYNRULE_WITH_ACTION 340
+#define YYNTOKEN 185
+#define YY_MAX_SHIFT 573
+#define YY_MIN_SHIFTREDUCE 831
+#define YY_MAX_SHIFTREDUCE 1232
+#define YY_ERROR_ACTION 1233
+#define YY_ACCEPT_ACTION 1234
+#define YY_NO_ACTION 1235
+#define YY_MIN_REDUCE 1236
+#define YY_MAX_REDUCE 1637
/************* End control #defines *******************************************/
#define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])))
@@ -160022,606 +161879,612 @@ typedef union {
** yy_default[] Default action for each state.
**
*********** Begin parsing tables **********************************************/
-#define YY_ACTTAB_COUNT (2037)
+#define YY_ACTTAB_COUNT (2070)
static const YYACTIONTYPE yy_action[] = {
- /* 0 */ 564, 115, 112, 220, 169, 199, 115, 112, 220, 564,
- /* 10 */ 375, 1266, 564, 376, 564, 270, 1309, 1309, 406, 407,
- /* 20 */ 1084, 199, 1513, 41, 41, 515, 489, 521, 558, 558,
- /* 30 */ 558, 965, 41, 41, 395, 41, 41, 51, 51, 966,
- /* 40 */ 296, 1269, 296, 122, 123, 113, 1207, 1207, 1041, 1044,
- /* 50 */ 1034, 1034, 120, 120, 121, 121, 121, 121, 564, 407,
- /* 60 */ 275, 275, 275, 275, 1268, 115, 112, 220, 115, 112,
- /* 70 */ 220, 1512, 846, 561, 516, 561, 115, 112, 220, 250,
- /* 80 */ 217, 71, 71, 122, 123, 113, 1207, 1207, 1041, 1044,
- /* 90 */ 1034, 1034, 120, 120, 121, 121, 121, 121, 440, 440,
- /* 100 */ 440, 1149, 119, 119, 119, 119, 118, 118, 117, 117,
- /* 110 */ 117, 116, 442, 1183, 1149, 116, 442, 1149, 546, 513,
- /* 120 */ 1548, 1554, 374, 442, 6, 1183, 1154, 522, 1154, 407,
- /* 130 */ 1556, 461, 373, 1554, 535, 99, 463, 332, 121, 121,
- /* 140 */ 121, 121, 119, 119, 119, 119, 118, 118, 117, 117,
- /* 150 */ 117, 116, 442, 122, 123, 113, 1207, 1207, 1041, 1044,
- /* 160 */ 1034, 1034, 120, 120, 121, 121, 121, 121, 1257, 1183,
- /* 170 */ 1184, 1185, 243, 1064, 564, 502, 499, 498, 567, 124,
- /* 180 */ 567, 1183, 1184, 1185, 474, 497, 119, 119, 119, 119,
- /* 190 */ 118, 118, 117, 117, 117, 116, 442, 70, 70, 407,
- /* 200 */ 121, 121, 121, 121, 114, 117, 117, 117, 116, 442,
- /* 210 */ 1409, 1469, 119, 119, 119, 119, 118, 118, 117, 117,
- /* 220 */ 117, 116, 442, 122, 123, 113, 1207, 1207, 1041, 1044,
- /* 230 */ 1034, 1034, 120, 120, 121, 121, 121, 121, 407, 1031,
- /* 240 */ 1031, 1042, 1045, 81, 382, 541, 378, 80, 119, 119,
- /* 250 */ 119, 119, 118, 118, 117, 117, 117, 116, 442, 381,
- /* 260 */ 463, 332, 122, 123, 113, 1207, 1207, 1041, 1044, 1034,
- /* 270 */ 1034, 120, 120, 121, 121, 121, 121, 262, 215, 512,
- /* 280 */ 1424, 422, 119, 119, 119, 119, 118, 118, 117, 117,
- /* 290 */ 117, 116, 442, 1231, 1, 1, 571, 2, 1235, 1573,
- /* 300 */ 571, 2, 1235, 307, 1149, 141, 1600, 307, 407, 141,
- /* 310 */ 1183, 361, 1317, 1035, 866, 531, 1317, 1149, 359, 1567,
- /* 320 */ 1149, 119, 119, 119, 119, 118, 118, 117, 117, 117,
- /* 330 */ 116, 442, 122, 123, 113, 1207, 1207, 1041, 1044, 1034,
- /* 340 */ 1034, 120, 120, 121, 121, 121, 121, 275, 275, 1001,
- /* 350 */ 426, 275, 275, 1128, 1627, 1021, 1627, 137, 542, 1541,
- /* 360 */ 561, 272, 950, 950, 561, 1423, 1183, 1184, 1185, 1594,
- /* 370 */ 866, 1012, 530, 315, 231, 1011, 468, 1276, 231, 119,
- /* 380 */ 119, 119, 119, 118, 118, 117, 117, 117, 116, 442,
- /* 390 */ 1570, 119, 119, 119, 119, 118, 118, 117, 117, 117,
- /* 400 */ 116, 442, 330, 359, 1567, 564, 446, 1011, 1011, 1013,
- /* 410 */ 446, 207, 564, 306, 555, 407, 363, 1021, 363, 346,
- /* 420 */ 184, 118, 118, 117, 117, 117, 116, 442, 71, 71,
- /* 430 */ 439, 438, 1126, 1012, 472, 71, 71, 1011, 205, 122,
- /* 440 */ 123, 113, 1207, 1207, 1041, 1044, 1034, 1034, 120, 120,
- /* 450 */ 121, 121, 121, 121, 219, 219, 472, 1183, 407, 570,
- /* 460 */ 1183, 1235, 503, 1477, 149, 546, 307, 489, 141, 1011,
- /* 470 */ 1011, 1013, 546, 140, 545, 1317, 1214, 191, 1214, 950,
- /* 480 */ 950, 514, 122, 123, 113, 1207, 1207, 1041, 1044, 1034,
- /* 490 */ 1034, 120, 120, 121, 121, 121, 121, 563, 119, 119,
- /* 500 */ 119, 119, 118, 118, 117, 117, 117, 116, 442, 283,
- /* 510 */ 275, 275, 415, 1183, 1184, 1185, 1183, 1184, 1185, 372,
- /* 520 */ 1183, 243, 344, 561, 502, 499, 498, 1539, 407, 1540,
- /* 530 */ 1183, 288, 870, 143, 497, 1549, 185, 231, 9, 6,
- /* 540 */ 253, 119, 119, 119, 119, 118, 118, 117, 117, 117,
- /* 550 */ 116, 442, 122, 123, 113, 1207, 1207, 1041, 1044, 1034,
- /* 560 */ 1034, 120, 120, 121, 121, 121, 121, 407, 137, 446,
- /* 570 */ 447, 863, 169, 1183, 397, 1204, 1183, 1184, 1185, 931,
- /* 580 */ 526, 1001, 98, 339, 564, 342, 1183, 1184, 1185, 306,
- /* 590 */ 555, 122, 123, 113, 1207, 1207, 1041, 1044, 1034, 1034,
- /* 600 */ 120, 120, 121, 121, 121, 121, 452, 71, 71, 275,
- /* 610 */ 275, 119, 119, 119, 119, 118, 118, 117, 117, 117,
- /* 620 */ 116, 442, 561, 417, 306, 555, 1183, 1307, 1307, 1183,
- /* 630 */ 1184, 1185, 1204, 1149, 330, 458, 318, 407, 363, 470,
- /* 640 */ 431, 1167, 32, 541, 527, 350, 1149, 1629, 393, 1149,
- /* 650 */ 119, 119, 119, 119, 118, 118, 117, 117, 117, 116,
- /* 660 */ 442, 122, 123, 113, 1207, 1207, 1041, 1044, 1034, 1034,
- /* 670 */ 120, 120, 121, 121, 121, 121, 407, 199, 472, 1183,
- /* 680 */ 1022, 472, 1183, 1184, 1185, 386, 151, 539, 1548, 277,
- /* 690 */ 400, 137, 6, 317, 5, 564, 562, 3, 920, 920,
- /* 700 */ 122, 123, 113, 1207, 1207, 1041, 1044, 1034, 1034, 120,
- /* 710 */ 120, 121, 121, 121, 121, 411, 505, 83, 71, 71,
- /* 720 */ 119, 119, 119, 119, 118, 118, 117, 117, 117, 116,
- /* 730 */ 442, 1183, 218, 428, 1183, 1183, 1184, 1185, 363, 261,
- /* 740 */ 278, 358, 508, 353, 507, 248, 407, 306, 555, 1539,
- /* 750 */ 1006, 349, 363, 291, 489, 302, 293, 1542, 281, 119,
- /* 760 */ 119, 119, 119, 118, 118, 117, 117, 117, 116, 442,
- /* 770 */ 122, 123, 113, 1207, 1207, 1041, 1044, 1034, 1034, 120,
- /* 780 */ 120, 121, 121, 121, 121, 407, 148, 1183, 1184, 1185,
- /* 790 */ 1183, 1184, 1185, 275, 275, 1304, 1257, 1283, 483, 1476,
- /* 800 */ 150, 489, 480, 564, 1187, 1304, 561, 1587, 1255, 122,
- /* 810 */ 123, 113, 1207, 1207, 1041, 1044, 1034, 1034, 120, 120,
- /* 820 */ 121, 121, 121, 121, 564, 886, 13, 13, 520, 119,
- /* 830 */ 119, 119, 119, 118, 118, 117, 117, 117, 116, 442,
- /* 840 */ 1183, 420, 417, 564, 269, 269, 1316, 13, 13, 1539,
- /* 850 */ 1546, 16, 16, 322, 6, 407, 506, 561, 1089, 1089,
- /* 860 */ 486, 1187, 425, 1539, 887, 292, 71, 71, 119, 119,
- /* 870 */ 119, 119, 118, 118, 117, 117, 117, 116, 442, 122,
- /* 880 */ 123, 113, 1207, 1207, 1041, 1044, 1034, 1034, 120, 120,
- /* 890 */ 121, 121, 121, 121, 564, 12, 1183, 1184, 1185, 407,
- /* 900 */ 275, 275, 451, 303, 834, 835, 836, 417, 489, 276,
- /* 910 */ 276, 1547, 284, 561, 319, 6, 321, 71, 71, 429,
- /* 920 */ 451, 450, 561, 952, 101, 113, 1207, 1207, 1041, 1044,
- /* 930 */ 1034, 1034, 120, 120, 121, 121, 121, 121, 119, 119,
- /* 940 */ 119, 119, 118, 118, 117, 117, 117, 116, 442, 1105,
- /* 950 */ 1183, 489, 564, 1312, 437, 455, 478, 564, 246, 245,
- /* 960 */ 244, 1409, 1545, 547, 1106, 405, 6, 1544, 196, 1258,
- /* 970 */ 413, 6, 105, 462, 103, 71, 71, 286, 564, 1107,
- /* 980 */ 13, 13, 119, 119, 119, 119, 118, 118, 117, 117,
- /* 990 */ 117, 116, 442, 451, 104, 427, 337, 320, 275, 275,
- /* 1000 */ 906, 13, 13, 564, 1482, 1105, 1183, 1184, 1185, 126,
- /* 1010 */ 907, 561, 546, 564, 407, 478, 295, 1321, 253, 200,
- /* 1020 */ 1106, 548, 1482, 1484, 280, 1409, 55, 55, 1287, 561,
- /* 1030 */ 478, 380, 423, 951, 407, 1107, 71, 71, 122, 123,
- /* 1040 */ 113, 1207, 1207, 1041, 1044, 1034, 1034, 120, 120, 121,
- /* 1050 */ 121, 121, 121, 1204, 407, 287, 552, 309, 122, 123,
- /* 1060 */ 113, 1207, 1207, 1041, 1044, 1034, 1034, 120, 120, 121,
- /* 1070 */ 121, 121, 121, 441, 1128, 1628, 146, 1628, 122, 111,
- /* 1080 */ 113, 1207, 1207, 1041, 1044, 1034, 1034, 120, 120, 121,
- /* 1090 */ 121, 121, 121, 404, 403, 1482, 424, 119, 119, 119,
- /* 1100 */ 119, 118, 118, 117, 117, 117, 116, 442, 1183, 564,
- /* 1110 */ 1204, 544, 1086, 858, 329, 361, 1086, 119, 119, 119,
- /* 1120 */ 119, 118, 118, 117, 117, 117, 116, 442, 564, 294,
- /* 1130 */ 144, 523, 56, 56, 224, 564, 510, 119, 119, 119,
- /* 1140 */ 119, 118, 118, 117, 117, 117, 116, 442, 484, 1409,
- /* 1150 */ 537, 15, 15, 1126, 434, 439, 438, 407, 13, 13,
- /* 1160 */ 1523, 12, 926, 1211, 1183, 1184, 1185, 925, 1213, 536,
- /* 1170 */ 858, 557, 413, 193, 1525, 494, 1212, 448, 1160, 1222,
- /* 1180 */ 1183, 564, 123, 113, 1207, 1207, 1041, 1044, 1034, 1034,
- /* 1190 */ 120, 120, 121, 121, 121, 121, 1521, 1149, 564, 965,
- /* 1200 */ 564, 1214, 247, 1214, 13, 13, 1409, 966, 538, 564,
- /* 1210 */ 1149, 108, 556, 1149, 4, 310, 392, 1227, 17, 194,
- /* 1220 */ 485, 43, 43, 57, 57, 306, 555, 524, 559, 1160,
- /* 1230 */ 464, 564, 44, 44, 392, 1127, 1183, 1184, 1185, 479,
- /* 1240 */ 119, 119, 119, 119, 118, 118, 117, 117, 117, 116,
- /* 1250 */ 442, 443, 564, 327, 13, 13, 564, 418, 1315, 414,
- /* 1260 */ 171, 564, 311, 553, 213, 529, 1253, 564, 517, 543,
- /* 1270 */ 412, 108, 556, 137, 4, 58, 58, 435, 314, 59,
- /* 1280 */ 59, 274, 217, 549, 60, 60, 349, 476, 559, 1353,
- /* 1290 */ 61, 61, 1021, 275, 275, 1228, 213, 564, 106, 106,
- /* 1300 */ 8, 275, 275, 275, 275, 107, 561, 443, 566, 565,
- /* 1310 */ 564, 443, 1011, 1228, 561, 564, 561, 564, 275, 275,
- /* 1320 */ 62, 62, 1352, 553, 247, 456, 564, 98, 110, 306,
- /* 1330 */ 555, 561, 564, 45, 45, 405, 1203, 533, 46, 46,
- /* 1340 */ 47, 47, 532, 465, 1011, 1011, 1013, 1014, 27, 49,
- /* 1350 */ 49, 564, 1021, 405, 469, 50, 50, 564, 106, 106,
- /* 1360 */ 305, 564, 84, 204, 405, 107, 564, 443, 566, 565,
- /* 1370 */ 405, 564, 1011, 564, 63, 63, 564, 1599, 564, 895,
- /* 1380 */ 64, 64, 457, 477, 65, 65, 147, 96, 38, 14,
- /* 1390 */ 14, 1528, 412, 564, 66, 66, 128, 128, 926, 67,
- /* 1400 */ 67, 52, 52, 925, 1011, 1011, 1013, 1014, 27, 1572,
- /* 1410 */ 1171, 445, 208, 1123, 279, 394, 68, 68, 228, 390,
- /* 1420 */ 390, 389, 264, 387, 1171, 445, 843, 877, 279, 108,
- /* 1430 */ 556, 453, 4, 390, 390, 389, 264, 387, 564, 225,
- /* 1440 */ 843, 313, 328, 1003, 98, 252, 559, 544, 471, 312,
- /* 1450 */ 252, 564, 208, 225, 564, 313, 473, 30, 252, 279,
- /* 1460 */ 466, 69, 69, 312, 390, 390, 389, 264, 387, 443,
- /* 1470 */ 333, 843, 98, 564, 53, 53, 323, 157, 157, 227,
- /* 1480 */ 495, 553, 249, 289, 225, 564, 313, 162, 31, 1501,
- /* 1490 */ 135, 564, 1500, 227, 312, 533, 158, 158, 885, 884,
- /* 1500 */ 534, 162, 873, 301, 135, 564, 481, 226, 76, 76,
- /* 1510 */ 1021, 347, 1071, 98, 54, 54, 106, 106, 1067, 564,
- /* 1520 */ 249, 226, 519, 107, 227, 443, 566, 565, 72, 72,
- /* 1530 */ 1011, 334, 162, 564, 230, 135, 108, 556, 959, 4,
- /* 1540 */ 252, 408, 129, 129, 564, 1349, 306, 555, 564, 923,
- /* 1550 */ 564, 110, 226, 559, 564, 408, 73, 73, 564, 873,
- /* 1560 */ 306, 555, 1011, 1011, 1013, 1014, 27, 130, 130, 1071,
- /* 1570 */ 449, 131, 131, 127, 127, 357, 443, 156, 156, 892,
- /* 1580 */ 893, 155, 155, 338, 449, 356, 408, 564, 553, 968,
- /* 1590 */ 969, 306, 555, 1015, 341, 564, 108, 556, 564, 4,
- /* 1600 */ 1132, 1286, 533, 564, 856, 343, 145, 532, 345, 1300,
- /* 1610 */ 136, 136, 1083, 559, 1083, 449, 564, 1021, 134, 134,
- /* 1620 */ 1284, 132, 132, 106, 106, 1285, 133, 133, 564, 352,
- /* 1630 */ 107, 564, 443, 566, 565, 1340, 443, 1011, 362, 75,
- /* 1640 */ 75, 1082, 564, 1082, 564, 924, 1561, 110, 553, 551,
- /* 1650 */ 1015, 77, 77, 1361, 74, 74, 1408, 1336, 1347, 550,
- /* 1660 */ 1414, 1265, 1256, 1244, 1243, 42, 42, 48, 48, 1011,
- /* 1670 */ 1011, 1013, 1014, 27, 1245, 1580, 490, 1021, 267, 202,
- /* 1680 */ 1333, 365, 11, 106, 106, 930, 367, 210, 369, 391,
- /* 1690 */ 107, 1395, 443, 566, 565, 223, 1390, 1011, 500, 454,
- /* 1700 */ 282, 1400, 285, 108, 556, 214, 4, 325, 1383, 1283,
- /* 1710 */ 475, 355, 1473, 1583, 1472, 1399, 371, 1222, 326, 398,
- /* 1720 */ 559, 290, 331, 197, 100, 556, 209, 4, 198, 1011,
- /* 1730 */ 1011, 1013, 1014, 27, 385, 256, 1520, 1518, 554, 1219,
- /* 1740 */ 416, 559, 83, 443, 173, 206, 182, 221, 459, 167,
- /* 1750 */ 177, 460, 175, 493, 233, 553, 79, 178, 1396, 179,
- /* 1760 */ 35, 180, 96, 1402, 443, 396, 36, 467, 1478, 1401,
- /* 1770 */ 482, 237, 1404, 399, 82, 186, 553, 1467, 89, 488,
- /* 1780 */ 190, 268, 239, 491, 1021, 340, 240, 401, 1246, 1489,
- /* 1790 */ 106, 106, 336, 509, 1294, 241, 1303, 107, 430, 443,
- /* 1800 */ 566, 565, 1302, 91, 1011, 1021, 1598, 1301, 1273, 215,
- /* 1810 */ 1597, 106, 106, 402, 877, 432, 354, 1272, 107, 1271,
- /* 1820 */ 443, 566, 565, 1596, 1566, 1011, 1293, 433, 518, 299,
- /* 1830 */ 300, 360, 95, 525, 1344, 364, 1011, 1011, 1013, 1014,
- /* 1840 */ 27, 254, 255, 1552, 436, 1551, 125, 544, 10, 379,
- /* 1850 */ 1326, 1453, 102, 97, 1345, 528, 304, 1011, 1011, 1013,
- /* 1860 */ 1014, 27, 366, 377, 1343, 1342, 368, 370, 1325, 384,
- /* 1870 */ 201, 383, 34, 1368, 1367, 568, 1177, 266, 263, 265,
- /* 1880 */ 1505, 159, 569, 1241, 1236, 1506, 160, 142, 1504, 1503,
- /* 1890 */ 297, 211, 830, 161, 212, 78, 444, 203, 308, 222,
- /* 1900 */ 1081, 139, 1079, 316, 174, 163, 1203, 229, 176, 909,
- /* 1910 */ 324, 232, 1095, 181, 409, 410, 172, 164, 165, 419,
- /* 1920 */ 183, 85, 86, 421, 166, 87, 88, 1098, 1094, 234,
- /* 1930 */ 235, 152, 18, 236, 335, 1087, 1216, 252, 187, 487,
- /* 1940 */ 238, 188, 37, 845, 492, 356, 242, 496, 351, 501,
- /* 1950 */ 189, 90, 19, 504, 348, 20, 875, 92, 298, 168,
- /* 1960 */ 888, 153, 93, 511, 94, 1165, 154, 1047, 1134, 39,
- /* 1970 */ 216, 1133, 271, 273, 958, 192, 953, 110, 1151, 1155,
- /* 1980 */ 251, 7, 21, 1159, 1139, 22, 1153, 33, 23, 24,
- /* 1990 */ 25, 540, 1158, 195, 98, 1062, 26, 1048, 1046, 1050,
- /* 2000 */ 1104, 1051, 1103, 257, 258, 28, 40, 1173, 1016, 857,
- /* 2010 */ 109, 29, 560, 388, 138, 1172, 259, 170, 260, 1232,
- /* 2020 */ 1232, 919, 1232, 1232, 1232, 1232, 1232, 1232, 1232, 1232,
- /* 2030 */ 1232, 1232, 1589, 1232, 1232, 1232, 1588,
+ /* 0 */ 566, 1307, 566, 1286, 201, 201, 566, 116, 112, 222,
+ /* 10 */ 566, 1307, 377, 566, 116, 112, 222, 397, 408, 409,
+ /* 20 */ 1260, 378, 1269, 41, 41, 41, 41, 1412, 1517, 71,
+ /* 30 */ 71, 967, 1258, 41, 41, 491, 71, 71, 272, 968,
+ /* 40 */ 298, 476, 298, 123, 124, 114, 1210, 1210, 1044, 1047,
+ /* 50 */ 1036, 1036, 121, 121, 122, 122, 122, 122, 543, 409,
+ /* 60 */ 1234, 1, 1, 573, 2, 1238, 548, 116, 112, 222,
+ /* 70 */ 309, 480, 142, 548, 1272, 524, 116, 112, 222, 1320,
+ /* 80 */ 417, 523, 547, 123, 124, 114, 1210, 1210, 1044, 1047,
+ /* 90 */ 1036, 1036, 121, 121, 122, 122, 122, 122, 424, 116,
+ /* 100 */ 112, 222, 120, 120, 120, 120, 119, 119, 118, 118,
+ /* 110 */ 118, 117, 113, 444, 277, 277, 277, 277, 560, 560,
+ /* 120 */ 560, 1558, 376, 1560, 1186, 375, 1157, 563, 1157, 563,
+ /* 130 */ 409, 1558, 537, 252, 219, 1553, 99, 141, 449, 6,
+ /* 140 */ 365, 233, 120, 120, 120, 120, 119, 119, 118, 118,
+ /* 150 */ 118, 117, 113, 444, 123, 124, 114, 1210, 1210, 1044,
+ /* 160 */ 1047, 1036, 1036, 121, 121, 122, 122, 122, 122, 138,
+ /* 170 */ 289, 1186, 1546, 448, 118, 118, 118, 117, 113, 444,
+ /* 180 */ 125, 1186, 1187, 1188, 144, 465, 334, 566, 150, 127,
+ /* 190 */ 444, 122, 122, 122, 122, 115, 120, 120, 120, 120,
+ /* 200 */ 119, 119, 118, 118, 118, 117, 113, 444, 454, 419,
+ /* 210 */ 13, 13, 215, 120, 120, 120, 120, 119, 119, 118,
+ /* 220 */ 118, 118, 117, 113, 444, 422, 308, 557, 1186, 1187,
+ /* 230 */ 1188, 441, 440, 409, 1271, 122, 122, 122, 122, 120,
+ /* 240 */ 120, 120, 120, 119, 119, 118, 118, 118, 117, 113,
+ /* 250 */ 444, 1543, 98, 1033, 1033, 1045, 1048, 123, 124, 114,
+ /* 260 */ 1210, 1210, 1044, 1047, 1036, 1036, 121, 121, 122, 122,
+ /* 270 */ 122, 122, 566, 406, 405, 1186, 566, 409, 1217, 319,
+ /* 280 */ 1217, 80, 81, 120, 120, 120, 120, 119, 119, 118,
+ /* 290 */ 118, 118, 117, 113, 444, 70, 70, 1186, 1604, 71,
+ /* 300 */ 71, 123, 124, 114, 1210, 1210, 1044, 1047, 1036, 1036,
+ /* 310 */ 121, 121, 122, 122, 122, 122, 120, 120, 120, 120,
+ /* 320 */ 119, 119, 118, 118, 118, 117, 113, 444, 1037, 210,
+ /* 330 */ 1186, 365, 1186, 1187, 1188, 245, 548, 399, 504, 501,
+ /* 340 */ 500, 108, 558, 138, 4, 516, 933, 433, 499, 217,
+ /* 350 */ 514, 522, 352, 879, 1186, 1187, 1188, 383, 561, 566,
+ /* 360 */ 120, 120, 120, 120, 119, 119, 118, 118, 118, 117,
+ /* 370 */ 113, 444, 277, 277, 16, 16, 1598, 441, 440, 153,
+ /* 380 */ 409, 445, 13, 13, 1279, 563, 1214, 1186, 1187, 1188,
+ /* 390 */ 1003, 1216, 264, 555, 1574, 186, 566, 427, 138, 1215,
+ /* 400 */ 308, 557, 472, 138, 123, 124, 114, 1210, 1210, 1044,
+ /* 410 */ 1047, 1036, 1036, 121, 121, 122, 122, 122, 122, 55,
+ /* 420 */ 55, 413, 1023, 507, 1217, 1186, 1217, 474, 106, 106,
+ /* 430 */ 1312, 1312, 1186, 171, 566, 384, 107, 380, 445, 568,
+ /* 440 */ 567, 430, 1543, 1013, 332, 549, 565, 263, 280, 360,
+ /* 450 */ 510, 355, 509, 250, 491, 308, 557, 71, 71, 351,
+ /* 460 */ 308, 557, 374, 120, 120, 120, 120, 119, 119, 118,
+ /* 470 */ 118, 118, 117, 113, 444, 1013, 1013, 1015, 1016, 27,
+ /* 480 */ 277, 277, 1186, 1187, 1188, 1152, 566, 528, 409, 1186,
+ /* 490 */ 1187, 1188, 348, 563, 548, 1260, 533, 517, 1152, 1516,
+ /* 500 */ 317, 1152, 285, 550, 485, 569, 566, 569, 482, 51,
+ /* 510 */ 51, 207, 123, 124, 114, 1210, 1210, 1044, 1047, 1036,
+ /* 520 */ 1036, 121, 121, 122, 122, 122, 122, 171, 1412, 13,
+ /* 530 */ 13, 409, 277, 277, 1186, 505, 119, 119, 118, 118,
+ /* 540 */ 118, 117, 113, 444, 429, 563, 518, 220, 515, 1552,
+ /* 550 */ 365, 546, 1186, 6, 532, 123, 124, 114, 1210, 1210,
+ /* 560 */ 1044, 1047, 1036, 1036, 121, 121, 122, 122, 122, 122,
+ /* 570 */ 145, 120, 120, 120, 120, 119, 119, 118, 118, 118,
+ /* 580 */ 117, 113, 444, 245, 566, 474, 504, 501, 500, 566,
+ /* 590 */ 1481, 1186, 1187, 1188, 1310, 1310, 499, 1186, 149, 425,
+ /* 600 */ 1186, 480, 409, 274, 365, 952, 872, 56, 56, 1186,
+ /* 610 */ 1187, 1188, 71, 71, 120, 120, 120, 120, 119, 119,
+ /* 620 */ 118, 118, 118, 117, 113, 444, 123, 124, 114, 1210,
+ /* 630 */ 1210, 1044, 1047, 1036, 1036, 121, 121, 122, 122, 122,
+ /* 640 */ 122, 409, 541, 1552, 83, 865, 98, 6, 928, 529,
+ /* 650 */ 848, 543, 151, 927, 1186, 1187, 1188, 1186, 1187, 1188,
+ /* 660 */ 290, 1543, 187, 1633, 395, 123, 124, 114, 1210, 1210,
+ /* 670 */ 1044, 1047, 1036, 1036, 121, 121, 122, 122, 122, 122,
+ /* 680 */ 566, 954, 566, 453, 953, 120, 120, 120, 120, 119,
+ /* 690 */ 119, 118, 118, 118, 117, 113, 444, 1152, 221, 1186,
+ /* 700 */ 331, 453, 452, 13, 13, 13, 13, 1003, 365, 463,
+ /* 710 */ 1152, 193, 409, 1152, 382, 1543, 1170, 32, 297, 474,
+ /* 720 */ 195, 1527, 5, 952, 120, 120, 120, 120, 119, 119,
+ /* 730 */ 118, 118, 118, 117, 113, 444, 123, 124, 114, 1210,
+ /* 740 */ 1210, 1044, 1047, 1036, 1036, 121, 121, 122, 122, 122,
+ /* 750 */ 122, 409, 1067, 419, 1186, 1024, 1186, 1187, 1188, 1186,
+ /* 760 */ 419, 332, 460, 320, 544, 1545, 442, 442, 442, 566,
+ /* 770 */ 3, 117, 113, 444, 453, 123, 124, 114, 1210, 1210,
+ /* 780 */ 1044, 1047, 1036, 1036, 121, 121, 122, 122, 122, 122,
+ /* 790 */ 1473, 566, 15, 15, 293, 120, 120, 120, 120, 119,
+ /* 800 */ 119, 118, 118, 118, 117, 113, 444, 1186, 566, 1486,
+ /* 810 */ 1412, 1186, 1187, 1188, 13, 13, 1186, 1187, 1188, 1544,
+ /* 820 */ 271, 271, 409, 286, 308, 557, 1008, 1486, 1488, 196,
+ /* 830 */ 288, 71, 71, 563, 120, 120, 120, 120, 119, 119,
+ /* 840 */ 118, 118, 118, 117, 113, 444, 123, 124, 114, 1210,
+ /* 850 */ 1210, 1044, 1047, 1036, 1036, 121, 121, 122, 122, 122,
+ /* 860 */ 122, 409, 201, 1087, 1186, 1187, 1188, 1324, 304, 1529,
+ /* 870 */ 388, 278, 278, 450, 564, 402, 922, 922, 566, 563,
+ /* 880 */ 566, 426, 491, 480, 563, 123, 124, 114, 1210, 1210,
+ /* 890 */ 1044, 1047, 1036, 1036, 121, 121, 122, 122, 122, 122,
+ /* 900 */ 1486, 71, 71, 13, 13, 120, 120, 120, 120, 119,
+ /* 910 */ 119, 118, 118, 118, 117, 113, 444, 566, 545, 566,
+ /* 920 */ 1577, 573, 2, 1238, 1092, 1092, 488, 1480, 309, 1525,
+ /* 930 */ 142, 324, 409, 836, 837, 838, 312, 1320, 305, 363,
+ /* 940 */ 43, 43, 57, 57, 120, 120, 120, 120, 119, 119,
+ /* 950 */ 118, 118, 118, 117, 113, 444, 123, 124, 114, 1210,
+ /* 960 */ 1210, 1044, 1047, 1036, 1036, 121, 121, 122, 122, 122,
+ /* 970 */ 122, 12, 277, 277, 566, 1152, 409, 572, 428, 1238,
+ /* 980 */ 465, 334, 296, 474, 309, 563, 142, 249, 1152, 308,
+ /* 990 */ 557, 1152, 321, 1320, 323, 491, 455, 71, 71, 233,
+ /* 1000 */ 283, 101, 114, 1210, 1210, 1044, 1047, 1036, 1036, 121,
+ /* 1010 */ 121, 122, 122, 122, 122, 120, 120, 120, 120, 119,
+ /* 1020 */ 119, 118, 118, 118, 117, 113, 444, 1108, 277, 277,
+ /* 1030 */ 1412, 448, 394, 1230, 439, 277, 277, 248, 247, 246,
+ /* 1040 */ 1319, 563, 1109, 313, 198, 294, 491, 1318, 563, 464,
+ /* 1050 */ 566, 1427, 394, 1130, 1023, 233, 414, 1110, 295, 120,
+ /* 1060 */ 120, 120, 120, 119, 119, 118, 118, 118, 117, 113,
+ /* 1070 */ 444, 1014, 104, 71, 71, 1013, 322, 496, 908, 566,
+ /* 1080 */ 277, 277, 277, 277, 1108, 1261, 415, 448, 909, 361,
+ /* 1090 */ 1571, 1315, 409, 563, 952, 563, 9, 202, 255, 1109,
+ /* 1100 */ 316, 487, 44, 44, 249, 559, 415, 1013, 1013, 1015,
+ /* 1110 */ 443, 1231, 409, 1603, 1110, 897, 123, 124, 114, 1210,
+ /* 1120 */ 1210, 1044, 1047, 1036, 1036, 121, 121, 122, 122, 122,
+ /* 1130 */ 122, 1231, 409, 1207, 215, 554, 123, 124, 114, 1210,
+ /* 1140 */ 1210, 1044, 1047, 1036, 1036, 121, 121, 122, 122, 122,
+ /* 1150 */ 122, 1131, 1631, 470, 1631, 255, 123, 111, 114, 1210,
+ /* 1160 */ 1210, 1044, 1047, 1036, 1036, 121, 121, 122, 122, 122,
+ /* 1170 */ 122, 1131, 1632, 414, 1632, 120, 120, 120, 120, 119,
+ /* 1180 */ 119, 118, 118, 118, 117, 113, 444, 221, 209, 351,
+ /* 1190 */ 1207, 1207, 147, 1426, 491, 120, 120, 120, 120, 119,
+ /* 1200 */ 119, 118, 118, 118, 117, 113, 444, 1256, 539, 519,
+ /* 1210 */ 888, 551, 952, 12, 566, 120, 120, 120, 120, 119,
+ /* 1220 */ 119, 118, 118, 118, 117, 113, 444, 538, 566, 860,
+ /* 1230 */ 1129, 361, 1571, 346, 1356, 409, 1163, 58, 58, 339,
+ /* 1240 */ 1355, 508, 277, 277, 277, 277, 277, 277, 1207, 889,
+ /* 1250 */ 1129, 59, 59, 459, 363, 563, 566, 563, 96, 563,
+ /* 1260 */ 124, 114, 1210, 1210, 1044, 1047, 1036, 1036, 121, 121,
+ /* 1270 */ 122, 122, 122, 122, 566, 1412, 566, 281, 1186, 60,
+ /* 1280 */ 60, 110, 392, 392, 391, 266, 389, 860, 1163, 845,
+ /* 1290 */ 566, 481, 566, 436, 341, 1152, 344, 61, 61, 62,
+ /* 1300 */ 62, 967, 227, 1550, 315, 431, 540, 6, 1152, 968,
+ /* 1310 */ 566, 1152, 314, 45, 45, 46, 46, 512, 120, 120,
+ /* 1320 */ 120, 120, 119, 119, 118, 118, 118, 117, 113, 444,
+ /* 1330 */ 416, 173, 1532, 47, 47, 1186, 1187, 1188, 108, 558,
+ /* 1340 */ 325, 4, 229, 1551, 928, 566, 437, 6, 566, 927,
+ /* 1350 */ 164, 566, 1290, 137, 1190, 561, 566, 1549, 566, 1089,
+ /* 1360 */ 566, 6, 566, 1089, 531, 566, 868, 8, 49, 49,
+ /* 1370 */ 228, 50, 50, 566, 63, 63, 566, 457, 445, 64,
+ /* 1380 */ 64, 65, 65, 14, 14, 66, 66, 407, 129, 129,
+ /* 1390 */ 555, 566, 458, 566, 1505, 486, 67, 67, 566, 52,
+ /* 1400 */ 52, 546, 407, 467, 535, 410, 226, 1023, 566, 534,
+ /* 1410 */ 308, 557, 1190, 407, 68, 68, 69, 69, 566, 1023,
+ /* 1420 */ 566, 53, 53, 868, 1014, 106, 106, 525, 1013, 566,
+ /* 1430 */ 1504, 159, 159, 107, 451, 445, 568, 567, 471, 307,
+ /* 1440 */ 1013, 160, 160, 76, 76, 566, 1548, 466, 407, 407,
+ /* 1450 */ 6, 1225, 54, 54, 478, 276, 219, 566, 887, 886,
+ /* 1460 */ 1013, 1013, 1015, 84, 206, 1206, 230, 282, 72, 72,
+ /* 1470 */ 329, 483, 1013, 1013, 1015, 1016, 27, 1576, 1174, 447,
+ /* 1480 */ 130, 130, 281, 148, 105, 38, 103, 392, 392, 391,
+ /* 1490 */ 266, 389, 566, 1126, 845, 396, 566, 108, 558, 566,
+ /* 1500 */ 4, 311, 566, 30, 17, 566, 279, 227, 566, 315,
+ /* 1510 */ 108, 558, 468, 4, 561, 73, 73, 314, 566, 157,
+ /* 1520 */ 157, 566, 131, 131, 526, 132, 132, 561, 128, 128,
+ /* 1530 */ 566, 158, 158, 566, 31, 291, 566, 445, 330, 521,
+ /* 1540 */ 98, 152, 152, 420, 136, 136, 1005, 229, 254, 555,
+ /* 1550 */ 445, 479, 336, 135, 135, 164, 133, 133, 137, 134,
+ /* 1560 */ 134, 875, 555, 535, 566, 473, 566, 254, 536, 475,
+ /* 1570 */ 335, 254, 98, 894, 895, 228, 535, 566, 1023, 566,
+ /* 1580 */ 1074, 534, 210, 232, 106, 106, 1352, 75, 75, 77,
+ /* 1590 */ 77, 1023, 107, 340, 445, 568, 567, 106, 106, 1013,
+ /* 1600 */ 74, 74, 42, 42, 566, 107, 343, 445, 568, 567,
+ /* 1610 */ 410, 497, 1013, 251, 359, 308, 557, 1135, 349, 875,
+ /* 1620 */ 98, 1070, 345, 251, 358, 1591, 347, 48, 48, 1017,
+ /* 1630 */ 1303, 1013, 1013, 1015, 1016, 27, 1289, 1287, 1074, 451,
+ /* 1640 */ 961, 925, 254, 110, 1013, 1013, 1015, 1016, 27, 1174,
+ /* 1650 */ 447, 970, 971, 281, 108, 558, 1288, 4, 392, 392,
+ /* 1660 */ 391, 266, 389, 1343, 1086, 845, 1086, 1085, 858, 1085,
+ /* 1670 */ 146, 561, 926, 354, 110, 303, 364, 553, 227, 1364,
+ /* 1680 */ 315, 108, 558, 1411, 4, 1339, 492, 1017, 314, 1350,
+ /* 1690 */ 1565, 552, 1417, 1268, 445, 204, 1259, 1247, 561, 1246,
+ /* 1700 */ 1248, 1584, 269, 1336, 367, 369, 555, 371, 11, 212,
+ /* 1710 */ 393, 225, 1393, 284, 1398, 456, 287, 327, 229, 328,
+ /* 1720 */ 292, 445, 1386, 216, 333, 1403, 164, 477, 373, 137,
+ /* 1730 */ 1402, 400, 502, 555, 1286, 1023, 357, 1477, 199, 1587,
+ /* 1740 */ 211, 106, 106, 932, 1476, 1225, 228, 556, 175, 107,
+ /* 1750 */ 200, 445, 568, 567, 258, 387, 1013, 1524, 1522, 223,
+ /* 1760 */ 1222, 418, 1023, 83, 208, 79, 82, 184, 106, 106,
+ /* 1770 */ 1482, 169, 177, 461, 179, 462, 107, 1399, 445, 568,
+ /* 1780 */ 567, 410, 180, 1013, 495, 181, 308, 557, 1013, 1013,
+ /* 1790 */ 1015, 1016, 27, 182, 35, 235, 100, 558, 398, 4,
+ /* 1800 */ 96, 1405, 1404, 36, 484, 469, 1407, 188, 401, 1471,
+ /* 1810 */ 451, 89, 1493, 561, 239, 1013, 1013, 1015, 1016, 27,
+ /* 1820 */ 490, 338, 270, 241, 192, 342, 493, 242, 403, 1249,
+ /* 1830 */ 243, 511, 432, 1297, 1306, 91, 445, 1305, 1304, 879,
+ /* 1840 */ 217, 434, 435, 1570, 1276, 1602, 520, 1601, 555, 301,
+ /* 1850 */ 527, 404, 1275, 302, 356, 1274, 1600, 95, 1347, 366,
+ /* 1860 */ 1296, 362, 1348, 368, 256, 257, 1556, 1555, 438, 1346,
+ /* 1870 */ 370, 126, 1345, 10, 1371, 546, 381, 1023, 102, 1457,
+ /* 1880 */ 97, 530, 34, 106, 106, 570, 1180, 372, 265, 1329,
+ /* 1890 */ 379, 107, 203, 445, 568, 567, 1328, 385, 1013, 1370,
+ /* 1900 */ 386, 267, 268, 571, 1244, 161, 1239, 162, 1509, 1510,
+ /* 1910 */ 1508, 143, 1507, 299, 832, 213, 214, 78, 446, 205,
+ /* 1920 */ 310, 306, 163, 224, 1084, 140, 1082, 318, 165, 176,
+ /* 1930 */ 1013, 1013, 1015, 1016, 27, 178, 1206, 231, 911, 234,
+ /* 1940 */ 326, 1098, 183, 421, 166, 167, 411, 185, 85, 423,
+ /* 1950 */ 412, 86, 174, 87, 168, 88, 1101, 236, 1097, 237,
+ /* 1960 */ 154, 18, 238, 254, 337, 1219, 489, 1090, 240, 190,
+ /* 1970 */ 37, 847, 189, 494, 358, 244, 350, 506, 191, 877,
+ /* 1980 */ 90, 498, 19, 20, 503, 92, 353, 890, 300, 170,
+ /* 1990 */ 155, 93, 513, 94, 1168, 156, 1050, 1137, 39, 218,
+ /* 2000 */ 273, 275, 1136, 960, 194, 955, 110, 1154, 1158, 253,
+ /* 2010 */ 7, 1162, 1156, 21, 22, 1161, 1142, 23, 24, 25,
+ /* 2020 */ 33, 542, 26, 260, 197, 98, 1065, 1051, 1049, 1053,
+ /* 2030 */ 1107, 1054, 1106, 259, 28, 40, 562, 1018, 859, 109,
+ /* 2040 */ 29, 921, 390, 1176, 172, 139, 1175, 1235, 261, 1235,
+ /* 2050 */ 1235, 1235, 1235, 1235, 1235, 1235, 1235, 262, 1235, 1235,
+ /* 2060 */ 1235, 1235, 1235, 1235, 1235, 1235, 1235, 1235, 1593, 1592,
};
static const YYCODETYPE yy_lookahead[] = {
- /* 0 */ 192, 273, 274, 275, 192, 192, 273, 274, 275, 192,
- /* 10 */ 218, 215, 192, 218, 192, 212, 234, 235, 205, 19,
- /* 20 */ 11, 192, 294, 215, 216, 203, 192, 203, 209, 210,
- /* 30 */ 211, 31, 215, 216, 205, 215, 216, 215, 216, 39,
- /* 40 */ 227, 215, 229, 43, 44, 45, 46, 47, 48, 49,
- /* 50 */ 50, 51, 52, 53, 54, 55, 56, 57, 192, 19,
- /* 60 */ 238, 239, 238, 239, 215, 273, 274, 275, 273, 274,
- /* 70 */ 275, 237, 21, 251, 252, 251, 273, 274, 275, 255,
- /* 80 */ 256, 215, 216, 43, 44, 45, 46, 47, 48, 49,
- /* 90 */ 50, 51, 52, 53, 54, 55, 56, 57, 209, 210,
- /* 100 */ 211, 76, 102, 103, 104, 105, 106, 107, 108, 109,
- /* 110 */ 110, 111, 112, 59, 89, 111, 112, 92, 252, 307,
- /* 120 */ 308, 313, 314, 112, 312, 59, 86, 261, 88, 19,
- /* 130 */ 313, 80, 315, 313, 314, 25, 127, 128, 54, 55,
- /* 140 */ 56, 57, 102, 103, 104, 105, 106, 107, 108, 109,
- /* 150 */ 110, 111, 112, 43, 44, 45, 46, 47, 48, 49,
- /* 160 */ 50, 51, 52, 53, 54, 55, 56, 57, 192, 115,
- /* 170 */ 116, 117, 118, 122, 192, 121, 122, 123, 202, 69,
- /* 180 */ 204, 115, 116, 117, 192, 131, 102, 103, 104, 105,
- /* 190 */ 106, 107, 108, 109, 110, 111, 112, 215, 216, 19,
- /* 200 */ 54, 55, 56, 57, 58, 108, 109, 110, 111, 112,
- /* 210 */ 192, 160, 102, 103, 104, 105, 106, 107, 108, 109,
- /* 220 */ 110, 111, 112, 43, 44, 45, 46, 47, 48, 49,
- /* 230 */ 50, 51, 52, 53, 54, 55, 56, 57, 19, 46,
- /* 240 */ 47, 48, 49, 24, 248, 192, 250, 67, 102, 103,
- /* 250 */ 104, 105, 106, 107, 108, 109, 110, 111, 112, 277,
- /* 260 */ 127, 128, 43, 44, 45, 46, 47, 48, 49, 50,
- /* 270 */ 51, 52, 53, 54, 55, 56, 57, 26, 164, 165,
- /* 280 */ 272, 263, 102, 103, 104, 105, 106, 107, 108, 109,
- /* 290 */ 110, 111, 112, 184, 185, 186, 187, 188, 189, 186,
- /* 300 */ 187, 188, 189, 194, 76, 196, 229, 194, 19, 196,
- /* 310 */ 59, 192, 203, 120, 59, 87, 203, 89, 310, 311,
- /* 320 */ 92, 102, 103, 104, 105, 106, 107, 108, 109, 110,
- /* 330 */ 111, 112, 43, 44, 45, 46, 47, 48, 49, 50,
- /* 340 */ 51, 52, 53, 54, 55, 56, 57, 238, 239, 73,
- /* 350 */ 231, 238, 239, 22, 23, 100, 25, 81, 305, 306,
- /* 360 */ 251, 23, 25, 25, 251, 272, 115, 116, 117, 214,
- /* 370 */ 115, 116, 144, 192, 265, 120, 114, 222, 265, 102,
- /* 380 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
- /* 390 */ 192, 102, 103, 104, 105, 106, 107, 108, 109, 110,
- /* 400 */ 111, 112, 126, 310, 311, 192, 297, 152, 153, 154,
- /* 410 */ 297, 149, 192, 137, 138, 19, 192, 100, 192, 23,
- /* 420 */ 22, 106, 107, 108, 109, 110, 111, 112, 215, 216,
- /* 430 */ 106, 107, 101, 116, 192, 215, 216, 120, 149, 43,
- /* 440 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
- /* 450 */ 54, 55, 56, 57, 117, 117, 192, 59, 19, 187,
- /* 460 */ 59, 189, 23, 282, 240, 252, 194, 192, 196, 152,
- /* 470 */ 153, 154, 252, 72, 261, 203, 152, 25, 154, 142,
- /* 480 */ 142, 261, 43, 44, 45, 46, 47, 48, 49, 50,
- /* 490 */ 51, 52, 53, 54, 55, 56, 57, 192, 102, 103,
- /* 500 */ 104, 105, 106, 107, 108, 109, 110, 111, 112, 267,
- /* 510 */ 238, 239, 237, 115, 116, 117, 115, 116, 117, 192,
- /* 520 */ 59, 118, 16, 251, 121, 122, 123, 303, 19, 303,
- /* 530 */ 59, 267, 23, 72, 131, 308, 22, 265, 22, 312,
- /* 540 */ 24, 102, 103, 104, 105, 106, 107, 108, 109, 110,
- /* 550 */ 111, 112, 43, 44, 45, 46, 47, 48, 49, 50,
- /* 560 */ 51, 52, 53, 54, 55, 56, 57, 19, 81, 297,
- /* 570 */ 295, 23, 192, 59, 203, 59, 115, 116, 117, 108,
- /* 580 */ 192, 73, 25, 77, 192, 79, 115, 116, 117, 137,
- /* 590 */ 138, 43, 44, 45, 46, 47, 48, 49, 50, 51,
- /* 600 */ 52, 53, 54, 55, 56, 57, 119, 215, 216, 238,
- /* 610 */ 239, 102, 103, 104, 105, 106, 107, 108, 109, 110,
- /* 620 */ 111, 112, 251, 192, 137, 138, 59, 234, 235, 115,
- /* 630 */ 116, 117, 116, 76, 126, 127, 128, 19, 192, 268,
- /* 640 */ 19, 23, 22, 192, 252, 24, 89, 300, 301, 92,
- /* 650 */ 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
- /* 660 */ 112, 43, 44, 45, 46, 47, 48, 49, 50, 51,
- /* 670 */ 52, 53, 54, 55, 56, 57, 19, 192, 192, 59,
- /* 680 */ 23, 192, 115, 116, 117, 200, 240, 307, 308, 22,
- /* 690 */ 205, 81, 312, 262, 22, 192, 133, 22, 135, 136,
- /* 700 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
- /* 710 */ 53, 54, 55, 56, 57, 197, 95, 150, 215, 216,
- /* 720 */ 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
- /* 730 */ 112, 59, 192, 112, 59, 115, 116, 117, 192, 118,
- /* 740 */ 119, 120, 121, 122, 123, 124, 19, 137, 138, 303,
- /* 750 */ 23, 130, 192, 267, 192, 252, 267, 306, 203, 102,
- /* 760 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
- /* 770 */ 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
- /* 780 */ 53, 54, 55, 56, 57, 19, 240, 115, 116, 117,
- /* 790 */ 115, 116, 117, 238, 239, 222, 192, 224, 280, 237,
- /* 800 */ 240, 192, 284, 192, 59, 232, 251, 140, 204, 43,
- /* 810 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
- /* 820 */ 54, 55, 56, 57, 192, 35, 215, 216, 192, 102,
- /* 830 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
- /* 840 */ 59, 230, 192, 192, 238, 239, 237, 215, 216, 303,
- /* 850 */ 308, 215, 216, 16, 312, 19, 66, 251, 126, 127,
- /* 860 */ 128, 116, 230, 303, 74, 203, 215, 216, 102, 103,
- /* 870 */ 104, 105, 106, 107, 108, 109, 110, 111, 112, 43,
- /* 880 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
- /* 890 */ 54, 55, 56, 57, 192, 212, 115, 116, 117, 19,
- /* 900 */ 238, 239, 192, 252, 7, 8, 9, 192, 192, 238,
- /* 910 */ 239, 308, 262, 251, 77, 312, 79, 215, 216, 129,
- /* 920 */ 210, 211, 251, 142, 158, 45, 46, 47, 48, 49,
- /* 930 */ 50, 51, 52, 53, 54, 55, 56, 57, 102, 103,
- /* 940 */ 104, 105, 106, 107, 108, 109, 110, 111, 112, 12,
- /* 950 */ 59, 192, 192, 237, 252, 243, 192, 192, 126, 127,
- /* 960 */ 128, 192, 308, 203, 27, 253, 312, 308, 285, 207,
- /* 970 */ 208, 312, 157, 290, 159, 215, 216, 262, 192, 42,
- /* 980 */ 215, 216, 102, 103, 104, 105, 106, 107, 108, 109,
- /* 990 */ 110, 111, 112, 283, 158, 230, 237, 160, 238, 239,
- /* 1000 */ 63, 215, 216, 192, 192, 12, 115, 116, 117, 22,
- /* 1010 */ 73, 251, 252, 192, 19, 192, 230, 239, 24, 24,
- /* 1020 */ 27, 261, 210, 211, 99, 192, 215, 216, 225, 251,
- /* 1030 */ 192, 192, 263, 142, 19, 42, 215, 216, 43, 44,
- /* 1040 */ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
- /* 1050 */ 55, 56, 57, 59, 19, 291, 63, 132, 43, 44,
- /* 1060 */ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
- /* 1070 */ 55, 56, 57, 252, 22, 23, 22, 25, 43, 44,
- /* 1080 */ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
- /* 1090 */ 55, 56, 57, 106, 107, 283, 263, 102, 103, 104,
- /* 1100 */ 105, 106, 107, 108, 109, 110, 111, 112, 59, 192,
- /* 1110 */ 116, 144, 29, 59, 291, 192, 33, 102, 103, 104,
- /* 1120 */ 105, 106, 107, 108, 109, 110, 111, 112, 192, 291,
- /* 1130 */ 163, 19, 215, 216, 15, 192, 108, 102, 103, 104,
- /* 1140 */ 105, 106, 107, 108, 109, 110, 111, 112, 65, 192,
- /* 1150 */ 66, 215, 216, 101, 231, 106, 107, 19, 215, 216,
- /* 1160 */ 192, 212, 134, 114, 115, 116, 117, 139, 119, 85,
- /* 1170 */ 116, 207, 208, 230, 192, 19, 127, 192, 94, 60,
- /* 1180 */ 59, 192, 44, 45, 46, 47, 48, 49, 50, 51,
- /* 1190 */ 52, 53, 54, 55, 56, 57, 192, 76, 192, 31,
- /* 1200 */ 192, 152, 46, 154, 215, 216, 192, 39, 87, 192,
- /* 1210 */ 89, 19, 20, 92, 22, 192, 22, 23, 22, 230,
- /* 1220 */ 263, 215, 216, 215, 216, 137, 138, 115, 36, 145,
- /* 1230 */ 128, 192, 215, 216, 22, 23, 115, 116, 117, 290,
- /* 1240 */ 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
- /* 1250 */ 112, 59, 192, 151, 215, 216, 192, 61, 203, 298,
- /* 1260 */ 299, 192, 192, 71, 25, 144, 203, 192, 203, 230,
- /* 1270 */ 114, 19, 20, 81, 22, 215, 216, 263, 192, 215,
- /* 1280 */ 216, 255, 256, 203, 215, 216, 130, 19, 36, 192,
- /* 1290 */ 215, 216, 100, 238, 239, 101, 25, 192, 106, 107,
- /* 1300 */ 48, 238, 239, 238, 239, 113, 251, 115, 116, 117,
- /* 1310 */ 192, 59, 120, 101, 251, 192, 251, 192, 238, 239,
- /* 1320 */ 215, 216, 192, 71, 46, 243, 192, 25, 25, 137,
- /* 1330 */ 138, 251, 192, 215, 216, 253, 25, 85, 215, 216,
- /* 1340 */ 215, 216, 90, 243, 152, 153, 154, 155, 156, 215,
- /* 1350 */ 216, 192, 100, 253, 243, 215, 216, 192, 106, 107,
- /* 1360 */ 243, 192, 148, 149, 253, 113, 192, 115, 116, 117,
- /* 1370 */ 253, 192, 120, 192, 215, 216, 192, 23, 192, 25,
- /* 1380 */ 215, 216, 192, 115, 215, 216, 22, 148, 24, 215,
- /* 1390 */ 216, 192, 114, 192, 215, 216, 215, 216, 134, 215,
- /* 1400 */ 216, 215, 216, 139, 152, 153, 154, 155, 156, 0,
- /* 1410 */ 1, 2, 141, 23, 5, 25, 215, 216, 24, 10,
- /* 1420 */ 11, 12, 13, 14, 1, 2, 17, 125, 5, 19,
- /* 1430 */ 20, 268, 22, 10, 11, 12, 13, 14, 192, 30,
- /* 1440 */ 17, 32, 23, 23, 25, 25, 36, 144, 23, 40,
- /* 1450 */ 25, 192, 141, 30, 192, 32, 23, 22, 25, 5,
- /* 1460 */ 128, 215, 216, 40, 10, 11, 12, 13, 14, 59,
- /* 1470 */ 23, 17, 25, 192, 215, 216, 192, 215, 216, 70,
- /* 1480 */ 23, 71, 25, 151, 30, 192, 32, 78, 53, 192,
- /* 1490 */ 81, 192, 192, 70, 40, 85, 215, 216, 119, 120,
- /* 1500 */ 90, 78, 59, 254, 81, 192, 192, 98, 215, 216,
- /* 1510 */ 100, 23, 59, 25, 215, 216, 106, 107, 23, 192,
- /* 1520 */ 25, 98, 19, 113, 70, 115, 116, 117, 215, 216,
- /* 1530 */ 120, 192, 78, 192, 140, 81, 19, 20, 23, 22,
- /* 1540 */ 25, 132, 215, 216, 192, 192, 137, 138, 192, 23,
- /* 1550 */ 192, 25, 98, 36, 192, 132, 215, 216, 192, 116,
- /* 1560 */ 137, 138, 152, 153, 154, 155, 156, 215, 216, 116,
- /* 1570 */ 161, 215, 216, 215, 216, 120, 59, 215, 216, 7,
- /* 1580 */ 8, 215, 216, 192, 161, 130, 132, 192, 71, 83,
- /* 1590 */ 84, 137, 138, 59, 192, 192, 19, 20, 192, 22,
- /* 1600 */ 97, 225, 85, 192, 23, 192, 25, 90, 192, 192,
- /* 1610 */ 215, 216, 152, 36, 154, 161, 192, 100, 215, 216,
- /* 1620 */ 192, 215, 216, 106, 107, 225, 215, 216, 192, 192,
- /* 1630 */ 113, 192, 115, 116, 117, 257, 59, 120, 192, 215,
- /* 1640 */ 216, 152, 192, 154, 192, 23, 317, 25, 71, 235,
- /* 1650 */ 116, 215, 216, 192, 215, 216, 192, 192, 192, 192,
- /* 1660 */ 192, 192, 192, 192, 192, 215, 216, 215, 216, 152,
- /* 1670 */ 153, 154, 155, 156, 192, 192, 287, 100, 286, 241,
- /* 1680 */ 254, 254, 242, 106, 107, 108, 254, 213, 254, 190,
- /* 1690 */ 113, 270, 115, 116, 117, 296, 266, 120, 219, 258,
- /* 1700 */ 244, 270, 258, 19, 20, 228, 22, 292, 266, 224,
- /* 1710 */ 292, 218, 218, 195, 218, 270, 258, 60, 245, 270,
- /* 1720 */ 36, 245, 244, 248, 19, 20, 242, 22, 248, 152,
- /* 1730 */ 153, 154, 155, 156, 244, 140, 199, 199, 279, 38,
- /* 1740 */ 199, 36, 150, 59, 296, 149, 22, 296, 18, 43,
- /* 1750 */ 236, 199, 233, 18, 198, 71, 293, 236, 271, 236,
- /* 1760 */ 269, 236, 148, 271, 59, 245, 269, 245, 282, 271,
- /* 1770 */ 199, 198, 233, 245, 293, 233, 71, 245, 157, 62,
- /* 1780 */ 22, 199, 198, 220, 100, 199, 198, 220, 199, 289,
- /* 1790 */ 106, 107, 288, 114, 226, 198, 217, 113, 64, 115,
- /* 1800 */ 116, 117, 217, 22, 120, 100, 223, 217, 217, 164,
- /* 1810 */ 223, 106, 107, 220, 125, 24, 217, 219, 113, 217,
- /* 1820 */ 115, 116, 117, 217, 311, 120, 226, 112, 304, 281,
- /* 1830 */ 281, 220, 114, 143, 260, 259, 152, 153, 154, 155,
- /* 1840 */ 156, 199, 91, 316, 82, 316, 147, 144, 22, 199,
- /* 1850 */ 249, 276, 157, 146, 260, 145, 278, 152, 153, 154,
- /* 1860 */ 155, 156, 259, 248, 260, 260, 259, 259, 249, 245,
- /* 1870 */ 247, 246, 25, 264, 264, 201, 13, 6, 193, 193,
- /* 1880 */ 212, 206, 191, 191, 191, 212, 206, 221, 212, 212,
- /* 1890 */ 221, 213, 4, 206, 213, 212, 3, 22, 162, 15,
- /* 1900 */ 23, 16, 23, 138, 150, 129, 25, 24, 141, 20,
- /* 1910 */ 16, 143, 1, 141, 302, 302, 299, 129, 129, 61,
- /* 1920 */ 150, 53, 53, 37, 129, 53, 53, 115, 1, 34,
- /* 1930 */ 140, 5, 22, 114, 160, 68, 75, 25, 68, 41,
- /* 1940 */ 140, 114, 24, 20, 19, 130, 124, 67, 24, 67,
- /* 1950 */ 22, 22, 22, 96, 23, 22, 59, 22, 67, 37,
- /* 1960 */ 28, 23, 148, 22, 25, 23, 23, 23, 23, 22,
- /* 1970 */ 140, 97, 23, 23, 115, 22, 142, 25, 88, 75,
- /* 1980 */ 34, 44, 34, 75, 23, 34, 86, 22, 34, 34,
- /* 1990 */ 34, 24, 93, 25, 25, 23, 34, 23, 23, 23,
- /* 2000 */ 23, 11, 23, 25, 22, 22, 22, 1, 23, 23,
- /* 2010 */ 22, 22, 25, 15, 23, 1, 140, 25, 140, 318,
- /* 2020 */ 318, 134, 318, 318, 318, 318, 318, 318, 318, 318,
- /* 2030 */ 318, 318, 140, 318, 318, 318, 140, 318, 318, 318,
- /* 2040 */ 318, 318, 318, 318, 318, 318, 318, 318, 318, 318,
- /* 2050 */ 318, 318, 318, 318, 318, 318, 318, 318, 318, 318,
- /* 2060 */ 318, 318, 318, 318, 318, 318, 318, 318, 318, 318,
- /* 2070 */ 318, 318, 318, 318, 318, 318, 318, 318, 318, 318,
- /* 2080 */ 318, 318, 318, 318, 318, 318, 318, 318, 318, 318,
- /* 2090 */ 318, 318, 318, 318, 318, 318, 318, 318, 318, 318,
- /* 2100 */ 318, 318, 318, 318, 318, 318, 318, 318, 318, 318,
- /* 2110 */ 318, 318, 318, 318, 318, 318, 318, 318, 318, 318,
- /* 2120 */ 318, 318, 318, 318, 318, 318, 318, 318, 318, 318,
- /* 2130 */ 318, 318, 318, 318, 318, 318, 318, 318, 318, 318,
- /* 2140 */ 318, 318, 318, 318, 318, 318, 318, 318, 318, 318,
- /* 2150 */ 318, 318, 318, 318, 318, 318, 318, 318, 318, 318,
- /* 2160 */ 318, 318, 318, 318, 318, 318, 318, 318, 318, 318,
- /* 2170 */ 318, 318, 318, 318, 318, 318, 318, 318, 318, 318,
- /* 2180 */ 318, 318, 318, 318, 318, 318, 318, 318, 318, 318,
- /* 2190 */ 318, 318, 318, 318, 318, 318, 318, 318, 318, 318,
- /* 2200 */ 318, 318, 318, 318, 318, 318, 318, 318, 318, 318,
- /* 2210 */ 318, 318, 318, 318, 318, 318, 318, 318, 318, 318,
- /* 2220 */ 318,
+ /* 0 */ 193, 223, 193, 225, 193, 193, 193, 274, 275, 276,
+ /* 10 */ 193, 233, 219, 193, 274, 275, 276, 206, 206, 19,
+ /* 20 */ 193, 219, 216, 216, 217, 216, 217, 193, 295, 216,
+ /* 30 */ 217, 31, 205, 216, 217, 193, 216, 217, 213, 39,
+ /* 40 */ 228, 193, 230, 43, 44, 45, 46, 47, 48, 49,
+ /* 50 */ 50, 51, 52, 53, 54, 55, 56, 57, 193, 19,
+ /* 60 */ 185, 186, 187, 188, 189, 190, 253, 274, 275, 276,
+ /* 70 */ 195, 193, 197, 253, 216, 262, 274, 275, 276, 204,
+ /* 80 */ 238, 204, 262, 43, 44, 45, 46, 47, 48, 49,
+ /* 90 */ 50, 51, 52, 53, 54, 55, 56, 57, 264, 274,
+ /* 100 */ 275, 276, 102, 103, 104, 105, 106, 107, 108, 109,
+ /* 110 */ 110, 111, 112, 113, 239, 240, 239, 240, 210, 211,
+ /* 120 */ 212, 314, 315, 314, 59, 316, 86, 252, 88, 252,
+ /* 130 */ 19, 314, 315, 256, 257, 309, 25, 72, 296, 313,
+ /* 140 */ 193, 266, 102, 103, 104, 105, 106, 107, 108, 109,
+ /* 150 */ 110, 111, 112, 113, 43, 44, 45, 46, 47, 48,
+ /* 160 */ 49, 50, 51, 52, 53, 54, 55, 56, 57, 81,
+ /* 170 */ 292, 59, 307, 298, 108, 109, 110, 111, 112, 113,
+ /* 180 */ 69, 116, 117, 118, 72, 128, 129, 193, 241, 22,
+ /* 190 */ 113, 54, 55, 56, 57, 58, 102, 103, 104, 105,
+ /* 200 */ 106, 107, 108, 109, 110, 111, 112, 113, 120, 193,
+ /* 210 */ 216, 217, 25, 102, 103, 104, 105, 106, 107, 108,
+ /* 220 */ 109, 110, 111, 112, 113, 231, 138, 139, 116, 117,
+ /* 230 */ 118, 106, 107, 19, 216, 54, 55, 56, 57, 102,
+ /* 240 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
+ /* 250 */ 113, 304, 25, 46, 47, 48, 49, 43, 44, 45,
+ /* 260 */ 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
+ /* 270 */ 56, 57, 193, 106, 107, 59, 193, 19, 153, 263,
+ /* 280 */ 155, 67, 24, 102, 103, 104, 105, 106, 107, 108,
+ /* 290 */ 109, 110, 111, 112, 113, 216, 217, 59, 230, 216,
+ /* 300 */ 217, 43, 44, 45, 46, 47, 48, 49, 50, 51,
+ /* 310 */ 52, 53, 54, 55, 56, 57, 102, 103, 104, 105,
+ /* 320 */ 106, 107, 108, 109, 110, 111, 112, 113, 121, 142,
+ /* 330 */ 59, 193, 116, 117, 118, 119, 253, 204, 122, 123,
+ /* 340 */ 124, 19, 20, 81, 22, 262, 108, 19, 132, 165,
+ /* 350 */ 166, 193, 24, 126, 116, 117, 118, 278, 36, 193,
+ /* 360 */ 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
+ /* 370 */ 112, 113, 239, 240, 216, 217, 215, 106, 107, 241,
+ /* 380 */ 19, 59, 216, 217, 223, 252, 115, 116, 117, 118,
+ /* 390 */ 73, 120, 26, 71, 193, 22, 193, 231, 81, 128,
+ /* 400 */ 138, 139, 269, 81, 43, 44, 45, 46, 47, 48,
+ /* 410 */ 49, 50, 51, 52, 53, 54, 55, 56, 57, 216,
+ /* 420 */ 217, 198, 100, 95, 153, 59, 155, 193, 106, 107,
+ /* 430 */ 235, 236, 59, 193, 193, 249, 114, 251, 116, 117,
+ /* 440 */ 118, 113, 304, 121, 127, 204, 193, 119, 120, 121,
+ /* 450 */ 122, 123, 124, 125, 193, 138, 139, 216, 217, 131,
+ /* 460 */ 138, 139, 193, 102, 103, 104, 105, 106, 107, 108,
+ /* 470 */ 109, 110, 111, 112, 113, 153, 154, 155, 156, 157,
+ /* 480 */ 239, 240, 116, 117, 118, 76, 193, 193, 19, 116,
+ /* 490 */ 117, 118, 23, 252, 253, 193, 87, 204, 89, 238,
+ /* 500 */ 193, 92, 268, 262, 281, 203, 193, 205, 285, 216,
+ /* 510 */ 217, 150, 43, 44, 45, 46, 47, 48, 49, 50,
+ /* 520 */ 51, 52, 53, 54, 55, 56, 57, 193, 193, 216,
+ /* 530 */ 217, 19, 239, 240, 59, 23, 106, 107, 108, 109,
+ /* 540 */ 110, 111, 112, 113, 231, 252, 253, 193, 308, 309,
+ /* 550 */ 193, 145, 59, 313, 145, 43, 44, 45, 46, 47,
+ /* 560 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
+ /* 570 */ 164, 102, 103, 104, 105, 106, 107, 108, 109, 110,
+ /* 580 */ 111, 112, 113, 119, 193, 193, 122, 123, 124, 193,
+ /* 590 */ 283, 116, 117, 118, 235, 236, 132, 59, 241, 264,
+ /* 600 */ 59, 193, 19, 23, 193, 25, 23, 216, 217, 116,
+ /* 610 */ 117, 118, 216, 217, 102, 103, 104, 105, 106, 107,
+ /* 620 */ 108, 109, 110, 111, 112, 113, 43, 44, 45, 46,
+ /* 630 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
+ /* 640 */ 57, 19, 308, 309, 151, 23, 25, 313, 135, 253,
+ /* 650 */ 21, 193, 241, 140, 116, 117, 118, 116, 117, 118,
+ /* 660 */ 268, 304, 22, 301, 302, 43, 44, 45, 46, 47,
+ /* 670 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
+ /* 680 */ 193, 143, 193, 193, 143, 102, 103, 104, 105, 106,
+ /* 690 */ 107, 108, 109, 110, 111, 112, 113, 76, 118, 59,
+ /* 700 */ 292, 211, 212, 216, 217, 216, 217, 73, 193, 80,
+ /* 710 */ 89, 25, 19, 92, 193, 304, 23, 22, 231, 193,
+ /* 720 */ 231, 193, 22, 143, 102, 103, 104, 105, 106, 107,
+ /* 730 */ 108, 109, 110, 111, 112, 113, 43, 44, 45, 46,
+ /* 740 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
+ /* 750 */ 57, 19, 123, 193, 59, 23, 116, 117, 118, 59,
+ /* 760 */ 193, 127, 128, 129, 306, 307, 210, 211, 212, 193,
+ /* 770 */ 22, 111, 112, 113, 284, 43, 44, 45, 46, 47,
+ /* 780 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
+ /* 790 */ 161, 193, 216, 217, 268, 102, 103, 104, 105, 106,
+ /* 800 */ 107, 108, 109, 110, 111, 112, 113, 59, 193, 193,
+ /* 810 */ 193, 116, 117, 118, 216, 217, 116, 117, 118, 304,
+ /* 820 */ 239, 240, 19, 263, 138, 139, 23, 211, 212, 231,
+ /* 830 */ 263, 216, 217, 252, 102, 103, 104, 105, 106, 107,
+ /* 840 */ 108, 109, 110, 111, 112, 113, 43, 44, 45, 46,
+ /* 850 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
+ /* 860 */ 57, 19, 193, 11, 116, 117, 118, 240, 253, 193,
+ /* 870 */ 201, 239, 240, 193, 134, 206, 136, 137, 193, 252,
+ /* 880 */ 193, 264, 193, 193, 252, 43, 44, 45, 46, 47,
+ /* 890 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
+ /* 900 */ 284, 216, 217, 216, 217, 102, 103, 104, 105, 106,
+ /* 910 */ 107, 108, 109, 110, 111, 112, 113, 193, 231, 193,
+ /* 920 */ 187, 188, 189, 190, 127, 128, 129, 238, 195, 193,
+ /* 930 */ 197, 16, 19, 7, 8, 9, 193, 204, 253, 193,
+ /* 940 */ 216, 217, 216, 217, 102, 103, 104, 105, 106, 107,
+ /* 950 */ 108, 109, 110, 111, 112, 113, 43, 44, 45, 46,
+ /* 960 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
+ /* 970 */ 57, 213, 239, 240, 193, 76, 19, 188, 232, 190,
+ /* 980 */ 128, 129, 292, 193, 195, 252, 197, 46, 89, 138,
+ /* 990 */ 139, 92, 77, 204, 79, 193, 269, 216, 217, 266,
+ /* 1000 */ 204, 159, 45, 46, 47, 48, 49, 50, 51, 52,
+ /* 1010 */ 53, 54, 55, 56, 57, 102, 103, 104, 105, 106,
+ /* 1020 */ 107, 108, 109, 110, 111, 112, 113, 12, 239, 240,
+ /* 1030 */ 193, 298, 22, 23, 253, 239, 240, 127, 128, 129,
+ /* 1040 */ 238, 252, 27, 193, 286, 204, 193, 204, 252, 291,
+ /* 1050 */ 193, 273, 22, 23, 100, 266, 115, 42, 268, 102,
+ /* 1060 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
+ /* 1070 */ 113, 117, 159, 216, 217, 121, 161, 19, 63, 193,
+ /* 1080 */ 239, 240, 239, 240, 12, 208, 209, 298, 73, 311,
+ /* 1090 */ 312, 238, 19, 252, 25, 252, 22, 24, 24, 27,
+ /* 1100 */ 193, 264, 216, 217, 46, 208, 209, 153, 154, 155,
+ /* 1110 */ 253, 101, 19, 23, 42, 25, 43, 44, 45, 46,
+ /* 1120 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
+ /* 1130 */ 57, 101, 19, 59, 25, 63, 43, 44, 45, 46,
+ /* 1140 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
+ /* 1150 */ 57, 22, 23, 115, 25, 24, 43, 44, 45, 46,
+ /* 1160 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
+ /* 1170 */ 57, 22, 23, 115, 25, 102, 103, 104, 105, 106,
+ /* 1180 */ 107, 108, 109, 110, 111, 112, 113, 118, 150, 131,
+ /* 1190 */ 59, 117, 22, 273, 193, 102, 103, 104, 105, 106,
+ /* 1200 */ 107, 108, 109, 110, 111, 112, 113, 204, 66, 204,
+ /* 1210 */ 35, 204, 143, 213, 193, 102, 103, 104, 105, 106,
+ /* 1220 */ 107, 108, 109, 110, 111, 112, 113, 85, 193, 59,
+ /* 1230 */ 101, 311, 312, 16, 193, 19, 94, 216, 217, 238,
+ /* 1240 */ 193, 66, 239, 240, 239, 240, 239, 240, 117, 74,
+ /* 1250 */ 101, 216, 217, 193, 193, 252, 193, 252, 149, 252,
+ /* 1260 */ 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
+ /* 1270 */ 54, 55, 56, 57, 193, 193, 193, 5, 59, 216,
+ /* 1280 */ 217, 25, 10, 11, 12, 13, 14, 117, 146, 17,
+ /* 1290 */ 193, 291, 193, 232, 77, 76, 79, 216, 217, 216,
+ /* 1300 */ 217, 31, 30, 309, 32, 130, 87, 313, 89, 39,
+ /* 1310 */ 193, 92, 40, 216, 217, 216, 217, 108, 102, 103,
+ /* 1320 */ 104, 105, 106, 107, 108, 109, 110, 111, 112, 113,
+ /* 1330 */ 299, 300, 193, 216, 217, 116, 117, 118, 19, 20,
+ /* 1340 */ 193, 22, 70, 309, 135, 193, 264, 313, 193, 140,
+ /* 1350 */ 78, 193, 226, 81, 59, 36, 193, 309, 193, 29,
+ /* 1360 */ 193, 313, 193, 33, 145, 193, 59, 48, 216, 217,
+ /* 1370 */ 98, 216, 217, 193, 216, 217, 193, 244, 59, 216,
+ /* 1380 */ 217, 216, 217, 216, 217, 216, 217, 254, 216, 217,
+ /* 1390 */ 71, 193, 244, 193, 193, 65, 216, 217, 193, 216,
+ /* 1400 */ 217, 145, 254, 244, 85, 133, 15, 100, 193, 90,
+ /* 1410 */ 138, 139, 117, 254, 216, 217, 216, 217, 193, 100,
+ /* 1420 */ 193, 216, 217, 116, 117, 106, 107, 19, 121, 193,
+ /* 1430 */ 193, 216, 217, 114, 162, 116, 117, 118, 244, 244,
+ /* 1440 */ 121, 216, 217, 216, 217, 193, 309, 129, 254, 254,
+ /* 1450 */ 313, 60, 216, 217, 19, 256, 257, 193, 120, 121,
+ /* 1460 */ 153, 154, 155, 149, 150, 25, 24, 99, 216, 217,
+ /* 1470 */ 152, 193, 153, 154, 155, 156, 157, 0, 1, 2,
+ /* 1480 */ 216, 217, 5, 22, 158, 24, 160, 10, 11, 12,
+ /* 1490 */ 13, 14, 193, 23, 17, 25, 193, 19, 20, 193,
+ /* 1500 */ 22, 133, 193, 22, 22, 193, 22, 30, 193, 32,
+ /* 1510 */ 19, 20, 129, 22, 36, 216, 217, 40, 193, 216,
+ /* 1520 */ 217, 193, 216, 217, 116, 216, 217, 36, 216, 217,
+ /* 1530 */ 193, 216, 217, 193, 53, 152, 193, 59, 23, 19,
+ /* 1540 */ 25, 216, 217, 61, 216, 217, 23, 70, 25, 71,
+ /* 1550 */ 59, 116, 193, 216, 217, 78, 216, 217, 81, 216,
+ /* 1560 */ 217, 59, 71, 85, 193, 23, 193, 25, 90, 23,
+ /* 1570 */ 23, 25, 25, 7, 8, 98, 85, 193, 100, 193,
+ /* 1580 */ 59, 90, 142, 141, 106, 107, 193, 216, 217, 216,
+ /* 1590 */ 217, 100, 114, 193, 116, 117, 118, 106, 107, 121,
+ /* 1600 */ 216, 217, 216, 217, 193, 114, 193, 116, 117, 118,
+ /* 1610 */ 133, 23, 121, 25, 121, 138, 139, 97, 23, 117,
+ /* 1620 */ 25, 23, 193, 25, 131, 141, 193, 216, 217, 59,
+ /* 1630 */ 193, 153, 154, 155, 156, 157, 226, 193, 117, 162,
+ /* 1640 */ 23, 23, 25, 25, 153, 154, 155, 156, 157, 1,
+ /* 1650 */ 2, 83, 84, 5, 19, 20, 226, 22, 10, 11,
+ /* 1660 */ 12, 13, 14, 258, 153, 17, 155, 153, 23, 155,
+ /* 1670 */ 25, 36, 23, 193, 25, 255, 193, 236, 30, 193,
+ /* 1680 */ 32, 19, 20, 193, 22, 193, 288, 117, 40, 193,
+ /* 1690 */ 318, 193, 193, 193, 59, 242, 193, 193, 36, 193,
+ /* 1700 */ 193, 193, 287, 255, 255, 255, 71, 255, 243, 214,
+ /* 1710 */ 191, 297, 267, 245, 271, 259, 259, 293, 70, 246,
+ /* 1720 */ 246, 59, 267, 229, 245, 271, 78, 293, 259, 81,
+ /* 1730 */ 271, 271, 220, 71, 225, 100, 219, 219, 249, 196,
+ /* 1740 */ 243, 106, 107, 108, 219, 60, 98, 280, 297, 114,
+ /* 1750 */ 249, 116, 117, 118, 141, 245, 121, 200, 200, 297,
+ /* 1760 */ 38, 200, 100, 151, 150, 294, 294, 22, 106, 107,
+ /* 1770 */ 283, 43, 234, 18, 237, 200, 114, 272, 116, 117,
+ /* 1780 */ 118, 133, 237, 121, 18, 237, 138, 139, 153, 154,
+ /* 1790 */ 155, 156, 157, 237, 270, 199, 19, 20, 246, 22,
+ /* 1800 */ 149, 272, 272, 270, 200, 246, 234, 234, 246, 246,
+ /* 1810 */ 162, 158, 290, 36, 199, 153, 154, 155, 156, 157,
+ /* 1820 */ 62, 289, 200, 199, 22, 200, 221, 199, 221, 200,
+ /* 1830 */ 199, 115, 64, 227, 218, 22, 59, 218, 218, 126,
+ /* 1840 */ 165, 24, 113, 312, 218, 224, 305, 224, 71, 282,
+ /* 1850 */ 144, 221, 220, 282, 218, 218, 218, 115, 261, 260,
+ /* 1860 */ 227, 221, 261, 260, 200, 91, 317, 317, 82, 261,
+ /* 1870 */ 260, 148, 261, 22, 265, 145, 200, 100, 158, 277,
+ /* 1880 */ 147, 146, 25, 106, 107, 202, 13, 260, 194, 250,
+ /* 1890 */ 249, 114, 248, 116, 117, 118, 250, 247, 121, 265,
+ /* 1900 */ 246, 194, 6, 192, 192, 207, 192, 207, 213, 213,
+ /* 1910 */ 213, 222, 213, 222, 4, 214, 214, 213, 3, 22,
+ /* 1920 */ 163, 279, 207, 15, 23, 16, 23, 139, 130, 151,
+ /* 1930 */ 153, 154, 155, 156, 157, 142, 25, 24, 20, 144,
+ /* 1940 */ 16, 1, 142, 61, 130, 130, 303, 151, 53, 37,
+ /* 1950 */ 303, 53, 300, 53, 130, 53, 116, 34, 1, 141,
+ /* 1960 */ 5, 22, 115, 25, 161, 75, 41, 68, 141, 115,
+ /* 1970 */ 24, 20, 68, 19, 131, 125, 23, 96, 22, 59,
+ /* 1980 */ 22, 67, 22, 22, 67, 22, 24, 28, 67, 37,
+ /* 1990 */ 23, 149, 22, 25, 23, 23, 23, 23, 22, 141,
+ /* 2000 */ 23, 23, 97, 116, 22, 143, 25, 88, 75, 34,
+ /* 2010 */ 44, 75, 86, 34, 34, 93, 23, 34, 34, 34,
+ /* 2020 */ 22, 24, 34, 22, 25, 25, 23, 23, 23, 23,
+ /* 2030 */ 23, 11, 23, 25, 22, 22, 25, 23, 23, 22,
+ /* 2040 */ 22, 135, 15, 1, 25, 23, 1, 319, 141, 319,
+ /* 2050 */ 319, 319, 319, 319, 319, 319, 319, 141, 319, 319,
+ /* 2060 */ 319, 319, 319, 319, 319, 319, 319, 319, 141, 141,
+ /* 2070 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
+ /* 2080 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
+ /* 2090 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
+ /* 2100 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
+ /* 2110 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
+ /* 2120 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
+ /* 2130 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
+ /* 2140 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
+ /* 2150 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
+ /* 2160 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
+ /* 2170 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
+ /* 2180 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
+ /* 2190 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
+ /* 2200 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
+ /* 2210 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
+ /* 2220 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
+ /* 2230 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
+ /* 2240 */ 319, 319, 319, 319, 319, 319, 319, 319, 319, 319,
+ /* 2250 */ 319, 319, 319, 319, 319,
};
-#define YY_SHIFT_COUNT (571)
+#define YY_SHIFT_COUNT (573)
#define YY_SHIFT_MIN (0)
-#define YY_SHIFT_MAX (2014)
+#define YY_SHIFT_MAX (2045)
static const unsigned short int yy_shift_ofst[] = {
- /* 0 */ 1423, 1409, 1454, 1192, 1192, 610, 1252, 1410, 1517, 1684,
- /* 10 */ 1684, 1684, 276, 0, 0, 180, 1015, 1684, 1684, 1684,
- /* 20 */ 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684,
- /* 30 */ 1049, 1049, 1121, 1121, 54, 487, 610, 610, 610, 610,
- /* 40 */ 610, 40, 110, 219, 289, 396, 439, 509, 548, 618,
- /* 50 */ 657, 727, 766, 836, 995, 1015, 1015, 1015, 1015, 1015,
- /* 60 */ 1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015, 1015,
- /* 70 */ 1015, 1015, 1015, 1035, 1015, 1138, 880, 880, 1577, 1684,
- /* 80 */ 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684,
- /* 90 */ 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684,
- /* 100 */ 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684,
- /* 110 */ 1684, 1684, 1684, 1705, 1684, 1684, 1684, 1684, 1684, 1684,
- /* 120 */ 1684, 1684, 1684, 1684, 1684, 1684, 1684, 146, 84, 84,
- /* 130 */ 84, 84, 84, 277, 315, 401, 97, 461, 251, 66,
- /* 140 */ 66, 51, 1156, 66, 66, 324, 324, 66, 452, 452,
- /* 150 */ 452, 452, 133, 114, 114, 4, 11, 2037, 2037, 621,
- /* 160 */ 621, 621, 567, 398, 398, 398, 398, 937, 937, 228,
- /* 170 */ 251, 331, 1052, 66, 66, 66, 66, 66, 66, 66,
- /* 180 */ 66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
- /* 190 */ 66, 66, 66, 557, 557, 66, 9, 25, 25, 745,
- /* 200 */ 745, 967, 1088, 2037, 2037, 2037, 2037, 2037, 2037, 2037,
- /* 210 */ 255, 317, 317, 514, 403, 620, 471, 672, 781, 891,
- /* 220 */ 675, 66, 66, 66, 66, 66, 66, 66, 66, 66,
- /* 230 */ 66, 508, 66, 66, 66, 66, 66, 66, 66, 66,
- /* 240 */ 66, 66, 66, 66, 790, 790, 790, 66, 66, 66,
- /* 250 */ 338, 66, 66, 66, 516, 1084, 66, 66, 993, 66,
- /* 260 */ 66, 66, 66, 66, 66, 66, 66, 732, 1083, 563,
- /* 270 */ 994, 994, 994, 994, 337, 563, 563, 1028, 987, 897,
- /* 280 */ 1119, 262, 1214, 1271, 1112, 1214, 1112, 1268, 1239, 262,
- /* 290 */ 262, 1239, 262, 1271, 1268, 1302, 1354, 1278, 1168, 1168,
- /* 300 */ 1168, 1112, 1303, 1303, 815, 1311, 1264, 1364, 1657, 1657,
- /* 310 */ 1595, 1595, 1701, 1701, 1595, 1592, 1596, 1724, 1706, 1730,
- /* 320 */ 1730, 1730, 1730, 1595, 1735, 1614, 1596, 1596, 1614, 1724,
- /* 330 */ 1706, 1614, 1706, 1614, 1595, 1735, 1621, 1717, 1595, 1735,
- /* 340 */ 1758, 1595, 1735, 1595, 1735, 1758, 1679, 1679, 1679, 1734,
- /* 350 */ 1781, 1781, 1758, 1679, 1689, 1679, 1734, 1679, 1679, 1645,
- /* 360 */ 1791, 1715, 1715, 1758, 1690, 1718, 1690, 1718, 1690, 1718,
- /* 370 */ 1690, 1718, 1595, 1751, 1751, 1762, 1762, 1699, 1703, 1826,
- /* 380 */ 1595, 1695, 1699, 1707, 1710, 1614, 1847, 1863, 1863, 1871,
- /* 390 */ 1871, 1871, 2037, 2037, 2037, 2037, 2037, 2037, 2037, 2037,
- /* 400 */ 2037, 2037, 2037, 2037, 2037, 2037, 2037, 193, 837, 1194,
- /* 410 */ 1212, 506, 832, 1054, 1390, 925, 1435, 1394, 1102, 1332,
- /* 420 */ 1419, 1196, 1420, 1425, 1433, 1447, 1457, 1488, 1443, 1379,
- /* 430 */ 1572, 1455, 1503, 1453, 1495, 1515, 1506, 1526, 1460, 1489,
- /* 440 */ 1581, 1622, 1534, 667, 1888, 1893, 1875, 1736, 1884, 1885,
- /* 450 */ 1877, 1879, 1765, 1754, 1776, 1881, 1881, 1883, 1767, 1889,
- /* 460 */ 1768, 1894, 1911, 1772, 1788, 1881, 1789, 1858, 1886, 1881,
- /* 470 */ 1770, 1868, 1869, 1872, 1873, 1795, 1812, 1895, 1790, 1927,
- /* 480 */ 1926, 1910, 1819, 1774, 1867, 1912, 1870, 1861, 1898, 1800,
- /* 490 */ 1827, 1918, 1923, 1925, 1815, 1822, 1928, 1880, 1929, 1930,
- /* 500 */ 1931, 1933, 1882, 1897, 1924, 1857, 1932, 1935, 1891, 1922,
- /* 510 */ 1938, 1814, 1941, 1942, 1943, 1944, 1939, 1945, 1947, 1874,
- /* 520 */ 1830, 1949, 1950, 1859, 1946, 1953, 1834, 1952, 1948, 1951,
- /* 530 */ 1954, 1955, 1890, 1904, 1900, 1937, 1908, 1899, 1956, 1961,
- /* 540 */ 1965, 1967, 1968, 1969, 1962, 1972, 1952, 1974, 1975, 1976,
- /* 550 */ 1977, 1978, 1979, 1982, 1990, 1983, 1984, 1985, 1986, 1988,
- /* 560 */ 1989, 1987, 1887, 1876, 1878, 1892, 1896, 1992, 1991, 1998,
- /* 570 */ 2006, 2014,
+ /* 0 */ 1648, 1477, 1272, 322, 322, 262, 1319, 1478, 1491, 1662,
+ /* 10 */ 1662, 1662, 317, 0, 0, 214, 1093, 1662, 1662, 1662,
+ /* 20 */ 1662, 1662, 1662, 1662, 1662, 1662, 1662, 1662, 1662, 1662,
+ /* 30 */ 271, 271, 1219, 1219, 216, 88, 262, 262, 262, 262,
+ /* 40 */ 262, 40, 111, 258, 361, 469, 512, 583, 622, 693,
+ /* 50 */ 732, 803, 842, 913, 1073, 1093, 1093, 1093, 1093, 1093,
+ /* 60 */ 1093, 1093, 1093, 1093, 1093, 1093, 1093, 1093, 1093, 1093,
+ /* 70 */ 1093, 1093, 1093, 1113, 1093, 1216, 957, 957, 1635, 1662,
+ /* 80 */ 1662, 1662, 1662, 1662, 1662, 1662, 1662, 1662, 1662, 1662,
+ /* 90 */ 1662, 1662, 1662, 1662, 1662, 1662, 1662, 1662, 1662, 1662,
+ /* 100 */ 1662, 1662, 1662, 1662, 1662, 1662, 1662, 1662, 1662, 1662,
+ /* 110 */ 1662, 1662, 1662, 1662, 1777, 1662, 1662, 1662, 1662, 1662,
+ /* 120 */ 1662, 1662, 1662, 1662, 1662, 1662, 1662, 1662, 137, 181,
+ /* 130 */ 181, 181, 181, 181, 94, 430, 66, 65, 112, 366,
+ /* 140 */ 475, 475, 629, 1058, 475, 475, 125, 125, 475, 686,
+ /* 150 */ 686, 686, 660, 686, 57, 184, 184, 77, 77, 2070,
+ /* 160 */ 2070, 328, 328, 328, 493, 373, 373, 373, 373, 1015,
+ /* 170 */ 1015, 409, 366, 1129, 1149, 475, 475, 475, 475, 475,
+ /* 180 */ 475, 475, 475, 475, 475, 475, 475, 475, 475, 475,
+ /* 190 */ 475, 475, 475, 475, 475, 621, 621, 475, 852, 899,
+ /* 200 */ 899, 1295, 1295, 406, 851, 2070, 2070, 2070, 2070, 2070,
+ /* 210 */ 2070, 2070, 1307, 954, 954, 640, 464, 695, 238, 700,
+ /* 220 */ 538, 541, 748, 475, 475, 475, 475, 475, 475, 475,
+ /* 230 */ 475, 475, 475, 634, 475, 475, 475, 475, 475, 475,
+ /* 240 */ 475, 475, 475, 475, 475, 475, 1175, 1175, 1175, 475,
+ /* 250 */ 475, 475, 580, 475, 475, 475, 1074, 1142, 475, 475,
+ /* 260 */ 1072, 475, 475, 475, 475, 475, 475, 475, 475, 797,
+ /* 270 */ 1330, 740, 1131, 1131, 1131, 1131, 1069, 740, 740, 1209,
+ /* 280 */ 167, 926, 1391, 1038, 1314, 187, 1408, 1314, 1408, 1435,
+ /* 290 */ 1109, 1038, 1038, 1109, 1038, 187, 1435, 227, 1090, 941,
+ /* 300 */ 1270, 1270, 1270, 1408, 1256, 1256, 1326, 1440, 513, 1461,
+ /* 310 */ 1685, 1685, 1613, 1613, 1722, 1722, 1613, 1612, 1614, 1745,
+ /* 320 */ 1728, 1755, 1755, 1755, 1755, 1613, 1766, 1651, 1614, 1614,
+ /* 330 */ 1651, 1745, 1728, 1651, 1728, 1651, 1613, 1766, 1653, 1758,
+ /* 340 */ 1613, 1766, 1802, 1613, 1766, 1613, 1766, 1802, 1716, 1716,
+ /* 350 */ 1716, 1768, 1813, 1813, 1802, 1716, 1713, 1716, 1768, 1716,
+ /* 360 */ 1716, 1675, 1817, 1729, 1729, 1802, 1706, 1742, 1706, 1742,
+ /* 370 */ 1706, 1742, 1706, 1742, 1613, 1774, 1774, 1786, 1786, 1723,
+ /* 380 */ 1730, 1851, 1613, 1720, 1723, 1733, 1735, 1651, 1857, 1873,
+ /* 390 */ 1873, 1896, 1896, 1896, 2070, 2070, 2070, 2070, 2070, 2070,
+ /* 400 */ 2070, 2070, 2070, 2070, 2070, 2070, 2070, 2070, 2070, 207,
+ /* 410 */ 915, 1010, 1030, 1217, 910, 1170, 1470, 1368, 1481, 1442,
+ /* 420 */ 1318, 1383, 1515, 1482, 1523, 1542, 1546, 1547, 1588, 1595,
+ /* 430 */ 1502, 1338, 1566, 1493, 1520, 1521, 1598, 1617, 1568, 1618,
+ /* 440 */ 1511, 1514, 1645, 1649, 1570, 1484, 1910, 1915, 1897, 1757,
+ /* 450 */ 1908, 1909, 1901, 1903, 1788, 1778, 1798, 1911, 1911, 1913,
+ /* 460 */ 1793, 1918, 1795, 1924, 1940, 1800, 1814, 1911, 1815, 1882,
+ /* 470 */ 1912, 1911, 1796, 1895, 1898, 1900, 1902, 1824, 1840, 1923,
+ /* 480 */ 1818, 1957, 1955, 1939, 1847, 1803, 1899, 1938, 1904, 1890,
+ /* 490 */ 1925, 1827, 1854, 1946, 1951, 1954, 1843, 1850, 1956, 1914,
+ /* 500 */ 1958, 1960, 1953, 1961, 1917, 1920, 1962, 1881, 1959, 1963,
+ /* 510 */ 1921, 1952, 1967, 1842, 1970, 1971, 1972, 1973, 1968, 1974,
+ /* 520 */ 1976, 1905, 1858, 1977, 1978, 1887, 1975, 1982, 1862, 1981,
+ /* 530 */ 1979, 1980, 1983, 1984, 1919, 1933, 1926, 1966, 1936, 1922,
+ /* 540 */ 1985, 1993, 1998, 1997, 1999, 2000, 1988, 2003, 1981, 2004,
+ /* 550 */ 2005, 2006, 2007, 2008, 2009, 2001, 2020, 2012, 2013, 2014,
+ /* 560 */ 2015, 2017, 2018, 2011, 1906, 1907, 1916, 1927, 1928, 2019,
+ /* 570 */ 2022, 2027, 2042, 2045,
};
-#define YY_REDUCE_COUNT (406)
-#define YY_REDUCE_MIN (-272)
-#define YY_REDUCE_MAX (1693)
+#define YY_REDUCE_COUNT (408)
+#define YY_REDUCE_MIN (-267)
+#define YY_REDUCE_MAX (1715)
static const short yy_reduce_ofst[] = {
- /* 0 */ 109, 113, 272, 760, -178, -176, -192, -183, -180, -134,
- /* 10 */ 213, 220, 371, -208, -205, -272, -197, 611, 632, 765,
- /* 20 */ 786, 392, 943, 989, 503, 651, 1039, -18, 702, 821,
- /* 30 */ 710, 812, -188, 380, -187, 555, 662, 1055, 1063, 1065,
- /* 40 */ 1080, -267, -267, -267, -267, -267, -267, -267, -267, -267,
- /* 50 */ -267, -267, -267, -267, -267, -267, -267, -267, -267, -267,
- /* 60 */ -267, -267, -267, -267, -267, -267, -267, -267, -267, -267,
- /* 70 */ -267, -267, -267, -267, -267, -267, -267, -267, 636, 811,
- /* 80 */ 917, 936, 1006, 1008, 1017, 1060, 1064, 1069, 1075, 1105,
- /* 90 */ 1118, 1123, 1125, 1134, 1140, 1159, 1165, 1169, 1174, 1179,
- /* 100 */ 1181, 1184, 1186, 1201, 1246, 1259, 1262, 1281, 1293, 1299,
- /* 110 */ 1313, 1327, 1341, 1352, 1356, 1358, 1362, 1366, 1395, 1403,
- /* 120 */ 1406, 1411, 1424, 1436, 1439, 1450, 1452, -267, -267, -267,
- /* 130 */ -267, -267, -267, -267, -267, 224, -267, 446, -24, 275,
- /* 140 */ 546, 518, 573, 560, 53, -181, -111, 485, 606, 671,
- /* 150 */ 606, 671, 683, 8, 93, -267, -267, -267, -267, 155,
- /* 160 */ 155, 155, 181, 242, 264, 486, 489, -218, 393, 227,
- /* 170 */ 604, 347, 347, -171, 431, 650, 715, -166, 562, 609,
- /* 180 */ 716, 764, 18, 823, 769, 833, 838, 957, 759, 119,
- /* 190 */ 923, 226, 1014, 542, 603, 451, 949, 654, 659, 762,
- /* 200 */ 964, -4, 778, 961, 712, 1082, 1100, 1111, 1026, 1117,
- /* 210 */ -204, -174, -151, -8, 77, 198, 305, 327, 388, 540,
- /* 220 */ 839, 968, 982, 985, 1004, 1023, 1070, 1086, 1097, 1130,
- /* 230 */ 1190, 1163, 1199, 1284, 1297, 1300, 1314, 1339, 1353, 1391,
- /* 240 */ 1402, 1413, 1416, 1417, 803, 1376, 1400, 1428, 1437, 1446,
- /* 250 */ 1378, 1461, 1464, 1465, 1249, 1329, 1466, 1467, 1414, 1468,
- /* 260 */ 305, 1469, 1470, 1471, 1472, 1482, 1483, 1389, 1392, 1438,
- /* 270 */ 1426, 1427, 1432, 1434, 1378, 1438, 1438, 1440, 1474, 1499,
- /* 280 */ 1399, 1421, 1430, 1456, 1441, 1442, 1444, 1415, 1473, 1431,
- /* 290 */ 1445, 1476, 1449, 1478, 1418, 1479, 1477, 1485, 1493, 1494,
- /* 300 */ 1496, 1458, 1475, 1480, 1459, 1490, 1484, 1518, 1448, 1451,
- /* 310 */ 1537, 1538, 1463, 1481, 1541, 1486, 1487, 1491, 1519, 1514,
- /* 320 */ 1521, 1523, 1525, 1552, 1556, 1520, 1492, 1498, 1522, 1497,
- /* 330 */ 1539, 1528, 1542, 1532, 1571, 1573, 1500, 1504, 1582, 1584,
- /* 340 */ 1563, 1586, 1588, 1589, 1597, 1567, 1579, 1585, 1590, 1568,
- /* 350 */ 1583, 1587, 1593, 1591, 1598, 1599, 1600, 1602, 1606, 1513,
- /* 360 */ 1524, 1548, 1549, 1611, 1574, 1576, 1594, 1603, 1604, 1607,
- /* 370 */ 1605, 1608, 1642, 1527, 1529, 1609, 1610, 1601, 1615, 1575,
- /* 380 */ 1650, 1578, 1619, 1623, 1625, 1624, 1674, 1685, 1686, 1691,
- /* 390 */ 1692, 1693, 1612, 1613, 1617, 1675, 1668, 1673, 1676, 1677,
- /* 400 */ 1680, 1666, 1669, 1678, 1681, 1683, 1687,
+ /* 0 */ -125, 733, 789, 241, 293, -123, -193, -191, -183, -187,
+ /* 10 */ -180, 83, 133, -207, -198, -267, -175, -6, 166, 313,
+ /* 20 */ 487, 396, 489, 598, 615, 685, 687, 79, 781, 857,
+ /* 30 */ 490, 616, 240, 334, -188, 796, 841, 843, 1003, 1005,
+ /* 40 */ 1007, -260, -260, -260, -260, -260, -260, -260, -260, -260,
+ /* 50 */ -260, -260, -260, -260, -260, -260, -260, -260, -260, -260,
+ /* 60 */ -260, -260, -260, -260, -260, -260, -260, -260, -260, -260,
+ /* 70 */ -260, -260, -260, -260, -260, -260, -260, -260, 158, 203,
+ /* 80 */ 391, 576, 724, 726, 886, 1021, 1035, 1063, 1081, 1083,
+ /* 90 */ 1097, 1099, 1117, 1152, 1155, 1158, 1163, 1165, 1167, 1169,
+ /* 100 */ 1172, 1180, 1183, 1198, 1200, 1205, 1215, 1225, 1227, 1236,
+ /* 110 */ 1252, 1264, 1299, 1303, 1306, 1309, 1312, 1315, 1325, 1328,
+ /* 120 */ 1337, 1340, 1343, 1371, 1373, 1384, 1386, 1411, -260, -260,
+ /* 130 */ -260, -260, -260, -260, -260, -260, -260, -53, 138, 302,
+ /* 140 */ -158, 357, 223, -222, 411, 458, -92, 556, 669, 581,
+ /* 150 */ 632, 581, -260, 632, 758, 778, 920, -260, -260, -260,
+ /* 160 */ -260, 161, 161, 161, 307, 234, 392, 526, 790, 195,
+ /* 170 */ 359, -174, -173, 362, 362, -189, 16, 560, 567, 261,
+ /* 180 */ 689, 802, 853, -122, -166, 408, 335, 617, 690, 837,
+ /* 190 */ 1001, 746, 1061, 515, 1082, 994, 1034, -135, 1000, 1048,
+ /* 200 */ 1137, 877, 897, 186, 627, 1031, 1133, 1148, 1159, 1194,
+ /* 210 */ 1199, 1195, -194, -142, 18, -152, 68, 201, 253, 269,
+ /* 220 */ 294, 354, 521, 528, 676, 680, 736, 743, 850, 907,
+ /* 230 */ 1041, 1047, 1060, 727, 1139, 1147, 1201, 1237, 1278, 1359,
+ /* 240 */ 1393, 1400, 1413, 1429, 1433, 1437, 1126, 1410, 1430, 1444,
+ /* 250 */ 1480, 1483, 1405, 1486, 1490, 1492, 1420, 1372, 1496, 1498,
+ /* 260 */ 1441, 1499, 253, 1500, 1503, 1504, 1506, 1507, 1508, 1398,
+ /* 270 */ 1415, 1453, 1448, 1449, 1450, 1452, 1405, 1453, 1453, 1465,
+ /* 280 */ 1495, 1519, 1414, 1443, 1445, 1468, 1456, 1455, 1457, 1424,
+ /* 290 */ 1473, 1454, 1459, 1474, 1460, 1479, 1434, 1512, 1494, 1509,
+ /* 300 */ 1517, 1518, 1525, 1469, 1489, 1501, 1467, 1510, 1497, 1543,
+ /* 310 */ 1451, 1462, 1557, 1558, 1471, 1472, 1561, 1487, 1505, 1524,
+ /* 320 */ 1538, 1537, 1545, 1548, 1556, 1575, 1596, 1552, 1529, 1530,
+ /* 330 */ 1559, 1533, 1572, 1562, 1573, 1563, 1604, 1615, 1522, 1532,
+ /* 340 */ 1622, 1624, 1605, 1625, 1628, 1629, 1631, 1607, 1616, 1619,
+ /* 350 */ 1620, 1606, 1621, 1623, 1630, 1626, 1632, 1636, 1633, 1637,
+ /* 360 */ 1638, 1531, 1541, 1567, 1571, 1640, 1597, 1599, 1601, 1603,
+ /* 370 */ 1608, 1610, 1611, 1627, 1664, 1549, 1550, 1609, 1634, 1639,
+ /* 380 */ 1641, 1602, 1676, 1642, 1646, 1644, 1650, 1654, 1683, 1694,
+ /* 390 */ 1707, 1711, 1712, 1714, 1643, 1647, 1652, 1698, 1695, 1696,
+ /* 400 */ 1697, 1699, 1700, 1689, 1691, 1701, 1702, 1704, 1715,
};
static const YYACTIONTYPE yy_default[] = {
- /* 0 */ 1633, 1633, 1633, 1462, 1230, 1341, 1230, 1230, 1230, 1462,
- /* 10 */ 1462, 1462, 1230, 1371, 1371, 1515, 1263, 1230, 1230, 1230,
- /* 20 */ 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1461, 1230, 1230,
- /* 30 */ 1230, 1230, 1550, 1550, 1230, 1230, 1230, 1230, 1230, 1230,
- /* 40 */ 1230, 1230, 1380, 1230, 1387, 1230, 1230, 1230, 1230, 1230,
- /* 50 */ 1463, 1464, 1230, 1230, 1230, 1514, 1516, 1479, 1394, 1393,
- /* 60 */ 1392, 1391, 1497, 1358, 1385, 1378, 1382, 1457, 1458, 1456,
- /* 70 */ 1460, 1464, 1463, 1230, 1381, 1428, 1442, 1427, 1230, 1230,
- /* 80 */ 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230,
- /* 90 */ 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230,
- /* 100 */ 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230,
- /* 110 */ 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230,
- /* 120 */ 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1436, 1441, 1447,
- /* 130 */ 1440, 1437, 1430, 1429, 1431, 1230, 1432, 1230, 1254, 1230,
- /* 140 */ 1230, 1251, 1305, 1230, 1230, 1230, 1230, 1230, 1534, 1533,
- /* 150 */ 1230, 1230, 1263, 1422, 1421, 1433, 1434, 1444, 1443, 1522,
- /* 160 */ 1586, 1585, 1480, 1230, 1230, 1230, 1230, 1230, 1230, 1550,
- /* 170 */ 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230,
- /* 180 */ 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230,
- /* 190 */ 1230, 1230, 1230, 1550, 1550, 1230, 1263, 1550, 1550, 1259,
- /* 200 */ 1259, 1365, 1230, 1529, 1332, 1332, 1332, 1332, 1341, 1332,
- /* 210 */ 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230,
- /* 220 */ 1230, 1230, 1230, 1230, 1230, 1519, 1517, 1230, 1230, 1230,
- /* 230 */ 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230,
- /* 240 */ 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230,
- /* 250 */ 1230, 1230, 1230, 1230, 1337, 1230, 1230, 1230, 1230, 1230,
- /* 260 */ 1230, 1230, 1230, 1230, 1230, 1230, 1579, 1230, 1492, 1319,
- /* 270 */ 1337, 1337, 1337, 1337, 1339, 1320, 1318, 1331, 1264, 1237,
- /* 280 */ 1625, 1397, 1386, 1338, 1360, 1386, 1360, 1622, 1384, 1397,
- /* 290 */ 1397, 1384, 1397, 1338, 1622, 1280, 1602, 1275, 1371, 1371,
- /* 300 */ 1371, 1360, 1365, 1365, 1459, 1338, 1331, 1230, 1625, 1625,
- /* 310 */ 1346, 1346, 1624, 1624, 1346, 1480, 1609, 1406, 1308, 1314,
- /* 320 */ 1314, 1314, 1314, 1346, 1248, 1384, 1609, 1609, 1384, 1406,
- /* 330 */ 1308, 1384, 1308, 1384, 1346, 1248, 1496, 1619, 1346, 1248,
- /* 340 */ 1470, 1346, 1248, 1346, 1248, 1470, 1306, 1306, 1306, 1295,
- /* 350 */ 1230, 1230, 1470, 1306, 1280, 1306, 1295, 1306, 1306, 1568,
- /* 360 */ 1230, 1474, 1474, 1470, 1364, 1359, 1364, 1359, 1364, 1359,
- /* 370 */ 1364, 1359, 1346, 1560, 1560, 1374, 1374, 1379, 1365, 1465,
- /* 380 */ 1346, 1230, 1379, 1377, 1375, 1384, 1298, 1582, 1582, 1578,
- /* 390 */ 1578, 1578, 1630, 1630, 1529, 1595, 1263, 1263, 1263, 1263,
- /* 400 */ 1595, 1282, 1282, 1264, 1264, 1263, 1595, 1230, 1230, 1230,
- /* 410 */ 1230, 1230, 1230, 1590, 1230, 1524, 1481, 1350, 1230, 1230,
- /* 420 */ 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230,
- /* 430 */ 1230, 1230, 1535, 1230, 1230, 1230, 1230, 1230, 1230, 1230,
- /* 440 */ 1230, 1230, 1230, 1411, 1230, 1233, 1526, 1230, 1230, 1230,
- /* 450 */ 1230, 1230, 1230, 1230, 1230, 1388, 1389, 1351, 1230, 1230,
- /* 460 */ 1230, 1230, 1230, 1230, 1230, 1403, 1230, 1230, 1230, 1398,
- /* 470 */ 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1621, 1230,
- /* 480 */ 1230, 1230, 1230, 1230, 1230, 1495, 1494, 1230, 1230, 1348,
- /* 490 */ 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230,
- /* 500 */ 1230, 1230, 1230, 1278, 1230, 1230, 1230, 1230, 1230, 1230,
- /* 510 */ 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230,
- /* 520 */ 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1376, 1230, 1230,
- /* 530 */ 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230,
- /* 540 */ 1230, 1230, 1565, 1366, 1230, 1230, 1612, 1230, 1230, 1230,
- /* 550 */ 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230, 1230,
- /* 560 */ 1230, 1606, 1322, 1413, 1230, 1412, 1416, 1252, 1230, 1242,
- /* 570 */ 1230, 1230,
+ /* 0 */ 1637, 1637, 1637, 1466, 1233, 1344, 1233, 1233, 1233, 1466,
+ /* 10 */ 1466, 1466, 1233, 1374, 1374, 1519, 1266, 1233, 1233, 1233,
+ /* 20 */ 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1465, 1233, 1233,
+ /* 30 */ 1233, 1233, 1554, 1554, 1233, 1233, 1233, 1233, 1233, 1233,
+ /* 40 */ 1233, 1233, 1383, 1233, 1390, 1233, 1233, 1233, 1233, 1233,
+ /* 50 */ 1467, 1468, 1233, 1233, 1233, 1518, 1520, 1483, 1397, 1396,
+ /* 60 */ 1395, 1394, 1501, 1361, 1388, 1381, 1385, 1461, 1462, 1460,
+ /* 70 */ 1464, 1468, 1467, 1233, 1384, 1431, 1445, 1430, 1233, 1233,
+ /* 80 */ 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233,
+ /* 90 */ 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233,
+ /* 100 */ 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233,
+ /* 110 */ 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233,
+ /* 120 */ 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1439, 1444,
+ /* 130 */ 1451, 1443, 1440, 1433, 1432, 1434, 1435, 1233, 1233, 1257,
+ /* 140 */ 1233, 1233, 1254, 1308, 1233, 1233, 1233, 1233, 1233, 1538,
+ /* 150 */ 1537, 1233, 1436, 1233, 1266, 1425, 1424, 1448, 1437, 1447,
+ /* 160 */ 1446, 1526, 1590, 1589, 1484, 1233, 1233, 1233, 1233, 1233,
+ /* 170 */ 1233, 1554, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233,
+ /* 180 */ 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233,
+ /* 190 */ 1233, 1233, 1233, 1233, 1233, 1554, 1554, 1233, 1266, 1554,
+ /* 200 */ 1554, 1262, 1262, 1368, 1233, 1533, 1335, 1335, 1335, 1335,
+ /* 210 */ 1344, 1335, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233,
+ /* 220 */ 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1523, 1521, 1233,
+ /* 230 */ 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233,
+ /* 240 */ 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233,
+ /* 250 */ 1233, 1233, 1233, 1233, 1233, 1233, 1340, 1233, 1233, 1233,
+ /* 260 */ 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1583, 1233,
+ /* 270 */ 1496, 1322, 1340, 1340, 1340, 1340, 1342, 1323, 1321, 1334,
+ /* 280 */ 1267, 1240, 1629, 1400, 1389, 1341, 1363, 1389, 1363, 1626,
+ /* 290 */ 1387, 1400, 1400, 1387, 1400, 1341, 1626, 1283, 1606, 1278,
+ /* 300 */ 1374, 1374, 1374, 1363, 1368, 1368, 1463, 1341, 1334, 1233,
+ /* 310 */ 1629, 1629, 1349, 1349, 1628, 1628, 1349, 1484, 1613, 1409,
+ /* 320 */ 1311, 1317, 1317, 1317, 1317, 1349, 1251, 1387, 1613, 1613,
+ /* 330 */ 1387, 1409, 1311, 1387, 1311, 1387, 1349, 1251, 1500, 1623,
+ /* 340 */ 1349, 1251, 1474, 1349, 1251, 1349, 1251, 1474, 1309, 1309,
+ /* 350 */ 1309, 1298, 1233, 1233, 1474, 1309, 1283, 1309, 1298, 1309,
+ /* 360 */ 1309, 1572, 1233, 1478, 1478, 1474, 1367, 1362, 1367, 1362,
+ /* 370 */ 1367, 1362, 1367, 1362, 1349, 1564, 1564, 1377, 1377, 1382,
+ /* 380 */ 1368, 1469, 1349, 1233, 1382, 1380, 1378, 1387, 1301, 1586,
+ /* 390 */ 1586, 1582, 1582, 1582, 1634, 1634, 1533, 1599, 1266, 1266,
+ /* 400 */ 1266, 1266, 1599, 1285, 1285, 1267, 1267, 1266, 1599, 1233,
+ /* 410 */ 1233, 1233, 1233, 1233, 1233, 1594, 1233, 1528, 1485, 1353,
+ /* 420 */ 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233,
+ /* 430 */ 1233, 1233, 1233, 1233, 1539, 1233, 1233, 1233, 1233, 1233,
+ /* 440 */ 1233, 1233, 1233, 1233, 1233, 1414, 1233, 1236, 1530, 1233,
+ /* 450 */ 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1391, 1392, 1354,
+ /* 460 */ 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1406, 1233, 1233,
+ /* 470 */ 1233, 1401, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233,
+ /* 480 */ 1625, 1233, 1233, 1233, 1233, 1233, 1233, 1499, 1498, 1233,
+ /* 490 */ 1233, 1351, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233,
+ /* 500 */ 1233, 1233, 1233, 1233, 1233, 1281, 1233, 1233, 1233, 1233,
+ /* 510 */ 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233,
+ /* 520 */ 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1379,
+ /* 530 */ 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233,
+ /* 540 */ 1233, 1233, 1233, 1233, 1569, 1369, 1233, 1233, 1616, 1233,
+ /* 550 */ 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233,
+ /* 560 */ 1233, 1233, 1233, 1610, 1325, 1416, 1233, 1415, 1419, 1255,
+ /* 570 */ 1233, 1245, 1233, 1233,
};
/********** End of lemon-generated parsing tables *****************************/
@@ -160753,6 +162616,7 @@ static const YYCODETYPE yyFallback[] = {
0, /* SLASH => nothing */
0, /* REM => nothing */
0, /* CONCAT => nothing */
+ 0, /* PTR => nothing */
0, /* COLLATE => nothing */
0, /* BITNOT => nothing */
0, /* ON => nothing */
@@ -161025,212 +162889,213 @@ static const char *const yyTokenName[] = {
/* 109 */ "SLASH",
/* 110 */ "REM",
/* 111 */ "CONCAT",
- /* 112 */ "COLLATE",
- /* 113 */ "BITNOT",
- /* 114 */ "ON",
- /* 115 */ "INDEXED",
- /* 116 */ "STRING",
- /* 117 */ "JOIN_KW",
- /* 118 */ "CONSTRAINT",
- /* 119 */ "DEFAULT",
- /* 120 */ "NULL",
- /* 121 */ "PRIMARY",
- /* 122 */ "UNIQUE",
- /* 123 */ "CHECK",
- /* 124 */ "REFERENCES",
- /* 125 */ "AUTOINCR",
- /* 126 */ "INSERT",
- /* 127 */ "DELETE",
- /* 128 */ "UPDATE",
- /* 129 */ "SET",
- /* 130 */ "DEFERRABLE",
- /* 131 */ "FOREIGN",
- /* 132 */ "DROP",
- /* 133 */ "UNION",
- /* 134 */ "ALL",
- /* 135 */ "EXCEPT",
- /* 136 */ "INTERSECT",
- /* 137 */ "SELECT",
- /* 138 */ "VALUES",
- /* 139 */ "DISTINCT",
- /* 140 */ "DOT",
- /* 141 */ "FROM",
- /* 142 */ "JOIN",
- /* 143 */ "USING",
- /* 144 */ "ORDER",
- /* 145 */ "GROUP",
- /* 146 */ "HAVING",
- /* 147 */ "LIMIT",
- /* 148 */ "WHERE",
- /* 149 */ "RETURNING",
- /* 150 */ "INTO",
- /* 151 */ "NOTHING",
- /* 152 */ "FLOAT",
- /* 153 */ "BLOB",
- /* 154 */ "INTEGER",
- /* 155 */ "VARIABLE",
- /* 156 */ "CASE",
- /* 157 */ "WHEN",
- /* 158 */ "THEN",
- /* 159 */ "ELSE",
- /* 160 */ "INDEX",
- /* 161 */ "ALTER",
- /* 162 */ "ADD",
- /* 163 */ "WINDOW",
- /* 164 */ "OVER",
- /* 165 */ "FILTER",
- /* 166 */ "COLUMN",
- /* 167 */ "AGG_FUNCTION",
- /* 168 */ "AGG_COLUMN",
- /* 169 */ "TRUEFALSE",
- /* 170 */ "ISNOT",
- /* 171 */ "FUNCTION",
- /* 172 */ "UMINUS",
- /* 173 */ "UPLUS",
- /* 174 */ "TRUTH",
- /* 175 */ "REGISTER",
- /* 176 */ "VECTOR",
- /* 177 */ "SELECT_COLUMN",
- /* 178 */ "IF_NULL_ROW",
- /* 179 */ "ASTERISK",
- /* 180 */ "SPAN",
- /* 181 */ "ERROR",
- /* 182 */ "SPACE",
- /* 183 */ "ILLEGAL",
- /* 184 */ "input",
- /* 185 */ "cmdlist",
- /* 186 */ "ecmd",
- /* 187 */ "cmdx",
- /* 188 */ "explain",
- /* 189 */ "cmd",
- /* 190 */ "transtype",
- /* 191 */ "trans_opt",
- /* 192 */ "nm",
- /* 193 */ "savepoint_opt",
- /* 194 */ "create_table",
- /* 195 */ "create_table_args",
- /* 196 */ "createkw",
- /* 197 */ "temp",
- /* 198 */ "ifnotexists",
- /* 199 */ "dbnm",
- /* 200 */ "columnlist",
- /* 201 */ "conslist_opt",
- /* 202 */ "table_option_set",
- /* 203 */ "select",
- /* 204 */ "table_option",
- /* 205 */ "columnname",
- /* 206 */ "carglist",
- /* 207 */ "typetoken",
- /* 208 */ "typename",
- /* 209 */ "signed",
- /* 210 */ "plus_num",
- /* 211 */ "minus_num",
- /* 212 */ "scanpt",
- /* 213 */ "scantok",
- /* 214 */ "ccons",
- /* 215 */ "term",
- /* 216 */ "expr",
- /* 217 */ "onconf",
- /* 218 */ "sortorder",
- /* 219 */ "autoinc",
- /* 220 */ "eidlist_opt",
- /* 221 */ "refargs",
- /* 222 */ "defer_subclause",
- /* 223 */ "generated",
- /* 224 */ "refarg",
- /* 225 */ "refact",
- /* 226 */ "init_deferred_pred_opt",
- /* 227 */ "conslist",
- /* 228 */ "tconscomma",
- /* 229 */ "tcons",
- /* 230 */ "sortlist",
- /* 231 */ "eidlist",
- /* 232 */ "defer_subclause_opt",
- /* 233 */ "orconf",
- /* 234 */ "resolvetype",
- /* 235 */ "raisetype",
- /* 236 */ "ifexists",
- /* 237 */ "fullname",
- /* 238 */ "selectnowith",
- /* 239 */ "oneselect",
- /* 240 */ "wqlist",
- /* 241 */ "multiselect_op",
- /* 242 */ "distinct",
- /* 243 */ "selcollist",
- /* 244 */ "from",
- /* 245 */ "where_opt",
- /* 246 */ "groupby_opt",
- /* 247 */ "having_opt",
- /* 248 */ "orderby_opt",
- /* 249 */ "limit_opt",
- /* 250 */ "window_clause",
- /* 251 */ "values",
- /* 252 */ "nexprlist",
- /* 253 */ "sclp",
- /* 254 */ "as",
- /* 255 */ "seltablist",
- /* 256 */ "stl_prefix",
- /* 257 */ "joinop",
- /* 258 */ "indexed_opt",
- /* 259 */ "on_opt",
- /* 260 */ "using_opt",
- /* 261 */ "exprlist",
- /* 262 */ "xfullname",
- /* 263 */ "idlist",
- /* 264 */ "nulls",
- /* 265 */ "with",
- /* 266 */ "where_opt_ret",
- /* 267 */ "setlist",
- /* 268 */ "insert_cmd",
- /* 269 */ "idlist_opt",
- /* 270 */ "upsert",
- /* 271 */ "returning",
- /* 272 */ "filter_over",
- /* 273 */ "likeop",
- /* 274 */ "between_op",
- /* 275 */ "in_op",
- /* 276 */ "paren_exprlist",
- /* 277 */ "case_operand",
- /* 278 */ "case_exprlist",
- /* 279 */ "case_else",
- /* 280 */ "uniqueflag",
- /* 281 */ "collate",
- /* 282 */ "vinto",
- /* 283 */ "nmnum",
- /* 284 */ "trigger_decl",
- /* 285 */ "trigger_cmd_list",
- /* 286 */ "trigger_time",
- /* 287 */ "trigger_event",
- /* 288 */ "foreach_clause",
- /* 289 */ "when_clause",
- /* 290 */ "trigger_cmd",
- /* 291 */ "trnm",
- /* 292 */ "tridxby",
- /* 293 */ "database_kw_opt",
- /* 294 */ "key_opt",
- /* 295 */ "add_column_fullname",
- /* 296 */ "kwcolumn_opt",
- /* 297 */ "create_vtab",
- /* 298 */ "vtabarglist",
- /* 299 */ "vtabarg",
- /* 300 */ "vtabargtoken",
- /* 301 */ "lp",
- /* 302 */ "anylist",
- /* 303 */ "wqitem",
- /* 304 */ "wqas",
- /* 305 */ "windowdefn_list",
- /* 306 */ "windowdefn",
- /* 307 */ "window",
- /* 308 */ "frame_opt",
- /* 309 */ "part_opt",
- /* 310 */ "filter_clause",
- /* 311 */ "over_clause",
- /* 312 */ "range_or_rows",
- /* 313 */ "frame_bound",
- /* 314 */ "frame_bound_s",
- /* 315 */ "frame_bound_e",
- /* 316 */ "frame_exclude_opt",
- /* 317 */ "frame_exclude",
+ /* 112 */ "PTR",
+ /* 113 */ "COLLATE",
+ /* 114 */ "BITNOT",
+ /* 115 */ "ON",
+ /* 116 */ "INDEXED",
+ /* 117 */ "STRING",
+ /* 118 */ "JOIN_KW",
+ /* 119 */ "CONSTRAINT",
+ /* 120 */ "DEFAULT",
+ /* 121 */ "NULL",
+ /* 122 */ "PRIMARY",
+ /* 123 */ "UNIQUE",
+ /* 124 */ "CHECK",
+ /* 125 */ "REFERENCES",
+ /* 126 */ "AUTOINCR",
+ /* 127 */ "INSERT",
+ /* 128 */ "DELETE",
+ /* 129 */ "UPDATE",
+ /* 130 */ "SET",
+ /* 131 */ "DEFERRABLE",
+ /* 132 */ "FOREIGN",
+ /* 133 */ "DROP",
+ /* 134 */ "UNION",
+ /* 135 */ "ALL",
+ /* 136 */ "EXCEPT",
+ /* 137 */ "INTERSECT",
+ /* 138 */ "SELECT",
+ /* 139 */ "VALUES",
+ /* 140 */ "DISTINCT",
+ /* 141 */ "DOT",
+ /* 142 */ "FROM",
+ /* 143 */ "JOIN",
+ /* 144 */ "USING",
+ /* 145 */ "ORDER",
+ /* 146 */ "GROUP",
+ /* 147 */ "HAVING",
+ /* 148 */ "LIMIT",
+ /* 149 */ "WHERE",
+ /* 150 */ "RETURNING",
+ /* 151 */ "INTO",
+ /* 152 */ "NOTHING",
+ /* 153 */ "FLOAT",
+ /* 154 */ "BLOB",
+ /* 155 */ "INTEGER",
+ /* 156 */ "VARIABLE",
+ /* 157 */ "CASE",
+ /* 158 */ "WHEN",
+ /* 159 */ "THEN",
+ /* 160 */ "ELSE",
+ /* 161 */ "INDEX",
+ /* 162 */ "ALTER",
+ /* 163 */ "ADD",
+ /* 164 */ "WINDOW",
+ /* 165 */ "OVER",
+ /* 166 */ "FILTER",
+ /* 167 */ "COLUMN",
+ /* 168 */ "AGG_FUNCTION",
+ /* 169 */ "AGG_COLUMN",
+ /* 170 */ "TRUEFALSE",
+ /* 171 */ "ISNOT",
+ /* 172 */ "FUNCTION",
+ /* 173 */ "UMINUS",
+ /* 174 */ "UPLUS",
+ /* 175 */ "TRUTH",
+ /* 176 */ "REGISTER",
+ /* 177 */ "VECTOR",
+ /* 178 */ "SELECT_COLUMN",
+ /* 179 */ "IF_NULL_ROW",
+ /* 180 */ "ASTERISK",
+ /* 181 */ "SPAN",
+ /* 182 */ "ERROR",
+ /* 183 */ "SPACE",
+ /* 184 */ "ILLEGAL",
+ /* 185 */ "input",
+ /* 186 */ "cmdlist",
+ /* 187 */ "ecmd",
+ /* 188 */ "cmdx",
+ /* 189 */ "explain",
+ /* 190 */ "cmd",
+ /* 191 */ "transtype",
+ /* 192 */ "trans_opt",
+ /* 193 */ "nm",
+ /* 194 */ "savepoint_opt",
+ /* 195 */ "create_table",
+ /* 196 */ "create_table_args",
+ /* 197 */ "createkw",
+ /* 198 */ "temp",
+ /* 199 */ "ifnotexists",
+ /* 200 */ "dbnm",
+ /* 201 */ "columnlist",
+ /* 202 */ "conslist_opt",
+ /* 203 */ "table_option_set",
+ /* 204 */ "select",
+ /* 205 */ "table_option",
+ /* 206 */ "columnname",
+ /* 207 */ "carglist",
+ /* 208 */ "typetoken",
+ /* 209 */ "typename",
+ /* 210 */ "signed",
+ /* 211 */ "plus_num",
+ /* 212 */ "minus_num",
+ /* 213 */ "scanpt",
+ /* 214 */ "scantok",
+ /* 215 */ "ccons",
+ /* 216 */ "term",
+ /* 217 */ "expr",
+ /* 218 */ "onconf",
+ /* 219 */ "sortorder",
+ /* 220 */ "autoinc",
+ /* 221 */ "eidlist_opt",
+ /* 222 */ "refargs",
+ /* 223 */ "defer_subclause",
+ /* 224 */ "generated",
+ /* 225 */ "refarg",
+ /* 226 */ "refact",
+ /* 227 */ "init_deferred_pred_opt",
+ /* 228 */ "conslist",
+ /* 229 */ "tconscomma",
+ /* 230 */ "tcons",
+ /* 231 */ "sortlist",
+ /* 232 */ "eidlist",
+ /* 233 */ "defer_subclause_opt",
+ /* 234 */ "orconf",
+ /* 235 */ "resolvetype",
+ /* 236 */ "raisetype",
+ /* 237 */ "ifexists",
+ /* 238 */ "fullname",
+ /* 239 */ "selectnowith",
+ /* 240 */ "oneselect",
+ /* 241 */ "wqlist",
+ /* 242 */ "multiselect_op",
+ /* 243 */ "distinct",
+ /* 244 */ "selcollist",
+ /* 245 */ "from",
+ /* 246 */ "where_opt",
+ /* 247 */ "groupby_opt",
+ /* 248 */ "having_opt",
+ /* 249 */ "orderby_opt",
+ /* 250 */ "limit_opt",
+ /* 251 */ "window_clause",
+ /* 252 */ "values",
+ /* 253 */ "nexprlist",
+ /* 254 */ "sclp",
+ /* 255 */ "as",
+ /* 256 */ "seltablist",
+ /* 257 */ "stl_prefix",
+ /* 258 */ "joinop",
+ /* 259 */ "indexed_opt",
+ /* 260 */ "on_opt",
+ /* 261 */ "using_opt",
+ /* 262 */ "exprlist",
+ /* 263 */ "xfullname",
+ /* 264 */ "idlist",
+ /* 265 */ "nulls",
+ /* 266 */ "with",
+ /* 267 */ "where_opt_ret",
+ /* 268 */ "setlist",
+ /* 269 */ "insert_cmd",
+ /* 270 */ "idlist_opt",
+ /* 271 */ "upsert",
+ /* 272 */ "returning",
+ /* 273 */ "filter_over",
+ /* 274 */ "likeop",
+ /* 275 */ "between_op",
+ /* 276 */ "in_op",
+ /* 277 */ "paren_exprlist",
+ /* 278 */ "case_operand",
+ /* 279 */ "case_exprlist",
+ /* 280 */ "case_else",
+ /* 281 */ "uniqueflag",
+ /* 282 */ "collate",
+ /* 283 */ "vinto",
+ /* 284 */ "nmnum",
+ /* 285 */ "trigger_decl",
+ /* 286 */ "trigger_cmd_list",
+ /* 287 */ "trigger_time",
+ /* 288 */ "trigger_event",
+ /* 289 */ "foreach_clause",
+ /* 290 */ "when_clause",
+ /* 291 */ "trigger_cmd",
+ /* 292 */ "trnm",
+ /* 293 */ "tridxby",
+ /* 294 */ "database_kw_opt",
+ /* 295 */ "key_opt",
+ /* 296 */ "add_column_fullname",
+ /* 297 */ "kwcolumn_opt",
+ /* 298 */ "create_vtab",
+ /* 299 */ "vtabarglist",
+ /* 300 */ "vtabarg",
+ /* 301 */ "vtabargtoken",
+ /* 302 */ "lp",
+ /* 303 */ "anylist",
+ /* 304 */ "wqitem",
+ /* 305 */ "wqas",
+ /* 306 */ "windowdefn_list",
+ /* 307 */ "windowdefn",
+ /* 308 */ "window",
+ /* 309 */ "frame_opt",
+ /* 310 */ "part_opt",
+ /* 311 */ "filter_clause",
+ /* 312 */ "over_clause",
+ /* 313 */ "range_or_rows",
+ /* 314 */ "frame_bound",
+ /* 315 */ "frame_bound_s",
+ /* 316 */ "frame_bound_e",
+ /* 317 */ "frame_exclude_opt",
+ /* 318 */ "frame_exclude",
};
#endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */
@@ -161450,195 +163315,196 @@ static const char *const yyRuleName[] = {
/* 209 */ "expr ::= NOT expr",
/* 210 */ "expr ::= BITNOT expr",
/* 211 */ "expr ::= PLUS|MINUS expr",
- /* 212 */ "between_op ::= BETWEEN",
- /* 213 */ "between_op ::= NOT BETWEEN",
- /* 214 */ "expr ::= expr between_op expr AND expr",
- /* 215 */ "in_op ::= IN",
- /* 216 */ "in_op ::= NOT IN",
- /* 217 */ "expr ::= expr in_op LP exprlist RP",
- /* 218 */ "expr ::= LP select RP",
- /* 219 */ "expr ::= expr in_op LP select RP",
- /* 220 */ "expr ::= expr in_op nm dbnm paren_exprlist",
- /* 221 */ "expr ::= EXISTS LP select RP",
- /* 222 */ "expr ::= CASE case_operand case_exprlist case_else END",
- /* 223 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr",
- /* 224 */ "case_exprlist ::= WHEN expr THEN expr",
- /* 225 */ "case_else ::= ELSE expr",
- /* 226 */ "case_else ::=",
- /* 227 */ "case_operand ::= expr",
- /* 228 */ "case_operand ::=",
- /* 229 */ "exprlist ::=",
- /* 230 */ "nexprlist ::= nexprlist COMMA expr",
- /* 231 */ "nexprlist ::= expr",
- /* 232 */ "paren_exprlist ::=",
- /* 233 */ "paren_exprlist ::= LP exprlist RP",
- /* 234 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt",
- /* 235 */ "uniqueflag ::= UNIQUE",
- /* 236 */ "uniqueflag ::=",
- /* 237 */ "eidlist_opt ::=",
- /* 238 */ "eidlist_opt ::= LP eidlist RP",
- /* 239 */ "eidlist ::= eidlist COMMA nm collate sortorder",
- /* 240 */ "eidlist ::= nm collate sortorder",
- /* 241 */ "collate ::=",
- /* 242 */ "collate ::= COLLATE ID|STRING",
- /* 243 */ "cmd ::= DROP INDEX ifexists fullname",
- /* 244 */ "cmd ::= VACUUM vinto",
- /* 245 */ "cmd ::= VACUUM nm vinto",
- /* 246 */ "vinto ::= INTO expr",
- /* 247 */ "vinto ::=",
- /* 248 */ "cmd ::= PRAGMA nm dbnm",
- /* 249 */ "cmd ::= PRAGMA nm dbnm EQ nmnum",
- /* 250 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP",
- /* 251 */ "cmd ::= PRAGMA nm dbnm EQ minus_num",
- /* 252 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP",
- /* 253 */ "plus_num ::= PLUS INTEGER|FLOAT",
- /* 254 */ "minus_num ::= MINUS INTEGER|FLOAT",
- /* 255 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
- /* 256 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
- /* 257 */ "trigger_time ::= BEFORE|AFTER",
- /* 258 */ "trigger_time ::= INSTEAD OF",
- /* 259 */ "trigger_time ::=",
- /* 260 */ "trigger_event ::= DELETE|INSERT",
- /* 261 */ "trigger_event ::= UPDATE",
- /* 262 */ "trigger_event ::= UPDATE OF idlist",
- /* 263 */ "when_clause ::=",
- /* 264 */ "when_clause ::= WHEN expr",
- /* 265 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
- /* 266 */ "trigger_cmd_list ::= trigger_cmd SEMI",
- /* 267 */ "trnm ::= nm DOT nm",
- /* 268 */ "tridxby ::= INDEXED BY nm",
- /* 269 */ "tridxby ::= NOT INDEXED",
- /* 270 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt",
- /* 271 */ "trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt",
- /* 272 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt",
- /* 273 */ "trigger_cmd ::= scanpt select scanpt",
- /* 274 */ "expr ::= RAISE LP IGNORE RP",
- /* 275 */ "expr ::= RAISE LP raisetype COMMA nm RP",
- /* 276 */ "raisetype ::= ROLLBACK",
- /* 277 */ "raisetype ::= ABORT",
- /* 278 */ "raisetype ::= FAIL",
- /* 279 */ "cmd ::= DROP TRIGGER ifexists fullname",
- /* 280 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
- /* 281 */ "cmd ::= DETACH database_kw_opt expr",
- /* 282 */ "key_opt ::=",
- /* 283 */ "key_opt ::= KEY expr",
- /* 284 */ "cmd ::= REINDEX",
- /* 285 */ "cmd ::= REINDEX nm dbnm",
- /* 286 */ "cmd ::= ANALYZE",
- /* 287 */ "cmd ::= ANALYZE nm dbnm",
- /* 288 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
- /* 289 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist",
- /* 290 */ "cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm",
- /* 291 */ "add_column_fullname ::= fullname",
- /* 292 */ "cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm",
- /* 293 */ "cmd ::= create_vtab",
- /* 294 */ "cmd ::= create_vtab LP vtabarglist RP",
- /* 295 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
- /* 296 */ "vtabarg ::=",
- /* 297 */ "vtabargtoken ::= ANY",
- /* 298 */ "vtabargtoken ::= lp anylist RP",
- /* 299 */ "lp ::= LP",
- /* 300 */ "with ::= WITH wqlist",
- /* 301 */ "with ::= WITH RECURSIVE wqlist",
- /* 302 */ "wqas ::= AS",
- /* 303 */ "wqas ::= AS MATERIALIZED",
- /* 304 */ "wqas ::= AS NOT MATERIALIZED",
- /* 305 */ "wqitem ::= nm eidlist_opt wqas LP select RP",
- /* 306 */ "wqlist ::= wqitem",
- /* 307 */ "wqlist ::= wqlist COMMA wqitem",
- /* 308 */ "windowdefn_list ::= windowdefn",
- /* 309 */ "windowdefn_list ::= windowdefn_list COMMA windowdefn",
- /* 310 */ "windowdefn ::= nm AS LP window RP",
- /* 311 */ "window ::= PARTITION BY nexprlist orderby_opt frame_opt",
- /* 312 */ "window ::= nm PARTITION BY nexprlist orderby_opt frame_opt",
- /* 313 */ "window ::= ORDER BY sortlist frame_opt",
- /* 314 */ "window ::= nm ORDER BY sortlist frame_opt",
- /* 315 */ "window ::= frame_opt",
- /* 316 */ "window ::= nm frame_opt",
- /* 317 */ "frame_opt ::=",
- /* 318 */ "frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt",
- /* 319 */ "frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt",
- /* 320 */ "range_or_rows ::= RANGE|ROWS|GROUPS",
- /* 321 */ "frame_bound_s ::= frame_bound",
- /* 322 */ "frame_bound_s ::= UNBOUNDED PRECEDING",
- /* 323 */ "frame_bound_e ::= frame_bound",
- /* 324 */ "frame_bound_e ::= UNBOUNDED FOLLOWING",
- /* 325 */ "frame_bound ::= expr PRECEDING|FOLLOWING",
- /* 326 */ "frame_bound ::= CURRENT ROW",
- /* 327 */ "frame_exclude_opt ::=",
- /* 328 */ "frame_exclude_opt ::= EXCLUDE frame_exclude",
- /* 329 */ "frame_exclude ::= NO OTHERS",
- /* 330 */ "frame_exclude ::= CURRENT ROW",
- /* 331 */ "frame_exclude ::= GROUP|TIES",
- /* 332 */ "window_clause ::= WINDOW windowdefn_list",
- /* 333 */ "filter_over ::= filter_clause over_clause",
- /* 334 */ "filter_over ::= over_clause",
- /* 335 */ "filter_over ::= filter_clause",
- /* 336 */ "over_clause ::= OVER LP window RP",
- /* 337 */ "over_clause ::= OVER nm",
- /* 338 */ "filter_clause ::= FILTER LP WHERE expr RP",
- /* 339 */ "input ::= cmdlist",
- /* 340 */ "cmdlist ::= cmdlist ecmd",
- /* 341 */ "cmdlist ::= ecmd",
- /* 342 */ "ecmd ::= SEMI",
- /* 343 */ "ecmd ::= cmdx SEMI",
- /* 344 */ "ecmd ::= explain cmdx SEMI",
- /* 345 */ "trans_opt ::=",
- /* 346 */ "trans_opt ::= TRANSACTION",
- /* 347 */ "trans_opt ::= TRANSACTION nm",
- /* 348 */ "savepoint_opt ::= SAVEPOINT",
- /* 349 */ "savepoint_opt ::=",
- /* 350 */ "cmd ::= create_table create_table_args",
- /* 351 */ "table_option_set ::= table_option",
- /* 352 */ "columnlist ::= columnlist COMMA columnname carglist",
- /* 353 */ "columnlist ::= columnname carglist",
- /* 354 */ "nm ::= ID|INDEXED",
- /* 355 */ "nm ::= STRING",
- /* 356 */ "nm ::= JOIN_KW",
- /* 357 */ "typetoken ::= typename",
- /* 358 */ "typename ::= ID|STRING",
- /* 359 */ "signed ::= plus_num",
- /* 360 */ "signed ::= minus_num",
- /* 361 */ "carglist ::= carglist ccons",
- /* 362 */ "carglist ::=",
- /* 363 */ "ccons ::= NULL onconf",
- /* 364 */ "ccons ::= GENERATED ALWAYS AS generated",
- /* 365 */ "ccons ::= AS generated",
- /* 366 */ "conslist_opt ::= COMMA conslist",
- /* 367 */ "conslist ::= conslist tconscomma tcons",
- /* 368 */ "conslist ::= tcons",
- /* 369 */ "tconscomma ::=",
- /* 370 */ "defer_subclause_opt ::= defer_subclause",
- /* 371 */ "resolvetype ::= raisetype",
- /* 372 */ "selectnowith ::= oneselect",
- /* 373 */ "oneselect ::= values",
- /* 374 */ "sclp ::= selcollist COMMA",
- /* 375 */ "as ::= ID|STRING",
- /* 376 */ "returning ::=",
- /* 377 */ "expr ::= term",
- /* 378 */ "likeop ::= LIKE_KW|MATCH",
- /* 379 */ "exprlist ::= nexprlist",
- /* 380 */ "nmnum ::= plus_num",
- /* 381 */ "nmnum ::= nm",
- /* 382 */ "nmnum ::= ON",
- /* 383 */ "nmnum ::= DELETE",
- /* 384 */ "nmnum ::= DEFAULT",
- /* 385 */ "plus_num ::= INTEGER|FLOAT",
- /* 386 */ "foreach_clause ::=",
- /* 387 */ "foreach_clause ::= FOR EACH ROW",
- /* 388 */ "trnm ::= nm",
- /* 389 */ "tridxby ::=",
- /* 390 */ "database_kw_opt ::= DATABASE",
- /* 391 */ "database_kw_opt ::=",
- /* 392 */ "kwcolumn_opt ::=",
- /* 393 */ "kwcolumn_opt ::= COLUMNKW",
- /* 394 */ "vtabarglist ::= vtabarg",
- /* 395 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
- /* 396 */ "vtabarg ::= vtabarg vtabargtoken",
- /* 397 */ "anylist ::=",
- /* 398 */ "anylist ::= anylist LP anylist RP",
- /* 399 */ "anylist ::= anylist ANY",
- /* 400 */ "with ::=",
+ /* 212 */ "expr ::= expr PTR expr",
+ /* 213 */ "between_op ::= BETWEEN",
+ /* 214 */ "between_op ::= NOT BETWEEN",
+ /* 215 */ "expr ::= expr between_op expr AND expr",
+ /* 216 */ "in_op ::= IN",
+ /* 217 */ "in_op ::= NOT IN",
+ /* 218 */ "expr ::= expr in_op LP exprlist RP",
+ /* 219 */ "expr ::= LP select RP",
+ /* 220 */ "expr ::= expr in_op LP select RP",
+ /* 221 */ "expr ::= expr in_op nm dbnm paren_exprlist",
+ /* 222 */ "expr ::= EXISTS LP select RP",
+ /* 223 */ "expr ::= CASE case_operand case_exprlist case_else END",
+ /* 224 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr",
+ /* 225 */ "case_exprlist ::= WHEN expr THEN expr",
+ /* 226 */ "case_else ::= ELSE expr",
+ /* 227 */ "case_else ::=",
+ /* 228 */ "case_operand ::= expr",
+ /* 229 */ "case_operand ::=",
+ /* 230 */ "exprlist ::=",
+ /* 231 */ "nexprlist ::= nexprlist COMMA expr",
+ /* 232 */ "nexprlist ::= expr",
+ /* 233 */ "paren_exprlist ::=",
+ /* 234 */ "paren_exprlist ::= LP exprlist RP",
+ /* 235 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt",
+ /* 236 */ "uniqueflag ::= UNIQUE",
+ /* 237 */ "uniqueflag ::=",
+ /* 238 */ "eidlist_opt ::=",
+ /* 239 */ "eidlist_opt ::= LP eidlist RP",
+ /* 240 */ "eidlist ::= eidlist COMMA nm collate sortorder",
+ /* 241 */ "eidlist ::= nm collate sortorder",
+ /* 242 */ "collate ::=",
+ /* 243 */ "collate ::= COLLATE ID|STRING",
+ /* 244 */ "cmd ::= DROP INDEX ifexists fullname",
+ /* 245 */ "cmd ::= VACUUM vinto",
+ /* 246 */ "cmd ::= VACUUM nm vinto",
+ /* 247 */ "vinto ::= INTO expr",
+ /* 248 */ "vinto ::=",
+ /* 249 */ "cmd ::= PRAGMA nm dbnm",
+ /* 250 */ "cmd ::= PRAGMA nm dbnm EQ nmnum",
+ /* 251 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP",
+ /* 252 */ "cmd ::= PRAGMA nm dbnm EQ minus_num",
+ /* 253 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP",
+ /* 254 */ "plus_num ::= PLUS INTEGER|FLOAT",
+ /* 255 */ "minus_num ::= MINUS INTEGER|FLOAT",
+ /* 256 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
+ /* 257 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
+ /* 258 */ "trigger_time ::= BEFORE|AFTER",
+ /* 259 */ "trigger_time ::= INSTEAD OF",
+ /* 260 */ "trigger_time ::=",
+ /* 261 */ "trigger_event ::= DELETE|INSERT",
+ /* 262 */ "trigger_event ::= UPDATE",
+ /* 263 */ "trigger_event ::= UPDATE OF idlist",
+ /* 264 */ "when_clause ::=",
+ /* 265 */ "when_clause ::= WHEN expr",
+ /* 266 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
+ /* 267 */ "trigger_cmd_list ::= trigger_cmd SEMI",
+ /* 268 */ "trnm ::= nm DOT nm",
+ /* 269 */ "tridxby ::= INDEXED BY nm",
+ /* 270 */ "tridxby ::= NOT INDEXED",
+ /* 271 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt",
+ /* 272 */ "trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt",
+ /* 273 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt",
+ /* 274 */ "trigger_cmd ::= scanpt select scanpt",
+ /* 275 */ "expr ::= RAISE LP IGNORE RP",
+ /* 276 */ "expr ::= RAISE LP raisetype COMMA nm RP",
+ /* 277 */ "raisetype ::= ROLLBACK",
+ /* 278 */ "raisetype ::= ABORT",
+ /* 279 */ "raisetype ::= FAIL",
+ /* 280 */ "cmd ::= DROP TRIGGER ifexists fullname",
+ /* 281 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
+ /* 282 */ "cmd ::= DETACH database_kw_opt expr",
+ /* 283 */ "key_opt ::=",
+ /* 284 */ "key_opt ::= KEY expr",
+ /* 285 */ "cmd ::= REINDEX",
+ /* 286 */ "cmd ::= REINDEX nm dbnm",
+ /* 287 */ "cmd ::= ANALYZE",
+ /* 288 */ "cmd ::= ANALYZE nm dbnm",
+ /* 289 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
+ /* 290 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist",
+ /* 291 */ "cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm",
+ /* 292 */ "add_column_fullname ::= fullname",
+ /* 293 */ "cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm",
+ /* 294 */ "cmd ::= create_vtab",
+ /* 295 */ "cmd ::= create_vtab LP vtabarglist RP",
+ /* 296 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
+ /* 297 */ "vtabarg ::=",
+ /* 298 */ "vtabargtoken ::= ANY",
+ /* 299 */ "vtabargtoken ::= lp anylist RP",
+ /* 300 */ "lp ::= LP",
+ /* 301 */ "with ::= WITH wqlist",
+ /* 302 */ "with ::= WITH RECURSIVE wqlist",
+ /* 303 */ "wqas ::= AS",
+ /* 304 */ "wqas ::= AS MATERIALIZED",
+ /* 305 */ "wqas ::= AS NOT MATERIALIZED",
+ /* 306 */ "wqitem ::= nm eidlist_opt wqas LP select RP",
+ /* 307 */ "wqlist ::= wqitem",
+ /* 308 */ "wqlist ::= wqlist COMMA wqitem",
+ /* 309 */ "windowdefn_list ::= windowdefn",
+ /* 310 */ "windowdefn_list ::= windowdefn_list COMMA windowdefn",
+ /* 311 */ "windowdefn ::= nm AS LP window RP",
+ /* 312 */ "window ::= PARTITION BY nexprlist orderby_opt frame_opt",
+ /* 313 */ "window ::= nm PARTITION BY nexprlist orderby_opt frame_opt",
+ /* 314 */ "window ::= ORDER BY sortlist frame_opt",
+ /* 315 */ "window ::= nm ORDER BY sortlist frame_opt",
+ /* 316 */ "window ::= frame_opt",
+ /* 317 */ "window ::= nm frame_opt",
+ /* 318 */ "frame_opt ::=",
+ /* 319 */ "frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt",
+ /* 320 */ "frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt",
+ /* 321 */ "range_or_rows ::= RANGE|ROWS|GROUPS",
+ /* 322 */ "frame_bound_s ::= frame_bound",
+ /* 323 */ "frame_bound_s ::= UNBOUNDED PRECEDING",
+ /* 324 */ "frame_bound_e ::= frame_bound",
+ /* 325 */ "frame_bound_e ::= UNBOUNDED FOLLOWING",
+ /* 326 */ "frame_bound ::= expr PRECEDING|FOLLOWING",
+ /* 327 */ "frame_bound ::= CURRENT ROW",
+ /* 328 */ "frame_exclude_opt ::=",
+ /* 329 */ "frame_exclude_opt ::= EXCLUDE frame_exclude",
+ /* 330 */ "frame_exclude ::= NO OTHERS",
+ /* 331 */ "frame_exclude ::= CURRENT ROW",
+ /* 332 */ "frame_exclude ::= GROUP|TIES",
+ /* 333 */ "window_clause ::= WINDOW windowdefn_list",
+ /* 334 */ "filter_over ::= filter_clause over_clause",
+ /* 335 */ "filter_over ::= over_clause",
+ /* 336 */ "filter_over ::= filter_clause",
+ /* 337 */ "over_clause ::= OVER LP window RP",
+ /* 338 */ "over_clause ::= OVER nm",
+ /* 339 */ "filter_clause ::= FILTER LP WHERE expr RP",
+ /* 340 */ "input ::= cmdlist",
+ /* 341 */ "cmdlist ::= cmdlist ecmd",
+ /* 342 */ "cmdlist ::= ecmd",
+ /* 343 */ "ecmd ::= SEMI",
+ /* 344 */ "ecmd ::= cmdx SEMI",
+ /* 345 */ "ecmd ::= explain cmdx SEMI",
+ /* 346 */ "trans_opt ::=",
+ /* 347 */ "trans_opt ::= TRANSACTION",
+ /* 348 */ "trans_opt ::= TRANSACTION nm",
+ /* 349 */ "savepoint_opt ::= SAVEPOINT",
+ /* 350 */ "savepoint_opt ::=",
+ /* 351 */ "cmd ::= create_table create_table_args",
+ /* 352 */ "table_option_set ::= table_option",
+ /* 353 */ "columnlist ::= columnlist COMMA columnname carglist",
+ /* 354 */ "columnlist ::= columnname carglist",
+ /* 355 */ "nm ::= ID|INDEXED",
+ /* 356 */ "nm ::= STRING",
+ /* 357 */ "nm ::= JOIN_KW",
+ /* 358 */ "typetoken ::= typename",
+ /* 359 */ "typename ::= ID|STRING",
+ /* 360 */ "signed ::= plus_num",
+ /* 361 */ "signed ::= minus_num",
+ /* 362 */ "carglist ::= carglist ccons",
+ /* 363 */ "carglist ::=",
+ /* 364 */ "ccons ::= NULL onconf",
+ /* 365 */ "ccons ::= GENERATED ALWAYS AS generated",
+ /* 366 */ "ccons ::= AS generated",
+ /* 367 */ "conslist_opt ::= COMMA conslist",
+ /* 368 */ "conslist ::= conslist tconscomma tcons",
+ /* 369 */ "conslist ::= tcons",
+ /* 370 */ "tconscomma ::=",
+ /* 371 */ "defer_subclause_opt ::= defer_subclause",
+ /* 372 */ "resolvetype ::= raisetype",
+ /* 373 */ "selectnowith ::= oneselect",
+ /* 374 */ "oneselect ::= values",
+ /* 375 */ "sclp ::= selcollist COMMA",
+ /* 376 */ "as ::= ID|STRING",
+ /* 377 */ "returning ::=",
+ /* 378 */ "expr ::= term",
+ /* 379 */ "likeop ::= LIKE_KW|MATCH",
+ /* 380 */ "exprlist ::= nexprlist",
+ /* 381 */ "nmnum ::= plus_num",
+ /* 382 */ "nmnum ::= nm",
+ /* 383 */ "nmnum ::= ON",
+ /* 384 */ "nmnum ::= DELETE",
+ /* 385 */ "nmnum ::= DEFAULT",
+ /* 386 */ "plus_num ::= INTEGER|FLOAT",
+ /* 387 */ "foreach_clause ::=",
+ /* 388 */ "foreach_clause ::= FOR EACH ROW",
+ /* 389 */ "trnm ::= nm",
+ /* 390 */ "tridxby ::=",
+ /* 391 */ "database_kw_opt ::= DATABASE",
+ /* 392 */ "database_kw_opt ::=",
+ /* 393 */ "kwcolumn_opt ::=",
+ /* 394 */ "kwcolumn_opt ::= COLUMNKW",
+ /* 395 */ "vtabarglist ::= vtabarg",
+ /* 396 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
+ /* 397 */ "vtabarg ::= vtabarg vtabargtoken",
+ /* 398 */ "anylist ::=",
+ /* 399 */ "anylist ::= anylist LP anylist RP",
+ /* 400 */ "anylist ::= anylist ANY",
+ /* 401 */ "with ::=",
};
#endif /* NDEBUG */
@@ -161764,99 +163630,99 @@ static void yy_destructor(
** inside the C code.
*/
/********* Begin destructor definitions ***************************************/
- case 203: /* select */
- case 238: /* selectnowith */
- case 239: /* oneselect */
- case 251: /* values */
+ case 204: /* select */
+ case 239: /* selectnowith */
+ case 240: /* oneselect */
+ case 252: /* values */
{
-sqlite3SelectDelete(pParse->db, (yypminor->yy303));
-}
- break;
- case 215: /* term */
- case 216: /* expr */
- case 245: /* where_opt */
- case 247: /* having_opt */
- case 259: /* on_opt */
- case 266: /* where_opt_ret */
- case 277: /* case_operand */
- case 279: /* case_else */
- case 282: /* vinto */
- case 289: /* when_clause */
- case 294: /* key_opt */
- case 310: /* filter_clause */
+sqlite3SelectDelete(pParse->db, (yypminor->yy47));
+}
+ break;
+ case 216: /* term */
+ case 217: /* expr */
+ case 246: /* where_opt */
+ case 248: /* having_opt */
+ case 260: /* on_opt */
+ case 267: /* where_opt_ret */
+ case 278: /* case_operand */
+ case 280: /* case_else */
+ case 283: /* vinto */
+ case 290: /* when_clause */
+ case 295: /* key_opt */
+ case 311: /* filter_clause */
{
-sqlite3ExprDelete(pParse->db, (yypminor->yy626));
-}
- break;
- case 220: /* eidlist_opt */
- case 230: /* sortlist */
- case 231: /* eidlist */
- case 243: /* selcollist */
- case 246: /* groupby_opt */
- case 248: /* orderby_opt */
- case 252: /* nexprlist */
- case 253: /* sclp */
- case 261: /* exprlist */
- case 267: /* setlist */
- case 276: /* paren_exprlist */
- case 278: /* case_exprlist */
- case 309: /* part_opt */
+sqlite3ExprDelete(pParse->db, (yypminor->yy528));
+}
+ break;
+ case 221: /* eidlist_opt */
+ case 231: /* sortlist */
+ case 232: /* eidlist */
+ case 244: /* selcollist */
+ case 247: /* groupby_opt */
+ case 249: /* orderby_opt */
+ case 253: /* nexprlist */
+ case 254: /* sclp */
+ case 262: /* exprlist */
+ case 268: /* setlist */
+ case 277: /* paren_exprlist */
+ case 279: /* case_exprlist */
+ case 310: /* part_opt */
{
-sqlite3ExprListDelete(pParse->db, (yypminor->yy562));
+sqlite3ExprListDelete(pParse->db, (yypminor->yy322));
}
break;
- case 237: /* fullname */
- case 244: /* from */
- case 255: /* seltablist */
- case 256: /* stl_prefix */
- case 262: /* xfullname */
+ case 238: /* fullname */
+ case 245: /* from */
+ case 256: /* seltablist */
+ case 257: /* stl_prefix */
+ case 263: /* xfullname */
{
-sqlite3SrcListDelete(pParse->db, (yypminor->yy607));
+sqlite3SrcListDelete(pParse->db, (yypminor->yy131));
}
break;
- case 240: /* wqlist */
+ case 241: /* wqlist */
{
-sqlite3WithDelete(pParse->db, (yypminor->yy43));
+sqlite3WithDelete(pParse->db, (yypminor->yy521));
}
break;
- case 250: /* window_clause */
- case 305: /* windowdefn_list */
+ case 251: /* window_clause */
+ case 306: /* windowdefn_list */
{
-sqlite3WindowListDelete(pParse->db, (yypminor->yy375));
+sqlite3WindowListDelete(pParse->db, (yypminor->yy41));
}
break;
- case 260: /* using_opt */
- case 263: /* idlist */
- case 269: /* idlist_opt */
+ case 261: /* using_opt */
+ case 264: /* idlist */
+ case 270: /* idlist_opt */
{
-sqlite3IdListDelete(pParse->db, (yypminor->yy240));
+sqlite3IdListDelete(pParse->db, (yypminor->yy254));
}
break;
- case 272: /* filter_over */
- case 306: /* windowdefn */
- case 307: /* window */
- case 308: /* frame_opt */
- case 311: /* over_clause */
+ case 273: /* filter_over */
+ case 307: /* windowdefn */
+ case 308: /* window */
+ case 309: /* frame_opt */
+ case 312: /* over_clause */
{
-sqlite3WindowDelete(pParse->db, (yypminor->yy375));
+sqlite3WindowDelete(pParse->db, (yypminor->yy41));
}
break;
- case 285: /* trigger_cmd_list */
- case 290: /* trigger_cmd */
+ case 286: /* trigger_cmd_list */
+ case 291: /* trigger_cmd */
{
-sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy95));
+sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy33));
}
break;
- case 287: /* trigger_event */
+ case 288: /* trigger_event */
{
-sqlite3IdListDelete(pParse->db, (yypminor->yy570).b);
+sqlite3IdListDelete(pParse->db, (yypminor->yy180).b);
}
break;
- case 313: /* frame_bound */
- case 314: /* frame_bound_s */
- case 315: /* frame_bound_e */
+ case 314: /* frame_bound */
+ case 315: /* frame_bound_s */
+ case 316: /* frame_bound_e */
{
-sqlite3ExprDelete(pParse->db, (yypminor->yy81).pExpr);
+sqlite3ExprDelete(pParse->db, (yypminor->yy595).pExpr);
}
break;
/********* End destructor definitions *****************************************/
@@ -162147,407 +164013,408 @@ static void yy_shift(
/* For rule J, yyRuleInfoLhs[J] contains the symbol on the left-hand side
** of that rule */
static const YYCODETYPE yyRuleInfoLhs[] = {
- 188, /* (0) explain ::= EXPLAIN */
- 188, /* (1) explain ::= EXPLAIN QUERY PLAN */
- 187, /* (2) cmdx ::= cmd */
- 189, /* (3) cmd ::= BEGIN transtype trans_opt */
- 190, /* (4) transtype ::= */
- 190, /* (5) transtype ::= DEFERRED */
- 190, /* (6) transtype ::= IMMEDIATE */
- 190, /* (7) transtype ::= EXCLUSIVE */
- 189, /* (8) cmd ::= COMMIT|END trans_opt */
- 189, /* (9) cmd ::= ROLLBACK trans_opt */
- 189, /* (10) cmd ::= SAVEPOINT nm */
- 189, /* (11) cmd ::= RELEASE savepoint_opt nm */
- 189, /* (12) cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */
- 194, /* (13) create_table ::= createkw temp TABLE ifnotexists nm dbnm */
- 196, /* (14) createkw ::= CREATE */
- 198, /* (15) ifnotexists ::= */
- 198, /* (16) ifnotexists ::= IF NOT EXISTS */
- 197, /* (17) temp ::= TEMP */
- 197, /* (18) temp ::= */
- 195, /* (19) create_table_args ::= LP columnlist conslist_opt RP table_option_set */
- 195, /* (20) create_table_args ::= AS select */
- 202, /* (21) table_option_set ::= */
- 202, /* (22) table_option_set ::= table_option_set COMMA table_option */
- 204, /* (23) table_option ::= WITHOUT nm */
- 204, /* (24) table_option ::= nm */
- 205, /* (25) columnname ::= nm typetoken */
- 207, /* (26) typetoken ::= */
- 207, /* (27) typetoken ::= typename LP signed RP */
- 207, /* (28) typetoken ::= typename LP signed COMMA signed RP */
- 208, /* (29) typename ::= typename ID|STRING */
- 212, /* (30) scanpt ::= */
- 213, /* (31) scantok ::= */
- 214, /* (32) ccons ::= CONSTRAINT nm */
- 214, /* (33) ccons ::= DEFAULT scantok term */
- 214, /* (34) ccons ::= DEFAULT LP expr RP */
- 214, /* (35) ccons ::= DEFAULT PLUS scantok term */
- 214, /* (36) ccons ::= DEFAULT MINUS scantok term */
- 214, /* (37) ccons ::= DEFAULT scantok ID|INDEXED */
- 214, /* (38) ccons ::= NOT NULL onconf */
- 214, /* (39) ccons ::= PRIMARY KEY sortorder onconf autoinc */
- 214, /* (40) ccons ::= UNIQUE onconf */
- 214, /* (41) ccons ::= CHECK LP expr RP */
- 214, /* (42) ccons ::= REFERENCES nm eidlist_opt refargs */
- 214, /* (43) ccons ::= defer_subclause */
- 214, /* (44) ccons ::= COLLATE ID|STRING */
- 223, /* (45) generated ::= LP expr RP */
- 223, /* (46) generated ::= LP expr RP ID */
- 219, /* (47) autoinc ::= */
- 219, /* (48) autoinc ::= AUTOINCR */
- 221, /* (49) refargs ::= */
- 221, /* (50) refargs ::= refargs refarg */
- 224, /* (51) refarg ::= MATCH nm */
- 224, /* (52) refarg ::= ON INSERT refact */
- 224, /* (53) refarg ::= ON DELETE refact */
- 224, /* (54) refarg ::= ON UPDATE refact */
- 225, /* (55) refact ::= SET NULL */
- 225, /* (56) refact ::= SET DEFAULT */
- 225, /* (57) refact ::= CASCADE */
- 225, /* (58) refact ::= RESTRICT */
- 225, /* (59) refact ::= NO ACTION */
- 222, /* (60) defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
- 222, /* (61) defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
- 226, /* (62) init_deferred_pred_opt ::= */
- 226, /* (63) init_deferred_pred_opt ::= INITIALLY DEFERRED */
- 226, /* (64) init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
- 201, /* (65) conslist_opt ::= */
- 228, /* (66) tconscomma ::= COMMA */
- 229, /* (67) tcons ::= CONSTRAINT nm */
- 229, /* (68) tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
- 229, /* (69) tcons ::= UNIQUE LP sortlist RP onconf */
- 229, /* (70) tcons ::= CHECK LP expr RP onconf */
- 229, /* (71) tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
- 232, /* (72) defer_subclause_opt ::= */
- 217, /* (73) onconf ::= */
- 217, /* (74) onconf ::= ON CONFLICT resolvetype */
- 233, /* (75) orconf ::= */
- 233, /* (76) orconf ::= OR resolvetype */
- 234, /* (77) resolvetype ::= IGNORE */
- 234, /* (78) resolvetype ::= REPLACE */
- 189, /* (79) cmd ::= DROP TABLE ifexists fullname */
- 236, /* (80) ifexists ::= IF EXISTS */
- 236, /* (81) ifexists ::= */
- 189, /* (82) cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
- 189, /* (83) cmd ::= DROP VIEW ifexists fullname */
- 189, /* (84) cmd ::= select */
- 203, /* (85) select ::= WITH wqlist selectnowith */
- 203, /* (86) select ::= WITH RECURSIVE wqlist selectnowith */
- 203, /* (87) select ::= selectnowith */
- 238, /* (88) selectnowith ::= selectnowith multiselect_op oneselect */
- 241, /* (89) multiselect_op ::= UNION */
- 241, /* (90) multiselect_op ::= UNION ALL */
- 241, /* (91) multiselect_op ::= EXCEPT|INTERSECT */
- 239, /* (92) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
- 239, /* (93) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */
- 251, /* (94) values ::= VALUES LP nexprlist RP */
- 251, /* (95) values ::= values COMMA LP nexprlist RP */
- 242, /* (96) distinct ::= DISTINCT */
- 242, /* (97) distinct ::= ALL */
- 242, /* (98) distinct ::= */
- 253, /* (99) sclp ::= */
- 243, /* (100) selcollist ::= sclp scanpt expr scanpt as */
- 243, /* (101) selcollist ::= sclp scanpt STAR */
- 243, /* (102) selcollist ::= sclp scanpt nm DOT STAR */
- 254, /* (103) as ::= AS nm */
- 254, /* (104) as ::= */
- 244, /* (105) from ::= */
- 244, /* (106) from ::= FROM seltablist */
- 256, /* (107) stl_prefix ::= seltablist joinop */
- 256, /* (108) stl_prefix ::= */
- 255, /* (109) seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
- 255, /* (110) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
- 255, /* (111) seltablist ::= stl_prefix LP select RP as on_opt using_opt */
- 255, /* (112) seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
- 199, /* (113) dbnm ::= */
- 199, /* (114) dbnm ::= DOT nm */
- 237, /* (115) fullname ::= nm */
- 237, /* (116) fullname ::= nm DOT nm */
- 262, /* (117) xfullname ::= nm */
- 262, /* (118) xfullname ::= nm DOT nm */
- 262, /* (119) xfullname ::= nm DOT nm AS nm */
- 262, /* (120) xfullname ::= nm AS nm */
- 257, /* (121) joinop ::= COMMA|JOIN */
- 257, /* (122) joinop ::= JOIN_KW JOIN */
- 257, /* (123) joinop ::= JOIN_KW nm JOIN */
- 257, /* (124) joinop ::= JOIN_KW nm nm JOIN */
- 259, /* (125) on_opt ::= ON expr */
- 259, /* (126) on_opt ::= */
- 258, /* (127) indexed_opt ::= */
- 258, /* (128) indexed_opt ::= INDEXED BY nm */
- 258, /* (129) indexed_opt ::= NOT INDEXED */
- 260, /* (130) using_opt ::= USING LP idlist RP */
- 260, /* (131) using_opt ::= */
- 248, /* (132) orderby_opt ::= */
- 248, /* (133) orderby_opt ::= ORDER BY sortlist */
- 230, /* (134) sortlist ::= sortlist COMMA expr sortorder nulls */
- 230, /* (135) sortlist ::= expr sortorder nulls */
- 218, /* (136) sortorder ::= ASC */
- 218, /* (137) sortorder ::= DESC */
- 218, /* (138) sortorder ::= */
- 264, /* (139) nulls ::= NULLS FIRST */
- 264, /* (140) nulls ::= NULLS LAST */
- 264, /* (141) nulls ::= */
- 246, /* (142) groupby_opt ::= */
- 246, /* (143) groupby_opt ::= GROUP BY nexprlist */
- 247, /* (144) having_opt ::= */
- 247, /* (145) having_opt ::= HAVING expr */
- 249, /* (146) limit_opt ::= */
- 249, /* (147) limit_opt ::= LIMIT expr */
- 249, /* (148) limit_opt ::= LIMIT expr OFFSET expr */
- 249, /* (149) limit_opt ::= LIMIT expr COMMA expr */
- 189, /* (150) cmd ::= with DELETE FROM xfullname indexed_opt where_opt_ret */
- 245, /* (151) where_opt ::= */
- 245, /* (152) where_opt ::= WHERE expr */
- 266, /* (153) where_opt_ret ::= */
- 266, /* (154) where_opt_ret ::= WHERE expr */
- 266, /* (155) where_opt_ret ::= RETURNING selcollist */
- 266, /* (156) where_opt_ret ::= WHERE expr RETURNING selcollist */
- 189, /* (157) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist from where_opt_ret */
- 267, /* (158) setlist ::= setlist COMMA nm EQ expr */
- 267, /* (159) setlist ::= setlist COMMA LP idlist RP EQ expr */
- 267, /* (160) setlist ::= nm EQ expr */
- 267, /* (161) setlist ::= LP idlist RP EQ expr */
- 189, /* (162) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
- 189, /* (163) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES returning */
- 270, /* (164) upsert ::= */
- 270, /* (165) upsert ::= RETURNING selcollist */
- 270, /* (166) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt upsert */
- 270, /* (167) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING upsert */
- 270, /* (168) upsert ::= ON CONFLICT DO NOTHING returning */
- 270, /* (169) upsert ::= ON CONFLICT DO UPDATE SET setlist where_opt returning */
- 271, /* (170) returning ::= RETURNING selcollist */
- 268, /* (171) insert_cmd ::= INSERT orconf */
- 268, /* (172) insert_cmd ::= REPLACE */
- 269, /* (173) idlist_opt ::= */
- 269, /* (174) idlist_opt ::= LP idlist RP */
- 263, /* (175) idlist ::= idlist COMMA nm */
- 263, /* (176) idlist ::= nm */
- 216, /* (177) expr ::= LP expr RP */
- 216, /* (178) expr ::= ID|INDEXED */
- 216, /* (179) expr ::= JOIN_KW */
- 216, /* (180) expr ::= nm DOT nm */
- 216, /* (181) expr ::= nm DOT nm DOT nm */
- 215, /* (182) term ::= NULL|FLOAT|BLOB */
- 215, /* (183) term ::= STRING */
- 215, /* (184) term ::= INTEGER */
- 216, /* (185) expr ::= VARIABLE */
- 216, /* (186) expr ::= expr COLLATE ID|STRING */
- 216, /* (187) expr ::= CAST LP expr AS typetoken RP */
- 216, /* (188) expr ::= ID|INDEXED LP distinct exprlist RP */
- 216, /* (189) expr ::= ID|INDEXED LP STAR RP */
- 216, /* (190) expr ::= ID|INDEXED LP distinct exprlist RP filter_over */
- 216, /* (191) expr ::= ID|INDEXED LP STAR RP filter_over */
- 215, /* (192) term ::= CTIME_KW */
- 216, /* (193) expr ::= LP nexprlist COMMA expr RP */
- 216, /* (194) expr ::= expr AND expr */
- 216, /* (195) expr ::= expr OR expr */
- 216, /* (196) expr ::= expr LT|GT|GE|LE expr */
- 216, /* (197) expr ::= expr EQ|NE expr */
- 216, /* (198) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */
- 216, /* (199) expr ::= expr PLUS|MINUS expr */
- 216, /* (200) expr ::= expr STAR|SLASH|REM expr */
- 216, /* (201) expr ::= expr CONCAT expr */
- 273, /* (202) likeop ::= NOT LIKE_KW|MATCH */
- 216, /* (203) expr ::= expr likeop expr */
- 216, /* (204) expr ::= expr likeop expr ESCAPE expr */
- 216, /* (205) expr ::= expr ISNULL|NOTNULL */
- 216, /* (206) expr ::= expr NOT NULL */
- 216, /* (207) expr ::= expr IS expr */
- 216, /* (208) expr ::= expr IS NOT expr */
- 216, /* (209) expr ::= NOT expr */
- 216, /* (210) expr ::= BITNOT expr */
- 216, /* (211) expr ::= PLUS|MINUS expr */
- 274, /* (212) between_op ::= BETWEEN */
- 274, /* (213) between_op ::= NOT BETWEEN */
- 216, /* (214) expr ::= expr between_op expr AND expr */
- 275, /* (215) in_op ::= IN */
- 275, /* (216) in_op ::= NOT IN */
- 216, /* (217) expr ::= expr in_op LP exprlist RP */
- 216, /* (218) expr ::= LP select RP */
- 216, /* (219) expr ::= expr in_op LP select RP */
- 216, /* (220) expr ::= expr in_op nm dbnm paren_exprlist */
- 216, /* (221) expr ::= EXISTS LP select RP */
- 216, /* (222) expr ::= CASE case_operand case_exprlist case_else END */
- 278, /* (223) case_exprlist ::= case_exprlist WHEN expr THEN expr */
- 278, /* (224) case_exprlist ::= WHEN expr THEN expr */
- 279, /* (225) case_else ::= ELSE expr */
- 279, /* (226) case_else ::= */
- 277, /* (227) case_operand ::= expr */
- 277, /* (228) case_operand ::= */
- 261, /* (229) exprlist ::= */
- 252, /* (230) nexprlist ::= nexprlist COMMA expr */
- 252, /* (231) nexprlist ::= expr */
- 276, /* (232) paren_exprlist ::= */
- 276, /* (233) paren_exprlist ::= LP exprlist RP */
- 189, /* (234) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
- 280, /* (235) uniqueflag ::= UNIQUE */
- 280, /* (236) uniqueflag ::= */
- 220, /* (237) eidlist_opt ::= */
- 220, /* (238) eidlist_opt ::= LP eidlist RP */
- 231, /* (239) eidlist ::= eidlist COMMA nm collate sortorder */
- 231, /* (240) eidlist ::= nm collate sortorder */
- 281, /* (241) collate ::= */
- 281, /* (242) collate ::= COLLATE ID|STRING */
- 189, /* (243) cmd ::= DROP INDEX ifexists fullname */
- 189, /* (244) cmd ::= VACUUM vinto */
- 189, /* (245) cmd ::= VACUUM nm vinto */
- 282, /* (246) vinto ::= INTO expr */
- 282, /* (247) vinto ::= */
- 189, /* (248) cmd ::= PRAGMA nm dbnm */
- 189, /* (249) cmd ::= PRAGMA nm dbnm EQ nmnum */
- 189, /* (250) cmd ::= PRAGMA nm dbnm LP nmnum RP */
- 189, /* (251) cmd ::= PRAGMA nm dbnm EQ minus_num */
- 189, /* (252) cmd ::= PRAGMA nm dbnm LP minus_num RP */
- 210, /* (253) plus_num ::= PLUS INTEGER|FLOAT */
- 211, /* (254) minus_num ::= MINUS INTEGER|FLOAT */
- 189, /* (255) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
- 284, /* (256) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
- 286, /* (257) trigger_time ::= BEFORE|AFTER */
- 286, /* (258) trigger_time ::= INSTEAD OF */
- 286, /* (259) trigger_time ::= */
- 287, /* (260) trigger_event ::= DELETE|INSERT */
- 287, /* (261) trigger_event ::= UPDATE */
- 287, /* (262) trigger_event ::= UPDATE OF idlist */
- 289, /* (263) when_clause ::= */
- 289, /* (264) when_clause ::= WHEN expr */
- 285, /* (265) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
- 285, /* (266) trigger_cmd_list ::= trigger_cmd SEMI */
- 291, /* (267) trnm ::= nm DOT nm */
- 292, /* (268) tridxby ::= INDEXED BY nm */
- 292, /* (269) tridxby ::= NOT INDEXED */
- 290, /* (270) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */
- 290, /* (271) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
- 290, /* (272) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
- 290, /* (273) trigger_cmd ::= scanpt select scanpt */
- 216, /* (274) expr ::= RAISE LP IGNORE RP */
- 216, /* (275) expr ::= RAISE LP raisetype COMMA nm RP */
- 235, /* (276) raisetype ::= ROLLBACK */
- 235, /* (277) raisetype ::= ABORT */
- 235, /* (278) raisetype ::= FAIL */
- 189, /* (279) cmd ::= DROP TRIGGER ifexists fullname */
- 189, /* (280) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
- 189, /* (281) cmd ::= DETACH database_kw_opt expr */
- 294, /* (282) key_opt ::= */
- 294, /* (283) key_opt ::= KEY expr */
- 189, /* (284) cmd ::= REINDEX */
- 189, /* (285) cmd ::= REINDEX nm dbnm */
- 189, /* (286) cmd ::= ANALYZE */
- 189, /* (287) cmd ::= ANALYZE nm dbnm */
- 189, /* (288) cmd ::= ALTER TABLE fullname RENAME TO nm */
- 189, /* (289) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
- 189, /* (290) cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */
- 295, /* (291) add_column_fullname ::= fullname */
- 189, /* (292) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
- 189, /* (293) cmd ::= create_vtab */
- 189, /* (294) cmd ::= create_vtab LP vtabarglist RP */
- 297, /* (295) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
- 299, /* (296) vtabarg ::= */
- 300, /* (297) vtabargtoken ::= ANY */
- 300, /* (298) vtabargtoken ::= lp anylist RP */
- 301, /* (299) lp ::= LP */
- 265, /* (300) with ::= WITH wqlist */
- 265, /* (301) with ::= WITH RECURSIVE wqlist */
- 304, /* (302) wqas ::= AS */
- 304, /* (303) wqas ::= AS MATERIALIZED */
- 304, /* (304) wqas ::= AS NOT MATERIALIZED */
- 303, /* (305) wqitem ::= nm eidlist_opt wqas LP select RP */
- 240, /* (306) wqlist ::= wqitem */
- 240, /* (307) wqlist ::= wqlist COMMA wqitem */
- 305, /* (308) windowdefn_list ::= windowdefn */
- 305, /* (309) windowdefn_list ::= windowdefn_list COMMA windowdefn */
- 306, /* (310) windowdefn ::= nm AS LP window RP */
- 307, /* (311) window ::= PARTITION BY nexprlist orderby_opt frame_opt */
- 307, /* (312) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
- 307, /* (313) window ::= ORDER BY sortlist frame_opt */
- 307, /* (314) window ::= nm ORDER BY sortlist frame_opt */
- 307, /* (315) window ::= frame_opt */
- 307, /* (316) window ::= nm frame_opt */
- 308, /* (317) frame_opt ::= */
- 308, /* (318) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */
- 308, /* (319) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */
- 312, /* (320) range_or_rows ::= RANGE|ROWS|GROUPS */
- 314, /* (321) frame_bound_s ::= frame_bound */
- 314, /* (322) frame_bound_s ::= UNBOUNDED PRECEDING */
- 315, /* (323) frame_bound_e ::= frame_bound */
- 315, /* (324) frame_bound_e ::= UNBOUNDED FOLLOWING */
- 313, /* (325) frame_bound ::= expr PRECEDING|FOLLOWING */
- 313, /* (326) frame_bound ::= CURRENT ROW */
- 316, /* (327) frame_exclude_opt ::= */
- 316, /* (328) frame_exclude_opt ::= EXCLUDE frame_exclude */
- 317, /* (329) frame_exclude ::= NO OTHERS */
- 317, /* (330) frame_exclude ::= CURRENT ROW */
- 317, /* (331) frame_exclude ::= GROUP|TIES */
- 250, /* (332) window_clause ::= WINDOW windowdefn_list */
- 272, /* (333) filter_over ::= filter_clause over_clause */
- 272, /* (334) filter_over ::= over_clause */
- 272, /* (335) filter_over ::= filter_clause */
- 311, /* (336) over_clause ::= OVER LP window RP */
- 311, /* (337) over_clause ::= OVER nm */
- 310, /* (338) filter_clause ::= FILTER LP WHERE expr RP */
- 184, /* (339) input ::= cmdlist */
- 185, /* (340) cmdlist ::= cmdlist ecmd */
- 185, /* (341) cmdlist ::= ecmd */
- 186, /* (342) ecmd ::= SEMI */
- 186, /* (343) ecmd ::= cmdx SEMI */
- 186, /* (344) ecmd ::= explain cmdx SEMI */
- 191, /* (345) trans_opt ::= */
- 191, /* (346) trans_opt ::= TRANSACTION */
- 191, /* (347) trans_opt ::= TRANSACTION nm */
- 193, /* (348) savepoint_opt ::= SAVEPOINT */
- 193, /* (349) savepoint_opt ::= */
- 189, /* (350) cmd ::= create_table create_table_args */
- 202, /* (351) table_option_set ::= table_option */
- 200, /* (352) columnlist ::= columnlist COMMA columnname carglist */
- 200, /* (353) columnlist ::= columnname carglist */
- 192, /* (354) nm ::= ID|INDEXED */
- 192, /* (355) nm ::= STRING */
- 192, /* (356) nm ::= JOIN_KW */
- 207, /* (357) typetoken ::= typename */
- 208, /* (358) typename ::= ID|STRING */
- 209, /* (359) signed ::= plus_num */
- 209, /* (360) signed ::= minus_num */
- 206, /* (361) carglist ::= carglist ccons */
- 206, /* (362) carglist ::= */
- 214, /* (363) ccons ::= NULL onconf */
- 214, /* (364) ccons ::= GENERATED ALWAYS AS generated */
- 214, /* (365) ccons ::= AS generated */
- 201, /* (366) conslist_opt ::= COMMA conslist */
- 227, /* (367) conslist ::= conslist tconscomma tcons */
- 227, /* (368) conslist ::= tcons */
- 228, /* (369) tconscomma ::= */
- 232, /* (370) defer_subclause_opt ::= defer_subclause */
- 234, /* (371) resolvetype ::= raisetype */
- 238, /* (372) selectnowith ::= oneselect */
- 239, /* (373) oneselect ::= values */
- 253, /* (374) sclp ::= selcollist COMMA */
- 254, /* (375) as ::= ID|STRING */
- 271, /* (376) returning ::= */
- 216, /* (377) expr ::= term */
- 273, /* (378) likeop ::= LIKE_KW|MATCH */
- 261, /* (379) exprlist ::= nexprlist */
- 283, /* (380) nmnum ::= plus_num */
- 283, /* (381) nmnum ::= nm */
- 283, /* (382) nmnum ::= ON */
- 283, /* (383) nmnum ::= DELETE */
- 283, /* (384) nmnum ::= DEFAULT */
- 210, /* (385) plus_num ::= INTEGER|FLOAT */
- 288, /* (386) foreach_clause ::= */
- 288, /* (387) foreach_clause ::= FOR EACH ROW */
- 291, /* (388) trnm ::= nm */
- 292, /* (389) tridxby ::= */
- 293, /* (390) database_kw_opt ::= DATABASE */
- 293, /* (391) database_kw_opt ::= */
- 296, /* (392) kwcolumn_opt ::= */
- 296, /* (393) kwcolumn_opt ::= COLUMNKW */
- 298, /* (394) vtabarglist ::= vtabarg */
- 298, /* (395) vtabarglist ::= vtabarglist COMMA vtabarg */
- 299, /* (396) vtabarg ::= vtabarg vtabargtoken */
- 302, /* (397) anylist ::= */
- 302, /* (398) anylist ::= anylist LP anylist RP */
- 302, /* (399) anylist ::= anylist ANY */
- 265, /* (400) with ::= */
+ 189, /* (0) explain ::= EXPLAIN */
+ 189, /* (1) explain ::= EXPLAIN QUERY PLAN */
+ 188, /* (2) cmdx ::= cmd */
+ 190, /* (3) cmd ::= BEGIN transtype trans_opt */
+ 191, /* (4) transtype ::= */
+ 191, /* (5) transtype ::= DEFERRED */
+ 191, /* (6) transtype ::= IMMEDIATE */
+ 191, /* (7) transtype ::= EXCLUSIVE */
+ 190, /* (8) cmd ::= COMMIT|END trans_opt */
+ 190, /* (9) cmd ::= ROLLBACK trans_opt */
+ 190, /* (10) cmd ::= SAVEPOINT nm */
+ 190, /* (11) cmd ::= RELEASE savepoint_opt nm */
+ 190, /* (12) cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */
+ 195, /* (13) create_table ::= createkw temp TABLE ifnotexists nm dbnm */
+ 197, /* (14) createkw ::= CREATE */
+ 199, /* (15) ifnotexists ::= */
+ 199, /* (16) ifnotexists ::= IF NOT EXISTS */
+ 198, /* (17) temp ::= TEMP */
+ 198, /* (18) temp ::= */
+ 196, /* (19) create_table_args ::= LP columnlist conslist_opt RP table_option_set */
+ 196, /* (20) create_table_args ::= AS select */
+ 203, /* (21) table_option_set ::= */
+ 203, /* (22) table_option_set ::= table_option_set COMMA table_option */
+ 205, /* (23) table_option ::= WITHOUT nm */
+ 205, /* (24) table_option ::= nm */
+ 206, /* (25) columnname ::= nm typetoken */
+ 208, /* (26) typetoken ::= */
+ 208, /* (27) typetoken ::= typename LP signed RP */
+ 208, /* (28) typetoken ::= typename LP signed COMMA signed RP */
+ 209, /* (29) typename ::= typename ID|STRING */
+ 213, /* (30) scanpt ::= */
+ 214, /* (31) scantok ::= */
+ 215, /* (32) ccons ::= CONSTRAINT nm */
+ 215, /* (33) ccons ::= DEFAULT scantok term */
+ 215, /* (34) ccons ::= DEFAULT LP expr RP */
+ 215, /* (35) ccons ::= DEFAULT PLUS scantok term */
+ 215, /* (36) ccons ::= DEFAULT MINUS scantok term */
+ 215, /* (37) ccons ::= DEFAULT scantok ID|INDEXED */
+ 215, /* (38) ccons ::= NOT NULL onconf */
+ 215, /* (39) ccons ::= PRIMARY KEY sortorder onconf autoinc */
+ 215, /* (40) ccons ::= UNIQUE onconf */
+ 215, /* (41) ccons ::= CHECK LP expr RP */
+ 215, /* (42) ccons ::= REFERENCES nm eidlist_opt refargs */
+ 215, /* (43) ccons ::= defer_subclause */
+ 215, /* (44) ccons ::= COLLATE ID|STRING */
+ 224, /* (45) generated ::= LP expr RP */
+ 224, /* (46) generated ::= LP expr RP ID */
+ 220, /* (47) autoinc ::= */
+ 220, /* (48) autoinc ::= AUTOINCR */
+ 222, /* (49) refargs ::= */
+ 222, /* (50) refargs ::= refargs refarg */
+ 225, /* (51) refarg ::= MATCH nm */
+ 225, /* (52) refarg ::= ON INSERT refact */
+ 225, /* (53) refarg ::= ON DELETE refact */
+ 225, /* (54) refarg ::= ON UPDATE refact */
+ 226, /* (55) refact ::= SET NULL */
+ 226, /* (56) refact ::= SET DEFAULT */
+ 226, /* (57) refact ::= CASCADE */
+ 226, /* (58) refact ::= RESTRICT */
+ 226, /* (59) refact ::= NO ACTION */
+ 223, /* (60) defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
+ 223, /* (61) defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
+ 227, /* (62) init_deferred_pred_opt ::= */
+ 227, /* (63) init_deferred_pred_opt ::= INITIALLY DEFERRED */
+ 227, /* (64) init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
+ 202, /* (65) conslist_opt ::= */
+ 229, /* (66) tconscomma ::= COMMA */
+ 230, /* (67) tcons ::= CONSTRAINT nm */
+ 230, /* (68) tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
+ 230, /* (69) tcons ::= UNIQUE LP sortlist RP onconf */
+ 230, /* (70) tcons ::= CHECK LP expr RP onconf */
+ 230, /* (71) tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
+ 233, /* (72) defer_subclause_opt ::= */
+ 218, /* (73) onconf ::= */
+ 218, /* (74) onconf ::= ON CONFLICT resolvetype */
+ 234, /* (75) orconf ::= */
+ 234, /* (76) orconf ::= OR resolvetype */
+ 235, /* (77) resolvetype ::= IGNORE */
+ 235, /* (78) resolvetype ::= REPLACE */
+ 190, /* (79) cmd ::= DROP TABLE ifexists fullname */
+ 237, /* (80) ifexists ::= IF EXISTS */
+ 237, /* (81) ifexists ::= */
+ 190, /* (82) cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
+ 190, /* (83) cmd ::= DROP VIEW ifexists fullname */
+ 190, /* (84) cmd ::= select */
+ 204, /* (85) select ::= WITH wqlist selectnowith */
+ 204, /* (86) select ::= WITH RECURSIVE wqlist selectnowith */
+ 204, /* (87) select ::= selectnowith */
+ 239, /* (88) selectnowith ::= selectnowith multiselect_op oneselect */
+ 242, /* (89) multiselect_op ::= UNION */
+ 242, /* (90) multiselect_op ::= UNION ALL */
+ 242, /* (91) multiselect_op ::= EXCEPT|INTERSECT */
+ 240, /* (92) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
+ 240, /* (93) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */
+ 252, /* (94) values ::= VALUES LP nexprlist RP */
+ 252, /* (95) values ::= values COMMA LP nexprlist RP */
+ 243, /* (96) distinct ::= DISTINCT */
+ 243, /* (97) distinct ::= ALL */
+ 243, /* (98) distinct ::= */
+ 254, /* (99) sclp ::= */
+ 244, /* (100) selcollist ::= sclp scanpt expr scanpt as */
+ 244, /* (101) selcollist ::= sclp scanpt STAR */
+ 244, /* (102) selcollist ::= sclp scanpt nm DOT STAR */
+ 255, /* (103) as ::= AS nm */
+ 255, /* (104) as ::= */
+ 245, /* (105) from ::= */
+ 245, /* (106) from ::= FROM seltablist */
+ 257, /* (107) stl_prefix ::= seltablist joinop */
+ 257, /* (108) stl_prefix ::= */
+ 256, /* (109) seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
+ 256, /* (110) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
+ 256, /* (111) seltablist ::= stl_prefix LP select RP as on_opt using_opt */
+ 256, /* (112) seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
+ 200, /* (113) dbnm ::= */
+ 200, /* (114) dbnm ::= DOT nm */
+ 238, /* (115) fullname ::= nm */
+ 238, /* (116) fullname ::= nm DOT nm */
+ 263, /* (117) xfullname ::= nm */
+ 263, /* (118) xfullname ::= nm DOT nm */
+ 263, /* (119) xfullname ::= nm DOT nm AS nm */
+ 263, /* (120) xfullname ::= nm AS nm */
+ 258, /* (121) joinop ::= COMMA|JOIN */
+ 258, /* (122) joinop ::= JOIN_KW JOIN */
+ 258, /* (123) joinop ::= JOIN_KW nm JOIN */
+ 258, /* (124) joinop ::= JOIN_KW nm nm JOIN */
+ 260, /* (125) on_opt ::= ON expr */
+ 260, /* (126) on_opt ::= */
+ 259, /* (127) indexed_opt ::= */
+ 259, /* (128) indexed_opt ::= INDEXED BY nm */
+ 259, /* (129) indexed_opt ::= NOT INDEXED */
+ 261, /* (130) using_opt ::= USING LP idlist RP */
+ 261, /* (131) using_opt ::= */
+ 249, /* (132) orderby_opt ::= */
+ 249, /* (133) orderby_opt ::= ORDER BY sortlist */
+ 231, /* (134) sortlist ::= sortlist COMMA expr sortorder nulls */
+ 231, /* (135) sortlist ::= expr sortorder nulls */
+ 219, /* (136) sortorder ::= ASC */
+ 219, /* (137) sortorder ::= DESC */
+ 219, /* (138) sortorder ::= */
+ 265, /* (139) nulls ::= NULLS FIRST */
+ 265, /* (140) nulls ::= NULLS LAST */
+ 265, /* (141) nulls ::= */
+ 247, /* (142) groupby_opt ::= */
+ 247, /* (143) groupby_opt ::= GROUP BY nexprlist */
+ 248, /* (144) having_opt ::= */
+ 248, /* (145) having_opt ::= HAVING expr */
+ 250, /* (146) limit_opt ::= */
+ 250, /* (147) limit_opt ::= LIMIT expr */
+ 250, /* (148) limit_opt ::= LIMIT expr OFFSET expr */
+ 250, /* (149) limit_opt ::= LIMIT expr COMMA expr */
+ 190, /* (150) cmd ::= with DELETE FROM xfullname indexed_opt where_opt_ret */
+ 246, /* (151) where_opt ::= */
+ 246, /* (152) where_opt ::= WHERE expr */
+ 267, /* (153) where_opt_ret ::= */
+ 267, /* (154) where_opt_ret ::= WHERE expr */
+ 267, /* (155) where_opt_ret ::= RETURNING selcollist */
+ 267, /* (156) where_opt_ret ::= WHERE expr RETURNING selcollist */
+ 190, /* (157) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist from where_opt_ret */
+ 268, /* (158) setlist ::= setlist COMMA nm EQ expr */
+ 268, /* (159) setlist ::= setlist COMMA LP idlist RP EQ expr */
+ 268, /* (160) setlist ::= nm EQ expr */
+ 268, /* (161) setlist ::= LP idlist RP EQ expr */
+ 190, /* (162) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
+ 190, /* (163) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES returning */
+ 271, /* (164) upsert ::= */
+ 271, /* (165) upsert ::= RETURNING selcollist */
+ 271, /* (166) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt upsert */
+ 271, /* (167) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING upsert */
+ 271, /* (168) upsert ::= ON CONFLICT DO NOTHING returning */
+ 271, /* (169) upsert ::= ON CONFLICT DO UPDATE SET setlist where_opt returning */
+ 272, /* (170) returning ::= RETURNING selcollist */
+ 269, /* (171) insert_cmd ::= INSERT orconf */
+ 269, /* (172) insert_cmd ::= REPLACE */
+ 270, /* (173) idlist_opt ::= */
+ 270, /* (174) idlist_opt ::= LP idlist RP */
+ 264, /* (175) idlist ::= idlist COMMA nm */
+ 264, /* (176) idlist ::= nm */
+ 217, /* (177) expr ::= LP expr RP */
+ 217, /* (178) expr ::= ID|INDEXED */
+ 217, /* (179) expr ::= JOIN_KW */
+ 217, /* (180) expr ::= nm DOT nm */
+ 217, /* (181) expr ::= nm DOT nm DOT nm */
+ 216, /* (182) term ::= NULL|FLOAT|BLOB */
+ 216, /* (183) term ::= STRING */
+ 216, /* (184) term ::= INTEGER */
+ 217, /* (185) expr ::= VARIABLE */
+ 217, /* (186) expr ::= expr COLLATE ID|STRING */
+ 217, /* (187) expr ::= CAST LP expr AS typetoken RP */
+ 217, /* (188) expr ::= ID|INDEXED LP distinct exprlist RP */
+ 217, /* (189) expr ::= ID|INDEXED LP STAR RP */
+ 217, /* (190) expr ::= ID|INDEXED LP distinct exprlist RP filter_over */
+ 217, /* (191) expr ::= ID|INDEXED LP STAR RP filter_over */
+ 216, /* (192) term ::= CTIME_KW */
+ 217, /* (193) expr ::= LP nexprlist COMMA expr RP */
+ 217, /* (194) expr ::= expr AND expr */
+ 217, /* (195) expr ::= expr OR expr */
+ 217, /* (196) expr ::= expr LT|GT|GE|LE expr */
+ 217, /* (197) expr ::= expr EQ|NE expr */
+ 217, /* (198) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */
+ 217, /* (199) expr ::= expr PLUS|MINUS expr */
+ 217, /* (200) expr ::= expr STAR|SLASH|REM expr */
+ 217, /* (201) expr ::= expr CONCAT expr */
+ 274, /* (202) likeop ::= NOT LIKE_KW|MATCH */
+ 217, /* (203) expr ::= expr likeop expr */
+ 217, /* (204) expr ::= expr likeop expr ESCAPE expr */
+ 217, /* (205) expr ::= expr ISNULL|NOTNULL */
+ 217, /* (206) expr ::= expr NOT NULL */
+ 217, /* (207) expr ::= expr IS expr */
+ 217, /* (208) expr ::= expr IS NOT expr */
+ 217, /* (209) expr ::= NOT expr */
+ 217, /* (210) expr ::= BITNOT expr */
+ 217, /* (211) expr ::= PLUS|MINUS expr */
+ 217, /* (212) expr ::= expr PTR expr */
+ 275, /* (213) between_op ::= BETWEEN */
+ 275, /* (214) between_op ::= NOT BETWEEN */
+ 217, /* (215) expr ::= expr between_op expr AND expr */
+ 276, /* (216) in_op ::= IN */
+ 276, /* (217) in_op ::= NOT IN */
+ 217, /* (218) expr ::= expr in_op LP exprlist RP */
+ 217, /* (219) expr ::= LP select RP */
+ 217, /* (220) expr ::= expr in_op LP select RP */
+ 217, /* (221) expr ::= expr in_op nm dbnm paren_exprlist */
+ 217, /* (222) expr ::= EXISTS LP select RP */
+ 217, /* (223) expr ::= CASE case_operand case_exprlist case_else END */
+ 279, /* (224) case_exprlist ::= case_exprlist WHEN expr THEN expr */
+ 279, /* (225) case_exprlist ::= WHEN expr THEN expr */
+ 280, /* (226) case_else ::= ELSE expr */
+ 280, /* (227) case_else ::= */
+ 278, /* (228) case_operand ::= expr */
+ 278, /* (229) case_operand ::= */
+ 262, /* (230) exprlist ::= */
+ 253, /* (231) nexprlist ::= nexprlist COMMA expr */
+ 253, /* (232) nexprlist ::= expr */
+ 277, /* (233) paren_exprlist ::= */
+ 277, /* (234) paren_exprlist ::= LP exprlist RP */
+ 190, /* (235) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
+ 281, /* (236) uniqueflag ::= UNIQUE */
+ 281, /* (237) uniqueflag ::= */
+ 221, /* (238) eidlist_opt ::= */
+ 221, /* (239) eidlist_opt ::= LP eidlist RP */
+ 232, /* (240) eidlist ::= eidlist COMMA nm collate sortorder */
+ 232, /* (241) eidlist ::= nm collate sortorder */
+ 282, /* (242) collate ::= */
+ 282, /* (243) collate ::= COLLATE ID|STRING */
+ 190, /* (244) cmd ::= DROP INDEX ifexists fullname */
+ 190, /* (245) cmd ::= VACUUM vinto */
+ 190, /* (246) cmd ::= VACUUM nm vinto */
+ 283, /* (247) vinto ::= INTO expr */
+ 283, /* (248) vinto ::= */
+ 190, /* (249) cmd ::= PRAGMA nm dbnm */
+ 190, /* (250) cmd ::= PRAGMA nm dbnm EQ nmnum */
+ 190, /* (251) cmd ::= PRAGMA nm dbnm LP nmnum RP */
+ 190, /* (252) cmd ::= PRAGMA nm dbnm EQ minus_num */
+ 190, /* (253) cmd ::= PRAGMA nm dbnm LP minus_num RP */
+ 211, /* (254) plus_num ::= PLUS INTEGER|FLOAT */
+ 212, /* (255) minus_num ::= MINUS INTEGER|FLOAT */
+ 190, /* (256) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
+ 285, /* (257) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
+ 287, /* (258) trigger_time ::= BEFORE|AFTER */
+ 287, /* (259) trigger_time ::= INSTEAD OF */
+ 287, /* (260) trigger_time ::= */
+ 288, /* (261) trigger_event ::= DELETE|INSERT */
+ 288, /* (262) trigger_event ::= UPDATE */
+ 288, /* (263) trigger_event ::= UPDATE OF idlist */
+ 290, /* (264) when_clause ::= */
+ 290, /* (265) when_clause ::= WHEN expr */
+ 286, /* (266) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
+ 286, /* (267) trigger_cmd_list ::= trigger_cmd SEMI */
+ 292, /* (268) trnm ::= nm DOT nm */
+ 293, /* (269) tridxby ::= INDEXED BY nm */
+ 293, /* (270) tridxby ::= NOT INDEXED */
+ 291, /* (271) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */
+ 291, /* (272) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
+ 291, /* (273) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
+ 291, /* (274) trigger_cmd ::= scanpt select scanpt */
+ 217, /* (275) expr ::= RAISE LP IGNORE RP */
+ 217, /* (276) expr ::= RAISE LP raisetype COMMA nm RP */
+ 236, /* (277) raisetype ::= ROLLBACK */
+ 236, /* (278) raisetype ::= ABORT */
+ 236, /* (279) raisetype ::= FAIL */
+ 190, /* (280) cmd ::= DROP TRIGGER ifexists fullname */
+ 190, /* (281) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
+ 190, /* (282) cmd ::= DETACH database_kw_opt expr */
+ 295, /* (283) key_opt ::= */
+ 295, /* (284) key_opt ::= KEY expr */
+ 190, /* (285) cmd ::= REINDEX */
+ 190, /* (286) cmd ::= REINDEX nm dbnm */
+ 190, /* (287) cmd ::= ANALYZE */
+ 190, /* (288) cmd ::= ANALYZE nm dbnm */
+ 190, /* (289) cmd ::= ALTER TABLE fullname RENAME TO nm */
+ 190, /* (290) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
+ 190, /* (291) cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */
+ 296, /* (292) add_column_fullname ::= fullname */
+ 190, /* (293) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
+ 190, /* (294) cmd ::= create_vtab */
+ 190, /* (295) cmd ::= create_vtab LP vtabarglist RP */
+ 298, /* (296) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
+ 300, /* (297) vtabarg ::= */
+ 301, /* (298) vtabargtoken ::= ANY */
+ 301, /* (299) vtabargtoken ::= lp anylist RP */
+ 302, /* (300) lp ::= LP */
+ 266, /* (301) with ::= WITH wqlist */
+ 266, /* (302) with ::= WITH RECURSIVE wqlist */
+ 305, /* (303) wqas ::= AS */
+ 305, /* (304) wqas ::= AS MATERIALIZED */
+ 305, /* (305) wqas ::= AS NOT MATERIALIZED */
+ 304, /* (306) wqitem ::= nm eidlist_opt wqas LP select RP */
+ 241, /* (307) wqlist ::= wqitem */
+ 241, /* (308) wqlist ::= wqlist COMMA wqitem */
+ 306, /* (309) windowdefn_list ::= windowdefn */
+ 306, /* (310) windowdefn_list ::= windowdefn_list COMMA windowdefn */
+ 307, /* (311) windowdefn ::= nm AS LP window RP */
+ 308, /* (312) window ::= PARTITION BY nexprlist orderby_opt frame_opt */
+ 308, /* (313) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
+ 308, /* (314) window ::= ORDER BY sortlist frame_opt */
+ 308, /* (315) window ::= nm ORDER BY sortlist frame_opt */
+ 308, /* (316) window ::= frame_opt */
+ 308, /* (317) window ::= nm frame_opt */
+ 309, /* (318) frame_opt ::= */
+ 309, /* (319) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */
+ 309, /* (320) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */
+ 313, /* (321) range_or_rows ::= RANGE|ROWS|GROUPS */
+ 315, /* (322) frame_bound_s ::= frame_bound */
+ 315, /* (323) frame_bound_s ::= UNBOUNDED PRECEDING */
+ 316, /* (324) frame_bound_e ::= frame_bound */
+ 316, /* (325) frame_bound_e ::= UNBOUNDED FOLLOWING */
+ 314, /* (326) frame_bound ::= expr PRECEDING|FOLLOWING */
+ 314, /* (327) frame_bound ::= CURRENT ROW */
+ 317, /* (328) frame_exclude_opt ::= */
+ 317, /* (329) frame_exclude_opt ::= EXCLUDE frame_exclude */
+ 318, /* (330) frame_exclude ::= NO OTHERS */
+ 318, /* (331) frame_exclude ::= CURRENT ROW */
+ 318, /* (332) frame_exclude ::= GROUP|TIES */
+ 251, /* (333) window_clause ::= WINDOW windowdefn_list */
+ 273, /* (334) filter_over ::= filter_clause over_clause */
+ 273, /* (335) filter_over ::= over_clause */
+ 273, /* (336) filter_over ::= filter_clause */
+ 312, /* (337) over_clause ::= OVER LP window RP */
+ 312, /* (338) over_clause ::= OVER nm */
+ 311, /* (339) filter_clause ::= FILTER LP WHERE expr RP */
+ 185, /* (340) input ::= cmdlist */
+ 186, /* (341) cmdlist ::= cmdlist ecmd */
+ 186, /* (342) cmdlist ::= ecmd */
+ 187, /* (343) ecmd ::= SEMI */
+ 187, /* (344) ecmd ::= cmdx SEMI */
+ 187, /* (345) ecmd ::= explain cmdx SEMI */
+ 192, /* (346) trans_opt ::= */
+ 192, /* (347) trans_opt ::= TRANSACTION */
+ 192, /* (348) trans_opt ::= TRANSACTION nm */
+ 194, /* (349) savepoint_opt ::= SAVEPOINT */
+ 194, /* (350) savepoint_opt ::= */
+ 190, /* (351) cmd ::= create_table create_table_args */
+ 203, /* (352) table_option_set ::= table_option */
+ 201, /* (353) columnlist ::= columnlist COMMA columnname carglist */
+ 201, /* (354) columnlist ::= columnname carglist */
+ 193, /* (355) nm ::= ID|INDEXED */
+ 193, /* (356) nm ::= STRING */
+ 193, /* (357) nm ::= JOIN_KW */
+ 208, /* (358) typetoken ::= typename */
+ 209, /* (359) typename ::= ID|STRING */
+ 210, /* (360) signed ::= plus_num */
+ 210, /* (361) signed ::= minus_num */
+ 207, /* (362) carglist ::= carglist ccons */
+ 207, /* (363) carglist ::= */
+ 215, /* (364) ccons ::= NULL onconf */
+ 215, /* (365) ccons ::= GENERATED ALWAYS AS generated */
+ 215, /* (366) ccons ::= AS generated */
+ 202, /* (367) conslist_opt ::= COMMA conslist */
+ 228, /* (368) conslist ::= conslist tconscomma tcons */
+ 228, /* (369) conslist ::= tcons */
+ 229, /* (370) tconscomma ::= */
+ 233, /* (371) defer_subclause_opt ::= defer_subclause */
+ 235, /* (372) resolvetype ::= raisetype */
+ 239, /* (373) selectnowith ::= oneselect */
+ 240, /* (374) oneselect ::= values */
+ 254, /* (375) sclp ::= selcollist COMMA */
+ 255, /* (376) as ::= ID|STRING */
+ 272, /* (377) returning ::= */
+ 217, /* (378) expr ::= term */
+ 274, /* (379) likeop ::= LIKE_KW|MATCH */
+ 262, /* (380) exprlist ::= nexprlist */
+ 284, /* (381) nmnum ::= plus_num */
+ 284, /* (382) nmnum ::= nm */
+ 284, /* (383) nmnum ::= ON */
+ 284, /* (384) nmnum ::= DELETE */
+ 284, /* (385) nmnum ::= DEFAULT */
+ 211, /* (386) plus_num ::= INTEGER|FLOAT */
+ 289, /* (387) foreach_clause ::= */
+ 289, /* (388) foreach_clause ::= FOR EACH ROW */
+ 292, /* (389) trnm ::= nm */
+ 293, /* (390) tridxby ::= */
+ 294, /* (391) database_kw_opt ::= DATABASE */
+ 294, /* (392) database_kw_opt ::= */
+ 297, /* (393) kwcolumn_opt ::= */
+ 297, /* (394) kwcolumn_opt ::= COLUMNKW */
+ 299, /* (395) vtabarglist ::= vtabarg */
+ 299, /* (396) vtabarglist ::= vtabarglist COMMA vtabarg */
+ 300, /* (397) vtabarg ::= vtabarg vtabargtoken */
+ 303, /* (398) anylist ::= */
+ 303, /* (399) anylist ::= anylist LP anylist RP */
+ 303, /* (400) anylist ::= anylist ANY */
+ 266, /* (401) with ::= */
};
/* For rule J, yyRuleInfoNRhs[J] contains the negative of the number
@@ -162765,195 +164632,196 @@ static const signed char yyRuleInfoNRhs[] = {
-2, /* (209) expr ::= NOT expr */
-2, /* (210) expr ::= BITNOT expr */
-2, /* (211) expr ::= PLUS|MINUS expr */
- -1, /* (212) between_op ::= BETWEEN */
- -2, /* (213) between_op ::= NOT BETWEEN */
- -5, /* (214) expr ::= expr between_op expr AND expr */
- -1, /* (215) in_op ::= IN */
- -2, /* (216) in_op ::= NOT IN */
- -5, /* (217) expr ::= expr in_op LP exprlist RP */
- -3, /* (218) expr ::= LP select RP */
- -5, /* (219) expr ::= expr in_op LP select RP */
- -5, /* (220) expr ::= expr in_op nm dbnm paren_exprlist */
- -4, /* (221) expr ::= EXISTS LP select RP */
- -5, /* (222) expr ::= CASE case_operand case_exprlist case_else END */
- -5, /* (223) case_exprlist ::= case_exprlist WHEN expr THEN expr */
- -4, /* (224) case_exprlist ::= WHEN expr THEN expr */
- -2, /* (225) case_else ::= ELSE expr */
- 0, /* (226) case_else ::= */
- -1, /* (227) case_operand ::= expr */
- 0, /* (228) case_operand ::= */
- 0, /* (229) exprlist ::= */
- -3, /* (230) nexprlist ::= nexprlist COMMA expr */
- -1, /* (231) nexprlist ::= expr */
- 0, /* (232) paren_exprlist ::= */
- -3, /* (233) paren_exprlist ::= LP exprlist RP */
- -12, /* (234) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
- -1, /* (235) uniqueflag ::= UNIQUE */
- 0, /* (236) uniqueflag ::= */
- 0, /* (237) eidlist_opt ::= */
- -3, /* (238) eidlist_opt ::= LP eidlist RP */
- -5, /* (239) eidlist ::= eidlist COMMA nm collate sortorder */
- -3, /* (240) eidlist ::= nm collate sortorder */
- 0, /* (241) collate ::= */
- -2, /* (242) collate ::= COLLATE ID|STRING */
- -4, /* (243) cmd ::= DROP INDEX ifexists fullname */
- -2, /* (244) cmd ::= VACUUM vinto */
- -3, /* (245) cmd ::= VACUUM nm vinto */
- -2, /* (246) vinto ::= INTO expr */
- 0, /* (247) vinto ::= */
- -3, /* (248) cmd ::= PRAGMA nm dbnm */
- -5, /* (249) cmd ::= PRAGMA nm dbnm EQ nmnum */
- -6, /* (250) cmd ::= PRAGMA nm dbnm LP nmnum RP */
- -5, /* (251) cmd ::= PRAGMA nm dbnm EQ minus_num */
- -6, /* (252) cmd ::= PRAGMA nm dbnm LP minus_num RP */
- -2, /* (253) plus_num ::= PLUS INTEGER|FLOAT */
- -2, /* (254) minus_num ::= MINUS INTEGER|FLOAT */
- -5, /* (255) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
- -11, /* (256) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
- -1, /* (257) trigger_time ::= BEFORE|AFTER */
- -2, /* (258) trigger_time ::= INSTEAD OF */
- 0, /* (259) trigger_time ::= */
- -1, /* (260) trigger_event ::= DELETE|INSERT */
- -1, /* (261) trigger_event ::= UPDATE */
- -3, /* (262) trigger_event ::= UPDATE OF idlist */
- 0, /* (263) when_clause ::= */
- -2, /* (264) when_clause ::= WHEN expr */
- -3, /* (265) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
- -2, /* (266) trigger_cmd_list ::= trigger_cmd SEMI */
- -3, /* (267) trnm ::= nm DOT nm */
- -3, /* (268) tridxby ::= INDEXED BY nm */
- -2, /* (269) tridxby ::= NOT INDEXED */
- -9, /* (270) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */
- -8, /* (271) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
- -6, /* (272) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
- -3, /* (273) trigger_cmd ::= scanpt select scanpt */
- -4, /* (274) expr ::= RAISE LP IGNORE RP */
- -6, /* (275) expr ::= RAISE LP raisetype COMMA nm RP */
- -1, /* (276) raisetype ::= ROLLBACK */
- -1, /* (277) raisetype ::= ABORT */
- -1, /* (278) raisetype ::= FAIL */
- -4, /* (279) cmd ::= DROP TRIGGER ifexists fullname */
- -6, /* (280) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
- -3, /* (281) cmd ::= DETACH database_kw_opt expr */
- 0, /* (282) key_opt ::= */
- -2, /* (283) key_opt ::= KEY expr */
- -1, /* (284) cmd ::= REINDEX */
- -3, /* (285) cmd ::= REINDEX nm dbnm */
- -1, /* (286) cmd ::= ANALYZE */
- -3, /* (287) cmd ::= ANALYZE nm dbnm */
- -6, /* (288) cmd ::= ALTER TABLE fullname RENAME TO nm */
- -7, /* (289) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
- -6, /* (290) cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */
- -1, /* (291) add_column_fullname ::= fullname */
- -8, /* (292) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
- -1, /* (293) cmd ::= create_vtab */
- -4, /* (294) cmd ::= create_vtab LP vtabarglist RP */
- -8, /* (295) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
- 0, /* (296) vtabarg ::= */
- -1, /* (297) vtabargtoken ::= ANY */
- -3, /* (298) vtabargtoken ::= lp anylist RP */
- -1, /* (299) lp ::= LP */
- -2, /* (300) with ::= WITH wqlist */
- -3, /* (301) with ::= WITH RECURSIVE wqlist */
- -1, /* (302) wqas ::= AS */
- -2, /* (303) wqas ::= AS MATERIALIZED */
- -3, /* (304) wqas ::= AS NOT MATERIALIZED */
- -6, /* (305) wqitem ::= nm eidlist_opt wqas LP select RP */
- -1, /* (306) wqlist ::= wqitem */
- -3, /* (307) wqlist ::= wqlist COMMA wqitem */
- -1, /* (308) windowdefn_list ::= windowdefn */
- -3, /* (309) windowdefn_list ::= windowdefn_list COMMA windowdefn */
- -5, /* (310) windowdefn ::= nm AS LP window RP */
- -5, /* (311) window ::= PARTITION BY nexprlist orderby_opt frame_opt */
- -6, /* (312) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
- -4, /* (313) window ::= ORDER BY sortlist frame_opt */
- -5, /* (314) window ::= nm ORDER BY sortlist frame_opt */
- -1, /* (315) window ::= frame_opt */
- -2, /* (316) window ::= nm frame_opt */
- 0, /* (317) frame_opt ::= */
- -3, /* (318) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */
- -6, /* (319) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */
- -1, /* (320) range_or_rows ::= RANGE|ROWS|GROUPS */
- -1, /* (321) frame_bound_s ::= frame_bound */
- -2, /* (322) frame_bound_s ::= UNBOUNDED PRECEDING */
- -1, /* (323) frame_bound_e ::= frame_bound */
- -2, /* (324) frame_bound_e ::= UNBOUNDED FOLLOWING */
- -2, /* (325) frame_bound ::= expr PRECEDING|FOLLOWING */
- -2, /* (326) frame_bound ::= CURRENT ROW */
- 0, /* (327) frame_exclude_opt ::= */
- -2, /* (328) frame_exclude_opt ::= EXCLUDE frame_exclude */
- -2, /* (329) frame_exclude ::= NO OTHERS */
- -2, /* (330) frame_exclude ::= CURRENT ROW */
- -1, /* (331) frame_exclude ::= GROUP|TIES */
- -2, /* (332) window_clause ::= WINDOW windowdefn_list */
- -2, /* (333) filter_over ::= filter_clause over_clause */
- -1, /* (334) filter_over ::= over_clause */
- -1, /* (335) filter_over ::= filter_clause */
- -4, /* (336) over_clause ::= OVER LP window RP */
- -2, /* (337) over_clause ::= OVER nm */
- -5, /* (338) filter_clause ::= FILTER LP WHERE expr RP */
- -1, /* (339) input ::= cmdlist */
- -2, /* (340) cmdlist ::= cmdlist ecmd */
- -1, /* (341) cmdlist ::= ecmd */
- -1, /* (342) ecmd ::= SEMI */
- -2, /* (343) ecmd ::= cmdx SEMI */
- -3, /* (344) ecmd ::= explain cmdx SEMI */
- 0, /* (345) trans_opt ::= */
- -1, /* (346) trans_opt ::= TRANSACTION */
- -2, /* (347) trans_opt ::= TRANSACTION nm */
- -1, /* (348) savepoint_opt ::= SAVEPOINT */
- 0, /* (349) savepoint_opt ::= */
- -2, /* (350) cmd ::= create_table create_table_args */
- -1, /* (351) table_option_set ::= table_option */
- -4, /* (352) columnlist ::= columnlist COMMA columnname carglist */
- -2, /* (353) columnlist ::= columnname carglist */
- -1, /* (354) nm ::= ID|INDEXED */
- -1, /* (355) nm ::= STRING */
- -1, /* (356) nm ::= JOIN_KW */
- -1, /* (357) typetoken ::= typename */
- -1, /* (358) typename ::= ID|STRING */
- -1, /* (359) signed ::= plus_num */
- -1, /* (360) signed ::= minus_num */
- -2, /* (361) carglist ::= carglist ccons */
- 0, /* (362) carglist ::= */
- -2, /* (363) ccons ::= NULL onconf */
- -4, /* (364) ccons ::= GENERATED ALWAYS AS generated */
- -2, /* (365) ccons ::= AS generated */
- -2, /* (366) conslist_opt ::= COMMA conslist */
- -3, /* (367) conslist ::= conslist tconscomma tcons */
- -1, /* (368) conslist ::= tcons */
- 0, /* (369) tconscomma ::= */
- -1, /* (370) defer_subclause_opt ::= defer_subclause */
- -1, /* (371) resolvetype ::= raisetype */
- -1, /* (372) selectnowith ::= oneselect */
- -1, /* (373) oneselect ::= values */
- -2, /* (374) sclp ::= selcollist COMMA */
- -1, /* (375) as ::= ID|STRING */
- 0, /* (376) returning ::= */
- -1, /* (377) expr ::= term */
- -1, /* (378) likeop ::= LIKE_KW|MATCH */
- -1, /* (379) exprlist ::= nexprlist */
- -1, /* (380) nmnum ::= plus_num */
- -1, /* (381) nmnum ::= nm */
- -1, /* (382) nmnum ::= ON */
- -1, /* (383) nmnum ::= DELETE */
- -1, /* (384) nmnum ::= DEFAULT */
- -1, /* (385) plus_num ::= INTEGER|FLOAT */
- 0, /* (386) foreach_clause ::= */
- -3, /* (387) foreach_clause ::= FOR EACH ROW */
- -1, /* (388) trnm ::= nm */
- 0, /* (389) tridxby ::= */
- -1, /* (390) database_kw_opt ::= DATABASE */
- 0, /* (391) database_kw_opt ::= */
- 0, /* (392) kwcolumn_opt ::= */
- -1, /* (393) kwcolumn_opt ::= COLUMNKW */
- -1, /* (394) vtabarglist ::= vtabarg */
- -3, /* (395) vtabarglist ::= vtabarglist COMMA vtabarg */
- -2, /* (396) vtabarg ::= vtabarg vtabargtoken */
- 0, /* (397) anylist ::= */
- -4, /* (398) anylist ::= anylist LP anylist RP */
- -2, /* (399) anylist ::= anylist ANY */
- 0, /* (400) with ::= */
+ -3, /* (212) expr ::= expr PTR expr */
+ -1, /* (213) between_op ::= BETWEEN */
+ -2, /* (214) between_op ::= NOT BETWEEN */
+ -5, /* (215) expr ::= expr between_op expr AND expr */
+ -1, /* (216) in_op ::= IN */
+ -2, /* (217) in_op ::= NOT IN */
+ -5, /* (218) expr ::= expr in_op LP exprlist RP */
+ -3, /* (219) expr ::= LP select RP */
+ -5, /* (220) expr ::= expr in_op LP select RP */
+ -5, /* (221) expr ::= expr in_op nm dbnm paren_exprlist */
+ -4, /* (222) expr ::= EXISTS LP select RP */
+ -5, /* (223) expr ::= CASE case_operand case_exprlist case_else END */
+ -5, /* (224) case_exprlist ::= case_exprlist WHEN expr THEN expr */
+ -4, /* (225) case_exprlist ::= WHEN expr THEN expr */
+ -2, /* (226) case_else ::= ELSE expr */
+ 0, /* (227) case_else ::= */
+ -1, /* (228) case_operand ::= expr */
+ 0, /* (229) case_operand ::= */
+ 0, /* (230) exprlist ::= */
+ -3, /* (231) nexprlist ::= nexprlist COMMA expr */
+ -1, /* (232) nexprlist ::= expr */
+ 0, /* (233) paren_exprlist ::= */
+ -3, /* (234) paren_exprlist ::= LP exprlist RP */
+ -12, /* (235) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
+ -1, /* (236) uniqueflag ::= UNIQUE */
+ 0, /* (237) uniqueflag ::= */
+ 0, /* (238) eidlist_opt ::= */
+ -3, /* (239) eidlist_opt ::= LP eidlist RP */
+ -5, /* (240) eidlist ::= eidlist COMMA nm collate sortorder */
+ -3, /* (241) eidlist ::= nm collate sortorder */
+ 0, /* (242) collate ::= */
+ -2, /* (243) collate ::= COLLATE ID|STRING */
+ -4, /* (244) cmd ::= DROP INDEX ifexists fullname */
+ -2, /* (245) cmd ::= VACUUM vinto */
+ -3, /* (246) cmd ::= VACUUM nm vinto */
+ -2, /* (247) vinto ::= INTO expr */
+ 0, /* (248) vinto ::= */
+ -3, /* (249) cmd ::= PRAGMA nm dbnm */
+ -5, /* (250) cmd ::= PRAGMA nm dbnm EQ nmnum */
+ -6, /* (251) cmd ::= PRAGMA nm dbnm LP nmnum RP */
+ -5, /* (252) cmd ::= PRAGMA nm dbnm EQ minus_num */
+ -6, /* (253) cmd ::= PRAGMA nm dbnm LP minus_num RP */
+ -2, /* (254) plus_num ::= PLUS INTEGER|FLOAT */
+ -2, /* (255) minus_num ::= MINUS INTEGER|FLOAT */
+ -5, /* (256) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
+ -11, /* (257) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
+ -1, /* (258) trigger_time ::= BEFORE|AFTER */
+ -2, /* (259) trigger_time ::= INSTEAD OF */
+ 0, /* (260) trigger_time ::= */
+ -1, /* (261) trigger_event ::= DELETE|INSERT */
+ -1, /* (262) trigger_event ::= UPDATE */
+ -3, /* (263) trigger_event ::= UPDATE OF idlist */
+ 0, /* (264) when_clause ::= */
+ -2, /* (265) when_clause ::= WHEN expr */
+ -3, /* (266) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
+ -2, /* (267) trigger_cmd_list ::= trigger_cmd SEMI */
+ -3, /* (268) trnm ::= nm DOT nm */
+ -3, /* (269) tridxby ::= INDEXED BY nm */
+ -2, /* (270) tridxby ::= NOT INDEXED */
+ -9, /* (271) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */
+ -8, /* (272) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
+ -6, /* (273) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
+ -3, /* (274) trigger_cmd ::= scanpt select scanpt */
+ -4, /* (275) expr ::= RAISE LP IGNORE RP */
+ -6, /* (276) expr ::= RAISE LP raisetype COMMA nm RP */
+ -1, /* (277) raisetype ::= ROLLBACK */
+ -1, /* (278) raisetype ::= ABORT */
+ -1, /* (279) raisetype ::= FAIL */
+ -4, /* (280) cmd ::= DROP TRIGGER ifexists fullname */
+ -6, /* (281) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
+ -3, /* (282) cmd ::= DETACH database_kw_opt expr */
+ 0, /* (283) key_opt ::= */
+ -2, /* (284) key_opt ::= KEY expr */
+ -1, /* (285) cmd ::= REINDEX */
+ -3, /* (286) cmd ::= REINDEX nm dbnm */
+ -1, /* (287) cmd ::= ANALYZE */
+ -3, /* (288) cmd ::= ANALYZE nm dbnm */
+ -6, /* (289) cmd ::= ALTER TABLE fullname RENAME TO nm */
+ -7, /* (290) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
+ -6, /* (291) cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */
+ -1, /* (292) add_column_fullname ::= fullname */
+ -8, /* (293) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
+ -1, /* (294) cmd ::= create_vtab */
+ -4, /* (295) cmd ::= create_vtab LP vtabarglist RP */
+ -8, /* (296) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
+ 0, /* (297) vtabarg ::= */
+ -1, /* (298) vtabargtoken ::= ANY */
+ -3, /* (299) vtabargtoken ::= lp anylist RP */
+ -1, /* (300) lp ::= LP */
+ -2, /* (301) with ::= WITH wqlist */
+ -3, /* (302) with ::= WITH RECURSIVE wqlist */
+ -1, /* (303) wqas ::= AS */
+ -2, /* (304) wqas ::= AS MATERIALIZED */
+ -3, /* (305) wqas ::= AS NOT MATERIALIZED */
+ -6, /* (306) wqitem ::= nm eidlist_opt wqas LP select RP */
+ -1, /* (307) wqlist ::= wqitem */
+ -3, /* (308) wqlist ::= wqlist COMMA wqitem */
+ -1, /* (309) windowdefn_list ::= windowdefn */
+ -3, /* (310) windowdefn_list ::= windowdefn_list COMMA windowdefn */
+ -5, /* (311) windowdefn ::= nm AS LP window RP */
+ -5, /* (312) window ::= PARTITION BY nexprlist orderby_opt frame_opt */
+ -6, /* (313) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
+ -4, /* (314) window ::= ORDER BY sortlist frame_opt */
+ -5, /* (315) window ::= nm ORDER BY sortlist frame_opt */
+ -1, /* (316) window ::= frame_opt */
+ -2, /* (317) window ::= nm frame_opt */
+ 0, /* (318) frame_opt ::= */
+ -3, /* (319) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */
+ -6, /* (320) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */
+ -1, /* (321) range_or_rows ::= RANGE|ROWS|GROUPS */
+ -1, /* (322) frame_bound_s ::= frame_bound */
+ -2, /* (323) frame_bound_s ::= UNBOUNDED PRECEDING */
+ -1, /* (324) frame_bound_e ::= frame_bound */
+ -2, /* (325) frame_bound_e ::= UNBOUNDED FOLLOWING */
+ -2, /* (326) frame_bound ::= expr PRECEDING|FOLLOWING */
+ -2, /* (327) frame_bound ::= CURRENT ROW */
+ 0, /* (328) frame_exclude_opt ::= */
+ -2, /* (329) frame_exclude_opt ::= EXCLUDE frame_exclude */
+ -2, /* (330) frame_exclude ::= NO OTHERS */
+ -2, /* (331) frame_exclude ::= CURRENT ROW */
+ -1, /* (332) frame_exclude ::= GROUP|TIES */
+ -2, /* (333) window_clause ::= WINDOW windowdefn_list */
+ -2, /* (334) filter_over ::= filter_clause over_clause */
+ -1, /* (335) filter_over ::= over_clause */
+ -1, /* (336) filter_over ::= filter_clause */
+ -4, /* (337) over_clause ::= OVER LP window RP */
+ -2, /* (338) over_clause ::= OVER nm */
+ -5, /* (339) filter_clause ::= FILTER LP WHERE expr RP */
+ -1, /* (340) input ::= cmdlist */
+ -2, /* (341) cmdlist ::= cmdlist ecmd */
+ -1, /* (342) cmdlist ::= ecmd */
+ -1, /* (343) ecmd ::= SEMI */
+ -2, /* (344) ecmd ::= cmdx SEMI */
+ -3, /* (345) ecmd ::= explain cmdx SEMI */
+ 0, /* (346) trans_opt ::= */
+ -1, /* (347) trans_opt ::= TRANSACTION */
+ -2, /* (348) trans_opt ::= TRANSACTION nm */
+ -1, /* (349) savepoint_opt ::= SAVEPOINT */
+ 0, /* (350) savepoint_opt ::= */
+ -2, /* (351) cmd ::= create_table create_table_args */
+ -1, /* (352) table_option_set ::= table_option */
+ -4, /* (353) columnlist ::= columnlist COMMA columnname carglist */
+ -2, /* (354) columnlist ::= columnname carglist */
+ -1, /* (355) nm ::= ID|INDEXED */
+ -1, /* (356) nm ::= STRING */
+ -1, /* (357) nm ::= JOIN_KW */
+ -1, /* (358) typetoken ::= typename */
+ -1, /* (359) typename ::= ID|STRING */
+ -1, /* (360) signed ::= plus_num */
+ -1, /* (361) signed ::= minus_num */
+ -2, /* (362) carglist ::= carglist ccons */
+ 0, /* (363) carglist ::= */
+ -2, /* (364) ccons ::= NULL onconf */
+ -4, /* (365) ccons ::= GENERATED ALWAYS AS generated */
+ -2, /* (366) ccons ::= AS generated */
+ -2, /* (367) conslist_opt ::= COMMA conslist */
+ -3, /* (368) conslist ::= conslist tconscomma tcons */
+ -1, /* (369) conslist ::= tcons */
+ 0, /* (370) tconscomma ::= */
+ -1, /* (371) defer_subclause_opt ::= defer_subclause */
+ -1, /* (372) resolvetype ::= raisetype */
+ -1, /* (373) selectnowith ::= oneselect */
+ -1, /* (374) oneselect ::= values */
+ -2, /* (375) sclp ::= selcollist COMMA */
+ -1, /* (376) as ::= ID|STRING */
+ 0, /* (377) returning ::= */
+ -1, /* (378) expr ::= term */
+ -1, /* (379) likeop ::= LIKE_KW|MATCH */
+ -1, /* (380) exprlist ::= nexprlist */
+ -1, /* (381) nmnum ::= plus_num */
+ -1, /* (382) nmnum ::= nm */
+ -1, /* (383) nmnum ::= ON */
+ -1, /* (384) nmnum ::= DELETE */
+ -1, /* (385) nmnum ::= DEFAULT */
+ -1, /* (386) plus_num ::= INTEGER|FLOAT */
+ 0, /* (387) foreach_clause ::= */
+ -3, /* (388) foreach_clause ::= FOR EACH ROW */
+ -1, /* (389) trnm ::= nm */
+ 0, /* (390) tridxby ::= */
+ -1, /* (391) database_kw_opt ::= DATABASE */
+ 0, /* (392) database_kw_opt ::= */
+ 0, /* (393) kwcolumn_opt ::= */
+ -1, /* (394) kwcolumn_opt ::= COLUMNKW */
+ -1, /* (395) vtabarglist ::= vtabarg */
+ -3, /* (396) vtabarglist ::= vtabarglist COMMA vtabarg */
+ -2, /* (397) vtabarg ::= vtabarg vtabargtoken */
+ 0, /* (398) anylist ::= */
+ -4, /* (399) anylist ::= anylist LP anylist RP */
+ -2, /* (400) anylist ::= anylist ANY */
+ 0, /* (401) with ::= */
};
static void yy_accept(yyParser*); /* Forward Declaration */
@@ -163005,16 +164873,16 @@ static YYACTIONTYPE yy_reduce(
{ sqlite3FinishCoding(pParse); }
break;
case 3: /* cmd ::= BEGIN transtype trans_opt */
-{sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy64);}
+{sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy394);}
break;
case 4: /* transtype ::= */
-{yymsp[1].minor.yy64 = TK_DEFERRED;}
+{yymsp[1].minor.yy394 = TK_DEFERRED;}
break;
case 5: /* transtype ::= DEFERRED */
case 6: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==6);
case 7: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==7);
- case 320: /* range_or_rows ::= RANGE|ROWS|GROUPS */ yytestcase(yyruleno==320);
-{yymsp[0].minor.yy64 = yymsp[0].major; /*A-overwrites-X*/}
+ case 321: /* range_or_rows ::= RANGE|ROWS|GROUPS */ yytestcase(yyruleno==321);
+{yymsp[0].minor.yy394 = yymsp[0].major; /*A-overwrites-X*/}
break;
case 8: /* cmd ::= COMMIT|END trans_opt */
case 9: /* cmd ::= ROLLBACK trans_opt */ yytestcase(yyruleno==9);
@@ -163037,7 +164905,7 @@ static YYACTIONTYPE yy_reduce(
break;
case 13: /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */
{
- sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy64,0,0,yymsp[-2].minor.yy64);
+ sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy394,0,0,yymsp[-2].minor.yy394);
}
break;
case 14: /* createkw ::= CREATE */
@@ -163050,39 +164918,39 @@ static YYACTIONTYPE yy_reduce(
case 72: /* defer_subclause_opt ::= */ yytestcase(yyruleno==72);
case 81: /* ifexists ::= */ yytestcase(yyruleno==81);
case 98: /* distinct ::= */ yytestcase(yyruleno==98);
- case 241: /* collate ::= */ yytestcase(yyruleno==241);
-{yymsp[1].minor.yy64 = 0;}
+ case 242: /* collate ::= */ yytestcase(yyruleno==242);
+{yymsp[1].minor.yy394 = 0;}
break;
case 16: /* ifnotexists ::= IF NOT EXISTS */
-{yymsp[-2].minor.yy64 = 1;}
+{yymsp[-2].minor.yy394 = 1;}
break;
case 17: /* temp ::= TEMP */
-{yymsp[0].minor.yy64 = pParse->db->init.busy==0;}
+{yymsp[0].minor.yy394 = pParse->db->init.busy==0;}
break;
case 19: /* create_table_args ::= LP columnlist conslist_opt RP table_option_set */
{
- sqlite3EndTable(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,yymsp[0].minor.yy51,0);
+ sqlite3EndTable(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,yymsp[0].minor.yy285,0);
}
break;
case 20: /* create_table_args ::= AS select */
{
- sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy303);
- sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy303);
+ sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy47);
+ sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy47);
}
break;
case 21: /* table_option_set ::= */
-{yymsp[1].minor.yy51 = 0;}
+{yymsp[1].minor.yy285 = 0;}
break;
case 22: /* table_option_set ::= table_option_set COMMA table_option */
-{yylhsminor.yy51 = yymsp[-2].minor.yy51|yymsp[0].minor.yy51;}
- yymsp[-2].minor.yy51 = yylhsminor.yy51;
+{yylhsminor.yy285 = yymsp[-2].minor.yy285|yymsp[0].minor.yy285;}
+ yymsp[-2].minor.yy285 = yylhsminor.yy285;
break;
case 23: /* table_option ::= WITHOUT nm */
{
if( yymsp[0].minor.yy0.n==5 && sqlite3_strnicmp(yymsp[0].minor.yy0.z,"rowid",5)==0 ){
- yymsp[-1].minor.yy51 = TF_WithoutRowid | TF_NoVisibleRowid;
+ yymsp[-1].minor.yy285 = TF_WithoutRowid | TF_NoVisibleRowid;
}else{
- yymsp[-1].minor.yy51 = 0;
+ yymsp[-1].minor.yy285 = 0;
sqlite3ErrorMsg(pParse, "unknown table option: %.*s", yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.z);
}
}
@@ -163090,13 +164958,13 @@ static YYACTIONTYPE yy_reduce(
case 24: /* table_option ::= nm */
{
if( yymsp[0].minor.yy0.n==6 && sqlite3_strnicmp(yymsp[0].minor.yy0.z,"strict",6)==0 ){
- yylhsminor.yy51 = TF_Strict;
+ yylhsminor.yy285 = TF_Strict;
}else{
- yylhsminor.yy51 = 0;
+ yylhsminor.yy285 = 0;
sqlite3ErrorMsg(pParse, "unknown table option: %.*s", yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.z);
}
}
- yymsp[0].minor.yy51 = yylhsminor.yy51;
+ yymsp[0].minor.yy285 = yylhsminor.yy285;
break;
case 25: /* columnname ::= nm typetoken */
{sqlite3AddColumn(pParse,yymsp[-1].minor.yy0,yymsp[0].minor.yy0);}
@@ -163122,7 +164990,7 @@ static YYACTIONTYPE yy_reduce(
case 30: /* scanpt ::= */
{
assert( yyLookahead!=YYNOCODE );
- yymsp[1].minor.yy600 = yyLookaheadToken.z;
+ yymsp[1].minor.yy522 = yyLookaheadToken.z;
}
break;
case 31: /* scantok ::= */
@@ -163136,17 +165004,17 @@ static YYACTIONTYPE yy_reduce(
{pParse->constraintName = yymsp[0].minor.yy0;}
break;
case 33: /* ccons ::= DEFAULT scantok term */
-{sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy626,yymsp[-1].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);}
+{sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy528,yymsp[-1].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);}
break;
case 34: /* ccons ::= DEFAULT LP expr RP */
-{sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy626,yymsp[-2].minor.yy0.z+1,yymsp[0].minor.yy0.z);}
+{sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy528,yymsp[-2].minor.yy0.z+1,yymsp[0].minor.yy0.z);}
break;
case 35: /* ccons ::= DEFAULT PLUS scantok term */
-{sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy626,yymsp[-2].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);}
+{sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy528,yymsp[-2].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);}
break;
case 36: /* ccons ::= DEFAULT MINUS scantok term */
{
- Expr *p = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy626, 0);
+ Expr *p = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy528, 0);
sqlite3AddDefaultValue(pParse,p,yymsp[-2].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);
}
break;
@@ -163161,161 +165029,161 @@ static YYACTIONTYPE yy_reduce(
}
break;
case 38: /* ccons ::= NOT NULL onconf */
-{sqlite3AddNotNull(pParse, yymsp[0].minor.yy64);}
+{sqlite3AddNotNull(pParse, yymsp[0].minor.yy394);}
break;
case 39: /* ccons ::= PRIMARY KEY sortorder onconf autoinc */
-{sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy64,yymsp[0].minor.yy64,yymsp[-2].minor.yy64);}
+{sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy394,yymsp[0].minor.yy394,yymsp[-2].minor.yy394);}
break;
case 40: /* ccons ::= UNIQUE onconf */
-{sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy64,0,0,0,0,
+{sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy394,0,0,0,0,
SQLITE_IDXTYPE_UNIQUE);}
break;
case 41: /* ccons ::= CHECK LP expr RP */
-{sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy626,yymsp[-2].minor.yy0.z,yymsp[0].minor.yy0.z);}
+{sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy528,yymsp[-2].minor.yy0.z,yymsp[0].minor.yy0.z);}
break;
case 42: /* ccons ::= REFERENCES nm eidlist_opt refargs */
-{sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy562,yymsp[0].minor.yy64);}
+{sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy322,yymsp[0].minor.yy394);}
break;
case 43: /* ccons ::= defer_subclause */
-{sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy64);}
+{sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy394);}
break;
case 44: /* ccons ::= COLLATE ID|STRING */
{sqlite3AddCollateType(pParse, &yymsp[0].minor.yy0);}
break;
case 45: /* generated ::= LP expr RP */
-{sqlite3AddGenerated(pParse,yymsp[-1].minor.yy626,0);}
+{sqlite3AddGenerated(pParse,yymsp[-1].minor.yy528,0);}
break;
case 46: /* generated ::= LP expr RP ID */
-{sqlite3AddGenerated(pParse,yymsp[-2].minor.yy626,&yymsp[0].minor.yy0);}
+{sqlite3AddGenerated(pParse,yymsp[-2].minor.yy528,&yymsp[0].minor.yy0);}
break;
case 48: /* autoinc ::= AUTOINCR */
-{yymsp[0].minor.yy64 = 1;}
+{yymsp[0].minor.yy394 = 1;}
break;
case 49: /* refargs ::= */
-{ yymsp[1].minor.yy64 = OE_None*0x0101; /* EV: R-19803-45884 */}
+{ yymsp[1].minor.yy394 = OE_None*0x0101; /* EV: R-19803-45884 */}
break;
case 50: /* refargs ::= refargs refarg */
-{ yymsp[-1].minor.yy64 = (yymsp[-1].minor.yy64 & ~yymsp[0].minor.yy83.mask) | yymsp[0].minor.yy83.value; }
+{ yymsp[-1].minor.yy394 = (yymsp[-1].minor.yy394 & ~yymsp[0].minor.yy231.mask) | yymsp[0].minor.yy231.value; }
break;
case 51: /* refarg ::= MATCH nm */
-{ yymsp[-1].minor.yy83.value = 0; yymsp[-1].minor.yy83.mask = 0x000000; }
+{ yymsp[-1].minor.yy231.value = 0; yymsp[-1].minor.yy231.mask = 0x000000; }
break;
case 52: /* refarg ::= ON INSERT refact */
-{ yymsp[-2].minor.yy83.value = 0; yymsp[-2].minor.yy83.mask = 0x000000; }
+{ yymsp[-2].minor.yy231.value = 0; yymsp[-2].minor.yy231.mask = 0x000000; }
break;
case 53: /* refarg ::= ON DELETE refact */
-{ yymsp[-2].minor.yy83.value = yymsp[0].minor.yy64; yymsp[-2].minor.yy83.mask = 0x0000ff; }
+{ yymsp[-2].minor.yy231.value = yymsp[0].minor.yy394; yymsp[-2].minor.yy231.mask = 0x0000ff; }
break;
case 54: /* refarg ::= ON UPDATE refact */
-{ yymsp[-2].minor.yy83.value = yymsp[0].minor.yy64<<8; yymsp[-2].minor.yy83.mask = 0x00ff00; }
+{ yymsp[-2].minor.yy231.value = yymsp[0].minor.yy394<<8; yymsp[-2].minor.yy231.mask = 0x00ff00; }
break;
case 55: /* refact ::= SET NULL */
-{ yymsp[-1].minor.yy64 = OE_SetNull; /* EV: R-33326-45252 */}
+{ yymsp[-1].minor.yy394 = OE_SetNull; /* EV: R-33326-45252 */}
break;
case 56: /* refact ::= SET DEFAULT */
-{ yymsp[-1].minor.yy64 = OE_SetDflt; /* EV: R-33326-45252 */}
+{ yymsp[-1].minor.yy394 = OE_SetDflt; /* EV: R-33326-45252 */}
break;
case 57: /* refact ::= CASCADE */
-{ yymsp[0].minor.yy64 = OE_Cascade; /* EV: R-33326-45252 */}
+{ yymsp[0].minor.yy394 = OE_Cascade; /* EV: R-33326-45252 */}
break;
case 58: /* refact ::= RESTRICT */
-{ yymsp[0].minor.yy64 = OE_Restrict; /* EV: R-33326-45252 */}
+{ yymsp[0].minor.yy394 = OE_Restrict; /* EV: R-33326-45252 */}
break;
case 59: /* refact ::= NO ACTION */
-{ yymsp[-1].minor.yy64 = OE_None; /* EV: R-33326-45252 */}
+{ yymsp[-1].minor.yy394 = OE_None; /* EV: R-33326-45252 */}
break;
case 60: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
-{yymsp[-2].minor.yy64 = 0;}
+{yymsp[-2].minor.yy394 = 0;}
break;
case 61: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
case 76: /* orconf ::= OR resolvetype */ yytestcase(yyruleno==76);
case 171: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==171);
-{yymsp[-1].minor.yy64 = yymsp[0].minor.yy64;}
+{yymsp[-1].minor.yy394 = yymsp[0].minor.yy394;}
break;
case 63: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */
case 80: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==80);
- case 213: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==213);
- case 216: /* in_op ::= NOT IN */ yytestcase(yyruleno==216);
- case 242: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==242);
-{yymsp[-1].minor.yy64 = 1;}
+ case 214: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==214);
+ case 217: /* in_op ::= NOT IN */ yytestcase(yyruleno==217);
+ case 243: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==243);
+{yymsp[-1].minor.yy394 = 1;}
break;
case 64: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
-{yymsp[-1].minor.yy64 = 0;}
+{yymsp[-1].minor.yy394 = 0;}
break;
case 66: /* tconscomma ::= COMMA */
{pParse->constraintName.n = 0;}
break;
case 68: /* tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
-{sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy562,yymsp[0].minor.yy64,yymsp[-2].minor.yy64,0);}
+{sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy322,yymsp[0].minor.yy394,yymsp[-2].minor.yy394,0);}
break;
case 69: /* tcons ::= UNIQUE LP sortlist RP onconf */
-{sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy562,yymsp[0].minor.yy64,0,0,0,0,
+{sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy322,yymsp[0].minor.yy394,0,0,0,0,
SQLITE_IDXTYPE_UNIQUE);}
break;
case 70: /* tcons ::= CHECK LP expr RP onconf */
-{sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy626,yymsp[-3].minor.yy0.z,yymsp[-1].minor.yy0.z);}
+{sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy528,yymsp[-3].minor.yy0.z,yymsp[-1].minor.yy0.z);}
break;
case 71: /* tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
{
- sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy562, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy562, yymsp[-1].minor.yy64);
- sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy64);
+ sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy322, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy322, yymsp[-1].minor.yy394);
+ sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy394);
}
break;
case 73: /* onconf ::= */
case 75: /* orconf ::= */ yytestcase(yyruleno==75);
-{yymsp[1].minor.yy64 = OE_Default;}
+{yymsp[1].minor.yy394 = OE_Default;}
break;
case 74: /* onconf ::= ON CONFLICT resolvetype */
-{yymsp[-2].minor.yy64 = yymsp[0].minor.yy64;}
+{yymsp[-2].minor.yy394 = yymsp[0].minor.yy394;}
break;
case 77: /* resolvetype ::= IGNORE */
-{yymsp[0].minor.yy64 = OE_Ignore;}
+{yymsp[0].minor.yy394 = OE_Ignore;}
break;
case 78: /* resolvetype ::= REPLACE */
case 172: /* insert_cmd ::= REPLACE */ yytestcase(yyruleno==172);
-{yymsp[0].minor.yy64 = OE_Replace;}
+{yymsp[0].minor.yy394 = OE_Replace;}
break;
case 79: /* cmd ::= DROP TABLE ifexists fullname */
{
- sqlite3DropTable(pParse, yymsp[0].minor.yy607, 0, yymsp[-1].minor.yy64);
+ sqlite3DropTable(pParse, yymsp[0].minor.yy131, 0, yymsp[-1].minor.yy394);
}
break;
case 82: /* 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.yy562, yymsp[0].minor.yy303, yymsp[-7].minor.yy64, yymsp[-5].minor.yy64);
+ sqlite3CreateView(pParse, &yymsp[-8].minor.yy0, &yymsp[-4].minor.yy0, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy322, yymsp[0].minor.yy47, yymsp[-7].minor.yy394, yymsp[-5].minor.yy394);
}
break;
case 83: /* cmd ::= DROP VIEW ifexists fullname */
{
- sqlite3DropTable(pParse, yymsp[0].minor.yy607, 1, yymsp[-1].minor.yy64);
+ sqlite3DropTable(pParse, yymsp[0].minor.yy131, 1, yymsp[-1].minor.yy394);
}
break;
case 84: /* cmd ::= select */
{
SelectDest dest = {SRT_Output, 0, 0, 0, 0, 0, 0};
- sqlite3Select(pParse, yymsp[0].minor.yy303, &dest);
- sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy303);
+ sqlite3Select(pParse, yymsp[0].minor.yy47, &dest);
+ sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy47);
}
break;
case 85: /* select ::= WITH wqlist selectnowith */
-{yymsp[-2].minor.yy303 = attachWithToSelect(pParse,yymsp[0].minor.yy303,yymsp[-1].minor.yy43);}
+{yymsp[-2].minor.yy47 = attachWithToSelect(pParse,yymsp[0].minor.yy47,yymsp[-1].minor.yy521);}
break;
case 86: /* select ::= WITH RECURSIVE wqlist selectnowith */
-{yymsp[-3].minor.yy303 = attachWithToSelect(pParse,yymsp[0].minor.yy303,yymsp[-1].minor.yy43);}
+{yymsp[-3].minor.yy47 = attachWithToSelect(pParse,yymsp[0].minor.yy47,yymsp[-1].minor.yy521);}
break;
case 87: /* select ::= selectnowith */
{
- Select *p = yymsp[0].minor.yy303;
+ Select *p = yymsp[0].minor.yy47;
if( p ){
parserDoubleLinkSelect(pParse, p);
}
- yymsp[0].minor.yy303 = p; /*A-overwrites-X*/
+ yymsp[0].minor.yy47 = p; /*A-overwrites-X*/
}
break;
case 88: /* selectnowith ::= selectnowith multiselect_op oneselect */
{
- Select *pRhs = yymsp[0].minor.yy303;
- Select *pLhs = yymsp[-2].minor.yy303;
+ Select *pRhs = yymsp[0].minor.yy47;
+ Select *pLhs = yymsp[-2].minor.yy47;
if( pRhs && pRhs->pPrior ){
SrcList *pFrom;
Token x;
@@ -163325,140 +165193,140 @@ static YYACTIONTYPE yy_reduce(
pRhs = sqlite3SelectNew(pParse,0,pFrom,0,0,0,0,0,0);
}
if( pRhs ){
- pRhs->op = (u8)yymsp[-1].minor.yy64;
+ pRhs->op = (u8)yymsp[-1].minor.yy394;
pRhs->pPrior = pLhs;
if( ALWAYS(pLhs) ) pLhs->selFlags &= ~SF_MultiValue;
pRhs->selFlags &= ~SF_MultiValue;
- if( yymsp[-1].minor.yy64!=TK_ALL ) pParse->hasCompound = 1;
+ if( yymsp[-1].minor.yy394!=TK_ALL ) pParse->hasCompound = 1;
}else{
sqlite3SelectDelete(pParse->db, pLhs);
}
- yymsp[-2].minor.yy303 = pRhs;
+ yymsp[-2].minor.yy47 = pRhs;
}
break;
case 89: /* multiselect_op ::= UNION */
case 91: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==91);
-{yymsp[0].minor.yy64 = yymsp[0].major; /*A-overwrites-OP*/}
+{yymsp[0].minor.yy394 = yymsp[0].major; /*A-overwrites-OP*/}
break;
case 90: /* multiselect_op ::= UNION ALL */
-{yymsp[-1].minor.yy64 = TK_ALL;}
+{yymsp[-1].minor.yy394 = TK_ALL;}
break;
case 92: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
{
- yymsp[-8].minor.yy303 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy562,yymsp[-5].minor.yy607,yymsp[-4].minor.yy626,yymsp[-3].minor.yy562,yymsp[-2].minor.yy626,yymsp[-1].minor.yy562,yymsp[-7].minor.yy64,yymsp[0].minor.yy626);
+ yymsp[-8].minor.yy47 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy322,yymsp[-5].minor.yy131,yymsp[-4].minor.yy528,yymsp[-3].minor.yy322,yymsp[-2].minor.yy528,yymsp[-1].minor.yy322,yymsp[-7].minor.yy394,yymsp[0].minor.yy528);
}
break;
case 93: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */
{
- yymsp[-9].minor.yy303 = sqlite3SelectNew(pParse,yymsp[-7].minor.yy562,yymsp[-6].minor.yy607,yymsp[-5].minor.yy626,yymsp[-4].minor.yy562,yymsp[-3].minor.yy626,yymsp[-1].minor.yy562,yymsp[-8].minor.yy64,yymsp[0].minor.yy626);
- if( yymsp[-9].minor.yy303 ){
- yymsp[-9].minor.yy303->pWinDefn = yymsp[-2].minor.yy375;
+ yymsp[-9].minor.yy47 = sqlite3SelectNew(pParse,yymsp[-7].minor.yy322,yymsp[-6].minor.yy131,yymsp[-5].minor.yy528,yymsp[-4].minor.yy322,yymsp[-3].minor.yy528,yymsp[-1].minor.yy322,yymsp[-8].minor.yy394,yymsp[0].minor.yy528);
+ if( yymsp[-9].minor.yy47 ){
+ yymsp[-9].minor.yy47->pWinDefn = yymsp[-2].minor.yy41;
}else{
- sqlite3WindowListDelete(pParse->db, yymsp[-2].minor.yy375);
+ sqlite3WindowListDelete(pParse->db, yymsp[-2].minor.yy41);
}
}
break;
case 94: /* values ::= VALUES LP nexprlist RP */
{
- yymsp[-3].minor.yy303 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy562,0,0,0,0,0,SF_Values,0);
+ yymsp[-3].minor.yy47 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy322,0,0,0,0,0,SF_Values,0);
}
break;
case 95: /* values ::= values COMMA LP nexprlist RP */
{
- Select *pRight, *pLeft = yymsp[-4].minor.yy303;
- pRight = sqlite3SelectNew(pParse,yymsp[-1].minor.yy562,0,0,0,0,0,SF_Values|SF_MultiValue,0);
+ Select *pRight, *pLeft = yymsp[-4].minor.yy47;
+ pRight = sqlite3SelectNew(pParse,yymsp[-1].minor.yy322,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.yy303 = pRight;
+ yymsp[-4].minor.yy47 = pRight;
}else{
- yymsp[-4].minor.yy303 = pLeft;
+ yymsp[-4].minor.yy47 = pLeft;
}
}
break;
case 96: /* distinct ::= DISTINCT */
-{yymsp[0].minor.yy64 = SF_Distinct;}
+{yymsp[0].minor.yy394 = SF_Distinct;}
break;
case 97: /* distinct ::= ALL */
-{yymsp[0].minor.yy64 = SF_All;}
+{yymsp[0].minor.yy394 = SF_All;}
break;
case 99: /* sclp ::= */
case 132: /* orderby_opt ::= */ yytestcase(yyruleno==132);
case 142: /* groupby_opt ::= */ yytestcase(yyruleno==142);
- case 229: /* exprlist ::= */ yytestcase(yyruleno==229);
- case 232: /* paren_exprlist ::= */ yytestcase(yyruleno==232);
- case 237: /* eidlist_opt ::= */ yytestcase(yyruleno==237);
-{yymsp[1].minor.yy562 = 0;}
+ case 230: /* exprlist ::= */ yytestcase(yyruleno==230);
+ case 233: /* paren_exprlist ::= */ yytestcase(yyruleno==233);
+ case 238: /* eidlist_opt ::= */ yytestcase(yyruleno==238);
+{yymsp[1].minor.yy322 = 0;}
break;
case 100: /* selcollist ::= sclp scanpt expr scanpt as */
{
- yymsp[-4].minor.yy562 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy562, yymsp[-2].minor.yy626);
- if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy562, &yymsp[0].minor.yy0, 1);
- sqlite3ExprListSetSpan(pParse,yymsp[-4].minor.yy562,yymsp[-3].minor.yy600,yymsp[-1].minor.yy600);
+ yymsp[-4].minor.yy322 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy322, yymsp[-2].minor.yy528);
+ if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy322, &yymsp[0].minor.yy0, 1);
+ sqlite3ExprListSetSpan(pParse,yymsp[-4].minor.yy322,yymsp[-3].minor.yy522,yymsp[-1].minor.yy522);
}
break;
case 101: /* selcollist ::= sclp scanpt STAR */
{
Expr *p = sqlite3Expr(pParse->db, TK_ASTERISK, 0);
- yymsp[-2].minor.yy562 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy562, p);
+ yymsp[-2].minor.yy322 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy322, p);
}
break;
case 102: /* selcollist ::= sclp scanpt nm DOT STAR */
{
Expr *pRight = sqlite3PExpr(pParse, TK_ASTERISK, 0, 0);
- Expr *pLeft = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
+ Expr *pLeft = tokenExpr(pParse, TK_ID, yymsp[-2].minor.yy0);
Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight);
- yymsp[-4].minor.yy562 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy562, pDot);
+ yymsp[-4].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy322, pDot);
}
break;
case 103: /* as ::= AS nm */
case 114: /* dbnm ::= DOT nm */ yytestcase(yyruleno==114);
- case 253: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==253);
- case 254: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==254);
+ case 254: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==254);
+ case 255: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==255);
{yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;}
break;
case 105: /* from ::= */
case 108: /* stl_prefix ::= */ yytestcase(yyruleno==108);
-{yymsp[1].minor.yy607 = 0;}
+{yymsp[1].minor.yy131 = 0;}
break;
case 106: /* from ::= FROM seltablist */
{
- yymsp[-1].minor.yy607 = yymsp[0].minor.yy607;
- sqlite3SrcListShiftJoinType(yymsp[-1].minor.yy607);
+ yymsp[-1].minor.yy131 = yymsp[0].minor.yy131;
+ sqlite3SrcListShiftJoinType(yymsp[-1].minor.yy131);
}
break;
case 107: /* stl_prefix ::= seltablist joinop */
{
- if( ALWAYS(yymsp[-1].minor.yy607 && yymsp[-1].minor.yy607->nSrc>0) ) yymsp[-1].minor.yy607->a[yymsp[-1].minor.yy607->nSrc-1].fg.jointype = (u8)yymsp[0].minor.yy64;
+ if( ALWAYS(yymsp[-1].minor.yy131 && yymsp[-1].minor.yy131->nSrc>0) ) yymsp[-1].minor.yy131->a[yymsp[-1].minor.yy131->nSrc-1].fg.jointype = (u8)yymsp[0].minor.yy394;
}
break;
case 109: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
{
- yymsp[-6].minor.yy607 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy607,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy626,yymsp[0].minor.yy240);
- sqlite3SrcListIndexedBy(pParse, yymsp[-6].minor.yy607, &yymsp[-2].minor.yy0);
+ yymsp[-6].minor.yy131 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy131,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy528,yymsp[0].minor.yy254);
+ sqlite3SrcListIndexedBy(pParse, yymsp[-6].minor.yy131, &yymsp[-2].minor.yy0);
}
break;
case 110: /* seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_opt using_opt */
{
- yymsp[-8].minor.yy607 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-8].minor.yy607,&yymsp[-7].minor.yy0,&yymsp[-6].minor.yy0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy626,yymsp[0].minor.yy240);
- sqlite3SrcListFuncArgs(pParse, yymsp[-8].minor.yy607, yymsp[-4].minor.yy562);
+ yymsp[-8].minor.yy131 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-8].minor.yy131,&yymsp[-7].minor.yy0,&yymsp[-6].minor.yy0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy528,yymsp[0].minor.yy254);
+ sqlite3SrcListFuncArgs(pParse, yymsp[-8].minor.yy131, yymsp[-4].minor.yy322);
}
break;
case 111: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */
{
- yymsp[-6].minor.yy607 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy607,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy303,yymsp[-1].minor.yy626,yymsp[0].minor.yy240);
+ yymsp[-6].minor.yy131 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy131,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy47,yymsp[-1].minor.yy528,yymsp[0].minor.yy254);
}
break;
case 112: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
{
- if( yymsp[-6].minor.yy607==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy626==0 && yymsp[0].minor.yy240==0 ){
- yymsp[-6].minor.yy607 = yymsp[-4].minor.yy607;
- }else if( yymsp[-4].minor.yy607->nSrc==1 ){
- yymsp[-6].minor.yy607 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy607,0,0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy626,yymsp[0].minor.yy240);
- if( yymsp[-6].minor.yy607 ){
- SrcItem *pNew = &yymsp[-6].minor.yy607->a[yymsp[-6].minor.yy607->nSrc-1];
- SrcItem *pOld = yymsp[-4].minor.yy607->a;
+ if( yymsp[-6].minor.yy131==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy528==0 && yymsp[0].minor.yy254==0 ){
+ yymsp[-6].minor.yy131 = yymsp[-4].minor.yy131;
+ }else if( yymsp[-4].minor.yy131->nSrc==1 ){
+ yymsp[-6].minor.yy131 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy131,0,0,&yymsp[-2].minor.yy0,0,yymsp[-1].minor.yy528,yymsp[0].minor.yy254);
+ if( yymsp[-6].minor.yy131 ){
+ SrcItem *pNew = &yymsp[-6].minor.yy131->a[yymsp[-6].minor.yy131->nSrc-1];
+ SrcItem *pOld = yymsp[-4].minor.yy131->a;
pNew->zName = pOld->zName;
pNew->zDatabase = pOld->zDatabase;
pNew->pSelect = pOld->pSelect;
@@ -163471,12 +165339,12 @@ static YYACTIONTYPE yy_reduce(
pOld->zName = pOld->zDatabase = 0;
pOld->pSelect = 0;
}
- sqlite3SrcListDelete(pParse->db, yymsp[-4].minor.yy607);
+ sqlite3SrcListDelete(pParse->db, yymsp[-4].minor.yy131);
}else{
Select *pSubquery;
- sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy607);
- pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy607,0,0,0,0,SF_NestedFrom,0);
- yymsp[-6].minor.yy607 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy607,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy626,yymsp[0].minor.yy240);
+ sqlite3SrcListShiftJoinType(yymsp[-4].minor.yy131);
+ pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy131,0,0,0,0,SF_NestedFrom,0);
+ yymsp[-6].minor.yy131 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy131,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy528,yymsp[0].minor.yy254);
}
}
break;
@@ -163486,65 +165354,65 @@ static YYACTIONTYPE yy_reduce(
break;
case 115: /* fullname ::= nm */
{
- yylhsminor.yy607 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0);
- if( IN_RENAME_OBJECT && yylhsminor.yy607 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy607->a[0].zName, &yymsp[0].minor.yy0);
+ yylhsminor.yy131 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0);
+ if( IN_RENAME_OBJECT && yylhsminor.yy131 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy131->a[0].zName, &yymsp[0].minor.yy0);
}
- yymsp[0].minor.yy607 = yylhsminor.yy607;
+ yymsp[0].minor.yy131 = yylhsminor.yy131;
break;
case 116: /* fullname ::= nm DOT nm */
{
- yylhsminor.yy607 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);
- if( IN_RENAME_OBJECT && yylhsminor.yy607 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy607->a[0].zName, &yymsp[0].minor.yy0);
+ yylhsminor.yy131 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);
+ if( IN_RENAME_OBJECT && yylhsminor.yy131 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy131->a[0].zName, &yymsp[0].minor.yy0);
}
- yymsp[-2].minor.yy607 = yylhsminor.yy607;
+ yymsp[-2].minor.yy131 = yylhsminor.yy131;
break;
case 117: /* xfullname ::= nm */
-{yymsp[0].minor.yy607 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0); /*A-overwrites-X*/}
+{yymsp[0].minor.yy131 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0); /*A-overwrites-X*/}
break;
case 118: /* xfullname ::= nm DOT nm */
-{yymsp[-2].minor.yy607 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/}
+{yymsp[-2].minor.yy131 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/}
break;
case 119: /* xfullname ::= nm DOT nm AS nm */
{
- yymsp[-4].minor.yy607 = sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,&yymsp[-2].minor.yy0); /*A-overwrites-X*/
- if( yymsp[-4].minor.yy607 ) yymsp[-4].minor.yy607->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
+ yymsp[-4].minor.yy131 = sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,&yymsp[-2].minor.yy0); /*A-overwrites-X*/
+ if( yymsp[-4].minor.yy131 ) yymsp[-4].minor.yy131->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
}
break;
case 120: /* xfullname ::= nm AS nm */
{
- yymsp[-2].minor.yy607 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,0); /*A-overwrites-X*/
- if( yymsp[-2].minor.yy607 ) yymsp[-2].minor.yy607->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
+ yymsp[-2].minor.yy131 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,0); /*A-overwrites-X*/
+ if( yymsp[-2].minor.yy131 ) yymsp[-2].minor.yy131->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
}
break;
case 121: /* joinop ::= COMMA|JOIN */
-{ yymsp[0].minor.yy64 = JT_INNER; }
+{ yymsp[0].minor.yy394 = JT_INNER; }
break;
case 122: /* joinop ::= JOIN_KW JOIN */
-{yymsp[-1].minor.yy64 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); /*X-overwrites-A*/}
+{yymsp[-1].minor.yy394 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); /*X-overwrites-A*/}
break;
case 123: /* joinop ::= JOIN_KW nm JOIN */
-{yymsp[-2].minor.yy64 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/}
+{yymsp[-2].minor.yy394 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/}
break;
case 124: /* joinop ::= JOIN_KW nm nm JOIN */
-{yymsp[-3].minor.yy64 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/}
+{yymsp[-3].minor.yy394 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/}
break;
case 125: /* on_opt ::= ON expr */
case 145: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==145);
case 152: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==152);
case 154: /* where_opt_ret ::= WHERE expr */ yytestcase(yyruleno==154);
- case 225: /* case_else ::= ELSE expr */ yytestcase(yyruleno==225);
- case 246: /* vinto ::= INTO expr */ yytestcase(yyruleno==246);
-{yymsp[-1].minor.yy626 = yymsp[0].minor.yy626;}
+ case 226: /* case_else ::= ELSE expr */ yytestcase(yyruleno==226);
+ case 247: /* vinto ::= INTO expr */ yytestcase(yyruleno==247);
+{yymsp[-1].minor.yy528 = yymsp[0].minor.yy528;}
break;
case 126: /* on_opt ::= */
case 144: /* having_opt ::= */ yytestcase(yyruleno==144);
case 146: /* limit_opt ::= */ yytestcase(yyruleno==146);
case 151: /* where_opt ::= */ yytestcase(yyruleno==151);
case 153: /* where_opt_ret ::= */ yytestcase(yyruleno==153);
- case 226: /* case_else ::= */ yytestcase(yyruleno==226);
- case 228: /* case_operand ::= */ yytestcase(yyruleno==228);
- case 247: /* vinto ::= */ yytestcase(yyruleno==247);
-{yymsp[1].minor.yy626 = 0;}
+ case 227: /* case_else ::= */ yytestcase(yyruleno==227);
+ case 229: /* case_operand ::= */ yytestcase(yyruleno==229);
+ case 248: /* vinto ::= */ yytestcase(yyruleno==248);
+{yymsp[1].minor.yy528 = 0;}
break;
case 128: /* indexed_opt ::= INDEXED BY nm */
{yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;}
@@ -163553,185 +165421,181 @@ static YYACTIONTYPE yy_reduce(
{yymsp[-1].minor.yy0.z=0; yymsp[-1].minor.yy0.n=1;}
break;
case 130: /* using_opt ::= USING LP idlist RP */
-{yymsp[-3].minor.yy240 = yymsp[-1].minor.yy240;}
+{yymsp[-3].minor.yy254 = yymsp[-1].minor.yy254;}
break;
case 131: /* using_opt ::= */
case 173: /* idlist_opt ::= */ yytestcase(yyruleno==173);
-{yymsp[1].minor.yy240 = 0;}
+{yymsp[1].minor.yy254 = 0;}
break;
case 133: /* orderby_opt ::= ORDER BY sortlist */
case 143: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==143);
-{yymsp[-2].minor.yy562 = yymsp[0].minor.yy562;}
+{yymsp[-2].minor.yy322 = yymsp[0].minor.yy322;}
break;
case 134: /* sortlist ::= sortlist COMMA expr sortorder nulls */
{
- yymsp[-4].minor.yy562 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy562,yymsp[-2].minor.yy626);
- sqlite3ExprListSetSortOrder(yymsp[-4].minor.yy562,yymsp[-1].minor.yy64,yymsp[0].minor.yy64);
+ yymsp[-4].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy322,yymsp[-2].minor.yy528);
+ sqlite3ExprListSetSortOrder(yymsp[-4].minor.yy322,yymsp[-1].minor.yy394,yymsp[0].minor.yy394);
}
break;
case 135: /* sortlist ::= expr sortorder nulls */
{
- yymsp[-2].minor.yy562 = sqlite3ExprListAppend(pParse,0,yymsp[-2].minor.yy626); /*A-overwrites-Y*/
- sqlite3ExprListSetSortOrder(yymsp[-2].minor.yy562,yymsp[-1].minor.yy64,yymsp[0].minor.yy64);
+ yymsp[-2].minor.yy322 = sqlite3ExprListAppend(pParse,0,yymsp[-2].minor.yy528); /*A-overwrites-Y*/
+ sqlite3ExprListSetSortOrder(yymsp[-2].minor.yy322,yymsp[-1].minor.yy394,yymsp[0].minor.yy394);
}
break;
case 136: /* sortorder ::= ASC */
-{yymsp[0].minor.yy64 = SQLITE_SO_ASC;}
+{yymsp[0].minor.yy394 = SQLITE_SO_ASC;}
break;
case 137: /* sortorder ::= DESC */
-{yymsp[0].minor.yy64 = SQLITE_SO_DESC;}
+{yymsp[0].minor.yy394 = SQLITE_SO_DESC;}
break;
case 138: /* sortorder ::= */
case 141: /* nulls ::= */ yytestcase(yyruleno==141);
-{yymsp[1].minor.yy64 = SQLITE_SO_UNDEFINED;}
+{yymsp[1].minor.yy394 = SQLITE_SO_UNDEFINED;}
break;
case 139: /* nulls ::= NULLS FIRST */
-{yymsp[-1].minor.yy64 = SQLITE_SO_ASC;}
+{yymsp[-1].minor.yy394 = SQLITE_SO_ASC;}
break;
case 140: /* nulls ::= NULLS LAST */
-{yymsp[-1].minor.yy64 = SQLITE_SO_DESC;}
+{yymsp[-1].minor.yy394 = SQLITE_SO_DESC;}
break;
case 147: /* limit_opt ::= LIMIT expr */
-{yymsp[-1].minor.yy626 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy626,0);}
+{yymsp[-1].minor.yy528 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy528,0);}
break;
case 148: /* limit_opt ::= LIMIT expr OFFSET expr */
-{yymsp[-3].minor.yy626 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[-2].minor.yy626,yymsp[0].minor.yy626);}
+{yymsp[-3].minor.yy528 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[-2].minor.yy528,yymsp[0].minor.yy528);}
break;
case 149: /* limit_opt ::= LIMIT expr COMMA expr */
-{yymsp[-3].minor.yy626 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy626,yymsp[-2].minor.yy626);}
+{yymsp[-3].minor.yy528 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy528,yymsp[-2].minor.yy528);}
break;
case 150: /* cmd ::= with DELETE FROM xfullname indexed_opt where_opt_ret */
{
- sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy607, &yymsp[-1].minor.yy0);
- sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy607,yymsp[0].minor.yy626,0,0);
+ sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy131, &yymsp[-1].minor.yy0);
+ sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy131,yymsp[0].minor.yy528,0,0);
}
break;
case 155: /* where_opt_ret ::= RETURNING selcollist */
-{sqlite3AddReturning(pParse,yymsp[0].minor.yy562); yymsp[-1].minor.yy626 = 0;}
+{sqlite3AddReturning(pParse,yymsp[0].minor.yy322); yymsp[-1].minor.yy528 = 0;}
break;
case 156: /* where_opt_ret ::= WHERE expr RETURNING selcollist */
-{sqlite3AddReturning(pParse,yymsp[0].minor.yy562); yymsp[-3].minor.yy626 = yymsp[-2].minor.yy626;}
+{sqlite3AddReturning(pParse,yymsp[0].minor.yy322); yymsp[-3].minor.yy528 = yymsp[-2].minor.yy528;}
break;
case 157: /* cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist from where_opt_ret */
{
- sqlite3SrcListIndexedBy(pParse, yymsp[-5].minor.yy607, &yymsp[-4].minor.yy0);
- sqlite3ExprListCheckLength(pParse,yymsp[-2].minor.yy562,"set list");
- yymsp[-5].minor.yy607 = sqlite3SrcListAppendList(pParse, yymsp[-5].minor.yy607, yymsp[-1].minor.yy607);
- sqlite3Update(pParse,yymsp[-5].minor.yy607,yymsp[-2].minor.yy562,yymsp[0].minor.yy626,yymsp[-6].minor.yy64,0,0,0);
+ sqlite3SrcListIndexedBy(pParse, yymsp[-5].minor.yy131, &yymsp[-4].minor.yy0);
+ sqlite3ExprListCheckLength(pParse,yymsp[-2].minor.yy322,"set list");
+ yymsp[-5].minor.yy131 = sqlite3SrcListAppendList(pParse, yymsp[-5].minor.yy131, yymsp[-1].minor.yy131);
+ sqlite3Update(pParse,yymsp[-5].minor.yy131,yymsp[-2].minor.yy322,yymsp[0].minor.yy528,yymsp[-6].minor.yy394,0,0,0);
}
break;
case 158: /* setlist ::= setlist COMMA nm EQ expr */
{
- yymsp[-4].minor.yy562 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy562, yymsp[0].minor.yy626);
- sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy562, &yymsp[-2].minor.yy0, 1);
+ yymsp[-4].minor.yy322 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy322, yymsp[0].minor.yy528);
+ sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy322, &yymsp[-2].minor.yy0, 1);
}
break;
case 159: /* setlist ::= setlist COMMA LP idlist RP EQ expr */
{
- yymsp[-6].minor.yy562 = sqlite3ExprListAppendVector(pParse, yymsp[-6].minor.yy562, yymsp[-3].minor.yy240, yymsp[0].minor.yy626);
+ yymsp[-6].minor.yy322 = sqlite3ExprListAppendVector(pParse, yymsp[-6].minor.yy322, yymsp[-3].minor.yy254, yymsp[0].minor.yy528);
}
break;
case 160: /* setlist ::= nm EQ expr */
{
- yylhsminor.yy562 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy626);
- sqlite3ExprListSetName(pParse, yylhsminor.yy562, &yymsp[-2].minor.yy0, 1);
+ yylhsminor.yy322 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy528);
+ sqlite3ExprListSetName(pParse, yylhsminor.yy322, &yymsp[-2].minor.yy0, 1);
}
- yymsp[-2].minor.yy562 = yylhsminor.yy562;
+ yymsp[-2].minor.yy322 = yylhsminor.yy322;
break;
case 161: /* setlist ::= LP idlist RP EQ expr */
{
- yymsp[-4].minor.yy562 = sqlite3ExprListAppendVector(pParse, 0, yymsp[-3].minor.yy240, yymsp[0].minor.yy626);
+ yymsp[-4].minor.yy322 = sqlite3ExprListAppendVector(pParse, 0, yymsp[-3].minor.yy254, yymsp[0].minor.yy528);
}
break;
case 162: /* cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
{
- sqlite3Insert(pParse, yymsp[-3].minor.yy607, yymsp[-1].minor.yy303, yymsp[-2].minor.yy240, yymsp[-5].minor.yy64, yymsp[0].minor.yy138);
+ sqlite3Insert(pParse, yymsp[-3].minor.yy131, yymsp[-1].minor.yy47, yymsp[-2].minor.yy254, yymsp[-5].minor.yy394, yymsp[0].minor.yy444);
}
break;
case 163: /* cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES returning */
{
- sqlite3Insert(pParse, yymsp[-4].minor.yy607, 0, yymsp[-3].minor.yy240, yymsp[-6].minor.yy64, 0);
+ sqlite3Insert(pParse, yymsp[-4].minor.yy131, 0, yymsp[-3].minor.yy254, yymsp[-6].minor.yy394, 0);
}
break;
case 164: /* upsert ::= */
-{ yymsp[1].minor.yy138 = 0; }
+{ yymsp[1].minor.yy444 = 0; }
break;
case 165: /* upsert ::= RETURNING selcollist */
-{ yymsp[-1].minor.yy138 = 0; sqlite3AddReturning(pParse,yymsp[0].minor.yy562); }
+{ yymsp[-1].minor.yy444 = 0; sqlite3AddReturning(pParse,yymsp[0].minor.yy322); }
break;
case 166: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt upsert */
-{ yymsp[-11].minor.yy138 = sqlite3UpsertNew(pParse->db,yymsp[-8].minor.yy562,yymsp[-6].minor.yy626,yymsp[-2].minor.yy562,yymsp[-1].minor.yy626,yymsp[0].minor.yy138);}
+{ yymsp[-11].minor.yy444 = sqlite3UpsertNew(pParse->db,yymsp[-8].minor.yy322,yymsp[-6].minor.yy528,yymsp[-2].minor.yy322,yymsp[-1].minor.yy528,yymsp[0].minor.yy444);}
break;
case 167: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING upsert */
-{ yymsp[-8].minor.yy138 = sqlite3UpsertNew(pParse->db,yymsp[-5].minor.yy562,yymsp[-3].minor.yy626,0,0,yymsp[0].minor.yy138); }
+{ yymsp[-8].minor.yy444 = sqlite3UpsertNew(pParse->db,yymsp[-5].minor.yy322,yymsp[-3].minor.yy528,0,0,yymsp[0].minor.yy444); }
break;
case 168: /* upsert ::= ON CONFLICT DO NOTHING returning */
-{ yymsp[-4].minor.yy138 = sqlite3UpsertNew(pParse->db,0,0,0,0,0); }
+{ yymsp[-4].minor.yy444 = sqlite3UpsertNew(pParse->db,0,0,0,0,0); }
break;
case 169: /* upsert ::= ON CONFLICT DO UPDATE SET setlist where_opt returning */
-{ yymsp[-7].minor.yy138 = sqlite3UpsertNew(pParse->db,0,0,yymsp[-2].minor.yy562,yymsp[-1].minor.yy626,0);}
+{ yymsp[-7].minor.yy444 = sqlite3UpsertNew(pParse->db,0,0,yymsp[-2].minor.yy322,yymsp[-1].minor.yy528,0);}
break;
case 170: /* returning ::= RETURNING selcollist */
-{sqlite3AddReturning(pParse,yymsp[0].minor.yy562);}
+{sqlite3AddReturning(pParse,yymsp[0].minor.yy322);}
break;
case 174: /* idlist_opt ::= LP idlist RP */
-{yymsp[-2].minor.yy240 = yymsp[-1].minor.yy240;}
+{yymsp[-2].minor.yy254 = yymsp[-1].minor.yy254;}
break;
case 175: /* idlist ::= idlist COMMA nm */
-{yymsp[-2].minor.yy240 = sqlite3IdListAppend(pParse,yymsp[-2].minor.yy240,&yymsp[0].minor.yy0);}
+{yymsp[-2].minor.yy254 = sqlite3IdListAppend(pParse,yymsp[-2].minor.yy254,&yymsp[0].minor.yy0);}
break;
case 176: /* idlist ::= nm */
-{yymsp[0].minor.yy240 = sqlite3IdListAppend(pParse,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/}
+{yymsp[0].minor.yy254 = sqlite3IdListAppend(pParse,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/}
break;
case 177: /* expr ::= LP expr RP */
-{yymsp[-2].minor.yy626 = yymsp[-1].minor.yy626;}
+{yymsp[-2].minor.yy528 = yymsp[-1].minor.yy528;}
break;
case 178: /* expr ::= ID|INDEXED */
case 179: /* expr ::= JOIN_KW */ yytestcase(yyruleno==179);
-{yymsp[0].minor.yy626=tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/}
+{yymsp[0].minor.yy528=tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/}
break;
case 180: /* expr ::= nm DOT nm */
{
- Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
- Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[0].minor.yy0, 1);
- if( IN_RENAME_OBJECT ){
- sqlite3RenameTokenMap(pParse, (void*)temp2, &yymsp[0].minor.yy0);
- sqlite3RenameTokenMap(pParse, (void*)temp1, &yymsp[-2].minor.yy0);
- }
- yylhsminor.yy626 = sqlite3PExpr(pParse, TK_DOT, temp1, temp2);
+ Expr *temp1 = tokenExpr(pParse,TK_ID,yymsp[-2].minor.yy0);
+ Expr *temp2 = tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0);
+ yylhsminor.yy528 = sqlite3PExpr(pParse, TK_DOT, temp1, temp2);
}
- yymsp[-2].minor.yy626 = yylhsminor.yy626;
+ yymsp[-2].minor.yy528 = yylhsminor.yy528;
break;
case 181: /* expr ::= nm DOT nm DOT nm */
{
- Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-4].minor.yy0, 1);
- Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[-2].minor.yy0, 1);
- Expr *temp3 = sqlite3ExprAlloc(pParse->db, TK_ID, &yymsp[0].minor.yy0, 1);
+ Expr *temp1 = tokenExpr(pParse,TK_ID,yymsp[-4].minor.yy0);
+ Expr *temp2 = tokenExpr(pParse,TK_ID,yymsp[-2].minor.yy0);
+ Expr *temp3 = tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0);
Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3);
if( IN_RENAME_OBJECT ){
- sqlite3RenameTokenMap(pParse, (void*)temp3, &yymsp[0].minor.yy0);
- sqlite3RenameTokenMap(pParse, (void*)temp2, &yymsp[-2].minor.yy0);
+ sqlite3RenameTokenRemap(pParse, 0, temp1);
}
- yylhsminor.yy626 = sqlite3PExpr(pParse, TK_DOT, temp1, temp4);
+ yylhsminor.yy528 = sqlite3PExpr(pParse, TK_DOT, temp1, temp4);
}
- yymsp[-4].minor.yy626 = yylhsminor.yy626;
+ yymsp[-4].minor.yy528 = yylhsminor.yy528;
break;
case 182: /* term ::= NULL|FLOAT|BLOB */
case 183: /* term ::= STRING */ yytestcase(yyruleno==183);
-{yymsp[0].minor.yy626=tokenExpr(pParse,yymsp[0].major,yymsp[0].minor.yy0); /*A-overwrites-X*/}
+{yymsp[0].minor.yy528=tokenExpr(pParse,yymsp[0].major,yymsp[0].minor.yy0); /*A-overwrites-X*/}
break;
case 184: /* term ::= INTEGER */
{
- yylhsminor.yy626 = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &yymsp[0].minor.yy0, 1);
+ yylhsminor.yy528 = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &yymsp[0].minor.yy0, 1);
+ if( yylhsminor.yy528 ) yylhsminor.yy528->w.iOfst = (int)(yymsp[0].minor.yy0.z - pParse->zTail);
}
- yymsp[0].minor.yy626 = yylhsminor.yy626;
+ yymsp[0].minor.yy528 = yylhsminor.yy528;
break;
case 185: /* 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.yy626 = tokenExpr(pParse, TK_VARIABLE, yymsp[0].minor.yy0);
- sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy626, n);
+ yymsp[0].minor.yy528 = tokenExpr(pParse, TK_VARIABLE, yymsp[0].minor.yy0);
+ sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy528, 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
@@ -163740,65 +165604,65 @@ static YYACTIONTYPE yy_reduce(
assert( t.n>=2 );
if( pParse->nested==0 ){
sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", &t);
- yymsp[0].minor.yy626 = 0;
+ yymsp[0].minor.yy528 = 0;
}else{
- yymsp[0].minor.yy626 = sqlite3PExpr(pParse, TK_REGISTER, 0, 0);
- if( yymsp[0].minor.yy626 ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy626->iTable);
+ yymsp[0].minor.yy528 = sqlite3PExpr(pParse, TK_REGISTER, 0, 0);
+ if( yymsp[0].minor.yy528 ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy528->iTable);
}
}
}
break;
case 186: /* expr ::= expr COLLATE ID|STRING */
{
- yymsp[-2].minor.yy626 = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy626, &yymsp[0].minor.yy0, 1);
+ yymsp[-2].minor.yy528 = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy528, &yymsp[0].minor.yy0, 1);
}
break;
case 187: /* expr ::= CAST LP expr AS typetoken RP */
{
- yymsp[-5].minor.yy626 = sqlite3ExprAlloc(pParse->db, TK_CAST, &yymsp[-1].minor.yy0, 1);
- sqlite3ExprAttachSubtrees(pParse->db, yymsp[-5].minor.yy626, yymsp[-3].minor.yy626, 0);
+ yymsp[-5].minor.yy528 = sqlite3ExprAlloc(pParse->db, TK_CAST, &yymsp[-1].minor.yy0, 1);
+ sqlite3ExprAttachSubtrees(pParse->db, yymsp[-5].minor.yy528, yymsp[-3].minor.yy528, 0);
}
break;
case 188: /* expr ::= ID|INDEXED LP distinct exprlist RP */
{
- yylhsminor.yy626 = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy562, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy64);
+ yylhsminor.yy528 = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy322, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy394);
}
- yymsp[-4].minor.yy626 = yylhsminor.yy626;
+ yymsp[-4].minor.yy528 = yylhsminor.yy528;
break;
case 189: /* expr ::= ID|INDEXED LP STAR RP */
{
- yylhsminor.yy626 = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0, 0);
+ yylhsminor.yy528 = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0, 0);
}
- yymsp[-3].minor.yy626 = yylhsminor.yy626;
+ yymsp[-3].minor.yy528 = yylhsminor.yy528;
break;
case 190: /* expr ::= ID|INDEXED LP distinct exprlist RP filter_over */
{
- yylhsminor.yy626 = sqlite3ExprFunction(pParse, yymsp[-2].minor.yy562, &yymsp[-5].minor.yy0, yymsp[-3].minor.yy64);
- sqlite3WindowAttach(pParse, yylhsminor.yy626, yymsp[0].minor.yy375);
+ yylhsminor.yy528 = sqlite3ExprFunction(pParse, yymsp[-2].minor.yy322, &yymsp[-5].minor.yy0, yymsp[-3].minor.yy394);
+ sqlite3WindowAttach(pParse, yylhsminor.yy528, yymsp[0].minor.yy41);
}
- yymsp[-5].minor.yy626 = yylhsminor.yy626;
+ yymsp[-5].minor.yy528 = yylhsminor.yy528;
break;
case 191: /* expr ::= ID|INDEXED LP STAR RP filter_over */
{
- yylhsminor.yy626 = sqlite3ExprFunction(pParse, 0, &yymsp[-4].minor.yy0, 0);
- sqlite3WindowAttach(pParse, yylhsminor.yy626, yymsp[0].minor.yy375);
+ yylhsminor.yy528 = sqlite3ExprFunction(pParse, 0, &yymsp[-4].minor.yy0, 0);
+ sqlite3WindowAttach(pParse, yylhsminor.yy528, yymsp[0].minor.yy41);
}
- yymsp[-4].minor.yy626 = yylhsminor.yy626;
+ yymsp[-4].minor.yy528 = yylhsminor.yy528;
break;
case 192: /* term ::= CTIME_KW */
{
- yylhsminor.yy626 = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0, 0);
+ yylhsminor.yy528 = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0, 0);
}
- yymsp[0].minor.yy626 = yylhsminor.yy626;
+ yymsp[0].minor.yy528 = yylhsminor.yy528;
break;
case 193: /* expr ::= LP nexprlist COMMA expr RP */
{
- ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy562, yymsp[-1].minor.yy626);
- yymsp[-4].minor.yy626 = sqlite3PExpr(pParse, TK_VECTOR, 0, 0);
- if( yymsp[-4].minor.yy626 ){
- yymsp[-4].minor.yy626->x.pList = pList;
+ ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy322, yymsp[-1].minor.yy528);
+ yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_VECTOR, 0, 0);
+ if( yymsp[-4].minor.yy528 ){
+ yymsp[-4].minor.yy528->x.pList = pList;
if( ALWAYS(pList->nExpr) ){
- yymsp[-4].minor.yy626->flags |= pList->a[0].pExpr->flags & EP_Propagate;
+ yymsp[-4].minor.yy528->flags |= pList->a[0].pExpr->flags & EP_Propagate;
}
}else{
sqlite3ExprListDelete(pParse->db, pList);
@@ -163806,7 +165670,7 @@ static YYACTIONTYPE yy_reduce(
}
break;
case 194: /* expr ::= expr AND expr */
-{yymsp[-2].minor.yy626=sqlite3ExprAnd(pParse,yymsp[-2].minor.yy626,yymsp[0].minor.yy626);}
+{yymsp[-2].minor.yy528=sqlite3ExprAnd(pParse,yymsp[-2].minor.yy528,yymsp[0].minor.yy528);}
break;
case 195: /* expr ::= expr OR expr */
case 196: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==196);
@@ -163815,7 +165679,7 @@ static YYACTIONTYPE yy_reduce(
case 199: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==199);
case 200: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==200);
case 201: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==201);
-{yymsp[-2].minor.yy626=sqlite3PExpr(pParse,yymsp[-1].major,yymsp[-2].minor.yy626,yymsp[0].minor.yy626);}
+{yymsp[-2].minor.yy528=sqlite3PExpr(pParse,yymsp[-1].major,yymsp[-2].minor.yy528,yymsp[0].minor.yy528);}
break;
case 202: /* 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*/}
@@ -163825,11 +165689,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.yy626);
- pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy626);
- yymsp[-2].minor.yy626 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0, 0);
- if( bNot ) yymsp[-2].minor.yy626 = sqlite3PExpr(pParse, TK_NOT, yymsp[-2].minor.yy626, 0);
- if( yymsp[-2].minor.yy626 ) yymsp[-2].minor.yy626->flags |= EP_InfixFunc;
+ pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy528);
+ pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy528);
+ yymsp[-2].minor.yy528 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0, 0);
+ if( bNot ) yymsp[-2].minor.yy528 = sqlite3PExpr(pParse, TK_NOT, yymsp[-2].minor.yy528, 0);
+ if( yymsp[-2].minor.yy528 ) yymsp[-2].minor.yy528->flags |= EP_InfixFunc;
}
break;
case 204: /* expr ::= expr likeop expr ESCAPE expr */
@@ -163837,62 +165701,70 @@ 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.yy626);
- pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy626);
- pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy626);
- yymsp[-4].minor.yy626 = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy0, 0);
- if( bNot ) yymsp[-4].minor.yy626 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy626, 0);
- if( yymsp[-4].minor.yy626 ) yymsp[-4].minor.yy626->flags |= EP_InfixFunc;
+ pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy528);
+ pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy528);
+ pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy528);
+ yymsp[-4].minor.yy528 = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy0, 0);
+ if( bNot ) yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy528, 0);
+ if( yymsp[-4].minor.yy528 ) yymsp[-4].minor.yy528->flags |= EP_InfixFunc;
}
break;
case 205: /* expr ::= expr ISNULL|NOTNULL */
-{yymsp[-1].minor.yy626 = sqlite3PExpr(pParse,yymsp[0].major,yymsp[-1].minor.yy626,0);}
+{yymsp[-1].minor.yy528 = sqlite3PExpr(pParse,yymsp[0].major,yymsp[-1].minor.yy528,0);}
break;
case 206: /* expr ::= expr NOT NULL */
-{yymsp[-2].minor.yy626 = sqlite3PExpr(pParse,TK_NOTNULL,yymsp[-2].minor.yy626,0);}
+{yymsp[-2].minor.yy528 = sqlite3PExpr(pParse,TK_NOTNULL,yymsp[-2].minor.yy528,0);}
break;
case 207: /* expr ::= expr IS expr */
{
- yymsp[-2].minor.yy626 = sqlite3PExpr(pParse,TK_IS,yymsp[-2].minor.yy626,yymsp[0].minor.yy626);
- binaryToUnaryIfNull(pParse, yymsp[0].minor.yy626, yymsp[-2].minor.yy626, TK_ISNULL);
+ yymsp[-2].minor.yy528 = sqlite3PExpr(pParse,TK_IS,yymsp[-2].minor.yy528,yymsp[0].minor.yy528);
+ binaryToUnaryIfNull(pParse, yymsp[0].minor.yy528, yymsp[-2].minor.yy528, TK_ISNULL);
}
break;
case 208: /* expr ::= expr IS NOT expr */
{
- yymsp[-3].minor.yy626 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-3].minor.yy626,yymsp[0].minor.yy626);
- binaryToUnaryIfNull(pParse, yymsp[0].minor.yy626, yymsp[-3].minor.yy626, TK_NOTNULL);
+ yymsp[-3].minor.yy528 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-3].minor.yy528,yymsp[0].minor.yy528);
+ binaryToUnaryIfNull(pParse, yymsp[0].minor.yy528, yymsp[-3].minor.yy528, TK_NOTNULL);
}
break;
case 209: /* expr ::= NOT expr */
case 210: /* expr ::= BITNOT expr */ yytestcase(yyruleno==210);
-{yymsp[-1].minor.yy626 = sqlite3PExpr(pParse, yymsp[-1].major, yymsp[0].minor.yy626, 0);/*A-overwrites-B*/}
+{yymsp[-1].minor.yy528 = sqlite3PExpr(pParse, yymsp[-1].major, yymsp[0].minor.yy528, 0);/*A-overwrites-B*/}
break;
case 211: /* expr ::= PLUS|MINUS expr */
{
- yymsp[-1].minor.yy626 = sqlite3PExpr(pParse, yymsp[-1].major==TK_PLUS ? TK_UPLUS : TK_UMINUS, yymsp[0].minor.yy626, 0);
+ yymsp[-1].minor.yy528 = sqlite3PExpr(pParse, yymsp[-1].major==TK_PLUS ? TK_UPLUS : TK_UMINUS, yymsp[0].minor.yy528, 0);
/*A-overwrites-B*/
}
break;
- case 212: /* between_op ::= BETWEEN */
- case 215: /* in_op ::= IN */ yytestcase(yyruleno==215);
-{yymsp[0].minor.yy64 = 0;}
+ case 212: /* expr ::= expr PTR expr */
+{
+ ExprList *pList = sqlite3ExprListAppend(pParse, 0, yymsp[-2].minor.yy528);
+ pList = sqlite3ExprListAppend(pParse, pList, yymsp[0].minor.yy528);
+ yylhsminor.yy528 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0, 0);
+}
+ yymsp[-2].minor.yy528 = yylhsminor.yy528;
+ break;
+ case 213: /* between_op ::= BETWEEN */
+ case 216: /* in_op ::= IN */ yytestcase(yyruleno==216);
+{yymsp[0].minor.yy394 = 0;}
break;
- case 214: /* expr ::= expr between_op expr AND expr */
+ case 215: /* expr ::= expr between_op expr AND expr */
{
- ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy626);
- pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy626);
- yymsp[-4].minor.yy626 = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy626, 0);
- if( yymsp[-4].minor.yy626 ){
- yymsp[-4].minor.yy626->x.pList = pList;
+ ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy528);
+ pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy528);
+ yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy528, 0);
+ if( yymsp[-4].minor.yy528 ){
+ yymsp[-4].minor.yy528->x.pList = pList;
}else{
sqlite3ExprListDelete(pParse->db, pList);
}
- if( yymsp[-3].minor.yy64 ) yymsp[-4].minor.yy626 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy626, 0);
+ if( yymsp[-3].minor.yy394 ) yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy528, 0);
}
break;
- case 217: /* expr ::= expr in_op LP exprlist RP */
+ case 218: /* expr ::= expr in_op LP exprlist RP */
{
- if( yymsp[-1].minor.yy562==0 ){
+ if( yymsp[-1].minor.yy322==0 ){
/* Expressions of the form
**
** expr1 IN ()
@@ -163901,205 +165773,205 @@ static YYACTIONTYPE yy_reduce(
** simplify to constants 0 (false) and 1 (true), respectively,
** regardless of the value of expr1.
*/
- sqlite3ExprUnmapAndDelete(pParse, yymsp[-4].minor.yy626);
- yymsp[-4].minor.yy626 = sqlite3Expr(pParse->db, TK_INTEGER, yymsp[-3].minor.yy64 ? "1" : "0");
+ sqlite3ExprUnmapAndDelete(pParse, yymsp[-4].minor.yy528);
+ yymsp[-4].minor.yy528 = sqlite3Expr(pParse->db, TK_INTEGER, yymsp[-3].minor.yy394 ? "1" : "0");
}else{
- Expr *pRHS = yymsp[-1].minor.yy562->a[0].pExpr;
- if( yymsp[-1].minor.yy562->nExpr==1 && sqlite3ExprIsConstant(pRHS) && yymsp[-4].minor.yy626->op!=TK_VECTOR ){
- yymsp[-1].minor.yy562->a[0].pExpr = 0;
- sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy562);
+ Expr *pRHS = yymsp[-1].minor.yy322->a[0].pExpr;
+ if( yymsp[-1].minor.yy322->nExpr==1 && sqlite3ExprIsConstant(pRHS) && yymsp[-4].minor.yy528->op!=TK_VECTOR ){
+ yymsp[-1].minor.yy322->a[0].pExpr = 0;
+ sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy322);
pRHS = sqlite3PExpr(pParse, TK_UPLUS, pRHS, 0);
- yymsp[-4].minor.yy626 = sqlite3PExpr(pParse, TK_EQ, yymsp[-4].minor.yy626, pRHS);
+ yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_EQ, yymsp[-4].minor.yy528, pRHS);
}else{
- yymsp[-4].minor.yy626 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy626, 0);
- if( yymsp[-4].minor.yy626==0 ){
- sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy562);
- }else if( yymsp[-4].minor.yy626->pLeft->op==TK_VECTOR ){
- int nExpr = yymsp[-4].minor.yy626->pLeft->x.pList->nExpr;
- Select *pSelectRHS = sqlite3ExprListToValues(pParse, nExpr, yymsp[-1].minor.yy562);
+ yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy528, 0);
+ if( yymsp[-4].minor.yy528==0 ){
+ sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy322);
+ }else if( yymsp[-4].minor.yy528->pLeft->op==TK_VECTOR ){
+ int nExpr = yymsp[-4].minor.yy528->pLeft->x.pList->nExpr;
+ Select *pSelectRHS = sqlite3ExprListToValues(pParse, nExpr, yymsp[-1].minor.yy322);
if( pSelectRHS ){
parserDoubleLinkSelect(pParse, pSelectRHS);
- sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy626, pSelectRHS);
+ sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy528, pSelectRHS);
}
}else{
- yymsp[-4].minor.yy626->x.pList = yymsp[-1].minor.yy562;
- sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy626);
+ yymsp[-4].minor.yy528->x.pList = yymsp[-1].minor.yy322;
+ sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy528);
}
}
- if( yymsp[-3].minor.yy64 ) yymsp[-4].minor.yy626 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy626, 0);
+ if( yymsp[-3].minor.yy394 ) yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy528, 0);
}
}
break;
- case 218: /* expr ::= LP select RP */
+ case 219: /* expr ::= LP select RP */
{
- yymsp[-2].minor.yy626 = sqlite3PExpr(pParse, TK_SELECT, 0, 0);
- sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy626, yymsp[-1].minor.yy303);
+ yymsp[-2].minor.yy528 = sqlite3PExpr(pParse, TK_SELECT, 0, 0);
+ sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy528, yymsp[-1].minor.yy47);
}
break;
- case 219: /* expr ::= expr in_op LP select RP */
+ case 220: /* expr ::= expr in_op LP select RP */
{
- yymsp[-4].minor.yy626 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy626, 0);
- sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy626, yymsp[-1].minor.yy303);
- if( yymsp[-3].minor.yy64 ) yymsp[-4].minor.yy626 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy626, 0);
+ yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy528, 0);
+ sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy528, yymsp[-1].minor.yy47);
+ if( yymsp[-3].minor.yy394 ) yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy528, 0);
}
break;
- case 220: /* expr ::= expr in_op nm dbnm paren_exprlist */
+ case 221: /* expr ::= expr in_op nm dbnm paren_exprlist */
{
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.yy562 ) sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy562);
- yymsp[-4].minor.yy626 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy626, 0);
- sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy626, pSelect);
- if( yymsp[-3].minor.yy64 ) yymsp[-4].minor.yy626 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy626, 0);
+ if( yymsp[0].minor.yy322 ) sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy322);
+ yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy528, 0);
+ sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy528, pSelect);
+ if( yymsp[-3].minor.yy394 ) yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy528, 0);
}
break;
- case 221: /* expr ::= EXISTS LP select RP */
+ case 222: /* expr ::= EXISTS LP select RP */
{
Expr *p;
- p = yymsp[-3].minor.yy626 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0);
- sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy303);
+ p = yymsp[-3].minor.yy528 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0);
+ sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy47);
}
break;
- case 222: /* expr ::= CASE case_operand case_exprlist case_else END */
+ case 223: /* expr ::= CASE case_operand case_exprlist case_else END */
{
- yymsp[-4].minor.yy626 = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy626, 0);
- if( yymsp[-4].minor.yy626 ){
- yymsp[-4].minor.yy626->x.pList = yymsp[-1].minor.yy626 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy562,yymsp[-1].minor.yy626) : yymsp[-2].minor.yy562;
- sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy626);
+ yymsp[-4].minor.yy528 = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy528, 0);
+ if( yymsp[-4].minor.yy528 ){
+ yymsp[-4].minor.yy528->x.pList = yymsp[-1].minor.yy528 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy322,yymsp[-1].minor.yy528) : yymsp[-2].minor.yy322;
+ sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy528);
}else{
- sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy562);
- sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy626);
+ sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy322);
+ sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy528);
}
}
break;
- case 223: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
+ case 224: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
{
- yymsp[-4].minor.yy562 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy562, yymsp[-2].minor.yy626);
- yymsp[-4].minor.yy562 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy562, yymsp[0].minor.yy626);
+ yymsp[-4].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy322, yymsp[-2].minor.yy528);
+ yymsp[-4].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy322, yymsp[0].minor.yy528);
}
break;
- case 224: /* case_exprlist ::= WHEN expr THEN expr */
+ case 225: /* case_exprlist ::= WHEN expr THEN expr */
{
- yymsp[-3].minor.yy562 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy626);
- yymsp[-3].minor.yy562 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy562, yymsp[0].minor.yy626);
+ yymsp[-3].minor.yy322 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy528);
+ yymsp[-3].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy322, yymsp[0].minor.yy528);
}
break;
- case 227: /* case_operand ::= expr */
-{yymsp[0].minor.yy626 = yymsp[0].minor.yy626; /*A-overwrites-X*/}
+ case 228: /* case_operand ::= expr */
+{yymsp[0].minor.yy528 = yymsp[0].minor.yy528; /*A-overwrites-X*/}
break;
- case 230: /* nexprlist ::= nexprlist COMMA expr */
-{yymsp[-2].minor.yy562 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy562,yymsp[0].minor.yy626);}
+ case 231: /* nexprlist ::= nexprlist COMMA expr */
+{yymsp[-2].minor.yy322 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy322,yymsp[0].minor.yy528);}
break;
- case 231: /* nexprlist ::= expr */
-{yymsp[0].minor.yy562 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy626); /*A-overwrites-Y*/}
+ case 232: /* nexprlist ::= expr */
+{yymsp[0].minor.yy322 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy528); /*A-overwrites-Y*/}
break;
- case 233: /* paren_exprlist ::= LP exprlist RP */
- case 238: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==238);
-{yymsp[-2].minor.yy562 = yymsp[-1].minor.yy562;}
+ case 234: /* paren_exprlist ::= LP exprlist RP */
+ case 239: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==239);
+{yymsp[-2].minor.yy322 = yymsp[-1].minor.yy322;}
break;
- case 234: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
+ case 235: /* 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,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy562, yymsp[-10].minor.yy64,
- &yymsp[-11].minor.yy0, yymsp[0].minor.yy626, SQLITE_SO_ASC, yymsp[-8].minor.yy64, SQLITE_IDXTYPE_APPDEF);
+ sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy322, yymsp[-10].minor.yy394,
+ &yymsp[-11].minor.yy0, yymsp[0].minor.yy528, SQLITE_SO_ASC, yymsp[-8].minor.yy394, SQLITE_IDXTYPE_APPDEF);
if( IN_RENAME_OBJECT && pParse->pNewIndex ){
sqlite3RenameTokenMap(pParse, pParse->pNewIndex->zName, &yymsp[-4].minor.yy0);
}
}
break;
- case 235: /* uniqueflag ::= UNIQUE */
- case 277: /* raisetype ::= ABORT */ yytestcase(yyruleno==277);
-{yymsp[0].minor.yy64 = OE_Abort;}
+ case 236: /* uniqueflag ::= UNIQUE */
+ case 278: /* raisetype ::= ABORT */ yytestcase(yyruleno==278);
+{yymsp[0].minor.yy394 = OE_Abort;}
break;
- case 236: /* uniqueflag ::= */
-{yymsp[1].minor.yy64 = OE_None;}
+ case 237: /* uniqueflag ::= */
+{yymsp[1].minor.yy394 = OE_None;}
break;
- case 239: /* eidlist ::= eidlist COMMA nm collate sortorder */
+ case 240: /* eidlist ::= eidlist COMMA nm collate sortorder */
{
- yymsp[-4].minor.yy562 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy562, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy64, yymsp[0].minor.yy64);
+ yymsp[-4].minor.yy322 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy322, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy394, yymsp[0].minor.yy394);
}
break;
- case 240: /* eidlist ::= nm collate sortorder */
+ case 241: /* eidlist ::= nm collate sortorder */
{
- yymsp[-2].minor.yy562 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy64, yymsp[0].minor.yy64); /*A-overwrites-Y*/
+ yymsp[-2].minor.yy322 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy394, yymsp[0].minor.yy394); /*A-overwrites-Y*/
}
break;
- case 243: /* cmd ::= DROP INDEX ifexists fullname */
-{sqlite3DropIndex(pParse, yymsp[0].minor.yy607, yymsp[-1].minor.yy64);}
+ case 244: /* cmd ::= DROP INDEX ifexists fullname */
+{sqlite3DropIndex(pParse, yymsp[0].minor.yy131, yymsp[-1].minor.yy394);}
break;
- case 244: /* cmd ::= VACUUM vinto */
-{sqlite3Vacuum(pParse,0,yymsp[0].minor.yy626);}
+ case 245: /* cmd ::= VACUUM vinto */
+{sqlite3Vacuum(pParse,0,yymsp[0].minor.yy528);}
break;
- case 245: /* cmd ::= VACUUM nm vinto */
-{sqlite3Vacuum(pParse,&yymsp[-1].minor.yy0,yymsp[0].minor.yy626);}
+ case 246: /* cmd ::= VACUUM nm vinto */
+{sqlite3Vacuum(pParse,&yymsp[-1].minor.yy0,yymsp[0].minor.yy528);}
break;
- case 248: /* cmd ::= PRAGMA nm dbnm */
+ case 249: /* cmd ::= PRAGMA nm dbnm */
{sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);}
break;
- case 249: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
+ case 250: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
{sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);}
break;
- case 250: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
+ case 251: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
{sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);}
break;
- case 251: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
+ case 252: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
{sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);}
break;
- case 252: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */
+ case 253: /* 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 255: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
+ case 256: /* 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.yy95, &all);
+ sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy33, &all);
}
break;
- case 256: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
+ case 257: /* 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.yy64, yymsp[-4].minor.yy570.a, yymsp[-4].minor.yy570.b, yymsp[-2].minor.yy607, yymsp[0].minor.yy626, yymsp[-10].minor.yy64, yymsp[-8].minor.yy64);
+ sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy394, yymsp[-4].minor.yy180.a, yymsp[-4].minor.yy180.b, yymsp[-2].minor.yy131, yymsp[0].minor.yy528, yymsp[-10].minor.yy394, yymsp[-8].minor.yy394);
yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/
}
break;
- case 257: /* trigger_time ::= BEFORE|AFTER */
-{ yymsp[0].minor.yy64 = yymsp[0].major; /*A-overwrites-X*/ }
+ case 258: /* trigger_time ::= BEFORE|AFTER */
+{ yymsp[0].minor.yy394 = yymsp[0].major; /*A-overwrites-X*/ }
break;
- case 258: /* trigger_time ::= INSTEAD OF */
-{ yymsp[-1].minor.yy64 = TK_INSTEAD;}
+ case 259: /* trigger_time ::= INSTEAD OF */
+{ yymsp[-1].minor.yy394 = TK_INSTEAD;}
break;
- case 259: /* trigger_time ::= */
-{ yymsp[1].minor.yy64 = TK_BEFORE; }
+ case 260: /* trigger_time ::= */
+{ yymsp[1].minor.yy394 = TK_BEFORE; }
break;
- case 260: /* trigger_event ::= DELETE|INSERT */
- case 261: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==261);
-{yymsp[0].minor.yy570.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy570.b = 0;}
+ case 261: /* trigger_event ::= DELETE|INSERT */
+ case 262: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==262);
+{yymsp[0].minor.yy180.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy180.b = 0;}
break;
- case 262: /* trigger_event ::= UPDATE OF idlist */
-{yymsp[-2].minor.yy570.a = TK_UPDATE; yymsp[-2].minor.yy570.b = yymsp[0].minor.yy240;}
+ case 263: /* trigger_event ::= UPDATE OF idlist */
+{yymsp[-2].minor.yy180.a = TK_UPDATE; yymsp[-2].minor.yy180.b = yymsp[0].minor.yy254;}
break;
- case 263: /* when_clause ::= */
- case 282: /* key_opt ::= */ yytestcase(yyruleno==282);
-{ yymsp[1].minor.yy626 = 0; }
+ case 264: /* when_clause ::= */
+ case 283: /* key_opt ::= */ yytestcase(yyruleno==283);
+{ yymsp[1].minor.yy528 = 0; }
break;
- case 264: /* when_clause ::= WHEN expr */
- case 283: /* key_opt ::= KEY expr */ yytestcase(yyruleno==283);
-{ yymsp[-1].minor.yy626 = yymsp[0].minor.yy626; }
+ case 265: /* when_clause ::= WHEN expr */
+ case 284: /* key_opt ::= KEY expr */ yytestcase(yyruleno==284);
+{ yymsp[-1].minor.yy528 = yymsp[0].minor.yy528; }
break;
- case 265: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
+ case 266: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
{
- assert( yymsp[-2].minor.yy95!=0 );
- yymsp[-2].minor.yy95->pLast->pNext = yymsp[-1].minor.yy95;
- yymsp[-2].minor.yy95->pLast = yymsp[-1].minor.yy95;
+ assert( yymsp[-2].minor.yy33!=0 );
+ yymsp[-2].minor.yy33->pLast->pNext = yymsp[-1].minor.yy33;
+ yymsp[-2].minor.yy33->pLast = yymsp[-1].minor.yy33;
}
break;
- case 266: /* trigger_cmd_list ::= trigger_cmd SEMI */
+ case 267: /* trigger_cmd_list ::= trigger_cmd SEMI */
{
- assert( yymsp[-1].minor.yy95!=0 );
- yymsp[-1].minor.yy95->pLast = yymsp[-1].minor.yy95;
+ assert( yymsp[-1].minor.yy33!=0 );
+ yymsp[-1].minor.yy33->pLast = yymsp[-1].minor.yy33;
}
break;
- case 267: /* trnm ::= nm DOT nm */
+ case 268: /* trnm ::= nm DOT nm */
{
yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;
sqlite3ErrorMsg(pParse,
@@ -164107,369 +165979,369 @@ static YYACTIONTYPE yy_reduce(
"statements within triggers");
}
break;
- case 268: /* tridxby ::= INDEXED BY nm */
+ case 269: /* tridxby ::= INDEXED BY nm */
{
sqlite3ErrorMsg(pParse,
"the INDEXED BY clause is not allowed on UPDATE or DELETE statements "
"within triggers");
}
break;
- case 269: /* tridxby ::= NOT INDEXED */
+ case 270: /* tridxby ::= NOT INDEXED */
{
sqlite3ErrorMsg(pParse,
"the NOT INDEXED clause is not allowed on UPDATE or DELETE statements "
"within triggers");
}
break;
- case 270: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */
-{yylhsminor.yy95 = sqlite3TriggerUpdateStep(pParse, &yymsp[-6].minor.yy0, yymsp[-2].minor.yy607, yymsp[-3].minor.yy562, yymsp[-1].minor.yy626, yymsp[-7].minor.yy64, yymsp[-8].minor.yy0.z, yymsp[0].minor.yy600);}
- yymsp[-8].minor.yy95 = yylhsminor.yy95;
+ case 271: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */
+{yylhsminor.yy33 = sqlite3TriggerUpdateStep(pParse, &yymsp[-6].minor.yy0, yymsp[-2].minor.yy131, yymsp[-3].minor.yy322, yymsp[-1].minor.yy528, yymsp[-7].minor.yy394, yymsp[-8].minor.yy0.z, yymsp[0].minor.yy522);}
+ yymsp[-8].minor.yy33 = yylhsminor.yy33;
break;
- case 271: /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
+ case 272: /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
{
- yylhsminor.yy95 = sqlite3TriggerInsertStep(pParse,&yymsp[-4].minor.yy0,yymsp[-3].minor.yy240,yymsp[-2].minor.yy303,yymsp[-6].minor.yy64,yymsp[-1].minor.yy138,yymsp[-7].minor.yy600,yymsp[0].minor.yy600);/*yylhsminor.yy95-overwrites-yymsp[-6].minor.yy64*/
+ yylhsminor.yy33 = sqlite3TriggerInsertStep(pParse,&yymsp[-4].minor.yy0,yymsp[-3].minor.yy254,yymsp[-2].minor.yy47,yymsp[-6].minor.yy394,yymsp[-1].minor.yy444,yymsp[-7].minor.yy522,yymsp[0].minor.yy522);/*yylhsminor.yy33-overwrites-yymsp[-6].minor.yy394*/
}
- yymsp[-7].minor.yy95 = yylhsminor.yy95;
+ yymsp[-7].minor.yy33 = yylhsminor.yy33;
break;
- case 272: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
-{yylhsminor.yy95 = sqlite3TriggerDeleteStep(pParse, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy626, yymsp[-5].minor.yy0.z, yymsp[0].minor.yy600);}
- yymsp[-5].minor.yy95 = yylhsminor.yy95;
+ case 273: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
+{yylhsminor.yy33 = sqlite3TriggerDeleteStep(pParse, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy528, yymsp[-5].minor.yy0.z, yymsp[0].minor.yy522);}
+ yymsp[-5].minor.yy33 = yylhsminor.yy33;
break;
- case 273: /* trigger_cmd ::= scanpt select scanpt */
-{yylhsminor.yy95 = sqlite3TriggerSelectStep(pParse->db, yymsp[-1].minor.yy303, yymsp[-2].minor.yy600, yymsp[0].minor.yy600); /*yylhsminor.yy95-overwrites-yymsp[-1].minor.yy303*/}
- yymsp[-2].minor.yy95 = yylhsminor.yy95;
+ case 274: /* trigger_cmd ::= scanpt select scanpt */
+{yylhsminor.yy33 = sqlite3TriggerSelectStep(pParse->db, yymsp[-1].minor.yy47, yymsp[-2].minor.yy522, yymsp[0].minor.yy522); /*yylhsminor.yy33-overwrites-yymsp[-1].minor.yy47*/}
+ yymsp[-2].minor.yy33 = yylhsminor.yy33;
break;
- case 274: /* expr ::= RAISE LP IGNORE RP */
+ case 275: /* expr ::= RAISE LP IGNORE RP */
{
- yymsp[-3].minor.yy626 = sqlite3PExpr(pParse, TK_RAISE, 0, 0);
- if( yymsp[-3].minor.yy626 ){
- yymsp[-3].minor.yy626->affExpr = OE_Ignore;
+ yymsp[-3].minor.yy528 = sqlite3PExpr(pParse, TK_RAISE, 0, 0);
+ if( yymsp[-3].minor.yy528 ){
+ yymsp[-3].minor.yy528->affExpr = OE_Ignore;
}
}
break;
- case 275: /* expr ::= RAISE LP raisetype COMMA nm RP */
+ case 276: /* expr ::= RAISE LP raisetype COMMA nm RP */
{
- yymsp[-5].minor.yy626 = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1);
- if( yymsp[-5].minor.yy626 ) {
- yymsp[-5].minor.yy626->affExpr = (char)yymsp[-3].minor.yy64;
+ yymsp[-5].minor.yy528 = sqlite3ExprAlloc(pParse->db, TK_RAISE, &yymsp[-1].minor.yy0, 1);
+ if( yymsp[-5].minor.yy528 ) {
+ yymsp[-5].minor.yy528->affExpr = (char)yymsp[-3].minor.yy394;
}
}
break;
- case 276: /* raisetype ::= ROLLBACK */
-{yymsp[0].minor.yy64 = OE_Rollback;}
+ case 277: /* raisetype ::= ROLLBACK */
+{yymsp[0].minor.yy394 = OE_Rollback;}
break;
- case 278: /* raisetype ::= FAIL */
-{yymsp[0].minor.yy64 = OE_Fail;}
+ case 279: /* raisetype ::= FAIL */
+{yymsp[0].minor.yy394 = OE_Fail;}
break;
- case 279: /* cmd ::= DROP TRIGGER ifexists fullname */
+ case 280: /* cmd ::= DROP TRIGGER ifexists fullname */
{
- sqlite3DropTrigger(pParse,yymsp[0].minor.yy607,yymsp[-1].minor.yy64);
+ sqlite3DropTrigger(pParse,yymsp[0].minor.yy131,yymsp[-1].minor.yy394);
}
break;
- case 280: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
+ case 281: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
{
- sqlite3Attach(pParse, yymsp[-3].minor.yy626, yymsp[-1].minor.yy626, yymsp[0].minor.yy626);
+ sqlite3Attach(pParse, yymsp[-3].minor.yy528, yymsp[-1].minor.yy528, yymsp[0].minor.yy528);
}
break;
- case 281: /* cmd ::= DETACH database_kw_opt expr */
+ case 282: /* cmd ::= DETACH database_kw_opt expr */
{
- sqlite3Detach(pParse, yymsp[0].minor.yy626);
+ sqlite3Detach(pParse, yymsp[0].minor.yy528);
}
break;
- case 284: /* cmd ::= REINDEX */
+ case 285: /* cmd ::= REINDEX */
{sqlite3Reindex(pParse, 0, 0);}
break;
- case 285: /* cmd ::= REINDEX nm dbnm */
+ case 286: /* cmd ::= REINDEX nm dbnm */
{sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
break;
- case 286: /* cmd ::= ANALYZE */
+ case 287: /* cmd ::= ANALYZE */
{sqlite3Analyze(pParse, 0, 0);}
break;
- case 287: /* cmd ::= ANALYZE nm dbnm */
+ case 288: /* cmd ::= ANALYZE nm dbnm */
{sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
break;
- case 288: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
+ case 289: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
{
- sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy607,&yymsp[0].minor.yy0);
+ sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy131,&yymsp[0].minor.yy0);
}
break;
- case 289: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
+ case 290: /* 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 290: /* cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */
+ case 291: /* cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */
{
- sqlite3AlterDropColumn(pParse, yymsp[-3].minor.yy607, &yymsp[0].minor.yy0);
+ sqlite3AlterDropColumn(pParse, yymsp[-3].minor.yy131, &yymsp[0].minor.yy0);
}
break;
- case 291: /* add_column_fullname ::= fullname */
+ case 292: /* add_column_fullname ::= fullname */
{
disableLookaside(pParse);
- sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy607);
+ sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy131);
}
break;
- case 292: /* cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
+ case 293: /* cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
{
- sqlite3AlterRenameColumn(pParse, yymsp[-5].minor.yy607, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);
+ sqlite3AlterRenameColumn(pParse, yymsp[-5].minor.yy131, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);
}
break;
- case 293: /* cmd ::= create_vtab */
+ case 294: /* cmd ::= create_vtab */
{sqlite3VtabFinishParse(pParse,0);}
break;
- case 294: /* cmd ::= create_vtab LP vtabarglist RP */
+ case 295: /* cmd ::= create_vtab LP vtabarglist RP */
{sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}
break;
- case 295: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
+ case 296: /* 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.yy64);
+ sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy394);
}
break;
- case 296: /* vtabarg ::= */
+ case 297: /* vtabarg ::= */
{sqlite3VtabArgInit(pParse);}
break;
- case 297: /* vtabargtoken ::= ANY */
- case 298: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==298);
- case 299: /* lp ::= LP */ yytestcase(yyruleno==299);
+ case 298: /* vtabargtoken ::= ANY */
+ case 299: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==299);
+ case 300: /* lp ::= LP */ yytestcase(yyruleno==300);
{sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}
break;
- case 300: /* with ::= WITH wqlist */
- case 301: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==301);
-{ sqlite3WithPush(pParse, yymsp[0].minor.yy43, 1); }
+ case 301: /* with ::= WITH wqlist */
+ case 302: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==302);
+{ sqlite3WithPush(pParse, yymsp[0].minor.yy521, 1); }
break;
- case 302: /* wqas ::= AS */
-{yymsp[0].minor.yy534 = M10d_Any;}
+ case 303: /* wqas ::= AS */
+{yymsp[0].minor.yy516 = M10d_Any;}
break;
- case 303: /* wqas ::= AS MATERIALIZED */
-{yymsp[-1].minor.yy534 = M10d_Yes;}
+ case 304: /* wqas ::= AS MATERIALIZED */
+{yymsp[-1].minor.yy516 = M10d_Yes;}
break;
- case 304: /* wqas ::= AS NOT MATERIALIZED */
-{yymsp[-2].minor.yy534 = M10d_No;}
+ case 305: /* wqas ::= AS NOT MATERIALIZED */
+{yymsp[-2].minor.yy516 = M10d_No;}
break;
- case 305: /* wqitem ::= nm eidlist_opt wqas LP select RP */
+ case 306: /* wqitem ::= nm eidlist_opt wqas LP select RP */
{
- yymsp[-5].minor.yy255 = sqlite3CteNew(pParse, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy562, yymsp[-1].minor.yy303, yymsp[-3].minor.yy534); /*A-overwrites-X*/
+ yymsp[-5].minor.yy385 = sqlite3CteNew(pParse, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy322, yymsp[-1].minor.yy47, yymsp[-3].minor.yy516); /*A-overwrites-X*/
}
break;
- case 306: /* wqlist ::= wqitem */
+ case 307: /* wqlist ::= wqitem */
{
- yymsp[0].minor.yy43 = sqlite3WithAdd(pParse, 0, yymsp[0].minor.yy255); /*A-overwrites-X*/
+ yymsp[0].minor.yy521 = sqlite3WithAdd(pParse, 0, yymsp[0].minor.yy385); /*A-overwrites-X*/
}
break;
- case 307: /* wqlist ::= wqlist COMMA wqitem */
+ case 308: /* wqlist ::= wqlist COMMA wqitem */
{
- yymsp[-2].minor.yy43 = sqlite3WithAdd(pParse, yymsp[-2].minor.yy43, yymsp[0].minor.yy255);
+ yymsp[-2].minor.yy521 = sqlite3WithAdd(pParse, yymsp[-2].minor.yy521, yymsp[0].minor.yy385);
}
break;
- case 308: /* windowdefn_list ::= windowdefn */
-{ yylhsminor.yy375 = yymsp[0].minor.yy375; }
- yymsp[0].minor.yy375 = yylhsminor.yy375;
+ case 309: /* windowdefn_list ::= windowdefn */
+{ yylhsminor.yy41 = yymsp[0].minor.yy41; }
+ yymsp[0].minor.yy41 = yylhsminor.yy41;
break;
- case 309: /* windowdefn_list ::= windowdefn_list COMMA windowdefn */
+ case 310: /* windowdefn_list ::= windowdefn_list COMMA windowdefn */
{
- assert( yymsp[0].minor.yy375!=0 );
- sqlite3WindowChain(pParse, yymsp[0].minor.yy375, yymsp[-2].minor.yy375);
- yymsp[0].minor.yy375->pNextWin = yymsp[-2].minor.yy375;
- yylhsminor.yy375 = yymsp[0].minor.yy375;
+ assert( yymsp[0].minor.yy41!=0 );
+ sqlite3WindowChain(pParse, yymsp[0].minor.yy41, yymsp[-2].minor.yy41);
+ yymsp[0].minor.yy41->pNextWin = yymsp[-2].minor.yy41;
+ yylhsminor.yy41 = yymsp[0].minor.yy41;
}
- yymsp[-2].minor.yy375 = yylhsminor.yy375;
+ yymsp[-2].minor.yy41 = yylhsminor.yy41;
break;
- case 310: /* windowdefn ::= nm AS LP window RP */
+ case 311: /* windowdefn ::= nm AS LP window RP */
{
- if( ALWAYS(yymsp[-1].minor.yy375) ){
- yymsp[-1].minor.yy375->zName = sqlite3DbStrNDup(pParse->db, yymsp[-4].minor.yy0.z, yymsp[-4].minor.yy0.n);
+ if( ALWAYS(yymsp[-1].minor.yy41) ){
+ yymsp[-1].minor.yy41->zName = sqlite3DbStrNDup(pParse->db, yymsp[-4].minor.yy0.z, yymsp[-4].minor.yy0.n);
}
- yylhsminor.yy375 = yymsp[-1].minor.yy375;
+ yylhsminor.yy41 = yymsp[-1].minor.yy41;
}
- yymsp[-4].minor.yy375 = yylhsminor.yy375;
+ yymsp[-4].minor.yy41 = yylhsminor.yy41;
break;
- case 311: /* window ::= PARTITION BY nexprlist orderby_opt frame_opt */
+ case 312: /* window ::= PARTITION BY nexprlist orderby_opt frame_opt */
{
- yymsp[-4].minor.yy375 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy375, yymsp[-2].minor.yy562, yymsp[-1].minor.yy562, 0);
+ yymsp[-4].minor.yy41 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy41, yymsp[-2].minor.yy322, yymsp[-1].minor.yy322, 0);
}
break;
- case 312: /* window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
+ case 313: /* window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
{
- yylhsminor.yy375 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy375, yymsp[-2].minor.yy562, yymsp[-1].minor.yy562, &yymsp[-5].minor.yy0);
+ yylhsminor.yy41 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy41, yymsp[-2].minor.yy322, yymsp[-1].minor.yy322, &yymsp[-5].minor.yy0);
}
- yymsp[-5].minor.yy375 = yylhsminor.yy375;
+ yymsp[-5].minor.yy41 = yylhsminor.yy41;
break;
- case 313: /* window ::= ORDER BY sortlist frame_opt */
+ case 314: /* window ::= ORDER BY sortlist frame_opt */
{
- yymsp[-3].minor.yy375 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy375, 0, yymsp[-1].minor.yy562, 0);
+ yymsp[-3].minor.yy41 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy41, 0, yymsp[-1].minor.yy322, 0);
}
break;
- case 314: /* window ::= nm ORDER BY sortlist frame_opt */
+ case 315: /* window ::= nm ORDER BY sortlist frame_opt */
{
- yylhsminor.yy375 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy375, 0, yymsp[-1].minor.yy562, &yymsp[-4].minor.yy0);
+ yylhsminor.yy41 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy41, 0, yymsp[-1].minor.yy322, &yymsp[-4].minor.yy0);
}
- yymsp[-4].minor.yy375 = yylhsminor.yy375;
+ yymsp[-4].minor.yy41 = yylhsminor.yy41;
break;
- case 315: /* window ::= frame_opt */
- case 334: /* filter_over ::= over_clause */ yytestcase(yyruleno==334);
+ case 316: /* window ::= frame_opt */
+ case 335: /* filter_over ::= over_clause */ yytestcase(yyruleno==335);
{
- yylhsminor.yy375 = yymsp[0].minor.yy375;
+ yylhsminor.yy41 = yymsp[0].minor.yy41;
}
- yymsp[0].minor.yy375 = yylhsminor.yy375;
+ yymsp[0].minor.yy41 = yylhsminor.yy41;
break;
- case 316: /* window ::= nm frame_opt */
+ case 317: /* window ::= nm frame_opt */
{
- yylhsminor.yy375 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy375, 0, 0, &yymsp[-1].minor.yy0);
+ yylhsminor.yy41 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy41, 0, 0, &yymsp[-1].minor.yy0);
}
- yymsp[-1].minor.yy375 = yylhsminor.yy375;
+ yymsp[-1].minor.yy41 = yylhsminor.yy41;
break;
- case 317: /* frame_opt ::= */
+ case 318: /* frame_opt ::= */
{
- yymsp[1].minor.yy375 = sqlite3WindowAlloc(pParse, 0, TK_UNBOUNDED, 0, TK_CURRENT, 0, 0);
+ yymsp[1].minor.yy41 = sqlite3WindowAlloc(pParse, 0, TK_UNBOUNDED, 0, TK_CURRENT, 0, 0);
}
break;
- case 318: /* frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */
+ case 319: /* frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */
{
- yylhsminor.yy375 = sqlite3WindowAlloc(pParse, yymsp[-2].minor.yy64, yymsp[-1].minor.yy81.eType, yymsp[-1].minor.yy81.pExpr, TK_CURRENT, 0, yymsp[0].minor.yy534);
+ yylhsminor.yy41 = sqlite3WindowAlloc(pParse, yymsp[-2].minor.yy394, yymsp[-1].minor.yy595.eType, yymsp[-1].minor.yy595.pExpr, TK_CURRENT, 0, yymsp[0].minor.yy516);
}
- yymsp[-2].minor.yy375 = yylhsminor.yy375;
+ yymsp[-2].minor.yy41 = yylhsminor.yy41;
break;
- case 319: /* frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */
+ case 320: /* frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */
{
- yylhsminor.yy375 = sqlite3WindowAlloc(pParse, yymsp[-5].minor.yy64, yymsp[-3].minor.yy81.eType, yymsp[-3].minor.yy81.pExpr, yymsp[-1].minor.yy81.eType, yymsp[-1].minor.yy81.pExpr, yymsp[0].minor.yy534);
+ yylhsminor.yy41 = sqlite3WindowAlloc(pParse, yymsp[-5].minor.yy394, yymsp[-3].minor.yy595.eType, yymsp[-3].minor.yy595.pExpr, yymsp[-1].minor.yy595.eType, yymsp[-1].minor.yy595.pExpr, yymsp[0].minor.yy516);
}
- yymsp[-5].minor.yy375 = yylhsminor.yy375;
+ yymsp[-5].minor.yy41 = yylhsminor.yy41;
break;
- case 321: /* frame_bound_s ::= frame_bound */
- case 323: /* frame_bound_e ::= frame_bound */ yytestcase(yyruleno==323);
-{yylhsminor.yy81 = yymsp[0].minor.yy81;}
- yymsp[0].minor.yy81 = yylhsminor.yy81;
+ case 322: /* frame_bound_s ::= frame_bound */
+ case 324: /* frame_bound_e ::= frame_bound */ yytestcase(yyruleno==324);
+{yylhsminor.yy595 = yymsp[0].minor.yy595;}
+ yymsp[0].minor.yy595 = yylhsminor.yy595;
break;
- case 322: /* frame_bound_s ::= UNBOUNDED PRECEDING */
- case 324: /* frame_bound_e ::= UNBOUNDED FOLLOWING */ yytestcase(yyruleno==324);
- case 326: /* frame_bound ::= CURRENT ROW */ yytestcase(yyruleno==326);
-{yylhsminor.yy81.eType = yymsp[-1].major; yylhsminor.yy81.pExpr = 0;}
- yymsp[-1].minor.yy81 = yylhsminor.yy81;
+ case 323: /* frame_bound_s ::= UNBOUNDED PRECEDING */
+ case 325: /* frame_bound_e ::= UNBOUNDED FOLLOWING */ yytestcase(yyruleno==325);
+ case 327: /* frame_bound ::= CURRENT ROW */ yytestcase(yyruleno==327);
+{yylhsminor.yy595.eType = yymsp[-1].major; yylhsminor.yy595.pExpr = 0;}
+ yymsp[-1].minor.yy595 = yylhsminor.yy595;
break;
- case 325: /* frame_bound ::= expr PRECEDING|FOLLOWING */
-{yylhsminor.yy81.eType = yymsp[0].major; yylhsminor.yy81.pExpr = yymsp[-1].minor.yy626;}
- yymsp[-1].minor.yy81 = yylhsminor.yy81;
+ case 326: /* frame_bound ::= expr PRECEDING|FOLLOWING */
+{yylhsminor.yy595.eType = yymsp[0].major; yylhsminor.yy595.pExpr = yymsp[-1].minor.yy528;}
+ yymsp[-1].minor.yy595 = yylhsminor.yy595;
break;
- case 327: /* frame_exclude_opt ::= */
-{yymsp[1].minor.yy534 = 0;}
+ case 328: /* frame_exclude_opt ::= */
+{yymsp[1].minor.yy516 = 0;}
break;
- case 328: /* frame_exclude_opt ::= EXCLUDE frame_exclude */
-{yymsp[-1].minor.yy534 = yymsp[0].minor.yy534;}
+ case 329: /* frame_exclude_opt ::= EXCLUDE frame_exclude */
+{yymsp[-1].minor.yy516 = yymsp[0].minor.yy516;}
break;
- case 329: /* frame_exclude ::= NO OTHERS */
- case 330: /* frame_exclude ::= CURRENT ROW */ yytestcase(yyruleno==330);
-{yymsp[-1].minor.yy534 = yymsp[-1].major; /*A-overwrites-X*/}
+ case 330: /* frame_exclude ::= NO OTHERS */
+ case 331: /* frame_exclude ::= CURRENT ROW */ yytestcase(yyruleno==331);
+{yymsp[-1].minor.yy516 = yymsp[-1].major; /*A-overwrites-X*/}
break;
- case 331: /* frame_exclude ::= GROUP|TIES */
-{yymsp[0].minor.yy534 = yymsp[0].major; /*A-overwrites-X*/}
+ case 332: /* frame_exclude ::= GROUP|TIES */
+{yymsp[0].minor.yy516 = yymsp[0].major; /*A-overwrites-X*/}
break;
- case 332: /* window_clause ::= WINDOW windowdefn_list */
-{ yymsp[-1].minor.yy375 = yymsp[0].minor.yy375; }
+ case 333: /* window_clause ::= WINDOW windowdefn_list */
+{ yymsp[-1].minor.yy41 = yymsp[0].minor.yy41; }
break;
- case 333: /* filter_over ::= filter_clause over_clause */
+ case 334: /* filter_over ::= filter_clause over_clause */
{
- if( yymsp[0].minor.yy375 ){
- yymsp[0].minor.yy375->pFilter = yymsp[-1].minor.yy626;
+ if( yymsp[0].minor.yy41 ){
+ yymsp[0].minor.yy41->pFilter = yymsp[-1].minor.yy528;
}else{
- sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy626);
+ sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy528);
}
- yylhsminor.yy375 = yymsp[0].minor.yy375;
+ yylhsminor.yy41 = yymsp[0].minor.yy41;
}
- yymsp[-1].minor.yy375 = yylhsminor.yy375;
+ yymsp[-1].minor.yy41 = yylhsminor.yy41;
break;
- case 335: /* filter_over ::= filter_clause */
+ case 336: /* filter_over ::= filter_clause */
{
- yylhsminor.yy375 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
- if( yylhsminor.yy375 ){
- yylhsminor.yy375->eFrmType = TK_FILTER;
- yylhsminor.yy375->pFilter = yymsp[0].minor.yy626;
+ yylhsminor.yy41 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
+ if( yylhsminor.yy41 ){
+ yylhsminor.yy41->eFrmType = TK_FILTER;
+ yylhsminor.yy41->pFilter = yymsp[0].minor.yy528;
}else{
- sqlite3ExprDelete(pParse->db, yymsp[0].minor.yy626);
+ sqlite3ExprDelete(pParse->db, yymsp[0].minor.yy528);
}
}
- yymsp[0].minor.yy375 = yylhsminor.yy375;
+ yymsp[0].minor.yy41 = yylhsminor.yy41;
break;
- case 336: /* over_clause ::= OVER LP window RP */
+ case 337: /* over_clause ::= OVER LP window RP */
{
- yymsp[-3].minor.yy375 = yymsp[-1].minor.yy375;
- assert( yymsp[-3].minor.yy375!=0 );
+ yymsp[-3].minor.yy41 = yymsp[-1].minor.yy41;
+ assert( yymsp[-3].minor.yy41!=0 );
}
break;
- case 337: /* over_clause ::= OVER nm */
+ case 338: /* over_clause ::= OVER nm */
{
- yymsp[-1].minor.yy375 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
- if( yymsp[-1].minor.yy375 ){
- yymsp[-1].minor.yy375->zName = sqlite3DbStrNDup(pParse->db, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n);
+ yymsp[-1].minor.yy41 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
+ if( yymsp[-1].minor.yy41 ){
+ yymsp[-1].minor.yy41->zName = sqlite3DbStrNDup(pParse->db, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n);
}
}
break;
- case 338: /* filter_clause ::= FILTER LP WHERE expr RP */
-{ yymsp[-4].minor.yy626 = yymsp[-1].minor.yy626; }
+ case 339: /* filter_clause ::= FILTER LP WHERE expr RP */
+{ yymsp[-4].minor.yy528 = yymsp[-1].minor.yy528; }
break;
default:
- /* (339) input ::= cmdlist */ yytestcase(yyruleno==339);
- /* (340) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==340);
- /* (341) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=341);
- /* (342) ecmd ::= SEMI */ yytestcase(yyruleno==342);
- /* (343) ecmd ::= cmdx SEMI */ yytestcase(yyruleno==343);
- /* (344) ecmd ::= explain cmdx SEMI (NEVER REDUCES) */ assert(yyruleno!=344);
- /* (345) trans_opt ::= */ yytestcase(yyruleno==345);
- /* (346) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==346);
- /* (347) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==347);
- /* (348) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==348);
- /* (349) savepoint_opt ::= */ yytestcase(yyruleno==349);
- /* (350) cmd ::= create_table create_table_args */ yytestcase(yyruleno==350);
- /* (351) table_option_set ::= table_option (OPTIMIZED OUT) */ assert(yyruleno!=351);
- /* (352) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==352);
- /* (353) columnlist ::= columnname carglist */ yytestcase(yyruleno==353);
- /* (354) nm ::= ID|INDEXED */ yytestcase(yyruleno==354);
- /* (355) nm ::= STRING */ yytestcase(yyruleno==355);
- /* (356) nm ::= JOIN_KW */ yytestcase(yyruleno==356);
- /* (357) typetoken ::= typename */ yytestcase(yyruleno==357);
- /* (358) typename ::= ID|STRING */ yytestcase(yyruleno==358);
- /* (359) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=359);
- /* (360) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=360);
- /* (361) carglist ::= carglist ccons */ yytestcase(yyruleno==361);
- /* (362) carglist ::= */ yytestcase(yyruleno==362);
- /* (363) ccons ::= NULL onconf */ yytestcase(yyruleno==363);
- /* (364) ccons ::= GENERATED ALWAYS AS generated */ yytestcase(yyruleno==364);
- /* (365) ccons ::= AS generated */ yytestcase(yyruleno==365);
- /* (366) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==366);
- /* (367) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==367);
- /* (368) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=368);
- /* (369) tconscomma ::= */ yytestcase(yyruleno==369);
- /* (370) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=370);
- /* (371) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=371);
- /* (372) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=372);
- /* (373) oneselect ::= values */ yytestcase(yyruleno==373);
- /* (374) sclp ::= selcollist COMMA */ yytestcase(yyruleno==374);
- /* (375) as ::= ID|STRING */ yytestcase(yyruleno==375);
- /* (376) returning ::= */ yytestcase(yyruleno==376);
- /* (377) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=377);
- /* (378) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==378);
- /* (379) exprlist ::= nexprlist */ yytestcase(yyruleno==379);
- /* (380) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=380);
- /* (381) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=381);
- /* (382) nmnum ::= ON */ yytestcase(yyruleno==382);
- /* (383) nmnum ::= DELETE */ yytestcase(yyruleno==383);
- /* (384) nmnum ::= DEFAULT */ yytestcase(yyruleno==384);
- /* (385) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==385);
- /* (386) foreach_clause ::= */ yytestcase(yyruleno==386);
- /* (387) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==387);
- /* (388) trnm ::= nm */ yytestcase(yyruleno==388);
- /* (389) tridxby ::= */ yytestcase(yyruleno==389);
- /* (390) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==390);
- /* (391) database_kw_opt ::= */ yytestcase(yyruleno==391);
- /* (392) kwcolumn_opt ::= */ yytestcase(yyruleno==392);
- /* (393) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==393);
- /* (394) vtabarglist ::= vtabarg */ yytestcase(yyruleno==394);
- /* (395) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==395);
- /* (396) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==396);
- /* (397) anylist ::= */ yytestcase(yyruleno==397);
- /* (398) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==398);
- /* (399) anylist ::= anylist ANY */ yytestcase(yyruleno==399);
- /* (400) with ::= */ yytestcase(yyruleno==400);
+ /* (340) input ::= cmdlist */ yytestcase(yyruleno==340);
+ /* (341) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==341);
+ /* (342) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=342);
+ /* (343) ecmd ::= SEMI */ yytestcase(yyruleno==343);
+ /* (344) ecmd ::= cmdx SEMI */ yytestcase(yyruleno==344);
+ /* (345) ecmd ::= explain cmdx SEMI (NEVER REDUCES) */ assert(yyruleno!=345);
+ /* (346) trans_opt ::= */ yytestcase(yyruleno==346);
+ /* (347) trans_opt ::= TRANSACTION */ yytestcase(yyruleno==347);
+ /* (348) trans_opt ::= TRANSACTION nm */ yytestcase(yyruleno==348);
+ /* (349) savepoint_opt ::= SAVEPOINT */ yytestcase(yyruleno==349);
+ /* (350) savepoint_opt ::= */ yytestcase(yyruleno==350);
+ /* (351) cmd ::= create_table create_table_args */ yytestcase(yyruleno==351);
+ /* (352) table_option_set ::= table_option (OPTIMIZED OUT) */ assert(yyruleno!=352);
+ /* (353) columnlist ::= columnlist COMMA columnname carglist */ yytestcase(yyruleno==353);
+ /* (354) columnlist ::= columnname carglist */ yytestcase(yyruleno==354);
+ /* (355) nm ::= ID|INDEXED */ yytestcase(yyruleno==355);
+ /* (356) nm ::= STRING */ yytestcase(yyruleno==356);
+ /* (357) nm ::= JOIN_KW */ yytestcase(yyruleno==357);
+ /* (358) typetoken ::= typename */ yytestcase(yyruleno==358);
+ /* (359) typename ::= ID|STRING */ yytestcase(yyruleno==359);
+ /* (360) signed ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=360);
+ /* (361) signed ::= minus_num (OPTIMIZED OUT) */ assert(yyruleno!=361);
+ /* (362) carglist ::= carglist ccons */ yytestcase(yyruleno==362);
+ /* (363) carglist ::= */ yytestcase(yyruleno==363);
+ /* (364) ccons ::= NULL onconf */ yytestcase(yyruleno==364);
+ /* (365) ccons ::= GENERATED ALWAYS AS generated */ yytestcase(yyruleno==365);
+ /* (366) ccons ::= AS generated */ yytestcase(yyruleno==366);
+ /* (367) conslist_opt ::= COMMA conslist */ yytestcase(yyruleno==367);
+ /* (368) conslist ::= conslist tconscomma tcons */ yytestcase(yyruleno==368);
+ /* (369) conslist ::= tcons (OPTIMIZED OUT) */ assert(yyruleno!=369);
+ /* (370) tconscomma ::= */ yytestcase(yyruleno==370);
+ /* (371) defer_subclause_opt ::= defer_subclause (OPTIMIZED OUT) */ assert(yyruleno!=371);
+ /* (372) resolvetype ::= raisetype (OPTIMIZED OUT) */ assert(yyruleno!=372);
+ /* (373) selectnowith ::= oneselect (OPTIMIZED OUT) */ assert(yyruleno!=373);
+ /* (374) oneselect ::= values */ yytestcase(yyruleno==374);
+ /* (375) sclp ::= selcollist COMMA */ yytestcase(yyruleno==375);
+ /* (376) as ::= ID|STRING */ yytestcase(yyruleno==376);
+ /* (377) returning ::= */ yytestcase(yyruleno==377);
+ /* (378) expr ::= term (OPTIMIZED OUT) */ assert(yyruleno!=378);
+ /* (379) likeop ::= LIKE_KW|MATCH */ yytestcase(yyruleno==379);
+ /* (380) exprlist ::= nexprlist */ yytestcase(yyruleno==380);
+ /* (381) nmnum ::= plus_num (OPTIMIZED OUT) */ assert(yyruleno!=381);
+ /* (382) nmnum ::= nm (OPTIMIZED OUT) */ assert(yyruleno!=382);
+ /* (383) nmnum ::= ON */ yytestcase(yyruleno==383);
+ /* (384) nmnum ::= DELETE */ yytestcase(yyruleno==384);
+ /* (385) nmnum ::= DEFAULT */ yytestcase(yyruleno==385);
+ /* (386) plus_num ::= INTEGER|FLOAT */ yytestcase(yyruleno==386);
+ /* (387) foreach_clause ::= */ yytestcase(yyruleno==387);
+ /* (388) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==388);
+ /* (389) trnm ::= nm */ yytestcase(yyruleno==389);
+ /* (390) tridxby ::= */ yytestcase(yyruleno==390);
+ /* (391) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==391);
+ /* (392) database_kw_opt ::= */ yytestcase(yyruleno==392);
+ /* (393) kwcolumn_opt ::= */ yytestcase(yyruleno==393);
+ /* (394) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==394);
+ /* (395) vtabarglist ::= vtabarg */ yytestcase(yyruleno==395);
+ /* (396) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==396);
+ /* (397) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==397);
+ /* (398) anylist ::= */ yytestcase(yyruleno==398);
+ /* (399) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==399);
+ /* (400) anylist ::= anylist ANY */ yytestcase(yyruleno==400);
+ /* (401) with ::= */ yytestcase(yyruleno==401);
break;
/********** End reduce actions ************************************************/
};
@@ -165592,6 +167464,9 @@ SQLITE_PRIVATE int sqlite3GetToken(const unsigned char *z, int *tokenType){
for(i=2; (c=z[i])!=0 && c!='\n'; i++){}
*tokenType = TK_SPACE; /* IMP: R-22934-25134 */
return i;
+ }else if( z[1]=='>' ){
+ *tokenType = TK_PTR;
+ return 2 + (z[2]=='>');
}
*tokenType = TK_MINUS;
return 1;
@@ -165861,13 +167736,9 @@ SQLITE_PRIVATE int sqlite3GetToken(const unsigned char *z, int *tokenType){
}
/*
-** Run the parser on the given SQL string. The parser structure is
-** passed in. An SQLITE_ status code is returned. If an error occurs
-** then an and attempt is made to write an error message into
-** memory obtained from sqlite3_malloc() and to make *pzErrMsg point to that
-** error message.
+** Run the parser on the given SQL string.
*/
-SQLITE_PRIVATE int sqlite3RunParser(Parse *pParse, const char *zSql, char **pzErrMsg){
+SQLITE_PRIVATE int sqlite3RunParser(Parse *pParse, const char *zSql){
int nErr = 0; /* Number of errors encountered */
void *pEngine; /* The LEMON-generated LALR(1) parser */
int n = 0; /* Length of the next token token */
@@ -165888,7 +167759,6 @@ SQLITE_PRIVATE int sqlite3RunParser(Parse *pParse, const char *zSql, char **pzEr
}
pParse->rc = SQLITE_OK;
pParse->zTail = zSql;
- assert( pzErrMsg!=0 );
#ifdef SQLITE_DEBUG
if( db->flags & SQLITE_ParserTrace ){
printf("parser: [[[%s]]]\n", zSql);
@@ -165931,6 +167801,7 @@ SQLITE_PRIVATE int sqlite3RunParser(Parse *pParse, const char *zSql, char **pzEr
#endif /* SQLITE_OMIT_WINDOWFUNC */
if( AtomicLoad(&db->u1.isInterrupted) ){
pParse->rc = SQLITE_INTERRUPT;
+ pParse->nErr++;
break;
}
if( tokenType==TK_SPACE ){
@@ -165960,7 +167831,10 @@ SQLITE_PRIVATE int sqlite3RunParser(Parse *pParse, const char *zSql, char **pzEr
tokenType = analyzeFilterKeyword((const u8*)&zSql[6], lastTokenParsed);
#endif /* SQLITE_OMIT_WINDOWFUNC */
}else{
- sqlite3ErrorMsg(pParse, "unrecognized token: \"%.*s\"", n, zSql);
+ Token x;
+ x.z = zSql;
+ x.n = n;
+ sqlite3ErrorMsg(pParse, "unrecognized token: \"%T\"", &x);
break;
}
}
@@ -165988,41 +167862,26 @@ SQLITE_PRIVATE int sqlite3RunParser(Parse *pParse, const char *zSql, char **pzEr
if( db->mallocFailed ){
pParse->rc = SQLITE_NOMEM_BKPT;
}
- if( pParse->rc!=SQLITE_OK && pParse->rc!=SQLITE_DONE && pParse->zErrMsg==0 ){
- pParse->zErrMsg = sqlite3MPrintf(db, "%s", sqlite3ErrStr(pParse->rc));
- }
- assert( pzErrMsg!=0 );
- if( pParse->zErrMsg ){
- *pzErrMsg = pParse->zErrMsg;
- sqlite3_log(pParse->rc, "%s in \"%s\"",
- *pzErrMsg, pParse->zTail);
- pParse->zErrMsg = 0;
+ if( pParse->zErrMsg || (pParse->rc!=SQLITE_OK && pParse->rc!=SQLITE_DONE) ){
+ if( pParse->zErrMsg==0 ){
+ pParse->zErrMsg = sqlite3MPrintf(db, "%s", sqlite3ErrStr(pParse->rc));
+ }
+ sqlite3_log(pParse->rc, "%s in \"%s\"", pParse->zErrMsg, pParse->zTail);
nErr++;
}
pParse->zTail = zSql;
- if( pParse->pVdbe && pParse->nErr>0 && pParse->nested==0 ){
- sqlite3VdbeDelete(pParse->pVdbe);
- pParse->pVdbe = 0;
- }
-#ifndef SQLITE_OMIT_SHARED_CACHE
- if( pParse->nested==0 ){
- sqlite3DbFree(db, pParse->aTableLock);
- pParse->aTableLock = 0;
- pParse->nTableLock = 0;
- }
-#endif
#ifndef SQLITE_OMIT_VIRTUALTABLE
sqlite3_free(pParse->apVtabLock);
#endif
- if( !IN_SPECIAL_PARSE ){
+ if( pParse->pNewTable && !IN_SPECIAL_PARSE ){
/* If the pParse->declareVtab flag is set, do not delete any table
** structure built up in pParse->pNewTable. The calling code (see vtab.c)
** will take responsibility for freeing the Table structure.
*/
sqlite3DeleteTable(db, pParse->pNewTable);
}
- if( !IN_RENAME_OBJECT ){
+ if( pParse->pNewTrigger && !IN_RENAME_OBJECT ){
sqlite3DeleteTrigger(db, pParse->pNewTrigger);
}
sqlite3DbFree(db, pParse->pVList);
@@ -166607,9 +168466,6 @@ SQLITE_PRIVATE int sqlite3Fts2Init(sqlite3*);
#ifdef SQLITE_ENABLE_FTS5
SQLITE_PRIVATE int sqlite3Fts5Init(sqlite3*);
#endif
-#ifdef SQLITE_ENABLE_JSON1
-SQLITE_PRIVATE int sqlite3Json1Init(sqlite3*);
-#endif
#ifdef SQLITE_ENABLE_STMTVTAB
SQLITE_PRIVATE int sqlite3StmtVtabInit(sqlite3*);
#endif
@@ -166644,8 +168500,8 @@ static int (*const sqlite3BuiltinExtensions[])(sqlite3*) = {
sqlite3DbstatRegister,
#endif
sqlite3TestExtInit,
-#ifdef SQLITE_ENABLE_JSON1
- sqlite3Json1Init,
+#if !defined(SQLITE_OMIT_VIRTUALTABLE) && !defined(SQLITE_OMIT_JSON)
+ sqlite3JsonTableFunctions,
#endif
#ifdef SQLITE_ENABLE_STMTVTAB
sqlite3StmtVtabInit,
@@ -169154,6 +171010,19 @@ SQLITE_API const char *sqlite3_errmsg(sqlite3 *db){
return z;
}
+/*
+** Return the byte offset of the most recent error
+*/
+SQLITE_API int sqlite3_error_offset(sqlite3 *db){
+ int iOffset = -1;
+ if( db && sqlite3SafetyCheckSickOrOk(db) && db->errCode ){
+ sqlite3_mutex_enter(db->mutex);
+ iOffset = db->errByteOffset;
+ sqlite3_mutex_leave(db->mutex);
+ }
+ return iOffset;
+}
+
#ifndef SQLITE_OMIT_UTF16
/*
** Return UTF-16 encoded English language explanation of the most recent
@@ -170576,12 +172445,16 @@ SQLITE_API int sqlite3_test_control(int op, ...){
** sqlite3_test_control().
*/
case SQLITE_TESTCTRL_FAULT_INSTALL: {
- /* MSVC is picky about pulling func ptrs from va lists.
- ** http://support.microsoft.com/kb/47961
+ /* A bug in MSVC prevents it from understanding pointers to functions
+ ** types in the second argument to va_arg(). Work around the problem
+ ** using a typedef.
+ ** http://support.microsoft.com/kb/47961 <-- dead hyperlink
+ ** Search at http://web.archive.org/ to find the 2015-03-16 archive
+ ** of the link above to see the original text.
** sqlite3GlobalConfig.xTestCallback = va_arg(ap, int(*)(int));
*/
- typedef int(*TESTCALLBACKFUNC_t)(int);
- sqlite3GlobalConfig.xTestCallback = va_arg(ap, TESTCALLBACKFUNC_t);
+ typedef int(*sqlite3FaultFuncType)(int);
+ sqlite3GlobalConfig.xTestCallback = va_arg(ap, sqlite3FaultFuncType);
rc = sqlite3FaultSim(0);
break;
}
@@ -170708,13 +172581,27 @@ SQLITE_API int sqlite3_test_control(int op, ...){
break;
}
- /* sqlite3_test_control(SQLITE_TESTCTRL_LOCALTIME_FAULT, int onoff);
+ /* sqlite3_test_control(SQLITE_TESTCTRL_LOCALTIME_FAULT, onoff, xAlt);
+ **
+ ** If parameter onoff is 1, subsequent calls to localtime() fail.
+ ** If 2, then invoke xAlt() instead of localtime(). If 0, normal
+ ** processing.
+ **
+ ** xAlt arguments are void pointers, but they really want to be:
**
- ** If parameter onoff is non-zero, subsequent calls to localtime()
- ** and its variants fail. If onoff is zero, undo this setting.
+ ** int xAlt(const time_t*, struct tm*);
+ **
+ ** xAlt should write results in to struct tm object of its 2nd argument
+ ** and return zero on success, or return non-zero on failure.
*/
case SQLITE_TESTCTRL_LOCALTIME_FAULT: {
sqlite3GlobalConfig.bLocaltimeFault = va_arg(ap, int);
+ if( sqlite3GlobalConfig.bLocaltimeFault==2 ){
+ typedef int(*sqlite3LocaltimeType)(const void*,void*);
+ sqlite3GlobalConfig.xAltLocaltime = va_arg(ap, sqlite3LocaltimeType);
+ }else{
+ sqlite3GlobalConfig.xAltLocaltime = 0;
+ }
break;
}
@@ -170904,6 +172791,26 @@ SQLITE_API int sqlite3_test_control(int op, ...){
break;
}
+ /* sqlite3_test_control(SQLITE_TESTCTRL_LOGEST,
+ ** double fIn, // Input value
+ ** int *pLogEst, // sqlite3LogEstFromDouble(fIn)
+ ** u64 *pInt, // sqlite3LogEstToInt(*pLogEst)
+ ** int *pLogEst2 // sqlite3LogEst(*pInt)
+ ** );
+ **
+ ** Test access for the LogEst conversion routines.
+ */
+ case SQLITE_TESTCTRL_LOGEST: {
+ double rIn = va_arg(ap, double);
+ LogEst rLogEst = sqlite3LogEstFromDouble(rIn);
+ u64 iInt = sqlite3LogEstToInt(rLogEst);
+ va_arg(ap, int*)[0] = rLogEst;
+ va_arg(ap, u64*)[0] = iInt;
+ va_arg(ap, int*)[0] = sqlite3LogEst(iInt);
+ break;
+ }
+
+
#if defined(SQLITE_DEBUG) && !defined(SQLITE_OMIT_WSD)
/* sqlite3_test_control(SQLITE_TESTCTRL_TUNE, id, *piValue)
**
@@ -172884,7 +174791,7 @@ SQLITE_PRIVATE int sqlite3Fts3MsrOvfl(Fts3Cursor *, Fts3MultiSegReader *, int *)
SQLITE_PRIVATE int sqlite3Fts3MsrIncrRestart(Fts3MultiSegReader *pCsr);
/* fts3_tokenize_vtab.c */
-SQLITE_PRIVATE int sqlite3Fts3InitTok(sqlite3*, Fts3Hash *);
+SQLITE_PRIVATE int sqlite3Fts3InitTok(sqlite3*, Fts3Hash *, void(*xDestroy)(void*));
/* fts3_unicode2.c (functions generated by parsing unicode text files) */
#ifndef SQLITE_DISABLE_FTS3_UNICODE
@@ -172917,6 +174824,12 @@ SQLITE_PRIVATE int sqlite3FtsUnicodeIsdiacritic(int);
SQLITE_EXTENSION_INIT1
#endif
+typedef struct Fts3HashWrapper Fts3HashWrapper;
+struct Fts3HashWrapper {
+ Fts3Hash hash; /* Hash table */
+ int nRef; /* Number of pointers to this object */
+};
+
static int fts3EvalNext(Fts3Cursor *pCsr);
static int fts3EvalStart(Fts3Cursor *pCsr);
static int fts3TermSegReaderCursor(
@@ -173781,7 +175694,7 @@ static int fts3InitVtab(
sqlite3_vtab **ppVTab, /* Write the resulting vtab structure here */
char **pzErr /* Write any error message here */
){
- Fts3Hash *pHash = (Fts3Hash *)pAux;
+ Fts3Hash *pHash = &((Fts3HashWrapper*)pAux)->hash;
Fts3Table *p = 0; /* Pointer to allocated vtab */
int rc = SQLITE_OK; /* Return code */
int i; /* Iterator variable */
@@ -176616,9 +178529,12 @@ static const sqlite3_module fts3Module = {
** allocated for the tokenizer hash table.
*/
static void hashDestroy(void *p){
- Fts3Hash *pHash = (Fts3Hash *)p;
- sqlite3Fts3HashClear(pHash);
- sqlite3_free(pHash);
+ Fts3HashWrapper *pHash = (Fts3HashWrapper *)p;
+ pHash->nRef--;
+ if( pHash->nRef<=0 ){
+ sqlite3Fts3HashClear(&pHash->hash);
+ sqlite3_free(pHash);
+ }
}
/*
@@ -176648,7 +178564,7 @@ SQLITE_PRIVATE void sqlite3Fts3IcuTokenizerModule(sqlite3_tokenizer_module const
*/
SQLITE_PRIVATE int sqlite3Fts3Init(sqlite3 *db){
int rc = SQLITE_OK;
- Fts3Hash *pHash = 0;
+ Fts3HashWrapper *pHash = 0;
const sqlite3_tokenizer_module *pSimple = 0;
const sqlite3_tokenizer_module *pPorter = 0;
#ifndef SQLITE_DISABLE_FTS3_UNICODE
@@ -176676,23 +178592,24 @@ SQLITE_PRIVATE int sqlite3Fts3Init(sqlite3 *db){
sqlite3Fts3PorterTokenizerModule(&pPorter);
/* Allocate and initialize the hash-table used to store tokenizers. */
- pHash = sqlite3_malloc(sizeof(Fts3Hash));
+ pHash = sqlite3_malloc(sizeof(Fts3HashWrapper));
if( !pHash ){
rc = SQLITE_NOMEM;
}else{
- sqlite3Fts3HashInit(pHash, FTS3_HASH_STRING, 1);
+ sqlite3Fts3HashInit(&pHash->hash, FTS3_HASH_STRING, 1);
+ pHash->nRef = 0;
}
/* Load the built-in tokenizers into the hash table */
if( rc==SQLITE_OK ){
- if( sqlite3Fts3HashInsert(pHash, "simple", 7, (void *)pSimple)
- || sqlite3Fts3HashInsert(pHash, "porter", 7, (void *)pPorter)
+ if( sqlite3Fts3HashInsert(&pHash->hash, "simple", 7, (void *)pSimple)
+ || sqlite3Fts3HashInsert(&pHash->hash, "porter", 7, (void *)pPorter)
#ifndef SQLITE_DISABLE_FTS3_UNICODE
- || sqlite3Fts3HashInsert(pHash, "unicode61", 10, (void *)pUnicode)
+ || sqlite3Fts3HashInsert(&pHash->hash, "unicode61", 10, (void *)pUnicode)
#endif
#ifdef SQLITE_ENABLE_ICU
- || (pIcu && sqlite3Fts3HashInsert(pHash, "icu", 4, (void *)pIcu))
+ || (pIcu && sqlite3Fts3HashInsert(&pHash->hash, "icu", 4, (void *)pIcu))
#endif
){
rc = SQLITE_NOMEM;
@@ -176701,7 +178618,7 @@ SQLITE_PRIVATE int sqlite3Fts3Init(sqlite3 *db){
#ifdef SQLITE_TEST
if( rc==SQLITE_OK ){
- rc = sqlite3Fts3ExprInitTestInterface(db, pHash);
+ rc = sqlite3Fts3ExprInitTestInterface(db, &pHash->hash);
}
#endif
@@ -176710,23 +178627,26 @@ SQLITE_PRIVATE int sqlite3Fts3Init(sqlite3 *db){
** module with sqlite.
*/
if( SQLITE_OK==rc
- && SQLITE_OK==(rc = sqlite3Fts3InitHashTable(db, pHash, "fts3_tokenizer"))
+ && SQLITE_OK==(rc=sqlite3Fts3InitHashTable(db,&pHash->hash,"fts3_tokenizer"))
&& 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))
&& SQLITE_OK==(rc = sqlite3_overload_function(db, "matchinfo", 2))
&& SQLITE_OK==(rc = sqlite3_overload_function(db, "optimize", 1))
){
+ pHash->nRef++;
rc = sqlite3_create_module_v2(
db, "fts3", &fts3Module, (void *)pHash, hashDestroy
);
if( rc==SQLITE_OK ){
+ pHash->nRef++;
rc = sqlite3_create_module_v2(
- db, "fts4", &fts3Module, (void *)pHash, 0
+ db, "fts4", &fts3Module, (void *)pHash, hashDestroy
);
}
if( rc==SQLITE_OK ){
- rc = sqlite3Fts3InitTok(db, (void *)pHash);
+ pHash->nRef++;
+ rc = sqlite3Fts3InitTok(db, (void *)pHash, hashDestroy);
}
return rc;
}
@@ -176735,7 +178655,7 @@ SQLITE_PRIVATE int sqlite3Fts3Init(sqlite3 *db){
/* An error has occurred. Delete the hash table and return the error code. */
assert( rc!=SQLITE_OK );
if( pHash ){
- sqlite3Fts3HashClear(pHash);
+ sqlite3Fts3HashClear(&pHash->hash);
sqlite3_free(pHash);
}
return rc;
@@ -182799,7 +184719,7 @@ static int fts3tokRowidMethod(
** Register the fts3tok module with database connection db. Return SQLITE_OK
** if successful or an error code if sqlite3_create_module() fails.
*/
-SQLITE_PRIVATE int sqlite3Fts3InitTok(sqlite3 *db, Fts3Hash *pHash){
+SQLITE_PRIVATE int sqlite3Fts3InitTok(sqlite3 *db, Fts3Hash *pHash, void(*xDestroy)(void*)){
static const sqlite3_module fts3tok_module = {
0, /* iVersion */
fts3tokConnectMethod, /* xCreate */
@@ -182828,7 +184748,9 @@ SQLITE_PRIVATE int sqlite3Fts3InitTok(sqlite3 *db, Fts3Hash *pHash){
};
int rc; /* Return code */
- rc = sqlite3_create_module(db, "fts3tokenize", &fts3tok_module, (void*)pHash);
+ rc = sqlite3_create_module_v2(
+ db, "fts3tokenize", &fts3tok_module, (void*)pHash, xDestroy
+ );
return rc;
}
@@ -191187,7 +193109,7 @@ SQLITE_PRIVATE int sqlite3FtsUnicodeFold(int c, int eRemoveDiacritic){
#endif /* !defined(SQLITE_DISABLE_FTS3_UNICODE) */
/************** End of fts3_unicode2.c ***************************************/
-/************** Begin file json1.c *******************************************/
+/************** Begin file json.c ********************************************/
/*
** 2015-08-12
**
@@ -191200,10 +193122,10 @@ SQLITE_PRIVATE int sqlite3FtsUnicodeFold(int c, int eRemoveDiacritic){
**
******************************************************************************
**
-** This SQLite extension implements JSON functions. The interface is
-** modeled after MySQL JSON functions:
+** This SQLite JSON functions.
**
-** https://dev.mysql.com/doc/refman/5.7/en/json.html
+** This file began as an extension in ext/misc/json1.c in 2015. That
+** extension proved so useful that it has now been moved into the core.
**
** For the time being, all JSON is stored as pure text. (We might add
** a JSONB type in the future which stores a binary encoding of JSON in
@@ -191211,48 +193133,8 @@ SQLITE_PRIVATE int sqlite3FtsUnicodeFold(int c, int eRemoveDiacritic){
** This implementation parses JSON text at 250 MB/s, so it is hard to see
** how JSONB might improve on that.)
*/
-#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_JSON1)
-#if !defined(SQLITEINT_H)
-/* #include "sqlite3ext.h" */
-#endif
-SQLITE_EXTENSION_INIT1
-/* #include <assert.h> */
-/* #include <string.h> */
-/* #include <stdlib.h> */
-/* #include <stdarg.h> */
-
-/* Mark a function parameter as unused, to suppress nuisance compiler
-** warnings. */
-#ifndef UNUSED_PARAM
-# define UNUSED_PARAM(X) (void)(X)
-#endif
-
-#ifndef LARGEST_INT64
-# define LARGEST_INT64 (0xffffffff|(((sqlite3_int64)0x7fffffff)<<32))
-# define SMALLEST_INT64 (((sqlite3_int64)-1) - LARGEST_INT64)
-#endif
-
-#ifndef deliberate_fall_through
-# define deliberate_fall_through
-#endif
-
-/*
-** Versions of isspace(), isalnum() and isdigit() to which it is safe
-** to pass signed char values.
-*/
-#ifdef sqlite3Isdigit
- /* Use the SQLite core versions if this routine is part of the
- ** SQLite amalgamation */
-# define safe_isdigit(x) sqlite3Isdigit(x)
-# define safe_isalnum(x) sqlite3Isalnum(x)
-# define safe_isxdigit(x) sqlite3Isxdigit(x)
-#else
- /* Use the standard library for separate compilation */
-#include <ctype.h> /* amalgamator: keep */
-# define safe_isdigit(x) isdigit((unsigned char)(x))
-# define safe_isalnum(x) isalnum((unsigned char)(x))
-# define safe_isxdigit(x) isxdigit((unsigned char)(x))
-#endif
+#ifndef SQLITE_OMIT_JSON
+/* #include "sqliteInt.h" */
/*
** Growing our own isspace() routine this way is twice as fast as
@@ -191277,44 +193159,14 @@ static const char jsonIsSpace[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
};
-#define safe_isspace(x) (jsonIsSpace[(unsigned char)x])
+#define fast_isspace(x) (jsonIsSpace[(unsigned char)x])
-#ifndef SQLITE_AMALGAMATION
- /* Unsigned integer types. These are already defined in the sqliteInt.h,
- ** but the definitions need to be repeated for separate compilation. */
- typedef sqlite3_uint64 u64;
- typedef unsigned int u32;
- typedef unsigned short int u16;
- typedef unsigned char u8;
-# if defined(SQLITE_COVERAGE_TEST) || defined(SQLITE_MUTATION_TEST)
-# define SQLITE_OMIT_AUXILIARY_SAFETY_CHECKS 1
-# endif
-# if defined(SQLITE_OMIT_AUXILIARY_SAFETY_CHECKS)
-# define ALWAYS(X) (1)
-# define NEVER(X) (0)
-# elif !defined(NDEBUG)
-# define ALWAYS(X) ((X)?1:(assert(0),0))
-# define NEVER(X) ((X)?(assert(0),1):0)
-# else
-# define ALWAYS(X) (X)
-# define NEVER(X) (X)
-# endif
-# define testcase(X)
-#endif
#if !defined(SQLITE_DEBUG) && !defined(SQLITE_COVERAGE_TEST)
# define VVA(X)
#else
# define VVA(X) X
#endif
-/*
-** Some of the testcase() macros in this file are problematic for gcov
-** in that they generate false-miss errors randomly. This is a gcov problem,
-** not a problem in this case. But to work around it, we disable the
-** problematic test cases for production builds.
-*/
-#define json_testcase(X)
-
/* Objects */
typedef struct JsonString JsonString;
typedef struct JsonNode JsonNode;
@@ -191772,10 +193624,10 @@ static u8 jsonHexToInt(int h){
*/
static u32 jsonHexToInt4(const char *z){
u32 v;
- assert( safe_isxdigit(z[0]) );
- assert( safe_isxdigit(z[1]) );
- assert( safe_isxdigit(z[2]) );
- assert( safe_isxdigit(z[3]) );
+ assert( sqlite3Isxdigit(z[0]) );
+ assert( sqlite3Isxdigit(z[1]) );
+ assert( sqlite3Isxdigit(z[2]) );
+ assert( sqlite3Isxdigit(z[3]) );
v = (jsonHexToInt(z[0])<<12)
+ (jsonHexToInt(z[1])<<8)
+ (jsonHexToInt(z[2])<<4)
@@ -192010,7 +193862,7 @@ static int jsonParseAddNode(
*/
static int jsonIs4Hex(const char *z){
int i;
- for(i=0; i<4; i++) if( !safe_isxdigit(z[i]) ) return 0;
+ for(i=0; i<4; i++) if( !sqlite3Isxdigit(z[i]) ) return 0;
return 1;
}
@@ -192029,13 +193881,13 @@ static int jsonParseValue(JsonParse *pParse, u32 i){
int x;
JsonNode *pNode;
const char *z = pParse->zJson;
- while( safe_isspace(z[i]) ){ i++; }
+ while( fast_isspace(z[i]) ){ i++; }
if( (c = z[i])=='{' ){
/* Parse object */
iThis = jsonParseAddNode(pParse, JSON_OBJECT, 0, 0);
if( iThis<0 ) return -1;
for(j=i+1;;j++){
- while( safe_isspace(z[j]) ){ j++; }
+ while( fast_isspace(z[j]) ){ j++; }
if( ++pParse->iDepth > JSON_MAX_DEPTH ) return -1;
x = jsonParseValue(pParse, j);
if( x<0 ){
@@ -192048,14 +193900,14 @@ static int jsonParseValue(JsonParse *pParse, u32 i){
if( pNode->eType!=JSON_STRING ) return -1;
pNode->jnFlags |= JNODE_LABEL;
j = x;
- while( safe_isspace(z[j]) ){ j++; }
+ while( fast_isspace(z[j]) ){ j++; }
if( z[j]!=':' ) return -1;
j++;
x = jsonParseValue(pParse, j);
pParse->iDepth--;
if( x<0 ) return -1;
j = x;
- while( safe_isspace(z[j]) ){ j++; }
+ while( fast_isspace(z[j]) ){ j++; }
c = z[j];
if( c==',' ) continue;
if( c!='}' ) return -1;
@@ -192069,7 +193921,7 @@ static int jsonParseValue(JsonParse *pParse, u32 i){
if( iThis<0 ) return -1;
memset(&pParse->aNode[iThis].u, 0, sizeof(pParse->aNode[iThis].u));
for(j=i+1;;j++){
- while( safe_isspace(z[j]) ){ j++; }
+ while( fast_isspace(z[j]) ){ j++; }
if( ++pParse->iDepth > JSON_MAX_DEPTH ) return -1;
x = jsonParseValue(pParse, j);
pParse->iDepth--;
@@ -192078,7 +193930,7 @@ static int jsonParseValue(JsonParse *pParse, u32 i){
return -1;
}
j = x;
- while( safe_isspace(z[j]) ){ j++; }
+ while( fast_isspace(z[j]) ){ j++; }
c = z[j];
if( c==',' ) continue;
if( c!=']' ) return -1;
@@ -192115,17 +193967,17 @@ static int jsonParseValue(JsonParse *pParse, u32 i){
return j+1;
}else if( c=='n'
&& strncmp(z+i,"null",4)==0
- && !safe_isalnum(z[i+4]) ){
+ && !sqlite3Isalnum(z[i+4]) ){
jsonParseAddNode(pParse, JSON_NULL, 0, 0);
return i+4;
}else if( c=='t'
&& strncmp(z+i,"true",4)==0
- && !safe_isalnum(z[i+4]) ){
+ && !sqlite3Isalnum(z[i+4]) ){
jsonParseAddNode(pParse, JSON_TRUE, 0, 0);
return i+4;
}else if( c=='f'
&& strncmp(z+i,"false",5)==0
- && !safe_isalnum(z[i+5]) ){
+ && !sqlite3Isalnum(z[i+5]) ){
jsonParseAddNode(pParse, JSON_FALSE, 0, 0);
return i+5;
}else if( c=='-' || (c>='0' && c<='9') ){
@@ -192196,7 +194048,7 @@ static int jsonParse(
if( pParse->oom ) i = -1;
if( i>0 ){
assert( pParse->iDepth==0 );
- while( safe_isspace(zJson[i]) ) i++;
+ while( fast_isspace(zJson[i]) ) i++;
if( zJson[i] ) i = -1;
}
if( i<=0 ){
@@ -192424,7 +194276,7 @@ static JsonNode *jsonLookupStep(
}else if( zPath[0]=='[' ){
i = 0;
j = 1;
- while( safe_isdigit(zPath[j]) ){
+ while( sqlite3Isdigit(zPath[j]) ){
i = i*10 + zPath[j] - '0';
j++;
}
@@ -192445,13 +194297,13 @@ static JsonNode *jsonLookupStep(
j = 1;
}
j = 2;
- if( zPath[2]=='-' && safe_isdigit(zPath[3]) ){
+ if( zPath[2]=='-' && sqlite3Isdigit(zPath[3]) ){
unsigned int x = 0;
j = 3;
do{
x = x*10 + zPath[j] - '0';
j++;
- }while( safe_isdigit(zPath[j]) );
+ }while( sqlite3Isdigit(zPath[j]) );
if( x>i ) return 0;
i -= x;
}
@@ -192670,7 +194522,7 @@ static void jsonTest1Func(
int argc,
sqlite3_value **argv
){
- UNUSED_PARAM(argc);
+ UNUSED_PARAMETER(argc);
sqlite3_result_int(ctx, sqlite3_value_subtype(argv[0])==JSON_SUBTYPE);
}
#endif /* SQLITE_DEBUG */
@@ -192691,7 +194543,7 @@ static void jsonQuoteFunc(
sqlite3_value **argv
){
JsonString jx;
- UNUSED_PARAM(argc);
+ UNUSED_PARAMETER(argc);
jsonInit(&jx, ctx);
jsonAppendValue(&jx, argv[0]);
@@ -192763,12 +194615,33 @@ static void jsonArrayLengthFunc(
}
/*
+** Bit values for the flags passed into jsonExtractFunc() or
+** jsonSetFunc() via the user-data value.
+*/
+#define JSON_JSON 0x01 /* Result is always JSON */
+#define JSON_SQL 0x02 /* Result is always SQL */
+#define JSON_ABPATH 0x03 /* Allow abbreviated JSON path specs */
+#define JSON_ISSET 0x04 /* json_set(), not json_insert() */
+
+/*
** json_extract(JSON, PATH, ...)
+** "->"(JSON,PATH)
+** "->>"(JSON,PATH)
**
-** Return the element described by PATH. Return NULL if there is no
-** PATH element. If there are multiple PATHs, then return a JSON array
-** with the result from each path. Throw an error if the JSON or any PATH
-** is malformed.
+** Return the element described by PATH. Return NULL if that PATH element
+** is not found.
+**
+** If JSON_JSON is set or if more that one PATH argument is supplied then
+** always return a JSON representation of the result. If JSON_SQL is set,
+** then always return an SQL representation of the result. If neither flag
+** is present and argc==2, then return JSON for objects and arrays and SQL
+** for all other values.
+**
+** When multiple PATH arguments are supplied, the result is a JSON array
+** containing the result of each PATH.
+**
+** Abbreviated JSON path expressions are allows if JSON_ABPATH, for
+** compatibility with PG.
*/
static void jsonExtractFunc(
sqlite3_context *ctx,
@@ -192778,35 +194651,77 @@ static void jsonExtractFunc(
JsonParse *p; /* The parse */
JsonNode *pNode;
const char *zPath;
+ int flags = SQLITE_PTR_TO_INT(sqlite3_user_data(ctx));
JsonString jx;
- int i;
if( argc<2 ) return;
p = jsonParseCached(ctx, argv, ctx);
if( p==0 ) return;
- jsonInit(&jx, ctx);
- jsonAppendChar(&jx, '[');
- for(i=1; i<argc; i++){
- zPath = (const char*)sqlite3_value_text(argv[i]);
- pNode = jsonLookup(p, zPath, 0, ctx);
- if( p->nErr ) break;
- if( argc>2 ){
+ if( argc==2 ){
+ /* With a single PATH argument */
+ zPath = (const char*)sqlite3_value_text(argv[1]);
+ if( zPath==0 ) return;
+ if( flags & JSON_ABPATH ){
+ if( zPath[0]!='$' ){
+ /* The -> and ->> operators accept abbreviated PATH arguments. This
+ ** is mostly for compatibility with PostgreSQL, but also for
+ ** convenience.
+ **
+ ** NUMBER ==> $[NUMBER] // PG compatible
+ ** LABEL ==> $.LABEL // PG compatible
+ ** [NUMBER] ==> $[NUMBER] // Not PG. Purely for convenience
+ */
+ jsonInit(&jx, ctx);
+ if( sqlite3Isdigit(zPath[0]) ){
+ jsonAppendRaw(&jx, "$[", 2);
+ jsonAppendRaw(&jx, zPath, (int)strlen(zPath));
+ jsonAppendRaw(&jx, "]", 2);
+ }else{
+ jsonAppendRaw(&jx, "$.", 1 + (zPath[0]!='['));
+ jsonAppendRaw(&jx, zPath, (int)strlen(zPath));
+ jsonAppendChar(&jx, 0);
+ }
+ pNode = jx.bErr ? 0 : jsonLookup(p, jx.zBuf, 0, ctx);
+ jsonReset(&jx);
+ }else{
+ pNode = jsonLookup(p, zPath, 0, ctx);
+ }
+ if( pNode ){
+ if( flags & JSON_JSON ){
+ jsonReturnJson(pNode, ctx, 0);
+ }else{
+ jsonReturn(pNode, ctx, 0);
+ sqlite3_result_subtype(ctx, 0);
+ }
+ }
+ }else{
+ pNode = jsonLookup(p, zPath, 0, ctx);
+ if( p->nErr==0 && pNode ) jsonReturn(pNode, ctx, 0);
+ }
+ }else{
+ /* Two or more PATH arguments results in a JSON array with each
+ ** element of the array being the value selected by one of the PATHs */
+ int i;
+ jsonInit(&jx, ctx);
+ jsonAppendChar(&jx, '[');
+ for(i=1; i<argc; i++){
+ zPath = (const char*)sqlite3_value_text(argv[i]);
+ pNode = jsonLookup(p, zPath, 0, ctx);
+ if( p->nErr ) break;
jsonAppendSeparator(&jx);
if( pNode ){
jsonRenderNode(pNode, &jx, 0);
}else{
jsonAppendRaw(&jx, "null", 4);
}
- }else if( pNode ){
- jsonReturn(pNode, ctx, 0);
}
+ if( i==argc ){
+ jsonAppendChar(&jx, ']');
+ jsonResult(&jx);
+ sqlite3_result_subtype(ctx, JSON_SUBTYPE);
+ }
+ jsonReset(&jx);
}
- if( argc>2 && i==argc ){
- jsonAppendChar(&jx, ']');
- jsonResult(&jx);
- sqlite3_result_subtype(ctx, JSON_SUBTYPE);
- }
- jsonReset(&jx);
}
/* This is the RFC 7396 MergePatch algorithm.
@@ -192902,7 +194817,7 @@ static void jsonPatchFunc(
JsonParse y; /* The patch */
JsonNode *pResult; /* The result of the merge */
- UNUSED_PARAM(argc);
+ UNUSED_PARAMETER(argc);
if( jsonParse(&x, ctx, (const char*)sqlite3_value_text(argv[0])) ) return;
if( jsonParse(&y, ctx, (const char*)sqlite3_value_text(argv[1])) ){
jsonParseReset(&x);
@@ -193023,7 +194938,7 @@ static void jsonReplaceFunc(
if( x.nErr ) goto replace_err;
if( pNode ){
assert( pNode->eU==0 || pNode->eU==1 || pNode->eU==4 );
- json_testcase( pNode->eU!=0 && pNode->eU!=1 );
+ testcase( pNode->eU!=0 && pNode->eU!=1 );
pNode->jnFlags |= (u8)JNODE_REPLACE;
VVA( pNode->eU = 4 );
pNode->u.iReplace = i + 1;
@@ -193039,6 +194954,7 @@ replace_err:
jsonParseReset(&x);
}
+
/*
** json_set(JSON, PATH, VALUE, ...)
**
@@ -193061,7 +194977,7 @@ static void jsonSetFunc(
const char *zPath;
u32 i;
int bApnd;
- int bIsSet = *(int*)sqlite3_user_data(ctx);
+ int bIsSet = sqlite3_user_data(ctx)!=0;
if( argc<1 ) return;
if( (argc&1)==0 ) {
@@ -193080,8 +194996,8 @@ static void jsonSetFunc(
}else if( x.nErr ){
goto jsonSetDone;
}else if( pNode && (bApnd || bIsSet) ){
- json_testcase( pNode->eU!=0 && pNode->eU!=1 && pNode->eU!=4 );
- assert( pNode->eU!=3 || pNode->eU!=5 );
+ testcase( pNode->eU!=0 && pNode->eU!=1 );
+ assert( pNode->eU!=3 && pNode->eU!=5 );
VVA( pNode->eU = 4 );
pNode->jnFlags |= (u8)JNODE_REPLACE;
pNode->u.iReplace = i + 1;
@@ -193101,8 +195017,8 @@ jsonSetDone:
** json_type(JSON)
** json_type(JSON, PATH)
**
-** Return the top-level "type" of a JSON string. Throw an error if
-** either the JSON or PATH inputs are not well-formed.
+** Return the top-level "type" of a JSON string. json_type() raises an
+** error if either the JSON or PATH inputs are not well-formed.
*/
static void jsonTypeFunc(
sqlite3_context *ctx,
@@ -193138,7 +195054,7 @@ static void jsonValidFunc(
sqlite3_value **argv
){
JsonParse *p; /* The parse */
- UNUSED_PARAM(argc);
+ UNUSED_PARAMETER(argc);
p = jsonParseCached(ctx, argv, 0);
sqlite3_result_int(ctx, p!=0);
}
@@ -193158,7 +195074,7 @@ static void jsonArrayStep(
sqlite3_value **argv
){
JsonString *pStr;
- UNUSED_PARAM(argc);
+ UNUSED_PARAMETER(argc);
pStr = (JsonString*)sqlite3_aggregate_context(ctx, sizeof(*pStr));
if( pStr ){
if( pStr->zBuf==0 ){
@@ -193218,8 +195134,8 @@ static void jsonGroupInverse(
char *z;
char c;
JsonString *pStr;
- UNUSED_PARAM(argc);
- UNUSED_PARAM(argv);
+ UNUSED_PARAMETER(argc);
+ UNUSED_PARAMETER(argv);
pStr = (JsonString*)sqlite3_aggregate_context(ctx, 0);
#ifdef NEVER
/* pStr is always non-NULL since jsonArrayStep() or jsonObjectStep() will
@@ -193263,7 +195179,7 @@ static void jsonObjectStep(
JsonString *pStr;
const char *z;
u32 n;
- UNUSED_PARAM(argc);
+ UNUSED_PARAMETER(argc);
pStr = (JsonString*)sqlite3_aggregate_context(ctx, sizeof(*pStr));
if( pStr ){
if( pStr->zBuf==0 ){
@@ -193354,10 +195270,10 @@ static int jsonEachConnect(
#define JEACH_JSON 8
#define JEACH_ROOT 9
- UNUSED_PARAM(pzErr);
- UNUSED_PARAM(argv);
- UNUSED_PARAM(argc);
- UNUSED_PARAM(pAux);
+ UNUSED_PARAMETER(pzErr);
+ UNUSED_PARAMETER(argv);
+ UNUSED_PARAMETER(argc);
+ UNUSED_PARAMETER(pAux);
rc = sqlite3_declare_vtab(db,
"CREATE TABLE x(key,value,type,atom,id,parent,fullkey,path,"
"json HIDDEN,root HIDDEN)");
@@ -193380,7 +195296,7 @@ static int jsonEachDisconnect(sqlite3_vtab *pVtab){
static int jsonEachOpenEach(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor){
JsonEachCursor *pCur;
- UNUSED_PARAM(p);
+ UNUSED_PARAMETER(p);
pCur = sqlite3_malloc( sizeof(*pCur) );
if( pCur==0 ) return SQLITE_NOMEM;
memset(pCur, 0, sizeof(*pCur));
@@ -193440,7 +195356,7 @@ static int jsonEachNext(sqlite3_vtab_cursor *cur){
p->eType = pUp->eType;
if( pUp->eType==JSON_ARRAY ){
assert( pUp->eU==0 || pUp->eU==3 );
- json_testcase( pUp->eU==3 );
+ testcase( pUp->eU==3 );
VVA( pUp->eU = 3 );
if( iUp==p->i-1 ){
pUp->u.iKey = 0;
@@ -193627,7 +195543,7 @@ static int jsonEachBestIndex(
/* This implementation assumes that JSON and ROOT are the last two
** columns in the table */
assert( JEACH_ROOT == JEACH_JSON+1 );
- UNUSED_PARAM(tab);
+ UNUSED_PARAMETER(tab);
aIdx[0] = aIdx[1] = -1;
pConstraint = pIdxInfo->aConstraint;
for(i=0; i<pIdxInfo->nConstraint; i++, pConstraint++){
@@ -193683,8 +195599,8 @@ static int jsonEachFilter(
const char *zRoot = 0;
sqlite3_int64 n;
- UNUSED_PARAM(idxStr);
- UNUSED_PARAM(argc);
+ UNUSED_PARAMETER(idxStr);
+ UNUSED_PARAMETER(argc);
jsonEachCursorReset(p);
if( idxNum==0 ) return SQLITE_OK;
z = (const char*)sqlite3_value_text(argv[0]);
@@ -193809,108 +195725,68 @@ static sqlite3_module jsonTreeModule = {
0 /* xShadowName */
};
#endif /* SQLITE_OMIT_VIRTUALTABLE */
-
-/****************************************************************************
-** The following routines are the only publically visible identifiers in this
-** file. Call the following routines in order to register the various SQL
-** functions and the virtual table implemented by this file.
-****************************************************************************/
-
-SQLITE_PRIVATE int sqlite3Json1Init(sqlite3 *db){
- int rc = SQLITE_OK;
- unsigned int i;
- static const struct {
- const char *zName;
- int nArg;
- int flag;
- void (*xFunc)(sqlite3_context*,int,sqlite3_value**);
- } aFunc[] = {
- { "json", 1, 0, jsonRemoveFunc },
- { "json_array", -1, 0, jsonArrayFunc },
- { "json_array_length", 1, 0, jsonArrayLengthFunc },
- { "json_array_length", 2, 0, jsonArrayLengthFunc },
- { "json_extract", -1, 0, jsonExtractFunc },
- { "json_insert", -1, 0, jsonSetFunc },
- { "json_object", -1, 0, jsonObjectFunc },
- { "json_patch", 2, 0, jsonPatchFunc },
- { "json_quote", 1, 0, jsonQuoteFunc },
- { "json_remove", -1, 0, jsonRemoveFunc },
- { "json_replace", -1, 0, jsonReplaceFunc },
- { "json_set", -1, 1, jsonSetFunc },
- { "json_type", 1, 0, jsonTypeFunc },
- { "json_type", 2, 0, jsonTypeFunc },
- { "json_valid", 1, 0, jsonValidFunc },
-
+#endif /* !defined(SQLITE_OMIT_JSON) */
+
+/*
+** Register JSON functions.
+*/
+SQLITE_PRIVATE void sqlite3RegisterJsonFunctions(void){
+#ifndef SQLITE_OMIT_JSON
+ static FuncDef aJsonFunc[] = {
+ JFUNCTION(json, 1, 0, jsonRemoveFunc),
+ JFUNCTION(json_array, -1, 0, jsonArrayFunc),
+ JFUNCTION(json_array_length, 1, 0, jsonArrayLengthFunc),
+ JFUNCTION(json_array_length, 2, 0, jsonArrayLengthFunc),
+ JFUNCTION(json_extract, -1, 0, jsonExtractFunc),
+ JFUNCTION(->, 2, JSON_JSON, jsonExtractFunc),
+ JFUNCTION(->>, 2, JSON_SQL, jsonExtractFunc),
+ JFUNCTION(json_insert, -1, 0, jsonSetFunc),
+ JFUNCTION(json_object, -1, 0, jsonObjectFunc),
+ JFUNCTION(json_patch, 2, 0, jsonPatchFunc),
+ JFUNCTION(json_quote, 1, 0, jsonQuoteFunc),
+ JFUNCTION(json_remove, -1, 0, jsonRemoveFunc),
+ JFUNCTION(json_replace, -1, 0, jsonReplaceFunc),
+ JFUNCTION(json_set, -1, JSON_ISSET, jsonSetFunc),
+ JFUNCTION(json_type, 1, 0, jsonTypeFunc),
+ JFUNCTION(json_type, 2, 0, jsonTypeFunc),
+ JFUNCTION(json_valid, 1, 0, jsonValidFunc),
#if SQLITE_DEBUG
- /* DEBUG and TESTING functions */
- { "json_parse", 1, 0, jsonParseFunc },
- { "json_test1", 1, 0, jsonTest1Func },
-#endif
- };
- static const struct {
- const char *zName;
- int nArg;
- void (*xStep)(sqlite3_context*,int,sqlite3_value**);
- void (*xFinal)(sqlite3_context*);
- void (*xValue)(sqlite3_context*);
- } aAgg[] = {
- { "json_group_array", 1,
- jsonArrayStep, jsonArrayFinal, jsonArrayValue },
- { "json_group_object", 2,
- jsonObjectStep, jsonObjectFinal, jsonObjectValue },
+ JFUNCTION(json_parse, 1, 0, jsonParseFunc),
+ JFUNCTION(json_test1, 1, 0, jsonTest1Func),
+#endif
+ WAGGREGATE(json_group_array, 1, 0, 0,
+ jsonArrayStep, jsonArrayFinal, jsonArrayValue, jsonGroupInverse,
+ SQLITE_SUBTYPE|SQLITE_UTF8|SQLITE_DETERMINISTIC|SQLITE_INNOCUOUS),
+ WAGGREGATE(json_group_object, 2, 0, 0,
+ jsonObjectStep, jsonObjectFinal, jsonObjectValue, jsonGroupInverse,
+ SQLITE_SUBTYPE|SQLITE_UTF8|SQLITE_DETERMINISTIC|SQLITE_INNOCUOUS)
};
-#ifndef SQLITE_OMIT_VIRTUALTABLE
+ sqlite3InsertBuiltinFuncs(aJsonFunc, ArraySize(aJsonFunc));
+#endif
+}
+
+#if !defined(SQLITE_OMIT_VIRTUALTABLE) && !defined(SQLITE_OMIT_JSON)
+/*
+** Register the JSON table-valued functions
+*/
+SQLITE_PRIVATE int sqlite3JsonTableFunctions(sqlite3 *db){
+ int rc = SQLITE_OK;
static const struct {
- const char *zName;
- sqlite3_module *pModule;
+ const char *zName;
+ sqlite3_module *pModule;
} aMod[] = {
{ "json_each", &jsonEachModule },
{ "json_tree", &jsonTreeModule },
};
-#endif
- static const int enc =
- SQLITE_UTF8 |
- SQLITE_DETERMINISTIC |
- SQLITE_INNOCUOUS;
- for(i=0; i<sizeof(aFunc)/sizeof(aFunc[0]) && rc==SQLITE_OK; i++){
- rc = sqlite3_create_function(db, aFunc[i].zName, aFunc[i].nArg, enc,
- (void*)&aFunc[i].flag,
- aFunc[i].xFunc, 0, 0);
- }
-#ifndef SQLITE_OMIT_WINDOWFUNC
- for(i=0; i<sizeof(aAgg)/sizeof(aAgg[0]) && rc==SQLITE_OK; i++){
- rc = sqlite3_create_window_function(db, aAgg[i].zName, aAgg[i].nArg,
- SQLITE_SUBTYPE | enc, 0,
- aAgg[i].xStep, aAgg[i].xFinal,
- aAgg[i].xValue, jsonGroupInverse, 0);
- }
-#endif
-#ifndef SQLITE_OMIT_VIRTUALTABLE
+ unsigned int i;
for(i=0; i<sizeof(aMod)/sizeof(aMod[0]) && rc==SQLITE_OK; i++){
rc = sqlite3_create_module(db, aMod[i].zName, aMod[i].pModule, 0);
}
-#endif
return rc;
}
+#endif /* !defined(SQLITE_OMIT_VIRTUALTABLE) && !defined(SQLITE_OMIT_JSON) */
-
-#ifndef SQLITE_CORE
-#ifdef _WIN32
-__declspec(dllexport)
-#endif
-SQLITE_API int sqlite3_json_init(
- sqlite3 *db,
- char **pzErrMsg,
- const sqlite3_api_routines *pApi
-){
- SQLITE_EXTENSION_INIT2(pApi);
- (void)pzErrMsg; /* Unused parameter */
- return sqlite3Json1Init(db);
-}
-#endif
-#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_JSON1) */
-
-/************** End of json1.c ***********************************************/
+/************** End of json.c ************************************************/
/************** Begin file rtree.c *******************************************/
/*
** 2001 September 15
@@ -198344,11 +200220,7 @@ static void rtreecheck(
# define GEODEBUG(X)
#endif
-#ifndef JSON_NULL /* The following stuff repeats things found in json1 */
-/*
-** Versions of isspace(), isalnum() and isdigit() to which it is safe
-** to pass signed char values.
-*/
+/* Character class routines */
#ifdef sqlite3Isdigit
/* Use the SQLite core versions if this routine is part of the
** SQLite amalgamation */
@@ -198363,6 +200235,7 @@ static void rtreecheck(
# define safe_isxdigit(x) isxdigit((unsigned char)(x))
#endif
+#ifndef JSON_NULL /* The following stuff repeats things found in json1 */
/*
** Growing our own isspace() routine this way is twice as fast as
** the library isspace() function.
@@ -198385,7 +200258,7 @@ static const char geopolyIsSpace[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
};
-#define safe_isspace(x) (geopolyIsSpace[(unsigned char)x])
+#define fast_isspace(x) (geopolyIsSpace[(unsigned char)x])
#endif /* JSON NULL - back to original code */
/* Compiler and version */
@@ -198474,7 +200347,7 @@ static void geopolySwab32(unsigned char *a){
/* Skip whitespace. Return the next non-whitespace character. */
static char geopolySkipSpace(GeoParse *p){
- while( safe_isspace(p->z[0]) ) p->z++;
+ while( fast_isspace(p->z[0]) ) p->z++;
return p->z[0];
}
@@ -203314,7 +205187,7 @@ static char *rbuVacuumTableStart(
** the caller has to use an OFFSET clause to extract only the required
** rows from the sourct table, just as it does for an RBU update operation.
*/
-char *rbuVacuumIndexStart(
+static char *rbuVacuumIndexStart(
sqlite3rbu *p, /* RBU handle */
RbuObjIter *pIter /* RBU iterator object */
){
@@ -208159,6 +210032,7 @@ static int dbpageBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){
){
pIdxInfo->orderByConsumed = 1;
}
+ sqlite3VtabWriteAll(pIdxInfo);
return SQLITE_OK;
}
@@ -228454,7 +230328,7 @@ static int sqlite3Fts5IndexQuery(
if( sqlite3Fts5BufferSize(&p->rc, &buf, nToken+1)==0 ){
int iIdx = 0; /* Index to search */
int iPrefixIdx = 0; /* +1 prefix index */
- if( nToken ) memcpy(&buf.p[1], pToken, nToken);
+ if( nToken>0 ) memcpy(&buf.p[1], pToken, nToken);
/* Figure out which index to search and set iIdx accordingly. If this
** is a prefix query for which there is no prefix index, set iIdx to
@@ -230513,7 +232387,7 @@ static int fts5SorterNext(Fts5Cursor *pCsr){
rc = sqlite3_step(pSorter->pStmt);
if( rc==SQLITE_DONE ){
rc = SQLITE_OK;
- CsrFlagSet(pCsr, FTS5CSR_EOF);
+ CsrFlagSet(pCsr, FTS5CSR_EOF|FTS5CSR_REQUIRE_CONTENT);
}else if( rc==SQLITE_ROW ){
const u8 *a;
const u8 *aBlob;
@@ -232502,7 +234376,7 @@ static void fts5SourceIdFunc(
){
assert( nArg==0 );
UNUSED_PARAM2(nArg, apUnused);
- sqlite3_result_text(pCtx, "fts5: 2021-12-30 15:30:28 378629bf2ea546f73eee84063c5358439a12f7300e433f18c9e1bddd948dea62", -1, SQLITE_TRANSIENT);
+ sqlite3_result_text(pCtx, "fts5: 2022-03-12 13:37:29 38c210fdd258658321c85ec9c01a072fda3ada94540e3239d29b34dc547a8cbc", -1, SQLITE_TRANSIENT);
}
/*
diff --git a/chromium/third_party/sqlite/src/amalgamation_dev/sqlite3.h b/chromium/third_party/sqlite/src/amalgamation_dev/sqlite3.h
index 393e9d206cb..d7f21648941 100644
--- a/chromium/third_party/sqlite/src/amalgamation_dev/sqlite3.h
+++ b/chromium/third_party/sqlite/src/amalgamation_dev/sqlite3.h
@@ -146,9 +146,9 @@ extern "C" {
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
** [sqlite_version()] and [sqlite_source_id()].
*/
-#define SQLITE_VERSION "3.37.1"
-#define SQLITE_VERSION_NUMBER 3037001
-#define SQLITE_SOURCE_ID "2021-12-30 15:30:28 378629bf2ea546f73eee84063c5358439a12f7300e433f18c9e1bddd948dea62"
+#define SQLITE_VERSION "3.38.1"
+#define SQLITE_VERSION_NUMBER 3038001
+#define SQLITE_SOURCE_ID "2022-03-12 13:37:29 38c210fdd258658321c85ec9c01a072fda3ada94540e3239d29b34dc547a8cbc"
/*
** CAPI3REF: Run-Time Library Version Numbers
@@ -566,7 +566,7 @@ SQLITE_API int sqlite3_exec(
#define SQLITE_WARNING_AUTOINDEX (SQLITE_WARNING | (1<<8))
#define SQLITE_AUTH_USER (SQLITE_AUTH | (1<<8))
#define SQLITE_OK_LOAD_PERMANENTLY (SQLITE_OK | (1<<8))
-#define SQLITE_OK_SYMLINK (SQLITE_OK | (2<<8))
+#define SQLITE_OK_SYMLINK (SQLITE_OK | (2<<8)) /* internal use only */
/*
** CAPI3REF: Flags For File Open Operations
@@ -3824,13 +3824,14 @@ SQLITE_API void sqlite3_free_filename(char*);
** sqlite3_extended_errcode() might change with each API call.
** Except, there are some interfaces that are guaranteed to never
** change the value of the error code. The error-code preserving
-** interfaces are:
+** interfaces include the following:
**
** <ul>
** <li> sqlite3_errcode()
** <li> sqlite3_extended_errcode()
** <li> sqlite3_errmsg()
** <li> sqlite3_errmsg16()
+** <li> sqlite3_error_offset()
** </ul>
**
** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language
@@ -3845,6 +3846,13 @@ SQLITE_API void sqlite3_free_filename(char*);
** ^(Memory to hold the error message string is managed internally
** and must not be freed by the application)^.
**
+** ^If the most recent error references a specific token in the input
+** SQL, the sqlite3_error_offset() interface returns the byte offset
+** of the start of that token. ^The byte offset returned by
+** sqlite3_error_offset() assumes that the input SQL is UTF8.
+** ^If the most recent error does not reference a specific token in the input
+** SQL, then the sqlite3_error_offset() function returns -1.
+**
** When the serialized [threading mode] is in use, it might be the
** case that a second error occurs on a separate thread in between
** the time of the first error and the call to these interfaces.
@@ -3864,6 +3872,7 @@ SQLITE_API int sqlite3_extended_errcode(sqlite3 *db);
SQLITE_API const char *sqlite3_errmsg(sqlite3*);
SQLITE_API const void *sqlite3_errmsg16(sqlite3*);
SQLITE_API const char *sqlite3_errstr(int);
+SQLITE_API int sqlite3_error_offset(sqlite3 *db);
/*
** CAPI3REF: Prepared Statement Object
@@ -4275,6 +4284,10 @@ SQLITE_API const char *sqlite3_normalized_sql(sqlite3_stmt *pStmt);
** be false. ^Similarly, a CREATE TABLE IF NOT EXISTS statement is a
** read-only no-op if the table already exists, but
** sqlite3_stmt_readonly() still returns false for such a statement.
+**
+** ^If prepared statement X is an [EXPLAIN] or [EXPLAIN QUERY PLAN]
+** statement, then sqlite3_stmt_readonly(X) returns the same value as
+** if the EXPLAIN or EXPLAIN QUERY PLAN prefix were omitted.
*/
SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt);
@@ -4343,6 +4356,8 @@ SQLITE_API int sqlite3_stmt_busy(sqlite3_stmt*);
**
** ^The sqlite3_value objects that are passed as parameters into the
** implementation of [application-defined SQL functions] are protected.
+** ^The sqlite3_value objects returned by [sqlite3_vtab_rhs_value()]
+** are protected.
** ^The sqlite3_value object returned by
** [sqlite3_column_value()] is unprotected.
** Unprotected sqlite3_value objects may only be used as arguments
@@ -4964,6 +4979,10 @@ SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
** even empty strings, are always zero-terminated. ^The return
** value from sqlite3_column_blob() for a zero-length BLOB is a NULL pointer.
**
+** ^Strings returned by sqlite3_column_text16() always have the endianness
+** which is native to the platform, regardless of the text encoding set
+** for the database.
+**
** <b>Warning:</b> ^The object returned by [sqlite3_column_value()] is an
** [unprotected sqlite3_value] object. In a multithreaded environment,
** an unprotected sqlite3_value object may only be used safely with
@@ -4977,7 +4996,7 @@ SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
** [application-defined SQL functions] or [virtual tables], not within
** top-level application code.
**
-** The these routines may attempt to convert the datatype of the result.
+** These routines may attempt to convert the datatype of the result.
** ^For example, if the internal representation is FLOAT and a text result
** is requested, [sqlite3_snprintf()] is used internally to perform the
** conversion automatically. ^(The following table details the conversions
@@ -5002,7 +5021,7 @@ SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
** <tr><td> TEXT <td> BLOB <td> No change
** <tr><td> BLOB <td> INTEGER <td> [CAST] to INTEGER
** <tr><td> BLOB <td> FLOAT <td> [CAST] to REAL
-** <tr><td> BLOB <td> TEXT <td> Add a zero terminator if needed
+** <tr><td> BLOB <td> TEXT <td> [CAST] to TEXT, ensure zero terminator
** </table>
** </blockquote>)^
**
@@ -7122,24 +7141,56 @@ struct sqlite3_index_info {
**
** These macros define the allowed values for the
** [sqlite3_index_info].aConstraint[].op field. Each value represents
-** an operator that is part of a constraint term in the wHERE clause of
+** an operator that is part of a constraint term in the WHERE clause of
** a query that uses a [virtual table].
-*/
-#define SQLITE_INDEX_CONSTRAINT_EQ 2
-#define SQLITE_INDEX_CONSTRAINT_GT 4
-#define SQLITE_INDEX_CONSTRAINT_LE 8
-#define SQLITE_INDEX_CONSTRAINT_LT 16
-#define SQLITE_INDEX_CONSTRAINT_GE 32
-#define SQLITE_INDEX_CONSTRAINT_MATCH 64
-#define SQLITE_INDEX_CONSTRAINT_LIKE 65
-#define SQLITE_INDEX_CONSTRAINT_GLOB 66
-#define SQLITE_INDEX_CONSTRAINT_REGEXP 67
-#define SQLITE_INDEX_CONSTRAINT_NE 68
-#define SQLITE_INDEX_CONSTRAINT_ISNOT 69
-#define SQLITE_INDEX_CONSTRAINT_ISNOTNULL 70
-#define SQLITE_INDEX_CONSTRAINT_ISNULL 71
-#define SQLITE_INDEX_CONSTRAINT_IS 72
-#define SQLITE_INDEX_CONSTRAINT_FUNCTION 150
+**
+** ^The left-hand operand of the operator is given by the corresponding
+** aConstraint[].iColumn field. ^An iColumn of -1 indicates the left-hand
+** operand is the rowid.
+** The SQLITE_INDEX_CONSTRAINT_LIMIT and SQLITE_INDEX_CONSTRAINT_OFFSET
+** operators have no left-hand operand, and so for those operators the
+** corresponding aConstraint[].iColumn is meaningless and should not be
+** used.
+**
+** All operator values from SQLITE_INDEX_CONSTRAINT_FUNCTION through
+** value 255 are reserved to represent functions that are overloaded
+** by the [xFindFunction|xFindFunction method] of the virtual table
+** implementation.
+**
+** The right-hand operands for each constraint might be accessible using
+** the [sqlite3_vtab_rhs_value()] interface. Usually the right-hand
+** operand is only available if it appears as a single constant literal
+** in the input SQL. If the right-hand operand is another column or an
+** expression (even a constant expression) or a parameter, then the
+** sqlite3_vtab_rhs_value() probably will not be able to extract it.
+** ^The SQLITE_INDEX_CONSTRAINT_ISNULL and
+** SQLITE_INDEX_CONSTRAINT_ISNOTNULL operators have no right-hand operand
+** and hence calls to sqlite3_vtab_rhs_value() for those operators will
+** always return SQLITE_NOTFOUND.
+**
+** The collating sequence to be used for comparison can be found using
+** the [sqlite3_vtab_collation()] interface. For most real-world virtual
+** tables, the collating sequence of constraints does not matter (for example
+** because the constraints are numeric) and so the sqlite3_vtab_collation()
+** interface is no commonly needed.
+*/
+#define SQLITE_INDEX_CONSTRAINT_EQ 2
+#define SQLITE_INDEX_CONSTRAINT_GT 4
+#define SQLITE_INDEX_CONSTRAINT_LE 8
+#define SQLITE_INDEX_CONSTRAINT_LT 16
+#define SQLITE_INDEX_CONSTRAINT_GE 32
+#define SQLITE_INDEX_CONSTRAINT_MATCH 64
+#define SQLITE_INDEX_CONSTRAINT_LIKE 65
+#define SQLITE_INDEX_CONSTRAINT_GLOB 66
+#define SQLITE_INDEX_CONSTRAINT_REGEXP 67
+#define SQLITE_INDEX_CONSTRAINT_NE 68
+#define SQLITE_INDEX_CONSTRAINT_ISNOT 69
+#define SQLITE_INDEX_CONSTRAINT_ISNOTNULL 70
+#define SQLITE_INDEX_CONSTRAINT_ISNULL 71
+#define SQLITE_INDEX_CONSTRAINT_IS 72
+#define SQLITE_INDEX_CONSTRAINT_LIMIT 73
+#define SQLITE_INDEX_CONSTRAINT_OFFSET 74
+#define SQLITE_INDEX_CONSTRAINT_FUNCTION 150
/*
** CAPI3REF: Register A Virtual Table Implementation
@@ -7168,7 +7219,7 @@ struct sqlite3_index_info {
** destructor.
**
** ^If the third parameter (the pointer to the sqlite3_module object) is
-** NULL then no new module is create and any existing modules with the
+** NULL then no new module is created and any existing modules with the
** same name are dropped.
**
** See also: [sqlite3_drop_modules()]
@@ -7944,7 +7995,8 @@ SQLITE_API int sqlite3_test_control(int op, ...);
#define SQLITE_TESTCTRL_SEEK_COUNT 30
#define SQLITE_TESTCTRL_TRACEFLAGS 31
#define SQLITE_TESTCTRL_TUNE 32
-#define SQLITE_TESTCTRL_LAST 32 /* Largest TESTCTRL */
+#define SQLITE_TESTCTRL_LOGEST 33
+#define SQLITE_TESTCTRL_LAST 33 /* Largest TESTCTRL */
/*
** CAPI3REF: SQL Keyword Checking
@@ -8467,6 +8519,16 @@ SQLITE_API int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);
** The counter is incremented on the first [sqlite3_step()] call of each
** cycle.
**
+** [[SQLITE_STMTSTATUS_FILTER_MISS]]
+** [[SQLITE_STMTSTATUS_FILTER HIT]]
+** <dt>SQLITE_STMTSTATUS_FILTER_HIT<br>
+** SQLITE_STMTSTATUS_FILTER_MISS</dt>
+** <dd>^SQLITE_STMTSTATUS_FILTER_HIT is the number of times that a join
+** step was bypassed because a Bloom filter returned not-found. The
+** corresponding SQLITE_STMTSTATUS_FILTER_MISS value is the number of
+** times that the Bloom filter returned a find, and thus the join step
+** had to be processed as normal.
+**
** [[SQLITE_STMTSTATUS_MEMUSED]] <dt>SQLITE_STMTSTATUS_MEMUSED</dt>
** <dd>^This is the approximate number of bytes of heap memory
** used to store the prepared statement. ^This value is not actually
@@ -8481,6 +8543,8 @@ SQLITE_API int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);
#define SQLITE_STMTSTATUS_VM_STEP 4
#define SQLITE_STMTSTATUS_REPREPARE 5
#define SQLITE_STMTSTATUS_RUN 6
+#define SQLITE_STMTSTATUS_FILTER_MISS 7
+#define SQLITE_STMTSTATUS_FILTER_HIT 8
#define SQLITE_STMTSTATUS_MEMUSED 99
/*
@@ -9449,20 +9513,270 @@ SQLITE_API int sqlite3_vtab_nochange(sqlite3_context*);
/*
** CAPI3REF: Determine The Collation For a Virtual Table Constraint
+** METHOD: sqlite3_index_info
**
** This function may only be called from within a call to the [xBestIndex]
-** method of a [virtual table].
+** method of a [virtual table]. This function returns a pointer to a string
+** that is the name of the appropriate collation sequence to use for text
+** comparisons on the constraint identified by its arguments.
+**
+** The first argument must be the pointer to the [sqlite3_index_info] object
+** that is the first parameter to the xBestIndex() method. The second argument
+** must be an index into the aConstraint[] array belonging to the
+** sqlite3_index_info structure passed to xBestIndex.
+**
+** Important:
+** The first parameter must be the same pointer that is passed into the
+** xBestMethod() method. The first parameter may not be a pointer to a
+** different [sqlite3_index_info] object, even an exact copy.
+**
+** The return value is computed as follows:
**
-** The first argument must be the sqlite3_index_info object that is the
-** first parameter to the xBestIndex() method. The second argument must be
-** an index into the aConstraint[] array belonging to the sqlite3_index_info
-** structure passed to xBestIndex. This function returns a pointer to a buffer
-** containing the name of the collation sequence for the corresponding
-** constraint.
+** <ol>
+** <li><p> If the constraint comes from a WHERE clause expression that contains
+** a [COLLATE operator], then the name of the collation specified by
+** that COLLATE operator is returned.
+** <li><p> If there is no COLLATE operator, but the column that is the subject
+** of the constraint specifies an alternative collating sequence via
+** a [COLLATE clause] on the column definition within the CREATE TABLE
+** statement that was passed into [sqlite3_declare_vtab()], then the
+** name of that alternative collating sequence is returned.
+** <li><p> Otherwise, "BINARY" is returned.
+** </ol>
*/
SQLITE_API SQLITE_EXPERIMENTAL const char *sqlite3_vtab_collation(sqlite3_index_info*,int);
/*
+** CAPI3REF: Determine if a virtual table query is DISTINCT
+** METHOD: sqlite3_index_info
+**
+** This API may only be used from within an [xBestIndex|xBestIndex method]
+** of a [virtual table] implementation. The result of calling this
+** interface from outside of xBestIndex() is undefined and probably harmful.
+**
+** ^The sqlite3_vtab_distinct() interface returns an integer that is
+** either 0, 1, or 2. The integer returned by sqlite3_vtab_distinct()
+** gives the virtual table additional information about how the query
+** planner wants the output to be ordered. As long as the virtual table
+** can meet the ordering requirements of the query planner, it may set
+** the "orderByConsumed" flag.
+**
+** <ol><li value="0"><p>
+** ^If the sqlite3_vtab_distinct() interface returns 0, that means
+** that the query planner needs the virtual table to return all rows in the
+** sort order defined by the "nOrderBy" and "aOrderBy" fields of the
+** [sqlite3_index_info] object. This is the default expectation. If the
+** virtual table outputs all rows in sorted order, then it is always safe for
+** the xBestIndex method to set the "orderByConsumed" flag, regardless of
+** the return value from sqlite3_vtab_distinct().
+** <li value="1"><p>
+** ^(If the sqlite3_vtab_distinct() interface returns 1, that means
+** that the query planner does not need the rows to be returned in sorted order
+** as long as all rows with the same values in all columns identified by the
+** "aOrderBy" field are adjacent.)^ This mode is used when the query planner
+** is doing a GROUP BY.
+** <li value="2"><p>
+** ^(If the sqlite3_vtab_distinct() interface returns 2, that means
+** that the query planner does not need the rows returned in any particular
+** order, as long as rows with the same values in all "aOrderBy" columns
+** are adjacent.)^ ^(Furthermore, only a single row for each particular
+** combination of values in the columns identified by the "aOrderBy" field
+** needs to be returned.)^ ^It is always ok for two or more rows with the same
+** values in all "aOrderBy" columns to be returned, as long as all such rows
+** are adjacent. ^The virtual table may, if it chooses, omit extra rows
+** that have the same value for all columns identified by "aOrderBy".
+** ^However omitting the extra rows is optional.
+** This mode is used for a DISTINCT query.
+** </ol>
+**
+** ^For the purposes of comparing virtual table output values to see if the
+** values are same value for sorting purposes, two NULL values are considered
+** to be the same. In other words, the comparison operator is "IS"
+** (or "IS NOT DISTINCT FROM") and not "==".
+**
+** If a virtual table implementation is unable to meet the requirements
+** specified above, then it must not set the "orderByConsumed" flag in the
+** [sqlite3_index_info] object or an incorrect answer may result.
+**
+** ^A virtual table implementation is always free to return rows in any order
+** it wants, as long as the "orderByConsumed" flag is not set. ^When the
+** the "orderByConsumed" flag is unset, the query planner will add extra
+** [bytecode] to ensure that the final results returned by the SQL query are
+** ordered correctly. The use of the "orderByConsumed" flag and the
+** sqlite3_vtab_distinct() interface is merely an optimization. ^Careful
+** use of the sqlite3_vtab_distinct() interface and the "orderByConsumed"
+** flag might help queries against a virtual table to run faster. Being
+** overly aggressive and setting the "orderByConsumed" flag when it is not
+** valid to do so, on the other hand, might cause SQLite to return incorrect
+** results.
+*/
+SQLITE_API int sqlite3_vtab_distinct(sqlite3_index_info*);
+
+/*
+** CAPI3REF: Identify and handle IN constraints in xBestIndex
+**
+** This interface may only be used from within an
+** [xBestIndex|xBestIndex() method] of a [virtual table] implementation.
+** The result of invoking this interface from any other context is
+** undefined and probably harmful.
+**
+** ^(A constraint on a virtual table of the form
+** "[IN operator|column IN (...)]" is
+** communicated to the xBestIndex method as a
+** [SQLITE_INDEX_CONSTRAINT_EQ] constraint.)^ If xBestIndex wants to use
+** this constraint, it must set the corresponding
+** aConstraintUsage[].argvIndex to a postive integer. ^(Then, under
+** the usual mode of handling IN operators, SQLite generates [bytecode]
+** that invokes the [xFilter|xFilter() method] once for each value
+** on the right-hand side of the IN operator.)^ Thus the virtual table
+** only sees a single value from the right-hand side of the IN operator
+** at a time.
+**
+** In some cases, however, it would be advantageous for the virtual
+** table to see all values on the right-hand of the IN operator all at
+** once. The sqlite3_vtab_in() interfaces facilitates this in two ways:
+**
+** <ol>
+** <li><p>
+** ^A call to sqlite3_vtab_in(P,N,-1) will return true (non-zero)
+** if and only if the [sqlite3_index_info|P->aConstraint][N] constraint
+** is an [IN operator] that can be processed all at once. ^In other words,
+** sqlite3_vtab_in() with -1 in the third argument is a mechanism
+** by which the virtual table can ask SQLite if all-at-once processing
+** of the IN operator is even possible.
+**
+** <li><p>
+** ^A call to sqlite3_vtab_in(P,N,F) with F==1 or F==0 indicates
+** to SQLite that the virtual table does or does not want to process
+** the IN operator all-at-once, respectively. ^Thus when the third
+** parameter (F) is non-negative, this interface is the mechanism by
+** which the virtual table tells SQLite how it wants to process the
+** IN operator.
+** </ol>
+**
+** ^The sqlite3_vtab_in(P,N,F) interface can be invoked multiple times
+** within the same xBestIndex method call. ^For any given P,N pair,
+** the return value from sqlite3_vtab_in(P,N,F) will always be the same
+** within the same xBestIndex call. ^If the interface returns true
+** (non-zero), that means that the constraint is an IN operator
+** that can be processed all-at-once. ^If the constraint is not an IN
+** operator or cannot be processed all-at-once, then the interface returns
+** false.
+**
+** ^(All-at-once processing of the IN operator is selected if both of the
+** following conditions are met:
+**
+** <ol>
+** <li><p> The P->aConstraintUsage[N].argvIndex value is set to a positive
+** integer. This is how the virtual table tells SQLite that it wants to
+** use the N-th constraint.
+**
+** <li><p> The last call to sqlite3_vtab_in(P,N,F) for which F was
+** non-negative had F>=1.
+** </ol>)^
+**
+** ^If either or both of the conditions above are false, then SQLite uses
+** the traditional one-at-a-time processing strategy for the IN constraint.
+** ^If both conditions are true, then the argvIndex-th parameter to the
+** xFilter method will be an [sqlite3_value] that appears to be NULL,
+** but which can be passed to [sqlite3_vtab_in_first()] and
+** [sqlite3_vtab_in_next()] to find all values on the right-hand side
+** of the IN constraint.
+*/
+SQLITE_API int sqlite3_vtab_in(sqlite3_index_info*, int iCons, int bHandle);
+
+/*
+** CAPI3REF: Find all elements on the right-hand side of an IN constraint.
+**
+** These interfaces are only useful from within the
+** [xFilter|xFilter() method] of a [virtual table] implementation.
+** The result of invoking these interfaces from any other context
+** is undefined and probably harmful.
+**
+** The X parameter in a call to sqlite3_vtab_in_first(X,P) or
+** sqlite3_vtab_in_next(X,P) must be one of the parameters to the
+** xFilter method which invokes these routines, and specifically
+** a parameter that was previously selected for all-at-once IN constraint
+** processing use the [sqlite3_vtab_in()] interface in the
+** [xBestIndex|xBestIndex method]. ^(If the X parameter is not
+** an xFilter argument that was selected for all-at-once IN constraint
+** processing, then these routines return [SQLITE_MISUSE])^ or perhaps
+** exhibit some other undefined or harmful behavior.
+**
+** ^(Use these routines to access all values on the right-hand side
+** of the IN constraint using code like the following:
+**
+** <blockquote><pre>
+** &nbsp; for(rc=sqlite3_vtab_in_first(pList, &pVal);
+** &nbsp; rc==SQLITE_OK && pVal
+** &nbsp; rc=sqlite3_vtab_in_next(pList, &pVal)
+** &nbsp; ){
+** &nbsp; // do something with pVal
+** &nbsp; }
+** &nbsp; if( rc!=SQLITE_OK ){
+** &nbsp; // an error has occurred
+** &nbsp; }
+** </pre></blockquote>)^
+**
+** ^On success, the sqlite3_vtab_in_first(X,P) and sqlite3_vtab_in_next(X,P)
+** routines return SQLITE_OK and set *P to point to the first or next value
+** on the RHS of the IN constraint. ^If there are no more values on the
+** right hand side of the IN constraint, then *P is set to NULL and these
+** routines return [SQLITE_DONE]. ^The return value might be
+** some other value, such as SQLITE_NOMEM, in the event of a malfunction.
+**
+** The *ppOut values returned by these routines are only valid until the
+** next call to either of these routines or until the end of the xFilter
+** method from which these routines were called. If the virtual table
+** implementation needs to retain the *ppOut values for longer, it must make
+** copies. The *ppOut values are [protected sqlite3_value|protected].
+*/
+SQLITE_API int sqlite3_vtab_in_first(sqlite3_value *pVal, sqlite3_value **ppOut);
+SQLITE_API int sqlite3_vtab_in_next(sqlite3_value *pVal, sqlite3_value **ppOut);
+
+/*
+** CAPI3REF: Constraint values in xBestIndex()
+** METHOD: sqlite3_index_info
+**
+** This API may only be used from within the [xBestIndex|xBestIndex method]
+** of a [virtual table] implementation. The result of calling this interface
+** from outside of an xBestIndex method are undefined and probably harmful.
+**
+** ^When the sqlite3_vtab_rhs_value(P,J,V) interface is invoked from within
+** the [xBestIndex] method of a [virtual table] implementation, with P being
+** a copy of the [sqlite3_index_info] object pointer passed into xBestIndex and
+** J being a 0-based index into P->aConstraint[], then this routine
+** attempts to set *V to the value of the right-hand operand of
+** that constraint if the right-hand operand is known. ^If the
+** right-hand operand is not known, then *V is set to a NULL pointer.
+** ^The sqlite3_vtab_rhs_value(P,J,V) interface returns SQLITE_OK if
+** and only if *V is set to a value. ^The sqlite3_vtab_rhs_value(P,J,V)
+** inteface returns SQLITE_NOTFOUND if the right-hand side of the J-th
+** constraint is not available. ^The sqlite3_vtab_rhs_value() interface
+** can return an result code other than SQLITE_OK or SQLITE_NOTFOUND if
+** something goes wrong.
+**
+** The sqlite3_vtab_rhs_value() interface is usually only successful if
+** the right-hand operand of a constraint is a literal value in the original
+** SQL statement. If the right-hand operand is an expression or a reference
+** to some other column or a [host parameter], then sqlite3_vtab_rhs_value()
+** will probably return [SQLITE_NOTFOUND].
+**
+** ^(Some constraints, such as [SQLITE_INDEX_CONSTRAINT_ISNULL] and
+** [SQLITE_INDEX_CONSTRAINT_ISNOTNULL], have no right-hand operand. For such
+** constraints, sqlite3_vtab_rhs_value() always returns SQLITE_NOTFOUND.)^
+**
+** ^The [sqlite3_value] object returned in *V is a protected sqlite3_value
+** and remains valid for the duration of the xBestIndex method call.
+** ^When xBestIndex returns, the sqlite3_value object returned by
+** sqlite3_vtab_rhs_value() is automatically deallocated.
+**
+** The "_rhs_" in the name of this routine is an abbreviation for
+** "Right-Hand Side".
+*/
+SQLITE_API int sqlite3_vtab_rhs_value(sqlite3_index_info*, int, sqlite3_value **ppVal);
+
+/*
** CAPI3REF: Conflict resolution modes
** KEYWORDS: {conflict resolution mode}
**
diff --git a/chromium/third_party/sqlite/src/autoconf/Makefile.msc b/chromium/third_party/sqlite/src/autoconf/Makefile.msc
index 40d0e8113da..e36eb21ea00 100644
--- a/chromium/third_party/sqlite/src/autoconf/Makefile.msc
+++ b/chromium/third_party/sqlite/src/autoconf/Makefile.msc
@@ -285,7 +285,6 @@ SQLITE3EXEPDB = /pdb:sqlite3sh.pdb
OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_FTS3=1
OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_RTREE=1
OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_GEOPOLY=1
-OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_JSON1=1
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
@@ -502,12 +501,12 @@ RCC = $(RC) -DSQLITE_OS_WIN=1 -I. -I$(TOP) $(RCOPTS) $(RCCOPTS)
#
!IF $(USE_STDCALL)!=0 || $(FOR_WIN10)!=0
!IF "$(PLATFORM)"=="x86"
-CORE_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall
-SHELL_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall
+CORE_CCONV_OPTS = -Gz -guard:cf -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall
+SHELL_CCONV_OPTS = -Gz -guard:cf -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall
!ELSE
!IFNDEF PLATFORM
-CORE_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall
-SHELL_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall
+CORE_CCONV_OPTS = -Gz -guard:cf -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall
+SHELL_CCONV_OPTS = -Gz -guard:cf -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall
!ELSE
CORE_CCONV_OPTS =
SHELL_CCONV_OPTS =
diff --git a/chromium/third_party/sqlite/src/autoconf/README.txt b/chromium/third_party/sqlite/src/autoconf/README.txt
index 6e62a4e1385..ccf5e235ac9 100644
--- a/chromium/third_party/sqlite/src/autoconf/README.txt
+++ b/chromium/third_party/sqlite/src/autoconf/README.txt
@@ -105,7 +105,7 @@ may be specified in this manner as some require the amalgamation to be built
with them enabled (see http://www.sqlite.org/compile.html). For example, the
following will work:
- "OPTS=-DSQLITE_ENABLE_STAT4=1 -DSQLITE_ENABLE_JSON1=1"
+ "OPTS=-DSQLITE_ENABLE_STAT4=1 -DSQLITE_OMIT_JSON=1"
However, the following will not compile unless the amalgamation was built
with it enabled:
diff --git a/chromium/third_party/sqlite/src/autoconf/configure.ac b/chromium/third_party/sqlite/src/autoconf/configure.ac
index e050786bd71..0c7a32db1f7 100644
--- a/chromium/third_party/sqlite/src/autoconf/configure.ac
+++ b/chromium/third_party/sqlite/src/autoconf/configure.ac
@@ -174,21 +174,6 @@ fi
#-----------------------------------------------------------------------
#-----------------------------------------------------------------------
-# --enable-json1
-#
-AC_ARG_ENABLE(json1, [AS_HELP_STRING(
- [--enable-json1], [include json1 support [default=yes]])],
- [],[enable_json1=yes])
-AC_MSG_CHECKING([JSON functions])
-if test x"$enable_json1" = "xyes"; then
- BUILD_CFLAGS="$BUILD_CFLAGS -DSQLITE_ENABLE_JSON1"
- AC_MSG_RESULT([enabled])
-else
- AC_MSG_RESULT([disabled])
-fi
-#-----------------------------------------------------------------------
-
-#-----------------------------------------------------------------------
# --enable-rtree
#
AC_ARG_ENABLE(rtree, [AS_HELP_STRING(
diff --git a/chromium/third_party/sqlite/src/configure b/chromium/third_party/sqlite/src/configure
index 28b508a0510..a7f0290bbab 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.37.1.
+# Generated by GNU Autoconf 2.69 for sqlite 3.38.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.37.1'
-PACKAGE_STRING='sqlite 3.37.1'
+PACKAGE_VERSION='3.38.1'
+PACKAGE_STRING='sqlite 3.38.1'
PACKAGE_BUGREPORT=''
PACKAGE_URL=''
@@ -905,13 +905,13 @@ enable_debug
enable_amalgamation
enable_load_extension
enable_math
+enable_json
enable_all
enable_memsys5
enable_memsys3
enable_fts3
enable_fts4
enable_fts5
-enable_json1
enable_update_limit
enable_geopoly
enable_rtree
@@ -1468,7 +1468,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.37.1 to adapt to many kinds of systems.
+\`configure' configures sqlite 3.38.1 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1533,7 +1533,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of sqlite 3.37.1:";;
+ short | recursive ) echo "Configuration of sqlite 3.38.1:";;
esac
cat <<\_ACEOF
@@ -1560,13 +1560,13 @@ Optional Features:
--disable-load-extension
Disable loading of external extensions
--disable-math Disable math functions
- --enable-all Enable FTS4, FTS5, Geopoly, JSON, RTree, Sessions
+ --disable-json Disable JSON functions
+ --enable-all Enable FTS4, FTS5, Geopoly, RTree, Sessions
--enable-memsys5 Enable MEMSYS5
--enable-memsys3 Enable MEMSYS3
--enable-fts3 Enable the FTS3 extension
--enable-fts4 Enable the FTS4 extension
--enable-fts5 Enable the FTS5 extension
- --enable-json1 Enable the JSON1 extension
--enable-update-limit Enable the UPDATE/DELETE LIMIT clause
--enable-geopoly Enable the GEOPOLY extension
--enable-rtree Enable the RTREE extension
@@ -1661,7 +1661,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-sqlite configure 3.37.1
+sqlite configure 3.38.1
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
@@ -2080,7 +2080,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.37.1, which was
+It was created by sqlite $as_me 3.38.1, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
@@ -11497,6 +11497,24 @@ fi
fi
+##########
+# Do we want to support JSON functions
+#
+# Check whether --enable-json was given.
+if test "${enable_json+set}" = set; then :
+ enableval=$enable_json;
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to support JSON functions" >&5
+$as_echo_n "checking whether to support JSON functions... " >&6; }
+if test "$enable_json" = "no"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_OMIT_JSON"
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+fi
########
# The --enable-all argument is short-hand to enable
@@ -11702,24 +11720,6 @@ $as_echo "no" >&6; }
fi
#########
-# See whether we should enable JSON1
-# Check whether --enable-json1 was given.
-if test "${enable_json1+set}" = set; then :
- enableval=$enable_json1;
-fi
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to support JSON" >&5
-$as_echo_n "checking whether to support JSON... " >&6; }
-if test "${enable_json1}" = "yes" -o "${enable_all}" = "yes" ; then
- OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_JSON1"
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-#########
# See whether we should enable the LIMIT clause on UPDATE and DELETE
# statements.
# Check whether --enable-update-limit was given.
@@ -12390,7 +12390,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.37.1, which was
+This file was extended by sqlite $as_me 3.38.1, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -12456,7 +12456,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.37.1
+sqlite config.status 3.38.1
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
diff --git a/chromium/third_party/sqlite/src/configure.ac b/chromium/third_party/sqlite/src/configure.ac
index 32fe0d229a3..cc805a00d57 100644
--- a/chromium/third_party/sqlite/src/configure.ac
+++ b/chromium/third_party/sqlite/src/configure.ac
@@ -605,12 +605,24 @@ else
AC_SEARCH_LIBS(ceil, m)
fi
+##########
+# Do we want to support JSON functions
+#
+AC_ARG_ENABLE(json,
+AC_HELP_STRING([--disable-json],[Disable JSON functions]))
+AC_MSG_CHECKING([whether to support JSON functions])
+if test "$enable_json" = "no"; then
+ AC_MSG_RESULT([no])
+ OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_OMIT_JSON"
+else
+ AC_MSG_RESULT([yes])
+fi
########
# The --enable-all argument is short-hand to enable
# multiple extensions.
AC_ARG_ENABLE(all, AC_HELP_STRING([--enable-all],
- [Enable FTS4, FTS5, Geopoly, JSON, RTree, Sessions]))
+ [Enable FTS4, FTS5, Geopoly, RTree, Sessions]))
##########
# Do we want to support memsys3 and/or memsys5
@@ -667,17 +679,6 @@ else
fi
#########
-# See whether we should enable JSON1
-AC_ARG_ENABLE(json1, AC_HELP_STRING([--enable-json1],[Enable the JSON1 extension]))
-AC_MSG_CHECKING([whether to support JSON])
-if test "${enable_json1}" = "yes" -o "${enable_all}" = "yes" ; then
- OPT_FEATURE_FLAGS="${OPT_FEATURE_FLAGS} -DSQLITE_ENABLE_JSON1"
- AC_MSG_RESULT([yes])
-else
- AC_MSG_RESULT([no])
-fi
-
-#########
# See whether we should enable the LIMIT clause on UPDATE and DELETE
# statements.
AC_ARG_ENABLE(update-limit, AC_HELP_STRING([--enable-update-limit],
diff --git a/chromium/third_party/sqlite/src/doc/json-enhancements.md b/chromium/third_party/sqlite/src/doc/json-enhancements.md
new file mode 100644
index 00000000000..bc03e8978cb
--- /dev/null
+++ b/chromium/third_party/sqlite/src/doc/json-enhancements.md
@@ -0,0 +1,144 @@
+# JSON Functions Enhancements (2022)
+
+This document summaries enhancements to the SQLite JSON support added in
+early 2022.
+
+## 1.0 Change summary:
+
+ 1. New **->** and **->>** operators that work like MySQL and PostgreSQL (PG).
+ 2. JSON functions are built-in rather than being an extension. They
+ are included by default, but can be omitted using the
+ -DSQLITE_OMIT_JSON compile-time option.
+
+
+## 2.0 New operators **->** and **->>**
+
+The SQLite language adds two new binary operators **->** and **->>**.
+Both operators are similar to json_extract(). The left operand is
+JSON and the right operand is a JSON path expression (possibly abbreviated
+for compatibility with PG - see below). So they are similar to a
+two-argument call to json_extract().
+
+The difference between -> and ->> (and json_extract()) is as follows:
+
+ * The -> operator always returns JSON.
+
+ * The ->> operator converts the answer into a primitive SQL datatype
+ such as TEXT, INTEGER, REAL, or NULL. If a JSON object or array
+ is selected, that object or array is rendered as text. If a JSON
+ value is selected, that value is converted into its corresponding
+ SQL type
+
+ * The json_extract() interface returns JSON when a JSON object or
+ array is selected, or a primitive SQL datatype when a JSON value
+ is selected. This is different from MySQL, in which json_extract()
+ always returns JSON, but the difference is retained because it has
+ worked that way for 6 years and changing it now would likely break
+ a lot of legacy code.
+
+In MySQL and PG, the ->> operator always returns TEXT (or NULL) and never
+INTEGER or REAL. This is due to limitations in the type handling capabilities
+of those systems. In MySQL and PG, the result type a function or operator
+may only depend on the type of its arguments, never the value of its arguments.
+But the underlying JSON type depends on the value of the JSON path
+expression, not the type of the JSON path expression (which is always TEXT).
+Hence, the result type of ->> in MySQL and PG is unable to vary according
+to the type of the JSON value being extracted.
+
+The type system in SQLite is more general. Functions in SQLite are able
+to return different datatypes depending on the value of their arguments.
+So the ->> operator in SQLite is able to return TEXT, INTEGER, REAL, or NULL
+depending on the JSON type of the value being extracted. This means that
+the behavior of the ->> is slightly different in SQLite versus MySQL and PG
+in that it will sometimes return INTEGER and REAL values, depending on its
+inputs. It is possible to implement the ->> operator in SQLite so that it
+always operates exactly like MySQL and PG and always returns TEXT or NULL,
+but I have been unable to think of any situations where returning the
+actual JSON value this would cause problems, so I'm including the enhanced
+functionality in SQLite.
+
+The table below attempts to summarize the differences between the
+-> and ->> operators and the json_extract() function, for SQLite, MySQL,
+and PG. JSON values are shown using their SQL text representation but
+in a bold font.
+
+
+<table border=1 cellpadding=5 cellspacing=0>
+<tr><th>JSON<th>PATH<th>-&gt; operator<br>(all)<th>-&gt;&gt; operator<br>(MySQL/PG)
+ <th>-&gt;&gt; operator<br>(SQLite)<th>json_extract()<br>(SQLite)
+<tr><td> **'{"a":123}'** <td>'$.a'<td> **'123'** <td> '123' <td> 123 <td> 123
+<tr><td> **'{"a":4.5}'** <td>'$.a'<td> **'4.5'** <td> '4.5' <td> 4.5 <td> 4.5
+<tr><td> **'{"a":"xyz"}'** <td>'$.a'<td> **'"xyz"'** <td> 'xyz' <td> 'xyz' <td> 'xyz'
+<tr><td> **'{"a":null}'** <td>'$.a'<td> **'null'** <td> NULL <td> NULL <td> NULL
+<tr><td> **'{"a":[6,7,8]}'** <td>'$.a'<td> **'[6,7,8]'** <td> '[6,7,8]' <td> '[6,7,8]' <td> **'[6,7,8]'**
+<tr><td> **'{"a":{"x":9}}'** <td>'$.a'<td> **'{"x":9}'** <td> '{"x":9}' <td> '{"x":9}' <td> **'{"x":9}'**
+<tr><td> **'{"b":999}'** <td>'$.a'<td> NULL <td> NULL <td> NULL <td> NULL
+</table>
+
+Important points about the table above:
+
+ * The -> operator always returns either JSON or NULL.
+
+ * The ->> operator never returns JSON. It always returns TEXT or NULL, or in the
+ case of SQLite, INTEGER or REAL.
+
+ * The MySQL json_extract() function works exactly the same
+ as the MySQL -> operator.
+
+ * The SQLite json_extract() operator works like -> for JSON objects and
+ arrays, and like ->> for JSON values.
+
+ * The -> operator works the same for all systems.
+
+ * The only difference in ->> between SQLite and other systems is that
+ when the JSON value is numeric, SQLite returns a numeric SQL value,
+ whereas the other systems return a text representation of the numeric
+ value.
+
+### 2.1 Abbreviated JSON path expressions for PG compatibility
+
+The table above always shows the full JSON path expression: '$.a'. But
+PG does not accept this syntax. PG only allows a single JSON object label
+name or a single integer array index. In order to provide compatibility
+with PG, The -> and ->> operators in SQLite are extended to also support
+a JSON object label or an integer array index for the right-hand side
+operand, in addition to a full JSON path expression.
+
+Thus, a -> or ->> operator that works on MySQL will work in
+SQLite. And a -> or ->> operator that works in PG will work in SQLite.
+But because SQLite supports the union of the disjoint capabilities of
+MySQL and PG, there will always be -> and ->> operators that work in
+SQLite that do not work in one of MySQL and PG. This is an unavoidable
+consequence of the different syntax for -> and ->> in MySQL and PG.
+
+In the following table, assume that "value1" is a JSON object and
+"value2" is a JSON array.
+
+<table border=1 cellpadding=5 cellspacing=0>
+<tr><th>SQL expression <th>Works in MySQL?<th>Works in PG?<th>Works in SQLite
+<tr><td>value1-&gt;'$.a' <td> yes <td> no <td> yes
+<tr><td>value1-&gt;'a' <td> no <td> yes <td> yes
+<tr><td>value2-&gt;'$[2]' <td> yes <td> no <td> yes
+<tr><td>value2-&gt;2 <td> no <td> yes <td> yes
+</table>
+
+The abbreviated JSON path expressions only work for the -> and ->> operators
+in SQLite. The json_extract() function, and all other built-in SQLite
+JSON functions, continue to require complete JSON path expressions for their
+PATH arguments.
+
+## 3.0 JSON moved into the core
+
+The JSON interface is now moved into the SQLite core.
+
+When originally written in 2015, the JSON functions were an extension
+that could be optionally included at compile-time, or loaded at run-time.
+The implementation was in a source file named ext/misc/json1.c in the
+source tree. JSON functions were only compiled in if the
+-DSQLITE_ENABLE_JSON1 compile-time option was used.
+
+After these enhancements, the JSON functions are now built-ins.
+The source file that implements the JSON functions is moved to src/json.c.
+No special compile-time options are needed to load JSON into the build.
+Instead, there is a new -DSQLITE_OMIT_JSON compile-time option to leave
+them out.
diff --git a/chromium/third_party/sqlite/src/ext/expert/sqlite3expert.c b/chromium/third_party/sqlite/src/ext/expert/sqlite3expert.c
index a5eb109b46b..f29b8a9e0bf 100644
--- a/chromium/third_party/sqlite/src/ext/expert/sqlite3expert.c
+++ b/chromium/third_party/sqlite/src/ext/expert/sqlite3expert.c
@@ -697,17 +697,25 @@ static int idxGetTableInfo(
){
sqlite3_stmt *p1 = 0;
int nCol = 0;
- int nTab = STRLEN(zTab);
- int nByte = sizeof(IdxTable) + nTab + 1;
+ int nTab;
+ int nByte;
IdxTable *pNew = 0;
int rc, rc2;
char *pCsr = 0;
int nPk = 0;
+ *ppOut = 0;
+ if( zTab==0 ) return SQLITE_ERROR;
+ nTab = STRLEN(zTab);
+ nByte = sizeof(IdxTable) + nTab + 1;
rc = idxPrintfPrepareStmt(db, &p1, pzErrmsg, "PRAGMA table_xinfo=%Q", zTab);
while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(p1) ){
const char *zCol = (const char*)sqlite3_column_text(p1, 1);
const char *zColSeq = 0;
+ if( zCol==0 ){
+ rc = SQLITE_ERROR;
+ break;
+ }
nByte += 1 + STRLEN(zCol);
rc = sqlite3_table_column_metadata(
db, "main", zTab, zCol, 0, &zColSeq, 0, 0, 0
@@ -734,7 +742,9 @@ static int idxGetTableInfo(
while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(p1) ){
const char *zCol = (const char*)sqlite3_column_text(p1, 1);
const char *zColSeq = 0;
- int nCopy = STRLEN(zCol) + 1;
+ int nCopy;
+ if( zCol==0 ) continue;
+ nCopy = STRLEN(zCol) + 1;
pNew->aCol[nCol].zName = pCsr;
pNew->aCol[nCol].iPk = (sqlite3_column_int(p1, 5)==1 && nPk==1);
memcpy(pCsr, zCol, nCopy);
@@ -886,6 +896,7 @@ static int idxFindCompatible(
IdxConstraint *pT = pTail;
sqlite3_stmt *pInfo = 0;
const char *zIdx = (const char*)sqlite3_column_text(pIdxList, 1);
+ if( zIdx==0 ) continue;
/* Zero the IdxConstraint.bFlag values in the pEq list */
for(pIter=pEq; pIter; pIter=pIter->pLink) pIter->bFlag = 0;
@@ -1168,7 +1179,7 @@ static void idxWriteFree(IdxWrite *pTab){
** runs all the queries to see which indexes they prefer, and populates
** IdxStatement.zIdx and IdxStatement.zEQP with the results.
*/
-int idxFindIndexes(
+static int idxFindIndexes(
sqlite3expert *p,
char **pzErr /* OUT: Error message (sqlite3_malloc) */
){
@@ -1297,6 +1308,7 @@ static int idxProcessOneTrigger(
rc = idxPrintfPrepareStmt(p->db, &pSelect, pzErr, zSql, zTab, zTab);
while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pSelect) ){
const char *zCreate = (const char*)sqlite3_column_text(pSelect, 0);
+ if( zCreate==0 ) continue;
rc = sqlite3_exec(p->dbv, zCreate, 0, 0, pzErr);
}
idxFinalize(&rc, pSelect);
@@ -1399,8 +1411,9 @@ static int idxCreateVtabSchema(sqlite3expert *p, char **pzErrmsg){
const char *zName = (const char*)sqlite3_column_text(pSchema, 1);
const char *zSql = (const char*)sqlite3_column_text(pSchema, 2);
+ if( zType==0 || zName==0 ) continue;
if( zType[0]=='v' || zType[1]=='r' ){
- rc = sqlite3_exec(p->dbv, zSql, 0, 0, pzErrmsg);
+ if( zSql ) rc = sqlite3_exec(p->dbv, zSql, 0, 0, pzErrmsg);
}else{
IdxTable *pTab;
rc = idxGetTableInfo(p->db, zName, &pTab, pzErrmsg);
@@ -1537,6 +1550,7 @@ static void idxRemFunc(
case SQLITE_BLOB:
case SQLITE_TEXT: {
int nByte = sqlite3_value_bytes(argv[1]);
+ const void *pData = 0;
if( nByte>pSlot->nByte ){
char *zNew = (char*)sqlite3_realloc(pSlot->z, nByte*2);
if( zNew==0 ){
@@ -1548,9 +1562,11 @@ static void idxRemFunc(
}
pSlot->n = nByte;
if( pSlot->eType==SQLITE_BLOB ){
- memcpy(pSlot->z, sqlite3_value_blob(argv[1]), nByte);
+ pData = sqlite3_value_blob(argv[1]);
+ if( pData ) memcpy(pSlot->z, pData, nByte);
}else{
- memcpy(pSlot->z, sqlite3_value_text(argv[1]), nByte);
+ pData = sqlite3_value_text(argv[1]);
+ memcpy(pSlot->z, pData, nByte);
}
break;
}
@@ -1761,6 +1777,7 @@ static int idxPopulateStat1(sqlite3expert *p, char **pzErr){
i64 iRowid = sqlite3_column_int64(pAllIndex, 0);
const char *zTab = (const char*)sqlite3_column_text(pAllIndex, 1);
const char *zIdx = (const char*)sqlite3_column_text(pAllIndex, 2);
+ if( zTab==0 || zIdx==0 ) continue;
if( p->iSample<100 && iPrev!=iRowid ){
samplectx.target = (double)p->iSample / 100.0;
samplectx.iTarget = p->iSample;
@@ -1827,14 +1844,14 @@ sqlite3expert *sqlite3_expert_new(sqlite3 *db, char **pzErrmsg){
/* Copy the entire schema of database [db] into [dbm]. */
if( rc==SQLITE_OK ){
- sqlite3_stmt *pSql;
+ sqlite3_stmt *pSql = 0;
rc = idxPrintfPrepareStmt(pNew->db, &pSql, pzErrmsg,
"SELECT sql FROM sqlite_schema WHERE name NOT LIKE 'sqlite_%%'"
" AND sql NOT LIKE 'CREATE VIRTUAL %%'"
);
while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pSql) ){
const char *zSql = (const char*)sqlite3_column_text(pSql, 0);
- rc = sqlite3_exec(pNew->dbm, zSql, 0, 0, pzErrmsg);
+ if( zSql ) rc = sqlite3_exec(pNew->dbm, zSql, 0, 0, pzErrmsg);
}
idxFinalize(&rc, pSql);
}
diff --git a/chromium/third_party/sqlite/src/ext/fts3/fts3.c b/chromium/third_party/sqlite/src/ext/fts3/fts3.c
index 074123d6589..097338f5477 100644
--- a/chromium/third_party/sqlite/src/ext/fts3/fts3.c
+++ b/chromium/third_party/sqlite/src/ext/fts3/fts3.c
@@ -308,6 +308,12 @@
SQLITE_EXTENSION_INIT1
#endif
+typedef struct Fts3HashWrapper Fts3HashWrapper;
+struct Fts3HashWrapper {
+ Fts3Hash hash; /* Hash table */
+ int nRef; /* Number of pointers to this object */
+};
+
static int fts3EvalNext(Fts3Cursor *pCsr);
static int fts3EvalStart(Fts3Cursor *pCsr);
static int fts3TermSegReaderCursor(
@@ -1172,7 +1178,7 @@ static int fts3InitVtab(
sqlite3_vtab **ppVTab, /* Write the resulting vtab structure here */
char **pzErr /* Write any error message here */
){
- Fts3Hash *pHash = (Fts3Hash *)pAux;
+ Fts3Hash *pHash = &((Fts3HashWrapper*)pAux)->hash;
Fts3Table *p = 0; /* Pointer to allocated vtab */
int rc = SQLITE_OK; /* Return code */
int i; /* Iterator variable */
@@ -4007,9 +4013,12 @@ static const sqlite3_module fts3Module = {
** allocated for the tokenizer hash table.
*/
static void hashDestroy(void *p){
- Fts3Hash *pHash = (Fts3Hash *)p;
- sqlite3Fts3HashClear(pHash);
- sqlite3_free(pHash);
+ Fts3HashWrapper *pHash = (Fts3HashWrapper *)p;
+ pHash->nRef--;
+ if( pHash->nRef<=0 ){
+ sqlite3Fts3HashClear(&pHash->hash);
+ sqlite3_free(pHash);
+ }
}
/*
@@ -4039,7 +4048,7 @@ void sqlite3Fts3IcuTokenizerModule(sqlite3_tokenizer_module const**ppModule);
*/
int sqlite3Fts3Init(sqlite3 *db){
int rc = SQLITE_OK;
- Fts3Hash *pHash = 0;
+ Fts3HashWrapper *pHash = 0;
const sqlite3_tokenizer_module *pSimple = 0;
const sqlite3_tokenizer_module *pPorter = 0;
#ifndef SQLITE_DISABLE_FTS3_UNICODE
@@ -4067,23 +4076,24 @@ int sqlite3Fts3Init(sqlite3 *db){
sqlite3Fts3PorterTokenizerModule(&pPorter);
/* Allocate and initialize the hash-table used to store tokenizers. */
- pHash = sqlite3_malloc(sizeof(Fts3Hash));
+ pHash = sqlite3_malloc(sizeof(Fts3HashWrapper));
if( !pHash ){
rc = SQLITE_NOMEM;
}else{
- sqlite3Fts3HashInit(pHash, FTS3_HASH_STRING, 1);
+ sqlite3Fts3HashInit(&pHash->hash, FTS3_HASH_STRING, 1);
+ pHash->nRef = 0;
}
/* Load the built-in tokenizers into the hash table */
if( rc==SQLITE_OK ){
- if( sqlite3Fts3HashInsert(pHash, "simple", 7, (void *)pSimple)
- || sqlite3Fts3HashInsert(pHash, "porter", 7, (void *)pPorter)
+ if( sqlite3Fts3HashInsert(&pHash->hash, "simple", 7, (void *)pSimple)
+ || sqlite3Fts3HashInsert(&pHash->hash, "porter", 7, (void *)pPorter)
#ifndef SQLITE_DISABLE_FTS3_UNICODE
- || sqlite3Fts3HashInsert(pHash, "unicode61", 10, (void *)pUnicode)
+ || sqlite3Fts3HashInsert(&pHash->hash, "unicode61", 10, (void *)pUnicode)
#endif
#ifdef SQLITE_ENABLE_ICU
- || (pIcu && sqlite3Fts3HashInsert(pHash, "icu", 4, (void *)pIcu))
+ || (pIcu && sqlite3Fts3HashInsert(&pHash->hash, "icu", 4, (void *)pIcu))
#endif
){
rc = SQLITE_NOMEM;
@@ -4092,7 +4102,7 @@ int sqlite3Fts3Init(sqlite3 *db){
#ifdef SQLITE_TEST
if( rc==SQLITE_OK ){
- rc = sqlite3Fts3ExprInitTestInterface(db, pHash);
+ rc = sqlite3Fts3ExprInitTestInterface(db, &pHash->hash);
}
#endif
@@ -4101,23 +4111,26 @@ int sqlite3Fts3Init(sqlite3 *db){
** module with sqlite.
*/
if( SQLITE_OK==rc
- && SQLITE_OK==(rc = sqlite3Fts3InitHashTable(db, pHash, "fts3_tokenizer"))
+ && SQLITE_OK==(rc=sqlite3Fts3InitHashTable(db,&pHash->hash,"fts3_tokenizer"))
&& 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))
&& SQLITE_OK==(rc = sqlite3_overload_function(db, "matchinfo", 2))
&& SQLITE_OK==(rc = sqlite3_overload_function(db, "optimize", 1))
){
+ pHash->nRef++;
rc = sqlite3_create_module_v2(
db, "fts3", &fts3Module, (void *)pHash, hashDestroy
);
if( rc==SQLITE_OK ){
+ pHash->nRef++;
rc = sqlite3_create_module_v2(
- db, "fts4", &fts3Module, (void *)pHash, 0
+ db, "fts4", &fts3Module, (void *)pHash, hashDestroy
);
}
if( rc==SQLITE_OK ){
- rc = sqlite3Fts3InitTok(db, (void *)pHash);
+ pHash->nRef++;
+ rc = sqlite3Fts3InitTok(db, (void *)pHash, hashDestroy);
}
return rc;
}
@@ -4126,7 +4139,7 @@ int sqlite3Fts3Init(sqlite3 *db){
/* An error has occurred. Delete the hash table and return the error code. */
assert( rc!=SQLITE_OK );
if( pHash ){
- sqlite3Fts3HashClear(pHash);
+ sqlite3Fts3HashClear(&pHash->hash);
sqlite3_free(pHash);
}
return rc;
diff --git a/chromium/third_party/sqlite/src/ext/fts3/fts3Int.h b/chromium/third_party/sqlite/src/ext/fts3/fts3Int.h
index 3a62ccc7a7d..0626486edff 100644
--- a/chromium/third_party/sqlite/src/ext/fts3/fts3Int.h
+++ b/chromium/third_party/sqlite/src/ext/fts3/fts3Int.h
@@ -641,7 +641,7 @@ int sqlite3Fts3MsrOvfl(Fts3Cursor *, Fts3MultiSegReader *, int *);
int sqlite3Fts3MsrIncrRestart(Fts3MultiSegReader *pCsr);
/* fts3_tokenize_vtab.c */
-int sqlite3Fts3InitTok(sqlite3*, Fts3Hash *);
+int sqlite3Fts3InitTok(sqlite3*, Fts3Hash *, void(*xDestroy)(void*));
/* fts3_unicode2.c (functions generated by parsing unicode text files) */
#ifndef SQLITE_DISABLE_FTS3_UNICODE
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 8bd22230cc9..65d7eef4c33 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
@@ -420,7 +420,7 @@ static int fts3tokRowidMethod(
** Register the fts3tok module with database connection db. Return SQLITE_OK
** if successful or an error code if sqlite3_create_module() fails.
*/
-int sqlite3Fts3InitTok(sqlite3 *db, Fts3Hash *pHash){
+int sqlite3Fts3InitTok(sqlite3 *db, Fts3Hash *pHash, void(*xDestroy)(void*)){
static const sqlite3_module fts3tok_module = {
0, /* iVersion */
fts3tokConnectMethod, /* xCreate */
@@ -449,7 +449,9 @@ int sqlite3Fts3InitTok(sqlite3 *db, Fts3Hash *pHash){
};
int rc; /* Return code */
- rc = sqlite3_create_module(db, "fts3tokenize", &fts3tok_module, (void*)pHash);
+ rc = sqlite3_create_module_v2(
+ db, "fts3tokenize", &fts3tok_module, (void*)pHash, xDestroy
+ );
return rc;
}
diff --git a/chromium/third_party/sqlite/src/ext/fts3/mkfts3amal.tcl b/chromium/third_party/sqlite/src/ext/fts3/mkfts3amal.tcl
deleted file mode 100644
index 059048717f9..00000000000
--- a/chromium/third_party/sqlite/src/ext/fts3/mkfts3amal.tcl
+++ /dev/null
@@ -1,115 +0,0 @@
-#!/usr/bin/tclsh
-#
-# This script builds a single C code file holding all of FTS3 code.
-# The name of the output file is fts3amal.c. To build this file,
-# first do:
-#
-# make target_source
-#
-# The make target above moves all of the source code files into
-# a subdirectory named "tsrc". (This script expects to find the files
-# there and will not work if they are not found.)
-#
-# After the "tsrc" directory has been created and populated, run
-# this script:
-#
-# tclsh mkfts3amal.tcl
-#
-# The amalgamated FTS3 code will be written into fts3amal.c
-#
-
-# Open the output file and write a header comment at the beginning
-# of the file.
-#
-set out [open fts3amal.c w]
-set today [clock format [clock seconds] -format "%Y-%m-%d %H:%M:%S UTC" -gmt 1]
-puts $out [subst \
-{/******************************************************************************
-** This file is an amalgamation of separate C source files from the SQLite
-** Full Text Search extension 2 (fts3). By combining all the individual C
-** code files into this single large file, the entire code can be compiled
-** as a one translation unit. This allows many compilers to do optimizations
-** that would not be possible if the files were compiled separately. It also
-** makes the code easier to import into other projects.
-**
-** This amalgamation was generated on $today.
-*/}]
-
-# These are the header files used by FTS3. The first time any of these
-# files are seen in a #include statement in the C code, include the complete
-# text of the file in-line. The file only needs to be included once.
-#
-foreach hdr {
- fts3.h
- fts3_hash.h
- fts3_tokenizer.h
- sqlite3.h
- sqlite3ext.h
-} {
- set available_hdr($hdr) 1
-}
-
-# 78 stars used for comment formatting.
-set s78 \
-{*****************************************************************************}
-
-# Insert a comment into the code
-#
-proc section_comment {text} {
- global out s78
- set n [string length $text]
- set nstar [expr {60 - $n}]
- set stars [string range $s78 0 $nstar]
- puts $out "/************** $text $stars/"
-}
-
-# Read the source file named $filename and write it into the
-# sqlite3.c output file. If any #include statements are seen,
-# process them approprately.
-#
-proc copy_file {filename} {
- global seen_hdr available_hdr out
- set tail [file tail $filename]
- section_comment "Begin file $tail"
- set in [open $filename r]
- while {![eof $in]} {
- set line [gets $in]
- if {[regexp {^#\s*include\s+["<]([^">]+)[">]} $line all hdr]} {
- if {[info exists available_hdr($hdr)]} {
- if {$available_hdr($hdr)} {
- section_comment "Include $hdr in the middle of $tail"
- copy_file tsrc/$hdr
- section_comment "Continuing where we left off in $tail"
- }
- } elseif {![info exists seen_hdr($hdr)]} {
- set seen_hdr($hdr) 1
- puts $out $line
- }
- } elseif {[regexp {^#ifdef __cplusplus} $line]} {
- puts $out "#if 0"
- } elseif {[regexp {^#line} $line]} {
- # Skip #line directives.
- } else {
- puts $out $line
- }
- }
- close $in
- section_comment "End of $tail"
-}
-
-
-# Process the source files. Process files containing commonly
-# used subroutines first in order to help the compiler find
-# inlining opportunities.
-#
-foreach file {
- fts3.c
- fts3_hash.c
- fts3_porter.c
- fts3_tokenizer.c
- fts3_tokenizer1.c
-} {
- copy_file tsrc/$file
-}
-
-close $out
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 fe253984b3f..6b88f31c023 100644
--- a/chromium/third_party/sqlite/src/ext/fts5/fts5_index.c
+++ b/chromium/third_party/sqlite/src/ext/fts5/fts5_index.c
@@ -5565,7 +5565,7 @@ int sqlite3Fts5IndexQuery(
if( sqlite3Fts5BufferSize(&p->rc, &buf, nToken+1)==0 ){
int iIdx = 0; /* Index to search */
int iPrefixIdx = 0; /* +1 prefix index */
- if( nToken ) memcpy(&buf.p[1], pToken, nToken);
+ if( nToken>0 ) memcpy(&buf.p[1], pToken, nToken);
/* Figure out which index to search and set iIdx accordingly. If this
** is a prefix query for which there is no prefix index, set iIdx to
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 fd3a9066b7f..9a8b2fadb45 100644
--- a/chromium/third_party/sqlite/src/ext/fts5/fts5_main.c
+++ b/chromium/third_party/sqlite/src/ext/fts5/fts5_main.c
@@ -804,7 +804,7 @@ static int fts5SorterNext(Fts5Cursor *pCsr){
rc = sqlite3_step(pSorter->pStmt);
if( rc==SQLITE_DONE ){
rc = SQLITE_OK;
- CsrFlagSet(pCsr, FTS5CSR_EOF);
+ CsrFlagSet(pCsr, FTS5CSR_EOF|FTS5CSR_REQUIRE_CONTENT);
}else if( rc==SQLITE_ROW ){
const u8 *a;
const u8 *aBlob;
diff --git a/chromium/third_party/sqlite/src/ext/lsm1/lsm_vtab.c b/chromium/third_party/sqlite/src/ext/lsm1/lsm_vtab.c
index f96a6bbd71c..bb1460297d3 100644
--- a/chromium/third_party/sqlite/src/ext/lsm1/lsm_vtab.c
+++ b/chromium/third_party/sqlite/src/ext/lsm1/lsm_vtab.c
@@ -26,7 +26,7 @@
**
** The virtual table contains read-only hidden columns:
**
-** lsm1_key A BLOB which is the raw LSM key. If the "keytype"
+** lsm1_key A BLOB which is the raw LSM key. If the "keytype"
** is BLOB or TEXT then this column is exactly the
** same as the key. For the UINT keytype, this column
** will be a variable-length integer encoding of the key.
diff --git a/chromium/third_party/sqlite/src/ext/misc/csv.c b/chromium/third_party/sqlite/src/ext/misc/csv.c
index d08ddd6b3a1..b51fbad30e6 100644
--- a/chromium/third_party/sqlite/src/ext/misc/csv.c
+++ b/chromium/third_party/sqlite/src/ext/misc/csv.c
@@ -941,7 +941,7 @@ int sqlite3_csv_init(
char **pzErrMsg,
const sqlite3_api_routines *pApi
){
-#ifndef SQLITE_OMIT_VIRTUALTABLE
+#ifndef SQLITE_OMIT_VIRTUALTABLE
int rc;
SQLITE_EXTENSION_INIT2(pApi);
rc = sqlite3_create_module(db, "csv", &CsvModule, 0);
diff --git a/chromium/third_party/sqlite/src/ext/misc/fileio.c b/chromium/third_party/sqlite/src/ext/misc/fileio.c
index c9988f60782..7cdbd5968f5 100644
--- a/chromium/third_party/sqlite/src/ext/misc/fileio.c
+++ b/chromium/third_party/sqlite/src/ext/misc/fileio.c
@@ -368,10 +368,11 @@ static int writeFile(
mode_t mode, /* MODE parameter passed to writefile() */
sqlite3_int64 mtime /* MTIME parameter (or -1 to not set time) */
){
+ if( zFile==0 ) return 1;
#if !defined(_WIN32) && !defined(WIN32)
if( S_ISLNK(mode) ){
const char *zTo = (const char*)sqlite3_value_text(pData);
- if( symlink(zTo, zFile)<0 ) return 1;
+ if( zTo==0 || symlink(zTo, zFile)<0 ) return 1;
}else
#endif
{
diff --git a/chromium/third_party/sqlite/src/ext/misc/ieee754.c b/chromium/third_party/sqlite/src/ext/misc/ieee754.c
index 66d946f3d58..ff5d2d333c0 100644
--- a/chromium/third_party/sqlite/src/ext/misc/ieee754.c
+++ b/chromium/third_party/sqlite/src/ext/misc/ieee754.c
@@ -284,7 +284,7 @@ int sqlite3_ieee_init(
SQLITE_EXTENSION_INIT2(pApi);
(void)pzErrMsg; /* Unused parameter */
for(i=0; i<sizeof(aFunc)/sizeof(aFunc[0]) && rc==SQLITE_OK; i++){
- rc = sqlite3_create_function(db, aFunc[i].zFName, aFunc[i].nArg,
+ rc = sqlite3_create_function(db, aFunc[i].zFName, aFunc[i].nArg,
SQLITE_UTF8|SQLITE_INNOCUOUS,
(void*)&aFunc[i].iAux,
aFunc[i].xFunc, 0, 0);
diff --git a/chromium/third_party/sqlite/src/ext/misc/qpvtab.c b/chromium/third_party/sqlite/src/ext/misc/qpvtab.c
new file mode 100644
index 00000000000..fb0c155a27c
--- /dev/null
+++ b/chromium/third_party/sqlite/src/ext/misc/qpvtab.c
@@ -0,0 +1,461 @@
+/*
+** 2022-01-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 virtual-table that returns information about
+** how the query planner called the xBestIndex method. This virtual table
+** is intended for testing and debugging only.
+**
+** The schema of the virtual table is this:
+**
+** CREATE TABLE qpvtab(
+** vn TEXT, -- Name of an sqlite3_index_info field
+** ix INTEGER, -- Array index or value
+** cn TEXT, -- Column name
+** op INTEGER, -- operator
+** ux BOOLEAN, -- "usable" field
+** rhs TEXT, -- sqlite3_vtab_rhs_value()
+**
+** a, b, c, d, e, -- Extra columns to attach constraints to
+**
+** flags INTEGER HIDDEN -- control flags
+** );
+**
+** The virtual table returns a description of the sqlite3_index_info object
+** that was provided to the (successful) xBestIndex method. There is one
+** row in the result table for each field in the sqlite3_index_info object.
+**
+** The values of the "a" through "e" columns are one of:
+**
+** 1. TEXT - the same as the column name
+** 2. INTEGER - 1 for "a", 2 for "b", and so forth
+**
+** Option 1 is the default behavior. 2 is use if there is a usable
+** constraint on "flags" with an integer right-hand side that where the
+** value of the right-hand side has its 0x001 bit set.
+**
+** All constraints on columns "a" through "e" are marked as "omit".
+**
+** If there is a usable constraint on "flags" that has a RHS value that
+** is an integer and that integer has its 0x02 bit set, then the
+** orderByConsumed flag is set.
+**
+** FLAGS SUMMARY:
+**
+** 0x001 Columns 'a' through 'e' have INT values
+** 0x002 orderByConsumed is set
+** 0x004 OFFSET and LIMIT have omit set
+**
+** COMPILE:
+**
+** gcc -Wall -g -shared -fPIC -I. qpvtab.c -o qqvtab.so
+**
+** EXAMPLE USAGE:
+**
+** .load ./qpvtab
+** SELECT rowid, *, flags FROM qpvtab(102)
+** WHERE a=19
+** AND b BETWEEN 4.5 and 'hello'
+** AND c<>x'aabbcc'
+** ORDER BY d, e DESC;
+*/
+#if !defined(SQLITEINT_H)
+#include "sqlite3ext.h"
+#endif
+SQLITE_EXTENSION_INIT1
+#include <string.h>
+#include <assert.h>
+#include <stdlib.h>
+
+#if !defined(SQLITE_OMIT_VIRTUALTABLE)
+
+/* qpvtab_vtab is a subclass of sqlite3_vtab which is
+** underlying representation of the virtual table
+*/
+typedef struct qpvtab_vtab qpvtab_vtab;
+struct qpvtab_vtab {
+ sqlite3_vtab base; /* Base class - must be first */
+};
+
+/* qpvtab_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 qpvtab_cursor qpvtab_cursor;
+struct qpvtab_cursor {
+ sqlite3_vtab_cursor base; /* Base class - must be first */
+ sqlite3_int64 iRowid; /* The rowid */
+ const char *zData; /* Data to return */
+ int nData; /* Number of bytes of data */
+ int flags; /* Flags value */
+};
+
+/*
+** Names of columns
+*/
+static const char *azColname[] = {
+ "vn",
+ "ix",
+ "cn",
+ "op",
+ "ux",
+ "rhs",
+ "a", "b", "c", "d", "e",
+ "flags",
+ ""
+};
+
+/*
+** The qpvtabConnect() method is invoked to create a new
+** qpvtab virtual table.
+*/
+static int qpvtabConnect(
+ sqlite3 *db,
+ void *pAux,
+ int argc, const char *const*argv,
+ sqlite3_vtab **ppVtab,
+ char **pzErr
+){
+ qpvtab_vtab *pNew;
+ int rc;
+
+ rc = sqlite3_declare_vtab(db,
+ "CREATE TABLE x("
+ " vn TEXT,"
+ " ix INT,"
+ " cn TEXT,"
+ " op INT,"
+ " ux BOOLEAN,"
+ " rhs TEXT,"
+ " a, b, c, d, e,"
+ " flags INT HIDDEN)"
+ );
+#define QPVTAB_VN 0
+#define QPVTAB_IX 1
+#define QPVTAB_CN 2
+#define QPVTAB_OP 3
+#define QPVTAB_UX 4
+#define QPVTAB_RHS 5
+#define QPVTAB_A 6
+#define QPVTAB_B 7
+#define QPVTAB_C 8
+#define QPVTAB_D 9
+#define QPVTAB_E 10
+#define QPVTAB_FLAGS 11
+#define QPVTAB_NONE 12
+ 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 qpvtab_vtab objects.
+*/
+static int qpvtabDisconnect(sqlite3_vtab *pVtab){
+ qpvtab_vtab *p = (qpvtab_vtab*)pVtab;
+ sqlite3_free(p);
+ return SQLITE_OK;
+}
+
+/*
+** Constructor for a new qpvtab_cursor object.
+*/
+static int qpvtabOpen(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor){
+ qpvtab_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 qpvtab_cursor.
+*/
+static int qpvtabClose(sqlite3_vtab_cursor *cur){
+ qpvtab_cursor *pCur = (qpvtab_cursor*)cur;
+ sqlite3_free(pCur);
+ return SQLITE_OK;
+}
+
+
+/*
+** Advance a qpvtab_cursor to its next row of output.
+*/
+static int qpvtabNext(sqlite3_vtab_cursor *cur){
+ qpvtab_cursor *pCur = (qpvtab_cursor*)cur;
+ if( pCur->iRowid<pCur->nData ){
+ const char *z = &pCur->zData[pCur->iRowid];
+ const char *zEnd = strchr(z, '\n');
+ if( zEnd ) zEnd++;
+ pCur->iRowid = (int)(zEnd - pCur->zData);
+ }
+ return SQLITE_OK;
+}
+
+/*
+** Return values of columns for the row at which the qpvtab_cursor
+** is currently pointing.
+*/
+static int qpvtabColumn(
+ sqlite3_vtab_cursor *cur, /* The cursor */
+ sqlite3_context *ctx, /* First argument to sqlite3_result_...() */
+ int i /* Which column to return */
+){
+ qpvtab_cursor *pCur = (qpvtab_cursor*)cur;
+ if( i>=QPVTAB_VN && i<=QPVTAB_RHS && pCur->iRowid<pCur->nData ){
+ const char *z = &pCur->zData[pCur->iRowid];
+ const char *zEnd;
+ int j;
+ j = QPVTAB_VN;
+ while(1){
+ zEnd = strchr(z, j==QPVTAB_RHS ? '\n' : ',');
+ if( j==i || zEnd==0 ) break;
+ z = zEnd+1;
+ j++;
+ }
+ if( zEnd==z ){
+ sqlite3_result_null(ctx);
+ }else if( i==QPVTAB_IX || i==QPVTAB_OP || i==QPVTAB_UX ){
+ sqlite3_result_int(ctx, atoi(z));
+ }else{
+ sqlite3_result_text64(ctx, z, zEnd-z, SQLITE_TRANSIENT, SQLITE_UTF8);
+ }
+ }else if( i>=QPVTAB_A && i<=QPVTAB_E ){
+ if( pCur->flags & 0x001 ){
+ sqlite3_result_int(ctx, i-QPVTAB_A+1);
+ }else{
+ char x = 'a'+i-QPVTAB_A;
+ sqlite3_result_text64(ctx, &x, 1, SQLITE_TRANSIENT, SQLITE_UTF8);
+ }
+ }else if( i==QPVTAB_FLAGS ){
+ sqlite3_result_int(ctx, pCur->flags);
+ }
+ return SQLITE_OK;
+}
+
+/*
+** Return the rowid for the current row. In this implementation, the
+** rowid is the same as the output value.
+*/
+static int qpvtabRowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){
+ qpvtab_cursor *pCur = (qpvtab_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 qpvtabEof(sqlite3_vtab_cursor *cur){
+ qpvtab_cursor *pCur = (qpvtab_cursor*)cur;
+ return pCur->iRowid>=pCur->nData;
+}
+
+/*
+** This method is called to "rewind" the qpvtab_cursor object back
+** to the first row of output. This method is always called at least
+** once prior to any call to qpvtabColumn() or qpvtabRowid() or
+** qpvtabEof().
+*/
+static int qpvtabFilter(
+ sqlite3_vtab_cursor *pVtabCursor,
+ int idxNum, const char *idxStr,
+ int argc, sqlite3_value **argv
+){
+ qpvtab_cursor *pCur = (qpvtab_cursor *)pVtabCursor;
+ pCur->iRowid = 0;
+ pCur->zData = idxStr;
+ pCur->nData = (int)strlen(idxStr);
+ pCur->flags = idxNum;
+ return SQLITE_OK;
+}
+
+/*
+** Append the text of a value to pStr
+*/
+static void qpvtabStrAppendValue(
+ sqlite3_str *pStr,
+ sqlite3_value *pVal
+){
+ switch( sqlite3_value_type(pVal) ){
+ case SQLITE_NULL:
+ sqlite3_str_appendf(pStr, "NULL");
+ break;
+ case SQLITE_INTEGER:
+ sqlite3_str_appendf(pStr, "%lld", sqlite3_value_int64(pVal));
+ break;
+ case SQLITE_FLOAT:
+ sqlite3_str_appendf(pStr, "%!f", sqlite3_value_double(pVal));
+ break;
+ case SQLITE_TEXT: {
+ int i;
+ const char *a = (const char*)sqlite3_value_text(pVal);
+ int n = sqlite3_value_bytes(pVal);
+ sqlite3_str_append(pStr, "'", 1);
+ for(i=0; i<n; i++){
+ char c = a[i];
+ if( c=='\n' ) c = ' ';
+ sqlite3_str_append(pStr, &c, 1);
+ if( c=='\'' ) sqlite3_str_append(pStr, &c, 1);
+ }
+ sqlite3_str_append(pStr, "'", 1);
+ break;
+ }
+ case SQLITE_BLOB: {
+ int i;
+ const unsigned char *a = sqlite3_value_blob(pVal);
+ int n = sqlite3_value_bytes(pVal);
+ sqlite3_str_append(pStr, "x'", 2);
+ for(i=0; i<n; i++){
+ sqlite3_str_appendf(pStr, "%02x", a[i]);
+ }
+ sqlite3_str_append(pStr, "'", 1);
+ break;
+ }
+ }
+}
+
+/*
+** 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 qpvtabBestIndex(
+ sqlite3_vtab *tab,
+ sqlite3_index_info *pIdxInfo
+){
+ sqlite3_str *pStr = sqlite3_str_new(0);
+ int i, k = 0;
+ int rc;
+ sqlite3_str_appendf(pStr, "nConstraint,%d,,,,\n", pIdxInfo->nConstraint);
+ for(i=0; i<pIdxInfo->nConstraint; i++){
+ sqlite3_value *pVal;
+ int iCol = pIdxInfo->aConstraint[i].iColumn;
+ int op = pIdxInfo->aConstraint[i].op;
+ if( iCol==QPVTAB_FLAGS && pIdxInfo->aConstraint[i].usable ){
+ pVal = 0;
+ rc = sqlite3_vtab_rhs_value(pIdxInfo, i, &pVal);
+ assert( rc==SQLITE_OK || pVal==0 );
+ if( pVal ){
+ pIdxInfo->idxNum = sqlite3_value_int(pVal);
+ if( pIdxInfo->idxNum & 0x002 ) pIdxInfo->orderByConsumed = 1;
+ }
+ }
+ if( op==SQLITE_INDEX_CONSTRAINT_LIMIT
+ || op==SQLITE_INDEX_CONSTRAINT_OFFSET
+ ){
+ iCol = QPVTAB_NONE;
+ }
+ sqlite3_str_appendf(pStr,"aConstraint,%d,%s,%d,%d,",
+ i,
+ azColname[iCol],
+ op,
+ pIdxInfo->aConstraint[i].usable);
+ pVal = 0;
+ rc = sqlite3_vtab_rhs_value(pIdxInfo, i, &pVal);
+ assert( rc==SQLITE_OK || pVal==0 );
+ if( pVal ){
+ qpvtabStrAppendValue(pStr, pVal);
+ }
+ sqlite3_str_append(pStr, "\n", 1);
+ }
+ for(i=0; i<pIdxInfo->nConstraint; i++){
+ int iCol = pIdxInfo->aConstraint[i].iColumn;
+ int op = pIdxInfo->aConstraint[i].op;
+ if( op==SQLITE_INDEX_CONSTRAINT_LIMIT
+ || op==SQLITE_INDEX_CONSTRAINT_OFFSET
+ ){
+ iCol = QPVTAB_NONE;
+ }
+ if( iCol>=QPVTAB_A && pIdxInfo->aConstraint[i].usable ){
+ pIdxInfo->aConstraintUsage[i].argvIndex = ++k;
+ if( iCol<=QPVTAB_FLAGS || (pIdxInfo->idxNum & 0x004)!=0 ){
+ pIdxInfo->aConstraintUsage[i].omit = 1;
+ }
+ }
+ }
+ sqlite3_str_appendf(pStr, "nOrderBy,%d,,,,\n", pIdxInfo->nOrderBy);
+ for(i=0; i<pIdxInfo->nOrderBy; i++){
+ int iCol = pIdxInfo->aOrderBy[i].iColumn;
+ sqlite3_str_appendf(pStr, "aOrderBy,%d,%s,%d,,\n",i,
+ iCol>=0 ? azColname[iCol] : "rowid",
+ pIdxInfo->aOrderBy[i].desc
+ );
+ }
+ sqlite3_str_appendf(pStr, "sqlite3_vtab_distinct,%d,,,,\n",
+ sqlite3_vtab_distinct(pIdxInfo));
+ sqlite3_str_appendf(pStr, "idxFlags,%d,,,,\n", pIdxInfo->idxFlags);
+ sqlite3_str_appendf(pStr, "colUsed,%d,,,,\n", (int)pIdxInfo->colUsed);
+ pIdxInfo->estimatedCost = (double)10;
+ pIdxInfo->estimatedRows = 10;
+ sqlite3_str_appendf(pStr, "idxNum,%d,,,,\n", pIdxInfo->idxNum);
+ sqlite3_str_appendf(pStr, "orderByConsumed,%d,,,,\n",
+ pIdxInfo->orderByConsumed);
+ pIdxInfo->idxStr = sqlite3_str_finish(pStr);
+ pIdxInfo->needToFreeIdxStr = 1;
+ return SQLITE_OK;
+}
+
+/*
+** This following structure defines all the methods for the
+** virtual table.
+*/
+static sqlite3_module qpvtabModule = {
+ /* iVersion */ 0,
+ /* xCreate */ 0,
+ /* xConnect */ qpvtabConnect,
+ /* xBestIndex */ qpvtabBestIndex,
+ /* xDisconnect */ qpvtabDisconnect,
+ /* xDestroy */ 0,
+ /* xOpen */ qpvtabOpen,
+ /* xClose */ qpvtabClose,
+ /* xFilter */ qpvtabFilter,
+ /* xNext */ qpvtabNext,
+ /* xEof */ qpvtabEof,
+ /* xColumn */ qpvtabColumn,
+ /* xRowid */ qpvtabRowid,
+ /* xUpdate */ 0,
+ /* xBegin */ 0,
+ /* xSync */ 0,
+ /* xCommit */ 0,
+ /* xRollback */ 0,
+ /* xFindMethod */ 0,
+ /* xRename */ 0,
+ /* xSavepoint */ 0,
+ /* xRelease */ 0,
+ /* xRollbackTo */ 0,
+ /* xShadowName */ 0
+};
+#endif /* SQLITE_OMIT_VIRTUALTABLE */
+
+
+#ifdef _WIN32
+__declspec(dllexport)
+#endif
+int sqlite3_qpvtab_init(
+ sqlite3 *db,
+ char **pzErrMsg,
+ const sqlite3_api_routines *pApi
+){
+ int rc = SQLITE_OK;
+ SQLITE_EXTENSION_INIT2(pApi);
+#ifndef SQLITE_OMIT_VIRTUALTABLE
+ rc = sqlite3_create_module(db, "qpvtab", &qpvtabModule, 0);
+#endif
+ return rc;
+}
diff --git a/chromium/third_party/sqlite/src/ext/misc/regexp.c b/chromium/third_party/sqlite/src/ext/misc/regexp.c
index f282e777f0b..b626ca424ad 100644
--- a/chromium/third_party/sqlite/src/ext/misc/regexp.c
+++ b/chromium/third_party/sqlite/src/ext/misc/regexp.c
@@ -759,13 +759,15 @@ int sqlite3_regexp_init(
int rc = SQLITE_OK;
SQLITE_EXTENSION_INIT2(pApi);
(void)pzErrMsg; /* Unused */
- rc = sqlite3_create_function(db, "regexp", 2, SQLITE_UTF8|SQLITE_INNOCUOUS,
- 0, re_sql_func, 0, 0);
+ rc = sqlite3_create_function(db, "regexp", 2,
+ SQLITE_UTF8|SQLITE_INNOCUOUS|SQLITE_DETERMINISTIC,
+ 0, re_sql_func, 0, 0);
if( rc==SQLITE_OK ){
/* The regexpi(PATTERN,STRING) function is a case-insensitive version
** of regexp(PATTERN,STRING). */
- rc = sqlite3_create_function(db, "regexpi", 2, SQLITE_UTF8|SQLITE_INNOCUOUS,
- (void*)db, re_sql_func, 0, 0);
+ rc = sqlite3_create_function(db, "regexpi", 2,
+ SQLITE_UTF8|SQLITE_INNOCUOUS|SQLITE_DETERMINISTIC,
+ (void*)db, re_sql_func, 0, 0);
}
return rc;
}
diff --git a/chromium/third_party/sqlite/src/ext/misc/series.c b/chromium/third_party/sqlite/src/ext/misc/series.c
index e8d8c10aeca..3941d96c476 100644
--- a/chromium/third_party/sqlite/src/ext/misc/series.c
+++ b/chromium/third_party/sqlite/src/ext/misc/series.c
@@ -386,7 +386,7 @@ static int seriesBestIndex(
** the preferred case */
pIdxInfo->estimatedCost = (double)(2 - ((idxNum&4)!=0));
pIdxInfo->estimatedRows = 1000;
- if( pIdxInfo->nOrderBy==1 ){
+ if( pIdxInfo->nOrderBy>=1 && pIdxInfo->aOrderBy[0].iColumn==0 ){
if( pIdxInfo->aOrderBy[0].desc ){
idxNum |= 8;
}else{
diff --git a/chromium/third_party/sqlite/src/ext/misc/sha1.c b/chromium/third_party/sqlite/src/ext/misc/sha1.c
index 9fe6cae740f..9790a1d8775 100644
--- a/chromium/third_party/sqlite/src/ext/misc/sha1.c
+++ b/chromium/third_party/sqlite/src/ext/misc/sha1.c
@@ -71,7 +71,7 @@ struct SHA1Context {
/*
* Hash a single 512-bit block. This is the core of the algorithm.
*/
-void SHA1Transform(unsigned int state[5], const unsigned char buffer[64]){
+static void SHA1Transform(unsigned int state[5], const unsigned char buffer[64]){
unsigned int qq[5]; /* a, b, c, d, e; */
static int one = 1;
unsigned int block[16];
diff --git a/chromium/third_party/sqlite/src/ext/misc/shathree.c b/chromium/third_party/sqlite/src/ext/misc/shathree.c
index ef25cb56c6d..1f100986ea4 100644
--- a/chromium/third_party/sqlite/src/ext/misc/shathree.c
+++ b/chromium/third_party/sqlite/src/ext/misc/shathree.c
@@ -436,6 +436,7 @@ static void SHA3Update(
unsigned int nData
){
unsigned int i = 0;
+ if( aData==0 ) return;
#if SHA3_BYTEORDER==1234
if( (p->nLoaded % 8)==0 && ((aData - (const unsigned char*)0)&7)==0 ){
for(; i+7<nData; i+=8){
diff --git a/chromium/third_party/sqlite/src/ext/misc/zipfile.c b/chromium/third_party/sqlite/src/ext/misc/zipfile.c
index b7ceb9396d7..db2aa78cc74 100644
--- a/chromium/third_party/sqlite/src/ext/misc/zipfile.c
+++ b/chromium/third_party/sqlite/src/ext/misc/zipfile.c
@@ -1938,7 +1938,7 @@ static int zipfileBufferGrow(ZipfileBuffer *pBuf, int nByte){
** SELECT zipfile(name,mode,mtime,data) ...
** SELECT zipfile(name,mode,mtime,data,method) ...
*/
-void zipfileStep(sqlite3_context *pCtx, int nVal, sqlite3_value **apVal){
+static void zipfileStep(sqlite3_context *pCtx, int nVal, sqlite3_value **apVal){
ZipfileCtx *p; /* Aggregate function context */
ZipfileEntry e; /* New entry to add to zip archive */
@@ -2113,7 +2113,7 @@ void zipfileStep(sqlite3_context *pCtx, int nVal, sqlite3_value **apVal){
/*
** xFinalize() callback for zipfile aggregate function.
*/
-void zipfileFinal(sqlite3_context *pCtx){
+static void zipfileFinal(sqlite3_context *pCtx){
ZipfileCtx *p;
ZipfileEOCD eocd;
sqlite3_int64 nZip;
diff --git a/chromium/third_party/sqlite/src/ext/rbu/sqlite3rbu.c b/chromium/third_party/sqlite/src/ext/rbu/sqlite3rbu.c
index 202712cca25..27a3720daa0 100644
--- a/chromium/third_party/sqlite/src/ext/rbu/sqlite3rbu.c
+++ b/chromium/third_party/sqlite/src/ext/rbu/sqlite3rbu.c
@@ -1563,7 +1563,7 @@ static char *rbuVacuumTableStart(
** the caller has to use an OFFSET clause to extract only the required
** rows from the sourct table, just as it does for an RBU update operation.
*/
-char *rbuVacuumIndexStart(
+static char *rbuVacuumIndexStart(
sqlite3rbu *p, /* RBU handle */
RbuObjIter *pIter /* RBU iterator object */
){
diff --git a/chromium/third_party/sqlite/src/ext/repair/sqlite3_checker.c.in b/chromium/third_party/sqlite/src/ext/repair/sqlite3_checker.c.in
index 76e9708787d..96b15f27136 100644
--- a/chromium/third_party/sqlite/src/ext/repair/sqlite3_checker.c.in
+++ b/chromium/third_party/sqlite/src/ext/repair/sqlite3_checker.c.in
@@ -4,7 +4,6 @@
*/
#define TCLSH_INIT_PROC sqlite3_checker_init_proc
#define SQLITE_ENABLE_DBPAGE_VTAB 1
-#define SQLITE_ENABLE_JSON1 1
#undef SQLITE_THREADSAFE
#define SQLITE_THREADSAFE 0
#undef SQLITE_ENABLE_COLUMN_METADATA
diff --git a/chromium/third_party/sqlite/src/ext/rtree/geopoly.c b/chromium/third_party/sqlite/src/ext/rtree/geopoly.c
index 98ea718f5a2..68cde873442 100644
--- a/chromium/third_party/sqlite/src/ext/rtree/geopoly.c
+++ b/chromium/third_party/sqlite/src/ext/rtree/geopoly.c
@@ -26,11 +26,7 @@
# define GEODEBUG(X)
#endif
-#ifndef JSON_NULL /* The following stuff repeats things found in json1 */
-/*
-** Versions of isspace(), isalnum() and isdigit() to which it is safe
-** to pass signed char values.
-*/
+/* Character class routines */
#ifdef sqlite3Isdigit
/* Use the SQLite core versions if this routine is part of the
** SQLite amalgamation */
@@ -45,6 +41,7 @@
# define safe_isxdigit(x) isxdigit((unsigned char)(x))
#endif
+#ifndef JSON_NULL /* The following stuff repeats things found in json1 */
/*
** Growing our own isspace() routine this way is twice as fast as
** the library isspace() function.
@@ -67,7 +64,7 @@ static const char geopolyIsSpace[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
};
-#define safe_isspace(x) (geopolyIsSpace[(unsigned char)x])
+#define fast_isspace(x) (geopolyIsSpace[(unsigned char)x])
#endif /* JSON NULL - back to original code */
/* Compiler and version */
@@ -156,7 +153,7 @@ static void geopolySwab32(unsigned char *a){
/* Skip whitespace. Return the next non-whitespace character. */
static char geopolySkipSpace(GeoParse *p){
- while( safe_isspace(p->z[0]) ) p->z++;
+ while( fast_isspace(p->z[0]) ) p->z++;
return p->z[0];
}
diff --git a/chromium/third_party/sqlite/src/ext/rtree/rtreeA.test b/chromium/third_party/sqlite/src/ext/rtree/rtreeA.test
index 921ba0b5109..301cd4fc62c 100644
--- a/chromium/third_party/sqlite/src/ext/rtree/rtreeA.test
+++ b/chromium/third_party/sqlite/src/ext/rtree/rtreeA.test
@@ -165,7 +165,7 @@ do_corruption_tests rtreeA-3.1 {
}
do_execsql_test rtreeA-3.1.0.3 {
- SELECT rtreecheck('main', 't1')!="ok"
+ SELECT rtreecheck('main', 't1')!='ok'
} {1}
do_test rtreeA-3.2.0 { set_tree_depth t1 1000 } {1000}
@@ -221,7 +221,7 @@ do_corruption_tests rtreeA-5.1 {
}
do_execsql_test rtreeA-5.2 {
- SELECT rtreecheck('main', 't1')!="ok"
+ SELECT rtreecheck('main', 't1')!='ok'
} {1}
#-------------------------------------------------------------------------
@@ -238,7 +238,7 @@ do_corruption_tests rtreeA-6.1 {
}
do_execsql_test rtreeA-6.2 {
- SELECT rtreecheck('main', 't1')!="ok"
+ SELECT rtreecheck('main', 't1')!='ok'
} {1}
#-------------------------------------------------------------------------
diff --git a/chromium/third_party/sqlite/src/ext/rtree/rtreecheck.test b/chromium/third_party/sqlite/src/ext/rtree/rtreecheck.test
index 545f4478a9b..17f359aa8ab 100644
--- a/chromium/third_party/sqlite/src/ext/rtree/rtreecheck.test
+++ b/chromium/third_party/sqlite/src/ext/rtree/rtreecheck.test
@@ -117,13 +117,13 @@ sqlite3_db_config db DEFENSIVE 0
do_execsql_test 3.2 {
BEGIN;
UPDATE r2_node SET data = X'123456';
- SELECT rtreecheck('r2')!="ok";
+ SELECT rtreecheck('r2')!='ok';
} {1}
do_execsql_test 3.3 {
ROLLBACK;
UPDATE r2_node SET data = X'00001234';
- SELECT rtreecheck('r2')!="ok";
+ SELECT rtreecheck('r2')!='ok';
} {1}
do_execsql_test 4.0 {
diff --git a/chromium/third_party/sqlite/src/ext/rtree/test_rtreedoc.c b/chromium/third_party/sqlite/src/ext/rtree/test_rtreedoc.c
index 3272d89ecaa..cdbcb2e8dc8 100644
--- a/chromium/third_party/sqlite/src/ext/rtree/test_rtreedoc.c
+++ b/chromium/third_party/sqlite/src/ext/rtree/test_rtreedoc.c
@@ -304,7 +304,7 @@ static int box_query(sqlite3_rtree_query_info *pInfo){
static void box_query_destroy(void *p){
BoxQueryCtx *pCtx = (BoxQueryCtx*)p;
Tcl_DecrRefCount(pCtx->pScript);
- ckfree(pCtx);
+ ckfree((char*)pCtx);
}
static int SQLITE_TCLAPI register_box_query(
@@ -324,7 +324,7 @@ static int SQLITE_TCLAPI register_box_query(
}
if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;
- pCtx = (BoxQueryCtx*)ckalloc(sizeof(BoxQueryCtx*));
+ pCtx = (BoxQueryCtx*)ckalloc(sizeof(BoxQueryCtx));
pCtx->interp = interp;
pCtx->pScript = Tcl_DuplicateObj(objv[2]);
Tcl_IncrRefCount(pCtx->pScript);
diff --git a/chromium/third_party/sqlite/src/ext/session/session8.test b/chromium/third_party/sqlite/src/ext/session/session8.test
index 9f70fe2829b..884da0e7751 100644
--- a/chromium/third_party/sqlite/src/ext/session/session8.test
+++ b/chromium/third_party/sqlite/src/ext/session/session8.test
@@ -63,7 +63,7 @@ proc do_then_undo {tn sql} {
do_execsql_test 1.1 {
CREATE TABLE t1(a PRIMARY KEY, b);
INSERT INTO t1 VALUES(1, 2);
- INSERT INTO t1 VALUES("abc", "xyz");
+ INSERT INTO t1 VALUES('abc', 'xyz');
}
do_then_undo 1.2 { INSERT INTO t1 VALUES(3, 4); }
do_then_undo 1.3 { DELETE FROM t1 WHERE b=2; }
diff --git a/chromium/third_party/sqlite/src/main.mk b/chromium/third_party/sqlite/src/main.mk
index f1a4660a8df..be16034e55a 100644
--- a/chromium/third_party/sqlite/src/main.mk
+++ b/chromium/third_party/sqlite/src/main.mk
@@ -64,7 +64,7 @@ LIBOBJ+= vdbe.o parse.o \
fts3_tokenize_vtab.o \
fts3_unicode.o fts3_unicode2.o \
fts3_write.o fts5.o func.o global.o hash.o \
- icu.o insert.o json1.o legacy.o loadext.o \
+ icu.o insert.o json.o legacy.o loadext.o \
main.o malloc.o mem0.o mem1.o mem2.o mem3.o mem5.o \
memdb.o memjournal.o \
mutex.o mutex_noop.o mutex_unix.o mutex_w32.o \
@@ -111,6 +111,7 @@ SRC = \
$(TOP)/src/hash.h \
$(TOP)/src/hwtime.h \
$(TOP)/src/insert.c \
+ $(TOP)/src/json.c \
$(TOP)/src/legacy.c \
$(TOP)/src/loadext.c \
$(TOP)/src/main.c \
@@ -244,7 +245,6 @@ SRC += \
$(TOP)/ext/rbu/sqlite3rbu.c \
$(TOP)/ext/rbu/sqlite3rbu.h
SRC += \
- $(TOP)/ext/misc/json1.c \
$(TOP)/ext/misc/stmt.c
@@ -377,6 +377,7 @@ TESTSRC += \
$(TOP)/ext/misc/normalize.c \
$(TOP)/ext/misc/percentile.c \
$(TOP)/ext/misc/prefixes.c \
+ $(TOP)/ext/misc/qpvtab.c \
$(TOP)/ext/misc/regexp.c \
$(TOP)/ext/misc/remember.c \
$(TOP)/ext/misc/series.c \
@@ -528,7 +529,7 @@ TESTOPTS = --verbose=file --output=test-out.txt
# Extra compiler options for various shell tools
#
-SHELL_OPT += -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS5
+SHELL_OPT += -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS5
SHELL_OPT += -DSQLITE_ENABLE_RTREE
SHELL_OPT += -DSQLITE_ENABLE_EXPLAIN_COMMENTS
SHELL_OPT += -DSQLITE_ENABLE_UNKNOWN_SQL_FUNCTION
@@ -537,8 +538,7 @@ SHELL_OPT += -DSQLITE_ENABLE_DBPAGE_VTAB
SHELL_OPT += -DSQLITE_ENABLE_DBSTAT_VTAB
SHELL_OPT += -DSQLITE_ENABLE_BYTECODE_VTAB
SHELL_OPT += -DSQLITE_ENABLE_OFFSET_SQL_FUNC
-FUZZERSHELL_OPT = -DSQLITE_ENABLE_JSON1
-FUZZCHECK_OPT = -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_MEMSYS5
+FUZZCHECK_OPT = -DSQLITE_ENABLE_MEMSYS5
FUZZCHECK_OPT += -DSQLITE_MAX_MEMORY=50000000
FUZZCHECK_OPT += -DSQLITE_PRINTF_PRECISION_LIMIT=1000
FUZZCHECK_OPT += -DSQLITE_ENABLE_FTS4
@@ -678,9 +678,6 @@ sqlite3-all.c: sqlite3.c $(TOP)/tool/split-sqlite3c.tcl
fts2amal.c: target_source $(TOP)/ext/fts2/mkfts2amal.tcl
tclsh $(TOP)/ext/fts2/mkfts2amal.tcl
-fts3amal.c: target_source $(TOP)/ext/fts3/mkfts3amal.tcl
- tclsh $(TOP)/ext/fts3/mkfts3amal.tcl
-
# Rules to build the LEMON compiler generator
#
lemon: $(TOP)/tool/lemon.c $(TOP)/tool/lempar.c
@@ -831,9 +828,6 @@ fts3_write.o: $(TOP)/ext/fts3/fts3_write.c $(HDR) $(EXTHDR)
fts5.o: fts5.c sqlite3ext.h sqlite3.h
$(TCCX) -DSQLITE_CORE -c fts5.c
-json1.o: $(TOP)/ext/misc/json1.c sqlite3ext.h sqlite3.h
- $(TCCX) -DSQLITE_CORE -c $(TOP)/ext/misc/json1.c
-
stmt.o: $(TOP)/ext/misc/stmt.c sqlite3ext.h sqlite3.h
$(TCCX) -DSQLITE_CORE -c $(TOP)/ext/misc/stmt.c
@@ -931,12 +925,6 @@ amalgamation-testfixture$(EXE): sqlite3.c $(TESTSRC) $(TOP)/src/tclsqlite.c \
$(TOP)/ext/session/test_session.c \
-o testfixture$(EXE) $(LIBTCL) $(THREADLIB)
-fts3-testfixture$(EXE): sqlite3.c fts3amal.c $(TESTSRC) $(TOP)/src/tclsqlite.c
- $(TCCX) $(TCL_FLAGS) $(TESTFIXTURE_FLAGS) \
- -DSQLITE_ENABLE_FTS3=1 \
- $(TESTSRC) $(TOP)/src/tclsqlite.c sqlite3.c fts3amal.c \
- -o testfixture$(EXE) $(LIBTCL) $(THREADLIB)
-
coretestprogs: $(TESTPROGS)
testprogs: coretestprogs srcck1$(EXE) fuzzcheck$(EXE) sessionfuzz$(EXE)
diff --git a/chromium/third_party/sqlite/src/manifest b/chromium/third_party/sqlite/src/manifest
index 8c0b0d4a106..4ca65c88cb8 100644
--- a/chromium/third_party/sqlite/src/manifest
+++ b/chromium/third_party/sqlite/src/manifest
@@ -1,13 +1,13 @@
-C Version\s3.37.1
-D 2021-12-30T15:30:28.342
+C Version\s3.38.1
+D 2022-03-12T13:37:29.643
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
-F Makefile.in 0e91c42a1dd13a569b1fa4f4dfb7d3632f3164a1c05c71341533d67db5b641dd
+F Makefile.in b210ad2733317f1a4353085dfb9d385ceec30b0e6a61d20a5accabecac6b1949
F Makefile.linux-gcc f609543700659711fbd230eced1f01353117621dccae7b9fb70daa64236c5241
-F Makefile.msc 88f05063ee36a5fb77d69b877ef824d0743b5325c95bfbf74d6ff17bd1c9fb1f
-F README.md 27fb76aa7eb57ed63a53bbba7292b6bf71f51125554f79f16b5d040edd1e6110
-F VERSION 912d4358751f2d7528c5a984129a84ac35fa96ee3207d2437b415cc36c06d6e4
+F Makefile.msc b28a8a7a977e7312f6859f560348e1eb110c21bd6cf9fab0d16537c0a514eef3
+F README.md 2dd87a5c1d108b224921f3dd47dea567973f706e1f6959386282a626f459a70c
+F VERSION 323c673ad334fe82cee0dd5e363eb373dd9c952246a5b61d95491d098be9fd93
F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50
F art/sqlite370.eps aa97a671332b432a54e1d74ff5e8775be34200c2
F art/sqlite370.ico af56c1d00fee7cd4753e8631ed60703ed0fc6e90
@@ -15,10 +15,10 @@ F art/sqlite370.jpg d512473dae7e378a67e28ff96a34da7cb331def2
F autoconf/INSTALL 83e4a25da9fd053c7b3665eaaaf7919707915903
F autoconf/Makefile.am a8d1d24affe52ebf8d7ddcf91aa973fa0316618ab95bb68c87cabf8faf527dc8
F autoconf/Makefile.fallback 22fe523eb36dfce31e0f6349f782eb084e86a5620b2b0b4f84a2d6133f53f5ac
-F autoconf/Makefile.msc d146a08ebbdf7f881ba600a49cd8dce40c4c807addcdb4b9b6a507e4b40ce837
+F autoconf/Makefile.msc 8401a514e4e70add3c6448348ae31322d5cb7db427b05a20828f943c3ddb2733
F autoconf/README.first 6c4f34fe115ff55d4e8dbfa3cecf04a0188292f7
-F autoconf/README.txt 4f04b0819303aabaa35fff5f7b257fb0c1ef95f1
-F autoconf/configure.ac a8ba2a9e61216f5093d44f3b7d2cb8fe1890d6b7dc330a02f802d8efaa1fdc79
+F autoconf/README.txt 42cfd21d0b19dc7d5d85fb5c405c5f3c6a4c923021c39128f6ba685355d8fd56
+F autoconf/configure.ac ec7fa914c5e74ff212fe879f9bb6918e1234497e05facfb641f30c4d5893b277
F autoconf/tea/Makefile.in b438a7020446c8a8156e8d97c8914a04833da6fd
F autoconf/tea/README 3e9a3c060f29a44344ab50aec506f4db903fb873
F autoconf/tea/aclocal.m4 52c47aac44ce0ddb1f918b6993e8beb8eee88f43
@@ -34,10 +34,11 @@ F autoconf/tea/win/rules.vc c511f222b80064096b705dbeb97060ee1d6b6d63
F config.guess 883205ddf25b46f10c181818bf42c09da9888884af96f79e1719264345053bd6
F config.h.in 6376abec766e9a0785178b1823b5a587e9f1ccbc
F config.sub c2d0260f17f3e4bc0b6808fccf1b291cb5e9126c14fc5890efc77b9fd0175559
-F configure 85be99bde3156905202042b2f292c2acf6eaf3119bbca3058c3007a1b7c85b79 x
-F configure.ac c8ba54bac7e73e000acdfef5e394fe21a3876aa09d0f5c07131bf5ac5a525299
+F configure 8938ad5a868970d410c8595e5d09f085a9534ea45226777cebaca810698e2f1b x
+F configure.ac 3ef6eeff4387585bfcab76b0c3f6e15a0618587bb90245dd5d44e4378141bb35
F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad
F doc/F2FS.txt c1d4a0ae9711cfe0e1d8b019d154f1c29e0d3abfe820787ba1e9ed7691160fcd
+F doc/json-enhancements.md e356fc834781f1f1aa22ee300027a270b2c960122468499bf347bb123ce1ea4f
F doc/lemon.html efc0cd2345d66905505d98f862e1c571512def0ceb5b016cb658fd4918eb76a3
F doc/pager-invariants.txt 27fed9a70ddad2088750c4a2b493b63853da2710
F doc/trusted-schema.md 33625008620e879c7bcfbbfa079587612c434fa094d338b08242288d358c3e8a
@@ -51,7 +52,7 @@ F ext/async/sqlite3async.h 46b47c79357b97ad85d20d2795942c0020dc20c532114a4980828
F ext/expert/README.md b321c2762bb93c18ea102d5a5f7753a4b8bac646cb392b3b437f633caf2020c3
F ext/expert/expert.c d548d603a4cc9e61f446cc179c120c6713511c413f82a4a32b1e1e69d3f086a4
F ext/expert/expert1.test 3c642a4e7bbb14f21ddab595436fb465a4733f47a0fe5b2855e1d5ff900ef08e
-F ext/expert/sqlite3expert.c 921a00823a826150cbb9a3341285a8edec7533480b71281e77737f19559b4b14
+F ext/expert/sqlite3expert.c 6ca30d73b9ed75bd56d6e0d7f2c962d2affaa72c505458619d0ff5d9cdfac204
F ext/expert/sqlite3expert.h ca81efc2679a92373a13a3e76a6138d0310e32be53d6c3bfaedabd158ea8969b
F ext/expert/test_expert.c d56c194b769bdc90cf829a14c9ecbc1edca9c850b837a4d0b13be14095c32a72
F ext/fts1/README.txt 20ac73b006a70bcfd80069bdaf59214b6cf1db5e
@@ -84,9 +85,9 @@ F ext/fts3/README.content b9078d0843a094d86af0d48dffbff13c906702b4c3558012e67b9c
F ext/fts3/README.syntax a19711dc5458c20734b8e485e75fb1981ec2427a
F ext/fts3/README.tokenizers b92bdeb8b46503f0dd301d364efc5ef59ef9fa8e2758b8e742f39fa93a2e422d
F ext/fts3/README.txt 8c18f41574404623b76917b9da66fcb0ab38328d
-F ext/fts3/fts3.c 6bfdc941372ee431e3d362986674a8708eb0e700b28c3d35d46d953a9351155f
+F ext/fts3/fts3.c 6634a3854e70afa8710ee5e3a7253cd0f0c89d4cce207fcbfe2ead3bad1db7d5
F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe
-F ext/fts3/fts3Int.h cff59b8b13dafe9d59924a5d710f771ed8b121a55cccbc99b6e2a723fcde14dc
+F ext/fts3/fts3Int.h dafdc371f9fbab175744b06cfe019d5f040cdfdbd11fea752f5dc28d45b04c05
F ext/fts3/fts3_aux.c f0dc9bd98582615b7750218899bd0c729879b6bbf94d1be57ca1833ff49afc6f
F ext/fts3/fts3_expr.c 903bfb9433109fffb10e910d7066c49cbf8eeae316adc93f0499c4da7dfc932a
F ext/fts3/fts3_hash.c 8b6e31bfb0844c27dc6092c2620bdb1fca17ed613072db057d96952c6bdb48b7
@@ -96,7 +97,7 @@ F ext/fts3/fts3_porter.c 3565faf04b626cddf85f03825e86056a4562c009
F ext/fts3/fts3_snippet.c f9a8149173553113f3c495a503843e30028b5dc3723d0ca798c5ad6142e130e6
F ext/fts3/fts3_term.c f45a1e7c6ef464abb1231245d123dae12266b69e05cc56e14045b76591ae92d1
F ext/fts3/fts3_test.c d8d7b2734f894e8a489987447658e374cdd3a3bc8575c401decf1911cb7c6454
-F ext/fts3/fts3_tokenize_vtab.c 8d15b148e7d88a4280389a200b26e8d52abda4c4ec2e9a35e9d7a1fa50e5aa03
+F ext/fts3/fts3_tokenize_vtab.c a95feda3590f3c3e17672fe35b67ea6112471aeea4c07ef7744a6606b66549aa
F ext/fts3/fts3_tokenizer.c 6d8fc150c48238955d5182bf661498db0dd473c8a2a80e00c16994a646fa96e7
F ext/fts3/fts3_tokenizer.h 64c6ef6c5272c51ebe60fc607a896e84288fcbc3
F ext/fts3/fts3_tokenizer1.c 5c98225a53705e5ee34824087478cf477bdb7004
@@ -104,7 +105,6 @@ F ext/fts3/fts3_unicode.c de426ff05c1c2e7bce161cf6b706638419c3a1d9c2667de9cb9dc0
F ext/fts3/fts3_unicode2.c 416eb7e1e81142703520d284b768ca2751d40e31fa912cae24ba74860532bf0f
F ext/fts3/fts3_write.c 3109c1a232da86474e196cc7db754445a354409f141e08cb11c846cdb17bdf31
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 413c346399159df81f86c4928b7c4a455caab73bfbc8cd68f950f632e5751674
F ext/fts3/unicode/CaseFolding.txt 8c678ca52ecc95e16bc7afc2dbf6fc9ffa05db8c
@@ -119,8 +119,8 @@ F ext/fts5/fts5_buffer.c 3001fbabb585d6de52947b44b455235072b741038391f830d6b7292
F ext/fts5/fts5_config.c 501e7d3566bc92766b0e11c0109a7c5a6146bc41144195459af5422f6c2078aa
F ext/fts5/fts5_expr.c fcd0770d53028c2b53a15d0f53bf6d0e01b1bf3dd97630b9fedf0801f03aa3ec
F ext/fts5/fts5_hash.c d4fb70940359f2120ccd1de7ffe64cc3efe65de9e8995b822cd536ff64c96982
-F ext/fts5/fts5_index.c b1b2e5d4a9e3b54c740d8354cc47e3fa879f54c2176de55e0b882dab45ab7b07
-F ext/fts5/fts5_main.c 7c6092a53e6802962fa07b0fad3e61cb077b6c98b74b727d8d44ac2cf63bd914
+F ext/fts5/fts5_index.c fdfbc8a62827ec1d1b6f207a1e59c1c4986c3ce245592b5128ffe738867cfcd1
+F ext/fts5/fts5_main.c 6078ae86d3b813753a4f1201054550aff21a3f660e97b30f200d2b1472874151
F ext/fts5/fts5_storage.c 76c6085239eb44424004c022e9da17a5ecd5aaec859fba90ad47d3b08f4c8082
F ext/fts5/fts5_tcl.c b1445cbe69908c411df8084a10b2485500ac70a9c747cdc8cda175a3da59d8ae
F ext/fts5/fts5_test_mi.c 08c11ec968148d4cb4119d96d819f8c1f329812c568bac3684f5464be177d3ee
@@ -160,7 +160,7 @@ F ext/fts5/test/fts5connect.test 08030168fc96fc278fa81f28654fb7e90566f33aff269c0
F ext/fts5/test/fts5content.test 213506436fb2c87567b8e31f6d43ab30aab99354cec74ed679f22aad0cdbf283
F ext/fts5/test/fts5corrupt.test 77ae6f41a7eba10620efb921cf7dbe218b0ef232b04519deb43581cb17a57ebe
F ext/fts5/test/fts5corrupt2.test 7453752ba12ce91690c469a6449d412561cc604b1dec994e16ab132952e7805f
-F ext/fts5/test/fts5corrupt3.test 0e473620582a53ac61f468f364db8a151c1e18d2a879b16439d172c12c4c9828
+F ext/fts5/test/fts5corrupt3.test 7da9895dafa404efd20728f66ff4b94399788bdc042c36fe2689801bba2ccd78
F ext/fts5/test/fts5corrupt4.test f4c08e2182a48d8b70975fd869ee5391855c06d8a0ff87b6a2529e7c5a88a1d3
F ext/fts5/test/fts5corrupt5.test 550d0884c14424f9acad051a741f1dd99ec9342277d938e91ff3daf9123d1209
F ext/fts5/test/fts5corrupt6.test bf8eeae07825b088b9665d9d8e4accbd8dc9bf3cb85b6c64cf6c9e18ccc420a4
@@ -170,7 +170,7 @@ F ext/fts5/test/fts5determin.test 1b77879b2ae818b5b71c859e534ee334dac088b7cf3ff3
F ext/fts5/test/fts5dlidx.test b90852c55881b29dbac6380b274de27beae623ac4b6d567c6c8fb9cdc315a86e
F ext/fts5/test/fts5doclist.test faa9e9cc3c0645fa6203667cb5f007c359447c6ee66753f71a58175c2497cacd
F ext/fts5/test/fts5ea.test b01e3a18cdfabbff8104a96a5242a06a68a998a0
-F ext/fts5/test/fts5eb.test 239bb2f02571f8cccfc7018d08f502df1cd8cc6a69b65ed1dde5f6a070e3f669
+F ext/fts5/test/fts5eb.test a973baadac524dbbb4ad9b0e99030e12cabde2c6b28e0ac437298007b642cd12
F ext/fts5/test/fts5fault1.test d28a65caee75db6897c3cf1358c5230d3bb2a3bf7fb31062c19c7e5382b3d2bd
F ext/fts5/test/fts5fault2.test 69c8fdbef830cd0d450908d4504d5bb86609e255af99c421c20a0756251fe344
F ext/fts5/test/fts5fault3.test da2f9e3e56ff5740d68ebdd6877c97089e7ed28ddff28a0da87a6afea27e5522
@@ -188,7 +188,7 @@ F ext/fts5/test/fts5first.test 3fcf2365c00a15fc9704233674789a3b95131d12de18a9b99
F ext/fts5/test/fts5full.test e1701a112354e0ff9a1fdffb0c940c576530c33732ee20ac5e8361777070d717
F ext/fts5/test/fts5fuzz1.test 238d8c45f3b81342aa384de3e581ff2fa330bf922a7b69e484bbc06051a1080e
F ext/fts5/test/fts5hash.test dc7bc7e0cdeb42cfce31294ad2f8fcf43192bfd0145bb7f3ecc5465d8c72696f
-F ext/fts5/test/fts5integrity.test e387b2bd1c83e50f4a12f58a5fd399111bbab36be2f1c9fd5bb974be08a32de6
+F ext/fts5/test/fts5integrity.test 62147a1e85405b986691177e0312be5a64ec9e67b17994e83892d9afa6247600
F ext/fts5/test/fts5interrupt.test 09613247b273a99889808ef852898177e671406fe71fdde7ea00e78ea283d227
F ext/fts5/test/fts5lastrowid.test be98fe3e03235296585b72daad7aed5717ba0062bae5e5c18dd6e04e194c6b28
F ext/fts5/test/fts5leftjoin.test c0b4cafb9661379e576dc4405c0891d8fcc2782680740513c4d1fc114b43d4ad
@@ -280,7 +280,7 @@ F ext/lsm1/lsm_str.c 65e361b488c87b10bf3e5c0070b14ffc602cf84f094880bece77bbf6678
F ext/lsm1/lsm_tree.c 682679d7ef2b8b6f2fe77aeb532c8d29695bca671c220b0abac77069de5fb9fb
F ext/lsm1/lsm_unix.c 11e0a5c19d754a4e1d93dfad06de8cc201f10f886b8e61a4c599ed34e334fc24
F ext/lsm1/lsm_varint.c 43f954af668a66c7928b81597c14d6ad4be9fedbc276bbd80f52fa28a02fdb62
-F ext/lsm1/lsm_vtab.c 169bfe7ef8e6c9de9c77e17c4c50c9ae55fb0167d80be3d1be82c991184b6f35
+F ext/lsm1/lsm_vtab.c e57aa3eb456bf2b98064014027e097c9402d6dec7b59564ddbfa1c0ead8f96c5
F ext/lsm1/lsm_win32.c 0a4acbd7e8d136dd3a5753f0a9e7a9802263a9d96cef3278cf120bcaa724db7c
F ext/lsm1/test/lsm1_common.tcl 5ed4bab07c93be2e4f300ebe46007ecf4b3e20bc5fbe1dedaf04a8774a6d8d82
F ext/lsm1/test/lsm1_simple.test a04d08e8661ae6fc53786c67f0bd102c6692f003e859dde03ed9ac3f12e066e5
@@ -297,17 +297,16 @@ F ext/misc/cksumvfs.c b42ef52eaaa510d54ec320c87bea149e934a3b06cd232be2093562bf66
F ext/misc/closure.c dbfd8543b2a017ae6b1a5843986b22ddf99ff126ec9634a2f4047cd14c85c243
F ext/misc/completion.c 6dafd7f4348eecc7be9e920d4b419d1fb2af75d938cd9c59a20cfe8beb2f22b9
F ext/misc/compress.c 3354c77a7c8e86e07d849916000cdac451ed96500bfb5bd83b20eb61eee012c9
-F ext/misc/csv.c 53b3338d4fa812eda51a2637df30233a4dae16b964ee5666e2051b9672ed8bb4
+F ext/misc/csv.c d14709096280dc0e20c533f184568952bf4b8022ea80afc4aa9fec5ab3637bb3
F ext/misc/dbdata.c e316fba936571584e55abd5b974a32a191727a6b746053a0c9d439bd2cf93940
F ext/misc/dbdump.c b8592f6f2da292c62991a13864a60d6c573c47a9cc58362131b9e6a64f823e01
F ext/misc/decimal.c 09f967dcf4a1ee35a76309829308ec278d3648168733f4a1147820e11ebefd12
F ext/misc/eval.c 04bc9aada78c888394204b4ed996ab834b99726fb59603b0ee3ed6e049755dc1
F ext/misc/explain.c 0086fab288d4352ea638cf40ac382aad3b0dc5e845a1ea829a694c015fd970fe
-F ext/misc/fileio.c 57fefd0efc535e62bb8b07fa146875171481da81a759bbfbe2fc91bab90058e0
+F ext/misc/fileio.c 4e7f7cd30de8df4820c552f14af3c9ca451c5ffe1f2e7bef34d598a12ebfb720
F ext/misc/fossildelta.c 1240b2d3e52eab1d50c160c7fe1902a9bd210e052dc209200a750bbf885402d5
F ext/misc/fuzzer.c eae560134f66333e9e1ca4c8ffea75df42056e2ce8456734565dbe1c2a92bf3d
-F ext/misc/ieee754.c 91a5594071143a4ab79c638fe9f059af1db09932faf2e704c3e29216a7d4f511
-F ext/misc/json1.c 89a988f06dcb3da0d0af9fdb2b09892452ad12dfd8f432600ee6437a6dcac310
+F ext/misc/ieee754.c 984d51fe23e956484ec1049df6f5257002e3ab338cabceb39761c2e80ad10bf4
F ext/misc/memstat.c 3017a0832c645c0f8c773435620d663855f04690172316bd127270d1a7523d4d
F ext/misc/memtrace.c 7c0d115d2ef716ad0ba632c91e05bd119cb16c1aedf3bec9f06196ead2d5537b
F ext/misc/memvfs.c 7dffa8cc89c7f2d73da4bd4ccea1bcbd2bd283e3bb4cea398df7c372a197291b
@@ -317,13 +316,14 @@ F ext/misc/noop.c 81efe4cad9ec740e64388b14281cb983e6e2c223fed43eb77ab3e34946e0c1
F ext/misc/normalize.c bd84355c118e297522aba74de34a4fd286fc775524e0499b14473918d09ea61f
F ext/misc/percentile.c b9086e223d583bdaf8cb73c98a6539d501a2fc4282654adbfea576453d82e691
F ext/misc/prefixes.c 0f4f8cff5aebc00a7e3ac4021fd59cfe1a8e17c800ceaf592859ecb9cbc38196
-F ext/misc/regexp.c 8cd0d2d904bf7014ba28beab8c1d502b5154e04a8c738b079d88e4ecca1b3981
+F ext/misc/qpvtab.c 09738419e25f603a35c0ac8bd0a04daab794f48d08a9bc07a6085b9057b99009
+F ext/misc/regexp.c b267fd05ff8d38b22f4c2809d7b7a2c61d522e9faf2feb928dbb9662e4a3a386
F ext/misc/remember.c add730f0f7e7436cd15ea3fd6a90fd83c3f706ab44169f7f048438b7d6baa69c
F ext/misc/rot13.c 51ac5f51e9d5fd811db58a9c23c628ad5f333c173f1fc53c8491a3603d38556c
F ext/misc/scrub.c 2a44b0d44c69584c0580ad2553f6290a307a49df4668941d2812135bfb96a946
-F ext/misc/series.c f9896e76b029e3c6553c520552555e803e26e7dfe1890d5866243cf072d938d0
-F ext/misc/sha1.c c8f2253c8792ffab9517695ea7d88c079f0395a5505eefef5c8198fe184ed5ac
-F ext/misc/shathree.c e984f31731de4cf302a0386be5fe664580f63d8204c47b9b41cc4b997745f9ec
+F ext/misc/series.c 8d79354f2c3d46b95ee21272a07cf0bcabb58d1f2b06d9e7b8a31dca1dacb3e5
+F ext/misc/sha1.c 4011aef176616872b2a0d5bccf0ecfb1f7ce3fe5c3d107f3a8e949d8e1e3f08d
+F ext/misc/shathree.c 9b6fce315bf8b37bd72786086d1f0974701f651e83022a93244e0e8f56f98a45
F ext/misc/showauth.c 732578f0fe4ce42d577e1c86dc89dd14a006ab52
F ext/misc/spellfix.c 94df9bbfa514a563c1484f684a2df3d128a2f7209a84ca3ca100c68a0163e29f
F ext/misc/sqlar.c 0ace5d3c10fe736dc584bf1159a36b8e2e60fab309d310cd8a0eecd9036621b6
@@ -339,7 +339,7 @@ F ext/misc/vfsstat.c 474d08efc697b8eba300082cb1eb74a5f0f3df31ed257db1cb07e72ab0e
F ext/misc/vtablog.c 5538acd0c8ddaae372331bee11608d76973436b77d6a91e8635cfc9432fba5ae
F ext/misc/vtshim.c 1976e6dd68dd0d64508c91a6dfab8e75f8aaf6cd
F ext/misc/wholenumber.c a838d1bea913c514ff316c69695efbb49ea3b8cb37d22afc57f73b6b010b4546
-F ext/misc/zipfile.c 5dcbbdae13ba45db5d3843b6f32a8f99df7ab0349a704857a3000618f9ea9ecb
+F ext/misc/zipfile.c 238ccb990ed45a74e24d0fbb449d7752a568c2b7c1d5b255d451f11703ced592
F ext/misc/zorder.c b0ff58fa643afa1d846786d51ea8d5c4b6b35aa0254ab5a82617db92f3adda64
F ext/rbu/rbu.c 801450b24eaf14440d8fd20385aacc751d5c9d6123398df41b1b5aa804bf4ce8
F ext/rbu/rbu1.test c62904bd9526dcdc3496a21199aaf14ae191bbadbf67f076bf16be6b3f2115c2
@@ -382,20 +382,20 @@ F ext/rbu/rbuvacuum.test 55e101e90168c2b31df6c9638fe73dc7f7cc666b6142266d1563697
F ext/rbu/rbuvacuum2.test 886add83fd74bcb02e6dd016ae5b585367bd58c5d0694c9d9ca7bdb1d1f578c2
F ext/rbu/rbuvacuum3.test 8addd82e4b83b4c93fa47428eae4fd0dbf410f8512c186f38e348feb49ba03dc
F ext/rbu/rbuvacuum4.test a78898e438a44803eb2bc897ba3323373c9f277418e2d6d76e90f2f1dbccfd10
-F ext/rbu/sqlite3rbu.c 3658f1c6603955c7426952b74a6896337b1f672d326cd565e5af20e18d5744f0
+F ext/rbu/sqlite3rbu.c 8737cabdfbee84bb25a7851ecef8b1312be332761238da9be6ddb10c62ad4291
F ext/rbu/sqlite3rbu.h 1dc88ab7bd32d0f15890ea08d23476c4198d3da3056985403991f8c9cd389812
F ext/rbu/test_rbu.c 03f6f177096a5f822d68d8e4069ad8907fe572c62ff2d19b141f59742821828a
F ext/repair/README.md 92f5e8aae749a4dae14f02eea8e1bb42d4db2b6ce5e83dbcdd6b1446997e0c15
F ext/repair/checkfreelist.c e21f06995ff4efdc1622dcceaea4dcba2caa83ca2f31a1607b98a8509168a996
F ext/repair/checkindex.c 4383e4469c21e5b9ae321d0d63cec53e981af9d7a6564be6374f0eeb93dfc890
-F ext/repair/sqlite3_checker.c.in 4a5a3af3f450fe503e5a2985e98516dc2a6b9ad247449e284c1cf140fc91720f
+F ext/repair/sqlite3_checker.c.in 445118c5f7fea958b36fba1b2c464283e60ed4842039ddee3265f1698115ebf7
F ext/repair/sqlite3_checker.tcl a9a2caa9660567257c177a91124d8c0dccdfa341e25c51e6da7f1fd9e601eafa
F ext/repair/test/README.md 34b2f542cf5be7bffe479242b33ee3492cea30711e447cc4a1a86cb5915f419e
F ext/repair/test/checkfreelist01.test 3e8aa6aeb4007680c94a8d07b41c339aa635cc78249442da72ff3f8297398a69
F ext/repair/test/checkindex01.test b530f141413b587c9eb78ff734de6bb79bc3515c335096108c12c01bddbadcec
F ext/repair/test/test.tcl 686d76d888dffd021f64260abf29a55c57b2cedfa7fc69150b42b1d6119aac3c
F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761
-F ext/rtree/geopoly.c a7021cb524621573ccda213a35b0339371849dd4acc4909f689786ee1f964b7f
+F ext/rtree/geopoly.c cc3f89c11abcf114fa60d74709ae8b5bc1eae5a261b30bc1bb7085089c03bfab
F ext/rtree/rtree.c d7b4b8b81d8d54376a7f81de5be85ec58b37c11604bcf42984a8418b34158d93
F ext/rtree/rtree.h 4a690463901cb5e6127cf05eb8e642f127012fd5003830dbc974eca5802d9412
F ext/rtree/rtree1.test 35c3bc0def71317b7601ee0d1149e7df2cd8fc4f13ec89a64761ac3f46ca123f
@@ -407,7 +407,7 @@ F ext/rtree/rtree6.test 9ce3691c1aac43070a9f194f0ebf54372db346c5a82241fd11b525ed
F ext/rtree/rtree7.test c8fb2e555b128dd0f0bdb520c61380014f497f8a23c40f2e820acc9f9e4fdce5
F ext/rtree/rtree8.test 2d99006a1386663978c9e1df167554671e4f711c419175b39f332719deb1ce0e
F ext/rtree/rtree9.test fd3c9384ef8aabbc127b3878764070398f136eebc551cd20484b570f2cc1956a
-F ext/rtree/rtreeA.test c0d8e91e25052d5f3fbda17632ca843b82ca13c4181fb6000a0d63bd2d7e70ce
+F ext/rtree/rtreeA.test a7fd235d8194115fa2e14d300337931eb2e960fe8a46cdfb66add2206412ea41
F ext/rtree/rtreeB.test 4cec297f8e5c588654bbf3c6ed0903f10612be8a2878055dd25faf8c71758bc9
F ext/rtree/rtreeC.test c4bfa9a61c6788c03e4a9ce40ab2cfc6100982559effd9842d1b658e1d47aa5f
F ext/rtree/rtreeD.test fe46aa7f012e137bd58294409b16c0d43976c3bb92c8f710481e577c4a1100dc
@@ -418,7 +418,7 @@ F ext/rtree/rtreeH.test 0885151ee8429242625600ae47142cca935332c70a06737f35af53a7
F ext/rtree/rtreeI.test 608e77f7fde9be5a12eae316baef640fffaafcfa90a3d67443e78123e19c4ca4
F ext/rtree/rtree_perf.tcl 6c18c1f23cd48e0f948930c98dfdd37dfccb5195
F ext/rtree/rtree_util.tcl db734b4c5e75fed6acc56d9701f2235345acfdec750b5fc7b587936f5f6bceed
-F ext/rtree/rtreecheck.test d67d5b3e9e45bfa8cd90734e8e9302144ac415b8e9176c6f02d4f92892ee8a35
+F ext/rtree/rtreecheck.test 1f542257f21c8a22ce3462c852ec1a0847fa8b3133053abfab3972764210e8bc
F ext/rtree/rtreecirc.test aec664eb21ae943aeb344191407afff5d392d3ae9d12b9a112ced0d9c5de298e
F ext/rtree/rtreeconnect.test 225ad3fcb483d36cbee423a25052a6bbae762c9576ae9268332360c68c170d3d
F ext/rtree/rtreedoc.test 27a5703cb1200f6f69051de68da546cef3dfdcf59be73afadfc50b9f9c9960d9
@@ -426,7 +426,7 @@ F ext/rtree/rtreedoc2.test 194ebb7d561452dcdc10bf03f44e30c082c2f0c14efeb07f5e02c
F ext/rtree/rtreedoc3.test 555a878c4d79c4e37fa439a1c3b02ee65d3ebaf75d9e8d96a9c55d66db3efbf8
F ext/rtree/rtreefuzz001.test 0fc793f67897c250c5fde96cefee455a5e2fb92f4feeabde5b85ea02040790ee
F ext/rtree/sqlite3rtree.h 03c8db3261e435fbddcfc961471795cbf12b24e03001d0015b2636b0f3881373
-F ext/rtree/test_rtreedoc.c 0167f9243a56d08e79230f604f3979d6b7cde4816355acf7a7d436d9d788bf38
+F ext/rtree/test_rtreedoc.c de76b3472bc74b788d079342fdede22ff598796dd3d97acffe46e09228af83a3
F ext/rtree/tkt3363.test 142ab96eded44a3615ec79fba98c7bde7d0f96de
F ext/rtree/util/randomshape.tcl 54ee03d0d4a1c621806f7f44d5b78d2db8fac26e0e8687c36c4bd0203b27dbff
F ext/rtree/viewrtree.tcl eea6224b3553599ae665b239bd827e182b466024
@@ -440,7 +440,7 @@ F ext/session/session3.test ce9ce3dfa489473987f899e9f6a0f2db9bde3479
F ext/session/session4.test 6778997065b44d99c51ff9cece047ff9244a32856b328735ae27ddef68979c40
F ext/session/session5.test 716bc6fafd625ce60dfa62ae128971628c1a1169
F ext/session/session6.test 35279f2ec45448cd2e24a61688219dc6cf7871757716063acf4a8b5455e1e926
-F ext/session/session8.test 8e194b3f655d861ca36de5d4de53f702751bab3b
+F ext/session/session8.test 326f3273abf9d5d2d7d559eee8f5994c4ea74a5d935562454605e6607ee29904
F ext/session/session9.test 5409d90d8141881d08285ed1c2c0d8d10fb92069
F ext/session/sessionA.test 1feeab0b8e03527f08f2f1defb442da25480138f
F ext/session/sessionB.test c4fb7f8a688787111606e123a555f18ee04f65bb9f2a4bb2aa71d55ce4e6d02c
@@ -473,7 +473,7 @@ F ext/userauth/userauth.c 7f00cded7dcaa5d47f54539b290a43d2e59f4b1eb5f447545fa865
F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x
F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8
F magic.txt 8273bf49ba3b0c8559cb2774495390c31fd61c60
-F main.mk 002e77acdfeb08d1d8f4d360b01e130aa243fb5701728e81fac9085794f27155
+F main.mk 80ac3d2f82eb21c6fb4423f9c7f8e207abb51be6676845a00e246cfb22f9c77c
F mkso.sh fd21c06b063bb16a5d25deea1752c2da6ac3ed83
F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271
F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504
@@ -485,45 +485,46 @@ F spec.template 86a4a43b99ebb3e75e6b9a735d5fd293a24e90ca
F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b
F sqlite3.1 fc7ad8990fc8409983309bb80de8c811a7506786
F sqlite3.pc.in 48fed132e7cb71ab676105d2a4dc77127d8c1f3a
-F src/alter.c 23743384e59f9d36df870ce41adfdf7934fd0adb619d7fa6fd1aac77c28a7533
+F src/alter.c 006325f8844c65d885b3ba469b4c08d9dd0cd3e9ec481d5bcff621f224cb2302
F src/analyze.c 7518b99e07c5494111fe3bd867f28f804b6c5c1ad0703ec3d116de9bab3fa516
-F src/attach.c e3f9d9a2a4a844750f3f348f37afb244535f21382cbfcd840152cb21cb41cfaf
+F src/attach.c f26d400f3ffe2cdca01406bca70e5f58c5488bf165b4fc37c228136dfcf1b583
F src/auth.c f4fa91b6a90bbc8e0d0f738aa284551739c9543a367071f55574681e0f24f8cf
-F src/backup.c 3014889fa06e20e6adfa0d07b60097eec1f6e5b06671625f476a714d2356513d
+F src/backup.c a2891172438e385fdbe97c11c9745676bec54f518d4447090af97189fd8e52d7
F src/bitvec.c 7c849aac407230278445cb069bebc5f89bf2ddd87c5ed9459b070a9175707b3d
F src/btmutex.c 8acc2f464ee76324bf13310df5692a262b801808984c1b79defb2503bbafadb6
-F src/btree.c 13b965a0f3cd57221e3b4e61e24452ec264a5b163de347b03b5039ddcd95cd54
+F src/btree.c 259413ef3018ff795f7934dcebc1268ed3d5e3076fb9ad645774002e8ed92940
F src/btree.h 74d64b8f28cfa4a894d14d4ed64fa432cd697b98b61708d4351482ae15913e22
-F src/btreeInt.h ee9348c4cb9077243b049edc93a82c1f32ca48baeabf2140d41362b9f9139ff7
-F src/build.c c46bd4f5a69f398410c4472f7c1c4291fb8078d2c9758a2dad5916edd1d30ecc
-F src/callback.c 106b585da1edd57d75fa579d823a5218e0bf37f191dbf7417eeb4a8a9a267dbc
+F src/btreeInt.h 8be97d3939d626f734ec1b577efa4e6e186da00daf5b3227af199ca1c24cdd71
+F src/build.c a0cc68fe8172c0a31b54576f9c6c0fe6f7c82b1b5e1387afdd6a5a13132bc131
+F src/callback.c 4c19af69835787bfe790ac560f3071a824eb629f34e41f97b52ce5235c77de1c
F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e
-F src/ctime.c 8159d5f706551861c18ec6c8f6bdf105e15ea00367f05d9ab65d31a1077facc1
-F src/date.c fa928630fecf1d436cdc7a7a5c950c781709023ca782c21b7a43cc7361a9451e
-F src/dbpage.c 8a01e865bf8bc6d7b1844b4314443a6436c07c3efe1d488ed89e81719047833a
+F src/ctime.c 2cce39df1a13e05b7633e6d21b651f21492471f991dd7b323a4ee4e7b7f0b7f1
+F src/date.c 15082566229d4b1e5f24fdb490bf9bcc68824b911d70e3573ef075a1b9e2d26f
+F src/dbpage.c 30ff075a9a9156bd2cccb5c1ea579f2afbaa64989648e8c9d72cb4a3417f5136
F src/dbstat.c 861e08690fcb0f2ee1165eff0060ea8d4f3e2ea10f80dab7d32ad70443a6ff2d
-F src/delete.c 0c151975fa99560767d7747f9b60543d0093d9f8b89f13d2d6058e9c83ad19e7
-F src/expr.c 827179c78d2ca7cc318392811de8151c60eacf7ce804b13e61bb7ef38f954846
+F src/delete.c b5f1716b4d723db48254ee0f896e362cd029e865e05414139ea7f539f3884e1d
+F src/expr.c b90a029105a93a93a0ed5e5f8c5eaed8f19043a3b62e4c4d235a4611d9ada178
F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007
-F src/fkey.c 187b67af20c5795953a592832c5d985e4313fe503ebd8f95e3e9e9ad5a730bb5
-F src/func.c 1cfb09d7ffca81238eccefdb0293e1f5b7cfebbd1816dfad5ec6024742a7496b
-F src/global.c 1f56aead86e8a18c4415638f5e6c4d0a0550427f4b3f5d065ba5164cc09c22e8
+F src/fkey.c 06e4ac33031b02dde7130c12e79cddf4dc5cfa72b23d8e63a3c26878fc9c1d3c
+F src/func.c a3407a6fbb0d4088d8d502e46f0ace63e0aeae7467ae23a9ca9815bbf9239761
+F src/global.c a3daa18a1696aadd94f18d37cbbdebf0bbdb827b8397a534f021cd56c15cd0f9
F src/hash.c 8d7dda241d0ebdafb6ffdeda3149a412d7df75102cecfc1021c98d6219823b19
F src/hash.h 3340ab6e1d13e725571d7cee6d3e3135f0779a7d8e76a9ce0a85971fa3953c51
F src/hwtime.h cb1d7e3e1ed94b7aa6fde95ae2c2daccc3df826be26fc9ed7fd90d1750ae6144
F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71
-F src/insert.c 9b133400f1c7f6d83ca14565e9cf4d2b9b8c938123b5d6793ae2fccb85c52834
+F src/insert.c 9fbf8704562fe17e442c16b7f60d3d91101ea69fc45c2bce96ee6cb982e86d2f
+F src/json.c 225b00422112ecd7094a555f3ace16b25d7d5894062b823269ed03899907c2a2
F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa
-F src/loadext.c e1dcff1c916bf6834e150b492eddda5d9792453182d2ad64294d2266b6e93c4c
-F src/main.c 1ea70751e6005ab6a9f784730fa0919efaa6639440a287deb73cb711e5aae57a
-F src/malloc.c ef796bcc0e81d845d59a469f1cf235056caf9024172fd524e32136e65593647b
+F src/loadext.c aa919a6a7884f8b34d7b791841b24d14b1b0ab43f45b3940f4851043b2855c0c
+F src/main.c 0840cee6984034c7e73cc747a1562c7eaed4673694bf20b00980aaa0672c0405
+F src/malloc.c fec841aa0a0400a6f7d20706178a5d8e8219a6bf562b6fe712c17f6c26813266
F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645
F src/mem1.c c12a42539b1ba105e3707d0e628ad70e611040d8f5e38cf942cee30c867083de
F src/mem2.c c8bfc9446fd0798bddd495eb5d9dbafa7d4b7287d8c22d50a83ac9daa26d8a75
F src/mem3.c 30301196cace2a085cbedee1326a49f4b26deff0af68774ca82c1f7c06fda4f6
F src/mem5.c 9bf955937b07f8c32541c8a9991f33ce3173d944
F src/memdb.c c2dc88f97c410eb68a24468344b65526685e18354ddfd15906750c1eaf9dc2dd
-F src/memjournal.c a85f0dc5c02a42453d0bc3819ecfb5666cb6433e5deefcd93ccbe05c9f088b83
+F src/memjournal.c 8bd50ae6d9c6d34b3a96cc3b4f567f9935dc358444d872ab48901a8c11ad82a6
F src/msvc.h 3a15918220367a8876be3fa4f2abe423a861491e84b864fb2b7426bf022a28f8
F src/mutex.c 5e3409715552348732e97b9194abe92fdfcd934cfb681df4ba0ab87ac6c18d25
F src/mutex.h a7b2293c48db5f27007c3bdb21d438873637d12658f5a0bf8ad025bb96803c4a
@@ -538,30 +539,30 @@ F src/os_setup.h 0dbaea40a7d36bf311613d31342e0b99e2536586
F src/os_unix.c f5ad51cfd024116db8531feab9efd831c2621436dca1464e4ff1e8af9bf3252e
F src/os_win.c 77d39873836f1831a9b0b91894fec45ab0e9ca8e067dc8c549e1d1eca1566fe9
F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a
-F src/pager.c bc10c191d18bffd3d76eda5f162799e43a9f875ecfe7c4869f752e2ddef87ea2
+F src/pager.c e4f4c1e07b2cc4fa44fc0bd51957ca6066f6b8c0b0e0388f11a6728b50d8f4e6
F src/pager.h 4bf9b3213a4b2bebbced5eaa8b219cf25d4a82f385d093cd64b7e93e5285f66f
-F src/parse.y 0bd7971a7489bbf6c3726f1b50da6e508bdff8fa493e9cc3f5a96b12cbb2361e
-F src/pcache.c 084e638432c610f95aea72b8509f0845d2791293f39d1b82f0c0a7e089c3bb6b
+F src/parse.y 0f02b27cdaa334441463153fff3ceb780fea006ab53ffd6ef566d4468f93e924
+F src/pcache.c 0aab73936341fad83d107cf62c6a7bc2d2d5fb9aaec8c3ce61e19fc18e4560fc
F src/pcache.h 4f87acd914cef5016fae3030343540d75f5b85a1877eed1a2a19b9f284248586
F src/pcache1.c 54881292a9a5db202b2c0ac541c5e3ef9a5e8c4f1c1383adb2601d5499a60e65
-F src/pragma.c c536665ce8431c8b1efbf7e0a5c01852f49f7bf28f1954f8118b2d28e4a3797f
+F src/pragma.c 7c024d690a3dc93f61830f11f900e4af2357f31d081b0c79099ca5e28919cba7
F src/pragma.h 87330ed2fbfa2a1274de93ca0ab850fba336189228cb256089202c3b52766fad
-F src/prepare.c 40961a1170a4c4151a90dae29dd00fc6c155f1af8246abeeeb8f0a10b3fb9719
-F src/printf.c 5901672228f305f7d493cbc4e7d76a61a5caecdbc1cd06b1f9ec42ea4265cf8d
+F src/prepare.c a187dade741c1f09ae118fcbbf0302511807bfc0355880927d7152eb75b8260d
+F src/printf.c 05d8dfd2018bc4fc3ddb8b37eb97ccef7abf985643fa1caebdcf2916ca90fa32
F src/random.c 097dc8b31b8fba5a9aca1697aeb9fd82078ec91be734c16bffda620ced7ab83c
-F src/resolve.c 4a1db4aadd802683db40ca2dbbb268187bd195f10cbdb7206dbd8ac988795571
+F src/resolve.c ea935b87d6fb36c78b70cdc7b28561dc8f33f2ef37048389549c7b5ef9b0ba5e
F src/rowset.c ba9515a922af32abe1f7d39406b9d35730ed65efab9443dc5702693b60854c92
-F src/select.c a7a3d9f54eb24821ec5f67f2e5589b68a5d42d46fc5849d7376886777d93a85a
-F src/shell.c.in 1458b700144c8326fda2514aaddeda49d6f01f1d1ccf7b9b696c53a3535a119c
-F src/sqlite.h.in 5cd209ac7dc4180f0e19292846f40440b8488015849ca0110c70b906b57d68f0
+F src/select.c 3baa9dd8cf240654773c7974e2bcce398ac9dd24419c36684156963defe43b35
+F src/shell.c.in 69d1e59da4881f096ab47fbd3e6d99794f3e4a43f41fd9e4d2e845c9b8d20fd5
+F src/sqlite.h.in b93deee892f1bc4030e5c8712df9e21d786a1bf8e921ab8dc987eaf1e44c676f
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
-F src/sqlite3ext.h 8ff2fd2c166150b2e48639f5e506fb44e29f1a3f65031710b9e89d1c126ac839
-F src/sqliteInt.h 193e716a67c877a6054a8c261c932bdc64f8c8be9b66388c74f21d94a259b7ce
+F src/sqlite3ext.h a95cb9ed106e3d39e2118e4dcc15a14faec3fa50d0093425083d340d9dfd96e6
+F src/sqliteInt.h e7b93bb693cb14259f6c3faadc6d7c824ff509aac673622a76c161a96c5872d0
F src/sqliteLimit.h d7323ffea5208c6af2734574bae933ca8ed2ab728083caa117c9738581a31657
F src/status.c 4b8bc2a6905163a38b739854a35b826c737333fab5b1f8e03fa7eb9a4799c4c1
F src/table.c 0f141b58a16de7e2fbe81c308379e7279f4c6b50eb08efeec5892794a0ba30d1
-F src/tclsqlite.c 48f291e1a7e672a7204884d4c164a8ed3a522ff087c361ada2991f5d54e987f6
-F src/test1.c d6c945a8bb211ed72ea515f0b9743caeaf38c66da6418a7b1dcf3764e1368bbb
+F src/tclsqlite.c 1f6673991147bc2cecc08a40d22f9803b84c805b24b499fe727f392256f73474
+F src/test1.c 87fda59eea3ac1eba1baef37c1967565cb1b8d6d264649f2e57f252ca5989914
F src/test2.c 3efb99ab7f1fc8d154933e02ae1378bac9637da5
F src/test3.c 61798bb0d38b915067a8c8e03f5a534b431181f802659a6616f9b4ff7d872644
F src/test4.c 7c4420e01c577b5c4add2cb03119743b1a357543d347773b9e717195ea967159
@@ -573,15 +574,15 @@ F src/test9.c 12e5ba554d2d1cbe0158f6ab3f7ffcd7a86ee4e5
F src/test_async.c 195ab49da082053fdb0f949c114b806a49ca770a
F src/test_autoext.c 915d245e736652a219a907909bb6710f0d587871
F src/test_backup.c bf5da90c9926df0a4b941f2d92825a01bbe090a0
-F src/test_bestindex.c 78809f11026f18a93fcfd798d9479cba37e1201c830260bf1edc674b2fa9b857
+F src/test_bestindex.c 8294d8223b7f18a3ddb7f9a0e30815dcca4e61681f78b538c870f7d934f88b81
F src/test_blob.c ae4a0620b478548afb67963095a7417cd06a4ec0a56adb453542203bfdcb31ce
F src/test_btree.c 8b2dc8b8848cf3a4db93f11578f075e82252a274
-F src/test_config.c 284c29912736f68b0a583a920bf63fd8f9125dffb8a75cb0676e58502b2f7908
+F src/test_config.c 8264637b06a3c1f0727c88d1ea32dcf7986b9e7e358a970cae87cdac8a5b2708
F src/test_delete.c e2fe07646dff6300b48d49b2fee2fe192ed389e834dd635e3b3bac0ce0bf9f8f
F src/test_demovfs.c 86142ba864d4297d54c5b2e972e74f3141ae4b30f05b3a95824184ed2d3d7f91
F src/test_devsym.c aff2255ea290d7718da08af30cdf18e470ff7325a5eff63e0057b1496ed66593
F src/test_fs.c ba1e1dc18fd3159fdba0b9c4256f14032159785320dfbd6776eb9973cb75d480
-F src/test_func.c 181f992e5495644434c4f0e3cc72362a78c295eb2cf3ff4d02498b8bde7aa276
+F src/test_func.c 24df3a346c012b1fc9e1001d346db6054deb426db0a7437e92490630e71c9b0a
F src/test_hexio.c 9478e56a0f08e07841a014a93b20e4ba2709ab56d039d1ca8020e26846aa19bd
F src/test_init.c 4413c211a94b62157ca4c145b3f27c497f03c664
F src/test_intarray.c 39b4181662a0f33a427748d87218e7578d913e683dc27eab7098bb41617cac71
@@ -615,34 +616,34 @@ F src/test_windirent.h 90dfbe95442c9762357fe128dc7ae3dc199d006de93eb33ba3972e0a9
F src/test_window.c cdae419fdcea5bad6dcd9368c685abdad6deb59e9fc8b84b153de513d394ba3f
F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9
F src/threads.c 4ae07fa022a3dc7c5beb373cf744a85d3c5c6c3c
-F src/tokenize.c 865911afa00fed589cd03b25c140ca88544842aaef7b81f7d41ed769a7a54120
-F src/treeview.c 9dfdb7ff7f6645d0a6458dbdf4ffac041c071c4533a6db8bb6e502b979ac67bc
-F src/trigger.c 2ef56f0b7b75349a5557d0604b475126329c2e1a02432e7d49c4c710613e8254
-F src/update.c 69c4c10bc6873a80c0a77cb578f9fc60ee90003d03f9530bc3370fa24615772d
+F src/tokenize.c 6661a9fa660ecbd3ac0df1acd2ec788b3a8122b4316022bcdaf476ea6754a8de
+F src/treeview.c a84b57d15e46007d8b1ae249344b3f0b7f3c62def908b98baaa54935a57c8476
+F src/trigger.c 5fc3cde35cc4de510be68bb2db4dcff0ce0e1625f43e28a0920be9a6f010cd3f
+F src/update.c f875b0d59da5c3055a0b2ac20560e1650229c6787e78de5e9836267b5cbb8359
F src/upsert.c 8789047a8f0a601ea42fa0256d1ba3190c13746b6ba940fe2d25643a7e991937
F src/utf.c ee39565f0843775cc2c81135751ddd93eceb91a673ea2c57f61c76f288b041a0
-F src/util.c 30df8356e231dad33be10bb27897655002668343280004ba28c734489414a167
+F src/util.c 602fe229f32a96ceccae4f40824129669582096f7c355f53dbac156c9fecef23
F src/vacuum.c 6c38ddc52f0619865c91dae9c441d4d48bf3040d7dc1bc5b22da1e45547ed0b3
-F src/vdbe.c e98f1baf54a00db2c4669dbd04f8bbc89b5909a5b43e76fbbbf1a97007adba2b
+F src/vdbe.c 8239c69f3cb6fa27bac30d60c5a1ebac723abc007ff870ffc3af93e5159c7216
F src/vdbe.h 25dabb25c7e157b84e59260cfb5b466c3ac103ede9f36f4db371332c47601abe
-F src/vdbeInt.h 31fbabdc1ed61d9695337dfe5269ea94e1cf615c17f5cafeaa1bb01066820bab
-F src/vdbeapi.c 22c79072ae7d8a01e9bcae8ba16e918d60d202eaa9553b5fda38f99f7464d99a
-F src/vdbeaux.c 21db442d159fd745a7693d157b5f998260b6af4ca60de559fa3b7b68c7405af2
-F src/vdbeblob.c 29c4118f7ee615cdee829e8401f6ead1b96b95d545b4de0042f6de39c962c652
-F src/vdbemem.c a3d91dc9bb9ef725db77e4e9de7e1acef43192c9f8406c307665d503e3c2837c
-F src/vdbesort.c 513b481c8bab4a6578c92194a60cf3bc3b48736e4a53f8d2d7918121c5b594e7
+F src/vdbeInt.h b45599a2b59f1ce042512ab6786b0b82a8cf3002f6b0fa60b4834e2cd3ac61d8
+F src/vdbeapi.c 8863ffb5a7bac42fe9a68aaa3526ee29fc18fb02a9b27188b756de41e33856e9
+F src/vdbeaux.c 0d7659fe8cb38ce86092b9bc5131c99a834a04eb78745e54acb77d79d7af2fb5
+F src/vdbeblob.c 5e61ce31aca17db8fb60395407457a8c1c7fb471dde405e0cd675974611dcfcd
+F src/vdbemem.c 69d3092d47b7a3a466a161961abd92bca7ab148abd8b497438eb17c6afdcbad8
+F src/vdbesort.c 43756031ca7430f7aec3ef904824a7883c4ede783e51f280d99b9b65c0796e35
F src/vdbetrace.c fe0bc29ebd4e02c8bc5c1945f1d2e6be5927ec12c06d89b03ef2a4def34bf823
F src/vdbevtab.c f99b275366c5fc5e2d99f734729880994ab9500bdafde7fae3b02d562b9d323c
-F src/vtab.c 9d5c3f49d3a6959b6eef287bb8fa773563102a80a835c3314c57144412709e78
+F src/vtab.c e0eaf5b8f7f8929088485a76bea2ff6124adb12e0eb5c0997287ff5e0e4c0517
F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9
-F src/wal.c ed0398a7adf02c31e34aada42cc86c58f413a7afe5f741a5d373ad087abde028
+F src/wal.c b9df133a705093da8977da5eb202eaadb844839f1c7297c08d33471f5491843d
F src/wal.h c3aa7825bfa2fe0d85bef2db94655f99870a285778baa36307c0a16da32b226a
F src/walker.c f890a3298418d7cba3b69b8803594fdc484ea241206a8dfa99db6dd36f8cbb3b
-F src/where.c de0d4ff409c7b62a8803f9f267cc2c7fedddbc00de9ab7b5382c507383c18665
-F src/whereInt.h 83877a75a1bce056ea44aff02f1dfa958ad1d6038c213ddadb8652003b45151d
-F src/wherecode.c 1f5b62f46d284c8886945eb7438415bc27e23e87bb60b9ee468fa6bd31268f33
-F src/whereexpr.c 17bdbf4f5b490e70a18635498f0b910a558f953a9bf80af7f19cbde6e60e6825
-F src/window.c 5d3b397b0c026d0ff5890244ac41359e524c01ae31e78782e1ff418c3e271a9e
+F src/where.c baec5c64db111227b6c7f07f65d91706a51d9f8c72d3f3ec7e65c39450b592d0
+F src/whereInt.h 15d2975c3b4c193c78c26674400a840da8647fe1777ae3b026e2d15937b38a03
+F src/wherecode.c 84be340684393248b9f3ecbce9b87c8a6f818149b52302702ea0b8d2a9d51faf
+F src/whereexpr.c 2a71f5491798460c9590317329234d332d9eb1717cba4f3403122189a75c465e
+F src/window.c 731980c0887f7ec9859f5e0d3c69d5fbeb6e512a9e1d338935f53938eaba431e
F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2
F test/affinity2.test ce1aafc86e110685b324e9a763eab4f2a73f737842ec3b687bd965867de90627
F test/affinity3.test eecb0dabee4b7765a8465439d5e99429279ffba23ca74a7eae270a452799f9e7
@@ -655,19 +656,19 @@ F test/alter2.test a966ccfcddf9ce0a4e0e6ff1aca9e6e7948e0e242cd7e43fc091948521807
F test/alter3.test ffc4ab29ce78a3517a66afd69b2730667e3471622509c283b2bd4c46f680fba3
F test/alter4.test 716caa071dd8a3c6d57225778d15d3c3cbf5e34b2e84ae44199aeb2bbf50a707
F test/alterauth.test 63442ba61ceb0c1eeb63aac1f4f5cebfa509d352276059d27106ae256bafc959
-F test/alterauth2.test 381b1ab603c9ef96314a3158528ea17f7964449385a28eeaf8191120b2e24a8d
-F test/altercol.test b11fa1b131e80ab5b6ecfb3b725fb0419c14ca6efba5adb57aeabfc9baa0c8f3
+F test/alterauth2.test 48967abae0494d9a300d1c92473d99fcb66edfcc23579c89322f033f49410adc
+F test/altercol.test 8465ca659c2c55a359cf16cc261df4fcb5c45a5f104a50827c337ae66c09dc15
F test/altercorrupt.test 2e1d705342cf9d7de884518ddbb053fd52d7e60d2b8869b7b63b2fda68435c12
F test/alterdropcol.test a653a3945f964d26845ec0cd0a8e74189f46de3119a984c5bc45457da392612e
F test/alterdropcol2.test 527fce683b200d620f560f666c44ae33e22728e990a10a48a543280dfd4b4d41
F test/alterfault.test 289067108947bedca27534edd4ff251bcd298cf84402d7b24eaa3749305418c6
F test/alterlegacy.test f38c6d06cda39e1f7b955bbce57f2e3ef5b7cb566d3d1234502093e228c15811
F test/altermalloc.test 167a47de41b5c638f5f5c6efb59784002b196fff70f98d9b4ed3cd74a3fb80c9
-F test/altermalloc2.test ca3ebc01670d9313953a2b7628d8cc00dc5ea9988f229b3cbbbe1cca506dae45
-F test/altermalloc3.test 4660ac6240a8c82ba3947b927612dcc7c05a8eec3fe3c9f38e047ca69a789a33
-F test/alterqf.test 6b2482a957692606b23567ebd2cf80eb773e3c826086f5f151eee9c5a962623d
+F test/altermalloc2.test 17fb3724c4b004c469c27dc4ef181608aa644555fbd3f3236767584f73747c81
+F test/altermalloc3.test 55e606edf4b0acfbbd851ddfe93cfdddfae43d103644dcfd6008ae4ab3c44adf
+F test/alterqf.test ff6c6f881485c29ed699b8ef4774864ca1b0c01a6c08f5cdd624a008e4b40fca
F test/altertab.test 7273b8506eab46342be016af78028df49f3bd99037412f997a8f1011b37a6912
-F test/altertab2.test b0d62f323ca5dab42b0bc028c52e310ebdd13e655e8fac070fe622bad7852c2b
+F test/altertab2.test 62597b6fd08feaba1b6bfe7d31dac6117c67e06dc9ce9c478a3abe75b5926de0
F test/altertab3.test 5929f522fd6fd708396ad9f317d4af9ff1a93e460df85bb1d54d4499eeb94960
F test/amatch1.test b5ae7065f042b7f4c1c922933f4700add50cdb9f
F test/analyze.test 547bb700f903107b38611b014ca645d6b5bb819f5210d7bf39c40802aafeb7d7
@@ -689,7 +690,7 @@ F test/async2.test c0a9bd20816d7d6a2ceca7b8c03d3d69c28ffb8b
F test/async3.test d73a062002376d7edc1fe3edff493edbec1fc2f7
F test/async4.test 1787e3952128aa10238bf39945126de7ca23685a
F test/async5.test 383ab533fdb9f7ad228cc99ee66e1acb34cc0dc0
-F test/atof1.test 77e8517df10cb39f2e4e65dbefe1e81c8d8e65f29f68b09265ca6e534c68227e
+F test/atof1.test 10049623e77006691c4c2978c1dc8a3f75276377a53417811aa85bda7493f963
F test/atomic.test 065a453dde33c77ff586d91ccaa6ed419829d492dbb1a5694b8a09f3f9d7d061
F test/atomic2.test b6863b4aa552543874f80b42fb3063f1c8c2e3d8e56b6562f00a3cc347b5c1da
F test/atrc.c c388fac43dbba05c804432a7135ae688b32e8f25818e9994ffba4b64cf60c27c
@@ -698,7 +699,7 @@ F test/attach2.test 256bd240da1835fb8408dd59fb7ef71f8358c7a756c46662434d11d07ba3
F test/attach3.test c59d92791070c59272e00183b7353eeb94915976
F test/attach4.test 00e754484859998d124d144de6d114d920f2ed6ca2f961e6a7f4183c714f885e
F test/attachmalloc.test 12c4f028e570acf9e0a4b0b7fe6f536e21f3d5ebddcece423603d0569beaf438
-F test/auth.test 567d917e0baddb6d0026a251cff977a3ab2c805a3cef906ba8653aafe7ad7240
+F test/auth.test 0f246deec5cb2f6f893f8fbb76628f182c08fe40f178b254dd72467ca012f657
F test/auth2.test 9eb7fce9f34bf1f50d3f366fb3e606be5a2000a1
F test/auth3.test 76d20a7fa136d63bcfcf8bcb65c0b1455ed71078d81f22bcd0550d3eb18594ab
F test/autoanalyze1.test b9cc3f32a990fa56669b668d237c6d53e983554ae80c0604992e18869a0b2dec
@@ -706,7 +707,7 @@ F test/autoinc.test 997d6f185f138229dc4251583a1d04816423dddc2fc034871a01aeb1d728
F test/autoindex1.test fe27af92eaf884bd9c38f94be3e8afa04ec494e5eefb189902026181a6175f5e
F test/autoindex2.test 12ef578928102baaa0dc23ad397601a2f4ecb0df
F test/autoindex3.test 2d13958a5617e987624a428d7aed91bf51f322b49b476e3573fadec697ce6da5
-F test/autoindex4.test 49d3cd791a9baa16fb461d7ea3de80d019a819cf
+F test/autoindex4.test 75cb1191a552b8201351f5a50d160fcb9387a0fbbfb820c77798bfee7da3f8cf
F test/autoindex5.test 2ee94f033b87ca0160e08d81034c507aff8e230df2627f0304fa309b2fee19a3
F test/autovacuum.test 00671369bbf96c6a49989a9425f5b78b94075d6a4b031e5e00000c2c32f365df
F test/autovacuum2.test 76f7eb4fe6a6bf6d33a196a7141dba98886d2fb53a268d7feca285d5da4759d7
@@ -714,7 +715,7 @@ F test/autovacuum_ioerr2.test 8a367b224183ad801e0e24dcb7d1501f45f244b4
F test/avfs.test 0c3a38e03cccb0fc3127838462dc05dc3f4c1480d770c084b388304c25de3652
F test/avtrans.test b7dc25459ecbd86c6fa9c606ee3068f59d81e225118617dcf2bbb6ded2ade89e
F test/backcompat.test 3e64cedda754c778ef6bbe417b6e7a295e662a4d
-F test/backup.test dd4a5ff756e3df3931dacb1791db0584d4bad989
+F test/backup.test fc1ecefce723fad5199b55cec7a5a992ec8c3ad6873419e5e8919066dec457f3
F test/backup2.test 8facb54df1388419d34b362ab1f7e233310ff3a3af64e8ad5ec47ba3c2bbe5cf
F test/backup4.test 8f6fd48e0dfde77b9a3bb26dc471ede3e101df32
F test/backup5.test ee5da6d7fe5082f5b9b0bbfa31d016f52412a2e4
@@ -723,13 +724,14 @@ F test/backup_malloc.test 0c9abdf74c51e7bedb66d504cd684f28d4bd4027
F test/badutf.test d5360fc31f643d37a973ab0d8b4fb85799c3169f
F test/badutf2.test f310fd3b24a491b6b77bccdf14923b85d6ebcce751068c180d93a6b8ff854399
F test/bc_common.tcl b5e42d80305be95697e6370e015af571e5333a1c
-F test/bestindex1.test 7cc626f1f4a7483bb6b38487d467db4477083be5cd93958aeda5d5127640dc81
-F test/bestindex2.test 60266e2854055788459cbfd86cef575601eabe74a2c61faba72601739fea4398
-F test/bestindex3.test e061a6ed0f519beee037ba7e7a4c37f80c8a7e4a303e2559ed1f760e4b0235eb
-F test/bestindex4.test 82250e7dcc6d5b15244edc9d6554b1760583af1b8548c2a255a1c4f28e744c0e
-F test/bestindex5.test 67c1166131bb59f9e47c00118f7d432ca5491e6cae6ca3f87ca9db20103a78f9
-F test/bestindex6.test d856a9bb63d927493575823eed44053bc36251e241aa364e54d0f2a2d302e1d4
-F test/bestindex7.test a11348824aed0de2bb9030f092636929000cd72882bdf919adacc3792f67ccbd
+F test/bestindex1.test 856a453dff8c68b4568601eed5a8b5e20b4763af9229f3947c215729ed878db0
+F test/bestindex2.test 394ff8fbf34703391247116d6a44e1c50ee7282236ee77909044573cefc37bc0
+F test/bestindex3.test 34bea272b0e0f835651b16a3931dbe7ac927039be6b2e1cb617bbe1d584b492b
+F test/bestindex4.test 3039894f2dad50f3a68443dffad1b44c9b067ac03870102df1ce3d9a46ea602e
+F test/bestindex5.test a0c90b2dad7836e80a01379e200e5f8ec9476d49b349af02c0dbff2fb75dc98d
+F test/bestindex6.test 16942535b551273f3ad9df8d7cc4b7f22b1fcd8882714358859eb049a6f99dd4
+F test/bestindex7.test f094c669a6400777f4d2ddc3ed28e39169f1adb5be3d59b55f22ccf8c414b71e
+F test/bestindex8.test abd0016fc04f19dc382976750b06df5463d2757e11e78a8ba7d7dc50671f3337
F test/between.test b9a65fb065391980119e8a781a7409d3fcf059d89968279c750e190a9a1d5263
F test/bigfile.test aa74f4e5db51c8e54a1d9de9fa65d01d1eb20b59
F test/bigfile2.test 1b489a3a39ae90c7f027b79110d6b4e1dbc71bfc
@@ -737,6 +739,7 @@ F test/bigmmap.test b820c234daa56d24bc3bf006e3ac7aa9d9623c8ac656a38f59063b444a2d
F test/bigrow.test f0aeb7573dcb8caaafea76454be3ade29b7fc747
F test/bigsort.test 8299fa9298f4f1e02fc7d2712e8b77d6cd60e5a2
F test/bind.test 1e136709b306f7ed3192d349c2930d89df6ab621654ad6f1a72381d3fe76f483
+F test/bind2.test 918bc35135f4141809ead7585909cde57d44db90a7a62aef540127148f91aab7
F test/bindxfer.test efecd12c580c14df5f4ad3b3e83c667744a4f7e0
F test/bitvec.test 75894a880520164d73b1305c1c3f96882615e142
F test/blob.test e7ac6c7d3a985cc4678c64f325292529a69ae252
@@ -760,19 +763,19 @@ F test/capi2.test 4ee545824adc3eb33bf57ef89f77440b28188ec3da72e5425ff0fcdba32e8d
F test/capi3.test 3910a73c38ac76d69778dd9eb481ab7cd6ed59117fc047b4f6056a5c72529de1
F test/capi3b.test efb2b9cfd127efa84433cd7a2d72ce0454ae0dc4
F test/capi3c.test 54e2dc0c8fd7c34ad1590d1be6864397da2438c95a9f5aee2f8fbc60c112e44b
-F test/capi3d.test aba917805573a03deed961a21f07a5a84505ad0a616f7e3fc1508844a15bccc4
+F test/capi3d.test 8b778794af891b0dca3d900bd345fbc8ebd2aa2aae425a9dccdd10d5233dfbde
F test/capi3e.test 3d49c01ef2a1a55f41d73cba2b23b5059ec460fe
F test/carray01.test d55d57bf66b1af1c7ac55fae66ff4910884a8f5d21a90a18797ce386212a2634
F test/cast.test 336fa21989b5170ebcaf90c24266be22dd97b3e23d1fad5ecf6ad4efb04c4423
F test/cffault.test 9d6b20606afe712374952eec4f8fd74b1a8097ef
F test/changes.test 9dd8e597d84072122fc8a4fcdea837f4a54a461e6e536053ea984303e8ca937b
-F test/check.test 4a2a91ed67eee84a6be16057c48d5198b6fb24849cd6da6cd855981de3fbb416
+F test/check.test 56e4ed457e9f8683b9fc56f5b964f461f6e8a8dd5a13f3d495408215d66419ed
F test/checkfault.test da6cb3d50247169efcb20bdf57863a3ccfa1d27d9e55cd324f0680096970f014
F test/chunksize.test 427d87791743486cbf0c3b8c625002f3255cb3a89c6eba655a98923b1387b760
F test/close.test eccbad8ecd611d974cbf47278c3d4e5874faf02d811338d5d348af42d56d647c
F test/closure01.test 9905883f1b171a4638f98fc764879f154e214a306d3d8daf412a15e7f3a9b1e0
F test/coalesce.test cee0dccb9fbd2d494b77234bccf9dc6c6786eb91
-F test/collate1.test 532b4992f78e91dd80c2e3c7bd944fada8cbe3d6c0ded0b20f7182b4dfca0006
+F test/collate1.test 71a6f27fdc93a92f14d8ab80c05e1937656a5a03197e1a10157314554d630ce8
F test/collate2.test 9aaa410a00734e48bcb27f3872617d6f69b2a621
F test/collate3.test 89defc49983ddfbf0a0555aca8c0521a676f56a5
F test/collate4.test c953715fb498b87163e3e73dd94356bff1f317bd
@@ -830,18 +833,19 @@ F test/crashtest1.c 09c1c7d728ccf4feb9e481671e29dda5669bbcc2
F test/createtab.test 85cdfdae5c3de331cd888d6c66e1aba575b47c2e3c3cc4a1d6f54140699f5165
F test/cse.test 00b3aea44b16828833c94fbe92475fd6977583fcb064ae0bc590986812b38d0c
F test/csv01.test c9c3af0d58c34e9ac970c5875a77939edb958762c8aafb95409e19a3f088b6cd
-F test/ctime.test 78749e6c9a5f0010d67985be80788f841e3cd2da18114e2ed6010399a7d807f3
+F test/ctime.test 340f362f41f92972bbd71f44e10569a5cc694062b692231bd08aa6fe6c1c4773
F test/cursorhint.test 0175e4404181ace3ceca8b114eb0a98eae600d565aa4e2705abbe6614c7fe201
F test/cursorhint2.test 6f3aa9cb19e7418967a10ec6905209bcbb5968054da855fc36c8beee9ae9c42f
F test/dataversion1.test 6e5e86ac681f0782e766ebcb56c019ae001522d114e0e111e5ebf68ccf2a7bb8
-F test/date.test 9b73bbeb1b82d9c1f44dec5cf563bf7da58d2373
+F test/date.test 118e04db8c8b4efeb885542b4918c7b869a34c460a6bebbfe927dfd75706b80d
F test/date2.test 7e12ec14aaf4d5e6294b4ba140445b0eca06ea50062a9c3a69c4ee13d0b6f8b1
+F test/date3.test a1b77abf05c6772fe5ca2337cac1398892f2a41e62bce7e6be0f4a08a0e64ae5
F test/dbdata.test 042f49acff3438f940eeba5868d3af080ae64ddf26ae78f80c92bec3ca7d8603
F test/dbfuzz.c 73047c920d6210e5912c87cdffd9a1c281d4252e
F test/dbfuzz001.test 55e1a3504f8dea84155e09912fe3b1c3ad77e0b1a938ec42ca03b8e51b321e30
F test/dbfuzz2-seed1.db e6225c6f3d7b63f9c5b6867146a5f329d997ab105bee64644dc2b3a2f2aebaee
F test/dbfuzz2.c 4b3c12de4d98b1b2d908ab03d217d4619e47c8b23d5e67f8a6f2b1bdee7cae23
-F test/dbpage.test 650234ba683b9d82b899c6c51439819787e7609f17a0cc40e0080a7b6443bc38
+F test/dbpage.test fce29035c7566fd7835ec0f19422cb4b9c6944ce0e1b936ff8452443f92e887d
F test/dbstatus.test 4a4221a883025ffd39696b3d1b3910b928fb097d77e671351acb35f3aed42759
F test/dbstatus2.test f5fe0afed3fa45e57cfa70d1147606c20d2ba23feac78e9a172f2fe8ab5b78ef
F test/decimal.test fcf403fd5585f47342234e153c4a4338cd737b8e0884ac66fc484df47dbcf1a7
@@ -863,12 +867,12 @@ F test/e_blobclose.test 692fc02a058476c2222a63d97e3f3b2b809c1842e5525ded7f854d54
F test/e_blobopen.test 29f6055ee453b8e679fe9570c4d3acfedbef821622c5dad16875148c5952ef50
F test/e_blobwrite.test 3075ff539827576d9a34cbb5a2ac75eb65fb49cd5aadc27686b0719fbf99c156
F test/e_changes.test 0f8c3e6aab7335cb772d5a3ea34ca4c82f98d0eb896e2eb3add971c16984b405
-F test/e_createtable.test 04c50b7fe41c12ed9cd88fbbc09b4900bcfc66f98ad198874fc993a2771f3913
+F test/e_createtable.test e3b9782e80c0cf2898ac0eb1d9cd058412955ff53a8e47307a60c8289d62ff9c
F test/e_delete.test ab39084f26ae1f033c940b70ebdbbd523dc4962e
F test/e_droptrigger.test 235c610f8bf8ec44513e222b9085c7e49fad65ad0c1975ac2577109dd06fd8fa
F test/e_dropview.test 74e405df7fa0f762e0c9445b166fe03955856532e2bb234c372f7c51228d75e7
-F test/e_expr.test e164550b9f8fd9c130283d1eae692dff9e2ba67f4dbd35f7325021f5d4b8851c
-F test/e_fkey.test ee321dbca3c53204da46cb40b8ec80192e995035f9ea26576ddcd842b1f0877f
+F test/e_expr.test bc6aa5906ba967587525bc746ea403011557cf6d8e4fc9efb1fab5dae7fb4fd6
+F test/e_fkey.test feeba6238aeff9d809fb6236b351da8df4ae9bda89e088e54526b31a0cbfeec5
F test/e_fts3.test 17ba7c373aba4d4f5696ba147ee23fd1a1ef70782af050e03e262ca187c5ee07
F test/e_insert.test f02f7f17852b2163732c6611d193f84fc67bc641fb4882c77a464076e5eba80e
F test/e_reindex.test 2b0e29344497d9a8a999453a003cb476b6b1d2eef2d6c120f83c2d3a429f3164
@@ -890,12 +894,12 @@ F test/enc3.test 6807f7a7740a00361ca8d0ccd66bc60c8dc5f2b6
F test/enc4.test c8f1ce3618508fd0909945beb8b8831feef2c020
F test/eqp.test bfe979eb1f4b8ab7a3bd7db6d16c2e6c6be0e5a3aada2227716f3fd3a9d76b69
F test/errmsg.test eae9f091eb39ce7e20305de45d8e5d115b68fa856fba4ea6757b6ca3705ff7f9
-F test/eval.test a64c9105d6ff163df7cf09d6ac29cdad5922078c
+F test/eval.test 73969a2d43a511bf44080c44485a8c4d796b6a4f038d19e491867081155692c0
F test/exclusive.test 7ff63be7503990921838d5c9f77f6e33e68e48ed1a9d48cd28745bf650bf0747
F test/exclusive2.test 984090e8e9d1b331d2e8111daf6e5d61dda0bef7
F test/exec.test e949714dc127eaa5ecc7d723efec1ec27118fdd7
F test/exists.test 79a75323c78f02bbe9c251ea502a092f9ef63dac
-F test/expr.test 26cd01e8485bc48c8aa6a1add598e9ce1e706b4eb4f3f554e0b0223022e8c2cf
+F test/expr.test e1afcdb1038e4d3fa67a3df323347c38750946e2e1b4e385bdc75d26284f2dac
F test/expr2.test c27327ae9c017a7ff6280123f67aff496f912da74d78c888926d68b46ec75fd8
F test/exprfault.test 497cc0b8fe6a677f49b55cb485e040f709ec2834b84f25912fe9c2dfeeda33db
F test/extension01.test 00d13cec817f331a687a243e0e5a2d87b0e358c9
@@ -908,7 +912,7 @@ F test/filter1.test 6c483ecf7886c8843a8612c021aa23f33c581f584151f251842b3a3592c9
F test/filter2.tcl 44e525497ce07382915f01bd29ffd0fa49dab3adb87253b5e5103ba8f93393e8
F test/filter2.test 485cf95d1f6d6ceee5632201ca52a71868599836f430cdee42e5f7f14666e30a
F test/filterfault.test c08fb491d698e8df6c122c98f7db1c65ffcfcad2c1ab0e07fa8a5be1b34eaa8b
-F test/fkey1.test 03503639d266d565db90ee3b8fe211ba446624030ac4eb24895cec265e9631d0
+F test/fkey1.test 55663090ab6735319a52647057b9f19f8ec8c6c7d7da25170b71a75e3e5bdeb7
F test/fkey2.test 1063d65e5923c054cfb8f0555a92a3ae0fa8c067275a33ee1715bd856cdb304c
F test/fkey3.test 76d475c80b84ee7a5d062e56ccb6ea68882e2b49
F test/fkey4.test 86446017011273aad8f9a99c1a65019e7bd9ca9d
@@ -965,8 +969,8 @@ F test/fts3af.test d394978c534eabf22dd0837e718b913fd66b499c
F test/fts3ag.test c003672a215124df7fc6000036d896f498b26b53
F test/fts3ah.test dc9f66c32c296f1bc8bcc4535126bddfeca62894
F test/fts3ai.test 24058fdc6e9e5102c1fd8459591b114b6a85d285
-F test/fts3aj.test 0ed71e1dd9b03b843a857dc3eb9b15630e0104fc
-F test/fts3ak.test bd14deafe9d1586e8e9bf032411026ac4f8c925d
+F test/fts3aj.test 1560a7ce5642dc887e8ecfcc4693bcfce1dbb3d1771a735c845f0061e525deb2
+F test/fts3ak.test 36ea92f609efb390cf018cdb5d389c12e62b650abe31cfc88261b252daf88174
F test/fts3al.test 07d64326e79bbdbab20ee87fc3328fbf01641c9f
F test/fts3am.test 218aa6ba0dfc50c7c16b2022aac5c6be593d08d8
F test/fts3an.test a49ccadc07a2f7d646ec1b81bc09da2d85a85b18
@@ -979,7 +983,7 @@ F test/fts3b.test c15c4a9d04e210d0be67e54ce6a87b927168fbf9c1e3faec8c1a732c366fd4
F test/fts3c.test fc723a9cf10b397fdfc2b32e73c53c8b1ec02958
F test/fts3comp1.test a0f5b16a2df44dd0b15751787130af2183167c0c
F test/fts3conf.test c84bbaec81281c1788aa545ac6e78a6bd6cde2bdbbce2da261690e3659f5a76b
-F test/fts3corrupt.test 79a32ffdcd5254e2f7fa121d9656e61949ad049c3c6554229911b7ceac37c9c6
+F test/fts3corrupt.test 43c6c89b994e90997590ece4dfa9c9325c9b61cddd7c97e158498da8b1de79f8
F test/fts3corrupt2.test e318f0676e5e78d5a4b702637e2bb25265954c08a1b1e4aaf93c7880bb0c67d0
F test/fts3corrupt3.test 0d5b69a0998b4adf868cc301fc78f3d0707745f1d984ce044c205cdb764b491f
F test/fts3corrupt4.test 799ff994b964fed7201be6b6b62c7ff2ef7bb3da6c02b9eaf0d96a5a4d9b6ca3
@@ -991,6 +995,7 @@ F test/fts3defer.test f4c20e4c7153d20a98ee49ee5f3faef624fefc9a067f8d8d629db380c4
F test/fts3defer2.test 3da52ca2114e300e9971eee2f0cc1a2e5f27e6a9ee67957d49e63e41fdfcc0e7
F test/fts3defer3.test dd53fc13223c6d8264a98244e9b19abd35ed71cd
F test/fts3drop.test 1b906e293d6773812587b3dc458cb9e8f3f0c297
+F test/fts3dropmod.test 7de242ea1c8a713a8b143ea54468f4b1c4953fa068349e23ac178e2c90c59889
F test/fts3e.test 1f6c6ac9cc8b772ca256e6b22aaeed50c9350851
F test/fts3expr.test ebae205a7a89446c32583bcd492dcb817b9f6b31819bb4dde2583bb99c77e526
F test/fts3expr2.test 18da930352e5693eaa163a3eacf96233b7290d1a
@@ -1036,7 +1041,7 @@ F test/fts4merge3.test 8d9ccb4a3d41c4c617a149d6c4b13ad02de797d0
F test/fts4merge4.test d895b1057a7798b67e03455d0fa50e9ea836c47b
F test/fts4merge5.test 69932d85cda8a1c4dcfb742865900ed8fbda51724b8cf9a45bbe226dfd06c596
F test/fts4min.test 1c11e4bde16674a0c795953509cbc3731a7d9cbd1ddc7f35467bf39d632d749f
-F test/fts4noti.test 5553d7bb2e20bf4a06b23e849352efc022ce6309
+F test/fts4noti.test d5d933705b1b1516b67a5e3f8e514ecb19c6522fb3357bb744776d48427c2292
F test/fts4onepass.test d69ddc4ee3415e40b0c5d1d0408488a87614d4f63ba9c44f3e52db541d6b7cc7
F test/fts4opt.test 0fd0cc84000743ff2a883b9b84b4a5be07249f0ba790c8848a757164cdd46b2a
F test/fts4record.test a48508f69a84c9287c8019d3a1ae712f5730d8335ffaf8e2101e691d078950bb
@@ -1045,21 +1050,21 @@ F test/fts4umlaut.test fcaca4471de7e78c9d1f7e8976e3e8704d7d8ad979d57a739d00f3f75
F test/fts4unicode.test 82a9c16b68ba2f358a856226bb2ee02f81583797bc4744061c54401bf1a0f4c9
F test/fts4upfrom.test f25835162c989dffd5e2ef91ec24c4848cc9973093e2d492d1c7b32afac1b49d
F test/full.test 6b3c8fb43c6beab6b95438c1675374b95fab245d
-F test/func.test 3a65ddb6c1998f71aa86492501a6be87904197e62bfb5b70b2493552b558abd1
+F test/func.test 4be8bed4be235e333f1e0ea31e32f5be3c9f456c30780363e7fcb15e3ff3e6bc
F test/func2.test 772d66227e4e6684b86053302e2d74a2500e1e0f
F test/func3.test 600a632c305a88f3946d38f9a51efe145c989b2e13bd2b2a488db47fe76bab6a
F test/func4.test 2285fb5792d593fef442358763f0fd9de806eda47dbc7a5934df57ffdc484c31
F test/func5.test 863e6d1bd0013d09c17236f8a13ea34008dd857d87d85a13a673960e4c25d82a
F test/func6.test 90e42b64c4f9fb6f04f44cb8a1da586c8542502e926b19c76504fe74ff2a9b7c
F test/func7.test b9e2a1a30a8562b00841b4a21a5d2d81754fa3ab99275fd71fd5279287b44b1c
-F test/fuzz-oss1.test e58330d01cbbd8215ee636b17a03fe220b37dbfa
-F test/fuzz.test 96083052bf5765e4518c1ba686ce2bab785670d1
+F test/fuzz-oss1.test 514dcabb24687818ea949fa6760229eaacad74ca70157743ef36d35bbe01ffb0
+F test/fuzz.test 4608c1310cff4c3014a84bcced6278139743e080046e5f6784b0de7b069371d8
F test/fuzz2.test 76dc35b32b6d6f965259508508abce75a6c4d7e1
F test/fuzz3.test 9c813e6613b837cb7a277b0383cd66bfa07042b4cf0317157c35852f30043c31
F test/fuzz4.test c229bcdb45518a89e1d208a21343e061503460ac69fae1539320a89f572eb634
F test/fuzz_common.tcl b7197de6ed1ee8250a4f82d67876f4561b42ee8cbbfc6160dcb66331bad3f830
F test/fuzz_malloc.test f348276e732e814802e39f042b1f6da6362a610af73a528d8f76898fde6b22f2
-F test/fuzzcheck.c bdb852815048a0beebbe5768bca61e75295324a811a8d7216f97b96501befd1e
+F test/fuzzcheck.c e34696a5db46738118b2efd14fb71f8458ecf0f482df8bbae18fa1d64db9ab7b
F test/fuzzdata1.db d36e88741b4f23bcbaaf55b006290669d03c6c891cf13c7b3a53bc1b097b693f
F test/fuzzdata2.db 128b3feeb78918d075c9b14b48610145a0dd4c8d6f1ca7c2870c7e425f5bf31f
F test/fuzzdata3.db c6586d3e3cef0fbc18108f9bb649aa77bfc38aba
@@ -1067,7 +1072,7 @@ F test/fuzzdata4.db b502c7d5498261715812dd8b3c2005bad08b3a26e6489414bd13926cd3e4
F test/fuzzdata5.db e35f64af17ec48926481cfaf3b3855e436bd40d1cfe2d59a9474cb4b748a52a5
F test/fuzzdata6.db 92a80e4afc172c24f662a10a612d188fb272de4a9bd19e017927c95f737de6d7
F test/fuzzdata7.db 0166b56fd7a6b9636a1d60ef0a060f86ddaecf99400a666bb6e5bbd7199ad1f2
-F test/fuzzdata8.db ef4d280ee69d6da0ebda7f81c0c66839fa577a97b29cc5790a564fde88be7183
+F test/fuzzdata8.db ca9a97f401b06b0d5376139ec7e1f9e773e13345a9a2d9ccc0032cdbfedea230
F test/fuzzer1.test 3d4c4b7e547aba5e5511a2991e3e3d07166cfbb8
F test/fuzzer2.test a85ef814ce071293bce1ad8dffa217cbbaad4c14
F test/fuzzerfault.test f64c4aef4c9e9edf1d6dc0d3f1e65dcc81e67c996403c88d14f09b74807a42bc
@@ -1082,7 +1087,7 @@ F test/hook2.test b9ff3b8c6519fb67f33192f1afe86e7782ee4ac8
F test/icu.test 716a6b89fbabe5cc63e0cd4c260befb08fd7b9d761f04d43669233292f0753b1
F test/ieee754.test b0945d12be7d255f3dfa18e2511b17ca37e0edd2b803231c52d05b86c04ab26e
F test/imposter1.test c3f1db2d3db2c24611a6596a3fc0ffc14f1466c8
-F test/in.test 688ed2011d922d83141a45af431601738674a4c0bdde34b6351f688b82a169b3
+F test/in.test 15de58ee017f43d36390812e9a51217d1b2db7758f97d0df48296ef178ea560b
F test/in2.test 5d4c61d17493c832f7d2d32bef785119e87bde75
F test/in3.test 3cbf58c87f4052cee3a58b37b6389777505aa0c0
F test/in4.test fdd1d8134da8376985c2edba6035a2de1f6c731524d2ffa651419e8fe2cd1c5a
@@ -1099,7 +1104,7 @@ F test/incrvacuum.test 3fa6145f5e71f603554fd7b8ec3da4290b1341029682313285cb5f9e1
F test/incrvacuum2.test 7d26cfda66c7e55898d196de54ac4ec7d86a4e3d
F test/incrvacuum3.test 75256fb1377e7c39ef2de62bfc42bbff67be295a
F test/incrvacuum_ioerr.test 6ae2f783424e47a0033304808fe27789cf93e635
-F test/index.test a2e948ed949e575487b5c1d521767d4584ac42d352f2dcd8e48004638e7bc7dc
+F test/index.test d866054c88b394fd42cbf2825628f127ca24dfac525fa019069a936674d92cbe
F test/index2.test f835d5e13ca163bd78c4459ca15fd2e4ed487407
F test/index3.test 51685f39345462b84fcf77eb8537af847fdf438cc96b05c45d6aaca4e473ade0
F test/index4.test ab92e736d5946840236cd61ac3191f91a7856bf6
@@ -1116,7 +1121,7 @@ F test/init.test 15c823093fdabbf7b531fe22cf037134d09587a7
F test/insert.test 4e3f0de67aac3c5be1f4aaedbcea11638f1b5cdc9a3115be14d19aa9db7623c6
F test/insert2.test 4d14b8f1b810a41995f6286b64a6943215d52208
F test/insert3.test 1b7db95a03ad9c5013fdf7d6722b6cd66ee55e30
-F test/insert4.test 59cb99521be01a5aefc9be8e8b5a51ee7f3944781d4d7f6201b9f774fcd51662
+F test/insert4.test 2bf81535a990c969665d66db51fcf76c23499b39893b5109f413d1de4ad34cd3
F test/insert5.test 394f96728d1258f406fe5f5aeb0aaf29487c39a6
F test/insertfault.test ac63d14ea3b49c573673a572f4014b9117383a03e497c58f308b5c776e4a7f74
F test/instr.test 107df2b9b74a4b59315916b575590a08f2a714de0754abe541f10a0971d0a2a4
@@ -1134,11 +1139,11 @@ F test/ioerr4.test f130fe9e71008577b342b8874d52984bd04ede2c
F test/ioerr5.test 2edfa4fb0f896f733071303b42224df8bedd9da4
F test/ioerr6.test a395a6ab144b26a9e3e21059a1ab6a7149cca65b
F test/istrue.test e7f285bb70282625c258e866ce6337d4c762922f5a300e1b50f958aef6e7d9c9
-F test/join.test 25da4f53523a4aa17c893134b47fba6aa4799bb33350517b157785878290e238
+F test/join.test 25cf0ac11c3b81fedfd166f9062166bdb39dea92f5a7c16cacbf6dc1f7f67020
F test/join2.test 9bdc615841b91c97a16d68bad9508aea11fa0c6b34e5689847bcc4dac70e4990
F test/join3.test 6f0c774ff1ba0489e6c88a3e77b9d3528fb4fda0
F test/join4.test 1a352e4e267114444c29266ce79e941af5885916
-F test/join5.test f418fccdfefa41f1659663463aa517431ddcf3e30ccbb80e64173b7d615a03f4
+F test/join5.test 3d51c4ae5f1f373a03164ca3c88d438f64bed7a2c01cf69810e2ca3d0e9071c8
F test/join6.test f809c025fa253f9e150c0e9afd4cef8813257bceeb6f46e04041228c9403cc2c
F test/journal1.test c7b768041b7f494471531e17abc2f4f5ebf9e5096984f43ed17c4eb80ba34497
F test/journal2.test 9dac6b4ba0ca79c3b21446bbae993a462c2397c4
@@ -1146,11 +1151,11 @@ F test/journal3.test 7c3cf23ffc77db06601c1fcfc9743de8441cb77db9d1aa931863d94f5ff
F test/jrnlmode.test 9b5bc01dac22223cb60ec2d5f97acf568d73820794386de5634dcadbea9e1946
F test/jrnlmode2.test 8759a1d4657c064637f8b079592651530db738419e1d649c6df7048cd724363d
F test/jrnlmode3.test 556b447a05be0e0963f4311e95ab1632b11c9eaa
-F test/json101.test bb71538005f2d9e18620bdd3b76839a93ca0be61903eb8d751a64e78cf99b8fb
-F test/json102.test eeb54efa221e50b74a2d6fb9259963b48d7414dca3ce2fdfdeed45cb28487bc1
-F test/json103.test aff6b7a4c17d5a20b487a7bc1a274bfdc63b829413bdfb83bedac42ec7f67e3b
-F test/json104.test 2cb7ff2cca2c8214d3e5260eeb9ce45faec0926f68b3e40c1aaa6ca247284144
-F test/json105.test 45f7d6a9a54c85f8a9589b68d3e7a1f42d02f2359911a8cdbad1f9988f571173
+F test/json101.test d7c84854acafaf80f883e183ac4248ea2742615086c94a61a46ad7d7382ce123
+F test/json102.test 327e77275f338c028faefa2da5164daf6b142a165e3015ff2a6e4251ddc6a0ac
+F test/json103.test 53df87f83a4e5fa0c0a56eb29ff6c94055c6eb919f33316d62161a8880112dbe
+F test/json104.test a502dc01853aada95d721b3b275afbe2dc18fffdac1fea6e96fb20c13586bbb5
+F test/json105.test 11670a4387f4308ae0318cadcbd6a918ea7edcd19fbafde020720a073952675d
F test/keyword1.test 37ef6bba5d2ed5b07ecdd6810571de2956599dff
F test/kvtest.c feb4358fb022da8ebd098c45811f2f6507688bb6c43aa72b3e840df19026317b
F test/lastinsert.test 42e948fd6442f07d60acbd15d33fb86473e0ef63
@@ -1203,14 +1208,16 @@ F test/mem5.test c6460fba403c5703141348cd90de1c294188c68f
F test/memdb.test c1f2a343ad14398d5d6debda6ea33e80d0dafcc7
F test/memdb1.test 2c4e9cc10d21c6bf4e217d72b7f6b8ba9b2605971bb2c5e6df76018e189f98f5
F test/memjournal.test 70f3a00c7f84ee2978ad14e831231caa1e7f23915a2c54b4f775a021d5740c6c
+F test/memjournal2.test 89a4e0d1084170a281efa4d54c2677599f986f44227f98f7dfae282802737b65
F test/memleak.test 10b9c6c57e19fc68c32941495e9ba1c50123f6e2
F test/memsubsys1.test 9e7555a22173b8f1c96c281ce289b338fcba2abe8b157f8798ca195bbf1d347e
F test/memsubsys2.test 3e4a8d0c05fd3e5fa92017c64666730a520c7e08
+F test/merge1.test 0ade470d77b689c4a64dc7f736527fcd893140bcafa70af8f7b98523cfb83f16
F test/minmax.test fe638b55d77d2375531a8f549b338eafcd9adfbd2f72df37ed77d9b26ca0a71a
F test/minmax2.test cf9311babb6f0518d04e42fd6a42c619531c4309a9dd790a2c4e9b3bc595e0de
F test/minmax3.test cc1e8b010136db0d01a6f2a29ba5a9f321034354
F test/minmax4.test 272ca395257f05937dc96441c9dde4bc9fbf116a8d4fa02baeb0d13d50e36c87
-F test/misc1.test e3fa5732080cc9a2b77bd5dd4ebb55bd6785b02565f8806092686b83ac58d600
+F test/misc1.test 294c97185354030c4ce40e7141b72f7a589585f2a44b666825381eb3df98f07c
F test/misc2.test 71e746af479119386ac2ed7ab7d81d99970e75b49ffd3e8efffee100b4b5f350
F test/misc3.test cf3dda47d5dda3e53fc5804a100d3c82be736c9d
F test/misc4.test 10cd6addb2fa9093df4751a1b92b50440175dd5468a6ec84d0386e78f087db0e
@@ -1265,7 +1272,7 @@ F test/oserror.test 1fc9746b83d778e70d115049747ba19c7fba154afce7cc165b09feb6ca6a
F test/ossfuzz.c 9636dad2092a05a32110df0ca06713038dd0c43dd89a77dabe4b8b0d71096715
F test/ossshell.c f125c5bd16e537a2549aa579b328dd1c59905e7ab1338dfc210e755bb7b69f17
F test/ovfl.test 199c482696defceacee8c8e0e0ef36da62726b2f
-F test/pager1.test 8cb45ccbdb3ba423fc8158701c8f010a1d104336b8f14ef14bbfbadf14bad700
+F test/pager1.test ffd885cdc98b986c9f746496508c0c4810ed0eaade3575ddf53c222e85880552
F test/pager2.test 67b8f40ae98112bcdba1f2b2d03ea83266418c71
F test/pager3.test 4e9a83d6ca0838d7c602c9eb93d1357562d9059c1e02ffb138a8271020838370
F test/pager4.test a122e9e6925d5b23b31e3dfef8c6a44bbf19590e
@@ -1288,7 +1295,7 @@ F test/pragma5.test 7b33fc43e2e41abf17f35fb73f71b49671a380ea92a6c94b6ce530a25f8d
F test/pragmafault.test 275edaf3161771d37de60e5c2b412627ac94cef11739236bec12ed1258b240f8
F test/prefixes.test b524a1c44bffec225b9aec98bd728480352aa8532ac4c15771fb85e8beef65d9
F test/printf.test 390d0d7fcffc3c4ea3c1bb4cbb267444e32b33b048ae21895f23a291844fe1da
-F test/printf2.test 30b5dd0b4b992dc5626496846ecce17ff592cacbcb11c3e589f3ac4d7e129dae
+F test/printf2.test 3f55c1871a5a65507416076f6eb97e738d5210aeda7595a74ee895f2224cce60
F test/progress.test ebab27f670bd0d4eb9d20d49cef96e68141d92fb
F test/ptrchng.test ef1aa72d6cf35a2bbd0869a649b744e9d84977fc
F test/pushdown.test 5e72c51c5e33253ed639ccee1e01ce62d62b6eee5ca893cd82334e4ee7b1d7fc
@@ -1297,7 +1304,7 @@ F test/quick.test 1681febc928d686362d50057c642f77a02c62e57
F test/quota-glob.test 32901e9eed6705d68ca3faee2a06b73b57cb3c26
F test/quota.test bfb269ce81ea52f593f9648316cd5013d766dd2a
F test/quota2.test 7dc12e08b11cbc4c16c9ba2aa2e040ea8d8ab4b8
-F test/quote.test f33f95990e4032d1227b98c0ef314c0a077d162f3f2e61b3039ed69e6f8adbbf
+F test/quote.test ffb40f0eb7a25c1d8cfe11ee2fe67f8e85fbf3fed348810834114be1fdada142
F test/randexpr1.tcl 40dec52119ed3a2b8b2a773bce24b63a3a746459
F test/randexpr1.test eda062a97e60f9c38ae8d806b03b0ddf23d796df
F test/rbu.test 168573d353cd0fd10196b87b0caa322c144ef736
@@ -1306,10 +1313,11 @@ F test/recover.test ccb8c2623902a92ebb76770edd075cb4f75a4760bb7afde38026572c6e79
F test/regexp1.test 0c3ff80f66b0eff80e623eb5db7a3dad512095c573d78ac23009785f6d8f51ce
F test/regexp2.test 55ed41da802b0e284ac7e2fe944be3948f93ff25abbca0361a609acfed1368b5
F test/reindex.test cd9d6021729910ece82267b4f5e1b5ac2911a7566c43b43c176a6a4732e2118d
-F test/releasetest_data.tcl 7cea6c852ae6bb3a9ff1a2b910e4dd13c16a05f74443984dfd52159b0b01ea55
+F test/releasetest_data.tcl 11ba48a21ed1c808147b0e77c6e93d204577f4327ffe6d7c3b34cd3c01eac3a2
F test/resetdb.test 8062cf10a09d8c048f8de7711e94571c38b38168db0e5877ba7561789e5eeb2b
F test/resolver01.test f4022acafda7f4d40eca94dbf16bc5fc4ac30ceb
-F test/returning1.test f96c7245f6ac16038e802760cd90b93479369939a8a7a44e2329ee5aed28239c
+F test/returning1.test c43b8370a351f77aec6d71f4a2cde59b849369ed1933261a2c2c69e23e34ff5e
+F test/returningfault.test ae4c4b5e8745813287a359d9ccdb9d5c883c2e68afb18fb0767937d5de5692a4
F test/rollback.test 06680159bc6746d0f26276e339e3ae2f951c64812468308838e0a3362d911eaa
F test/rollback2.test 3f3a4e20401825017df7e7671e9f31b6de5fae5620c2b9b49917f52f8c160a8f
F test/rollbackfault.test 0e646aeab8840c399cfbfa43daab46fd609cf04a
@@ -1317,11 +1325,11 @@ F test/round1.test 768018b04522ca420b1aba8a24bd76091d269f3bce3902af3ec6ebcee41ab
F test/rowallock.test 3f88ec6819489d0b2341c7a7528ae17c053ab7cc
F test/rowhash.test 0bc1d31415e4575d10cacf31e1a66b5cc0f8be81
F test/rowid.test e29025be95baf6b32f0d5edef59a7633028325896a98f1caa8019559ca910350
-F test/rowvalue.test 37effea4dd83555ea969a9461dfcffb25e6731a5db7c388e232410999c100853
+F test/rowvalue.test 228b312f8526ed000ecda559a6a9adf30aa2d79dcb12afa5c04eebaafcf55eae
F test/rowvalue2.test 060d238b7e5639a7c5630cb5e63e311b44efef2b
F test/rowvalue3.test 3068f508753af69884b12125995f023da0dbb256
F test/rowvalue4.test 441e7e366ac6d939a3a95a574031c56ec2a854077a91d66eee5ff1d86cb5be58
-F test/rowvalue5.test c81c7d8cf36711ab37675ad7376084ae2a359cb6
+F test/rowvalue5.test 00740304ea6a53a8704640c7405690f0045d5d2a6b4b04dde7bccc14c3068ea7
F test/rowvalue6.test d19b54feb604d5601f8614b15e214e0774c01087
F test/rowvalue7.test c1cbdbf407029db01f87764097c6ac02a1c5a37efd2776eff32a9cdfdf6f2dba
F test/rowvalue8.test 5900eddad9e2c3c2e26f1a95f74aafc1232ee5e0
@@ -1353,7 +1361,7 @@ F test/select2.test 352480e0e9c66eda9c3044e412abdf5be0215b56
F test/select3.test c49fbb758903f3718e2de5aa4655eda4838131cbea24a86db908f8b6889aa68c
F test/select4.test f0684d3da3bccacbe2a1ebadf6fb49d9df6f53acb4c6ebc228a88d0d6054cc7b
F test/select5.test 8afc5e5dcdebc2be54472e73ebd9cd1adef1225fd15d37a1c62f969159f390ae
-F test/select6.test 319d45e414cdd321bf17cfacedaf19e3935ad64dac357c53f1492338c6e9b801
+F test/select6.test 9b2fb4ffedf52e1b5703cfcae1212e7a4a063f014c0458d78d29aca3db766d1f
F test/select7.test f659f231489349e8c5734e610803d7654207318f
F test/select8.test 8c8f5ae43894c891efc5755ed905467d1d67ad5d
F test/select9.test f7586b207ce2304ab80dc93d3146469a28fd4403621dd3a82d06644563d3c812
@@ -1380,11 +1388,11 @@ 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 c354008b27c904f0166c2138abd7382013ea070b41114114ecbdfb32c726a807
-F test/shell2.test f00a0501c00583cbc46f7510e1d713366326b2b3e63d06d15937284171a8787c
-F test/shell3.test cb4b835a901742c9719437a89171172ecc4a8823ad97349af8e4e841e6f82566
-F test/shell4.test 3ed6c4b42fd695efcbc25d69ef759dbb15855ca8e52ba6c5ee076f8b435f48be
-F test/shell5.test 6e4aa0e531dcb8dcf74b7920a2a7442c6712d4dff8422bbc81f768f9dee8a0e3
+F test/shell1.test b224e0793c5f48aa3749e65d8c64b93a30731bd206f2e41e6c5f1bee1bdb16c6
+F test/shell2.test 89e4b2db062d52baed75022227b462d085cff495809de1699652779d8e0257d6
+F test/shell3.test a50628ab1d78d90889d9d3f32fb2c084ee15674771e96afe954aaa0accd1de3c
+F test/shell4.test 8f6c0fce4abed19a8a7f7262517149812a04caa905d01bdc8f5e92573504b759
+F test/shell5.test 0a9920d81fae28c45cd5dbd1deb809487a23c5f4b422a49f9d31c85f926d4a9c
F test/shell6.test 1ceb51b2678c472ba6cf1e5da96679ce8347889fe2c3bf93a0e0fa73f00b00d3
F test/shell7.test 115132f66d0463417f408562cc2cf534f6bbc6d83a6d50f0072a9eb171bae97f
F test/shell8.test 388471d16e4de767333107e30653983f186232c0e863f4490bb230419e830aae
@@ -1434,16 +1442,16 @@ F test/stat.test 123212a20ceb496893d5254a5f6c76442ce549fdc08d1702d8288a2bbaac840
F test/statfault.test 55f86055f9cd7b2d962a621b8a04215c1cebd4eaaecde92d279442327fe648a0
F test/stmt.test 54ed2cc0764bf3e48a058331813c3dbd19fc1d0827c3d8369914a5d8f564ec75
F test/stmtvtab1.test 6873dfb24f8e79cbb5b799b95c2e4349060eb7a3b811982749a84b359468e2d5
-F test/strict1.test a3ec495471f24c1a6e1a1664bd23e24ccdb27ae93b1a763ee1942ec955b68e71
+F test/strict1.test 4d2b492152b984fd7e8196d23eb88e2ccb0ef9e46ca2f96c2ce7147ceef9d168
F test/strict2.test b22c7a98b5000aef937f1990776497f0e979b1a23bc4f63e2d53b00e59b20070
F test/subjournal.test 8d4e2572c0ee9a15549f0d8e40863161295107e52f07a3e8012a2e1fdd093c49
-F test/subquery.test d7268d193dd33d5505df965399d3a594e76ae13f
+F test/subquery.test 3a1a5b600b8d4f504d2a2c61f33db820983dba94a0ef3e4aedca8f0165eaecb8
F test/subquery2.test 90cf944b9de8204569cf656028391e4af1ccc8c0cc02d4ef38ee3be8de1ffb12
F test/subselect.test 0966aa8e720224dbd6a5e769a3ec2a723e332303
F test/substr.test a673e3763e247e9b5e497a6cacbaf3da2bd8ec8921c0677145c109f2e633f36b
F test/subtype1.test 7fe09496352f97053af1437150751be2d0a0cae8
F test/superlock.test ec94f0556b6488d97f71c79f9061ae08d9ab8f12
-F test/swarmvtab.test 9a3fd5ab3e9b3c976ad1b3d7646aab725114f2ac26b59395d0778b33bab6cdaf
+F test/swarmvtab.test 250231404fcac88f61a6c147bb0e3a118ed879278cd3ccb0ae2d3a729e1e8e26
F test/swarmvtab2.test c948cb2fdfc5b01d85e8f6d6504854202dc1a0782ab2a0ed61538f27cbd0aa5c
F test/swarmvtab3.test 247aa38b6ebd2b99db2075847ae47e789ac34f1c2ab5c720dfcffd990004c544
F test/swarmvtabfault.test 8a67a9f27c61073a47990829e92bc0c64420a807cb642b15a25f6c788210ed95
@@ -1453,11 +1461,11 @@ F test/sync.test 89539f4973c010eda5638407e71ca7fddbcd8e0594f4c9980229f804d433309
F test/sync2.test 8f9f7d4f6d5be8ca8941a8dadcc4299e558cb6a1ff653a9469146c7a76ef2039
F test/syscall.test a39d9a36f852ae6e4800f861bc2f2e83f68bbc2112d9399931ecfadeabd2d69d
F test/sysfault.test c9f2b0d8d677558f74de750c75e12a5454719d04
-F test/tabfunc01.test d6821e7042e5653104dac0c63d75eff24a2415ab1889fc68b5db7fde59464c59
+F test/tabfunc01.test 241425ce3998687ab24adba09cb95e8012e17499b84a0ed47e128ab45e588bef
F test/table.test eb3463b7add9f16a5bb836badf118cf391b809d09fdccd1f79684600d07ec132
F test/tableapi.test ecbcc29c4ab62c1912c3717c48ea5c5e59f7d64e4a91034e6148bd2b82f177f4
F test/tableopts.test dba698ba97251017b7c80d738c198d39ab747930
-F test/tclsqlite.test 97cda6e4843e9f3e06c56f656d9b77ee0178fe1ee33fb09a6eeae8f125757ac1
+F test/tclsqlite.test ad0bbd92edabe64cc91d990a0748142fe5ab962d74ac71fa3bfa94d50d2f4c87
F test/tempdb.test 4cdaa23ddd8acb4d79cbb1b68ccdfd09b0537aaba909ca69a876157c2a2cbd08
F test/tempdb2.test 353864e96fd3ae2f70773d0ffbf8b1fe48589b02c2ec05013b540879410c3440
F test/tempfault.test 0c0d349c9a99bf5f374655742577f8712c647900
@@ -1505,7 +1513,7 @@ F test/tkt-6bfb98dfc0.test 24780633627b5cfc0635a5500c2389ebfb563336
F test/tkt-752e1646fc.test ea78d88d14fe9866bdd991c634483334639e13bf
F test/tkt-78e04e52ea.test b731f2ab7d1c2482ac5152097da02ef4805a45147ba9498d3cd9da27072f34d1
F test/tkt-7a31705a7e6.test 9e9c057b6a9497c8f7ba7b16871029414ccf6550e7345d9085d6d71c9a56bb6f
-F test/tkt-7bbfb7d442.test 7b2cd79c7a17ae6750e75ec1a7846712a69c9d18
+F test/tkt-7bbfb7d442.test e87b59e620700b5a52ecd92f05d56686c1cad9e1aa17456eada55e0bb821b698
F test/tkt-80ba201079.test 105a721e6aad0ae3c5946d7615d1e4d03f6145b8
F test/tkt-80e031a00f.test 9ee36348b761bf7c14261e002b75a4c0d5a04d4c
F test/tkt-8454a207b9.test aff2e76143cfa443ddce6f7d85968a2e9b57a3deb0b881b730120740555f9e2f
@@ -1588,7 +1596,7 @@ F test/tkt3346.test 6f67c3ed7db94dfc5df4f5f0b63809a1f611e01a
F test/tkt3357.test 77c37c6482b526fe89941ce951c22d011f5922ed
F test/tkt3419.test 1bbf36d7ea03b638c15804251287c2391f5c1f6b
F test/tkt3424.test 61f831bd2b071bd128fa5d00fbda57e656ca5812
-F test/tkt3442.test 6287173de5bb2d43693b1f822426018a209f9df49ce2f454808bac1771852330
+F test/tkt3442.test c9d95b4c8f4f35a51b523f35d2afd0ce124937812af296545ad551ff763504fd
F test/tkt3457.test 5651e2cbb94645b677ec663160b9e192b87b7d365aecdfb24e19f749575a6fc2
F test/tkt3461.test 228ea328a5a21e8663f80ee3d212a6ad92549a19
F test/tkt3493.test 1686cbde85f8721fc1bdc0ee72f2ef2f63139218
@@ -1612,7 +1620,7 @@ F test/tkt3810.test 3a3be9965d1861bd84019875851ad5ea90fd8d76b638361514a36a48ea53
F test/tkt3824.test 150aa00bb6220672e5f0eb14dc8eaa36750425f0
F test/tkt3832.test 2300d10d57562b89875b72148338ac3e14f8847d
F test/tkt3838.test 292e72489101cd1320d7278dc111c173ebf334d4
-F test/tkt3841.test 4659845bc53f809a5932c61c6ce8c5bb9d6b947f
+F test/tkt3841.test c4be3870f777f82aa788a588e40b4fb6627c3874e19f336d0d92894f929ffbfe
F test/tkt3871.test d921703d07c68f4fd5312073215a17fa34b0401d
F test/tkt3879.test 2ad5bef2c87e9991ce941e054c31abe26ef7fb90
F test/tkt3911.test 74cd324f3ba653040cc6d94cc4857b290d12d633
@@ -1632,7 +1640,7 @@ F test/trans.test 45f6f9ab6f66a7b5744f1caac06b558f95da62501916906cf55586a896f9f4
F test/trans2.test 62bd045bfc7a1c14c5ba83ba64d21ade31583f76
F test/trans3.test 91a100e5412b488e22a655fe423a14c26403ab94
F test/transitive1.test f8ee983600b33d167da1885657f064aec404e1c0d0bc8765fdf163f4c749237a
-F test/trigger1.test d30cd09ae8ac365a088f09daba583cc5c0b8fc7d4e1d70809d0b4be3bf6ae2ab
+F test/trigger1.test 02cc64dc98278816c1c1ed8e472e18db8edbad88f37018bf46223e9614831963
F test/trigger2.test 6e35bd7321c49e63d540aee980eb95dec63e1d1caca175224101045bcc80871f
F test/trigger3.test aa640bb2bbb03edd5ff69c055117ea088f121945
F test/trigger4.test 74700b76ebf3947b2f7a92405141eb2cf2a5d359
@@ -1668,7 +1676,7 @@ F test/unique.test 93f8b2ef5ea51b9495f8d6493429b1fd0f465264
F test/unique2.test 3674e9f2a3f1fbbfd4772ac74b7a97090d0f77d2
F test/unixexcl.test d936ba2b06794018e136418addd59a2354eeae97
F test/unordered.test 0edaf3411d300693bca595897c5201421c6c5ec787990a1dfe2f7f60ae93f1e2
-F test/update.test ef3ebbafeb4be5c96db831f40796e2e77ee846da5ee8b61cfedb1ff1b9e0cc23
+F test/update.test eb7f4eb172ce270e51bb67d7867521f33a63635bb671e261bbafccaef3bd6db2
F test/update2.test 67455bc61fcbcf96923c45b3bc4f87bc72be7d67575ad35f134906148c7b06d3
F test/upfrom1.tcl 8859d9d437f03b44174c4524a7a734a391fd4526fcff65be08285dafc9dc9041
F test/upfrom1.test 8cb06689e99cd707d884faa16da0e8eb26ff658bb01c47ddf72fadade666e6e1
@@ -1676,7 +1684,7 @@ F test/upfrom2.test 88d39cb755db5789541e645d4e2764abc697a56958f28a3f8451a0e9342b
F test/upfrom3.test 6130f24ebf97f5ea865e5d2a14a2d543fe5428a62e87cc60f62d875e45c1f5f0
F test/upfromfault.test 3a10075a0043f0c4fad6614b2c371f88a8ba5a4acab68b907438413865d6a8d6
F test/upsert1.test b0ae2f58680c5205b4bc1cdeed3c3d444057c506f6c44494fa3eac60731d68a2
-F test/upsert2.test 9c3cdbb1a890227f6504ce4b0e3de68f4cdfa16bb21d8641208a9239896c5a09
+F test/upsert2.test 720e94d09f7362a282bc69b3c6b83d51daeaaf0440eb4920a08b86518b8c7496
F test/upsert3.test 88d7d590a1948a9cb6eac1b54b0642f67a9f35a1fc0f19b200e97d5d39e3179c
F test/upsert4.test 25d2a1da92f149331ae0c51ca6e3eee78189577585eab92de149900d62994fa5
F test/upsert5.test fff0dcfce73c649204543088d8e5bde01172676063ec9b8f8fc7f195abc386fe
@@ -1684,7 +1692,7 @@ F test/upsertfault.test f21ca47740841fdb4d61acfa7b17646d773e67724fe8c185b71c018d
F test/uri.test 3481026f00ade6dfe8adb7acb6e1e47b04369568
F test/uri2.test 9d3ba7a53ee167572d53a298ee4a5d38ec4a8fb7
F test/userauth01.test e740a2697a7b40d7c5003a7d7edaee16acd349a9
-F test/utf16align.test 54cd35a27c005a9b6e7815d887718780b6a462ae
+F test/utf16align.test 9fde0bb5d3a821594aa68c6829ab9c5453a084384137ebb9f6153e2d678039da
F test/vacuum-into.test f0b8c091df5305728b6973e9cce4166c861955b650dd3c599cb045d7160d3971
F test/vacuum.test ce91c39f7f91a4273bf620efad21086b5aa6ef1d
F test/vacuum2.test 9fd45ce6ce29f5614c249e03938d3567c06a9e772d4f155949f8eafe2d8af520
@@ -1702,7 +1710,7 @@ F test/vtab2.test 14d4ab26cee13ba6cf5c5601b158e4f57552d3b055cdd9406cf7f711e9c840
F test/vtab3.test b45f47d20f225ccc9c28dc915d92740c2dee311e
F test/vtab4.test 8e73ed268f3d596bc3590f45fc948fb40f28e9c3
F test/vtab5.test 889f444970393c73f1e077e2bdc5d845e157a391
-F test/vtab6.test 8e789f526e6594cf7ae933d1adee0caa87dc9f78
+F test/vtab6.test 82d5bb8fd3c0643102c1209e9ea353b168b7eb9c8db4406ab2ee2cbbdaead62c
F test/vtab7.test 70c6f4a1d6177144a8236e4172d5fba92e683440374664ad1f04851fbb335d3c
F test/vtab8.test e19fa4a538fcd1bb66c22825fa8f71618fb13583
F test/vtab9.test ea58d2b95d61955f87226381716b2d0b1d4e4f9b
@@ -1719,7 +1727,9 @@ F test/vtabK.test 13293177528fada1235c0112db0d187d754af1355c5a39371abd365104e3af
F test/vtab_alter.test 736e66fb5ec7b4fee58229aa3ada2f27ec58bc58c00edae4836890c3784c6783
F test/vtab_err.test dcc8b7b9cb67522b3fe7a272c73856829dae4ab7fdb30399aea1b6981bda2b65
F test/vtab_shared.test 5253bff2355a9a3f014c15337da7e177ab0ef8ad
+F test/vtabdistinct.test 7688f0889358f849fd60bbfde1ded38b014b18066076d4bfbb75395804dfe072
F test/vtabdrop.test 65d4cf6722972e5499bdaf0c0d70ee3b8133944a4e4bc31862563f32a7edca12
+F test/vtabrhs1.test 9b5ecbc74a689500c33a4b2b36761f9bcc22fcc4e3f9d21066ee0c9c74cf5f6c
F test/wal.test b7cc6984709f54afbf8441747ced1f646af120bf0c1b1d847bfa39306fbea089
F test/wal2.test 31f6e2c404b9f2cdf9ca19b105a1742fdc19653c2c936da39e3658c617524046
F test/wal3.test 2a93004bc0fb2b5c29888964024695bade278ab2
@@ -1749,7 +1759,7 @@ F test/walpersist.test 8c6b7e3ec1ba91b5e4dc4e0921d6d3f87cd356a6
F test/walprotocol.test 1b3f922125e341703f6e946d77fdc564d38fb3e07a9385cfdc6c99cac1ecf878
F test/walprotocol2.test 7d3b6b4bf0b12f8007121b1e6ef714bc99101fb3b48e46371df1db868eebc131
F test/walro.test cb438d05ba0d191f10b688e39c4f0cd5b71569a1d1f4440e5bdf3c6880e08c20
-F test/walro2.test 0e79dd15cbdb4f482c01ea248373669c732414a726b357d04846a816afafb768
+F test/walro2.test 33955a6fd874dd9724005e17f77fef89d334b3171454a1256fe4941a96766cdc
F test/walrofault.test c70cb6e308c443867701856cce92ad8288cd99488fa52afab77cca6cfd51af68
F test/walsetlk.test 3185bebc90557e0d611442c8d64f7a0cb7b06f8e156eea37a4a7358f722715be
F test/walshared.test 0befc811dcf0b287efae21612304d15576e35417
@@ -1764,7 +1774,7 @@ F test/where3.test 5b4ffc0ac2ea0fe92f02b1244b7531522fe4d7bccf6fa8741d54e82c10e67
F test/where4.test 4a371bfcc607f41d233701bdec33ac2972908ba8
F test/where5.test fdf66f96d29a064b63eb543e28da4dfdccd81ad2
F test/where6.test 5da5a98cec820d488e82708301b96cb8c18a258b
-F test/where7.test ab41d53ce8f2a6919ea3d5b13cd1153c1375a8e3ddaa129b81781f9033981383
+F test/where7.test 1c1bf436bf31b913d4764a2b62ac6e98b9681e5c7ae2b562605592a56b7e946b
F test/where8.test 461ca40265ed996a6305da99bb024b0e41602bb586acf544c08f95922358e49f
F test/where9.test 1ffb75edc50a8faa6e7bd77f8221d783febb00b44b0bdb32fb48cec6e38eca95
F test/whereA.test 9d1077b117f1b68d5f739d94f36956c36cf995eb87bb19b77b2e81af020edd20
@@ -1796,7 +1806,7 @@ F test/window3.test e9959a993c8a71e96433be8daaa1827d78b8921e4f12debd7bdbeb3c856e
F test/window4.tcl 6f85307eb67242b654d051f7da32a996a66aee039a09c5ae358541aa61720742
F test/window4.test fbead87f681400ac07ef3555e0488b544a47d35491f8bf09a7474b6f76ce9b4e
F test/window5.test d328dd18221217c49c144181975eea17339eaeaf0e9aa558cee3afb84652821e
-F test/window6.test f8d674254b23289cc17c84d79dec7eda7caa1dfb7836c43122cfdf3640d1df32
+F test/window6.test 311de885bd7e453134fa6747680bfb4a1be87c91720bf58703db945891e7d30b
F test/window7.tcl 6a1210f05d40ec89c22960213a22cd3f98d4e2f2eb20646c83c8c30d4d76108f
F test/window7.test 1d31276961ae7801edc72173edaf7593e3cbc79c06d1f1f09e20d8418af403cd
F test/window8.tcl 5e02e41d9d9a80f597063aed1a381eb19d1d0ef677a4f0df352c5365cf23f79c
@@ -1816,7 +1826,7 @@ F test/with4.test 257be66c0c67fee1defbbac0f685c3465e2cad037f21ce65f23f86084f1982
F test/with5.test 6248213c41fab36290b5b73aa3f937309dfba337004d9d8434c3fabc8c7d4be8
F test/with6.test 661d7e416bef6c0a2556b2c9f0c8178a5b15932bed65246abed99723a8d4e7c0
F test/withM.test 693b61765f2b387b5e3e24a4536e2e82de15ff64
-F test/without_rowid1.test df3de14f1cc422d2b0f9b79969b5ef8e51c86ed87834ab35fb5139403e7f5a03
+F test/without_rowid1.test a5210b8770dc4736bca4e74bc96588f43025ad03ad6a80f885afd36d9890e217
F test/without_rowid2.test af260339f79d13cb220288b67cd287fbcf81ad99
F test/without_rowid3.test 39ab0dd773eaa62e59b17093f875327630f54c4145458f6d2b053d68d4b2f67b
F test/without_rowid4.test 4e08bcbaee0399f35d58b5581881e7a6243d458a
@@ -1852,16 +1862,16 @@ F tool/genfkey.test b6afd7b825d797a1e1274f519ab5695373552ecad5cd373530c63533638a
F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce
F tool/index_usage.c f62a0c701b2c7ff2f3e21d206f093c123f222dbf07136a10ffd1ca15a5c706c5
F tool/kvtest-speed.sh 4761a9c4b3530907562314d7757995787f7aef8f
-F tool/lemon.c 258881835bd5bccd0c74fb110fe54244ff18e8e7ef3d949cbdab7187f02132bb
+F tool/lemon.c 1c5a14f6044193e42864c36de48359026fa2cdcf205a43cc1a31116101e27258
F tool/lempar.c 57478ea48420da05faa873c6d1616321caa5464644588c97fbe8e0ea04450748
F tool/libvers.c caafc3b689638a1d88d44bc5f526c2278760d9b9
F tool/loadfts.c c3c64e4d5e90e8ba41159232c2189dba4be7b862
-F tool/logest.c 11346aa019e2e77a00902aa7d0cabd27bd2e8cca
+F tool/logest.c c34e5944318415de513d29a6098df247a9618c96d83c38d4abd88641fe46e669
F tool/max-limits.c cbb635fbb37ae4d05f240bfb5b5270bb63c54439
F tool/merge-test.tcl de76b62f2de2a92d4c1ca4f976bce0aea6899e0229e250479b229b2a1914b176
F tool/mkautoconfamal.sh f62353eb6c06ab264da027fd4507d09914433dbdcab9cb011cdc18016f1ab3b8
F tool/mkccode.tcl 86463e68ce9c15d3041610fedd285ce32a5cf7a58fc88b3202b8b76837650dbe x
-F tool/mkctimec.tcl 5ef1891ed3d0e8143ff39bad7c01ed60c2817a2fb2d9a09487f7ccad2df621e4
+F tool/mkctimec.tcl 3147e9dfc4ad774e94f80084789ebaada9da9b6e66ddab16438cfc07999b6047 x
F tool/mkkeywordhash.c 35bfc41adacc4aa6ef6fca7fd0c63e0ec0534b78daf4d0cfdebe398216bbffc3
F tool/mkmsvcmin.tcl 6ecab9fe22c2c8de4d82d4c46797bda3d2deac8e763885f5a38d0c44a895ab33
F tool/mkopcodec.tcl 33d20791e191df43209b77d37f0ff0904620b28465cca6990cf8d60da61a07ef
@@ -1872,19 +1882,19 @@ F tool/mkshellc.tcl df5d249617f9cc94d5c48eb0401673eb3f31f383ecbc54e8a13ca3dd97e8
F tool/mksourceid.c 36aa8020014aed0836fd13c51d6dc9219b0df1761d6b5f58ff5b616211b079b9
F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97
F tool/mksqlite3c-noext.tcl 4f7cfef5152b0c91920355cbfc1d608a4ad242cb819f1aea07f6d0274f584a7f
-F tool/mksqlite3c.tcl bf9b40811aba68f73f2a8848fad9b1fb09fd54ab5b77e5227f18eea87ab60d92
+F tool/mksqlite3c.tcl 6f9e05facb51e906a1a7ef9f95274ef2ec91bf88b96732a9aed40647c605f419
F tool/mksqlite3h.tcl 1f5e4a1dbbbc43c83cc6e74fe32c6c620502240b66c7c0f33a51378e78fc4edf
F tool/mksqlite3internalh.tcl eb994013e833359137eb53a55acdad0b5ae1049b
F tool/mkvsix.tcl b9e0777a213c23156b6542842c238479e496ebf5
F tool/offsets.c 8ed2b344d33f06e71366a9b93ccedaa38c096cc1dbd4c3c26ad08c6115285845
-F tool/omittest.tcl 3d222272b1d840b4e3d67bff0cb743ce3f633faddadb3702b2056b726775db8f
+F tool/omittest.tcl 3bc9609aceea871e1ca6ed6749df9ce79b89369d22b492f6ce6078f40647cc3f
F tool/opcodesum.tcl 740ed206ba8c5040018988129abbf3089a0ccf4a
F tool/pagesig.c ff0ca355fd3c2398e933da5e22439bbff89b803b
F tool/replace.tcl 937c931ad560688e85bdd6258bdc754371bb1e2732e1fb28ef441e44c9228fce
F tool/restore_jrnl.tcl 6957a34f8f1f0f8285e07536225ec3b292a9024a
F tool/rollback-test.c 9fc98427d1e23e84429d7e6d07d9094fbdec65a5
F tool/run-speed-test.sh f95d19fd669b68c4c38b6b475242841d47c66076
-F tool/showdb.c 7cc12c6deeddfe40ba5d948b408730696d8365988da05fcb6b6a90ea4965e2b4
+F tool/showdb.c 72239e95e1d05a2941c6a1d86b4d857812be4dadd71f24e381db572f350fc172
F tool/showjournal.c 5bad7ae8784a43d2b270d953060423b8bd480818
F tool/showlocks.c 9cc5e66d4ebbf2d194f39db2527ece92077e86ae627ddd233ee48e16e8142564
F tool/showshm.c a0ab6ec32dd1f11218ca2a4018f8fb875b59414801ab8ceed8b2e69b7b45a809
@@ -1899,7 +1909,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 7ce07da76b5e745783e703a834417d725b7d45fd
F tool/split-sqlite3c.tcl 3efcd4240b738f6bb2b5af0aea7e1e0ef9bc1c61654f645076cec883030b710c
-F tool/sqldiff.c 9c639de9fa541a947ea9776435c84adf00f43945e262556e15219ef09f0d912c
+F tool/sqldiff.c 4f967c199c5f93eec64978e3a625d6c07fb1162212b1d48f65740d9eb4607eee
F tool/sqlite3_analyzer.c.in f88615bf33098945e0a42f17733f472083d150b58bdaaa5555a7129d0a51621c
F tool/sqltclsh.c.in 1bcc2e9da58fadf17b0bf6a50e68c1159e602ce057210b655d50bad5aaaef898
F tool/sqltclsh.tcl 862f4cf1418df5e1315b5db3b5ebe88969e2a784525af5fbf9596592f14ed848
@@ -1908,10 +1918,10 @@ F tool/stack_usage.tcl f8e71b92cdb099a147dad572375595eae55eca43
F tool/symbols-mingw.sh 4dbcea7e74768305384c9fd2ed2b41bbf9f0414d
F tool/symbols.sh 1612bd947750e21e7b47befad5f6b3825b06cce0705441f903bf35ced65ae9b9
F tool/varint.c 5d94cb5003db9dbbcbcc5df08d66f16071aee003
-F tool/vdbe-compress.tcl 5926c71f9c12d2ab73ef35c29376e756eb68361c
+F tool/vdbe-compress.tcl 1dcb7632e57cf57105248029e6e162fddaf6c0fccb3bb9e6215603752c5a2d4a
F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f
F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7
-F tool/warnings.sh 09311479bdc290e20ec8e35a3d1b14b096bbd96222277cfd6274c3a99b3d012f
+F tool/warnings.sh d58dc38367cc776550f90327e205d7946802d4004fb9f291fd8b81256bc1eedd
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
F vsixtest/App.xaml b76d3b48860e7454775c47ea38ffea9c4abe3e85
F vsixtest/App.xaml.cpp 41158ee43269820136fa3bba00c0bd91b26cc38b650ee392aec2a8d823e54318
@@ -1934,11 +1944,10 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 986a94d036f029539c3bb3873096f4a85ee26fc674f56856c57ca3dfd3bd0f37
-R 6693a475946c1486ee6fea9335c37ae8
-T +bgcolor * #d0c0ff
+P 1894577c8eff6d0cb586cc8cd3a8f6a2b5800b9aa6391261121f4e26c9ba5f8f
+R fc330fc7977b978fbc04c276d2bfab7f
T +sym-release *
-T +sym-version-3.37.1 *
+T +sym-version-3.38.1 *
U drh
-Z 8f71d7fd3282e6b87441d928ca292620
+Z 4b5637d3ca4eabb01e9b15baef29b1f6
# Remove this line to create a well-formed Fossil manifest.
diff --git a/chromium/third_party/sqlite/src/manifest.uuid b/chromium/third_party/sqlite/src/manifest.uuid
index 05414622d67..5ec8976c068 100644
--- a/chromium/third_party/sqlite/src/manifest.uuid
+++ b/chromium/third_party/sqlite/src/manifest.uuid
@@ -1 +1 @@
-378629bf2ea546f73eee84063c5358439a12f7300e433f18c9e1bddd948dea62 \ No newline at end of file
+38c210fdd258658321c85ec9c01a072fda3ada94540e3239d29b34dc547a8cbc \ No newline at end of file
diff --git a/chromium/third_party/sqlite/src/src/alter.c b/chromium/third_party/sqlite/src/src/alter.c
index bb43edbeda3..1ec74cdcc7b 100644
--- a/chromium/third_party/sqlite/src/src/alter.c
+++ b/chromium/third_party/sqlite/src/src/alter.c
@@ -324,7 +324,9 @@ void sqlite3AlterFinishAddColumn(Parse *pParse, Token *pColDef){
int r1; /* Temporary registers */
db = pParse->db;
- if( pParse->nErr || db->mallocFailed ) return;
+ assert( db->pParse==pParse );
+ if( pParse->nErr ) return;
+ assert( db->mallocFailed==0 );
pNew = pParse->pNewTable;
assert( pNew );
@@ -450,7 +452,7 @@ void sqlite3AlterFinishAddColumn(Parse *pParse, Token *pColDef){
" THEN raise(ABORT,'CHECK constraint failed')"
" ELSE raise(ABORT,'NOT NULL constraint failed')"
" END"
- " FROM pragma_quick_check(\"%w\",\"%w\")"
+ " FROM pragma_quick_check(%Q,%Q)"
" WHERE quick_check GLOB 'CHECK*' OR quick_check GLOB 'NULL*'",
zTab, zDb
);
@@ -629,7 +631,7 @@ void sqlite3AlterRenameColumn(
if( 0==sqlite3StrICmp(pTab->aCol[iCol].zCnName, zOld) ) break;
}
if( iCol==pTab->nCol ){
- sqlite3ErrorMsg(pParse, "no such column: \"%s\"", zOld);
+ sqlite3ErrorMsg(pParse, "no such column: \"%T\"", pOld);
goto exit_rename_column;
}
@@ -735,7 +737,9 @@ struct RenameCtx {
** following a valid object, it may not be used in comparison operations.
*/
static void renameTokenCheckAll(Parse *pParse, const void *pPtr){
- if( pParse->nErr==0 && pParse->db->mallocFailed==0 ){
+ assert( pParse==pParse->db->pParse );
+ assert( pParse->db->mallocFailed==0 || pParse->nErr!=0 );
+ if( pParse->nErr==0 ){
const RenameToken *p;
u8 i = 0;
for(p=pParse->pRename; p; p=p->pNext){
@@ -1057,12 +1061,12 @@ static void renameColumnParseError(
const char *zN = (const char*)sqlite3_value_text(pObject);
char *zErr;
- zErr = sqlite3_mprintf("error in %s %s%s%s: %s",
+ zErr = sqlite3MPrintf(pParse->db, "error in %s %s%s%s: %s",
zT, zN, (zWhen[0] ? " " : ""), zWhen,
pParse->zErrMsg
);
sqlite3_result_error(pCtx, zErr, -1);
- sqlite3_free(zErr);
+ sqlite3DbFree(pParse->db, zErr);
}
/*
@@ -1126,24 +1130,22 @@ static int renameParseSql(
int bTemp /* True if SQL is from temp schema */
){
int rc;
- char *zErr = 0;
+ sqlite3ParseObjectInit(p, db);
+ if( zSql==0 ){
+ return SQLITE_NOMEM;
+ }
+ if( sqlite3StrNICmp(zSql,"CREATE ",7)!=0 ){
+ return SQLITE_CORRUPT_BKPT;
+ }
db->init.iDb = bTemp ? 1 : sqlite3FindDbName(db, zDb);
-
- /* Parse the SQL statement passed as the first argument. If no error
- ** occurs and the parse does not result in a new table, index or
- ** trigger object, the database must be corrupt. */
- memset(p, 0, sizeof(Parse));
p->eParseMode = PARSE_MODE_RENAME;
p->db = db;
p->nQueryLoop = 1;
- rc = zSql ? sqlite3RunParser(p, zSql, &zErr) : SQLITE_NOMEM;
- assert( p->zErrMsg==0 );
- assert( rc!=SQLITE_OK || zErr==0 );
- p->zErrMsg = zErr;
+ rc = sqlite3RunParser(p, zSql);
if( db->mallocFailed ) rc = SQLITE_NOMEM;
if( rc==SQLITE_OK
- && p->pNewTable==0 && p->pNewIndex==0 && p->pNewTrigger==0
+ && NEVER(p->pNewTable==0 && p->pNewIndex==0 && p->pNewTrigger==0)
){
rc = SQLITE_CORRUPT_BKPT;
}
@@ -1421,13 +1423,13 @@ static void renameParseCleanup(Parse *pParse){
sqlite3DeleteTrigger(db, pParse->pNewTrigger);
sqlite3DbFree(db, pParse->zErrMsg);
renameTokenFree(db, pParse->pRename);
- sqlite3ParserReset(pParse);
+ sqlite3ParseObjectReset(pParse);
}
/*
** SQL function:
**
-** sqlite_rename_column(zSql, iCol, bQuote, zNew, zTable, zOld)
+** sqlite_rename_column(SQL,TYPE,OBJ,DB,TABLE,COL,NEWNAME,QUOTE,TEMP)
**
** 0. zSql: SQL statement to rewrite
** 1. type: Type of object ("table", "view" etc.)
@@ -1445,7 +1447,8 @@ static void renameParseCleanup(Parse *pParse){
**
** This function is used internally by the ALTER TABLE RENAME COLUMN command.
** It is only accessible to SQL created using sqlite3NestedParse(). It is
-** not reachable from ordinary SQL passed into sqlite3_prepare().
+** not reachable from ordinary SQL passed into sqlite3_prepare() unless the
+** SQLITE_TESTCTRL_INTERNAL_FUNCTIONS test setting is enabled.
*/
static void renameColumnFunc(
sqlite3_context *context,
@@ -1594,7 +1597,9 @@ static void renameColumnFunc(
renameColumnFunc_done:
if( rc!=SQLITE_OK ){
- if( sParse.zErrMsg ){
+ if( rc==SQLITE_ERROR && sqlite3WritableSchema(db) ){
+ sqlite3_result_value(context, argv[0]);
+ }else if( sParse.zErrMsg ){
renameColumnParseError(context, "", argv[1], argv[2], &sParse);
}else{
sqlite3_result_error_code(context, rc);
@@ -1793,7 +1798,9 @@ static void renameTableFunc(
rc = renameEditSql(context, &sCtx, zInput, zNew, bQuote);
}
if( rc!=SQLITE_OK ){
- if( sParse.zErrMsg ){
+ if( rc==SQLITE_ERROR && sqlite3WritableSchema(db) ){
+ sqlite3_result_value(context, argv[3]);
+ }else if( sParse.zErrMsg ){
renameColumnParseError(context, "", argv[1], argv[2], &sParse);
}else{
sqlite3_result_error_code(context, rc);
@@ -1818,10 +1825,10 @@ static int renameQuotefixExprCb(Walker *pWalker, Expr *pExpr){
return WRC_Continue;
}
-/*
-** The implementation of an SQL scalar function that rewrites DDL statements
-** so that any string literals that use double-quotes are modified so that
-** they use single quotes.
+/* SQL function: sqlite_rename_quotefix(DB,SQL)
+**
+** Rewrite the DDL statement "SQL" so that any string literals that use
+** double-quotes use single quotes instead.
**
** Two arguments must be passed:
**
@@ -1840,6 +1847,10 @@ static int renameQuotefixExprCb(Walker *pWalker, Expr *pExpr){
** returns the string:
**
** CREATE VIEW v1 AS SELECT "a", 'string' FROM t1
+**
+** If there is a error in the input SQL, then raise an error, except
+** if PRAGMA writable_schema=ON, then just return the input string
+** unmodified following an error.
*/
static void renameQuotefixFunc(
sqlite3_context *context,
@@ -1914,7 +1925,11 @@ static void renameQuotefixFunc(
renameTokenFree(db, sCtx.pList);
}
if( rc!=SQLITE_OK ){
- sqlite3_result_error_code(context, rc);
+ if( sqlite3WritableSchema(db) && rc==SQLITE_ERROR ){
+ sqlite3_result_value(context, argv[1]);
+ }else{
+ sqlite3_result_error_code(context, rc);
+ }
}
renameParseCleanup(&sParse);
}
@@ -1926,7 +1941,8 @@ static void renameQuotefixFunc(
sqlite3BtreeLeaveAll(db);
}
-/*
+/* Function: sqlite_rename_test(DB,SQL,TYPE,NAME,ISTEMP,WHEN,DQS)
+**
** An SQL user function that checks that there are no parse or symbol
** resolution problems in a CREATE TRIGGER|TABLE|VIEW|INDEX statement.
** After an ALTER TABLE .. RENAME operation is performed and the schema
@@ -1941,11 +1957,13 @@ static void renameQuotefixFunc(
** 5: "when" part of error message.
** 6: True to disable the DQS quirk when parsing SQL.
**
-** Unless it finds an error, this function normally returns NULL. However, it
-** returns integer value 1 if:
+** The return value is computed as follows:
**
-** * the SQL argument creates a trigger, and
-** * the table that the trigger is attached to is in database zDb.
+** A. If an error is seen and not in PRAGMA writable_schema=ON mode,
+** then raise the error.
+** B. Else if a trigger is created and the the table that the trigger is
+** attached to is in database zDb, then return 1.
+** C. Otherwise return NULL.
*/
static void renameTableTest(
sqlite3_context *context,
@@ -1990,12 +2008,16 @@ static void renameTableTest(
if( rc==SQLITE_OK ){
int i1 = sqlite3SchemaToIndex(db, sParse.pNewTrigger->pTabSchema);
int i2 = sqlite3FindDbName(db, zDb);
- if( i1==i2 ) sqlite3_result_int(context, 1);
+ if( i1==i2 ){
+ /* Handle output case B */
+ sqlite3_result_int(context, 1);
+ }
}
}
}
- if( rc!=SQLITE_OK && zWhen ){
+ if( rc!=SQLITE_OK && zWhen && !sqlite3WritableSchema(db) ){
+ /* Output case A */
renameColumnParseError(context, zWhen, argv[2], argv[3],&sParse);
}
renameParseCleanup(&sParse);
@@ -2111,7 +2133,7 @@ void sqlite3AlterDropColumn(Parse *pParse, SrcList *pSrc, const Token *pName){
}
iCol = sqlite3ColumnIndex(pTab, zCol);
if( iCol<0 ){
- sqlite3ErrorMsg(pParse, "no such column: \"%s\"", zCol);
+ sqlite3ErrorMsg(pParse, "no such column: \"%T\"", pName);
goto exit_drop_column;
}
@@ -2135,6 +2157,12 @@ void sqlite3AlterDropColumn(Parse *pParse, SrcList *pSrc, const Token *pName){
iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
assert( iDb>=0 );
zDb = db->aDb[iDb].zDbSName;
+#ifndef SQLITE_OMIT_AUTHORIZATION
+ /* Invoke the authorization callback. */
+ if( sqlite3AuthCheck(pParse, SQLITE_ALTER_TABLE, zDb, pTab->zName, zCol) ){
+ goto exit_drop_column;
+ }
+#endif
renameTestSchema(pParse, zDb, iDb==1, "", 0);
renameFixQuotes(pParse, zDb, iDb==1);
sqlite3NestedParse(pParse,
diff --git a/chromium/third_party/sqlite/src/src/attach.c b/chromium/third_party/sqlite/src/src/attach.c
index 2123278c472..e587f6cc5ed 100644
--- a/chromium/third_party/sqlite/src/src/attach.c
+++ b/chromium/third_party/sqlite/src/src/attach.c
@@ -354,7 +354,7 @@ static void codeAttach(
}
#ifndef SQLITE_OMIT_AUTHORIZATION
- if( pAuthArg ){
+ if( ALWAYS(pAuthArg) ){
char *zAuthArg;
if( pAuthArg->op==TK_STRING ){
assert( !ExprHasProperty(pAuthArg, EP_IntValue) );
diff --git a/chromium/third_party/sqlite/src/src/backup.c b/chromium/third_party/sqlite/src/src/backup.c
index 2b286de6bda..d9671750f40 100644
--- a/chromium/third_party/sqlite/src/src/backup.c
+++ b/chromium/third_party/sqlite/src/src/backup.c
@@ -85,14 +85,13 @@ static Btree *findBtree(sqlite3 *pErrorDb, sqlite3 *pDb, const char *zDb){
if( i==1 ){
Parse sParse;
int rc = 0;
- memset(&sParse, 0, sizeof(sParse));
- sParse.db = pDb;
+ sqlite3ParseObjectInit(&sParse,pDb);
if( sqlite3OpenTempDatabase(&sParse) ){
sqlite3ErrorWithMsg(pErrorDb, sParse.rc, "%s", sParse.zErrMsg);
rc = SQLITE_ERROR;
}
sqlite3DbFree(pErrorDb, sParse.zErrMsg);
- sqlite3ParserReset(&sParse);
+ sqlite3ParseObjectReset(&sParse);
if( rc ){
return 0;
}
diff --git a/chromium/third_party/sqlite/src/src/btree.c b/chromium/third_party/sqlite/src/src/btree.c
index ba35af03f01..9bc242256a7 100644
--- a/chromium/third_party/sqlite/src/src/btree.c
+++ b/chromium/third_party/sqlite/src/src/btree.c
@@ -1225,18 +1225,32 @@ static void btreeParseCellPtr(
**
** pIter += getVarint(pIter, (u64*)&pInfo->nKey);
**
- ** The code is inlined to avoid a function call.
+ ** The code is inlined and the loop is unrolled for performance.
+ ** This routine is a high-runner.
*/
iKey = *pIter;
if( iKey>=0x80 ){
- u8 *pEnd = &pIter[7];
- iKey &= 0x7f;
- while(1){
- iKey = (iKey<<7) | (*++pIter & 0x7f);
- if( (*pIter)<0x80 ) break;
- if( pIter>=pEnd ){
- iKey = (iKey<<8) | *++pIter;
- break;
+ u8 x;
+ iKey = ((iKey&0x7f)<<7) | ((x = *++pIter) & 0x7f);
+ if( x>=0x80 ){
+ iKey = (iKey<<7) | ((x =*++pIter) & 0x7f);
+ if( x>=0x80 ){
+ iKey = (iKey<<7) | ((x = *++pIter) & 0x7f);
+ if( x>=0x80 ){
+ iKey = (iKey<<7) | ((x = *++pIter) & 0x7f);
+ if( x>=0x80 ){
+ iKey = (iKey<<7) | ((x = *++pIter) & 0x7f);
+ if( x>=0x80 ){
+ iKey = (iKey<<7) | ((x = *++pIter) & 0x7f);
+ if( x>=0x80 ){
+ iKey = (iKey<<7) | ((x = *++pIter) & 0x7f);
+ if( x>=0x80 ){
+ iKey = (iKey<<8) | (*++pIter);
+ }
+ }
+ }
+ }
+ }
}
}
}
@@ -1246,7 +1260,7 @@ static void btreeParseCellPtr(
pInfo->nPayload = nPayload;
pInfo->pPayload = pIter;
testcase( nPayload==pPage->maxLocal );
- testcase( nPayload==pPage->maxLocal+1 );
+ testcase( nPayload==(u32)pPage->maxLocal+1 );
if( nPayload<=pPage->maxLocal ){
/* This is the (easy) common case where the entire payload fits
** on the local page. No overflow is required.
@@ -1283,7 +1297,7 @@ static void btreeParseCellPtrIndex(
pInfo->nPayload = nPayload;
pInfo->pPayload = pIter;
testcase( nPayload==pPage->maxLocal );
- testcase( nPayload==pPage->maxLocal+1 );
+ testcase( nPayload==(u32)pPage->maxLocal+1 );
if( nPayload<=pPage->maxLocal ){
/* This is the (easy) common case where the entire payload fits
** on the local page. No overflow is required.
@@ -1346,7 +1360,7 @@ static u16 cellSizePtr(MemPage *pPage, u8 *pCell){
while( (*pIter++)&0x80 && pIter<pEnd );
}
testcase( nSize==pPage->maxLocal );
- testcase( nSize==pPage->maxLocal+1 );
+ testcase( nSize==(u32)pPage->maxLocal+1 );
if( nSize<=pPage->maxLocal ){
nSize += (u32)(pIter - pCell);
if( nSize<4 ) nSize = 4;
@@ -1354,7 +1368,7 @@ static u16 cellSizePtr(MemPage *pPage, u8 *pCell){
int minLocal = pPage->minLocal;
nSize = minLocal + (nSize - minLocal) % (pPage->pBt->usableSize - 4);
testcase( nSize==pPage->maxLocal );
- testcase( nSize==pPage->maxLocal+1 );
+ testcase( nSize==(u32)pPage->maxLocal+1 );
if( nSize>pPage->maxLocal ){
nSize = minLocal;
}
@@ -1768,7 +1782,7 @@ static int freeSpace(MemPage *pPage, u16 iStart, u16 iSize){
if( iFreeBlk>pPage->pBt->usableSize-4 ){ /* TH3: corrupt081.100 */
return SQLITE_CORRUPT_PAGE(pPage);
}
- assert( iFreeBlk>iPtr || iFreeBlk==0 );
+ assert( iFreeBlk>iPtr || iFreeBlk==0 || CORRUPT_DB );
/* At this point:
** iFreeBlk: First freeblock after iStart, or zero if none
@@ -2039,7 +2053,7 @@ static int btreeInitPage(MemPage *pPage){
pPage->nOverflow = 0;
pPage->cellOffset = pPage->hdrOffset + 8 + pPage->childPtrSize;
pPage->aCellIdx = data + pPage->childPtrSize + 8;
- pPage->aDataEnd = pPage->aData + pBt->usableSize;
+ pPage->aDataEnd = pPage->aData + pBt->pageSize;
pPage->aDataOfst = pPage->aData + pPage->childPtrSize;
/* EVIDENCE-OF: R-37002-32774 The two-byte integer at offset 3 gives the
** number of cells on the page. */
@@ -2074,7 +2088,7 @@ static void zeroPage(MemPage *pPage, int flags){
u8 hdr = pPage->hdrOffset;
u16 first;
- assert( sqlite3PagerPagenumber(pPage->pDbPage)==pPage->pgno );
+ assert( sqlite3PagerPagenumber(pPage->pDbPage)==pPage->pgno || CORRUPT_DB );
assert( sqlite3PagerGetExtra(pPage->pDbPage) == (void*)pPage );
assert( sqlite3PagerGetData(pPage->pDbPage) == data );
assert( sqlite3PagerIswriteable(pPage->pDbPage) );
@@ -2090,7 +2104,7 @@ static void zeroPage(MemPage *pPage, int flags){
pPage->nFree = (u16)(pBt->usableSize - first);
decodeFlags(pPage, flags);
pPage->cellOffset = first;
- pPage->aDataEnd = &data[pBt->usableSize];
+ pPage->aDataEnd = &data[pBt->pageSize];
pPage->aCellIdx = &data[first];
pPage->aDataOfst = &data[pPage->childPtrSize];
pPage->nOverflow = 0;
@@ -2216,7 +2230,7 @@ static int getAndInitPage(
goto getAndInitPage_error2;
}
}
- assert( (*ppPage)->pgno==pgno );
+ assert( (*ppPage)->pgno==pgno || CORRUPT_DB );
assert( (*ppPage)->aData==sqlite3PagerGetData(pDbPage) );
/* If obtaining a child page for a cursor, we must verify that the page is
@@ -2693,30 +2707,38 @@ static int removeFromSharingList(BtShared *pBt){
** MX_CELL_SIZE(pBt) bytes with a 4-byte prefix for a left-child
** pointer.
*/
-static void allocateTempSpace(BtShared *pBt){
- if( !pBt->pTmpSpace ){
- pBt->pTmpSpace = sqlite3PageMalloc( pBt->pageSize );
-
- /* One of the uses of pBt->pTmpSpace is to format cells before
- ** inserting them into a leaf page (function fillInCell()). If
- ** a cell is less than 4 bytes in size, it is rounded up to 4 bytes
- ** by the various routines that manipulate binary cells. Which
- ** can mean that fillInCell() only initializes the first 2 or 3
- ** bytes of pTmpSpace, but that the first 4 bytes are copied from
- ** it into a database page. This is not actually a problem, but it
- ** does cause a valgrind error when the 1 or 2 bytes of unitialized
- ** data is passed to system call write(). So to avoid this error,
- ** zero the first 4 bytes of temp space here.
- **
- ** Also: Provide four bytes of initialized space before the
- ** beginning of pTmpSpace as an area available to prepend the
- ** left-child pointer to the beginning of a cell.
- */
- if( pBt->pTmpSpace ){
- memset(pBt->pTmpSpace, 0, 8);
- pBt->pTmpSpace += 4;
- }
+static SQLITE_NOINLINE int allocateTempSpace(BtShared *pBt){
+ assert( pBt!=0 );
+ assert( pBt->pTmpSpace==0 );
+ /* This routine is called only by btreeCursor() when allocating the
+ ** first write cursor for the BtShared object */
+ assert( pBt->pCursor!=0 && (pBt->pCursor->curFlags & BTCF_WriteFlag)!=0 );
+ pBt->pTmpSpace = sqlite3PageMalloc( pBt->pageSize );
+ if( pBt->pTmpSpace==0 ){
+ BtCursor *pCur = pBt->pCursor;
+ pBt->pCursor = pCur->pNext; /* Unlink the cursor */
+ memset(pCur, 0, sizeof(*pCur));
+ return SQLITE_NOMEM_BKPT;
}
+
+ /* One of the uses of pBt->pTmpSpace is to format cells before
+ ** inserting them into a leaf page (function fillInCell()). If
+ ** a cell is less than 4 bytes in size, it is rounded up to 4 bytes
+ ** by the various routines that manipulate binary cells. Which
+ ** can mean that fillInCell() only initializes the first 2 or 3
+ ** bytes of pTmpSpace, but that the first 4 bytes are copied from
+ ** it into a database page. This is not actually a problem, but it
+ ** does cause a valgrind error when the 1 or 2 bytes of unitialized
+ ** data is passed to system call write(). So to avoid this error,
+ ** zero the first 4 bytes of temp space here.
+ **
+ ** Also: Provide four bytes of initialized space before the
+ ** beginning of pTmpSpace as an area available to prepend the
+ ** left-child pointer to the beginning of a cell.
+ */
+ memset(pBt->pTmpSpace, 0, 8);
+ pBt->pTmpSpace += 4;
+ return SQLITE_OK;
}
/*
@@ -3213,9 +3235,13 @@ static int lockBtree(BtShared *pBt){
pageSize-usableSize);
return rc;
}
- if( sqlite3WritableSchema(pBt->db)==0 && nPage>nPageFile ){
- rc = SQLITE_CORRUPT_BKPT;
- goto page1_init_failed;
+ if( nPage>nPageFile ){
+ if( sqlite3WritableSchema(pBt->db)==0 ){
+ rc = SQLITE_CORRUPT_BKPT;
+ goto page1_init_failed;
+ }else{
+ nPage = nPageFile;
+ }
}
/* EVIDENCE-OF: R-28312-64704 However, the usable size is not allowed to
** be less than 480. In other words, if the page size is 512, then the
@@ -4245,7 +4271,7 @@ static void btreeSetNPage(BtShared *pBt, MemPage *pPage1){
int nPage = get4byte(&pPage1->aData[28]);
testcase( nPage==0 );
if( nPage==0 ) sqlite3PagerPagecount(pBt->pPager, &nPage);
- testcase( pBt->nPage!=nPage );
+ testcase( pBt->nPage!=(u32)nPage );
pBt->nPage = nPage;
}
@@ -4457,10 +4483,6 @@ static int btreeCursor(
assert( pBt->pPage1 && pBt->pPage1->aData );
assert( wrFlag==0 || (pBt->btsFlags & BTS_READ_ONLY)==0 );
- if( wrFlag ){
- allocateTempSpace(pBt);
- if( pBt->pTmpSpace==0 ) return SQLITE_NOMEM_BKPT;
- }
if( iTable<=1 ){
if( iTable<1 ){
return SQLITE_CORRUPT_BKPT;
@@ -4477,19 +4499,25 @@ static int btreeCursor(
pCur->pKeyInfo = pKeyInfo;
pCur->pBtree = p;
pCur->pBt = pBt;
- pCur->curFlags = wrFlag ? BTCF_WriteFlag : 0;
- pCur->curPagerFlags = wrFlag ? 0 : PAGER_GET_READONLY;
+ pCur->curFlags = 0;
/* If there are two or more cursors on the same btree, then all such
** cursors *must* have the BTCF_Multiple flag set. */
for(pX=pBt->pCursor; pX; pX=pX->pNext){
if( pX->pgnoRoot==iTable ){
pX->curFlags |= BTCF_Multiple;
- pCur->curFlags |= BTCF_Multiple;
+ pCur->curFlags = BTCF_Multiple;
}
}
+ pCur->eState = CURSOR_INVALID;
pCur->pNext = pBt->pCursor;
pBt->pCursor = pCur;
- pCur->eState = CURSOR_INVALID;
+ if( wrFlag ){
+ pCur->curFlags |= BTCF_WriteFlag;
+ pCur->curPagerFlags = 0;
+ if( pBt->pTmpSpace==0 ) return allocateTempSpace(pBt);
+ }else{
+ pCur->curPagerFlags = PAGER_GET_READONLY;
+ }
return SQLITE_OK;
}
static int btreeCursorWithLock(
@@ -5264,7 +5292,7 @@ static int moveToRoot(BtCursor *pCur){
while( --pCur->iPage ){
releasePageNotNull(pCur->apPage[pCur->iPage]);
}
- pCur->pPage = pCur->apPage[0];
+ pRoot = pCur->pPage = pCur->apPage[0];
goto skip_init;
}
}else if( pCur->pgnoRoot==0 ){
@@ -5289,7 +5317,7 @@ static int moveToRoot(BtCursor *pCur){
pCur->curIntKey = pCur->pPage->intKey;
}
pRoot = pCur->pPage;
- assert( pRoot->pgno==pCur->pgnoRoot );
+ assert( pRoot->pgno==pCur->pgnoRoot || CORRUPT_DB );
/* If pCur->pKeyInfo is not NULL, then the caller that opened this cursor
** expected to open it on an index b-tree. Otherwise, if pKeyInfo is
@@ -5311,7 +5339,6 @@ skip_init:
pCur->info.nSize = 0;
pCur->curFlags &= ~(BTCF_AtLast|BTCF_ValidNKey|BTCF_ValidOvfl);
- pRoot = pCur->pPage;
if( pRoot->nCell>0 ){
pCur->eState = CURSOR_VALID;
}else if( !pRoot->leaf ){
@@ -5552,7 +5579,6 @@ int sqlite3BtreeTableMoveto(
upr = pPage->nCell-1;
assert( biasRight==0 || biasRight==1 );
idx = upr>>(1-biasRight); /* idx = biasRight ? upr : (lwr+upr)/2; */
- pCur->ix = (u16)idx;
for(;;){
i64 nCellKey;
pCell = findCellPastPtr(pPage, idx);
@@ -5694,7 +5720,6 @@ int sqlite3BtreeIndexMoveto(
lwr = 0;
upr = pPage->nCell-1;
idx = upr>>1; /* idx = (lwr+upr)/2; */
- pCur->ix = (u16)idx;
for(;;){
int nCell; /* Size of the pCell cell in bytes */
pCell = findCellPastPtr(pPage, idx);
@@ -6386,7 +6411,7 @@ static int freePage2(BtShared *pBt, MemPage *pMemPage, Pgno iPage){
assert( CORRUPT_DB || iPage>1 );
assert( !pMemPage || pMemPage->pgno==iPage );
- if( NEVER(iPage<2) || iPage>pBt->nPage ){
+ if( iPage<2 || iPage>pBt->nPage ){
return SQLITE_CORRUPT_BKPT;
}
if( pMemPage ){
@@ -6810,16 +6835,24 @@ static void dropCell(MemPage *pPage, int idx, int sz, int *pRC){
int hdr; /* Beginning of the header. 0 most pages. 100 page 1 */
if( *pRC ) return;
- assert( idx>=0 && idx<pPage->nCell );
+ assert( idx>=0 );
+ assert( idx<pPage->nCell );
assert( CORRUPT_DB || sz==cellSize(pPage, idx) );
assert( sqlite3PagerIswriteable(pPage->pDbPage) );
assert( sqlite3_mutex_held(pPage->pBt->mutex) );
assert( pPage->nFree>=0 );
data = pPage->aData;
ptr = &pPage->aCellIdx[2*idx];
+ assert( pPage->pBt->usableSize > (u32)(ptr-data) );
pc = get2byte(ptr);
hdr = pPage->hdrOffset;
- testcase( pc==get2byte(&data[hdr+5]) );
+#if 0 /* Not required. Omit for efficiency */
+ if( pc<hdr+pPage->nCell*2 ){
+ *pRC = SQLITE_CORRUPT_BKPT;
+ return;
+ }
+#endif
+ testcase( pc==(u32)get2byte(&data[hdr+5]) );
testcase( pc+sz==pPage->pBt->usableSize );
if( pc+sz > pPage->pBt->usableSize ){
*pRC = SQLITE_CORRUPT_BKPT;
@@ -7111,7 +7144,7 @@ static int rebuildPage(
assert( i<iEnd );
j = get2byte(&aData[hdr+5]);
- if( NEVER(j>(u32)usableSize) ){ j = 0; }
+ if( j>(u32)usableSize ){ j = 0; }
memcpy(&pTmp[j], &aData[j], usableSize - j);
for(k=0; pCArray->ixNx[k]<=i && ALWAYS(k<NB*2); k++){}
@@ -7342,7 +7375,7 @@ static int editPage(
pData = &aData[get2byteNotZero(&aData[hdr+5])];
if( pData<pBegin ) goto editpage_fail;
- if( NEVER(pData>pPg->aDataEnd) ) goto editpage_fail;
+ if( pData>pPg->aDataEnd ) goto editpage_fail;
/* Add cells to the start of the page */
if( iNew<iOld ){
@@ -8952,7 +8985,7 @@ int sqlite3BtreeInsert(
assert( pPage->intKey || pX->nKey>=0 || (flags & BTREE_PREFORMAT) );
assert( pPage->leaf || !pPage->intKey );
if( pPage->nFree<0 ){
- if( NEVER(pCur->eState>CURSOR_INVALID) ){
+ if( pCur->eState>CURSOR_INVALID ){
rc = SQLITE_CORRUPT_BKPT;
}else{
rc = btreeComputeFreeSpace(pPage);
@@ -9218,14 +9251,13 @@ int sqlite3BtreeTransferRow(BtCursor *pDest, BtCursor *pSrc, i64 iKey){
int sqlite3BtreeDelete(BtCursor *pCur, u8 flags){
Btree *p = pCur->pBtree;
BtShared *pBt = p->pBt;
- int rc; /* Return code */
- MemPage *pPage; /* Page to delete cell from */
- unsigned char *pCell; /* Pointer to cell to delete */
- int iCellIdx; /* Index of cell to delete */
- int iCellDepth; /* Depth of node containing pCell */
- CellInfo info; /* Size of the cell being deleted */
- int bSkipnext = 0; /* Leaf cursor in SKIPNEXT state */
- u8 bPreserve = flags & BTREE_SAVEPOSITION; /* Keep cursor valid */
+ int rc; /* Return code */
+ MemPage *pPage; /* Page to delete cell from */
+ unsigned char *pCell; /* Pointer to cell to delete */
+ int iCellIdx; /* Index of cell to delete */
+ int iCellDepth; /* Depth of node containing pCell */
+ CellInfo info; /* Size of the cell being deleted */
+ u8 bPreserve; /* Keep cursor valid. 2 for CURSOR_SKIPNEXT */
assert( cursorOwnsBtShared(pCur) );
assert( pBt->inTransaction==TRANS_WRITE );
@@ -9244,18 +9276,31 @@ int sqlite3BtreeDelete(BtCursor *pCur, u8 flags){
iCellDepth = pCur->iPage;
iCellIdx = pCur->ix;
pPage = pCur->pPage;
+ if( pPage->nCell<=iCellIdx ){
+ return SQLITE_CORRUPT_BKPT;
+ }
pCell = findCell(pPage, iCellIdx);
- if( pPage->nFree<0 && btreeComputeFreeSpace(pPage) ) return SQLITE_CORRUPT;
+ if( pPage->nFree<0 && btreeComputeFreeSpace(pPage) ){
+ return SQLITE_CORRUPT_BKPT;
+ }
- /* If the bPreserve flag is set to true, then the cursor position must
+ /* If the BTREE_SAVEPOSITION bit is on, then the cursor position must
** be preserved following this delete operation. If the current delete
** will cause a b-tree rebalance, then this is done by saving the cursor
** key and leaving the cursor in CURSOR_REQUIRESEEK state before
** returning.
**
- ** Or, if the current delete will not cause a rebalance, then the cursor
+ ** If the current delete will not cause a rebalance, then the cursor
** will be left in CURSOR_SKIPNEXT state pointing to the entry immediately
- ** before or after the deleted entry. In this case set bSkipnext to true. */
+ ** before or after the deleted entry.
+ **
+ ** The bPreserve value records which path is required:
+ **
+ ** bPreserve==0 Not necessary to save the cursor position
+ ** bPreserve==1 Use CURSOR_REQUIRESEEK to save the cursor position
+ ** bPreserve==2 Cursor won't move. Set CURSOR_SKIPNEXT.
+ */
+ bPreserve = (flags & BTREE_SAVEPOSITION)!=0;
if( bPreserve ){
if( !pPage->leaf
|| (pPage->nFree+cellSizePtr(pPage,pCell)+2)>(int)(pBt->usableSize*2/3)
@@ -9266,7 +9311,7 @@ int sqlite3BtreeDelete(BtCursor *pCur, u8 flags){
rc = saveCursorKey(pCur);
if( rc ) return rc;
}else{
- bSkipnext = 1;
+ bPreserve = 2;
}
}
@@ -9366,8 +9411,8 @@ int sqlite3BtreeDelete(BtCursor *pCur, u8 flags){
}
if( rc==SQLITE_OK ){
- if( bSkipnext ){
- assert( bPreserve && (pCur->iPage==iCellDepth || CORRUPT_DB) );
+ if( bPreserve>1 ){
+ assert( (pCur->iPage==iCellDepth || CORRUPT_DB) );
assert( pPage==pCur->pPage || CORRUPT_DB );
assert( (pPage->nCell>0 || CORRUPT_DB) && iCellIdx<=pPage->nCell );
pCur->eState = CURSOR_SKIPNEXT;
@@ -9577,7 +9622,7 @@ static int clearDatabasePage(
rc = getAndInitPage(pBt, pgno, &pPage, 0, 0);
if( rc ) return rc;
if( (pBt->openFlags & BTREE_SINGLE)==0
- && sqlite3PagerPageRefcount(pPage->pDbPage)!=1
+ && sqlite3PagerPageRefcount(pPage->pDbPage) != (1 + (pgno==1))
){
rc = SQLITE_CORRUPT_BKPT;
goto cleardatabasepage_out;
diff --git a/chromium/third_party/sqlite/src/src/btreeInt.h b/chromium/third_party/sqlite/src/src/btreeInt.h
index 1076fd8f2ca..dc46629320e 100644
--- a/chromium/third_party/sqlite/src/src/btreeInt.h
+++ b/chromium/third_party/sqlite/src/src/btreeInt.h
@@ -293,7 +293,9 @@ struct MemPage {
u8 *apOvfl[4]; /* Pointers to the body of overflow cells */
BtShared *pBt; /* Pointer to BtShared that this page is part of */
u8 *aData; /* Pointer to disk image of the page data */
- u8 *aDataEnd; /* One byte past the end of usable data */
+ u8 *aDataEnd; /* One byte past the end of the entire page - not just
+ ** the usable space, the entire page. Used to prevent
+ ** corruption-induced of buffer overflow. */
u8 *aCellIdx; /* The cell index area */
u8 *aDataOfst; /* Same as aData for leaves. aData+4 for interior */
DbPage *pDbPage; /* Pager page handle */
diff --git a/chromium/third_party/sqlite/src/src/build.c b/chromium/third_party/sqlite/src/src/build.c
index d53ff3b6709..f7614af625e 100644
--- a/chromium/third_party/sqlite/src/src/build.c
+++ b/chromium/third_party/sqlite/src/src/build.c
@@ -143,11 +143,13 @@ void sqlite3FinishCoding(Parse *pParse){
assert( pParse->pToplevel==0 );
db = pParse->db;
+ assert( db->pParse==pParse );
if( pParse->nested ) return;
- if( db->mallocFailed || pParse->nErr ){
- if( pParse->rc==SQLITE_OK ) pParse->rc = SQLITE_ERROR;
+ if( pParse->nErr ){
+ if( db->mallocFailed ) pParse->rc = SQLITE_NOMEM;
return;
}
+ assert( db->mallocFailed==0 );
/* Begin by generating some termination code at the end of the
** vdbe program
@@ -170,9 +172,10 @@ void sqlite3FinishCoding(Parse *pParse){
int i;
int reg;
- if( pReturning->nRetCol==0 ){
+ if( NEVER(pReturning->nRetCol==0) ){
assert( CORRUPT_DB );
}else{
+ sqlite3VdbeAddOp0(v, OP_FkCheck);
addrRewind =
sqlite3VdbeAddOp1(v, OP_Rewind, pReturning->iRetCur);
VdbeCoverage(v);
@@ -265,7 +268,7 @@ void sqlite3FinishCoding(Parse *pParse){
if( pParse->bReturning ){
Returning *pRet = pParse->u1.pReturning;
- if( pRet->nRetCol==0 ){
+ if( NEVER(pRet->nRetCol==0) ){
assert( CORRUPT_DB );
}else{
sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pRet->iRetCur, pRet->nRetCol);
@@ -279,7 +282,9 @@ void sqlite3FinishCoding(Parse *pParse){
/* Get the VDBE program ready for execution
*/
- if( v && pParse->nErr==0 && !db->mallocFailed ){
+ assert( v!=0 || pParse->nErr );
+ assert( db->mallocFailed==0 || pParse->nErr );
+ if( pParse->nErr==0 ){
/* A minimum of one cursor is required if autoincrement is used
* See ticket [a696379c1f08866] */
assert( pParse->pAinc==0 || pParse->nTab>0 );
@@ -306,7 +311,6 @@ void sqlite3FinishCoding(Parse *pParse){
void sqlite3NestedParse(Parse *pParse, const char *zFormat, ...){
va_list ap;
char *zSql;
- char *zErrMsg = 0;
sqlite3 *db = pParse->db;
u32 savedDbFlags = db->mDbFlags;
char saveBuf[PARSE_TAIL_SZ];
@@ -328,9 +332,10 @@ void sqlite3NestedParse(Parse *pParse, const char *zFormat, ...){
memcpy(saveBuf, PARSE_TAIL(pParse), PARSE_TAIL_SZ);
memset(PARSE_TAIL(pParse), 0, PARSE_TAIL_SZ);
db->mDbFlags |= DBFLAG_PreferBuiltin;
- sqlite3RunParser(pParse, zSql, &zErrMsg);
+ sqlite3RunParser(pParse, zSql);
+ sqlite3DbFree(db, pParse->zErrMsg);
+ pParse->zErrMsg = 0;
db->mDbFlags = savedDbFlags;
- sqlite3DbFree(db, zErrMsg);
sqlite3DbFree(db, zSql);
memcpy(PARSE_TAIL(pParse), saveBuf, PARSE_TAIL_SZ);
pParse->nested--;
@@ -1290,7 +1295,8 @@ void sqlite3StartTable(
pTable = sqlite3FindTable(db, zName, zDb);
if( pTable ){
if( !noErr ){
- sqlite3ErrorMsg(pParse, "table %T already exists", pName);
+ sqlite3ErrorMsg(pParse, "%s %T already exists",
+ (IsView(pTable)? "view" : "table"), pName);
}else{
assert( !db->init.busy || CORRUPT_DB );
sqlite3CodeVerifySchema(pParse, iDb);
@@ -2385,10 +2391,11 @@ static void convertToWithoutRowidTable(Parse *pParse, Table *pTab){
pTab->iPKey = -1;
sqlite3CreateIndex(pParse, 0, 0, 0, pList, pTab->keyConf, 0, 0, 0, 0,
SQLITE_IDXTYPE_PRIMARYKEY);
- if( db->mallocFailed || pParse->nErr ){
+ if( pParse->nErr ){
pTab->tabFlags &= ~TF_WithoutRowid;
return;
}
+ assert( db->mallocFailed==0 );
pPk = sqlite3PrimaryKeyIndex(pTab);
assert( pPk->nKeyCol==1 );
}else{
@@ -2819,6 +2826,11 @@ void sqlite3EndTable(
int addrInsLoop; /* Top of the loop for inserting rows */
Table *pSelTab; /* A table that describes the SELECT results */
+ if( IN_SPECIAL_PARSE ){
+ pParse->rc = SQLITE_ERROR;
+ pParse->nErr++;
+ return;
+ }
regYield = ++pParse->nMem;
regRec = ++pParse->nMem;
regRowid = ++pParse->nMem;
@@ -3129,10 +3141,10 @@ int sqlite3ViewGetColumnNames(Parse *pParse, Table *pTable){
*/
sqlite3ColumnsFromExprList(pParse, pTable->pCheck,
&pTable->nCol, &pTable->aCol);
- if( db->mallocFailed==0
- && pParse->nErr==0
+ if( pParse->nErr==0
&& pTable->nCol==pSel->pEList->nExpr
){
+ assert( db->mallocFailed==0 );
sqlite3SelectAddColumnTypeAndCollation(pParse, pTable, pSel,
SQLITE_AFF_NONE);
}
@@ -3751,7 +3763,7 @@ static void sqlite3RefillIndex(Parse *pParse, Index *pIndex, int memRootPage){
tnum = pIndex->tnum;
}
pKey = sqlite3KeyInfoOfIndex(pParse, pIndex);
- assert( pKey!=0 || db->mallocFailed || pParse->nErr );
+ assert( pKey!=0 || pParse->nErr );
/* Open the sorter cursor if we are to use one. */
iSorter = pParse->nTab++;
@@ -3915,9 +3927,11 @@ void sqlite3CreateIndex(
char *zExtra = 0; /* Extra space after the Index object */
Index *pPk = 0; /* PRIMARY KEY index for WITHOUT ROWID tables */
- if( db->mallocFailed || pParse->nErr>0 ){
+ assert( db->pParse==pParse );
+ if( pParse->nErr ){
goto exit_create_index;
}
+ assert( db->mallocFailed==0 );
if( IN_DECLARE_VTAB && idxType!=SQLITE_IDXTYPE_PRIMARYKEY ){
goto exit_create_index;
}
@@ -3981,7 +3995,6 @@ void sqlite3CreateIndex(
pDb = &db->aDb[iDb];
assert( pTab!=0 );
- assert( pParse->nErr==0 );
if( sqlite3StrNICmp(pTab->zName, "sqlite_", 7)==0
&& db->init.busy==0
&& pTblName!=0
@@ -4405,13 +4418,13 @@ void sqlite3CreateIndex(
/* Add an entry in sqlite_schema for this index
*/
sqlite3NestedParse(pParse,
- "INSERT INTO %Q." LEGACY_SCHEMA_TABLE " VALUES('index',%Q,%Q,#%d,%Q);",
- db->aDb[iDb].zDbSName,
- pIndex->zName,
- pTab->zName,
- iMem,
- zStmt
- );
+ "INSERT INTO %Q." LEGACY_SCHEMA_TABLE " VALUES('index',%Q,%Q,#%d,%Q);",
+ db->aDb[iDb].zDbSName,
+ pIndex->zName,
+ pTab->zName,
+ iMem,
+ zStmt
+ );
sqlite3DbFree(db, zStmt);
/* Fill the index with data and reparse the schema. Code an OP_Expire
@@ -4545,10 +4558,10 @@ void sqlite3DropIndex(Parse *pParse, SrcList *pName, int ifExists){
sqlite3 *db = pParse->db;
int iDb;
- assert( pParse->nErr==0 ); /* Never called with prior errors */
if( db->mallocFailed ){
goto exit_drop_index;
}
+ assert( pParse->nErr==0 ); /* Never called with prior non-OOM errors */
assert( pName->nSrc==1 );
if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){
goto exit_drop_index;
@@ -4959,7 +4972,7 @@ SrcList *sqlite3SrcListAppendFromTerm(
pItem->pUsing = pUsing;
return p;
- append_from_error:
+append_from_error:
assert( p==0 );
sqlite3ExprDelete(db, pOn);
sqlite3IdListDelete(db, pUsing);
diff --git a/chromium/third_party/sqlite/src/src/callback.c b/chromium/third_party/sqlite/src/src/callback.c
index 936c374abd7..7d8f9dcbced 100644
--- a/chromium/third_party/sqlite/src/src/callback.c
+++ b/chromium/third_party/sqlite/src/src/callback.c
@@ -358,7 +358,6 @@ void sqlite3InsertBuiltinFuncs(
const char *zName = aDef[i].zName;
int nName = sqlite3Strlen30(zName);
int h = SQLITE_FUNC_HASH(zName[0], nName);
- assert( zName[0]>='a' && zName[0]<='z' );
assert( aDef[i].funcFlags & SQLITE_FUNC_BUILTIN );
pOther = sqlite3FunctionSearch(h, zName);
if( pOther ){
diff --git a/chromium/third_party/sqlite/src/src/ctime.c b/chromium/third_party/sqlite/src/src/ctime.c
index de68ea7f572..1463e4f552a 100644
--- a/chromium/third_party/sqlite/src/src/ctime.c
+++ b/chromium/third_party/sqlite/src/src/ctime.c
@@ -1,3 +1,11 @@
+/* DO NOT EDIT!
+** This file is automatically generated by the script in the canonical
+** SQLite source tree at tool/mkctimec.tcl.
+**
+** To modify this header, edit any of the various lists in that script
+** which specify categories of generated conditionals in this file.
+*/
+
/*
** 2010 February 23
**
@@ -46,9 +54,6 @@
*/
static const char * const sqlite3azCompileOpt[] = {
-/*
-** BEGIN CODE GENERATED BY tool/mkctime.tcl
-*/
#ifdef SQLITE_32BIT_ROWID
"32BIT_ROWID",
#endif
@@ -257,9 +262,6 @@ static const char * const sqlite3azCompileOpt[] = {
#ifdef SQLITE_ENABLE_IOTRACE
"ENABLE_IOTRACE",
#endif
-#ifdef SQLITE_ENABLE_JSON1
- "ENABLE_JSON1",
-#endif
#ifdef SQLITE_ENABLE_LOAD_EXTENSION
"ENABLE_LOAD_EXTENSION",
#endif
@@ -583,6 +585,9 @@ static const char * const sqlite3azCompileOpt[] = {
#ifdef SQLITE_OMIT_INTROSPECTION_PRAGMAS
"OMIT_INTROSPECTION_PRAGMAS",
#endif
+#ifdef SQLITE_OMIT_JSON
+ "OMIT_JSON",
+#endif
#ifdef SQLITE_OMIT_LIKE_OPTIMIZATION
"OMIT_LIKE_OPTIMIZATION",
#endif
@@ -771,10 +776,8 @@ static const char * const sqlite3azCompileOpt[] = {
#ifdef SQLITE_ZERO_MALLOC
"ZERO_MALLOC",
#endif
-/*
-** END CODE GENERATED BY tool/mkctime.tcl
-*/
-};
+
+} ;
const char **sqlite3CompileOptions(int *pnOpt){
*pnOpt = sizeof(sqlite3azCompileOpt) / sizeof(sqlite3azCompileOpt[0]);
diff --git a/chromium/third_party/sqlite/src/src/date.c b/chromium/third_party/sqlite/src/src/date.c
index 20a0a5d175a..6e2ba202b73 100644
--- a/chromium/third_party/sqlite/src/src/date.c
+++ b/chromium/third_party/sqlite/src/src/date.c
@@ -503,8 +503,10 @@ static void clearYMD_HMS_TZ(DateTime *p){
** is available. This routine returns 0 on success and
** non-zero on any kind of error.
**
-** If the sqlite3GlobalConfig.bLocaltimeFault variable is true then this
-** routine will always fail.
+** If the sqlite3GlobalConfig.bLocaltimeFault variable is non-zero then this
+** routine will always fail. If bLocaltimeFault is nonzero and
+** sqlite3GlobalConfig.xAltLocaltime is not NULL, then xAltLocaltime() is
+** invoked in place of the OS-defined localtime() function.
**
** EVIDENCE-OF: R-62172-00036 In this implementation, the standard C
** library function localtime_r() is used to assist in the calculation of
@@ -520,14 +522,30 @@ static int osLocaltime(time_t *t, struct tm *pTm){
sqlite3_mutex_enter(mutex);
pX = localtime(t);
#ifndef SQLITE_UNTESTABLE
- if( sqlite3GlobalConfig.bLocaltimeFault ) pX = 0;
+ if( sqlite3GlobalConfig.bLocaltimeFault ){
+ if( sqlite3GlobalConfig.xAltLocaltime!=0
+ && 0==sqlite3GlobalConfig.xAltLocaltime((const void*)t,(void*)pTm)
+ ){
+ pX = pTm;
+ }else{
+ pX = 0;
+ }
+ }
#endif
if( pX ) *pTm = *pX;
+#if SQLITE_THREADSAFE>0
sqlite3_mutex_leave(mutex);
+#endif
rc = pX==0;
#else
#ifndef SQLITE_UNTESTABLE
- if( sqlite3GlobalConfig.bLocaltimeFault ) return 1;
+ if( sqlite3GlobalConfig.bLocaltimeFault ){
+ if( sqlite3GlobalConfig.xAltLocaltime!=0 ){
+ return sqlite3GlobalConfig.xAltLocaltime((const void*)t,(void*)pTm);
+ }else{
+ return 1;
+ }
+ }
#endif
#if HAVE_LOCALTIME_R
rc = localtime_r(t, pTm)==0;
@@ -542,67 +560,56 @@ static int osLocaltime(time_t *t, struct tm *pTm){
#ifndef SQLITE_OMIT_LOCALTIME
/*
-** Compute the difference (in milliseconds) between localtime and UTC
-** (a.k.a. GMT) for the time value p where p is in UTC. If no error occurs,
-** return this value and set *pRc to SQLITE_OK.
-**
-** Or, if an error does occur, set *pRc to SQLITE_ERROR. The returned value
-** is undefined in this case.
+** Assuming the input DateTime is UTC, move it to its localtime equivalent.
*/
-static sqlite3_int64 localtimeOffset(
- DateTime *p, /* Date at which to calculate offset */
- sqlite3_context *pCtx, /* Write error here if one occurs */
- int *pRc /* OUT: Error code. SQLITE_OK or ERROR */
+static int toLocaltime(
+ DateTime *p, /* Date at which to calculate offset */
+ sqlite3_context *pCtx /* Write error here if one occurs */
){
- DateTime x, y;
time_t t;
struct tm sLocal;
+ int iYearDiff;
/* Initialize the contents of sLocal to avoid a compiler warning. */
memset(&sLocal, 0, sizeof(sLocal));
- x = *p;
- computeYMD_HMS(&x);
- if( x.Y<1971 || x.Y>=2038 ){
+ computeJD(p);
+ if( p->iJD<2108667600*(i64)100000 /* 1970-01-01 */
+ || p->iJD>2130141456*(i64)100000 /* 2038-01-18 */
+ ){
/* EVIDENCE-OF: R-55269-29598 The localtime_r() C function normally only
** works for years between 1970 and 2037. For dates outside this range,
** SQLite attempts to map the year into an equivalent year within this
** range, do the calculation, then map the year back.
*/
- x.Y = 2000;
- x.M = 1;
- x.D = 1;
- x.h = 0;
- x.m = 0;
- x.s = 0.0;
- } else {
- int s = (int)(x.s + 0.5);
- x.s = s;
+ DateTime x = *p;
+ computeYMD_HMS(&x);
+ iYearDiff = (2000 + x.Y%4) - x.Y;
+ x.Y += iYearDiff;
+ x.validJD = 0;
+ computeJD(&x);
+ t = (time_t)(x.iJD/1000 - 21086676*(i64)10000);
+ }else{
+ iYearDiff = 0;
+ t = (time_t)(p->iJD/1000 - 21086676*(i64)10000);
}
- x.tz = 0;
- x.validJD = 0;
- computeJD(&x);
- t = (time_t)(x.iJD/1000 - 21086676*(i64)10000);
if( osLocaltime(&t, &sLocal) ){
sqlite3_result_error(pCtx, "local time unavailable", -1);
- *pRc = SQLITE_ERROR;
- return 0;
+ return SQLITE_ERROR;
}
- y.Y = sLocal.tm_year + 1900;
- y.M = sLocal.tm_mon + 1;
- y.D = sLocal.tm_mday;
- y.h = sLocal.tm_hour;
- y.m = sLocal.tm_min;
- y.s = sLocal.tm_sec;
- y.validYMD = 1;
- y.validHMS = 1;
- y.validJD = 0;
- y.rawS = 0;
- y.validTZ = 0;
- y.isError = 0;
- computeJD(&y);
- *pRc = SQLITE_OK;
- return y.iJD - x.iJD;
+ p->Y = sLocal.tm_year + 1900 - iYearDiff;
+ p->M = sLocal.tm_mon + 1;
+ p->D = sLocal.tm_mday;
+ p->h = sLocal.tm_hour;
+ p->m = sLocal.tm_min;
+ p->s = sLocal.tm_sec + (p->iJD%1000)*0.001;
+ p->validYMD = 1;
+ p->validHMS = 1;
+ p->validJD = 0;
+ p->rawS = 0;
+ p->validTZ = 0;
+ p->isError = 0;
+ return SQLITE_OK;
}
#endif /* SQLITE_OMIT_LOCALTIME */
@@ -615,18 +622,17 @@ static sqlite3_int64 localtimeOffset(
** of several units of time.
*/
static const struct {
- u8 eType; /* Transformation type code */
- u8 nName; /* Length of th name */
- char *zName; /* Name of the transformation */
- double rLimit; /* Maximum NNN value for this transform */
- double rXform; /* Constant used for this transform */
+ u8 nName; /* Length of the name */
+ char zName[7]; /* Name of the transformation */
+ float rLimit; /* Maximum NNN value for this transform */
+ float rXform; /* Constant used for this transform */
} aXformType[] = {
- { 0, 6, "second", 464269060800.0, 1000.0 },
- { 0, 6, "minute", 7737817680.0, 60000.0 },
- { 0, 4, "hour", 128963628.0, 3600000.0 },
- { 0, 3, "day", 5373485.0, 86400000.0 },
- { 1, 5, "month", 176546.0, 2592000000.0 },
- { 2, 4, "year", 14713.0, 31536000000.0 },
+ { 6, "second", 4.6427e+14, 1.0 },
+ { 6, "minute", 7.7379e+12, 60.0 },
+ { 4, "hour", 1.2897e+11, 3600.0 },
+ { 3, "day", 5373485.0, 86400.0 },
+ { 5, "month", 176546.0, 2592000.0 },
+ { 4, "year", 14713.0, 31536000.0 },
};
/*
@@ -657,11 +663,55 @@ static int parseModifier(
sqlite3_context *pCtx, /* Function context */
const char *z, /* The text of the modifier */
int n, /* Length of zMod in bytes */
- DateTime *p /* The date/time value to be modified */
+ DateTime *p, /* The date/time value to be modified */
+ int idx /* Parameter index of the modifier */
){
int rc = 1;
double r;
switch(sqlite3UpperToLower[(u8)z[0]] ){
+ case 'a': {
+ /*
+ ** auto
+ **
+ ** If rawS is available, then interpret as a julian day number, or
+ ** a unix timestamp, depending on its magnitude.
+ */
+ if( sqlite3_stricmp(z, "auto")==0 ){
+ if( idx>1 ) return 1; /* IMP: R-33611-57934 */
+ if( !p->rawS || p->validJD ){
+ rc = 0;
+ p->rawS = 0;
+ }else if( p->s>=-21086676*(i64)10000 /* -4713-11-24 12:00:00 */
+ && p->s<=(25340230*(i64)10000)+799 /* 9999-12-31 23:59:59 */
+ ){
+ r = p->s*1000.0 + 210866760000000.0;
+ clearYMD_HMS_TZ(p);
+ p->iJD = (sqlite3_int64)(r + 0.5);
+ p->validJD = 1;
+ p->rawS = 0;
+ rc = 0;
+ }
+ }
+ break;
+ }
+ case 'j': {
+ /*
+ ** julianday
+ **
+ ** Always interpret the prior number as a julian-day value. If this
+ ** is not the first modifier, or if the prior argument is not a numeric
+ ** value in the allowed range of julian day numbers understood by
+ ** SQLite (0..5373484.5) then the result will be NULL.
+ */
+ if( sqlite3_stricmp(z, "julianday")==0 ){
+ if( idx>1 ) return 1; /* IMP: R-31176-64601 */
+ if( p->validJD && p->rawS ){
+ rc = 0;
+ p->rawS = 0;
+ }
+ }
+ break;
+ }
#ifndef SQLITE_OMIT_LOCALTIME
case 'l': {
/* localtime
@@ -670,9 +720,7 @@ static int parseModifier(
** show local time.
*/
if( sqlite3_stricmp(z, "localtime")==0 && sqlite3NotPureFunc(pCtx) ){
- computeJD(p);
- p->iJD += localtimeOffset(p, pCtx, &rc);
- clearYMD_HMS_TZ(p);
+ rc = toLocaltime(p, pCtx);
}
break;
}
@@ -685,6 +733,7 @@ static int parseModifier(
** seconds since 1970. Convert to a real julian day number.
*/
if( sqlite3_stricmp(z, "unixepoch")==0 && p->rawS ){
+ if( idx>1 ) return 1; /* IMP: R-49255-55373 */
r = p->s*1000.0 + 210866760000000.0;
if( r>=0.0 && r<464269060800000.0 ){
clearYMD_HMS_TZ(p);
@@ -697,18 +746,31 @@ static int parseModifier(
#ifndef SQLITE_OMIT_LOCALTIME
else if( sqlite3_stricmp(z, "utc")==0 && sqlite3NotPureFunc(pCtx) ){
if( p->tzSet==0 ){
- sqlite3_int64 c1;
+ i64 iOrigJD; /* Original localtime */
+ i64 iGuess; /* Guess at the corresponding utc time */
+ int cnt = 0; /* Safety to prevent infinite loop */
+ int iErr; /* Guess is off by this much */
+
computeJD(p);
- c1 = localtimeOffset(p, pCtx, &rc);
- if( rc==SQLITE_OK ){
- p->iJD -= c1;
- clearYMD_HMS_TZ(p);
- p->iJD += c1 - localtimeOffset(p, pCtx, &rc);
- }
+ iGuess = iOrigJD = p->iJD;
+ iErr = 0;
+ do{
+ DateTime new;
+ memset(&new, 0, sizeof(new));
+ iGuess -= iErr;
+ new.iJD = iGuess;
+ new.validJD = 1;
+ rc = toLocaltime(&new, pCtx);
+ if( rc ) return rc;
+ computeJD(&new);
+ iErr = new.iJD - iOrigJD;
+ }while( iErr && cnt++<3 );
+ memset(p, 0, sizeof(*p));
+ p->iJD = iGuess;
+ p->validJD = 1;
p->tzSet = 1;
- }else{
- rc = SQLITE_OK;
}
+ rc = SQLITE_OK;
}
#endif
break;
@@ -824,9 +886,10 @@ static int parseModifier(
&& sqlite3_strnicmp(aXformType[i].zName, z, n)==0
&& r>-aXformType[i].rLimit && r<aXformType[i].rLimit
){
- switch( aXformType[i].eType ){
- case 1: { /* Special processing to add months */
+ switch( i ){
+ case 4: { /* Special processing to add months */
int x;
+ assert( strcmp(aXformType[i].zName,"month")==0 );
computeYMD_HMS(p);
p->M += (int)r;
x = p->M>0 ? (p->M-1)/12 : (p->M-12)/12;
@@ -836,8 +899,9 @@ static int parseModifier(
r -= (int)r;
break;
}
- case 2: { /* Special processing to add years */
+ case 5: { /* Special processing to add years */
int y = (int)r;
+ assert( strcmp(aXformType[i].zName,"year")==0 );
computeYMD_HMS(p);
p->Y += y;
p->validJD = 0;
@@ -846,7 +910,7 @@ static int parseModifier(
}
}
computeJD(p);
- p->iJD += (sqlite3_int64)(r*aXformType[i].rXform + rRounder);
+ p->iJD += (sqlite3_int64)(r*1000.0*aXformType[i].rXform + rRounder);
rc = 0;
break;
}
@@ -896,7 +960,7 @@ static int isDate(
for(i=1; i<argc; i++){
z = sqlite3_value_text(argv[i]);
n = sqlite3_value_bytes(argv[i]);
- if( z==0 || parseModifier(context, (char*)z, n, p) ) return 1;
+ if( z==0 || parseModifier(context, (char*)z, n, p, i) ) return 1;
}
computeJD(p);
if( p->isError || !validJulianDay(p->iJD) ) return 1;
@@ -927,6 +991,24 @@ static void juliandayFunc(
}
/*
+** unixepoch( TIMESTRING, MOD, MOD, ...)
+**
+** Return the number of seconds (including fractional seconds) since
+** the unix epoch of 1970-01-01 00:00:00 GMT.
+*/
+static void unixepochFunc(
+ sqlite3_context *context,
+ int argc,
+ sqlite3_value **argv
+){
+ DateTime x;
+ if( isDate(context, argc, argv, &x)==0 ){
+ computeJD(&x);
+ sqlite3_result_int64(context, x.iJD/1000 - 21086676*(i64)10000);
+ }
+}
+
+/*
** datetime( TIMESTRING, MOD, MOD, ...)
**
** Return YYYY-MM-DD HH:MM:SS
@@ -938,11 +1020,38 @@ static void datetimeFunc(
){
DateTime x;
if( isDate(context, argc, argv, &x)==0 ){
- char zBuf[100];
+ int Y, s;
+ char zBuf[24];
computeYMD_HMS(&x);
- sqlite3_snprintf(sizeof(zBuf), zBuf, "%04d-%02d-%02d %02d:%02d:%02d",
- x.Y, x.M, x.D, x.h, x.m, (int)(x.s));
- sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT);
+ Y = x.Y;
+ if( Y<0 ) Y = -Y;
+ zBuf[1] = '0' + (Y/1000)%10;
+ zBuf[2] = '0' + (Y/100)%10;
+ zBuf[3] = '0' + (Y/10)%10;
+ zBuf[4] = '0' + (Y)%10;
+ zBuf[5] = '-';
+ zBuf[6] = '0' + (x.M/10)%10;
+ zBuf[7] = '0' + (x.M)%10;
+ zBuf[8] = '-';
+ zBuf[9] = '0' + (x.D/10)%10;
+ zBuf[10] = '0' + (x.D)%10;
+ zBuf[11] = ' ';
+ zBuf[12] = '0' + (x.h/10)%10;
+ zBuf[13] = '0' + (x.h)%10;
+ zBuf[14] = ':';
+ zBuf[15] = '0' + (x.m/10)%10;
+ zBuf[16] = '0' + (x.m)%10;
+ zBuf[17] = ':';
+ s = (int)x.s;
+ zBuf[18] = '0' + (s/10)%10;
+ zBuf[19] = '0' + (s)%10;
+ zBuf[20] = 0;
+ if( x.Y<0 ){
+ zBuf[0] = '-';
+ sqlite3_result_text(context, zBuf, 20, SQLITE_TRANSIENT);
+ }else{
+ sqlite3_result_text(context, &zBuf[1], 19, SQLITE_TRANSIENT);
+ }
}
}
@@ -958,10 +1067,20 @@ static void timeFunc(
){
DateTime x;
if( isDate(context, argc, argv, &x)==0 ){
- char zBuf[100];
+ int s;
+ char zBuf[16];
computeHMS(&x);
- sqlite3_snprintf(sizeof(zBuf), zBuf, "%02d:%02d:%02d", x.h, x.m, (int)x.s);
- sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT);
+ zBuf[0] = '0' + (x.h/10)%10;
+ zBuf[1] = '0' + (x.h)%10;
+ zBuf[2] = ':';
+ zBuf[3] = '0' + (x.m/10)%10;
+ zBuf[4] = '0' + (x.m)%10;
+ zBuf[5] = ':';
+ s = (int)x.s;
+ zBuf[6] = '0' + (s/10)%10;
+ zBuf[7] = '0' + (s)%10;
+ zBuf[8] = 0;
+ sqlite3_result_text(context, zBuf, 8, SQLITE_TRANSIENT);
}
}
@@ -977,10 +1096,28 @@ static void dateFunc(
){
DateTime x;
if( isDate(context, argc, argv, &x)==0 ){
- char zBuf[100];
+ int Y;
+ char zBuf[16];
computeYMD(&x);
- sqlite3_snprintf(sizeof(zBuf), zBuf, "%04d-%02d-%02d", x.Y, x.M, x.D);
- sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT);
+ Y = x.Y;
+ if( Y<0 ) Y = -Y;
+ zBuf[1] = '0' + (Y/1000)%10;
+ zBuf[2] = '0' + (Y/100)%10;
+ zBuf[3] = '0' + (Y/10)%10;
+ zBuf[4] = '0' + (Y)%10;
+ zBuf[5] = '-';
+ zBuf[6] = '0' + (x.M/10)%10;
+ zBuf[7] = '0' + (x.M)%10;
+ zBuf[8] = '-';
+ zBuf[9] = '0' + (x.D/10)%10;
+ zBuf[10] = '0' + (x.D)%10;
+ zBuf[11] = 0;
+ if( x.Y<0 ){
+ zBuf[0] = '-';
+ sqlite3_result_text(context, zBuf, 11, SQLITE_TRANSIENT);
+ }else{
+ sqlite3_result_text(context, &zBuf[1], 10, SQLITE_TRANSIENT);
+ }
}
}
@@ -1202,6 +1339,7 @@ void sqlite3RegisterDateTimeFunctions(void){
static FuncDef aDateTimeFuncs[] = {
#ifndef SQLITE_OMIT_DATETIME_FUNCS
PURE_DATE(julianday, -1, 0, 0, juliandayFunc ),
+ PURE_DATE(unixepoch, -1, 0, 0, unixepochFunc ),
PURE_DATE(date, -1, 0, 0, dateFunc ),
PURE_DATE(time, -1, 0, 0, timeFunc ),
PURE_DATE(datetime, -1, 0, 0, datetimeFunc ),
diff --git a/chromium/third_party/sqlite/src/src/dbpage.c b/chromium/third_party/sqlite/src/src/dbpage.c
index c4f0b539ef3..575ee677154 100644
--- a/chromium/third_party/sqlite/src/src/dbpage.c
+++ b/chromium/third_party/sqlite/src/src/dbpage.c
@@ -156,6 +156,7 @@ static int dbpageBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){
){
pIdxInfo->orderByConsumed = 1;
}
+ sqlite3VtabWriteAll(pIdxInfo);
return SQLITE_OK;
}
diff --git a/chromium/third_party/sqlite/src/src/delete.c b/chromium/third_party/sqlite/src/src/delete.c
index e2b283ea472..7b769e6a189 100644
--- a/chromium/third_party/sqlite/src/src/delete.c
+++ b/chromium/third_party/sqlite/src/src/delete.c
@@ -44,6 +44,16 @@ Table *sqlite3SrcListLookup(Parse *pParse, SrcList *pSrc){
return pTab;
}
+/* Generate byte-code that will report the number of rows modified
+** by a DELETE, INSERT, or UPDATE statement.
+*/
+void sqlite3CodeChangeCount(Vdbe *v, int regCounter, const char *zColName){
+ sqlite3VdbeAddOp0(v, OP_FkCheck);
+ sqlite3VdbeAddOp2(v, OP_ResultRow, regCounter, 1);
+ sqlite3VdbeSetNumCols(v, 1);
+ sqlite3VdbeSetColName(v, 0, COLNAME_NAME, zColName, SQLITE_STATIC);
+}
+
/* Return true if table pTab is read-only.
**
** A table is read-only if any of the following are true:
@@ -283,9 +293,11 @@ void sqlite3DeleteFrom(
memset(&sContext, 0, sizeof(sContext));
db = pParse->db;
- if( pParse->nErr || db->mallocFailed ){
+ assert( db->pParse==pParse );
+ if( pParse->nErr ){
goto delete_from_cleanup;
}
+ assert( db->mallocFailed==0 );
assert( pTabList->nSrc==1 );
@@ -466,7 +478,7 @@ void sqlite3DeleteFrom(
** ONEPASS_SINGLE: One-pass approach - at most one row deleted.
** ONEPASS_MULTI: One-pass approach - any number of rows may be deleted.
*/
- pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, 0, 0, wcf, iTabCur+1);
+ pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, 0, 0,0,wcf,iTabCur+1);
if( pWInfo==0 ) goto delete_from_cleanup;
eOnePass = sqlite3WhereOkOnePass(pWInfo, aiCurOnePass);
assert( IsVirtual(pTab)==0 || eOnePass!=ONEPASS_MULTI );
@@ -619,9 +631,7 @@ void sqlite3DeleteFrom(
** invoke the callback function.
*/
if( memCnt ){
- sqlite3VdbeAddOp2(v, OP_ChngCntRow, memCnt, 1);
- sqlite3VdbeSetNumCols(v, 1);
- sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "rows deleted", SQLITE_STATIC);
+ sqlite3CodeChangeCount(v, memCnt, "rows deleted");
}
delete_from_cleanup:
diff --git a/chromium/third_party/sqlite/src/src/expr.c b/chromium/third_party/sqlite/src/src/expr.c
index a51d37a7b70..271f06bc6af 100644
--- a/chromium/third_party/sqlite/src/src/expr.c
+++ b/chromium/third_party/sqlite/src/src/expr.c
@@ -769,9 +769,8 @@ static void heightOfSelect(const Select *pSelect, int *pnHeight){
** if appropriate.
*/
static void exprSetHeight(Expr *p){
- int nHeight = 0;
- heightOfExpr(p->pLeft, &nHeight);
- heightOfExpr(p->pRight, &nHeight);
+ int nHeight = p->pLeft ? p->pLeft->nHeight : 0;
+ if( p->pRight && p->pRight->nHeight>nHeight ) nHeight = p->pRight->nHeight;
if( ExprUseXSelect(p) ){
heightOfSelect(p->x.pSelect, &nHeight);
}else if( p->x.pList ){
@@ -1070,6 +1069,7 @@ Expr *sqlite3ExprFunction(
sqlite3ExprListDelete(db, pList); /* Avoid memory leak when malloc fails */
return 0;
}
+ pNew->w.iOfst = (int)(pToken->z - pParse->zTail);
if( pList
&& pList->nExpr > pParse->db->aLimit[SQLITE_LIMIT_FUNCTION_ARG]
&& !pParse->nested
@@ -1113,7 +1113,7 @@ void sqlite3ExprFunctionUsable(
** SQLITE_DBCONFIG_TRUSTED_SCHEMA is off (meaning
** that the schema is possibly tainted).
*/
- sqlite3ErrorMsg(pParse, "unsafe use of %s()", pDef->zName);
+ sqlite3ErrorMsg(pParse, "unsafe use of %#T()", pExpr);
}
}
}
@@ -1169,6 +1169,7 @@ void sqlite3ExprAssignVarNumber(Parse *pParse, Expr *pExpr, u32 n){
if( bOk==0 || i<1 || i>db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER] ){
sqlite3ErrorMsg(pParse, "variable number must be between ?1 and ?%d",
db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER]);
+ sqlite3RecordErrorOffsetOfExpr(pParse->db, pExpr);
return;
}
x = (ynVar)i;
@@ -1196,6 +1197,7 @@ void sqlite3ExprAssignVarNumber(Parse *pParse, Expr *pExpr, u32 n){
pExpr->iColumn = x;
if( x>db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER] ){
sqlite3ErrorMsg(pParse, "too many SQL variables");
+ sqlite3RecordErrorOffsetOfExpr(pParse->db, pExpr);
}
}
@@ -2803,8 +2805,7 @@ int sqlite3FindInIndex(
CollSeq *pReq = sqlite3BinaryCompareCollSeq(pParse, pLhs, pRhs);
int j;
- assert( pReq!=0 || pRhs->iColumn==XN_ROWID
- || pParse->nErr || db->mallocFailed );
+ assert( pReq!=0 || pRhs->iColumn==XN_ROWID || pParse->nErr );
for(j=0; j<nExpr; j++){
if( pIdx->aiColumn[j]!=pRhs->iColumn ) continue;
assert( pIdx->azColl[j] );
@@ -3280,10 +3281,8 @@ int sqlite3CodeSubselect(Parse *pParse, Expr *pExpr){
}
pSel->iLimit = 0;
if( sqlite3Select(pParse, pSel, &dest) ){
- if( pParse->nErr ){
- pExpr->op2 = pExpr->op;
- pExpr->op = TK_ERROR;
- }
+ pExpr->op2 = pExpr->op;
+ pExpr->op = TK_ERROR;
return 0;
}
pExpr->iTable = rReg = dest.iSDParm;
@@ -3500,10 +3499,9 @@ static void sqlite3ExprCodeIN(
}else{
destStep2 = destStep6 = sqlite3VdbeMakeLabel(pParse);
}
- if( pParse->nErr ) goto sqlite3ExprCodeIN_finished;
for(i=0; i<nVector; i++){
Expr *p = sqlite3VectorFieldSubexpr(pExpr->pLeft, i);
- if( pParse->db->mallocFailed ) goto sqlite3ExprCodeIN_oom_error;
+ if( pParse->nErr ) goto sqlite3ExprCodeIN_oom_error;
if( sqlite3ExprCanBeNull(p) ){
sqlite3VdbeAddOp2(v, OP_IsNull, rLhs+i, destStep2);
VdbeCoverage(v);
@@ -3641,11 +3639,12 @@ static void codeInteger(Parse *pParse, Expr *pExpr, int negFlag, int iMem){
c = sqlite3DecOrHexToI64(z, &value);
if( (c==3 && !negFlag) || (c==2) || (negFlag && value==SMALLEST_INT64)){
#ifdef SQLITE_OMIT_FLOATING_POINT
- sqlite3ErrorMsg(pParse, "oversized integer: %s%s", negFlag ? "-" : "", z);
+ sqlite3ErrorMsg(pParse, "oversized integer: %s%#T", negFlag?"-":"",pExpr);
#else
#ifndef SQLITE_OMIT_HEX_INTEGER
if( sqlite3_strnicmp(z,"0x",2)==0 ){
- sqlite3ErrorMsg(pParse, "hex literal too big: %s%s", negFlag?"-":"",z);
+ sqlite3ErrorMsg(pParse, "hex literal too big: %s%#T",
+ negFlag?"-":"",pExpr);
}else
#endif
{
@@ -4321,7 +4320,7 @@ expr_code_doover:
|| NEVER(pExpr->iAgg>=pInfo->nFunc)
){
assert( !ExprHasProperty(pExpr, EP_IntValue) );
- sqlite3ErrorMsg(pParse, "misuse of aggregate: %s()", pExpr->u.zToken);
+ sqlite3ErrorMsg(pParse, "misuse of aggregate: %#T()", pExpr);
}else{
return pInfo->aFunc[pExpr->iAgg].iMem;
}
@@ -4362,7 +4361,7 @@ expr_code_doover:
}
#endif
if( pDef==0 || pDef->xFinalize!=0 ){
- sqlite3ErrorMsg(pParse, "unknown function: %s()", zId);
+ sqlite3ErrorMsg(pParse, "unknown function: %#T()", pExpr);
break;
}
if( pDef->funcFlags & SQLITE_FUNC_INLINE ){
diff --git a/chromium/third_party/sqlite/src/src/fkey.c b/chromium/third_party/sqlite/src/src/fkey.c
index 13b08dfe191..b464743c786 100644
--- a/chromium/third_party/sqlite/src/src/fkey.c
+++ b/chromium/third_party/sqlite/src/src/fkey.c
@@ -651,7 +651,7 @@ static void fkScanChildren(
** clause. For each row found, increment either the deferred or immediate
** foreign key constraint counter. */
if( pParse->nErr==0 ){
- pWInfo = sqlite3WhereBegin(pParse, pSrc, pWhere, 0, 0, 0, 0);
+ pWInfo = sqlite3WhereBegin(pParse, pSrc, pWhere, 0, 0, 0, 0, 0);
sqlite3VdbeAddOp2(v, OP_FkCounter, pFKey->isDeferred, nIncr);
if( pWInfo ){
sqlite3WhereEnd(pWInfo);
@@ -703,6 +703,25 @@ static void fkTriggerDelete(sqlite3 *dbMem, Trigger *p){
}
/*
+** Clear the apTrigger[] cache of CASCADE triggers for all foreign keys
+** in a particular database. This needs to happen when the schema
+** changes.
+*/
+void sqlite3FkClearTriggerCache(sqlite3 *db, int iDb){
+ HashElem *k;
+ Hash *pHash = &db->aDb[iDb].pSchema->tblHash;
+ for(k=sqliteHashFirst(pHash); k; k=sqliteHashNext(k)){
+ Table *pTab = sqliteHashData(k);
+ FKey *pFKey;
+ if( !IsOrdinaryTable(pTab) ) continue;
+ for(pFKey=pTab->u.tab.pFKey; pFKey; pFKey=pFKey->pNextFrom){
+ fkTriggerDelete(db, pFKey->apTrigger[0]); pFKey->apTrigger[0] = 0;
+ fkTriggerDelete(db, pFKey->apTrigger[1]); pFKey->apTrigger[1] = 0;
+ }
+ }
+}
+
+/*
** This function is called to generate code that runs when table pTab is
** being dropped from the database. The SrcList passed as the second argument
** to this function contains a single entry guaranteed to resolve to
diff --git a/chromium/third_party/sqlite/src/src/func.c b/chromium/third_party/sqlite/src/src/func.c
index 6a2903d328b..7ccb5118e8a 100644
--- a/chromium/third_party/sqlite/src/src/func.c
+++ b/chromium/third_party/sqlite/src/src/func.c
@@ -97,6 +97,18 @@ static void typeofFunc(
sqlite3_result_text(context, azType[i], -1, SQLITE_STATIC);
}
+/* subtype(X)
+**
+** Return the subtype of X
+*/
+static void subtypeFunc(
+ sqlite3_context *context,
+ int argc,
+ sqlite3_value **argv
+){
+ UNUSED_PARAMETER(argc);
+ sqlite3_result_int(context, sqlite3_value_subtype(argv[0]));
+}
/*
** Implementation of the length() function
@@ -258,7 +270,7 @@ endInstrOOM:
}
/*
-** Implementation of the printf() function.
+** Implementation of the printf() (a.k.a. format()) SQL function.
*/
static void printfFunc(
sqlite3_context *context,
@@ -1027,39 +1039,42 @@ static const char hexdigits[] = {
};
/*
-** Implementation of the QUOTE() function. This function takes a single
-** argument. If the argument is numeric, the return value is the same as
-** the argument. If the argument is NULL, the return value is the string
-** "NULL". Otherwise, the argument is enclosed in single quotes with
-** single-quote escapes.
+** Append to pStr text that is the SQL literal representation of the
+** value contained in pValue.
*/
-static void quoteFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
- assert( argc==1 );
- UNUSED_PARAMETER(argc);
- switch( sqlite3_value_type(argv[0]) ){
+void sqlite3QuoteValue(StrAccum *pStr, sqlite3_value *pValue){
+ /* As currently implemented, the string must be initially empty.
+ ** we might relax this requirement in the future, but that will
+ ** require enhancements to the implementation. */
+ assert( pStr!=0 && pStr->nChar==0 );
+
+ switch( sqlite3_value_type(pValue) ){
case SQLITE_FLOAT: {
double r1, r2;
- char zBuf[50];
- r1 = sqlite3_value_double(argv[0]);
- sqlite3_snprintf(sizeof(zBuf), zBuf, "%!.15g", r1);
- sqlite3AtoF(zBuf, &r2, 20, SQLITE_UTF8);
- if( r1!=r2 ){
- sqlite3_snprintf(sizeof(zBuf), zBuf, "%!.20e", r1);
+ const char *zVal;
+ r1 = sqlite3_value_double(pValue);
+ sqlite3_str_appendf(pStr, "%!.15g", r1);
+ zVal = sqlite3_str_value(pStr);
+ if( zVal ){
+ sqlite3AtoF(zVal, &r2, pStr->nChar, SQLITE_UTF8);
+ if( r1!=r2 ){
+ sqlite3_str_reset(pStr);
+ sqlite3_str_appendf(pStr, "%!.20e", r1);
+ }
}
- sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT);
break;
}
case SQLITE_INTEGER: {
- sqlite3_result_value(context, argv[0]);
+ sqlite3_str_appendf(pStr, "%lld", sqlite3_value_int64(pValue));
break;
}
case SQLITE_BLOB: {
- char *zText = 0;
- char const *zBlob = sqlite3_value_blob(argv[0]);
- int nBlob = sqlite3_value_bytes(argv[0]);
- assert( zBlob==sqlite3_value_blob(argv[0]) ); /* No encoding change */
- zText = (char *)contextMalloc(context, (2*(i64)nBlob)+4);
- if( zText ){
+ char const *zBlob = sqlite3_value_blob(pValue);
+ int nBlob = sqlite3_value_bytes(pValue);
+ assert( zBlob==sqlite3_value_blob(pValue) ); /* No encoding change */
+ sqlite3StrAccumEnlarge(pStr, nBlob*2 + 4);
+ if( pStr->accError==0 ){
+ char *zText = pStr->zText;
int i;
for(i=0; i<nBlob; i++){
zText[(i*2)+2] = hexdigits[(zBlob[i]>>4)&0x0F];
@@ -1069,43 +1084,49 @@ static void quoteFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
zText[(nBlob*2)+3] = '\0';
zText[0] = 'X';
zText[1] = '\'';
- sqlite3_result_text(context, zText, -1, SQLITE_TRANSIENT);
- sqlite3_free(zText);
+ pStr->nChar = nBlob*2 + 3;
}
break;
}
case SQLITE_TEXT: {
- int i,j;
- u64 n;
- const unsigned char *zArg = sqlite3_value_text(argv[0]);
- char *z;
-
- if( zArg==0 ) return;
- for(i=0, n=0; zArg[i]; i++){ if( zArg[i]=='\'' ) n++; }
- z = contextMalloc(context, ((i64)i)+((i64)n)+3);
- if( z ){
- z[0] = '\'';
- for(i=0, j=1; zArg[i]; i++){
- z[j++] = zArg[i];
- if( zArg[i]=='\'' ){
- z[j++] = '\'';
- }
- }
- z[j++] = '\'';
- z[j] = 0;
- sqlite3_result_text(context, z, j, sqlite3_free);
- }
+ const unsigned char *zArg = sqlite3_value_text(pValue);
+ sqlite3_str_appendf(pStr, "%Q", zArg);
break;
}
default: {
- assert( sqlite3_value_type(argv[0])==SQLITE_NULL );
- sqlite3_result_text(context, "NULL", 4, SQLITE_STATIC);
+ assert( sqlite3_value_type(pValue)==SQLITE_NULL );
+ sqlite3_str_append(pStr, "NULL", 4);
break;
}
}
}
/*
+** Implementation of the QUOTE() function.
+**
+** The quote(X) function returns the text of an SQL literal which is the
+** value of its argument suitable for inclusion into an SQL statement.
+** Strings are surrounded by single-quotes with escapes on interior quotes
+** as needed. BLOBs are encoded as hexadecimal literals. Strings with
+** embedded NUL characters cannot be represented as string literals in SQL
+** and hence the returned string literal is truncated prior to the first NUL.
+*/
+static void quoteFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
+ sqlite3_str str;
+ sqlite3 *db = sqlite3_context_db_handle(context);
+ assert( argc==1 );
+ UNUSED_PARAMETER(argc);
+ sqlite3StrAccumInit(&str, db, 0, 0, db->aLimit[SQLITE_LIMIT_LENGTH]);
+ sqlite3QuoteValue(&str,argv[0]);
+ sqlite3_result_text(context, sqlite3StrAccumFinish(&str), str.nChar,
+ SQLITE_DYNAMIC);
+ if( str.accError!=SQLITE_OK ){
+ sqlite3_result_null(context);
+ sqlite3_result_error_code(context, str.accError);
+ }
+}
+
+/*
** The unicode() function. Return the integer unicode code-point value
** for the first character of the input string.
*/
@@ -2220,8 +2241,8 @@ void sqlite3RegisterBuiltinFunctions(void){
INLINE_FUNC(likelihood, 2, INLINEFUNC_unlikely, SQLITE_FUNC_UNLIKELY),
INLINE_FUNC(likely, 1, INLINEFUNC_unlikely, SQLITE_FUNC_UNLIKELY),
#ifdef SQLITE_ENABLE_OFFSET_SQL_FUNC
- FUNCTION2(sqlite_offset, 1, 0, 0, noopFunc, SQLITE_FUNC_OFFSET|
- SQLITE_FUNC_TYPEOF),
+ {1, SQLITE_FUNC_BUILTIN|SQLITE_UTF8|SQLITE_FUNC_OFFSET|SQLITE_FUNC_TYPEOF,
+ 0, 0, noopFunc, 0, 0, 0, "sqlite_offset", {0} },
#endif
FUNCTION(ltrim, 1, 1, 0, trimFunc ),
FUNCTION(ltrim, 2, 1, 0, trimFunc ),
@@ -2238,9 +2259,11 @@ void sqlite3RegisterBuiltinFunctions(void){
WAGGREGATE(max, 1, 1, 1, minmaxStep, minMaxFinalize, minMaxValue, 0,
SQLITE_FUNC_MINMAX|SQLITE_FUNC_ANYORDER ),
FUNCTION2(typeof, 1, 0, 0, typeofFunc, SQLITE_FUNC_TYPEOF),
+ FUNCTION2(subtype, 1, 0, 0, subtypeFunc, SQLITE_FUNC_TYPEOF),
FUNCTION2(length, 1, 0, 0, lengthFunc, SQLITE_FUNC_LENGTH),
FUNCTION(instr, 2, 0, 0, instrFunc ),
FUNCTION(printf, -1, 0, 0, printfFunc ),
+ FUNCTION(format, -1, 0, 0, printfFunc ),
FUNCTION(unicode, 1, 0, 0, unicodeFunc ),
FUNCTION(char, -1, 0, 0, charFunc ),
FUNCTION(abs, 1, 0, 0, absFunc ),
@@ -2339,6 +2362,7 @@ void sqlite3RegisterBuiltinFunctions(void){
#endif
sqlite3WindowFunctions();
sqlite3RegisterDateTimeFunctions();
+ sqlite3RegisterJsonFunctions();
sqlite3InsertBuiltinFuncs(aBuiltinFunc, ArraySize(aBuiltinFunc));
#if 0 /* Enable to print out how the built-in functions are hashed */
diff --git a/chromium/third_party/sqlite/src/src/global.c b/chromium/third_party/sqlite/src/src/global.c
index 34b7d9583b8..6ad3bb4654a 100644
--- a/chromium/third_party/sqlite/src/src/global.c
+++ b/chromium/third_party/sqlite/src/src/global.c
@@ -286,6 +286,7 @@ SQLITE_WSD struct Sqlite3Config sqlite3Config = {
0, /* xTestCallback */
#endif
0, /* bLocaltimeFault */
+ 0, /* xAltLocaltime */
0x7ffffffe, /* iOnceResetThreshold */
SQLITE_DEFAULT_SORTERREF_SIZE, /* szSorterRef */
0, /* iPrngSeed */
diff --git a/chromium/third_party/sqlite/src/src/insert.c b/chromium/third_party/sqlite/src/src/insert.c
index 4bd94e486b3..de01be3ba11 100644
--- a/chromium/third_party/sqlite/src/src/insert.c
+++ b/chromium/third_party/sqlite/src/src/insert.c
@@ -43,7 +43,7 @@ void sqlite3OpenTable(
}else{
Index *pPk = sqlite3PrimaryKeyIndex(pTab);
assert( pPk!=0 );
- assert( pPk->tnum==pTab->tnum );
+ assert( pPk->tnum==pTab->tnum || CORRUPT_DB );
sqlite3VdbeAddOp3(v, opcode, iCur, pPk->tnum, iDb);
sqlite3VdbeSetP4KeyInfo(pParse, pPk);
VdbeComment((v, "%s", pTab->zName));
@@ -715,9 +715,11 @@ void sqlite3Insert(
#endif
db = pParse->db;
- if( pParse->nErr || db->mallocFailed ){
+ assert( db->pParse==pParse );
+ if( pParse->nErr ){
goto insert_cleanup;
}
+ assert( db->mallocFailed==0 );
dest.iSDParm = 0; /* Suppress a harmless compiler warning */
/* If the Select object is really just a simple VALUES() list with a
@@ -793,7 +795,11 @@ void sqlite3Insert(
**
** This is the 2nd template.
*/
- if( pColumn==0 && xferOptimization(pParse, pTab, pSelect, onError, iDb) ){
+ if( pColumn==0
+ && pSelect!=0
+ && pTrigger==0
+ && xferOptimization(pParse, pTab, pSelect, onError, iDb)
+ ){
assert( !pTrigger );
assert( pList==0 );
goto insert_end;
@@ -893,7 +899,9 @@ void sqlite3Insert(
dest.nSdst = pTab->nCol;
rc = sqlite3Select(pParse, pSelect, &dest);
regFromSelect = dest.iSdst;
- if( rc || db->mallocFailed || pParse->nErr ) goto insert_cleanup;
+ assert( db->pParse==pParse );
+ if( rc || pParse->nErr ) goto insert_cleanup;
+ assert( db->mallocFailed==0 );
sqlite3VdbeEndCoroutine(v, regYield);
sqlite3VdbeJumpHere(v, addrTop - 1); /* label B: */
assert( pSelect->pEList );
@@ -1382,9 +1390,7 @@ insert_end:
** invoke the callback function.
*/
if( regRowCount ){
- sqlite3VdbeAddOp2(v, OP_ChngCntRow, regRowCount, 1);
- sqlite3VdbeSetNumCols(v, 1);
- sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "rows inserted", SQLITE_STATIC);
+ sqlite3CodeChangeCount(v, regRowCount, "rows inserted");
}
insert_cleanup:
@@ -2549,7 +2555,6 @@ void sqlite3CompleteInsertion(
}
pik_flags = (useSeekResult ? OPFLAG_USESEEKRESULT : 0);
if( IsPrimaryKeyIndex(pIdx) && !HasRowid(pTab) ){
- assert( pParse->nested==0 );
pik_flags |= OPFLAG_NCHANGE;
pik_flags |= (update_flags & OPFLAG_SAVEPOSITION);
if( update_flags==0 ){
@@ -2765,18 +2770,13 @@ static int xferOptimization(
int destHasUniqueIdx = 0; /* True if pDest has a UNIQUE index */
int regData, regRowid; /* Registers holding data and rowid */
- if( pSelect==0 ){
- return 0; /* Must be of the form INSERT INTO ... SELECT ... */
- }
+ assert( pSelect!=0 );
if( pParse->pWith || pSelect->pWith ){
/* Do not attempt to process this query if there are an WITH clauses
** attached to it. Proceeding may generate a false "no such table: xxx"
** error if pSelect reads from a CTE named "xxx". */
return 0;
}
- if( sqlite3TriggerList(pParse, pDest) ){
- return 0; /* tab1 must not have triggers */
- }
#ifndef SQLITE_OMIT_VIRTUALTABLE
if( IsVirtual(pDest) ){
return 0; /* tab1 must not be a virtual table */
diff --git a/chromium/third_party/sqlite/src/ext/misc/json1.c b/chromium/third_party/sqlite/src/src/json.c
index 7fcd7342a61..ab1d32d6a54 100644
--- a/chromium/third_party/sqlite/src/ext/misc/json1.c
+++ b/chromium/third_party/sqlite/src/src/json.c
@@ -10,10 +10,10 @@
**
******************************************************************************
**
-** This SQLite extension implements JSON functions. The interface is
-** modeled after MySQL JSON functions:
+** This SQLite JSON functions.
**
-** https://dev.mysql.com/doc/refman/5.7/en/json.html
+** This file began as an extension in ext/misc/json1.c in 2015. That
+** extension proved so useful that it has now been moved into the core.
**
** For the time being, all JSON is stored as pure text. (We might add
** a JSONB type in the future which stores a binary encoding of JSON in
@@ -21,48 +21,8 @@
** This implementation parses JSON text at 250 MB/s, so it is hard to see
** how JSONB might improve on that.)
*/
-#if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_JSON1)
-#if !defined(SQLITEINT_H)
-#include "sqlite3ext.h"
-#endif
-SQLITE_EXTENSION_INIT1
-#include <assert.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdarg.h>
-
-/* Mark a function parameter as unused, to suppress nuisance compiler
-** warnings. */
-#ifndef UNUSED_PARAM
-# define UNUSED_PARAM(X) (void)(X)
-#endif
-
-#ifndef LARGEST_INT64
-# define LARGEST_INT64 (0xffffffff|(((sqlite3_int64)0x7fffffff)<<32))
-# define SMALLEST_INT64 (((sqlite3_int64)-1) - LARGEST_INT64)
-#endif
-
-#ifndef deliberate_fall_through
-# define deliberate_fall_through
-#endif
-
-/*
-** Versions of isspace(), isalnum() and isdigit() to which it is safe
-** to pass signed char values.
-*/
-#ifdef sqlite3Isdigit
- /* Use the SQLite core versions if this routine is part of the
- ** SQLite amalgamation */
-# define safe_isdigit(x) sqlite3Isdigit(x)
-# define safe_isalnum(x) sqlite3Isalnum(x)
-# define safe_isxdigit(x) sqlite3Isxdigit(x)
-#else
- /* Use the standard library for separate compilation */
-#include <ctype.h> /* amalgamator: keep */
-# define safe_isdigit(x) isdigit((unsigned char)(x))
-# define safe_isalnum(x) isalnum((unsigned char)(x))
-# define safe_isxdigit(x) isxdigit((unsigned char)(x))
-#endif
+#ifndef SQLITE_OMIT_JSON
+#include "sqliteInt.h"
/*
** Growing our own isspace() routine this way is twice as fast as
@@ -87,44 +47,14 @@ static const char jsonIsSpace[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
};
-#define safe_isspace(x) (jsonIsSpace[(unsigned char)x])
-
-#ifndef SQLITE_AMALGAMATION
- /* Unsigned integer types. These are already defined in the sqliteInt.h,
- ** but the definitions need to be repeated for separate compilation. */
- typedef sqlite3_uint64 u64;
- typedef unsigned int u32;
- typedef unsigned short int u16;
- typedef unsigned char u8;
-# if defined(SQLITE_COVERAGE_TEST) || defined(SQLITE_MUTATION_TEST)
-# define SQLITE_OMIT_AUXILIARY_SAFETY_CHECKS 1
-# endif
-# if defined(SQLITE_OMIT_AUXILIARY_SAFETY_CHECKS)
-# define ALWAYS(X) (1)
-# define NEVER(X) (0)
-# elif !defined(NDEBUG)
-# define ALWAYS(X) ((X)?1:(assert(0),0))
-# define NEVER(X) ((X)?(assert(0),1):0)
-# else
-# define ALWAYS(X) (X)
-# define NEVER(X) (X)
-# endif
-# define testcase(X)
-#endif
+#define fast_isspace(x) (jsonIsSpace[(unsigned char)x])
+
#if !defined(SQLITE_DEBUG) && !defined(SQLITE_COVERAGE_TEST)
# define VVA(X)
#else
# define VVA(X) X
#endif
-/*
-** Some of the testcase() macros in this file are problematic for gcov
-** in that they generate false-miss errors randomly. This is a gcov problem,
-** not a problem in this case. But to work around it, we disable the
-** problematic test cases for production builds.
-*/
-#define json_testcase(X)
-
/* Objects */
typedef struct JsonString JsonString;
typedef struct JsonNode JsonNode;
@@ -582,10 +512,10 @@ static u8 jsonHexToInt(int h){
*/
static u32 jsonHexToInt4(const char *z){
u32 v;
- assert( safe_isxdigit(z[0]) );
- assert( safe_isxdigit(z[1]) );
- assert( safe_isxdigit(z[2]) );
- assert( safe_isxdigit(z[3]) );
+ assert( sqlite3Isxdigit(z[0]) );
+ assert( sqlite3Isxdigit(z[1]) );
+ assert( sqlite3Isxdigit(z[2]) );
+ assert( sqlite3Isxdigit(z[3]) );
v = (jsonHexToInt(z[0])<<12)
+ (jsonHexToInt(z[1])<<8)
+ (jsonHexToInt(z[2])<<4)
@@ -820,7 +750,7 @@ static int jsonParseAddNode(
*/
static int jsonIs4Hex(const char *z){
int i;
- for(i=0; i<4; i++) if( !safe_isxdigit(z[i]) ) return 0;
+ for(i=0; i<4; i++) if( !sqlite3Isxdigit(z[i]) ) return 0;
return 1;
}
@@ -839,13 +769,13 @@ static int jsonParseValue(JsonParse *pParse, u32 i){
int x;
JsonNode *pNode;
const char *z = pParse->zJson;
- while( safe_isspace(z[i]) ){ i++; }
+ while( fast_isspace(z[i]) ){ i++; }
if( (c = z[i])=='{' ){
/* Parse object */
iThis = jsonParseAddNode(pParse, JSON_OBJECT, 0, 0);
if( iThis<0 ) return -1;
for(j=i+1;;j++){
- while( safe_isspace(z[j]) ){ j++; }
+ while( fast_isspace(z[j]) ){ j++; }
if( ++pParse->iDepth > JSON_MAX_DEPTH ) return -1;
x = jsonParseValue(pParse, j);
if( x<0 ){
@@ -858,14 +788,14 @@ static int jsonParseValue(JsonParse *pParse, u32 i){
if( pNode->eType!=JSON_STRING ) return -1;
pNode->jnFlags |= JNODE_LABEL;
j = x;
- while( safe_isspace(z[j]) ){ j++; }
+ while( fast_isspace(z[j]) ){ j++; }
if( z[j]!=':' ) return -1;
j++;
x = jsonParseValue(pParse, j);
pParse->iDepth--;
if( x<0 ) return -1;
j = x;
- while( safe_isspace(z[j]) ){ j++; }
+ while( fast_isspace(z[j]) ){ j++; }
c = z[j];
if( c==',' ) continue;
if( c!='}' ) return -1;
@@ -879,7 +809,7 @@ static int jsonParseValue(JsonParse *pParse, u32 i){
if( iThis<0 ) return -1;
memset(&pParse->aNode[iThis].u, 0, sizeof(pParse->aNode[iThis].u));
for(j=i+1;;j++){
- while( safe_isspace(z[j]) ){ j++; }
+ while( fast_isspace(z[j]) ){ j++; }
if( ++pParse->iDepth > JSON_MAX_DEPTH ) return -1;
x = jsonParseValue(pParse, j);
pParse->iDepth--;
@@ -888,7 +818,7 @@ static int jsonParseValue(JsonParse *pParse, u32 i){
return -1;
}
j = x;
- while( safe_isspace(z[j]) ){ j++; }
+ while( fast_isspace(z[j]) ){ j++; }
c = z[j];
if( c==',' ) continue;
if( c!=']' ) return -1;
@@ -925,17 +855,17 @@ static int jsonParseValue(JsonParse *pParse, u32 i){
return j+1;
}else if( c=='n'
&& strncmp(z+i,"null",4)==0
- && !safe_isalnum(z[i+4]) ){
+ && !sqlite3Isalnum(z[i+4]) ){
jsonParseAddNode(pParse, JSON_NULL, 0, 0);
return i+4;
}else if( c=='t'
&& strncmp(z+i,"true",4)==0
- && !safe_isalnum(z[i+4]) ){
+ && !sqlite3Isalnum(z[i+4]) ){
jsonParseAddNode(pParse, JSON_TRUE, 0, 0);
return i+4;
}else if( c=='f'
&& strncmp(z+i,"false",5)==0
- && !safe_isalnum(z[i+5]) ){
+ && !sqlite3Isalnum(z[i+5]) ){
jsonParseAddNode(pParse, JSON_FALSE, 0, 0);
return i+5;
}else if( c=='-' || (c>='0' && c<='9') ){
@@ -1006,7 +936,7 @@ static int jsonParse(
if( pParse->oom ) i = -1;
if( i>0 ){
assert( pParse->iDepth==0 );
- while( safe_isspace(zJson[i]) ) i++;
+ while( fast_isspace(zJson[i]) ) i++;
if( zJson[i] ) i = -1;
}
if( i<=0 ){
@@ -1234,7 +1164,7 @@ static JsonNode *jsonLookupStep(
}else if( zPath[0]=='[' ){
i = 0;
j = 1;
- while( safe_isdigit(zPath[j]) ){
+ while( sqlite3Isdigit(zPath[j]) ){
i = i*10 + zPath[j] - '0';
j++;
}
@@ -1255,13 +1185,13 @@ static JsonNode *jsonLookupStep(
j = 1;
}
j = 2;
- if( zPath[2]=='-' && safe_isdigit(zPath[3]) ){
+ if( zPath[2]=='-' && sqlite3Isdigit(zPath[3]) ){
unsigned int x = 0;
j = 3;
do{
x = x*10 + zPath[j] - '0';
j++;
- }while( safe_isdigit(zPath[j]) );
+ }while( sqlite3Isdigit(zPath[j]) );
if( x>i ) return 0;
i -= x;
}
@@ -1480,7 +1410,7 @@ static void jsonTest1Func(
int argc,
sqlite3_value **argv
){
- UNUSED_PARAM(argc);
+ UNUSED_PARAMETER(argc);
sqlite3_result_int(ctx, sqlite3_value_subtype(argv[0])==JSON_SUBTYPE);
}
#endif /* SQLITE_DEBUG */
@@ -1501,7 +1431,7 @@ static void jsonQuoteFunc(
sqlite3_value **argv
){
JsonString jx;
- UNUSED_PARAM(argc);
+ UNUSED_PARAMETER(argc);
jsonInit(&jx, ctx);
jsonAppendValue(&jx, argv[0]);
@@ -1573,12 +1503,33 @@ static void jsonArrayLengthFunc(
}
/*
+** Bit values for the flags passed into jsonExtractFunc() or
+** jsonSetFunc() via the user-data value.
+*/
+#define JSON_JSON 0x01 /* Result is always JSON */
+#define JSON_SQL 0x02 /* Result is always SQL */
+#define JSON_ABPATH 0x03 /* Allow abbreviated JSON path specs */
+#define JSON_ISSET 0x04 /* json_set(), not json_insert() */
+
+/*
** json_extract(JSON, PATH, ...)
+** "->"(JSON,PATH)
+** "->>"(JSON,PATH)
+**
+** Return the element described by PATH. Return NULL if that PATH element
+** is not found.
**
-** Return the element described by PATH. Return NULL if there is no
-** PATH element. If there are multiple PATHs, then return a JSON array
-** with the result from each path. Throw an error if the JSON or any PATH
-** is malformed.
+** If JSON_JSON is set or if more that one PATH argument is supplied then
+** always return a JSON representation of the result. If JSON_SQL is set,
+** then always return an SQL representation of the result. If neither flag
+** is present and argc==2, then return JSON for objects and arrays and SQL
+** for all other values.
+**
+** When multiple PATH arguments are supplied, the result is a JSON array
+** containing the result of each PATH.
+**
+** Abbreviated JSON path expressions are allows if JSON_ABPATH, for
+** compatibility with PG.
*/
static void jsonExtractFunc(
sqlite3_context *ctx,
@@ -1588,35 +1539,77 @@ static void jsonExtractFunc(
JsonParse *p; /* The parse */
JsonNode *pNode;
const char *zPath;
+ int flags = SQLITE_PTR_TO_INT(sqlite3_user_data(ctx));
JsonString jx;
- int i;
if( argc<2 ) return;
p = jsonParseCached(ctx, argv, ctx);
if( p==0 ) return;
- jsonInit(&jx, ctx);
- jsonAppendChar(&jx, '[');
- for(i=1; i<argc; i++){
- zPath = (const char*)sqlite3_value_text(argv[i]);
- pNode = jsonLookup(p, zPath, 0, ctx);
- if( p->nErr ) break;
- if( argc>2 ){
+ if( argc==2 ){
+ /* With a single PATH argument */
+ zPath = (const char*)sqlite3_value_text(argv[1]);
+ if( zPath==0 ) return;
+ if( flags & JSON_ABPATH ){
+ if( zPath[0]!='$' ){
+ /* The -> and ->> operators accept abbreviated PATH arguments. This
+ ** is mostly for compatibility with PostgreSQL, but also for
+ ** convenience.
+ **
+ ** NUMBER ==> $[NUMBER] // PG compatible
+ ** LABEL ==> $.LABEL // PG compatible
+ ** [NUMBER] ==> $[NUMBER] // Not PG. Purely for convenience
+ */
+ jsonInit(&jx, ctx);
+ if( sqlite3Isdigit(zPath[0]) ){
+ jsonAppendRaw(&jx, "$[", 2);
+ jsonAppendRaw(&jx, zPath, (int)strlen(zPath));
+ jsonAppendRaw(&jx, "]", 2);
+ }else{
+ jsonAppendRaw(&jx, "$.", 1 + (zPath[0]!='['));
+ jsonAppendRaw(&jx, zPath, (int)strlen(zPath));
+ jsonAppendChar(&jx, 0);
+ }
+ pNode = jx.bErr ? 0 : jsonLookup(p, jx.zBuf, 0, ctx);
+ jsonReset(&jx);
+ }else{
+ pNode = jsonLookup(p, zPath, 0, ctx);
+ }
+ if( pNode ){
+ if( flags & JSON_JSON ){
+ jsonReturnJson(pNode, ctx, 0);
+ }else{
+ jsonReturn(pNode, ctx, 0);
+ sqlite3_result_subtype(ctx, 0);
+ }
+ }
+ }else{
+ pNode = jsonLookup(p, zPath, 0, ctx);
+ if( p->nErr==0 && pNode ) jsonReturn(pNode, ctx, 0);
+ }
+ }else{
+ /* Two or more PATH arguments results in a JSON array with each
+ ** element of the array being the value selected by one of the PATHs */
+ int i;
+ jsonInit(&jx, ctx);
+ jsonAppendChar(&jx, '[');
+ for(i=1; i<argc; i++){
+ zPath = (const char*)sqlite3_value_text(argv[i]);
+ pNode = jsonLookup(p, zPath, 0, ctx);
+ if( p->nErr ) break;
jsonAppendSeparator(&jx);
if( pNode ){
jsonRenderNode(pNode, &jx, 0);
}else{
jsonAppendRaw(&jx, "null", 4);
}
- }else if( pNode ){
- jsonReturn(pNode, ctx, 0);
}
+ if( i==argc ){
+ jsonAppendChar(&jx, ']');
+ jsonResult(&jx);
+ sqlite3_result_subtype(ctx, JSON_SUBTYPE);
+ }
+ jsonReset(&jx);
}
- if( argc>2 && i==argc ){
- jsonAppendChar(&jx, ']');
- jsonResult(&jx);
- sqlite3_result_subtype(ctx, JSON_SUBTYPE);
- }
- jsonReset(&jx);
}
/* This is the RFC 7396 MergePatch algorithm.
@@ -1712,7 +1705,7 @@ static void jsonPatchFunc(
JsonParse y; /* The patch */
JsonNode *pResult; /* The result of the merge */
- UNUSED_PARAM(argc);
+ UNUSED_PARAMETER(argc);
if( jsonParse(&x, ctx, (const char*)sqlite3_value_text(argv[0])) ) return;
if( jsonParse(&y, ctx, (const char*)sqlite3_value_text(argv[1])) ){
jsonParseReset(&x);
@@ -1833,7 +1826,7 @@ static void jsonReplaceFunc(
if( x.nErr ) goto replace_err;
if( pNode ){
assert( pNode->eU==0 || pNode->eU==1 || pNode->eU==4 );
- json_testcase( pNode->eU!=0 && pNode->eU!=1 );
+ testcase( pNode->eU!=0 && pNode->eU!=1 );
pNode->jnFlags |= (u8)JNODE_REPLACE;
VVA( pNode->eU = 4 );
pNode->u.iReplace = i + 1;
@@ -1849,6 +1842,7 @@ replace_err:
jsonParseReset(&x);
}
+
/*
** json_set(JSON, PATH, VALUE, ...)
**
@@ -1871,7 +1865,7 @@ static void jsonSetFunc(
const char *zPath;
u32 i;
int bApnd;
- int bIsSet = *(int*)sqlite3_user_data(ctx);
+ int bIsSet = sqlite3_user_data(ctx)!=0;
if( argc<1 ) return;
if( (argc&1)==0 ) {
@@ -1890,8 +1884,8 @@ static void jsonSetFunc(
}else if( x.nErr ){
goto jsonSetDone;
}else if( pNode && (bApnd || bIsSet) ){
- json_testcase( pNode->eU!=0 && pNode->eU!=1 && pNode->eU!=4 );
- assert( pNode->eU!=3 || pNode->eU!=5 );
+ testcase( pNode->eU!=0 && pNode->eU!=1 );
+ assert( pNode->eU!=3 && pNode->eU!=5 );
VVA( pNode->eU = 4 );
pNode->jnFlags |= (u8)JNODE_REPLACE;
pNode->u.iReplace = i + 1;
@@ -1911,8 +1905,8 @@ jsonSetDone:
** json_type(JSON)
** json_type(JSON, PATH)
**
-** Return the top-level "type" of a JSON string. Throw an error if
-** either the JSON or PATH inputs are not well-formed.
+** Return the top-level "type" of a JSON string. json_type() raises an
+** error if either the JSON or PATH inputs are not well-formed.
*/
static void jsonTypeFunc(
sqlite3_context *ctx,
@@ -1948,7 +1942,7 @@ static void jsonValidFunc(
sqlite3_value **argv
){
JsonParse *p; /* The parse */
- UNUSED_PARAM(argc);
+ UNUSED_PARAMETER(argc);
p = jsonParseCached(ctx, argv, 0);
sqlite3_result_int(ctx, p!=0);
}
@@ -1968,7 +1962,7 @@ static void jsonArrayStep(
sqlite3_value **argv
){
JsonString *pStr;
- UNUSED_PARAM(argc);
+ UNUSED_PARAMETER(argc);
pStr = (JsonString*)sqlite3_aggregate_context(ctx, sizeof(*pStr));
if( pStr ){
if( pStr->zBuf==0 ){
@@ -2028,8 +2022,8 @@ static void jsonGroupInverse(
char *z;
char c;
JsonString *pStr;
- UNUSED_PARAM(argc);
- UNUSED_PARAM(argv);
+ UNUSED_PARAMETER(argc);
+ UNUSED_PARAMETER(argv);
pStr = (JsonString*)sqlite3_aggregate_context(ctx, 0);
#ifdef NEVER
/* pStr is always non-NULL since jsonArrayStep() or jsonObjectStep() will
@@ -2073,7 +2067,7 @@ static void jsonObjectStep(
JsonString *pStr;
const char *z;
u32 n;
- UNUSED_PARAM(argc);
+ UNUSED_PARAMETER(argc);
pStr = (JsonString*)sqlite3_aggregate_context(ctx, sizeof(*pStr));
if( pStr ){
if( pStr->zBuf==0 ){
@@ -2164,10 +2158,10 @@ static int jsonEachConnect(
#define JEACH_JSON 8
#define JEACH_ROOT 9
- UNUSED_PARAM(pzErr);
- UNUSED_PARAM(argv);
- UNUSED_PARAM(argc);
- UNUSED_PARAM(pAux);
+ UNUSED_PARAMETER(pzErr);
+ UNUSED_PARAMETER(argv);
+ UNUSED_PARAMETER(argc);
+ UNUSED_PARAMETER(pAux);
rc = sqlite3_declare_vtab(db,
"CREATE TABLE x(key,value,type,atom,id,parent,fullkey,path,"
"json HIDDEN,root HIDDEN)");
@@ -2190,7 +2184,7 @@ static int jsonEachDisconnect(sqlite3_vtab *pVtab){
static int jsonEachOpenEach(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor){
JsonEachCursor *pCur;
- UNUSED_PARAM(p);
+ UNUSED_PARAMETER(p);
pCur = sqlite3_malloc( sizeof(*pCur) );
if( pCur==0 ) return SQLITE_NOMEM;
memset(pCur, 0, sizeof(*pCur));
@@ -2250,7 +2244,7 @@ static int jsonEachNext(sqlite3_vtab_cursor *cur){
p->eType = pUp->eType;
if( pUp->eType==JSON_ARRAY ){
assert( pUp->eU==0 || pUp->eU==3 );
- json_testcase( pUp->eU==3 );
+ testcase( pUp->eU==3 );
VVA( pUp->eU = 3 );
if( iUp==p->i-1 ){
pUp->u.iKey = 0;
@@ -2437,7 +2431,7 @@ static int jsonEachBestIndex(
/* This implementation assumes that JSON and ROOT are the last two
** columns in the table */
assert( JEACH_ROOT == JEACH_JSON+1 );
- UNUSED_PARAM(tab);
+ UNUSED_PARAMETER(tab);
aIdx[0] = aIdx[1] = -1;
pConstraint = pIdxInfo->aConstraint;
for(i=0; i<pIdxInfo->nConstraint; i++, pConstraint++){
@@ -2493,8 +2487,8 @@ static int jsonEachFilter(
const char *zRoot = 0;
sqlite3_int64 n;
- UNUSED_PARAM(idxStr);
- UNUSED_PARAM(argc);
+ UNUSED_PARAMETER(idxStr);
+ UNUSED_PARAMETER(argc);
jsonEachCursorReset(p);
if( idxNum==0 ) return SQLITE_OK;
z = (const char*)sqlite3_value_text(argv[0]);
@@ -2619,103 +2613,63 @@ static sqlite3_module jsonTreeModule = {
0 /* xShadowName */
};
#endif /* SQLITE_OMIT_VIRTUALTABLE */
+#endif /* !defined(SQLITE_OMIT_JSON) */
-/****************************************************************************
-** The following routines are the only publically visible identifiers in this
-** file. Call the following routines in order to register the various SQL
-** functions and the virtual table implemented by this file.
-****************************************************************************/
-
-int sqlite3Json1Init(sqlite3 *db){
- int rc = SQLITE_OK;
- unsigned int i;
- static const struct {
- const char *zName;
- int nArg;
- int flag;
- void (*xFunc)(sqlite3_context*,int,sqlite3_value**);
- } aFunc[] = {
- { "json", 1, 0, jsonRemoveFunc },
- { "json_array", -1, 0, jsonArrayFunc },
- { "json_array_length", 1, 0, jsonArrayLengthFunc },
- { "json_array_length", 2, 0, jsonArrayLengthFunc },
- { "json_extract", -1, 0, jsonExtractFunc },
- { "json_insert", -1, 0, jsonSetFunc },
- { "json_object", -1, 0, jsonObjectFunc },
- { "json_patch", 2, 0, jsonPatchFunc },
- { "json_quote", 1, 0, jsonQuoteFunc },
- { "json_remove", -1, 0, jsonRemoveFunc },
- { "json_replace", -1, 0, jsonReplaceFunc },
- { "json_set", -1, 1, jsonSetFunc },
- { "json_type", 1, 0, jsonTypeFunc },
- { "json_type", 2, 0, jsonTypeFunc },
- { "json_valid", 1, 0, jsonValidFunc },
-
+/*
+** Register JSON functions.
+*/
+void sqlite3RegisterJsonFunctions(void){
+#ifndef SQLITE_OMIT_JSON
+ static FuncDef aJsonFunc[] = {
+ JFUNCTION(json, 1, 0, jsonRemoveFunc),
+ JFUNCTION(json_array, -1, 0, jsonArrayFunc),
+ JFUNCTION(json_array_length, 1, 0, jsonArrayLengthFunc),
+ JFUNCTION(json_array_length, 2, 0, jsonArrayLengthFunc),
+ JFUNCTION(json_extract, -1, 0, jsonExtractFunc),
+ JFUNCTION(->, 2, JSON_JSON, jsonExtractFunc),
+ JFUNCTION(->>, 2, JSON_SQL, jsonExtractFunc),
+ JFUNCTION(json_insert, -1, 0, jsonSetFunc),
+ JFUNCTION(json_object, -1, 0, jsonObjectFunc),
+ JFUNCTION(json_patch, 2, 0, jsonPatchFunc),
+ JFUNCTION(json_quote, 1, 0, jsonQuoteFunc),
+ JFUNCTION(json_remove, -1, 0, jsonRemoveFunc),
+ JFUNCTION(json_replace, -1, 0, jsonReplaceFunc),
+ JFUNCTION(json_set, -1, JSON_ISSET, jsonSetFunc),
+ JFUNCTION(json_type, 1, 0, jsonTypeFunc),
+ JFUNCTION(json_type, 2, 0, jsonTypeFunc),
+ JFUNCTION(json_valid, 1, 0, jsonValidFunc),
#if SQLITE_DEBUG
- /* DEBUG and TESTING functions */
- { "json_parse", 1, 0, jsonParseFunc },
- { "json_test1", 1, 0, jsonTest1Func },
+ JFUNCTION(json_parse, 1, 0, jsonParseFunc),
+ JFUNCTION(json_test1, 1, 0, jsonTest1Func),
#endif
+ WAGGREGATE(json_group_array, 1, 0, 0,
+ jsonArrayStep, jsonArrayFinal, jsonArrayValue, jsonGroupInverse,
+ SQLITE_SUBTYPE|SQLITE_UTF8|SQLITE_DETERMINISTIC|SQLITE_INNOCUOUS),
+ WAGGREGATE(json_group_object, 2, 0, 0,
+ jsonObjectStep, jsonObjectFinal, jsonObjectValue, jsonGroupInverse,
+ SQLITE_SUBTYPE|SQLITE_UTF8|SQLITE_DETERMINISTIC|SQLITE_INNOCUOUS)
};
+ sqlite3InsertBuiltinFuncs(aJsonFunc, ArraySize(aJsonFunc));
+#endif
+}
+
+#if !defined(SQLITE_OMIT_VIRTUALTABLE) && !defined(SQLITE_OMIT_JSON)
+/*
+** Register the JSON table-valued functions
+*/
+int sqlite3JsonTableFunctions(sqlite3 *db){
+ int rc = SQLITE_OK;
static const struct {
- const char *zName;
- int nArg;
- void (*xStep)(sqlite3_context*,int,sqlite3_value**);
- void (*xFinal)(sqlite3_context*);
- void (*xValue)(sqlite3_context*);
- } aAgg[] = {
- { "json_group_array", 1,
- jsonArrayStep, jsonArrayFinal, jsonArrayValue },
- { "json_group_object", 2,
- jsonObjectStep, jsonObjectFinal, jsonObjectValue },
- };
-#ifndef SQLITE_OMIT_VIRTUALTABLE
- static const struct {
- const char *zName;
- sqlite3_module *pModule;
+ const char *zName;
+ sqlite3_module *pModule;
} aMod[] = {
{ "json_each", &jsonEachModule },
{ "json_tree", &jsonTreeModule },
};
-#endif
- static const int enc =
- SQLITE_UTF8 |
- SQLITE_DETERMINISTIC |
- SQLITE_INNOCUOUS;
- for(i=0; i<sizeof(aFunc)/sizeof(aFunc[0]) && rc==SQLITE_OK; i++){
- rc = sqlite3_create_function(db, aFunc[i].zName, aFunc[i].nArg, enc,
- (void*)&aFunc[i].flag,
- aFunc[i].xFunc, 0, 0);
- }
-#ifndef SQLITE_OMIT_WINDOWFUNC
- for(i=0; i<sizeof(aAgg)/sizeof(aAgg[0]) && rc==SQLITE_OK; i++){
- rc = sqlite3_create_window_function(db, aAgg[i].zName, aAgg[i].nArg,
- SQLITE_SUBTYPE | enc, 0,
- aAgg[i].xStep, aAgg[i].xFinal,
- aAgg[i].xValue, jsonGroupInverse, 0);
- }
-#endif
-#ifndef SQLITE_OMIT_VIRTUALTABLE
+ unsigned int i;
for(i=0; i<sizeof(aMod)/sizeof(aMod[0]) && rc==SQLITE_OK; i++){
rc = sqlite3_create_module(db, aMod[i].zName, aMod[i].pModule, 0);
}
-#endif
return rc;
}
-
-
-#ifndef SQLITE_CORE
-#ifdef _WIN32
-__declspec(dllexport)
-#endif
-int sqlite3_json_init(
- sqlite3 *db,
- char **pzErrMsg,
- const sqlite3_api_routines *pApi
-){
- SQLITE_EXTENSION_INIT2(pApi);
- (void)pzErrMsg; /* Unused parameter */
- return sqlite3Json1Init(db);
-}
-#endif
-#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_JSON1) */
+#endif /* !defined(SQLITE_OMIT_VIRTUALTABLE) && !defined(SQLITE_OMIT_JSON) */
diff --git a/chromium/third_party/sqlite/src/src/loadext.c b/chromium/third_party/sqlite/src/src/loadext.c
index 4edefec0c91..603516e18ad 100644
--- a/chromium/third_party/sqlite/src/src/loadext.c
+++ b/chromium/third_party/sqlite/src/src/loadext.c
@@ -485,6 +485,13 @@ static const sqlite3_api_routines sqlite3Apis = {
sqlite3_total_changes64,
/* Version 3.37.0 and later */
sqlite3_autovacuum_pages,
+ /* Version 3.38.0 and later */
+ sqlite3_error_offset,
+ sqlite3_vtab_rhs_value,
+ sqlite3_vtab_distinct,
+ sqlite3_vtab_in,
+ sqlite3_vtab_in_first,
+ sqlite3_vtab_in_next
};
/* True if x is the directory separator character
diff --git a/chromium/third_party/sqlite/src/src/main.c b/chromium/third_party/sqlite/src/src/main.c
index 804719f176f..8747f07b56c 100644
--- a/chromium/third_party/sqlite/src/src/main.c
+++ b/chromium/third_party/sqlite/src/src/main.c
@@ -50,9 +50,6 @@ int sqlite3Fts2Init(sqlite3*);
#ifdef SQLITE_ENABLE_FTS5
int sqlite3Fts5Init(sqlite3*);
#endif
-#ifdef SQLITE_ENABLE_JSON1
-int sqlite3Json1Init(sqlite3*);
-#endif
#ifdef SQLITE_ENABLE_STMTVTAB
int sqlite3StmtVtabInit(sqlite3*);
#endif
@@ -87,8 +84,8 @@ static int (*const sqlite3BuiltinExtensions[])(sqlite3*) = {
sqlite3DbstatRegister,
#endif
sqlite3TestExtInit,
-#ifdef SQLITE_ENABLE_JSON1
- sqlite3Json1Init,
+#if !defined(SQLITE_OMIT_VIRTUALTABLE) && !defined(SQLITE_OMIT_JSON)
+ sqlite3JsonTableFunctions,
#endif
#ifdef SQLITE_ENABLE_STMTVTAB
sqlite3StmtVtabInit,
@@ -2597,6 +2594,19 @@ const char *sqlite3_errmsg(sqlite3 *db){
return z;
}
+/*
+** Return the byte offset of the most recent error
+*/
+int sqlite3_error_offset(sqlite3 *db){
+ int iOffset = -1;
+ if( db && sqlite3SafetyCheckSickOrOk(db) && db->errCode ){
+ sqlite3_mutex_enter(db->mutex);
+ iOffset = db->errByteOffset;
+ sqlite3_mutex_leave(db->mutex);
+ }
+ return iOffset;
+}
+
#ifndef SQLITE_OMIT_UTF16
/*
** Return UTF-16 encoded English language explanation of the most recent
@@ -4019,12 +4029,16 @@ int sqlite3_test_control(int op, ...){
** sqlite3_test_control().
*/
case SQLITE_TESTCTRL_FAULT_INSTALL: {
- /* MSVC is picky about pulling func ptrs from va lists.
- ** http://support.microsoft.com/kb/47961
+ /* A bug in MSVC prevents it from understanding pointers to functions
+ ** types in the second argument to va_arg(). Work around the problem
+ ** using a typedef.
+ ** http://support.microsoft.com/kb/47961 <-- dead hyperlink
+ ** Search at http://web.archive.org/ to find the 2015-03-16 archive
+ ** of the link above to see the original text.
** sqlite3GlobalConfig.xTestCallback = va_arg(ap, int(*)(int));
*/
- typedef int(*TESTCALLBACKFUNC_t)(int);
- sqlite3GlobalConfig.xTestCallback = va_arg(ap, TESTCALLBACKFUNC_t);
+ typedef int(*sqlite3FaultFuncType)(int);
+ sqlite3GlobalConfig.xTestCallback = va_arg(ap, sqlite3FaultFuncType);
rc = sqlite3FaultSim(0);
break;
}
@@ -4151,13 +4165,27 @@ int sqlite3_test_control(int op, ...){
break;
}
- /* sqlite3_test_control(SQLITE_TESTCTRL_LOCALTIME_FAULT, int onoff);
+ /* sqlite3_test_control(SQLITE_TESTCTRL_LOCALTIME_FAULT, onoff, xAlt);
+ **
+ ** If parameter onoff is 1, subsequent calls to localtime() fail.
+ ** If 2, then invoke xAlt() instead of localtime(). If 0, normal
+ ** processing.
**
- ** If parameter onoff is non-zero, subsequent calls to localtime()
- ** and its variants fail. If onoff is zero, undo this setting.
+ ** xAlt arguments are void pointers, but they really want to be:
+ **
+ ** int xAlt(const time_t*, struct tm*);
+ **
+ ** xAlt should write results in to struct tm object of its 2nd argument
+ ** and return zero on success, or return non-zero on failure.
*/
case SQLITE_TESTCTRL_LOCALTIME_FAULT: {
sqlite3GlobalConfig.bLocaltimeFault = va_arg(ap, int);
+ if( sqlite3GlobalConfig.bLocaltimeFault==2 ){
+ typedef int(*sqlite3LocaltimeType)(const void*,void*);
+ sqlite3GlobalConfig.xAltLocaltime = va_arg(ap, sqlite3LocaltimeType);
+ }else{
+ sqlite3GlobalConfig.xAltLocaltime = 0;
+ }
break;
}
@@ -4347,6 +4375,26 @@ int sqlite3_test_control(int op, ...){
break;
}
+ /* sqlite3_test_control(SQLITE_TESTCTRL_LOGEST,
+ ** double fIn, // Input value
+ ** int *pLogEst, // sqlite3LogEstFromDouble(fIn)
+ ** u64 *pInt, // sqlite3LogEstToInt(*pLogEst)
+ ** int *pLogEst2 // sqlite3LogEst(*pInt)
+ ** );
+ **
+ ** Test access for the LogEst conversion routines.
+ */
+ case SQLITE_TESTCTRL_LOGEST: {
+ double rIn = va_arg(ap, double);
+ LogEst rLogEst = sqlite3LogEstFromDouble(rIn);
+ u64 iInt = sqlite3LogEstToInt(rLogEst);
+ va_arg(ap, int*)[0] = rLogEst;
+ va_arg(ap, u64*)[0] = iInt;
+ va_arg(ap, int*)[0] = sqlite3LogEst(iInt);
+ break;
+ }
+
+
#if defined(SQLITE_DEBUG) && !defined(SQLITE_OMIT_WSD)
/* sqlite3_test_control(SQLITE_TESTCTRL_TUNE, id, *piValue)
**
diff --git a/chromium/third_party/sqlite/src/src/malloc.c b/chromium/third_party/sqlite/src/src/malloc.c
index 932cecc2101..21e52458918 100644
--- a/chromium/third_party/sqlite/src/src/malloc.c
+++ b/chromium/third_party/sqlite/src/src/malloc.c
@@ -759,8 +759,15 @@ void sqlite3SetString(char **pz, sqlite3 *db, const char *zNew){
** has happened. This routine will set db->mallocFailed, and also
** temporarily disable the lookaside memory allocator and interrupt
** any running VDBEs.
+**
+** Always return a NULL pointer so that this routine can be invoked using
+**
+** return sqlite3OomFault(db);
+**
+** and thereby avoid unnecessary stack frame allocations for the overwhelmingly
+** common case where no OOM occurs.
*/
-void sqlite3OomFault(sqlite3 *db){
+void *sqlite3OomFault(sqlite3 *db){
if( db->mallocFailed==0 && db->bBenignMalloc==0 ){
db->mallocFailed = 1;
if( db->nVdbeExec>0 ){
@@ -768,9 +775,11 @@ void sqlite3OomFault(sqlite3 *db){
}
DisableLookaside;
if( db->pParse ){
+ sqlite3ErrorMsg(db->pParse, "out of memory");
db->pParse->rc = SQLITE_NOMEM_BKPT;
}
}
+ return 0;
}
/*
diff --git a/chromium/third_party/sqlite/src/src/memjournal.c b/chromium/third_party/sqlite/src/src/memjournal.c
index 598d5cc026b..a4c17eedd48 100644
--- a/chromium/third_party/sqlite/src/src/memjournal.c
+++ b/chromium/third_party/sqlite/src/src/memjournal.c
@@ -178,6 +178,9 @@ static int memjrnlCreateFile(MemJournal *p){
}
+/* Forward reference */
+static int memjrnlTruncate(sqlite3_file *pJfd, sqlite_int64 size);
+
/*
** Write data to the file.
*/
@@ -207,23 +210,21 @@ static int memjrnlWrite(
** access writes are not required. The only exception to this is when
** the in-memory journal is being used by a connection using the
** atomic-write optimization. In this case the first 28 bytes of the
- ** journal file may be written as part of committing the transaction. */
- assert( iOfst==p->endpoint.iOffset || iOfst==0 );
-#if defined(SQLITE_ENABLE_ATOMIC_WRITE) \
- || defined(SQLITE_ENABLE_BATCH_ATOMIC_WRITE)
+ ** journal file may be written as part of committing the transaction. */
+ assert( iOfst<=p->endpoint.iOffset );
+ if( iOfst>0 && iOfst!=p->endpoint.iOffset ){
+ memjrnlTruncate(pJfd, iOfst);
+ }
if( iOfst==0 && p->pFirst ){
assert( p->nChunkSize>iAmt );
memcpy((u8*)p->pFirst->zChunk, zBuf, iAmt);
- }else
-#else
- assert( iOfst>0 || p->pFirst==0 );
-#endif
- {
+ }else{
while( nWrite>0 ){
FileChunk *pChunk = p->endpoint.pChunk;
int iChunkOffset = (int)(p->endpoint.iOffset%p->nChunkSize);
int iSpace = MIN(nWrite, p->nChunkSize - iChunkOffset);
+ assert( pChunk!=0 || iChunkOffset==0 );
if( iChunkOffset==0 ){
/* New chunk is required to extend the file. */
FileChunk *pNew = sqlite3_malloc(fileChunkSize(p->nChunkSize));
@@ -238,10 +239,11 @@ static int memjrnlWrite(
assert( !p->pFirst );
p->pFirst = pNew;
}
- p->endpoint.pChunk = pNew;
+ pChunk = p->endpoint.pChunk = pNew;
}
- memcpy((u8*)p->endpoint.pChunk->zChunk + iChunkOffset, zWrite, iSpace);
+ assert( pChunk!=0 );
+ memcpy((u8*)pChunk->zChunk + iChunkOffset, zWrite, iSpace);
zWrite += iSpace;
nWrite -= iSpace;
p->endpoint.iOffset += iSpace;
@@ -265,7 +267,7 @@ static int memjrnlTruncate(sqlite3_file *pJfd, sqlite_int64 size){
p->pFirst = 0;
}else{
i64 iOff = p->nChunkSize;
- for(pIter=p->pFirst; ALWAYS(pIter) && iOff<=size; pIter=pIter->pNext){
+ for(pIter=p->pFirst; ALWAYS(pIter) && iOff<size; pIter=pIter->pNext){
iOff += p->nChunkSize;
}
if( ALWAYS(pIter) ){
diff --git a/chromium/third_party/sqlite/src/src/pager.c b/chromium/third_party/sqlite/src/src/pager.c
index 0ed58483435..01086dcfad3 100644
--- a/chromium/third_party/sqlite/src/src/pager.c
+++ b/chromium/third_party/sqlite/src/src/pager.c
@@ -2844,6 +2844,9 @@ static int pager_playback(Pager *pPager, int isHot){
goto end_playback;
}
pPager->dbSize = mxPg;
+ if( pPager->mxPgno<mxPg ){
+ pPager->mxPgno = mxPg;
+ }
}
/* Copy original pages out of the journal and back into the
@@ -3900,8 +3903,7 @@ static int pager_wait_on_lock(Pager *pPager, int locktype){
** current database image, in pages, OR
**
** b) if the page content were written at this time, it would not
-** be necessary to write the current content out to the sub-journal
-** (as determined by function subjRequiresPage()).
+** be necessary to write the current content out to the sub-journal.
**
** If the condition asserted by this function were not true, and the
** dirty page were to be discarded from the cache via the pagerStress()
@@ -3916,8 +3918,16 @@ static int pager_wait_on_lock(Pager *pPager, int locktype){
*/
#if defined(SQLITE_DEBUG)
static void assertTruncateConstraintCb(PgHdr *pPg){
+ Pager *pPager = pPg->pPager;
assert( pPg->flags&PGHDR_DIRTY );
- assert( !subjRequiresPage(pPg) || pPg->pgno<=pPg->pPager->dbSize );
+ if( pPg->pgno>pPager->dbSize ){ /* if (a) is false */
+ Pgno pgno = pPg->pgno;
+ int i;
+ for(i=0; i<pPg->pPager->nSavepoint; i++){
+ PagerSavepoint *p = &pPager->aSavepoint[i];
+ assert( p->nOrig<pgno || sqlite3BitvecTestNotNull(p->pInSavepoint,pgno) );
+ }
+ }
}
static void assertTruncateConstraint(Pager *pPager){
sqlite3PcacheIterateDirty(pPager->pPCache, assertTruncateConstraintCb);
@@ -3939,7 +3949,6 @@ static void assertTruncateConstraint(Pager *pPager){
*/
void sqlite3PagerTruncateImage(Pager *pPager, Pgno nPage){
assert( pPager->dbSize>=nPage || CORRUPT_DB );
- testcase( pPager->dbSize<nPage );
assert( pPager->eState>=PAGER_WRITER_CACHEMOD );
pPager->dbSize = nPage;
@@ -5258,7 +5267,7 @@ int sqlite3PagerSharedLock(Pager *pPager){
** may mean that the pager was in the error-state when this
** function was called and the journal file does not exist.
*/
- if( !isOpen(pPager->jfd) ){
+ if( !isOpen(pPager->jfd) && pPager->journalMode!=PAGER_JOURNALMODE_OFF ){
sqlite3_vfs * const pVfs = pPager->pVfs;
int bExists; /* True if journal file exists */
rc = sqlite3OsAccess(
@@ -5660,6 +5669,7 @@ int sqlite3PagerGet(
DbPage **ppPage, /* Write a pointer to the page here */
int flags /* PAGER_GET_XXX flags */
){
+ /* printf("PAGE %u\n", pgno); fflush(stdout); */
return pPager->xGet(pPager, pgno, ppPage, flags);
}
@@ -7265,12 +7275,12 @@ int sqlite3PagerSetJournalMode(Pager *pPager, int eMode){
u8 eOld = pPager->journalMode; /* Prior journalmode */
/* The eMode parameter is always valid */
- assert( eMode==PAGER_JOURNALMODE_DELETE
- || eMode==PAGER_JOURNALMODE_TRUNCATE
- || eMode==PAGER_JOURNALMODE_PERSIST
- || eMode==PAGER_JOURNALMODE_OFF
- || eMode==PAGER_JOURNALMODE_WAL
- || eMode==PAGER_JOURNALMODE_MEMORY );
+ assert( eMode==PAGER_JOURNALMODE_DELETE /* 0 */
+ || eMode==PAGER_JOURNALMODE_PERSIST /* 1 */
+ || eMode==PAGER_JOURNALMODE_OFF /* 2 */
+ || eMode==PAGER_JOURNALMODE_TRUNCATE /* 3 */
+ || eMode==PAGER_JOURNALMODE_MEMORY /* 4 */
+ || eMode==PAGER_JOURNALMODE_WAL /* 5 */ );
/* This routine is only called from the OP_JournalMode opcode, and
** the logic there will never allow a temporary file to be changed
@@ -7307,7 +7317,6 @@ int sqlite3PagerSetJournalMode(Pager *pPager, int eMode){
assert( isOpen(pPager->fd) || pPager->exclusiveMode );
if( !pPager->exclusiveMode && (eOld & 5)==1 && (eMode & 1)==0 ){
-
/* In this case we would like to delete the journal file. If it is
** not possible, then that is not a problem. Deleting the journal file
** here is an optimization only.
@@ -7419,6 +7428,18 @@ int sqlite3PagerCheckpoint(
int *pnCkpt /* OUT: Final number of checkpointed frames */
){
int rc = SQLITE_OK;
+ if( pPager->pWal==0 && pPager->journalMode==PAGER_JOURNALMODE_WAL ){
+ /* This only happens when a database file is zero bytes in size opened and
+ ** then "PRAGMA journal_mode=WAL" is run and then sqlite3_wal_checkpoint()
+ ** is invoked without any intervening transactions. We need to start
+ ** a transaction to initialize pWal. The PRAGMA table_list statement is
+ ** used for this since it starts transactions on every database file,
+ ** including all ATTACHed databases. This seems expensive for a single
+ ** sqlite3_wal_checkpoint() call, but it happens very rarely.
+ ** https://sqlite.org/forum/forumpost/fd0f19d229156939
+ */
+ sqlite3_exec(db, "PRAGMA table_list",0,0,0);
+ }
if( pPager->pWal ){
rc = sqlite3WalCheckpoint(pPager->pWal, db, eMode,
(eMode==SQLITE_CHECKPOINT_PASSIVE ? 0 : pPager->xBusyHandler),
diff --git a/chromium/third_party/sqlite/src/src/parse.y b/chromium/third_party/sqlite/src/src/parse.y
index 97a26c28e89..2680e640a04 100644
--- a/chromium/third_party/sqlite/src/src/parse.y
+++ b/chromium/third_party/sqlite/src/src/parse.y
@@ -286,7 +286,7 @@ columnname(A) ::= nm(A) typetoken(Y). {sqlite3AddColumn(pParse,A,Y);}
%left BITAND BITOR LSHIFT RSHIFT.
%left PLUS MINUS.
%left STAR SLASH REM.
-%left CONCAT.
+%left CONCAT PTR.
%left COLLATE.
%right BITNOT.
%nonassoc ON.
@@ -659,7 +659,7 @@ selcollist(A) ::= sclp(A) scanpt STAR. {
}
selcollist(A) ::= sclp(A) scanpt nm(X) DOT STAR. {
Expr *pRight = sqlite3PExpr(pParse, TK_ASTERISK, 0, 0);
- Expr *pLeft = sqlite3ExprAlloc(pParse->db, TK_ID, &X, 1);
+ Expr *pLeft = tokenExpr(pParse, TK_ID, X);
Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight);
A = sqlite3ExprListAppend(pParse,A, pDot);
}
@@ -1025,10 +1025,7 @@ idlist(A) ::= nm(Y).
%include {
- /* Construct a new Expr object from a single identifier. Use the
- ** new Expr to populate pOut. Set the span of pOut to be the identifier
- ** that created the expression.
- */
+ /* Construct a new Expr object from a single token */
static Expr *tokenExpr(Parse *pParse, int op, Token t){
Expr *p = sqlite3DbMallocRawNN(pParse->db, sizeof(Expr)+t.n+1);
if( p ){
@@ -1048,6 +1045,7 @@ idlist(A) ::= nm(Y).
p->u.zToken = (char*)&p[1];
memcpy(p->u.zToken, t.z, t.n);
p->u.zToken[t.n] = 0;
+ p->w.iOfst = (int)(t.z - pParse->zTail);
if( sqlite3Isquote(p->u.zToken[0]) ){
sqlite3DequoteExpr(p);
}
@@ -1068,22 +1066,17 @@ expr(A) ::= LP expr(X) RP. {A = X;}
expr(A) ::= id(X). {A=tokenExpr(pParse,TK_ID,X); /*A-overwrites-X*/}
expr(A) ::= JOIN_KW(X). {A=tokenExpr(pParse,TK_ID,X); /*A-overwrites-X*/}
expr(A) ::= nm(X) DOT nm(Y). {
- Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &X, 1);
- Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &Y, 1);
- if( IN_RENAME_OBJECT ){
- sqlite3RenameTokenMap(pParse, (void*)temp2, &Y);
- sqlite3RenameTokenMap(pParse, (void*)temp1, &X);
- }
+ Expr *temp1 = tokenExpr(pParse,TK_ID,X);
+ Expr *temp2 = tokenExpr(pParse,TK_ID,Y);
A = sqlite3PExpr(pParse, TK_DOT, temp1, temp2);
}
expr(A) ::= nm(X) DOT nm(Y) DOT nm(Z). {
- Expr *temp1 = sqlite3ExprAlloc(pParse->db, TK_ID, &X, 1);
- Expr *temp2 = sqlite3ExprAlloc(pParse->db, TK_ID, &Y, 1);
- Expr *temp3 = sqlite3ExprAlloc(pParse->db, TK_ID, &Z, 1);
+ Expr *temp1 = tokenExpr(pParse,TK_ID,X);
+ Expr *temp2 = tokenExpr(pParse,TK_ID,Y);
+ Expr *temp3 = tokenExpr(pParse,TK_ID,Z);
Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3);
if( IN_RENAME_OBJECT ){
- sqlite3RenameTokenMap(pParse, (void*)temp3, &Z);
- sqlite3RenameTokenMap(pParse, (void*)temp2, &Y);
+ sqlite3RenameTokenRemap(pParse, 0, temp1);
}
A = sqlite3PExpr(pParse, TK_DOT, temp1, temp4);
}
@@ -1091,6 +1084,7 @@ term(A) ::= NULL|FLOAT|BLOB(X). {A=tokenExpr(pParse,@X,X); /*A-overwrites-X*/}
term(A) ::= STRING(X). {A=tokenExpr(pParse,@X,X); /*A-overwrites-X*/}
term(A) ::= INTEGER(X). {
A = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &X, 1);
+ if( A ) A->w.iOfst = (int)(X.z - pParse->zTail);
}
expr(A) ::= VARIABLE(X). {
if( !(X.z[0]=='#' && sqlite3Isdigit(X.z[1])) ){
@@ -1235,6 +1229,12 @@ expr(A) ::= PLUS|MINUS(B) expr(X). [BITNOT] {
/*A-overwrites-B*/
}
+expr(A) ::= expr(B) PTR(C) expr(D). {
+ ExprList *pList = sqlite3ExprListAppend(pParse, 0, B);
+ pList = sqlite3ExprListAppend(pParse, pList, D);
+ A = sqlite3ExprFunction(pParse, pList, &C, 0);
+}
+
%type between_op {int}
between_op(A) ::= BETWEEN. {A = 0;}
between_op(A) ::= NOT BETWEEN. {A = 1;}
@@ -1587,7 +1587,7 @@ expr(A) ::= RAISE LP IGNORE RP. {
}
}
expr(A) ::= RAISE LP raisetype(T) COMMA nm(Z) RP. {
- A = sqlite3ExprAlloc(pParse->db, TK_RAISE, &Z, 1);
+ A = sqlite3ExprAlloc(pParse->db, TK_RAISE, &Z, 1);
if( A ) {
A->affExpr = (char)T;
}
diff --git a/chromium/third_party/sqlite/src/src/pcache.c b/chromium/third_party/sqlite/src/src/pcache.c
index 14d1e7cde0f..76cc4bb7a95 100644
--- a/chromium/third_party/sqlite/src/src/pcache.c
+++ b/chromium/third_party/sqlite/src/src/pcache.c
@@ -551,7 +551,8 @@ void sqlite3PcacheDrop(PgHdr *p){
** make it so.
*/
void sqlite3PcacheMakeDirty(PgHdr *p){
- assert( p->nRef>0 );
+ assert( p->nRef>0 || p->pCache->bPurgeable==0 );
+ testcase( p->nRef==0 );
assert( sqlite3PcachePageSanity(p) );
if( p->flags & (PGHDR_CLEAN|PGHDR_DONT_WRITE) ){ /*OPTIMIZATION-IF-FALSE*/
p->flags &= ~PGHDR_DONT_WRITE;
diff --git a/chromium/third_party/sqlite/src/src/pragma.c b/chromium/third_party/sqlite/src/src/pragma.c
index ba84af75755..b13de549424 100644
--- a/chromium/third_party/sqlite/src/src/pragma.c
+++ b/chromium/third_party/sqlite/src/src/pragma.c
@@ -1250,6 +1250,10 @@ void sqlite3Pragma(
(void)sqlite3_finalize(pDummy);
sqlite3DbFree(db, zSql);
}
+ if( db->mallocFailed ){
+ sqlite3ErrorMsg(db->pParse, "out of memory");
+ db->pParse->rc = SQLITE_NOMEM_BKPT;
+ }
pHash = &db->aDb[ii].pSchema->tblHash;
break;
}
diff --git a/chromium/third_party/sqlite/src/src/prepare.c b/chromium/third_party/sqlite/src/src/prepare.c
index 183a749a5fe..7e08a5a6742 100644
--- a/chromium/third_party/sqlite/src/src/prepare.c
+++ b/chromium/third_party/sqlite/src/src/prepare.c
@@ -568,8 +568,14 @@ int sqlite3SchemaToIndex(sqlite3 *db, Schema *pSchema){
/*
** Free all memory allocations in the pParse object
*/
-void sqlite3ParserReset(Parse *pParse){
+void sqlite3ParseObjectReset(Parse *pParse){
sqlite3 *db = pParse->db;
+ assert( db!=0 );
+ assert( db->pParse==pParse );
+ assert( pParse->nested==0 );
+#ifndef SQLITE_OMIT_SHARED_CACHE
+ sqlite3DbFree(db, pParse->aTableLock);
+#endif
while( pParse->pCleanup ){
ParseCleanup *pCleanup = pParse->pCleanup;
pParse->pCleanup = pCleanup->pNext;
@@ -580,11 +586,12 @@ void sqlite3ParserReset(Parse *pParse){
if( pParse->pConstExpr ){
sqlite3ExprListDelete(db, pParse->pConstExpr);
}
- if( db ){
- assert( db->lookaside.bDisable >= pParse->disableLookaside );
- db->lookaside.bDisable -= pParse->disableLookaside;
- db->lookaside.sz = db->lookaside.bDisable ? 0 : db->lookaside.szTrue;
- }
+ assert( db->lookaside.bDisable >= pParse->disableLookaside );
+ db->lookaside.bDisable -= pParse->disableLookaside;
+ db->lookaside.sz = db->lookaside.bDisable ? 0 : db->lookaside.szTrue;
+ assert( pParse->db->pParse==pParse );
+ db->pParse = pParse->pOuterParse;
+ pParse->db = 0;
pParse->disableLookaside = 0;
}
@@ -597,7 +604,7 @@ void sqlite3ParserReset(Parse *pParse){
** cost for this mechansim (an extra malloc), so it should not be used
** for common cleanups that happen on most calls. But for less
** common cleanups, we save a single NULL-pointer comparison in
-** sqlite3ParserReset(), which reduces the total CPU cycle count.
+** sqlite3ParseObjectReset(), which reduces the total CPU cycle count.
**
** If a memory allocation error occurs, then the cleanup happens immediately.
** When either SQLITE_DEBUG or SQLITE_COVERAGE_TEST are defined, the
@@ -638,6 +645,25 @@ void *sqlite3ParserAddCleanup(
}
/*
+** Turn bulk memory into a valid Parse object and link that Parse object
+** into database connection db.
+**
+** Call sqlite3ParseObjectReset() to undo this operation.
+**
+** Caution: Do not confuse this routine with sqlite3ParseObjectInit() which
+** is generated by Lemon.
+*/
+void sqlite3ParseObjectInit(Parse *pParse, sqlite3 *db){
+ memset(PARSE_HDR(pParse), 0, PARSE_HDR_SZ);
+ memset(PARSE_TAIL(pParse), 0, PARSE_TAIL_SZ);
+ assert( db->pParse!=pParse );
+ pParse->pOuterParse = db->pParse;
+ db->pParse = pParse;
+ pParse->db = db;
+ if( db->mallocFailed ) sqlite3ErrorMsg(pParse, "out of memory");
+}
+
+/*
** Compile the UTF-8 encoded SQL statement zSql into a statement handle.
*/
static int sqlite3Prepare(
@@ -649,16 +675,19 @@ static int sqlite3Prepare(
sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
const char **pzTail /* OUT: End of parsed string */
){
- char *zErrMsg = 0; /* Error message */
int rc = SQLITE_OK; /* Result code */
int i; /* Loop counter */
Parse sParse; /* Parsing context */
- memset(&sParse, 0, PARSE_HDR_SZ);
+ /* sqlite3ParseObjectInit(&sParse, db); // inlined for performance */
+ memset(PARSE_HDR(&sParse), 0, PARSE_HDR_SZ);
memset(PARSE_TAIL(&sParse), 0, PARSE_TAIL_SZ);
+ sParse.pOuterParse = db->pParse;
+ db->pParse = &sParse;
+ sParse.db = db;
sParse.pReprepare = pReprepare;
assert( ppStmt && *ppStmt==0 );
- /* assert( !db->mallocFailed ); // not true with SQLITE_USE_ALLOCA */
+ if( db->mallocFailed ) sqlite3ErrorMsg(&sParse, "out of memory");
assert( sqlite3_mutex_held(db->mutex) );
/* For a long-term use prepared statement avoid the use of
@@ -711,7 +740,6 @@ static int sqlite3Prepare(
sqlite3VtabUnlockList(db);
- sParse.db = db;
if( nBytes>=0 && (nBytes==0 || zSql[nBytes-1]!=0) ){
char *zSqlCopy;
int mxLen = db->aLimit[SQLITE_LIMIT_SQL_LENGTH];
@@ -724,14 +752,14 @@ static int sqlite3Prepare(
}
zSqlCopy = sqlite3DbStrNDup(db, zSql, nBytes);
if( zSqlCopy ){
- sqlite3RunParser(&sParse, zSqlCopy, &zErrMsg);
+ sqlite3RunParser(&sParse, zSqlCopy);
sParse.zTail = &zSql[sParse.zTail-zSqlCopy];
sqlite3DbFree(db, zSqlCopy);
}else{
sParse.zTail = &zSql[nBytes];
}
}else{
- sqlite3RunParser(&sParse, zSql, &zErrMsg);
+ sqlite3RunParser(&sParse, zSql);
}
assert( 0==sParse.nQueryLoop );
@@ -747,7 +775,7 @@ static int sqlite3Prepare(
sParse.checkSchema = 0;
}
if( sParse.rc!=SQLITE_OK && sParse.rc!=SQLITE_DONE ){
- if( sParse.checkSchema ){
+ if( sParse.checkSchema && db->init.busy==0 ){
schemaIsValid(&sParse);
}
if( sParse.pVdbe ){
@@ -755,14 +783,14 @@ static int sqlite3Prepare(
}
assert( 0==(*ppStmt) );
rc = sParse.rc;
- if( zErrMsg ){
- sqlite3ErrorWithMsg(db, rc, "%s", zErrMsg);
- sqlite3DbFree(db, zErrMsg);
+ if( sParse.zErrMsg ){
+ sqlite3ErrorWithMsg(db, rc, "%s", sParse.zErrMsg);
+ sqlite3DbFree(db, sParse.zErrMsg);
}else{
sqlite3Error(db, rc);
}
}else{
- assert( zErrMsg==0 );
+ assert( sParse.zErrMsg==0 );
*ppStmt = (sqlite3_stmt*)sParse.pVdbe;
rc = SQLITE_OK;
sqlite3ErrorClear(db);
@@ -778,7 +806,7 @@ static int sqlite3Prepare(
end_prepare:
- sqlite3ParserReset(&sParse);
+ sqlite3ParseObjectReset(&sParse);
return rc;
}
static int sqlite3LockAndPrepare(
diff --git a/chromium/third_party/sqlite/src/src/printf.c b/chromium/third_party/sqlite/src/src/printf.c
index e63518450c9..7bf6f2aebb1 100644
--- a/chromium/third_party/sqlite/src/src/printf.c
+++ b/chromium/third_party/sqlite/src/src/printf.c
@@ -849,12 +849,22 @@ void sqlite3_str_vappendf(
goto adjust_width_for_utf8;
}
case etTOKEN: {
- Token *pToken;
if( (pAccum->printfFlags & SQLITE_PRINTF_INTERNAL)==0 ) return;
- pToken = va_arg(ap, Token*);
- assert( bArgList==0 );
- if( pToken && pToken->n ){
- sqlite3_str_append(pAccum, (const char*)pToken->z, pToken->n);
+ if( flag_alternateform ){
+ /* %#T means an Expr pointer that uses Expr.u.zToken */
+ Expr *pExpr = va_arg(ap,Expr*);
+ if( ALWAYS(pExpr) && ALWAYS(!ExprHasProperty(pExpr,EP_IntValue)) ){
+ sqlite3_str_appendall(pAccum, (const char*)pExpr->u.zToken);
+ sqlite3RecordErrorOffsetOfExpr(pAccum->db, pExpr);
+ }
+ }else{
+ /* %T means a Token pointer */
+ Token *pToken = va_arg(ap, Token*);
+ assert( bArgList==0 );
+ if( pToken && pToken->n ){
+ sqlite3_str_append(pAccum, (const char*)pToken->z, pToken->n);
+ sqlite3RecordErrorByteOffset(pAccum->db, pToken->z);
+ }
}
length = width = 0;
break;
@@ -909,6 +919,42 @@ void sqlite3_str_vappendf(
}/* End for loop over the format string */
} /* End of function */
+
+/*
+** The z string points to the first character of a token that is
+** associated with an error. If db does not already have an error
+** byte offset recorded, try to compute the error byte offset for
+** z and set the error byte offset in db.
+*/
+void sqlite3RecordErrorByteOffset(sqlite3 *db, const char *z){
+ const Parse *pParse;
+ const char *zText;
+ const char *zEnd;
+ assert( z!=0 );
+ if( NEVER(db==0) ) return;
+ if( db->errByteOffset!=(-2) ) return;
+ pParse = db->pParse;
+ if( NEVER(pParse==0) ) return;
+ zText =pParse->zTail;
+ if( NEVER(zText==0) ) return;
+ zEnd = &zText[strlen(zText)];
+ if( SQLITE_WITHIN(z,zText,zEnd) ){
+ db->errByteOffset = (int)(z-zText);
+ }
+}
+
+/*
+** If pExpr has a byte offset for the start of a token, record that as
+** as the error offset.
+*/
+void sqlite3RecordErrorOffsetOfExpr(sqlite3 *db, const Expr *pExpr){
+ while( pExpr && (ExprHasProperty(pExpr,EP_FromJoin) || pExpr->w.iOfst<=0) ){
+ pExpr = pExpr->pLeft;
+ }
+ if( pExpr==0 ) return;
+ db->errByteOffset = pExpr->w.iOfst;
+}
+
/*
** Enlarge the memory allocation on a StrAccum object so that it is
** able to accept at least N more bytes of text.
@@ -916,7 +962,7 @@ void sqlite3_str_vappendf(
** Return the number of bytes of text that StrAccum is able to accept
** after the attempted enlargement. The value returned might be zero.
*/
-static int sqlite3StrAccumEnlarge(StrAccum *p, int N){
+int sqlite3StrAccumEnlarge(StrAccum *p, int N){
char *zNew;
assert( p->nChar+(i64)N >= p->nAlloc ); /* Only called if really needed */
if( p->accError ){
diff --git a/chromium/third_party/sqlite/src/src/resolve.c b/chromium/third_party/sqlite/src/src/resolve.c
index 27b260e059f..480694f6f57 100644
--- a/chromium/third_party/sqlite/src/src/resolve.c
+++ b/chromium/third_party/sqlite/src/src/resolve.c
@@ -320,8 +320,9 @@ static int lookupName(
}
if( hit || zTab==0 ) continue;
}
- if( zDb && pTab->pSchema!=pSchema ){
- continue;
+ if( zDb ){
+ if( pTab->pSchema!=pSchema ) continue;
+ if( pSchema==0 && strcmp(zDb,"*")!=0 ) continue;
}
if( zTab ){
const char *zTabName = pItem->zAlias ? pItem->zAlias : pTab->zName;
@@ -452,6 +453,7 @@ static int lookupName(
pExpr->y.pTab = pTab;
if( pParse->bReturning ){
eNewExprOp = TK_REGISTER;
+ pExpr->op2 = TK_COLUMN;
pExpr->iTable = pNC->uNC.iBaseReg + (pTab->nCol+1)*pExpr->iTable +
sqlite3TableColumnToStorage(pTab, iCol) + 1;
}else{
@@ -618,6 +620,7 @@ static int lookupName(
}else{
sqlite3ErrorMsg(pParse, "%s: %s", zErr, zCol);
}
+ sqlite3RecordErrorOffsetOfExpr(pParse->db, pExpr);
pParse->checkSchema = 1;
pTopNC->nNcErr++;
}
@@ -726,7 +729,8 @@ static void notValidImpl(
Parse *pParse, /* Leave error message here */
NameContext *pNC, /* The name context */
const char *zMsg, /* Type of error */
- Expr *pExpr /* Invalidate this expression on error */
+ Expr *pExpr, /* Invalidate this expression on error */
+ Expr *pError /* Associate error with this expression */
){
const char *zIn = "partial index WHERE clauses";
if( pNC->ncFlags & NC_IdxExpr ) zIn = "index expressions";
@@ -738,10 +742,11 @@ static void notValidImpl(
#endif
sqlite3ErrorMsg(pParse, "%s prohibited in %s", zMsg, zIn);
if( pExpr ) pExpr->op = TK_NULL;
+ sqlite3RecordErrorOffsetOfExpr(pParse->db, pError);
}
-#define sqlite3ResolveNotValid(P,N,M,X,E) \
+#define sqlite3ResolveNotValid(P,N,M,X,E,R) \
assert( ((X)&~(NC_IsCheck|NC_PartIdx|NC_IdxExpr|NC_GenCol))==0 ); \
- if( ((N)->ncFlags & (X))!=0 ) notValidImpl(P,N,M,E);
+ if( ((N)->ncFlags & (X))!=0 ) notValidImpl(P,N,M,E,R);
/*
** Expression p should encode a floating point value between 1.0 and 0.0.
@@ -876,7 +881,7 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
testcase( pNC->ncFlags & NC_IdxExpr );
testcase( pNC->ncFlags & NC_GenCol );
sqlite3ResolveNotValid(pParse, pNC, "the \".\" operator",
- NC_IdxExpr|NC_GenCol, 0);
+ NC_IdxExpr|NC_GenCol, 0, pExpr);
pRight = pExpr->pRight;
if( pRight->op==TK_ID ){
zDb = 0;
@@ -907,7 +912,6 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
int no_such_func = 0; /* True if no such function exists */
int wrong_num_args = 0; /* True if wrong number of arguments */
int is_agg = 0; /* True if is an aggregate function */
- int nId; /* Number of characters in function name */
const char *zId; /* The function name. */
FuncDef *pDef; /* Information about the function */
u8 enc = ENC(pParse->db); /* The database encoding */
@@ -917,7 +921,6 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
#endif
assert( !ExprHasProperty(pExpr, EP_xIsSelect|EP_IntValue) );
zId = pExpr->u.zToken;
- nId = sqlite3Strlen30(zId);
pDef = sqlite3FindFunction(pParse->db, zId, n, enc, 0);
if( pDef==0 ){
pDef = sqlite3FindFunction(pParse->db, zId, -2, enc, 0);
@@ -934,8 +937,8 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
pExpr->iTable = exprProbability(pList->a[1].pExpr);
if( pExpr->iTable<0 ){
sqlite3ErrorMsg(pParse,
- "second argument to likelihood() must be a "
- "constant between 0.0 and 1.0");
+ "second argument to %#T() must be a "
+ "constant between 0.0 and 1.0", pExpr);
pNC->nNcErr++;
}
}else{
@@ -956,8 +959,8 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
int auth = sqlite3AuthCheck(pParse, SQLITE_FUNCTION, 0,pDef->zName,0);
if( auth!=SQLITE_OK ){
if( auth==SQLITE_DENY ){
- sqlite3ErrorMsg(pParse, "not authorized to use function: %s",
- pDef->zName);
+ sqlite3ErrorMsg(pParse, "not authorized to use function: %#T",
+ pExpr);
pNC->nNcErr++;
}
pExpr->op = TK_NULL;
@@ -980,7 +983,7 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
** in a CHECK constraint. SQLServer, MySQL, and PostgreSQL all
** all this. */
sqlite3ResolveNotValid(pParse, pNC, "non-deterministic functions",
- NC_IdxExpr|NC_PartIdx|NC_GenCol, 0);
+ NC_IdxExpr|NC_PartIdx|NC_GenCol, 0, pExpr);
}else{
assert( (NC_SelfRef & 0xff)==NC_SelfRef ); /* Must fit in 8 bits */
pExpr->op2 = pNC->ncFlags & NC_SelfRef;
@@ -993,7 +996,7 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
/* Internal-use-only functions are disallowed unless the
** SQL is being compiled using sqlite3NestedParse() or
** the SQLITE_TESTCTRL_INTERNAL_FUNCTIONS test-control has be
- ** used to activate internal functionsn for testing purposes */
+ ** used to activate internal functions for testing purposes */
no_such_func = 1;
pDef = 0;
}else
@@ -1012,7 +1015,7 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
);
if( pDef && pDef->xValue==0 && pWin ){
sqlite3ErrorMsg(pParse,
- "%.*s() may not be used as a window function", nId, zId
+ "%#T() may not be used as a window function", pExpr
);
pNC->nNcErr++;
}else if(
@@ -1026,13 +1029,13 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
}else{
zType = "aggregate";
}
- sqlite3ErrorMsg(pParse, "misuse of %s function %.*s()",zType,nId,zId);
+ sqlite3ErrorMsg(pParse, "misuse of %s function %#T()",zType,pExpr);
pNC->nNcErr++;
is_agg = 0;
}
#else
if( (is_agg && (pNC->ncFlags & NC_AllowAgg)==0) ){
- sqlite3ErrorMsg(pParse,"misuse of aggregate function %.*s()",nId,zId);
+ sqlite3ErrorMsg(pParse,"misuse of aggregate function %#T()",pExpr);
pNC->nNcErr++;
is_agg = 0;
}
@@ -1042,18 +1045,18 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
&& pParse->explain==0
#endif
){
- sqlite3ErrorMsg(pParse, "no such function: %.*s", nId, zId);
+ sqlite3ErrorMsg(pParse, "no such function: %#T", pExpr);
pNC->nNcErr++;
}else if( wrong_num_args ){
- sqlite3ErrorMsg(pParse,"wrong number of arguments to function %.*s()",
- nId, zId);
+ sqlite3ErrorMsg(pParse,"wrong number of arguments to function %#T()",
+ pExpr);
pNC->nNcErr++;
}
#ifndef SQLITE_OMIT_WINDOWFUNC
else if( is_agg==0 && ExprHasProperty(pExpr, EP_WinFunc) ){
sqlite3ErrorMsg(pParse,
- "FILTER may not be used with non-aggregate %.*s()",
- nId, zId
+ "FILTER may not be used with non-aggregate %#T()",
+ pExpr
);
pNC->nNcErr++;
}
@@ -1138,7 +1141,7 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
testcase( pNC->ncFlags & NC_IdxExpr );
testcase( pNC->ncFlags & NC_GenCol );
if( pNC->ncFlags & NC_SelfRef ){
- notValidImpl(pParse, pNC, "subqueries", pExpr);
+ notValidImpl(pParse, pNC, "subqueries", pExpr, pExpr);
}else{
sqlite3WalkSelect(pWalker, pExpr->x.pSelect);
}
@@ -1156,7 +1159,7 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
testcase( pNC->ncFlags & NC_IdxExpr );
testcase( pNC->ncFlags & NC_GenCol );
sqlite3ResolveNotValid(pParse, pNC, "parameters",
- NC_IsCheck|NC_PartIdx|NC_IdxExpr|NC_GenCol, pExpr);
+ NC_IsCheck|NC_PartIdx|NC_IdxExpr|NC_GenCol, pExpr, pExpr);
break;
}
case TK_IS:
@@ -1208,11 +1211,13 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
testcase( pExpr->op==TK_ISNOT );
testcase( pExpr->op==TK_BETWEEN );
sqlite3ErrorMsg(pParse, "row value misused");
+ sqlite3RecordErrorOffsetOfExpr(pParse->db, pExpr);
}
break;
}
}
- return (pParse->nErr || pParse->db->mallocFailed) ? WRC_Abort : WRC_Continue;
+ assert( pParse->db->mallocFailed==0 || pParse->nErr!=0 );
+ return pParse->nErr ? WRC_Abort : WRC_Continue;
}
/*
@@ -1320,11 +1325,13 @@ static void resolveOutOfRangeError(
Parse *pParse, /* The error context into which to write the error */
const char *zType, /* "ORDER" or "GROUP" */
int i, /* The index (1-based) of the term out of range */
- int mx /* Largest permissible value of i */
+ int mx, /* Largest permissible value of i */
+ Expr *pError /* Associate the error with the expression */
){
sqlite3ErrorMsg(pParse,
"%r %s BY term out of range - should be "
"between 1 and %d", i, zType, mx);
+ sqlite3RecordErrorOffsetOfExpr(pParse->db, pError);
}
/*
@@ -1380,7 +1387,7 @@ static int resolveCompoundOrderBy(
if( NEVER(pE==0) ) continue;
if( sqlite3ExprIsInteger(pE, &iCol) ){
if( iCol<=0 || iCol>pEList->nExpr ){
- resolveOutOfRangeError(pParse, "ORDER", i+1, pEList->nExpr);
+ resolveOutOfRangeError(pParse, "ORDER", i+1, pEList->nExpr, pE);
return 1;
}
}else{
@@ -1476,7 +1483,7 @@ int sqlite3ResolveOrderGroupBy(
for(i=0, pItem=pOrderBy->a; i<pOrderBy->nExpr; i++, pItem++){
if( pItem->u.x.iOrderByCol ){
if( pItem->u.x.iOrderByCol>pEList->nExpr ){
- resolveOutOfRangeError(pParse, zType, i+1, pEList->nExpr);
+ resolveOutOfRangeError(pParse, zType, i+1, pEList->nExpr, 0);
return 1;
}
resolveAlias(pParse, pEList, pItem->u.x.iOrderByCol-1, pItem->pExpr,0);
@@ -1568,7 +1575,7 @@ static int resolveOrderGroupBy(
** number so that sqlite3ResolveOrderGroupBy() will convert the
** order-by term to a copy of the result-set expression */
if( iCol<1 || iCol>0xffff ){
- resolveOutOfRangeError(pParse, zType, i+1, nResult);
+ resolveOutOfRangeError(pParse, zType, i+1, nResult, pE2);
return 1;
}
pItem->u.x.iOrderByCol = (u16)iCol;
@@ -1626,7 +1633,7 @@ static int resolveSelectStep(Walker *pWalker, Select *p){
*/
if( (p->selFlags & SF_Expanded)==0 ){
sqlite3SelectPrep(pParse, p, pOuterNC);
- return (pParse->nErr || db->mallocFailed) ? WRC_Abort : WRC_Prune;
+ return pParse->nErr ? WRC_Abort : WRC_Prune;
}
isCompound = p->pPrior!=0;
@@ -1674,7 +1681,8 @@ static int resolveSelectStep(Walker *pWalker, Select *p){
if( pItem->zName ) pParse->zAuthContext = pItem->zName;
sqlite3ResolveSelectNames(pParse, pItem->pSelect, pOuterNC);
pParse->zAuthContext = zSavedContext;
- if( pParse->nErr || db->mallocFailed ) return WRC_Abort;
+ if( pParse->nErr ) return WRC_Abort;
+ assert( db->mallocFailed==0 );
/* If the number of references to the outer context changed when
** expressions in the sub-select were resolved, the sub-select
diff --git a/chromium/third_party/sqlite/src/src/select.c b/chromium/third_party/sqlite/src/src/select.c
index 7f15c2acb28..6719d474718 100644
--- a/chromium/third_party/sqlite/src/src/select.c
+++ b/chromium/third_party/sqlite/src/src/select.c
@@ -354,14 +354,14 @@ static void addWhereTerm(
ExprSetProperty(pEq, EP_FromJoin);
assert( !ExprHasProperty(pEq, EP_TokenOnly|EP_Reduced) );
ExprSetVVAProperty(pEq, EP_NoReduce);
- pEq->iRightJoinTable = pE2->iTable;
+ pEq->w.iRightJoinTable = pE2->iTable;
}
*ppWhere = sqlite3ExprAnd(pParse, *ppWhere, pEq);
}
/*
** Set the EP_FromJoin property on all terms of the given expression.
-** And set the Expr.iRightJoinTable to iTable for every term in the
+** And set the Expr.w.iRightJoinTable to iTable for every term in the
** expression.
**
** The EP_FromJoin property is used on terms of an expression to tell
@@ -371,8 +371,8 @@ static void addWhereTerm(
** WHERE clause during join processing but we need to remember that they
** originated in the ON or USING clause.
**
-** The Expr.iRightJoinTable tells the WHERE clause processing that the
-** expression depends on table iRightJoinTable even if that table is not
+** The Expr.w.iRightJoinTable tells the WHERE clause processing that the
+** expression depends on table w.iRightJoinTable even if that table is not
** explicitly mentioned in the expression. That information is needed
** for cases like this:
**
@@ -390,7 +390,7 @@ void sqlite3SetJoinExpr(Expr *p, int iTable){
ExprSetProperty(p, EP_FromJoin);
assert( !ExprHasProperty(p, EP_TokenOnly|EP_Reduced) );
ExprSetVVAProperty(p, EP_NoReduce);
- p->iRightJoinTable = iTable;
+ p->w.iRightJoinTable = iTable;
if( p->op==TK_FUNCTION ){
assert( ExprUseXList(p) );
if( p->x.pList ){
@@ -406,7 +406,7 @@ void sqlite3SetJoinExpr(Expr *p, int iTable){
}
/* Undo the work of sqlite3SetJoinExpr(). In the expression p, convert every
-** term that is marked with EP_FromJoin and iRightJoinTable==iTable into
+** term that is marked with EP_FromJoin and w.iRightJoinTable==iTable into
** an ordinary term that omits the EP_FromJoin mark.
**
** This happens when a LEFT JOIN is simplified into an ordinary JOIN.
@@ -414,7 +414,7 @@ void sqlite3SetJoinExpr(Expr *p, int iTable){
static void unsetJoinExpr(Expr *p, int iTable){
while( p ){
if( ExprHasProperty(p, EP_FromJoin)
- && (iTable<0 || p->iRightJoinTable==iTable) ){
+ && (iTable<0 || p->w.iRightJoinTable==iTable) ){
ExprClearProperty(p, EP_FromJoin);
}
if( p->op==TK_COLUMN && p->iTable==iTable ){
@@ -1404,7 +1404,7 @@ KeyInfo *sqlite3KeyInfoAlloc(sqlite3 *db, int N, int X){
p->nRef = 1;
memset(&p[1], 0, nExtra);
}else{
- sqlite3OomFault(db);
+ return (KeyInfo*)sqlite3OomFault(db);
}
return p;
}
@@ -1575,6 +1575,9 @@ static void generateSortTail(
iTab = pSort->iECursor;
if( eDest==SRT_Output || eDest==SRT_Coroutine || eDest==SRT_Mem ){
+ if( eDest==SRT_Mem && p->iOffset ){
+ sqlite3VdbeAddOp2(v, OP_Null, 0, pDest->iSdst);
+ }
regRowid = 0;
regRow = pDest->iSdst;
}else{
@@ -3296,6 +3299,8 @@ static int multiSelectOrderBy(
){
int i, j; /* Loop counters */
Select *pPrior; /* Another SELECT immediately to our left */
+ Select *pSplit; /* Left-most SELECT in the right-hand group */
+ int nSelect; /* Number of SELECT statements in the compound */
Vdbe *v; /* Generate code to this VDBE */
SelectDest destA; /* Destination for coroutine A */
SelectDest destB; /* Destination for coroutine B */
@@ -3341,8 +3346,7 @@ static int multiSelectOrderBy(
/* Patch up the ORDER BY clause
*/
op = p->op;
- pPrior = p->pPrior;
- assert( pPrior->pOrderBy==0 );
+ assert( p->pPrior->pOrderBy==0 );
pOrderBy = p->pOrderBy;
assert( pOrderBy );
nOrderBy = pOrderBy->nExpr;
@@ -3392,11 +3396,6 @@ static int multiSelectOrderBy(
pKeyMerge = 0;
}
- /* Reattach the ORDER BY clause to the query.
- */
- p->pOrderBy = pOrderBy;
- pPrior->pOrderBy = sqlite3ExprListDup(pParse->db, pOrderBy, 0);
-
/* Allocate a range of temporary registers and the KeyInfo needed
** for the logic that removes duplicate result rows when the
** operator is UNION, EXCEPT, or INTERSECT (but not UNION ALL).
@@ -3421,12 +3420,30 @@ static int multiSelectOrderBy(
/* Separate the left and the right query from one another
*/
- p->pPrior = 0;
+ nSelect = 1;
+ if( (op==TK_ALL || op==TK_UNION)
+ && OptimizationEnabled(db, SQLITE_BalancedMerge)
+ ){
+ for(pSplit=p; pSplit->pPrior!=0 && pSplit->op==op; pSplit=pSplit->pPrior){
+ nSelect++;
+ assert( pSplit->pPrior->pNext==pSplit );
+ }
+ }
+ if( nSelect<=3 ){
+ pSplit = p;
+ }else{
+ pSplit = p;
+ for(i=2; i<nSelect; i+=2){ pSplit = pSplit->pPrior; }
+ }
+ pPrior = pSplit->pPrior;
+ assert( pPrior!=0 );
+ pSplit->pPrior = 0;
pPrior->pNext = 0;
+ assert( p->pOrderBy == pOrderBy );
+ assert( pOrderBy!=0 || db->mallocFailed );
+ pPrior->pOrderBy = sqlite3ExprListDup(pParse->db, pOrderBy, 0);
sqlite3ResolveOrderGroupBy(pParse, p, p->pOrderBy, "ORDER");
- if( pPrior->pPrior==0 ){
- sqlite3ResolveOrderGroupBy(pParse, pPrior, pPrior->pOrderBy, "ORDER");
- }
+ sqlite3ResolveOrderGroupBy(pParse, pPrior, pPrior->pOrderBy, "ORDER");
/* Compute the limit registers */
computeLimitRegisters(pParse, p, labelEnd);
@@ -3577,12 +3594,11 @@ static int multiSelectOrderBy(
/* Reassembly the compound query so that it will be freed correctly
** by the calling function */
- if( p->pPrior ){
- sqlite3SelectDelete(db, p->pPrior);
+ if( pSplit->pPrior ){
+ sqlite3SelectDelete(db, pSplit->pPrior);
}
- p->pPrior = pPrior;
- pPrior->pNext = p;
-
+ pSplit->pPrior = pPrior;
+ pPrior->pNext = pSplit;
sqlite3ExprListDelete(db, pPrior->pOrderBy);
pPrior->pOrderBy = 0;
@@ -3632,9 +3648,9 @@ static Expr *substExpr(
){
if( pExpr==0 ) return 0;
if( ExprHasProperty(pExpr, EP_FromJoin)
- && pExpr->iRightJoinTable==pSubst->iTable
+ && pExpr->w.iRightJoinTable==pSubst->iTable
){
- pExpr->iRightJoinTable = pSubst->iNewTable;
+ pExpr->w.iRightJoinTable = pSubst->iNewTable;
}
if( pExpr->op==TK_COLUMN
&& pExpr->iTable==pSubst->iTable
@@ -3673,7 +3689,7 @@ static Expr *substExpr(
ExprSetProperty(pNew, EP_CanBeNull);
}
if( ExprHasProperty(pExpr,EP_FromJoin) ){
- sqlite3SetJoinExpr(pNew, pExpr->iRightJoinTable);
+ sqlite3SetJoinExpr(pNew, pExpr->w.iRightJoinTable);
}
sqlite3ExprDelete(db, pExpr);
pExpr = pNew;
@@ -3838,7 +3854,7 @@ static int renumberCursorsCb(Walker *pWalker, Expr *pExpr){
renumberCursorDoMapping(pWalker, &pExpr->iTable);
}
if( ExprHasProperty(pExpr, EP_FromJoin) ){
- renumberCursorDoMapping(pWalker, &pExpr->iRightJoinTable);
+ renumberCursorDoMapping(pWalker, &pExpr->w.iRightJoinTable);
}
return WRC_Continue;
}
@@ -4848,11 +4864,13 @@ static int pushDownWhereTerms(
}
if( isLeftJoin
&& (ExprHasProperty(pWhere,EP_FromJoin)==0
- || pWhere->iRightJoinTable!=iCursor)
+ || pWhere->w.iRightJoinTable!=iCursor)
){
return 0; /* restriction (4) */
}
- if( ExprHasProperty(pWhere,EP_FromJoin) && pWhere->iRightJoinTable!=iCursor ){
+ if( ExprHasProperty(pWhere,EP_FromJoin)
+ && pWhere->w.iRightJoinTable!=iCursor
+ ){
return 0; /* restriction (5) */
}
if( sqlite3ExprIsTableConstant(pWhere, iCursor) ){
@@ -5572,7 +5590,8 @@ static int selectExpander(Walker *pWalker, Select *p){
/* Process NATURAL keywords, and ON and USING clauses of joins.
*/
- if( pParse->nErr || db->mallocFailed || sqliteProcessJoin(pParse, p) ){
+ assert( db->mallocFailed==0 || pParse->nErr!=0 );
+ if( pParse->nErr || sqliteProcessJoin(pParse, p) ){
return WRC_Abort;
}
@@ -5869,12 +5888,13 @@ void sqlite3SelectPrep(
NameContext *pOuterNC /* Name context for container */
){
assert( p!=0 || pParse->db->mallocFailed );
+ assert( pParse->db->pParse==pParse );
if( pParse->db->mallocFailed ) return;
if( p->selFlags & SF_HasTypeInfo ) return;
sqlite3SelectExpand(pParse, p);
- if( pParse->nErr || pParse->db->mallocFailed ) return;
+ if( pParse->nErr ) return;
sqlite3ResolveSelectNames(pParse, p, pOuterNC);
- if( pParse->nErr || pParse->db->mallocFailed ) return;
+ if( pParse->nErr ) return;
sqlite3SelectAddTypeInfo(pParse, p);
}
@@ -5891,8 +5911,10 @@ static void resetAccumulator(Parse *pParse, AggInfo *pAggInfo){
int i;
struct AggInfo_func *pFunc;
int nReg = pAggInfo->nFunc + pAggInfo->nColumn;
+ assert( pParse->db->pParse==pParse );
+ assert( pParse->db->mallocFailed==0 || pParse->nErr!=0 );
if( nReg==0 ) return;
- if( pParse->nErr || pParse->db->mallocFailed ) return;
+ if( pParse->nErr ) return;
#ifdef SQLITE_DEBUG
/* Verify that all AggInfo registers are within the range specified by
** AggInfo.mnReg..AggInfo.mxReg */
@@ -6315,10 +6337,12 @@ int sqlite3Select(
u8 minMaxFlag; /* Flag for min/max queries */
db = pParse->db;
+ assert( pParse==db->pParse );
v = sqlite3GetVdbe(pParse);
- if( p==0 || db->mallocFailed || pParse->nErr ){
+ if( p==0 || pParse->nErr ){
return 1;
}
+ assert( db->mallocFailed==0 );
if( sqlite3AuthCheck(pParse, SQLITE_SELECT, 0, 0, 0) ) return 1;
#if SELECTTRACE_ENABLED
SELECTTRACE(1,pParse,p, ("begin processing:\n", pParse->addrExplain));
@@ -6353,9 +6377,10 @@ int sqlite3Select(
p->selFlags |= SF_NoopOrderBy;
}
sqlite3SelectPrep(pParse, p, 0);
- if( pParse->nErr || db->mallocFailed ){
+ if( pParse->nErr ){
goto select_end;
}
+ assert( db->mallocFailed==0 );
assert( p->pEList!=0 );
#if SELECTTRACE_ENABLED
if( sqlite3SelectTrace & 0x104 ){
@@ -6399,7 +6424,7 @@ int sqlite3Select(
#ifndef SQLITE_OMIT_WINDOWFUNC
if( sqlite3WindowRewrite(pParse, p) ){
- assert( db->mallocFailed || pParse->nErr>0 );
+ assert( pParse->nErr );
goto select_end;
}
#if SELECTTRACE_ENABLED
@@ -6875,7 +6900,7 @@ int sqlite3Select(
/* Begin the database scan. */
SELECTTRACE(1,pParse,p,("WhereBegin\n"));
pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, sSort.pOrderBy,
- p->pEList, wctrlFlags, p->nSelectRow);
+ p->pEList, p, wctrlFlags, p->nSelectRow);
if( pWInfo==0 ) goto select_end;
if( sqlite3WhereOutputRowCount(pWInfo) < p->nSelectRow ){
p->nSelectRow = sqlite3WhereOutputRowCount(pWInfo);
@@ -7139,7 +7164,7 @@ int sqlite3Select(
sqlite3VdbeAddOp2(v, OP_Gosub, regReset, addrReset);
SELECTTRACE(1,pParse,p,("WhereBegin\n"));
pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, pGroupBy, pDistinct,
- WHERE_GROUPBY | (orderByGrp ? WHERE_SORTBYGROUP : 0) | distFlag, 0
+ 0, (WHERE_GROUPBY|(orderByGrp ? WHERE_SORTBYGROUP : 0)|distFlag), 0
);
if( pWInfo==0 ){
sqlite3ExprListDelete(db, pDistinct);
@@ -7437,7 +7462,7 @@ int sqlite3Select(
SELECTTRACE(1,pParse,p,("WhereBegin\n"));
pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, pMinMaxOrderBy,
- pDistinct, minMaxFlag|distFlag, 0);
+ pDistinct, 0, minMaxFlag|distFlag, 0);
if( pWInfo==0 ){
goto select_end;
}
@@ -7494,7 +7519,7 @@ int sqlite3Select(
*/
select_end:
assert( db->mallocFailed==0 || db->mallocFailed==1 );
- pParse->nErr += db->mallocFailed;
+ assert( db->mallocFailed==0 || pParse->nErr!=0 );
sqlite3ExprListDelete(db, pMinMaxOrderBy);
#ifdef SQLITE_DEBUG
if( pAggInfo && !db->mallocFailed ){
diff --git a/chromium/third_party/sqlite/src/src/shell.c.in b/chromium/third_party/sqlite/src/src/shell.c.in
index 543141c9e4f..45cbb436e0c 100644
--- a/chromium/third_party/sqlite/src/src/shell.c.in
+++ b/chromium/third_party/sqlite/src/src/shell.c.in
@@ -23,10 +23,10 @@
** If SQLITE_CUSTOM_INCLUDE=? is defined, its value names the #include
** file. Note that this macro has a like effect on sqlite3.c compilation.
*/
+# define SHELL_STRINGIFY_(f) #f
+# define SHELL_STRINGIFY(f) SHELL_STRINGIFY_(f)
#ifdef SQLITE_CUSTOM_INCLUDE
-# define INC_STRINGIFY_(f) #f
-# define INC_STRINGIFY(f) INC_STRINGIFY_(f)
-# include INC_STRINGIFY(SQLITE_CUSTOM_INCLUDE)
+# include SHELL_STRINGIFY(SQLITE_CUSTOM_INCLUDE)
#endif
/*
@@ -427,15 +427,6 @@ static sqlite3 *globalDb = 0;
*/
static volatile int seenInterrupt = 0;
-#ifdef SQLITE_DEBUG
-/*
-** Out-of-memory simulator variables
-*/
-static unsigned int oomCounter = 0; /* Simulate OOM when equals 1 */
-static unsigned int oomRepeat = 0; /* Number of OOMs in a row */
-static void*(*defaultMalloc)(int) = 0; /* The low-level malloc routine */
-#endif /* SQLITE_DEBUG */
-
/*
** This is the name of our program. It is set in main(), used
** in a number of other places, mostly for error messages.
@@ -487,48 +478,12 @@ static void shell_out_of_memory(void){
exit(1);
}
-#ifdef SQLITE_DEBUG
-/* This routine is called when a simulated OOM occurs. It is broken
-** out as a separate routine to make it easy to set a breakpoint on
-** the OOM
+/* Check a pointer to see if it is NULL. If it is NULL, exit with an
+** out-of-memory error.
*/
-void shellOomFault(void){
- if( oomRepeat>0 ){
- oomRepeat--;
- }else{
- oomCounter--;
- }
-}
-#endif /* SQLITE_DEBUG */
-
-#ifdef SQLITE_DEBUG
-/* This routine is a replacement malloc() that is used to simulate
-** Out-Of-Memory (OOM) errors for testing purposes.
-*/
-static void *oomMalloc(int nByte){
- if( oomCounter ){
- if( oomCounter==1 ){
- shellOomFault();
- return 0;
- }else{
- oomCounter--;
- }
- }
- return defaultMalloc(nByte);
+static void shell_check_oom(void *p){
+ if( p==0 ) shell_out_of_memory();
}
-#endif /* SQLITE_DEBUG */
-
-#ifdef SQLITE_DEBUG
-/* Register the OOM simulator. This must occur before any memory
-** allocations */
-static void registerOomSimulator(void){
- sqlite3_mem_methods mem;
- sqlite3_config(SQLITE_CONFIG_GETMALLOC, &mem);
- defaultMalloc = mem.xMalloc;
- mem.xMalloc = oomMalloc;
- sqlite3_config(SQLITE_CONFIG_MALLOC, &mem);
-}
-#endif
/*
** Write I/O traces to the following stream.
@@ -685,7 +640,7 @@ static char *local_getline(char *zLine, FILE *in){
if( n+100>nLine ){
nLine = nLine*2 + 100;
zLine = realloc(zLine, nLine);
- if( zLine==0 ) shell_out_of_memory();
+ shell_check_oom(zLine);
}
if( fgets(&zLine[n], nLine - n, in)==0 ){
if( n==0 ){
@@ -712,7 +667,7 @@ static char *local_getline(char *zLine, FILE *in){
int nTrans = strlen30(zTrans)+1;
if( nTrans>nLine ){
zLine = realloc(zLine, nTrans);
- if( zLine==0 ) shell_out_of_memory();
+ shell_check_oom(zLine);
}
memcpy(zLine, zTrans, nTrans);
sqlite3_free(zTrans);
@@ -859,7 +814,7 @@ static void appendText(ShellText *p, char const *zAppend, char quote){
if( p->z==0 || p->n+len>=p->nAlloc ){
p->nAlloc = p->nAlloc*2 + len + 20;
p->z = realloc(p->z, p->nAlloc);
- if( p->z==0 ) shell_out_of_memory();
+ shell_check_oom(p->z);
}
if( quote ){
@@ -914,6 +869,7 @@ static char *shellFakeSchema(
zSql = sqlite3_mprintf("PRAGMA \"%w\".table_info=%Q;",
zSchema ? zSchema : "main", zName);
+ shell_check_oom(zSql);
sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);
sqlite3_free(zSql);
initText(&s);
@@ -930,6 +886,7 @@ static char *shellFakeSchema(
nRow++;
appendText(&s, zDiv, 0);
zDiv = ",";
+ if( zCol==0 ) zCol = "";
cQuote = quoteChar(zCol);
appendText(&s, zCol, cQuote);
}
@@ -953,9 +910,11 @@ static void shellModuleSchema(
int nVal,
sqlite3_value **apVal
){
- const char *zName = (const char*)sqlite3_value_text(apVal[0]);
- char *zFake = shellFakeSchema(sqlite3_context_db_handle(pCtx), 0, zName);
+ const char *zName;
+ char *zFake;
UNUSED_PARAMETER(nVal);
+ zName = (const char*)sqlite3_value_text(apVal[0]);
+ zFake = zName ? shellFakeSchema(sqlite3_context_db_handle(pCtx), 0, zName) : 0;
if( zFake ){
sqlite3_result_text(pCtx, sqlite3_mprintf("/* %s */", zFake),
-1, sqlite3_free);
@@ -1107,6 +1066,15 @@ struct EQPGraph {
char zPrefix[100]; /* Graph prefix */
};
+/* Parameters affecting columnar mode result display (defaulting together) */
+typedef struct ColModeOpts {
+ int iWrap; /* In columnar modes, wrap lines reaching this limit */
+ u8 bQuote; /* Quote results for .mode box and table */
+ u8 bWordWrap; /* In columnar modes, wrap at word boundaries */
+} ColModeOpts;
+#define ColModeOpts_default { 60, 0, 0 }
+#define ColModeOpts_default_qbox { 60, 1, 0 }
+
/*
** State information about the database connection is contained in an
** instance of the following structure.
@@ -1125,8 +1093,10 @@ struct ShellState {
u8 eTraceType; /* SHELL_TRACE_* value for type of trace */
u8 bSafeMode; /* True to prohibit unsafe operations */
u8 bSafeModePersist; /* The long-term value of bSafeMode */
+ ColModeOpts cmOpts; /* Option values affecting columnar mode output */
unsigned statsOn; /* True to display memory stats before each finalize */
unsigned mEqpLines; /* Mask of veritical lines in the EQP output graph */
+ int inputNesting; /* Track nesting level of .read and other redirects */
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 */
@@ -1253,6 +1223,8 @@ struct ShellState {
#define MODE_Markdown 14 /* Markdown formatting */
#define MODE_Table 15 /* MySQL-style table formatting */
#define MODE_Box 16 /* Unicode box-drawing characters */
+#define MODE_Count 17 /* Output only a count of the rows of output */
+#define MODE_Off 18 /* No query output shown */
static const char *modeDescr[] = {
"line",
@@ -1271,7 +1243,9 @@ static const char *modeDescr[] = {
"json",
"markdown",
"table",
- "box"
+ "box",
+ "count",
+ "off"
};
/*
@@ -1288,6 +1262,12 @@ static const char *modeDescr[] = {
#define SEP_Record "\x1E"
/*
+** Limit input nesting via .read or any other input redirect.
+** It's not too expensive, so a generous allowance can be made.
+*/
+#define MAX_INPUT_NESTING 25
+
+/*
** A callback for the sqlite3_log() interface.
*/
static void shellLog(void *pArg, int iErrCode, const char *zMsg){
@@ -1771,6 +1751,7 @@ static void output_csv(ShellState *p, const char *z, int bSep){
}
if( i==0 || strstr(z, p->colSeparator)!=0 ){
char *zQuoted = sqlite3_mprintf("\"%w\"", z);
+ shell_check_oom(zQuoted);
utf8_printf(out, "%s", zQuoted);
sqlite3_free(zQuoted);
}else{
@@ -1945,7 +1926,7 @@ static void eqp_append(ShellState *p, int iEqpId, int p2, const char *zText){
utf8_printf(p->out, "%d,%d,%s\n", iEqpId, p2, zText);
}
pNew = sqlite3_malloc64( sizeof(*pNew) + nText );
- if( pNew==0 ) shell_out_of_memory();
+ shell_check_oom(pNew);
pNew->iEqpId = iEqpId;
pNew->iParentId = p2;
memcpy(pNew->zText, zText, nText+1);
@@ -2093,6 +2074,10 @@ static int shell_callback(
if( azArg==0 ) return 0;
switch( p->cMode ){
+ case MODE_Count:
+ case MODE_Off: {
+ break;
+ }
case MODE_Line: {
int w = 5;
if( azArg==0 ) break;
@@ -2162,6 +2147,7 @@ static int shell_callback(
break;
}
z = sqlite3_mprintf("%s", azArg[0]);
+ shell_check_oom(z);
j = 0;
for(i=0; IsSpace(z[i]); i++){}
for(; (c = z[i])!=0; i++){
@@ -2293,6 +2279,7 @@ static int shell_callback(
if( i>0 ) raw_printf(p->out, ",");
if( quoteChar(azCol[i]) ){
char *z = sqlite3_mprintf("\"%w\"", azCol[i]);
+ shell_check_oom(z);
utf8_printf(p->out, "%s", z);
sqlite3_free(z);
}else{
@@ -2324,7 +2311,12 @@ static int shell_callback(
}else if( ur==0xfff0000000000000LL ){
raw_printf(p->out, "-1e999");
}else{
- sqlite3_snprintf(50,z,"%!.20g", r);
+ sqlite3_int64 ir = (sqlite3_int64)r;
+ if( r==(double)ir ){
+ sqlite3_snprintf(50,z,"%lld.0", ir);
+ }else{
+ sqlite3_snprintf(50,z,"%!.20g", r);
+ }
raw_printf(p->out, "%s", z);
}
}else if( aiType && aiType[i]==SQLITE_BLOB && p->pStmt ){
@@ -2538,7 +2530,7 @@ static void set_table_name(ShellState *p, const char *zName){
n = strlen30(zName);
if( cQuote ) n += n+2;
z = p->zDestTable = malloc( n+1 );
- if( z==0 ) shell_out_of_memory();
+ shell_check_oom(z);
n = 0;
if( cQuote ) z[n++] = cQuote;
for(i=0; zName[i]; i++){
@@ -2549,6 +2541,47 @@ static void set_table_name(ShellState *p, const char *zName){
z[n] = 0;
}
+/*
+** Maybe construct two lines of text that point out the position of a
+** syntax error. Return a pointer to the text, in memory obtained from
+** sqlite3_malloc(). Or, if the most recent error does not involve a
+** specific token that we can point to, return an empty string.
+**
+** In all cases, the memory returned is obtained from sqlite3_malloc64()
+** and should be released by the caller invoking sqlite3_free().
+*/
+static char *shell_error_context(const char *zSql, sqlite3 *db){
+ int iOffset;
+ size_t len;
+ char *zCode;
+ char *zMsg;
+ int i;
+ if( db==0
+ || zSql==0
+ || (iOffset = sqlite3_error_offset(db))<0
+ ){
+ return sqlite3_mprintf("");
+ }
+ while( iOffset>50 ){
+ iOffset--;
+ zSql++;
+ while( (zSql[0]&0xc0)==0x80 ){ zSql++; iOffset--; }
+ }
+ len = strlen(zSql);
+ if( len>78 ){
+ len = 78;
+ while( (zSql[len]&0xc0)==0x80 ) len--;
+ }
+ zCode = sqlite3_mprintf("%.*s", len, zSql);
+ for(i=0; zCode[i]; i++){ if( IsSpace(zSql[i]) ) zCode[i] = ' '; }
+ if( iOffset<25 ){
+ zMsg = sqlite3_mprintf("\n %z\n %*s^--- error here", zCode, iOffset, "");
+ }else{
+ zMsg = sqlite3_mprintf("\n %z\n %*serror here ---^", zCode, iOffset-14, "");
+ }
+ return zMsg;
+}
+
/*
** Execute a query statement that will generate SQL output. Print
@@ -2571,8 +2604,10 @@ static int run_table_dump_query(
const char *z;
rc = sqlite3_prepare_v2(p->db, zSelect, -1, &pSelect, 0);
if( rc!=SQLITE_OK || !pSelect ){
- utf8_printf(p->out, "/**** ERROR: (%d) %s *****/\n", rc,
- sqlite3_errmsg(p->db));
+ char *zContext = shell_error_context(zSelect, p->db);
+ utf8_printf(p->out, "/**** ERROR: (%d) %s *****/\n%s", rc,
+ sqlite3_errmsg(p->db), zContext);
+ sqlite3_free(zContext);
if( (rc&0xff)!=SQLITE_CORRUPT ) p->nErr++;
return rc;
}
@@ -2607,12 +2642,25 @@ static int run_table_dump_query(
*/
static char *save_err_msg(
sqlite3 *db, /* Database to query */
- const char *zWhen, /* Qualifier (format) wrapper */
- int rc /* Error code returned from API */
+ const char *zPhase, /* When the error occcurs */
+ int rc, /* Error code returned from API */
+ const char *zSql /* SQL string, or NULL */
){
- if( zWhen==0 )
- zWhen = "%s (%d)";
- return sqlite3_mprintf(zWhen, sqlite3_errmsg(db), rc);
+ char *zErr;
+ char *zContext;
+ sqlite3_str *pStr = sqlite3_str_new(0);
+ sqlite3_str_appendf(pStr, "%s, %s", zPhase, sqlite3_errmsg(db));
+ if( rc>1 ){
+ sqlite3_str_appendf(pStr, " (%d)", rc);
+ }
+ zContext = shell_error_context(zSql, db);
+ if( zContext ){
+ sqlite3_str_appendall(pStr, zContext);
+ sqlite3_free(zContext);
+ }
+ zErr = sqlite3_str_finish(pStr);
+ shell_check_oom(zErr);
+ return zErr;
}
#ifdef __linux__
@@ -2790,6 +2838,7 @@ static int display_stats(
}
if( pArg->pStmt ){
+ int iHit, iMiss;
iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_FULLSCAN_STEP,
bReset);
raw_printf(pArg->out, "Fullscan Steps: %d\n", iCur);
@@ -2797,6 +2846,12 @@ static int display_stats(
raw_printf(pArg->out, "Sort Operations: %d\n", iCur);
iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_AUTOINDEX,bReset);
raw_printf(pArg->out, "Autoindex Inserts: %d\n", iCur);
+ iHit = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_FILTER_HIT, bReset);
+ iMiss = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_FILTER_MISS, bReset);
+ if( iHit || iMiss ){
+ raw_printf(pArg->out, "Bloom filter bypass taken: %d/%d\n",
+ iHit, iHit+iMiss);
+ }
iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_VM_STEP, bReset);
raw_printf(pArg->out, "Virtual Machine Steps: %d\n", iCur);
iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_REPREPARE,bReset);
@@ -2953,9 +3008,9 @@ static void explain_data_prepare(ShellState *p, sqlite3_stmt *pSql){
}
nAlloc += 100;
p->aiIndent = (int*)sqlite3_realloc64(p->aiIndent, nAlloc*sizeof(int));
- if( p->aiIndent==0 ) shell_out_of_memory();
+ shell_check_oom(p->aiIndent);
abYield = (int*)sqlite3_realloc64(abYield, nAlloc*sizeof(int));
- if( abYield==0 ) shell_out_of_memory();
+ shell_check_oom(abYield);
}
abYield[iOp] = str_in_array(zOp, azYield);
p->aiIndent[iOp] = 0;
@@ -3131,7 +3186,134 @@ static void print_box_row_separator(
fputs("\n", p->out);
}
+/*
+** z[] is a line of text that is to be displayed the .mode box or table or
+** similar tabular formats. z[] might contain control characters such
+** as \n, \t, \f, or \r.
+**
+** Compute characters to display on the first line of z[]. Stop at the
+** first \r, \n, or \f. Expand \t into spaces. Return a copy (obtained
+** from malloc()) of that first line, which caller should free sometime.
+** Write anything to display on the next line into *pzTail. If this is
+** the last line, write a NULL into *pzTail. (*pzTail is not allocated.)
+*/
+static char *translateForDisplayAndDup(
+ const unsigned char *z, /* Input text to be transformed */
+ const unsigned char **pzTail, /* OUT: Tail of the input for next line */
+ int mxWidth, /* Max width. 0 means no limit */
+ u8 bWordWrap /* If true, avoid breaking mid-word */
+){
+ int i; /* Input bytes consumed */
+ int j; /* Output bytes generated */
+ int k; /* Input bytes to be displayed */
+ int n; /* Output column number */
+ unsigned char *zOut; /* Output text */
+
+ if( z==0 ){
+ *pzTail = 0;
+ return 0;
+ }
+ if( mxWidth<0 ) mxWidth = -mxWidth;
+ if( mxWidth==0 ) mxWidth = 1000000;
+ i = j = n = 0;
+ while( n<mxWidth ){
+ if( z[i]>=' ' ){
+ n++;
+ do{ i++; j++; }while( (z[i]&0xc0)==0x80 );
+ continue;
+ }
+ if( z[i]=='\t' ){
+ do{
+ n++;
+ j++;
+ }while( (n&7)!=0 && n<mxWidth );
+ i++;
+ continue;
+ }
+ break;
+ }
+ if( n>=mxWidth && bWordWrap ){
+ /* Perhaps try to back up to a better place to break the line */
+ for(k=i; k>i/2; k--){
+ if( isspace(z[k-1]) ) break;
+ }
+ if( k<=i/2 ){
+ for(k=i; k>i/2; k--){
+ if( isalnum(z[k-1])!=isalnum(z[k]) && (z[k]&0xc0)!=0x80 ) break;
+ }
+ }
+ if( k<=i/2 ){
+ k = i;
+ }else{
+ i = k;
+ while( z[i]==' ' ) i++;
+ }
+ }else{
+ k = i;
+ }
+ if( n>=mxWidth && z[i]>=' ' ){
+ *pzTail = &z[i];
+ }else if( z[i]=='\r' && z[i+1]=='\n' ){
+ *pzTail = z[i+2] ? &z[i+2] : 0;
+ }else if( z[i]==0 || z[i+1]==0 ){
+ *pzTail = 0;
+ }else{
+ *pzTail = &z[i+1];
+ }
+ zOut = malloc( j+1 );
+ shell_check_oom(zOut);
+ i = j = n = 0;
+ while( i<k ){
+ if( z[i]>=' ' ){
+ n++;
+ do{ zOut[j++] = z[i++]; }while( (z[i]&0xc0)==0x80 );
+ continue;
+ }
+ if( z[i]=='\t' ){
+ do{
+ n++;
+ zOut[j++] = ' ';
+ }while( (n&7)!=0 && n<mxWidth );
+ i++;
+ continue;
+ }
+ break;
+ }
+ zOut[j] = 0;
+ return (char*)zOut;
+}
+/* Extract the value of the i-th current column for pStmt as an SQL literal
+** value. Memory is obtained from sqlite3_malloc64() and must be freed by
+** the caller.
+*/
+static char *quoted_column(sqlite3_stmt *pStmt, int i){
+ switch( sqlite3_column_type(pStmt, i) ){
+ case SQLITE_NULL: {
+ return sqlite3_mprintf("NULL");
+ }
+ case SQLITE_INTEGER:
+ case SQLITE_FLOAT: {
+ return sqlite3_mprintf("%s",sqlite3_column_text(pStmt,i));
+ }
+ case SQLITE_TEXT: {
+ return sqlite3_mprintf("%Q",sqlite3_column_text(pStmt,i));
+ }
+ case SQLITE_BLOB: {
+ int j;
+ sqlite3_str *pStr = sqlite3_str_new(0);
+ const unsigned char *a = sqlite3_column_blob(pStmt,i);
+ int n = sqlite3_column_bytes(pStmt,i);
+ sqlite3_str_append(pStr, "x'", 2);
+ for(j=0; j<n; j++){
+ sqlite3_str_appendf(pStr, "%02x", a[j]);
+ }
+ sqlite3_str_append(pStr, "'", 1);
+ return sqlite3_str_finish(pStr);
+ }
+ }
+ return 0; /* Not reached */
+}
/*
** Run a prepared statement and output the result in one of the
@@ -3151,12 +3333,19 @@ static void exec_prepared_stmt_columnar(
int nColumn = 0;
char **azData = 0;
sqlite3_int64 nAlloc = 0;
+ char *abRowDiv = 0;
+ const unsigned char *uz;
const char *z;
+ char **azQuoted = 0;
int rc;
sqlite3_int64 i, nData;
int j, nTotal, w, n;
const char *colSep = 0;
const char *rowSep = 0;
+ const unsigned char **azNextLine = 0;
+ int bNextLine = 0;
+ int bMultiLineRowExists = 0;
+ int bw = p->cmOpts.bWordWrap;
rc = sqlite3_step(pStmt);
if( rc!=SQLITE_ROW ) return;
@@ -3164,25 +3353,20 @@ static void exec_prepared_stmt_columnar(
nAlloc = nColumn*4;
if( nAlloc<=0 ) nAlloc = 1;
azData = sqlite3_malloc64( nAlloc*sizeof(char*) );
- if( azData==0 ) shell_out_of_memory();
- for(i=0; i<nColumn; i++){
- azData[i] = strdup(sqlite3_column_name(pStmt,i));
- }
- do{
- if( (nRow+2)*nColumn >= nAlloc ){
- nAlloc *= 2;
- azData = sqlite3_realloc64(azData, nAlloc*sizeof(char*));
- if( azData==0 ) shell_out_of_memory();
- }
- nRow++;
- for(i=0; i<nColumn; i++){
- z = (const char*)sqlite3_column_text(pStmt,i);
- azData[nRow*nColumn + i] = z ? strdup(z) : 0;
- }
- }while( sqlite3_step(pStmt)==SQLITE_ROW );
+ shell_check_oom(azData);
+ azNextLine = sqlite3_malloc64( nColumn*sizeof(char*) );
+ shell_check_oom((void*)azNextLine);
+ memset((void*)azNextLine, 0, nColumn*sizeof(char*) );
+ if( p->cmOpts.bQuote ){
+ azQuoted = sqlite3_malloc64( nColumn*sizeof(char*) );
+ shell_check_oom(azQuoted);
+ memset(azQuoted, 0, nColumn*sizeof(char*) );
+ }
+ abRowDiv = sqlite3_malloc64( nAlloc/nColumn );
+ shell_check_oom(abRowDiv);
if( nColumn>p->nWidth ){
p->colWidth = realloc(p->colWidth, (nColumn+1)*2*sizeof(int));
- if( p->colWidth==0 ) shell_out_of_memory();
+ shell_check_oom(p->colWidth);
for(i=p->nWidth; i<nColumn; i++) p->colWidth[i] = 0;
p->nWidth = nColumn;
p->actualWidth = &p->colWidth[nColumn];
@@ -3193,6 +3377,52 @@ static void exec_prepared_stmt_columnar(
if( w<0 ) w = -w;
p->actualWidth[i] = w;
}
+ for(i=0; i<nColumn; i++){
+ const unsigned char *zNotUsed;
+ int wx = p->colWidth[i];
+ if( wx==0 ){
+ wx = p->cmOpts.iWrap;
+ }
+ if( wx<0 ) wx = -wx;
+ uz = (const unsigned char*)sqlite3_column_name(pStmt,i);
+ azData[i] = translateForDisplayAndDup(uz, &zNotUsed, wx, bw);
+ }
+ do{
+ int useNextLine = bNextLine;
+ bNextLine = 0;
+ if( (nRow+2)*nColumn >= nAlloc ){
+ nAlloc *= 2;
+ azData = sqlite3_realloc64(azData, nAlloc*sizeof(char*));
+ shell_check_oom(azData);
+ abRowDiv = sqlite3_realloc64(abRowDiv, nAlloc/nColumn);
+ shell_check_oom(abRowDiv);
+ }
+ abRowDiv[nRow] = 1;
+ nRow++;
+ for(i=0; i<nColumn; i++){
+ int wx = p->colWidth[i];
+ if( wx==0 ){
+ wx = p->cmOpts.iWrap;
+ }
+ if( wx<0 ) wx = -wx;
+ if( useNextLine ){
+ uz = azNextLine[i];
+ }else if( p->cmOpts.bQuote ){
+ sqlite3_free(azQuoted[i]);
+ azQuoted[i] = quoted_column(pStmt,i);
+ uz = (const unsigned char*)azQuoted[i];
+ }else{
+ uz = (const unsigned char*)sqlite3_column_text(pStmt,i);
+ }
+ azData[nRow*nColumn + i]
+ = translateForDisplayAndDup(uz, &azNextLine[i], wx, bw);
+ if( azNextLine[i] ){
+ bNextLine = 1;
+ abRowDiv[nRow-1] = 0;
+ bMultiLineRowExists = 1;
+ }
+ }
+ }while( bNextLine || sqlite3_step(pStmt)==SQLITE_ROW );
nTotal = nColumn*(nRow+1);
for(i=0; i<nTotal; i++){
z = azData[i];
@@ -3275,6 +3505,15 @@ static void exec_prepared_stmt_columnar(
utf8_width_print(p->out, w, z);
if( j==nColumn-1 ){
utf8_printf(p->out, "%s", rowSep);
+ if( bMultiLineRowExists && abRowDiv[i/nColumn-1] && i+1<nTotal ){
+ if( p->cMode==MODE_Table ){
+ print_row_separator(p, nColumn, "+");
+ }else if( p->cMode==MODE_Box ){
+ print_box_row_separator(p, nColumn, BOX_123, BOX_1234, BOX_134);
+ }else if( p->cMode==MODE_Column ){
+ raw_printf(p->out, "\n");
+ }
+ }
j = -1;
if( seenInterrupt ) goto columnar_end;
}else{
@@ -3293,6 +3532,12 @@ columnar_end:
nData = (nRow+1)*nColumn;
for(i=0; i<nData; i++) free(azData[i]);
sqlite3_free(azData);
+ sqlite3_free((void*)azNextLine);
+ sqlite3_free(abRowDiv);
+ if( azQuoted ){
+ for(i=0; i<nColumn; i++) sqlite3_free(azQuoted[i]);
+ sqlite3_free(azQuoted);
+ }
}
/*
@@ -3303,6 +3548,7 @@ static void exec_prepared_stmt(
sqlite3_stmt *pStmt /* Statment to run */
){
int rc;
+ sqlite3_uint64 nRow = 0;
if( pArg->cMode==MODE_Column
|| pArg->cMode==MODE_Table
@@ -3335,10 +3581,14 @@ static void exec_prepared_stmt(
azCols[i] = (char *)sqlite3_column_name(pStmt, i);
}
do{
+ nRow++;
/* extract the data and data types */
for(i=0; i<nCol; i++){
aiTypes[i] = x = sqlite3_column_type(pStmt, i);
- if( x==SQLITE_BLOB && pArg && pArg->cMode==MODE_Insert ){
+ if( x==SQLITE_BLOB
+ && pArg
+ && (pArg->cMode==MODE_Insert || pArg->cMode==MODE_Quote)
+ ){
azVals[i] = "";
}else{
azVals[i] = (char*)sqlite3_column_text(pStmt, i);
@@ -3362,6 +3612,11 @@ static void exec_prepared_stmt(
sqlite3_free(pData);
if( pArg->cMode==MODE_Json ){
fputs("]\n", pArg->out);
+ }else if( pArg->cMode==MODE_Count ){
+ char zBuf[200];
+ sqlite3_snprintf(sizeof(zBuf), zBuf, "%llu row%s\n",
+ nRow, nRow!=1 ? "s" : "");
+ printf("%s", zBuf);
}
}
}
@@ -3485,7 +3740,7 @@ static int expertDotCommand(
if( rc==SQLITE_OK ){
pState->expert.pExpert = sqlite3_expert_new(pState->db, &zErr);
if( pState->expert.pExpert==0 ){
- raw_printf(stderr, "sqlite3_expert_new: %s\n", zErr);
+ raw_printf(stderr, "sqlite3_expert_new: %s\n", zErr ? zErr : "out of memory");
rc = SQLITE_ERROR;
}else{
sqlite3_expert_config(
@@ -3493,6 +3748,7 @@ static int expertDotCommand(
);
}
}
+ sqlite3_free(zErr);
return rc;
}
@@ -3534,7 +3790,7 @@ static int shell_exec(
rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, &zLeftover);
if( SQLITE_OK != rc ){
if( pzErrMsg ){
- *pzErrMsg = save_err_msg(db, "in prepare, %s (%d)", rc);
+ *pzErrMsg = save_err_msg(db, "in prepare", rc, zSql);
}
}else{
if( !pStmt ){
@@ -3569,6 +3825,7 @@ static int shell_exec(
sqlite3_db_config(db, SQLITE_DBCONFIG_TRIGGER_EQP, 1, 0);
}
zEQP = sqlite3_mprintf("EXPLAIN QUERY PLAN %s", zStmtSql);
+ shell_check_oom(zEQP);
rc = sqlite3_prepare_v2(db, zEQP, -1, &pExplain, 0);
if( rc==SQLITE_OK ){
while( sqlite3_step(pExplain)==SQLITE_ROW ){
@@ -3586,6 +3843,7 @@ static int shell_exec(
if( pArg->autoEQP>=AUTOEQP_full ){
/* Also do an EXPLAIN for ".eqp full" mode */
zEQP = sqlite3_mprintf("EXPLAIN %s", zStmtSql);
+ shell_check_oom(zEQP);
rc = sqlite3_prepare_v2(db, zEQP, -1, &pExplain, 0);
if( rc==SQLITE_OK ){
pArg->cMode = MODE_Explain;
@@ -3648,7 +3906,7 @@ static int shell_exec(
zSql = zLeftover;
while( IsSpace(zSql[0]) ) zSql++;
}else if( pzErrMsg ){
- *pzErrMsg = save_err_msg(db, "stepping, %s (%d)", rc);
+ *pzErrMsg = save_err_msg(db, "stepping", rc, 0);
}
/* clear saved stmt handle */
@@ -3698,6 +3956,7 @@ static char **tableColumnList(ShellState *p, const char *zTab){
int rc;
zSql = sqlite3_mprintf("PRAGMA table_info=%Q", zTab);
+ shell_check_oom(zSql);
rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
sqlite3_free(zSql);
if( rc ) return 0;
@@ -3705,9 +3964,10 @@ static char **tableColumnList(ShellState *p, const char *zTab){
if( nCol>=nAlloc-2 ){
nAlloc = nAlloc*2 + nCol + 10;
azCol = sqlite3_realloc(azCol, nAlloc*sizeof(azCol[0]));
- if( azCol==0 ) shell_out_of_memory();
+ shell_check_oom(azCol);
}
azCol[++nCol] = sqlite3_mprintf("%s", sqlite3_column_text(pStmt, 1));
+ shell_check_oom(azCol[nCol]);
if( sqlite3_column_int(pStmt, 5) ){
nPK++;
if( nPK==1
@@ -3741,6 +4001,7 @@ static char **tableColumnList(ShellState *p, const char *zTab){
*/
zSql = sqlite3_mprintf("SELECT 1 FROM pragma_index_list(%Q)"
" WHERE origin='pk'", zTab);
+ shell_check_oom(zSql);
rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
sqlite3_free(zSql);
if( rc ){
@@ -3832,6 +4093,7 @@ static int dump_callback(void *pArg, int nArg, char **azArg, char **azNotUsed){
"INSERT INTO sqlite_schema(type,name,tbl_name,rootpage,sql)"
"VALUES('table','%q','%q',0,'%q');",
zTable, zTable, zSql);
+ shell_check_oom(zIns);
utf8_printf(p->out, "%s\n", zIns);
sqlite3_free(zIns);
return 0;
@@ -3983,6 +4245,7 @@ static const char *(azHelp[]) = {
".auth ON|OFF Show authorizer callbacks",
#endif
".backup ?DB? FILE Backup DB (default \"main\") to FILE",
+ " Options:",
" --append Use the appendvfs",
" --async Write to FILE without journal and fsync()",
".bail on|off Stop after hitting an error. Default OFF",
@@ -4027,6 +4290,7 @@ static const char *(azHelp[]) = {
" --ascii Use \\037 and \\036 as column and row separators",
" --csv Use , and \\n as column and row separators",
" --skip N Skip the first N rows of input",
+ " --schema S Target table to be S.TABLE",
" -v \"Verbose\" - increase auxiliary output",
" Notes:",
" * If TABLE does not exist, it is created. The first row of input",
@@ -4052,32 +4316,37 @@ static const char *(azHelp[]) = {
".load FILE ?ENTRY? Load an extension library",
#endif
".log FILE|off Turn logging on or off. FILE can be stderr/stdout",
- ".mode MODE ?TABLE? Set output mode",
+ ".mode MODE ?OPTIONS? Set output mode",
" MODE is one of:",
- " ascii Columns/rows delimited by 0x1F and 0x1E",
- " box Tables using unicode box-drawing characters",
- " csv Comma-separated values",
- " column Output in columns. (See .width)",
- " html HTML <table> code",
- " insert SQL insert statements for TABLE",
- " json Results in a JSON array",
- " line One value per line",
- " list Values delimited by \"|\"",
- " markdown Markdown table format",
- " quote Escape answers as for SQL",
- " table ASCII-art table",
- " tabs Tab-separated values",
- " tcl TCL list elements",
- ".nonce STRING Disable safe mode for one command if the nonce matches",
+ " ascii Columns/rows delimited by 0x1F and 0x1E",
+ " box Tables using unicode box-drawing characters",
+ " csv Comma-separated values",
+ " column Output in columns. (See .width)",
+ " html HTML <table> code",
+ " insert SQL insert statements for TABLE",
+ " json Results in a JSON array",
+ " line One value per line",
+ " list Values delimited by \"|\"",
+ " markdown Markdown table format",
+ " qbox Shorthand for \"box --width 60 --quote\"",
+ " quote Escape answers as for SQL",
+ " table ASCII-art table",
+ " tabs Tab-separated values",
+ " tcl TCL list elements",
+ " OPTIONS: (for columnar modes or insert mode):",
+ " --wrap N Wrap output lines to no longer than N characters",
+ " --wordwrap B Wrap or not at word boundaries per B (on/off)",
+ " --ww Shorthand for \"--wordwrap 1\"",
+ " --quote Quote output text as SQL literals",
+ " --noquote Do not quote output text",
+ " TABLE The name of SQL table used for \"insert\" mode",
+ ".nonce STRING Suspend safe mode for one command if nonce matches",
".nullvalue STRING Use STRING in place of NULL values",
".once ?OPTIONS? ?FILE? Output for the next SQL command only to FILE",
" If FILE begins with '|' then open as a pipe",
" --bom Put a UTF8 byte-order mark at the beginning",
" -e Send output to the system text editor",
" -x Send output as CSV to a spreadsheet (same as \".excel\")",
-#ifdef SQLITE_DEBUG
- ".oom ?--repeat M? ?N? Simulate an OOM error on the N-th allocation",
-#endif
".open ?OPTIONS? ?FILE? Close existing database and reopen FILE",
" Options:",
" --append Use appendvfs to append database to the end of FILE",
@@ -4113,7 +4382,8 @@ static const char *(azHelp[]) = {
#endif
".prompt MAIN CONTINUE Replace the standard prompts",
".quit Exit this program",
- ".read FILE Read input from FILE",
+ ".read FILE Read input from FILE or command output",
+ " If FILE begins with \"|\", it is a command that generates the input.",
#if !defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_ENABLE_DBPAGE_VTAB)
".recover Recover as much data as possible from corrupt db.",
" --freelist-corrupt Assume the freelist is corrupt",
@@ -4123,7 +4393,7 @@ static const char *(azHelp[]) = {
" that are not also INTEGER PRIMARY KEYs",
#endif
".restore ?DB? FILE Restore content of DB (default \"main\") from FILE",
- ".save FILE Write in-memory database into FILE",
+ ".save ?OPTIONS? FILE Write database to FILE (an alias for .backup ...)",
".scanstats on|off Turn sqlite3_stmt_scanstatus() metrics on or off",
".schema ?PATTERN? Show the CREATE statements matching PATTERN",
" Options:",
@@ -4233,6 +4503,7 @@ static int showHelp(FILE *out, const char *zPattern){
}else{
/* Look for commands that for which zPattern is an exact prefix */
zPat = sqlite3_mprintf(".%s*", zPattern);
+ shell_check_oom(zPat);
for(i=0; i<ArraySize(azHelp); i++){
if( sqlite3_strglob(zPat, azHelp[i])==0 ){
utf8_printf(out, "%s\n", azHelp[i]);
@@ -4255,6 +4526,7 @@ static int showHelp(FILE *out, const char *zPattern){
/* Look for commands that contain zPattern anywhere. Show the complete
** text of all commands that match. */
zPat = sqlite3_mprintf("%%%s%%", zPattern);
+ shell_check_oom(zPat);
for(i=0; i<ArraySize(azHelp); i++){
if( azHelp[i][0]=='.' ) j = i;
if( sqlite3_strlike(zPat, azHelp[i], 0)==0 ){
@@ -4443,10 +4715,7 @@ static unsigned char *readHexDb(ShellState *p, int *pnData){
if( pgsz<512 || pgsz>65536 || (pgsz&(pgsz-1))!=0 ) goto readHexDb_error;
n = (n+pgsz-1)&~(pgsz-1); /* Round n up to the next multiple of pgsz */
a = sqlite3_malloc( n ? n : 1 );
- if( a==0 ){
- utf8_printf(stderr, "Out of memory!\n");
- goto readHexDb_error;
- }
+ shell_check_oom(a);
memset(a, 0, n);
if( pgsz<512 || pgsz>65536 || (pgsz & (pgsz-1))!=0 ){
utf8_printf(stderr, "invalid pagesize\n");
@@ -4577,7 +4846,7 @@ static void shellEscapeCrnl(
){
const char *zText = (const char*)sqlite3_value_text(argv[0]);
UNUSED_PARAMETER(argc);
- if( zText[0]=='\'' ){
+ if( zText && zText[0]=='\'' ){
int nText = sqlite3_value_bytes(argv[0]);
int i;
char zBuf1[20];
@@ -4754,6 +5023,7 @@ static void open_db(ShellState *p, int openFlags){
if( p->openMode==SHELL_OPEN_ZIPFILE ){
char *zSql = sqlite3_mprintf(
"CREATE VIRTUAL TABLE zip USING zipfile(%Q);", zDbFilename);
+ shell_check_oom(zSql);
sqlite3_exec(p->db, zSql, 0, 0, 0);
sqlite3_free(zSql);
}
@@ -4811,11 +5081,13 @@ static char *readline_completion_generator(const char *text, int state){
sqlite3_finalize(pStmt);
zSql = sqlite3_mprintf("SELECT DISTINCT candidate COLLATE nocase"
" FROM completion(%Q) ORDER BY 1", text);
+ shell_check_oom(zSql);
sqlite3_prepare_v2(globalDb, zSql, -1, &pStmt, 0);
sqlite3_free(zSql);
}
if( sqlite3_step(pStmt)==SQLITE_ROW ){
- zRet = strdup((const char*)sqlite3_column_text(pStmt, 0));
+ const char *z = (const char*)sqlite3_column_text(pStmt,0);
+ zRet = z ? strdup(z) : 0;
}else{
sqlite3_finalize(pStmt);
pStmt = 0;
@@ -4848,13 +5120,14 @@ static void linenoise_completion(const char *zLine, linenoiseCompletions *lc){
zSql = sqlite3_mprintf("SELECT DISTINCT candidate COLLATE nocase"
" FROM completion(%Q,%Q) ORDER BY 1",
&zLine[iStart], zLine);
+ shell_check_oom(zSql);
sqlite3_prepare_v2(globalDb, zSql, -1, &pStmt, 0);
sqlite3_free(zSql);
sqlite3_exec(globalDb, "PRAGMA page_count", 0, 0, 0); /* Load the schema */
while( sqlite3_step(pStmt)==SQLITE_ROW ){
const char *zCompletion = (const char*)sqlite3_column_text(pStmt, 0);
int nCompletion = sqlite3_column_bytes(pStmt, 0);
- if( iStart+nCompletion < sizeof(zBuf)-1 ){
+ if( iStart+nCompletion < sizeof(zBuf)-1 && zCompletion ){
memcpy(zBuf+iStart, zCompletion, nCompletion+1);
linenoiseAddCompletion(lc, zBuf);
}
@@ -5089,7 +5362,7 @@ static void import_append_char(ImportCtx *p, int c){
if( p->n+1>=p->nAlloc ){
p->nAlloc += p->nAlloc + 100;
p->z = sqlite3_realloc64(p->z, p->nAlloc);
- if( p->z==0 ) shell_out_of_memory();
+ shell_check_oom(p->z);
}
p->z[p->n++] = (char)c;
}
@@ -5241,6 +5514,7 @@ static void tryToCloneData(
const int spinRate = 10000;
zQuery = sqlite3_mprintf("SELECT * FROM \"%w\"", zTable);
+ shell_check_oom(zQuery);
rc = sqlite3_prepare_v2(p->db, zQuery, -1, &pQuery, 0);
if( rc ){
utf8_printf(stderr, "Error %d: %s on [%s]\n",
@@ -5250,7 +5524,7 @@ static void tryToCloneData(
}
n = sqlite3_column_count(pQuery);
zInsert = sqlite3_malloc64(200 + nTable + n*3);
- if( zInsert==0 ) shell_out_of_memory();
+ shell_check_oom(zInsert);
sqlite3_snprintf(200+nTable,zInsert,
"INSERT OR IGNORE INTO \"%s\" VALUES(?", zTable);
i = strlen30(zInsert);
@@ -5313,6 +5587,7 @@ static void tryToCloneData(
sqlite3_free(zQuery);
zQuery = sqlite3_mprintf("SELECT * FROM \"%w\" ORDER BY rowid DESC;",
zTable);
+ shell_check_oom(zQuery);
rc = sqlite3_prepare_v2(p->db, zQuery, -1, &pQuery, 0);
if( rc ){
utf8_printf(stderr, "Warning: cannot step \"%s\" backwards", zTable);
@@ -5349,6 +5624,7 @@ static void tryToCloneSchema(
zQuery = sqlite3_mprintf("SELECT name, sql FROM sqlite_schema"
" WHERE %s", zWhere);
+ shell_check_oom(zQuery);
rc = sqlite3_prepare_v2(p->db, zQuery, -1, &pQuery, 0);
if( rc ){
utf8_printf(stderr, "Error: (%d) %s on [%s]\n",
@@ -5359,6 +5635,7 @@ static void tryToCloneSchema(
while( (rc = sqlite3_step(pQuery))==SQLITE_ROW ){
zName = sqlite3_column_text(pQuery, 0);
zSql = sqlite3_column_text(pQuery, 1);
+ if( zName==0 || zSql==0 ) continue;
printf("%s... ", zName); fflush(stdout);
sqlite3_exec(newDb, (const char*)zSql, 0, 0, &zErrMsg);
if( zErrMsg ){
@@ -5376,6 +5653,7 @@ static void tryToCloneSchema(
sqlite3_free(zQuery);
zQuery = sqlite3_mprintf("SELECT name, sql FROM sqlite_schema"
" WHERE %s ORDER BY rowid DESC", zWhere);
+ shell_check_oom(zQuery);
rc = sqlite3_prepare_v2(p->db, zQuery, -1, &pQuery, 0);
if( rc ){
utf8_printf(stderr, "Error: (%d) %s on [%s]\n",
@@ -5386,6 +5664,7 @@ static void tryToCloneSchema(
while( sqlite3_step(pQuery)==SQLITE_ROW ){
zName = sqlite3_column_text(pQuery, 0);
zSql = sqlite3_column_text(pQuery, 1);
+ if( zName==0 || zSql==0 ) continue;
printf("%s... ", zName); fflush(stdout);
sqlite3_exec(newDb, (const char*)zSql, 0, 0, &zErrMsg);
if( zErrMsg ){
@@ -5478,10 +5757,10 @@ static void output_reset(ShellState *p){
/*
** Run an SQL command and return the single integer result.
*/
-static int db_int(ShellState *p, const char *zSql){
+static int db_int(sqlite3 *db, const char *zSql){
sqlite3_stmt *pStmt;
int res = 0;
- sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
+ sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);
if( pStmt && sqlite3_step(pStmt)==SQLITE_ROW ){
res = sqlite3_column_int(pStmt,0);
}
@@ -5586,7 +5865,7 @@ static int shell_dbinfo_command(ShellState *p, int nArg, char **azArg){
}
for(i=0; i<ArraySize(aQuery); i++){
char *zSql = sqlite3_mprintf(aQuery[i].zSql, zSchemaTab);
- int val = db_int(p, zSql);
+ int val = db_int(p->db, zSql);
sqlite3_free(zSql);
utf8_printf(p->out, "%-20s %d\n", aQuery[i].zName, val);
}
@@ -5770,9 +6049,7 @@ static void newTempFile(ShellState *p, const char *zSuffix){
}else{
p->zTempFile = sqlite3_mprintf("%z.%s", p->zTempFile, zSuffix);
}
- if( p->zTempFile==0 ){
- shell_out_of_memory();
- }
+ shell_check_oom(p->zTempFile);
}
@@ -5953,14 +6230,14 @@ static int lintFkeyIndexes(
const char *zCI = (const char*)sqlite3_column_text(pSql, 4);
const char *zParent = (const char*)sqlite3_column_text(pSql, 5);
+ if( zEQP==0 ) continue;
+ if( zGlob==0 ) continue;
rc = sqlite3_prepare_v2(db, zEQP, -1, &pExplain, 0);
if( rc!=SQLITE_OK ) break;
if( SQLITE_ROW==sqlite3_step(pExplain) ){
const char *zPlan = (const char*)sqlite3_column_text(pExplain, 3);
- res = (
- 0==sqlite3_strglob(zGlob, zPlan)
- || 0==sqlite3_strglob(zGlobIPK, zPlan)
- );
+ res = zPlan!=0 && ( 0==sqlite3_strglob(zGlob, zPlan)
+ || 0==sqlite3_strglob(zGlobIPK, zPlan));
}
rc = sqlite3_finalize(pExplain);
if( rc!=SQLITE_OK ) break;
@@ -6952,6 +7229,7 @@ static char *shellMPrintf(int *pRc, const char *zFmt, ...){
return z;
}
+
/*
** When running the ".recover" command, each output table, and the special
** orphaned row table if it is required, is represented by an instance
@@ -7065,6 +7343,7 @@ static RecoverTable *recoverNewTable(
if( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pPkFinder) ){
pTab->iPk = sqlite3_column_int(pPkFinder, 0);
zPk = (const char*)sqlite3_column_text(pPkFinder, 1);
+ if( zPk==0 ){ zPk = "_"; /* Defensive. Should never happen */ }
}
}
@@ -7149,8 +7428,10 @@ static RecoverTable *recoverFindTable(
if( sqlite3_stricmp(zType, "table")==0 ){
zName = (const char*)sqlite3_column_text(pStmt, 1);
zSql = (const char*)sqlite3_column_text(pStmt, 2);
- pRet = recoverNewTable(pRc, zName, zSql, bIntkey, nCol);
- break;
+ if( zName!=0 && zSql!=0 ){
+ pRet = recoverNewTable(pRc, zName, zSql, bIntkey, nCol);
+ break;
+ }
}
}
@@ -7545,6 +7826,221 @@ static int recoverDatabaseCmd(ShellState *pState, int nArg, char **azArg){
}
#endif /* !(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_ENABLE_DBPAGE_VTAB) */
+
+/*
+ * zAutoColumn(zCol, &db, ?) => Maybe init db, add column zCol to it.
+ * zAutoColumn(0, &db, ?) => (db!=0) Form columns spec for CREATE TABLE,
+ * close db and set it to 0, and return the columns spec, to later
+ * be sqlite3_free()'ed by the caller.
+ * The return is 0 when either:
+ * (a) The db was not initialized and zCol==0 (There are no columns.)
+ * (b) zCol!=0 (Column was added, db initialized as needed.)
+ * The 3rd argument, pRenamed, references an out parameter. If the
+ * pointer is non-zero, its referent will be set to a summary of renames
+ * done if renaming was necessary, or set to 0 if none was done. The out
+ * string (if any) must be sqlite3_free()'ed by the caller.
+ */
+#ifdef SHELL_DEBUG
+#define rc_err_oom_die(rc) \
+ if( rc==SQLITE_NOMEM ) shell_check_oom(0); \
+ else if(!(rc==SQLITE_OK||rc==SQLITE_DONE)) \
+ fprintf(stderr,"E:%d\n",rc), assert(0)
+#else
+static void rc_err_oom_die(int rc){
+ if( rc==SQLITE_NOMEM ) shell_check_oom(0);
+ assert(rc==SQLITE_OK||rc==SQLITE_DONE);
+}
+#endif
+
+#ifdef SHELL_COLFIX_DB /* If this is set, the DB can be in a file. */
+static char zCOL_DB[] = SHELL_STRINGIFY(SHELL_COLFIX_DB);
+#else /* Otherwise, memory is faster/better for the transient DB. */
+static const char *zCOL_DB = ":memory:";
+#endif
+
+/* Define character (as C string) to separate generated column ordinal
+ * from protected part of incoming column names. This defaults to "_"
+ * so that incoming column identifiers that did not need not be quoted
+ * remain usable without being quoted. It must be one character.
+ */
+#ifndef SHELL_AUTOCOLUMN_SEP
+# define AUTOCOLUMN_SEP "_"
+#else
+# define AUTOCOLUMN_SEP SHELL_STRINGIFY(SHELL_AUTOCOLUMN_SEP)
+#endif
+
+static char *zAutoColumn(const char *zColNew, sqlite3 **pDb, char **pzRenamed){
+ /* Queries and D{D,M}L used here */
+ static const char * const zTabMake = "\
+CREATE TABLE ColNames(\
+ cpos INTEGER PRIMARY KEY,\
+ name TEXT, nlen INT, chop INT, reps INT, suff TEXT);\
+CREATE VIEW RepeatedNames AS \
+SELECT DISTINCT t.name FROM ColNames t \
+WHERE t.name COLLATE NOCASE IN (\
+ SELECT o.name FROM ColNames o WHERE o.cpos<>t.cpos\
+);\
+";
+ static const char * const zTabFill = "\
+INSERT INTO ColNames(name,nlen,chop,reps,suff)\
+ VALUES(iif(length(?1)>0,?1,'?'),max(length(?1),1),0,0,'')\
+";
+ static const char * const zHasDupes = "\
+SELECT count(DISTINCT (substring(name,1,nlen-chop)||suff) COLLATE NOCASE)\
+ <count(name) FROM ColNames\
+";
+#ifdef SHELL_COLUMN_RENAME_CLEAN
+ static const char * const zDedoctor = "\
+UPDATE ColNames SET chop=iif(\
+ (substring(name,nlen,1) BETWEEN '0' AND '9')\
+ AND (rtrim(name,'0123456790') glob '*"AUTOCOLUMN_SEP"'),\
+ nlen-length(rtrim(name, '"AUTOCOLUMN_SEP"0123456789')),\
+ 0\
+)\
+";
+#endif
+ static const char * const zSetReps = "\
+UPDATE ColNames AS t SET reps=\
+(SELECT count(*) FROM ColNames d \
+ WHERE substring(t.name,1,t.nlen-t.chop)=substring(d.name,1,d.nlen-d.chop)\
+ COLLATE NOCASE\
+)\
+";
+#ifdef SQLITE_ENABLE_MATH_FUNCTIONS
+ static const char * const zColDigits = "\
+SELECT CAST(ceil(log(count(*)+0.5)) AS INT) FROM ColNames \
+";
+#endif
+ static const char * const zRenameRank =
+#ifdef SHELL_COLUMN_RENAME_CLEAN
+ "UPDATE ColNames AS t SET suff="
+ "iif(reps>1, printf('%c%0*d', '"AUTOCOLUMN_SEP"', $1, cpos), '')"
+#else /* ...RENAME_MINIMAL_ONE_PASS */
+"WITH Lzn(nlz) AS (" /* Find minimum extraneous leading 0's for uniqueness */
+" SELECT 0 AS nlz"
+" UNION"
+" SELECT nlz+1 AS nlz FROM Lzn"
+" WHERE EXISTS("
+" SELECT 1"
+" FROM ColNames t, ColNames o"
+" WHERE"
+" iif(t.name IN (SELECT * FROM RepeatedNames),"
+" printf('%s"AUTOCOLUMN_SEP"%s',"
+" t.name, substring(printf('%.*c%0.*d',nlz+1,'0',$1,t.cpos),2)),"
+" t.name"
+" )"
+" ="
+" iif(o.name IN (SELECT * FROM RepeatedNames),"
+" printf('%s"AUTOCOLUMN_SEP"%s',"
+" o.name, substring(printf('%.*c%0.*d',nlz+1,'0',$1,o.cpos),2)),"
+" o.name"
+" )"
+" COLLATE NOCASE"
+" AND o.cpos<>t.cpos"
+" GROUP BY t.cpos"
+" )"
+") UPDATE Colnames AS t SET"
+" chop = 0," /* No chopping, never touch incoming names. */
+" suff = iif(name IN (SELECT * FROM RepeatedNames),"
+" printf('"AUTOCOLUMN_SEP"%s', substring("
+" printf('%.*c%0.*d',(SELECT max(nlz) FROM Lzn)+1,'0',1,t.cpos),2)),"
+" ''"
+" )"
+#endif
+ ;
+ static const char * const zCollectVar = "\
+SELECT\
+ '('||x'0a'\
+ || group_concat(\
+ cname||' TEXT',\
+ ','||iif((cpos-1)%4>0, ' ', x'0a'||' '))\
+ ||')' AS ColsSpec \
+FROM (\
+ SELECT cpos, printf('\"%w\"',printf('%.*s%s', nlen-chop,name,suff)) AS cname \
+ FROM ColNames ORDER BY cpos\
+)";
+ static const char * const zRenamesDone =
+ "SELECT group_concat("
+ " printf('\"%w\" to \"%w\"',name,printf('%.*s%s', nlen-chop, name, suff)),"
+ " ','||x'0a')"
+ "FROM ColNames WHERE suff<>'' OR chop!=0"
+ ;
+ int rc;
+ sqlite3_stmt *pStmt = 0;
+ assert(pDb!=0);
+ if( zColNew ){
+ /* Add initial or additional column. Init db if necessary. */
+ if( *pDb==0 ){
+ if( SQLITE_OK!=sqlite3_open(zCOL_DB, pDb) ) return 0;
+#ifdef SHELL_COLFIX_DB
+ if(*zCOL_DB!=':')
+ sqlite3_exec(*pDb,"drop table if exists ColNames;"
+ "drop view if exists RepeatedNames;",0,0,0);
+#endif
+ rc = sqlite3_exec(*pDb, zTabMake, 0, 0, 0);
+ rc_err_oom_die(rc);
+ }
+ assert(*pDb!=0);
+ rc = sqlite3_prepare_v2(*pDb, zTabFill, -1, &pStmt, 0);
+ rc_err_oom_die(rc);
+ rc = sqlite3_bind_text(pStmt, 1, zColNew, -1, 0);
+ rc_err_oom_die(rc);
+ rc = sqlite3_step(pStmt);
+ rc_err_oom_die(rc);
+ sqlite3_finalize(pStmt);
+ return 0;
+ }else if( *pDb==0 ){
+ return 0;
+ }else{
+ /* Formulate the columns spec, close the DB, zero *pDb. */
+ char *zColsSpec = 0;
+ int hasDupes = db_int(*pDb, zHasDupes);
+#ifdef SQLITE_ENABLE_MATH_FUNCTIONS
+ int nDigits = (hasDupes)? db_int(*pDb, zColDigits) : 0;
+#else
+# define nDigits 2
+#endif
+ if( hasDupes ){
+#ifdef SHELL_COLUMN_RENAME_CLEAN
+ rc = sqlite3_exec(*pDb, zDedoctor, 0, 0, 0);
+ rc_err_oom_die(rc);
+#endif
+ rc = sqlite3_exec(*pDb, zSetReps, 0, 0, 0);
+ rc_err_oom_die(rc);
+ rc = sqlite3_prepare_v2(*pDb, zRenameRank, -1, &pStmt, 0);
+ rc_err_oom_die(rc);
+ sqlite3_bind_int(pStmt, 1, nDigits);
+ rc = sqlite3_step(pStmt);
+ sqlite3_finalize(pStmt);
+ assert(rc==SQLITE_DONE);
+ }
+ assert(db_int(*pDb, zHasDupes)==0); /* Consider: remove this */
+ rc = sqlite3_prepare_v2(*pDb, zCollectVar, -1, &pStmt, 0);
+ rc_err_oom_die(rc);
+ rc = sqlite3_step(pStmt);
+ if( rc==SQLITE_ROW ){
+ zColsSpec = sqlite3_mprintf("%s", sqlite3_column_text(pStmt, 0));
+ }else{
+ zColsSpec = 0;
+ }
+ if( pzRenamed!=0 ){
+ if( !hasDupes ) *pzRenamed = 0;
+ else{
+ sqlite3_finalize(pStmt);
+ if( SQLITE_OK==sqlite3_prepare_v2(*pDb, zRenamesDone, -1, &pStmt, 0)
+ && SQLITE_ROW==sqlite3_step(pStmt) ){
+ *pzRenamed = sqlite3_mprintf("%s", sqlite3_column_text(pStmt, 0));
+ }else
+ *pzRenamed = 0;
+ }
+ }
+ sqlite3_finalize(pStmt);
+ sqlite3_close(*pDb);
+ *pDb = 0;
+ return zColsSpec;
+ }
+}
+
/*
** If an input line begins with "." then invoke this routine to
** process that line.
@@ -7844,8 +8340,9 @@ static int do_meta_command(char *zLine, ShellState *p){
while( sqlite3_step(pStmt)==SQLITE_ROW ){
const char *zSchema = (const char *)sqlite3_column_text(pStmt,1);
const char *zFile = (const char*)sqlite3_column_text(pStmt,2);
+ if( zSchema==0 || zFile==0 ) continue;
azName = sqlite3_realloc(azName, (nName+1)*2*sizeof(char*));
- if( azName==0 ){ shell_out_of_memory(); /* Does not return */ }
+ shell_check_oom(azName);
azName[nName*2] = strdup(zSchema);
azName[nName*2+1] = strdup(zFile);
nName++;
@@ -8101,8 +8598,15 @@ static int do_meta_command(char *zLine, ShellState *p){
#ifndef SQLITE_OMIT_VIRTUALTABLE
if( c=='e' && strncmp(azArg[0], "expert", n)==0 ){
- open_db(p, 0);
- expertDotCommand(p, azArg, nArg);
+ if( p->bSafeMode ){
+ raw_printf(stderr,
+ "Cannot run experimental commands such as \"%s\" in safe mode\n",
+ azArg[0]);
+ rc = 1;
+ }else{
+ open_db(p, 0);
+ expertDotCommand(p, azArg, nArg);
+ }
}else
#endif
@@ -8323,6 +8827,7 @@ static int do_meta_command(char *zLine, ShellState *p){
if( c=='i' && strncmp(azArg[0], "import", n)==0 ){
char *zTable = 0; /* Insert data into this table */
+ char *zSchema = 0; /* within this schema (may default to "main") */
char *zFile = 0; /* Name of file to extra content from */
sqlite3_stmt *pStmt = NULL; /* A statement */
int nCol; /* Number of columns in the table */
@@ -8331,11 +8836,13 @@ static int do_meta_command(char *zLine, ShellState *p){
int needCommit; /* True to COMMIT or ROLLBACK at end */
int nSep; /* Number of bytes in p->colSeparator[] */
char *zSql; /* An SQL statement */
+ char *zFullTabName; /* Table name with schema if applicable */
ImportCtx sCtx; /* Reader context */
char *(SQLITE_CDECL *xRead)(ImportCtx*); /* Func to read one value */
int eVerbose = 0; /* Larger for more console output */
int nSkip = 0; /* Initial lines to skip */
int useOutputMode = 1; /* Use output mode to determine separators */
+ char *zCreate = 0; /* CREATE TABLE statement text */
failIfSafeMode(p, "cannot run .import in safe mode");
memset(&sCtx, 0, sizeof(sCtx));
@@ -8365,6 +8872,8 @@ static int do_meta_command(char *zLine, ShellState *p){
}
}else if( strcmp(z,"-v")==0 ){
eVerbose++;
+ }else if( strcmp(z,"-schema")==0 && i<nArg-1 ){
+ zSchema = azArg[++i];
}else if( strcmp(z,"-skip")==0 && i<nArg-1 ){
nSkip = integerValue(azArg[++i]);
}else if( strcmp(z,"-ascii")==0 ){
@@ -8467,11 +8976,17 @@ static int do_meta_command(char *zLine, ShellState *p){
output_c_string(p->out, zSep);
utf8_printf(p->out, "\n");
}
+ /* Below, resources must be freed before exit. */
while( (nSkip--)>0 ){
while( xRead(&sCtx) && sCtx.cTerm==sCtx.cColSep ){}
}
- zSql = sqlite3_mprintf("SELECT * FROM \"%w\"", zTable);
- if( zSql==0 ){
+ if( zSchema!=0 ){
+ zFullTabName = sqlite3_mprintf("\"%w\".\"%w\"", zSchema, zTable);
+ }else{
+ zFullTabName = sqlite3_mprintf("\"%w\"", zTable);
+ }
+ zSql = sqlite3_mprintf("SELECT * FROM %s", zFullTabName);
+ if( zSql==0 || zFullTabName==0 ){
import_cleanup(&sCtx);
shell_out_of_memory();
}
@@ -8479,43 +8994,51 @@ static int do_meta_command(char *zLine, ShellState *p){
rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
import_append_char(&sCtx, 0); /* To ensure sCtx.z is allocated */
if( rc && sqlite3_strglob("no such table: *", sqlite3_errmsg(p->db))==0 ){
- char *zCreate = sqlite3_mprintf("CREATE TABLE \"%w\"", zTable);
- char cSep = '(';
+ sqlite3 *dbCols = 0;
+ char *zRenames = 0;
+ char *zColDefs;
+ zCreate = sqlite3_mprintf("CREATE TABLE %s", zFullTabName);
while( xRead(&sCtx) ){
- zCreate = sqlite3_mprintf("%z%c\n \"%w\" TEXT", zCreate, cSep, sCtx.z);
- cSep = ',';
+ zAutoColumn(sCtx.z, &dbCols, 0);
if( sCtx.cTerm!=sCtx.cColSep ) break;
}
- if( cSep=='(' ){
+ zColDefs = zAutoColumn(0, &dbCols, &zRenames);
+ if( zRenames!=0 ){
+ utf8_printf((stdin_is_interactive && p->in==stdin)? p->out : stderr,
+ "Columns renamed during .import %s due to duplicates:\n"
+ "%s\n", sCtx.zFile, zRenames);
+ sqlite3_free(zRenames);
+ }
+ assert(dbCols==0);
+ if( zColDefs==0 ){
+ utf8_printf(stderr,"%s: empty file\n", sCtx.zFile);
+ import_fail:
sqlite3_free(zCreate);
+ sqlite3_free(zSql);
+ sqlite3_free(zFullTabName);
import_cleanup(&sCtx);
- utf8_printf(stderr,"%s: empty file\n", sCtx.zFile);
rc = 1;
goto meta_command_exit;
}
- zCreate = sqlite3_mprintf("%z\n)", zCreate);
+ zCreate = sqlite3_mprintf("%z%z\n", zCreate, zColDefs);
if( eVerbose>=1 ){
utf8_printf(p->out, "%s\n", zCreate);
}
rc = sqlite3_exec(p->db, zCreate, 0, 0, 0);
- sqlite3_free(zCreate);
if( rc ){
- utf8_printf(stderr, "CREATE TABLE \"%s\"(...) failed: %s\n", zTable,
- sqlite3_errmsg(p->db));
- import_cleanup(&sCtx);
- rc = 1;
- goto meta_command_exit;
+ utf8_printf(stderr, "%s failed:\n%s\n", zCreate, sqlite3_errmsg(p->db));
+ goto import_fail;
}
+ sqlite3_free(zCreate);
+ zCreate = 0;
rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
}
- sqlite3_free(zSql);
if( rc ){
if (pStmt) sqlite3_finalize(pStmt);
utf8_printf(stderr,"Error: %s\n", sqlite3_errmsg(p->db));
- import_cleanup(&sCtx);
- rc = 1;
- goto meta_command_exit;
+ goto import_fail;
}
+ sqlite3_free(zSql);
nCol = sqlite3_column_count(pStmt);
sqlite3_finalize(pStmt);
pStmt = 0;
@@ -8525,7 +9048,7 @@ static int do_meta_command(char *zLine, ShellState *p){
import_cleanup(&sCtx);
shell_out_of_memory();
}
- sqlite3_snprintf(nByte+20, zSql, "INSERT INTO \"%w\" VALUES(?", zTable);
+ sqlite3_snprintf(nByte+20, zSql, "INSERT INTO %s VALUES(?", zFullTabName);
j = strlen30(zSql);
for(i=1; i<nCol; i++){
zSql[j++] = ',';
@@ -8537,14 +9060,13 @@ static int do_meta_command(char *zLine, ShellState *p){
utf8_printf(p->out, "Insert using: %s\n", zSql);
}
rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
- sqlite3_free(zSql);
if( rc ){
utf8_printf(stderr, "Error: %s\n", sqlite3_errmsg(p->db));
if (pStmt) sqlite3_finalize(pStmt);
- import_cleanup(&sCtx);
- rc = 1;
- goto meta_command_exit;
+ goto import_fail;
}
+ sqlite3_free(zSql);
+ sqlite3_free(zFullTabName);
needCommit = sqlite3_get_autocommit(p->db);
if( needCommit ) sqlite3_exec(p->db, "BEGIN", 0, 0, 0);
do{
@@ -8826,60 +9348,123 @@ static int do_meta_command(char *zLine, ShellState *p){
}else
if( c=='m' && strncmp(azArg[0], "mode", n)==0 ){
- const char *zMode = nArg>=2 ? azArg[1] : "";
- int n2 = strlen30(zMode);
- int c2 = zMode[0];
- if( c2=='l' && n2>2 && strncmp(azArg[1],"lines",n2)==0 ){
+ const char *zMode = 0;
+ const char *zTabname = 0;
+ int i, n2;
+ ColModeOpts cmOpts = ColModeOpts_default;
+ for(i=1; i<nArg; i++){
+ const char *z = azArg[i];
+ if( optionMatch(z,"wrap") && i+1<nArg ){
+ cmOpts.iWrap = integerValue(azArg[++i]);
+ }else if( optionMatch(z,"ww") ){
+ cmOpts.bWordWrap = 1;
+ }else if( optionMatch(z,"wordwrap") && i+1<nArg ){
+ cmOpts.bWordWrap = (u8)booleanValue(azArg[++i]);
+ }else if( optionMatch(z,"quote") ){
+ cmOpts.bQuote = 1;
+ }else if( optionMatch(z,"noquote") ){
+ cmOpts.bQuote = 0;
+ }else if( zMode==0 ){
+ zMode = z;
+ /* Apply defaults for qbox pseudo-mods. If that
+ * overwrites already-set values, user was informed of this.
+ */
+ if( strcmp(z, "qbox")==0 ){
+ ColModeOpts cmo = ColModeOpts_default_qbox;
+ zMode = "box";
+ cmOpts = cmo;
+ }
+ }else if( zTabname==0 ){
+ zTabname = z;
+ }else if( z[0]=='-' ){
+ utf8_printf(stderr, "unknown option: %s\n", z);
+ utf8_printf(stderr, "options:\n"
+ " --noquote\n"
+ " --quote\n"
+ " --wordwrap on/off\n"
+ " --wrap N\n"
+ " --ww\n");
+ rc = 1;
+ goto meta_command_exit;
+ }else{
+ utf8_printf(stderr, "extra argument: \"%s\"\n", z);
+ rc = 1;
+ goto meta_command_exit;
+ }
+ }
+ if( zMode==0 ){
+ if( p->mode==MODE_Column
+ || (p->mode>=MODE_Markdown && p->mode<=MODE_Box)
+ ){
+ raw_printf
+ (p->out,
+ "current output mode: %s --wrap %d --wordwrap %s --%squote\n",
+ modeDescr[p->mode], p->cmOpts.iWrap,
+ p->cmOpts.bWordWrap ? "on" : "off",
+ p->cmOpts.bQuote ? "" : "no");
+ }else{
+ raw_printf(p->out, "current output mode: %s\n", modeDescr[p->mode]);
+ }
+ zMode = modeDescr[p->mode];
+ }
+ n2 = strlen30(zMode);
+ if( strncmp(zMode,"lines",n2)==0 ){
p->mode = MODE_Line;
sqlite3_snprintf(sizeof(p->rowSeparator), p->rowSeparator, SEP_Row);
- }else if( c2=='c' && strncmp(azArg[1],"columns",n2)==0 ){
+ }else if( strncmp(zMode,"columns",n2)==0 ){
p->mode = MODE_Column;
if( (p->shellFlgs & SHFLG_HeaderSet)==0 ){
p->showHeader = 1;
}
sqlite3_snprintf(sizeof(p->rowSeparator), p->rowSeparator, SEP_Row);
- }else if( c2=='l' && n2>2 && strncmp(azArg[1],"list",n2)==0 ){
+ p->cmOpts = cmOpts;
+ }else if( strncmp(zMode,"list",n2)==0 ){
p->mode = MODE_List;
sqlite3_snprintf(sizeof(p->colSeparator), p->colSeparator, SEP_Column);
sqlite3_snprintf(sizeof(p->rowSeparator), p->rowSeparator, SEP_Row);
- }else if( c2=='h' && strncmp(azArg[1],"html",n2)==0 ){
+ }else if( strncmp(zMode,"html",n2)==0 ){
p->mode = MODE_Html;
- }else if( c2=='t' && strncmp(azArg[1],"tcl",n2)==0 ){
+ }else if( strncmp(zMode,"tcl",n2)==0 ){
p->mode = MODE_Tcl;
sqlite3_snprintf(sizeof(p->colSeparator), p->colSeparator, SEP_Space);
sqlite3_snprintf(sizeof(p->rowSeparator), p->rowSeparator, SEP_Row);
- }else if( c2=='c' && strncmp(azArg[1],"csv",n2)==0 ){
+ }else if( strncmp(zMode,"csv",n2)==0 ){
p->mode = MODE_Csv;
sqlite3_snprintf(sizeof(p->colSeparator), p->colSeparator, SEP_Comma);
sqlite3_snprintf(sizeof(p->rowSeparator), p->rowSeparator, SEP_CrLf);
- }else if( c2=='t' && strncmp(azArg[1],"tabs",n2)==0 ){
+ }else if( strncmp(zMode,"tabs",n2)==0 ){
p->mode = MODE_List;
sqlite3_snprintf(sizeof(p->colSeparator), p->colSeparator, SEP_Tab);
- }else if( c2=='i' && strncmp(azArg[1],"insert",n2)==0 ){
+ }else if( strncmp(zMode,"insert",n2)==0 ){
p->mode = MODE_Insert;
- set_table_name(p, nArg>=3 ? azArg[2] : "table");
- }else if( c2=='q' && strncmp(azArg[1],"quote",n2)==0 ){
+ set_table_name(p, zTabname ? zTabname : "table");
+ }else if( strncmp(zMode,"quote",n2)==0 ){
p->mode = MODE_Quote;
sqlite3_snprintf(sizeof(p->colSeparator), p->colSeparator, SEP_Comma);
sqlite3_snprintf(sizeof(p->rowSeparator), p->rowSeparator, SEP_Row);
- }else if( c2=='a' && strncmp(azArg[1],"ascii",n2)==0 ){
+ }else if( strncmp(zMode,"ascii",n2)==0 ){
p->mode = MODE_Ascii;
sqlite3_snprintf(sizeof(p->colSeparator), p->colSeparator, SEP_Unit);
sqlite3_snprintf(sizeof(p->rowSeparator), p->rowSeparator, SEP_Record);
- }else if( c2=='m' && strncmp(azArg[1],"markdown",n2)==0 ){
+ }else if( strncmp(zMode,"markdown",n2)==0 ){
p->mode = MODE_Markdown;
- }else if( c2=='t' && strncmp(azArg[1],"table",n2)==0 ){
+ p->cmOpts = cmOpts;
+ }else if( strncmp(zMode,"table",n2)==0 ){
p->mode = MODE_Table;
- }else if( c2=='b' && strncmp(azArg[1],"box",n2)==0 ){
+ p->cmOpts = cmOpts;
+ }else if( strncmp(zMode,"box",n2)==0 ){
p->mode = MODE_Box;
- }else if( c2=='j' && strncmp(azArg[1],"json",n2)==0 ){
+ p->cmOpts = cmOpts;
+ }else if( strncmp(zMode,"count",n2)==0 ){
+ p->mode = MODE_Count;
+ }else if( strncmp(zMode,"off",n2)==0 ){
+ p->mode = MODE_Off;
+ }else if( strncmp(zMode,"json",n2)==0 ){
p->mode = MODE_Json;
- }else if( nArg==1 ){
- raw_printf(p->out, "current output mode: %s\n", modeDescr[p->mode]);
}else{
raw_printf(stderr, "Error: mode should be one of: "
"ascii box column csv html insert json line list markdown "
- "quote table tabs tcl\n");
+ "qbox quote table tabs tcl\n");
rc = 1;
}
p->cMode = p->mode;
@@ -8890,7 +9475,8 @@ static int do_meta_command(char *zLine, ShellState *p){
raw_printf(stderr, "Usage: .nonce NONCE\n");
rc = 1;
}else if( p->zNonce==0 || strcmp(azArg[1],p->zNonce)!=0 ){
- raw_printf(stderr, "line %d: incorrect nonce: \"%s\"\n", p->lineno, azArg[1]);
+ raw_printf(stderr, "line %d: incorrect nonce: \"%s\"\n",
+ p->lineno, azArg[1]);
exit(1);
}else{
p->bSafeMode = 0;
@@ -8909,35 +9495,8 @@ static int do_meta_command(char *zLine, ShellState *p){
}
}else
-#ifdef SQLITE_DEBUG
- if( c=='o' && strcmp(azArg[0],"oom")==0 ){
- int i;
- for(i=1; i<nArg; i++){
- const char *z = azArg[i];
- if( z[0]=='-' && z[1]=='-' ) z++;
- if( strcmp(z,"-repeat")==0 ){
- if( i==nArg-1 ){
- raw_printf(p->out, "missing argument on \"%s\"\n", azArg[i]);
- rc = 1;
- }else{
- oomRepeat = (int)integerValue(azArg[++i]);
- }
- }else if( IsDigit(z[0]) ){
- oomCounter = (int)integerValue(azArg[i]);
- }else{
- raw_printf(p->out, "unknown argument: \"%s\"\n", azArg[i]);
- raw_printf(p->out, "Usage: .oom [--repeat N] [M]\n");
- rc = 1;
- }
- }
- if( rc==0 ){
- raw_printf(p->out, "oomCounter = %d\n", oomCounter);
- raw_printf(p->out, "oomRepeat = %d\n", oomRepeat);
- }
- }else
-#endif /* SQLITE_DEBUG */
-
if( c=='o' && strncmp(azArg[0], "open", n)==0 && n>=2 ){
+ const char *zFN = 0; /* Pointer to constant filename */
char *zNewFilename = 0; /* Name of the database file to open */
int iName = 1; /* Index in azArg[] of the filename */
int newFlag = 0; /* True to delete file before opening */
@@ -8970,12 +9529,12 @@ static int do_meta_command(char *zLine, ShellState *p){
utf8_printf(stderr, "unknown option: %s\n", z);
rc = 1;
goto meta_command_exit;
- }else if( zNewFilename ){
+ }else if( zFN ){
utf8_printf(stderr, "extra argument: \"%s\"\n", z);
rc = 1;
goto meta_command_exit;
}else{
- zNewFilename = sqlite3_mprintf("%s", z);
+ zFN = z;
}
}
@@ -8991,15 +9550,21 @@ static int do_meta_command(char *zLine, ShellState *p){
p->szMax = 0;
/* If a filename is specified, try to open it first */
- if( zNewFilename || p->openMode==SHELL_OPEN_HEXDB ){
- if( newFlag && !p->bSafeMode ) shellDeleteFile(zNewFilename);
+ if( zFN || p->openMode==SHELL_OPEN_HEXDB ){
+ if( newFlag && zFN && !p->bSafeMode ) shellDeleteFile(zFN);
if( p->bSafeMode
&& p->openMode!=SHELL_OPEN_HEXDB
- && zNewFilename
- && strcmp(zNewFilename,":memory:")!=0
+ && zFN
+ && strcmp(zFN,":memory:")!=0
){
failIfSafeMode(p, "cannot open disk-based database files in safe mode");
}
+ if( zFN ){
+ zNewFilename = sqlite3_mprintf("%s", zFN);
+ shell_check_oom(zNewFilename);
+ }else{
+ zNewFilename = 0;
+ }
p->pAuxDb->zDbFilename = zNewFilename;
open_db(p, OPEN_DB_KEEPALIVE);
if( p->db==0 ){
@@ -9053,7 +9618,7 @@ static int do_meta_command(char *zLine, ShellState *p){
}
}else if( zFile==0 && eMode!='e' && eMode!='x' ){
zFile = sqlite3_mprintf("%s", z);
- if( zFile[0]=='|' ){
+ if( zFile && zFile[0]=='|' ){
while( i+1<nArg ) zFile = sqlite3_mprintf("%z %s", zFile, azArg[++i]);
break;
}
@@ -9066,7 +9631,9 @@ static int do_meta_command(char *zLine, ShellState *p){
goto meta_command_exit;
}
}
- if( zFile==0 ) zFile = sqlite3_mprintf("stdout");
+ if( zFile==0 ){
+ zFile = sqlite3_mprintf("stdout");
+ }
if( bOnce ){
p->outCount = 2;
}else{
@@ -9093,6 +9660,7 @@ static int do_meta_command(char *zLine, ShellState *p){
zFile = sqlite3_mprintf("%s", p->zTempFile);
}
#endif /* SQLITE_NOHAVE_SYSTEM */
+ shell_check_oom(zFile);
if( zFile[0]=='|' ){
#ifdef SQLITE_OMIT_POPEN
raw_printf(stderr, "Error: pipes are not supported in this OS\n");
@@ -9189,7 +9757,7 @@ static int do_meta_command(char *zLine, ShellState *p){
zSql = sqlite3_mprintf(
"REPLACE INTO temp.sqlite_parameters(key,value)"
"VALUES(%Q,%s);", zKey, zValue);
- if( zSql==0 ) shell_out_of_memory();
+ shell_check_oom(zSql);
pStmt = 0;
rx = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
sqlite3_free(zSql);
@@ -9199,7 +9767,7 @@ static int do_meta_command(char *zLine, ShellState *p){
zSql = sqlite3_mprintf(
"REPLACE INTO temp.sqlite_parameters(key,value)"
"VALUES(%Q,%Q);", zKey, zValue);
- if( zSql==0 ) shell_out_of_memory();
+ shell_check_oom(zSql);
rx = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
sqlite3_free(zSql);
if( rx!=SQLITE_OK ){
@@ -9220,7 +9788,7 @@ static int do_meta_command(char *zLine, ShellState *p){
if( nArg==3 && strcmp(azArg[1],"unset")==0 ){
char *zSql = sqlite3_mprintf(
"DELETE FROM temp.sqlite_parameters WHERE key=%Q", azArg[2]);
- if( zSql==0 ) shell_out_of_memory();
+ shell_check_oom(zSql);
sqlite3_exec(p->db, zSql, 0, 0, 0);
sqlite3_free(zSql);
}else
@@ -9446,6 +10014,7 @@ static int do_meta_command(char *zLine, ShellState *p){
" rootpage integer,\n"
" sql text\n"
")", zName);
+ shell_check_oom(new_argv[0]);
new_argv[1] = 0;
new_colv[0] = "sql";
new_colv[1] = 0;
@@ -9497,8 +10066,10 @@ static int do_meta_command(char *zLine, ShellState *p){
appendText(&sSelect, ") WHERE ", 0);
if( zName ){
char *zQarg = sqlite3_mprintf("%Q", zName);
- int bGlob = strchr(zName, '*') != 0 || strchr(zName, '?') != 0 ||
- strchr(zName, '[') != 0;
+ int bGlob;
+ shell_check_oom(zQarg);
+ bGlob = strchr(zName, '*') != 0 || strchr(zName, '?') != 0 ||
+ strchr(zName, '[') != 0;
if( strchr(zName, '.') ){
appendText(&sSelect, "lower(printf('%s.%s',sname,tbl_name))", 0);
}else{
@@ -9661,7 +10232,8 @@ static int do_meta_command(char *zLine, ShellState *p){
exit(1);
}
for(ii=1; ii<nCmd; ii++){
- pSession->azFilter[ii-1] = sqlite3_mprintf("%s", azCmd[ii]);
+ char *x = pSession->azFilter[ii-1] = sqlite3_mprintf("%s", azCmd[ii]);
+ shell_check_oom(x);
}
pSession->nFilter = ii-1;
}
@@ -9733,6 +10305,7 @@ static int do_meta_command(char *zLine, ShellState *p){
sqlite3session_table_filter(pSession->p, session_filter, pSession);
pAuxDb->nSession++;
pSession->zName = sqlite3_mprintf("%s", zName);
+ shell_check_oom(pSession->zName);
}else
/* If no command name matches, show a syntax error */
session_syntax_error:
@@ -9826,11 +10399,12 @@ static int do_meta_command(char *zLine, ShellState *p){
const char *zSql = (const char*)sqlite3_column_text(pStmt, 2);
const char *zAns = (const char*)sqlite3_column_text(pStmt, 3);
+ if( zOp==0 ) continue;
+ if( zSql==0 ) continue;
+ if( zAns==0 ) continue;
k = 0;
if( bVerbose>0 ){
- char *zQuote = sqlite3_mprintf("%q", zSql);
printf("%d: %s %s\n", tno, zOp, zSql);
- sqlite3_free(zQuote);
}
if( strcmp(zOp,"memo")==0 ){
utf8_printf(p->out, "%s\n", zSql);
@@ -9948,6 +10522,7 @@ static int do_meta_command(char *zLine, ShellState *p){
zSep = "VALUES(";
while( SQLITE_ROW==sqlite3_step(pStmt) ){
const char *zTab = (const char*)sqlite3_column_text(pStmt,0);
+ if( zTab==0 ) continue;
if( zLike && sqlite3_strlike(zLike, zTab, 0)!=0 ) continue;
if( strncmp(zTab, "sqlite_",7)!=0 ){
appendText(&sQuery,"SELECT * FROM ", 0);
@@ -9988,6 +10563,7 @@ static int do_meta_command(char *zLine, ShellState *p){
" FROM [sha3sum$query]",
sSql.z, iSize);
}
+ shell_check_oom(zSql);
freeText(&sQuery);
freeText(&sSql);
if( bDebug ){
@@ -10011,11 +10587,11 @@ static int do_meta_command(char *zLine, ShellState *p){
goto meta_command_exit;
}
zCmd = sqlite3_mprintf(strchr(azArg[1],' ')==0?"%s":"\"%s\"", azArg[1]);
- for(i=2; i<nArg; i++){
+ for(i=2; i<nArg && zCmd!=0; i++){
zCmd = sqlite3_mprintf(strchr(azArg[i],' ')==0?"%z %s":"%z \"%s\"",
zCmd, azArg[i]);
}
- x = system(zCmd);
+ x = zCmd!=0 ? system(zCmd) : 1;
sqlite3_free(zCmd);
if( x ) raw_printf(stderr, "System command returns %d\n", x);
}else
@@ -10036,7 +10612,17 @@ static int do_meta_command(char *zLine, ShellState *p){
utf8_printf(p->out, "%12.12s: %s\n","explain",
p->mode==MODE_Explain ? "on" : p->autoExplain ? "auto" : "off");
utf8_printf(p->out,"%12.12s: %s\n","headers", azBool[p->showHeader!=0]);
- utf8_printf(p->out, "%12.12s: %s\n","mode", modeDescr[p->mode]);
+ if( p->mode==MODE_Column
+ || (p->mode>=MODE_Markdown && p->mode<=MODE_Box)
+ ){
+ utf8_printf
+ (p->out, "%12.12s: %s --wrap %d --wordwrap %s --%squote\n", "mode",
+ modeDescr[p->mode], p->cmOpts.iWrap,
+ p->cmOpts.bWordWrap ? "on" : "off",
+ p->cmOpts.bQuote ? "" : "no");
+ }else{
+ utf8_printf(p->out, "%12.12s: %s\n","mode", modeDescr[p->mode]);
+ }
utf8_printf(p->out, "%12.12s: ", "nullvalue");
output_c_string(p->out, p->nullValue);
raw_printf(p->out, "\n");
@@ -10151,12 +10737,12 @@ static int do_meta_command(char *zLine, ShellState *p){
char **azNew;
int n2 = nAlloc*2 + 10;
azNew = sqlite3_realloc64(azResult, sizeof(azResult[0])*n2);
- if( azNew==0 ) shell_out_of_memory();
+ shell_check_oom(azNew);
nAlloc = n2;
azResult = azNew;
}
azResult[nRow] = sqlite3_mprintf("%s", sqlite3_column_text(pStmt, 0));
- if( 0==azResult[nRow] ) shell_out_of_memory();
+ shell_check_oom(azResult[nRow]);
nRow++;
}
if( sqlite3_finalize(pStmt)!=SQLITE_OK ){
@@ -10834,19 +11420,30 @@ static int runOneSqlLine(ShellState *p, char *zSql, FILE *in, int startline){
END_TIMER;
if( rc || zErrMsg ){
char zPrefix[100];
- if( in!=0 || !stdin_is_interactive ){
- sqlite3_snprintf(sizeof(zPrefix), zPrefix,
- "Error: near line %d:", startline);
+ const char *zErrorTail;
+ const char *zErrorType;
+ if( zErrMsg==0 ){
+ zErrorType = "Error";
+ zErrorTail = sqlite3_errmsg(p->db);
+ }else if( strncmp(zErrMsg, "in prepare, ",12)==0 ){
+ zErrorType = "Parse error";
+ zErrorTail = &zErrMsg[12];
+ }else if( strncmp(zErrMsg, "stepping, ", 10)==0 ){
+ zErrorType = "Runtime error";
+ zErrorTail = &zErrMsg[10];
}else{
- sqlite3_snprintf(sizeof(zPrefix), zPrefix, "Error:");
+ zErrorType = "Error";
+ zErrorTail = zErrMsg;
}
- if( zErrMsg!=0 ){
- utf8_printf(stderr, "%s %s\n", zPrefix, zErrMsg);
- sqlite3_free(zErrMsg);
- zErrMsg = 0;
+ if( in!=0 || !stdin_is_interactive ){
+ sqlite3_snprintf(sizeof(zPrefix), zPrefix,
+ "%s near line %d:", zErrorType, startline);
}else{
- utf8_printf(stderr, "%s %s\n", zPrefix, sqlite3_errmsg(p->db));
+ sqlite3_snprintf(sizeof(zPrefix), zPrefix, "%s:", zErrorType);
}
+ utf8_printf(stderr, "%s %s\n", zPrefix, zErrorTail);
+ sqlite3_free(zErrMsg);
+ zErrMsg = 0;
return 1;
}else if( ShellHasFlag(p, SHFLG_CountChanges) ){
char zLineBuf[2000];
@@ -10879,6 +11476,13 @@ static int process_input(ShellState *p){
int startline = 0; /* Line number for start of current input */
QuickScanState qss = QSS_Start; /* Accumulated line status (so far) */
+ if( p->inputNesting==MAX_INPUT_NESTING ){
+ /* This will be more informative in a later version. */
+ utf8_printf(stderr,"Input nesting limit (%d) reached at line %d."
+ " Check recursion.\n", MAX_INPUT_NESTING, p->lineno);
+ return 1;
+ }
+ ++p->inputNesting;
p->lineno = 0;
while( errCnt==0 || !bail_on_error || (p->in==0 && stdin_is_interactive) ){
fflush(p->out);
@@ -10925,7 +11529,7 @@ static int process_input(ShellState *p){
/* Grow buffer by half-again increments when big. */
nAlloc = nSql+(nSql>>1)+nLine+100;
zSql = realloc(zSql, nAlloc);
- if( zSql==0 ) shell_out_of_memory();
+ shell_check_oom(zSql);
}
if( nSql==0 ){
int i;
@@ -10961,6 +11565,7 @@ static int process_input(ShellState *p){
}
free(zSql);
free(zLine);
+ --p->inputNesting;
return errCnt>0;
}
@@ -11057,6 +11662,7 @@ static void process_sqliterc(
return;
}
zBuf = sqlite3_mprintf("%s/.sqliterc",home_dir);
+ shell_check_oom(zBuf);
sqliterc = zBuf;
}
p->in = fopen(sqliterc,"rb");
@@ -11255,10 +11861,6 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){
stdin_is_interactive = isatty(0);
stdout_is_console = isatty(1);
-#ifdef SQLITE_DEBUG
- registerOomSimulator();
-#endif
-
#if !defined(_WIN32_WCE)
if( getenv("SQLITE_DEBUG_BREAK") ){
if( isatty(0) && isatty(2) ){
@@ -11298,16 +11900,16 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){
#if !SQLITE_SHELL_IS_UTF8
sqlite3_initialize();
argvToFree = malloc(sizeof(argv[0])*argc*2);
+ shell_check_oom(argvToFree);
argcToFree = argc;
argv = argvToFree + argc;
- if( argv==0 ) shell_out_of_memory();
for(i=0; i<argc; i++){
char *z = sqlite3_win32_unicode_to_utf8(wargv[i]);
int n;
- if( z==0 ) shell_out_of_memory();
+ shell_check_oom(z);
n = (int)strlen(z);
argv[i] = malloc( n+1 );
- if( argv[i]==0 ) shell_out_of_memory();
+ shell_check_oom(argv[i]);
memcpy(argv[i], z, n+1);
argvToFree[i] = argv[i];
sqlite3_free(z);
@@ -11357,7 +11959,7 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){
readStdin = 0;
nCmd++;
azCmd = realloc(azCmd, sizeof(azCmd[0])*nCmd);
- if( azCmd==0 ) shell_out_of_memory();
+ shell_check_oom(azCmd);
azCmd[nCmd-1] = z;
}
}
diff --git a/chromium/third_party/sqlite/src/src/sqlite.h.in b/chromium/third_party/sqlite/src/src/sqlite.h.in
index 98a028b0b07..6062f79c227 100644
--- a/chromium/third_party/sqlite/src/src/sqlite.h.in
+++ b/chromium/third_party/sqlite/src/src/sqlite.h.in
@@ -566,7 +566,7 @@ int sqlite3_exec(
#define SQLITE_WARNING_AUTOINDEX (SQLITE_WARNING | (1<<8))
#define SQLITE_AUTH_USER (SQLITE_AUTH | (1<<8))
#define SQLITE_OK_LOAD_PERMANENTLY (SQLITE_OK | (1<<8))
-#define SQLITE_OK_SYMLINK (SQLITE_OK | (2<<8))
+#define SQLITE_OK_SYMLINK (SQLITE_OK | (2<<8)) /* internal use only */
/*
** CAPI3REF: Flags For File Open Operations
@@ -3824,13 +3824,14 @@ void sqlite3_free_filename(char*);
** sqlite3_extended_errcode() might change with each API call.
** Except, there are some interfaces that are guaranteed to never
** change the value of the error code. The error-code preserving
-** interfaces are:
+** interfaces include the following:
**
** <ul>
** <li> sqlite3_errcode()
** <li> sqlite3_extended_errcode()
** <li> sqlite3_errmsg()
** <li> sqlite3_errmsg16()
+** <li> sqlite3_error_offset()
** </ul>
**
** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language
@@ -3845,6 +3846,13 @@ void sqlite3_free_filename(char*);
** ^(Memory to hold the error message string is managed internally
** and must not be freed by the application)^.
**
+** ^If the most recent error references a specific token in the input
+** SQL, the sqlite3_error_offset() interface returns the byte offset
+** of the start of that token. ^The byte offset returned by
+** sqlite3_error_offset() assumes that the input SQL is UTF8.
+** ^If the most recent error does not reference a specific token in the input
+** SQL, then the sqlite3_error_offset() function returns -1.
+**
** When the serialized [threading mode] is in use, it might be the
** case that a second error occurs on a separate thread in between
** the time of the first error and the call to these interfaces.
@@ -3864,6 +3872,7 @@ int sqlite3_extended_errcode(sqlite3 *db);
const char *sqlite3_errmsg(sqlite3*);
const void *sqlite3_errmsg16(sqlite3*);
const char *sqlite3_errstr(int);
+int sqlite3_error_offset(sqlite3 *db);
/*
** CAPI3REF: Prepared Statement Object
@@ -4275,6 +4284,10 @@ const char *sqlite3_normalized_sql(sqlite3_stmt *pStmt);
** be false. ^Similarly, a CREATE TABLE IF NOT EXISTS statement is a
** read-only no-op if the table already exists, but
** sqlite3_stmt_readonly() still returns false for such a statement.
+**
+** ^If prepared statement X is an [EXPLAIN] or [EXPLAIN QUERY PLAN]
+** statement, then sqlite3_stmt_readonly(X) returns the same value as
+** if the EXPLAIN or EXPLAIN QUERY PLAN prefix were omitted.
*/
int sqlite3_stmt_readonly(sqlite3_stmt *pStmt);
@@ -4343,6 +4356,8 @@ int sqlite3_stmt_busy(sqlite3_stmt*);
**
** ^The sqlite3_value objects that are passed as parameters into the
** implementation of [application-defined SQL functions] are protected.
+** ^The sqlite3_value objects returned by [sqlite3_vtab_rhs_value()]
+** are protected.
** ^The sqlite3_value object returned by
** [sqlite3_column_value()] is unprotected.
** Unprotected sqlite3_value objects may only be used as arguments
@@ -4964,6 +4979,10 @@ int sqlite3_data_count(sqlite3_stmt *pStmt);
** even empty strings, are always zero-terminated. ^The return
** value from sqlite3_column_blob() for a zero-length BLOB is a NULL pointer.
**
+** ^Strings returned by sqlite3_column_text16() always have the endianness
+** which is native to the platform, regardless of the text encoding set
+** for the database.
+**
** <b>Warning:</b> ^The object returned by [sqlite3_column_value()] is an
** [unprotected sqlite3_value] object. In a multithreaded environment,
** an unprotected sqlite3_value object may only be used safely with
@@ -4977,7 +4996,7 @@ int sqlite3_data_count(sqlite3_stmt *pStmt);
** [application-defined SQL functions] or [virtual tables], not within
** top-level application code.
**
-** The these routines may attempt to convert the datatype of the result.
+** These routines may attempt to convert the datatype of the result.
** ^For example, if the internal representation is FLOAT and a text result
** is requested, [sqlite3_snprintf()] is used internally to perform the
** conversion automatically. ^(The following table details the conversions
@@ -5002,7 +5021,7 @@ int sqlite3_data_count(sqlite3_stmt *pStmt);
** <tr><td> TEXT <td> BLOB <td> No change
** <tr><td> BLOB <td> INTEGER <td> [CAST] to INTEGER
** <tr><td> BLOB <td> FLOAT <td> [CAST] to REAL
-** <tr><td> BLOB <td> TEXT <td> Add a zero terminator if needed
+** <tr><td> BLOB <td> TEXT <td> [CAST] to TEXT, ensure zero terminator
** </table>
** </blockquote>)^
**
@@ -7122,24 +7141,56 @@ struct sqlite3_index_info {
**
** These macros define the allowed values for the
** [sqlite3_index_info].aConstraint[].op field. Each value represents
-** an operator that is part of a constraint term in the wHERE clause of
+** an operator that is part of a constraint term in the WHERE clause of
** a query that uses a [virtual table].
-*/
-#define SQLITE_INDEX_CONSTRAINT_EQ 2
-#define SQLITE_INDEX_CONSTRAINT_GT 4
-#define SQLITE_INDEX_CONSTRAINT_LE 8
-#define SQLITE_INDEX_CONSTRAINT_LT 16
-#define SQLITE_INDEX_CONSTRAINT_GE 32
-#define SQLITE_INDEX_CONSTRAINT_MATCH 64
-#define SQLITE_INDEX_CONSTRAINT_LIKE 65
-#define SQLITE_INDEX_CONSTRAINT_GLOB 66
-#define SQLITE_INDEX_CONSTRAINT_REGEXP 67
-#define SQLITE_INDEX_CONSTRAINT_NE 68
-#define SQLITE_INDEX_CONSTRAINT_ISNOT 69
-#define SQLITE_INDEX_CONSTRAINT_ISNOTNULL 70
-#define SQLITE_INDEX_CONSTRAINT_ISNULL 71
-#define SQLITE_INDEX_CONSTRAINT_IS 72
-#define SQLITE_INDEX_CONSTRAINT_FUNCTION 150
+**
+** ^The left-hand operand of the operator is given by the corresponding
+** aConstraint[].iColumn field. ^An iColumn of -1 indicates the left-hand
+** operand is the rowid.
+** The SQLITE_INDEX_CONSTRAINT_LIMIT and SQLITE_INDEX_CONSTRAINT_OFFSET
+** operators have no left-hand operand, and so for those operators the
+** corresponding aConstraint[].iColumn is meaningless and should not be
+** used.
+**
+** All operator values from SQLITE_INDEX_CONSTRAINT_FUNCTION through
+** value 255 are reserved to represent functions that are overloaded
+** by the [xFindFunction|xFindFunction method] of the virtual table
+** implementation.
+**
+** The right-hand operands for each constraint might be accessible using
+** the [sqlite3_vtab_rhs_value()] interface. Usually the right-hand
+** operand is only available if it appears as a single constant literal
+** in the input SQL. If the right-hand operand is another column or an
+** expression (even a constant expression) or a parameter, then the
+** sqlite3_vtab_rhs_value() probably will not be able to extract it.
+** ^The SQLITE_INDEX_CONSTRAINT_ISNULL and
+** SQLITE_INDEX_CONSTRAINT_ISNOTNULL operators have no right-hand operand
+** and hence calls to sqlite3_vtab_rhs_value() for those operators will
+** always return SQLITE_NOTFOUND.
+**
+** The collating sequence to be used for comparison can be found using
+** the [sqlite3_vtab_collation()] interface. For most real-world virtual
+** tables, the collating sequence of constraints does not matter (for example
+** because the constraints are numeric) and so the sqlite3_vtab_collation()
+** interface is no commonly needed.
+*/
+#define SQLITE_INDEX_CONSTRAINT_EQ 2
+#define SQLITE_INDEX_CONSTRAINT_GT 4
+#define SQLITE_INDEX_CONSTRAINT_LE 8
+#define SQLITE_INDEX_CONSTRAINT_LT 16
+#define SQLITE_INDEX_CONSTRAINT_GE 32
+#define SQLITE_INDEX_CONSTRAINT_MATCH 64
+#define SQLITE_INDEX_CONSTRAINT_LIKE 65
+#define SQLITE_INDEX_CONSTRAINT_GLOB 66
+#define SQLITE_INDEX_CONSTRAINT_REGEXP 67
+#define SQLITE_INDEX_CONSTRAINT_NE 68
+#define SQLITE_INDEX_CONSTRAINT_ISNOT 69
+#define SQLITE_INDEX_CONSTRAINT_ISNOTNULL 70
+#define SQLITE_INDEX_CONSTRAINT_ISNULL 71
+#define SQLITE_INDEX_CONSTRAINT_IS 72
+#define SQLITE_INDEX_CONSTRAINT_LIMIT 73
+#define SQLITE_INDEX_CONSTRAINT_OFFSET 74
+#define SQLITE_INDEX_CONSTRAINT_FUNCTION 150
/*
** CAPI3REF: Register A Virtual Table Implementation
@@ -7168,7 +7219,7 @@ struct sqlite3_index_info {
** destructor.
**
** ^If the third parameter (the pointer to the sqlite3_module object) is
-** NULL then no new module is create and any existing modules with the
+** NULL then no new module is created and any existing modules with the
** same name are dropped.
**
** See also: [sqlite3_drop_modules()]
@@ -7944,7 +7995,8 @@ int sqlite3_test_control(int op, ...);
#define SQLITE_TESTCTRL_SEEK_COUNT 30
#define SQLITE_TESTCTRL_TRACEFLAGS 31
#define SQLITE_TESTCTRL_TUNE 32
-#define SQLITE_TESTCTRL_LAST 32 /* Largest TESTCTRL */
+#define SQLITE_TESTCTRL_LOGEST 33
+#define SQLITE_TESTCTRL_LAST 33 /* Largest TESTCTRL */
/*
** CAPI3REF: SQL Keyword Checking
@@ -8467,6 +8519,16 @@ int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);
** The counter is incremented on the first [sqlite3_step()] call of each
** cycle.
**
+** [[SQLITE_STMTSTATUS_FILTER_MISS]]
+** [[SQLITE_STMTSTATUS_FILTER HIT]]
+** <dt>SQLITE_STMTSTATUS_FILTER_HIT<br>
+** SQLITE_STMTSTATUS_FILTER_MISS</dt>
+** <dd>^SQLITE_STMTSTATUS_FILTER_HIT is the number of times that a join
+** step was bypassed because a Bloom filter returned not-found. The
+** corresponding SQLITE_STMTSTATUS_FILTER_MISS value is the number of
+** times that the Bloom filter returned a find, and thus the join step
+** had to be processed as normal.
+**
** [[SQLITE_STMTSTATUS_MEMUSED]] <dt>SQLITE_STMTSTATUS_MEMUSED</dt>
** <dd>^This is the approximate number of bytes of heap memory
** used to store the prepared statement. ^This value is not actually
@@ -8481,6 +8543,8 @@ int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);
#define SQLITE_STMTSTATUS_VM_STEP 4
#define SQLITE_STMTSTATUS_REPREPARE 5
#define SQLITE_STMTSTATUS_RUN 6
+#define SQLITE_STMTSTATUS_FILTER_MISS 7
+#define SQLITE_STMTSTATUS_FILTER_HIT 8
#define SQLITE_STMTSTATUS_MEMUSED 99
/*
@@ -9449,20 +9513,270 @@ int sqlite3_vtab_nochange(sqlite3_context*);
/*
** CAPI3REF: Determine The Collation For a Virtual Table Constraint
+** METHOD: sqlite3_index_info
**
** This function may only be called from within a call to the [xBestIndex]
-** method of a [virtual table].
+** method of a [virtual table]. This function returns a pointer to a string
+** that is the name of the appropriate collation sequence to use for text
+** comparisons on the constraint identified by its arguments.
+**
+** The first argument must be the pointer to the [sqlite3_index_info] object
+** that is the first parameter to the xBestIndex() method. The second argument
+** must be an index into the aConstraint[] array belonging to the
+** sqlite3_index_info structure passed to xBestIndex.
+**
+** Important:
+** The first parameter must be the same pointer that is passed into the
+** xBestMethod() method. The first parameter may not be a pointer to a
+** different [sqlite3_index_info] object, even an exact copy.
+**
+** The return value is computed as follows:
**
-** The first argument must be the sqlite3_index_info object that is the
-** first parameter to the xBestIndex() method. The second argument must be
-** an index into the aConstraint[] array belonging to the sqlite3_index_info
-** structure passed to xBestIndex. This function returns a pointer to a buffer
-** containing the name of the collation sequence for the corresponding
-** constraint.
+** <ol>
+** <li><p> If the constraint comes from a WHERE clause expression that contains
+** a [COLLATE operator], then the name of the collation specified by
+** that COLLATE operator is returned.
+** <li><p> If there is no COLLATE operator, but the column that is the subject
+** of the constraint specifies an alternative collating sequence via
+** a [COLLATE clause] on the column definition within the CREATE TABLE
+** statement that was passed into [sqlite3_declare_vtab()], then the
+** name of that alternative collating sequence is returned.
+** <li><p> Otherwise, "BINARY" is returned.
+** </ol>
*/
SQLITE_EXPERIMENTAL const char *sqlite3_vtab_collation(sqlite3_index_info*,int);
/*
+** CAPI3REF: Determine if a virtual table query is DISTINCT
+** METHOD: sqlite3_index_info
+**
+** This API may only be used from within an [xBestIndex|xBestIndex method]
+** of a [virtual table] implementation. The result of calling this
+** interface from outside of xBestIndex() is undefined and probably harmful.
+**
+** ^The sqlite3_vtab_distinct() interface returns an integer that is
+** either 0, 1, or 2. The integer returned by sqlite3_vtab_distinct()
+** gives the virtual table additional information about how the query
+** planner wants the output to be ordered. As long as the virtual table
+** can meet the ordering requirements of the query planner, it may set
+** the "orderByConsumed" flag.
+**
+** <ol><li value="0"><p>
+** ^If the sqlite3_vtab_distinct() interface returns 0, that means
+** that the query planner needs the virtual table to return all rows in the
+** sort order defined by the "nOrderBy" and "aOrderBy" fields of the
+** [sqlite3_index_info] object. This is the default expectation. If the
+** virtual table outputs all rows in sorted order, then it is always safe for
+** the xBestIndex method to set the "orderByConsumed" flag, regardless of
+** the return value from sqlite3_vtab_distinct().
+** <li value="1"><p>
+** ^(If the sqlite3_vtab_distinct() interface returns 1, that means
+** that the query planner does not need the rows to be returned in sorted order
+** as long as all rows with the same values in all columns identified by the
+** "aOrderBy" field are adjacent.)^ This mode is used when the query planner
+** is doing a GROUP BY.
+** <li value="2"><p>
+** ^(If the sqlite3_vtab_distinct() interface returns 2, that means
+** that the query planner does not need the rows returned in any particular
+** order, as long as rows with the same values in all "aOrderBy" columns
+** are adjacent.)^ ^(Furthermore, only a single row for each particular
+** combination of values in the columns identified by the "aOrderBy" field
+** needs to be returned.)^ ^It is always ok for two or more rows with the same
+** values in all "aOrderBy" columns to be returned, as long as all such rows
+** are adjacent. ^The virtual table may, if it chooses, omit extra rows
+** that have the same value for all columns identified by "aOrderBy".
+** ^However omitting the extra rows is optional.
+** This mode is used for a DISTINCT query.
+** </ol>
+**
+** ^For the purposes of comparing virtual table output values to see if the
+** values are same value for sorting purposes, two NULL values are considered
+** to be the same. In other words, the comparison operator is "IS"
+** (or "IS NOT DISTINCT FROM") and not "==".
+**
+** If a virtual table implementation is unable to meet the requirements
+** specified above, then it must not set the "orderByConsumed" flag in the
+** [sqlite3_index_info] object or an incorrect answer may result.
+**
+** ^A virtual table implementation is always free to return rows in any order
+** it wants, as long as the "orderByConsumed" flag is not set. ^When the
+** the "orderByConsumed" flag is unset, the query planner will add extra
+** [bytecode] to ensure that the final results returned by the SQL query are
+** ordered correctly. The use of the "orderByConsumed" flag and the
+** sqlite3_vtab_distinct() interface is merely an optimization. ^Careful
+** use of the sqlite3_vtab_distinct() interface and the "orderByConsumed"
+** flag might help queries against a virtual table to run faster. Being
+** overly aggressive and setting the "orderByConsumed" flag when it is not
+** valid to do so, on the other hand, might cause SQLite to return incorrect
+** results.
+*/
+int sqlite3_vtab_distinct(sqlite3_index_info*);
+
+/*
+** CAPI3REF: Identify and handle IN constraints in xBestIndex
+**
+** This interface may only be used from within an
+** [xBestIndex|xBestIndex() method] of a [virtual table] implementation.
+** The result of invoking this interface from any other context is
+** undefined and probably harmful.
+**
+** ^(A constraint on a virtual table of the form
+** "[IN operator|column IN (...)]" is
+** communicated to the xBestIndex method as a
+** [SQLITE_INDEX_CONSTRAINT_EQ] constraint.)^ If xBestIndex wants to use
+** this constraint, it must set the corresponding
+** aConstraintUsage[].argvIndex to a postive integer. ^(Then, under
+** the usual mode of handling IN operators, SQLite generates [bytecode]
+** that invokes the [xFilter|xFilter() method] once for each value
+** on the right-hand side of the IN operator.)^ Thus the virtual table
+** only sees a single value from the right-hand side of the IN operator
+** at a time.
+**
+** In some cases, however, it would be advantageous for the virtual
+** table to see all values on the right-hand of the IN operator all at
+** once. The sqlite3_vtab_in() interfaces facilitates this in two ways:
+**
+** <ol>
+** <li><p>
+** ^A call to sqlite3_vtab_in(P,N,-1) will return true (non-zero)
+** if and only if the [sqlite3_index_info|P->aConstraint][N] constraint
+** is an [IN operator] that can be processed all at once. ^In other words,
+** sqlite3_vtab_in() with -1 in the third argument is a mechanism
+** by which the virtual table can ask SQLite if all-at-once processing
+** of the IN operator is even possible.
+**
+** <li><p>
+** ^A call to sqlite3_vtab_in(P,N,F) with F==1 or F==0 indicates
+** to SQLite that the virtual table does or does not want to process
+** the IN operator all-at-once, respectively. ^Thus when the third
+** parameter (F) is non-negative, this interface is the mechanism by
+** which the virtual table tells SQLite how it wants to process the
+** IN operator.
+** </ol>
+**
+** ^The sqlite3_vtab_in(P,N,F) interface can be invoked multiple times
+** within the same xBestIndex method call. ^For any given P,N pair,
+** the return value from sqlite3_vtab_in(P,N,F) will always be the same
+** within the same xBestIndex call. ^If the interface returns true
+** (non-zero), that means that the constraint is an IN operator
+** that can be processed all-at-once. ^If the constraint is not an IN
+** operator or cannot be processed all-at-once, then the interface returns
+** false.
+**
+** ^(All-at-once processing of the IN operator is selected if both of the
+** following conditions are met:
+**
+** <ol>
+** <li><p> The P->aConstraintUsage[N].argvIndex value is set to a positive
+** integer. This is how the virtual table tells SQLite that it wants to
+** use the N-th constraint.
+**
+** <li><p> The last call to sqlite3_vtab_in(P,N,F) for which F was
+** non-negative had F>=1.
+** </ol>)^
+**
+** ^If either or both of the conditions above are false, then SQLite uses
+** the traditional one-at-a-time processing strategy for the IN constraint.
+** ^If both conditions are true, then the argvIndex-th parameter to the
+** xFilter method will be an [sqlite3_value] that appears to be NULL,
+** but which can be passed to [sqlite3_vtab_in_first()] and
+** [sqlite3_vtab_in_next()] to find all values on the right-hand side
+** of the IN constraint.
+*/
+int sqlite3_vtab_in(sqlite3_index_info*, int iCons, int bHandle);
+
+/*
+** CAPI3REF: Find all elements on the right-hand side of an IN constraint.
+**
+** These interfaces are only useful from within the
+** [xFilter|xFilter() method] of a [virtual table] implementation.
+** The result of invoking these interfaces from any other context
+** is undefined and probably harmful.
+**
+** The X parameter in a call to sqlite3_vtab_in_first(X,P) or
+** sqlite3_vtab_in_next(X,P) must be one of the parameters to the
+** xFilter method which invokes these routines, and specifically
+** a parameter that was previously selected for all-at-once IN constraint
+** processing use the [sqlite3_vtab_in()] interface in the
+** [xBestIndex|xBestIndex method]. ^(If the X parameter is not
+** an xFilter argument that was selected for all-at-once IN constraint
+** processing, then these routines return [SQLITE_MISUSE])^ or perhaps
+** exhibit some other undefined or harmful behavior.
+**
+** ^(Use these routines to access all values on the right-hand side
+** of the IN constraint using code like the following:
+**
+** <blockquote><pre>
+** &nbsp; for(rc=sqlite3_vtab_in_first(pList, &pVal);
+** &nbsp; rc==SQLITE_OK && pVal
+** &nbsp; rc=sqlite3_vtab_in_next(pList, &pVal)
+** &nbsp; ){
+** &nbsp; // do something with pVal
+** &nbsp; }
+** &nbsp; if( rc!=SQLITE_OK ){
+** &nbsp; // an error has occurred
+** &nbsp; }
+** </pre></blockquote>)^
+**
+** ^On success, the sqlite3_vtab_in_first(X,P) and sqlite3_vtab_in_next(X,P)
+** routines return SQLITE_OK and set *P to point to the first or next value
+** on the RHS of the IN constraint. ^If there are no more values on the
+** right hand side of the IN constraint, then *P is set to NULL and these
+** routines return [SQLITE_DONE]. ^The return value might be
+** some other value, such as SQLITE_NOMEM, in the event of a malfunction.
+**
+** The *ppOut values returned by these routines are only valid until the
+** next call to either of these routines or until the end of the xFilter
+** method from which these routines were called. If the virtual table
+** implementation needs to retain the *ppOut values for longer, it must make
+** copies. The *ppOut values are [protected sqlite3_value|protected].
+*/
+int sqlite3_vtab_in_first(sqlite3_value *pVal, sqlite3_value **ppOut);
+int sqlite3_vtab_in_next(sqlite3_value *pVal, sqlite3_value **ppOut);
+
+/*
+** CAPI3REF: Constraint values in xBestIndex()
+** METHOD: sqlite3_index_info
+**
+** This API may only be used from within the [xBestIndex|xBestIndex method]
+** of a [virtual table] implementation. The result of calling this interface
+** from outside of an xBestIndex method are undefined and probably harmful.
+**
+** ^When the sqlite3_vtab_rhs_value(P,J,V) interface is invoked from within
+** the [xBestIndex] method of a [virtual table] implementation, with P being
+** a copy of the [sqlite3_index_info] object pointer passed into xBestIndex and
+** J being a 0-based index into P->aConstraint[], then this routine
+** attempts to set *V to the value of the right-hand operand of
+** that constraint if the right-hand operand is known. ^If the
+** right-hand operand is not known, then *V is set to a NULL pointer.
+** ^The sqlite3_vtab_rhs_value(P,J,V) interface returns SQLITE_OK if
+** and only if *V is set to a value. ^The sqlite3_vtab_rhs_value(P,J,V)
+** inteface returns SQLITE_NOTFOUND if the right-hand side of the J-th
+** constraint is not available. ^The sqlite3_vtab_rhs_value() interface
+** can return an result code other than SQLITE_OK or SQLITE_NOTFOUND if
+** something goes wrong.
+**
+** The sqlite3_vtab_rhs_value() interface is usually only successful if
+** the right-hand operand of a constraint is a literal value in the original
+** SQL statement. If the right-hand operand is an expression or a reference
+** to some other column or a [host parameter], then sqlite3_vtab_rhs_value()
+** will probably return [SQLITE_NOTFOUND].
+**
+** ^(Some constraints, such as [SQLITE_INDEX_CONSTRAINT_ISNULL] and
+** [SQLITE_INDEX_CONSTRAINT_ISNOTNULL], have no right-hand operand. For such
+** constraints, sqlite3_vtab_rhs_value() always returns SQLITE_NOTFOUND.)^
+**
+** ^The [sqlite3_value] object returned in *V is a protected sqlite3_value
+** and remains valid for the duration of the xBestIndex method call.
+** ^When xBestIndex returns, the sqlite3_value object returned by
+** sqlite3_vtab_rhs_value() is automatically deallocated.
+**
+** The "_rhs_" in the name of this routine is an abbreviation for
+** "Right-Hand Side".
+*/
+int sqlite3_vtab_rhs_value(sqlite3_index_info*, int, sqlite3_value **ppVal);
+
+/*
** CAPI3REF: Conflict resolution modes
** KEYWORDS: {conflict resolution mode}
**
diff --git a/chromium/third_party/sqlite/src/src/sqlite3ext.h b/chromium/third_party/sqlite/src/src/sqlite3ext.h
index 9767daa01da..2eac4f3f05f 100644
--- a/chromium/third_party/sqlite/src/src/sqlite3ext.h
+++ b/chromium/third_party/sqlite/src/src/sqlite3ext.h
@@ -344,6 +344,13 @@ struct sqlite3_api_routines {
int (*autovacuum_pages)(sqlite3*,
unsigned int(*)(void*,const char*,unsigned int,unsigned int,unsigned int),
void*, void(*)(void*));
+ /* Version 3.38.0 and later */
+ int (*error_offset)(sqlite3*);
+ int (*vtab_rhs_value)(sqlite3_index_info*,int,sqlite3_value**);
+ int (*vtab_distinct)(sqlite3_index_info*);
+ int (*vtab_in)(sqlite3_index_info*,int,int);
+ int (*vtab_in_first)(sqlite3_value*,sqlite3_value**);
+ int (*vtab_in_next)(sqlite3_value*,sqlite3_value**);
};
/*
@@ -655,6 +662,13 @@ typedef int (*sqlite3_loadext_entry)(
#define sqlite3_total_changes64 sqlite3_api->total_changes64
/* Version 3.37.0 and later */
#define sqlite3_autovacuum_pages sqlite3_api->autovacuum_pages
+/* Version 3.38.0 and later */
+#define sqlite3_error_offset sqlite3_api->error_offset
+#define sqlite3_vtab_rhs_value sqlite3_api->vtab_rhs_value
+#define sqlite3_vtab_distinct sqlite3_api->vtab_distinct
+#define sqlite3_vtab_in sqlite3_api->vtab_in
+#define sqlite3_vtab_in_first sqlite3_api->vtab_in_first
+#define sqlite3_vtab_in_next sqlite3_api->vtab_in_next
#endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */
#if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)
diff --git a/chromium/third_party/sqlite/src/src/sqliteInt.h b/chromium/third_party/sqlite/src/src/sqliteInt.h
index b45151104ae..3f11f157154 100644
--- a/chromium/third_party/sqlite/src/src/sqliteInt.h
+++ b/chromium/third_party/sqlite/src/src/sqliteInt.h
@@ -1231,10 +1231,11 @@ typedef struct With With;
/*
** A bit in a Bitmask
*/
-#define MASKBIT(n) (((Bitmask)1)<<(n))
-#define MASKBIT64(n) (((u64)1)<<(n))
-#define MASKBIT32(n) (((unsigned int)1)<<(n))
-#define ALLBITS ((Bitmask)-1)
+#define MASKBIT(n) (((Bitmask)1)<<(n))
+#define MASKBIT64(n) (((u64)1)<<(n))
+#define MASKBIT32(n) (((unsigned int)1)<<(n))
+#define SMASKBIT32(n) ((n)<=31?((unsigned int)1)<<(n):0)
+#define ALLBITS ((Bitmask)-1)
/* A VList object records a mapping between parameters/variables/wildcards
** in the SQL statement (such as $abc, @pqr, or :xyz) and the integer
@@ -1527,6 +1528,7 @@ struct sqlite3 {
u32 nSchemaLock; /* Do not reset the schema when non-zero */
unsigned int openFlags; /* Flags passed to sqlite3_vfs.xOpen() */
int errCode; /* Most recent error code (SQLITE_*) */
+ int errByteOffset; /* Byte offset of error in SQL statement */
int errMask; /* & result codes with this before returning */
int iSysErrno; /* Errno value from last system error */
u32 dbOptFlags; /* Flags to enable/disable optimizations */
@@ -1761,6 +1763,9 @@ struct sqlite3 {
#define SQLITE_SeekScan 0x00020000 /* The OP_SeekScan optimization */
#define SQLITE_OmitOrderBy 0x00040000 /* Omit pointless ORDER BY */
/* TH3 expects this value ^^^^^^^^^^ to be 0x40000. Coordinate any change */
+#define SQLITE_BloomFilter 0x00080000 /* Use a Bloom filter on searches */
+#define SQLITE_BloomPulldown 0x00100000 /* Run Bloom filters early */
+#define SQLITE_BalancedMerge 0x00200000 /* Balance multi-way merges */
#define SQLITE_AllOpts 0xffffffff /* All optimizations */
/*
@@ -1934,7 +1939,7 @@ struct FuncDestructor {
** are interpreted in the same way as the first 4 parameters to
** FUNCTION().
**
-** WFUNCTION(zName, nArg, iArg, xStep, xFinal, xValue, xInverse)
+** WAGGREGATE(zName, nArg, iArg, xStep, xFinal, xValue, xInverse)
** Used to create an aggregate function definition implemented by
** the C functions xStep and xFinal. The first four parameters
** are interpreted in the same way as the first 4 parameters to
@@ -1961,6 +1966,10 @@ struct FuncDestructor {
#define MFUNCTION(zName, nArg, xPtr, xFunc) \
{nArg, SQLITE_FUNC_BUILTIN|SQLITE_FUNC_CONSTANT|SQLITE_UTF8, \
xPtr, 0, xFunc, 0, 0, 0, #zName, {0} }
+#define JFUNCTION(zName, nArg, iArg, xFunc) \
+ {nArg, SQLITE_FUNC_BUILTIN|SQLITE_DETERMINISTIC|SQLITE_INNOCUOUS|\
+ SQLITE_FUNC_CONSTANT|SQLITE_UTF8, \
+ SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, 0, #zName, {0} }
#define INLINE_FUNC(zName, nArg, iArg, mFlags) \
{nArg, SQLITE_FUNC_BUILTIN|\
SQLITE_UTF8|SQLITE_FUNC_INLINE|SQLITE_FUNC_CONSTANT|(mFlags), \
@@ -2815,7 +2824,10 @@ struct Expr {
** TK_VARIABLE: variable number (always >= 1).
** TK_SELECT_COLUMN: column of the result vector */
i16 iAgg; /* Which entry in pAggInfo->aCol[] or ->aFunc[] */
- int iRightJoinTable; /* If EP_FromJoin, the right table of the join */
+ union {
+ int iRightJoinTable; /* If EP_FromJoin, the right table of the join */
+ int iOfst; /* else: start of token from start of statement */
+ } w;
AggInfo *pAggInfo; /* Used by TK_AGG_COLUMN and TK_AGG_FUNCTION */
union {
Table *pTab; /* TK_COLUMN: Table containing column. Can be NULL
@@ -3555,6 +3567,8 @@ struct Parse {
AutoincInfo *pAinc; /* Information about AUTOINCREMENT counters */
Parse *pToplevel; /* Parse structure for main program (or NULL) */
Table *pTriggerTab; /* Table triggers are being coded for */
+ TriggerPrg *pTriggerPrg; /* Linked list of coded triggers */
+ ParseCleanup *pCleanup; /* List of cleanup operations to run after parse */
union {
int addrCrTab; /* Address of OP_CreateBtree on CREATE TABLE */
Returning *pReturning; /* The RETURNING clause */
@@ -3575,6 +3589,7 @@ struct Parse {
**************************************************************************/
int aTempReg[8]; /* Holding area for temporary registers */
+ Parse *pOuterParse; /* Outer Parse object when nested */
Token sNameToken; /* Token with unqualified schema object name */
/************************************************************************
@@ -3609,9 +3624,7 @@ struct Parse {
Token sArg; /* Complete text of a module argument */
Table **apVtabLock; /* Pointer to virtual tables needing locking */
#endif
- TriggerPrg *pTriggerPrg; /* Linked list of coded triggers */
With *pWith; /* Current WITH clause, or NULL */
- ParseCleanup *pCleanup; /* List of cleanup operations to run after parse */
#ifndef SQLITE_OMIT_ALTERTABLE
RenameToken *pRename; /* Tokens subject to renaming by ALTER TABLE */
#endif
@@ -3627,7 +3640,8 @@ struct Parse {
/*
** Sizes and pointers of various parts of the Parse object.
*/
-#define PARSE_HDR_SZ offsetof(Parse,aTempReg) /* Recursive part w/o aColCache*/
+#define PARSE_HDR(X) (((char*)(X))+offsetof(Parse,zErrMsg))
+#define PARSE_HDR_SZ (offsetof(Parse,aTempReg)-offsetof(Parse,zErrMsg)) /* Recursive part w/o aColCache*/
#define PARSE_RECURSE_SZ offsetof(Parse,sLastToken) /* Recursive part */
#define PARSE_TAIL_SZ (sizeof(Parse)-PARSE_RECURSE_SZ) /* Non-recursive part */
#define PARSE_TAIL(X) (((char*)(X))+PARSE_RECURSE_SZ) /* Pointer to tail */
@@ -3922,6 +3936,7 @@ struct Sqlite3Config {
int (*xTestCallback)(int); /* Invoked by sqlite3FaultSim() */
#endif
int bLocaltimeFault; /* True to fail localtime() calls */
+ int (*xAltLocaltime)(const void*,void*); /* Alternative localtime() routine */
int iOnceResetThreshold; /* When to reset OP_Once counters */
u32 szSorterRef; /* Min size in bytes to use sorter-refs */
unsigned int iPrngSeed; /* Alternative fixed seed for the PRNG */
@@ -4402,7 +4417,7 @@ void sqlite3DequoteExpr(Expr*);
void sqlite3DequoteToken(Token*);
void sqlite3TokenInit(Token*,char*);
int sqlite3KeywordCode(const unsigned char*, int);
-int sqlite3RunParser(Parse*, const char*, char **);
+int sqlite3RunParser(Parse*, const char*);
void sqlite3FinishCoding(Parse*);
int sqlite3GetTempReg(Parse*);
void sqlite3ReleaseTempReg(Parse*,int);
@@ -4563,10 +4578,12 @@ void sqlite3OpenTable(Parse*, int iCur, int iDb, Table*, int);
#if defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT) && !defined(SQLITE_OMIT_SUBQUERY)
Expr *sqlite3LimitWhere(Parse*,SrcList*,Expr*,ExprList*,Expr*,char*);
#endif
+void sqlite3CodeChangeCount(Vdbe*,int,const char*);
void sqlite3DeleteFrom(Parse*, SrcList*, Expr*, ExprList*, Expr*);
void sqlite3Update(Parse*, SrcList*, ExprList*,Expr*,int,ExprList*,Expr*,
Upsert*);
-WhereInfo *sqlite3WhereBegin(Parse*,SrcList*,Expr*,ExprList*,ExprList*,u16,int);
+WhereInfo *sqlite3WhereBegin(Parse*,SrcList*,Expr*,ExprList*,
+ ExprList*,Select*,u16,int);
void sqlite3WhereEnd(WhereInfo*);
LogEst sqlite3WhereOutputRowCount(WhereInfo*);
int sqlite3WhereIsDistinct(WhereInfo*);
@@ -4681,9 +4698,14 @@ Select *sqlite3SelectDup(sqlite3*,const Select*,int);
FuncDef *sqlite3FunctionSearch(int,const char*);
void sqlite3InsertBuiltinFuncs(FuncDef*,int);
FuncDef *sqlite3FindFunction(sqlite3*,const char*,int,u8,u8);
+void sqlite3QuoteValue(StrAccum*,sqlite3_value*);
void sqlite3RegisterBuiltinFunctions(void);
void sqlite3RegisterDateTimeFunctions(void);
+void sqlite3RegisterJsonFunctions(void);
void sqlite3RegisterPerConnectionBuiltinFunctions(sqlite3*);
+#if !defined(SQLITE_OMIT_VIRTUALTABLE) && !defined(SQLITE_OMIT_JSON)
+ int sqlite3JsonTableFunctions(sqlite3*);
+#endif
int sqlite3SafetyCheckOk(sqlite3*);
int sqlite3SafetyCheckSickOrOk(sqlite3*);
void sqlite3ChangeCookie(Parse*, int);
@@ -4773,14 +4795,8 @@ int sqlite3Utf8CharLen(const char *pData, int nByte);
u32 sqlite3Utf8Read(const u8**);
LogEst sqlite3LogEst(u64);
LogEst sqlite3LogEstAdd(LogEst,LogEst);
-#ifndef SQLITE_OMIT_VIRTUALTABLE
LogEst sqlite3LogEstFromDouble(double);
-#endif
-#if defined(SQLITE_ENABLE_STMT_SCANSTATUS) || \
- defined(SQLITE_ENABLE_STAT4) || \
- defined(SQLITE_EXPLAIN_ESTIMATED_ROWS)
u64 sqlite3LogEstToInt(LogEst);
-#endif
VList *sqlite3VListAdd(sqlite3*,VList*,const char*,int,int);
const char *sqlite3VListNumToName(VList*,int);
int sqlite3VListNameToNum(VList*,const char*,int);
@@ -4967,17 +4983,20 @@ int sqlite3CreateFunc(sqlite3 *, const char *, int, int, void *,
FuncDestructor *pDestructor
);
void sqlite3NoopDestructor(void*);
-void sqlite3OomFault(sqlite3*);
+void *sqlite3OomFault(sqlite3*);
void sqlite3OomClear(sqlite3*);
int sqlite3ApiExit(sqlite3 *db, int);
int sqlite3OpenTempDatabase(Parse *);
void sqlite3StrAccumInit(StrAccum*, sqlite3*, char*, int, int);
+int sqlite3StrAccumEnlarge(StrAccum*, int);
char *sqlite3StrAccumFinish(StrAccum*);
void sqlite3StrAccumSetError(StrAccum*, u8);
void sqlite3ResultStrAccum(sqlite3_context*,StrAccum*);
void sqlite3SelectDestInit(SelectDest*,int,int);
Expr *sqlite3CreateColumnExpr(sqlite3 *, SrcList *, int, int);
+void sqlite3RecordErrorByteOffset(sqlite3*,const char*);
+void sqlite3RecordErrorOffsetOfExpr(sqlite3*,const Expr*);
void sqlite3BackupRestart(sqlite3_backup *);
void sqlite3BackupUpdate(sqlite3_backup *, Pgno, const u8 *);
@@ -5082,11 +5101,17 @@ int sqlite3VtabCallCreate(sqlite3*, int, const char *, char **);
int sqlite3VtabCallConnect(Parse*, Table*);
int sqlite3VtabCallDestroy(sqlite3*, int, const char *);
int sqlite3VtabBegin(sqlite3 *, VTable *);
+
FuncDef *sqlite3VtabOverloadFunction(sqlite3 *,FuncDef*, int nArg, Expr*);
+#if (defined(SQLITE_ENABLE_DBPAGE_VTAB) || defined(SQLITE_TEST)) \
+ && !defined(SQLITE_OMIT_VIRTUALTABLE)
+ void sqlite3VtabWriteAll(sqlite3_index_info*);
+#endif
sqlite3_int64 sqlite3StmtCurrentTime(sqlite3_context*);
int sqlite3VdbeParameterIndex(Vdbe*, const char*, int);
int sqlite3TransferBindings(sqlite3_stmt *, sqlite3_stmt *);
-void sqlite3ParserReset(Parse*);
+void sqlite3ParseObjectInit(Parse*,sqlite3*);
+void sqlite3ParseObjectReset(Parse*);
void *sqlite3ParserAddCleanup(Parse*,void(*)(sqlite3*,void*),void*);
#ifdef SQLITE_ENABLE_NORMALIZE
char *sqlite3Normalize(Vdbe*, const char*);
@@ -5145,6 +5170,7 @@ const char *sqlite3JournalModename(int);
int sqlite3FkRequired(Parse*, Table*, int*, int);
u32 sqlite3FkOldmask(Parse*, Table*);
FKey *sqlite3FkReferences(Table *);
+ void sqlite3FkClearTriggerCache(sqlite3*,int);
#else
#define sqlite3FkActions(a,b,c,d,e,f)
#define sqlite3FkCheck(a,b,c,d,e,f)
@@ -5152,6 +5178,7 @@ const char *sqlite3JournalModename(int);
#define sqlite3FkOldmask(a,b) 0
#define sqlite3FkRequired(a,b,c,d) 0
#define sqlite3FkReferences(a) 0
+ #define sqlite3FkClearTriggerCache(a,b)
#endif
#ifndef SQLITE_OMIT_FOREIGN_KEY
void sqlite3FkDelete(sqlite3 *, Table*);
diff --git a/chromium/third_party/sqlite/src/src/tclsqlite.c b/chromium/third_party/sqlite/src/src/tclsqlite.c
index d379f8d5ae8..8c184809f1d 100644
--- a/chromium/third_party/sqlite/src/src/tclsqlite.c
+++ b/chromium/third_party/sqlite/src/src/tclsqlite.c
@@ -1943,15 +1943,16 @@ static int SQLITE_TCLAPI DbObjCmd(
"close", "collate", "collation_needed",
"commit_hook", "complete", "config",
"copy", "deserialize", "enable_load_extension",
- "errorcode", "eval", "exists",
- "function", "incrblob", "interrupt",
- "last_insert_rowid", "nullvalue", "onecolumn",
- "preupdate", "profile", "progress",
- "rekey", "restore", "rollback_hook",
- "serialize", "status", "timeout",
- "total_changes", "trace", "trace_v2",
- "transaction", "unlock_notify", "update_hook",
- "version", "wal_hook", 0
+ "errorcode", "erroroffset", "eval",
+ "exists", "function", "incrblob",
+ "interrupt", "last_insert_rowid", "nullvalue",
+ "onecolumn", "preupdate", "profile",
+ "progress", "rekey", "restore",
+ "rollback_hook", "serialize", "status",
+ "timeout", "total_changes", "trace",
+ "trace_v2", "transaction", "unlock_notify",
+ "update_hook", "version", "wal_hook",
+ 0
};
enum DB_enum {
DB_AUTHORIZER, DB_BACKUP, DB_BIND_FALLBACK,
@@ -1959,15 +1960,15 @@ static int SQLITE_TCLAPI DbObjCmd(
DB_CLOSE, DB_COLLATE, DB_COLLATION_NEEDED,
DB_COMMIT_HOOK, DB_COMPLETE, DB_CONFIG,
DB_COPY, DB_DESERIALIZE, DB_ENABLE_LOAD_EXTENSION,
- DB_ERRORCODE, DB_EVAL, DB_EXISTS,
- DB_FUNCTION, DB_INCRBLOB, DB_INTERRUPT,
- DB_LAST_INSERT_ROWID, DB_NULLVALUE, DB_ONECOLUMN,
- DB_PREUPDATE, DB_PROFILE, DB_PROGRESS,
- DB_REKEY, DB_RESTORE, DB_ROLLBACK_HOOK,
- DB_SERIALIZE, DB_STATUS, DB_TIMEOUT,
- DB_TOTAL_CHANGES, DB_TRACE, DB_TRACE_V2,
- DB_TRANSACTION, DB_UNLOCK_NOTIFY, DB_UPDATE_HOOK,
- DB_VERSION, DB_WAL_HOOK
+ DB_ERRORCODE, DB_ERROROFFSET, DB_EVAL,
+ DB_EXISTS, DB_FUNCTION, DB_INCRBLOB,
+ DB_INTERRUPT, DB_LAST_INSERT_ROWID, DB_NULLVALUE,
+ DB_ONECOLUMN, DB_PREUPDATE, DB_PROFILE,
+ DB_PROGRESS, DB_REKEY, DB_RESTORE,
+ DB_ROLLBACK_HOOK, DB_SERIALIZE, DB_STATUS,
+ DB_TIMEOUT, DB_TOTAL_CHANGES, DB_TRACE,
+ DB_TRACE_V2, DB_TRANSACTION, DB_UNLOCK_NOTIFY,
+ DB_UPDATE_HOOK, DB_VERSION, DB_WAL_HOOK,
};
/* don't leave trailing commas on DB_enum, it confuses the AIX xlc compiler */
@@ -2731,6 +2732,17 @@ deserialize_error:
}
/*
+ ** $db erroroffset
+ **
+ ** Return the numeric error code that was returned by the most recent
+ ** call to sqlite3_exec().
+ */
+ case DB_ERROROFFSET: {
+ Tcl_SetObjResult(interp, Tcl_NewIntObj(sqlite3_error_offset(pDb->db)));
+ break;
+ }
+
+ /*
** $db exists $sql
** $db onecolumn $sql
**
diff --git a/chromium/third_party/sqlite/src/src/test1.c b/chromium/third_party/sqlite/src/src/test1.c
index 6060290b98d..455c4b2579c 100644
--- a/chromium/third_party/sqlite/src/src/test1.c
+++ b/chromium/third_party/sqlite/src/src/test1.c
@@ -1097,7 +1097,7 @@ static int SQLITE_TCLAPI test_drop_modules(
){
sqlite3 *db;
- if( argc!=2 ){
+ if( argc<2 ){
Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
" DB\"", 0);
return TCL_ERROR;
@@ -3977,6 +3977,102 @@ static int SQLITE_TCLAPI test_bind_blob(
return TCL_OK;
}
+/*
+** Usage: sqlite3_bind_value_from_preupdate STMT N NEW|OLD IDX
+**
+** Test the sqlite3_bind_value interface using sqlite3_value objects
+** obtained from either sqlite3_preupdate_new() (if arg[3]=="new") or
+** sqlite3_preupdate_old() if (arg[3]=="old"). IDX is the index to
+** pass to the sqlite3_preupdate_xxx() function.
+*/
+static int SQLITE_TCLAPI test_bind_value_from_preupdate(
+ void * clientData,
+ Tcl_Interp *interp,
+ int objc,
+ Tcl_Obj *CONST objv[]
+){
+ sqlite3_stmt *pStmt;
+ int idx;
+ int bidx;
+ const char *z3 = 0;
+ sqlite3 *db = 0;
+ sqlite3_value *pVal = 0;
+
+ if( objc!=5 ){
+ Tcl_WrongNumArgs(interp, 1, objv, "STMT N NEW|OLD IDX");
+ return TCL_ERROR;
+ }
+
+ if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR;
+ if( Tcl_GetIntFromObj(interp, objv[2], &idx) ) return TCL_ERROR;
+ z3 = Tcl_GetString(objv[3]);
+ if( Tcl_GetIntFromObj(interp, objv[4], &bidx) ) return TCL_ERROR;
+ db = sqlite3_db_handle(pStmt);
+
+#ifdef SQLITE_ENABLE_PREUPDATE_HOOK
+ if( z3[0]=='n' ){
+ sqlite3_preupdate_new(db, bidx, &pVal);
+ }else if( z3[0]=='o' ){
+ sqlite3_preupdate_old(db, bidx, &pVal);
+ }else{
+ Tcl_AppendResult(interp, "expected new or old, got: ", z3, (char*)0);
+ return TCL_ERROR;
+ }
+ sqlite3_bind_value(pStmt, idx, pVal);
+#endif
+
+ return TCL_OK;
+}
+
+/*
+** Usage: sqlite3_bind_value_from_select STMT N SELECT
+**
+** Test the sqlite3_bind_value interface. STMT is a prepared statement.
+** N is the index of a wildcard in the prepared statement.
+*/
+static int SQLITE_TCLAPI test_bind_value_from_select(
+ void * clientData,
+ Tcl_Interp *interp,
+ int objc,
+ Tcl_Obj *CONST objv[]
+){
+ sqlite3_stmt *pStmt;
+ sqlite3_stmt *pStmt2;
+ int idx;
+ const char *zSql = 0;
+ sqlite3 *db = 0;
+ int rc = SQLITE_OK;
+
+ if( objc!=4 ){
+ Tcl_WrongNumArgs(interp, 1, objv, "STMT N SELECT");
+ return TCL_ERROR;
+ }
+
+ if( getStmtPointer(interp, Tcl_GetString(objv[1]), &pStmt) ) return TCL_ERROR;
+ if( Tcl_GetIntFromObj(interp, objv[2], &idx) ) return TCL_ERROR;
+ zSql = Tcl_GetString(objv[3]);
+ db = sqlite3_db_handle(pStmt);
+
+ rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt2, 0);
+ if( rc!=SQLITE_OK ){
+ Tcl_AppendResult(interp, "error in SQL: ", sqlite3_errmsg(db), (char*)0);
+ return TCL_ERROR;
+ }
+ if( sqlite3_step(pStmt2)==SQLITE_ROW ){
+ sqlite3_value *pVal = sqlite3_column_value(pStmt2, 0);
+ sqlite3_bind_value(pStmt, idx, pVal);
+ }
+ rc = sqlite3_finalize(pStmt2);
+ if( rc!=SQLITE_OK ){
+ Tcl_AppendResult(interp,
+ "error runnning SQL: ", sqlite3_errmsg(db), (char*)0
+ );
+ return TCL_ERROR;
+ }
+
+ return TCL_OK;
+}
+
#ifndef SQLITE_OMIT_VIRTUALTABLE
/*
@@ -4366,6 +4462,34 @@ static int SQLITE_TCLAPI test_errmsg(
return TCL_OK;
}
+
+/*
+** Usage: sqlite3_error_offset DB
+**
+** Return the byte offset into the input UTF8 SQL for the most recent
+** error, or -1 of the error does not refer to a specific token.
+*/
+static int SQLITE_TCLAPI test_error_offset(
+ void * clientData,
+ Tcl_Interp *interp,
+ int objc,
+ Tcl_Obj *CONST objv[]
+){
+ sqlite3 *db;
+ int iByteOffset;
+
+ if( objc!=2 ){
+ Tcl_AppendResult(interp, "wrong # args: should be \"",
+ Tcl_GetString(objv[0]), " DB", 0);
+ return TCL_ERROR;
+ }
+ if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;
+
+ iByteOffset = sqlite3_error_offset(db);
+ Tcl_SetObjResult(interp, Tcl_NewIntObj(iByteOffset));
+ return TCL_OK;
+}
+
/*
** Usage: test_errmsg16 DB
**
@@ -7083,6 +7207,55 @@ static int SQLITE_TCLAPI test_print_eqp(
}
#endif /* SQLITE_OMIT_EXPLAIN */
+#include <time.h>
+/*
+** This is an alternative localtime_r() implementation used for testing
+** the 'localtime' and 'utc' modifiers of date-time functions. Because
+** the OS-supplied localtime_r() is locale-dependent, this alternative is
+** provided as a stable test platform.
+**
+** Operation:
+**
+** (1) Localtime is 30 minutes earlier than (west of) UTC on
+** even days (counting from 1970-01-01)
+**
+** (2) Localtime is 30 minutes later than (east of) UTC on odd days.
+**
+** (3) The function fails for the specific date/time value
+** of 2000-05-29 14:16:00 in order to test the ability of
+** SQLite to deal with localtime_r() failures.
+*/
+static int testLocaltime(const void *aliasT, void *aliasTM){
+ const time_t t = *(const time_t*)aliasT;
+ struct tm *pTm = (struct tm *)aliasTM;
+ time_t altT;
+ sqlite3_int64 iJD;
+ int Z, A, B, C, D, E, X1, S;
+
+ if( (t/86400) & 1 ){
+ altT = t + 1800; /* 30 minutes later on odd days */
+ }else{
+ altT = t - 1800; /* 30 minutes earlier on even days */
+ }
+ iJD = (sqlite3_int64)(altT + 210866760000);
+ Z = (int)((iJD + 43200)/86400);
+ A = (int)((Z - 1867216.25)/36524.25);
+ A = Z + 1 + A - (A/4);
+ B = A + 1524;
+ C = (int)((B - 122.1)/365.25);
+ D = (36525*(C&32767))/100;
+ E = (int)((B-D)/30.6001);
+ X1 = (int)(30.6001*E);
+ pTm->tm_mday = B - D - X1;
+ pTm->tm_mon = E<14 ? E-2 : E-14;
+ pTm->tm_year = (pTm->tm_mon>1 ? C - 4716 : C - 4715) - 1900;
+ S = (int)((iJD + 43200)%86400);
+ pTm->tm_hour = S/3600;
+ pTm->tm_min = (S/60)%60;
+ pTm->tm_sec = S % 60;
+ return t==959609760; /* Special case: 2000-05-29 14:16:00 fails */
+}
+
/*
** sqlite3_test_control VERB ARGS...
*/
@@ -7130,11 +7303,11 @@ static int SQLITE_TCLAPI test_test_control(
case SQLITE_TESTCTRL_LOCALTIME_FAULT: {
int val;
if( objc!=3 ){
- Tcl_WrongNumArgs(interp, 2, objv, "ONOFF");
+ Tcl_WrongNumArgs(interp, 2, objv, "0|1|2");
return TCL_ERROR;
}
- if( Tcl_GetBooleanFromObj(interp, objv[2], &val) ) return TCL_ERROR;
- sqlite3_test_control(iFlag, val);
+ if( Tcl_GetIntFromObj(interp, objv[2], &val) ) return TCL_ERROR;
+ sqlite3_test_control(iFlag, val, testLocaltime);
break;
}
@@ -7484,6 +7657,7 @@ static int SQLITE_TCLAPI optimization_control(
{ "stat4", SQLITE_Stat4 },
{ "skip-scan", SQLITE_SkipScan },
{ "push-down", SQLITE_PushDown },
+ { "balanced-merge", SQLITE_BalancedMerge },
};
if( objc!=4 ){
@@ -7539,6 +7713,7 @@ static int SQLITE_TCLAPI tclLoadStaticExtensionCmd(
#ifndef SQLITE_OMIT_VIRTUALTABLE
extern int sqlite3_prefixes_init(sqlite3*,char**,const sqlite3_api_routines*);
#endif
+ extern int sqlite3_qpvtab_init(sqlite3*,char**,const sqlite3_api_routines*);
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*);
@@ -7569,6 +7744,7 @@ static int SQLITE_TCLAPI tclLoadStaticExtensionCmd(
#ifndef SQLITE_OMIT_VIRTUALTABLE
{ "prefixes", sqlite3_prefixes_init },
#endif
+ { "qpvtab", sqlite3_qpvtab_init },
{ "regexp", sqlite3_regexp_init },
{ "remember", sqlite3_remember_init },
{ "series", sqlite3_series_init },
@@ -8411,6 +8587,8 @@ int Sqlitetest1_Init(Tcl_Interp *interp){
{ "sqlite3_bind_text", test_bind_text ,0 },
{ "sqlite3_bind_text16", test_bind_text16 ,0 },
{ "sqlite3_bind_blob", test_bind_blob ,0 },
+ { "sqlite3_bind_value_from_select",test_bind_value_from_select ,0 },
+ { "sqlite3_bind_value_from_preupdate",test_bind_value_from_preupdate ,0 },
#ifndef SQLITE_OMIT_VIRTUALTABLE
{ "sqlite3_carray_bind", test_carray_bind ,0 },
#endif
@@ -8422,6 +8600,7 @@ int Sqlitetest1_Init(Tcl_Interp *interp){
{ "sqlite3_errcode", test_errcode ,0 },
{ "sqlite3_extended_errcode", test_ex_errcode ,0 },
{ "sqlite3_errmsg", test_errmsg ,0 },
+ { "sqlite3_error_offset", test_error_offset ,0 },
{ "sqlite3_errmsg16", test_errmsg16 ,0 },
{ "sqlite3_open", test_open ,0 },
{ "sqlite3_open16", test_open16 ,0 },
diff --git a/chromium/third_party/sqlite/src/src/test_bestindex.c b/chromium/third_party/sqlite/src/src/test_bestindex.c
index 2cd79baf2bc..67a0c8258d6 100644
--- a/chromium/third_party/sqlite/src/src/test_bestindex.c
+++ b/chromium/third_party/sqlite/src/src/test_bestindex.c
@@ -299,7 +299,21 @@ static int tclFilter(
const char *zVal = (const char*)sqlite3_value_text(argv[ii]);
Tcl_Obj *pVal;
if( zVal==0 ){
+ sqlite3_value *pMem;
pVal = Tcl_NewObj();
+ for(rc=sqlite3_vtab_in_first(argv[ii], &pMem);
+ rc==SQLITE_OK && pMem;
+ rc=sqlite3_vtab_in_next(argv[ii], &pMem)
+ ){
+ Tcl_Obj *pVal2 = 0;
+ zVal = (const char*)sqlite3_value_text(pMem);
+ if( zVal ){
+ pVal2 = Tcl_NewStringObj(zVal, -1);
+ }else{
+ pVal2 = Tcl_NewObj();
+ }
+ Tcl_ListObjAppendElement(interp, pVal, pVal2);
+ }
}else{
pVal = Tcl_NewStringObj(zVal, -1);
}
@@ -374,20 +388,13 @@ static int tclEof(sqlite3_vtab_cursor *pVtabCursor){
return (pCsr->pStmt==0);
}
-static int tclBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){
- tcl_vtab *pTab = (tcl_vtab*)tab;
- Tcl_Interp *interp = pTab->interp;
- Tcl_Obj *pArg;
- Tcl_Obj *pScript;
+static void testBestIndexObjConstraints(
+ Tcl_Interp *interp,
+ sqlite3_index_info *pIdxInfo
+){
int ii;
- int rc = SQLITE_OK;
-
- pScript = Tcl_DuplicateObj(pTab->pCmd);
- Tcl_IncrRefCount(pScript);
- Tcl_ListObjAppendElement(interp, pScript, Tcl_NewStringObj("xBestIndex", -1));
-
- pArg = Tcl_NewObj();
- Tcl_IncrRefCount(pArg);
+ Tcl_Obj *pRes = Tcl_NewObj();
+ Tcl_IncrRefCount(pRes);
for(ii=0; ii<pIdxInfo->nConstraint; ii++){
struct sqlite3_index_constraint const *pCons = &pIdxInfo->aConstraint[ii];
Tcl_Obj *pElem = Tcl_NewObj();
@@ -424,6 +431,10 @@ static int tclBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){
zOp = "isnull"; break;
case SQLITE_INDEX_CONSTRAINT_IS:
zOp = "is"; break;
+ case SQLITE_INDEX_CONSTRAINT_LIMIT:
+ zOp = "limit"; break;
+ case SQLITE_INDEX_CONSTRAINT_OFFSET:
+ zOp = "offset"; break;
}
Tcl_ListObjAppendElement(0, pElem, Tcl_NewStringObj("op", -1));
@@ -433,15 +444,21 @@ static int tclBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){
Tcl_ListObjAppendElement(0, pElem, Tcl_NewStringObj("usable", -1));
Tcl_ListObjAppendElement(0, pElem, Tcl_NewIntObj(pCons->usable));
- Tcl_ListObjAppendElement(0, pArg, pElem);
+ Tcl_ListObjAppendElement(0, pRes, pElem);
Tcl_DecrRefCount(pElem);
}
- Tcl_ListObjAppendElement(0, pScript, pArg);
- Tcl_DecrRefCount(pArg);
+ Tcl_SetObjResult(interp, pRes);
+ Tcl_DecrRefCount(pRes);
+}
- pArg = Tcl_NewObj();
- Tcl_IncrRefCount(pArg);
+static void testBestIndexObjOrderby(
+ Tcl_Interp *interp,
+ sqlite3_index_info *pIdxInfo
+){
+ int ii;
+ Tcl_Obj *pRes = Tcl_NewObj();
+ Tcl_IncrRefCount(pRes);
for(ii=0; ii<pIdxInfo->nOrderBy; ii++){
struct sqlite3_index_orderby const *pOrder = &pIdxInfo->aOrderBy[ii];
Tcl_Obj *pElem = Tcl_NewObj();
@@ -452,17 +469,150 @@ static int tclBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){
Tcl_ListObjAppendElement(0, pElem, Tcl_NewStringObj("desc", -1));
Tcl_ListObjAppendElement(0, pElem, Tcl_NewIntObj(pOrder->desc));
- Tcl_ListObjAppendElement(0, pArg, pElem);
+ Tcl_ListObjAppendElement(0, pRes, pElem);
Tcl_DecrRefCount(pElem);
}
- Tcl_ListObjAppendElement(0, pScript, pArg);
- Tcl_DecrRefCount(pArg);
+ Tcl_SetObjResult(interp, pRes);
+ Tcl_DecrRefCount(pRes);
+}
- Tcl_ListObjAppendElement(0, pScript, Tcl_NewWideIntObj(pIdxInfo->colUsed));
+/*
+** Implementation of the handle passed to each xBestIndex callback. This
+** object features the following sub-commands:
+**
+** $hdl constraints
+** $hdl orderby
+** $hdl mask
+**
+** $hdl distinct
+** Return the result (an integer) of calling sqlite3_vtab_distinct()
+** on the index-info structure.
+**
+** $hdl in IDX BOOLEAN
+** Wrapper around sqlite3_vtab_in(). Returns an integer.
+**
+** $hdl rhs_value IDX ?DEFAULT?
+** Wrapper around sqlite3_vtab_rhs_value().
+*/
+static int SQLITE_TCLAPI testBestIndexObj(
+ ClientData clientData, /* Pointer to sqlite3_enable_XXX function */
+ Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
+ int objc, /* Number of arguments */
+ Tcl_Obj *CONST objv[] /* Command arguments */
+){
+ const char *azSub[] = {
+ "constraints", /* 0 */
+ "orderby", /* 1 */
+ "mask", /* 2 */
+ "distinct", /* 3 */
+ "in", /* 4 */
+ "rhs_value", /* 5 */
+ 0
+ };
+ int ii;
+ sqlite3_index_info *pIdxInfo = (sqlite3_index_info*)clientData;
+ if( objc<2 ){
+ Tcl_WrongNumArgs(interp, 1, objv, "SUB-COMMAND");
+ return TCL_ERROR;
+ }
+ if( Tcl_GetIndexFromObj(interp, objv[1], azSub, "sub-command", 0, &ii) ){
+ return TCL_ERROR;
+ }
+
+ if( ii<4 && objc!=2 ){
+ Tcl_WrongNumArgs(interp, 2, objv, "");
+ return TCL_ERROR;
+ }
+ if( ii==4 && objc!=4 ){
+ Tcl_WrongNumArgs(interp, 2, objv, "INDEX BOOLEAN");
+ return TCL_ERROR;
+ }
+ if( ii==5 && objc!=3 && objc!=4 ){
+ Tcl_WrongNumArgs(interp, 2, objv, "INDEX ?DEFAULT?");
+ return TCL_ERROR;
+ }
+
+ switch( ii ){
+ case 0: assert( sqlite3_stricmp(azSub[ii], "constraints")==0 );
+ testBestIndexObjConstraints(interp, pIdxInfo);
+ break;
+
+ case 1: assert( sqlite3_stricmp(azSub[ii], "orderby")==0 );
+ testBestIndexObjOrderby(interp, pIdxInfo);
+ break;
+
+ case 2: assert( sqlite3_stricmp(azSub[ii], "mask")==0 );
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(pIdxInfo->colUsed));
+ break;
+
+ case 3: assert( sqlite3_stricmp(azSub[ii], "distinct")==0 ); {
+ int bDistinct = sqlite3_vtab_distinct(pIdxInfo);
+ Tcl_SetObjResult(interp, Tcl_NewIntObj(bDistinct));
+ break;
+ }
+
+ case 4: assert( sqlite3_stricmp(azSub[ii], "in")==0 ); {
+ int iCons;
+ int bHandle;
+ if( Tcl_GetIntFromObj(interp, objv[2], &iCons)
+ || Tcl_GetBooleanFromObj(interp, objv[3], &bHandle)
+ ){
+ return TCL_ERROR;
+ }
+ Tcl_SetObjResult(interp,
+ Tcl_NewIntObj(sqlite3_vtab_in(pIdxInfo, iCons, bHandle))
+ );
+ break;
+ }
+
+ case 5: assert( sqlite3_stricmp(azSub[ii], "rhs_value")==0 ); {
+ int iCons = 0;
+ int rc;
+ sqlite3_value *pVal = 0;
+ const char *zVal = "";
+ if( Tcl_GetIntFromObj(interp, objv[2], &iCons) ){
+ return TCL_ERROR;
+ }
+ rc = sqlite3_vtab_rhs_value(pIdxInfo, iCons, &pVal);
+ if( rc!=SQLITE_OK && rc!=SQLITE_NOTFOUND ){
+ Tcl_SetResult(interp, (char *)sqlite3ErrName(rc), TCL_VOLATILE);
+ return TCL_ERROR;
+ }
+ if( pVal ){
+ zVal = (const char*)sqlite3_value_text(pVal);
+ }else if( objc==4 ){
+ zVal = Tcl_GetString(objv[3]);
+ }
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(zVal, -1));
+ break;
+ }
+ }
+
+ return TCL_OK;
+}
+
+static int tclBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){
+ tcl_vtab *pTab = (tcl_vtab*)tab;
+ Tcl_Interp *interp = pTab->interp;
+ int rc = SQLITE_OK;
+
+ static int iNext = 43;
+ char zHdl[24];
+ Tcl_Obj *pScript;
+
+ pScript = Tcl_DuplicateObj(pTab->pCmd);
+ Tcl_IncrRefCount(pScript);
+ Tcl_ListObjAppendElement(interp, pScript, Tcl_NewStringObj("xBestIndex", -1));
+
+ sqlite3_snprintf(sizeof(zHdl), zHdl, "bestindex%d", iNext++);
+ Tcl_CreateObjCommand(interp, zHdl, testBestIndexObj, pIdxInfo, 0);
+ Tcl_ListObjAppendElement(interp, pScript, Tcl_NewStringObj(zHdl, -1));
rc = Tcl_EvalObjEx(interp, pScript, TCL_EVAL_GLOBAL);
+ Tcl_DeleteCommand(interp, zHdl);
Tcl_DecrRefCount(pScript);
+
if( rc!=TCL_OK ){
const char *zErr = Tcl_GetStringResult(interp);
rc = SQLITE_ERROR;
@@ -489,6 +639,7 @@ static int tclBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){
rc = SQLITE_ERROR;
pTab->base.zErrMsg = sqlite3_mprintf("%s", zErr);
}else{
+ int ii;
int iArgv = 1;
for(ii=0; rc==SQLITE_OK && ii<nElem; ii+=2){
const char *zCmd = Tcl_GetString(apElem[ii]);
diff --git a/chromium/third_party/sqlite/src/src/test_config.c b/chromium/third_party/sqlite/src/src/test_config.c
index acf98e36d87..a362dbc567b 100644
--- a/chromium/third_party/sqlite/src/src/test_config.c
+++ b/chromium/third_party/sqlite/src/src/test_config.c
@@ -239,7 +239,7 @@ static void set_options(Tcl_Interp *interp){
Tcl_SetVar2(interp, "sqlite_options", "geopoly", "0", TCL_GLOBAL_ONLY);
#endif
-#ifdef SQLITE_ENABLE_JSON1
+#ifndef SQLITE_OMIT_JSON
Tcl_SetVar2(interp, "sqlite_options", "json1", "1", TCL_GLOBAL_ONLY);
#else
Tcl_SetVar2(interp, "sqlite_options", "json1", "0", TCL_GLOBAL_ONLY);
diff --git a/chromium/third_party/sqlite/src/src/test_func.c b/chromium/third_party/sqlite/src/src/test_func.c
index b7c9e08ceb3..fa524382610 100644
--- a/chromium/third_party/sqlite/src/src/test_func.c
+++ b/chromium/third_party/sqlite/src/src/test_func.c
@@ -499,7 +499,8 @@ static void test_extract(
mem.db = db;
mem.enc = ENC(db);
pHdr += sqlite3GetVarint(pHdr, &iSerialType);
- pBody += sqlite3VdbeSerialGet(pBody, (u32)iSerialType, &mem);
+ sqlite3VdbeSerialGet(pBody, (u32)iSerialType, &mem);
+ pBody += sqlite3VdbeSerialTypeLen((u32)iSerialType);
if( iCurrent==iIdx ){
sqlite3_result_value(context, &mem);
@@ -547,7 +548,8 @@ static void test_decode(
mem.db = db;
mem.enc = ENC(db);
pHdr += sqlite3GetVarint(pHdr, &iSerialType);
- pBody += sqlite3VdbeSerialGet(pBody, (u32)iSerialType, &mem);
+ sqlite3VdbeSerialGet(pBody, (u32)iSerialType, &mem);
+ pBody += sqlite3VdbeSerialTypeLen((u32)iSerialType);
switch( sqlite3_value_type(&mem) ){
case SQLITE_TEXT:
diff --git a/chromium/third_party/sqlite/src/src/tokenize.c b/chromium/third_party/sqlite/src/src/tokenize.c
index e128d161484..a727078ba7a 100644
--- a/chromium/third_party/sqlite/src/src/tokenize.c
+++ b/chromium/third_party/sqlite/src/src/tokenize.c
@@ -290,6 +290,9 @@ int sqlite3GetToken(const unsigned char *z, int *tokenType){
for(i=2; (c=z[i])!=0 && c!='\n'; i++){}
*tokenType = TK_SPACE; /* IMP: R-22934-25134 */
return i;
+ }else if( z[1]=='>' ){
+ *tokenType = TK_PTR;
+ return 2 + (z[2]=='>');
}
*tokenType = TK_MINUS;
return 1;
@@ -559,13 +562,9 @@ int sqlite3GetToken(const unsigned char *z, int *tokenType){
}
/*
-** Run the parser on the given SQL string. The parser structure is
-** passed in. An SQLITE_ status code is returned. If an error occurs
-** then an and attempt is made to write an error message into
-** memory obtained from sqlite3_malloc() and to make *pzErrMsg point to that
-** error message.
+** Run the parser on the given SQL string.
*/
-int sqlite3RunParser(Parse *pParse, const char *zSql, char **pzErrMsg){
+int sqlite3RunParser(Parse *pParse, const char *zSql){
int nErr = 0; /* Number of errors encountered */
void *pEngine; /* The LEMON-generated LALR(1) parser */
int n = 0; /* Length of the next token token */
@@ -586,7 +585,6 @@ int sqlite3RunParser(Parse *pParse, const char *zSql, char **pzErrMsg){
}
pParse->rc = SQLITE_OK;
pParse->zTail = zSql;
- assert( pzErrMsg!=0 );
#ifdef SQLITE_DEBUG
if( db->flags & SQLITE_ParserTrace ){
printf("parser: [[[%s]]]\n", zSql);
@@ -629,6 +627,7 @@ int sqlite3RunParser(Parse *pParse, const char *zSql, char **pzErrMsg){
#endif /* SQLITE_OMIT_WINDOWFUNC */
if( AtomicLoad(&db->u1.isInterrupted) ){
pParse->rc = SQLITE_INTERRUPT;
+ pParse->nErr++;
break;
}
if( tokenType==TK_SPACE ){
@@ -658,7 +657,10 @@ int sqlite3RunParser(Parse *pParse, const char *zSql, char **pzErrMsg){
tokenType = analyzeFilterKeyword((const u8*)&zSql[6], lastTokenParsed);
#endif /* SQLITE_OMIT_WINDOWFUNC */
}else{
- sqlite3ErrorMsg(pParse, "unrecognized token: \"%.*s\"", n, zSql);
+ Token x;
+ x.z = zSql;
+ x.n = n;
+ sqlite3ErrorMsg(pParse, "unrecognized token: \"%T\"", &x);
break;
}
}
@@ -686,41 +688,26 @@ int sqlite3RunParser(Parse *pParse, const char *zSql, char **pzErrMsg){
if( db->mallocFailed ){
pParse->rc = SQLITE_NOMEM_BKPT;
}
- if( pParse->rc!=SQLITE_OK && pParse->rc!=SQLITE_DONE && pParse->zErrMsg==0 ){
- pParse->zErrMsg = sqlite3MPrintf(db, "%s", sqlite3ErrStr(pParse->rc));
- }
- assert( pzErrMsg!=0 );
- if( pParse->zErrMsg ){
- *pzErrMsg = pParse->zErrMsg;
- sqlite3_log(pParse->rc, "%s in \"%s\"",
- *pzErrMsg, pParse->zTail);
- pParse->zErrMsg = 0;
+ if( pParse->zErrMsg || (pParse->rc!=SQLITE_OK && pParse->rc!=SQLITE_DONE) ){
+ if( pParse->zErrMsg==0 ){
+ pParse->zErrMsg = sqlite3MPrintf(db, "%s", sqlite3ErrStr(pParse->rc));
+ }
+ sqlite3_log(pParse->rc, "%s in \"%s\"", pParse->zErrMsg, pParse->zTail);
nErr++;
}
pParse->zTail = zSql;
- if( pParse->pVdbe && pParse->nErr>0 && pParse->nested==0 ){
- sqlite3VdbeDelete(pParse->pVdbe);
- pParse->pVdbe = 0;
- }
-#ifndef SQLITE_OMIT_SHARED_CACHE
- if( pParse->nested==0 ){
- sqlite3DbFree(db, pParse->aTableLock);
- pParse->aTableLock = 0;
- pParse->nTableLock = 0;
- }
-#endif
#ifndef SQLITE_OMIT_VIRTUALTABLE
sqlite3_free(pParse->apVtabLock);
#endif
- if( !IN_SPECIAL_PARSE ){
+ if( pParse->pNewTable && !IN_SPECIAL_PARSE ){
/* If the pParse->declareVtab flag is set, do not delete any table
** structure built up in pParse->pNewTable. The calling code (see vtab.c)
** will take responsibility for freeing the Table structure.
*/
sqlite3DeleteTable(db, pParse->pNewTable);
}
- if( !IN_RENAME_OBJECT ){
+ if( pParse->pNewTrigger && !IN_RENAME_OBJECT ){
sqlite3DeleteTrigger(db, pParse->pNewTrigger);
}
sqlite3DbFree(db, pParse->pVList);
diff --git a/chromium/third_party/sqlite/src/src/treeview.c b/chromium/third_party/sqlite/src/src/treeview.c
index 1b19ea6797d..86f06e83236 100644
--- a/chromium/third_party/sqlite/src/src/treeview.c
+++ b/chromium/third_party/sqlite/src/src/treeview.c
@@ -412,7 +412,7 @@ void sqlite3TreeViewExpr(TreeView *pView, const Expr *pExpr, u8 moreToFollow){
sqlite3_str_appendf(&x, " fg.af=%x.%c",
pExpr->flags, pExpr->affExpr ? pExpr->affExpr : 'n');
if( ExprHasProperty(pExpr, EP_FromJoin) ){
- sqlite3_str_appendf(&x, " iRJT=%d", pExpr->iRightJoinTable);
+ sqlite3_str_appendf(&x, " iRJT=%d", pExpr->w.iRightJoinTable);
}
if( ExprHasProperty(pExpr, EP_FromDDL) ){
sqlite3_str_appendf(&x, " DDL");
diff --git a/chromium/third_party/sqlite/src/src/trigger.c b/chromium/third_party/sqlite/src/src/trigger.c
index a80ad40734c..5df6b0c0bc8 100644
--- a/chromium/third_party/sqlite/src/src/trigger.c
+++ b/chromium/third_party/sqlite/src/src/trigger.c
@@ -446,6 +446,7 @@ static TriggerStep *triggerStepAllocate(
sqlite3 *db = pParse->db;
TriggerStep *pTriggerStep;
+ if( pParse->nErr ) return 0;
pTriggerStep = sqlite3DbMallocZero(db, sizeof(TriggerStep) + pName->n + 1);
if( pTriggerStep ){
char *z = (char*)&pTriggerStep[1];
@@ -918,6 +919,7 @@ static void codeReturningTrigger(
assert( v!=0 );
assert( pParse->bReturning );
+ assert( db->pParse==pParse );
pReturning = pParse->u1.pReturning;
assert( pTrigger == &(pReturning->retTrig) );
memset(&sSelect, 0, sizeof(sSelect));
@@ -928,12 +930,13 @@ static void codeReturningTrigger(
sFrom.a[0].pTab = pTab;
sFrom.a[0].iCursor = -1;
sqlite3SelectPrep(pParse, &sSelect, 0);
- if( db->mallocFailed==0 && pParse->nErr==0 ){
+ if( pParse->nErr==0 ){
+ assert( db->mallocFailed==0 );
sqlite3GenerateColumnNames(pParse, &sSelect);
}
sqlite3ExprListDelete(db, sSelect.pEList);
pNew = sqlite3ExpandReturning(pParse, pReturning->pReturnEL, pTab);
- if( pNew ){
+ if( !db->mallocFailed ){
NameContext sNC;
memset(&sNC, 0, sizeof(sNC));
if( pReturning->nRetCol==0 ){
@@ -945,7 +948,9 @@ static void codeReturningTrigger(
sNC.ncFlags = NC_UBaseReg;
pParse->eTriggerOp = pTrigger->op;
pParse->pTriggerTab = pTab;
- if( sqlite3ResolveExprListNames(&sNC, pNew)==SQLITE_OK ){
+ if( sqlite3ResolveExprListNames(&sNC, pNew)==SQLITE_OK
+ && ALWAYS(!db->mallocFailed)
+ ){
int i;
int nCol = pNew->nExpr;
int reg = pParse->nMem+1;
@@ -953,16 +958,20 @@ static void codeReturningTrigger(
pReturning->iRetReg = reg;
for(i=0; i<nCol; i++){
Expr *pCol = pNew->a[i].pExpr;
+ assert( pCol!=0 ); /* Due to !db->mallocFailed ~9 lines above */
sqlite3ExprCodeFactorable(pParse, pCol, reg+i);
+ if( sqlite3ExprAffinity(pCol)==SQLITE_AFF_REAL ){
+ sqlite3VdbeAddOp1(v, OP_RealAffinity, reg+i);
+ }
}
sqlite3VdbeAddOp3(v, OP_MakeRecord, reg, i, reg+i);
sqlite3VdbeAddOp2(v, OP_NewRowid, pReturning->iRetCur, reg+i+1);
sqlite3VdbeAddOp3(v, OP_Insert, pReturning->iRetCur, reg+i, reg+i+1);
}
- sqlite3ExprListDelete(db, pNew);
- pParse->eTriggerOp = 0;
- pParse->pTriggerTab = 0;
}
+ sqlite3ExprListDelete(db, pNew);
+ pParse->eTriggerOp = 0;
+ pParse->pTriggerTab = 0;
}
@@ -1104,8 +1113,8 @@ static TriggerPrg *codeRowTrigger(
Vdbe *v; /* Temporary VM */
NameContext sNC; /* Name context for sub-vdbe */
SubProgram *pProgram = 0; /* Sub-vdbe for trigger program */
- Parse *pSubParse; /* Parse context for sub-vdbe */
int iEndTrigger = 0; /* Label to jump to if WHEN is false */
+ Parse sSubParse; /* Parse context for sub-vdbe */
assert( pTrigger->zName==0 || pTab==tableOfTrigger(pTrigger) );
assert( pTop->pVdbe );
@@ -1127,19 +1136,17 @@ static TriggerPrg *codeRowTrigger(
/* Allocate and populate a new Parse context to use for coding the
** trigger sub-program. */
- pSubParse = sqlite3StackAllocZero(db, sizeof(Parse));
- if( !pSubParse ) return 0;
+ sqlite3ParseObjectInit(&sSubParse, db);
memset(&sNC, 0, sizeof(sNC));
- sNC.pParse = pSubParse;
- pSubParse->db = db;
- pSubParse->pTriggerTab = pTab;
- pSubParse->pToplevel = pTop;
- pSubParse->zAuthContext = pTrigger->zName;
- pSubParse->eTriggerOp = pTrigger->op;
- pSubParse->nQueryLoop = pParse->nQueryLoop;
- pSubParse->disableVtab = pParse->disableVtab;
-
- v = sqlite3GetVdbe(pSubParse);
+ sNC.pParse = &sSubParse;
+ sSubParse.pTriggerTab = pTab;
+ sSubParse.pToplevel = pTop;
+ sSubParse.zAuthContext = pTrigger->zName;
+ sSubParse.eTriggerOp = pTrigger->op;
+ sSubParse.nQueryLoop = pParse->nQueryLoop;
+ sSubParse.disableVtab = pParse->disableVtab;
+
+ v = sqlite3GetVdbe(&sSubParse);
if( v ){
VdbeComment((v, "Start: %s.%s (%s %s%s%s ON %s)",
pTrigger->zName, onErrorText(orconf),
@@ -1165,14 +1172,14 @@ static TriggerPrg *codeRowTrigger(
if( db->mallocFailed==0
&& SQLITE_OK==sqlite3ResolveExprNames(&sNC, pWhen)
){
- iEndTrigger = sqlite3VdbeMakeLabel(pSubParse);
- sqlite3ExprIfFalse(pSubParse, pWhen, iEndTrigger, SQLITE_JUMPIFNULL);
+ iEndTrigger = sqlite3VdbeMakeLabel(&sSubParse);
+ sqlite3ExprIfFalse(&sSubParse, pWhen, iEndTrigger, SQLITE_JUMPIFNULL);
}
sqlite3ExprDelete(db, pWhen);
}
/* Code the trigger program into the sub-vdbe. */
- codeTriggerProgram(pSubParse, pTrigger->step_list, orconf);
+ codeTriggerProgram(&sSubParse, pTrigger->step_list, orconf);
/* Insert an OP_Halt at the end of the sub-program. */
if( iEndTrigger ){
@@ -1180,23 +1187,24 @@ static TriggerPrg *codeRowTrigger(
}
sqlite3VdbeAddOp0(v, OP_Halt);
VdbeComment((v, "End: %s.%s", pTrigger->zName, onErrorText(orconf)));
+ transferParseError(pParse, &sSubParse);
- transferParseError(pParse, pSubParse);
- if( db->mallocFailed==0 && pParse->nErr==0 ){
+ if( pParse->nErr==0 ){
+ assert( db->mallocFailed==0 );
pProgram->aOp = sqlite3VdbeTakeOpArray(v, &pProgram->nOp, &pTop->nMaxArg);
}
- pProgram->nMem = pSubParse->nMem;
- pProgram->nCsr = pSubParse->nTab;
+ pProgram->nMem = sSubParse.nMem;
+ pProgram->nCsr = sSubParse.nTab;
pProgram->token = (void *)pTrigger;
- pPrg->aColmask[0] = pSubParse->oldmask;
- pPrg->aColmask[1] = pSubParse->newmask;
+ pPrg->aColmask[0] = sSubParse.oldmask;
+ pPrg->aColmask[1] = sSubParse.newmask;
sqlite3VdbeDelete(v);
+ }else{
+ transferParseError(pParse, &sSubParse);
}
- assert( !pSubParse->pTriggerPrg && !pSubParse->nMaxArg );
- sqlite3ParserReset(pSubParse);
- sqlite3StackFree(db, pSubParse);
-
+ assert( !sSubParse.pTriggerPrg && !sSubParse.nMaxArg );
+ sqlite3ParseObjectReset(&sSubParse);
return pPrg;
}
@@ -1229,6 +1237,7 @@ static TriggerPrg *getRowTrigger(
/* If an existing TriggerPrg could not be located, create a new one. */
if( !pPrg ){
pPrg = codeRowTrigger(pParse, pTrigger, pTab, orconf);
+ pParse->db->errByteOffset = -1;
}
return pPrg;
@@ -1251,7 +1260,7 @@ void sqlite3CodeRowTriggerDirect(
Vdbe *v = sqlite3GetVdbe(pParse); /* Main VM */
TriggerPrg *pPrg;
pPrg = getRowTrigger(pParse, p, pTab, orconf);
- assert( pPrg || pParse->nErr || pParse->db->mallocFailed );
+ assert( pPrg || pParse->nErr );
/* Code the OP_Program opcode in the parent VDBE. P4 of the OP_Program
** is a pointer to the sub-vdbe containing the trigger program. */
diff --git a/chromium/third_party/sqlite/src/src/update.c b/chromium/third_party/sqlite/src/src/update.c
index 484bee47cd8..a43d0eac53c 100644
--- a/chromium/third_party/sqlite/src/src/update.c
+++ b/chromium/third_party/sqlite/src/src/update.c
@@ -347,9 +347,11 @@ void sqlite3Update(
memset(&sContext, 0, sizeof(sContext));
db = pParse->db;
- if( pParse->nErr || db->mallocFailed ){
+ assert( db->pParse==pParse );
+ if( pParse->nErr ){
goto update_cleanup;
}
+ assert( db->mallocFailed==0 );
/* Locate the table which we want to update.
*/
@@ -721,7 +723,7 @@ void sqlite3Update(
if( !pParse->nested && !pTrigger && !hasFK && !chngKey && !bReplace ){
flags |= WHERE_ONEPASS_MULTIROW;
}
- pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere, 0, 0, flags,iIdxCur);
+ pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere,0,0,0,flags,iIdxCur);
if( pWInfo==0 ) goto update_cleanup;
/* A one-pass strategy that might update more than one row may not
@@ -1121,9 +1123,7 @@ void sqlite3Update(
** that information.
*/
if( regRowCount ){
- sqlite3VdbeAddOp2(v, OP_ChngCntRow, regRowCount, 1);
- sqlite3VdbeSetNumCols(v, 1);
- sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "rows updated", SQLITE_STATIC);
+ sqlite3CodeChangeCount(v, regRowCount, "rows updated");
}
update_cleanup:
@@ -1245,7 +1245,9 @@ static void updateVirtualTable(
regRowid = ++pParse->nMem;
/* Start scanning the virtual table */
- pWInfo = sqlite3WhereBegin(pParse, pSrc,pWhere,0,0,WHERE_ONEPASS_DESIRED,0);
+ pWInfo = sqlite3WhereBegin(
+ pParse, pSrc, pWhere, 0, 0, 0, WHERE_ONEPASS_DESIRED, 0
+ );
if( pWInfo==0 ) return;
/* Populate the argument registers. */
diff --git a/chromium/third_party/sqlite/src/src/util.c b/chromium/third_party/sqlite/src/src/util.c
index 8452aea665b..84608739ae2 100644
--- a/chromium/third_party/sqlite/src/src/util.c
+++ b/chromium/third_party/sqlite/src/src/util.c
@@ -117,7 +117,11 @@ static SQLITE_NOINLINE void sqlite3ErrorFinish(sqlite3 *db, int err_code){
void sqlite3Error(sqlite3 *db, int err_code){
assert( db!=0 );
db->errCode = err_code;
- if( err_code || db->pErr ) sqlite3ErrorFinish(db, err_code);
+ if( err_code || db->pErr ){
+ sqlite3ErrorFinish(db, err_code);
+ }else{
+ db->errByteOffset = -1;
+ }
}
/*
@@ -127,6 +131,7 @@ void sqlite3Error(sqlite3 *db, int err_code){
void sqlite3ErrorClear(sqlite3 *db){
assert( db!=0 );
db->errCode = SQLITE_OK;
+ db->errByteOffset = -1;
if( db->pErr ) sqlite3ValueSetNull(db->pErr);
}
@@ -147,17 +152,8 @@ void sqlite3SystemError(sqlite3 *db, int rc){
** handle "db". The error code is set to "err_code".
**
** If it is not NULL, string zFormat specifies the format of the
-** error string in the style of the printf functions: The following
-** format characters are allowed:
-**
-** %s Insert a string
-** %z A string that should be freed after use
-** %d Insert an integer
-** %T Insert a token
-** %S Insert the first element of a SrcList
-**
-** zFormat and any string tokens that follow it are assumed to be
-** encoded in UTF-8.
+** error string. zFormat and any string tokens that follow it are
+** assumed to be encoded in UTF-8.
**
** To clear the most recent error for sqlite handle "db", sqlite3Error
** should be called with err_code set to SQLITE_OK and zFormat set
@@ -181,13 +177,6 @@ void sqlite3ErrorWithMsg(sqlite3 *db, int err_code, const char *zFormat, ...){
/*
** Add an error message to pParse->zErrMsg and increment pParse->nErr.
-** The following formatting characters are allowed:
-**
-** %s Insert a string
-** %z A string that should be freed after use
-** %d Insert an integer
-** %T Insert a token
-** %S Insert the first element of a SrcList
**
** This function should be used to report any error that occurs while
** compiling an SQL statement (i.e. within sqlite3_prepare()). The
@@ -200,11 +189,19 @@ void sqlite3ErrorMsg(Parse *pParse, const char *zFormat, ...){
char *zMsg;
va_list ap;
sqlite3 *db = pParse->db;
+ assert( db!=0 );
+ assert( db->pParse==pParse );
+ db->errByteOffset = -2;
va_start(ap, zFormat);
zMsg = sqlite3VMPrintf(db, zFormat, ap);
va_end(ap);
+ if( db->errByteOffset<-1 ) db->errByteOffset = -1;
if( db->suppressErr ){
sqlite3DbFree(db, zMsg);
+ if( db->mallocFailed ){
+ pParse->nErr++;
+ pParse->rc = SQLITE_NOMEM;
+ }
}else{
pParse->nErr++;
sqlite3DbFree(db, pParse->zErrMsg);
@@ -1586,7 +1583,6 @@ LogEst sqlite3LogEst(u64 x){
return a[x&7] + y - 10;
}
-#ifndef SQLITE_OMIT_VIRTUALTABLE
/*
** Convert a double into a LogEst
** In other words, compute an approximation for 10*log2(x).
@@ -1601,16 +1597,9 @@ LogEst sqlite3LogEstFromDouble(double x){
e = (a>>52) - 1022;
return e*10;
}
-#endif /* SQLITE_OMIT_VIRTUALTABLE */
-#if defined(SQLITE_ENABLE_STMT_SCANSTATUS) || \
- defined(SQLITE_ENABLE_STAT4) || \
- defined(SQLITE_EXPLAIN_ESTIMATED_ROWS)
/*
** Convert a LogEst into an integer.
-**
-** Note that this routine is only used when one or more of various
-** non-standard compile-time options is enabled.
*/
u64 sqlite3LogEstToInt(LogEst x){
u64 n;
@@ -1618,17 +1607,9 @@ u64 sqlite3LogEstToInt(LogEst x){
x /= 10;
if( n>=5 ) n -= 2;
else if( n>=1 ) n -= 1;
-#if defined(SQLITE_ENABLE_STMT_SCANSTATUS) || \
- defined(SQLITE_EXPLAIN_ESTIMATED_ROWS)
if( x>60 ) return (u64)LARGEST_INT64;
-#else
- /* If only SQLITE_ENABLE_STAT4 is on, then the largest input
- ** possible to this routine is 310, resulting in a maximum x of 31 */
- assert( x<=60 );
-#endif
return x>=3 ? (n+8)<<(x-3) : (n+8)>>(3-x);
}
-#endif /* defined SCANSTAT or STAT4 or ESTIMATED_ROWS */
/*
** Add a new name/number pair to a VList. This might require that the
diff --git a/chromium/third_party/sqlite/src/src/vdbe.c b/chromium/third_party/sqlite/src/src/vdbe.c
index 3476c02daa9..fa56689dff5 100644
--- a/chromium/third_party/sqlite/src/src/vdbe.c
+++ b/chromium/third_party/sqlite/src/src/vdbe.c
@@ -241,7 +241,6 @@ static VdbeCursor *allocateCursor(
Vdbe *p, /* The virtual machine */
int iCur, /* Index of the new VdbeCursor */
int nField, /* Number of fields in the table or index */
- int iDb, /* Database the cursor belongs to, or -1 */
u8 eCurType /* Type of the new cursor */
){
/* Find the memory cell that will be used to store the blob of memory
@@ -298,7 +297,6 @@ static VdbeCursor *allocateCursor(
p->apCsr[iCur] = pCx = (VdbeCursor*)pMem->zMalloc;
memset(pCx, 0, offsetof(VdbeCursor,pAltCursor));
pCx->eCurType = eCurType;
- pCx->iDb = iDb;
pCx->nField = nField;
pCx->aOffset = &pCx->aType[nField];
if( eCurType==CURTYPE_BTREE ){
@@ -672,6 +670,29 @@ static Mem *out2Prerelease(Vdbe *p, VdbeOp *pOp){
}
/*
+** Compute a bloom filter hash using pOp->p4.i registers from aMem[] beginning
+** with pOp->p3. Return the hash.
+*/
+static u64 filterHash(const Mem *aMem, const Op *pOp){
+ int i, mx;
+ u64 h = 0;
+
+ assert( pOp->p4type==P4_INT32 );
+ for(i=pOp->p3, mx=i+pOp->p4.i; i<mx; i++){
+ const Mem *p = &aMem[i];
+ if( p->flags & (MEM_Int|MEM_IntReal) ){
+ h += p->u.i;
+ }else if( p->flags & MEM_Real ){
+ h += sqlite3VdbeIntValue(p);
+ }else if( p->flags & (MEM_Str|MEM_Blob) ){
+ h += p->n;
+ if( p->flags & MEM_Zero ) h += p->u.nZero;
+ }
+ }
+ return h;
+}
+
+/*
** Return the symbolic name for the data type of a pMem
*/
static const char *vdbeMemTypeName(Mem *pMem){
@@ -1325,12 +1346,18 @@ case OP_SoftNull: {
** Synopsis: r[P2]=P4 (len=P1)
**
** P4 points to a blob of data P1 bytes long. Store this
-** blob in register P2.
+** blob in register P2. If P4 is a NULL pointer, then construct
+** a zero-filled blob that is P1 bytes long in P2.
*/
case OP_Blob: { /* out2 */
assert( pOp->p1 <= SQLITE_MAX_LENGTH );
pOut = out2Prerelease(p, pOp);
- sqlite3VdbeMemSetStr(pOut, pOp->p4.z, pOp->p1, 0, 0);
+ if( pOp->p4.z==0 ){
+ sqlite3VdbeMemSetZeroBlob(pOut, pOp->p1);
+ if( sqlite3VdbeMemExpandBlob(pOut) ) goto no_mem;
+ }else{
+ sqlite3VdbeMemSetStr(pOut, pOp->p4.z, pOp->p1, 0, 0);
+ }
pOut->enc = encoding;
UPDATE_MAX_BLOBSIZE(pOut);
break;
@@ -1479,24 +1506,22 @@ case OP_IntCopy: { /* out2 */
break;
}
-/* Opcode: ChngCntRow P1 P2 * * *
-** Synopsis: output=r[P1]
+/* Opcode: FkCheck * * * * *
**
-** Output value in register P1 as the chance count for a DML statement,
-** due to the "PRAGMA count_changes=ON" setting. Or, if there was a
-** foreign key error in the statement, trigger the error now.
+** Halt with an SQLITE_CONSTRAINT error if there are any unresolved
+** foreign key constraint violations. If there are no foreign key
+** constraint violations, this is a no-op.
**
-** This opcode is a variant of OP_ResultRow that checks the foreign key
-** immediate constraint count and throws an error if the count is
-** non-zero. The P2 opcode must be 1.
+** FK constraint violations are also checked when the prepared statement
+** exits. This opcode is used to raise foreign key constraint errors prior
+** to returning results such as a row change count or the result of a
+** RETURNING clause.
*/
-case OP_ChngCntRow: {
- assert( pOp->p2==1 );
+case OP_FkCheck: {
if( (rc = sqlite3VdbeCheckFk(p,0))!=SQLITE_OK ){
goto abort_due_to_error;
}
- /* Fall through to the next case, OP_ResultRow */
- /* no break */ deliberate_fall_through
+ break;
}
/* Opcode: ResultRow P1 P2 * * *
@@ -2134,7 +2159,7 @@ case OP_Ge: { /* same as TK_GE, jump, in1, in3 */
sqlite3VdbeMemStringify(pIn1, encoding, 1);
testcase( (flags1&MEM_Dyn) != (pIn1->flags&MEM_Dyn) );
flags1 = (pIn1->flags & ~MEM_TypeMask) | (flags1 & MEM_TypeMask);
- if( NEVER(pIn1==pIn3) ) flags3 = flags1 | MEM_Str;
+ if( pIn1==pIn3 ) flags3 = flags1 | MEM_Str;
}
if( (flags3 & MEM_Str)==0 && (flags3&(MEM_Int|MEM_Real|MEM_IntReal))!=0 ){
testcase( pIn3->flags & MEM_Int );
@@ -2602,10 +2627,18 @@ case OP_Offset: { /* out3 */
assert( pOp->p1>=0 && pOp->p1<p->nCursor );
pC = p->apCsr[pOp->p1];
pOut = &p->aMem[pOp->p3];
- if( NEVER(pC==0) || pC->eCurType!=CURTYPE_BTREE ){
+ if( pC==0 || pC->eCurType!=CURTYPE_BTREE ){
sqlite3VdbeMemSetNull(pOut);
}else{
- sqlite3VdbeMemSetInt64(pOut, sqlite3BtreeOffset(pC->uc.pCursor));
+ if( pC->deferredMoveto ){
+ rc = sqlite3VdbeFinishMoveto(pC);
+ if( rc ) goto abort_due_to_error;
+ }
+ if( sqlite3BtreeEof(pC->uc.pCursor) ){
+ sqlite3VdbeMemSetNull(pOut);
+ }else{
+ sqlite3VdbeMemSetInt64(pOut, sqlite3BtreeOffset(pC->uc.pCursor));
+ }
}
break;
}
@@ -2664,6 +2697,7 @@ case OP_Column: {
assert( pC!=0 );
assert( p2<(u32)pC->nField );
aOffset = pC->aOffset;
+ assert( aOffset==pC->aType+pC->nField );
assert( pC->eCurType!=CURTYPE_VTAB );
assert( pC->eCurType!=CURTYPE_PSEUDO || pC->nullRow );
assert( pC->eCurType!=CURTYPE_SORTER );
@@ -2959,6 +2993,8 @@ case OP_TypeCheck: {
break;
}
case COLTYPE_REAL: {
+ testcase( (pIn1->flags & (MEM_Real|MEM_IntReal))==MEM_Real );
+ testcase( (pIn1->flags & (MEM_Real|MEM_IntReal))==MEM_IntReal );
if( pIn1->flags & MEM_Int ){
/* When applying REAL affinity, if the result is still an MEM_Int
** that will fit in 6 bytes, then change the type to MEM_IntReal
@@ -2976,7 +3012,7 @@ case OP_TypeCheck: {
pIn1->flags |= MEM_Real;
pIn1->flags &= ~MEM_Int;
}
- }else if( (pIn1->flags & MEM_Real)==0 ){
+ }else if( (pIn1->flags & (MEM_Real|MEM_IntReal))==0 ){
goto vdbe_type_error;
}
break;
@@ -3215,7 +3251,7 @@ case OP_MakeRecord: {
testcase( uu==127 ); testcase( uu==128 );
testcase( uu==32767 ); testcase( uu==32768 );
testcase( uu==8388607 ); testcase( uu==8388608 );
- testcase( uu==2147483647 ); testcase( uu==2147483648 );
+ testcase( uu==2147483647 ); testcase( uu==2147483648LL );
testcase( uu==140737488355327LL ); testcase( uu==140737488355328LL );
if( uu<=127 ){
if( (i&1)==i && file_format>=4 ){
@@ -3343,7 +3379,7 @@ case OP_MakeRecord: {
break;
}
-/* Opcode: Count P1 P2 p3 * *
+/* Opcode: Count P1 P2 P3 * *
** Synopsis: r[P2]=count()
**
** Store the number of entries (an integer value) in the table or index
@@ -3813,6 +3849,7 @@ case OP_SetCookie: {
/* When the schema cookie changes, record the new cookie internally */
pDb->pSchema->schema_cookie = pOp->p3 - pOp->p5;
db->mDbFlags |= DBFLAG_SchemaChange;
+ sqlite3FkClearTriggerCache(db, pOp->p1);
}else if( pOp->p2==BTREE_FILE_FORMAT ){
/* Record changes in the file format */
pDb->pSchema->file_format = pOp->p3;
@@ -3990,8 +4027,9 @@ case OP_OpenWrite:
assert( pOp->p1>=0 );
assert( nField>=0 );
testcase( nField==0 ); /* Table with INTEGER PRIMARY KEY and nothing else */
- pCur = allocateCursor(p, pOp->p1, nField, iDb, CURTYPE_BTREE);
+ pCur = allocateCursor(p, pOp->p1, nField, CURTYPE_BTREE);
if( pCur==0 ) goto no_mem;
+ pCur->iDb = iDb;
pCur->nullRow = 1;
pCur->isOrdered = 1;
pCur->pgnoRoot = p2;
@@ -4033,7 +4071,7 @@ case OP_OpenDup: {
assert( pOrig );
assert( pOrig->isEphemeral ); /* Only ephemeral cursors can be duplicated */
- pCx = allocateCursor(p, pOp->p1, pOrig->nField, -1, CURTYPE_BTREE);
+ pCx = allocateCursor(p, pOp->p1, pOrig->nField, CURTYPE_BTREE);
if( pCx==0 ) goto no_mem;
pCx->nullRow = 1;
pCx->isEphemeral = 1;
@@ -4041,10 +4079,10 @@ case OP_OpenDup: {
pCx->isTable = pOrig->isTable;
pCx->pgnoRoot = pOrig->pgnoRoot;
pCx->isOrdered = pOrig->isOrdered;
- pCx->pBtx = pOrig->pBtx;
+ pCx->ub.pBtx = pOrig->ub.pBtx;
pCx->hasBeenDuped = 1;
pOrig->hasBeenDuped = 1;
- rc = sqlite3BtreeCursor(pCx->pBtx, pCx->pgnoRoot, BTREE_WRCSR,
+ rc = sqlite3BtreeCursor(pCx->ub.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
@@ -4117,16 +4155,16 @@ case OP_OpenEphemeral: {
assert( pCx->isEphemeral );
pCx->seqCount = 0;
pCx->cacheStatus = CACHE_STALE;
- rc = sqlite3BtreeClearTable(pCx->pBtx, pCx->pgnoRoot, 0);
+ rc = sqlite3BtreeClearTable(pCx->ub.pBtx, pCx->pgnoRoot, 0);
}else{
- pCx = allocateCursor(p, pOp->p1, pOp->p2, -1, CURTYPE_BTREE);
+ pCx = allocateCursor(p, pOp->p1, pOp->p2, CURTYPE_BTREE);
if( pCx==0 ) goto no_mem;
pCx->isEphemeral = 1;
- rc = sqlite3BtreeOpen(db->pVfs, 0, db, &pCx->pBtx,
+ rc = sqlite3BtreeOpen(db->pVfs, 0, db, &pCx->ub.pBtx,
BTREE_OMIT_JOURNAL | BTREE_SINGLE | pOp->p5,
vfsFlags);
if( rc==SQLITE_OK ){
- rc = sqlite3BtreeBeginTrans(pCx->pBtx, 1, 0);
+ rc = sqlite3BtreeBeginTrans(pCx->ub.pBtx, 1, 0);
if( rc==SQLITE_OK ){
/* If a transient index is required, create it by calling
** sqlite3BtreeCreateTable() with the BTREE_BLOBKEY flag before
@@ -4135,26 +4173,26 @@ case OP_OpenEphemeral: {
*/
if( (pCx->pKeyInfo = pKeyInfo = pOp->p4.pKeyInfo)!=0 ){
assert( pOp->p4type==P4_KEYINFO );
- rc = sqlite3BtreeCreateTable(pCx->pBtx, &pCx->pgnoRoot,
+ rc = sqlite3BtreeCreateTable(pCx->ub.pBtx, &pCx->pgnoRoot,
BTREE_BLOBKEY | pOp->p5);
if( rc==SQLITE_OK ){
assert( pCx->pgnoRoot==SCHEMA_ROOT+1 );
assert( pKeyInfo->db==db );
assert( pKeyInfo->enc==ENC(db) );
- rc = sqlite3BtreeCursor(pCx->pBtx, pCx->pgnoRoot, BTREE_WRCSR,
+ rc = sqlite3BtreeCursor(pCx->ub.pBtx, pCx->pgnoRoot, BTREE_WRCSR,
pKeyInfo, pCx->uc.pCursor);
}
pCx->isTable = 0;
}else{
pCx->pgnoRoot = SCHEMA_ROOT;
- rc = sqlite3BtreeCursor(pCx->pBtx, SCHEMA_ROOT, BTREE_WRCSR,
+ rc = sqlite3BtreeCursor(pCx->ub.pBtx, SCHEMA_ROOT, BTREE_WRCSR,
0, pCx->uc.pCursor);
pCx->isTable = 1;
}
}
pCx->isOrdered = (pOp->p5!=BTREE_UNORDERED);
if( rc ){
- sqlite3BtreeClose(pCx->pBtx);
+ sqlite3BtreeClose(pCx->ub.pBtx);
}
}
}
@@ -4178,7 +4216,7 @@ case OP_SorterOpen: {
assert( pOp->p1>=0 );
assert( pOp->p2>=0 );
- pCx = allocateCursor(p, pOp->p1, pOp->p2, -1, CURTYPE_SORTER);
+ pCx = allocateCursor(p, pOp->p1, pOp->p2, CURTYPE_SORTER);
if( pCx==0 ) goto no_mem;
pCx->pKeyInfo = pOp->p4.pKeyInfo;
assert( pCx->pKeyInfo->db==db );
@@ -4227,7 +4265,7 @@ case OP_OpenPseudo: {
assert( pOp->p1>=0 );
assert( pOp->p3>=0 );
- pCx = allocateCursor(p, pOp->p1, pOp->p3, -1, CURTYPE_PSEUDO);
+ pCx = allocateCursor(p, pOp->p1, pOp->p3, CURTYPE_PSEUDO);
if( pCx==0 ) goto no_mem;
pCx->nullRow = 1;
pCx->seekResult = pOp->p2;
@@ -5679,6 +5717,10 @@ case OP_Rowid: { /* out2 */
** Move the cursor P1 to a null row. Any OP_Column operations
** that occur while the cursor is on the null row will always
** write a NULL.
+**
+** Or, if P1 is a Pseudo-Cursor (a cursor opened using OP_OpenPseudo)
+** just reset the cache for that cursor. This causes the row of
+** content held by the pseudo-cursor to be reparsed.
*/
case OP_NullRow: {
VdbeCursor *pC;
@@ -6167,9 +6209,9 @@ case OP_IdxRowid: { /* out2 */
pTabCur->movetoTarget = rowid;
pTabCur->deferredMoveto = 1;
assert( pOp->p4type==P4_INTARRAY || pOp->p4.ai==0 );
- pTabCur->aAltMap = pOp->p4.ai;
- assert( !pC->isEphemeral );
assert( !pTabCur->isEphemeral );
+ pTabCur->ub.aAltMap = pOp->p4.ai;
+ assert( !pC->isEphemeral );
pTabCur->pAltCursor = pC;
}else{
pOut = out2Prerelease(p, pOp);
@@ -7691,7 +7733,7 @@ case OP_VOpen: {
pVCur->pVtab = pVtab;
/* Initialize vdbe cursor object */
- pCur = allocateCursor(p, pOp->p1, 0, -1, CURTYPE_VTAB);
+ pCur = allocateCursor(p, pOp->p1, 0, CURTYPE_VTAB);
if( pCur ){
pCur->uc.pVCur = pVCur;
pVtab->nRef++;
@@ -7705,6 +7747,34 @@ case OP_VOpen: {
#endif /* SQLITE_OMIT_VIRTUALTABLE */
#ifndef SQLITE_OMIT_VIRTUALTABLE
+/* Opcode: VInitIn P1 P2 P3 * *
+** Synopsis: r[P2]=ValueList(P1,P3)
+**
+** Set register P2 to be a pointer to a ValueList object for cursor P1
+** with cache register P3 and output register P3+1. This ValueList object
+** can be used as the first argument to sqlite3_vtab_in_first() and
+** sqlite3_vtab_in_next() to extract all of the values stored in the P1
+** cursor. Register P3 is used to hold the values returned by
+** sqlite3_vtab_in_first() and sqlite3_vtab_in_next().
+*/
+case OP_VInitIn: { /* out2 */
+ VdbeCursor *pC; /* The cursor containing the RHS values */
+ ValueList *pRhs; /* New ValueList object to put in reg[P2] */
+
+ pC = p->apCsr[pOp->p1];
+ pRhs = sqlite3_malloc64( sizeof(*pRhs) );
+ if( pRhs==0 ) goto no_mem;
+ pRhs->pCsr = pC->uc.pCursor;
+ pRhs->pOut = &aMem[pOp->p3];
+ pOut = out2Prerelease(p, pOp);
+ pOut->flags = MEM_Null;
+ sqlite3VdbeMemSetPointer(pOut, pRhs, "ValueList", sqlite3_free);
+ break;
+}
+#endif /* SQLITE_OMIT_VIRTUALTABLE */
+
+
+#ifndef SQLITE_OMIT_VIRTUALTABLE
/* Opcode: VFilter P1 P2 P3 P4 *
** Synopsis: iplan=r[P3] zplan='P4'
**
@@ -8129,6 +8199,77 @@ case OP_Function: { /* group */
break;
}
+/* Opcode: FilterAdd P1 * P3 P4 *
+** Synopsis: filter(P1) += key(P3@P4)
+**
+** Compute a hash on the P4 registers starting with r[P3] and
+** add that hash to the bloom filter contained in r[P1].
+*/
+case OP_FilterAdd: {
+ u64 h;
+
+ assert( pOp->p1>0 && pOp->p1<=(p->nMem+1 - p->nCursor) );
+ pIn1 = &aMem[pOp->p1];
+ assert( pIn1->flags & MEM_Blob );
+ assert( pIn1->n>0 );
+ h = filterHash(aMem, pOp);
+#ifdef SQLITE_DEBUG
+ if( db->flags&SQLITE_VdbeTrace ){
+ int ii;
+ for(ii=pOp->p3; ii<pOp->p3+pOp->p4.i; ii++){
+ registerTrace(ii, &aMem[ii]);
+ }
+ printf("hash: %llu modulo %d -> %u\n", h, pIn1->n, (int)(h%pIn1->n));
+ }
+#endif
+ h %= pIn1->n;
+ pIn1->z[h/8] |= 1<<(h&7);
+ break;
+}
+
+/* Opcode: Filter P1 P2 P3 P4 *
+** Synopsis: if key(P3@P4) not in filter(P1) goto P2
+**
+** Compute a hash on the key contained in the P4 registers starting
+** with r[P3]. Check to see if that hash is found in the
+** bloom filter hosted by register P1. If it is not present then
+** maybe jump to P2. Otherwise fall through.
+**
+** False negatives are harmless. It is always safe to fall through,
+** even if the value is in the bloom filter. A false negative causes
+** more CPU cycles to be used, but it should still yield the correct
+** answer. However, an incorrect answer may well arise from a
+** false positive - if the jump is taken when it should fall through.
+*/
+case OP_Filter: { /* jump */
+ u64 h;
+
+ assert( pOp->p1>0 && pOp->p1<=(p->nMem+1 - p->nCursor) );
+ pIn1 = &aMem[pOp->p1];
+ assert( (pIn1->flags & MEM_Blob)!=0 );
+ assert( pIn1->n >= 1 );
+ h = filterHash(aMem, pOp);
+#ifdef SQLITE_DEBUG
+ if( db->flags&SQLITE_VdbeTrace ){
+ int ii;
+ for(ii=pOp->p3; ii<pOp->p3+pOp->p4.i; ii++){
+ registerTrace(ii, &aMem[ii]);
+ }
+ printf("hash: %llu modulo %d -> %u\n", h, pIn1->n, (int)(h%pIn1->n));
+ }
+#endif
+ h %= pIn1->n;
+ if( (pIn1->z[h/8] & (1<<(h&7)))==0 ){
+ VdbeBranchTaken(1, 2);
+ p->aCounter[SQLITE_STMTSTATUS_FILTER_HIT]++;
+ goto jump_to_p2;
+ }else{
+ p->aCounter[SQLITE_STMTSTATUS_FILTER_MISS]++;
+ VdbeBranchTaken(0, 2);
+ }
+ break;
+}
+
/* Opcode: Trace P1 P2 * P4 *
**
** Write P4 on the statement trace output if statement tracing is
diff --git a/chromium/third_party/sqlite/src/src/vdbeInt.h b/chromium/third_party/sqlite/src/src/vdbeInt.h
index 599d064165b..f02b37c6a29 100644
--- a/chromium/third_party/sqlite/src/src/vdbeInt.h
+++ b/chromium/third_party/sqlite/src/src/vdbeInt.h
@@ -75,7 +75,7 @@ typedef struct AuxData AuxData;
typedef struct VdbeCursor VdbeCursor;
struct VdbeCursor {
u8 eCurType; /* One of the CURTYPE_* values above */
- i8 iDb; /* Index of cursor database in db->aDb[] (or -1) */
+ i8 iDb; /* Index of cursor database in db->aDb[] */
u8 nullRow; /* True if pointing to a row with no data */
u8 deferredMoveto; /* A call to sqlite3BtreeMoveto() is needed */
u8 isTable; /* True for rowid tables. False for indexes */
@@ -88,9 +88,11 @@ struct VdbeCursor {
Bool isOrdered:1; /* True if the table is not BTREE_UNORDERED */
Bool hasBeenDuped:1; /* This cursor was source or target of OP_OpenDup */
u16 seekHit; /* See the OP_SeekHit and OP_IfNoHope opcodes */
- Btree *pBtx; /* Separate file holding temporary table */
+ union { /* pBtx for isEphermeral. pAltMap otherwise */
+ Btree *pBtx; /* Separate file holding temporary table */
+ u32 *aAltMap; /* Mapping from table to index column numbers */
+ } ub;
i64 seqCount; /* Sequence counter */
- u32 *aAltMap; /* Mapping from table to index column numbers */
/* Cached OP_Column parse information is only valid if cacheStatus matches
** Vdbe.cacheCtr. Vdbe.cacheCtr will never take on the value of
@@ -430,7 +432,7 @@ struct Vdbe {
bft bIsReader:1; /* True for statements that read */
yDbMask btreeMask; /* Bitmask of db->aDb[] entries referenced */
yDbMask lockMask; /* Subset of btreeMask that requires a lock */
- u32 aCounter[7]; /* Counters used by sqlite3_stmt_status() */
+ u32 aCounter[9]; /* Counters used by sqlite3_stmt_status() */
char *zSql; /* Text of the SQL statement that generated this */
#ifdef SQLITE_ENABLE_NORMALIZE
char *zNormSql; /* Normalization of the associated SQL statement */
@@ -481,6 +483,24 @@ struct PreUpdate {
};
/*
+** An instance of this object is used to pass an vector of values into
+** OP_VFilter, the xFilter method of a virtual table. The vector is the
+** set of values on the right-hand side of an IN constraint.
+**
+** The value as passed into xFilter is an sqlite3_value with a "pointer"
+** type, such as is generated by sqlite3_result_pointer() and read by
+** sqlite3_value_pointer. Such values have MEM_Term|MEM_Subtype|MEM_Null
+** and a subtype of 'p'. The sqlite3_vtab_in_first() and _next() interfaces
+** know how to use this object to step through all the values in the
+** right operand of the IN constraint.
+*/
+typedef struct ValueList ValueList;
+struct ValueList {
+ BtCursor *pCsr; /* An ephemeral table holding all values */
+ sqlite3_value *pOut; /* Register to hold each decoded output value */
+};
+
+/*
** Function prototypes
*/
void sqlite3VdbeError(Vdbe*, const char *, ...);
@@ -492,7 +512,7 @@ int sqlite3VdbeCursorRestore(VdbeCursor*);
u32 sqlite3VdbeSerialTypeLen(u32);
u8 sqlite3VdbeOneByteSerialTypeLen(u8);
u32 sqlite3VdbeSerialPut(unsigned char*, Mem*, u32);
-u32 sqlite3VdbeSerialGet(const unsigned char*, u32, Mem*);
+void sqlite3VdbeSerialGet(const unsigned char*, u32, Mem*);
void sqlite3VdbeDeleteAuxData(sqlite3*, AuxData**, int, int);
int sqlite2BtreeKeyCompare(BtCursor *, const void *, int, int, int *);
@@ -538,7 +558,7 @@ int sqlite3VdbeMemSetRowSet(Mem*);
int sqlite3VdbeMemMakeWriteable(Mem*);
int sqlite3VdbeMemStringify(Mem*, u8, u8);
int sqlite3IntFloatCompare(i64,double);
-i64 sqlite3VdbeIntValue(Mem*);
+i64 sqlite3VdbeIntValue(const Mem*);
int sqlite3VdbeMemIntegerify(Mem*);
double sqlite3VdbeRealValue(Mem*);
int sqlite3VdbeBooleanValue(Mem*, int ifNull);
diff --git a/chromium/third_party/sqlite/src/src/vdbeapi.c b/chromium/third_party/sqlite/src/src/vdbeapi.c
index 17df807de4c..6939813a275 100644
--- a/chromium/third_party/sqlite/src/src/vdbeapi.c
+++ b/chromium/third_party/sqlite/src/src/vdbeapi.c
@@ -847,6 +847,70 @@ int sqlite3_vtab_nochange(sqlite3_context *p){
}
/*
+** Implementation of sqlite3_vtab_in_first() (if bNext==0) and
+** sqlite3_vtab_in_next() (if bNext!=0).
+*/
+static int valueFromValueList(
+ sqlite3_value *pVal, /* Pointer to the ValueList object */
+ sqlite3_value **ppOut, /* Store the next value from the list here */
+ int bNext /* 1 for _next(). 0 for _first() */
+){
+ int rc;
+ ValueList *pRhs;
+
+ *ppOut = 0;
+ if( pVal==0 ) return SQLITE_MISUSE;
+ pRhs = (ValueList*)sqlite3_value_pointer(pVal, "ValueList");
+ if( pRhs==0 ) return SQLITE_MISUSE;
+ if( bNext ){
+ rc = sqlite3BtreeNext(pRhs->pCsr, 0);
+ }else{
+ int dummy = 0;
+ rc = sqlite3BtreeFirst(pRhs->pCsr, &dummy);
+ assert( rc==SQLITE_OK || sqlite3BtreeEof(pRhs->pCsr) );
+ if( sqlite3BtreeEof(pRhs->pCsr) ) rc = SQLITE_DONE;
+ }
+ if( rc==SQLITE_OK ){
+ u32 sz; /* Size of current row in bytes */
+ Mem sMem; /* Raw content of current row */
+ memset(&sMem, 0, sizeof(sMem));
+ sz = sqlite3BtreePayloadSize(pRhs->pCsr);
+ rc = sqlite3VdbeMemFromBtreeZeroOffset(pRhs->pCsr,(int)sz,&sMem);
+ if( rc==SQLITE_OK ){
+ u8 *zBuf = (u8*)sMem.z;
+ u32 iSerial;
+ sqlite3_value *pOut = pRhs->pOut;
+ int iOff = 1 + getVarint32(&zBuf[1], iSerial);
+ sqlite3VdbeSerialGet(&zBuf[iOff], iSerial, pOut);
+ pOut->enc = ENC(pOut->db);
+ if( (pOut->flags & MEM_Ephem)!=0 && sqlite3VdbeMemMakeWriteable(pOut) ){
+ rc = SQLITE_NOMEM;
+ }else{
+ *ppOut = pOut;
+ }
+ }
+ sqlite3VdbeMemRelease(&sMem);
+ }
+ return rc;
+}
+
+/*
+** Set the iterator value pVal to point to the first value in the set.
+** Set (*ppOut) to point to this value before returning.
+*/
+int sqlite3_vtab_in_first(sqlite3_value *pVal, sqlite3_value **ppOut){
+ return valueFromValueList(pVal, ppOut, 0);
+}
+
+/*
+** Set the iterator value pVal to point to the next value in the set.
+** Set (*ppOut) to point to this value before returning.
+*/
+int sqlite3_vtab_in_next(sqlite3_value *pVal, sqlite3_value **ppOut){
+ return valueFromValueList(pVal, ppOut, 1);
+}
+
+/*
** Return the current time for a statement. If the current time
** is requested more than once within the same run of a single prepared
** statement, the exact same time is returned for each invocation regardless
@@ -1530,7 +1594,10 @@ int sqlite3_bind_value(sqlite3_stmt *pStmt, int i, const sqlite3_value *pValue){
break;
}
case SQLITE_FLOAT: {
- rc = sqlite3_bind_double(pStmt, i, pValue->u.r);
+ assert( pValue->flags & (MEM_Real|MEM_IntReal) );
+ rc = sqlite3_bind_double(pStmt, i,
+ (pValue->flags & MEM_Real) ? pValue->u.r : (double)pValue->u.i
+ );
break;
}
case SQLITE_BLOB: {
diff --git a/chromium/third_party/sqlite/src/src/vdbeaux.c b/chromium/third_party/sqlite/src/src/vdbeaux.c
index f03196bffe8..0f3d0eb877f 100644
--- a/chromium/third_party/sqlite/src/src/vdbeaux.c
+++ b/chromium/third_party/sqlite/src/src/vdbeaux.c
@@ -1378,8 +1378,7 @@ void sqlite3VdbeSetP4KeyInfo(Parse *pParse, Index *pIdx){
*/
static void vdbeVComment(Vdbe *p, const char *zFormat, va_list ap){
assert( p->nOp>0 || p->aOp==0 );
- assert( p->aOp==0 || p->aOp[p->nOp-1].zComment==0 || p->db->mallocFailed
- || p->pParse->nErr>0 );
+ assert( p->aOp==0 || p->aOp[p->nOp-1].zComment==0 || p->pParse->nErr>0 );
if( p->nOp ){
assert( p->aOp );
sqlite3DbFree(p->db, p->aOp[p->nOp-1].zComment);
@@ -2470,8 +2469,6 @@ void sqlite3VdbeFreeCursor(Vdbe *p, VdbeCursor *pCx){
if( pCx==0 ){
return;
}
- assert( pCx->pBtx==0 || pCx->eCurType==CURTYPE_BTREE );
- assert( pCx->pBtx==0 || pCx->isEphemeral );
switch( pCx->eCurType ){
case CURTYPE_SORTER: {
sqlite3VdbeSorterClose(p->db, pCx);
@@ -3252,6 +3249,7 @@ int sqlite3VdbeTransferError(Vdbe *p){
sqlite3ValueSetNull(db->pErr);
}
db->errCode = rc;
+ db->errByteOffset = -1;
return rc;
}
@@ -3573,7 +3571,7 @@ int sqlite3VdbeCursorMoveto(VdbeCursor **pp, u32 *piCol){
if( p->deferredMoveto ){
u32 iMap;
assert( !p->isEphemeral );
- if( p->aAltMap && (iMap = p->aAltMap[1+*piCol])>0 && !p->nullRow ){
+ if( p->ub.aAltMap && (iMap = p->ub.aAltMap[1+*piCol])>0 && !p->nullRow ){
*pp = p->pAltCursor;
*piCol = iMap - 1;
return SQLITE_OK;
@@ -3851,14 +3849,14 @@ u32 sqlite3VdbeSerialPut(u8 *buf, Mem *pMem, u32 serial_type){
/*
** Deserialize the data blob pointed to by buf as serial type serial_type
-** and store the result in pMem. Return the number of bytes read.
+** and store the result in pMem.
**
** This function is implemented as two separate routines for performance.
** The few cases that require local variables are broken out into a separate
** routine so that in most cases the overhead of moving the stack pointer
** is avoided.
*/
-static u32 serialGet(
+static void serialGet(
const unsigned char *buf, /* Buffer to deserialize from */
u32 serial_type, /* Serial type to deserialize */
Mem *pMem /* Memory cell to write value into */
@@ -3892,9 +3890,8 @@ static u32 serialGet(
memcpy(&pMem->u.r, &x, sizeof(x));
pMem->flags = IsNaN(x) ? MEM_Null : MEM_Real;
}
- return 8;
}
-u32 sqlite3VdbeSerialGet(
+void sqlite3VdbeSerialGet(
const unsigned char *buf, /* Buffer to deserialize from */
u32 serial_type, /* Serial type to deserialize */
Mem *pMem /* Memory cell to write value into */
@@ -3905,13 +3902,13 @@ u32 sqlite3VdbeSerialGet(
pMem->flags = MEM_Null|MEM_Zero;
pMem->n = 0;
pMem->u.nZero = 0;
- break;
+ return;
}
case 11: /* Reserved for future use */
case 0: { /* Null */
/* EVIDENCE-OF: R-24078-09375 Value is a NULL. */
pMem->flags = MEM_Null;
- break;
+ return;
}
case 1: {
/* EVIDENCE-OF: R-44885-25196 Value is an 8-bit twos-complement
@@ -3919,7 +3916,7 @@ u32 sqlite3VdbeSerialGet(
pMem->u.i = ONE_BYTE_INT(buf);
pMem->flags = MEM_Int;
testcase( pMem->u.i<0 );
- return 1;
+ return;
}
case 2: { /* 2-byte signed integer */
/* EVIDENCE-OF: R-49794-35026 Value is a big-endian 16-bit
@@ -3927,7 +3924,7 @@ u32 sqlite3VdbeSerialGet(
pMem->u.i = TWO_BYTE_INT(buf);
pMem->flags = MEM_Int;
testcase( pMem->u.i<0 );
- return 2;
+ return;
}
case 3: { /* 3-byte signed integer */
/* EVIDENCE-OF: R-37839-54301 Value is a big-endian 24-bit
@@ -3935,7 +3932,7 @@ u32 sqlite3VdbeSerialGet(
pMem->u.i = THREE_BYTE_INT(buf);
pMem->flags = MEM_Int;
testcase( pMem->u.i<0 );
- return 3;
+ return;
}
case 4: { /* 4-byte signed integer */
/* EVIDENCE-OF: R-01849-26079 Value is a big-endian 32-bit
@@ -3947,7 +3944,7 @@ u32 sqlite3VdbeSerialGet(
#endif
pMem->flags = MEM_Int;
testcase( pMem->u.i<0 );
- return 4;
+ return;
}
case 5: { /* 6-byte signed integer */
/* EVIDENCE-OF: R-50385-09674 Value is a big-endian 48-bit
@@ -3955,13 +3952,14 @@ u32 sqlite3VdbeSerialGet(
pMem->u.i = FOUR_BYTE_UINT(buf+2) + (((i64)1)<<32)*TWO_BYTE_INT(buf);
pMem->flags = MEM_Int;
testcase( pMem->u.i<0 );
- return 6;
+ return;
}
case 6: /* 8-byte signed integer */
case 7: { /* IEEE floating point */
/* These use local variables, so do them in a separate routine
** to avoid having to move the frame pointer in the common case */
- return serialGet(buf,serial_type,pMem);
+ serialGet(buf,serial_type,pMem);
+ return;
}
case 8: /* Integer 0 */
case 9: { /* Integer 1 */
@@ -3969,7 +3967,7 @@ u32 sqlite3VdbeSerialGet(
/* EVIDENCE-OF: R-18143-12121 Value is the integer 1. */
pMem->u.i = serial_type-8;
pMem->flags = MEM_Int;
- return 0;
+ return;
}
default: {
/* EVIDENCE-OF: R-14606-31564 Value is a BLOB that is (N-12)/2 bytes in
@@ -3980,10 +3978,10 @@ u32 sqlite3VdbeSerialGet(
pMem->z = (char *)buf;
pMem->n = (serial_type-12)/2;
pMem->flags = aFlag[serial_type&1];
- return pMem->n;
+ return;
}
}
- return 0;
+ return;
}
/*
** This routine is used to allocate sufficient space for an UnpackedRecord
@@ -4046,7 +4044,8 @@ void sqlite3VdbeRecordUnpack(
/* pMem->flags = 0; // sqlite3VdbeSerialGet() will set this for us */
pMem->szMalloc = 0;
pMem->z = 0;
- d += sqlite3VdbeSerialGet(&aKey[d], serial_type, pMem);
+ sqlite3VdbeSerialGet(&aKey[d], serial_type, pMem);
+ d += sqlite3VdbeSerialTypeLen(serial_type);
pMem++;
if( (++u)>=p->nField ) break;
}
@@ -4130,7 +4129,8 @@ static int vdbeRecordCompareDebug(
/* Extract the values to be compared.
*/
- d1 += sqlite3VdbeSerialGet(&aKey1[d1], serial_type1, &mem1);
+ sqlite3VdbeSerialGet(&aKey1[d1], serial_type1, &mem1);
+ d1 += sqlite3VdbeSerialTypeLen(serial_type1);
/* Do the comparison
*/
@@ -4934,7 +4934,7 @@ int sqlite3VdbeIdxRowid(sqlite3 *db, BtCursor *pCur, i64 *rowid){
/* The index entry must begin with a header size */
getVarint32NR((u8*)m.z, szHdr);
testcase( szHdr==3 );
- testcase( szHdr==m.n );
+ testcase( szHdr==(u32)m.n );
testcase( szHdr>0x7fffffff );
assert( m.n>=0 );
if( unlikely(szHdr<3 || szHdr>(unsigned)m.n) ){
diff --git a/chromium/third_party/sqlite/src/src/vdbeblob.c b/chromium/third_party/sqlite/src/src/vdbeblob.c
index 512442fd2a7..a18ee05b52b 100644
--- a/chromium/third_party/sqlite/src/src/vdbeblob.c
+++ b/chromium/third_party/sqlite/src/src/vdbeblob.c
@@ -152,10 +152,9 @@ int sqlite3_blob_open(
sqlite3_mutex_enter(db->mutex);
pBlob = (Incrblob *)sqlite3DbMallocZero(db, sizeof(Incrblob));
- do {
- memset(&sParse, 0, sizeof(Parse));
+ while(1){
+ sqlite3ParseObjectInit(&sParse,db);
if( !pBlob ) goto blob_open_out;
- sParse.db = db;
sqlite3DbFree(db, zErr);
zErr = 0;
@@ -332,7 +331,9 @@ int sqlite3_blob_open(
goto blob_open_out;
}
rc = blobSeekToRow(pBlob, iRow, &zErr);
- } while( (++nAttempt)<SQLITE_MAX_SCHEMA_RETRY && rc==SQLITE_SCHEMA );
+ if( (++nAttempt)>=SQLITE_MAX_SCHEMA_RETRY || rc!=SQLITE_SCHEMA ) break;
+ sqlite3ParseObjectReset(&sParse);
+ }
blob_open_out:
if( rc==SQLITE_OK && db->mallocFailed==0 ){
@@ -343,7 +344,7 @@ blob_open_out:
}
sqlite3ErrorWithMsg(db, rc, (zErr ? "%s" : 0), zErr);
sqlite3DbFree(db, zErr);
- sqlite3ParserReset(&sParse);
+ sqlite3ParseObjectReset(&sParse);
rc = sqlite3ApiExit(db, rc);
sqlite3_mutex_leave(db->mutex);
return rc;
diff --git a/chromium/third_party/sqlite/src/src/vdbemem.c b/chromium/third_party/sqlite/src/src/vdbemem.c
index 570a2eb38c1..adbc5df997b 100644
--- a/chromium/third_party/sqlite/src/src/vdbemem.c
+++ b/chromium/third_party/sqlite/src/src/vdbemem.c
@@ -596,12 +596,12 @@ static SQLITE_NOINLINE i64 doubleToInt64(double r){
**
** If pMem represents a string value, its encoding might be changed.
*/
-static SQLITE_NOINLINE i64 memIntValue(Mem *pMem){
+static SQLITE_NOINLINE i64 memIntValue(const Mem *pMem){
i64 value = 0;
sqlite3Atoi64(pMem->z, &value, pMem->n, pMem->enc);
return value;
}
-i64 sqlite3VdbeIntValue(Mem *pMem){
+i64 sqlite3VdbeIntValue(const Mem *pMem){
int flags;
assert( pMem!=0 );
assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
@@ -916,6 +916,7 @@ void sqlite3VdbeMemSetPointer(
void (*xDestructor)(void*)
){
assert( pMem->flags==MEM_Null );
+ vdbeMemClear(pMem);
pMem->u.zPType = zPType ? zPType : "";
pMem->z = pPtr;
pMem->flags = MEM_Null|MEM_Dyn|MEM_Subtype|MEM_Term;
@@ -1530,11 +1531,7 @@ static int valueFromExpr(
assert( pExpr!=0 );
while( (op = pExpr->op)==TK_UPLUS || op==TK_SPAN ) pExpr = pExpr->pLeft;
-#if defined(SQLITE_ENABLE_STAT4)
if( op==TK_REGISTER ) op = pExpr->op2;
-#else
- if( NEVER(op==TK_REGISTER) ) op = pExpr->op2;
-#endif
/* Compressed expressions only appear when parsing the DEFAULT clause
** on a table column definition, and hence only when pCtx==0. This
@@ -1649,7 +1646,7 @@ static int valueFromExpr(
no_mem:
#ifdef SQLITE_ENABLE_STAT4
- if( pCtx==0 || pCtx->pParse->nErr==0 )
+ if( pCtx==0 || NEVER(pCtx->pParse->nErr==0) )
#endif
sqlite3OomFault(db);
sqlite3DbFree(db, zVal);
diff --git a/chromium/third_party/sqlite/src/src/vdbesort.c b/chromium/third_party/sqlite/src/src/vdbesort.c
index 8bf7b571738..3958662cc69 100644
--- a/chromium/third_party/sqlite/src/src/vdbesort.c
+++ b/chromium/third_party/sqlite/src/src/vdbesort.c
@@ -960,7 +960,8 @@ int sqlite3VdbeSorterInit(
}
#endif
- assert( pCsr->pKeyInfo && pCsr->pBtx==0 );
+ assert( pCsr->pKeyInfo );
+ assert( !pCsr->isEphemeral );
assert( pCsr->eCurType==CURTYPE_SORTER );
szKeyInfo = sizeof(KeyInfo) + (pCsr->pKeyInfo->nKeyField-1)*sizeof(CollSeq*);
sz = sizeof(VdbeSorter) + nWorker * sizeof(SortSubtask);
diff --git a/chromium/third_party/sqlite/src/src/vtab.c b/chromium/third_party/sqlite/src/src/vtab.c
index 2c787c6c449..11c076e4e6a 100644
--- a/chromium/third_party/sqlite/src/src/vtab.c
+++ b/chromium/third_party/sqlite/src/src/vtab.c
@@ -807,7 +807,6 @@ int sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable){
VtabCtx *pCtx;
int rc = SQLITE_OK;
Table *pTab;
- char *zErr = 0;
Parse sParse;
int initBusy;
@@ -826,9 +825,8 @@ int sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable){
pTab = pCtx->pTab;
assert( IsVirtual(pTab) );
- memset(&sParse, 0, sizeof(sParse));
+ sqlite3ParseObjectInit(&sParse, db);
sParse.eParseMode = PARSE_MODE_DECLARE_VTAB;
- sParse.db = db;
/* We should never be able to reach this point while loading the
** schema. Nevertheless, defend against that (turn off db->init.busy)
** in case a bug arises. */
@@ -836,11 +834,12 @@ int sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable){
initBusy = db->init.busy;
db->init.busy = 0;
sParse.nQueryLoop = 1;
- if( SQLITE_OK==sqlite3RunParser(&sParse, zCreateTable, &zErr)
- && sParse.pNewTable
- && !db->mallocFailed
+ if( SQLITE_OK==sqlite3RunParser(&sParse, zCreateTable)
+ && ALWAYS(sParse.pNewTable!=0)
+ && ALWAYS(!db->mallocFailed)
&& IsOrdinaryTable(sParse.pNewTable)
){
+ assert( sParse.zErrMsg==0 );
if( !pTab->aCol ){
Table *pNew = sParse.pNewTable;
Index *pIdx;
@@ -870,8 +869,9 @@ int sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable){
}
pCtx->bDeclared = 1;
}else{
- sqlite3ErrorWithMsg(db, SQLITE_ERROR, (zErr ? "%s" : 0), zErr);
- sqlite3DbFree(db, zErr);
+ sqlite3ErrorWithMsg(db, SQLITE_ERROR,
+ (sParse.zErrMsg ? "%s" : 0), sParse.zErrMsg);
+ sqlite3DbFree(db, sParse.zErrMsg);
rc = SQLITE_ERROR;
}
sParse.eParseMode = PARSE_MODE_NORMAL;
@@ -880,7 +880,7 @@ int sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable){
sqlite3VdbeFinalize(sParse.pVdbe);
}
sqlite3DeleteTable(db, sParse.pNewTable);
- sqlite3ParserReset(&sParse);
+ sqlite3ParseObjectReset(&sParse);
db->init.busy = initBusy;
assert( (rc&0xff)==rc );
diff --git a/chromium/third_party/sqlite/src/src/wal.c b/chromium/third_party/sqlite/src/src/wal.c
index a0ec91965ca..fdc4ac39b62 100644
--- a/chromium/third_party/sqlite/src/src/wal.c
+++ b/chromium/third_party/sqlite/src/src/wal.c
@@ -2603,7 +2603,9 @@ static int walBeginShmUnreliable(Wal *pWal, int *pChanged){
}
/* Allocate a buffer to read frames into */
- szFrame = pWal->hdr.szPage + WAL_FRAME_HDRSIZE;
+ assert( (pWal->szPage & (pWal->szPage-1))==0 );
+ assert( pWal->szPage>=512 && pWal->szPage<=65536 );
+ szFrame = pWal->szPage + WAL_FRAME_HDRSIZE;
aFrame = (u8 *)sqlite3_malloc64(szFrame);
if( aFrame==0 ){
rc = SQLITE_NOMEM_BKPT;
@@ -2617,7 +2619,7 @@ static int walBeginShmUnreliable(Wal *pWal, int *pChanged){
** the caller. */
aSaveCksum[0] = pWal->hdr.aFrameCksum[0];
aSaveCksum[1] = pWal->hdr.aFrameCksum[1];
- for(iOffset=walFrameOffset(pWal->hdr.mxFrame+1, pWal->hdr.szPage);
+ for(iOffset=walFrameOffset(pWal->hdr.mxFrame+1, pWal->szPage);
iOffset+szFrame<=szWal;
iOffset+=szFrame
){
diff --git a/chromium/third_party/sqlite/src/src/where.c b/chromium/third_party/sqlite/src/src/where.c
index 7a8342675d7..ca4ce3d805a 100644
--- a/chromium/third_party/sqlite/src/src/where.c
+++ b/chromium/third_party/sqlite/src/src/where.c
@@ -30,8 +30,14 @@
*/
typedef struct HiddenIndexInfo HiddenIndexInfo;
struct HiddenIndexInfo {
- WhereClause *pWC; /* The Where clause being analyzed */
- Parse *pParse; /* The parsing context */
+ WhereClause *pWC; /* The Where clause being analyzed */
+ Parse *pParse; /* The parsing context */
+ int eDistinct; /* Value to return from sqlite3_vtab_distinct() */
+ u32 mIn; /* Mask of terms that are <col> IN (...) */
+ u32 mHandleIn; /* Terms that vtab will handle as <col> IN (...) */
+ sqlite3_value *aRhs[1]; /* RHS values for constraints. MUST BE LAST
+ ** because extra space is allocated to hold up
+ ** to nTerm such values */
};
/* Forward declaration of methods */
@@ -234,7 +240,12 @@ whereOrInsert_done:
Bitmask sqlite3WhereGetMask(WhereMaskSet *pMaskSet, int iCursor){
int i;
assert( pMaskSet->n<=(int)sizeof(Bitmask)*8 );
- for(i=0; i<pMaskSet->n; i++){
+ assert( pMaskSet->n>0 || pMaskSet->ix[0]<0 );
+ assert( iCursor>=-1 );
+ if( pMaskSet->ix[0]==iCursor ){
+ return 1;
+ }
+ for(i=1; i<pMaskSet->n; i++){
if( pMaskSet->ix[i]==iCursor ){
return MASKBIT(i);
}
@@ -419,16 +430,16 @@ static WhereTerm *whereScanInit(
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 ){
+ if( iColumn==pIdx->pTable->iPKey ){
iColumn = XN_ROWID;
}else if( iColumn>=0 ){
pScan->idxaff = pIdx->pTable->aCol[iColumn].affinity;
pScan->zCollName = pIdx->azColl[j];
+ }else 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==XN_EXPR ){
return 0;
@@ -671,12 +682,14 @@ static void whereTraceIndexInfoInputs(sqlite3_index_info *p){
int i;
if( !sqlite3WhereTrace ) return;
for(i=0; i<p->nConstraint; i++){
- sqlite3DebugPrintf(" constraint[%d]: col=%d termid=%d op=%d usabled=%d\n",
+ sqlite3DebugPrintf(
+ " constraint[%d]: col=%d termid=%d op=%d usabled=%d collseq=%s\n",
i,
p->aConstraint[i].iColumn,
p->aConstraint[i].iTermOffset,
p->aConstraint[i].op,
- p->aConstraint[i].usable);
+ p->aConstraint[i].usable,
+ sqlite3_vtab_collation(p,i));
}
for(i=0; i<p->nOrderBy; i++){
sqlite3DebugPrintf(" orderby[%d]: col=%d desc=%d\n",
@@ -712,9 +725,9 @@ static void whereTraceIndexInfoOutputs(sqlite3_index_info *p){
** index existed.
*/
static int termCanDriveIndex(
- WhereTerm *pTerm, /* WHERE clause term to check */
- SrcItem *pSrc, /* Table we are trying to access */
- Bitmask notReady /* Tables in outer loops of the join */
+ const WhereTerm *pTerm, /* WHERE clause term to check */
+ const SrcItem *pSrc, /* Table we are trying to access */
+ const Bitmask notReady /* Tables in outer loops of the join */
){
char aff;
if( pTerm->leftCursor!=pSrc->iCursor ) return 0;
@@ -745,11 +758,11 @@ static int termCanDriveIndex(
** and to set up the WhereLevel object pLevel so that the code generator
** makes use of the automatic index.
*/
-static void constructAutomaticIndex(
+static SQLITE_NOINLINE void constructAutomaticIndex(
Parse *pParse, /* The parsing context */
- WhereClause *pWC, /* The WHERE clause */
- SrcItem *pSrc, /* The FROM clause term to get the next index */
- Bitmask notReady, /* Mask of cursors that are not available */
+ const WhereClause *pWC, /* The WHERE clause */
+ const SrcItem *pSrc, /* The FROM clause term to get the next index */
+ const Bitmask notReady, /* Mask of cursors that are not available */
WhereLevel *pLevel /* Write new index here */
){
int nKeyCol; /* Number of columns in the constructed index */
@@ -791,13 +804,13 @@ static void constructAutomaticIndex(
idxCols = 0;
for(pTerm=pWC->a; pTerm<pWCEnd; pTerm++){
Expr *pExpr = pTerm->pExpr;
- assert( !ExprHasProperty(pExpr, EP_FromJoin) /* prereq always non-zero */
- || pExpr->iRightJoinTable!=pSrc->iCursor /* for the right-hand */
- || pLoop->prereq!=0 ); /* table of a LEFT JOIN */
- if( pLoop->prereq==0
- && (pTerm->wtFlags & TERM_VIRTUAL)==0
- && !ExprHasProperty(pExpr, EP_FromJoin)
- && sqlite3ExprIsTableConstant(pExpr, pSrc->iCursor) ){
+ /* Make the automatic index a partial index if there are terms in the
+ ** WHERE clause (or the ON clause of a LEFT join) that constrain which
+ ** rows of the target table (pSrc) that can be used. */
+ if( (pTerm->wtFlags & TERM_VIRTUAL)==0
+ && ((pSrc->fg.jointype&JT_LEFT)==0 || ExprHasProperty(pExpr,EP_FromJoin))
+ && sqlite3ExprIsTableConstant(pExpr, pSrc->iCursor)
+ ){
pPartial = sqlite3ExprAnd(pParse, pPartial,
sqlite3ExprDup(pParse->db, pExpr, 0));
}
@@ -904,6 +917,10 @@ static void constructAutomaticIndex(
sqlite3VdbeAddOp2(v, OP_OpenAutoindex, pLevel->iIdxCur, nKeyCol+1);
sqlite3VdbeSetP4KeyInfo(pParse, pIdx);
VdbeComment((v, "for %s", pTable->zName));
+ if( OptimizationEnabled(pParse->db, SQLITE_BloomFilter) ){
+ pLevel->regFilter = ++pParse->nMem;
+ sqlite3VdbeAddOp2(v, OP_Blob, 10000, pLevel->regFilter);
+ }
/* Fill the automatic index with content */
pTabItem = &pWC->pWInfo->pTabList->a[pLevel->iFrom];
@@ -926,6 +943,10 @@ static void constructAutomaticIndex(
regBase = sqlite3GenerateIndexKey(
pParse, pIdx, pLevel->iTabCur, regRecord, 0, 0, 0, 0
);
+ if( pLevel->regFilter ){
+ sqlite3VdbeAddOp4Int(v, OP_FilterAdd, pLevel->regFilter, 0,
+ regBase, pLoop->u.btree.nEq);
+ }
sqlite3VdbeAddOp2(v, OP_IdxInsert, pLevel->iIdxCur, regRecord);
sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT);
if( pPartial ) sqlite3VdbeResolveLabel(v, iContinue);
@@ -952,22 +973,149 @@ end_auto_index_create:
}
#endif /* SQLITE_OMIT_AUTOMATIC_INDEX */
+/*
+** Generate bytecode that will initialize a Bloom filter that is appropriate
+** for pLevel.
+**
+** If there are inner loops within pLevel that have the WHERE_BLOOMFILTER
+** flag set, initialize a Bloomfilter for them as well. Except don't do
+** this recursive initialization if the SQLITE_BloomPulldown optimization has
+** been turned off.
+**
+** When the Bloom filter is initialized, the WHERE_BLOOMFILTER flag is cleared
+** from the loop, but the regFilter value is set to a register that implements
+** the Bloom filter. When regFilter is positive, the
+** sqlite3WhereCodeOneLoopStart() will generate code to test the Bloom filter
+** and skip the subsequence B-Tree seek if the Bloom filter indicates that
+** no matching rows exist.
+**
+** This routine may only be called if it has previously been determined that
+** the loop would benefit from a Bloom filter, and the WHERE_BLOOMFILTER bit
+** is set.
+*/
+static SQLITE_NOINLINE void sqlite3ConstructBloomFilter(
+ WhereInfo *pWInfo, /* The WHERE clause */
+ int iLevel, /* Index in pWInfo->a[] that is pLevel */
+ WhereLevel *pLevel, /* Make a Bloom filter for this FROM term */
+ Bitmask notReady /* Loops that are not ready */
+){
+ int addrOnce; /* Address of opening OP_Once */
+ int addrTop; /* Address of OP_Rewind */
+ int addrCont; /* Jump here to skip a row */
+ const WhereTerm *pTerm; /* For looping over WHERE clause terms */
+ const WhereTerm *pWCEnd; /* Last WHERE clause term */
+ Parse *pParse = pWInfo->pParse; /* Parsing context */
+ Vdbe *v = pParse->pVdbe; /* VDBE under construction */
+ WhereLoop *pLoop = pLevel->pWLoop; /* The loop being coded */
+ int iCur; /* Cursor for table getting the filter */
+
+ assert( pLoop!=0 );
+ assert( v!=0 );
+ assert( pLoop->wsFlags & WHERE_BLOOMFILTER );
+
+ addrOnce = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v);
+ do{
+ const SrcItem *pItem;
+ const Table *pTab;
+ u64 sz;
+ sqlite3WhereExplainBloomFilter(pParse, pWInfo, pLevel);
+ addrCont = sqlite3VdbeMakeLabel(pParse);
+ iCur = pLevel->iTabCur;
+ pLevel->regFilter = ++pParse->nMem;
+
+ /* The Bloom filter is a Blob held in a register. Initialize it
+ ** to zero-filled blob of at least 80K bits, but maybe more if the
+ ** estimated size of the table is larger. We could actually
+ ** measure the size of the table at run-time using OP_Count with
+ ** P3==1 and use that value to initialize the blob. But that makes
+ ** testing complicated. By basing the blob size on the value in the
+ ** sqlite_stat1 table, testing is much easier.
+ */
+ pItem = &pWInfo->pTabList->a[pLevel->iFrom];
+ assert( pItem!=0 );
+ pTab = pItem->pTab;
+ assert( pTab!=0 );
+ sz = sqlite3LogEstToInt(pTab->nRowLogEst);
+ if( sz<10000 ){
+ sz = 10000;
+ }else if( sz>10000000 ){
+ sz = 10000000;
+ }
+ sqlite3VdbeAddOp2(v, OP_Blob, (int)sz, pLevel->regFilter);
+
+ addrTop = sqlite3VdbeAddOp1(v, OP_Rewind, iCur); VdbeCoverage(v);
+ pWCEnd = &pWInfo->sWC.a[pWInfo->sWC.nTerm];
+ for(pTerm=pWInfo->sWC.a; pTerm<pWCEnd; pTerm++){
+ Expr *pExpr = pTerm->pExpr;
+ if( (pTerm->wtFlags & TERM_VIRTUAL)==0
+ && sqlite3ExprIsTableConstant(pExpr, iCur)
+ ){
+ sqlite3ExprIfFalse(pParse, pTerm->pExpr, addrCont, SQLITE_JUMPIFNULL);
+ }
+ }
+ if( pLoop->wsFlags & WHERE_IPK ){
+ int r1 = sqlite3GetTempReg(pParse);
+ sqlite3VdbeAddOp2(v, OP_Rowid, iCur, r1);
+ sqlite3VdbeAddOp4Int(v, OP_FilterAdd, pLevel->regFilter, 0, r1, 1);
+ sqlite3ReleaseTempReg(pParse, r1);
+ }else{
+ Index *pIdx = pLoop->u.btree.pIndex;
+ int n = pLoop->u.btree.nEq;
+ int r1 = sqlite3GetTempRange(pParse, n);
+ int jj;
+ for(jj=0; jj<n; jj++){
+ int iCol = pIdx->aiColumn[jj];
+ assert( pIdx->pTable==pItem->pTab );
+ sqlite3ExprCodeGetColumnOfTable(v, pIdx->pTable, iCur, iCol,r1+jj);
+ }
+ sqlite3VdbeAddOp4Int(v, OP_FilterAdd, pLevel->regFilter, 0, r1, n);
+ sqlite3ReleaseTempRange(pParse, r1, n);
+ }
+ sqlite3VdbeResolveLabel(v, addrCont);
+ sqlite3VdbeAddOp2(v, OP_Next, pLevel->iTabCur, addrTop+1);
+ VdbeCoverage(v);
+ sqlite3VdbeJumpHere(v, addrTop);
+ pLoop->wsFlags &= ~WHERE_BLOOMFILTER;
+ if( OptimizationDisabled(pParse->db, SQLITE_BloomPulldown) ) break;
+ while( ++iLevel < pWInfo->nLevel ){
+ const SrcItem *pTabItem;
+ pLevel = &pWInfo->a[iLevel];
+ pTabItem = &pWInfo->pTabList->a[pLevel->iFrom];
+ if( pTabItem->fg.jointype & JT_LEFT ) continue;
+ pLoop = pLevel->pWLoop;
+ if( NEVER(pLoop==0) ) continue;
+ if( pLoop->prereq & notReady ) continue;
+ if( (pLoop->wsFlags & (WHERE_BLOOMFILTER|WHERE_COLUMN_IN))
+ ==WHERE_BLOOMFILTER
+ ){
+ /* This is a candidate for bloom-filter pull-down (early evaluation).
+ ** The test that WHERE_COLUMN_IN is omitted is important, as we are
+ ** not able to do early evaluation of bloom filters that make use of
+ ** the IN operator */
+ break;
+ }
+ }
+ }while( iLevel < pWInfo->nLevel );
+ sqlite3VdbeJumpHere(v, addrOnce);
+}
+
+
#ifndef SQLITE_OMIT_VIRTUALTABLE
/*
** Allocate and populate an sqlite3_index_info structure. It is the
** responsibility of the caller to eventually release the structure
-** by passing the pointer returned by this function to sqlite3_free().
+** by passing the pointer returned by this function to freeIndexInfo().
*/
static sqlite3_index_info *allocateIndexInfo(
- Parse *pParse, /* The parsing context */
+ WhereInfo *pWInfo, /* The WHERE clause */
WhereClause *pWC, /* The WHERE clause being analyzed */
Bitmask mUnusable, /* Ignore terms with these prereqs */
SrcItem *pSrc, /* The FROM clause term that is the vtab */
- ExprList *pOrderBy, /* The ORDER BY clause */
u16 *pmNoOmit /* Mask of terms not to omit */
){
int i, j;
int nTerm;
+ Parse *pParse = pWInfo->pParse;
struct sqlite3_index_constraint *pIdxCons;
struct sqlite3_index_orderby *pIdxOrderBy;
struct sqlite3_index_constraint_usage *pUsage;
@@ -976,10 +1124,21 @@ static sqlite3_index_info *allocateIndexInfo(
int nOrderBy;
sqlite3_index_info *pIdxInfo;
u16 mNoOmit = 0;
+ const Table *pTab;
+ int eDistinct = 0;
+ ExprList *pOrderBy = pWInfo->pOrderBy;
+
+ assert( pSrc!=0 );
+ pTab = pSrc->pTab;
+ assert( pTab!=0 );
+ assert( IsVirtual(pTab) );
- /* Count the number of possible WHERE clause constraints referring
- ** to this virtual table */
+ /* Find all WHERE clause constraints referring to this virtual table.
+ ** Mark each term with the TERM_OK flag. Set nTerm to the number of
+ ** terms found.
+ */
for(i=nTerm=0, pTerm=pWC->a; i<pWC->nTerm; i++, pTerm++){
+ pTerm->wtFlags &= ~TERM_OK;
if( pTerm->leftCursor != pSrc->iCursor ) continue;
if( pTerm->prereqRight & mUnusable ) continue;
assert( IsPowerOfTwo(pTerm->eOperator & ~WO_EQUIV) );
@@ -989,9 +1148,21 @@ static sqlite3_index_info *allocateIndexInfo(
testcase( pTerm->eOperator & WO_ALL );
if( (pTerm->eOperator & ~(WO_EQUIV))==0 ) continue;
if( pTerm->wtFlags & TERM_VNULL ) continue;
+
assert( (pTerm->eOperator & (WO_OR|WO_AND))==0 );
- assert( pTerm->u.x.leftColumn>=(-1) );
+ assert( pTerm->u.x.leftColumn>=XN_ROWID );
+ assert( pTerm->u.x.leftColumn<pTab->nCol );
+
+ /* tag-20191211-002: WHERE-clause constraints are not useful to the
+ ** right-hand table of a LEFT JOIN. See tag-20191211-001 for the
+ ** equivalent restriction for ordinary tables. */
+ if( (pSrc->fg.jointype & JT_LEFT)!=0
+ && !ExprHasProperty(pTerm->pExpr, EP_FromJoin)
+ ){
+ continue;
+ }
nTerm++;
+ pTerm->wtFlags |= TERM_OK;
}
/* If the ORDER BY clause contains only columns in the current
@@ -1003,11 +1174,47 @@ static sqlite3_index_info *allocateIndexInfo(
int n = pOrderBy->nExpr;
for(i=0; i<n; i++){
Expr *pExpr = pOrderBy->a[i].pExpr;
- if( pExpr->op!=TK_COLUMN || pExpr->iTable!=pSrc->iCursor ) break;
+ Expr *pE2;
+
+ /* Skip over constant terms in the ORDER BY clause */
+ if( sqlite3ExprIsConstant(pExpr) ){
+ continue;
+ }
+
+ /* Virtual tables are unable to deal with NULLS FIRST */
if( pOrderBy->a[i].sortFlags & KEYINFO_ORDER_BIGNULL ) break;
+
+ /* First case - a direct column references without a COLLATE operator */
+ if( pExpr->op==TK_COLUMN && pExpr->iTable==pSrc->iCursor ){
+ assert( pExpr->iColumn>=XN_ROWID && pExpr->iColumn<pTab->nCol );
+ continue;
+ }
+
+ /* 2nd case - a column reference with a COLLATE operator. Only match
+ ** of the COLLATE operator matches the collation of the column. */
+ if( pExpr->op==TK_COLLATE
+ && (pE2 = pExpr->pLeft)->op==TK_COLUMN
+ && pE2->iTable==pSrc->iCursor
+ ){
+ const char *zColl; /* The collating sequence name */
+ assert( !ExprHasProperty(pExpr, EP_IntValue) );
+ assert( pExpr->u.zToken!=0 );
+ assert( pE2->iColumn>=XN_ROWID && pE2->iColumn<pTab->nCol );
+ pExpr->iColumn = pE2->iColumn;
+ if( pE2->iColumn<0 ) continue; /* Collseq does not matter for rowid */
+ zColl = sqlite3ColumnColl(&pTab->aCol[pE2->iColumn]);
+ if( zColl==0 ) zColl = sqlite3StrBINARY;
+ if( sqlite3_stricmp(pExpr->u.zToken, zColl)==0 ) continue;
+ }
+
+ /* No matches cause a break out of the loop */
+ break;
}
- if( i==n){
+ if( i==n ){
nOrderBy = n;
+ if( (pWInfo->wctrlFlags & (WHERE_GROUPBY|WHERE_DISTINCTBY)) ){
+ eDistinct = 1 + ((pWInfo->wctrlFlags & WHERE_DISTINCTBY)!=0);
+ }
}
}
@@ -1015,47 +1222,35 @@ static sqlite3_index_info *allocateIndexInfo(
*/
pIdxInfo = sqlite3DbMallocZero(pParse->db, sizeof(*pIdxInfo)
+ (sizeof(*pIdxCons) + sizeof(*pUsage))*nTerm
- + sizeof(*pIdxOrderBy)*nOrderBy + sizeof(*pHidden) );
+ + sizeof(*pIdxOrderBy)*nOrderBy + sizeof(*pHidden)
+ + sizeof(sqlite3_value*)*nTerm );
if( pIdxInfo==0 ){
sqlite3ErrorMsg(pParse, "out of memory");
return 0;
}
pHidden = (struct HiddenIndexInfo*)&pIdxInfo[1];
- pIdxCons = (struct sqlite3_index_constraint*)&pHidden[1];
+ pIdxCons = (struct sqlite3_index_constraint*)&pHidden->aRhs[nTerm];
pIdxOrderBy = (struct sqlite3_index_orderby*)&pIdxCons[nTerm];
pUsage = (struct sqlite3_index_constraint_usage*)&pIdxOrderBy[nOrderBy];
- pIdxInfo->nOrderBy = nOrderBy;
pIdxInfo->aConstraint = pIdxCons;
pIdxInfo->aOrderBy = pIdxOrderBy;
pIdxInfo->aConstraintUsage = pUsage;
pHidden->pWC = pWC;
pHidden->pParse = pParse;
+ pHidden->eDistinct = eDistinct;
+ pHidden->mIn = 0;
for(i=j=0, pTerm=pWC->a; i<pWC->nTerm; i++, pTerm++){
u16 op;
- if( pTerm->leftCursor != pSrc->iCursor ) continue;
- if( pTerm->prereqRight & mUnusable ) continue;
- assert( IsPowerOfTwo(pTerm->eOperator & ~WO_EQUIV) );
- testcase( pTerm->eOperator & WO_IN );
- testcase( pTerm->eOperator & WO_IS );
- testcase( pTerm->eOperator & WO_ISNULL );
- testcase( pTerm->eOperator & WO_ALL );
- if( (pTerm->eOperator & ~(WO_EQUIV))==0 ) continue;
- if( pTerm->wtFlags & TERM_VNULL ) continue;
-
- /* tag-20191211-002: WHERE-clause constraints are not useful to the
- ** right-hand table of a LEFT JOIN. See tag-20191211-001 for the
- ** equivalent restriction for ordinary tables. */
- if( (pSrc->fg.jointype & JT_LEFT)!=0
- && !ExprHasProperty(pTerm->pExpr, EP_FromJoin)
- ){
- continue;
- }
- assert( (pTerm->eOperator & (WO_OR|WO_AND))==0 );
- assert( pTerm->u.x.leftColumn>=(-1) );
+ if( (pTerm->wtFlags & TERM_OK)==0 ) continue;
pIdxCons[j].iColumn = pTerm->u.x.leftColumn;
pIdxCons[j].iTermOffset = i;
op = pTerm->eOperator & WO_ALL;
- if( op==WO_IN ) op = WO_EQ;
+ if( op==WO_IN ){
+ if( (pTerm->wtFlags & TERM_SLICE)==0 ){
+ pHidden->mIn |= SMASKBIT32(j);
+ }
+ op = WO_EQ;
+ }
if( op==WO_AUX ){
pIdxCons[j].op = pTerm->eMatchOp;
}else if( op & (WO_ISNULL|WO_IS) ){
@@ -1088,18 +1283,43 @@ static sqlite3_index_info *allocateIndexInfo(
j++;
}
+ assert( j==nTerm );
pIdxInfo->nConstraint = j;
- for(i=0; i<nOrderBy; i++){
+ for(i=j=0; i<nOrderBy; i++){
Expr *pExpr = pOrderBy->a[i].pExpr;
- pIdxOrderBy[i].iColumn = pExpr->iColumn;
- pIdxOrderBy[i].desc = pOrderBy->a[i].sortFlags & KEYINFO_ORDER_DESC;
+ if( sqlite3ExprIsConstant(pExpr) ) continue;
+ assert( pExpr->op==TK_COLUMN
+ || (pExpr->op==TK_COLLATE && pExpr->pLeft->op==TK_COLUMN
+ && pExpr->iColumn==pExpr->pLeft->iColumn) );
+ pIdxOrderBy[j].iColumn = pExpr->iColumn;
+ pIdxOrderBy[j].desc = pOrderBy->a[i].sortFlags & KEYINFO_ORDER_DESC;
+ j++;
}
+ pIdxInfo->nOrderBy = j;
*pmNoOmit = mNoOmit;
return pIdxInfo;
}
/*
+** Free an sqlite3_index_info structure allocated by allocateIndexInfo()
+** and possibly modified by xBestIndex methods.
+*/
+static void freeIndexInfo(sqlite3 *db, sqlite3_index_info *pIdxInfo){
+ HiddenIndexInfo *pHidden;
+ int i;
+ assert( pIdxInfo!=0 );
+ pHidden = (HiddenIndexInfo*)&pIdxInfo[1];
+ assert( pHidden->pParse!=0 );
+ assert( pHidden->pParse->db==db );
+ for(i=0; i<pIdxInfo->nConstraint; i++){
+ sqlite3ValueFree(pHidden->aRhs[i]); /* IMP: R-14553-25174 */
+ pHidden->aRhs[i] = 0;
+ }
+ sqlite3DbFree(db, pIdxInfo);
+}
+
+/*
** The table object reference passed as the second argument to this function
** must represent a virtual table. This function invokes the xBestIndex()
** method of the virtual table with the sqlite3_index_info object that
@@ -1120,7 +1340,9 @@ static int vtabBestIndex(Parse *pParse, Table *pTab, sqlite3_index_info *p){
int rc;
whereTraceIndexInfoInputs(p);
+ pParse->db->nSchemaLock++;
rc = pVtab->pModule->xBestIndex(pVtab, p);
+ pParse->db->nSchemaLock--;
whereTraceIndexInfoOutputs(p);
if( rc!=SQLITE_OK && rc!=SQLITE_CONSTRAINT ){
@@ -1894,9 +2116,9 @@ void sqlite3WhereLoopPrint(WhereLoop *p, WhereClause *pWC){
sqlite3_free(z);
}
if( p->wsFlags & WHERE_SKIPSCAN ){
- sqlite3DebugPrintf(" f %05x %d-%d", p->wsFlags, p->nLTerm,p->nSkip);
+ sqlite3DebugPrintf(" f %06x %d-%d", p->wsFlags, p->nLTerm,p->nSkip);
}else{
- sqlite3DebugPrintf(" f %05x N %d", p->wsFlags, p->nLTerm);
+ sqlite3DebugPrintf(" f %06x N %d", p->wsFlags, p->nLTerm);
}
sqlite3DebugPrintf(" cost %d,%d,%d\n", p->rSetup, p->rRun, p->nOut);
if( p->nLTerm && (sqlite3WhereTrace & 0x100)!=0 ){
@@ -2356,11 +2578,11 @@ static void whereLoopOutputAdjust(
LogEst iReduce = 0; /* pLoop->nOut should not exceed nRow-iReduce */
assert( (pLoop->wsFlags & WHERE_AUTO_INDEX)==0 );
- for(i=pWC->nTerm, pTerm=pWC->a; i>0; i--, pTerm++){
+ for(i=pWC->nBase, pTerm=pWC->a; i>0; i--, pTerm++){
assert( pTerm!=0 );
- if( (pTerm->wtFlags & TERM_VIRTUAL)!=0 ) break;
- if( (pTerm->prereqAll & pLoop->maskSelf)==0 ) continue;
if( (pTerm->prereqAll & notAllowed)!=0 ) continue;
+ if( (pTerm->prereqAll & pLoop->maskSelf)==0 ) continue;
+ if( (pTerm->wtFlags & TERM_VIRTUAL)!=0 ) continue;
for(j=pLoop->nLTerm-1; j>=0; j--){
pX = pLoop->aLTerm[j];
if( pX==0 ) continue;
@@ -2368,6 +2590,13 @@ static void whereLoopOutputAdjust(
if( pX->iParent>=0 && (&pWC->a[pX->iParent])==pTerm ) break;
}
if( j<0 ){
+ if( pLoop->maskSelf==pTerm->prereqAll ){
+ /* If there are extra terms in the WHERE clause not used by an index
+ ** that depend only on the table being scanned, and that will tend to
+ ** cause many rows to be omitted, then mark that table as
+ ** "self-culling". */
+ pLoop->wsFlags |= WHERE_SELFCULL;
+ }
if( pTerm->truthProb<=0 ){
/* If a truth probability is specified using the likelihood() hints,
** then use the probability provided by the application. */
@@ -2395,7 +2624,9 @@ static void whereLoopOutputAdjust(
}
}
}
- if( pLoop->nOut > nRow-iReduce ) pLoop->nOut = nRow - iReduce;
+ if( pLoop->nOut > nRow-iReduce ){
+ pLoop->nOut = nRow - iReduce;
+ }
}
/*
@@ -2940,7 +3171,7 @@ static int whereUsablePartialIndex(
for(i=0, pTerm=pWC->a; i<pWC->nTerm; i++, pTerm++){
Expr *pExpr;
pExpr = pTerm->pExpr;
- if( (!ExprHasProperty(pExpr, EP_FromJoin) || pExpr->iRightJoinTable==iTab)
+ if( (!ExprHasProperty(pExpr, EP_FromJoin) || pExpr->w.iRightJoinTable==iTab)
&& (isLeft==0 || ExprHasProperty(pExpr, EP_FromJoin))
&& sqlite3ExprImpliesExpr(pParse, pExpr, pWhere, iTab)
&& (pTerm->wtFlags & TERM_VNULL)==0
@@ -3243,6 +3474,15 @@ static int whereLoopAddBtree(
#ifndef SQLITE_OMIT_VIRTUALTABLE
/*
+** Return true if pTerm is a virtual table LIMIT or OFFSET term.
+*/
+static int isLimitTerm(WhereTerm *pTerm){
+ assert( pTerm->eOperator==WO_AUX || pTerm->eMatchOp==0 );
+ return pTerm->eMatchOp>=SQLITE_INDEX_CONSTRAINT_LIMIT
+ && pTerm->eMatchOp<=SQLITE_INDEX_CONSTRAINT_OFFSET;
+}
+
+/*
** Argument pIdxInfo is already populated with all constraints that may
** be used by the virtual table identified by pBuilder->pNew->iTab. This
** function marks a subset of those constraints usable, invokes the
@@ -3269,9 +3509,11 @@ static int whereLoopAddVirtualOne(
u16 mExclude, /* Exclude terms using these operators */
sqlite3_index_info *pIdxInfo, /* Populated object for xBestIndex */
u16 mNoOmit, /* Do not omit these constraints */
- int *pbIn /* OUT: True if plan uses an IN(...) op */
+ int *pbIn, /* OUT: True if plan uses an IN(...) op */
+ int *pbRetryLimit /* OUT: Retry without LIMIT/OFFSET */
){
WhereClause *pWC = pBuilder->pWC;
+ HiddenIndexInfo *pHidden = (HiddenIndexInfo*)&pIdxInfo[1];
struct sqlite3_index_constraint *pIdxCons;
struct sqlite3_index_constraint_usage *pUsage = pIdxInfo->aConstraintUsage;
int i;
@@ -3294,6 +3536,7 @@ static int whereLoopAddVirtualOne(
pIdxCons->usable = 0;
if( (pTerm->prereqRight & mUsable)==pTerm->prereqRight
&& (pTerm->eOperator & mExclude)==0
+ && (pbRetryLimit || !isLimitTerm(pTerm))
){
pIdxCons->usable = 1;
}
@@ -3309,6 +3552,7 @@ static int whereLoopAddVirtualOne(
pIdxInfo->estimatedRows = 25;
pIdxInfo->idxFlags = 0;
pIdxInfo->colUsed = (sqlite3_int64)pSrc->colUsed;
+ pHidden->mHandleIn = 0;
/* Invoke the virtual table xBestIndex() method */
rc = vtabBestIndex(pParse, pSrc->pTab, pIdxInfo);
@@ -3326,8 +3570,8 @@ static int whereLoopAddVirtualOne(
mxTerm = -1;
assert( pNew->nLSlot>=nConstraint );
- for(i=0; i<nConstraint; i++) pNew->aLTerm[i] = 0;
- pNew->u.vtab.omitMask = 0;
+ memset(pNew->aLTerm, 0, sizeof(pNew->aLTerm[0])*nConstraint );
+ memset(&pNew->u.vtab, 0, sizeof(pNew->u.vtab));
pIdxCons = *(struct sqlite3_index_constraint**)&pIdxInfo->aConstraint;
for(i=0; i<nConstraint; i++, pIdxCons++){
int iTerm;
@@ -3361,8 +3605,13 @@ static int whereLoopAddVirtualOne(
}else{
testcase( i!=iTerm );
}
+ if( pTerm->eMatchOp==SQLITE_INDEX_CONSTRAINT_OFFSET ){
+ pNew->u.vtab.bOmitOffset = 1;
+ }
}
- if( (pTerm->eOperator & WO_IN)!=0 ){
+ if( SMASKBIT32(i) & pHidden->mHandleIn ){
+ pNew->u.vtab.mHandleIn |= MASKBIT32(iTerm);
+ }else if( (pTerm->eOperator & WO_IN)!=0 ){
/* A virtual table that is constrained by an IN clause may not
** consume the ORDER BY clause because (1) the order of IN terms
** is not necessarily related to the order of output terms and
@@ -3372,6 +3621,21 @@ static int whereLoopAddVirtualOne(
pIdxInfo->idxFlags &= ~SQLITE_INDEX_SCAN_UNIQUE;
*pbIn = 1; assert( (mExclude & WO_IN)==0 );
}
+
+ if( isLimitTerm(pTerm) && *pbIn ){
+ /* If there is an IN(...) term handled as an == (separate call to
+ ** xFilter for each value on the RHS of the IN) and a LIMIT or
+ ** OFFSET term handled as well, the plan is unusable. Set output
+ ** variable *pbRetryLimit to true to tell the caller to retry with
+ ** LIMIT and OFFSET disabled. */
+ if( pIdxInfo->needToFreeIdxStr ){
+ sqlite3_free(pIdxInfo->idxStr);
+ pIdxInfo->idxStr = 0;
+ pIdxInfo->needToFreeIdxStr = 0;
+ }
+ *pbRetryLimit = 1;
+ return SQLITE_OK;
+ }
}
}
@@ -3416,11 +3680,19 @@ static int whereLoopAddVirtualOne(
}
/*
-** If this function is invoked from within an xBestIndex() callback, it
-** returns a pointer to a buffer containing the name of the collation
-** sequence associated with element iCons of the sqlite3_index_info.aConstraint
-** array. Or, if iCons is out of range or there is no active xBestIndex
-** call, return NULL.
+** Return the collating sequence for a constraint passed into xBestIndex.
+**
+** pIdxInfo must be an sqlite3_index_info structure passed into xBestIndex.
+** This routine depends on there being a HiddenIndexInfo structure immediately
+** following the sqlite3_index_info structure.
+**
+** Return a pointer to the collation name:
+**
+** 1. If there is an explicit COLLATE operator on the constaint, return it.
+**
+** 2. Else, if the column has an alternative collation, return that.
+**
+** 3. Otherwise, return "BINARY".
*/
const char *sqlite3_vtab_collation(sqlite3_index_info *pIdxInfo, int iCons){
HiddenIndexInfo *pHidden = (HiddenIndexInfo*)&pIdxInfo[1];
@@ -3438,6 +3710,88 @@ const char *sqlite3_vtab_collation(sqlite3_index_info *pIdxInfo, int iCons){
}
/*
+** Return true if constraint iCons is really an IN(...) constraint, or
+** false otherwise. If iCons is an IN(...) constraint, set (if bHandle!=0)
+** or clear (if bHandle==0) the flag to handle it using an iterator.
+*/
+int sqlite3_vtab_in(sqlite3_index_info *pIdxInfo, int iCons, int bHandle){
+ HiddenIndexInfo *pHidden = (HiddenIndexInfo*)&pIdxInfo[1];
+ u32 m = SMASKBIT32(iCons);
+ if( m & pHidden->mIn ){
+ if( bHandle==0 ){
+ pHidden->mHandleIn &= ~m;
+ }else if( bHandle>0 ){
+ pHidden->mHandleIn |= m;
+ }
+ return 1;
+ }
+ return 0;
+}
+
+/*
+** This interface is callable from within the xBestIndex callback only.
+**
+** If possible, set (*ppVal) to point to an object containing the value
+** on the right-hand-side of constraint iCons.
+*/
+int sqlite3_vtab_rhs_value(
+ sqlite3_index_info *pIdxInfo, /* Copy of first argument to xBestIndex */
+ int iCons, /* Constraint for which RHS is wanted */
+ sqlite3_value **ppVal /* Write value extracted here */
+){
+ HiddenIndexInfo *pH = (HiddenIndexInfo*)&pIdxInfo[1];
+ sqlite3_value *pVal = 0;
+ int rc = SQLITE_OK;
+ if( iCons<0 || iCons>=pIdxInfo->nConstraint ){
+ rc = SQLITE_MISUSE; /* EV: R-30545-25046 */
+ }else{
+ if( pH->aRhs[iCons]==0 ){
+ WhereTerm *pTerm = &pH->pWC->a[pIdxInfo->aConstraint[iCons].iTermOffset];
+ rc = sqlite3ValueFromExpr(
+ pH->pParse->db, pTerm->pExpr->pRight, ENC(pH->pParse->db),
+ SQLITE_AFF_BLOB, &pH->aRhs[iCons]
+ );
+ testcase( rc!=SQLITE_OK );
+ }
+ pVal = pH->aRhs[iCons];
+ }
+ *ppVal = pVal;
+
+ if( rc==SQLITE_OK && pVal==0 ){ /* IMP: R-19933-32160 */
+ rc = SQLITE_NOTFOUND; /* IMP: R-36424-56542 */
+ }
+
+ return rc;
+}
+
+/*
+** Return true if ORDER BY clause may be handled as DISTINCT.
+*/
+int sqlite3_vtab_distinct(sqlite3_index_info *pIdxInfo){
+ HiddenIndexInfo *pHidden = (HiddenIndexInfo*)&pIdxInfo[1];
+ assert( pHidden->eDistinct==0
+ || pHidden->eDistinct==1
+ || pHidden->eDistinct==2 );
+ return pHidden->eDistinct;
+}
+
+#if (defined(SQLITE_ENABLE_DBPAGE_VTAB) || defined(SQLITE_TEST)) \
+ && !defined(SQLITE_OMIT_VIRTUALTABLE)
+/*
+** Cause the prepared statement that is associated with a call to
+** xBestIndex to open write transactions on all attached schemas.
+** This is used by the (built-in) sqlite_dbpage virtual table.
+*/
+void sqlite3VtabWriteAll(sqlite3_index_info *pIdxInfo){
+ HiddenIndexInfo *pHidden = (HiddenIndexInfo*)&pIdxInfo[1];
+ Parse *pParse = pHidden->pParse;
+ int nDb = pParse->db->nDb;
+ int i;
+ for(i=0; i<nDb; i++) sqlite3BeginWriteOperation(pParse, 0, i);
+}
+#endif
+
+/*
** Add all WhereLoop objects for a table of the join identified by
** pBuilder->pNew->iTab. That table is guaranteed to be a virtual table.
**
@@ -3478,6 +3832,7 @@ static int whereLoopAddVirtual(
WhereLoop *pNew;
Bitmask mBest; /* Tables used by best possible plan */
u16 mNoOmit;
+ int bRetry = 0; /* True to retry with LIMIT/OFFSET disabled */
assert( (mPrereq & mUnusable)==0 );
pWInfo = pBuilder->pWInfo;
@@ -3486,8 +3841,7 @@ static int whereLoopAddVirtual(
pNew = pBuilder->pNew;
pSrc = &pWInfo->pTabList->a[pNew->iTab];
assert( IsVirtual(pSrc->pTab) );
- p = allocateIndexInfo(pParse, pWC, mUnusable, pSrc, pBuilder->pOrderBy,
- &mNoOmit);
+ p = allocateIndexInfo(pWInfo, pWC, mUnusable, pSrc, &mNoOmit);
if( p==0 ) return SQLITE_NOMEM_BKPT;
pNew->rSetup = 0;
pNew->wsFlags = WHERE_VIRTUALTABLE;
@@ -3495,14 +3849,22 @@ static int whereLoopAddVirtual(
pNew->u.vtab.needFree = 0;
nConstraint = p->nConstraint;
if( whereLoopResize(pParse->db, pNew, nConstraint) ){
- sqlite3DbFree(pParse->db, p);
+ freeIndexInfo(pParse->db, p);
return SQLITE_NOMEM_BKPT;
}
/* First call xBestIndex() with all constraints usable. */
WHERETRACE(0x800, ("BEGIN %s.addVirtual()\n", pSrc->pTab->zName));
WHERETRACE(0x40, (" VirtualOne: all usable\n"));
- rc = whereLoopAddVirtualOne(pBuilder, mPrereq, ALLBITS, 0, p, mNoOmit, &bIn);
+ rc = whereLoopAddVirtualOne(
+ pBuilder, mPrereq, ALLBITS, 0, p, mNoOmit, &bIn, &bRetry
+ );
+ if( bRetry ){
+ assert( rc==SQLITE_OK );
+ rc = whereLoopAddVirtualOne(
+ pBuilder, mPrereq, ALLBITS, 0, p, mNoOmit, &bIn, 0
+ );
+ }
/* If the call to xBestIndex() with all terms enabled produced a plan
** that does not require any source tables (IOW: a plan with mBest==0)
@@ -3520,7 +3882,7 @@ static int whereLoopAddVirtual(
if( bIn ){
WHERETRACE(0x40, (" VirtualOne: all usable w/o IN\n"));
rc = whereLoopAddVirtualOne(
- pBuilder, mPrereq, ALLBITS, WO_IN, p, mNoOmit, &bIn);
+ pBuilder, mPrereq, ALLBITS, WO_IN, p, mNoOmit, &bIn, 0);
assert( bIn==0 );
mBestNoIn = pNew->prereq & ~mPrereq;
if( mBestNoIn==0 ){
@@ -3547,7 +3909,7 @@ static int whereLoopAddVirtual(
WHERETRACE(0x40, (" VirtualOne: mPrev=%04llx mNext=%04llx\n",
(sqlite3_uint64)mPrev, (sqlite3_uint64)mNext));
rc = whereLoopAddVirtualOne(
- pBuilder, mPrereq, mNext|mPrereq, 0, p, mNoOmit, &bIn);
+ pBuilder, mPrereq, mNext|mPrereq, 0, p, mNoOmit, &bIn, 0);
if( pNew->prereq==mPrereq ){
seenZero = 1;
if( bIn==0 ) seenZeroNoIN = 1;
@@ -3560,7 +3922,7 @@ static int whereLoopAddVirtual(
if( rc==SQLITE_OK && seenZero==0 ){
WHERETRACE(0x40, (" VirtualOne: all disabled\n"));
rc = whereLoopAddVirtualOne(
- pBuilder, mPrereq, mPrereq, 0, p, mNoOmit, &bIn);
+ pBuilder, mPrereq, mPrereq, 0, p, mNoOmit, &bIn, 0);
if( bIn==0 ) seenZeroNoIN = 1;
}
@@ -3570,12 +3932,12 @@ static int whereLoopAddVirtual(
if( rc==SQLITE_OK && seenZeroNoIN==0 ){
WHERETRACE(0x40, (" VirtualOne: all disabled and w/o IN\n"));
rc = whereLoopAddVirtualOne(
- pBuilder, mPrereq, mPrereq, WO_IN, p, mNoOmit, &bIn);
+ pBuilder, mPrereq, mPrereq, WO_IN, p, mNoOmit, &bIn, 0);
}
}
if( p->needToFreeIdxStr ) sqlite3_free(p->idxStr);
- sqlite3DbFreeNN(pParse->db, p);
+ freeIndexInfo(pParse->db, p);
WHERETRACE(0x800, ("END %s.addVirtual(), rc=%d\n", pSrc->pTab->zName, rc));
return rc;
}
@@ -3619,7 +3981,6 @@ static int whereLoopAddOr(
int i, j;
sSubBuild = *pBuilder;
- sSubBuild.pOrderBy = 0;
sSubBuild.pOrSet = &sCur;
WHERETRACE(0x200, ("Begin processing OR-clause %p\n", pTerm));
@@ -3631,6 +3992,7 @@ static int whereLoopAddOr(
tempWC.pOuter = pWC;
tempWC.op = TK_AND;
tempWC.nTerm = 1;
+ tempWC.nBase = 1;
tempWC.a = pOrTerm;
sSubBuild.pWC = &tempWC;
}else{
@@ -4738,6 +5100,150 @@ static void showAllWhereLoops(WhereInfo *pWInfo, WhereClause *pWC){
# define WHERETRACE_ALL_LOOPS(W,C)
#endif
+/* Attempt to omit tables from a join that do not affect the result.
+** For a table to not affect the result, the following must be true:
+**
+** 1) The query must not be an aggregate.
+** 2) The table must be the RHS of a LEFT JOIN.
+** 3) Either the query must be DISTINCT, or else the ON or USING clause
+** must contain a constraint that limits the scan of the table to
+** at most a single row.
+** 4) The table must not be referenced by any part of the query apart
+** from its own USING or ON clause.
+**
+** For example, given:
+**
+** CREATE TABLE t1(ipk INTEGER PRIMARY KEY, v1);
+** CREATE TABLE t2(ipk INTEGER PRIMARY KEY, v2);
+** CREATE TABLE t3(ipk INTEGER PRIMARY KEY, v3);
+**
+** then table t2 can be omitted from the following:
+**
+** SELECT v1, v3 FROM t1
+** LEFT JOIN t2 ON (t1.ipk=t2.ipk)
+** LEFT JOIN t3 ON (t1.ipk=t3.ipk)
+**
+** or from:
+**
+** SELECT DISTINCT v1, v3 FROM t1
+** LEFT JOIN t2
+** LEFT JOIN t3 ON (t1.ipk=t3.ipk)
+*/
+static SQLITE_NOINLINE Bitmask whereOmitNoopJoin(
+ WhereInfo *pWInfo,
+ Bitmask notReady
+){
+ int i;
+ Bitmask tabUsed;
+
+ /* Preconditions checked by the caller */
+ assert( pWInfo->nLevel>=2 );
+ assert( OptimizationEnabled(pWInfo->pParse->db, SQLITE_OmitNoopJoin) );
+
+ /* These two preconditions checked by the caller combine to guarantee
+ ** condition (1) of the header comment */
+ assert( pWInfo->pResultSet!=0 );
+ assert( 0==(pWInfo->wctrlFlags & WHERE_AGG_DISTINCT) );
+
+ tabUsed = sqlite3WhereExprListUsage(&pWInfo->sMaskSet, pWInfo->pResultSet);
+ if( pWInfo->pOrderBy ){
+ tabUsed |= sqlite3WhereExprListUsage(&pWInfo->sMaskSet, pWInfo->pOrderBy);
+ }
+ for(i=pWInfo->nLevel-1; i>=1; i--){
+ WhereTerm *pTerm, *pEnd;
+ SrcItem *pItem;
+ WhereLoop *pLoop;
+ pLoop = pWInfo->a[i].pWLoop;
+ pItem = &pWInfo->pTabList->a[pLoop->iTab];
+ if( (pItem->fg.jointype & JT_LEFT)==0 ) continue;
+ if( (pWInfo->wctrlFlags & WHERE_WANT_DISTINCT)==0
+ && (pLoop->wsFlags & WHERE_ONEROW)==0
+ ){
+ continue;
+ }
+ if( (tabUsed & pLoop->maskSelf)!=0 ) continue;
+ pEnd = pWInfo->sWC.a + pWInfo->sWC.nTerm;
+ for(pTerm=pWInfo->sWC.a; pTerm<pEnd; pTerm++){
+ if( (pTerm->prereqAll & pLoop->maskSelf)!=0 ){
+ if( !ExprHasProperty(pTerm->pExpr, EP_FromJoin)
+ || pTerm->pExpr->w.iRightJoinTable!=pItem->iCursor
+ ){
+ break;
+ }
+ }
+ }
+ if( pTerm<pEnd ) continue;
+ WHERETRACE(0xffff, ("-> drop loop %c not used\n", pLoop->cId));
+ notReady &= ~pLoop->maskSelf;
+ for(pTerm=pWInfo->sWC.a; pTerm<pEnd; pTerm++){
+ if( (pTerm->prereqAll & pLoop->maskSelf)!=0 ){
+ pTerm->wtFlags |= TERM_CODED;
+ }
+ }
+ if( i!=pWInfo->nLevel-1 ){
+ int nByte = (pWInfo->nLevel-1-i) * sizeof(WhereLevel);
+ memmove(&pWInfo->a[i], &pWInfo->a[i+1], nByte);
+ }
+ pWInfo->nLevel--;
+ assert( pWInfo->nLevel>0 );
+ }
+ return notReady;
+}
+
+/*
+** Check to see if there are any SEARCH loops that might benefit from
+** using a Bloom filter. Consider a Bloom filter if:
+**
+** (1) The SEARCH happens more than N times where N is the number
+** of rows in the table that is being considered for the Bloom
+** filter.
+** (2) Some searches are expected to find zero rows. (This is determined
+** by the WHERE_SELFCULL flag on the term.)
+** (3) Bloom-filter processing is not disabled. (Checked by the
+** caller.)
+** (4) The size of the table being searched is known by ANALYZE.
+**
+** This block of code merely checks to see if a Bloom filter would be
+** appropriate, and if so sets the WHERE_BLOOMFILTER flag on the
+** WhereLoop. The implementation of the Bloom filter comes further
+** down where the code for each WhereLoop is generated.
+*/
+static SQLITE_NOINLINE void whereCheckIfBloomFilterIsUseful(
+ const WhereInfo *pWInfo
+){
+ int i;
+ LogEst nSearch;
+
+ assert( pWInfo->nLevel>=2 );
+ assert( OptimizationEnabled(pWInfo->pParse->db, SQLITE_BloomFilter) );
+ nSearch = pWInfo->a[0].pWLoop->nOut;
+ for(i=1; i<pWInfo->nLevel; i++){
+ WhereLoop *pLoop = pWInfo->a[i].pWLoop;
+ const unsigned int reqFlags = (WHERE_SELFCULL|WHERE_COLUMN_EQ);
+ if( (pLoop->wsFlags & reqFlags)==reqFlags
+ /* vvvvvv--- Always the case if WHERE_COLUMN_EQ is defined */
+ && ALWAYS((pLoop->wsFlags & (WHERE_IPK|WHERE_INDEXED))!=0)
+ ){
+ SrcItem *pItem = &pWInfo->pTabList->a[pLoop->iTab];
+ Table *pTab = pItem->pTab;
+ pTab->tabFlags |= TF_StatsUsed;
+ if( nSearch > pTab->nRowLogEst
+ && (pTab->tabFlags & TF_HasStat1)!=0
+ ){
+ testcase( pItem->fg.jointype & JT_LEFT );
+ pLoop->wsFlags |= WHERE_BLOOMFILTER;
+ pLoop->wsFlags &= ~WHERE_IDX_ONLY;
+ WHERETRACE(0xffff, (
+ "-> use Bloom-filter on loop %c because there are ~%.1e "
+ "lookups into %s which has only ~%.1e rows\n",
+ pLoop->cId, (double)sqlite3LogEstToInt(nSearch), pTab->zName,
+ (double)sqlite3LogEstToInt(pTab->nRowLogEst)));
+ }
+ }
+ nSearch += pLoop->nOut;
+ }
+}
+
/*
** Generate the beginning of the loop used for WHERE clause processing.
** The return value is a pointer to an opaque structure that contains
@@ -4832,6 +5338,7 @@ WhereInfo *sqlite3WhereBegin(
Expr *pWhere, /* The WHERE clause */
ExprList *pOrderBy, /* An ORDER BY (or GROUP BY) clause, or NULL */
ExprList *pResultSet, /* Query result set. Req'd for DISTINCT */
+ Select *pLimit, /* Use this LIMIT/OFFSET clause, if any */
u16 wctrlFlags, /* The WHERE_* flags defined in sqliteInt.h */
int iAuxArg /* If WHERE_OR_SUBCLAUSE is set, index cursor number
** If WHERE_USE_LIMIT, then the limit amount */
@@ -4866,13 +5373,6 @@ WhereInfo *sqlite3WhereBegin(
/* An ORDER/GROUP BY clause of more than 63 terms cannot be optimized */
testcase( pOrderBy && pOrderBy->nExpr==BMS-1 );
if( pOrderBy && pOrderBy->nExpr>=BMS ) pOrderBy = 0;
- sWLB.pOrderBy = pOrderBy;
-
- /* Disable the DISTINCT optimization if SQLITE_DistinctOpt is set via
- ** sqlite3_test_ctrl(SQLITE_TESTCTRL_OPTIMIZATIONS,...) */
- if( OptimizationDisabled(db, SQLITE_DistinctOpt) ){
- wctrlFlags &= ~WHERE_WANT_DISTINCT;
- }
/* The number of tables in the FROM clause is limited by the number of
** bits in a Bitmask
@@ -4915,11 +5415,18 @@ WhereInfo *sqlite3WhereBegin(
pWInfo->wctrlFlags = wctrlFlags;
pWInfo->iLimit = iAuxArg;
pWInfo->savedNQueryLoop = pParse->nQueryLoop;
+#ifndef SQLITE_OMIT_VIRTUALTABLE
+ pWInfo->pLimit = pLimit;
+#endif
memset(&pWInfo->nOBSat, 0,
offsetof(WhereInfo,sWC) - offsetof(WhereInfo,nOBSat));
memset(&pWInfo->a[0], 0, sizeof(WhereLoop)+nTabList*sizeof(WhereLevel));
assert( pWInfo->eOnePass==ONEPASS_OFF ); /* ONEPASS defaults to OFF */
pMaskSet = &pWInfo->sMaskSet;
+ pMaskSet->n = 0;
+ pMaskSet->ix[0] = -99; /* Initialize ix[0] to a value that can never be
+ ** a valid cursor number, to avoid an initial
+ ** test for pMaskSet->n==0 in sqlite3WhereGetMask() */
sWLB.pWInfo = pWInfo;
sWLB.pWC = &pWInfo->sWC;
sWLB.pNew = (WhereLoop*)(((char*)pWInfo)+nByteWInfo);
@@ -4932,7 +5439,6 @@ WhereInfo *sqlite3WhereBegin(
/* Split the WHERE clause into separate subexpressions where each
** subexpression is separated by an AND operator.
*/
- initMaskSet(pMaskSet);
sqlite3WhereClauseInit(&pWInfo->sWC, pWInfo);
sqlite3WhereSplit(&pWInfo->sWC, pWhere, TK_AND);
@@ -4940,7 +5446,9 @@ WhereInfo *sqlite3WhereBegin(
*/
if( nTabList==0 ){
if( pOrderBy ) pWInfo->nOBSat = pOrderBy->nExpr;
- if( wctrlFlags & WHERE_WANT_DISTINCT ){
+ if( (wctrlFlags & WHERE_WANT_DISTINCT)!=0
+ && OptimizationEnabled(db, SQLITE_DistinctOpt)
+ ){
pWInfo->eDistinct = WHERE_DISTINCT_UNIQUE;
}
ExplainQueryPlan((pParse, 0, "SCAN CONSTANT ROW"));
@@ -4978,6 +5486,7 @@ WhereInfo *sqlite3WhereBegin(
/* Analyze all of the subexpressions. */
sqlite3WhereExprAnalyze(pTabList, &pWInfo->sWC);
+ sqlite3WhereAddLimit(&pWInfo->sWC, pLimit);
if( db->mallocFailed ) goto whereBeginError;
/* Special case: WHERE terms that do not refer to any tables in the join
@@ -4991,7 +5500,7 @@ WhereInfo *sqlite3WhereBegin(
** FROM ... WHERE random()>0; -- eval random() once per row
** FROM ... WHERE (SELECT random())>0; -- eval random() once overall
*/
- for(ii=0; ii<sWLB.pWC->nTerm; ii++){
+ for(ii=0; ii<sWLB.pWC->nBase; ii++){
WhereTerm *pT = &sWLB.pWC->a[ii];
if( pT->wtFlags & TERM_VIRTUAL ) continue;
if( pT->prereqAll==0 && (nTabList==0 || exprIsDeterministic(pT->pExpr)) ){
@@ -5001,7 +5510,12 @@ WhereInfo *sqlite3WhereBegin(
}
if( wctrlFlags & WHERE_WANT_DISTINCT ){
- if( isDistinctRedundant(pParse, pTabList, &pWInfo->sWC, pResultSet) ){
+ if( OptimizationDisabled(db, SQLITE_DistinctOpt) ){
+ /* Disable the DISTINCT optimization if SQLITE_DistinctOpt is set via
+ ** sqlite3_test_ctrl(SQLITE_TESTCTRL_OPTIMIZATIONS,...) */
+ wctrlFlags &= ~WHERE_WANT_DISTINCT;
+ pWInfo->wctrlFlags &= ~WHERE_WANT_DISTINCT;
+ }else if( isDistinctRedundant(pParse, pTabList, &pWInfo->sWC, pResultSet) ){
/* The DISTINCT marking is pointless. Ignore it. */
pWInfo->eDistinct = WHERE_DISTINCT_UNIQUE;
}else if( pOrderBy==0 ){
@@ -5072,9 +5586,10 @@ WhereInfo *sqlite3WhereBegin(
if( pWInfo->pOrderBy==0 && (db->flags & SQLITE_ReverseOrder)!=0 ){
pWInfo->revMask = ALLBITS;
}
- if( pParse->nErr || db->mallocFailed ){
+ if( pParse->nErr ){
goto whereBeginError;
}
+ assert( db->mallocFailed==0 );
#ifdef WHERETRACE_ENABLED
if( sqlite3WhereTrace ){
sqlite3DebugPrintf("---- Solution nRow=%d", pWInfo->nRowOut);
@@ -5102,34 +5617,15 @@ WhereInfo *sqlite3WhereBegin(
}
#endif
- /* Attempt to omit tables from the join that do not affect the result.
- ** For a table to not affect the result, the following must be true:
- **
- ** 1) The query must not be an aggregate.
- ** 2) The table must be the RHS of a LEFT JOIN.
- ** 3) Either the query must be DISTINCT, or else the ON or USING clause
- ** must contain a constraint that limits the scan of the table to
- ** at most a single row.
- ** 4) The table must not be referenced by any part of the query apart
- ** from its own USING or ON clause.
- **
- ** For example, given:
+ /* Attempt to omit tables from a join that do not affect the result.
+ ** See the comment on whereOmitNoopJoin() for further information.
**
- ** CREATE TABLE t1(ipk INTEGER PRIMARY KEY, v1);
- ** CREATE TABLE t2(ipk INTEGER PRIMARY KEY, v2);
- ** CREATE TABLE t3(ipk INTEGER PRIMARY KEY, v3);
- **
- ** then table t2 can be omitted from the following:
- **
- ** SELECT v1, v3 FROM t1
- ** LEFT JOIN t2 ON (t1.ipk=t2.ipk)
- ** LEFT JOIN t3 ON (t1.ipk=t3.ipk)
- **
- ** or from:
- **
- ** SELECT DISTINCT v1, v3 FROM t1
- ** LEFT JOIN t2
- ** LEFT JOIN t3 ON (t1.ipk=t3.ipk)
+ ** This query optimization is factored out into a separate "no-inline"
+ ** procedure to keep the sqlite3WhereBegin() procedure from becoming
+ ** too large. If sqlite3WhereBegin() becomes too large, that prevents
+ ** some C-compiler optimizers from in-lining the
+ ** sqlite3WhereCodeOneLoopStart() procedure, and it is important to
+ ** in-line sqlite3WhereCodeOneLoopStart() for performance reasons.
*/
notReady = ~(Bitmask)0;
if( pWInfo->nLevel>=2
@@ -5137,49 +5633,20 @@ WhereInfo *sqlite3WhereBegin(
&& 0==(wctrlFlags & WHERE_AGG_DISTINCT) /* condition (1) above */
&& OptimizationEnabled(db, SQLITE_OmitNoopJoin)
){
- int i;
- Bitmask tabUsed = sqlite3WhereExprListUsage(pMaskSet, pResultSet);
- if( sWLB.pOrderBy ){
- tabUsed |= sqlite3WhereExprListUsage(pMaskSet, sWLB.pOrderBy);
- }
- for(i=pWInfo->nLevel-1; i>=1; i--){
- WhereTerm *pTerm, *pEnd;
- SrcItem *pItem;
- pLoop = pWInfo->a[i].pWLoop;
- pItem = &pWInfo->pTabList->a[pLoop->iTab];
- if( (pItem->fg.jointype & JT_LEFT)==0 ) continue;
- if( (wctrlFlags & WHERE_WANT_DISTINCT)==0
- && (pLoop->wsFlags & WHERE_ONEROW)==0
- ){
- continue;
- }
- if( (tabUsed & pLoop->maskSelf)!=0 ) continue;
- pEnd = sWLB.pWC->a + sWLB.pWC->nTerm;
- for(pTerm=sWLB.pWC->a; pTerm<pEnd; pTerm++){
- if( (pTerm->prereqAll & pLoop->maskSelf)!=0 ){
- if( !ExprHasProperty(pTerm->pExpr, EP_FromJoin)
- || pTerm->pExpr->iRightJoinTable!=pItem->iCursor
- ){
- break;
- }
- }
- }
- if( pTerm<pEnd ) continue;
- WHERETRACE(0xffff, ("-> drop loop %c not used\n", pLoop->cId));
- notReady &= ~pLoop->maskSelf;
- for(pTerm=sWLB.pWC->a; pTerm<pEnd; pTerm++){
- if( (pTerm->prereqAll & pLoop->maskSelf)!=0 ){
- pTerm->wtFlags |= TERM_CODED;
- }
- }
- if( i!=pWInfo->nLevel-1 ){
- int nByte = (pWInfo->nLevel-1-i) * sizeof(WhereLevel);
- memmove(&pWInfo->a[i], &pWInfo->a[i+1], nByte);
- }
- pWInfo->nLevel--;
- nTabList--;
- }
+ notReady = whereOmitNoopJoin(pWInfo, notReady);
+ nTabList = pWInfo->nLevel;
+ assert( nTabList>0 );
+ }
+
+ /* Check to see if there are any SEARCH loops that might benefit from
+ ** using a Bloom filter.
+ */
+ if( pWInfo->nLevel>=2
+ && OptimizationEnabled(db, SQLITE_BloomFilter)
+ ){
+ whereCheckIfBloomFilterIsUseful(pWInfo);
}
+
#if defined(WHERETRACE_ENABLED)
if( sqlite3WhereTrace & 0x100 ){ /* Display all terms of the WHERE clause */
sqlite3DebugPrintf("---- WHERE clause at end of analysis:\n");
@@ -5266,6 +5733,7 @@ WhereInfo *sqlite3WhereBegin(
if( pWInfo->eOnePass==ONEPASS_OFF
&& pTab->nCol<BMS
&& (pTab->tabFlags & (TF_HasGenerated|TF_WithoutRowid))==0
+ && (pLoop->wsFlags & (WHERE_AUTO_INDEX|WHERE_BLOOMFILTER))==0
){
/* If we know that only a prefix of the record will be used,
** it is advantageous to reduce the "column count" field in
@@ -5368,13 +5836,17 @@ WhereInfo *sqlite3WhereBegin(
if( pParse->nErr ) goto whereBeginError;
pLevel = &pWInfo->a[ii];
wsFlags = pLevel->pWLoop->wsFlags;
+ if( (wsFlags & (WHERE_AUTO_INDEX|WHERE_BLOOMFILTER))!=0 ){
+ if( (wsFlags & WHERE_AUTO_INDEX)!=0 ){
#ifndef SQLITE_OMIT_AUTOMATIC_INDEX
- if( (pLevel->pWLoop->wsFlags & WHERE_AUTO_INDEX)!=0 ){
- constructAutomaticIndex(pParse, &pWInfo->sWC,
- &pTabList->a[pLevel->iFrom], notReady, pLevel);
+ constructAutomaticIndex(pParse, &pWInfo->sWC,
+ &pTabList->a[pLevel->iFrom], notReady, pLevel);
+#endif
+ }else{
+ sqlite3ConstructBloomFilter(pWInfo, ii, pLevel, notReady);
+ }
if( db->mallocFailed ) goto whereBeginError;
}
-#endif
addrExplain = sqlite3WhereExplainOneScan(
pParse, pTabList, pLevel, wctrlFlags
);
@@ -5678,6 +6150,10 @@ void sqlite3WhereEnd(WhereInfo *pWInfo){
Index *pPk = sqlite3PrimaryKeyIndex(pTab);
x = pPk->aiColumn[x];
assert( x>=0 );
+#ifdef SQLITE_ENABLE_OFFSET_SQL_FUNC
+ }else if( pOp->opcode==OP_Offset ){
+ /* Do not need to translate the column number */
+#endif
}else{
testcase( x!=sqlite3StorageColumnToTable(pTab,x) );
x = sqlite3StorageColumnToTable(pTab,x);
diff --git a/chromium/third_party/sqlite/src/src/whereInt.h b/chromium/third_party/sqlite/src/src/whereInt.h
index f651e790cce..3fc39f6b4a5 100644
--- a/chromium/third_party/sqlite/src/src/whereInt.h
+++ b/chromium/third_party/sqlite/src/src/whereInt.h
@@ -64,6 +64,7 @@ struct WhereLevel {
u32 iLikeRepCntr; /* LIKE range processing counter register (times 2) */
int addrLikeRep; /* LIKE range processing address */
#endif
+ int regFilter; /* Bloom filter */
u8 iFrom; /* Which entry in the FROM clause */
u8 op, p3, p5; /* Opcode, P3 & P5 of the opcode that ends the loop */
int p1, p2; /* Operands of the opcode used to end the loop */
@@ -122,10 +123,12 @@ struct WhereLoop {
} btree;
struct { /* Information for virtual tables */
int idxNum; /* Index number */
- u8 needFree; /* True if sqlite3_free(idxStr) is needed */
+ u32 needFree : 1; /* True if sqlite3_free(idxStr) is needed */
+ u32 bOmitOffset : 1; /* True to let virtual table handle offset */
i8 isOrdered; /* True if satisfies ORDER BY */
u16 omitMask; /* Terms that may be omitted */
char *idxStr; /* Index identifier string */
+ u32 mHandleIn; /* Terms to handle as IN(...) instead of == */
} vtab;
} u;
u32 wsFlags; /* WHERE_* flags describing the plan */
@@ -269,7 +272,7 @@ struct WhereTerm {
#define TERM_COPIED 0x0008 /* Has a child */
#define TERM_ORINFO 0x0010 /* Need to free the WhereTerm.u.pOrInfo object */
#define TERM_ANDINFO 0x0020 /* Need to free the WhereTerm.u.pAndInfo obj */
-#define TERM_OR_OK 0x0040 /* Used during OR-clause processing */
+#define TERM_OK 0x0040 /* Used during OR-clause processing */
#define TERM_VNULL 0x0080 /* Manufactured x>NULL or x<=NULL term */
#define TERM_LIKEOPT 0x0100 /* Virtual terms from the LIKE optimization */
#define TERM_LIKECOND 0x0200 /* Conditionally this LIKE operator term */
@@ -282,6 +285,7 @@ struct WhereTerm {
#else
# define TERM_HIGHTRUTH 0 /* Only used with STAT4 */
#endif
+#define TERM_SLICE 0x8000 /* One slice of a row-value/vector comparison */
/*
** An instance of the WhereScan object is used as an iterator for locating
@@ -292,11 +296,11 @@ struct WhereScan {
WhereClause *pWC; /* WhereClause currently being scanned */
const char *zCollName; /* Required collating sequence, if not NULL */
Expr *pIdxExpr; /* Search for this index expression */
+ int k; /* Resume scanning at this->pWC->a[this->k] */
+ u32 opMask; /* Acceptable operators */
char idxaff; /* Must match this affinity, if zCollName!=NULL */
+ unsigned char iEquiv; /* Current slot in aiCur[] and aiColumn[] */
unsigned char nEquiv; /* Number of entries in aiCur[] and aiColumn[] */
- unsigned char iEquiv; /* Next unused slot in aiCur[] and aiColumn[] */
- u32 opMask; /* Acceptable operators */
- int k; /* Resume scanning at this->pWC->a[this->k] */
int aiCur[11]; /* Cursors in the equivalence class */
i16 aiColumn[11]; /* Corresponding column number in the eq-class */
};
@@ -320,6 +324,7 @@ struct WhereClause {
u8 hasOr; /* True if any a[].eOperator is WO_OR */
int nTerm; /* Number of terms */
int nSlot; /* Number of entries in a[] */
+ int nBase; /* Number of terms through the last non-Virtual */
WhereTerm *a; /* Each a[] describes a term of the WHERE cluase */
#if defined(SQLITE_SMALL_STACK)
WhereTerm aStatic[1]; /* Initial static space for a[] */
@@ -378,18 +383,12 @@ struct WhereMaskSet {
};
/*
-** Initialize a WhereMaskSet object
-*/
-#define initMaskSet(P) (P)->n=0
-
-/*
** This object is a convenience wrapper holding all information needed
** to construct WhereLoop objects for a particular query.
*/
struct WhereLoopBuilder {
WhereInfo *pWInfo; /* Information about this WHERE */
WhereClause *pWC; /* WHERE clause terms */
- ExprList *pOrderBy; /* ORDER BY clause */
WhereLoop *pNew; /* Template WhereLoop */
WhereOrSet *pOrSet; /* Record best loops here, if not NULL */
#ifdef SQLITE_ENABLE_STAT4
@@ -457,6 +456,9 @@ struct WhereInfo {
ExprList *pOrderBy; /* The ORDER BY clause or NULL */
ExprList *pResultSet; /* Result set of the query */
Expr *pWhere; /* The complete WHERE clause */
+#ifndef SQLITE_OMIT_VIRTUALTABLE
+ Select *pLimit; /* Used to access LIMIT expr/registers for vtabs */
+#endif
int aiCurOnePass[2]; /* OP_OpenWrite cursors for the ONEPASS opt */
int iContinue; /* Jump here to continue with next record */
int iBreak; /* Jump here to break out of the loop */
@@ -510,8 +512,14 @@ int sqlite3WhereExplainOneScan(
WhereLevel *pLevel, /* Scan to write OP_Explain opcode for */
u16 wctrlFlags /* Flags passed to sqlite3WhereBegin() */
);
+int sqlite3WhereExplainBloomFilter(
+ const Parse *pParse, /* Parse context */
+ const WhereInfo *pWInfo, /* WHERE clause */
+ const WhereLevel *pLevel /* Bloom filter on this level */
+);
#else
# define sqlite3WhereExplainOneScan(u,v,w,x) 0
+# define sqlite3WhereExplainBloomFilter(u,v,w) 0
#endif /* SQLITE_OMIT_EXPLAIN */
#ifdef SQLITE_ENABLE_STMT_SCANSTATUS
void sqlite3WhereAddScanStatus(
@@ -536,6 +544,7 @@ Bitmask sqlite3WhereCodeOneLoopStart(
void sqlite3WhereClauseInit(WhereClause*,WhereInfo*);
void sqlite3WhereClauseClear(WhereClause*);
void sqlite3WhereSplit(WhereClause*,Expr*,u8);
+void sqlite3WhereAddLimit(WhereClause*, Select*);
Bitmask sqlite3WhereExprUsage(WhereMaskSet*, Expr*);
Bitmask sqlite3WhereExprUsageNN(WhereMaskSet*, Expr*);
Bitmask sqlite3WhereExprListUsage(WhereMaskSet*, ExprList*);
@@ -604,5 +613,8 @@ void sqlite3WhereTabFuncArgs(Parse*, SrcItem*, WhereClause*);
#define WHERE_BIGNULL_SORT 0x00080000 /* Column nEq of index is BIGNULL */
#define WHERE_IN_SEEKSCAN 0x00100000 /* Seek-scan optimization for IN */
#define WHERE_TRANSCONS 0x00200000 /* Uses a transitive constraint */
+#define WHERE_BLOOMFILTER 0x00400000 /* Consider using a Bloom-filter */
+#define WHERE_SELFCULL 0x00800000 /* nOut reduced by extra WHERE terms */
+#define WHERE_OMIT_OFFSET 0x01000000 /* Set offset counter to zero */
#endif /* !defined(SQLITE_WHEREINT_H) */
diff --git a/chromium/third_party/sqlite/src/src/wherecode.c b/chromium/third_party/sqlite/src/src/wherecode.c
index 460ac4fe30a..6944c3acd56 100644
--- a/chromium/third_party/sqlite/src/src/wherecode.c
+++ b/chromium/third_party/sqlite/src/src/wherecode.c
@@ -176,19 +176,27 @@ int sqlite3WhereExplainOneScan(
explainIndexRange(&str, pLoop);
}
}else if( (flags & WHERE_IPK)!=0 && (flags & WHERE_CONSTRAINT)!=0 ){
- const char *zRangeOp;
+ char cRangeOp;
+#if 0 /* Better output, but breaks many tests */
+ const Table *pTab = pItem->pTab;
+ const char *zRowid = pTab->iPKey>=0 ? pTab->aCol[pTab->iPKey].zCnName:
+ "rowid";
+#else
+ const char *zRowid = "rowid";
+#endif
+ sqlite3_str_appendf(&str, " USING INTEGER PRIMARY KEY (%s", zRowid);
if( flags&(WHERE_COLUMN_EQ|WHERE_COLUMN_IN) ){
- zRangeOp = "=";
+ cRangeOp = '=';
}else if( (flags&WHERE_BOTH_LIMIT)==WHERE_BOTH_LIMIT ){
- zRangeOp = ">? AND rowid<";
+ sqlite3_str_appendf(&str, ">? AND %s", zRowid);
+ cRangeOp = '<';
}else if( flags&WHERE_BTM_LIMIT ){
- zRangeOp = ">";
+ cRangeOp = '>';
}else{
assert( flags&WHERE_TOP_LIMIT);
- zRangeOp = "<";
+ cRangeOp = '<';
}
- sqlite3_str_appendf(&str,
- " USING INTEGER PRIMARY KEY (rowid%s?)",zRangeOp);
+ sqlite3_str_appendf(&str, "%c?)", cRangeOp);
}
#ifndef SQLITE_OMIT_VIRTUALTABLE
else if( (flags & WHERE_VIRTUALTABLE)!=0 ){
@@ -211,6 +219,56 @@ int sqlite3WhereExplainOneScan(
}
return ret;
}
+
+/*
+** Add a single OP_Explain opcode that describes a Bloom filter.
+**
+** Or if not processing EXPLAIN QUERY PLAN and not in a SQLITE_DEBUG and/or
+** SQLITE_ENABLE_STMT_SCANSTATUS build, then OP_Explain opcodes are not
+** required and this routine is a no-op.
+**
+** If an OP_Explain opcode is added to the VM, its address is returned.
+** Otherwise, if no OP_Explain is coded, zero is returned.
+*/
+int sqlite3WhereExplainBloomFilter(
+ const Parse *pParse, /* Parse context */
+ const WhereInfo *pWInfo, /* WHERE clause */
+ const WhereLevel *pLevel /* Bloom filter on this level */
+){
+ int ret = 0;
+ SrcItem *pItem = &pWInfo->pTabList->a[pLevel->iFrom];
+ Vdbe *v = pParse->pVdbe; /* VM being constructed */
+ sqlite3 *db = pParse->db; /* Database handle */
+ char *zMsg; /* Text to add to EQP output */
+ int i; /* Loop counter */
+ WhereLoop *pLoop; /* The where loop */
+ StrAccum str; /* EQP output string */
+ char zBuf[100]; /* Initial space for EQP output string */
+
+ sqlite3StrAccumInit(&str, db, zBuf, sizeof(zBuf), SQLITE_MAX_LENGTH);
+ str.printfFlags = SQLITE_PRINTF_INTERNAL;
+ sqlite3_str_appendf(&str, "BLOOM FILTER ON %S (", pItem);
+ pLoop = pLevel->pWLoop;
+ if( pLoop->wsFlags & WHERE_IPK ){
+ const Table *pTab = pItem->pTab;
+ if( pTab->iPKey>=0 ){
+ sqlite3_str_appendf(&str, "%s=?", pTab->aCol[pTab->iPKey].zCnName);
+ }else{
+ sqlite3_str_appendf(&str, "rowid=?");
+ }
+ }else{
+ for(i=pLoop->nSkip; i<pLoop->u.btree.nEq; i++){
+ const char *z = explainIndexColumnName(pLoop->u.btree.pIndex, i);
+ if( i>pLoop->nSkip ) sqlite3_str_append(&str, " AND ", 5);
+ sqlite3_str_appendf(&str, "%s=?", z);
+ }
+ }
+ sqlite3_str_append(&str, ")", 1);
+ zMsg = sqlite3StrAccumFinish(&str);
+ ret = sqlite3VdbeAddOp4(v, OP_Explain, sqlite3VdbeCurrentAddr(v),
+ pParse->addrExplain, 0, zMsg,P4_DYNAMIC);
+ return ret;
+}
#endif /* SQLITE_OMIT_EXPLAIN */
#ifdef SQLITE_ENABLE_STMT_SCANSTATUS
@@ -734,6 +792,7 @@ static int codeAllEqualityTerms(
VdbeCoverageIf(v, bRev!=0);
VdbeComment((v, "begin skip-scan on %s", pIdx->zName));
j = sqlite3VdbeAddOp0(v, OP_Goto);
+ assert( pLevel->addrSkip==0 );
pLevel->addrSkip = sqlite3VdbeAddOp4Int(v, (bRev?OP_SeekLT:OP_SeekGT),
iIdxCur, 0, regBase, nSkip);
VdbeCoverageIf(v, bRev==0);
@@ -766,6 +825,9 @@ static int codeAllEqualityTerms(
sqlite3VdbeAddOp2(v, OP_Copy, r1, regBase+j);
}
}
+ }
+ for(j=nSkip; j<nEq; j++){
+ pTerm = pLoop->aLTerm[j];
if( pTerm->eOperator & WO_IN ){
if( pTerm->pExpr->flags & EP_xIsSelect ){
/* No affinity ever needs to be (or should be) applied to a value
@@ -780,7 +842,8 @@ static int codeAllEqualityTerms(
sqlite3VdbeAddOp2(v, OP_IsNull, regBase+j, pLevel->addrBrk);
VdbeCoverage(v);
}
- if( pParse->db->mallocFailed==0 && pParse->nErr==0 ){
+ if( pParse->nErr==0 ){
+ assert( pParse->db->mallocFailed==0 );
if( sqlite3CompareAffinity(pRight, zAff[j])==SQLITE_AFF_BLOB ){
zAff[j] = SQLITE_AFF_BLOB;
}
@@ -970,7 +1033,7 @@ static void codeCursorHint(
sWalker.pParse = pParse;
sWalker.u.pCCurHint = &sHint;
pWC = &pWInfo->sWC;
- for(i=0; i<pWC->nTerm; i++){
+ for(i=0; i<pWC->nBase; i++){
pTerm = &pWC->a[i];
if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
if( pTerm->prereqAll & pLevel->notReady ) continue;
@@ -1000,7 +1063,7 @@ static void codeCursorHint(
if( pTabItem->fg.jointype & JT_LEFT ){
Expr *pExpr = pTerm->pExpr;
if( !ExprHasProperty(pExpr, EP_FromJoin)
- || pExpr->iRightJoinTable!=pTabItem->iCursor
+ || pExpr->w.iRightJoinTable!=pTabItem->iCursor
){
sWalker.eCode = 0;
sWalker.xExprCallback = codeCursorHintIsOrFunction;
@@ -1302,6 +1365,65 @@ static void whereApplyPartialIndexConstraints(
}
/*
+** This routine is called right after An OP_Filter has been generated and
+** before the corresponding index search has been performed. This routine
+** checks to see if there are additional Bloom filters in inner loops that
+** can be checked prior to doing the index lookup. If there are available
+** inner-loop Bloom filters, then evaluate those filters now, before the
+** index lookup. The idea is that a Bloom filter check is way faster than
+** an index lookup, and the Bloom filter might return false, meaning that
+** the index lookup can be skipped.
+**
+** We know that an inner loop uses a Bloom filter because it has the
+** WhereLevel.regFilter set. If an inner-loop Bloom filter is checked,
+** then clear the WhereLevel.regFilter value to prevent the Bloom filter
+** from being checked a second time when the inner loop is evaluated.
+*/
+static SQLITE_NOINLINE void filterPullDown(
+ Parse *pParse, /* Parsing context */
+ WhereInfo *pWInfo, /* Complete information about the WHERE clause */
+ int iLevel, /* Which level of pWInfo->a[] should be coded */
+ int addrNxt, /* Jump here to bypass inner loops */
+ Bitmask notReady /* Loops that are not ready */
+){
+ while( ++iLevel < pWInfo->nLevel ){
+ WhereLevel *pLevel = &pWInfo->a[iLevel];
+ WhereLoop *pLoop = pLevel->pWLoop;
+ if( pLevel->regFilter==0 ) continue;
+ if( pLevel->pWLoop->nSkip ) continue;
+ /* ,--- Because sqlite3ConstructBloomFilter() has will not have set
+ ** vvvvv--' pLevel->regFilter if this were true. */
+ if( NEVER(pLoop->prereq & notReady) ) continue;
+ if( pLoop->wsFlags & WHERE_IPK ){
+ WhereTerm *pTerm = pLoop->aLTerm[0];
+ int regRowid;
+ assert( pTerm!=0 );
+ assert( pTerm->pExpr!=0 );
+ testcase( pTerm->wtFlags & TERM_VIRTUAL );
+ regRowid = sqlite3GetTempReg(pParse);
+ regRowid = codeEqualityTerm(pParse, pTerm, pLevel, 0, 0, regRowid);
+ sqlite3VdbeAddOp4Int(pParse->pVdbe, OP_Filter, pLevel->regFilter,
+ addrNxt, regRowid, 1);
+ VdbeCoverage(pParse->pVdbe);
+ }else{
+ u16 nEq = pLoop->u.btree.nEq;
+ int r1;
+ char *zStartAff;
+
+ assert( pLoop->wsFlags & WHERE_INDEXED );
+ assert( (pLoop->wsFlags & WHERE_COLUMN_IN)==0 );
+ r1 = codeAllEqualityTerms(pParse,pLevel,0,0,&zStartAff);
+ codeApplyAffinity(pParse, r1, nEq, zStartAff);
+ sqlite3DbFree(pParse->db, zStartAff);
+ sqlite3VdbeAddOp4Int(pParse->pVdbe, OP_Filter, pLevel->regFilter,
+ addrNxt, r1, nEq);
+ VdbeCoverage(pParse->pVdbe);
+ }
+ pLevel->regFilter = 0;
+ }
+}
+
+/*
** Generate code for the start of the iLevel-th loop in the WHERE clause
** implementation described by pWInfo.
*/
@@ -1403,7 +1525,6 @@ Bitmask sqlite3WhereCodeOneLoopStart(
int iReg; /* P3 Value for OP_VFilter */
int addrNotFound;
int nConstraint = pLoop->nLTerm;
- int iIn; /* Counter for IN constraints */
iReg = sqlite3GetTempRange(pParse, nConstraint+2);
addrNotFound = pLevel->addrBrk;
@@ -1412,11 +1533,27 @@ Bitmask sqlite3WhereCodeOneLoopStart(
pTerm = pLoop->aLTerm[j];
if( NEVER(pTerm==0) ) continue;
if( pTerm->eOperator & WO_IN ){
- codeEqualityTerm(pParse, pTerm, pLevel, j, bRev, iTarget);
- addrNotFound = pLevel->addrNxt;
+ if( SMASKBIT32(j) & pLoop->u.vtab.mHandleIn ){
+ int iTab = pParse->nTab++;
+ int iCache = ++pParse->nMem;
+ sqlite3CodeRhsOfIN(pParse, pTerm->pExpr, iTab);
+ sqlite3VdbeAddOp3(v, OP_VInitIn, iTab, iTarget, iCache);
+ }else{
+ codeEqualityTerm(pParse, pTerm, pLevel, j, bRev, iTarget);
+ addrNotFound = pLevel->addrNxt;
+ }
}else{
Expr *pRight = pTerm->pExpr->pRight;
codeExprOrVector(pParse, pRight, iTarget, 1);
+ if( pTerm->eMatchOp==SQLITE_INDEX_CONSTRAINT_OFFSET
+ && pLoop->u.vtab.bOmitOffset
+ ){
+ assert( pTerm->eOperator==WO_AUX );
+ assert( pWInfo->pLimit!=0 );
+ assert( pWInfo->pLimit->iOffset>0 );
+ sqlite3VdbeAddOp2(v, OP_Integer, 0, pWInfo->pLimit->iOffset);
+ VdbeComment((v,"Zero OFFSET counter"));
+ }
}
}
sqlite3VdbeAddOp2(v, OP_Integer, pLoop->u.vtab.idxNum, iReg);
@@ -1433,44 +1570,54 @@ Bitmask sqlite3WhereCodeOneLoopStart(
pLevel->op = pWInfo->eOnePass ? OP_Noop : OP_VNext;
pLevel->p2 = sqlite3VdbeCurrentAddr(v);
assert( (pLoop->wsFlags & WHERE_MULTI_OR)==0 );
- if( pLoop->wsFlags & WHERE_IN_ABLE ){
- iIn = pLevel->u.in.nIn;
- }else{
- iIn = 0;
- }
- for(j=nConstraint-1; j>=0; j--){
+
+ for(j=0; j<nConstraint; j++){
pTerm = pLoop->aLTerm[j];
- if( (pTerm->eOperator & WO_IN)!=0 ) iIn--;
if( j<16 && (pLoop->u.vtab.omitMask>>j)&1 ){
disableTerm(pLevel, pTerm);
- }else if( (pTerm->eOperator & WO_IN)!=0
- && sqlite3ExprVectorSize(pTerm->pExpr->pLeft)==1
+ continue;
+ }
+ if( (pTerm->eOperator & WO_IN)!=0
+ && (SMASKBIT32(j) & pLoop->u.vtab.mHandleIn)==0
+ && !db->mallocFailed
){
Expr *pCompare; /* The comparison operator */
Expr *pRight; /* RHS of the comparison */
VdbeOp *pOp; /* Opcode to access the value of the IN constraint */
+ int iIn; /* IN loop corresponding to the j-th constraint */
/* Reload the constraint value into reg[iReg+j+2]. The same value
** was loaded into the same register prior to the OP_VFilter, but
** the xFilter implementation might have changed the datatype or
- ** encoding of the value in the register, so it *must* be reloaded. */
- assert( pLevel->u.in.aInLoop!=0 || db->mallocFailed );
- if( !db->mallocFailed ){
- assert( iIn>=0 && iIn<pLevel->u.in.nIn );
+ ** encoding of the value in the register, so it *must* be reloaded.
+ */
+ for(iIn=0; ALWAYS(iIn<pLevel->u.in.nIn); iIn++){
pOp = sqlite3VdbeGetOp(v, pLevel->u.in.aInLoop[iIn].addrInTop);
- assert( pOp->opcode==OP_Column || pOp->opcode==OP_Rowid );
- assert( pOp->opcode!=OP_Column || pOp->p3==iReg+j+2 );
- assert( pOp->opcode!=OP_Rowid || pOp->p2==iReg+j+2 );
- testcase( pOp->opcode==OP_Rowid );
- sqlite3VdbeAddOp3(v, pOp->opcode, pOp->p1, pOp->p2, pOp->p3);
+ if( (pOp->opcode==OP_Column && pOp->p3==iReg+j+2)
+ || (pOp->opcode==OP_Rowid && pOp->p2==iReg+j+2)
+ ){
+ testcase( pOp->opcode==OP_Rowid );
+ sqlite3VdbeAddOp3(v, pOp->opcode, pOp->p1, pOp->p2, pOp->p3);
+ break;
+ }
}
/* Generate code that will continue to the next row if
- ** the IN constraint is not satisfied */
+ ** the IN constraint is not satisfied
+ */
pCompare = sqlite3PExpr(pParse, TK_EQ, 0, 0);
- assert( pCompare!=0 || db->mallocFailed );
- if( pCompare ){
- pCompare->pLeft = pTerm->pExpr->pLeft;
+ if( !db->mallocFailed ){
+ int iFld = pTerm->u.x.iField;
+ Expr *pLeft = pTerm->pExpr->pLeft;
+ assert( pLeft!=0 );
+ if( iFld>0 ){
+ assert( pLeft->op==TK_VECTOR );
+ assert( ExprUseXList(pLeft) );
+ assert( iFld<=pLeft->x.pList->nExpr );
+ pCompare->pLeft = pLeft->x.pList->a[iFld-1].pExpr;
+ }else{
+ pCompare->pLeft = pLeft;
+ }
pCompare->pRight = pRight = sqlite3Expr(db, TK_REGISTER, 0);
if( pRight ){
pRight->iTable = iReg+j+2;
@@ -1479,11 +1626,11 @@ Bitmask sqlite3WhereCodeOneLoopStart(
);
}
pCompare->pLeft = 0;
- sqlite3ExprDelete(db, pCompare);
}
+ sqlite3ExprDelete(db, pCompare);
}
}
- assert( iIn==0 || db->mallocFailed );
+
/* These registers need to be preserved in case there is an IN operator
** loop. So we could deallocate the registers here (and potentially
** reuse them later) if (pLoop->wsFlags & WHERE_IN_ABLE)==0. But it seems
@@ -1511,6 +1658,12 @@ Bitmask sqlite3WhereCodeOneLoopStart(
iRowidReg = codeEqualityTerm(pParse, pTerm, pLevel, 0, bRev, iReleaseReg);
if( iRowidReg!=iReleaseReg ) sqlite3ReleaseTempReg(pParse, iReleaseReg);
addrNxt = pLevel->addrNxt;
+ if( pLevel->regFilter ){
+ sqlite3VdbeAddOp4Int(v, OP_Filter, pLevel->regFilter, addrNxt,
+ iRowidReg, 1);
+ VdbeCoverage(v);
+ filterPullDown(pParse, pWInfo, iLevel, addrNxt, notReady);
+ }
sqlite3VdbeAddOp3(v, OP_SeekRowid, iCur, addrNxt, iRowidReg);
VdbeCoverage(v);
pLevel->op = OP_Noop;
@@ -1836,6 +1989,12 @@ Bitmask sqlite3WhereCodeOneLoopStart(
sqlite3VdbeAddOp2(v, OP_Integer, 1, regBignull);
VdbeComment((v, "NULL-scan pass ctr"));
}
+ if( pLevel->regFilter ){
+ sqlite3VdbeAddOp4Int(v, OP_Filter, pLevel->regFilter, addrNxt,
+ regBase, nEq);
+ VdbeCoverage(v);
+ filterPullDown(pParse, pWInfo, iLevel, addrNxt, notReady);
+ }
op = aStartOp[(start_constraints<<2) + (startEq<<1) + bRev];
assert( op!=0 );
@@ -2163,7 +2322,7 @@ Bitmask sqlite3WhereCodeOneLoopStart(
iRetInit = sqlite3VdbeAddOp2(v, OP_Integer, 0, regReturn);
/* If the original WHERE clause is z of the form: (x1 OR x2 OR ...) AND y
- ** Then for every term xN, evaluate as the subexpression: xN AND z
+ ** Then for every term xN, evaluate as the subexpression: xN AND y
** That way, terms in y that are factored into the disjunction will
** be picked up by the recursive calls to sqlite3WhereBegin() below.
**
@@ -2175,6 +2334,20 @@ Bitmask sqlite3WhereCodeOneLoopStart(
** This optimization also only applies if the (x1 OR x2 OR ...) term
** is not contained in the ON clause of a LEFT JOIN.
** See ticket http://www.sqlite.org/src/info/f2369304e4
+ **
+ ** 2022-02-04: Do not push down slices of a row-value comparison.
+ ** In other words, "w" or "y" may not be a slice of a vector. Otherwise,
+ ** the initialization of the right-hand operand of the vector comparison
+ ** might not occur, or might occur only in an OR branch that is not
+ ** taken. dbsqlfuzz 80a9fade844b4fb43564efc972bcb2c68270f5d1.
+ **
+ ** 2022-03-03: Do not push down expressions that involve subqueries.
+ ** The subquery might get coded as a subroutine. Any table-references
+ ** in the subquery might be resolved to index-references for the index on
+ ** the OR branch in which the subroutine is coded. But if the subroutine
+ ** is invoked from a different OR branch that uses a different index, such
+ ** index-references will not work. tag-20220303a
+ ** https://sqlite.org/forum/forumpost/36937b197273d403
*/
if( pWC->nTerm>1 ){
int iTerm;
@@ -2183,9 +2356,12 @@ Bitmask sqlite3WhereCodeOneLoopStart(
if( &pWC->a[iTerm] == pTerm ) continue;
testcase( pWC->a[iTerm].wtFlags & TERM_VIRTUAL );
testcase( pWC->a[iTerm].wtFlags & TERM_CODED );
- if( (pWC->a[iTerm].wtFlags & (TERM_VIRTUAL|TERM_CODED))!=0 ) continue;
+ testcase( pWC->a[iTerm].wtFlags & TERM_SLICE );
+ if( (pWC->a[iTerm].wtFlags & (TERM_VIRTUAL|TERM_CODED|TERM_SLICE))!=0 ){
+ continue;
+ }
if( (pWC->a[iTerm].eOperator & WO_ALL)==0 ) continue;
- testcase( pWC->a[iTerm].wtFlags & TERM_ORINFO );
+ if( ExprHasProperty(pExpr, EP_Subquery) ) continue; /* tag-20220303a */
pExpr = sqlite3ExprDup(db, pExpr, 0);
pAndExpr = sqlite3ExprAnd(pParse, pAndExpr, pExpr);
}
@@ -2226,9 +2402,9 @@ Bitmask sqlite3WhereCodeOneLoopStart(
/* 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,
+ pSubWInfo = sqlite3WhereBegin(pParse, pOrTab, pOrExpr, 0, 0, 0,
WHERE_OR_SUBCLAUSE, iCovCur);
- assert( pSubWInfo || pParse->nErr || db->mallocFailed );
+ assert( pSubWInfo || pParse->nErr );
if( pSubWInfo ){
WhereLoop *pSubLoop;
int addrExplain = sqlite3WhereExplainOneScan(
@@ -2467,7 +2643,7 @@ Bitmask sqlite3WhereCodeOneLoopStart(
** then we cannot use the "t1.a=t2.b" constraint, but we can code
** the implied "t1.a=123" constraint.
*/
- for(pTerm=pWC->a, j=pWC->nTerm; j>0; j--, pTerm++){
+ for(pTerm=pWC->a, j=pWC->nBase; j>0; j--, pTerm++){
Expr *pE, sEAlt;
WhereTerm *pAlt;
if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
@@ -2512,7 +2688,7 @@ Bitmask sqlite3WhereCodeOneLoopStart(
pLevel->addrFirst = sqlite3VdbeCurrentAddr(v);
sqlite3VdbeAddOp2(v, OP_Integer, 1, pLevel->iLeftJoin);
VdbeComment((v, "record LEFT JOIN hit"));
- for(pTerm=pWC->a, j=0; j<pWC->nTerm; j++, pTerm++){
+ for(pTerm=pWC->a, j=0; j<pWC->nBase; j++, pTerm++){
testcase( pTerm->wtFlags & TERM_VIRTUAL );
testcase( pTerm->wtFlags & TERM_CODED );
if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
diff --git a/chromium/third_party/sqlite/src/src/whereexpr.c b/chromium/third_party/sqlite/src/src/whereexpr.c
index 53dd14031cd..19dd886de5f 100644
--- a/chromium/third_party/sqlite/src/src/whereexpr.c
+++ b/chromium/third_party/sqlite/src/src/whereexpr.c
@@ -79,6 +79,7 @@ static int whereClauseInsert(WhereClause *pWC, Expr *p, u16 wtFlags){
pWC->nSlot = sqlite3DbMallocSize(db, pWC->a)/sizeof(pWC->a[0]);
}
pTerm = &pWC->a[idx = pWC->nTerm++];
+ if( (wtFlags & TERM_VIRTUAL)==0 ) pWC->nBase = pWC->nTerm;
if( p && ExprHasProperty(p, EP_Unlikely) ){
pTerm->truthProb = sqlite3LogEst(p->iTable) - 270;
}else{
@@ -421,7 +422,7 @@ static int isAuxiliaryVtabOperator(
assert( pVtab!=0 );
assert( pVtab->pModule!=0 );
assert( !ExprHasProperty(pExpr, EP_IntValue) );
- pMod = (sqlite3_module *)pVtab->pModule;
+ pMod = (sqlite3_module *)pVtab->pModule;
if( pMod->xFindFunction!=0 ){
i = pMod->xFindFunction(pVtab,2, pExpr->u.zToken, &xNotUsed, &pNotUsed);
if( i>=SQLITE_INDEX_CONSTRAINT_FUNCTION ){
@@ -465,7 +466,7 @@ static int isAuxiliaryVtabOperator(
static void transferJoinMarkings(Expr *pDerived, Expr *pBase){
if( pDerived ){
pDerived->flags |= pBase->flags & EP_FromJoin;
- pDerived->iRightJoinTable = pBase->iRightJoinTable;
+ pDerived->w.iRightJoinTable = pBase->w.iRightJoinTable;
}
}
@@ -795,7 +796,7 @@ static void exprAnalyzeOrTerm(
pOrTerm = pOrWc->a;
for(i=pOrWc->nTerm-1; i>=0; i--, pOrTerm++){
assert( pOrTerm->eOperator & WO_EQ );
- pOrTerm->wtFlags &= ~TERM_OR_OK;
+ pOrTerm->wtFlags &= ~TERM_OK;
if( pOrTerm->leftCursor==iCursor ){
/* This is the 2-bit case and we are on the second iteration and
** current term is from the first iteration. So skip this term. */
@@ -836,7 +837,7 @@ static void exprAnalyzeOrTerm(
assert( pOrTerm->eOperator & WO_EQ );
assert( (pOrTerm->eOperator & (WO_OR|WO_AND))==0 );
if( pOrTerm->leftCursor!=iCursor ){
- pOrTerm->wtFlags &= ~TERM_OR_OK;
+ pOrTerm->wtFlags &= ~TERM_OK;
}else if( pOrTerm->u.x.leftColumn!=iColumn || (iColumn==XN_EXPR
&& sqlite3ExprCompare(pParse, pOrTerm->pExpr->pLeft, pLeft, -1)
)){
@@ -852,7 +853,7 @@ static void exprAnalyzeOrTerm(
if( affRight!=0 && affRight!=affLeft ){
okToChngToIN = 0;
}else{
- pOrTerm->wtFlags |= TERM_OR_OK;
+ pOrTerm->wtFlags |= TERM_OK;
}
}
}
@@ -869,7 +870,7 @@ static void exprAnalyzeOrTerm(
Expr *pNew; /* The complete IN operator */
for(i=pOrWc->nTerm-1, pOrTerm=pOrWc->a; i>=0; i--, pOrTerm++){
- if( (pOrTerm->wtFlags & TERM_OR_OK)==0 ) continue;
+ if( (pOrTerm->wtFlags & TERM_OK)==0 ) continue;
assert( pOrTerm->eOperator & WO_EQ );
assert( (pOrTerm->eOperator & (WO_OR|WO_AND))==0 );
assert( pOrTerm->leftCursor==iCursor );
@@ -1070,10 +1071,13 @@ static void exprAnalyze(
if( db->mallocFailed ){
return;
}
+ assert( pWC->nTerm > idxTerm );
pTerm = &pWC->a[idxTerm];
pMaskSet = &pWInfo->sMaskSet;
pExpr = pTerm->pExpr;
+ assert( pExpr!=0 ); /* Because malloc() has not failed */
assert( pExpr->op!=TK_AS && pExpr->op!=TK_COLLATE );
+ pMaskSet->bVarSelect = 0;
prereqLeft = sqlite3WhereExprUsage(pMaskSet, pExpr->pLeft);
op = pExpr->op;
if( op==TK_IN ){
@@ -1084,16 +1088,30 @@ static void exprAnalyze(
}else{
pTerm->prereqRight = sqlite3WhereExprListUsage(pMaskSet, pExpr->x.pList);
}
- }else if( op==TK_ISNULL ){
- pTerm->prereqRight = 0;
+ prereqAll = prereqLeft | pTerm->prereqRight;
}else{
pTerm->prereqRight = sqlite3WhereExprUsage(pMaskSet, pExpr->pRight);
+ if( pExpr->pLeft==0
+ || ExprHasProperty(pExpr, EP_xIsSelect|EP_IfNullRow)
+ || pExpr->x.pList!=0
+ ){
+ prereqAll = sqlite3WhereExprUsageNN(pMaskSet, pExpr);
+ }else{
+ prereqAll = prereqLeft | pTerm->prereqRight;
+ }
}
- pMaskSet->bVarSelect = 0;
- prereqAll = sqlite3WhereExprUsageNN(pMaskSet, pExpr);
if( pMaskSet->bVarSelect ) pTerm->wtFlags |= TERM_VARSELECT;
+
+#ifdef SQLITE_DEBUG
+ if( prereqAll!=sqlite3WhereExprUsageNN(pMaskSet, pExpr) ){
+ printf("\n*** Incorrect prereqAll computed for:\n");
+ sqlite3TreeViewExpr(0,pExpr,0);
+ abort();
+ }
+#endif
+
if( ExprHasProperty(pExpr, EP_FromJoin) ){
- Bitmask x = sqlite3WhereGetMask(pMaskSet, pExpr->iRightJoinTable);
+ Bitmask x = sqlite3WhereGetMask(pMaskSet, pExpr->w.iRightJoinTable);
prereqAll |= x;
extraRight = x-1; /* ON clause terms may not be used with an index
** on left table of a LEFT JOIN. Ticket #3015 */
@@ -1361,7 +1379,10 @@ static void exprAnalyze(
** no longer used.
**
** This is only required if at least one side of the comparison operation
- ** is not a sub-select. */
+ ** is not a sub-select.
+ **
+ ** tag-20220128a
+ */
if( (pExpr->op==TK_EQ || pExpr->op==TK_IS)
&& (nLeft = sqlite3ExprVectorSize(pExpr->pLeft))>1
&& sqlite3ExprVectorSize(pExpr->pRight)==nLeft
@@ -1378,7 +1399,7 @@ static void exprAnalyze(
pNew = sqlite3PExpr(pParse, pExpr->op, pLeft, pRight);
transferJoinMarkings(pNew, pExpr);
- idxNew = whereClauseInsert(pWC, pNew, TERM_DYNAMIC);
+ idxNew = whereClauseInsert(pWC, pNew, TERM_DYNAMIC|TERM_SLICE);
exprAnalyze(pSrc, pWC, idxNew);
}
pTerm = &pWC->a[idxTerm];
@@ -1408,7 +1429,7 @@ static void exprAnalyze(
int i;
for(i=0; i<sqlite3ExprVectorSize(pExpr->pLeft); i++){
int idxNew;
- idxNew = whereClauseInsert(pWC, pExpr, TERM_VIRTUAL);
+ idxNew = whereClauseInsert(pWC, pExpr, TERM_VIRTUAL|TERM_SLICE);
pWC->a[idxNew].u.x.iField = i+1;
exprAnalyze(pSrc, pWC, idxNew);
markTermAsChild(pWC, idxNew, idxTerm);
@@ -1441,7 +1462,7 @@ static void exprAnalyze(
0, sqlite3ExprDup(db, pRight, 0));
if( ExprHasProperty(pExpr, EP_FromJoin) && pNewExpr ){
ExprSetProperty(pNewExpr, EP_FromJoin);
- pNewExpr->iRightJoinTable = pExpr->iRightJoinTable;
+ pNewExpr->w.iRightJoinTable = pExpr->w.iRightJoinTable;
}
idxNew = whereClauseInsert(pWC, pNewExpr, TERM_VIRTUAL|TERM_DYNAMIC);
testcase( idxNew==0 );
@@ -1505,6 +1526,113 @@ void sqlite3WhereSplit(WhereClause *pWC, Expr *pExpr, u8 op){
}
/*
+** Add either a LIMIT (if eMatchOp==SQLITE_INDEX_CONSTRAINT_LIMIT) or
+** OFFSET (if eMatchOp==SQLITE_INDEX_CONSTRAINT_OFFSET) term to the
+** where-clause passed as the first argument. The value for the term
+** is found in register iReg.
+**
+** In the common case where the value is a simple integer
+** (example: "LIMIT 5 OFFSET 10") then the expression codes as a
+** TK_INTEGER so that it will be available to sqlite3_vtab_rhs_value().
+** If not, then it codes as a TK_REGISTER expression.
+*/
+static void whereAddLimitExpr(
+ WhereClause *pWC, /* Add the constraint to this WHERE clause */
+ int iReg, /* Register that will hold value of the limit/offset */
+ Expr *pExpr, /* Expression that defines the limit/offset */
+ int iCsr, /* Cursor to which the constraint applies */
+ int eMatchOp /* SQLITE_INDEX_CONSTRAINT_LIMIT or _OFFSET */
+){
+ Parse *pParse = pWC->pWInfo->pParse;
+ sqlite3 *db = pParse->db;
+ Expr *pNew;
+ int iVal = 0;
+
+ if( sqlite3ExprIsInteger(pExpr, &iVal) && iVal>=0 ){
+ Expr *pVal = sqlite3Expr(db, TK_INTEGER, 0);
+ if( pVal==0 ) return;
+ ExprSetProperty(pVal, EP_IntValue);
+ pVal->u.iValue = iVal;
+ pNew = sqlite3PExpr(pParse, TK_MATCH, 0, pVal);
+ }else{
+ Expr *pVal = sqlite3Expr(db, TK_REGISTER, 0);
+ if( pVal==0 ) return;
+ pVal->iTable = iReg;
+ pNew = sqlite3PExpr(pParse, TK_MATCH, 0, pVal);
+ }
+ if( pNew ){
+ WhereTerm *pTerm;
+ int idx;
+ idx = whereClauseInsert(pWC, pNew, TERM_DYNAMIC|TERM_VIRTUAL);
+ pTerm = &pWC->a[idx];
+ pTerm->leftCursor = iCsr;
+ pTerm->eOperator = WO_AUX;
+ pTerm->eMatchOp = eMatchOp;
+ }
+}
+
+/*
+** Possibly add terms corresponding to the LIMIT and OFFSET clauses of the
+** SELECT statement passed as the second argument. These terms are only
+** added if:
+**
+** 1. The SELECT statement has a LIMIT clause, and
+** 2. The SELECT statement is not an aggregate or DISTINCT query, and
+** 3. The SELECT statement has exactly one object in its from clause, and
+** that object is a virtual table, and
+** 4. There are no terms in the WHERE clause that will not be passed
+** to the virtual table xBestIndex method.
+** 5. The ORDER BY clause, if any, will be made available to the xBestIndex
+** method.
+**
+** LIMIT and OFFSET terms are ignored by most of the planner code. They
+** exist only so that they may be passed to the xBestIndex method of the
+** single virtual table in the FROM clause of the SELECT.
+*/
+void sqlite3WhereAddLimit(WhereClause *pWC, Select *p){
+ assert( p==0 || (p->pGroupBy==0 && (p->selFlags & SF_Aggregate)==0) );
+ if( (p && p->pLimit) /* 1 */
+ && (p->selFlags & (SF_Distinct|SF_Aggregate))==0 /* 2 */
+ && (p->pSrc->nSrc==1 && IsVirtual(p->pSrc->a[0].pTab)) /* 3 */
+ ){
+ ExprList *pOrderBy = p->pOrderBy;
+ int iCsr = p->pSrc->a[0].iCursor;
+ int ii;
+
+ /* Check condition (4). Return early if it is not met. */
+ for(ii=0; ii<pWC->nTerm; ii++){
+ if( pWC->a[ii].wtFlags & TERM_CODED ){
+ /* This term is a vector operation that has been decomposed into
+ ** other, subsequent terms. It can be ignored. See tag-20220128a */
+ assert( pWC->a[ii].wtFlags & TERM_VIRTUAL );
+ assert( pWC->a[ii].eOperator==0 );
+ continue;
+ }
+ if( pWC->a[ii].leftCursor!=iCsr ) return;
+ }
+
+ /* Check condition (5). Return early if it is not met. */
+ if( pOrderBy ){
+ for(ii=0; ii<pOrderBy->nExpr; ii++){
+ Expr *pExpr = pOrderBy->a[ii].pExpr;
+ if( pExpr->op!=TK_COLUMN ) return;
+ if( pExpr->iTable!=iCsr ) return;
+ if( pOrderBy->a[ii].sortFlags & KEYINFO_ORDER_BIGNULL ) return;
+ }
+ }
+
+ /* All conditions are met. Add the terms to the where-clause object. */
+ assert( p->pLimit->op==TK_LIMIT );
+ whereAddLimitExpr(pWC, p->iLimit, p->pLimit->pLeft,
+ iCsr, SQLITE_INDEX_CONSTRAINT_LIMIT);
+ if( p->iOffset>0 ){
+ whereAddLimitExpr(pWC, p->iOffset, p->pLimit->pRight,
+ iCsr, SQLITE_INDEX_CONSTRAINT_OFFSET);
+ }
+ }
+}
+
+/*
** Initialize a preallocated WhereClause structure.
*/
void sqlite3WhereClauseInit(
@@ -1515,6 +1643,7 @@ void sqlite3WhereClauseInit(
pWC->hasOr = 0;
pWC->pOuter = 0;
pWC->nTerm = 0;
+ pWC->nBase = 0;
pWC->nSlot = ArraySize(pWC->aStatic);
pWC->a = pWC->aStatic;
}
@@ -1525,17 +1654,34 @@ void sqlite3WhereClauseInit(
** sqlite3WhereClauseInit().
*/
void sqlite3WhereClauseClear(WhereClause *pWC){
- int i;
- WhereTerm *a;
sqlite3 *db = pWC->pWInfo->pParse->db;
- for(i=pWC->nTerm-1, a=pWC->a; i>=0; i--, a++){
- if( a->wtFlags & TERM_DYNAMIC ){
- sqlite3ExprDelete(db, a->pExpr);
+ assert( pWC->nTerm>=pWC->nBase );
+ if( pWC->nTerm>0 ){
+ WhereTerm *a = pWC->a;
+ WhereTerm *aLast = &pWC->a[pWC->nTerm-1];
+#ifdef SQLITE_DEBUG
+ int i;
+ /* Verify that every term past pWC->nBase is virtual */
+ for(i=pWC->nBase; i<pWC->nTerm; i++){
+ assert( (pWC->a[i].wtFlags & TERM_VIRTUAL)!=0 );
}
- if( a->wtFlags & TERM_ORINFO ){
- whereOrInfoDelete(db, a->u.pOrInfo);
- }else if( a->wtFlags & TERM_ANDINFO ){
- whereAndInfoDelete(db, a->u.pAndInfo);
+#endif
+ while(1){
+ assert( a->eMatchOp==0 || a->eOperator==WO_AUX );
+ if( a->wtFlags & TERM_DYNAMIC ){
+ sqlite3ExprDelete(db, a->pExpr);
+ }
+ if( a->wtFlags & (TERM_ORINFO|TERM_ANDINFO) ){
+ if( a->wtFlags & TERM_ORINFO ){
+ assert( (a->wtFlags & TERM_ANDINFO)==0 );
+ whereOrInfoDelete(db, a->u.pOrInfo);
+ }else{
+ assert( (a->wtFlags & TERM_ANDINFO)!=0 );
+ whereAndInfoDelete(db, a->u.pAndInfo);
+ }
+ }
+ if( a==aLast ) break;
+ a++;
}
}
if( pWC->a!=pWC->aStatic ){
@@ -1548,15 +1694,38 @@ void sqlite3WhereClauseClear(WhereClause *pWC){
** These routines walk (recursively) an expression tree and generate
** a bitmask indicating which tables are used in that expression
** tree.
+**
+** sqlite3WhereExprUsage(MaskSet, Expr) ->
+**
+** Return a Bitmask of all tables referenced by Expr. Expr can be
+** be NULL, in which case 0 is returned.
+**
+** sqlite3WhereExprUsageNN(MaskSet, Expr) ->
+**
+** Same as sqlite3WhereExprUsage() except that Expr must not be
+** NULL. The "NN" suffix on the name stands for "Not Null".
+**
+** sqlite3WhereExprListUsage(MaskSet, ExprList) ->
+**
+** Return a Bitmask of all tables referenced by every expression
+** in the expression list ExprList. ExprList can be NULL, in which
+** case 0 is returned.
+**
+** sqlite3WhereExprUsageFull(MaskSet, ExprList) ->
+**
+** Internal use only. Called only by sqlite3WhereExprUsageNN() for
+** complex expressions that require pushing register values onto
+** the stack. Many calls to sqlite3WhereExprUsageNN() do not need
+** the more complex analysis done by this routine. Hence, the
+** computations done by this routine are broken out into a separate
+** "no-inline" function to avoid the stack push overhead in the
+** common case where it is not needed.
*/
-Bitmask sqlite3WhereExprUsageNN(WhereMaskSet *pMaskSet, Expr *p){
+static SQLITE_NOINLINE Bitmask sqlite3WhereExprUsageFull(
+ WhereMaskSet *pMaskSet,
+ Expr *p
+){
Bitmask mask;
- if( p->op==TK_COLUMN && !ExprHasProperty(p, EP_FixedCol) ){
- return sqlite3WhereGetMask(pMaskSet, p->iTable);
- }else if( ExprHasProperty(p, EP_TokenOnly|EP_Leaf) ){
- assert( p->op!=TK_IF_NULL_ROW );
- return 0;
- }
mask = (p->op==TK_IF_NULL_ROW) ? sqlite3WhereGetMask(pMaskSet, p->iTable) : 0;
if( p->pLeft ) mask |= sqlite3WhereExprUsageNN(pMaskSet, p->pLeft);
if( p->pRight ){
@@ -1578,6 +1747,15 @@ Bitmask sqlite3WhereExprUsageNN(WhereMaskSet *pMaskSet, Expr *p){
#endif
return mask;
}
+Bitmask sqlite3WhereExprUsageNN(WhereMaskSet *pMaskSet, Expr *p){
+ if( p->op==TK_COLUMN && !ExprHasProperty(p, EP_FixedCol) ){
+ return sqlite3WhereGetMask(pMaskSet, p->iTable);
+ }else if( ExprHasProperty(p, EP_TokenOnly|EP_Leaf) ){
+ assert( p->op!=TK_IF_NULL_ROW );
+ return 0;
+ }
+ return sqlite3WhereExprUsageFull(pMaskSet, p);
+}
Bitmask sqlite3WhereExprUsage(WhereMaskSet *pMaskSet, Expr *p){
return p ? sqlite3WhereExprUsageNN(pMaskSet,p) : 0;
}
@@ -1647,6 +1825,7 @@ void sqlite3WhereTabFuncArgs(
pColRef->iColumn = k++;
assert( ExprUseYTab(pColRef) );
pColRef->y.pTab = pTab;
+ pItem->colUsed |= sqlite3ExprColUsed(pColRef);
pRhs = sqlite3PExpr(pParse, TK_UPLUS,
sqlite3ExprDup(pParse->db, pArgs->a[j].pExpr, 0), 0);
pTerm = sqlite3PExpr(pParse, TK_EQ, pColRef, pRhs);
diff --git a/chromium/third_party/sqlite/src/src/window.c b/chromium/third_party/sqlite/src/src/window.c
index d7c412a3a63..bed6ab636c1 100644
--- a/chromium/third_party/sqlite/src/src/window.c
+++ b/chromium/third_party/sqlite/src/src/window.c
@@ -957,7 +957,11 @@ static int disallowAggregatesInOrderByCb(Walker *pWalker, Expr *pExpr){
*/
int sqlite3WindowRewrite(Parse *pParse, Select *p){
int rc = SQLITE_OK;
- if( p->pWin && p->pPrior==0 && ALWAYS((p->selFlags & SF_WinRewrite)==0) ){
+ if( p->pWin
+ && p->pPrior==0
+ && ALWAYS((p->selFlags & SF_WinRewrite)==0)
+ && ALWAYS(!IN_RENAME_OBJECT)
+ ){
Vdbe *v = sqlite3GetVdbe(pParse);
sqlite3 *db = pParse->db;
Select *pSub = 0; /* The subquery */
@@ -1032,6 +1036,7 @@ int sqlite3WindowRewrite(Parse *pParse, Select *p){
for(pWin=pMWin; pWin; pWin=pWin->pNextWin){
ExprList *pArgs;
assert( ExprUseXList(pWin->pOwner) );
+ assert( pWin->pFunc!=0 );
pArgs = pWin->pOwner->x.pList;
if( pWin->pFunc->funcFlags & SQLITE_FUNC_SUBTYPE ){
selectWindowRewriteEList(pParse, pMWin, pSrc, pArgs, pTab, &pSublist);
@@ -1106,12 +1111,7 @@ int sqlite3WindowRewrite(Parse *pParse, Select *p){
sqlite3ParserAddCleanup(pParse, sqlite3DbFree, pTab);
}
- if( rc ){
- if( pParse->nErr==0 ){
- assert( pParse->db->mallocFailed );
- sqlite3ErrorToParser(pParse->db, SQLITE_NOMEM);
- }
- }
+ assert( rc==SQLITE_OK || pParse->nErr!=0 );
return rc;
}
diff --git a/chromium/third_party/sqlite/src/tool/lemon.c b/chromium/third_party/sqlite/src/tool/lemon.c
index d4e157a1cd1..11e25c8a1c4 100644
--- a/chromium/third_party/sqlite/src/tool/lemon.c
+++ b/chromium/third_party/sqlite/src/tool/lemon.c
@@ -4290,7 +4290,6 @@ void ReportTable(
int sqlFlag /* Generate the *.sql file too */
){
FILE *out, *in, *sql;
- char line[LINESIZE];
int lineno;
struct state *stp;
struct action *ap;
@@ -4765,7 +4764,6 @@ void ReportTable(
/* Generate a table containing the symbolic name of every symbol
*/
for(i=0; i<lemp->nsymbol; i++){
- lemon_sprintf(line,"\"%s\",",lemp->symbols[i]->name);
fprintf(out," /* %4d */ \"%s\",\n",i, lemp->symbols[i]->name); lineno++;
}
tplt_xfer(lemp->name,in,out,&lineno);
diff --git a/chromium/third_party/sqlite/src/tool/logest.c b/chromium/third_party/sqlite/src/tool/logest.c
index e936e02cbee..d916b43d396 100644
--- a/chromium/third_party/sqlite/src/tool/logest.c
+++ b/chromium/third_party/sqlite/src/tool/logest.c
@@ -75,6 +75,7 @@ static sqlite3_uint64 logEstToInt(LogEst x){
x /= 10;
if( n>=5 ) n -= 2;
else if( n>=1 ) n -= 1;
+ if( x>60 ) return (((sqlite3_uint64)0xffffffff)<<32)+(sqlite3_uint64)0xffffffff;
if( x>=3 ) return (n+8)<<(x-3);
return (n+8)>>(3-x);
}
@@ -149,7 +150,7 @@ int main(int argc, char **argv){
}else if( z[0]=='^' ){
a[n++] = (LogEst)atoi(z+1);
}else if( isInteger(z) ){
- a[n++] = logEstFromInteger(atoi(z));
+ a[n++] = logEstFromInteger(atoll(z));
}else if( isFloat(z) && z[0]!='-' ){
a[n++] = logEstFromDouble(atof(z));
}else{
@@ -161,6 +162,8 @@ int main(int argc, char **argv){
printf("%5d (%f)\n", a[i], 1.0/(double)logEstToInt(-a[i]));
}else if( a[i]<10 ){
printf("%5d (%f)\n", a[i], logEstToInt(a[i]+100)/1024.0);
+ }else if( a[i]>100 ){
+ printf("%5d (%lld)\n", a[i], logEstToInt(a[i]));
}else{
sqlite3_uint64 x = logEstToInt(a[i]+100)*100/1024;
printf("%5d (%lld.%02lld)\n", a[i], x/100, x%100);
diff --git a/chromium/third_party/sqlite/src/tool/mkctimec.tcl b/chromium/third_party/sqlite/src/tool/mkctimec.tcl
index 6294609451d..745a59a229c 100644..100755
--- a/chromium/third_party/sqlite/src/tool/mkctimec.tcl
+++ b/chromium/third_party/sqlite/src/tool/mkctimec.tcl
@@ -5,9 +5,82 @@
# const char **azCompileOpt[]
#
# definition used in src/ctime.c, run this script from
-# the checkout root. It alters src/ctime.c in-place.
+# the checkout root. It generates src/ctime.c .
#
+
+set ::headWarning {/* DO NOT EDIT!
+** This file is automatically generated by the script in the canonical
+** SQLite source tree at tool/mkctimec.tcl.
+**
+** To modify this header, edit any of the various lists in that script
+** which specify categories of generated conditionals in this file.
+*/}
+
+# Make { and } easier to put into literals (even on EBCDIC machines.)
+regexp {(\{)(\})} "{}" ma ::lb ::rb
+
+set ::headCode "
+/*
+** 2010 February 23
+**
+** The author disclaims copyright to this source code. In place of
+** a legal notice, here is a blessing:
+**
+** May you do good and not evil.
+** May you find forgiveness for yourself and forgive others.
+** May you share freely, never taking more than you give.
+**
+*************************************************************************
+**
+** This file implements routines used to report what compile-time options
+** SQLite was built with.
+*/
+#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS /* IMP: R-16824-07538 */
+
+/*
+** Include the configuration header output by 'configure' if we're using the
+** autoconf-based build
+*/
+#if defined(_HAVE_SQLITE_CONFIG_H) && !defined(SQLITECONFIG_H)
+#include \"config.h\"
+#define SQLITECONFIG_H 1
+#endif
+
+/* These macros are provided to \"stringify\" the value of the define
+** for those options in which the value is meaningful. */
+#define CTIMEOPT_VAL_(opt) #opt
+#define CTIMEOPT_VAL(opt) CTIMEOPT_VAL_(opt)
+
+/* Like CTIMEOPT_VAL, but especially for SQLITE_DEFAULT_LOOKASIDE. This
+** option requires a separate macro because legal values contain a single
+** comma. e.g. (-DSQLITE_DEFAULT_LOOKASIDE=\"100,100\") */
+#define CTIMEOPT_VAL2_(opt1,opt2) #opt1 \",\" #opt2
+#define CTIMEOPT_VAL2(opt) CTIMEOPT_VAL2_(opt)
+#include \"sqliteInt.h\"
+
+/*
+** An array of names of all compile-time options. This array should
+** be sorted A-Z.
+**
+** This array looks large, but in a typical installation actually uses
+** only a handful of compile-time options, so most times this array is usually
+** rather short and uses little memory space.
+*/
+static const char * const sqlite3azCompileOpt\[\] = $::lb
+"
+
+set ::tailCode "
+$::rb ;
+
+const char **sqlite3CompileOptions(int *pnOpt){
+ *pnOpt = sizeof(sqlite3azCompileOpt) / sizeof(sqlite3azCompileOpt\[0\]);
+ return (const char**)sqlite3azCompileOpt;
+}
+
+#endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */
+"
+
# All Boolean compile time options which default to something
# other than 0 or empty. The default is paired with the PP
# symbol so that a differing define can be detected.
@@ -70,7 +143,6 @@ set boolean_defnil_options {
SQLITE_ENABLE_HIDDEN_COLUMNS
SQLITE_ENABLE_ICU
SQLITE_ENABLE_IOTRACE
- SQLITE_ENABLE_JSON1
SQLITE_ENABLE_LOAD_EXTENSION
SQLITE_ENABLE_LOCKING_STYLE
SQLITE_ENABLE_MATH_FUNCTIONS
@@ -151,6 +223,7 @@ set boolean_defnil_options {
SQLITE_OMIT_INCRBLOB
SQLITE_OMIT_INTEGRITY_CHECK
SQLITE_OMIT_INTROSPECTION_PRAGMAS
+ SQLITE_OMIT_JSON
SQLITE_OMIT_LIKE_OPTIMIZATION
SQLITE_OMIT_LOAD_EXTENSION
SQLITE_OMIT_LOCALTIME
@@ -354,60 +427,18 @@ foreach v $value2_options {
}]
}
-# Split a string on a regex, return all parts in order.
-# Any elements with an even index may be empty.
-# Elements with odd indices will match the regex.
-proc split_on_re {re str {nrepps 1}} {
- set chunks {}
- set cix 0
- set resm [regexp -all -inline -indices $re $str]
- if {[llength $resm]==0} {
- return $str
- }
- set rix 0
- while {$rix < [llength $resm]} {
- set mre [lindex $resm $rix]
- incr rix $nrepps
- set mbx [lindex $mre 0]
- set mex [lindex $mre 1]
- lappend chunks [string range $str $cix [expr $mbx - 1]]
- lappend chunks [string range $str $mbx $mex]
- set cix [expr $mex + 1]
- }
- lappend chunks [string range $str $cix end]
- return $chunks
-}
-
-
set ctime_c "src/ctime.c"
-if {[catch {set cfd [open $ctime_c r]}]!=0} {
- puts stderr "File '$ctime_c' unreadable. Run this script from checkout root."
- exit 1;
-}
-
-set ctfc [read $cfd]
-close $cfd
-
-set re {/\*\s+\*+\s*((BEGIN)|(END)) CODE GENERATED BY (\S+)\s+\*/\s+}
-set renpp 5
-
-set ctfcChunks [split_on_re $re $ctfc $renpp]
-if {[llength $ctfcChunks] != 5} {
- puts stderr "File '$ctime_c' has too few generated code markers."
- exit 1;
-}
if {[catch {set cfd [open $ctime_c w]}]!=0} {
puts stderr "File '$ctime_c' unwritable."
exit 1;
}
-puts -nonewline $cfd [lindex $ctfcChunks 0]
-puts -nonewline $cfd [lindex $ctfcChunks 1]
+puts $cfd $::headWarning;
+puts $cfd $::headCode;
foreach o [lsort [array names options]] {
puts $cfd [string trim $options($o)]
}
-puts -nonewline $cfd [lindex $ctfcChunks 3]
-puts -nonewline $cfd [lindex $ctfcChunks 4]
+puts -nonewline $cfd $::tailCode;
close $cfd
diff --git a/chromium/third_party/sqlite/src/tool/mksqlite3c.tcl b/chromium/third_party/sqlite/src/tool/mksqlite3c.tcl
index 9d59e17b166..1a35fc0ea38 100644
--- a/chromium/third_party/sqlite/src/tool/mksqlite3c.tcl
+++ b/chromium/third_party/sqlite/src/tool/mksqlite3c.tcl
@@ -429,7 +429,7 @@ foreach file {
fts3_unicode.c
fts3_unicode2.c
- json1.c
+ json.c
rtree.c
icu.c
fts3_icu.c
diff --git a/chromium/third_party/sqlite/src/tool/omittest.tcl b/chromium/third_party/sqlite/src/tool/omittest.tcl
index 9f24d6d3d35..b54f2984d41 100644
--- a/chromium/third_party/sqlite/src/tool/omittest.tcl
+++ b/chromium/third_party/sqlite/src/tool/omittest.tcl
@@ -218,6 +218,7 @@ proc main {argv} {
SQLITE_OMIT_INCRBLOB \
SQLITE_OMIT_INTEGRITY_CHECK \
SQLITE_OMIT_INTROSPECTION_PRAGMAS \
+ SQLITE_OMIT_JSON \
SQLITE_OMIT_LIKE_OPTIMIZATION \
SQLITE_OMIT_LOAD_EXTENSION \
SQLITE_OMIT_LOCALTIME \
diff --git a/chromium/third_party/sqlite/src/tool/showdb.c b/chromium/third_party/sqlite/src/tool/showdb.c
index 3c91967ed1d..611e603fe90 100644
--- a/chromium/third_party/sqlite/src/tool/showdb.c
+++ b/chromium/third_party/sqlite/src/tool/showdb.c
@@ -726,7 +726,7 @@ static void decode_btree_page(
}
if( showMap ){
printf("Page map: (H=header P=cell-index 1=page-1-header .=free-space)\n");
- for(i=0; i<g.pagesize; i+=64){
+ for(i=0; (u32)i<g.pagesize; i+=64){
printf(" %03x: %.64s\n", i, &zMap[i]);
}
sqlite3_free(zMap);
@@ -861,7 +861,7 @@ static int allZero(unsigned char *a, int n){
*/
static void page_usage_btree(
u32 pgno, /* Page to describe */
- u32 parent, /* Parent of this page. 0 for root pages */
+ int parent, /* Parent of this page. 0 for root pages */
int idx, /* Which child of the parent */
const char *zName /* Name of the table */
){
@@ -954,7 +954,7 @@ static void page_usage_freelist(u32 pgno){
int iNext;
int parent = 1;
- while( pgno>0 && pgno<=g.mxPage && (cnt++)<g.mxPage ){
+ while( pgno>0 && pgno<=g.mxPage && (u32)(cnt++)<g.mxPage ){
page_usage_msg(pgno, "freelist trunk #%d child of %d", cnt, parent);
a = fileRead((pgno-1)*g.pagesize, g.pagesize);
iNext = decodeInt32(a);
diff --git a/chromium/third_party/sqlite/src/tool/sqldiff.c b/chromium/third_party/sqlite/src/tool/sqldiff.c
index da444bf9aff..0a017037cf3 100644
--- a/chromium/third_party/sqlite/src/tool/sqldiff.c
+++ b/chromium/third_party/sqlite/src/tool/sqldiff.c
@@ -407,31 +407,31 @@ static void printQuoted(FILE *out, sqlite3_value *X){
if( zArg==0 ){
fprintf(out, "NULL");
}else{
- int inctl = 0;
- int i, j;
+ int inctl = 0;
+ int i, j;
fprintf(out, "'");
- for(i=j=0; zArg[i]; i++){
- char c = zArg[i];
- int ctl = iscntrl(c);
- if( ctl>inctl ){
- inctl = ctl;
- fprintf(out, "%.*s'||X'%02x", i-j, &zArg[j], c);
- j = i+1;
- }else if( ctl ){
- fprintf(out, "%02x", c);
- j = i+1;
- }else{
- if( inctl ){
- inctl = 0;
- fprintf(out, "'\n||'");
- }
- if( c=='\'' ){
- fprintf(out, "%.*s'", i-j+1, &zArg[j]);
- j = i+1;
- }
- }
- }
- fprintf(out, "%s'", &zArg[j]);
+ for(i=j=0; zArg[i]; i++){
+ char c = zArg[i];
+ int ctl = iscntrl(c);
+ if( ctl>inctl ){
+ inctl = ctl;
+ fprintf(out, "%.*s'||X'%02x", i-j, &zArg[j], c);
+ j = i+1;
+ }else if( ctl ){
+ fprintf(out, "%02x", c);
+ j = i+1;
+ }else{
+ if( inctl ){
+ inctl = 0;
+ fprintf(out, "'\n||'");
+ }
+ if( c=='\'' ){
+ fprintf(out, "%.*s'", i-j+1, &zArg[j]);
+ j = i+1;
+ }
+ }
+ }
+ fprintf(out, "%s'", &zArg[j]);
}
break;
}
diff --git a/chromium/third_party/sqlite/src/tool/vdbe-compress.tcl b/chromium/third_party/sqlite/src/tool/vdbe-compress.tcl
index 9477f4afe62..5e63c96a9a5 100644
--- a/chromium/third_party/sqlite/src/tool/vdbe-compress.tcl
+++ b/chromium/third_party/sqlite/src/tool/vdbe-compress.tcl
@@ -65,7 +65,7 @@ while {![eof stdin]} {
#
set vlist {}
set seenDecl 0
-set namechars {abcdefghijklmnopqrstuvwxyz}
+set namechars {abcefghjklmnopqrstuvwxyz}
set nnc [string length $namechars]
while {![eof stdin]} {
set line [gets stdin]
diff --git a/chromium/third_party/sqlite/src/tool/warnings.sh b/chromium/third_party/sqlite/src/tool/warnings.sh
index 0754a0f3f6f..a839d235b65 100644
--- a/chromium/third_party/sqlite/src/tool/warnings.sh
+++ b/chromium/third_party/sqlite/src/tool/warnings.sh
@@ -20,7 +20,7 @@ echo '********** No optimizations. Includes FTS4/5, GEOPOLY, JSON1 ***'
echo '********** ' Options: $WARNING_OPTS
gcc -c $WARNING_OPTS -std=c89 \
-ansi -DHAVE_STDINT_H -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_GEOPOLY \
- -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_JSON1 \
+ -DSQLITE_ENABLE_FTS5 \
sqlite3.c
if test x`uname` = 'xLinux'; then
echo '********** Android configuration ******************************'
@@ -56,5 +56,5 @@ echo '********** Optimized -O3. Includes FTS4/5, GEOPOLY, JSON1 ******'
echo '********** ' Options: $WARNING_OPTS
gcc -O3 -c $WARNING_OPTS -std=c89 \
-ansi -DHAVE_STDINT_H -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_GEOPOLY \
- -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_JSON1 \
+ -DSQLITE_ENABLE_FTS5 \
sqlite3.c