Fossil SCM

Bring the merge-info-html branch up to date with trunk, step 1 of 2.

stephan 2025-02-20 14:32 UTC merge-info-html merge
Commit 1140b020de296a7724c5d444f1bb73d96a666333b38111280efcf6f81c36a761
80 files changed +6 -6 +1 -1 +110 -36 +65 -16 +3000 -2454 +165 -61 +4 -1 +1 -1 +2 -3 +1 -1 +38 -27 +2 -2 +1 -1 +12 -3 +3 -4 +26 -3 +1 +108 -32 +10 -4 +10 -4 +49 -39 +9 +5 -1 +92 -16 +92 -16 +8 -1 +18 +39 +1 -1 -2 +90 -26 +3 -1 +28 -12 +1 -1 +466 -36 +37 -10 +17 -2 +7 -3 +386 +23 -8 +23 -8 +6 -1 +151 -24 +50 -17 +14 -1 +3 -3 +1 -1 +71 -35 +3 -39 +4 -4 +2 +473 -462 +17 -11 +1 +11 -13 +55 -2 +25 +28 -25 +6 -4 +2 +1 -1 +24 -18 +4 -1 +16 -5 +12 -6 +16 -2 +14 -2 +4 -8 +20 -22 +53 -1 +14 -11 +1 -1 +1 -1 +9 -8 +19 +1 +5 -4 +117 +197 -88 +8
+6 -6
--- Dockerfile
+++ Dockerfile
@@ -3,19 +3,19 @@
33
44
## ---------------------------------------------------------------------
55
## STAGE 1: Build static Fossil binary
66
## ---------------------------------------------------------------------
77
8
-### We aren't pinning to a more stable version of Alpine because we want
8
+### We don't pin a more stable version of our base layer because we want
99
### to build with the latest tools and libraries available in case they
1010
### fixed something that matters to us since the last build. Everything
1111
### below depends on this layer, and so, alas, we toss this container's
1212
### cache on Alpine's release schedule, roughly once a month.
1313
FROM alpine:latest AS bld
1414
WORKDIR /fsl
1515
16
-### Bake the basic Alpine Linux into a base layer so it only changes
16
+### Bake the build-time userland into a base layer so it only changes
1717
### when the upstream image is updated or we change the package set.
1818
RUN set -x \
1919
&& apk update \
2020
&& apk upgrade --no-cache \
2121
&& apk add --no-cache \
@@ -23,19 +23,19 @@
2323
linux-headers musl-dev \
2424
openssl-dev openssl-libs-static \
2525
zlib-dev zlib-static
2626
2727
### Build Fossil as a separate layer so we don't have to rebuild the
28
-### Alpine environment for each iteration of Fossil's dev cycle.
28
+### userland for each iteration of Fossil's dev cycle.
2929
###
3030
### We must cope with a bizarre ADD misfeature here: it unpacks tarballs
3131
### automatically when you give it a local file name but not if you give
3232
### it a /tarball URL! It matters because we default to a URL in case
3333
### you're building outside a Fossil checkout, but when building via the
34
-### container-image target, we avoid a costly hit on fossil-scm.org
35
-### by leveraging its DVCS nature via the "tarball" command and passing
36
-### the resulting file's name in.
34
+### container-image target, we avoid a costly hit on fossil-scm.org by
35
+### leveraging its DVCS nature via the "tarball" command and passing the
36
+### resulting file's name in.
3737
ARG FSLCFG=""
3838
ARG FSLVER="trunk"
3939
ARG FSLURL="https://fossil-scm.org/home/tarball/src?r=${FSLVER}"
4040
ENV FSLSTB=/fsl/src.tar.gz
4141
ADD $FSLURL $FSLSTB
4242
--- Dockerfile
+++ Dockerfile
@@ -3,19 +3,19 @@
3
4 ## ---------------------------------------------------------------------
5 ## STAGE 1: Build static Fossil binary
6 ## ---------------------------------------------------------------------
7
8 ### We aren't pinning to a more stable version of Alpine because we want
9 ### to build with the latest tools and libraries available in case they
10 ### fixed something that matters to us since the last build. Everything
11 ### below depends on this layer, and so, alas, we toss this container's
12 ### cache on Alpine's release schedule, roughly once a month.
13 FROM alpine:latest AS bld
14 WORKDIR /fsl
15
16 ### Bake the basic Alpine Linux into a base layer so it only changes
17 ### when the upstream image is updated or we change the package set.
18 RUN set -x \
19 && apk update \
20 && apk upgrade --no-cache \
21 && apk add --no-cache \
@@ -23,19 +23,19 @@
23 linux-headers musl-dev \
24 openssl-dev openssl-libs-static \
25 zlib-dev zlib-static
26
27 ### Build Fossil as a separate layer so we don't have to rebuild the
28 ### Alpine environment for each iteration of Fossil's dev cycle.
29 ###
30 ### We must cope with a bizarre ADD misfeature here: it unpacks tarballs
31 ### automatically when you give it a local file name but not if you give
32 ### it a /tarball URL! It matters because we default to a URL in case
33 ### you're building outside a Fossil checkout, but when building via the
34 ### container-image target, we avoid a costly hit on fossil-scm.org
35 ### by leveraging its DVCS nature via the "tarball" command and passing
36 ### the resulting file's name in.
37 ARG FSLCFG=""
38 ARG FSLVER="trunk"
39 ARG FSLURL="https://fossil-scm.org/home/tarball/src?r=${FSLVER}"
40 ENV FSLSTB=/fsl/src.tar.gz
41 ADD $FSLURL $FSLSTB
42
--- Dockerfile
+++ Dockerfile
@@ -3,19 +3,19 @@
3
4 ## ---------------------------------------------------------------------
5 ## STAGE 1: Build static Fossil binary
6 ## ---------------------------------------------------------------------
7
8 ### We don't pin a more stable version of our base layer because we want
9 ### to build with the latest tools and libraries available in case they
10 ### fixed something that matters to us since the last build. Everything
11 ### below depends on this layer, and so, alas, we toss this container's
12 ### cache on Alpine's release schedule, roughly once a month.
13 FROM alpine:latest AS bld
14 WORKDIR /fsl
15
16 ### Bake the build-time userland into a base layer so it only changes
17 ### when the upstream image is updated or we change the package set.
18 RUN set -x \
19 && apk update \
20 && apk upgrade --no-cache \
21 && apk add --no-cache \
@@ -23,19 +23,19 @@
23 linux-headers musl-dev \
24 openssl-dev openssl-libs-static \
25 zlib-dev zlib-static
26
27 ### Build Fossil as a separate layer so we don't have to rebuild the
28 ### userland for each iteration of Fossil's dev cycle.
29 ###
30 ### We must cope with a bizarre ADD misfeature here: it unpacks tarballs
31 ### automatically when you give it a local file name but not if you give
32 ### it a /tarball URL! It matters because we default to a URL in case
33 ### you're building outside a Fossil checkout, but when building via the
34 ### container-image target, we avoid a costly hit on fossil-scm.org by
35 ### leveraging its DVCS nature via the "tarball" command and passing the
36 ### resulting file's name in.
37 ARG FSLCFG=""
38 ARG FSLVER="trunk"
39 ARG FSLURL="https://fossil-scm.org/home/tarball/src?r=${FSLVER}"
40 ENV FSLSTB=/fsl/src.tar.gz
41 ADD $FSLURL $FSLSTB
42
--- Makefile.classic
+++ Makefile.classic
@@ -95,11 +95,11 @@
9595
#
9696
# Automatic platform-specific options.
9797
HOST_OS_CMD = uname -s
9898
HOST_OS = $(HOST_OS_CMD:sh)
9999
100
-LIB.SunOS= -lsocket -lnsl
100
+LIB.SunOS= -lsocket -lnsl -lrt
101101
LIB += $(LIB.$(HOST_OS))
102102
103103
TCC.DragonFly += -DUSE_PREAD
104104
TCC.FreeBSD += -DUSE_PREAD
105105
TCC.NetBSD += -DUSE_PREAD
106106
--- Makefile.classic
+++ Makefile.classic
@@ -95,11 +95,11 @@
95 #
96 # Automatic platform-specific options.
97 HOST_OS_CMD = uname -s
98 HOST_OS = $(HOST_OS_CMD:sh)
99
100 LIB.SunOS= -lsocket -lnsl
101 LIB += $(LIB.$(HOST_OS))
102
103 TCC.DragonFly += -DUSE_PREAD
104 TCC.FreeBSD += -DUSE_PREAD
105 TCC.NetBSD += -DUSE_PREAD
106
--- Makefile.classic
+++ Makefile.classic
@@ -95,11 +95,11 @@
95 #
96 # Automatic platform-specific options.
97 HOST_OS_CMD = uname -s
98 HOST_OS = $(HOST_OS_CMD:sh)
99
100 LIB.SunOS= -lsocket -lnsl -lrt
101 LIB += $(LIB.$(HOST_OS))
102
103 TCC.DragonFly += -DUSE_PREAD
104 TCC.FreeBSD += -DUSE_PREAD
105 TCC.NetBSD += -DUSE_PREAD
106
+110 -36
--- auto.def
+++ auto.def
@@ -44,10 +44,24 @@
4444
# to compare the one they have against the minimum required
4545
if {[opt-bool print-minimum-sqlite-version]} {
4646
puts [get-define MINIMUM_SQLITE_VERSION]
4747
exit 0
4848
}
49
+
50
+# Space characters have never been allowed in either the source
51
+# tree nor the build directory. But the resulting error messages
52
+# could be confusing. The following checks make the reason for the
53
+# failure clear.
54
+#
55
+if {[string first " " $autosetup(srcdir)] != -1} {
56
+ user-error "The pathname of the source tree\
57
+ may not contain space characters"
58
+}
59
+if {[string first " " $autosetup(builddir)] != -1} {
60
+ user-error "The pathname of the build directory\
61
+ may not contain space characters"
62
+}
4963
5064
set outOfTreeBuild 0
5165
if {![file exists fossil.1]} {
5266
puts "This appears to be an out-of-tree build."
5367
set outOfTreeBuild 1
@@ -82,11 +96,11 @@
8296
cc-check-progs tclsh
8397
set hbtd /usr/local/Cellar/tcl-tk
8498
if {[string equal false [get-define TCLSH]]} {
8599
msg-result "WARNING: 'make test' will not run here."
86100
} else {
87
- set v [exec /bin/sh -c "echo 'puts \$tcl_version' | tclsh"]
101
+ set v [exec sh -c "echo 'puts \$tcl_version' | tclsh"]
88102
if {[expr {$v >= 8.6}]} {
89103
msg-result "Found Tclsh version $v in the PATH."
90104
define TCLSH tclsh
91105
} elseif {[file isdirectory $hbtd]} {
92106
# This is a macOS system with the Homebrew version of Tcl/Tk
@@ -104,11 +118,11 @@
104118
msg-result "WARNING: tclsh $v found; need >= 8.6 for 'make test'."
105119
define TCLSH false ;# force "make test" failure via /usr/bin/false
106120
}
107121
}
108122
109
-define CFLAGS [get-env CFLAGS "-g -O2"]
123
+define CFLAGS [get-env CFLAGS "-g -Os"]
110124
define EXTRA_CFLAGS "-Wall"
111125
define EXTRA_LDFLAGS ""
112126
define USE_SYSTEM_SQLITE 0
113127
define USE_LINENOISE 0
114128
define USE_MMAN_H 0
@@ -230,11 +244,14 @@
230244
test_system_sqlite
231245
232246
}
233247
234248
proc is_mingw {} {
235
- return [string match *mingw* [get-define host]]
249
+ return [expr {
250
+ [string match *mingw* [get-define host]] &&
251
+ ![file exists "/dev/null"]
252
+ }]
236253
}
237254
238255
if {[is_mingw]} {
239256
define-append EXTRA_CFLAGS -DBROKEN_MINGW_CMDLINE
240257
define-append LIBS -lkernel32 -lws2_32
@@ -422,15 +439,15 @@
422439
if {$ssldirs eq "tree"} {
423440
set ssldir [file dirname $autosetup(dir)]/compat/openssl
424441
if {![file isdirectory $ssldir]} {
425442
user-error "The OpenSSL in source tree directory does not exist"
426443
}
427
- set msg "ssl in $ssldir"
444
+ set msg "openssl in $ssldir"
428445
set cflags "-I$ssldir/include"
429446
set ldflags "-L$ssldir"
430447
set ssllibs "$ssldir/libssl.a $ssldir/libcrypto.a -lpthread"
431
- set found [check-for-openssl "ssl in source tree" "$cflags $ldflags" $ssllibs]
448
+ set found [check-for-openssl "openssl in source tree" "$cflags $ldflags" $ssllibs]
432449
} else {
433450
if {$ssldirs in {auto ""}} {
434451
catch {
435452
set cflags [exec pkg-config openssl --cflags-only-I]
436453
set ldflags [exec pkg-config openssl --libs-only-L]
@@ -443,21 +460,30 @@
443460
}
444461
}
445462
if {!$found} {
446463
foreach dir $ssldirs {
447464
if {$dir eq ""} {
448
- set msg "system ssl"
465
+ set msg "system openssl"
449466
set cflags ""
450467
set ldflags ""
451468
} else {
452
- set msg "ssl in $dir"
469
+ set msg "openssl in $dir"
453470
set cflags "-I$dir/include"
454471
set ldflags "-L$dir/lib"
455472
}
456473
if {[check-for-openssl $msg "$cflags $ldflags"]} {
457474
incr found
458475
break
476
+ }
477
+ if {$dir ne ""} {
478
+ set ldflags ""
479
+ set msg "static build of openssl in $dir"
480
+ set ssllibs "$dir/libssl.a $dir/libcrypto.a -lpthread"
481
+ if {[check-for-openssl $msg "$cflags $ldflags" $ssllibs]} {
482
+ incr found
483
+ break
484
+ }
459485
}
460486
}
461487
}
462488
}
463489
if {$found} {
@@ -683,45 +709,21 @@
683709
$tclconfig(TCL_LD_FLAGS)]
684710
define-append EXTRA_LDFLAGS $tclconfig(TCL_LD_FLAGS)
685711
define FOSSIL_ENABLE_TCL
686712
}
687713
688
-# Emscripten is a purely optional component used only for doing
689
-# in-tree builds of WASM stuff, as opposed to WASM binaries we import
690
-# from other places. This is only set up for Unix-style OSes and is
691
-# untested anywhere but Linux.
692
-set emsdkHome [opt-val with-emsdk]
693
-define EMSDK_HOME ""
694
-define EMSDK_ENV ""
695
-define EMCC_OPT "-Oz"
696
-if {$emsdkHome eq "" && [info exists ::env(EMSDK)]} {
697
- # Fall back to checking the environment. $EMSDK gets set
698
- # by sourcing emsdk_env.sh.
699
- set emsdkHome $::env(EMSDK)
700
-}
701
-if {$emsdkHome ne ""} {
702
- define EMSDK_HOME $emsdkHome
703
- set emsdkEnv "$emsdkHome/emsdk_env.sh"
704
- if {[file exists $emsdkEnv]} {
705
- puts "Using Emscripten SDK environment from $emsdkEnv."
706
- define EMSDK_ENV $emsdkEnv
707
- if {[info exists ::env(EMCC_OPT)]} {
708
- define EMCC_OPT $::env(EMCC_OPT)
709
- }
710
- } else {
711
- puts "emsdk_env.sh not found. Assuming emcc is in the PATH."
712
- }
713
-}
714
-
715714
# Network functions require libraries on some systems
716715
cc-check-function-in-lib gethostbyname nsl
717716
if {![cc-check-function-in-lib socket {socket network}]} {
718717
# Last resort, may be Windows
719718
if {[is_mingw]} {
720719
define-append LIBS -lwsock32
721720
}
722721
}
722
+
723
+# Some systems (ex: SunOS) require -lrt in order to use nanosleep
724
+cc-check-function-in-lib nanosleep rt
723725
724726
# The SMTP module requires special libraries and headers for MX DNS
725727
# record lookups and such.
726728
cc-check-includes arpa/nameser.h
727729
cc-include-needs bind/resolv.h netinet/in.h
@@ -744,11 +746,11 @@
744746
cc-check-functions strchrnul
745747
cc-check-functions pledge
746748
cc-check-functions backtrace
747749
748750
# Termux on Android adds "getpass(char *)" to unistd.h, so check this so we
749
-# guard against including it again; use cctest as cc-check-functions and
751
+# guard against including it again; use cctest as cc-check-functions and
750752
# cctest_function check for "getpass()" with no args and fail
751753
if {[cctest -link 1 -includes {unistd.h} -code "getpass(0);"]} {
752754
define FOSSIL_HAVE_GETPASS 1
753755
msg-result "Found getpass() with unistd.h"
754756
}
@@ -836,16 +838,88 @@
836838
# Linux can only infer the dependency on pthread from OpenSSL when
837839
# doing dynamic linkage.
838840
define-append LIBS -lpthread
839841
}
840842
841
-if {[get-define EMSDK_HOME] ne ""} {
843
+
844
+########################################################################
845
+# @proj-check-emsdk
846
+#
847
+# Emscripten is used for doing in-tree builds of web-based WASM stuff,
848
+# as opposed to WASI-based WASM or WASM binaries we import from other
849
+# places. This is only set up for Unix-style OSes and is untested
850
+# anywhere but Linux. Requires that the --with-emsdk flag be
851
+# registered with autosetup.
852
+#
853
+# It looks for the SDK in the location specified by --with-emsdk.
854
+# Values of "" or "auto" mean to check for the environment var EMSDK
855
+# (which gets set by the emsdk_env.sh script from the SDK) or that
856
+# same var passed to configure.
857
+#
858
+# If the given directory is found, it expects to find emsdk_env.sh in
859
+# that directory, as well as the emcc compiler somewhere under there.
860
+#
861
+# If the --with-emsdk flag is explicitly provided and the SDK is not
862
+# found then a fatal error is generated, otherwise failure to find the
863
+# SDK is not fatal.
864
+#
865
+# Defines the following:
866
+#
867
+# - EMSDK_HOME = top dir of the emsdk or "".
868
+# - EMSDK_ENV_SH = path to EMSDK_HOME/emsdk_env.sh or ""
869
+# - BIN_EMCC = $EMSDK_HOME/upstream/emscripten/emcc or ""
870
+# - HAVE_EMSDK = 0 or 1 (this function's return value)
871
+#
872
+# Returns 1 if EMSDK_ENV_SH is found, else 0. If EMSDK_HOME is not empty
873
+# but BIN_EMCC is then emcc was not found in the EMSDK_HOME, in which
874
+# case we have to rely on the fact that sourcing $EMSDK_ENV_SH from a
875
+# shell will add emcc to the $PATH.
876
+proc proj-check-emsdk {} {
877
+ set emsdkHome [opt-val with-emsdk]
878
+ define EMSDK_HOME ""
879
+ define EMSDK_ENV_SH ""
880
+ define BIN_EMCC ""
881
+ set hadValue [llength $emsdkHome]
882
+ msg-checking "Emscripten SDK? "
883
+ if {$emsdkHome in {"" "auto"}} {
884
+ # Check the environment. $EMSDK gets set by sourcing emsdk_env.sh.
885
+ set emsdkHome [get-env EMSDK ""]
886
+ }
887
+ set rc 0
888
+ if {$emsdkHome ne ""} {
889
+ define EMSDK_HOME $emsdkHome
890
+ set emsdkEnv "$emsdkHome/emsdk_env.sh"
891
+ if {[file exists $emsdkEnv]} {
892
+ msg-result "$emsdkHome"
893
+ define EMSDK_ENV_SH $emsdkEnv
894
+ set rc 1
895
+ set emcc "$emsdkHome/upstream/emscripten/emcc"
896
+ if {[file exists $emcc]} {
897
+ define BIN_EMCC $emcc
898
+ }
899
+ } else {
900
+ msg-result "emsdk_env.sh not found in $emsdkHome"
901
+ }
902
+ } else {
903
+ msg-result "not found"
904
+ }
905
+ if {$hadValue && 0 == $rc} {
906
+ # Fail if it was explicitly requested but not found
907
+ proj-fatal "Cannot find the Emscripten SDK"
908
+ }
909
+ define HAVE_EMSDK $rc
910
+ return $rc
911
+}
912
+
913
+if {[proj-check-emsdk]} {
842914
define EMCC_WRAPPER $::autosetup(dir)/../tools/emcc.sh
915
+ define EMCC_OPT [get-env EMCC_OPT "-Oz"]; # optional flags to pass to emcc
843916
make-template tools/emcc.sh.in
844917
catch {exec chmod u+x tools/emcc.sh}
845918
} else {
846919
define EMCC_WRAPPER ""
920
+ define EMCC_OPT ""
847921
catch {exec rm -f tools/emcc.sh}
848922
}
849923
850924
# Tag container builds with a prefix of the checkin ID of the version
851925
# of Fossil each one contains. This not only allows multiple images
852926
--- auto.def
+++ auto.def
@@ -44,10 +44,24 @@
44 # to compare the one they have against the minimum required
45 if {[opt-bool print-minimum-sqlite-version]} {
46 puts [get-define MINIMUM_SQLITE_VERSION]
47 exit 0
48 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
50 set outOfTreeBuild 0
51 if {![file exists fossil.1]} {
52 puts "This appears to be an out-of-tree build."
53 set outOfTreeBuild 1
@@ -82,11 +96,11 @@
82 cc-check-progs tclsh
83 set hbtd /usr/local/Cellar/tcl-tk
84 if {[string equal false [get-define TCLSH]]} {
85 msg-result "WARNING: 'make test' will not run here."
86 } else {
87 set v [exec /bin/sh -c "echo 'puts \$tcl_version' | tclsh"]
88 if {[expr {$v >= 8.6}]} {
89 msg-result "Found Tclsh version $v in the PATH."
90 define TCLSH tclsh
91 } elseif {[file isdirectory $hbtd]} {
92 # This is a macOS system with the Homebrew version of Tcl/Tk
@@ -104,11 +118,11 @@
104 msg-result "WARNING: tclsh $v found; need >= 8.6 for 'make test'."
105 define TCLSH false ;# force "make test" failure via /usr/bin/false
106 }
107 }
108
109 define CFLAGS [get-env CFLAGS "-g -O2"]
110 define EXTRA_CFLAGS "-Wall"
111 define EXTRA_LDFLAGS ""
112 define USE_SYSTEM_SQLITE 0
113 define USE_LINENOISE 0
114 define USE_MMAN_H 0
@@ -230,11 +244,14 @@
230 test_system_sqlite
231
232 }
233
234 proc is_mingw {} {
235 return [string match *mingw* [get-define host]]
 
 
 
236 }
237
238 if {[is_mingw]} {
239 define-append EXTRA_CFLAGS -DBROKEN_MINGW_CMDLINE
240 define-append LIBS -lkernel32 -lws2_32
@@ -422,15 +439,15 @@
422 if {$ssldirs eq "tree"} {
423 set ssldir [file dirname $autosetup(dir)]/compat/openssl
424 if {![file isdirectory $ssldir]} {
425 user-error "The OpenSSL in source tree directory does not exist"
426 }
427 set msg "ssl in $ssldir"
428 set cflags "-I$ssldir/include"
429 set ldflags "-L$ssldir"
430 set ssllibs "$ssldir/libssl.a $ssldir/libcrypto.a -lpthread"
431 set found [check-for-openssl "ssl in source tree" "$cflags $ldflags" $ssllibs]
432 } else {
433 if {$ssldirs in {auto ""}} {
434 catch {
435 set cflags [exec pkg-config openssl --cflags-only-I]
436 set ldflags [exec pkg-config openssl --libs-only-L]
@@ -443,21 +460,30 @@
443 }
444 }
445 if {!$found} {
446 foreach dir $ssldirs {
447 if {$dir eq ""} {
448 set msg "system ssl"
449 set cflags ""
450 set ldflags ""
451 } else {
452 set msg "ssl in $dir"
453 set cflags "-I$dir/include"
454 set ldflags "-L$dir/lib"
455 }
456 if {[check-for-openssl $msg "$cflags $ldflags"]} {
457 incr found
458 break
 
 
 
 
 
 
 
 
 
459 }
460 }
461 }
462 }
463 if {$found} {
@@ -683,45 +709,21 @@
683 $tclconfig(TCL_LD_FLAGS)]
684 define-append EXTRA_LDFLAGS $tclconfig(TCL_LD_FLAGS)
685 define FOSSIL_ENABLE_TCL
686 }
687
688 # Emscripten is a purely optional component used only for doing
689 # in-tree builds of WASM stuff, as opposed to WASM binaries we import
690 # from other places. This is only set up for Unix-style OSes and is
691 # untested anywhere but Linux.
692 set emsdkHome [opt-val with-emsdk]
693 define EMSDK_HOME ""
694 define EMSDK_ENV ""
695 define EMCC_OPT "-Oz"
696 if {$emsdkHome eq "" && [info exists ::env(EMSDK)]} {
697 # Fall back to checking the environment. $EMSDK gets set
698 # by sourcing emsdk_env.sh.
699 set emsdkHome $::env(EMSDK)
700 }
701 if {$emsdkHome ne ""} {
702 define EMSDK_HOME $emsdkHome
703 set emsdkEnv "$emsdkHome/emsdk_env.sh"
704 if {[file exists $emsdkEnv]} {
705 puts "Using Emscripten SDK environment from $emsdkEnv."
706 define EMSDK_ENV $emsdkEnv
707 if {[info exists ::env(EMCC_OPT)]} {
708 define EMCC_OPT $::env(EMCC_OPT)
709 }
710 } else {
711 puts "emsdk_env.sh not found. Assuming emcc is in the PATH."
712 }
713 }
714
715 # Network functions require libraries on some systems
716 cc-check-function-in-lib gethostbyname nsl
717 if {![cc-check-function-in-lib socket {socket network}]} {
718 # Last resort, may be Windows
719 if {[is_mingw]} {
720 define-append LIBS -lwsock32
721 }
722 }
 
 
 
723
724 # The SMTP module requires special libraries and headers for MX DNS
725 # record lookups and such.
726 cc-check-includes arpa/nameser.h
727 cc-include-needs bind/resolv.h netinet/in.h
@@ -744,11 +746,11 @@
744 cc-check-functions strchrnul
745 cc-check-functions pledge
746 cc-check-functions backtrace
747
748 # Termux on Android adds "getpass(char *)" to unistd.h, so check this so we
749 # guard against including it again; use cctest as cc-check-functions and
750 # cctest_function check for "getpass()" with no args and fail
751 if {[cctest -link 1 -includes {unistd.h} -code "getpass(0);"]} {
752 define FOSSIL_HAVE_GETPASS 1
753 msg-result "Found getpass() with unistd.h"
754 }
@@ -836,16 +838,88 @@
836 # Linux can only infer the dependency on pthread from OpenSSL when
837 # doing dynamic linkage.
838 define-append LIBS -lpthread
839 }
840
841 if {[get-define EMSDK_HOME] ne ""} {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
842 define EMCC_WRAPPER $::autosetup(dir)/../tools/emcc.sh
 
843 make-template tools/emcc.sh.in
844 catch {exec chmod u+x tools/emcc.sh}
845 } else {
846 define EMCC_WRAPPER ""
 
847 catch {exec rm -f tools/emcc.sh}
848 }
849
850 # Tag container builds with a prefix of the checkin ID of the version
851 # of Fossil each one contains. This not only allows multiple images
852
--- auto.def
+++ auto.def
@@ -44,10 +44,24 @@
44 # to compare the one they have against the minimum required
45 if {[opt-bool print-minimum-sqlite-version]} {
46 puts [get-define MINIMUM_SQLITE_VERSION]
47 exit 0
48 }
49
50 # Space characters have never been allowed in either the source
51 # tree nor the build directory. But the resulting error messages
52 # could be confusing. The following checks make the reason for the
53 # failure clear.
54 #
55 if {[string first " " $autosetup(srcdir)] != -1} {
56 user-error "The pathname of the source tree\
57 may not contain space characters"
58 }
59 if {[string first " " $autosetup(builddir)] != -1} {
60 user-error "The pathname of the build directory\
61 may not contain space characters"
62 }
63
64 set outOfTreeBuild 0
65 if {![file exists fossil.1]} {
66 puts "This appears to be an out-of-tree build."
67 set outOfTreeBuild 1
@@ -82,11 +96,11 @@
96 cc-check-progs tclsh
97 set hbtd /usr/local/Cellar/tcl-tk
98 if {[string equal false [get-define TCLSH]]} {
99 msg-result "WARNING: 'make test' will not run here."
100 } else {
101 set v [exec sh -c "echo 'puts \$tcl_version' | tclsh"]
102 if {[expr {$v >= 8.6}]} {
103 msg-result "Found Tclsh version $v in the PATH."
104 define TCLSH tclsh
105 } elseif {[file isdirectory $hbtd]} {
106 # This is a macOS system with the Homebrew version of Tcl/Tk
@@ -104,11 +118,11 @@
118 msg-result "WARNING: tclsh $v found; need >= 8.6 for 'make test'."
119 define TCLSH false ;# force "make test" failure via /usr/bin/false
120 }
121 }
122
123 define CFLAGS [get-env CFLAGS "-g -Os"]
124 define EXTRA_CFLAGS "-Wall"
125 define EXTRA_LDFLAGS ""
126 define USE_SYSTEM_SQLITE 0
127 define USE_LINENOISE 0
128 define USE_MMAN_H 0
@@ -230,11 +244,14 @@
244 test_system_sqlite
245
246 }
247
248 proc is_mingw {} {
249 return [expr {
250 [string match *mingw* [get-define host]] &&
251 ![file exists "/dev/null"]
252 }]
253 }
254
255 if {[is_mingw]} {
256 define-append EXTRA_CFLAGS -DBROKEN_MINGW_CMDLINE
257 define-append LIBS -lkernel32 -lws2_32
@@ -422,15 +439,15 @@
439 if {$ssldirs eq "tree"} {
440 set ssldir [file dirname $autosetup(dir)]/compat/openssl
441 if {![file isdirectory $ssldir]} {
442 user-error "The OpenSSL in source tree directory does not exist"
443 }
444 set msg "openssl in $ssldir"
445 set cflags "-I$ssldir/include"
446 set ldflags "-L$ssldir"
447 set ssllibs "$ssldir/libssl.a $ssldir/libcrypto.a -lpthread"
448 set found [check-for-openssl "openssl in source tree" "$cflags $ldflags" $ssllibs]
449 } else {
450 if {$ssldirs in {auto ""}} {
451 catch {
452 set cflags [exec pkg-config openssl --cflags-only-I]
453 set ldflags [exec pkg-config openssl --libs-only-L]
@@ -443,21 +460,30 @@
460 }
461 }
462 if {!$found} {
463 foreach dir $ssldirs {
464 if {$dir eq ""} {
465 set msg "system openssl"
466 set cflags ""
467 set ldflags ""
468 } else {
469 set msg "openssl in $dir"
470 set cflags "-I$dir/include"
471 set ldflags "-L$dir/lib"
472 }
473 if {[check-for-openssl $msg "$cflags $ldflags"]} {
474 incr found
475 break
476 }
477 if {$dir ne ""} {
478 set ldflags ""
479 set msg "static build of openssl in $dir"
480 set ssllibs "$dir/libssl.a $dir/libcrypto.a -lpthread"
481 if {[check-for-openssl $msg "$cflags $ldflags" $ssllibs]} {
482 incr found
483 break
484 }
485 }
486 }
487 }
488 }
489 if {$found} {
@@ -683,45 +709,21 @@
709 $tclconfig(TCL_LD_FLAGS)]
710 define-append EXTRA_LDFLAGS $tclconfig(TCL_LD_FLAGS)
711 define FOSSIL_ENABLE_TCL
712 }
713
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
714 # Network functions require libraries on some systems
715 cc-check-function-in-lib gethostbyname nsl
716 if {![cc-check-function-in-lib socket {socket network}]} {
717 # Last resort, may be Windows
718 if {[is_mingw]} {
719 define-append LIBS -lwsock32
720 }
721 }
722
723 # Some systems (ex: SunOS) require -lrt in order to use nanosleep
724 cc-check-function-in-lib nanosleep rt
725
726 # The SMTP module requires special libraries and headers for MX DNS
727 # record lookups and such.
728 cc-check-includes arpa/nameser.h
729 cc-include-needs bind/resolv.h netinet/in.h
@@ -744,11 +746,11 @@
746 cc-check-functions strchrnul
747 cc-check-functions pledge
748 cc-check-functions backtrace
749
750 # Termux on Android adds "getpass(char *)" to unistd.h, so check this so we
751 # guard against including it again; use cctest as cc-check-functions and
752 # cctest_function check for "getpass()" with no args and fail
753 if {[cctest -link 1 -includes {unistd.h} -code "getpass(0);"]} {
754 define FOSSIL_HAVE_GETPASS 1
755 msg-result "Found getpass() with unistd.h"
756 }
@@ -836,16 +838,88 @@
838 # Linux can only infer the dependency on pthread from OpenSSL when
839 # doing dynamic linkage.
840 define-append LIBS -lpthread
841 }
842
843
844 ########################################################################
845 # @proj-check-emsdk
846 #
847 # Emscripten is used for doing in-tree builds of web-based WASM stuff,
848 # as opposed to WASI-based WASM or WASM binaries we import from other
849 # places. This is only set up for Unix-style OSes and is untested
850 # anywhere but Linux. Requires that the --with-emsdk flag be
851 # registered with autosetup.
852 #
853 # It looks for the SDK in the location specified by --with-emsdk.
854 # Values of "" or "auto" mean to check for the environment var EMSDK
855 # (which gets set by the emsdk_env.sh script from the SDK) or that
856 # same var passed to configure.
857 #
858 # If the given directory is found, it expects to find emsdk_env.sh in
859 # that directory, as well as the emcc compiler somewhere under there.
860 #
861 # If the --with-emsdk flag is explicitly provided and the SDK is not
862 # found then a fatal error is generated, otherwise failure to find the
863 # SDK is not fatal.
864 #
865 # Defines the following:
866 #
867 # - EMSDK_HOME = top dir of the emsdk or "".
868 # - EMSDK_ENV_SH = path to EMSDK_HOME/emsdk_env.sh or ""
869 # - BIN_EMCC = $EMSDK_HOME/upstream/emscripten/emcc or ""
870 # - HAVE_EMSDK = 0 or 1 (this function's return value)
871 #
872 # Returns 1 if EMSDK_ENV_SH is found, else 0. If EMSDK_HOME is not empty
873 # but BIN_EMCC is then emcc was not found in the EMSDK_HOME, in which
874 # case we have to rely on the fact that sourcing $EMSDK_ENV_SH from a
875 # shell will add emcc to the $PATH.
876 proc proj-check-emsdk {} {
877 set emsdkHome [opt-val with-emsdk]
878 define EMSDK_HOME ""
879 define EMSDK_ENV_SH ""
880 define BIN_EMCC ""
881 set hadValue [llength $emsdkHome]
882 msg-checking "Emscripten SDK? "
883 if {$emsdkHome in {"" "auto"}} {
884 # Check the environment. $EMSDK gets set by sourcing emsdk_env.sh.
885 set emsdkHome [get-env EMSDK ""]
886 }
887 set rc 0
888 if {$emsdkHome ne ""} {
889 define EMSDK_HOME $emsdkHome
890 set emsdkEnv "$emsdkHome/emsdk_env.sh"
891 if {[file exists $emsdkEnv]} {
892 msg-result "$emsdkHome"
893 define EMSDK_ENV_SH $emsdkEnv
894 set rc 1
895 set emcc "$emsdkHome/upstream/emscripten/emcc"
896 if {[file exists $emcc]} {
897 define BIN_EMCC $emcc
898 }
899 } else {
900 msg-result "emsdk_env.sh not found in $emsdkHome"
901 }
902 } else {
903 msg-result "not found"
904 }
905 if {$hadValue && 0 == $rc} {
906 # Fail if it was explicitly requested but not found
907 proj-fatal "Cannot find the Emscripten SDK"
908 }
909 define HAVE_EMSDK $rc
910 return $rc
911 }
912
913 if {[proj-check-emsdk]} {
914 define EMCC_WRAPPER $::autosetup(dir)/../tools/emcc.sh
915 define EMCC_OPT [get-env EMCC_OPT "-Oz"]; # optional flags to pass to emcc
916 make-template tools/emcc.sh.in
917 catch {exec chmod u+x tools/emcc.sh}
918 } else {
919 define EMCC_WRAPPER ""
920 define EMCC_OPT ""
921 catch {exec rm -f tools/emcc.sh}
922 }
923
924 # Tag container builds with a prefix of the checkin ID of the version
925 # of Fossil each one contains. This not only allows multiple images
926
+65 -16
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -355,10 +355,15 @@
355355
**
356356
** The default behavior, if neither of the above is defined is to
357357
** use O_U8TEXT when writing to the Windows console (or anything
358358
** else for which _isatty() returns true) and to use O_BINARY or O_TEXT
359359
** for all other output channels.
360
+**
361
+** The SQLITE_USE_W32_FOR_CONSOLE_IO macro is also available. If
362
+** defined, it forces the use of Win32 APIs for all console I/O, both
363
+** input and output. This is necessary for some non-Microsoft run-times
364
+** that implement stdio differently from Microsoft/Visual-Studio.
360365
*/
361366
#if defined(SQLITE_U8TEXT_ONLY)
362367
# define UseWtextForOutput(fd) 1
363368
# define UseWtextForInput(fd) 1
364369
# define IsConsole(fd) _isatty(_fileno(fd))
@@ -457,14 +462,14 @@
457462
** that into UTF-8. Otherwise, non-ASCII characters all get translated
458463
** into '?'.
459464
*/
460465
wchar_t *b1 = sqlite3_malloc( sz*sizeof(wchar_t) );
461466
if( b1==0 ) return 0;
462
-#ifndef SQLITE_USE_STDIO_FOR_CONSOLE
467
+#ifdef SQLITE_USE_W32_FOR_CONSOLE_IO
463468
DWORD nRead = 0;
464469
if( IsConsole(in)
465
- && ReadConsoleW(GetStdHandle(STD_INPUT_HANDLE), b1, sz, &nRead, 0)
470
+ && ReadConsoleW(GetStdHandle(STD_INPUT_HANDLE), b1, sz-1, &nRead, 0)
466471
){
467472
b1[nRead] = 0;
468473
}else
469474
#endif
470475
{
@@ -535,22 +540,23 @@
535540
wchar_t *b1 = sqlite3_malloc( (sz+1)*sizeof(wchar_t) );
536541
if( b1==0 ) return 0;
537542
sz = MultiByteToWideChar(CP_UTF8, 0, z, sz, b1, sz);
538543
b1[sz] = 0;
539544
540
-#ifndef SQLITE_STDIO_FOR_CONSOLE
545
+#ifdef SQLITE_USE_W32_FOR_CONSOLE_IO
541546
DWORD nWr = 0;
542547
if( IsConsole(out)
543548
&& WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE),b1,sz,&nWr,0)
544549
){
545550
/* If writing to the console, then the WriteConsoleW() is all we
546551
** need to do. */
547552
}else
548553
#endif
549554
{
550
- /* For non-console I/O, or if SQLITE_USE_STDIO_FOR_CONSOLE is defined
551
- ** then write using the standard library. */
555
+ /* As long as SQLITE_USE_W32_FOR_CONSOLE_IO is not defined, or for
556
+ ** non-console I/O even if that macro is defined, write using the
557
+ ** standard library. */
552558
_setmode(_fileno(out), _O_U8TEXT);
553559
if( UseBinaryWText(out) ){
554560
piecemealOutput(b1, sz, out);
555561
}else{
556562
fputws(b1, out);
@@ -5289,31 +5295,34 @@
52895295
u8 bdp = BX_DV_PROTO(c);
52905296
switch( bdp ){
52915297
case ND:
52925298
/* Treat dark non-digits as pad, but they terminate decode too. */
52935299
ncIn = 0;
5294
- deliberate_fall_through;
5300
+ deliberate_fall_through; /* FALLTHRU */
52955301
case WS:
52965302
/* Treat whitespace as pad and terminate this group.*/
52975303
nti = nac;
5298
- deliberate_fall_through;
5304
+ deliberate_fall_through; /* FALLTHRU */
52995305
case PC:
53005306
bdp = 0;
53015307
--nbo;
5302
- deliberate_fall_through;
5308
+ deliberate_fall_through; /* FALLTHRU */
53035309
default: /* bdp is the digit value. */
53045310
qv = qv<<6 | bdp;
53055311
break;
53065312
}
53075313
}
53085314
switch( nbo ){
53095315
case 3:
53105316
pOut[2] = (qv) & 0xff;
5317
+ deliberate_fall_through; /* FALLTHRU */
53115318
case 2:
53125319
pOut[1] = (qv>>8) & 0xff;
5320
+ deliberate_fall_through; /* FALLTHRU */
53135321
case 1:
53145322
pOut[0] = (qv>>16) & 0xff;
5323
+ break;
53155324
}
53165325
pOut += nbo;
53175326
}
53185327
return pOut;
53195328
}
@@ -5644,16 +5653,20 @@
56445653
}
56455654
nbo -= nti; /* Adjust for early (non-digit) end of group. */
56465655
switch( nbo ){
56475656
case 4:
56485657
*pOut++ = (qv >> 24)&0xff;
5658
+ /* FALLTHRU */
56495659
case 3:
56505660
*pOut++ = (qv >> 16)&0xff;
5661
+ /* FALLTHRU */
56515662
case 2:
56525663
*pOut++ = (qv >> 8)&0xff;
5664
+ /* FALLTHRU */
56535665
case 1:
56545666
*pOut++ = qv&0xff;
5667
+ /* FALLTHRU */
56555668
case 0:
56565669
break;
56575670
}
56585671
}
56595672
return pOut;
@@ -7692,11 +7705,12 @@
76927705
76937706
/* Free and reclaim all the memory used by a previously compiled
76947707
** regular expression. Applications should invoke this routine once
76957708
** for every call to re_compile() to avoid memory leaks.
76967709
*/
7697
-static void re_free(ReCompiled *pRe){
7710
+static void re_free(void *p){
7711
+ ReCompiled *pRe = (ReCompiled*)p;
76987712
if( pRe ){
76997713
sqlite3_free(pRe->aOp);
77007714
sqlite3_free(pRe->aArg);
77017715
sqlite3_free(pRe);
77027716
}
@@ -8358,11 +8372,11 @@
83588372
LPWSTR zUnicodeName;
83598373
extern LPWSTR sqlite3_win32_utf8_to_unicode(const char*);
83608374
83618375
GetSystemTime(&currentTime);
83628376
SystemTimeToFileTime(&currentTime, &lastAccess);
8363
- intervals = Int32x32To64(mtime, 10000000) + 116444736000000000;
8377
+ intervals = (mtime*10000000) + 116444736000000000;
83648378
lastWrite.dwLowDateTime = (DWORD)intervals;
83658379
lastWrite.dwHighDateTime = intervals >> 32;
83668380
zUnicodeName = sqlite3_win32_utf8_to_unicode(zFile);
83678381
if( zUnicodeName==0 ){
83688382
return 1;
@@ -16344,10 +16358,11 @@
1634416358
#define VTR_DLCLOSE 0x00800000
1634516359
#define VTR_RAND 0x01000000
1634616360
#define VTR_SLEEP 0x02000000
1634716361
#define VTR_CURTIME 0x04000000
1634816362
#define VTR_LASTERR 0x08000000
16363
+#define VTR_FETCH 0x10000000 /* Also coverse xUnfetch */
1634916364
1635016365
/*
1635116366
** Method declarations for vfstrace_file.
1635216367
*/
1635316368
static int vfstraceClose(sqlite3_file*);
@@ -16773,10 +16788,11 @@
1677316788
{ "randomness", VTR_RAND },
1677416789
{ "sleep", VTR_SLEEP },
1677516790
{ "currenttime", VTR_CURTIME },
1677616791
{ "currenttimeint64", VTR_CURTIME },
1677716792
{ "getlasterror", VTR_LASTERR },
16793
+ { "fetch", VTR_FETCH },
1677816794
};
1677916795
int onOff = 1;
1678016796
while( zArg[0] ){
1678116797
int jj, n;
1678216798
while( zArg[0]!=0 && zArg[0]!='-' && zArg[0]!='+'
@@ -17000,11 +17016,32 @@
1700017016
pInfo->zVfsName, p->zFName, delFlag);
1700117017
rc = p->pReal->pMethods->xShmUnmap(p->pReal, delFlag);
1700217018
vfstrace_print_errcode(pInfo, " -> %s\n", rc);
1700317019
return rc;
1700417020
}
17005
-
17021
+static int vfstraceFetch(sqlite3_file *pFile, i64 iOff, int nAmt, void **pptr){
17022
+ vfstrace_file *p = (vfstrace_file *)pFile;
17023
+ vfstrace_info *pInfo = p->pInfo;
17024
+ int rc;
17025
+ vfstraceOnOff(pInfo, VTR_FETCH);
17026
+ vfstrace_printf(pInfo, "%s.xFetch(%s,iOff=%lld,nAmt=%d,p=%p)",
17027
+ pInfo->zVfsName, p->zFName, iOff, nAmt, *pptr);
17028
+ rc = p->pReal->pMethods->xFetch(p->pReal, iOff, nAmt, pptr);
17029
+ vfstrace_print_errcode(pInfo, " -> %s\n", rc);
17030
+ return rc;
17031
+}
17032
+static int vfstraceUnfetch(sqlite3_file *pFile, i64 iOff, void *ptr){
17033
+ vfstrace_file *p = (vfstrace_file *)pFile;
17034
+ vfstrace_info *pInfo = p->pInfo;
17035
+ int rc;
17036
+ vfstraceOnOff(pInfo, VTR_FETCH);
17037
+ vfstrace_printf(pInfo, "%s.xUnfetch(%s,iOff=%lld,p=%p)",
17038
+ pInfo->zVfsName, p->zFName, iOff, ptr);
17039
+ rc = p->pReal->pMethods->xUnfetch(p->pReal, iOff, ptr);
17040
+ vfstrace_print_errcode(pInfo, " -> %s\n", rc);
17041
+ return rc;
17042
+}
1700617043
1700717044
1700817045
/*
1700917046
** Open an vfstrace file handle.
1701017047
*/
@@ -17047,10 +17084,14 @@
1704717084
pNew->xShmMap = pSub->xShmMap ? vfstraceShmMap : 0;
1704817085
pNew->xShmLock = pSub->xShmLock ? vfstraceShmLock : 0;
1704917086
pNew->xShmBarrier = pSub->xShmBarrier ? vfstraceShmBarrier : 0;
1705017087
pNew->xShmUnmap = pSub->xShmUnmap ? vfstraceShmUnmap : 0;
1705117088
}
17089
+ if( pNew->iVersion>=3 ){
17090
+ pNew->xFetch = pSub->xFetch ? vfstraceFetch : 0;
17091
+ pNew->xUnfetch = pSub->xUnfetch ? vfstraceUnfetch : 0;
17092
+ }
1705217093
pFile->pMethods = pNew;
1705317094
}
1705417095
vfstrace_print_errcode(pInfo, " -> %s", rc);
1705517096
if( pOutFlags ){
1705617097
vfstrace_printf(pInfo, ", outFlags=0x%x\n", *pOutFlags);
@@ -17162,11 +17203,11 @@
1716217203
*/
1716317204
static void vfstraceDlClose(sqlite3_vfs *pVfs, void *pHandle){
1716417205
vfstrace_info *pInfo = (vfstrace_info*)pVfs->pAppData;
1716517206
sqlite3_vfs *pRoot = pInfo->pRootVfs;
1716617207
vfstraceOnOff(pInfo, VTR_DLCLOSE);
17167
- vfstrace_printf(pInfo, "%s.xDlOpen()\n", pInfo->zVfsName);
17208
+ vfstrace_printf(pInfo, "%s.xDlClose()\n", pInfo->zVfsName);
1716817209
pRoot->xDlClose(pRoot, pHandle);
1716917210
}
1717017211
1717117212
/*
1717217213
** Populate the buffer pointed to by zBufOut with nByte bytes of
@@ -27460,11 +27501,11 @@
2746027501
case AR_SWITCH_VERBOSE:
2746127502
pAr->bVerbose = 1;
2746227503
break;
2746327504
case AR_SWITCH_APPEND:
2746427505
pAr->bAppend = 1;
27465
- deliberate_fall_through;
27506
+ deliberate_fall_through; /* FALLTHRU */
2746627507
case AR_SWITCH_FILE:
2746727508
pAr->zFile = zArg;
2746827509
break;
2746927510
case AR_SWITCH_DIRECTORY:
2747027511
pAr->zDir = zArg;
@@ -28848,10 +28889,13 @@
2884828889
if( c=='d' && n>=3 && cli_strncmp(azArg[0], "dbconfig", n)==0 ){
2884928890
static const struct DbConfigChoices {
2885028891
const char *zName;
2885128892
int op;
2885228893
} aDbConfig[] = {
28894
+ { "attach_create", SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE },
28895
+ { "attach_write", SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE },
28896
+ { "comments", SQLITE_DBCONFIG_ENABLE_COMMENTS },
2885328897
{ "defensive", SQLITE_DBCONFIG_DEFENSIVE },
2885428898
{ "dqs_ddl", SQLITE_DBCONFIG_DQS_DDL },
2885528899
{ "dqs_dml", SQLITE_DBCONFIG_DQS_DML },
2885628900
{ "enable_fkey", SQLITE_DBCONFIG_ENABLE_FKEY },
2885728901
{ "enable_qpsg", SQLITE_DBCONFIG_ENABLE_QPSG },
@@ -30202,10 +30246,11 @@
3020230246
}
3020330247
}
3020430248
if( zFile==0 ){
3020530249
zFile = sqlite3_mprintf("stdout");
3020630250
}
30251
+ shell_check_oom(zFile);
3020730252
if( bOnce ){
3020830253
p->outCount = 2;
3020930254
}else{
3021030255
p->outCount = 0;
3021130256
}
@@ -30244,10 +30289,11 @@
3024430289
rc = 1;
3024530290
output_redir(p, stdout);
3024630291
#else
3024730292
FILE *pfPipe = sqlite3_popen(zFile + 1, "w");
3024830293
if( pfPipe==0 ){
30294
+ assert( stderr!=NULL );
3024930295
sqlite3_fprintf(stderr,"Error: cannot open pipe \"%s\"\n", zFile + 1);
3025030296
rc = 1;
3025130297
}else{
3025230298
output_redir(p, pfPipe);
3025330299
if( zBom ) sqlite3_fputs(zBom, pfPipe);
@@ -30256,11 +30302,12 @@
3025630302
#endif
3025730303
}else{
3025830304
FILE *pfFile = output_file_open(zFile);
3025930305
if( pfFile==0 ){
3026030306
if( cli_strcmp(zFile,"off")!=0 ){
30261
- sqlite3_fprintf(stderr,"Error: cannot write to \"%s\"\n", zFile);
30307
+ assert( stderr!=NULL );
30308
+ sqlite3_fprintf(stderr,"Error: cannot write to \"%s\"\n", zFile);
3026230309
}
3026330310
rc = 1;
3026430311
} else {
3026530312
output_redir(p, pfFile);
3026630313
if( zBom ) sqlite3_fputs(zBom, pfFile);
@@ -30360,10 +30407,11 @@
3036030407
sqlite3_finalize(pStmt);
3036130408
pStmt = 0;
3036230409
rc = 1;
3036330410
}
3036430411
}
30412
+ bind_prepared_stmt(p, pStmt);
3036530413
sqlite3_step(pStmt);
3036630414
sqlite3_finalize(pStmt);
3036730415
}else
3036830416
3036930417
/* .parameter unset NAME
@@ -31594,10 +31642,11 @@
3159431642
{ 0x01000000, 1, "IndexedEXpr" },
3159531643
{ 0x02000000, 1, "Coroutines" },
3159631644
{ 0x04000000, 1, "NullUnusedCols" },
3159731645
{ 0x08000000, 1, "OnePass" },
3159831646
{ 0x10000000, 1, "OrderBySubq" },
31647
+ { 0x20000000, 1, "StarQuery" },
3159931648
{ 0xffffffff, 0, "All" },
3160031649
};
3160131650
unsigned int curOpt;
3160231651
unsigned int newOpt;
3160331652
unsigned int m;
@@ -32148,11 +32197,11 @@
3214832197
goto TermScan;
3214932198
}
3215032199
break;
3215132200
case '[':
3215232201
cin = ']';
32153
- deliberate_fall_through;
32202
+ deliberate_fall_through; /* FALLTHRU */
3215432203
case '`': case '\'': case '"':
3215532204
cWait = cin;
3215632205
qss = QSS_HasDark | cWait;
3215732206
CONTINUE_PROMPT_AWAITC(pst, cin);
3215832207
goto TermScan;
@@ -32183,11 +32232,11 @@
3218332232
if(*zLine==cWait){
3218432233
/* Swallow doubled end-delimiter.*/
3218532234
++zLine;
3218632235
continue;
3218732236
}
32188
- deliberate_fall_through;
32237
+ deliberate_fall_through; /* FALLTHRU */
3218932238
case ']':
3219032239
CONTINUE_PROMPT_AWAITC(pst, 0);
3219132240
qss = QSS_SETV(qss, 0);
3219232241
goto PlainScan;
3219332242
default: assert(0);
3219432243
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -355,10 +355,15 @@
355 **
356 ** The default behavior, if neither of the above is defined is to
357 ** use O_U8TEXT when writing to the Windows console (or anything
358 ** else for which _isatty() returns true) and to use O_BINARY or O_TEXT
359 ** for all other output channels.
 
 
 
 
 
360 */
361 #if defined(SQLITE_U8TEXT_ONLY)
362 # define UseWtextForOutput(fd) 1
363 # define UseWtextForInput(fd) 1
364 # define IsConsole(fd) _isatty(_fileno(fd))
@@ -457,14 +462,14 @@
457 ** that into UTF-8. Otherwise, non-ASCII characters all get translated
458 ** into '?'.
459 */
460 wchar_t *b1 = sqlite3_malloc( sz*sizeof(wchar_t) );
461 if( b1==0 ) return 0;
462 #ifndef SQLITE_USE_STDIO_FOR_CONSOLE
463 DWORD nRead = 0;
464 if( IsConsole(in)
465 && ReadConsoleW(GetStdHandle(STD_INPUT_HANDLE), b1, sz, &nRead, 0)
466 ){
467 b1[nRead] = 0;
468 }else
469 #endif
470 {
@@ -535,22 +540,23 @@
535 wchar_t *b1 = sqlite3_malloc( (sz+1)*sizeof(wchar_t) );
536 if( b1==0 ) return 0;
537 sz = MultiByteToWideChar(CP_UTF8, 0, z, sz, b1, sz);
538 b1[sz] = 0;
539
540 #ifndef SQLITE_STDIO_FOR_CONSOLE
541 DWORD nWr = 0;
542 if( IsConsole(out)
543 && WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE),b1,sz,&nWr,0)
544 ){
545 /* If writing to the console, then the WriteConsoleW() is all we
546 ** need to do. */
547 }else
548 #endif
549 {
550 /* For non-console I/O, or if SQLITE_USE_STDIO_FOR_CONSOLE is defined
551 ** then write using the standard library. */
 
552 _setmode(_fileno(out), _O_U8TEXT);
553 if( UseBinaryWText(out) ){
554 piecemealOutput(b1, sz, out);
555 }else{
556 fputws(b1, out);
@@ -5289,31 +5295,34 @@
5289 u8 bdp = BX_DV_PROTO(c);
5290 switch( bdp ){
5291 case ND:
5292 /* Treat dark non-digits as pad, but they terminate decode too. */
5293 ncIn = 0;
5294 deliberate_fall_through;
5295 case WS:
5296 /* Treat whitespace as pad and terminate this group.*/
5297 nti = nac;
5298 deliberate_fall_through;
5299 case PC:
5300 bdp = 0;
5301 --nbo;
5302 deliberate_fall_through;
5303 default: /* bdp is the digit value. */
5304 qv = qv<<6 | bdp;
5305 break;
5306 }
5307 }
5308 switch( nbo ){
5309 case 3:
5310 pOut[2] = (qv) & 0xff;
 
5311 case 2:
5312 pOut[1] = (qv>>8) & 0xff;
 
5313 case 1:
5314 pOut[0] = (qv>>16) & 0xff;
 
5315 }
5316 pOut += nbo;
5317 }
5318 return pOut;
5319 }
@@ -5644,16 +5653,20 @@
5644 }
5645 nbo -= nti; /* Adjust for early (non-digit) end of group. */
5646 switch( nbo ){
5647 case 4:
5648 *pOut++ = (qv >> 24)&0xff;
 
5649 case 3:
5650 *pOut++ = (qv >> 16)&0xff;
 
5651 case 2:
5652 *pOut++ = (qv >> 8)&0xff;
 
5653 case 1:
5654 *pOut++ = qv&0xff;
 
5655 case 0:
5656 break;
5657 }
5658 }
5659 return pOut;
@@ -7692,11 +7705,12 @@
7692
7693 /* Free and reclaim all the memory used by a previously compiled
7694 ** regular expression. Applications should invoke this routine once
7695 ** for every call to re_compile() to avoid memory leaks.
7696 */
7697 static void re_free(ReCompiled *pRe){
 
7698 if( pRe ){
7699 sqlite3_free(pRe->aOp);
7700 sqlite3_free(pRe->aArg);
7701 sqlite3_free(pRe);
7702 }
@@ -8358,11 +8372,11 @@
8358 LPWSTR zUnicodeName;
8359 extern LPWSTR sqlite3_win32_utf8_to_unicode(const char*);
8360
8361 GetSystemTime(&currentTime);
8362 SystemTimeToFileTime(&currentTime, &lastAccess);
8363 intervals = Int32x32To64(mtime, 10000000) + 116444736000000000;
8364 lastWrite.dwLowDateTime = (DWORD)intervals;
8365 lastWrite.dwHighDateTime = intervals >> 32;
8366 zUnicodeName = sqlite3_win32_utf8_to_unicode(zFile);
8367 if( zUnicodeName==0 ){
8368 return 1;
@@ -16344,10 +16358,11 @@
16344 #define VTR_DLCLOSE 0x00800000
16345 #define VTR_RAND 0x01000000
16346 #define VTR_SLEEP 0x02000000
16347 #define VTR_CURTIME 0x04000000
16348 #define VTR_LASTERR 0x08000000
 
16349
16350 /*
16351 ** Method declarations for vfstrace_file.
16352 */
16353 static int vfstraceClose(sqlite3_file*);
@@ -16773,10 +16788,11 @@
16773 { "randomness", VTR_RAND },
16774 { "sleep", VTR_SLEEP },
16775 { "currenttime", VTR_CURTIME },
16776 { "currenttimeint64", VTR_CURTIME },
16777 { "getlasterror", VTR_LASTERR },
 
16778 };
16779 int onOff = 1;
16780 while( zArg[0] ){
16781 int jj, n;
16782 while( zArg[0]!=0 && zArg[0]!='-' && zArg[0]!='+'
@@ -17000,11 +17016,32 @@
17000 pInfo->zVfsName, p->zFName, delFlag);
17001 rc = p->pReal->pMethods->xShmUnmap(p->pReal, delFlag);
17002 vfstrace_print_errcode(pInfo, " -> %s\n", rc);
17003 return rc;
17004 }
17005
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17006
17007
17008 /*
17009 ** Open an vfstrace file handle.
17010 */
@@ -17047,10 +17084,14 @@
17047 pNew->xShmMap = pSub->xShmMap ? vfstraceShmMap : 0;
17048 pNew->xShmLock = pSub->xShmLock ? vfstraceShmLock : 0;
17049 pNew->xShmBarrier = pSub->xShmBarrier ? vfstraceShmBarrier : 0;
17050 pNew->xShmUnmap = pSub->xShmUnmap ? vfstraceShmUnmap : 0;
17051 }
 
 
 
 
17052 pFile->pMethods = pNew;
17053 }
17054 vfstrace_print_errcode(pInfo, " -> %s", rc);
17055 if( pOutFlags ){
17056 vfstrace_printf(pInfo, ", outFlags=0x%x\n", *pOutFlags);
@@ -17162,11 +17203,11 @@
17162 */
17163 static void vfstraceDlClose(sqlite3_vfs *pVfs, void *pHandle){
17164 vfstrace_info *pInfo = (vfstrace_info*)pVfs->pAppData;
17165 sqlite3_vfs *pRoot = pInfo->pRootVfs;
17166 vfstraceOnOff(pInfo, VTR_DLCLOSE);
17167 vfstrace_printf(pInfo, "%s.xDlOpen()\n", pInfo->zVfsName);
17168 pRoot->xDlClose(pRoot, pHandle);
17169 }
17170
17171 /*
17172 ** Populate the buffer pointed to by zBufOut with nByte bytes of
@@ -27460,11 +27501,11 @@
27460 case AR_SWITCH_VERBOSE:
27461 pAr->bVerbose = 1;
27462 break;
27463 case AR_SWITCH_APPEND:
27464 pAr->bAppend = 1;
27465 deliberate_fall_through;
27466 case AR_SWITCH_FILE:
27467 pAr->zFile = zArg;
27468 break;
27469 case AR_SWITCH_DIRECTORY:
27470 pAr->zDir = zArg;
@@ -28848,10 +28889,13 @@
28848 if( c=='d' && n>=3 && cli_strncmp(azArg[0], "dbconfig", n)==0 ){
28849 static const struct DbConfigChoices {
28850 const char *zName;
28851 int op;
28852 } aDbConfig[] = {
 
 
 
28853 { "defensive", SQLITE_DBCONFIG_DEFENSIVE },
28854 { "dqs_ddl", SQLITE_DBCONFIG_DQS_DDL },
28855 { "dqs_dml", SQLITE_DBCONFIG_DQS_DML },
28856 { "enable_fkey", SQLITE_DBCONFIG_ENABLE_FKEY },
28857 { "enable_qpsg", SQLITE_DBCONFIG_ENABLE_QPSG },
@@ -30202,10 +30246,11 @@
30202 }
30203 }
30204 if( zFile==0 ){
30205 zFile = sqlite3_mprintf("stdout");
30206 }
 
30207 if( bOnce ){
30208 p->outCount = 2;
30209 }else{
30210 p->outCount = 0;
30211 }
@@ -30244,10 +30289,11 @@
30244 rc = 1;
30245 output_redir(p, stdout);
30246 #else
30247 FILE *pfPipe = sqlite3_popen(zFile + 1, "w");
30248 if( pfPipe==0 ){
 
30249 sqlite3_fprintf(stderr,"Error: cannot open pipe \"%s\"\n", zFile + 1);
30250 rc = 1;
30251 }else{
30252 output_redir(p, pfPipe);
30253 if( zBom ) sqlite3_fputs(zBom, pfPipe);
@@ -30256,11 +30302,12 @@
30256 #endif
30257 }else{
30258 FILE *pfFile = output_file_open(zFile);
30259 if( pfFile==0 ){
30260 if( cli_strcmp(zFile,"off")!=0 ){
30261 sqlite3_fprintf(stderr,"Error: cannot write to \"%s\"\n", zFile);
 
30262 }
30263 rc = 1;
30264 } else {
30265 output_redir(p, pfFile);
30266 if( zBom ) sqlite3_fputs(zBom, pfFile);
@@ -30360,10 +30407,11 @@
30360 sqlite3_finalize(pStmt);
30361 pStmt = 0;
30362 rc = 1;
30363 }
30364 }
 
30365 sqlite3_step(pStmt);
30366 sqlite3_finalize(pStmt);
30367 }else
30368
30369 /* .parameter unset NAME
@@ -31594,10 +31642,11 @@
31594 { 0x01000000, 1, "IndexedEXpr" },
31595 { 0x02000000, 1, "Coroutines" },
31596 { 0x04000000, 1, "NullUnusedCols" },
31597 { 0x08000000, 1, "OnePass" },
31598 { 0x10000000, 1, "OrderBySubq" },
 
31599 { 0xffffffff, 0, "All" },
31600 };
31601 unsigned int curOpt;
31602 unsigned int newOpt;
31603 unsigned int m;
@@ -32148,11 +32197,11 @@
32148 goto TermScan;
32149 }
32150 break;
32151 case '[':
32152 cin = ']';
32153 deliberate_fall_through;
32154 case '`': case '\'': case '"':
32155 cWait = cin;
32156 qss = QSS_HasDark | cWait;
32157 CONTINUE_PROMPT_AWAITC(pst, cin);
32158 goto TermScan;
@@ -32183,11 +32232,11 @@
32183 if(*zLine==cWait){
32184 /* Swallow doubled end-delimiter.*/
32185 ++zLine;
32186 continue;
32187 }
32188 deliberate_fall_through;
32189 case ']':
32190 CONTINUE_PROMPT_AWAITC(pst, 0);
32191 qss = QSS_SETV(qss, 0);
32192 goto PlainScan;
32193 default: assert(0);
32194
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -355,10 +355,15 @@
355 **
356 ** The default behavior, if neither of the above is defined is to
357 ** use O_U8TEXT when writing to the Windows console (or anything
358 ** else for which _isatty() returns true) and to use O_BINARY or O_TEXT
359 ** for all other output channels.
360 **
361 ** The SQLITE_USE_W32_FOR_CONSOLE_IO macro is also available. If
362 ** defined, it forces the use of Win32 APIs for all console I/O, both
363 ** input and output. This is necessary for some non-Microsoft run-times
364 ** that implement stdio differently from Microsoft/Visual-Studio.
365 */
366 #if defined(SQLITE_U8TEXT_ONLY)
367 # define UseWtextForOutput(fd) 1
368 # define UseWtextForInput(fd) 1
369 # define IsConsole(fd) _isatty(_fileno(fd))
@@ -457,14 +462,14 @@
462 ** that into UTF-8. Otherwise, non-ASCII characters all get translated
463 ** into '?'.
464 */
465 wchar_t *b1 = sqlite3_malloc( sz*sizeof(wchar_t) );
466 if( b1==0 ) return 0;
467 #ifdef SQLITE_USE_W32_FOR_CONSOLE_IO
468 DWORD nRead = 0;
469 if( IsConsole(in)
470 && ReadConsoleW(GetStdHandle(STD_INPUT_HANDLE), b1, sz-1, &nRead, 0)
471 ){
472 b1[nRead] = 0;
473 }else
474 #endif
475 {
@@ -535,22 +540,23 @@
540 wchar_t *b1 = sqlite3_malloc( (sz+1)*sizeof(wchar_t) );
541 if( b1==0 ) return 0;
542 sz = MultiByteToWideChar(CP_UTF8, 0, z, sz, b1, sz);
543 b1[sz] = 0;
544
545 #ifdef SQLITE_USE_W32_FOR_CONSOLE_IO
546 DWORD nWr = 0;
547 if( IsConsole(out)
548 && WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE),b1,sz,&nWr,0)
549 ){
550 /* If writing to the console, then the WriteConsoleW() is all we
551 ** need to do. */
552 }else
553 #endif
554 {
555 /* As long as SQLITE_USE_W32_FOR_CONSOLE_IO is not defined, or for
556 ** non-console I/O even if that macro is defined, write using the
557 ** standard library. */
558 _setmode(_fileno(out), _O_U8TEXT);
559 if( UseBinaryWText(out) ){
560 piecemealOutput(b1, sz, out);
561 }else{
562 fputws(b1, out);
@@ -5289,31 +5295,34 @@
5295 u8 bdp = BX_DV_PROTO(c);
5296 switch( bdp ){
5297 case ND:
5298 /* Treat dark non-digits as pad, but they terminate decode too. */
5299 ncIn = 0;
5300 deliberate_fall_through; /* FALLTHRU */
5301 case WS:
5302 /* Treat whitespace as pad and terminate this group.*/
5303 nti = nac;
5304 deliberate_fall_through; /* FALLTHRU */
5305 case PC:
5306 bdp = 0;
5307 --nbo;
5308 deliberate_fall_through; /* FALLTHRU */
5309 default: /* bdp is the digit value. */
5310 qv = qv<<6 | bdp;
5311 break;
5312 }
5313 }
5314 switch( nbo ){
5315 case 3:
5316 pOut[2] = (qv) & 0xff;
5317 deliberate_fall_through; /* FALLTHRU */
5318 case 2:
5319 pOut[1] = (qv>>8) & 0xff;
5320 deliberate_fall_through; /* FALLTHRU */
5321 case 1:
5322 pOut[0] = (qv>>16) & 0xff;
5323 break;
5324 }
5325 pOut += nbo;
5326 }
5327 return pOut;
5328 }
@@ -5644,16 +5653,20 @@
5653 }
5654 nbo -= nti; /* Adjust for early (non-digit) end of group. */
5655 switch( nbo ){
5656 case 4:
5657 *pOut++ = (qv >> 24)&0xff;
5658 /* FALLTHRU */
5659 case 3:
5660 *pOut++ = (qv >> 16)&0xff;
5661 /* FALLTHRU */
5662 case 2:
5663 *pOut++ = (qv >> 8)&0xff;
5664 /* FALLTHRU */
5665 case 1:
5666 *pOut++ = qv&0xff;
5667 /* FALLTHRU */
5668 case 0:
5669 break;
5670 }
5671 }
5672 return pOut;
@@ -7692,11 +7705,12 @@
7705
7706 /* Free and reclaim all the memory used by a previously compiled
7707 ** regular expression. Applications should invoke this routine once
7708 ** for every call to re_compile() to avoid memory leaks.
7709 */
7710 static void re_free(void *p){
7711 ReCompiled *pRe = (ReCompiled*)p;
7712 if( pRe ){
7713 sqlite3_free(pRe->aOp);
7714 sqlite3_free(pRe->aArg);
7715 sqlite3_free(pRe);
7716 }
@@ -8358,11 +8372,11 @@
8372 LPWSTR zUnicodeName;
8373 extern LPWSTR sqlite3_win32_utf8_to_unicode(const char*);
8374
8375 GetSystemTime(&currentTime);
8376 SystemTimeToFileTime(&currentTime, &lastAccess);
8377 intervals = (mtime*10000000) + 116444736000000000;
8378 lastWrite.dwLowDateTime = (DWORD)intervals;
8379 lastWrite.dwHighDateTime = intervals >> 32;
8380 zUnicodeName = sqlite3_win32_utf8_to_unicode(zFile);
8381 if( zUnicodeName==0 ){
8382 return 1;
@@ -16344,10 +16358,11 @@
16358 #define VTR_DLCLOSE 0x00800000
16359 #define VTR_RAND 0x01000000
16360 #define VTR_SLEEP 0x02000000
16361 #define VTR_CURTIME 0x04000000
16362 #define VTR_LASTERR 0x08000000
16363 #define VTR_FETCH 0x10000000 /* Also coverse xUnfetch */
16364
16365 /*
16366 ** Method declarations for vfstrace_file.
16367 */
16368 static int vfstraceClose(sqlite3_file*);
@@ -16773,10 +16788,11 @@
16788 { "randomness", VTR_RAND },
16789 { "sleep", VTR_SLEEP },
16790 { "currenttime", VTR_CURTIME },
16791 { "currenttimeint64", VTR_CURTIME },
16792 { "getlasterror", VTR_LASTERR },
16793 { "fetch", VTR_FETCH },
16794 };
16795 int onOff = 1;
16796 while( zArg[0] ){
16797 int jj, n;
16798 while( zArg[0]!=0 && zArg[0]!='-' && zArg[0]!='+'
@@ -17000,11 +17016,32 @@
17016 pInfo->zVfsName, p->zFName, delFlag);
17017 rc = p->pReal->pMethods->xShmUnmap(p->pReal, delFlag);
17018 vfstrace_print_errcode(pInfo, " -> %s\n", rc);
17019 return rc;
17020 }
17021 static int vfstraceFetch(sqlite3_file *pFile, i64 iOff, int nAmt, void **pptr){
17022 vfstrace_file *p = (vfstrace_file *)pFile;
17023 vfstrace_info *pInfo = p->pInfo;
17024 int rc;
17025 vfstraceOnOff(pInfo, VTR_FETCH);
17026 vfstrace_printf(pInfo, "%s.xFetch(%s,iOff=%lld,nAmt=%d,p=%p)",
17027 pInfo->zVfsName, p->zFName, iOff, nAmt, *pptr);
17028 rc = p->pReal->pMethods->xFetch(p->pReal, iOff, nAmt, pptr);
17029 vfstrace_print_errcode(pInfo, " -> %s\n", rc);
17030 return rc;
17031 }
17032 static int vfstraceUnfetch(sqlite3_file *pFile, i64 iOff, void *ptr){
17033 vfstrace_file *p = (vfstrace_file *)pFile;
17034 vfstrace_info *pInfo = p->pInfo;
17035 int rc;
17036 vfstraceOnOff(pInfo, VTR_FETCH);
17037 vfstrace_printf(pInfo, "%s.xUnfetch(%s,iOff=%lld,p=%p)",
17038 pInfo->zVfsName, p->zFName, iOff, ptr);
17039 rc = p->pReal->pMethods->xUnfetch(p->pReal, iOff, ptr);
17040 vfstrace_print_errcode(pInfo, " -> %s\n", rc);
17041 return rc;
17042 }
17043
17044
17045 /*
17046 ** Open an vfstrace file handle.
17047 */
@@ -17047,10 +17084,14 @@
17084 pNew->xShmMap = pSub->xShmMap ? vfstraceShmMap : 0;
17085 pNew->xShmLock = pSub->xShmLock ? vfstraceShmLock : 0;
17086 pNew->xShmBarrier = pSub->xShmBarrier ? vfstraceShmBarrier : 0;
17087 pNew->xShmUnmap = pSub->xShmUnmap ? vfstraceShmUnmap : 0;
17088 }
17089 if( pNew->iVersion>=3 ){
17090 pNew->xFetch = pSub->xFetch ? vfstraceFetch : 0;
17091 pNew->xUnfetch = pSub->xUnfetch ? vfstraceUnfetch : 0;
17092 }
17093 pFile->pMethods = pNew;
17094 }
17095 vfstrace_print_errcode(pInfo, " -> %s", rc);
17096 if( pOutFlags ){
17097 vfstrace_printf(pInfo, ", outFlags=0x%x\n", *pOutFlags);
@@ -17162,11 +17203,11 @@
17203 */
17204 static void vfstraceDlClose(sqlite3_vfs *pVfs, void *pHandle){
17205 vfstrace_info *pInfo = (vfstrace_info*)pVfs->pAppData;
17206 sqlite3_vfs *pRoot = pInfo->pRootVfs;
17207 vfstraceOnOff(pInfo, VTR_DLCLOSE);
17208 vfstrace_printf(pInfo, "%s.xDlClose()\n", pInfo->zVfsName);
17209 pRoot->xDlClose(pRoot, pHandle);
17210 }
17211
17212 /*
17213 ** Populate the buffer pointed to by zBufOut with nByte bytes of
@@ -27460,11 +27501,11 @@
27501 case AR_SWITCH_VERBOSE:
27502 pAr->bVerbose = 1;
27503 break;
27504 case AR_SWITCH_APPEND:
27505 pAr->bAppend = 1;
27506 deliberate_fall_through; /* FALLTHRU */
27507 case AR_SWITCH_FILE:
27508 pAr->zFile = zArg;
27509 break;
27510 case AR_SWITCH_DIRECTORY:
27511 pAr->zDir = zArg;
@@ -28848,10 +28889,13 @@
28889 if( c=='d' && n>=3 && cli_strncmp(azArg[0], "dbconfig", n)==0 ){
28890 static const struct DbConfigChoices {
28891 const char *zName;
28892 int op;
28893 } aDbConfig[] = {
28894 { "attach_create", SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE },
28895 { "attach_write", SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE },
28896 { "comments", SQLITE_DBCONFIG_ENABLE_COMMENTS },
28897 { "defensive", SQLITE_DBCONFIG_DEFENSIVE },
28898 { "dqs_ddl", SQLITE_DBCONFIG_DQS_DDL },
28899 { "dqs_dml", SQLITE_DBCONFIG_DQS_DML },
28900 { "enable_fkey", SQLITE_DBCONFIG_ENABLE_FKEY },
28901 { "enable_qpsg", SQLITE_DBCONFIG_ENABLE_QPSG },
@@ -30202,10 +30246,11 @@
30246 }
30247 }
30248 if( zFile==0 ){
30249 zFile = sqlite3_mprintf("stdout");
30250 }
30251 shell_check_oom(zFile);
30252 if( bOnce ){
30253 p->outCount = 2;
30254 }else{
30255 p->outCount = 0;
30256 }
@@ -30244,10 +30289,11 @@
30289 rc = 1;
30290 output_redir(p, stdout);
30291 #else
30292 FILE *pfPipe = sqlite3_popen(zFile + 1, "w");
30293 if( pfPipe==0 ){
30294 assert( stderr!=NULL );
30295 sqlite3_fprintf(stderr,"Error: cannot open pipe \"%s\"\n", zFile + 1);
30296 rc = 1;
30297 }else{
30298 output_redir(p, pfPipe);
30299 if( zBom ) sqlite3_fputs(zBom, pfPipe);
@@ -30256,11 +30302,12 @@
30302 #endif
30303 }else{
30304 FILE *pfFile = output_file_open(zFile);
30305 if( pfFile==0 ){
30306 if( cli_strcmp(zFile,"off")!=0 ){
30307 assert( stderr!=NULL );
30308 sqlite3_fprintf(stderr,"Error: cannot write to \"%s\"\n", zFile);
30309 }
30310 rc = 1;
30311 } else {
30312 output_redir(p, pfFile);
30313 if( zBom ) sqlite3_fputs(zBom, pfFile);
@@ -30360,10 +30407,11 @@
30407 sqlite3_finalize(pStmt);
30408 pStmt = 0;
30409 rc = 1;
30410 }
30411 }
30412 bind_prepared_stmt(p, pStmt);
30413 sqlite3_step(pStmt);
30414 sqlite3_finalize(pStmt);
30415 }else
30416
30417 /* .parameter unset NAME
@@ -31594,10 +31642,11 @@
31642 { 0x01000000, 1, "IndexedEXpr" },
31643 { 0x02000000, 1, "Coroutines" },
31644 { 0x04000000, 1, "NullUnusedCols" },
31645 { 0x08000000, 1, "OnePass" },
31646 { 0x10000000, 1, "OrderBySubq" },
31647 { 0x20000000, 1, "StarQuery" },
31648 { 0xffffffff, 0, "All" },
31649 };
31650 unsigned int curOpt;
31651 unsigned int newOpt;
31652 unsigned int m;
@@ -32148,11 +32197,11 @@
32197 goto TermScan;
32198 }
32199 break;
32200 case '[':
32201 cin = ']';
32202 deliberate_fall_through; /* FALLTHRU */
32203 case '`': case '\'': case '"':
32204 cWait = cin;
32205 qss = QSS_HasDark | cWait;
32206 CONTINUE_PROMPT_AWAITC(pst, cin);
32207 goto TermScan;
@@ -32183,11 +32232,11 @@
32232 if(*zLine==cWait){
32233 /* Swallow doubled end-delimiter.*/
32234 ++zLine;
32235 continue;
32236 }
32237 deliberate_fall_through; /* FALLTHRU */
32238 case ']':
32239 CONTINUE_PROMPT_AWAITC(pst, 0);
32240 qss = QSS_SETV(qss, 0);
32241 goto PlainScan;
32242 default: assert(0);
32243
+3000 -2454
--- extsrc/sqlite3.c
+++ extsrc/sqlite3.c
@@ -1,8 +1,8 @@
11
/******************************************************************************
22
** This file is an amalgamation of many separate C source files from SQLite
3
-** version 3.48.0. By combining all the individual C code files into this
3
+** version 3.50.0. By combining all the individual C code files into this
44
** single large file, the entire code can be compiled as a single translation
55
** unit. This allows many compilers to do optimizations that would not be
66
** possible if the files were compiled separately. Performance improvements
77
** of 5% or more are commonly seen when SQLite is compiled as a single
88
** translation unit.
@@ -16,11 +16,11 @@
1616
** if you want a wrapper to interface SQLite with your choice of programming
1717
** language. The code for the "sqlite3" command-line shell is also in a
1818
** separate file. This file contains only code for the core SQLite library.
1919
**
2020
** The content in this amalgamation comes from Fossil check-in
21
-** e2bae4143afd07de1ae55a6d2606a3b541a5 with changes in files:
21
+** 57caa3136d1bfca06e4f2285734a4977b8d3 with changes in files:
2222
**
2323
**
2424
*/
2525
#ifndef SQLITE_AMALGAMATION
2626
#define SQLITE_CORE 1
@@ -463,13 +463,13 @@
463463
**
464464
** See also: [sqlite3_libversion()],
465465
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
466466
** [sqlite_version()] and [sqlite_source_id()].
467467
*/
468
-#define SQLITE_VERSION "3.48.0"
469
-#define SQLITE_VERSION_NUMBER 3048000
470
-#define SQLITE_SOURCE_ID "2024-12-09 20:46:36 e2bae4143afd07de1ae55a6d2606a3b541a5b94568aa41f6a96e5d1245471653"
468
+#define SQLITE_VERSION "3.50.0"
469
+#define SQLITE_VERSION_NUMBER 3050000
470
+#define SQLITE_SOURCE_ID "2025-02-18 01:16:26 57caa3136d1bfca06e4f2285734a4977b8d3fa1f75bf87453b975867e9de38fc"
471471
472472
/*
473473
** CAPI3REF: Run-Time Library Version Numbers
474474
** KEYWORDS: sqlite3_version sqlite3_sourceid
475475
**
@@ -2306,17 +2306,20 @@
23062306
** [sqlite3_config()] with the SQLITE_CONFIG_GETMUTEX configuration option will
23072307
** return [SQLITE_ERROR].</dd>
23082308
**
23092309
** [[SQLITE_CONFIG_LOOKASIDE]] <dt>SQLITE_CONFIG_LOOKASIDE</dt>
23102310
** <dd> ^(The SQLITE_CONFIG_LOOKASIDE option takes two arguments that determine
2311
-** the default size of lookaside memory on each [database connection].
2311
+** the default size of [lookaside memory] on each [database connection].
23122312
** The first argument is the
2313
-** size of each lookaside buffer slot and the second is the number of
2314
-** slots allocated to each database connection.)^ ^(SQLITE_CONFIG_LOOKASIDE
2315
-** sets the <i>default</i> lookaside size. The [SQLITE_DBCONFIG_LOOKASIDE]
2316
-** option to [sqlite3_db_config()] can be used to change the lookaside
2317
-** configuration on individual connections.)^ </dd>
2313
+** size of each lookaside buffer slot ("sz") and the second is the number of
2314
+** slots allocated to each database connection ("cnt").)^
2315
+** ^(SQLITE_CONFIG_LOOKASIDE sets the <i>default</i> lookaside size.
2316
+** The [SQLITE_DBCONFIG_LOOKASIDE] option to [sqlite3_db_config()] can
2317
+** be used to change the lookaside configuration on individual connections.)^
2318
+** The [-DSQLITE_DEFAULT_LOOKASIDE] option can be used to change the
2319
+** default lookaside configuration at compile-time.
2320
+** </dd>
23182321
**
23192322
** [[SQLITE_CONFIG_PCACHE2]] <dt>SQLITE_CONFIG_PCACHE2</dt>
23202323
** <dd> ^(The SQLITE_CONFIG_PCACHE2 option takes a single argument which is
23212324
** a pointer to an [sqlite3_pcache_methods2] object. This object specifies
23222325
** the interface to a custom page cache implementation.)^
@@ -2528,11 +2531,19 @@
25282531
25292532
/*
25302533
** CAPI3REF: Database Connection Configuration Options
25312534
**
25322535
** These constants are the available integer configuration options that
2533
-** can be passed as the second argument to the [sqlite3_db_config()] interface.
2536
+** can be passed as the second parameter to the [sqlite3_db_config()] interface.
2537
+**
2538
+** The [sqlite3_db_config()] interface is a var-args functions. It takes a
2539
+** variable number of parameters, though always at least two. The number of
2540
+** parameters passed into sqlite3_db_config() depends on which of these
2541
+** constants is given as the second parameter. This documentation page
2542
+** refers to parameters beyond the second as "arguments". Thus, when this
2543
+** page says "the N-th argument" it means "the N-th parameter past the
2544
+** configuration option" or "the (N+2)-th parameter to sqlite3_db_config()".
25342545
**
25352546
** New configuration options may be added in future releases of SQLite.
25362547
** Existing configuration options might be discontinued. Applications
25372548
** should check the return code from [sqlite3_db_config()] to make sure that
25382549
** the call worked. ^The [sqlite3_db_config()] interface will return a
@@ -2540,35 +2551,61 @@
25402551
** is invoked.
25412552
**
25422553
** <dl>
25432554
** [[SQLITE_DBCONFIG_LOOKASIDE]]
25442555
** <dt>SQLITE_DBCONFIG_LOOKASIDE</dt>
2545
-** <dd> ^This option takes three additional arguments that determine the
2546
-** [lookaside memory allocator] configuration for the [database connection].
2547
-** ^The first argument (the third parameter to [sqlite3_db_config()] is a
2556
+** <dd> The SQLITE_DBCONFIG_LOOKASIDE option is used to adjust the
2557
+** configuration of the [lookaside memory allocator] within a database
2558
+** connection.
2559
+** The arguments to the SQLITE_DBCONFIG_LOOKASIDE option are <i>not</i>
2560
+** in the [DBCONFIG arguments|usual format].
2561
+** The SQLITE_DBCONFIG_LOOKASIDE option takes three arguments, not two,
2562
+** so that a call to [sqlite3_db_config()] that uses SQLITE_DBCONFIG_LOOKASIDE
2563
+** should have a total of five parameters.
2564
+** <ol>
2565
+** <li><p>The first argument ("buf") is a
25482566
** pointer to a memory buffer to use for lookaside memory.
2549
-** ^The first argument after the SQLITE_DBCONFIG_LOOKASIDE verb
2550
-** may be NULL in which case SQLite will allocate the
2551
-** lookaside buffer itself using [sqlite3_malloc()]. ^The second argument is the
2552
-** size of each lookaside buffer slot. ^The third argument is the number of
2553
-** slots. The size of the buffer in the first argument must be greater than
2554
-** or equal to the product of the second and third arguments. The buffer
2555
-** must be aligned to an 8-byte boundary. ^If the second argument to
2556
-** SQLITE_DBCONFIG_LOOKASIDE is not a multiple of 8, it is internally
2557
-** rounded down to the next smaller multiple of 8. ^(The lookaside memory
2567
+** The first argument may be NULL in which case SQLite will allocate the
2568
+** lookaside buffer itself using [sqlite3_malloc()].
2569
+** <li><P>The second argument ("sz") is the
2570
+** size of each lookaside buffer slot. Lookaside is disabled if "sz"
2571
+** is less than 8. The "sz" argument should be a multiple of 8 less than
2572
+** 65536. If "sz" does not meet this constraint, it is reduced in size until
2573
+** it does.
2574
+** <li><p>The third argument ("cnt") is the number of slots. Lookaside is disabled
2575
+** if "cnt"is less than 1. The "cnt" value will be reduced, if necessary, so
2576
+** that the product of "sz" and "cnt" does not exceed 2,147,418,112. The "cnt"
2577
+** parameter is usually chosen so that the product of "sz" and "cnt" is less
2578
+** than 1,000,000.
2579
+** </ol>
2580
+** <p>If the "buf" argument is not NULL, then it must
2581
+** point to a memory buffer with a size that is greater than
2582
+** or equal to the product of "sz" and "cnt".
2583
+** The buffer must be aligned to an 8-byte boundary.
2584
+** The lookaside memory
25582585
** configuration for a database connection can only be changed when that
25592586
** connection is not currently using lookaside memory, or in other words
2560
-** when the "current value" returned by
2561
-** [sqlite3_db_status](D,[SQLITE_DBSTATUS_LOOKASIDE_USED],...) is zero.
2587
+** when the value returned by [SQLITE_DBSTATUS_LOOKASIDE_USED] is zero.
25622588
** Any attempt to change the lookaside memory configuration when lookaside
25632589
** memory is in use leaves the configuration unchanged and returns
2564
-** [SQLITE_BUSY].)^</dd>
2590
+** [SQLITE_BUSY].
2591
+** If the "buf" argument is NULL and an attempt
2592
+** to allocate memory based on "sz" and "cnt" fails, then
2593
+** lookaside is silently disabled.
2594
+** <p>
2595
+** The [SQLITE_CONFIG_LOOKASIDE] configuration option can be used to set the
2596
+** default lookaside configuration at initialization. The
2597
+** [-DSQLITE_DEFAULT_LOOKASIDE] option can be used to set the default lookaside
2598
+** configuration at compile-time. Typical values for lookaside are 1200 for
2599
+** "sz" and 40 to 100 for "cnt".
2600
+** </dd>
25652601
**
25662602
** [[SQLITE_DBCONFIG_ENABLE_FKEY]]
25672603
** <dt>SQLITE_DBCONFIG_ENABLE_FKEY</dt>
25682604
** <dd> ^This option is used to enable or disable the enforcement of
2569
-** [foreign key constraints]. There should be two additional arguments.
2605
+** [foreign key constraints]. This is the same setting that is
2606
+** enabled or disabled by the [PRAGMA foreign_keys] statement.
25702607
** The first argument is an integer which is 0 to disable FK enforcement,
25712608
** positive to enable FK enforcement or negative to leave FK enforcement
25722609
** unchanged. The second parameter is a pointer to an integer into which
25732610
** is written 0 or 1 to indicate whether FK enforcement is off or on
25742611
** following this call. The second parameter may be a NULL pointer, in
@@ -2586,17 +2623,17 @@
25862623
** which case the trigger setting is not reported back.
25872624
**
25882625
** <p>Originally this option disabled all triggers. ^(However, since
25892626
** SQLite version 3.35.0, TEMP triggers are still allowed even if
25902627
** this option is off. So, in other words, this option now only disables
2591
-** triggers in the main database schema or in the schemas of ATTACH-ed
2628
+** triggers in the main database schema or in the schemas of [ATTACH]-ed
25922629
** databases.)^ </dd>
25932630
**
25942631
** [[SQLITE_DBCONFIG_ENABLE_VIEW]]
25952632
** <dt>SQLITE_DBCONFIG_ENABLE_VIEW</dt>
25962633
** <dd> ^This option is used to enable or disable [CREATE VIEW | views].
2597
-** There should be two additional arguments.
2634
+** There must be two additional arguments.
25982635
** The first argument is an integer which is 0 to disable views,
25992636
** positive to enable views or negative to leave the setting unchanged.
26002637
** The second parameter is a pointer to an integer into which
26012638
** is written 0 or 1 to indicate whether views are disabled or enabled
26022639
** following this call. The second parameter may be a NULL pointer, in
@@ -2611,11 +2648,11 @@
26112648
** [[SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER]]
26122649
** <dt>SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER</dt>
26132650
** <dd> ^This option is used to enable or disable the
26142651
** [fts3_tokenizer()] function which is part of the
26152652
** [FTS3] full-text search engine extension.
2616
-** There should be two additional arguments.
2653
+** There must be two additional arguments.
26172654
** The first argument is an integer which is 0 to disable fts3_tokenizer() or
26182655
** positive to enable fts3_tokenizer() or negative to leave the setting
26192656
** unchanged.
26202657
** The second parameter is a pointer to an integer into which
26212658
** is written 0 or 1 to indicate whether fts3_tokenizer is disabled or enabled
@@ -2626,11 +2663,11 @@
26262663
** <dt>SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION</dt>
26272664
** <dd> ^This option is used to enable or disable the [sqlite3_load_extension()]
26282665
** interface independently of the [load_extension()] SQL function.
26292666
** The [sqlite3_enable_load_extension()] API enables or disables both the
26302667
** C-API [sqlite3_load_extension()] and the SQL function [load_extension()].
2631
-** There should be two additional arguments.
2668
+** There must be two additional arguments.
26322669
** When the first argument to this interface is 1, then only the C-API is
26332670
** enabled and the SQL function remains disabled. If the first argument to
26342671
** this interface is 0, then both the C-API and the SQL function are disabled.
26352672
** If the first argument is -1, then no changes are made to state of either the
26362673
** C-API or the SQL function.
@@ -2640,27 +2677,34 @@
26402677
** be a NULL pointer, in which case the new setting is not reported back.
26412678
** </dd>
26422679
**
26432680
** [[SQLITE_DBCONFIG_MAINDBNAME]] <dt>SQLITE_DBCONFIG_MAINDBNAME</dt>
26442681
** <dd> ^This option is used to change the name of the "main" database
2645
-** schema. ^The sole argument is a pointer to a constant UTF8 string
2646
-** which will become the new schema name in place of "main". ^SQLite
2647
-** does not make a copy of the new main schema name string, so the application
2648
-** must ensure that the argument passed into this DBCONFIG option is unchanged
2649
-** until after the database connection closes.
2682
+** schema. This option does not follow the
2683
+** [DBCONFIG arguments|usual SQLITE_DBCONFIG argument format].
2684
+** This option takes exactly one additional argument so that the
2685
+** [sqlite3_db_config()] call has a total of three parameters. The
2686
+** extra argument must be a pointer to a constant UTF8 string which
2687
+** will become the new schema name in place of "main". ^SQLite does
2688
+** not make a copy of the new main schema name string, so the application
2689
+** must ensure that the argument passed into SQLITE_DBCONFIG MAINDBNAME
2690
+** is unchanged until after the database connection closes.
26502691
** </dd>
26512692
**
26522693
** [[SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE]]
26532694
** <dt>SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE</dt>
2654
-** <dd> Usually, when a database in wal mode is closed or detached from a
2655
-** database handle, SQLite checks if this will mean that there are now no
2656
-** connections at all to the database. If so, it performs a checkpoint
2657
-** operation before closing the connection. This option may be used to
2658
-** override this behavior. The first parameter passed to this operation
2659
-** is an integer - positive to disable checkpoints-on-close, or zero (the
2660
-** default) to enable them, and negative to leave the setting unchanged.
2661
-** The second parameter is a pointer to an integer
2695
+** <dd> Usually, when a database in [WAL mode] is closed or detached from a
2696
+** database handle, SQLite checks if if there are other connections to the
2697
+** same database, and if there are no other database connection (if the
2698
+** connection being closed is the last open connection to the database),
2699
+** then SQLite performs a [checkpoint] before closing the connection and
2700
+** deletes the WAL file. The SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE option can
2701
+** be used to override that behavior. The first argument passed to this
2702
+** operation (the third parameter to [sqlite3_db_config()]) is an integer
2703
+** which is positive to disable checkpoints-on-close, or zero (the default)
2704
+** to enable them, and negative to leave the setting unchanged.
2705
+** The second argument (the fourth parameter) is a pointer to an integer
26622706
** into which is written 0 or 1 to indicate whether checkpoints-on-close
26632707
** have been disabled - 0 if they are not disabled, 1 if they are.
26642708
** </dd>
26652709
**
26662710
** [[SQLITE_DBCONFIG_ENABLE_QPSG]] <dt>SQLITE_DBCONFIG_ENABLE_QPSG</dt>
@@ -2817,11 +2861,11 @@
28172861
** SQLITE_ENABLE_STMT_SCANSTATUS builds. In this case, it sets or clears
28182862
** a flag that enables collection of the sqlite3_stmt_scanstatus_v2()
28192863
** statistics. For statistics to be collected, the flag must be set on
28202864
** the database handle both when the SQL statement is prepared and when it
28212865
** is stepped. The flag is set (collection of statistics is enabled)
2822
-** by default. This option takes two arguments: an integer and a pointer to
2866
+** by default. <p>This option takes two arguments: an integer and a pointer to
28232867
** an integer.. The first argument is 1, 0, or -1 to enable, disable, or
28242868
** leave unchanged the statement scanstatus option. If the second argument
28252869
** is not NULL, then the value of the statement scanstatus setting after
28262870
** processing the first argument is written into the integer that the second
28272871
** argument points to.
@@ -2831,20 +2875,89 @@
28312875
** <dt>SQLITE_DBCONFIG_REVERSE_SCANORDER</dt>
28322876
** <dd>The SQLITE_DBCONFIG_REVERSE_SCANORDER option changes the default order
28332877
** in which tables and indexes are scanned so that the scans start at the end
28342878
** and work toward the beginning rather than starting at the beginning and
28352879
** working toward the end. Setting SQLITE_DBCONFIG_REVERSE_SCANORDER is the
2836
-** same as setting [PRAGMA reverse_unordered_selects]. This option takes
2880
+** same as setting [PRAGMA reverse_unordered_selects]. <p>This option takes
28372881
** two arguments which are an integer and a pointer to an integer. The first
28382882
** argument is 1, 0, or -1 to enable, disable, or leave unchanged the
28392883
** reverse scan order flag, respectively. If the second argument is not NULL,
28402884
** then 0 or 1 is written into the integer that the second argument points to
28412885
** depending on if the reverse scan order flag is set after processing the
28422886
** first argument.
28432887
** </dd>
28442888
**
2889
+** [[SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE]]
2890
+** <dt>SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE</dt>
2891
+** <dd>The SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE option enables or disables
2892
+** the ability of the [ATTACH DATABASE] SQL command to create a new database
2893
+** file if the database filed named in the ATTACH command does not already
2894
+** exist. This ability of ATTACH to create a new database is enabled by
2895
+** default. Applications can disable or reenable the ability for ATTACH to
2896
+** create new database files using this DBCONFIG option.<p>
2897
+** This option takes two arguments which are an integer and a pointer
2898
+** to an integer. The first argument is 1, 0, or -1 to enable, disable, or
2899
+** leave unchanged the attach-create flag, respectively. If the second
2900
+** argument is not NULL, then 0 or 1 is written into the integer that the
2901
+** second argument points to depending on if the attach-create flag is set
2902
+** after processing the first argument.
2903
+** </dd>
2904
+**
2905
+** [[SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE]]
2906
+** <dt>SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE</dt>
2907
+** <dd>The SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE option enables or disables the
2908
+** ability of the [ATTACH DATABASE] SQL command to open a database for writing.
2909
+** This capability is enabled by default. Applications can disable or
2910
+** reenable this capability using the current DBCONFIG option. If the
2911
+** the this capability is disabled, the [ATTACH] command will still work,
2912
+** but the database will be opened read-only. If this option is disabled,
2913
+** then the ability to create a new database using [ATTACH] is also disabled,
2914
+** regardless of the value of the [SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE]
2915
+** option.<p>
2916
+** This option takes two arguments which are an integer and a pointer
2917
+** to an integer. The first argument is 1, 0, or -1 to enable, disable, or
2918
+** leave unchanged the ability to ATTACH another database for writing,
2919
+** respectively. If the second argument is not NULL, then 0 or 1 is written
2920
+** into the integer to which the second argument points, depending on whether
2921
+** the ability to ATTACH a read/write database is enabled or disabled
2922
+** after processing the first argument.
2923
+** </dd>
2924
+**
2925
+** [[SQLITE_DBCONFIG_ENABLE_COMMENTS]]
2926
+** <dt>SQLITE_DBCONFIG_ENABLE_COMMENTS</dt>
2927
+** <dd>The SQLITE_DBCONFIG_ENABLE_COMMENTS option enables or disables the
2928
+** ability to include comments in SQL text. Comments are enabled by default.
2929
+** An application can disable or reenable comments in SQL text using this
2930
+** DBCONFIG option.<p>
2931
+** This option takes two arguments which are an integer and a pointer
2932
+** to an integer. The first argument is 1, 0, or -1 to enable, disable, or
2933
+** leave unchanged the ability to use comments in SQL text,
2934
+** respectively. If the second argument is not NULL, then 0 or 1 is written
2935
+** into the integer that the second argument points to depending on if
2936
+** comments are allowed in SQL text after processing the first argument.
2937
+** </dd>
2938
+**
28452939
** </dl>
2940
+**
2941
+** [[DBCONFIG arguments]] <h3>Arguments To SQLITE_DBCONFIG Options</h3>
2942
+**
2943
+** <p>Most of the SQLITE_DBCONFIG options take two arguments, so that the
2944
+** overall call to [sqlite3_db_config()] has a total of four parameters.
2945
+** The first argument (the third parameter to sqlite3_db_config()) is a integer.
2946
+** The second argument is a pointer to an integer. If the first argument is 1,
2947
+** then the option becomes enabled. If the first integer argument is 0, then the
2948
+** option is disabled. If the first argument is -1, then the option setting
2949
+** is unchanged. The second argument, the pointer to an integer, may be NULL.
2950
+** If the second argument is not NULL, then a value of 0 or 1 is written into
2951
+** the integer to which the second argument points, depending on whether the
2952
+** setting is disabled or enabled after applying any changes specified by
2953
+** the first argument.
2954
+**
2955
+** <p>While most SQLITE_DBCONFIG options use the argument format
2956
+** described in the previous paragraph, the [SQLITE_DBCONFIG_MAINDBNAME]
2957
+** and [SQLITE_DBCONFIG_LOOKASIDE] options are different. See the
2958
+** documentation of those exceptional options for details.
28462959
*/
28472960
#define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */
28482961
#define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */
28492962
#define SQLITE_DBCONFIG_ENABLE_FKEY 1002 /* int int* */
28502963
#define SQLITE_DBCONFIG_ENABLE_TRIGGER 1003 /* int int* */
@@ -2862,11 +2975,14 @@
28622975
#define SQLITE_DBCONFIG_ENABLE_VIEW 1015 /* int int* */
28632976
#define SQLITE_DBCONFIG_LEGACY_FILE_FORMAT 1016 /* int int* */
28642977
#define SQLITE_DBCONFIG_TRUSTED_SCHEMA 1017 /* int int* */
28652978
#define SQLITE_DBCONFIG_STMT_SCANSTATUS 1018 /* int int* */
28662979
#define SQLITE_DBCONFIG_REVERSE_SCANORDER 1019 /* int int* */
2867
-#define SQLITE_DBCONFIG_MAX 1019 /* Largest DBCONFIG */
2980
+#define SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE 1020 /* int int* */
2981
+#define SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE 1021 /* int int* */
2982
+#define SQLITE_DBCONFIG_ENABLE_COMMENTS 1022 /* int int* */
2983
+#define SQLITE_DBCONFIG_MAX 1022 /* Largest DBCONFIG */
28682984
28692985
/*
28702986
** CAPI3REF: Enable Or Disable Extended Result Codes
28712987
** METHOD: sqlite3
28722988
**
@@ -11065,12 +11181,13 @@
1106511181
SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_recover(sqlite3 *db, const char *zDb);
1106611182
1106711183
/*
1106811184
** CAPI3REF: Serialize a database
1106911185
**
11070
-** The sqlite3_serialize(D,S,P,F) interface returns a pointer to memory
11071
-** that is a serialization of the S database on [database connection] D.
11186
+** The sqlite3_serialize(D,S,P,F) interface returns a pointer to
11187
+** memory that is a serialization of the S database on
11188
+** [database connection] D. If S is a NULL pointer, the main database is used.
1107211189
** If P is not a NULL pointer, then the size of the database in bytes
1107311190
** is written into *P.
1107411191
**
1107511192
** For an ordinary on-disk database file, the serialization is just a
1107611193
** copy of the disk file. For an in-memory database or a "TEMP" database,
@@ -12232,23 +12349,10 @@
1223212349
int nB, /* Number of bytes in buffer pB */
1223312350
void *pB, /* Pointer to buffer containing changeset B */
1223412351
int *pnOut, /* OUT: Number of bytes in output changeset */
1223512352
void **ppOut /* OUT: Buffer containing output changeset */
1223612353
);
12237
-
12238
-
12239
-/*
12240
-** CAPI3REF: Upgrade the Schema of a Changeset/Patchset
12241
-*/
12242
-SQLITE_API int sqlite3changeset_upgrade(
12243
- sqlite3 *db,
12244
- const char *zDb,
12245
- int nIn, const void *pIn, /* Input changeset */
12246
- int *pnOut, void **ppOut /* OUT: Inverse of input */
12247
-);
12248
-
12249
-
1225012354
1225112355
/*
1225212356
** CAPI3REF: Changegroup Handle
1225312357
**
1225412358
** A changegroup is an object used to combine two or more
@@ -14046,13 +14150,17 @@
1404614150
# define SQLITE_MAX_VDBE_OP 250000000
1404714151
#endif
1404814152
1404914153
/*
1405014154
** The maximum number of arguments to an SQL function.
14155
+**
14156
+** This value has a hard upper limit of 32767 due to storage
14157
+** constraints (it needs to fit inside a i16). We keep it
14158
+** lower than that to prevent abuse.
1405114159
*/
1405214160
#ifndef SQLITE_MAX_FUNCTION_ARG
14053
-# define SQLITE_MAX_FUNCTION_ARG 127
14161
+# define SQLITE_MAX_FUNCTION_ARG 1000
1405414162
#endif
1405514163
1405614164
/*
1405714165
** The suggested maximum number of in-memory pages to use for
1405814166
** the main database table and for temporary tables.
@@ -14648,10 +14756,11 @@
1464814756
*/
1464914757
struct HashElem {
1465014758
HashElem *next, *prev; /* Next and previous elements in the table */
1465114759
void *data; /* Data associated with this element */
1465214760
const char *pKey; /* Key associated with this element */
14761
+ unsigned int h; /* hash for pKey */
1465314762
};
1465414763
1465514764
/*
1465614765
** Access routines. To delete, insert a NULL pointer.
1465714766
*/
@@ -14871,11 +14980,12 @@
1487114980
#define TK_ASTERISK 180
1487214981
#define TK_SPAN 181
1487314982
#define TK_ERROR 182
1487414983
#define TK_QNUMBER 183
1487514984
#define TK_SPACE 184
14876
-#define TK_ILLEGAL 185
14985
+#define TK_COMMENT 185
14986
+#define TK_ILLEGAL 186
1487714987
1487814988
/************** End of parse.h ***********************************************/
1487914989
/************** Continuing where we left off in sqliteInt.h ******************/
1488014990
#include <stdio.h>
1488114991
#include <stdlib.h>
@@ -15085,10 +15195,15 @@
1508515195
typedef UINT16_TYPE u16; /* 2-byte unsigned integer */
1508615196
typedef INT16_TYPE i16; /* 2-byte signed integer */
1508715197
typedef UINT8_TYPE u8; /* 1-byte unsigned integer */
1508815198
typedef INT8_TYPE i8; /* 1-byte signed integer */
1508915199
15200
+/* A bitfield type for use inside of structures. Always follow with :N where
15201
+** N is the number of bits.
15202
+*/
15203
+typedef unsigned bft; /* Bit Field Type */
15204
+
1509015205
/*
1509115206
** SQLITE_MAX_U32 is a u64 constant that is the maximum u64 value
1509215207
** that can be stored in a u32 without loss of data. The value
1509315208
** is 0x00000000ffffffff. But because of quirks of some compilers, we
1509415209
** have to specify the value in the less intuitive manner shown:
@@ -15123,10 +15238,12 @@
1512315238
** Examples:
1512415239
**
1512515240
** 0.5 -> -10 0.1 -> -33 0.0625 -> -40
1512615241
*/
1512715242
typedef INT16_TYPE LogEst;
15243
+#define LOGEST_MIN (-32768)
15244
+#define LOGEST_MAX (32767)
1512815245
1512915246
/*
1513015247
** Set the SQLITE_PTRSIZE macro to the number of bytes in a pointer
1513115248
*/
1513215249
#ifndef SQLITE_PTRSIZE
@@ -15251,10 +15368,18 @@
1525115368
*/
1525215369
#define LARGEST_INT64 (0xffffffff|(((i64)0x7fffffff)<<32))
1525315370
#define LARGEST_UINT64 (0xffffffff|(((u64)0xffffffff)<<32))
1525415371
#define SMALLEST_INT64 (((i64)-1) - LARGEST_INT64)
1525515372
15373
+/*
15374
+** Macro SMXV(n) return the maximum value that can be held in variable n,
15375
+** assuming n is a signed integer type. UMXV(n) is similar for unsigned
15376
+** integer types.
15377
+*/
15378
+#define SMXV(n) ((((i64)1)<<(sizeof(n)-1))-1)
15379
+#define UMXV(n) ((((i64)1)<<(sizeof(n)))-1)
15380
+
1525615381
/*
1525715382
** Round up a number to the next larger multiple of 8. This is used
1525815383
** to force 8-byte alignment on 64-bit architectures.
1525915384
**
1526015385
** ROUND8() always does the rounding, for any argument.
@@ -15393,11 +15518,11 @@
1539315518
** 0x-------F High-level debug messages
1539415519
** 0x----FFF- More detail
1539515520
** 0xFFFF---- Low-level debug messages
1539615521
**
1539715522
** 0x00000001 Code generation
15398
-** 0x00000002 Solver
15523
+** 0x00000002 Solver (Use 0x40000 for less detail)
1539915524
** 0x00000004 Solver costs
1540015525
** 0x00000008 WhereLoop inserts
1540115526
**
1540215527
** 0x00000010 Display sqlite3_index_info xBestIndex calls
1540315528
** 0x00000020 Range an equality scan metrics
@@ -15412,10 +15537,12 @@
1541215537
** 0x00004000 Show all WHERE terms at key points
1541315538
** 0x00008000 Show the full SELECT statement at key places
1541415539
**
1541515540
** 0x00010000 Show more detail when printing WHERE terms
1541615541
** 0x00020000 Show WHERE terms returned from whereScanNext()
15542
+** 0x00040000 Solver overview messages
15543
+** 0x00080000 Star-query heuristic
1541715544
*/
1541815545
1541915546
1542015547
/*
1542115548
** An instance of the following structure is used to store the busy-handler
@@ -16049,10 +16176,26 @@
1604916176
#define PAGER_JOURNALMODE_PERSIST 1 /* Commit by zeroing journal header */
1605016177
#define PAGER_JOURNALMODE_OFF 2 /* Journal omitted. */
1605116178
#define PAGER_JOURNALMODE_TRUNCATE 3 /* Commit by truncating journal */
1605216179
#define PAGER_JOURNALMODE_MEMORY 4 /* In-memory journal file */
1605316180
#define PAGER_JOURNALMODE_WAL 5 /* Use write-ahead logging */
16181
+
16182
+#define isWalMode(x) ((x)==PAGER_JOURNALMODE_WAL)
16183
+
16184
+/*
16185
+** The argument to this macro is a file descriptor (type sqlite3_file*).
16186
+** Return 0 if it is not open, or non-zero (but not 1) if it is.
16187
+**
16188
+** This is so that expressions can be written as:
16189
+**
16190
+** if( isOpen(pPager->jfd) ){ ...
16191
+**
16192
+** instead of
16193
+**
16194
+** if( pPager->jfd->pMethods ){ ...
16195
+*/
16196
+#define isOpen(pFd) ((pFd)->pMethods!=0)
1605416197
1605516198
/*
1605616199
** Flags that make up the mask passed to sqlite3PagerGet().
1605716200
*/
1605816201
#define PAGER_GET_NOCONTENT 0x01 /* Do not load data from disk */
@@ -16688,10 +16831,11 @@
1668816831
** A signature for a reusable subroutine that materializes the RHS of
1668916832
** an IN operator.
1669016833
*/
1669116834
struct SubrtnSig {
1669216835
int selId; /* SELECT-id for the SELECT statement on the RHS */
16836
+ u8 bComplete; /* True if fully coded and available for reusable */
1669316837
char *zAff; /* Affinity of the overall IN expression */
1669416838
int iTable; /* Ephemeral table generated by the subroutine */
1669516839
int iAddr; /* Subroutine entry address */
1669616840
int regReturn; /* Register used to hold return address */
1669716841
};
@@ -18018,10 +18162,13 @@
1801818162
/* DELETE, or UPDATE and return */
1801918163
/* the count using a callback. */
1802018164
#define SQLITE_CorruptRdOnly HI(0x00002) /* Prohibit writes due to error */
1802118165
#define SQLITE_ReadUncommit HI(0x00004) /* READ UNCOMMITTED in shared-cache */
1802218166
#define SQLITE_FkNoAction HI(0x00008) /* Treat all FK as NO ACTION */
18167
+#define SQLITE_AttachCreate HI(0x00010) /* ATTACH allowed to create new dbs */
18168
+#define SQLITE_AttachWrite HI(0x00020) /* ATTACH allowed to open for write */
18169
+#define SQLITE_Comments HI(0x00040) /* Enable SQL comments */
1802318170
1802418171
/* Flags used only if debugging */
1802518172
#ifdef SQLITE_DEBUG
1802618173
#define SQLITE_SqlTrace HI(0x0100000) /* Debug print SQL as it executes */
1802718174
#define SQLITE_VdbeListing HI(0x0200000) /* Debug listings of VDBE progs */
@@ -18077,10 +18224,11 @@
1807718224
#define SQLITE_IndexedExpr 0x01000000 /* Pull exprs from index when able */
1807818225
#define SQLITE_Coroutines 0x02000000 /* Co-routines for subqueries */
1807918226
#define SQLITE_NullUnusedCols 0x04000000 /* NULL unused columns in subqueries */
1808018227
#define SQLITE_OnePass 0x08000000 /* Single-pass DELETE and UPDATE */
1808118228
#define SQLITE_OrderBySubq 0x10000000 /* ORDER BY in subquery helps outer */
18229
+#define SQLITE_StarQuery 0x20000000 /* Heurists for star queries */
1808218230
#define SQLITE_AllOpts 0xffffffff /* All optimizations */
1808318231
1808418232
/*
1808518233
** Macros for testing whether or not optimizations are enabled or disabled.
1808618234
*/
@@ -18113,11 +18261,11 @@
1811318261
**
1811418262
** The u.pHash field is used by the global built-ins. The u.pDestructor
1811518263
** field is used by per-connection app-def functions.
1811618264
*/
1811718265
struct FuncDef {
18118
- i8 nArg; /* Number of arguments. -1 means unlimited */
18266
+ i16 nArg; /* Number of arguments. -1 means unlimited */
1811918267
u32 funcFlags; /* Some combination of SQLITE_FUNC_* */
1812018268
void *pUserData; /* User data parameter */
1812118269
FuncDef *pNext; /* Next function with same name */
1812218270
void (*xSFunc)(sqlite3_context*,int,sqlite3_value**); /* func or agg-step */
1812318271
void (*xFinalize)(sqlite3_context*); /* Agg finalizer */
@@ -18606,10 +18754,11 @@
1860618754
VTable *p; /* List of VTable objects. */
1860718755
} vtab;
1860818756
} u;
1860918757
Trigger *pTrigger; /* List of triggers on this object */
1861018758
Schema *pSchema; /* Schema that contains this table */
18759
+ u8 aHx[16]; /* Column aHt[K%sizeof(aHt)] might have hash K */
1861118760
};
1861218761
1861318762
/*
1861418763
** Allowed values for Table.tabFlags.
1861518764
**
@@ -19406,17 +19555,12 @@
1940619555
**
1940719556
** If "a" is the k-th column of table "t", then IdList.a[0].idx==k.
1940819557
*/
1940919558
struct IdList {
1941019559
int nId; /* Number of identifiers on the list */
19411
- u8 eU4; /* Which element of a.u4 is valid */
1941219560
struct IdList_item {
1941319561
char *zName; /* Name of the identifier */
19414
- union {
19415
- int idx; /* Index in some Table.aCol[] of a column named zName */
19416
- Expr *pExpr; /* Expr to implement a USING variable -- NOT USED */
19417
- } u4;
1941819562
} a[1];
1941919563
};
1942019564
1942119565
/*
1942219566
** Allowed values for IdList.eType, which determines which value of the a.u4
@@ -20008,29 +20152,36 @@
2000820152
struct Parse {
2000920153
sqlite3 *db; /* The main database structure */
2001020154
char *zErrMsg; /* An error message */
2001120155
Vdbe *pVdbe; /* An engine for executing database bytecode */
2001220156
int rc; /* Return code from execution */
20013
- u8 colNamesSet; /* TRUE after OP_ColumnName has been issued to pVdbe */
20014
- u8 checkSchema; /* Causes schema cookie check after an error */
20157
+ LogEst nQueryLoop; /* Est number of iterations of a query (10*log2(N)) */
2001520158
u8 nested; /* Number of nested calls to the parser/code generator */
2001620159
u8 nTempReg; /* Number of temporary registers in aTempReg[] */
2001720160
u8 isMultiWrite; /* True if statement may modify/insert multiple rows */
2001820161
u8 mayAbort; /* True if statement may throw an ABORT exception */
2001920162
u8 hasCompound; /* Need to invoke convertCompoundSelectToSubquery() */
20020
- u8 okConstFactor; /* OK to factor out constants */
2002120163
u8 disableLookaside; /* Number of times lookaside has been disabled */
2002220164
u8 prepFlags; /* SQLITE_PREPARE_* flags */
2002320165
u8 withinRJSubrtn; /* Nesting level for RIGHT JOIN body subroutines */
20024
- u8 bHasWith; /* True if statement contains WITH */
2002520166
u8 mSubrtnSig; /* mini Bloom filter on available SubrtnSig.selId */
20167
+ u8 eTriggerOp; /* TK_UPDATE, TK_INSERT or TK_DELETE */
20168
+ u8 bReturning; /* Coding a RETURNING trigger */
20169
+ u8 eOrconf; /* Default ON CONFLICT policy for trigger steps */
20170
+ u8 disableTriggers; /* True to disable triggers */
2002620171
#if defined(SQLITE_DEBUG) || defined(SQLITE_COVERAGE_TEST)
2002720172
u8 earlyCleanup; /* OOM inside sqlite3ParserAddCleanup() */
2002820173
#endif
2002920174
#ifdef SQLITE_DEBUG
2003020175
u8 ifNotExists; /* Might be true if IF NOT EXISTS. Assert()s only */
20176
+ u8 isCreate; /* CREATE TABLE, INDEX, or VIEW (but not TRIGGER)
20177
+ ** and ALTER TABLE ADD COLUMN. */
2003120178
#endif
20179
+ bft colNamesSet :1; /* TRUE after OP_ColumnName has been issued to pVdbe */
20180
+ bft bHasWith :1; /* True if statement contains WITH */
20181
+ bft okConstFactor :1; /* OK to factor out constants */
20182
+ bft checkSchema :1; /* Causes schema cookie check after an error */
2003220183
int nRangeReg; /* Size of the temporary register block */
2003320184
int iRangeReg; /* First register in temporary register block */
2003420185
int nErr; /* Number of errors seen */
2003520186
int nTab; /* Number of previously allocated VDBE cursors */
2003620187
int nMem; /* Number of memory cells used so far */
@@ -20041,16 +20192,13 @@
2004120192
int nLabelAlloc; /* Number of slots in aLabel */
2004220193
int *aLabel; /* Space to hold the labels */
2004320194
ExprList *pConstExpr;/* Constant expressions */
2004420195
IndexedExpr *pIdxEpr;/* List of expressions used by active indexes */
2004520196
IndexedExpr *pIdxPartExpr; /* Exprs constrained by index WHERE clauses */
20046
- Token constraintName;/* Name of the constraint currently being parsed */
2004720197
yDbMask writeMask; /* Start a write transaction on these databases */
2004820198
yDbMask cookieMask; /* Bitmask of schema verified databases */
20049
- int regRowid; /* Register holding rowid of CREATE TABLE entry */
20050
- int regRoot; /* Register holding root page number for new objects */
20051
- int nMaxArg; /* Max args passed to user function by sub-program */
20199
+ int nMaxArg; /* Max args to xUpdate and xFilter vtab methods */
2005220200
int nSelect; /* Number of SELECT stmts. Counter for Select.selId */
2005320201
#ifndef SQLITE_OMIT_PROGRESS_CALLBACK
2005420202
u32 nProgressSteps; /* xProgress steps taken during sqlite3_prepare() */
2005520203
#endif
2005620204
#ifndef SQLITE_OMIT_SHARED_CACHE
@@ -20060,21 +20208,10 @@
2006020208
AutoincInfo *pAinc; /* Information about AUTOINCREMENT counters */
2006120209
Parse *pToplevel; /* Parse structure for main program (or NULL) */
2006220210
Table *pTriggerTab; /* Table triggers are being coded for */
2006320211
TriggerPrg *pTriggerPrg; /* Linked list of coded triggers */
2006420212
ParseCleanup *pCleanup; /* List of cleanup operations to run after parse */
20065
- union {
20066
- int addrCrTab; /* Address of OP_CreateBtree on CREATE TABLE */
20067
- Returning *pReturning; /* The RETURNING clause */
20068
- } u1;
20069
- u32 oldmask; /* Mask of old.* columns referenced */
20070
- u32 newmask; /* Mask of new.* columns referenced */
20071
- LogEst nQueryLoop; /* Est number of iterations of a query (10*log2(N)) */
20072
- u8 eTriggerOp; /* TK_UPDATE, TK_INSERT or TK_DELETE */
20073
- u8 bReturning; /* Coding a RETURNING trigger */
20074
- u8 eOrconf; /* Default ON CONFLICT policy for trigger steps */
20075
- u8 disableTriggers; /* True to disable triggers */
2007620213
2007720214
/**************************************************************************
2007820215
** Fields above must be initialized to zero. The fields that follow,
2007920216
** down to the beginning of the recursive section, do not need to be
2008020217
** initialized as they will be set before being used. The boundary is
@@ -20082,10 +20219,23 @@
2008220219
**************************************************************************/
2008320220
2008420221
int aTempReg[8]; /* Holding area for temporary registers */
2008520222
Parse *pOuterParse; /* Outer Parse object when nested */
2008620223
Token sNameToken; /* Token with unqualified schema object name */
20224
+ u32 oldmask; /* Mask of old.* columns referenced */
20225
+ u32 newmask; /* Mask of new.* columns referenced */
20226
+ union {
20227
+ struct { /* These fields available when isCreate is true */
20228
+ int addrCrTab; /* Address of OP_CreateBtree on CREATE TABLE */
20229
+ int regRowid; /* Register holding rowid of CREATE TABLE entry */
20230
+ int regRoot; /* Register holding root page for new objects */
20231
+ Token constraintName; /* Name of the constraint currently being parsed */
20232
+ } cr;
20233
+ struct { /* These fields available to all other statements */
20234
+ Returning *pReturning; /* The RETURNING clause */
20235
+ } d;
20236
+ } u1;
2008720237
2008820238
/************************************************************************
2008920239
** Above is constant between recursions. Below is reset before and after
2009020240
** each recursion. The boundary between these two regions is determined
2009120241
** using offsetof(Parse,sLastToken) so the sLastToken field must be the
@@ -20099,13 +20249,11 @@
2009920249
u8 eParseMode; /* PARSE_MODE_XXX constant */
2010020250
#ifndef SQLITE_OMIT_VIRTUALTABLE
2010120251
int nVtabLock; /* Number of virtual tables to lock */
2010220252
#endif
2010320253
int nHeight; /* Expression tree height of current sub-select */
20104
-#ifndef SQLITE_OMIT_EXPLAIN
2010520254
int addrExplain; /* Address of current OP_Explain opcode */
20106
-#endif
2010720255
VList *pVList; /* Mapping between variable names and numbers */
2010820256
Vdbe *pReprepare; /* VM being reprepared (sqlite3Reprepare()) */
2010920257
const char *zTail; /* All SQL text past the last semicolon parsed */
2011020258
Table *pNewTable; /* A table being constructed by CREATE TABLE */
2011120259
Index *pNewIndex; /* An index being constructed by CREATE INDEX.
@@ -23559,10 +23707,11 @@
2355923707
char *zMalloc; /* Space to hold MEM_Str or MEM_Blob if szMalloc>0 */
2356023708
void (*xDel)(void*);/* Destructor for Mem.z - only valid if MEM_Dyn */
2356123709
#ifdef SQLITE_DEBUG
2356223710
Mem *pScopyFrom; /* This Mem is a shallow copy of pScopyFrom */
2356323711
u16 mScopyFlags; /* flags value immediately after the shallow copy */
23712
+ u8 bScopy; /* The pScopyFrom of some other Mem *might* point here */
2356423713
#endif
2356523714
};
2356623715
2356723716
/*
2356823717
** Size of struct Mem not including the Mem.zMalloc member or anything that
@@ -23708,18 +23857,14 @@
2370823857
Vdbe *pVdbe; /* The VM that owns this context */
2370923858
int iOp; /* Instruction number of OP_Function */
2371023859
int isError; /* Error code returned by the function. */
2371123860
u8 enc; /* Encoding to use for results */
2371223861
u8 skipFlag; /* Skip accumulator loading if true */
23713
- u8 argc; /* Number of arguments */
23862
+ u16 argc; /* Number of arguments */
2371423863
sqlite3_value *argv[1]; /* Argument set */
2371523864
};
2371623865
23717
-/* A bitfield type for use inside of structures. Always follow with :N where
23718
-** N is the number of bits.
23719
-*/
23720
-typedef unsigned bft; /* Bit Field Type */
2372123866
2372223867
/* The ScanStatus object holds a single value for the
2372323868
** sqlite3_stmt_scanstatus() interface.
2372423869
**
2372523870
** aAddrRange[]:
@@ -23776,11 +23921,11 @@
2377623921
i64 iCurrentTime; /* Value of julianday('now') for this statement */
2377723922
i64 nFkConstraint; /* Number of imm. FK constraints this VM */
2377823923
i64 nStmtDefCons; /* Number of def. constraints when stmt started */
2377923924
i64 nStmtDefImmCons; /* Number of def. imm constraints when stmt started */
2378023925
Mem *aMem; /* The memory locations */
23781
- Mem **apArg; /* Arguments to currently executing user function */
23926
+ Mem **apArg; /* Arguments xUpdate and xFilter vtab methods */
2378223927
VdbeCursor **apCsr; /* One element of this array for each open cursor */
2378323928
Mem *aVar; /* Values for the OP_Variable opcode. */
2378423929
2378523930
/* When allocating a new Vdbe object, all of the fields below should be
2378623931
** initialized to zero or NULL */
@@ -23796,10 +23941,11 @@
2379623941
i64 startTime; /* Time when query started - used for profiling */
2379723942
#endif
2379823943
#ifdef SQLITE_DEBUG
2379923944
int rcApp; /* errcode set by sqlite3_result_error_code() */
2380023945
u32 nWrite; /* Number of write operations that have occurred */
23946
+ int napArg; /* Size of the apArg[] array */
2380123947
#endif
2380223948
u16 nResColumn; /* Number of columns in one row of the result set */
2380323949
u16 nResAlloc; /* Column slots allocated to aColName[] */
2380423950
u8 errorAction; /* Recovery action to do in case of an error */
2380523951
u8 minWriteFileFormat; /* Minimum file format for writable database files */
@@ -24657,10 +24803,13 @@
2465724803
ms = ms*10.0 + *zDate - '0';
2465824804
rScale *= 10.0;
2465924805
zDate++;
2466024806
}
2466124807
ms /= rScale;
24808
+ /* Truncate to avoid problems with sub-milliseconds
24809
+ ** rounding. https://sqlite.org/forum/forumpost/766a2c9231 */
24810
+ if( ms>0.999 ) ms = 0.999;
2466224811
}
2466324812
}else{
2466424813
s = 0;
2466524814
}
2466624815
p->validJD = 0;
@@ -25864,11 +26013,11 @@
2586426013
sqlite3_str_appendf(&sRes, cf=='d' ? "%02d" : "%2d", x.D);
2586526014
break;
2586626015
}
2586726016
case 'f': { /* Fractional seconds. (Non-standard) */
2586826017
double s = x.s;
25869
- if( s>59.999 ) s = 59.999;
26018
+ if( NEVER(s>59.999) ) s = 59.999;
2587026019
sqlite3_str_appendf(&sRes, "%06.3f", s);
2587126020
break;
2587226021
}
2587326022
case 'F': {
2587426023
sqlite3_str_appendf(&sRes, "%04d-%02d-%02d", x.Y, x.M, x.D);
@@ -32424,11 +32573,11 @@
3242432573
** pointer if any kind of error was encountered.
3242532574
*/
3242632575
static SQLITE_NOINLINE char *strAccumFinishRealloc(StrAccum *p){
3242732576
char *zText;
3242832577
assert( p->mxAlloc>0 && !isMalloced(p) );
32429
- zText = sqlite3DbMallocRaw(p->db, p->nChar+1 );
32578
+ zText = sqlite3DbMallocRaw(p->db, 1+(u64)p->nChar );
3243032579
if( zText ){
3243132580
memcpy(zText, p->zText, p->nChar+1);
3243232581
p->printfFlags |= SQLITE_PRINTF_MALLOCED;
3243332582
}else{
3243432583
sqlite3StrAccumSetError(p, SQLITE_NOMEM);
@@ -33032,11 +33181,14 @@
3303233181
}
3303333182
if( pItem->fg.fromDDL ){
3303433183
sqlite3_str_appendf(&x, " DDL");
3303533184
}
3303633185
if( pItem->fg.isCte ){
33037
- sqlite3_str_appendf(&x, " CteUse=0x%p", pItem->u2.pCteUse);
33186
+ static const char *aMat[] = {",MAT", "", ",NO-MAT"};
33187
+ sqlite3_str_appendf(&x, " CteUse=%d%s",
33188
+ pItem->u2.pCteUse->nUse,
33189
+ aMat[pItem->u2.pCteUse->eM10d]);
3303833190
}
3303933191
if( pItem->fg.isOn || (pItem->fg.isUsing==0 && pItem->u3.pOn!=0) ){
3304033192
sqlite3_str_appendf(&x, " isOn");
3304133193
}
3304233194
if( pItem->fg.isTabFunc ) sqlite3_str_appendf(&x, " isTabFunc");
@@ -33063,13 +33215,10 @@
3306333215
if( pItem->pSTab ){
3306433216
Table *pTab = pItem->pSTab;
3306533217
sqlite3TreeViewColumnList(pView, pTab->aCol, pTab->nCol, 1);
3306633218
}
3306733219
assert( (int)pItem->fg.isNestedFrom == IsNestedFrom(pItem) );
33068
- sqlite3TreeViewPush(&pView, 0);
33069
- sqlite3TreeViewLine(pView, "SUBQUERY");
33070
- sqlite3TreeViewPop(&pView);
3307133220
sqlite3TreeViewSelect(pView, pItem->u4.pSubq->pSelect, 0);
3307233221
}
3307333222
if( pItem->fg.isTabFunc ){
3307433223
sqlite3TreeViewExprList(pView, pItem->u1.pFuncArg, 0, "func-args:");
3307533224
}
@@ -33795,25 +33944,11 @@
3379533944
char *zName = pList->a[i].zName;
3379633945
int moreToFollow = i<pList->nId - 1;
3379733946
if( zName==0 ) zName = "(null)";
3379833947
sqlite3TreeViewPush(&pView, moreToFollow);
3379933948
sqlite3TreeViewLine(pView, 0);
33800
- if( pList->eU4==EU4_NONE ){
33801
- fprintf(stdout, "%s\n", zName);
33802
- }else if( pList->eU4==EU4_IDX ){
33803
- fprintf(stdout, "%s (%d)\n", zName, pList->a[i].u4.idx);
33804
- }else{
33805
- assert( pList->eU4==EU4_EXPR );
33806
- if( pList->a[i].u4.pExpr==0 ){
33807
- fprintf(stdout, "%s (pExpr=NULL)\n", zName);
33808
- }else{
33809
- fprintf(stdout, "%s\n", zName);
33810
- sqlite3TreeViewPush(&pView, i<pList->nId-1);
33811
- sqlite3TreeViewExpr(pView, pList->a[i].u4.pExpr, 0);
33812
- sqlite3TreeViewPop(&pView);
33813
- }
33814
- }
33949
+ fprintf(stdout, "%s\n", zName);
3381533950
sqlite3TreeViewPop(&pView);
3381633951
}
3381733952
}
3381833953
}
3381933954
SQLITE_PRIVATE void sqlite3TreeViewIdList(
@@ -36290,11 +36425,15 @@
3629036425
}
3629136426
}
3629236427
}
3629336428
p->z = &p->zBuf[i+1];
3629436429
assert( i+p->n < sizeof(p->zBuf) );
36295
- while( ALWAYS(p->n>0) && p->z[p->n-1]=='0' ){ p->n--; }
36430
+ assert( p->n>0 );
36431
+ while( p->z[p->n-1]=='0' ){
36432
+ p->n--;
36433
+ assert( p->n>0 );
36434
+ }
3629636435
}
3629736436
3629836437
/*
3629936438
** Try to convert z into an unsigned 32-bit integer. Return true on
3630036439
** success and false if there is an error.
@@ -37076,16 +37215,23 @@
3707637215
/*
3707737216
** The hashing function.
3707837217
*/
3707937218
static unsigned int strHash(const char *z){
3708037219
unsigned int h = 0;
37081
- unsigned char c;
37082
- while( (c = (unsigned char)*z++)!=0 ){ /*OPTIMIZATION-IF-TRUE*/
37220
+ while( z[0] ){ /*OPTIMIZATION-IF-TRUE*/
3708337221
/* Knuth multiplicative hashing. (Sorting & Searching, p. 510).
3708437222
** 0x9e3779b1 is 2654435761 which is the closest prime number to
37085
- ** (2**32)*golden_ratio, where golden_ratio = (sqrt(5) - 1)/2. */
37086
- h += sqlite3UpperToLower[c];
37223
+ ** (2**32)*golden_ratio, where golden_ratio = (sqrt(5) - 1)/2.
37224
+ **
37225
+ ** Only bits 0xdf for ASCII and bits 0xbf for EBCDIC each octet are
37226
+ ** hashed since the omitted bits determine the upper/lower case difference.
37227
+ */
37228
+#ifdef SQLITE_EBCDIC
37229
+ h += 0xbf & (unsigned char)*(z++);
37230
+#else
37231
+ h += 0xdf & (unsigned char)*(z++);
37232
+#endif
3708737233
h *= 0x9e3779b1;
3708837234
}
3708937235
return h;
3709037236
}
3709137237
@@ -37154,13 +37300,12 @@
3715437300
sqlite3_free(pH->ht);
3715537301
pH->ht = new_ht;
3715637302
pH->htsize = new_size = sqlite3MallocSize(new_ht)/sizeof(struct _ht);
3715737303
memset(new_ht, 0, new_size*sizeof(struct _ht));
3715837304
for(elem=pH->first, pH->first=0; elem; elem = next_elem){
37159
- unsigned int h = strHash(elem->pKey) % new_size;
3716037305
next_elem = elem->next;
37161
- insertElement(pH, &new_ht[h], elem);
37306
+ insertElement(pH, &new_ht[elem->h % new_size], elem);
3716237307
}
3716337308
return 1;
3716437309
}
3716537310
3716637311
/* This function (for internal use only) locates an element in an
@@ -37174,27 +37319,26 @@
3717437319
unsigned int *pHash /* Write the hash value here */
3717537320
){
3717637321
HashElem *elem; /* Used to loop thru the element list */
3717737322
unsigned int count; /* Number of elements left to test */
3717837323
unsigned int h; /* The computed hash */
37179
- static HashElem nullElement = { 0, 0, 0, 0 };
37324
+ static HashElem nullElement = { 0, 0, 0, 0, 0 };
3718037325
37326
+ h = strHash(pKey);
3718137327
if( pH->ht ){ /*OPTIMIZATION-IF-TRUE*/
3718237328
struct _ht *pEntry;
37183
- h = strHash(pKey) % pH->htsize;
37184
- pEntry = &pH->ht[h];
37329
+ pEntry = &pH->ht[h % pH->htsize];
3718537330
elem = pEntry->chain;
3718637331
count = pEntry->count;
3718737332
}else{
37188
- h = 0;
3718937333
elem = pH->first;
3719037334
count = pH->count;
3719137335
}
3719237336
if( pHash ) *pHash = h;
3719337337
while( count ){
3719437338
assert( elem!=0 );
37195
- if( sqlite3StrICmp(elem->pKey,pKey)==0 ){
37339
+ if( h==elem->h && sqlite3StrICmp(elem->pKey,pKey)==0 ){
3719637340
return elem;
3719737341
}
3719837342
elem = elem->next;
3719937343
count--;
3720037344
}
@@ -37202,14 +37346,13 @@
3720237346
}
3720337347
3720437348
/* Remove a single entry from the hash table given a pointer to that
3720537349
** element and a hash on the element's key.
3720637350
*/
37207
-static void removeElementGivenHash(
37351
+static void removeElement(
3720837352
Hash *pH, /* The pH containing "elem" */
37209
- HashElem* elem, /* The element to be removed from the pH */
37210
- unsigned int h /* Hash value for the element */
37353
+ HashElem *elem /* The element to be removed from the pH */
3721137354
){
3721237355
struct _ht *pEntry;
3721337356
if( elem->prev ){
3721437357
elem->prev->next = elem->next;
3721537358
}else{
@@ -37217,11 +37360,11 @@
3721737360
}
3721837361
if( elem->next ){
3721937362
elem->next->prev = elem->prev;
3722037363
}
3722137364
if( pH->ht ){
37222
- pEntry = &pH->ht[h];
37365
+ pEntry = &pH->ht[elem->h % pH->htsize];
3722337366
if( pEntry->chain==elem ){
3722437367
pEntry->chain = elem->next;
3722537368
}
3722637369
assert( pEntry->count>0 );
3722737370
pEntry->count--;
@@ -37268,11 +37411,11 @@
3726837411
assert( pKey!=0 );
3726937412
elem = findElementWithHash(pH,pKey,&h);
3727037413
if( elem->data ){
3727137414
void *old_data = elem->data;
3727237415
if( data==0 ){
37273
- removeElementGivenHash(pH,elem,h);
37416
+ removeElement(pH,elem);
3727437417
}else{
3727537418
elem->data = data;
3727637419
elem->pKey = pKey;
3727737420
}
3727837421
return old_data;
@@ -37279,19 +37422,17 @@
3727937422
}
3728037423
if( data==0 ) return 0;
3728137424
new_elem = (HashElem*)sqlite3Malloc( sizeof(HashElem) );
3728237425
if( new_elem==0 ) return data;
3728337426
new_elem->pKey = pKey;
37427
+ new_elem->h = h;
3728437428
new_elem->data = data;
3728537429
pH->count++;
37286
- if( pH->count>=10 && pH->count > 2*pH->htsize ){
37287
- if( rehash(pH, pH->count*2) ){
37288
- assert( pH->htsize>0 );
37289
- h = strHash(pKey) % pH->htsize;
37290
- }
37430
+ if( pH->count>=5 && pH->count > 2*pH->htsize ){
37431
+ rehash(pH, pH->count*3);
3729137432
}
37292
- insertElement(pH, pH->ht ? &pH->ht[h] : 0, new_elem);
37433
+ insertElement(pH, pH->ht ? &pH->ht[new_elem->h % pH->htsize] : 0, new_elem);
3729337434
return 0;
3729437435
}
3729537436
3729637437
/************** End of hash.c ************************************************/
3729737438
/************** Begin file opcodes.c *****************************************/
@@ -40150,11 +40291,11 @@
4015040291
assert( pInode!=0 );
4015140292
assert( sqlite3_mutex_held(pInode->pLockMutex) );
4015240293
if( (pFile->ctrlFlags & (UNIXFILE_EXCL|UNIXFILE_RDONLY))==UNIXFILE_EXCL ){
4015340294
if( pInode->bProcessLock==0 ){
4015440295
struct flock lock;
40155
- assert( pInode->nLock==0 );
40296
+ /* assert( pInode->nLock==0 ); <-- Not true if unix-excl READONLY used */
4015640297
lock.l_whence = SEEK_SET;
4015740298
lock.l_start = SHARED_FIRST;
4015840299
lock.l_len = SHARED_SIZE;
4015940300
lock.l_type = F_WRLCK;
4016040301
rc = osSetPosixAdvisoryLock(pFile->h, &lock, pFile);
@@ -50698,11 +50839,11 @@
5069850839
** allocate space for a new winShmNode and filename.
5069950840
*/
5070050841
p = sqlite3MallocZero( sizeof(*p) );
5070150842
if( p==0 ) return SQLITE_IOERR_NOMEM_BKPT;
5070250843
nName = sqlite3Strlen30(pDbFd->zPath);
50703
- pNew = sqlite3MallocZero( sizeof(*pShmNode) + nName + 17 );
50844
+ pNew = sqlite3MallocZero( sizeof(*pShmNode) + (i64)nName + 17 );
5070450845
if( pNew==0 ){
5070550846
sqlite3_free(p);
5070650847
return SQLITE_IOERR_NOMEM_BKPT;
5070750848
}
5070850849
pNew->zFilename = (char*)&pNew[1];
@@ -51519,11 +51660,11 @@
5151951660
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
5152051661
"0123456789";
5152151662
size_t i, j;
5152251663
DWORD pid;
5152351664
int nPre = sqlite3Strlen30(SQLITE_TEMP_FILE_PREFIX);
51524
- int nMax, nBuf, nDir, nLen;
51665
+ i64 nMax, nBuf, nDir, nLen;
5152551666
char *zBuf;
5152651667
5152751668
/* It's odd to simulate an io-error here, but really this is just
5152851669
** using the io-error infrastructure to test that SQLite handles this
5152951670
** function failing.
@@ -51531,11 +51672,12 @@
5153151672
SimulateIOError( return SQLITE_IOERR );
5153251673
5153351674
/* Allocate a temporary buffer to store the fully qualified file
5153451675
** name for the temporary file. If this fails, we cannot continue.
5153551676
*/
51536
- nMax = pVfs->mxPathname; nBuf = nMax + 2;
51677
+ nMax = pVfs->mxPathname;
51678
+ nBuf = 2 + (i64)nMax;
5153751679
zBuf = sqlite3MallocZero( nBuf );
5153851680
if( !zBuf ){
5153951681
OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
5154051682
return SQLITE_IOERR_NOMEM_BKPT;
5154151683
}
@@ -52390,11 +52532,11 @@
5239052532
** NOTE: We are dealing with a relative path name and the data
5239152533
** directory has been set. Therefore, use it as the basis
5239252534
** for converting the relative path name to an absolute
5239352535
** one by prepending the data directory and a slash.
5239452536
*/
52395
- char *zOut = sqlite3MallocZero( pVfs->mxPathname+1 );
52537
+ char *zOut = sqlite3MallocZero( 1+(u64)pVfs->mxPathname );
5239652538
if( !zOut ){
5239752539
return SQLITE_IOERR_NOMEM_BKPT;
5239852540
}
5239952541
if( cygwin_conv_path(
5240052542
(osIsNT() ? CCP_POSIX_TO_WIN_W : CCP_POSIX_TO_WIN_A) |
@@ -52485,17 +52627,16 @@
5248552627
if( nByte==0 ){
5248652628
sqlite3_free(zConverted);
5248752629
return winLogError(SQLITE_CANTOPEN_FULLPATH, osGetLastError(),
5248852630
"winFullPathname1", zRelative);
5248952631
}
52490
- nByte += 3;
52491
- zTemp = sqlite3MallocZero( nByte*sizeof(zTemp[0]) );
52632
+ zTemp = sqlite3MallocZero( nByte*sizeof(zTemp[0]) + 3*sizeof(zTemp[0]) );
5249252633
if( zTemp==0 ){
5249352634
sqlite3_free(zConverted);
5249452635
return SQLITE_IOERR_NOMEM_BKPT;
5249552636
}
52496
- nByte = osGetFullPathNameW((LPCWSTR)zConverted, nByte, zTemp, 0);
52637
+ nByte = osGetFullPathNameW((LPCWSTR)zConverted, nByte+3, zTemp, 0);
5249752638
if( nByte==0 ){
5249852639
sqlite3_free(zConverted);
5249952640
sqlite3_free(zTemp);
5250052641
return winLogError(SQLITE_CANTOPEN_FULLPATH, osGetLastError(),
5250152642
"winFullPathname2", zRelative);
@@ -52511,17 +52652,16 @@
5251152652
if( nByte==0 ){
5251252653
sqlite3_free(zConverted);
5251352654
return winLogError(SQLITE_CANTOPEN_FULLPATH, osGetLastError(),
5251452655
"winFullPathname3", zRelative);
5251552656
}
52516
- nByte += 3;
52517
- zTemp = sqlite3MallocZero( nByte*sizeof(zTemp[0]) );
52657
+ zTemp = sqlite3MallocZero( nByte*sizeof(zTemp[0]) + 3*sizeof(zTemp[0]) );
5251852658
if( zTemp==0 ){
5251952659
sqlite3_free(zConverted);
5252052660
return SQLITE_IOERR_NOMEM_BKPT;
5252152661
}
52522
- nByte = osGetFullPathNameA((char*)zConverted, nByte, zTemp, 0);
52662
+ nByte = osGetFullPathNameA((char*)zConverted, nByte+3, zTemp, 0);
5252352663
if( nByte==0 ){
5252452664
sqlite3_free(zConverted);
5252552665
sqlite3_free(zTemp);
5252652666
return winLogError(SQLITE_CANTOPEN_FULLPATH, osGetLastError(),
5252752667
"winFullPathname4", zRelative);
@@ -53546,17 +53686,17 @@
5354653686
break;
5354753687
}
5354853688
}
5354953689
if( p==0 ){
5355053690
MemStore **apNew;
53551
- p = sqlite3Malloc( sizeof(*p) + szName + 3 );
53691
+ p = sqlite3Malloc( sizeof(*p) + (i64)szName + 3 );
5355253692
if( p==0 ){
5355353693
sqlite3_mutex_leave(pVfsMutex);
5355453694
return SQLITE_NOMEM;
5355553695
}
5355653696
apNew = sqlite3Realloc(memdb_g.apMemStore,
53557
- sizeof(apNew[0])*(memdb_g.nMemStore+1) );
53697
+ sizeof(apNew[0])*(1+(i64)memdb_g.nMemStore) );
5355853698
if( apNew==0 ){
5355953699
sqlite3_free(p);
5356053700
sqlite3_mutex_leave(pVfsMutex);
5356153701
return SQLITE_NOMEM;
5356253702
}
@@ -54262,11 +54402,11 @@
5426254402
void *pTmpSpace;
5426354403
5426454404
/* Allocate the Bitvec to be tested and a linear array of
5426554405
** bits to act as the reference */
5426654406
pBitvec = sqlite3BitvecCreate( sz );
54267
- pV = sqlite3MallocZero( (sz+7)/8 + 1 );
54407
+ pV = sqlite3MallocZero( (7+(i64)sz)/8 + 1 );
5426854408
pTmpSpace = sqlite3_malloc64(BITVEC_SZ);
5426954409
if( pBitvec==0 || pV==0 || pTmpSpace==0 ) goto bitvec_end;
5427054410
5427154411
/* NULL pBitvec tests */
5427254412
sqlite3BitvecSet(0, 1);
@@ -55809,16 +55949,16 @@
5580955949
**
5581055950
** The PCache mutex must be held when this function is called.
5581155951
*/
5581255952
static void pcache1ResizeHash(PCache1 *p){
5581355953
PgHdr1 **apNew;
55814
- unsigned int nNew;
55815
- unsigned int i;
55954
+ u64 nNew;
55955
+ u32 i;
5581655956
5581755957
assert( sqlite3_mutex_held(p->pGroup->mutex) );
5581855958
55819
- nNew = p->nHash*2;
55959
+ nNew = 2*(u64)p->nHash;
5582055960
if( nNew<256 ){
5582155961
nNew = 256;
5582255962
}
5582355963
5582455964
pcache1LeaveMutex(p->pGroup);
@@ -56037,11 +56177,11 @@
5603756177
** Allocate a new cache.
5603856178
*/
5603956179
static sqlite3_pcache *pcache1Create(int szPage, int szExtra, int bPurgeable){
5604056180
PCache1 *pCache; /* The newly created page cache */
5604156181
PGroup *pGroup; /* The group the new page cache will belong to */
56042
- int sz; /* Bytes of memory required to allocate the new cache */
56182
+ i64 sz; /* Bytes of memory required to allocate the new cache */
5604356183
5604456184
assert( (szPage & (szPage-1))==0 && szPage>=512 && szPage<=65536 );
5604556185
assert( szExtra < 300 );
5604656186
5604756187
sz = sizeof(PCache1) + sizeof(PGroup)*pcache1.separateCache;
@@ -58014,24 +58154,10 @@
5801458154
# define USEFETCH(x) ((x)->bUseFetch)
5801558155
#else
5801658156
# define USEFETCH(x) 0
5801758157
#endif
5801858158
58019
-/*
58020
-** The argument to this macro is a file descriptor (type sqlite3_file*).
58021
-** Return 0 if it is not open, or non-zero (but not 1) if it is.
58022
-**
58023
-** This is so that expressions can be written as:
58024
-**
58025
-** if( isOpen(pPager->jfd) ){ ...
58026
-**
58027
-** instead of
58028
-**
58029
-** if( pPager->jfd->pMethods ){ ...
58030
-*/
58031
-#define isOpen(pFd) ((pFd)->pMethods!=0)
58032
-
5803358159
#ifdef SQLITE_DIRECT_OVERFLOW_READ
5803458160
/*
5803558161
** Return true if page pgno can be read directly from the database file
5803658162
** by the b-tree layer. This is the case if:
5803758163
**
@@ -58047,11 +58173,11 @@
5804758173
if( sqlite3PCacheIsDirty(pPager->pPCache) ) return 0; /* Failed (3) */
5804858174
#ifndef SQLITE_OMIT_WAL
5804958175
if( pPager->pWal ){
5805058176
u32 iRead = 0;
5805158177
(void)sqlite3WalFindFrame(pPager->pWal, pgno, &iRead);
58052
- return iRead==0; /* Condition (4) */
58178
+ if( iRead ) return 0; /* Case (4) */
5805358179
}
5805458180
#endif
5805558181
assert( pPager->fd->pMethods->xDeviceCharacteristics!=0 );
5805658182
if( (pPager->fd->pMethods->xDeviceCharacteristics(pPager->fd)
5805758183
& SQLITE_IOCAP_SUBPAGE_READ)==0 ){
@@ -58530,11 +58656,11 @@
5853058656
** zSuper[0] is set to 0 and SQLITE_OK returned.
5853158657
**
5853258658
** If an error occurs while reading from the journal file, an SQLite
5853358659
** error code is returned.
5853458660
*/
58535
-static int readSuperJournal(sqlite3_file *pJrnl, char *zSuper, u32 nSuper){
58661
+static int readSuperJournal(sqlite3_file *pJrnl, char *zSuper, u64 nSuper){
5853658662
int rc; /* Return code */
5853758663
u32 len; /* Length in bytes of super-journal name */
5853858664
i64 szJ; /* Total size in bytes of journal file pJrnl */
5853958665
u32 cksum; /* MJ checksum value read from journal */
5854058666
u32 u; /* Unsigned loop counter */
@@ -59313,11 +59439,11 @@
5931359439
rc = sqlite3OsSync(pPager->jfd, pPager->syncFlags);
5931459440
}
5931559441
}
5931659442
pPager->journalOff = 0;
5931759443
}else if( pPager->journalMode==PAGER_JOURNALMODE_PERSIST
59318
- || (pPager->exclusiveMode && pPager->journalMode!=PAGER_JOURNALMODE_WAL)
59444
+ || (pPager->exclusiveMode && pPager->journalMode<PAGER_JOURNALMODE_WAL)
5931959445
){
5932059446
rc = zeroJournalHdr(pPager, hasSuper||pPager->tempFile);
5932159447
pPager->journalOff = 0;
5932259448
}else{
5932359449
/* This branch may be executed with Pager.journalMode==MEMORY if
@@ -59766,16 +59892,16 @@
5976659892
char *zSuperJournal = 0; /* Contents of super-journal file */
5976759893
i64 nSuperJournal; /* Size of super-journal file */
5976859894
char *zJournal; /* Pointer to one journal within MJ file */
5976959895
char *zSuperPtr; /* Space to hold super-journal filename */
5977059896
char *zFree = 0; /* Free this buffer */
59771
- int nSuperPtr; /* Amount of space allocated to zSuperPtr[] */
59897
+ i64 nSuperPtr; /* Amount of space allocated to zSuperPtr[] */
5977259898
5977359899
/* Allocate space for both the pJournal and pSuper file descriptors.
5977459900
** If successful, open the super-journal file for reading.
5977559901
*/
59776
- pSuper = (sqlite3_file *)sqlite3MallocZero(pVfs->szOsFile * 2);
59902
+ pSuper = (sqlite3_file *)sqlite3MallocZero(2 * (i64)pVfs->szOsFile);
5977759903
if( !pSuper ){
5977859904
rc = SQLITE_NOMEM_BKPT;
5977959905
pJournal = 0;
5978059906
}else{
5978159907
const int flags = (SQLITE_OPEN_READONLY|SQLITE_OPEN_SUPER_JOURNAL);
@@ -59789,15 +59915,18 @@
5978959915
** sufficient space (in zSuperPtr) to hold the names of super-journal
5979059916
** files extracted from regular rollback-journals.
5979159917
*/
5979259918
rc = sqlite3OsFileSize(pSuper, &nSuperJournal);
5979359919
if( rc!=SQLITE_OK ) goto delsuper_out;
59794
- nSuperPtr = pVfs->mxPathname+1;
59920
+ nSuperPtr = 1 + (i64)pVfs->mxPathname;
59921
+ assert( nSuperJournal>=0 && nSuperPtr>0 );
5979559922
zFree = sqlite3Malloc(4 + nSuperJournal + nSuperPtr + 2);
5979659923
if( !zFree ){
5979759924
rc = SQLITE_NOMEM_BKPT;
5979859925
goto delsuper_out;
59926
+ }else{
59927
+ assert( nSuperJournal<=0x7fffffff );
5979959928
}
5980059929
zFree[0] = zFree[1] = zFree[2] = zFree[3] = 0;
5980159930
zSuperJournal = &zFree[4];
5980259931
zSuperPtr = &zSuperJournal[nSuperJournal+2];
5980359932
rc = sqlite3OsRead(pSuper, zSuperJournal, (int)nSuperJournal, 0);
@@ -60054,11 +60183,11 @@
6005460183
** (pPager->pageSize >= pPager->pVfs->mxPathname+1). Using os_unix.c,
6005560184
** mxPathname is 512, which is the same as the minimum allowable value
6005660185
** for pageSize.
6005760186
*/
6005860187
zSuper = pPager->pTmpSpace;
60059
- rc = readSuperJournal(pPager->jfd, zSuper, pPager->pVfs->mxPathname+1);
60188
+ rc = readSuperJournal(pPager->jfd, zSuper, 1+(i64)pPager->pVfs->mxPathname);
6006060189
if( rc==SQLITE_OK && zSuper[0] ){
6006160190
rc = sqlite3OsAccess(pVfs, zSuper, SQLITE_ACCESS_EXISTS, &res);
6006260191
}
6006360192
zSuper = 0;
6006460193
if( rc!=SQLITE_OK || !res ){
@@ -60193,11 +60322,11 @@
6019360322
/* Leave 4 bytes of space before the super-journal filename in memory.
6019460323
** This is because it may end up being passed to sqlite3OsOpen(), in
6019560324
** which case it requires 4 0x00 bytes in memory immediately before
6019660325
** the filename. */
6019760326
zSuper = &pPager->pTmpSpace[4];
60198
- rc = readSuperJournal(pPager->jfd, zSuper, pPager->pVfs->mxPathname+1);
60327
+ rc = readSuperJournal(pPager->jfd, zSuper, 1+(i64)pPager->pVfs->mxPathname);
6019960328
testcase( rc!=SQLITE_OK );
6020060329
}
6020160330
if( rc==SQLITE_OK
6020260331
&& (pPager->eState>=PAGER_WRITER_DBMOD || pPager->eState==PAGER_OPEN)
6020360332
){
@@ -61963,10 +62092,11 @@
6196362092
int useJournal = (flags & PAGER_OMIT_JOURNAL)==0; /* False to omit journal */
6196462093
int pcacheSize = sqlite3PcacheSize(); /* Bytes to allocate for PCache */
6196562094
u32 szPageDflt = SQLITE_DEFAULT_PAGE_SIZE; /* Default page size */
6196662095
const char *zUri = 0; /* URI args to copy */
6196762096
int nUriByte = 1; /* Number of bytes of URI args at *zUri */
62097
+
6196862098
6196962099
/* Figure out how much space is required for each journal file-handle
6197062100
** (there are two of them, the main journal and the sub-journal). */
6197162101
journalFileSize = ROUND8(sqlite3JournalSize(pVfs));
6197262102
@@ -61989,12 +62119,12 @@
6198962119
** to by zPathname, length nPathname. Or, if this is a temporary file,
6199062120
** leave both nPathname and zPathname set to 0.
6199162121
*/
6199262122
if( zFilename && zFilename[0] ){
6199362123
const char *z;
61994
- nPathname = pVfs->mxPathname+1;
61995
- zPathname = sqlite3DbMallocRaw(0, nPathname*2);
62124
+ nPathname = pVfs->mxPathname + 1;
62125
+ zPathname = sqlite3DbMallocRaw(0, 2*(i64)nPathname);
6199662126
if( zPathname==0 ){
6199762127
return SQLITE_NOMEM_BKPT;
6199862128
}
6199962129
zPathname[0] = 0; /* Make sure initialized even if FullPathname() fails */
6200062130
rc = sqlite3OsFullPathname(pVfs, zFilename, nPathname, zPathname);
@@ -62077,18 +62207,18 @@
6207762207
assert( SQLITE_PTRSIZE==sizeof(Pager*) );
6207862208
pPtr = (u8 *)sqlite3MallocZero(
6207962209
ROUND8(sizeof(*pPager)) + /* Pager structure */
6208062210
ROUND8(pcacheSize) + /* PCache object */
6208162211
ROUND8(pVfs->szOsFile) + /* The main db file */
62082
- journalFileSize * 2 + /* The two journal files */
62212
+ (u64)journalFileSize * 2 + /* The two journal files */
6208362213
SQLITE_PTRSIZE + /* Space to hold a pointer */
6208462214
4 + /* Database prefix */
62085
- nPathname + 1 + /* database filename */
62086
- nUriByte + /* query parameters */
62087
- nPathname + 8 + 1 + /* Journal filename */
62215
+ (u64)nPathname + 1 + /* database filename */
62216
+ (u64)nUriByte + /* query parameters */
62217
+ (u64)nPathname + 8 + 1 + /* Journal filename */
6208862218
#ifndef SQLITE_OMIT_WAL
62089
- nPathname + 4 + 1 + /* WAL filename */
62219
+ (u64)nPathname + 4 + 1 + /* WAL filename */
6209062220
#endif
6209162221
3 /* Terminator */
6209262222
);
6209362223
assert( EIGHT_BYTE_ALIGNMENT(SQLITE_INT_TO_PTR(journalFileSize)) );
6209462224
if( !pPtr ){
@@ -65790,11 +65920,11 @@
6579065920
){
6579165921
int rc = SQLITE_OK;
6579265922
6579365923
/* Enlarge the pWal->apWiData[] array if required */
6579465924
if( pWal->nWiData<=iPage ){
65795
- sqlite3_int64 nByte = sizeof(u32*)*(iPage+1);
65925
+ sqlite3_int64 nByte = sizeof(u32*)*(1+(i64)iPage);
6579665926
volatile u32 **apNew;
6579765927
apNew = (volatile u32 **)sqlite3Realloc((void *)pWal->apWiData, nByte);
6579865928
if( !apNew ){
6579965929
*ppPage = 0;
6580065930
return SQLITE_NOMEM_BKPT;
@@ -68023,15 +68153,11 @@
6802368153
** so it takes care to hold an exclusive lock on the corresponding
6802468154
** WAL_READ_LOCK() while changing values.
6802568155
*/
6802668156
static int walTryBeginRead(Wal *pWal, int *pChanged, int useWal, int *pCnt){
6802768157
volatile WalCkptInfo *pInfo; /* Checkpoint information in wal-index */
68028
- u32 mxReadMark; /* Largest aReadMark[] value */
68029
- int mxI; /* Index of largest aReadMark[] value */
68030
- int i; /* Loop counter */
6803168158
int rc = SQLITE_OK; /* Return code */
68032
- u32 mxFrame; /* Wal frame to lock to */
6803368159
#ifdef SQLITE_ENABLE_SETLK_TIMEOUT
6803468160
int nBlockTmout = 0;
6803568161
#endif
6803668162
6803768163
assert( pWal->readLock<0 ); /* Not currently locked */
@@ -68133,145 +68259,151 @@
6813368259
6813468260
assert( pWal->nWiData>0 );
6813568261
assert( pWal->apWiData[0]!=0 );
6813668262
pInfo = walCkptInfo(pWal);
6813768263
SEH_INJECT_FAULT;
68138
- if( !useWal && AtomicLoad(&pInfo->nBackfill)==pWal->hdr.mxFrame
68139
-#ifdef SQLITE_ENABLE_SNAPSHOT
68140
- && ((pWal->bGetSnapshot==0 && pWal->pSnapshot==0) || pWal->hdr.mxFrame==0)
68141
-#endif
68142
- ){
68143
- /* The WAL has been completely backfilled (or it is empty).
68144
- ** and can be safely ignored.
68145
- */
68146
- rc = walLockShared(pWal, WAL_READ_LOCK(0));
68147
- walShmBarrier(pWal);
68148
- if( rc==SQLITE_OK ){
68149
- if( memcmp((void *)walIndexHdr(pWal), &pWal->hdr, sizeof(WalIndexHdr)) ){
68150
- /* It is not safe to allow the reader to continue here if frames
68151
- ** may have been appended to the log before READ_LOCK(0) was obtained.
68152
- ** When holding READ_LOCK(0), the reader ignores the entire log file,
68153
- ** which implies that the database file contains a trustworthy
68154
- ** snapshot. Since holding READ_LOCK(0) prevents a checkpoint from
68155
- ** happening, this is usually correct.
68156
- **
68157
- ** However, if frames have been appended to the log (or if the log
68158
- ** is wrapped and written for that matter) before the READ_LOCK(0)
68159
- ** is obtained, that is not necessarily true. A checkpointer may
68160
- ** have started to backfill the appended frames but crashed before
68161
- ** it finished. Leaving a corrupt image in the database file.
68162
- */
68163
- walUnlockShared(pWal, WAL_READ_LOCK(0));
68164
- return WAL_RETRY;
68165
- }
68166
- pWal->readLock = 0;
68167
- return SQLITE_OK;
68168
- }else if( rc!=SQLITE_BUSY ){
68169
- return rc;
68170
- }
68171
- }
68172
-
68173
- /* If we get this far, it means that the reader will want to use
68174
- ** the WAL to get at content from recent commits. The job now is
68175
- ** to select one of the aReadMark[] entries that is closest to
68176
- ** but not exceeding pWal->hdr.mxFrame and lock that entry.
68177
- */
68178
- mxReadMark = 0;
68179
- mxI = 0;
68180
- mxFrame = pWal->hdr.mxFrame;
68181
-#ifdef SQLITE_ENABLE_SNAPSHOT
68182
- if( pWal->pSnapshot && pWal->pSnapshot->mxFrame<mxFrame ){
68183
- mxFrame = pWal->pSnapshot->mxFrame;
68184
- }
68185
-#endif
68186
- for(i=1; i<WAL_NREADER; i++){
68187
- u32 thisMark = AtomicLoad(pInfo->aReadMark+i); SEH_INJECT_FAULT;
68188
- if( mxReadMark<=thisMark && thisMark<=mxFrame ){
68189
- assert( thisMark!=READMARK_NOT_USED );
68190
- mxReadMark = thisMark;
68191
- mxI = i;
68192
- }
68193
- }
68194
- if( (pWal->readOnly & WAL_SHM_RDONLY)==0
68195
- && (mxReadMark<mxFrame || mxI==0)
68196
- ){
68197
- for(i=1; i<WAL_NREADER; i++){
68198
- rc = walLockExclusive(pWal, WAL_READ_LOCK(i), 1);
68199
- if( rc==SQLITE_OK ){
68200
- AtomicStore(pInfo->aReadMark+i,mxFrame);
68201
- mxReadMark = mxFrame;
68202
- mxI = i;
68203
- walUnlockExclusive(pWal, WAL_READ_LOCK(i), 1);
68204
- break;
68205
- }else if( rc!=SQLITE_BUSY ){
68206
- return rc;
68207
- }
68208
- }
68209
- }
68210
- if( mxI==0 ){
68211
- assert( rc==SQLITE_BUSY || (pWal->readOnly & WAL_SHM_RDONLY)!=0 );
68212
- return rc==SQLITE_BUSY ? WAL_RETRY : SQLITE_READONLY_CANTINIT;
68213
- }
68214
-
68215
- (void)walEnableBlockingMs(pWal, nBlockTmout);
68216
- rc = walLockShared(pWal, WAL_READ_LOCK(mxI));
68217
- walDisableBlocking(pWal);
68218
- if( rc ){
68219
-#ifdef SQLITE_ENABLE_SETLK_TIMEOUT
68220
- if( rc==SQLITE_BUSY_TIMEOUT ){
68221
- *pCnt |= WAL_RETRY_BLOCKED_MASK;
68222
- }
68223
-#else
68224
- assert( rc!=SQLITE_BUSY_TIMEOUT );
68225
-#endif
68226
- assert( (rc&0xFF)!=SQLITE_BUSY||rc==SQLITE_BUSY||rc==SQLITE_BUSY_TIMEOUT );
68227
- return (rc&0xFF)==SQLITE_BUSY ? WAL_RETRY : rc;
68228
- }
68229
- /* Now that the read-lock has been obtained, check that neither the
68230
- ** value in the aReadMark[] array or the contents of the wal-index
68231
- ** header have changed.
68232
- **
68233
- ** It is necessary to check that the wal-index header did not change
68234
- ** between the time it was read and when the shared-lock was obtained
68235
- ** on WAL_READ_LOCK(mxI) was obtained to account for the possibility
68236
- ** that the log file may have been wrapped by a writer, or that frames
68237
- ** that occur later in the log than pWal->hdr.mxFrame may have been
68238
- ** copied into the database by a checkpointer. If either of these things
68239
- ** happened, then reading the database with the current value of
68240
- ** pWal->hdr.mxFrame risks reading a corrupted snapshot. So, retry
68241
- ** instead.
68242
- **
68243
- ** Before checking that the live wal-index header has not changed
68244
- ** since it was read, set Wal.minFrame to the first frame in the wal
68245
- ** file that has not yet been checkpointed. This client will not need
68246
- ** to read any frames earlier than minFrame from the wal file - they
68247
- ** can be safely read directly from the database file.
68248
- **
68249
- ** Because a ShmBarrier() call is made between taking the copy of
68250
- ** nBackfill and checking that the wal-header in shared-memory still
68251
- ** matches the one cached in pWal->hdr, it is guaranteed that the
68252
- ** checkpointer that set nBackfill was not working with a wal-index
68253
- ** header newer than that cached in pWal->hdr. If it were, that could
68254
- ** cause a problem. The checkpointer could omit to checkpoint
68255
- ** a version of page X that lies before pWal->minFrame (call that version
68256
- ** A) on the basis that there is a newer version (version B) of the same
68257
- ** page later in the wal file. But if version B happens to like past
68258
- ** frame pWal->hdr.mxFrame - then the client would incorrectly assume
68259
- ** that it can read version A from the database file. However, since
68260
- ** we can guarantee that the checkpointer that set nBackfill could not
68261
- ** see any pages past pWal->hdr.mxFrame, this problem does not come up.
68262
- */
68263
- pWal->minFrame = AtomicLoad(&pInfo->nBackfill)+1; SEH_INJECT_FAULT;
68264
- walShmBarrier(pWal);
68265
- if( AtomicLoad(pInfo->aReadMark+mxI)!=mxReadMark
68266
- || memcmp((void *)walIndexHdr(pWal), &pWal->hdr, sizeof(WalIndexHdr))
68267
- ){
68268
- walUnlockShared(pWal, WAL_READ_LOCK(mxI));
68269
- return WAL_RETRY;
68270
- }else{
68271
- assert( mxReadMark<=pWal->hdr.mxFrame );
68272
- pWal->readLock = (i16)mxI;
68264
+ {
68265
+ u32 mxReadMark; /* Largest aReadMark[] value */
68266
+ int mxI; /* Index of largest aReadMark[] value */
68267
+ int i; /* Loop counter */
68268
+ u32 mxFrame; /* Wal frame to lock to */
68269
+ if( !useWal && AtomicLoad(&pInfo->nBackfill)==pWal->hdr.mxFrame
68270
+#ifdef SQLITE_ENABLE_SNAPSHOT
68271
+ && ((pWal->bGetSnapshot==0 && pWal->pSnapshot==0) || pWal->hdr.mxFrame==0)
68272
+#endif
68273
+ ){
68274
+ /* The WAL has been completely backfilled (or it is empty).
68275
+ ** and can be safely ignored.
68276
+ */
68277
+ rc = walLockShared(pWal, WAL_READ_LOCK(0));
68278
+ walShmBarrier(pWal);
68279
+ if( rc==SQLITE_OK ){
68280
+ if( memcmp((void *)walIndexHdr(pWal), &pWal->hdr,sizeof(WalIndexHdr)) ){
68281
+ /* It is not safe to allow the reader to continue here if frames
68282
+ ** may have been appended to the log before READ_LOCK(0) was obtained.
68283
+ ** When holding READ_LOCK(0), the reader ignores the entire log file,
68284
+ ** which implies that the database file contains a trustworthy
68285
+ ** snapshot. Since holding READ_LOCK(0) prevents a checkpoint from
68286
+ ** happening, this is usually correct.
68287
+ **
68288
+ ** However, if frames have been appended to the log (or if the log
68289
+ ** is wrapped and written for that matter) before the READ_LOCK(0)
68290
+ ** is obtained, that is not necessarily true. A checkpointer may
68291
+ ** have started to backfill the appended frames but crashed before
68292
+ ** it finished. Leaving a corrupt image in the database file.
68293
+ */
68294
+ walUnlockShared(pWal, WAL_READ_LOCK(0));
68295
+ return WAL_RETRY;
68296
+ }
68297
+ pWal->readLock = 0;
68298
+ return SQLITE_OK;
68299
+ }else if( rc!=SQLITE_BUSY ){
68300
+ return rc;
68301
+ }
68302
+ }
68303
+
68304
+ /* If we get this far, it means that the reader will want to use
68305
+ ** the WAL to get at content from recent commits. The job now is
68306
+ ** to select one of the aReadMark[] entries that is closest to
68307
+ ** but not exceeding pWal->hdr.mxFrame and lock that entry.
68308
+ */
68309
+ mxReadMark = 0;
68310
+ mxI = 0;
68311
+ mxFrame = pWal->hdr.mxFrame;
68312
+#ifdef SQLITE_ENABLE_SNAPSHOT
68313
+ if( pWal->pSnapshot && pWal->pSnapshot->mxFrame<mxFrame ){
68314
+ mxFrame = pWal->pSnapshot->mxFrame;
68315
+ }
68316
+#endif
68317
+ for(i=1; i<WAL_NREADER; i++){
68318
+ u32 thisMark = AtomicLoad(pInfo->aReadMark+i); SEH_INJECT_FAULT;
68319
+ if( mxReadMark<=thisMark && thisMark<=mxFrame ){
68320
+ assert( thisMark!=READMARK_NOT_USED );
68321
+ mxReadMark = thisMark;
68322
+ mxI = i;
68323
+ }
68324
+ }
68325
+ if( (pWal->readOnly & WAL_SHM_RDONLY)==0
68326
+ && (mxReadMark<mxFrame || mxI==0)
68327
+ ){
68328
+ for(i=1; i<WAL_NREADER; i++){
68329
+ rc = walLockExclusive(pWal, WAL_READ_LOCK(i), 1);
68330
+ if( rc==SQLITE_OK ){
68331
+ AtomicStore(pInfo->aReadMark+i,mxFrame);
68332
+ mxReadMark = mxFrame;
68333
+ mxI = i;
68334
+ walUnlockExclusive(pWal, WAL_READ_LOCK(i), 1);
68335
+ break;
68336
+ }else if( rc!=SQLITE_BUSY ){
68337
+ return rc;
68338
+ }
68339
+ }
68340
+ }
68341
+ if( mxI==0 ){
68342
+ assert( rc==SQLITE_BUSY || (pWal->readOnly & WAL_SHM_RDONLY)!=0 );
68343
+ return rc==SQLITE_BUSY ? WAL_RETRY : SQLITE_READONLY_CANTINIT;
68344
+ }
68345
+
68346
+ (void)walEnableBlockingMs(pWal, nBlockTmout);
68347
+ rc = walLockShared(pWal, WAL_READ_LOCK(mxI));
68348
+ walDisableBlocking(pWal);
68349
+ if( rc ){
68350
+#ifdef SQLITE_ENABLE_SETLK_TIMEOUT
68351
+ if( rc==SQLITE_BUSY_TIMEOUT ){
68352
+ *pCnt |= WAL_RETRY_BLOCKED_MASK;
68353
+ }
68354
+#else
68355
+ assert( rc!=SQLITE_BUSY_TIMEOUT );
68356
+#endif
68357
+ assert((rc&0xFF)!=SQLITE_BUSY||rc==SQLITE_BUSY||rc==SQLITE_BUSY_TIMEOUT);
68358
+ return (rc&0xFF)==SQLITE_BUSY ? WAL_RETRY : rc;
68359
+ }
68360
+ /* Now that the read-lock has been obtained, check that neither the
68361
+ ** value in the aReadMark[] array or the contents of the wal-index
68362
+ ** header have changed.
68363
+ **
68364
+ ** It is necessary to check that the wal-index header did not change
68365
+ ** between the time it was read and when the shared-lock was obtained
68366
+ ** on WAL_READ_LOCK(mxI) was obtained to account for the possibility
68367
+ ** that the log file may have been wrapped by a writer, or that frames
68368
+ ** that occur later in the log than pWal->hdr.mxFrame may have been
68369
+ ** copied into the database by a checkpointer. If either of these things
68370
+ ** happened, then reading the database with the current value of
68371
+ ** pWal->hdr.mxFrame risks reading a corrupted snapshot. So, retry
68372
+ ** instead.
68373
+ **
68374
+ ** Before checking that the live wal-index header has not changed
68375
+ ** since it was read, set Wal.minFrame to the first frame in the wal
68376
+ ** file that has not yet been checkpointed. This client will not need
68377
+ ** to read any frames earlier than minFrame from the wal file - they
68378
+ ** can be safely read directly from the database file.
68379
+ **
68380
+ ** Because a ShmBarrier() call is made between taking the copy of
68381
+ ** nBackfill and checking that the wal-header in shared-memory still
68382
+ ** matches the one cached in pWal->hdr, it is guaranteed that the
68383
+ ** checkpointer that set nBackfill was not working with a wal-index
68384
+ ** header newer than that cached in pWal->hdr. If it were, that could
68385
+ ** cause a problem. The checkpointer could omit to checkpoint
68386
+ ** a version of page X that lies before pWal->minFrame (call that version
68387
+ ** A) on the basis that there is a newer version (version B) of the same
68388
+ ** page later in the wal file. But if version B happens to like past
68389
+ ** frame pWal->hdr.mxFrame - then the client would incorrectly assume
68390
+ ** that it can read version A from the database file. However, since
68391
+ ** we can guarantee that the checkpointer that set nBackfill could not
68392
+ ** see any pages past pWal->hdr.mxFrame, this problem does not come up.
68393
+ */
68394
+ pWal->minFrame = AtomicLoad(&pInfo->nBackfill)+1; SEH_INJECT_FAULT;
68395
+ walShmBarrier(pWal);
68396
+ if( AtomicLoad(pInfo->aReadMark+mxI)!=mxReadMark
68397
+ || memcmp((void *)walIndexHdr(pWal), &pWal->hdr, sizeof(WalIndexHdr))
68398
+ ){
68399
+ walUnlockShared(pWal, WAL_READ_LOCK(mxI));
68400
+ return WAL_RETRY;
68401
+ }else{
68402
+ assert( mxReadMark<=pWal->hdr.mxFrame );
68403
+ pWal->readLock = (i16)mxI;
68404
+ }
6827368405
}
6827468406
return rc;
6827568407
}
6827668408
6827768409
#ifdef SQLITE_ENABLE_SNAPSHOT
@@ -71412,11 +71544,11 @@
7141271544
** up to the size of 1 varint plus 1 8-byte value when the cursor
7141371545
** position is restored. Hence the 17 bytes of padding allocated
7141471546
** below. */
7141571547
void *pKey;
7141671548
pCur->nKey = sqlite3BtreePayloadSize(pCur);
71417
- pKey = sqlite3Malloc( pCur->nKey + 9 + 8 );
71549
+ pKey = sqlite3Malloc( ((i64)pCur->nKey) + 9 + 8 );
7141871550
if( pKey ){
7141971551
rc = sqlite3BtreePayload(pCur, 0, (int)pCur->nKey, pKey);
7142071552
if( rc==SQLITE_OK ){
7142171553
memset(((u8*)pKey)+pCur->nKey, 0, 9+8);
7142271554
pCur->pKey = pKey;
@@ -76783,11 +76915,11 @@
7678376915
testcase( nCell==2 ); /* Minimum legal index key size */
7678476916
if( nCell<2 || nCell/pCur->pBt->usableSize>pCur->pBt->nPage ){
7678576917
rc = SQLITE_CORRUPT_PAGE(pPage);
7678676918
goto moveto_index_finish;
7678776919
}
76788
- pCellKey = sqlite3Malloc( nCell+nOverrun );
76920
+ pCellKey = sqlite3Malloc( (u64)nCell+(u64)nOverrun );
7678976921
if( pCellKey==0 ){
7679076922
rc = SQLITE_NOMEM_BKPT;
7679176923
goto moveto_index_finish;
7679276924
}
7679376925
pCur->ix = (u16)idx;
@@ -81972,10 +82104,11 @@
8197282104
** blob of allocated memory. The xFree function should not call sqlite3_free()
8197382105
** on the memory, the btree layer does that.
8197482106
*/
8197582107
SQLITE_PRIVATE void *sqlite3BtreeSchema(Btree *p, int nBytes, void(*xFree)(void *)){
8197682108
BtShared *pBt = p->pBt;
82109
+ assert( nBytes==0 || nBytes==sizeof(Schema) );
8197782110
sqlite3BtreeEnter(p);
8197882111
if( !pBt->pSchema && nBytes ){
8197982112
pBt->pSchema = sqlite3DbMallocZero(0, nBytes);
8198082113
pBt->xFreeSchema = xFree;
8198182114
}
@@ -83274,11 +83407,11 @@
8327483407
if( (pMem->flags & (MEM_Str|MEM_Term|MEM_Ephem|MEM_Static))!=MEM_Str ){
8327583408
/* pMem must be a string, and it cannot be an ephemeral or static string */
8327683409
return;
8327783410
}
8327883411
if( pMem->enc!=SQLITE_UTF8 ) return;
83279
- if( NEVER(pMem->z==0) ) return;
83412
+ assert( pMem->z!=0 );
8328083413
if( pMem->flags & MEM_Dyn ){
8328183414
if( pMem->xDel==sqlite3_free
8328283415
&& sqlite3_msize(pMem->z) >= (u64)(pMem->n+1)
8328383416
){
8328483417
pMem->z[pMem->n] = 0;
@@ -83993,31 +84126,34 @@
8399384126
** copies (created by OP_SCopy) are not misused.
8399484127
*/
8399584128
SQLITE_PRIVATE void sqlite3VdbeMemAboutToChange(Vdbe *pVdbe, Mem *pMem){
8399684129
int i;
8399784130
Mem *pX;
83998
- for(i=1, pX=pVdbe->aMem+1; i<pVdbe->nMem; i++, pX++){
83999
- if( pX->pScopyFrom==pMem ){
84000
- u16 mFlags;
84001
- if( pVdbe->db->flags & SQLITE_VdbeTrace ){
84002
- sqlite3DebugPrintf("Invalidate R[%d] due to change in R[%d]\n",
84003
- (int)(pX - pVdbe->aMem), (int)(pMem - pVdbe->aMem));
84004
- }
84005
- /* If pX is marked as a shallow copy of pMem, then try to verify that
84006
- ** no significant changes have been made to pX since the OP_SCopy.
84007
- ** A significant change would indicated a missed call to this
84008
- ** function for pX. Minor changes, such as adding or removing a
84009
- ** dual type, are allowed, as long as the underlying value is the
84010
- ** same. */
84011
- mFlags = pMem->flags & pX->flags & pX->mScopyFlags;
84012
- assert( (mFlags&(MEM_Int|MEM_IntReal))==0 || pMem->u.i==pX->u.i );
84013
-
84014
- /* pMem is the register that is changing. But also mark pX as
84015
- ** undefined so that we can quickly detect the shallow-copy error */
84016
- pX->flags = MEM_Undefined;
84017
- pX->pScopyFrom = 0;
84018
- }
84131
+ if( pMem->bScopy ){
84132
+ for(i=1, pX=pVdbe->aMem+1; i<pVdbe->nMem; i++, pX++){
84133
+ if( pX->pScopyFrom==pMem ){
84134
+ u16 mFlags;
84135
+ if( pVdbe->db->flags & SQLITE_VdbeTrace ){
84136
+ sqlite3DebugPrintf("Invalidate R[%d] due to change in R[%d]\n",
84137
+ (int)(pX - pVdbe->aMem), (int)(pMem - pVdbe->aMem));
84138
+ }
84139
+ /* If pX is marked as a shallow copy of pMem, then try to verify that
84140
+ ** no significant changes have been made to pX since the OP_SCopy.
84141
+ ** A significant change would indicated a missed call to this
84142
+ ** function for pX. Minor changes, such as adding or removing a
84143
+ ** dual type, are allowed, as long as the underlying value is the
84144
+ ** same. */
84145
+ mFlags = pMem->flags & pX->flags & pX->mScopyFlags;
84146
+ assert( (mFlags&(MEM_Int|MEM_IntReal))==0 || pMem->u.i==pX->u.i );
84147
+
84148
+ /* pMem is the register that is changing. But also mark pX as
84149
+ ** undefined so that we can quickly detect the shallow-copy error */
84150
+ pX->flags = MEM_Undefined;
84151
+ pX->pScopyFrom = 0;
84152
+ }
84153
+ }
84154
+ pMem->bScopy = 0;
8401984155
}
8402084156
pMem->pScopyFrom = 0;
8402184157
}
8402284158
#endif /* SQLITE_DEBUG */
8402384159
@@ -84384,11 +84520,11 @@
8438484520
if( p ){
8438584521
UnpackedRecord *pRec = p->ppRec[0];
8438684522
8438784523
if( pRec==0 ){
8438884524
Index *pIdx = p->pIdx; /* Index being probed */
84389
- int nByte; /* Bytes of space to allocate */
84525
+ i64 nByte; /* Bytes of space to allocate */
8439084526
int i; /* Counter variable */
8439184527
int nCol = pIdx->nColumn; /* Number of index columns including rowid */
8439284528
8439384529
nByte = sizeof(Mem) * nCol + ROUND8(sizeof(UnpackedRecord));
8439484530
pRec = (UnpackedRecord*)sqlite3DbMallocZero(db, nByte);
@@ -84450,11 +84586,11 @@
8445084586
sqlite3_value **ppVal, /* Write the new value here */
8445184587
struct ValueNewStat4Ctx *pCtx /* Second argument for valueNew() */
8445284588
){
8445384589
sqlite3_context ctx; /* Context object for function invocation */
8445484590
sqlite3_value **apVal = 0; /* Function arguments */
84455
- int nVal = 0; /* Size of apVal[] array */
84591
+ int nVal = 0; /* Number of function arguments */
8445684592
FuncDef *pFunc = 0; /* Function definition */
8445784593
sqlite3_value *pVal = 0; /* New value */
8445884594
int rc = SQLITE_OK; /* Return code */
8445984595
ExprList *pList = 0; /* Function arguments */
8446084596
int i; /* Iterator variable */
@@ -85729,11 +85865,11 @@
8572985865
p->iSub++;
8573085866
p->iAddr = 0;
8573185867
}
8573285868
8573385869
if( pRet->p4type==P4_SUBPROGRAM ){
85734
- int nByte = (p->nSub+1)*sizeof(SubProgram*);
85870
+ i64 nByte = (1+(u64)p->nSub)*sizeof(SubProgram*);
8573585871
int j;
8573685872
for(j=0; j<p->nSub; j++){
8573785873
if( p->apSub[j]==pRet->p4.pProgram ) break;
8573885874
}
8573985875
if( j==p->nSub ){
@@ -85859,12 +85995,12 @@
8585985995
** through all the opcodes and fixes up some details.
8586085996
**
8586185997
** (1) For each jump instruction with a negative P2 value (a label)
8586285998
** resolve the P2 value to an actual address.
8586385999
**
85864
-** (2) Compute the maximum number of arguments used by any SQL function
85865
-** and store that value in *pMaxFuncArgs.
86000
+** (2) Compute the maximum number of arguments used by the xUpdate/xFilter
86001
+** methods of any virtual table and store that value in *pMaxVtabArgs.
8586686002
**
8586786003
** (3) Update the Vdbe.readOnly and Vdbe.bIsReader flags to accurately
8586886004
** indicate what the prepared statement actually does.
8586986005
**
8587086006
** (4) (discontinued)
@@ -85873,12 +86009,12 @@
8587386009
**
8587486010
** This routine will only function correctly if the mkopcodeh.tcl generator
8587586011
** script numbers the opcodes correctly. Changes to this routine must be
8587686012
** coordinated with changes to mkopcodeh.tcl.
8587786013
*/
85878
-static void resolveP2Values(Vdbe *p, int *pMaxFuncArgs){
85879
- int nMaxArgs = *pMaxFuncArgs;
86014
+static void resolveP2Values(Vdbe *p, int *pMaxVtabArgs){
86015
+ int nMaxVtabArgs = *pMaxVtabArgs;
8588086016
Op *pOp;
8588186017
Parse *pParse = p->pParse;
8588286018
int *aLabel = pParse->aLabel;
8588386019
8588486020
assert( pParse->db->mallocFailed==0 ); /* tag-20230419-1 */
@@ -85919,19 +86055,23 @@
8591986055
assert( pOp->p2>=0 );
8592086056
goto resolve_p2_values_loop_exit;
8592186057
}
8592286058
#ifndef SQLITE_OMIT_VIRTUALTABLE
8592386059
case OP_VUpdate: {
85924
- if( pOp->p2>nMaxArgs ) nMaxArgs = pOp->p2;
86060
+ if( pOp->p2>nMaxVtabArgs ) nMaxVtabArgs = pOp->p2;
8592586061
break;
8592686062
}
8592786063
case OP_VFilter: {
8592886064
int n;
86065
+ /* The instruction immediately prior to VFilter will be an
86066
+ ** OP_Integer that sets the "argc" value for the VFilter. See
86067
+ ** the code where OP_VFilter is generated at tag-20250207a. */
8592986068
assert( (pOp - p->aOp) >= 3 );
8593086069
assert( pOp[-1].opcode==OP_Integer );
86070
+ assert( pOp[-1].p2==pOp->p3+1 );
8593186071
n = pOp[-1].p1;
85932
- if( n>nMaxArgs ) nMaxArgs = n;
86072
+ if( n>nMaxVtabArgs ) nMaxVtabArgs = n;
8593386073
/* Fall through into the default case */
8593486074
/* no break */ deliberate_fall_through
8593586075
}
8593686076
#endif
8593786077
default: {
@@ -85968,11 +86108,11 @@
8596886108
if( aLabel ){
8596986109
sqlite3DbNNFreeNN(p->db, pParse->aLabel);
8597086110
pParse->aLabel = 0;
8597186111
}
8597286112
pParse->nLabel = 0;
85973
- *pMaxFuncArgs = nMaxArgs;
86113
+ *pMaxVtabArgs = nMaxVtabArgs;
8597486114
assert( p->bIsReader!=0 || DbMaskAllZero(p->btreeMask) );
8597586115
}
8597686116
8597786117
#ifdef SQLITE_DEBUG
8597886118
/*
@@ -86197,11 +86337,11 @@
8619786337
int addrVisit, /* Address of rows visited counter */
8619886338
LogEst nEst, /* Estimated number of output rows */
8619986339
const char *zName /* Name of table or index being scanned */
8620086340
){
8620186341
if( IS_STMT_SCANSTATUS(p->db) ){
86202
- sqlite3_int64 nByte = (p->nScan+1) * sizeof(ScanStatus);
86342
+ i64 nByte = (1+(i64)p->nScan) * sizeof(ScanStatus);
8620386343
ScanStatus *aNew;
8620486344
aNew = (ScanStatus*)sqlite3DbRealloc(p->db, p->aScan, nByte);
8620586345
if( aNew ){
8620686346
ScanStatus *pNew = &aNew[p->nScan++];
8620786347
memset(pNew, 0, sizeof(ScanStatus));
@@ -87147,17 +87287,19 @@
8714787287
**
8714887288
** All other fields of Mem can safely remain uninitialized for now. They
8714987289
** will be initialized before use.
8715087290
*/
8715187291
static void initMemArray(Mem *p, int N, sqlite3 *db, u16 flags){
87292
+ assert( db!=0 );
8715287293
if( N>0 ){
8715387294
do{
8715487295
p->flags = flags;
8715587296
p->db = db;
8715687297
p->szMalloc = 0;
8715787298
#ifdef SQLITE_DEBUG
8715887299
p->pScopyFrom = 0;
87300
+ p->bScopy = 0;
8715987301
#endif
8716087302
p++;
8716187303
}while( (--N)>0 );
8716287304
}
8716387305
}
@@ -87172,10 +87314,11 @@
8717287314
*/
8717387315
static void releaseMemArray(Mem *p, int N){
8717487316
if( p && N ){
8717587317
Mem *pEnd = &p[N];
8717687318
sqlite3 *db = p->db;
87319
+ assert( db!=0 );
8717787320
if( db->pnBytesFreed ){
8717887321
do{
8717987322
if( p->szMalloc ) sqlite3DbFree(db, p->zMalloc);
8718087323
}while( (++p)<pEnd );
8718187324
return;
@@ -87643,19 +87786,20 @@
8764387786
){
8764487787
sqlite3 *db; /* The database connection */
8764587788
int nVar; /* Number of parameters */
8764687789
int nMem; /* Number of VM memory registers */
8764787790
int nCursor; /* Number of cursors required */
87648
- int nArg; /* Number of arguments in subprograms */
87791
+ int nArg; /* Max number args to xFilter or xUpdate */
8764987792
int n; /* Loop counter */
8765087793
struct ReusableSpace x; /* Reusable bulk memory */
8765187794
8765287795
assert( p!=0 );
8765387796
assert( p->nOp>0 );
8765487797
assert( pParse!=0 );
8765587798
assert( p->eVdbeState==VDBE_INIT_STATE );
8765687799
assert( pParse==p->pParse );
87800
+ assert( pParse->db==p->db );
8765787801
p->pVList = pParse->pVList;
8765887802
pParse->pVList = 0;
8765987803
db = p->db;
8766087804
assert( db->mallocFailed==0 );
8766187805
nVar = pParse->nVar;
@@ -87714,10 +87858,13 @@
8771487858
p->aVar = allocSpace(&x, p->aVar, nVar*sizeof(Mem));
8771587859
p->apArg = allocSpace(&x, p->apArg, nArg*sizeof(Mem*));
8771687860
p->apCsr = allocSpace(&x, p->apCsr, nCursor*sizeof(VdbeCursor*));
8771787861
}
8771887862
}
87863
+#ifdef SQLITE_DEBUG
87864
+ p->napArg = nArg;
87865
+#endif
8771987866
8772087867
if( db->mallocFailed ){
8772187868
p->nVar = 0;
8772287869
p->nCursor = 0;
8772387870
p->nMem = 0;
@@ -89211,10 +89358,11 @@
8921189358
SQLITE_PRIVATE UnpackedRecord *sqlite3VdbeAllocUnpackedRecord(
8921289359
KeyInfo *pKeyInfo /* Description of the record */
8921389360
){
8921489361
UnpackedRecord *p; /* Unpacked record to return */
8921589362
int nByte; /* Number of bytes required for *p */
89363
+ assert( sizeof(UnpackedRecord) + sizeof(Mem)*65536 < 0x7fffffff );
8921689364
nByte = ROUND8P(sizeof(UnpackedRecord)) + sizeof(Mem)*(pKeyInfo->nKeyField+1);
8921789365
p = (UnpackedRecord *)sqlite3DbMallocRaw(pKeyInfo->db, nByte);
8921889366
if( !p ) return 0;
8921989367
p->aMem = (Mem*)&((char*)p)[ROUND8P(sizeof(UnpackedRecord))];
8922089368
assert( pKeyInfo->aSortFlags!=0 );
@@ -90617,11 +90765,10 @@
9061790765
*/
9061890766
static SQLITE_NOINLINE void invokeProfileCallback(sqlite3 *db, Vdbe *p){
9061990767
sqlite3_int64 iNow;
9062090768
sqlite3_int64 iElapse;
9062190769
assert( p->startTime>0 );
90622
- assert( (db->mTrace & (SQLITE_TRACE_PROFILE|SQLITE_TRACE_XPROFILE))!=0 );
9062390770
assert( db->init.busy==0 );
9062490771
assert( p->zSql!=0 );
9062590772
sqlite3OsCurrentTimeInt64(db->pVfs, &iNow);
9062690773
iElapse = (iNow - p->startTime)*1000000;
9062790774
#ifndef SQLITE_OMIT_DEPRECATED
@@ -91337,11 +91484,11 @@
9133791484
if( db->nVdbeActive==0 ){
9133891485
AtomicStore(&db->u1.isInterrupted, 0);
9133991486
}
9134091487
9134191488
assert( db->nVdbeWrite>0 || db->autoCommit==0
91342
- || (db->nDeferredCons==0 && db->nDeferredImmCons==0)
91489
+ || ((db->nDeferredCons + db->nDeferredImmCons)==0)
9134391490
);
9134491491
9134591492
#ifndef SQLITE_OMIT_TRACE
9134691493
if( (db->mTrace & (SQLITE_TRACE_PROFILE|SQLITE_TRACE_XPROFILE))!=0
9134791494
&& !db->init.busy && p->zSql ){
@@ -91848,10 +91995,11 @@
9184891995
/* .zMalloc = */ (char*)0,
9184991996
/* .xDel = */ (void(*)(void*))0,
9185091997
#ifdef SQLITE_DEBUG
9185191998
/* .pScopyFrom = */ (Mem*)0,
9185291999
/* .mScopyFlags= */ 0,
92000
+ /* .bScopy = */ 0,
9185392001
#endif
9185492002
};
9185592003
return &nullMem;
9185692004
}
9185792005
@@ -91889,11 +92037,11 @@
9188992037
**
9189092038
** sqlite3_column_int()
9189192039
** sqlite3_column_int64()
9189292040
** sqlite3_column_text()
9189392041
** sqlite3_column_text16()
91894
-** sqlite3_column_real()
92042
+** sqlite3_column_double()
9189592043
** sqlite3_column_bytes()
9189692044
** sqlite3_column_bytes16()
9189792045
** sqlite3_column_blob()
9189892046
*/
9189992047
static void columnMallocFailure(sqlite3_stmt *pStmt)
@@ -92730,10 +92878,11 @@
9273092878
*/
9273192879
SQLITE_API int sqlite3_preupdate_old(sqlite3 *db, int iIdx, sqlite3_value **ppValue){
9273292880
PreUpdate *p;
9273392881
Mem *pMem;
9273492882
int rc = SQLITE_OK;
92883
+ int iStore = 0;
9273592884
9273692885
#ifdef SQLITE_ENABLE_API_ARMOR
9273792886
if( db==0 || ppValue==0 ){
9273892887
return SQLITE_MISUSE_BKPT;
9273992888
}
@@ -92744,13 +92893,15 @@
9274492893
if( !p || p->op==SQLITE_INSERT ){
9274592894
rc = SQLITE_MISUSE_BKPT;
9274692895
goto preupdate_old_out;
9274792896
}
9274892897
if( p->pPk ){
92749
- iIdx = sqlite3TableColumnToIndex(p->pPk, iIdx);
92898
+ iStore = sqlite3TableColumnToIndex(p->pPk, iIdx);
92899
+ }else{
92900
+ iStore = sqlite3TableColumnToStorage(p->pTab, iIdx);
9275092901
}
92751
- if( iIdx>=p->pCsr->nField || iIdx<0 ){
92902
+ if( iStore>=p->pCsr->nField || iStore<0 ){
9275292903
rc = SQLITE_RANGE;
9275392904
goto preupdate_old_out;
9275492905
}
9275592906
9275692907
if( iIdx==p->pTab->iPKey ){
@@ -92777,18 +92928,20 @@
9277792928
goto preupdate_old_out;
9277892929
}
9277992930
p->aRecord = aRec;
9278092931
}
9278192932
92782
- pMem = *ppValue = &p->pUnpacked->aMem[iIdx];
92783
- if( iIdx>=p->pUnpacked->nField ){
92933
+ pMem = *ppValue = &p->pUnpacked->aMem[iStore];
92934
+ if( iStore>=p->pUnpacked->nField ){
9278492935
/* This occurs when the table has been extended using ALTER TABLE
9278592936
** ADD COLUMN. The value to return is the default value of the column. */
9278692937
Column *pCol = &p->pTab->aCol[iIdx];
9278792938
if( pCol->iDflt>0 ){
9278892939
if( p->apDflt==0 ){
92789
- int nByte = sizeof(sqlite3_value*)*p->pTab->nCol;
92940
+ int nByte;
92941
+ assert( sizeof(sqlite3_value*)*UMXV(p->pTab->nCol) < 0x7fffffff );
92942
+ nByte = sizeof(sqlite3_value*)*p->pTab->nCol;
9279092943
p->apDflt = (sqlite3_value**)sqlite3DbMallocZero(db, nByte);
9279192944
if( p->apDflt==0 ) goto preupdate_old_out;
9279292945
}
9279392946
if( p->apDflt[iIdx]==0 ){
9279492947
sqlite3_value *pVal = 0;
@@ -92882,10 +93035,11 @@
9288293035
*/
9288393036
SQLITE_API int sqlite3_preupdate_new(sqlite3 *db, int iIdx, sqlite3_value **ppValue){
9288493037
PreUpdate *p;
9288593038
int rc = SQLITE_OK;
9288693039
Mem *pMem;
93040
+ int iStore = 0;
9288793041
9288893042
#ifdef SQLITE_ENABLE_API_ARMOR
9288993043
if( db==0 || ppValue==0 ){
9289093044
return SQLITE_MISUSE_BKPT;
9289193045
}
@@ -92894,13 +93048,16 @@
9289493048
if( !p || p->op==SQLITE_DELETE ){
9289593049
rc = SQLITE_MISUSE_BKPT;
9289693050
goto preupdate_new_out;
9289793051
}
9289893052
if( p->pPk && p->op!=SQLITE_UPDATE ){
92899
- iIdx = sqlite3TableColumnToIndex(p->pPk, iIdx);
93053
+ iStore = sqlite3TableColumnToIndex(p->pPk, iIdx);
93054
+ }else{
93055
+ iStore = sqlite3TableColumnToStorage(p->pTab, iIdx);
9290093056
}
92901
- if( iIdx>=p->pCsr->nField || iIdx<0 ){
93057
+
93058
+ if( iStore>=p->pCsr->nField || iStore<0 ){
9290293059
rc = SQLITE_RANGE;
9290393060
goto preupdate_new_out;
9290493061
}
9290593062
9290693063
if( p->op==SQLITE_INSERT ){
@@ -92916,37 +93073,38 @@
9291693073
rc = SQLITE_NOMEM;
9291793074
goto preupdate_new_out;
9291893075
}
9291993076
p->pNewUnpacked = pUnpack;
9292093077
}
92921
- pMem = &pUnpack->aMem[iIdx];
93078
+ pMem = &pUnpack->aMem[iStore];
9292293079
if( iIdx==p->pTab->iPKey ){
9292393080
sqlite3VdbeMemSetInt64(pMem, p->iKey2);
92924
- }else if( iIdx>=pUnpack->nField ){
93081
+ }else if( iStore>=pUnpack->nField ){
9292593082
pMem = (sqlite3_value *)columnNullValue();
9292693083
}
9292793084
}else{
92928
- /* For an UPDATE, memory cell (p->iNewReg+1+iIdx) contains the required
93085
+ /* For an UPDATE, memory cell (p->iNewReg+1+iStore) contains the required
9292993086
** value. Make a copy of the cell contents and return a pointer to it.
9293093087
** It is not safe to return a pointer to the memory cell itself as the
9293193088
** caller may modify the value text encoding.
9293293089
*/
9293393090
assert( p->op==SQLITE_UPDATE );
9293493091
if( !p->aNew ){
92935
- p->aNew = (Mem *)sqlite3DbMallocZero(db, sizeof(Mem) * p->pCsr->nField);
93092
+ assert( sizeof(Mem)*UMXV(p->pCsr->nField) < 0x7fffffff );
93093
+ p->aNew = (Mem *)sqlite3DbMallocZero(db, sizeof(Mem)*p->pCsr->nField);
9293693094
if( !p->aNew ){
9293793095
rc = SQLITE_NOMEM;
9293893096
goto preupdate_new_out;
9293993097
}
9294093098
}
92941
- assert( iIdx>=0 && iIdx<p->pCsr->nField );
92942
- pMem = &p->aNew[iIdx];
93099
+ assert( iStore>=0 && iStore<p->pCsr->nField );
93100
+ pMem = &p->aNew[iStore];
9294393101
if( pMem->flags==0 ){
9294493102
if( iIdx==p->pTab->iPKey ){
9294593103
sqlite3VdbeMemSetInt64(pMem, p->iKey2);
9294693104
}else{
92947
- rc = sqlite3VdbeMemCopy(pMem, &p->v->aMem[p->iNewReg+1+iIdx]);
93105
+ rc = sqlite3VdbeMemCopy(pMem, &p->v->aMem[p->iNewReg+1+iStore]);
9294893106
if( rc!=SQLITE_OK ) goto preupdate_new_out;
9294993107
}
9295093108
}
9295193109
}
9295293110
*ppValue = pMem;
@@ -93700,11 +93858,11 @@
9370093858
** the top of the register space. Cursor 1 is at Mem[p->nMem-1].
9370193859
** Cursor 2 is at Mem[p->nMem-2]. And so forth.
9370293860
*/
9370393861
Mem *pMem = iCur>0 ? &p->aMem[p->nMem-iCur] : p->aMem;
9370493862
93705
- int nByte;
93863
+ i64 nByte;
9370693864
VdbeCursor *pCx = 0;
9370793865
nByte =
9370893866
ROUND8P(sizeof(VdbeCursor)) + 2*sizeof(u32)*nField +
9370993867
(eCurType==CURTYPE_BTREE?sqlite3BtreeCursorSize():0);
9371093868
@@ -93728,11 +93886,11 @@
9372893886
pMem->z = pMem->zMalloc = sqlite3DbMallocRaw(pMem->db, nByte);
9372993887
if( pMem->zMalloc==0 ){
9373093888
pMem->szMalloc = 0;
9373193889
return 0;
9373293890
}
93733
- pMem->szMalloc = nByte;
93891
+ pMem->szMalloc = (int)nByte;
9373493892
}
9373593893
9373693894
p->apCsr[iCur] = pCx = (VdbeCursor*)pMem->zMalloc;
9373793895
memset(pCx, 0, offsetof(VdbeCursor,pAltCursor));
9373893896
pCx->eCurType = eCurType;
@@ -94031,10 +94189,11 @@
9403194189
}
9403294190
static void registerTrace(int iReg, Mem *p){
9403394191
printf("R[%d] = ", iReg);
9403494192
memTracePrint(p);
9403594193
if( p->pScopyFrom ){
94194
+ assert( p->pScopyFrom->bScopy );
9403694195
printf(" <== R[%d]", (int)(p->pScopyFrom - &p[-iReg]));
9403794196
}
9403894197
printf("\n");
9403994198
sqlite3VdbeCheckMemInvariants(p);
9404094199
}
@@ -95014,10 +95173,11 @@
9501495173
#ifdef SQLITE_DEBUG
9501595174
pIn1->pScopyFrom = 0;
9501695175
{ int i;
9501795176
for(i=1; i<p->nMem; i++){
9501895177
if( aMem[i].pScopyFrom==pIn1 ){
95178
+ assert( aMem[i].bScopy );
9501995179
aMem[i].pScopyFrom = pOut;
9502095180
}
9502195181
}
9502295182
}
9502395183
#endif
@@ -95086,10 +95246,11 @@
9508695246
assert( pOut!=pIn1 );
9508795247
sqlite3VdbeMemShallowCopy(pOut, pIn1, MEM_Ephem);
9508895248
#ifdef SQLITE_DEBUG
9508995249
pOut->pScopyFrom = pIn1;
9509095250
pOut->mScopyFlags = pIn1->flags;
95251
+ pIn1->bScopy = 1;
9509195252
#endif
9509295253
break;
9509395254
}
9509495255
9509595256
/* Opcode: IntCopy P1 P2 * * *
@@ -100746,11 +100907,11 @@
100746100907
**
100747100908
** If P5 is non-zero, then recursive program invocation is enabled.
100748100909
*/
100749100910
case OP_Program: { /* jump0 */
100750100911
int nMem; /* Number of memory registers for sub-program */
100751
- int nByte; /* Bytes of runtime space required for sub-program */
100912
+ i64 nByte; /* Bytes of runtime space required for sub-program */
100752100913
Mem *pRt; /* Register to allocate runtime space */
100753100914
Mem *pMem; /* Used to iterate through memory cells */
100754100915
Mem *pEnd; /* Last memory cell in new array */
100755100916
VdbeFrame *pFrame; /* New vdbe frame to execute in */
100756100917
SubProgram *pProgram; /* Sub-program to execute */
@@ -100797,19 +100958,19 @@
100797100958
assert( nMem>0 );
100798100959
if( pProgram->nCsr==0 ) nMem++;
100799100960
nByte = ROUND8(sizeof(VdbeFrame))
100800100961
+ nMem * sizeof(Mem)
100801100962
+ pProgram->nCsr * sizeof(VdbeCursor*)
100802
- + (pProgram->nOp + 7)/8;
100963
+ + (7 + (i64)pProgram->nOp)/8;
100803100964
pFrame = sqlite3DbMallocZero(db, nByte);
100804100965
if( !pFrame ){
100805100966
goto no_mem;
100806100967
}
100807100968
sqlite3VdbeMemRelease(pRt);
100808100969
pRt->flags = MEM_Blob|MEM_Dyn;
100809100970
pRt->z = (char*)pFrame;
100810
- pRt->n = nByte;
100971
+ pRt->n = (int)nByte;
100811100972
pRt->xDel = sqlite3VdbeFrameMemDel;
100812100973
100813100974
pFrame->v = p;
100814100975
pFrame->nChildMem = nMem;
100815100976
pFrame->nChildCsr = pProgram->nCsr;
@@ -100904,16 +101065,18 @@
100904101065
** If P1 is non-zero, the database constraint counter is incremented
100905101066
** (deferred foreign key constraints). Otherwise, if P1 is zero, the
100906101067
** statement counter is incremented (immediate foreign key constraints).
100907101068
*/
100908101069
case OP_FkCounter: {
100909
- if( db->flags & SQLITE_DeferFKs ){
100910
- db->nDeferredImmCons += pOp->p2;
100911
- }else if( pOp->p1 ){
101070
+ if( pOp->p1 ){
100912101071
db->nDeferredCons += pOp->p2;
100913101072
}else{
100914
- p->nFkConstraint += pOp->p2;
101073
+ if( db->flags & SQLITE_DeferFKs ){
101074
+ db->nDeferredImmCons += pOp->p2;
101075
+ }else{
101076
+ p->nFkConstraint += pOp->p2;
101077
+ }
100915101078
}
100916101079
break;
100917101080
}
100918101081
100919101082
/* Opcode: FkIfZero P1 P2 * * *
@@ -101784,10 +101947,11 @@
101784101947
nArg = (int)pArgc->u.i;
101785101948
iQuery = (int)pQuery->u.i;
101786101949
101787101950
/* Invoke the xFilter method */
101788101951
apArg = p->apArg;
101952
+ assert( nArg<=p->napArg );
101789101953
for(i = 0; i<nArg; i++){
101790101954
apArg[i] = &pArgc[i+1];
101791101955
}
101792101956
rc = pModule->xFilter(pVCur, iQuery, pOp->p4.z, nArg, apArg);
101793101957
sqlite3VtabImportErrmsg(p, pVtab);
@@ -101994,10 +102158,11 @@
101994102158
assert( pOp->p4type==P4_VTAB );
101995102159
if( ALWAYS(pModule->xUpdate) ){
101996102160
u8 vtabOnConflict = db->vtabOnConflict;
101997102161
apArg = p->apArg;
101998102162
pX = &aMem[pOp->p3];
102163
+ assert( nArg<=p->napArg );
101999102164
for(i=0; i<nArg; i++){
102000102165
assert( memIsValid(pX) );
102001102166
memAboutToChange(p, pX);
102002102167
apArg[i] = pX;
102003102168
pX++;
@@ -102839,16 +103004,12 @@
102839103004
}
102840103005
pBlob->pTab = pTab;
102841103006
pBlob->zDb = db->aDb[sqlite3SchemaToIndex(db, pTab->pSchema)].zDbSName;
102842103007
102843103008
/* Now search pTab for the exact column. */
102844
- for(iCol=0; iCol<pTab->nCol; iCol++) {
102845
- if( sqlite3StrICmp(pTab->aCol[iCol].zCnName, zColumn)==0 ){
102846
- break;
102847
- }
102848
- }
102849
- if( iCol==pTab->nCol ){
103009
+ iCol = sqlite3ColumnIndex(pTab, zColumn);
103010
+ if( iCol<0 ){
102850103011
sqlite3DbFree(db, zErr);
102851103012
zErr = sqlite3MPrintf(db, "no such column: \"%s\"", zColumn);
102852103013
rc = SQLITE_ERROR;
102853103014
sqlite3BtreeLeaveAll(db);
102854103015
goto blob_open_out;
@@ -104106,11 +104267,11 @@
104106104267
int pgsz; /* Page size of main database */
104107104268
int i; /* Used to iterate through aTask[] */
104108104269
VdbeSorter *pSorter; /* The new sorter */
104109104270
KeyInfo *pKeyInfo; /* Copy of pCsr->pKeyInfo with db==0 */
104110104271
int szKeyInfo; /* Size of pCsr->pKeyInfo in bytes */
104111
- int sz; /* Size of pSorter in bytes */
104272
+ i64 sz; /* Size of pSorter in bytes */
104112104273
int rc = SQLITE_OK;
104113104274
#if SQLITE_MAX_WORKER_THREADS==0
104114104275
# define nWorker 0
104115104276
#else
104116104277
int nWorker;
@@ -104134,10 +104295,12 @@
104134104295
#endif
104135104296
104136104297
assert( pCsr->pKeyInfo );
104137104298
assert( !pCsr->isEphemeral );
104138104299
assert( pCsr->eCurType==CURTYPE_SORTER );
104300
+ assert( sizeof(KeyInfo) + UMXV(pCsr->pKeyInfo->nKeyField)*sizeof(CollSeq*)
104301
+ < 0x7fffffff );
104139104302
szKeyInfo = sizeof(KeyInfo) + (pCsr->pKeyInfo->nKeyField-1)*sizeof(CollSeq*);
104140104303
sz = sizeof(VdbeSorter) + nWorker * sizeof(SortSubtask);
104141104304
104142104305
pSorter = (VdbeSorter*)sqlite3DbMallocZero(db, sz + szKeyInfo);
104143104306
pCsr->uc.pSorter = pSorter;
@@ -104347,11 +104510,11 @@
104347104510
** nReader is automatically rounded up to the next power of two.
104348104511
** nReader may not exceed SORTER_MAX_MERGE_COUNT even after rounding up.
104349104512
*/
104350104513
static MergeEngine *vdbeMergeEngineNew(int nReader){
104351104514
int N = 2; /* Smallest power of two >= nReader */
104352
- int nByte; /* Total bytes of space to allocate */
104515
+ i64 nByte; /* Total bytes of space to allocate */
104353104516
MergeEngine *pNew; /* Pointer to allocated object to return */
104354104517
104355104518
assert( nReader<=SORTER_MAX_MERGE_COUNT );
104356104519
104357104520
while( N<nReader ) N += N;
@@ -107390,11 +107553,10 @@
107390107553
SrcItem *pMatch = 0; /* The matching pSrcList item */
107391107554
NameContext *pTopNC = pNC; /* First namecontext in the list */
107392107555
Schema *pSchema = 0; /* Schema of the expression */
107393107556
int eNewExprOp = TK_COLUMN; /* New value for pExpr->op on success */
107394107557
Table *pTab = 0; /* Table holding the row */
107395
- Column *pCol; /* A column of pTab */
107396107558
ExprList *pFJMatch = 0; /* Matches for FULL JOIN .. USING */
107397107559
const char *zCol = pRight->u.zToken;
107398107560
107399107561
assert( pNC ); /* the name context cannot be NULL. */
107400107562
assert( zCol ); /* The Z in X.Y.Z cannot be NULL */
@@ -107441,11 +107603,10 @@
107441107603
ExprList *pEList;
107442107604
SrcList *pSrcList = pNC->pSrcList;
107443107605
107444107606
if( pSrcList ){
107445107607
for(i=0, pItem=pSrcList->a; i<pSrcList->nSrc; i++, pItem++){
107446
- u8 hCol;
107447107608
pTab = pItem->pSTab;
107448107609
assert( pTab!=0 && pTab->zName!=0 );
107449107610
assert( pTab->nCol>0 || pParse->nErr );
107450107611
assert( (int)pItem->fg.isNestedFrom == IsNestedFrom(pItem));
107451107612
if( pItem->fg.isNestedFrom ){
@@ -107529,47 +107690,42 @@
107529107690
assert( ExprUseYTab(pExpr) );
107530107691
if( IN_RENAME_OBJECT && pItem->zAlias ){
107531107692
sqlite3RenameTokenRemap(pParse, 0, (void*)&pExpr->y.pTab);
107532107693
}
107533107694
}
107534
- hCol = sqlite3StrIHash(zCol);
107535
- for(j=0, pCol=pTab->aCol; j<pTab->nCol; j++, pCol++){
107536
- if( pCol->hName==hCol
107537
- && sqlite3StrICmp(pCol->zCnName, zCol)==0
107538
- ){
107539
- if( cnt>0 ){
107540
- if( pItem->fg.isUsing==0
107541
- || sqlite3IdListIndex(pItem->u3.pUsing, zCol)<0
107542
- ){
107543
- /* Two or more tables have the same column name which is
107544
- ** not joined by USING. This is an error. Signal as much
107545
- ** by clearing pFJMatch and letting cnt go above 1. */
107546
- sqlite3ExprListDelete(db, pFJMatch);
107547
- pFJMatch = 0;
107548
- }else
107549
- if( (pItem->fg.jointype & JT_RIGHT)==0 ){
107550
- /* An INNER or LEFT JOIN. Use the left-most table */
107551
- continue;
107552
- }else
107553
- if( (pItem->fg.jointype & JT_LEFT)==0 ){
107554
- /* A RIGHT JOIN. Use the right-most table */
107555
- cnt = 0;
107556
- sqlite3ExprListDelete(db, pFJMatch);
107557
- pFJMatch = 0;
107558
- }else{
107559
- /* For a FULL JOIN, we must construct a coalesce() func */
107560
- extendFJMatch(pParse, &pFJMatch, pMatch, pExpr->iColumn);
107561
- }
107562
- }
107563
- cnt++;
107564
- pMatch = pItem;
107565
- /* Substitute the rowid (column -1) for the INTEGER PRIMARY KEY */
107566
- pExpr->iColumn = j==pTab->iPKey ? -1 : (i16)j;
107567
- if( pItem->fg.isNestedFrom ){
107568
- sqlite3SrcItemColumnUsed(pItem, j);
107569
- }
107570
- break;
107695
+ j = sqlite3ColumnIndex(pTab, zCol);
107696
+ if( j>=0 ){
107697
+ if( cnt>0 ){
107698
+ if( pItem->fg.isUsing==0
107699
+ || sqlite3IdListIndex(pItem->u3.pUsing, zCol)<0
107700
+ ){
107701
+ /* Two or more tables have the same column name which is
107702
+ ** not joined by USING. This is an error. Signal as much
107703
+ ** by clearing pFJMatch and letting cnt go above 1. */
107704
+ sqlite3ExprListDelete(db, pFJMatch);
107705
+ pFJMatch = 0;
107706
+ }else
107707
+ if( (pItem->fg.jointype & JT_RIGHT)==0 ){
107708
+ /* An INNER or LEFT JOIN. Use the left-most table */
107709
+ continue;
107710
+ }else
107711
+ if( (pItem->fg.jointype & JT_LEFT)==0 ){
107712
+ /* A RIGHT JOIN. Use the right-most table */
107713
+ cnt = 0;
107714
+ sqlite3ExprListDelete(db, pFJMatch);
107715
+ pFJMatch = 0;
107716
+ }else{
107717
+ /* For a FULL JOIN, we must construct a coalesce() func */
107718
+ extendFJMatch(pParse, &pFJMatch, pMatch, pExpr->iColumn);
107719
+ }
107720
+ }
107721
+ cnt++;
107722
+ pMatch = pItem;
107723
+ /* Substitute the rowid (column -1) for the INTEGER PRIMARY KEY */
107724
+ pExpr->iColumn = j==pTab->iPKey ? -1 : (i16)j;
107725
+ if( pItem->fg.isNestedFrom ){
107726
+ sqlite3SrcItemColumnUsed(pItem, j);
107571107727
}
107572107728
}
107573107729
if( 0==cnt && VisibleRowid(pTab) ){
107574107730
/* pTab is a potential ROWID match. Keep track of it and match
107575107731
** the ROWID later if that seems appropriate. (Search for "cntTab"
@@ -107655,26 +107811,21 @@
107655107811
}
107656107812
#endif /* SQLITE_OMIT_UPSERT */
107657107813
107658107814
if( pTab ){
107659107815
int iCol;
107660
- u8 hCol = sqlite3StrIHash(zCol);
107661107816
pSchema = pTab->pSchema;
107662107817
cntTab++;
107663
- for(iCol=0, pCol=pTab->aCol; iCol<pTab->nCol; iCol++, pCol++){
107664
- if( pCol->hName==hCol
107665
- && sqlite3StrICmp(pCol->zCnName, zCol)==0
107666
- ){
107667
- if( iCol==pTab->iPKey ){
107668
- iCol = -1;
107669
- }
107670
- break;
107671
- }
107672
- }
107673
- if( iCol>=pTab->nCol && sqlite3IsRowid(zCol) && VisibleRowid(pTab) ){
107674
- /* IMP: R-51414-32910 */
107675
- iCol = -1;
107818
+ iCol = sqlite3ColumnIndex(pTab, zCol);
107819
+ if( iCol>=0 ){
107820
+ if( pTab->iPKey==iCol ) iCol = -1;
107821
+ }else{
107822
+ if( sqlite3IsRowid(zCol) && VisibleRowid(pTab) ){
107823
+ iCol = -1;
107824
+ }else{
107825
+ iCol = pTab->nCol;
107826
+ }
107676107827
}
107677107828
if( iCol<pTab->nCol ){
107678107829
cnt++;
107679107830
pMatch = 0;
107680107831
#ifndef SQLITE_OMIT_UPSERT
@@ -109896,11 +110047,11 @@
109896110047
p4 = sqlite3BinaryCompareCollSeq(pParse, pLeft, pRight);
109897110048
}
109898110049
p5 = binaryCompareP5(pLeft, pRight, jumpIfNull);
109899110050
addr = sqlite3VdbeAddOp4(pParse->pVdbe, opcode, in2, dest, in1,
109900110051
(void*)p4, P4_COLLSEQ);
109901
- sqlite3VdbeChangeP5(pParse->pVdbe, (u8)p5);
110052
+ sqlite3VdbeChangeP5(pParse->pVdbe, (u16)p5);
109902110053
return addr;
109903110054
}
109904110055
109905110056
/*
109906110057
** Return true if expression pExpr is a vector, or false otherwise.
@@ -111266,11 +111417,10 @@
111266111417
pNewExpr->pLeft = pPriorSelectColNew;
111267111418
}
111268111419
}
111269111420
pItem->zEName = sqlite3DbStrDup(db, pOldItem->zEName);
111270111421
pItem->fg = pOldItem->fg;
111271
- pItem->fg.done = 0;
111272111422
pItem->u = pOldItem->u;
111273111423
}
111274111424
return pNew;
111275111425
}
111276111426
@@ -111349,20 +111499,17 @@
111349111499
SQLITE_PRIVATE IdList *sqlite3IdListDup(sqlite3 *db, const IdList *p){
111350111500
IdList *pNew;
111351111501
int i;
111352111502
assert( db!=0 );
111353111503
if( p==0 ) return 0;
111354
- assert( p->eU4!=EU4_EXPR );
111355111504
pNew = sqlite3DbMallocRawNN(db, sizeof(*pNew)+(p->nId-1)*sizeof(p->a[0]) );
111356111505
if( pNew==0 ) return 0;
111357111506
pNew->nId = p->nId;
111358
- pNew->eU4 = p->eU4;
111359111507
for(i=0; i<p->nId; i++){
111360111508
struct IdList_item *pNewItem = &pNew->a[i];
111361111509
const struct IdList_item *pOldItem = &p->a[i];
111362111510
pNewItem->zName = sqlite3DbStrDup(db, pOldItem->zName);
111363
- pNewItem->u4 = pOldItem->u4;
111364111511
}
111365111512
return pNew;
111366111513
}
111367111514
SQLITE_PRIVATE Select *sqlite3SelectDup(sqlite3 *db, const Select *pDup, int flags){
111368111515
Select *pRet = 0;
@@ -112386,17 +112533,11 @@
112386112533
SQLITE_PRIVATE const char *sqlite3RowidAlias(Table *pTab){
112387112534
const char *azOpt[] = {"_ROWID_", "ROWID", "OID"};
112388112535
int ii;
112389112536
assert( VisibleRowid(pTab) );
112390112537
for(ii=0; ii<ArraySize(azOpt); ii++){
112391
- int iCol;
112392
- for(iCol=0; iCol<pTab->nCol; iCol++){
112393
- if( sqlite3_stricmp(azOpt[ii], pTab->aCol[iCol].zCnName)==0 ) break;
112394
- }
112395
- if( iCol==pTab->nCol ){
112396
- return azOpt[ii];
112397
- }
112538
+ if( sqlite3ColumnIndex(pTab, azOpt[ii])<0 ) return azOpt[ii];
112398112539
}
112399112540
return 0;
112400112541
}
112401112542
112402112543
/*
@@ -112702,10 +112843,11 @@
112702112843
if( mCol & colUsed ) break; /* Each column used only once */
112703112844
colUsed |= mCol;
112704112845
if( aiMap ) aiMap[i] = j;
112705112846
}
112706112847
112848
+ assert( nExpr>0 && nExpr<BMS );
112707112849
assert( i==nExpr || colUsed!=(MASKBIT(nExpr)-1) );
112708112850
if( colUsed==(MASKBIT(nExpr)-1) ){
112709112851
/* If we reach this point, that means the index pIdx is usable */
112710112852
int iAddr = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v);
112711112853
ExplainQueryPlan((pParse, 0,
@@ -112795,11 +112937,11 @@
112795112937
int nVal = sqlite3ExprVectorSize(pLeft);
112796112938
Select *pSelect = ExprUseXSelect(pExpr) ? pExpr->x.pSelect : 0;
112797112939
char *zRet;
112798112940
112799112941
assert( pExpr->op==TK_IN );
112800
- zRet = sqlite3DbMallocRaw(pParse->db, nVal+1);
112942
+ zRet = sqlite3DbMallocRaw(pParse->db, 1+(i64)nVal);
112801112943
if( zRet ){
112802112944
int i;
112803112945
for(i=0; i<nVal; i++){
112804112946
Expr *pA = sqlite3VectorFieldSubexpr(pLeft, i);
112805112947
char a = sqlite3ExprAffinity(pA);
@@ -112881,10 +113023,11 @@
112881113023
for(; pOp<pEnd; pOp++){
112882113024
if( pOp->p4type!=P4_SUBRTNSIG ) continue;
112883113025
assert( pOp->opcode==OP_BeginSubrtn );
112884113026
pSig = pOp->p4.pSubrtnSig;
112885113027
assert( pSig!=0 );
113028
+ if( !pSig->bComplete ) continue;
112886113029
if( pNewSig->selId!=pSig->selId ) continue;
112887113030
if( strcmp(pNewSig->zAff,pSig->zAff)!=0 ) continue;
112888113031
pExpr->y.sub.iAddr = pSig->iAddr;
112889113032
pExpr->y.sub.regReturn = pSig->regReturn;
112890113033
pExpr->iTable = pSig->iTable;
@@ -112927,10 +113070,11 @@
112927113070
int addr; /* Address of OP_OpenEphemeral instruction */
112928113071
Expr *pLeft; /* the LHS of the IN operator */
112929113072
KeyInfo *pKeyInfo = 0; /* Key information */
112930113073
int nVal; /* Size of vector pLeft */
112931113074
Vdbe *v; /* The prepared statement under construction */
113075
+ SubrtnSig *pSig = 0; /* Signature for this subroutine */
112932113076
112933113077
v = pParse->pVdbe;
112934113078
assert( v!=0 );
112935113079
112936113080
/* The evaluation of the IN must be repeated every time it
@@ -112947,11 +113091,10 @@
112947113091
/* Reuse of the RHS is allowed
112948113092
**
112949113093
** Compute a signature for the RHS of the IN operator to facility
112950113094
** finding and reusing prior instances of the same IN operator.
112951113095
*/
112952
- SubrtnSig *pSig = 0;
112953113096
assert( !ExprUseXSelect(pExpr) || pExpr->x.pSelect!=0 );
112954113097
if( ExprUseXSelect(pExpr) && (pExpr->x.pSelect->selFlags & SF_All)==0 ){
112955113098
pSig = sqlite3DbMallocRawNN(pParse->db, sizeof(pSig[0]));
112956113099
if( pSig ){
112957113100
pSig->selId = pExpr->x.pSelect->selId;
@@ -112990,10 +113133,11 @@
112990113133
assert( !ExprHasProperty(pExpr, EP_TokenOnly|EP_Reduced) );
112991113134
pExpr->y.sub.regReturn = ++pParse->nMem;
112992113135
pExpr->y.sub.iAddr =
112993113136
sqlite3VdbeAddOp2(v, OP_BeginSubrtn, 0, pExpr->y.sub.regReturn) + 1;
112994113137
if( pSig ){
113138
+ pSig->bComplete = 0;
112995113139
pSig->iAddr = pExpr->y.sub.iAddr;
112996113140
pSig->regReturn = pExpr->y.sub.regReturn;
112997113141
pSig->iTable = iTab;
112998113142
pParse->mSubrtnSig = 1 << (pSig->selId&7);
112999113143
sqlite3VdbeChangeP4(v, -1, (const char*)pSig, P4_SUBRTNSIG);
@@ -113125,10 +113269,11 @@
113125113269
sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iTab, r2, r1, 1);
113126113270
}
113127113271
sqlite3ReleaseTempReg(pParse, r1);
113128113272
sqlite3ReleaseTempReg(pParse, r2);
113129113273
}
113274
+ if( pSig ) pSig->bComplete = 1;
113130113275
if( pKeyInfo ){
113131113276
sqlite3VdbeChangeP4(v, addr, (void *)pKeyInfo, P4_KEYINFO);
113132113277
}
113133113278
if( addrOnce ){
113134113279
sqlite3VdbeAddOp1(v, OP_NullRow, iTab);
@@ -117437,14 +117582,12 @@
117437117582
117438117583
/* Make sure the old name really is a column name in the table to be
117439117584
** altered. Set iCol to be the index of the column being renamed */
117440117585
zOld = sqlite3NameFromToken(db, pOld);
117441117586
if( !zOld ) goto exit_rename_column;
117442
- for(iCol=0; iCol<pTab->nCol; iCol++){
117443
- if( 0==sqlite3StrICmp(pTab->aCol[iCol].zCnName, zOld) ) break;
117444
- }
117445
- if( iCol==pTab->nCol ){
117587
+ iCol = sqlite3ColumnIndex(pTab, zOld);
117588
+ if( iCol<0 ){
117446117589
sqlite3ErrorMsg(pParse, "no such column: \"%T\"", pOld);
117447117590
goto exit_rename_column;
117448117591
}
117449117592
117450117593
/* Ensure the schema contains no double-quoted strings */
@@ -119339,11 +119482,12 @@
119339119482
** of the new table in register pParse->regRoot. This is important
119340119483
** because the OpenWrite opcode below will be needing it. */
119341119484
sqlite3NestedParse(pParse,
119342119485
"CREATE TABLE %Q.%s(%s)", pDb->zDbSName, zTab, aTable[i].zCols
119343119486
);
119344
- aRoot[i] = (u32)pParse->regRoot;
119487
+ assert( pParse->isCreate || pParse->nErr );
119488
+ aRoot[i] = (u32)pParse->u1.cr.regRoot;
119345119489
aCreateTbl[i] = OPFLAG_P2ISREG;
119346119490
}
119347119491
}else{
119348119492
/* The table already exists. If zWhere is not NULL, delete all entries
119349119493
** associated with the table zWhere. If zWhere is NULL, delete the
@@ -119530,11 +119674,11 @@
119530119674
){
119531119675
StatAccum *p;
119532119676
int nCol; /* Number of columns in index being sampled */
119533119677
int nKeyCol; /* Number of key columns */
119534119678
int nColUp; /* nCol rounded up for alignment */
119535
- int n; /* Bytes of space to allocate */
119679
+ i64 n; /* Bytes of space to allocate */
119536119680
sqlite3 *db = sqlite3_context_db_handle(context); /* Database connection */
119537119681
#ifdef SQLITE_ENABLE_STAT4
119538119682
/* Maximum number of samples. 0 if STAT4 data is not collected */
119539119683
int mxSample = OptimizationEnabled(db,SQLITE_Stat4) ?SQLITE_STAT4_SAMPLES :0;
119540119684
#endif
@@ -121304,11 +121448,11 @@
121304121448
if( db->aDb==db->aDbStatic ){
121305121449
aNew = sqlite3DbMallocRawNN(db, sizeof(db->aDb[0])*3 );
121306121450
if( aNew==0 ) return;
121307121451
memcpy(aNew, db->aDb, sizeof(db->aDb[0])*2);
121308121452
}else{
121309
- aNew = sqlite3DbRealloc(db, db->aDb, sizeof(db->aDb[0])*(db->nDb+1) );
121453
+ aNew = sqlite3DbRealloc(db, db->aDb, sizeof(db->aDb[0])*(1+(i64)db->nDb));
121310121454
if( aNew==0 ) return;
121311121455
}
121312121456
db->aDb = aNew;
121313121457
pNew = &db->aDb[db->nDb];
121314121458
memset(pNew, 0, sizeof(*pNew));
@@ -121322,10 +121466,16 @@
121322121466
if( rc!=SQLITE_OK ){
121323121467
if( rc==SQLITE_NOMEM ) sqlite3OomFault(db);
121324121468
sqlite3_result_error(context, zErr, -1);
121325121469
sqlite3_free(zErr);
121326121470
return;
121471
+ }
121472
+ if( (db->flags & SQLITE_AttachWrite)==0 ){
121473
+ flags &= ~(SQLITE_OPEN_CREATE|SQLITE_OPEN_READWRITE);
121474
+ flags |= SQLITE_OPEN_READONLY;
121475
+ }else if( (db->flags & SQLITE_AttachCreate)==0 ){
121476
+ flags &= ~SQLITE_OPEN_CREATE;
121327121477
}
121328121478
assert( pVfs );
121329121479
flags |= SQLITE_OPEN_MAIN_DB;
121330121480
rc = sqlite3BtreeOpen(pVfs, zPath, db, &pNew->pBt, 0, flags);
121331121481
db->nDb++;
@@ -122091,10 +122241,11 @@
122091122241
p->isWriteLock = (p->isWriteLock || isWriteLock);
122092122242
return;
122093122243
}
122094122244
}
122095122245
122246
+ assert( pToplevel->nTableLock < 0x7fff0000 );
122096122247
nBytes = sizeof(TableLock) * (pToplevel->nTableLock+1);
122097122248
pToplevel->aTableLock =
122098122249
sqlite3DbReallocOrFree(pToplevel->db, pToplevel->aTableLock, nBytes);
122099122250
if( pToplevel->aTableLock ){
122100122251
p = &pToplevel->aTableLock[pToplevel->nTableLock++];
@@ -122191,14 +122342,16 @@
122191122342
}
122192122343
assert( !pParse->isMultiWrite
122193122344
|| sqlite3VdbeAssertMayAbort(v, pParse->mayAbort));
122194122345
if( v ){
122195122346
if( pParse->bReturning ){
122196
- Returning *pReturning = pParse->u1.pReturning;
122347
+ Returning *pReturning;
122197122348
int addrRewind;
122198122349
int reg;
122199122350
122351
+ assert( !pParse->isCreate );
122352
+ pReturning = pParse->u1.d.pReturning;
122200122353
if( pReturning->nRetCol ){
122201122354
sqlite3VdbeAddOp0(v, OP_FkCheck);
122202122355
addrRewind =
122203122356
sqlite3VdbeAddOp1(v, OP_Rewind, pReturning->iRetCur);
122204122357
VdbeCoverage(v);
@@ -122270,11 +122423,13 @@
122270122423
sqlite3ExprCode(pParse, pEL->a[i].pExpr, pEL->a[i].u.iConstExprReg);
122271122424
}
122272122425
}
122273122426
122274122427
if( pParse->bReturning ){
122275
- Returning *pRet = pParse->u1.pReturning;
122428
+ Returning *pRet;
122429
+ assert( !pParse->isCreate );
122430
+ pRet = pParse->u1.d.pReturning;
122276122431
if( pRet->nRetCol ){
122277122432
sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pRet->iRetCur, pRet->nRetCol);
122278122433
}
122279122434
}
122280122435
@@ -123342,12 +123497,13 @@
123342123497
#endif
123343123498
123344123499
/* If the file format and encoding in the database have not been set,
123345123500
** set them now.
123346123501
*/
123347
- reg1 = pParse->regRowid = ++pParse->nMem;
123348
- reg2 = pParse->regRoot = ++pParse->nMem;
123502
+ assert( pParse->isCreate );
123503
+ reg1 = pParse->u1.cr.regRowid = ++pParse->nMem;
123504
+ reg2 = pParse->u1.cr.regRoot = ++pParse->nMem;
123349123505
reg3 = ++pParse->nMem;
123350123506
sqlite3VdbeAddOp3(v, OP_ReadCookie, iDb, reg3, BTREE_FILE_FORMAT);
123351123507
sqlite3VdbeUsesBtree(v, iDb);
123352123508
addr1 = sqlite3VdbeAddOp1(v, OP_If, reg3); VdbeCoverage(v);
123353123509
fileFormat = (db->flags & SQLITE_LegacyFileFmt)!=0 ?
@@ -123358,12 +123514,12 @@
123358123514
123359123515
/* This just creates a place-holder record in the sqlite_schema table.
123360123516
** The record created does not contain anything yet. It will be replaced
123361123517
** by the real entry in code generated at sqlite3EndTable().
123362123518
**
123363
- ** The rowid for the new entry is left in register pParse->regRowid.
123364
- ** The root page number of the new table is left in reg pParse->regRoot.
123519
+ ** The rowid for the new entry is left in register pParse->u1.cr.regRowid.
123520
+ ** The root page of the new table is left in reg pParse->u1.cr.regRoot.
123365123521
** The rowid and root page number values are needed by the code that
123366123522
** sqlite3EndTable will generate.
123367123523
*/
123368123524
#if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_VIRTUALTABLE)
123369123525
if( isView || isVirtual ){
@@ -123370,11 +123526,11 @@
123370123526
sqlite3VdbeAddOp2(v, OP_Integer, 0, reg2);
123371123527
}else
123372123528
#endif
123373123529
{
123374123530
assert( !pParse->bReturning );
123375
- pParse->u1.addrCrTab =
123531
+ pParse->u1.cr.addrCrTab =
123376123532
sqlite3VdbeAddOp3(v, OP_CreateBtree, iDb, reg2, BTREE_INTKEY);
123377123533
}
123378123534
sqlite3OpenSchemaTable(pParse, iDb);
123379123535
sqlite3VdbeAddOp2(v, OP_NewRowid, 0, reg1);
123380123536
sqlite3VdbeAddOp4(v, OP_Blob, 6, reg3, 0, nullRow, P4_STATIC);
@@ -123448,11 +123604,12 @@
123448123604
pRet = sqlite3DbMallocZero(db, sizeof(*pRet));
123449123605
if( pRet==0 ){
123450123606
sqlite3ExprListDelete(db, pList);
123451123607
return;
123452123608
}
123453
- pParse->u1.pReturning = pRet;
123609
+ assert( !pParse->isCreate );
123610
+ pParse->u1.d.pReturning = pRet;
123454123611
pRet->pParse = pParse;
123455123612
pRet->pReturnEL = pList;
123456123613
sqlite3ParserAddCleanup(pParse, sqlite3DeleteReturning, pRet);
123457123614
testcase( pParse->earlyCleanup );
123458123615
if( db->mallocFailed ) return;
@@ -123490,11 +123647,10 @@
123490123647
int i;
123491123648
char *z;
123492123649
char *zType;
123493123650
Column *pCol;
123494123651
sqlite3 *db = pParse->db;
123495
- u8 hName;
123496123652
Column *aNew;
123497123653
u8 eType = COLTYPE_CUSTOM;
123498123654
u8 szEst = 1;
123499123655
char affinity = SQLITE_AFF_BLOB;
123500123656
@@ -123544,17 +123700,14 @@
123544123700
if( z==0 ) return;
123545123701
if( IN_RENAME_OBJECT ) sqlite3RenameTokenMap(pParse, (void*)z, &sName);
123546123702
memcpy(z, sName.z, sName.n);
123547123703
z[sName.n] = 0;
123548123704
sqlite3Dequote(z);
123549
- hName = sqlite3StrIHash(z);
123550
- for(i=0; i<p->nCol; i++){
123551
- if( p->aCol[i].hName==hName && sqlite3StrICmp(z, p->aCol[i].zCnName)==0 ){
123552
- sqlite3ErrorMsg(pParse, "duplicate column name: %s", z);
123553
- sqlite3DbFree(db, z);
123554
- return;
123555
- }
123705
+ if( p->nCol && sqlite3ColumnIndex(p, z)>=0 ){
123706
+ sqlite3ErrorMsg(pParse, "duplicate column name: %s", z);
123707
+ sqlite3DbFree(db, z);
123708
+ return;
123556123709
}
123557123710
aNew = sqlite3DbRealloc(db,p->aCol,((i64)p->nCol+1)*sizeof(p->aCol[0]));
123558123711
if( aNew==0 ){
123559123712
sqlite3DbFree(db, z);
123560123713
return;
@@ -123561,11 +123714,11 @@
123561123714
}
123562123715
p->aCol = aNew;
123563123716
pCol = &p->aCol[p->nCol];
123564123717
memset(pCol, 0, sizeof(p->aCol[0]));
123565123718
pCol->zCnName = z;
123566
- pCol->hName = hName;
123719
+ pCol->hName = sqlite3StrIHash(z);
123567123720
sqlite3ColumnPropertiesFromName(p, pCol);
123568123721
123569123722
if( sType.n==0 ){
123570123723
/* If there is no type specified, columns have the default affinity
123571123724
** 'BLOB' with a default size of 4 bytes. */
@@ -123585,13 +123738,18 @@
123585123738
zType[sType.n] = 0;
123586123739
sqlite3Dequote(zType);
123587123740
pCol->affinity = sqlite3AffinityType(zType, pCol);
123588123741
pCol->colFlags |= COLFLAG_HASTYPE;
123589123742
}
123743
+ if( p->nCol<=0xff ){
123744
+ u8 h = pCol->hName % sizeof(p->aHx);
123745
+ p->aHx[h] = p->nCol;
123746
+ }
123590123747
p->nCol++;
123591123748
p->nNVCol++;
123592
- pParse->constraintName.n = 0;
123749
+ assert( pParse->isCreate );
123750
+ pParse->u1.cr.constraintName.n = 0;
123593123751
}
123594123752
123595123753
/*
123596123754
** This routine is called by the parser while in the middle of
123597123755
** parsing a CREATE TABLE statement. A "NOT NULL" constraint has
@@ -123851,19 +124009,15 @@
123851124009
for(i=0; i<nTerm; i++){
123852124010
Expr *pCExpr = sqlite3ExprSkipCollate(pList->a[i].pExpr);
123853124011
assert( pCExpr!=0 );
123854124012
sqlite3StringToId(pCExpr);
123855124013
if( pCExpr->op==TK_ID ){
123856
- const char *zCName;
123857124014
assert( !ExprHasProperty(pCExpr, EP_IntValue) );
123858
- zCName = pCExpr->u.zToken;
123859
- for(iCol=0; iCol<pTab->nCol; iCol++){
123860
- if( sqlite3StrICmp(zCName, pTab->aCol[iCol].zCnName)==0 ){
123861
- pCol = &pTab->aCol[iCol];
123862
- makeColumnPartOfPrimaryKey(pParse, pCol);
123863
- break;
123864
- }
124015
+ iCol = sqlite3ColumnIndex(pTab, pCExpr->u.zToken);
124016
+ if( iCol>=0 ){
124017
+ pCol = &pTab->aCol[iCol];
124018
+ makeColumnPartOfPrimaryKey(pParse, pCol);
123865124019
}
123866124020
}
123867124021
}
123868124022
}
123869124023
if( nTerm==1
@@ -123911,12 +124065,14 @@
123911124065
sqlite3 *db = pParse->db;
123912124066
if( pTab && !IN_DECLARE_VTAB
123913124067
&& !sqlite3BtreeIsReadonly(db->aDb[db->init.iDb].pBt)
123914124068
){
123915124069
pTab->pCheck = sqlite3ExprListAppend(pParse, pTab->pCheck, pCheckExpr);
123916
- if( pParse->constraintName.n ){
123917
- sqlite3ExprListSetName(pParse, pTab->pCheck, &pParse->constraintName, 1);
124070
+ assert( pParse->isCreate );
124071
+ if( pParse->u1.cr.constraintName.n ){
124072
+ sqlite3ExprListSetName(pParse, pTab->pCheck,
124073
+ &pParse->u1.cr.constraintName, 1);
123918124074
}else{
123919124075
Token t;
123920124076
for(zStart++; sqlite3Isspace(zStart[0]); zStart++){}
123921124077
while( sqlite3Isspace(zEnd[-1]) ){ zEnd--; }
123922124078
t.z = zStart;
@@ -124107,11 +124263,12 @@
124107124263
** Generate a CREATE TABLE statement appropriate for the given
124108124264
** table. Memory to hold the text of the statement is obtained
124109124265
** from sqliteMalloc() and must be freed by the calling function.
124110124266
*/
124111124267
static char *createTableStmt(sqlite3 *db, Table *p){
124112
- int i, k, n;
124268
+ int i, k, len;
124269
+ i64 n;
124113124270
char *zStmt;
124114124271
char *zSep, *zSep2, *zEnd;
124115124272
Column *pCol;
124116124273
n = 0;
124117124274
for(pCol = p->aCol, i=0; i<p->nCol; i++, pCol++){
@@ -124131,12 +124288,13 @@
124131124288
zStmt = sqlite3DbMallocRaw(0, n);
124132124289
if( zStmt==0 ){
124133124290
sqlite3OomFault(db);
124134124291
return 0;
124135124292
}
124136
- sqlite3_snprintf(n, zStmt, "CREATE TABLE ");
124137
- k = sqlite3Strlen30(zStmt);
124293
+ assert( n>14 && n<=0x7fffffff );
124294
+ memcpy(zStmt, "CREATE TABLE ", 13);
124295
+ k = 13;
124138124296
identPut(zStmt, &k, p->zName);
124139124297
zStmt[k++] = '(';
124140124298
for(pCol=p->aCol, i=0; i<p->nCol; i++, pCol++){
124141124299
static const char * const azType[] = {
124142124300
/* SQLITE_AFF_BLOB */ "",
@@ -124144,17 +124302,19 @@
124144124302
/* SQLITE_AFF_NUMERIC */ " NUM",
124145124303
/* SQLITE_AFF_INTEGER */ " INT",
124146124304
/* SQLITE_AFF_REAL */ " REAL",
124147124305
/* SQLITE_AFF_FLEXNUM */ " NUM",
124148124306
};
124149
- int len;
124150124307
const char *zType;
124151124308
124152
- sqlite3_snprintf(n-k, &zStmt[k], zSep);
124153
- k += sqlite3Strlen30(&zStmt[k]);
124309
+ len = sqlite3Strlen30(zSep);
124310
+ assert( k+len<n );
124311
+ memcpy(&zStmt[k], zSep, len);
124312
+ k += len;
124154124313
zSep = zSep2;
124155124314
identPut(zStmt, &k, pCol->zCnName);
124315
+ assert( k<n );
124156124316
assert( pCol->affinity-SQLITE_AFF_BLOB >= 0 );
124157124317
assert( pCol->affinity-SQLITE_AFF_BLOB < ArraySize(azType) );
124158124318
testcase( pCol->affinity==SQLITE_AFF_BLOB );
124159124319
testcase( pCol->affinity==SQLITE_AFF_TEXT );
124160124320
testcase( pCol->affinity==SQLITE_AFF_NUMERIC );
@@ -124165,15 +124325,18 @@
124165124325
zType = azType[pCol->affinity - SQLITE_AFF_BLOB];
124166124326
len = sqlite3Strlen30(zType);
124167124327
assert( pCol->affinity==SQLITE_AFF_BLOB
124168124328
|| pCol->affinity==SQLITE_AFF_FLEXNUM
124169124329
|| pCol->affinity==sqlite3AffinityType(zType, 0) );
124330
+ assert( k+len<n );
124170124331
memcpy(&zStmt[k], zType, len);
124171124332
k += len;
124172124333
assert( k<=n );
124173124334
}
124174
- sqlite3_snprintf(n-k, &zStmt[k], "%s", zEnd);
124335
+ len = sqlite3Strlen30(zEnd);
124336
+ assert( k+len<n );
124337
+ memcpy(&zStmt[k], zEnd, len+1);
124175124338
return zStmt;
124176124339
}
124177124340
124178124341
/*
124179124342
** Resize an Index object to hold N columns total. Return SQLITE_OK
@@ -124362,13 +124525,13 @@
124362124525
124363124526
/* Convert the P3 operand of the OP_CreateBtree opcode from BTREE_INTKEY
124364124527
** into BTREE_BLOBKEY.
124365124528
*/
124366124529
assert( !pParse->bReturning );
124367
- if( pParse->u1.addrCrTab ){
124530
+ if( pParse->u1.cr.addrCrTab ){
124368124531
assert( v );
124369
- sqlite3VdbeChangeP3(v, pParse->u1.addrCrTab, BTREE_BLOBKEY);
124532
+ sqlite3VdbeChangeP3(v, pParse->u1.cr.addrCrTab, BTREE_BLOBKEY);
124370124533
}
124371124534
124372124535
/* Locate the PRIMARY KEY index. Or, if this table was originally
124373124536
** an INTEGER PRIMARY KEY table, create a new PRIMARY KEY index.
124374124537
*/
@@ -124804,11 +124967,11 @@
124804124967
#endif
124805124968
}
124806124969
124807124970
/* If this is a CREATE TABLE xx AS SELECT ..., execute the SELECT
124808124971
** statement to populate the new table. The root-page number for the
124809
- ** new table is in register pParse->regRoot.
124972
+ ** new table is in register pParse->u1.cr.regRoot.
124810124973
**
124811124974
** Once the SELECT has been coded by sqlite3Select(), it is in a
124812124975
** suitable state to query for the column names and types to be used
124813124976
** by the new table.
124814124977
**
@@ -124835,11 +124998,12 @@
124835124998
iCsr = pParse->nTab++;
124836124999
regYield = ++pParse->nMem;
124837125000
regRec = ++pParse->nMem;
124838125001
regRowid = ++pParse->nMem;
124839125002
sqlite3MayAbort(pParse);
124840
- sqlite3VdbeAddOp3(v, OP_OpenWrite, iCsr, pParse->regRoot, iDb);
125003
+ assert( pParse->isCreate );
125004
+ sqlite3VdbeAddOp3(v, OP_OpenWrite, iCsr, pParse->u1.cr.regRoot, iDb);
124841125005
sqlite3VdbeChangeP5(v, OPFLAG_P2ISREG);
124842125006
addrTop = sqlite3VdbeCurrentAddr(v) + 1;
124843125007
sqlite3VdbeAddOp3(v, OP_InitCoroutine, regYield, 0, addrTop);
124844125008
if( pParse->nErr ) return;
124845125009
pSelTab = sqlite3ResultSetOfSelect(pParse, pSelect, SQLITE_AFF_BLOB);
@@ -124880,21 +125044,22 @@
124880125044
124881125045
/* A slot for the record has already been allocated in the
124882125046
** schema table. We just need to update that slot with all
124883125047
** the information we've collected.
124884125048
*/
125049
+ assert( pParse->isCreate );
124885125050
sqlite3NestedParse(pParse,
124886125051
"UPDATE %Q." LEGACY_SCHEMA_TABLE
124887125052
" SET type='%s', name=%Q, tbl_name=%Q, rootpage=#%d, sql=%Q"
124888125053
" WHERE rowid=#%d",
124889125054
db->aDb[iDb].zDbSName,
124890125055
zType,
124891125056
p->zName,
124892125057
p->zName,
124893
- pParse->regRoot,
125058
+ pParse->u1.cr.regRoot,
124894125059
zStmt,
124895
- pParse->regRowid
125060
+ pParse->u1.cr.regRowid
124896125061
);
124897125062
sqlite3DbFree(db, zStmt);
124898125063
sqlite3ChangeCookie(pParse, iDb);
124899125064
124900125065
#ifndef SQLITE_OMIT_AUTOINCREMENT
@@ -125861,11 +126026,11 @@
125861126026
i16 nCol, /* Total number of columns in the index */
125862126027
int nExtra, /* Number of bytes of extra space to alloc */
125863126028
char **ppExtra /* Pointer to the "extra" space */
125864126029
){
125865126030
Index *p; /* Allocated index object */
125866
- int nByte; /* Bytes of space for Index object + arrays */
126031
+ i64 nByte; /* Bytes of space for Index object + arrays */
125867126032
125868126033
nByte = ROUND8(sizeof(Index)) + /* Index structure */
125869126034
ROUND8(sizeof(char*)*nCol) + /* Index.azColl */
125870126035
ROUND8(sizeof(LogEst)*(nCol+1) + /* Index.aiRowLogEst */
125871126036
sizeof(i16)*nCol + /* Index.aiColumn */
@@ -126714,11 +126879,10 @@
126714126879
*/
126715126880
SQLITE_PRIVATE void sqlite3IdListDelete(sqlite3 *db, IdList *pList){
126716126881
int i;
126717126882
assert( db!=0 );
126718126883
if( pList==0 ) return;
126719
- assert( pList->eU4!=EU4_EXPR ); /* EU4_EXPR mode is not currently used */
126720126884
for(i=0; i<pList->nId; i++){
126721126885
sqlite3DbFree(db, pList->a[i].zName);
126722126886
}
126723126887
sqlite3DbNNFreeNN(db, pList);
126724126888
}
@@ -128095,16 +128259,22 @@
128095128259
FuncDef *p, /* The function we are evaluating for match quality */
128096128260
int nArg, /* Desired number of arguments. (-1)==any */
128097128261
u8 enc /* Desired text encoding */
128098128262
){
128099128263
int match;
128100
- assert( p->nArg>=-1 );
128264
+ assert( p->nArg>=(-4) && p->nArg!=(-2) );
128265
+ assert( nArg>=(-2) );
128101128266
128102128267
/* Wrong number of arguments means "no match" */
128103128268
if( p->nArg!=nArg ){
128104
- if( nArg==(-2) ) return (p->xSFunc==0) ? 0 : FUNC_PERFECT_MATCH;
128269
+ if( nArg==(-2) ) return p->xSFunc==0 ? 0 : FUNC_PERFECT_MATCH;
128105128270
if( p->nArg>=0 ) return 0;
128271
+ /* Special p->nArg values available to built-in functions only:
128272
+ ** -3 1 or more arguments required
128273
+ ** -4 2 or more arguments required
128274
+ */
128275
+ if( p->nArg<(-2) && nArg<(-2-p->nArg) ) return 0;
128106128276
}
128107128277
128108128278
/* Give a better score to a function with a specific number of arguments
128109128279
** than to function that accepts any number of arguments. */
128110128280
if( p->nArg==nArg ){
@@ -129723,20 +129893,14 @@
129723129893
const unsigned char *z;
129724129894
const unsigned char *z2;
129725129895
int len;
129726129896
int p0type;
129727129897
i64 p1, p2;
129728
- int negP2 = 0;
129729129898
129730129899
assert( argc==3 || argc==2 );
129731
- if( sqlite3_value_type(argv[1])==SQLITE_NULL
129732
- || (argc==3 && sqlite3_value_type(argv[2])==SQLITE_NULL)
129733
- ){
129734
- return;
129735
- }
129736129900
p0type = sqlite3_value_type(argv[0]);
129737
- p1 = sqlite3_value_int(argv[1]);
129901
+ p1 = sqlite3_value_int64(argv[1]);
129738129902
if( p0type==SQLITE_BLOB ){
129739129903
len = sqlite3_value_bytes(argv[0]);
129740129904
z = sqlite3_value_blob(argv[0]);
129741129905
if( z==0 ) return;
129742129906
assert( len==sqlite3_value_bytes(argv[0]) );
@@ -129748,45 +129912,49 @@
129748129912
for(z2=z; *z2; len++){
129749129913
SQLITE_SKIP_UTF8(z2);
129750129914
}
129751129915
}
129752129916
}
129753
-#ifdef SQLITE_SUBSTR_COMPATIBILITY
129754
- /* If SUBSTR_COMPATIBILITY is defined then substr(X,0,N) work the same as
129755
- ** as substr(X,1,N) - it returns the first N characters of X. This
129756
- ** is essentially a back-out of the bug-fix in check-in [5fc125d362df4b8]
129757
- ** from 2009-02-02 for compatibility of applications that exploited the
129758
- ** old buggy behavior. */
129759
- if( p1==0 ) p1 = 1; /* <rdar://problem/6778339> */
129760
-#endif
129761129917
if( argc==3 ){
129762
- p2 = sqlite3_value_int(argv[2]);
129763
- if( p2<0 ){
129764
- p2 = -p2;
129765
- negP2 = 1;
129766
- }
129918
+ p2 = sqlite3_value_int64(argv[2]);
129919
+ if( p2==0 && sqlite3_value_type(argv[2])==SQLITE_NULL ) return;
129767129920
}else{
129768129921
p2 = sqlite3_context_db_handle(context)->aLimit[SQLITE_LIMIT_LENGTH];
129769129922
}
129923
+ if( p1==0 ){
129924
+#ifdef SQLITE_SUBSTR_COMPATIBILITY
129925
+ /* If SUBSTR_COMPATIBILITY is defined then substr(X,0,N) work the same as
129926
+ ** as substr(X,1,N) - it returns the first N characters of X. This
129927
+ ** is essentially a back-out of the bug-fix in check-in [5fc125d362df4b8]
129928
+ ** from 2009-02-02 for compatibility of applications that exploited the
129929
+ ** old buggy behavior. */
129930
+ p1 = 1; /* <rdar://problem/6778339> */
129931
+#endif
129932
+ if( sqlite3_value_type(argv[1])==SQLITE_NULL ) return;
129933
+ }
129770129934
if( p1<0 ){
129771129935
p1 += len;
129772129936
if( p1<0 ){
129773
- p2 += p1;
129774
- if( p2<0 ) p2 = 0;
129937
+ if( p2<0 ){
129938
+ p2 = 0;
129939
+ }else{
129940
+ p2 += p1;
129941
+ }
129775129942
p1 = 0;
129776129943
}
129777129944
}else if( p1>0 ){
129778129945
p1--;
129779129946
}else if( p2>0 ){
129780129947
p2--;
129781129948
}
129782
- if( negP2 ){
129949
+ if( p2<0 ){
129950
+ if( p2<-p1 ){
129951
+ p2 = p1;
129952
+ }else{
129953
+ p2 = -p2;
129954
+ }
129783129955
p1 -= p2;
129784
- if( p1<0 ){
129785
- p2 += p1;
129786
- p1 = 0;
129787
- }
129788129956
}
129789129957
assert( p1>=0 && p2>=0 );
129790129958
if( p0type!=SQLITE_BLOB ){
129791129959
while( *z && p1 ){
129792129960
SQLITE_SKIP_UTF8(z);
@@ -129796,13 +129964,15 @@
129796129964
SQLITE_SKIP_UTF8(z2);
129797129965
}
129798129966
sqlite3_result_text64(context, (char*)z, z2-z, SQLITE_TRANSIENT,
129799129967
SQLITE_UTF8);
129800129968
}else{
129801
- if( p1+p2>len ){
129969
+ if( p1>=len ){
129970
+ p1 = p2 = 0;
129971
+ }else if( p2>len-p1 ){
129802129972
p2 = len-p1;
129803
- if( p2<0 ) p2 = 0;
129973
+ assert( p2>0 );
129804129974
}
129805129975
sqlite3_result_blob64(context, (char*)&z[p1], (u64)p2, SQLITE_TRANSIENT);
129806129976
}
129807129977
}
129808129978
@@ -129809,17 +129979,17 @@
129809129979
/*
129810129980
** Implementation of the round() function
129811129981
*/
129812129982
#ifndef SQLITE_OMIT_FLOATING_POINT
129813129983
static void roundFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
129814
- int n = 0;
129984
+ i64 n = 0;
129815129985
double r;
129816129986
char *zBuf;
129817129987
assert( argc==1 || argc==2 );
129818129988
if( argc==2 ){
129819129989
if( SQLITE_NULL==sqlite3_value_type(argv[1]) ) return;
129820
- n = sqlite3_value_int(argv[1]);
129990
+ n = sqlite3_value_int64(argv[1]);
129821129991
if( n>30 ) n = 30;
129822129992
if( n<0 ) n = 0;
129823129993
}
129824129994
if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return;
129825129995
r = sqlite3_value_double(argv[0]);
@@ -129830,11 +130000,11 @@
129830130000
if( r<-4503599627370496.0 || r>+4503599627370496.0 ){
129831130001
/* The value has no fractional part so there is nothing to round */
129832130002
}else if( n==0 ){
129833130003
r = (double)((sqlite_int64)(r+(r<0?-0.5:+0.5)));
129834130004
}else{
129835
- zBuf = sqlite3_mprintf("%!.*f",n,r);
130005
+ zBuf = sqlite3_mprintf("%!.*f",(int)n,r);
129836130006
if( zBuf==0 ){
129837130007
sqlite3_result_error_nomem(context);
129838130008
return;
129839130009
}
129840130010
sqlite3AtoF(zBuf, &r, sqlite3Strlen30(zBuf), SQLITE_UTF8);
@@ -130789,11 +130959,11 @@
130789130959
if( zRep==0 ) return;
130790130960
nRep = sqlite3_value_bytes(argv[2]);
130791130961
assert( zRep==sqlite3_value_text(argv[2]) );
130792130962
nOut = nStr + 1;
130793130963
assert( nOut<SQLITE_MAX_LENGTH );
130794
- zOut = contextMalloc(context, (i64)nOut);
130964
+ zOut = contextMalloc(context, nOut);
130795130965
if( zOut==0 ){
130796130966
return;
130797130967
}
130798130968
loopLimit = nStr - nPattern;
130799130969
cntExpand = 0;
@@ -130939,11 +131109,11 @@
130939131109
int i;
130940131110
char *z;
130941131111
for(i=0; i<argc; i++){
130942131112
n += sqlite3_value_bytes(argv[i]);
130943131113
}
130944
- n += (argc-1)*nSep;
131114
+ n += (argc-1)*(i64)nSep;
130945131115
z = sqlite3_malloc64(n+1);
130946131116
if( z==0 ){
130947131117
sqlite3_result_error_nomem(context);
130948131118
return;
130949131119
}
@@ -131237,11 +131407,14 @@
131237131407
** to initialize it */
131238131408
if( ALWAYS(p) && type!=SQLITE_NULL ){
131239131409
assert( p->cnt>0 );
131240131410
p->cnt--;
131241131411
if( !p->approx ){
131242
- p->iSum -= sqlite3_value_int64(argv[0]);
131412
+ if( sqlite3SubInt64(&p->iSum, sqlite3_value_int64(argv[0])) ){
131413
+ p->ovrfl = 1;
131414
+ p->approx = 1;
131415
+ }
131243131416
}else if( type==SQLITE_INTEGER ){
131244131417
i64 iVal = sqlite3_value_int64(argv[0]);
131245131418
if( iVal!=SMALLEST_INT64 ){
131246131419
kahanBabuskaNeumaierStepInt64(p, -iVal);
131247131420
}else{
@@ -132063,16 +132236,14 @@
132063132236
FUNCTION(ltrim, 2, 1, 0, trimFunc ),
132064132237
FUNCTION(rtrim, 1, 2, 0, trimFunc ),
132065132238
FUNCTION(rtrim, 2, 2, 0, trimFunc ),
132066132239
FUNCTION(trim, 1, 3, 0, trimFunc ),
132067132240
FUNCTION(trim, 2, 3, 0, trimFunc ),
132068
- FUNCTION(min, -1, 0, 1, minmaxFunc ),
132069
- FUNCTION(min, 0, 0, 1, 0 ),
132241
+ FUNCTION(min, -3, 0, 1, minmaxFunc ),
132070132242
WAGGREGATE(min, 1, 0, 1, minmaxStep, minMaxFinalize, minMaxValue, 0,
132071132243
SQLITE_FUNC_MINMAX|SQLITE_FUNC_ANYORDER ),
132072
- FUNCTION(max, -1, 1, 1, minmaxFunc ),
132073
- FUNCTION(max, 0, 1, 1, 0 ),
132244
+ FUNCTION(max, -3, 1, 1, minmaxFunc ),
132074132245
WAGGREGATE(max, 1, 1, 1, minmaxStep, minMaxFinalize, minMaxValue, 0,
132075132246
SQLITE_FUNC_MINMAX|SQLITE_FUNC_ANYORDER ),
132076132247
FUNCTION2(typeof, 1, 0, 0, typeofFunc, SQLITE_FUNC_TYPEOF),
132077132248
FUNCTION2(subtype, 1, 0, 0, subtypeFunc,
132078132249
SQLITE_FUNC_TYPEOF|SQLITE_SUBTYPE),
@@ -132095,15 +132266,12 @@
132095132266
FUNCTION(upper, 1, 0, 0, upperFunc ),
132096132267
FUNCTION(lower, 1, 0, 0, lowerFunc ),
132097132268
FUNCTION(hex, 1, 0, 0, hexFunc ),
132098132269
FUNCTION(unhex, 1, 0, 0, unhexFunc ),
132099132270
FUNCTION(unhex, 2, 0, 0, unhexFunc ),
132100
- FUNCTION(concat, -1, 0, 0, concatFunc ),
132101
- FUNCTION(concat, 0, 0, 0, 0 ),
132102
- FUNCTION(concat_ws, -1, 0, 0, concatwsFunc ),
132103
- FUNCTION(concat_ws, 0, 0, 0, 0 ),
132104
- FUNCTION(concat_ws, 1, 0, 0, 0 ),
132271
+ FUNCTION(concat, -3, 0, 0, concatFunc ),
132272
+ FUNCTION(concat_ws, -4, 0, 0, concatwsFunc ),
132105132273
INLINE_FUNC(ifnull, 2, INLINEFUNC_coalesce, 0 ),
132106132274
VFUNCTION(random, 0, 0, 0, randomFunc ),
132107132275
VFUNCTION(randomblob, 1, 0, 0, randomBlob ),
132108132276
FUNCTION(nullif, 2, 0, 1, nullifFunc ),
132109132277
DFUNCTION(sqlite_version, 0, 0, 0, versionFunc ),
@@ -132143,12 +132311,10 @@
132143132311
LIKEFUNC(like, 3, &likeInfoNorm, SQLITE_FUNC_LIKE),
132144132312
#endif
132145132313
#ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION
132146132314
FUNCTION(unknown, -1, 0, 0, unknownFunc ),
132147132315
#endif
132148
- FUNCTION(coalesce, 1, 0, 0, 0 ),
132149
- FUNCTION(coalesce, 0, 0, 0, 0 ),
132150132316
#ifdef SQLITE_ENABLE_MATH_FUNCTIONS
132151132317
MFUNCTION(ceil, 1, xCeil, ceilingFunc ),
132152132318
MFUNCTION(ceiling, 1, xCeil, ceilingFunc ),
132153132319
MFUNCTION(floor, 1, xFloor, ceilingFunc ),
132154132320
#if SQLITE_HAVE_C99_MATH_FUNCS
@@ -132182,15 +132348,13 @@
132182132348
MFUNCTION(radians, 1, degToRad, math1Func ),
132183132349
MFUNCTION(degrees, 1, radToDeg, math1Func ),
132184132350
MFUNCTION(pi, 0, 0, piFunc ),
132185132351
#endif /* SQLITE_ENABLE_MATH_FUNCTIONS */
132186132352
FUNCTION(sign, 1, 0, 0, signFunc ),
132187
- INLINE_FUNC(coalesce, -1, INLINEFUNC_coalesce, 0 ),
132188
- INLINE_FUNC(iif, 2, INLINEFUNC_iif, 0 ),
132189
- INLINE_FUNC(iif, 3, INLINEFUNC_iif, 0 ),
132190
- INLINE_FUNC(if, 2, INLINEFUNC_iif, 0 ),
132191
- INLINE_FUNC(if, 3, INLINEFUNC_iif, 0 ),
132353
+ INLINE_FUNC(coalesce, -4, INLINEFUNC_coalesce, 0 ),
132354
+ INLINE_FUNC(iif, -4, INLINEFUNC_iif, 0 ),
132355
+ INLINE_FUNC(if, -4, INLINEFUNC_iif, 0 ),
132192132356
};
132193132357
#ifndef SQLITE_OMIT_ALTERTABLE
132194132358
sqlite3AlterFunctions();
132195132359
#endif
132196132360
sqlite3WindowFunctions();
@@ -134632,10 +134796,11 @@
134632134796
int regRowCount = 0; /* Memory cell used for the row counter */
134633134797
int regIns; /* Block of regs holding rowid+data being inserted */
134634134798
int regRowid; /* registers holding insert rowid */
134635134799
int regData; /* register holding first column to insert */
134636134800
int *aRegIdx = 0; /* One register allocated to each index */
134801
+ int *aTabColMap = 0; /* Mapping from pTab columns to pCol entries */
134637134802
134638134803
#ifndef SQLITE_OMIT_TRIGGER
134639134804
int isView; /* True if attempting to insert into a view */
134640134805
Trigger *pTrigger; /* List of triggers on pTab, if required */
134641134806
int tmask; /* Mask of trigger times */
@@ -134776,35 +134941,29 @@
134776134941
** columns into storage order. False negatives are harmless,
134777134942
** but false positives will cause database corruption.
134778134943
*/
134779134944
bIdListInOrder = (pTab->tabFlags & (TF_OOOHidden|TF_HasStored))==0;
134780134945
if( pColumn ){
134781
- assert( pColumn->eU4!=EU4_EXPR );
134782
- pColumn->eU4 = EU4_IDX;
134783
- for(i=0; i<pColumn->nId; i++){
134784
- pColumn->a[i].u4.idx = -1;
134785
- }
134786
- for(i=0; i<pColumn->nId; i++){
134787
- for(j=0; j<pTab->nCol; j++){
134788
- if( sqlite3StrICmp(pColumn->a[i].zName, pTab->aCol[j].zCnName)==0 ){
134789
- pColumn->a[i].u4.idx = j;
134790
- if( i!=j ) bIdListInOrder = 0;
134791
- if( j==pTab->iPKey ){
134792
- ipkColumn = i; assert( !withoutRowid );
134793
- }
134794
-#ifndef SQLITE_OMIT_GENERATED_COLUMNS
134795
- if( pTab->aCol[j].colFlags & (COLFLAG_STORED|COLFLAG_VIRTUAL) ){
134796
- sqlite3ErrorMsg(pParse,
134797
- "cannot INSERT into generated column \"%s\"",
134798
- pTab->aCol[j].zCnName);
134799
- goto insert_cleanup;
134800
- }
134801
-#endif
134802
- break;
134803
- }
134804
- }
134805
- if( j>=pTab->nCol ){
134946
+ aTabColMap = sqlite3DbMallocZero(db, pTab->nCol*sizeof(int));
134947
+ if( aTabColMap==0 ) goto insert_cleanup;
134948
+ for(i=0; i<pColumn->nId; i++){
134949
+ j = sqlite3ColumnIndex(pTab, pColumn->a[i].zName);
134950
+ if( j>=0 ){
134951
+ if( aTabColMap[j]==0 ) aTabColMap[j] = i+1;
134952
+ if( i!=j ) bIdListInOrder = 0;
134953
+ if( j==pTab->iPKey ){
134954
+ ipkColumn = i; assert( !withoutRowid );
134955
+ }
134956
+#ifndef SQLITE_OMIT_GENERATED_COLUMNS
134957
+ if( pTab->aCol[j].colFlags & (COLFLAG_STORED|COLFLAG_VIRTUAL) ){
134958
+ sqlite3ErrorMsg(pParse,
134959
+ "cannot INSERT into generated column \"%s\"",
134960
+ pTab->aCol[j].zCnName);
134961
+ goto insert_cleanup;
134962
+ }
134963
+#endif
134964
+ }else{
134806134965
if( sqlite3IsRowid(pColumn->a[i].zName) && !withoutRowid ){
134807134966
ipkColumn = i;
134808134967
bIdListInOrder = 0;
134809134968
}else{
134810134969
sqlite3ErrorMsg(pParse, "table %S has no column named %s",
@@ -135098,29 +135257,29 @@
135098135257
sqlite3VdbeAddOp1(v, OP_SoftNull, iRegStore);
135099135258
}
135100135259
continue;
135101135260
}else if( pColumn==0 ){
135102135261
/* Hidden columns that are not explicitly named in the INSERT
135103
- ** get there default value */
135262
+ ** get their default value */
135104135263
sqlite3ExprCodeFactorable(pParse,
135105135264
sqlite3ColumnExpr(pTab, &pTab->aCol[i]),
135106135265
iRegStore);
135107135266
continue;
135108135267
}
135109135268
}
135110135269
if( pColumn ){
135111
- assert( pColumn->eU4==EU4_IDX );
135112
- for(j=0; j<pColumn->nId && pColumn->a[j].u4.idx!=i; j++){}
135113
- if( j>=pColumn->nId ){
135270
+ j = aTabColMap[i];
135271
+ assert( j>=0 && j<=pColumn->nId );
135272
+ if( j==0 ){
135114135273
/* A column not named in the insert column list gets its
135115135274
** default value */
135116135275
sqlite3ExprCodeFactorable(pParse,
135117135276
sqlite3ColumnExpr(pTab, &pTab->aCol[i]),
135118135277
iRegStore);
135119135278
continue;
135120135279
}
135121
- k = j;
135280
+ k = j - 1;
135122135281
}else if( nColumn==0 ){
135123135282
/* This is INSERT INTO ... DEFAULT VALUES. Load the default value. */
135124135283
sqlite3ExprCodeFactorable(pParse,
135125135284
sqlite3ColumnExpr(pTab, &pTab->aCol[i]),
135126135285
iRegStore);
@@ -135361,11 +135520,14 @@
135361135520
insert_cleanup:
135362135521
sqlite3SrcListDelete(db, pTabList);
135363135522
sqlite3ExprListDelete(db, pList);
135364135523
sqlite3UpsertDelete(db, pUpsert);
135365135524
sqlite3SelectDelete(db, pSelect);
135366
- sqlite3IdListDelete(db, pColumn);
135525
+ if( pColumn ){
135526
+ sqlite3IdListDelete(db, pColumn);
135527
+ sqlite3DbFree(db, aTabColMap);
135528
+ }
135367135529
if( aRegIdx ) sqlite3DbNNFreeNN(db, aRegIdx);
135368135530
}
135369135531
135370135532
/* Make sure "isView" and other macros defined above are undefined. Otherwise
135371135533
** they may interfere with compilation of other functions in this file
@@ -140708,11 +140870,14 @@
140708140870
){
140709140871
db->flags |= mask;
140710140872
}
140711140873
}else{
140712140874
db->flags &= ~mask;
140713
- if( mask==SQLITE_DeferFKs ) db->nDeferredImmCons = 0;
140875
+ if( mask==SQLITE_DeferFKs ){
140876
+ db->nDeferredImmCons = 0;
140877
+ db->nDeferredCons = 0;
140878
+ }
140714140879
if( (mask & SQLITE_WriteSchema)!=0
140715140880
&& sqlite3_stricmp(zRight, "reset")==0
140716140881
){
140717140882
/* IMP: R-60817-01178 If the argument is "RESET" then schema
140718140883
** writing is disabled (as with "PRAGMA writable_schema=OFF") and,
@@ -141316,11 +141481,11 @@
141316141481
sqlite3VdbeAddOp3(v, OP_Null, 0, 8, 8+cnt);
141317141482
sqlite3ClearTempRegCache(pParse);
141318141483
141319141484
/* Do the b-tree integrity checks */
141320141485
sqlite3VdbeAddOp4(v, OP_IntegrityCk, 1, cnt, 8, (char*)aRoot,P4_INTARRAY);
141321
- sqlite3VdbeChangeP5(v, (u8)i);
141486
+ sqlite3VdbeChangeP5(v, (u16)i);
141322141487
addr = sqlite3VdbeAddOp1(v, OP_IsNull, 2); VdbeCoverage(v);
141323141488
sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0,
141324141489
sqlite3MPrintf(db, "*** in database %s ***\n", db->aDb[i].zDbSName),
141325141490
P4_DYNAMIC);
141326141491
sqlite3VdbeAddOp3(v, OP_Concat, 2, 3, 3);
@@ -144042,14 +144207,37 @@
144042144207
** Return the index of a column in a table. Return -1 if the column
144043144208
** is not contained in the table.
144044144209
*/
144045144210
SQLITE_PRIVATE int sqlite3ColumnIndex(Table *pTab, const char *zCol){
144046144211
int i;
144047
- u8 h = sqlite3StrIHash(zCol);
144048
- Column *pCol;
144049
- for(pCol=pTab->aCol, i=0; i<pTab->nCol; pCol++, i++){
144050
- if( pCol->hName==h && sqlite3StrICmp(pCol->zCnName, zCol)==0 ) return i;
144212
+ u8 h;
144213
+ const Column *aCol;
144214
+ int nCol;
144215
+
144216
+ h = sqlite3StrIHash(zCol);
144217
+ aCol = pTab->aCol;
144218
+ nCol = pTab->nCol;
144219
+
144220
+ /* See if the aHx gives us a lucky match */
144221
+ i = pTab->aHx[h % sizeof(pTab->aHx)];
144222
+ assert( i<nCol );
144223
+ if( aCol[i].hName==h
144224
+ && sqlite3StrICmp(aCol[i].zCnName, zCol)==0
144225
+ ){
144226
+ return i;
144227
+ }
144228
+
144229
+ /* No lucky match from the hash table. Do a full search. */
144230
+ i = 0;
144231
+ while( 1 /*exit-by-break*/ ){
144232
+ if( aCol[i].hName==h
144233
+ && sqlite3StrICmp(aCol[i].zCnName, zCol)==0
144234
+ ){
144235
+ return i;
144236
+ }
144237
+ i++;
144238
+ if( i>=nCol ) break;
144051144239
}
144052144240
return -1;
144053144241
}
144054144242
144055144243
/*
@@ -150549,11 +150737,11 @@
150549150737
}
150550150738
sqlite3ReleaseTempReg(pParse, regSubtype);
150551150739
}
150552150740
sqlite3VdbeAddOp3(v, OP_AggStep, 0, regAgg, AggInfoFuncReg(pAggInfo,i));
150553150741
sqlite3VdbeAppendP4(v, pF->pFunc, P4_FUNCDEF);
150554
- sqlite3VdbeChangeP5(v, (u8)nArg);
150742
+ sqlite3VdbeChangeP5(v, (u16)nArg);
150555150743
sqlite3VdbeAddOp2(v, OP_Next, pF->iOBTab, iTop+1); VdbeCoverage(v);
150556150744
sqlite3VdbeJumpHere(v, iTop);
150557150745
sqlite3ReleaseTempRange(pParse, regAgg, nArg);
150558150746
}
150559150747
sqlite3VdbeAddOp2(v, OP_AggFinal, AggInfoFuncReg(pAggInfo,i),
@@ -150712,11 +150900,11 @@
150712150900
sqlite3VdbeAddOp4(v, OP_CollSeq, regHit, 0, 0,
150713150901
(char *)pColl, P4_COLLSEQ);
150714150902
}
150715150903
sqlite3VdbeAddOp3(v, OP_AggStep, 0, regAgg, AggInfoFuncReg(pAggInfo,i));
150716150904
sqlite3VdbeAppendP4(v, pF->pFunc, P4_FUNCDEF);
150717
- sqlite3VdbeChangeP5(v, (u8)nArg);
150905
+ sqlite3VdbeChangeP5(v, (u16)nArg);
150718150906
sqlite3ReleaseTempRange(pParse, regAgg, nArg);
150719150907
}
150720150908
if( addrNext ){
150721150909
sqlite3VdbeResolveLabel(v, addrNext);
150722150910
}
@@ -152767,11 +152955,12 @@
152767152955
}else if( pTrig->op==TK_RETURNING ){
152768152956
#ifndef SQLITE_OMIT_VIRTUALTABLE
152769152957
assert( pParse->db->pVtabCtx==0 );
152770152958
#endif
152771152959
assert( pParse->bReturning );
152772
- assert( &(pParse->u1.pReturning->retTrig) == pTrig );
152960
+ assert( !pParse->isCreate );
152961
+ assert( &(pParse->u1.d.pReturning->retTrig) == pTrig );
152773152962
pTrig->table = pTab->zName;
152774152963
pTrig->pTabSchema = pTab->pSchema;
152775152964
pTrig->pNext = pList;
152776152965
pList = pTrig;
152777152966
}
@@ -153744,11 +153933,12 @@
153744153933
/* This RETURNING trigger must be for a different statement as
153745153934
** this statement lacks a RETURNING clause. */
153746153935
return;
153747153936
}
153748153937
assert( db->pParse==pParse );
153749
- pReturning = pParse->u1.pReturning;
153938
+ assert( !pParse->isCreate );
153939
+ pReturning = pParse->u1.d.pReturning;
153750153940
if( pTrigger != &(pReturning->retTrig) ){
153751153941
/* This RETURNING trigger is for a different statement */
153752153942
return;
153753153943
}
153754153944
memset(&sSelect, 0, sizeof(sSelect));
@@ -153974,10 +154164,12 @@
153974154164
sSubParse.pToplevel = pTop;
153975154165
sSubParse.zAuthContext = pTrigger->zName;
153976154166
sSubParse.eTriggerOp = pTrigger->op;
153977154167
sSubParse.nQueryLoop = pParse->nQueryLoop;
153978154168
sSubParse.prepFlags = pParse->prepFlags;
154169
+ sSubParse.oldmask = 0;
154170
+ sSubParse.newmask = 0;
153979154171
153980154172
v = sqlite3GetVdbe(&sSubParse);
153981154173
if( v ){
153982154174
VdbeComment((v, "Start: %s.%s (%s %s%s%s ON %s)",
153983154175
pTrigger->zName, onErrorText(orconf),
@@ -154106,11 +154298,11 @@
154106154298
/* Set the P5 operand of the OP_Program instruction to non-zero if
154107154299
** recursive invocation of this trigger program is disallowed. Recursive
154108154300
** invocation is disallowed if (a) the sub-program is really a trigger,
154109154301
** not a foreign key action, and (b) the flag to enable recursive triggers
154110154302
** is clear. */
154111
- sqlite3VdbeChangeP5(v, (u8)bRecursive);
154303
+ sqlite3VdbeChangeP5(v, (u16)bRecursive);
154112154304
}
154113154305
}
154114154306
154115154307
/*
154116154308
** This is called to code the required FOR EACH ROW triggers for an operation
@@ -154728,42 +154920,36 @@
154728154920
** column to be updated, make sure we have authorization to change
154729154921
** that column.
154730154922
*/
154731154923
chngRowid = chngPk = 0;
154732154924
for(i=0; i<pChanges->nExpr; i++){
154733
- u8 hCol = sqlite3StrIHash(pChanges->a[i].zEName);
154734154925
/* If this is an UPDATE with a FROM clause, do not resolve expressions
154735154926
** here. The call to sqlite3Select() below will do that. */
154736154927
if( nChangeFrom==0 && sqlite3ResolveExprNames(&sNC, pChanges->a[i].pExpr) ){
154737154928
goto update_cleanup;
154738154929
}
154739
- for(j=0; j<pTab->nCol; j++){
154740
- if( pTab->aCol[j].hName==hCol
154741
- && sqlite3StrICmp(pTab->aCol[j].zCnName, pChanges->a[i].zEName)==0
154742
- ){
154743
- if( j==pTab->iPKey ){
154744
- chngRowid = 1;
154745
- pRowidExpr = pChanges->a[i].pExpr;
154746
- iRowidExpr = i;
154747
- }else if( pPk && (pTab->aCol[j].colFlags & COLFLAG_PRIMKEY)!=0 ){
154748
- chngPk = 1;
154749
- }
154930
+ j = sqlite3ColumnIndex(pTab, pChanges->a[i].zEName);
154931
+ if( j>=0 ){
154932
+ if( j==pTab->iPKey ){
154933
+ chngRowid = 1;
154934
+ pRowidExpr = pChanges->a[i].pExpr;
154935
+ iRowidExpr = i;
154936
+ }else if( pPk && (pTab->aCol[j].colFlags & COLFLAG_PRIMKEY)!=0 ){
154937
+ chngPk = 1;
154938
+ }
154750154939
#ifndef SQLITE_OMIT_GENERATED_COLUMNS
154751
- else if( pTab->aCol[j].colFlags & COLFLAG_GENERATED ){
154752
- testcase( pTab->aCol[j].colFlags & COLFLAG_VIRTUAL );
154753
- testcase( pTab->aCol[j].colFlags & COLFLAG_STORED );
154754
- sqlite3ErrorMsg(pParse,
154755
- "cannot UPDATE generated column \"%s\"",
154756
- pTab->aCol[j].zCnName);
154757
- goto update_cleanup;
154758
- }
154940
+ else if( pTab->aCol[j].colFlags & COLFLAG_GENERATED ){
154941
+ testcase( pTab->aCol[j].colFlags & COLFLAG_VIRTUAL );
154942
+ testcase( pTab->aCol[j].colFlags & COLFLAG_STORED );
154943
+ sqlite3ErrorMsg(pParse,
154944
+ "cannot UPDATE generated column \"%s\"",
154945
+ pTab->aCol[j].zCnName);
154946
+ goto update_cleanup;
154947
+ }
154759154948
#endif
154760
- aXRef[j] = i;
154761
- break;
154762
- }
154763
- }
154764
- if( j>=pTab->nCol ){
154949
+ aXRef[j] = i;
154950
+ }else{
154765154951
if( pPk==0 && sqlite3IsRowid(pChanges->a[i].zEName) ){
154766154952
j = -1;
154767154953
chngRowid = 1;
154768154954
pRowidExpr = pChanges->a[i].pExpr;
154769154955
iRowidExpr = i;
@@ -156866,24 +157052,25 @@
156866157052
156867157053
/* A slot for the record has already been allocated in the
156868157054
** schema table. We just need to update that slot with all
156869157055
** the information we've collected.
156870157056
**
156871
- ** The VM register number pParse->regRowid holds the rowid of an
157057
+ ** The VM register number pParse->u1.cr.regRowid holds the rowid of an
156872157058
** entry in the sqlite_schema table that was created for this vtab
156873157059
** by sqlite3StartTable().
156874157060
*/
156875157061
iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
157062
+ assert( pParse->isCreate );
156876157063
sqlite3NestedParse(pParse,
156877157064
"UPDATE %Q." LEGACY_SCHEMA_TABLE " "
156878157065
"SET type='table', name=%Q, tbl_name=%Q, rootpage=0, sql=%Q "
156879157066
"WHERE rowid=#%d",
156880157067
db->aDb[iDb].zDbSName,
156881157068
pTab->zName,
156882157069
pTab->zName,
156883157070
zStmt,
156884
- pParse->regRowid
157071
+ pParse->u1.cr.regRowid
156885157072
);
156886157073
v = sqlite3GetVdbe(pParse);
156887157074
sqlite3ChangeCookie(pParse, iDb);
156888157075
156889157076
sqlite3VdbeAddOp0(v, OP_Expire);
@@ -157217,11 +157404,13 @@
157217157404
** sqlite3_declare_vtab() is being misused.
157218157405
*/
157219157406
z = (const unsigned char*)zCreateTable;
157220157407
for(i=0; aKeyword[i]; i++){
157221157408
int tokenType = 0;
157222
- do{ z += sqlite3GetToken(z, &tokenType); }while( tokenType==TK_SPACE );
157409
+ do{
157410
+ z += sqlite3GetToken(z, &tokenType);
157411
+ }while( tokenType==TK_SPACE || tokenType==TK_COMMENT );
157223157412
if( tokenType!=aKeyword[i] ){
157224157413
sqlite3ErrorWithMsg(db, SQLITE_ERROR, "syntax error");
157225157414
return SQLITE_ERROR;
157226157415
}
157227157416
}
@@ -157948,12 +158137,14 @@
157948158137
u16 nLTerm; /* Number of entries in aLTerm[] */
157949158138
u16 nSkip; /* Number of NULL aLTerm[] entries */
157950158139
/**** whereLoopXfer() copies fields above ***********************/
157951158140
# define WHERE_LOOP_XFER_SZ offsetof(WhereLoop,nLSlot)
157952158141
u16 nLSlot; /* Number of slots allocated for aLTerm[] */
158142
+#ifdef WHERETRACE_ENABLED
157953158143
LogEst rStarDelta; /* Cost delta due to star-schema heuristic. Not
157954
- ** initialized unless pWInfo->nOutStarDelta>0 */
158144
+ ** initialized unless pWInfo->bStarUsed */
158145
+#endif
157955158146
WhereTerm **aLTerm; /* WhereTerms used */
157956158147
WhereLoop *pNextLoop; /* Next WhereLoop object in the WhereClause */
157957158148
WhereTerm *aLTermSpace[3]; /* Initial aLTerm[] space */
157958158149
};
157959158150
@@ -157998,11 +158189,11 @@
157998158189
struct WherePath {
157999158190
Bitmask maskLoop; /* Bitmask of all WhereLoop objects in this path */
158000158191
Bitmask revLoop; /* aLoop[]s that should be reversed for ORDER BY */
158001158192
LogEst nRow; /* Estimated number of rows generated by this path */
158002158193
LogEst rCost; /* Total cost of this path */
158003
- LogEst rUnsorted; /* Total cost of this path ignoring sorting costs */
158194
+ LogEst rUnsort; /* Total cost of this path ignoring sorting costs */
158004158195
i8 isOrdered; /* No. of ORDER BY terms satisfied. -1 for unknown */
158005158196
WhereLoop **aLoop; /* Array of WhereLoop objects implementing this path */
158006158197
};
158007158198
158008158199
/*
@@ -158271,13 +158462,17 @@
158271158462
u8 eOnePass; /* ONEPASS_OFF, or _SINGLE, or _MULTI */
158272158463
u8 eDistinct; /* One of the WHERE_DISTINCT_* values */
158273158464
unsigned bDeferredSeek :1; /* Uses OP_DeferredSeek */
158274158465
unsigned untestedTerms :1; /* Not all WHERE terms resolved by outer loop */
158275158466
unsigned bOrderedInnerLoop:1;/* True if only the inner-most loop is ordered */
158276
- unsigned sorted :1; /* True if really sorted (not just grouped) */
158277
- LogEst nOutStarDelta; /* Artifical nOut reduction for star-query */
158467
+ unsigned sorted :1; /* True if really sorted (not just grouped) */
158468
+ unsigned bStarDone :1; /* True if check for star-query is complete */
158469
+ unsigned bStarUsed :1; /* True if star-query heuristic is used */
158278158470
LogEst nRowOut; /* Estimated number of output rows */
158471
+#ifdef WHERETRACE_ENABLED
158472
+ LogEst rTotalCost; /* Total cost of the solution */
158473
+#endif
158279158474
int iTop; /* The very beginning of the WHERE loop */
158280158475
int iEndWhere; /* End of the WHERE clause itself */
158281158476
WhereLoop *pLoops; /* List of all WhereLoop objects */
158282158477
WhereMemBlock *pMemToFree;/* Memory to free when this object destroyed */
158283158478
Bitmask revMask; /* Mask of ORDER BY terms that need reversing */
@@ -160029,10 +160224,13 @@
160029160224
}
160030160225
}
160031160226
}
160032160227
sqlite3VdbeAddOp2(v, OP_Integer, pLoop->u.vtab.idxNum, iReg);
160033160228
sqlite3VdbeAddOp2(v, OP_Integer, nConstraint, iReg+1);
160229
+ /* The instruction immediately prior to OP_VFilter must be an OP_Integer
160230
+ ** that sets the "argc" value for xVFilter. This is necessary for
160231
+ ** resolveP2() to work correctly. See tag-20250207a. */
160034160232
sqlite3VdbeAddOp4(v, OP_VFilter, iCur, addrNotFound, iReg,
160035160233
pLoop->u.vtab.idxStr,
160036160234
pLoop->u.vtab.needFree ? P4_DYNAMIC : P4_STATIC);
160037160235
VdbeCoverage(v);
160038160236
pLoop->u.vtab.needFree = 0;
@@ -161584,24 +161782,26 @@
161584161782
}else if( op==TK_STRING ){
161585161783
assert( !ExprHasProperty(pRight, EP_IntValue) );
161586161784
z = (u8*)pRight->u.zToken;
161587161785
}
161588161786
if( z ){
161589
- /* Count the number of prefix bytes prior to the first wildcard.
161590
- ** or U+fffd character. If the underlying database has a UTF16LE
161591
- ** encoding, then only consider ASCII characters. Note that the
161592
- ** encoding of z[] is UTF8 - we are dealing with only UTF8 here in
161593
- ** this code, but the database engine itself might be processing
161594
- ** content using a different encoding. */
161787
+ /* Count the number of prefix bytes prior to the first wildcard,
161788
+ ** U+fffd character, or malformed utf-8. If the underlying database
161789
+ ** has a UTF16LE encoding, then only consider ASCII characters. Note that
161790
+ ** the encoding of z[] is UTF8 - we are dealing with only UTF8 here in this
161791
+ ** code, but the database engine itself might be processing content using a
161792
+ ** different encoding. */
161595161793
cnt = 0;
161596161794
while( (c=z[cnt])!=0 && c!=wc[0] && c!=wc[1] && c!=wc[2] ){
161597161795
cnt++;
161598161796
if( c==wc[3] && z[cnt]>0 && z[cnt]<0x80 ){
161599161797
cnt++;
161600161798
}else if( c>=0x80 ){
161601161799
const u8 *z2 = z+cnt-1;
161602
- if( sqlite3Utf8Read(&z2)==0xfffd || ENC(db)==SQLITE_UTF16LE ){
161800
+ if( c==0xff || sqlite3Utf8Read(&z2)==0xfffd /* bad utf-8 */
161801
+ || ENC(db)==SQLITE_UTF16LE
161802
+ ){
161603161803
cnt--;
161604161804
break;
161605161805
}else{
161606161806
cnt = (int)(z2-z);
161607161807
}
@@ -162749,24 +162949,30 @@
162749162949
pStr2->u.zToken[i] = sqlite3Tolower(c);
162750162950
}
162751162951
}
162752162952
162753162953
if( !db->mallocFailed ){
162754
- u8 c, *pC; /* Last character before the first wildcard */
162954
+ u8 *pC; /* Last character before the first wildcard */
162755162955
pC = (u8*)&pStr2->u.zToken[sqlite3Strlen30(pStr2->u.zToken)-1];
162756
- c = *pC;
162757162956
if( noCase ){
162758162957
/* The point is to increment the last character before the first
162759162958
** wildcard. But if we increment '@', that will push it into the
162760162959
** alphabetic range where case conversions will mess up the
162761162960
** inequality. To avoid this, make sure to also run the full
162762162961
** LIKE on all candidate expressions by clearing the isComplete flag
162763162962
*/
162764
- if( c=='A'-1 ) isComplete = 0;
162765
- c = sqlite3UpperToLower[c];
162963
+ if( *pC=='A'-1 ) isComplete = 0;
162964
+ *pC = sqlite3UpperToLower[*pC];
162766162965
}
162767
- *pC = c + 1;
162966
+
162967
+ /* Increment the value of the last utf8 character in the prefix. */
162968
+ while( *pC==0xBF && pC>(u8*)pStr2->u.zToken ){
162969
+ *pC = 0x80;
162970
+ pC--;
162971
+ }
162972
+ assert( *pC!=0xFF ); /* isLikeOrGlob() guarantees this */
162973
+ (*pC)++;
162768162974
}
162769162975
zCollSeqName = noCase ? "NOCASE" : sqlite3StrBINARY;
162770162976
pNewExpr1 = sqlite3ExprDup(db, pLeft, 0);
162771162977
pNewExpr1 = sqlite3PExpr(pParse, TK_GE,
162772162978
sqlite3ExprAddCollateString(pParse,pNewExpr1,zCollSeqName),
@@ -164130,10 +164336,15 @@
164130164336
**
164131164337
** 2. If iCol is part of an existing index that has an aiRowLogEst of
164132164338
** more than 20, then return false.
164133164339
**
164134164340
** 3. If no disqualifying conditions above are found, return true.
164341
+**
164342
+** 2025-01-03: I experimented with a new rule that returns false if the
164343
+** the datatype of the column is "BOOLEAN". This did not improve
164344
+** performance on any queries at hand, but it did burn CPU cycles, so the
164345
+** idea was not committed.
164135164346
*/
164136164347
static SQLITE_NOINLINE int columnIsGoodIndexCandidate(
164137164348
const Table *pTab,
164138164349
int iCol
164139164350
){
@@ -164214,11 +164425,11 @@
164214164425
char *zText = 0;
164215164426
int ii = 0;
164216164427
sqlite3_str *pStr = sqlite3_str_new(pParse->db);
164217164428
sqlite3_str_appendf(pStr,"CREATE AUTOMATIC INDEX ON %s(", pTab->zName);
164218164429
assert( pIdx->nColumn>1 );
164219
- assert( pIdx->aiColumn[pIdx->nColumn-1]==XN_ROWID );
164430
+ assert( pIdx->aiColumn[pIdx->nColumn-1]==XN_ROWID || !HasRowid(pTab) );
164220164431
for(ii=0; ii<(pIdx->nColumn-1); ii++){
164221164432
const char *zName = 0;
164222164433
int iCol = pIdx->aiColumn[ii];
164223164434
164224164435
zName = pTab->aCol[iCol].zCnName;
@@ -164344,10 +164555,23 @@
164344164555
*/
164345164556
if( IsView(pTable) ){
164346164557
extraCols = ALLBITS & ~idxCols;
164347164558
}else{
164348164559
extraCols = pSrc->colUsed & (~idxCols | MASKBIT(BMS-1));
164560
+ }
164561
+ if( !HasRowid(pTable) ){
164562
+ /* For WITHOUT ROWID tables, ensure that all PRIMARY KEY columns are
164563
+ ** either in the idxCols mask or in the extraCols mask */
164564
+ for(i=0; i<pTable->nCol; i++){
164565
+ if( (pTable->aCol[i].colFlags & COLFLAG_PRIMKEY)==0 ) continue;
164566
+ if( i>=BMS-1 ){
164567
+ extraCols |= MASKBIT(BMS-1);
164568
+ break;
164569
+ }
164570
+ if( idxCols & MASKBIT(i) ) continue;
164571
+ extraCols |= MASKBIT(i);
164572
+ }
164349164573
}
164350164574
mxBitCol = MIN(BMS-1,pTable->nCol);
164351164575
testcase( pTable->nCol==BMS-1 );
164352164576
testcase( pTable->nCol==BMS-2 );
164353164577
for(i=0; i<mxBitCol; i++){
@@ -164356,11 +164580,12 @@
164356164580
if( pSrc->colUsed & MASKBIT(BMS-1) ){
164357164581
nKeyCol += pTable->nCol - BMS + 1;
164358164582
}
164359164583
164360164584
/* Construct the Index object to describe this index */
164361
- pIdx = sqlite3AllocateIndexObject(pParse->db, nKeyCol+1, 0, &zNotUsed);
164585
+ pIdx = sqlite3AllocateIndexObject(pParse->db, nKeyCol+HasRowid(pTable),
164586
+ 0, &zNotUsed);
164362164587
if( pIdx==0 ) goto end_auto_index_create;
164363164588
pLoop->u.btree.pIndex = pIdx;
164364164589
pIdx->zName = "auto-index";
164365164590
pIdx->pTable = pTable;
164366164591
n = 0;
@@ -164412,12 +164637,14 @@
164412164637
pIdx->azColl[n] = sqlite3StrBINARY;
164413164638
n++;
164414164639
}
164415164640
}
164416164641
assert( n==nKeyCol );
164417
- pIdx->aiColumn[n] = XN_ROWID;
164418
- pIdx->azColl[n] = sqlite3StrBINARY;
164642
+ if( HasRowid(pTable) ){
164643
+ pIdx->aiColumn[n] = XN_ROWID;
164644
+ pIdx->azColl[n] = sqlite3StrBINARY;
164645
+ }
164419164646
164420164647
/* Create the automatic index */
164421164648
explainAutomaticIndex(pParse, pIdx, pPartial!=0, &addrExp);
164422164649
assert( pLevel->iIdxCur>=0 );
164423164650
pLevel->iIdxCur = pParse->nTab++;
@@ -165680,21 +165907,23 @@
165680165907
** | | | __|__ nEq ---. ___|__ | __|__
165681165908
** | / \ / \ / \ | / \ / \ / \
165682165909
** 1.002.001 t2.t2xy 2 f 010241 N 2 cost 0,56,31
165683165910
*/
165684165911
SQLITE_PRIVATE void sqlite3WhereLoopPrint(const WhereLoop *p, const WhereClause *pWC){
165912
+ WhereInfo *pWInfo;
165685165913
if( pWC ){
165686
- WhereInfo *pWInfo = pWC->pWInfo;
165914
+ pWInfo = pWC->pWInfo;
165687165915
int nb = 1+(pWInfo->pTabList->nSrc+3)/4;
165688165916
SrcItem *pItem = pWInfo->pTabList->a + p->iTab;
165689165917
Table *pTab = pItem->pSTab;
165690165918
Bitmask mAll = (((Bitmask)1)<<(nb*4)) - 1;
165691165919
sqlite3DebugPrintf("%c%2d.%0*llx.%0*llx", p->cId,
165692165920
p->iTab, nb, p->maskSelf, nb, p->prereq & mAll);
165693165921
sqlite3DebugPrintf(" %12s",
165694165922
pItem->zAlias ? pItem->zAlias : pTab->zName);
165695165923
}else{
165924
+ pWInfo = 0;
165696165925
sqlite3DebugPrintf("%c%2d.%03llx.%03llx %c%d",
165697165926
p->cId, p->iTab, p->maskSelf, p->prereq & 0xfff, p->cId, p->iTab);
165698165927
}
165699165928
if( (p->wsFlags & WHERE_VIRTUALTABLE)==0 ){
165700165929
const char *zName;
@@ -165722,11 +165951,16 @@
165722165951
if( p->wsFlags & WHERE_SKIPSCAN ){
165723165952
sqlite3DebugPrintf(" f %06x %d-%d", p->wsFlags, p->nLTerm,p->nSkip);
165724165953
}else{
165725165954
sqlite3DebugPrintf(" f %06x N %d", p->wsFlags, p->nLTerm);
165726165955
}
165727
- sqlite3DebugPrintf(" cost %d,%d,%d\n", p->rSetup, p->rRun, p->nOut);
165956
+ if( pWInfo && pWInfo->bStarUsed && p->rStarDelta!=0 ){
165957
+ sqlite3DebugPrintf(" cost %d,%d,%d delta=%d\n",
165958
+ p->rSetup, p->rRun, p->nOut, p->rStarDelta);
165959
+ }else{
165960
+ sqlite3DebugPrintf(" cost %d,%d,%d\n", p->rSetup, p->rRun, p->nOut);
165961
+ }
165728165962
if( p->nLTerm && (sqlite3WhereTrace & 0x4000)!=0 ){
165729165963
int i;
165730165964
for(i=0; i<p->nLTerm; i++){
165731165965
sqlite3WhereTermPrint(p->aLTerm[i], i);
165732165966
}
@@ -167188,11 +167422,10 @@
167188167422
if( !pBuilder->pOrSet /* Not part of an OR optimization */
167189167423
&& (pWInfo->wctrlFlags & (WHERE_RIGHT_JOIN|WHERE_OR_SUBCLAUSE))==0
167190167424
&& (pWInfo->pParse->db->flags & SQLITE_AutoIndex)!=0
167191167425
&& !pSrc->fg.isIndexedBy /* Has no INDEXED BY clause */
167192167426
&& !pSrc->fg.notIndexed /* Has no NOT INDEXED clause */
167193
- && HasRowid(pTab) /* Not WITHOUT ROWID table. (FIXME: Why not?) */
167194167427
&& !pSrc->fg.isCorrelated /* Not a correlated subquery */
167195167428
&& !pSrc->fg.isRecursive /* Not a recursive common table expression. */
167196167429
&& (pSrc->fg.jointype & JT_RIGHT)==0 /* Not the right tab of a RIGHT JOIN */
167197167430
){
167198167431
/* Generate auto-index WhereLoops */
@@ -168691,72 +168924,205 @@
168691168924
** The value returned is a tuning parameter. Currently the value is:
168692168925
**
168693168926
** 18 for star queries
168694168927
** 12 otherwise
168695168928
**
168696
-** For the purposes of SQLite, a star-query is defined as a query
168697
-** with a large central table that is joined against four or more
168698
-** smaller tables. The central table is called the "fact" table.
168699
-** The smaller tables that get joined are "dimension tables".
168929
+** For the purposes of this heuristic, a star-query is defined as a query
168930
+** with a large central table that is joined using an INNER JOIN,
168931
+** not CROSS or OUTER JOINs, against four or more smaller tables.
168932
+** The central table is called the "fact" table. The smaller tables
168933
+** that get joined are "dimension tables". Also, any table that is
168934
+** self-joined cannot be a dimension table; we assume that dimension
168935
+** tables may only be joined against fact tables.
168700168936
**
168701168937
** SIDE EFFECT: (and really the whole point of this subroutine)
168702168938
**
168703
-** If pWInfo describes a star-query, then the cost on WhereLoops for the
168704
-** fact table is reduced. This heuristic helps keep fact tables in
168705
-** outer loops. Without this heuristic, paths with fact tables in outer
168706
-** loops tend to get pruned by the mxChoice limit on the number of paths,
168707
-** resulting in poor query plans. The total amount of heuristic cost
168708
-** adjustment is stored in pWInfo->nOutStarDelta and the cost adjustment
168709
-** for each WhereLoop is stored in its rStarDelta field.
168939
+** If pWInfo describes a star-query, then the cost for SCANs of dimension
168940
+** WhereLoops is increased to be slightly larger than the cost of a SCAN
168941
+** in the fact table. Only SCAN costs are increased. SEARCH costs are
168942
+** unchanged. This heuristic helps keep fact tables in outer loops. Without
168943
+** this heuristic, paths with fact tables in outer loops tend to get pruned
168944
+** by the mxChoice limit on the number of paths, resulting in poor query
168945
+** plans. See the starschema1.test test module for examples of queries
168946
+** that need this heuristic to find good query plans.
168947
+**
168948
+** This heuristic can be completely disabled, so that no query is
168949
+** considered a star-query, using SQLITE_TESTCTRL_OPTIMIZATION to
168950
+** disable the SQLITE_StarQuery optimization. In the CLI, the command
168951
+** to do that is: ".testctrl opt -starquery".
168952
+**
168953
+** HISTORICAL NOTES:
168954
+**
168955
+** This optimization was first added on 2024-05-09 by check-in 38db9b5c83d.
168956
+** The original optimization reduced the cost and output size estimate for
168957
+** fact tables to help them move to outer loops. But months later (as people
168958
+** started upgrading) performance regression reports started caming in,
168959
+** including:
168960
+**
168961
+** forum post b18ef983e68d06d1 (2024-12-21)
168962
+** forum post 0025389d0860af82 (2025-01-14)
168963
+** forum post d87570a145599033 (2025-01-17)
168964
+**
168965
+** To address these, the criteria for a star-query was tightened to exclude
168966
+** cases where the fact and dimensions are separated by an outer join, and
168967
+** the affect of star-schema detection was changed to increase the rRun cost
168968
+** on just full table scans of dimension tables, rather than reducing costs
168969
+** in the all access methods of the fact table.
168710168970
*/
168711
-static int computeMxChoice(WhereInfo *pWInfo, LogEst nRowEst){
168971
+static int computeMxChoice(WhereInfo *pWInfo){
168712168972
int nLoop = pWInfo->nLevel; /* Number of terms in the join */
168713
- if( nRowEst==0 && nLoop>=5 ){
168714
- /* Check to see if we are dealing with a star schema and if so, reduce
168715
- ** the cost of fact tables relative to dimension tables, as a heuristic
168716
- ** to help keep the fact tables in outer loops.
168973
+ WhereLoop *pWLoop; /* For looping over WhereLoops */
168974
+
168975
+#ifdef SQLITE_DEBUG
168976
+ /* The star-query detection code below makes use of the following
168977
+ ** properties of the WhereLoop list, so verify them before
168978
+ ** continuing:
168979
+ ** (1) .maskSelf is the bitmask corresponding to .iTab
168980
+ ** (2) The WhereLoop list is in ascending .iTab order
168981
+ */
168982
+ for(pWLoop=pWInfo->pLoops; pWLoop; pWLoop=pWLoop->pNextLoop){
168983
+ assert( pWLoop->maskSelf==MASKBIT(pWLoop->iTab) );
168984
+ assert( pWLoop->pNextLoop==0 || pWLoop->iTab<=pWLoop->pNextLoop->iTab );
168985
+ }
168986
+#endif /* SQLITE_DEBUG */
168987
+
168988
+ if( nLoop>=5
168989
+ && !pWInfo->bStarDone
168990
+ && OptimizationEnabled(pWInfo->pParse->db, SQLITE_StarQuery)
168991
+ ){
168992
+ SrcItem *aFromTabs; /* All terms of the FROM clause */
168993
+ int iFromIdx; /* Term of FROM clause is the candidate fact-table */
168994
+ Bitmask m; /* Bitmask for candidate fact-table */
168995
+ Bitmask mSelfJoin = 0; /* Tables that cannot be dimension tables */
168996
+ WhereLoop *pStart; /* Where to start searching for dimension-tables */
168997
+
168998
+ pWInfo->bStarDone = 1; /* Only do this computation once */
168999
+
169000
+ /* Look for fact tables with four or more dimensions where the
169001
+ ** dimension tables are not separately from the fact tables by an outer
169002
+ ** or cross join. Adjust cost weights if found.
168717169003
*/
168718
- int iLoop; /* Counter over join terms */
168719
- Bitmask m; /* Bitmask for current loop */
168720
- assert( pWInfo->nOutStarDelta==0 );
168721
- for(iLoop=0, m=1; iLoop<nLoop; iLoop++, m<<=1){
168722
- WhereLoop *pWLoop; /* For looping over WhereLoops */
169004
+ assert( !pWInfo->bStarUsed );
169005
+ aFromTabs = pWInfo->pTabList->a;
169006
+ pStart = pWInfo->pLoops;
169007
+ for(iFromIdx=0, m=1; iFromIdx<nLoop; iFromIdx++, m<<=1){
168723169008
int nDep = 0; /* Number of dimension tables */
168724
- LogEst rDelta; /* Heuristic cost adjustment */
169009
+ LogEst mxRun; /* Maximum SCAN cost of a fact table */
168725169010
Bitmask mSeen = 0; /* Mask of dimension tables */
168726
- for(pWLoop=pWInfo->pLoops; pWLoop; pWLoop=pWLoop->pNextLoop){
168727
- if( (pWLoop->prereq & m)!=0 && (pWLoop->maskSelf & mSeen)==0 ){
168728
- nDep++;
168729
- mSeen |= pWLoop->maskSelf;
169011
+ SrcItem *pFactTab; /* The candidate fact table */
169012
+
169013
+ pFactTab = aFromTabs + iFromIdx;
169014
+ if( (pFactTab->fg.jointype & (JT_OUTER|JT_CROSS))!=0 ){
169015
+ /* If the candidate fact-table is the right table of an outer join
169016
+ ** restrict the search for dimension-tables to be tables to the right
169017
+ ** of the fact-table. */
169018
+ if( iFromIdx+4 > nLoop ) break; /* Impossible to reach nDep>=4 */
169019
+ while( pStart && pStart->iTab<=iFromIdx ){
169020
+ pStart = pStart->pNextLoop;
169021
+ }
169022
+ }
169023
+ for(pWLoop=pStart; pWLoop; pWLoop=pWLoop->pNextLoop){
169024
+ if( (aFromTabs[pWLoop->iTab].fg.jointype & (JT_OUTER|JT_CROSS))!=0 ){
169025
+ /* Fact-tables and dimension-tables cannot be separated by an
169026
+ ** outer join (at least for the definition of fact- and dimension-
169027
+ ** used by this heuristic). */
169028
+ break;
169029
+ }
169030
+ if( (pWLoop->prereq & m)!=0 /* pWInfo depends on iFromIdx */
169031
+ && (pWLoop->maskSelf & mSeen)==0 /* pWInfo not already a dependency */
169032
+ && (pWLoop->maskSelf & mSelfJoin)==0 /* Not a self-join */
169033
+ ){
169034
+ if( aFromTabs[pWLoop->iTab].pSTab==pFactTab->pSTab ){
169035
+ mSelfJoin |= m;
169036
+ }else{
169037
+ nDep++;
169038
+ mSeen |= pWLoop->maskSelf;
169039
+ }
168730169040
}
168731169041
}
168732169042
if( nDep<=3 ) continue;
168733
- rDelta = 15*(nDep-3);
168734
-#ifdef WHERETRACE_ENABLED /* 0x4 */
168735
- if( sqlite3WhereTrace&0x4 ){
168736
- SrcItem *pItem = pWInfo->pTabList->a + iLoop;
168737
- sqlite3DebugPrintf("Fact-table %s: %d dimensions, cost reduced %d\n",
168738
- pItem->zAlias ? pItem->zAlias : pItem->pSTab->zName,
168739
- nDep, rDelta);
168740
- }
168741
-#endif
168742
- if( pWInfo->nOutStarDelta==0 ){
169043
+
169044
+ /* If we reach this point, it means that pFactTab is a fact table
169045
+ ** with four or more dimensions connected by inner joins. Proceed
169046
+ ** to make cost adjustments. */
169047
+
169048
+#ifdef WHERETRACE_ENABLED
169049
+ /* Make sure rStarDelta values are initialized */
169050
+ if( !pWInfo->bStarUsed ){
168743169051
for(pWLoop=pWInfo->pLoops; pWLoop; pWLoop=pWLoop->pNextLoop){
168744169052
pWLoop->rStarDelta = 0;
168745169053
}
168746169054
}
168747
- pWInfo->nOutStarDelta += rDelta;
169055
+#endif
169056
+ pWInfo->bStarUsed = 1;
169057
+
169058
+ /* Compute the maximum cost of any WhereLoop for the
169059
+ ** fact table plus one epsilon */
169060
+ mxRun = LOGEST_MIN;
169061
+ for(pWLoop=pStart; pWLoop; pWLoop=pWLoop->pNextLoop){
169062
+ if( pWLoop->iTab<iFromIdx ) continue;
169063
+ if( pWLoop->iTab>iFromIdx ) break;
169064
+ if( pWLoop->rRun>mxRun ) mxRun = pWLoop->rRun;
169065
+ }
169066
+ if( ALWAYS(mxRun<LOGEST_MAX) ) mxRun++;
169067
+
169068
+ /* Increase the cost of table scans for dimension tables to be
169069
+ ** slightly more than the maximum cost of the fact table */
169070
+ for(pWLoop=pStart; pWLoop; pWLoop=pWLoop->pNextLoop){
169071
+ if( (pWLoop->maskSelf & mSeen)==0 ) continue;
169072
+ if( pWLoop->nLTerm ) continue;
169073
+ if( pWLoop->rRun<mxRun ){
169074
+#ifdef WHERETRACE_ENABLED /* 0x80000 */
169075
+ if( sqlite3WhereTrace & 0x80000 ){
169076
+ SrcItem *pDim = aFromTabs + pWLoop->iTab;
169077
+ sqlite3DebugPrintf(
169078
+ "Increase SCAN cost of dimension %s(%d) of fact %s(%d) to %d\n",
169079
+ pDim->zAlias ? pDim->zAlias: pDim->pSTab->zName, pWLoop->iTab,
169080
+ pFactTab->zAlias ? pFactTab->zAlias : pFactTab->pSTab->zName,
169081
+ iFromIdx, mxRun
169082
+ );
169083
+ }
169084
+ pWLoop->rStarDelta = mxRun - pWLoop->rRun;
169085
+#endif /* WHERETRACE_ENABLED */
169086
+ pWLoop->rRun = mxRun;
169087
+ }
169088
+ }
169089
+ }
169090
+#ifdef WHERETRACE_ENABLED /* 0x80000 */
169091
+ if( (sqlite3WhereTrace & 0x80000)!=0 && pWInfo->bStarUsed ){
169092
+ sqlite3DebugPrintf("WhereLoops changed by star-query heuristic:\n");
168748169093
for(pWLoop=pWInfo->pLoops; pWLoop; pWLoop=pWLoop->pNextLoop){
168749
- if( pWLoop->maskSelf==m ){
168750
- pWLoop->rRun -= rDelta;
168751
- pWLoop->nOut -= rDelta;
168752
- pWLoop->rStarDelta = rDelta;
169094
+ if( pWLoop->rStarDelta ){
169095
+ sqlite3WhereLoopPrint(pWLoop, &pWInfo->sWC);
168753169096
}
168754169097
}
168755169098
}
169099
+#endif
168756169100
}
168757
- return pWInfo->nOutStarDelta>0 ? 18 : 12;
169101
+ return pWInfo->bStarUsed ? 18 : 12;
169102
+}
169103
+
169104
+/*
169105
+** Two WhereLoop objects, pCandidate and pBaseline, are known to have the
169106
+** same cost. Look deep into each to see if pCandidate is even slightly
169107
+** better than pBaseline. Return false if it is, if pCandidate is is preferred.
169108
+** Return true if pBaseline is preferred or if we cannot tell the difference.
169109
+**
169110
+** Result Meaning
169111
+** -------- ----------------------------------------------------------
169112
+** true We cannot tell the difference in pCandidate and pBaseline
169113
+** false pCandidate seems like a better choice than pBaseline
169114
+*/
169115
+static SQLITE_NOINLINE int whereLoopIsNoBetter(
169116
+ const WhereLoop *pCandidate,
169117
+ const WhereLoop *pBaseline
169118
+){
169119
+ if( (pCandidate->wsFlags & WHERE_INDEXED)==0 ) return 1;
169120
+ if( (pBaseline->wsFlags & WHERE_INDEXED)==0 ) return 1;
169121
+ if( pCandidate->u.btree.pIndex->szIdxRow <
169122
+ pBaseline->u.btree.pIndex->szIdxRow ) return 0;
169123
+ return 1;
168758169124
}
168759169125
168760169126
/*
168761169127
** Given the list of WhereLoop objects at pWInfo->pLoops, this routine
168762169128
** attempts to find the lowest cost path that visits each WhereLoop
@@ -168776,11 +169142,11 @@
168776169142
int iLoop; /* Loop counter over the terms of the join */
168777169143
int ii, jj; /* Loop counters */
168778169144
int mxI = 0; /* Index of next entry to replace */
168779169145
int nOrderBy; /* Number of ORDER BY clause terms */
168780169146
LogEst mxCost = 0; /* Maximum cost of a set of paths */
168781
- LogEst mxUnsorted = 0; /* Maximum unsorted cost of a set of path */
169147
+ LogEst mxUnsort = 0; /* Maximum unsorted cost of a set of path */
168782169148
int nTo, nFrom; /* Number of valid entries in aTo[] and aFrom[] */
168783169149
WherePath *aFrom; /* All nFrom paths at the previous level */
168784169150
WherePath *aTo; /* The nTo best paths at the current level */
168785169151
WherePath *pFrom; /* An element of aFrom[] that we are working on */
168786169152
WherePath *pTo; /* An element of aTo[] that we are working on */
@@ -168805,12 +169171,14 @@
168805169171
*/
168806169172
if( nLoop<=1 ){
168807169173
mxChoice = 1;
168808169174
}else if( nLoop==2 ){
168809169175
mxChoice = 5;
169176
+ }else if( pParse->nErr ){
169177
+ mxChoice = 1;
168810169178
}else{
168811
- mxChoice = computeMxChoice(pWInfo, nRowEst);
169179
+ mxChoice = computeMxChoice(pWInfo);
168812169180
}
168813169181
assert( nLoop<=pWInfo->pTabList->nSrc );
168814169182
168815169183
/* If nRowEst is zero and there is an ORDER BY clause, ignore it. In this
168816169184
** case the purpose of this call is to estimate the number of rows returned
@@ -168873,11 +169241,11 @@
168873169241
nTo = 0;
168874169242
for(ii=0, pFrom=aFrom; ii<nFrom; ii++, pFrom++){
168875169243
for(pWLoop=pWInfo->pLoops; pWLoop; pWLoop=pWLoop->pNextLoop){
168876169244
LogEst nOut; /* Rows visited by (pFrom+pWLoop) */
168877169245
LogEst rCost; /* Cost of path (pFrom+pWLoop) */
168878
- LogEst rUnsorted; /* Unsorted cost of (pFrom+pWLoop) */
169246
+ LogEst rUnsort; /* Unsorted cost of (pFrom+pWLoop) */
168879169247
i8 isOrdered; /* isOrdered for (pFrom+pWLoop) */
168880169248
Bitmask maskNew; /* Mask of src visited by (..) */
168881169249
Bitmask revMask; /* Mask of rev-order loops for (..) */
168882169250
168883169251
if( (pWLoop->prereq & ~pFrom->maskLoop)!=0 ) continue;
@@ -168891,15 +169259,15 @@
168891169259
continue;
168892169260
}
168893169261
168894169262
/* At this point, pWLoop is a candidate to be the next loop.
168895169263
** Compute its cost */
168896
- rUnsorted = pWLoop->rRun + pFrom->nRow;
169264
+ rUnsort = pWLoop->rRun + pFrom->nRow;
168897169265
if( pWLoop->rSetup ){
168898
- rUnsorted = sqlite3LogEstAdd(pWLoop->rSetup, rUnsorted);
169266
+ rUnsort = sqlite3LogEstAdd(pWLoop->rSetup, rUnsort);
168899169267
}
168900
- rUnsorted = sqlite3LogEstAdd(rUnsorted, pFrom->rUnsorted);
169268
+ rUnsort = sqlite3LogEstAdd(rUnsort, pFrom->rUnsort);
168901169269
nOut = pFrom->nRow + pWLoop->nOut;
168902169270
maskNew = pFrom->maskLoop | pWLoop->maskSelf;
168903169271
isOrdered = pFrom->isOrdered;
168904169272
if( isOrdered<0 ){
168905169273
revMask = 0;
@@ -168917,19 +169285,19 @@
168917169285
}
168918169286
/* TUNING: Add a small extra penalty (3) to sorting as an
168919169287
** extra encouragement to the query planner to select a plan
168920169288
** where the rows emerge in the correct order without any sorting
168921169289
** required. */
168922
- rCost = sqlite3LogEstAdd(rUnsorted, aSortCost[isOrdered]) + 3;
169290
+ rCost = sqlite3LogEstAdd(rUnsort, aSortCost[isOrdered]) + 3;
168923169291
168924169292
WHERETRACE(0x002,
168925169293
("---- sort cost=%-3d (%d/%d) increases cost %3d to %-3d\n",
168926169294
aSortCost[isOrdered], (nOrderBy-isOrdered), nOrderBy,
168927
- rUnsorted, rCost));
169295
+ rUnsort, rCost));
168928169296
}else{
168929
- rCost = rUnsorted;
168930
- rUnsorted -= 2; /* TUNING: Slight bias in favor of no-sort plans */
169297
+ rCost = rUnsort;
169298
+ rUnsort -= 2; /* TUNING: Slight bias in favor of no-sort plans */
168931169299
}
168932169300
168933169301
/* Check to see if pWLoop should be added to the set of
168934169302
** mxChoice best-so-far paths.
168935169303
**
@@ -168951,19 +169319,19 @@
168951169319
}
168952169320
}
168953169321
if( jj>=nTo ){
168954169322
/* None of the existing best-so-far paths match the candidate. */
168955169323
if( nTo>=mxChoice
168956
- && (rCost>mxCost || (rCost==mxCost && rUnsorted>=mxUnsorted))
169324
+ && (rCost>mxCost || (rCost==mxCost && rUnsort>=mxUnsort))
168957169325
){
168958169326
/* The current candidate is no better than any of the mxChoice
168959169327
** paths currently in the best-so-far buffer. So discard
168960169328
** this candidate as not viable. */
168961169329
#ifdef WHERETRACE_ENABLED /* 0x4 */
168962169330
if( sqlite3WhereTrace&0x4 ){
168963169331
sqlite3DebugPrintf("Skip %s cost=%-3d,%3d,%3d order=%c\n",
168964
- wherePathName(pFrom, iLoop, pWLoop), rCost, nOut, rUnsorted,
169332
+ wherePathName(pFrom, iLoop, pWLoop), rCost, nOut, rUnsort,
168965169333
isOrdered>=0 ? isOrdered+'0' : '?');
168966169334
}
168967169335
#endif
168968169336
continue;
168969169337
}
@@ -168978,11 +169346,11 @@
168978169346
}
168979169347
pTo = &aTo[jj];
168980169348
#ifdef WHERETRACE_ENABLED /* 0x4 */
168981169349
if( sqlite3WhereTrace&0x4 ){
168982169350
sqlite3DebugPrintf("New %s cost=%-3d,%3d,%3d order=%c\n",
168983
- wherePathName(pFrom, iLoop, pWLoop), rCost, nOut, rUnsorted,
169351
+ wherePathName(pFrom, iLoop, pWLoop), rCost, nOut, rUnsort,
168984169352
isOrdered>=0 ? isOrdered+'0' : '?');
168985169353
}
168986169354
#endif
168987169355
}else{
168988169356
/* Control reaches here if best-so-far path pTo=aTo[jj] covers the
@@ -168989,28 +169357,27 @@
168989169357
** same set of loops and has the same isOrdered setting as the
168990169358
** candidate path. Check to see if the candidate should replace
168991169359
** pTo or if the candidate should be skipped.
168992169360
**
168993169361
** The conditional is an expanded vector comparison equivalent to:
168994
- ** (pTo->rCost,pTo->nRow,pTo->rUnsorted) <= (rCost,nOut,rUnsorted)
169362
+ ** (pTo->rCost,pTo->nRow,pTo->rUnsort) <= (rCost,nOut,rUnsort)
168995169363
*/
168996
- if( pTo->rCost<rCost
168997
- || (pTo->rCost==rCost
168998
- && (pTo->nRow<nOut
168999
- || (pTo->nRow==nOut && pTo->rUnsorted<=rUnsorted)
169000
- )
169001
- )
169364
+ if( (pTo->rCost<rCost)
169365
+ || (pTo->rCost==rCost && pTo->nRow<nOut)
169366
+ || (pTo->rCost==rCost && pTo->nRow==nOut && pTo->rUnsort<rUnsort)
169367
+ || (pTo->rCost==rCost && pTo->nRow==nOut && pTo->rUnsort==rUnsort
169368
+ && whereLoopIsNoBetter(pWLoop, pTo->aLoop[iLoop]) )
169002169369
){
169003169370
#ifdef WHERETRACE_ENABLED /* 0x4 */
169004169371
if( sqlite3WhereTrace&0x4 ){
169005169372
sqlite3DebugPrintf(
169006169373
"Skip %s cost=%-3d,%3d,%3d order=%c",
169007
- wherePathName(pFrom, iLoop, pWLoop), rCost, nOut, rUnsorted,
169374
+ wherePathName(pFrom, iLoop, pWLoop), rCost, nOut, rUnsort,
169008169375
isOrdered>=0 ? isOrdered+'0' : '?');
169009169376
sqlite3DebugPrintf(" vs %s cost=%-3d,%3d,%3d order=%c\n",
169010169377
wherePathName(pTo, iLoop+1, 0), pTo->rCost, pTo->nRow,
169011
- pTo->rUnsorted, pTo->isOrdered>=0 ? pTo->isOrdered+'0' : '?');
169378
+ pTo->rUnsort, pTo->isOrdered>=0 ? pTo->isOrdered+'0' : '?');
169012169379
}
169013169380
#endif
169014169381
/* Discard the candidate path from further consideration */
169015169382
testcase( pTo->rCost==rCost );
169016169383
continue;
@@ -169020,37 +169387,37 @@
169020169387
** pTo path. Replace pTo with the candidate. */
169021169388
#ifdef WHERETRACE_ENABLED /* 0x4 */
169022169389
if( sqlite3WhereTrace&0x4 ){
169023169390
sqlite3DebugPrintf(
169024169391
"Update %s cost=%-3d,%3d,%3d order=%c",
169025
- wherePathName(pFrom, iLoop, pWLoop), rCost, nOut, rUnsorted,
169392
+ wherePathName(pFrom, iLoop, pWLoop), rCost, nOut, rUnsort,
169026169393
isOrdered>=0 ? isOrdered+'0' : '?');
169027169394
sqlite3DebugPrintf(" was %s cost=%-3d,%3d,%3d order=%c\n",
169028169395
wherePathName(pTo, iLoop+1, 0), pTo->rCost, pTo->nRow,
169029
- pTo->rUnsorted, pTo->isOrdered>=0 ? pTo->isOrdered+'0' : '?');
169396
+ pTo->rUnsort, pTo->isOrdered>=0 ? pTo->isOrdered+'0' : '?');
169030169397
}
169031169398
#endif
169032169399
}
169033169400
/* pWLoop is a winner. Add it to the set of best so far */
169034169401
pTo->maskLoop = pFrom->maskLoop | pWLoop->maskSelf;
169035169402
pTo->revLoop = revMask;
169036169403
pTo->nRow = nOut;
169037169404
pTo->rCost = rCost;
169038
- pTo->rUnsorted = rUnsorted;
169405
+ pTo->rUnsort = rUnsort;
169039169406
pTo->isOrdered = isOrdered;
169040169407
memcpy(pTo->aLoop, pFrom->aLoop, sizeof(WhereLoop*)*iLoop);
169041169408
pTo->aLoop[iLoop] = pWLoop;
169042169409
if( nTo>=mxChoice ){
169043169410
mxI = 0;
169044169411
mxCost = aTo[0].rCost;
169045
- mxUnsorted = aTo[0].nRow;
169412
+ mxUnsort = aTo[0].nRow;
169046169413
for(jj=1, pTo=&aTo[1]; jj<mxChoice; jj++, pTo++){
169047169414
if( pTo->rCost>mxCost
169048
- || (pTo->rCost==mxCost && pTo->rUnsorted>mxUnsorted)
169415
+ || (pTo->rCost==mxCost && pTo->rUnsort>mxUnsort)
169049169416
){
169050169417
mxCost = pTo->rCost;
169051
- mxUnsorted = pTo->rUnsorted;
169418
+ mxUnsort = pTo->rUnsort;
169052169419
mxI = jj;
169053169420
}
169054169421
}
169055169422
}
169056169423
}
@@ -169058,12 +169425,14 @@
169058169425
169059169426
#ifdef WHERETRACE_ENABLED /* >=2 */
169060169427
if( sqlite3WhereTrace & 0x02 ){
169061169428
LogEst rMin, rFloor = 0;
169062169429
int nDone = 0;
169430
+ int nProgress;
169063169431
sqlite3DebugPrintf("---- after round %d ----\n", iLoop);
169064
- while( nDone<nTo ){
169432
+ do{
169433
+ nProgress = 0;
169065169434
rMin = 0x7fff;
169066169435
for(ii=0, pTo=aTo; ii<nTo; ii++, pTo++){
169067169436
if( pTo->rCost>rFloor && pTo->rCost<rMin ) rMin = pTo->rCost;
169068169437
}
169069169438
for(ii=0, pTo=aTo; ii<nTo; ii++, pTo++){
@@ -169075,14 +169444,15 @@
169075169444
sqlite3DebugPrintf(" rev=0x%llx\n", pTo->revLoop);
169076169445
}else{
169077169446
sqlite3DebugPrintf("\n");
169078169447
}
169079169448
nDone++;
169449
+ nProgress++;
169080169450
}
169081169451
}
169082169452
rFloor = rMin;
169083
- }
169453
+ }while( nDone<nTo && nProgress>0 );
169084169454
}
169085169455
#endif
169086169456
169087169457
/* Swap the roles of aFrom and aTo for the next generation */
169088169458
pFrom = aTo;
@@ -169172,11 +169542,14 @@
169172169542
pWInfo->revMask = revMask;
169173169543
}
169174169544
}
169175169545
}
169176169546
169177
- pWInfo->nRowOut = pFrom->nRow + pWInfo->nOutStarDelta;
169547
+ pWInfo->nRowOut = pFrom->nRow;
169548
+#ifdef WHERETRACE_ENABLED
169549
+ pWInfo->rTotalCost = pFrom->rCost;
169550
+#endif
169178169551
169179169552
/* Free temporary memory and return success */
169180169553
sqlite3StackFreeNN(pParse->db, pSpace);
169181169554
return SQLITE_OK;
169182169555
}
@@ -169570,11 +169943,10 @@
169570169943
pLoop->cId, (double)sqlite3LogEstToInt(nSearch), pTab->zName,
169571169944
(double)sqlite3LogEstToInt(pTab->nRowLogEst)));
169572169945
}
169573169946
}
169574169947
nSearch += pLoop->nOut;
169575
- if( pWInfo->nOutStarDelta ) nSearch += pLoop->rStarDelta;
169576169948
}
169577169949
}
169578169950
169579169951
/*
169580169952
** The index pIdx is used by a query and contains one or more expressions.
@@ -170053,11 +170425,12 @@
170053170425
goto whereBeginError;
170054170426
}
170055170427
assert( db->mallocFailed==0 );
170056170428
#ifdef WHERETRACE_ENABLED
170057170429
if( sqlite3WhereTrace ){
170058
- sqlite3DebugPrintf("---- Solution nRow=%d", pWInfo->nRowOut);
170430
+ sqlite3DebugPrintf("---- Solution cost=%d, nRow=%d",
170431
+ pWInfo->rTotalCost, pWInfo->nRowOut);
170059170432
if( pWInfo->nOBSat>0 ){
170060170433
sqlite3DebugPrintf(" ORDERBY=%d,0x%llx", pWInfo->nOBSat, pWInfo->revMask);
170061170434
}
170062170435
switch( pWInfo->eDistinct ){
170063170436
case WHERE_DISTINCT_UNIQUE: {
@@ -170414,10 +170787,11 @@
170414170787
int pc,
170415170788
VdbeOp *pOp
170416170789
){
170417170790
if( (db->flags & SQLITE_VdbeAddopTrace)==0 ) return;
170418170791
sqlite3VdbePrintOp(0, pc, pOp);
170792
+ sqlite3ShowWhereTerm(0); /* So compiler won't complain about unused func */
170419170793
}
170420170794
#endif
170421170795
170422170796
/*
170423170797
** Generate the end of the WHERE loop. See comments on
@@ -172523,11 +172897,11 @@
172523172897
sqlite3VdbeAddOp4(v, OP_CollSeq, 0,0,0, (const char*)pColl, P4_COLLSEQ);
172524172898
}
172525172899
sqlite3VdbeAddOp3(v, bInverse? OP_AggInverse : OP_AggStep,
172526172900
bInverse, regArg, pWin->regAccum);
172527172901
sqlite3VdbeAppendP4(v, pFunc, P4_FUNCDEF);
172528
- sqlite3VdbeChangeP5(v, (u8)nArg);
172902
+ sqlite3VdbeChangeP5(v, (u16)nArg);
172529172903
if( pWin->bExprArgs ){
172530172904
sqlite3ReleaseTempRange(pParse, regArg, nArg);
172531172905
}
172532172906
}
172533172907
@@ -173907,10 +174281,15 @@
173907174281
** to the original parse.y sources.
173908174282
*/
173909174283
173910174284
/* #include "sqliteInt.h" */
173911174285
174286
+/*
174287
+** Verify that the pParse->isCreate field is set
174288
+*/
174289
+#define ASSERT_IS_CREATE assert(pParse->isCreate)
174290
+
173912174291
/*
173913174292
** Disable all error recovery processing in the parser push-down
173914174293
** automaton.
173915174294
*/
173916174295
#define YYNOERRORRECOVERY 1
@@ -173970,10 +174349,14 @@
173970174349
** shared across database connections.
173971174350
*/
173972174351
static void disableLookaside(Parse *pParse){
173973174352
sqlite3 *db = pParse->db;
173974174353
pParse->disableLookaside++;
174354
+#ifdef SQLITE_DEBUG
174355
+ pParse->isCreate = 1;
174356
+#endif
174357
+ memset(&pParse->u1.cr, 0, sizeof(pParse->u1.cr));
173975174358
DisableLookaside;
173976174359
}
173977174360
173978174361
#if !defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT) \
173979174362
&& defined(SQLITE_UDL_CAPABLE_PARSER)
@@ -174310,11 +174693,12 @@
174310174693
#define TK_ASTERISK 180
174311174694
#define TK_SPAN 181
174312174695
#define TK_ERROR 182
174313174696
#define TK_QNUMBER 183
174314174697
#define TK_SPACE 184
174315
-#define TK_ILLEGAL 185
174698
+#define TK_COMMENT 185
174699
+#define TK_ILLEGAL 186
174316174700
#endif
174317174701
/**************** End token definitions ***************************************/
174318174702
174319174703
/* The next sections is a series of control #defines.
174320174704
** various aspects of the generated parser.
@@ -174375,35 +174759,35 @@
174375174759
#ifndef INTERFACE
174376174760
# define INTERFACE 1
174377174761
#endif
174378174762
/************* Begin control #defines *****************************************/
174379174763
#define YYCODETYPE unsigned short int
174380
-#define YYNOCODE 322
174764
+#define YYNOCODE 323
174381174765
#define YYACTIONTYPE unsigned short int
174382174766
#define YYWILDCARD 102
174383174767
#define sqlite3ParserTOKENTYPE Token
174384174768
typedef union {
174385174769
int yyinit;
174386174770
sqlite3ParserTOKENTYPE yy0;
174387
- ExprList* yy14;
174388
- With* yy59;
174389
- Cte* yy67;
174390
- Upsert* yy122;
174391
- IdList* yy132;
174392
- int yy144;
174393
- const char* yy168;
174394
- SrcList* yy203;
174395
- Window* yy211;
174396
- OnOrUsing yy269;
174397
- struct TrigEvent yy286;
174398
- struct {int value; int mask;} yy383;
174399
- u32 yy391;
174400
- TriggerStep* yy427;
174401
- Expr* yy454;
174402
- u8 yy462;
174403
- struct FrameBound yy509;
174404
- Select* yy555;
174771
+ u32 yy9;
174772
+ struct TrigEvent yy28;
174773
+ With* yy125;
174774
+ IdList* yy204;
174775
+ struct FrameBound yy205;
174776
+ TriggerStep* yy319;
174777
+ const char* yy342;
174778
+ Cte* yy361;
174779
+ ExprList* yy402;
174780
+ Upsert* yy403;
174781
+ OnOrUsing yy421;
174782
+ u8 yy444;
174783
+ struct {int value; int mask;} yy481;
174784
+ Window* yy483;
174785
+ int yy502;
174786
+ SrcList* yy563;
174787
+ Expr* yy590;
174788
+ Select* yy637;
174405174789
} YYMINORTYPE;
174406174790
#ifndef YYSTACKDEPTH
174407174791
#define YYSTACKDEPTH 100
174408174792
#endif
174409174793
#define sqlite3ParserARG_SDECL
@@ -174421,21 +174805,21 @@
174421174805
#define sqlite3ParserCTX_STORE yypParser->pParse=pParse;
174422174806
#define YYFALLBACK 1
174423174807
#define YYNSTATE 583
174424174808
#define YYNRULE 409
174425174809
#define YYNRULE_WITH_ACTION 344
174426
-#define YYNTOKEN 186
174810
+#define YYNTOKEN 187
174427174811
#define YY_MAX_SHIFT 582
174428174812
#define YY_MIN_SHIFTREDUCE 845
174429174813
#define YY_MAX_SHIFTREDUCE 1253
174430174814
#define YY_ERROR_ACTION 1254
174431174815
#define YY_ACCEPT_ACTION 1255
174432174816
#define YY_NO_ACTION 1256
174433174817
#define YY_MIN_REDUCE 1257
174434174818
#define YY_MAX_REDUCE 1665
174435
-#define YY_MIN_DSTRCTR 205
174436
-#define YY_MAX_DSTRCTR 319
174819
+#define YY_MIN_DSTRCTR 206
174820
+#define YY_MAX_DSTRCTR 320
174437174821
/************* End control #defines *******************************************/
174438174822
#define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])))
174439174823
174440174824
/* Define the yytestcase() macro to be a no-op if is not already defined
174441174825
** otherwise.
@@ -174527,573 +174911,573 @@
174527174911
/* 60 */ 288, 288, 182, 288, 288, 481, 536, 288, 288, 130,
174528174912
/* 70 */ 127, 234, 432, 573, 525, 562, 573, 557, 562, 1290,
174529174913
/* 80 */ 573, 421, 562, 137, 138, 91, 559, 1228, 1228, 1063,
174530174914
/* 90 */ 1066, 1053, 1053, 135, 135, 136, 136, 136, 136, 296,
174531174915
/* 100 */ 460, 398, 1249, 134, 134, 134, 134, 133, 133, 132,
174532
- /* 110 */ 132, 132, 131, 128, 451, 44, 1050, 1050, 1064, 1067,
174916
+ /* 110 */ 132, 132, 131, 128, 451, 451, 1050, 1050, 1064, 1067,
174533174917
/* 120 */ 1255, 1, 1, 582, 2, 1259, 581, 1174, 1259, 1174,
174534
- /* 130 */ 321, 413, 155, 321, 1584, 155, 379, 112, 498, 1341,
174918
+ /* 130 */ 321, 413, 155, 321, 1584, 155, 379, 112, 481, 1341,
174535174919
/* 140 */ 456, 299, 1341, 134, 134, 134, 134, 133, 133, 132,
174536
- /* 150 */ 132, 132, 131, 128, 451, 137, 138, 91, 1105, 1228,
174920
+ /* 150 */ 132, 132, 131, 128, 451, 137, 138, 91, 498, 1228,
174537174921
/* 160 */ 1228, 1063, 1066, 1053, 1053, 135, 135, 136, 136, 136,
174538
- /* 170 */ 136, 1204, 320, 567, 288, 288, 283, 288, 288, 523,
174539
- /* 180 */ 523, 1250, 139, 1541, 7, 214, 503, 573, 1169, 562,
174540
- /* 190 */ 573, 1054, 562, 136, 136, 136, 136, 129, 401, 547,
174541
- /* 200 */ 487, 1169, 245, 1568, 1169, 245, 133, 133, 132, 132,
174542
- /* 210 */ 132, 131, 128, 451, 261, 134, 134, 134, 134, 133,
174543
- /* 220 */ 133, 132, 132, 132, 131, 128, 451, 451, 1204, 1205,
174544
- /* 230 */ 1204, 130, 127, 234, 455, 413, 182, 455, 130, 127,
174922
+ /* 170 */ 136, 1204, 862, 1281, 288, 288, 283, 288, 288, 523,
174923
+ /* 180 */ 523, 1250, 139, 578, 7, 578, 1345, 573, 1169, 562,
174924
+ /* 190 */ 573, 1054, 562, 136, 136, 136, 136, 129, 573, 547,
174925
+ /* 200 */ 562, 1169, 245, 1541, 1169, 245, 133, 133, 132, 132,
174926
+ /* 210 */ 132, 131, 128, 451, 302, 134, 134, 134, 134, 133,
174927
+ /* 220 */ 133, 132, 132, 132, 131, 128, 451, 1575, 1204, 1205,
174928
+ /* 230 */ 1204, 7, 470, 550, 455, 413, 550, 455, 130, 127,
174545174929
/* 240 */ 234, 134, 134, 134, 134, 133, 133, 132, 132, 132,
174546
- /* 250 */ 131, 128, 451, 136, 136, 136, 136, 538, 576, 137,
174547
- /* 260 */ 138, 91, 261, 1228, 1228, 1063, 1066, 1053, 1053, 135,
174548
- /* 270 */ 135, 136, 136, 136, 136, 44, 472, 346, 1204, 472,
174549
- /* 280 */ 346, 51, 51, 418, 93, 157, 134, 134, 134, 134,
174550
- /* 290 */ 133, 133, 132, 132, 132, 131, 128, 451, 166, 363,
174551
- /* 300 */ 298, 134, 134, 134, 134, 133, 133, 132, 132, 132,
174552
- /* 310 */ 131, 128, 451, 1293, 461, 1570, 423, 377, 275, 134,
174930
+ /* 250 */ 131, 128, 451, 136, 136, 136, 136, 538, 483, 137,
174931
+ /* 260 */ 138, 91, 1019, 1228, 1228, 1063, 1066, 1053, 1053, 135,
174932
+ /* 270 */ 135, 136, 136, 136, 136, 1085, 576, 1204, 132, 132,
174933
+ /* 280 */ 132, 131, 128, 451, 93, 214, 134, 134, 134, 134,
174934
+ /* 290 */ 133, 133, 132, 132, 132, 131, 128, 451, 401, 19,
174935
+ /* 300 */ 19, 134, 134, 134, 134, 133, 133, 132, 132, 132,
174936
+ /* 310 */ 131, 128, 451, 1498, 426, 267, 344, 467, 332, 134,
174553174937
/* 320 */ 134, 134, 134, 133, 133, 132, 132, 132, 131, 128,
174554
- /* 330 */ 451, 418, 320, 567, 1292, 1204, 1205, 1204, 257, 413,
174555
- /* 340 */ 483, 511, 508, 507, 94, 132, 132, 132, 131, 128,
174556
- /* 350 */ 451, 506, 1204, 548, 548, 388, 576, 384, 7, 413,
174557
- /* 360 */ 550, 229, 522, 137, 138, 91, 530, 1228, 1228, 1063,
174558
- /* 370 */ 1066, 1053, 1053, 135, 135, 136, 136, 136, 136, 51,
174559
- /* 380 */ 51, 1582, 380, 137, 138, 91, 331, 1228, 1228, 1063,
174560
- /* 390 */ 1066, 1053, 1053, 135, 135, 136, 136, 136, 136, 320,
174561
- /* 400 */ 567, 288, 288, 320, 567, 1602, 582, 2, 1259, 1204,
174562
- /* 410 */ 1205, 1204, 1628, 321, 573, 155, 562, 576, 1511, 264,
174563
- /* 420 */ 231, 520, 1341, 134, 134, 134, 134, 133, 133, 132,
174564
- /* 430 */ 132, 132, 131, 128, 451, 519, 1511, 1513, 1333, 1333,
174565
- /* 440 */ 82, 82, 498, 134, 134, 134, 134, 133, 133, 132,
174566
- /* 450 */ 132, 132, 131, 128, 451, 1435, 257, 288, 288, 511,
174567
- /* 460 */ 508, 507, 944, 1568, 413, 1019, 1204, 943, 360, 506,
174568
- /* 470 */ 573, 1598, 562, 44, 575, 551, 551, 557, 1107, 1582,
174569
- /* 480 */ 544, 576, 1107, 40, 417, 245, 531, 1505, 137, 138,
174938
+ /* 330 */ 451, 1281, 576, 6, 1204, 1205, 1204, 257, 576, 413,
174939
+ /* 340 */ 511, 508, 507, 1279, 94, 1019, 464, 1204, 551, 551,
174940
+ /* 350 */ 506, 1224, 1571, 44, 38, 51, 51, 411, 576, 413,
174941
+ /* 360 */ 45, 51, 51, 137, 138, 91, 530, 1228, 1228, 1063,
174942
+ /* 370 */ 1066, 1053, 1053, 135, 135, 136, 136, 136, 136, 398,
174943
+ /* 380 */ 1148, 82, 82, 137, 138, 91, 39, 1228, 1228, 1063,
174944
+ /* 390 */ 1066, 1053, 1053, 135, 135, 136, 136, 136, 136, 344,
174945
+ /* 400 */ 44, 288, 288, 375, 1204, 1205, 1204, 209, 1204, 1224,
174946
+ /* 410 */ 320, 567, 471, 576, 573, 576, 562, 576, 316, 264,
174947
+ /* 420 */ 231, 46, 160, 134, 134, 134, 134, 133, 133, 132,
174948
+ /* 430 */ 132, 132, 131, 128, 451, 303, 82, 82, 82, 82,
174949
+ /* 440 */ 82, 82, 442, 134, 134, 134, 134, 133, 133, 132,
174950
+ /* 450 */ 132, 132, 131, 128, 451, 1582, 544, 320, 567, 1250,
174951
+ /* 460 */ 874, 1582, 380, 382, 413, 1204, 1205, 1204, 360, 182,
174952
+ /* 470 */ 288, 288, 1576, 557, 1339, 557, 7, 557, 1277, 472,
174953
+ /* 480 */ 346, 526, 531, 573, 556, 562, 439, 1511, 137, 138,
174570174954
/* 490 */ 91, 219, 1228, 1228, 1063, 1066, 1053, 1053, 135, 135,
174571
- /* 500 */ 136, 136, 136, 136, 81, 81, 1281, 1204, 413, 553,
174572
- /* 510 */ 1511, 48, 512, 448, 447, 493, 578, 455, 578, 344,
174573
- /* 520 */ 45, 1204, 1233, 1204, 1205, 1204, 428, 1235, 158, 882,
174574
- /* 530 */ 320, 567, 137, 138, 91, 1234, 1228, 1228, 1063, 1066,
174955
+ /* 500 */ 136, 136, 136, 136, 465, 1511, 1513, 532, 413, 288,
174956
+ /* 510 */ 288, 423, 512, 288, 288, 411, 288, 288, 874, 130,
174957
+ /* 520 */ 127, 234, 573, 1107, 562, 1204, 573, 1107, 562, 573,
174958
+ /* 530 */ 560, 562, 137, 138, 91, 1293, 1228, 1228, 1063, 1066,
174575174959
/* 540 */ 1053, 1053, 135, 135, 136, 136, 136, 136, 134, 134,
174576174960
/* 550 */ 134, 134, 133, 133, 132, 132, 132, 131, 128, 451,
174577
- /* 560 */ 1236, 576, 1236, 329, 1204, 1205, 1204, 387, 492, 403,
174578
- /* 570 */ 1040, 382, 489, 123, 568, 1569, 4, 377, 1204, 1205,
174579
- /* 580 */ 1204, 570, 570, 570, 82, 82, 882, 1029, 1331, 1331,
174580
- /* 590 */ 571, 1028, 134, 134, 134, 134, 133, 133, 132, 132,
174581
- /* 600 */ 132, 131, 128, 451, 288, 288, 1281, 1204, 576, 423,
174582
- /* 610 */ 576, 1568, 413, 423, 452, 378, 886, 573, 1279, 562,
174583
- /* 620 */ 46, 557, 532, 1028, 1028, 1030, 565, 130, 127, 234,
174584
- /* 630 */ 556, 82, 82, 82, 82, 479, 137, 138, 91, 462,
174961
+ /* 560 */ 493, 503, 1292, 1204, 257, 288, 288, 511, 508, 507,
174962
+ /* 570 */ 1204, 1628, 1169, 123, 568, 275, 4, 506, 573, 1511,
174963
+ /* 580 */ 562, 331, 1204, 1205, 1204, 1169, 548, 548, 1169, 261,
174964
+ /* 590 */ 571, 7, 134, 134, 134, 134, 133, 133, 132, 132,
174965
+ /* 600 */ 132, 131, 128, 451, 108, 533, 130, 127, 234, 1204,
174966
+ /* 610 */ 448, 447, 413, 1451, 452, 983, 886, 96, 1598, 1233,
174967
+ /* 620 */ 1204, 1205, 1204, 984, 1235, 1450, 565, 1204, 1205, 1204,
174968
+ /* 630 */ 229, 522, 1234, 534, 1333, 1333, 137, 138, 91, 1449,
174585174969
/* 640 */ 1228, 1228, 1063, 1066, 1053, 1053, 135, 135, 136, 136,
174586
- /* 650 */ 136, 136, 1188, 487, 1506, 1040, 413, 6, 1204, 50,
174587
- /* 660 */ 879, 121, 121, 948, 1204, 1205, 1204, 358, 557, 122,
174588
- /* 670 */ 316, 452, 577, 452, 535, 1204, 1028, 439, 303, 212,
174589
- /* 680 */ 137, 138, 91, 213, 1228, 1228, 1063, 1066, 1053, 1053,
174970
+ /* 650 */ 136, 136, 373, 1595, 971, 1040, 413, 1236, 418, 1236,
174971
+ /* 660 */ 879, 121, 121, 948, 373, 1595, 1204, 1205, 1204, 122,
174972
+ /* 670 */ 1204, 452, 577, 452, 363, 417, 1028, 882, 373, 1595,
174973
+ /* 680 */ 137, 138, 91, 462, 1228, 1228, 1063, 1066, 1053, 1053,
174590174974
/* 690 */ 135, 135, 136, 136, 136, 136, 134, 134, 134, 134,
174591174975
/* 700 */ 133, 133, 132, 132, 132, 131, 128, 451, 1028, 1028,
174592
- /* 710 */ 1030, 1031, 35, 288, 288, 1204, 1205, 1204, 1040, 1339,
174593
- /* 720 */ 533, 123, 568, 1569, 4, 377, 573, 1019, 562, 353,
174594
- /* 730 */ 1277, 356, 1204, 1205, 1204, 1029, 488, 1188, 571, 1028,
174976
+ /* 710 */ 1030, 1031, 35, 570, 570, 570, 197, 423, 1040, 198,
174977
+ /* 720 */ 1204, 123, 568, 1204, 4, 320, 567, 1204, 1205, 1204,
174978
+ /* 730 */ 40, 388, 576, 384, 882, 1029, 423, 1188, 571, 1028,
174595174979
/* 740 */ 134, 134, 134, 134, 133, 133, 132, 132, 132, 131,
174596
- /* 750 */ 128, 451, 576, 343, 288, 288, 449, 449, 449, 971,
174597
- /* 760 */ 413, 1627, 452, 911, 1187, 288, 288, 573, 464, 562,
174598
- /* 770 */ 238, 1028, 1028, 1030, 565, 82, 82, 498, 573, 411,
174599
- /* 780 */ 562, 344, 467, 332, 137, 138, 91, 197, 1228, 1228,
174980
+ /* 750 */ 128, 451, 529, 1568, 1204, 19, 19, 1204, 575, 492,
174981
+ /* 760 */ 413, 157, 452, 489, 1187, 1331, 1331, 5, 1204, 949,
174982
+ /* 770 */ 431, 1028, 1028, 1030, 565, 22, 22, 1204, 1205, 1204,
174983
+ /* 780 */ 1204, 1205, 1204, 477, 137, 138, 91, 212, 1228, 1228,
174600174984
/* 790 */ 1063, 1066, 1053, 1053, 135, 135, 136, 136, 136, 136,
174601
- /* 800 */ 1188, 528, 1169, 1040, 413, 1110, 1110, 495, 1041, 121,
174602
- /* 810 */ 121, 1204, 317, 540, 862, 1169, 1244, 122, 1169, 452,
174603
- /* 820 */ 577, 452, 1340, 198, 1028, 1204, 481, 526, 137, 138,
174604
- /* 830 */ 91, 560, 1228, 1228, 1063, 1066, 1053, 1053, 135, 135,
174985
+ /* 800 */ 1188, 48, 111, 1040, 413, 1204, 213, 970, 1041, 121,
174986
+ /* 810 */ 121, 1204, 1205, 1204, 1204, 1205, 1204, 122, 221, 452,
174987
+ /* 820 */ 577, 452, 44, 487, 1028, 1204, 1205, 1204, 137, 138,
174988
+ /* 830 */ 91, 378, 1228, 1228, 1063, 1066, 1053, 1053, 135, 135,
174605174989
/* 840 */ 136, 136, 136, 136, 134, 134, 134, 134, 133, 133,
174606174990
/* 850 */ 132, 132, 132, 131, 128, 451, 1028, 1028, 1030, 1031,
174607
- /* 860 */ 35, 1204, 288, 288, 1204, 477, 288, 288, 1204, 1205,
174608
- /* 870 */ 1204, 539, 481, 437, 470, 573, 1451, 562, 364, 573,
174609
- /* 880 */ 1153, 562, 1204, 1205, 1204, 1188, 5, 576, 134, 134,
174991
+ /* 860 */ 35, 461, 1204, 1205, 1204, 1569, 1040, 377, 214, 1149,
174992
+ /* 870 */ 1657, 535, 1657, 437, 902, 320, 567, 1568, 364, 320,
174993
+ /* 880 */ 567, 412, 329, 1029, 519, 1188, 3, 1028, 134, 134,
174610174994
/* 890 */ 134, 134, 133, 133, 132, 132, 132, 131, 128, 451,
174611
- /* 900 */ 221, 214, 302, 96, 1149, 1657, 232, 1657, 413, 392,
174612
- /* 910 */ 19, 19, 1024, 949, 406, 373, 1595, 1085, 1204, 1205,
174613
- /* 920 */ 1204, 1204, 1205, 1204, 1204, 426, 1149, 1658, 413, 1658,
174614
- /* 930 */ 1659, 399, 137, 138, 91, 3, 1228, 1228, 1063, 1066,
174615
- /* 940 */ 1053, 1053, 135, 135, 136, 136, 136, 136, 304, 1311,
174616
- /* 950 */ 514, 1204, 137, 138, 91, 1498, 1228, 1228, 1063, 1066,
174617
- /* 960 */ 1053, 1053, 135, 135, 136, 136, 136, 136, 434, 131,
174618
- /* 970 */ 128, 451, 375, 1204, 274, 291, 372, 517, 367, 516,
174619
- /* 980 */ 262, 1204, 1205, 1204, 1147, 227, 363, 448, 447, 1435,
174620
- /* 990 */ 1568, 1310, 134, 134, 134, 134, 133, 133, 132, 132,
174621
- /* 1000 */ 132, 131, 128, 451, 1568, 576, 1147, 487, 1204, 1205,
174622
- /* 1010 */ 1204, 442, 134, 134, 134, 134, 133, 133, 132, 132,
174623
- /* 1020 */ 132, 131, 128, 451, 386, 576, 485, 576, 19, 19,
174624
- /* 1030 */ 1204, 1205, 1204, 1345, 1236, 970, 1236, 574, 47, 936,
174625
- /* 1040 */ 936, 473, 413, 431, 1552, 573, 1125, 562, 19, 19,
174626
- /* 1050 */ 19, 19, 49, 336, 850, 851, 852, 111, 1368, 315,
174627
- /* 1060 */ 429, 576, 413, 433, 341, 306, 137, 138, 91, 115,
174995
+ /* 900 */ 1659, 399, 1169, 307, 893, 307, 515, 576, 413, 214,
174996
+ /* 910 */ 498, 944, 1024, 540, 903, 1169, 943, 392, 1169, 1028,
174997
+ /* 920 */ 1028, 1030, 406, 298, 1204, 50, 1149, 1658, 413, 1658,
174998
+ /* 930 */ 145, 145, 137, 138, 91, 293, 1228, 1228, 1063, 1066,
174999
+ /* 940 */ 1053, 1053, 135, 135, 136, 136, 136, 136, 1188, 1147,
175000
+ /* 950 */ 514, 1568, 137, 138, 91, 1505, 1228, 1228, 1063, 1066,
175001
+ /* 960 */ 1053, 1053, 135, 135, 136, 136, 136, 136, 434, 323,
175002
+ /* 970 */ 435, 539, 111, 1506, 274, 291, 372, 517, 367, 516,
175003
+ /* 980 */ 262, 1204, 1205, 1204, 1574, 481, 363, 576, 7, 1569,
175004
+ /* 990 */ 1568, 377, 134, 134, 134, 134, 133, 133, 132, 132,
175005
+ /* 1000 */ 132, 131, 128, 451, 1568, 576, 1147, 576, 232, 576,
175006
+ /* 1010 */ 19, 19, 134, 134, 134, 134, 133, 133, 132, 132,
175007
+ /* 1020 */ 132, 131, 128, 451, 1169, 433, 576, 1207, 19, 19,
175008
+ /* 1030 */ 19, 19, 19, 19, 1627, 576, 911, 1169, 47, 120,
175009
+ /* 1040 */ 1169, 117, 413, 306, 498, 438, 1125, 206, 336, 19,
175010
+ /* 1050 */ 19, 1435, 49, 449, 449, 449, 1368, 315, 81, 81,
175011
+ /* 1060 */ 576, 304, 413, 1570, 207, 377, 137, 138, 91, 115,
174628175012
/* 1070 */ 1228, 1228, 1063, 1066, 1053, 1053, 135, 135, 136, 136,
174629
- /* 1080 */ 136, 136, 576, 1309, 82, 82, 137, 138, 91, 529,
175013
+ /* 1080 */ 136, 136, 576, 82, 82, 1207, 137, 138, 91, 1340,
174630175014
/* 1090 */ 1228, 1228, 1063, 1066, 1053, 1053, 135, 135, 136, 136,
174631
- /* 1100 */ 136, 136, 1569, 222, 377, 19, 19, 305, 1126, 1169,
174632
- /* 1110 */ 398, 1148, 22, 22, 498, 333, 1569, 335, 377, 576,
174633
- /* 1120 */ 438, 445, 1169, 1127, 486, 1169, 134, 134, 134, 134,
175015
+ /* 1100 */ 136, 136, 1569, 386, 377, 82, 82, 463, 1126, 1552,
175016
+ /* 1110 */ 333, 463, 335, 131, 128, 451, 1569, 161, 377, 16,
175017
+ /* 1120 */ 317, 387, 428, 1127, 448, 447, 134, 134, 134, 134,
174634175018
/* 1130 */ 133, 133, 132, 132, 132, 131, 128, 451, 1128, 576,
174635
- /* 1140 */ 902, 576, 145, 145, 6, 576, 134, 134, 134, 134,
174636
- /* 1150 */ 133, 133, 132, 132, 132, 131, 128, 451, 214, 1336,
174637
- /* 1160 */ 922, 576, 19, 19, 19, 19, 1282, 419, 19, 19,
174638
- /* 1170 */ 923, 412, 515, 141, 576, 1169, 413, 206, 465, 207,
174639
- /* 1180 */ 903, 215, 1575, 552, 147, 147, 7, 227, 1169, 411,
174640
- /* 1190 */ 1250, 1169, 120, 307, 117, 307, 413, 66, 66, 334,
175019
+ /* 1140 */ 1105, 10, 445, 267, 576, 1554, 134, 134, 134, 134,
175020
+ /* 1150 */ 133, 133, 132, 132, 132, 131, 128, 451, 532, 576,
175021
+ /* 1160 */ 922, 576, 19, 19, 576, 1573, 576, 147, 147, 7,
175022
+ /* 1170 */ 923, 1236, 498, 1236, 576, 487, 413, 552, 285, 1224,
175023
+ /* 1180 */ 969, 215, 82, 82, 66, 66, 1435, 67, 67, 21,
175024
+ /* 1190 */ 21, 1110, 1110, 495, 334, 297, 413, 53, 53, 297,
174641175025
/* 1200 */ 137, 138, 91, 119, 1228, 1228, 1063, 1066, 1053, 1053,
174642
- /* 1210 */ 135, 135, 136, 136, 136, 136, 413, 285, 209, 969,
174643
- /* 1220 */ 137, 138, 91, 471, 1228, 1228, 1063, 1066, 1053, 1053,
174644
- /* 1230 */ 135, 135, 136, 136, 136, 136, 435, 10, 1450, 267,
174645
- /* 1240 */ 137, 126, 91, 1435, 1228, 1228, 1063, 1066, 1053, 1053,
174646
- /* 1250 */ 135, 135, 136, 136, 136, 136, 1435, 1435, 410, 409,
175026
+ /* 1210 */ 135, 135, 136, 136, 136, 136, 413, 1336, 1311, 446,
175027
+ /* 1220 */ 137, 138, 91, 227, 1228, 1228, 1063, 1066, 1053, 1053,
175028
+ /* 1230 */ 135, 135, 136, 136, 136, 136, 574, 1224, 936, 936,
175029
+ /* 1240 */ 137, 126, 91, 141, 1228, 1228, 1063, 1066, 1053, 1053,
175030
+ /* 1250 */ 135, 135, 136, 136, 136, 136, 533, 429, 472, 346,
174647175031
/* 1260 */ 134, 134, 134, 134, 133, 133, 132, 132, 132, 131,
174648
- /* 1270 */ 128, 451, 576, 969, 576, 1224, 498, 373, 1595, 1554,
175032
+ /* 1270 */ 128, 451, 576, 457, 233, 343, 1435, 403, 498, 1550,
174649175033
/* 1280 */ 134, 134, 134, 134, 133, 133, 132, 132, 132, 131,
174650
- /* 1290 */ 128, 451, 532, 457, 576, 82, 82, 82, 82, 111,
175034
+ /* 1290 */ 128, 451, 576, 324, 576, 82, 82, 487, 576, 969,
174651175035
/* 1300 */ 134, 134, 134, 134, 133, 133, 132, 132, 132, 131,
174652
- /* 1310 */ 128, 451, 109, 233, 430, 1576, 546, 67, 67, 7,
174653
- /* 1320 */ 413, 351, 550, 1550, 260, 259, 258, 494, 443, 569,
174654
- /* 1330 */ 419, 983, 446, 1224, 450, 545, 1207, 576, 969, 984,
174655
- /* 1340 */ 413, 475, 1449, 1574, 1180, 138, 91, 7, 1228, 1228,
175036
+ /* 1310 */ 128, 451, 288, 288, 546, 68, 68, 54, 54, 553,
175037
+ /* 1320 */ 413, 69, 69, 351, 6, 573, 944, 562, 410, 409,
175038
+ /* 1330 */ 1435, 943, 450, 545, 260, 259, 258, 576, 158, 576,
175039
+ /* 1340 */ 413, 222, 1180, 479, 969, 138, 91, 430, 1228, 1228,
174656175040
/* 1350 */ 1063, 1066, 1053, 1053, 135, 135, 136, 136, 136, 136,
174657
- /* 1360 */ 21, 21, 267, 576, 300, 1126, 91, 233, 1228, 1228,
175041
+ /* 1360 */ 70, 70, 71, 71, 576, 1126, 91, 576, 1228, 1228,
174658175042
/* 1370 */ 1063, 1066, 1053, 1053, 135, 135, 136, 136, 136, 136,
174659
- /* 1380 */ 1127, 373, 1595, 161, 1573, 16, 53, 53, 7, 108,
174660
- /* 1390 */ 533, 38, 969, 125, 1207, 1128, 1180, 576, 1224, 123,
174661
- /* 1400 */ 568, 893, 4, 324, 134, 134, 134, 134, 133, 133,
174662
- /* 1410 */ 132, 132, 132, 131, 128, 451, 571, 564, 534, 576,
174663
- /* 1420 */ 68, 68, 576, 39, 134, 134, 134, 134, 133, 133,
174664
- /* 1430 */ 132, 132, 132, 131, 128, 451, 576, 160, 1571, 1223,
174665
- /* 1440 */ 452, 576, 54, 54, 576, 69, 69, 576, 1366, 576,
174666
- /* 1450 */ 420, 184, 565, 463, 297, 576, 1224, 463, 297, 70,
174667
- /* 1460 */ 70, 576, 44, 474, 71, 71, 576, 72, 72, 576,
174668
- /* 1470 */ 73, 73, 55, 55, 411, 874, 242, 576, 56, 56,
174669
- /* 1480 */ 576, 1040, 576, 478, 57, 57, 576, 121, 121, 59,
174670
- /* 1490 */ 59, 23, 60, 60, 411, 122, 319, 452, 577, 452,
174671
- /* 1500 */ 74, 74, 1028, 75, 75, 76, 76, 411, 290, 20,
174672
- /* 1510 */ 20, 108, 287, 231, 553, 123, 568, 325, 4, 320,
174673
- /* 1520 */ 567, 97, 218, 944, 1144, 328, 400, 576, 943, 576,
174674
- /* 1530 */ 1380, 424, 571, 874, 1028, 1028, 1030, 1031, 35, 293,
174675
- /* 1540 */ 534, 576, 1104, 576, 1104, 9, 576, 342, 576, 111,
174676
- /* 1550 */ 77, 77, 143, 143, 576, 205, 452, 222, 1379, 889,
174677
- /* 1560 */ 576, 901, 900, 1188, 144, 144, 78, 78, 565, 62,
174678
- /* 1570 */ 62, 79, 79, 323, 1021, 576, 266, 63, 63, 908,
174679
- /* 1580 */ 909, 1589, 542, 80, 80, 576, 371, 541, 123, 568,
174680
- /* 1590 */ 480, 4, 266, 482, 244, 266, 370, 1040, 64, 64,
174681
- /* 1600 */ 576, 466, 576, 121, 121, 571, 1557, 576, 170, 170,
174682
- /* 1610 */ 576, 122, 576, 452, 577, 452, 576, 889, 1028, 576,
174683
- /* 1620 */ 165, 576, 111, 171, 171, 87, 87, 337, 1616, 452,
174684
- /* 1630 */ 65, 65, 1530, 83, 83, 146, 146, 986, 987, 84,
174685
- /* 1640 */ 84, 565, 168, 168, 148, 148, 1092, 347, 1032, 111,
174686
- /* 1650 */ 1028, 1028, 1030, 1031, 35, 542, 1103, 576, 1103, 576,
174687
- /* 1660 */ 543, 123, 568, 504, 4, 263, 576, 361, 1529, 111,
174688
- /* 1670 */ 1040, 1088, 576, 263, 576, 490, 121, 121, 571, 1188,
174689
- /* 1680 */ 142, 142, 169, 169, 122, 576, 452, 577, 452, 162,
174690
- /* 1690 */ 162, 1028, 576, 563, 576, 152, 152, 151, 151, 348,
174691
- /* 1700 */ 1376, 974, 452, 266, 1092, 942, 1032, 125, 149, 149,
174692
- /* 1710 */ 939, 576, 125, 576, 565, 150, 150, 86, 86, 872,
174693
- /* 1720 */ 352, 159, 576, 1028, 1028, 1030, 1031, 35, 542, 941,
174694
- /* 1730 */ 576, 125, 355, 541, 88, 88, 85, 85, 357, 359,
174695
- /* 1740 */ 1324, 1308, 366, 1040, 376, 52, 52, 499, 1389, 121,
174696
- /* 1750 */ 121, 1434, 1188, 58, 58, 1362, 1374, 122, 1439, 452,
174697
- /* 1760 */ 577, 452, 1289, 167, 1028, 1280, 280, 1268, 1267, 1269,
174698
- /* 1770 */ 1609, 1359, 312, 313, 12, 314, 397, 1421, 224, 1416,
174699
- /* 1780 */ 295, 237, 1409, 339, 340, 1426, 301, 345, 484, 228,
174700
- /* 1790 */ 1371, 1307, 1372, 1370, 1425, 404, 1028, 1028, 1030, 1031,
174701
- /* 1800 */ 35, 1601, 1192, 454, 509, 369, 292, 1502, 210, 1501,
174702
- /* 1810 */ 1369, 396, 396, 395, 277, 393, 211, 566, 859, 1612,
174703
- /* 1820 */ 1244, 123, 568, 391, 4, 1188, 223, 270, 1549, 1547,
174704
- /* 1830 */ 1241, 239, 186, 327, 422, 96, 195, 220, 571, 235,
174705
- /* 1840 */ 180, 326, 188, 468, 190, 1507, 191, 192, 92, 193,
174706
- /* 1850 */ 469, 95, 1422, 13, 502, 247, 1430, 109, 199, 402,
174707
- /* 1860 */ 476, 405, 452, 1496, 1428, 1427, 14, 491, 251, 102,
174708
- /* 1870 */ 497, 1518, 241, 281, 565, 253, 203, 354, 500, 254,
174709
- /* 1880 */ 175, 1270, 407, 43, 350, 518, 1327, 436, 255, 1326,
174710
- /* 1890 */ 1325, 1318, 104, 893, 1626, 229, 408, 440, 1625, 441,
174711
- /* 1900 */ 240, 310, 1296, 1040, 311, 1317, 527, 1594, 1297, 121,
174712
- /* 1910 */ 121, 368, 1295, 1624, 268, 269, 1580, 122, 1579, 452,
174713
- /* 1920 */ 577, 452, 374, 444, 1028, 1394, 1393, 140, 553, 90,
174714
- /* 1930 */ 568, 11, 4, 1483, 383, 414, 385, 110, 116, 216,
174715
- /* 1940 */ 320, 567, 1350, 555, 42, 318, 571, 537, 1349, 389,
174716
- /* 1950 */ 390, 579, 1198, 276, 279, 278, 1028, 1028, 1030, 1031,
174717
- /* 1960 */ 35, 580, 415, 1265, 458, 1260, 416, 185, 1534, 172,
174718
- /* 1970 */ 452, 1535, 173, 156, 308, 846, 1533, 1532, 453, 217,
174719
- /* 1980 */ 225, 89, 565, 174, 322, 1188, 226, 236, 1102, 154,
174720
- /* 1990 */ 1100, 330, 176, 187, 1223, 189, 925, 338, 243, 1116,
174721
- /* 2000 */ 246, 194, 177, 178, 425, 427, 98, 99, 196, 100,
174722
- /* 2010 */ 101, 1040, 179, 1119, 248, 1115, 249, 121, 121, 24,
174723
- /* 2020 */ 163, 250, 349, 1108, 266, 122, 1238, 452, 577, 452,
174724
- /* 2030 */ 1192, 454, 1028, 200, 292, 496, 252, 201, 861, 396,
175043
+ /* 1380 */ 1127, 166, 850, 851, 852, 1282, 419, 72, 72, 108,
175044
+ /* 1390 */ 73, 73, 1310, 358, 1180, 1128, 576, 305, 576, 123,
175045
+ /* 1400 */ 568, 494, 4, 488, 134, 134, 134, 134, 133, 133,
175046
+ /* 1410 */ 132, 132, 132, 131, 128, 451, 571, 564, 534, 55,
175047
+ /* 1420 */ 55, 56, 56, 576, 134, 134, 134, 134, 133, 133,
175048
+ /* 1430 */ 132, 132, 132, 131, 128, 451, 576, 1104, 233, 1104,
175049
+ /* 1440 */ 452, 1602, 582, 2, 1259, 576, 57, 57, 576, 321,
175050
+ /* 1450 */ 576, 155, 565, 1435, 485, 353, 576, 356, 1341, 59,
175051
+ /* 1460 */ 59, 576, 44, 969, 569, 419, 576, 238, 60, 60,
175052
+ /* 1470 */ 261, 74, 74, 75, 75, 287, 231, 576, 1366, 76,
175053
+ /* 1480 */ 76, 1040, 420, 184, 20, 20, 576, 121, 121, 77,
175054
+ /* 1490 */ 77, 97, 218, 288, 288, 122, 125, 452, 577, 452,
175055
+ /* 1500 */ 143, 143, 1028, 576, 520, 576, 573, 576, 562, 144,
175056
+ /* 1510 */ 144, 474, 227, 1244, 478, 123, 568, 576, 4, 320,
175057
+ /* 1520 */ 567, 245, 411, 576, 443, 411, 78, 78, 62, 62,
175058
+ /* 1530 */ 79, 79, 571, 319, 1028, 1028, 1030, 1031, 35, 418,
175059
+ /* 1540 */ 63, 63, 576, 290, 411, 9, 80, 80, 1144, 576,
175060
+ /* 1550 */ 400, 576, 486, 455, 576, 1223, 452, 576, 325, 342,
175061
+ /* 1560 */ 576, 111, 576, 1188, 242, 64, 64, 473, 565, 576,
175062
+ /* 1570 */ 23, 576, 170, 170, 171, 171, 576, 87, 87, 328,
175063
+ /* 1580 */ 65, 65, 542, 83, 83, 146, 146, 541, 123, 568,
175064
+ /* 1590 */ 341, 4, 84, 84, 168, 168, 576, 1040, 576, 148,
175065
+ /* 1600 */ 148, 576, 1380, 121, 121, 571, 1021, 576, 266, 576,
175066
+ /* 1610 */ 424, 122, 576, 452, 577, 452, 576, 553, 1028, 142,
175067
+ /* 1620 */ 142, 169, 169, 576, 162, 162, 528, 889, 371, 452,
175068
+ /* 1630 */ 152, 152, 151, 151, 1379, 149, 149, 109, 370, 150,
175069
+ /* 1640 */ 150, 565, 576, 480, 576, 266, 86, 86, 576, 1092,
175070
+ /* 1650 */ 1028, 1028, 1030, 1031, 35, 542, 482, 576, 266, 466,
175071
+ /* 1660 */ 543, 123, 568, 1616, 4, 88, 88, 85, 85, 475,
175072
+ /* 1670 */ 1040, 52, 52, 222, 901, 900, 121, 121, 571, 1188,
175073
+ /* 1680 */ 58, 58, 244, 1032, 122, 889, 452, 577, 452, 908,
175074
+ /* 1690 */ 909, 1028, 300, 347, 504, 111, 263, 361, 165, 111,
175075
+ /* 1700 */ 111, 1088, 452, 263, 974, 1153, 266, 1092, 986, 987,
175076
+ /* 1710 */ 942, 939, 125, 125, 565, 1103, 872, 1103, 159, 941,
175077
+ /* 1720 */ 1309, 125, 1557, 1028, 1028, 1030, 1031, 35, 542, 337,
175078
+ /* 1730 */ 1530, 205, 1529, 541, 499, 1589, 490, 348, 1376, 352,
175079
+ /* 1740 */ 355, 1032, 357, 1040, 359, 1324, 1308, 366, 563, 121,
175080
+ /* 1750 */ 121, 376, 1188, 1389, 1434, 1362, 280, 122, 1374, 452,
175081
+ /* 1760 */ 577, 452, 167, 1439, 1028, 1289, 1280, 1268, 1267, 1269,
175082
+ /* 1770 */ 1609, 1359, 312, 313, 314, 397, 12, 237, 224, 1421,
175083
+ /* 1780 */ 295, 1416, 1409, 1426, 339, 484, 340, 509, 1371, 1612,
175084
+ /* 1790 */ 1372, 1425, 1244, 404, 301, 228, 1028, 1028, 1030, 1031,
175085
+ /* 1800 */ 35, 1601, 1192, 454, 345, 1307, 292, 369, 1502, 1501,
175086
+ /* 1810 */ 270, 396, 396, 395, 277, 393, 1370, 1369, 859, 1549,
175087
+ /* 1820 */ 186, 123, 568, 235, 4, 1188, 391, 210, 211, 223,
175088
+ /* 1830 */ 1547, 239, 1241, 327, 422, 96, 220, 195, 571, 180,
175089
+ /* 1840 */ 188, 326, 468, 469, 190, 191, 502, 192, 193, 566,
175090
+ /* 1850 */ 247, 109, 1430, 491, 199, 251, 102, 281, 402, 476,
175091
+ /* 1860 */ 405, 1496, 452, 497, 253, 1422, 13, 1428, 14, 1427,
175092
+ /* 1870 */ 203, 1507, 241, 500, 565, 354, 407, 92, 95, 1270,
175093
+ /* 1880 */ 175, 254, 518, 43, 1327, 255, 1326, 1325, 436, 1518,
175094
+ /* 1890 */ 350, 1318, 104, 229, 893, 1626, 440, 441, 1625, 408,
175095
+ /* 1900 */ 240, 1296, 268, 1040, 310, 269, 1297, 527, 444, 121,
175096
+ /* 1910 */ 121, 368, 1295, 1594, 1624, 311, 1394, 122, 1317, 452,
175097
+ /* 1920 */ 577, 452, 374, 1580, 1028, 1393, 140, 553, 11, 90,
175098
+ /* 1930 */ 568, 385, 4, 116, 318, 414, 1579, 110, 1483, 537,
175099
+ /* 1940 */ 320, 567, 1350, 555, 42, 579, 571, 1349, 1198, 383,
175100
+ /* 1950 */ 276, 390, 216, 389, 278, 279, 1028, 1028, 1030, 1031,
175101
+ /* 1960 */ 35, 172, 580, 1265, 458, 1260, 415, 416, 185, 156,
175102
+ /* 1970 */ 452, 1534, 1535, 173, 1533, 1532, 89, 308, 225, 226,
175103
+ /* 1980 */ 846, 174, 565, 453, 217, 1188, 322, 236, 1102, 154,
175104
+ /* 1990 */ 1100, 330, 187, 176, 1223, 243, 189, 925, 338, 246,
175105
+ /* 2000 */ 1116, 194, 177, 425, 178, 427, 98, 196, 99, 100,
175106
+ /* 2010 */ 101, 1040, 179, 1119, 1115, 248, 249, 121, 121, 163,
175107
+ /* 2020 */ 24, 250, 349, 1238, 496, 122, 1108, 452, 577, 452,
175108
+ /* 2030 */ 1192, 454, 1028, 266, 292, 200, 252, 201, 861, 396,
174725175109
/* 2040 */ 396, 395, 277, 393, 15, 501, 859, 370, 292, 256,
174726175110
/* 2050 */ 202, 554, 505, 396, 396, 395, 277, 393, 103, 239,
174727175111
/* 2060 */ 859, 327, 25, 26, 1028, 1028, 1030, 1031, 35, 326,
174728175112
/* 2070 */ 362, 510, 891, 239, 365, 327, 513, 904, 105, 309,
174729175113
/* 2080 */ 164, 181, 27, 326, 106, 521, 107, 1185, 1069, 1155,
174730
- /* 2090 */ 17, 1154, 284, 1188, 286, 978, 265, 204, 125, 1171,
174731
- /* 2100 */ 241, 230, 972, 1175, 28, 1160, 29, 1179, 175, 1173,
174732
- /* 2110 */ 30, 43, 31, 1178, 241, 32, 41, 549, 8, 33,
174733
- /* 2120 */ 208, 111, 175, 1083, 1070, 43, 113, 1068, 240, 114,
174734
- /* 2130 */ 1072, 34, 1073, 561, 1124, 118, 271, 36, 18, 1194,
174735
- /* 2140 */ 1033, 873, 240, 935, 124, 37, 272, 273, 1617, 572,
174736
- /* 2150 */ 183, 153, 394, 1193, 1256, 1256, 1256, 1256, 1256, 1256,
175114
+ /* 2090 */ 17, 1154, 230, 1188, 284, 286, 265, 204, 125, 1171,
175115
+ /* 2100 */ 241, 28, 978, 972, 29, 41, 1175, 1179, 175, 1173,
175116
+ /* 2110 */ 30, 43, 31, 8, 241, 1178, 32, 1160, 208, 549,
175117
+ /* 2120 */ 33, 111, 175, 1083, 1070, 43, 1068, 1072, 240, 113,
175118
+ /* 2130 */ 114, 34, 561, 118, 1124, 271, 1073, 36, 18, 572,
175119
+ /* 2140 */ 1033, 873, 240, 124, 37, 935, 272, 273, 1617, 183,
175120
+ /* 2150 */ 153, 394, 1194, 1193, 1256, 1256, 1256, 1256, 1256, 1256,
174737175121
/* 2160 */ 1256, 1256, 1256, 414, 1256, 1256, 1256, 1256, 320, 567,
174738175122
/* 2170 */ 1256, 1256, 1256, 1256, 1256, 1256, 1256, 414, 1256, 1256,
174739175123
/* 2180 */ 1256, 1256, 320, 567, 1256, 1256, 1256, 1256, 1256, 1256,
174740175124
/* 2190 */ 1256, 1256, 458, 1256, 1256, 1256, 1256, 1256, 1256, 1256,
174741175125
/* 2200 */ 1256, 1256, 1256, 1256, 1256, 1256, 458,
174742175126
};
174743175127
static const YYCODETYPE yy_lookahead[] = {
174744
- /* 0 */ 276, 277, 278, 240, 241, 224, 194, 226, 194, 240,
174745
- /* 10 */ 241, 194, 216, 220, 194, 234, 253, 194, 255, 19,
174746
- /* 20 */ 224, 297, 253, 194, 255, 205, 212, 213, 205, 217,
174747
- /* 30 */ 218, 31, 205, 194, 217, 218, 194, 217, 218, 39,
174748
- /* 40 */ 217, 218, 312, 43, 44, 45, 316, 47, 48, 49,
175128
+ /* 0 */ 277, 278, 279, 241, 242, 225, 195, 227, 195, 241,
175129
+ /* 10 */ 242, 195, 217, 221, 195, 235, 254, 195, 256, 19,
175130
+ /* 20 */ 225, 298, 254, 195, 256, 206, 213, 214, 206, 218,
175131
+ /* 30 */ 219, 31, 206, 195, 218, 219, 195, 218, 219, 39,
175132
+ /* 40 */ 218, 219, 313, 43, 44, 45, 317, 47, 48, 49,
174749175133
/* 50 */ 50, 51, 52, 53, 54, 55, 56, 57, 58, 19,
174750
- /* 60 */ 240, 241, 194, 240, 241, 194, 254, 240, 241, 276,
174751
- /* 70 */ 277, 278, 233, 253, 254, 255, 253, 254, 255, 217,
174752
- /* 80 */ 253, 239, 255, 43, 44, 45, 263, 47, 48, 49,
174753
- /* 90 */ 50, 51, 52, 53, 54, 55, 56, 57, 58, 270,
174754
- /* 100 */ 286, 22, 23, 103, 104, 105, 106, 107, 108, 109,
174755
- /* 110 */ 110, 111, 112, 113, 114, 82, 47, 48, 49, 50,
174756
- /* 120 */ 186, 187, 188, 189, 190, 191, 189, 87, 191, 89,
174757
- /* 130 */ 196, 19, 198, 196, 317, 198, 319, 25, 194, 205,
174758
- /* 140 */ 298, 270, 205, 103, 104, 105, 106, 107, 108, 109,
174759
- /* 150 */ 110, 111, 112, 113, 114, 43, 44, 45, 11, 47,
175134
+ /* 60 */ 241, 242, 195, 241, 242, 195, 255, 241, 242, 277,
175135
+ /* 70 */ 278, 279, 234, 254, 255, 256, 254, 255, 256, 218,
175136
+ /* 80 */ 254, 240, 256, 43, 44, 45, 264, 47, 48, 49,
175137
+ /* 90 */ 50, 51, 52, 53, 54, 55, 56, 57, 58, 271,
175138
+ /* 100 */ 287, 22, 23, 103, 104, 105, 106, 107, 108, 109,
175139
+ /* 110 */ 110, 111, 112, 113, 114, 114, 47, 48, 49, 50,
175140
+ /* 120 */ 187, 188, 189, 190, 191, 192, 190, 87, 192, 89,
175141
+ /* 130 */ 197, 19, 199, 197, 318, 199, 320, 25, 195, 206,
175142
+ /* 140 */ 299, 271, 206, 103, 104, 105, 106, 107, 108, 109,
175143
+ /* 150 */ 110, 111, 112, 113, 114, 43, 44, 45, 195, 47,
174760175144
/* 160 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
174761
- /* 170 */ 58, 60, 139, 140, 240, 241, 214, 240, 241, 311,
174762
- /* 180 */ 312, 102, 70, 239, 316, 194, 19, 253, 77, 255,
174763
- /* 190 */ 253, 122, 255, 55, 56, 57, 58, 59, 207, 88,
174764
- /* 200 */ 194, 90, 268, 194, 93, 268, 107, 108, 109, 110,
174765
- /* 210 */ 111, 112, 113, 114, 47, 103, 104, 105, 106, 107,
174766
- /* 220 */ 108, 109, 110, 111, 112, 113, 114, 114, 117, 118,
174767
- /* 230 */ 119, 276, 277, 278, 300, 19, 194, 300, 276, 277,
174768
- /* 240 */ 278, 103, 104, 105, 106, 107, 108, 109, 110, 111,
174769
- /* 250 */ 112, 113, 114, 55, 56, 57, 58, 146, 194, 43,
174770
- /* 260 */ 44, 45, 47, 47, 48, 49, 50, 51, 52, 53,
174771
- /* 270 */ 54, 55, 56, 57, 58, 82, 129, 130, 60, 129,
174772
- /* 280 */ 130, 217, 218, 116, 68, 25, 103, 104, 105, 106,
174773
- /* 290 */ 107, 108, 109, 110, 111, 112, 113, 114, 23, 132,
174774
- /* 300 */ 294, 103, 104, 105, 106, 107, 108, 109, 110, 111,
174775
- /* 310 */ 112, 113, 114, 217, 121, 306, 194, 308, 26, 103,
175145
+ /* 170 */ 58, 60, 21, 195, 241, 242, 215, 241, 242, 312,
175146
+ /* 180 */ 313, 102, 70, 205, 317, 207, 242, 254, 77, 256,
175147
+ /* 190 */ 254, 122, 256, 55, 56, 57, 58, 59, 254, 88,
175148
+ /* 200 */ 256, 90, 269, 240, 93, 269, 107, 108, 109, 110,
175149
+ /* 210 */ 111, 112, 113, 114, 271, 103, 104, 105, 106, 107,
175150
+ /* 220 */ 108, 109, 110, 111, 112, 113, 114, 313, 117, 118,
175151
+ /* 230 */ 119, 317, 81, 195, 301, 19, 195, 301, 277, 278,
175152
+ /* 240 */ 279, 103, 104, 105, 106, 107, 108, 109, 110, 111,
175153
+ /* 250 */ 112, 113, 114, 55, 56, 57, 58, 146, 195, 43,
175154
+ /* 260 */ 44, 45, 74, 47, 48, 49, 50, 51, 52, 53,
175155
+ /* 270 */ 54, 55, 56, 57, 58, 124, 195, 60, 109, 110,
175156
+ /* 280 */ 111, 112, 113, 114, 68, 195, 103, 104, 105, 106,
175157
+ /* 290 */ 107, 108, 109, 110, 111, 112, 113, 114, 208, 218,
175158
+ /* 300 */ 219, 103, 104, 105, 106, 107, 108, 109, 110, 111,
175159
+ /* 310 */ 112, 113, 114, 162, 233, 24, 128, 129, 130, 103,
174776175160
/* 320 */ 104, 105, 106, 107, 108, 109, 110, 111, 112, 113,
174777
- /* 330 */ 114, 116, 139, 140, 217, 117, 118, 119, 120, 19,
174778
- /* 340 */ 194, 123, 124, 125, 24, 109, 110, 111, 112, 113,
174779
- /* 350 */ 114, 133, 60, 311, 312, 250, 194, 252, 316, 19,
174780
- /* 360 */ 194, 166, 167, 43, 44, 45, 205, 47, 48, 49,
174781
- /* 370 */ 50, 51, 52, 53, 54, 55, 56, 57, 58, 217,
174782
- /* 380 */ 218, 317, 318, 43, 44, 45, 264, 47, 48, 49,
174783
- /* 390 */ 50, 51, 52, 53, 54, 55, 56, 57, 58, 139,
174784
- /* 400 */ 140, 240, 241, 139, 140, 188, 189, 190, 191, 117,
174785
- /* 410 */ 118, 119, 231, 196, 253, 198, 255, 194, 194, 258,
174786
- /* 420 */ 259, 146, 205, 103, 104, 105, 106, 107, 108, 109,
174787
- /* 430 */ 110, 111, 112, 113, 114, 109, 212, 213, 236, 237,
174788
- /* 440 */ 217, 218, 194, 103, 104, 105, 106, 107, 108, 109,
174789
- /* 450 */ 110, 111, 112, 113, 114, 194, 120, 240, 241, 123,
174790
- /* 460 */ 124, 125, 136, 194, 19, 74, 60, 141, 23, 133,
174791
- /* 470 */ 253, 194, 255, 82, 194, 309, 310, 254, 29, 317,
174792
- /* 480 */ 318, 194, 33, 22, 199, 268, 263, 239, 43, 44,
175161
+ /* 330 */ 114, 195, 195, 215, 117, 118, 119, 120, 195, 19,
175162
+ /* 340 */ 123, 124, 125, 207, 24, 74, 246, 60, 310, 311,
175163
+ /* 350 */ 133, 60, 311, 82, 22, 218, 219, 257, 195, 19,
175164
+ /* 360 */ 73, 218, 219, 43, 44, 45, 206, 47, 48, 49,
175165
+ /* 370 */ 50, 51, 52, 53, 54, 55, 56, 57, 58, 22,
175166
+ /* 380 */ 23, 218, 219, 43, 44, 45, 54, 47, 48, 49,
175167
+ /* 390 */ 50, 51, 52, 53, 54, 55, 56, 57, 58, 128,
175168
+ /* 400 */ 82, 241, 242, 195, 117, 118, 119, 289, 60, 118,
175169
+ /* 410 */ 139, 140, 294, 195, 254, 195, 256, 195, 255, 259,
175170
+ /* 420 */ 260, 73, 22, 103, 104, 105, 106, 107, 108, 109,
175171
+ /* 430 */ 110, 111, 112, 113, 114, 206, 218, 219, 218, 219,
175172
+ /* 440 */ 218, 219, 234, 103, 104, 105, 106, 107, 108, 109,
175173
+ /* 450 */ 110, 111, 112, 113, 114, 318, 319, 139, 140, 102,
175174
+ /* 460 */ 60, 318, 319, 221, 19, 117, 118, 119, 23, 195,
175175
+ /* 470 */ 241, 242, 313, 255, 206, 255, 317, 255, 206, 129,
175176
+ /* 480 */ 130, 206, 264, 254, 264, 256, 264, 195, 43, 44,
174793175177
/* 490 */ 45, 151, 47, 48, 49, 50, 51, 52, 53, 54,
174794
- /* 500 */ 55, 56, 57, 58, 217, 218, 194, 60, 19, 146,
174795
- /* 510 */ 286, 242, 23, 107, 108, 66, 204, 300, 206, 128,
174796
- /* 520 */ 73, 60, 116, 117, 118, 119, 265, 121, 165, 60,
174797
- /* 530 */ 139, 140, 43, 44, 45, 129, 47, 48, 49, 50,
175178
+ /* 500 */ 55, 56, 57, 58, 246, 213, 214, 19, 19, 241,
175179
+ /* 510 */ 242, 195, 23, 241, 242, 257, 241, 242, 118, 277,
175180
+ /* 520 */ 278, 279, 254, 29, 256, 60, 254, 33, 256, 254,
175181
+ /* 530 */ 206, 256, 43, 44, 45, 218, 47, 48, 49, 50,
174798175182
/* 540 */ 51, 52, 53, 54, 55, 56, 57, 58, 103, 104,
174799175183
/* 550 */ 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
174800
- /* 560 */ 154, 194, 156, 194, 117, 118, 119, 280, 283, 205,
174801
- /* 570 */ 101, 220, 287, 19, 20, 306, 22, 308, 117, 118,
174802
- /* 580 */ 119, 211, 212, 213, 217, 218, 117, 118, 236, 237,
174803
- /* 590 */ 36, 122, 103, 104, 105, 106, 107, 108, 109, 110,
174804
- /* 600 */ 111, 112, 113, 114, 240, 241, 194, 60, 194, 194,
174805
- /* 610 */ 194, 194, 19, 194, 60, 194, 23, 253, 206, 255,
174806
- /* 620 */ 73, 254, 19, 154, 155, 156, 72, 276, 277, 278,
174807
- /* 630 */ 263, 217, 218, 217, 218, 271, 43, 44, 45, 271,
175184
+ /* 560 */ 66, 19, 218, 60, 120, 241, 242, 123, 124, 125,
175185
+ /* 570 */ 60, 232, 77, 19, 20, 26, 22, 133, 254, 287,
175186
+ /* 580 */ 256, 265, 117, 118, 119, 90, 312, 313, 93, 47,
175187
+ /* 590 */ 36, 317, 103, 104, 105, 106, 107, 108, 109, 110,
175188
+ /* 600 */ 111, 112, 113, 114, 116, 117, 277, 278, 279, 60,
175189
+ /* 610 */ 107, 108, 19, 276, 60, 31, 23, 152, 195, 116,
175190
+ /* 620 */ 117, 118, 119, 39, 121, 276, 72, 117, 118, 119,
175191
+ /* 630 */ 166, 167, 129, 145, 237, 238, 43, 44, 45, 276,
174808175192
/* 640 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
174809
- /* 650 */ 57, 58, 183, 194, 285, 101, 19, 214, 60, 242,
174810
- /* 660 */ 23, 107, 108, 109, 117, 118, 119, 16, 254, 115,
174811
- /* 670 */ 254, 117, 118, 119, 194, 60, 122, 263, 205, 264,
174812
- /* 680 */ 43, 44, 45, 264, 47, 48, 49, 50, 51, 52,
175193
+ /* 650 */ 57, 58, 315, 316, 144, 101, 19, 154, 116, 156,
175194
+ /* 660 */ 23, 107, 108, 109, 315, 316, 117, 118, 119, 115,
175195
+ /* 670 */ 60, 117, 118, 119, 132, 200, 122, 60, 315, 316,
175196
+ /* 680 */ 43, 44, 45, 272, 47, 48, 49, 50, 51, 52,
174813175197
/* 690 */ 53, 54, 55, 56, 57, 58, 103, 104, 105, 106,
174814175198
/* 700 */ 107, 108, 109, 110, 111, 112, 113, 114, 154, 155,
174815
- /* 710 */ 156, 157, 158, 240, 241, 117, 118, 119, 101, 205,
174816
- /* 720 */ 117, 19, 20, 306, 22, 308, 253, 74, 255, 78,
174817
- /* 730 */ 205, 80, 117, 118, 119, 118, 293, 183, 36, 122,
175199
+ /* 710 */ 156, 157, 158, 212, 213, 214, 22, 195, 101, 22,
175200
+ /* 720 */ 60, 19, 20, 60, 22, 139, 140, 117, 118, 119,
175201
+ /* 730 */ 22, 251, 195, 253, 117, 118, 195, 183, 36, 122,
174818175202
/* 740 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
174819
- /* 750 */ 113, 114, 194, 294, 240, 241, 211, 212, 213, 144,
174820
- /* 760 */ 19, 23, 60, 25, 23, 240, 241, 253, 245, 255,
174821
- /* 770 */ 15, 154, 155, 156, 72, 217, 218, 194, 253, 256,
174822
- /* 780 */ 255, 128, 129, 130, 43, 44, 45, 22, 47, 48,
175203
+ /* 750 */ 113, 114, 195, 195, 60, 218, 219, 60, 195, 284,
175204
+ /* 760 */ 19, 25, 60, 288, 23, 237, 238, 22, 60, 109,
175205
+ /* 770 */ 233, 154, 155, 156, 72, 218, 219, 117, 118, 119,
175206
+ /* 780 */ 117, 118, 119, 116, 43, 44, 45, 265, 47, 48,
174823175207
/* 790 */ 49, 50, 51, 52, 53, 54, 55, 56, 57, 58,
174824
- /* 800 */ 183, 19, 77, 101, 19, 128, 129, 130, 23, 107,
174825
- /* 810 */ 108, 60, 254, 88, 21, 90, 61, 115, 93, 117,
174826
- /* 820 */ 118, 119, 239, 22, 122, 60, 194, 205, 43, 44,
174827
- /* 830 */ 45, 205, 47, 48, 49, 50, 51, 52, 53, 54,
175208
+ /* 800 */ 183, 243, 25, 101, 19, 60, 265, 144, 23, 107,
175209
+ /* 810 */ 108, 117, 118, 119, 117, 118, 119, 115, 151, 117,
175210
+ /* 820 */ 118, 119, 82, 195, 122, 117, 118, 119, 43, 44,
175211
+ /* 830 */ 45, 195, 47, 48, 49, 50, 51, 52, 53, 54,
174828175212
/* 840 */ 55, 56, 57, 58, 103, 104, 105, 106, 107, 108,
174829175213
/* 850 */ 109, 110, 111, 112, 113, 114, 154, 155, 156, 157,
174830
- /* 860 */ 158, 60, 240, 241, 60, 116, 240, 241, 117, 118,
174831
- /* 870 */ 119, 146, 194, 19, 81, 253, 275, 255, 24, 253,
174832
- /* 880 */ 98, 255, 117, 118, 119, 183, 22, 194, 103, 104,
175214
+ /* 860 */ 158, 121, 117, 118, 119, 307, 101, 309, 195, 22,
175215
+ /* 870 */ 23, 195, 25, 19, 35, 139, 140, 195, 24, 139,
175216
+ /* 880 */ 140, 208, 195, 118, 109, 183, 22, 122, 103, 104,
174833175217
/* 890 */ 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
174834
- /* 900 */ 151, 194, 270, 152, 22, 23, 194, 25, 19, 202,
174835
- /* 910 */ 217, 218, 23, 109, 207, 314, 315, 124, 117, 118,
174836
- /* 920 */ 119, 117, 118, 119, 60, 232, 22, 23, 19, 25,
174837
- /* 930 */ 303, 304, 43, 44, 45, 22, 47, 48, 49, 50,
174838
- /* 940 */ 51, 52, 53, 54, 55, 56, 57, 58, 270, 227,
174839
- /* 950 */ 96, 60, 43, 44, 45, 162, 47, 48, 49, 50,
174840
- /* 960 */ 51, 52, 53, 54, 55, 56, 57, 58, 114, 112,
174841
- /* 970 */ 113, 114, 194, 60, 120, 121, 122, 123, 124, 125,
174842
- /* 980 */ 126, 117, 118, 119, 102, 25, 132, 107, 108, 194,
174843
- /* 990 */ 194, 227, 103, 104, 105, 106, 107, 108, 109, 110,
174844
- /* 1000 */ 111, 112, 113, 114, 194, 194, 102, 194, 117, 118,
174845
- /* 1010 */ 119, 233, 103, 104, 105, 106, 107, 108, 109, 110,
174846
- /* 1020 */ 111, 112, 113, 114, 194, 194, 19, 194, 217, 218,
174847
- /* 1030 */ 117, 118, 119, 241, 154, 144, 156, 135, 242, 137,
174848
- /* 1040 */ 138, 130, 19, 232, 194, 253, 23, 255, 217, 218,
174849
- /* 1050 */ 217, 218, 242, 16, 7, 8, 9, 25, 261, 262,
174850
- /* 1060 */ 265, 194, 19, 232, 153, 232, 43, 44, 45, 160,
175218
+ /* 900 */ 304, 305, 77, 230, 127, 232, 67, 195, 19, 195,
175219
+ /* 910 */ 195, 136, 23, 88, 75, 90, 141, 203, 93, 154,
175220
+ /* 920 */ 155, 156, 208, 295, 60, 243, 22, 23, 19, 25,
175221
+ /* 930 */ 218, 219, 43, 44, 45, 100, 47, 48, 49, 50,
175222
+ /* 940 */ 51, 52, 53, 54, 55, 56, 57, 58, 183, 102,
175223
+ /* 950 */ 96, 195, 43, 44, 45, 240, 47, 48, 49, 50,
175224
+ /* 960 */ 51, 52, 53, 54, 55, 56, 57, 58, 114, 134,
175225
+ /* 970 */ 131, 146, 25, 286, 120, 121, 122, 123, 124, 125,
175226
+ /* 980 */ 126, 117, 118, 119, 313, 195, 132, 195, 317, 307,
175227
+ /* 990 */ 195, 309, 103, 104, 105, 106, 107, 108, 109, 110,
175228
+ /* 1000 */ 111, 112, 113, 114, 195, 195, 102, 195, 195, 195,
175229
+ /* 1010 */ 218, 219, 103, 104, 105, 106, 107, 108, 109, 110,
175230
+ /* 1020 */ 111, 112, 113, 114, 77, 233, 195, 60, 218, 219,
175231
+ /* 1030 */ 218, 219, 218, 219, 23, 195, 25, 90, 243, 159,
175232
+ /* 1040 */ 93, 161, 19, 233, 195, 233, 23, 233, 16, 218,
175233
+ /* 1050 */ 219, 195, 243, 212, 213, 214, 262, 263, 218, 219,
175234
+ /* 1060 */ 195, 271, 19, 307, 233, 309, 43, 44, 45, 160,
174851175235
/* 1070 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
174852
- /* 1080 */ 57, 58, 194, 227, 217, 218, 43, 44, 45, 194,
175236
+ /* 1080 */ 57, 58, 195, 218, 219, 118, 43, 44, 45, 240,
174853175237
/* 1090 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
174854
- /* 1100 */ 57, 58, 306, 143, 308, 217, 218, 294, 12, 77,
174855
- /* 1110 */ 22, 23, 217, 218, 194, 78, 306, 80, 308, 194,
174856
- /* 1120 */ 232, 254, 90, 27, 117, 93, 103, 104, 105, 106,
174857
- /* 1130 */ 107, 108, 109, 110, 111, 112, 113, 114, 42, 194,
174858
- /* 1140 */ 35, 194, 217, 218, 214, 194, 103, 104, 105, 106,
174859
- /* 1150 */ 107, 108, 109, 110, 111, 112, 113, 114, 194, 239,
174860
- /* 1160 */ 64, 194, 217, 218, 217, 218, 209, 210, 217, 218,
174861
- /* 1170 */ 74, 207, 67, 22, 194, 77, 19, 232, 245, 232,
174862
- /* 1180 */ 75, 24, 312, 232, 217, 218, 316, 25, 90, 256,
174863
- /* 1190 */ 102, 93, 159, 229, 161, 231, 19, 217, 218, 162,
175238
+ /* 1100 */ 57, 58, 307, 195, 309, 218, 219, 263, 12, 195,
175239
+ /* 1110 */ 78, 267, 80, 112, 113, 114, 307, 22, 309, 24,
175240
+ /* 1120 */ 255, 281, 266, 27, 107, 108, 103, 104, 105, 106,
175241
+ /* 1130 */ 107, 108, 109, 110, 111, 112, 113, 114, 42, 195,
175242
+ /* 1140 */ 11, 22, 255, 24, 195, 195, 103, 104, 105, 106,
175243
+ /* 1150 */ 107, 108, 109, 110, 111, 112, 113, 114, 19, 195,
175244
+ /* 1160 */ 64, 195, 218, 219, 195, 313, 195, 218, 219, 317,
175245
+ /* 1170 */ 74, 154, 195, 156, 195, 195, 19, 233, 23, 60,
175246
+ /* 1180 */ 25, 24, 218, 219, 218, 219, 195, 218, 219, 218,
175247
+ /* 1190 */ 219, 128, 129, 130, 162, 263, 19, 218, 219, 267,
174864175248
/* 1200 */ 43, 44, 45, 160, 47, 48, 49, 50, 51, 52,
174865
- /* 1210 */ 53, 54, 55, 56, 57, 58, 19, 23, 288, 25,
174866
- /* 1220 */ 43, 44, 45, 293, 47, 48, 49, 50, 51, 52,
174867
- /* 1230 */ 53, 54, 55, 56, 57, 58, 131, 22, 275, 24,
174868
- /* 1240 */ 43, 44, 45, 194, 47, 48, 49, 50, 51, 52,
174869
- /* 1250 */ 53, 54, 55, 56, 57, 58, 194, 194, 107, 108,
175249
+ /* 1210 */ 53, 54, 55, 56, 57, 58, 19, 240, 228, 255,
175250
+ /* 1220 */ 43, 44, 45, 25, 47, 48, 49, 50, 51, 52,
175251
+ /* 1230 */ 53, 54, 55, 56, 57, 58, 135, 118, 137, 138,
175252
+ /* 1240 */ 43, 44, 45, 22, 47, 48, 49, 50, 51, 52,
175253
+ /* 1250 */ 53, 54, 55, 56, 57, 58, 117, 266, 129, 130,
174870175254
/* 1260 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
174871
- /* 1270 */ 113, 114, 194, 25, 194, 60, 194, 314, 315, 194,
175255
+ /* 1270 */ 113, 114, 195, 195, 119, 295, 195, 206, 195, 195,
174872175256
/* 1280 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
174873
- /* 1290 */ 113, 114, 19, 194, 194, 217, 218, 217, 218, 25,
175257
+ /* 1290 */ 113, 114, 195, 195, 195, 218, 219, 195, 195, 144,
174874175258
/* 1300 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
174875
- /* 1310 */ 113, 114, 150, 119, 265, 312, 67, 217, 218, 316,
174876
- /* 1320 */ 19, 239, 194, 194, 128, 129, 130, 265, 265, 209,
174877
- /* 1330 */ 210, 31, 254, 118, 254, 86, 60, 194, 144, 39,
174878
- /* 1340 */ 19, 130, 275, 312, 95, 44, 45, 316, 47, 48,
175259
+ /* 1310 */ 113, 114, 241, 242, 67, 218, 219, 218, 219, 146,
175260
+ /* 1320 */ 19, 218, 219, 240, 215, 254, 136, 256, 107, 108,
175261
+ /* 1330 */ 195, 141, 255, 86, 128, 129, 130, 195, 165, 195,
175262
+ /* 1340 */ 19, 143, 95, 272, 25, 44, 45, 266, 47, 48,
174879175263
/* 1350 */ 49, 50, 51, 52, 53, 54, 55, 56, 57, 58,
174880
- /* 1360 */ 217, 218, 24, 194, 153, 12, 45, 119, 47, 48,
175264
+ /* 1360 */ 218, 219, 218, 219, 195, 12, 45, 195, 47, 48,
174881175265
/* 1370 */ 49, 50, 51, 52, 53, 54, 55, 56, 57, 58,
174882
- /* 1380 */ 27, 314, 315, 22, 312, 24, 217, 218, 316, 116,
174883
- /* 1390 */ 117, 22, 144, 25, 118, 42, 147, 194, 60, 19,
174884
- /* 1400 */ 20, 127, 22, 194, 103, 104, 105, 106, 107, 108,
174885
- /* 1410 */ 109, 110, 111, 112, 113, 114, 36, 64, 145, 194,
174886
- /* 1420 */ 217, 218, 194, 54, 103, 104, 105, 106, 107, 108,
174887
- /* 1430 */ 109, 110, 111, 112, 113, 114, 194, 22, 310, 25,
174888
- /* 1440 */ 60, 194, 217, 218, 194, 217, 218, 194, 260, 194,
174889
- /* 1450 */ 301, 302, 72, 262, 262, 194, 118, 266, 266, 217,
174890
- /* 1460 */ 218, 194, 82, 245, 217, 218, 194, 217, 218, 194,
174891
- /* 1470 */ 217, 218, 217, 218, 256, 60, 24, 194, 217, 218,
174892
- /* 1480 */ 194, 101, 194, 245, 217, 218, 194, 107, 108, 217,
174893
- /* 1490 */ 218, 22, 217, 218, 256, 115, 245, 117, 118, 119,
174894
- /* 1500 */ 217, 218, 122, 217, 218, 217, 218, 256, 22, 217,
174895
- /* 1510 */ 218, 116, 258, 259, 146, 19, 20, 194, 22, 139,
174896
- /* 1520 */ 140, 150, 151, 136, 23, 194, 25, 194, 141, 194,
174897
- /* 1530 */ 194, 62, 36, 118, 154, 155, 156, 157, 158, 100,
174898
- /* 1540 */ 145, 194, 154, 194, 156, 49, 194, 23, 194, 25,
174899
- /* 1550 */ 217, 218, 217, 218, 194, 257, 60, 143, 194, 60,
174900
- /* 1560 */ 194, 121, 122, 183, 217, 218, 217, 218, 72, 217,
174901
- /* 1570 */ 218, 217, 218, 134, 23, 194, 25, 217, 218, 7,
174902
- /* 1580 */ 8, 321, 86, 217, 218, 194, 122, 91, 19, 20,
174903
- /* 1590 */ 23, 22, 25, 23, 142, 25, 132, 101, 217, 218,
174904
- /* 1600 */ 194, 194, 194, 107, 108, 36, 194, 194, 217, 218,
174905
- /* 1610 */ 194, 115, 194, 117, 118, 119, 194, 118, 122, 194,
174906
- /* 1620 */ 23, 194, 25, 217, 218, 217, 218, 194, 142, 60,
174907
- /* 1630 */ 217, 218, 194, 217, 218, 217, 218, 84, 85, 217,
174908
- /* 1640 */ 218, 72, 217, 218, 217, 218, 60, 23, 60, 25,
174909
- /* 1650 */ 154, 155, 156, 157, 158, 86, 154, 194, 156, 194,
174910
- /* 1660 */ 91, 19, 20, 23, 22, 25, 194, 23, 194, 25,
174911
- /* 1670 */ 101, 23, 194, 25, 194, 194, 107, 108, 36, 183,
174912
- /* 1680 */ 217, 218, 217, 218, 115, 194, 117, 118, 119, 217,
174913
- /* 1690 */ 218, 122, 194, 237, 194, 217, 218, 217, 218, 194,
174914
- /* 1700 */ 194, 23, 60, 25, 118, 23, 118, 25, 217, 218,
174915
- /* 1710 */ 23, 194, 25, 194, 72, 217, 218, 217, 218, 23,
174916
- /* 1720 */ 194, 25, 194, 154, 155, 156, 157, 158, 86, 23,
174917
- /* 1730 */ 194, 25, 194, 91, 217, 218, 217, 218, 194, 194,
174918
- /* 1740 */ 194, 194, 194, 101, 194, 217, 218, 290, 194, 107,
174919
- /* 1750 */ 108, 194, 183, 217, 218, 194, 194, 115, 194, 117,
174920
- /* 1760 */ 118, 119, 194, 243, 122, 194, 289, 194, 194, 194,
174921
- /* 1770 */ 194, 257, 257, 257, 244, 257, 192, 273, 215, 269,
174922
- /* 1780 */ 246, 299, 269, 295, 247, 273, 247, 246, 295, 230,
174923
- /* 1790 */ 261, 226, 261, 261, 273, 273, 154, 155, 156, 157,
174924
- /* 1800 */ 158, 0, 1, 2, 221, 220, 5, 220, 250, 220,
174925
- /* 1810 */ 261, 10, 11, 12, 13, 14, 250, 282, 17, 197,
174926
- /* 1820 */ 61, 19, 20, 246, 22, 183, 244, 142, 201, 201,
174927
- /* 1830 */ 38, 30, 299, 32, 201, 152, 22, 151, 36, 299,
174928
- /* 1840 */ 43, 40, 235, 18, 238, 285, 238, 238, 296, 238,
174929
- /* 1850 */ 201, 296, 274, 272, 18, 200, 235, 150, 235, 247,
174930
- /* 1860 */ 247, 247, 60, 247, 274, 274, 272, 201, 200, 159,
174931
- /* 1870 */ 63, 292, 71, 201, 72, 200, 22, 201, 222, 200,
174932
- /* 1880 */ 79, 201, 222, 82, 291, 116, 219, 65, 200, 219,
174933
- /* 1890 */ 219, 228, 22, 127, 225, 166, 222, 24, 225, 114,
174934
- /* 1900 */ 99, 284, 221, 101, 284, 228, 307, 315, 219, 107,
174935
- /* 1910 */ 108, 219, 219, 219, 201, 92, 320, 115, 320, 117,
174936
- /* 1920 */ 118, 119, 222, 83, 122, 267, 267, 149, 146, 19,
174937
- /* 1930 */ 20, 22, 22, 279, 250, 134, 201, 148, 159, 249,
174938
- /* 1940 */ 139, 140, 251, 141, 25, 281, 36, 147, 251, 248,
174939
- /* 1950 */ 247, 203, 13, 195, 6, 195, 154, 155, 156, 157,
174940
- /* 1960 */ 158, 193, 305, 193, 163, 193, 305, 302, 214, 208,
174941
- /* 1970 */ 60, 214, 208, 223, 223, 4, 214, 214, 3, 22,
174942
- /* 1980 */ 215, 214, 72, 208, 164, 183, 215, 15, 23, 16,
174943
- /* 1990 */ 23, 140, 131, 152, 25, 143, 20, 16, 24, 1,
174944
- /* 2000 */ 145, 143, 131, 131, 62, 37, 54, 54, 152, 54,
174945
- /* 2010 */ 54, 101, 131, 117, 34, 1, 142, 107, 108, 22,
174946
- /* 2020 */ 5, 116, 162, 69, 25, 115, 76, 117, 118, 119,
174947
- /* 2030 */ 1, 2, 122, 69, 5, 41, 142, 116, 20, 10,
175266
+ /* 1380 */ 27, 23, 7, 8, 9, 210, 211, 218, 219, 116,
175267
+ /* 1390 */ 218, 219, 228, 16, 147, 42, 195, 295, 195, 19,
175268
+ /* 1400 */ 20, 266, 22, 294, 103, 104, 105, 106, 107, 108,
175269
+ /* 1410 */ 109, 110, 111, 112, 113, 114, 36, 64, 145, 218,
175270
+ /* 1420 */ 219, 218, 219, 195, 103, 104, 105, 106, 107, 108,
175271
+ /* 1430 */ 109, 110, 111, 112, 113, 114, 195, 154, 119, 156,
175272
+ /* 1440 */ 60, 189, 190, 191, 192, 195, 218, 219, 195, 197,
175273
+ /* 1450 */ 195, 199, 72, 195, 19, 78, 195, 80, 206, 218,
175274
+ /* 1460 */ 219, 195, 82, 144, 210, 211, 195, 15, 218, 219,
175275
+ /* 1470 */ 47, 218, 219, 218, 219, 259, 260, 195, 261, 218,
175276
+ /* 1480 */ 219, 101, 302, 303, 218, 219, 195, 107, 108, 218,
175277
+ /* 1490 */ 219, 150, 151, 241, 242, 115, 25, 117, 118, 119,
175278
+ /* 1500 */ 218, 219, 122, 195, 146, 195, 254, 195, 256, 218,
175279
+ /* 1510 */ 219, 246, 25, 61, 246, 19, 20, 195, 22, 139,
175280
+ /* 1520 */ 140, 269, 257, 195, 266, 257, 218, 219, 218, 219,
175281
+ /* 1530 */ 218, 219, 36, 246, 154, 155, 156, 157, 158, 116,
175282
+ /* 1540 */ 218, 219, 195, 22, 257, 49, 218, 219, 23, 195,
175283
+ /* 1550 */ 25, 195, 117, 301, 195, 25, 60, 195, 195, 23,
175284
+ /* 1560 */ 195, 25, 195, 183, 24, 218, 219, 130, 72, 195,
175285
+ /* 1570 */ 22, 195, 218, 219, 218, 219, 195, 218, 219, 195,
175286
+ /* 1580 */ 218, 219, 86, 218, 219, 218, 219, 91, 19, 20,
175287
+ /* 1590 */ 153, 22, 218, 219, 218, 219, 195, 101, 195, 218,
175288
+ /* 1600 */ 219, 195, 195, 107, 108, 36, 23, 195, 25, 195,
175289
+ /* 1610 */ 62, 115, 195, 117, 118, 119, 195, 146, 122, 218,
175290
+ /* 1620 */ 219, 218, 219, 195, 218, 219, 19, 60, 122, 60,
175291
+ /* 1630 */ 218, 219, 218, 219, 195, 218, 219, 150, 132, 218,
175292
+ /* 1640 */ 219, 72, 195, 23, 195, 25, 218, 219, 195, 60,
175293
+ /* 1650 */ 154, 155, 156, 157, 158, 86, 23, 195, 25, 195,
175294
+ /* 1660 */ 91, 19, 20, 142, 22, 218, 219, 218, 219, 130,
175295
+ /* 1670 */ 101, 218, 219, 143, 121, 122, 107, 108, 36, 183,
175296
+ /* 1680 */ 218, 219, 142, 60, 115, 118, 117, 118, 119, 7,
175297
+ /* 1690 */ 8, 122, 153, 23, 23, 25, 25, 23, 23, 25,
175298
+ /* 1700 */ 25, 23, 60, 25, 23, 98, 25, 118, 84, 85,
175299
+ /* 1710 */ 23, 23, 25, 25, 72, 154, 23, 156, 25, 23,
175300
+ /* 1720 */ 228, 25, 195, 154, 155, 156, 157, 158, 86, 195,
175301
+ /* 1730 */ 195, 258, 195, 91, 291, 322, 195, 195, 195, 195,
175302
+ /* 1740 */ 195, 118, 195, 101, 195, 195, 195, 195, 238, 107,
175303
+ /* 1750 */ 108, 195, 183, 195, 195, 195, 290, 115, 195, 117,
175304
+ /* 1760 */ 118, 119, 244, 195, 122, 195, 195, 195, 195, 195,
175305
+ /* 1770 */ 195, 258, 258, 258, 258, 193, 245, 300, 216, 274,
175306
+ /* 1780 */ 247, 270, 270, 274, 296, 296, 248, 222, 262, 198,
175307
+ /* 1790 */ 262, 274, 61, 274, 248, 231, 154, 155, 156, 157,
175308
+ /* 1800 */ 158, 0, 1, 2, 247, 227, 5, 221, 221, 221,
175309
+ /* 1810 */ 142, 10, 11, 12, 13, 14, 262, 262, 17, 202,
175310
+ /* 1820 */ 300, 19, 20, 300, 22, 183, 247, 251, 251, 245,
175311
+ /* 1830 */ 202, 30, 38, 32, 202, 152, 151, 22, 36, 43,
175312
+ /* 1840 */ 236, 40, 18, 202, 239, 239, 18, 239, 239, 283,
175313
+ /* 1850 */ 201, 150, 236, 202, 236, 201, 159, 202, 248, 248,
175314
+ /* 1860 */ 248, 248, 60, 63, 201, 275, 273, 275, 273, 275,
175315
+ /* 1870 */ 22, 286, 71, 223, 72, 202, 223, 297, 297, 202,
175316
+ /* 1880 */ 79, 201, 116, 82, 220, 201, 220, 220, 65, 293,
175317
+ /* 1890 */ 292, 229, 22, 166, 127, 226, 24, 114, 226, 223,
175318
+ /* 1900 */ 99, 222, 202, 101, 285, 92, 220, 308, 83, 107,
175319
+ /* 1910 */ 108, 220, 220, 316, 220, 285, 268, 115, 229, 117,
175320
+ /* 1920 */ 118, 119, 223, 321, 122, 268, 149, 146, 22, 19,
175321
+ /* 1930 */ 20, 202, 22, 159, 282, 134, 321, 148, 280, 147,
175322
+ /* 1940 */ 139, 140, 252, 141, 25, 204, 36, 252, 13, 251,
175323
+ /* 1950 */ 196, 248, 250, 249, 196, 6, 154, 155, 156, 157,
175324
+ /* 1960 */ 158, 209, 194, 194, 163, 194, 306, 306, 303, 224,
175325
+ /* 1970 */ 60, 215, 215, 209, 215, 215, 215, 224, 216, 216,
175326
+ /* 1980 */ 4, 209, 72, 3, 22, 183, 164, 15, 23, 16,
175327
+ /* 1990 */ 23, 140, 152, 131, 25, 24, 143, 20, 16, 145,
175328
+ /* 2000 */ 1, 143, 131, 62, 131, 37, 54, 152, 54, 54,
175329
+ /* 2010 */ 54, 101, 131, 117, 1, 34, 142, 107, 108, 5,
175330
+ /* 2020 */ 22, 116, 162, 76, 41, 115, 69, 117, 118, 119,
175331
+ /* 2030 */ 1, 2, 122, 25, 5, 69, 142, 116, 20, 10,
174948175332
/* 2040 */ 11, 12, 13, 14, 24, 19, 17, 132, 5, 126,
174949175333
/* 2050 */ 22, 141, 68, 10, 11, 12, 13, 14, 22, 30,
174950175334
/* 2060 */ 17, 32, 22, 22, 154, 155, 156, 157, 158, 40,
174951175335
/* 2070 */ 23, 68, 60, 30, 24, 32, 97, 28, 22, 68,
174952175336
/* 2080 */ 23, 37, 34, 40, 150, 22, 25, 23, 23, 23,
174953
- /* 2090 */ 22, 98, 23, 183, 23, 117, 34, 22, 25, 89,
174954
- /* 2100 */ 71, 142, 144, 76, 34, 23, 34, 76, 79, 87,
174955
- /* 2110 */ 34, 82, 34, 94, 71, 34, 22, 24, 44, 34,
174956
- /* 2120 */ 25, 25, 79, 23, 23, 82, 143, 23, 99, 143,
174957
- /* 2130 */ 23, 22, 11, 25, 23, 25, 22, 22, 22, 1,
174958
- /* 2140 */ 23, 23, 99, 136, 22, 22, 142, 142, 142, 25,
174959
- /* 2150 */ 25, 23, 15, 1, 322, 322, 322, 322, 322, 322,
174960
- /* 2160 */ 322, 322, 322, 134, 322, 322, 322, 322, 139, 140,
174961
- /* 2170 */ 322, 322, 322, 322, 322, 322, 322, 134, 322, 322,
174962
- /* 2180 */ 322, 322, 139, 140, 322, 322, 322, 322, 322, 322,
174963
- /* 2190 */ 322, 322, 163, 322, 322, 322, 322, 322, 322, 322,
174964
- /* 2200 */ 322, 322, 322, 322, 322, 322, 163, 322, 322, 322,
174965
- /* 2210 */ 322, 322, 322, 322, 322, 322, 322, 322, 322, 322,
174966
- /* 2220 */ 322, 322, 322, 322, 322, 322, 322, 322, 322, 322,
174967
- /* 2230 */ 322, 322, 322, 322, 322, 322, 322, 322, 322, 322,
174968
- /* 2240 */ 322, 322, 322, 322, 322, 322, 322, 322, 322, 322,
174969
- /* 2250 */ 322, 322, 322, 322, 322, 322, 322, 322, 322, 322,
174970
- /* 2260 */ 322, 322, 322, 322, 322, 322, 322, 322, 322, 322,
174971
- /* 2270 */ 322, 322, 322, 322, 322, 322, 322, 322, 322, 322,
174972
- /* 2280 */ 322, 322, 322, 322, 322, 322, 322, 322, 322, 322,
174973
- /* 2290 */ 322, 322, 322, 322, 322, 322, 322, 322, 322, 322,
174974
- /* 2300 */ 322, 322, 322, 322, 322, 322, 322, 322, 322, 322,
174975
- /* 2310 */ 322, 322, 322, 322, 322, 322, 322, 322, 322, 322,
174976
- /* 2320 */ 322, 322, 322, 322, 322, 322, 322, 322, 322, 322,
174977
- /* 2330 */ 322, 322, 322, 322, 322, 322, 322, 322, 322, 322,
174978
- /* 2340 */ 186, 186, 186, 186, 186, 186, 186, 186, 186, 186,
174979
- /* 2350 */ 186, 186, 186, 186, 186, 186, 186, 186, 186, 186,
174980
- /* 2360 */ 186, 186, 186, 186, 186, 186, 186, 186, 186, 186,
174981
- /* 2370 */ 186, 186, 186, 186, 186, 186, 186, 186, 186, 186,
174982
- /* 2380 */ 186, 186, 186, 186, 186, 186, 186, 186, 186, 186,
174983
- /* 2390 */ 186, 186, 186,
175337
+ /* 2090 */ 22, 98, 142, 183, 23, 23, 34, 22, 25, 89,
175338
+ /* 2100 */ 71, 34, 117, 144, 34, 22, 76, 76, 79, 87,
175339
+ /* 2110 */ 34, 82, 34, 44, 71, 94, 34, 23, 25, 24,
175340
+ /* 2120 */ 34, 25, 79, 23, 23, 82, 23, 23, 99, 143,
175341
+ /* 2130 */ 143, 22, 25, 25, 23, 22, 11, 22, 22, 25,
175342
+ /* 2140 */ 23, 23, 99, 22, 22, 136, 142, 142, 142, 25,
175343
+ /* 2150 */ 23, 15, 1, 1, 323, 323, 323, 323, 323, 323,
175344
+ /* 2160 */ 323, 323, 323, 134, 323, 323, 323, 323, 139, 140,
175345
+ /* 2170 */ 323, 323, 323, 323, 323, 323, 323, 134, 323, 323,
175346
+ /* 2180 */ 323, 323, 139, 140, 323, 323, 323, 323, 323, 323,
175347
+ /* 2190 */ 323, 323, 163, 323, 323, 323, 323, 323, 323, 323,
175348
+ /* 2200 */ 323, 323, 323, 323, 323, 323, 163, 323, 323, 323,
175349
+ /* 2210 */ 323, 323, 323, 323, 323, 323, 323, 323, 323, 323,
175350
+ /* 2220 */ 323, 323, 323, 323, 323, 323, 323, 323, 323, 323,
175351
+ /* 2230 */ 323, 323, 323, 323, 323, 323, 323, 323, 323, 323,
175352
+ /* 2240 */ 323, 323, 323, 323, 323, 323, 323, 323, 323, 323,
175353
+ /* 2250 */ 323, 323, 323, 323, 323, 323, 323, 323, 323, 323,
175354
+ /* 2260 */ 323, 323, 323, 323, 323, 323, 323, 323, 323, 323,
175355
+ /* 2270 */ 323, 323, 323, 323, 323, 323, 323, 323, 323, 323,
175356
+ /* 2280 */ 323, 323, 323, 323, 323, 323, 323, 323, 323, 323,
175357
+ /* 2290 */ 323, 323, 323, 323, 323, 323, 323, 323, 323, 323,
175358
+ /* 2300 */ 323, 323, 323, 323, 323, 323, 323, 323, 323, 323,
175359
+ /* 2310 */ 323, 323, 323, 323, 323, 323, 323, 323, 323, 323,
175360
+ /* 2320 */ 323, 323, 323, 323, 323, 323, 323, 323, 323, 323,
175361
+ /* 2330 */ 323, 323, 323, 323, 323, 323, 323, 323, 323, 323,
175362
+ /* 2340 */ 323, 187, 187, 187, 187, 187, 187, 187, 187, 187,
175363
+ /* 2350 */ 187, 187, 187, 187, 187, 187, 187, 187, 187, 187,
175364
+ /* 2360 */ 187, 187, 187, 187, 187, 187, 187, 187, 187, 187,
175365
+ /* 2370 */ 187, 187, 187, 187, 187, 187, 187, 187, 187, 187,
175366
+ /* 2380 */ 187, 187, 187, 187, 187, 187, 187, 187, 187, 187,
175367
+ /* 2390 */ 187, 187, 187, 187,
174984175368
};
174985175369
#define YY_SHIFT_COUNT (582)
174986175370
#define YY_SHIFT_MIN (0)
174987175371
#define YY_SHIFT_MAX (2152)
174988175372
static const unsigned short int yy_shift_ofst[] = {
174989
- /* 0 */ 2029, 1801, 2043, 1380, 1380, 33, 391, 1496, 1569, 1642,
174990
- /* 10 */ 702, 702, 702, 193, 33, 33, 33, 33, 33, 0,
175373
+ /* 0 */ 2029, 1801, 2043, 1380, 1380, 318, 271, 1496, 1569, 1642,
175374
+ /* 10 */ 702, 702, 702, 740, 318, 318, 318, 318, 318, 0,
174991175375
/* 20 */ 0, 216, 1177, 702, 702, 702, 702, 702, 702, 702,
174992
- /* 30 */ 702, 702, 702, 702, 702, 702, 702, 702, 406, 406,
174993
- /* 40 */ 111, 111, 218, 447, 547, 598, 598, 260, 260, 260,
174994
- /* 50 */ 260, 40, 112, 320, 340, 445, 489, 593, 637, 741,
175376
+ /* 30 */ 702, 702, 702, 702, 702, 702, 702, 702, 503, 503,
175377
+ /* 40 */ 111, 111, 217, 287, 348, 610, 610, 736, 736, 736,
175378
+ /* 50 */ 736, 40, 112, 320, 340, 445, 489, 593, 637, 741,
174995175379
/* 60 */ 785, 889, 909, 1023, 1043, 1157, 1177, 1177, 1177, 1177,
174996175380
/* 70 */ 1177, 1177, 1177, 1177, 1177, 1177, 1177, 1177, 1177, 1177,
174997175381
/* 80 */ 1177, 1177, 1177, 1177, 1197, 1177, 1301, 1321, 1321, 554,
174998175382
/* 90 */ 1802, 1910, 702, 702, 702, 702, 702, 702, 702, 702,
174999175383
/* 100 */ 702, 702, 702, 702, 702, 702, 702, 702, 702, 702,
175000175384
/* 110 */ 702, 702, 702, 702, 702, 702, 702, 702, 702, 702,
175001175385
/* 120 */ 702, 702, 702, 702, 702, 702, 702, 702, 702, 702,
175002175386
/* 130 */ 702, 702, 702, 702, 702, 702, 702, 702, 702, 702,
175003175387
/* 140 */ 702, 702, 138, 198, 198, 198, 198, 198, 198, 198,
175004
- /* 150 */ 183, 99, 236, 292, 598, 793, 167, 598, 598, 880,
175005
- /* 160 */ 880, 598, 857, 150, 195, 195, 195, 264, 113, 113,
175006
- /* 170 */ 2207, 2207, 854, 854, 854, 751, 765, 765, 765, 765,
175007
- /* 180 */ 1096, 1096, 725, 292, 882, 904, 598, 598, 598, 598,
175008
- /* 190 */ 598, 598, 598, 598, 598, 598, 598, 598, 598, 598,
175009
- /* 200 */ 598, 598, 598, 598, 598, 1273, 1032, 1032, 598, 147,
175010
- /* 210 */ 1098, 1098, 603, 603, 1276, 1276, 363, 2207, 2207, 2207,
175011
- /* 220 */ 2207, 2207, 2207, 2207, 469, 617, 617, 801, 336, 461,
175012
- /* 230 */ 804, 864, 615, 891, 913, 598, 598, 598, 598, 598,
175013
- /* 240 */ 598, 598, 598, 598, 598, 653, 598, 598, 598, 598,
175014
- /* 250 */ 598, 598, 598, 598, 598, 598, 598, 598, 1105, 1105,
175015
- /* 260 */ 1105, 598, 598, 598, 1194, 598, 598, 598, 1215, 1249,
175016
- /* 270 */ 598, 1353, 598, 598, 598, 598, 598, 598, 598, 598,
175017
- /* 280 */ 677, 449, 902, 1338, 1338, 1338, 1338, 1248, 902, 902,
175018
- /* 290 */ 326, 1151, 1047, 755, 749, 1371, 960, 1371, 1007, 1162,
175019
- /* 300 */ 749, 749, 1162, 749, 960, 1007, 1274, 738, 215, 1300,
175020
- /* 310 */ 1300, 1300, 1395, 1395, 1395, 1395, 1368, 1368, 1033, 1414,
175021
- /* 320 */ 1387, 1361, 1759, 1759, 1685, 1685, 1792, 1792, 1685, 1683,
175022
- /* 330 */ 1686, 1814, 1797, 1825, 1825, 1825, 1825, 1685, 1836, 1707,
175023
- /* 340 */ 1686, 1686, 1707, 1814, 1797, 1707, 1797, 1707, 1685, 1836,
175024
- /* 350 */ 1710, 1807, 1685, 1836, 1854, 1685, 1836, 1685, 1836, 1854,
175025
- /* 360 */ 1769, 1769, 1769, 1822, 1870, 1870, 1854, 1769, 1766, 1769,
175026
- /* 370 */ 1822, 1769, 1769, 1729, 1873, 1785, 1785, 1854, 1685, 1823,
175027
- /* 380 */ 1823, 1840, 1840, 1778, 1782, 1909, 1685, 1779, 1778, 1789,
175028
- /* 390 */ 1800, 1707, 1919, 1939, 1939, 1948, 1948, 1948, 2207, 2207,
175388
+ /* 150 */ 183, 99, 169, 549, 610, 151, 542, 610, 610, 1017,
175389
+ /* 160 */ 1017, 610, 1001, 350, 464, 464, 464, 586, 1, 1,
175390
+ /* 170 */ 2207, 2207, 854, 854, 854, 465, 694, 694, 694, 694,
175391
+ /* 180 */ 1096, 1096, 825, 549, 847, 904, 610, 610, 610, 610,
175392
+ /* 190 */ 610, 610, 610, 610, 610, 610, 610, 610, 610, 610,
175393
+ /* 200 */ 610, 610, 610, 610, 610, 488, 947, 947, 610, 1129,
175394
+ /* 210 */ 495, 495, 1139, 1139, 967, 967, 1173, 2207, 2207, 2207,
175395
+ /* 220 */ 2207, 2207, 2207, 2207, 617, 765, 765, 697, 444, 708,
175396
+ /* 230 */ 660, 745, 510, 663, 864, 610, 610, 610, 610, 610,
175397
+ /* 240 */ 610, 610, 610, 610, 610, 188, 610, 610, 610, 610,
175398
+ /* 250 */ 610, 610, 610, 610, 610, 610, 610, 610, 839, 839,
175399
+ /* 260 */ 839, 610, 610, 610, 1155, 610, 610, 610, 1119, 1247,
175400
+ /* 270 */ 610, 1353, 610, 610, 610, 610, 610, 610, 610, 610,
175401
+ /* 280 */ 1063, 494, 1101, 291, 291, 291, 291, 1319, 1101, 1101,
175402
+ /* 290 */ 775, 1221, 1375, 1452, 667, 1341, 1198, 1341, 1435, 1487,
175403
+ /* 300 */ 667, 667, 1487, 667, 1198, 1435, 777, 1011, 1423, 584,
175404
+ /* 310 */ 584, 584, 1273, 1273, 1273, 1273, 1471, 1471, 880, 1530,
175405
+ /* 320 */ 1190, 1095, 1731, 1731, 1668, 1668, 1794, 1794, 1668, 1683,
175406
+ /* 330 */ 1685, 1815, 1796, 1824, 1824, 1824, 1824, 1668, 1828, 1701,
175407
+ /* 340 */ 1685, 1685, 1701, 1815, 1796, 1701, 1796, 1701, 1668, 1828,
175408
+ /* 350 */ 1697, 1800, 1668, 1828, 1848, 1668, 1828, 1668, 1828, 1848,
175409
+ /* 360 */ 1766, 1766, 1766, 1823, 1870, 1870, 1848, 1766, 1767, 1766,
175410
+ /* 370 */ 1823, 1766, 1766, 1727, 1872, 1783, 1783, 1848, 1668, 1813,
175411
+ /* 380 */ 1813, 1825, 1825, 1777, 1781, 1906, 1668, 1774, 1777, 1789,
175412
+ /* 390 */ 1792, 1701, 1919, 1935, 1935, 1949, 1949, 1949, 2207, 2207,
175029175413
/* 400 */ 2207, 2207, 2207, 2207, 2207, 2207, 2207, 2207, 2207, 2207,
175030
- /* 410 */ 2207, 2207, 2207, 69, 1037, 79, 1088, 651, 1196, 1415,
175031
- /* 420 */ 1501, 1439, 1369, 1452, 911, 1211, 1524, 1469, 1551, 1567,
175032
- /* 430 */ 1570, 1624, 1640, 1644, 1499, 1440, 1572, 1464, 1597, 275,
175033
- /* 440 */ 782, 1586, 1648, 1678, 1553, 1682, 1687, 1388, 1502, 1696,
175034
- /* 450 */ 1706, 1588, 1486, 1971, 1975, 1957, 1820, 1972, 1973, 1965,
175035
- /* 460 */ 1967, 1851, 1841, 1861, 1969, 1969, 1974, 1852, 1976, 1855,
175036
- /* 470 */ 1981, 1998, 1858, 1871, 1969, 1872, 1942, 1968, 1969, 1856,
175037
- /* 480 */ 1952, 1953, 1955, 1956, 1881, 1896, 1980, 1874, 2014, 2015,
175038
- /* 490 */ 1997, 1905, 1860, 1954, 1999, 1964, 1950, 1994, 1894, 1921,
175414
+ /* 410 */ 2207, 2207, 2207, 69, 1032, 79, 357, 1377, 1206, 400,
175415
+ /* 420 */ 1525, 835, 332, 1540, 1437, 1539, 1536, 1548, 1583, 1620,
175416
+ /* 430 */ 1633, 1670, 1671, 1674, 1567, 1553, 1682, 1506, 1675, 1358,
175417
+ /* 440 */ 1607, 1589, 1678, 1681, 1624, 1687, 1688, 1283, 1561, 1693,
175418
+ /* 450 */ 1696, 1623, 1521, 1976, 1980, 1962, 1822, 1972, 1973, 1965,
175419
+ /* 460 */ 1967, 1851, 1840, 1862, 1969, 1969, 1971, 1853, 1977, 1854,
175420
+ /* 470 */ 1982, 1999, 1858, 1871, 1969, 1873, 1941, 1968, 1969, 1855,
175421
+ /* 480 */ 1952, 1954, 1955, 1956, 1881, 1896, 1981, 1874, 2013, 2014,
175422
+ /* 490 */ 1998, 1905, 1860, 1957, 2008, 1966, 1947, 1983, 1894, 1921,
175039175423
/* 500 */ 2020, 2018, 2026, 1915, 1923, 2028, 1984, 2036, 2040, 2047,
175040175424
/* 510 */ 2041, 2003, 2012, 2050, 1979, 2049, 2056, 2011, 2044, 2057,
175041
- /* 520 */ 2048, 1934, 2063, 2064, 2065, 2061, 2066, 2068, 1993, 1959,
175042
- /* 530 */ 2069, 2071, 1978, 2062, 2075, 1958, 2073, 2070, 2072, 2076,
175043
- /* 540 */ 2078, 2010, 2027, 2022, 2074, 2031, 2019, 2081, 2082, 2094,
175044
- /* 550 */ 2093, 2095, 2096, 2085, 1983, 1986, 2100, 2073, 2101, 2104,
175045
- /* 560 */ 2107, 2109, 2108, 2110, 2111, 2114, 2121, 2115, 2116, 2117,
175046
- /* 570 */ 2118, 2122, 2123, 2124, 2007, 2004, 2005, 2006, 2125, 2128,
175047
- /* 580 */ 2137, 2138, 2152,
175425
+ /* 520 */ 2048, 1934, 2063, 2064, 2065, 2061, 2066, 2068, 1993, 1950,
175426
+ /* 530 */ 2071, 2072, 1985, 2062, 2075, 1959, 2073, 2067, 2070, 2076,
175427
+ /* 540 */ 2078, 2010, 2030, 2022, 2069, 2031, 2021, 2082, 2094, 2083,
175428
+ /* 550 */ 2095, 2093, 2096, 2086, 1986, 1987, 2100, 2073, 2101, 2103,
175429
+ /* 560 */ 2104, 2109, 2107, 2108, 2111, 2113, 2125, 2115, 2116, 2117,
175430
+ /* 570 */ 2118, 2121, 2122, 2114, 2009, 2004, 2005, 2006, 2124, 2127,
175431
+ /* 580 */ 2136, 2151, 2152,
175048175432
};
175049175433
#define YY_REDUCE_COUNT (412)
175050
-#define YY_REDUCE_MIN (-276)
175051
-#define YY_REDUCE_MAX (1775)
175434
+#define YY_REDUCE_MIN (-277)
175435
+#define YY_REDUCE_MAX (1772)
175052175436
static const short yy_reduce_ofst[] = {
175053
- /* 0 */ -66, 217, -63, -177, -180, 161, 364, 64, -183, 162,
175054
- /* 10 */ 223, 367, 414, -173, 473, 514, 525, 622, 626, -207,
175055
- /* 20 */ 351, -276, -38, 693, 811, 831, 833, 888, -188, 945,
175056
- /* 30 */ 947, 416, 558, 951, 867, 287, 1078, 1080, -186, 224,
175057
- /* 40 */ -132, 42, 964, 269, 417, 796, 810, -237, -231, -237,
175058
- /* 50 */ -231, -45, -45, -45, -45, -45, -45, -45, -45, -45,
175059
- /* 60 */ -45, -45, -45, -45, -45, -45, -45, -45, -45, -45,
175060
- /* 70 */ -45, -45, -45, -45, -45, -45, -45, -45, -45, -45,
175061
- /* 80 */ -45, -45, -45, -45, -45, -45, -45, -45, -45, 895,
175062
- /* 90 */ 925, 967, 980, 1100, 1143, 1169, 1203, 1225, 1228, 1242,
175063
- /* 100 */ 1247, 1250, 1253, 1255, 1261, 1267, 1272, 1275, 1283, 1286,
175064
- /* 110 */ 1288, 1292, 1333, 1335, 1347, 1349, 1352, 1354, 1360, 1366,
175065
- /* 120 */ 1381, 1391, 1406, 1408, 1413, 1416, 1418, 1422, 1425, 1427,
175066
- /* 130 */ 1463, 1465, 1472, 1478, 1480, 1491, 1498, 1500, 1517, 1519,
175067
- /* 140 */ 1528, 1536, -45, -45, -45, -45, -45, -45, -45, -45,
175068
- /* 150 */ -45, -45, -45, 312, -158, 285, -219, 9, 166, 370,
175069
- /* 160 */ 545, 707, -45, 930, 601, 963, 1067, 792, -45, -45,
175070
- /* 170 */ -45, -45, -204, -204, -204, 369, -171, -129, 632, 678,
175071
- /* 180 */ 202, 352, -270, 412, 627, 627, -9, 122, 415, 419,
175072
- /* 190 */ -56, 248, 583, 920, 6, 261, 459, 795, 1049, 813,
175073
- /* 200 */ 1062, 1082, -161, 778, 1063, 797, 870, 1003, 1128, 443,
175074
- /* 210 */ 1031, 1072, 1191, 1192, 957, 1120, 105, 1149, 523, 933,
175075
- /* 220 */ 1218, 1238, 1254, 1251, -138, 96, 117, 146, 181, 277,
175076
- /* 230 */ 280, 421, 480, 712, 830, 850, 1085, 1099, 1129, 1209,
175077
- /* 240 */ 1323, 1331, 1336, 1364, 1407, 368, 1412, 1433, 1438, 1474,
175078
- /* 250 */ 1481, 1505, 1506, 1526, 1538, 1544, 1545, 1546, 722, 764,
175079
- /* 260 */ 856, 1547, 1548, 1550, 1188, 1554, 1557, 1561, 1298, 1260,
175080
- /* 270 */ 1562, 1456, 1564, 280, 1568, 1571, 1573, 1574, 1575, 1576,
175081
- /* 280 */ 1457, 1477, 1520, 1514, 1515, 1516, 1518, 1188, 1520, 1520,
175082
- /* 290 */ 1530, 1563, 1584, 1482, 1504, 1510, 1534, 1513, 1488, 1537,
175083
- /* 300 */ 1512, 1521, 1539, 1522, 1541, 1493, 1583, 1559, 1565, 1585,
175084
- /* 310 */ 1587, 1589, 1529, 1531, 1532, 1549, 1558, 1566, 1535, 1577,
175085
- /* 320 */ 1582, 1622, 1533, 1540, 1627, 1628, 1552, 1555, 1633, 1560,
175086
- /* 330 */ 1578, 1581, 1607, 1606, 1608, 1609, 1611, 1649, 1655, 1612,
175087
- /* 340 */ 1590, 1591, 1613, 1594, 1621, 1614, 1623, 1616, 1666, 1668,
175088
- /* 350 */ 1579, 1593, 1672, 1675, 1656, 1676, 1679, 1680, 1688, 1660,
175089
- /* 360 */ 1667, 1670, 1671, 1663, 1669, 1673, 1674, 1689, 1681, 1692,
175090
- /* 370 */ 1677, 1693, 1694, 1592, 1599, 1617, 1620, 1700, 1713, 1596,
175091
- /* 380 */ 1598, 1658, 1659, 1691, 1684, 1654, 1735, 1664, 1697, 1690,
175092
- /* 390 */ 1701, 1703, 1748, 1758, 1760, 1768, 1770, 1772, 1657, 1661,
175093
- /* 400 */ 1665, 1761, 1754, 1757, 1762, 1763, 1764, 1750, 1751, 1765,
175094
- /* 410 */ 1771, 1767, 1775,
175437
+ /* 0 */ -67, 1252, -64, -178, -181, 160, 1071, 143, -184, 137,
175438
+ /* 10 */ 218, 220, 222, -174, 229, 268, 272, 275, 324, -208,
175439
+ /* 20 */ 242, -277, -39, 81, 537, 792, 810, 812, -189, 814,
175440
+ /* 30 */ 831, 163, 865, 944, 887, 840, 964, 1077, -187, 292,
175441
+ /* 40 */ -133, 274, 673, 558, 682, 795, 809, -238, -232, -238,
175442
+ /* 50 */ -232, 329, 329, 329, 329, 329, 329, 329, 329, 329,
175443
+ /* 60 */ 329, 329, 329, 329, 329, 329, 329, 329, 329, 329,
175444
+ /* 70 */ 329, 329, 329, 329, 329, 329, 329, 329, 329, 329,
175445
+ /* 80 */ 329, 329, 329, 329, 329, 329, 329, 329, 329, 557,
175446
+ /* 90 */ 712, 949, 966, 969, 971, 979, 1097, 1099, 1103, 1142,
175447
+ /* 100 */ 1144, 1169, 1172, 1201, 1203, 1228, 1241, 1250, 1253, 1255,
175448
+ /* 110 */ 1261, 1266, 1271, 1282, 1291, 1308, 1310, 1312, 1322, 1328,
175449
+ /* 120 */ 1347, 1354, 1356, 1359, 1362, 1365, 1367, 1374, 1376, 1381,
175450
+ /* 130 */ 1401, 1403, 1406, 1412, 1414, 1417, 1421, 1428, 1447, 1449,
175451
+ /* 140 */ 1453, 1462, 329, 329, 329, 329, 329, 329, 329, 329,
175452
+ /* 150 */ 329, 329, 329, -22, -159, 475, -220, 756, 38, 501,
175453
+ /* 160 */ 841, 714, 329, 118, 337, 349, 363, -56, 329, 329,
175454
+ /* 170 */ 329, 329, -205, -205, -205, 687, -172, -130, -57, 790,
175455
+ /* 180 */ 397, 528, -271, 136, 596, 596, 90, 316, 522, 541,
175456
+ /* 190 */ -37, 715, 849, 977, 628, 856, 980, 991, 1081, 1102,
175457
+ /* 200 */ 1135, 1083, -162, 208, 1258, 794, -86, 159, 41, 1109,
175458
+ /* 210 */ 671, 852, 844, 932, 1175, 1254, 480, 1180, 100, 258,
175459
+ /* 220 */ 1265, 1268, 1216, 1287, -139, 317, 344, 63, 339, 423,
175460
+ /* 230 */ 563, 636, 676, 813, 908, 914, 950, 1078, 1084, 1098,
175461
+ /* 240 */ 1363, 1384, 1407, 1439, 1464, 411, 1527, 1534, 1535, 1537,
175462
+ /* 250 */ 1541, 1542, 1543, 1544, 1545, 1547, 1549, 1550, 990, 1164,
175463
+ /* 260 */ 1492, 1551, 1552, 1556, 1217, 1558, 1559, 1560, 1473, 1413,
175464
+ /* 270 */ 1563, 1510, 1568, 563, 1570, 1571, 1572, 1573, 1574, 1575,
175465
+ /* 280 */ 1443, 1466, 1518, 1513, 1514, 1515, 1516, 1217, 1518, 1518,
175466
+ /* 290 */ 1531, 1562, 1582, 1477, 1505, 1511, 1533, 1512, 1488, 1538,
175467
+ /* 300 */ 1509, 1517, 1546, 1519, 1557, 1489, 1565, 1564, 1578, 1586,
175468
+ /* 310 */ 1587, 1588, 1526, 1528, 1554, 1555, 1576, 1577, 1566, 1579,
175469
+ /* 320 */ 1584, 1591, 1520, 1523, 1617, 1628, 1580, 1581, 1632, 1585,
175470
+ /* 330 */ 1590, 1593, 1604, 1605, 1606, 1608, 1609, 1641, 1649, 1610,
175471
+ /* 340 */ 1592, 1594, 1611, 1595, 1616, 1612, 1618, 1613, 1651, 1654,
175472
+ /* 350 */ 1596, 1598, 1655, 1663, 1650, 1673, 1680, 1677, 1684, 1653,
175473
+ /* 360 */ 1664, 1666, 1667, 1662, 1669, 1672, 1676, 1686, 1679, 1691,
175474
+ /* 370 */ 1689, 1692, 1694, 1597, 1599, 1619, 1630, 1699, 1700, 1602,
175475
+ /* 380 */ 1615, 1648, 1657, 1690, 1698, 1658, 1729, 1652, 1695, 1702,
175476
+ /* 390 */ 1704, 1703, 1741, 1754, 1758, 1768, 1769, 1771, 1660, 1661,
175477
+ /* 400 */ 1665, 1752, 1756, 1757, 1759, 1760, 1764, 1745, 1753, 1762,
175478
+ /* 410 */ 1763, 1761, 1772,
175095175479
};
175096175480
static const YYACTIONTYPE yy_default[] = {
175097175481
/* 0 */ 1663, 1663, 1663, 1491, 1254, 1367, 1254, 1254, 1254, 1254,
175098175482
/* 10 */ 1491, 1491, 1491, 1254, 1254, 1254, 1254, 1254, 1254, 1397,
175099175483
/* 20 */ 1397, 1544, 1287, 1254, 1254, 1254, 1254, 1254, 1254, 1254,
@@ -175355,10 +175739,11 @@
175355175739
0, /* ASTERISK => nothing */
175356175740
0, /* SPAN => nothing */
175357175741
0, /* ERROR => nothing */
175358175742
0, /* QNUMBER => nothing */
175359175743
0, /* SPACE => nothing */
175744
+ 0, /* COMMENT => nothing */
175360175745
0, /* ILLEGAL => nothing */
175361175746
};
175362175747
#endif /* YYFALLBACK */
175363175748
175364175749
/* The following structure represents a single element of the
@@ -175624,147 +176009,148 @@
175624176009
/* 180 */ "ASTERISK",
175625176010
/* 181 */ "SPAN",
175626176011
/* 182 */ "ERROR",
175627176012
/* 183 */ "QNUMBER",
175628176013
/* 184 */ "SPACE",
175629
- /* 185 */ "ILLEGAL",
175630
- /* 186 */ "input",
175631
- /* 187 */ "cmdlist",
175632
- /* 188 */ "ecmd",
175633
- /* 189 */ "cmdx",
175634
- /* 190 */ "explain",
175635
- /* 191 */ "cmd",
175636
- /* 192 */ "transtype",
175637
- /* 193 */ "trans_opt",
175638
- /* 194 */ "nm",
175639
- /* 195 */ "savepoint_opt",
175640
- /* 196 */ "create_table",
175641
- /* 197 */ "create_table_args",
175642
- /* 198 */ "createkw",
175643
- /* 199 */ "temp",
175644
- /* 200 */ "ifnotexists",
175645
- /* 201 */ "dbnm",
175646
- /* 202 */ "columnlist",
175647
- /* 203 */ "conslist_opt",
175648
- /* 204 */ "table_option_set",
175649
- /* 205 */ "select",
175650
- /* 206 */ "table_option",
175651
- /* 207 */ "columnname",
175652
- /* 208 */ "carglist",
175653
- /* 209 */ "typetoken",
175654
- /* 210 */ "typename",
175655
- /* 211 */ "signed",
175656
- /* 212 */ "plus_num",
175657
- /* 213 */ "minus_num",
175658
- /* 214 */ "scanpt",
175659
- /* 215 */ "scantok",
175660
- /* 216 */ "ccons",
175661
- /* 217 */ "term",
175662
- /* 218 */ "expr",
175663
- /* 219 */ "onconf",
175664
- /* 220 */ "sortorder",
175665
- /* 221 */ "autoinc",
175666
- /* 222 */ "eidlist_opt",
175667
- /* 223 */ "refargs",
175668
- /* 224 */ "defer_subclause",
175669
- /* 225 */ "generated",
175670
- /* 226 */ "refarg",
175671
- /* 227 */ "refact",
175672
- /* 228 */ "init_deferred_pred_opt",
175673
- /* 229 */ "conslist",
175674
- /* 230 */ "tconscomma",
175675
- /* 231 */ "tcons",
175676
- /* 232 */ "sortlist",
175677
- /* 233 */ "eidlist",
175678
- /* 234 */ "defer_subclause_opt",
175679
- /* 235 */ "orconf",
175680
- /* 236 */ "resolvetype",
175681
- /* 237 */ "raisetype",
175682
- /* 238 */ "ifexists",
175683
- /* 239 */ "fullname",
175684
- /* 240 */ "selectnowith",
175685
- /* 241 */ "oneselect",
175686
- /* 242 */ "wqlist",
175687
- /* 243 */ "multiselect_op",
175688
- /* 244 */ "distinct",
175689
- /* 245 */ "selcollist",
175690
- /* 246 */ "from",
175691
- /* 247 */ "where_opt",
175692
- /* 248 */ "groupby_opt",
175693
- /* 249 */ "having_opt",
175694
- /* 250 */ "orderby_opt",
175695
- /* 251 */ "limit_opt",
175696
- /* 252 */ "window_clause",
175697
- /* 253 */ "values",
175698
- /* 254 */ "nexprlist",
175699
- /* 255 */ "mvalues",
175700
- /* 256 */ "sclp",
175701
- /* 257 */ "as",
175702
- /* 258 */ "seltablist",
175703
- /* 259 */ "stl_prefix",
175704
- /* 260 */ "joinop",
175705
- /* 261 */ "on_using",
175706
- /* 262 */ "indexed_by",
175707
- /* 263 */ "exprlist",
175708
- /* 264 */ "xfullname",
175709
- /* 265 */ "idlist",
175710
- /* 266 */ "indexed_opt",
175711
- /* 267 */ "nulls",
175712
- /* 268 */ "with",
175713
- /* 269 */ "where_opt_ret",
175714
- /* 270 */ "setlist",
175715
- /* 271 */ "insert_cmd",
175716
- /* 272 */ "idlist_opt",
175717
- /* 273 */ "upsert",
175718
- /* 274 */ "returning",
175719
- /* 275 */ "filter_over",
175720
- /* 276 */ "likeop",
175721
- /* 277 */ "between_op",
175722
- /* 278 */ "in_op",
175723
- /* 279 */ "paren_exprlist",
175724
- /* 280 */ "case_operand",
175725
- /* 281 */ "case_exprlist",
175726
- /* 282 */ "case_else",
175727
- /* 283 */ "uniqueflag",
175728
- /* 284 */ "collate",
175729
- /* 285 */ "vinto",
175730
- /* 286 */ "nmnum",
175731
- /* 287 */ "trigger_decl",
175732
- /* 288 */ "trigger_cmd_list",
175733
- /* 289 */ "trigger_time",
175734
- /* 290 */ "trigger_event",
175735
- /* 291 */ "foreach_clause",
175736
- /* 292 */ "when_clause",
175737
- /* 293 */ "trigger_cmd",
175738
- /* 294 */ "trnm",
175739
- /* 295 */ "tridxby",
175740
- /* 296 */ "database_kw_opt",
175741
- /* 297 */ "key_opt",
175742
- /* 298 */ "add_column_fullname",
175743
- /* 299 */ "kwcolumn_opt",
175744
- /* 300 */ "create_vtab",
175745
- /* 301 */ "vtabarglist",
175746
- /* 302 */ "vtabarg",
175747
- /* 303 */ "vtabargtoken",
175748
- /* 304 */ "lp",
175749
- /* 305 */ "anylist",
175750
- /* 306 */ "wqitem",
175751
- /* 307 */ "wqas",
175752
- /* 308 */ "withnm",
175753
- /* 309 */ "windowdefn_list",
175754
- /* 310 */ "windowdefn",
175755
- /* 311 */ "window",
175756
- /* 312 */ "frame_opt",
175757
- /* 313 */ "part_opt",
175758
- /* 314 */ "filter_clause",
175759
- /* 315 */ "over_clause",
175760
- /* 316 */ "range_or_rows",
175761
- /* 317 */ "frame_bound",
175762
- /* 318 */ "frame_bound_s",
175763
- /* 319 */ "frame_bound_e",
175764
- /* 320 */ "frame_exclude_opt",
175765
- /* 321 */ "frame_exclude",
176014
+ /* 185 */ "COMMENT",
176015
+ /* 186 */ "ILLEGAL",
176016
+ /* 187 */ "input",
176017
+ /* 188 */ "cmdlist",
176018
+ /* 189 */ "ecmd",
176019
+ /* 190 */ "cmdx",
176020
+ /* 191 */ "explain",
176021
+ /* 192 */ "cmd",
176022
+ /* 193 */ "transtype",
176023
+ /* 194 */ "trans_opt",
176024
+ /* 195 */ "nm",
176025
+ /* 196 */ "savepoint_opt",
176026
+ /* 197 */ "create_table",
176027
+ /* 198 */ "create_table_args",
176028
+ /* 199 */ "createkw",
176029
+ /* 200 */ "temp",
176030
+ /* 201 */ "ifnotexists",
176031
+ /* 202 */ "dbnm",
176032
+ /* 203 */ "columnlist",
176033
+ /* 204 */ "conslist_opt",
176034
+ /* 205 */ "table_option_set",
176035
+ /* 206 */ "select",
176036
+ /* 207 */ "table_option",
176037
+ /* 208 */ "columnname",
176038
+ /* 209 */ "carglist",
176039
+ /* 210 */ "typetoken",
176040
+ /* 211 */ "typename",
176041
+ /* 212 */ "signed",
176042
+ /* 213 */ "plus_num",
176043
+ /* 214 */ "minus_num",
176044
+ /* 215 */ "scanpt",
176045
+ /* 216 */ "scantok",
176046
+ /* 217 */ "ccons",
176047
+ /* 218 */ "term",
176048
+ /* 219 */ "expr",
176049
+ /* 220 */ "onconf",
176050
+ /* 221 */ "sortorder",
176051
+ /* 222 */ "autoinc",
176052
+ /* 223 */ "eidlist_opt",
176053
+ /* 224 */ "refargs",
176054
+ /* 225 */ "defer_subclause",
176055
+ /* 226 */ "generated",
176056
+ /* 227 */ "refarg",
176057
+ /* 228 */ "refact",
176058
+ /* 229 */ "init_deferred_pred_opt",
176059
+ /* 230 */ "conslist",
176060
+ /* 231 */ "tconscomma",
176061
+ /* 232 */ "tcons",
176062
+ /* 233 */ "sortlist",
176063
+ /* 234 */ "eidlist",
176064
+ /* 235 */ "defer_subclause_opt",
176065
+ /* 236 */ "orconf",
176066
+ /* 237 */ "resolvetype",
176067
+ /* 238 */ "raisetype",
176068
+ /* 239 */ "ifexists",
176069
+ /* 240 */ "fullname",
176070
+ /* 241 */ "selectnowith",
176071
+ /* 242 */ "oneselect",
176072
+ /* 243 */ "wqlist",
176073
+ /* 244 */ "multiselect_op",
176074
+ /* 245 */ "distinct",
176075
+ /* 246 */ "selcollist",
176076
+ /* 247 */ "from",
176077
+ /* 248 */ "where_opt",
176078
+ /* 249 */ "groupby_opt",
176079
+ /* 250 */ "having_opt",
176080
+ /* 251 */ "orderby_opt",
176081
+ /* 252 */ "limit_opt",
176082
+ /* 253 */ "window_clause",
176083
+ /* 254 */ "values",
176084
+ /* 255 */ "nexprlist",
176085
+ /* 256 */ "mvalues",
176086
+ /* 257 */ "sclp",
176087
+ /* 258 */ "as",
176088
+ /* 259 */ "seltablist",
176089
+ /* 260 */ "stl_prefix",
176090
+ /* 261 */ "joinop",
176091
+ /* 262 */ "on_using",
176092
+ /* 263 */ "indexed_by",
176093
+ /* 264 */ "exprlist",
176094
+ /* 265 */ "xfullname",
176095
+ /* 266 */ "idlist",
176096
+ /* 267 */ "indexed_opt",
176097
+ /* 268 */ "nulls",
176098
+ /* 269 */ "with",
176099
+ /* 270 */ "where_opt_ret",
176100
+ /* 271 */ "setlist",
176101
+ /* 272 */ "insert_cmd",
176102
+ /* 273 */ "idlist_opt",
176103
+ /* 274 */ "upsert",
176104
+ /* 275 */ "returning",
176105
+ /* 276 */ "filter_over",
176106
+ /* 277 */ "likeop",
176107
+ /* 278 */ "between_op",
176108
+ /* 279 */ "in_op",
176109
+ /* 280 */ "paren_exprlist",
176110
+ /* 281 */ "case_operand",
176111
+ /* 282 */ "case_exprlist",
176112
+ /* 283 */ "case_else",
176113
+ /* 284 */ "uniqueflag",
176114
+ /* 285 */ "collate",
176115
+ /* 286 */ "vinto",
176116
+ /* 287 */ "nmnum",
176117
+ /* 288 */ "trigger_decl",
176118
+ /* 289 */ "trigger_cmd_list",
176119
+ /* 290 */ "trigger_time",
176120
+ /* 291 */ "trigger_event",
176121
+ /* 292 */ "foreach_clause",
176122
+ /* 293 */ "when_clause",
176123
+ /* 294 */ "trigger_cmd",
176124
+ /* 295 */ "trnm",
176125
+ /* 296 */ "tridxby",
176126
+ /* 297 */ "database_kw_opt",
176127
+ /* 298 */ "key_opt",
176128
+ /* 299 */ "add_column_fullname",
176129
+ /* 300 */ "kwcolumn_opt",
176130
+ /* 301 */ "create_vtab",
176131
+ /* 302 */ "vtabarglist",
176132
+ /* 303 */ "vtabarg",
176133
+ /* 304 */ "vtabargtoken",
176134
+ /* 305 */ "lp",
176135
+ /* 306 */ "anylist",
176136
+ /* 307 */ "wqitem",
176137
+ /* 308 */ "wqas",
176138
+ /* 309 */ "withnm",
176139
+ /* 310 */ "windowdefn_list",
176140
+ /* 311 */ "windowdefn",
176141
+ /* 312 */ "window",
176142
+ /* 313 */ "frame_opt",
176143
+ /* 314 */ "part_opt",
176144
+ /* 315 */ "filter_clause",
176145
+ /* 316 */ "over_clause",
176146
+ /* 317 */ "range_or_rows",
176147
+ /* 318 */ "frame_bound",
176148
+ /* 319 */ "frame_bound_s",
176149
+ /* 320 */ "frame_bound_e",
176150
+ /* 321 */ "frame_exclude_opt",
176151
+ /* 322 */ "frame_exclude",
175766176152
};
175767176153
#endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */
175768176154
175769176155
#ifndef NDEBUG
175770176156
/* For tracing reduce actions, the names of all rules are required.
@@ -176300,102 +176686,102 @@
176300176686
** Note: during a reduce, the only symbols destroyed are those
176301176687
** which appear on the RHS of the rule, but which are *not* used
176302176688
** inside the C code.
176303176689
*/
176304176690
/********* Begin destructor definitions ***************************************/
176305
- case 205: /* select */
176306
- case 240: /* selectnowith */
176307
- case 241: /* oneselect */
176308
- case 253: /* values */
176309
- case 255: /* mvalues */
176310
-{
176311
-sqlite3SelectDelete(pParse->db, (yypminor->yy555));
176312
-}
176313
- break;
176314
- case 217: /* term */
176315
- case 218: /* expr */
176316
- case 247: /* where_opt */
176317
- case 249: /* having_opt */
176318
- case 269: /* where_opt_ret */
176319
- case 280: /* case_operand */
176320
- case 282: /* case_else */
176321
- case 285: /* vinto */
176322
- case 292: /* when_clause */
176323
- case 297: /* key_opt */
176324
- case 314: /* filter_clause */
176325
-{
176326
-sqlite3ExprDelete(pParse->db, (yypminor->yy454));
176327
-}
176328
- break;
176329
- case 222: /* eidlist_opt */
176330
- case 232: /* sortlist */
176331
- case 233: /* eidlist */
176332
- case 245: /* selcollist */
176333
- case 248: /* groupby_opt */
176334
- case 250: /* orderby_opt */
176335
- case 254: /* nexprlist */
176336
- case 256: /* sclp */
176337
- case 263: /* exprlist */
176338
- case 270: /* setlist */
176339
- case 279: /* paren_exprlist */
176340
- case 281: /* case_exprlist */
176341
- case 313: /* part_opt */
176342
-{
176343
-sqlite3ExprListDelete(pParse->db, (yypminor->yy14));
176344
-}
176345
- break;
176346
- case 239: /* fullname */
176347
- case 246: /* from */
176348
- case 258: /* seltablist */
176349
- case 259: /* stl_prefix */
176350
- case 264: /* xfullname */
176351
-{
176352
-sqlite3SrcListDelete(pParse->db, (yypminor->yy203));
176353
-}
176354
- break;
176355
- case 242: /* wqlist */
176356
-{
176357
-sqlite3WithDelete(pParse->db, (yypminor->yy59));
176358
-}
176359
- break;
176360
- case 252: /* window_clause */
176361
- case 309: /* windowdefn_list */
176362
-{
176363
-sqlite3WindowListDelete(pParse->db, (yypminor->yy211));
176364
-}
176365
- break;
176366
- case 265: /* idlist */
176367
- case 272: /* idlist_opt */
176368
-{
176369
-sqlite3IdListDelete(pParse->db, (yypminor->yy132));
176370
-}
176371
- break;
176372
- case 275: /* filter_over */
176373
- case 310: /* windowdefn */
176374
- case 311: /* window */
176375
- case 312: /* frame_opt */
176376
- case 315: /* over_clause */
176377
-{
176378
-sqlite3WindowDelete(pParse->db, (yypminor->yy211));
176379
-}
176380
- break;
176381
- case 288: /* trigger_cmd_list */
176382
- case 293: /* trigger_cmd */
176383
-{
176384
-sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy427));
176385
-}
176386
- break;
176387
- case 290: /* trigger_event */
176388
-{
176389
-sqlite3IdListDelete(pParse->db, (yypminor->yy286).b);
176390
-}
176391
- break;
176392
- case 317: /* frame_bound */
176393
- case 318: /* frame_bound_s */
176394
- case 319: /* frame_bound_e */
176395
-{
176396
-sqlite3ExprDelete(pParse->db, (yypminor->yy509).pExpr);
176691
+ case 206: /* select */
176692
+ case 241: /* selectnowith */
176693
+ case 242: /* oneselect */
176694
+ case 254: /* values */
176695
+ case 256: /* mvalues */
176696
+{
176697
+sqlite3SelectDelete(pParse->db, (yypminor->yy637));
176698
+}
176699
+ break;
176700
+ case 218: /* term */
176701
+ case 219: /* expr */
176702
+ case 248: /* where_opt */
176703
+ case 250: /* having_opt */
176704
+ case 270: /* where_opt_ret */
176705
+ case 281: /* case_operand */
176706
+ case 283: /* case_else */
176707
+ case 286: /* vinto */
176708
+ case 293: /* when_clause */
176709
+ case 298: /* key_opt */
176710
+ case 315: /* filter_clause */
176711
+{
176712
+sqlite3ExprDelete(pParse->db, (yypminor->yy590));
176713
+}
176714
+ break;
176715
+ case 223: /* eidlist_opt */
176716
+ case 233: /* sortlist */
176717
+ case 234: /* eidlist */
176718
+ case 246: /* selcollist */
176719
+ case 249: /* groupby_opt */
176720
+ case 251: /* orderby_opt */
176721
+ case 255: /* nexprlist */
176722
+ case 257: /* sclp */
176723
+ case 264: /* exprlist */
176724
+ case 271: /* setlist */
176725
+ case 280: /* paren_exprlist */
176726
+ case 282: /* case_exprlist */
176727
+ case 314: /* part_opt */
176728
+{
176729
+sqlite3ExprListDelete(pParse->db, (yypminor->yy402));
176730
+}
176731
+ break;
176732
+ case 240: /* fullname */
176733
+ case 247: /* from */
176734
+ case 259: /* seltablist */
176735
+ case 260: /* stl_prefix */
176736
+ case 265: /* xfullname */
176737
+{
176738
+sqlite3SrcListDelete(pParse->db, (yypminor->yy563));
176739
+}
176740
+ break;
176741
+ case 243: /* wqlist */
176742
+{
176743
+sqlite3WithDelete(pParse->db, (yypminor->yy125));
176744
+}
176745
+ break;
176746
+ case 253: /* window_clause */
176747
+ case 310: /* windowdefn_list */
176748
+{
176749
+sqlite3WindowListDelete(pParse->db, (yypminor->yy483));
176750
+}
176751
+ break;
176752
+ case 266: /* idlist */
176753
+ case 273: /* idlist_opt */
176754
+{
176755
+sqlite3IdListDelete(pParse->db, (yypminor->yy204));
176756
+}
176757
+ break;
176758
+ case 276: /* filter_over */
176759
+ case 311: /* windowdefn */
176760
+ case 312: /* window */
176761
+ case 313: /* frame_opt */
176762
+ case 316: /* over_clause */
176763
+{
176764
+sqlite3WindowDelete(pParse->db, (yypminor->yy483));
176765
+}
176766
+ break;
176767
+ case 289: /* trigger_cmd_list */
176768
+ case 294: /* trigger_cmd */
176769
+{
176770
+sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy319));
176771
+}
176772
+ break;
176773
+ case 291: /* trigger_event */
176774
+{
176775
+sqlite3IdListDelete(pParse->db, (yypminor->yy28).b);
176776
+}
176777
+ break;
176778
+ case 318: /* frame_bound */
176779
+ case 319: /* frame_bound_s */
176780
+ case 320: /* frame_bound_e */
176781
+{
176782
+sqlite3ExprDelete(pParse->db, (yypminor->yy205).pExpr);
176397176783
}
176398176784
break;
176399176785
/********* End destructor definitions *****************************************/
176400176786
default: break; /* If no destructor action specified: do nothing */
176401176787
}
@@ -176693,419 +177079,419 @@
176693177079
}
176694177080
176695177081
/* For rule J, yyRuleInfoLhs[J] contains the symbol on the left-hand side
176696177082
** of that rule */
176697177083
static const YYCODETYPE yyRuleInfoLhs[] = {
176698
- 190, /* (0) explain ::= EXPLAIN */
176699
- 190, /* (1) explain ::= EXPLAIN QUERY PLAN */
176700
- 189, /* (2) cmdx ::= cmd */
176701
- 191, /* (3) cmd ::= BEGIN transtype trans_opt */
176702
- 192, /* (4) transtype ::= */
176703
- 192, /* (5) transtype ::= DEFERRED */
176704
- 192, /* (6) transtype ::= IMMEDIATE */
176705
- 192, /* (7) transtype ::= EXCLUSIVE */
176706
- 191, /* (8) cmd ::= COMMIT|END trans_opt */
176707
- 191, /* (9) cmd ::= ROLLBACK trans_opt */
176708
- 191, /* (10) cmd ::= SAVEPOINT nm */
176709
- 191, /* (11) cmd ::= RELEASE savepoint_opt nm */
176710
- 191, /* (12) cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */
176711
- 196, /* (13) create_table ::= createkw temp TABLE ifnotexists nm dbnm */
176712
- 198, /* (14) createkw ::= CREATE */
176713
- 200, /* (15) ifnotexists ::= */
176714
- 200, /* (16) ifnotexists ::= IF NOT EXISTS */
176715
- 199, /* (17) temp ::= TEMP */
176716
- 199, /* (18) temp ::= */
176717
- 197, /* (19) create_table_args ::= LP columnlist conslist_opt RP table_option_set */
176718
- 197, /* (20) create_table_args ::= AS select */
176719
- 204, /* (21) table_option_set ::= */
176720
- 204, /* (22) table_option_set ::= table_option_set COMMA table_option */
176721
- 206, /* (23) table_option ::= WITHOUT nm */
176722
- 206, /* (24) table_option ::= nm */
176723
- 207, /* (25) columnname ::= nm typetoken */
176724
- 209, /* (26) typetoken ::= */
176725
- 209, /* (27) typetoken ::= typename LP signed RP */
176726
- 209, /* (28) typetoken ::= typename LP signed COMMA signed RP */
176727
- 210, /* (29) typename ::= typename ID|STRING */
176728
- 214, /* (30) scanpt ::= */
176729
- 215, /* (31) scantok ::= */
176730
- 216, /* (32) ccons ::= CONSTRAINT nm */
176731
- 216, /* (33) ccons ::= DEFAULT scantok term */
176732
- 216, /* (34) ccons ::= DEFAULT LP expr RP */
176733
- 216, /* (35) ccons ::= DEFAULT PLUS scantok term */
176734
- 216, /* (36) ccons ::= DEFAULT MINUS scantok term */
176735
- 216, /* (37) ccons ::= DEFAULT scantok ID|INDEXED */
176736
- 216, /* (38) ccons ::= NOT NULL onconf */
176737
- 216, /* (39) ccons ::= PRIMARY KEY sortorder onconf autoinc */
176738
- 216, /* (40) ccons ::= UNIQUE onconf */
176739
- 216, /* (41) ccons ::= CHECK LP expr RP */
176740
- 216, /* (42) ccons ::= REFERENCES nm eidlist_opt refargs */
176741
- 216, /* (43) ccons ::= defer_subclause */
176742
- 216, /* (44) ccons ::= COLLATE ID|STRING */
176743
- 225, /* (45) generated ::= LP expr RP */
176744
- 225, /* (46) generated ::= LP expr RP ID */
176745
- 221, /* (47) autoinc ::= */
176746
- 221, /* (48) autoinc ::= AUTOINCR */
176747
- 223, /* (49) refargs ::= */
176748
- 223, /* (50) refargs ::= refargs refarg */
176749
- 226, /* (51) refarg ::= MATCH nm */
176750
- 226, /* (52) refarg ::= ON INSERT refact */
176751
- 226, /* (53) refarg ::= ON DELETE refact */
176752
- 226, /* (54) refarg ::= ON UPDATE refact */
176753
- 227, /* (55) refact ::= SET NULL */
176754
- 227, /* (56) refact ::= SET DEFAULT */
176755
- 227, /* (57) refact ::= CASCADE */
176756
- 227, /* (58) refact ::= RESTRICT */
176757
- 227, /* (59) refact ::= NO ACTION */
176758
- 224, /* (60) defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
176759
- 224, /* (61) defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
176760
- 228, /* (62) init_deferred_pred_opt ::= */
176761
- 228, /* (63) init_deferred_pred_opt ::= INITIALLY DEFERRED */
176762
- 228, /* (64) init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
176763
- 203, /* (65) conslist_opt ::= */
176764
- 230, /* (66) tconscomma ::= COMMA */
176765
- 231, /* (67) tcons ::= CONSTRAINT nm */
176766
- 231, /* (68) tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
176767
- 231, /* (69) tcons ::= UNIQUE LP sortlist RP onconf */
176768
- 231, /* (70) tcons ::= CHECK LP expr RP onconf */
176769
- 231, /* (71) tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
176770
- 234, /* (72) defer_subclause_opt ::= */
176771
- 219, /* (73) onconf ::= */
176772
- 219, /* (74) onconf ::= ON CONFLICT resolvetype */
176773
- 235, /* (75) orconf ::= */
176774
- 235, /* (76) orconf ::= OR resolvetype */
176775
- 236, /* (77) resolvetype ::= IGNORE */
176776
- 236, /* (78) resolvetype ::= REPLACE */
176777
- 191, /* (79) cmd ::= DROP TABLE ifexists fullname */
176778
- 238, /* (80) ifexists ::= IF EXISTS */
176779
- 238, /* (81) ifexists ::= */
176780
- 191, /* (82) cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
176781
- 191, /* (83) cmd ::= DROP VIEW ifexists fullname */
176782
- 191, /* (84) cmd ::= select */
176783
- 205, /* (85) select ::= WITH wqlist selectnowith */
176784
- 205, /* (86) select ::= WITH RECURSIVE wqlist selectnowith */
176785
- 205, /* (87) select ::= selectnowith */
176786
- 240, /* (88) selectnowith ::= selectnowith multiselect_op oneselect */
176787
- 243, /* (89) multiselect_op ::= UNION */
176788
- 243, /* (90) multiselect_op ::= UNION ALL */
176789
- 243, /* (91) multiselect_op ::= EXCEPT|INTERSECT */
176790
- 241, /* (92) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
176791
- 241, /* (93) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */
176792
- 253, /* (94) values ::= VALUES LP nexprlist RP */
176793
- 241, /* (95) oneselect ::= mvalues */
176794
- 255, /* (96) mvalues ::= values COMMA LP nexprlist RP */
176795
- 255, /* (97) mvalues ::= mvalues COMMA LP nexprlist RP */
176796
- 244, /* (98) distinct ::= DISTINCT */
176797
- 244, /* (99) distinct ::= ALL */
176798
- 244, /* (100) distinct ::= */
176799
- 256, /* (101) sclp ::= */
176800
- 245, /* (102) selcollist ::= sclp scanpt expr scanpt as */
176801
- 245, /* (103) selcollist ::= sclp scanpt STAR */
176802
- 245, /* (104) selcollist ::= sclp scanpt nm DOT STAR */
176803
- 257, /* (105) as ::= AS nm */
176804
- 257, /* (106) as ::= */
176805
- 246, /* (107) from ::= */
176806
- 246, /* (108) from ::= FROM seltablist */
176807
- 259, /* (109) stl_prefix ::= seltablist joinop */
176808
- 259, /* (110) stl_prefix ::= */
176809
- 258, /* (111) seltablist ::= stl_prefix nm dbnm as on_using */
176810
- 258, /* (112) seltablist ::= stl_prefix nm dbnm as indexed_by on_using */
176811
- 258, /* (113) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_using */
176812
- 258, /* (114) seltablist ::= stl_prefix LP select RP as on_using */
176813
- 258, /* (115) seltablist ::= stl_prefix LP seltablist RP as on_using */
176814
- 201, /* (116) dbnm ::= */
176815
- 201, /* (117) dbnm ::= DOT nm */
176816
- 239, /* (118) fullname ::= nm */
176817
- 239, /* (119) fullname ::= nm DOT nm */
176818
- 264, /* (120) xfullname ::= nm */
176819
- 264, /* (121) xfullname ::= nm DOT nm */
176820
- 264, /* (122) xfullname ::= nm DOT nm AS nm */
176821
- 264, /* (123) xfullname ::= nm AS nm */
176822
- 260, /* (124) joinop ::= COMMA|JOIN */
176823
- 260, /* (125) joinop ::= JOIN_KW JOIN */
176824
- 260, /* (126) joinop ::= JOIN_KW nm JOIN */
176825
- 260, /* (127) joinop ::= JOIN_KW nm nm JOIN */
176826
- 261, /* (128) on_using ::= ON expr */
176827
- 261, /* (129) on_using ::= USING LP idlist RP */
176828
- 261, /* (130) on_using ::= */
176829
- 266, /* (131) indexed_opt ::= */
176830
- 262, /* (132) indexed_by ::= INDEXED BY nm */
176831
- 262, /* (133) indexed_by ::= NOT INDEXED */
176832
- 250, /* (134) orderby_opt ::= */
176833
- 250, /* (135) orderby_opt ::= ORDER BY sortlist */
176834
- 232, /* (136) sortlist ::= sortlist COMMA expr sortorder nulls */
176835
- 232, /* (137) sortlist ::= expr sortorder nulls */
176836
- 220, /* (138) sortorder ::= ASC */
176837
- 220, /* (139) sortorder ::= DESC */
176838
- 220, /* (140) sortorder ::= */
176839
- 267, /* (141) nulls ::= NULLS FIRST */
176840
- 267, /* (142) nulls ::= NULLS LAST */
176841
- 267, /* (143) nulls ::= */
176842
- 248, /* (144) groupby_opt ::= */
176843
- 248, /* (145) groupby_opt ::= GROUP BY nexprlist */
176844
- 249, /* (146) having_opt ::= */
176845
- 249, /* (147) having_opt ::= HAVING expr */
176846
- 251, /* (148) limit_opt ::= */
176847
- 251, /* (149) limit_opt ::= LIMIT expr */
176848
- 251, /* (150) limit_opt ::= LIMIT expr OFFSET expr */
176849
- 251, /* (151) limit_opt ::= LIMIT expr COMMA expr */
176850
- 191, /* (152) cmd ::= with DELETE FROM xfullname indexed_opt where_opt_ret */
176851
- 247, /* (153) where_opt ::= */
176852
- 247, /* (154) where_opt ::= WHERE expr */
176853
- 269, /* (155) where_opt_ret ::= */
176854
- 269, /* (156) where_opt_ret ::= WHERE expr */
176855
- 269, /* (157) where_opt_ret ::= RETURNING selcollist */
176856
- 269, /* (158) where_opt_ret ::= WHERE expr RETURNING selcollist */
176857
- 191, /* (159) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist from where_opt_ret */
176858
- 270, /* (160) setlist ::= setlist COMMA nm EQ expr */
176859
- 270, /* (161) setlist ::= setlist COMMA LP idlist RP EQ expr */
176860
- 270, /* (162) setlist ::= nm EQ expr */
176861
- 270, /* (163) setlist ::= LP idlist RP EQ expr */
176862
- 191, /* (164) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
176863
- 191, /* (165) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES returning */
176864
- 273, /* (166) upsert ::= */
176865
- 273, /* (167) upsert ::= RETURNING selcollist */
176866
- 273, /* (168) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt upsert */
176867
- 273, /* (169) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING upsert */
176868
- 273, /* (170) upsert ::= ON CONFLICT DO NOTHING returning */
176869
- 273, /* (171) upsert ::= ON CONFLICT DO UPDATE SET setlist where_opt returning */
176870
- 274, /* (172) returning ::= RETURNING selcollist */
176871
- 271, /* (173) insert_cmd ::= INSERT orconf */
176872
- 271, /* (174) insert_cmd ::= REPLACE */
176873
- 272, /* (175) idlist_opt ::= */
176874
- 272, /* (176) idlist_opt ::= LP idlist RP */
176875
- 265, /* (177) idlist ::= idlist COMMA nm */
176876
- 265, /* (178) idlist ::= nm */
176877
- 218, /* (179) expr ::= LP expr RP */
176878
- 218, /* (180) expr ::= ID|INDEXED|JOIN_KW */
176879
- 218, /* (181) expr ::= nm DOT nm */
176880
- 218, /* (182) expr ::= nm DOT nm DOT nm */
176881
- 217, /* (183) term ::= NULL|FLOAT|BLOB */
176882
- 217, /* (184) term ::= STRING */
176883
- 217, /* (185) term ::= INTEGER */
176884
- 218, /* (186) expr ::= VARIABLE */
176885
- 218, /* (187) expr ::= expr COLLATE ID|STRING */
176886
- 218, /* (188) expr ::= CAST LP expr AS typetoken RP */
176887
- 218, /* (189) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP */
176888
- 218, /* (190) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP */
176889
- 218, /* (191) expr ::= ID|INDEXED|JOIN_KW LP STAR RP */
176890
- 218, /* (192) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP filter_over */
176891
- 218, /* (193) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP filter_over */
176892
- 218, /* (194) expr ::= ID|INDEXED|JOIN_KW LP STAR RP filter_over */
176893
- 217, /* (195) term ::= CTIME_KW */
176894
- 218, /* (196) expr ::= LP nexprlist COMMA expr RP */
176895
- 218, /* (197) expr ::= expr AND expr */
176896
- 218, /* (198) expr ::= expr OR expr */
176897
- 218, /* (199) expr ::= expr LT|GT|GE|LE expr */
176898
- 218, /* (200) expr ::= expr EQ|NE expr */
176899
- 218, /* (201) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */
176900
- 218, /* (202) expr ::= expr PLUS|MINUS expr */
176901
- 218, /* (203) expr ::= expr STAR|SLASH|REM expr */
176902
- 218, /* (204) expr ::= expr CONCAT expr */
176903
- 276, /* (205) likeop ::= NOT LIKE_KW|MATCH */
176904
- 218, /* (206) expr ::= expr likeop expr */
176905
- 218, /* (207) expr ::= expr likeop expr ESCAPE expr */
176906
- 218, /* (208) expr ::= expr ISNULL|NOTNULL */
176907
- 218, /* (209) expr ::= expr NOT NULL */
176908
- 218, /* (210) expr ::= expr IS expr */
176909
- 218, /* (211) expr ::= expr IS NOT expr */
176910
- 218, /* (212) expr ::= expr IS NOT DISTINCT FROM expr */
176911
- 218, /* (213) expr ::= expr IS DISTINCT FROM expr */
176912
- 218, /* (214) expr ::= NOT expr */
176913
- 218, /* (215) expr ::= BITNOT expr */
176914
- 218, /* (216) expr ::= PLUS|MINUS expr */
176915
- 218, /* (217) expr ::= expr PTR expr */
176916
- 277, /* (218) between_op ::= BETWEEN */
176917
- 277, /* (219) between_op ::= NOT BETWEEN */
176918
- 218, /* (220) expr ::= expr between_op expr AND expr */
176919
- 278, /* (221) in_op ::= IN */
176920
- 278, /* (222) in_op ::= NOT IN */
176921
- 218, /* (223) expr ::= expr in_op LP exprlist RP */
176922
- 218, /* (224) expr ::= LP select RP */
176923
- 218, /* (225) expr ::= expr in_op LP select RP */
176924
- 218, /* (226) expr ::= expr in_op nm dbnm paren_exprlist */
176925
- 218, /* (227) expr ::= EXISTS LP select RP */
176926
- 218, /* (228) expr ::= CASE case_operand case_exprlist case_else END */
176927
- 281, /* (229) case_exprlist ::= case_exprlist WHEN expr THEN expr */
176928
- 281, /* (230) case_exprlist ::= WHEN expr THEN expr */
176929
- 282, /* (231) case_else ::= ELSE expr */
176930
- 282, /* (232) case_else ::= */
176931
- 280, /* (233) case_operand ::= */
176932
- 263, /* (234) exprlist ::= */
176933
- 254, /* (235) nexprlist ::= nexprlist COMMA expr */
176934
- 254, /* (236) nexprlist ::= expr */
176935
- 279, /* (237) paren_exprlist ::= */
176936
- 279, /* (238) paren_exprlist ::= LP exprlist RP */
176937
- 191, /* (239) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
176938
- 283, /* (240) uniqueflag ::= UNIQUE */
176939
- 283, /* (241) uniqueflag ::= */
176940
- 222, /* (242) eidlist_opt ::= */
176941
- 222, /* (243) eidlist_opt ::= LP eidlist RP */
176942
- 233, /* (244) eidlist ::= eidlist COMMA nm collate sortorder */
176943
- 233, /* (245) eidlist ::= nm collate sortorder */
176944
- 284, /* (246) collate ::= */
176945
- 284, /* (247) collate ::= COLLATE ID|STRING */
176946
- 191, /* (248) cmd ::= DROP INDEX ifexists fullname */
176947
- 191, /* (249) cmd ::= VACUUM vinto */
176948
- 191, /* (250) cmd ::= VACUUM nm vinto */
176949
- 285, /* (251) vinto ::= INTO expr */
176950
- 285, /* (252) vinto ::= */
176951
- 191, /* (253) cmd ::= PRAGMA nm dbnm */
176952
- 191, /* (254) cmd ::= PRAGMA nm dbnm EQ nmnum */
176953
- 191, /* (255) cmd ::= PRAGMA nm dbnm LP nmnum RP */
176954
- 191, /* (256) cmd ::= PRAGMA nm dbnm EQ minus_num */
176955
- 191, /* (257) cmd ::= PRAGMA nm dbnm LP minus_num RP */
176956
- 212, /* (258) plus_num ::= PLUS INTEGER|FLOAT */
176957
- 213, /* (259) minus_num ::= MINUS INTEGER|FLOAT */
176958
- 191, /* (260) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
176959
- 287, /* (261) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
176960
- 289, /* (262) trigger_time ::= BEFORE|AFTER */
176961
- 289, /* (263) trigger_time ::= INSTEAD OF */
176962
- 289, /* (264) trigger_time ::= */
176963
- 290, /* (265) trigger_event ::= DELETE|INSERT */
176964
- 290, /* (266) trigger_event ::= UPDATE */
176965
- 290, /* (267) trigger_event ::= UPDATE OF idlist */
176966
- 292, /* (268) when_clause ::= */
176967
- 292, /* (269) when_clause ::= WHEN expr */
176968
- 288, /* (270) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
176969
- 288, /* (271) trigger_cmd_list ::= trigger_cmd SEMI */
176970
- 294, /* (272) trnm ::= nm DOT nm */
176971
- 295, /* (273) tridxby ::= INDEXED BY nm */
176972
- 295, /* (274) tridxby ::= NOT INDEXED */
176973
- 293, /* (275) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */
176974
- 293, /* (276) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
176975
- 293, /* (277) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
176976
- 293, /* (278) trigger_cmd ::= scanpt select scanpt */
176977
- 218, /* (279) expr ::= RAISE LP IGNORE RP */
176978
- 218, /* (280) expr ::= RAISE LP raisetype COMMA expr RP */
176979
- 237, /* (281) raisetype ::= ROLLBACK */
176980
- 237, /* (282) raisetype ::= ABORT */
176981
- 237, /* (283) raisetype ::= FAIL */
176982
- 191, /* (284) cmd ::= DROP TRIGGER ifexists fullname */
176983
- 191, /* (285) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
176984
- 191, /* (286) cmd ::= DETACH database_kw_opt expr */
176985
- 297, /* (287) key_opt ::= */
176986
- 297, /* (288) key_opt ::= KEY expr */
176987
- 191, /* (289) cmd ::= REINDEX */
176988
- 191, /* (290) cmd ::= REINDEX nm dbnm */
176989
- 191, /* (291) cmd ::= ANALYZE */
176990
- 191, /* (292) cmd ::= ANALYZE nm dbnm */
176991
- 191, /* (293) cmd ::= ALTER TABLE fullname RENAME TO nm */
176992
- 191, /* (294) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
176993
- 191, /* (295) cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */
176994
- 298, /* (296) add_column_fullname ::= fullname */
176995
- 191, /* (297) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
176996
- 191, /* (298) cmd ::= create_vtab */
176997
- 191, /* (299) cmd ::= create_vtab LP vtabarglist RP */
176998
- 300, /* (300) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
176999
- 302, /* (301) vtabarg ::= */
177000
- 303, /* (302) vtabargtoken ::= ANY */
177001
- 303, /* (303) vtabargtoken ::= lp anylist RP */
177002
- 304, /* (304) lp ::= LP */
177003
- 268, /* (305) with ::= WITH wqlist */
177004
- 268, /* (306) with ::= WITH RECURSIVE wqlist */
177005
- 307, /* (307) wqas ::= AS */
177006
- 307, /* (308) wqas ::= AS MATERIALIZED */
177007
- 307, /* (309) wqas ::= AS NOT MATERIALIZED */
177008
- 306, /* (310) wqitem ::= withnm eidlist_opt wqas LP select RP */
177009
- 308, /* (311) withnm ::= nm */
177010
- 242, /* (312) wqlist ::= wqitem */
177011
- 242, /* (313) wqlist ::= wqlist COMMA wqitem */
177012
- 309, /* (314) windowdefn_list ::= windowdefn_list COMMA windowdefn */
177013
- 310, /* (315) windowdefn ::= nm AS LP window RP */
177014
- 311, /* (316) window ::= PARTITION BY nexprlist orderby_opt frame_opt */
177015
- 311, /* (317) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
177016
- 311, /* (318) window ::= ORDER BY sortlist frame_opt */
177017
- 311, /* (319) window ::= nm ORDER BY sortlist frame_opt */
177018
- 311, /* (320) window ::= nm frame_opt */
177019
- 312, /* (321) frame_opt ::= */
177020
- 312, /* (322) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */
177021
- 312, /* (323) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */
177022
- 316, /* (324) range_or_rows ::= RANGE|ROWS|GROUPS */
177023
- 318, /* (325) frame_bound_s ::= frame_bound */
177024
- 318, /* (326) frame_bound_s ::= UNBOUNDED PRECEDING */
177025
- 319, /* (327) frame_bound_e ::= frame_bound */
177026
- 319, /* (328) frame_bound_e ::= UNBOUNDED FOLLOWING */
177027
- 317, /* (329) frame_bound ::= expr PRECEDING|FOLLOWING */
177028
- 317, /* (330) frame_bound ::= CURRENT ROW */
177029
- 320, /* (331) frame_exclude_opt ::= */
177030
- 320, /* (332) frame_exclude_opt ::= EXCLUDE frame_exclude */
177031
- 321, /* (333) frame_exclude ::= NO OTHERS */
177032
- 321, /* (334) frame_exclude ::= CURRENT ROW */
177033
- 321, /* (335) frame_exclude ::= GROUP|TIES */
177034
- 252, /* (336) window_clause ::= WINDOW windowdefn_list */
177035
- 275, /* (337) filter_over ::= filter_clause over_clause */
177036
- 275, /* (338) filter_over ::= over_clause */
177037
- 275, /* (339) filter_over ::= filter_clause */
177038
- 315, /* (340) over_clause ::= OVER LP window RP */
177039
- 315, /* (341) over_clause ::= OVER nm */
177040
- 314, /* (342) filter_clause ::= FILTER LP WHERE expr RP */
177041
- 217, /* (343) term ::= QNUMBER */
177042
- 186, /* (344) input ::= cmdlist */
177043
- 187, /* (345) cmdlist ::= cmdlist ecmd */
177044
- 187, /* (346) cmdlist ::= ecmd */
177045
- 188, /* (347) ecmd ::= SEMI */
177046
- 188, /* (348) ecmd ::= cmdx SEMI */
177047
- 188, /* (349) ecmd ::= explain cmdx SEMI */
177048
- 193, /* (350) trans_opt ::= */
177049
- 193, /* (351) trans_opt ::= TRANSACTION */
177050
- 193, /* (352) trans_opt ::= TRANSACTION nm */
177051
- 195, /* (353) savepoint_opt ::= SAVEPOINT */
177052
- 195, /* (354) savepoint_opt ::= */
177053
- 191, /* (355) cmd ::= create_table create_table_args */
177054
- 204, /* (356) table_option_set ::= table_option */
177055
- 202, /* (357) columnlist ::= columnlist COMMA columnname carglist */
177056
- 202, /* (358) columnlist ::= columnname carglist */
177057
- 194, /* (359) nm ::= ID|INDEXED|JOIN_KW */
177058
- 194, /* (360) nm ::= STRING */
177059
- 209, /* (361) typetoken ::= typename */
177060
- 210, /* (362) typename ::= ID|STRING */
177061
- 211, /* (363) signed ::= plus_num */
177062
- 211, /* (364) signed ::= minus_num */
177063
- 208, /* (365) carglist ::= carglist ccons */
177064
- 208, /* (366) carglist ::= */
177065
- 216, /* (367) ccons ::= NULL onconf */
177066
- 216, /* (368) ccons ::= GENERATED ALWAYS AS generated */
177067
- 216, /* (369) ccons ::= AS generated */
177068
- 203, /* (370) conslist_opt ::= COMMA conslist */
177069
- 229, /* (371) conslist ::= conslist tconscomma tcons */
177070
- 229, /* (372) conslist ::= tcons */
177071
- 230, /* (373) tconscomma ::= */
177072
- 234, /* (374) defer_subclause_opt ::= defer_subclause */
177073
- 236, /* (375) resolvetype ::= raisetype */
177074
- 240, /* (376) selectnowith ::= oneselect */
177075
- 241, /* (377) oneselect ::= values */
177076
- 256, /* (378) sclp ::= selcollist COMMA */
177077
- 257, /* (379) as ::= ID|STRING */
177078
- 266, /* (380) indexed_opt ::= indexed_by */
177079
- 274, /* (381) returning ::= */
177080
- 218, /* (382) expr ::= term */
177081
- 276, /* (383) likeop ::= LIKE_KW|MATCH */
177082
- 280, /* (384) case_operand ::= expr */
177083
- 263, /* (385) exprlist ::= nexprlist */
177084
- 286, /* (386) nmnum ::= plus_num */
177085
- 286, /* (387) nmnum ::= nm */
177086
- 286, /* (388) nmnum ::= ON */
177087
- 286, /* (389) nmnum ::= DELETE */
177088
- 286, /* (390) nmnum ::= DEFAULT */
177089
- 212, /* (391) plus_num ::= INTEGER|FLOAT */
177090
- 291, /* (392) foreach_clause ::= */
177091
- 291, /* (393) foreach_clause ::= FOR EACH ROW */
177092
- 294, /* (394) trnm ::= nm */
177093
- 295, /* (395) tridxby ::= */
177094
- 296, /* (396) database_kw_opt ::= DATABASE */
177095
- 296, /* (397) database_kw_opt ::= */
177096
- 299, /* (398) kwcolumn_opt ::= */
177097
- 299, /* (399) kwcolumn_opt ::= COLUMNKW */
177098
- 301, /* (400) vtabarglist ::= vtabarg */
177099
- 301, /* (401) vtabarglist ::= vtabarglist COMMA vtabarg */
177100
- 302, /* (402) vtabarg ::= vtabarg vtabargtoken */
177101
- 305, /* (403) anylist ::= */
177102
- 305, /* (404) anylist ::= anylist LP anylist RP */
177103
- 305, /* (405) anylist ::= anylist ANY */
177104
- 268, /* (406) with ::= */
177105
- 309, /* (407) windowdefn_list ::= windowdefn */
177106
- 311, /* (408) window ::= frame_opt */
177084
+ 191, /* (0) explain ::= EXPLAIN */
177085
+ 191, /* (1) explain ::= EXPLAIN QUERY PLAN */
177086
+ 190, /* (2) cmdx ::= cmd */
177087
+ 192, /* (3) cmd ::= BEGIN transtype trans_opt */
177088
+ 193, /* (4) transtype ::= */
177089
+ 193, /* (5) transtype ::= DEFERRED */
177090
+ 193, /* (6) transtype ::= IMMEDIATE */
177091
+ 193, /* (7) transtype ::= EXCLUSIVE */
177092
+ 192, /* (8) cmd ::= COMMIT|END trans_opt */
177093
+ 192, /* (9) cmd ::= ROLLBACK trans_opt */
177094
+ 192, /* (10) cmd ::= SAVEPOINT nm */
177095
+ 192, /* (11) cmd ::= RELEASE savepoint_opt nm */
177096
+ 192, /* (12) cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */
177097
+ 197, /* (13) create_table ::= createkw temp TABLE ifnotexists nm dbnm */
177098
+ 199, /* (14) createkw ::= CREATE */
177099
+ 201, /* (15) ifnotexists ::= */
177100
+ 201, /* (16) ifnotexists ::= IF NOT EXISTS */
177101
+ 200, /* (17) temp ::= TEMP */
177102
+ 200, /* (18) temp ::= */
177103
+ 198, /* (19) create_table_args ::= LP columnlist conslist_opt RP table_option_set */
177104
+ 198, /* (20) create_table_args ::= AS select */
177105
+ 205, /* (21) table_option_set ::= */
177106
+ 205, /* (22) table_option_set ::= table_option_set COMMA table_option */
177107
+ 207, /* (23) table_option ::= WITHOUT nm */
177108
+ 207, /* (24) table_option ::= nm */
177109
+ 208, /* (25) columnname ::= nm typetoken */
177110
+ 210, /* (26) typetoken ::= */
177111
+ 210, /* (27) typetoken ::= typename LP signed RP */
177112
+ 210, /* (28) typetoken ::= typename LP signed COMMA signed RP */
177113
+ 211, /* (29) typename ::= typename ID|STRING */
177114
+ 215, /* (30) scanpt ::= */
177115
+ 216, /* (31) scantok ::= */
177116
+ 217, /* (32) ccons ::= CONSTRAINT nm */
177117
+ 217, /* (33) ccons ::= DEFAULT scantok term */
177118
+ 217, /* (34) ccons ::= DEFAULT LP expr RP */
177119
+ 217, /* (35) ccons ::= DEFAULT PLUS scantok term */
177120
+ 217, /* (36) ccons ::= DEFAULT MINUS scantok term */
177121
+ 217, /* (37) ccons ::= DEFAULT scantok ID|INDEXED */
177122
+ 217, /* (38) ccons ::= NOT NULL onconf */
177123
+ 217, /* (39) ccons ::= PRIMARY KEY sortorder onconf autoinc */
177124
+ 217, /* (40) ccons ::= UNIQUE onconf */
177125
+ 217, /* (41) ccons ::= CHECK LP expr RP */
177126
+ 217, /* (42) ccons ::= REFERENCES nm eidlist_opt refargs */
177127
+ 217, /* (43) ccons ::= defer_subclause */
177128
+ 217, /* (44) ccons ::= COLLATE ID|STRING */
177129
+ 226, /* (45) generated ::= LP expr RP */
177130
+ 226, /* (46) generated ::= LP expr RP ID */
177131
+ 222, /* (47) autoinc ::= */
177132
+ 222, /* (48) autoinc ::= AUTOINCR */
177133
+ 224, /* (49) refargs ::= */
177134
+ 224, /* (50) refargs ::= refargs refarg */
177135
+ 227, /* (51) refarg ::= MATCH nm */
177136
+ 227, /* (52) refarg ::= ON INSERT refact */
177137
+ 227, /* (53) refarg ::= ON DELETE refact */
177138
+ 227, /* (54) refarg ::= ON UPDATE refact */
177139
+ 228, /* (55) refact ::= SET NULL */
177140
+ 228, /* (56) refact ::= SET DEFAULT */
177141
+ 228, /* (57) refact ::= CASCADE */
177142
+ 228, /* (58) refact ::= RESTRICT */
177143
+ 228, /* (59) refact ::= NO ACTION */
177144
+ 225, /* (60) defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
177145
+ 225, /* (61) defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
177146
+ 229, /* (62) init_deferred_pred_opt ::= */
177147
+ 229, /* (63) init_deferred_pred_opt ::= INITIALLY DEFERRED */
177148
+ 229, /* (64) init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
177149
+ 204, /* (65) conslist_opt ::= */
177150
+ 231, /* (66) tconscomma ::= COMMA */
177151
+ 232, /* (67) tcons ::= CONSTRAINT nm */
177152
+ 232, /* (68) tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
177153
+ 232, /* (69) tcons ::= UNIQUE LP sortlist RP onconf */
177154
+ 232, /* (70) tcons ::= CHECK LP expr RP onconf */
177155
+ 232, /* (71) tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
177156
+ 235, /* (72) defer_subclause_opt ::= */
177157
+ 220, /* (73) onconf ::= */
177158
+ 220, /* (74) onconf ::= ON CONFLICT resolvetype */
177159
+ 236, /* (75) orconf ::= */
177160
+ 236, /* (76) orconf ::= OR resolvetype */
177161
+ 237, /* (77) resolvetype ::= IGNORE */
177162
+ 237, /* (78) resolvetype ::= REPLACE */
177163
+ 192, /* (79) cmd ::= DROP TABLE ifexists fullname */
177164
+ 239, /* (80) ifexists ::= IF EXISTS */
177165
+ 239, /* (81) ifexists ::= */
177166
+ 192, /* (82) cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
177167
+ 192, /* (83) cmd ::= DROP VIEW ifexists fullname */
177168
+ 192, /* (84) cmd ::= select */
177169
+ 206, /* (85) select ::= WITH wqlist selectnowith */
177170
+ 206, /* (86) select ::= WITH RECURSIVE wqlist selectnowith */
177171
+ 206, /* (87) select ::= selectnowith */
177172
+ 241, /* (88) selectnowith ::= selectnowith multiselect_op oneselect */
177173
+ 244, /* (89) multiselect_op ::= UNION */
177174
+ 244, /* (90) multiselect_op ::= UNION ALL */
177175
+ 244, /* (91) multiselect_op ::= EXCEPT|INTERSECT */
177176
+ 242, /* (92) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
177177
+ 242, /* (93) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */
177178
+ 254, /* (94) values ::= VALUES LP nexprlist RP */
177179
+ 242, /* (95) oneselect ::= mvalues */
177180
+ 256, /* (96) mvalues ::= values COMMA LP nexprlist RP */
177181
+ 256, /* (97) mvalues ::= mvalues COMMA LP nexprlist RP */
177182
+ 245, /* (98) distinct ::= DISTINCT */
177183
+ 245, /* (99) distinct ::= ALL */
177184
+ 245, /* (100) distinct ::= */
177185
+ 257, /* (101) sclp ::= */
177186
+ 246, /* (102) selcollist ::= sclp scanpt expr scanpt as */
177187
+ 246, /* (103) selcollist ::= sclp scanpt STAR */
177188
+ 246, /* (104) selcollist ::= sclp scanpt nm DOT STAR */
177189
+ 258, /* (105) as ::= AS nm */
177190
+ 258, /* (106) as ::= */
177191
+ 247, /* (107) from ::= */
177192
+ 247, /* (108) from ::= FROM seltablist */
177193
+ 260, /* (109) stl_prefix ::= seltablist joinop */
177194
+ 260, /* (110) stl_prefix ::= */
177195
+ 259, /* (111) seltablist ::= stl_prefix nm dbnm as on_using */
177196
+ 259, /* (112) seltablist ::= stl_prefix nm dbnm as indexed_by on_using */
177197
+ 259, /* (113) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_using */
177198
+ 259, /* (114) seltablist ::= stl_prefix LP select RP as on_using */
177199
+ 259, /* (115) seltablist ::= stl_prefix LP seltablist RP as on_using */
177200
+ 202, /* (116) dbnm ::= */
177201
+ 202, /* (117) dbnm ::= DOT nm */
177202
+ 240, /* (118) fullname ::= nm */
177203
+ 240, /* (119) fullname ::= nm DOT nm */
177204
+ 265, /* (120) xfullname ::= nm */
177205
+ 265, /* (121) xfullname ::= nm DOT nm */
177206
+ 265, /* (122) xfullname ::= nm DOT nm AS nm */
177207
+ 265, /* (123) xfullname ::= nm AS nm */
177208
+ 261, /* (124) joinop ::= COMMA|JOIN */
177209
+ 261, /* (125) joinop ::= JOIN_KW JOIN */
177210
+ 261, /* (126) joinop ::= JOIN_KW nm JOIN */
177211
+ 261, /* (127) joinop ::= JOIN_KW nm nm JOIN */
177212
+ 262, /* (128) on_using ::= ON expr */
177213
+ 262, /* (129) on_using ::= USING LP idlist RP */
177214
+ 262, /* (130) on_using ::= */
177215
+ 267, /* (131) indexed_opt ::= */
177216
+ 263, /* (132) indexed_by ::= INDEXED BY nm */
177217
+ 263, /* (133) indexed_by ::= NOT INDEXED */
177218
+ 251, /* (134) orderby_opt ::= */
177219
+ 251, /* (135) orderby_opt ::= ORDER BY sortlist */
177220
+ 233, /* (136) sortlist ::= sortlist COMMA expr sortorder nulls */
177221
+ 233, /* (137) sortlist ::= expr sortorder nulls */
177222
+ 221, /* (138) sortorder ::= ASC */
177223
+ 221, /* (139) sortorder ::= DESC */
177224
+ 221, /* (140) sortorder ::= */
177225
+ 268, /* (141) nulls ::= NULLS FIRST */
177226
+ 268, /* (142) nulls ::= NULLS LAST */
177227
+ 268, /* (143) nulls ::= */
177228
+ 249, /* (144) groupby_opt ::= */
177229
+ 249, /* (145) groupby_opt ::= GROUP BY nexprlist */
177230
+ 250, /* (146) having_opt ::= */
177231
+ 250, /* (147) having_opt ::= HAVING expr */
177232
+ 252, /* (148) limit_opt ::= */
177233
+ 252, /* (149) limit_opt ::= LIMIT expr */
177234
+ 252, /* (150) limit_opt ::= LIMIT expr OFFSET expr */
177235
+ 252, /* (151) limit_opt ::= LIMIT expr COMMA expr */
177236
+ 192, /* (152) cmd ::= with DELETE FROM xfullname indexed_opt where_opt_ret */
177237
+ 248, /* (153) where_opt ::= */
177238
+ 248, /* (154) where_opt ::= WHERE expr */
177239
+ 270, /* (155) where_opt_ret ::= */
177240
+ 270, /* (156) where_opt_ret ::= WHERE expr */
177241
+ 270, /* (157) where_opt_ret ::= RETURNING selcollist */
177242
+ 270, /* (158) where_opt_ret ::= WHERE expr RETURNING selcollist */
177243
+ 192, /* (159) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist from where_opt_ret */
177244
+ 271, /* (160) setlist ::= setlist COMMA nm EQ expr */
177245
+ 271, /* (161) setlist ::= setlist COMMA LP idlist RP EQ expr */
177246
+ 271, /* (162) setlist ::= nm EQ expr */
177247
+ 271, /* (163) setlist ::= LP idlist RP EQ expr */
177248
+ 192, /* (164) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
177249
+ 192, /* (165) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES returning */
177250
+ 274, /* (166) upsert ::= */
177251
+ 274, /* (167) upsert ::= RETURNING selcollist */
177252
+ 274, /* (168) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt upsert */
177253
+ 274, /* (169) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING upsert */
177254
+ 274, /* (170) upsert ::= ON CONFLICT DO NOTHING returning */
177255
+ 274, /* (171) upsert ::= ON CONFLICT DO UPDATE SET setlist where_opt returning */
177256
+ 275, /* (172) returning ::= RETURNING selcollist */
177257
+ 272, /* (173) insert_cmd ::= INSERT orconf */
177258
+ 272, /* (174) insert_cmd ::= REPLACE */
177259
+ 273, /* (175) idlist_opt ::= */
177260
+ 273, /* (176) idlist_opt ::= LP idlist RP */
177261
+ 266, /* (177) idlist ::= idlist COMMA nm */
177262
+ 266, /* (178) idlist ::= nm */
177263
+ 219, /* (179) expr ::= LP expr RP */
177264
+ 219, /* (180) expr ::= ID|INDEXED|JOIN_KW */
177265
+ 219, /* (181) expr ::= nm DOT nm */
177266
+ 219, /* (182) expr ::= nm DOT nm DOT nm */
177267
+ 218, /* (183) term ::= NULL|FLOAT|BLOB */
177268
+ 218, /* (184) term ::= STRING */
177269
+ 218, /* (185) term ::= INTEGER */
177270
+ 219, /* (186) expr ::= VARIABLE */
177271
+ 219, /* (187) expr ::= expr COLLATE ID|STRING */
177272
+ 219, /* (188) expr ::= CAST LP expr AS typetoken RP */
177273
+ 219, /* (189) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP */
177274
+ 219, /* (190) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP */
177275
+ 219, /* (191) expr ::= ID|INDEXED|JOIN_KW LP STAR RP */
177276
+ 219, /* (192) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP filter_over */
177277
+ 219, /* (193) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP filter_over */
177278
+ 219, /* (194) expr ::= ID|INDEXED|JOIN_KW LP STAR RP filter_over */
177279
+ 218, /* (195) term ::= CTIME_KW */
177280
+ 219, /* (196) expr ::= LP nexprlist COMMA expr RP */
177281
+ 219, /* (197) expr ::= expr AND expr */
177282
+ 219, /* (198) expr ::= expr OR expr */
177283
+ 219, /* (199) expr ::= expr LT|GT|GE|LE expr */
177284
+ 219, /* (200) expr ::= expr EQ|NE expr */
177285
+ 219, /* (201) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */
177286
+ 219, /* (202) expr ::= expr PLUS|MINUS expr */
177287
+ 219, /* (203) expr ::= expr STAR|SLASH|REM expr */
177288
+ 219, /* (204) expr ::= expr CONCAT expr */
177289
+ 277, /* (205) likeop ::= NOT LIKE_KW|MATCH */
177290
+ 219, /* (206) expr ::= expr likeop expr */
177291
+ 219, /* (207) expr ::= expr likeop expr ESCAPE expr */
177292
+ 219, /* (208) expr ::= expr ISNULL|NOTNULL */
177293
+ 219, /* (209) expr ::= expr NOT NULL */
177294
+ 219, /* (210) expr ::= expr IS expr */
177295
+ 219, /* (211) expr ::= expr IS NOT expr */
177296
+ 219, /* (212) expr ::= expr IS NOT DISTINCT FROM expr */
177297
+ 219, /* (213) expr ::= expr IS DISTINCT FROM expr */
177298
+ 219, /* (214) expr ::= NOT expr */
177299
+ 219, /* (215) expr ::= BITNOT expr */
177300
+ 219, /* (216) expr ::= PLUS|MINUS expr */
177301
+ 219, /* (217) expr ::= expr PTR expr */
177302
+ 278, /* (218) between_op ::= BETWEEN */
177303
+ 278, /* (219) between_op ::= NOT BETWEEN */
177304
+ 219, /* (220) expr ::= expr between_op expr AND expr */
177305
+ 279, /* (221) in_op ::= IN */
177306
+ 279, /* (222) in_op ::= NOT IN */
177307
+ 219, /* (223) expr ::= expr in_op LP exprlist RP */
177308
+ 219, /* (224) expr ::= LP select RP */
177309
+ 219, /* (225) expr ::= expr in_op LP select RP */
177310
+ 219, /* (226) expr ::= expr in_op nm dbnm paren_exprlist */
177311
+ 219, /* (227) expr ::= EXISTS LP select RP */
177312
+ 219, /* (228) expr ::= CASE case_operand case_exprlist case_else END */
177313
+ 282, /* (229) case_exprlist ::= case_exprlist WHEN expr THEN expr */
177314
+ 282, /* (230) case_exprlist ::= WHEN expr THEN expr */
177315
+ 283, /* (231) case_else ::= ELSE expr */
177316
+ 283, /* (232) case_else ::= */
177317
+ 281, /* (233) case_operand ::= */
177318
+ 264, /* (234) exprlist ::= */
177319
+ 255, /* (235) nexprlist ::= nexprlist COMMA expr */
177320
+ 255, /* (236) nexprlist ::= expr */
177321
+ 280, /* (237) paren_exprlist ::= */
177322
+ 280, /* (238) paren_exprlist ::= LP exprlist RP */
177323
+ 192, /* (239) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
177324
+ 284, /* (240) uniqueflag ::= UNIQUE */
177325
+ 284, /* (241) uniqueflag ::= */
177326
+ 223, /* (242) eidlist_opt ::= */
177327
+ 223, /* (243) eidlist_opt ::= LP eidlist RP */
177328
+ 234, /* (244) eidlist ::= eidlist COMMA nm collate sortorder */
177329
+ 234, /* (245) eidlist ::= nm collate sortorder */
177330
+ 285, /* (246) collate ::= */
177331
+ 285, /* (247) collate ::= COLLATE ID|STRING */
177332
+ 192, /* (248) cmd ::= DROP INDEX ifexists fullname */
177333
+ 192, /* (249) cmd ::= VACUUM vinto */
177334
+ 192, /* (250) cmd ::= VACUUM nm vinto */
177335
+ 286, /* (251) vinto ::= INTO expr */
177336
+ 286, /* (252) vinto ::= */
177337
+ 192, /* (253) cmd ::= PRAGMA nm dbnm */
177338
+ 192, /* (254) cmd ::= PRAGMA nm dbnm EQ nmnum */
177339
+ 192, /* (255) cmd ::= PRAGMA nm dbnm LP nmnum RP */
177340
+ 192, /* (256) cmd ::= PRAGMA nm dbnm EQ minus_num */
177341
+ 192, /* (257) cmd ::= PRAGMA nm dbnm LP minus_num RP */
177342
+ 213, /* (258) plus_num ::= PLUS INTEGER|FLOAT */
177343
+ 214, /* (259) minus_num ::= MINUS INTEGER|FLOAT */
177344
+ 192, /* (260) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
177345
+ 288, /* (261) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
177346
+ 290, /* (262) trigger_time ::= BEFORE|AFTER */
177347
+ 290, /* (263) trigger_time ::= INSTEAD OF */
177348
+ 290, /* (264) trigger_time ::= */
177349
+ 291, /* (265) trigger_event ::= DELETE|INSERT */
177350
+ 291, /* (266) trigger_event ::= UPDATE */
177351
+ 291, /* (267) trigger_event ::= UPDATE OF idlist */
177352
+ 293, /* (268) when_clause ::= */
177353
+ 293, /* (269) when_clause ::= WHEN expr */
177354
+ 289, /* (270) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
177355
+ 289, /* (271) trigger_cmd_list ::= trigger_cmd SEMI */
177356
+ 295, /* (272) trnm ::= nm DOT nm */
177357
+ 296, /* (273) tridxby ::= INDEXED BY nm */
177358
+ 296, /* (274) tridxby ::= NOT INDEXED */
177359
+ 294, /* (275) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */
177360
+ 294, /* (276) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
177361
+ 294, /* (277) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
177362
+ 294, /* (278) trigger_cmd ::= scanpt select scanpt */
177363
+ 219, /* (279) expr ::= RAISE LP IGNORE RP */
177364
+ 219, /* (280) expr ::= RAISE LP raisetype COMMA expr RP */
177365
+ 238, /* (281) raisetype ::= ROLLBACK */
177366
+ 238, /* (282) raisetype ::= ABORT */
177367
+ 238, /* (283) raisetype ::= FAIL */
177368
+ 192, /* (284) cmd ::= DROP TRIGGER ifexists fullname */
177369
+ 192, /* (285) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
177370
+ 192, /* (286) cmd ::= DETACH database_kw_opt expr */
177371
+ 298, /* (287) key_opt ::= */
177372
+ 298, /* (288) key_opt ::= KEY expr */
177373
+ 192, /* (289) cmd ::= REINDEX */
177374
+ 192, /* (290) cmd ::= REINDEX nm dbnm */
177375
+ 192, /* (291) cmd ::= ANALYZE */
177376
+ 192, /* (292) cmd ::= ANALYZE nm dbnm */
177377
+ 192, /* (293) cmd ::= ALTER TABLE fullname RENAME TO nm */
177378
+ 192, /* (294) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
177379
+ 192, /* (295) cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */
177380
+ 299, /* (296) add_column_fullname ::= fullname */
177381
+ 192, /* (297) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
177382
+ 192, /* (298) cmd ::= create_vtab */
177383
+ 192, /* (299) cmd ::= create_vtab LP vtabarglist RP */
177384
+ 301, /* (300) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
177385
+ 303, /* (301) vtabarg ::= */
177386
+ 304, /* (302) vtabargtoken ::= ANY */
177387
+ 304, /* (303) vtabargtoken ::= lp anylist RP */
177388
+ 305, /* (304) lp ::= LP */
177389
+ 269, /* (305) with ::= WITH wqlist */
177390
+ 269, /* (306) with ::= WITH RECURSIVE wqlist */
177391
+ 308, /* (307) wqas ::= AS */
177392
+ 308, /* (308) wqas ::= AS MATERIALIZED */
177393
+ 308, /* (309) wqas ::= AS NOT MATERIALIZED */
177394
+ 307, /* (310) wqitem ::= withnm eidlist_opt wqas LP select RP */
177395
+ 309, /* (311) withnm ::= nm */
177396
+ 243, /* (312) wqlist ::= wqitem */
177397
+ 243, /* (313) wqlist ::= wqlist COMMA wqitem */
177398
+ 310, /* (314) windowdefn_list ::= windowdefn_list COMMA windowdefn */
177399
+ 311, /* (315) windowdefn ::= nm AS LP window RP */
177400
+ 312, /* (316) window ::= PARTITION BY nexprlist orderby_opt frame_opt */
177401
+ 312, /* (317) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
177402
+ 312, /* (318) window ::= ORDER BY sortlist frame_opt */
177403
+ 312, /* (319) window ::= nm ORDER BY sortlist frame_opt */
177404
+ 312, /* (320) window ::= nm frame_opt */
177405
+ 313, /* (321) frame_opt ::= */
177406
+ 313, /* (322) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */
177407
+ 313, /* (323) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */
177408
+ 317, /* (324) range_or_rows ::= RANGE|ROWS|GROUPS */
177409
+ 319, /* (325) frame_bound_s ::= frame_bound */
177410
+ 319, /* (326) frame_bound_s ::= UNBOUNDED PRECEDING */
177411
+ 320, /* (327) frame_bound_e ::= frame_bound */
177412
+ 320, /* (328) frame_bound_e ::= UNBOUNDED FOLLOWING */
177413
+ 318, /* (329) frame_bound ::= expr PRECEDING|FOLLOWING */
177414
+ 318, /* (330) frame_bound ::= CURRENT ROW */
177415
+ 321, /* (331) frame_exclude_opt ::= */
177416
+ 321, /* (332) frame_exclude_opt ::= EXCLUDE frame_exclude */
177417
+ 322, /* (333) frame_exclude ::= NO OTHERS */
177418
+ 322, /* (334) frame_exclude ::= CURRENT ROW */
177419
+ 322, /* (335) frame_exclude ::= GROUP|TIES */
177420
+ 253, /* (336) window_clause ::= WINDOW windowdefn_list */
177421
+ 276, /* (337) filter_over ::= filter_clause over_clause */
177422
+ 276, /* (338) filter_over ::= over_clause */
177423
+ 276, /* (339) filter_over ::= filter_clause */
177424
+ 316, /* (340) over_clause ::= OVER LP window RP */
177425
+ 316, /* (341) over_clause ::= OVER nm */
177426
+ 315, /* (342) filter_clause ::= FILTER LP WHERE expr RP */
177427
+ 218, /* (343) term ::= QNUMBER */
177428
+ 187, /* (344) input ::= cmdlist */
177429
+ 188, /* (345) cmdlist ::= cmdlist ecmd */
177430
+ 188, /* (346) cmdlist ::= ecmd */
177431
+ 189, /* (347) ecmd ::= SEMI */
177432
+ 189, /* (348) ecmd ::= cmdx SEMI */
177433
+ 189, /* (349) ecmd ::= explain cmdx SEMI */
177434
+ 194, /* (350) trans_opt ::= */
177435
+ 194, /* (351) trans_opt ::= TRANSACTION */
177436
+ 194, /* (352) trans_opt ::= TRANSACTION nm */
177437
+ 196, /* (353) savepoint_opt ::= SAVEPOINT */
177438
+ 196, /* (354) savepoint_opt ::= */
177439
+ 192, /* (355) cmd ::= create_table create_table_args */
177440
+ 205, /* (356) table_option_set ::= table_option */
177441
+ 203, /* (357) columnlist ::= columnlist COMMA columnname carglist */
177442
+ 203, /* (358) columnlist ::= columnname carglist */
177443
+ 195, /* (359) nm ::= ID|INDEXED|JOIN_KW */
177444
+ 195, /* (360) nm ::= STRING */
177445
+ 210, /* (361) typetoken ::= typename */
177446
+ 211, /* (362) typename ::= ID|STRING */
177447
+ 212, /* (363) signed ::= plus_num */
177448
+ 212, /* (364) signed ::= minus_num */
177449
+ 209, /* (365) carglist ::= carglist ccons */
177450
+ 209, /* (366) carglist ::= */
177451
+ 217, /* (367) ccons ::= NULL onconf */
177452
+ 217, /* (368) ccons ::= GENERATED ALWAYS AS generated */
177453
+ 217, /* (369) ccons ::= AS generated */
177454
+ 204, /* (370) conslist_opt ::= COMMA conslist */
177455
+ 230, /* (371) conslist ::= conslist tconscomma tcons */
177456
+ 230, /* (372) conslist ::= tcons */
177457
+ 231, /* (373) tconscomma ::= */
177458
+ 235, /* (374) defer_subclause_opt ::= defer_subclause */
177459
+ 237, /* (375) resolvetype ::= raisetype */
177460
+ 241, /* (376) selectnowith ::= oneselect */
177461
+ 242, /* (377) oneselect ::= values */
177462
+ 257, /* (378) sclp ::= selcollist COMMA */
177463
+ 258, /* (379) as ::= ID|STRING */
177464
+ 267, /* (380) indexed_opt ::= indexed_by */
177465
+ 275, /* (381) returning ::= */
177466
+ 219, /* (382) expr ::= term */
177467
+ 277, /* (383) likeop ::= LIKE_KW|MATCH */
177468
+ 281, /* (384) case_operand ::= expr */
177469
+ 264, /* (385) exprlist ::= nexprlist */
177470
+ 287, /* (386) nmnum ::= plus_num */
177471
+ 287, /* (387) nmnum ::= nm */
177472
+ 287, /* (388) nmnum ::= ON */
177473
+ 287, /* (389) nmnum ::= DELETE */
177474
+ 287, /* (390) nmnum ::= DEFAULT */
177475
+ 213, /* (391) plus_num ::= INTEGER|FLOAT */
177476
+ 292, /* (392) foreach_clause ::= */
177477
+ 292, /* (393) foreach_clause ::= FOR EACH ROW */
177478
+ 295, /* (394) trnm ::= nm */
177479
+ 296, /* (395) tridxby ::= */
177480
+ 297, /* (396) database_kw_opt ::= DATABASE */
177481
+ 297, /* (397) database_kw_opt ::= */
177482
+ 300, /* (398) kwcolumn_opt ::= */
177483
+ 300, /* (399) kwcolumn_opt ::= COLUMNKW */
177484
+ 302, /* (400) vtabarglist ::= vtabarg */
177485
+ 302, /* (401) vtabarglist ::= vtabarglist COMMA vtabarg */
177486
+ 303, /* (402) vtabarg ::= vtabarg vtabargtoken */
177487
+ 306, /* (403) anylist ::= */
177488
+ 306, /* (404) anylist ::= anylist LP anylist RP */
177489
+ 306, /* (405) anylist ::= anylist ANY */
177490
+ 269, /* (406) with ::= */
177491
+ 310, /* (407) windowdefn_list ::= windowdefn */
177492
+ 312, /* (408) window ::= frame_opt */
177107177493
};
177108177494
177109177495
/* For rule J, yyRuleInfoNRhs[J] contains the negative of the number
177110177496
** of symbols on the right-hand side of that rule. */
177111177497
static const signed char yyRuleInfoNRhs[] = {
@@ -177567,20 +177953,20 @@
177567177953
break;
177568177954
case 2: /* cmdx ::= cmd */
177569177955
{ sqlite3FinishCoding(pParse); }
177570177956
break;
177571177957
case 3: /* cmd ::= BEGIN transtype trans_opt */
177572
-{sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy144);}
177958
+{sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy502);}
177573177959
break;
177574177960
case 4: /* transtype ::= */
177575
-{yymsp[1].minor.yy144 = TK_DEFERRED;}
177961
+{yymsp[1].minor.yy502 = TK_DEFERRED;}
177576177962
break;
177577177963
case 5: /* transtype ::= DEFERRED */
177578177964
case 6: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==6);
177579177965
case 7: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==7);
177580177966
case 324: /* range_or_rows ::= RANGE|ROWS|GROUPS */ yytestcase(yyruleno==324);
177581
-{yymsp[0].minor.yy144 = yymsp[0].major; /*A-overwrites-X*/}
177967
+{yymsp[0].minor.yy502 = yymsp[0].major; /*A-overwrites-X*/}
177582177968
break;
177583177969
case 8: /* cmd ::= COMMIT|END trans_opt */
177584177970
case 9: /* cmd ::= ROLLBACK trans_opt */ yytestcase(yyruleno==9);
177585177971
{sqlite3EndTransaction(pParse,yymsp[-1].major);}
177586177972
break;
@@ -177599,70 +177985,72 @@
177599177985
sqlite3Savepoint(pParse, SAVEPOINT_ROLLBACK, &yymsp[0].minor.yy0);
177600177986
}
177601177987
break;
177602177988
case 13: /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */
177603177989
{
177604
- sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy144,0,0,yymsp[-2].minor.yy144);
177990
+ sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy502,0,0,yymsp[-2].minor.yy502);
177605177991
}
177606177992
break;
177607177993
case 14: /* createkw ::= CREATE */
177608
-{disableLookaside(pParse);}
177994
+{
177995
+ disableLookaside(pParse);
177996
+}
177609177997
break;
177610177998
case 15: /* ifnotexists ::= */
177611177999
case 18: /* temp ::= */ yytestcase(yyruleno==18);
177612178000
case 47: /* autoinc ::= */ yytestcase(yyruleno==47);
177613178001
case 62: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==62);
177614178002
case 72: /* defer_subclause_opt ::= */ yytestcase(yyruleno==72);
177615178003
case 81: /* ifexists ::= */ yytestcase(yyruleno==81);
177616178004
case 100: /* distinct ::= */ yytestcase(yyruleno==100);
177617178005
case 246: /* collate ::= */ yytestcase(yyruleno==246);
177618
-{yymsp[1].minor.yy144 = 0;}
178006
+{yymsp[1].minor.yy502 = 0;}
177619178007
break;
177620178008
case 16: /* ifnotexists ::= IF NOT EXISTS */
177621
-{yymsp[-2].minor.yy144 = 1;}
178009
+{yymsp[-2].minor.yy502 = 1;}
177622178010
break;
177623178011
case 17: /* temp ::= TEMP */
177624
-{yymsp[0].minor.yy144 = pParse->db->init.busy==0;}
178012
+{yymsp[0].minor.yy502 = pParse->db->init.busy==0;}
177625178013
break;
177626178014
case 19: /* create_table_args ::= LP columnlist conslist_opt RP table_option_set */
177627178015
{
177628
- sqlite3EndTable(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,yymsp[0].minor.yy391,0);
178016
+ sqlite3EndTable(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,yymsp[0].minor.yy9,0);
177629178017
}
177630178018
break;
177631178019
case 20: /* create_table_args ::= AS select */
177632178020
{
177633
- sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy555);
177634
- sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy555);
178021
+ sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy637);
178022
+ sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy637);
177635178023
}
177636178024
break;
177637178025
case 21: /* table_option_set ::= */
177638
-{yymsp[1].minor.yy391 = 0;}
178026
+{yymsp[1].minor.yy9 = 0;}
177639178027
break;
177640178028
case 22: /* table_option_set ::= table_option_set COMMA table_option */
177641
-{yylhsminor.yy391 = yymsp[-2].minor.yy391|yymsp[0].minor.yy391;}
177642
- yymsp[-2].minor.yy391 = yylhsminor.yy391;
178029
+{yylhsminor.yy9 = yymsp[-2].minor.yy9|yymsp[0].minor.yy9;}
178030
+ yymsp[-2].minor.yy9 = yylhsminor.yy9;
177643178031
break;
177644178032
case 23: /* table_option ::= WITHOUT nm */
177645178033
{
177646178034
if( yymsp[0].minor.yy0.n==5 && sqlite3_strnicmp(yymsp[0].minor.yy0.z,"rowid",5)==0 ){
177647
- yymsp[-1].minor.yy391 = TF_WithoutRowid | TF_NoVisibleRowid;
178035
+ yymsp[-1].minor.yy9 = TF_WithoutRowid | TF_NoVisibleRowid;
177648178036
}else{
177649
- yymsp[-1].minor.yy391 = 0;
178037
+ yymsp[-1].minor.yy9 = 0;
177650178038
sqlite3ErrorMsg(pParse, "unknown table option: %.*s", yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.z);
177651178039
}
177652178040
}
177653178041
break;
177654178042
case 24: /* table_option ::= nm */
177655178043
{
177656178044
if( yymsp[0].minor.yy0.n==6 && sqlite3_strnicmp(yymsp[0].minor.yy0.z,"strict",6)==0 ){
177657
- yylhsminor.yy391 = TF_Strict;
178045
+ yylhsminor.yy9 = TF_Strict;
177658178046
}else{
177659
- yylhsminor.yy391 = 0;
178047
+ yylhsminor.yy9 = 0;
177660178048
sqlite3ErrorMsg(pParse, "unknown table option: %.*s", yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.z);
177661178049
}
177662178050
}
177663
- yymsp[0].minor.yy391 = yylhsminor.yy391;
178051
+ yymsp[0].minor.yy9 = yylhsminor.yy9;
177664178052
break;
177665178053
case 25: /* columnname ::= nm typetoken */
177666178054
{sqlite3AddColumn(pParse,yymsp[-1].minor.yy0,yymsp[0].minor.yy0);}
177667178055
break;
177668178056
case 26: /* typetoken ::= */
@@ -177684,11 +178072,11 @@
177684178072
{yymsp[-1].minor.yy0.n=yymsp[0].minor.yy0.n+(int)(yymsp[0].minor.yy0.z-yymsp[-1].minor.yy0.z);}
177685178073
break;
177686178074
case 30: /* scanpt ::= */
177687178075
{
177688178076
assert( yyLookahead!=YYNOCODE );
177689
- yymsp[1].minor.yy168 = yyLookaheadToken.z;
178077
+ yymsp[1].minor.yy342 = yyLookaheadToken.z;
177690178078
}
177691178079
break;
177692178080
case 31: /* scantok ::= */
177693178081
{
177694178082
assert( yyLookahead!=YYNOCODE );
@@ -177695,24 +178083,24 @@
177695178083
yymsp[1].minor.yy0 = yyLookaheadToken;
177696178084
}
177697178085
break;
177698178086
case 32: /* ccons ::= CONSTRAINT nm */
177699178087
case 67: /* tcons ::= CONSTRAINT nm */ yytestcase(yyruleno==67);
177700
-{pParse->constraintName = yymsp[0].minor.yy0;}
178088
+{ASSERT_IS_CREATE; pParse->u1.cr.constraintName = yymsp[0].minor.yy0;}
177701178089
break;
177702178090
case 33: /* ccons ::= DEFAULT scantok term */
177703
-{sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy454,yymsp[-1].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);}
178091
+{sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy590,yymsp[-1].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);}
177704178092
break;
177705178093
case 34: /* ccons ::= DEFAULT LP expr RP */
177706
-{sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy454,yymsp[-2].minor.yy0.z+1,yymsp[0].minor.yy0.z);}
178094
+{sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy590,yymsp[-2].minor.yy0.z+1,yymsp[0].minor.yy0.z);}
177707178095
break;
177708178096
case 35: /* ccons ::= DEFAULT PLUS scantok term */
177709
-{sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy454,yymsp[-2].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);}
178097
+{sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy590,yymsp[-2].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);}
177710178098
break;
177711178099
case 36: /* ccons ::= DEFAULT MINUS scantok term */
177712178100
{
177713
- Expr *p = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy454, 0);
178101
+ Expr *p = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy590, 0);
177714178102
sqlite3AddDefaultValue(pParse,p,yymsp[-2].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);
177715178103
}
177716178104
break;
177717178105
case 37: /* ccons ::= DEFAULT scantok ID|INDEXED */
177718178106
{
@@ -177723,262 +178111,262 @@
177723178111
}
177724178112
sqlite3AddDefaultValue(pParse,p,yymsp[0].minor.yy0.z,yymsp[0].minor.yy0.z+yymsp[0].minor.yy0.n);
177725178113
}
177726178114
break;
177727178115
case 38: /* ccons ::= NOT NULL onconf */
177728
-{sqlite3AddNotNull(pParse, yymsp[0].minor.yy144);}
178116
+{sqlite3AddNotNull(pParse, yymsp[0].minor.yy502);}
177729178117
break;
177730178118
case 39: /* ccons ::= PRIMARY KEY sortorder onconf autoinc */
177731
-{sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy144,yymsp[0].minor.yy144,yymsp[-2].minor.yy144);}
178119
+{sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy502,yymsp[0].minor.yy502,yymsp[-2].minor.yy502);}
177732178120
break;
177733178121
case 40: /* ccons ::= UNIQUE onconf */
177734
-{sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy144,0,0,0,0,
178122
+{sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy502,0,0,0,0,
177735178123
SQLITE_IDXTYPE_UNIQUE);}
177736178124
break;
177737178125
case 41: /* ccons ::= CHECK LP expr RP */
177738
-{sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy454,yymsp[-2].minor.yy0.z,yymsp[0].minor.yy0.z);}
178126
+{sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy590,yymsp[-2].minor.yy0.z,yymsp[0].minor.yy0.z);}
177739178127
break;
177740178128
case 42: /* ccons ::= REFERENCES nm eidlist_opt refargs */
177741
-{sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy14,yymsp[0].minor.yy144);}
178129
+{sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy402,yymsp[0].minor.yy502);}
177742178130
break;
177743178131
case 43: /* ccons ::= defer_subclause */
177744
-{sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy144);}
178132
+{sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy502);}
177745178133
break;
177746178134
case 44: /* ccons ::= COLLATE ID|STRING */
177747178135
{sqlite3AddCollateType(pParse, &yymsp[0].minor.yy0);}
177748178136
break;
177749178137
case 45: /* generated ::= LP expr RP */
177750
-{sqlite3AddGenerated(pParse,yymsp[-1].minor.yy454,0);}
178138
+{sqlite3AddGenerated(pParse,yymsp[-1].minor.yy590,0);}
177751178139
break;
177752178140
case 46: /* generated ::= LP expr RP ID */
177753
-{sqlite3AddGenerated(pParse,yymsp[-2].minor.yy454,&yymsp[0].minor.yy0);}
178141
+{sqlite3AddGenerated(pParse,yymsp[-2].minor.yy590,&yymsp[0].minor.yy0);}
177754178142
break;
177755178143
case 48: /* autoinc ::= AUTOINCR */
177756
-{yymsp[0].minor.yy144 = 1;}
178144
+{yymsp[0].minor.yy502 = 1;}
177757178145
break;
177758178146
case 49: /* refargs ::= */
177759
-{ yymsp[1].minor.yy144 = OE_None*0x0101; /* EV: R-19803-45884 */}
178147
+{ yymsp[1].minor.yy502 = OE_None*0x0101; /* EV: R-19803-45884 */}
177760178148
break;
177761178149
case 50: /* refargs ::= refargs refarg */
177762
-{ yymsp[-1].minor.yy144 = (yymsp[-1].minor.yy144 & ~yymsp[0].minor.yy383.mask) | yymsp[0].minor.yy383.value; }
178150
+{ yymsp[-1].minor.yy502 = (yymsp[-1].minor.yy502 & ~yymsp[0].minor.yy481.mask) | yymsp[0].minor.yy481.value; }
177763178151
break;
177764178152
case 51: /* refarg ::= MATCH nm */
177765
-{ yymsp[-1].minor.yy383.value = 0; yymsp[-1].minor.yy383.mask = 0x000000; }
178153
+{ yymsp[-1].minor.yy481.value = 0; yymsp[-1].minor.yy481.mask = 0x000000; }
177766178154
break;
177767178155
case 52: /* refarg ::= ON INSERT refact */
177768
-{ yymsp[-2].minor.yy383.value = 0; yymsp[-2].minor.yy383.mask = 0x000000; }
178156
+{ yymsp[-2].minor.yy481.value = 0; yymsp[-2].minor.yy481.mask = 0x000000; }
177769178157
break;
177770178158
case 53: /* refarg ::= ON DELETE refact */
177771
-{ yymsp[-2].minor.yy383.value = yymsp[0].minor.yy144; yymsp[-2].minor.yy383.mask = 0x0000ff; }
178159
+{ yymsp[-2].minor.yy481.value = yymsp[0].minor.yy502; yymsp[-2].minor.yy481.mask = 0x0000ff; }
177772178160
break;
177773178161
case 54: /* refarg ::= ON UPDATE refact */
177774
-{ yymsp[-2].minor.yy383.value = yymsp[0].minor.yy144<<8; yymsp[-2].minor.yy383.mask = 0x00ff00; }
178162
+{ yymsp[-2].minor.yy481.value = yymsp[0].minor.yy502<<8; yymsp[-2].minor.yy481.mask = 0x00ff00; }
177775178163
break;
177776178164
case 55: /* refact ::= SET NULL */
177777
-{ yymsp[-1].minor.yy144 = OE_SetNull; /* EV: R-33326-45252 */}
178165
+{ yymsp[-1].minor.yy502 = OE_SetNull; /* EV: R-33326-45252 */}
177778178166
break;
177779178167
case 56: /* refact ::= SET DEFAULT */
177780
-{ yymsp[-1].minor.yy144 = OE_SetDflt; /* EV: R-33326-45252 */}
178168
+{ yymsp[-1].minor.yy502 = OE_SetDflt; /* EV: R-33326-45252 */}
177781178169
break;
177782178170
case 57: /* refact ::= CASCADE */
177783
-{ yymsp[0].minor.yy144 = OE_Cascade; /* EV: R-33326-45252 */}
178171
+{ yymsp[0].minor.yy502 = OE_Cascade; /* EV: R-33326-45252 */}
177784178172
break;
177785178173
case 58: /* refact ::= RESTRICT */
177786
-{ yymsp[0].minor.yy144 = OE_Restrict; /* EV: R-33326-45252 */}
178174
+{ yymsp[0].minor.yy502 = OE_Restrict; /* EV: R-33326-45252 */}
177787178175
break;
177788178176
case 59: /* refact ::= NO ACTION */
177789
-{ yymsp[-1].minor.yy144 = OE_None; /* EV: R-33326-45252 */}
178177
+{ yymsp[-1].minor.yy502 = OE_None; /* EV: R-33326-45252 */}
177790178178
break;
177791178179
case 60: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
177792
-{yymsp[-2].minor.yy144 = 0;}
178180
+{yymsp[-2].minor.yy502 = 0;}
177793178181
break;
177794178182
case 61: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
177795178183
case 76: /* orconf ::= OR resolvetype */ yytestcase(yyruleno==76);
177796178184
case 173: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==173);
177797
-{yymsp[-1].minor.yy144 = yymsp[0].minor.yy144;}
178185
+{yymsp[-1].minor.yy502 = yymsp[0].minor.yy502;}
177798178186
break;
177799178187
case 63: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */
177800178188
case 80: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==80);
177801178189
case 219: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==219);
177802178190
case 222: /* in_op ::= NOT IN */ yytestcase(yyruleno==222);
177803178191
case 247: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==247);
177804
-{yymsp[-1].minor.yy144 = 1;}
178192
+{yymsp[-1].minor.yy502 = 1;}
177805178193
break;
177806178194
case 64: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
177807
-{yymsp[-1].minor.yy144 = 0;}
178195
+{yymsp[-1].minor.yy502 = 0;}
177808178196
break;
177809178197
case 66: /* tconscomma ::= COMMA */
177810
-{pParse->constraintName.n = 0;}
178198
+{ASSERT_IS_CREATE; pParse->u1.cr.constraintName.n = 0;}
177811178199
break;
177812178200
case 68: /* tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
177813
-{sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy14,yymsp[0].minor.yy144,yymsp[-2].minor.yy144,0);}
178201
+{sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy402,yymsp[0].minor.yy502,yymsp[-2].minor.yy502,0);}
177814178202
break;
177815178203
case 69: /* tcons ::= UNIQUE LP sortlist RP onconf */
177816
-{sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy14,yymsp[0].minor.yy144,0,0,0,0,
178204
+{sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy402,yymsp[0].minor.yy502,0,0,0,0,
177817178205
SQLITE_IDXTYPE_UNIQUE);}
177818178206
break;
177819178207
case 70: /* tcons ::= CHECK LP expr RP onconf */
177820
-{sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy454,yymsp[-3].minor.yy0.z,yymsp[-1].minor.yy0.z);}
178208
+{sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy590,yymsp[-3].minor.yy0.z,yymsp[-1].minor.yy0.z);}
177821178209
break;
177822178210
case 71: /* tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
177823178211
{
177824
- sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy14, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy14, yymsp[-1].minor.yy144);
177825
- sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy144);
178212
+ sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy402, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy402, yymsp[-1].minor.yy502);
178213
+ sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy502);
177826178214
}
177827178215
break;
177828178216
case 73: /* onconf ::= */
177829178217
case 75: /* orconf ::= */ yytestcase(yyruleno==75);
177830
-{yymsp[1].minor.yy144 = OE_Default;}
178218
+{yymsp[1].minor.yy502 = OE_Default;}
177831178219
break;
177832178220
case 74: /* onconf ::= ON CONFLICT resolvetype */
177833
-{yymsp[-2].minor.yy144 = yymsp[0].minor.yy144;}
178221
+{yymsp[-2].minor.yy502 = yymsp[0].minor.yy502;}
177834178222
break;
177835178223
case 77: /* resolvetype ::= IGNORE */
177836
-{yymsp[0].minor.yy144 = OE_Ignore;}
178224
+{yymsp[0].minor.yy502 = OE_Ignore;}
177837178225
break;
177838178226
case 78: /* resolvetype ::= REPLACE */
177839178227
case 174: /* insert_cmd ::= REPLACE */ yytestcase(yyruleno==174);
177840
-{yymsp[0].minor.yy144 = OE_Replace;}
178228
+{yymsp[0].minor.yy502 = OE_Replace;}
177841178229
break;
177842178230
case 79: /* cmd ::= DROP TABLE ifexists fullname */
177843178231
{
177844
- sqlite3DropTable(pParse, yymsp[0].minor.yy203, 0, yymsp[-1].minor.yy144);
178232
+ sqlite3DropTable(pParse, yymsp[0].minor.yy563, 0, yymsp[-1].minor.yy502);
177845178233
}
177846178234
break;
177847178235
case 82: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
177848178236
{
177849
- sqlite3CreateView(pParse, &yymsp[-8].minor.yy0, &yymsp[-4].minor.yy0, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy14, yymsp[0].minor.yy555, yymsp[-7].minor.yy144, yymsp[-5].minor.yy144);
178237
+ sqlite3CreateView(pParse, &yymsp[-8].minor.yy0, &yymsp[-4].minor.yy0, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy402, yymsp[0].minor.yy637, yymsp[-7].minor.yy502, yymsp[-5].minor.yy502);
177850178238
}
177851178239
break;
177852178240
case 83: /* cmd ::= DROP VIEW ifexists fullname */
177853178241
{
177854
- sqlite3DropTable(pParse, yymsp[0].minor.yy203, 1, yymsp[-1].minor.yy144);
178242
+ sqlite3DropTable(pParse, yymsp[0].minor.yy563, 1, yymsp[-1].minor.yy502);
177855178243
}
177856178244
break;
177857178245
case 84: /* cmd ::= select */
177858178246
{
177859178247
SelectDest dest = {SRT_Output, 0, 0, 0, 0, 0, 0};
177860178248
if( (pParse->db->mDbFlags & DBFLAG_EncodingFixed)!=0
177861178249
|| sqlite3ReadSchema(pParse)==SQLITE_OK
177862178250
){
177863
- sqlite3Select(pParse, yymsp[0].minor.yy555, &dest);
178251
+ sqlite3Select(pParse, yymsp[0].minor.yy637, &dest);
177864178252
}
177865
- sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy555);
178253
+ sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy637);
177866178254
}
177867178255
break;
177868178256
case 85: /* select ::= WITH wqlist selectnowith */
177869
-{yymsp[-2].minor.yy555 = attachWithToSelect(pParse,yymsp[0].minor.yy555,yymsp[-1].minor.yy59);}
178257
+{yymsp[-2].minor.yy637 = attachWithToSelect(pParse,yymsp[0].minor.yy637,yymsp[-1].minor.yy125);}
177870178258
break;
177871178259
case 86: /* select ::= WITH RECURSIVE wqlist selectnowith */
177872
-{yymsp[-3].minor.yy555 = attachWithToSelect(pParse,yymsp[0].minor.yy555,yymsp[-1].minor.yy59);}
178260
+{yymsp[-3].minor.yy637 = attachWithToSelect(pParse,yymsp[0].minor.yy637,yymsp[-1].minor.yy125);}
177873178261
break;
177874178262
case 87: /* select ::= selectnowith */
177875178263
{
177876
- Select *p = yymsp[0].minor.yy555;
178264
+ Select *p = yymsp[0].minor.yy637;
177877178265
if( p ){
177878178266
parserDoubleLinkSelect(pParse, p);
177879178267
}
177880178268
}
177881178269
break;
177882178270
case 88: /* selectnowith ::= selectnowith multiselect_op oneselect */
177883178271
{
177884
- Select *pRhs = yymsp[0].minor.yy555;
177885
- Select *pLhs = yymsp[-2].minor.yy555;
178272
+ Select *pRhs = yymsp[0].minor.yy637;
178273
+ Select *pLhs = yymsp[-2].minor.yy637;
177886178274
if( pRhs && pRhs->pPrior ){
177887178275
SrcList *pFrom;
177888178276
Token x;
177889178277
x.n = 0;
177890178278
parserDoubleLinkSelect(pParse, pRhs);
177891178279
pFrom = sqlite3SrcListAppendFromTerm(pParse,0,0,0,&x,pRhs,0);
177892178280
pRhs = sqlite3SelectNew(pParse,0,pFrom,0,0,0,0,0,0);
177893178281
}
177894178282
if( pRhs ){
177895
- pRhs->op = (u8)yymsp[-1].minor.yy144;
178283
+ pRhs->op = (u8)yymsp[-1].minor.yy502;
177896178284
pRhs->pPrior = pLhs;
177897178285
if( ALWAYS(pLhs) ) pLhs->selFlags &= ~SF_MultiValue;
177898178286
pRhs->selFlags &= ~SF_MultiValue;
177899
- if( yymsp[-1].minor.yy144!=TK_ALL ) pParse->hasCompound = 1;
178287
+ if( yymsp[-1].minor.yy502!=TK_ALL ) pParse->hasCompound = 1;
177900178288
}else{
177901178289
sqlite3SelectDelete(pParse->db, pLhs);
177902178290
}
177903
- yymsp[-2].minor.yy555 = pRhs;
178291
+ yymsp[-2].minor.yy637 = pRhs;
177904178292
}
177905178293
break;
177906178294
case 89: /* multiselect_op ::= UNION */
177907178295
case 91: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==91);
177908
-{yymsp[0].minor.yy144 = yymsp[0].major; /*A-overwrites-OP*/}
178296
+{yymsp[0].minor.yy502 = yymsp[0].major; /*A-overwrites-OP*/}
177909178297
break;
177910178298
case 90: /* multiselect_op ::= UNION ALL */
177911
-{yymsp[-1].minor.yy144 = TK_ALL;}
178299
+{yymsp[-1].minor.yy502 = TK_ALL;}
177912178300
break;
177913178301
case 92: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
177914178302
{
177915
- yymsp[-8].minor.yy555 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy14,yymsp[-5].minor.yy203,yymsp[-4].minor.yy454,yymsp[-3].minor.yy14,yymsp[-2].minor.yy454,yymsp[-1].minor.yy14,yymsp[-7].minor.yy144,yymsp[0].minor.yy454);
178303
+ yymsp[-8].minor.yy637 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy402,yymsp[-5].minor.yy563,yymsp[-4].minor.yy590,yymsp[-3].minor.yy402,yymsp[-2].minor.yy590,yymsp[-1].minor.yy402,yymsp[-7].minor.yy502,yymsp[0].minor.yy590);
177916178304
}
177917178305
break;
177918178306
case 93: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */
177919178307
{
177920
- yymsp[-9].minor.yy555 = sqlite3SelectNew(pParse,yymsp[-7].minor.yy14,yymsp[-6].minor.yy203,yymsp[-5].minor.yy454,yymsp[-4].minor.yy14,yymsp[-3].minor.yy454,yymsp[-1].minor.yy14,yymsp[-8].minor.yy144,yymsp[0].minor.yy454);
177921
- if( yymsp[-9].minor.yy555 ){
177922
- yymsp[-9].minor.yy555->pWinDefn = yymsp[-2].minor.yy211;
178308
+ yymsp[-9].minor.yy637 = sqlite3SelectNew(pParse,yymsp[-7].minor.yy402,yymsp[-6].minor.yy563,yymsp[-5].minor.yy590,yymsp[-4].minor.yy402,yymsp[-3].minor.yy590,yymsp[-1].minor.yy402,yymsp[-8].minor.yy502,yymsp[0].minor.yy590);
178309
+ if( yymsp[-9].minor.yy637 ){
178310
+ yymsp[-9].minor.yy637->pWinDefn = yymsp[-2].minor.yy483;
177923178311
}else{
177924
- sqlite3WindowListDelete(pParse->db, yymsp[-2].minor.yy211);
178312
+ sqlite3WindowListDelete(pParse->db, yymsp[-2].minor.yy483);
177925178313
}
177926178314
}
177927178315
break;
177928178316
case 94: /* values ::= VALUES LP nexprlist RP */
177929178317
{
177930
- yymsp[-3].minor.yy555 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy14,0,0,0,0,0,SF_Values,0);
178318
+ yymsp[-3].minor.yy637 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy402,0,0,0,0,0,SF_Values,0);
177931178319
}
177932178320
break;
177933178321
case 95: /* oneselect ::= mvalues */
177934178322
{
177935
- sqlite3MultiValuesEnd(pParse, yymsp[0].minor.yy555);
178323
+ sqlite3MultiValuesEnd(pParse, yymsp[0].minor.yy637);
177936178324
}
177937178325
break;
177938178326
case 96: /* mvalues ::= values COMMA LP nexprlist RP */
177939178327
case 97: /* mvalues ::= mvalues COMMA LP nexprlist RP */ yytestcase(yyruleno==97);
177940178328
{
177941
- yymsp[-4].minor.yy555 = sqlite3MultiValues(pParse, yymsp[-4].minor.yy555, yymsp[-1].minor.yy14);
178329
+ yymsp[-4].minor.yy637 = sqlite3MultiValues(pParse, yymsp[-4].minor.yy637, yymsp[-1].minor.yy402);
177942178330
}
177943178331
break;
177944178332
case 98: /* distinct ::= DISTINCT */
177945
-{yymsp[0].minor.yy144 = SF_Distinct;}
178333
+{yymsp[0].minor.yy502 = SF_Distinct;}
177946178334
break;
177947178335
case 99: /* distinct ::= ALL */
177948
-{yymsp[0].minor.yy144 = SF_All;}
178336
+{yymsp[0].minor.yy502 = SF_All;}
177949178337
break;
177950178338
case 101: /* sclp ::= */
177951178339
case 134: /* orderby_opt ::= */ yytestcase(yyruleno==134);
177952178340
case 144: /* groupby_opt ::= */ yytestcase(yyruleno==144);
177953178341
case 234: /* exprlist ::= */ yytestcase(yyruleno==234);
177954178342
case 237: /* paren_exprlist ::= */ yytestcase(yyruleno==237);
177955178343
case 242: /* eidlist_opt ::= */ yytestcase(yyruleno==242);
177956
-{yymsp[1].minor.yy14 = 0;}
178344
+{yymsp[1].minor.yy402 = 0;}
177957178345
break;
177958178346
case 102: /* selcollist ::= sclp scanpt expr scanpt as */
177959178347
{
177960
- yymsp[-4].minor.yy14 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy14, yymsp[-2].minor.yy454);
177961
- if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy14, &yymsp[0].minor.yy0, 1);
177962
- sqlite3ExprListSetSpan(pParse,yymsp[-4].minor.yy14,yymsp[-3].minor.yy168,yymsp[-1].minor.yy168);
178348
+ yymsp[-4].minor.yy402 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy402, yymsp[-2].minor.yy590);
178349
+ if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy402, &yymsp[0].minor.yy0, 1);
178350
+ sqlite3ExprListSetSpan(pParse,yymsp[-4].minor.yy402,yymsp[-3].minor.yy342,yymsp[-1].minor.yy342);
177963178351
}
177964178352
break;
177965178353
case 103: /* selcollist ::= sclp scanpt STAR */
177966178354
{
177967178355
Expr *p = sqlite3Expr(pParse->db, TK_ASTERISK, 0);
177968178356
sqlite3ExprSetErrorOffset(p, (int)(yymsp[0].minor.yy0.z - pParse->zTail));
177969
- yymsp[-2].minor.yy14 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy14, p);
178357
+ yymsp[-2].minor.yy402 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy402, p);
177970178358
}
177971178359
break;
177972178360
case 104: /* selcollist ::= sclp scanpt nm DOT STAR */
177973178361
{
177974178362
Expr *pRight, *pLeft, *pDot;
177975178363
pRight = sqlite3PExpr(pParse, TK_ASTERISK, 0, 0);
177976178364
sqlite3ExprSetErrorOffset(pRight, (int)(yymsp[0].minor.yy0.z - pParse->zTail));
177977178365
pLeft = tokenExpr(pParse, TK_ID, yymsp[-2].minor.yy0);
177978178366
pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight);
177979
- yymsp[-4].minor.yy14 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy14, pDot);
178367
+ yymsp[-4].minor.yy402 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy402, pDot);
177980178368
}
177981178369
break;
177982178370
case 105: /* as ::= AS nm */
177983178371
case 117: /* dbnm ::= DOT nm */ yytestcase(yyruleno==117);
177984178372
case 258: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==258);
@@ -177985,54 +178373,54 @@
177985178373
case 259: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==259);
177986178374
{yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;}
177987178375
break;
177988178376
case 107: /* from ::= */
177989178377
case 110: /* stl_prefix ::= */ yytestcase(yyruleno==110);
177990
-{yymsp[1].minor.yy203 = 0;}
178378
+{yymsp[1].minor.yy563 = 0;}
177991178379
break;
177992178380
case 108: /* from ::= FROM seltablist */
177993178381
{
177994
- yymsp[-1].minor.yy203 = yymsp[0].minor.yy203;
177995
- sqlite3SrcListShiftJoinType(pParse,yymsp[-1].minor.yy203);
178382
+ yymsp[-1].minor.yy563 = yymsp[0].minor.yy563;
178383
+ sqlite3SrcListShiftJoinType(pParse,yymsp[-1].minor.yy563);
177996178384
}
177997178385
break;
177998178386
case 109: /* stl_prefix ::= seltablist joinop */
177999178387
{
178000
- if( ALWAYS(yymsp[-1].minor.yy203 && yymsp[-1].minor.yy203->nSrc>0) ) yymsp[-1].minor.yy203->a[yymsp[-1].minor.yy203->nSrc-1].fg.jointype = (u8)yymsp[0].minor.yy144;
178388
+ if( ALWAYS(yymsp[-1].minor.yy563 && yymsp[-1].minor.yy563->nSrc>0) ) yymsp[-1].minor.yy563->a[yymsp[-1].minor.yy563->nSrc-1].fg.jointype = (u8)yymsp[0].minor.yy502;
178001178389
}
178002178390
break;
178003178391
case 111: /* seltablist ::= stl_prefix nm dbnm as on_using */
178004178392
{
178005
- yymsp[-4].minor.yy203 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-4].minor.yy203,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0,&yymsp[0].minor.yy269);
178393
+ yymsp[-4].minor.yy563 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-4].minor.yy563,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0,&yymsp[0].minor.yy421);
178006178394
}
178007178395
break;
178008178396
case 112: /* seltablist ::= stl_prefix nm dbnm as indexed_by on_using */
178009178397
{
178010
- yymsp[-5].minor.yy203 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-5].minor.yy203,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,0,&yymsp[0].minor.yy269);
178011
- sqlite3SrcListIndexedBy(pParse, yymsp[-5].minor.yy203, &yymsp[-1].minor.yy0);
178398
+ yymsp[-5].minor.yy563 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-5].minor.yy563,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,0,&yymsp[0].minor.yy421);
178399
+ sqlite3SrcListIndexedBy(pParse, yymsp[-5].minor.yy563, &yymsp[-1].minor.yy0);
178012178400
}
178013178401
break;
178014178402
case 113: /* seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_using */
178015178403
{
178016
- yymsp[-7].minor.yy203 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-7].minor.yy203,&yymsp[-6].minor.yy0,&yymsp[-5].minor.yy0,&yymsp[-1].minor.yy0,0,&yymsp[0].minor.yy269);
178017
- sqlite3SrcListFuncArgs(pParse, yymsp[-7].minor.yy203, yymsp[-3].minor.yy14);
178404
+ yymsp[-7].minor.yy563 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-7].minor.yy563,&yymsp[-6].minor.yy0,&yymsp[-5].minor.yy0,&yymsp[-1].minor.yy0,0,&yymsp[0].minor.yy421);
178405
+ sqlite3SrcListFuncArgs(pParse, yymsp[-7].minor.yy563, yymsp[-3].minor.yy402);
178018178406
}
178019178407
break;
178020178408
case 114: /* seltablist ::= stl_prefix LP select RP as on_using */
178021178409
{
178022
- yymsp[-5].minor.yy203 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-5].minor.yy203,0,0,&yymsp[-1].minor.yy0,yymsp[-3].minor.yy555,&yymsp[0].minor.yy269);
178410
+ yymsp[-5].minor.yy563 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-5].minor.yy563,0,0,&yymsp[-1].minor.yy0,yymsp[-3].minor.yy637,&yymsp[0].minor.yy421);
178023178411
}
178024178412
break;
178025178413
case 115: /* seltablist ::= stl_prefix LP seltablist RP as on_using */
178026178414
{
178027
- if( yymsp[-5].minor.yy203==0 && yymsp[-1].minor.yy0.n==0 && yymsp[0].minor.yy269.pOn==0 && yymsp[0].minor.yy269.pUsing==0 ){
178028
- yymsp[-5].minor.yy203 = yymsp[-3].minor.yy203;
178029
- }else if( ALWAYS(yymsp[-3].minor.yy203!=0) && yymsp[-3].minor.yy203->nSrc==1 ){
178030
- yymsp[-5].minor.yy203 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-5].minor.yy203,0,0,&yymsp[-1].minor.yy0,0,&yymsp[0].minor.yy269);
178031
- if( yymsp[-5].minor.yy203 ){
178032
- SrcItem *pNew = &yymsp[-5].minor.yy203->a[yymsp[-5].minor.yy203->nSrc-1];
178033
- SrcItem *pOld = yymsp[-3].minor.yy203->a;
178415
+ if( yymsp[-5].minor.yy563==0 && yymsp[-1].minor.yy0.n==0 && yymsp[0].minor.yy421.pOn==0 && yymsp[0].minor.yy421.pUsing==0 ){
178416
+ yymsp[-5].minor.yy563 = yymsp[-3].minor.yy563;
178417
+ }else if( ALWAYS(yymsp[-3].minor.yy563!=0) && yymsp[-3].minor.yy563->nSrc==1 ){
178418
+ yymsp[-5].minor.yy563 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-5].minor.yy563,0,0,&yymsp[-1].minor.yy0,0,&yymsp[0].minor.yy421);
178419
+ if( yymsp[-5].minor.yy563 ){
178420
+ SrcItem *pNew = &yymsp[-5].minor.yy563->a[yymsp[-5].minor.yy563->nSrc-1];
178421
+ SrcItem *pOld = yymsp[-3].minor.yy563->a;
178034178422
assert( pOld->fg.fixedSchema==0 );
178035178423
pNew->zName = pOld->zName;
178036178424
assert( pOld->fg.fixedSchema==0 );
178037178425
if( pOld->fg.isSubquery ){
178038178426
pNew->fg.isSubquery = 1;
@@ -178053,249 +178441,249 @@
178053178441
pOld->fg.isTabFunc = 0;
178054178442
pNew->fg.isTabFunc = 1;
178055178443
}
178056178444
pOld->zName = 0;
178057178445
}
178058
- sqlite3SrcListDelete(pParse->db, yymsp[-3].minor.yy203);
178446
+ sqlite3SrcListDelete(pParse->db, yymsp[-3].minor.yy563);
178059178447
}else{
178060178448
Select *pSubquery;
178061
- sqlite3SrcListShiftJoinType(pParse,yymsp[-3].minor.yy203);
178062
- pSubquery = sqlite3SelectNew(pParse,0,yymsp[-3].minor.yy203,0,0,0,0,SF_NestedFrom,0);
178063
- yymsp[-5].minor.yy203 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-5].minor.yy203,0,0,&yymsp[-1].minor.yy0,pSubquery,&yymsp[0].minor.yy269);
178449
+ sqlite3SrcListShiftJoinType(pParse,yymsp[-3].minor.yy563);
178450
+ pSubquery = sqlite3SelectNew(pParse,0,yymsp[-3].minor.yy563,0,0,0,0,SF_NestedFrom,0);
178451
+ yymsp[-5].minor.yy563 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-5].minor.yy563,0,0,&yymsp[-1].minor.yy0,pSubquery,&yymsp[0].minor.yy421);
178064178452
}
178065178453
}
178066178454
break;
178067178455
case 116: /* dbnm ::= */
178068178456
case 131: /* indexed_opt ::= */ yytestcase(yyruleno==131);
178069178457
{yymsp[1].minor.yy0.z=0; yymsp[1].minor.yy0.n=0;}
178070178458
break;
178071178459
case 118: /* fullname ::= nm */
178072178460
{
178073
- yylhsminor.yy203 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0);
178074
- if( IN_RENAME_OBJECT && yylhsminor.yy203 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy203->a[0].zName, &yymsp[0].minor.yy0);
178461
+ yylhsminor.yy563 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0);
178462
+ if( IN_RENAME_OBJECT && yylhsminor.yy563 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy563->a[0].zName, &yymsp[0].minor.yy0);
178075178463
}
178076
- yymsp[0].minor.yy203 = yylhsminor.yy203;
178464
+ yymsp[0].minor.yy563 = yylhsminor.yy563;
178077178465
break;
178078178466
case 119: /* fullname ::= nm DOT nm */
178079178467
{
178080
- yylhsminor.yy203 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);
178081
- if( IN_RENAME_OBJECT && yylhsminor.yy203 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy203->a[0].zName, &yymsp[0].minor.yy0);
178468
+ yylhsminor.yy563 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);
178469
+ if( IN_RENAME_OBJECT && yylhsminor.yy563 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy563->a[0].zName, &yymsp[0].minor.yy0);
178082178470
}
178083
- yymsp[-2].minor.yy203 = yylhsminor.yy203;
178471
+ yymsp[-2].minor.yy563 = yylhsminor.yy563;
178084178472
break;
178085178473
case 120: /* xfullname ::= nm */
178086
-{yymsp[0].minor.yy203 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0); /*A-overwrites-X*/}
178474
+{yymsp[0].minor.yy563 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0); /*A-overwrites-X*/}
178087178475
break;
178088178476
case 121: /* xfullname ::= nm DOT nm */
178089
-{yymsp[-2].minor.yy203 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/}
178477
+{yymsp[-2].minor.yy563 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/}
178090178478
break;
178091178479
case 122: /* xfullname ::= nm DOT nm AS nm */
178092178480
{
178093
- yymsp[-4].minor.yy203 = sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,&yymsp[-2].minor.yy0); /*A-overwrites-X*/
178094
- if( yymsp[-4].minor.yy203 ) yymsp[-4].minor.yy203->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
178481
+ yymsp[-4].minor.yy563 = sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,&yymsp[-2].minor.yy0); /*A-overwrites-X*/
178482
+ if( yymsp[-4].minor.yy563 ) yymsp[-4].minor.yy563->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
178095178483
}
178096178484
break;
178097178485
case 123: /* xfullname ::= nm AS nm */
178098178486
{
178099
- yymsp[-2].minor.yy203 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,0); /*A-overwrites-X*/
178100
- if( yymsp[-2].minor.yy203 ) yymsp[-2].minor.yy203->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
178487
+ yymsp[-2].minor.yy563 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,0); /*A-overwrites-X*/
178488
+ if( yymsp[-2].minor.yy563 ) yymsp[-2].minor.yy563->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
178101178489
}
178102178490
break;
178103178491
case 124: /* joinop ::= COMMA|JOIN */
178104
-{ yymsp[0].minor.yy144 = JT_INNER; }
178492
+{ yymsp[0].minor.yy502 = JT_INNER; }
178105178493
break;
178106178494
case 125: /* joinop ::= JOIN_KW JOIN */
178107
-{yymsp[-1].minor.yy144 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); /*X-overwrites-A*/}
178495
+{yymsp[-1].minor.yy502 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); /*X-overwrites-A*/}
178108178496
break;
178109178497
case 126: /* joinop ::= JOIN_KW nm JOIN */
178110
-{yymsp[-2].minor.yy144 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/}
178498
+{yymsp[-2].minor.yy502 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/}
178111178499
break;
178112178500
case 127: /* joinop ::= JOIN_KW nm nm JOIN */
178113
-{yymsp[-3].minor.yy144 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/}
178501
+{yymsp[-3].minor.yy502 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/}
178114178502
break;
178115178503
case 128: /* on_using ::= ON expr */
178116
-{yymsp[-1].minor.yy269.pOn = yymsp[0].minor.yy454; yymsp[-1].minor.yy269.pUsing = 0;}
178504
+{yymsp[-1].minor.yy421.pOn = yymsp[0].minor.yy590; yymsp[-1].minor.yy421.pUsing = 0;}
178117178505
break;
178118178506
case 129: /* on_using ::= USING LP idlist RP */
178119
-{yymsp[-3].minor.yy269.pOn = 0; yymsp[-3].minor.yy269.pUsing = yymsp[-1].minor.yy132;}
178507
+{yymsp[-3].minor.yy421.pOn = 0; yymsp[-3].minor.yy421.pUsing = yymsp[-1].minor.yy204;}
178120178508
break;
178121178509
case 130: /* on_using ::= */
178122
-{yymsp[1].minor.yy269.pOn = 0; yymsp[1].minor.yy269.pUsing = 0;}
178510
+{yymsp[1].minor.yy421.pOn = 0; yymsp[1].minor.yy421.pUsing = 0;}
178123178511
break;
178124178512
case 132: /* indexed_by ::= INDEXED BY nm */
178125178513
{yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;}
178126178514
break;
178127178515
case 133: /* indexed_by ::= NOT INDEXED */
178128178516
{yymsp[-1].minor.yy0.z=0; yymsp[-1].minor.yy0.n=1;}
178129178517
break;
178130178518
case 135: /* orderby_opt ::= ORDER BY sortlist */
178131178519
case 145: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==145);
178132
-{yymsp[-2].minor.yy14 = yymsp[0].minor.yy14;}
178520
+{yymsp[-2].minor.yy402 = yymsp[0].minor.yy402;}
178133178521
break;
178134178522
case 136: /* sortlist ::= sortlist COMMA expr sortorder nulls */
178135178523
{
178136
- yymsp[-4].minor.yy14 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy14,yymsp[-2].minor.yy454);
178137
- sqlite3ExprListSetSortOrder(yymsp[-4].minor.yy14,yymsp[-1].minor.yy144,yymsp[0].minor.yy144);
178524
+ yymsp[-4].minor.yy402 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy402,yymsp[-2].minor.yy590);
178525
+ sqlite3ExprListSetSortOrder(yymsp[-4].minor.yy402,yymsp[-1].minor.yy502,yymsp[0].minor.yy502);
178138178526
}
178139178527
break;
178140178528
case 137: /* sortlist ::= expr sortorder nulls */
178141178529
{
178142
- yymsp[-2].minor.yy14 = sqlite3ExprListAppend(pParse,0,yymsp[-2].minor.yy454); /*A-overwrites-Y*/
178143
- sqlite3ExprListSetSortOrder(yymsp[-2].minor.yy14,yymsp[-1].minor.yy144,yymsp[0].minor.yy144);
178530
+ yymsp[-2].minor.yy402 = sqlite3ExprListAppend(pParse,0,yymsp[-2].minor.yy590); /*A-overwrites-Y*/
178531
+ sqlite3ExprListSetSortOrder(yymsp[-2].minor.yy402,yymsp[-1].minor.yy502,yymsp[0].minor.yy502);
178144178532
}
178145178533
break;
178146178534
case 138: /* sortorder ::= ASC */
178147
-{yymsp[0].minor.yy144 = SQLITE_SO_ASC;}
178535
+{yymsp[0].minor.yy502 = SQLITE_SO_ASC;}
178148178536
break;
178149178537
case 139: /* sortorder ::= DESC */
178150
-{yymsp[0].minor.yy144 = SQLITE_SO_DESC;}
178538
+{yymsp[0].minor.yy502 = SQLITE_SO_DESC;}
178151178539
break;
178152178540
case 140: /* sortorder ::= */
178153178541
case 143: /* nulls ::= */ yytestcase(yyruleno==143);
178154
-{yymsp[1].minor.yy144 = SQLITE_SO_UNDEFINED;}
178542
+{yymsp[1].minor.yy502 = SQLITE_SO_UNDEFINED;}
178155178543
break;
178156178544
case 141: /* nulls ::= NULLS FIRST */
178157
-{yymsp[-1].minor.yy144 = SQLITE_SO_ASC;}
178545
+{yymsp[-1].minor.yy502 = SQLITE_SO_ASC;}
178158178546
break;
178159178547
case 142: /* nulls ::= NULLS LAST */
178160
-{yymsp[-1].minor.yy144 = SQLITE_SO_DESC;}
178548
+{yymsp[-1].minor.yy502 = SQLITE_SO_DESC;}
178161178549
break;
178162178550
case 146: /* having_opt ::= */
178163178551
case 148: /* limit_opt ::= */ yytestcase(yyruleno==148);
178164178552
case 153: /* where_opt ::= */ yytestcase(yyruleno==153);
178165178553
case 155: /* where_opt_ret ::= */ yytestcase(yyruleno==155);
178166178554
case 232: /* case_else ::= */ yytestcase(yyruleno==232);
178167178555
case 233: /* case_operand ::= */ yytestcase(yyruleno==233);
178168178556
case 252: /* vinto ::= */ yytestcase(yyruleno==252);
178169
-{yymsp[1].minor.yy454 = 0;}
178557
+{yymsp[1].minor.yy590 = 0;}
178170178558
break;
178171178559
case 147: /* having_opt ::= HAVING expr */
178172178560
case 154: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==154);
178173178561
case 156: /* where_opt_ret ::= WHERE expr */ yytestcase(yyruleno==156);
178174178562
case 231: /* case_else ::= ELSE expr */ yytestcase(yyruleno==231);
178175178563
case 251: /* vinto ::= INTO expr */ yytestcase(yyruleno==251);
178176
-{yymsp[-1].minor.yy454 = yymsp[0].minor.yy454;}
178564
+{yymsp[-1].minor.yy590 = yymsp[0].minor.yy590;}
178177178565
break;
178178178566
case 149: /* limit_opt ::= LIMIT expr */
178179
-{yymsp[-1].minor.yy454 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy454,0);}
178567
+{yymsp[-1].minor.yy590 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy590,0);}
178180178568
break;
178181178569
case 150: /* limit_opt ::= LIMIT expr OFFSET expr */
178182
-{yymsp[-3].minor.yy454 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[-2].minor.yy454,yymsp[0].minor.yy454);}
178570
+{yymsp[-3].minor.yy590 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[-2].minor.yy590,yymsp[0].minor.yy590);}
178183178571
break;
178184178572
case 151: /* limit_opt ::= LIMIT expr COMMA expr */
178185
-{yymsp[-3].minor.yy454 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy454,yymsp[-2].minor.yy454);}
178573
+{yymsp[-3].minor.yy590 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy590,yymsp[-2].minor.yy590);}
178186178574
break;
178187178575
case 152: /* cmd ::= with DELETE FROM xfullname indexed_opt where_opt_ret */
178188178576
{
178189
- sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy203, &yymsp[-1].minor.yy0);
178190
- sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy203,yymsp[0].minor.yy454,0,0);
178577
+ sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy563, &yymsp[-1].minor.yy0);
178578
+ sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy563,yymsp[0].minor.yy590,0,0);
178191178579
}
178192178580
break;
178193178581
case 157: /* where_opt_ret ::= RETURNING selcollist */
178194
-{sqlite3AddReturning(pParse,yymsp[0].minor.yy14); yymsp[-1].minor.yy454 = 0;}
178582
+{sqlite3AddReturning(pParse,yymsp[0].minor.yy402); yymsp[-1].minor.yy590 = 0;}
178195178583
break;
178196178584
case 158: /* where_opt_ret ::= WHERE expr RETURNING selcollist */
178197
-{sqlite3AddReturning(pParse,yymsp[0].minor.yy14); yymsp[-3].minor.yy454 = yymsp[-2].minor.yy454;}
178585
+{sqlite3AddReturning(pParse,yymsp[0].minor.yy402); yymsp[-3].minor.yy590 = yymsp[-2].minor.yy590;}
178198178586
break;
178199178587
case 159: /* cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist from where_opt_ret */
178200178588
{
178201
- sqlite3SrcListIndexedBy(pParse, yymsp[-5].minor.yy203, &yymsp[-4].minor.yy0);
178202
- sqlite3ExprListCheckLength(pParse,yymsp[-2].minor.yy14,"set list");
178203
- if( yymsp[-1].minor.yy203 ){
178204
- SrcList *pFromClause = yymsp[-1].minor.yy203;
178589
+ sqlite3SrcListIndexedBy(pParse, yymsp[-5].minor.yy563, &yymsp[-4].minor.yy0);
178590
+ sqlite3ExprListCheckLength(pParse,yymsp[-2].minor.yy402,"set list");
178591
+ if( yymsp[-1].minor.yy563 ){
178592
+ SrcList *pFromClause = yymsp[-1].minor.yy563;
178205178593
if( pFromClause->nSrc>1 ){
178206178594
Select *pSubquery;
178207178595
Token as;
178208178596
pSubquery = sqlite3SelectNew(pParse,0,pFromClause,0,0,0,0,SF_NestedFrom,0);
178209178597
as.n = 0;
178210178598
as.z = 0;
178211178599
pFromClause = sqlite3SrcListAppendFromTerm(pParse,0,0,0,&as,pSubquery,0);
178212178600
}
178213
- yymsp[-5].minor.yy203 = sqlite3SrcListAppendList(pParse, yymsp[-5].minor.yy203, pFromClause);
178601
+ yymsp[-5].minor.yy563 = sqlite3SrcListAppendList(pParse, yymsp[-5].minor.yy563, pFromClause);
178214178602
}
178215
- sqlite3Update(pParse,yymsp[-5].minor.yy203,yymsp[-2].minor.yy14,yymsp[0].minor.yy454,yymsp[-6].minor.yy144,0,0,0);
178603
+ sqlite3Update(pParse,yymsp[-5].minor.yy563,yymsp[-2].minor.yy402,yymsp[0].minor.yy590,yymsp[-6].minor.yy502,0,0,0);
178216178604
}
178217178605
break;
178218178606
case 160: /* setlist ::= setlist COMMA nm EQ expr */
178219178607
{
178220
- yymsp[-4].minor.yy14 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy14, yymsp[0].minor.yy454);
178221
- sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy14, &yymsp[-2].minor.yy0, 1);
178608
+ yymsp[-4].minor.yy402 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy402, yymsp[0].minor.yy590);
178609
+ sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy402, &yymsp[-2].minor.yy0, 1);
178222178610
}
178223178611
break;
178224178612
case 161: /* setlist ::= setlist COMMA LP idlist RP EQ expr */
178225178613
{
178226
- yymsp[-6].minor.yy14 = sqlite3ExprListAppendVector(pParse, yymsp[-6].minor.yy14, yymsp[-3].minor.yy132, yymsp[0].minor.yy454);
178614
+ yymsp[-6].minor.yy402 = sqlite3ExprListAppendVector(pParse, yymsp[-6].minor.yy402, yymsp[-3].minor.yy204, yymsp[0].minor.yy590);
178227178615
}
178228178616
break;
178229178617
case 162: /* setlist ::= nm EQ expr */
178230178618
{
178231
- yylhsminor.yy14 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy454);
178232
- sqlite3ExprListSetName(pParse, yylhsminor.yy14, &yymsp[-2].minor.yy0, 1);
178619
+ yylhsminor.yy402 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy590);
178620
+ sqlite3ExprListSetName(pParse, yylhsminor.yy402, &yymsp[-2].minor.yy0, 1);
178233178621
}
178234
- yymsp[-2].minor.yy14 = yylhsminor.yy14;
178622
+ yymsp[-2].minor.yy402 = yylhsminor.yy402;
178235178623
break;
178236178624
case 163: /* setlist ::= LP idlist RP EQ expr */
178237178625
{
178238
- yymsp[-4].minor.yy14 = sqlite3ExprListAppendVector(pParse, 0, yymsp[-3].minor.yy132, yymsp[0].minor.yy454);
178626
+ yymsp[-4].minor.yy402 = sqlite3ExprListAppendVector(pParse, 0, yymsp[-3].minor.yy204, yymsp[0].minor.yy590);
178239178627
}
178240178628
break;
178241178629
case 164: /* cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
178242178630
{
178243
- sqlite3Insert(pParse, yymsp[-3].minor.yy203, yymsp[-1].minor.yy555, yymsp[-2].minor.yy132, yymsp[-5].minor.yy144, yymsp[0].minor.yy122);
178631
+ sqlite3Insert(pParse, yymsp[-3].minor.yy563, yymsp[-1].minor.yy637, yymsp[-2].minor.yy204, yymsp[-5].minor.yy502, yymsp[0].minor.yy403);
178244178632
}
178245178633
break;
178246178634
case 165: /* cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES returning */
178247178635
{
178248
- sqlite3Insert(pParse, yymsp[-4].minor.yy203, 0, yymsp[-3].minor.yy132, yymsp[-6].minor.yy144, 0);
178636
+ sqlite3Insert(pParse, yymsp[-4].minor.yy563, 0, yymsp[-3].minor.yy204, yymsp[-6].minor.yy502, 0);
178249178637
}
178250178638
break;
178251178639
case 166: /* upsert ::= */
178252
-{ yymsp[1].minor.yy122 = 0; }
178640
+{ yymsp[1].minor.yy403 = 0; }
178253178641
break;
178254178642
case 167: /* upsert ::= RETURNING selcollist */
178255
-{ yymsp[-1].minor.yy122 = 0; sqlite3AddReturning(pParse,yymsp[0].minor.yy14); }
178643
+{ yymsp[-1].minor.yy403 = 0; sqlite3AddReturning(pParse,yymsp[0].minor.yy402); }
178256178644
break;
178257178645
case 168: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt upsert */
178258
-{ yymsp[-11].minor.yy122 = sqlite3UpsertNew(pParse->db,yymsp[-8].minor.yy14,yymsp[-6].minor.yy454,yymsp[-2].minor.yy14,yymsp[-1].minor.yy454,yymsp[0].minor.yy122);}
178646
+{ yymsp[-11].minor.yy403 = sqlite3UpsertNew(pParse->db,yymsp[-8].minor.yy402,yymsp[-6].minor.yy590,yymsp[-2].minor.yy402,yymsp[-1].minor.yy590,yymsp[0].minor.yy403);}
178259178647
break;
178260178648
case 169: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING upsert */
178261
-{ yymsp[-8].minor.yy122 = sqlite3UpsertNew(pParse->db,yymsp[-5].minor.yy14,yymsp[-3].minor.yy454,0,0,yymsp[0].minor.yy122); }
178649
+{ yymsp[-8].minor.yy403 = sqlite3UpsertNew(pParse->db,yymsp[-5].minor.yy402,yymsp[-3].minor.yy590,0,0,yymsp[0].minor.yy403); }
178262178650
break;
178263178651
case 170: /* upsert ::= ON CONFLICT DO NOTHING returning */
178264
-{ yymsp[-4].minor.yy122 = sqlite3UpsertNew(pParse->db,0,0,0,0,0); }
178652
+{ yymsp[-4].minor.yy403 = sqlite3UpsertNew(pParse->db,0,0,0,0,0); }
178265178653
break;
178266178654
case 171: /* upsert ::= ON CONFLICT DO UPDATE SET setlist where_opt returning */
178267
-{ yymsp[-7].minor.yy122 = sqlite3UpsertNew(pParse->db,0,0,yymsp[-2].minor.yy14,yymsp[-1].minor.yy454,0);}
178655
+{ yymsp[-7].minor.yy403 = sqlite3UpsertNew(pParse->db,0,0,yymsp[-2].minor.yy402,yymsp[-1].minor.yy590,0);}
178268178656
break;
178269178657
case 172: /* returning ::= RETURNING selcollist */
178270
-{sqlite3AddReturning(pParse,yymsp[0].minor.yy14);}
178658
+{sqlite3AddReturning(pParse,yymsp[0].minor.yy402);}
178271178659
break;
178272178660
case 175: /* idlist_opt ::= */
178273
-{yymsp[1].minor.yy132 = 0;}
178661
+{yymsp[1].minor.yy204 = 0;}
178274178662
break;
178275178663
case 176: /* idlist_opt ::= LP idlist RP */
178276
-{yymsp[-2].minor.yy132 = yymsp[-1].minor.yy132;}
178664
+{yymsp[-2].minor.yy204 = yymsp[-1].minor.yy204;}
178277178665
break;
178278178666
case 177: /* idlist ::= idlist COMMA nm */
178279
-{yymsp[-2].minor.yy132 = sqlite3IdListAppend(pParse,yymsp[-2].minor.yy132,&yymsp[0].minor.yy0);}
178667
+{yymsp[-2].minor.yy204 = sqlite3IdListAppend(pParse,yymsp[-2].minor.yy204,&yymsp[0].minor.yy0);}
178280178668
break;
178281178669
case 178: /* idlist ::= nm */
178282
-{yymsp[0].minor.yy132 = sqlite3IdListAppend(pParse,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/}
178670
+{yymsp[0].minor.yy204 = sqlite3IdListAppend(pParse,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/}
178283178671
break;
178284178672
case 179: /* expr ::= LP expr RP */
178285
-{yymsp[-2].minor.yy454 = yymsp[-1].minor.yy454;}
178673
+{yymsp[-2].minor.yy590 = yymsp[-1].minor.yy590;}
178286178674
break;
178287178675
case 180: /* expr ::= ID|INDEXED|JOIN_KW */
178288
-{yymsp[0].minor.yy454=tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/}
178676
+{yymsp[0].minor.yy590=tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/}
178289178677
break;
178290178678
case 181: /* expr ::= nm DOT nm */
178291178679
{
178292178680
Expr *temp1 = tokenExpr(pParse,TK_ID,yymsp[-2].minor.yy0);
178293178681
Expr *temp2 = tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0);
178294
- yylhsminor.yy454 = sqlite3PExpr(pParse, TK_DOT, temp1, temp2);
178682
+ yylhsminor.yy590 = sqlite3PExpr(pParse, TK_DOT, temp1, temp2);
178295178683
}
178296
- yymsp[-2].minor.yy454 = yylhsminor.yy454;
178684
+ yymsp[-2].minor.yy590 = yylhsminor.yy590;
178297178685
break;
178298178686
case 182: /* expr ::= nm DOT nm DOT nm */
178299178687
{
178300178688
Expr *temp1 = tokenExpr(pParse,TK_ID,yymsp[-4].minor.yy0);
178301178689
Expr *temp2 = tokenExpr(pParse,TK_ID,yymsp[-2].minor.yy0);
@@ -178302,378 +178690,378 @@
178302178690
Expr *temp3 = tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0);
178303178691
Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3);
178304178692
if( IN_RENAME_OBJECT ){
178305178693
sqlite3RenameTokenRemap(pParse, 0, temp1);
178306178694
}
178307
- yylhsminor.yy454 = sqlite3PExpr(pParse, TK_DOT, temp1, temp4);
178695
+ yylhsminor.yy590 = sqlite3PExpr(pParse, TK_DOT, temp1, temp4);
178308178696
}
178309
- yymsp[-4].minor.yy454 = yylhsminor.yy454;
178697
+ yymsp[-4].minor.yy590 = yylhsminor.yy590;
178310178698
break;
178311178699
case 183: /* term ::= NULL|FLOAT|BLOB */
178312178700
case 184: /* term ::= STRING */ yytestcase(yyruleno==184);
178313
-{yymsp[0].minor.yy454=tokenExpr(pParse,yymsp[0].major,yymsp[0].minor.yy0); /*A-overwrites-X*/}
178701
+{yymsp[0].minor.yy590=tokenExpr(pParse,yymsp[0].major,yymsp[0].minor.yy0); /*A-overwrites-X*/}
178314178702
break;
178315178703
case 185: /* term ::= INTEGER */
178316178704
{
178317
- yylhsminor.yy454 = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &yymsp[0].minor.yy0, 1);
178318
- if( yylhsminor.yy454 ) yylhsminor.yy454->w.iOfst = (int)(yymsp[0].minor.yy0.z - pParse->zTail);
178705
+ yylhsminor.yy590 = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &yymsp[0].minor.yy0, 1);
178706
+ if( yylhsminor.yy590 ) yylhsminor.yy590->w.iOfst = (int)(yymsp[0].minor.yy0.z - pParse->zTail);
178319178707
}
178320
- yymsp[0].minor.yy454 = yylhsminor.yy454;
178708
+ yymsp[0].minor.yy590 = yylhsminor.yy590;
178321178709
break;
178322178710
case 186: /* expr ::= VARIABLE */
178323178711
{
178324178712
if( !(yymsp[0].minor.yy0.z[0]=='#' && sqlite3Isdigit(yymsp[0].minor.yy0.z[1])) ){
178325178713
u32 n = yymsp[0].minor.yy0.n;
178326
- yymsp[0].minor.yy454 = tokenExpr(pParse, TK_VARIABLE, yymsp[0].minor.yy0);
178327
- sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy454, n);
178714
+ yymsp[0].minor.yy590 = tokenExpr(pParse, TK_VARIABLE, yymsp[0].minor.yy0);
178715
+ sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy590, n);
178328178716
}else{
178329178717
/* When doing a nested parse, one can include terms in an expression
178330178718
** that look like this: #1 #2 ... These terms refer to registers
178331178719
** in the virtual machine. #N is the N-th register. */
178332178720
Token t = yymsp[0].minor.yy0; /*A-overwrites-X*/
178333178721
assert( t.n>=2 );
178334178722
if( pParse->nested==0 ){
178335178723
parserSyntaxError(pParse, &t);
178336
- yymsp[0].minor.yy454 = 0;
178724
+ yymsp[0].minor.yy590 = 0;
178337178725
}else{
178338
- yymsp[0].minor.yy454 = sqlite3PExpr(pParse, TK_REGISTER, 0, 0);
178339
- if( yymsp[0].minor.yy454 ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy454->iTable);
178726
+ yymsp[0].minor.yy590 = sqlite3PExpr(pParse, TK_REGISTER, 0, 0);
178727
+ if( yymsp[0].minor.yy590 ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy590->iTable);
178340178728
}
178341178729
}
178342178730
}
178343178731
break;
178344178732
case 187: /* expr ::= expr COLLATE ID|STRING */
178345178733
{
178346
- yymsp[-2].minor.yy454 = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy454, &yymsp[0].minor.yy0, 1);
178734
+ yymsp[-2].minor.yy590 = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy590, &yymsp[0].minor.yy0, 1);
178347178735
}
178348178736
break;
178349178737
case 188: /* expr ::= CAST LP expr AS typetoken RP */
178350178738
{
178351
- yymsp[-5].minor.yy454 = sqlite3ExprAlloc(pParse->db, TK_CAST, &yymsp[-1].minor.yy0, 1);
178352
- sqlite3ExprAttachSubtrees(pParse->db, yymsp[-5].minor.yy454, yymsp[-3].minor.yy454, 0);
178739
+ yymsp[-5].minor.yy590 = sqlite3ExprAlloc(pParse->db, TK_CAST, &yymsp[-1].minor.yy0, 1);
178740
+ sqlite3ExprAttachSubtrees(pParse->db, yymsp[-5].minor.yy590, yymsp[-3].minor.yy590, 0);
178353178741
}
178354178742
break;
178355178743
case 189: /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP */
178356178744
{
178357
- yylhsminor.yy454 = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy14, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy144);
178745
+ yylhsminor.yy590 = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy402, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy502);
178358178746
}
178359
- yymsp[-4].minor.yy454 = yylhsminor.yy454;
178747
+ yymsp[-4].minor.yy590 = yylhsminor.yy590;
178360178748
break;
178361178749
case 190: /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP */
178362178750
{
178363
- yylhsminor.yy454 = sqlite3ExprFunction(pParse, yymsp[-4].minor.yy14, &yymsp[-7].minor.yy0, yymsp[-5].minor.yy144);
178364
- sqlite3ExprAddFunctionOrderBy(pParse, yylhsminor.yy454, yymsp[-1].minor.yy14);
178751
+ yylhsminor.yy590 = sqlite3ExprFunction(pParse, yymsp[-4].minor.yy402, &yymsp[-7].minor.yy0, yymsp[-5].minor.yy502);
178752
+ sqlite3ExprAddFunctionOrderBy(pParse, yylhsminor.yy590, yymsp[-1].minor.yy402);
178365178753
}
178366
- yymsp[-7].minor.yy454 = yylhsminor.yy454;
178754
+ yymsp[-7].minor.yy590 = yylhsminor.yy590;
178367178755
break;
178368178756
case 191: /* expr ::= ID|INDEXED|JOIN_KW LP STAR RP */
178369178757
{
178370
- yylhsminor.yy454 = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0, 0);
178758
+ yylhsminor.yy590 = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0, 0);
178371178759
}
178372
- yymsp[-3].minor.yy454 = yylhsminor.yy454;
178760
+ yymsp[-3].minor.yy590 = yylhsminor.yy590;
178373178761
break;
178374178762
case 192: /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP filter_over */
178375178763
{
178376
- yylhsminor.yy454 = sqlite3ExprFunction(pParse, yymsp[-2].minor.yy14, &yymsp[-5].minor.yy0, yymsp[-3].minor.yy144);
178377
- sqlite3WindowAttach(pParse, yylhsminor.yy454, yymsp[0].minor.yy211);
178764
+ yylhsminor.yy590 = sqlite3ExprFunction(pParse, yymsp[-2].minor.yy402, &yymsp[-5].minor.yy0, yymsp[-3].minor.yy502);
178765
+ sqlite3WindowAttach(pParse, yylhsminor.yy590, yymsp[0].minor.yy483);
178378178766
}
178379
- yymsp[-5].minor.yy454 = yylhsminor.yy454;
178767
+ yymsp[-5].minor.yy590 = yylhsminor.yy590;
178380178768
break;
178381178769
case 193: /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP filter_over */
178382178770
{
178383
- yylhsminor.yy454 = sqlite3ExprFunction(pParse, yymsp[-5].minor.yy14, &yymsp[-8].minor.yy0, yymsp[-6].minor.yy144);
178384
- sqlite3WindowAttach(pParse, yylhsminor.yy454, yymsp[0].minor.yy211);
178385
- sqlite3ExprAddFunctionOrderBy(pParse, yylhsminor.yy454, yymsp[-2].minor.yy14);
178771
+ yylhsminor.yy590 = sqlite3ExprFunction(pParse, yymsp[-5].minor.yy402, &yymsp[-8].minor.yy0, yymsp[-6].minor.yy502);
178772
+ sqlite3WindowAttach(pParse, yylhsminor.yy590, yymsp[0].minor.yy483);
178773
+ sqlite3ExprAddFunctionOrderBy(pParse, yylhsminor.yy590, yymsp[-2].minor.yy402);
178386178774
}
178387
- yymsp[-8].minor.yy454 = yylhsminor.yy454;
178775
+ yymsp[-8].minor.yy590 = yylhsminor.yy590;
178388178776
break;
178389178777
case 194: /* expr ::= ID|INDEXED|JOIN_KW LP STAR RP filter_over */
178390178778
{
178391
- yylhsminor.yy454 = sqlite3ExprFunction(pParse, 0, &yymsp[-4].minor.yy0, 0);
178392
- sqlite3WindowAttach(pParse, yylhsminor.yy454, yymsp[0].minor.yy211);
178779
+ yylhsminor.yy590 = sqlite3ExprFunction(pParse, 0, &yymsp[-4].minor.yy0, 0);
178780
+ sqlite3WindowAttach(pParse, yylhsminor.yy590, yymsp[0].minor.yy483);
178393178781
}
178394
- yymsp[-4].minor.yy454 = yylhsminor.yy454;
178782
+ yymsp[-4].minor.yy590 = yylhsminor.yy590;
178395178783
break;
178396178784
case 195: /* term ::= CTIME_KW */
178397178785
{
178398
- yylhsminor.yy454 = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0, 0);
178786
+ yylhsminor.yy590 = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0, 0);
178399178787
}
178400
- yymsp[0].minor.yy454 = yylhsminor.yy454;
178788
+ yymsp[0].minor.yy590 = yylhsminor.yy590;
178401178789
break;
178402178790
case 196: /* expr ::= LP nexprlist COMMA expr RP */
178403178791
{
178404
- ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy14, yymsp[-1].minor.yy454);
178405
- yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_VECTOR, 0, 0);
178406
- if( yymsp[-4].minor.yy454 ){
178407
- yymsp[-4].minor.yy454->x.pList = pList;
178792
+ ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy402, yymsp[-1].minor.yy590);
178793
+ yymsp[-4].minor.yy590 = sqlite3PExpr(pParse, TK_VECTOR, 0, 0);
178794
+ if( yymsp[-4].minor.yy590 ){
178795
+ yymsp[-4].minor.yy590->x.pList = pList;
178408178796
if( ALWAYS(pList->nExpr) ){
178409
- yymsp[-4].minor.yy454->flags |= pList->a[0].pExpr->flags & EP_Propagate;
178797
+ yymsp[-4].minor.yy590->flags |= pList->a[0].pExpr->flags & EP_Propagate;
178410178798
}
178411178799
}else{
178412178800
sqlite3ExprListDelete(pParse->db, pList);
178413178801
}
178414178802
}
178415178803
break;
178416178804
case 197: /* expr ::= expr AND expr */
178417
-{yymsp[-2].minor.yy454=sqlite3ExprAnd(pParse,yymsp[-2].minor.yy454,yymsp[0].minor.yy454);}
178805
+{yymsp[-2].minor.yy590=sqlite3ExprAnd(pParse,yymsp[-2].minor.yy590,yymsp[0].minor.yy590);}
178418178806
break;
178419178807
case 198: /* expr ::= expr OR expr */
178420178808
case 199: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==199);
178421178809
case 200: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==200);
178422178810
case 201: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==201);
178423178811
case 202: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==202);
178424178812
case 203: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==203);
178425178813
case 204: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==204);
178426
-{yymsp[-2].minor.yy454=sqlite3PExpr(pParse,yymsp[-1].major,yymsp[-2].minor.yy454,yymsp[0].minor.yy454);}
178814
+{yymsp[-2].minor.yy590=sqlite3PExpr(pParse,yymsp[-1].major,yymsp[-2].minor.yy590,yymsp[0].minor.yy590);}
178427178815
break;
178428178816
case 205: /* likeop ::= NOT LIKE_KW|MATCH */
178429178817
{yymsp[-1].minor.yy0=yymsp[0].minor.yy0; yymsp[-1].minor.yy0.n|=0x80000000; /*yymsp[-1].minor.yy0-overwrite-yymsp[0].minor.yy0*/}
178430178818
break;
178431178819
case 206: /* expr ::= expr likeop expr */
178432178820
{
178433178821
ExprList *pList;
178434178822
int bNot = yymsp[-1].minor.yy0.n & 0x80000000;
178435178823
yymsp[-1].minor.yy0.n &= 0x7fffffff;
178436
- pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy454);
178437
- pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy454);
178438
- yymsp[-2].minor.yy454 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0, 0);
178439
- if( bNot ) yymsp[-2].minor.yy454 = sqlite3PExpr(pParse, TK_NOT, yymsp[-2].minor.yy454, 0);
178440
- if( yymsp[-2].minor.yy454 ) yymsp[-2].minor.yy454->flags |= EP_InfixFunc;
178824
+ pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy590);
178825
+ pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy590);
178826
+ yymsp[-2].minor.yy590 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0, 0);
178827
+ if( bNot ) yymsp[-2].minor.yy590 = sqlite3PExpr(pParse, TK_NOT, yymsp[-2].minor.yy590, 0);
178828
+ if( yymsp[-2].minor.yy590 ) yymsp[-2].minor.yy590->flags |= EP_InfixFunc;
178441178829
}
178442178830
break;
178443178831
case 207: /* expr ::= expr likeop expr ESCAPE expr */
178444178832
{
178445178833
ExprList *pList;
178446178834
int bNot = yymsp[-3].minor.yy0.n & 0x80000000;
178447178835
yymsp[-3].minor.yy0.n &= 0x7fffffff;
178448
- pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy454);
178449
- pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy454);
178450
- pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy454);
178451
- yymsp[-4].minor.yy454 = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy0, 0);
178452
- if( bNot ) yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy454, 0);
178453
- if( yymsp[-4].minor.yy454 ) yymsp[-4].minor.yy454->flags |= EP_InfixFunc;
178836
+ pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy590);
178837
+ pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy590);
178838
+ pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy590);
178839
+ yymsp[-4].minor.yy590 = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy0, 0);
178840
+ if( bNot ) yymsp[-4].minor.yy590 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy590, 0);
178841
+ if( yymsp[-4].minor.yy590 ) yymsp[-4].minor.yy590->flags |= EP_InfixFunc;
178454178842
}
178455178843
break;
178456178844
case 208: /* expr ::= expr ISNULL|NOTNULL */
178457
-{yymsp[-1].minor.yy454 = sqlite3PExpr(pParse,yymsp[0].major,yymsp[-1].minor.yy454,0);}
178845
+{yymsp[-1].minor.yy590 = sqlite3PExpr(pParse,yymsp[0].major,yymsp[-1].minor.yy590,0);}
178458178846
break;
178459178847
case 209: /* expr ::= expr NOT NULL */
178460
-{yymsp[-2].minor.yy454 = sqlite3PExpr(pParse,TK_NOTNULL,yymsp[-2].minor.yy454,0);}
178848
+{yymsp[-2].minor.yy590 = sqlite3PExpr(pParse,TK_NOTNULL,yymsp[-2].minor.yy590,0);}
178461178849
break;
178462178850
case 210: /* expr ::= expr IS expr */
178463178851
{
178464
- yymsp[-2].minor.yy454 = sqlite3PExpr(pParse,TK_IS,yymsp[-2].minor.yy454,yymsp[0].minor.yy454);
178465
- binaryToUnaryIfNull(pParse, yymsp[0].minor.yy454, yymsp[-2].minor.yy454, TK_ISNULL);
178852
+ yymsp[-2].minor.yy590 = sqlite3PExpr(pParse,TK_IS,yymsp[-2].minor.yy590,yymsp[0].minor.yy590);
178853
+ binaryToUnaryIfNull(pParse, yymsp[0].minor.yy590, yymsp[-2].minor.yy590, TK_ISNULL);
178466178854
}
178467178855
break;
178468178856
case 211: /* expr ::= expr IS NOT expr */
178469178857
{
178470
- yymsp[-3].minor.yy454 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-3].minor.yy454,yymsp[0].minor.yy454);
178471
- binaryToUnaryIfNull(pParse, yymsp[0].minor.yy454, yymsp[-3].minor.yy454, TK_NOTNULL);
178858
+ yymsp[-3].minor.yy590 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-3].minor.yy590,yymsp[0].minor.yy590);
178859
+ binaryToUnaryIfNull(pParse, yymsp[0].minor.yy590, yymsp[-3].minor.yy590, TK_NOTNULL);
178472178860
}
178473178861
break;
178474178862
case 212: /* expr ::= expr IS NOT DISTINCT FROM expr */
178475178863
{
178476
- yymsp[-5].minor.yy454 = sqlite3PExpr(pParse,TK_IS,yymsp[-5].minor.yy454,yymsp[0].minor.yy454);
178477
- binaryToUnaryIfNull(pParse, yymsp[0].minor.yy454, yymsp[-5].minor.yy454, TK_ISNULL);
178864
+ yymsp[-5].minor.yy590 = sqlite3PExpr(pParse,TK_IS,yymsp[-5].minor.yy590,yymsp[0].minor.yy590);
178865
+ binaryToUnaryIfNull(pParse, yymsp[0].minor.yy590, yymsp[-5].minor.yy590, TK_ISNULL);
178478178866
}
178479178867
break;
178480178868
case 213: /* expr ::= expr IS DISTINCT FROM expr */
178481178869
{
178482
- yymsp[-4].minor.yy454 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-4].minor.yy454,yymsp[0].minor.yy454);
178483
- binaryToUnaryIfNull(pParse, yymsp[0].minor.yy454, yymsp[-4].minor.yy454, TK_NOTNULL);
178870
+ yymsp[-4].minor.yy590 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-4].minor.yy590,yymsp[0].minor.yy590);
178871
+ binaryToUnaryIfNull(pParse, yymsp[0].minor.yy590, yymsp[-4].minor.yy590, TK_NOTNULL);
178484178872
}
178485178873
break;
178486178874
case 214: /* expr ::= NOT expr */
178487178875
case 215: /* expr ::= BITNOT expr */ yytestcase(yyruleno==215);
178488
-{yymsp[-1].minor.yy454 = sqlite3PExpr(pParse, yymsp[-1].major, yymsp[0].minor.yy454, 0);/*A-overwrites-B*/}
178876
+{yymsp[-1].minor.yy590 = sqlite3PExpr(pParse, yymsp[-1].major, yymsp[0].minor.yy590, 0);/*A-overwrites-B*/}
178489178877
break;
178490178878
case 216: /* expr ::= PLUS|MINUS expr */
178491178879
{
178492
- Expr *p = yymsp[0].minor.yy454;
178880
+ Expr *p = yymsp[0].minor.yy590;
178493178881
u8 op = yymsp[-1].major + (TK_UPLUS-TK_PLUS);
178494178882
assert( TK_UPLUS>TK_PLUS );
178495178883
assert( TK_UMINUS == TK_MINUS + (TK_UPLUS - TK_PLUS) );
178496178884
if( p && p->op==TK_UPLUS ){
178497178885
p->op = op;
178498
- yymsp[-1].minor.yy454 = p;
178886
+ yymsp[-1].minor.yy590 = p;
178499178887
}else{
178500
- yymsp[-1].minor.yy454 = sqlite3PExpr(pParse, op, p, 0);
178888
+ yymsp[-1].minor.yy590 = sqlite3PExpr(pParse, op, p, 0);
178501178889
/*A-overwrites-B*/
178502178890
}
178503178891
}
178504178892
break;
178505178893
case 217: /* expr ::= expr PTR expr */
178506178894
{
178507
- ExprList *pList = sqlite3ExprListAppend(pParse, 0, yymsp[-2].minor.yy454);
178508
- pList = sqlite3ExprListAppend(pParse, pList, yymsp[0].minor.yy454);
178509
- yylhsminor.yy454 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0, 0);
178895
+ ExprList *pList = sqlite3ExprListAppend(pParse, 0, yymsp[-2].minor.yy590);
178896
+ pList = sqlite3ExprListAppend(pParse, pList, yymsp[0].minor.yy590);
178897
+ yylhsminor.yy590 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0, 0);
178510178898
}
178511
- yymsp[-2].minor.yy454 = yylhsminor.yy454;
178899
+ yymsp[-2].minor.yy590 = yylhsminor.yy590;
178512178900
break;
178513178901
case 218: /* between_op ::= BETWEEN */
178514178902
case 221: /* in_op ::= IN */ yytestcase(yyruleno==221);
178515
-{yymsp[0].minor.yy144 = 0;}
178903
+{yymsp[0].minor.yy502 = 0;}
178516178904
break;
178517178905
case 220: /* expr ::= expr between_op expr AND expr */
178518178906
{
178519
- ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy454);
178520
- pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy454);
178521
- yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy454, 0);
178522
- if( yymsp[-4].minor.yy454 ){
178523
- yymsp[-4].minor.yy454->x.pList = pList;
178907
+ ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy590);
178908
+ pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy590);
178909
+ yymsp[-4].minor.yy590 = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy590, 0);
178910
+ if( yymsp[-4].minor.yy590 ){
178911
+ yymsp[-4].minor.yy590->x.pList = pList;
178524178912
}else{
178525178913
sqlite3ExprListDelete(pParse->db, pList);
178526178914
}
178527
- if( yymsp[-3].minor.yy144 ) yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy454, 0);
178915
+ if( yymsp[-3].minor.yy502 ) yymsp[-4].minor.yy590 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy590, 0);
178528178916
}
178529178917
break;
178530178918
case 223: /* expr ::= expr in_op LP exprlist RP */
178531178919
{
178532
- if( yymsp[-1].minor.yy14==0 ){
178920
+ if( yymsp[-1].minor.yy402==0 ){
178533178921
/* Expressions of the form
178534178922
**
178535178923
** expr1 IN ()
178536178924
** expr1 NOT IN ()
178537178925
**
178538178926
** simplify to constants 0 (false) and 1 (true), respectively,
178539178927
** regardless of the value of expr1.
178540178928
*/
178541
- sqlite3ExprUnmapAndDelete(pParse, yymsp[-4].minor.yy454);
178542
- yymsp[-4].minor.yy454 = sqlite3Expr(pParse->db, TK_STRING, yymsp[-3].minor.yy144 ? "true" : "false");
178543
- if( yymsp[-4].minor.yy454 ) sqlite3ExprIdToTrueFalse(yymsp[-4].minor.yy454);
178929
+ sqlite3ExprUnmapAndDelete(pParse, yymsp[-4].minor.yy590);
178930
+ yymsp[-4].minor.yy590 = sqlite3Expr(pParse->db, TK_STRING, yymsp[-3].minor.yy502 ? "true" : "false");
178931
+ if( yymsp[-4].minor.yy590 ) sqlite3ExprIdToTrueFalse(yymsp[-4].minor.yy590);
178544178932
}else{
178545
- Expr *pRHS = yymsp[-1].minor.yy14->a[0].pExpr;
178546
- if( yymsp[-1].minor.yy14->nExpr==1 && sqlite3ExprIsConstant(pParse,pRHS) && yymsp[-4].minor.yy454->op!=TK_VECTOR ){
178547
- yymsp[-1].minor.yy14->a[0].pExpr = 0;
178548
- sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy14);
178933
+ Expr *pRHS = yymsp[-1].minor.yy402->a[0].pExpr;
178934
+ if( yymsp[-1].minor.yy402->nExpr==1 && sqlite3ExprIsConstant(pParse,pRHS) && yymsp[-4].minor.yy590->op!=TK_VECTOR ){
178935
+ yymsp[-1].minor.yy402->a[0].pExpr = 0;
178936
+ sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy402);
178549178937
pRHS = sqlite3PExpr(pParse, TK_UPLUS, pRHS, 0);
178550
- yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_EQ, yymsp[-4].minor.yy454, pRHS);
178551
- }else if( yymsp[-1].minor.yy14->nExpr==1 && pRHS->op==TK_SELECT ){
178552
- yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy454, 0);
178553
- sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy454, pRHS->x.pSelect);
178938
+ yymsp[-4].minor.yy590 = sqlite3PExpr(pParse, TK_EQ, yymsp[-4].minor.yy590, pRHS);
178939
+ }else if( yymsp[-1].minor.yy402->nExpr==1 && pRHS->op==TK_SELECT ){
178940
+ yymsp[-4].minor.yy590 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy590, 0);
178941
+ sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy590, pRHS->x.pSelect);
178554178942
pRHS->x.pSelect = 0;
178555
- sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy14);
178943
+ sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy402);
178556178944
}else{
178557
- yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy454, 0);
178558
- if( yymsp[-4].minor.yy454==0 ){
178559
- sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy14);
178560
- }else if( yymsp[-4].minor.yy454->pLeft->op==TK_VECTOR ){
178561
- int nExpr = yymsp[-4].minor.yy454->pLeft->x.pList->nExpr;
178562
- Select *pSelectRHS = sqlite3ExprListToValues(pParse, nExpr, yymsp[-1].minor.yy14);
178945
+ yymsp[-4].minor.yy590 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy590, 0);
178946
+ if( yymsp[-4].minor.yy590==0 ){
178947
+ sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy402);
178948
+ }else if( yymsp[-4].minor.yy590->pLeft->op==TK_VECTOR ){
178949
+ int nExpr = yymsp[-4].minor.yy590->pLeft->x.pList->nExpr;
178950
+ Select *pSelectRHS = sqlite3ExprListToValues(pParse, nExpr, yymsp[-1].minor.yy402);
178563178951
if( pSelectRHS ){
178564178952
parserDoubleLinkSelect(pParse, pSelectRHS);
178565
- sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy454, pSelectRHS);
178953
+ sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy590, pSelectRHS);
178566178954
}
178567178955
}else{
178568
- yymsp[-4].minor.yy454->x.pList = yymsp[-1].minor.yy14;
178569
- sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy454);
178956
+ yymsp[-4].minor.yy590->x.pList = yymsp[-1].minor.yy402;
178957
+ sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy590);
178570178958
}
178571178959
}
178572
- if( yymsp[-3].minor.yy144 ) yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy454, 0);
178960
+ if( yymsp[-3].minor.yy502 ) yymsp[-4].minor.yy590 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy590, 0);
178573178961
}
178574178962
}
178575178963
break;
178576178964
case 224: /* expr ::= LP select RP */
178577178965
{
178578
- yymsp[-2].minor.yy454 = sqlite3PExpr(pParse, TK_SELECT, 0, 0);
178579
- sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy454, yymsp[-1].minor.yy555);
178966
+ yymsp[-2].minor.yy590 = sqlite3PExpr(pParse, TK_SELECT, 0, 0);
178967
+ sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy590, yymsp[-1].minor.yy637);
178580178968
}
178581178969
break;
178582178970
case 225: /* expr ::= expr in_op LP select RP */
178583178971
{
178584
- yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy454, 0);
178585
- sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy454, yymsp[-1].minor.yy555);
178586
- if( yymsp[-3].minor.yy144 ) yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy454, 0);
178972
+ yymsp[-4].minor.yy590 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy590, 0);
178973
+ sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy590, yymsp[-1].minor.yy637);
178974
+ if( yymsp[-3].minor.yy502 ) yymsp[-4].minor.yy590 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy590, 0);
178587178975
}
178588178976
break;
178589178977
case 226: /* expr ::= expr in_op nm dbnm paren_exprlist */
178590178978
{
178591178979
SrcList *pSrc = sqlite3SrcListAppend(pParse, 0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);
178592178980
Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0);
178593
- if( yymsp[0].minor.yy14 ) sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy14);
178594
- yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy454, 0);
178595
- sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy454, pSelect);
178596
- if( yymsp[-3].minor.yy144 ) yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy454, 0);
178981
+ if( yymsp[0].minor.yy402 ) sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy402);
178982
+ yymsp[-4].minor.yy590 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy590, 0);
178983
+ sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy590, pSelect);
178984
+ if( yymsp[-3].minor.yy502 ) yymsp[-4].minor.yy590 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy590, 0);
178597178985
}
178598178986
break;
178599178987
case 227: /* expr ::= EXISTS LP select RP */
178600178988
{
178601178989
Expr *p;
178602
- p = yymsp[-3].minor.yy454 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0);
178603
- sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy555);
178990
+ p = yymsp[-3].minor.yy590 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0);
178991
+ sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy637);
178604178992
}
178605178993
break;
178606178994
case 228: /* expr ::= CASE case_operand case_exprlist case_else END */
178607178995
{
178608
- yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy454, 0);
178609
- if( yymsp[-4].minor.yy454 ){
178610
- yymsp[-4].minor.yy454->x.pList = yymsp[-1].minor.yy454 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy14,yymsp[-1].minor.yy454) : yymsp[-2].minor.yy14;
178611
- sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy454);
178996
+ yymsp[-4].minor.yy590 = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy590, 0);
178997
+ if( yymsp[-4].minor.yy590 ){
178998
+ yymsp[-4].minor.yy590->x.pList = yymsp[-1].minor.yy590 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy402,yymsp[-1].minor.yy590) : yymsp[-2].minor.yy402;
178999
+ sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy590);
178612179000
}else{
178613
- sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy14);
178614
- sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy454);
179001
+ sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy402);
179002
+ sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy590);
178615179003
}
178616179004
}
178617179005
break;
178618179006
case 229: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
178619179007
{
178620
- yymsp[-4].minor.yy14 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy14, yymsp[-2].minor.yy454);
178621
- yymsp[-4].minor.yy14 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy14, yymsp[0].minor.yy454);
179008
+ yymsp[-4].minor.yy402 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy402, yymsp[-2].minor.yy590);
179009
+ yymsp[-4].minor.yy402 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy402, yymsp[0].minor.yy590);
178622179010
}
178623179011
break;
178624179012
case 230: /* case_exprlist ::= WHEN expr THEN expr */
178625179013
{
178626
- yymsp[-3].minor.yy14 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy454);
178627
- yymsp[-3].minor.yy14 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy14, yymsp[0].minor.yy454);
179014
+ yymsp[-3].minor.yy402 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy590);
179015
+ yymsp[-3].minor.yy402 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy402, yymsp[0].minor.yy590);
178628179016
}
178629179017
break;
178630179018
case 235: /* nexprlist ::= nexprlist COMMA expr */
178631
-{yymsp[-2].minor.yy14 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy14,yymsp[0].minor.yy454);}
179019
+{yymsp[-2].minor.yy402 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy402,yymsp[0].minor.yy590);}
178632179020
break;
178633179021
case 236: /* nexprlist ::= expr */
178634
-{yymsp[0].minor.yy14 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy454); /*A-overwrites-Y*/}
179022
+{yymsp[0].minor.yy402 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy590); /*A-overwrites-Y*/}
178635179023
break;
178636179024
case 238: /* paren_exprlist ::= LP exprlist RP */
178637179025
case 243: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==243);
178638
-{yymsp[-2].minor.yy14 = yymsp[-1].minor.yy14;}
179026
+{yymsp[-2].minor.yy402 = yymsp[-1].minor.yy402;}
178639179027
break;
178640179028
case 239: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
178641179029
{
178642179030
sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0,
178643
- sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy14, yymsp[-10].minor.yy144,
178644
- &yymsp[-11].minor.yy0, yymsp[0].minor.yy454, SQLITE_SO_ASC, yymsp[-8].minor.yy144, SQLITE_IDXTYPE_APPDEF);
179031
+ sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy402, yymsp[-10].minor.yy502,
179032
+ &yymsp[-11].minor.yy0, yymsp[0].minor.yy590, SQLITE_SO_ASC, yymsp[-8].minor.yy502, SQLITE_IDXTYPE_APPDEF);
178645179033
if( IN_RENAME_OBJECT && pParse->pNewIndex ){
178646179034
sqlite3RenameTokenMap(pParse, pParse->pNewIndex->zName, &yymsp[-4].minor.yy0);
178647179035
}
178648179036
}
178649179037
break;
178650179038
case 240: /* uniqueflag ::= UNIQUE */
178651179039
case 282: /* raisetype ::= ABORT */ yytestcase(yyruleno==282);
178652
-{yymsp[0].minor.yy144 = OE_Abort;}
179040
+{yymsp[0].minor.yy502 = OE_Abort;}
178653179041
break;
178654179042
case 241: /* uniqueflag ::= */
178655
-{yymsp[1].minor.yy144 = OE_None;}
179043
+{yymsp[1].minor.yy502 = OE_None;}
178656179044
break;
178657179045
case 244: /* eidlist ::= eidlist COMMA nm collate sortorder */
178658179046
{
178659
- yymsp[-4].minor.yy14 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy14, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy144, yymsp[0].minor.yy144);
179047
+ yymsp[-4].minor.yy402 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy402, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy502, yymsp[0].minor.yy502);
178660179048
}
178661179049
break;
178662179050
case 245: /* eidlist ::= nm collate sortorder */
178663179051
{
178664
- yymsp[-2].minor.yy14 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy144, yymsp[0].minor.yy144); /*A-overwrites-Y*/
179052
+ yymsp[-2].minor.yy402 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy502, yymsp[0].minor.yy502); /*A-overwrites-Y*/
178665179053
}
178666179054
break;
178667179055
case 248: /* cmd ::= DROP INDEX ifexists fullname */
178668
-{sqlite3DropIndex(pParse, yymsp[0].minor.yy203, yymsp[-1].minor.yy144);}
179056
+{sqlite3DropIndex(pParse, yymsp[0].minor.yy563, yymsp[-1].minor.yy502);}
178669179057
break;
178670179058
case 249: /* cmd ::= VACUUM vinto */
178671
-{sqlite3Vacuum(pParse,0,yymsp[0].minor.yy454);}
179059
+{sqlite3Vacuum(pParse,0,yymsp[0].minor.yy590);}
178672179060
break;
178673179061
case 250: /* cmd ::= VACUUM nm vinto */
178674
-{sqlite3Vacuum(pParse,&yymsp[-1].minor.yy0,yymsp[0].minor.yy454);}
179062
+{sqlite3Vacuum(pParse,&yymsp[-1].minor.yy0,yymsp[0].minor.yy590);}
178675179063
break;
178676179064
case 253: /* cmd ::= PRAGMA nm dbnm */
178677179065
{sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);}
178678179066
break;
178679179067
case 254: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
@@ -178691,54 +179079,58 @@
178691179079
case 260: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
178692179080
{
178693179081
Token all;
178694179082
all.z = yymsp[-3].minor.yy0.z;
178695179083
all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n;
178696
- sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy427, &all);
179084
+ sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy319, &all);
178697179085
}
178698179086
break;
178699179087
case 261: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
178700179088
{
178701
- sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy144, yymsp[-4].minor.yy286.a, yymsp[-4].minor.yy286.b, yymsp[-2].minor.yy203, yymsp[0].minor.yy454, yymsp[-10].minor.yy144, yymsp[-8].minor.yy144);
179089
+ sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy502, yymsp[-4].minor.yy28.a, yymsp[-4].minor.yy28.b, yymsp[-2].minor.yy563, yymsp[0].minor.yy590, yymsp[-10].minor.yy502, yymsp[-8].minor.yy502);
178702179090
yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/
179091
+#ifdef SQLITE_DEBUG
179092
+ assert( pParse->isCreate ); /* Set by createkw reduce action */
179093
+ pParse->isCreate = 0; /* But, should not be set for CREATE TRIGGER */
179094
+#endif
178703179095
}
178704179096
break;
178705179097
case 262: /* trigger_time ::= BEFORE|AFTER */
178706
-{ yymsp[0].minor.yy144 = yymsp[0].major; /*A-overwrites-X*/ }
179098
+{ yymsp[0].minor.yy502 = yymsp[0].major; /*A-overwrites-X*/ }
178707179099
break;
178708179100
case 263: /* trigger_time ::= INSTEAD OF */
178709
-{ yymsp[-1].minor.yy144 = TK_INSTEAD;}
179101
+{ yymsp[-1].minor.yy502 = TK_INSTEAD;}
178710179102
break;
178711179103
case 264: /* trigger_time ::= */
178712
-{ yymsp[1].minor.yy144 = TK_BEFORE; }
179104
+{ yymsp[1].minor.yy502 = TK_BEFORE; }
178713179105
break;
178714179106
case 265: /* trigger_event ::= DELETE|INSERT */
178715179107
case 266: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==266);
178716
-{yymsp[0].minor.yy286.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy286.b = 0;}
179108
+{yymsp[0].minor.yy28.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy28.b = 0;}
178717179109
break;
178718179110
case 267: /* trigger_event ::= UPDATE OF idlist */
178719
-{yymsp[-2].minor.yy286.a = TK_UPDATE; yymsp[-2].minor.yy286.b = yymsp[0].minor.yy132;}
179111
+{yymsp[-2].minor.yy28.a = TK_UPDATE; yymsp[-2].minor.yy28.b = yymsp[0].minor.yy204;}
178720179112
break;
178721179113
case 268: /* when_clause ::= */
178722179114
case 287: /* key_opt ::= */ yytestcase(yyruleno==287);
178723
-{ yymsp[1].minor.yy454 = 0; }
179115
+{ yymsp[1].minor.yy590 = 0; }
178724179116
break;
178725179117
case 269: /* when_clause ::= WHEN expr */
178726179118
case 288: /* key_opt ::= KEY expr */ yytestcase(yyruleno==288);
178727
-{ yymsp[-1].minor.yy454 = yymsp[0].minor.yy454; }
179119
+{ yymsp[-1].minor.yy590 = yymsp[0].minor.yy590; }
178728179120
break;
178729179121
case 270: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
178730179122
{
178731
- assert( yymsp[-2].minor.yy427!=0 );
178732
- yymsp[-2].minor.yy427->pLast->pNext = yymsp[-1].minor.yy427;
178733
- yymsp[-2].minor.yy427->pLast = yymsp[-1].minor.yy427;
179123
+ assert( yymsp[-2].minor.yy319!=0 );
179124
+ yymsp[-2].minor.yy319->pLast->pNext = yymsp[-1].minor.yy319;
179125
+ yymsp[-2].minor.yy319->pLast = yymsp[-1].minor.yy319;
178734179126
}
178735179127
break;
178736179128
case 271: /* trigger_cmd_list ::= trigger_cmd SEMI */
178737179129
{
178738
- assert( yymsp[-1].minor.yy427!=0 );
178739
- yymsp[-1].minor.yy427->pLast = yymsp[-1].minor.yy427;
179130
+ assert( yymsp[-1].minor.yy319!=0 );
179131
+ yymsp[-1].minor.yy319->pLast = yymsp[-1].minor.yy319;
178740179132
}
178741179133
break;
178742179134
case 272: /* trnm ::= nm DOT nm */
178743179135
{
178744179136
yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;
@@ -178760,62 +179152,62 @@
178760179152
"the NOT INDEXED clause is not allowed on UPDATE or DELETE statements "
178761179153
"within triggers");
178762179154
}
178763179155
break;
178764179156
case 275: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */
178765
-{yylhsminor.yy427 = sqlite3TriggerUpdateStep(pParse, &yymsp[-6].minor.yy0, yymsp[-2].minor.yy203, yymsp[-3].minor.yy14, yymsp[-1].minor.yy454, yymsp[-7].minor.yy144, yymsp[-8].minor.yy0.z, yymsp[0].minor.yy168);}
178766
- yymsp[-8].minor.yy427 = yylhsminor.yy427;
179157
+{yylhsminor.yy319 = sqlite3TriggerUpdateStep(pParse, &yymsp[-6].minor.yy0, yymsp[-2].minor.yy563, yymsp[-3].minor.yy402, yymsp[-1].minor.yy590, yymsp[-7].minor.yy502, yymsp[-8].minor.yy0.z, yymsp[0].minor.yy342);}
179158
+ yymsp[-8].minor.yy319 = yylhsminor.yy319;
178767179159
break;
178768179160
case 276: /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
178769179161
{
178770
- yylhsminor.yy427 = sqlite3TriggerInsertStep(pParse,&yymsp[-4].minor.yy0,yymsp[-3].minor.yy132,yymsp[-2].minor.yy555,yymsp[-6].minor.yy144,yymsp[-1].minor.yy122,yymsp[-7].minor.yy168,yymsp[0].minor.yy168);/*yylhsminor.yy427-overwrites-yymsp[-6].minor.yy144*/
179162
+ yylhsminor.yy319 = sqlite3TriggerInsertStep(pParse,&yymsp[-4].minor.yy0,yymsp[-3].minor.yy204,yymsp[-2].minor.yy637,yymsp[-6].minor.yy502,yymsp[-1].minor.yy403,yymsp[-7].minor.yy342,yymsp[0].minor.yy342);/*yylhsminor.yy319-overwrites-yymsp[-6].minor.yy502*/
178771179163
}
178772
- yymsp[-7].minor.yy427 = yylhsminor.yy427;
179164
+ yymsp[-7].minor.yy319 = yylhsminor.yy319;
178773179165
break;
178774179166
case 277: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
178775
-{yylhsminor.yy427 = sqlite3TriggerDeleteStep(pParse, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy454, yymsp[-5].minor.yy0.z, yymsp[0].minor.yy168);}
178776
- yymsp[-5].minor.yy427 = yylhsminor.yy427;
179167
+{yylhsminor.yy319 = sqlite3TriggerDeleteStep(pParse, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy590, yymsp[-5].minor.yy0.z, yymsp[0].minor.yy342);}
179168
+ yymsp[-5].minor.yy319 = yylhsminor.yy319;
178777179169
break;
178778179170
case 278: /* trigger_cmd ::= scanpt select scanpt */
178779
-{yylhsminor.yy427 = sqlite3TriggerSelectStep(pParse->db, yymsp[-1].minor.yy555, yymsp[-2].minor.yy168, yymsp[0].minor.yy168); /*yylhsminor.yy427-overwrites-yymsp[-1].minor.yy555*/}
178780
- yymsp[-2].minor.yy427 = yylhsminor.yy427;
179171
+{yylhsminor.yy319 = sqlite3TriggerSelectStep(pParse->db, yymsp[-1].minor.yy637, yymsp[-2].minor.yy342, yymsp[0].minor.yy342); /*yylhsminor.yy319-overwrites-yymsp[-1].minor.yy637*/}
179172
+ yymsp[-2].minor.yy319 = yylhsminor.yy319;
178781179173
break;
178782179174
case 279: /* expr ::= RAISE LP IGNORE RP */
178783179175
{
178784
- yymsp[-3].minor.yy454 = sqlite3PExpr(pParse, TK_RAISE, 0, 0);
178785
- if( yymsp[-3].minor.yy454 ){
178786
- yymsp[-3].minor.yy454->affExpr = OE_Ignore;
179176
+ yymsp[-3].minor.yy590 = sqlite3PExpr(pParse, TK_RAISE, 0, 0);
179177
+ if( yymsp[-3].minor.yy590 ){
179178
+ yymsp[-3].minor.yy590->affExpr = OE_Ignore;
178787179179
}
178788179180
}
178789179181
break;
178790179182
case 280: /* expr ::= RAISE LP raisetype COMMA expr RP */
178791179183
{
178792
- yymsp[-5].minor.yy454 = sqlite3PExpr(pParse, TK_RAISE, yymsp[-1].minor.yy454, 0);
178793
- if( yymsp[-5].minor.yy454 ) {
178794
- yymsp[-5].minor.yy454->affExpr = (char)yymsp[-3].minor.yy144;
179184
+ yymsp[-5].minor.yy590 = sqlite3PExpr(pParse, TK_RAISE, yymsp[-1].minor.yy590, 0);
179185
+ if( yymsp[-5].minor.yy590 ) {
179186
+ yymsp[-5].minor.yy590->affExpr = (char)yymsp[-3].minor.yy502;
178795179187
}
178796179188
}
178797179189
break;
178798179190
case 281: /* raisetype ::= ROLLBACK */
178799
-{yymsp[0].minor.yy144 = OE_Rollback;}
179191
+{yymsp[0].minor.yy502 = OE_Rollback;}
178800179192
break;
178801179193
case 283: /* raisetype ::= FAIL */
178802
-{yymsp[0].minor.yy144 = OE_Fail;}
179194
+{yymsp[0].minor.yy502 = OE_Fail;}
178803179195
break;
178804179196
case 284: /* cmd ::= DROP TRIGGER ifexists fullname */
178805179197
{
178806
- sqlite3DropTrigger(pParse,yymsp[0].minor.yy203,yymsp[-1].minor.yy144);
179198
+ sqlite3DropTrigger(pParse,yymsp[0].minor.yy563,yymsp[-1].minor.yy502);
178807179199
}
178808179200
break;
178809179201
case 285: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
178810179202
{
178811
- sqlite3Attach(pParse, yymsp[-3].minor.yy454, yymsp[-1].minor.yy454, yymsp[0].minor.yy454);
179203
+ sqlite3Attach(pParse, yymsp[-3].minor.yy590, yymsp[-1].minor.yy590, yymsp[0].minor.yy590);
178812179204
}
178813179205
break;
178814179206
case 286: /* cmd ::= DETACH database_kw_opt expr */
178815179207
{
178816
- sqlite3Detach(pParse, yymsp[0].minor.yy454);
179208
+ sqlite3Detach(pParse, yymsp[0].minor.yy590);
178817179209
}
178818179210
break;
178819179211
case 289: /* cmd ::= REINDEX */
178820179212
{sqlite3Reindex(pParse, 0, 0);}
178821179213
break;
@@ -178828,11 +179220,11 @@
178828179220
case 292: /* cmd ::= ANALYZE nm dbnm */
178829179221
{sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
178830179222
break;
178831179223
case 293: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
178832179224
{
178833
- sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy203,&yymsp[0].minor.yy0);
179225
+ sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy563,&yymsp[0].minor.yy0);
178834179226
}
178835179227
break;
178836179228
case 294: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
178837179229
{
178838179230
yymsp[-1].minor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-1].minor.yy0.z) + pParse->sLastToken.n;
@@ -178839,22 +179231,22 @@
178839179231
sqlite3AlterFinishAddColumn(pParse, &yymsp[-1].minor.yy0);
178840179232
}
178841179233
break;
178842179234
case 295: /* cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */
178843179235
{
178844
- sqlite3AlterDropColumn(pParse, yymsp[-3].minor.yy203, &yymsp[0].minor.yy0);
179236
+ sqlite3AlterDropColumn(pParse, yymsp[-3].minor.yy563, &yymsp[0].minor.yy0);
178845179237
}
178846179238
break;
178847179239
case 296: /* add_column_fullname ::= fullname */
178848179240
{
178849179241
disableLookaside(pParse);
178850
- sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy203);
179242
+ sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy563);
178851179243
}
178852179244
break;
178853179245
case 297: /* cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
178854179246
{
178855
- sqlite3AlterRenameColumn(pParse, yymsp[-5].minor.yy203, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);
179247
+ sqlite3AlterRenameColumn(pParse, yymsp[-5].minor.yy563, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);
178856179248
}
178857179249
break;
178858179250
case 298: /* cmd ::= create_vtab */
178859179251
{sqlite3VtabFinishParse(pParse,0);}
178860179252
break;
@@ -178861,11 +179253,11 @@
178861179253
case 299: /* cmd ::= create_vtab LP vtabarglist RP */
178862179254
{sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}
178863179255
break;
178864179256
case 300: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
178865179257
{
178866
- sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy144);
179258
+ sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy502);
178867179259
}
178868179260
break;
178869179261
case 301: /* vtabarg ::= */
178870179262
{sqlite3VtabArgInit(pParse);}
178871179263
break;
@@ -178874,185 +179266,185 @@
178874179266
case 304: /* lp ::= LP */ yytestcase(yyruleno==304);
178875179267
{sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}
178876179268
break;
178877179269
case 305: /* with ::= WITH wqlist */
178878179270
case 306: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==306);
178879
-{ sqlite3WithPush(pParse, yymsp[0].minor.yy59, 1); }
179271
+{ sqlite3WithPush(pParse, yymsp[0].minor.yy125, 1); }
178880179272
break;
178881179273
case 307: /* wqas ::= AS */
178882
-{yymsp[0].minor.yy462 = M10d_Any;}
179274
+{yymsp[0].minor.yy444 = M10d_Any;}
178883179275
break;
178884179276
case 308: /* wqas ::= AS MATERIALIZED */
178885
-{yymsp[-1].minor.yy462 = M10d_Yes;}
179277
+{yymsp[-1].minor.yy444 = M10d_Yes;}
178886179278
break;
178887179279
case 309: /* wqas ::= AS NOT MATERIALIZED */
178888
-{yymsp[-2].minor.yy462 = M10d_No;}
179280
+{yymsp[-2].minor.yy444 = M10d_No;}
178889179281
break;
178890179282
case 310: /* wqitem ::= withnm eidlist_opt wqas LP select RP */
178891179283
{
178892
- yymsp[-5].minor.yy67 = sqlite3CteNew(pParse, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy14, yymsp[-1].minor.yy555, yymsp[-3].minor.yy462); /*A-overwrites-X*/
179284
+ yymsp[-5].minor.yy361 = sqlite3CteNew(pParse, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy402, yymsp[-1].minor.yy637, yymsp[-3].minor.yy444); /*A-overwrites-X*/
178893179285
}
178894179286
break;
178895179287
case 311: /* withnm ::= nm */
178896179288
{pParse->bHasWith = 1;}
178897179289
break;
178898179290
case 312: /* wqlist ::= wqitem */
178899179291
{
178900
- yymsp[0].minor.yy59 = sqlite3WithAdd(pParse, 0, yymsp[0].minor.yy67); /*A-overwrites-X*/
179292
+ yymsp[0].minor.yy125 = sqlite3WithAdd(pParse, 0, yymsp[0].minor.yy361); /*A-overwrites-X*/
178901179293
}
178902179294
break;
178903179295
case 313: /* wqlist ::= wqlist COMMA wqitem */
178904179296
{
178905
- yymsp[-2].minor.yy59 = sqlite3WithAdd(pParse, yymsp[-2].minor.yy59, yymsp[0].minor.yy67);
179297
+ yymsp[-2].minor.yy125 = sqlite3WithAdd(pParse, yymsp[-2].minor.yy125, yymsp[0].minor.yy361);
178906179298
}
178907179299
break;
178908179300
case 314: /* windowdefn_list ::= windowdefn_list COMMA windowdefn */
178909179301
{
178910
- assert( yymsp[0].minor.yy211!=0 );
178911
- sqlite3WindowChain(pParse, yymsp[0].minor.yy211, yymsp[-2].minor.yy211);
178912
- yymsp[0].minor.yy211->pNextWin = yymsp[-2].minor.yy211;
178913
- yylhsminor.yy211 = yymsp[0].minor.yy211;
179302
+ assert( yymsp[0].minor.yy483!=0 );
179303
+ sqlite3WindowChain(pParse, yymsp[0].minor.yy483, yymsp[-2].minor.yy483);
179304
+ yymsp[0].minor.yy483->pNextWin = yymsp[-2].minor.yy483;
179305
+ yylhsminor.yy483 = yymsp[0].minor.yy483;
178914179306
}
178915
- yymsp[-2].minor.yy211 = yylhsminor.yy211;
179307
+ yymsp[-2].minor.yy483 = yylhsminor.yy483;
178916179308
break;
178917179309
case 315: /* windowdefn ::= nm AS LP window RP */
178918179310
{
178919
- if( ALWAYS(yymsp[-1].minor.yy211) ){
178920
- yymsp[-1].minor.yy211->zName = sqlite3DbStrNDup(pParse->db, yymsp[-4].minor.yy0.z, yymsp[-4].minor.yy0.n);
179311
+ if( ALWAYS(yymsp[-1].minor.yy483) ){
179312
+ yymsp[-1].minor.yy483->zName = sqlite3DbStrNDup(pParse->db, yymsp[-4].minor.yy0.z, yymsp[-4].minor.yy0.n);
178921179313
}
178922
- yylhsminor.yy211 = yymsp[-1].minor.yy211;
179314
+ yylhsminor.yy483 = yymsp[-1].minor.yy483;
178923179315
}
178924
- yymsp[-4].minor.yy211 = yylhsminor.yy211;
179316
+ yymsp[-4].minor.yy483 = yylhsminor.yy483;
178925179317
break;
178926179318
case 316: /* window ::= PARTITION BY nexprlist orderby_opt frame_opt */
178927179319
{
178928
- yymsp[-4].minor.yy211 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy211, yymsp[-2].minor.yy14, yymsp[-1].minor.yy14, 0);
179320
+ yymsp[-4].minor.yy483 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy483, yymsp[-2].minor.yy402, yymsp[-1].minor.yy402, 0);
178929179321
}
178930179322
break;
178931179323
case 317: /* window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
178932179324
{
178933
- yylhsminor.yy211 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy211, yymsp[-2].minor.yy14, yymsp[-1].minor.yy14, &yymsp[-5].minor.yy0);
179325
+ yylhsminor.yy483 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy483, yymsp[-2].minor.yy402, yymsp[-1].minor.yy402, &yymsp[-5].minor.yy0);
178934179326
}
178935
- yymsp[-5].minor.yy211 = yylhsminor.yy211;
179327
+ yymsp[-5].minor.yy483 = yylhsminor.yy483;
178936179328
break;
178937179329
case 318: /* window ::= ORDER BY sortlist frame_opt */
178938179330
{
178939
- yymsp[-3].minor.yy211 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy211, 0, yymsp[-1].minor.yy14, 0);
179331
+ yymsp[-3].minor.yy483 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy483, 0, yymsp[-1].minor.yy402, 0);
178940179332
}
178941179333
break;
178942179334
case 319: /* window ::= nm ORDER BY sortlist frame_opt */
178943179335
{
178944
- yylhsminor.yy211 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy211, 0, yymsp[-1].minor.yy14, &yymsp[-4].minor.yy0);
179336
+ yylhsminor.yy483 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy483, 0, yymsp[-1].minor.yy402, &yymsp[-4].minor.yy0);
178945179337
}
178946
- yymsp[-4].minor.yy211 = yylhsminor.yy211;
179338
+ yymsp[-4].minor.yy483 = yylhsminor.yy483;
178947179339
break;
178948179340
case 320: /* window ::= nm frame_opt */
178949179341
{
178950
- yylhsminor.yy211 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy211, 0, 0, &yymsp[-1].minor.yy0);
179342
+ yylhsminor.yy483 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy483, 0, 0, &yymsp[-1].minor.yy0);
178951179343
}
178952
- yymsp[-1].minor.yy211 = yylhsminor.yy211;
179344
+ yymsp[-1].minor.yy483 = yylhsminor.yy483;
178953179345
break;
178954179346
case 321: /* frame_opt ::= */
178955179347
{
178956
- yymsp[1].minor.yy211 = sqlite3WindowAlloc(pParse, 0, TK_UNBOUNDED, 0, TK_CURRENT, 0, 0);
179348
+ yymsp[1].minor.yy483 = sqlite3WindowAlloc(pParse, 0, TK_UNBOUNDED, 0, TK_CURRENT, 0, 0);
178957179349
}
178958179350
break;
178959179351
case 322: /* frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */
178960179352
{
178961
- yylhsminor.yy211 = sqlite3WindowAlloc(pParse, yymsp[-2].minor.yy144, yymsp[-1].minor.yy509.eType, yymsp[-1].minor.yy509.pExpr, TK_CURRENT, 0, yymsp[0].minor.yy462);
179353
+ yylhsminor.yy483 = sqlite3WindowAlloc(pParse, yymsp[-2].minor.yy502, yymsp[-1].minor.yy205.eType, yymsp[-1].minor.yy205.pExpr, TK_CURRENT, 0, yymsp[0].minor.yy444);
178962179354
}
178963
- yymsp[-2].minor.yy211 = yylhsminor.yy211;
179355
+ yymsp[-2].minor.yy483 = yylhsminor.yy483;
178964179356
break;
178965179357
case 323: /* frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */
178966179358
{
178967
- yylhsminor.yy211 = sqlite3WindowAlloc(pParse, yymsp[-5].minor.yy144, yymsp[-3].minor.yy509.eType, yymsp[-3].minor.yy509.pExpr, yymsp[-1].minor.yy509.eType, yymsp[-1].minor.yy509.pExpr, yymsp[0].minor.yy462);
179359
+ yylhsminor.yy483 = sqlite3WindowAlloc(pParse, yymsp[-5].minor.yy502, yymsp[-3].minor.yy205.eType, yymsp[-3].minor.yy205.pExpr, yymsp[-1].minor.yy205.eType, yymsp[-1].minor.yy205.pExpr, yymsp[0].minor.yy444);
178968179360
}
178969
- yymsp[-5].minor.yy211 = yylhsminor.yy211;
179361
+ yymsp[-5].minor.yy483 = yylhsminor.yy483;
178970179362
break;
178971179363
case 325: /* frame_bound_s ::= frame_bound */
178972179364
case 327: /* frame_bound_e ::= frame_bound */ yytestcase(yyruleno==327);
178973
-{yylhsminor.yy509 = yymsp[0].minor.yy509;}
178974
- yymsp[0].minor.yy509 = yylhsminor.yy509;
179365
+{yylhsminor.yy205 = yymsp[0].minor.yy205;}
179366
+ yymsp[0].minor.yy205 = yylhsminor.yy205;
178975179367
break;
178976179368
case 326: /* frame_bound_s ::= UNBOUNDED PRECEDING */
178977179369
case 328: /* frame_bound_e ::= UNBOUNDED FOLLOWING */ yytestcase(yyruleno==328);
178978179370
case 330: /* frame_bound ::= CURRENT ROW */ yytestcase(yyruleno==330);
178979
-{yylhsminor.yy509.eType = yymsp[-1].major; yylhsminor.yy509.pExpr = 0;}
178980
- yymsp[-1].minor.yy509 = yylhsminor.yy509;
179371
+{yylhsminor.yy205.eType = yymsp[-1].major; yylhsminor.yy205.pExpr = 0;}
179372
+ yymsp[-1].minor.yy205 = yylhsminor.yy205;
178981179373
break;
178982179374
case 329: /* frame_bound ::= expr PRECEDING|FOLLOWING */
178983
-{yylhsminor.yy509.eType = yymsp[0].major; yylhsminor.yy509.pExpr = yymsp[-1].minor.yy454;}
178984
- yymsp[-1].minor.yy509 = yylhsminor.yy509;
179375
+{yylhsminor.yy205.eType = yymsp[0].major; yylhsminor.yy205.pExpr = yymsp[-1].minor.yy590;}
179376
+ yymsp[-1].minor.yy205 = yylhsminor.yy205;
178985179377
break;
178986179378
case 331: /* frame_exclude_opt ::= */
178987
-{yymsp[1].minor.yy462 = 0;}
179379
+{yymsp[1].minor.yy444 = 0;}
178988179380
break;
178989179381
case 332: /* frame_exclude_opt ::= EXCLUDE frame_exclude */
178990
-{yymsp[-1].minor.yy462 = yymsp[0].minor.yy462;}
179382
+{yymsp[-1].minor.yy444 = yymsp[0].minor.yy444;}
178991179383
break;
178992179384
case 333: /* frame_exclude ::= NO OTHERS */
178993179385
case 334: /* frame_exclude ::= CURRENT ROW */ yytestcase(yyruleno==334);
178994
-{yymsp[-1].minor.yy462 = yymsp[-1].major; /*A-overwrites-X*/}
179386
+{yymsp[-1].minor.yy444 = yymsp[-1].major; /*A-overwrites-X*/}
178995179387
break;
178996179388
case 335: /* frame_exclude ::= GROUP|TIES */
178997
-{yymsp[0].minor.yy462 = yymsp[0].major; /*A-overwrites-X*/}
179389
+{yymsp[0].minor.yy444 = yymsp[0].major; /*A-overwrites-X*/}
178998179390
break;
178999179391
case 336: /* window_clause ::= WINDOW windowdefn_list */
179000
-{ yymsp[-1].minor.yy211 = yymsp[0].minor.yy211; }
179392
+{ yymsp[-1].minor.yy483 = yymsp[0].minor.yy483; }
179001179393
break;
179002179394
case 337: /* filter_over ::= filter_clause over_clause */
179003179395
{
179004
- if( yymsp[0].minor.yy211 ){
179005
- yymsp[0].minor.yy211->pFilter = yymsp[-1].minor.yy454;
179396
+ if( yymsp[0].minor.yy483 ){
179397
+ yymsp[0].minor.yy483->pFilter = yymsp[-1].minor.yy590;
179006179398
}else{
179007
- sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy454);
179399
+ sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy590);
179008179400
}
179009
- yylhsminor.yy211 = yymsp[0].minor.yy211;
179401
+ yylhsminor.yy483 = yymsp[0].minor.yy483;
179010179402
}
179011
- yymsp[-1].minor.yy211 = yylhsminor.yy211;
179403
+ yymsp[-1].minor.yy483 = yylhsminor.yy483;
179012179404
break;
179013179405
case 338: /* filter_over ::= over_clause */
179014179406
{
179015
- yylhsminor.yy211 = yymsp[0].minor.yy211;
179407
+ yylhsminor.yy483 = yymsp[0].minor.yy483;
179016179408
}
179017
- yymsp[0].minor.yy211 = yylhsminor.yy211;
179409
+ yymsp[0].minor.yy483 = yylhsminor.yy483;
179018179410
break;
179019179411
case 339: /* filter_over ::= filter_clause */
179020179412
{
179021
- yylhsminor.yy211 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
179022
- if( yylhsminor.yy211 ){
179023
- yylhsminor.yy211->eFrmType = TK_FILTER;
179024
- yylhsminor.yy211->pFilter = yymsp[0].minor.yy454;
179413
+ yylhsminor.yy483 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
179414
+ if( yylhsminor.yy483 ){
179415
+ yylhsminor.yy483->eFrmType = TK_FILTER;
179416
+ yylhsminor.yy483->pFilter = yymsp[0].minor.yy590;
179025179417
}else{
179026
- sqlite3ExprDelete(pParse->db, yymsp[0].minor.yy454);
179418
+ sqlite3ExprDelete(pParse->db, yymsp[0].minor.yy590);
179027179419
}
179028179420
}
179029
- yymsp[0].minor.yy211 = yylhsminor.yy211;
179421
+ yymsp[0].minor.yy483 = yylhsminor.yy483;
179030179422
break;
179031179423
case 340: /* over_clause ::= OVER LP window RP */
179032179424
{
179033
- yymsp[-3].minor.yy211 = yymsp[-1].minor.yy211;
179034
- assert( yymsp[-3].minor.yy211!=0 );
179425
+ yymsp[-3].minor.yy483 = yymsp[-1].minor.yy483;
179426
+ assert( yymsp[-3].minor.yy483!=0 );
179035179427
}
179036179428
break;
179037179429
case 341: /* over_clause ::= OVER nm */
179038179430
{
179039
- yymsp[-1].minor.yy211 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
179040
- if( yymsp[-1].minor.yy211 ){
179041
- yymsp[-1].minor.yy211->zName = sqlite3DbStrNDup(pParse->db, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n);
179431
+ yymsp[-1].minor.yy483 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
179432
+ if( yymsp[-1].minor.yy483 ){
179433
+ yymsp[-1].minor.yy483->zName = sqlite3DbStrNDup(pParse->db, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n);
179042179434
}
179043179435
}
179044179436
break;
179045179437
case 342: /* filter_clause ::= FILTER LP WHERE expr RP */
179046
-{ yymsp[-4].minor.yy454 = yymsp[-1].minor.yy454; }
179438
+{ yymsp[-4].minor.yy590 = yymsp[-1].minor.yy590; }
179047179439
break;
179048179440
case 343: /* term ::= QNUMBER */
179049179441
{
179050
- yylhsminor.yy454=tokenExpr(pParse,yymsp[0].major,yymsp[0].minor.yy0);
179051
- sqlite3DequoteNumber(pParse, yylhsminor.yy454);
179442
+ yylhsminor.yy590=tokenExpr(pParse,yymsp[0].major,yymsp[0].minor.yy0);
179443
+ sqlite3DequoteNumber(pParse, yylhsminor.yy590);
179052179444
}
179053
- yymsp[0].minor.yy454 = yylhsminor.yy454;
179445
+ yymsp[0].minor.yy590 = yylhsminor.yy590;
179054179446
break;
179055179447
default:
179056179448
/* (344) input ::= cmdlist */ yytestcase(yyruleno==344);
179057179449
/* (345) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==345);
179058179450
/* (346) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=346);
@@ -180229,11 +180621,11 @@
180229180621
return i;
180230180622
}
180231180623
case CC_MINUS: {
180232180624
if( z[1]=='-' ){
180233180625
for(i=2; (c=z[i])!=0 && c!='\n'; i++){}
180234
- *tokenType = TK_SPACE; /* IMP: R-22934-25134 */
180626
+ *tokenType = TK_COMMENT;
180235180627
return i;
180236180628
}else if( z[1]=='>' ){
180237180629
*tokenType = TK_PTR;
180238180630
return 2 + (z[2]=='>');
180239180631
}
@@ -180265,11 +180657,11 @@
180265180657
*tokenType = TK_SLASH;
180266180658
return 1;
180267180659
}
180268180660
for(i=3, c=z[2]; (c!='*' || z[i]!='/') && (c=z[i])!=0; i++){}
180269180661
if( c ) i++;
180270
- *tokenType = TK_SPACE; /* IMP: R-22934-25134 */
180662
+ *tokenType = TK_COMMENT;
180271180663
return i;
180272180664
}
180273180665
case CC_PERCENT: {
180274180666
*tokenType = TK_REM;
180275180667
return 1;
@@ -180594,16 +180986,16 @@
180594180986
}
180595180987
#ifndef SQLITE_OMIT_WINDOWFUNC
180596180988
if( tokenType>=TK_WINDOW ){
180597180989
assert( tokenType==TK_SPACE || tokenType==TK_OVER || tokenType==TK_FILTER
180598180990
|| tokenType==TK_ILLEGAL || tokenType==TK_WINDOW
180599
- || tokenType==TK_QNUMBER
180991
+ || tokenType==TK_QNUMBER || tokenType==TK_COMMENT
180600180992
);
180601180993
#else
180602180994
if( tokenType>=TK_SPACE ){
180603180995
assert( tokenType==TK_SPACE || tokenType==TK_ILLEGAL
180604
- || tokenType==TK_QNUMBER
180996
+ || tokenType==TK_QNUMBER || tokenType==TK_COMMENT
180605180997
);
180606180998
#endif /* SQLITE_OMIT_WINDOWFUNC */
180607180999
if( AtomicLoad(&db->u1.isInterrupted) ){
180608181000
pParse->rc = SQLITE_INTERRUPT;
180609181001
pParse->nErr++;
@@ -180633,10 +181025,13 @@
180633181025
tokenType = analyzeOverKeyword((const u8*)&zSql[4], lastTokenParsed);
180634181026
}else if( tokenType==TK_FILTER ){
180635181027
assert( n==6 );
180636181028
tokenType = analyzeFilterKeyword((const u8*)&zSql[6], lastTokenParsed);
180637181029
#endif /* SQLITE_OMIT_WINDOWFUNC */
181030
+ }else if( tokenType==TK_COMMENT && (db->flags & SQLITE_Comments)!=0 ){
181031
+ zSql += n;
181032
+ continue;
180638181033
}else if( tokenType!=TK_QNUMBER ){
180639181034
Token x;
180640181035
x.z = zSql;
180641181036
x.n = n;
180642181037
sqlite3ErrorMsg(pParse, "unrecognized token: \"%T\"", &x);
@@ -180739,10 +181134,11 @@
180739181134
prevType = tokenType;
180740181135
}
180741181136
n = sqlite3GetToken((unsigned char*)zSql+i, &tokenType);
180742181137
if( NEVER(n<=0) ) break;
180743181138
switch( tokenType ){
181139
+ case TK_COMMENT:
180744181140
case TK_SPACE: {
180745181141
break;
180746181142
}
180747181143
case TK_NULL: {
180748181144
if( prevType==TK_IS || prevType==TK_NOT ){
@@ -181980,21 +182376,26 @@
181980182376
** Set up the lookaside buffers for a database connection.
181981182377
** Return SQLITE_OK on success.
181982182378
** If lookaside is already active, return SQLITE_BUSY.
181983182379
**
181984182380
** The sz parameter is the number of bytes in each lookaside slot.
181985
-** The cnt parameter is the number of slots. If pStart is NULL the
181986
-** space for the lookaside memory is obtained from sqlite3_malloc().
181987
-** If pStart is not NULL then it is sz*cnt bytes of memory to use for
181988
-** the lookaside memory.
182381
+** The cnt parameter is the number of slots. If pBuf is NULL the
182382
+** space for the lookaside memory is obtained from sqlite3_malloc()
182383
+** or similar. If pBuf is not NULL then it is sz*cnt bytes of memory
182384
+** to use for the lookaside memory.
181989182385
*/
181990
-static int setupLookaside(sqlite3 *db, void *pBuf, int sz, int cnt){
182386
+static int setupLookaside(
182387
+ sqlite3 *db, /* Database connection being configured */
182388
+ void *pBuf, /* Memory to use for lookaside. May be NULL */
182389
+ int sz, /* Desired size of each lookaside memory slot */
182390
+ int cnt /* Number of slots to allocate */
182391
+){
181991182392
#ifndef SQLITE_OMIT_LOOKASIDE
181992
- void *pStart;
181993
- sqlite3_int64 szAlloc = sz*(sqlite3_int64)cnt;
181994
- int nBig; /* Number of full-size slots */
181995
- int nSm; /* Number smaller LOOKASIDE_SMALL-byte slots */
182393
+ void *pStart; /* Start of the lookaside buffer */
182394
+ sqlite3_int64 szAlloc; /* Total space set aside for lookaside memory */
182395
+ int nBig; /* Number of full-size slots */
182396
+ int nSm; /* Number smaller LOOKASIDE_SMALL-byte slots */
181996182397
181997182398
if( sqlite3LookasideUsed(db,0)>0 ){
181998182399
return SQLITE_BUSY;
181999182400
}
182000182401
/* Free any existing lookaside buffer for this handle before
@@ -182003,33 +182404,38 @@
182003182404
*/
182004182405
if( db->lookaside.bMalloced ){
182005182406
sqlite3_free(db->lookaside.pStart);
182006182407
}
182007182408
/* The size of a lookaside slot after ROUNDDOWN8 needs to be larger
182008
- ** than a pointer to be useful.
182409
+ ** than a pointer and small enough to fit in a u16.
182009182410
*/
182010
- sz = ROUNDDOWN8(sz); /* IMP: R-33038-09382 */
182411
+ sz = ROUNDDOWN8(sz);
182011182412
if( sz<=(int)sizeof(LookasideSlot*) ) sz = 0;
182012
- if( cnt<0 ) cnt = 0;
182013
- if( sz==0 || cnt==0 ){
182413
+ if( sz>65528 ) sz = 65528;
182414
+ /* Count must be at least 1 to be useful, but not so large as to use
182415
+ ** more than 0x7fff0000 total bytes for lookaside. */
182416
+ if( cnt<1 ) cnt = 0;
182417
+ if( sz>0 && cnt>(0x7fff0000/sz) ) cnt = 0x7fff0000/sz;
182418
+ szAlloc = (i64)sz*(i64)cnt;
182419
+ if( szAlloc==0 ){
182014182420
sz = 0;
182015182421
pStart = 0;
182016182422
}else if( pBuf==0 ){
182017182423
sqlite3BeginBenignMalloc();
182018
- pStart = sqlite3Malloc( szAlloc ); /* IMP: R-61949-35727 */
182424
+ pStart = sqlite3Malloc( szAlloc );
182019182425
sqlite3EndBenignMalloc();
182020182426
if( pStart ) szAlloc = sqlite3MallocSize(pStart);
182021182427
}else{
182022182428
pStart = pBuf;
182023182429
}
182024182430
#ifndef SQLITE_OMIT_TWOSIZE_LOOKASIDE
182025182431
if( sz>=LOOKASIDE_SMALL*3 ){
182026182432
nBig = szAlloc/(3*LOOKASIDE_SMALL+sz);
182027
- nSm = (szAlloc - sz*nBig)/LOOKASIDE_SMALL;
182433
+ nSm = (szAlloc - (i64)sz*(i64)nBig)/LOOKASIDE_SMALL;
182028182434
}else if( sz>=LOOKASIDE_SMALL*2 ){
182029182435
nBig = szAlloc/(LOOKASIDE_SMALL+sz);
182030
- nSm = (szAlloc - sz*nBig)/LOOKASIDE_SMALL;
182436
+ nSm = (szAlloc - (i64)sz*(i64)nBig)/LOOKASIDE_SMALL;
182031182437
}else
182032182438
#endif /* SQLITE_OMIT_TWOSIZE_LOOKASIDE */
182033182439
if( sz>0 ){
182034182440
nBig = szAlloc/sz;
182035182441
nSm = 0;
@@ -182180,11 +182586,11 @@
182180182586
break;
182181182587
}
182182182588
default: {
182183182589
static const struct {
182184182590
int op; /* The opcode */
182185
- u32 mask; /* Mask of the bit in sqlite3.flags to set/clear */
182591
+ u64 mask; /* Mask of the bit in sqlite3.flags to set/clear */
182186182592
} aFlagOp[] = {
182187182593
{ SQLITE_DBCONFIG_ENABLE_FKEY, SQLITE_ForeignKeys },
182188182594
{ SQLITE_DBCONFIG_ENABLE_TRIGGER, SQLITE_EnableTrigger },
182189182595
{ SQLITE_DBCONFIG_ENABLE_VIEW, SQLITE_EnableView },
182190182596
{ SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER, SQLITE_Fts3Tokenizer },
@@ -182201,10 +182607,13 @@
182201182607
{ SQLITE_DBCONFIG_DQS_DML, SQLITE_DqsDML },
182202182608
{ SQLITE_DBCONFIG_LEGACY_FILE_FORMAT, SQLITE_LegacyFileFmt },
182203182609
{ SQLITE_DBCONFIG_TRUSTED_SCHEMA, SQLITE_TrustedSchema },
182204182610
{ SQLITE_DBCONFIG_STMT_SCANSTATUS, SQLITE_StmtScanStatus },
182205182611
{ SQLITE_DBCONFIG_REVERSE_SCANORDER, SQLITE_ReverseOrder },
182612
+ { SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE, SQLITE_AttachCreate },
182613
+ { SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE, SQLITE_AttachWrite },
182614
+ { SQLITE_DBCONFIG_ENABLE_COMMENTS, SQLITE_Comments },
182206182615
};
182207182616
unsigned int i;
182208182617
rc = SQLITE_ERROR; /* IMP: R-42790-23372 */
182209182618
for(i=0; i<ArraySize(aFlagOp); i++){
182210182619
if( aFlagOp[i].op==op ){
@@ -184078,12 +184487,12 @@
184078184487
# error SQLITE_MAX_COMPOUND_SELECT must be at least 2
184079184488
#endif
184080184489
#if SQLITE_MAX_VDBE_OP<40
184081184490
# error SQLITE_MAX_VDBE_OP must be at least 40
184082184491
#endif
184083
-#if SQLITE_MAX_FUNCTION_ARG<0 || SQLITE_MAX_FUNCTION_ARG>127
184084
-# error SQLITE_MAX_FUNCTION_ARG must be between 0 and 127
184492
+#if SQLITE_MAX_FUNCTION_ARG<0 || SQLITE_MAX_FUNCTION_ARG>32767
184493
+# error SQLITE_MAX_FUNCTION_ARG must be between 0 and 32767
184085184494
#endif
184086184495
#if SQLITE_MAX_ATTACHED<0 || SQLITE_MAX_ATTACHED>125
184087184496
# error SQLITE_MAX_ATTACHED must be between 0 and 125
184088184497
#endif
184089184498
#if SQLITE_MAX_LIKE_PATTERN_LENGTH<1
@@ -184542,10 +184951,13 @@
184542184951
#endif
184543184952
db->flags |= SQLITE_ShortColNames
184544184953
| SQLITE_EnableTrigger
184545184954
| SQLITE_EnableView
184546184955
| SQLITE_CacheSpill
184956
+ | SQLITE_AttachCreate
184957
+ | SQLITE_AttachWrite
184958
+ | SQLITE_Comments
184547184959
#if !defined(SQLITE_TRUSTED_SCHEMA) || SQLITE_TRUSTED_SCHEMA+0!=0
184548184960
| SQLITE_TrustedSchema
184549184961
#endif
184550184962
/* The SQLITE_DQS compile-time option determines the default settings
184551184963
** for SQLITE_DBCONFIG_DQS_DDL and SQLITE_DBCONFIG_DQS_DML.
@@ -185158,17 +185570,14 @@
185158185570
185159185571
/* Find the column for which info is requested */
185160185572
if( zColumnName==0 ){
185161185573
/* Query for existence of table only */
185162185574
}else{
185163
- for(iCol=0; iCol<pTab->nCol; iCol++){
185575
+ iCol = sqlite3ColumnIndex(pTab, zColumnName);
185576
+ if( iCol>=0 ){
185164185577
pCol = &pTab->aCol[iCol];
185165
- if( 0==sqlite3StrICmp(pCol->zCnName, zColumnName) ){
185166
- break;
185167
- }
185168
- }
185169
- if( iCol==pTab->nCol ){
185578
+ }else{
185170185579
if( HasRowid(pTab) && sqlite3IsRowid(zColumnName) ){
185171185580
iCol = pTab->iPKey;
185172185581
pCol = iCol>=0 ? &pTab->aCol[iCol] : 0;
185173185582
}else{
185174185583
pTab = 0;
@@ -185492,11 +185901,10 @@
185492185901
#if defined(SQLITE_DEBUG)
185493185902
/* Invoke these debugging routines so that the compiler does not
185494185903
** issue "defined but not used" warnings. */
185495185904
if( x==9999 ){
185496185905
sqlite3ShowExpr(0);
185497
- sqlite3ShowExpr(0);
185498185906
sqlite3ShowExprList(0);
185499185907
sqlite3ShowIdList(0);
185500185908
sqlite3ShowSrcList(0);
185501185909
sqlite3ShowWith(0);
185502185910
sqlite3ShowUpsert(0);
@@ -185509,11 +185917,10 @@
185509185917
#ifndef SQLITE_OMIT_WINDOWFUNC
185510185918
sqlite3ShowWindow(0);
185511185919
sqlite3ShowWinFunc(0);
185512185920
#endif
185513185921
sqlite3ShowSelect(0);
185514
- sqlite3ShowWhereTerm(0);
185515185922
}
185516185923
#endif
185517185924
break;
185518185925
}
185519185926
@@ -187849,10 +188256,11 @@
187849188256
SQLITE_PRIVATE int sqlite3Fts3MsrIncrNext(
187850188257
Fts3Table *, Fts3MultiSegReader *, sqlite3_int64 *, char **, int *);
187851188258
SQLITE_PRIVATE int sqlite3Fts3EvalPhrasePoslist(Fts3Cursor *, Fts3Expr *, int iCol, char **);
187852188259
SQLITE_PRIVATE int sqlite3Fts3MsrOvfl(Fts3Cursor *, Fts3MultiSegReader *, int *);
187853188260
SQLITE_PRIVATE int sqlite3Fts3MsrIncrRestart(Fts3MultiSegReader *pCsr);
188261
+SQLITE_PRIVATE int sqlite3Fts3MsrCancel(Fts3Cursor*, Fts3Expr*);
187854188262
187855188263
/* fts3_tokenize_vtab.c */
187856188264
SQLITE_PRIVATE int sqlite3Fts3InitTok(sqlite3*, Fts3Hash *, void(*xDestroy)(void*));
187857188265
187858188266
/* fts3_unicode2.c (functions generated by parsing unicode text files) */
@@ -192018,11 +192426,11 @@
192018192426
p1 = pPhrase->doclist.pList;
192019192427
p2 = aPoslist;
192020192428
nDistance = iPrev - nMaxUndeferred;
192021192429
}
192022192430
192023
- aOut = (char *)sqlite3Fts3MallocZero(nPoslist+FTS3_BUFFER_PADDING);
192431
+ aOut = (char *)sqlite3Fts3MallocZero(((i64)nPoslist)+FTS3_BUFFER_PADDING);
192024192432
if( !aOut ){
192025192433
sqlite3_free(aPoslist);
192026192434
return SQLITE_NOMEM;
192027192435
}
192028192436
@@ -193366,10 +193774,28 @@
193366193774
193367193775
fts3EvalRestart(pCsr, pExpr->pLeft, pRc);
193368193776
fts3EvalRestart(pCsr, pExpr->pRight, pRc);
193369193777
}
193370193778
}
193779
+
193780
+/*
193781
+** Expression node pExpr is an MSR phrase. This function restarts pExpr
193782
+** so that it is a regular phrase query, not an MSR. SQLITE_OK is returned
193783
+** if successful, or an SQLite error code otherwise.
193784
+*/
193785
+SQLITE_PRIVATE int sqlite3Fts3MsrCancel(Fts3Cursor *pCsr, Fts3Expr *pExpr){
193786
+ int rc = SQLITE_OK;
193787
+ if( pExpr->bEof==0 ){
193788
+ i64 iDocid = pExpr->iDocid;
193789
+ fts3EvalRestart(pCsr, pExpr, &rc);
193790
+ while( rc==SQLITE_OK && pExpr->iDocid!=iDocid ){
193791
+ fts3EvalNextRow(pCsr, pExpr, &rc);
193792
+ if( pExpr->bEof ) rc = FTS_CORRUPT_VTAB;
193793
+ }
193794
+ }
193795
+ return rc;
193796
+}
193371193797
193372193798
/*
193373193799
** After allocating the Fts3Expr.aMI[] array for each phrase in the
193374193800
** expression rooted at pExpr, the cursor iterates through all rows matched
193375193801
** by pExpr, calling this function for each row. This function increments
@@ -194620,11 +195046,11 @@
194620195046
sqlite3_tokenizer_module const *pModule = pTokenizer->pModule;
194621195047
int rc;
194622195048
Fts3Expr *p = 0;
194623195049
sqlite3_tokenizer_cursor *pCursor = 0;
194624195050
char *zTemp = 0;
194625
- int nTemp = 0;
195051
+ i64 nTemp = 0;
194626195052
194627195053
const int nSpace = sizeof(Fts3Expr) + sizeof(Fts3Phrase);
194628195054
int nToken = 0;
194629195055
194630195056
/* The final Fts3Expr data structure, including the Fts3Phrase,
@@ -205323,10 +205749,26 @@
205323205749
pT->iPos = iPos;
205324205750
}
205325205751
205326205752
return rc;
205327205753
}
205754
+
205755
+/*
205756
+** If expression pExpr is a phrase expression that uses an MSR query,
205757
+** restart it as a regular, non-incremental query. Return SQLITE_OK
205758
+** if successful, or an SQLite error code otherwise.
205759
+*/
205760
+static int fts3ExprRestartIfCb(Fts3Expr *pExpr, int iPhrase, void *ctx){
205761
+ TermOffsetCtx *p = (TermOffsetCtx*)ctx;
205762
+ int rc = SQLITE_OK;
205763
+ UNUSED_PARAMETER(iPhrase);
205764
+ if( pExpr->pPhrase && pExpr->pPhrase->bIncr ){
205765
+ rc = sqlite3Fts3MsrCancel(p->pCsr, pExpr);
205766
+ pExpr->pPhrase->bIncr = 0;
205767
+ }
205768
+ return rc;
205769
+}
205328205770
205329205771
/*
205330205772
** Implementation of offsets() function.
205331205773
*/
205332205774
SQLITE_PRIVATE void sqlite3Fts3Offsets(
@@ -205359,10 +205801,16 @@
205359205801
rc = SQLITE_NOMEM;
205360205802
goto offsets_out;
205361205803
}
205362205804
sCtx.iDocid = pCsr->iPrevId;
205363205805
sCtx.pCsr = pCsr;
205806
+
205807
+ /* If a query restart will be required, do it here, rather than later of
205808
+ ** after pointers to poslist buffers that may be invalidated by a restart
205809
+ ** have been saved. */
205810
+ rc = sqlite3Fts3ExprIterate(pCsr->pExpr, fts3ExprRestartIfCb, (void*)&sCtx);
205811
+ if( rc!=SQLITE_OK ) goto offsets_out;
205364205812
205365205813
/* Loop through the table columns, appending offset information to
205366205814
** string-buffer res for each column.
205367205815
*/
205368205816
for(iCol=0; iCol<pTab->nColumn; iCol++){
@@ -207369,22 +207817,23 @@
207369207817
**
207370207818
** Return the number of errors.
207371207819
*/
207372207820
static int jsonBlobExpand(JsonParse *pParse, u32 N){
207373207821
u8 *aNew;
207374
- u32 t;
207822
+ u64 t;
207375207823
assert( N>pParse->nBlobAlloc );
207376207824
if( pParse->nBlobAlloc==0 ){
207377207825
t = 100;
207378207826
}else{
207379207827
t = pParse->nBlobAlloc*2;
207380207828
}
207381207829
if( t<N ) t = N+100;
207382207830
aNew = sqlite3DbRealloc(pParse->db, pParse->aBlob, t);
207383207831
if( aNew==0 ){ pParse->oom = 1; return 1; }
207832
+ assert( t<0x7fffffff );
207384207833
pParse->aBlob = aNew;
207385
- pParse->nBlobAlloc = t;
207834
+ pParse->nBlobAlloc = (u32)t;
207386207835
return 0;
207387207836
}
207388207837
207389207838
/*
207390207839
** If pParse->aBlob is not previously editable (because it is taken
@@ -208337,14 +208786,11 @@
208337208786
*/
208338208787
static u32 jsonbPayloadSize(const JsonParse *pParse, u32 i, u32 *pSz){
208339208788
u8 x;
208340208789
u32 sz;
208341208790
u32 n;
208342
- if( NEVER(i>pParse->nBlob) ){
208343
- *pSz = 0;
208344
- return 0;
208345
- }
208791
+ assert( i<=pParse->nBlob );
208346208792
x = pParse->aBlob[i]>>4;
208347208793
if( x<=11 ){
208348208794
sz = x;
208349208795
n = 1;
208350208796
}else if( x==12 ){
@@ -208384,12 +208830,12 @@
208384208830
n = 9;
208385208831
}
208386208832
if( (i64)i+sz+n > pParse->nBlob
208387208833
&& (i64)i+sz+n > pParse->nBlob-pParse->delta
208388208834
){
208389
- sz = 0;
208390
- n = 0;
208835
+ *pSz = 0;
208836
+ return 0;
208391208837
}
208392208838
*pSz = sz;
208393208839
return n;
208394208840
}
208395208841
@@ -208482,13 +208928,16 @@
208482208928
}
208483208929
break;
208484208930
}
208485208931
case JSONB_TEXT:
208486208932
case JSONB_TEXTJ: {
208487
- jsonAppendChar(pOut, '"');
208488
- jsonAppendRaw(pOut, (const char*)&pParse->aBlob[i+n], sz);
208489
- jsonAppendChar(pOut, '"');
208933
+ if( pOut->nUsed+sz+2<=pOut->nAlloc || jsonStringGrow(pOut, sz+2)==0 ){
208934
+ pOut->zBuf[pOut->nUsed] = '"';
208935
+ memcpy(pOut->zBuf+pOut->nUsed+1,(const char*)&pParse->aBlob[i+n],sz);
208936
+ pOut->zBuf[pOut->nUsed+sz+1] = '"';
208937
+ pOut->nUsed += sz+2;
208938
+ }
208490208939
break;
208491208940
}
208492208941
case JSONB_TEXT5: {
208493208942
const char *zIn;
208494208943
u32 k;
@@ -209399,11 +209848,11 @@
209399209848
u32 iIn, iOut;
209400209849
const char *z;
209401209850
char *zOut;
209402209851
u32 nOut = sz;
209403209852
z = (const char*)&pParse->aBlob[i+n];
209404
- zOut = sqlite3DbMallocRaw(db, nOut+1);
209853
+ zOut = sqlite3DbMallocRaw(db, ((u64)nOut)+1);
209405209854
if( zOut==0 ) goto returnfromblob_oom;
209406209855
for(iIn=iOut=0; iIn<sz; iIn++){
209407209856
char c = z[iIn];
209408209857
if( c=='\\' ){
209409209858
u32 v;
@@ -215527,12 +215976,12 @@
215527215976
#endif
215528215977
}
215529215978
sqlite3_str_append(pOut, "}", 1);
215530215979
}
215531215980
errCode = sqlite3_str_errcode(pOut);
215532
- sqlite3_result_text(ctx, sqlite3_str_finish(pOut), -1, sqlite3_free);
215533215981
sqlite3_result_error_code(ctx, errCode);
215982
+ sqlite3_result_text(ctx, sqlite3_str_finish(pOut), -1, sqlite3_free);
215534215983
}
215535215984
215536215985
/* This routine implements an SQL function that returns the "depth" parameter
215537215986
** from the front of a blob that is an r-tree node. For example:
215538215987
**
@@ -226232,10 +226681,28 @@
226232226681
static int dbpageRowid(sqlite3_vtab_cursor *pCursor, sqlite_int64 *pRowid){
226233226682
DbpageCursor *pCsr = (DbpageCursor *)pCursor;
226234226683
*pRowid = pCsr->pgno;
226235226684
return SQLITE_OK;
226236226685
}
226686
+
226687
+/*
226688
+** Open write transactions. Since we do not know in advance which database
226689
+** files will be written by the sqlite_dbpage virtual table, start a write
226690
+** transaction on them all.
226691
+**
226692
+** Return SQLITE_OK if successful, or an SQLite error code otherwise.
226693
+*/
226694
+static int dbpageBeginTrans(DbpageTable *pTab){
226695
+ sqlite3 *db = pTab->db;
226696
+ int rc = SQLITE_OK;
226697
+ int i;
226698
+ for(i=0; rc==SQLITE_OK && i<db->nDb; i++){
226699
+ Btree *pBt = db->aDb[i].pBt;
226700
+ if( pBt ) rc = sqlite3BtreeBeginTrans(pBt, 1, 0);
226701
+ }
226702
+ return rc;
226703
+}
226237226704
226238226705
static int dbpageUpdate(
226239226706
sqlite3_vtab *pVtab,
226240226707
int argc,
226241226708
sqlite3_value **argv,
@@ -226300,10 +226767,16 @@
226300226767
}else{
226301226768
zErr = "bad page value";
226302226769
goto update_fail;
226303226770
}
226304226771
}
226772
+
226773
+ if( dbpageBeginTrans(pTab)!=SQLITE_OK ){
226774
+ zErr = "failed to open transaction";
226775
+ goto update_fail;
226776
+ }
226777
+
226305226778
pPager = sqlite3BtreePager(pBt);
226306226779
rc = sqlite3PagerGet(pPager, pgno, (DbPage**)&pDbPage, 0);
226307226780
if( rc==SQLITE_OK ){
226308226781
const void *pData = sqlite3_value_blob(argv[3]);
226309226782
if( (rc = sqlite3PagerWrite(pDbPage))==SQLITE_OK && pData ){
@@ -226316,27 +226789,18 @@
226316226789
}
226317226790
sqlite3PagerUnref(pDbPage);
226318226791
return rc;
226319226792
226320226793
update_fail:
226794
+ pTab->pgnoTrunc = 0;
226321226795
sqlite3_free(pVtab->zErrMsg);
226322226796
pVtab->zErrMsg = sqlite3_mprintf("%s", zErr);
226323226797
return SQLITE_ERROR;
226324226798
}
226325226799
226326
-/* Since we do not know in advance which database files will be
226327
-** written by the sqlite_dbpage virtual table, start a write transaction
226328
-** on them all.
226329
-*/
226330226800
static int dbpageBegin(sqlite3_vtab *pVtab){
226331226801
DbpageTable *pTab = (DbpageTable *)pVtab;
226332
- sqlite3 *db = pTab->db;
226333
- int i;
226334
- for(i=0; i<db->nDb; i++){
226335
- Btree *pBt = db->aDb[i].pBt;
226336
- if( pBt ) (void)sqlite3BtreeBeginTrans(pBt, 1, 0);
226337
- }
226338226802
pTab->pgnoTrunc = 0;
226339226803
return SQLITE_OK;
226340226804
}
226341226805
226342226806
/* Invoke sqlite3PagerTruncate() as necessary, just prior to COMMIT
@@ -226344,11 +226808,15 @@
226344226808
static int dbpageSync(sqlite3_vtab *pVtab){
226345226809
DbpageTable *pTab = (DbpageTable *)pVtab;
226346226810
if( pTab->pgnoTrunc>0 ){
226347226811
Btree *pBt = pTab->db->aDb[pTab->iDbTrunc].pBt;
226348226812
Pager *pPager = sqlite3BtreePager(pBt);
226349
- sqlite3PagerTruncateImage(pPager, pTab->pgnoTrunc);
226813
+ sqlite3BtreeEnter(pBt);
226814
+ if( pTab->pgnoTrunc<sqlite3BtreeLastPage(pBt) ){
226815
+ sqlite3PagerTruncateImage(pPager, pTab->pgnoTrunc);
226816
+ }
226817
+ sqlite3BtreeLeave(pBt);
226350226818
}
226351226819
pTab->pgnoTrunc = 0;
226352226820
return SQLITE_OK;
226353226821
}
226354226822
@@ -226364,11 +226832,11 @@
226364226832
/*
226365226833
** Invoke this routine to register the "dbpage" virtual table module
226366226834
*/
226367226835
SQLITE_PRIVATE int sqlite3DbpageRegister(sqlite3 *db){
226368226836
static sqlite3_module dbpage_module = {
226369
- 0, /* iVersion */
226837
+ 2, /* iVersion */
226370226838
dbpageConnect, /* xCreate */
226371226839
dbpageConnect, /* xConnect */
226372226840
dbpageBestIndex, /* xBestIndex */
226373226841
dbpageDisconnect, /* xDisconnect */
226374226842
dbpageDisconnect, /* xDestroy */
@@ -226539,15 +227007,17 @@
226539227007
** SELECT 1, NULL, 'abc'
226540227008
*/
226541227009
struct SessionTable {
226542227010
SessionTable *pNext;
226543227011
char *zName; /* Local name of table */
226544
- int nCol; /* Number of columns in table zName */
227012
+ int nCol; /* Number of non-hidden columns */
227013
+ int nTotalCol; /* Number of columns including hidden */
226545227014
int bStat1; /* True if this is sqlite_stat1 */
226546227015
int bRowid; /* True if this table uses rowid for PK */
226547227016
const char **azCol; /* Column names */
226548227017
const char **azDflt; /* Default value expressions */
227018
+ int *aiIdx; /* Index to pass to xNew/xOld */
226549227019
u8 *abPK; /* Array of primary key flags */
226550227020
int nEntry; /* Total number of entries in hash table */
226551227021
int nChange; /* Size of apChange[] array */
226552227022
SessionChange **apChange; /* Hash table buckets */
226553227023
sqlite3_stmt *pDfltStmt;
@@ -226946,26 +227416,26 @@
226946227416
int *pbNullPK /* OUT: True if there are NULL values in PK */
226947227417
){
226948227418
unsigned int h = 0; /* Hash value to return */
226949227419
int i; /* Used to iterate through columns */
226950227420
227421
+ assert( pTab->nTotalCol==pSession->hook.xCount(pSession->hook.pCtx) );
226951227422
if( pTab->bRowid ){
226952
- assert( pTab->nCol-1==pSession->hook.xCount(pSession->hook.pCtx) );
226953227423
h = sessionHashAppendI64(h, iRowid);
226954227424
}else{
226955227425
assert( *pbNullPK==0 );
226956
- assert( pTab->nCol==pSession->hook.xCount(pSession->hook.pCtx) );
226957227426
for(i=0; i<pTab->nCol; i++){
226958227427
if( pTab->abPK[i] ){
226959227428
int rc;
226960227429
int eType;
226961227430
sqlite3_value *pVal;
227431
+ int iIdx = pTab->aiIdx[i];
226962227432
226963227433
if( bNew ){
226964
- rc = pSession->hook.xNew(pSession->hook.pCtx, i, &pVal);
227434
+ rc = pSession->hook.xNew(pSession->hook.pCtx, iIdx, &pVal);
226965227435
}else{
226966
- rc = pSession->hook.xOld(pSession->hook.pCtx, i, &pVal);
227436
+ rc = pSession->hook.xOld(pSession->hook.pCtx, iIdx, &pVal);
226967227437
}
226968227438
if( rc!=SQLITE_OK ) return rc;
226969227439
226970227440
eType = sqlite3_value_type(pVal);
226971227441
h = sessionHashAppendType(h, eType);
@@ -227298,22 +227768,23 @@
227298227768
a += sessionSerialLen(a);
227299227769
}else{
227300227770
sqlite3_value *pVal; /* Value returned by preupdate_new/old */
227301227771
int rc; /* Error code from preupdate_new/old */
227302227772
int eType = *a++; /* Type of value from change record */
227773
+ int iIdx = pTab->aiIdx[iCol];
227303227774
227304227775
/* The following calls to preupdate_new() and preupdate_old() can not
227305227776
** fail. This is because they cache their return values, and by the
227306227777
** time control flows to here they have already been called once from
227307227778
** within sessionPreupdateHash(). The first two asserts below verify
227308227779
** this (that the method has already been called). */
227309227780
if( op==SQLITE_INSERT ){
227310227781
/* assert( db->pPreUpdate->pNewUnpacked || db->pPreUpdate->aNew ); */
227311
- rc = pSession->hook.xNew(pSession->hook.pCtx, iCol, &pVal);
227782
+ rc = pSession->hook.xNew(pSession->hook.pCtx, iIdx, &pVal);
227312227783
}else{
227313227784
/* assert( db->pPreUpdate->pUnpacked ); */
227314
- rc = pSession->hook.xOld(pSession->hook.pCtx, iCol, &pVal);
227785
+ rc = pSession->hook.xOld(pSession->hook.pCtx, iIdx, &pVal);
227315227786
}
227316227787
assert( rc==SQLITE_OK );
227317227788
(void)rc; /* Suppress warning about unused variable */
227318227789
if( sqlite3_value_type(pVal)!=eType ) return 0;
227319227790
@@ -227434,13 +227905,15 @@
227434227905
sqlite3_session *pSession, /* For memory accounting. May be NULL */
227435227906
sqlite3 *db, /* Database connection */
227436227907
const char *zDb, /* Name of attached database (e.g. "main") */
227437227908
const char *zThis, /* Table name */
227438227909
int *pnCol, /* OUT: number of columns */
227910
+ int *pnTotalCol, /* OUT: number of hidden columns */
227439227911
const char **pzTab, /* OUT: Copy of zThis */
227440227912
const char ***pazCol, /* OUT: Array of column names for table */
227441227913
const char ***pazDflt, /* OUT: Array of default value expressions */
227914
+ int **paiIdx, /* OUT: Array of xNew/xOld indexes */
227442227915
u8 **pabPK, /* OUT: Array of booleans - true for PK col */
227443227916
int *pbRowid /* OUT: True if only PK is a rowid */
227444227917
){
227445227918
char *zPragma;
227446227919
sqlite3_stmt *pStmt;
@@ -227451,37 +227924,40 @@
227451227924
int i;
227452227925
u8 *pAlloc = 0;
227453227926
char **azCol = 0;
227454227927
char **azDflt = 0;
227455227928
u8 *abPK = 0;
227929
+ int *aiIdx = 0;
227456227930
int bRowid = 0; /* Set to true to use rowid as PK */
227457227931
227458227932
assert( pazCol && pabPK );
227459227933
227460227934
*pazCol = 0;
227461227935
*pabPK = 0;
227462227936
*pnCol = 0;
227937
+ if( pnTotalCol ) *pnTotalCol = 0;
227938
+ if( paiIdx ) *paiIdx = 0;
227463227939
if( pzTab ) *pzTab = 0;
227464227940
if( pazDflt ) *pazDflt = 0;
227465227941
227466227942
nThis = sqlite3Strlen30(zThis);
227467227943
if( nThis==12 && 0==sqlite3_stricmp("sqlite_stat1", zThis) ){
227468227944
rc = sqlite3_table_column_metadata(db, zDb, zThis, 0, 0, 0, 0, 0, 0);
227469227945
if( rc==SQLITE_OK ){
227470227946
/* For sqlite_stat1, pretend that (tbl,idx) is the PRIMARY KEY. */
227471227947
zPragma = sqlite3_mprintf(
227472
- "SELECT 0, 'tbl', '', 0, '', 1 UNION ALL "
227473
- "SELECT 1, 'idx', '', 0, '', 2 UNION ALL "
227474
- "SELECT 2, 'stat', '', 0, '', 0"
227948
+ "SELECT 0, 'tbl', '', 0, '', 1, 0 UNION ALL "
227949
+ "SELECT 1, 'idx', '', 0, '', 2, 0 UNION ALL "
227950
+ "SELECT 2, 'stat', '', 0, '', 0, 0"
227475227951
);
227476227952
}else if( rc==SQLITE_ERROR ){
227477227953
zPragma = sqlite3_mprintf("");
227478227954
}else{
227479227955
return rc;
227480227956
}
227481227957
}else{
227482
- zPragma = sqlite3_mprintf("PRAGMA '%q'.table_info('%q')", zDb, zThis);
227958
+ zPragma = sqlite3_mprintf("PRAGMA '%q'.table_xinfo('%q')", zDb, zThis);
227483227959
}
227484227960
if( !zPragma ){
227485227961
return SQLITE_NOMEM;
227486227962
}
227487227963
@@ -227494,20 +227970,22 @@
227494227970
nByte = nThis + 1;
227495227971
bRowid = (pbRowid!=0);
227496227972
while( SQLITE_ROW==sqlite3_step(pStmt) ){
227497227973
nByte += sqlite3_column_bytes(pStmt, 1); /* name */
227498227974
nByte += sqlite3_column_bytes(pStmt, 4); /* dflt_value */
227499
- nDbCol++;
227975
+ if( sqlite3_column_int(pStmt, 6)==0 ){ /* !hidden */
227976
+ nDbCol++;
227977
+ }
227500227978
if( sqlite3_column_int(pStmt, 5) ) bRowid = 0; /* pk */
227501227979
}
227502227980
if( nDbCol==0 ) bRowid = 0;
227503227981
nDbCol += bRowid;
227504227982
nByte += strlen(SESSIONS_ROWID);
227505227983
rc = sqlite3_reset(pStmt);
227506227984
227507227985
if( rc==SQLITE_OK ){
227508
- nByte += nDbCol * (sizeof(const char *)*2 + sizeof(u8) + 1 + 1);
227986
+ nByte += nDbCol * (sizeof(const char *)*2 +sizeof(int)+sizeof(u8) + 1 + 1);
227509227987
pAlloc = sessionMalloc64(pSession, nByte);
227510227988
if( pAlloc==0 ){
227511227989
rc = SQLITE_NOMEM;
227512227990
}else{
227513227991
memset(pAlloc, 0, nByte);
@@ -227514,12 +227992,12 @@
227514227992
}
227515227993
}
227516227994
if( rc==SQLITE_OK ){
227517227995
azCol = (char **)pAlloc;
227518227996
azDflt = (char**)&azCol[nDbCol];
227519
- pAlloc = (u8 *)&azDflt[nDbCol];
227520
- abPK = (u8 *)pAlloc;
227997
+ aiIdx = (int*)&azDflt[nDbCol];
227998
+ abPK = (u8 *)&aiIdx[nDbCol];
227521227999
pAlloc = &abPK[nDbCol];
227522228000
if( pzTab ){
227523228001
memcpy(pAlloc, zThis, nThis+1);
227524228002
*pzTab = (char *)pAlloc;
227525228003
pAlloc += nThis+1;
@@ -227530,31 +228008,36 @@
227530228008
size_t nName = strlen(SESSIONS_ROWID);
227531228009
memcpy(pAlloc, SESSIONS_ROWID, nName+1);
227532228010
azCol[i] = (char*)pAlloc;
227533228011
pAlloc += nName+1;
227534228012
abPK[i] = 1;
228013
+ aiIdx[i] = -1;
227535228014
i++;
227536228015
}
227537228016
while( SQLITE_ROW==sqlite3_step(pStmt) ){
227538
- int nName = sqlite3_column_bytes(pStmt, 1);
227539
- int nDflt = sqlite3_column_bytes(pStmt, 4);
227540
- const unsigned char *zName = sqlite3_column_text(pStmt, 1);
227541
- const unsigned char *zDflt = sqlite3_column_text(pStmt, 4);
227542
-
227543
- if( zName==0 ) break;
227544
- memcpy(pAlloc, zName, nName+1);
227545
- azCol[i] = (char *)pAlloc;
227546
- pAlloc += nName+1;
227547
- if( zDflt ){
227548
- memcpy(pAlloc, zDflt, nDflt+1);
227549
- azDflt[i] = (char *)pAlloc;
227550
- pAlloc += nDflt+1;
227551
- }else{
227552
- azDflt[i] = 0;
227553
- }
227554
- abPK[i] = sqlite3_column_int(pStmt, 5);
227555
- i++;
228017
+ if( sqlite3_column_int(pStmt, 6)==0 ){ /* !hidden */
228018
+ int nName = sqlite3_column_bytes(pStmt, 1);
228019
+ int nDflt = sqlite3_column_bytes(pStmt, 4);
228020
+ const unsigned char *zName = sqlite3_column_text(pStmt, 1);
228021
+ const unsigned char *zDflt = sqlite3_column_text(pStmt, 4);
228022
+
228023
+ if( zName==0 ) break;
228024
+ memcpy(pAlloc, zName, nName+1);
228025
+ azCol[i] = (char *)pAlloc;
228026
+ pAlloc += nName+1;
228027
+ if( zDflt ){
228028
+ memcpy(pAlloc, zDflt, nDflt+1);
228029
+ azDflt[i] = (char *)pAlloc;
228030
+ pAlloc += nDflt+1;
228031
+ }else{
228032
+ azDflt[i] = 0;
228033
+ }
228034
+ abPK[i] = sqlite3_column_int(pStmt, 5);
228035
+ aiIdx[i] = sqlite3_column_int(pStmt, 0);
228036
+ i++;
228037
+ }
228038
+ if( pnTotalCol ) (*pnTotalCol)++;
227556228039
}
227557228040
rc = sqlite3_reset(pStmt);
227558228041
}
227559228042
227560228043
/* If successful, populate the output variables. Otherwise, zero them and
@@ -227563,10 +228046,11 @@
227563228046
if( rc==SQLITE_OK ){
227564228047
*pazCol = (const char**)azCol;
227565228048
if( pazDflt ) *pazDflt = (const char**)azDflt;
227566228049
*pabPK = abPK;
227567228050
*pnCol = nDbCol;
228051
+ if( paiIdx ) *paiIdx = aiIdx;
227568228052
}else{
227569228053
sessionFree(pSession, azCol);
227570228054
}
227571228055
if( pbRowid ) *pbRowid = bRowid;
227572228056
sqlite3_finalize(pStmt);
@@ -227594,11 +228078,12 @@
227594228078
227595228079
if( pTab->nCol==0 ){
227596228080
u8 *abPK;
227597228081
assert( pTab->azCol==0 || pTab->abPK==0 );
227598228082
rc = sessionTableInfo(pSession, db, zDb,
227599
- pTab->zName, &pTab->nCol, 0, &pTab->azCol, &pTab->azDflt, &abPK,
228083
+ pTab->zName, &pTab->nCol, &pTab->nTotalCol, 0, &pTab->azCol,
228084
+ &pTab->azDflt, &pTab->aiIdx, &abPK,
227600228085
((pSession==0 || pSession->bImplicitPK) ? &pTab->bRowid : 0)
227601228086
);
227602228087
if( rc==SQLITE_OK ){
227603228088
int i;
227604228089
for(i=0; i<pTab->nCol; i++){
@@ -227629,19 +228114,21 @@
227629228114
/*
227630228115
** Re-initialize table object pTab.
227631228116
*/
227632228117
static int sessionReinitTable(sqlite3_session *pSession, SessionTable *pTab){
227633228118
int nCol = 0;
228119
+ int nTotalCol = 0;
227634228120
const char **azCol = 0;
227635228121
const char **azDflt = 0;
228122
+ int *aiIdx = 0;
227636228123
u8 *abPK = 0;
227637228124
int bRowid = 0;
227638228125
227639228126
assert( pSession->rc==SQLITE_OK );
227640228127
227641228128
pSession->rc = sessionTableInfo(pSession, pSession->db, pSession->zDb,
227642
- pTab->zName, &nCol, 0, &azCol, &azDflt, &abPK,
228129
+ pTab->zName, &nCol, &nTotalCol, 0, &azCol, &azDflt, &aiIdx, &abPK,
227643228130
(pSession->bImplicitPK ? &bRowid : 0)
227644228131
);
227645228132
if( pSession->rc==SQLITE_OK ){
227646228133
if( pTab->nCol>nCol || pTab->bRowid!=bRowid ){
227647228134
pSession->rc = SQLITE_SCHEMA;
@@ -227660,12 +228147,14 @@
227660228147
227661228148
if( pSession->rc==SQLITE_OK ){
227662228149
const char **a = pTab->azCol;
227663228150
pTab->azCol = azCol;
227664228151
pTab->nCol = nCol;
228152
+ pTab->nTotalCol = nTotalCol;
227665228153
pTab->azDflt = azDflt;
227666228154
pTab->abPK = abPK;
228155
+ pTab->aiIdx = aiIdx;
227667228156
azCol = a;
227668228157
}
227669228158
if( pSession->bEnableSize ){
227670228159
pSession->nMaxChangesetSize += (nCol - nOldCol);
227671228160
pSession->nMaxChangesetSize += sessionVarintLen(nCol);
@@ -227979,11 +228468,11 @@
227979228468
if( pTab->bRowid ) nNew += 9;
227980228469
if( op!=SQLITE_DELETE ){
227981228470
int ii;
227982228471
for(ii=0; ii<pTab->nCol; ii++){
227983228472
sqlite3_value *p = 0;
227984
- pSession->hook.xNew(pSession->hook.pCtx, ii, &p);
228473
+ pSession->hook.xNew(pSession->hook.pCtx, pTab->aiIdx[ii], &p);
227985228474
sessionSerializeValue(0, p, &nNew);
227986228475
}
227987228476
}
227988228477
}else if( op==SQLITE_DELETE ){
227989228478
nNew += pC->nRecord;
@@ -227999,12 +228488,13 @@
227999228488
}
228000228489
for(ii=pTab->bRowid; ii<pTab->nCol; ii++){
228001228490
int bChanged = 1;
228002228491
int nOld = 0;
228003228492
int eType;
228493
+ int iIdx = pTab->aiIdx[ii];
228004228494
sqlite3_value *p = 0;
228005
- pSession->hook.xNew(pSession->hook.pCtx, ii-pTab->bRowid, &p);
228495
+ pSession->hook.xNew(pSession->hook.pCtx, iIdx, &p);
228006228496
if( p==0 ){
228007228497
return SQLITE_NOMEM;
228008228498
}
228009228499
228010228500
eType = *pCsr++;
@@ -228097,15 +228587,15 @@
228097228587
if( sessionInitTable(pSession, pTab, pSession->db, pSession->zDb) ) return;
228098228588
228099228589
/* Check the number of columns in this xPreUpdate call matches the
228100228590
** number of columns in the table. */
228101228591
nExpect = pSession->hook.xCount(pSession->hook.pCtx);
228102
- if( (pTab->nCol-pTab->bRowid)<nExpect ){
228592
+ if( pTab->nTotalCol<nExpect ){
228103228593
if( sessionReinitTable(pSession, pTab) ) return;
228104228594
if( sessionUpdateChanges(pSession, pTab) ) return;
228105228595
}
228106
- if( (pTab->nCol-pTab->bRowid)!=nExpect ){
228596
+ if( pTab->nTotalCol!=nExpect ){
228107228597
pSession->rc = SQLITE_SCHEMA;
228108228598
return;
228109228599
}
228110228600
228111228601
/* Grow the hash table if required */
@@ -228158,18 +228648,19 @@
228158228648
assert( rc==SQLITE_OK );
228159228649
pTab->nEntry++;
228160228650
228161228651
/* Figure out how large an allocation is required */
228162228652
nByte = sizeof(SessionChange);
228163
- for(i=0; i<(pTab->nCol-pTab->bRowid); i++){
228653
+ for(i=pTab->bRowid; i<pTab->nCol; i++){
228654
+ int iIdx = pTab->aiIdx[i];
228164228655
sqlite3_value *p = 0;
228165228656
if( op!=SQLITE_INSERT ){
228166228657
/* This may fail if the column has a non-NULL default and was added
228167228658
** using ALTER TABLE ADD COLUMN after this record was created. */
228168
- rc = pSession->hook.xOld(pSession->hook.pCtx, i, &p);
228659
+ rc = pSession->hook.xOld(pSession->hook.pCtx, iIdx, &p);
228169228660
}else if( pTab->abPK[i] ){
228170
- TESTONLY(int trc = ) pSession->hook.xNew(pSession->hook.pCtx, i, &p);
228661
+ TESTONLY(int trc = ) pSession->hook.xNew(pSession->hook.pCtx,iIdx,&p);
228171228662
assert( trc==SQLITE_OK );
228172228663
}
228173228664
228174228665
if( rc==SQLITE_OK ){
228175228666
/* This may fail if SQLite value p contains a utf-16 string that must
@@ -228200,16 +228691,17 @@
228200228691
if( pTab->bRowid ){
228201228692
pC->aRecord[0] = SQLITE_INTEGER;
228202228693
sessionPutI64(&pC->aRecord[1], iRowid);
228203228694
nByte = 9;
228204228695
}
228205
- for(i=0; i<(pTab->nCol-pTab->bRowid); i++){
228696
+ for(i=pTab->bRowid; i<pTab->nCol; i++){
228206228697
sqlite3_value *p = 0;
228698
+ int iIdx = pTab->aiIdx[i];
228207228699
if( op!=SQLITE_INSERT ){
228208
- pSession->hook.xOld(pSession->hook.pCtx, i, &p);
228700
+ pSession->hook.xOld(pSession->hook.pCtx, iIdx, &p);
228209228701
}else if( pTab->abPK[i] ){
228210
- pSession->hook.xNew(pSession->hook.pCtx, i, &p);
228702
+ pSession->hook.xNew(pSession->hook.pCtx, iIdx, &p);
228211228703
}
228212228704
sessionSerializeValue(&pC->aRecord[nByte], p, &nByte);
228213228705
}
228214228706
228215228707
/* Add the change to the hash-table */
@@ -228607,11 +229099,12 @@
228607229099
int bMismatch = 0;
228608229100
int nCol; /* Columns in zFrom.zTbl */
228609229101
int bRowid = 0;
228610229102
u8 *abPK;
228611229103
const char **azCol = 0;
228612
- rc = sessionTableInfo(0, db, zFrom, zTbl, &nCol, 0, &azCol, 0, &abPK,
229104
+ rc = sessionTableInfo(0, db, zFrom, zTbl,
229105
+ &nCol, 0, 0, &azCol, 0, 0, &abPK,
228613229106
pSession->bImplicitPK ? &bRowid : 0
228614229107
);
228615229108
if( rc==SQLITE_OK ){
228616229109
if( pTo->nCol!=nCol ){
228617229110
bMismatch = 1;
@@ -228931,13 +229424,15 @@
228931229424
int nStr = sqlite3Strlen30(zStr)*2 + 2 + 2;
228932229425
if( 0==sessionBufferGrow(p, nStr, pRc) ){
228933229426
char *zOut = (char *)&p->aBuf[p->nBuf];
228934229427
const char *zIn = zStr;
228935229428
*zOut++ = '"';
228936
- while( *zIn ){
228937
- if( *zIn=='"' ) *zOut++ = '"';
228938
- *zOut++ = *(zIn++);
229429
+ if( zIn!=0 ){
229430
+ while( *zIn ){
229431
+ if( *zIn=='"' ) *zOut++ = '"';
229432
+ *zOut++ = *(zIn++);
229433
+ }
228939229434
}
228940229435
*zOut++ = '"';
228941229436
p->nBuf = (int)((u8 *)zOut - p->aBuf);
228942229437
p->aBuf[p->nBuf] = 0x00;
228943229438
}
@@ -229184,14 +229679,14 @@
229184229679
sqlite3_stmt **ppStmt /* OUT: Prepared SELECT statement */
229185229680
){
229186229681
int rc = SQLITE_OK;
229187229682
char *zSql = 0;
229188229683
const char *zSep = "";
229189
- const char *zCols = bRowid ? SESSIONS_ROWID ", *" : "*";
229190229684
int nSql = -1;
229191229685
int i;
229192229686
229687
+ SessionBuffer cols = {0, 0, 0};
229193229688
SessionBuffer nooptest = {0, 0, 0};
229194229689
SessionBuffer pkfield = {0, 0, 0};
229195229690
SessionBuffer pkvar = {0, 0, 0};
229196229691
229197229692
sessionAppendStr(&nooptest, ", 1", &rc);
@@ -229200,13 +229695,20 @@
229200229695
sessionAppendStr(&nooptest, " AND (?6 OR ?3 IS stat)", &rc);
229201229696
sessionAppendStr(&pkfield, "tbl, idx", &rc);
229202229697
sessionAppendStr(&pkvar,
229203229698
"?1, (CASE WHEN ?2=X'' THEN NULL ELSE ?2 END)", &rc
229204229699
);
229205
- zCols = "tbl, ?2, stat";
229700
+ sessionAppendStr(&cols, "tbl, ?2, stat", &rc);
229206229701
}else{
229702
+ #if 0
229703
+ if( bRowid ){
229704
+ sessionAppendStr(&cols, SESSIONS_ROWID, &rc);
229705
+ }
229706
+ #endif
229207229707
for(i=0; i<nCol; i++){
229708
+ if( cols.nBuf ) sessionAppendStr(&cols, ", ", &rc);
229709
+ sessionAppendIdent(&cols, azCol[i], &rc);
229208229710
if( abPK[i] ){
229209229711
sessionAppendStr(&pkfield, zSep, &rc);
229210229712
sessionAppendStr(&pkvar, zSep, &rc);
229211229713
zSep = ", ";
229212229714
sessionAppendIdent(&pkfield, azCol[i], &rc);
@@ -229220,11 +229722,11 @@
229220229722
}
229221229723
229222229724
if( rc==SQLITE_OK ){
229223229725
zSql = sqlite3_mprintf(
229224229726
"SELECT %s%s FROM %Q.%Q WHERE (%s) IS (%s)",
229225
- zCols, (bIgnoreNoop ? (char*)nooptest.aBuf : ""),
229727
+ (char*)cols.aBuf, (bIgnoreNoop ? (char*)nooptest.aBuf : ""),
229226229728
zDb, zTab, (char*)pkfield.aBuf, (char*)pkvar.aBuf
229227229729
);
229228229730
if( zSql==0 ) rc = SQLITE_NOMEM;
229229229731
}
229230229732
@@ -229263,10 +229765,11 @@
229263229765
}
229264229766
sqlite3_free(zSql);
229265229767
sqlite3_free(nooptest.aBuf);
229266229768
sqlite3_free(pkfield.aBuf);
229267229769
sqlite3_free(pkvar.aBuf);
229770
+ sqlite3_free(cols.aBuf);
229268229771
return rc;
229269229772
}
229270229773
229271229774
/*
229272229775
** Bind the PRIMARY KEY values from the change passed in argument pChange
@@ -231603,11 +232106,12 @@
231603232106
int nMinCol = 0;
231604232107
int i;
231605232108
231606232109
sqlite3changeset_pk(pIter, &abPK, 0);
231607232110
rc = sessionTableInfo(0, db, "main", zNew,
231608
- &sApply.nCol, &zTab, &sApply.azCol, 0, &sApply.abPK, &sApply.bRowid
232111
+ &sApply.nCol, 0, &zTab, &sApply.azCol, 0, 0,
232112
+ &sApply.abPK, &sApply.bRowid
231609232113
);
231610232114
if( rc!=SQLITE_OK ) break;
231611232115
for(i=0; i<sApply.nCol; i++){
231612232116
if( sApply.abPK[i] ) nMinCol = i+1;
231613232117
}
@@ -231683,16 +232187,21 @@
231683232187
if( res!=SQLITE_CHANGESET_OMIT ){
231684232188
rc = SQLITE_CONSTRAINT;
231685232189
}
231686232190
}
231687232191
}
231688
- sqlite3_exec(db, "PRAGMA defer_foreign_keys = 0", 0, 0, 0);
232192
+
232193
+ {
232194
+ int rc2 = sqlite3_exec(db, "PRAGMA defer_foreign_keys = 0", 0, 0, 0);
232195
+ if( rc==SQLITE_OK ) rc = rc2;
232196
+ }
231689232197
231690232198
if( (flags & SQLITE_CHANGESETAPPLY_NOSAVEPOINT)==0 ){
231691232199
if( rc==SQLITE_OK ){
231692232200
rc = sqlite3_exec(db, "RELEASE changeset_apply", 0, 0, 0);
231693
- }else{
232201
+ }
232202
+ if( rc!=SQLITE_OK ){
231694232203
sqlite3_exec(db, "ROLLBACK TO changeset_apply", 0, 0, 0);
231695232204
sqlite3_exec(db, "RELEASE changeset_apply", 0, 0, 0);
231696232205
}
231697232206
}
231698232207
@@ -243195,15 +243704,17 @@
243195243704
}
243196243705
243197243706
/*
243198243707
** Close the read-only blob handle, if it is open.
243199243708
*/
243200
-static void sqlite3Fts5IndexCloseReader(Fts5Index *p){
243709
+static void fts5IndexCloseReader(Fts5Index *p){
243201243710
if( p->pReader ){
243711
+ int rc;
243202243712
sqlite3_blob *pReader = p->pReader;
243203243713
p->pReader = 0;
243204
- sqlite3_blob_close(pReader);
243714
+ rc = sqlite3_blob_close(pReader);
243715
+ if( p->rc==SQLITE_OK ) p->rc = rc;
243205243716
}
243206243717
}
243207243718
243208243719
/*
243209243720
** Retrieve a record from the %_data table.
@@ -243224,11 +243735,11 @@
243224243735
p->pReader = 0;
243225243736
rc = sqlite3_blob_reopen(pBlob, iRowid);
243226243737
assert( p->pReader==0 );
243227243738
p->pReader = pBlob;
243228243739
if( rc!=SQLITE_OK ){
243229
- sqlite3Fts5IndexCloseReader(p);
243740
+ fts5IndexCloseReader(p);
243230243741
}
243231243742
if( rc==SQLITE_ABORT ) rc = SQLITE_OK;
243232243743
}
243233243744
243234243745
/* If the blob handle is not open at this point, open it and seek
@@ -243308,13 +243819,17 @@
243308243819
sqlite3_stmt **ppStmt,
243309243820
char *zSql
243310243821
){
243311243822
if( p->rc==SQLITE_OK ){
243312243823
if( zSql ){
243313
- p->rc = sqlite3_prepare_v3(p->pConfig->db, zSql, -1,
243824
+ int rc = sqlite3_prepare_v3(p->pConfig->db, zSql, -1,
243314243825
SQLITE_PREPARE_PERSISTENT|SQLITE_PREPARE_NO_VTAB,
243315243826
ppStmt, 0);
243827
+ /* If this prepare() call fails with SQLITE_ERROR, then one of the
243828
+ ** %_idx or %_data tables has been removed or modified. Call this
243829
+ ** corruption. */
243830
+ p->rc = (rc==SQLITE_ERROR ? SQLITE_CORRUPT : rc);
243316243831
}else{
243317243832
p->rc = SQLITE_NOMEM;
243318243833
}
243319243834
}
243320243835
sqlite3_free(zSql);
@@ -247421,10 +247936,18 @@
247421247936
static int fts5IndexReturn(Fts5Index *p){
247422247937
int rc = p->rc;
247423247938
p->rc = SQLITE_OK;
247424247939
return rc;
247425247940
}
247941
+
247942
+/*
247943
+** Close the read-only blob handle, if it is open.
247944
+*/
247945
+static void sqlite3Fts5IndexCloseReader(Fts5Index *p){
247946
+ fts5IndexCloseReader(p);
247947
+ fts5IndexReturn(p);
247948
+}
247426247949
247427247950
typedef struct Fts5FlushCtx Fts5FlushCtx;
247428247951
struct Fts5FlushCtx {
247429247952
Fts5Index *pIdx;
247430247953
Fts5SegWriter writer;
@@ -247609,11 +248132,11 @@
247609248132
int iIdx = 0;
247610248133
int iStart = 0;
247611248134
int iDelKeyOff = 0; /* Offset of deleted key, if any */
247612248135
247613248136
nIdx = nPg-iPgIdx;
247614
- aIdx = sqlite3Fts5MallocZero(&p->rc, nIdx+16);
248137
+ aIdx = sqlite3Fts5MallocZero(&p->rc, ((i64)nIdx)+16);
247615248138
if( p->rc ) return;
247616248139
memcpy(aIdx, &aPg[iPgIdx], nIdx);
247617248140
247618248141
/* At this point segment iterator pSeg points to the entry
247619248142
** this function should remove from the b-tree segment.
@@ -247879,20 +248402,41 @@
247879248402
247880248403
/*
247881248404
** This is called as part of flushing a delete to disk in 'secure-delete'
247882248405
** mode. It edits the segments within the database described by argument
247883248406
** pStruct to remove the entries for term zTerm, rowid iRowid.
248407
+**
248408
+** Return SQLITE_OK if successful, or an SQLite error code if an error
248409
+** has occurred. Any error code is also stored in the Fts5Index handle.
247884248410
*/
247885
-static void fts5FlushSecureDelete(
248411
+static int fts5FlushSecureDelete(
247886248412
Fts5Index *p,
247887248413
Fts5Structure *pStruct,
247888248414
const char *zTerm,
247889248415
int nTerm,
247890248416
i64 iRowid
247891248417
){
247892248418
const int f = FTS5INDEX_QUERY_SKIPHASH;
247893248419
Fts5Iter *pIter = 0; /* Used to find term instance */
248420
+
248421
+ /* If the version number has not been set to SECUREDELETE, do so now. */
248422
+ if( p->pConfig->iVersion!=FTS5_CURRENT_VERSION_SECUREDELETE ){
248423
+ Fts5Config *pConfig = p->pConfig;
248424
+ sqlite3_stmt *pStmt = 0;
248425
+ fts5IndexPrepareStmt(p, &pStmt, sqlite3_mprintf(
248426
+ "REPLACE INTO %Q.'%q_config' VALUES ('version', %d)",
248427
+ pConfig->zDb, pConfig->zName, FTS5_CURRENT_VERSION_SECUREDELETE
248428
+ ));
248429
+ if( p->rc==SQLITE_OK ){
248430
+ int rc;
248431
+ sqlite3_step(pStmt);
248432
+ rc = sqlite3_finalize(pStmt);
248433
+ if( p->rc==SQLITE_OK ) p->rc = rc;
248434
+ pConfig->iCookie++;
248435
+ pConfig->iVersion = FTS5_CURRENT_VERSION_SECUREDELETE;
248436
+ }
248437
+ }
247894248438
247895248439
fts5MultiIterNew(p, pStruct, f, 0, (const u8*)zTerm, nTerm, -1, 0, &pIter);
247896248440
if( fts5MultiIterEof(p, pIter)==0 ){
247897248441
i64 iThis = fts5MultiIterRowid(pIter);
247898248442
if( iThis<iRowid ){
@@ -247907,10 +248451,11 @@
247907248451
fts5DoSecureDelete(p, pSeg);
247908248452
}
247909248453
}
247910248454
247911248455
fts5MultiIterFree(pIter);
248456
+ return p->rc;
247912248457
}
247913248458
247914248459
247915248460
/*
247916248461
** Flush the contents of in-memory hash table iHash to a new level-0
@@ -247990,22 +248535,24 @@
247990248535
/* If in secure delete mode, and if this entry in the poslist is
247991248536
** in fact a delete, then edit the existing segments directly
247992248537
** using fts5FlushSecureDelete(). */
247993248538
if( bSecureDelete ){
247994248539
if( eDetail==FTS5_DETAIL_NONE ){
247995
- if( iOff<nDoclist && pDoclist[iOff]==0x00 ){
247996
- fts5FlushSecureDelete(p, pStruct, zTerm, nTerm, iRowid);
248540
+ if( iOff<nDoclist && pDoclist[iOff]==0x00
248541
+ && !fts5FlushSecureDelete(p, pStruct, zTerm, nTerm, iRowid)
248542
+ ){
247997248543
iOff++;
247998248544
if( iOff<nDoclist && pDoclist[iOff]==0x00 ){
247999248545
iOff++;
248000248546
nDoclist = 0;
248001248547
}else{
248002248548
continue;
248003248549
}
248004248550
}
248005
- }else if( (pDoclist[iOff] & 0x01) ){
248006
- fts5FlushSecureDelete(p, pStruct, zTerm, nTerm, iRowid);
248551
+ }else if( (pDoclist[iOff] & 0x01)
248552
+ && !fts5FlushSecureDelete(p, pStruct, zTerm, nTerm, iRowid)
248553
+ ){
248007248554
if( p->rc!=SQLITE_OK || pDoclist[iOff]==0x01 ){
248008248555
iOff++;
248009248556
continue;
248010248557
}
248011248558
}
@@ -248179,11 +248726,11 @@
248179248726
return pStruct;
248180248727
}
248181248728
assert( pStruct->aLevel[i].nMerge<=nThis );
248182248729
}
248183248730
248184
- nByte += (pStruct->nLevel+1) * sizeof(Fts5StructureLevel);
248731
+ nByte += (((i64)pStruct->nLevel)+1) * sizeof(Fts5StructureLevel);
248185248732
pNew = (Fts5Structure*)sqlite3Fts5MallocZero(&p->rc, nByte);
248186248733
248187248734
if( pNew ){
248188248735
Fts5StructureLevel *pLvl;
248189248736
nByte = nSeg * sizeof(Fts5StructureSegment);
@@ -249067,18 +249614,21 @@
249067249614
for(iFree=i; iFree<i+s.nMerge; iFree++){
249068249615
fts5BufferFree(&s.aBuf[iFree]);
249069249616
}
249070249617
}
249071249618
249072
- pData = fts5IdxMalloc(p, sizeof(*pData)+s.doclist.n+FTS5_DATA_ZERO_PADDING);
249619
+ pData = fts5IdxMalloc(p, sizeof(*pData)
249620
+ + ((i64)s.doclist.n)+FTS5_DATA_ZERO_PADDING);
249621
+ assert( pData!=0 || p->rc!=SQLITE_OK );
249073249622
if( pData ){
249074249623
pData->p = (u8*)&pData[1];
249075249624
pData->nn = pData->szLeaf = s.doclist.n;
249076249625
if( s.doclist.n ) memcpy(pData->p, s.doclist.p, s.doclist.n);
249077249626
fts5MultiIterNew2(p, pData, bDesc, ppIter);
249078249627
}
249079249628
249629
+ assert( (*ppIter)!=0 || p->rc!=SQLITE_OK );
249080249630
if( p->rc==SQLITE_OK && s.pTokendata ){
249081249631
fts5TokendataIterSortMap(p, s2.pT);
249082249632
(*ppIter)->pTokenDataIter = s2.pT;
249083249633
s2.pT = 0;
249084249634
}
@@ -249123,11 +249673,11 @@
249123249673
** Commit data to disk.
249124249674
*/
249125249675
static int sqlite3Fts5IndexSync(Fts5Index *p){
249126249676
assert( p->rc==SQLITE_OK );
249127249677
fts5IndexFlush(p);
249128
- sqlite3Fts5IndexCloseReader(p);
249678
+ fts5IndexCloseReader(p);
249129249679
return fts5IndexReturn(p);
249130249680
}
249131249681
249132249682
/*
249133249683
** Discard any data stored in the in-memory hash tables. Do not write it
@@ -249134,15 +249684,14 @@
249134249684
** to the database. Additionally, assume that the contents of the %_data
249135249685
** table may have changed on disk. So any in-memory caches of %_data
249136249686
** records must be invalidated.
249137249687
*/
249138249688
static int sqlite3Fts5IndexRollback(Fts5Index *p){
249139
- sqlite3Fts5IndexCloseReader(p);
249689
+ fts5IndexCloseReader(p);
249140249690
fts5IndexDiscardData(p);
249141249691
fts5StructureInvalidate(p);
249142
- /* assert( p->rc==SQLITE_OK ); */
249143
- return SQLITE_OK;
249692
+ return fts5IndexReturn(p);
249144249693
}
249145249694
249146249695
/*
249147249696
** The %_data table is completely empty when this function is called. This
249148249697
** function populates it with the initial structure objects for each index,
@@ -249338,10 +249887,20 @@
249338249887
*/
249339249888
static void fts5SegIterSetEOF(Fts5SegIter *pSeg){
249340249889
fts5DataRelease(pSeg->pLeaf);
249341249890
pSeg->pLeaf = 0;
249342249891
}
249892
+
249893
+static void fts5IterClose(Fts5IndexIter *pIndexIter){
249894
+ if( pIndexIter ){
249895
+ Fts5Iter *pIter = (Fts5Iter*)pIndexIter;
249896
+ Fts5Index *pIndex = pIter->pIndex;
249897
+ fts5TokendataIterDelete(pIter->pTokenDataIter);
249898
+ fts5MultiIterFree(pIter);
249899
+ fts5IndexCloseReader(pIndex);
249900
+ }
249901
+}
249343249902
249344249903
/*
249345249904
** This function appends iterator pAppend to Fts5TokenDataIter pIn and
249346249905
** returns the result.
249347249906
*/
@@ -249366,11 +249925,11 @@
249366249925
pNew->nIterAlloc = nAlloc;
249367249926
}
249368249927
}
249369249928
}
249370249929
if( p->rc ){
249371
- sqlite3Fts5IterClose((Fts5IndexIter*)pAppend);
249930
+ fts5IterClose((Fts5IndexIter*)pAppend);
249372249931
}else{
249373249932
pRet->apIter[pRet->nIter++] = pAppend;
249374249933
}
249375249934
assert( pRet==0 || pRet->nIter<=pRet->nIterAlloc );
249376249935
@@ -249579,11 +250138,11 @@
249579250138
fts5BufferAppendBlob(&p->rc, &bSeek, 1, (const u8*)"\0");
249580250139
}else{
249581250140
fts5BufferSet(&p->rc, &bSeek, nToken, pToken);
249582250141
}
249583250142
if( p->rc ){
249584
- sqlite3Fts5IterClose((Fts5IndexIter*)pNew);
250143
+ fts5IterClose((Fts5IndexIter*)pNew);
249585250144
break;
249586250145
}
249587250146
249588250147
pNewIter = &pNew->aSeg[0];
249589250148
pPrevIter = (pPrev ? &pPrev->aSeg[0] : 0);
@@ -249644,11 +250203,11 @@
249644250203
249645250204
/* If pSmall is still NULL at this point, then the new iterator does
249646250205
** not point to any terms that match the query. So delete it and break
249647250206
** out of the loop - all required iterators have been collected. */
249648250207
if( pSmall==0 ){
249649
- sqlite3Fts5IterClose((Fts5IndexIter*)pNew);
250208
+ fts5IterClose((Fts5IndexIter*)pNew);
249650250209
break;
249651250210
}
249652250211
249653250212
/* Append this iterator to the set and continue. */
249654250213
pSet = fts5AppendTokendataIter(p, pSet, pNew);
@@ -249706,10 +250265,11 @@
249706250265
249707250266
if( sqlite3Fts5BufferSize(&p->rc, &buf, nToken+1)==0 ){
249708250267
int iIdx = 0; /* Index to search */
249709250268
int iPrefixIdx = 0; /* +1 prefix index */
249710250269
int bTokendata = pConfig->bTokendata;
250270
+ assert( buf.p!=0 );
249711250271
if( nToken>0 ) memcpy(&buf.p[1], pToken, nToken);
249712250272
249713250273
/* The NOTOKENDATA flag is set when each token in a tokendata=1 table
249714250274
** should be treated individually, instead of merging all those with
249715250275
** a common prefix into a single entry. This is used, for example, by
@@ -249772,13 +250332,13 @@
249772250332
}
249773250333
}
249774250334
}
249775250335
249776250336
if( p->rc ){
249777
- sqlite3Fts5IterClose((Fts5IndexIter*)pRet);
250337
+ fts5IterClose((Fts5IndexIter*)pRet);
249778250338
pRet = 0;
249779
- sqlite3Fts5IndexCloseReader(p);
250339
+ fts5IndexCloseReader(p);
249780250340
}
249781250341
249782250342
*ppIter = (Fts5IndexIter*)pRet;
249783250343
sqlite3Fts5BufferFree(&buf);
249784250344
}
@@ -249867,10 +250427,11 @@
249867250427
TokendataSetupCtx ctx;
249868250428
249869250429
memset(&ctx, 0, sizeof(ctx));
249870250430
249871250431
fts5BufferGrow(&p->rc, &token, nToken+1);
250432
+ assert( token.p!=0 || p->rc!=SQLITE_OK );
249872250433
ctx.pT = (Fts5TokenDataIter*)sqlite3Fts5MallocZero(&p->rc, sizeof(*ctx.pT));
249873250434
249874250435
if( p->rc==SQLITE_OK ){
249875250436
249876250437
/* Fill in the token prefix to search for */
@@ -250023,15 +250584,13 @@
250023250584
/*
250024250585
** Close an iterator opened by an earlier call to sqlite3Fts5IndexQuery().
250025250586
*/
250026250587
static void sqlite3Fts5IterClose(Fts5IndexIter *pIndexIter){
250027250588
if( pIndexIter ){
250028
- Fts5Iter *pIter = (Fts5Iter*)pIndexIter;
250029
- Fts5Index *pIndex = pIter->pIndex;
250030
- fts5TokendataIterDelete(pIter->pTokenDataIter);
250031
- fts5MultiIterFree(pIter);
250032
- sqlite3Fts5IndexCloseReader(pIndex);
250589
+ Fts5Index *pIndex = ((Fts5Iter*)pIndexIter)->pIndex;
250590
+ fts5IterClose(pIndexIter);
250591
+ fts5IndexReturn(pIndex);
250033250592
}
250034250593
}
250035250594
250036250595
/*
250037250596
** Read and decode the "averages" record from the database.
@@ -250557,11 +251116,11 @@
250557251116
}
250558251117
if( rc==SQLITE_OK ){
250559251118
rc = sqlite3Fts5IterNext(pIter);
250560251119
}
250561251120
}
250562
- sqlite3Fts5IterClose(pIter);
251121
+ fts5IterClose(pIter);
250563251122
250564251123
*pCksum = cksum;
250565251124
return rc;
250566251125
}
250567251126
@@ -251280,11 +251839,11 @@
251280251839
/* Make a copy of the second argument (a blob) in aBlob[]. The aBlob[]
251281251840
** copy is followed by FTS5_DATA_ZERO_PADDING 0x00 bytes, which prevents
251282251841
** buffer overreads even if the record is corrupt. */
251283251842
n = sqlite3_value_bytes(apVal[1]);
251284251843
aBlob = sqlite3_value_blob(apVal[1]);
251285
- nSpace = n + FTS5_DATA_ZERO_PADDING;
251844
+ nSpace = ((i64)n) + FTS5_DATA_ZERO_PADDING;
251286251845
a = (u8*)sqlite3Fts5MallocZero(&rc, nSpace);
251287251846
if( a==0 ) goto decode_out;
251288251847
if( n>0 ) memcpy(a, aBlob, n);
251289251848
251290251849
fts5DecodeRowid(iRowid, &bTomb, &iSegid, &bDlidx, &iHeight, &iPgno);
@@ -253726,11 +254285,10 @@
253726254285
){
253727254286
Fts5FullTable *pTab = (Fts5FullTable*)pVtab;
253728254287
Fts5Config *pConfig = pTab->p.pConfig;
253729254288
int eType0; /* value_type() of apVal[0] */
253730254289
int rc = SQLITE_OK; /* Return code */
253731
- int bUpdateOrDelete = 0;
253732254290
253733254291
/* A transaction must be open when this is called. */
253734254292
assert( pTab->ts.eState==1 || pTab->ts.eState==2 );
253735254293
253736254294
assert( pVtab->zErrMsg==0 );
@@ -253738,11 +254296,11 @@
253738254296
assert( sqlite3_value_type(apVal[0])==SQLITE_INTEGER
253739254297
|| sqlite3_value_type(apVal[0])==SQLITE_NULL
253740254298
);
253741254299
assert( pTab->p.pConfig->pzErrmsg==0 );
253742254300
if( pConfig->pgsz==0 ){
253743
- rc = sqlite3Fts5IndexLoadConfig(pTab->p.pIndex);
254301
+ rc = sqlite3Fts5ConfigLoad(pTab->p.pConfig, pTab->p.pConfig->iCookie);
253744254302
if( rc!=SQLITE_OK ) return rc;
253745254303
}
253746254304
253747254305
pTab->p.pConfig->pzErrmsg = &pTab->p.base.zErrMsg;
253748254306
@@ -253763,11 +254321,10 @@
253763254321
"'delete' may not be used with a contentless_delete=1 table"
253764254322
);
253765254323
rc = SQLITE_ERROR;
253766254324
}else{
253767254325
rc = fts5SpecialDelete(pTab, apVal);
253768
- bUpdateOrDelete = 1;
253769254326
}
253770254327
}else{
253771254328
rc = fts5SpecialInsert(pTab, z, apVal[2 + pConfig->nCol + 1]);
253772254329
}
253773254330
}else{
@@ -253800,11 +254357,10 @@
253800254357
);
253801254358
rc = SQLITE_ERROR;
253802254359
}else{
253803254360
i64 iDel = sqlite3_value_int64(apVal[0]); /* Rowid to delete */
253804254361
rc = sqlite3Fts5StorageDelete(pTab->pStorage, iDel, 0, 0);
253805
- bUpdateOrDelete = 1;
253806254362
}
253807254363
}
253808254364
253809254365
/* INSERT or UPDATE */
253810254366
else{
@@ -253828,11 +254384,10 @@
253828254384
/* An INSERT statement. If the conflict-mode is REPLACE, first remove
253829254385
** the current entry (if any). */
253830254386
if( eConflict==SQLITE_REPLACE && eType1==SQLITE_INTEGER ){
253831254387
i64 iNew = sqlite3_value_int64(apVal[1]); /* Rowid to delete */
253832254388
rc = sqlite3Fts5StorageDelete(pTab->pStorage, iNew, 0, 0);
253833
- bUpdateOrDelete = 1;
253834254389
}
253835254390
fts5StorageInsert(&rc, pTab, apVal, pRowid);
253836254391
}
253837254392
253838254393
/* UPDATE */
@@ -253882,27 +254437,12 @@
253882254437
}
253883254438
}else{
253884254439
rc = sqlite3Fts5StorageDelete(pStorage, iOld, 0, 1);
253885254440
fts5StorageInsert(&rc, pTab, apVal, pRowid);
253886254441
}
253887
- bUpdateOrDelete = 1;
253888254442
sqlite3Fts5StorageReleaseDeleteRow(pStorage);
253889254443
}
253890
-
253891
- }
253892
- }
253893
-
253894
- if( rc==SQLITE_OK
253895
- && bUpdateOrDelete
253896
- && pConfig->bSecureDelete
253897
- && pConfig->iVersion==FTS5_CURRENT_VERSION
253898
- ){
253899
- rc = sqlite3Fts5StorageConfigValue(
253900
- pTab->pStorage, "version", 0, FTS5_CURRENT_VERSION_SECUREDELETE
253901
- );
253902
- if( rc==SQLITE_OK ){
253903
- pConfig->iVersion = FTS5_CURRENT_VERSION_SECUREDELETE;
253904254444
}
253905254445
}
253906254446
253907254447
update_out:
253908254448
pTab->p.pConfig->pzErrmsg = 0;
@@ -253951,10 +254491,11 @@
253951254491
static int fts5RollbackMethod(sqlite3_vtab *pVtab){
253952254492
int rc;
253953254493
Fts5FullTable *pTab = (Fts5FullTable*)pVtab;
253954254494
fts5CheckTransactionState(pTab, FTS5_ROLLBACK, 0);
253955254495
rc = sqlite3Fts5StorageRollback(pTab->pStorage);
254496
+ pTab->p.pConfig->pgsz = 0;
253956254497
return rc;
253957254498
}
253958254499
253959254500
static int fts5CsrPoslist(Fts5Cursor*, int, const u8**, int*);
253960254501
@@ -255419,11 +255960,11 @@
255419255960
int nArg, /* Number of args */
255420255961
sqlite3_value **apUnused /* Function arguments */
255421255962
){
255422255963
assert( nArg==0 );
255423255964
UNUSED_PARAM2(nArg, apUnused);
255424
- sqlite3_result_text(pCtx, "fts5: 2024-12-09 20:46:36 e2bae4143afd07de1ae55a6d2606a3b541a5b94568aa41f6a96e5d1245471653", -1, SQLITE_TRANSIENT);
255965
+ sqlite3_result_text(pCtx, "fts5: 2025-02-18 01:16:26 57caa3136d1bfca06e4f2285734a4977b8d3fa1f75bf87453b975867e9de38fc", -1, SQLITE_TRANSIENT);
255425255966
}
255426255967
255427255968
/*
255428255969
** Implementation of fts5_locale(LOCALE, TEXT) function.
255429255970
**
@@ -255899,10 +256440,15 @@
255899256440
rc = sqlite3_prepare_v3(pC->db, zSql, -1, f, &p->aStmt[eStmt], 0);
255900256441
p->pConfig->bLock--;
255901256442
sqlite3_free(zSql);
255902256443
if( rc!=SQLITE_OK && pzErrMsg ){
255903256444
*pzErrMsg = sqlite3_mprintf("%s", sqlite3_errmsg(pC->db));
256445
+ }
256446
+ if( rc==SQLITE_ERROR && eStmt>FTS5_STMT_LOOKUP2 && eStmt<FTS5_STMT_SCAN ){
256447
+ /* One of the internal tables - not the %_content table - is missing.
256448
+ ** This counts as a corrupted table. */
256449
+ rc = SQLITE_CORRUPT;
255904256450
}
255905256451
}
255906256452
}
255907256453
255908256454
*ppStmt = p->aStmt[eStmt];
@@ -260019,16 +260565,16 @@
260019260565
260020260566
if( argc!=5 && bDb==0 ){
260021260567
*pzErr = sqlite3_mprintf("wrong number of vtable arguments");
260022260568
rc = SQLITE_ERROR;
260023260569
}else{
260024
- int nByte; /* Bytes of space to allocate */
260570
+ i64 nByte; /* Bytes of space to allocate */
260025260571
const char *zDb = bDb ? argv[3] : argv[1];
260026260572
const char *zTab = bDb ? argv[4] : argv[3];
260027260573
const char *zType = bDb ? argv[5] : argv[4];
260028
- int nDb = (int)strlen(zDb)+1;
260029
- int nTab = (int)strlen(zTab)+1;
260574
+ i64 nDb = strlen(zDb)+1;
260575
+ i64 nTab = strlen(zTab)+1;
260030260576
int eType = 0;
260031260577
260032260578
rc = fts5VocabTableType(zType, pzErr, &eType);
260033260579
if( rc==SQLITE_OK ){
260034260580
assert( eType>=0 && eType<ArraySize(azSchema) );
260035260581
--- extsrc/sqlite3.c
+++ extsrc/sqlite3.c
@@ -1,8 +1,8 @@
1 /******************************************************************************
2 ** This file is an amalgamation of many separate C source files from SQLite
3 ** version 3.48.0. By combining all the individual C code files into this
4 ** single large file, the entire code can be compiled as a single translation
5 ** unit. This allows many compilers to do optimizations that would not be
6 ** possible if the files were compiled separately. Performance improvements
7 ** of 5% or more are commonly seen when SQLite is compiled as a single
8 ** translation unit.
@@ -16,11 +16,11 @@
16 ** if you want a wrapper to interface SQLite with your choice of programming
17 ** language. The code for the "sqlite3" command-line shell is also in a
18 ** separate file. This file contains only code for the core SQLite library.
19 **
20 ** The content in this amalgamation comes from Fossil check-in
21 ** e2bae4143afd07de1ae55a6d2606a3b541a5 with changes in files:
22 **
23 **
24 */
25 #ifndef SQLITE_AMALGAMATION
26 #define SQLITE_CORE 1
@@ -463,13 +463,13 @@
463 **
464 ** See also: [sqlite3_libversion()],
465 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
466 ** [sqlite_version()] and [sqlite_source_id()].
467 */
468 #define SQLITE_VERSION "3.48.0"
469 #define SQLITE_VERSION_NUMBER 3048000
470 #define SQLITE_SOURCE_ID "2024-12-09 20:46:36 e2bae4143afd07de1ae55a6d2606a3b541a5b94568aa41f6a96e5d1245471653"
471
472 /*
473 ** CAPI3REF: Run-Time Library Version Numbers
474 ** KEYWORDS: sqlite3_version sqlite3_sourceid
475 **
@@ -2306,17 +2306,20 @@
2306 ** [sqlite3_config()] with the SQLITE_CONFIG_GETMUTEX configuration option will
2307 ** return [SQLITE_ERROR].</dd>
2308 **
2309 ** [[SQLITE_CONFIG_LOOKASIDE]] <dt>SQLITE_CONFIG_LOOKASIDE</dt>
2310 ** <dd> ^(The SQLITE_CONFIG_LOOKASIDE option takes two arguments that determine
2311 ** the default size of lookaside memory on each [database connection].
2312 ** The first argument is the
2313 ** size of each lookaside buffer slot and the second is the number of
2314 ** slots allocated to each database connection.)^ ^(SQLITE_CONFIG_LOOKASIDE
2315 ** sets the <i>default</i> lookaside size. The [SQLITE_DBCONFIG_LOOKASIDE]
2316 ** option to [sqlite3_db_config()] can be used to change the lookaside
2317 ** configuration on individual connections.)^ </dd>
 
 
 
2318 **
2319 ** [[SQLITE_CONFIG_PCACHE2]] <dt>SQLITE_CONFIG_PCACHE2</dt>
2320 ** <dd> ^(The SQLITE_CONFIG_PCACHE2 option takes a single argument which is
2321 ** a pointer to an [sqlite3_pcache_methods2] object. This object specifies
2322 ** the interface to a custom page cache implementation.)^
@@ -2528,11 +2531,19 @@
2528
2529 /*
2530 ** CAPI3REF: Database Connection Configuration Options
2531 **
2532 ** These constants are the available integer configuration options that
2533 ** can be passed as the second argument to the [sqlite3_db_config()] interface.
 
 
 
 
 
 
 
 
2534 **
2535 ** New configuration options may be added in future releases of SQLite.
2536 ** Existing configuration options might be discontinued. Applications
2537 ** should check the return code from [sqlite3_db_config()] to make sure that
2538 ** the call worked. ^The [sqlite3_db_config()] interface will return a
@@ -2540,35 +2551,61 @@
2540 ** is invoked.
2541 **
2542 ** <dl>
2543 ** [[SQLITE_DBCONFIG_LOOKASIDE]]
2544 ** <dt>SQLITE_DBCONFIG_LOOKASIDE</dt>
2545 ** <dd> ^This option takes three additional arguments that determine the
2546 ** [lookaside memory allocator] configuration for the [database connection].
2547 ** ^The first argument (the third parameter to [sqlite3_db_config()] is a
 
 
 
 
 
 
 
2548 ** pointer to a memory buffer to use for lookaside memory.
2549 ** ^The first argument after the SQLITE_DBCONFIG_LOOKASIDE verb
2550 ** may be NULL in which case SQLite will allocate the
2551 ** lookaside buffer itself using [sqlite3_malloc()]. ^The second argument is the
2552 ** size of each lookaside buffer slot. ^The third argument is the number of
2553 ** slots. The size of the buffer in the first argument must be greater than
2554 ** or equal to the product of the second and third arguments. The buffer
2555 ** must be aligned to an 8-byte boundary. ^If the second argument to
2556 ** SQLITE_DBCONFIG_LOOKASIDE is not a multiple of 8, it is internally
2557 ** rounded down to the next smaller multiple of 8. ^(The lookaside memory
 
 
 
 
 
 
 
 
 
2558 ** configuration for a database connection can only be changed when that
2559 ** connection is not currently using lookaside memory, or in other words
2560 ** when the "current value" returned by
2561 ** [sqlite3_db_status](D,[SQLITE_DBSTATUS_LOOKASIDE_USED],...) is zero.
2562 ** Any attempt to change the lookaside memory configuration when lookaside
2563 ** memory is in use leaves the configuration unchanged and returns
2564 ** [SQLITE_BUSY].)^</dd>
 
 
 
 
 
 
 
 
 
 
2565 **
2566 ** [[SQLITE_DBCONFIG_ENABLE_FKEY]]
2567 ** <dt>SQLITE_DBCONFIG_ENABLE_FKEY</dt>
2568 ** <dd> ^This option is used to enable or disable the enforcement of
2569 ** [foreign key constraints]. There should be two additional arguments.
 
2570 ** The first argument is an integer which is 0 to disable FK enforcement,
2571 ** positive to enable FK enforcement or negative to leave FK enforcement
2572 ** unchanged. The second parameter is a pointer to an integer into which
2573 ** is written 0 or 1 to indicate whether FK enforcement is off or on
2574 ** following this call. The second parameter may be a NULL pointer, in
@@ -2586,17 +2623,17 @@
2586 ** which case the trigger setting is not reported back.
2587 **
2588 ** <p>Originally this option disabled all triggers. ^(However, since
2589 ** SQLite version 3.35.0, TEMP triggers are still allowed even if
2590 ** this option is off. So, in other words, this option now only disables
2591 ** triggers in the main database schema or in the schemas of ATTACH-ed
2592 ** databases.)^ </dd>
2593 **
2594 ** [[SQLITE_DBCONFIG_ENABLE_VIEW]]
2595 ** <dt>SQLITE_DBCONFIG_ENABLE_VIEW</dt>
2596 ** <dd> ^This option is used to enable or disable [CREATE VIEW | views].
2597 ** There should be two additional arguments.
2598 ** The first argument is an integer which is 0 to disable views,
2599 ** positive to enable views or negative to leave the setting unchanged.
2600 ** The second parameter is a pointer to an integer into which
2601 ** is written 0 or 1 to indicate whether views are disabled or enabled
2602 ** following this call. The second parameter may be a NULL pointer, in
@@ -2611,11 +2648,11 @@
2611 ** [[SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER]]
2612 ** <dt>SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER</dt>
2613 ** <dd> ^This option is used to enable or disable the
2614 ** [fts3_tokenizer()] function which is part of the
2615 ** [FTS3] full-text search engine extension.
2616 ** There should be two additional arguments.
2617 ** The first argument is an integer which is 0 to disable fts3_tokenizer() or
2618 ** positive to enable fts3_tokenizer() or negative to leave the setting
2619 ** unchanged.
2620 ** The second parameter is a pointer to an integer into which
2621 ** is written 0 or 1 to indicate whether fts3_tokenizer is disabled or enabled
@@ -2626,11 +2663,11 @@
2626 ** <dt>SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION</dt>
2627 ** <dd> ^This option is used to enable or disable the [sqlite3_load_extension()]
2628 ** interface independently of the [load_extension()] SQL function.
2629 ** The [sqlite3_enable_load_extension()] API enables or disables both the
2630 ** C-API [sqlite3_load_extension()] and the SQL function [load_extension()].
2631 ** There should be two additional arguments.
2632 ** When the first argument to this interface is 1, then only the C-API is
2633 ** enabled and the SQL function remains disabled. If the first argument to
2634 ** this interface is 0, then both the C-API and the SQL function are disabled.
2635 ** If the first argument is -1, then no changes are made to state of either the
2636 ** C-API or the SQL function.
@@ -2640,27 +2677,34 @@
2640 ** be a NULL pointer, in which case the new setting is not reported back.
2641 ** </dd>
2642 **
2643 ** [[SQLITE_DBCONFIG_MAINDBNAME]] <dt>SQLITE_DBCONFIG_MAINDBNAME</dt>
2644 ** <dd> ^This option is used to change the name of the "main" database
2645 ** schema. ^The sole argument is a pointer to a constant UTF8 string
2646 ** which will become the new schema name in place of "main". ^SQLite
2647 ** does not make a copy of the new main schema name string, so the application
2648 ** must ensure that the argument passed into this DBCONFIG option is unchanged
2649 ** until after the database connection closes.
 
 
 
 
2650 ** </dd>
2651 **
2652 ** [[SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE]]
2653 ** <dt>SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE</dt>
2654 ** <dd> Usually, when a database in wal mode is closed or detached from a
2655 ** database handle, SQLite checks if this will mean that there are now no
2656 ** connections at all to the database. If so, it performs a checkpoint
2657 ** operation before closing the connection. This option may be used to
2658 ** override this behavior. The first parameter passed to this operation
2659 ** is an integer - positive to disable checkpoints-on-close, or zero (the
2660 ** default) to enable them, and negative to leave the setting unchanged.
2661 ** The second parameter is a pointer to an integer
 
 
 
2662 ** into which is written 0 or 1 to indicate whether checkpoints-on-close
2663 ** have been disabled - 0 if they are not disabled, 1 if they are.
2664 ** </dd>
2665 **
2666 ** [[SQLITE_DBCONFIG_ENABLE_QPSG]] <dt>SQLITE_DBCONFIG_ENABLE_QPSG</dt>
@@ -2817,11 +2861,11 @@
2817 ** SQLITE_ENABLE_STMT_SCANSTATUS builds. In this case, it sets or clears
2818 ** a flag that enables collection of the sqlite3_stmt_scanstatus_v2()
2819 ** statistics. For statistics to be collected, the flag must be set on
2820 ** the database handle both when the SQL statement is prepared and when it
2821 ** is stepped. The flag is set (collection of statistics is enabled)
2822 ** by default. This option takes two arguments: an integer and a pointer to
2823 ** an integer.. The first argument is 1, 0, or -1 to enable, disable, or
2824 ** leave unchanged the statement scanstatus option. If the second argument
2825 ** is not NULL, then the value of the statement scanstatus setting after
2826 ** processing the first argument is written into the integer that the second
2827 ** argument points to.
@@ -2831,20 +2875,89 @@
2831 ** <dt>SQLITE_DBCONFIG_REVERSE_SCANORDER</dt>
2832 ** <dd>The SQLITE_DBCONFIG_REVERSE_SCANORDER option changes the default order
2833 ** in which tables and indexes are scanned so that the scans start at the end
2834 ** and work toward the beginning rather than starting at the beginning and
2835 ** working toward the end. Setting SQLITE_DBCONFIG_REVERSE_SCANORDER is the
2836 ** same as setting [PRAGMA reverse_unordered_selects]. This option takes
2837 ** two arguments which are an integer and a pointer to an integer. The first
2838 ** argument is 1, 0, or -1 to enable, disable, or leave unchanged the
2839 ** reverse scan order flag, respectively. If the second argument is not NULL,
2840 ** then 0 or 1 is written into the integer that the second argument points to
2841 ** depending on if the reverse scan order flag is set after processing the
2842 ** first argument.
2843 ** </dd>
2844 **
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2845 ** </dl>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2846 */
2847 #define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */
2848 #define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */
2849 #define SQLITE_DBCONFIG_ENABLE_FKEY 1002 /* int int* */
2850 #define SQLITE_DBCONFIG_ENABLE_TRIGGER 1003 /* int int* */
@@ -2862,11 +2975,14 @@
2862 #define SQLITE_DBCONFIG_ENABLE_VIEW 1015 /* int int* */
2863 #define SQLITE_DBCONFIG_LEGACY_FILE_FORMAT 1016 /* int int* */
2864 #define SQLITE_DBCONFIG_TRUSTED_SCHEMA 1017 /* int int* */
2865 #define SQLITE_DBCONFIG_STMT_SCANSTATUS 1018 /* int int* */
2866 #define SQLITE_DBCONFIG_REVERSE_SCANORDER 1019 /* int int* */
2867 #define SQLITE_DBCONFIG_MAX 1019 /* Largest DBCONFIG */
 
 
 
2868
2869 /*
2870 ** CAPI3REF: Enable Or Disable Extended Result Codes
2871 ** METHOD: sqlite3
2872 **
@@ -11065,12 +11181,13 @@
11065 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_recover(sqlite3 *db, const char *zDb);
11066
11067 /*
11068 ** CAPI3REF: Serialize a database
11069 **
11070 ** The sqlite3_serialize(D,S,P,F) interface returns a pointer to memory
11071 ** that is a serialization of the S database on [database connection] D.
 
11072 ** If P is not a NULL pointer, then the size of the database in bytes
11073 ** is written into *P.
11074 **
11075 ** For an ordinary on-disk database file, the serialization is just a
11076 ** copy of the disk file. For an in-memory database or a "TEMP" database,
@@ -12232,23 +12349,10 @@
12232 int nB, /* Number of bytes in buffer pB */
12233 void *pB, /* Pointer to buffer containing changeset B */
12234 int *pnOut, /* OUT: Number of bytes in output changeset */
12235 void **ppOut /* OUT: Buffer containing output changeset */
12236 );
12237
12238
12239 /*
12240 ** CAPI3REF: Upgrade the Schema of a Changeset/Patchset
12241 */
12242 SQLITE_API int sqlite3changeset_upgrade(
12243 sqlite3 *db,
12244 const char *zDb,
12245 int nIn, const void *pIn, /* Input changeset */
12246 int *pnOut, void **ppOut /* OUT: Inverse of input */
12247 );
12248
12249
12250
12251 /*
12252 ** CAPI3REF: Changegroup Handle
12253 **
12254 ** A changegroup is an object used to combine two or more
@@ -14046,13 +14150,17 @@
14046 # define SQLITE_MAX_VDBE_OP 250000000
14047 #endif
14048
14049 /*
14050 ** The maximum number of arguments to an SQL function.
 
 
 
 
14051 */
14052 #ifndef SQLITE_MAX_FUNCTION_ARG
14053 # define SQLITE_MAX_FUNCTION_ARG 127
14054 #endif
14055
14056 /*
14057 ** The suggested maximum number of in-memory pages to use for
14058 ** the main database table and for temporary tables.
@@ -14648,10 +14756,11 @@
14648 */
14649 struct HashElem {
14650 HashElem *next, *prev; /* Next and previous elements in the table */
14651 void *data; /* Data associated with this element */
14652 const char *pKey; /* Key associated with this element */
 
14653 };
14654
14655 /*
14656 ** Access routines. To delete, insert a NULL pointer.
14657 */
@@ -14871,11 +14980,12 @@
14871 #define TK_ASTERISK 180
14872 #define TK_SPAN 181
14873 #define TK_ERROR 182
14874 #define TK_QNUMBER 183
14875 #define TK_SPACE 184
14876 #define TK_ILLEGAL 185
 
14877
14878 /************** End of parse.h ***********************************************/
14879 /************** Continuing where we left off in sqliteInt.h ******************/
14880 #include <stdio.h>
14881 #include <stdlib.h>
@@ -15085,10 +15195,15 @@
15085 typedef UINT16_TYPE u16; /* 2-byte unsigned integer */
15086 typedef INT16_TYPE i16; /* 2-byte signed integer */
15087 typedef UINT8_TYPE u8; /* 1-byte unsigned integer */
15088 typedef INT8_TYPE i8; /* 1-byte signed integer */
15089
 
 
 
 
 
15090 /*
15091 ** SQLITE_MAX_U32 is a u64 constant that is the maximum u64 value
15092 ** that can be stored in a u32 without loss of data. The value
15093 ** is 0x00000000ffffffff. But because of quirks of some compilers, we
15094 ** have to specify the value in the less intuitive manner shown:
@@ -15123,10 +15238,12 @@
15123 ** Examples:
15124 **
15125 ** 0.5 -> -10 0.1 -> -33 0.0625 -> -40
15126 */
15127 typedef INT16_TYPE LogEst;
 
 
15128
15129 /*
15130 ** Set the SQLITE_PTRSIZE macro to the number of bytes in a pointer
15131 */
15132 #ifndef SQLITE_PTRSIZE
@@ -15251,10 +15368,18 @@
15251 */
15252 #define LARGEST_INT64 (0xffffffff|(((i64)0x7fffffff)<<32))
15253 #define LARGEST_UINT64 (0xffffffff|(((u64)0xffffffff)<<32))
15254 #define SMALLEST_INT64 (((i64)-1) - LARGEST_INT64)
15255
 
 
 
 
 
 
 
 
15256 /*
15257 ** Round up a number to the next larger multiple of 8. This is used
15258 ** to force 8-byte alignment on 64-bit architectures.
15259 **
15260 ** ROUND8() always does the rounding, for any argument.
@@ -15393,11 +15518,11 @@
15393 ** 0x-------F High-level debug messages
15394 ** 0x----FFF- More detail
15395 ** 0xFFFF---- Low-level debug messages
15396 **
15397 ** 0x00000001 Code generation
15398 ** 0x00000002 Solver
15399 ** 0x00000004 Solver costs
15400 ** 0x00000008 WhereLoop inserts
15401 **
15402 ** 0x00000010 Display sqlite3_index_info xBestIndex calls
15403 ** 0x00000020 Range an equality scan metrics
@@ -15412,10 +15537,12 @@
15412 ** 0x00004000 Show all WHERE terms at key points
15413 ** 0x00008000 Show the full SELECT statement at key places
15414 **
15415 ** 0x00010000 Show more detail when printing WHERE terms
15416 ** 0x00020000 Show WHERE terms returned from whereScanNext()
 
 
15417 */
15418
15419
15420 /*
15421 ** An instance of the following structure is used to store the busy-handler
@@ -16049,10 +16176,26 @@
16049 #define PAGER_JOURNALMODE_PERSIST 1 /* Commit by zeroing journal header */
16050 #define PAGER_JOURNALMODE_OFF 2 /* Journal omitted. */
16051 #define PAGER_JOURNALMODE_TRUNCATE 3 /* Commit by truncating journal */
16052 #define PAGER_JOURNALMODE_MEMORY 4 /* In-memory journal file */
16053 #define PAGER_JOURNALMODE_WAL 5 /* Use write-ahead logging */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16054
16055 /*
16056 ** Flags that make up the mask passed to sqlite3PagerGet().
16057 */
16058 #define PAGER_GET_NOCONTENT 0x01 /* Do not load data from disk */
@@ -16688,10 +16831,11 @@
16688 ** A signature for a reusable subroutine that materializes the RHS of
16689 ** an IN operator.
16690 */
16691 struct SubrtnSig {
16692 int selId; /* SELECT-id for the SELECT statement on the RHS */
 
16693 char *zAff; /* Affinity of the overall IN expression */
16694 int iTable; /* Ephemeral table generated by the subroutine */
16695 int iAddr; /* Subroutine entry address */
16696 int regReturn; /* Register used to hold return address */
16697 };
@@ -18018,10 +18162,13 @@
18018 /* DELETE, or UPDATE and return */
18019 /* the count using a callback. */
18020 #define SQLITE_CorruptRdOnly HI(0x00002) /* Prohibit writes due to error */
18021 #define SQLITE_ReadUncommit HI(0x00004) /* READ UNCOMMITTED in shared-cache */
18022 #define SQLITE_FkNoAction HI(0x00008) /* Treat all FK as NO ACTION */
 
 
 
18023
18024 /* Flags used only if debugging */
18025 #ifdef SQLITE_DEBUG
18026 #define SQLITE_SqlTrace HI(0x0100000) /* Debug print SQL as it executes */
18027 #define SQLITE_VdbeListing HI(0x0200000) /* Debug listings of VDBE progs */
@@ -18077,10 +18224,11 @@
18077 #define SQLITE_IndexedExpr 0x01000000 /* Pull exprs from index when able */
18078 #define SQLITE_Coroutines 0x02000000 /* Co-routines for subqueries */
18079 #define SQLITE_NullUnusedCols 0x04000000 /* NULL unused columns in subqueries */
18080 #define SQLITE_OnePass 0x08000000 /* Single-pass DELETE and UPDATE */
18081 #define SQLITE_OrderBySubq 0x10000000 /* ORDER BY in subquery helps outer */
 
18082 #define SQLITE_AllOpts 0xffffffff /* All optimizations */
18083
18084 /*
18085 ** Macros for testing whether or not optimizations are enabled or disabled.
18086 */
@@ -18113,11 +18261,11 @@
18113 **
18114 ** The u.pHash field is used by the global built-ins. The u.pDestructor
18115 ** field is used by per-connection app-def functions.
18116 */
18117 struct FuncDef {
18118 i8 nArg; /* Number of arguments. -1 means unlimited */
18119 u32 funcFlags; /* Some combination of SQLITE_FUNC_* */
18120 void *pUserData; /* User data parameter */
18121 FuncDef *pNext; /* Next function with same name */
18122 void (*xSFunc)(sqlite3_context*,int,sqlite3_value**); /* func or agg-step */
18123 void (*xFinalize)(sqlite3_context*); /* Agg finalizer */
@@ -18606,10 +18754,11 @@
18606 VTable *p; /* List of VTable objects. */
18607 } vtab;
18608 } u;
18609 Trigger *pTrigger; /* List of triggers on this object */
18610 Schema *pSchema; /* Schema that contains this table */
 
18611 };
18612
18613 /*
18614 ** Allowed values for Table.tabFlags.
18615 **
@@ -19406,17 +19555,12 @@
19406 **
19407 ** If "a" is the k-th column of table "t", then IdList.a[0].idx==k.
19408 */
19409 struct IdList {
19410 int nId; /* Number of identifiers on the list */
19411 u8 eU4; /* Which element of a.u4 is valid */
19412 struct IdList_item {
19413 char *zName; /* Name of the identifier */
19414 union {
19415 int idx; /* Index in some Table.aCol[] of a column named zName */
19416 Expr *pExpr; /* Expr to implement a USING variable -- NOT USED */
19417 } u4;
19418 } a[1];
19419 };
19420
19421 /*
19422 ** Allowed values for IdList.eType, which determines which value of the a.u4
@@ -20008,29 +20152,36 @@
20008 struct Parse {
20009 sqlite3 *db; /* The main database structure */
20010 char *zErrMsg; /* An error message */
20011 Vdbe *pVdbe; /* An engine for executing database bytecode */
20012 int rc; /* Return code from execution */
20013 u8 colNamesSet; /* TRUE after OP_ColumnName has been issued to pVdbe */
20014 u8 checkSchema; /* Causes schema cookie check after an error */
20015 u8 nested; /* Number of nested calls to the parser/code generator */
20016 u8 nTempReg; /* Number of temporary registers in aTempReg[] */
20017 u8 isMultiWrite; /* True if statement may modify/insert multiple rows */
20018 u8 mayAbort; /* True if statement may throw an ABORT exception */
20019 u8 hasCompound; /* Need to invoke convertCompoundSelectToSubquery() */
20020 u8 okConstFactor; /* OK to factor out constants */
20021 u8 disableLookaside; /* Number of times lookaside has been disabled */
20022 u8 prepFlags; /* SQLITE_PREPARE_* flags */
20023 u8 withinRJSubrtn; /* Nesting level for RIGHT JOIN body subroutines */
20024 u8 bHasWith; /* True if statement contains WITH */
20025 u8 mSubrtnSig; /* mini Bloom filter on available SubrtnSig.selId */
 
 
 
 
20026 #if defined(SQLITE_DEBUG) || defined(SQLITE_COVERAGE_TEST)
20027 u8 earlyCleanup; /* OOM inside sqlite3ParserAddCleanup() */
20028 #endif
20029 #ifdef SQLITE_DEBUG
20030 u8 ifNotExists; /* Might be true if IF NOT EXISTS. Assert()s only */
 
 
20031 #endif
 
 
 
 
20032 int nRangeReg; /* Size of the temporary register block */
20033 int iRangeReg; /* First register in temporary register block */
20034 int nErr; /* Number of errors seen */
20035 int nTab; /* Number of previously allocated VDBE cursors */
20036 int nMem; /* Number of memory cells used so far */
@@ -20041,16 +20192,13 @@
20041 int nLabelAlloc; /* Number of slots in aLabel */
20042 int *aLabel; /* Space to hold the labels */
20043 ExprList *pConstExpr;/* Constant expressions */
20044 IndexedExpr *pIdxEpr;/* List of expressions used by active indexes */
20045 IndexedExpr *pIdxPartExpr; /* Exprs constrained by index WHERE clauses */
20046 Token constraintName;/* Name of the constraint currently being parsed */
20047 yDbMask writeMask; /* Start a write transaction on these databases */
20048 yDbMask cookieMask; /* Bitmask of schema verified databases */
20049 int regRowid; /* Register holding rowid of CREATE TABLE entry */
20050 int regRoot; /* Register holding root page number for new objects */
20051 int nMaxArg; /* Max args passed to user function by sub-program */
20052 int nSelect; /* Number of SELECT stmts. Counter for Select.selId */
20053 #ifndef SQLITE_OMIT_PROGRESS_CALLBACK
20054 u32 nProgressSteps; /* xProgress steps taken during sqlite3_prepare() */
20055 #endif
20056 #ifndef SQLITE_OMIT_SHARED_CACHE
@@ -20060,21 +20208,10 @@
20060 AutoincInfo *pAinc; /* Information about AUTOINCREMENT counters */
20061 Parse *pToplevel; /* Parse structure for main program (or NULL) */
20062 Table *pTriggerTab; /* Table triggers are being coded for */
20063 TriggerPrg *pTriggerPrg; /* Linked list of coded triggers */
20064 ParseCleanup *pCleanup; /* List of cleanup operations to run after parse */
20065 union {
20066 int addrCrTab; /* Address of OP_CreateBtree on CREATE TABLE */
20067 Returning *pReturning; /* The RETURNING clause */
20068 } u1;
20069 u32 oldmask; /* Mask of old.* columns referenced */
20070 u32 newmask; /* Mask of new.* columns referenced */
20071 LogEst nQueryLoop; /* Est number of iterations of a query (10*log2(N)) */
20072 u8 eTriggerOp; /* TK_UPDATE, TK_INSERT or TK_DELETE */
20073 u8 bReturning; /* Coding a RETURNING trigger */
20074 u8 eOrconf; /* Default ON CONFLICT policy for trigger steps */
20075 u8 disableTriggers; /* True to disable triggers */
20076
20077 /**************************************************************************
20078 ** Fields above must be initialized to zero. The fields that follow,
20079 ** down to the beginning of the recursive section, do not need to be
20080 ** initialized as they will be set before being used. The boundary is
@@ -20082,10 +20219,23 @@
20082 **************************************************************************/
20083
20084 int aTempReg[8]; /* Holding area for temporary registers */
20085 Parse *pOuterParse; /* Outer Parse object when nested */
20086 Token sNameToken; /* Token with unqualified schema object name */
 
 
 
 
 
 
 
 
 
 
 
 
 
20087
20088 /************************************************************************
20089 ** Above is constant between recursions. Below is reset before and after
20090 ** each recursion. The boundary between these two regions is determined
20091 ** using offsetof(Parse,sLastToken) so the sLastToken field must be the
@@ -20099,13 +20249,11 @@
20099 u8 eParseMode; /* PARSE_MODE_XXX constant */
20100 #ifndef SQLITE_OMIT_VIRTUALTABLE
20101 int nVtabLock; /* Number of virtual tables to lock */
20102 #endif
20103 int nHeight; /* Expression tree height of current sub-select */
20104 #ifndef SQLITE_OMIT_EXPLAIN
20105 int addrExplain; /* Address of current OP_Explain opcode */
20106 #endif
20107 VList *pVList; /* Mapping between variable names and numbers */
20108 Vdbe *pReprepare; /* VM being reprepared (sqlite3Reprepare()) */
20109 const char *zTail; /* All SQL text past the last semicolon parsed */
20110 Table *pNewTable; /* A table being constructed by CREATE TABLE */
20111 Index *pNewIndex; /* An index being constructed by CREATE INDEX.
@@ -23559,10 +23707,11 @@
23559 char *zMalloc; /* Space to hold MEM_Str or MEM_Blob if szMalloc>0 */
23560 void (*xDel)(void*);/* Destructor for Mem.z - only valid if MEM_Dyn */
23561 #ifdef SQLITE_DEBUG
23562 Mem *pScopyFrom; /* This Mem is a shallow copy of pScopyFrom */
23563 u16 mScopyFlags; /* flags value immediately after the shallow copy */
 
23564 #endif
23565 };
23566
23567 /*
23568 ** Size of struct Mem not including the Mem.zMalloc member or anything that
@@ -23708,18 +23857,14 @@
23708 Vdbe *pVdbe; /* The VM that owns this context */
23709 int iOp; /* Instruction number of OP_Function */
23710 int isError; /* Error code returned by the function. */
23711 u8 enc; /* Encoding to use for results */
23712 u8 skipFlag; /* Skip accumulator loading if true */
23713 u8 argc; /* Number of arguments */
23714 sqlite3_value *argv[1]; /* Argument set */
23715 };
23716
23717 /* A bitfield type for use inside of structures. Always follow with :N where
23718 ** N is the number of bits.
23719 */
23720 typedef unsigned bft; /* Bit Field Type */
23721
23722 /* The ScanStatus object holds a single value for the
23723 ** sqlite3_stmt_scanstatus() interface.
23724 **
23725 ** aAddrRange[]:
@@ -23776,11 +23921,11 @@
23776 i64 iCurrentTime; /* Value of julianday('now') for this statement */
23777 i64 nFkConstraint; /* Number of imm. FK constraints this VM */
23778 i64 nStmtDefCons; /* Number of def. constraints when stmt started */
23779 i64 nStmtDefImmCons; /* Number of def. imm constraints when stmt started */
23780 Mem *aMem; /* The memory locations */
23781 Mem **apArg; /* Arguments to currently executing user function */
23782 VdbeCursor **apCsr; /* One element of this array for each open cursor */
23783 Mem *aVar; /* Values for the OP_Variable opcode. */
23784
23785 /* When allocating a new Vdbe object, all of the fields below should be
23786 ** initialized to zero or NULL */
@@ -23796,10 +23941,11 @@
23796 i64 startTime; /* Time when query started - used for profiling */
23797 #endif
23798 #ifdef SQLITE_DEBUG
23799 int rcApp; /* errcode set by sqlite3_result_error_code() */
23800 u32 nWrite; /* Number of write operations that have occurred */
 
23801 #endif
23802 u16 nResColumn; /* Number of columns in one row of the result set */
23803 u16 nResAlloc; /* Column slots allocated to aColName[] */
23804 u8 errorAction; /* Recovery action to do in case of an error */
23805 u8 minWriteFileFormat; /* Minimum file format for writable database files */
@@ -24657,10 +24803,13 @@
24657 ms = ms*10.0 + *zDate - '0';
24658 rScale *= 10.0;
24659 zDate++;
24660 }
24661 ms /= rScale;
 
 
 
24662 }
24663 }else{
24664 s = 0;
24665 }
24666 p->validJD = 0;
@@ -25864,11 +26013,11 @@
25864 sqlite3_str_appendf(&sRes, cf=='d' ? "%02d" : "%2d", x.D);
25865 break;
25866 }
25867 case 'f': { /* Fractional seconds. (Non-standard) */
25868 double s = x.s;
25869 if( s>59.999 ) s = 59.999;
25870 sqlite3_str_appendf(&sRes, "%06.3f", s);
25871 break;
25872 }
25873 case 'F': {
25874 sqlite3_str_appendf(&sRes, "%04d-%02d-%02d", x.Y, x.M, x.D);
@@ -32424,11 +32573,11 @@
32424 ** pointer if any kind of error was encountered.
32425 */
32426 static SQLITE_NOINLINE char *strAccumFinishRealloc(StrAccum *p){
32427 char *zText;
32428 assert( p->mxAlloc>0 && !isMalloced(p) );
32429 zText = sqlite3DbMallocRaw(p->db, p->nChar+1 );
32430 if( zText ){
32431 memcpy(zText, p->zText, p->nChar+1);
32432 p->printfFlags |= SQLITE_PRINTF_MALLOCED;
32433 }else{
32434 sqlite3StrAccumSetError(p, SQLITE_NOMEM);
@@ -33032,11 +33181,14 @@
33032 }
33033 if( pItem->fg.fromDDL ){
33034 sqlite3_str_appendf(&x, " DDL");
33035 }
33036 if( pItem->fg.isCte ){
33037 sqlite3_str_appendf(&x, " CteUse=0x%p", pItem->u2.pCteUse);
 
 
 
33038 }
33039 if( pItem->fg.isOn || (pItem->fg.isUsing==0 && pItem->u3.pOn!=0) ){
33040 sqlite3_str_appendf(&x, " isOn");
33041 }
33042 if( pItem->fg.isTabFunc ) sqlite3_str_appendf(&x, " isTabFunc");
@@ -33063,13 +33215,10 @@
33063 if( pItem->pSTab ){
33064 Table *pTab = pItem->pSTab;
33065 sqlite3TreeViewColumnList(pView, pTab->aCol, pTab->nCol, 1);
33066 }
33067 assert( (int)pItem->fg.isNestedFrom == IsNestedFrom(pItem) );
33068 sqlite3TreeViewPush(&pView, 0);
33069 sqlite3TreeViewLine(pView, "SUBQUERY");
33070 sqlite3TreeViewPop(&pView);
33071 sqlite3TreeViewSelect(pView, pItem->u4.pSubq->pSelect, 0);
33072 }
33073 if( pItem->fg.isTabFunc ){
33074 sqlite3TreeViewExprList(pView, pItem->u1.pFuncArg, 0, "func-args:");
33075 }
@@ -33795,25 +33944,11 @@
33795 char *zName = pList->a[i].zName;
33796 int moreToFollow = i<pList->nId - 1;
33797 if( zName==0 ) zName = "(null)";
33798 sqlite3TreeViewPush(&pView, moreToFollow);
33799 sqlite3TreeViewLine(pView, 0);
33800 if( pList->eU4==EU4_NONE ){
33801 fprintf(stdout, "%s\n", zName);
33802 }else if( pList->eU4==EU4_IDX ){
33803 fprintf(stdout, "%s (%d)\n", zName, pList->a[i].u4.idx);
33804 }else{
33805 assert( pList->eU4==EU4_EXPR );
33806 if( pList->a[i].u4.pExpr==0 ){
33807 fprintf(stdout, "%s (pExpr=NULL)\n", zName);
33808 }else{
33809 fprintf(stdout, "%s\n", zName);
33810 sqlite3TreeViewPush(&pView, i<pList->nId-1);
33811 sqlite3TreeViewExpr(pView, pList->a[i].u4.pExpr, 0);
33812 sqlite3TreeViewPop(&pView);
33813 }
33814 }
33815 sqlite3TreeViewPop(&pView);
33816 }
33817 }
33818 }
33819 SQLITE_PRIVATE void sqlite3TreeViewIdList(
@@ -36290,11 +36425,15 @@
36290 }
36291 }
36292 }
36293 p->z = &p->zBuf[i+1];
36294 assert( i+p->n < sizeof(p->zBuf) );
36295 while( ALWAYS(p->n>0) && p->z[p->n-1]=='0' ){ p->n--; }
 
 
 
 
36296 }
36297
36298 /*
36299 ** Try to convert z into an unsigned 32-bit integer. Return true on
36300 ** success and false if there is an error.
@@ -37076,16 +37215,23 @@
37076 /*
37077 ** The hashing function.
37078 */
37079 static unsigned int strHash(const char *z){
37080 unsigned int h = 0;
37081 unsigned char c;
37082 while( (c = (unsigned char)*z++)!=0 ){ /*OPTIMIZATION-IF-TRUE*/
37083 /* Knuth multiplicative hashing. (Sorting & Searching, p. 510).
37084 ** 0x9e3779b1 is 2654435761 which is the closest prime number to
37085 ** (2**32)*golden_ratio, where golden_ratio = (sqrt(5) - 1)/2. */
37086 h += sqlite3UpperToLower[c];
 
 
 
 
 
 
 
 
37087 h *= 0x9e3779b1;
37088 }
37089 return h;
37090 }
37091
@@ -37154,13 +37300,12 @@
37154 sqlite3_free(pH->ht);
37155 pH->ht = new_ht;
37156 pH->htsize = new_size = sqlite3MallocSize(new_ht)/sizeof(struct _ht);
37157 memset(new_ht, 0, new_size*sizeof(struct _ht));
37158 for(elem=pH->first, pH->first=0; elem; elem = next_elem){
37159 unsigned int h = strHash(elem->pKey) % new_size;
37160 next_elem = elem->next;
37161 insertElement(pH, &new_ht[h], elem);
37162 }
37163 return 1;
37164 }
37165
37166 /* This function (for internal use only) locates an element in an
@@ -37174,27 +37319,26 @@
37174 unsigned int *pHash /* Write the hash value here */
37175 ){
37176 HashElem *elem; /* Used to loop thru the element list */
37177 unsigned int count; /* Number of elements left to test */
37178 unsigned int h; /* The computed hash */
37179 static HashElem nullElement = { 0, 0, 0, 0 };
37180
 
37181 if( pH->ht ){ /*OPTIMIZATION-IF-TRUE*/
37182 struct _ht *pEntry;
37183 h = strHash(pKey) % pH->htsize;
37184 pEntry = &pH->ht[h];
37185 elem = pEntry->chain;
37186 count = pEntry->count;
37187 }else{
37188 h = 0;
37189 elem = pH->first;
37190 count = pH->count;
37191 }
37192 if( pHash ) *pHash = h;
37193 while( count ){
37194 assert( elem!=0 );
37195 if( sqlite3StrICmp(elem->pKey,pKey)==0 ){
37196 return elem;
37197 }
37198 elem = elem->next;
37199 count--;
37200 }
@@ -37202,14 +37346,13 @@
37202 }
37203
37204 /* Remove a single entry from the hash table given a pointer to that
37205 ** element and a hash on the element's key.
37206 */
37207 static void removeElementGivenHash(
37208 Hash *pH, /* The pH containing "elem" */
37209 HashElem* elem, /* The element to be removed from the pH */
37210 unsigned int h /* Hash value for the element */
37211 ){
37212 struct _ht *pEntry;
37213 if( elem->prev ){
37214 elem->prev->next = elem->next;
37215 }else{
@@ -37217,11 +37360,11 @@
37217 }
37218 if( elem->next ){
37219 elem->next->prev = elem->prev;
37220 }
37221 if( pH->ht ){
37222 pEntry = &pH->ht[h];
37223 if( pEntry->chain==elem ){
37224 pEntry->chain = elem->next;
37225 }
37226 assert( pEntry->count>0 );
37227 pEntry->count--;
@@ -37268,11 +37411,11 @@
37268 assert( pKey!=0 );
37269 elem = findElementWithHash(pH,pKey,&h);
37270 if( elem->data ){
37271 void *old_data = elem->data;
37272 if( data==0 ){
37273 removeElementGivenHash(pH,elem,h);
37274 }else{
37275 elem->data = data;
37276 elem->pKey = pKey;
37277 }
37278 return old_data;
@@ -37279,19 +37422,17 @@
37279 }
37280 if( data==0 ) return 0;
37281 new_elem = (HashElem*)sqlite3Malloc( sizeof(HashElem) );
37282 if( new_elem==0 ) return data;
37283 new_elem->pKey = pKey;
 
37284 new_elem->data = data;
37285 pH->count++;
37286 if( pH->count>=10 && pH->count > 2*pH->htsize ){
37287 if( rehash(pH, pH->count*2) ){
37288 assert( pH->htsize>0 );
37289 h = strHash(pKey) % pH->htsize;
37290 }
37291 }
37292 insertElement(pH, pH->ht ? &pH->ht[h] : 0, new_elem);
37293 return 0;
37294 }
37295
37296 /************** End of hash.c ************************************************/
37297 /************** Begin file opcodes.c *****************************************/
@@ -40150,11 +40291,11 @@
40150 assert( pInode!=0 );
40151 assert( sqlite3_mutex_held(pInode->pLockMutex) );
40152 if( (pFile->ctrlFlags & (UNIXFILE_EXCL|UNIXFILE_RDONLY))==UNIXFILE_EXCL ){
40153 if( pInode->bProcessLock==0 ){
40154 struct flock lock;
40155 assert( pInode->nLock==0 );
40156 lock.l_whence = SEEK_SET;
40157 lock.l_start = SHARED_FIRST;
40158 lock.l_len = SHARED_SIZE;
40159 lock.l_type = F_WRLCK;
40160 rc = osSetPosixAdvisoryLock(pFile->h, &lock, pFile);
@@ -50698,11 +50839,11 @@
50698 ** allocate space for a new winShmNode and filename.
50699 */
50700 p = sqlite3MallocZero( sizeof(*p) );
50701 if( p==0 ) return SQLITE_IOERR_NOMEM_BKPT;
50702 nName = sqlite3Strlen30(pDbFd->zPath);
50703 pNew = sqlite3MallocZero( sizeof(*pShmNode) + nName + 17 );
50704 if( pNew==0 ){
50705 sqlite3_free(p);
50706 return SQLITE_IOERR_NOMEM_BKPT;
50707 }
50708 pNew->zFilename = (char*)&pNew[1];
@@ -51519,11 +51660,11 @@
51519 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
51520 "0123456789";
51521 size_t i, j;
51522 DWORD pid;
51523 int nPre = sqlite3Strlen30(SQLITE_TEMP_FILE_PREFIX);
51524 int nMax, nBuf, nDir, nLen;
51525 char *zBuf;
51526
51527 /* It's odd to simulate an io-error here, but really this is just
51528 ** using the io-error infrastructure to test that SQLite handles this
51529 ** function failing.
@@ -51531,11 +51672,12 @@
51531 SimulateIOError( return SQLITE_IOERR );
51532
51533 /* Allocate a temporary buffer to store the fully qualified file
51534 ** name for the temporary file. If this fails, we cannot continue.
51535 */
51536 nMax = pVfs->mxPathname; nBuf = nMax + 2;
 
51537 zBuf = sqlite3MallocZero( nBuf );
51538 if( !zBuf ){
51539 OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
51540 return SQLITE_IOERR_NOMEM_BKPT;
51541 }
@@ -52390,11 +52532,11 @@
52390 ** NOTE: We are dealing with a relative path name and the data
52391 ** directory has been set. Therefore, use it as the basis
52392 ** for converting the relative path name to an absolute
52393 ** one by prepending the data directory and a slash.
52394 */
52395 char *zOut = sqlite3MallocZero( pVfs->mxPathname+1 );
52396 if( !zOut ){
52397 return SQLITE_IOERR_NOMEM_BKPT;
52398 }
52399 if( cygwin_conv_path(
52400 (osIsNT() ? CCP_POSIX_TO_WIN_W : CCP_POSIX_TO_WIN_A) |
@@ -52485,17 +52627,16 @@
52485 if( nByte==0 ){
52486 sqlite3_free(zConverted);
52487 return winLogError(SQLITE_CANTOPEN_FULLPATH, osGetLastError(),
52488 "winFullPathname1", zRelative);
52489 }
52490 nByte += 3;
52491 zTemp = sqlite3MallocZero( nByte*sizeof(zTemp[0]) );
52492 if( zTemp==0 ){
52493 sqlite3_free(zConverted);
52494 return SQLITE_IOERR_NOMEM_BKPT;
52495 }
52496 nByte = osGetFullPathNameW((LPCWSTR)zConverted, nByte, zTemp, 0);
52497 if( nByte==0 ){
52498 sqlite3_free(zConverted);
52499 sqlite3_free(zTemp);
52500 return winLogError(SQLITE_CANTOPEN_FULLPATH, osGetLastError(),
52501 "winFullPathname2", zRelative);
@@ -52511,17 +52652,16 @@
52511 if( nByte==0 ){
52512 sqlite3_free(zConverted);
52513 return winLogError(SQLITE_CANTOPEN_FULLPATH, osGetLastError(),
52514 "winFullPathname3", zRelative);
52515 }
52516 nByte += 3;
52517 zTemp = sqlite3MallocZero( nByte*sizeof(zTemp[0]) );
52518 if( zTemp==0 ){
52519 sqlite3_free(zConverted);
52520 return SQLITE_IOERR_NOMEM_BKPT;
52521 }
52522 nByte = osGetFullPathNameA((char*)zConverted, nByte, zTemp, 0);
52523 if( nByte==0 ){
52524 sqlite3_free(zConverted);
52525 sqlite3_free(zTemp);
52526 return winLogError(SQLITE_CANTOPEN_FULLPATH, osGetLastError(),
52527 "winFullPathname4", zRelative);
@@ -53546,17 +53686,17 @@
53546 break;
53547 }
53548 }
53549 if( p==0 ){
53550 MemStore **apNew;
53551 p = sqlite3Malloc( sizeof(*p) + szName + 3 );
53552 if( p==0 ){
53553 sqlite3_mutex_leave(pVfsMutex);
53554 return SQLITE_NOMEM;
53555 }
53556 apNew = sqlite3Realloc(memdb_g.apMemStore,
53557 sizeof(apNew[0])*(memdb_g.nMemStore+1) );
53558 if( apNew==0 ){
53559 sqlite3_free(p);
53560 sqlite3_mutex_leave(pVfsMutex);
53561 return SQLITE_NOMEM;
53562 }
@@ -54262,11 +54402,11 @@
54262 void *pTmpSpace;
54263
54264 /* Allocate the Bitvec to be tested and a linear array of
54265 ** bits to act as the reference */
54266 pBitvec = sqlite3BitvecCreate( sz );
54267 pV = sqlite3MallocZero( (sz+7)/8 + 1 );
54268 pTmpSpace = sqlite3_malloc64(BITVEC_SZ);
54269 if( pBitvec==0 || pV==0 || pTmpSpace==0 ) goto bitvec_end;
54270
54271 /* NULL pBitvec tests */
54272 sqlite3BitvecSet(0, 1);
@@ -55809,16 +55949,16 @@
55809 **
55810 ** The PCache mutex must be held when this function is called.
55811 */
55812 static void pcache1ResizeHash(PCache1 *p){
55813 PgHdr1 **apNew;
55814 unsigned int nNew;
55815 unsigned int i;
55816
55817 assert( sqlite3_mutex_held(p->pGroup->mutex) );
55818
55819 nNew = p->nHash*2;
55820 if( nNew<256 ){
55821 nNew = 256;
55822 }
55823
55824 pcache1LeaveMutex(p->pGroup);
@@ -56037,11 +56177,11 @@
56037 ** Allocate a new cache.
56038 */
56039 static sqlite3_pcache *pcache1Create(int szPage, int szExtra, int bPurgeable){
56040 PCache1 *pCache; /* The newly created page cache */
56041 PGroup *pGroup; /* The group the new page cache will belong to */
56042 int sz; /* Bytes of memory required to allocate the new cache */
56043
56044 assert( (szPage & (szPage-1))==0 && szPage>=512 && szPage<=65536 );
56045 assert( szExtra < 300 );
56046
56047 sz = sizeof(PCache1) + sizeof(PGroup)*pcache1.separateCache;
@@ -58014,24 +58154,10 @@
58014 # define USEFETCH(x) ((x)->bUseFetch)
58015 #else
58016 # define USEFETCH(x) 0
58017 #endif
58018
58019 /*
58020 ** The argument to this macro is a file descriptor (type sqlite3_file*).
58021 ** Return 0 if it is not open, or non-zero (but not 1) if it is.
58022 **
58023 ** This is so that expressions can be written as:
58024 **
58025 ** if( isOpen(pPager->jfd) ){ ...
58026 **
58027 ** instead of
58028 **
58029 ** if( pPager->jfd->pMethods ){ ...
58030 */
58031 #define isOpen(pFd) ((pFd)->pMethods!=0)
58032
58033 #ifdef SQLITE_DIRECT_OVERFLOW_READ
58034 /*
58035 ** Return true if page pgno can be read directly from the database file
58036 ** by the b-tree layer. This is the case if:
58037 **
@@ -58047,11 +58173,11 @@
58047 if( sqlite3PCacheIsDirty(pPager->pPCache) ) return 0; /* Failed (3) */
58048 #ifndef SQLITE_OMIT_WAL
58049 if( pPager->pWal ){
58050 u32 iRead = 0;
58051 (void)sqlite3WalFindFrame(pPager->pWal, pgno, &iRead);
58052 return iRead==0; /* Condition (4) */
58053 }
58054 #endif
58055 assert( pPager->fd->pMethods->xDeviceCharacteristics!=0 );
58056 if( (pPager->fd->pMethods->xDeviceCharacteristics(pPager->fd)
58057 & SQLITE_IOCAP_SUBPAGE_READ)==0 ){
@@ -58530,11 +58656,11 @@
58530 ** zSuper[0] is set to 0 and SQLITE_OK returned.
58531 **
58532 ** If an error occurs while reading from the journal file, an SQLite
58533 ** error code is returned.
58534 */
58535 static int readSuperJournal(sqlite3_file *pJrnl, char *zSuper, u32 nSuper){
58536 int rc; /* Return code */
58537 u32 len; /* Length in bytes of super-journal name */
58538 i64 szJ; /* Total size in bytes of journal file pJrnl */
58539 u32 cksum; /* MJ checksum value read from journal */
58540 u32 u; /* Unsigned loop counter */
@@ -59313,11 +59439,11 @@
59313 rc = sqlite3OsSync(pPager->jfd, pPager->syncFlags);
59314 }
59315 }
59316 pPager->journalOff = 0;
59317 }else if( pPager->journalMode==PAGER_JOURNALMODE_PERSIST
59318 || (pPager->exclusiveMode && pPager->journalMode!=PAGER_JOURNALMODE_WAL)
59319 ){
59320 rc = zeroJournalHdr(pPager, hasSuper||pPager->tempFile);
59321 pPager->journalOff = 0;
59322 }else{
59323 /* This branch may be executed with Pager.journalMode==MEMORY if
@@ -59766,16 +59892,16 @@
59766 char *zSuperJournal = 0; /* Contents of super-journal file */
59767 i64 nSuperJournal; /* Size of super-journal file */
59768 char *zJournal; /* Pointer to one journal within MJ file */
59769 char *zSuperPtr; /* Space to hold super-journal filename */
59770 char *zFree = 0; /* Free this buffer */
59771 int nSuperPtr; /* Amount of space allocated to zSuperPtr[] */
59772
59773 /* Allocate space for both the pJournal and pSuper file descriptors.
59774 ** If successful, open the super-journal file for reading.
59775 */
59776 pSuper = (sqlite3_file *)sqlite3MallocZero(pVfs->szOsFile * 2);
59777 if( !pSuper ){
59778 rc = SQLITE_NOMEM_BKPT;
59779 pJournal = 0;
59780 }else{
59781 const int flags = (SQLITE_OPEN_READONLY|SQLITE_OPEN_SUPER_JOURNAL);
@@ -59789,15 +59915,18 @@
59789 ** sufficient space (in zSuperPtr) to hold the names of super-journal
59790 ** files extracted from regular rollback-journals.
59791 */
59792 rc = sqlite3OsFileSize(pSuper, &nSuperJournal);
59793 if( rc!=SQLITE_OK ) goto delsuper_out;
59794 nSuperPtr = pVfs->mxPathname+1;
 
59795 zFree = sqlite3Malloc(4 + nSuperJournal + nSuperPtr + 2);
59796 if( !zFree ){
59797 rc = SQLITE_NOMEM_BKPT;
59798 goto delsuper_out;
 
 
59799 }
59800 zFree[0] = zFree[1] = zFree[2] = zFree[3] = 0;
59801 zSuperJournal = &zFree[4];
59802 zSuperPtr = &zSuperJournal[nSuperJournal+2];
59803 rc = sqlite3OsRead(pSuper, zSuperJournal, (int)nSuperJournal, 0);
@@ -60054,11 +60183,11 @@
60054 ** (pPager->pageSize >= pPager->pVfs->mxPathname+1). Using os_unix.c,
60055 ** mxPathname is 512, which is the same as the minimum allowable value
60056 ** for pageSize.
60057 */
60058 zSuper = pPager->pTmpSpace;
60059 rc = readSuperJournal(pPager->jfd, zSuper, pPager->pVfs->mxPathname+1);
60060 if( rc==SQLITE_OK && zSuper[0] ){
60061 rc = sqlite3OsAccess(pVfs, zSuper, SQLITE_ACCESS_EXISTS, &res);
60062 }
60063 zSuper = 0;
60064 if( rc!=SQLITE_OK || !res ){
@@ -60193,11 +60322,11 @@
60193 /* Leave 4 bytes of space before the super-journal filename in memory.
60194 ** This is because it may end up being passed to sqlite3OsOpen(), in
60195 ** which case it requires 4 0x00 bytes in memory immediately before
60196 ** the filename. */
60197 zSuper = &pPager->pTmpSpace[4];
60198 rc = readSuperJournal(pPager->jfd, zSuper, pPager->pVfs->mxPathname+1);
60199 testcase( rc!=SQLITE_OK );
60200 }
60201 if( rc==SQLITE_OK
60202 && (pPager->eState>=PAGER_WRITER_DBMOD || pPager->eState==PAGER_OPEN)
60203 ){
@@ -61963,10 +62092,11 @@
61963 int useJournal = (flags & PAGER_OMIT_JOURNAL)==0; /* False to omit journal */
61964 int pcacheSize = sqlite3PcacheSize(); /* Bytes to allocate for PCache */
61965 u32 szPageDflt = SQLITE_DEFAULT_PAGE_SIZE; /* Default page size */
61966 const char *zUri = 0; /* URI args to copy */
61967 int nUriByte = 1; /* Number of bytes of URI args at *zUri */
 
61968
61969 /* Figure out how much space is required for each journal file-handle
61970 ** (there are two of them, the main journal and the sub-journal). */
61971 journalFileSize = ROUND8(sqlite3JournalSize(pVfs));
61972
@@ -61989,12 +62119,12 @@
61989 ** to by zPathname, length nPathname. Or, if this is a temporary file,
61990 ** leave both nPathname and zPathname set to 0.
61991 */
61992 if( zFilename && zFilename[0] ){
61993 const char *z;
61994 nPathname = pVfs->mxPathname+1;
61995 zPathname = sqlite3DbMallocRaw(0, nPathname*2);
61996 if( zPathname==0 ){
61997 return SQLITE_NOMEM_BKPT;
61998 }
61999 zPathname[0] = 0; /* Make sure initialized even if FullPathname() fails */
62000 rc = sqlite3OsFullPathname(pVfs, zFilename, nPathname, zPathname);
@@ -62077,18 +62207,18 @@
62077 assert( SQLITE_PTRSIZE==sizeof(Pager*) );
62078 pPtr = (u8 *)sqlite3MallocZero(
62079 ROUND8(sizeof(*pPager)) + /* Pager structure */
62080 ROUND8(pcacheSize) + /* PCache object */
62081 ROUND8(pVfs->szOsFile) + /* The main db file */
62082 journalFileSize * 2 + /* The two journal files */
62083 SQLITE_PTRSIZE + /* Space to hold a pointer */
62084 4 + /* Database prefix */
62085 nPathname + 1 + /* database filename */
62086 nUriByte + /* query parameters */
62087 nPathname + 8 + 1 + /* Journal filename */
62088 #ifndef SQLITE_OMIT_WAL
62089 nPathname + 4 + 1 + /* WAL filename */
62090 #endif
62091 3 /* Terminator */
62092 );
62093 assert( EIGHT_BYTE_ALIGNMENT(SQLITE_INT_TO_PTR(journalFileSize)) );
62094 if( !pPtr ){
@@ -65790,11 +65920,11 @@
65790 ){
65791 int rc = SQLITE_OK;
65792
65793 /* Enlarge the pWal->apWiData[] array if required */
65794 if( pWal->nWiData<=iPage ){
65795 sqlite3_int64 nByte = sizeof(u32*)*(iPage+1);
65796 volatile u32 **apNew;
65797 apNew = (volatile u32 **)sqlite3Realloc((void *)pWal->apWiData, nByte);
65798 if( !apNew ){
65799 *ppPage = 0;
65800 return SQLITE_NOMEM_BKPT;
@@ -68023,15 +68153,11 @@
68023 ** so it takes care to hold an exclusive lock on the corresponding
68024 ** WAL_READ_LOCK() while changing values.
68025 */
68026 static int walTryBeginRead(Wal *pWal, int *pChanged, int useWal, int *pCnt){
68027 volatile WalCkptInfo *pInfo; /* Checkpoint information in wal-index */
68028 u32 mxReadMark; /* Largest aReadMark[] value */
68029 int mxI; /* Index of largest aReadMark[] value */
68030 int i; /* Loop counter */
68031 int rc = SQLITE_OK; /* Return code */
68032 u32 mxFrame; /* Wal frame to lock to */
68033 #ifdef SQLITE_ENABLE_SETLK_TIMEOUT
68034 int nBlockTmout = 0;
68035 #endif
68036
68037 assert( pWal->readLock<0 ); /* Not currently locked */
@@ -68133,145 +68259,151 @@
68133
68134 assert( pWal->nWiData>0 );
68135 assert( pWal->apWiData[0]!=0 );
68136 pInfo = walCkptInfo(pWal);
68137 SEH_INJECT_FAULT;
68138 if( !useWal && AtomicLoad(&pInfo->nBackfill)==pWal->hdr.mxFrame
68139 #ifdef SQLITE_ENABLE_SNAPSHOT
68140 && ((pWal->bGetSnapshot==0 && pWal->pSnapshot==0) || pWal->hdr.mxFrame==0)
68141 #endif
68142 ){
68143 /* The WAL has been completely backfilled (or it is empty).
68144 ** and can be safely ignored.
68145 */
68146 rc = walLockShared(pWal, WAL_READ_LOCK(0));
68147 walShmBarrier(pWal);
68148 if( rc==SQLITE_OK ){
68149 if( memcmp((void *)walIndexHdr(pWal), &pWal->hdr, sizeof(WalIndexHdr)) ){
68150 /* It is not safe to allow the reader to continue here if frames
68151 ** may have been appended to the log before READ_LOCK(0) was obtained.
68152 ** When holding READ_LOCK(0), the reader ignores the entire log file,
68153 ** which implies that the database file contains a trustworthy
68154 ** snapshot. Since holding READ_LOCK(0) prevents a checkpoint from
68155 ** happening, this is usually correct.
68156 **
68157 ** However, if frames have been appended to the log (or if the log
68158 ** is wrapped and written for that matter) before the READ_LOCK(0)
68159 ** is obtained, that is not necessarily true. A checkpointer may
68160 ** have started to backfill the appended frames but crashed before
68161 ** it finished. Leaving a corrupt image in the database file.
68162 */
68163 walUnlockShared(pWal, WAL_READ_LOCK(0));
68164 return WAL_RETRY;
68165 }
68166 pWal->readLock = 0;
68167 return SQLITE_OK;
68168 }else if( rc!=SQLITE_BUSY ){
68169 return rc;
68170 }
68171 }
68172
68173 /* If we get this far, it means that the reader will want to use
68174 ** the WAL to get at content from recent commits. The job now is
68175 ** to select one of the aReadMark[] entries that is closest to
68176 ** but not exceeding pWal->hdr.mxFrame and lock that entry.
68177 */
68178 mxReadMark = 0;
68179 mxI = 0;
68180 mxFrame = pWal->hdr.mxFrame;
68181 #ifdef SQLITE_ENABLE_SNAPSHOT
68182 if( pWal->pSnapshot && pWal->pSnapshot->mxFrame<mxFrame ){
68183 mxFrame = pWal->pSnapshot->mxFrame;
68184 }
68185 #endif
68186 for(i=1; i<WAL_NREADER; i++){
68187 u32 thisMark = AtomicLoad(pInfo->aReadMark+i); SEH_INJECT_FAULT;
68188 if( mxReadMark<=thisMark && thisMark<=mxFrame ){
68189 assert( thisMark!=READMARK_NOT_USED );
68190 mxReadMark = thisMark;
68191 mxI = i;
68192 }
68193 }
68194 if( (pWal->readOnly & WAL_SHM_RDONLY)==0
68195 && (mxReadMark<mxFrame || mxI==0)
68196 ){
68197 for(i=1; i<WAL_NREADER; i++){
68198 rc = walLockExclusive(pWal, WAL_READ_LOCK(i), 1);
68199 if( rc==SQLITE_OK ){
68200 AtomicStore(pInfo->aReadMark+i,mxFrame);
68201 mxReadMark = mxFrame;
68202 mxI = i;
68203 walUnlockExclusive(pWal, WAL_READ_LOCK(i), 1);
68204 break;
68205 }else if( rc!=SQLITE_BUSY ){
68206 return rc;
68207 }
68208 }
68209 }
68210 if( mxI==0 ){
68211 assert( rc==SQLITE_BUSY || (pWal->readOnly & WAL_SHM_RDONLY)!=0 );
68212 return rc==SQLITE_BUSY ? WAL_RETRY : SQLITE_READONLY_CANTINIT;
68213 }
68214
68215 (void)walEnableBlockingMs(pWal, nBlockTmout);
68216 rc = walLockShared(pWal, WAL_READ_LOCK(mxI));
68217 walDisableBlocking(pWal);
68218 if( rc ){
68219 #ifdef SQLITE_ENABLE_SETLK_TIMEOUT
68220 if( rc==SQLITE_BUSY_TIMEOUT ){
68221 *pCnt |= WAL_RETRY_BLOCKED_MASK;
68222 }
68223 #else
68224 assert( rc!=SQLITE_BUSY_TIMEOUT );
68225 #endif
68226 assert( (rc&0xFF)!=SQLITE_BUSY||rc==SQLITE_BUSY||rc==SQLITE_BUSY_TIMEOUT );
68227 return (rc&0xFF)==SQLITE_BUSY ? WAL_RETRY : rc;
68228 }
68229 /* Now that the read-lock has been obtained, check that neither the
68230 ** value in the aReadMark[] array or the contents of the wal-index
68231 ** header have changed.
68232 **
68233 ** It is necessary to check that the wal-index header did not change
68234 ** between the time it was read and when the shared-lock was obtained
68235 ** on WAL_READ_LOCK(mxI) was obtained to account for the possibility
68236 ** that the log file may have been wrapped by a writer, or that frames
68237 ** that occur later in the log than pWal->hdr.mxFrame may have been
68238 ** copied into the database by a checkpointer. If either of these things
68239 ** happened, then reading the database with the current value of
68240 ** pWal->hdr.mxFrame risks reading a corrupted snapshot. So, retry
68241 ** instead.
68242 **
68243 ** Before checking that the live wal-index header has not changed
68244 ** since it was read, set Wal.minFrame to the first frame in the wal
68245 ** file that has not yet been checkpointed. This client will not need
68246 ** to read any frames earlier than minFrame from the wal file - they
68247 ** can be safely read directly from the database file.
68248 **
68249 ** Because a ShmBarrier() call is made between taking the copy of
68250 ** nBackfill and checking that the wal-header in shared-memory still
68251 ** matches the one cached in pWal->hdr, it is guaranteed that the
68252 ** checkpointer that set nBackfill was not working with a wal-index
68253 ** header newer than that cached in pWal->hdr. If it were, that could
68254 ** cause a problem. The checkpointer could omit to checkpoint
68255 ** a version of page X that lies before pWal->minFrame (call that version
68256 ** A) on the basis that there is a newer version (version B) of the same
68257 ** page later in the wal file. But if version B happens to like past
68258 ** frame pWal->hdr.mxFrame - then the client would incorrectly assume
68259 ** that it can read version A from the database file. However, since
68260 ** we can guarantee that the checkpointer that set nBackfill could not
68261 ** see any pages past pWal->hdr.mxFrame, this problem does not come up.
68262 */
68263 pWal->minFrame = AtomicLoad(&pInfo->nBackfill)+1; SEH_INJECT_FAULT;
68264 walShmBarrier(pWal);
68265 if( AtomicLoad(pInfo->aReadMark+mxI)!=mxReadMark
68266 || memcmp((void *)walIndexHdr(pWal), &pWal->hdr, sizeof(WalIndexHdr))
68267 ){
68268 walUnlockShared(pWal, WAL_READ_LOCK(mxI));
68269 return WAL_RETRY;
68270 }else{
68271 assert( mxReadMark<=pWal->hdr.mxFrame );
68272 pWal->readLock = (i16)mxI;
 
 
 
 
 
 
68273 }
68274 return rc;
68275 }
68276
68277 #ifdef SQLITE_ENABLE_SNAPSHOT
@@ -71412,11 +71544,11 @@
71412 ** up to the size of 1 varint plus 1 8-byte value when the cursor
71413 ** position is restored. Hence the 17 bytes of padding allocated
71414 ** below. */
71415 void *pKey;
71416 pCur->nKey = sqlite3BtreePayloadSize(pCur);
71417 pKey = sqlite3Malloc( pCur->nKey + 9 + 8 );
71418 if( pKey ){
71419 rc = sqlite3BtreePayload(pCur, 0, (int)pCur->nKey, pKey);
71420 if( rc==SQLITE_OK ){
71421 memset(((u8*)pKey)+pCur->nKey, 0, 9+8);
71422 pCur->pKey = pKey;
@@ -76783,11 +76915,11 @@
76783 testcase( nCell==2 ); /* Minimum legal index key size */
76784 if( nCell<2 || nCell/pCur->pBt->usableSize>pCur->pBt->nPage ){
76785 rc = SQLITE_CORRUPT_PAGE(pPage);
76786 goto moveto_index_finish;
76787 }
76788 pCellKey = sqlite3Malloc( nCell+nOverrun );
76789 if( pCellKey==0 ){
76790 rc = SQLITE_NOMEM_BKPT;
76791 goto moveto_index_finish;
76792 }
76793 pCur->ix = (u16)idx;
@@ -81972,10 +82104,11 @@
81972 ** blob of allocated memory. The xFree function should not call sqlite3_free()
81973 ** on the memory, the btree layer does that.
81974 */
81975 SQLITE_PRIVATE void *sqlite3BtreeSchema(Btree *p, int nBytes, void(*xFree)(void *)){
81976 BtShared *pBt = p->pBt;
 
81977 sqlite3BtreeEnter(p);
81978 if( !pBt->pSchema && nBytes ){
81979 pBt->pSchema = sqlite3DbMallocZero(0, nBytes);
81980 pBt->xFreeSchema = xFree;
81981 }
@@ -83274,11 +83407,11 @@
83274 if( (pMem->flags & (MEM_Str|MEM_Term|MEM_Ephem|MEM_Static))!=MEM_Str ){
83275 /* pMem must be a string, and it cannot be an ephemeral or static string */
83276 return;
83277 }
83278 if( pMem->enc!=SQLITE_UTF8 ) return;
83279 if( NEVER(pMem->z==0) ) return;
83280 if( pMem->flags & MEM_Dyn ){
83281 if( pMem->xDel==sqlite3_free
83282 && sqlite3_msize(pMem->z) >= (u64)(pMem->n+1)
83283 ){
83284 pMem->z[pMem->n] = 0;
@@ -83993,31 +84126,34 @@
83993 ** copies (created by OP_SCopy) are not misused.
83994 */
83995 SQLITE_PRIVATE void sqlite3VdbeMemAboutToChange(Vdbe *pVdbe, Mem *pMem){
83996 int i;
83997 Mem *pX;
83998 for(i=1, pX=pVdbe->aMem+1; i<pVdbe->nMem; i++, pX++){
83999 if( pX->pScopyFrom==pMem ){
84000 u16 mFlags;
84001 if( pVdbe->db->flags & SQLITE_VdbeTrace ){
84002 sqlite3DebugPrintf("Invalidate R[%d] due to change in R[%d]\n",
84003 (int)(pX - pVdbe->aMem), (int)(pMem - pVdbe->aMem));
84004 }
84005 /* If pX is marked as a shallow copy of pMem, then try to verify that
84006 ** no significant changes have been made to pX since the OP_SCopy.
84007 ** A significant change would indicated a missed call to this
84008 ** function for pX. Minor changes, such as adding or removing a
84009 ** dual type, are allowed, as long as the underlying value is the
84010 ** same. */
84011 mFlags = pMem->flags & pX->flags & pX->mScopyFlags;
84012 assert( (mFlags&(MEM_Int|MEM_IntReal))==0 || pMem->u.i==pX->u.i );
84013
84014 /* pMem is the register that is changing. But also mark pX as
84015 ** undefined so that we can quickly detect the shallow-copy error */
84016 pX->flags = MEM_Undefined;
84017 pX->pScopyFrom = 0;
84018 }
 
 
 
84019 }
84020 pMem->pScopyFrom = 0;
84021 }
84022 #endif /* SQLITE_DEBUG */
84023
@@ -84384,11 +84520,11 @@
84384 if( p ){
84385 UnpackedRecord *pRec = p->ppRec[0];
84386
84387 if( pRec==0 ){
84388 Index *pIdx = p->pIdx; /* Index being probed */
84389 int nByte; /* Bytes of space to allocate */
84390 int i; /* Counter variable */
84391 int nCol = pIdx->nColumn; /* Number of index columns including rowid */
84392
84393 nByte = sizeof(Mem) * nCol + ROUND8(sizeof(UnpackedRecord));
84394 pRec = (UnpackedRecord*)sqlite3DbMallocZero(db, nByte);
@@ -84450,11 +84586,11 @@
84450 sqlite3_value **ppVal, /* Write the new value here */
84451 struct ValueNewStat4Ctx *pCtx /* Second argument for valueNew() */
84452 ){
84453 sqlite3_context ctx; /* Context object for function invocation */
84454 sqlite3_value **apVal = 0; /* Function arguments */
84455 int nVal = 0; /* Size of apVal[] array */
84456 FuncDef *pFunc = 0; /* Function definition */
84457 sqlite3_value *pVal = 0; /* New value */
84458 int rc = SQLITE_OK; /* Return code */
84459 ExprList *pList = 0; /* Function arguments */
84460 int i; /* Iterator variable */
@@ -85729,11 +85865,11 @@
85729 p->iSub++;
85730 p->iAddr = 0;
85731 }
85732
85733 if( pRet->p4type==P4_SUBPROGRAM ){
85734 int nByte = (p->nSub+1)*sizeof(SubProgram*);
85735 int j;
85736 for(j=0; j<p->nSub; j++){
85737 if( p->apSub[j]==pRet->p4.pProgram ) break;
85738 }
85739 if( j==p->nSub ){
@@ -85859,12 +85995,12 @@
85859 ** through all the opcodes and fixes up some details.
85860 **
85861 ** (1) For each jump instruction with a negative P2 value (a label)
85862 ** resolve the P2 value to an actual address.
85863 **
85864 ** (2) Compute the maximum number of arguments used by any SQL function
85865 ** and store that value in *pMaxFuncArgs.
85866 **
85867 ** (3) Update the Vdbe.readOnly and Vdbe.bIsReader flags to accurately
85868 ** indicate what the prepared statement actually does.
85869 **
85870 ** (4) (discontinued)
@@ -85873,12 +86009,12 @@
85873 **
85874 ** This routine will only function correctly if the mkopcodeh.tcl generator
85875 ** script numbers the opcodes correctly. Changes to this routine must be
85876 ** coordinated with changes to mkopcodeh.tcl.
85877 */
85878 static void resolveP2Values(Vdbe *p, int *pMaxFuncArgs){
85879 int nMaxArgs = *pMaxFuncArgs;
85880 Op *pOp;
85881 Parse *pParse = p->pParse;
85882 int *aLabel = pParse->aLabel;
85883
85884 assert( pParse->db->mallocFailed==0 ); /* tag-20230419-1 */
@@ -85919,19 +86055,23 @@
85919 assert( pOp->p2>=0 );
85920 goto resolve_p2_values_loop_exit;
85921 }
85922 #ifndef SQLITE_OMIT_VIRTUALTABLE
85923 case OP_VUpdate: {
85924 if( pOp->p2>nMaxArgs ) nMaxArgs = pOp->p2;
85925 break;
85926 }
85927 case OP_VFilter: {
85928 int n;
 
 
 
85929 assert( (pOp - p->aOp) >= 3 );
85930 assert( pOp[-1].opcode==OP_Integer );
 
85931 n = pOp[-1].p1;
85932 if( n>nMaxArgs ) nMaxArgs = n;
85933 /* Fall through into the default case */
85934 /* no break */ deliberate_fall_through
85935 }
85936 #endif
85937 default: {
@@ -85968,11 +86108,11 @@
85968 if( aLabel ){
85969 sqlite3DbNNFreeNN(p->db, pParse->aLabel);
85970 pParse->aLabel = 0;
85971 }
85972 pParse->nLabel = 0;
85973 *pMaxFuncArgs = nMaxArgs;
85974 assert( p->bIsReader!=0 || DbMaskAllZero(p->btreeMask) );
85975 }
85976
85977 #ifdef SQLITE_DEBUG
85978 /*
@@ -86197,11 +86337,11 @@
86197 int addrVisit, /* Address of rows visited counter */
86198 LogEst nEst, /* Estimated number of output rows */
86199 const char *zName /* Name of table or index being scanned */
86200 ){
86201 if( IS_STMT_SCANSTATUS(p->db) ){
86202 sqlite3_int64 nByte = (p->nScan+1) * sizeof(ScanStatus);
86203 ScanStatus *aNew;
86204 aNew = (ScanStatus*)sqlite3DbRealloc(p->db, p->aScan, nByte);
86205 if( aNew ){
86206 ScanStatus *pNew = &aNew[p->nScan++];
86207 memset(pNew, 0, sizeof(ScanStatus));
@@ -87147,17 +87287,19 @@
87147 **
87148 ** All other fields of Mem can safely remain uninitialized for now. They
87149 ** will be initialized before use.
87150 */
87151 static void initMemArray(Mem *p, int N, sqlite3 *db, u16 flags){
 
87152 if( N>0 ){
87153 do{
87154 p->flags = flags;
87155 p->db = db;
87156 p->szMalloc = 0;
87157 #ifdef SQLITE_DEBUG
87158 p->pScopyFrom = 0;
 
87159 #endif
87160 p++;
87161 }while( (--N)>0 );
87162 }
87163 }
@@ -87172,10 +87314,11 @@
87172 */
87173 static void releaseMemArray(Mem *p, int N){
87174 if( p && N ){
87175 Mem *pEnd = &p[N];
87176 sqlite3 *db = p->db;
 
87177 if( db->pnBytesFreed ){
87178 do{
87179 if( p->szMalloc ) sqlite3DbFree(db, p->zMalloc);
87180 }while( (++p)<pEnd );
87181 return;
@@ -87643,19 +87786,20 @@
87643 ){
87644 sqlite3 *db; /* The database connection */
87645 int nVar; /* Number of parameters */
87646 int nMem; /* Number of VM memory registers */
87647 int nCursor; /* Number of cursors required */
87648 int nArg; /* Number of arguments in subprograms */
87649 int n; /* Loop counter */
87650 struct ReusableSpace x; /* Reusable bulk memory */
87651
87652 assert( p!=0 );
87653 assert( p->nOp>0 );
87654 assert( pParse!=0 );
87655 assert( p->eVdbeState==VDBE_INIT_STATE );
87656 assert( pParse==p->pParse );
 
87657 p->pVList = pParse->pVList;
87658 pParse->pVList = 0;
87659 db = p->db;
87660 assert( db->mallocFailed==0 );
87661 nVar = pParse->nVar;
@@ -87714,10 +87858,13 @@
87714 p->aVar = allocSpace(&x, p->aVar, nVar*sizeof(Mem));
87715 p->apArg = allocSpace(&x, p->apArg, nArg*sizeof(Mem*));
87716 p->apCsr = allocSpace(&x, p->apCsr, nCursor*sizeof(VdbeCursor*));
87717 }
87718 }
 
 
 
87719
87720 if( db->mallocFailed ){
87721 p->nVar = 0;
87722 p->nCursor = 0;
87723 p->nMem = 0;
@@ -89211,10 +89358,11 @@
89211 SQLITE_PRIVATE UnpackedRecord *sqlite3VdbeAllocUnpackedRecord(
89212 KeyInfo *pKeyInfo /* Description of the record */
89213 ){
89214 UnpackedRecord *p; /* Unpacked record to return */
89215 int nByte; /* Number of bytes required for *p */
 
89216 nByte = ROUND8P(sizeof(UnpackedRecord)) + sizeof(Mem)*(pKeyInfo->nKeyField+1);
89217 p = (UnpackedRecord *)sqlite3DbMallocRaw(pKeyInfo->db, nByte);
89218 if( !p ) return 0;
89219 p->aMem = (Mem*)&((char*)p)[ROUND8P(sizeof(UnpackedRecord))];
89220 assert( pKeyInfo->aSortFlags!=0 );
@@ -90617,11 +90765,10 @@
90617 */
90618 static SQLITE_NOINLINE void invokeProfileCallback(sqlite3 *db, Vdbe *p){
90619 sqlite3_int64 iNow;
90620 sqlite3_int64 iElapse;
90621 assert( p->startTime>0 );
90622 assert( (db->mTrace & (SQLITE_TRACE_PROFILE|SQLITE_TRACE_XPROFILE))!=0 );
90623 assert( db->init.busy==0 );
90624 assert( p->zSql!=0 );
90625 sqlite3OsCurrentTimeInt64(db->pVfs, &iNow);
90626 iElapse = (iNow - p->startTime)*1000000;
90627 #ifndef SQLITE_OMIT_DEPRECATED
@@ -91337,11 +91484,11 @@
91337 if( db->nVdbeActive==0 ){
91338 AtomicStore(&db->u1.isInterrupted, 0);
91339 }
91340
91341 assert( db->nVdbeWrite>0 || db->autoCommit==0
91342 || (db->nDeferredCons==0 && db->nDeferredImmCons==0)
91343 );
91344
91345 #ifndef SQLITE_OMIT_TRACE
91346 if( (db->mTrace & (SQLITE_TRACE_PROFILE|SQLITE_TRACE_XPROFILE))!=0
91347 && !db->init.busy && p->zSql ){
@@ -91848,10 +91995,11 @@
91848 /* .zMalloc = */ (char*)0,
91849 /* .xDel = */ (void(*)(void*))0,
91850 #ifdef SQLITE_DEBUG
91851 /* .pScopyFrom = */ (Mem*)0,
91852 /* .mScopyFlags= */ 0,
 
91853 #endif
91854 };
91855 return &nullMem;
91856 }
91857
@@ -91889,11 +92037,11 @@
91889 **
91890 ** sqlite3_column_int()
91891 ** sqlite3_column_int64()
91892 ** sqlite3_column_text()
91893 ** sqlite3_column_text16()
91894 ** sqlite3_column_real()
91895 ** sqlite3_column_bytes()
91896 ** sqlite3_column_bytes16()
91897 ** sqlite3_column_blob()
91898 */
91899 static void columnMallocFailure(sqlite3_stmt *pStmt)
@@ -92730,10 +92878,11 @@
92730 */
92731 SQLITE_API int sqlite3_preupdate_old(sqlite3 *db, int iIdx, sqlite3_value **ppValue){
92732 PreUpdate *p;
92733 Mem *pMem;
92734 int rc = SQLITE_OK;
 
92735
92736 #ifdef SQLITE_ENABLE_API_ARMOR
92737 if( db==0 || ppValue==0 ){
92738 return SQLITE_MISUSE_BKPT;
92739 }
@@ -92744,13 +92893,15 @@
92744 if( !p || p->op==SQLITE_INSERT ){
92745 rc = SQLITE_MISUSE_BKPT;
92746 goto preupdate_old_out;
92747 }
92748 if( p->pPk ){
92749 iIdx = sqlite3TableColumnToIndex(p->pPk, iIdx);
 
 
92750 }
92751 if( iIdx>=p->pCsr->nField || iIdx<0 ){
92752 rc = SQLITE_RANGE;
92753 goto preupdate_old_out;
92754 }
92755
92756 if( iIdx==p->pTab->iPKey ){
@@ -92777,18 +92928,20 @@
92777 goto preupdate_old_out;
92778 }
92779 p->aRecord = aRec;
92780 }
92781
92782 pMem = *ppValue = &p->pUnpacked->aMem[iIdx];
92783 if( iIdx>=p->pUnpacked->nField ){
92784 /* This occurs when the table has been extended using ALTER TABLE
92785 ** ADD COLUMN. The value to return is the default value of the column. */
92786 Column *pCol = &p->pTab->aCol[iIdx];
92787 if( pCol->iDflt>0 ){
92788 if( p->apDflt==0 ){
92789 int nByte = sizeof(sqlite3_value*)*p->pTab->nCol;
 
 
92790 p->apDflt = (sqlite3_value**)sqlite3DbMallocZero(db, nByte);
92791 if( p->apDflt==0 ) goto preupdate_old_out;
92792 }
92793 if( p->apDflt[iIdx]==0 ){
92794 sqlite3_value *pVal = 0;
@@ -92882,10 +93035,11 @@
92882 */
92883 SQLITE_API int sqlite3_preupdate_new(sqlite3 *db, int iIdx, sqlite3_value **ppValue){
92884 PreUpdate *p;
92885 int rc = SQLITE_OK;
92886 Mem *pMem;
 
92887
92888 #ifdef SQLITE_ENABLE_API_ARMOR
92889 if( db==0 || ppValue==0 ){
92890 return SQLITE_MISUSE_BKPT;
92891 }
@@ -92894,13 +93048,16 @@
92894 if( !p || p->op==SQLITE_DELETE ){
92895 rc = SQLITE_MISUSE_BKPT;
92896 goto preupdate_new_out;
92897 }
92898 if( p->pPk && p->op!=SQLITE_UPDATE ){
92899 iIdx = sqlite3TableColumnToIndex(p->pPk, iIdx);
 
 
92900 }
92901 if( iIdx>=p->pCsr->nField || iIdx<0 ){
 
92902 rc = SQLITE_RANGE;
92903 goto preupdate_new_out;
92904 }
92905
92906 if( p->op==SQLITE_INSERT ){
@@ -92916,37 +93073,38 @@
92916 rc = SQLITE_NOMEM;
92917 goto preupdate_new_out;
92918 }
92919 p->pNewUnpacked = pUnpack;
92920 }
92921 pMem = &pUnpack->aMem[iIdx];
92922 if( iIdx==p->pTab->iPKey ){
92923 sqlite3VdbeMemSetInt64(pMem, p->iKey2);
92924 }else if( iIdx>=pUnpack->nField ){
92925 pMem = (sqlite3_value *)columnNullValue();
92926 }
92927 }else{
92928 /* For an UPDATE, memory cell (p->iNewReg+1+iIdx) contains the required
92929 ** value. Make a copy of the cell contents and return a pointer to it.
92930 ** It is not safe to return a pointer to the memory cell itself as the
92931 ** caller may modify the value text encoding.
92932 */
92933 assert( p->op==SQLITE_UPDATE );
92934 if( !p->aNew ){
92935 p->aNew = (Mem *)sqlite3DbMallocZero(db, sizeof(Mem) * p->pCsr->nField);
 
92936 if( !p->aNew ){
92937 rc = SQLITE_NOMEM;
92938 goto preupdate_new_out;
92939 }
92940 }
92941 assert( iIdx>=0 && iIdx<p->pCsr->nField );
92942 pMem = &p->aNew[iIdx];
92943 if( pMem->flags==0 ){
92944 if( iIdx==p->pTab->iPKey ){
92945 sqlite3VdbeMemSetInt64(pMem, p->iKey2);
92946 }else{
92947 rc = sqlite3VdbeMemCopy(pMem, &p->v->aMem[p->iNewReg+1+iIdx]);
92948 if( rc!=SQLITE_OK ) goto preupdate_new_out;
92949 }
92950 }
92951 }
92952 *ppValue = pMem;
@@ -93700,11 +93858,11 @@
93700 ** the top of the register space. Cursor 1 is at Mem[p->nMem-1].
93701 ** Cursor 2 is at Mem[p->nMem-2]. And so forth.
93702 */
93703 Mem *pMem = iCur>0 ? &p->aMem[p->nMem-iCur] : p->aMem;
93704
93705 int nByte;
93706 VdbeCursor *pCx = 0;
93707 nByte =
93708 ROUND8P(sizeof(VdbeCursor)) + 2*sizeof(u32)*nField +
93709 (eCurType==CURTYPE_BTREE?sqlite3BtreeCursorSize():0);
93710
@@ -93728,11 +93886,11 @@
93728 pMem->z = pMem->zMalloc = sqlite3DbMallocRaw(pMem->db, nByte);
93729 if( pMem->zMalloc==0 ){
93730 pMem->szMalloc = 0;
93731 return 0;
93732 }
93733 pMem->szMalloc = nByte;
93734 }
93735
93736 p->apCsr[iCur] = pCx = (VdbeCursor*)pMem->zMalloc;
93737 memset(pCx, 0, offsetof(VdbeCursor,pAltCursor));
93738 pCx->eCurType = eCurType;
@@ -94031,10 +94189,11 @@
94031 }
94032 static void registerTrace(int iReg, Mem *p){
94033 printf("R[%d] = ", iReg);
94034 memTracePrint(p);
94035 if( p->pScopyFrom ){
 
94036 printf(" <== R[%d]", (int)(p->pScopyFrom - &p[-iReg]));
94037 }
94038 printf("\n");
94039 sqlite3VdbeCheckMemInvariants(p);
94040 }
@@ -95014,10 +95173,11 @@
95014 #ifdef SQLITE_DEBUG
95015 pIn1->pScopyFrom = 0;
95016 { int i;
95017 for(i=1; i<p->nMem; i++){
95018 if( aMem[i].pScopyFrom==pIn1 ){
 
95019 aMem[i].pScopyFrom = pOut;
95020 }
95021 }
95022 }
95023 #endif
@@ -95086,10 +95246,11 @@
95086 assert( pOut!=pIn1 );
95087 sqlite3VdbeMemShallowCopy(pOut, pIn1, MEM_Ephem);
95088 #ifdef SQLITE_DEBUG
95089 pOut->pScopyFrom = pIn1;
95090 pOut->mScopyFlags = pIn1->flags;
 
95091 #endif
95092 break;
95093 }
95094
95095 /* Opcode: IntCopy P1 P2 * * *
@@ -100746,11 +100907,11 @@
100746 **
100747 ** If P5 is non-zero, then recursive program invocation is enabled.
100748 */
100749 case OP_Program: { /* jump0 */
100750 int nMem; /* Number of memory registers for sub-program */
100751 int nByte; /* Bytes of runtime space required for sub-program */
100752 Mem *pRt; /* Register to allocate runtime space */
100753 Mem *pMem; /* Used to iterate through memory cells */
100754 Mem *pEnd; /* Last memory cell in new array */
100755 VdbeFrame *pFrame; /* New vdbe frame to execute in */
100756 SubProgram *pProgram; /* Sub-program to execute */
@@ -100797,19 +100958,19 @@
100797 assert( nMem>0 );
100798 if( pProgram->nCsr==0 ) nMem++;
100799 nByte = ROUND8(sizeof(VdbeFrame))
100800 + nMem * sizeof(Mem)
100801 + pProgram->nCsr * sizeof(VdbeCursor*)
100802 + (pProgram->nOp + 7)/8;
100803 pFrame = sqlite3DbMallocZero(db, nByte);
100804 if( !pFrame ){
100805 goto no_mem;
100806 }
100807 sqlite3VdbeMemRelease(pRt);
100808 pRt->flags = MEM_Blob|MEM_Dyn;
100809 pRt->z = (char*)pFrame;
100810 pRt->n = nByte;
100811 pRt->xDel = sqlite3VdbeFrameMemDel;
100812
100813 pFrame->v = p;
100814 pFrame->nChildMem = nMem;
100815 pFrame->nChildCsr = pProgram->nCsr;
@@ -100904,16 +101065,18 @@
100904 ** If P1 is non-zero, the database constraint counter is incremented
100905 ** (deferred foreign key constraints). Otherwise, if P1 is zero, the
100906 ** statement counter is incremented (immediate foreign key constraints).
100907 */
100908 case OP_FkCounter: {
100909 if( db->flags & SQLITE_DeferFKs ){
100910 db->nDeferredImmCons += pOp->p2;
100911 }else if( pOp->p1 ){
100912 db->nDeferredCons += pOp->p2;
100913 }else{
100914 p->nFkConstraint += pOp->p2;
 
 
 
 
100915 }
100916 break;
100917 }
100918
100919 /* Opcode: FkIfZero P1 P2 * * *
@@ -101784,10 +101947,11 @@
101784 nArg = (int)pArgc->u.i;
101785 iQuery = (int)pQuery->u.i;
101786
101787 /* Invoke the xFilter method */
101788 apArg = p->apArg;
 
101789 for(i = 0; i<nArg; i++){
101790 apArg[i] = &pArgc[i+1];
101791 }
101792 rc = pModule->xFilter(pVCur, iQuery, pOp->p4.z, nArg, apArg);
101793 sqlite3VtabImportErrmsg(p, pVtab);
@@ -101994,10 +102158,11 @@
101994 assert( pOp->p4type==P4_VTAB );
101995 if( ALWAYS(pModule->xUpdate) ){
101996 u8 vtabOnConflict = db->vtabOnConflict;
101997 apArg = p->apArg;
101998 pX = &aMem[pOp->p3];
 
101999 for(i=0; i<nArg; i++){
102000 assert( memIsValid(pX) );
102001 memAboutToChange(p, pX);
102002 apArg[i] = pX;
102003 pX++;
@@ -102839,16 +103004,12 @@
102839 }
102840 pBlob->pTab = pTab;
102841 pBlob->zDb = db->aDb[sqlite3SchemaToIndex(db, pTab->pSchema)].zDbSName;
102842
102843 /* Now search pTab for the exact column. */
102844 for(iCol=0; iCol<pTab->nCol; iCol++) {
102845 if( sqlite3StrICmp(pTab->aCol[iCol].zCnName, zColumn)==0 ){
102846 break;
102847 }
102848 }
102849 if( iCol==pTab->nCol ){
102850 sqlite3DbFree(db, zErr);
102851 zErr = sqlite3MPrintf(db, "no such column: \"%s\"", zColumn);
102852 rc = SQLITE_ERROR;
102853 sqlite3BtreeLeaveAll(db);
102854 goto blob_open_out;
@@ -104106,11 +104267,11 @@
104106 int pgsz; /* Page size of main database */
104107 int i; /* Used to iterate through aTask[] */
104108 VdbeSorter *pSorter; /* The new sorter */
104109 KeyInfo *pKeyInfo; /* Copy of pCsr->pKeyInfo with db==0 */
104110 int szKeyInfo; /* Size of pCsr->pKeyInfo in bytes */
104111 int sz; /* Size of pSorter in bytes */
104112 int rc = SQLITE_OK;
104113 #if SQLITE_MAX_WORKER_THREADS==0
104114 # define nWorker 0
104115 #else
104116 int nWorker;
@@ -104134,10 +104295,12 @@
104134 #endif
104135
104136 assert( pCsr->pKeyInfo );
104137 assert( !pCsr->isEphemeral );
104138 assert( pCsr->eCurType==CURTYPE_SORTER );
 
 
104139 szKeyInfo = sizeof(KeyInfo) + (pCsr->pKeyInfo->nKeyField-1)*sizeof(CollSeq*);
104140 sz = sizeof(VdbeSorter) + nWorker * sizeof(SortSubtask);
104141
104142 pSorter = (VdbeSorter*)sqlite3DbMallocZero(db, sz + szKeyInfo);
104143 pCsr->uc.pSorter = pSorter;
@@ -104347,11 +104510,11 @@
104347 ** nReader is automatically rounded up to the next power of two.
104348 ** nReader may not exceed SORTER_MAX_MERGE_COUNT even after rounding up.
104349 */
104350 static MergeEngine *vdbeMergeEngineNew(int nReader){
104351 int N = 2; /* Smallest power of two >= nReader */
104352 int nByte; /* Total bytes of space to allocate */
104353 MergeEngine *pNew; /* Pointer to allocated object to return */
104354
104355 assert( nReader<=SORTER_MAX_MERGE_COUNT );
104356
104357 while( N<nReader ) N += N;
@@ -107390,11 +107553,10 @@
107390 SrcItem *pMatch = 0; /* The matching pSrcList item */
107391 NameContext *pTopNC = pNC; /* First namecontext in the list */
107392 Schema *pSchema = 0; /* Schema of the expression */
107393 int eNewExprOp = TK_COLUMN; /* New value for pExpr->op on success */
107394 Table *pTab = 0; /* Table holding the row */
107395 Column *pCol; /* A column of pTab */
107396 ExprList *pFJMatch = 0; /* Matches for FULL JOIN .. USING */
107397 const char *zCol = pRight->u.zToken;
107398
107399 assert( pNC ); /* the name context cannot be NULL. */
107400 assert( zCol ); /* The Z in X.Y.Z cannot be NULL */
@@ -107441,11 +107603,10 @@
107441 ExprList *pEList;
107442 SrcList *pSrcList = pNC->pSrcList;
107443
107444 if( pSrcList ){
107445 for(i=0, pItem=pSrcList->a; i<pSrcList->nSrc; i++, pItem++){
107446 u8 hCol;
107447 pTab = pItem->pSTab;
107448 assert( pTab!=0 && pTab->zName!=0 );
107449 assert( pTab->nCol>0 || pParse->nErr );
107450 assert( (int)pItem->fg.isNestedFrom == IsNestedFrom(pItem));
107451 if( pItem->fg.isNestedFrom ){
@@ -107529,47 +107690,42 @@
107529 assert( ExprUseYTab(pExpr) );
107530 if( IN_RENAME_OBJECT && pItem->zAlias ){
107531 sqlite3RenameTokenRemap(pParse, 0, (void*)&pExpr->y.pTab);
107532 }
107533 }
107534 hCol = sqlite3StrIHash(zCol);
107535 for(j=0, pCol=pTab->aCol; j<pTab->nCol; j++, pCol++){
107536 if( pCol->hName==hCol
107537 && sqlite3StrICmp(pCol->zCnName, zCol)==0
107538 ){
107539 if( cnt>0 ){
107540 if( pItem->fg.isUsing==0
107541 || sqlite3IdListIndex(pItem->u3.pUsing, zCol)<0
107542 ){
107543 /* Two or more tables have the same column name which is
107544 ** not joined by USING. This is an error. Signal as much
107545 ** by clearing pFJMatch and letting cnt go above 1. */
107546 sqlite3ExprListDelete(db, pFJMatch);
107547 pFJMatch = 0;
107548 }else
107549 if( (pItem->fg.jointype & JT_RIGHT)==0 ){
107550 /* An INNER or LEFT JOIN. Use the left-most table */
107551 continue;
107552 }else
107553 if( (pItem->fg.jointype & JT_LEFT)==0 ){
107554 /* A RIGHT JOIN. Use the right-most table */
107555 cnt = 0;
107556 sqlite3ExprListDelete(db, pFJMatch);
107557 pFJMatch = 0;
107558 }else{
107559 /* For a FULL JOIN, we must construct a coalesce() func */
107560 extendFJMatch(pParse, &pFJMatch, pMatch, pExpr->iColumn);
107561 }
107562 }
107563 cnt++;
107564 pMatch = pItem;
107565 /* Substitute the rowid (column -1) for the INTEGER PRIMARY KEY */
107566 pExpr->iColumn = j==pTab->iPKey ? -1 : (i16)j;
107567 if( pItem->fg.isNestedFrom ){
107568 sqlite3SrcItemColumnUsed(pItem, j);
107569 }
107570 break;
107571 }
107572 }
107573 if( 0==cnt && VisibleRowid(pTab) ){
107574 /* pTab is a potential ROWID match. Keep track of it and match
107575 ** the ROWID later if that seems appropriate. (Search for "cntTab"
@@ -107655,26 +107811,21 @@
107655 }
107656 #endif /* SQLITE_OMIT_UPSERT */
107657
107658 if( pTab ){
107659 int iCol;
107660 u8 hCol = sqlite3StrIHash(zCol);
107661 pSchema = pTab->pSchema;
107662 cntTab++;
107663 for(iCol=0, pCol=pTab->aCol; iCol<pTab->nCol; iCol++, pCol++){
107664 if( pCol->hName==hCol
107665 && sqlite3StrICmp(pCol->zCnName, zCol)==0
107666 ){
107667 if( iCol==pTab->iPKey ){
107668 iCol = -1;
107669 }
107670 break;
107671 }
107672 }
107673 if( iCol>=pTab->nCol && sqlite3IsRowid(zCol) && VisibleRowid(pTab) ){
107674 /* IMP: R-51414-32910 */
107675 iCol = -1;
107676 }
107677 if( iCol<pTab->nCol ){
107678 cnt++;
107679 pMatch = 0;
107680 #ifndef SQLITE_OMIT_UPSERT
@@ -109896,11 +110047,11 @@
109896 p4 = sqlite3BinaryCompareCollSeq(pParse, pLeft, pRight);
109897 }
109898 p5 = binaryCompareP5(pLeft, pRight, jumpIfNull);
109899 addr = sqlite3VdbeAddOp4(pParse->pVdbe, opcode, in2, dest, in1,
109900 (void*)p4, P4_COLLSEQ);
109901 sqlite3VdbeChangeP5(pParse->pVdbe, (u8)p5);
109902 return addr;
109903 }
109904
109905 /*
109906 ** Return true if expression pExpr is a vector, or false otherwise.
@@ -111266,11 +111417,10 @@
111266 pNewExpr->pLeft = pPriorSelectColNew;
111267 }
111268 }
111269 pItem->zEName = sqlite3DbStrDup(db, pOldItem->zEName);
111270 pItem->fg = pOldItem->fg;
111271 pItem->fg.done = 0;
111272 pItem->u = pOldItem->u;
111273 }
111274 return pNew;
111275 }
111276
@@ -111349,20 +111499,17 @@
111349 SQLITE_PRIVATE IdList *sqlite3IdListDup(sqlite3 *db, const IdList *p){
111350 IdList *pNew;
111351 int i;
111352 assert( db!=0 );
111353 if( p==0 ) return 0;
111354 assert( p->eU4!=EU4_EXPR );
111355 pNew = sqlite3DbMallocRawNN(db, sizeof(*pNew)+(p->nId-1)*sizeof(p->a[0]) );
111356 if( pNew==0 ) return 0;
111357 pNew->nId = p->nId;
111358 pNew->eU4 = p->eU4;
111359 for(i=0; i<p->nId; i++){
111360 struct IdList_item *pNewItem = &pNew->a[i];
111361 const struct IdList_item *pOldItem = &p->a[i];
111362 pNewItem->zName = sqlite3DbStrDup(db, pOldItem->zName);
111363 pNewItem->u4 = pOldItem->u4;
111364 }
111365 return pNew;
111366 }
111367 SQLITE_PRIVATE Select *sqlite3SelectDup(sqlite3 *db, const Select *pDup, int flags){
111368 Select *pRet = 0;
@@ -112386,17 +112533,11 @@
112386 SQLITE_PRIVATE const char *sqlite3RowidAlias(Table *pTab){
112387 const char *azOpt[] = {"_ROWID_", "ROWID", "OID"};
112388 int ii;
112389 assert( VisibleRowid(pTab) );
112390 for(ii=0; ii<ArraySize(azOpt); ii++){
112391 int iCol;
112392 for(iCol=0; iCol<pTab->nCol; iCol++){
112393 if( sqlite3_stricmp(azOpt[ii], pTab->aCol[iCol].zCnName)==0 ) break;
112394 }
112395 if( iCol==pTab->nCol ){
112396 return azOpt[ii];
112397 }
112398 }
112399 return 0;
112400 }
112401
112402 /*
@@ -112702,10 +112843,11 @@
112702 if( mCol & colUsed ) break; /* Each column used only once */
112703 colUsed |= mCol;
112704 if( aiMap ) aiMap[i] = j;
112705 }
112706
 
112707 assert( i==nExpr || colUsed!=(MASKBIT(nExpr)-1) );
112708 if( colUsed==(MASKBIT(nExpr)-1) ){
112709 /* If we reach this point, that means the index pIdx is usable */
112710 int iAddr = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v);
112711 ExplainQueryPlan((pParse, 0,
@@ -112795,11 +112937,11 @@
112795 int nVal = sqlite3ExprVectorSize(pLeft);
112796 Select *pSelect = ExprUseXSelect(pExpr) ? pExpr->x.pSelect : 0;
112797 char *zRet;
112798
112799 assert( pExpr->op==TK_IN );
112800 zRet = sqlite3DbMallocRaw(pParse->db, nVal+1);
112801 if( zRet ){
112802 int i;
112803 for(i=0; i<nVal; i++){
112804 Expr *pA = sqlite3VectorFieldSubexpr(pLeft, i);
112805 char a = sqlite3ExprAffinity(pA);
@@ -112881,10 +113023,11 @@
112881 for(; pOp<pEnd; pOp++){
112882 if( pOp->p4type!=P4_SUBRTNSIG ) continue;
112883 assert( pOp->opcode==OP_BeginSubrtn );
112884 pSig = pOp->p4.pSubrtnSig;
112885 assert( pSig!=0 );
 
112886 if( pNewSig->selId!=pSig->selId ) continue;
112887 if( strcmp(pNewSig->zAff,pSig->zAff)!=0 ) continue;
112888 pExpr->y.sub.iAddr = pSig->iAddr;
112889 pExpr->y.sub.regReturn = pSig->regReturn;
112890 pExpr->iTable = pSig->iTable;
@@ -112927,10 +113070,11 @@
112927 int addr; /* Address of OP_OpenEphemeral instruction */
112928 Expr *pLeft; /* the LHS of the IN operator */
112929 KeyInfo *pKeyInfo = 0; /* Key information */
112930 int nVal; /* Size of vector pLeft */
112931 Vdbe *v; /* The prepared statement under construction */
 
112932
112933 v = pParse->pVdbe;
112934 assert( v!=0 );
112935
112936 /* The evaluation of the IN must be repeated every time it
@@ -112947,11 +113091,10 @@
112947 /* Reuse of the RHS is allowed
112948 **
112949 ** Compute a signature for the RHS of the IN operator to facility
112950 ** finding and reusing prior instances of the same IN operator.
112951 */
112952 SubrtnSig *pSig = 0;
112953 assert( !ExprUseXSelect(pExpr) || pExpr->x.pSelect!=0 );
112954 if( ExprUseXSelect(pExpr) && (pExpr->x.pSelect->selFlags & SF_All)==0 ){
112955 pSig = sqlite3DbMallocRawNN(pParse->db, sizeof(pSig[0]));
112956 if( pSig ){
112957 pSig->selId = pExpr->x.pSelect->selId;
@@ -112990,10 +113133,11 @@
112990 assert( !ExprHasProperty(pExpr, EP_TokenOnly|EP_Reduced) );
112991 pExpr->y.sub.regReturn = ++pParse->nMem;
112992 pExpr->y.sub.iAddr =
112993 sqlite3VdbeAddOp2(v, OP_BeginSubrtn, 0, pExpr->y.sub.regReturn) + 1;
112994 if( pSig ){
 
112995 pSig->iAddr = pExpr->y.sub.iAddr;
112996 pSig->regReturn = pExpr->y.sub.regReturn;
112997 pSig->iTable = iTab;
112998 pParse->mSubrtnSig = 1 << (pSig->selId&7);
112999 sqlite3VdbeChangeP4(v, -1, (const char*)pSig, P4_SUBRTNSIG);
@@ -113125,10 +113269,11 @@
113125 sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iTab, r2, r1, 1);
113126 }
113127 sqlite3ReleaseTempReg(pParse, r1);
113128 sqlite3ReleaseTempReg(pParse, r2);
113129 }
 
113130 if( pKeyInfo ){
113131 sqlite3VdbeChangeP4(v, addr, (void *)pKeyInfo, P4_KEYINFO);
113132 }
113133 if( addrOnce ){
113134 sqlite3VdbeAddOp1(v, OP_NullRow, iTab);
@@ -117437,14 +117582,12 @@
117437
117438 /* Make sure the old name really is a column name in the table to be
117439 ** altered. Set iCol to be the index of the column being renamed */
117440 zOld = sqlite3NameFromToken(db, pOld);
117441 if( !zOld ) goto exit_rename_column;
117442 for(iCol=0; iCol<pTab->nCol; iCol++){
117443 if( 0==sqlite3StrICmp(pTab->aCol[iCol].zCnName, zOld) ) break;
117444 }
117445 if( iCol==pTab->nCol ){
117446 sqlite3ErrorMsg(pParse, "no such column: \"%T\"", pOld);
117447 goto exit_rename_column;
117448 }
117449
117450 /* Ensure the schema contains no double-quoted strings */
@@ -119339,11 +119482,12 @@
119339 ** of the new table in register pParse->regRoot. This is important
119340 ** because the OpenWrite opcode below will be needing it. */
119341 sqlite3NestedParse(pParse,
119342 "CREATE TABLE %Q.%s(%s)", pDb->zDbSName, zTab, aTable[i].zCols
119343 );
119344 aRoot[i] = (u32)pParse->regRoot;
 
119345 aCreateTbl[i] = OPFLAG_P2ISREG;
119346 }
119347 }else{
119348 /* The table already exists. If zWhere is not NULL, delete all entries
119349 ** associated with the table zWhere. If zWhere is NULL, delete the
@@ -119530,11 +119674,11 @@
119530 ){
119531 StatAccum *p;
119532 int nCol; /* Number of columns in index being sampled */
119533 int nKeyCol; /* Number of key columns */
119534 int nColUp; /* nCol rounded up for alignment */
119535 int n; /* Bytes of space to allocate */
119536 sqlite3 *db = sqlite3_context_db_handle(context); /* Database connection */
119537 #ifdef SQLITE_ENABLE_STAT4
119538 /* Maximum number of samples. 0 if STAT4 data is not collected */
119539 int mxSample = OptimizationEnabled(db,SQLITE_Stat4) ?SQLITE_STAT4_SAMPLES :0;
119540 #endif
@@ -121304,11 +121448,11 @@
121304 if( db->aDb==db->aDbStatic ){
121305 aNew = sqlite3DbMallocRawNN(db, sizeof(db->aDb[0])*3 );
121306 if( aNew==0 ) return;
121307 memcpy(aNew, db->aDb, sizeof(db->aDb[0])*2);
121308 }else{
121309 aNew = sqlite3DbRealloc(db, db->aDb, sizeof(db->aDb[0])*(db->nDb+1) );
121310 if( aNew==0 ) return;
121311 }
121312 db->aDb = aNew;
121313 pNew = &db->aDb[db->nDb];
121314 memset(pNew, 0, sizeof(*pNew));
@@ -121322,10 +121466,16 @@
121322 if( rc!=SQLITE_OK ){
121323 if( rc==SQLITE_NOMEM ) sqlite3OomFault(db);
121324 sqlite3_result_error(context, zErr, -1);
121325 sqlite3_free(zErr);
121326 return;
 
 
 
 
 
 
121327 }
121328 assert( pVfs );
121329 flags |= SQLITE_OPEN_MAIN_DB;
121330 rc = sqlite3BtreeOpen(pVfs, zPath, db, &pNew->pBt, 0, flags);
121331 db->nDb++;
@@ -122091,10 +122241,11 @@
122091 p->isWriteLock = (p->isWriteLock || isWriteLock);
122092 return;
122093 }
122094 }
122095
 
122096 nBytes = sizeof(TableLock) * (pToplevel->nTableLock+1);
122097 pToplevel->aTableLock =
122098 sqlite3DbReallocOrFree(pToplevel->db, pToplevel->aTableLock, nBytes);
122099 if( pToplevel->aTableLock ){
122100 p = &pToplevel->aTableLock[pToplevel->nTableLock++];
@@ -122191,14 +122342,16 @@
122191 }
122192 assert( !pParse->isMultiWrite
122193 || sqlite3VdbeAssertMayAbort(v, pParse->mayAbort));
122194 if( v ){
122195 if( pParse->bReturning ){
122196 Returning *pReturning = pParse->u1.pReturning;
122197 int addrRewind;
122198 int reg;
122199
 
 
122200 if( pReturning->nRetCol ){
122201 sqlite3VdbeAddOp0(v, OP_FkCheck);
122202 addrRewind =
122203 sqlite3VdbeAddOp1(v, OP_Rewind, pReturning->iRetCur);
122204 VdbeCoverage(v);
@@ -122270,11 +122423,13 @@
122270 sqlite3ExprCode(pParse, pEL->a[i].pExpr, pEL->a[i].u.iConstExprReg);
122271 }
122272 }
122273
122274 if( pParse->bReturning ){
122275 Returning *pRet = pParse->u1.pReturning;
 
 
122276 if( pRet->nRetCol ){
122277 sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pRet->iRetCur, pRet->nRetCol);
122278 }
122279 }
122280
@@ -123342,12 +123497,13 @@
123342 #endif
123343
123344 /* If the file format and encoding in the database have not been set,
123345 ** set them now.
123346 */
123347 reg1 = pParse->regRowid = ++pParse->nMem;
123348 reg2 = pParse->regRoot = ++pParse->nMem;
 
123349 reg3 = ++pParse->nMem;
123350 sqlite3VdbeAddOp3(v, OP_ReadCookie, iDb, reg3, BTREE_FILE_FORMAT);
123351 sqlite3VdbeUsesBtree(v, iDb);
123352 addr1 = sqlite3VdbeAddOp1(v, OP_If, reg3); VdbeCoverage(v);
123353 fileFormat = (db->flags & SQLITE_LegacyFileFmt)!=0 ?
@@ -123358,12 +123514,12 @@
123358
123359 /* This just creates a place-holder record in the sqlite_schema table.
123360 ** The record created does not contain anything yet. It will be replaced
123361 ** by the real entry in code generated at sqlite3EndTable().
123362 **
123363 ** The rowid for the new entry is left in register pParse->regRowid.
123364 ** The root page number of the new table is left in reg pParse->regRoot.
123365 ** The rowid and root page number values are needed by the code that
123366 ** sqlite3EndTable will generate.
123367 */
123368 #if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_VIRTUALTABLE)
123369 if( isView || isVirtual ){
@@ -123370,11 +123526,11 @@
123370 sqlite3VdbeAddOp2(v, OP_Integer, 0, reg2);
123371 }else
123372 #endif
123373 {
123374 assert( !pParse->bReturning );
123375 pParse->u1.addrCrTab =
123376 sqlite3VdbeAddOp3(v, OP_CreateBtree, iDb, reg2, BTREE_INTKEY);
123377 }
123378 sqlite3OpenSchemaTable(pParse, iDb);
123379 sqlite3VdbeAddOp2(v, OP_NewRowid, 0, reg1);
123380 sqlite3VdbeAddOp4(v, OP_Blob, 6, reg3, 0, nullRow, P4_STATIC);
@@ -123448,11 +123604,12 @@
123448 pRet = sqlite3DbMallocZero(db, sizeof(*pRet));
123449 if( pRet==0 ){
123450 sqlite3ExprListDelete(db, pList);
123451 return;
123452 }
123453 pParse->u1.pReturning = pRet;
 
123454 pRet->pParse = pParse;
123455 pRet->pReturnEL = pList;
123456 sqlite3ParserAddCleanup(pParse, sqlite3DeleteReturning, pRet);
123457 testcase( pParse->earlyCleanup );
123458 if( db->mallocFailed ) return;
@@ -123490,11 +123647,10 @@
123490 int i;
123491 char *z;
123492 char *zType;
123493 Column *pCol;
123494 sqlite3 *db = pParse->db;
123495 u8 hName;
123496 Column *aNew;
123497 u8 eType = COLTYPE_CUSTOM;
123498 u8 szEst = 1;
123499 char affinity = SQLITE_AFF_BLOB;
123500
@@ -123544,17 +123700,14 @@
123544 if( z==0 ) return;
123545 if( IN_RENAME_OBJECT ) sqlite3RenameTokenMap(pParse, (void*)z, &sName);
123546 memcpy(z, sName.z, sName.n);
123547 z[sName.n] = 0;
123548 sqlite3Dequote(z);
123549 hName = sqlite3StrIHash(z);
123550 for(i=0; i<p->nCol; i++){
123551 if( p->aCol[i].hName==hName && sqlite3StrICmp(z, p->aCol[i].zCnName)==0 ){
123552 sqlite3ErrorMsg(pParse, "duplicate column name: %s", z);
123553 sqlite3DbFree(db, z);
123554 return;
123555 }
123556 }
123557 aNew = sqlite3DbRealloc(db,p->aCol,((i64)p->nCol+1)*sizeof(p->aCol[0]));
123558 if( aNew==0 ){
123559 sqlite3DbFree(db, z);
123560 return;
@@ -123561,11 +123714,11 @@
123561 }
123562 p->aCol = aNew;
123563 pCol = &p->aCol[p->nCol];
123564 memset(pCol, 0, sizeof(p->aCol[0]));
123565 pCol->zCnName = z;
123566 pCol->hName = hName;
123567 sqlite3ColumnPropertiesFromName(p, pCol);
123568
123569 if( sType.n==0 ){
123570 /* If there is no type specified, columns have the default affinity
123571 ** 'BLOB' with a default size of 4 bytes. */
@@ -123585,13 +123738,18 @@
123585 zType[sType.n] = 0;
123586 sqlite3Dequote(zType);
123587 pCol->affinity = sqlite3AffinityType(zType, pCol);
123588 pCol->colFlags |= COLFLAG_HASTYPE;
123589 }
 
 
 
 
123590 p->nCol++;
123591 p->nNVCol++;
123592 pParse->constraintName.n = 0;
 
123593 }
123594
123595 /*
123596 ** This routine is called by the parser while in the middle of
123597 ** parsing a CREATE TABLE statement. A "NOT NULL" constraint has
@@ -123851,19 +124009,15 @@
123851 for(i=0; i<nTerm; i++){
123852 Expr *pCExpr = sqlite3ExprSkipCollate(pList->a[i].pExpr);
123853 assert( pCExpr!=0 );
123854 sqlite3StringToId(pCExpr);
123855 if( pCExpr->op==TK_ID ){
123856 const char *zCName;
123857 assert( !ExprHasProperty(pCExpr, EP_IntValue) );
123858 zCName = pCExpr->u.zToken;
123859 for(iCol=0; iCol<pTab->nCol; iCol++){
123860 if( sqlite3StrICmp(zCName, pTab->aCol[iCol].zCnName)==0 ){
123861 pCol = &pTab->aCol[iCol];
123862 makeColumnPartOfPrimaryKey(pParse, pCol);
123863 break;
123864 }
123865 }
123866 }
123867 }
123868 }
123869 if( nTerm==1
@@ -123911,12 +124065,14 @@
123911 sqlite3 *db = pParse->db;
123912 if( pTab && !IN_DECLARE_VTAB
123913 && !sqlite3BtreeIsReadonly(db->aDb[db->init.iDb].pBt)
123914 ){
123915 pTab->pCheck = sqlite3ExprListAppend(pParse, pTab->pCheck, pCheckExpr);
123916 if( pParse->constraintName.n ){
123917 sqlite3ExprListSetName(pParse, pTab->pCheck, &pParse->constraintName, 1);
 
 
123918 }else{
123919 Token t;
123920 for(zStart++; sqlite3Isspace(zStart[0]); zStart++){}
123921 while( sqlite3Isspace(zEnd[-1]) ){ zEnd--; }
123922 t.z = zStart;
@@ -124107,11 +124263,12 @@
124107 ** Generate a CREATE TABLE statement appropriate for the given
124108 ** table. Memory to hold the text of the statement is obtained
124109 ** from sqliteMalloc() and must be freed by the calling function.
124110 */
124111 static char *createTableStmt(sqlite3 *db, Table *p){
124112 int i, k, n;
 
124113 char *zStmt;
124114 char *zSep, *zSep2, *zEnd;
124115 Column *pCol;
124116 n = 0;
124117 for(pCol = p->aCol, i=0; i<p->nCol; i++, pCol++){
@@ -124131,12 +124288,13 @@
124131 zStmt = sqlite3DbMallocRaw(0, n);
124132 if( zStmt==0 ){
124133 sqlite3OomFault(db);
124134 return 0;
124135 }
124136 sqlite3_snprintf(n, zStmt, "CREATE TABLE ");
124137 k = sqlite3Strlen30(zStmt);
 
124138 identPut(zStmt, &k, p->zName);
124139 zStmt[k++] = '(';
124140 for(pCol=p->aCol, i=0; i<p->nCol; i++, pCol++){
124141 static const char * const azType[] = {
124142 /* SQLITE_AFF_BLOB */ "",
@@ -124144,17 +124302,19 @@
124144 /* SQLITE_AFF_NUMERIC */ " NUM",
124145 /* SQLITE_AFF_INTEGER */ " INT",
124146 /* SQLITE_AFF_REAL */ " REAL",
124147 /* SQLITE_AFF_FLEXNUM */ " NUM",
124148 };
124149 int len;
124150 const char *zType;
124151
124152 sqlite3_snprintf(n-k, &zStmt[k], zSep);
124153 k += sqlite3Strlen30(&zStmt[k]);
 
 
124154 zSep = zSep2;
124155 identPut(zStmt, &k, pCol->zCnName);
 
124156 assert( pCol->affinity-SQLITE_AFF_BLOB >= 0 );
124157 assert( pCol->affinity-SQLITE_AFF_BLOB < ArraySize(azType) );
124158 testcase( pCol->affinity==SQLITE_AFF_BLOB );
124159 testcase( pCol->affinity==SQLITE_AFF_TEXT );
124160 testcase( pCol->affinity==SQLITE_AFF_NUMERIC );
@@ -124165,15 +124325,18 @@
124165 zType = azType[pCol->affinity - SQLITE_AFF_BLOB];
124166 len = sqlite3Strlen30(zType);
124167 assert( pCol->affinity==SQLITE_AFF_BLOB
124168 || pCol->affinity==SQLITE_AFF_FLEXNUM
124169 || pCol->affinity==sqlite3AffinityType(zType, 0) );
 
124170 memcpy(&zStmt[k], zType, len);
124171 k += len;
124172 assert( k<=n );
124173 }
124174 sqlite3_snprintf(n-k, &zStmt[k], "%s", zEnd);
 
 
124175 return zStmt;
124176 }
124177
124178 /*
124179 ** Resize an Index object to hold N columns total. Return SQLITE_OK
@@ -124362,13 +124525,13 @@
124362
124363 /* Convert the P3 operand of the OP_CreateBtree opcode from BTREE_INTKEY
124364 ** into BTREE_BLOBKEY.
124365 */
124366 assert( !pParse->bReturning );
124367 if( pParse->u1.addrCrTab ){
124368 assert( v );
124369 sqlite3VdbeChangeP3(v, pParse->u1.addrCrTab, BTREE_BLOBKEY);
124370 }
124371
124372 /* Locate the PRIMARY KEY index. Or, if this table was originally
124373 ** an INTEGER PRIMARY KEY table, create a new PRIMARY KEY index.
124374 */
@@ -124804,11 +124967,11 @@
124804 #endif
124805 }
124806
124807 /* If this is a CREATE TABLE xx AS SELECT ..., execute the SELECT
124808 ** statement to populate the new table. The root-page number for the
124809 ** new table is in register pParse->regRoot.
124810 **
124811 ** Once the SELECT has been coded by sqlite3Select(), it is in a
124812 ** suitable state to query for the column names and types to be used
124813 ** by the new table.
124814 **
@@ -124835,11 +124998,12 @@
124835 iCsr = pParse->nTab++;
124836 regYield = ++pParse->nMem;
124837 regRec = ++pParse->nMem;
124838 regRowid = ++pParse->nMem;
124839 sqlite3MayAbort(pParse);
124840 sqlite3VdbeAddOp3(v, OP_OpenWrite, iCsr, pParse->regRoot, iDb);
 
124841 sqlite3VdbeChangeP5(v, OPFLAG_P2ISREG);
124842 addrTop = sqlite3VdbeCurrentAddr(v) + 1;
124843 sqlite3VdbeAddOp3(v, OP_InitCoroutine, regYield, 0, addrTop);
124844 if( pParse->nErr ) return;
124845 pSelTab = sqlite3ResultSetOfSelect(pParse, pSelect, SQLITE_AFF_BLOB);
@@ -124880,21 +125044,22 @@
124880
124881 /* A slot for the record has already been allocated in the
124882 ** schema table. We just need to update that slot with all
124883 ** the information we've collected.
124884 */
 
124885 sqlite3NestedParse(pParse,
124886 "UPDATE %Q." LEGACY_SCHEMA_TABLE
124887 " SET type='%s', name=%Q, tbl_name=%Q, rootpage=#%d, sql=%Q"
124888 " WHERE rowid=#%d",
124889 db->aDb[iDb].zDbSName,
124890 zType,
124891 p->zName,
124892 p->zName,
124893 pParse->regRoot,
124894 zStmt,
124895 pParse->regRowid
124896 );
124897 sqlite3DbFree(db, zStmt);
124898 sqlite3ChangeCookie(pParse, iDb);
124899
124900 #ifndef SQLITE_OMIT_AUTOINCREMENT
@@ -125861,11 +126026,11 @@
125861 i16 nCol, /* Total number of columns in the index */
125862 int nExtra, /* Number of bytes of extra space to alloc */
125863 char **ppExtra /* Pointer to the "extra" space */
125864 ){
125865 Index *p; /* Allocated index object */
125866 int nByte; /* Bytes of space for Index object + arrays */
125867
125868 nByte = ROUND8(sizeof(Index)) + /* Index structure */
125869 ROUND8(sizeof(char*)*nCol) + /* Index.azColl */
125870 ROUND8(sizeof(LogEst)*(nCol+1) + /* Index.aiRowLogEst */
125871 sizeof(i16)*nCol + /* Index.aiColumn */
@@ -126714,11 +126879,10 @@
126714 */
126715 SQLITE_PRIVATE void sqlite3IdListDelete(sqlite3 *db, IdList *pList){
126716 int i;
126717 assert( db!=0 );
126718 if( pList==0 ) return;
126719 assert( pList->eU4!=EU4_EXPR ); /* EU4_EXPR mode is not currently used */
126720 for(i=0; i<pList->nId; i++){
126721 sqlite3DbFree(db, pList->a[i].zName);
126722 }
126723 sqlite3DbNNFreeNN(db, pList);
126724 }
@@ -128095,16 +128259,22 @@
128095 FuncDef *p, /* The function we are evaluating for match quality */
128096 int nArg, /* Desired number of arguments. (-1)==any */
128097 u8 enc /* Desired text encoding */
128098 ){
128099 int match;
128100 assert( p->nArg>=-1 );
 
128101
128102 /* Wrong number of arguments means "no match" */
128103 if( p->nArg!=nArg ){
128104 if( nArg==(-2) ) return (p->xSFunc==0) ? 0 : FUNC_PERFECT_MATCH;
128105 if( p->nArg>=0 ) return 0;
 
 
 
 
 
128106 }
128107
128108 /* Give a better score to a function with a specific number of arguments
128109 ** than to function that accepts any number of arguments. */
128110 if( p->nArg==nArg ){
@@ -129723,20 +129893,14 @@
129723 const unsigned char *z;
129724 const unsigned char *z2;
129725 int len;
129726 int p0type;
129727 i64 p1, p2;
129728 int negP2 = 0;
129729
129730 assert( argc==3 || argc==2 );
129731 if( sqlite3_value_type(argv[1])==SQLITE_NULL
129732 || (argc==3 && sqlite3_value_type(argv[2])==SQLITE_NULL)
129733 ){
129734 return;
129735 }
129736 p0type = sqlite3_value_type(argv[0]);
129737 p1 = sqlite3_value_int(argv[1]);
129738 if( p0type==SQLITE_BLOB ){
129739 len = sqlite3_value_bytes(argv[0]);
129740 z = sqlite3_value_blob(argv[0]);
129741 if( z==0 ) return;
129742 assert( len==sqlite3_value_bytes(argv[0]) );
@@ -129748,45 +129912,49 @@
129748 for(z2=z; *z2; len++){
129749 SQLITE_SKIP_UTF8(z2);
129750 }
129751 }
129752 }
129753 #ifdef SQLITE_SUBSTR_COMPATIBILITY
129754 /* If SUBSTR_COMPATIBILITY is defined then substr(X,0,N) work the same as
129755 ** as substr(X,1,N) - it returns the first N characters of X. This
129756 ** is essentially a back-out of the bug-fix in check-in [5fc125d362df4b8]
129757 ** from 2009-02-02 for compatibility of applications that exploited the
129758 ** old buggy behavior. */
129759 if( p1==0 ) p1 = 1; /* <rdar://problem/6778339> */
129760 #endif
129761 if( argc==3 ){
129762 p2 = sqlite3_value_int(argv[2]);
129763 if( p2<0 ){
129764 p2 = -p2;
129765 negP2 = 1;
129766 }
129767 }else{
129768 p2 = sqlite3_context_db_handle(context)->aLimit[SQLITE_LIMIT_LENGTH];
129769 }
 
 
 
 
 
 
 
 
 
 
 
129770 if( p1<0 ){
129771 p1 += len;
129772 if( p1<0 ){
129773 p2 += p1;
129774 if( p2<0 ) p2 = 0;
 
 
 
129775 p1 = 0;
129776 }
129777 }else if( p1>0 ){
129778 p1--;
129779 }else if( p2>0 ){
129780 p2--;
129781 }
129782 if( negP2 ){
 
 
 
 
 
129783 p1 -= p2;
129784 if( p1<0 ){
129785 p2 += p1;
129786 p1 = 0;
129787 }
129788 }
129789 assert( p1>=0 && p2>=0 );
129790 if( p0type!=SQLITE_BLOB ){
129791 while( *z && p1 ){
129792 SQLITE_SKIP_UTF8(z);
@@ -129796,13 +129964,15 @@
129796 SQLITE_SKIP_UTF8(z2);
129797 }
129798 sqlite3_result_text64(context, (char*)z, z2-z, SQLITE_TRANSIENT,
129799 SQLITE_UTF8);
129800 }else{
129801 if( p1+p2>len ){
 
 
129802 p2 = len-p1;
129803 if( p2<0 ) p2 = 0;
129804 }
129805 sqlite3_result_blob64(context, (char*)&z[p1], (u64)p2, SQLITE_TRANSIENT);
129806 }
129807 }
129808
@@ -129809,17 +129979,17 @@
129809 /*
129810 ** Implementation of the round() function
129811 */
129812 #ifndef SQLITE_OMIT_FLOATING_POINT
129813 static void roundFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
129814 int n = 0;
129815 double r;
129816 char *zBuf;
129817 assert( argc==1 || argc==2 );
129818 if( argc==2 ){
129819 if( SQLITE_NULL==sqlite3_value_type(argv[1]) ) return;
129820 n = sqlite3_value_int(argv[1]);
129821 if( n>30 ) n = 30;
129822 if( n<0 ) n = 0;
129823 }
129824 if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return;
129825 r = sqlite3_value_double(argv[0]);
@@ -129830,11 +130000,11 @@
129830 if( r<-4503599627370496.0 || r>+4503599627370496.0 ){
129831 /* The value has no fractional part so there is nothing to round */
129832 }else if( n==0 ){
129833 r = (double)((sqlite_int64)(r+(r<0?-0.5:+0.5)));
129834 }else{
129835 zBuf = sqlite3_mprintf("%!.*f",n,r);
129836 if( zBuf==0 ){
129837 sqlite3_result_error_nomem(context);
129838 return;
129839 }
129840 sqlite3AtoF(zBuf, &r, sqlite3Strlen30(zBuf), SQLITE_UTF8);
@@ -130789,11 +130959,11 @@
130789 if( zRep==0 ) return;
130790 nRep = sqlite3_value_bytes(argv[2]);
130791 assert( zRep==sqlite3_value_text(argv[2]) );
130792 nOut = nStr + 1;
130793 assert( nOut<SQLITE_MAX_LENGTH );
130794 zOut = contextMalloc(context, (i64)nOut);
130795 if( zOut==0 ){
130796 return;
130797 }
130798 loopLimit = nStr - nPattern;
130799 cntExpand = 0;
@@ -130939,11 +131109,11 @@
130939 int i;
130940 char *z;
130941 for(i=0; i<argc; i++){
130942 n += sqlite3_value_bytes(argv[i]);
130943 }
130944 n += (argc-1)*nSep;
130945 z = sqlite3_malloc64(n+1);
130946 if( z==0 ){
130947 sqlite3_result_error_nomem(context);
130948 return;
130949 }
@@ -131237,11 +131407,14 @@
131237 ** to initialize it */
131238 if( ALWAYS(p) && type!=SQLITE_NULL ){
131239 assert( p->cnt>0 );
131240 p->cnt--;
131241 if( !p->approx ){
131242 p->iSum -= sqlite3_value_int64(argv[0]);
 
 
 
131243 }else if( type==SQLITE_INTEGER ){
131244 i64 iVal = sqlite3_value_int64(argv[0]);
131245 if( iVal!=SMALLEST_INT64 ){
131246 kahanBabuskaNeumaierStepInt64(p, -iVal);
131247 }else{
@@ -132063,16 +132236,14 @@
132063 FUNCTION(ltrim, 2, 1, 0, trimFunc ),
132064 FUNCTION(rtrim, 1, 2, 0, trimFunc ),
132065 FUNCTION(rtrim, 2, 2, 0, trimFunc ),
132066 FUNCTION(trim, 1, 3, 0, trimFunc ),
132067 FUNCTION(trim, 2, 3, 0, trimFunc ),
132068 FUNCTION(min, -1, 0, 1, minmaxFunc ),
132069 FUNCTION(min, 0, 0, 1, 0 ),
132070 WAGGREGATE(min, 1, 0, 1, minmaxStep, minMaxFinalize, minMaxValue, 0,
132071 SQLITE_FUNC_MINMAX|SQLITE_FUNC_ANYORDER ),
132072 FUNCTION(max, -1, 1, 1, minmaxFunc ),
132073 FUNCTION(max, 0, 1, 1, 0 ),
132074 WAGGREGATE(max, 1, 1, 1, minmaxStep, minMaxFinalize, minMaxValue, 0,
132075 SQLITE_FUNC_MINMAX|SQLITE_FUNC_ANYORDER ),
132076 FUNCTION2(typeof, 1, 0, 0, typeofFunc, SQLITE_FUNC_TYPEOF),
132077 FUNCTION2(subtype, 1, 0, 0, subtypeFunc,
132078 SQLITE_FUNC_TYPEOF|SQLITE_SUBTYPE),
@@ -132095,15 +132266,12 @@
132095 FUNCTION(upper, 1, 0, 0, upperFunc ),
132096 FUNCTION(lower, 1, 0, 0, lowerFunc ),
132097 FUNCTION(hex, 1, 0, 0, hexFunc ),
132098 FUNCTION(unhex, 1, 0, 0, unhexFunc ),
132099 FUNCTION(unhex, 2, 0, 0, unhexFunc ),
132100 FUNCTION(concat, -1, 0, 0, concatFunc ),
132101 FUNCTION(concat, 0, 0, 0, 0 ),
132102 FUNCTION(concat_ws, -1, 0, 0, concatwsFunc ),
132103 FUNCTION(concat_ws, 0, 0, 0, 0 ),
132104 FUNCTION(concat_ws, 1, 0, 0, 0 ),
132105 INLINE_FUNC(ifnull, 2, INLINEFUNC_coalesce, 0 ),
132106 VFUNCTION(random, 0, 0, 0, randomFunc ),
132107 VFUNCTION(randomblob, 1, 0, 0, randomBlob ),
132108 FUNCTION(nullif, 2, 0, 1, nullifFunc ),
132109 DFUNCTION(sqlite_version, 0, 0, 0, versionFunc ),
@@ -132143,12 +132311,10 @@
132143 LIKEFUNC(like, 3, &likeInfoNorm, SQLITE_FUNC_LIKE),
132144 #endif
132145 #ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION
132146 FUNCTION(unknown, -1, 0, 0, unknownFunc ),
132147 #endif
132148 FUNCTION(coalesce, 1, 0, 0, 0 ),
132149 FUNCTION(coalesce, 0, 0, 0, 0 ),
132150 #ifdef SQLITE_ENABLE_MATH_FUNCTIONS
132151 MFUNCTION(ceil, 1, xCeil, ceilingFunc ),
132152 MFUNCTION(ceiling, 1, xCeil, ceilingFunc ),
132153 MFUNCTION(floor, 1, xFloor, ceilingFunc ),
132154 #if SQLITE_HAVE_C99_MATH_FUNCS
@@ -132182,15 +132348,13 @@
132182 MFUNCTION(radians, 1, degToRad, math1Func ),
132183 MFUNCTION(degrees, 1, radToDeg, math1Func ),
132184 MFUNCTION(pi, 0, 0, piFunc ),
132185 #endif /* SQLITE_ENABLE_MATH_FUNCTIONS */
132186 FUNCTION(sign, 1, 0, 0, signFunc ),
132187 INLINE_FUNC(coalesce, -1, INLINEFUNC_coalesce, 0 ),
132188 INLINE_FUNC(iif, 2, INLINEFUNC_iif, 0 ),
132189 INLINE_FUNC(iif, 3, INLINEFUNC_iif, 0 ),
132190 INLINE_FUNC(if, 2, INLINEFUNC_iif, 0 ),
132191 INLINE_FUNC(if, 3, INLINEFUNC_iif, 0 ),
132192 };
132193 #ifndef SQLITE_OMIT_ALTERTABLE
132194 sqlite3AlterFunctions();
132195 #endif
132196 sqlite3WindowFunctions();
@@ -134632,10 +134796,11 @@
134632 int regRowCount = 0; /* Memory cell used for the row counter */
134633 int regIns; /* Block of regs holding rowid+data being inserted */
134634 int regRowid; /* registers holding insert rowid */
134635 int regData; /* register holding first column to insert */
134636 int *aRegIdx = 0; /* One register allocated to each index */
 
134637
134638 #ifndef SQLITE_OMIT_TRIGGER
134639 int isView; /* True if attempting to insert into a view */
134640 Trigger *pTrigger; /* List of triggers on pTab, if required */
134641 int tmask; /* Mask of trigger times */
@@ -134776,35 +134941,29 @@
134776 ** columns into storage order. False negatives are harmless,
134777 ** but false positives will cause database corruption.
134778 */
134779 bIdListInOrder = (pTab->tabFlags & (TF_OOOHidden|TF_HasStored))==0;
134780 if( pColumn ){
134781 assert( pColumn->eU4!=EU4_EXPR );
134782 pColumn->eU4 = EU4_IDX;
134783 for(i=0; i<pColumn->nId; i++){
134784 pColumn->a[i].u4.idx = -1;
134785 }
134786 for(i=0; i<pColumn->nId; i++){
134787 for(j=0; j<pTab->nCol; j++){
134788 if( sqlite3StrICmp(pColumn->a[i].zName, pTab->aCol[j].zCnName)==0 ){
134789 pColumn->a[i].u4.idx = j;
134790 if( i!=j ) bIdListInOrder = 0;
134791 if( j==pTab->iPKey ){
134792 ipkColumn = i; assert( !withoutRowid );
134793 }
134794 #ifndef SQLITE_OMIT_GENERATED_COLUMNS
134795 if( pTab->aCol[j].colFlags & (COLFLAG_STORED|COLFLAG_VIRTUAL) ){
134796 sqlite3ErrorMsg(pParse,
134797 "cannot INSERT into generated column \"%s\"",
134798 pTab->aCol[j].zCnName);
134799 goto insert_cleanup;
134800 }
134801 #endif
134802 break;
134803 }
134804 }
134805 if( j>=pTab->nCol ){
134806 if( sqlite3IsRowid(pColumn->a[i].zName) && !withoutRowid ){
134807 ipkColumn = i;
134808 bIdListInOrder = 0;
134809 }else{
134810 sqlite3ErrorMsg(pParse, "table %S has no column named %s",
@@ -135098,29 +135257,29 @@
135098 sqlite3VdbeAddOp1(v, OP_SoftNull, iRegStore);
135099 }
135100 continue;
135101 }else if( pColumn==0 ){
135102 /* Hidden columns that are not explicitly named in the INSERT
135103 ** get there default value */
135104 sqlite3ExprCodeFactorable(pParse,
135105 sqlite3ColumnExpr(pTab, &pTab->aCol[i]),
135106 iRegStore);
135107 continue;
135108 }
135109 }
135110 if( pColumn ){
135111 assert( pColumn->eU4==EU4_IDX );
135112 for(j=0; j<pColumn->nId && pColumn->a[j].u4.idx!=i; j++){}
135113 if( j>=pColumn->nId ){
135114 /* A column not named in the insert column list gets its
135115 ** default value */
135116 sqlite3ExprCodeFactorable(pParse,
135117 sqlite3ColumnExpr(pTab, &pTab->aCol[i]),
135118 iRegStore);
135119 continue;
135120 }
135121 k = j;
135122 }else if( nColumn==0 ){
135123 /* This is INSERT INTO ... DEFAULT VALUES. Load the default value. */
135124 sqlite3ExprCodeFactorable(pParse,
135125 sqlite3ColumnExpr(pTab, &pTab->aCol[i]),
135126 iRegStore);
@@ -135361,11 +135520,14 @@
135361 insert_cleanup:
135362 sqlite3SrcListDelete(db, pTabList);
135363 sqlite3ExprListDelete(db, pList);
135364 sqlite3UpsertDelete(db, pUpsert);
135365 sqlite3SelectDelete(db, pSelect);
135366 sqlite3IdListDelete(db, pColumn);
 
 
 
135367 if( aRegIdx ) sqlite3DbNNFreeNN(db, aRegIdx);
135368 }
135369
135370 /* Make sure "isView" and other macros defined above are undefined. Otherwise
135371 ** they may interfere with compilation of other functions in this file
@@ -140708,11 +140870,14 @@
140708 ){
140709 db->flags |= mask;
140710 }
140711 }else{
140712 db->flags &= ~mask;
140713 if( mask==SQLITE_DeferFKs ) db->nDeferredImmCons = 0;
 
 
 
140714 if( (mask & SQLITE_WriteSchema)!=0
140715 && sqlite3_stricmp(zRight, "reset")==0
140716 ){
140717 /* IMP: R-60817-01178 If the argument is "RESET" then schema
140718 ** writing is disabled (as with "PRAGMA writable_schema=OFF") and,
@@ -141316,11 +141481,11 @@
141316 sqlite3VdbeAddOp3(v, OP_Null, 0, 8, 8+cnt);
141317 sqlite3ClearTempRegCache(pParse);
141318
141319 /* Do the b-tree integrity checks */
141320 sqlite3VdbeAddOp4(v, OP_IntegrityCk, 1, cnt, 8, (char*)aRoot,P4_INTARRAY);
141321 sqlite3VdbeChangeP5(v, (u8)i);
141322 addr = sqlite3VdbeAddOp1(v, OP_IsNull, 2); VdbeCoverage(v);
141323 sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0,
141324 sqlite3MPrintf(db, "*** in database %s ***\n", db->aDb[i].zDbSName),
141325 P4_DYNAMIC);
141326 sqlite3VdbeAddOp3(v, OP_Concat, 2, 3, 3);
@@ -144042,14 +144207,37 @@
144042 ** Return the index of a column in a table. Return -1 if the column
144043 ** is not contained in the table.
144044 */
144045 SQLITE_PRIVATE int sqlite3ColumnIndex(Table *pTab, const char *zCol){
144046 int i;
144047 u8 h = sqlite3StrIHash(zCol);
144048 Column *pCol;
144049 for(pCol=pTab->aCol, i=0; i<pTab->nCol; pCol++, i++){
144050 if( pCol->hName==h && sqlite3StrICmp(pCol->zCnName, zCol)==0 ) return i;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
144051 }
144052 return -1;
144053 }
144054
144055 /*
@@ -150549,11 +150737,11 @@
150549 }
150550 sqlite3ReleaseTempReg(pParse, regSubtype);
150551 }
150552 sqlite3VdbeAddOp3(v, OP_AggStep, 0, regAgg, AggInfoFuncReg(pAggInfo,i));
150553 sqlite3VdbeAppendP4(v, pF->pFunc, P4_FUNCDEF);
150554 sqlite3VdbeChangeP5(v, (u8)nArg);
150555 sqlite3VdbeAddOp2(v, OP_Next, pF->iOBTab, iTop+1); VdbeCoverage(v);
150556 sqlite3VdbeJumpHere(v, iTop);
150557 sqlite3ReleaseTempRange(pParse, regAgg, nArg);
150558 }
150559 sqlite3VdbeAddOp2(v, OP_AggFinal, AggInfoFuncReg(pAggInfo,i),
@@ -150712,11 +150900,11 @@
150712 sqlite3VdbeAddOp4(v, OP_CollSeq, regHit, 0, 0,
150713 (char *)pColl, P4_COLLSEQ);
150714 }
150715 sqlite3VdbeAddOp3(v, OP_AggStep, 0, regAgg, AggInfoFuncReg(pAggInfo,i));
150716 sqlite3VdbeAppendP4(v, pF->pFunc, P4_FUNCDEF);
150717 sqlite3VdbeChangeP5(v, (u8)nArg);
150718 sqlite3ReleaseTempRange(pParse, regAgg, nArg);
150719 }
150720 if( addrNext ){
150721 sqlite3VdbeResolveLabel(v, addrNext);
150722 }
@@ -152767,11 +152955,12 @@
152767 }else if( pTrig->op==TK_RETURNING ){
152768 #ifndef SQLITE_OMIT_VIRTUALTABLE
152769 assert( pParse->db->pVtabCtx==0 );
152770 #endif
152771 assert( pParse->bReturning );
152772 assert( &(pParse->u1.pReturning->retTrig) == pTrig );
 
152773 pTrig->table = pTab->zName;
152774 pTrig->pTabSchema = pTab->pSchema;
152775 pTrig->pNext = pList;
152776 pList = pTrig;
152777 }
@@ -153744,11 +153933,12 @@
153744 /* This RETURNING trigger must be for a different statement as
153745 ** this statement lacks a RETURNING clause. */
153746 return;
153747 }
153748 assert( db->pParse==pParse );
153749 pReturning = pParse->u1.pReturning;
 
153750 if( pTrigger != &(pReturning->retTrig) ){
153751 /* This RETURNING trigger is for a different statement */
153752 return;
153753 }
153754 memset(&sSelect, 0, sizeof(sSelect));
@@ -153974,10 +154164,12 @@
153974 sSubParse.pToplevel = pTop;
153975 sSubParse.zAuthContext = pTrigger->zName;
153976 sSubParse.eTriggerOp = pTrigger->op;
153977 sSubParse.nQueryLoop = pParse->nQueryLoop;
153978 sSubParse.prepFlags = pParse->prepFlags;
 
 
153979
153980 v = sqlite3GetVdbe(&sSubParse);
153981 if( v ){
153982 VdbeComment((v, "Start: %s.%s (%s %s%s%s ON %s)",
153983 pTrigger->zName, onErrorText(orconf),
@@ -154106,11 +154298,11 @@
154106 /* Set the P5 operand of the OP_Program instruction to non-zero if
154107 ** recursive invocation of this trigger program is disallowed. Recursive
154108 ** invocation is disallowed if (a) the sub-program is really a trigger,
154109 ** not a foreign key action, and (b) the flag to enable recursive triggers
154110 ** is clear. */
154111 sqlite3VdbeChangeP5(v, (u8)bRecursive);
154112 }
154113 }
154114
154115 /*
154116 ** This is called to code the required FOR EACH ROW triggers for an operation
@@ -154728,42 +154920,36 @@
154728 ** column to be updated, make sure we have authorization to change
154729 ** that column.
154730 */
154731 chngRowid = chngPk = 0;
154732 for(i=0; i<pChanges->nExpr; i++){
154733 u8 hCol = sqlite3StrIHash(pChanges->a[i].zEName);
154734 /* If this is an UPDATE with a FROM clause, do not resolve expressions
154735 ** here. The call to sqlite3Select() below will do that. */
154736 if( nChangeFrom==0 && sqlite3ResolveExprNames(&sNC, pChanges->a[i].pExpr) ){
154737 goto update_cleanup;
154738 }
154739 for(j=0; j<pTab->nCol; j++){
154740 if( pTab->aCol[j].hName==hCol
154741 && sqlite3StrICmp(pTab->aCol[j].zCnName, pChanges->a[i].zEName)==0
154742 ){
154743 if( j==pTab->iPKey ){
154744 chngRowid = 1;
154745 pRowidExpr = pChanges->a[i].pExpr;
154746 iRowidExpr = i;
154747 }else if( pPk && (pTab->aCol[j].colFlags & COLFLAG_PRIMKEY)!=0 ){
154748 chngPk = 1;
154749 }
154750 #ifndef SQLITE_OMIT_GENERATED_COLUMNS
154751 else if( pTab->aCol[j].colFlags & COLFLAG_GENERATED ){
154752 testcase( pTab->aCol[j].colFlags & COLFLAG_VIRTUAL );
154753 testcase( pTab->aCol[j].colFlags & COLFLAG_STORED );
154754 sqlite3ErrorMsg(pParse,
154755 "cannot UPDATE generated column \"%s\"",
154756 pTab->aCol[j].zCnName);
154757 goto update_cleanup;
154758 }
154759 #endif
154760 aXRef[j] = i;
154761 break;
154762 }
154763 }
154764 if( j>=pTab->nCol ){
154765 if( pPk==0 && sqlite3IsRowid(pChanges->a[i].zEName) ){
154766 j = -1;
154767 chngRowid = 1;
154768 pRowidExpr = pChanges->a[i].pExpr;
154769 iRowidExpr = i;
@@ -156866,24 +157052,25 @@
156866
156867 /* A slot for the record has already been allocated in the
156868 ** schema table. We just need to update that slot with all
156869 ** the information we've collected.
156870 **
156871 ** The VM register number pParse->regRowid holds the rowid of an
156872 ** entry in the sqlite_schema table that was created for this vtab
156873 ** by sqlite3StartTable().
156874 */
156875 iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
 
156876 sqlite3NestedParse(pParse,
156877 "UPDATE %Q." LEGACY_SCHEMA_TABLE " "
156878 "SET type='table', name=%Q, tbl_name=%Q, rootpage=0, sql=%Q "
156879 "WHERE rowid=#%d",
156880 db->aDb[iDb].zDbSName,
156881 pTab->zName,
156882 pTab->zName,
156883 zStmt,
156884 pParse->regRowid
156885 );
156886 v = sqlite3GetVdbe(pParse);
156887 sqlite3ChangeCookie(pParse, iDb);
156888
156889 sqlite3VdbeAddOp0(v, OP_Expire);
@@ -157217,11 +157404,13 @@
157217 ** sqlite3_declare_vtab() is being misused.
157218 */
157219 z = (const unsigned char*)zCreateTable;
157220 for(i=0; aKeyword[i]; i++){
157221 int tokenType = 0;
157222 do{ z += sqlite3GetToken(z, &tokenType); }while( tokenType==TK_SPACE );
 
 
157223 if( tokenType!=aKeyword[i] ){
157224 sqlite3ErrorWithMsg(db, SQLITE_ERROR, "syntax error");
157225 return SQLITE_ERROR;
157226 }
157227 }
@@ -157948,12 +158137,14 @@
157948 u16 nLTerm; /* Number of entries in aLTerm[] */
157949 u16 nSkip; /* Number of NULL aLTerm[] entries */
157950 /**** whereLoopXfer() copies fields above ***********************/
157951 # define WHERE_LOOP_XFER_SZ offsetof(WhereLoop,nLSlot)
157952 u16 nLSlot; /* Number of slots allocated for aLTerm[] */
 
157953 LogEst rStarDelta; /* Cost delta due to star-schema heuristic. Not
157954 ** initialized unless pWInfo->nOutStarDelta>0 */
 
157955 WhereTerm **aLTerm; /* WhereTerms used */
157956 WhereLoop *pNextLoop; /* Next WhereLoop object in the WhereClause */
157957 WhereTerm *aLTermSpace[3]; /* Initial aLTerm[] space */
157958 };
157959
@@ -157998,11 +158189,11 @@
157998 struct WherePath {
157999 Bitmask maskLoop; /* Bitmask of all WhereLoop objects in this path */
158000 Bitmask revLoop; /* aLoop[]s that should be reversed for ORDER BY */
158001 LogEst nRow; /* Estimated number of rows generated by this path */
158002 LogEst rCost; /* Total cost of this path */
158003 LogEst rUnsorted; /* Total cost of this path ignoring sorting costs */
158004 i8 isOrdered; /* No. of ORDER BY terms satisfied. -1 for unknown */
158005 WhereLoop **aLoop; /* Array of WhereLoop objects implementing this path */
158006 };
158007
158008 /*
@@ -158271,13 +158462,17 @@
158271 u8 eOnePass; /* ONEPASS_OFF, or _SINGLE, or _MULTI */
158272 u8 eDistinct; /* One of the WHERE_DISTINCT_* values */
158273 unsigned bDeferredSeek :1; /* Uses OP_DeferredSeek */
158274 unsigned untestedTerms :1; /* Not all WHERE terms resolved by outer loop */
158275 unsigned bOrderedInnerLoop:1;/* True if only the inner-most loop is ordered */
158276 unsigned sorted :1; /* True if really sorted (not just grouped) */
158277 LogEst nOutStarDelta; /* Artifical nOut reduction for star-query */
 
158278 LogEst nRowOut; /* Estimated number of output rows */
 
 
 
158279 int iTop; /* The very beginning of the WHERE loop */
158280 int iEndWhere; /* End of the WHERE clause itself */
158281 WhereLoop *pLoops; /* List of all WhereLoop objects */
158282 WhereMemBlock *pMemToFree;/* Memory to free when this object destroyed */
158283 Bitmask revMask; /* Mask of ORDER BY terms that need reversing */
@@ -160029,10 +160224,13 @@
160029 }
160030 }
160031 }
160032 sqlite3VdbeAddOp2(v, OP_Integer, pLoop->u.vtab.idxNum, iReg);
160033 sqlite3VdbeAddOp2(v, OP_Integer, nConstraint, iReg+1);
 
 
 
160034 sqlite3VdbeAddOp4(v, OP_VFilter, iCur, addrNotFound, iReg,
160035 pLoop->u.vtab.idxStr,
160036 pLoop->u.vtab.needFree ? P4_DYNAMIC : P4_STATIC);
160037 VdbeCoverage(v);
160038 pLoop->u.vtab.needFree = 0;
@@ -161584,24 +161782,26 @@
161584 }else if( op==TK_STRING ){
161585 assert( !ExprHasProperty(pRight, EP_IntValue) );
161586 z = (u8*)pRight->u.zToken;
161587 }
161588 if( z ){
161589 /* Count the number of prefix bytes prior to the first wildcard.
161590 ** or U+fffd character. If the underlying database has a UTF16LE
161591 ** encoding, then only consider ASCII characters. Note that the
161592 ** encoding of z[] is UTF8 - we are dealing with only UTF8 here in
161593 ** this code, but the database engine itself might be processing
161594 ** content using a different encoding. */
161595 cnt = 0;
161596 while( (c=z[cnt])!=0 && c!=wc[0] && c!=wc[1] && c!=wc[2] ){
161597 cnt++;
161598 if( c==wc[3] && z[cnt]>0 && z[cnt]<0x80 ){
161599 cnt++;
161600 }else if( c>=0x80 ){
161601 const u8 *z2 = z+cnt-1;
161602 if( sqlite3Utf8Read(&z2)==0xfffd || ENC(db)==SQLITE_UTF16LE ){
 
 
161603 cnt--;
161604 break;
161605 }else{
161606 cnt = (int)(z2-z);
161607 }
@@ -162749,24 +162949,30 @@
162749 pStr2->u.zToken[i] = sqlite3Tolower(c);
162750 }
162751 }
162752
162753 if( !db->mallocFailed ){
162754 u8 c, *pC; /* Last character before the first wildcard */
162755 pC = (u8*)&pStr2->u.zToken[sqlite3Strlen30(pStr2->u.zToken)-1];
162756 c = *pC;
162757 if( noCase ){
162758 /* The point is to increment the last character before the first
162759 ** wildcard. But if we increment '@', that will push it into the
162760 ** alphabetic range where case conversions will mess up the
162761 ** inequality. To avoid this, make sure to also run the full
162762 ** LIKE on all candidate expressions by clearing the isComplete flag
162763 */
162764 if( c=='A'-1 ) isComplete = 0;
162765 c = sqlite3UpperToLower[c];
162766 }
162767 *pC = c + 1;
 
 
 
 
 
 
 
162768 }
162769 zCollSeqName = noCase ? "NOCASE" : sqlite3StrBINARY;
162770 pNewExpr1 = sqlite3ExprDup(db, pLeft, 0);
162771 pNewExpr1 = sqlite3PExpr(pParse, TK_GE,
162772 sqlite3ExprAddCollateString(pParse,pNewExpr1,zCollSeqName),
@@ -164130,10 +164336,15 @@
164130 **
164131 ** 2. If iCol is part of an existing index that has an aiRowLogEst of
164132 ** more than 20, then return false.
164133 **
164134 ** 3. If no disqualifying conditions above are found, return true.
 
 
 
 
 
164135 */
164136 static SQLITE_NOINLINE int columnIsGoodIndexCandidate(
164137 const Table *pTab,
164138 int iCol
164139 ){
@@ -164214,11 +164425,11 @@
164214 char *zText = 0;
164215 int ii = 0;
164216 sqlite3_str *pStr = sqlite3_str_new(pParse->db);
164217 sqlite3_str_appendf(pStr,"CREATE AUTOMATIC INDEX ON %s(", pTab->zName);
164218 assert( pIdx->nColumn>1 );
164219 assert( pIdx->aiColumn[pIdx->nColumn-1]==XN_ROWID );
164220 for(ii=0; ii<(pIdx->nColumn-1); ii++){
164221 const char *zName = 0;
164222 int iCol = pIdx->aiColumn[ii];
164223
164224 zName = pTab->aCol[iCol].zCnName;
@@ -164344,10 +164555,23 @@
164344 */
164345 if( IsView(pTable) ){
164346 extraCols = ALLBITS & ~idxCols;
164347 }else{
164348 extraCols = pSrc->colUsed & (~idxCols | MASKBIT(BMS-1));
 
 
 
 
 
 
 
 
 
 
 
 
 
164349 }
164350 mxBitCol = MIN(BMS-1,pTable->nCol);
164351 testcase( pTable->nCol==BMS-1 );
164352 testcase( pTable->nCol==BMS-2 );
164353 for(i=0; i<mxBitCol; i++){
@@ -164356,11 +164580,12 @@
164356 if( pSrc->colUsed & MASKBIT(BMS-1) ){
164357 nKeyCol += pTable->nCol - BMS + 1;
164358 }
164359
164360 /* Construct the Index object to describe this index */
164361 pIdx = sqlite3AllocateIndexObject(pParse->db, nKeyCol+1, 0, &zNotUsed);
 
164362 if( pIdx==0 ) goto end_auto_index_create;
164363 pLoop->u.btree.pIndex = pIdx;
164364 pIdx->zName = "auto-index";
164365 pIdx->pTable = pTable;
164366 n = 0;
@@ -164412,12 +164637,14 @@
164412 pIdx->azColl[n] = sqlite3StrBINARY;
164413 n++;
164414 }
164415 }
164416 assert( n==nKeyCol );
164417 pIdx->aiColumn[n] = XN_ROWID;
164418 pIdx->azColl[n] = sqlite3StrBINARY;
 
 
164419
164420 /* Create the automatic index */
164421 explainAutomaticIndex(pParse, pIdx, pPartial!=0, &addrExp);
164422 assert( pLevel->iIdxCur>=0 );
164423 pLevel->iIdxCur = pParse->nTab++;
@@ -165680,21 +165907,23 @@
165680 ** | | | __|__ nEq ---. ___|__ | __|__
165681 ** | / \ / \ / \ | / \ / \ / \
165682 ** 1.002.001 t2.t2xy 2 f 010241 N 2 cost 0,56,31
165683 */
165684 SQLITE_PRIVATE void sqlite3WhereLoopPrint(const WhereLoop *p, const WhereClause *pWC){
 
165685 if( pWC ){
165686 WhereInfo *pWInfo = pWC->pWInfo;
165687 int nb = 1+(pWInfo->pTabList->nSrc+3)/4;
165688 SrcItem *pItem = pWInfo->pTabList->a + p->iTab;
165689 Table *pTab = pItem->pSTab;
165690 Bitmask mAll = (((Bitmask)1)<<(nb*4)) - 1;
165691 sqlite3DebugPrintf("%c%2d.%0*llx.%0*llx", p->cId,
165692 p->iTab, nb, p->maskSelf, nb, p->prereq & mAll);
165693 sqlite3DebugPrintf(" %12s",
165694 pItem->zAlias ? pItem->zAlias : pTab->zName);
165695 }else{
 
165696 sqlite3DebugPrintf("%c%2d.%03llx.%03llx %c%d",
165697 p->cId, p->iTab, p->maskSelf, p->prereq & 0xfff, p->cId, p->iTab);
165698 }
165699 if( (p->wsFlags & WHERE_VIRTUALTABLE)==0 ){
165700 const char *zName;
@@ -165722,11 +165951,16 @@
165722 if( p->wsFlags & WHERE_SKIPSCAN ){
165723 sqlite3DebugPrintf(" f %06x %d-%d", p->wsFlags, p->nLTerm,p->nSkip);
165724 }else{
165725 sqlite3DebugPrintf(" f %06x N %d", p->wsFlags, p->nLTerm);
165726 }
165727 sqlite3DebugPrintf(" cost %d,%d,%d\n", p->rSetup, p->rRun, p->nOut);
 
 
 
 
 
165728 if( p->nLTerm && (sqlite3WhereTrace & 0x4000)!=0 ){
165729 int i;
165730 for(i=0; i<p->nLTerm; i++){
165731 sqlite3WhereTermPrint(p->aLTerm[i], i);
165732 }
@@ -167188,11 +167422,10 @@
167188 if( !pBuilder->pOrSet /* Not part of an OR optimization */
167189 && (pWInfo->wctrlFlags & (WHERE_RIGHT_JOIN|WHERE_OR_SUBCLAUSE))==0
167190 && (pWInfo->pParse->db->flags & SQLITE_AutoIndex)!=0
167191 && !pSrc->fg.isIndexedBy /* Has no INDEXED BY clause */
167192 && !pSrc->fg.notIndexed /* Has no NOT INDEXED clause */
167193 && HasRowid(pTab) /* Not WITHOUT ROWID table. (FIXME: Why not?) */
167194 && !pSrc->fg.isCorrelated /* Not a correlated subquery */
167195 && !pSrc->fg.isRecursive /* Not a recursive common table expression. */
167196 && (pSrc->fg.jointype & JT_RIGHT)==0 /* Not the right tab of a RIGHT JOIN */
167197 ){
167198 /* Generate auto-index WhereLoops */
@@ -168691,72 +168924,205 @@
168691 ** The value returned is a tuning parameter. Currently the value is:
168692 **
168693 ** 18 for star queries
168694 ** 12 otherwise
168695 **
168696 ** For the purposes of SQLite, a star-query is defined as a query
168697 ** with a large central table that is joined against four or more
168698 ** smaller tables. The central table is called the "fact" table.
168699 ** The smaller tables that get joined are "dimension tables".
 
 
 
168700 **
168701 ** SIDE EFFECT: (and really the whole point of this subroutine)
168702 **
168703 ** If pWInfo describes a star-query, then the cost on WhereLoops for the
168704 ** fact table is reduced. This heuristic helps keep fact tables in
168705 ** outer loops. Without this heuristic, paths with fact tables in outer
168706 ** loops tend to get pruned by the mxChoice limit on the number of paths,
168707 ** resulting in poor query plans. The total amount of heuristic cost
168708 ** adjustment is stored in pWInfo->nOutStarDelta and the cost adjustment
168709 ** for each WhereLoop is stored in its rStarDelta field.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
168710 */
168711 static int computeMxChoice(WhereInfo *pWInfo, LogEst nRowEst){
168712 int nLoop = pWInfo->nLevel; /* Number of terms in the join */
168713 if( nRowEst==0 && nLoop>=5 ){
168714 /* Check to see if we are dealing with a star schema and if so, reduce
168715 ** the cost of fact tables relative to dimension tables, as a heuristic
168716 ** to help keep the fact tables in outer loops.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
168717 */
168718 int iLoop; /* Counter over join terms */
168719 Bitmask m; /* Bitmask for current loop */
168720 assert( pWInfo->nOutStarDelta==0 );
168721 for(iLoop=0, m=1; iLoop<nLoop; iLoop++, m<<=1){
168722 WhereLoop *pWLoop; /* For looping over WhereLoops */
168723 int nDep = 0; /* Number of dimension tables */
168724 LogEst rDelta; /* Heuristic cost adjustment */
168725 Bitmask mSeen = 0; /* Mask of dimension tables */
168726 for(pWLoop=pWInfo->pLoops; pWLoop; pWLoop=pWLoop->pNextLoop){
168727 if( (pWLoop->prereq & m)!=0 && (pWLoop->maskSelf & mSeen)==0 ){
168728 nDep++;
168729 mSeen |= pWLoop->maskSelf;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
168730 }
168731 }
168732 if( nDep<=3 ) continue;
168733 rDelta = 15*(nDep-3);
168734 #ifdef WHERETRACE_ENABLED /* 0x4 */
168735 if( sqlite3WhereTrace&0x4 ){
168736 SrcItem *pItem = pWInfo->pTabList->a + iLoop;
168737 sqlite3DebugPrintf("Fact-table %s: %d dimensions, cost reduced %d\n",
168738 pItem->zAlias ? pItem->zAlias : pItem->pSTab->zName,
168739 nDep, rDelta);
168740 }
168741 #endif
168742 if( pWInfo->nOutStarDelta==0 ){
168743 for(pWLoop=pWInfo->pLoops; pWLoop; pWLoop=pWLoop->pNextLoop){
168744 pWLoop->rStarDelta = 0;
168745 }
168746 }
168747 pWInfo->nOutStarDelta += rDelta;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
168748 for(pWLoop=pWInfo->pLoops; pWLoop; pWLoop=pWLoop->pNextLoop){
168749 if( pWLoop->maskSelf==m ){
168750 pWLoop->rRun -= rDelta;
168751 pWLoop->nOut -= rDelta;
168752 pWLoop->rStarDelta = rDelta;
168753 }
168754 }
168755 }
 
168756 }
168757 return pWInfo->nOutStarDelta>0 ? 18 : 12;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
168758 }
168759
168760 /*
168761 ** Given the list of WhereLoop objects at pWInfo->pLoops, this routine
168762 ** attempts to find the lowest cost path that visits each WhereLoop
@@ -168776,11 +169142,11 @@
168776 int iLoop; /* Loop counter over the terms of the join */
168777 int ii, jj; /* Loop counters */
168778 int mxI = 0; /* Index of next entry to replace */
168779 int nOrderBy; /* Number of ORDER BY clause terms */
168780 LogEst mxCost = 0; /* Maximum cost of a set of paths */
168781 LogEst mxUnsorted = 0; /* Maximum unsorted cost of a set of path */
168782 int nTo, nFrom; /* Number of valid entries in aTo[] and aFrom[] */
168783 WherePath *aFrom; /* All nFrom paths at the previous level */
168784 WherePath *aTo; /* The nTo best paths at the current level */
168785 WherePath *pFrom; /* An element of aFrom[] that we are working on */
168786 WherePath *pTo; /* An element of aTo[] that we are working on */
@@ -168805,12 +169171,14 @@
168805 */
168806 if( nLoop<=1 ){
168807 mxChoice = 1;
168808 }else if( nLoop==2 ){
168809 mxChoice = 5;
 
 
168810 }else{
168811 mxChoice = computeMxChoice(pWInfo, nRowEst);
168812 }
168813 assert( nLoop<=pWInfo->pTabList->nSrc );
168814
168815 /* If nRowEst is zero and there is an ORDER BY clause, ignore it. In this
168816 ** case the purpose of this call is to estimate the number of rows returned
@@ -168873,11 +169241,11 @@
168873 nTo = 0;
168874 for(ii=0, pFrom=aFrom; ii<nFrom; ii++, pFrom++){
168875 for(pWLoop=pWInfo->pLoops; pWLoop; pWLoop=pWLoop->pNextLoop){
168876 LogEst nOut; /* Rows visited by (pFrom+pWLoop) */
168877 LogEst rCost; /* Cost of path (pFrom+pWLoop) */
168878 LogEst rUnsorted; /* Unsorted cost of (pFrom+pWLoop) */
168879 i8 isOrdered; /* isOrdered for (pFrom+pWLoop) */
168880 Bitmask maskNew; /* Mask of src visited by (..) */
168881 Bitmask revMask; /* Mask of rev-order loops for (..) */
168882
168883 if( (pWLoop->prereq & ~pFrom->maskLoop)!=0 ) continue;
@@ -168891,15 +169259,15 @@
168891 continue;
168892 }
168893
168894 /* At this point, pWLoop is a candidate to be the next loop.
168895 ** Compute its cost */
168896 rUnsorted = pWLoop->rRun + pFrom->nRow;
168897 if( pWLoop->rSetup ){
168898 rUnsorted = sqlite3LogEstAdd(pWLoop->rSetup, rUnsorted);
168899 }
168900 rUnsorted = sqlite3LogEstAdd(rUnsorted, pFrom->rUnsorted);
168901 nOut = pFrom->nRow + pWLoop->nOut;
168902 maskNew = pFrom->maskLoop | pWLoop->maskSelf;
168903 isOrdered = pFrom->isOrdered;
168904 if( isOrdered<0 ){
168905 revMask = 0;
@@ -168917,19 +169285,19 @@
168917 }
168918 /* TUNING: Add a small extra penalty (3) to sorting as an
168919 ** extra encouragement to the query planner to select a plan
168920 ** where the rows emerge in the correct order without any sorting
168921 ** required. */
168922 rCost = sqlite3LogEstAdd(rUnsorted, aSortCost[isOrdered]) + 3;
168923
168924 WHERETRACE(0x002,
168925 ("---- sort cost=%-3d (%d/%d) increases cost %3d to %-3d\n",
168926 aSortCost[isOrdered], (nOrderBy-isOrdered), nOrderBy,
168927 rUnsorted, rCost));
168928 }else{
168929 rCost = rUnsorted;
168930 rUnsorted -= 2; /* TUNING: Slight bias in favor of no-sort plans */
168931 }
168932
168933 /* Check to see if pWLoop should be added to the set of
168934 ** mxChoice best-so-far paths.
168935 **
@@ -168951,19 +169319,19 @@
168951 }
168952 }
168953 if( jj>=nTo ){
168954 /* None of the existing best-so-far paths match the candidate. */
168955 if( nTo>=mxChoice
168956 && (rCost>mxCost || (rCost==mxCost && rUnsorted>=mxUnsorted))
168957 ){
168958 /* The current candidate is no better than any of the mxChoice
168959 ** paths currently in the best-so-far buffer. So discard
168960 ** this candidate as not viable. */
168961 #ifdef WHERETRACE_ENABLED /* 0x4 */
168962 if( sqlite3WhereTrace&0x4 ){
168963 sqlite3DebugPrintf("Skip %s cost=%-3d,%3d,%3d order=%c\n",
168964 wherePathName(pFrom, iLoop, pWLoop), rCost, nOut, rUnsorted,
168965 isOrdered>=0 ? isOrdered+'0' : '?');
168966 }
168967 #endif
168968 continue;
168969 }
@@ -168978,11 +169346,11 @@
168978 }
168979 pTo = &aTo[jj];
168980 #ifdef WHERETRACE_ENABLED /* 0x4 */
168981 if( sqlite3WhereTrace&0x4 ){
168982 sqlite3DebugPrintf("New %s cost=%-3d,%3d,%3d order=%c\n",
168983 wherePathName(pFrom, iLoop, pWLoop), rCost, nOut, rUnsorted,
168984 isOrdered>=0 ? isOrdered+'0' : '?');
168985 }
168986 #endif
168987 }else{
168988 /* Control reaches here if best-so-far path pTo=aTo[jj] covers the
@@ -168989,28 +169357,27 @@
168989 ** same set of loops and has the same isOrdered setting as the
168990 ** candidate path. Check to see if the candidate should replace
168991 ** pTo or if the candidate should be skipped.
168992 **
168993 ** The conditional is an expanded vector comparison equivalent to:
168994 ** (pTo->rCost,pTo->nRow,pTo->rUnsorted) <= (rCost,nOut,rUnsorted)
168995 */
168996 if( pTo->rCost<rCost
168997 || (pTo->rCost==rCost
168998 && (pTo->nRow<nOut
168999 || (pTo->nRow==nOut && pTo->rUnsorted<=rUnsorted)
169000 )
169001 )
169002 ){
169003 #ifdef WHERETRACE_ENABLED /* 0x4 */
169004 if( sqlite3WhereTrace&0x4 ){
169005 sqlite3DebugPrintf(
169006 "Skip %s cost=%-3d,%3d,%3d order=%c",
169007 wherePathName(pFrom, iLoop, pWLoop), rCost, nOut, rUnsorted,
169008 isOrdered>=0 ? isOrdered+'0' : '?');
169009 sqlite3DebugPrintf(" vs %s cost=%-3d,%3d,%3d order=%c\n",
169010 wherePathName(pTo, iLoop+1, 0), pTo->rCost, pTo->nRow,
169011 pTo->rUnsorted, pTo->isOrdered>=0 ? pTo->isOrdered+'0' : '?');
169012 }
169013 #endif
169014 /* Discard the candidate path from further consideration */
169015 testcase( pTo->rCost==rCost );
169016 continue;
@@ -169020,37 +169387,37 @@
169020 ** pTo path. Replace pTo with the candidate. */
169021 #ifdef WHERETRACE_ENABLED /* 0x4 */
169022 if( sqlite3WhereTrace&0x4 ){
169023 sqlite3DebugPrintf(
169024 "Update %s cost=%-3d,%3d,%3d order=%c",
169025 wherePathName(pFrom, iLoop, pWLoop), rCost, nOut, rUnsorted,
169026 isOrdered>=0 ? isOrdered+'0' : '?');
169027 sqlite3DebugPrintf(" was %s cost=%-3d,%3d,%3d order=%c\n",
169028 wherePathName(pTo, iLoop+1, 0), pTo->rCost, pTo->nRow,
169029 pTo->rUnsorted, pTo->isOrdered>=0 ? pTo->isOrdered+'0' : '?');
169030 }
169031 #endif
169032 }
169033 /* pWLoop is a winner. Add it to the set of best so far */
169034 pTo->maskLoop = pFrom->maskLoop | pWLoop->maskSelf;
169035 pTo->revLoop = revMask;
169036 pTo->nRow = nOut;
169037 pTo->rCost = rCost;
169038 pTo->rUnsorted = rUnsorted;
169039 pTo->isOrdered = isOrdered;
169040 memcpy(pTo->aLoop, pFrom->aLoop, sizeof(WhereLoop*)*iLoop);
169041 pTo->aLoop[iLoop] = pWLoop;
169042 if( nTo>=mxChoice ){
169043 mxI = 0;
169044 mxCost = aTo[0].rCost;
169045 mxUnsorted = aTo[0].nRow;
169046 for(jj=1, pTo=&aTo[1]; jj<mxChoice; jj++, pTo++){
169047 if( pTo->rCost>mxCost
169048 || (pTo->rCost==mxCost && pTo->rUnsorted>mxUnsorted)
169049 ){
169050 mxCost = pTo->rCost;
169051 mxUnsorted = pTo->rUnsorted;
169052 mxI = jj;
169053 }
169054 }
169055 }
169056 }
@@ -169058,12 +169425,14 @@
169058
169059 #ifdef WHERETRACE_ENABLED /* >=2 */
169060 if( sqlite3WhereTrace & 0x02 ){
169061 LogEst rMin, rFloor = 0;
169062 int nDone = 0;
 
169063 sqlite3DebugPrintf("---- after round %d ----\n", iLoop);
169064 while( nDone<nTo ){
 
169065 rMin = 0x7fff;
169066 for(ii=0, pTo=aTo; ii<nTo; ii++, pTo++){
169067 if( pTo->rCost>rFloor && pTo->rCost<rMin ) rMin = pTo->rCost;
169068 }
169069 for(ii=0, pTo=aTo; ii<nTo; ii++, pTo++){
@@ -169075,14 +169444,15 @@
169075 sqlite3DebugPrintf(" rev=0x%llx\n", pTo->revLoop);
169076 }else{
169077 sqlite3DebugPrintf("\n");
169078 }
169079 nDone++;
 
169080 }
169081 }
169082 rFloor = rMin;
169083 }
169084 }
169085 #endif
169086
169087 /* Swap the roles of aFrom and aTo for the next generation */
169088 pFrom = aTo;
@@ -169172,11 +169542,14 @@
169172 pWInfo->revMask = revMask;
169173 }
169174 }
169175 }
169176
169177 pWInfo->nRowOut = pFrom->nRow + pWInfo->nOutStarDelta;
 
 
 
169178
169179 /* Free temporary memory and return success */
169180 sqlite3StackFreeNN(pParse->db, pSpace);
169181 return SQLITE_OK;
169182 }
@@ -169570,11 +169943,10 @@
169570 pLoop->cId, (double)sqlite3LogEstToInt(nSearch), pTab->zName,
169571 (double)sqlite3LogEstToInt(pTab->nRowLogEst)));
169572 }
169573 }
169574 nSearch += pLoop->nOut;
169575 if( pWInfo->nOutStarDelta ) nSearch += pLoop->rStarDelta;
169576 }
169577 }
169578
169579 /*
169580 ** The index pIdx is used by a query and contains one or more expressions.
@@ -170053,11 +170425,12 @@
170053 goto whereBeginError;
170054 }
170055 assert( db->mallocFailed==0 );
170056 #ifdef WHERETRACE_ENABLED
170057 if( sqlite3WhereTrace ){
170058 sqlite3DebugPrintf("---- Solution nRow=%d", pWInfo->nRowOut);
 
170059 if( pWInfo->nOBSat>0 ){
170060 sqlite3DebugPrintf(" ORDERBY=%d,0x%llx", pWInfo->nOBSat, pWInfo->revMask);
170061 }
170062 switch( pWInfo->eDistinct ){
170063 case WHERE_DISTINCT_UNIQUE: {
@@ -170414,10 +170787,11 @@
170414 int pc,
170415 VdbeOp *pOp
170416 ){
170417 if( (db->flags & SQLITE_VdbeAddopTrace)==0 ) return;
170418 sqlite3VdbePrintOp(0, pc, pOp);
 
170419 }
170420 #endif
170421
170422 /*
170423 ** Generate the end of the WHERE loop. See comments on
@@ -172523,11 +172897,11 @@
172523 sqlite3VdbeAddOp4(v, OP_CollSeq, 0,0,0, (const char*)pColl, P4_COLLSEQ);
172524 }
172525 sqlite3VdbeAddOp3(v, bInverse? OP_AggInverse : OP_AggStep,
172526 bInverse, regArg, pWin->regAccum);
172527 sqlite3VdbeAppendP4(v, pFunc, P4_FUNCDEF);
172528 sqlite3VdbeChangeP5(v, (u8)nArg);
172529 if( pWin->bExprArgs ){
172530 sqlite3ReleaseTempRange(pParse, regArg, nArg);
172531 }
172532 }
172533
@@ -173907,10 +174281,15 @@
173907 ** to the original parse.y sources.
173908 */
173909
173910 /* #include "sqliteInt.h" */
173911
 
 
 
 
 
173912 /*
173913 ** Disable all error recovery processing in the parser push-down
173914 ** automaton.
173915 */
173916 #define YYNOERRORRECOVERY 1
@@ -173970,10 +174349,14 @@
173970 ** shared across database connections.
173971 */
173972 static void disableLookaside(Parse *pParse){
173973 sqlite3 *db = pParse->db;
173974 pParse->disableLookaside++;
 
 
 
 
173975 DisableLookaside;
173976 }
173977
173978 #if !defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT) \
173979 && defined(SQLITE_UDL_CAPABLE_PARSER)
@@ -174310,11 +174693,12 @@
174310 #define TK_ASTERISK 180
174311 #define TK_SPAN 181
174312 #define TK_ERROR 182
174313 #define TK_QNUMBER 183
174314 #define TK_SPACE 184
174315 #define TK_ILLEGAL 185
 
174316 #endif
174317 /**************** End token definitions ***************************************/
174318
174319 /* The next sections is a series of control #defines.
174320 ** various aspects of the generated parser.
@@ -174375,35 +174759,35 @@
174375 #ifndef INTERFACE
174376 # define INTERFACE 1
174377 #endif
174378 /************* Begin control #defines *****************************************/
174379 #define YYCODETYPE unsigned short int
174380 #define YYNOCODE 322
174381 #define YYACTIONTYPE unsigned short int
174382 #define YYWILDCARD 102
174383 #define sqlite3ParserTOKENTYPE Token
174384 typedef union {
174385 int yyinit;
174386 sqlite3ParserTOKENTYPE yy0;
174387 ExprList* yy14;
174388 With* yy59;
174389 Cte* yy67;
174390 Upsert* yy122;
174391 IdList* yy132;
174392 int yy144;
174393 const char* yy168;
174394 SrcList* yy203;
174395 Window* yy211;
174396 OnOrUsing yy269;
174397 struct TrigEvent yy286;
174398 struct {int value; int mask;} yy383;
174399 u32 yy391;
174400 TriggerStep* yy427;
174401 Expr* yy454;
174402 u8 yy462;
174403 struct FrameBound yy509;
174404 Select* yy555;
174405 } YYMINORTYPE;
174406 #ifndef YYSTACKDEPTH
174407 #define YYSTACKDEPTH 100
174408 #endif
174409 #define sqlite3ParserARG_SDECL
@@ -174421,21 +174805,21 @@
174421 #define sqlite3ParserCTX_STORE yypParser->pParse=pParse;
174422 #define YYFALLBACK 1
174423 #define YYNSTATE 583
174424 #define YYNRULE 409
174425 #define YYNRULE_WITH_ACTION 344
174426 #define YYNTOKEN 186
174427 #define YY_MAX_SHIFT 582
174428 #define YY_MIN_SHIFTREDUCE 845
174429 #define YY_MAX_SHIFTREDUCE 1253
174430 #define YY_ERROR_ACTION 1254
174431 #define YY_ACCEPT_ACTION 1255
174432 #define YY_NO_ACTION 1256
174433 #define YY_MIN_REDUCE 1257
174434 #define YY_MAX_REDUCE 1665
174435 #define YY_MIN_DSTRCTR 205
174436 #define YY_MAX_DSTRCTR 319
174437 /************* End control #defines *******************************************/
174438 #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])))
174439
174440 /* Define the yytestcase() macro to be a no-op if is not already defined
174441 ** otherwise.
@@ -174527,573 +174911,573 @@
174527 /* 60 */ 288, 288, 182, 288, 288, 481, 536, 288, 288, 130,
174528 /* 70 */ 127, 234, 432, 573, 525, 562, 573, 557, 562, 1290,
174529 /* 80 */ 573, 421, 562, 137, 138, 91, 559, 1228, 1228, 1063,
174530 /* 90 */ 1066, 1053, 1053, 135, 135, 136, 136, 136, 136, 296,
174531 /* 100 */ 460, 398, 1249, 134, 134, 134, 134, 133, 133, 132,
174532 /* 110 */ 132, 132, 131, 128, 451, 44, 1050, 1050, 1064, 1067,
174533 /* 120 */ 1255, 1, 1, 582, 2, 1259, 581, 1174, 1259, 1174,
174534 /* 130 */ 321, 413, 155, 321, 1584, 155, 379, 112, 498, 1341,
174535 /* 140 */ 456, 299, 1341, 134, 134, 134, 134, 133, 133, 132,
174536 /* 150 */ 132, 132, 131, 128, 451, 137, 138, 91, 1105, 1228,
174537 /* 160 */ 1228, 1063, 1066, 1053, 1053, 135, 135, 136, 136, 136,
174538 /* 170 */ 136, 1204, 320, 567, 288, 288, 283, 288, 288, 523,
174539 /* 180 */ 523, 1250, 139, 1541, 7, 214, 503, 573, 1169, 562,
174540 /* 190 */ 573, 1054, 562, 136, 136, 136, 136, 129, 401, 547,
174541 /* 200 */ 487, 1169, 245, 1568, 1169, 245, 133, 133, 132, 132,
174542 /* 210 */ 132, 131, 128, 451, 261, 134, 134, 134, 134, 133,
174543 /* 220 */ 133, 132, 132, 132, 131, 128, 451, 451, 1204, 1205,
174544 /* 230 */ 1204, 130, 127, 234, 455, 413, 182, 455, 130, 127,
174545 /* 240 */ 234, 134, 134, 134, 134, 133, 133, 132, 132, 132,
174546 /* 250 */ 131, 128, 451, 136, 136, 136, 136, 538, 576, 137,
174547 /* 260 */ 138, 91, 261, 1228, 1228, 1063, 1066, 1053, 1053, 135,
174548 /* 270 */ 135, 136, 136, 136, 136, 44, 472, 346, 1204, 472,
174549 /* 280 */ 346, 51, 51, 418, 93, 157, 134, 134, 134, 134,
174550 /* 290 */ 133, 133, 132, 132, 132, 131, 128, 451, 166, 363,
174551 /* 300 */ 298, 134, 134, 134, 134, 133, 133, 132, 132, 132,
174552 /* 310 */ 131, 128, 451, 1293, 461, 1570, 423, 377, 275, 134,
174553 /* 320 */ 134, 134, 134, 133, 133, 132, 132, 132, 131, 128,
174554 /* 330 */ 451, 418, 320, 567, 1292, 1204, 1205, 1204, 257, 413,
174555 /* 340 */ 483, 511, 508, 507, 94, 132, 132, 132, 131, 128,
174556 /* 350 */ 451, 506, 1204, 548, 548, 388, 576, 384, 7, 413,
174557 /* 360 */ 550, 229, 522, 137, 138, 91, 530, 1228, 1228, 1063,
174558 /* 370 */ 1066, 1053, 1053, 135, 135, 136, 136, 136, 136, 51,
174559 /* 380 */ 51, 1582, 380, 137, 138, 91, 331, 1228, 1228, 1063,
174560 /* 390 */ 1066, 1053, 1053, 135, 135, 136, 136, 136, 136, 320,
174561 /* 400 */ 567, 288, 288, 320, 567, 1602, 582, 2, 1259, 1204,
174562 /* 410 */ 1205, 1204, 1628, 321, 573, 155, 562, 576, 1511, 264,
174563 /* 420 */ 231, 520, 1341, 134, 134, 134, 134, 133, 133, 132,
174564 /* 430 */ 132, 132, 131, 128, 451, 519, 1511, 1513, 1333, 1333,
174565 /* 440 */ 82, 82, 498, 134, 134, 134, 134, 133, 133, 132,
174566 /* 450 */ 132, 132, 131, 128, 451, 1435, 257, 288, 288, 511,
174567 /* 460 */ 508, 507, 944, 1568, 413, 1019, 1204, 943, 360, 506,
174568 /* 470 */ 573, 1598, 562, 44, 575, 551, 551, 557, 1107, 1582,
174569 /* 480 */ 544, 576, 1107, 40, 417, 245, 531, 1505, 137, 138,
174570 /* 490 */ 91, 219, 1228, 1228, 1063, 1066, 1053, 1053, 135, 135,
174571 /* 500 */ 136, 136, 136, 136, 81, 81, 1281, 1204, 413, 553,
174572 /* 510 */ 1511, 48, 512, 448, 447, 493, 578, 455, 578, 344,
174573 /* 520 */ 45, 1204, 1233, 1204, 1205, 1204, 428, 1235, 158, 882,
174574 /* 530 */ 320, 567, 137, 138, 91, 1234, 1228, 1228, 1063, 1066,
174575 /* 540 */ 1053, 1053, 135, 135, 136, 136, 136, 136, 134, 134,
174576 /* 550 */ 134, 134, 133, 133, 132, 132, 132, 131, 128, 451,
174577 /* 560 */ 1236, 576, 1236, 329, 1204, 1205, 1204, 387, 492, 403,
174578 /* 570 */ 1040, 382, 489, 123, 568, 1569, 4, 377, 1204, 1205,
174579 /* 580 */ 1204, 570, 570, 570, 82, 82, 882, 1029, 1331, 1331,
174580 /* 590 */ 571, 1028, 134, 134, 134, 134, 133, 133, 132, 132,
174581 /* 600 */ 132, 131, 128, 451, 288, 288, 1281, 1204, 576, 423,
174582 /* 610 */ 576, 1568, 413, 423, 452, 378, 886, 573, 1279, 562,
174583 /* 620 */ 46, 557, 532, 1028, 1028, 1030, 565, 130, 127, 234,
174584 /* 630 */ 556, 82, 82, 82, 82, 479, 137, 138, 91, 462,
174585 /* 640 */ 1228, 1228, 1063, 1066, 1053, 1053, 135, 135, 136, 136,
174586 /* 650 */ 136, 136, 1188, 487, 1506, 1040, 413, 6, 1204, 50,
174587 /* 660 */ 879, 121, 121, 948, 1204, 1205, 1204, 358, 557, 122,
174588 /* 670 */ 316, 452, 577, 452, 535, 1204, 1028, 439, 303, 212,
174589 /* 680 */ 137, 138, 91, 213, 1228, 1228, 1063, 1066, 1053, 1053,
174590 /* 690 */ 135, 135, 136, 136, 136, 136, 134, 134, 134, 134,
174591 /* 700 */ 133, 133, 132, 132, 132, 131, 128, 451, 1028, 1028,
174592 /* 710 */ 1030, 1031, 35, 288, 288, 1204, 1205, 1204, 1040, 1339,
174593 /* 720 */ 533, 123, 568, 1569, 4, 377, 573, 1019, 562, 353,
174594 /* 730 */ 1277, 356, 1204, 1205, 1204, 1029, 488, 1188, 571, 1028,
174595 /* 740 */ 134, 134, 134, 134, 133, 133, 132, 132, 132, 131,
174596 /* 750 */ 128, 451, 576, 343, 288, 288, 449, 449, 449, 971,
174597 /* 760 */ 413, 1627, 452, 911, 1187, 288, 288, 573, 464, 562,
174598 /* 770 */ 238, 1028, 1028, 1030, 565, 82, 82, 498, 573, 411,
174599 /* 780 */ 562, 344, 467, 332, 137, 138, 91, 197, 1228, 1228,
174600 /* 790 */ 1063, 1066, 1053, 1053, 135, 135, 136, 136, 136, 136,
174601 /* 800 */ 1188, 528, 1169, 1040, 413, 1110, 1110, 495, 1041, 121,
174602 /* 810 */ 121, 1204, 317, 540, 862, 1169, 1244, 122, 1169, 452,
174603 /* 820 */ 577, 452, 1340, 198, 1028, 1204, 481, 526, 137, 138,
174604 /* 830 */ 91, 560, 1228, 1228, 1063, 1066, 1053, 1053, 135, 135,
174605 /* 840 */ 136, 136, 136, 136, 134, 134, 134, 134, 133, 133,
174606 /* 850 */ 132, 132, 132, 131, 128, 451, 1028, 1028, 1030, 1031,
174607 /* 860 */ 35, 1204, 288, 288, 1204, 477, 288, 288, 1204, 1205,
174608 /* 870 */ 1204, 539, 481, 437, 470, 573, 1451, 562, 364, 573,
174609 /* 880 */ 1153, 562, 1204, 1205, 1204, 1188, 5, 576, 134, 134,
174610 /* 890 */ 134, 134, 133, 133, 132, 132, 132, 131, 128, 451,
174611 /* 900 */ 221, 214, 302, 96, 1149, 1657, 232, 1657, 413, 392,
174612 /* 910 */ 19, 19, 1024, 949, 406, 373, 1595, 1085, 1204, 1205,
174613 /* 920 */ 1204, 1204, 1205, 1204, 1204, 426, 1149, 1658, 413, 1658,
174614 /* 930 */ 1659, 399, 137, 138, 91, 3, 1228, 1228, 1063, 1066,
174615 /* 940 */ 1053, 1053, 135, 135, 136, 136, 136, 136, 304, 1311,
174616 /* 950 */ 514, 1204, 137, 138, 91, 1498, 1228, 1228, 1063, 1066,
174617 /* 960 */ 1053, 1053, 135, 135, 136, 136, 136, 136, 434, 131,
174618 /* 970 */ 128, 451, 375, 1204, 274, 291, 372, 517, 367, 516,
174619 /* 980 */ 262, 1204, 1205, 1204, 1147, 227, 363, 448, 447, 1435,
174620 /* 990 */ 1568, 1310, 134, 134, 134, 134, 133, 133, 132, 132,
174621 /* 1000 */ 132, 131, 128, 451, 1568, 576, 1147, 487, 1204, 1205,
174622 /* 1010 */ 1204, 442, 134, 134, 134, 134, 133, 133, 132, 132,
174623 /* 1020 */ 132, 131, 128, 451, 386, 576, 485, 576, 19, 19,
174624 /* 1030 */ 1204, 1205, 1204, 1345, 1236, 970, 1236, 574, 47, 936,
174625 /* 1040 */ 936, 473, 413, 431, 1552, 573, 1125, 562, 19, 19,
174626 /* 1050 */ 19, 19, 49, 336, 850, 851, 852, 111, 1368, 315,
174627 /* 1060 */ 429, 576, 413, 433, 341, 306, 137, 138, 91, 115,
174628 /* 1070 */ 1228, 1228, 1063, 1066, 1053, 1053, 135, 135, 136, 136,
174629 /* 1080 */ 136, 136, 576, 1309, 82, 82, 137, 138, 91, 529,
174630 /* 1090 */ 1228, 1228, 1063, 1066, 1053, 1053, 135, 135, 136, 136,
174631 /* 1100 */ 136, 136, 1569, 222, 377, 19, 19, 305, 1126, 1169,
174632 /* 1110 */ 398, 1148, 22, 22, 498, 333, 1569, 335, 377, 576,
174633 /* 1120 */ 438, 445, 1169, 1127, 486, 1169, 134, 134, 134, 134,
174634 /* 1130 */ 133, 133, 132, 132, 132, 131, 128, 451, 1128, 576,
174635 /* 1140 */ 902, 576, 145, 145, 6, 576, 134, 134, 134, 134,
174636 /* 1150 */ 133, 133, 132, 132, 132, 131, 128, 451, 214, 1336,
174637 /* 1160 */ 922, 576, 19, 19, 19, 19, 1282, 419, 19, 19,
174638 /* 1170 */ 923, 412, 515, 141, 576, 1169, 413, 206, 465, 207,
174639 /* 1180 */ 903, 215, 1575, 552, 147, 147, 7, 227, 1169, 411,
174640 /* 1190 */ 1250, 1169, 120, 307, 117, 307, 413, 66, 66, 334,
174641 /* 1200 */ 137, 138, 91, 119, 1228, 1228, 1063, 1066, 1053, 1053,
174642 /* 1210 */ 135, 135, 136, 136, 136, 136, 413, 285, 209, 969,
174643 /* 1220 */ 137, 138, 91, 471, 1228, 1228, 1063, 1066, 1053, 1053,
174644 /* 1230 */ 135, 135, 136, 136, 136, 136, 435, 10, 1450, 267,
174645 /* 1240 */ 137, 126, 91, 1435, 1228, 1228, 1063, 1066, 1053, 1053,
174646 /* 1250 */ 135, 135, 136, 136, 136, 136, 1435, 1435, 410, 409,
174647 /* 1260 */ 134, 134, 134, 134, 133, 133, 132, 132, 132, 131,
174648 /* 1270 */ 128, 451, 576, 969, 576, 1224, 498, 373, 1595, 1554,
174649 /* 1280 */ 134, 134, 134, 134, 133, 133, 132, 132, 132, 131,
174650 /* 1290 */ 128, 451, 532, 457, 576, 82, 82, 82, 82, 111,
174651 /* 1300 */ 134, 134, 134, 134, 133, 133, 132, 132, 132, 131,
174652 /* 1310 */ 128, 451, 109, 233, 430, 1576, 546, 67, 67, 7,
174653 /* 1320 */ 413, 351, 550, 1550, 260, 259, 258, 494, 443, 569,
174654 /* 1330 */ 419, 983, 446, 1224, 450, 545, 1207, 576, 969, 984,
174655 /* 1340 */ 413, 475, 1449, 1574, 1180, 138, 91, 7, 1228, 1228,
174656 /* 1350 */ 1063, 1066, 1053, 1053, 135, 135, 136, 136, 136, 136,
174657 /* 1360 */ 21, 21, 267, 576, 300, 1126, 91, 233, 1228, 1228,
174658 /* 1370 */ 1063, 1066, 1053, 1053, 135, 135, 136, 136, 136, 136,
174659 /* 1380 */ 1127, 373, 1595, 161, 1573, 16, 53, 53, 7, 108,
174660 /* 1390 */ 533, 38, 969, 125, 1207, 1128, 1180, 576, 1224, 123,
174661 /* 1400 */ 568, 893, 4, 324, 134, 134, 134, 134, 133, 133,
174662 /* 1410 */ 132, 132, 132, 131, 128, 451, 571, 564, 534, 576,
174663 /* 1420 */ 68, 68, 576, 39, 134, 134, 134, 134, 133, 133,
174664 /* 1430 */ 132, 132, 132, 131, 128, 451, 576, 160, 1571, 1223,
174665 /* 1440 */ 452, 576, 54, 54, 576, 69, 69, 576, 1366, 576,
174666 /* 1450 */ 420, 184, 565, 463, 297, 576, 1224, 463, 297, 70,
174667 /* 1460 */ 70, 576, 44, 474, 71, 71, 576, 72, 72, 576,
174668 /* 1470 */ 73, 73, 55, 55, 411, 874, 242, 576, 56, 56,
174669 /* 1480 */ 576, 1040, 576, 478, 57, 57, 576, 121, 121, 59,
174670 /* 1490 */ 59, 23, 60, 60, 411, 122, 319, 452, 577, 452,
174671 /* 1500 */ 74, 74, 1028, 75, 75, 76, 76, 411, 290, 20,
174672 /* 1510 */ 20, 108, 287, 231, 553, 123, 568, 325, 4, 320,
174673 /* 1520 */ 567, 97, 218, 944, 1144, 328, 400, 576, 943, 576,
174674 /* 1530 */ 1380, 424, 571, 874, 1028, 1028, 1030, 1031, 35, 293,
174675 /* 1540 */ 534, 576, 1104, 576, 1104, 9, 576, 342, 576, 111,
174676 /* 1550 */ 77, 77, 143, 143, 576, 205, 452, 222, 1379, 889,
174677 /* 1560 */ 576, 901, 900, 1188, 144, 144, 78, 78, 565, 62,
174678 /* 1570 */ 62, 79, 79, 323, 1021, 576, 266, 63, 63, 908,
174679 /* 1580 */ 909, 1589, 542, 80, 80, 576, 371, 541, 123, 568,
174680 /* 1590 */ 480, 4, 266, 482, 244, 266, 370, 1040, 64, 64,
174681 /* 1600 */ 576, 466, 576, 121, 121, 571, 1557, 576, 170, 170,
174682 /* 1610 */ 576, 122, 576, 452, 577, 452, 576, 889, 1028, 576,
174683 /* 1620 */ 165, 576, 111, 171, 171, 87, 87, 337, 1616, 452,
174684 /* 1630 */ 65, 65, 1530, 83, 83, 146, 146, 986, 987, 84,
174685 /* 1640 */ 84, 565, 168, 168, 148, 148, 1092, 347, 1032, 111,
174686 /* 1650 */ 1028, 1028, 1030, 1031, 35, 542, 1103, 576, 1103, 576,
174687 /* 1660 */ 543, 123, 568, 504, 4, 263, 576, 361, 1529, 111,
174688 /* 1670 */ 1040, 1088, 576, 263, 576, 490, 121, 121, 571, 1188,
174689 /* 1680 */ 142, 142, 169, 169, 122, 576, 452, 577, 452, 162,
174690 /* 1690 */ 162, 1028, 576, 563, 576, 152, 152, 151, 151, 348,
174691 /* 1700 */ 1376, 974, 452, 266, 1092, 942, 1032, 125, 149, 149,
174692 /* 1710 */ 939, 576, 125, 576, 565, 150, 150, 86, 86, 872,
174693 /* 1720 */ 352, 159, 576, 1028, 1028, 1030, 1031, 35, 542, 941,
174694 /* 1730 */ 576, 125, 355, 541, 88, 88, 85, 85, 357, 359,
174695 /* 1740 */ 1324, 1308, 366, 1040, 376, 52, 52, 499, 1389, 121,
174696 /* 1750 */ 121, 1434, 1188, 58, 58, 1362, 1374, 122, 1439, 452,
174697 /* 1760 */ 577, 452, 1289, 167, 1028, 1280, 280, 1268, 1267, 1269,
174698 /* 1770 */ 1609, 1359, 312, 313, 12, 314, 397, 1421, 224, 1416,
174699 /* 1780 */ 295, 237, 1409, 339, 340, 1426, 301, 345, 484, 228,
174700 /* 1790 */ 1371, 1307, 1372, 1370, 1425, 404, 1028, 1028, 1030, 1031,
174701 /* 1800 */ 35, 1601, 1192, 454, 509, 369, 292, 1502, 210, 1501,
174702 /* 1810 */ 1369, 396, 396, 395, 277, 393, 211, 566, 859, 1612,
174703 /* 1820 */ 1244, 123, 568, 391, 4, 1188, 223, 270, 1549, 1547,
174704 /* 1830 */ 1241, 239, 186, 327, 422, 96, 195, 220, 571, 235,
174705 /* 1840 */ 180, 326, 188, 468, 190, 1507, 191, 192, 92, 193,
174706 /* 1850 */ 469, 95, 1422, 13, 502, 247, 1430, 109, 199, 402,
174707 /* 1860 */ 476, 405, 452, 1496, 1428, 1427, 14, 491, 251, 102,
174708 /* 1870 */ 497, 1518, 241, 281, 565, 253, 203, 354, 500, 254,
174709 /* 1880 */ 175, 1270, 407, 43, 350, 518, 1327, 436, 255, 1326,
174710 /* 1890 */ 1325, 1318, 104, 893, 1626, 229, 408, 440, 1625, 441,
174711 /* 1900 */ 240, 310, 1296, 1040, 311, 1317, 527, 1594, 1297, 121,
174712 /* 1910 */ 121, 368, 1295, 1624, 268, 269, 1580, 122, 1579, 452,
174713 /* 1920 */ 577, 452, 374, 444, 1028, 1394, 1393, 140, 553, 90,
174714 /* 1930 */ 568, 11, 4, 1483, 383, 414, 385, 110, 116, 216,
174715 /* 1940 */ 320, 567, 1350, 555, 42, 318, 571, 537, 1349, 389,
174716 /* 1950 */ 390, 579, 1198, 276, 279, 278, 1028, 1028, 1030, 1031,
174717 /* 1960 */ 35, 580, 415, 1265, 458, 1260, 416, 185, 1534, 172,
174718 /* 1970 */ 452, 1535, 173, 156, 308, 846, 1533, 1532, 453, 217,
174719 /* 1980 */ 225, 89, 565, 174, 322, 1188, 226, 236, 1102, 154,
174720 /* 1990 */ 1100, 330, 176, 187, 1223, 189, 925, 338, 243, 1116,
174721 /* 2000 */ 246, 194, 177, 178, 425, 427, 98, 99, 196, 100,
174722 /* 2010 */ 101, 1040, 179, 1119, 248, 1115, 249, 121, 121, 24,
174723 /* 2020 */ 163, 250, 349, 1108, 266, 122, 1238, 452, 577, 452,
174724 /* 2030 */ 1192, 454, 1028, 200, 292, 496, 252, 201, 861, 396,
174725 /* 2040 */ 396, 395, 277, 393, 15, 501, 859, 370, 292, 256,
174726 /* 2050 */ 202, 554, 505, 396, 396, 395, 277, 393, 103, 239,
174727 /* 2060 */ 859, 327, 25, 26, 1028, 1028, 1030, 1031, 35, 326,
174728 /* 2070 */ 362, 510, 891, 239, 365, 327, 513, 904, 105, 309,
174729 /* 2080 */ 164, 181, 27, 326, 106, 521, 107, 1185, 1069, 1155,
174730 /* 2090 */ 17, 1154, 284, 1188, 286, 978, 265, 204, 125, 1171,
174731 /* 2100 */ 241, 230, 972, 1175, 28, 1160, 29, 1179, 175, 1173,
174732 /* 2110 */ 30, 43, 31, 1178, 241, 32, 41, 549, 8, 33,
174733 /* 2120 */ 208, 111, 175, 1083, 1070, 43, 113, 1068, 240, 114,
174734 /* 2130 */ 1072, 34, 1073, 561, 1124, 118, 271, 36, 18, 1194,
174735 /* 2140 */ 1033, 873, 240, 935, 124, 37, 272, 273, 1617, 572,
174736 /* 2150 */ 183, 153, 394, 1193, 1256, 1256, 1256, 1256, 1256, 1256,
174737 /* 2160 */ 1256, 1256, 1256, 414, 1256, 1256, 1256, 1256, 320, 567,
174738 /* 2170 */ 1256, 1256, 1256, 1256, 1256, 1256, 1256, 414, 1256, 1256,
174739 /* 2180 */ 1256, 1256, 320, 567, 1256, 1256, 1256, 1256, 1256, 1256,
174740 /* 2190 */ 1256, 1256, 458, 1256, 1256, 1256, 1256, 1256, 1256, 1256,
174741 /* 2200 */ 1256, 1256, 1256, 1256, 1256, 1256, 458,
174742 };
174743 static const YYCODETYPE yy_lookahead[] = {
174744 /* 0 */ 276, 277, 278, 240, 241, 224, 194, 226, 194, 240,
174745 /* 10 */ 241, 194, 216, 220, 194, 234, 253, 194, 255, 19,
174746 /* 20 */ 224, 297, 253, 194, 255, 205, 212, 213, 205, 217,
174747 /* 30 */ 218, 31, 205, 194, 217, 218, 194, 217, 218, 39,
174748 /* 40 */ 217, 218, 312, 43, 44, 45, 316, 47, 48, 49,
174749 /* 50 */ 50, 51, 52, 53, 54, 55, 56, 57, 58, 19,
174750 /* 60 */ 240, 241, 194, 240, 241, 194, 254, 240, 241, 276,
174751 /* 70 */ 277, 278, 233, 253, 254, 255, 253, 254, 255, 217,
174752 /* 80 */ 253, 239, 255, 43, 44, 45, 263, 47, 48, 49,
174753 /* 90 */ 50, 51, 52, 53, 54, 55, 56, 57, 58, 270,
174754 /* 100 */ 286, 22, 23, 103, 104, 105, 106, 107, 108, 109,
174755 /* 110 */ 110, 111, 112, 113, 114, 82, 47, 48, 49, 50,
174756 /* 120 */ 186, 187, 188, 189, 190, 191, 189, 87, 191, 89,
174757 /* 130 */ 196, 19, 198, 196, 317, 198, 319, 25, 194, 205,
174758 /* 140 */ 298, 270, 205, 103, 104, 105, 106, 107, 108, 109,
174759 /* 150 */ 110, 111, 112, 113, 114, 43, 44, 45, 11, 47,
174760 /* 160 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
174761 /* 170 */ 58, 60, 139, 140, 240, 241, 214, 240, 241, 311,
174762 /* 180 */ 312, 102, 70, 239, 316, 194, 19, 253, 77, 255,
174763 /* 190 */ 253, 122, 255, 55, 56, 57, 58, 59, 207, 88,
174764 /* 200 */ 194, 90, 268, 194, 93, 268, 107, 108, 109, 110,
174765 /* 210 */ 111, 112, 113, 114, 47, 103, 104, 105, 106, 107,
174766 /* 220 */ 108, 109, 110, 111, 112, 113, 114, 114, 117, 118,
174767 /* 230 */ 119, 276, 277, 278, 300, 19, 194, 300, 276, 277,
174768 /* 240 */ 278, 103, 104, 105, 106, 107, 108, 109, 110, 111,
174769 /* 250 */ 112, 113, 114, 55, 56, 57, 58, 146, 194, 43,
174770 /* 260 */ 44, 45, 47, 47, 48, 49, 50, 51, 52, 53,
174771 /* 270 */ 54, 55, 56, 57, 58, 82, 129, 130, 60, 129,
174772 /* 280 */ 130, 217, 218, 116, 68, 25, 103, 104, 105, 106,
174773 /* 290 */ 107, 108, 109, 110, 111, 112, 113, 114, 23, 132,
174774 /* 300 */ 294, 103, 104, 105, 106, 107, 108, 109, 110, 111,
174775 /* 310 */ 112, 113, 114, 217, 121, 306, 194, 308, 26, 103,
174776 /* 320 */ 104, 105, 106, 107, 108, 109, 110, 111, 112, 113,
174777 /* 330 */ 114, 116, 139, 140, 217, 117, 118, 119, 120, 19,
174778 /* 340 */ 194, 123, 124, 125, 24, 109, 110, 111, 112, 113,
174779 /* 350 */ 114, 133, 60, 311, 312, 250, 194, 252, 316, 19,
174780 /* 360 */ 194, 166, 167, 43, 44, 45, 205, 47, 48, 49,
174781 /* 370 */ 50, 51, 52, 53, 54, 55, 56, 57, 58, 217,
174782 /* 380 */ 218, 317, 318, 43, 44, 45, 264, 47, 48, 49,
174783 /* 390 */ 50, 51, 52, 53, 54, 55, 56, 57, 58, 139,
174784 /* 400 */ 140, 240, 241, 139, 140, 188, 189, 190, 191, 117,
174785 /* 410 */ 118, 119, 231, 196, 253, 198, 255, 194, 194, 258,
174786 /* 420 */ 259, 146, 205, 103, 104, 105, 106, 107, 108, 109,
174787 /* 430 */ 110, 111, 112, 113, 114, 109, 212, 213, 236, 237,
174788 /* 440 */ 217, 218, 194, 103, 104, 105, 106, 107, 108, 109,
174789 /* 450 */ 110, 111, 112, 113, 114, 194, 120, 240, 241, 123,
174790 /* 460 */ 124, 125, 136, 194, 19, 74, 60, 141, 23, 133,
174791 /* 470 */ 253, 194, 255, 82, 194, 309, 310, 254, 29, 317,
174792 /* 480 */ 318, 194, 33, 22, 199, 268, 263, 239, 43, 44,
174793 /* 490 */ 45, 151, 47, 48, 49, 50, 51, 52, 53, 54,
174794 /* 500 */ 55, 56, 57, 58, 217, 218, 194, 60, 19, 146,
174795 /* 510 */ 286, 242, 23, 107, 108, 66, 204, 300, 206, 128,
174796 /* 520 */ 73, 60, 116, 117, 118, 119, 265, 121, 165, 60,
174797 /* 530 */ 139, 140, 43, 44, 45, 129, 47, 48, 49, 50,
174798 /* 540 */ 51, 52, 53, 54, 55, 56, 57, 58, 103, 104,
174799 /* 550 */ 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
174800 /* 560 */ 154, 194, 156, 194, 117, 118, 119, 280, 283, 205,
174801 /* 570 */ 101, 220, 287, 19, 20, 306, 22, 308, 117, 118,
174802 /* 580 */ 119, 211, 212, 213, 217, 218, 117, 118, 236, 237,
174803 /* 590 */ 36, 122, 103, 104, 105, 106, 107, 108, 109, 110,
174804 /* 600 */ 111, 112, 113, 114, 240, 241, 194, 60, 194, 194,
174805 /* 610 */ 194, 194, 19, 194, 60, 194, 23, 253, 206, 255,
174806 /* 620 */ 73, 254, 19, 154, 155, 156, 72, 276, 277, 278,
174807 /* 630 */ 263, 217, 218, 217, 218, 271, 43, 44, 45, 271,
174808 /* 640 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
174809 /* 650 */ 57, 58, 183, 194, 285, 101, 19, 214, 60, 242,
174810 /* 660 */ 23, 107, 108, 109, 117, 118, 119, 16, 254, 115,
174811 /* 670 */ 254, 117, 118, 119, 194, 60, 122, 263, 205, 264,
174812 /* 680 */ 43, 44, 45, 264, 47, 48, 49, 50, 51, 52,
174813 /* 690 */ 53, 54, 55, 56, 57, 58, 103, 104, 105, 106,
174814 /* 700 */ 107, 108, 109, 110, 111, 112, 113, 114, 154, 155,
174815 /* 710 */ 156, 157, 158, 240, 241, 117, 118, 119, 101, 205,
174816 /* 720 */ 117, 19, 20, 306, 22, 308, 253, 74, 255, 78,
174817 /* 730 */ 205, 80, 117, 118, 119, 118, 293, 183, 36, 122,
174818 /* 740 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
174819 /* 750 */ 113, 114, 194, 294, 240, 241, 211, 212, 213, 144,
174820 /* 760 */ 19, 23, 60, 25, 23, 240, 241, 253, 245, 255,
174821 /* 770 */ 15, 154, 155, 156, 72, 217, 218, 194, 253, 256,
174822 /* 780 */ 255, 128, 129, 130, 43, 44, 45, 22, 47, 48,
174823 /* 790 */ 49, 50, 51, 52, 53, 54, 55, 56, 57, 58,
174824 /* 800 */ 183, 19, 77, 101, 19, 128, 129, 130, 23, 107,
174825 /* 810 */ 108, 60, 254, 88, 21, 90, 61, 115, 93, 117,
174826 /* 820 */ 118, 119, 239, 22, 122, 60, 194, 205, 43, 44,
174827 /* 830 */ 45, 205, 47, 48, 49, 50, 51, 52, 53, 54,
174828 /* 840 */ 55, 56, 57, 58, 103, 104, 105, 106, 107, 108,
174829 /* 850 */ 109, 110, 111, 112, 113, 114, 154, 155, 156, 157,
174830 /* 860 */ 158, 60, 240, 241, 60, 116, 240, 241, 117, 118,
174831 /* 870 */ 119, 146, 194, 19, 81, 253, 275, 255, 24, 253,
174832 /* 880 */ 98, 255, 117, 118, 119, 183, 22, 194, 103, 104,
174833 /* 890 */ 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
174834 /* 900 */ 151, 194, 270, 152, 22, 23, 194, 25, 19, 202,
174835 /* 910 */ 217, 218, 23, 109, 207, 314, 315, 124, 117, 118,
174836 /* 920 */ 119, 117, 118, 119, 60, 232, 22, 23, 19, 25,
174837 /* 930 */ 303, 304, 43, 44, 45, 22, 47, 48, 49, 50,
174838 /* 940 */ 51, 52, 53, 54, 55, 56, 57, 58, 270, 227,
174839 /* 950 */ 96, 60, 43, 44, 45, 162, 47, 48, 49, 50,
174840 /* 960 */ 51, 52, 53, 54, 55, 56, 57, 58, 114, 112,
174841 /* 970 */ 113, 114, 194, 60, 120, 121, 122, 123, 124, 125,
174842 /* 980 */ 126, 117, 118, 119, 102, 25, 132, 107, 108, 194,
174843 /* 990 */ 194, 227, 103, 104, 105, 106, 107, 108, 109, 110,
174844 /* 1000 */ 111, 112, 113, 114, 194, 194, 102, 194, 117, 118,
174845 /* 1010 */ 119, 233, 103, 104, 105, 106, 107, 108, 109, 110,
174846 /* 1020 */ 111, 112, 113, 114, 194, 194, 19, 194, 217, 218,
174847 /* 1030 */ 117, 118, 119, 241, 154, 144, 156, 135, 242, 137,
174848 /* 1040 */ 138, 130, 19, 232, 194, 253, 23, 255, 217, 218,
174849 /* 1050 */ 217, 218, 242, 16, 7, 8, 9, 25, 261, 262,
174850 /* 1060 */ 265, 194, 19, 232, 153, 232, 43, 44, 45, 160,
174851 /* 1070 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
174852 /* 1080 */ 57, 58, 194, 227, 217, 218, 43, 44, 45, 194,
174853 /* 1090 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
174854 /* 1100 */ 57, 58, 306, 143, 308, 217, 218, 294, 12, 77,
174855 /* 1110 */ 22, 23, 217, 218, 194, 78, 306, 80, 308, 194,
174856 /* 1120 */ 232, 254, 90, 27, 117, 93, 103, 104, 105, 106,
174857 /* 1130 */ 107, 108, 109, 110, 111, 112, 113, 114, 42, 194,
174858 /* 1140 */ 35, 194, 217, 218, 214, 194, 103, 104, 105, 106,
174859 /* 1150 */ 107, 108, 109, 110, 111, 112, 113, 114, 194, 239,
174860 /* 1160 */ 64, 194, 217, 218, 217, 218, 209, 210, 217, 218,
174861 /* 1170 */ 74, 207, 67, 22, 194, 77, 19, 232, 245, 232,
174862 /* 1180 */ 75, 24, 312, 232, 217, 218, 316, 25, 90, 256,
174863 /* 1190 */ 102, 93, 159, 229, 161, 231, 19, 217, 218, 162,
174864 /* 1200 */ 43, 44, 45, 160, 47, 48, 49, 50, 51, 52,
174865 /* 1210 */ 53, 54, 55, 56, 57, 58, 19, 23, 288, 25,
174866 /* 1220 */ 43, 44, 45, 293, 47, 48, 49, 50, 51, 52,
174867 /* 1230 */ 53, 54, 55, 56, 57, 58, 131, 22, 275, 24,
174868 /* 1240 */ 43, 44, 45, 194, 47, 48, 49, 50, 51, 52,
174869 /* 1250 */ 53, 54, 55, 56, 57, 58, 194, 194, 107, 108,
174870 /* 1260 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
174871 /* 1270 */ 113, 114, 194, 25, 194, 60, 194, 314, 315, 194,
174872 /* 1280 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
174873 /* 1290 */ 113, 114, 19, 194, 194, 217, 218, 217, 218, 25,
174874 /* 1300 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
174875 /* 1310 */ 113, 114, 150, 119, 265, 312, 67, 217, 218, 316,
174876 /* 1320 */ 19, 239, 194, 194, 128, 129, 130, 265, 265, 209,
174877 /* 1330 */ 210, 31, 254, 118, 254, 86, 60, 194, 144, 39,
174878 /* 1340 */ 19, 130, 275, 312, 95, 44, 45, 316, 47, 48,
174879 /* 1350 */ 49, 50, 51, 52, 53, 54, 55, 56, 57, 58,
174880 /* 1360 */ 217, 218, 24, 194, 153, 12, 45, 119, 47, 48,
174881 /* 1370 */ 49, 50, 51, 52, 53, 54, 55, 56, 57, 58,
174882 /* 1380 */ 27, 314, 315, 22, 312, 24, 217, 218, 316, 116,
174883 /* 1390 */ 117, 22, 144, 25, 118, 42, 147, 194, 60, 19,
174884 /* 1400 */ 20, 127, 22, 194, 103, 104, 105, 106, 107, 108,
174885 /* 1410 */ 109, 110, 111, 112, 113, 114, 36, 64, 145, 194,
174886 /* 1420 */ 217, 218, 194, 54, 103, 104, 105, 106, 107, 108,
174887 /* 1430 */ 109, 110, 111, 112, 113, 114, 194, 22, 310, 25,
174888 /* 1440 */ 60, 194, 217, 218, 194, 217, 218, 194, 260, 194,
174889 /* 1450 */ 301, 302, 72, 262, 262, 194, 118, 266, 266, 217,
174890 /* 1460 */ 218, 194, 82, 245, 217, 218, 194, 217, 218, 194,
174891 /* 1470 */ 217, 218, 217, 218, 256, 60, 24, 194, 217, 218,
174892 /* 1480 */ 194, 101, 194, 245, 217, 218, 194, 107, 108, 217,
174893 /* 1490 */ 218, 22, 217, 218, 256, 115, 245, 117, 118, 119,
174894 /* 1500 */ 217, 218, 122, 217, 218, 217, 218, 256, 22, 217,
174895 /* 1510 */ 218, 116, 258, 259, 146, 19, 20, 194, 22, 139,
174896 /* 1520 */ 140, 150, 151, 136, 23, 194, 25, 194, 141, 194,
174897 /* 1530 */ 194, 62, 36, 118, 154, 155, 156, 157, 158, 100,
174898 /* 1540 */ 145, 194, 154, 194, 156, 49, 194, 23, 194, 25,
174899 /* 1550 */ 217, 218, 217, 218, 194, 257, 60, 143, 194, 60,
174900 /* 1560 */ 194, 121, 122, 183, 217, 218, 217, 218, 72, 217,
174901 /* 1570 */ 218, 217, 218, 134, 23, 194, 25, 217, 218, 7,
174902 /* 1580 */ 8, 321, 86, 217, 218, 194, 122, 91, 19, 20,
174903 /* 1590 */ 23, 22, 25, 23, 142, 25, 132, 101, 217, 218,
174904 /* 1600 */ 194, 194, 194, 107, 108, 36, 194, 194, 217, 218,
174905 /* 1610 */ 194, 115, 194, 117, 118, 119, 194, 118, 122, 194,
174906 /* 1620 */ 23, 194, 25, 217, 218, 217, 218, 194, 142, 60,
174907 /* 1630 */ 217, 218, 194, 217, 218, 217, 218, 84, 85, 217,
174908 /* 1640 */ 218, 72, 217, 218, 217, 218, 60, 23, 60, 25,
174909 /* 1650 */ 154, 155, 156, 157, 158, 86, 154, 194, 156, 194,
174910 /* 1660 */ 91, 19, 20, 23, 22, 25, 194, 23, 194, 25,
174911 /* 1670 */ 101, 23, 194, 25, 194, 194, 107, 108, 36, 183,
174912 /* 1680 */ 217, 218, 217, 218, 115, 194, 117, 118, 119, 217,
174913 /* 1690 */ 218, 122, 194, 237, 194, 217, 218, 217, 218, 194,
174914 /* 1700 */ 194, 23, 60, 25, 118, 23, 118, 25, 217, 218,
174915 /* 1710 */ 23, 194, 25, 194, 72, 217, 218, 217, 218, 23,
174916 /* 1720 */ 194, 25, 194, 154, 155, 156, 157, 158, 86, 23,
174917 /* 1730 */ 194, 25, 194, 91, 217, 218, 217, 218, 194, 194,
174918 /* 1740 */ 194, 194, 194, 101, 194, 217, 218, 290, 194, 107,
174919 /* 1750 */ 108, 194, 183, 217, 218, 194, 194, 115, 194, 117,
174920 /* 1760 */ 118, 119, 194, 243, 122, 194, 289, 194, 194, 194,
174921 /* 1770 */ 194, 257, 257, 257, 244, 257, 192, 273, 215, 269,
174922 /* 1780 */ 246, 299, 269, 295, 247, 273, 247, 246, 295, 230,
174923 /* 1790 */ 261, 226, 261, 261, 273, 273, 154, 155, 156, 157,
174924 /* 1800 */ 158, 0, 1, 2, 221, 220, 5, 220, 250, 220,
174925 /* 1810 */ 261, 10, 11, 12, 13, 14, 250, 282, 17, 197,
174926 /* 1820 */ 61, 19, 20, 246, 22, 183, 244, 142, 201, 201,
174927 /* 1830 */ 38, 30, 299, 32, 201, 152, 22, 151, 36, 299,
174928 /* 1840 */ 43, 40, 235, 18, 238, 285, 238, 238, 296, 238,
174929 /* 1850 */ 201, 296, 274, 272, 18, 200, 235, 150, 235, 247,
174930 /* 1860 */ 247, 247, 60, 247, 274, 274, 272, 201, 200, 159,
174931 /* 1870 */ 63, 292, 71, 201, 72, 200, 22, 201, 222, 200,
174932 /* 1880 */ 79, 201, 222, 82, 291, 116, 219, 65, 200, 219,
174933 /* 1890 */ 219, 228, 22, 127, 225, 166, 222, 24, 225, 114,
174934 /* 1900 */ 99, 284, 221, 101, 284, 228, 307, 315, 219, 107,
174935 /* 1910 */ 108, 219, 219, 219, 201, 92, 320, 115, 320, 117,
174936 /* 1920 */ 118, 119, 222, 83, 122, 267, 267, 149, 146, 19,
174937 /* 1930 */ 20, 22, 22, 279, 250, 134, 201, 148, 159, 249,
174938 /* 1940 */ 139, 140, 251, 141, 25, 281, 36, 147, 251, 248,
174939 /* 1950 */ 247, 203, 13, 195, 6, 195, 154, 155, 156, 157,
174940 /* 1960 */ 158, 193, 305, 193, 163, 193, 305, 302, 214, 208,
174941 /* 1970 */ 60, 214, 208, 223, 223, 4, 214, 214, 3, 22,
174942 /* 1980 */ 215, 214, 72, 208, 164, 183, 215, 15, 23, 16,
174943 /* 1990 */ 23, 140, 131, 152, 25, 143, 20, 16, 24, 1,
174944 /* 2000 */ 145, 143, 131, 131, 62, 37, 54, 54, 152, 54,
174945 /* 2010 */ 54, 101, 131, 117, 34, 1, 142, 107, 108, 22,
174946 /* 2020 */ 5, 116, 162, 69, 25, 115, 76, 117, 118, 119,
174947 /* 2030 */ 1, 2, 122, 69, 5, 41, 142, 116, 20, 10,
174948 /* 2040 */ 11, 12, 13, 14, 24, 19, 17, 132, 5, 126,
174949 /* 2050 */ 22, 141, 68, 10, 11, 12, 13, 14, 22, 30,
174950 /* 2060 */ 17, 32, 22, 22, 154, 155, 156, 157, 158, 40,
174951 /* 2070 */ 23, 68, 60, 30, 24, 32, 97, 28, 22, 68,
174952 /* 2080 */ 23, 37, 34, 40, 150, 22, 25, 23, 23, 23,
174953 /* 2090 */ 22, 98, 23, 183, 23, 117, 34, 22, 25, 89,
174954 /* 2100 */ 71, 142, 144, 76, 34, 23, 34, 76, 79, 87,
174955 /* 2110 */ 34, 82, 34, 94, 71, 34, 22, 24, 44, 34,
174956 /* 2120 */ 25, 25, 79, 23, 23, 82, 143, 23, 99, 143,
174957 /* 2130 */ 23, 22, 11, 25, 23, 25, 22, 22, 22, 1,
174958 /* 2140 */ 23, 23, 99, 136, 22, 22, 142, 142, 142, 25,
174959 /* 2150 */ 25, 23, 15, 1, 322, 322, 322, 322, 322, 322,
174960 /* 2160 */ 322, 322, 322, 134, 322, 322, 322, 322, 139, 140,
174961 /* 2170 */ 322, 322, 322, 322, 322, 322, 322, 134, 322, 322,
174962 /* 2180 */ 322, 322, 139, 140, 322, 322, 322, 322, 322, 322,
174963 /* 2190 */ 322, 322, 163, 322, 322, 322, 322, 322, 322, 322,
174964 /* 2200 */ 322, 322, 322, 322, 322, 322, 163, 322, 322, 322,
174965 /* 2210 */ 322, 322, 322, 322, 322, 322, 322, 322, 322, 322,
174966 /* 2220 */ 322, 322, 322, 322, 322, 322, 322, 322, 322, 322,
174967 /* 2230 */ 322, 322, 322, 322, 322, 322, 322, 322, 322, 322,
174968 /* 2240 */ 322, 322, 322, 322, 322, 322, 322, 322, 322, 322,
174969 /* 2250 */ 322, 322, 322, 322, 322, 322, 322, 322, 322, 322,
174970 /* 2260 */ 322, 322, 322, 322, 322, 322, 322, 322, 322, 322,
174971 /* 2270 */ 322, 322, 322, 322, 322, 322, 322, 322, 322, 322,
174972 /* 2280 */ 322, 322, 322, 322, 322, 322, 322, 322, 322, 322,
174973 /* 2290 */ 322, 322, 322, 322, 322, 322, 322, 322, 322, 322,
174974 /* 2300 */ 322, 322, 322, 322, 322, 322, 322, 322, 322, 322,
174975 /* 2310 */ 322, 322, 322, 322, 322, 322, 322, 322, 322, 322,
174976 /* 2320 */ 322, 322, 322, 322, 322, 322, 322, 322, 322, 322,
174977 /* 2330 */ 322, 322, 322, 322, 322, 322, 322, 322, 322, 322,
174978 /* 2340 */ 186, 186, 186, 186, 186, 186, 186, 186, 186, 186,
174979 /* 2350 */ 186, 186, 186, 186, 186, 186, 186, 186, 186, 186,
174980 /* 2360 */ 186, 186, 186, 186, 186, 186, 186, 186, 186, 186,
174981 /* 2370 */ 186, 186, 186, 186, 186, 186, 186, 186, 186, 186,
174982 /* 2380 */ 186, 186, 186, 186, 186, 186, 186, 186, 186, 186,
174983 /* 2390 */ 186, 186, 186,
174984 };
174985 #define YY_SHIFT_COUNT (582)
174986 #define YY_SHIFT_MIN (0)
174987 #define YY_SHIFT_MAX (2152)
174988 static const unsigned short int yy_shift_ofst[] = {
174989 /* 0 */ 2029, 1801, 2043, 1380, 1380, 33, 391, 1496, 1569, 1642,
174990 /* 10 */ 702, 702, 702, 193, 33, 33, 33, 33, 33, 0,
174991 /* 20 */ 0, 216, 1177, 702, 702, 702, 702, 702, 702, 702,
174992 /* 30 */ 702, 702, 702, 702, 702, 702, 702, 702, 406, 406,
174993 /* 40 */ 111, 111, 218, 447, 547, 598, 598, 260, 260, 260,
174994 /* 50 */ 260, 40, 112, 320, 340, 445, 489, 593, 637, 741,
174995 /* 60 */ 785, 889, 909, 1023, 1043, 1157, 1177, 1177, 1177, 1177,
174996 /* 70 */ 1177, 1177, 1177, 1177, 1177, 1177, 1177, 1177, 1177, 1177,
174997 /* 80 */ 1177, 1177, 1177, 1177, 1197, 1177, 1301, 1321, 1321, 554,
174998 /* 90 */ 1802, 1910, 702, 702, 702, 702, 702, 702, 702, 702,
174999 /* 100 */ 702, 702, 702, 702, 702, 702, 702, 702, 702, 702,
175000 /* 110 */ 702, 702, 702, 702, 702, 702, 702, 702, 702, 702,
175001 /* 120 */ 702, 702, 702, 702, 702, 702, 702, 702, 702, 702,
175002 /* 130 */ 702, 702, 702, 702, 702, 702, 702, 702, 702, 702,
175003 /* 140 */ 702, 702, 138, 198, 198, 198, 198, 198, 198, 198,
175004 /* 150 */ 183, 99, 236, 292, 598, 793, 167, 598, 598, 880,
175005 /* 160 */ 880, 598, 857, 150, 195, 195, 195, 264, 113, 113,
175006 /* 170 */ 2207, 2207, 854, 854, 854, 751, 765, 765, 765, 765,
175007 /* 180 */ 1096, 1096, 725, 292, 882, 904, 598, 598, 598, 598,
175008 /* 190 */ 598, 598, 598, 598, 598, 598, 598, 598, 598, 598,
175009 /* 200 */ 598, 598, 598, 598, 598, 1273, 1032, 1032, 598, 147,
175010 /* 210 */ 1098, 1098, 603, 603, 1276, 1276, 363, 2207, 2207, 2207,
175011 /* 220 */ 2207, 2207, 2207, 2207, 469, 617, 617, 801, 336, 461,
175012 /* 230 */ 804, 864, 615, 891, 913, 598, 598, 598, 598, 598,
175013 /* 240 */ 598, 598, 598, 598, 598, 653, 598, 598, 598, 598,
175014 /* 250 */ 598, 598, 598, 598, 598, 598, 598, 598, 1105, 1105,
175015 /* 260 */ 1105, 598, 598, 598, 1194, 598, 598, 598, 1215, 1249,
175016 /* 270 */ 598, 1353, 598, 598, 598, 598, 598, 598, 598, 598,
175017 /* 280 */ 677, 449, 902, 1338, 1338, 1338, 1338, 1248, 902, 902,
175018 /* 290 */ 326, 1151, 1047, 755, 749, 1371, 960, 1371, 1007, 1162,
175019 /* 300 */ 749, 749, 1162, 749, 960, 1007, 1274, 738, 215, 1300,
175020 /* 310 */ 1300, 1300, 1395, 1395, 1395, 1395, 1368, 1368, 1033, 1414,
175021 /* 320 */ 1387, 1361, 1759, 1759, 1685, 1685, 1792, 1792, 1685, 1683,
175022 /* 330 */ 1686, 1814, 1797, 1825, 1825, 1825, 1825, 1685, 1836, 1707,
175023 /* 340 */ 1686, 1686, 1707, 1814, 1797, 1707, 1797, 1707, 1685, 1836,
175024 /* 350 */ 1710, 1807, 1685, 1836, 1854, 1685, 1836, 1685, 1836, 1854,
175025 /* 360 */ 1769, 1769, 1769, 1822, 1870, 1870, 1854, 1769, 1766, 1769,
175026 /* 370 */ 1822, 1769, 1769, 1729, 1873, 1785, 1785, 1854, 1685, 1823,
175027 /* 380 */ 1823, 1840, 1840, 1778, 1782, 1909, 1685, 1779, 1778, 1789,
175028 /* 390 */ 1800, 1707, 1919, 1939, 1939, 1948, 1948, 1948, 2207, 2207,
175029 /* 400 */ 2207, 2207, 2207, 2207, 2207, 2207, 2207, 2207, 2207, 2207,
175030 /* 410 */ 2207, 2207, 2207, 69, 1037, 79, 1088, 651, 1196, 1415,
175031 /* 420 */ 1501, 1439, 1369, 1452, 911, 1211, 1524, 1469, 1551, 1567,
175032 /* 430 */ 1570, 1624, 1640, 1644, 1499, 1440, 1572, 1464, 1597, 275,
175033 /* 440 */ 782, 1586, 1648, 1678, 1553, 1682, 1687, 1388, 1502, 1696,
175034 /* 450 */ 1706, 1588, 1486, 1971, 1975, 1957, 1820, 1972, 1973, 1965,
175035 /* 460 */ 1967, 1851, 1841, 1861, 1969, 1969, 1974, 1852, 1976, 1855,
175036 /* 470 */ 1981, 1998, 1858, 1871, 1969, 1872, 1942, 1968, 1969, 1856,
175037 /* 480 */ 1952, 1953, 1955, 1956, 1881, 1896, 1980, 1874, 2014, 2015,
175038 /* 490 */ 1997, 1905, 1860, 1954, 1999, 1964, 1950, 1994, 1894, 1921,
175039 /* 500 */ 2020, 2018, 2026, 1915, 1923, 2028, 1984, 2036, 2040, 2047,
175040 /* 510 */ 2041, 2003, 2012, 2050, 1979, 2049, 2056, 2011, 2044, 2057,
175041 /* 520 */ 2048, 1934, 2063, 2064, 2065, 2061, 2066, 2068, 1993, 1959,
175042 /* 530 */ 2069, 2071, 1978, 2062, 2075, 1958, 2073, 2070, 2072, 2076,
175043 /* 540 */ 2078, 2010, 2027, 2022, 2074, 2031, 2019, 2081, 2082, 2094,
175044 /* 550 */ 2093, 2095, 2096, 2085, 1983, 1986, 2100, 2073, 2101, 2104,
175045 /* 560 */ 2107, 2109, 2108, 2110, 2111, 2114, 2121, 2115, 2116, 2117,
175046 /* 570 */ 2118, 2122, 2123, 2124, 2007, 2004, 2005, 2006, 2125, 2128,
175047 /* 580 */ 2137, 2138, 2152,
175048 };
175049 #define YY_REDUCE_COUNT (412)
175050 #define YY_REDUCE_MIN (-276)
175051 #define YY_REDUCE_MAX (1775)
175052 static const short yy_reduce_ofst[] = {
175053 /* 0 */ -66, 217, -63, -177, -180, 161, 364, 64, -183, 162,
175054 /* 10 */ 223, 367, 414, -173, 473, 514, 525, 622, 626, -207,
175055 /* 20 */ 351, -276, -38, 693, 811, 831, 833, 888, -188, 945,
175056 /* 30 */ 947, 416, 558, 951, 867, 287, 1078, 1080, -186, 224,
175057 /* 40 */ -132, 42, 964, 269, 417, 796, 810, -237, -231, -237,
175058 /* 50 */ -231, -45, -45, -45, -45, -45, -45, -45, -45, -45,
175059 /* 60 */ -45, -45, -45, -45, -45, -45, -45, -45, -45, -45,
175060 /* 70 */ -45, -45, -45, -45, -45, -45, -45, -45, -45, -45,
175061 /* 80 */ -45, -45, -45, -45, -45, -45, -45, -45, -45, 895,
175062 /* 90 */ 925, 967, 980, 1100, 1143, 1169, 1203, 1225, 1228, 1242,
175063 /* 100 */ 1247, 1250, 1253, 1255, 1261, 1267, 1272, 1275, 1283, 1286,
175064 /* 110 */ 1288, 1292, 1333, 1335, 1347, 1349, 1352, 1354, 1360, 1366,
175065 /* 120 */ 1381, 1391, 1406, 1408, 1413, 1416, 1418, 1422, 1425, 1427,
175066 /* 130 */ 1463, 1465, 1472, 1478, 1480, 1491, 1498, 1500, 1517, 1519,
175067 /* 140 */ 1528, 1536, -45, -45, -45, -45, -45, -45, -45, -45,
175068 /* 150 */ -45, -45, -45, 312, -158, 285, -219, 9, 166, 370,
175069 /* 160 */ 545, 707, -45, 930, 601, 963, 1067, 792, -45, -45,
175070 /* 170 */ -45, -45, -204, -204, -204, 369, -171, -129, 632, 678,
175071 /* 180 */ 202, 352, -270, 412, 627, 627, -9, 122, 415, 419,
175072 /* 190 */ -56, 248, 583, 920, 6, 261, 459, 795, 1049, 813,
175073 /* 200 */ 1062, 1082, -161, 778, 1063, 797, 870, 1003, 1128, 443,
175074 /* 210 */ 1031, 1072, 1191, 1192, 957, 1120, 105, 1149, 523, 933,
175075 /* 220 */ 1218, 1238, 1254, 1251, -138, 96, 117, 146, 181, 277,
175076 /* 230 */ 280, 421, 480, 712, 830, 850, 1085, 1099, 1129, 1209,
175077 /* 240 */ 1323, 1331, 1336, 1364, 1407, 368, 1412, 1433, 1438, 1474,
175078 /* 250 */ 1481, 1505, 1506, 1526, 1538, 1544, 1545, 1546, 722, 764,
175079 /* 260 */ 856, 1547, 1548, 1550, 1188, 1554, 1557, 1561, 1298, 1260,
175080 /* 270 */ 1562, 1456, 1564, 280, 1568, 1571, 1573, 1574, 1575, 1576,
175081 /* 280 */ 1457, 1477, 1520, 1514, 1515, 1516, 1518, 1188, 1520, 1520,
175082 /* 290 */ 1530, 1563, 1584, 1482, 1504, 1510, 1534, 1513, 1488, 1537,
175083 /* 300 */ 1512, 1521, 1539, 1522, 1541, 1493, 1583, 1559, 1565, 1585,
175084 /* 310 */ 1587, 1589, 1529, 1531, 1532, 1549, 1558, 1566, 1535, 1577,
175085 /* 320 */ 1582, 1622, 1533, 1540, 1627, 1628, 1552, 1555, 1633, 1560,
175086 /* 330 */ 1578, 1581, 1607, 1606, 1608, 1609, 1611, 1649, 1655, 1612,
175087 /* 340 */ 1590, 1591, 1613, 1594, 1621, 1614, 1623, 1616, 1666, 1668,
175088 /* 350 */ 1579, 1593, 1672, 1675, 1656, 1676, 1679, 1680, 1688, 1660,
175089 /* 360 */ 1667, 1670, 1671, 1663, 1669, 1673, 1674, 1689, 1681, 1692,
175090 /* 370 */ 1677, 1693, 1694, 1592, 1599, 1617, 1620, 1700, 1713, 1596,
175091 /* 380 */ 1598, 1658, 1659, 1691, 1684, 1654, 1735, 1664, 1697, 1690,
175092 /* 390 */ 1701, 1703, 1748, 1758, 1760, 1768, 1770, 1772, 1657, 1661,
175093 /* 400 */ 1665, 1761, 1754, 1757, 1762, 1763, 1764, 1750, 1751, 1765,
175094 /* 410 */ 1771, 1767, 1775,
175095 };
175096 static const YYACTIONTYPE yy_default[] = {
175097 /* 0 */ 1663, 1663, 1663, 1491, 1254, 1367, 1254, 1254, 1254, 1254,
175098 /* 10 */ 1491, 1491, 1491, 1254, 1254, 1254, 1254, 1254, 1254, 1397,
175099 /* 20 */ 1397, 1544, 1287, 1254, 1254, 1254, 1254, 1254, 1254, 1254,
@@ -175355,10 +175739,11 @@
175355 0, /* ASTERISK => nothing */
175356 0, /* SPAN => nothing */
175357 0, /* ERROR => nothing */
175358 0, /* QNUMBER => nothing */
175359 0, /* SPACE => nothing */
 
175360 0, /* ILLEGAL => nothing */
175361 };
175362 #endif /* YYFALLBACK */
175363
175364 /* The following structure represents a single element of the
@@ -175624,147 +176009,148 @@
175624 /* 180 */ "ASTERISK",
175625 /* 181 */ "SPAN",
175626 /* 182 */ "ERROR",
175627 /* 183 */ "QNUMBER",
175628 /* 184 */ "SPACE",
175629 /* 185 */ "ILLEGAL",
175630 /* 186 */ "input",
175631 /* 187 */ "cmdlist",
175632 /* 188 */ "ecmd",
175633 /* 189 */ "cmdx",
175634 /* 190 */ "explain",
175635 /* 191 */ "cmd",
175636 /* 192 */ "transtype",
175637 /* 193 */ "trans_opt",
175638 /* 194 */ "nm",
175639 /* 195 */ "savepoint_opt",
175640 /* 196 */ "create_table",
175641 /* 197 */ "create_table_args",
175642 /* 198 */ "createkw",
175643 /* 199 */ "temp",
175644 /* 200 */ "ifnotexists",
175645 /* 201 */ "dbnm",
175646 /* 202 */ "columnlist",
175647 /* 203 */ "conslist_opt",
175648 /* 204 */ "table_option_set",
175649 /* 205 */ "select",
175650 /* 206 */ "table_option",
175651 /* 207 */ "columnname",
175652 /* 208 */ "carglist",
175653 /* 209 */ "typetoken",
175654 /* 210 */ "typename",
175655 /* 211 */ "signed",
175656 /* 212 */ "plus_num",
175657 /* 213 */ "minus_num",
175658 /* 214 */ "scanpt",
175659 /* 215 */ "scantok",
175660 /* 216 */ "ccons",
175661 /* 217 */ "term",
175662 /* 218 */ "expr",
175663 /* 219 */ "onconf",
175664 /* 220 */ "sortorder",
175665 /* 221 */ "autoinc",
175666 /* 222 */ "eidlist_opt",
175667 /* 223 */ "refargs",
175668 /* 224 */ "defer_subclause",
175669 /* 225 */ "generated",
175670 /* 226 */ "refarg",
175671 /* 227 */ "refact",
175672 /* 228 */ "init_deferred_pred_opt",
175673 /* 229 */ "conslist",
175674 /* 230 */ "tconscomma",
175675 /* 231 */ "tcons",
175676 /* 232 */ "sortlist",
175677 /* 233 */ "eidlist",
175678 /* 234 */ "defer_subclause_opt",
175679 /* 235 */ "orconf",
175680 /* 236 */ "resolvetype",
175681 /* 237 */ "raisetype",
175682 /* 238 */ "ifexists",
175683 /* 239 */ "fullname",
175684 /* 240 */ "selectnowith",
175685 /* 241 */ "oneselect",
175686 /* 242 */ "wqlist",
175687 /* 243 */ "multiselect_op",
175688 /* 244 */ "distinct",
175689 /* 245 */ "selcollist",
175690 /* 246 */ "from",
175691 /* 247 */ "where_opt",
175692 /* 248 */ "groupby_opt",
175693 /* 249 */ "having_opt",
175694 /* 250 */ "orderby_opt",
175695 /* 251 */ "limit_opt",
175696 /* 252 */ "window_clause",
175697 /* 253 */ "values",
175698 /* 254 */ "nexprlist",
175699 /* 255 */ "mvalues",
175700 /* 256 */ "sclp",
175701 /* 257 */ "as",
175702 /* 258 */ "seltablist",
175703 /* 259 */ "stl_prefix",
175704 /* 260 */ "joinop",
175705 /* 261 */ "on_using",
175706 /* 262 */ "indexed_by",
175707 /* 263 */ "exprlist",
175708 /* 264 */ "xfullname",
175709 /* 265 */ "idlist",
175710 /* 266 */ "indexed_opt",
175711 /* 267 */ "nulls",
175712 /* 268 */ "with",
175713 /* 269 */ "where_opt_ret",
175714 /* 270 */ "setlist",
175715 /* 271 */ "insert_cmd",
175716 /* 272 */ "idlist_opt",
175717 /* 273 */ "upsert",
175718 /* 274 */ "returning",
175719 /* 275 */ "filter_over",
175720 /* 276 */ "likeop",
175721 /* 277 */ "between_op",
175722 /* 278 */ "in_op",
175723 /* 279 */ "paren_exprlist",
175724 /* 280 */ "case_operand",
175725 /* 281 */ "case_exprlist",
175726 /* 282 */ "case_else",
175727 /* 283 */ "uniqueflag",
175728 /* 284 */ "collate",
175729 /* 285 */ "vinto",
175730 /* 286 */ "nmnum",
175731 /* 287 */ "trigger_decl",
175732 /* 288 */ "trigger_cmd_list",
175733 /* 289 */ "trigger_time",
175734 /* 290 */ "trigger_event",
175735 /* 291 */ "foreach_clause",
175736 /* 292 */ "when_clause",
175737 /* 293 */ "trigger_cmd",
175738 /* 294 */ "trnm",
175739 /* 295 */ "tridxby",
175740 /* 296 */ "database_kw_opt",
175741 /* 297 */ "key_opt",
175742 /* 298 */ "add_column_fullname",
175743 /* 299 */ "kwcolumn_opt",
175744 /* 300 */ "create_vtab",
175745 /* 301 */ "vtabarglist",
175746 /* 302 */ "vtabarg",
175747 /* 303 */ "vtabargtoken",
175748 /* 304 */ "lp",
175749 /* 305 */ "anylist",
175750 /* 306 */ "wqitem",
175751 /* 307 */ "wqas",
175752 /* 308 */ "withnm",
175753 /* 309 */ "windowdefn_list",
175754 /* 310 */ "windowdefn",
175755 /* 311 */ "window",
175756 /* 312 */ "frame_opt",
175757 /* 313 */ "part_opt",
175758 /* 314 */ "filter_clause",
175759 /* 315 */ "over_clause",
175760 /* 316 */ "range_or_rows",
175761 /* 317 */ "frame_bound",
175762 /* 318 */ "frame_bound_s",
175763 /* 319 */ "frame_bound_e",
175764 /* 320 */ "frame_exclude_opt",
175765 /* 321 */ "frame_exclude",
 
175766 };
175767 #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */
175768
175769 #ifndef NDEBUG
175770 /* For tracing reduce actions, the names of all rules are required.
@@ -176300,102 +176686,102 @@
176300 ** Note: during a reduce, the only symbols destroyed are those
176301 ** which appear on the RHS of the rule, but which are *not* used
176302 ** inside the C code.
176303 */
176304 /********* Begin destructor definitions ***************************************/
176305 case 205: /* select */
176306 case 240: /* selectnowith */
176307 case 241: /* oneselect */
176308 case 253: /* values */
176309 case 255: /* mvalues */
176310 {
176311 sqlite3SelectDelete(pParse->db, (yypminor->yy555));
176312 }
176313 break;
176314 case 217: /* term */
176315 case 218: /* expr */
176316 case 247: /* where_opt */
176317 case 249: /* having_opt */
176318 case 269: /* where_opt_ret */
176319 case 280: /* case_operand */
176320 case 282: /* case_else */
176321 case 285: /* vinto */
176322 case 292: /* when_clause */
176323 case 297: /* key_opt */
176324 case 314: /* filter_clause */
176325 {
176326 sqlite3ExprDelete(pParse->db, (yypminor->yy454));
176327 }
176328 break;
176329 case 222: /* eidlist_opt */
176330 case 232: /* sortlist */
176331 case 233: /* eidlist */
176332 case 245: /* selcollist */
176333 case 248: /* groupby_opt */
176334 case 250: /* orderby_opt */
176335 case 254: /* nexprlist */
176336 case 256: /* sclp */
176337 case 263: /* exprlist */
176338 case 270: /* setlist */
176339 case 279: /* paren_exprlist */
176340 case 281: /* case_exprlist */
176341 case 313: /* part_opt */
176342 {
176343 sqlite3ExprListDelete(pParse->db, (yypminor->yy14));
176344 }
176345 break;
176346 case 239: /* fullname */
176347 case 246: /* from */
176348 case 258: /* seltablist */
176349 case 259: /* stl_prefix */
176350 case 264: /* xfullname */
176351 {
176352 sqlite3SrcListDelete(pParse->db, (yypminor->yy203));
176353 }
176354 break;
176355 case 242: /* wqlist */
176356 {
176357 sqlite3WithDelete(pParse->db, (yypminor->yy59));
176358 }
176359 break;
176360 case 252: /* window_clause */
176361 case 309: /* windowdefn_list */
176362 {
176363 sqlite3WindowListDelete(pParse->db, (yypminor->yy211));
176364 }
176365 break;
176366 case 265: /* idlist */
176367 case 272: /* idlist_opt */
176368 {
176369 sqlite3IdListDelete(pParse->db, (yypminor->yy132));
176370 }
176371 break;
176372 case 275: /* filter_over */
176373 case 310: /* windowdefn */
176374 case 311: /* window */
176375 case 312: /* frame_opt */
176376 case 315: /* over_clause */
176377 {
176378 sqlite3WindowDelete(pParse->db, (yypminor->yy211));
176379 }
176380 break;
176381 case 288: /* trigger_cmd_list */
176382 case 293: /* trigger_cmd */
176383 {
176384 sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy427));
176385 }
176386 break;
176387 case 290: /* trigger_event */
176388 {
176389 sqlite3IdListDelete(pParse->db, (yypminor->yy286).b);
176390 }
176391 break;
176392 case 317: /* frame_bound */
176393 case 318: /* frame_bound_s */
176394 case 319: /* frame_bound_e */
176395 {
176396 sqlite3ExprDelete(pParse->db, (yypminor->yy509).pExpr);
176397 }
176398 break;
176399 /********* End destructor definitions *****************************************/
176400 default: break; /* If no destructor action specified: do nothing */
176401 }
@@ -176693,419 +177079,419 @@
176693 }
176694
176695 /* For rule J, yyRuleInfoLhs[J] contains the symbol on the left-hand side
176696 ** of that rule */
176697 static const YYCODETYPE yyRuleInfoLhs[] = {
176698 190, /* (0) explain ::= EXPLAIN */
176699 190, /* (1) explain ::= EXPLAIN QUERY PLAN */
176700 189, /* (2) cmdx ::= cmd */
176701 191, /* (3) cmd ::= BEGIN transtype trans_opt */
176702 192, /* (4) transtype ::= */
176703 192, /* (5) transtype ::= DEFERRED */
176704 192, /* (6) transtype ::= IMMEDIATE */
176705 192, /* (7) transtype ::= EXCLUSIVE */
176706 191, /* (8) cmd ::= COMMIT|END trans_opt */
176707 191, /* (9) cmd ::= ROLLBACK trans_opt */
176708 191, /* (10) cmd ::= SAVEPOINT nm */
176709 191, /* (11) cmd ::= RELEASE savepoint_opt nm */
176710 191, /* (12) cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */
176711 196, /* (13) create_table ::= createkw temp TABLE ifnotexists nm dbnm */
176712 198, /* (14) createkw ::= CREATE */
176713 200, /* (15) ifnotexists ::= */
176714 200, /* (16) ifnotexists ::= IF NOT EXISTS */
176715 199, /* (17) temp ::= TEMP */
176716 199, /* (18) temp ::= */
176717 197, /* (19) create_table_args ::= LP columnlist conslist_opt RP table_option_set */
176718 197, /* (20) create_table_args ::= AS select */
176719 204, /* (21) table_option_set ::= */
176720 204, /* (22) table_option_set ::= table_option_set COMMA table_option */
176721 206, /* (23) table_option ::= WITHOUT nm */
176722 206, /* (24) table_option ::= nm */
176723 207, /* (25) columnname ::= nm typetoken */
176724 209, /* (26) typetoken ::= */
176725 209, /* (27) typetoken ::= typename LP signed RP */
176726 209, /* (28) typetoken ::= typename LP signed COMMA signed RP */
176727 210, /* (29) typename ::= typename ID|STRING */
176728 214, /* (30) scanpt ::= */
176729 215, /* (31) scantok ::= */
176730 216, /* (32) ccons ::= CONSTRAINT nm */
176731 216, /* (33) ccons ::= DEFAULT scantok term */
176732 216, /* (34) ccons ::= DEFAULT LP expr RP */
176733 216, /* (35) ccons ::= DEFAULT PLUS scantok term */
176734 216, /* (36) ccons ::= DEFAULT MINUS scantok term */
176735 216, /* (37) ccons ::= DEFAULT scantok ID|INDEXED */
176736 216, /* (38) ccons ::= NOT NULL onconf */
176737 216, /* (39) ccons ::= PRIMARY KEY sortorder onconf autoinc */
176738 216, /* (40) ccons ::= UNIQUE onconf */
176739 216, /* (41) ccons ::= CHECK LP expr RP */
176740 216, /* (42) ccons ::= REFERENCES nm eidlist_opt refargs */
176741 216, /* (43) ccons ::= defer_subclause */
176742 216, /* (44) ccons ::= COLLATE ID|STRING */
176743 225, /* (45) generated ::= LP expr RP */
176744 225, /* (46) generated ::= LP expr RP ID */
176745 221, /* (47) autoinc ::= */
176746 221, /* (48) autoinc ::= AUTOINCR */
176747 223, /* (49) refargs ::= */
176748 223, /* (50) refargs ::= refargs refarg */
176749 226, /* (51) refarg ::= MATCH nm */
176750 226, /* (52) refarg ::= ON INSERT refact */
176751 226, /* (53) refarg ::= ON DELETE refact */
176752 226, /* (54) refarg ::= ON UPDATE refact */
176753 227, /* (55) refact ::= SET NULL */
176754 227, /* (56) refact ::= SET DEFAULT */
176755 227, /* (57) refact ::= CASCADE */
176756 227, /* (58) refact ::= RESTRICT */
176757 227, /* (59) refact ::= NO ACTION */
176758 224, /* (60) defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
176759 224, /* (61) defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
176760 228, /* (62) init_deferred_pred_opt ::= */
176761 228, /* (63) init_deferred_pred_opt ::= INITIALLY DEFERRED */
176762 228, /* (64) init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
176763 203, /* (65) conslist_opt ::= */
176764 230, /* (66) tconscomma ::= COMMA */
176765 231, /* (67) tcons ::= CONSTRAINT nm */
176766 231, /* (68) tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
176767 231, /* (69) tcons ::= UNIQUE LP sortlist RP onconf */
176768 231, /* (70) tcons ::= CHECK LP expr RP onconf */
176769 231, /* (71) tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
176770 234, /* (72) defer_subclause_opt ::= */
176771 219, /* (73) onconf ::= */
176772 219, /* (74) onconf ::= ON CONFLICT resolvetype */
176773 235, /* (75) orconf ::= */
176774 235, /* (76) orconf ::= OR resolvetype */
176775 236, /* (77) resolvetype ::= IGNORE */
176776 236, /* (78) resolvetype ::= REPLACE */
176777 191, /* (79) cmd ::= DROP TABLE ifexists fullname */
176778 238, /* (80) ifexists ::= IF EXISTS */
176779 238, /* (81) ifexists ::= */
176780 191, /* (82) cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
176781 191, /* (83) cmd ::= DROP VIEW ifexists fullname */
176782 191, /* (84) cmd ::= select */
176783 205, /* (85) select ::= WITH wqlist selectnowith */
176784 205, /* (86) select ::= WITH RECURSIVE wqlist selectnowith */
176785 205, /* (87) select ::= selectnowith */
176786 240, /* (88) selectnowith ::= selectnowith multiselect_op oneselect */
176787 243, /* (89) multiselect_op ::= UNION */
176788 243, /* (90) multiselect_op ::= UNION ALL */
176789 243, /* (91) multiselect_op ::= EXCEPT|INTERSECT */
176790 241, /* (92) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
176791 241, /* (93) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */
176792 253, /* (94) values ::= VALUES LP nexprlist RP */
176793 241, /* (95) oneselect ::= mvalues */
176794 255, /* (96) mvalues ::= values COMMA LP nexprlist RP */
176795 255, /* (97) mvalues ::= mvalues COMMA LP nexprlist RP */
176796 244, /* (98) distinct ::= DISTINCT */
176797 244, /* (99) distinct ::= ALL */
176798 244, /* (100) distinct ::= */
176799 256, /* (101) sclp ::= */
176800 245, /* (102) selcollist ::= sclp scanpt expr scanpt as */
176801 245, /* (103) selcollist ::= sclp scanpt STAR */
176802 245, /* (104) selcollist ::= sclp scanpt nm DOT STAR */
176803 257, /* (105) as ::= AS nm */
176804 257, /* (106) as ::= */
176805 246, /* (107) from ::= */
176806 246, /* (108) from ::= FROM seltablist */
176807 259, /* (109) stl_prefix ::= seltablist joinop */
176808 259, /* (110) stl_prefix ::= */
176809 258, /* (111) seltablist ::= stl_prefix nm dbnm as on_using */
176810 258, /* (112) seltablist ::= stl_prefix nm dbnm as indexed_by on_using */
176811 258, /* (113) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_using */
176812 258, /* (114) seltablist ::= stl_prefix LP select RP as on_using */
176813 258, /* (115) seltablist ::= stl_prefix LP seltablist RP as on_using */
176814 201, /* (116) dbnm ::= */
176815 201, /* (117) dbnm ::= DOT nm */
176816 239, /* (118) fullname ::= nm */
176817 239, /* (119) fullname ::= nm DOT nm */
176818 264, /* (120) xfullname ::= nm */
176819 264, /* (121) xfullname ::= nm DOT nm */
176820 264, /* (122) xfullname ::= nm DOT nm AS nm */
176821 264, /* (123) xfullname ::= nm AS nm */
176822 260, /* (124) joinop ::= COMMA|JOIN */
176823 260, /* (125) joinop ::= JOIN_KW JOIN */
176824 260, /* (126) joinop ::= JOIN_KW nm JOIN */
176825 260, /* (127) joinop ::= JOIN_KW nm nm JOIN */
176826 261, /* (128) on_using ::= ON expr */
176827 261, /* (129) on_using ::= USING LP idlist RP */
176828 261, /* (130) on_using ::= */
176829 266, /* (131) indexed_opt ::= */
176830 262, /* (132) indexed_by ::= INDEXED BY nm */
176831 262, /* (133) indexed_by ::= NOT INDEXED */
176832 250, /* (134) orderby_opt ::= */
176833 250, /* (135) orderby_opt ::= ORDER BY sortlist */
176834 232, /* (136) sortlist ::= sortlist COMMA expr sortorder nulls */
176835 232, /* (137) sortlist ::= expr sortorder nulls */
176836 220, /* (138) sortorder ::= ASC */
176837 220, /* (139) sortorder ::= DESC */
176838 220, /* (140) sortorder ::= */
176839 267, /* (141) nulls ::= NULLS FIRST */
176840 267, /* (142) nulls ::= NULLS LAST */
176841 267, /* (143) nulls ::= */
176842 248, /* (144) groupby_opt ::= */
176843 248, /* (145) groupby_opt ::= GROUP BY nexprlist */
176844 249, /* (146) having_opt ::= */
176845 249, /* (147) having_opt ::= HAVING expr */
176846 251, /* (148) limit_opt ::= */
176847 251, /* (149) limit_opt ::= LIMIT expr */
176848 251, /* (150) limit_opt ::= LIMIT expr OFFSET expr */
176849 251, /* (151) limit_opt ::= LIMIT expr COMMA expr */
176850 191, /* (152) cmd ::= with DELETE FROM xfullname indexed_opt where_opt_ret */
176851 247, /* (153) where_opt ::= */
176852 247, /* (154) where_opt ::= WHERE expr */
176853 269, /* (155) where_opt_ret ::= */
176854 269, /* (156) where_opt_ret ::= WHERE expr */
176855 269, /* (157) where_opt_ret ::= RETURNING selcollist */
176856 269, /* (158) where_opt_ret ::= WHERE expr RETURNING selcollist */
176857 191, /* (159) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist from where_opt_ret */
176858 270, /* (160) setlist ::= setlist COMMA nm EQ expr */
176859 270, /* (161) setlist ::= setlist COMMA LP idlist RP EQ expr */
176860 270, /* (162) setlist ::= nm EQ expr */
176861 270, /* (163) setlist ::= LP idlist RP EQ expr */
176862 191, /* (164) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
176863 191, /* (165) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES returning */
176864 273, /* (166) upsert ::= */
176865 273, /* (167) upsert ::= RETURNING selcollist */
176866 273, /* (168) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt upsert */
176867 273, /* (169) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING upsert */
176868 273, /* (170) upsert ::= ON CONFLICT DO NOTHING returning */
176869 273, /* (171) upsert ::= ON CONFLICT DO UPDATE SET setlist where_opt returning */
176870 274, /* (172) returning ::= RETURNING selcollist */
176871 271, /* (173) insert_cmd ::= INSERT orconf */
176872 271, /* (174) insert_cmd ::= REPLACE */
176873 272, /* (175) idlist_opt ::= */
176874 272, /* (176) idlist_opt ::= LP idlist RP */
176875 265, /* (177) idlist ::= idlist COMMA nm */
176876 265, /* (178) idlist ::= nm */
176877 218, /* (179) expr ::= LP expr RP */
176878 218, /* (180) expr ::= ID|INDEXED|JOIN_KW */
176879 218, /* (181) expr ::= nm DOT nm */
176880 218, /* (182) expr ::= nm DOT nm DOT nm */
176881 217, /* (183) term ::= NULL|FLOAT|BLOB */
176882 217, /* (184) term ::= STRING */
176883 217, /* (185) term ::= INTEGER */
176884 218, /* (186) expr ::= VARIABLE */
176885 218, /* (187) expr ::= expr COLLATE ID|STRING */
176886 218, /* (188) expr ::= CAST LP expr AS typetoken RP */
176887 218, /* (189) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP */
176888 218, /* (190) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP */
176889 218, /* (191) expr ::= ID|INDEXED|JOIN_KW LP STAR RP */
176890 218, /* (192) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP filter_over */
176891 218, /* (193) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP filter_over */
176892 218, /* (194) expr ::= ID|INDEXED|JOIN_KW LP STAR RP filter_over */
176893 217, /* (195) term ::= CTIME_KW */
176894 218, /* (196) expr ::= LP nexprlist COMMA expr RP */
176895 218, /* (197) expr ::= expr AND expr */
176896 218, /* (198) expr ::= expr OR expr */
176897 218, /* (199) expr ::= expr LT|GT|GE|LE expr */
176898 218, /* (200) expr ::= expr EQ|NE expr */
176899 218, /* (201) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */
176900 218, /* (202) expr ::= expr PLUS|MINUS expr */
176901 218, /* (203) expr ::= expr STAR|SLASH|REM expr */
176902 218, /* (204) expr ::= expr CONCAT expr */
176903 276, /* (205) likeop ::= NOT LIKE_KW|MATCH */
176904 218, /* (206) expr ::= expr likeop expr */
176905 218, /* (207) expr ::= expr likeop expr ESCAPE expr */
176906 218, /* (208) expr ::= expr ISNULL|NOTNULL */
176907 218, /* (209) expr ::= expr NOT NULL */
176908 218, /* (210) expr ::= expr IS expr */
176909 218, /* (211) expr ::= expr IS NOT expr */
176910 218, /* (212) expr ::= expr IS NOT DISTINCT FROM expr */
176911 218, /* (213) expr ::= expr IS DISTINCT FROM expr */
176912 218, /* (214) expr ::= NOT expr */
176913 218, /* (215) expr ::= BITNOT expr */
176914 218, /* (216) expr ::= PLUS|MINUS expr */
176915 218, /* (217) expr ::= expr PTR expr */
176916 277, /* (218) between_op ::= BETWEEN */
176917 277, /* (219) between_op ::= NOT BETWEEN */
176918 218, /* (220) expr ::= expr between_op expr AND expr */
176919 278, /* (221) in_op ::= IN */
176920 278, /* (222) in_op ::= NOT IN */
176921 218, /* (223) expr ::= expr in_op LP exprlist RP */
176922 218, /* (224) expr ::= LP select RP */
176923 218, /* (225) expr ::= expr in_op LP select RP */
176924 218, /* (226) expr ::= expr in_op nm dbnm paren_exprlist */
176925 218, /* (227) expr ::= EXISTS LP select RP */
176926 218, /* (228) expr ::= CASE case_operand case_exprlist case_else END */
176927 281, /* (229) case_exprlist ::= case_exprlist WHEN expr THEN expr */
176928 281, /* (230) case_exprlist ::= WHEN expr THEN expr */
176929 282, /* (231) case_else ::= ELSE expr */
176930 282, /* (232) case_else ::= */
176931 280, /* (233) case_operand ::= */
176932 263, /* (234) exprlist ::= */
176933 254, /* (235) nexprlist ::= nexprlist COMMA expr */
176934 254, /* (236) nexprlist ::= expr */
176935 279, /* (237) paren_exprlist ::= */
176936 279, /* (238) paren_exprlist ::= LP exprlist RP */
176937 191, /* (239) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
176938 283, /* (240) uniqueflag ::= UNIQUE */
176939 283, /* (241) uniqueflag ::= */
176940 222, /* (242) eidlist_opt ::= */
176941 222, /* (243) eidlist_opt ::= LP eidlist RP */
176942 233, /* (244) eidlist ::= eidlist COMMA nm collate sortorder */
176943 233, /* (245) eidlist ::= nm collate sortorder */
176944 284, /* (246) collate ::= */
176945 284, /* (247) collate ::= COLLATE ID|STRING */
176946 191, /* (248) cmd ::= DROP INDEX ifexists fullname */
176947 191, /* (249) cmd ::= VACUUM vinto */
176948 191, /* (250) cmd ::= VACUUM nm vinto */
176949 285, /* (251) vinto ::= INTO expr */
176950 285, /* (252) vinto ::= */
176951 191, /* (253) cmd ::= PRAGMA nm dbnm */
176952 191, /* (254) cmd ::= PRAGMA nm dbnm EQ nmnum */
176953 191, /* (255) cmd ::= PRAGMA nm dbnm LP nmnum RP */
176954 191, /* (256) cmd ::= PRAGMA nm dbnm EQ minus_num */
176955 191, /* (257) cmd ::= PRAGMA nm dbnm LP minus_num RP */
176956 212, /* (258) plus_num ::= PLUS INTEGER|FLOAT */
176957 213, /* (259) minus_num ::= MINUS INTEGER|FLOAT */
176958 191, /* (260) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
176959 287, /* (261) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
176960 289, /* (262) trigger_time ::= BEFORE|AFTER */
176961 289, /* (263) trigger_time ::= INSTEAD OF */
176962 289, /* (264) trigger_time ::= */
176963 290, /* (265) trigger_event ::= DELETE|INSERT */
176964 290, /* (266) trigger_event ::= UPDATE */
176965 290, /* (267) trigger_event ::= UPDATE OF idlist */
176966 292, /* (268) when_clause ::= */
176967 292, /* (269) when_clause ::= WHEN expr */
176968 288, /* (270) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
176969 288, /* (271) trigger_cmd_list ::= trigger_cmd SEMI */
176970 294, /* (272) trnm ::= nm DOT nm */
176971 295, /* (273) tridxby ::= INDEXED BY nm */
176972 295, /* (274) tridxby ::= NOT INDEXED */
176973 293, /* (275) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */
176974 293, /* (276) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
176975 293, /* (277) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
176976 293, /* (278) trigger_cmd ::= scanpt select scanpt */
176977 218, /* (279) expr ::= RAISE LP IGNORE RP */
176978 218, /* (280) expr ::= RAISE LP raisetype COMMA expr RP */
176979 237, /* (281) raisetype ::= ROLLBACK */
176980 237, /* (282) raisetype ::= ABORT */
176981 237, /* (283) raisetype ::= FAIL */
176982 191, /* (284) cmd ::= DROP TRIGGER ifexists fullname */
176983 191, /* (285) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
176984 191, /* (286) cmd ::= DETACH database_kw_opt expr */
176985 297, /* (287) key_opt ::= */
176986 297, /* (288) key_opt ::= KEY expr */
176987 191, /* (289) cmd ::= REINDEX */
176988 191, /* (290) cmd ::= REINDEX nm dbnm */
176989 191, /* (291) cmd ::= ANALYZE */
176990 191, /* (292) cmd ::= ANALYZE nm dbnm */
176991 191, /* (293) cmd ::= ALTER TABLE fullname RENAME TO nm */
176992 191, /* (294) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
176993 191, /* (295) cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */
176994 298, /* (296) add_column_fullname ::= fullname */
176995 191, /* (297) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
176996 191, /* (298) cmd ::= create_vtab */
176997 191, /* (299) cmd ::= create_vtab LP vtabarglist RP */
176998 300, /* (300) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
176999 302, /* (301) vtabarg ::= */
177000 303, /* (302) vtabargtoken ::= ANY */
177001 303, /* (303) vtabargtoken ::= lp anylist RP */
177002 304, /* (304) lp ::= LP */
177003 268, /* (305) with ::= WITH wqlist */
177004 268, /* (306) with ::= WITH RECURSIVE wqlist */
177005 307, /* (307) wqas ::= AS */
177006 307, /* (308) wqas ::= AS MATERIALIZED */
177007 307, /* (309) wqas ::= AS NOT MATERIALIZED */
177008 306, /* (310) wqitem ::= withnm eidlist_opt wqas LP select RP */
177009 308, /* (311) withnm ::= nm */
177010 242, /* (312) wqlist ::= wqitem */
177011 242, /* (313) wqlist ::= wqlist COMMA wqitem */
177012 309, /* (314) windowdefn_list ::= windowdefn_list COMMA windowdefn */
177013 310, /* (315) windowdefn ::= nm AS LP window RP */
177014 311, /* (316) window ::= PARTITION BY nexprlist orderby_opt frame_opt */
177015 311, /* (317) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
177016 311, /* (318) window ::= ORDER BY sortlist frame_opt */
177017 311, /* (319) window ::= nm ORDER BY sortlist frame_opt */
177018 311, /* (320) window ::= nm frame_opt */
177019 312, /* (321) frame_opt ::= */
177020 312, /* (322) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */
177021 312, /* (323) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */
177022 316, /* (324) range_or_rows ::= RANGE|ROWS|GROUPS */
177023 318, /* (325) frame_bound_s ::= frame_bound */
177024 318, /* (326) frame_bound_s ::= UNBOUNDED PRECEDING */
177025 319, /* (327) frame_bound_e ::= frame_bound */
177026 319, /* (328) frame_bound_e ::= UNBOUNDED FOLLOWING */
177027 317, /* (329) frame_bound ::= expr PRECEDING|FOLLOWING */
177028 317, /* (330) frame_bound ::= CURRENT ROW */
177029 320, /* (331) frame_exclude_opt ::= */
177030 320, /* (332) frame_exclude_opt ::= EXCLUDE frame_exclude */
177031 321, /* (333) frame_exclude ::= NO OTHERS */
177032 321, /* (334) frame_exclude ::= CURRENT ROW */
177033 321, /* (335) frame_exclude ::= GROUP|TIES */
177034 252, /* (336) window_clause ::= WINDOW windowdefn_list */
177035 275, /* (337) filter_over ::= filter_clause over_clause */
177036 275, /* (338) filter_over ::= over_clause */
177037 275, /* (339) filter_over ::= filter_clause */
177038 315, /* (340) over_clause ::= OVER LP window RP */
177039 315, /* (341) over_clause ::= OVER nm */
177040 314, /* (342) filter_clause ::= FILTER LP WHERE expr RP */
177041 217, /* (343) term ::= QNUMBER */
177042 186, /* (344) input ::= cmdlist */
177043 187, /* (345) cmdlist ::= cmdlist ecmd */
177044 187, /* (346) cmdlist ::= ecmd */
177045 188, /* (347) ecmd ::= SEMI */
177046 188, /* (348) ecmd ::= cmdx SEMI */
177047 188, /* (349) ecmd ::= explain cmdx SEMI */
177048 193, /* (350) trans_opt ::= */
177049 193, /* (351) trans_opt ::= TRANSACTION */
177050 193, /* (352) trans_opt ::= TRANSACTION nm */
177051 195, /* (353) savepoint_opt ::= SAVEPOINT */
177052 195, /* (354) savepoint_opt ::= */
177053 191, /* (355) cmd ::= create_table create_table_args */
177054 204, /* (356) table_option_set ::= table_option */
177055 202, /* (357) columnlist ::= columnlist COMMA columnname carglist */
177056 202, /* (358) columnlist ::= columnname carglist */
177057 194, /* (359) nm ::= ID|INDEXED|JOIN_KW */
177058 194, /* (360) nm ::= STRING */
177059 209, /* (361) typetoken ::= typename */
177060 210, /* (362) typename ::= ID|STRING */
177061 211, /* (363) signed ::= plus_num */
177062 211, /* (364) signed ::= minus_num */
177063 208, /* (365) carglist ::= carglist ccons */
177064 208, /* (366) carglist ::= */
177065 216, /* (367) ccons ::= NULL onconf */
177066 216, /* (368) ccons ::= GENERATED ALWAYS AS generated */
177067 216, /* (369) ccons ::= AS generated */
177068 203, /* (370) conslist_opt ::= COMMA conslist */
177069 229, /* (371) conslist ::= conslist tconscomma tcons */
177070 229, /* (372) conslist ::= tcons */
177071 230, /* (373) tconscomma ::= */
177072 234, /* (374) defer_subclause_opt ::= defer_subclause */
177073 236, /* (375) resolvetype ::= raisetype */
177074 240, /* (376) selectnowith ::= oneselect */
177075 241, /* (377) oneselect ::= values */
177076 256, /* (378) sclp ::= selcollist COMMA */
177077 257, /* (379) as ::= ID|STRING */
177078 266, /* (380) indexed_opt ::= indexed_by */
177079 274, /* (381) returning ::= */
177080 218, /* (382) expr ::= term */
177081 276, /* (383) likeop ::= LIKE_KW|MATCH */
177082 280, /* (384) case_operand ::= expr */
177083 263, /* (385) exprlist ::= nexprlist */
177084 286, /* (386) nmnum ::= plus_num */
177085 286, /* (387) nmnum ::= nm */
177086 286, /* (388) nmnum ::= ON */
177087 286, /* (389) nmnum ::= DELETE */
177088 286, /* (390) nmnum ::= DEFAULT */
177089 212, /* (391) plus_num ::= INTEGER|FLOAT */
177090 291, /* (392) foreach_clause ::= */
177091 291, /* (393) foreach_clause ::= FOR EACH ROW */
177092 294, /* (394) trnm ::= nm */
177093 295, /* (395) tridxby ::= */
177094 296, /* (396) database_kw_opt ::= DATABASE */
177095 296, /* (397) database_kw_opt ::= */
177096 299, /* (398) kwcolumn_opt ::= */
177097 299, /* (399) kwcolumn_opt ::= COLUMNKW */
177098 301, /* (400) vtabarglist ::= vtabarg */
177099 301, /* (401) vtabarglist ::= vtabarglist COMMA vtabarg */
177100 302, /* (402) vtabarg ::= vtabarg vtabargtoken */
177101 305, /* (403) anylist ::= */
177102 305, /* (404) anylist ::= anylist LP anylist RP */
177103 305, /* (405) anylist ::= anylist ANY */
177104 268, /* (406) with ::= */
177105 309, /* (407) windowdefn_list ::= windowdefn */
177106 311, /* (408) window ::= frame_opt */
177107 };
177108
177109 /* For rule J, yyRuleInfoNRhs[J] contains the negative of the number
177110 ** of symbols on the right-hand side of that rule. */
177111 static const signed char yyRuleInfoNRhs[] = {
@@ -177567,20 +177953,20 @@
177567 break;
177568 case 2: /* cmdx ::= cmd */
177569 { sqlite3FinishCoding(pParse); }
177570 break;
177571 case 3: /* cmd ::= BEGIN transtype trans_opt */
177572 {sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy144);}
177573 break;
177574 case 4: /* transtype ::= */
177575 {yymsp[1].minor.yy144 = TK_DEFERRED;}
177576 break;
177577 case 5: /* transtype ::= DEFERRED */
177578 case 6: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==6);
177579 case 7: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==7);
177580 case 324: /* range_or_rows ::= RANGE|ROWS|GROUPS */ yytestcase(yyruleno==324);
177581 {yymsp[0].minor.yy144 = yymsp[0].major; /*A-overwrites-X*/}
177582 break;
177583 case 8: /* cmd ::= COMMIT|END trans_opt */
177584 case 9: /* cmd ::= ROLLBACK trans_opt */ yytestcase(yyruleno==9);
177585 {sqlite3EndTransaction(pParse,yymsp[-1].major);}
177586 break;
@@ -177599,70 +177985,72 @@
177599 sqlite3Savepoint(pParse, SAVEPOINT_ROLLBACK, &yymsp[0].minor.yy0);
177600 }
177601 break;
177602 case 13: /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */
177603 {
177604 sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy144,0,0,yymsp[-2].minor.yy144);
177605 }
177606 break;
177607 case 14: /* createkw ::= CREATE */
177608 {disableLookaside(pParse);}
 
 
177609 break;
177610 case 15: /* ifnotexists ::= */
177611 case 18: /* temp ::= */ yytestcase(yyruleno==18);
177612 case 47: /* autoinc ::= */ yytestcase(yyruleno==47);
177613 case 62: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==62);
177614 case 72: /* defer_subclause_opt ::= */ yytestcase(yyruleno==72);
177615 case 81: /* ifexists ::= */ yytestcase(yyruleno==81);
177616 case 100: /* distinct ::= */ yytestcase(yyruleno==100);
177617 case 246: /* collate ::= */ yytestcase(yyruleno==246);
177618 {yymsp[1].minor.yy144 = 0;}
177619 break;
177620 case 16: /* ifnotexists ::= IF NOT EXISTS */
177621 {yymsp[-2].minor.yy144 = 1;}
177622 break;
177623 case 17: /* temp ::= TEMP */
177624 {yymsp[0].minor.yy144 = pParse->db->init.busy==0;}
177625 break;
177626 case 19: /* create_table_args ::= LP columnlist conslist_opt RP table_option_set */
177627 {
177628 sqlite3EndTable(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,yymsp[0].minor.yy391,0);
177629 }
177630 break;
177631 case 20: /* create_table_args ::= AS select */
177632 {
177633 sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy555);
177634 sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy555);
177635 }
177636 break;
177637 case 21: /* table_option_set ::= */
177638 {yymsp[1].minor.yy391 = 0;}
177639 break;
177640 case 22: /* table_option_set ::= table_option_set COMMA table_option */
177641 {yylhsminor.yy391 = yymsp[-2].minor.yy391|yymsp[0].minor.yy391;}
177642 yymsp[-2].minor.yy391 = yylhsminor.yy391;
177643 break;
177644 case 23: /* table_option ::= WITHOUT nm */
177645 {
177646 if( yymsp[0].minor.yy0.n==5 && sqlite3_strnicmp(yymsp[0].minor.yy0.z,"rowid",5)==0 ){
177647 yymsp[-1].minor.yy391 = TF_WithoutRowid | TF_NoVisibleRowid;
177648 }else{
177649 yymsp[-1].minor.yy391 = 0;
177650 sqlite3ErrorMsg(pParse, "unknown table option: %.*s", yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.z);
177651 }
177652 }
177653 break;
177654 case 24: /* table_option ::= nm */
177655 {
177656 if( yymsp[0].minor.yy0.n==6 && sqlite3_strnicmp(yymsp[0].minor.yy0.z,"strict",6)==0 ){
177657 yylhsminor.yy391 = TF_Strict;
177658 }else{
177659 yylhsminor.yy391 = 0;
177660 sqlite3ErrorMsg(pParse, "unknown table option: %.*s", yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.z);
177661 }
177662 }
177663 yymsp[0].minor.yy391 = yylhsminor.yy391;
177664 break;
177665 case 25: /* columnname ::= nm typetoken */
177666 {sqlite3AddColumn(pParse,yymsp[-1].minor.yy0,yymsp[0].minor.yy0);}
177667 break;
177668 case 26: /* typetoken ::= */
@@ -177684,11 +178072,11 @@
177684 {yymsp[-1].minor.yy0.n=yymsp[0].minor.yy0.n+(int)(yymsp[0].minor.yy0.z-yymsp[-1].minor.yy0.z);}
177685 break;
177686 case 30: /* scanpt ::= */
177687 {
177688 assert( yyLookahead!=YYNOCODE );
177689 yymsp[1].minor.yy168 = yyLookaheadToken.z;
177690 }
177691 break;
177692 case 31: /* scantok ::= */
177693 {
177694 assert( yyLookahead!=YYNOCODE );
@@ -177695,24 +178083,24 @@
177695 yymsp[1].minor.yy0 = yyLookaheadToken;
177696 }
177697 break;
177698 case 32: /* ccons ::= CONSTRAINT nm */
177699 case 67: /* tcons ::= CONSTRAINT nm */ yytestcase(yyruleno==67);
177700 {pParse->constraintName = yymsp[0].minor.yy0;}
177701 break;
177702 case 33: /* ccons ::= DEFAULT scantok term */
177703 {sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy454,yymsp[-1].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);}
177704 break;
177705 case 34: /* ccons ::= DEFAULT LP expr RP */
177706 {sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy454,yymsp[-2].minor.yy0.z+1,yymsp[0].minor.yy0.z);}
177707 break;
177708 case 35: /* ccons ::= DEFAULT PLUS scantok term */
177709 {sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy454,yymsp[-2].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);}
177710 break;
177711 case 36: /* ccons ::= DEFAULT MINUS scantok term */
177712 {
177713 Expr *p = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy454, 0);
177714 sqlite3AddDefaultValue(pParse,p,yymsp[-2].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);
177715 }
177716 break;
177717 case 37: /* ccons ::= DEFAULT scantok ID|INDEXED */
177718 {
@@ -177723,262 +178111,262 @@
177723 }
177724 sqlite3AddDefaultValue(pParse,p,yymsp[0].minor.yy0.z,yymsp[0].minor.yy0.z+yymsp[0].minor.yy0.n);
177725 }
177726 break;
177727 case 38: /* ccons ::= NOT NULL onconf */
177728 {sqlite3AddNotNull(pParse, yymsp[0].minor.yy144);}
177729 break;
177730 case 39: /* ccons ::= PRIMARY KEY sortorder onconf autoinc */
177731 {sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy144,yymsp[0].minor.yy144,yymsp[-2].minor.yy144);}
177732 break;
177733 case 40: /* ccons ::= UNIQUE onconf */
177734 {sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy144,0,0,0,0,
177735 SQLITE_IDXTYPE_UNIQUE);}
177736 break;
177737 case 41: /* ccons ::= CHECK LP expr RP */
177738 {sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy454,yymsp[-2].minor.yy0.z,yymsp[0].minor.yy0.z);}
177739 break;
177740 case 42: /* ccons ::= REFERENCES nm eidlist_opt refargs */
177741 {sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy14,yymsp[0].minor.yy144);}
177742 break;
177743 case 43: /* ccons ::= defer_subclause */
177744 {sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy144);}
177745 break;
177746 case 44: /* ccons ::= COLLATE ID|STRING */
177747 {sqlite3AddCollateType(pParse, &yymsp[0].minor.yy0);}
177748 break;
177749 case 45: /* generated ::= LP expr RP */
177750 {sqlite3AddGenerated(pParse,yymsp[-1].minor.yy454,0);}
177751 break;
177752 case 46: /* generated ::= LP expr RP ID */
177753 {sqlite3AddGenerated(pParse,yymsp[-2].minor.yy454,&yymsp[0].minor.yy0);}
177754 break;
177755 case 48: /* autoinc ::= AUTOINCR */
177756 {yymsp[0].minor.yy144 = 1;}
177757 break;
177758 case 49: /* refargs ::= */
177759 { yymsp[1].minor.yy144 = OE_None*0x0101; /* EV: R-19803-45884 */}
177760 break;
177761 case 50: /* refargs ::= refargs refarg */
177762 { yymsp[-1].minor.yy144 = (yymsp[-1].minor.yy144 & ~yymsp[0].minor.yy383.mask) | yymsp[0].minor.yy383.value; }
177763 break;
177764 case 51: /* refarg ::= MATCH nm */
177765 { yymsp[-1].minor.yy383.value = 0; yymsp[-1].minor.yy383.mask = 0x000000; }
177766 break;
177767 case 52: /* refarg ::= ON INSERT refact */
177768 { yymsp[-2].minor.yy383.value = 0; yymsp[-2].minor.yy383.mask = 0x000000; }
177769 break;
177770 case 53: /* refarg ::= ON DELETE refact */
177771 { yymsp[-2].minor.yy383.value = yymsp[0].minor.yy144; yymsp[-2].minor.yy383.mask = 0x0000ff; }
177772 break;
177773 case 54: /* refarg ::= ON UPDATE refact */
177774 { yymsp[-2].minor.yy383.value = yymsp[0].minor.yy144<<8; yymsp[-2].minor.yy383.mask = 0x00ff00; }
177775 break;
177776 case 55: /* refact ::= SET NULL */
177777 { yymsp[-1].minor.yy144 = OE_SetNull; /* EV: R-33326-45252 */}
177778 break;
177779 case 56: /* refact ::= SET DEFAULT */
177780 { yymsp[-1].minor.yy144 = OE_SetDflt; /* EV: R-33326-45252 */}
177781 break;
177782 case 57: /* refact ::= CASCADE */
177783 { yymsp[0].minor.yy144 = OE_Cascade; /* EV: R-33326-45252 */}
177784 break;
177785 case 58: /* refact ::= RESTRICT */
177786 { yymsp[0].minor.yy144 = OE_Restrict; /* EV: R-33326-45252 */}
177787 break;
177788 case 59: /* refact ::= NO ACTION */
177789 { yymsp[-1].minor.yy144 = OE_None; /* EV: R-33326-45252 */}
177790 break;
177791 case 60: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
177792 {yymsp[-2].minor.yy144 = 0;}
177793 break;
177794 case 61: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
177795 case 76: /* orconf ::= OR resolvetype */ yytestcase(yyruleno==76);
177796 case 173: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==173);
177797 {yymsp[-1].minor.yy144 = yymsp[0].minor.yy144;}
177798 break;
177799 case 63: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */
177800 case 80: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==80);
177801 case 219: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==219);
177802 case 222: /* in_op ::= NOT IN */ yytestcase(yyruleno==222);
177803 case 247: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==247);
177804 {yymsp[-1].minor.yy144 = 1;}
177805 break;
177806 case 64: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
177807 {yymsp[-1].minor.yy144 = 0;}
177808 break;
177809 case 66: /* tconscomma ::= COMMA */
177810 {pParse->constraintName.n = 0;}
177811 break;
177812 case 68: /* tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
177813 {sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy14,yymsp[0].minor.yy144,yymsp[-2].minor.yy144,0);}
177814 break;
177815 case 69: /* tcons ::= UNIQUE LP sortlist RP onconf */
177816 {sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy14,yymsp[0].minor.yy144,0,0,0,0,
177817 SQLITE_IDXTYPE_UNIQUE);}
177818 break;
177819 case 70: /* tcons ::= CHECK LP expr RP onconf */
177820 {sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy454,yymsp[-3].minor.yy0.z,yymsp[-1].minor.yy0.z);}
177821 break;
177822 case 71: /* tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
177823 {
177824 sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy14, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy14, yymsp[-1].minor.yy144);
177825 sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy144);
177826 }
177827 break;
177828 case 73: /* onconf ::= */
177829 case 75: /* orconf ::= */ yytestcase(yyruleno==75);
177830 {yymsp[1].minor.yy144 = OE_Default;}
177831 break;
177832 case 74: /* onconf ::= ON CONFLICT resolvetype */
177833 {yymsp[-2].minor.yy144 = yymsp[0].minor.yy144;}
177834 break;
177835 case 77: /* resolvetype ::= IGNORE */
177836 {yymsp[0].minor.yy144 = OE_Ignore;}
177837 break;
177838 case 78: /* resolvetype ::= REPLACE */
177839 case 174: /* insert_cmd ::= REPLACE */ yytestcase(yyruleno==174);
177840 {yymsp[0].minor.yy144 = OE_Replace;}
177841 break;
177842 case 79: /* cmd ::= DROP TABLE ifexists fullname */
177843 {
177844 sqlite3DropTable(pParse, yymsp[0].minor.yy203, 0, yymsp[-1].minor.yy144);
177845 }
177846 break;
177847 case 82: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
177848 {
177849 sqlite3CreateView(pParse, &yymsp[-8].minor.yy0, &yymsp[-4].minor.yy0, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy14, yymsp[0].minor.yy555, yymsp[-7].minor.yy144, yymsp[-5].minor.yy144);
177850 }
177851 break;
177852 case 83: /* cmd ::= DROP VIEW ifexists fullname */
177853 {
177854 sqlite3DropTable(pParse, yymsp[0].minor.yy203, 1, yymsp[-1].minor.yy144);
177855 }
177856 break;
177857 case 84: /* cmd ::= select */
177858 {
177859 SelectDest dest = {SRT_Output, 0, 0, 0, 0, 0, 0};
177860 if( (pParse->db->mDbFlags & DBFLAG_EncodingFixed)!=0
177861 || sqlite3ReadSchema(pParse)==SQLITE_OK
177862 ){
177863 sqlite3Select(pParse, yymsp[0].minor.yy555, &dest);
177864 }
177865 sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy555);
177866 }
177867 break;
177868 case 85: /* select ::= WITH wqlist selectnowith */
177869 {yymsp[-2].minor.yy555 = attachWithToSelect(pParse,yymsp[0].minor.yy555,yymsp[-1].minor.yy59);}
177870 break;
177871 case 86: /* select ::= WITH RECURSIVE wqlist selectnowith */
177872 {yymsp[-3].minor.yy555 = attachWithToSelect(pParse,yymsp[0].minor.yy555,yymsp[-1].minor.yy59);}
177873 break;
177874 case 87: /* select ::= selectnowith */
177875 {
177876 Select *p = yymsp[0].minor.yy555;
177877 if( p ){
177878 parserDoubleLinkSelect(pParse, p);
177879 }
177880 }
177881 break;
177882 case 88: /* selectnowith ::= selectnowith multiselect_op oneselect */
177883 {
177884 Select *pRhs = yymsp[0].minor.yy555;
177885 Select *pLhs = yymsp[-2].minor.yy555;
177886 if( pRhs && pRhs->pPrior ){
177887 SrcList *pFrom;
177888 Token x;
177889 x.n = 0;
177890 parserDoubleLinkSelect(pParse, pRhs);
177891 pFrom = sqlite3SrcListAppendFromTerm(pParse,0,0,0,&x,pRhs,0);
177892 pRhs = sqlite3SelectNew(pParse,0,pFrom,0,0,0,0,0,0);
177893 }
177894 if( pRhs ){
177895 pRhs->op = (u8)yymsp[-1].minor.yy144;
177896 pRhs->pPrior = pLhs;
177897 if( ALWAYS(pLhs) ) pLhs->selFlags &= ~SF_MultiValue;
177898 pRhs->selFlags &= ~SF_MultiValue;
177899 if( yymsp[-1].minor.yy144!=TK_ALL ) pParse->hasCompound = 1;
177900 }else{
177901 sqlite3SelectDelete(pParse->db, pLhs);
177902 }
177903 yymsp[-2].minor.yy555 = pRhs;
177904 }
177905 break;
177906 case 89: /* multiselect_op ::= UNION */
177907 case 91: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==91);
177908 {yymsp[0].minor.yy144 = yymsp[0].major; /*A-overwrites-OP*/}
177909 break;
177910 case 90: /* multiselect_op ::= UNION ALL */
177911 {yymsp[-1].minor.yy144 = TK_ALL;}
177912 break;
177913 case 92: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
177914 {
177915 yymsp[-8].minor.yy555 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy14,yymsp[-5].minor.yy203,yymsp[-4].minor.yy454,yymsp[-3].minor.yy14,yymsp[-2].minor.yy454,yymsp[-1].minor.yy14,yymsp[-7].minor.yy144,yymsp[0].minor.yy454);
177916 }
177917 break;
177918 case 93: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */
177919 {
177920 yymsp[-9].minor.yy555 = sqlite3SelectNew(pParse,yymsp[-7].minor.yy14,yymsp[-6].minor.yy203,yymsp[-5].minor.yy454,yymsp[-4].minor.yy14,yymsp[-3].minor.yy454,yymsp[-1].minor.yy14,yymsp[-8].minor.yy144,yymsp[0].minor.yy454);
177921 if( yymsp[-9].minor.yy555 ){
177922 yymsp[-9].minor.yy555->pWinDefn = yymsp[-2].minor.yy211;
177923 }else{
177924 sqlite3WindowListDelete(pParse->db, yymsp[-2].minor.yy211);
177925 }
177926 }
177927 break;
177928 case 94: /* values ::= VALUES LP nexprlist RP */
177929 {
177930 yymsp[-3].minor.yy555 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy14,0,0,0,0,0,SF_Values,0);
177931 }
177932 break;
177933 case 95: /* oneselect ::= mvalues */
177934 {
177935 sqlite3MultiValuesEnd(pParse, yymsp[0].minor.yy555);
177936 }
177937 break;
177938 case 96: /* mvalues ::= values COMMA LP nexprlist RP */
177939 case 97: /* mvalues ::= mvalues COMMA LP nexprlist RP */ yytestcase(yyruleno==97);
177940 {
177941 yymsp[-4].minor.yy555 = sqlite3MultiValues(pParse, yymsp[-4].minor.yy555, yymsp[-1].minor.yy14);
177942 }
177943 break;
177944 case 98: /* distinct ::= DISTINCT */
177945 {yymsp[0].minor.yy144 = SF_Distinct;}
177946 break;
177947 case 99: /* distinct ::= ALL */
177948 {yymsp[0].minor.yy144 = SF_All;}
177949 break;
177950 case 101: /* sclp ::= */
177951 case 134: /* orderby_opt ::= */ yytestcase(yyruleno==134);
177952 case 144: /* groupby_opt ::= */ yytestcase(yyruleno==144);
177953 case 234: /* exprlist ::= */ yytestcase(yyruleno==234);
177954 case 237: /* paren_exprlist ::= */ yytestcase(yyruleno==237);
177955 case 242: /* eidlist_opt ::= */ yytestcase(yyruleno==242);
177956 {yymsp[1].minor.yy14 = 0;}
177957 break;
177958 case 102: /* selcollist ::= sclp scanpt expr scanpt as */
177959 {
177960 yymsp[-4].minor.yy14 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy14, yymsp[-2].minor.yy454);
177961 if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy14, &yymsp[0].minor.yy0, 1);
177962 sqlite3ExprListSetSpan(pParse,yymsp[-4].minor.yy14,yymsp[-3].minor.yy168,yymsp[-1].minor.yy168);
177963 }
177964 break;
177965 case 103: /* selcollist ::= sclp scanpt STAR */
177966 {
177967 Expr *p = sqlite3Expr(pParse->db, TK_ASTERISK, 0);
177968 sqlite3ExprSetErrorOffset(p, (int)(yymsp[0].minor.yy0.z - pParse->zTail));
177969 yymsp[-2].minor.yy14 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy14, p);
177970 }
177971 break;
177972 case 104: /* selcollist ::= sclp scanpt nm DOT STAR */
177973 {
177974 Expr *pRight, *pLeft, *pDot;
177975 pRight = sqlite3PExpr(pParse, TK_ASTERISK, 0, 0);
177976 sqlite3ExprSetErrorOffset(pRight, (int)(yymsp[0].minor.yy0.z - pParse->zTail));
177977 pLeft = tokenExpr(pParse, TK_ID, yymsp[-2].minor.yy0);
177978 pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight);
177979 yymsp[-4].minor.yy14 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy14, pDot);
177980 }
177981 break;
177982 case 105: /* as ::= AS nm */
177983 case 117: /* dbnm ::= DOT nm */ yytestcase(yyruleno==117);
177984 case 258: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==258);
@@ -177985,54 +178373,54 @@
177985 case 259: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==259);
177986 {yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;}
177987 break;
177988 case 107: /* from ::= */
177989 case 110: /* stl_prefix ::= */ yytestcase(yyruleno==110);
177990 {yymsp[1].minor.yy203 = 0;}
177991 break;
177992 case 108: /* from ::= FROM seltablist */
177993 {
177994 yymsp[-1].minor.yy203 = yymsp[0].minor.yy203;
177995 sqlite3SrcListShiftJoinType(pParse,yymsp[-1].minor.yy203);
177996 }
177997 break;
177998 case 109: /* stl_prefix ::= seltablist joinop */
177999 {
178000 if( ALWAYS(yymsp[-1].minor.yy203 && yymsp[-1].minor.yy203->nSrc>0) ) yymsp[-1].minor.yy203->a[yymsp[-1].minor.yy203->nSrc-1].fg.jointype = (u8)yymsp[0].minor.yy144;
178001 }
178002 break;
178003 case 111: /* seltablist ::= stl_prefix nm dbnm as on_using */
178004 {
178005 yymsp[-4].minor.yy203 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-4].minor.yy203,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0,&yymsp[0].minor.yy269);
178006 }
178007 break;
178008 case 112: /* seltablist ::= stl_prefix nm dbnm as indexed_by on_using */
178009 {
178010 yymsp[-5].minor.yy203 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-5].minor.yy203,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,0,&yymsp[0].minor.yy269);
178011 sqlite3SrcListIndexedBy(pParse, yymsp[-5].minor.yy203, &yymsp[-1].minor.yy0);
178012 }
178013 break;
178014 case 113: /* seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_using */
178015 {
178016 yymsp[-7].minor.yy203 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-7].minor.yy203,&yymsp[-6].minor.yy0,&yymsp[-5].minor.yy0,&yymsp[-1].minor.yy0,0,&yymsp[0].minor.yy269);
178017 sqlite3SrcListFuncArgs(pParse, yymsp[-7].minor.yy203, yymsp[-3].minor.yy14);
178018 }
178019 break;
178020 case 114: /* seltablist ::= stl_prefix LP select RP as on_using */
178021 {
178022 yymsp[-5].minor.yy203 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-5].minor.yy203,0,0,&yymsp[-1].minor.yy0,yymsp[-3].minor.yy555,&yymsp[0].minor.yy269);
178023 }
178024 break;
178025 case 115: /* seltablist ::= stl_prefix LP seltablist RP as on_using */
178026 {
178027 if( yymsp[-5].minor.yy203==0 && yymsp[-1].minor.yy0.n==0 && yymsp[0].minor.yy269.pOn==0 && yymsp[0].minor.yy269.pUsing==0 ){
178028 yymsp[-5].minor.yy203 = yymsp[-3].minor.yy203;
178029 }else if( ALWAYS(yymsp[-3].minor.yy203!=0) && yymsp[-3].minor.yy203->nSrc==1 ){
178030 yymsp[-5].minor.yy203 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-5].minor.yy203,0,0,&yymsp[-1].minor.yy0,0,&yymsp[0].minor.yy269);
178031 if( yymsp[-5].minor.yy203 ){
178032 SrcItem *pNew = &yymsp[-5].minor.yy203->a[yymsp[-5].minor.yy203->nSrc-1];
178033 SrcItem *pOld = yymsp[-3].minor.yy203->a;
178034 assert( pOld->fg.fixedSchema==0 );
178035 pNew->zName = pOld->zName;
178036 assert( pOld->fg.fixedSchema==0 );
178037 if( pOld->fg.isSubquery ){
178038 pNew->fg.isSubquery = 1;
@@ -178053,249 +178441,249 @@
178053 pOld->fg.isTabFunc = 0;
178054 pNew->fg.isTabFunc = 1;
178055 }
178056 pOld->zName = 0;
178057 }
178058 sqlite3SrcListDelete(pParse->db, yymsp[-3].minor.yy203);
178059 }else{
178060 Select *pSubquery;
178061 sqlite3SrcListShiftJoinType(pParse,yymsp[-3].minor.yy203);
178062 pSubquery = sqlite3SelectNew(pParse,0,yymsp[-3].minor.yy203,0,0,0,0,SF_NestedFrom,0);
178063 yymsp[-5].minor.yy203 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-5].minor.yy203,0,0,&yymsp[-1].minor.yy0,pSubquery,&yymsp[0].minor.yy269);
178064 }
178065 }
178066 break;
178067 case 116: /* dbnm ::= */
178068 case 131: /* indexed_opt ::= */ yytestcase(yyruleno==131);
178069 {yymsp[1].minor.yy0.z=0; yymsp[1].minor.yy0.n=0;}
178070 break;
178071 case 118: /* fullname ::= nm */
178072 {
178073 yylhsminor.yy203 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0);
178074 if( IN_RENAME_OBJECT && yylhsminor.yy203 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy203->a[0].zName, &yymsp[0].minor.yy0);
178075 }
178076 yymsp[0].minor.yy203 = yylhsminor.yy203;
178077 break;
178078 case 119: /* fullname ::= nm DOT nm */
178079 {
178080 yylhsminor.yy203 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);
178081 if( IN_RENAME_OBJECT && yylhsminor.yy203 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy203->a[0].zName, &yymsp[0].minor.yy0);
178082 }
178083 yymsp[-2].minor.yy203 = yylhsminor.yy203;
178084 break;
178085 case 120: /* xfullname ::= nm */
178086 {yymsp[0].minor.yy203 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0); /*A-overwrites-X*/}
178087 break;
178088 case 121: /* xfullname ::= nm DOT nm */
178089 {yymsp[-2].minor.yy203 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/}
178090 break;
178091 case 122: /* xfullname ::= nm DOT nm AS nm */
178092 {
178093 yymsp[-4].minor.yy203 = sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,&yymsp[-2].minor.yy0); /*A-overwrites-X*/
178094 if( yymsp[-4].minor.yy203 ) yymsp[-4].minor.yy203->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
178095 }
178096 break;
178097 case 123: /* xfullname ::= nm AS nm */
178098 {
178099 yymsp[-2].minor.yy203 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,0); /*A-overwrites-X*/
178100 if( yymsp[-2].minor.yy203 ) yymsp[-2].minor.yy203->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
178101 }
178102 break;
178103 case 124: /* joinop ::= COMMA|JOIN */
178104 { yymsp[0].minor.yy144 = JT_INNER; }
178105 break;
178106 case 125: /* joinop ::= JOIN_KW JOIN */
178107 {yymsp[-1].minor.yy144 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); /*X-overwrites-A*/}
178108 break;
178109 case 126: /* joinop ::= JOIN_KW nm JOIN */
178110 {yymsp[-2].minor.yy144 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/}
178111 break;
178112 case 127: /* joinop ::= JOIN_KW nm nm JOIN */
178113 {yymsp[-3].minor.yy144 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/}
178114 break;
178115 case 128: /* on_using ::= ON expr */
178116 {yymsp[-1].minor.yy269.pOn = yymsp[0].minor.yy454; yymsp[-1].minor.yy269.pUsing = 0;}
178117 break;
178118 case 129: /* on_using ::= USING LP idlist RP */
178119 {yymsp[-3].minor.yy269.pOn = 0; yymsp[-3].minor.yy269.pUsing = yymsp[-1].minor.yy132;}
178120 break;
178121 case 130: /* on_using ::= */
178122 {yymsp[1].minor.yy269.pOn = 0; yymsp[1].minor.yy269.pUsing = 0;}
178123 break;
178124 case 132: /* indexed_by ::= INDEXED BY nm */
178125 {yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;}
178126 break;
178127 case 133: /* indexed_by ::= NOT INDEXED */
178128 {yymsp[-1].minor.yy0.z=0; yymsp[-1].minor.yy0.n=1;}
178129 break;
178130 case 135: /* orderby_opt ::= ORDER BY sortlist */
178131 case 145: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==145);
178132 {yymsp[-2].minor.yy14 = yymsp[0].minor.yy14;}
178133 break;
178134 case 136: /* sortlist ::= sortlist COMMA expr sortorder nulls */
178135 {
178136 yymsp[-4].minor.yy14 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy14,yymsp[-2].minor.yy454);
178137 sqlite3ExprListSetSortOrder(yymsp[-4].minor.yy14,yymsp[-1].minor.yy144,yymsp[0].minor.yy144);
178138 }
178139 break;
178140 case 137: /* sortlist ::= expr sortorder nulls */
178141 {
178142 yymsp[-2].minor.yy14 = sqlite3ExprListAppend(pParse,0,yymsp[-2].minor.yy454); /*A-overwrites-Y*/
178143 sqlite3ExprListSetSortOrder(yymsp[-2].minor.yy14,yymsp[-1].minor.yy144,yymsp[0].minor.yy144);
178144 }
178145 break;
178146 case 138: /* sortorder ::= ASC */
178147 {yymsp[0].minor.yy144 = SQLITE_SO_ASC;}
178148 break;
178149 case 139: /* sortorder ::= DESC */
178150 {yymsp[0].minor.yy144 = SQLITE_SO_DESC;}
178151 break;
178152 case 140: /* sortorder ::= */
178153 case 143: /* nulls ::= */ yytestcase(yyruleno==143);
178154 {yymsp[1].minor.yy144 = SQLITE_SO_UNDEFINED;}
178155 break;
178156 case 141: /* nulls ::= NULLS FIRST */
178157 {yymsp[-1].minor.yy144 = SQLITE_SO_ASC;}
178158 break;
178159 case 142: /* nulls ::= NULLS LAST */
178160 {yymsp[-1].minor.yy144 = SQLITE_SO_DESC;}
178161 break;
178162 case 146: /* having_opt ::= */
178163 case 148: /* limit_opt ::= */ yytestcase(yyruleno==148);
178164 case 153: /* where_opt ::= */ yytestcase(yyruleno==153);
178165 case 155: /* where_opt_ret ::= */ yytestcase(yyruleno==155);
178166 case 232: /* case_else ::= */ yytestcase(yyruleno==232);
178167 case 233: /* case_operand ::= */ yytestcase(yyruleno==233);
178168 case 252: /* vinto ::= */ yytestcase(yyruleno==252);
178169 {yymsp[1].minor.yy454 = 0;}
178170 break;
178171 case 147: /* having_opt ::= HAVING expr */
178172 case 154: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==154);
178173 case 156: /* where_opt_ret ::= WHERE expr */ yytestcase(yyruleno==156);
178174 case 231: /* case_else ::= ELSE expr */ yytestcase(yyruleno==231);
178175 case 251: /* vinto ::= INTO expr */ yytestcase(yyruleno==251);
178176 {yymsp[-1].minor.yy454 = yymsp[0].minor.yy454;}
178177 break;
178178 case 149: /* limit_opt ::= LIMIT expr */
178179 {yymsp[-1].minor.yy454 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy454,0);}
178180 break;
178181 case 150: /* limit_opt ::= LIMIT expr OFFSET expr */
178182 {yymsp[-3].minor.yy454 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[-2].minor.yy454,yymsp[0].minor.yy454);}
178183 break;
178184 case 151: /* limit_opt ::= LIMIT expr COMMA expr */
178185 {yymsp[-3].minor.yy454 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy454,yymsp[-2].minor.yy454);}
178186 break;
178187 case 152: /* cmd ::= with DELETE FROM xfullname indexed_opt where_opt_ret */
178188 {
178189 sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy203, &yymsp[-1].minor.yy0);
178190 sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy203,yymsp[0].minor.yy454,0,0);
178191 }
178192 break;
178193 case 157: /* where_opt_ret ::= RETURNING selcollist */
178194 {sqlite3AddReturning(pParse,yymsp[0].minor.yy14); yymsp[-1].minor.yy454 = 0;}
178195 break;
178196 case 158: /* where_opt_ret ::= WHERE expr RETURNING selcollist */
178197 {sqlite3AddReturning(pParse,yymsp[0].minor.yy14); yymsp[-3].minor.yy454 = yymsp[-2].minor.yy454;}
178198 break;
178199 case 159: /* cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist from where_opt_ret */
178200 {
178201 sqlite3SrcListIndexedBy(pParse, yymsp[-5].minor.yy203, &yymsp[-4].minor.yy0);
178202 sqlite3ExprListCheckLength(pParse,yymsp[-2].minor.yy14,"set list");
178203 if( yymsp[-1].minor.yy203 ){
178204 SrcList *pFromClause = yymsp[-1].minor.yy203;
178205 if( pFromClause->nSrc>1 ){
178206 Select *pSubquery;
178207 Token as;
178208 pSubquery = sqlite3SelectNew(pParse,0,pFromClause,0,0,0,0,SF_NestedFrom,0);
178209 as.n = 0;
178210 as.z = 0;
178211 pFromClause = sqlite3SrcListAppendFromTerm(pParse,0,0,0,&as,pSubquery,0);
178212 }
178213 yymsp[-5].minor.yy203 = sqlite3SrcListAppendList(pParse, yymsp[-5].minor.yy203, pFromClause);
178214 }
178215 sqlite3Update(pParse,yymsp[-5].minor.yy203,yymsp[-2].minor.yy14,yymsp[0].minor.yy454,yymsp[-6].minor.yy144,0,0,0);
178216 }
178217 break;
178218 case 160: /* setlist ::= setlist COMMA nm EQ expr */
178219 {
178220 yymsp[-4].minor.yy14 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy14, yymsp[0].minor.yy454);
178221 sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy14, &yymsp[-2].minor.yy0, 1);
178222 }
178223 break;
178224 case 161: /* setlist ::= setlist COMMA LP idlist RP EQ expr */
178225 {
178226 yymsp[-6].minor.yy14 = sqlite3ExprListAppendVector(pParse, yymsp[-6].minor.yy14, yymsp[-3].minor.yy132, yymsp[0].minor.yy454);
178227 }
178228 break;
178229 case 162: /* setlist ::= nm EQ expr */
178230 {
178231 yylhsminor.yy14 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy454);
178232 sqlite3ExprListSetName(pParse, yylhsminor.yy14, &yymsp[-2].minor.yy0, 1);
178233 }
178234 yymsp[-2].minor.yy14 = yylhsminor.yy14;
178235 break;
178236 case 163: /* setlist ::= LP idlist RP EQ expr */
178237 {
178238 yymsp[-4].minor.yy14 = sqlite3ExprListAppendVector(pParse, 0, yymsp[-3].minor.yy132, yymsp[0].minor.yy454);
178239 }
178240 break;
178241 case 164: /* cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
178242 {
178243 sqlite3Insert(pParse, yymsp[-3].minor.yy203, yymsp[-1].minor.yy555, yymsp[-2].minor.yy132, yymsp[-5].minor.yy144, yymsp[0].minor.yy122);
178244 }
178245 break;
178246 case 165: /* cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES returning */
178247 {
178248 sqlite3Insert(pParse, yymsp[-4].minor.yy203, 0, yymsp[-3].minor.yy132, yymsp[-6].minor.yy144, 0);
178249 }
178250 break;
178251 case 166: /* upsert ::= */
178252 { yymsp[1].minor.yy122 = 0; }
178253 break;
178254 case 167: /* upsert ::= RETURNING selcollist */
178255 { yymsp[-1].minor.yy122 = 0; sqlite3AddReturning(pParse,yymsp[0].minor.yy14); }
178256 break;
178257 case 168: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt upsert */
178258 { yymsp[-11].minor.yy122 = sqlite3UpsertNew(pParse->db,yymsp[-8].minor.yy14,yymsp[-6].minor.yy454,yymsp[-2].minor.yy14,yymsp[-1].minor.yy454,yymsp[0].minor.yy122);}
178259 break;
178260 case 169: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING upsert */
178261 { yymsp[-8].minor.yy122 = sqlite3UpsertNew(pParse->db,yymsp[-5].minor.yy14,yymsp[-3].minor.yy454,0,0,yymsp[0].minor.yy122); }
178262 break;
178263 case 170: /* upsert ::= ON CONFLICT DO NOTHING returning */
178264 { yymsp[-4].minor.yy122 = sqlite3UpsertNew(pParse->db,0,0,0,0,0); }
178265 break;
178266 case 171: /* upsert ::= ON CONFLICT DO UPDATE SET setlist where_opt returning */
178267 { yymsp[-7].minor.yy122 = sqlite3UpsertNew(pParse->db,0,0,yymsp[-2].minor.yy14,yymsp[-1].minor.yy454,0);}
178268 break;
178269 case 172: /* returning ::= RETURNING selcollist */
178270 {sqlite3AddReturning(pParse,yymsp[0].minor.yy14);}
178271 break;
178272 case 175: /* idlist_opt ::= */
178273 {yymsp[1].minor.yy132 = 0;}
178274 break;
178275 case 176: /* idlist_opt ::= LP idlist RP */
178276 {yymsp[-2].minor.yy132 = yymsp[-1].minor.yy132;}
178277 break;
178278 case 177: /* idlist ::= idlist COMMA nm */
178279 {yymsp[-2].minor.yy132 = sqlite3IdListAppend(pParse,yymsp[-2].minor.yy132,&yymsp[0].minor.yy0);}
178280 break;
178281 case 178: /* idlist ::= nm */
178282 {yymsp[0].minor.yy132 = sqlite3IdListAppend(pParse,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/}
178283 break;
178284 case 179: /* expr ::= LP expr RP */
178285 {yymsp[-2].minor.yy454 = yymsp[-1].minor.yy454;}
178286 break;
178287 case 180: /* expr ::= ID|INDEXED|JOIN_KW */
178288 {yymsp[0].minor.yy454=tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/}
178289 break;
178290 case 181: /* expr ::= nm DOT nm */
178291 {
178292 Expr *temp1 = tokenExpr(pParse,TK_ID,yymsp[-2].minor.yy0);
178293 Expr *temp2 = tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0);
178294 yylhsminor.yy454 = sqlite3PExpr(pParse, TK_DOT, temp1, temp2);
178295 }
178296 yymsp[-2].minor.yy454 = yylhsminor.yy454;
178297 break;
178298 case 182: /* expr ::= nm DOT nm DOT nm */
178299 {
178300 Expr *temp1 = tokenExpr(pParse,TK_ID,yymsp[-4].minor.yy0);
178301 Expr *temp2 = tokenExpr(pParse,TK_ID,yymsp[-2].minor.yy0);
@@ -178302,378 +178690,378 @@
178302 Expr *temp3 = tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0);
178303 Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3);
178304 if( IN_RENAME_OBJECT ){
178305 sqlite3RenameTokenRemap(pParse, 0, temp1);
178306 }
178307 yylhsminor.yy454 = sqlite3PExpr(pParse, TK_DOT, temp1, temp4);
178308 }
178309 yymsp[-4].minor.yy454 = yylhsminor.yy454;
178310 break;
178311 case 183: /* term ::= NULL|FLOAT|BLOB */
178312 case 184: /* term ::= STRING */ yytestcase(yyruleno==184);
178313 {yymsp[0].minor.yy454=tokenExpr(pParse,yymsp[0].major,yymsp[0].minor.yy0); /*A-overwrites-X*/}
178314 break;
178315 case 185: /* term ::= INTEGER */
178316 {
178317 yylhsminor.yy454 = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &yymsp[0].minor.yy0, 1);
178318 if( yylhsminor.yy454 ) yylhsminor.yy454->w.iOfst = (int)(yymsp[0].minor.yy0.z - pParse->zTail);
178319 }
178320 yymsp[0].minor.yy454 = yylhsminor.yy454;
178321 break;
178322 case 186: /* expr ::= VARIABLE */
178323 {
178324 if( !(yymsp[0].minor.yy0.z[0]=='#' && sqlite3Isdigit(yymsp[0].minor.yy0.z[1])) ){
178325 u32 n = yymsp[0].minor.yy0.n;
178326 yymsp[0].minor.yy454 = tokenExpr(pParse, TK_VARIABLE, yymsp[0].minor.yy0);
178327 sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy454, n);
178328 }else{
178329 /* When doing a nested parse, one can include terms in an expression
178330 ** that look like this: #1 #2 ... These terms refer to registers
178331 ** in the virtual machine. #N is the N-th register. */
178332 Token t = yymsp[0].minor.yy0; /*A-overwrites-X*/
178333 assert( t.n>=2 );
178334 if( pParse->nested==0 ){
178335 parserSyntaxError(pParse, &t);
178336 yymsp[0].minor.yy454 = 0;
178337 }else{
178338 yymsp[0].minor.yy454 = sqlite3PExpr(pParse, TK_REGISTER, 0, 0);
178339 if( yymsp[0].minor.yy454 ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy454->iTable);
178340 }
178341 }
178342 }
178343 break;
178344 case 187: /* expr ::= expr COLLATE ID|STRING */
178345 {
178346 yymsp[-2].minor.yy454 = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy454, &yymsp[0].minor.yy0, 1);
178347 }
178348 break;
178349 case 188: /* expr ::= CAST LP expr AS typetoken RP */
178350 {
178351 yymsp[-5].minor.yy454 = sqlite3ExprAlloc(pParse->db, TK_CAST, &yymsp[-1].minor.yy0, 1);
178352 sqlite3ExprAttachSubtrees(pParse->db, yymsp[-5].minor.yy454, yymsp[-3].minor.yy454, 0);
178353 }
178354 break;
178355 case 189: /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP */
178356 {
178357 yylhsminor.yy454 = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy14, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy144);
178358 }
178359 yymsp[-4].minor.yy454 = yylhsminor.yy454;
178360 break;
178361 case 190: /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP */
178362 {
178363 yylhsminor.yy454 = sqlite3ExprFunction(pParse, yymsp[-4].minor.yy14, &yymsp[-7].minor.yy0, yymsp[-5].minor.yy144);
178364 sqlite3ExprAddFunctionOrderBy(pParse, yylhsminor.yy454, yymsp[-1].minor.yy14);
178365 }
178366 yymsp[-7].minor.yy454 = yylhsminor.yy454;
178367 break;
178368 case 191: /* expr ::= ID|INDEXED|JOIN_KW LP STAR RP */
178369 {
178370 yylhsminor.yy454 = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0, 0);
178371 }
178372 yymsp[-3].minor.yy454 = yylhsminor.yy454;
178373 break;
178374 case 192: /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP filter_over */
178375 {
178376 yylhsminor.yy454 = sqlite3ExprFunction(pParse, yymsp[-2].minor.yy14, &yymsp[-5].minor.yy0, yymsp[-3].minor.yy144);
178377 sqlite3WindowAttach(pParse, yylhsminor.yy454, yymsp[0].minor.yy211);
178378 }
178379 yymsp[-5].minor.yy454 = yylhsminor.yy454;
178380 break;
178381 case 193: /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP filter_over */
178382 {
178383 yylhsminor.yy454 = sqlite3ExprFunction(pParse, yymsp[-5].minor.yy14, &yymsp[-8].minor.yy0, yymsp[-6].minor.yy144);
178384 sqlite3WindowAttach(pParse, yylhsminor.yy454, yymsp[0].minor.yy211);
178385 sqlite3ExprAddFunctionOrderBy(pParse, yylhsminor.yy454, yymsp[-2].minor.yy14);
178386 }
178387 yymsp[-8].minor.yy454 = yylhsminor.yy454;
178388 break;
178389 case 194: /* expr ::= ID|INDEXED|JOIN_KW LP STAR RP filter_over */
178390 {
178391 yylhsminor.yy454 = sqlite3ExprFunction(pParse, 0, &yymsp[-4].minor.yy0, 0);
178392 sqlite3WindowAttach(pParse, yylhsminor.yy454, yymsp[0].minor.yy211);
178393 }
178394 yymsp[-4].minor.yy454 = yylhsminor.yy454;
178395 break;
178396 case 195: /* term ::= CTIME_KW */
178397 {
178398 yylhsminor.yy454 = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0, 0);
178399 }
178400 yymsp[0].minor.yy454 = yylhsminor.yy454;
178401 break;
178402 case 196: /* expr ::= LP nexprlist COMMA expr RP */
178403 {
178404 ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy14, yymsp[-1].minor.yy454);
178405 yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_VECTOR, 0, 0);
178406 if( yymsp[-4].minor.yy454 ){
178407 yymsp[-4].minor.yy454->x.pList = pList;
178408 if( ALWAYS(pList->nExpr) ){
178409 yymsp[-4].minor.yy454->flags |= pList->a[0].pExpr->flags & EP_Propagate;
178410 }
178411 }else{
178412 sqlite3ExprListDelete(pParse->db, pList);
178413 }
178414 }
178415 break;
178416 case 197: /* expr ::= expr AND expr */
178417 {yymsp[-2].minor.yy454=sqlite3ExprAnd(pParse,yymsp[-2].minor.yy454,yymsp[0].minor.yy454);}
178418 break;
178419 case 198: /* expr ::= expr OR expr */
178420 case 199: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==199);
178421 case 200: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==200);
178422 case 201: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==201);
178423 case 202: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==202);
178424 case 203: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==203);
178425 case 204: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==204);
178426 {yymsp[-2].minor.yy454=sqlite3PExpr(pParse,yymsp[-1].major,yymsp[-2].minor.yy454,yymsp[0].minor.yy454);}
178427 break;
178428 case 205: /* likeop ::= NOT LIKE_KW|MATCH */
178429 {yymsp[-1].minor.yy0=yymsp[0].minor.yy0; yymsp[-1].minor.yy0.n|=0x80000000; /*yymsp[-1].minor.yy0-overwrite-yymsp[0].minor.yy0*/}
178430 break;
178431 case 206: /* expr ::= expr likeop expr */
178432 {
178433 ExprList *pList;
178434 int bNot = yymsp[-1].minor.yy0.n & 0x80000000;
178435 yymsp[-1].minor.yy0.n &= 0x7fffffff;
178436 pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy454);
178437 pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy454);
178438 yymsp[-2].minor.yy454 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0, 0);
178439 if( bNot ) yymsp[-2].minor.yy454 = sqlite3PExpr(pParse, TK_NOT, yymsp[-2].minor.yy454, 0);
178440 if( yymsp[-2].minor.yy454 ) yymsp[-2].minor.yy454->flags |= EP_InfixFunc;
178441 }
178442 break;
178443 case 207: /* expr ::= expr likeop expr ESCAPE expr */
178444 {
178445 ExprList *pList;
178446 int bNot = yymsp[-3].minor.yy0.n & 0x80000000;
178447 yymsp[-3].minor.yy0.n &= 0x7fffffff;
178448 pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy454);
178449 pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy454);
178450 pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy454);
178451 yymsp[-4].minor.yy454 = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy0, 0);
178452 if( bNot ) yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy454, 0);
178453 if( yymsp[-4].minor.yy454 ) yymsp[-4].minor.yy454->flags |= EP_InfixFunc;
178454 }
178455 break;
178456 case 208: /* expr ::= expr ISNULL|NOTNULL */
178457 {yymsp[-1].minor.yy454 = sqlite3PExpr(pParse,yymsp[0].major,yymsp[-1].minor.yy454,0);}
178458 break;
178459 case 209: /* expr ::= expr NOT NULL */
178460 {yymsp[-2].minor.yy454 = sqlite3PExpr(pParse,TK_NOTNULL,yymsp[-2].minor.yy454,0);}
178461 break;
178462 case 210: /* expr ::= expr IS expr */
178463 {
178464 yymsp[-2].minor.yy454 = sqlite3PExpr(pParse,TK_IS,yymsp[-2].minor.yy454,yymsp[0].minor.yy454);
178465 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy454, yymsp[-2].minor.yy454, TK_ISNULL);
178466 }
178467 break;
178468 case 211: /* expr ::= expr IS NOT expr */
178469 {
178470 yymsp[-3].minor.yy454 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-3].minor.yy454,yymsp[0].minor.yy454);
178471 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy454, yymsp[-3].minor.yy454, TK_NOTNULL);
178472 }
178473 break;
178474 case 212: /* expr ::= expr IS NOT DISTINCT FROM expr */
178475 {
178476 yymsp[-5].minor.yy454 = sqlite3PExpr(pParse,TK_IS,yymsp[-5].minor.yy454,yymsp[0].minor.yy454);
178477 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy454, yymsp[-5].minor.yy454, TK_ISNULL);
178478 }
178479 break;
178480 case 213: /* expr ::= expr IS DISTINCT FROM expr */
178481 {
178482 yymsp[-4].minor.yy454 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-4].minor.yy454,yymsp[0].minor.yy454);
178483 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy454, yymsp[-4].minor.yy454, TK_NOTNULL);
178484 }
178485 break;
178486 case 214: /* expr ::= NOT expr */
178487 case 215: /* expr ::= BITNOT expr */ yytestcase(yyruleno==215);
178488 {yymsp[-1].minor.yy454 = sqlite3PExpr(pParse, yymsp[-1].major, yymsp[0].minor.yy454, 0);/*A-overwrites-B*/}
178489 break;
178490 case 216: /* expr ::= PLUS|MINUS expr */
178491 {
178492 Expr *p = yymsp[0].minor.yy454;
178493 u8 op = yymsp[-1].major + (TK_UPLUS-TK_PLUS);
178494 assert( TK_UPLUS>TK_PLUS );
178495 assert( TK_UMINUS == TK_MINUS + (TK_UPLUS - TK_PLUS) );
178496 if( p && p->op==TK_UPLUS ){
178497 p->op = op;
178498 yymsp[-1].minor.yy454 = p;
178499 }else{
178500 yymsp[-1].minor.yy454 = sqlite3PExpr(pParse, op, p, 0);
178501 /*A-overwrites-B*/
178502 }
178503 }
178504 break;
178505 case 217: /* expr ::= expr PTR expr */
178506 {
178507 ExprList *pList = sqlite3ExprListAppend(pParse, 0, yymsp[-2].minor.yy454);
178508 pList = sqlite3ExprListAppend(pParse, pList, yymsp[0].minor.yy454);
178509 yylhsminor.yy454 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0, 0);
178510 }
178511 yymsp[-2].minor.yy454 = yylhsminor.yy454;
178512 break;
178513 case 218: /* between_op ::= BETWEEN */
178514 case 221: /* in_op ::= IN */ yytestcase(yyruleno==221);
178515 {yymsp[0].minor.yy144 = 0;}
178516 break;
178517 case 220: /* expr ::= expr between_op expr AND expr */
178518 {
178519 ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy454);
178520 pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy454);
178521 yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy454, 0);
178522 if( yymsp[-4].minor.yy454 ){
178523 yymsp[-4].minor.yy454->x.pList = pList;
178524 }else{
178525 sqlite3ExprListDelete(pParse->db, pList);
178526 }
178527 if( yymsp[-3].minor.yy144 ) yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy454, 0);
178528 }
178529 break;
178530 case 223: /* expr ::= expr in_op LP exprlist RP */
178531 {
178532 if( yymsp[-1].minor.yy14==0 ){
178533 /* Expressions of the form
178534 **
178535 ** expr1 IN ()
178536 ** expr1 NOT IN ()
178537 **
178538 ** simplify to constants 0 (false) and 1 (true), respectively,
178539 ** regardless of the value of expr1.
178540 */
178541 sqlite3ExprUnmapAndDelete(pParse, yymsp[-4].minor.yy454);
178542 yymsp[-4].minor.yy454 = sqlite3Expr(pParse->db, TK_STRING, yymsp[-3].minor.yy144 ? "true" : "false");
178543 if( yymsp[-4].minor.yy454 ) sqlite3ExprIdToTrueFalse(yymsp[-4].minor.yy454);
178544 }else{
178545 Expr *pRHS = yymsp[-1].minor.yy14->a[0].pExpr;
178546 if( yymsp[-1].minor.yy14->nExpr==1 && sqlite3ExprIsConstant(pParse,pRHS) && yymsp[-4].minor.yy454->op!=TK_VECTOR ){
178547 yymsp[-1].minor.yy14->a[0].pExpr = 0;
178548 sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy14);
178549 pRHS = sqlite3PExpr(pParse, TK_UPLUS, pRHS, 0);
178550 yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_EQ, yymsp[-4].minor.yy454, pRHS);
178551 }else if( yymsp[-1].minor.yy14->nExpr==1 && pRHS->op==TK_SELECT ){
178552 yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy454, 0);
178553 sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy454, pRHS->x.pSelect);
178554 pRHS->x.pSelect = 0;
178555 sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy14);
178556 }else{
178557 yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy454, 0);
178558 if( yymsp[-4].minor.yy454==0 ){
178559 sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy14);
178560 }else if( yymsp[-4].minor.yy454->pLeft->op==TK_VECTOR ){
178561 int nExpr = yymsp[-4].minor.yy454->pLeft->x.pList->nExpr;
178562 Select *pSelectRHS = sqlite3ExprListToValues(pParse, nExpr, yymsp[-1].minor.yy14);
178563 if( pSelectRHS ){
178564 parserDoubleLinkSelect(pParse, pSelectRHS);
178565 sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy454, pSelectRHS);
178566 }
178567 }else{
178568 yymsp[-4].minor.yy454->x.pList = yymsp[-1].minor.yy14;
178569 sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy454);
178570 }
178571 }
178572 if( yymsp[-3].minor.yy144 ) yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy454, 0);
178573 }
178574 }
178575 break;
178576 case 224: /* expr ::= LP select RP */
178577 {
178578 yymsp[-2].minor.yy454 = sqlite3PExpr(pParse, TK_SELECT, 0, 0);
178579 sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy454, yymsp[-1].minor.yy555);
178580 }
178581 break;
178582 case 225: /* expr ::= expr in_op LP select RP */
178583 {
178584 yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy454, 0);
178585 sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy454, yymsp[-1].minor.yy555);
178586 if( yymsp[-3].minor.yy144 ) yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy454, 0);
178587 }
178588 break;
178589 case 226: /* expr ::= expr in_op nm dbnm paren_exprlist */
178590 {
178591 SrcList *pSrc = sqlite3SrcListAppend(pParse, 0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);
178592 Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0);
178593 if( yymsp[0].minor.yy14 ) sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy14);
178594 yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy454, 0);
178595 sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy454, pSelect);
178596 if( yymsp[-3].minor.yy144 ) yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy454, 0);
178597 }
178598 break;
178599 case 227: /* expr ::= EXISTS LP select RP */
178600 {
178601 Expr *p;
178602 p = yymsp[-3].minor.yy454 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0);
178603 sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy555);
178604 }
178605 break;
178606 case 228: /* expr ::= CASE case_operand case_exprlist case_else END */
178607 {
178608 yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy454, 0);
178609 if( yymsp[-4].minor.yy454 ){
178610 yymsp[-4].minor.yy454->x.pList = yymsp[-1].minor.yy454 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy14,yymsp[-1].minor.yy454) : yymsp[-2].minor.yy14;
178611 sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy454);
178612 }else{
178613 sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy14);
178614 sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy454);
178615 }
178616 }
178617 break;
178618 case 229: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
178619 {
178620 yymsp[-4].minor.yy14 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy14, yymsp[-2].minor.yy454);
178621 yymsp[-4].minor.yy14 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy14, yymsp[0].minor.yy454);
178622 }
178623 break;
178624 case 230: /* case_exprlist ::= WHEN expr THEN expr */
178625 {
178626 yymsp[-3].minor.yy14 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy454);
178627 yymsp[-3].minor.yy14 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy14, yymsp[0].minor.yy454);
178628 }
178629 break;
178630 case 235: /* nexprlist ::= nexprlist COMMA expr */
178631 {yymsp[-2].minor.yy14 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy14,yymsp[0].minor.yy454);}
178632 break;
178633 case 236: /* nexprlist ::= expr */
178634 {yymsp[0].minor.yy14 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy454); /*A-overwrites-Y*/}
178635 break;
178636 case 238: /* paren_exprlist ::= LP exprlist RP */
178637 case 243: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==243);
178638 {yymsp[-2].minor.yy14 = yymsp[-1].minor.yy14;}
178639 break;
178640 case 239: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
178641 {
178642 sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0,
178643 sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy14, yymsp[-10].minor.yy144,
178644 &yymsp[-11].minor.yy0, yymsp[0].minor.yy454, SQLITE_SO_ASC, yymsp[-8].minor.yy144, SQLITE_IDXTYPE_APPDEF);
178645 if( IN_RENAME_OBJECT && pParse->pNewIndex ){
178646 sqlite3RenameTokenMap(pParse, pParse->pNewIndex->zName, &yymsp[-4].minor.yy0);
178647 }
178648 }
178649 break;
178650 case 240: /* uniqueflag ::= UNIQUE */
178651 case 282: /* raisetype ::= ABORT */ yytestcase(yyruleno==282);
178652 {yymsp[0].minor.yy144 = OE_Abort;}
178653 break;
178654 case 241: /* uniqueflag ::= */
178655 {yymsp[1].minor.yy144 = OE_None;}
178656 break;
178657 case 244: /* eidlist ::= eidlist COMMA nm collate sortorder */
178658 {
178659 yymsp[-4].minor.yy14 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy14, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy144, yymsp[0].minor.yy144);
178660 }
178661 break;
178662 case 245: /* eidlist ::= nm collate sortorder */
178663 {
178664 yymsp[-2].minor.yy14 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy144, yymsp[0].minor.yy144); /*A-overwrites-Y*/
178665 }
178666 break;
178667 case 248: /* cmd ::= DROP INDEX ifexists fullname */
178668 {sqlite3DropIndex(pParse, yymsp[0].minor.yy203, yymsp[-1].minor.yy144);}
178669 break;
178670 case 249: /* cmd ::= VACUUM vinto */
178671 {sqlite3Vacuum(pParse,0,yymsp[0].minor.yy454);}
178672 break;
178673 case 250: /* cmd ::= VACUUM nm vinto */
178674 {sqlite3Vacuum(pParse,&yymsp[-1].minor.yy0,yymsp[0].minor.yy454);}
178675 break;
178676 case 253: /* cmd ::= PRAGMA nm dbnm */
178677 {sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);}
178678 break;
178679 case 254: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
@@ -178691,54 +179079,58 @@
178691 case 260: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
178692 {
178693 Token all;
178694 all.z = yymsp[-3].minor.yy0.z;
178695 all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n;
178696 sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy427, &all);
178697 }
178698 break;
178699 case 261: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
178700 {
178701 sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy144, yymsp[-4].minor.yy286.a, yymsp[-4].minor.yy286.b, yymsp[-2].minor.yy203, yymsp[0].minor.yy454, yymsp[-10].minor.yy144, yymsp[-8].minor.yy144);
178702 yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/
 
 
 
 
178703 }
178704 break;
178705 case 262: /* trigger_time ::= BEFORE|AFTER */
178706 { yymsp[0].minor.yy144 = yymsp[0].major; /*A-overwrites-X*/ }
178707 break;
178708 case 263: /* trigger_time ::= INSTEAD OF */
178709 { yymsp[-1].minor.yy144 = TK_INSTEAD;}
178710 break;
178711 case 264: /* trigger_time ::= */
178712 { yymsp[1].minor.yy144 = TK_BEFORE; }
178713 break;
178714 case 265: /* trigger_event ::= DELETE|INSERT */
178715 case 266: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==266);
178716 {yymsp[0].minor.yy286.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy286.b = 0;}
178717 break;
178718 case 267: /* trigger_event ::= UPDATE OF idlist */
178719 {yymsp[-2].minor.yy286.a = TK_UPDATE; yymsp[-2].minor.yy286.b = yymsp[0].minor.yy132;}
178720 break;
178721 case 268: /* when_clause ::= */
178722 case 287: /* key_opt ::= */ yytestcase(yyruleno==287);
178723 { yymsp[1].minor.yy454 = 0; }
178724 break;
178725 case 269: /* when_clause ::= WHEN expr */
178726 case 288: /* key_opt ::= KEY expr */ yytestcase(yyruleno==288);
178727 { yymsp[-1].minor.yy454 = yymsp[0].minor.yy454; }
178728 break;
178729 case 270: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
178730 {
178731 assert( yymsp[-2].minor.yy427!=0 );
178732 yymsp[-2].minor.yy427->pLast->pNext = yymsp[-1].minor.yy427;
178733 yymsp[-2].minor.yy427->pLast = yymsp[-1].minor.yy427;
178734 }
178735 break;
178736 case 271: /* trigger_cmd_list ::= trigger_cmd SEMI */
178737 {
178738 assert( yymsp[-1].minor.yy427!=0 );
178739 yymsp[-1].minor.yy427->pLast = yymsp[-1].minor.yy427;
178740 }
178741 break;
178742 case 272: /* trnm ::= nm DOT nm */
178743 {
178744 yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;
@@ -178760,62 +179152,62 @@
178760 "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements "
178761 "within triggers");
178762 }
178763 break;
178764 case 275: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */
178765 {yylhsminor.yy427 = sqlite3TriggerUpdateStep(pParse, &yymsp[-6].minor.yy0, yymsp[-2].minor.yy203, yymsp[-3].minor.yy14, yymsp[-1].minor.yy454, yymsp[-7].minor.yy144, yymsp[-8].minor.yy0.z, yymsp[0].minor.yy168);}
178766 yymsp[-8].minor.yy427 = yylhsminor.yy427;
178767 break;
178768 case 276: /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
178769 {
178770 yylhsminor.yy427 = sqlite3TriggerInsertStep(pParse,&yymsp[-4].minor.yy0,yymsp[-3].minor.yy132,yymsp[-2].minor.yy555,yymsp[-6].minor.yy144,yymsp[-1].minor.yy122,yymsp[-7].minor.yy168,yymsp[0].minor.yy168);/*yylhsminor.yy427-overwrites-yymsp[-6].minor.yy144*/
178771 }
178772 yymsp[-7].minor.yy427 = yylhsminor.yy427;
178773 break;
178774 case 277: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
178775 {yylhsminor.yy427 = sqlite3TriggerDeleteStep(pParse, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy454, yymsp[-5].minor.yy0.z, yymsp[0].minor.yy168);}
178776 yymsp[-5].minor.yy427 = yylhsminor.yy427;
178777 break;
178778 case 278: /* trigger_cmd ::= scanpt select scanpt */
178779 {yylhsminor.yy427 = sqlite3TriggerSelectStep(pParse->db, yymsp[-1].minor.yy555, yymsp[-2].minor.yy168, yymsp[0].minor.yy168); /*yylhsminor.yy427-overwrites-yymsp[-1].minor.yy555*/}
178780 yymsp[-2].minor.yy427 = yylhsminor.yy427;
178781 break;
178782 case 279: /* expr ::= RAISE LP IGNORE RP */
178783 {
178784 yymsp[-3].minor.yy454 = sqlite3PExpr(pParse, TK_RAISE, 0, 0);
178785 if( yymsp[-3].minor.yy454 ){
178786 yymsp[-3].minor.yy454->affExpr = OE_Ignore;
178787 }
178788 }
178789 break;
178790 case 280: /* expr ::= RAISE LP raisetype COMMA expr RP */
178791 {
178792 yymsp[-5].minor.yy454 = sqlite3PExpr(pParse, TK_RAISE, yymsp[-1].minor.yy454, 0);
178793 if( yymsp[-5].minor.yy454 ) {
178794 yymsp[-5].minor.yy454->affExpr = (char)yymsp[-3].minor.yy144;
178795 }
178796 }
178797 break;
178798 case 281: /* raisetype ::= ROLLBACK */
178799 {yymsp[0].minor.yy144 = OE_Rollback;}
178800 break;
178801 case 283: /* raisetype ::= FAIL */
178802 {yymsp[0].minor.yy144 = OE_Fail;}
178803 break;
178804 case 284: /* cmd ::= DROP TRIGGER ifexists fullname */
178805 {
178806 sqlite3DropTrigger(pParse,yymsp[0].minor.yy203,yymsp[-1].minor.yy144);
178807 }
178808 break;
178809 case 285: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
178810 {
178811 sqlite3Attach(pParse, yymsp[-3].minor.yy454, yymsp[-1].minor.yy454, yymsp[0].minor.yy454);
178812 }
178813 break;
178814 case 286: /* cmd ::= DETACH database_kw_opt expr */
178815 {
178816 sqlite3Detach(pParse, yymsp[0].minor.yy454);
178817 }
178818 break;
178819 case 289: /* cmd ::= REINDEX */
178820 {sqlite3Reindex(pParse, 0, 0);}
178821 break;
@@ -178828,11 +179220,11 @@
178828 case 292: /* cmd ::= ANALYZE nm dbnm */
178829 {sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
178830 break;
178831 case 293: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
178832 {
178833 sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy203,&yymsp[0].minor.yy0);
178834 }
178835 break;
178836 case 294: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
178837 {
178838 yymsp[-1].minor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-1].minor.yy0.z) + pParse->sLastToken.n;
@@ -178839,22 +179231,22 @@
178839 sqlite3AlterFinishAddColumn(pParse, &yymsp[-1].minor.yy0);
178840 }
178841 break;
178842 case 295: /* cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */
178843 {
178844 sqlite3AlterDropColumn(pParse, yymsp[-3].minor.yy203, &yymsp[0].minor.yy0);
178845 }
178846 break;
178847 case 296: /* add_column_fullname ::= fullname */
178848 {
178849 disableLookaside(pParse);
178850 sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy203);
178851 }
178852 break;
178853 case 297: /* cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
178854 {
178855 sqlite3AlterRenameColumn(pParse, yymsp[-5].minor.yy203, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);
178856 }
178857 break;
178858 case 298: /* cmd ::= create_vtab */
178859 {sqlite3VtabFinishParse(pParse,0);}
178860 break;
@@ -178861,11 +179253,11 @@
178861 case 299: /* cmd ::= create_vtab LP vtabarglist RP */
178862 {sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}
178863 break;
178864 case 300: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
178865 {
178866 sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy144);
178867 }
178868 break;
178869 case 301: /* vtabarg ::= */
178870 {sqlite3VtabArgInit(pParse);}
178871 break;
@@ -178874,185 +179266,185 @@
178874 case 304: /* lp ::= LP */ yytestcase(yyruleno==304);
178875 {sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}
178876 break;
178877 case 305: /* with ::= WITH wqlist */
178878 case 306: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==306);
178879 { sqlite3WithPush(pParse, yymsp[0].minor.yy59, 1); }
178880 break;
178881 case 307: /* wqas ::= AS */
178882 {yymsp[0].minor.yy462 = M10d_Any;}
178883 break;
178884 case 308: /* wqas ::= AS MATERIALIZED */
178885 {yymsp[-1].minor.yy462 = M10d_Yes;}
178886 break;
178887 case 309: /* wqas ::= AS NOT MATERIALIZED */
178888 {yymsp[-2].minor.yy462 = M10d_No;}
178889 break;
178890 case 310: /* wqitem ::= withnm eidlist_opt wqas LP select RP */
178891 {
178892 yymsp[-5].minor.yy67 = sqlite3CteNew(pParse, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy14, yymsp[-1].minor.yy555, yymsp[-3].minor.yy462); /*A-overwrites-X*/
178893 }
178894 break;
178895 case 311: /* withnm ::= nm */
178896 {pParse->bHasWith = 1;}
178897 break;
178898 case 312: /* wqlist ::= wqitem */
178899 {
178900 yymsp[0].minor.yy59 = sqlite3WithAdd(pParse, 0, yymsp[0].minor.yy67); /*A-overwrites-X*/
178901 }
178902 break;
178903 case 313: /* wqlist ::= wqlist COMMA wqitem */
178904 {
178905 yymsp[-2].minor.yy59 = sqlite3WithAdd(pParse, yymsp[-2].minor.yy59, yymsp[0].minor.yy67);
178906 }
178907 break;
178908 case 314: /* windowdefn_list ::= windowdefn_list COMMA windowdefn */
178909 {
178910 assert( yymsp[0].minor.yy211!=0 );
178911 sqlite3WindowChain(pParse, yymsp[0].minor.yy211, yymsp[-2].minor.yy211);
178912 yymsp[0].minor.yy211->pNextWin = yymsp[-2].minor.yy211;
178913 yylhsminor.yy211 = yymsp[0].minor.yy211;
178914 }
178915 yymsp[-2].minor.yy211 = yylhsminor.yy211;
178916 break;
178917 case 315: /* windowdefn ::= nm AS LP window RP */
178918 {
178919 if( ALWAYS(yymsp[-1].minor.yy211) ){
178920 yymsp[-1].minor.yy211->zName = sqlite3DbStrNDup(pParse->db, yymsp[-4].minor.yy0.z, yymsp[-4].minor.yy0.n);
178921 }
178922 yylhsminor.yy211 = yymsp[-1].minor.yy211;
178923 }
178924 yymsp[-4].minor.yy211 = yylhsminor.yy211;
178925 break;
178926 case 316: /* window ::= PARTITION BY nexprlist orderby_opt frame_opt */
178927 {
178928 yymsp[-4].minor.yy211 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy211, yymsp[-2].minor.yy14, yymsp[-1].minor.yy14, 0);
178929 }
178930 break;
178931 case 317: /* window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
178932 {
178933 yylhsminor.yy211 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy211, yymsp[-2].minor.yy14, yymsp[-1].minor.yy14, &yymsp[-5].minor.yy0);
178934 }
178935 yymsp[-5].minor.yy211 = yylhsminor.yy211;
178936 break;
178937 case 318: /* window ::= ORDER BY sortlist frame_opt */
178938 {
178939 yymsp[-3].minor.yy211 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy211, 0, yymsp[-1].minor.yy14, 0);
178940 }
178941 break;
178942 case 319: /* window ::= nm ORDER BY sortlist frame_opt */
178943 {
178944 yylhsminor.yy211 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy211, 0, yymsp[-1].minor.yy14, &yymsp[-4].minor.yy0);
178945 }
178946 yymsp[-4].minor.yy211 = yylhsminor.yy211;
178947 break;
178948 case 320: /* window ::= nm frame_opt */
178949 {
178950 yylhsminor.yy211 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy211, 0, 0, &yymsp[-1].minor.yy0);
178951 }
178952 yymsp[-1].minor.yy211 = yylhsminor.yy211;
178953 break;
178954 case 321: /* frame_opt ::= */
178955 {
178956 yymsp[1].minor.yy211 = sqlite3WindowAlloc(pParse, 0, TK_UNBOUNDED, 0, TK_CURRENT, 0, 0);
178957 }
178958 break;
178959 case 322: /* frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */
178960 {
178961 yylhsminor.yy211 = sqlite3WindowAlloc(pParse, yymsp[-2].minor.yy144, yymsp[-1].minor.yy509.eType, yymsp[-1].minor.yy509.pExpr, TK_CURRENT, 0, yymsp[0].minor.yy462);
178962 }
178963 yymsp[-2].minor.yy211 = yylhsminor.yy211;
178964 break;
178965 case 323: /* frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */
178966 {
178967 yylhsminor.yy211 = sqlite3WindowAlloc(pParse, yymsp[-5].minor.yy144, yymsp[-3].minor.yy509.eType, yymsp[-3].minor.yy509.pExpr, yymsp[-1].minor.yy509.eType, yymsp[-1].minor.yy509.pExpr, yymsp[0].minor.yy462);
178968 }
178969 yymsp[-5].minor.yy211 = yylhsminor.yy211;
178970 break;
178971 case 325: /* frame_bound_s ::= frame_bound */
178972 case 327: /* frame_bound_e ::= frame_bound */ yytestcase(yyruleno==327);
178973 {yylhsminor.yy509 = yymsp[0].minor.yy509;}
178974 yymsp[0].minor.yy509 = yylhsminor.yy509;
178975 break;
178976 case 326: /* frame_bound_s ::= UNBOUNDED PRECEDING */
178977 case 328: /* frame_bound_e ::= UNBOUNDED FOLLOWING */ yytestcase(yyruleno==328);
178978 case 330: /* frame_bound ::= CURRENT ROW */ yytestcase(yyruleno==330);
178979 {yylhsminor.yy509.eType = yymsp[-1].major; yylhsminor.yy509.pExpr = 0;}
178980 yymsp[-1].minor.yy509 = yylhsminor.yy509;
178981 break;
178982 case 329: /* frame_bound ::= expr PRECEDING|FOLLOWING */
178983 {yylhsminor.yy509.eType = yymsp[0].major; yylhsminor.yy509.pExpr = yymsp[-1].minor.yy454;}
178984 yymsp[-1].minor.yy509 = yylhsminor.yy509;
178985 break;
178986 case 331: /* frame_exclude_opt ::= */
178987 {yymsp[1].minor.yy462 = 0;}
178988 break;
178989 case 332: /* frame_exclude_opt ::= EXCLUDE frame_exclude */
178990 {yymsp[-1].minor.yy462 = yymsp[0].minor.yy462;}
178991 break;
178992 case 333: /* frame_exclude ::= NO OTHERS */
178993 case 334: /* frame_exclude ::= CURRENT ROW */ yytestcase(yyruleno==334);
178994 {yymsp[-1].minor.yy462 = yymsp[-1].major; /*A-overwrites-X*/}
178995 break;
178996 case 335: /* frame_exclude ::= GROUP|TIES */
178997 {yymsp[0].minor.yy462 = yymsp[0].major; /*A-overwrites-X*/}
178998 break;
178999 case 336: /* window_clause ::= WINDOW windowdefn_list */
179000 { yymsp[-1].minor.yy211 = yymsp[0].minor.yy211; }
179001 break;
179002 case 337: /* filter_over ::= filter_clause over_clause */
179003 {
179004 if( yymsp[0].minor.yy211 ){
179005 yymsp[0].minor.yy211->pFilter = yymsp[-1].minor.yy454;
179006 }else{
179007 sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy454);
179008 }
179009 yylhsminor.yy211 = yymsp[0].minor.yy211;
179010 }
179011 yymsp[-1].minor.yy211 = yylhsminor.yy211;
179012 break;
179013 case 338: /* filter_over ::= over_clause */
179014 {
179015 yylhsminor.yy211 = yymsp[0].minor.yy211;
179016 }
179017 yymsp[0].minor.yy211 = yylhsminor.yy211;
179018 break;
179019 case 339: /* filter_over ::= filter_clause */
179020 {
179021 yylhsminor.yy211 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
179022 if( yylhsminor.yy211 ){
179023 yylhsminor.yy211->eFrmType = TK_FILTER;
179024 yylhsminor.yy211->pFilter = yymsp[0].minor.yy454;
179025 }else{
179026 sqlite3ExprDelete(pParse->db, yymsp[0].minor.yy454);
179027 }
179028 }
179029 yymsp[0].minor.yy211 = yylhsminor.yy211;
179030 break;
179031 case 340: /* over_clause ::= OVER LP window RP */
179032 {
179033 yymsp[-3].minor.yy211 = yymsp[-1].minor.yy211;
179034 assert( yymsp[-3].minor.yy211!=0 );
179035 }
179036 break;
179037 case 341: /* over_clause ::= OVER nm */
179038 {
179039 yymsp[-1].minor.yy211 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
179040 if( yymsp[-1].minor.yy211 ){
179041 yymsp[-1].minor.yy211->zName = sqlite3DbStrNDup(pParse->db, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n);
179042 }
179043 }
179044 break;
179045 case 342: /* filter_clause ::= FILTER LP WHERE expr RP */
179046 { yymsp[-4].minor.yy454 = yymsp[-1].minor.yy454; }
179047 break;
179048 case 343: /* term ::= QNUMBER */
179049 {
179050 yylhsminor.yy454=tokenExpr(pParse,yymsp[0].major,yymsp[0].minor.yy0);
179051 sqlite3DequoteNumber(pParse, yylhsminor.yy454);
179052 }
179053 yymsp[0].minor.yy454 = yylhsminor.yy454;
179054 break;
179055 default:
179056 /* (344) input ::= cmdlist */ yytestcase(yyruleno==344);
179057 /* (345) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==345);
179058 /* (346) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=346);
@@ -180229,11 +180621,11 @@
180229 return i;
180230 }
180231 case CC_MINUS: {
180232 if( z[1]=='-' ){
180233 for(i=2; (c=z[i])!=0 && c!='\n'; i++){}
180234 *tokenType = TK_SPACE; /* IMP: R-22934-25134 */
180235 return i;
180236 }else if( z[1]=='>' ){
180237 *tokenType = TK_PTR;
180238 return 2 + (z[2]=='>');
180239 }
@@ -180265,11 +180657,11 @@
180265 *tokenType = TK_SLASH;
180266 return 1;
180267 }
180268 for(i=3, c=z[2]; (c!='*' || z[i]!='/') && (c=z[i])!=0; i++){}
180269 if( c ) i++;
180270 *tokenType = TK_SPACE; /* IMP: R-22934-25134 */
180271 return i;
180272 }
180273 case CC_PERCENT: {
180274 *tokenType = TK_REM;
180275 return 1;
@@ -180594,16 +180986,16 @@
180594 }
180595 #ifndef SQLITE_OMIT_WINDOWFUNC
180596 if( tokenType>=TK_WINDOW ){
180597 assert( tokenType==TK_SPACE || tokenType==TK_OVER || tokenType==TK_FILTER
180598 || tokenType==TK_ILLEGAL || tokenType==TK_WINDOW
180599 || tokenType==TK_QNUMBER
180600 );
180601 #else
180602 if( tokenType>=TK_SPACE ){
180603 assert( tokenType==TK_SPACE || tokenType==TK_ILLEGAL
180604 || tokenType==TK_QNUMBER
180605 );
180606 #endif /* SQLITE_OMIT_WINDOWFUNC */
180607 if( AtomicLoad(&db->u1.isInterrupted) ){
180608 pParse->rc = SQLITE_INTERRUPT;
180609 pParse->nErr++;
@@ -180633,10 +181025,13 @@
180633 tokenType = analyzeOverKeyword((const u8*)&zSql[4], lastTokenParsed);
180634 }else if( tokenType==TK_FILTER ){
180635 assert( n==6 );
180636 tokenType = analyzeFilterKeyword((const u8*)&zSql[6], lastTokenParsed);
180637 #endif /* SQLITE_OMIT_WINDOWFUNC */
 
 
 
180638 }else if( tokenType!=TK_QNUMBER ){
180639 Token x;
180640 x.z = zSql;
180641 x.n = n;
180642 sqlite3ErrorMsg(pParse, "unrecognized token: \"%T\"", &x);
@@ -180739,10 +181134,11 @@
180739 prevType = tokenType;
180740 }
180741 n = sqlite3GetToken((unsigned char*)zSql+i, &tokenType);
180742 if( NEVER(n<=0) ) break;
180743 switch( tokenType ){
 
180744 case TK_SPACE: {
180745 break;
180746 }
180747 case TK_NULL: {
180748 if( prevType==TK_IS || prevType==TK_NOT ){
@@ -181980,21 +182376,26 @@
181980 ** Set up the lookaside buffers for a database connection.
181981 ** Return SQLITE_OK on success.
181982 ** If lookaside is already active, return SQLITE_BUSY.
181983 **
181984 ** The sz parameter is the number of bytes in each lookaside slot.
181985 ** The cnt parameter is the number of slots. If pStart is NULL the
181986 ** space for the lookaside memory is obtained from sqlite3_malloc().
181987 ** If pStart is not NULL then it is sz*cnt bytes of memory to use for
181988 ** the lookaside memory.
181989 */
181990 static int setupLookaside(sqlite3 *db, void *pBuf, int sz, int cnt){
 
 
 
 
 
181991 #ifndef SQLITE_OMIT_LOOKASIDE
181992 void *pStart;
181993 sqlite3_int64 szAlloc = sz*(sqlite3_int64)cnt;
181994 int nBig; /* Number of full-size slots */
181995 int nSm; /* Number smaller LOOKASIDE_SMALL-byte slots */
181996
181997 if( sqlite3LookasideUsed(db,0)>0 ){
181998 return SQLITE_BUSY;
181999 }
182000 /* Free any existing lookaside buffer for this handle before
@@ -182003,33 +182404,38 @@
182003 */
182004 if( db->lookaside.bMalloced ){
182005 sqlite3_free(db->lookaside.pStart);
182006 }
182007 /* The size of a lookaside slot after ROUNDDOWN8 needs to be larger
182008 ** than a pointer to be useful.
182009 */
182010 sz = ROUNDDOWN8(sz); /* IMP: R-33038-09382 */
182011 if( sz<=(int)sizeof(LookasideSlot*) ) sz = 0;
182012 if( cnt<0 ) cnt = 0;
182013 if( sz==0 || cnt==0 ){
 
 
 
 
 
182014 sz = 0;
182015 pStart = 0;
182016 }else if( pBuf==0 ){
182017 sqlite3BeginBenignMalloc();
182018 pStart = sqlite3Malloc( szAlloc ); /* IMP: R-61949-35727 */
182019 sqlite3EndBenignMalloc();
182020 if( pStart ) szAlloc = sqlite3MallocSize(pStart);
182021 }else{
182022 pStart = pBuf;
182023 }
182024 #ifndef SQLITE_OMIT_TWOSIZE_LOOKASIDE
182025 if( sz>=LOOKASIDE_SMALL*3 ){
182026 nBig = szAlloc/(3*LOOKASIDE_SMALL+sz);
182027 nSm = (szAlloc - sz*nBig)/LOOKASIDE_SMALL;
182028 }else if( sz>=LOOKASIDE_SMALL*2 ){
182029 nBig = szAlloc/(LOOKASIDE_SMALL+sz);
182030 nSm = (szAlloc - sz*nBig)/LOOKASIDE_SMALL;
182031 }else
182032 #endif /* SQLITE_OMIT_TWOSIZE_LOOKASIDE */
182033 if( sz>0 ){
182034 nBig = szAlloc/sz;
182035 nSm = 0;
@@ -182180,11 +182586,11 @@
182180 break;
182181 }
182182 default: {
182183 static const struct {
182184 int op; /* The opcode */
182185 u32 mask; /* Mask of the bit in sqlite3.flags to set/clear */
182186 } aFlagOp[] = {
182187 { SQLITE_DBCONFIG_ENABLE_FKEY, SQLITE_ForeignKeys },
182188 { SQLITE_DBCONFIG_ENABLE_TRIGGER, SQLITE_EnableTrigger },
182189 { SQLITE_DBCONFIG_ENABLE_VIEW, SQLITE_EnableView },
182190 { SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER, SQLITE_Fts3Tokenizer },
@@ -182201,10 +182607,13 @@
182201 { SQLITE_DBCONFIG_DQS_DML, SQLITE_DqsDML },
182202 { SQLITE_DBCONFIG_LEGACY_FILE_FORMAT, SQLITE_LegacyFileFmt },
182203 { SQLITE_DBCONFIG_TRUSTED_SCHEMA, SQLITE_TrustedSchema },
182204 { SQLITE_DBCONFIG_STMT_SCANSTATUS, SQLITE_StmtScanStatus },
182205 { SQLITE_DBCONFIG_REVERSE_SCANORDER, SQLITE_ReverseOrder },
 
 
 
182206 };
182207 unsigned int i;
182208 rc = SQLITE_ERROR; /* IMP: R-42790-23372 */
182209 for(i=0; i<ArraySize(aFlagOp); i++){
182210 if( aFlagOp[i].op==op ){
@@ -184078,12 +184487,12 @@
184078 # error SQLITE_MAX_COMPOUND_SELECT must be at least 2
184079 #endif
184080 #if SQLITE_MAX_VDBE_OP<40
184081 # error SQLITE_MAX_VDBE_OP must be at least 40
184082 #endif
184083 #if SQLITE_MAX_FUNCTION_ARG<0 || SQLITE_MAX_FUNCTION_ARG>127
184084 # error SQLITE_MAX_FUNCTION_ARG must be between 0 and 127
184085 #endif
184086 #if SQLITE_MAX_ATTACHED<0 || SQLITE_MAX_ATTACHED>125
184087 # error SQLITE_MAX_ATTACHED must be between 0 and 125
184088 #endif
184089 #if SQLITE_MAX_LIKE_PATTERN_LENGTH<1
@@ -184542,10 +184951,13 @@
184542 #endif
184543 db->flags |= SQLITE_ShortColNames
184544 | SQLITE_EnableTrigger
184545 | SQLITE_EnableView
184546 | SQLITE_CacheSpill
 
 
 
184547 #if !defined(SQLITE_TRUSTED_SCHEMA) || SQLITE_TRUSTED_SCHEMA+0!=0
184548 | SQLITE_TrustedSchema
184549 #endif
184550 /* The SQLITE_DQS compile-time option determines the default settings
184551 ** for SQLITE_DBCONFIG_DQS_DDL and SQLITE_DBCONFIG_DQS_DML.
@@ -185158,17 +185570,14 @@
185158
185159 /* Find the column for which info is requested */
185160 if( zColumnName==0 ){
185161 /* Query for existence of table only */
185162 }else{
185163 for(iCol=0; iCol<pTab->nCol; iCol++){
 
185164 pCol = &pTab->aCol[iCol];
185165 if( 0==sqlite3StrICmp(pCol->zCnName, zColumnName) ){
185166 break;
185167 }
185168 }
185169 if( iCol==pTab->nCol ){
185170 if( HasRowid(pTab) && sqlite3IsRowid(zColumnName) ){
185171 iCol = pTab->iPKey;
185172 pCol = iCol>=0 ? &pTab->aCol[iCol] : 0;
185173 }else{
185174 pTab = 0;
@@ -185492,11 +185901,10 @@
185492 #if defined(SQLITE_DEBUG)
185493 /* Invoke these debugging routines so that the compiler does not
185494 ** issue "defined but not used" warnings. */
185495 if( x==9999 ){
185496 sqlite3ShowExpr(0);
185497 sqlite3ShowExpr(0);
185498 sqlite3ShowExprList(0);
185499 sqlite3ShowIdList(0);
185500 sqlite3ShowSrcList(0);
185501 sqlite3ShowWith(0);
185502 sqlite3ShowUpsert(0);
@@ -185509,11 +185917,10 @@
185509 #ifndef SQLITE_OMIT_WINDOWFUNC
185510 sqlite3ShowWindow(0);
185511 sqlite3ShowWinFunc(0);
185512 #endif
185513 sqlite3ShowSelect(0);
185514 sqlite3ShowWhereTerm(0);
185515 }
185516 #endif
185517 break;
185518 }
185519
@@ -187849,10 +188256,11 @@
187849 SQLITE_PRIVATE int sqlite3Fts3MsrIncrNext(
187850 Fts3Table *, Fts3MultiSegReader *, sqlite3_int64 *, char **, int *);
187851 SQLITE_PRIVATE int sqlite3Fts3EvalPhrasePoslist(Fts3Cursor *, Fts3Expr *, int iCol, char **);
187852 SQLITE_PRIVATE int sqlite3Fts3MsrOvfl(Fts3Cursor *, Fts3MultiSegReader *, int *);
187853 SQLITE_PRIVATE int sqlite3Fts3MsrIncrRestart(Fts3MultiSegReader *pCsr);
 
187854
187855 /* fts3_tokenize_vtab.c */
187856 SQLITE_PRIVATE int sqlite3Fts3InitTok(sqlite3*, Fts3Hash *, void(*xDestroy)(void*));
187857
187858 /* fts3_unicode2.c (functions generated by parsing unicode text files) */
@@ -192018,11 +192426,11 @@
192018 p1 = pPhrase->doclist.pList;
192019 p2 = aPoslist;
192020 nDistance = iPrev - nMaxUndeferred;
192021 }
192022
192023 aOut = (char *)sqlite3Fts3MallocZero(nPoslist+FTS3_BUFFER_PADDING);
192024 if( !aOut ){
192025 sqlite3_free(aPoslist);
192026 return SQLITE_NOMEM;
192027 }
192028
@@ -193366,10 +193774,28 @@
193366
193367 fts3EvalRestart(pCsr, pExpr->pLeft, pRc);
193368 fts3EvalRestart(pCsr, pExpr->pRight, pRc);
193369 }
193370 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
193371
193372 /*
193373 ** After allocating the Fts3Expr.aMI[] array for each phrase in the
193374 ** expression rooted at pExpr, the cursor iterates through all rows matched
193375 ** by pExpr, calling this function for each row. This function increments
@@ -194620,11 +195046,11 @@
194620 sqlite3_tokenizer_module const *pModule = pTokenizer->pModule;
194621 int rc;
194622 Fts3Expr *p = 0;
194623 sqlite3_tokenizer_cursor *pCursor = 0;
194624 char *zTemp = 0;
194625 int nTemp = 0;
194626
194627 const int nSpace = sizeof(Fts3Expr) + sizeof(Fts3Phrase);
194628 int nToken = 0;
194629
194630 /* The final Fts3Expr data structure, including the Fts3Phrase,
@@ -205323,10 +205749,26 @@
205323 pT->iPos = iPos;
205324 }
205325
205326 return rc;
205327 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
205328
205329 /*
205330 ** Implementation of offsets() function.
205331 */
205332 SQLITE_PRIVATE void sqlite3Fts3Offsets(
@@ -205359,10 +205801,16 @@
205359 rc = SQLITE_NOMEM;
205360 goto offsets_out;
205361 }
205362 sCtx.iDocid = pCsr->iPrevId;
205363 sCtx.pCsr = pCsr;
 
 
 
 
 
 
205364
205365 /* Loop through the table columns, appending offset information to
205366 ** string-buffer res for each column.
205367 */
205368 for(iCol=0; iCol<pTab->nColumn; iCol++){
@@ -207369,22 +207817,23 @@
207369 **
207370 ** Return the number of errors.
207371 */
207372 static int jsonBlobExpand(JsonParse *pParse, u32 N){
207373 u8 *aNew;
207374 u32 t;
207375 assert( N>pParse->nBlobAlloc );
207376 if( pParse->nBlobAlloc==0 ){
207377 t = 100;
207378 }else{
207379 t = pParse->nBlobAlloc*2;
207380 }
207381 if( t<N ) t = N+100;
207382 aNew = sqlite3DbRealloc(pParse->db, pParse->aBlob, t);
207383 if( aNew==0 ){ pParse->oom = 1; return 1; }
 
207384 pParse->aBlob = aNew;
207385 pParse->nBlobAlloc = t;
207386 return 0;
207387 }
207388
207389 /*
207390 ** If pParse->aBlob is not previously editable (because it is taken
@@ -208337,14 +208786,11 @@
208337 */
208338 static u32 jsonbPayloadSize(const JsonParse *pParse, u32 i, u32 *pSz){
208339 u8 x;
208340 u32 sz;
208341 u32 n;
208342 if( NEVER(i>pParse->nBlob) ){
208343 *pSz = 0;
208344 return 0;
208345 }
208346 x = pParse->aBlob[i]>>4;
208347 if( x<=11 ){
208348 sz = x;
208349 n = 1;
208350 }else if( x==12 ){
@@ -208384,12 +208830,12 @@
208384 n = 9;
208385 }
208386 if( (i64)i+sz+n > pParse->nBlob
208387 && (i64)i+sz+n > pParse->nBlob-pParse->delta
208388 ){
208389 sz = 0;
208390 n = 0;
208391 }
208392 *pSz = sz;
208393 return n;
208394 }
208395
@@ -208482,13 +208928,16 @@
208482 }
208483 break;
208484 }
208485 case JSONB_TEXT:
208486 case JSONB_TEXTJ: {
208487 jsonAppendChar(pOut, '"');
208488 jsonAppendRaw(pOut, (const char*)&pParse->aBlob[i+n], sz);
208489 jsonAppendChar(pOut, '"');
 
 
 
208490 break;
208491 }
208492 case JSONB_TEXT5: {
208493 const char *zIn;
208494 u32 k;
@@ -209399,11 +209848,11 @@
209399 u32 iIn, iOut;
209400 const char *z;
209401 char *zOut;
209402 u32 nOut = sz;
209403 z = (const char*)&pParse->aBlob[i+n];
209404 zOut = sqlite3DbMallocRaw(db, nOut+1);
209405 if( zOut==0 ) goto returnfromblob_oom;
209406 for(iIn=iOut=0; iIn<sz; iIn++){
209407 char c = z[iIn];
209408 if( c=='\\' ){
209409 u32 v;
@@ -215527,12 +215976,12 @@
215527 #endif
215528 }
215529 sqlite3_str_append(pOut, "}", 1);
215530 }
215531 errCode = sqlite3_str_errcode(pOut);
215532 sqlite3_result_text(ctx, sqlite3_str_finish(pOut), -1, sqlite3_free);
215533 sqlite3_result_error_code(ctx, errCode);
 
215534 }
215535
215536 /* This routine implements an SQL function that returns the "depth" parameter
215537 ** from the front of a blob that is an r-tree node. For example:
215538 **
@@ -226232,10 +226681,28 @@
226232 static int dbpageRowid(sqlite3_vtab_cursor *pCursor, sqlite_int64 *pRowid){
226233 DbpageCursor *pCsr = (DbpageCursor *)pCursor;
226234 *pRowid = pCsr->pgno;
226235 return SQLITE_OK;
226236 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
226237
226238 static int dbpageUpdate(
226239 sqlite3_vtab *pVtab,
226240 int argc,
226241 sqlite3_value **argv,
@@ -226300,10 +226767,16 @@
226300 }else{
226301 zErr = "bad page value";
226302 goto update_fail;
226303 }
226304 }
 
 
 
 
 
 
226305 pPager = sqlite3BtreePager(pBt);
226306 rc = sqlite3PagerGet(pPager, pgno, (DbPage**)&pDbPage, 0);
226307 if( rc==SQLITE_OK ){
226308 const void *pData = sqlite3_value_blob(argv[3]);
226309 if( (rc = sqlite3PagerWrite(pDbPage))==SQLITE_OK && pData ){
@@ -226316,27 +226789,18 @@
226316 }
226317 sqlite3PagerUnref(pDbPage);
226318 return rc;
226319
226320 update_fail:
 
226321 sqlite3_free(pVtab->zErrMsg);
226322 pVtab->zErrMsg = sqlite3_mprintf("%s", zErr);
226323 return SQLITE_ERROR;
226324 }
226325
226326 /* Since we do not know in advance which database files will be
226327 ** written by the sqlite_dbpage virtual table, start a write transaction
226328 ** on them all.
226329 */
226330 static int dbpageBegin(sqlite3_vtab *pVtab){
226331 DbpageTable *pTab = (DbpageTable *)pVtab;
226332 sqlite3 *db = pTab->db;
226333 int i;
226334 for(i=0; i<db->nDb; i++){
226335 Btree *pBt = db->aDb[i].pBt;
226336 if( pBt ) (void)sqlite3BtreeBeginTrans(pBt, 1, 0);
226337 }
226338 pTab->pgnoTrunc = 0;
226339 return SQLITE_OK;
226340 }
226341
226342 /* Invoke sqlite3PagerTruncate() as necessary, just prior to COMMIT
@@ -226344,11 +226808,15 @@
226344 static int dbpageSync(sqlite3_vtab *pVtab){
226345 DbpageTable *pTab = (DbpageTable *)pVtab;
226346 if( pTab->pgnoTrunc>0 ){
226347 Btree *pBt = pTab->db->aDb[pTab->iDbTrunc].pBt;
226348 Pager *pPager = sqlite3BtreePager(pBt);
226349 sqlite3PagerTruncateImage(pPager, pTab->pgnoTrunc);
 
 
 
 
226350 }
226351 pTab->pgnoTrunc = 0;
226352 return SQLITE_OK;
226353 }
226354
@@ -226364,11 +226832,11 @@
226364 /*
226365 ** Invoke this routine to register the "dbpage" virtual table module
226366 */
226367 SQLITE_PRIVATE int sqlite3DbpageRegister(sqlite3 *db){
226368 static sqlite3_module dbpage_module = {
226369 0, /* iVersion */
226370 dbpageConnect, /* xCreate */
226371 dbpageConnect, /* xConnect */
226372 dbpageBestIndex, /* xBestIndex */
226373 dbpageDisconnect, /* xDisconnect */
226374 dbpageDisconnect, /* xDestroy */
@@ -226539,15 +227007,17 @@
226539 ** SELECT 1, NULL, 'abc'
226540 */
226541 struct SessionTable {
226542 SessionTable *pNext;
226543 char *zName; /* Local name of table */
226544 int nCol; /* Number of columns in table zName */
 
226545 int bStat1; /* True if this is sqlite_stat1 */
226546 int bRowid; /* True if this table uses rowid for PK */
226547 const char **azCol; /* Column names */
226548 const char **azDflt; /* Default value expressions */
 
226549 u8 *abPK; /* Array of primary key flags */
226550 int nEntry; /* Total number of entries in hash table */
226551 int nChange; /* Size of apChange[] array */
226552 SessionChange **apChange; /* Hash table buckets */
226553 sqlite3_stmt *pDfltStmt;
@@ -226946,26 +227416,26 @@
226946 int *pbNullPK /* OUT: True if there are NULL values in PK */
226947 ){
226948 unsigned int h = 0; /* Hash value to return */
226949 int i; /* Used to iterate through columns */
226950
 
226951 if( pTab->bRowid ){
226952 assert( pTab->nCol-1==pSession->hook.xCount(pSession->hook.pCtx) );
226953 h = sessionHashAppendI64(h, iRowid);
226954 }else{
226955 assert( *pbNullPK==0 );
226956 assert( pTab->nCol==pSession->hook.xCount(pSession->hook.pCtx) );
226957 for(i=0; i<pTab->nCol; i++){
226958 if( pTab->abPK[i] ){
226959 int rc;
226960 int eType;
226961 sqlite3_value *pVal;
 
226962
226963 if( bNew ){
226964 rc = pSession->hook.xNew(pSession->hook.pCtx, i, &pVal);
226965 }else{
226966 rc = pSession->hook.xOld(pSession->hook.pCtx, i, &pVal);
226967 }
226968 if( rc!=SQLITE_OK ) return rc;
226969
226970 eType = sqlite3_value_type(pVal);
226971 h = sessionHashAppendType(h, eType);
@@ -227298,22 +227768,23 @@
227298 a += sessionSerialLen(a);
227299 }else{
227300 sqlite3_value *pVal; /* Value returned by preupdate_new/old */
227301 int rc; /* Error code from preupdate_new/old */
227302 int eType = *a++; /* Type of value from change record */
 
227303
227304 /* The following calls to preupdate_new() and preupdate_old() can not
227305 ** fail. This is because they cache their return values, and by the
227306 ** time control flows to here they have already been called once from
227307 ** within sessionPreupdateHash(). The first two asserts below verify
227308 ** this (that the method has already been called). */
227309 if( op==SQLITE_INSERT ){
227310 /* assert( db->pPreUpdate->pNewUnpacked || db->pPreUpdate->aNew ); */
227311 rc = pSession->hook.xNew(pSession->hook.pCtx, iCol, &pVal);
227312 }else{
227313 /* assert( db->pPreUpdate->pUnpacked ); */
227314 rc = pSession->hook.xOld(pSession->hook.pCtx, iCol, &pVal);
227315 }
227316 assert( rc==SQLITE_OK );
227317 (void)rc; /* Suppress warning about unused variable */
227318 if( sqlite3_value_type(pVal)!=eType ) return 0;
227319
@@ -227434,13 +227905,15 @@
227434 sqlite3_session *pSession, /* For memory accounting. May be NULL */
227435 sqlite3 *db, /* Database connection */
227436 const char *zDb, /* Name of attached database (e.g. "main") */
227437 const char *zThis, /* Table name */
227438 int *pnCol, /* OUT: number of columns */
 
227439 const char **pzTab, /* OUT: Copy of zThis */
227440 const char ***pazCol, /* OUT: Array of column names for table */
227441 const char ***pazDflt, /* OUT: Array of default value expressions */
 
227442 u8 **pabPK, /* OUT: Array of booleans - true for PK col */
227443 int *pbRowid /* OUT: True if only PK is a rowid */
227444 ){
227445 char *zPragma;
227446 sqlite3_stmt *pStmt;
@@ -227451,37 +227924,40 @@
227451 int i;
227452 u8 *pAlloc = 0;
227453 char **azCol = 0;
227454 char **azDflt = 0;
227455 u8 *abPK = 0;
 
227456 int bRowid = 0; /* Set to true to use rowid as PK */
227457
227458 assert( pazCol && pabPK );
227459
227460 *pazCol = 0;
227461 *pabPK = 0;
227462 *pnCol = 0;
 
 
227463 if( pzTab ) *pzTab = 0;
227464 if( pazDflt ) *pazDflt = 0;
227465
227466 nThis = sqlite3Strlen30(zThis);
227467 if( nThis==12 && 0==sqlite3_stricmp("sqlite_stat1", zThis) ){
227468 rc = sqlite3_table_column_metadata(db, zDb, zThis, 0, 0, 0, 0, 0, 0);
227469 if( rc==SQLITE_OK ){
227470 /* For sqlite_stat1, pretend that (tbl,idx) is the PRIMARY KEY. */
227471 zPragma = sqlite3_mprintf(
227472 "SELECT 0, 'tbl', '', 0, '', 1 UNION ALL "
227473 "SELECT 1, 'idx', '', 0, '', 2 UNION ALL "
227474 "SELECT 2, 'stat', '', 0, '', 0"
227475 );
227476 }else if( rc==SQLITE_ERROR ){
227477 zPragma = sqlite3_mprintf("");
227478 }else{
227479 return rc;
227480 }
227481 }else{
227482 zPragma = sqlite3_mprintf("PRAGMA '%q'.table_info('%q')", zDb, zThis);
227483 }
227484 if( !zPragma ){
227485 return SQLITE_NOMEM;
227486 }
227487
@@ -227494,20 +227970,22 @@
227494 nByte = nThis + 1;
227495 bRowid = (pbRowid!=0);
227496 while( SQLITE_ROW==sqlite3_step(pStmt) ){
227497 nByte += sqlite3_column_bytes(pStmt, 1); /* name */
227498 nByte += sqlite3_column_bytes(pStmt, 4); /* dflt_value */
227499 nDbCol++;
 
 
227500 if( sqlite3_column_int(pStmt, 5) ) bRowid = 0; /* pk */
227501 }
227502 if( nDbCol==0 ) bRowid = 0;
227503 nDbCol += bRowid;
227504 nByte += strlen(SESSIONS_ROWID);
227505 rc = sqlite3_reset(pStmt);
227506
227507 if( rc==SQLITE_OK ){
227508 nByte += nDbCol * (sizeof(const char *)*2 + sizeof(u8) + 1 + 1);
227509 pAlloc = sessionMalloc64(pSession, nByte);
227510 if( pAlloc==0 ){
227511 rc = SQLITE_NOMEM;
227512 }else{
227513 memset(pAlloc, 0, nByte);
@@ -227514,12 +227992,12 @@
227514 }
227515 }
227516 if( rc==SQLITE_OK ){
227517 azCol = (char **)pAlloc;
227518 azDflt = (char**)&azCol[nDbCol];
227519 pAlloc = (u8 *)&azDflt[nDbCol];
227520 abPK = (u8 *)pAlloc;
227521 pAlloc = &abPK[nDbCol];
227522 if( pzTab ){
227523 memcpy(pAlloc, zThis, nThis+1);
227524 *pzTab = (char *)pAlloc;
227525 pAlloc += nThis+1;
@@ -227530,31 +228008,36 @@
227530 size_t nName = strlen(SESSIONS_ROWID);
227531 memcpy(pAlloc, SESSIONS_ROWID, nName+1);
227532 azCol[i] = (char*)pAlloc;
227533 pAlloc += nName+1;
227534 abPK[i] = 1;
 
227535 i++;
227536 }
227537 while( SQLITE_ROW==sqlite3_step(pStmt) ){
227538 int nName = sqlite3_column_bytes(pStmt, 1);
227539 int nDflt = sqlite3_column_bytes(pStmt, 4);
227540 const unsigned char *zName = sqlite3_column_text(pStmt, 1);
227541 const unsigned char *zDflt = sqlite3_column_text(pStmt, 4);
227542
227543 if( zName==0 ) break;
227544 memcpy(pAlloc, zName, nName+1);
227545 azCol[i] = (char *)pAlloc;
227546 pAlloc += nName+1;
227547 if( zDflt ){
227548 memcpy(pAlloc, zDflt, nDflt+1);
227549 azDflt[i] = (char *)pAlloc;
227550 pAlloc += nDflt+1;
227551 }else{
227552 azDflt[i] = 0;
227553 }
227554 abPK[i] = sqlite3_column_int(pStmt, 5);
227555 i++;
 
 
 
 
227556 }
227557 rc = sqlite3_reset(pStmt);
227558 }
227559
227560 /* If successful, populate the output variables. Otherwise, zero them and
@@ -227563,10 +228046,11 @@
227563 if( rc==SQLITE_OK ){
227564 *pazCol = (const char**)azCol;
227565 if( pazDflt ) *pazDflt = (const char**)azDflt;
227566 *pabPK = abPK;
227567 *pnCol = nDbCol;
 
227568 }else{
227569 sessionFree(pSession, azCol);
227570 }
227571 if( pbRowid ) *pbRowid = bRowid;
227572 sqlite3_finalize(pStmt);
@@ -227594,11 +228078,12 @@
227594
227595 if( pTab->nCol==0 ){
227596 u8 *abPK;
227597 assert( pTab->azCol==0 || pTab->abPK==0 );
227598 rc = sessionTableInfo(pSession, db, zDb,
227599 pTab->zName, &pTab->nCol, 0, &pTab->azCol, &pTab->azDflt, &abPK,
 
227600 ((pSession==0 || pSession->bImplicitPK) ? &pTab->bRowid : 0)
227601 );
227602 if( rc==SQLITE_OK ){
227603 int i;
227604 for(i=0; i<pTab->nCol; i++){
@@ -227629,19 +228114,21 @@
227629 /*
227630 ** Re-initialize table object pTab.
227631 */
227632 static int sessionReinitTable(sqlite3_session *pSession, SessionTable *pTab){
227633 int nCol = 0;
 
227634 const char **azCol = 0;
227635 const char **azDflt = 0;
 
227636 u8 *abPK = 0;
227637 int bRowid = 0;
227638
227639 assert( pSession->rc==SQLITE_OK );
227640
227641 pSession->rc = sessionTableInfo(pSession, pSession->db, pSession->zDb,
227642 pTab->zName, &nCol, 0, &azCol, &azDflt, &abPK,
227643 (pSession->bImplicitPK ? &bRowid : 0)
227644 );
227645 if( pSession->rc==SQLITE_OK ){
227646 if( pTab->nCol>nCol || pTab->bRowid!=bRowid ){
227647 pSession->rc = SQLITE_SCHEMA;
@@ -227660,12 +228147,14 @@
227660
227661 if( pSession->rc==SQLITE_OK ){
227662 const char **a = pTab->azCol;
227663 pTab->azCol = azCol;
227664 pTab->nCol = nCol;
 
227665 pTab->azDflt = azDflt;
227666 pTab->abPK = abPK;
 
227667 azCol = a;
227668 }
227669 if( pSession->bEnableSize ){
227670 pSession->nMaxChangesetSize += (nCol - nOldCol);
227671 pSession->nMaxChangesetSize += sessionVarintLen(nCol);
@@ -227979,11 +228468,11 @@
227979 if( pTab->bRowid ) nNew += 9;
227980 if( op!=SQLITE_DELETE ){
227981 int ii;
227982 for(ii=0; ii<pTab->nCol; ii++){
227983 sqlite3_value *p = 0;
227984 pSession->hook.xNew(pSession->hook.pCtx, ii, &p);
227985 sessionSerializeValue(0, p, &nNew);
227986 }
227987 }
227988 }else if( op==SQLITE_DELETE ){
227989 nNew += pC->nRecord;
@@ -227999,12 +228488,13 @@
227999 }
228000 for(ii=pTab->bRowid; ii<pTab->nCol; ii++){
228001 int bChanged = 1;
228002 int nOld = 0;
228003 int eType;
 
228004 sqlite3_value *p = 0;
228005 pSession->hook.xNew(pSession->hook.pCtx, ii-pTab->bRowid, &p);
228006 if( p==0 ){
228007 return SQLITE_NOMEM;
228008 }
228009
228010 eType = *pCsr++;
@@ -228097,15 +228587,15 @@
228097 if( sessionInitTable(pSession, pTab, pSession->db, pSession->zDb) ) return;
228098
228099 /* Check the number of columns in this xPreUpdate call matches the
228100 ** number of columns in the table. */
228101 nExpect = pSession->hook.xCount(pSession->hook.pCtx);
228102 if( (pTab->nCol-pTab->bRowid)<nExpect ){
228103 if( sessionReinitTable(pSession, pTab) ) return;
228104 if( sessionUpdateChanges(pSession, pTab) ) return;
228105 }
228106 if( (pTab->nCol-pTab->bRowid)!=nExpect ){
228107 pSession->rc = SQLITE_SCHEMA;
228108 return;
228109 }
228110
228111 /* Grow the hash table if required */
@@ -228158,18 +228648,19 @@
228158 assert( rc==SQLITE_OK );
228159 pTab->nEntry++;
228160
228161 /* Figure out how large an allocation is required */
228162 nByte = sizeof(SessionChange);
228163 for(i=0; i<(pTab->nCol-pTab->bRowid); i++){
 
228164 sqlite3_value *p = 0;
228165 if( op!=SQLITE_INSERT ){
228166 /* This may fail if the column has a non-NULL default and was added
228167 ** using ALTER TABLE ADD COLUMN after this record was created. */
228168 rc = pSession->hook.xOld(pSession->hook.pCtx, i, &p);
228169 }else if( pTab->abPK[i] ){
228170 TESTONLY(int trc = ) pSession->hook.xNew(pSession->hook.pCtx, i, &p);
228171 assert( trc==SQLITE_OK );
228172 }
228173
228174 if( rc==SQLITE_OK ){
228175 /* This may fail if SQLite value p contains a utf-16 string that must
@@ -228200,16 +228691,17 @@
228200 if( pTab->bRowid ){
228201 pC->aRecord[0] = SQLITE_INTEGER;
228202 sessionPutI64(&pC->aRecord[1], iRowid);
228203 nByte = 9;
228204 }
228205 for(i=0; i<(pTab->nCol-pTab->bRowid); i++){
228206 sqlite3_value *p = 0;
 
228207 if( op!=SQLITE_INSERT ){
228208 pSession->hook.xOld(pSession->hook.pCtx, i, &p);
228209 }else if( pTab->abPK[i] ){
228210 pSession->hook.xNew(pSession->hook.pCtx, i, &p);
228211 }
228212 sessionSerializeValue(&pC->aRecord[nByte], p, &nByte);
228213 }
228214
228215 /* Add the change to the hash-table */
@@ -228607,11 +229099,12 @@
228607 int bMismatch = 0;
228608 int nCol; /* Columns in zFrom.zTbl */
228609 int bRowid = 0;
228610 u8 *abPK;
228611 const char **azCol = 0;
228612 rc = sessionTableInfo(0, db, zFrom, zTbl, &nCol, 0, &azCol, 0, &abPK,
 
228613 pSession->bImplicitPK ? &bRowid : 0
228614 );
228615 if( rc==SQLITE_OK ){
228616 if( pTo->nCol!=nCol ){
228617 bMismatch = 1;
@@ -228931,13 +229424,15 @@
228931 int nStr = sqlite3Strlen30(zStr)*2 + 2 + 2;
228932 if( 0==sessionBufferGrow(p, nStr, pRc) ){
228933 char *zOut = (char *)&p->aBuf[p->nBuf];
228934 const char *zIn = zStr;
228935 *zOut++ = '"';
228936 while( *zIn ){
228937 if( *zIn=='"' ) *zOut++ = '"';
228938 *zOut++ = *(zIn++);
 
 
228939 }
228940 *zOut++ = '"';
228941 p->nBuf = (int)((u8 *)zOut - p->aBuf);
228942 p->aBuf[p->nBuf] = 0x00;
228943 }
@@ -229184,14 +229679,14 @@
229184 sqlite3_stmt **ppStmt /* OUT: Prepared SELECT statement */
229185 ){
229186 int rc = SQLITE_OK;
229187 char *zSql = 0;
229188 const char *zSep = "";
229189 const char *zCols = bRowid ? SESSIONS_ROWID ", *" : "*";
229190 int nSql = -1;
229191 int i;
229192
 
229193 SessionBuffer nooptest = {0, 0, 0};
229194 SessionBuffer pkfield = {0, 0, 0};
229195 SessionBuffer pkvar = {0, 0, 0};
229196
229197 sessionAppendStr(&nooptest, ", 1", &rc);
@@ -229200,13 +229695,20 @@
229200 sessionAppendStr(&nooptest, " AND (?6 OR ?3 IS stat)", &rc);
229201 sessionAppendStr(&pkfield, "tbl, idx", &rc);
229202 sessionAppendStr(&pkvar,
229203 "?1, (CASE WHEN ?2=X'' THEN NULL ELSE ?2 END)", &rc
229204 );
229205 zCols = "tbl, ?2, stat";
229206 }else{
 
 
 
 
 
229207 for(i=0; i<nCol; i++){
 
 
229208 if( abPK[i] ){
229209 sessionAppendStr(&pkfield, zSep, &rc);
229210 sessionAppendStr(&pkvar, zSep, &rc);
229211 zSep = ", ";
229212 sessionAppendIdent(&pkfield, azCol[i], &rc);
@@ -229220,11 +229722,11 @@
229220 }
229221
229222 if( rc==SQLITE_OK ){
229223 zSql = sqlite3_mprintf(
229224 "SELECT %s%s FROM %Q.%Q WHERE (%s) IS (%s)",
229225 zCols, (bIgnoreNoop ? (char*)nooptest.aBuf : ""),
229226 zDb, zTab, (char*)pkfield.aBuf, (char*)pkvar.aBuf
229227 );
229228 if( zSql==0 ) rc = SQLITE_NOMEM;
229229 }
229230
@@ -229263,10 +229765,11 @@
229263 }
229264 sqlite3_free(zSql);
229265 sqlite3_free(nooptest.aBuf);
229266 sqlite3_free(pkfield.aBuf);
229267 sqlite3_free(pkvar.aBuf);
 
229268 return rc;
229269 }
229270
229271 /*
229272 ** Bind the PRIMARY KEY values from the change passed in argument pChange
@@ -231603,11 +232106,12 @@
231603 int nMinCol = 0;
231604 int i;
231605
231606 sqlite3changeset_pk(pIter, &abPK, 0);
231607 rc = sessionTableInfo(0, db, "main", zNew,
231608 &sApply.nCol, &zTab, &sApply.azCol, 0, &sApply.abPK, &sApply.bRowid
 
231609 );
231610 if( rc!=SQLITE_OK ) break;
231611 for(i=0; i<sApply.nCol; i++){
231612 if( sApply.abPK[i] ) nMinCol = i+1;
231613 }
@@ -231683,16 +232187,21 @@
231683 if( res!=SQLITE_CHANGESET_OMIT ){
231684 rc = SQLITE_CONSTRAINT;
231685 }
231686 }
231687 }
231688 sqlite3_exec(db, "PRAGMA defer_foreign_keys = 0", 0, 0, 0);
 
 
 
 
231689
231690 if( (flags & SQLITE_CHANGESETAPPLY_NOSAVEPOINT)==0 ){
231691 if( rc==SQLITE_OK ){
231692 rc = sqlite3_exec(db, "RELEASE changeset_apply", 0, 0, 0);
231693 }else{
 
231694 sqlite3_exec(db, "ROLLBACK TO changeset_apply", 0, 0, 0);
231695 sqlite3_exec(db, "RELEASE changeset_apply", 0, 0, 0);
231696 }
231697 }
231698
@@ -243195,15 +243704,17 @@
243195 }
243196
243197 /*
243198 ** Close the read-only blob handle, if it is open.
243199 */
243200 static void sqlite3Fts5IndexCloseReader(Fts5Index *p){
243201 if( p->pReader ){
 
243202 sqlite3_blob *pReader = p->pReader;
243203 p->pReader = 0;
243204 sqlite3_blob_close(pReader);
 
243205 }
243206 }
243207
243208 /*
243209 ** Retrieve a record from the %_data table.
@@ -243224,11 +243735,11 @@
243224 p->pReader = 0;
243225 rc = sqlite3_blob_reopen(pBlob, iRowid);
243226 assert( p->pReader==0 );
243227 p->pReader = pBlob;
243228 if( rc!=SQLITE_OK ){
243229 sqlite3Fts5IndexCloseReader(p);
243230 }
243231 if( rc==SQLITE_ABORT ) rc = SQLITE_OK;
243232 }
243233
243234 /* If the blob handle is not open at this point, open it and seek
@@ -243308,13 +243819,17 @@
243308 sqlite3_stmt **ppStmt,
243309 char *zSql
243310 ){
243311 if( p->rc==SQLITE_OK ){
243312 if( zSql ){
243313 p->rc = sqlite3_prepare_v3(p->pConfig->db, zSql, -1,
243314 SQLITE_PREPARE_PERSISTENT|SQLITE_PREPARE_NO_VTAB,
243315 ppStmt, 0);
 
 
 
 
243316 }else{
243317 p->rc = SQLITE_NOMEM;
243318 }
243319 }
243320 sqlite3_free(zSql);
@@ -247421,10 +247936,18 @@
247421 static int fts5IndexReturn(Fts5Index *p){
247422 int rc = p->rc;
247423 p->rc = SQLITE_OK;
247424 return rc;
247425 }
 
 
 
 
 
 
 
 
247426
247427 typedef struct Fts5FlushCtx Fts5FlushCtx;
247428 struct Fts5FlushCtx {
247429 Fts5Index *pIdx;
247430 Fts5SegWriter writer;
@@ -247609,11 +248132,11 @@
247609 int iIdx = 0;
247610 int iStart = 0;
247611 int iDelKeyOff = 0; /* Offset of deleted key, if any */
247612
247613 nIdx = nPg-iPgIdx;
247614 aIdx = sqlite3Fts5MallocZero(&p->rc, nIdx+16);
247615 if( p->rc ) return;
247616 memcpy(aIdx, &aPg[iPgIdx], nIdx);
247617
247618 /* At this point segment iterator pSeg points to the entry
247619 ** this function should remove from the b-tree segment.
@@ -247879,20 +248402,41 @@
247879
247880 /*
247881 ** This is called as part of flushing a delete to disk in 'secure-delete'
247882 ** mode. It edits the segments within the database described by argument
247883 ** pStruct to remove the entries for term zTerm, rowid iRowid.
 
 
 
247884 */
247885 static void fts5FlushSecureDelete(
247886 Fts5Index *p,
247887 Fts5Structure *pStruct,
247888 const char *zTerm,
247889 int nTerm,
247890 i64 iRowid
247891 ){
247892 const int f = FTS5INDEX_QUERY_SKIPHASH;
247893 Fts5Iter *pIter = 0; /* Used to find term instance */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
247894
247895 fts5MultiIterNew(p, pStruct, f, 0, (const u8*)zTerm, nTerm, -1, 0, &pIter);
247896 if( fts5MultiIterEof(p, pIter)==0 ){
247897 i64 iThis = fts5MultiIterRowid(pIter);
247898 if( iThis<iRowid ){
@@ -247907,10 +248451,11 @@
247907 fts5DoSecureDelete(p, pSeg);
247908 }
247909 }
247910
247911 fts5MultiIterFree(pIter);
 
247912 }
247913
247914
247915 /*
247916 ** Flush the contents of in-memory hash table iHash to a new level-0
@@ -247990,22 +248535,24 @@
247990 /* If in secure delete mode, and if this entry in the poslist is
247991 ** in fact a delete, then edit the existing segments directly
247992 ** using fts5FlushSecureDelete(). */
247993 if( bSecureDelete ){
247994 if( eDetail==FTS5_DETAIL_NONE ){
247995 if( iOff<nDoclist && pDoclist[iOff]==0x00 ){
247996 fts5FlushSecureDelete(p, pStruct, zTerm, nTerm, iRowid);
 
247997 iOff++;
247998 if( iOff<nDoclist && pDoclist[iOff]==0x00 ){
247999 iOff++;
248000 nDoclist = 0;
248001 }else{
248002 continue;
248003 }
248004 }
248005 }else if( (pDoclist[iOff] & 0x01) ){
248006 fts5FlushSecureDelete(p, pStruct, zTerm, nTerm, iRowid);
 
248007 if( p->rc!=SQLITE_OK || pDoclist[iOff]==0x01 ){
248008 iOff++;
248009 continue;
248010 }
248011 }
@@ -248179,11 +248726,11 @@
248179 return pStruct;
248180 }
248181 assert( pStruct->aLevel[i].nMerge<=nThis );
248182 }
248183
248184 nByte += (pStruct->nLevel+1) * sizeof(Fts5StructureLevel);
248185 pNew = (Fts5Structure*)sqlite3Fts5MallocZero(&p->rc, nByte);
248186
248187 if( pNew ){
248188 Fts5StructureLevel *pLvl;
248189 nByte = nSeg * sizeof(Fts5StructureSegment);
@@ -249067,18 +249614,21 @@
249067 for(iFree=i; iFree<i+s.nMerge; iFree++){
249068 fts5BufferFree(&s.aBuf[iFree]);
249069 }
249070 }
249071
249072 pData = fts5IdxMalloc(p, sizeof(*pData)+s.doclist.n+FTS5_DATA_ZERO_PADDING);
 
 
249073 if( pData ){
249074 pData->p = (u8*)&pData[1];
249075 pData->nn = pData->szLeaf = s.doclist.n;
249076 if( s.doclist.n ) memcpy(pData->p, s.doclist.p, s.doclist.n);
249077 fts5MultiIterNew2(p, pData, bDesc, ppIter);
249078 }
249079
 
249080 if( p->rc==SQLITE_OK && s.pTokendata ){
249081 fts5TokendataIterSortMap(p, s2.pT);
249082 (*ppIter)->pTokenDataIter = s2.pT;
249083 s2.pT = 0;
249084 }
@@ -249123,11 +249673,11 @@
249123 ** Commit data to disk.
249124 */
249125 static int sqlite3Fts5IndexSync(Fts5Index *p){
249126 assert( p->rc==SQLITE_OK );
249127 fts5IndexFlush(p);
249128 sqlite3Fts5IndexCloseReader(p);
249129 return fts5IndexReturn(p);
249130 }
249131
249132 /*
249133 ** Discard any data stored in the in-memory hash tables. Do not write it
@@ -249134,15 +249684,14 @@
249134 ** to the database. Additionally, assume that the contents of the %_data
249135 ** table may have changed on disk. So any in-memory caches of %_data
249136 ** records must be invalidated.
249137 */
249138 static int sqlite3Fts5IndexRollback(Fts5Index *p){
249139 sqlite3Fts5IndexCloseReader(p);
249140 fts5IndexDiscardData(p);
249141 fts5StructureInvalidate(p);
249142 /* assert( p->rc==SQLITE_OK ); */
249143 return SQLITE_OK;
249144 }
249145
249146 /*
249147 ** The %_data table is completely empty when this function is called. This
249148 ** function populates it with the initial structure objects for each index,
@@ -249338,10 +249887,20 @@
249338 */
249339 static void fts5SegIterSetEOF(Fts5SegIter *pSeg){
249340 fts5DataRelease(pSeg->pLeaf);
249341 pSeg->pLeaf = 0;
249342 }
 
 
 
 
 
 
 
 
 
 
249343
249344 /*
249345 ** This function appends iterator pAppend to Fts5TokenDataIter pIn and
249346 ** returns the result.
249347 */
@@ -249366,11 +249925,11 @@
249366 pNew->nIterAlloc = nAlloc;
249367 }
249368 }
249369 }
249370 if( p->rc ){
249371 sqlite3Fts5IterClose((Fts5IndexIter*)pAppend);
249372 }else{
249373 pRet->apIter[pRet->nIter++] = pAppend;
249374 }
249375 assert( pRet==0 || pRet->nIter<=pRet->nIterAlloc );
249376
@@ -249579,11 +250138,11 @@
249579 fts5BufferAppendBlob(&p->rc, &bSeek, 1, (const u8*)"\0");
249580 }else{
249581 fts5BufferSet(&p->rc, &bSeek, nToken, pToken);
249582 }
249583 if( p->rc ){
249584 sqlite3Fts5IterClose((Fts5IndexIter*)pNew);
249585 break;
249586 }
249587
249588 pNewIter = &pNew->aSeg[0];
249589 pPrevIter = (pPrev ? &pPrev->aSeg[0] : 0);
@@ -249644,11 +250203,11 @@
249644
249645 /* If pSmall is still NULL at this point, then the new iterator does
249646 ** not point to any terms that match the query. So delete it and break
249647 ** out of the loop - all required iterators have been collected. */
249648 if( pSmall==0 ){
249649 sqlite3Fts5IterClose((Fts5IndexIter*)pNew);
249650 break;
249651 }
249652
249653 /* Append this iterator to the set and continue. */
249654 pSet = fts5AppendTokendataIter(p, pSet, pNew);
@@ -249706,10 +250265,11 @@
249706
249707 if( sqlite3Fts5BufferSize(&p->rc, &buf, nToken+1)==0 ){
249708 int iIdx = 0; /* Index to search */
249709 int iPrefixIdx = 0; /* +1 prefix index */
249710 int bTokendata = pConfig->bTokendata;
 
249711 if( nToken>0 ) memcpy(&buf.p[1], pToken, nToken);
249712
249713 /* The NOTOKENDATA flag is set when each token in a tokendata=1 table
249714 ** should be treated individually, instead of merging all those with
249715 ** a common prefix into a single entry. This is used, for example, by
@@ -249772,13 +250332,13 @@
249772 }
249773 }
249774 }
249775
249776 if( p->rc ){
249777 sqlite3Fts5IterClose((Fts5IndexIter*)pRet);
249778 pRet = 0;
249779 sqlite3Fts5IndexCloseReader(p);
249780 }
249781
249782 *ppIter = (Fts5IndexIter*)pRet;
249783 sqlite3Fts5BufferFree(&buf);
249784 }
@@ -249867,10 +250427,11 @@
249867 TokendataSetupCtx ctx;
249868
249869 memset(&ctx, 0, sizeof(ctx));
249870
249871 fts5BufferGrow(&p->rc, &token, nToken+1);
 
249872 ctx.pT = (Fts5TokenDataIter*)sqlite3Fts5MallocZero(&p->rc, sizeof(*ctx.pT));
249873
249874 if( p->rc==SQLITE_OK ){
249875
249876 /* Fill in the token prefix to search for */
@@ -250023,15 +250584,13 @@
250023 /*
250024 ** Close an iterator opened by an earlier call to sqlite3Fts5IndexQuery().
250025 */
250026 static void sqlite3Fts5IterClose(Fts5IndexIter *pIndexIter){
250027 if( pIndexIter ){
250028 Fts5Iter *pIter = (Fts5Iter*)pIndexIter;
250029 Fts5Index *pIndex = pIter->pIndex;
250030 fts5TokendataIterDelete(pIter->pTokenDataIter);
250031 fts5MultiIterFree(pIter);
250032 sqlite3Fts5IndexCloseReader(pIndex);
250033 }
250034 }
250035
250036 /*
250037 ** Read and decode the "averages" record from the database.
@@ -250557,11 +251116,11 @@
250557 }
250558 if( rc==SQLITE_OK ){
250559 rc = sqlite3Fts5IterNext(pIter);
250560 }
250561 }
250562 sqlite3Fts5IterClose(pIter);
250563
250564 *pCksum = cksum;
250565 return rc;
250566 }
250567
@@ -251280,11 +251839,11 @@
251280 /* Make a copy of the second argument (a blob) in aBlob[]. The aBlob[]
251281 ** copy is followed by FTS5_DATA_ZERO_PADDING 0x00 bytes, which prevents
251282 ** buffer overreads even if the record is corrupt. */
251283 n = sqlite3_value_bytes(apVal[1]);
251284 aBlob = sqlite3_value_blob(apVal[1]);
251285 nSpace = n + FTS5_DATA_ZERO_PADDING;
251286 a = (u8*)sqlite3Fts5MallocZero(&rc, nSpace);
251287 if( a==0 ) goto decode_out;
251288 if( n>0 ) memcpy(a, aBlob, n);
251289
251290 fts5DecodeRowid(iRowid, &bTomb, &iSegid, &bDlidx, &iHeight, &iPgno);
@@ -253726,11 +254285,10 @@
253726 ){
253727 Fts5FullTable *pTab = (Fts5FullTable*)pVtab;
253728 Fts5Config *pConfig = pTab->p.pConfig;
253729 int eType0; /* value_type() of apVal[0] */
253730 int rc = SQLITE_OK; /* Return code */
253731 int bUpdateOrDelete = 0;
253732
253733 /* A transaction must be open when this is called. */
253734 assert( pTab->ts.eState==1 || pTab->ts.eState==2 );
253735
253736 assert( pVtab->zErrMsg==0 );
@@ -253738,11 +254296,11 @@
253738 assert( sqlite3_value_type(apVal[0])==SQLITE_INTEGER
253739 || sqlite3_value_type(apVal[0])==SQLITE_NULL
253740 );
253741 assert( pTab->p.pConfig->pzErrmsg==0 );
253742 if( pConfig->pgsz==0 ){
253743 rc = sqlite3Fts5IndexLoadConfig(pTab->p.pIndex);
253744 if( rc!=SQLITE_OK ) return rc;
253745 }
253746
253747 pTab->p.pConfig->pzErrmsg = &pTab->p.base.zErrMsg;
253748
@@ -253763,11 +254321,10 @@
253763 "'delete' may not be used with a contentless_delete=1 table"
253764 );
253765 rc = SQLITE_ERROR;
253766 }else{
253767 rc = fts5SpecialDelete(pTab, apVal);
253768 bUpdateOrDelete = 1;
253769 }
253770 }else{
253771 rc = fts5SpecialInsert(pTab, z, apVal[2 + pConfig->nCol + 1]);
253772 }
253773 }else{
@@ -253800,11 +254357,10 @@
253800 );
253801 rc = SQLITE_ERROR;
253802 }else{
253803 i64 iDel = sqlite3_value_int64(apVal[0]); /* Rowid to delete */
253804 rc = sqlite3Fts5StorageDelete(pTab->pStorage, iDel, 0, 0);
253805 bUpdateOrDelete = 1;
253806 }
253807 }
253808
253809 /* INSERT or UPDATE */
253810 else{
@@ -253828,11 +254384,10 @@
253828 /* An INSERT statement. If the conflict-mode is REPLACE, first remove
253829 ** the current entry (if any). */
253830 if( eConflict==SQLITE_REPLACE && eType1==SQLITE_INTEGER ){
253831 i64 iNew = sqlite3_value_int64(apVal[1]); /* Rowid to delete */
253832 rc = sqlite3Fts5StorageDelete(pTab->pStorage, iNew, 0, 0);
253833 bUpdateOrDelete = 1;
253834 }
253835 fts5StorageInsert(&rc, pTab, apVal, pRowid);
253836 }
253837
253838 /* UPDATE */
@@ -253882,27 +254437,12 @@
253882 }
253883 }else{
253884 rc = sqlite3Fts5StorageDelete(pStorage, iOld, 0, 1);
253885 fts5StorageInsert(&rc, pTab, apVal, pRowid);
253886 }
253887 bUpdateOrDelete = 1;
253888 sqlite3Fts5StorageReleaseDeleteRow(pStorage);
253889 }
253890
253891 }
253892 }
253893
253894 if( rc==SQLITE_OK
253895 && bUpdateOrDelete
253896 && pConfig->bSecureDelete
253897 && pConfig->iVersion==FTS5_CURRENT_VERSION
253898 ){
253899 rc = sqlite3Fts5StorageConfigValue(
253900 pTab->pStorage, "version", 0, FTS5_CURRENT_VERSION_SECUREDELETE
253901 );
253902 if( rc==SQLITE_OK ){
253903 pConfig->iVersion = FTS5_CURRENT_VERSION_SECUREDELETE;
253904 }
253905 }
253906
253907 update_out:
253908 pTab->p.pConfig->pzErrmsg = 0;
@@ -253951,10 +254491,11 @@
253951 static int fts5RollbackMethod(sqlite3_vtab *pVtab){
253952 int rc;
253953 Fts5FullTable *pTab = (Fts5FullTable*)pVtab;
253954 fts5CheckTransactionState(pTab, FTS5_ROLLBACK, 0);
253955 rc = sqlite3Fts5StorageRollback(pTab->pStorage);
 
253956 return rc;
253957 }
253958
253959 static int fts5CsrPoslist(Fts5Cursor*, int, const u8**, int*);
253960
@@ -255419,11 +255960,11 @@
255419 int nArg, /* Number of args */
255420 sqlite3_value **apUnused /* Function arguments */
255421 ){
255422 assert( nArg==0 );
255423 UNUSED_PARAM2(nArg, apUnused);
255424 sqlite3_result_text(pCtx, "fts5: 2024-12-09 20:46:36 e2bae4143afd07de1ae55a6d2606a3b541a5b94568aa41f6a96e5d1245471653", -1, SQLITE_TRANSIENT);
255425 }
255426
255427 /*
255428 ** Implementation of fts5_locale(LOCALE, TEXT) function.
255429 **
@@ -255899,10 +256440,15 @@
255899 rc = sqlite3_prepare_v3(pC->db, zSql, -1, f, &p->aStmt[eStmt], 0);
255900 p->pConfig->bLock--;
255901 sqlite3_free(zSql);
255902 if( rc!=SQLITE_OK && pzErrMsg ){
255903 *pzErrMsg = sqlite3_mprintf("%s", sqlite3_errmsg(pC->db));
 
 
 
 
 
255904 }
255905 }
255906 }
255907
255908 *ppStmt = p->aStmt[eStmt];
@@ -260019,16 +260565,16 @@
260019
260020 if( argc!=5 && bDb==0 ){
260021 *pzErr = sqlite3_mprintf("wrong number of vtable arguments");
260022 rc = SQLITE_ERROR;
260023 }else{
260024 int nByte; /* Bytes of space to allocate */
260025 const char *zDb = bDb ? argv[3] : argv[1];
260026 const char *zTab = bDb ? argv[4] : argv[3];
260027 const char *zType = bDb ? argv[5] : argv[4];
260028 int nDb = (int)strlen(zDb)+1;
260029 int nTab = (int)strlen(zTab)+1;
260030 int eType = 0;
260031
260032 rc = fts5VocabTableType(zType, pzErr, &eType);
260033 if( rc==SQLITE_OK ){
260034 assert( eType>=0 && eType<ArraySize(azSchema) );
260035
--- extsrc/sqlite3.c
+++ extsrc/sqlite3.c
@@ -1,8 +1,8 @@
1 /******************************************************************************
2 ** This file is an amalgamation of many separate C source files from SQLite
3 ** version 3.50.0. By combining all the individual C code files into this
4 ** single large file, the entire code can be compiled as a single translation
5 ** unit. This allows many compilers to do optimizations that would not be
6 ** possible if the files were compiled separately. Performance improvements
7 ** of 5% or more are commonly seen when SQLite is compiled as a single
8 ** translation unit.
@@ -16,11 +16,11 @@
16 ** if you want a wrapper to interface SQLite with your choice of programming
17 ** language. The code for the "sqlite3" command-line shell is also in a
18 ** separate file. This file contains only code for the core SQLite library.
19 **
20 ** The content in this amalgamation comes from Fossil check-in
21 ** 57caa3136d1bfca06e4f2285734a4977b8d3 with changes in files:
22 **
23 **
24 */
25 #ifndef SQLITE_AMALGAMATION
26 #define SQLITE_CORE 1
@@ -463,13 +463,13 @@
463 **
464 ** See also: [sqlite3_libversion()],
465 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
466 ** [sqlite_version()] and [sqlite_source_id()].
467 */
468 #define SQLITE_VERSION "3.50.0"
469 #define SQLITE_VERSION_NUMBER 3050000
470 #define SQLITE_SOURCE_ID "2025-02-18 01:16:26 57caa3136d1bfca06e4f2285734a4977b8d3fa1f75bf87453b975867e9de38fc"
471
472 /*
473 ** CAPI3REF: Run-Time Library Version Numbers
474 ** KEYWORDS: sqlite3_version sqlite3_sourceid
475 **
@@ -2306,17 +2306,20 @@
2306 ** [sqlite3_config()] with the SQLITE_CONFIG_GETMUTEX configuration option will
2307 ** return [SQLITE_ERROR].</dd>
2308 **
2309 ** [[SQLITE_CONFIG_LOOKASIDE]] <dt>SQLITE_CONFIG_LOOKASIDE</dt>
2310 ** <dd> ^(The SQLITE_CONFIG_LOOKASIDE option takes two arguments that determine
2311 ** the default size of [lookaside memory] on each [database connection].
2312 ** The first argument is the
2313 ** size of each lookaside buffer slot ("sz") and the second is the number of
2314 ** slots allocated to each database connection ("cnt").)^
2315 ** ^(SQLITE_CONFIG_LOOKASIDE sets the <i>default</i> lookaside size.
2316 ** The [SQLITE_DBCONFIG_LOOKASIDE] option to [sqlite3_db_config()] can
2317 ** be used to change the lookaside configuration on individual connections.)^
2318 ** The [-DSQLITE_DEFAULT_LOOKASIDE] option can be used to change the
2319 ** default lookaside configuration at compile-time.
2320 ** </dd>
2321 **
2322 ** [[SQLITE_CONFIG_PCACHE2]] <dt>SQLITE_CONFIG_PCACHE2</dt>
2323 ** <dd> ^(The SQLITE_CONFIG_PCACHE2 option takes a single argument which is
2324 ** a pointer to an [sqlite3_pcache_methods2] object. This object specifies
2325 ** the interface to a custom page cache implementation.)^
@@ -2528,11 +2531,19 @@
2531
2532 /*
2533 ** CAPI3REF: Database Connection Configuration Options
2534 **
2535 ** These constants are the available integer configuration options that
2536 ** can be passed as the second parameter to the [sqlite3_db_config()] interface.
2537 **
2538 ** The [sqlite3_db_config()] interface is a var-args functions. It takes a
2539 ** variable number of parameters, though always at least two. The number of
2540 ** parameters passed into sqlite3_db_config() depends on which of these
2541 ** constants is given as the second parameter. This documentation page
2542 ** refers to parameters beyond the second as "arguments". Thus, when this
2543 ** page says "the N-th argument" it means "the N-th parameter past the
2544 ** configuration option" or "the (N+2)-th parameter to sqlite3_db_config()".
2545 **
2546 ** New configuration options may be added in future releases of SQLite.
2547 ** Existing configuration options might be discontinued. Applications
2548 ** should check the return code from [sqlite3_db_config()] to make sure that
2549 ** the call worked. ^The [sqlite3_db_config()] interface will return a
@@ -2540,35 +2551,61 @@
2551 ** is invoked.
2552 **
2553 ** <dl>
2554 ** [[SQLITE_DBCONFIG_LOOKASIDE]]
2555 ** <dt>SQLITE_DBCONFIG_LOOKASIDE</dt>
2556 ** <dd> The SQLITE_DBCONFIG_LOOKASIDE option is used to adjust the
2557 ** configuration of the [lookaside memory allocator] within a database
2558 ** connection.
2559 ** The arguments to the SQLITE_DBCONFIG_LOOKASIDE option are <i>not</i>
2560 ** in the [DBCONFIG arguments|usual format].
2561 ** The SQLITE_DBCONFIG_LOOKASIDE option takes three arguments, not two,
2562 ** so that a call to [sqlite3_db_config()] that uses SQLITE_DBCONFIG_LOOKASIDE
2563 ** should have a total of five parameters.
2564 ** <ol>
2565 ** <li><p>The first argument ("buf") is a
2566 ** pointer to a memory buffer to use for lookaside memory.
2567 ** The first argument may be NULL in which case SQLite will allocate the
2568 ** lookaside buffer itself using [sqlite3_malloc()].
2569 ** <li><P>The second argument ("sz") is the
2570 ** size of each lookaside buffer slot. Lookaside is disabled if "sz"
2571 ** is less than 8. The "sz" argument should be a multiple of 8 less than
2572 ** 65536. If "sz" does not meet this constraint, it is reduced in size until
2573 ** it does.
2574 ** <li><p>The third argument ("cnt") is the number of slots. Lookaside is disabled
2575 ** if "cnt"is less than 1. The "cnt" value will be reduced, if necessary, so
2576 ** that the product of "sz" and "cnt" does not exceed 2,147,418,112. The "cnt"
2577 ** parameter is usually chosen so that the product of "sz" and "cnt" is less
2578 ** than 1,000,000.
2579 ** </ol>
2580 ** <p>If the "buf" argument is not NULL, then it must
2581 ** point to a memory buffer with a size that is greater than
2582 ** or equal to the product of "sz" and "cnt".
2583 ** The buffer must be aligned to an 8-byte boundary.
2584 ** The lookaside memory
2585 ** configuration for a database connection can only be changed when that
2586 ** connection is not currently using lookaside memory, or in other words
2587 ** when the value returned by [SQLITE_DBSTATUS_LOOKASIDE_USED] is zero.
 
2588 ** Any attempt to change the lookaside memory configuration when lookaside
2589 ** memory is in use leaves the configuration unchanged and returns
2590 ** [SQLITE_BUSY].
2591 ** If the "buf" argument is NULL and an attempt
2592 ** to allocate memory based on "sz" and "cnt" fails, then
2593 ** lookaside is silently disabled.
2594 ** <p>
2595 ** The [SQLITE_CONFIG_LOOKASIDE] configuration option can be used to set the
2596 ** default lookaside configuration at initialization. The
2597 ** [-DSQLITE_DEFAULT_LOOKASIDE] option can be used to set the default lookaside
2598 ** configuration at compile-time. Typical values for lookaside are 1200 for
2599 ** "sz" and 40 to 100 for "cnt".
2600 ** </dd>
2601 **
2602 ** [[SQLITE_DBCONFIG_ENABLE_FKEY]]
2603 ** <dt>SQLITE_DBCONFIG_ENABLE_FKEY</dt>
2604 ** <dd> ^This option is used to enable or disable the enforcement of
2605 ** [foreign key constraints]. This is the same setting that is
2606 ** enabled or disabled by the [PRAGMA foreign_keys] statement.
2607 ** The first argument is an integer which is 0 to disable FK enforcement,
2608 ** positive to enable FK enforcement or negative to leave FK enforcement
2609 ** unchanged. The second parameter is a pointer to an integer into which
2610 ** is written 0 or 1 to indicate whether FK enforcement is off or on
2611 ** following this call. The second parameter may be a NULL pointer, in
@@ -2586,17 +2623,17 @@
2623 ** which case the trigger setting is not reported back.
2624 **
2625 ** <p>Originally this option disabled all triggers. ^(However, since
2626 ** SQLite version 3.35.0, TEMP triggers are still allowed even if
2627 ** this option is off. So, in other words, this option now only disables
2628 ** triggers in the main database schema or in the schemas of [ATTACH]-ed
2629 ** databases.)^ </dd>
2630 **
2631 ** [[SQLITE_DBCONFIG_ENABLE_VIEW]]
2632 ** <dt>SQLITE_DBCONFIG_ENABLE_VIEW</dt>
2633 ** <dd> ^This option is used to enable or disable [CREATE VIEW | views].
2634 ** There must be two additional arguments.
2635 ** The first argument is an integer which is 0 to disable views,
2636 ** positive to enable views or negative to leave the setting unchanged.
2637 ** The second parameter is a pointer to an integer into which
2638 ** is written 0 or 1 to indicate whether views are disabled or enabled
2639 ** following this call. The second parameter may be a NULL pointer, in
@@ -2611,11 +2648,11 @@
2648 ** [[SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER]]
2649 ** <dt>SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER</dt>
2650 ** <dd> ^This option is used to enable or disable the
2651 ** [fts3_tokenizer()] function which is part of the
2652 ** [FTS3] full-text search engine extension.
2653 ** There must be two additional arguments.
2654 ** The first argument is an integer which is 0 to disable fts3_tokenizer() or
2655 ** positive to enable fts3_tokenizer() or negative to leave the setting
2656 ** unchanged.
2657 ** The second parameter is a pointer to an integer into which
2658 ** is written 0 or 1 to indicate whether fts3_tokenizer is disabled or enabled
@@ -2626,11 +2663,11 @@
2663 ** <dt>SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION</dt>
2664 ** <dd> ^This option is used to enable or disable the [sqlite3_load_extension()]
2665 ** interface independently of the [load_extension()] SQL function.
2666 ** The [sqlite3_enable_load_extension()] API enables or disables both the
2667 ** C-API [sqlite3_load_extension()] and the SQL function [load_extension()].
2668 ** There must be two additional arguments.
2669 ** When the first argument to this interface is 1, then only the C-API is
2670 ** enabled and the SQL function remains disabled. If the first argument to
2671 ** this interface is 0, then both the C-API and the SQL function are disabled.
2672 ** If the first argument is -1, then no changes are made to state of either the
2673 ** C-API or the SQL function.
@@ -2640,27 +2677,34 @@
2677 ** be a NULL pointer, in which case the new setting is not reported back.
2678 ** </dd>
2679 **
2680 ** [[SQLITE_DBCONFIG_MAINDBNAME]] <dt>SQLITE_DBCONFIG_MAINDBNAME</dt>
2681 ** <dd> ^This option is used to change the name of the "main" database
2682 ** schema. This option does not follow the
2683 ** [DBCONFIG arguments|usual SQLITE_DBCONFIG argument format].
2684 ** This option takes exactly one additional argument so that the
2685 ** [sqlite3_db_config()] call has a total of three parameters. The
2686 ** extra argument must be a pointer to a constant UTF8 string which
2687 ** will become the new schema name in place of "main". ^SQLite does
2688 ** not make a copy of the new main schema name string, so the application
2689 ** must ensure that the argument passed into SQLITE_DBCONFIG MAINDBNAME
2690 ** is unchanged until after the database connection closes.
2691 ** </dd>
2692 **
2693 ** [[SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE]]
2694 ** <dt>SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE</dt>
2695 ** <dd> Usually, when a database in [WAL mode] is closed or detached from a
2696 ** database handle, SQLite checks if if there are other connections to the
2697 ** same database, and if there are no other database connection (if the
2698 ** connection being closed is the last open connection to the database),
2699 ** then SQLite performs a [checkpoint] before closing the connection and
2700 ** deletes the WAL file. The SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE option can
2701 ** be used to override that behavior. The first argument passed to this
2702 ** operation (the third parameter to [sqlite3_db_config()]) is an integer
2703 ** which is positive to disable checkpoints-on-close, or zero (the default)
2704 ** to enable them, and negative to leave the setting unchanged.
2705 ** The second argument (the fourth parameter) is a pointer to an integer
2706 ** into which is written 0 or 1 to indicate whether checkpoints-on-close
2707 ** have been disabled - 0 if they are not disabled, 1 if they are.
2708 ** </dd>
2709 **
2710 ** [[SQLITE_DBCONFIG_ENABLE_QPSG]] <dt>SQLITE_DBCONFIG_ENABLE_QPSG</dt>
@@ -2817,11 +2861,11 @@
2861 ** SQLITE_ENABLE_STMT_SCANSTATUS builds. In this case, it sets or clears
2862 ** a flag that enables collection of the sqlite3_stmt_scanstatus_v2()
2863 ** statistics. For statistics to be collected, the flag must be set on
2864 ** the database handle both when the SQL statement is prepared and when it
2865 ** is stepped. The flag is set (collection of statistics is enabled)
2866 ** by default. <p>This option takes two arguments: an integer and a pointer to
2867 ** an integer.. The first argument is 1, 0, or -1 to enable, disable, or
2868 ** leave unchanged the statement scanstatus option. If the second argument
2869 ** is not NULL, then the value of the statement scanstatus setting after
2870 ** processing the first argument is written into the integer that the second
2871 ** argument points to.
@@ -2831,20 +2875,89 @@
2875 ** <dt>SQLITE_DBCONFIG_REVERSE_SCANORDER</dt>
2876 ** <dd>The SQLITE_DBCONFIG_REVERSE_SCANORDER option changes the default order
2877 ** in which tables and indexes are scanned so that the scans start at the end
2878 ** and work toward the beginning rather than starting at the beginning and
2879 ** working toward the end. Setting SQLITE_DBCONFIG_REVERSE_SCANORDER is the
2880 ** same as setting [PRAGMA reverse_unordered_selects]. <p>This option takes
2881 ** two arguments which are an integer and a pointer to an integer. The first
2882 ** argument is 1, 0, or -1 to enable, disable, or leave unchanged the
2883 ** reverse scan order flag, respectively. If the second argument is not NULL,
2884 ** then 0 or 1 is written into the integer that the second argument points to
2885 ** depending on if the reverse scan order flag is set after processing the
2886 ** first argument.
2887 ** </dd>
2888 **
2889 ** [[SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE]]
2890 ** <dt>SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE</dt>
2891 ** <dd>The SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE option enables or disables
2892 ** the ability of the [ATTACH DATABASE] SQL command to create a new database
2893 ** file if the database filed named in the ATTACH command does not already
2894 ** exist. This ability of ATTACH to create a new database is enabled by
2895 ** default. Applications can disable or reenable the ability for ATTACH to
2896 ** create new database files using this DBCONFIG option.<p>
2897 ** This option takes two arguments which are an integer and a pointer
2898 ** to an integer. The first argument is 1, 0, or -1 to enable, disable, or
2899 ** leave unchanged the attach-create flag, respectively. If the second
2900 ** argument is not NULL, then 0 or 1 is written into the integer that the
2901 ** second argument points to depending on if the attach-create flag is set
2902 ** after processing the first argument.
2903 ** </dd>
2904 **
2905 ** [[SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE]]
2906 ** <dt>SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE</dt>
2907 ** <dd>The SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE option enables or disables the
2908 ** ability of the [ATTACH DATABASE] SQL command to open a database for writing.
2909 ** This capability is enabled by default. Applications can disable or
2910 ** reenable this capability using the current DBCONFIG option. If the
2911 ** the this capability is disabled, the [ATTACH] command will still work,
2912 ** but the database will be opened read-only. If this option is disabled,
2913 ** then the ability to create a new database using [ATTACH] is also disabled,
2914 ** regardless of the value of the [SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE]
2915 ** option.<p>
2916 ** This option takes two arguments which are an integer and a pointer
2917 ** to an integer. The first argument is 1, 0, or -1 to enable, disable, or
2918 ** leave unchanged the ability to ATTACH another database for writing,
2919 ** respectively. If the second argument is not NULL, then 0 or 1 is written
2920 ** into the integer to which the second argument points, depending on whether
2921 ** the ability to ATTACH a read/write database is enabled or disabled
2922 ** after processing the first argument.
2923 ** </dd>
2924 **
2925 ** [[SQLITE_DBCONFIG_ENABLE_COMMENTS]]
2926 ** <dt>SQLITE_DBCONFIG_ENABLE_COMMENTS</dt>
2927 ** <dd>The SQLITE_DBCONFIG_ENABLE_COMMENTS option enables or disables the
2928 ** ability to include comments in SQL text. Comments are enabled by default.
2929 ** An application can disable or reenable comments in SQL text using this
2930 ** DBCONFIG option.<p>
2931 ** This option takes two arguments which are an integer and a pointer
2932 ** to an integer. The first argument is 1, 0, or -1 to enable, disable, or
2933 ** leave unchanged the ability to use comments in SQL text,
2934 ** respectively. If the second argument is not NULL, then 0 or 1 is written
2935 ** into the integer that the second argument points to depending on if
2936 ** comments are allowed in SQL text after processing the first argument.
2937 ** </dd>
2938 **
2939 ** </dl>
2940 **
2941 ** [[DBCONFIG arguments]] <h3>Arguments To SQLITE_DBCONFIG Options</h3>
2942 **
2943 ** <p>Most of the SQLITE_DBCONFIG options take two arguments, so that the
2944 ** overall call to [sqlite3_db_config()] has a total of four parameters.
2945 ** The first argument (the third parameter to sqlite3_db_config()) is a integer.
2946 ** The second argument is a pointer to an integer. If the first argument is 1,
2947 ** then the option becomes enabled. If the first integer argument is 0, then the
2948 ** option is disabled. If the first argument is -1, then the option setting
2949 ** is unchanged. The second argument, the pointer to an integer, may be NULL.
2950 ** If the second argument is not NULL, then a value of 0 or 1 is written into
2951 ** the integer to which the second argument points, depending on whether the
2952 ** setting is disabled or enabled after applying any changes specified by
2953 ** the first argument.
2954 **
2955 ** <p>While most SQLITE_DBCONFIG options use the argument format
2956 ** described in the previous paragraph, the [SQLITE_DBCONFIG_MAINDBNAME]
2957 ** and [SQLITE_DBCONFIG_LOOKASIDE] options are different. See the
2958 ** documentation of those exceptional options for details.
2959 */
2960 #define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */
2961 #define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */
2962 #define SQLITE_DBCONFIG_ENABLE_FKEY 1002 /* int int* */
2963 #define SQLITE_DBCONFIG_ENABLE_TRIGGER 1003 /* int int* */
@@ -2862,11 +2975,14 @@
2975 #define SQLITE_DBCONFIG_ENABLE_VIEW 1015 /* int int* */
2976 #define SQLITE_DBCONFIG_LEGACY_FILE_FORMAT 1016 /* int int* */
2977 #define SQLITE_DBCONFIG_TRUSTED_SCHEMA 1017 /* int int* */
2978 #define SQLITE_DBCONFIG_STMT_SCANSTATUS 1018 /* int int* */
2979 #define SQLITE_DBCONFIG_REVERSE_SCANORDER 1019 /* int int* */
2980 #define SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE 1020 /* int int* */
2981 #define SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE 1021 /* int int* */
2982 #define SQLITE_DBCONFIG_ENABLE_COMMENTS 1022 /* int int* */
2983 #define SQLITE_DBCONFIG_MAX 1022 /* Largest DBCONFIG */
2984
2985 /*
2986 ** CAPI3REF: Enable Or Disable Extended Result Codes
2987 ** METHOD: sqlite3
2988 **
@@ -11065,12 +11181,13 @@
11181 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_recover(sqlite3 *db, const char *zDb);
11182
11183 /*
11184 ** CAPI3REF: Serialize a database
11185 **
11186 ** The sqlite3_serialize(D,S,P,F) interface returns a pointer to
11187 ** memory that is a serialization of the S database on
11188 ** [database connection] D. If S is a NULL pointer, the main database is used.
11189 ** If P is not a NULL pointer, then the size of the database in bytes
11190 ** is written into *P.
11191 **
11192 ** For an ordinary on-disk database file, the serialization is just a
11193 ** copy of the disk file. For an in-memory database or a "TEMP" database,
@@ -12232,23 +12349,10 @@
12349 int nB, /* Number of bytes in buffer pB */
12350 void *pB, /* Pointer to buffer containing changeset B */
12351 int *pnOut, /* OUT: Number of bytes in output changeset */
12352 void **ppOut /* OUT: Buffer containing output changeset */
12353 );
 
 
 
 
 
 
 
 
 
 
 
 
 
12354
12355 /*
12356 ** CAPI3REF: Changegroup Handle
12357 **
12358 ** A changegroup is an object used to combine two or more
@@ -14046,13 +14150,17 @@
14150 # define SQLITE_MAX_VDBE_OP 250000000
14151 #endif
14152
14153 /*
14154 ** The maximum number of arguments to an SQL function.
14155 **
14156 ** This value has a hard upper limit of 32767 due to storage
14157 ** constraints (it needs to fit inside a i16). We keep it
14158 ** lower than that to prevent abuse.
14159 */
14160 #ifndef SQLITE_MAX_FUNCTION_ARG
14161 # define SQLITE_MAX_FUNCTION_ARG 1000
14162 #endif
14163
14164 /*
14165 ** The suggested maximum number of in-memory pages to use for
14166 ** the main database table and for temporary tables.
@@ -14648,10 +14756,11 @@
14756 */
14757 struct HashElem {
14758 HashElem *next, *prev; /* Next and previous elements in the table */
14759 void *data; /* Data associated with this element */
14760 const char *pKey; /* Key associated with this element */
14761 unsigned int h; /* hash for pKey */
14762 };
14763
14764 /*
14765 ** Access routines. To delete, insert a NULL pointer.
14766 */
@@ -14871,11 +14980,12 @@
14980 #define TK_ASTERISK 180
14981 #define TK_SPAN 181
14982 #define TK_ERROR 182
14983 #define TK_QNUMBER 183
14984 #define TK_SPACE 184
14985 #define TK_COMMENT 185
14986 #define TK_ILLEGAL 186
14987
14988 /************** End of parse.h ***********************************************/
14989 /************** Continuing where we left off in sqliteInt.h ******************/
14990 #include <stdio.h>
14991 #include <stdlib.h>
@@ -15085,10 +15195,15 @@
15195 typedef UINT16_TYPE u16; /* 2-byte unsigned integer */
15196 typedef INT16_TYPE i16; /* 2-byte signed integer */
15197 typedef UINT8_TYPE u8; /* 1-byte unsigned integer */
15198 typedef INT8_TYPE i8; /* 1-byte signed integer */
15199
15200 /* A bitfield type for use inside of structures. Always follow with :N where
15201 ** N is the number of bits.
15202 */
15203 typedef unsigned bft; /* Bit Field Type */
15204
15205 /*
15206 ** SQLITE_MAX_U32 is a u64 constant that is the maximum u64 value
15207 ** that can be stored in a u32 without loss of data. The value
15208 ** is 0x00000000ffffffff. But because of quirks of some compilers, we
15209 ** have to specify the value in the less intuitive manner shown:
@@ -15123,10 +15238,12 @@
15238 ** Examples:
15239 **
15240 ** 0.5 -> -10 0.1 -> -33 0.0625 -> -40
15241 */
15242 typedef INT16_TYPE LogEst;
15243 #define LOGEST_MIN (-32768)
15244 #define LOGEST_MAX (32767)
15245
15246 /*
15247 ** Set the SQLITE_PTRSIZE macro to the number of bytes in a pointer
15248 */
15249 #ifndef SQLITE_PTRSIZE
@@ -15251,10 +15368,18 @@
15368 */
15369 #define LARGEST_INT64 (0xffffffff|(((i64)0x7fffffff)<<32))
15370 #define LARGEST_UINT64 (0xffffffff|(((u64)0xffffffff)<<32))
15371 #define SMALLEST_INT64 (((i64)-1) - LARGEST_INT64)
15372
15373 /*
15374 ** Macro SMXV(n) return the maximum value that can be held in variable n,
15375 ** assuming n is a signed integer type. UMXV(n) is similar for unsigned
15376 ** integer types.
15377 */
15378 #define SMXV(n) ((((i64)1)<<(sizeof(n)-1))-1)
15379 #define UMXV(n) ((((i64)1)<<(sizeof(n)))-1)
15380
15381 /*
15382 ** Round up a number to the next larger multiple of 8. This is used
15383 ** to force 8-byte alignment on 64-bit architectures.
15384 **
15385 ** ROUND8() always does the rounding, for any argument.
@@ -15393,11 +15518,11 @@
15518 ** 0x-------F High-level debug messages
15519 ** 0x----FFF- More detail
15520 ** 0xFFFF---- Low-level debug messages
15521 **
15522 ** 0x00000001 Code generation
15523 ** 0x00000002 Solver (Use 0x40000 for less detail)
15524 ** 0x00000004 Solver costs
15525 ** 0x00000008 WhereLoop inserts
15526 **
15527 ** 0x00000010 Display sqlite3_index_info xBestIndex calls
15528 ** 0x00000020 Range an equality scan metrics
@@ -15412,10 +15537,12 @@
15537 ** 0x00004000 Show all WHERE terms at key points
15538 ** 0x00008000 Show the full SELECT statement at key places
15539 **
15540 ** 0x00010000 Show more detail when printing WHERE terms
15541 ** 0x00020000 Show WHERE terms returned from whereScanNext()
15542 ** 0x00040000 Solver overview messages
15543 ** 0x00080000 Star-query heuristic
15544 */
15545
15546
15547 /*
15548 ** An instance of the following structure is used to store the busy-handler
@@ -16049,10 +16176,26 @@
16176 #define PAGER_JOURNALMODE_PERSIST 1 /* Commit by zeroing journal header */
16177 #define PAGER_JOURNALMODE_OFF 2 /* Journal omitted. */
16178 #define PAGER_JOURNALMODE_TRUNCATE 3 /* Commit by truncating journal */
16179 #define PAGER_JOURNALMODE_MEMORY 4 /* In-memory journal file */
16180 #define PAGER_JOURNALMODE_WAL 5 /* Use write-ahead logging */
16181
16182 #define isWalMode(x) ((x)==PAGER_JOURNALMODE_WAL)
16183
16184 /*
16185 ** The argument to this macro is a file descriptor (type sqlite3_file*).
16186 ** Return 0 if it is not open, or non-zero (but not 1) if it is.
16187 **
16188 ** This is so that expressions can be written as:
16189 **
16190 ** if( isOpen(pPager->jfd) ){ ...
16191 **
16192 ** instead of
16193 **
16194 ** if( pPager->jfd->pMethods ){ ...
16195 */
16196 #define isOpen(pFd) ((pFd)->pMethods!=0)
16197
16198 /*
16199 ** Flags that make up the mask passed to sqlite3PagerGet().
16200 */
16201 #define PAGER_GET_NOCONTENT 0x01 /* Do not load data from disk */
@@ -16688,10 +16831,11 @@
16831 ** A signature for a reusable subroutine that materializes the RHS of
16832 ** an IN operator.
16833 */
16834 struct SubrtnSig {
16835 int selId; /* SELECT-id for the SELECT statement on the RHS */
16836 u8 bComplete; /* True if fully coded and available for reusable */
16837 char *zAff; /* Affinity of the overall IN expression */
16838 int iTable; /* Ephemeral table generated by the subroutine */
16839 int iAddr; /* Subroutine entry address */
16840 int regReturn; /* Register used to hold return address */
16841 };
@@ -18018,10 +18162,13 @@
18162 /* DELETE, or UPDATE and return */
18163 /* the count using a callback. */
18164 #define SQLITE_CorruptRdOnly HI(0x00002) /* Prohibit writes due to error */
18165 #define SQLITE_ReadUncommit HI(0x00004) /* READ UNCOMMITTED in shared-cache */
18166 #define SQLITE_FkNoAction HI(0x00008) /* Treat all FK as NO ACTION */
18167 #define SQLITE_AttachCreate HI(0x00010) /* ATTACH allowed to create new dbs */
18168 #define SQLITE_AttachWrite HI(0x00020) /* ATTACH allowed to open for write */
18169 #define SQLITE_Comments HI(0x00040) /* Enable SQL comments */
18170
18171 /* Flags used only if debugging */
18172 #ifdef SQLITE_DEBUG
18173 #define SQLITE_SqlTrace HI(0x0100000) /* Debug print SQL as it executes */
18174 #define SQLITE_VdbeListing HI(0x0200000) /* Debug listings of VDBE progs */
@@ -18077,10 +18224,11 @@
18224 #define SQLITE_IndexedExpr 0x01000000 /* Pull exprs from index when able */
18225 #define SQLITE_Coroutines 0x02000000 /* Co-routines for subqueries */
18226 #define SQLITE_NullUnusedCols 0x04000000 /* NULL unused columns in subqueries */
18227 #define SQLITE_OnePass 0x08000000 /* Single-pass DELETE and UPDATE */
18228 #define SQLITE_OrderBySubq 0x10000000 /* ORDER BY in subquery helps outer */
18229 #define SQLITE_StarQuery 0x20000000 /* Heurists for star queries */
18230 #define SQLITE_AllOpts 0xffffffff /* All optimizations */
18231
18232 /*
18233 ** Macros for testing whether or not optimizations are enabled or disabled.
18234 */
@@ -18113,11 +18261,11 @@
18261 **
18262 ** The u.pHash field is used by the global built-ins. The u.pDestructor
18263 ** field is used by per-connection app-def functions.
18264 */
18265 struct FuncDef {
18266 i16 nArg; /* Number of arguments. -1 means unlimited */
18267 u32 funcFlags; /* Some combination of SQLITE_FUNC_* */
18268 void *pUserData; /* User data parameter */
18269 FuncDef *pNext; /* Next function with same name */
18270 void (*xSFunc)(sqlite3_context*,int,sqlite3_value**); /* func or agg-step */
18271 void (*xFinalize)(sqlite3_context*); /* Agg finalizer */
@@ -18606,10 +18754,11 @@
18754 VTable *p; /* List of VTable objects. */
18755 } vtab;
18756 } u;
18757 Trigger *pTrigger; /* List of triggers on this object */
18758 Schema *pSchema; /* Schema that contains this table */
18759 u8 aHx[16]; /* Column aHt[K%sizeof(aHt)] might have hash K */
18760 };
18761
18762 /*
18763 ** Allowed values for Table.tabFlags.
18764 **
@@ -19406,17 +19555,12 @@
19555 **
19556 ** If "a" is the k-th column of table "t", then IdList.a[0].idx==k.
19557 */
19558 struct IdList {
19559 int nId; /* Number of identifiers on the list */
 
19560 struct IdList_item {
19561 char *zName; /* Name of the identifier */
 
 
 
 
19562 } a[1];
19563 };
19564
19565 /*
19566 ** Allowed values for IdList.eType, which determines which value of the a.u4
@@ -20008,29 +20152,36 @@
20152 struct Parse {
20153 sqlite3 *db; /* The main database structure */
20154 char *zErrMsg; /* An error message */
20155 Vdbe *pVdbe; /* An engine for executing database bytecode */
20156 int rc; /* Return code from execution */
20157 LogEst nQueryLoop; /* Est number of iterations of a query (10*log2(N)) */
 
20158 u8 nested; /* Number of nested calls to the parser/code generator */
20159 u8 nTempReg; /* Number of temporary registers in aTempReg[] */
20160 u8 isMultiWrite; /* True if statement may modify/insert multiple rows */
20161 u8 mayAbort; /* True if statement may throw an ABORT exception */
20162 u8 hasCompound; /* Need to invoke convertCompoundSelectToSubquery() */
 
20163 u8 disableLookaside; /* Number of times lookaside has been disabled */
20164 u8 prepFlags; /* SQLITE_PREPARE_* flags */
20165 u8 withinRJSubrtn; /* Nesting level for RIGHT JOIN body subroutines */
 
20166 u8 mSubrtnSig; /* mini Bloom filter on available SubrtnSig.selId */
20167 u8 eTriggerOp; /* TK_UPDATE, TK_INSERT or TK_DELETE */
20168 u8 bReturning; /* Coding a RETURNING trigger */
20169 u8 eOrconf; /* Default ON CONFLICT policy for trigger steps */
20170 u8 disableTriggers; /* True to disable triggers */
20171 #if defined(SQLITE_DEBUG) || defined(SQLITE_COVERAGE_TEST)
20172 u8 earlyCleanup; /* OOM inside sqlite3ParserAddCleanup() */
20173 #endif
20174 #ifdef SQLITE_DEBUG
20175 u8 ifNotExists; /* Might be true if IF NOT EXISTS. Assert()s only */
20176 u8 isCreate; /* CREATE TABLE, INDEX, or VIEW (but not TRIGGER)
20177 ** and ALTER TABLE ADD COLUMN. */
20178 #endif
20179 bft colNamesSet :1; /* TRUE after OP_ColumnName has been issued to pVdbe */
20180 bft bHasWith :1; /* True if statement contains WITH */
20181 bft okConstFactor :1; /* OK to factor out constants */
20182 bft checkSchema :1; /* Causes schema cookie check after an error */
20183 int nRangeReg; /* Size of the temporary register block */
20184 int iRangeReg; /* First register in temporary register block */
20185 int nErr; /* Number of errors seen */
20186 int nTab; /* Number of previously allocated VDBE cursors */
20187 int nMem; /* Number of memory cells used so far */
@@ -20041,16 +20192,13 @@
20192 int nLabelAlloc; /* Number of slots in aLabel */
20193 int *aLabel; /* Space to hold the labels */
20194 ExprList *pConstExpr;/* Constant expressions */
20195 IndexedExpr *pIdxEpr;/* List of expressions used by active indexes */
20196 IndexedExpr *pIdxPartExpr; /* Exprs constrained by index WHERE clauses */
 
20197 yDbMask writeMask; /* Start a write transaction on these databases */
20198 yDbMask cookieMask; /* Bitmask of schema verified databases */
20199 int nMaxArg; /* Max args to xUpdate and xFilter vtab methods */
 
 
20200 int nSelect; /* Number of SELECT stmts. Counter for Select.selId */
20201 #ifndef SQLITE_OMIT_PROGRESS_CALLBACK
20202 u32 nProgressSteps; /* xProgress steps taken during sqlite3_prepare() */
20203 #endif
20204 #ifndef SQLITE_OMIT_SHARED_CACHE
@@ -20060,21 +20208,10 @@
20208 AutoincInfo *pAinc; /* Information about AUTOINCREMENT counters */
20209 Parse *pToplevel; /* Parse structure for main program (or NULL) */
20210 Table *pTriggerTab; /* Table triggers are being coded for */
20211 TriggerPrg *pTriggerPrg; /* Linked list of coded triggers */
20212 ParseCleanup *pCleanup; /* List of cleanup operations to run after parse */
 
 
 
 
 
 
 
 
 
 
 
20213
20214 /**************************************************************************
20215 ** Fields above must be initialized to zero. The fields that follow,
20216 ** down to the beginning of the recursive section, do not need to be
20217 ** initialized as they will be set before being used. The boundary is
@@ -20082,10 +20219,23 @@
20219 **************************************************************************/
20220
20221 int aTempReg[8]; /* Holding area for temporary registers */
20222 Parse *pOuterParse; /* Outer Parse object when nested */
20223 Token sNameToken; /* Token with unqualified schema object name */
20224 u32 oldmask; /* Mask of old.* columns referenced */
20225 u32 newmask; /* Mask of new.* columns referenced */
20226 union {
20227 struct { /* These fields available when isCreate is true */
20228 int addrCrTab; /* Address of OP_CreateBtree on CREATE TABLE */
20229 int regRowid; /* Register holding rowid of CREATE TABLE entry */
20230 int regRoot; /* Register holding root page for new objects */
20231 Token constraintName; /* Name of the constraint currently being parsed */
20232 } cr;
20233 struct { /* These fields available to all other statements */
20234 Returning *pReturning; /* The RETURNING clause */
20235 } d;
20236 } u1;
20237
20238 /************************************************************************
20239 ** Above is constant between recursions. Below is reset before and after
20240 ** each recursion. The boundary between these two regions is determined
20241 ** using offsetof(Parse,sLastToken) so the sLastToken field must be the
@@ -20099,13 +20249,11 @@
20249 u8 eParseMode; /* PARSE_MODE_XXX constant */
20250 #ifndef SQLITE_OMIT_VIRTUALTABLE
20251 int nVtabLock; /* Number of virtual tables to lock */
20252 #endif
20253 int nHeight; /* Expression tree height of current sub-select */
 
20254 int addrExplain; /* Address of current OP_Explain opcode */
 
20255 VList *pVList; /* Mapping between variable names and numbers */
20256 Vdbe *pReprepare; /* VM being reprepared (sqlite3Reprepare()) */
20257 const char *zTail; /* All SQL text past the last semicolon parsed */
20258 Table *pNewTable; /* A table being constructed by CREATE TABLE */
20259 Index *pNewIndex; /* An index being constructed by CREATE INDEX.
@@ -23559,10 +23707,11 @@
23707 char *zMalloc; /* Space to hold MEM_Str or MEM_Blob if szMalloc>0 */
23708 void (*xDel)(void*);/* Destructor for Mem.z - only valid if MEM_Dyn */
23709 #ifdef SQLITE_DEBUG
23710 Mem *pScopyFrom; /* This Mem is a shallow copy of pScopyFrom */
23711 u16 mScopyFlags; /* flags value immediately after the shallow copy */
23712 u8 bScopy; /* The pScopyFrom of some other Mem *might* point here */
23713 #endif
23714 };
23715
23716 /*
23717 ** Size of struct Mem not including the Mem.zMalloc member or anything that
@@ -23708,18 +23857,14 @@
23857 Vdbe *pVdbe; /* The VM that owns this context */
23858 int iOp; /* Instruction number of OP_Function */
23859 int isError; /* Error code returned by the function. */
23860 u8 enc; /* Encoding to use for results */
23861 u8 skipFlag; /* Skip accumulator loading if true */
23862 u16 argc; /* Number of arguments */
23863 sqlite3_value *argv[1]; /* Argument set */
23864 };
23865
 
 
 
 
23866
23867 /* The ScanStatus object holds a single value for the
23868 ** sqlite3_stmt_scanstatus() interface.
23869 **
23870 ** aAddrRange[]:
@@ -23776,11 +23921,11 @@
23921 i64 iCurrentTime; /* Value of julianday('now') for this statement */
23922 i64 nFkConstraint; /* Number of imm. FK constraints this VM */
23923 i64 nStmtDefCons; /* Number of def. constraints when stmt started */
23924 i64 nStmtDefImmCons; /* Number of def. imm constraints when stmt started */
23925 Mem *aMem; /* The memory locations */
23926 Mem **apArg; /* Arguments xUpdate and xFilter vtab methods */
23927 VdbeCursor **apCsr; /* One element of this array for each open cursor */
23928 Mem *aVar; /* Values for the OP_Variable opcode. */
23929
23930 /* When allocating a new Vdbe object, all of the fields below should be
23931 ** initialized to zero or NULL */
@@ -23796,10 +23941,11 @@
23941 i64 startTime; /* Time when query started - used for profiling */
23942 #endif
23943 #ifdef SQLITE_DEBUG
23944 int rcApp; /* errcode set by sqlite3_result_error_code() */
23945 u32 nWrite; /* Number of write operations that have occurred */
23946 int napArg; /* Size of the apArg[] array */
23947 #endif
23948 u16 nResColumn; /* Number of columns in one row of the result set */
23949 u16 nResAlloc; /* Column slots allocated to aColName[] */
23950 u8 errorAction; /* Recovery action to do in case of an error */
23951 u8 minWriteFileFormat; /* Minimum file format for writable database files */
@@ -24657,10 +24803,13 @@
24803 ms = ms*10.0 + *zDate - '0';
24804 rScale *= 10.0;
24805 zDate++;
24806 }
24807 ms /= rScale;
24808 /* Truncate to avoid problems with sub-milliseconds
24809 ** rounding. https://sqlite.org/forum/forumpost/766a2c9231 */
24810 if( ms>0.999 ) ms = 0.999;
24811 }
24812 }else{
24813 s = 0;
24814 }
24815 p->validJD = 0;
@@ -25864,11 +26013,11 @@
26013 sqlite3_str_appendf(&sRes, cf=='d' ? "%02d" : "%2d", x.D);
26014 break;
26015 }
26016 case 'f': { /* Fractional seconds. (Non-standard) */
26017 double s = x.s;
26018 if( NEVER(s>59.999) ) s = 59.999;
26019 sqlite3_str_appendf(&sRes, "%06.3f", s);
26020 break;
26021 }
26022 case 'F': {
26023 sqlite3_str_appendf(&sRes, "%04d-%02d-%02d", x.Y, x.M, x.D);
@@ -32424,11 +32573,11 @@
32573 ** pointer if any kind of error was encountered.
32574 */
32575 static SQLITE_NOINLINE char *strAccumFinishRealloc(StrAccum *p){
32576 char *zText;
32577 assert( p->mxAlloc>0 && !isMalloced(p) );
32578 zText = sqlite3DbMallocRaw(p->db, 1+(u64)p->nChar );
32579 if( zText ){
32580 memcpy(zText, p->zText, p->nChar+1);
32581 p->printfFlags |= SQLITE_PRINTF_MALLOCED;
32582 }else{
32583 sqlite3StrAccumSetError(p, SQLITE_NOMEM);
@@ -33032,11 +33181,14 @@
33181 }
33182 if( pItem->fg.fromDDL ){
33183 sqlite3_str_appendf(&x, " DDL");
33184 }
33185 if( pItem->fg.isCte ){
33186 static const char *aMat[] = {",MAT", "", ",NO-MAT"};
33187 sqlite3_str_appendf(&x, " CteUse=%d%s",
33188 pItem->u2.pCteUse->nUse,
33189 aMat[pItem->u2.pCteUse->eM10d]);
33190 }
33191 if( pItem->fg.isOn || (pItem->fg.isUsing==0 && pItem->u3.pOn!=0) ){
33192 sqlite3_str_appendf(&x, " isOn");
33193 }
33194 if( pItem->fg.isTabFunc ) sqlite3_str_appendf(&x, " isTabFunc");
@@ -33063,13 +33215,10 @@
33215 if( pItem->pSTab ){
33216 Table *pTab = pItem->pSTab;
33217 sqlite3TreeViewColumnList(pView, pTab->aCol, pTab->nCol, 1);
33218 }
33219 assert( (int)pItem->fg.isNestedFrom == IsNestedFrom(pItem) );
 
 
 
33220 sqlite3TreeViewSelect(pView, pItem->u4.pSubq->pSelect, 0);
33221 }
33222 if( pItem->fg.isTabFunc ){
33223 sqlite3TreeViewExprList(pView, pItem->u1.pFuncArg, 0, "func-args:");
33224 }
@@ -33795,25 +33944,11 @@
33944 char *zName = pList->a[i].zName;
33945 int moreToFollow = i<pList->nId - 1;
33946 if( zName==0 ) zName = "(null)";
33947 sqlite3TreeViewPush(&pView, moreToFollow);
33948 sqlite3TreeViewLine(pView, 0);
33949 fprintf(stdout, "%s\n", zName);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33950 sqlite3TreeViewPop(&pView);
33951 }
33952 }
33953 }
33954 SQLITE_PRIVATE void sqlite3TreeViewIdList(
@@ -36290,11 +36425,15 @@
36425 }
36426 }
36427 }
36428 p->z = &p->zBuf[i+1];
36429 assert( i+p->n < sizeof(p->zBuf) );
36430 assert( p->n>0 );
36431 while( p->z[p->n-1]=='0' ){
36432 p->n--;
36433 assert( p->n>0 );
36434 }
36435 }
36436
36437 /*
36438 ** Try to convert z into an unsigned 32-bit integer. Return true on
36439 ** success and false if there is an error.
@@ -37076,16 +37215,23 @@
37215 /*
37216 ** The hashing function.
37217 */
37218 static unsigned int strHash(const char *z){
37219 unsigned int h = 0;
37220 while( z[0] ){ /*OPTIMIZATION-IF-TRUE*/
 
37221 /* Knuth multiplicative hashing. (Sorting & Searching, p. 510).
37222 ** 0x9e3779b1 is 2654435761 which is the closest prime number to
37223 ** (2**32)*golden_ratio, where golden_ratio = (sqrt(5) - 1)/2.
37224 **
37225 ** Only bits 0xdf for ASCII and bits 0xbf for EBCDIC each octet are
37226 ** hashed since the omitted bits determine the upper/lower case difference.
37227 */
37228 #ifdef SQLITE_EBCDIC
37229 h += 0xbf & (unsigned char)*(z++);
37230 #else
37231 h += 0xdf & (unsigned char)*(z++);
37232 #endif
37233 h *= 0x9e3779b1;
37234 }
37235 return h;
37236 }
37237
@@ -37154,13 +37300,12 @@
37300 sqlite3_free(pH->ht);
37301 pH->ht = new_ht;
37302 pH->htsize = new_size = sqlite3MallocSize(new_ht)/sizeof(struct _ht);
37303 memset(new_ht, 0, new_size*sizeof(struct _ht));
37304 for(elem=pH->first, pH->first=0; elem; elem = next_elem){
 
37305 next_elem = elem->next;
37306 insertElement(pH, &new_ht[elem->h % new_size], elem);
37307 }
37308 return 1;
37309 }
37310
37311 /* This function (for internal use only) locates an element in an
@@ -37174,27 +37319,26 @@
37319 unsigned int *pHash /* Write the hash value here */
37320 ){
37321 HashElem *elem; /* Used to loop thru the element list */
37322 unsigned int count; /* Number of elements left to test */
37323 unsigned int h; /* The computed hash */
37324 static HashElem nullElement = { 0, 0, 0, 0, 0 };
37325
37326 h = strHash(pKey);
37327 if( pH->ht ){ /*OPTIMIZATION-IF-TRUE*/
37328 struct _ht *pEntry;
37329 pEntry = &pH->ht[h % pH->htsize];
 
37330 elem = pEntry->chain;
37331 count = pEntry->count;
37332 }else{
 
37333 elem = pH->first;
37334 count = pH->count;
37335 }
37336 if( pHash ) *pHash = h;
37337 while( count ){
37338 assert( elem!=0 );
37339 if( h==elem->h && sqlite3StrICmp(elem->pKey,pKey)==0 ){
37340 return elem;
37341 }
37342 elem = elem->next;
37343 count--;
37344 }
@@ -37202,14 +37346,13 @@
37346 }
37347
37348 /* Remove a single entry from the hash table given a pointer to that
37349 ** element and a hash on the element's key.
37350 */
37351 static void removeElement(
37352 Hash *pH, /* The pH containing "elem" */
37353 HashElem *elem /* The element to be removed from the pH */
 
37354 ){
37355 struct _ht *pEntry;
37356 if( elem->prev ){
37357 elem->prev->next = elem->next;
37358 }else{
@@ -37217,11 +37360,11 @@
37360 }
37361 if( elem->next ){
37362 elem->next->prev = elem->prev;
37363 }
37364 if( pH->ht ){
37365 pEntry = &pH->ht[elem->h % pH->htsize];
37366 if( pEntry->chain==elem ){
37367 pEntry->chain = elem->next;
37368 }
37369 assert( pEntry->count>0 );
37370 pEntry->count--;
@@ -37268,11 +37411,11 @@
37411 assert( pKey!=0 );
37412 elem = findElementWithHash(pH,pKey,&h);
37413 if( elem->data ){
37414 void *old_data = elem->data;
37415 if( data==0 ){
37416 removeElement(pH,elem);
37417 }else{
37418 elem->data = data;
37419 elem->pKey = pKey;
37420 }
37421 return old_data;
@@ -37279,19 +37422,17 @@
37422 }
37423 if( data==0 ) return 0;
37424 new_elem = (HashElem*)sqlite3Malloc( sizeof(HashElem) );
37425 if( new_elem==0 ) return data;
37426 new_elem->pKey = pKey;
37427 new_elem->h = h;
37428 new_elem->data = data;
37429 pH->count++;
37430 if( pH->count>=5 && pH->count > 2*pH->htsize ){
37431 rehash(pH, pH->count*3);
 
 
 
37432 }
37433 insertElement(pH, pH->ht ? &pH->ht[new_elem->h % pH->htsize] : 0, new_elem);
37434 return 0;
37435 }
37436
37437 /************** End of hash.c ************************************************/
37438 /************** Begin file opcodes.c *****************************************/
@@ -40150,11 +40291,11 @@
40291 assert( pInode!=0 );
40292 assert( sqlite3_mutex_held(pInode->pLockMutex) );
40293 if( (pFile->ctrlFlags & (UNIXFILE_EXCL|UNIXFILE_RDONLY))==UNIXFILE_EXCL ){
40294 if( pInode->bProcessLock==0 ){
40295 struct flock lock;
40296 /* assert( pInode->nLock==0 ); <-- Not true if unix-excl READONLY used */
40297 lock.l_whence = SEEK_SET;
40298 lock.l_start = SHARED_FIRST;
40299 lock.l_len = SHARED_SIZE;
40300 lock.l_type = F_WRLCK;
40301 rc = osSetPosixAdvisoryLock(pFile->h, &lock, pFile);
@@ -50698,11 +50839,11 @@
50839 ** allocate space for a new winShmNode and filename.
50840 */
50841 p = sqlite3MallocZero( sizeof(*p) );
50842 if( p==0 ) return SQLITE_IOERR_NOMEM_BKPT;
50843 nName = sqlite3Strlen30(pDbFd->zPath);
50844 pNew = sqlite3MallocZero( sizeof(*pShmNode) + (i64)nName + 17 );
50845 if( pNew==0 ){
50846 sqlite3_free(p);
50847 return SQLITE_IOERR_NOMEM_BKPT;
50848 }
50849 pNew->zFilename = (char*)&pNew[1];
@@ -51519,11 +51660,11 @@
51660 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
51661 "0123456789";
51662 size_t i, j;
51663 DWORD pid;
51664 int nPre = sqlite3Strlen30(SQLITE_TEMP_FILE_PREFIX);
51665 i64 nMax, nBuf, nDir, nLen;
51666 char *zBuf;
51667
51668 /* It's odd to simulate an io-error here, but really this is just
51669 ** using the io-error infrastructure to test that SQLite handles this
51670 ** function failing.
@@ -51531,11 +51672,12 @@
51672 SimulateIOError( return SQLITE_IOERR );
51673
51674 /* Allocate a temporary buffer to store the fully qualified file
51675 ** name for the temporary file. If this fails, we cannot continue.
51676 */
51677 nMax = pVfs->mxPathname;
51678 nBuf = 2 + (i64)nMax;
51679 zBuf = sqlite3MallocZero( nBuf );
51680 if( !zBuf ){
51681 OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
51682 return SQLITE_IOERR_NOMEM_BKPT;
51683 }
@@ -52390,11 +52532,11 @@
52532 ** NOTE: We are dealing with a relative path name and the data
52533 ** directory has been set. Therefore, use it as the basis
52534 ** for converting the relative path name to an absolute
52535 ** one by prepending the data directory and a slash.
52536 */
52537 char *zOut = sqlite3MallocZero( 1+(u64)pVfs->mxPathname );
52538 if( !zOut ){
52539 return SQLITE_IOERR_NOMEM_BKPT;
52540 }
52541 if( cygwin_conv_path(
52542 (osIsNT() ? CCP_POSIX_TO_WIN_W : CCP_POSIX_TO_WIN_A) |
@@ -52485,17 +52627,16 @@
52627 if( nByte==0 ){
52628 sqlite3_free(zConverted);
52629 return winLogError(SQLITE_CANTOPEN_FULLPATH, osGetLastError(),
52630 "winFullPathname1", zRelative);
52631 }
52632 zTemp = sqlite3MallocZero( nByte*sizeof(zTemp[0]) + 3*sizeof(zTemp[0]) );
 
52633 if( zTemp==0 ){
52634 sqlite3_free(zConverted);
52635 return SQLITE_IOERR_NOMEM_BKPT;
52636 }
52637 nByte = osGetFullPathNameW((LPCWSTR)zConverted, nByte+3, zTemp, 0);
52638 if( nByte==0 ){
52639 sqlite3_free(zConverted);
52640 sqlite3_free(zTemp);
52641 return winLogError(SQLITE_CANTOPEN_FULLPATH, osGetLastError(),
52642 "winFullPathname2", zRelative);
@@ -52511,17 +52652,16 @@
52652 if( nByte==0 ){
52653 sqlite3_free(zConverted);
52654 return winLogError(SQLITE_CANTOPEN_FULLPATH, osGetLastError(),
52655 "winFullPathname3", zRelative);
52656 }
52657 zTemp = sqlite3MallocZero( nByte*sizeof(zTemp[0]) + 3*sizeof(zTemp[0]) );
 
52658 if( zTemp==0 ){
52659 sqlite3_free(zConverted);
52660 return SQLITE_IOERR_NOMEM_BKPT;
52661 }
52662 nByte = osGetFullPathNameA((char*)zConverted, nByte+3, zTemp, 0);
52663 if( nByte==0 ){
52664 sqlite3_free(zConverted);
52665 sqlite3_free(zTemp);
52666 return winLogError(SQLITE_CANTOPEN_FULLPATH, osGetLastError(),
52667 "winFullPathname4", zRelative);
@@ -53546,17 +53686,17 @@
53686 break;
53687 }
53688 }
53689 if( p==0 ){
53690 MemStore **apNew;
53691 p = sqlite3Malloc( sizeof(*p) + (i64)szName + 3 );
53692 if( p==0 ){
53693 sqlite3_mutex_leave(pVfsMutex);
53694 return SQLITE_NOMEM;
53695 }
53696 apNew = sqlite3Realloc(memdb_g.apMemStore,
53697 sizeof(apNew[0])*(1+(i64)memdb_g.nMemStore) );
53698 if( apNew==0 ){
53699 sqlite3_free(p);
53700 sqlite3_mutex_leave(pVfsMutex);
53701 return SQLITE_NOMEM;
53702 }
@@ -54262,11 +54402,11 @@
54402 void *pTmpSpace;
54403
54404 /* Allocate the Bitvec to be tested and a linear array of
54405 ** bits to act as the reference */
54406 pBitvec = sqlite3BitvecCreate( sz );
54407 pV = sqlite3MallocZero( (7+(i64)sz)/8 + 1 );
54408 pTmpSpace = sqlite3_malloc64(BITVEC_SZ);
54409 if( pBitvec==0 || pV==0 || pTmpSpace==0 ) goto bitvec_end;
54410
54411 /* NULL pBitvec tests */
54412 sqlite3BitvecSet(0, 1);
@@ -55809,16 +55949,16 @@
55949 **
55950 ** The PCache mutex must be held when this function is called.
55951 */
55952 static void pcache1ResizeHash(PCache1 *p){
55953 PgHdr1 **apNew;
55954 u64 nNew;
55955 u32 i;
55956
55957 assert( sqlite3_mutex_held(p->pGroup->mutex) );
55958
55959 nNew = 2*(u64)p->nHash;
55960 if( nNew<256 ){
55961 nNew = 256;
55962 }
55963
55964 pcache1LeaveMutex(p->pGroup);
@@ -56037,11 +56177,11 @@
56177 ** Allocate a new cache.
56178 */
56179 static sqlite3_pcache *pcache1Create(int szPage, int szExtra, int bPurgeable){
56180 PCache1 *pCache; /* The newly created page cache */
56181 PGroup *pGroup; /* The group the new page cache will belong to */
56182 i64 sz; /* Bytes of memory required to allocate the new cache */
56183
56184 assert( (szPage & (szPage-1))==0 && szPage>=512 && szPage<=65536 );
56185 assert( szExtra < 300 );
56186
56187 sz = sizeof(PCache1) + sizeof(PGroup)*pcache1.separateCache;
@@ -58014,24 +58154,10 @@
58154 # define USEFETCH(x) ((x)->bUseFetch)
58155 #else
58156 # define USEFETCH(x) 0
58157 #endif
58158
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58159 #ifdef SQLITE_DIRECT_OVERFLOW_READ
58160 /*
58161 ** Return true if page pgno can be read directly from the database file
58162 ** by the b-tree layer. This is the case if:
58163 **
@@ -58047,11 +58173,11 @@
58173 if( sqlite3PCacheIsDirty(pPager->pPCache) ) return 0; /* Failed (3) */
58174 #ifndef SQLITE_OMIT_WAL
58175 if( pPager->pWal ){
58176 u32 iRead = 0;
58177 (void)sqlite3WalFindFrame(pPager->pWal, pgno, &iRead);
58178 if( iRead ) return 0; /* Case (4) */
58179 }
58180 #endif
58181 assert( pPager->fd->pMethods->xDeviceCharacteristics!=0 );
58182 if( (pPager->fd->pMethods->xDeviceCharacteristics(pPager->fd)
58183 & SQLITE_IOCAP_SUBPAGE_READ)==0 ){
@@ -58530,11 +58656,11 @@
58656 ** zSuper[0] is set to 0 and SQLITE_OK returned.
58657 **
58658 ** If an error occurs while reading from the journal file, an SQLite
58659 ** error code is returned.
58660 */
58661 static int readSuperJournal(sqlite3_file *pJrnl, char *zSuper, u64 nSuper){
58662 int rc; /* Return code */
58663 u32 len; /* Length in bytes of super-journal name */
58664 i64 szJ; /* Total size in bytes of journal file pJrnl */
58665 u32 cksum; /* MJ checksum value read from journal */
58666 u32 u; /* Unsigned loop counter */
@@ -59313,11 +59439,11 @@
59439 rc = sqlite3OsSync(pPager->jfd, pPager->syncFlags);
59440 }
59441 }
59442 pPager->journalOff = 0;
59443 }else if( pPager->journalMode==PAGER_JOURNALMODE_PERSIST
59444 || (pPager->exclusiveMode && pPager->journalMode<PAGER_JOURNALMODE_WAL)
59445 ){
59446 rc = zeroJournalHdr(pPager, hasSuper||pPager->tempFile);
59447 pPager->journalOff = 0;
59448 }else{
59449 /* This branch may be executed with Pager.journalMode==MEMORY if
@@ -59766,16 +59892,16 @@
59892 char *zSuperJournal = 0; /* Contents of super-journal file */
59893 i64 nSuperJournal; /* Size of super-journal file */
59894 char *zJournal; /* Pointer to one journal within MJ file */
59895 char *zSuperPtr; /* Space to hold super-journal filename */
59896 char *zFree = 0; /* Free this buffer */
59897 i64 nSuperPtr; /* Amount of space allocated to zSuperPtr[] */
59898
59899 /* Allocate space for both the pJournal and pSuper file descriptors.
59900 ** If successful, open the super-journal file for reading.
59901 */
59902 pSuper = (sqlite3_file *)sqlite3MallocZero(2 * (i64)pVfs->szOsFile);
59903 if( !pSuper ){
59904 rc = SQLITE_NOMEM_BKPT;
59905 pJournal = 0;
59906 }else{
59907 const int flags = (SQLITE_OPEN_READONLY|SQLITE_OPEN_SUPER_JOURNAL);
@@ -59789,15 +59915,18 @@
59915 ** sufficient space (in zSuperPtr) to hold the names of super-journal
59916 ** files extracted from regular rollback-journals.
59917 */
59918 rc = sqlite3OsFileSize(pSuper, &nSuperJournal);
59919 if( rc!=SQLITE_OK ) goto delsuper_out;
59920 nSuperPtr = 1 + (i64)pVfs->mxPathname;
59921 assert( nSuperJournal>=0 && nSuperPtr>0 );
59922 zFree = sqlite3Malloc(4 + nSuperJournal + nSuperPtr + 2);
59923 if( !zFree ){
59924 rc = SQLITE_NOMEM_BKPT;
59925 goto delsuper_out;
59926 }else{
59927 assert( nSuperJournal<=0x7fffffff );
59928 }
59929 zFree[0] = zFree[1] = zFree[2] = zFree[3] = 0;
59930 zSuperJournal = &zFree[4];
59931 zSuperPtr = &zSuperJournal[nSuperJournal+2];
59932 rc = sqlite3OsRead(pSuper, zSuperJournal, (int)nSuperJournal, 0);
@@ -60054,11 +60183,11 @@
60183 ** (pPager->pageSize >= pPager->pVfs->mxPathname+1). Using os_unix.c,
60184 ** mxPathname is 512, which is the same as the minimum allowable value
60185 ** for pageSize.
60186 */
60187 zSuper = pPager->pTmpSpace;
60188 rc = readSuperJournal(pPager->jfd, zSuper, 1+(i64)pPager->pVfs->mxPathname);
60189 if( rc==SQLITE_OK && zSuper[0] ){
60190 rc = sqlite3OsAccess(pVfs, zSuper, SQLITE_ACCESS_EXISTS, &res);
60191 }
60192 zSuper = 0;
60193 if( rc!=SQLITE_OK || !res ){
@@ -60193,11 +60322,11 @@
60322 /* Leave 4 bytes of space before the super-journal filename in memory.
60323 ** This is because it may end up being passed to sqlite3OsOpen(), in
60324 ** which case it requires 4 0x00 bytes in memory immediately before
60325 ** the filename. */
60326 zSuper = &pPager->pTmpSpace[4];
60327 rc = readSuperJournal(pPager->jfd, zSuper, 1+(i64)pPager->pVfs->mxPathname);
60328 testcase( rc!=SQLITE_OK );
60329 }
60330 if( rc==SQLITE_OK
60331 && (pPager->eState>=PAGER_WRITER_DBMOD || pPager->eState==PAGER_OPEN)
60332 ){
@@ -61963,10 +62092,11 @@
62092 int useJournal = (flags & PAGER_OMIT_JOURNAL)==0; /* False to omit journal */
62093 int pcacheSize = sqlite3PcacheSize(); /* Bytes to allocate for PCache */
62094 u32 szPageDflt = SQLITE_DEFAULT_PAGE_SIZE; /* Default page size */
62095 const char *zUri = 0; /* URI args to copy */
62096 int nUriByte = 1; /* Number of bytes of URI args at *zUri */
62097
62098
62099 /* Figure out how much space is required for each journal file-handle
62100 ** (there are two of them, the main journal and the sub-journal). */
62101 journalFileSize = ROUND8(sqlite3JournalSize(pVfs));
62102
@@ -61989,12 +62119,12 @@
62119 ** to by zPathname, length nPathname. Or, if this is a temporary file,
62120 ** leave both nPathname and zPathname set to 0.
62121 */
62122 if( zFilename && zFilename[0] ){
62123 const char *z;
62124 nPathname = pVfs->mxPathname + 1;
62125 zPathname = sqlite3DbMallocRaw(0, 2*(i64)nPathname);
62126 if( zPathname==0 ){
62127 return SQLITE_NOMEM_BKPT;
62128 }
62129 zPathname[0] = 0; /* Make sure initialized even if FullPathname() fails */
62130 rc = sqlite3OsFullPathname(pVfs, zFilename, nPathname, zPathname);
@@ -62077,18 +62207,18 @@
62207 assert( SQLITE_PTRSIZE==sizeof(Pager*) );
62208 pPtr = (u8 *)sqlite3MallocZero(
62209 ROUND8(sizeof(*pPager)) + /* Pager structure */
62210 ROUND8(pcacheSize) + /* PCache object */
62211 ROUND8(pVfs->szOsFile) + /* The main db file */
62212 (u64)journalFileSize * 2 + /* The two journal files */
62213 SQLITE_PTRSIZE + /* Space to hold a pointer */
62214 4 + /* Database prefix */
62215 (u64)nPathname + 1 + /* database filename */
62216 (u64)nUriByte + /* query parameters */
62217 (u64)nPathname + 8 + 1 + /* Journal filename */
62218 #ifndef SQLITE_OMIT_WAL
62219 (u64)nPathname + 4 + 1 + /* WAL filename */
62220 #endif
62221 3 /* Terminator */
62222 );
62223 assert( EIGHT_BYTE_ALIGNMENT(SQLITE_INT_TO_PTR(journalFileSize)) );
62224 if( !pPtr ){
@@ -65790,11 +65920,11 @@
65920 ){
65921 int rc = SQLITE_OK;
65922
65923 /* Enlarge the pWal->apWiData[] array if required */
65924 if( pWal->nWiData<=iPage ){
65925 sqlite3_int64 nByte = sizeof(u32*)*(1+(i64)iPage);
65926 volatile u32 **apNew;
65927 apNew = (volatile u32 **)sqlite3Realloc((void *)pWal->apWiData, nByte);
65928 if( !apNew ){
65929 *ppPage = 0;
65930 return SQLITE_NOMEM_BKPT;
@@ -68023,15 +68153,11 @@
68153 ** so it takes care to hold an exclusive lock on the corresponding
68154 ** WAL_READ_LOCK() while changing values.
68155 */
68156 static int walTryBeginRead(Wal *pWal, int *pChanged, int useWal, int *pCnt){
68157 volatile WalCkptInfo *pInfo; /* Checkpoint information in wal-index */
 
 
 
68158 int rc = SQLITE_OK; /* Return code */
 
68159 #ifdef SQLITE_ENABLE_SETLK_TIMEOUT
68160 int nBlockTmout = 0;
68161 #endif
68162
68163 assert( pWal->readLock<0 ); /* Not currently locked */
@@ -68133,145 +68259,151 @@
68259
68260 assert( pWal->nWiData>0 );
68261 assert( pWal->apWiData[0]!=0 );
68262 pInfo = walCkptInfo(pWal);
68263 SEH_INJECT_FAULT;
68264 {
68265 u32 mxReadMark; /* Largest aReadMark[] value */
68266 int mxI; /* Index of largest aReadMark[] value */
68267 int i; /* Loop counter */
68268 u32 mxFrame; /* Wal frame to lock to */
68269 if( !useWal && AtomicLoad(&pInfo->nBackfill)==pWal->hdr.mxFrame
68270 #ifdef SQLITE_ENABLE_SNAPSHOT
68271 && ((pWal->bGetSnapshot==0 && pWal->pSnapshot==0) || pWal->hdr.mxFrame==0)
68272 #endif
68273 ){
68274 /* The WAL has been completely backfilled (or it is empty).
68275 ** and can be safely ignored.
68276 */
68277 rc = walLockShared(pWal, WAL_READ_LOCK(0));
68278 walShmBarrier(pWal);
68279 if( rc==SQLITE_OK ){
68280 if( memcmp((void *)walIndexHdr(pWal), &pWal->hdr,sizeof(WalIndexHdr)) ){
68281 /* It is not safe to allow the reader to continue here if frames
68282 ** may have been appended to the log before READ_LOCK(0) was obtained.
68283 ** When holding READ_LOCK(0), the reader ignores the entire log file,
68284 ** which implies that the database file contains a trustworthy
68285 ** snapshot. Since holding READ_LOCK(0) prevents a checkpoint from
68286 ** happening, this is usually correct.
68287 **
68288 ** However, if frames have been appended to the log (or if the log
68289 ** is wrapped and written for that matter) before the READ_LOCK(0)
68290 ** is obtained, that is not necessarily true. A checkpointer may
68291 ** have started to backfill the appended frames but crashed before
68292 ** it finished. Leaving a corrupt image in the database file.
68293 */
68294 walUnlockShared(pWal, WAL_READ_LOCK(0));
68295 return WAL_RETRY;
68296 }
68297 pWal->readLock = 0;
68298 return SQLITE_OK;
68299 }else if( rc!=SQLITE_BUSY ){
68300 return rc;
68301 }
68302 }
68303
68304 /* If we get this far, it means that the reader will want to use
68305 ** the WAL to get at content from recent commits. The job now is
68306 ** to select one of the aReadMark[] entries that is closest to
68307 ** but not exceeding pWal->hdr.mxFrame and lock that entry.
68308 */
68309 mxReadMark = 0;
68310 mxI = 0;
68311 mxFrame = pWal->hdr.mxFrame;
68312 #ifdef SQLITE_ENABLE_SNAPSHOT
68313 if( pWal->pSnapshot && pWal->pSnapshot->mxFrame<mxFrame ){
68314 mxFrame = pWal->pSnapshot->mxFrame;
68315 }
68316 #endif
68317 for(i=1; i<WAL_NREADER; i++){
68318 u32 thisMark = AtomicLoad(pInfo->aReadMark+i); SEH_INJECT_FAULT;
68319 if( mxReadMark<=thisMark && thisMark<=mxFrame ){
68320 assert( thisMark!=READMARK_NOT_USED );
68321 mxReadMark = thisMark;
68322 mxI = i;
68323 }
68324 }
68325 if( (pWal->readOnly & WAL_SHM_RDONLY)==0
68326 && (mxReadMark<mxFrame || mxI==0)
68327 ){
68328 for(i=1; i<WAL_NREADER; i++){
68329 rc = walLockExclusive(pWal, WAL_READ_LOCK(i), 1);
68330 if( rc==SQLITE_OK ){
68331 AtomicStore(pInfo->aReadMark+i,mxFrame);
68332 mxReadMark = mxFrame;
68333 mxI = i;
68334 walUnlockExclusive(pWal, WAL_READ_LOCK(i), 1);
68335 break;
68336 }else if( rc!=SQLITE_BUSY ){
68337 return rc;
68338 }
68339 }
68340 }
68341 if( mxI==0 ){
68342 assert( rc==SQLITE_BUSY || (pWal->readOnly & WAL_SHM_RDONLY)!=0 );
68343 return rc==SQLITE_BUSY ? WAL_RETRY : SQLITE_READONLY_CANTINIT;
68344 }
68345
68346 (void)walEnableBlockingMs(pWal, nBlockTmout);
68347 rc = walLockShared(pWal, WAL_READ_LOCK(mxI));
68348 walDisableBlocking(pWal);
68349 if( rc ){
68350 #ifdef SQLITE_ENABLE_SETLK_TIMEOUT
68351 if( rc==SQLITE_BUSY_TIMEOUT ){
68352 *pCnt |= WAL_RETRY_BLOCKED_MASK;
68353 }
68354 #else
68355 assert( rc!=SQLITE_BUSY_TIMEOUT );
68356 #endif
68357 assert((rc&0xFF)!=SQLITE_BUSY||rc==SQLITE_BUSY||rc==SQLITE_BUSY_TIMEOUT);
68358 return (rc&0xFF)==SQLITE_BUSY ? WAL_RETRY : rc;
68359 }
68360 /* Now that the read-lock has been obtained, check that neither the
68361 ** value in the aReadMark[] array or the contents of the wal-index
68362 ** header have changed.
68363 **
68364 ** It is necessary to check that the wal-index header did not change
68365 ** between the time it was read and when the shared-lock was obtained
68366 ** on WAL_READ_LOCK(mxI) was obtained to account for the possibility
68367 ** that the log file may have been wrapped by a writer, or that frames
68368 ** that occur later in the log than pWal->hdr.mxFrame may have been
68369 ** copied into the database by a checkpointer. If either of these things
68370 ** happened, then reading the database with the current value of
68371 ** pWal->hdr.mxFrame risks reading a corrupted snapshot. So, retry
68372 ** instead.
68373 **
68374 ** Before checking that the live wal-index header has not changed
68375 ** since it was read, set Wal.minFrame to the first frame in the wal
68376 ** file that has not yet been checkpointed. This client will not need
68377 ** to read any frames earlier than minFrame from the wal file - they
68378 ** can be safely read directly from the database file.
68379 **
68380 ** Because a ShmBarrier() call is made between taking the copy of
68381 ** nBackfill and checking that the wal-header in shared-memory still
68382 ** matches the one cached in pWal->hdr, it is guaranteed that the
68383 ** checkpointer that set nBackfill was not working with a wal-index
68384 ** header newer than that cached in pWal->hdr. If it were, that could
68385 ** cause a problem. The checkpointer could omit to checkpoint
68386 ** a version of page X that lies before pWal->minFrame (call that version
68387 ** A) on the basis that there is a newer version (version B) of the same
68388 ** page later in the wal file. But if version B happens to like past
68389 ** frame pWal->hdr.mxFrame - then the client would incorrectly assume
68390 ** that it can read version A from the database file. However, since
68391 ** we can guarantee that the checkpointer that set nBackfill could not
68392 ** see any pages past pWal->hdr.mxFrame, this problem does not come up.
68393 */
68394 pWal->minFrame = AtomicLoad(&pInfo->nBackfill)+1; SEH_INJECT_FAULT;
68395 walShmBarrier(pWal);
68396 if( AtomicLoad(pInfo->aReadMark+mxI)!=mxReadMark
68397 || memcmp((void *)walIndexHdr(pWal), &pWal->hdr, sizeof(WalIndexHdr))
68398 ){
68399 walUnlockShared(pWal, WAL_READ_LOCK(mxI));
68400 return WAL_RETRY;
68401 }else{
68402 assert( mxReadMark<=pWal->hdr.mxFrame );
68403 pWal->readLock = (i16)mxI;
68404 }
68405 }
68406 return rc;
68407 }
68408
68409 #ifdef SQLITE_ENABLE_SNAPSHOT
@@ -71412,11 +71544,11 @@
71544 ** up to the size of 1 varint plus 1 8-byte value when the cursor
71545 ** position is restored. Hence the 17 bytes of padding allocated
71546 ** below. */
71547 void *pKey;
71548 pCur->nKey = sqlite3BtreePayloadSize(pCur);
71549 pKey = sqlite3Malloc( ((i64)pCur->nKey) + 9 + 8 );
71550 if( pKey ){
71551 rc = sqlite3BtreePayload(pCur, 0, (int)pCur->nKey, pKey);
71552 if( rc==SQLITE_OK ){
71553 memset(((u8*)pKey)+pCur->nKey, 0, 9+8);
71554 pCur->pKey = pKey;
@@ -76783,11 +76915,11 @@
76915 testcase( nCell==2 ); /* Minimum legal index key size */
76916 if( nCell<2 || nCell/pCur->pBt->usableSize>pCur->pBt->nPage ){
76917 rc = SQLITE_CORRUPT_PAGE(pPage);
76918 goto moveto_index_finish;
76919 }
76920 pCellKey = sqlite3Malloc( (u64)nCell+(u64)nOverrun );
76921 if( pCellKey==0 ){
76922 rc = SQLITE_NOMEM_BKPT;
76923 goto moveto_index_finish;
76924 }
76925 pCur->ix = (u16)idx;
@@ -81972,10 +82104,11 @@
82104 ** blob of allocated memory. The xFree function should not call sqlite3_free()
82105 ** on the memory, the btree layer does that.
82106 */
82107 SQLITE_PRIVATE void *sqlite3BtreeSchema(Btree *p, int nBytes, void(*xFree)(void *)){
82108 BtShared *pBt = p->pBt;
82109 assert( nBytes==0 || nBytes==sizeof(Schema) );
82110 sqlite3BtreeEnter(p);
82111 if( !pBt->pSchema && nBytes ){
82112 pBt->pSchema = sqlite3DbMallocZero(0, nBytes);
82113 pBt->xFreeSchema = xFree;
82114 }
@@ -83274,11 +83407,11 @@
83407 if( (pMem->flags & (MEM_Str|MEM_Term|MEM_Ephem|MEM_Static))!=MEM_Str ){
83408 /* pMem must be a string, and it cannot be an ephemeral or static string */
83409 return;
83410 }
83411 if( pMem->enc!=SQLITE_UTF8 ) return;
83412 assert( pMem->z!=0 );
83413 if( pMem->flags & MEM_Dyn ){
83414 if( pMem->xDel==sqlite3_free
83415 && sqlite3_msize(pMem->z) >= (u64)(pMem->n+1)
83416 ){
83417 pMem->z[pMem->n] = 0;
@@ -83993,31 +84126,34 @@
84126 ** copies (created by OP_SCopy) are not misused.
84127 */
84128 SQLITE_PRIVATE void sqlite3VdbeMemAboutToChange(Vdbe *pVdbe, Mem *pMem){
84129 int i;
84130 Mem *pX;
84131 if( pMem->bScopy ){
84132 for(i=1, pX=pVdbe->aMem+1; i<pVdbe->nMem; i++, pX++){
84133 if( pX->pScopyFrom==pMem ){
84134 u16 mFlags;
84135 if( pVdbe->db->flags & SQLITE_VdbeTrace ){
84136 sqlite3DebugPrintf("Invalidate R[%d] due to change in R[%d]\n",
84137 (int)(pX - pVdbe->aMem), (int)(pMem - pVdbe->aMem));
84138 }
84139 /* If pX is marked as a shallow copy of pMem, then try to verify that
84140 ** no significant changes have been made to pX since the OP_SCopy.
84141 ** A significant change would indicated a missed call to this
84142 ** function for pX. Minor changes, such as adding or removing a
84143 ** dual type, are allowed, as long as the underlying value is the
84144 ** same. */
84145 mFlags = pMem->flags & pX->flags & pX->mScopyFlags;
84146 assert( (mFlags&(MEM_Int|MEM_IntReal))==0 || pMem->u.i==pX->u.i );
84147
84148 /* pMem is the register that is changing. But also mark pX as
84149 ** undefined so that we can quickly detect the shallow-copy error */
84150 pX->flags = MEM_Undefined;
84151 pX->pScopyFrom = 0;
84152 }
84153 }
84154 pMem->bScopy = 0;
84155 }
84156 pMem->pScopyFrom = 0;
84157 }
84158 #endif /* SQLITE_DEBUG */
84159
@@ -84384,11 +84520,11 @@
84520 if( p ){
84521 UnpackedRecord *pRec = p->ppRec[0];
84522
84523 if( pRec==0 ){
84524 Index *pIdx = p->pIdx; /* Index being probed */
84525 i64 nByte; /* Bytes of space to allocate */
84526 int i; /* Counter variable */
84527 int nCol = pIdx->nColumn; /* Number of index columns including rowid */
84528
84529 nByte = sizeof(Mem) * nCol + ROUND8(sizeof(UnpackedRecord));
84530 pRec = (UnpackedRecord*)sqlite3DbMallocZero(db, nByte);
@@ -84450,11 +84586,11 @@
84586 sqlite3_value **ppVal, /* Write the new value here */
84587 struct ValueNewStat4Ctx *pCtx /* Second argument for valueNew() */
84588 ){
84589 sqlite3_context ctx; /* Context object for function invocation */
84590 sqlite3_value **apVal = 0; /* Function arguments */
84591 int nVal = 0; /* Number of function arguments */
84592 FuncDef *pFunc = 0; /* Function definition */
84593 sqlite3_value *pVal = 0; /* New value */
84594 int rc = SQLITE_OK; /* Return code */
84595 ExprList *pList = 0; /* Function arguments */
84596 int i; /* Iterator variable */
@@ -85729,11 +85865,11 @@
85865 p->iSub++;
85866 p->iAddr = 0;
85867 }
85868
85869 if( pRet->p4type==P4_SUBPROGRAM ){
85870 i64 nByte = (1+(u64)p->nSub)*sizeof(SubProgram*);
85871 int j;
85872 for(j=0; j<p->nSub; j++){
85873 if( p->apSub[j]==pRet->p4.pProgram ) break;
85874 }
85875 if( j==p->nSub ){
@@ -85859,12 +85995,12 @@
85995 ** through all the opcodes and fixes up some details.
85996 **
85997 ** (1) For each jump instruction with a negative P2 value (a label)
85998 ** resolve the P2 value to an actual address.
85999 **
86000 ** (2) Compute the maximum number of arguments used by the xUpdate/xFilter
86001 ** methods of any virtual table and store that value in *pMaxVtabArgs.
86002 **
86003 ** (3) Update the Vdbe.readOnly and Vdbe.bIsReader flags to accurately
86004 ** indicate what the prepared statement actually does.
86005 **
86006 ** (4) (discontinued)
@@ -85873,12 +86009,12 @@
86009 **
86010 ** This routine will only function correctly if the mkopcodeh.tcl generator
86011 ** script numbers the opcodes correctly. Changes to this routine must be
86012 ** coordinated with changes to mkopcodeh.tcl.
86013 */
86014 static void resolveP2Values(Vdbe *p, int *pMaxVtabArgs){
86015 int nMaxVtabArgs = *pMaxVtabArgs;
86016 Op *pOp;
86017 Parse *pParse = p->pParse;
86018 int *aLabel = pParse->aLabel;
86019
86020 assert( pParse->db->mallocFailed==0 ); /* tag-20230419-1 */
@@ -85919,19 +86055,23 @@
86055 assert( pOp->p2>=0 );
86056 goto resolve_p2_values_loop_exit;
86057 }
86058 #ifndef SQLITE_OMIT_VIRTUALTABLE
86059 case OP_VUpdate: {
86060 if( pOp->p2>nMaxVtabArgs ) nMaxVtabArgs = pOp->p2;
86061 break;
86062 }
86063 case OP_VFilter: {
86064 int n;
86065 /* The instruction immediately prior to VFilter will be an
86066 ** OP_Integer that sets the "argc" value for the VFilter. See
86067 ** the code where OP_VFilter is generated at tag-20250207a. */
86068 assert( (pOp - p->aOp) >= 3 );
86069 assert( pOp[-1].opcode==OP_Integer );
86070 assert( pOp[-1].p2==pOp->p3+1 );
86071 n = pOp[-1].p1;
86072 if( n>nMaxVtabArgs ) nMaxVtabArgs = n;
86073 /* Fall through into the default case */
86074 /* no break */ deliberate_fall_through
86075 }
86076 #endif
86077 default: {
@@ -85968,11 +86108,11 @@
86108 if( aLabel ){
86109 sqlite3DbNNFreeNN(p->db, pParse->aLabel);
86110 pParse->aLabel = 0;
86111 }
86112 pParse->nLabel = 0;
86113 *pMaxVtabArgs = nMaxVtabArgs;
86114 assert( p->bIsReader!=0 || DbMaskAllZero(p->btreeMask) );
86115 }
86116
86117 #ifdef SQLITE_DEBUG
86118 /*
@@ -86197,11 +86337,11 @@
86337 int addrVisit, /* Address of rows visited counter */
86338 LogEst nEst, /* Estimated number of output rows */
86339 const char *zName /* Name of table or index being scanned */
86340 ){
86341 if( IS_STMT_SCANSTATUS(p->db) ){
86342 i64 nByte = (1+(i64)p->nScan) * sizeof(ScanStatus);
86343 ScanStatus *aNew;
86344 aNew = (ScanStatus*)sqlite3DbRealloc(p->db, p->aScan, nByte);
86345 if( aNew ){
86346 ScanStatus *pNew = &aNew[p->nScan++];
86347 memset(pNew, 0, sizeof(ScanStatus));
@@ -87147,17 +87287,19 @@
87287 **
87288 ** All other fields of Mem can safely remain uninitialized for now. They
87289 ** will be initialized before use.
87290 */
87291 static void initMemArray(Mem *p, int N, sqlite3 *db, u16 flags){
87292 assert( db!=0 );
87293 if( N>0 ){
87294 do{
87295 p->flags = flags;
87296 p->db = db;
87297 p->szMalloc = 0;
87298 #ifdef SQLITE_DEBUG
87299 p->pScopyFrom = 0;
87300 p->bScopy = 0;
87301 #endif
87302 p++;
87303 }while( (--N)>0 );
87304 }
87305 }
@@ -87172,10 +87314,11 @@
87314 */
87315 static void releaseMemArray(Mem *p, int N){
87316 if( p && N ){
87317 Mem *pEnd = &p[N];
87318 sqlite3 *db = p->db;
87319 assert( db!=0 );
87320 if( db->pnBytesFreed ){
87321 do{
87322 if( p->szMalloc ) sqlite3DbFree(db, p->zMalloc);
87323 }while( (++p)<pEnd );
87324 return;
@@ -87643,19 +87786,20 @@
87786 ){
87787 sqlite3 *db; /* The database connection */
87788 int nVar; /* Number of parameters */
87789 int nMem; /* Number of VM memory registers */
87790 int nCursor; /* Number of cursors required */
87791 int nArg; /* Max number args to xFilter or xUpdate */
87792 int n; /* Loop counter */
87793 struct ReusableSpace x; /* Reusable bulk memory */
87794
87795 assert( p!=0 );
87796 assert( p->nOp>0 );
87797 assert( pParse!=0 );
87798 assert( p->eVdbeState==VDBE_INIT_STATE );
87799 assert( pParse==p->pParse );
87800 assert( pParse->db==p->db );
87801 p->pVList = pParse->pVList;
87802 pParse->pVList = 0;
87803 db = p->db;
87804 assert( db->mallocFailed==0 );
87805 nVar = pParse->nVar;
@@ -87714,10 +87858,13 @@
87858 p->aVar = allocSpace(&x, p->aVar, nVar*sizeof(Mem));
87859 p->apArg = allocSpace(&x, p->apArg, nArg*sizeof(Mem*));
87860 p->apCsr = allocSpace(&x, p->apCsr, nCursor*sizeof(VdbeCursor*));
87861 }
87862 }
87863 #ifdef SQLITE_DEBUG
87864 p->napArg = nArg;
87865 #endif
87866
87867 if( db->mallocFailed ){
87868 p->nVar = 0;
87869 p->nCursor = 0;
87870 p->nMem = 0;
@@ -89211,10 +89358,11 @@
89358 SQLITE_PRIVATE UnpackedRecord *sqlite3VdbeAllocUnpackedRecord(
89359 KeyInfo *pKeyInfo /* Description of the record */
89360 ){
89361 UnpackedRecord *p; /* Unpacked record to return */
89362 int nByte; /* Number of bytes required for *p */
89363 assert( sizeof(UnpackedRecord) + sizeof(Mem)*65536 < 0x7fffffff );
89364 nByte = ROUND8P(sizeof(UnpackedRecord)) + sizeof(Mem)*(pKeyInfo->nKeyField+1);
89365 p = (UnpackedRecord *)sqlite3DbMallocRaw(pKeyInfo->db, nByte);
89366 if( !p ) return 0;
89367 p->aMem = (Mem*)&((char*)p)[ROUND8P(sizeof(UnpackedRecord))];
89368 assert( pKeyInfo->aSortFlags!=0 );
@@ -90617,11 +90765,10 @@
90765 */
90766 static SQLITE_NOINLINE void invokeProfileCallback(sqlite3 *db, Vdbe *p){
90767 sqlite3_int64 iNow;
90768 sqlite3_int64 iElapse;
90769 assert( p->startTime>0 );
 
90770 assert( db->init.busy==0 );
90771 assert( p->zSql!=0 );
90772 sqlite3OsCurrentTimeInt64(db->pVfs, &iNow);
90773 iElapse = (iNow - p->startTime)*1000000;
90774 #ifndef SQLITE_OMIT_DEPRECATED
@@ -91337,11 +91484,11 @@
91484 if( db->nVdbeActive==0 ){
91485 AtomicStore(&db->u1.isInterrupted, 0);
91486 }
91487
91488 assert( db->nVdbeWrite>0 || db->autoCommit==0
91489 || ((db->nDeferredCons + db->nDeferredImmCons)==0)
91490 );
91491
91492 #ifndef SQLITE_OMIT_TRACE
91493 if( (db->mTrace & (SQLITE_TRACE_PROFILE|SQLITE_TRACE_XPROFILE))!=0
91494 && !db->init.busy && p->zSql ){
@@ -91848,10 +91995,11 @@
91995 /* .zMalloc = */ (char*)0,
91996 /* .xDel = */ (void(*)(void*))0,
91997 #ifdef SQLITE_DEBUG
91998 /* .pScopyFrom = */ (Mem*)0,
91999 /* .mScopyFlags= */ 0,
92000 /* .bScopy = */ 0,
92001 #endif
92002 };
92003 return &nullMem;
92004 }
92005
@@ -91889,11 +92037,11 @@
92037 **
92038 ** sqlite3_column_int()
92039 ** sqlite3_column_int64()
92040 ** sqlite3_column_text()
92041 ** sqlite3_column_text16()
92042 ** sqlite3_column_double()
92043 ** sqlite3_column_bytes()
92044 ** sqlite3_column_bytes16()
92045 ** sqlite3_column_blob()
92046 */
92047 static void columnMallocFailure(sqlite3_stmt *pStmt)
@@ -92730,10 +92878,11 @@
92878 */
92879 SQLITE_API int sqlite3_preupdate_old(sqlite3 *db, int iIdx, sqlite3_value **ppValue){
92880 PreUpdate *p;
92881 Mem *pMem;
92882 int rc = SQLITE_OK;
92883 int iStore = 0;
92884
92885 #ifdef SQLITE_ENABLE_API_ARMOR
92886 if( db==0 || ppValue==0 ){
92887 return SQLITE_MISUSE_BKPT;
92888 }
@@ -92744,13 +92893,15 @@
92893 if( !p || p->op==SQLITE_INSERT ){
92894 rc = SQLITE_MISUSE_BKPT;
92895 goto preupdate_old_out;
92896 }
92897 if( p->pPk ){
92898 iStore = sqlite3TableColumnToIndex(p->pPk, iIdx);
92899 }else{
92900 iStore = sqlite3TableColumnToStorage(p->pTab, iIdx);
92901 }
92902 if( iStore>=p->pCsr->nField || iStore<0 ){
92903 rc = SQLITE_RANGE;
92904 goto preupdate_old_out;
92905 }
92906
92907 if( iIdx==p->pTab->iPKey ){
@@ -92777,18 +92928,20 @@
92928 goto preupdate_old_out;
92929 }
92930 p->aRecord = aRec;
92931 }
92932
92933 pMem = *ppValue = &p->pUnpacked->aMem[iStore];
92934 if( iStore>=p->pUnpacked->nField ){
92935 /* This occurs when the table has been extended using ALTER TABLE
92936 ** ADD COLUMN. The value to return is the default value of the column. */
92937 Column *pCol = &p->pTab->aCol[iIdx];
92938 if( pCol->iDflt>0 ){
92939 if( p->apDflt==0 ){
92940 int nByte;
92941 assert( sizeof(sqlite3_value*)*UMXV(p->pTab->nCol) < 0x7fffffff );
92942 nByte = sizeof(sqlite3_value*)*p->pTab->nCol;
92943 p->apDflt = (sqlite3_value**)sqlite3DbMallocZero(db, nByte);
92944 if( p->apDflt==0 ) goto preupdate_old_out;
92945 }
92946 if( p->apDflt[iIdx]==0 ){
92947 sqlite3_value *pVal = 0;
@@ -92882,10 +93035,11 @@
93035 */
93036 SQLITE_API int sqlite3_preupdate_new(sqlite3 *db, int iIdx, sqlite3_value **ppValue){
93037 PreUpdate *p;
93038 int rc = SQLITE_OK;
93039 Mem *pMem;
93040 int iStore = 0;
93041
93042 #ifdef SQLITE_ENABLE_API_ARMOR
93043 if( db==0 || ppValue==0 ){
93044 return SQLITE_MISUSE_BKPT;
93045 }
@@ -92894,13 +93048,16 @@
93048 if( !p || p->op==SQLITE_DELETE ){
93049 rc = SQLITE_MISUSE_BKPT;
93050 goto preupdate_new_out;
93051 }
93052 if( p->pPk && p->op!=SQLITE_UPDATE ){
93053 iStore = sqlite3TableColumnToIndex(p->pPk, iIdx);
93054 }else{
93055 iStore = sqlite3TableColumnToStorage(p->pTab, iIdx);
93056 }
93057
93058 if( iStore>=p->pCsr->nField || iStore<0 ){
93059 rc = SQLITE_RANGE;
93060 goto preupdate_new_out;
93061 }
93062
93063 if( p->op==SQLITE_INSERT ){
@@ -92916,37 +93073,38 @@
93073 rc = SQLITE_NOMEM;
93074 goto preupdate_new_out;
93075 }
93076 p->pNewUnpacked = pUnpack;
93077 }
93078 pMem = &pUnpack->aMem[iStore];
93079 if( iIdx==p->pTab->iPKey ){
93080 sqlite3VdbeMemSetInt64(pMem, p->iKey2);
93081 }else if( iStore>=pUnpack->nField ){
93082 pMem = (sqlite3_value *)columnNullValue();
93083 }
93084 }else{
93085 /* For an UPDATE, memory cell (p->iNewReg+1+iStore) contains the required
93086 ** value. Make a copy of the cell contents and return a pointer to it.
93087 ** It is not safe to return a pointer to the memory cell itself as the
93088 ** caller may modify the value text encoding.
93089 */
93090 assert( p->op==SQLITE_UPDATE );
93091 if( !p->aNew ){
93092 assert( sizeof(Mem)*UMXV(p->pCsr->nField) < 0x7fffffff );
93093 p->aNew = (Mem *)sqlite3DbMallocZero(db, sizeof(Mem)*p->pCsr->nField);
93094 if( !p->aNew ){
93095 rc = SQLITE_NOMEM;
93096 goto preupdate_new_out;
93097 }
93098 }
93099 assert( iStore>=0 && iStore<p->pCsr->nField );
93100 pMem = &p->aNew[iStore];
93101 if( pMem->flags==0 ){
93102 if( iIdx==p->pTab->iPKey ){
93103 sqlite3VdbeMemSetInt64(pMem, p->iKey2);
93104 }else{
93105 rc = sqlite3VdbeMemCopy(pMem, &p->v->aMem[p->iNewReg+1+iStore]);
93106 if( rc!=SQLITE_OK ) goto preupdate_new_out;
93107 }
93108 }
93109 }
93110 *ppValue = pMem;
@@ -93700,11 +93858,11 @@
93858 ** the top of the register space. Cursor 1 is at Mem[p->nMem-1].
93859 ** Cursor 2 is at Mem[p->nMem-2]. And so forth.
93860 */
93861 Mem *pMem = iCur>0 ? &p->aMem[p->nMem-iCur] : p->aMem;
93862
93863 i64 nByte;
93864 VdbeCursor *pCx = 0;
93865 nByte =
93866 ROUND8P(sizeof(VdbeCursor)) + 2*sizeof(u32)*nField +
93867 (eCurType==CURTYPE_BTREE?sqlite3BtreeCursorSize():0);
93868
@@ -93728,11 +93886,11 @@
93886 pMem->z = pMem->zMalloc = sqlite3DbMallocRaw(pMem->db, nByte);
93887 if( pMem->zMalloc==0 ){
93888 pMem->szMalloc = 0;
93889 return 0;
93890 }
93891 pMem->szMalloc = (int)nByte;
93892 }
93893
93894 p->apCsr[iCur] = pCx = (VdbeCursor*)pMem->zMalloc;
93895 memset(pCx, 0, offsetof(VdbeCursor,pAltCursor));
93896 pCx->eCurType = eCurType;
@@ -94031,10 +94189,11 @@
94189 }
94190 static void registerTrace(int iReg, Mem *p){
94191 printf("R[%d] = ", iReg);
94192 memTracePrint(p);
94193 if( p->pScopyFrom ){
94194 assert( p->pScopyFrom->bScopy );
94195 printf(" <== R[%d]", (int)(p->pScopyFrom - &p[-iReg]));
94196 }
94197 printf("\n");
94198 sqlite3VdbeCheckMemInvariants(p);
94199 }
@@ -95014,10 +95173,11 @@
95173 #ifdef SQLITE_DEBUG
95174 pIn1->pScopyFrom = 0;
95175 { int i;
95176 for(i=1; i<p->nMem; i++){
95177 if( aMem[i].pScopyFrom==pIn1 ){
95178 assert( aMem[i].bScopy );
95179 aMem[i].pScopyFrom = pOut;
95180 }
95181 }
95182 }
95183 #endif
@@ -95086,10 +95246,11 @@
95246 assert( pOut!=pIn1 );
95247 sqlite3VdbeMemShallowCopy(pOut, pIn1, MEM_Ephem);
95248 #ifdef SQLITE_DEBUG
95249 pOut->pScopyFrom = pIn1;
95250 pOut->mScopyFlags = pIn1->flags;
95251 pIn1->bScopy = 1;
95252 #endif
95253 break;
95254 }
95255
95256 /* Opcode: IntCopy P1 P2 * * *
@@ -100746,11 +100907,11 @@
100907 **
100908 ** If P5 is non-zero, then recursive program invocation is enabled.
100909 */
100910 case OP_Program: { /* jump0 */
100911 int nMem; /* Number of memory registers for sub-program */
100912 i64 nByte; /* Bytes of runtime space required for sub-program */
100913 Mem *pRt; /* Register to allocate runtime space */
100914 Mem *pMem; /* Used to iterate through memory cells */
100915 Mem *pEnd; /* Last memory cell in new array */
100916 VdbeFrame *pFrame; /* New vdbe frame to execute in */
100917 SubProgram *pProgram; /* Sub-program to execute */
@@ -100797,19 +100958,19 @@
100958 assert( nMem>0 );
100959 if( pProgram->nCsr==0 ) nMem++;
100960 nByte = ROUND8(sizeof(VdbeFrame))
100961 + nMem * sizeof(Mem)
100962 + pProgram->nCsr * sizeof(VdbeCursor*)
100963 + (7 + (i64)pProgram->nOp)/8;
100964 pFrame = sqlite3DbMallocZero(db, nByte);
100965 if( !pFrame ){
100966 goto no_mem;
100967 }
100968 sqlite3VdbeMemRelease(pRt);
100969 pRt->flags = MEM_Blob|MEM_Dyn;
100970 pRt->z = (char*)pFrame;
100971 pRt->n = (int)nByte;
100972 pRt->xDel = sqlite3VdbeFrameMemDel;
100973
100974 pFrame->v = p;
100975 pFrame->nChildMem = nMem;
100976 pFrame->nChildCsr = pProgram->nCsr;
@@ -100904,16 +101065,18 @@
101065 ** If P1 is non-zero, the database constraint counter is incremented
101066 ** (deferred foreign key constraints). Otherwise, if P1 is zero, the
101067 ** statement counter is incremented (immediate foreign key constraints).
101068 */
101069 case OP_FkCounter: {
101070 if( pOp->p1 ){
 
 
101071 db->nDeferredCons += pOp->p2;
101072 }else{
101073 if( db->flags & SQLITE_DeferFKs ){
101074 db->nDeferredImmCons += pOp->p2;
101075 }else{
101076 p->nFkConstraint += pOp->p2;
101077 }
101078 }
101079 break;
101080 }
101081
101082 /* Opcode: FkIfZero P1 P2 * * *
@@ -101784,10 +101947,11 @@
101947 nArg = (int)pArgc->u.i;
101948 iQuery = (int)pQuery->u.i;
101949
101950 /* Invoke the xFilter method */
101951 apArg = p->apArg;
101952 assert( nArg<=p->napArg );
101953 for(i = 0; i<nArg; i++){
101954 apArg[i] = &pArgc[i+1];
101955 }
101956 rc = pModule->xFilter(pVCur, iQuery, pOp->p4.z, nArg, apArg);
101957 sqlite3VtabImportErrmsg(p, pVtab);
@@ -101994,10 +102158,11 @@
102158 assert( pOp->p4type==P4_VTAB );
102159 if( ALWAYS(pModule->xUpdate) ){
102160 u8 vtabOnConflict = db->vtabOnConflict;
102161 apArg = p->apArg;
102162 pX = &aMem[pOp->p3];
102163 assert( nArg<=p->napArg );
102164 for(i=0; i<nArg; i++){
102165 assert( memIsValid(pX) );
102166 memAboutToChange(p, pX);
102167 apArg[i] = pX;
102168 pX++;
@@ -102839,16 +103004,12 @@
103004 }
103005 pBlob->pTab = pTab;
103006 pBlob->zDb = db->aDb[sqlite3SchemaToIndex(db, pTab->pSchema)].zDbSName;
103007
103008 /* Now search pTab for the exact column. */
103009 iCol = sqlite3ColumnIndex(pTab, zColumn);
103010 if( iCol<0 ){
 
 
 
 
103011 sqlite3DbFree(db, zErr);
103012 zErr = sqlite3MPrintf(db, "no such column: \"%s\"", zColumn);
103013 rc = SQLITE_ERROR;
103014 sqlite3BtreeLeaveAll(db);
103015 goto blob_open_out;
@@ -104106,11 +104267,11 @@
104267 int pgsz; /* Page size of main database */
104268 int i; /* Used to iterate through aTask[] */
104269 VdbeSorter *pSorter; /* The new sorter */
104270 KeyInfo *pKeyInfo; /* Copy of pCsr->pKeyInfo with db==0 */
104271 int szKeyInfo; /* Size of pCsr->pKeyInfo in bytes */
104272 i64 sz; /* Size of pSorter in bytes */
104273 int rc = SQLITE_OK;
104274 #if SQLITE_MAX_WORKER_THREADS==0
104275 # define nWorker 0
104276 #else
104277 int nWorker;
@@ -104134,10 +104295,12 @@
104295 #endif
104296
104297 assert( pCsr->pKeyInfo );
104298 assert( !pCsr->isEphemeral );
104299 assert( pCsr->eCurType==CURTYPE_SORTER );
104300 assert( sizeof(KeyInfo) + UMXV(pCsr->pKeyInfo->nKeyField)*sizeof(CollSeq*)
104301 < 0x7fffffff );
104302 szKeyInfo = sizeof(KeyInfo) + (pCsr->pKeyInfo->nKeyField-1)*sizeof(CollSeq*);
104303 sz = sizeof(VdbeSorter) + nWorker * sizeof(SortSubtask);
104304
104305 pSorter = (VdbeSorter*)sqlite3DbMallocZero(db, sz + szKeyInfo);
104306 pCsr->uc.pSorter = pSorter;
@@ -104347,11 +104510,11 @@
104510 ** nReader is automatically rounded up to the next power of two.
104511 ** nReader may not exceed SORTER_MAX_MERGE_COUNT even after rounding up.
104512 */
104513 static MergeEngine *vdbeMergeEngineNew(int nReader){
104514 int N = 2; /* Smallest power of two >= nReader */
104515 i64 nByte; /* Total bytes of space to allocate */
104516 MergeEngine *pNew; /* Pointer to allocated object to return */
104517
104518 assert( nReader<=SORTER_MAX_MERGE_COUNT );
104519
104520 while( N<nReader ) N += N;
@@ -107390,11 +107553,10 @@
107553 SrcItem *pMatch = 0; /* The matching pSrcList item */
107554 NameContext *pTopNC = pNC; /* First namecontext in the list */
107555 Schema *pSchema = 0; /* Schema of the expression */
107556 int eNewExprOp = TK_COLUMN; /* New value for pExpr->op on success */
107557 Table *pTab = 0; /* Table holding the row */
 
107558 ExprList *pFJMatch = 0; /* Matches for FULL JOIN .. USING */
107559 const char *zCol = pRight->u.zToken;
107560
107561 assert( pNC ); /* the name context cannot be NULL. */
107562 assert( zCol ); /* The Z in X.Y.Z cannot be NULL */
@@ -107441,11 +107603,10 @@
107603 ExprList *pEList;
107604 SrcList *pSrcList = pNC->pSrcList;
107605
107606 if( pSrcList ){
107607 for(i=0, pItem=pSrcList->a; i<pSrcList->nSrc; i++, pItem++){
 
107608 pTab = pItem->pSTab;
107609 assert( pTab!=0 && pTab->zName!=0 );
107610 assert( pTab->nCol>0 || pParse->nErr );
107611 assert( (int)pItem->fg.isNestedFrom == IsNestedFrom(pItem));
107612 if( pItem->fg.isNestedFrom ){
@@ -107529,47 +107690,42 @@
107690 assert( ExprUseYTab(pExpr) );
107691 if( IN_RENAME_OBJECT && pItem->zAlias ){
107692 sqlite3RenameTokenRemap(pParse, 0, (void*)&pExpr->y.pTab);
107693 }
107694 }
107695 j = sqlite3ColumnIndex(pTab, zCol);
107696 if( j>=0 ){
107697 if( cnt>0 ){
107698 if( pItem->fg.isUsing==0
107699 || sqlite3IdListIndex(pItem->u3.pUsing, zCol)<0
107700 ){
107701 /* Two or more tables have the same column name which is
107702 ** not joined by USING. This is an error. Signal as much
107703 ** by clearing pFJMatch and letting cnt go above 1. */
107704 sqlite3ExprListDelete(db, pFJMatch);
107705 pFJMatch = 0;
107706 }else
107707 if( (pItem->fg.jointype & JT_RIGHT)==0 ){
107708 /* An INNER or LEFT JOIN. Use the left-most table */
107709 continue;
107710 }else
107711 if( (pItem->fg.jointype & JT_LEFT)==0 ){
107712 /* A RIGHT JOIN. Use the right-most table */
107713 cnt = 0;
107714 sqlite3ExprListDelete(db, pFJMatch);
107715 pFJMatch = 0;
107716 }else{
107717 /* For a FULL JOIN, we must construct a coalesce() func */
107718 extendFJMatch(pParse, &pFJMatch, pMatch, pExpr->iColumn);
107719 }
107720 }
107721 cnt++;
107722 pMatch = pItem;
107723 /* Substitute the rowid (column -1) for the INTEGER PRIMARY KEY */
107724 pExpr->iColumn = j==pTab->iPKey ? -1 : (i16)j;
107725 if( pItem->fg.isNestedFrom ){
107726 sqlite3SrcItemColumnUsed(pItem, j);
 
 
 
 
 
107727 }
107728 }
107729 if( 0==cnt && VisibleRowid(pTab) ){
107730 /* pTab is a potential ROWID match. Keep track of it and match
107731 ** the ROWID later if that seems appropriate. (Search for "cntTab"
@@ -107655,26 +107811,21 @@
107811 }
107812 #endif /* SQLITE_OMIT_UPSERT */
107813
107814 if( pTab ){
107815 int iCol;
 
107816 pSchema = pTab->pSchema;
107817 cntTab++;
107818 iCol = sqlite3ColumnIndex(pTab, zCol);
107819 if( iCol>=0 ){
107820 if( pTab->iPKey==iCol ) iCol = -1;
107821 }else{
107822 if( sqlite3IsRowid(zCol) && VisibleRowid(pTab) ){
107823 iCol = -1;
107824 }else{
107825 iCol = pTab->nCol;
107826 }
 
 
 
 
107827 }
107828 if( iCol<pTab->nCol ){
107829 cnt++;
107830 pMatch = 0;
107831 #ifndef SQLITE_OMIT_UPSERT
@@ -109896,11 +110047,11 @@
110047 p4 = sqlite3BinaryCompareCollSeq(pParse, pLeft, pRight);
110048 }
110049 p5 = binaryCompareP5(pLeft, pRight, jumpIfNull);
110050 addr = sqlite3VdbeAddOp4(pParse->pVdbe, opcode, in2, dest, in1,
110051 (void*)p4, P4_COLLSEQ);
110052 sqlite3VdbeChangeP5(pParse->pVdbe, (u16)p5);
110053 return addr;
110054 }
110055
110056 /*
110057 ** Return true if expression pExpr is a vector, or false otherwise.
@@ -111266,11 +111417,10 @@
111417 pNewExpr->pLeft = pPriorSelectColNew;
111418 }
111419 }
111420 pItem->zEName = sqlite3DbStrDup(db, pOldItem->zEName);
111421 pItem->fg = pOldItem->fg;
 
111422 pItem->u = pOldItem->u;
111423 }
111424 return pNew;
111425 }
111426
@@ -111349,20 +111499,17 @@
111499 SQLITE_PRIVATE IdList *sqlite3IdListDup(sqlite3 *db, const IdList *p){
111500 IdList *pNew;
111501 int i;
111502 assert( db!=0 );
111503 if( p==0 ) return 0;
 
111504 pNew = sqlite3DbMallocRawNN(db, sizeof(*pNew)+(p->nId-1)*sizeof(p->a[0]) );
111505 if( pNew==0 ) return 0;
111506 pNew->nId = p->nId;
 
111507 for(i=0; i<p->nId; i++){
111508 struct IdList_item *pNewItem = &pNew->a[i];
111509 const struct IdList_item *pOldItem = &p->a[i];
111510 pNewItem->zName = sqlite3DbStrDup(db, pOldItem->zName);
 
111511 }
111512 return pNew;
111513 }
111514 SQLITE_PRIVATE Select *sqlite3SelectDup(sqlite3 *db, const Select *pDup, int flags){
111515 Select *pRet = 0;
@@ -112386,17 +112533,11 @@
112533 SQLITE_PRIVATE const char *sqlite3RowidAlias(Table *pTab){
112534 const char *azOpt[] = {"_ROWID_", "ROWID", "OID"};
112535 int ii;
112536 assert( VisibleRowid(pTab) );
112537 for(ii=0; ii<ArraySize(azOpt); ii++){
112538 if( sqlite3ColumnIndex(pTab, azOpt[ii])<0 ) return azOpt[ii];
 
 
 
 
 
 
112539 }
112540 return 0;
112541 }
112542
112543 /*
@@ -112702,10 +112843,11 @@
112843 if( mCol & colUsed ) break; /* Each column used only once */
112844 colUsed |= mCol;
112845 if( aiMap ) aiMap[i] = j;
112846 }
112847
112848 assert( nExpr>0 && nExpr<BMS );
112849 assert( i==nExpr || colUsed!=(MASKBIT(nExpr)-1) );
112850 if( colUsed==(MASKBIT(nExpr)-1) ){
112851 /* If we reach this point, that means the index pIdx is usable */
112852 int iAddr = sqlite3VdbeAddOp0(v, OP_Once); VdbeCoverage(v);
112853 ExplainQueryPlan((pParse, 0,
@@ -112795,11 +112937,11 @@
112937 int nVal = sqlite3ExprVectorSize(pLeft);
112938 Select *pSelect = ExprUseXSelect(pExpr) ? pExpr->x.pSelect : 0;
112939 char *zRet;
112940
112941 assert( pExpr->op==TK_IN );
112942 zRet = sqlite3DbMallocRaw(pParse->db, 1+(i64)nVal);
112943 if( zRet ){
112944 int i;
112945 for(i=0; i<nVal; i++){
112946 Expr *pA = sqlite3VectorFieldSubexpr(pLeft, i);
112947 char a = sqlite3ExprAffinity(pA);
@@ -112881,10 +113023,11 @@
113023 for(; pOp<pEnd; pOp++){
113024 if( pOp->p4type!=P4_SUBRTNSIG ) continue;
113025 assert( pOp->opcode==OP_BeginSubrtn );
113026 pSig = pOp->p4.pSubrtnSig;
113027 assert( pSig!=0 );
113028 if( !pSig->bComplete ) continue;
113029 if( pNewSig->selId!=pSig->selId ) continue;
113030 if( strcmp(pNewSig->zAff,pSig->zAff)!=0 ) continue;
113031 pExpr->y.sub.iAddr = pSig->iAddr;
113032 pExpr->y.sub.regReturn = pSig->regReturn;
113033 pExpr->iTable = pSig->iTable;
@@ -112927,10 +113070,11 @@
113070 int addr; /* Address of OP_OpenEphemeral instruction */
113071 Expr *pLeft; /* the LHS of the IN operator */
113072 KeyInfo *pKeyInfo = 0; /* Key information */
113073 int nVal; /* Size of vector pLeft */
113074 Vdbe *v; /* The prepared statement under construction */
113075 SubrtnSig *pSig = 0; /* Signature for this subroutine */
113076
113077 v = pParse->pVdbe;
113078 assert( v!=0 );
113079
113080 /* The evaluation of the IN must be repeated every time it
@@ -112947,11 +113091,10 @@
113091 /* Reuse of the RHS is allowed
113092 **
113093 ** Compute a signature for the RHS of the IN operator to facility
113094 ** finding and reusing prior instances of the same IN operator.
113095 */
 
113096 assert( !ExprUseXSelect(pExpr) || pExpr->x.pSelect!=0 );
113097 if( ExprUseXSelect(pExpr) && (pExpr->x.pSelect->selFlags & SF_All)==0 ){
113098 pSig = sqlite3DbMallocRawNN(pParse->db, sizeof(pSig[0]));
113099 if( pSig ){
113100 pSig->selId = pExpr->x.pSelect->selId;
@@ -112990,10 +113133,11 @@
113133 assert( !ExprHasProperty(pExpr, EP_TokenOnly|EP_Reduced) );
113134 pExpr->y.sub.regReturn = ++pParse->nMem;
113135 pExpr->y.sub.iAddr =
113136 sqlite3VdbeAddOp2(v, OP_BeginSubrtn, 0, pExpr->y.sub.regReturn) + 1;
113137 if( pSig ){
113138 pSig->bComplete = 0;
113139 pSig->iAddr = pExpr->y.sub.iAddr;
113140 pSig->regReturn = pExpr->y.sub.regReturn;
113141 pSig->iTable = iTab;
113142 pParse->mSubrtnSig = 1 << (pSig->selId&7);
113143 sqlite3VdbeChangeP4(v, -1, (const char*)pSig, P4_SUBRTNSIG);
@@ -113125,10 +113269,11 @@
113269 sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iTab, r2, r1, 1);
113270 }
113271 sqlite3ReleaseTempReg(pParse, r1);
113272 sqlite3ReleaseTempReg(pParse, r2);
113273 }
113274 if( pSig ) pSig->bComplete = 1;
113275 if( pKeyInfo ){
113276 sqlite3VdbeChangeP4(v, addr, (void *)pKeyInfo, P4_KEYINFO);
113277 }
113278 if( addrOnce ){
113279 sqlite3VdbeAddOp1(v, OP_NullRow, iTab);
@@ -117437,14 +117582,12 @@
117582
117583 /* Make sure the old name really is a column name in the table to be
117584 ** altered. Set iCol to be the index of the column being renamed */
117585 zOld = sqlite3NameFromToken(db, pOld);
117586 if( !zOld ) goto exit_rename_column;
117587 iCol = sqlite3ColumnIndex(pTab, zOld);
117588 if( iCol<0 ){
 
 
117589 sqlite3ErrorMsg(pParse, "no such column: \"%T\"", pOld);
117590 goto exit_rename_column;
117591 }
117592
117593 /* Ensure the schema contains no double-quoted strings */
@@ -119339,11 +119482,12 @@
119482 ** of the new table in register pParse->regRoot. This is important
119483 ** because the OpenWrite opcode below will be needing it. */
119484 sqlite3NestedParse(pParse,
119485 "CREATE TABLE %Q.%s(%s)", pDb->zDbSName, zTab, aTable[i].zCols
119486 );
119487 assert( pParse->isCreate || pParse->nErr );
119488 aRoot[i] = (u32)pParse->u1.cr.regRoot;
119489 aCreateTbl[i] = OPFLAG_P2ISREG;
119490 }
119491 }else{
119492 /* The table already exists. If zWhere is not NULL, delete all entries
119493 ** associated with the table zWhere. If zWhere is NULL, delete the
@@ -119530,11 +119674,11 @@
119674 ){
119675 StatAccum *p;
119676 int nCol; /* Number of columns in index being sampled */
119677 int nKeyCol; /* Number of key columns */
119678 int nColUp; /* nCol rounded up for alignment */
119679 i64 n; /* Bytes of space to allocate */
119680 sqlite3 *db = sqlite3_context_db_handle(context); /* Database connection */
119681 #ifdef SQLITE_ENABLE_STAT4
119682 /* Maximum number of samples. 0 if STAT4 data is not collected */
119683 int mxSample = OptimizationEnabled(db,SQLITE_Stat4) ?SQLITE_STAT4_SAMPLES :0;
119684 #endif
@@ -121304,11 +121448,11 @@
121448 if( db->aDb==db->aDbStatic ){
121449 aNew = sqlite3DbMallocRawNN(db, sizeof(db->aDb[0])*3 );
121450 if( aNew==0 ) return;
121451 memcpy(aNew, db->aDb, sizeof(db->aDb[0])*2);
121452 }else{
121453 aNew = sqlite3DbRealloc(db, db->aDb, sizeof(db->aDb[0])*(1+(i64)db->nDb));
121454 if( aNew==0 ) return;
121455 }
121456 db->aDb = aNew;
121457 pNew = &db->aDb[db->nDb];
121458 memset(pNew, 0, sizeof(*pNew));
@@ -121322,10 +121466,16 @@
121466 if( rc!=SQLITE_OK ){
121467 if( rc==SQLITE_NOMEM ) sqlite3OomFault(db);
121468 sqlite3_result_error(context, zErr, -1);
121469 sqlite3_free(zErr);
121470 return;
121471 }
121472 if( (db->flags & SQLITE_AttachWrite)==0 ){
121473 flags &= ~(SQLITE_OPEN_CREATE|SQLITE_OPEN_READWRITE);
121474 flags |= SQLITE_OPEN_READONLY;
121475 }else if( (db->flags & SQLITE_AttachCreate)==0 ){
121476 flags &= ~SQLITE_OPEN_CREATE;
121477 }
121478 assert( pVfs );
121479 flags |= SQLITE_OPEN_MAIN_DB;
121480 rc = sqlite3BtreeOpen(pVfs, zPath, db, &pNew->pBt, 0, flags);
121481 db->nDb++;
@@ -122091,10 +122241,11 @@
122241 p->isWriteLock = (p->isWriteLock || isWriteLock);
122242 return;
122243 }
122244 }
122245
122246 assert( pToplevel->nTableLock < 0x7fff0000 );
122247 nBytes = sizeof(TableLock) * (pToplevel->nTableLock+1);
122248 pToplevel->aTableLock =
122249 sqlite3DbReallocOrFree(pToplevel->db, pToplevel->aTableLock, nBytes);
122250 if( pToplevel->aTableLock ){
122251 p = &pToplevel->aTableLock[pToplevel->nTableLock++];
@@ -122191,14 +122342,16 @@
122342 }
122343 assert( !pParse->isMultiWrite
122344 || sqlite3VdbeAssertMayAbort(v, pParse->mayAbort));
122345 if( v ){
122346 if( pParse->bReturning ){
122347 Returning *pReturning;
122348 int addrRewind;
122349 int reg;
122350
122351 assert( !pParse->isCreate );
122352 pReturning = pParse->u1.d.pReturning;
122353 if( pReturning->nRetCol ){
122354 sqlite3VdbeAddOp0(v, OP_FkCheck);
122355 addrRewind =
122356 sqlite3VdbeAddOp1(v, OP_Rewind, pReturning->iRetCur);
122357 VdbeCoverage(v);
@@ -122270,11 +122423,13 @@
122423 sqlite3ExprCode(pParse, pEL->a[i].pExpr, pEL->a[i].u.iConstExprReg);
122424 }
122425 }
122426
122427 if( pParse->bReturning ){
122428 Returning *pRet;
122429 assert( !pParse->isCreate );
122430 pRet = pParse->u1.d.pReturning;
122431 if( pRet->nRetCol ){
122432 sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pRet->iRetCur, pRet->nRetCol);
122433 }
122434 }
122435
@@ -123342,12 +123497,13 @@
123497 #endif
123498
123499 /* If the file format and encoding in the database have not been set,
123500 ** set them now.
123501 */
123502 assert( pParse->isCreate );
123503 reg1 = pParse->u1.cr.regRowid = ++pParse->nMem;
123504 reg2 = pParse->u1.cr.regRoot = ++pParse->nMem;
123505 reg3 = ++pParse->nMem;
123506 sqlite3VdbeAddOp3(v, OP_ReadCookie, iDb, reg3, BTREE_FILE_FORMAT);
123507 sqlite3VdbeUsesBtree(v, iDb);
123508 addr1 = sqlite3VdbeAddOp1(v, OP_If, reg3); VdbeCoverage(v);
123509 fileFormat = (db->flags & SQLITE_LegacyFileFmt)!=0 ?
@@ -123358,12 +123514,12 @@
123514
123515 /* This just creates a place-holder record in the sqlite_schema table.
123516 ** The record created does not contain anything yet. It will be replaced
123517 ** by the real entry in code generated at sqlite3EndTable().
123518 **
123519 ** The rowid for the new entry is left in register pParse->u1.cr.regRowid.
123520 ** The root page of the new table is left in reg pParse->u1.cr.regRoot.
123521 ** The rowid and root page number values are needed by the code that
123522 ** sqlite3EndTable will generate.
123523 */
123524 #if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_VIRTUALTABLE)
123525 if( isView || isVirtual ){
@@ -123370,11 +123526,11 @@
123526 sqlite3VdbeAddOp2(v, OP_Integer, 0, reg2);
123527 }else
123528 #endif
123529 {
123530 assert( !pParse->bReturning );
123531 pParse->u1.cr.addrCrTab =
123532 sqlite3VdbeAddOp3(v, OP_CreateBtree, iDb, reg2, BTREE_INTKEY);
123533 }
123534 sqlite3OpenSchemaTable(pParse, iDb);
123535 sqlite3VdbeAddOp2(v, OP_NewRowid, 0, reg1);
123536 sqlite3VdbeAddOp4(v, OP_Blob, 6, reg3, 0, nullRow, P4_STATIC);
@@ -123448,11 +123604,12 @@
123604 pRet = sqlite3DbMallocZero(db, sizeof(*pRet));
123605 if( pRet==0 ){
123606 sqlite3ExprListDelete(db, pList);
123607 return;
123608 }
123609 assert( !pParse->isCreate );
123610 pParse->u1.d.pReturning = pRet;
123611 pRet->pParse = pParse;
123612 pRet->pReturnEL = pList;
123613 sqlite3ParserAddCleanup(pParse, sqlite3DeleteReturning, pRet);
123614 testcase( pParse->earlyCleanup );
123615 if( db->mallocFailed ) return;
@@ -123490,11 +123647,10 @@
123647 int i;
123648 char *z;
123649 char *zType;
123650 Column *pCol;
123651 sqlite3 *db = pParse->db;
 
123652 Column *aNew;
123653 u8 eType = COLTYPE_CUSTOM;
123654 u8 szEst = 1;
123655 char affinity = SQLITE_AFF_BLOB;
123656
@@ -123544,17 +123700,14 @@
123700 if( z==0 ) return;
123701 if( IN_RENAME_OBJECT ) sqlite3RenameTokenMap(pParse, (void*)z, &sName);
123702 memcpy(z, sName.z, sName.n);
123703 z[sName.n] = 0;
123704 sqlite3Dequote(z);
123705 if( p->nCol && sqlite3ColumnIndex(p, z)>=0 ){
123706 sqlite3ErrorMsg(pParse, "duplicate column name: %s", z);
123707 sqlite3DbFree(db, z);
123708 return;
 
 
 
123709 }
123710 aNew = sqlite3DbRealloc(db,p->aCol,((i64)p->nCol+1)*sizeof(p->aCol[0]));
123711 if( aNew==0 ){
123712 sqlite3DbFree(db, z);
123713 return;
@@ -123561,11 +123714,11 @@
123714 }
123715 p->aCol = aNew;
123716 pCol = &p->aCol[p->nCol];
123717 memset(pCol, 0, sizeof(p->aCol[0]));
123718 pCol->zCnName = z;
123719 pCol->hName = sqlite3StrIHash(z);
123720 sqlite3ColumnPropertiesFromName(p, pCol);
123721
123722 if( sType.n==0 ){
123723 /* If there is no type specified, columns have the default affinity
123724 ** 'BLOB' with a default size of 4 bytes. */
@@ -123585,13 +123738,18 @@
123738 zType[sType.n] = 0;
123739 sqlite3Dequote(zType);
123740 pCol->affinity = sqlite3AffinityType(zType, pCol);
123741 pCol->colFlags |= COLFLAG_HASTYPE;
123742 }
123743 if( p->nCol<=0xff ){
123744 u8 h = pCol->hName % sizeof(p->aHx);
123745 p->aHx[h] = p->nCol;
123746 }
123747 p->nCol++;
123748 p->nNVCol++;
123749 assert( pParse->isCreate );
123750 pParse->u1.cr.constraintName.n = 0;
123751 }
123752
123753 /*
123754 ** This routine is called by the parser while in the middle of
123755 ** parsing a CREATE TABLE statement. A "NOT NULL" constraint has
@@ -123851,19 +124009,15 @@
124009 for(i=0; i<nTerm; i++){
124010 Expr *pCExpr = sqlite3ExprSkipCollate(pList->a[i].pExpr);
124011 assert( pCExpr!=0 );
124012 sqlite3StringToId(pCExpr);
124013 if( pCExpr->op==TK_ID ){
 
124014 assert( !ExprHasProperty(pCExpr, EP_IntValue) );
124015 iCol = sqlite3ColumnIndex(pTab, pCExpr->u.zToken);
124016 if( iCol>=0 ){
124017 pCol = &pTab->aCol[iCol];
124018 makeColumnPartOfPrimaryKey(pParse, pCol);
 
 
 
124019 }
124020 }
124021 }
124022 }
124023 if( nTerm==1
@@ -123911,12 +124065,14 @@
124065 sqlite3 *db = pParse->db;
124066 if( pTab && !IN_DECLARE_VTAB
124067 && !sqlite3BtreeIsReadonly(db->aDb[db->init.iDb].pBt)
124068 ){
124069 pTab->pCheck = sqlite3ExprListAppend(pParse, pTab->pCheck, pCheckExpr);
124070 assert( pParse->isCreate );
124071 if( pParse->u1.cr.constraintName.n ){
124072 sqlite3ExprListSetName(pParse, pTab->pCheck,
124073 &pParse->u1.cr.constraintName, 1);
124074 }else{
124075 Token t;
124076 for(zStart++; sqlite3Isspace(zStart[0]); zStart++){}
124077 while( sqlite3Isspace(zEnd[-1]) ){ zEnd--; }
124078 t.z = zStart;
@@ -124107,11 +124263,12 @@
124263 ** Generate a CREATE TABLE statement appropriate for the given
124264 ** table. Memory to hold the text of the statement is obtained
124265 ** from sqliteMalloc() and must be freed by the calling function.
124266 */
124267 static char *createTableStmt(sqlite3 *db, Table *p){
124268 int i, k, len;
124269 i64 n;
124270 char *zStmt;
124271 char *zSep, *zSep2, *zEnd;
124272 Column *pCol;
124273 n = 0;
124274 for(pCol = p->aCol, i=0; i<p->nCol; i++, pCol++){
@@ -124131,12 +124288,13 @@
124288 zStmt = sqlite3DbMallocRaw(0, n);
124289 if( zStmt==0 ){
124290 sqlite3OomFault(db);
124291 return 0;
124292 }
124293 assert( n>14 && n<=0x7fffffff );
124294 memcpy(zStmt, "CREATE TABLE ", 13);
124295 k = 13;
124296 identPut(zStmt, &k, p->zName);
124297 zStmt[k++] = '(';
124298 for(pCol=p->aCol, i=0; i<p->nCol; i++, pCol++){
124299 static const char * const azType[] = {
124300 /* SQLITE_AFF_BLOB */ "",
@@ -124144,17 +124302,19 @@
124302 /* SQLITE_AFF_NUMERIC */ " NUM",
124303 /* SQLITE_AFF_INTEGER */ " INT",
124304 /* SQLITE_AFF_REAL */ " REAL",
124305 /* SQLITE_AFF_FLEXNUM */ " NUM",
124306 };
 
124307 const char *zType;
124308
124309 len = sqlite3Strlen30(zSep);
124310 assert( k+len<n );
124311 memcpy(&zStmt[k], zSep, len);
124312 k += len;
124313 zSep = zSep2;
124314 identPut(zStmt, &k, pCol->zCnName);
124315 assert( k<n );
124316 assert( pCol->affinity-SQLITE_AFF_BLOB >= 0 );
124317 assert( pCol->affinity-SQLITE_AFF_BLOB < ArraySize(azType) );
124318 testcase( pCol->affinity==SQLITE_AFF_BLOB );
124319 testcase( pCol->affinity==SQLITE_AFF_TEXT );
124320 testcase( pCol->affinity==SQLITE_AFF_NUMERIC );
@@ -124165,15 +124325,18 @@
124325 zType = azType[pCol->affinity - SQLITE_AFF_BLOB];
124326 len = sqlite3Strlen30(zType);
124327 assert( pCol->affinity==SQLITE_AFF_BLOB
124328 || pCol->affinity==SQLITE_AFF_FLEXNUM
124329 || pCol->affinity==sqlite3AffinityType(zType, 0) );
124330 assert( k+len<n );
124331 memcpy(&zStmt[k], zType, len);
124332 k += len;
124333 assert( k<=n );
124334 }
124335 len = sqlite3Strlen30(zEnd);
124336 assert( k+len<n );
124337 memcpy(&zStmt[k], zEnd, len+1);
124338 return zStmt;
124339 }
124340
124341 /*
124342 ** Resize an Index object to hold N columns total. Return SQLITE_OK
@@ -124362,13 +124525,13 @@
124525
124526 /* Convert the P3 operand of the OP_CreateBtree opcode from BTREE_INTKEY
124527 ** into BTREE_BLOBKEY.
124528 */
124529 assert( !pParse->bReturning );
124530 if( pParse->u1.cr.addrCrTab ){
124531 assert( v );
124532 sqlite3VdbeChangeP3(v, pParse->u1.cr.addrCrTab, BTREE_BLOBKEY);
124533 }
124534
124535 /* Locate the PRIMARY KEY index. Or, if this table was originally
124536 ** an INTEGER PRIMARY KEY table, create a new PRIMARY KEY index.
124537 */
@@ -124804,11 +124967,11 @@
124967 #endif
124968 }
124969
124970 /* If this is a CREATE TABLE xx AS SELECT ..., execute the SELECT
124971 ** statement to populate the new table. The root-page number for the
124972 ** new table is in register pParse->u1.cr.regRoot.
124973 **
124974 ** Once the SELECT has been coded by sqlite3Select(), it is in a
124975 ** suitable state to query for the column names and types to be used
124976 ** by the new table.
124977 **
@@ -124835,11 +124998,12 @@
124998 iCsr = pParse->nTab++;
124999 regYield = ++pParse->nMem;
125000 regRec = ++pParse->nMem;
125001 regRowid = ++pParse->nMem;
125002 sqlite3MayAbort(pParse);
125003 assert( pParse->isCreate );
125004 sqlite3VdbeAddOp3(v, OP_OpenWrite, iCsr, pParse->u1.cr.regRoot, iDb);
125005 sqlite3VdbeChangeP5(v, OPFLAG_P2ISREG);
125006 addrTop = sqlite3VdbeCurrentAddr(v) + 1;
125007 sqlite3VdbeAddOp3(v, OP_InitCoroutine, regYield, 0, addrTop);
125008 if( pParse->nErr ) return;
125009 pSelTab = sqlite3ResultSetOfSelect(pParse, pSelect, SQLITE_AFF_BLOB);
@@ -124880,21 +125044,22 @@
125044
125045 /* A slot for the record has already been allocated in the
125046 ** schema table. We just need to update that slot with all
125047 ** the information we've collected.
125048 */
125049 assert( pParse->isCreate );
125050 sqlite3NestedParse(pParse,
125051 "UPDATE %Q." LEGACY_SCHEMA_TABLE
125052 " SET type='%s', name=%Q, tbl_name=%Q, rootpage=#%d, sql=%Q"
125053 " WHERE rowid=#%d",
125054 db->aDb[iDb].zDbSName,
125055 zType,
125056 p->zName,
125057 p->zName,
125058 pParse->u1.cr.regRoot,
125059 zStmt,
125060 pParse->u1.cr.regRowid
125061 );
125062 sqlite3DbFree(db, zStmt);
125063 sqlite3ChangeCookie(pParse, iDb);
125064
125065 #ifndef SQLITE_OMIT_AUTOINCREMENT
@@ -125861,11 +126026,11 @@
126026 i16 nCol, /* Total number of columns in the index */
126027 int nExtra, /* Number of bytes of extra space to alloc */
126028 char **ppExtra /* Pointer to the "extra" space */
126029 ){
126030 Index *p; /* Allocated index object */
126031 i64 nByte; /* Bytes of space for Index object + arrays */
126032
126033 nByte = ROUND8(sizeof(Index)) + /* Index structure */
126034 ROUND8(sizeof(char*)*nCol) + /* Index.azColl */
126035 ROUND8(sizeof(LogEst)*(nCol+1) + /* Index.aiRowLogEst */
126036 sizeof(i16)*nCol + /* Index.aiColumn */
@@ -126714,11 +126879,10 @@
126879 */
126880 SQLITE_PRIVATE void sqlite3IdListDelete(sqlite3 *db, IdList *pList){
126881 int i;
126882 assert( db!=0 );
126883 if( pList==0 ) return;
 
126884 for(i=0; i<pList->nId; i++){
126885 sqlite3DbFree(db, pList->a[i].zName);
126886 }
126887 sqlite3DbNNFreeNN(db, pList);
126888 }
@@ -128095,16 +128259,22 @@
128259 FuncDef *p, /* The function we are evaluating for match quality */
128260 int nArg, /* Desired number of arguments. (-1)==any */
128261 u8 enc /* Desired text encoding */
128262 ){
128263 int match;
128264 assert( p->nArg>=(-4) && p->nArg!=(-2) );
128265 assert( nArg>=(-2) );
128266
128267 /* Wrong number of arguments means "no match" */
128268 if( p->nArg!=nArg ){
128269 if( nArg==(-2) ) return p->xSFunc==0 ? 0 : FUNC_PERFECT_MATCH;
128270 if( p->nArg>=0 ) return 0;
128271 /* Special p->nArg values available to built-in functions only:
128272 ** -3 1 or more arguments required
128273 ** -4 2 or more arguments required
128274 */
128275 if( p->nArg<(-2) && nArg<(-2-p->nArg) ) return 0;
128276 }
128277
128278 /* Give a better score to a function with a specific number of arguments
128279 ** than to function that accepts any number of arguments. */
128280 if( p->nArg==nArg ){
@@ -129723,20 +129893,14 @@
129893 const unsigned char *z;
129894 const unsigned char *z2;
129895 int len;
129896 int p0type;
129897 i64 p1, p2;
 
129898
129899 assert( argc==3 || argc==2 );
 
 
 
 
 
129900 p0type = sqlite3_value_type(argv[0]);
129901 p1 = sqlite3_value_int64(argv[1]);
129902 if( p0type==SQLITE_BLOB ){
129903 len = sqlite3_value_bytes(argv[0]);
129904 z = sqlite3_value_blob(argv[0]);
129905 if( z==0 ) return;
129906 assert( len==sqlite3_value_bytes(argv[0]) );
@@ -129748,45 +129912,49 @@
129912 for(z2=z; *z2; len++){
129913 SQLITE_SKIP_UTF8(z2);
129914 }
129915 }
129916 }
 
 
 
 
 
 
 
 
129917 if( argc==3 ){
129918 p2 = sqlite3_value_int64(argv[2]);
129919 if( p2==0 && sqlite3_value_type(argv[2])==SQLITE_NULL ) return;
 
 
 
129920 }else{
129921 p2 = sqlite3_context_db_handle(context)->aLimit[SQLITE_LIMIT_LENGTH];
129922 }
129923 if( p1==0 ){
129924 #ifdef SQLITE_SUBSTR_COMPATIBILITY
129925 /* If SUBSTR_COMPATIBILITY is defined then substr(X,0,N) work the same as
129926 ** as substr(X,1,N) - it returns the first N characters of X. This
129927 ** is essentially a back-out of the bug-fix in check-in [5fc125d362df4b8]
129928 ** from 2009-02-02 for compatibility of applications that exploited the
129929 ** old buggy behavior. */
129930 p1 = 1; /* <rdar://problem/6778339> */
129931 #endif
129932 if( sqlite3_value_type(argv[1])==SQLITE_NULL ) return;
129933 }
129934 if( p1<0 ){
129935 p1 += len;
129936 if( p1<0 ){
129937 if( p2<0 ){
129938 p2 = 0;
129939 }else{
129940 p2 += p1;
129941 }
129942 p1 = 0;
129943 }
129944 }else if( p1>0 ){
129945 p1--;
129946 }else if( p2>0 ){
129947 p2--;
129948 }
129949 if( p2<0 ){
129950 if( p2<-p1 ){
129951 p2 = p1;
129952 }else{
129953 p2 = -p2;
129954 }
129955 p1 -= p2;
 
 
 
 
129956 }
129957 assert( p1>=0 && p2>=0 );
129958 if( p0type!=SQLITE_BLOB ){
129959 while( *z && p1 ){
129960 SQLITE_SKIP_UTF8(z);
@@ -129796,13 +129964,15 @@
129964 SQLITE_SKIP_UTF8(z2);
129965 }
129966 sqlite3_result_text64(context, (char*)z, z2-z, SQLITE_TRANSIENT,
129967 SQLITE_UTF8);
129968 }else{
129969 if( p1>=len ){
129970 p1 = p2 = 0;
129971 }else if( p2>len-p1 ){
129972 p2 = len-p1;
129973 assert( p2>0 );
129974 }
129975 sqlite3_result_blob64(context, (char*)&z[p1], (u64)p2, SQLITE_TRANSIENT);
129976 }
129977 }
129978
@@ -129809,17 +129979,17 @@
129979 /*
129980 ** Implementation of the round() function
129981 */
129982 #ifndef SQLITE_OMIT_FLOATING_POINT
129983 static void roundFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
129984 i64 n = 0;
129985 double r;
129986 char *zBuf;
129987 assert( argc==1 || argc==2 );
129988 if( argc==2 ){
129989 if( SQLITE_NULL==sqlite3_value_type(argv[1]) ) return;
129990 n = sqlite3_value_int64(argv[1]);
129991 if( n>30 ) n = 30;
129992 if( n<0 ) n = 0;
129993 }
129994 if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return;
129995 r = sqlite3_value_double(argv[0]);
@@ -129830,11 +130000,11 @@
130000 if( r<-4503599627370496.0 || r>+4503599627370496.0 ){
130001 /* The value has no fractional part so there is nothing to round */
130002 }else if( n==0 ){
130003 r = (double)((sqlite_int64)(r+(r<0?-0.5:+0.5)));
130004 }else{
130005 zBuf = sqlite3_mprintf("%!.*f",(int)n,r);
130006 if( zBuf==0 ){
130007 sqlite3_result_error_nomem(context);
130008 return;
130009 }
130010 sqlite3AtoF(zBuf, &r, sqlite3Strlen30(zBuf), SQLITE_UTF8);
@@ -130789,11 +130959,11 @@
130959 if( zRep==0 ) return;
130960 nRep = sqlite3_value_bytes(argv[2]);
130961 assert( zRep==sqlite3_value_text(argv[2]) );
130962 nOut = nStr + 1;
130963 assert( nOut<SQLITE_MAX_LENGTH );
130964 zOut = contextMalloc(context, nOut);
130965 if( zOut==0 ){
130966 return;
130967 }
130968 loopLimit = nStr - nPattern;
130969 cntExpand = 0;
@@ -130939,11 +131109,11 @@
131109 int i;
131110 char *z;
131111 for(i=0; i<argc; i++){
131112 n += sqlite3_value_bytes(argv[i]);
131113 }
131114 n += (argc-1)*(i64)nSep;
131115 z = sqlite3_malloc64(n+1);
131116 if( z==0 ){
131117 sqlite3_result_error_nomem(context);
131118 return;
131119 }
@@ -131237,11 +131407,14 @@
131407 ** to initialize it */
131408 if( ALWAYS(p) && type!=SQLITE_NULL ){
131409 assert( p->cnt>0 );
131410 p->cnt--;
131411 if( !p->approx ){
131412 if( sqlite3SubInt64(&p->iSum, sqlite3_value_int64(argv[0])) ){
131413 p->ovrfl = 1;
131414 p->approx = 1;
131415 }
131416 }else if( type==SQLITE_INTEGER ){
131417 i64 iVal = sqlite3_value_int64(argv[0]);
131418 if( iVal!=SMALLEST_INT64 ){
131419 kahanBabuskaNeumaierStepInt64(p, -iVal);
131420 }else{
@@ -132063,16 +132236,14 @@
132236 FUNCTION(ltrim, 2, 1, 0, trimFunc ),
132237 FUNCTION(rtrim, 1, 2, 0, trimFunc ),
132238 FUNCTION(rtrim, 2, 2, 0, trimFunc ),
132239 FUNCTION(trim, 1, 3, 0, trimFunc ),
132240 FUNCTION(trim, 2, 3, 0, trimFunc ),
132241 FUNCTION(min, -3, 0, 1, minmaxFunc ),
 
132242 WAGGREGATE(min, 1, 0, 1, minmaxStep, minMaxFinalize, minMaxValue, 0,
132243 SQLITE_FUNC_MINMAX|SQLITE_FUNC_ANYORDER ),
132244 FUNCTION(max, -3, 1, 1, minmaxFunc ),
 
132245 WAGGREGATE(max, 1, 1, 1, minmaxStep, minMaxFinalize, minMaxValue, 0,
132246 SQLITE_FUNC_MINMAX|SQLITE_FUNC_ANYORDER ),
132247 FUNCTION2(typeof, 1, 0, 0, typeofFunc, SQLITE_FUNC_TYPEOF),
132248 FUNCTION2(subtype, 1, 0, 0, subtypeFunc,
132249 SQLITE_FUNC_TYPEOF|SQLITE_SUBTYPE),
@@ -132095,15 +132266,12 @@
132266 FUNCTION(upper, 1, 0, 0, upperFunc ),
132267 FUNCTION(lower, 1, 0, 0, lowerFunc ),
132268 FUNCTION(hex, 1, 0, 0, hexFunc ),
132269 FUNCTION(unhex, 1, 0, 0, unhexFunc ),
132270 FUNCTION(unhex, 2, 0, 0, unhexFunc ),
132271 FUNCTION(concat, -3, 0, 0, concatFunc ),
132272 FUNCTION(concat_ws, -4, 0, 0, concatwsFunc ),
 
 
 
132273 INLINE_FUNC(ifnull, 2, INLINEFUNC_coalesce, 0 ),
132274 VFUNCTION(random, 0, 0, 0, randomFunc ),
132275 VFUNCTION(randomblob, 1, 0, 0, randomBlob ),
132276 FUNCTION(nullif, 2, 0, 1, nullifFunc ),
132277 DFUNCTION(sqlite_version, 0, 0, 0, versionFunc ),
@@ -132143,12 +132311,10 @@
132311 LIKEFUNC(like, 3, &likeInfoNorm, SQLITE_FUNC_LIKE),
132312 #endif
132313 #ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION
132314 FUNCTION(unknown, -1, 0, 0, unknownFunc ),
132315 #endif
 
 
132316 #ifdef SQLITE_ENABLE_MATH_FUNCTIONS
132317 MFUNCTION(ceil, 1, xCeil, ceilingFunc ),
132318 MFUNCTION(ceiling, 1, xCeil, ceilingFunc ),
132319 MFUNCTION(floor, 1, xFloor, ceilingFunc ),
132320 #if SQLITE_HAVE_C99_MATH_FUNCS
@@ -132182,15 +132348,13 @@
132348 MFUNCTION(radians, 1, degToRad, math1Func ),
132349 MFUNCTION(degrees, 1, radToDeg, math1Func ),
132350 MFUNCTION(pi, 0, 0, piFunc ),
132351 #endif /* SQLITE_ENABLE_MATH_FUNCTIONS */
132352 FUNCTION(sign, 1, 0, 0, signFunc ),
132353 INLINE_FUNC(coalesce, -4, INLINEFUNC_coalesce, 0 ),
132354 INLINE_FUNC(iif, -4, INLINEFUNC_iif, 0 ),
132355 INLINE_FUNC(if, -4, INLINEFUNC_iif, 0 ),
 
 
132356 };
132357 #ifndef SQLITE_OMIT_ALTERTABLE
132358 sqlite3AlterFunctions();
132359 #endif
132360 sqlite3WindowFunctions();
@@ -134632,10 +134796,11 @@
134796 int regRowCount = 0; /* Memory cell used for the row counter */
134797 int regIns; /* Block of regs holding rowid+data being inserted */
134798 int regRowid; /* registers holding insert rowid */
134799 int regData; /* register holding first column to insert */
134800 int *aRegIdx = 0; /* One register allocated to each index */
134801 int *aTabColMap = 0; /* Mapping from pTab columns to pCol entries */
134802
134803 #ifndef SQLITE_OMIT_TRIGGER
134804 int isView; /* True if attempting to insert into a view */
134805 Trigger *pTrigger; /* List of triggers on pTab, if required */
134806 int tmask; /* Mask of trigger times */
@@ -134776,35 +134941,29 @@
134941 ** columns into storage order. False negatives are harmless,
134942 ** but false positives will cause database corruption.
134943 */
134944 bIdListInOrder = (pTab->tabFlags & (TF_OOOHidden|TF_HasStored))==0;
134945 if( pColumn ){
134946 aTabColMap = sqlite3DbMallocZero(db, pTab->nCol*sizeof(int));
134947 if( aTabColMap==0 ) goto insert_cleanup;
134948 for(i=0; i<pColumn->nId; i++){
134949 j = sqlite3ColumnIndex(pTab, pColumn->a[i].zName);
134950 if( j>=0 ){
134951 if( aTabColMap[j]==0 ) aTabColMap[j] = i+1;
134952 if( i!=j ) bIdListInOrder = 0;
134953 if( j==pTab->iPKey ){
134954 ipkColumn = i; assert( !withoutRowid );
134955 }
134956 #ifndef SQLITE_OMIT_GENERATED_COLUMNS
134957 if( pTab->aCol[j].colFlags & (COLFLAG_STORED|COLFLAG_VIRTUAL) ){
134958 sqlite3ErrorMsg(pParse,
134959 "cannot INSERT into generated column \"%s\"",
134960 pTab->aCol[j].zCnName);
134961 goto insert_cleanup;
134962 }
134963 #endif
134964 }else{
 
 
 
 
 
 
134965 if( sqlite3IsRowid(pColumn->a[i].zName) && !withoutRowid ){
134966 ipkColumn = i;
134967 bIdListInOrder = 0;
134968 }else{
134969 sqlite3ErrorMsg(pParse, "table %S has no column named %s",
@@ -135098,29 +135257,29 @@
135257 sqlite3VdbeAddOp1(v, OP_SoftNull, iRegStore);
135258 }
135259 continue;
135260 }else if( pColumn==0 ){
135261 /* Hidden columns that are not explicitly named in the INSERT
135262 ** get their default value */
135263 sqlite3ExprCodeFactorable(pParse,
135264 sqlite3ColumnExpr(pTab, &pTab->aCol[i]),
135265 iRegStore);
135266 continue;
135267 }
135268 }
135269 if( pColumn ){
135270 j = aTabColMap[i];
135271 assert( j>=0 && j<=pColumn->nId );
135272 if( j==0 ){
135273 /* A column not named in the insert column list gets its
135274 ** default value */
135275 sqlite3ExprCodeFactorable(pParse,
135276 sqlite3ColumnExpr(pTab, &pTab->aCol[i]),
135277 iRegStore);
135278 continue;
135279 }
135280 k = j - 1;
135281 }else if( nColumn==0 ){
135282 /* This is INSERT INTO ... DEFAULT VALUES. Load the default value. */
135283 sqlite3ExprCodeFactorable(pParse,
135284 sqlite3ColumnExpr(pTab, &pTab->aCol[i]),
135285 iRegStore);
@@ -135361,11 +135520,14 @@
135520 insert_cleanup:
135521 sqlite3SrcListDelete(db, pTabList);
135522 sqlite3ExprListDelete(db, pList);
135523 sqlite3UpsertDelete(db, pUpsert);
135524 sqlite3SelectDelete(db, pSelect);
135525 if( pColumn ){
135526 sqlite3IdListDelete(db, pColumn);
135527 sqlite3DbFree(db, aTabColMap);
135528 }
135529 if( aRegIdx ) sqlite3DbNNFreeNN(db, aRegIdx);
135530 }
135531
135532 /* Make sure "isView" and other macros defined above are undefined. Otherwise
135533 ** they may interfere with compilation of other functions in this file
@@ -140708,11 +140870,14 @@
140870 ){
140871 db->flags |= mask;
140872 }
140873 }else{
140874 db->flags &= ~mask;
140875 if( mask==SQLITE_DeferFKs ){
140876 db->nDeferredImmCons = 0;
140877 db->nDeferredCons = 0;
140878 }
140879 if( (mask & SQLITE_WriteSchema)!=0
140880 && sqlite3_stricmp(zRight, "reset")==0
140881 ){
140882 /* IMP: R-60817-01178 If the argument is "RESET" then schema
140883 ** writing is disabled (as with "PRAGMA writable_schema=OFF") and,
@@ -141316,11 +141481,11 @@
141481 sqlite3VdbeAddOp3(v, OP_Null, 0, 8, 8+cnt);
141482 sqlite3ClearTempRegCache(pParse);
141483
141484 /* Do the b-tree integrity checks */
141485 sqlite3VdbeAddOp4(v, OP_IntegrityCk, 1, cnt, 8, (char*)aRoot,P4_INTARRAY);
141486 sqlite3VdbeChangeP5(v, (u16)i);
141487 addr = sqlite3VdbeAddOp1(v, OP_IsNull, 2); VdbeCoverage(v);
141488 sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0,
141489 sqlite3MPrintf(db, "*** in database %s ***\n", db->aDb[i].zDbSName),
141490 P4_DYNAMIC);
141491 sqlite3VdbeAddOp3(v, OP_Concat, 2, 3, 3);
@@ -144042,14 +144207,37 @@
144207 ** Return the index of a column in a table. Return -1 if the column
144208 ** is not contained in the table.
144209 */
144210 SQLITE_PRIVATE int sqlite3ColumnIndex(Table *pTab, const char *zCol){
144211 int i;
144212 u8 h;
144213 const Column *aCol;
144214 int nCol;
144215
144216 h = sqlite3StrIHash(zCol);
144217 aCol = pTab->aCol;
144218 nCol = pTab->nCol;
144219
144220 /* See if the aHx gives us a lucky match */
144221 i = pTab->aHx[h % sizeof(pTab->aHx)];
144222 assert( i<nCol );
144223 if( aCol[i].hName==h
144224 && sqlite3StrICmp(aCol[i].zCnName, zCol)==0
144225 ){
144226 return i;
144227 }
144228
144229 /* No lucky match from the hash table. Do a full search. */
144230 i = 0;
144231 while( 1 /*exit-by-break*/ ){
144232 if( aCol[i].hName==h
144233 && sqlite3StrICmp(aCol[i].zCnName, zCol)==0
144234 ){
144235 return i;
144236 }
144237 i++;
144238 if( i>=nCol ) break;
144239 }
144240 return -1;
144241 }
144242
144243 /*
@@ -150549,11 +150737,11 @@
150737 }
150738 sqlite3ReleaseTempReg(pParse, regSubtype);
150739 }
150740 sqlite3VdbeAddOp3(v, OP_AggStep, 0, regAgg, AggInfoFuncReg(pAggInfo,i));
150741 sqlite3VdbeAppendP4(v, pF->pFunc, P4_FUNCDEF);
150742 sqlite3VdbeChangeP5(v, (u16)nArg);
150743 sqlite3VdbeAddOp2(v, OP_Next, pF->iOBTab, iTop+1); VdbeCoverage(v);
150744 sqlite3VdbeJumpHere(v, iTop);
150745 sqlite3ReleaseTempRange(pParse, regAgg, nArg);
150746 }
150747 sqlite3VdbeAddOp2(v, OP_AggFinal, AggInfoFuncReg(pAggInfo,i),
@@ -150712,11 +150900,11 @@
150900 sqlite3VdbeAddOp4(v, OP_CollSeq, regHit, 0, 0,
150901 (char *)pColl, P4_COLLSEQ);
150902 }
150903 sqlite3VdbeAddOp3(v, OP_AggStep, 0, regAgg, AggInfoFuncReg(pAggInfo,i));
150904 sqlite3VdbeAppendP4(v, pF->pFunc, P4_FUNCDEF);
150905 sqlite3VdbeChangeP5(v, (u16)nArg);
150906 sqlite3ReleaseTempRange(pParse, regAgg, nArg);
150907 }
150908 if( addrNext ){
150909 sqlite3VdbeResolveLabel(v, addrNext);
150910 }
@@ -152767,11 +152955,12 @@
152955 }else if( pTrig->op==TK_RETURNING ){
152956 #ifndef SQLITE_OMIT_VIRTUALTABLE
152957 assert( pParse->db->pVtabCtx==0 );
152958 #endif
152959 assert( pParse->bReturning );
152960 assert( !pParse->isCreate );
152961 assert( &(pParse->u1.d.pReturning->retTrig) == pTrig );
152962 pTrig->table = pTab->zName;
152963 pTrig->pTabSchema = pTab->pSchema;
152964 pTrig->pNext = pList;
152965 pList = pTrig;
152966 }
@@ -153744,11 +153933,12 @@
153933 /* This RETURNING trigger must be for a different statement as
153934 ** this statement lacks a RETURNING clause. */
153935 return;
153936 }
153937 assert( db->pParse==pParse );
153938 assert( !pParse->isCreate );
153939 pReturning = pParse->u1.d.pReturning;
153940 if( pTrigger != &(pReturning->retTrig) ){
153941 /* This RETURNING trigger is for a different statement */
153942 return;
153943 }
153944 memset(&sSelect, 0, sizeof(sSelect));
@@ -153974,10 +154164,12 @@
154164 sSubParse.pToplevel = pTop;
154165 sSubParse.zAuthContext = pTrigger->zName;
154166 sSubParse.eTriggerOp = pTrigger->op;
154167 sSubParse.nQueryLoop = pParse->nQueryLoop;
154168 sSubParse.prepFlags = pParse->prepFlags;
154169 sSubParse.oldmask = 0;
154170 sSubParse.newmask = 0;
154171
154172 v = sqlite3GetVdbe(&sSubParse);
154173 if( v ){
154174 VdbeComment((v, "Start: %s.%s (%s %s%s%s ON %s)",
154175 pTrigger->zName, onErrorText(orconf),
@@ -154106,11 +154298,11 @@
154298 /* Set the P5 operand of the OP_Program instruction to non-zero if
154299 ** recursive invocation of this trigger program is disallowed. Recursive
154300 ** invocation is disallowed if (a) the sub-program is really a trigger,
154301 ** not a foreign key action, and (b) the flag to enable recursive triggers
154302 ** is clear. */
154303 sqlite3VdbeChangeP5(v, (u16)bRecursive);
154304 }
154305 }
154306
154307 /*
154308 ** This is called to code the required FOR EACH ROW triggers for an operation
@@ -154728,42 +154920,36 @@
154920 ** column to be updated, make sure we have authorization to change
154921 ** that column.
154922 */
154923 chngRowid = chngPk = 0;
154924 for(i=0; i<pChanges->nExpr; i++){
 
154925 /* If this is an UPDATE with a FROM clause, do not resolve expressions
154926 ** here. The call to sqlite3Select() below will do that. */
154927 if( nChangeFrom==0 && sqlite3ResolveExprNames(&sNC, pChanges->a[i].pExpr) ){
154928 goto update_cleanup;
154929 }
154930 j = sqlite3ColumnIndex(pTab, pChanges->a[i].zEName);
154931 if( j>=0 ){
154932 if( j==pTab->iPKey ){
154933 chngRowid = 1;
154934 pRowidExpr = pChanges->a[i].pExpr;
154935 iRowidExpr = i;
154936 }else if( pPk && (pTab->aCol[j].colFlags & COLFLAG_PRIMKEY)!=0 ){
154937 chngPk = 1;
154938 }
 
 
154939 #ifndef SQLITE_OMIT_GENERATED_COLUMNS
154940 else if( pTab->aCol[j].colFlags & COLFLAG_GENERATED ){
154941 testcase( pTab->aCol[j].colFlags & COLFLAG_VIRTUAL );
154942 testcase( pTab->aCol[j].colFlags & COLFLAG_STORED );
154943 sqlite3ErrorMsg(pParse,
154944 "cannot UPDATE generated column \"%s\"",
154945 pTab->aCol[j].zCnName);
154946 goto update_cleanup;
154947 }
154948 #endif
154949 aXRef[j] = i;
154950 }else{
 
 
 
154951 if( pPk==0 && sqlite3IsRowid(pChanges->a[i].zEName) ){
154952 j = -1;
154953 chngRowid = 1;
154954 pRowidExpr = pChanges->a[i].pExpr;
154955 iRowidExpr = i;
@@ -156866,24 +157052,25 @@
157052
157053 /* A slot for the record has already been allocated in the
157054 ** schema table. We just need to update that slot with all
157055 ** the information we've collected.
157056 **
157057 ** The VM register number pParse->u1.cr.regRowid holds the rowid of an
157058 ** entry in the sqlite_schema table that was created for this vtab
157059 ** by sqlite3StartTable().
157060 */
157061 iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
157062 assert( pParse->isCreate );
157063 sqlite3NestedParse(pParse,
157064 "UPDATE %Q." LEGACY_SCHEMA_TABLE " "
157065 "SET type='table', name=%Q, tbl_name=%Q, rootpage=0, sql=%Q "
157066 "WHERE rowid=#%d",
157067 db->aDb[iDb].zDbSName,
157068 pTab->zName,
157069 pTab->zName,
157070 zStmt,
157071 pParse->u1.cr.regRowid
157072 );
157073 v = sqlite3GetVdbe(pParse);
157074 sqlite3ChangeCookie(pParse, iDb);
157075
157076 sqlite3VdbeAddOp0(v, OP_Expire);
@@ -157217,11 +157404,13 @@
157404 ** sqlite3_declare_vtab() is being misused.
157405 */
157406 z = (const unsigned char*)zCreateTable;
157407 for(i=0; aKeyword[i]; i++){
157408 int tokenType = 0;
157409 do{
157410 z += sqlite3GetToken(z, &tokenType);
157411 }while( tokenType==TK_SPACE || tokenType==TK_COMMENT );
157412 if( tokenType!=aKeyword[i] ){
157413 sqlite3ErrorWithMsg(db, SQLITE_ERROR, "syntax error");
157414 return SQLITE_ERROR;
157415 }
157416 }
@@ -157948,12 +158137,14 @@
158137 u16 nLTerm; /* Number of entries in aLTerm[] */
158138 u16 nSkip; /* Number of NULL aLTerm[] entries */
158139 /**** whereLoopXfer() copies fields above ***********************/
158140 # define WHERE_LOOP_XFER_SZ offsetof(WhereLoop,nLSlot)
158141 u16 nLSlot; /* Number of slots allocated for aLTerm[] */
158142 #ifdef WHERETRACE_ENABLED
158143 LogEst rStarDelta; /* Cost delta due to star-schema heuristic. Not
158144 ** initialized unless pWInfo->bStarUsed */
158145 #endif
158146 WhereTerm **aLTerm; /* WhereTerms used */
158147 WhereLoop *pNextLoop; /* Next WhereLoop object in the WhereClause */
158148 WhereTerm *aLTermSpace[3]; /* Initial aLTerm[] space */
158149 };
158150
@@ -157998,11 +158189,11 @@
158189 struct WherePath {
158190 Bitmask maskLoop; /* Bitmask of all WhereLoop objects in this path */
158191 Bitmask revLoop; /* aLoop[]s that should be reversed for ORDER BY */
158192 LogEst nRow; /* Estimated number of rows generated by this path */
158193 LogEst rCost; /* Total cost of this path */
158194 LogEst rUnsort; /* Total cost of this path ignoring sorting costs */
158195 i8 isOrdered; /* No. of ORDER BY terms satisfied. -1 for unknown */
158196 WhereLoop **aLoop; /* Array of WhereLoop objects implementing this path */
158197 };
158198
158199 /*
@@ -158271,13 +158462,17 @@
158462 u8 eOnePass; /* ONEPASS_OFF, or _SINGLE, or _MULTI */
158463 u8 eDistinct; /* One of the WHERE_DISTINCT_* values */
158464 unsigned bDeferredSeek :1; /* Uses OP_DeferredSeek */
158465 unsigned untestedTerms :1; /* Not all WHERE terms resolved by outer loop */
158466 unsigned bOrderedInnerLoop:1;/* True if only the inner-most loop is ordered */
158467 unsigned sorted :1; /* True if really sorted (not just grouped) */
158468 unsigned bStarDone :1; /* True if check for star-query is complete */
158469 unsigned bStarUsed :1; /* True if star-query heuristic is used */
158470 LogEst nRowOut; /* Estimated number of output rows */
158471 #ifdef WHERETRACE_ENABLED
158472 LogEst rTotalCost; /* Total cost of the solution */
158473 #endif
158474 int iTop; /* The very beginning of the WHERE loop */
158475 int iEndWhere; /* End of the WHERE clause itself */
158476 WhereLoop *pLoops; /* List of all WhereLoop objects */
158477 WhereMemBlock *pMemToFree;/* Memory to free when this object destroyed */
158478 Bitmask revMask; /* Mask of ORDER BY terms that need reversing */
@@ -160029,10 +160224,13 @@
160224 }
160225 }
160226 }
160227 sqlite3VdbeAddOp2(v, OP_Integer, pLoop->u.vtab.idxNum, iReg);
160228 sqlite3VdbeAddOp2(v, OP_Integer, nConstraint, iReg+1);
160229 /* The instruction immediately prior to OP_VFilter must be an OP_Integer
160230 ** that sets the "argc" value for xVFilter. This is necessary for
160231 ** resolveP2() to work correctly. See tag-20250207a. */
160232 sqlite3VdbeAddOp4(v, OP_VFilter, iCur, addrNotFound, iReg,
160233 pLoop->u.vtab.idxStr,
160234 pLoop->u.vtab.needFree ? P4_DYNAMIC : P4_STATIC);
160235 VdbeCoverage(v);
160236 pLoop->u.vtab.needFree = 0;
@@ -161584,24 +161782,26 @@
161782 }else if( op==TK_STRING ){
161783 assert( !ExprHasProperty(pRight, EP_IntValue) );
161784 z = (u8*)pRight->u.zToken;
161785 }
161786 if( z ){
161787 /* Count the number of prefix bytes prior to the first wildcard,
161788 ** U+fffd character, or malformed utf-8. If the underlying database
161789 ** has a UTF16LE encoding, then only consider ASCII characters. Note that
161790 ** the encoding of z[] is UTF8 - we are dealing with only UTF8 here in this
161791 ** code, but the database engine itself might be processing content using a
161792 ** different encoding. */
161793 cnt = 0;
161794 while( (c=z[cnt])!=0 && c!=wc[0] && c!=wc[1] && c!=wc[2] ){
161795 cnt++;
161796 if( c==wc[3] && z[cnt]>0 && z[cnt]<0x80 ){
161797 cnt++;
161798 }else if( c>=0x80 ){
161799 const u8 *z2 = z+cnt-1;
161800 if( c==0xff || sqlite3Utf8Read(&z2)==0xfffd /* bad utf-8 */
161801 || ENC(db)==SQLITE_UTF16LE
161802 ){
161803 cnt--;
161804 break;
161805 }else{
161806 cnt = (int)(z2-z);
161807 }
@@ -162749,24 +162949,30 @@
162949 pStr2->u.zToken[i] = sqlite3Tolower(c);
162950 }
162951 }
162952
162953 if( !db->mallocFailed ){
162954 u8 *pC; /* Last character before the first wildcard */
162955 pC = (u8*)&pStr2->u.zToken[sqlite3Strlen30(pStr2->u.zToken)-1];
 
162956 if( noCase ){
162957 /* The point is to increment the last character before the first
162958 ** wildcard. But if we increment '@', that will push it into the
162959 ** alphabetic range where case conversions will mess up the
162960 ** inequality. To avoid this, make sure to also run the full
162961 ** LIKE on all candidate expressions by clearing the isComplete flag
162962 */
162963 if( *pC=='A'-1 ) isComplete = 0;
162964 *pC = sqlite3UpperToLower[*pC];
162965 }
162966
162967 /* Increment the value of the last utf8 character in the prefix. */
162968 while( *pC==0xBF && pC>(u8*)pStr2->u.zToken ){
162969 *pC = 0x80;
162970 pC--;
162971 }
162972 assert( *pC!=0xFF ); /* isLikeOrGlob() guarantees this */
162973 (*pC)++;
162974 }
162975 zCollSeqName = noCase ? "NOCASE" : sqlite3StrBINARY;
162976 pNewExpr1 = sqlite3ExprDup(db, pLeft, 0);
162977 pNewExpr1 = sqlite3PExpr(pParse, TK_GE,
162978 sqlite3ExprAddCollateString(pParse,pNewExpr1,zCollSeqName),
@@ -164130,10 +164336,15 @@
164336 **
164337 ** 2. If iCol is part of an existing index that has an aiRowLogEst of
164338 ** more than 20, then return false.
164339 **
164340 ** 3. If no disqualifying conditions above are found, return true.
164341 **
164342 ** 2025-01-03: I experimented with a new rule that returns false if the
164343 ** the datatype of the column is "BOOLEAN". This did not improve
164344 ** performance on any queries at hand, but it did burn CPU cycles, so the
164345 ** idea was not committed.
164346 */
164347 static SQLITE_NOINLINE int columnIsGoodIndexCandidate(
164348 const Table *pTab,
164349 int iCol
164350 ){
@@ -164214,11 +164425,11 @@
164425 char *zText = 0;
164426 int ii = 0;
164427 sqlite3_str *pStr = sqlite3_str_new(pParse->db);
164428 sqlite3_str_appendf(pStr,"CREATE AUTOMATIC INDEX ON %s(", pTab->zName);
164429 assert( pIdx->nColumn>1 );
164430 assert( pIdx->aiColumn[pIdx->nColumn-1]==XN_ROWID || !HasRowid(pTab) );
164431 for(ii=0; ii<(pIdx->nColumn-1); ii++){
164432 const char *zName = 0;
164433 int iCol = pIdx->aiColumn[ii];
164434
164435 zName = pTab->aCol[iCol].zCnName;
@@ -164344,10 +164555,23 @@
164555 */
164556 if( IsView(pTable) ){
164557 extraCols = ALLBITS & ~idxCols;
164558 }else{
164559 extraCols = pSrc->colUsed & (~idxCols | MASKBIT(BMS-1));
164560 }
164561 if( !HasRowid(pTable) ){
164562 /* For WITHOUT ROWID tables, ensure that all PRIMARY KEY columns are
164563 ** either in the idxCols mask or in the extraCols mask */
164564 for(i=0; i<pTable->nCol; i++){
164565 if( (pTable->aCol[i].colFlags & COLFLAG_PRIMKEY)==0 ) continue;
164566 if( i>=BMS-1 ){
164567 extraCols |= MASKBIT(BMS-1);
164568 break;
164569 }
164570 if( idxCols & MASKBIT(i) ) continue;
164571 extraCols |= MASKBIT(i);
164572 }
164573 }
164574 mxBitCol = MIN(BMS-1,pTable->nCol);
164575 testcase( pTable->nCol==BMS-1 );
164576 testcase( pTable->nCol==BMS-2 );
164577 for(i=0; i<mxBitCol; i++){
@@ -164356,11 +164580,12 @@
164580 if( pSrc->colUsed & MASKBIT(BMS-1) ){
164581 nKeyCol += pTable->nCol - BMS + 1;
164582 }
164583
164584 /* Construct the Index object to describe this index */
164585 pIdx = sqlite3AllocateIndexObject(pParse->db, nKeyCol+HasRowid(pTable),
164586 0, &zNotUsed);
164587 if( pIdx==0 ) goto end_auto_index_create;
164588 pLoop->u.btree.pIndex = pIdx;
164589 pIdx->zName = "auto-index";
164590 pIdx->pTable = pTable;
164591 n = 0;
@@ -164412,12 +164637,14 @@
164637 pIdx->azColl[n] = sqlite3StrBINARY;
164638 n++;
164639 }
164640 }
164641 assert( n==nKeyCol );
164642 if( HasRowid(pTable) ){
164643 pIdx->aiColumn[n] = XN_ROWID;
164644 pIdx->azColl[n] = sqlite3StrBINARY;
164645 }
164646
164647 /* Create the automatic index */
164648 explainAutomaticIndex(pParse, pIdx, pPartial!=0, &addrExp);
164649 assert( pLevel->iIdxCur>=0 );
164650 pLevel->iIdxCur = pParse->nTab++;
@@ -165680,21 +165907,23 @@
165907 ** | | | __|__ nEq ---. ___|__ | __|__
165908 ** | / \ / \ / \ | / \ / \ / \
165909 ** 1.002.001 t2.t2xy 2 f 010241 N 2 cost 0,56,31
165910 */
165911 SQLITE_PRIVATE void sqlite3WhereLoopPrint(const WhereLoop *p, const WhereClause *pWC){
165912 WhereInfo *pWInfo;
165913 if( pWC ){
165914 pWInfo = pWC->pWInfo;
165915 int nb = 1+(pWInfo->pTabList->nSrc+3)/4;
165916 SrcItem *pItem = pWInfo->pTabList->a + p->iTab;
165917 Table *pTab = pItem->pSTab;
165918 Bitmask mAll = (((Bitmask)1)<<(nb*4)) - 1;
165919 sqlite3DebugPrintf("%c%2d.%0*llx.%0*llx", p->cId,
165920 p->iTab, nb, p->maskSelf, nb, p->prereq & mAll);
165921 sqlite3DebugPrintf(" %12s",
165922 pItem->zAlias ? pItem->zAlias : pTab->zName);
165923 }else{
165924 pWInfo = 0;
165925 sqlite3DebugPrintf("%c%2d.%03llx.%03llx %c%d",
165926 p->cId, p->iTab, p->maskSelf, p->prereq & 0xfff, p->cId, p->iTab);
165927 }
165928 if( (p->wsFlags & WHERE_VIRTUALTABLE)==0 ){
165929 const char *zName;
@@ -165722,11 +165951,16 @@
165951 if( p->wsFlags & WHERE_SKIPSCAN ){
165952 sqlite3DebugPrintf(" f %06x %d-%d", p->wsFlags, p->nLTerm,p->nSkip);
165953 }else{
165954 sqlite3DebugPrintf(" f %06x N %d", p->wsFlags, p->nLTerm);
165955 }
165956 if( pWInfo && pWInfo->bStarUsed && p->rStarDelta!=0 ){
165957 sqlite3DebugPrintf(" cost %d,%d,%d delta=%d\n",
165958 p->rSetup, p->rRun, p->nOut, p->rStarDelta);
165959 }else{
165960 sqlite3DebugPrintf(" cost %d,%d,%d\n", p->rSetup, p->rRun, p->nOut);
165961 }
165962 if( p->nLTerm && (sqlite3WhereTrace & 0x4000)!=0 ){
165963 int i;
165964 for(i=0; i<p->nLTerm; i++){
165965 sqlite3WhereTermPrint(p->aLTerm[i], i);
165966 }
@@ -167188,11 +167422,10 @@
167422 if( !pBuilder->pOrSet /* Not part of an OR optimization */
167423 && (pWInfo->wctrlFlags & (WHERE_RIGHT_JOIN|WHERE_OR_SUBCLAUSE))==0
167424 && (pWInfo->pParse->db->flags & SQLITE_AutoIndex)!=0
167425 && !pSrc->fg.isIndexedBy /* Has no INDEXED BY clause */
167426 && !pSrc->fg.notIndexed /* Has no NOT INDEXED clause */
 
167427 && !pSrc->fg.isCorrelated /* Not a correlated subquery */
167428 && !pSrc->fg.isRecursive /* Not a recursive common table expression. */
167429 && (pSrc->fg.jointype & JT_RIGHT)==0 /* Not the right tab of a RIGHT JOIN */
167430 ){
167431 /* Generate auto-index WhereLoops */
@@ -168691,72 +168924,205 @@
168924 ** The value returned is a tuning parameter. Currently the value is:
168925 **
168926 ** 18 for star queries
168927 ** 12 otherwise
168928 **
168929 ** For the purposes of this heuristic, a star-query is defined as a query
168930 ** with a large central table that is joined using an INNER JOIN,
168931 ** not CROSS or OUTER JOINs, against four or more smaller tables.
168932 ** The central table is called the "fact" table. The smaller tables
168933 ** that get joined are "dimension tables". Also, any table that is
168934 ** self-joined cannot be a dimension table; we assume that dimension
168935 ** tables may only be joined against fact tables.
168936 **
168937 ** SIDE EFFECT: (and really the whole point of this subroutine)
168938 **
168939 ** If pWInfo describes a star-query, then the cost for SCANs of dimension
168940 ** WhereLoops is increased to be slightly larger than the cost of a SCAN
168941 ** in the fact table. Only SCAN costs are increased. SEARCH costs are
168942 ** unchanged. This heuristic helps keep fact tables in outer loops. Without
168943 ** this heuristic, paths with fact tables in outer loops tend to get pruned
168944 ** by the mxChoice limit on the number of paths, resulting in poor query
168945 ** plans. See the starschema1.test test module for examples of queries
168946 ** that need this heuristic to find good query plans.
168947 **
168948 ** This heuristic can be completely disabled, so that no query is
168949 ** considered a star-query, using SQLITE_TESTCTRL_OPTIMIZATION to
168950 ** disable the SQLITE_StarQuery optimization. In the CLI, the command
168951 ** to do that is: ".testctrl opt -starquery".
168952 **
168953 ** HISTORICAL NOTES:
168954 **
168955 ** This optimization was first added on 2024-05-09 by check-in 38db9b5c83d.
168956 ** The original optimization reduced the cost and output size estimate for
168957 ** fact tables to help them move to outer loops. But months later (as people
168958 ** started upgrading) performance regression reports started caming in,
168959 ** including:
168960 **
168961 ** forum post b18ef983e68d06d1 (2024-12-21)
168962 ** forum post 0025389d0860af82 (2025-01-14)
168963 ** forum post d87570a145599033 (2025-01-17)
168964 **
168965 ** To address these, the criteria for a star-query was tightened to exclude
168966 ** cases where the fact and dimensions are separated by an outer join, and
168967 ** the affect of star-schema detection was changed to increase the rRun cost
168968 ** on just full table scans of dimension tables, rather than reducing costs
168969 ** in the all access methods of the fact table.
168970 */
168971 static int computeMxChoice(WhereInfo *pWInfo){
168972 int nLoop = pWInfo->nLevel; /* Number of terms in the join */
168973 WhereLoop *pWLoop; /* For looping over WhereLoops */
168974
168975 #ifdef SQLITE_DEBUG
168976 /* The star-query detection code below makes use of the following
168977 ** properties of the WhereLoop list, so verify them before
168978 ** continuing:
168979 ** (1) .maskSelf is the bitmask corresponding to .iTab
168980 ** (2) The WhereLoop list is in ascending .iTab order
168981 */
168982 for(pWLoop=pWInfo->pLoops; pWLoop; pWLoop=pWLoop->pNextLoop){
168983 assert( pWLoop->maskSelf==MASKBIT(pWLoop->iTab) );
168984 assert( pWLoop->pNextLoop==0 || pWLoop->iTab<=pWLoop->pNextLoop->iTab );
168985 }
168986 #endif /* SQLITE_DEBUG */
168987
168988 if( nLoop>=5
168989 && !pWInfo->bStarDone
168990 && OptimizationEnabled(pWInfo->pParse->db, SQLITE_StarQuery)
168991 ){
168992 SrcItem *aFromTabs; /* All terms of the FROM clause */
168993 int iFromIdx; /* Term of FROM clause is the candidate fact-table */
168994 Bitmask m; /* Bitmask for candidate fact-table */
168995 Bitmask mSelfJoin = 0; /* Tables that cannot be dimension tables */
168996 WhereLoop *pStart; /* Where to start searching for dimension-tables */
168997
168998 pWInfo->bStarDone = 1; /* Only do this computation once */
168999
169000 /* Look for fact tables with four or more dimensions where the
169001 ** dimension tables are not separately from the fact tables by an outer
169002 ** or cross join. Adjust cost weights if found.
169003 */
169004 assert( !pWInfo->bStarUsed );
169005 aFromTabs = pWInfo->pTabList->a;
169006 pStart = pWInfo->pLoops;
169007 for(iFromIdx=0, m=1; iFromIdx<nLoop; iFromIdx++, m<<=1){
 
169008 int nDep = 0; /* Number of dimension tables */
169009 LogEst mxRun; /* Maximum SCAN cost of a fact table */
169010 Bitmask mSeen = 0; /* Mask of dimension tables */
169011 SrcItem *pFactTab; /* The candidate fact table */
169012
169013 pFactTab = aFromTabs + iFromIdx;
169014 if( (pFactTab->fg.jointype & (JT_OUTER|JT_CROSS))!=0 ){
169015 /* If the candidate fact-table is the right table of an outer join
169016 ** restrict the search for dimension-tables to be tables to the right
169017 ** of the fact-table. */
169018 if( iFromIdx+4 > nLoop ) break; /* Impossible to reach nDep>=4 */
169019 while( pStart && pStart->iTab<=iFromIdx ){
169020 pStart = pStart->pNextLoop;
169021 }
169022 }
169023 for(pWLoop=pStart; pWLoop; pWLoop=pWLoop->pNextLoop){
169024 if( (aFromTabs[pWLoop->iTab].fg.jointype & (JT_OUTER|JT_CROSS))!=0 ){
169025 /* Fact-tables and dimension-tables cannot be separated by an
169026 ** outer join (at least for the definition of fact- and dimension-
169027 ** used by this heuristic). */
169028 break;
169029 }
169030 if( (pWLoop->prereq & m)!=0 /* pWInfo depends on iFromIdx */
169031 && (pWLoop->maskSelf & mSeen)==0 /* pWInfo not already a dependency */
169032 && (pWLoop->maskSelf & mSelfJoin)==0 /* Not a self-join */
169033 ){
169034 if( aFromTabs[pWLoop->iTab].pSTab==pFactTab->pSTab ){
169035 mSelfJoin |= m;
169036 }else{
169037 nDep++;
169038 mSeen |= pWLoop->maskSelf;
169039 }
169040 }
169041 }
169042 if( nDep<=3 ) continue;
169043
169044 /* If we reach this point, it means that pFactTab is a fact table
169045 ** with four or more dimensions connected by inner joins. Proceed
169046 ** to make cost adjustments. */
169047
169048 #ifdef WHERETRACE_ENABLED
169049 /* Make sure rStarDelta values are initialized */
169050 if( !pWInfo->bStarUsed ){
 
 
169051 for(pWLoop=pWInfo->pLoops; pWLoop; pWLoop=pWLoop->pNextLoop){
169052 pWLoop->rStarDelta = 0;
169053 }
169054 }
169055 #endif
169056 pWInfo->bStarUsed = 1;
169057
169058 /* Compute the maximum cost of any WhereLoop for the
169059 ** fact table plus one epsilon */
169060 mxRun = LOGEST_MIN;
169061 for(pWLoop=pStart; pWLoop; pWLoop=pWLoop->pNextLoop){
169062 if( pWLoop->iTab<iFromIdx ) continue;
169063 if( pWLoop->iTab>iFromIdx ) break;
169064 if( pWLoop->rRun>mxRun ) mxRun = pWLoop->rRun;
169065 }
169066 if( ALWAYS(mxRun<LOGEST_MAX) ) mxRun++;
169067
169068 /* Increase the cost of table scans for dimension tables to be
169069 ** slightly more than the maximum cost of the fact table */
169070 for(pWLoop=pStart; pWLoop; pWLoop=pWLoop->pNextLoop){
169071 if( (pWLoop->maskSelf & mSeen)==0 ) continue;
169072 if( pWLoop->nLTerm ) continue;
169073 if( pWLoop->rRun<mxRun ){
169074 #ifdef WHERETRACE_ENABLED /* 0x80000 */
169075 if( sqlite3WhereTrace & 0x80000 ){
169076 SrcItem *pDim = aFromTabs + pWLoop->iTab;
169077 sqlite3DebugPrintf(
169078 "Increase SCAN cost of dimension %s(%d) of fact %s(%d) to %d\n",
169079 pDim->zAlias ? pDim->zAlias: pDim->pSTab->zName, pWLoop->iTab,
169080 pFactTab->zAlias ? pFactTab->zAlias : pFactTab->pSTab->zName,
169081 iFromIdx, mxRun
169082 );
169083 }
169084 pWLoop->rStarDelta = mxRun - pWLoop->rRun;
169085 #endif /* WHERETRACE_ENABLED */
169086 pWLoop->rRun = mxRun;
169087 }
169088 }
169089 }
169090 #ifdef WHERETRACE_ENABLED /* 0x80000 */
169091 if( (sqlite3WhereTrace & 0x80000)!=0 && pWInfo->bStarUsed ){
169092 sqlite3DebugPrintf("WhereLoops changed by star-query heuristic:\n");
169093 for(pWLoop=pWInfo->pLoops; pWLoop; pWLoop=pWLoop->pNextLoop){
169094 if( pWLoop->rStarDelta ){
169095 sqlite3WhereLoopPrint(pWLoop, &pWInfo->sWC);
 
 
169096 }
169097 }
169098 }
169099 #endif
169100 }
169101 return pWInfo->bStarUsed ? 18 : 12;
169102 }
169103
169104 /*
169105 ** Two WhereLoop objects, pCandidate and pBaseline, are known to have the
169106 ** same cost. Look deep into each to see if pCandidate is even slightly
169107 ** better than pBaseline. Return false if it is, if pCandidate is is preferred.
169108 ** Return true if pBaseline is preferred or if we cannot tell the difference.
169109 **
169110 ** Result Meaning
169111 ** -------- ----------------------------------------------------------
169112 ** true We cannot tell the difference in pCandidate and pBaseline
169113 ** false pCandidate seems like a better choice than pBaseline
169114 */
169115 static SQLITE_NOINLINE int whereLoopIsNoBetter(
169116 const WhereLoop *pCandidate,
169117 const WhereLoop *pBaseline
169118 ){
169119 if( (pCandidate->wsFlags & WHERE_INDEXED)==0 ) return 1;
169120 if( (pBaseline->wsFlags & WHERE_INDEXED)==0 ) return 1;
169121 if( pCandidate->u.btree.pIndex->szIdxRow <
169122 pBaseline->u.btree.pIndex->szIdxRow ) return 0;
169123 return 1;
169124 }
169125
169126 /*
169127 ** Given the list of WhereLoop objects at pWInfo->pLoops, this routine
169128 ** attempts to find the lowest cost path that visits each WhereLoop
@@ -168776,11 +169142,11 @@
169142 int iLoop; /* Loop counter over the terms of the join */
169143 int ii, jj; /* Loop counters */
169144 int mxI = 0; /* Index of next entry to replace */
169145 int nOrderBy; /* Number of ORDER BY clause terms */
169146 LogEst mxCost = 0; /* Maximum cost of a set of paths */
169147 LogEst mxUnsort = 0; /* Maximum unsorted cost of a set of path */
169148 int nTo, nFrom; /* Number of valid entries in aTo[] and aFrom[] */
169149 WherePath *aFrom; /* All nFrom paths at the previous level */
169150 WherePath *aTo; /* The nTo best paths at the current level */
169151 WherePath *pFrom; /* An element of aFrom[] that we are working on */
169152 WherePath *pTo; /* An element of aTo[] that we are working on */
@@ -168805,12 +169171,14 @@
169171 */
169172 if( nLoop<=1 ){
169173 mxChoice = 1;
169174 }else if( nLoop==2 ){
169175 mxChoice = 5;
169176 }else if( pParse->nErr ){
169177 mxChoice = 1;
169178 }else{
169179 mxChoice = computeMxChoice(pWInfo);
169180 }
169181 assert( nLoop<=pWInfo->pTabList->nSrc );
169182
169183 /* If nRowEst is zero and there is an ORDER BY clause, ignore it. In this
169184 ** case the purpose of this call is to estimate the number of rows returned
@@ -168873,11 +169241,11 @@
169241 nTo = 0;
169242 for(ii=0, pFrom=aFrom; ii<nFrom; ii++, pFrom++){
169243 for(pWLoop=pWInfo->pLoops; pWLoop; pWLoop=pWLoop->pNextLoop){
169244 LogEst nOut; /* Rows visited by (pFrom+pWLoop) */
169245 LogEst rCost; /* Cost of path (pFrom+pWLoop) */
169246 LogEst rUnsort; /* Unsorted cost of (pFrom+pWLoop) */
169247 i8 isOrdered; /* isOrdered for (pFrom+pWLoop) */
169248 Bitmask maskNew; /* Mask of src visited by (..) */
169249 Bitmask revMask; /* Mask of rev-order loops for (..) */
169250
169251 if( (pWLoop->prereq & ~pFrom->maskLoop)!=0 ) continue;
@@ -168891,15 +169259,15 @@
169259 continue;
169260 }
169261
169262 /* At this point, pWLoop is a candidate to be the next loop.
169263 ** Compute its cost */
169264 rUnsort = pWLoop->rRun + pFrom->nRow;
169265 if( pWLoop->rSetup ){
169266 rUnsort = sqlite3LogEstAdd(pWLoop->rSetup, rUnsort);
169267 }
169268 rUnsort = sqlite3LogEstAdd(rUnsort, pFrom->rUnsort);
169269 nOut = pFrom->nRow + pWLoop->nOut;
169270 maskNew = pFrom->maskLoop | pWLoop->maskSelf;
169271 isOrdered = pFrom->isOrdered;
169272 if( isOrdered<0 ){
169273 revMask = 0;
@@ -168917,19 +169285,19 @@
169285 }
169286 /* TUNING: Add a small extra penalty (3) to sorting as an
169287 ** extra encouragement to the query planner to select a plan
169288 ** where the rows emerge in the correct order without any sorting
169289 ** required. */
169290 rCost = sqlite3LogEstAdd(rUnsort, aSortCost[isOrdered]) + 3;
169291
169292 WHERETRACE(0x002,
169293 ("---- sort cost=%-3d (%d/%d) increases cost %3d to %-3d\n",
169294 aSortCost[isOrdered], (nOrderBy-isOrdered), nOrderBy,
169295 rUnsort, rCost));
169296 }else{
169297 rCost = rUnsort;
169298 rUnsort -= 2; /* TUNING: Slight bias in favor of no-sort plans */
169299 }
169300
169301 /* Check to see if pWLoop should be added to the set of
169302 ** mxChoice best-so-far paths.
169303 **
@@ -168951,19 +169319,19 @@
169319 }
169320 }
169321 if( jj>=nTo ){
169322 /* None of the existing best-so-far paths match the candidate. */
169323 if( nTo>=mxChoice
169324 && (rCost>mxCost || (rCost==mxCost && rUnsort>=mxUnsort))
169325 ){
169326 /* The current candidate is no better than any of the mxChoice
169327 ** paths currently in the best-so-far buffer. So discard
169328 ** this candidate as not viable. */
169329 #ifdef WHERETRACE_ENABLED /* 0x4 */
169330 if( sqlite3WhereTrace&0x4 ){
169331 sqlite3DebugPrintf("Skip %s cost=%-3d,%3d,%3d order=%c\n",
169332 wherePathName(pFrom, iLoop, pWLoop), rCost, nOut, rUnsort,
169333 isOrdered>=0 ? isOrdered+'0' : '?');
169334 }
169335 #endif
169336 continue;
169337 }
@@ -168978,11 +169346,11 @@
169346 }
169347 pTo = &aTo[jj];
169348 #ifdef WHERETRACE_ENABLED /* 0x4 */
169349 if( sqlite3WhereTrace&0x4 ){
169350 sqlite3DebugPrintf("New %s cost=%-3d,%3d,%3d order=%c\n",
169351 wherePathName(pFrom, iLoop, pWLoop), rCost, nOut, rUnsort,
169352 isOrdered>=0 ? isOrdered+'0' : '?');
169353 }
169354 #endif
169355 }else{
169356 /* Control reaches here if best-so-far path pTo=aTo[jj] covers the
@@ -168989,28 +169357,27 @@
169357 ** same set of loops and has the same isOrdered setting as the
169358 ** candidate path. Check to see if the candidate should replace
169359 ** pTo or if the candidate should be skipped.
169360 **
169361 ** The conditional is an expanded vector comparison equivalent to:
169362 ** (pTo->rCost,pTo->nRow,pTo->rUnsort) <= (rCost,nOut,rUnsort)
169363 */
169364 if( (pTo->rCost<rCost)
169365 || (pTo->rCost==rCost && pTo->nRow<nOut)
169366 || (pTo->rCost==rCost && pTo->nRow==nOut && pTo->rUnsort<rUnsort)
169367 || (pTo->rCost==rCost && pTo->nRow==nOut && pTo->rUnsort==rUnsort
169368 && whereLoopIsNoBetter(pWLoop, pTo->aLoop[iLoop]) )
 
169369 ){
169370 #ifdef WHERETRACE_ENABLED /* 0x4 */
169371 if( sqlite3WhereTrace&0x4 ){
169372 sqlite3DebugPrintf(
169373 "Skip %s cost=%-3d,%3d,%3d order=%c",
169374 wherePathName(pFrom, iLoop, pWLoop), rCost, nOut, rUnsort,
169375 isOrdered>=0 ? isOrdered+'0' : '?');
169376 sqlite3DebugPrintf(" vs %s cost=%-3d,%3d,%3d order=%c\n",
169377 wherePathName(pTo, iLoop+1, 0), pTo->rCost, pTo->nRow,
169378 pTo->rUnsort, pTo->isOrdered>=0 ? pTo->isOrdered+'0' : '?');
169379 }
169380 #endif
169381 /* Discard the candidate path from further consideration */
169382 testcase( pTo->rCost==rCost );
169383 continue;
@@ -169020,37 +169387,37 @@
169387 ** pTo path. Replace pTo with the candidate. */
169388 #ifdef WHERETRACE_ENABLED /* 0x4 */
169389 if( sqlite3WhereTrace&0x4 ){
169390 sqlite3DebugPrintf(
169391 "Update %s cost=%-3d,%3d,%3d order=%c",
169392 wherePathName(pFrom, iLoop, pWLoop), rCost, nOut, rUnsort,
169393 isOrdered>=0 ? isOrdered+'0' : '?');
169394 sqlite3DebugPrintf(" was %s cost=%-3d,%3d,%3d order=%c\n",
169395 wherePathName(pTo, iLoop+1, 0), pTo->rCost, pTo->nRow,
169396 pTo->rUnsort, pTo->isOrdered>=0 ? pTo->isOrdered+'0' : '?');
169397 }
169398 #endif
169399 }
169400 /* pWLoop is a winner. Add it to the set of best so far */
169401 pTo->maskLoop = pFrom->maskLoop | pWLoop->maskSelf;
169402 pTo->revLoop = revMask;
169403 pTo->nRow = nOut;
169404 pTo->rCost = rCost;
169405 pTo->rUnsort = rUnsort;
169406 pTo->isOrdered = isOrdered;
169407 memcpy(pTo->aLoop, pFrom->aLoop, sizeof(WhereLoop*)*iLoop);
169408 pTo->aLoop[iLoop] = pWLoop;
169409 if( nTo>=mxChoice ){
169410 mxI = 0;
169411 mxCost = aTo[0].rCost;
169412 mxUnsort = aTo[0].nRow;
169413 for(jj=1, pTo=&aTo[1]; jj<mxChoice; jj++, pTo++){
169414 if( pTo->rCost>mxCost
169415 || (pTo->rCost==mxCost && pTo->rUnsort>mxUnsort)
169416 ){
169417 mxCost = pTo->rCost;
169418 mxUnsort = pTo->rUnsort;
169419 mxI = jj;
169420 }
169421 }
169422 }
169423 }
@@ -169058,12 +169425,14 @@
169425
169426 #ifdef WHERETRACE_ENABLED /* >=2 */
169427 if( sqlite3WhereTrace & 0x02 ){
169428 LogEst rMin, rFloor = 0;
169429 int nDone = 0;
169430 int nProgress;
169431 sqlite3DebugPrintf("---- after round %d ----\n", iLoop);
169432 do{
169433 nProgress = 0;
169434 rMin = 0x7fff;
169435 for(ii=0, pTo=aTo; ii<nTo; ii++, pTo++){
169436 if( pTo->rCost>rFloor && pTo->rCost<rMin ) rMin = pTo->rCost;
169437 }
169438 for(ii=0, pTo=aTo; ii<nTo; ii++, pTo++){
@@ -169075,14 +169444,15 @@
169444 sqlite3DebugPrintf(" rev=0x%llx\n", pTo->revLoop);
169445 }else{
169446 sqlite3DebugPrintf("\n");
169447 }
169448 nDone++;
169449 nProgress++;
169450 }
169451 }
169452 rFloor = rMin;
169453 }while( nDone<nTo && nProgress>0 );
169454 }
169455 #endif
169456
169457 /* Swap the roles of aFrom and aTo for the next generation */
169458 pFrom = aTo;
@@ -169172,11 +169542,14 @@
169542 pWInfo->revMask = revMask;
169543 }
169544 }
169545 }
169546
169547 pWInfo->nRowOut = pFrom->nRow;
169548 #ifdef WHERETRACE_ENABLED
169549 pWInfo->rTotalCost = pFrom->rCost;
169550 #endif
169551
169552 /* Free temporary memory and return success */
169553 sqlite3StackFreeNN(pParse->db, pSpace);
169554 return SQLITE_OK;
169555 }
@@ -169570,11 +169943,10 @@
169943 pLoop->cId, (double)sqlite3LogEstToInt(nSearch), pTab->zName,
169944 (double)sqlite3LogEstToInt(pTab->nRowLogEst)));
169945 }
169946 }
169947 nSearch += pLoop->nOut;
 
169948 }
169949 }
169950
169951 /*
169952 ** The index pIdx is used by a query and contains one or more expressions.
@@ -170053,11 +170425,12 @@
170425 goto whereBeginError;
170426 }
170427 assert( db->mallocFailed==0 );
170428 #ifdef WHERETRACE_ENABLED
170429 if( sqlite3WhereTrace ){
170430 sqlite3DebugPrintf("---- Solution cost=%d, nRow=%d",
170431 pWInfo->rTotalCost, pWInfo->nRowOut);
170432 if( pWInfo->nOBSat>0 ){
170433 sqlite3DebugPrintf(" ORDERBY=%d,0x%llx", pWInfo->nOBSat, pWInfo->revMask);
170434 }
170435 switch( pWInfo->eDistinct ){
170436 case WHERE_DISTINCT_UNIQUE: {
@@ -170414,10 +170787,11 @@
170787 int pc,
170788 VdbeOp *pOp
170789 ){
170790 if( (db->flags & SQLITE_VdbeAddopTrace)==0 ) return;
170791 sqlite3VdbePrintOp(0, pc, pOp);
170792 sqlite3ShowWhereTerm(0); /* So compiler won't complain about unused func */
170793 }
170794 #endif
170795
170796 /*
170797 ** Generate the end of the WHERE loop. See comments on
@@ -172523,11 +172897,11 @@
172897 sqlite3VdbeAddOp4(v, OP_CollSeq, 0,0,0, (const char*)pColl, P4_COLLSEQ);
172898 }
172899 sqlite3VdbeAddOp3(v, bInverse? OP_AggInverse : OP_AggStep,
172900 bInverse, regArg, pWin->regAccum);
172901 sqlite3VdbeAppendP4(v, pFunc, P4_FUNCDEF);
172902 sqlite3VdbeChangeP5(v, (u16)nArg);
172903 if( pWin->bExprArgs ){
172904 sqlite3ReleaseTempRange(pParse, regArg, nArg);
172905 }
172906 }
172907
@@ -173907,10 +174281,15 @@
174281 ** to the original parse.y sources.
174282 */
174283
174284 /* #include "sqliteInt.h" */
174285
174286 /*
174287 ** Verify that the pParse->isCreate field is set
174288 */
174289 #define ASSERT_IS_CREATE assert(pParse->isCreate)
174290
174291 /*
174292 ** Disable all error recovery processing in the parser push-down
174293 ** automaton.
174294 */
174295 #define YYNOERRORRECOVERY 1
@@ -173970,10 +174349,14 @@
174349 ** shared across database connections.
174350 */
174351 static void disableLookaside(Parse *pParse){
174352 sqlite3 *db = pParse->db;
174353 pParse->disableLookaside++;
174354 #ifdef SQLITE_DEBUG
174355 pParse->isCreate = 1;
174356 #endif
174357 memset(&pParse->u1.cr, 0, sizeof(pParse->u1.cr));
174358 DisableLookaside;
174359 }
174360
174361 #if !defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT) \
174362 && defined(SQLITE_UDL_CAPABLE_PARSER)
@@ -174310,11 +174693,12 @@
174693 #define TK_ASTERISK 180
174694 #define TK_SPAN 181
174695 #define TK_ERROR 182
174696 #define TK_QNUMBER 183
174697 #define TK_SPACE 184
174698 #define TK_COMMENT 185
174699 #define TK_ILLEGAL 186
174700 #endif
174701 /**************** End token definitions ***************************************/
174702
174703 /* The next sections is a series of control #defines.
174704 ** various aspects of the generated parser.
@@ -174375,35 +174759,35 @@
174759 #ifndef INTERFACE
174760 # define INTERFACE 1
174761 #endif
174762 /************* Begin control #defines *****************************************/
174763 #define YYCODETYPE unsigned short int
174764 #define YYNOCODE 323
174765 #define YYACTIONTYPE unsigned short int
174766 #define YYWILDCARD 102
174767 #define sqlite3ParserTOKENTYPE Token
174768 typedef union {
174769 int yyinit;
174770 sqlite3ParserTOKENTYPE yy0;
174771 u32 yy9;
174772 struct TrigEvent yy28;
174773 With* yy125;
174774 IdList* yy204;
174775 struct FrameBound yy205;
174776 TriggerStep* yy319;
174777 const char* yy342;
174778 Cte* yy361;
174779 ExprList* yy402;
174780 Upsert* yy403;
174781 OnOrUsing yy421;
174782 u8 yy444;
174783 struct {int value; int mask;} yy481;
174784 Window* yy483;
174785 int yy502;
174786 SrcList* yy563;
174787 Expr* yy590;
174788 Select* yy637;
174789 } YYMINORTYPE;
174790 #ifndef YYSTACKDEPTH
174791 #define YYSTACKDEPTH 100
174792 #endif
174793 #define sqlite3ParserARG_SDECL
@@ -174421,21 +174805,21 @@
174805 #define sqlite3ParserCTX_STORE yypParser->pParse=pParse;
174806 #define YYFALLBACK 1
174807 #define YYNSTATE 583
174808 #define YYNRULE 409
174809 #define YYNRULE_WITH_ACTION 344
174810 #define YYNTOKEN 187
174811 #define YY_MAX_SHIFT 582
174812 #define YY_MIN_SHIFTREDUCE 845
174813 #define YY_MAX_SHIFTREDUCE 1253
174814 #define YY_ERROR_ACTION 1254
174815 #define YY_ACCEPT_ACTION 1255
174816 #define YY_NO_ACTION 1256
174817 #define YY_MIN_REDUCE 1257
174818 #define YY_MAX_REDUCE 1665
174819 #define YY_MIN_DSTRCTR 206
174820 #define YY_MAX_DSTRCTR 320
174821 /************* End control #defines *******************************************/
174822 #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])))
174823
174824 /* Define the yytestcase() macro to be a no-op if is not already defined
174825 ** otherwise.
@@ -174527,573 +174911,573 @@
174911 /* 60 */ 288, 288, 182, 288, 288, 481, 536, 288, 288, 130,
174912 /* 70 */ 127, 234, 432, 573, 525, 562, 573, 557, 562, 1290,
174913 /* 80 */ 573, 421, 562, 137, 138, 91, 559, 1228, 1228, 1063,
174914 /* 90 */ 1066, 1053, 1053, 135, 135, 136, 136, 136, 136, 296,
174915 /* 100 */ 460, 398, 1249, 134, 134, 134, 134, 133, 133, 132,
174916 /* 110 */ 132, 132, 131, 128, 451, 451, 1050, 1050, 1064, 1067,
174917 /* 120 */ 1255, 1, 1, 582, 2, 1259, 581, 1174, 1259, 1174,
174918 /* 130 */ 321, 413, 155, 321, 1584, 155, 379, 112, 481, 1341,
174919 /* 140 */ 456, 299, 1341, 134, 134, 134, 134, 133, 133, 132,
174920 /* 150 */ 132, 132, 131, 128, 451, 137, 138, 91, 498, 1228,
174921 /* 160 */ 1228, 1063, 1066, 1053, 1053, 135, 135, 136, 136, 136,
174922 /* 170 */ 136, 1204, 862, 1281, 288, 288, 283, 288, 288, 523,
174923 /* 180 */ 523, 1250, 139, 578, 7, 578, 1345, 573, 1169, 562,
174924 /* 190 */ 573, 1054, 562, 136, 136, 136, 136, 129, 573, 547,
174925 /* 200 */ 562, 1169, 245, 1541, 1169, 245, 133, 133, 132, 132,
174926 /* 210 */ 132, 131, 128, 451, 302, 134, 134, 134, 134, 133,
174927 /* 220 */ 133, 132, 132, 132, 131, 128, 451, 1575, 1204, 1205,
174928 /* 230 */ 1204, 7, 470, 550, 455, 413, 550, 455, 130, 127,
174929 /* 240 */ 234, 134, 134, 134, 134, 133, 133, 132, 132, 132,
174930 /* 250 */ 131, 128, 451, 136, 136, 136, 136, 538, 483, 137,
174931 /* 260 */ 138, 91, 1019, 1228, 1228, 1063, 1066, 1053, 1053, 135,
174932 /* 270 */ 135, 136, 136, 136, 136, 1085, 576, 1204, 132, 132,
174933 /* 280 */ 132, 131, 128, 451, 93, 214, 134, 134, 134, 134,
174934 /* 290 */ 133, 133, 132, 132, 132, 131, 128, 451, 401, 19,
174935 /* 300 */ 19, 134, 134, 134, 134, 133, 133, 132, 132, 132,
174936 /* 310 */ 131, 128, 451, 1498, 426, 267, 344, 467, 332, 134,
174937 /* 320 */ 134, 134, 134, 133, 133, 132, 132, 132, 131, 128,
174938 /* 330 */ 451, 1281, 576, 6, 1204, 1205, 1204, 257, 576, 413,
174939 /* 340 */ 511, 508, 507, 1279, 94, 1019, 464, 1204, 551, 551,
174940 /* 350 */ 506, 1224, 1571, 44, 38, 51, 51, 411, 576, 413,
174941 /* 360 */ 45, 51, 51, 137, 138, 91, 530, 1228, 1228, 1063,
174942 /* 370 */ 1066, 1053, 1053, 135, 135, 136, 136, 136, 136, 398,
174943 /* 380 */ 1148, 82, 82, 137, 138, 91, 39, 1228, 1228, 1063,
174944 /* 390 */ 1066, 1053, 1053, 135, 135, 136, 136, 136, 136, 344,
174945 /* 400 */ 44, 288, 288, 375, 1204, 1205, 1204, 209, 1204, 1224,
174946 /* 410 */ 320, 567, 471, 576, 573, 576, 562, 576, 316, 264,
174947 /* 420 */ 231, 46, 160, 134, 134, 134, 134, 133, 133, 132,
174948 /* 430 */ 132, 132, 131, 128, 451, 303, 82, 82, 82, 82,
174949 /* 440 */ 82, 82, 442, 134, 134, 134, 134, 133, 133, 132,
174950 /* 450 */ 132, 132, 131, 128, 451, 1582, 544, 320, 567, 1250,
174951 /* 460 */ 874, 1582, 380, 382, 413, 1204, 1205, 1204, 360, 182,
174952 /* 470 */ 288, 288, 1576, 557, 1339, 557, 7, 557, 1277, 472,
174953 /* 480 */ 346, 526, 531, 573, 556, 562, 439, 1511, 137, 138,
174954 /* 490 */ 91, 219, 1228, 1228, 1063, 1066, 1053, 1053, 135, 135,
174955 /* 500 */ 136, 136, 136, 136, 465, 1511, 1513, 532, 413, 288,
174956 /* 510 */ 288, 423, 512, 288, 288, 411, 288, 288, 874, 130,
174957 /* 520 */ 127, 234, 573, 1107, 562, 1204, 573, 1107, 562, 573,
174958 /* 530 */ 560, 562, 137, 138, 91, 1293, 1228, 1228, 1063, 1066,
174959 /* 540 */ 1053, 1053, 135, 135, 136, 136, 136, 136, 134, 134,
174960 /* 550 */ 134, 134, 133, 133, 132, 132, 132, 131, 128, 451,
174961 /* 560 */ 493, 503, 1292, 1204, 257, 288, 288, 511, 508, 507,
174962 /* 570 */ 1204, 1628, 1169, 123, 568, 275, 4, 506, 573, 1511,
174963 /* 580 */ 562, 331, 1204, 1205, 1204, 1169, 548, 548, 1169, 261,
174964 /* 590 */ 571, 7, 134, 134, 134, 134, 133, 133, 132, 132,
174965 /* 600 */ 132, 131, 128, 451, 108, 533, 130, 127, 234, 1204,
174966 /* 610 */ 448, 447, 413, 1451, 452, 983, 886, 96, 1598, 1233,
174967 /* 620 */ 1204, 1205, 1204, 984, 1235, 1450, 565, 1204, 1205, 1204,
174968 /* 630 */ 229, 522, 1234, 534, 1333, 1333, 137, 138, 91, 1449,
174969 /* 640 */ 1228, 1228, 1063, 1066, 1053, 1053, 135, 135, 136, 136,
174970 /* 650 */ 136, 136, 373, 1595, 971, 1040, 413, 1236, 418, 1236,
174971 /* 660 */ 879, 121, 121, 948, 373, 1595, 1204, 1205, 1204, 122,
174972 /* 670 */ 1204, 452, 577, 452, 363, 417, 1028, 882, 373, 1595,
174973 /* 680 */ 137, 138, 91, 462, 1228, 1228, 1063, 1066, 1053, 1053,
174974 /* 690 */ 135, 135, 136, 136, 136, 136, 134, 134, 134, 134,
174975 /* 700 */ 133, 133, 132, 132, 132, 131, 128, 451, 1028, 1028,
174976 /* 710 */ 1030, 1031, 35, 570, 570, 570, 197, 423, 1040, 198,
174977 /* 720 */ 1204, 123, 568, 1204, 4, 320, 567, 1204, 1205, 1204,
174978 /* 730 */ 40, 388, 576, 384, 882, 1029, 423, 1188, 571, 1028,
174979 /* 740 */ 134, 134, 134, 134, 133, 133, 132, 132, 132, 131,
174980 /* 750 */ 128, 451, 529, 1568, 1204, 19, 19, 1204, 575, 492,
174981 /* 760 */ 413, 157, 452, 489, 1187, 1331, 1331, 5, 1204, 949,
174982 /* 770 */ 431, 1028, 1028, 1030, 565, 22, 22, 1204, 1205, 1204,
174983 /* 780 */ 1204, 1205, 1204, 477, 137, 138, 91, 212, 1228, 1228,
174984 /* 790 */ 1063, 1066, 1053, 1053, 135, 135, 136, 136, 136, 136,
174985 /* 800 */ 1188, 48, 111, 1040, 413, 1204, 213, 970, 1041, 121,
174986 /* 810 */ 121, 1204, 1205, 1204, 1204, 1205, 1204, 122, 221, 452,
174987 /* 820 */ 577, 452, 44, 487, 1028, 1204, 1205, 1204, 137, 138,
174988 /* 830 */ 91, 378, 1228, 1228, 1063, 1066, 1053, 1053, 135, 135,
174989 /* 840 */ 136, 136, 136, 136, 134, 134, 134, 134, 133, 133,
174990 /* 850 */ 132, 132, 132, 131, 128, 451, 1028, 1028, 1030, 1031,
174991 /* 860 */ 35, 461, 1204, 1205, 1204, 1569, 1040, 377, 214, 1149,
174992 /* 870 */ 1657, 535, 1657, 437, 902, 320, 567, 1568, 364, 320,
174993 /* 880 */ 567, 412, 329, 1029, 519, 1188, 3, 1028, 134, 134,
174994 /* 890 */ 134, 134, 133, 133, 132, 132, 132, 131, 128, 451,
174995 /* 900 */ 1659, 399, 1169, 307, 893, 307, 515, 576, 413, 214,
174996 /* 910 */ 498, 944, 1024, 540, 903, 1169, 943, 392, 1169, 1028,
174997 /* 920 */ 1028, 1030, 406, 298, 1204, 50, 1149, 1658, 413, 1658,
174998 /* 930 */ 145, 145, 137, 138, 91, 293, 1228, 1228, 1063, 1066,
174999 /* 940 */ 1053, 1053, 135, 135, 136, 136, 136, 136, 1188, 1147,
175000 /* 950 */ 514, 1568, 137, 138, 91, 1505, 1228, 1228, 1063, 1066,
175001 /* 960 */ 1053, 1053, 135, 135, 136, 136, 136, 136, 434, 323,
175002 /* 970 */ 435, 539, 111, 1506, 274, 291, 372, 517, 367, 516,
175003 /* 980 */ 262, 1204, 1205, 1204, 1574, 481, 363, 576, 7, 1569,
175004 /* 990 */ 1568, 377, 134, 134, 134, 134, 133, 133, 132, 132,
175005 /* 1000 */ 132, 131, 128, 451, 1568, 576, 1147, 576, 232, 576,
175006 /* 1010 */ 19, 19, 134, 134, 134, 134, 133, 133, 132, 132,
175007 /* 1020 */ 132, 131, 128, 451, 1169, 433, 576, 1207, 19, 19,
175008 /* 1030 */ 19, 19, 19, 19, 1627, 576, 911, 1169, 47, 120,
175009 /* 1040 */ 1169, 117, 413, 306, 498, 438, 1125, 206, 336, 19,
175010 /* 1050 */ 19, 1435, 49, 449, 449, 449, 1368, 315, 81, 81,
175011 /* 1060 */ 576, 304, 413, 1570, 207, 377, 137, 138, 91, 115,
175012 /* 1070 */ 1228, 1228, 1063, 1066, 1053, 1053, 135, 135, 136, 136,
175013 /* 1080 */ 136, 136, 576, 82, 82, 1207, 137, 138, 91, 1340,
175014 /* 1090 */ 1228, 1228, 1063, 1066, 1053, 1053, 135, 135, 136, 136,
175015 /* 1100 */ 136, 136, 1569, 386, 377, 82, 82, 463, 1126, 1552,
175016 /* 1110 */ 333, 463, 335, 131, 128, 451, 1569, 161, 377, 16,
175017 /* 1120 */ 317, 387, 428, 1127, 448, 447, 134, 134, 134, 134,
175018 /* 1130 */ 133, 133, 132, 132, 132, 131, 128, 451, 1128, 576,
175019 /* 1140 */ 1105, 10, 445, 267, 576, 1554, 134, 134, 134, 134,
175020 /* 1150 */ 133, 133, 132, 132, 132, 131, 128, 451, 532, 576,
175021 /* 1160 */ 922, 576, 19, 19, 576, 1573, 576, 147, 147, 7,
175022 /* 1170 */ 923, 1236, 498, 1236, 576, 487, 413, 552, 285, 1224,
175023 /* 1180 */ 969, 215, 82, 82, 66, 66, 1435, 67, 67, 21,
175024 /* 1190 */ 21, 1110, 1110, 495, 334, 297, 413, 53, 53, 297,
175025 /* 1200 */ 137, 138, 91, 119, 1228, 1228, 1063, 1066, 1053, 1053,
175026 /* 1210 */ 135, 135, 136, 136, 136, 136, 413, 1336, 1311, 446,
175027 /* 1220 */ 137, 138, 91, 227, 1228, 1228, 1063, 1066, 1053, 1053,
175028 /* 1230 */ 135, 135, 136, 136, 136, 136, 574, 1224, 936, 936,
175029 /* 1240 */ 137, 126, 91, 141, 1228, 1228, 1063, 1066, 1053, 1053,
175030 /* 1250 */ 135, 135, 136, 136, 136, 136, 533, 429, 472, 346,
175031 /* 1260 */ 134, 134, 134, 134, 133, 133, 132, 132, 132, 131,
175032 /* 1270 */ 128, 451, 576, 457, 233, 343, 1435, 403, 498, 1550,
175033 /* 1280 */ 134, 134, 134, 134, 133, 133, 132, 132, 132, 131,
175034 /* 1290 */ 128, 451, 576, 324, 576, 82, 82, 487, 576, 969,
175035 /* 1300 */ 134, 134, 134, 134, 133, 133, 132, 132, 132, 131,
175036 /* 1310 */ 128, 451, 288, 288, 546, 68, 68, 54, 54, 553,
175037 /* 1320 */ 413, 69, 69, 351, 6, 573, 944, 562, 410, 409,
175038 /* 1330 */ 1435, 943, 450, 545, 260, 259, 258, 576, 158, 576,
175039 /* 1340 */ 413, 222, 1180, 479, 969, 138, 91, 430, 1228, 1228,
175040 /* 1350 */ 1063, 1066, 1053, 1053, 135, 135, 136, 136, 136, 136,
175041 /* 1360 */ 70, 70, 71, 71, 576, 1126, 91, 576, 1228, 1228,
175042 /* 1370 */ 1063, 1066, 1053, 1053, 135, 135, 136, 136, 136, 136,
175043 /* 1380 */ 1127, 166, 850, 851, 852, 1282, 419, 72, 72, 108,
175044 /* 1390 */ 73, 73, 1310, 358, 1180, 1128, 576, 305, 576, 123,
175045 /* 1400 */ 568, 494, 4, 488, 134, 134, 134, 134, 133, 133,
175046 /* 1410 */ 132, 132, 132, 131, 128, 451, 571, 564, 534, 55,
175047 /* 1420 */ 55, 56, 56, 576, 134, 134, 134, 134, 133, 133,
175048 /* 1430 */ 132, 132, 132, 131, 128, 451, 576, 1104, 233, 1104,
175049 /* 1440 */ 452, 1602, 582, 2, 1259, 576, 57, 57, 576, 321,
175050 /* 1450 */ 576, 155, 565, 1435, 485, 353, 576, 356, 1341, 59,
175051 /* 1460 */ 59, 576, 44, 969, 569, 419, 576, 238, 60, 60,
175052 /* 1470 */ 261, 74, 74, 75, 75, 287, 231, 576, 1366, 76,
175053 /* 1480 */ 76, 1040, 420, 184, 20, 20, 576, 121, 121, 77,
175054 /* 1490 */ 77, 97, 218, 288, 288, 122, 125, 452, 577, 452,
175055 /* 1500 */ 143, 143, 1028, 576, 520, 576, 573, 576, 562, 144,
175056 /* 1510 */ 144, 474, 227, 1244, 478, 123, 568, 576, 4, 320,
175057 /* 1520 */ 567, 245, 411, 576, 443, 411, 78, 78, 62, 62,
175058 /* 1530 */ 79, 79, 571, 319, 1028, 1028, 1030, 1031, 35, 418,
175059 /* 1540 */ 63, 63, 576, 290, 411, 9, 80, 80, 1144, 576,
175060 /* 1550 */ 400, 576, 486, 455, 576, 1223, 452, 576, 325, 342,
175061 /* 1560 */ 576, 111, 576, 1188, 242, 64, 64, 473, 565, 576,
175062 /* 1570 */ 23, 576, 170, 170, 171, 171, 576, 87, 87, 328,
175063 /* 1580 */ 65, 65, 542, 83, 83, 146, 146, 541, 123, 568,
175064 /* 1590 */ 341, 4, 84, 84, 168, 168, 576, 1040, 576, 148,
175065 /* 1600 */ 148, 576, 1380, 121, 121, 571, 1021, 576, 266, 576,
175066 /* 1610 */ 424, 122, 576, 452, 577, 452, 576, 553, 1028, 142,
175067 /* 1620 */ 142, 169, 169, 576, 162, 162, 528, 889, 371, 452,
175068 /* 1630 */ 152, 152, 151, 151, 1379, 149, 149, 109, 370, 150,
175069 /* 1640 */ 150, 565, 576, 480, 576, 266, 86, 86, 576, 1092,
175070 /* 1650 */ 1028, 1028, 1030, 1031, 35, 542, 482, 576, 266, 466,
175071 /* 1660 */ 543, 123, 568, 1616, 4, 88, 88, 85, 85, 475,
175072 /* 1670 */ 1040, 52, 52, 222, 901, 900, 121, 121, 571, 1188,
175073 /* 1680 */ 58, 58, 244, 1032, 122, 889, 452, 577, 452, 908,
175074 /* 1690 */ 909, 1028, 300, 347, 504, 111, 263, 361, 165, 111,
175075 /* 1700 */ 111, 1088, 452, 263, 974, 1153, 266, 1092, 986, 987,
175076 /* 1710 */ 942, 939, 125, 125, 565, 1103, 872, 1103, 159, 941,
175077 /* 1720 */ 1309, 125, 1557, 1028, 1028, 1030, 1031, 35, 542, 337,
175078 /* 1730 */ 1530, 205, 1529, 541, 499, 1589, 490, 348, 1376, 352,
175079 /* 1740 */ 355, 1032, 357, 1040, 359, 1324, 1308, 366, 563, 121,
175080 /* 1750 */ 121, 376, 1188, 1389, 1434, 1362, 280, 122, 1374, 452,
175081 /* 1760 */ 577, 452, 167, 1439, 1028, 1289, 1280, 1268, 1267, 1269,
175082 /* 1770 */ 1609, 1359, 312, 313, 314, 397, 12, 237, 224, 1421,
175083 /* 1780 */ 295, 1416, 1409, 1426, 339, 484, 340, 509, 1371, 1612,
175084 /* 1790 */ 1372, 1425, 1244, 404, 301, 228, 1028, 1028, 1030, 1031,
175085 /* 1800 */ 35, 1601, 1192, 454, 345, 1307, 292, 369, 1502, 1501,
175086 /* 1810 */ 270, 396, 396, 395, 277, 393, 1370, 1369, 859, 1549,
175087 /* 1820 */ 186, 123, 568, 235, 4, 1188, 391, 210, 211, 223,
175088 /* 1830 */ 1547, 239, 1241, 327, 422, 96, 220, 195, 571, 180,
175089 /* 1840 */ 188, 326, 468, 469, 190, 191, 502, 192, 193, 566,
175090 /* 1850 */ 247, 109, 1430, 491, 199, 251, 102, 281, 402, 476,
175091 /* 1860 */ 405, 1496, 452, 497, 253, 1422, 13, 1428, 14, 1427,
175092 /* 1870 */ 203, 1507, 241, 500, 565, 354, 407, 92, 95, 1270,
175093 /* 1880 */ 175, 254, 518, 43, 1327, 255, 1326, 1325, 436, 1518,
175094 /* 1890 */ 350, 1318, 104, 229, 893, 1626, 440, 441, 1625, 408,
175095 /* 1900 */ 240, 1296, 268, 1040, 310, 269, 1297, 527, 444, 121,
175096 /* 1910 */ 121, 368, 1295, 1594, 1624, 311, 1394, 122, 1317, 452,
175097 /* 1920 */ 577, 452, 374, 1580, 1028, 1393, 140, 553, 11, 90,
175098 /* 1930 */ 568, 385, 4, 116, 318, 414, 1579, 110, 1483, 537,
175099 /* 1940 */ 320, 567, 1350, 555, 42, 579, 571, 1349, 1198, 383,
175100 /* 1950 */ 276, 390, 216, 389, 278, 279, 1028, 1028, 1030, 1031,
175101 /* 1960 */ 35, 172, 580, 1265, 458, 1260, 415, 416, 185, 156,
175102 /* 1970 */ 452, 1534, 1535, 173, 1533, 1532, 89, 308, 225, 226,
175103 /* 1980 */ 846, 174, 565, 453, 217, 1188, 322, 236, 1102, 154,
175104 /* 1990 */ 1100, 330, 187, 176, 1223, 243, 189, 925, 338, 246,
175105 /* 2000 */ 1116, 194, 177, 425, 178, 427, 98, 196, 99, 100,
175106 /* 2010 */ 101, 1040, 179, 1119, 1115, 248, 249, 121, 121, 163,
175107 /* 2020 */ 24, 250, 349, 1238, 496, 122, 1108, 452, 577, 452,
175108 /* 2030 */ 1192, 454, 1028, 266, 292, 200, 252, 201, 861, 396,
175109 /* 2040 */ 396, 395, 277, 393, 15, 501, 859, 370, 292, 256,
175110 /* 2050 */ 202, 554, 505, 396, 396, 395, 277, 393, 103, 239,
175111 /* 2060 */ 859, 327, 25, 26, 1028, 1028, 1030, 1031, 35, 326,
175112 /* 2070 */ 362, 510, 891, 239, 365, 327, 513, 904, 105, 309,
175113 /* 2080 */ 164, 181, 27, 326, 106, 521, 107, 1185, 1069, 1155,
175114 /* 2090 */ 17, 1154, 230, 1188, 284, 286, 265, 204, 125, 1171,
175115 /* 2100 */ 241, 28, 978, 972, 29, 41, 1175, 1179, 175, 1173,
175116 /* 2110 */ 30, 43, 31, 8, 241, 1178, 32, 1160, 208, 549,
175117 /* 2120 */ 33, 111, 175, 1083, 1070, 43, 1068, 1072, 240, 113,
175118 /* 2130 */ 114, 34, 561, 118, 1124, 271, 1073, 36, 18, 572,
175119 /* 2140 */ 1033, 873, 240, 124, 37, 935, 272, 273, 1617, 183,
175120 /* 2150 */ 153, 394, 1194, 1193, 1256, 1256, 1256, 1256, 1256, 1256,
175121 /* 2160 */ 1256, 1256, 1256, 414, 1256, 1256, 1256, 1256, 320, 567,
175122 /* 2170 */ 1256, 1256, 1256, 1256, 1256, 1256, 1256, 414, 1256, 1256,
175123 /* 2180 */ 1256, 1256, 320, 567, 1256, 1256, 1256, 1256, 1256, 1256,
175124 /* 2190 */ 1256, 1256, 458, 1256, 1256, 1256, 1256, 1256, 1256, 1256,
175125 /* 2200 */ 1256, 1256, 1256, 1256, 1256, 1256, 458,
175126 };
175127 static const YYCODETYPE yy_lookahead[] = {
175128 /* 0 */ 277, 278, 279, 241, 242, 225, 195, 227, 195, 241,
175129 /* 10 */ 242, 195, 217, 221, 195, 235, 254, 195, 256, 19,
175130 /* 20 */ 225, 298, 254, 195, 256, 206, 213, 214, 206, 218,
175131 /* 30 */ 219, 31, 206, 195, 218, 219, 195, 218, 219, 39,
175132 /* 40 */ 218, 219, 313, 43, 44, 45, 317, 47, 48, 49,
175133 /* 50 */ 50, 51, 52, 53, 54, 55, 56, 57, 58, 19,
175134 /* 60 */ 241, 242, 195, 241, 242, 195, 255, 241, 242, 277,
175135 /* 70 */ 278, 279, 234, 254, 255, 256, 254, 255, 256, 218,
175136 /* 80 */ 254, 240, 256, 43, 44, 45, 264, 47, 48, 49,
175137 /* 90 */ 50, 51, 52, 53, 54, 55, 56, 57, 58, 271,
175138 /* 100 */ 287, 22, 23, 103, 104, 105, 106, 107, 108, 109,
175139 /* 110 */ 110, 111, 112, 113, 114, 114, 47, 48, 49, 50,
175140 /* 120 */ 187, 188, 189, 190, 191, 192, 190, 87, 192, 89,
175141 /* 130 */ 197, 19, 199, 197, 318, 199, 320, 25, 195, 206,
175142 /* 140 */ 299, 271, 206, 103, 104, 105, 106, 107, 108, 109,
175143 /* 150 */ 110, 111, 112, 113, 114, 43, 44, 45, 195, 47,
175144 /* 160 */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
175145 /* 170 */ 58, 60, 21, 195, 241, 242, 215, 241, 242, 312,
175146 /* 180 */ 313, 102, 70, 205, 317, 207, 242, 254, 77, 256,
175147 /* 190 */ 254, 122, 256, 55, 56, 57, 58, 59, 254, 88,
175148 /* 200 */ 256, 90, 269, 240, 93, 269, 107, 108, 109, 110,
175149 /* 210 */ 111, 112, 113, 114, 271, 103, 104, 105, 106, 107,
175150 /* 220 */ 108, 109, 110, 111, 112, 113, 114, 313, 117, 118,
175151 /* 230 */ 119, 317, 81, 195, 301, 19, 195, 301, 277, 278,
175152 /* 240 */ 279, 103, 104, 105, 106, 107, 108, 109, 110, 111,
175153 /* 250 */ 112, 113, 114, 55, 56, 57, 58, 146, 195, 43,
175154 /* 260 */ 44, 45, 74, 47, 48, 49, 50, 51, 52, 53,
175155 /* 270 */ 54, 55, 56, 57, 58, 124, 195, 60, 109, 110,
175156 /* 280 */ 111, 112, 113, 114, 68, 195, 103, 104, 105, 106,
175157 /* 290 */ 107, 108, 109, 110, 111, 112, 113, 114, 208, 218,
175158 /* 300 */ 219, 103, 104, 105, 106, 107, 108, 109, 110, 111,
175159 /* 310 */ 112, 113, 114, 162, 233, 24, 128, 129, 130, 103,
175160 /* 320 */ 104, 105, 106, 107, 108, 109, 110, 111, 112, 113,
175161 /* 330 */ 114, 195, 195, 215, 117, 118, 119, 120, 195, 19,
175162 /* 340 */ 123, 124, 125, 207, 24, 74, 246, 60, 310, 311,
175163 /* 350 */ 133, 60, 311, 82, 22, 218, 219, 257, 195, 19,
175164 /* 360 */ 73, 218, 219, 43, 44, 45, 206, 47, 48, 49,
175165 /* 370 */ 50, 51, 52, 53, 54, 55, 56, 57, 58, 22,
175166 /* 380 */ 23, 218, 219, 43, 44, 45, 54, 47, 48, 49,
175167 /* 390 */ 50, 51, 52, 53, 54, 55, 56, 57, 58, 128,
175168 /* 400 */ 82, 241, 242, 195, 117, 118, 119, 289, 60, 118,
175169 /* 410 */ 139, 140, 294, 195, 254, 195, 256, 195, 255, 259,
175170 /* 420 */ 260, 73, 22, 103, 104, 105, 106, 107, 108, 109,
175171 /* 430 */ 110, 111, 112, 113, 114, 206, 218, 219, 218, 219,
175172 /* 440 */ 218, 219, 234, 103, 104, 105, 106, 107, 108, 109,
175173 /* 450 */ 110, 111, 112, 113, 114, 318, 319, 139, 140, 102,
175174 /* 460 */ 60, 318, 319, 221, 19, 117, 118, 119, 23, 195,
175175 /* 470 */ 241, 242, 313, 255, 206, 255, 317, 255, 206, 129,
175176 /* 480 */ 130, 206, 264, 254, 264, 256, 264, 195, 43, 44,
175177 /* 490 */ 45, 151, 47, 48, 49, 50, 51, 52, 53, 54,
175178 /* 500 */ 55, 56, 57, 58, 246, 213, 214, 19, 19, 241,
175179 /* 510 */ 242, 195, 23, 241, 242, 257, 241, 242, 118, 277,
175180 /* 520 */ 278, 279, 254, 29, 256, 60, 254, 33, 256, 254,
175181 /* 530 */ 206, 256, 43, 44, 45, 218, 47, 48, 49, 50,
175182 /* 540 */ 51, 52, 53, 54, 55, 56, 57, 58, 103, 104,
175183 /* 550 */ 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
175184 /* 560 */ 66, 19, 218, 60, 120, 241, 242, 123, 124, 125,
175185 /* 570 */ 60, 232, 77, 19, 20, 26, 22, 133, 254, 287,
175186 /* 580 */ 256, 265, 117, 118, 119, 90, 312, 313, 93, 47,
175187 /* 590 */ 36, 317, 103, 104, 105, 106, 107, 108, 109, 110,
175188 /* 600 */ 111, 112, 113, 114, 116, 117, 277, 278, 279, 60,
175189 /* 610 */ 107, 108, 19, 276, 60, 31, 23, 152, 195, 116,
175190 /* 620 */ 117, 118, 119, 39, 121, 276, 72, 117, 118, 119,
175191 /* 630 */ 166, 167, 129, 145, 237, 238, 43, 44, 45, 276,
175192 /* 640 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
175193 /* 650 */ 57, 58, 315, 316, 144, 101, 19, 154, 116, 156,
175194 /* 660 */ 23, 107, 108, 109, 315, 316, 117, 118, 119, 115,
175195 /* 670 */ 60, 117, 118, 119, 132, 200, 122, 60, 315, 316,
175196 /* 680 */ 43, 44, 45, 272, 47, 48, 49, 50, 51, 52,
175197 /* 690 */ 53, 54, 55, 56, 57, 58, 103, 104, 105, 106,
175198 /* 700 */ 107, 108, 109, 110, 111, 112, 113, 114, 154, 155,
175199 /* 710 */ 156, 157, 158, 212, 213, 214, 22, 195, 101, 22,
175200 /* 720 */ 60, 19, 20, 60, 22, 139, 140, 117, 118, 119,
175201 /* 730 */ 22, 251, 195, 253, 117, 118, 195, 183, 36, 122,
175202 /* 740 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
175203 /* 750 */ 113, 114, 195, 195, 60, 218, 219, 60, 195, 284,
175204 /* 760 */ 19, 25, 60, 288, 23, 237, 238, 22, 60, 109,
175205 /* 770 */ 233, 154, 155, 156, 72, 218, 219, 117, 118, 119,
175206 /* 780 */ 117, 118, 119, 116, 43, 44, 45, 265, 47, 48,
175207 /* 790 */ 49, 50, 51, 52, 53, 54, 55, 56, 57, 58,
175208 /* 800 */ 183, 243, 25, 101, 19, 60, 265, 144, 23, 107,
175209 /* 810 */ 108, 117, 118, 119, 117, 118, 119, 115, 151, 117,
175210 /* 820 */ 118, 119, 82, 195, 122, 117, 118, 119, 43, 44,
175211 /* 830 */ 45, 195, 47, 48, 49, 50, 51, 52, 53, 54,
175212 /* 840 */ 55, 56, 57, 58, 103, 104, 105, 106, 107, 108,
175213 /* 850 */ 109, 110, 111, 112, 113, 114, 154, 155, 156, 157,
175214 /* 860 */ 158, 121, 117, 118, 119, 307, 101, 309, 195, 22,
175215 /* 870 */ 23, 195, 25, 19, 35, 139, 140, 195, 24, 139,
175216 /* 880 */ 140, 208, 195, 118, 109, 183, 22, 122, 103, 104,
175217 /* 890 */ 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
175218 /* 900 */ 304, 305, 77, 230, 127, 232, 67, 195, 19, 195,
175219 /* 910 */ 195, 136, 23, 88, 75, 90, 141, 203, 93, 154,
175220 /* 920 */ 155, 156, 208, 295, 60, 243, 22, 23, 19, 25,
175221 /* 930 */ 218, 219, 43, 44, 45, 100, 47, 48, 49, 50,
175222 /* 940 */ 51, 52, 53, 54, 55, 56, 57, 58, 183, 102,
175223 /* 950 */ 96, 195, 43, 44, 45, 240, 47, 48, 49, 50,
175224 /* 960 */ 51, 52, 53, 54, 55, 56, 57, 58, 114, 134,
175225 /* 970 */ 131, 146, 25, 286, 120, 121, 122, 123, 124, 125,
175226 /* 980 */ 126, 117, 118, 119, 313, 195, 132, 195, 317, 307,
175227 /* 990 */ 195, 309, 103, 104, 105, 106, 107, 108, 109, 110,
175228 /* 1000 */ 111, 112, 113, 114, 195, 195, 102, 195, 195, 195,
175229 /* 1010 */ 218, 219, 103, 104, 105, 106, 107, 108, 109, 110,
175230 /* 1020 */ 111, 112, 113, 114, 77, 233, 195, 60, 218, 219,
175231 /* 1030 */ 218, 219, 218, 219, 23, 195, 25, 90, 243, 159,
175232 /* 1040 */ 93, 161, 19, 233, 195, 233, 23, 233, 16, 218,
175233 /* 1050 */ 219, 195, 243, 212, 213, 214, 262, 263, 218, 219,
175234 /* 1060 */ 195, 271, 19, 307, 233, 309, 43, 44, 45, 160,
175235 /* 1070 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
175236 /* 1080 */ 57, 58, 195, 218, 219, 118, 43, 44, 45, 240,
175237 /* 1090 */ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
175238 /* 1100 */ 57, 58, 307, 195, 309, 218, 219, 263, 12, 195,
175239 /* 1110 */ 78, 267, 80, 112, 113, 114, 307, 22, 309, 24,
175240 /* 1120 */ 255, 281, 266, 27, 107, 108, 103, 104, 105, 106,
175241 /* 1130 */ 107, 108, 109, 110, 111, 112, 113, 114, 42, 195,
175242 /* 1140 */ 11, 22, 255, 24, 195, 195, 103, 104, 105, 106,
175243 /* 1150 */ 107, 108, 109, 110, 111, 112, 113, 114, 19, 195,
175244 /* 1160 */ 64, 195, 218, 219, 195, 313, 195, 218, 219, 317,
175245 /* 1170 */ 74, 154, 195, 156, 195, 195, 19, 233, 23, 60,
175246 /* 1180 */ 25, 24, 218, 219, 218, 219, 195, 218, 219, 218,
175247 /* 1190 */ 219, 128, 129, 130, 162, 263, 19, 218, 219, 267,
175248 /* 1200 */ 43, 44, 45, 160, 47, 48, 49, 50, 51, 52,
175249 /* 1210 */ 53, 54, 55, 56, 57, 58, 19, 240, 228, 255,
175250 /* 1220 */ 43, 44, 45, 25, 47, 48, 49, 50, 51, 52,
175251 /* 1230 */ 53, 54, 55, 56, 57, 58, 135, 118, 137, 138,
175252 /* 1240 */ 43, 44, 45, 22, 47, 48, 49, 50, 51, 52,
175253 /* 1250 */ 53, 54, 55, 56, 57, 58, 117, 266, 129, 130,
175254 /* 1260 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
175255 /* 1270 */ 113, 114, 195, 195, 119, 295, 195, 206, 195, 195,
175256 /* 1280 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
175257 /* 1290 */ 113, 114, 195, 195, 195, 218, 219, 195, 195, 144,
175258 /* 1300 */ 103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
175259 /* 1310 */ 113, 114, 241, 242, 67, 218, 219, 218, 219, 146,
175260 /* 1320 */ 19, 218, 219, 240, 215, 254, 136, 256, 107, 108,
175261 /* 1330 */ 195, 141, 255, 86, 128, 129, 130, 195, 165, 195,
175262 /* 1340 */ 19, 143, 95, 272, 25, 44, 45, 266, 47, 48,
175263 /* 1350 */ 49, 50, 51, 52, 53, 54, 55, 56, 57, 58,
175264 /* 1360 */ 218, 219, 218, 219, 195, 12, 45, 195, 47, 48,
175265 /* 1370 */ 49, 50, 51, 52, 53, 54, 55, 56, 57, 58,
175266 /* 1380 */ 27, 23, 7, 8, 9, 210, 211, 218, 219, 116,
175267 /* 1390 */ 218, 219, 228, 16, 147, 42, 195, 295, 195, 19,
175268 /* 1400 */ 20, 266, 22, 294, 103, 104, 105, 106, 107, 108,
175269 /* 1410 */ 109, 110, 111, 112, 113, 114, 36, 64, 145, 218,
175270 /* 1420 */ 219, 218, 219, 195, 103, 104, 105, 106, 107, 108,
175271 /* 1430 */ 109, 110, 111, 112, 113, 114, 195, 154, 119, 156,
175272 /* 1440 */ 60, 189, 190, 191, 192, 195, 218, 219, 195, 197,
175273 /* 1450 */ 195, 199, 72, 195, 19, 78, 195, 80, 206, 218,
175274 /* 1460 */ 219, 195, 82, 144, 210, 211, 195, 15, 218, 219,
175275 /* 1470 */ 47, 218, 219, 218, 219, 259, 260, 195, 261, 218,
175276 /* 1480 */ 219, 101, 302, 303, 218, 219, 195, 107, 108, 218,
175277 /* 1490 */ 219, 150, 151, 241, 242, 115, 25, 117, 118, 119,
175278 /* 1500 */ 218, 219, 122, 195, 146, 195, 254, 195, 256, 218,
175279 /* 1510 */ 219, 246, 25, 61, 246, 19, 20, 195, 22, 139,
175280 /* 1520 */ 140, 269, 257, 195, 266, 257, 218, 219, 218, 219,
175281 /* 1530 */ 218, 219, 36, 246, 154, 155, 156, 157, 158, 116,
175282 /* 1540 */ 218, 219, 195, 22, 257, 49, 218, 219, 23, 195,
175283 /* 1550 */ 25, 195, 117, 301, 195, 25, 60, 195, 195, 23,
175284 /* 1560 */ 195, 25, 195, 183, 24, 218, 219, 130, 72, 195,
175285 /* 1570 */ 22, 195, 218, 219, 218, 219, 195, 218, 219, 195,
175286 /* 1580 */ 218, 219, 86, 218, 219, 218, 219, 91, 19, 20,
175287 /* 1590 */ 153, 22, 218, 219, 218, 219, 195, 101, 195, 218,
175288 /* 1600 */ 219, 195, 195, 107, 108, 36, 23, 195, 25, 195,
175289 /* 1610 */ 62, 115, 195, 117, 118, 119, 195, 146, 122, 218,
175290 /* 1620 */ 219, 218, 219, 195, 218, 219, 19, 60, 122, 60,
175291 /* 1630 */ 218, 219, 218, 219, 195, 218, 219, 150, 132, 218,
175292 /* 1640 */ 219, 72, 195, 23, 195, 25, 218, 219, 195, 60,
175293 /* 1650 */ 154, 155, 156, 157, 158, 86, 23, 195, 25, 195,
175294 /* 1660 */ 91, 19, 20, 142, 22, 218, 219, 218, 219, 130,
175295 /* 1670 */ 101, 218, 219, 143, 121, 122, 107, 108, 36, 183,
175296 /* 1680 */ 218, 219, 142, 60, 115, 118, 117, 118, 119, 7,
175297 /* 1690 */ 8, 122, 153, 23, 23, 25, 25, 23, 23, 25,
175298 /* 1700 */ 25, 23, 60, 25, 23, 98, 25, 118, 84, 85,
175299 /* 1710 */ 23, 23, 25, 25, 72, 154, 23, 156, 25, 23,
175300 /* 1720 */ 228, 25, 195, 154, 155, 156, 157, 158, 86, 195,
175301 /* 1730 */ 195, 258, 195, 91, 291, 322, 195, 195, 195, 195,
175302 /* 1740 */ 195, 118, 195, 101, 195, 195, 195, 195, 238, 107,
175303 /* 1750 */ 108, 195, 183, 195, 195, 195, 290, 115, 195, 117,
175304 /* 1760 */ 118, 119, 244, 195, 122, 195, 195, 195, 195, 195,
175305 /* 1770 */ 195, 258, 258, 258, 258, 193, 245, 300, 216, 274,
175306 /* 1780 */ 247, 270, 270, 274, 296, 296, 248, 222, 262, 198,
175307 /* 1790 */ 262, 274, 61, 274, 248, 231, 154, 155, 156, 157,
175308 /* 1800 */ 158, 0, 1, 2, 247, 227, 5, 221, 221, 221,
175309 /* 1810 */ 142, 10, 11, 12, 13, 14, 262, 262, 17, 202,
175310 /* 1820 */ 300, 19, 20, 300, 22, 183, 247, 251, 251, 245,
175311 /* 1830 */ 202, 30, 38, 32, 202, 152, 151, 22, 36, 43,
175312 /* 1840 */ 236, 40, 18, 202, 239, 239, 18, 239, 239, 283,
175313 /* 1850 */ 201, 150, 236, 202, 236, 201, 159, 202, 248, 248,
175314 /* 1860 */ 248, 248, 60, 63, 201, 275, 273, 275, 273, 275,
175315 /* 1870 */ 22, 286, 71, 223, 72, 202, 223, 297, 297, 202,
175316 /* 1880 */ 79, 201, 116, 82, 220, 201, 220, 220, 65, 293,
175317 /* 1890 */ 292, 229, 22, 166, 127, 226, 24, 114, 226, 223,
175318 /* 1900 */ 99, 222, 202, 101, 285, 92, 220, 308, 83, 107,
175319 /* 1910 */ 108, 220, 220, 316, 220, 285, 268, 115, 229, 117,
175320 /* 1920 */ 118, 119, 223, 321, 122, 268, 149, 146, 22, 19,
175321 /* 1930 */ 20, 202, 22, 159, 282, 134, 321, 148, 280, 147,
175322 /* 1940 */ 139, 140, 252, 141, 25, 204, 36, 252, 13, 251,
175323 /* 1950 */ 196, 248, 250, 249, 196, 6, 154, 155, 156, 157,
175324 /* 1960 */ 158, 209, 194, 194, 163, 194, 306, 306, 303, 224,
175325 /* 1970 */ 60, 215, 215, 209, 215, 215, 215, 224, 216, 216,
175326 /* 1980 */ 4, 209, 72, 3, 22, 183, 164, 15, 23, 16,
175327 /* 1990 */ 23, 140, 152, 131, 25, 24, 143, 20, 16, 145,
175328 /* 2000 */ 1, 143, 131, 62, 131, 37, 54, 152, 54, 54,
175329 /* 2010 */ 54, 101, 131, 117, 1, 34, 142, 107, 108, 5,
175330 /* 2020 */ 22, 116, 162, 76, 41, 115, 69, 117, 118, 119,
175331 /* 2030 */ 1, 2, 122, 25, 5, 69, 142, 116, 20, 10,
175332 /* 2040 */ 11, 12, 13, 14, 24, 19, 17, 132, 5, 126,
175333 /* 2050 */ 22, 141, 68, 10, 11, 12, 13, 14, 22, 30,
175334 /* 2060 */ 17, 32, 22, 22, 154, 155, 156, 157, 158, 40,
175335 /* 2070 */ 23, 68, 60, 30, 24, 32, 97, 28, 22, 68,
175336 /* 2080 */ 23, 37, 34, 40, 150, 22, 25, 23, 23, 23,
175337 /* 2090 */ 22, 98, 142, 183, 23, 23, 34, 22, 25, 89,
175338 /* 2100 */ 71, 34, 117, 144, 34, 22, 76, 76, 79, 87,
175339 /* 2110 */ 34, 82, 34, 44, 71, 94, 34, 23, 25, 24,
175340 /* 2120 */ 34, 25, 79, 23, 23, 82, 23, 23, 99, 143,
175341 /* 2130 */ 143, 22, 25, 25, 23, 22, 11, 22, 22, 25,
175342 /* 2140 */ 23, 23, 99, 22, 22, 136, 142, 142, 142, 25,
175343 /* 2150 */ 23, 15, 1, 1, 323, 323, 323, 323, 323, 323,
175344 /* 2160 */ 323, 323, 323, 134, 323, 323, 323, 323, 139, 140,
175345 /* 2170 */ 323, 323, 323, 323, 323, 323, 323, 134, 323, 323,
175346 /* 2180 */ 323, 323, 139, 140, 323, 323, 323, 323, 323, 323,
175347 /* 2190 */ 323, 323, 163, 323, 323, 323, 323, 323, 323, 323,
175348 /* 2200 */ 323, 323, 323, 323, 323, 323, 163, 323, 323, 323,
175349 /* 2210 */ 323, 323, 323, 323, 323, 323, 323, 323, 323, 323,
175350 /* 2220 */ 323, 323, 323, 323, 323, 323, 323, 323, 323, 323,
175351 /* 2230 */ 323, 323, 323, 323, 323, 323, 323, 323, 323, 323,
175352 /* 2240 */ 323, 323, 323, 323, 323, 323, 323, 323, 323, 323,
175353 /* 2250 */ 323, 323, 323, 323, 323, 323, 323, 323, 323, 323,
175354 /* 2260 */ 323, 323, 323, 323, 323, 323, 323, 323, 323, 323,
175355 /* 2270 */ 323, 323, 323, 323, 323, 323, 323, 323, 323, 323,
175356 /* 2280 */ 323, 323, 323, 323, 323, 323, 323, 323, 323, 323,
175357 /* 2290 */ 323, 323, 323, 323, 323, 323, 323, 323, 323, 323,
175358 /* 2300 */ 323, 323, 323, 323, 323, 323, 323, 323, 323, 323,
175359 /* 2310 */ 323, 323, 323, 323, 323, 323, 323, 323, 323, 323,
175360 /* 2320 */ 323, 323, 323, 323, 323, 323, 323, 323, 323, 323,
175361 /* 2330 */ 323, 323, 323, 323, 323, 323, 323, 323, 323, 323,
175362 /* 2340 */ 323, 187, 187, 187, 187, 187, 187, 187, 187, 187,
175363 /* 2350 */ 187, 187, 187, 187, 187, 187, 187, 187, 187, 187,
175364 /* 2360 */ 187, 187, 187, 187, 187, 187, 187, 187, 187, 187,
175365 /* 2370 */ 187, 187, 187, 187, 187, 187, 187, 187, 187, 187,
175366 /* 2380 */ 187, 187, 187, 187, 187, 187, 187, 187, 187, 187,
175367 /* 2390 */ 187, 187, 187, 187,
175368 };
175369 #define YY_SHIFT_COUNT (582)
175370 #define YY_SHIFT_MIN (0)
175371 #define YY_SHIFT_MAX (2152)
175372 static const unsigned short int yy_shift_ofst[] = {
175373 /* 0 */ 2029, 1801, 2043, 1380, 1380, 318, 271, 1496, 1569, 1642,
175374 /* 10 */ 702, 702, 702, 740, 318, 318, 318, 318, 318, 0,
175375 /* 20 */ 0, 216, 1177, 702, 702, 702, 702, 702, 702, 702,
175376 /* 30 */ 702, 702, 702, 702, 702, 702, 702, 702, 503, 503,
175377 /* 40 */ 111, 111, 217, 287, 348, 610, 610, 736, 736, 736,
175378 /* 50 */ 736, 40, 112, 320, 340, 445, 489, 593, 637, 741,
175379 /* 60 */ 785, 889, 909, 1023, 1043, 1157, 1177, 1177, 1177, 1177,
175380 /* 70 */ 1177, 1177, 1177, 1177, 1177, 1177, 1177, 1177, 1177, 1177,
175381 /* 80 */ 1177, 1177, 1177, 1177, 1197, 1177, 1301, 1321, 1321, 554,
175382 /* 90 */ 1802, 1910, 702, 702, 702, 702, 702, 702, 702, 702,
175383 /* 100 */ 702, 702, 702, 702, 702, 702, 702, 702, 702, 702,
175384 /* 110 */ 702, 702, 702, 702, 702, 702, 702, 702, 702, 702,
175385 /* 120 */ 702, 702, 702, 702, 702, 702, 702, 702, 702, 702,
175386 /* 130 */ 702, 702, 702, 702, 702, 702, 702, 702, 702, 702,
175387 /* 140 */ 702, 702, 138, 198, 198, 198, 198, 198, 198, 198,
175388 /* 150 */ 183, 99, 169, 549, 610, 151, 542, 610, 610, 1017,
175389 /* 160 */ 1017, 610, 1001, 350, 464, 464, 464, 586, 1, 1,
175390 /* 170 */ 2207, 2207, 854, 854, 854, 465, 694, 694, 694, 694,
175391 /* 180 */ 1096, 1096, 825, 549, 847, 904, 610, 610, 610, 610,
175392 /* 190 */ 610, 610, 610, 610, 610, 610, 610, 610, 610, 610,
175393 /* 200 */ 610, 610, 610, 610, 610, 488, 947, 947, 610, 1129,
175394 /* 210 */ 495, 495, 1139, 1139, 967, 967, 1173, 2207, 2207, 2207,
175395 /* 220 */ 2207, 2207, 2207, 2207, 617, 765, 765, 697, 444, 708,
175396 /* 230 */ 660, 745, 510, 663, 864, 610, 610, 610, 610, 610,
175397 /* 240 */ 610, 610, 610, 610, 610, 188, 610, 610, 610, 610,
175398 /* 250 */ 610, 610, 610, 610, 610, 610, 610, 610, 839, 839,
175399 /* 260 */ 839, 610, 610, 610, 1155, 610, 610, 610, 1119, 1247,
175400 /* 270 */ 610, 1353, 610, 610, 610, 610, 610, 610, 610, 610,
175401 /* 280 */ 1063, 494, 1101, 291, 291, 291, 291, 1319, 1101, 1101,
175402 /* 290 */ 775, 1221, 1375, 1452, 667, 1341, 1198, 1341, 1435, 1487,
175403 /* 300 */ 667, 667, 1487, 667, 1198, 1435, 777, 1011, 1423, 584,
175404 /* 310 */ 584, 584, 1273, 1273, 1273, 1273, 1471, 1471, 880, 1530,
175405 /* 320 */ 1190, 1095, 1731, 1731, 1668, 1668, 1794, 1794, 1668, 1683,
175406 /* 330 */ 1685, 1815, 1796, 1824, 1824, 1824, 1824, 1668, 1828, 1701,
175407 /* 340 */ 1685, 1685, 1701, 1815, 1796, 1701, 1796, 1701, 1668, 1828,
175408 /* 350 */ 1697, 1800, 1668, 1828, 1848, 1668, 1828, 1668, 1828, 1848,
175409 /* 360 */ 1766, 1766, 1766, 1823, 1870, 1870, 1848, 1766, 1767, 1766,
175410 /* 370 */ 1823, 1766, 1766, 1727, 1872, 1783, 1783, 1848, 1668, 1813,
175411 /* 380 */ 1813, 1825, 1825, 1777, 1781, 1906, 1668, 1774, 1777, 1789,
175412 /* 390 */ 1792, 1701, 1919, 1935, 1935, 1949, 1949, 1949, 2207, 2207,
175413 /* 400 */ 2207, 2207, 2207, 2207, 2207, 2207, 2207, 2207, 2207, 2207,
175414 /* 410 */ 2207, 2207, 2207, 69, 1032, 79, 357, 1377, 1206, 400,
175415 /* 420 */ 1525, 835, 332, 1540, 1437, 1539, 1536, 1548, 1583, 1620,
175416 /* 430 */ 1633, 1670, 1671, 1674, 1567, 1553, 1682, 1506, 1675, 1358,
175417 /* 440 */ 1607, 1589, 1678, 1681, 1624, 1687, 1688, 1283, 1561, 1693,
175418 /* 450 */ 1696, 1623, 1521, 1976, 1980, 1962, 1822, 1972, 1973, 1965,
175419 /* 460 */ 1967, 1851, 1840, 1862, 1969, 1969, 1971, 1853, 1977, 1854,
175420 /* 470 */ 1982, 1999, 1858, 1871, 1969, 1873, 1941, 1968, 1969, 1855,
175421 /* 480 */ 1952, 1954, 1955, 1956, 1881, 1896, 1981, 1874, 2013, 2014,
175422 /* 490 */ 1998, 1905, 1860, 1957, 2008, 1966, 1947, 1983, 1894, 1921,
175423 /* 500 */ 2020, 2018, 2026, 1915, 1923, 2028, 1984, 2036, 2040, 2047,
175424 /* 510 */ 2041, 2003, 2012, 2050, 1979, 2049, 2056, 2011, 2044, 2057,
175425 /* 520 */ 2048, 1934, 2063, 2064, 2065, 2061, 2066, 2068, 1993, 1950,
175426 /* 530 */ 2071, 2072, 1985, 2062, 2075, 1959, 2073, 2067, 2070, 2076,
175427 /* 540 */ 2078, 2010, 2030, 2022, 2069, 2031, 2021, 2082, 2094, 2083,
175428 /* 550 */ 2095, 2093, 2096, 2086, 1986, 1987, 2100, 2073, 2101, 2103,
175429 /* 560 */ 2104, 2109, 2107, 2108, 2111, 2113, 2125, 2115, 2116, 2117,
175430 /* 570 */ 2118, 2121, 2122, 2114, 2009, 2004, 2005, 2006, 2124, 2127,
175431 /* 580 */ 2136, 2151, 2152,
175432 };
175433 #define YY_REDUCE_COUNT (412)
175434 #define YY_REDUCE_MIN (-277)
175435 #define YY_REDUCE_MAX (1772)
175436 static const short yy_reduce_ofst[] = {
175437 /* 0 */ -67, 1252, -64, -178, -181, 160, 1071, 143, -184, 137,
175438 /* 10 */ 218, 220, 222, -174, 229, 268, 272, 275, 324, -208,
175439 /* 20 */ 242, -277, -39, 81, 537, 792, 810, 812, -189, 814,
175440 /* 30 */ 831, 163, 865, 944, 887, 840, 964, 1077, -187, 292,
175441 /* 40 */ -133, 274, 673, 558, 682, 795, 809, -238, -232, -238,
175442 /* 50 */ -232, 329, 329, 329, 329, 329, 329, 329, 329, 329,
175443 /* 60 */ 329, 329, 329, 329, 329, 329, 329, 329, 329, 329,
175444 /* 70 */ 329, 329, 329, 329, 329, 329, 329, 329, 329, 329,
175445 /* 80 */ 329, 329, 329, 329, 329, 329, 329, 329, 329, 557,
175446 /* 90 */ 712, 949, 966, 969, 971, 979, 1097, 1099, 1103, 1142,
175447 /* 100 */ 1144, 1169, 1172, 1201, 1203, 1228, 1241, 1250, 1253, 1255,
175448 /* 110 */ 1261, 1266, 1271, 1282, 1291, 1308, 1310, 1312, 1322, 1328,
175449 /* 120 */ 1347, 1354, 1356, 1359, 1362, 1365, 1367, 1374, 1376, 1381,
175450 /* 130 */ 1401, 1403, 1406, 1412, 1414, 1417, 1421, 1428, 1447, 1449,
175451 /* 140 */ 1453, 1462, 329, 329, 329, 329, 329, 329, 329, 329,
175452 /* 150 */ 329, 329, 329, -22, -159, 475, -220, 756, 38, 501,
175453 /* 160 */ 841, 714, 329, 118, 337, 349, 363, -56, 329, 329,
175454 /* 170 */ 329, 329, -205, -205, -205, 687, -172, -130, -57, 790,
175455 /* 180 */ 397, 528, -271, 136, 596, 596, 90, 316, 522, 541,
175456 /* 190 */ -37, 715, 849, 977, 628, 856, 980, 991, 1081, 1102,
175457 /* 200 */ 1135, 1083, -162, 208, 1258, 794, -86, 159, 41, 1109,
175458 /* 210 */ 671, 852, 844, 932, 1175, 1254, 480, 1180, 100, 258,
175459 /* 220 */ 1265, 1268, 1216, 1287, -139, 317, 344, 63, 339, 423,
175460 /* 230 */ 563, 636, 676, 813, 908, 914, 950, 1078, 1084, 1098,
175461 /* 240 */ 1363, 1384, 1407, 1439, 1464, 411, 1527, 1534, 1535, 1537,
175462 /* 250 */ 1541, 1542, 1543, 1544, 1545, 1547, 1549, 1550, 990, 1164,
175463 /* 260 */ 1492, 1551, 1552, 1556, 1217, 1558, 1559, 1560, 1473, 1413,
175464 /* 270 */ 1563, 1510, 1568, 563, 1570, 1571, 1572, 1573, 1574, 1575,
175465 /* 280 */ 1443, 1466, 1518, 1513, 1514, 1515, 1516, 1217, 1518, 1518,
175466 /* 290 */ 1531, 1562, 1582, 1477, 1505, 1511, 1533, 1512, 1488, 1538,
175467 /* 300 */ 1509, 1517, 1546, 1519, 1557, 1489, 1565, 1564, 1578, 1586,
175468 /* 310 */ 1587, 1588, 1526, 1528, 1554, 1555, 1576, 1577, 1566, 1579,
175469 /* 320 */ 1584, 1591, 1520, 1523, 1617, 1628, 1580, 1581, 1632, 1585,
175470 /* 330 */ 1590, 1593, 1604, 1605, 1606, 1608, 1609, 1641, 1649, 1610,
175471 /* 340 */ 1592, 1594, 1611, 1595, 1616, 1612, 1618, 1613, 1651, 1654,
175472 /* 350 */ 1596, 1598, 1655, 1663, 1650, 1673, 1680, 1677, 1684, 1653,
175473 /* 360 */ 1664, 1666, 1667, 1662, 1669, 1672, 1676, 1686, 1679, 1691,
175474 /* 370 */ 1689, 1692, 1694, 1597, 1599, 1619, 1630, 1699, 1700, 1602,
175475 /* 380 */ 1615, 1648, 1657, 1690, 1698, 1658, 1729, 1652, 1695, 1702,
175476 /* 390 */ 1704, 1703, 1741, 1754, 1758, 1768, 1769, 1771, 1660, 1661,
175477 /* 400 */ 1665, 1752, 1756, 1757, 1759, 1760, 1764, 1745, 1753, 1762,
175478 /* 410 */ 1763, 1761, 1772,
175479 };
175480 static const YYACTIONTYPE yy_default[] = {
175481 /* 0 */ 1663, 1663, 1663, 1491, 1254, 1367, 1254, 1254, 1254, 1254,
175482 /* 10 */ 1491, 1491, 1491, 1254, 1254, 1254, 1254, 1254, 1254, 1397,
175483 /* 20 */ 1397, 1544, 1287, 1254, 1254, 1254, 1254, 1254, 1254, 1254,
@@ -175355,10 +175739,11 @@
175739 0, /* ASTERISK => nothing */
175740 0, /* SPAN => nothing */
175741 0, /* ERROR => nothing */
175742 0, /* QNUMBER => nothing */
175743 0, /* SPACE => nothing */
175744 0, /* COMMENT => nothing */
175745 0, /* ILLEGAL => nothing */
175746 };
175747 #endif /* YYFALLBACK */
175748
175749 /* The following structure represents a single element of the
@@ -175624,147 +176009,148 @@
176009 /* 180 */ "ASTERISK",
176010 /* 181 */ "SPAN",
176011 /* 182 */ "ERROR",
176012 /* 183 */ "QNUMBER",
176013 /* 184 */ "SPACE",
176014 /* 185 */ "COMMENT",
176015 /* 186 */ "ILLEGAL",
176016 /* 187 */ "input",
176017 /* 188 */ "cmdlist",
176018 /* 189 */ "ecmd",
176019 /* 190 */ "cmdx",
176020 /* 191 */ "explain",
176021 /* 192 */ "cmd",
176022 /* 193 */ "transtype",
176023 /* 194 */ "trans_opt",
176024 /* 195 */ "nm",
176025 /* 196 */ "savepoint_opt",
176026 /* 197 */ "create_table",
176027 /* 198 */ "create_table_args",
176028 /* 199 */ "createkw",
176029 /* 200 */ "temp",
176030 /* 201 */ "ifnotexists",
176031 /* 202 */ "dbnm",
176032 /* 203 */ "columnlist",
176033 /* 204 */ "conslist_opt",
176034 /* 205 */ "table_option_set",
176035 /* 206 */ "select",
176036 /* 207 */ "table_option",
176037 /* 208 */ "columnname",
176038 /* 209 */ "carglist",
176039 /* 210 */ "typetoken",
176040 /* 211 */ "typename",
176041 /* 212 */ "signed",
176042 /* 213 */ "plus_num",
176043 /* 214 */ "minus_num",
176044 /* 215 */ "scanpt",
176045 /* 216 */ "scantok",
176046 /* 217 */ "ccons",
176047 /* 218 */ "term",
176048 /* 219 */ "expr",
176049 /* 220 */ "onconf",
176050 /* 221 */ "sortorder",
176051 /* 222 */ "autoinc",
176052 /* 223 */ "eidlist_opt",
176053 /* 224 */ "refargs",
176054 /* 225 */ "defer_subclause",
176055 /* 226 */ "generated",
176056 /* 227 */ "refarg",
176057 /* 228 */ "refact",
176058 /* 229 */ "init_deferred_pred_opt",
176059 /* 230 */ "conslist",
176060 /* 231 */ "tconscomma",
176061 /* 232 */ "tcons",
176062 /* 233 */ "sortlist",
176063 /* 234 */ "eidlist",
176064 /* 235 */ "defer_subclause_opt",
176065 /* 236 */ "orconf",
176066 /* 237 */ "resolvetype",
176067 /* 238 */ "raisetype",
176068 /* 239 */ "ifexists",
176069 /* 240 */ "fullname",
176070 /* 241 */ "selectnowith",
176071 /* 242 */ "oneselect",
176072 /* 243 */ "wqlist",
176073 /* 244 */ "multiselect_op",
176074 /* 245 */ "distinct",
176075 /* 246 */ "selcollist",
176076 /* 247 */ "from",
176077 /* 248 */ "where_opt",
176078 /* 249 */ "groupby_opt",
176079 /* 250 */ "having_opt",
176080 /* 251 */ "orderby_opt",
176081 /* 252 */ "limit_opt",
176082 /* 253 */ "window_clause",
176083 /* 254 */ "values",
176084 /* 255 */ "nexprlist",
176085 /* 256 */ "mvalues",
176086 /* 257 */ "sclp",
176087 /* 258 */ "as",
176088 /* 259 */ "seltablist",
176089 /* 260 */ "stl_prefix",
176090 /* 261 */ "joinop",
176091 /* 262 */ "on_using",
176092 /* 263 */ "indexed_by",
176093 /* 264 */ "exprlist",
176094 /* 265 */ "xfullname",
176095 /* 266 */ "idlist",
176096 /* 267 */ "indexed_opt",
176097 /* 268 */ "nulls",
176098 /* 269 */ "with",
176099 /* 270 */ "where_opt_ret",
176100 /* 271 */ "setlist",
176101 /* 272 */ "insert_cmd",
176102 /* 273 */ "idlist_opt",
176103 /* 274 */ "upsert",
176104 /* 275 */ "returning",
176105 /* 276 */ "filter_over",
176106 /* 277 */ "likeop",
176107 /* 278 */ "between_op",
176108 /* 279 */ "in_op",
176109 /* 280 */ "paren_exprlist",
176110 /* 281 */ "case_operand",
176111 /* 282 */ "case_exprlist",
176112 /* 283 */ "case_else",
176113 /* 284 */ "uniqueflag",
176114 /* 285 */ "collate",
176115 /* 286 */ "vinto",
176116 /* 287 */ "nmnum",
176117 /* 288 */ "trigger_decl",
176118 /* 289 */ "trigger_cmd_list",
176119 /* 290 */ "trigger_time",
176120 /* 291 */ "trigger_event",
176121 /* 292 */ "foreach_clause",
176122 /* 293 */ "when_clause",
176123 /* 294 */ "trigger_cmd",
176124 /* 295 */ "trnm",
176125 /* 296 */ "tridxby",
176126 /* 297 */ "database_kw_opt",
176127 /* 298 */ "key_opt",
176128 /* 299 */ "add_column_fullname",
176129 /* 300 */ "kwcolumn_opt",
176130 /* 301 */ "create_vtab",
176131 /* 302 */ "vtabarglist",
176132 /* 303 */ "vtabarg",
176133 /* 304 */ "vtabargtoken",
176134 /* 305 */ "lp",
176135 /* 306 */ "anylist",
176136 /* 307 */ "wqitem",
176137 /* 308 */ "wqas",
176138 /* 309 */ "withnm",
176139 /* 310 */ "windowdefn_list",
176140 /* 311 */ "windowdefn",
176141 /* 312 */ "window",
176142 /* 313 */ "frame_opt",
176143 /* 314 */ "part_opt",
176144 /* 315 */ "filter_clause",
176145 /* 316 */ "over_clause",
176146 /* 317 */ "range_or_rows",
176147 /* 318 */ "frame_bound",
176148 /* 319 */ "frame_bound_s",
176149 /* 320 */ "frame_bound_e",
176150 /* 321 */ "frame_exclude_opt",
176151 /* 322 */ "frame_exclude",
176152 };
176153 #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */
176154
176155 #ifndef NDEBUG
176156 /* For tracing reduce actions, the names of all rules are required.
@@ -176300,102 +176686,102 @@
176686 ** Note: during a reduce, the only symbols destroyed are those
176687 ** which appear on the RHS of the rule, but which are *not* used
176688 ** inside the C code.
176689 */
176690 /********* Begin destructor definitions ***************************************/
176691 case 206: /* select */
176692 case 241: /* selectnowith */
176693 case 242: /* oneselect */
176694 case 254: /* values */
176695 case 256: /* mvalues */
176696 {
176697 sqlite3SelectDelete(pParse->db, (yypminor->yy637));
176698 }
176699 break;
176700 case 218: /* term */
176701 case 219: /* expr */
176702 case 248: /* where_opt */
176703 case 250: /* having_opt */
176704 case 270: /* where_opt_ret */
176705 case 281: /* case_operand */
176706 case 283: /* case_else */
176707 case 286: /* vinto */
176708 case 293: /* when_clause */
176709 case 298: /* key_opt */
176710 case 315: /* filter_clause */
176711 {
176712 sqlite3ExprDelete(pParse->db, (yypminor->yy590));
176713 }
176714 break;
176715 case 223: /* eidlist_opt */
176716 case 233: /* sortlist */
176717 case 234: /* eidlist */
176718 case 246: /* selcollist */
176719 case 249: /* groupby_opt */
176720 case 251: /* orderby_opt */
176721 case 255: /* nexprlist */
176722 case 257: /* sclp */
176723 case 264: /* exprlist */
176724 case 271: /* setlist */
176725 case 280: /* paren_exprlist */
176726 case 282: /* case_exprlist */
176727 case 314: /* part_opt */
176728 {
176729 sqlite3ExprListDelete(pParse->db, (yypminor->yy402));
176730 }
176731 break;
176732 case 240: /* fullname */
176733 case 247: /* from */
176734 case 259: /* seltablist */
176735 case 260: /* stl_prefix */
176736 case 265: /* xfullname */
176737 {
176738 sqlite3SrcListDelete(pParse->db, (yypminor->yy563));
176739 }
176740 break;
176741 case 243: /* wqlist */
176742 {
176743 sqlite3WithDelete(pParse->db, (yypminor->yy125));
176744 }
176745 break;
176746 case 253: /* window_clause */
176747 case 310: /* windowdefn_list */
176748 {
176749 sqlite3WindowListDelete(pParse->db, (yypminor->yy483));
176750 }
176751 break;
176752 case 266: /* idlist */
176753 case 273: /* idlist_opt */
176754 {
176755 sqlite3IdListDelete(pParse->db, (yypminor->yy204));
176756 }
176757 break;
176758 case 276: /* filter_over */
176759 case 311: /* windowdefn */
176760 case 312: /* window */
176761 case 313: /* frame_opt */
176762 case 316: /* over_clause */
176763 {
176764 sqlite3WindowDelete(pParse->db, (yypminor->yy483));
176765 }
176766 break;
176767 case 289: /* trigger_cmd_list */
176768 case 294: /* trigger_cmd */
176769 {
176770 sqlite3DeleteTriggerStep(pParse->db, (yypminor->yy319));
176771 }
176772 break;
176773 case 291: /* trigger_event */
176774 {
176775 sqlite3IdListDelete(pParse->db, (yypminor->yy28).b);
176776 }
176777 break;
176778 case 318: /* frame_bound */
176779 case 319: /* frame_bound_s */
176780 case 320: /* frame_bound_e */
176781 {
176782 sqlite3ExprDelete(pParse->db, (yypminor->yy205).pExpr);
176783 }
176784 break;
176785 /********* End destructor definitions *****************************************/
176786 default: break; /* If no destructor action specified: do nothing */
176787 }
@@ -176693,419 +177079,419 @@
177079 }
177080
177081 /* For rule J, yyRuleInfoLhs[J] contains the symbol on the left-hand side
177082 ** of that rule */
177083 static const YYCODETYPE yyRuleInfoLhs[] = {
177084 191, /* (0) explain ::= EXPLAIN */
177085 191, /* (1) explain ::= EXPLAIN QUERY PLAN */
177086 190, /* (2) cmdx ::= cmd */
177087 192, /* (3) cmd ::= BEGIN transtype trans_opt */
177088 193, /* (4) transtype ::= */
177089 193, /* (5) transtype ::= DEFERRED */
177090 193, /* (6) transtype ::= IMMEDIATE */
177091 193, /* (7) transtype ::= EXCLUSIVE */
177092 192, /* (8) cmd ::= COMMIT|END trans_opt */
177093 192, /* (9) cmd ::= ROLLBACK trans_opt */
177094 192, /* (10) cmd ::= SAVEPOINT nm */
177095 192, /* (11) cmd ::= RELEASE savepoint_opt nm */
177096 192, /* (12) cmd ::= ROLLBACK trans_opt TO savepoint_opt nm */
177097 197, /* (13) create_table ::= createkw temp TABLE ifnotexists nm dbnm */
177098 199, /* (14) createkw ::= CREATE */
177099 201, /* (15) ifnotexists ::= */
177100 201, /* (16) ifnotexists ::= IF NOT EXISTS */
177101 200, /* (17) temp ::= TEMP */
177102 200, /* (18) temp ::= */
177103 198, /* (19) create_table_args ::= LP columnlist conslist_opt RP table_option_set */
177104 198, /* (20) create_table_args ::= AS select */
177105 205, /* (21) table_option_set ::= */
177106 205, /* (22) table_option_set ::= table_option_set COMMA table_option */
177107 207, /* (23) table_option ::= WITHOUT nm */
177108 207, /* (24) table_option ::= nm */
177109 208, /* (25) columnname ::= nm typetoken */
177110 210, /* (26) typetoken ::= */
177111 210, /* (27) typetoken ::= typename LP signed RP */
177112 210, /* (28) typetoken ::= typename LP signed COMMA signed RP */
177113 211, /* (29) typename ::= typename ID|STRING */
177114 215, /* (30) scanpt ::= */
177115 216, /* (31) scantok ::= */
177116 217, /* (32) ccons ::= CONSTRAINT nm */
177117 217, /* (33) ccons ::= DEFAULT scantok term */
177118 217, /* (34) ccons ::= DEFAULT LP expr RP */
177119 217, /* (35) ccons ::= DEFAULT PLUS scantok term */
177120 217, /* (36) ccons ::= DEFAULT MINUS scantok term */
177121 217, /* (37) ccons ::= DEFAULT scantok ID|INDEXED */
177122 217, /* (38) ccons ::= NOT NULL onconf */
177123 217, /* (39) ccons ::= PRIMARY KEY sortorder onconf autoinc */
177124 217, /* (40) ccons ::= UNIQUE onconf */
177125 217, /* (41) ccons ::= CHECK LP expr RP */
177126 217, /* (42) ccons ::= REFERENCES nm eidlist_opt refargs */
177127 217, /* (43) ccons ::= defer_subclause */
177128 217, /* (44) ccons ::= COLLATE ID|STRING */
177129 226, /* (45) generated ::= LP expr RP */
177130 226, /* (46) generated ::= LP expr RP ID */
177131 222, /* (47) autoinc ::= */
177132 222, /* (48) autoinc ::= AUTOINCR */
177133 224, /* (49) refargs ::= */
177134 224, /* (50) refargs ::= refargs refarg */
177135 227, /* (51) refarg ::= MATCH nm */
177136 227, /* (52) refarg ::= ON INSERT refact */
177137 227, /* (53) refarg ::= ON DELETE refact */
177138 227, /* (54) refarg ::= ON UPDATE refact */
177139 228, /* (55) refact ::= SET NULL */
177140 228, /* (56) refact ::= SET DEFAULT */
177141 228, /* (57) refact ::= CASCADE */
177142 228, /* (58) refact ::= RESTRICT */
177143 228, /* (59) refact ::= NO ACTION */
177144 225, /* (60) defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
177145 225, /* (61) defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
177146 229, /* (62) init_deferred_pred_opt ::= */
177147 229, /* (63) init_deferred_pred_opt ::= INITIALLY DEFERRED */
177148 229, /* (64) init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
177149 204, /* (65) conslist_opt ::= */
177150 231, /* (66) tconscomma ::= COMMA */
177151 232, /* (67) tcons ::= CONSTRAINT nm */
177152 232, /* (68) tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
177153 232, /* (69) tcons ::= UNIQUE LP sortlist RP onconf */
177154 232, /* (70) tcons ::= CHECK LP expr RP onconf */
177155 232, /* (71) tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
177156 235, /* (72) defer_subclause_opt ::= */
177157 220, /* (73) onconf ::= */
177158 220, /* (74) onconf ::= ON CONFLICT resolvetype */
177159 236, /* (75) orconf ::= */
177160 236, /* (76) orconf ::= OR resolvetype */
177161 237, /* (77) resolvetype ::= IGNORE */
177162 237, /* (78) resolvetype ::= REPLACE */
177163 192, /* (79) cmd ::= DROP TABLE ifexists fullname */
177164 239, /* (80) ifexists ::= IF EXISTS */
177165 239, /* (81) ifexists ::= */
177166 192, /* (82) cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
177167 192, /* (83) cmd ::= DROP VIEW ifexists fullname */
177168 192, /* (84) cmd ::= select */
177169 206, /* (85) select ::= WITH wqlist selectnowith */
177170 206, /* (86) select ::= WITH RECURSIVE wqlist selectnowith */
177171 206, /* (87) select ::= selectnowith */
177172 241, /* (88) selectnowith ::= selectnowith multiselect_op oneselect */
177173 244, /* (89) multiselect_op ::= UNION */
177174 244, /* (90) multiselect_op ::= UNION ALL */
177175 244, /* (91) multiselect_op ::= EXCEPT|INTERSECT */
177176 242, /* (92) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
177177 242, /* (93) oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */
177178 254, /* (94) values ::= VALUES LP nexprlist RP */
177179 242, /* (95) oneselect ::= mvalues */
177180 256, /* (96) mvalues ::= values COMMA LP nexprlist RP */
177181 256, /* (97) mvalues ::= mvalues COMMA LP nexprlist RP */
177182 245, /* (98) distinct ::= DISTINCT */
177183 245, /* (99) distinct ::= ALL */
177184 245, /* (100) distinct ::= */
177185 257, /* (101) sclp ::= */
177186 246, /* (102) selcollist ::= sclp scanpt expr scanpt as */
177187 246, /* (103) selcollist ::= sclp scanpt STAR */
177188 246, /* (104) selcollist ::= sclp scanpt nm DOT STAR */
177189 258, /* (105) as ::= AS nm */
177190 258, /* (106) as ::= */
177191 247, /* (107) from ::= */
177192 247, /* (108) from ::= FROM seltablist */
177193 260, /* (109) stl_prefix ::= seltablist joinop */
177194 260, /* (110) stl_prefix ::= */
177195 259, /* (111) seltablist ::= stl_prefix nm dbnm as on_using */
177196 259, /* (112) seltablist ::= stl_prefix nm dbnm as indexed_by on_using */
177197 259, /* (113) seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_using */
177198 259, /* (114) seltablist ::= stl_prefix LP select RP as on_using */
177199 259, /* (115) seltablist ::= stl_prefix LP seltablist RP as on_using */
177200 202, /* (116) dbnm ::= */
177201 202, /* (117) dbnm ::= DOT nm */
177202 240, /* (118) fullname ::= nm */
177203 240, /* (119) fullname ::= nm DOT nm */
177204 265, /* (120) xfullname ::= nm */
177205 265, /* (121) xfullname ::= nm DOT nm */
177206 265, /* (122) xfullname ::= nm DOT nm AS nm */
177207 265, /* (123) xfullname ::= nm AS nm */
177208 261, /* (124) joinop ::= COMMA|JOIN */
177209 261, /* (125) joinop ::= JOIN_KW JOIN */
177210 261, /* (126) joinop ::= JOIN_KW nm JOIN */
177211 261, /* (127) joinop ::= JOIN_KW nm nm JOIN */
177212 262, /* (128) on_using ::= ON expr */
177213 262, /* (129) on_using ::= USING LP idlist RP */
177214 262, /* (130) on_using ::= */
177215 267, /* (131) indexed_opt ::= */
177216 263, /* (132) indexed_by ::= INDEXED BY nm */
177217 263, /* (133) indexed_by ::= NOT INDEXED */
177218 251, /* (134) orderby_opt ::= */
177219 251, /* (135) orderby_opt ::= ORDER BY sortlist */
177220 233, /* (136) sortlist ::= sortlist COMMA expr sortorder nulls */
177221 233, /* (137) sortlist ::= expr sortorder nulls */
177222 221, /* (138) sortorder ::= ASC */
177223 221, /* (139) sortorder ::= DESC */
177224 221, /* (140) sortorder ::= */
177225 268, /* (141) nulls ::= NULLS FIRST */
177226 268, /* (142) nulls ::= NULLS LAST */
177227 268, /* (143) nulls ::= */
177228 249, /* (144) groupby_opt ::= */
177229 249, /* (145) groupby_opt ::= GROUP BY nexprlist */
177230 250, /* (146) having_opt ::= */
177231 250, /* (147) having_opt ::= HAVING expr */
177232 252, /* (148) limit_opt ::= */
177233 252, /* (149) limit_opt ::= LIMIT expr */
177234 252, /* (150) limit_opt ::= LIMIT expr OFFSET expr */
177235 252, /* (151) limit_opt ::= LIMIT expr COMMA expr */
177236 192, /* (152) cmd ::= with DELETE FROM xfullname indexed_opt where_opt_ret */
177237 248, /* (153) where_opt ::= */
177238 248, /* (154) where_opt ::= WHERE expr */
177239 270, /* (155) where_opt_ret ::= */
177240 270, /* (156) where_opt_ret ::= WHERE expr */
177241 270, /* (157) where_opt_ret ::= RETURNING selcollist */
177242 270, /* (158) where_opt_ret ::= WHERE expr RETURNING selcollist */
177243 192, /* (159) cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist from where_opt_ret */
177244 271, /* (160) setlist ::= setlist COMMA nm EQ expr */
177245 271, /* (161) setlist ::= setlist COMMA LP idlist RP EQ expr */
177246 271, /* (162) setlist ::= nm EQ expr */
177247 271, /* (163) setlist ::= LP idlist RP EQ expr */
177248 192, /* (164) cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
177249 192, /* (165) cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES returning */
177250 274, /* (166) upsert ::= */
177251 274, /* (167) upsert ::= RETURNING selcollist */
177252 274, /* (168) upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt upsert */
177253 274, /* (169) upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING upsert */
177254 274, /* (170) upsert ::= ON CONFLICT DO NOTHING returning */
177255 274, /* (171) upsert ::= ON CONFLICT DO UPDATE SET setlist where_opt returning */
177256 275, /* (172) returning ::= RETURNING selcollist */
177257 272, /* (173) insert_cmd ::= INSERT orconf */
177258 272, /* (174) insert_cmd ::= REPLACE */
177259 273, /* (175) idlist_opt ::= */
177260 273, /* (176) idlist_opt ::= LP idlist RP */
177261 266, /* (177) idlist ::= idlist COMMA nm */
177262 266, /* (178) idlist ::= nm */
177263 219, /* (179) expr ::= LP expr RP */
177264 219, /* (180) expr ::= ID|INDEXED|JOIN_KW */
177265 219, /* (181) expr ::= nm DOT nm */
177266 219, /* (182) expr ::= nm DOT nm DOT nm */
177267 218, /* (183) term ::= NULL|FLOAT|BLOB */
177268 218, /* (184) term ::= STRING */
177269 218, /* (185) term ::= INTEGER */
177270 219, /* (186) expr ::= VARIABLE */
177271 219, /* (187) expr ::= expr COLLATE ID|STRING */
177272 219, /* (188) expr ::= CAST LP expr AS typetoken RP */
177273 219, /* (189) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP */
177274 219, /* (190) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP */
177275 219, /* (191) expr ::= ID|INDEXED|JOIN_KW LP STAR RP */
177276 219, /* (192) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP filter_over */
177277 219, /* (193) expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP filter_over */
177278 219, /* (194) expr ::= ID|INDEXED|JOIN_KW LP STAR RP filter_over */
177279 218, /* (195) term ::= CTIME_KW */
177280 219, /* (196) expr ::= LP nexprlist COMMA expr RP */
177281 219, /* (197) expr ::= expr AND expr */
177282 219, /* (198) expr ::= expr OR expr */
177283 219, /* (199) expr ::= expr LT|GT|GE|LE expr */
177284 219, /* (200) expr ::= expr EQ|NE expr */
177285 219, /* (201) expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */
177286 219, /* (202) expr ::= expr PLUS|MINUS expr */
177287 219, /* (203) expr ::= expr STAR|SLASH|REM expr */
177288 219, /* (204) expr ::= expr CONCAT expr */
177289 277, /* (205) likeop ::= NOT LIKE_KW|MATCH */
177290 219, /* (206) expr ::= expr likeop expr */
177291 219, /* (207) expr ::= expr likeop expr ESCAPE expr */
177292 219, /* (208) expr ::= expr ISNULL|NOTNULL */
177293 219, /* (209) expr ::= expr NOT NULL */
177294 219, /* (210) expr ::= expr IS expr */
177295 219, /* (211) expr ::= expr IS NOT expr */
177296 219, /* (212) expr ::= expr IS NOT DISTINCT FROM expr */
177297 219, /* (213) expr ::= expr IS DISTINCT FROM expr */
177298 219, /* (214) expr ::= NOT expr */
177299 219, /* (215) expr ::= BITNOT expr */
177300 219, /* (216) expr ::= PLUS|MINUS expr */
177301 219, /* (217) expr ::= expr PTR expr */
177302 278, /* (218) between_op ::= BETWEEN */
177303 278, /* (219) between_op ::= NOT BETWEEN */
177304 219, /* (220) expr ::= expr between_op expr AND expr */
177305 279, /* (221) in_op ::= IN */
177306 279, /* (222) in_op ::= NOT IN */
177307 219, /* (223) expr ::= expr in_op LP exprlist RP */
177308 219, /* (224) expr ::= LP select RP */
177309 219, /* (225) expr ::= expr in_op LP select RP */
177310 219, /* (226) expr ::= expr in_op nm dbnm paren_exprlist */
177311 219, /* (227) expr ::= EXISTS LP select RP */
177312 219, /* (228) expr ::= CASE case_operand case_exprlist case_else END */
177313 282, /* (229) case_exprlist ::= case_exprlist WHEN expr THEN expr */
177314 282, /* (230) case_exprlist ::= WHEN expr THEN expr */
177315 283, /* (231) case_else ::= ELSE expr */
177316 283, /* (232) case_else ::= */
177317 281, /* (233) case_operand ::= */
177318 264, /* (234) exprlist ::= */
177319 255, /* (235) nexprlist ::= nexprlist COMMA expr */
177320 255, /* (236) nexprlist ::= expr */
177321 280, /* (237) paren_exprlist ::= */
177322 280, /* (238) paren_exprlist ::= LP exprlist RP */
177323 192, /* (239) cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
177324 284, /* (240) uniqueflag ::= UNIQUE */
177325 284, /* (241) uniqueflag ::= */
177326 223, /* (242) eidlist_opt ::= */
177327 223, /* (243) eidlist_opt ::= LP eidlist RP */
177328 234, /* (244) eidlist ::= eidlist COMMA nm collate sortorder */
177329 234, /* (245) eidlist ::= nm collate sortorder */
177330 285, /* (246) collate ::= */
177331 285, /* (247) collate ::= COLLATE ID|STRING */
177332 192, /* (248) cmd ::= DROP INDEX ifexists fullname */
177333 192, /* (249) cmd ::= VACUUM vinto */
177334 192, /* (250) cmd ::= VACUUM nm vinto */
177335 286, /* (251) vinto ::= INTO expr */
177336 286, /* (252) vinto ::= */
177337 192, /* (253) cmd ::= PRAGMA nm dbnm */
177338 192, /* (254) cmd ::= PRAGMA nm dbnm EQ nmnum */
177339 192, /* (255) cmd ::= PRAGMA nm dbnm LP nmnum RP */
177340 192, /* (256) cmd ::= PRAGMA nm dbnm EQ minus_num */
177341 192, /* (257) cmd ::= PRAGMA nm dbnm LP minus_num RP */
177342 213, /* (258) plus_num ::= PLUS INTEGER|FLOAT */
177343 214, /* (259) minus_num ::= MINUS INTEGER|FLOAT */
177344 192, /* (260) cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
177345 288, /* (261) trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
177346 290, /* (262) trigger_time ::= BEFORE|AFTER */
177347 290, /* (263) trigger_time ::= INSTEAD OF */
177348 290, /* (264) trigger_time ::= */
177349 291, /* (265) trigger_event ::= DELETE|INSERT */
177350 291, /* (266) trigger_event ::= UPDATE */
177351 291, /* (267) trigger_event ::= UPDATE OF idlist */
177352 293, /* (268) when_clause ::= */
177353 293, /* (269) when_clause ::= WHEN expr */
177354 289, /* (270) trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
177355 289, /* (271) trigger_cmd_list ::= trigger_cmd SEMI */
177356 295, /* (272) trnm ::= nm DOT nm */
177357 296, /* (273) tridxby ::= INDEXED BY nm */
177358 296, /* (274) tridxby ::= NOT INDEXED */
177359 294, /* (275) trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */
177360 294, /* (276) trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
177361 294, /* (277) trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
177362 294, /* (278) trigger_cmd ::= scanpt select scanpt */
177363 219, /* (279) expr ::= RAISE LP IGNORE RP */
177364 219, /* (280) expr ::= RAISE LP raisetype COMMA expr RP */
177365 238, /* (281) raisetype ::= ROLLBACK */
177366 238, /* (282) raisetype ::= ABORT */
177367 238, /* (283) raisetype ::= FAIL */
177368 192, /* (284) cmd ::= DROP TRIGGER ifexists fullname */
177369 192, /* (285) cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
177370 192, /* (286) cmd ::= DETACH database_kw_opt expr */
177371 298, /* (287) key_opt ::= */
177372 298, /* (288) key_opt ::= KEY expr */
177373 192, /* (289) cmd ::= REINDEX */
177374 192, /* (290) cmd ::= REINDEX nm dbnm */
177375 192, /* (291) cmd ::= ANALYZE */
177376 192, /* (292) cmd ::= ANALYZE nm dbnm */
177377 192, /* (293) cmd ::= ALTER TABLE fullname RENAME TO nm */
177378 192, /* (294) cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
177379 192, /* (295) cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */
177380 299, /* (296) add_column_fullname ::= fullname */
177381 192, /* (297) cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
177382 192, /* (298) cmd ::= create_vtab */
177383 192, /* (299) cmd ::= create_vtab LP vtabarglist RP */
177384 301, /* (300) create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
177385 303, /* (301) vtabarg ::= */
177386 304, /* (302) vtabargtoken ::= ANY */
177387 304, /* (303) vtabargtoken ::= lp anylist RP */
177388 305, /* (304) lp ::= LP */
177389 269, /* (305) with ::= WITH wqlist */
177390 269, /* (306) with ::= WITH RECURSIVE wqlist */
177391 308, /* (307) wqas ::= AS */
177392 308, /* (308) wqas ::= AS MATERIALIZED */
177393 308, /* (309) wqas ::= AS NOT MATERIALIZED */
177394 307, /* (310) wqitem ::= withnm eidlist_opt wqas LP select RP */
177395 309, /* (311) withnm ::= nm */
177396 243, /* (312) wqlist ::= wqitem */
177397 243, /* (313) wqlist ::= wqlist COMMA wqitem */
177398 310, /* (314) windowdefn_list ::= windowdefn_list COMMA windowdefn */
177399 311, /* (315) windowdefn ::= nm AS LP window RP */
177400 312, /* (316) window ::= PARTITION BY nexprlist orderby_opt frame_opt */
177401 312, /* (317) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
177402 312, /* (318) window ::= ORDER BY sortlist frame_opt */
177403 312, /* (319) window ::= nm ORDER BY sortlist frame_opt */
177404 312, /* (320) window ::= nm frame_opt */
177405 313, /* (321) frame_opt ::= */
177406 313, /* (322) frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */
177407 313, /* (323) frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */
177408 317, /* (324) range_or_rows ::= RANGE|ROWS|GROUPS */
177409 319, /* (325) frame_bound_s ::= frame_bound */
177410 319, /* (326) frame_bound_s ::= UNBOUNDED PRECEDING */
177411 320, /* (327) frame_bound_e ::= frame_bound */
177412 320, /* (328) frame_bound_e ::= UNBOUNDED FOLLOWING */
177413 318, /* (329) frame_bound ::= expr PRECEDING|FOLLOWING */
177414 318, /* (330) frame_bound ::= CURRENT ROW */
177415 321, /* (331) frame_exclude_opt ::= */
177416 321, /* (332) frame_exclude_opt ::= EXCLUDE frame_exclude */
177417 322, /* (333) frame_exclude ::= NO OTHERS */
177418 322, /* (334) frame_exclude ::= CURRENT ROW */
177419 322, /* (335) frame_exclude ::= GROUP|TIES */
177420 253, /* (336) window_clause ::= WINDOW windowdefn_list */
177421 276, /* (337) filter_over ::= filter_clause over_clause */
177422 276, /* (338) filter_over ::= over_clause */
177423 276, /* (339) filter_over ::= filter_clause */
177424 316, /* (340) over_clause ::= OVER LP window RP */
177425 316, /* (341) over_clause ::= OVER nm */
177426 315, /* (342) filter_clause ::= FILTER LP WHERE expr RP */
177427 218, /* (343) term ::= QNUMBER */
177428 187, /* (344) input ::= cmdlist */
177429 188, /* (345) cmdlist ::= cmdlist ecmd */
177430 188, /* (346) cmdlist ::= ecmd */
177431 189, /* (347) ecmd ::= SEMI */
177432 189, /* (348) ecmd ::= cmdx SEMI */
177433 189, /* (349) ecmd ::= explain cmdx SEMI */
177434 194, /* (350) trans_opt ::= */
177435 194, /* (351) trans_opt ::= TRANSACTION */
177436 194, /* (352) trans_opt ::= TRANSACTION nm */
177437 196, /* (353) savepoint_opt ::= SAVEPOINT */
177438 196, /* (354) savepoint_opt ::= */
177439 192, /* (355) cmd ::= create_table create_table_args */
177440 205, /* (356) table_option_set ::= table_option */
177441 203, /* (357) columnlist ::= columnlist COMMA columnname carglist */
177442 203, /* (358) columnlist ::= columnname carglist */
177443 195, /* (359) nm ::= ID|INDEXED|JOIN_KW */
177444 195, /* (360) nm ::= STRING */
177445 210, /* (361) typetoken ::= typename */
177446 211, /* (362) typename ::= ID|STRING */
177447 212, /* (363) signed ::= plus_num */
177448 212, /* (364) signed ::= minus_num */
177449 209, /* (365) carglist ::= carglist ccons */
177450 209, /* (366) carglist ::= */
177451 217, /* (367) ccons ::= NULL onconf */
177452 217, /* (368) ccons ::= GENERATED ALWAYS AS generated */
177453 217, /* (369) ccons ::= AS generated */
177454 204, /* (370) conslist_opt ::= COMMA conslist */
177455 230, /* (371) conslist ::= conslist tconscomma tcons */
177456 230, /* (372) conslist ::= tcons */
177457 231, /* (373) tconscomma ::= */
177458 235, /* (374) defer_subclause_opt ::= defer_subclause */
177459 237, /* (375) resolvetype ::= raisetype */
177460 241, /* (376) selectnowith ::= oneselect */
177461 242, /* (377) oneselect ::= values */
177462 257, /* (378) sclp ::= selcollist COMMA */
177463 258, /* (379) as ::= ID|STRING */
177464 267, /* (380) indexed_opt ::= indexed_by */
177465 275, /* (381) returning ::= */
177466 219, /* (382) expr ::= term */
177467 277, /* (383) likeop ::= LIKE_KW|MATCH */
177468 281, /* (384) case_operand ::= expr */
177469 264, /* (385) exprlist ::= nexprlist */
177470 287, /* (386) nmnum ::= plus_num */
177471 287, /* (387) nmnum ::= nm */
177472 287, /* (388) nmnum ::= ON */
177473 287, /* (389) nmnum ::= DELETE */
177474 287, /* (390) nmnum ::= DEFAULT */
177475 213, /* (391) plus_num ::= INTEGER|FLOAT */
177476 292, /* (392) foreach_clause ::= */
177477 292, /* (393) foreach_clause ::= FOR EACH ROW */
177478 295, /* (394) trnm ::= nm */
177479 296, /* (395) tridxby ::= */
177480 297, /* (396) database_kw_opt ::= DATABASE */
177481 297, /* (397) database_kw_opt ::= */
177482 300, /* (398) kwcolumn_opt ::= */
177483 300, /* (399) kwcolumn_opt ::= COLUMNKW */
177484 302, /* (400) vtabarglist ::= vtabarg */
177485 302, /* (401) vtabarglist ::= vtabarglist COMMA vtabarg */
177486 303, /* (402) vtabarg ::= vtabarg vtabargtoken */
177487 306, /* (403) anylist ::= */
177488 306, /* (404) anylist ::= anylist LP anylist RP */
177489 306, /* (405) anylist ::= anylist ANY */
177490 269, /* (406) with ::= */
177491 310, /* (407) windowdefn_list ::= windowdefn */
177492 312, /* (408) window ::= frame_opt */
177493 };
177494
177495 /* For rule J, yyRuleInfoNRhs[J] contains the negative of the number
177496 ** of symbols on the right-hand side of that rule. */
177497 static const signed char yyRuleInfoNRhs[] = {
@@ -177567,20 +177953,20 @@
177953 break;
177954 case 2: /* cmdx ::= cmd */
177955 { sqlite3FinishCoding(pParse); }
177956 break;
177957 case 3: /* cmd ::= BEGIN transtype trans_opt */
177958 {sqlite3BeginTransaction(pParse, yymsp[-1].minor.yy502);}
177959 break;
177960 case 4: /* transtype ::= */
177961 {yymsp[1].minor.yy502 = TK_DEFERRED;}
177962 break;
177963 case 5: /* transtype ::= DEFERRED */
177964 case 6: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==6);
177965 case 7: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==7);
177966 case 324: /* range_or_rows ::= RANGE|ROWS|GROUPS */ yytestcase(yyruleno==324);
177967 {yymsp[0].minor.yy502 = yymsp[0].major; /*A-overwrites-X*/}
177968 break;
177969 case 8: /* cmd ::= COMMIT|END trans_opt */
177970 case 9: /* cmd ::= ROLLBACK trans_opt */ yytestcase(yyruleno==9);
177971 {sqlite3EndTransaction(pParse,yymsp[-1].major);}
177972 break;
@@ -177599,70 +177985,72 @@
177985 sqlite3Savepoint(pParse, SAVEPOINT_ROLLBACK, &yymsp[0].minor.yy0);
177986 }
177987 break;
177988 case 13: /* create_table ::= createkw temp TABLE ifnotexists nm dbnm */
177989 {
177990 sqlite3StartTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,yymsp[-4].minor.yy502,0,0,yymsp[-2].minor.yy502);
177991 }
177992 break;
177993 case 14: /* createkw ::= CREATE */
177994 {
177995 disableLookaside(pParse);
177996 }
177997 break;
177998 case 15: /* ifnotexists ::= */
177999 case 18: /* temp ::= */ yytestcase(yyruleno==18);
178000 case 47: /* autoinc ::= */ yytestcase(yyruleno==47);
178001 case 62: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==62);
178002 case 72: /* defer_subclause_opt ::= */ yytestcase(yyruleno==72);
178003 case 81: /* ifexists ::= */ yytestcase(yyruleno==81);
178004 case 100: /* distinct ::= */ yytestcase(yyruleno==100);
178005 case 246: /* collate ::= */ yytestcase(yyruleno==246);
178006 {yymsp[1].minor.yy502 = 0;}
178007 break;
178008 case 16: /* ifnotexists ::= IF NOT EXISTS */
178009 {yymsp[-2].minor.yy502 = 1;}
178010 break;
178011 case 17: /* temp ::= TEMP */
178012 {yymsp[0].minor.yy502 = pParse->db->init.busy==0;}
178013 break;
178014 case 19: /* create_table_args ::= LP columnlist conslist_opt RP table_option_set */
178015 {
178016 sqlite3EndTable(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,yymsp[0].minor.yy9,0);
178017 }
178018 break;
178019 case 20: /* create_table_args ::= AS select */
178020 {
178021 sqlite3EndTable(pParse,0,0,0,yymsp[0].minor.yy637);
178022 sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy637);
178023 }
178024 break;
178025 case 21: /* table_option_set ::= */
178026 {yymsp[1].minor.yy9 = 0;}
178027 break;
178028 case 22: /* table_option_set ::= table_option_set COMMA table_option */
178029 {yylhsminor.yy9 = yymsp[-2].minor.yy9|yymsp[0].minor.yy9;}
178030 yymsp[-2].minor.yy9 = yylhsminor.yy9;
178031 break;
178032 case 23: /* table_option ::= WITHOUT nm */
178033 {
178034 if( yymsp[0].minor.yy0.n==5 && sqlite3_strnicmp(yymsp[0].minor.yy0.z,"rowid",5)==0 ){
178035 yymsp[-1].minor.yy9 = TF_WithoutRowid | TF_NoVisibleRowid;
178036 }else{
178037 yymsp[-1].minor.yy9 = 0;
178038 sqlite3ErrorMsg(pParse, "unknown table option: %.*s", yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.z);
178039 }
178040 }
178041 break;
178042 case 24: /* table_option ::= nm */
178043 {
178044 if( yymsp[0].minor.yy0.n==6 && sqlite3_strnicmp(yymsp[0].minor.yy0.z,"strict",6)==0 ){
178045 yylhsminor.yy9 = TF_Strict;
178046 }else{
178047 yylhsminor.yy9 = 0;
178048 sqlite3ErrorMsg(pParse, "unknown table option: %.*s", yymsp[0].minor.yy0.n, yymsp[0].minor.yy0.z);
178049 }
178050 }
178051 yymsp[0].minor.yy9 = yylhsminor.yy9;
178052 break;
178053 case 25: /* columnname ::= nm typetoken */
178054 {sqlite3AddColumn(pParse,yymsp[-1].minor.yy0,yymsp[0].minor.yy0);}
178055 break;
178056 case 26: /* typetoken ::= */
@@ -177684,11 +178072,11 @@
178072 {yymsp[-1].minor.yy0.n=yymsp[0].minor.yy0.n+(int)(yymsp[0].minor.yy0.z-yymsp[-1].minor.yy0.z);}
178073 break;
178074 case 30: /* scanpt ::= */
178075 {
178076 assert( yyLookahead!=YYNOCODE );
178077 yymsp[1].minor.yy342 = yyLookaheadToken.z;
178078 }
178079 break;
178080 case 31: /* scantok ::= */
178081 {
178082 assert( yyLookahead!=YYNOCODE );
@@ -177695,24 +178083,24 @@
178083 yymsp[1].minor.yy0 = yyLookaheadToken;
178084 }
178085 break;
178086 case 32: /* ccons ::= CONSTRAINT nm */
178087 case 67: /* tcons ::= CONSTRAINT nm */ yytestcase(yyruleno==67);
178088 {ASSERT_IS_CREATE; pParse->u1.cr.constraintName = yymsp[0].minor.yy0;}
178089 break;
178090 case 33: /* ccons ::= DEFAULT scantok term */
178091 {sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy590,yymsp[-1].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);}
178092 break;
178093 case 34: /* ccons ::= DEFAULT LP expr RP */
178094 {sqlite3AddDefaultValue(pParse,yymsp[-1].minor.yy590,yymsp[-2].minor.yy0.z+1,yymsp[0].minor.yy0.z);}
178095 break;
178096 case 35: /* ccons ::= DEFAULT PLUS scantok term */
178097 {sqlite3AddDefaultValue(pParse,yymsp[0].minor.yy590,yymsp[-2].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);}
178098 break;
178099 case 36: /* ccons ::= DEFAULT MINUS scantok term */
178100 {
178101 Expr *p = sqlite3PExpr(pParse, TK_UMINUS, yymsp[0].minor.yy590, 0);
178102 sqlite3AddDefaultValue(pParse,p,yymsp[-2].minor.yy0.z,&yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n]);
178103 }
178104 break;
178105 case 37: /* ccons ::= DEFAULT scantok ID|INDEXED */
178106 {
@@ -177723,262 +178111,262 @@
178111 }
178112 sqlite3AddDefaultValue(pParse,p,yymsp[0].minor.yy0.z,yymsp[0].minor.yy0.z+yymsp[0].minor.yy0.n);
178113 }
178114 break;
178115 case 38: /* ccons ::= NOT NULL onconf */
178116 {sqlite3AddNotNull(pParse, yymsp[0].minor.yy502);}
178117 break;
178118 case 39: /* ccons ::= PRIMARY KEY sortorder onconf autoinc */
178119 {sqlite3AddPrimaryKey(pParse,0,yymsp[-1].minor.yy502,yymsp[0].minor.yy502,yymsp[-2].minor.yy502);}
178120 break;
178121 case 40: /* ccons ::= UNIQUE onconf */
178122 {sqlite3CreateIndex(pParse,0,0,0,0,yymsp[0].minor.yy502,0,0,0,0,
178123 SQLITE_IDXTYPE_UNIQUE);}
178124 break;
178125 case 41: /* ccons ::= CHECK LP expr RP */
178126 {sqlite3AddCheckConstraint(pParse,yymsp[-1].minor.yy590,yymsp[-2].minor.yy0.z,yymsp[0].minor.yy0.z);}
178127 break;
178128 case 42: /* ccons ::= REFERENCES nm eidlist_opt refargs */
178129 {sqlite3CreateForeignKey(pParse,0,&yymsp[-2].minor.yy0,yymsp[-1].minor.yy402,yymsp[0].minor.yy502);}
178130 break;
178131 case 43: /* ccons ::= defer_subclause */
178132 {sqlite3DeferForeignKey(pParse,yymsp[0].minor.yy502);}
178133 break;
178134 case 44: /* ccons ::= COLLATE ID|STRING */
178135 {sqlite3AddCollateType(pParse, &yymsp[0].minor.yy0);}
178136 break;
178137 case 45: /* generated ::= LP expr RP */
178138 {sqlite3AddGenerated(pParse,yymsp[-1].minor.yy590,0);}
178139 break;
178140 case 46: /* generated ::= LP expr RP ID */
178141 {sqlite3AddGenerated(pParse,yymsp[-2].minor.yy590,&yymsp[0].minor.yy0);}
178142 break;
178143 case 48: /* autoinc ::= AUTOINCR */
178144 {yymsp[0].minor.yy502 = 1;}
178145 break;
178146 case 49: /* refargs ::= */
178147 { yymsp[1].minor.yy502 = OE_None*0x0101; /* EV: R-19803-45884 */}
178148 break;
178149 case 50: /* refargs ::= refargs refarg */
178150 { yymsp[-1].minor.yy502 = (yymsp[-1].minor.yy502 & ~yymsp[0].minor.yy481.mask) | yymsp[0].minor.yy481.value; }
178151 break;
178152 case 51: /* refarg ::= MATCH nm */
178153 { yymsp[-1].minor.yy481.value = 0; yymsp[-1].minor.yy481.mask = 0x000000; }
178154 break;
178155 case 52: /* refarg ::= ON INSERT refact */
178156 { yymsp[-2].minor.yy481.value = 0; yymsp[-2].minor.yy481.mask = 0x000000; }
178157 break;
178158 case 53: /* refarg ::= ON DELETE refact */
178159 { yymsp[-2].minor.yy481.value = yymsp[0].minor.yy502; yymsp[-2].minor.yy481.mask = 0x0000ff; }
178160 break;
178161 case 54: /* refarg ::= ON UPDATE refact */
178162 { yymsp[-2].minor.yy481.value = yymsp[0].minor.yy502<<8; yymsp[-2].minor.yy481.mask = 0x00ff00; }
178163 break;
178164 case 55: /* refact ::= SET NULL */
178165 { yymsp[-1].minor.yy502 = OE_SetNull; /* EV: R-33326-45252 */}
178166 break;
178167 case 56: /* refact ::= SET DEFAULT */
178168 { yymsp[-1].minor.yy502 = OE_SetDflt; /* EV: R-33326-45252 */}
178169 break;
178170 case 57: /* refact ::= CASCADE */
178171 { yymsp[0].minor.yy502 = OE_Cascade; /* EV: R-33326-45252 */}
178172 break;
178173 case 58: /* refact ::= RESTRICT */
178174 { yymsp[0].minor.yy502 = OE_Restrict; /* EV: R-33326-45252 */}
178175 break;
178176 case 59: /* refact ::= NO ACTION */
178177 { yymsp[-1].minor.yy502 = OE_None; /* EV: R-33326-45252 */}
178178 break;
178179 case 60: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */
178180 {yymsp[-2].minor.yy502 = 0;}
178181 break;
178182 case 61: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
178183 case 76: /* orconf ::= OR resolvetype */ yytestcase(yyruleno==76);
178184 case 173: /* insert_cmd ::= INSERT orconf */ yytestcase(yyruleno==173);
178185 {yymsp[-1].minor.yy502 = yymsp[0].minor.yy502;}
178186 break;
178187 case 63: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */
178188 case 80: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==80);
178189 case 219: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==219);
178190 case 222: /* in_op ::= NOT IN */ yytestcase(yyruleno==222);
178191 case 247: /* collate ::= COLLATE ID|STRING */ yytestcase(yyruleno==247);
178192 {yymsp[-1].minor.yy502 = 1;}
178193 break;
178194 case 64: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */
178195 {yymsp[-1].minor.yy502 = 0;}
178196 break;
178197 case 66: /* tconscomma ::= COMMA */
178198 {ASSERT_IS_CREATE; pParse->u1.cr.constraintName.n = 0;}
178199 break;
178200 case 68: /* tcons ::= PRIMARY KEY LP sortlist autoinc RP onconf */
178201 {sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy402,yymsp[0].minor.yy502,yymsp[-2].minor.yy502,0);}
178202 break;
178203 case 69: /* tcons ::= UNIQUE LP sortlist RP onconf */
178204 {sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy402,yymsp[0].minor.yy502,0,0,0,0,
178205 SQLITE_IDXTYPE_UNIQUE);}
178206 break;
178207 case 70: /* tcons ::= CHECK LP expr RP onconf */
178208 {sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy590,yymsp[-3].minor.yy0.z,yymsp[-1].minor.yy0.z);}
178209 break;
178210 case 71: /* tcons ::= FOREIGN KEY LP eidlist RP REFERENCES nm eidlist_opt refargs defer_subclause_opt */
178211 {
178212 sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy402, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy402, yymsp[-1].minor.yy502);
178213 sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy502);
178214 }
178215 break;
178216 case 73: /* onconf ::= */
178217 case 75: /* orconf ::= */ yytestcase(yyruleno==75);
178218 {yymsp[1].minor.yy502 = OE_Default;}
178219 break;
178220 case 74: /* onconf ::= ON CONFLICT resolvetype */
178221 {yymsp[-2].minor.yy502 = yymsp[0].minor.yy502;}
178222 break;
178223 case 77: /* resolvetype ::= IGNORE */
178224 {yymsp[0].minor.yy502 = OE_Ignore;}
178225 break;
178226 case 78: /* resolvetype ::= REPLACE */
178227 case 174: /* insert_cmd ::= REPLACE */ yytestcase(yyruleno==174);
178228 {yymsp[0].minor.yy502 = OE_Replace;}
178229 break;
178230 case 79: /* cmd ::= DROP TABLE ifexists fullname */
178231 {
178232 sqlite3DropTable(pParse, yymsp[0].minor.yy563, 0, yymsp[-1].minor.yy502);
178233 }
178234 break;
178235 case 82: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm eidlist_opt AS select */
178236 {
178237 sqlite3CreateView(pParse, &yymsp[-8].minor.yy0, &yymsp[-4].minor.yy0, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy402, yymsp[0].minor.yy637, yymsp[-7].minor.yy502, yymsp[-5].minor.yy502);
178238 }
178239 break;
178240 case 83: /* cmd ::= DROP VIEW ifexists fullname */
178241 {
178242 sqlite3DropTable(pParse, yymsp[0].minor.yy563, 1, yymsp[-1].minor.yy502);
178243 }
178244 break;
178245 case 84: /* cmd ::= select */
178246 {
178247 SelectDest dest = {SRT_Output, 0, 0, 0, 0, 0, 0};
178248 if( (pParse->db->mDbFlags & DBFLAG_EncodingFixed)!=0
178249 || sqlite3ReadSchema(pParse)==SQLITE_OK
178250 ){
178251 sqlite3Select(pParse, yymsp[0].minor.yy637, &dest);
178252 }
178253 sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy637);
178254 }
178255 break;
178256 case 85: /* select ::= WITH wqlist selectnowith */
178257 {yymsp[-2].minor.yy637 = attachWithToSelect(pParse,yymsp[0].minor.yy637,yymsp[-1].minor.yy125);}
178258 break;
178259 case 86: /* select ::= WITH RECURSIVE wqlist selectnowith */
178260 {yymsp[-3].minor.yy637 = attachWithToSelect(pParse,yymsp[0].minor.yy637,yymsp[-1].minor.yy125);}
178261 break;
178262 case 87: /* select ::= selectnowith */
178263 {
178264 Select *p = yymsp[0].minor.yy637;
178265 if( p ){
178266 parserDoubleLinkSelect(pParse, p);
178267 }
178268 }
178269 break;
178270 case 88: /* selectnowith ::= selectnowith multiselect_op oneselect */
178271 {
178272 Select *pRhs = yymsp[0].minor.yy637;
178273 Select *pLhs = yymsp[-2].minor.yy637;
178274 if( pRhs && pRhs->pPrior ){
178275 SrcList *pFrom;
178276 Token x;
178277 x.n = 0;
178278 parserDoubleLinkSelect(pParse, pRhs);
178279 pFrom = sqlite3SrcListAppendFromTerm(pParse,0,0,0,&x,pRhs,0);
178280 pRhs = sqlite3SelectNew(pParse,0,pFrom,0,0,0,0,0,0);
178281 }
178282 if( pRhs ){
178283 pRhs->op = (u8)yymsp[-1].minor.yy502;
178284 pRhs->pPrior = pLhs;
178285 if( ALWAYS(pLhs) ) pLhs->selFlags &= ~SF_MultiValue;
178286 pRhs->selFlags &= ~SF_MultiValue;
178287 if( yymsp[-1].minor.yy502!=TK_ALL ) pParse->hasCompound = 1;
178288 }else{
178289 sqlite3SelectDelete(pParse->db, pLhs);
178290 }
178291 yymsp[-2].minor.yy637 = pRhs;
178292 }
178293 break;
178294 case 89: /* multiselect_op ::= UNION */
178295 case 91: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==91);
178296 {yymsp[0].minor.yy502 = yymsp[0].major; /*A-overwrites-OP*/}
178297 break;
178298 case 90: /* multiselect_op ::= UNION ALL */
178299 {yymsp[-1].minor.yy502 = TK_ALL;}
178300 break;
178301 case 92: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
178302 {
178303 yymsp[-8].minor.yy637 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy402,yymsp[-5].minor.yy563,yymsp[-4].minor.yy590,yymsp[-3].minor.yy402,yymsp[-2].minor.yy590,yymsp[-1].minor.yy402,yymsp[-7].minor.yy502,yymsp[0].minor.yy590);
178304 }
178305 break;
178306 case 93: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt window_clause orderby_opt limit_opt */
178307 {
178308 yymsp[-9].minor.yy637 = sqlite3SelectNew(pParse,yymsp[-7].minor.yy402,yymsp[-6].minor.yy563,yymsp[-5].minor.yy590,yymsp[-4].minor.yy402,yymsp[-3].minor.yy590,yymsp[-1].minor.yy402,yymsp[-8].minor.yy502,yymsp[0].minor.yy590);
178309 if( yymsp[-9].minor.yy637 ){
178310 yymsp[-9].minor.yy637->pWinDefn = yymsp[-2].minor.yy483;
178311 }else{
178312 sqlite3WindowListDelete(pParse->db, yymsp[-2].minor.yy483);
178313 }
178314 }
178315 break;
178316 case 94: /* values ::= VALUES LP nexprlist RP */
178317 {
178318 yymsp[-3].minor.yy637 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy402,0,0,0,0,0,SF_Values,0);
178319 }
178320 break;
178321 case 95: /* oneselect ::= mvalues */
178322 {
178323 sqlite3MultiValuesEnd(pParse, yymsp[0].minor.yy637);
178324 }
178325 break;
178326 case 96: /* mvalues ::= values COMMA LP nexprlist RP */
178327 case 97: /* mvalues ::= mvalues COMMA LP nexprlist RP */ yytestcase(yyruleno==97);
178328 {
178329 yymsp[-4].minor.yy637 = sqlite3MultiValues(pParse, yymsp[-4].minor.yy637, yymsp[-1].minor.yy402);
178330 }
178331 break;
178332 case 98: /* distinct ::= DISTINCT */
178333 {yymsp[0].minor.yy502 = SF_Distinct;}
178334 break;
178335 case 99: /* distinct ::= ALL */
178336 {yymsp[0].minor.yy502 = SF_All;}
178337 break;
178338 case 101: /* sclp ::= */
178339 case 134: /* orderby_opt ::= */ yytestcase(yyruleno==134);
178340 case 144: /* groupby_opt ::= */ yytestcase(yyruleno==144);
178341 case 234: /* exprlist ::= */ yytestcase(yyruleno==234);
178342 case 237: /* paren_exprlist ::= */ yytestcase(yyruleno==237);
178343 case 242: /* eidlist_opt ::= */ yytestcase(yyruleno==242);
178344 {yymsp[1].minor.yy402 = 0;}
178345 break;
178346 case 102: /* selcollist ::= sclp scanpt expr scanpt as */
178347 {
178348 yymsp[-4].minor.yy402 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy402, yymsp[-2].minor.yy590);
178349 if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy402, &yymsp[0].minor.yy0, 1);
178350 sqlite3ExprListSetSpan(pParse,yymsp[-4].minor.yy402,yymsp[-3].minor.yy342,yymsp[-1].minor.yy342);
178351 }
178352 break;
178353 case 103: /* selcollist ::= sclp scanpt STAR */
178354 {
178355 Expr *p = sqlite3Expr(pParse->db, TK_ASTERISK, 0);
178356 sqlite3ExprSetErrorOffset(p, (int)(yymsp[0].minor.yy0.z - pParse->zTail));
178357 yymsp[-2].minor.yy402 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy402, p);
178358 }
178359 break;
178360 case 104: /* selcollist ::= sclp scanpt nm DOT STAR */
178361 {
178362 Expr *pRight, *pLeft, *pDot;
178363 pRight = sqlite3PExpr(pParse, TK_ASTERISK, 0, 0);
178364 sqlite3ExprSetErrorOffset(pRight, (int)(yymsp[0].minor.yy0.z - pParse->zTail));
178365 pLeft = tokenExpr(pParse, TK_ID, yymsp[-2].minor.yy0);
178366 pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight);
178367 yymsp[-4].minor.yy402 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy402, pDot);
178368 }
178369 break;
178370 case 105: /* as ::= AS nm */
178371 case 117: /* dbnm ::= DOT nm */ yytestcase(yyruleno==117);
178372 case 258: /* plus_num ::= PLUS INTEGER|FLOAT */ yytestcase(yyruleno==258);
@@ -177985,54 +178373,54 @@
178373 case 259: /* minus_num ::= MINUS INTEGER|FLOAT */ yytestcase(yyruleno==259);
178374 {yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;}
178375 break;
178376 case 107: /* from ::= */
178377 case 110: /* stl_prefix ::= */ yytestcase(yyruleno==110);
178378 {yymsp[1].minor.yy563 = 0;}
178379 break;
178380 case 108: /* from ::= FROM seltablist */
178381 {
178382 yymsp[-1].minor.yy563 = yymsp[0].minor.yy563;
178383 sqlite3SrcListShiftJoinType(pParse,yymsp[-1].minor.yy563);
178384 }
178385 break;
178386 case 109: /* stl_prefix ::= seltablist joinop */
178387 {
178388 if( ALWAYS(yymsp[-1].minor.yy563 && yymsp[-1].minor.yy563->nSrc>0) ) yymsp[-1].minor.yy563->a[yymsp[-1].minor.yy563->nSrc-1].fg.jointype = (u8)yymsp[0].minor.yy502;
178389 }
178390 break;
178391 case 111: /* seltablist ::= stl_prefix nm dbnm as on_using */
178392 {
178393 yymsp[-4].minor.yy563 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-4].minor.yy563,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0,&yymsp[0].minor.yy421);
178394 }
178395 break;
178396 case 112: /* seltablist ::= stl_prefix nm dbnm as indexed_by on_using */
178397 {
178398 yymsp[-5].minor.yy563 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-5].minor.yy563,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,0,&yymsp[0].minor.yy421);
178399 sqlite3SrcListIndexedBy(pParse, yymsp[-5].minor.yy563, &yymsp[-1].minor.yy0);
178400 }
178401 break;
178402 case 113: /* seltablist ::= stl_prefix nm dbnm LP exprlist RP as on_using */
178403 {
178404 yymsp[-7].minor.yy563 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-7].minor.yy563,&yymsp[-6].minor.yy0,&yymsp[-5].minor.yy0,&yymsp[-1].minor.yy0,0,&yymsp[0].minor.yy421);
178405 sqlite3SrcListFuncArgs(pParse, yymsp[-7].minor.yy563, yymsp[-3].minor.yy402);
178406 }
178407 break;
178408 case 114: /* seltablist ::= stl_prefix LP select RP as on_using */
178409 {
178410 yymsp[-5].minor.yy563 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-5].minor.yy563,0,0,&yymsp[-1].minor.yy0,yymsp[-3].minor.yy637,&yymsp[0].minor.yy421);
178411 }
178412 break;
178413 case 115: /* seltablist ::= stl_prefix LP seltablist RP as on_using */
178414 {
178415 if( yymsp[-5].minor.yy563==0 && yymsp[-1].minor.yy0.n==0 && yymsp[0].minor.yy421.pOn==0 && yymsp[0].minor.yy421.pUsing==0 ){
178416 yymsp[-5].minor.yy563 = yymsp[-3].minor.yy563;
178417 }else if( ALWAYS(yymsp[-3].minor.yy563!=0) && yymsp[-3].minor.yy563->nSrc==1 ){
178418 yymsp[-5].minor.yy563 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-5].minor.yy563,0,0,&yymsp[-1].minor.yy0,0,&yymsp[0].minor.yy421);
178419 if( yymsp[-5].minor.yy563 ){
178420 SrcItem *pNew = &yymsp[-5].minor.yy563->a[yymsp[-5].minor.yy563->nSrc-1];
178421 SrcItem *pOld = yymsp[-3].minor.yy563->a;
178422 assert( pOld->fg.fixedSchema==0 );
178423 pNew->zName = pOld->zName;
178424 assert( pOld->fg.fixedSchema==0 );
178425 if( pOld->fg.isSubquery ){
178426 pNew->fg.isSubquery = 1;
@@ -178053,249 +178441,249 @@
178441 pOld->fg.isTabFunc = 0;
178442 pNew->fg.isTabFunc = 1;
178443 }
178444 pOld->zName = 0;
178445 }
178446 sqlite3SrcListDelete(pParse->db, yymsp[-3].minor.yy563);
178447 }else{
178448 Select *pSubquery;
178449 sqlite3SrcListShiftJoinType(pParse,yymsp[-3].minor.yy563);
178450 pSubquery = sqlite3SelectNew(pParse,0,yymsp[-3].minor.yy563,0,0,0,0,SF_NestedFrom,0);
178451 yymsp[-5].minor.yy563 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-5].minor.yy563,0,0,&yymsp[-1].minor.yy0,pSubquery,&yymsp[0].minor.yy421);
178452 }
178453 }
178454 break;
178455 case 116: /* dbnm ::= */
178456 case 131: /* indexed_opt ::= */ yytestcase(yyruleno==131);
178457 {yymsp[1].minor.yy0.z=0; yymsp[1].minor.yy0.n=0;}
178458 break;
178459 case 118: /* fullname ::= nm */
178460 {
178461 yylhsminor.yy563 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0);
178462 if( IN_RENAME_OBJECT && yylhsminor.yy563 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy563->a[0].zName, &yymsp[0].minor.yy0);
178463 }
178464 yymsp[0].minor.yy563 = yylhsminor.yy563;
178465 break;
178466 case 119: /* fullname ::= nm DOT nm */
178467 {
178468 yylhsminor.yy563 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);
178469 if( IN_RENAME_OBJECT && yylhsminor.yy563 ) sqlite3RenameTokenMap(pParse, yylhsminor.yy563->a[0].zName, &yymsp[0].minor.yy0);
178470 }
178471 yymsp[-2].minor.yy563 = yylhsminor.yy563;
178472 break;
178473 case 120: /* xfullname ::= nm */
178474 {yymsp[0].minor.yy563 = sqlite3SrcListAppend(pParse,0,&yymsp[0].minor.yy0,0); /*A-overwrites-X*/}
178475 break;
178476 case 121: /* xfullname ::= nm DOT nm */
178477 {yymsp[-2].minor.yy563 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); /*A-overwrites-X*/}
178478 break;
178479 case 122: /* xfullname ::= nm DOT nm AS nm */
178480 {
178481 yymsp[-4].minor.yy563 = sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,&yymsp[-2].minor.yy0); /*A-overwrites-X*/
178482 if( yymsp[-4].minor.yy563 ) yymsp[-4].minor.yy563->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
178483 }
178484 break;
178485 case 123: /* xfullname ::= nm AS nm */
178486 {
178487 yymsp[-2].minor.yy563 = sqlite3SrcListAppend(pParse,0,&yymsp[-2].minor.yy0,0); /*A-overwrites-X*/
178488 if( yymsp[-2].minor.yy563 ) yymsp[-2].minor.yy563->a[0].zAlias = sqlite3NameFromToken(pParse->db, &yymsp[0].minor.yy0);
178489 }
178490 break;
178491 case 124: /* joinop ::= COMMA|JOIN */
178492 { yymsp[0].minor.yy502 = JT_INNER; }
178493 break;
178494 case 125: /* joinop ::= JOIN_KW JOIN */
178495 {yymsp[-1].minor.yy502 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); /*X-overwrites-A*/}
178496 break;
178497 case 126: /* joinop ::= JOIN_KW nm JOIN */
178498 {yymsp[-2].minor.yy502 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); /*X-overwrites-A*/}
178499 break;
178500 case 127: /* joinop ::= JOIN_KW nm nm JOIN */
178501 {yymsp[-3].minor.yy502 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);/*X-overwrites-A*/}
178502 break;
178503 case 128: /* on_using ::= ON expr */
178504 {yymsp[-1].minor.yy421.pOn = yymsp[0].minor.yy590; yymsp[-1].minor.yy421.pUsing = 0;}
178505 break;
178506 case 129: /* on_using ::= USING LP idlist RP */
178507 {yymsp[-3].minor.yy421.pOn = 0; yymsp[-3].minor.yy421.pUsing = yymsp[-1].minor.yy204;}
178508 break;
178509 case 130: /* on_using ::= */
178510 {yymsp[1].minor.yy421.pOn = 0; yymsp[1].minor.yy421.pUsing = 0;}
178511 break;
178512 case 132: /* indexed_by ::= INDEXED BY nm */
178513 {yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;}
178514 break;
178515 case 133: /* indexed_by ::= NOT INDEXED */
178516 {yymsp[-1].minor.yy0.z=0; yymsp[-1].minor.yy0.n=1;}
178517 break;
178518 case 135: /* orderby_opt ::= ORDER BY sortlist */
178519 case 145: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==145);
178520 {yymsp[-2].minor.yy402 = yymsp[0].minor.yy402;}
178521 break;
178522 case 136: /* sortlist ::= sortlist COMMA expr sortorder nulls */
178523 {
178524 yymsp[-4].minor.yy402 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy402,yymsp[-2].minor.yy590);
178525 sqlite3ExprListSetSortOrder(yymsp[-4].minor.yy402,yymsp[-1].minor.yy502,yymsp[0].minor.yy502);
178526 }
178527 break;
178528 case 137: /* sortlist ::= expr sortorder nulls */
178529 {
178530 yymsp[-2].minor.yy402 = sqlite3ExprListAppend(pParse,0,yymsp[-2].minor.yy590); /*A-overwrites-Y*/
178531 sqlite3ExprListSetSortOrder(yymsp[-2].minor.yy402,yymsp[-1].minor.yy502,yymsp[0].minor.yy502);
178532 }
178533 break;
178534 case 138: /* sortorder ::= ASC */
178535 {yymsp[0].minor.yy502 = SQLITE_SO_ASC;}
178536 break;
178537 case 139: /* sortorder ::= DESC */
178538 {yymsp[0].minor.yy502 = SQLITE_SO_DESC;}
178539 break;
178540 case 140: /* sortorder ::= */
178541 case 143: /* nulls ::= */ yytestcase(yyruleno==143);
178542 {yymsp[1].minor.yy502 = SQLITE_SO_UNDEFINED;}
178543 break;
178544 case 141: /* nulls ::= NULLS FIRST */
178545 {yymsp[-1].minor.yy502 = SQLITE_SO_ASC;}
178546 break;
178547 case 142: /* nulls ::= NULLS LAST */
178548 {yymsp[-1].minor.yy502 = SQLITE_SO_DESC;}
178549 break;
178550 case 146: /* having_opt ::= */
178551 case 148: /* limit_opt ::= */ yytestcase(yyruleno==148);
178552 case 153: /* where_opt ::= */ yytestcase(yyruleno==153);
178553 case 155: /* where_opt_ret ::= */ yytestcase(yyruleno==155);
178554 case 232: /* case_else ::= */ yytestcase(yyruleno==232);
178555 case 233: /* case_operand ::= */ yytestcase(yyruleno==233);
178556 case 252: /* vinto ::= */ yytestcase(yyruleno==252);
178557 {yymsp[1].minor.yy590 = 0;}
178558 break;
178559 case 147: /* having_opt ::= HAVING expr */
178560 case 154: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==154);
178561 case 156: /* where_opt_ret ::= WHERE expr */ yytestcase(yyruleno==156);
178562 case 231: /* case_else ::= ELSE expr */ yytestcase(yyruleno==231);
178563 case 251: /* vinto ::= INTO expr */ yytestcase(yyruleno==251);
178564 {yymsp[-1].minor.yy590 = yymsp[0].minor.yy590;}
178565 break;
178566 case 149: /* limit_opt ::= LIMIT expr */
178567 {yymsp[-1].minor.yy590 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy590,0);}
178568 break;
178569 case 150: /* limit_opt ::= LIMIT expr OFFSET expr */
178570 {yymsp[-3].minor.yy590 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[-2].minor.yy590,yymsp[0].minor.yy590);}
178571 break;
178572 case 151: /* limit_opt ::= LIMIT expr COMMA expr */
178573 {yymsp[-3].minor.yy590 = sqlite3PExpr(pParse,TK_LIMIT,yymsp[0].minor.yy590,yymsp[-2].minor.yy590);}
178574 break;
178575 case 152: /* cmd ::= with DELETE FROM xfullname indexed_opt where_opt_ret */
178576 {
178577 sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy563, &yymsp[-1].minor.yy0);
178578 sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy563,yymsp[0].minor.yy590,0,0);
178579 }
178580 break;
178581 case 157: /* where_opt_ret ::= RETURNING selcollist */
178582 {sqlite3AddReturning(pParse,yymsp[0].minor.yy402); yymsp[-1].minor.yy590 = 0;}
178583 break;
178584 case 158: /* where_opt_ret ::= WHERE expr RETURNING selcollist */
178585 {sqlite3AddReturning(pParse,yymsp[0].minor.yy402); yymsp[-3].minor.yy590 = yymsp[-2].minor.yy590;}
178586 break;
178587 case 159: /* cmd ::= with UPDATE orconf xfullname indexed_opt SET setlist from where_opt_ret */
178588 {
178589 sqlite3SrcListIndexedBy(pParse, yymsp[-5].minor.yy563, &yymsp[-4].minor.yy0);
178590 sqlite3ExprListCheckLength(pParse,yymsp[-2].minor.yy402,"set list");
178591 if( yymsp[-1].minor.yy563 ){
178592 SrcList *pFromClause = yymsp[-1].minor.yy563;
178593 if( pFromClause->nSrc>1 ){
178594 Select *pSubquery;
178595 Token as;
178596 pSubquery = sqlite3SelectNew(pParse,0,pFromClause,0,0,0,0,SF_NestedFrom,0);
178597 as.n = 0;
178598 as.z = 0;
178599 pFromClause = sqlite3SrcListAppendFromTerm(pParse,0,0,0,&as,pSubquery,0);
178600 }
178601 yymsp[-5].minor.yy563 = sqlite3SrcListAppendList(pParse, yymsp[-5].minor.yy563, pFromClause);
178602 }
178603 sqlite3Update(pParse,yymsp[-5].minor.yy563,yymsp[-2].minor.yy402,yymsp[0].minor.yy590,yymsp[-6].minor.yy502,0,0,0);
178604 }
178605 break;
178606 case 160: /* setlist ::= setlist COMMA nm EQ expr */
178607 {
178608 yymsp[-4].minor.yy402 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy402, yymsp[0].minor.yy590);
178609 sqlite3ExprListSetName(pParse, yymsp[-4].minor.yy402, &yymsp[-2].minor.yy0, 1);
178610 }
178611 break;
178612 case 161: /* setlist ::= setlist COMMA LP idlist RP EQ expr */
178613 {
178614 yymsp[-6].minor.yy402 = sqlite3ExprListAppendVector(pParse, yymsp[-6].minor.yy402, yymsp[-3].minor.yy204, yymsp[0].minor.yy590);
178615 }
178616 break;
178617 case 162: /* setlist ::= nm EQ expr */
178618 {
178619 yylhsminor.yy402 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy590);
178620 sqlite3ExprListSetName(pParse, yylhsminor.yy402, &yymsp[-2].minor.yy0, 1);
178621 }
178622 yymsp[-2].minor.yy402 = yylhsminor.yy402;
178623 break;
178624 case 163: /* setlist ::= LP idlist RP EQ expr */
178625 {
178626 yymsp[-4].minor.yy402 = sqlite3ExprListAppendVector(pParse, 0, yymsp[-3].minor.yy204, yymsp[0].minor.yy590);
178627 }
178628 break;
178629 case 164: /* cmd ::= with insert_cmd INTO xfullname idlist_opt select upsert */
178630 {
178631 sqlite3Insert(pParse, yymsp[-3].minor.yy563, yymsp[-1].minor.yy637, yymsp[-2].minor.yy204, yymsp[-5].minor.yy502, yymsp[0].minor.yy403);
178632 }
178633 break;
178634 case 165: /* cmd ::= with insert_cmd INTO xfullname idlist_opt DEFAULT VALUES returning */
178635 {
178636 sqlite3Insert(pParse, yymsp[-4].minor.yy563, 0, yymsp[-3].minor.yy204, yymsp[-6].minor.yy502, 0);
178637 }
178638 break;
178639 case 166: /* upsert ::= */
178640 { yymsp[1].minor.yy403 = 0; }
178641 break;
178642 case 167: /* upsert ::= RETURNING selcollist */
178643 { yymsp[-1].minor.yy403 = 0; sqlite3AddReturning(pParse,yymsp[0].minor.yy402); }
178644 break;
178645 case 168: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO UPDATE SET setlist where_opt upsert */
178646 { yymsp[-11].minor.yy403 = sqlite3UpsertNew(pParse->db,yymsp[-8].minor.yy402,yymsp[-6].minor.yy590,yymsp[-2].minor.yy402,yymsp[-1].minor.yy590,yymsp[0].minor.yy403);}
178647 break;
178648 case 169: /* upsert ::= ON CONFLICT LP sortlist RP where_opt DO NOTHING upsert */
178649 { yymsp[-8].minor.yy403 = sqlite3UpsertNew(pParse->db,yymsp[-5].minor.yy402,yymsp[-3].minor.yy590,0,0,yymsp[0].minor.yy403); }
178650 break;
178651 case 170: /* upsert ::= ON CONFLICT DO NOTHING returning */
178652 { yymsp[-4].minor.yy403 = sqlite3UpsertNew(pParse->db,0,0,0,0,0); }
178653 break;
178654 case 171: /* upsert ::= ON CONFLICT DO UPDATE SET setlist where_opt returning */
178655 { yymsp[-7].minor.yy403 = sqlite3UpsertNew(pParse->db,0,0,yymsp[-2].minor.yy402,yymsp[-1].minor.yy590,0);}
178656 break;
178657 case 172: /* returning ::= RETURNING selcollist */
178658 {sqlite3AddReturning(pParse,yymsp[0].minor.yy402);}
178659 break;
178660 case 175: /* idlist_opt ::= */
178661 {yymsp[1].minor.yy204 = 0;}
178662 break;
178663 case 176: /* idlist_opt ::= LP idlist RP */
178664 {yymsp[-2].minor.yy204 = yymsp[-1].minor.yy204;}
178665 break;
178666 case 177: /* idlist ::= idlist COMMA nm */
178667 {yymsp[-2].minor.yy204 = sqlite3IdListAppend(pParse,yymsp[-2].minor.yy204,&yymsp[0].minor.yy0);}
178668 break;
178669 case 178: /* idlist ::= nm */
178670 {yymsp[0].minor.yy204 = sqlite3IdListAppend(pParse,0,&yymsp[0].minor.yy0); /*A-overwrites-Y*/}
178671 break;
178672 case 179: /* expr ::= LP expr RP */
178673 {yymsp[-2].minor.yy590 = yymsp[-1].minor.yy590;}
178674 break;
178675 case 180: /* expr ::= ID|INDEXED|JOIN_KW */
178676 {yymsp[0].minor.yy590=tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0); /*A-overwrites-X*/}
178677 break;
178678 case 181: /* expr ::= nm DOT nm */
178679 {
178680 Expr *temp1 = tokenExpr(pParse,TK_ID,yymsp[-2].minor.yy0);
178681 Expr *temp2 = tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0);
178682 yylhsminor.yy590 = sqlite3PExpr(pParse, TK_DOT, temp1, temp2);
178683 }
178684 yymsp[-2].minor.yy590 = yylhsminor.yy590;
178685 break;
178686 case 182: /* expr ::= nm DOT nm DOT nm */
178687 {
178688 Expr *temp1 = tokenExpr(pParse,TK_ID,yymsp[-4].minor.yy0);
178689 Expr *temp2 = tokenExpr(pParse,TK_ID,yymsp[-2].minor.yy0);
@@ -178302,378 +178690,378 @@
178690 Expr *temp3 = tokenExpr(pParse,TK_ID,yymsp[0].minor.yy0);
178691 Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3);
178692 if( IN_RENAME_OBJECT ){
178693 sqlite3RenameTokenRemap(pParse, 0, temp1);
178694 }
178695 yylhsminor.yy590 = sqlite3PExpr(pParse, TK_DOT, temp1, temp4);
178696 }
178697 yymsp[-4].minor.yy590 = yylhsminor.yy590;
178698 break;
178699 case 183: /* term ::= NULL|FLOAT|BLOB */
178700 case 184: /* term ::= STRING */ yytestcase(yyruleno==184);
178701 {yymsp[0].minor.yy590=tokenExpr(pParse,yymsp[0].major,yymsp[0].minor.yy0); /*A-overwrites-X*/}
178702 break;
178703 case 185: /* term ::= INTEGER */
178704 {
178705 yylhsminor.yy590 = sqlite3ExprAlloc(pParse->db, TK_INTEGER, &yymsp[0].minor.yy0, 1);
178706 if( yylhsminor.yy590 ) yylhsminor.yy590->w.iOfst = (int)(yymsp[0].minor.yy0.z - pParse->zTail);
178707 }
178708 yymsp[0].minor.yy590 = yylhsminor.yy590;
178709 break;
178710 case 186: /* expr ::= VARIABLE */
178711 {
178712 if( !(yymsp[0].minor.yy0.z[0]=='#' && sqlite3Isdigit(yymsp[0].minor.yy0.z[1])) ){
178713 u32 n = yymsp[0].minor.yy0.n;
178714 yymsp[0].minor.yy590 = tokenExpr(pParse, TK_VARIABLE, yymsp[0].minor.yy0);
178715 sqlite3ExprAssignVarNumber(pParse, yymsp[0].minor.yy590, n);
178716 }else{
178717 /* When doing a nested parse, one can include terms in an expression
178718 ** that look like this: #1 #2 ... These terms refer to registers
178719 ** in the virtual machine. #N is the N-th register. */
178720 Token t = yymsp[0].minor.yy0; /*A-overwrites-X*/
178721 assert( t.n>=2 );
178722 if( pParse->nested==0 ){
178723 parserSyntaxError(pParse, &t);
178724 yymsp[0].minor.yy590 = 0;
178725 }else{
178726 yymsp[0].minor.yy590 = sqlite3PExpr(pParse, TK_REGISTER, 0, 0);
178727 if( yymsp[0].minor.yy590 ) sqlite3GetInt32(&t.z[1], &yymsp[0].minor.yy590->iTable);
178728 }
178729 }
178730 }
178731 break;
178732 case 187: /* expr ::= expr COLLATE ID|STRING */
178733 {
178734 yymsp[-2].minor.yy590 = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy590, &yymsp[0].minor.yy0, 1);
178735 }
178736 break;
178737 case 188: /* expr ::= CAST LP expr AS typetoken RP */
178738 {
178739 yymsp[-5].minor.yy590 = sqlite3ExprAlloc(pParse->db, TK_CAST, &yymsp[-1].minor.yy0, 1);
178740 sqlite3ExprAttachSubtrees(pParse->db, yymsp[-5].minor.yy590, yymsp[-3].minor.yy590, 0);
178741 }
178742 break;
178743 case 189: /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP */
178744 {
178745 yylhsminor.yy590 = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy402, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy502);
178746 }
178747 yymsp[-4].minor.yy590 = yylhsminor.yy590;
178748 break;
178749 case 190: /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP */
178750 {
178751 yylhsminor.yy590 = sqlite3ExprFunction(pParse, yymsp[-4].minor.yy402, &yymsp[-7].minor.yy0, yymsp[-5].minor.yy502);
178752 sqlite3ExprAddFunctionOrderBy(pParse, yylhsminor.yy590, yymsp[-1].minor.yy402);
178753 }
178754 yymsp[-7].minor.yy590 = yylhsminor.yy590;
178755 break;
178756 case 191: /* expr ::= ID|INDEXED|JOIN_KW LP STAR RP */
178757 {
178758 yylhsminor.yy590 = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0, 0);
178759 }
178760 yymsp[-3].minor.yy590 = yylhsminor.yy590;
178761 break;
178762 case 192: /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist RP filter_over */
178763 {
178764 yylhsminor.yy590 = sqlite3ExprFunction(pParse, yymsp[-2].minor.yy402, &yymsp[-5].minor.yy0, yymsp[-3].minor.yy502);
178765 sqlite3WindowAttach(pParse, yylhsminor.yy590, yymsp[0].minor.yy483);
178766 }
178767 yymsp[-5].minor.yy590 = yylhsminor.yy590;
178768 break;
178769 case 193: /* expr ::= ID|INDEXED|JOIN_KW LP distinct exprlist ORDER BY sortlist RP filter_over */
178770 {
178771 yylhsminor.yy590 = sqlite3ExprFunction(pParse, yymsp[-5].minor.yy402, &yymsp[-8].minor.yy0, yymsp[-6].minor.yy502);
178772 sqlite3WindowAttach(pParse, yylhsminor.yy590, yymsp[0].minor.yy483);
178773 sqlite3ExprAddFunctionOrderBy(pParse, yylhsminor.yy590, yymsp[-2].minor.yy402);
178774 }
178775 yymsp[-8].minor.yy590 = yylhsminor.yy590;
178776 break;
178777 case 194: /* expr ::= ID|INDEXED|JOIN_KW LP STAR RP filter_over */
178778 {
178779 yylhsminor.yy590 = sqlite3ExprFunction(pParse, 0, &yymsp[-4].minor.yy0, 0);
178780 sqlite3WindowAttach(pParse, yylhsminor.yy590, yymsp[0].minor.yy483);
178781 }
178782 yymsp[-4].minor.yy590 = yylhsminor.yy590;
178783 break;
178784 case 195: /* term ::= CTIME_KW */
178785 {
178786 yylhsminor.yy590 = sqlite3ExprFunction(pParse, 0, &yymsp[0].minor.yy0, 0);
178787 }
178788 yymsp[0].minor.yy590 = yylhsminor.yy590;
178789 break;
178790 case 196: /* expr ::= LP nexprlist COMMA expr RP */
178791 {
178792 ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy402, yymsp[-1].minor.yy590);
178793 yymsp[-4].minor.yy590 = sqlite3PExpr(pParse, TK_VECTOR, 0, 0);
178794 if( yymsp[-4].minor.yy590 ){
178795 yymsp[-4].minor.yy590->x.pList = pList;
178796 if( ALWAYS(pList->nExpr) ){
178797 yymsp[-4].minor.yy590->flags |= pList->a[0].pExpr->flags & EP_Propagate;
178798 }
178799 }else{
178800 sqlite3ExprListDelete(pParse->db, pList);
178801 }
178802 }
178803 break;
178804 case 197: /* expr ::= expr AND expr */
178805 {yymsp[-2].minor.yy590=sqlite3ExprAnd(pParse,yymsp[-2].minor.yy590,yymsp[0].minor.yy590);}
178806 break;
178807 case 198: /* expr ::= expr OR expr */
178808 case 199: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==199);
178809 case 200: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==200);
178810 case 201: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==201);
178811 case 202: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==202);
178812 case 203: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==203);
178813 case 204: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==204);
178814 {yymsp[-2].minor.yy590=sqlite3PExpr(pParse,yymsp[-1].major,yymsp[-2].minor.yy590,yymsp[0].minor.yy590);}
178815 break;
178816 case 205: /* likeop ::= NOT LIKE_KW|MATCH */
178817 {yymsp[-1].minor.yy0=yymsp[0].minor.yy0; yymsp[-1].minor.yy0.n|=0x80000000; /*yymsp[-1].minor.yy0-overwrite-yymsp[0].minor.yy0*/}
178818 break;
178819 case 206: /* expr ::= expr likeop expr */
178820 {
178821 ExprList *pList;
178822 int bNot = yymsp[-1].minor.yy0.n & 0x80000000;
178823 yymsp[-1].minor.yy0.n &= 0x7fffffff;
178824 pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy590);
178825 pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy590);
178826 yymsp[-2].minor.yy590 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0, 0);
178827 if( bNot ) yymsp[-2].minor.yy590 = sqlite3PExpr(pParse, TK_NOT, yymsp[-2].minor.yy590, 0);
178828 if( yymsp[-2].minor.yy590 ) yymsp[-2].minor.yy590->flags |= EP_InfixFunc;
178829 }
178830 break;
178831 case 207: /* expr ::= expr likeop expr ESCAPE expr */
178832 {
178833 ExprList *pList;
178834 int bNot = yymsp[-3].minor.yy0.n & 0x80000000;
178835 yymsp[-3].minor.yy0.n &= 0x7fffffff;
178836 pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy590);
178837 pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy590);
178838 pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy590);
178839 yymsp[-4].minor.yy590 = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy0, 0);
178840 if( bNot ) yymsp[-4].minor.yy590 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy590, 0);
178841 if( yymsp[-4].minor.yy590 ) yymsp[-4].minor.yy590->flags |= EP_InfixFunc;
178842 }
178843 break;
178844 case 208: /* expr ::= expr ISNULL|NOTNULL */
178845 {yymsp[-1].minor.yy590 = sqlite3PExpr(pParse,yymsp[0].major,yymsp[-1].minor.yy590,0);}
178846 break;
178847 case 209: /* expr ::= expr NOT NULL */
178848 {yymsp[-2].minor.yy590 = sqlite3PExpr(pParse,TK_NOTNULL,yymsp[-2].minor.yy590,0);}
178849 break;
178850 case 210: /* expr ::= expr IS expr */
178851 {
178852 yymsp[-2].minor.yy590 = sqlite3PExpr(pParse,TK_IS,yymsp[-2].minor.yy590,yymsp[0].minor.yy590);
178853 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy590, yymsp[-2].minor.yy590, TK_ISNULL);
178854 }
178855 break;
178856 case 211: /* expr ::= expr IS NOT expr */
178857 {
178858 yymsp[-3].minor.yy590 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-3].minor.yy590,yymsp[0].minor.yy590);
178859 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy590, yymsp[-3].minor.yy590, TK_NOTNULL);
178860 }
178861 break;
178862 case 212: /* expr ::= expr IS NOT DISTINCT FROM expr */
178863 {
178864 yymsp[-5].minor.yy590 = sqlite3PExpr(pParse,TK_IS,yymsp[-5].minor.yy590,yymsp[0].minor.yy590);
178865 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy590, yymsp[-5].minor.yy590, TK_ISNULL);
178866 }
178867 break;
178868 case 213: /* expr ::= expr IS DISTINCT FROM expr */
178869 {
178870 yymsp[-4].minor.yy590 = sqlite3PExpr(pParse,TK_ISNOT,yymsp[-4].minor.yy590,yymsp[0].minor.yy590);
178871 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy590, yymsp[-4].minor.yy590, TK_NOTNULL);
178872 }
178873 break;
178874 case 214: /* expr ::= NOT expr */
178875 case 215: /* expr ::= BITNOT expr */ yytestcase(yyruleno==215);
178876 {yymsp[-1].minor.yy590 = sqlite3PExpr(pParse, yymsp[-1].major, yymsp[0].minor.yy590, 0);/*A-overwrites-B*/}
178877 break;
178878 case 216: /* expr ::= PLUS|MINUS expr */
178879 {
178880 Expr *p = yymsp[0].minor.yy590;
178881 u8 op = yymsp[-1].major + (TK_UPLUS-TK_PLUS);
178882 assert( TK_UPLUS>TK_PLUS );
178883 assert( TK_UMINUS == TK_MINUS + (TK_UPLUS - TK_PLUS) );
178884 if( p && p->op==TK_UPLUS ){
178885 p->op = op;
178886 yymsp[-1].minor.yy590 = p;
178887 }else{
178888 yymsp[-1].minor.yy590 = sqlite3PExpr(pParse, op, p, 0);
178889 /*A-overwrites-B*/
178890 }
178891 }
178892 break;
178893 case 217: /* expr ::= expr PTR expr */
178894 {
178895 ExprList *pList = sqlite3ExprListAppend(pParse, 0, yymsp[-2].minor.yy590);
178896 pList = sqlite3ExprListAppend(pParse, pList, yymsp[0].minor.yy590);
178897 yylhsminor.yy590 = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy0, 0);
178898 }
178899 yymsp[-2].minor.yy590 = yylhsminor.yy590;
178900 break;
178901 case 218: /* between_op ::= BETWEEN */
178902 case 221: /* in_op ::= IN */ yytestcase(yyruleno==221);
178903 {yymsp[0].minor.yy502 = 0;}
178904 break;
178905 case 220: /* expr ::= expr between_op expr AND expr */
178906 {
178907 ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy590);
178908 pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy590);
178909 yymsp[-4].minor.yy590 = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy590, 0);
178910 if( yymsp[-4].minor.yy590 ){
178911 yymsp[-4].minor.yy590->x.pList = pList;
178912 }else{
178913 sqlite3ExprListDelete(pParse->db, pList);
178914 }
178915 if( yymsp[-3].minor.yy502 ) yymsp[-4].minor.yy590 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy590, 0);
178916 }
178917 break;
178918 case 223: /* expr ::= expr in_op LP exprlist RP */
178919 {
178920 if( yymsp[-1].minor.yy402==0 ){
178921 /* Expressions of the form
178922 **
178923 ** expr1 IN ()
178924 ** expr1 NOT IN ()
178925 **
178926 ** simplify to constants 0 (false) and 1 (true), respectively,
178927 ** regardless of the value of expr1.
178928 */
178929 sqlite3ExprUnmapAndDelete(pParse, yymsp[-4].minor.yy590);
178930 yymsp[-4].minor.yy590 = sqlite3Expr(pParse->db, TK_STRING, yymsp[-3].minor.yy502 ? "true" : "false");
178931 if( yymsp[-4].minor.yy590 ) sqlite3ExprIdToTrueFalse(yymsp[-4].minor.yy590);
178932 }else{
178933 Expr *pRHS = yymsp[-1].minor.yy402->a[0].pExpr;
178934 if( yymsp[-1].minor.yy402->nExpr==1 && sqlite3ExprIsConstant(pParse,pRHS) && yymsp[-4].minor.yy590->op!=TK_VECTOR ){
178935 yymsp[-1].minor.yy402->a[0].pExpr = 0;
178936 sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy402);
178937 pRHS = sqlite3PExpr(pParse, TK_UPLUS, pRHS, 0);
178938 yymsp[-4].minor.yy590 = sqlite3PExpr(pParse, TK_EQ, yymsp[-4].minor.yy590, pRHS);
178939 }else if( yymsp[-1].minor.yy402->nExpr==1 && pRHS->op==TK_SELECT ){
178940 yymsp[-4].minor.yy590 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy590, 0);
178941 sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy590, pRHS->x.pSelect);
178942 pRHS->x.pSelect = 0;
178943 sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy402);
178944 }else{
178945 yymsp[-4].minor.yy590 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy590, 0);
178946 if( yymsp[-4].minor.yy590==0 ){
178947 sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy402);
178948 }else if( yymsp[-4].minor.yy590->pLeft->op==TK_VECTOR ){
178949 int nExpr = yymsp[-4].minor.yy590->pLeft->x.pList->nExpr;
178950 Select *pSelectRHS = sqlite3ExprListToValues(pParse, nExpr, yymsp[-1].minor.yy402);
178951 if( pSelectRHS ){
178952 parserDoubleLinkSelect(pParse, pSelectRHS);
178953 sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy590, pSelectRHS);
178954 }
178955 }else{
178956 yymsp[-4].minor.yy590->x.pList = yymsp[-1].minor.yy402;
178957 sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy590);
178958 }
178959 }
178960 if( yymsp[-3].minor.yy502 ) yymsp[-4].minor.yy590 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy590, 0);
178961 }
178962 }
178963 break;
178964 case 224: /* expr ::= LP select RP */
178965 {
178966 yymsp[-2].minor.yy590 = sqlite3PExpr(pParse, TK_SELECT, 0, 0);
178967 sqlite3PExprAddSelect(pParse, yymsp[-2].minor.yy590, yymsp[-1].minor.yy637);
178968 }
178969 break;
178970 case 225: /* expr ::= expr in_op LP select RP */
178971 {
178972 yymsp[-4].minor.yy590 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy590, 0);
178973 sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy590, yymsp[-1].minor.yy637);
178974 if( yymsp[-3].minor.yy502 ) yymsp[-4].minor.yy590 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy590, 0);
178975 }
178976 break;
178977 case 226: /* expr ::= expr in_op nm dbnm paren_exprlist */
178978 {
178979 SrcList *pSrc = sqlite3SrcListAppend(pParse, 0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0);
178980 Select *pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0);
178981 if( yymsp[0].minor.yy402 ) sqlite3SrcListFuncArgs(pParse, pSelect ? pSrc : 0, yymsp[0].minor.yy402);
178982 yymsp[-4].minor.yy590 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy590, 0);
178983 sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy590, pSelect);
178984 if( yymsp[-3].minor.yy502 ) yymsp[-4].minor.yy590 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy590, 0);
178985 }
178986 break;
178987 case 227: /* expr ::= EXISTS LP select RP */
178988 {
178989 Expr *p;
178990 p = yymsp[-3].minor.yy590 = sqlite3PExpr(pParse, TK_EXISTS, 0, 0);
178991 sqlite3PExprAddSelect(pParse, p, yymsp[-1].minor.yy637);
178992 }
178993 break;
178994 case 228: /* expr ::= CASE case_operand case_exprlist case_else END */
178995 {
178996 yymsp[-4].minor.yy590 = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy590, 0);
178997 if( yymsp[-4].minor.yy590 ){
178998 yymsp[-4].minor.yy590->x.pList = yymsp[-1].minor.yy590 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy402,yymsp[-1].minor.yy590) : yymsp[-2].minor.yy402;
178999 sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy590);
179000 }else{
179001 sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy402);
179002 sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy590);
179003 }
179004 }
179005 break;
179006 case 229: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
179007 {
179008 yymsp[-4].minor.yy402 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy402, yymsp[-2].minor.yy590);
179009 yymsp[-4].minor.yy402 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy402, yymsp[0].minor.yy590);
179010 }
179011 break;
179012 case 230: /* case_exprlist ::= WHEN expr THEN expr */
179013 {
179014 yymsp[-3].minor.yy402 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy590);
179015 yymsp[-3].minor.yy402 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy402, yymsp[0].minor.yy590);
179016 }
179017 break;
179018 case 235: /* nexprlist ::= nexprlist COMMA expr */
179019 {yymsp[-2].minor.yy402 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy402,yymsp[0].minor.yy590);}
179020 break;
179021 case 236: /* nexprlist ::= expr */
179022 {yymsp[0].minor.yy402 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy590); /*A-overwrites-Y*/}
179023 break;
179024 case 238: /* paren_exprlist ::= LP exprlist RP */
179025 case 243: /* eidlist_opt ::= LP eidlist RP */ yytestcase(yyruleno==243);
179026 {yymsp[-2].minor.yy402 = yymsp[-1].minor.yy402;}
179027 break;
179028 case 239: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP sortlist RP where_opt */
179029 {
179030 sqlite3CreateIndex(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0,
179031 sqlite3SrcListAppend(pParse,0,&yymsp[-4].minor.yy0,0), yymsp[-2].minor.yy402, yymsp[-10].minor.yy502,
179032 &yymsp[-11].minor.yy0, yymsp[0].minor.yy590, SQLITE_SO_ASC, yymsp[-8].minor.yy502, SQLITE_IDXTYPE_APPDEF);
179033 if( IN_RENAME_OBJECT && pParse->pNewIndex ){
179034 sqlite3RenameTokenMap(pParse, pParse->pNewIndex->zName, &yymsp[-4].minor.yy0);
179035 }
179036 }
179037 break;
179038 case 240: /* uniqueflag ::= UNIQUE */
179039 case 282: /* raisetype ::= ABORT */ yytestcase(yyruleno==282);
179040 {yymsp[0].minor.yy502 = OE_Abort;}
179041 break;
179042 case 241: /* uniqueflag ::= */
179043 {yymsp[1].minor.yy502 = OE_None;}
179044 break;
179045 case 244: /* eidlist ::= eidlist COMMA nm collate sortorder */
179046 {
179047 yymsp[-4].minor.yy402 = parserAddExprIdListTerm(pParse, yymsp[-4].minor.yy402, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy502, yymsp[0].minor.yy502);
179048 }
179049 break;
179050 case 245: /* eidlist ::= nm collate sortorder */
179051 {
179052 yymsp[-2].minor.yy402 = parserAddExprIdListTerm(pParse, 0, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy502, yymsp[0].minor.yy502); /*A-overwrites-Y*/
179053 }
179054 break;
179055 case 248: /* cmd ::= DROP INDEX ifexists fullname */
179056 {sqlite3DropIndex(pParse, yymsp[0].minor.yy563, yymsp[-1].minor.yy502);}
179057 break;
179058 case 249: /* cmd ::= VACUUM vinto */
179059 {sqlite3Vacuum(pParse,0,yymsp[0].minor.yy590);}
179060 break;
179061 case 250: /* cmd ::= VACUUM nm vinto */
179062 {sqlite3Vacuum(pParse,&yymsp[-1].minor.yy0,yymsp[0].minor.yy590);}
179063 break;
179064 case 253: /* cmd ::= PRAGMA nm dbnm */
179065 {sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);}
179066 break;
179067 case 254: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
@@ -178691,54 +179079,58 @@
179079 case 260: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
179080 {
179081 Token all;
179082 all.z = yymsp[-3].minor.yy0.z;
179083 all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n;
179084 sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy319, &all);
179085 }
179086 break;
179087 case 261: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
179088 {
179089 sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy502, yymsp[-4].minor.yy28.a, yymsp[-4].minor.yy28.b, yymsp[-2].minor.yy563, yymsp[0].minor.yy590, yymsp[-10].minor.yy502, yymsp[-8].minor.yy502);
179090 yymsp[-10].minor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); /*A-overwrites-T*/
179091 #ifdef SQLITE_DEBUG
179092 assert( pParse->isCreate ); /* Set by createkw reduce action */
179093 pParse->isCreate = 0; /* But, should not be set for CREATE TRIGGER */
179094 #endif
179095 }
179096 break;
179097 case 262: /* trigger_time ::= BEFORE|AFTER */
179098 { yymsp[0].minor.yy502 = yymsp[0].major; /*A-overwrites-X*/ }
179099 break;
179100 case 263: /* trigger_time ::= INSTEAD OF */
179101 { yymsp[-1].minor.yy502 = TK_INSTEAD;}
179102 break;
179103 case 264: /* trigger_time ::= */
179104 { yymsp[1].minor.yy502 = TK_BEFORE; }
179105 break;
179106 case 265: /* trigger_event ::= DELETE|INSERT */
179107 case 266: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==266);
179108 {yymsp[0].minor.yy28.a = yymsp[0].major; /*A-overwrites-X*/ yymsp[0].minor.yy28.b = 0;}
179109 break;
179110 case 267: /* trigger_event ::= UPDATE OF idlist */
179111 {yymsp[-2].minor.yy28.a = TK_UPDATE; yymsp[-2].minor.yy28.b = yymsp[0].minor.yy204;}
179112 break;
179113 case 268: /* when_clause ::= */
179114 case 287: /* key_opt ::= */ yytestcase(yyruleno==287);
179115 { yymsp[1].minor.yy590 = 0; }
179116 break;
179117 case 269: /* when_clause ::= WHEN expr */
179118 case 288: /* key_opt ::= KEY expr */ yytestcase(yyruleno==288);
179119 { yymsp[-1].minor.yy590 = yymsp[0].minor.yy590; }
179120 break;
179121 case 270: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
179122 {
179123 assert( yymsp[-2].minor.yy319!=0 );
179124 yymsp[-2].minor.yy319->pLast->pNext = yymsp[-1].minor.yy319;
179125 yymsp[-2].minor.yy319->pLast = yymsp[-1].minor.yy319;
179126 }
179127 break;
179128 case 271: /* trigger_cmd_list ::= trigger_cmd SEMI */
179129 {
179130 assert( yymsp[-1].minor.yy319!=0 );
179131 yymsp[-1].minor.yy319->pLast = yymsp[-1].minor.yy319;
179132 }
179133 break;
179134 case 272: /* trnm ::= nm DOT nm */
179135 {
179136 yymsp[-2].minor.yy0 = yymsp[0].minor.yy0;
@@ -178760,62 +179152,62 @@
179152 "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements "
179153 "within triggers");
179154 }
179155 break;
179156 case 275: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist from where_opt scanpt */
179157 {yylhsminor.yy319 = sqlite3TriggerUpdateStep(pParse, &yymsp[-6].minor.yy0, yymsp[-2].minor.yy563, yymsp[-3].minor.yy402, yymsp[-1].minor.yy590, yymsp[-7].minor.yy502, yymsp[-8].minor.yy0.z, yymsp[0].minor.yy342);}
179158 yymsp[-8].minor.yy319 = yylhsminor.yy319;
179159 break;
179160 case 276: /* trigger_cmd ::= scanpt insert_cmd INTO trnm idlist_opt select upsert scanpt */
179161 {
179162 yylhsminor.yy319 = sqlite3TriggerInsertStep(pParse,&yymsp[-4].minor.yy0,yymsp[-3].minor.yy204,yymsp[-2].minor.yy637,yymsp[-6].minor.yy502,yymsp[-1].minor.yy403,yymsp[-7].minor.yy342,yymsp[0].minor.yy342);/*yylhsminor.yy319-overwrites-yymsp[-6].minor.yy502*/
179163 }
179164 yymsp[-7].minor.yy319 = yylhsminor.yy319;
179165 break;
179166 case 277: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt scanpt */
179167 {yylhsminor.yy319 = sqlite3TriggerDeleteStep(pParse, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy590, yymsp[-5].minor.yy0.z, yymsp[0].minor.yy342);}
179168 yymsp[-5].minor.yy319 = yylhsminor.yy319;
179169 break;
179170 case 278: /* trigger_cmd ::= scanpt select scanpt */
179171 {yylhsminor.yy319 = sqlite3TriggerSelectStep(pParse->db, yymsp[-1].minor.yy637, yymsp[-2].minor.yy342, yymsp[0].minor.yy342); /*yylhsminor.yy319-overwrites-yymsp[-1].minor.yy637*/}
179172 yymsp[-2].minor.yy319 = yylhsminor.yy319;
179173 break;
179174 case 279: /* expr ::= RAISE LP IGNORE RP */
179175 {
179176 yymsp[-3].minor.yy590 = sqlite3PExpr(pParse, TK_RAISE, 0, 0);
179177 if( yymsp[-3].minor.yy590 ){
179178 yymsp[-3].minor.yy590->affExpr = OE_Ignore;
179179 }
179180 }
179181 break;
179182 case 280: /* expr ::= RAISE LP raisetype COMMA expr RP */
179183 {
179184 yymsp[-5].minor.yy590 = sqlite3PExpr(pParse, TK_RAISE, yymsp[-1].minor.yy590, 0);
179185 if( yymsp[-5].minor.yy590 ) {
179186 yymsp[-5].minor.yy590->affExpr = (char)yymsp[-3].minor.yy502;
179187 }
179188 }
179189 break;
179190 case 281: /* raisetype ::= ROLLBACK */
179191 {yymsp[0].minor.yy502 = OE_Rollback;}
179192 break;
179193 case 283: /* raisetype ::= FAIL */
179194 {yymsp[0].minor.yy502 = OE_Fail;}
179195 break;
179196 case 284: /* cmd ::= DROP TRIGGER ifexists fullname */
179197 {
179198 sqlite3DropTrigger(pParse,yymsp[0].minor.yy563,yymsp[-1].minor.yy502);
179199 }
179200 break;
179201 case 285: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
179202 {
179203 sqlite3Attach(pParse, yymsp[-3].minor.yy590, yymsp[-1].minor.yy590, yymsp[0].minor.yy590);
179204 }
179205 break;
179206 case 286: /* cmd ::= DETACH database_kw_opt expr */
179207 {
179208 sqlite3Detach(pParse, yymsp[0].minor.yy590);
179209 }
179210 break;
179211 case 289: /* cmd ::= REINDEX */
179212 {sqlite3Reindex(pParse, 0, 0);}
179213 break;
@@ -178828,11 +179220,11 @@
179220 case 292: /* cmd ::= ANALYZE nm dbnm */
179221 {sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
179222 break;
179223 case 293: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
179224 {
179225 sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy563,&yymsp[0].minor.yy0);
179226 }
179227 break;
179228 case 294: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt columnname carglist */
179229 {
179230 yymsp[-1].minor.yy0.n = (int)(pParse->sLastToken.z-yymsp[-1].minor.yy0.z) + pParse->sLastToken.n;
@@ -178839,22 +179231,22 @@
179231 sqlite3AlterFinishAddColumn(pParse, &yymsp[-1].minor.yy0);
179232 }
179233 break;
179234 case 295: /* cmd ::= ALTER TABLE fullname DROP kwcolumn_opt nm */
179235 {
179236 sqlite3AlterDropColumn(pParse, yymsp[-3].minor.yy563, &yymsp[0].minor.yy0);
179237 }
179238 break;
179239 case 296: /* add_column_fullname ::= fullname */
179240 {
179241 disableLookaside(pParse);
179242 sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy563);
179243 }
179244 break;
179245 case 297: /* cmd ::= ALTER TABLE fullname RENAME kwcolumn_opt nm TO nm */
179246 {
179247 sqlite3AlterRenameColumn(pParse, yymsp[-5].minor.yy563, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);
179248 }
179249 break;
179250 case 298: /* cmd ::= create_vtab */
179251 {sqlite3VtabFinishParse(pParse,0);}
179252 break;
@@ -178861,11 +179253,11 @@
179253 case 299: /* cmd ::= create_vtab LP vtabarglist RP */
179254 {sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}
179255 break;
179256 case 300: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
179257 {
179258 sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy502);
179259 }
179260 break;
179261 case 301: /* vtabarg ::= */
179262 {sqlite3VtabArgInit(pParse);}
179263 break;
@@ -178874,185 +179266,185 @@
179266 case 304: /* lp ::= LP */ yytestcase(yyruleno==304);
179267 {sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}
179268 break;
179269 case 305: /* with ::= WITH wqlist */
179270 case 306: /* with ::= WITH RECURSIVE wqlist */ yytestcase(yyruleno==306);
179271 { sqlite3WithPush(pParse, yymsp[0].minor.yy125, 1); }
179272 break;
179273 case 307: /* wqas ::= AS */
179274 {yymsp[0].minor.yy444 = M10d_Any;}
179275 break;
179276 case 308: /* wqas ::= AS MATERIALIZED */
179277 {yymsp[-1].minor.yy444 = M10d_Yes;}
179278 break;
179279 case 309: /* wqas ::= AS NOT MATERIALIZED */
179280 {yymsp[-2].minor.yy444 = M10d_No;}
179281 break;
179282 case 310: /* wqitem ::= withnm eidlist_opt wqas LP select RP */
179283 {
179284 yymsp[-5].minor.yy361 = sqlite3CteNew(pParse, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy402, yymsp[-1].minor.yy637, yymsp[-3].minor.yy444); /*A-overwrites-X*/
179285 }
179286 break;
179287 case 311: /* withnm ::= nm */
179288 {pParse->bHasWith = 1;}
179289 break;
179290 case 312: /* wqlist ::= wqitem */
179291 {
179292 yymsp[0].minor.yy125 = sqlite3WithAdd(pParse, 0, yymsp[0].minor.yy361); /*A-overwrites-X*/
179293 }
179294 break;
179295 case 313: /* wqlist ::= wqlist COMMA wqitem */
179296 {
179297 yymsp[-2].minor.yy125 = sqlite3WithAdd(pParse, yymsp[-2].minor.yy125, yymsp[0].minor.yy361);
179298 }
179299 break;
179300 case 314: /* windowdefn_list ::= windowdefn_list COMMA windowdefn */
179301 {
179302 assert( yymsp[0].minor.yy483!=0 );
179303 sqlite3WindowChain(pParse, yymsp[0].minor.yy483, yymsp[-2].minor.yy483);
179304 yymsp[0].minor.yy483->pNextWin = yymsp[-2].minor.yy483;
179305 yylhsminor.yy483 = yymsp[0].minor.yy483;
179306 }
179307 yymsp[-2].minor.yy483 = yylhsminor.yy483;
179308 break;
179309 case 315: /* windowdefn ::= nm AS LP window RP */
179310 {
179311 if( ALWAYS(yymsp[-1].minor.yy483) ){
179312 yymsp[-1].minor.yy483->zName = sqlite3DbStrNDup(pParse->db, yymsp[-4].minor.yy0.z, yymsp[-4].minor.yy0.n);
179313 }
179314 yylhsminor.yy483 = yymsp[-1].minor.yy483;
179315 }
179316 yymsp[-4].minor.yy483 = yylhsminor.yy483;
179317 break;
179318 case 316: /* window ::= PARTITION BY nexprlist orderby_opt frame_opt */
179319 {
179320 yymsp[-4].minor.yy483 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy483, yymsp[-2].minor.yy402, yymsp[-1].minor.yy402, 0);
179321 }
179322 break;
179323 case 317: /* window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
179324 {
179325 yylhsminor.yy483 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy483, yymsp[-2].minor.yy402, yymsp[-1].minor.yy402, &yymsp[-5].minor.yy0);
179326 }
179327 yymsp[-5].minor.yy483 = yylhsminor.yy483;
179328 break;
179329 case 318: /* window ::= ORDER BY sortlist frame_opt */
179330 {
179331 yymsp[-3].minor.yy483 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy483, 0, yymsp[-1].minor.yy402, 0);
179332 }
179333 break;
179334 case 319: /* window ::= nm ORDER BY sortlist frame_opt */
179335 {
179336 yylhsminor.yy483 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy483, 0, yymsp[-1].minor.yy402, &yymsp[-4].minor.yy0);
179337 }
179338 yymsp[-4].minor.yy483 = yylhsminor.yy483;
179339 break;
179340 case 320: /* window ::= nm frame_opt */
179341 {
179342 yylhsminor.yy483 = sqlite3WindowAssemble(pParse, yymsp[0].minor.yy483, 0, 0, &yymsp[-1].minor.yy0);
179343 }
179344 yymsp[-1].minor.yy483 = yylhsminor.yy483;
179345 break;
179346 case 321: /* frame_opt ::= */
179347 {
179348 yymsp[1].minor.yy483 = sqlite3WindowAlloc(pParse, 0, TK_UNBOUNDED, 0, TK_CURRENT, 0, 0);
179349 }
179350 break;
179351 case 322: /* frame_opt ::= range_or_rows frame_bound_s frame_exclude_opt */
179352 {
179353 yylhsminor.yy483 = sqlite3WindowAlloc(pParse, yymsp[-2].minor.yy502, yymsp[-1].minor.yy205.eType, yymsp[-1].minor.yy205.pExpr, TK_CURRENT, 0, yymsp[0].minor.yy444);
179354 }
179355 yymsp[-2].minor.yy483 = yylhsminor.yy483;
179356 break;
179357 case 323: /* frame_opt ::= range_or_rows BETWEEN frame_bound_s AND frame_bound_e frame_exclude_opt */
179358 {
179359 yylhsminor.yy483 = sqlite3WindowAlloc(pParse, yymsp[-5].minor.yy502, yymsp[-3].minor.yy205.eType, yymsp[-3].minor.yy205.pExpr, yymsp[-1].minor.yy205.eType, yymsp[-1].minor.yy205.pExpr, yymsp[0].minor.yy444);
179360 }
179361 yymsp[-5].minor.yy483 = yylhsminor.yy483;
179362 break;
179363 case 325: /* frame_bound_s ::= frame_bound */
179364 case 327: /* frame_bound_e ::= frame_bound */ yytestcase(yyruleno==327);
179365 {yylhsminor.yy205 = yymsp[0].minor.yy205;}
179366 yymsp[0].minor.yy205 = yylhsminor.yy205;
179367 break;
179368 case 326: /* frame_bound_s ::= UNBOUNDED PRECEDING */
179369 case 328: /* frame_bound_e ::= UNBOUNDED FOLLOWING */ yytestcase(yyruleno==328);
179370 case 330: /* frame_bound ::= CURRENT ROW */ yytestcase(yyruleno==330);
179371 {yylhsminor.yy205.eType = yymsp[-1].major; yylhsminor.yy205.pExpr = 0;}
179372 yymsp[-1].minor.yy205 = yylhsminor.yy205;
179373 break;
179374 case 329: /* frame_bound ::= expr PRECEDING|FOLLOWING */
179375 {yylhsminor.yy205.eType = yymsp[0].major; yylhsminor.yy205.pExpr = yymsp[-1].minor.yy590;}
179376 yymsp[-1].minor.yy205 = yylhsminor.yy205;
179377 break;
179378 case 331: /* frame_exclude_opt ::= */
179379 {yymsp[1].minor.yy444 = 0;}
179380 break;
179381 case 332: /* frame_exclude_opt ::= EXCLUDE frame_exclude */
179382 {yymsp[-1].minor.yy444 = yymsp[0].minor.yy444;}
179383 break;
179384 case 333: /* frame_exclude ::= NO OTHERS */
179385 case 334: /* frame_exclude ::= CURRENT ROW */ yytestcase(yyruleno==334);
179386 {yymsp[-1].minor.yy444 = yymsp[-1].major; /*A-overwrites-X*/}
179387 break;
179388 case 335: /* frame_exclude ::= GROUP|TIES */
179389 {yymsp[0].minor.yy444 = yymsp[0].major; /*A-overwrites-X*/}
179390 break;
179391 case 336: /* window_clause ::= WINDOW windowdefn_list */
179392 { yymsp[-1].minor.yy483 = yymsp[0].minor.yy483; }
179393 break;
179394 case 337: /* filter_over ::= filter_clause over_clause */
179395 {
179396 if( yymsp[0].minor.yy483 ){
179397 yymsp[0].minor.yy483->pFilter = yymsp[-1].minor.yy590;
179398 }else{
179399 sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy590);
179400 }
179401 yylhsminor.yy483 = yymsp[0].minor.yy483;
179402 }
179403 yymsp[-1].minor.yy483 = yylhsminor.yy483;
179404 break;
179405 case 338: /* filter_over ::= over_clause */
179406 {
179407 yylhsminor.yy483 = yymsp[0].minor.yy483;
179408 }
179409 yymsp[0].minor.yy483 = yylhsminor.yy483;
179410 break;
179411 case 339: /* filter_over ::= filter_clause */
179412 {
179413 yylhsminor.yy483 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
179414 if( yylhsminor.yy483 ){
179415 yylhsminor.yy483->eFrmType = TK_FILTER;
179416 yylhsminor.yy483->pFilter = yymsp[0].minor.yy590;
179417 }else{
179418 sqlite3ExprDelete(pParse->db, yymsp[0].minor.yy590);
179419 }
179420 }
179421 yymsp[0].minor.yy483 = yylhsminor.yy483;
179422 break;
179423 case 340: /* over_clause ::= OVER LP window RP */
179424 {
179425 yymsp[-3].minor.yy483 = yymsp[-1].minor.yy483;
179426 assert( yymsp[-3].minor.yy483!=0 );
179427 }
179428 break;
179429 case 341: /* over_clause ::= OVER nm */
179430 {
179431 yymsp[-1].minor.yy483 = (Window*)sqlite3DbMallocZero(pParse->db, sizeof(Window));
179432 if( yymsp[-1].minor.yy483 ){
179433 yymsp[-1].minor.yy483->zName = sqlite3DbStrNDup(pParse->db, yymsp[0].minor.yy0.z, yymsp[0].minor.yy0.n);
179434 }
179435 }
179436 break;
179437 case 342: /* filter_clause ::= FILTER LP WHERE expr RP */
179438 { yymsp[-4].minor.yy590 = yymsp[-1].minor.yy590; }
179439 break;
179440 case 343: /* term ::= QNUMBER */
179441 {
179442 yylhsminor.yy590=tokenExpr(pParse,yymsp[0].major,yymsp[0].minor.yy0);
179443 sqlite3DequoteNumber(pParse, yylhsminor.yy590);
179444 }
179445 yymsp[0].minor.yy590 = yylhsminor.yy590;
179446 break;
179447 default:
179448 /* (344) input ::= cmdlist */ yytestcase(yyruleno==344);
179449 /* (345) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==345);
179450 /* (346) cmdlist ::= ecmd (OPTIMIZED OUT) */ assert(yyruleno!=346);
@@ -180229,11 +180621,11 @@
180621 return i;
180622 }
180623 case CC_MINUS: {
180624 if( z[1]=='-' ){
180625 for(i=2; (c=z[i])!=0 && c!='\n'; i++){}
180626 *tokenType = TK_COMMENT;
180627 return i;
180628 }else if( z[1]=='>' ){
180629 *tokenType = TK_PTR;
180630 return 2 + (z[2]=='>');
180631 }
@@ -180265,11 +180657,11 @@
180657 *tokenType = TK_SLASH;
180658 return 1;
180659 }
180660 for(i=3, c=z[2]; (c!='*' || z[i]!='/') && (c=z[i])!=0; i++){}
180661 if( c ) i++;
180662 *tokenType = TK_COMMENT;
180663 return i;
180664 }
180665 case CC_PERCENT: {
180666 *tokenType = TK_REM;
180667 return 1;
@@ -180594,16 +180986,16 @@
180986 }
180987 #ifndef SQLITE_OMIT_WINDOWFUNC
180988 if( tokenType>=TK_WINDOW ){
180989 assert( tokenType==TK_SPACE || tokenType==TK_OVER || tokenType==TK_FILTER
180990 || tokenType==TK_ILLEGAL || tokenType==TK_WINDOW
180991 || tokenType==TK_QNUMBER || tokenType==TK_COMMENT
180992 );
180993 #else
180994 if( tokenType>=TK_SPACE ){
180995 assert( tokenType==TK_SPACE || tokenType==TK_ILLEGAL
180996 || tokenType==TK_QNUMBER || tokenType==TK_COMMENT
180997 );
180998 #endif /* SQLITE_OMIT_WINDOWFUNC */
180999 if( AtomicLoad(&db->u1.isInterrupted) ){
181000 pParse->rc = SQLITE_INTERRUPT;
181001 pParse->nErr++;
@@ -180633,10 +181025,13 @@
181025 tokenType = analyzeOverKeyword((const u8*)&zSql[4], lastTokenParsed);
181026 }else if( tokenType==TK_FILTER ){
181027 assert( n==6 );
181028 tokenType = analyzeFilterKeyword((const u8*)&zSql[6], lastTokenParsed);
181029 #endif /* SQLITE_OMIT_WINDOWFUNC */
181030 }else if( tokenType==TK_COMMENT && (db->flags & SQLITE_Comments)!=0 ){
181031 zSql += n;
181032 continue;
181033 }else if( tokenType!=TK_QNUMBER ){
181034 Token x;
181035 x.z = zSql;
181036 x.n = n;
181037 sqlite3ErrorMsg(pParse, "unrecognized token: \"%T\"", &x);
@@ -180739,10 +181134,11 @@
181134 prevType = tokenType;
181135 }
181136 n = sqlite3GetToken((unsigned char*)zSql+i, &tokenType);
181137 if( NEVER(n<=0) ) break;
181138 switch( tokenType ){
181139 case TK_COMMENT:
181140 case TK_SPACE: {
181141 break;
181142 }
181143 case TK_NULL: {
181144 if( prevType==TK_IS || prevType==TK_NOT ){
@@ -181980,21 +182376,26 @@
182376 ** Set up the lookaside buffers for a database connection.
182377 ** Return SQLITE_OK on success.
182378 ** If lookaside is already active, return SQLITE_BUSY.
182379 **
182380 ** The sz parameter is the number of bytes in each lookaside slot.
182381 ** The cnt parameter is the number of slots. If pBuf is NULL the
182382 ** space for the lookaside memory is obtained from sqlite3_malloc()
182383 ** or similar. If pBuf is not NULL then it is sz*cnt bytes of memory
182384 ** to use for the lookaside memory.
182385 */
182386 static int setupLookaside(
182387 sqlite3 *db, /* Database connection being configured */
182388 void *pBuf, /* Memory to use for lookaside. May be NULL */
182389 int sz, /* Desired size of each lookaside memory slot */
182390 int cnt /* Number of slots to allocate */
182391 ){
182392 #ifndef SQLITE_OMIT_LOOKASIDE
182393 void *pStart; /* Start of the lookaside buffer */
182394 sqlite3_int64 szAlloc; /* Total space set aside for lookaside memory */
182395 int nBig; /* Number of full-size slots */
182396 int nSm; /* Number smaller LOOKASIDE_SMALL-byte slots */
182397
182398 if( sqlite3LookasideUsed(db,0)>0 ){
182399 return SQLITE_BUSY;
182400 }
182401 /* Free any existing lookaside buffer for this handle before
@@ -182003,33 +182404,38 @@
182404 */
182405 if( db->lookaside.bMalloced ){
182406 sqlite3_free(db->lookaside.pStart);
182407 }
182408 /* The size of a lookaside slot after ROUNDDOWN8 needs to be larger
182409 ** than a pointer and small enough to fit in a u16.
182410 */
182411 sz = ROUNDDOWN8(sz);
182412 if( sz<=(int)sizeof(LookasideSlot*) ) sz = 0;
182413 if( sz>65528 ) sz = 65528;
182414 /* Count must be at least 1 to be useful, but not so large as to use
182415 ** more than 0x7fff0000 total bytes for lookaside. */
182416 if( cnt<1 ) cnt = 0;
182417 if( sz>0 && cnt>(0x7fff0000/sz) ) cnt = 0x7fff0000/sz;
182418 szAlloc = (i64)sz*(i64)cnt;
182419 if( szAlloc==0 ){
182420 sz = 0;
182421 pStart = 0;
182422 }else if( pBuf==0 ){
182423 sqlite3BeginBenignMalloc();
182424 pStart = sqlite3Malloc( szAlloc );
182425 sqlite3EndBenignMalloc();
182426 if( pStart ) szAlloc = sqlite3MallocSize(pStart);
182427 }else{
182428 pStart = pBuf;
182429 }
182430 #ifndef SQLITE_OMIT_TWOSIZE_LOOKASIDE
182431 if( sz>=LOOKASIDE_SMALL*3 ){
182432 nBig = szAlloc/(3*LOOKASIDE_SMALL+sz);
182433 nSm = (szAlloc - (i64)sz*(i64)nBig)/LOOKASIDE_SMALL;
182434 }else if( sz>=LOOKASIDE_SMALL*2 ){
182435 nBig = szAlloc/(LOOKASIDE_SMALL+sz);
182436 nSm = (szAlloc - (i64)sz*(i64)nBig)/LOOKASIDE_SMALL;
182437 }else
182438 #endif /* SQLITE_OMIT_TWOSIZE_LOOKASIDE */
182439 if( sz>0 ){
182440 nBig = szAlloc/sz;
182441 nSm = 0;
@@ -182180,11 +182586,11 @@
182586 break;
182587 }
182588 default: {
182589 static const struct {
182590 int op; /* The opcode */
182591 u64 mask; /* Mask of the bit in sqlite3.flags to set/clear */
182592 } aFlagOp[] = {
182593 { SQLITE_DBCONFIG_ENABLE_FKEY, SQLITE_ForeignKeys },
182594 { SQLITE_DBCONFIG_ENABLE_TRIGGER, SQLITE_EnableTrigger },
182595 { SQLITE_DBCONFIG_ENABLE_VIEW, SQLITE_EnableView },
182596 { SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER, SQLITE_Fts3Tokenizer },
@@ -182201,10 +182607,13 @@
182607 { SQLITE_DBCONFIG_DQS_DML, SQLITE_DqsDML },
182608 { SQLITE_DBCONFIG_LEGACY_FILE_FORMAT, SQLITE_LegacyFileFmt },
182609 { SQLITE_DBCONFIG_TRUSTED_SCHEMA, SQLITE_TrustedSchema },
182610 { SQLITE_DBCONFIG_STMT_SCANSTATUS, SQLITE_StmtScanStatus },
182611 { SQLITE_DBCONFIG_REVERSE_SCANORDER, SQLITE_ReverseOrder },
182612 { SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE, SQLITE_AttachCreate },
182613 { SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE, SQLITE_AttachWrite },
182614 { SQLITE_DBCONFIG_ENABLE_COMMENTS, SQLITE_Comments },
182615 };
182616 unsigned int i;
182617 rc = SQLITE_ERROR; /* IMP: R-42790-23372 */
182618 for(i=0; i<ArraySize(aFlagOp); i++){
182619 if( aFlagOp[i].op==op ){
@@ -184078,12 +184487,12 @@
184487 # error SQLITE_MAX_COMPOUND_SELECT must be at least 2
184488 #endif
184489 #if SQLITE_MAX_VDBE_OP<40
184490 # error SQLITE_MAX_VDBE_OP must be at least 40
184491 #endif
184492 #if SQLITE_MAX_FUNCTION_ARG<0 || SQLITE_MAX_FUNCTION_ARG>32767
184493 # error SQLITE_MAX_FUNCTION_ARG must be between 0 and 32767
184494 #endif
184495 #if SQLITE_MAX_ATTACHED<0 || SQLITE_MAX_ATTACHED>125
184496 # error SQLITE_MAX_ATTACHED must be between 0 and 125
184497 #endif
184498 #if SQLITE_MAX_LIKE_PATTERN_LENGTH<1
@@ -184542,10 +184951,13 @@
184951 #endif
184952 db->flags |= SQLITE_ShortColNames
184953 | SQLITE_EnableTrigger
184954 | SQLITE_EnableView
184955 | SQLITE_CacheSpill
184956 | SQLITE_AttachCreate
184957 | SQLITE_AttachWrite
184958 | SQLITE_Comments
184959 #if !defined(SQLITE_TRUSTED_SCHEMA) || SQLITE_TRUSTED_SCHEMA+0!=0
184960 | SQLITE_TrustedSchema
184961 #endif
184962 /* The SQLITE_DQS compile-time option determines the default settings
184963 ** for SQLITE_DBCONFIG_DQS_DDL and SQLITE_DBCONFIG_DQS_DML.
@@ -185158,17 +185570,14 @@
185570
185571 /* Find the column for which info is requested */
185572 if( zColumnName==0 ){
185573 /* Query for existence of table only */
185574 }else{
185575 iCol = sqlite3ColumnIndex(pTab, zColumnName);
185576 if( iCol>=0 ){
185577 pCol = &pTab->aCol[iCol];
185578 }else{
 
 
 
 
185579 if( HasRowid(pTab) && sqlite3IsRowid(zColumnName) ){
185580 iCol = pTab->iPKey;
185581 pCol = iCol>=0 ? &pTab->aCol[iCol] : 0;
185582 }else{
185583 pTab = 0;
@@ -185492,11 +185901,10 @@
185901 #if defined(SQLITE_DEBUG)
185902 /* Invoke these debugging routines so that the compiler does not
185903 ** issue "defined but not used" warnings. */
185904 if( x==9999 ){
185905 sqlite3ShowExpr(0);
 
185906 sqlite3ShowExprList(0);
185907 sqlite3ShowIdList(0);
185908 sqlite3ShowSrcList(0);
185909 sqlite3ShowWith(0);
185910 sqlite3ShowUpsert(0);
@@ -185509,11 +185917,10 @@
185917 #ifndef SQLITE_OMIT_WINDOWFUNC
185918 sqlite3ShowWindow(0);
185919 sqlite3ShowWinFunc(0);
185920 #endif
185921 sqlite3ShowSelect(0);
 
185922 }
185923 #endif
185924 break;
185925 }
185926
@@ -187849,10 +188256,11 @@
188256 SQLITE_PRIVATE int sqlite3Fts3MsrIncrNext(
188257 Fts3Table *, Fts3MultiSegReader *, sqlite3_int64 *, char **, int *);
188258 SQLITE_PRIVATE int sqlite3Fts3EvalPhrasePoslist(Fts3Cursor *, Fts3Expr *, int iCol, char **);
188259 SQLITE_PRIVATE int sqlite3Fts3MsrOvfl(Fts3Cursor *, Fts3MultiSegReader *, int *);
188260 SQLITE_PRIVATE int sqlite3Fts3MsrIncrRestart(Fts3MultiSegReader *pCsr);
188261 SQLITE_PRIVATE int sqlite3Fts3MsrCancel(Fts3Cursor*, Fts3Expr*);
188262
188263 /* fts3_tokenize_vtab.c */
188264 SQLITE_PRIVATE int sqlite3Fts3InitTok(sqlite3*, Fts3Hash *, void(*xDestroy)(void*));
188265
188266 /* fts3_unicode2.c (functions generated by parsing unicode text files) */
@@ -192018,11 +192426,11 @@
192426 p1 = pPhrase->doclist.pList;
192427 p2 = aPoslist;
192428 nDistance = iPrev - nMaxUndeferred;
192429 }
192430
192431 aOut = (char *)sqlite3Fts3MallocZero(((i64)nPoslist)+FTS3_BUFFER_PADDING);
192432 if( !aOut ){
192433 sqlite3_free(aPoslist);
192434 return SQLITE_NOMEM;
192435 }
192436
@@ -193366,10 +193774,28 @@
193774
193775 fts3EvalRestart(pCsr, pExpr->pLeft, pRc);
193776 fts3EvalRestart(pCsr, pExpr->pRight, pRc);
193777 }
193778 }
193779
193780 /*
193781 ** Expression node pExpr is an MSR phrase. This function restarts pExpr
193782 ** so that it is a regular phrase query, not an MSR. SQLITE_OK is returned
193783 ** if successful, or an SQLite error code otherwise.
193784 */
193785 SQLITE_PRIVATE int sqlite3Fts3MsrCancel(Fts3Cursor *pCsr, Fts3Expr *pExpr){
193786 int rc = SQLITE_OK;
193787 if( pExpr->bEof==0 ){
193788 i64 iDocid = pExpr->iDocid;
193789 fts3EvalRestart(pCsr, pExpr, &rc);
193790 while( rc==SQLITE_OK && pExpr->iDocid!=iDocid ){
193791 fts3EvalNextRow(pCsr, pExpr, &rc);
193792 if( pExpr->bEof ) rc = FTS_CORRUPT_VTAB;
193793 }
193794 }
193795 return rc;
193796 }
193797
193798 /*
193799 ** After allocating the Fts3Expr.aMI[] array for each phrase in the
193800 ** expression rooted at pExpr, the cursor iterates through all rows matched
193801 ** by pExpr, calling this function for each row. This function increments
@@ -194620,11 +195046,11 @@
195046 sqlite3_tokenizer_module const *pModule = pTokenizer->pModule;
195047 int rc;
195048 Fts3Expr *p = 0;
195049 sqlite3_tokenizer_cursor *pCursor = 0;
195050 char *zTemp = 0;
195051 i64 nTemp = 0;
195052
195053 const int nSpace = sizeof(Fts3Expr) + sizeof(Fts3Phrase);
195054 int nToken = 0;
195055
195056 /* The final Fts3Expr data structure, including the Fts3Phrase,
@@ -205323,10 +205749,26 @@
205749 pT->iPos = iPos;
205750 }
205751
205752 return rc;
205753 }
205754
205755 /*
205756 ** If expression pExpr is a phrase expression that uses an MSR query,
205757 ** restart it as a regular, non-incremental query. Return SQLITE_OK
205758 ** if successful, or an SQLite error code otherwise.
205759 */
205760 static int fts3ExprRestartIfCb(Fts3Expr *pExpr, int iPhrase, void *ctx){
205761 TermOffsetCtx *p = (TermOffsetCtx*)ctx;
205762 int rc = SQLITE_OK;
205763 UNUSED_PARAMETER(iPhrase);
205764 if( pExpr->pPhrase && pExpr->pPhrase->bIncr ){
205765 rc = sqlite3Fts3MsrCancel(p->pCsr, pExpr);
205766 pExpr->pPhrase->bIncr = 0;
205767 }
205768 return rc;
205769 }
205770
205771 /*
205772 ** Implementation of offsets() function.
205773 */
205774 SQLITE_PRIVATE void sqlite3Fts3Offsets(
@@ -205359,10 +205801,16 @@
205801 rc = SQLITE_NOMEM;
205802 goto offsets_out;
205803 }
205804 sCtx.iDocid = pCsr->iPrevId;
205805 sCtx.pCsr = pCsr;
205806
205807 /* If a query restart will be required, do it here, rather than later of
205808 ** after pointers to poslist buffers that may be invalidated by a restart
205809 ** have been saved. */
205810 rc = sqlite3Fts3ExprIterate(pCsr->pExpr, fts3ExprRestartIfCb, (void*)&sCtx);
205811 if( rc!=SQLITE_OK ) goto offsets_out;
205812
205813 /* Loop through the table columns, appending offset information to
205814 ** string-buffer res for each column.
205815 */
205816 for(iCol=0; iCol<pTab->nColumn; iCol++){
@@ -207369,22 +207817,23 @@
207817 **
207818 ** Return the number of errors.
207819 */
207820 static int jsonBlobExpand(JsonParse *pParse, u32 N){
207821 u8 *aNew;
207822 u64 t;
207823 assert( N>pParse->nBlobAlloc );
207824 if( pParse->nBlobAlloc==0 ){
207825 t = 100;
207826 }else{
207827 t = pParse->nBlobAlloc*2;
207828 }
207829 if( t<N ) t = N+100;
207830 aNew = sqlite3DbRealloc(pParse->db, pParse->aBlob, t);
207831 if( aNew==0 ){ pParse->oom = 1; return 1; }
207832 assert( t<0x7fffffff );
207833 pParse->aBlob = aNew;
207834 pParse->nBlobAlloc = (u32)t;
207835 return 0;
207836 }
207837
207838 /*
207839 ** If pParse->aBlob is not previously editable (because it is taken
@@ -208337,14 +208786,11 @@
208786 */
208787 static u32 jsonbPayloadSize(const JsonParse *pParse, u32 i, u32 *pSz){
208788 u8 x;
208789 u32 sz;
208790 u32 n;
208791 assert( i<=pParse->nBlob );
 
 
 
208792 x = pParse->aBlob[i]>>4;
208793 if( x<=11 ){
208794 sz = x;
208795 n = 1;
208796 }else if( x==12 ){
@@ -208384,12 +208830,12 @@
208830 n = 9;
208831 }
208832 if( (i64)i+sz+n > pParse->nBlob
208833 && (i64)i+sz+n > pParse->nBlob-pParse->delta
208834 ){
208835 *pSz = 0;
208836 return 0;
208837 }
208838 *pSz = sz;
208839 return n;
208840 }
208841
@@ -208482,13 +208928,16 @@
208928 }
208929 break;
208930 }
208931 case JSONB_TEXT:
208932 case JSONB_TEXTJ: {
208933 if( pOut->nUsed+sz+2<=pOut->nAlloc || jsonStringGrow(pOut, sz+2)==0 ){
208934 pOut->zBuf[pOut->nUsed] = '"';
208935 memcpy(pOut->zBuf+pOut->nUsed+1,(const char*)&pParse->aBlob[i+n],sz);
208936 pOut->zBuf[pOut->nUsed+sz+1] = '"';
208937 pOut->nUsed += sz+2;
208938 }
208939 break;
208940 }
208941 case JSONB_TEXT5: {
208942 const char *zIn;
208943 u32 k;
@@ -209399,11 +209848,11 @@
209848 u32 iIn, iOut;
209849 const char *z;
209850 char *zOut;
209851 u32 nOut = sz;
209852 z = (const char*)&pParse->aBlob[i+n];
209853 zOut = sqlite3DbMallocRaw(db, ((u64)nOut)+1);
209854 if( zOut==0 ) goto returnfromblob_oom;
209855 for(iIn=iOut=0; iIn<sz; iIn++){
209856 char c = z[iIn];
209857 if( c=='\\' ){
209858 u32 v;
@@ -215527,12 +215976,12 @@
215976 #endif
215977 }
215978 sqlite3_str_append(pOut, "}", 1);
215979 }
215980 errCode = sqlite3_str_errcode(pOut);
 
215981 sqlite3_result_error_code(ctx, errCode);
215982 sqlite3_result_text(ctx, sqlite3_str_finish(pOut), -1, sqlite3_free);
215983 }
215984
215985 /* This routine implements an SQL function that returns the "depth" parameter
215986 ** from the front of a blob that is an r-tree node. For example:
215987 **
@@ -226232,10 +226681,28 @@
226681 static int dbpageRowid(sqlite3_vtab_cursor *pCursor, sqlite_int64 *pRowid){
226682 DbpageCursor *pCsr = (DbpageCursor *)pCursor;
226683 *pRowid = pCsr->pgno;
226684 return SQLITE_OK;
226685 }
226686
226687 /*
226688 ** Open write transactions. Since we do not know in advance which database
226689 ** files will be written by the sqlite_dbpage virtual table, start a write
226690 ** transaction on them all.
226691 **
226692 ** Return SQLITE_OK if successful, or an SQLite error code otherwise.
226693 */
226694 static int dbpageBeginTrans(DbpageTable *pTab){
226695 sqlite3 *db = pTab->db;
226696 int rc = SQLITE_OK;
226697 int i;
226698 for(i=0; rc==SQLITE_OK && i<db->nDb; i++){
226699 Btree *pBt = db->aDb[i].pBt;
226700 if( pBt ) rc = sqlite3BtreeBeginTrans(pBt, 1, 0);
226701 }
226702 return rc;
226703 }
226704
226705 static int dbpageUpdate(
226706 sqlite3_vtab *pVtab,
226707 int argc,
226708 sqlite3_value **argv,
@@ -226300,10 +226767,16 @@
226767 }else{
226768 zErr = "bad page value";
226769 goto update_fail;
226770 }
226771 }
226772
226773 if( dbpageBeginTrans(pTab)!=SQLITE_OK ){
226774 zErr = "failed to open transaction";
226775 goto update_fail;
226776 }
226777
226778 pPager = sqlite3BtreePager(pBt);
226779 rc = sqlite3PagerGet(pPager, pgno, (DbPage**)&pDbPage, 0);
226780 if( rc==SQLITE_OK ){
226781 const void *pData = sqlite3_value_blob(argv[3]);
226782 if( (rc = sqlite3PagerWrite(pDbPage))==SQLITE_OK && pData ){
@@ -226316,27 +226789,18 @@
226789 }
226790 sqlite3PagerUnref(pDbPage);
226791 return rc;
226792
226793 update_fail:
226794 pTab->pgnoTrunc = 0;
226795 sqlite3_free(pVtab->zErrMsg);
226796 pVtab->zErrMsg = sqlite3_mprintf("%s", zErr);
226797 return SQLITE_ERROR;
226798 }
226799
 
 
 
 
226800 static int dbpageBegin(sqlite3_vtab *pVtab){
226801 DbpageTable *pTab = (DbpageTable *)pVtab;
 
 
 
 
 
 
226802 pTab->pgnoTrunc = 0;
226803 return SQLITE_OK;
226804 }
226805
226806 /* Invoke sqlite3PagerTruncate() as necessary, just prior to COMMIT
@@ -226344,11 +226808,15 @@
226808 static int dbpageSync(sqlite3_vtab *pVtab){
226809 DbpageTable *pTab = (DbpageTable *)pVtab;
226810 if( pTab->pgnoTrunc>0 ){
226811 Btree *pBt = pTab->db->aDb[pTab->iDbTrunc].pBt;
226812 Pager *pPager = sqlite3BtreePager(pBt);
226813 sqlite3BtreeEnter(pBt);
226814 if( pTab->pgnoTrunc<sqlite3BtreeLastPage(pBt) ){
226815 sqlite3PagerTruncateImage(pPager, pTab->pgnoTrunc);
226816 }
226817 sqlite3BtreeLeave(pBt);
226818 }
226819 pTab->pgnoTrunc = 0;
226820 return SQLITE_OK;
226821 }
226822
@@ -226364,11 +226832,11 @@
226832 /*
226833 ** Invoke this routine to register the "dbpage" virtual table module
226834 */
226835 SQLITE_PRIVATE int sqlite3DbpageRegister(sqlite3 *db){
226836 static sqlite3_module dbpage_module = {
226837 2, /* iVersion */
226838 dbpageConnect, /* xCreate */
226839 dbpageConnect, /* xConnect */
226840 dbpageBestIndex, /* xBestIndex */
226841 dbpageDisconnect, /* xDisconnect */
226842 dbpageDisconnect, /* xDestroy */
@@ -226539,15 +227007,17 @@
227007 ** SELECT 1, NULL, 'abc'
227008 */
227009 struct SessionTable {
227010 SessionTable *pNext;
227011 char *zName; /* Local name of table */
227012 int nCol; /* Number of non-hidden columns */
227013 int nTotalCol; /* Number of columns including hidden */
227014 int bStat1; /* True if this is sqlite_stat1 */
227015 int bRowid; /* True if this table uses rowid for PK */
227016 const char **azCol; /* Column names */
227017 const char **azDflt; /* Default value expressions */
227018 int *aiIdx; /* Index to pass to xNew/xOld */
227019 u8 *abPK; /* Array of primary key flags */
227020 int nEntry; /* Total number of entries in hash table */
227021 int nChange; /* Size of apChange[] array */
227022 SessionChange **apChange; /* Hash table buckets */
227023 sqlite3_stmt *pDfltStmt;
@@ -226946,26 +227416,26 @@
227416 int *pbNullPK /* OUT: True if there are NULL values in PK */
227417 ){
227418 unsigned int h = 0; /* Hash value to return */
227419 int i; /* Used to iterate through columns */
227420
227421 assert( pTab->nTotalCol==pSession->hook.xCount(pSession->hook.pCtx) );
227422 if( pTab->bRowid ){
 
227423 h = sessionHashAppendI64(h, iRowid);
227424 }else{
227425 assert( *pbNullPK==0 );
 
227426 for(i=0; i<pTab->nCol; i++){
227427 if( pTab->abPK[i] ){
227428 int rc;
227429 int eType;
227430 sqlite3_value *pVal;
227431 int iIdx = pTab->aiIdx[i];
227432
227433 if( bNew ){
227434 rc = pSession->hook.xNew(pSession->hook.pCtx, iIdx, &pVal);
227435 }else{
227436 rc = pSession->hook.xOld(pSession->hook.pCtx, iIdx, &pVal);
227437 }
227438 if( rc!=SQLITE_OK ) return rc;
227439
227440 eType = sqlite3_value_type(pVal);
227441 h = sessionHashAppendType(h, eType);
@@ -227298,22 +227768,23 @@
227768 a += sessionSerialLen(a);
227769 }else{
227770 sqlite3_value *pVal; /* Value returned by preupdate_new/old */
227771 int rc; /* Error code from preupdate_new/old */
227772 int eType = *a++; /* Type of value from change record */
227773 int iIdx = pTab->aiIdx[iCol];
227774
227775 /* The following calls to preupdate_new() and preupdate_old() can not
227776 ** fail. This is because they cache their return values, and by the
227777 ** time control flows to here they have already been called once from
227778 ** within sessionPreupdateHash(). The first two asserts below verify
227779 ** this (that the method has already been called). */
227780 if( op==SQLITE_INSERT ){
227781 /* assert( db->pPreUpdate->pNewUnpacked || db->pPreUpdate->aNew ); */
227782 rc = pSession->hook.xNew(pSession->hook.pCtx, iIdx, &pVal);
227783 }else{
227784 /* assert( db->pPreUpdate->pUnpacked ); */
227785 rc = pSession->hook.xOld(pSession->hook.pCtx, iIdx, &pVal);
227786 }
227787 assert( rc==SQLITE_OK );
227788 (void)rc; /* Suppress warning about unused variable */
227789 if( sqlite3_value_type(pVal)!=eType ) return 0;
227790
@@ -227434,13 +227905,15 @@
227905 sqlite3_session *pSession, /* For memory accounting. May be NULL */
227906 sqlite3 *db, /* Database connection */
227907 const char *zDb, /* Name of attached database (e.g. "main") */
227908 const char *zThis, /* Table name */
227909 int *pnCol, /* OUT: number of columns */
227910 int *pnTotalCol, /* OUT: number of hidden columns */
227911 const char **pzTab, /* OUT: Copy of zThis */
227912 const char ***pazCol, /* OUT: Array of column names for table */
227913 const char ***pazDflt, /* OUT: Array of default value expressions */
227914 int **paiIdx, /* OUT: Array of xNew/xOld indexes */
227915 u8 **pabPK, /* OUT: Array of booleans - true for PK col */
227916 int *pbRowid /* OUT: True if only PK is a rowid */
227917 ){
227918 char *zPragma;
227919 sqlite3_stmt *pStmt;
@@ -227451,37 +227924,40 @@
227924 int i;
227925 u8 *pAlloc = 0;
227926 char **azCol = 0;
227927 char **azDflt = 0;
227928 u8 *abPK = 0;
227929 int *aiIdx = 0;
227930 int bRowid = 0; /* Set to true to use rowid as PK */
227931
227932 assert( pazCol && pabPK );
227933
227934 *pazCol = 0;
227935 *pabPK = 0;
227936 *pnCol = 0;
227937 if( pnTotalCol ) *pnTotalCol = 0;
227938 if( paiIdx ) *paiIdx = 0;
227939 if( pzTab ) *pzTab = 0;
227940 if( pazDflt ) *pazDflt = 0;
227941
227942 nThis = sqlite3Strlen30(zThis);
227943 if( nThis==12 && 0==sqlite3_stricmp("sqlite_stat1", zThis) ){
227944 rc = sqlite3_table_column_metadata(db, zDb, zThis, 0, 0, 0, 0, 0, 0);
227945 if( rc==SQLITE_OK ){
227946 /* For sqlite_stat1, pretend that (tbl,idx) is the PRIMARY KEY. */
227947 zPragma = sqlite3_mprintf(
227948 "SELECT 0, 'tbl', '', 0, '', 1, 0 UNION ALL "
227949 "SELECT 1, 'idx', '', 0, '', 2, 0 UNION ALL "
227950 "SELECT 2, 'stat', '', 0, '', 0, 0"
227951 );
227952 }else if( rc==SQLITE_ERROR ){
227953 zPragma = sqlite3_mprintf("");
227954 }else{
227955 return rc;
227956 }
227957 }else{
227958 zPragma = sqlite3_mprintf("PRAGMA '%q'.table_xinfo('%q')", zDb, zThis);
227959 }
227960 if( !zPragma ){
227961 return SQLITE_NOMEM;
227962 }
227963
@@ -227494,20 +227970,22 @@
227970 nByte = nThis + 1;
227971 bRowid = (pbRowid!=0);
227972 while( SQLITE_ROW==sqlite3_step(pStmt) ){
227973 nByte += sqlite3_column_bytes(pStmt, 1); /* name */
227974 nByte += sqlite3_column_bytes(pStmt, 4); /* dflt_value */
227975 if( sqlite3_column_int(pStmt, 6)==0 ){ /* !hidden */
227976 nDbCol++;
227977 }
227978 if( sqlite3_column_int(pStmt, 5) ) bRowid = 0; /* pk */
227979 }
227980 if( nDbCol==0 ) bRowid = 0;
227981 nDbCol += bRowid;
227982 nByte += strlen(SESSIONS_ROWID);
227983 rc = sqlite3_reset(pStmt);
227984
227985 if( rc==SQLITE_OK ){
227986 nByte += nDbCol * (sizeof(const char *)*2 +sizeof(int)+sizeof(u8) + 1 + 1);
227987 pAlloc = sessionMalloc64(pSession, nByte);
227988 if( pAlloc==0 ){
227989 rc = SQLITE_NOMEM;
227990 }else{
227991 memset(pAlloc, 0, nByte);
@@ -227514,12 +227992,12 @@
227992 }
227993 }
227994 if( rc==SQLITE_OK ){
227995 azCol = (char **)pAlloc;
227996 azDflt = (char**)&azCol[nDbCol];
227997 aiIdx = (int*)&azDflt[nDbCol];
227998 abPK = (u8 *)&aiIdx[nDbCol];
227999 pAlloc = &abPK[nDbCol];
228000 if( pzTab ){
228001 memcpy(pAlloc, zThis, nThis+1);
228002 *pzTab = (char *)pAlloc;
228003 pAlloc += nThis+1;
@@ -227530,31 +228008,36 @@
228008 size_t nName = strlen(SESSIONS_ROWID);
228009 memcpy(pAlloc, SESSIONS_ROWID, nName+1);
228010 azCol[i] = (char*)pAlloc;
228011 pAlloc += nName+1;
228012 abPK[i] = 1;
228013 aiIdx[i] = -1;
228014 i++;
228015 }
228016 while( SQLITE_ROW==sqlite3_step(pStmt) ){
228017 if( sqlite3_column_int(pStmt, 6)==0 ){ /* !hidden */
228018 int nName = sqlite3_column_bytes(pStmt, 1);
228019 int nDflt = sqlite3_column_bytes(pStmt, 4);
228020 const unsigned char *zName = sqlite3_column_text(pStmt, 1);
228021 const unsigned char *zDflt = sqlite3_column_text(pStmt, 4);
228022
228023 if( zName==0 ) break;
228024 memcpy(pAlloc, zName, nName+1);
228025 azCol[i] = (char *)pAlloc;
228026 pAlloc += nName+1;
228027 if( zDflt ){
228028 memcpy(pAlloc, zDflt, nDflt+1);
228029 azDflt[i] = (char *)pAlloc;
228030 pAlloc += nDflt+1;
228031 }else{
228032 azDflt[i] = 0;
228033 }
228034 abPK[i] = sqlite3_column_int(pStmt, 5);
228035 aiIdx[i] = sqlite3_column_int(pStmt, 0);
228036 i++;
228037 }
228038 if( pnTotalCol ) (*pnTotalCol)++;
228039 }
228040 rc = sqlite3_reset(pStmt);
228041 }
228042
228043 /* If successful, populate the output variables. Otherwise, zero them and
@@ -227563,10 +228046,11 @@
228046 if( rc==SQLITE_OK ){
228047 *pazCol = (const char**)azCol;
228048 if( pazDflt ) *pazDflt = (const char**)azDflt;
228049 *pabPK = abPK;
228050 *pnCol = nDbCol;
228051 if( paiIdx ) *paiIdx = aiIdx;
228052 }else{
228053 sessionFree(pSession, azCol);
228054 }
228055 if( pbRowid ) *pbRowid = bRowid;
228056 sqlite3_finalize(pStmt);
@@ -227594,11 +228078,12 @@
228078
228079 if( pTab->nCol==0 ){
228080 u8 *abPK;
228081 assert( pTab->azCol==0 || pTab->abPK==0 );
228082 rc = sessionTableInfo(pSession, db, zDb,
228083 pTab->zName, &pTab->nCol, &pTab->nTotalCol, 0, &pTab->azCol,
228084 &pTab->azDflt, &pTab->aiIdx, &abPK,
228085 ((pSession==0 || pSession->bImplicitPK) ? &pTab->bRowid : 0)
228086 );
228087 if( rc==SQLITE_OK ){
228088 int i;
228089 for(i=0; i<pTab->nCol; i++){
@@ -227629,19 +228114,21 @@
228114 /*
228115 ** Re-initialize table object pTab.
228116 */
228117 static int sessionReinitTable(sqlite3_session *pSession, SessionTable *pTab){
228118 int nCol = 0;
228119 int nTotalCol = 0;
228120 const char **azCol = 0;
228121 const char **azDflt = 0;
228122 int *aiIdx = 0;
228123 u8 *abPK = 0;
228124 int bRowid = 0;
228125
228126 assert( pSession->rc==SQLITE_OK );
228127
228128 pSession->rc = sessionTableInfo(pSession, pSession->db, pSession->zDb,
228129 pTab->zName, &nCol, &nTotalCol, 0, &azCol, &azDflt, &aiIdx, &abPK,
228130 (pSession->bImplicitPK ? &bRowid : 0)
228131 );
228132 if( pSession->rc==SQLITE_OK ){
228133 if( pTab->nCol>nCol || pTab->bRowid!=bRowid ){
228134 pSession->rc = SQLITE_SCHEMA;
@@ -227660,12 +228147,14 @@
228147
228148 if( pSession->rc==SQLITE_OK ){
228149 const char **a = pTab->azCol;
228150 pTab->azCol = azCol;
228151 pTab->nCol = nCol;
228152 pTab->nTotalCol = nTotalCol;
228153 pTab->azDflt = azDflt;
228154 pTab->abPK = abPK;
228155 pTab->aiIdx = aiIdx;
228156 azCol = a;
228157 }
228158 if( pSession->bEnableSize ){
228159 pSession->nMaxChangesetSize += (nCol - nOldCol);
228160 pSession->nMaxChangesetSize += sessionVarintLen(nCol);
@@ -227979,11 +228468,11 @@
228468 if( pTab->bRowid ) nNew += 9;
228469 if( op!=SQLITE_DELETE ){
228470 int ii;
228471 for(ii=0; ii<pTab->nCol; ii++){
228472 sqlite3_value *p = 0;
228473 pSession->hook.xNew(pSession->hook.pCtx, pTab->aiIdx[ii], &p);
228474 sessionSerializeValue(0, p, &nNew);
228475 }
228476 }
228477 }else if( op==SQLITE_DELETE ){
228478 nNew += pC->nRecord;
@@ -227999,12 +228488,13 @@
228488 }
228489 for(ii=pTab->bRowid; ii<pTab->nCol; ii++){
228490 int bChanged = 1;
228491 int nOld = 0;
228492 int eType;
228493 int iIdx = pTab->aiIdx[ii];
228494 sqlite3_value *p = 0;
228495 pSession->hook.xNew(pSession->hook.pCtx, iIdx, &p);
228496 if( p==0 ){
228497 return SQLITE_NOMEM;
228498 }
228499
228500 eType = *pCsr++;
@@ -228097,15 +228587,15 @@
228587 if( sessionInitTable(pSession, pTab, pSession->db, pSession->zDb) ) return;
228588
228589 /* Check the number of columns in this xPreUpdate call matches the
228590 ** number of columns in the table. */
228591 nExpect = pSession->hook.xCount(pSession->hook.pCtx);
228592 if( pTab->nTotalCol<nExpect ){
228593 if( sessionReinitTable(pSession, pTab) ) return;
228594 if( sessionUpdateChanges(pSession, pTab) ) return;
228595 }
228596 if( pTab->nTotalCol!=nExpect ){
228597 pSession->rc = SQLITE_SCHEMA;
228598 return;
228599 }
228600
228601 /* Grow the hash table if required */
@@ -228158,18 +228648,19 @@
228648 assert( rc==SQLITE_OK );
228649 pTab->nEntry++;
228650
228651 /* Figure out how large an allocation is required */
228652 nByte = sizeof(SessionChange);
228653 for(i=pTab->bRowid; i<pTab->nCol; i++){
228654 int iIdx = pTab->aiIdx[i];
228655 sqlite3_value *p = 0;
228656 if( op!=SQLITE_INSERT ){
228657 /* This may fail if the column has a non-NULL default and was added
228658 ** using ALTER TABLE ADD COLUMN after this record was created. */
228659 rc = pSession->hook.xOld(pSession->hook.pCtx, iIdx, &p);
228660 }else if( pTab->abPK[i] ){
228661 TESTONLY(int trc = ) pSession->hook.xNew(pSession->hook.pCtx,iIdx,&p);
228662 assert( trc==SQLITE_OK );
228663 }
228664
228665 if( rc==SQLITE_OK ){
228666 /* This may fail if SQLite value p contains a utf-16 string that must
@@ -228200,16 +228691,17 @@
228691 if( pTab->bRowid ){
228692 pC->aRecord[0] = SQLITE_INTEGER;
228693 sessionPutI64(&pC->aRecord[1], iRowid);
228694 nByte = 9;
228695 }
228696 for(i=pTab->bRowid; i<pTab->nCol; i++){
228697 sqlite3_value *p = 0;
228698 int iIdx = pTab->aiIdx[i];
228699 if( op!=SQLITE_INSERT ){
228700 pSession->hook.xOld(pSession->hook.pCtx, iIdx, &p);
228701 }else if( pTab->abPK[i] ){
228702 pSession->hook.xNew(pSession->hook.pCtx, iIdx, &p);
228703 }
228704 sessionSerializeValue(&pC->aRecord[nByte], p, &nByte);
228705 }
228706
228707 /* Add the change to the hash-table */
@@ -228607,11 +229099,12 @@
229099 int bMismatch = 0;
229100 int nCol; /* Columns in zFrom.zTbl */
229101 int bRowid = 0;
229102 u8 *abPK;
229103 const char **azCol = 0;
229104 rc = sessionTableInfo(0, db, zFrom, zTbl,
229105 &nCol, 0, 0, &azCol, 0, 0, &abPK,
229106 pSession->bImplicitPK ? &bRowid : 0
229107 );
229108 if( rc==SQLITE_OK ){
229109 if( pTo->nCol!=nCol ){
229110 bMismatch = 1;
@@ -228931,13 +229424,15 @@
229424 int nStr = sqlite3Strlen30(zStr)*2 + 2 + 2;
229425 if( 0==sessionBufferGrow(p, nStr, pRc) ){
229426 char *zOut = (char *)&p->aBuf[p->nBuf];
229427 const char *zIn = zStr;
229428 *zOut++ = '"';
229429 if( zIn!=0 ){
229430 while( *zIn ){
229431 if( *zIn=='"' ) *zOut++ = '"';
229432 *zOut++ = *(zIn++);
229433 }
229434 }
229435 *zOut++ = '"';
229436 p->nBuf = (int)((u8 *)zOut - p->aBuf);
229437 p->aBuf[p->nBuf] = 0x00;
229438 }
@@ -229184,14 +229679,14 @@
229679 sqlite3_stmt **ppStmt /* OUT: Prepared SELECT statement */
229680 ){
229681 int rc = SQLITE_OK;
229682 char *zSql = 0;
229683 const char *zSep = "";
 
229684 int nSql = -1;
229685 int i;
229686
229687 SessionBuffer cols = {0, 0, 0};
229688 SessionBuffer nooptest = {0, 0, 0};
229689 SessionBuffer pkfield = {0, 0, 0};
229690 SessionBuffer pkvar = {0, 0, 0};
229691
229692 sessionAppendStr(&nooptest, ", 1", &rc);
@@ -229200,13 +229695,20 @@
229695 sessionAppendStr(&nooptest, " AND (?6 OR ?3 IS stat)", &rc);
229696 sessionAppendStr(&pkfield, "tbl, idx", &rc);
229697 sessionAppendStr(&pkvar,
229698 "?1, (CASE WHEN ?2=X'' THEN NULL ELSE ?2 END)", &rc
229699 );
229700 sessionAppendStr(&cols, "tbl, ?2, stat", &rc);
229701 }else{
229702 #if 0
229703 if( bRowid ){
229704 sessionAppendStr(&cols, SESSIONS_ROWID, &rc);
229705 }
229706 #endif
229707 for(i=0; i<nCol; i++){
229708 if( cols.nBuf ) sessionAppendStr(&cols, ", ", &rc);
229709 sessionAppendIdent(&cols, azCol[i], &rc);
229710 if( abPK[i] ){
229711 sessionAppendStr(&pkfield, zSep, &rc);
229712 sessionAppendStr(&pkvar, zSep, &rc);
229713 zSep = ", ";
229714 sessionAppendIdent(&pkfield, azCol[i], &rc);
@@ -229220,11 +229722,11 @@
229722 }
229723
229724 if( rc==SQLITE_OK ){
229725 zSql = sqlite3_mprintf(
229726 "SELECT %s%s FROM %Q.%Q WHERE (%s) IS (%s)",
229727 (char*)cols.aBuf, (bIgnoreNoop ? (char*)nooptest.aBuf : ""),
229728 zDb, zTab, (char*)pkfield.aBuf, (char*)pkvar.aBuf
229729 );
229730 if( zSql==0 ) rc = SQLITE_NOMEM;
229731 }
229732
@@ -229263,10 +229765,11 @@
229765 }
229766 sqlite3_free(zSql);
229767 sqlite3_free(nooptest.aBuf);
229768 sqlite3_free(pkfield.aBuf);
229769 sqlite3_free(pkvar.aBuf);
229770 sqlite3_free(cols.aBuf);
229771 return rc;
229772 }
229773
229774 /*
229775 ** Bind the PRIMARY KEY values from the change passed in argument pChange
@@ -231603,11 +232106,12 @@
232106 int nMinCol = 0;
232107 int i;
232108
232109 sqlite3changeset_pk(pIter, &abPK, 0);
232110 rc = sessionTableInfo(0, db, "main", zNew,
232111 &sApply.nCol, 0, &zTab, &sApply.azCol, 0, 0,
232112 &sApply.abPK, &sApply.bRowid
232113 );
232114 if( rc!=SQLITE_OK ) break;
232115 for(i=0; i<sApply.nCol; i++){
232116 if( sApply.abPK[i] ) nMinCol = i+1;
232117 }
@@ -231683,16 +232187,21 @@
232187 if( res!=SQLITE_CHANGESET_OMIT ){
232188 rc = SQLITE_CONSTRAINT;
232189 }
232190 }
232191 }
232192
232193 {
232194 int rc2 = sqlite3_exec(db, "PRAGMA defer_foreign_keys = 0", 0, 0, 0);
232195 if( rc==SQLITE_OK ) rc = rc2;
232196 }
232197
232198 if( (flags & SQLITE_CHANGESETAPPLY_NOSAVEPOINT)==0 ){
232199 if( rc==SQLITE_OK ){
232200 rc = sqlite3_exec(db, "RELEASE changeset_apply", 0, 0, 0);
232201 }
232202 if( rc!=SQLITE_OK ){
232203 sqlite3_exec(db, "ROLLBACK TO changeset_apply", 0, 0, 0);
232204 sqlite3_exec(db, "RELEASE changeset_apply", 0, 0, 0);
232205 }
232206 }
232207
@@ -243195,15 +243704,17 @@
243704 }
243705
243706 /*
243707 ** Close the read-only blob handle, if it is open.
243708 */
243709 static void fts5IndexCloseReader(Fts5Index *p){
243710 if( p->pReader ){
243711 int rc;
243712 sqlite3_blob *pReader = p->pReader;
243713 p->pReader = 0;
243714 rc = sqlite3_blob_close(pReader);
243715 if( p->rc==SQLITE_OK ) p->rc = rc;
243716 }
243717 }
243718
243719 /*
243720 ** Retrieve a record from the %_data table.
@@ -243224,11 +243735,11 @@
243735 p->pReader = 0;
243736 rc = sqlite3_blob_reopen(pBlob, iRowid);
243737 assert( p->pReader==0 );
243738 p->pReader = pBlob;
243739 if( rc!=SQLITE_OK ){
243740 fts5IndexCloseReader(p);
243741 }
243742 if( rc==SQLITE_ABORT ) rc = SQLITE_OK;
243743 }
243744
243745 /* If the blob handle is not open at this point, open it and seek
@@ -243308,13 +243819,17 @@
243819 sqlite3_stmt **ppStmt,
243820 char *zSql
243821 ){
243822 if( p->rc==SQLITE_OK ){
243823 if( zSql ){
243824 int rc = sqlite3_prepare_v3(p->pConfig->db, zSql, -1,
243825 SQLITE_PREPARE_PERSISTENT|SQLITE_PREPARE_NO_VTAB,
243826 ppStmt, 0);
243827 /* If this prepare() call fails with SQLITE_ERROR, then one of the
243828 ** %_idx or %_data tables has been removed or modified. Call this
243829 ** corruption. */
243830 p->rc = (rc==SQLITE_ERROR ? SQLITE_CORRUPT : rc);
243831 }else{
243832 p->rc = SQLITE_NOMEM;
243833 }
243834 }
243835 sqlite3_free(zSql);
@@ -247421,10 +247936,18 @@
247936 static int fts5IndexReturn(Fts5Index *p){
247937 int rc = p->rc;
247938 p->rc = SQLITE_OK;
247939 return rc;
247940 }
247941
247942 /*
247943 ** Close the read-only blob handle, if it is open.
247944 */
247945 static void sqlite3Fts5IndexCloseReader(Fts5Index *p){
247946 fts5IndexCloseReader(p);
247947 fts5IndexReturn(p);
247948 }
247949
247950 typedef struct Fts5FlushCtx Fts5FlushCtx;
247951 struct Fts5FlushCtx {
247952 Fts5Index *pIdx;
247953 Fts5SegWriter writer;
@@ -247609,11 +248132,11 @@
248132 int iIdx = 0;
248133 int iStart = 0;
248134 int iDelKeyOff = 0; /* Offset of deleted key, if any */
248135
248136 nIdx = nPg-iPgIdx;
248137 aIdx = sqlite3Fts5MallocZero(&p->rc, ((i64)nIdx)+16);
248138 if( p->rc ) return;
248139 memcpy(aIdx, &aPg[iPgIdx], nIdx);
248140
248141 /* At this point segment iterator pSeg points to the entry
248142 ** this function should remove from the b-tree segment.
@@ -247879,20 +248402,41 @@
248402
248403 /*
248404 ** This is called as part of flushing a delete to disk in 'secure-delete'
248405 ** mode. It edits the segments within the database described by argument
248406 ** pStruct to remove the entries for term zTerm, rowid iRowid.
248407 **
248408 ** Return SQLITE_OK if successful, or an SQLite error code if an error
248409 ** has occurred. Any error code is also stored in the Fts5Index handle.
248410 */
248411 static int fts5FlushSecureDelete(
248412 Fts5Index *p,
248413 Fts5Structure *pStruct,
248414 const char *zTerm,
248415 int nTerm,
248416 i64 iRowid
248417 ){
248418 const int f = FTS5INDEX_QUERY_SKIPHASH;
248419 Fts5Iter *pIter = 0; /* Used to find term instance */
248420
248421 /* If the version number has not been set to SECUREDELETE, do so now. */
248422 if( p->pConfig->iVersion!=FTS5_CURRENT_VERSION_SECUREDELETE ){
248423 Fts5Config *pConfig = p->pConfig;
248424 sqlite3_stmt *pStmt = 0;
248425 fts5IndexPrepareStmt(p, &pStmt, sqlite3_mprintf(
248426 "REPLACE INTO %Q.'%q_config' VALUES ('version', %d)",
248427 pConfig->zDb, pConfig->zName, FTS5_CURRENT_VERSION_SECUREDELETE
248428 ));
248429 if( p->rc==SQLITE_OK ){
248430 int rc;
248431 sqlite3_step(pStmt);
248432 rc = sqlite3_finalize(pStmt);
248433 if( p->rc==SQLITE_OK ) p->rc = rc;
248434 pConfig->iCookie++;
248435 pConfig->iVersion = FTS5_CURRENT_VERSION_SECUREDELETE;
248436 }
248437 }
248438
248439 fts5MultiIterNew(p, pStruct, f, 0, (const u8*)zTerm, nTerm, -1, 0, &pIter);
248440 if( fts5MultiIterEof(p, pIter)==0 ){
248441 i64 iThis = fts5MultiIterRowid(pIter);
248442 if( iThis<iRowid ){
@@ -247907,10 +248451,11 @@
248451 fts5DoSecureDelete(p, pSeg);
248452 }
248453 }
248454
248455 fts5MultiIterFree(pIter);
248456 return p->rc;
248457 }
248458
248459
248460 /*
248461 ** Flush the contents of in-memory hash table iHash to a new level-0
@@ -247990,22 +248535,24 @@
248535 /* If in secure delete mode, and if this entry in the poslist is
248536 ** in fact a delete, then edit the existing segments directly
248537 ** using fts5FlushSecureDelete(). */
248538 if( bSecureDelete ){
248539 if( eDetail==FTS5_DETAIL_NONE ){
248540 if( iOff<nDoclist && pDoclist[iOff]==0x00
248541 && !fts5FlushSecureDelete(p, pStruct, zTerm, nTerm, iRowid)
248542 ){
248543 iOff++;
248544 if( iOff<nDoclist && pDoclist[iOff]==0x00 ){
248545 iOff++;
248546 nDoclist = 0;
248547 }else{
248548 continue;
248549 }
248550 }
248551 }else if( (pDoclist[iOff] & 0x01)
248552 && !fts5FlushSecureDelete(p, pStruct, zTerm, nTerm, iRowid)
248553 ){
248554 if( p->rc!=SQLITE_OK || pDoclist[iOff]==0x01 ){
248555 iOff++;
248556 continue;
248557 }
248558 }
@@ -248179,11 +248726,11 @@
248726 return pStruct;
248727 }
248728 assert( pStruct->aLevel[i].nMerge<=nThis );
248729 }
248730
248731 nByte += (((i64)pStruct->nLevel)+1) * sizeof(Fts5StructureLevel);
248732 pNew = (Fts5Structure*)sqlite3Fts5MallocZero(&p->rc, nByte);
248733
248734 if( pNew ){
248735 Fts5StructureLevel *pLvl;
248736 nByte = nSeg * sizeof(Fts5StructureSegment);
@@ -249067,18 +249614,21 @@
249614 for(iFree=i; iFree<i+s.nMerge; iFree++){
249615 fts5BufferFree(&s.aBuf[iFree]);
249616 }
249617 }
249618
249619 pData = fts5IdxMalloc(p, sizeof(*pData)
249620 + ((i64)s.doclist.n)+FTS5_DATA_ZERO_PADDING);
249621 assert( pData!=0 || p->rc!=SQLITE_OK );
249622 if( pData ){
249623 pData->p = (u8*)&pData[1];
249624 pData->nn = pData->szLeaf = s.doclist.n;
249625 if( s.doclist.n ) memcpy(pData->p, s.doclist.p, s.doclist.n);
249626 fts5MultiIterNew2(p, pData, bDesc, ppIter);
249627 }
249628
249629 assert( (*ppIter)!=0 || p->rc!=SQLITE_OK );
249630 if( p->rc==SQLITE_OK && s.pTokendata ){
249631 fts5TokendataIterSortMap(p, s2.pT);
249632 (*ppIter)->pTokenDataIter = s2.pT;
249633 s2.pT = 0;
249634 }
@@ -249123,11 +249673,11 @@
249673 ** Commit data to disk.
249674 */
249675 static int sqlite3Fts5IndexSync(Fts5Index *p){
249676 assert( p->rc==SQLITE_OK );
249677 fts5IndexFlush(p);
249678 fts5IndexCloseReader(p);
249679 return fts5IndexReturn(p);
249680 }
249681
249682 /*
249683 ** Discard any data stored in the in-memory hash tables. Do not write it
@@ -249134,15 +249684,14 @@
249684 ** to the database. Additionally, assume that the contents of the %_data
249685 ** table may have changed on disk. So any in-memory caches of %_data
249686 ** records must be invalidated.
249687 */
249688 static int sqlite3Fts5IndexRollback(Fts5Index *p){
249689 fts5IndexCloseReader(p);
249690 fts5IndexDiscardData(p);
249691 fts5StructureInvalidate(p);
249692 return fts5IndexReturn(p);
 
249693 }
249694
249695 /*
249696 ** The %_data table is completely empty when this function is called. This
249697 ** function populates it with the initial structure objects for each index,
@@ -249338,10 +249887,20 @@
249887 */
249888 static void fts5SegIterSetEOF(Fts5SegIter *pSeg){
249889 fts5DataRelease(pSeg->pLeaf);
249890 pSeg->pLeaf = 0;
249891 }
249892
249893 static void fts5IterClose(Fts5IndexIter *pIndexIter){
249894 if( pIndexIter ){
249895 Fts5Iter *pIter = (Fts5Iter*)pIndexIter;
249896 Fts5Index *pIndex = pIter->pIndex;
249897 fts5TokendataIterDelete(pIter->pTokenDataIter);
249898 fts5MultiIterFree(pIter);
249899 fts5IndexCloseReader(pIndex);
249900 }
249901 }
249902
249903 /*
249904 ** This function appends iterator pAppend to Fts5TokenDataIter pIn and
249905 ** returns the result.
249906 */
@@ -249366,11 +249925,11 @@
249925 pNew->nIterAlloc = nAlloc;
249926 }
249927 }
249928 }
249929 if( p->rc ){
249930 fts5IterClose((Fts5IndexIter*)pAppend);
249931 }else{
249932 pRet->apIter[pRet->nIter++] = pAppend;
249933 }
249934 assert( pRet==0 || pRet->nIter<=pRet->nIterAlloc );
249935
@@ -249579,11 +250138,11 @@
250138 fts5BufferAppendBlob(&p->rc, &bSeek, 1, (const u8*)"\0");
250139 }else{
250140 fts5BufferSet(&p->rc, &bSeek, nToken, pToken);
250141 }
250142 if( p->rc ){
250143 fts5IterClose((Fts5IndexIter*)pNew);
250144 break;
250145 }
250146
250147 pNewIter = &pNew->aSeg[0];
250148 pPrevIter = (pPrev ? &pPrev->aSeg[0] : 0);
@@ -249644,11 +250203,11 @@
250203
250204 /* If pSmall is still NULL at this point, then the new iterator does
250205 ** not point to any terms that match the query. So delete it and break
250206 ** out of the loop - all required iterators have been collected. */
250207 if( pSmall==0 ){
250208 fts5IterClose((Fts5IndexIter*)pNew);
250209 break;
250210 }
250211
250212 /* Append this iterator to the set and continue. */
250213 pSet = fts5AppendTokendataIter(p, pSet, pNew);
@@ -249706,10 +250265,11 @@
250265
250266 if( sqlite3Fts5BufferSize(&p->rc, &buf, nToken+1)==0 ){
250267 int iIdx = 0; /* Index to search */
250268 int iPrefixIdx = 0; /* +1 prefix index */
250269 int bTokendata = pConfig->bTokendata;
250270 assert( buf.p!=0 );
250271 if( nToken>0 ) memcpy(&buf.p[1], pToken, nToken);
250272
250273 /* The NOTOKENDATA flag is set when each token in a tokendata=1 table
250274 ** should be treated individually, instead of merging all those with
250275 ** a common prefix into a single entry. This is used, for example, by
@@ -249772,13 +250332,13 @@
250332 }
250333 }
250334 }
250335
250336 if( p->rc ){
250337 fts5IterClose((Fts5IndexIter*)pRet);
250338 pRet = 0;
250339 fts5IndexCloseReader(p);
250340 }
250341
250342 *ppIter = (Fts5IndexIter*)pRet;
250343 sqlite3Fts5BufferFree(&buf);
250344 }
@@ -249867,10 +250427,11 @@
250427 TokendataSetupCtx ctx;
250428
250429 memset(&ctx, 0, sizeof(ctx));
250430
250431 fts5BufferGrow(&p->rc, &token, nToken+1);
250432 assert( token.p!=0 || p->rc!=SQLITE_OK );
250433 ctx.pT = (Fts5TokenDataIter*)sqlite3Fts5MallocZero(&p->rc, sizeof(*ctx.pT));
250434
250435 if( p->rc==SQLITE_OK ){
250436
250437 /* Fill in the token prefix to search for */
@@ -250023,15 +250584,13 @@
250584 /*
250585 ** Close an iterator opened by an earlier call to sqlite3Fts5IndexQuery().
250586 */
250587 static void sqlite3Fts5IterClose(Fts5IndexIter *pIndexIter){
250588 if( pIndexIter ){
250589 Fts5Index *pIndex = ((Fts5Iter*)pIndexIter)->pIndex;
250590 fts5IterClose(pIndexIter);
250591 fts5IndexReturn(pIndex);
 
 
250592 }
250593 }
250594
250595 /*
250596 ** Read and decode the "averages" record from the database.
@@ -250557,11 +251116,11 @@
251116 }
251117 if( rc==SQLITE_OK ){
251118 rc = sqlite3Fts5IterNext(pIter);
251119 }
251120 }
251121 fts5IterClose(pIter);
251122
251123 *pCksum = cksum;
251124 return rc;
251125 }
251126
@@ -251280,11 +251839,11 @@
251839 /* Make a copy of the second argument (a blob) in aBlob[]. The aBlob[]
251840 ** copy is followed by FTS5_DATA_ZERO_PADDING 0x00 bytes, which prevents
251841 ** buffer overreads even if the record is corrupt. */
251842 n = sqlite3_value_bytes(apVal[1]);
251843 aBlob = sqlite3_value_blob(apVal[1]);
251844 nSpace = ((i64)n) + FTS5_DATA_ZERO_PADDING;
251845 a = (u8*)sqlite3Fts5MallocZero(&rc, nSpace);
251846 if( a==0 ) goto decode_out;
251847 if( n>0 ) memcpy(a, aBlob, n);
251848
251849 fts5DecodeRowid(iRowid, &bTomb, &iSegid, &bDlidx, &iHeight, &iPgno);
@@ -253726,11 +254285,10 @@
254285 ){
254286 Fts5FullTable *pTab = (Fts5FullTable*)pVtab;
254287 Fts5Config *pConfig = pTab->p.pConfig;
254288 int eType0; /* value_type() of apVal[0] */
254289 int rc = SQLITE_OK; /* Return code */
 
254290
254291 /* A transaction must be open when this is called. */
254292 assert( pTab->ts.eState==1 || pTab->ts.eState==2 );
254293
254294 assert( pVtab->zErrMsg==0 );
@@ -253738,11 +254296,11 @@
254296 assert( sqlite3_value_type(apVal[0])==SQLITE_INTEGER
254297 || sqlite3_value_type(apVal[0])==SQLITE_NULL
254298 );
254299 assert( pTab->p.pConfig->pzErrmsg==0 );
254300 if( pConfig->pgsz==0 ){
254301 rc = sqlite3Fts5ConfigLoad(pTab->p.pConfig, pTab->p.pConfig->iCookie);
254302 if( rc!=SQLITE_OK ) return rc;
254303 }
254304
254305 pTab->p.pConfig->pzErrmsg = &pTab->p.base.zErrMsg;
254306
@@ -253763,11 +254321,10 @@
254321 "'delete' may not be used with a contentless_delete=1 table"
254322 );
254323 rc = SQLITE_ERROR;
254324 }else{
254325 rc = fts5SpecialDelete(pTab, apVal);
 
254326 }
254327 }else{
254328 rc = fts5SpecialInsert(pTab, z, apVal[2 + pConfig->nCol + 1]);
254329 }
254330 }else{
@@ -253800,11 +254357,10 @@
254357 );
254358 rc = SQLITE_ERROR;
254359 }else{
254360 i64 iDel = sqlite3_value_int64(apVal[0]); /* Rowid to delete */
254361 rc = sqlite3Fts5StorageDelete(pTab->pStorage, iDel, 0, 0);
 
254362 }
254363 }
254364
254365 /* INSERT or UPDATE */
254366 else{
@@ -253828,11 +254384,10 @@
254384 /* An INSERT statement. If the conflict-mode is REPLACE, first remove
254385 ** the current entry (if any). */
254386 if( eConflict==SQLITE_REPLACE && eType1==SQLITE_INTEGER ){
254387 i64 iNew = sqlite3_value_int64(apVal[1]); /* Rowid to delete */
254388 rc = sqlite3Fts5StorageDelete(pTab->pStorage, iNew, 0, 0);
 
254389 }
254390 fts5StorageInsert(&rc, pTab, apVal, pRowid);
254391 }
254392
254393 /* UPDATE */
@@ -253882,27 +254437,12 @@
254437 }
254438 }else{
254439 rc = sqlite3Fts5StorageDelete(pStorage, iOld, 0, 1);
254440 fts5StorageInsert(&rc, pTab, apVal, pRowid);
254441 }
 
254442 sqlite3Fts5StorageReleaseDeleteRow(pStorage);
254443 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
254444 }
254445 }
254446
254447 update_out:
254448 pTab->p.pConfig->pzErrmsg = 0;
@@ -253951,10 +254491,11 @@
254491 static int fts5RollbackMethod(sqlite3_vtab *pVtab){
254492 int rc;
254493 Fts5FullTable *pTab = (Fts5FullTable*)pVtab;
254494 fts5CheckTransactionState(pTab, FTS5_ROLLBACK, 0);
254495 rc = sqlite3Fts5StorageRollback(pTab->pStorage);
254496 pTab->p.pConfig->pgsz = 0;
254497 return rc;
254498 }
254499
254500 static int fts5CsrPoslist(Fts5Cursor*, int, const u8**, int*);
254501
@@ -255419,11 +255960,11 @@
255960 int nArg, /* Number of args */
255961 sqlite3_value **apUnused /* Function arguments */
255962 ){
255963 assert( nArg==0 );
255964 UNUSED_PARAM2(nArg, apUnused);
255965 sqlite3_result_text(pCtx, "fts5: 2025-02-18 01:16:26 57caa3136d1bfca06e4f2285734a4977b8d3fa1f75bf87453b975867e9de38fc", -1, SQLITE_TRANSIENT);
255966 }
255967
255968 /*
255969 ** Implementation of fts5_locale(LOCALE, TEXT) function.
255970 **
@@ -255899,10 +256440,15 @@
256440 rc = sqlite3_prepare_v3(pC->db, zSql, -1, f, &p->aStmt[eStmt], 0);
256441 p->pConfig->bLock--;
256442 sqlite3_free(zSql);
256443 if( rc!=SQLITE_OK && pzErrMsg ){
256444 *pzErrMsg = sqlite3_mprintf("%s", sqlite3_errmsg(pC->db));
256445 }
256446 if( rc==SQLITE_ERROR && eStmt>FTS5_STMT_LOOKUP2 && eStmt<FTS5_STMT_SCAN ){
256447 /* One of the internal tables - not the %_content table - is missing.
256448 ** This counts as a corrupted table. */
256449 rc = SQLITE_CORRUPT;
256450 }
256451 }
256452 }
256453
256454 *ppStmt = p->aStmt[eStmt];
@@ -260019,16 +260565,16 @@
260565
260566 if( argc!=5 && bDb==0 ){
260567 *pzErr = sqlite3_mprintf("wrong number of vtable arguments");
260568 rc = SQLITE_ERROR;
260569 }else{
260570 i64 nByte; /* Bytes of space to allocate */
260571 const char *zDb = bDb ? argv[3] : argv[1];
260572 const char *zTab = bDb ? argv[4] : argv[3];
260573 const char *zType = bDb ? argv[5] : argv[4];
260574 i64 nDb = strlen(zDb)+1;
260575 i64 nTab = strlen(zTab)+1;
260576 int eType = 0;
260577
260578 rc = fts5VocabTableType(zType, pzErr, &eType);
260579 if( rc==SQLITE_OK ){
260580 assert( eType>=0 && eType<ArraySize(azSchema) );
260581
+165 -61
--- extsrc/sqlite3.h
+++ extsrc/sqlite3.h
@@ -144,13 +144,13 @@
144144
**
145145
** See also: [sqlite3_libversion()],
146146
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147147
** [sqlite_version()] and [sqlite_source_id()].
148148
*/
149
-#define SQLITE_VERSION "3.48.0"
150
-#define SQLITE_VERSION_NUMBER 3048000
151
-#define SQLITE_SOURCE_ID "2024-12-09 20:46:36 e2bae4143afd07de1ae55a6d2606a3b541a5b94568aa41f6a96e5d1245471653"
149
+#define SQLITE_VERSION "3.50.0"
150
+#define SQLITE_VERSION_NUMBER 3050000
151
+#define SQLITE_SOURCE_ID "2025-02-18 01:16:26 57caa3136d1bfca06e4f2285734a4977b8d3fa1f75bf87453b975867e9de38fc"
152152
153153
/*
154154
** CAPI3REF: Run-Time Library Version Numbers
155155
** KEYWORDS: sqlite3_version sqlite3_sourceid
156156
**
@@ -1987,17 +1987,20 @@
19871987
** [sqlite3_config()] with the SQLITE_CONFIG_GETMUTEX configuration option will
19881988
** return [SQLITE_ERROR].</dd>
19891989
**
19901990
** [[SQLITE_CONFIG_LOOKASIDE]] <dt>SQLITE_CONFIG_LOOKASIDE</dt>
19911991
** <dd> ^(The SQLITE_CONFIG_LOOKASIDE option takes two arguments that determine
1992
-** the default size of lookaside memory on each [database connection].
1992
+** the default size of [lookaside memory] on each [database connection].
19931993
** The first argument is the
1994
-** size of each lookaside buffer slot and the second is the number of
1995
-** slots allocated to each database connection.)^ ^(SQLITE_CONFIG_LOOKASIDE
1996
-** sets the <i>default</i> lookaside size. The [SQLITE_DBCONFIG_LOOKASIDE]
1997
-** option to [sqlite3_db_config()] can be used to change the lookaside
1998
-** configuration on individual connections.)^ </dd>
1994
+** size of each lookaside buffer slot ("sz") and the second is the number of
1995
+** slots allocated to each database connection ("cnt").)^
1996
+** ^(SQLITE_CONFIG_LOOKASIDE sets the <i>default</i> lookaside size.
1997
+** The [SQLITE_DBCONFIG_LOOKASIDE] option to [sqlite3_db_config()] can
1998
+** be used to change the lookaside configuration on individual connections.)^
1999
+** The [-DSQLITE_DEFAULT_LOOKASIDE] option can be used to change the
2000
+** default lookaside configuration at compile-time.
2001
+** </dd>
19992002
**
20002003
** [[SQLITE_CONFIG_PCACHE2]] <dt>SQLITE_CONFIG_PCACHE2</dt>
20012004
** <dd> ^(The SQLITE_CONFIG_PCACHE2 option takes a single argument which is
20022005
** a pointer to an [sqlite3_pcache_methods2] object. This object specifies
20032006
** the interface to a custom page cache implementation.)^
@@ -2209,11 +2212,19 @@
22092212
22102213
/*
22112214
** CAPI3REF: Database Connection Configuration Options
22122215
**
22132216
** These constants are the available integer configuration options that
2214
-** can be passed as the second argument to the [sqlite3_db_config()] interface.
2217
+** can be passed as the second parameter to the [sqlite3_db_config()] interface.
2218
+**
2219
+** The [sqlite3_db_config()] interface is a var-args functions. It takes a
2220
+** variable number of parameters, though always at least two. The number of
2221
+** parameters passed into sqlite3_db_config() depends on which of these
2222
+** constants is given as the second parameter. This documentation page
2223
+** refers to parameters beyond the second as "arguments". Thus, when this
2224
+** page says "the N-th argument" it means "the N-th parameter past the
2225
+** configuration option" or "the (N+2)-th parameter to sqlite3_db_config()".
22152226
**
22162227
** New configuration options may be added in future releases of SQLite.
22172228
** Existing configuration options might be discontinued. Applications
22182229
** should check the return code from [sqlite3_db_config()] to make sure that
22192230
** the call worked. ^The [sqlite3_db_config()] interface will return a
@@ -2221,35 +2232,61 @@
22212232
** is invoked.
22222233
**
22232234
** <dl>
22242235
** [[SQLITE_DBCONFIG_LOOKASIDE]]
22252236
** <dt>SQLITE_DBCONFIG_LOOKASIDE</dt>
2226
-** <dd> ^This option takes three additional arguments that determine the
2227
-** [lookaside memory allocator] configuration for the [database connection].
2228
-** ^The first argument (the third parameter to [sqlite3_db_config()] is a
2237
+** <dd> The SQLITE_DBCONFIG_LOOKASIDE option is used to adjust the
2238
+** configuration of the [lookaside memory allocator] within a database
2239
+** connection.
2240
+** The arguments to the SQLITE_DBCONFIG_LOOKASIDE option are <i>not</i>
2241
+** in the [DBCONFIG arguments|usual format].
2242
+** The SQLITE_DBCONFIG_LOOKASIDE option takes three arguments, not two,
2243
+** so that a call to [sqlite3_db_config()] that uses SQLITE_DBCONFIG_LOOKASIDE
2244
+** should have a total of five parameters.
2245
+** <ol>
2246
+** <li><p>The first argument ("buf") is a
22292247
** pointer to a memory buffer to use for lookaside memory.
2230
-** ^The first argument after the SQLITE_DBCONFIG_LOOKASIDE verb
2231
-** may be NULL in which case SQLite will allocate the
2232
-** lookaside buffer itself using [sqlite3_malloc()]. ^The second argument is the
2233
-** size of each lookaside buffer slot. ^The third argument is the number of
2234
-** slots. The size of the buffer in the first argument must be greater than
2235
-** or equal to the product of the second and third arguments. The buffer
2236
-** must be aligned to an 8-byte boundary. ^If the second argument to
2237
-** SQLITE_DBCONFIG_LOOKASIDE is not a multiple of 8, it is internally
2238
-** rounded down to the next smaller multiple of 8. ^(The lookaside memory
2248
+** The first argument may be NULL in which case SQLite will allocate the
2249
+** lookaside buffer itself using [sqlite3_malloc()].
2250
+** <li><P>The second argument ("sz") is the
2251
+** size of each lookaside buffer slot. Lookaside is disabled if "sz"
2252
+** is less than 8. The "sz" argument should be a multiple of 8 less than
2253
+** 65536. If "sz" does not meet this constraint, it is reduced in size until
2254
+** it does.
2255
+** <li><p>The third argument ("cnt") is the number of slots. Lookaside is disabled
2256
+** if "cnt"is less than 1. The "cnt" value will be reduced, if necessary, so
2257
+** that the product of "sz" and "cnt" does not exceed 2,147,418,112. The "cnt"
2258
+** parameter is usually chosen so that the product of "sz" and "cnt" is less
2259
+** than 1,000,000.
2260
+** </ol>
2261
+** <p>If the "buf" argument is not NULL, then it must
2262
+** point to a memory buffer with a size that is greater than
2263
+** or equal to the product of "sz" and "cnt".
2264
+** The buffer must be aligned to an 8-byte boundary.
2265
+** The lookaside memory
22392266
** configuration for a database connection can only be changed when that
22402267
** connection is not currently using lookaside memory, or in other words
2241
-** when the "current value" returned by
2242
-** [sqlite3_db_status](D,[SQLITE_DBSTATUS_LOOKASIDE_USED],...) is zero.
2268
+** when the value returned by [SQLITE_DBSTATUS_LOOKASIDE_USED] is zero.
22432269
** Any attempt to change the lookaside memory configuration when lookaside
22442270
** memory is in use leaves the configuration unchanged and returns
2245
-** [SQLITE_BUSY].)^</dd>
2271
+** [SQLITE_BUSY].
2272
+** If the "buf" argument is NULL and an attempt
2273
+** to allocate memory based on "sz" and "cnt" fails, then
2274
+** lookaside is silently disabled.
2275
+** <p>
2276
+** The [SQLITE_CONFIG_LOOKASIDE] configuration option can be used to set the
2277
+** default lookaside configuration at initialization. The
2278
+** [-DSQLITE_DEFAULT_LOOKASIDE] option can be used to set the default lookaside
2279
+** configuration at compile-time. Typical values for lookaside are 1200 for
2280
+** "sz" and 40 to 100 for "cnt".
2281
+** </dd>
22462282
**
22472283
** [[SQLITE_DBCONFIG_ENABLE_FKEY]]
22482284
** <dt>SQLITE_DBCONFIG_ENABLE_FKEY</dt>
22492285
** <dd> ^This option is used to enable or disable the enforcement of
2250
-** [foreign key constraints]. There should be two additional arguments.
2286
+** [foreign key constraints]. This is the same setting that is
2287
+** enabled or disabled by the [PRAGMA foreign_keys] statement.
22512288
** The first argument is an integer which is 0 to disable FK enforcement,
22522289
** positive to enable FK enforcement or negative to leave FK enforcement
22532290
** unchanged. The second parameter is a pointer to an integer into which
22542291
** is written 0 or 1 to indicate whether FK enforcement is off or on
22552292
** following this call. The second parameter may be a NULL pointer, in
@@ -2267,17 +2304,17 @@
22672304
** which case the trigger setting is not reported back.
22682305
**
22692306
** <p>Originally this option disabled all triggers. ^(However, since
22702307
** SQLite version 3.35.0, TEMP triggers are still allowed even if
22712308
** this option is off. So, in other words, this option now only disables
2272
-** triggers in the main database schema or in the schemas of ATTACH-ed
2309
+** triggers in the main database schema or in the schemas of [ATTACH]-ed
22732310
** databases.)^ </dd>
22742311
**
22752312
** [[SQLITE_DBCONFIG_ENABLE_VIEW]]
22762313
** <dt>SQLITE_DBCONFIG_ENABLE_VIEW</dt>
22772314
** <dd> ^This option is used to enable or disable [CREATE VIEW | views].
2278
-** There should be two additional arguments.
2315
+** There must be two additional arguments.
22792316
** The first argument is an integer which is 0 to disable views,
22802317
** positive to enable views or negative to leave the setting unchanged.
22812318
** The second parameter is a pointer to an integer into which
22822319
** is written 0 or 1 to indicate whether views are disabled or enabled
22832320
** following this call. The second parameter may be a NULL pointer, in
@@ -2292,11 +2329,11 @@
22922329
** [[SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER]]
22932330
** <dt>SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER</dt>
22942331
** <dd> ^This option is used to enable or disable the
22952332
** [fts3_tokenizer()] function which is part of the
22962333
** [FTS3] full-text search engine extension.
2297
-** There should be two additional arguments.
2334
+** There must be two additional arguments.
22982335
** The first argument is an integer which is 0 to disable fts3_tokenizer() or
22992336
** positive to enable fts3_tokenizer() or negative to leave the setting
23002337
** unchanged.
23012338
** The second parameter is a pointer to an integer into which
23022339
** is written 0 or 1 to indicate whether fts3_tokenizer is disabled or enabled
@@ -2307,11 +2344,11 @@
23072344
** <dt>SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION</dt>
23082345
** <dd> ^This option is used to enable or disable the [sqlite3_load_extension()]
23092346
** interface independently of the [load_extension()] SQL function.
23102347
** The [sqlite3_enable_load_extension()] API enables or disables both the
23112348
** C-API [sqlite3_load_extension()] and the SQL function [load_extension()].
2312
-** There should be two additional arguments.
2349
+** There must be two additional arguments.
23132350
** When the first argument to this interface is 1, then only the C-API is
23142351
** enabled and the SQL function remains disabled. If the first argument to
23152352
** this interface is 0, then both the C-API and the SQL function are disabled.
23162353
** If the first argument is -1, then no changes are made to state of either the
23172354
** C-API or the SQL function.
@@ -2321,27 +2358,34 @@
23212358
** be a NULL pointer, in which case the new setting is not reported back.
23222359
** </dd>
23232360
**
23242361
** [[SQLITE_DBCONFIG_MAINDBNAME]] <dt>SQLITE_DBCONFIG_MAINDBNAME</dt>
23252362
** <dd> ^This option is used to change the name of the "main" database
2326
-** schema. ^The sole argument is a pointer to a constant UTF8 string
2327
-** which will become the new schema name in place of "main". ^SQLite
2328
-** does not make a copy of the new main schema name string, so the application
2329
-** must ensure that the argument passed into this DBCONFIG option is unchanged
2330
-** until after the database connection closes.
2363
+** schema. This option does not follow the
2364
+** [DBCONFIG arguments|usual SQLITE_DBCONFIG argument format].
2365
+** This option takes exactly one additional argument so that the
2366
+** [sqlite3_db_config()] call has a total of three parameters. The
2367
+** extra argument must be a pointer to a constant UTF8 string which
2368
+** will become the new schema name in place of "main". ^SQLite does
2369
+** not make a copy of the new main schema name string, so the application
2370
+** must ensure that the argument passed into SQLITE_DBCONFIG MAINDBNAME
2371
+** is unchanged until after the database connection closes.
23312372
** </dd>
23322373
**
23332374
** [[SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE]]
23342375
** <dt>SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE</dt>
2335
-** <dd> Usually, when a database in wal mode is closed or detached from a
2336
-** database handle, SQLite checks if this will mean that there are now no
2337
-** connections at all to the database. If so, it performs a checkpoint
2338
-** operation before closing the connection. This option may be used to
2339
-** override this behavior. The first parameter passed to this operation
2340
-** is an integer - positive to disable checkpoints-on-close, or zero (the
2341
-** default) to enable them, and negative to leave the setting unchanged.
2342
-** The second parameter is a pointer to an integer
2376
+** <dd> Usually, when a database in [WAL mode] is closed or detached from a
2377
+** database handle, SQLite checks if if there are other connections to the
2378
+** same database, and if there are no other database connection (if the
2379
+** connection being closed is the last open connection to the database),
2380
+** then SQLite performs a [checkpoint] before closing the connection and
2381
+** deletes the WAL file. The SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE option can
2382
+** be used to override that behavior. The first argument passed to this
2383
+** operation (the third parameter to [sqlite3_db_config()]) is an integer
2384
+** which is positive to disable checkpoints-on-close, or zero (the default)
2385
+** to enable them, and negative to leave the setting unchanged.
2386
+** The second argument (the fourth parameter) is a pointer to an integer
23432387
** into which is written 0 or 1 to indicate whether checkpoints-on-close
23442388
** have been disabled - 0 if they are not disabled, 1 if they are.
23452389
** </dd>
23462390
**
23472391
** [[SQLITE_DBCONFIG_ENABLE_QPSG]] <dt>SQLITE_DBCONFIG_ENABLE_QPSG</dt>
@@ -2498,11 +2542,11 @@
24982542
** SQLITE_ENABLE_STMT_SCANSTATUS builds. In this case, it sets or clears
24992543
** a flag that enables collection of the sqlite3_stmt_scanstatus_v2()
25002544
** statistics. For statistics to be collected, the flag must be set on
25012545
** the database handle both when the SQL statement is prepared and when it
25022546
** is stepped. The flag is set (collection of statistics is enabled)
2503
-** by default. This option takes two arguments: an integer and a pointer to
2547
+** by default. <p>This option takes two arguments: an integer and a pointer to
25042548
** an integer.. The first argument is 1, 0, or -1 to enable, disable, or
25052549
** leave unchanged the statement scanstatus option. If the second argument
25062550
** is not NULL, then the value of the statement scanstatus setting after
25072551
** processing the first argument is written into the integer that the second
25082552
** argument points to.
@@ -2512,20 +2556,89 @@
25122556
** <dt>SQLITE_DBCONFIG_REVERSE_SCANORDER</dt>
25132557
** <dd>The SQLITE_DBCONFIG_REVERSE_SCANORDER option changes the default order
25142558
** in which tables and indexes are scanned so that the scans start at the end
25152559
** and work toward the beginning rather than starting at the beginning and
25162560
** working toward the end. Setting SQLITE_DBCONFIG_REVERSE_SCANORDER is the
2517
-** same as setting [PRAGMA reverse_unordered_selects]. This option takes
2561
+** same as setting [PRAGMA reverse_unordered_selects]. <p>This option takes
25182562
** two arguments which are an integer and a pointer to an integer. The first
25192563
** argument is 1, 0, or -1 to enable, disable, or leave unchanged the
25202564
** reverse scan order flag, respectively. If the second argument is not NULL,
25212565
** then 0 or 1 is written into the integer that the second argument points to
25222566
** depending on if the reverse scan order flag is set after processing the
25232567
** first argument.
25242568
** </dd>
25252569
**
2570
+** [[SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE]]
2571
+** <dt>SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE</dt>
2572
+** <dd>The SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE option enables or disables
2573
+** the ability of the [ATTACH DATABASE] SQL command to create a new database
2574
+** file if the database filed named in the ATTACH command does not already
2575
+** exist. This ability of ATTACH to create a new database is enabled by
2576
+** default. Applications can disable or reenable the ability for ATTACH to
2577
+** create new database files using this DBCONFIG option.<p>
2578
+** This option takes two arguments which are an integer and a pointer
2579
+** to an integer. The first argument is 1, 0, or -1 to enable, disable, or
2580
+** leave unchanged the attach-create flag, respectively. If the second
2581
+** argument is not NULL, then 0 or 1 is written into the integer that the
2582
+** second argument points to depending on if the attach-create flag is set
2583
+** after processing the first argument.
2584
+** </dd>
2585
+**
2586
+** [[SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE]]
2587
+** <dt>SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE</dt>
2588
+** <dd>The SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE option enables or disables the
2589
+** ability of the [ATTACH DATABASE] SQL command to open a database for writing.
2590
+** This capability is enabled by default. Applications can disable or
2591
+** reenable this capability using the current DBCONFIG option. If the
2592
+** the this capability is disabled, the [ATTACH] command will still work,
2593
+** but the database will be opened read-only. If this option is disabled,
2594
+** then the ability to create a new database using [ATTACH] is also disabled,
2595
+** regardless of the value of the [SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE]
2596
+** option.<p>
2597
+** This option takes two arguments which are an integer and a pointer
2598
+** to an integer. The first argument is 1, 0, or -1 to enable, disable, or
2599
+** leave unchanged the ability to ATTACH another database for writing,
2600
+** respectively. If the second argument is not NULL, then 0 or 1 is written
2601
+** into the integer to which the second argument points, depending on whether
2602
+** the ability to ATTACH a read/write database is enabled or disabled
2603
+** after processing the first argument.
2604
+** </dd>
2605
+**
2606
+** [[SQLITE_DBCONFIG_ENABLE_COMMENTS]]
2607
+** <dt>SQLITE_DBCONFIG_ENABLE_COMMENTS</dt>
2608
+** <dd>The SQLITE_DBCONFIG_ENABLE_COMMENTS option enables or disables the
2609
+** ability to include comments in SQL text. Comments are enabled by default.
2610
+** An application can disable or reenable comments in SQL text using this
2611
+** DBCONFIG option.<p>
2612
+** This option takes two arguments which are an integer and a pointer
2613
+** to an integer. The first argument is 1, 0, or -1 to enable, disable, or
2614
+** leave unchanged the ability to use comments in SQL text,
2615
+** respectively. If the second argument is not NULL, then 0 or 1 is written
2616
+** into the integer that the second argument points to depending on if
2617
+** comments are allowed in SQL text after processing the first argument.
2618
+** </dd>
2619
+**
25262620
** </dl>
2621
+**
2622
+** [[DBCONFIG arguments]] <h3>Arguments To SQLITE_DBCONFIG Options</h3>
2623
+**
2624
+** <p>Most of the SQLITE_DBCONFIG options take two arguments, so that the
2625
+** overall call to [sqlite3_db_config()] has a total of four parameters.
2626
+** The first argument (the third parameter to sqlite3_db_config()) is a integer.
2627
+** The second argument is a pointer to an integer. If the first argument is 1,
2628
+** then the option becomes enabled. If the first integer argument is 0, then the
2629
+** option is disabled. If the first argument is -1, then the option setting
2630
+** is unchanged. The second argument, the pointer to an integer, may be NULL.
2631
+** If the second argument is not NULL, then a value of 0 or 1 is written into
2632
+** the integer to which the second argument points, depending on whether the
2633
+** setting is disabled or enabled after applying any changes specified by
2634
+** the first argument.
2635
+**
2636
+** <p>While most SQLITE_DBCONFIG options use the argument format
2637
+** described in the previous paragraph, the [SQLITE_DBCONFIG_MAINDBNAME]
2638
+** and [SQLITE_DBCONFIG_LOOKASIDE] options are different. See the
2639
+** documentation of those exceptional options for details.
25272640
*/
25282641
#define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */
25292642
#define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */
25302643
#define SQLITE_DBCONFIG_ENABLE_FKEY 1002 /* int int* */
25312644
#define SQLITE_DBCONFIG_ENABLE_TRIGGER 1003 /* int int* */
@@ -2543,11 +2656,14 @@
25432656
#define SQLITE_DBCONFIG_ENABLE_VIEW 1015 /* int int* */
25442657
#define SQLITE_DBCONFIG_LEGACY_FILE_FORMAT 1016 /* int int* */
25452658
#define SQLITE_DBCONFIG_TRUSTED_SCHEMA 1017 /* int int* */
25462659
#define SQLITE_DBCONFIG_STMT_SCANSTATUS 1018 /* int int* */
25472660
#define SQLITE_DBCONFIG_REVERSE_SCANORDER 1019 /* int int* */
2548
-#define SQLITE_DBCONFIG_MAX 1019 /* Largest DBCONFIG */
2661
+#define SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE 1020 /* int int* */
2662
+#define SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE 1021 /* int int* */
2663
+#define SQLITE_DBCONFIG_ENABLE_COMMENTS 1022 /* int int* */
2664
+#define SQLITE_DBCONFIG_MAX 1022 /* Largest DBCONFIG */
25492665
25502666
/*
25512667
** CAPI3REF: Enable Or Disable Extended Result Codes
25522668
** METHOD: sqlite3
25532669
**
@@ -10746,12 +10862,13 @@
1074610862
SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_recover(sqlite3 *db, const char *zDb);
1074710863
1074810864
/*
1074910865
** CAPI3REF: Serialize a database
1075010866
**
10751
-** The sqlite3_serialize(D,S,P,F) interface returns a pointer to memory
10752
-** that is a serialization of the S database on [database connection] D.
10867
+** The sqlite3_serialize(D,S,P,F) interface returns a pointer to
10868
+** memory that is a serialization of the S database on
10869
+** [database connection] D. If S is a NULL pointer, the main database is used.
1075310870
** If P is not a NULL pointer, then the size of the database in bytes
1075410871
** is written into *P.
1075510872
**
1075610873
** For an ordinary on-disk database file, the serialization is just a
1075710874
** copy of the disk file. For an in-memory database or a "TEMP" database,
@@ -11913,23 +12030,10 @@
1191312030
int nB, /* Number of bytes in buffer pB */
1191412031
void *pB, /* Pointer to buffer containing changeset B */
1191512032
int *pnOut, /* OUT: Number of bytes in output changeset */
1191612033
void **ppOut /* OUT: Buffer containing output changeset */
1191712034
);
11918
-
11919
-
11920
-/*
11921
-** CAPI3REF: Upgrade the Schema of a Changeset/Patchset
11922
-*/
11923
-SQLITE_API int sqlite3changeset_upgrade(
11924
- sqlite3 *db,
11925
- const char *zDb,
11926
- int nIn, const void *pIn, /* Input changeset */
11927
- int *pnOut, void **ppOut /* OUT: Inverse of input */
11928
-);
11929
-
11930
-
1193112035
1193212036
/*
1193312037
** CAPI3REF: Changegroup Handle
1193412038
**
1193512039
** A changegroup is an object used to combine two or more
1193612040
--- extsrc/sqlite3.h
+++ extsrc/sqlite3.h
@@ -144,13 +144,13 @@
144 **
145 ** See also: [sqlite3_libversion()],
146 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147 ** [sqlite_version()] and [sqlite_source_id()].
148 */
149 #define SQLITE_VERSION "3.48.0"
150 #define SQLITE_VERSION_NUMBER 3048000
151 #define SQLITE_SOURCE_ID "2024-12-09 20:46:36 e2bae4143afd07de1ae55a6d2606a3b541a5b94568aa41f6a96e5d1245471653"
152
153 /*
154 ** CAPI3REF: Run-Time Library Version Numbers
155 ** KEYWORDS: sqlite3_version sqlite3_sourceid
156 **
@@ -1987,17 +1987,20 @@
1987 ** [sqlite3_config()] with the SQLITE_CONFIG_GETMUTEX configuration option will
1988 ** return [SQLITE_ERROR].</dd>
1989 **
1990 ** [[SQLITE_CONFIG_LOOKASIDE]] <dt>SQLITE_CONFIG_LOOKASIDE</dt>
1991 ** <dd> ^(The SQLITE_CONFIG_LOOKASIDE option takes two arguments that determine
1992 ** the default size of lookaside memory on each [database connection].
1993 ** The first argument is the
1994 ** size of each lookaside buffer slot and the second is the number of
1995 ** slots allocated to each database connection.)^ ^(SQLITE_CONFIG_LOOKASIDE
1996 ** sets the <i>default</i> lookaside size. The [SQLITE_DBCONFIG_LOOKASIDE]
1997 ** option to [sqlite3_db_config()] can be used to change the lookaside
1998 ** configuration on individual connections.)^ </dd>
 
 
 
1999 **
2000 ** [[SQLITE_CONFIG_PCACHE2]] <dt>SQLITE_CONFIG_PCACHE2</dt>
2001 ** <dd> ^(The SQLITE_CONFIG_PCACHE2 option takes a single argument which is
2002 ** a pointer to an [sqlite3_pcache_methods2] object. This object specifies
2003 ** the interface to a custom page cache implementation.)^
@@ -2209,11 +2212,19 @@
2209
2210 /*
2211 ** CAPI3REF: Database Connection Configuration Options
2212 **
2213 ** These constants are the available integer configuration options that
2214 ** can be passed as the second argument to the [sqlite3_db_config()] interface.
 
 
 
 
 
 
 
 
2215 **
2216 ** New configuration options may be added in future releases of SQLite.
2217 ** Existing configuration options might be discontinued. Applications
2218 ** should check the return code from [sqlite3_db_config()] to make sure that
2219 ** the call worked. ^The [sqlite3_db_config()] interface will return a
@@ -2221,35 +2232,61 @@
2221 ** is invoked.
2222 **
2223 ** <dl>
2224 ** [[SQLITE_DBCONFIG_LOOKASIDE]]
2225 ** <dt>SQLITE_DBCONFIG_LOOKASIDE</dt>
2226 ** <dd> ^This option takes three additional arguments that determine the
2227 ** [lookaside memory allocator] configuration for the [database connection].
2228 ** ^The first argument (the third parameter to [sqlite3_db_config()] is a
 
 
 
 
 
 
 
2229 ** pointer to a memory buffer to use for lookaside memory.
2230 ** ^The first argument after the SQLITE_DBCONFIG_LOOKASIDE verb
2231 ** may be NULL in which case SQLite will allocate the
2232 ** lookaside buffer itself using [sqlite3_malloc()]. ^The second argument is the
2233 ** size of each lookaside buffer slot. ^The third argument is the number of
2234 ** slots. The size of the buffer in the first argument must be greater than
2235 ** or equal to the product of the second and third arguments. The buffer
2236 ** must be aligned to an 8-byte boundary. ^If the second argument to
2237 ** SQLITE_DBCONFIG_LOOKASIDE is not a multiple of 8, it is internally
2238 ** rounded down to the next smaller multiple of 8. ^(The lookaside memory
 
 
 
 
 
 
 
 
 
2239 ** configuration for a database connection can only be changed when that
2240 ** connection is not currently using lookaside memory, or in other words
2241 ** when the "current value" returned by
2242 ** [sqlite3_db_status](D,[SQLITE_DBSTATUS_LOOKASIDE_USED],...) is zero.
2243 ** Any attempt to change the lookaside memory configuration when lookaside
2244 ** memory is in use leaves the configuration unchanged and returns
2245 ** [SQLITE_BUSY].)^</dd>
 
 
 
 
 
 
 
 
 
 
2246 **
2247 ** [[SQLITE_DBCONFIG_ENABLE_FKEY]]
2248 ** <dt>SQLITE_DBCONFIG_ENABLE_FKEY</dt>
2249 ** <dd> ^This option is used to enable or disable the enforcement of
2250 ** [foreign key constraints]. There should be two additional arguments.
 
2251 ** The first argument is an integer which is 0 to disable FK enforcement,
2252 ** positive to enable FK enforcement or negative to leave FK enforcement
2253 ** unchanged. The second parameter is a pointer to an integer into which
2254 ** is written 0 or 1 to indicate whether FK enforcement is off or on
2255 ** following this call. The second parameter may be a NULL pointer, in
@@ -2267,17 +2304,17 @@
2267 ** which case the trigger setting is not reported back.
2268 **
2269 ** <p>Originally this option disabled all triggers. ^(However, since
2270 ** SQLite version 3.35.0, TEMP triggers are still allowed even if
2271 ** this option is off. So, in other words, this option now only disables
2272 ** triggers in the main database schema or in the schemas of ATTACH-ed
2273 ** databases.)^ </dd>
2274 **
2275 ** [[SQLITE_DBCONFIG_ENABLE_VIEW]]
2276 ** <dt>SQLITE_DBCONFIG_ENABLE_VIEW</dt>
2277 ** <dd> ^This option is used to enable or disable [CREATE VIEW | views].
2278 ** There should be two additional arguments.
2279 ** The first argument is an integer which is 0 to disable views,
2280 ** positive to enable views or negative to leave the setting unchanged.
2281 ** The second parameter is a pointer to an integer into which
2282 ** is written 0 or 1 to indicate whether views are disabled or enabled
2283 ** following this call. The second parameter may be a NULL pointer, in
@@ -2292,11 +2329,11 @@
2292 ** [[SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER]]
2293 ** <dt>SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER</dt>
2294 ** <dd> ^This option is used to enable or disable the
2295 ** [fts3_tokenizer()] function which is part of the
2296 ** [FTS3] full-text search engine extension.
2297 ** There should be two additional arguments.
2298 ** The first argument is an integer which is 0 to disable fts3_tokenizer() or
2299 ** positive to enable fts3_tokenizer() or negative to leave the setting
2300 ** unchanged.
2301 ** The second parameter is a pointer to an integer into which
2302 ** is written 0 or 1 to indicate whether fts3_tokenizer is disabled or enabled
@@ -2307,11 +2344,11 @@
2307 ** <dt>SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION</dt>
2308 ** <dd> ^This option is used to enable or disable the [sqlite3_load_extension()]
2309 ** interface independently of the [load_extension()] SQL function.
2310 ** The [sqlite3_enable_load_extension()] API enables or disables both the
2311 ** C-API [sqlite3_load_extension()] and the SQL function [load_extension()].
2312 ** There should be two additional arguments.
2313 ** When the first argument to this interface is 1, then only the C-API is
2314 ** enabled and the SQL function remains disabled. If the first argument to
2315 ** this interface is 0, then both the C-API and the SQL function are disabled.
2316 ** If the first argument is -1, then no changes are made to state of either the
2317 ** C-API or the SQL function.
@@ -2321,27 +2358,34 @@
2321 ** be a NULL pointer, in which case the new setting is not reported back.
2322 ** </dd>
2323 **
2324 ** [[SQLITE_DBCONFIG_MAINDBNAME]] <dt>SQLITE_DBCONFIG_MAINDBNAME</dt>
2325 ** <dd> ^This option is used to change the name of the "main" database
2326 ** schema. ^The sole argument is a pointer to a constant UTF8 string
2327 ** which will become the new schema name in place of "main". ^SQLite
2328 ** does not make a copy of the new main schema name string, so the application
2329 ** must ensure that the argument passed into this DBCONFIG option is unchanged
2330 ** until after the database connection closes.
 
 
 
 
2331 ** </dd>
2332 **
2333 ** [[SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE]]
2334 ** <dt>SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE</dt>
2335 ** <dd> Usually, when a database in wal mode is closed or detached from a
2336 ** database handle, SQLite checks if this will mean that there are now no
2337 ** connections at all to the database. If so, it performs a checkpoint
2338 ** operation before closing the connection. This option may be used to
2339 ** override this behavior. The first parameter passed to this operation
2340 ** is an integer - positive to disable checkpoints-on-close, or zero (the
2341 ** default) to enable them, and negative to leave the setting unchanged.
2342 ** The second parameter is a pointer to an integer
 
 
 
2343 ** into which is written 0 or 1 to indicate whether checkpoints-on-close
2344 ** have been disabled - 0 if they are not disabled, 1 if they are.
2345 ** </dd>
2346 **
2347 ** [[SQLITE_DBCONFIG_ENABLE_QPSG]] <dt>SQLITE_DBCONFIG_ENABLE_QPSG</dt>
@@ -2498,11 +2542,11 @@
2498 ** SQLITE_ENABLE_STMT_SCANSTATUS builds. In this case, it sets or clears
2499 ** a flag that enables collection of the sqlite3_stmt_scanstatus_v2()
2500 ** statistics. For statistics to be collected, the flag must be set on
2501 ** the database handle both when the SQL statement is prepared and when it
2502 ** is stepped. The flag is set (collection of statistics is enabled)
2503 ** by default. This option takes two arguments: an integer and a pointer to
2504 ** an integer.. The first argument is 1, 0, or -1 to enable, disable, or
2505 ** leave unchanged the statement scanstatus option. If the second argument
2506 ** is not NULL, then the value of the statement scanstatus setting after
2507 ** processing the first argument is written into the integer that the second
2508 ** argument points to.
@@ -2512,20 +2556,89 @@
2512 ** <dt>SQLITE_DBCONFIG_REVERSE_SCANORDER</dt>
2513 ** <dd>The SQLITE_DBCONFIG_REVERSE_SCANORDER option changes the default order
2514 ** in which tables and indexes are scanned so that the scans start at the end
2515 ** and work toward the beginning rather than starting at the beginning and
2516 ** working toward the end. Setting SQLITE_DBCONFIG_REVERSE_SCANORDER is the
2517 ** same as setting [PRAGMA reverse_unordered_selects]. This option takes
2518 ** two arguments which are an integer and a pointer to an integer. The first
2519 ** argument is 1, 0, or -1 to enable, disable, or leave unchanged the
2520 ** reverse scan order flag, respectively. If the second argument is not NULL,
2521 ** then 0 or 1 is written into the integer that the second argument points to
2522 ** depending on if the reverse scan order flag is set after processing the
2523 ** first argument.
2524 ** </dd>
2525 **
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2526 ** </dl>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2527 */
2528 #define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */
2529 #define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */
2530 #define SQLITE_DBCONFIG_ENABLE_FKEY 1002 /* int int* */
2531 #define SQLITE_DBCONFIG_ENABLE_TRIGGER 1003 /* int int* */
@@ -2543,11 +2656,14 @@
2543 #define SQLITE_DBCONFIG_ENABLE_VIEW 1015 /* int int* */
2544 #define SQLITE_DBCONFIG_LEGACY_FILE_FORMAT 1016 /* int int* */
2545 #define SQLITE_DBCONFIG_TRUSTED_SCHEMA 1017 /* int int* */
2546 #define SQLITE_DBCONFIG_STMT_SCANSTATUS 1018 /* int int* */
2547 #define SQLITE_DBCONFIG_REVERSE_SCANORDER 1019 /* int int* */
2548 #define SQLITE_DBCONFIG_MAX 1019 /* Largest DBCONFIG */
 
 
 
2549
2550 /*
2551 ** CAPI3REF: Enable Or Disable Extended Result Codes
2552 ** METHOD: sqlite3
2553 **
@@ -10746,12 +10862,13 @@
10746 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_recover(sqlite3 *db, const char *zDb);
10747
10748 /*
10749 ** CAPI3REF: Serialize a database
10750 **
10751 ** The sqlite3_serialize(D,S,P,F) interface returns a pointer to memory
10752 ** that is a serialization of the S database on [database connection] D.
 
10753 ** If P is not a NULL pointer, then the size of the database in bytes
10754 ** is written into *P.
10755 **
10756 ** For an ordinary on-disk database file, the serialization is just a
10757 ** copy of the disk file. For an in-memory database or a "TEMP" database,
@@ -11913,23 +12030,10 @@
11913 int nB, /* Number of bytes in buffer pB */
11914 void *pB, /* Pointer to buffer containing changeset B */
11915 int *pnOut, /* OUT: Number of bytes in output changeset */
11916 void **ppOut /* OUT: Buffer containing output changeset */
11917 );
11918
11919
11920 /*
11921 ** CAPI3REF: Upgrade the Schema of a Changeset/Patchset
11922 */
11923 SQLITE_API int sqlite3changeset_upgrade(
11924 sqlite3 *db,
11925 const char *zDb,
11926 int nIn, const void *pIn, /* Input changeset */
11927 int *pnOut, void **ppOut /* OUT: Inverse of input */
11928 );
11929
11930
11931
11932 /*
11933 ** CAPI3REF: Changegroup Handle
11934 **
11935 ** A changegroup is an object used to combine two or more
11936
--- extsrc/sqlite3.h
+++ extsrc/sqlite3.h
@@ -144,13 +144,13 @@
144 **
145 ** See also: [sqlite3_libversion()],
146 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147 ** [sqlite_version()] and [sqlite_source_id()].
148 */
149 #define SQLITE_VERSION "3.50.0"
150 #define SQLITE_VERSION_NUMBER 3050000
151 #define SQLITE_SOURCE_ID "2025-02-18 01:16:26 57caa3136d1bfca06e4f2285734a4977b8d3fa1f75bf87453b975867e9de38fc"
152
153 /*
154 ** CAPI3REF: Run-Time Library Version Numbers
155 ** KEYWORDS: sqlite3_version sqlite3_sourceid
156 **
@@ -1987,17 +1987,20 @@
1987 ** [sqlite3_config()] with the SQLITE_CONFIG_GETMUTEX configuration option will
1988 ** return [SQLITE_ERROR].</dd>
1989 **
1990 ** [[SQLITE_CONFIG_LOOKASIDE]] <dt>SQLITE_CONFIG_LOOKASIDE</dt>
1991 ** <dd> ^(The SQLITE_CONFIG_LOOKASIDE option takes two arguments that determine
1992 ** the default size of [lookaside memory] on each [database connection].
1993 ** The first argument is the
1994 ** size of each lookaside buffer slot ("sz") and the second is the number of
1995 ** slots allocated to each database connection ("cnt").)^
1996 ** ^(SQLITE_CONFIG_LOOKASIDE sets the <i>default</i> lookaside size.
1997 ** The [SQLITE_DBCONFIG_LOOKASIDE] option to [sqlite3_db_config()] can
1998 ** be used to change the lookaside configuration on individual connections.)^
1999 ** The [-DSQLITE_DEFAULT_LOOKASIDE] option can be used to change the
2000 ** default lookaside configuration at compile-time.
2001 ** </dd>
2002 **
2003 ** [[SQLITE_CONFIG_PCACHE2]] <dt>SQLITE_CONFIG_PCACHE2</dt>
2004 ** <dd> ^(The SQLITE_CONFIG_PCACHE2 option takes a single argument which is
2005 ** a pointer to an [sqlite3_pcache_methods2] object. This object specifies
2006 ** the interface to a custom page cache implementation.)^
@@ -2209,11 +2212,19 @@
2212
2213 /*
2214 ** CAPI3REF: Database Connection Configuration Options
2215 **
2216 ** These constants are the available integer configuration options that
2217 ** can be passed as the second parameter to the [sqlite3_db_config()] interface.
2218 **
2219 ** The [sqlite3_db_config()] interface is a var-args functions. It takes a
2220 ** variable number of parameters, though always at least two. The number of
2221 ** parameters passed into sqlite3_db_config() depends on which of these
2222 ** constants is given as the second parameter. This documentation page
2223 ** refers to parameters beyond the second as "arguments". Thus, when this
2224 ** page says "the N-th argument" it means "the N-th parameter past the
2225 ** configuration option" or "the (N+2)-th parameter to sqlite3_db_config()".
2226 **
2227 ** New configuration options may be added in future releases of SQLite.
2228 ** Existing configuration options might be discontinued. Applications
2229 ** should check the return code from [sqlite3_db_config()] to make sure that
2230 ** the call worked. ^The [sqlite3_db_config()] interface will return a
@@ -2221,35 +2232,61 @@
2232 ** is invoked.
2233 **
2234 ** <dl>
2235 ** [[SQLITE_DBCONFIG_LOOKASIDE]]
2236 ** <dt>SQLITE_DBCONFIG_LOOKASIDE</dt>
2237 ** <dd> The SQLITE_DBCONFIG_LOOKASIDE option is used to adjust the
2238 ** configuration of the [lookaside memory allocator] within a database
2239 ** connection.
2240 ** The arguments to the SQLITE_DBCONFIG_LOOKASIDE option are <i>not</i>
2241 ** in the [DBCONFIG arguments|usual format].
2242 ** The SQLITE_DBCONFIG_LOOKASIDE option takes three arguments, not two,
2243 ** so that a call to [sqlite3_db_config()] that uses SQLITE_DBCONFIG_LOOKASIDE
2244 ** should have a total of five parameters.
2245 ** <ol>
2246 ** <li><p>The first argument ("buf") is a
2247 ** pointer to a memory buffer to use for lookaside memory.
2248 ** The first argument may be NULL in which case SQLite will allocate the
2249 ** lookaside buffer itself using [sqlite3_malloc()].
2250 ** <li><P>The second argument ("sz") is the
2251 ** size of each lookaside buffer slot. Lookaside is disabled if "sz"
2252 ** is less than 8. The "sz" argument should be a multiple of 8 less than
2253 ** 65536. If "sz" does not meet this constraint, it is reduced in size until
2254 ** it does.
2255 ** <li><p>The third argument ("cnt") is the number of slots. Lookaside is disabled
2256 ** if "cnt"is less than 1. The "cnt" value will be reduced, if necessary, so
2257 ** that the product of "sz" and "cnt" does not exceed 2,147,418,112. The "cnt"
2258 ** parameter is usually chosen so that the product of "sz" and "cnt" is less
2259 ** than 1,000,000.
2260 ** </ol>
2261 ** <p>If the "buf" argument is not NULL, then it must
2262 ** point to a memory buffer with a size that is greater than
2263 ** or equal to the product of "sz" and "cnt".
2264 ** The buffer must be aligned to an 8-byte boundary.
2265 ** The lookaside memory
2266 ** configuration for a database connection can only be changed when that
2267 ** connection is not currently using lookaside memory, or in other words
2268 ** when the value returned by [SQLITE_DBSTATUS_LOOKASIDE_USED] is zero.
 
2269 ** Any attempt to change the lookaside memory configuration when lookaside
2270 ** memory is in use leaves the configuration unchanged and returns
2271 ** [SQLITE_BUSY].
2272 ** If the "buf" argument is NULL and an attempt
2273 ** to allocate memory based on "sz" and "cnt" fails, then
2274 ** lookaside is silently disabled.
2275 ** <p>
2276 ** The [SQLITE_CONFIG_LOOKASIDE] configuration option can be used to set the
2277 ** default lookaside configuration at initialization. The
2278 ** [-DSQLITE_DEFAULT_LOOKASIDE] option can be used to set the default lookaside
2279 ** configuration at compile-time. Typical values for lookaside are 1200 for
2280 ** "sz" and 40 to 100 for "cnt".
2281 ** </dd>
2282 **
2283 ** [[SQLITE_DBCONFIG_ENABLE_FKEY]]
2284 ** <dt>SQLITE_DBCONFIG_ENABLE_FKEY</dt>
2285 ** <dd> ^This option is used to enable or disable the enforcement of
2286 ** [foreign key constraints]. This is the same setting that is
2287 ** enabled or disabled by the [PRAGMA foreign_keys] statement.
2288 ** The first argument is an integer which is 0 to disable FK enforcement,
2289 ** positive to enable FK enforcement or negative to leave FK enforcement
2290 ** unchanged. The second parameter is a pointer to an integer into which
2291 ** is written 0 or 1 to indicate whether FK enforcement is off or on
2292 ** following this call. The second parameter may be a NULL pointer, in
@@ -2267,17 +2304,17 @@
2304 ** which case the trigger setting is not reported back.
2305 **
2306 ** <p>Originally this option disabled all triggers. ^(However, since
2307 ** SQLite version 3.35.0, TEMP triggers are still allowed even if
2308 ** this option is off. So, in other words, this option now only disables
2309 ** triggers in the main database schema or in the schemas of [ATTACH]-ed
2310 ** databases.)^ </dd>
2311 **
2312 ** [[SQLITE_DBCONFIG_ENABLE_VIEW]]
2313 ** <dt>SQLITE_DBCONFIG_ENABLE_VIEW</dt>
2314 ** <dd> ^This option is used to enable or disable [CREATE VIEW | views].
2315 ** There must be two additional arguments.
2316 ** The first argument is an integer which is 0 to disable views,
2317 ** positive to enable views or negative to leave the setting unchanged.
2318 ** The second parameter is a pointer to an integer into which
2319 ** is written 0 or 1 to indicate whether views are disabled or enabled
2320 ** following this call. The second parameter may be a NULL pointer, in
@@ -2292,11 +2329,11 @@
2329 ** [[SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER]]
2330 ** <dt>SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER</dt>
2331 ** <dd> ^This option is used to enable or disable the
2332 ** [fts3_tokenizer()] function which is part of the
2333 ** [FTS3] full-text search engine extension.
2334 ** There must be two additional arguments.
2335 ** The first argument is an integer which is 0 to disable fts3_tokenizer() or
2336 ** positive to enable fts3_tokenizer() or negative to leave the setting
2337 ** unchanged.
2338 ** The second parameter is a pointer to an integer into which
2339 ** is written 0 or 1 to indicate whether fts3_tokenizer is disabled or enabled
@@ -2307,11 +2344,11 @@
2344 ** <dt>SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION</dt>
2345 ** <dd> ^This option is used to enable or disable the [sqlite3_load_extension()]
2346 ** interface independently of the [load_extension()] SQL function.
2347 ** The [sqlite3_enable_load_extension()] API enables or disables both the
2348 ** C-API [sqlite3_load_extension()] and the SQL function [load_extension()].
2349 ** There must be two additional arguments.
2350 ** When the first argument to this interface is 1, then only the C-API is
2351 ** enabled and the SQL function remains disabled. If the first argument to
2352 ** this interface is 0, then both the C-API and the SQL function are disabled.
2353 ** If the first argument is -1, then no changes are made to state of either the
2354 ** C-API or the SQL function.
@@ -2321,27 +2358,34 @@
2358 ** be a NULL pointer, in which case the new setting is not reported back.
2359 ** </dd>
2360 **
2361 ** [[SQLITE_DBCONFIG_MAINDBNAME]] <dt>SQLITE_DBCONFIG_MAINDBNAME</dt>
2362 ** <dd> ^This option is used to change the name of the "main" database
2363 ** schema. This option does not follow the
2364 ** [DBCONFIG arguments|usual SQLITE_DBCONFIG argument format].
2365 ** This option takes exactly one additional argument so that the
2366 ** [sqlite3_db_config()] call has a total of three parameters. The
2367 ** extra argument must be a pointer to a constant UTF8 string which
2368 ** will become the new schema name in place of "main". ^SQLite does
2369 ** not make a copy of the new main schema name string, so the application
2370 ** must ensure that the argument passed into SQLITE_DBCONFIG MAINDBNAME
2371 ** is unchanged until after the database connection closes.
2372 ** </dd>
2373 **
2374 ** [[SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE]]
2375 ** <dt>SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE</dt>
2376 ** <dd> Usually, when a database in [WAL mode] is closed or detached from a
2377 ** database handle, SQLite checks if if there are other connections to the
2378 ** same database, and if there are no other database connection (if the
2379 ** connection being closed is the last open connection to the database),
2380 ** then SQLite performs a [checkpoint] before closing the connection and
2381 ** deletes the WAL file. The SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE option can
2382 ** be used to override that behavior. The first argument passed to this
2383 ** operation (the third parameter to [sqlite3_db_config()]) is an integer
2384 ** which is positive to disable checkpoints-on-close, or zero (the default)
2385 ** to enable them, and negative to leave the setting unchanged.
2386 ** The second argument (the fourth parameter) is a pointer to an integer
2387 ** into which is written 0 or 1 to indicate whether checkpoints-on-close
2388 ** have been disabled - 0 if they are not disabled, 1 if they are.
2389 ** </dd>
2390 **
2391 ** [[SQLITE_DBCONFIG_ENABLE_QPSG]] <dt>SQLITE_DBCONFIG_ENABLE_QPSG</dt>
@@ -2498,11 +2542,11 @@
2542 ** SQLITE_ENABLE_STMT_SCANSTATUS builds. In this case, it sets or clears
2543 ** a flag that enables collection of the sqlite3_stmt_scanstatus_v2()
2544 ** statistics. For statistics to be collected, the flag must be set on
2545 ** the database handle both when the SQL statement is prepared and when it
2546 ** is stepped. The flag is set (collection of statistics is enabled)
2547 ** by default. <p>This option takes two arguments: an integer and a pointer to
2548 ** an integer.. The first argument is 1, 0, or -1 to enable, disable, or
2549 ** leave unchanged the statement scanstatus option. If the second argument
2550 ** is not NULL, then the value of the statement scanstatus setting after
2551 ** processing the first argument is written into the integer that the second
2552 ** argument points to.
@@ -2512,20 +2556,89 @@
2556 ** <dt>SQLITE_DBCONFIG_REVERSE_SCANORDER</dt>
2557 ** <dd>The SQLITE_DBCONFIG_REVERSE_SCANORDER option changes the default order
2558 ** in which tables and indexes are scanned so that the scans start at the end
2559 ** and work toward the beginning rather than starting at the beginning and
2560 ** working toward the end. Setting SQLITE_DBCONFIG_REVERSE_SCANORDER is the
2561 ** same as setting [PRAGMA reverse_unordered_selects]. <p>This option takes
2562 ** two arguments which are an integer and a pointer to an integer. The first
2563 ** argument is 1, 0, or -1 to enable, disable, or leave unchanged the
2564 ** reverse scan order flag, respectively. If the second argument is not NULL,
2565 ** then 0 or 1 is written into the integer that the second argument points to
2566 ** depending on if the reverse scan order flag is set after processing the
2567 ** first argument.
2568 ** </dd>
2569 **
2570 ** [[SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE]]
2571 ** <dt>SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE</dt>
2572 ** <dd>The SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE option enables or disables
2573 ** the ability of the [ATTACH DATABASE] SQL command to create a new database
2574 ** file if the database filed named in the ATTACH command does not already
2575 ** exist. This ability of ATTACH to create a new database is enabled by
2576 ** default. Applications can disable or reenable the ability for ATTACH to
2577 ** create new database files using this DBCONFIG option.<p>
2578 ** This option takes two arguments which are an integer and a pointer
2579 ** to an integer. The first argument is 1, 0, or -1 to enable, disable, or
2580 ** leave unchanged the attach-create flag, respectively. If the second
2581 ** argument is not NULL, then 0 or 1 is written into the integer that the
2582 ** second argument points to depending on if the attach-create flag is set
2583 ** after processing the first argument.
2584 ** </dd>
2585 **
2586 ** [[SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE]]
2587 ** <dt>SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE</dt>
2588 ** <dd>The SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE option enables or disables the
2589 ** ability of the [ATTACH DATABASE] SQL command to open a database for writing.
2590 ** This capability is enabled by default. Applications can disable or
2591 ** reenable this capability using the current DBCONFIG option. If the
2592 ** the this capability is disabled, the [ATTACH] command will still work,
2593 ** but the database will be opened read-only. If this option is disabled,
2594 ** then the ability to create a new database using [ATTACH] is also disabled,
2595 ** regardless of the value of the [SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE]
2596 ** option.<p>
2597 ** This option takes two arguments which are an integer and a pointer
2598 ** to an integer. The first argument is 1, 0, or -1 to enable, disable, or
2599 ** leave unchanged the ability to ATTACH another database for writing,
2600 ** respectively. If the second argument is not NULL, then 0 or 1 is written
2601 ** into the integer to which the second argument points, depending on whether
2602 ** the ability to ATTACH a read/write database is enabled or disabled
2603 ** after processing the first argument.
2604 ** </dd>
2605 **
2606 ** [[SQLITE_DBCONFIG_ENABLE_COMMENTS]]
2607 ** <dt>SQLITE_DBCONFIG_ENABLE_COMMENTS</dt>
2608 ** <dd>The SQLITE_DBCONFIG_ENABLE_COMMENTS option enables or disables the
2609 ** ability to include comments in SQL text. Comments are enabled by default.
2610 ** An application can disable or reenable comments in SQL text using this
2611 ** DBCONFIG option.<p>
2612 ** This option takes two arguments which are an integer and a pointer
2613 ** to an integer. The first argument is 1, 0, or -1 to enable, disable, or
2614 ** leave unchanged the ability to use comments in SQL text,
2615 ** respectively. If the second argument is not NULL, then 0 or 1 is written
2616 ** into the integer that the second argument points to depending on if
2617 ** comments are allowed in SQL text after processing the first argument.
2618 ** </dd>
2619 **
2620 ** </dl>
2621 **
2622 ** [[DBCONFIG arguments]] <h3>Arguments To SQLITE_DBCONFIG Options</h3>
2623 **
2624 ** <p>Most of the SQLITE_DBCONFIG options take two arguments, so that the
2625 ** overall call to [sqlite3_db_config()] has a total of four parameters.
2626 ** The first argument (the third parameter to sqlite3_db_config()) is a integer.
2627 ** The second argument is a pointer to an integer. If the first argument is 1,
2628 ** then the option becomes enabled. If the first integer argument is 0, then the
2629 ** option is disabled. If the first argument is -1, then the option setting
2630 ** is unchanged. The second argument, the pointer to an integer, may be NULL.
2631 ** If the second argument is not NULL, then a value of 0 or 1 is written into
2632 ** the integer to which the second argument points, depending on whether the
2633 ** setting is disabled or enabled after applying any changes specified by
2634 ** the first argument.
2635 **
2636 ** <p>While most SQLITE_DBCONFIG options use the argument format
2637 ** described in the previous paragraph, the [SQLITE_DBCONFIG_MAINDBNAME]
2638 ** and [SQLITE_DBCONFIG_LOOKASIDE] options are different. See the
2639 ** documentation of those exceptional options for details.
2640 */
2641 #define SQLITE_DBCONFIG_MAINDBNAME 1000 /* const char* */
2642 #define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */
2643 #define SQLITE_DBCONFIG_ENABLE_FKEY 1002 /* int int* */
2644 #define SQLITE_DBCONFIG_ENABLE_TRIGGER 1003 /* int int* */
@@ -2543,11 +2656,14 @@
2656 #define SQLITE_DBCONFIG_ENABLE_VIEW 1015 /* int int* */
2657 #define SQLITE_DBCONFIG_LEGACY_FILE_FORMAT 1016 /* int int* */
2658 #define SQLITE_DBCONFIG_TRUSTED_SCHEMA 1017 /* int int* */
2659 #define SQLITE_DBCONFIG_STMT_SCANSTATUS 1018 /* int int* */
2660 #define SQLITE_DBCONFIG_REVERSE_SCANORDER 1019 /* int int* */
2661 #define SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE 1020 /* int int* */
2662 #define SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE 1021 /* int int* */
2663 #define SQLITE_DBCONFIG_ENABLE_COMMENTS 1022 /* int int* */
2664 #define SQLITE_DBCONFIG_MAX 1022 /* Largest DBCONFIG */
2665
2666 /*
2667 ** CAPI3REF: Enable Or Disable Extended Result Codes
2668 ** METHOD: sqlite3
2669 **
@@ -10746,12 +10862,13 @@
10862 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_recover(sqlite3 *db, const char *zDb);
10863
10864 /*
10865 ** CAPI3REF: Serialize a database
10866 **
10867 ** The sqlite3_serialize(D,S,P,F) interface returns a pointer to
10868 ** memory that is a serialization of the S database on
10869 ** [database connection] D. If S is a NULL pointer, the main database is used.
10870 ** If P is not a NULL pointer, then the size of the database in bytes
10871 ** is written into *P.
10872 **
10873 ** For an ordinary on-disk database file, the serialization is just a
10874 ** copy of the disk file. For an in-memory database or a "TEMP" database,
@@ -11913,23 +12030,10 @@
12030 int nB, /* Number of bytes in buffer pB */
12031 void *pB, /* Pointer to buffer containing changeset B */
12032 int *pnOut, /* OUT: Number of bytes in output changeset */
12033 void **ppOut /* OUT: Buffer containing output changeset */
12034 );
 
 
 
 
 
 
 
 
 
 
 
 
 
12035
12036 /*
12037 ** CAPI3REF: Changegroup Handle
12038 **
12039 ** A changegroup is an object used to combine two or more
12040
--- skins/darkmode/css.txt
+++ skins/darkmode/css.txt
@@ -98,14 +98,17 @@
9898
}
9999
.fileage tr:hover,
100100
div.filetreeline:hover {
101101
background-color: #333;
102102
}
103
+div.file-change-line button {
104
+ background-color: #484848
105
+}
103106
.button,
104107
button {
105108
color: #aaa;
106
- background-color: #444;
109
+ background-color: #484848;
107110
border-radius: 5px;
108111
border: 0
109112
}
110113
.button:hover,
111114
button:hover {
112115
--- skins/darkmode/css.txt
+++ skins/darkmode/css.txt
@@ -98,14 +98,17 @@
98 }
99 .fileage tr:hover,
100 div.filetreeline:hover {
101 background-color: #333;
102 }
 
 
 
103 .button,
104 button {
105 color: #aaa;
106 background-color: #444;
107 border-radius: 5px;
108 border: 0
109 }
110 .button:hover,
111 button:hover {
112
--- skins/darkmode/css.txt
+++ skins/darkmode/css.txt
@@ -98,14 +98,17 @@
98 }
99 .fileage tr:hover,
100 div.filetreeline:hover {
101 background-color: #333;
102 }
103 div.file-change-line button {
104 background-color: #484848
105 }
106 .button,
107 button {
108 color: #aaa;
109 background-color: #484848;
110 border-radius: 5px;
111 border: 0
112 }
113 .button:hover,
114 button:hover {
115
--- skins/eagle/css.txt
+++ skins/eagle/css.txt
@@ -180,11 +180,11 @@
180180
cellspacing: 0;
181181
border: 0;
182182
cellpadding: 0;
183183
font-family: "courier new";
184184
border-spacing: 0px 2px;
185
- // border-collapse: collapse;
185
+ /* border-collapse: collapse; */
186186
}
187187
188188
.timelineSelected {
189189
background-color: #7EA2D9;
190190
}
191191
--- skins/eagle/css.txt
+++ skins/eagle/css.txt
@@ -180,11 +180,11 @@
180 cellspacing: 0;
181 border: 0;
182 cellpadding: 0;
183 font-family: "courier new";
184 border-spacing: 0px 2px;
185 // border-collapse: collapse;
186 }
187
188 .timelineSelected {
189 background-color: #7EA2D9;
190 }
191
--- skins/eagle/css.txt
+++ skins/eagle/css.txt
@@ -180,11 +180,11 @@
180 cellspacing: 0;
181 border: 0;
182 cellpadding: 0;
183 font-family: "courier new";
184 border-spacing: 0px 2px;
185 /* border-collapse: collapse; */
186 }
187
188 .timelineSelected {
189 background-color: #7EA2D9;
190 }
191
+2 -3
--- src/add.c
+++ src/add.c
@@ -353,11 +353,11 @@
353353
** for files to be excluded. Example: '*.o,*.obj,*.exe' If the --ignore
354354
** option does not appear on the command line then the "ignore-glob" setting
355355
** is used. If the --clean option does not appear on the command line then
356356
** the "clean-glob" setting is used.
357357
**
358
-** If files are attempted to be added explicitly on the command line which
358
+** When attempting to explicitly add files on the commandline, and if those
359359
** match "ignore-glob", a confirmation is asked first. This can be prevented
360360
** using the -f|--force option.
361361
**
362362
** The --case-sensitive option determines whether or not filenames should
363363
** be treated case sensitive or not. If the option is not given, the default
@@ -753,12 +753,11 @@
753753
**
754754
** * All files in the repository but missing from the check-out (that is,
755755
** all files that show as MISSING with the "status" command) are
756756
** removed as if by the "[[rm]]" command.
757757
**
758
-** The command does not "[[commit]]". You must run the "[[commit]]" separately
759
-** as a separate step.
758
+** Note that this command does not "commit", as that is a separate step.
760759
**
761760
** Files and directories whose names begin with "." are ignored unless
762761
** the --dotfiles option is used.
763762
**
764763
** The --ignore option overrides the "ignore-glob" setting, as do the
765764
--- src/add.c
+++ src/add.c
@@ -353,11 +353,11 @@
353 ** for files to be excluded. Example: '*.o,*.obj,*.exe' If the --ignore
354 ** option does not appear on the command line then the "ignore-glob" setting
355 ** is used. If the --clean option does not appear on the command line then
356 ** the "clean-glob" setting is used.
357 **
358 ** If files are attempted to be added explicitly on the command line which
359 ** match "ignore-glob", a confirmation is asked first. This can be prevented
360 ** using the -f|--force option.
361 **
362 ** The --case-sensitive option determines whether or not filenames should
363 ** be treated case sensitive or not. If the option is not given, the default
@@ -753,12 +753,11 @@
753 **
754 ** * All files in the repository but missing from the check-out (that is,
755 ** all files that show as MISSING with the "status" command) are
756 ** removed as if by the "[[rm]]" command.
757 **
758 ** The command does not "[[commit]]". You must run the "[[commit]]" separately
759 ** as a separate step.
760 **
761 ** Files and directories whose names begin with "." are ignored unless
762 ** the --dotfiles option is used.
763 **
764 ** The --ignore option overrides the "ignore-glob" setting, as do the
765
--- src/add.c
+++ src/add.c
@@ -353,11 +353,11 @@
353 ** for files to be excluded. Example: '*.o,*.obj,*.exe' If the --ignore
354 ** option does not appear on the command line then the "ignore-glob" setting
355 ** is used. If the --clean option does not appear on the command line then
356 ** the "clean-glob" setting is used.
357 **
358 ** When attempting to explicitly add files on the commandline, and if those
359 ** match "ignore-glob", a confirmation is asked first. This can be prevented
360 ** using the -f|--force option.
361 **
362 ** The --case-sensitive option determines whether or not filenames should
363 ** be treated case sensitive or not. If the option is not given, the default
@@ -753,12 +753,11 @@
753 **
754 ** * All files in the repository but missing from the check-out (that is,
755 ** all files that show as MISSING with the "status" command) are
756 ** removed as if by the "[[rm]]" command.
757 **
758 ** Note that this command does not "commit", as that is a separate step.
 
759 **
760 ** Files and directories whose names begin with "." are ignored unless
761 ** the --dotfiles option is used.
762 **
763 ** The --ignore option overrides the "ignore-glob" setting, as do the
764
--- src/backoffice.c
+++ src/backoffice.c
@@ -691,11 +691,11 @@
691691
** once every N seconds even if the repository
692692
** never changes. 0 or negative means disable
693693
** this feature. Default: 3600 (once per hour).
694694
**
695695
** --poll N Repeat backoffice calls for repositories that
696
-** change in appoximately N-second intervals.
696
+** change in approximately N-second intervals.
697697
** N less than 1 turns polling off (the default).
698698
** Recommended polling interval: 60 seconds.
699699
**
700700
** --trace Enable debugging output on stderr
701701
**
702702
--- src/backoffice.c
+++ src/backoffice.c
@@ -691,11 +691,11 @@
691 ** once every N seconds even if the repository
692 ** never changes. 0 or negative means disable
693 ** this feature. Default: 3600 (once per hour).
694 **
695 ** --poll N Repeat backoffice calls for repositories that
696 ** change in appoximately N-second intervals.
697 ** N less than 1 turns polling off (the default).
698 ** Recommended polling interval: 60 seconds.
699 **
700 ** --trace Enable debugging output on stderr
701 **
702
--- src/backoffice.c
+++ src/backoffice.c
@@ -691,11 +691,11 @@
691 ** once every N seconds even if the repository
692 ** never changes. 0 or negative means disable
693 ** this feature. Default: 3600 (once per hour).
694 **
695 ** --poll N Repeat backoffice calls for repositories that
696 ** change in approximately N-second intervals.
697 ** N less than 1 turns polling off (the default).
698 ** Recommended polling interval: 60 seconds.
699 **
700 ** --trace Enable debugging output on stderr
701 **
702
+38 -27
--- src/bisect.c
+++ src/bisect.c
@@ -197,10 +197,26 @@
197197
static void bisect_append_skip(int rid){
198198
db_multi_exec(
199199
"UPDATE vvar SET value=value||' s%d' WHERE name='bisect-log'", rid
200200
);
201201
}
202
+
203
+/*
204
+** Append a VALUES entry to the bilog table insert
205
+*/
206
+static void bisect_log_append(Blob *pSql,int iSeq,const char *zStat,int iRid){
207
+ if( (iSeq%6)==3 ){
208
+ blob_append_sql(pSql, ",\n ");
209
+ }else if( iSeq>1 ){
210
+ blob_append_sql(pSql, ",");
211
+ }
212
+ if( zStat ){
213
+ blob_append_sql(pSql, "(%d,%Q,%d)", iSeq, zStat, iRid);
214
+ }else{
215
+ blob_append_sql(pSql, "(NULL,NULL,%d)", iRid);
216
+ }
217
+}
202218
203219
/*
204220
** Create a TEMP table named "bilog" that contains the complete history
205221
** of the current bisect.
206222
**
@@ -215,14 +231,14 @@
215231
** in between the inner-most GOOD and BAD nodes.
216232
*/
217233
int bisect_create_bilog_table(int iCurrent, const char *zDesc, int bDetail){
218234
char *zLog;
219235
Blob log, id;
220
- Stmt q;
221236
int cnt = 0;
222237
int lastGood = -1;
223238
int lastBad = -1;
239
+ Blob ins = BLOB_INITIALIZER;
224240
225241
if( zDesc!=0 ){
226242
blob_init(&log, 0, 0);
227243
while( zDesc[0]=='y' || zDesc[0]=='n' || zDesc[0]=='s' ){
228244
int i;
@@ -253,55 +269,42 @@
253269
" rid INTEGER PRIMARY KEY," /* Sequence of events */
254270
" stat TEXT," /* Type of occurrence */
255271
" seq INTEGER UNIQUE" /* Check-in number */
256272
");"
257273
);
258
- db_prepare(&q, "INSERT OR IGNORE INTO bilog(seq,stat,rid)"
259
- " VALUES(:seq,:stat,:rid)");
274
+ blob_append_sql(&ins, "INSERT OR IGNORE INTO bilog(seq,stat,rid) VALUES");
260275
while( blob_token(&log, &id) ){
261276
int rid;
262
- db_bind_int(&q, ":seq", ++cnt);
277
+ cnt++;
263278
if( blob_str(&id)[0]=='s' ){
264279
rid = atoi(blob_str(&id)+1);
265
- db_bind_text(&q, ":stat", "SKIP");
266
- db_bind_int(&q, ":rid", rid);
280
+ bisect_log_append(&ins, cnt, "SKIP", rid);
267281
}else{
268282
rid = atoi(blob_str(&id));
269283
if( rid>0 ){
270
- db_bind_text(&q, ":stat","GOOD");
271
- db_bind_int(&q, ":rid", rid);
284
+ bisect_log_append(&ins, cnt, "GOOD", rid);
272285
lastGood = rid;
273286
}else{
274
- db_bind_text(&q, ":stat", "BAD");
275
- db_bind_int(&q, ":rid", -rid);
287
+ bisect_log_append(&ins, cnt, "BAD", -rid);
276288
lastBad = -rid;
277289
}
278290
}
279
- db_step(&q);
280
- db_reset(&q);
281291
}
282292
if( iCurrent>0 ){
283
- db_bind_int(&q, ":seq", ++cnt);
284
- db_bind_text(&q, ":stat", "CURRENT");
285
- db_bind_int(&q, ":rid", iCurrent);
286
- db_step(&q);
287
- db_reset(&q);
293
+ bisect_log_append(&ins, ++cnt, "CURRENT", iCurrent);
288294
}
289295
if( bDetail && lastGood>0 && lastBad>0 ){
290296
PathNode *p;
291297
p = path_shortest(lastGood, lastBad, bisect_option("direct-only"),0, 0);
292298
while( p ){
293
- db_bind_null(&q, ":seq");
294
- db_bind_null(&q, ":stat");
295
- db_bind_int(&q, ":rid", p->rid);
296
- db_step(&q);
297
- db_reset(&q);
299
+ bisect_log_append(&ins, ++cnt, 0, p->rid);
298300
p = p->u.pTo;
299301
}
300302
path_reset();
301303
}
302
- db_finalize(&q);
304
+ db_exec_sql(blob_sql_text(&ins));
305
+ blob_reset(&ins);
303306
return 1;
304307
}
305308
306309
/* Return a permalink description of a bisect. Space is obtained from
307310
** fossil_malloc() and should be freed by the caller.
@@ -543,14 +546,16 @@
543546
**
544547
** > fossil bisect vlist|ls|status ?-a|--all?
545548
**
546549
** List the versions in between the inner-most "bad" and "good".
547550
**
548
-** > fossil bisect ui
551
+** > fossil bisect ui ?HOST@USER:PATH?
549552
**
550553
** Like "fossil ui" except start on a timeline that shows only the
551
-** check-ins that are part of the current bisect.
554
+** check-ins that are part of the current bisect. If the optional
555
+** fourth term is added, then information is shown for the bisect that
556
+** occurred in the PATH directory by USER on remote machine HOST.
552557
**
553558
** > fossil bisect undo
554559
**
555560
** Undo the most recent "good", "bad", or "skip" command.
556561
*/
@@ -719,17 +724,23 @@
719724
}
720725
}else if( strncmp(zCmd, "reset", n)==0 ){
721726
bisect_reset();
722727
}else if( strcmp(zCmd, "ui")==0 ){
723728
char *newArgv[8];
729
+ verify_all_options();
724730
newArgv[0] = g.argv[0];
725731
newArgv[1] = "ui";
726732
newArgv[2] = "--page";
727733
newArgv[3] = "timeline?bisect";
728
- newArgv[4] = 0;
734
+ if( g.argc==4 ){
735
+ newArgv[4] = g.argv[3];
736
+ g.argc = 5;
737
+ }else{
738
+ g.argc = 4;
739
+ }
740
+ newArgv[g.argc] = 0;
729741
g.argv = newArgv;
730
- g.argc = 4;
731742
cmd_webserver();
732743
}else if( strncmp(zCmd, "vlist", n)==0
733744
|| strncmp(zCmd, "ls", n)==0
734745
|| strncmp(zCmd, "status", n)==0
735746
){
736747
--- src/bisect.c
+++ src/bisect.c
@@ -197,10 +197,26 @@
197 static void bisect_append_skip(int rid){
198 db_multi_exec(
199 "UPDATE vvar SET value=value||' s%d' WHERE name='bisect-log'", rid
200 );
201 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
202
203 /*
204 ** Create a TEMP table named "bilog" that contains the complete history
205 ** of the current bisect.
206 **
@@ -215,14 +231,14 @@
215 ** in between the inner-most GOOD and BAD nodes.
216 */
217 int bisect_create_bilog_table(int iCurrent, const char *zDesc, int bDetail){
218 char *zLog;
219 Blob log, id;
220 Stmt q;
221 int cnt = 0;
222 int lastGood = -1;
223 int lastBad = -1;
 
224
225 if( zDesc!=0 ){
226 blob_init(&log, 0, 0);
227 while( zDesc[0]=='y' || zDesc[0]=='n' || zDesc[0]=='s' ){
228 int i;
@@ -253,55 +269,42 @@
253 " rid INTEGER PRIMARY KEY," /* Sequence of events */
254 " stat TEXT," /* Type of occurrence */
255 " seq INTEGER UNIQUE" /* Check-in number */
256 ");"
257 );
258 db_prepare(&q, "INSERT OR IGNORE INTO bilog(seq,stat,rid)"
259 " VALUES(:seq,:stat,:rid)");
260 while( blob_token(&log, &id) ){
261 int rid;
262 db_bind_int(&q, ":seq", ++cnt);
263 if( blob_str(&id)[0]=='s' ){
264 rid = atoi(blob_str(&id)+1);
265 db_bind_text(&q, ":stat", "SKIP");
266 db_bind_int(&q, ":rid", rid);
267 }else{
268 rid = atoi(blob_str(&id));
269 if( rid>0 ){
270 db_bind_text(&q, ":stat","GOOD");
271 db_bind_int(&q, ":rid", rid);
272 lastGood = rid;
273 }else{
274 db_bind_text(&q, ":stat", "BAD");
275 db_bind_int(&q, ":rid", -rid);
276 lastBad = -rid;
277 }
278 }
279 db_step(&q);
280 db_reset(&q);
281 }
282 if( iCurrent>0 ){
283 db_bind_int(&q, ":seq", ++cnt);
284 db_bind_text(&q, ":stat", "CURRENT");
285 db_bind_int(&q, ":rid", iCurrent);
286 db_step(&q);
287 db_reset(&q);
288 }
289 if( bDetail && lastGood>0 && lastBad>0 ){
290 PathNode *p;
291 p = path_shortest(lastGood, lastBad, bisect_option("direct-only"),0, 0);
292 while( p ){
293 db_bind_null(&q, ":seq");
294 db_bind_null(&q, ":stat");
295 db_bind_int(&q, ":rid", p->rid);
296 db_step(&q);
297 db_reset(&q);
298 p = p->u.pTo;
299 }
300 path_reset();
301 }
302 db_finalize(&q);
 
303 return 1;
304 }
305
306 /* Return a permalink description of a bisect. Space is obtained from
307 ** fossil_malloc() and should be freed by the caller.
@@ -543,14 +546,16 @@
543 **
544 ** > fossil bisect vlist|ls|status ?-a|--all?
545 **
546 ** List the versions in between the inner-most "bad" and "good".
547 **
548 ** > fossil bisect ui
549 **
550 ** Like "fossil ui" except start on a timeline that shows only the
551 ** check-ins that are part of the current bisect.
 
 
552 **
553 ** > fossil bisect undo
554 **
555 ** Undo the most recent "good", "bad", or "skip" command.
556 */
@@ -719,17 +724,23 @@
719 }
720 }else if( strncmp(zCmd, "reset", n)==0 ){
721 bisect_reset();
722 }else if( strcmp(zCmd, "ui")==0 ){
723 char *newArgv[8];
 
724 newArgv[0] = g.argv[0];
725 newArgv[1] = "ui";
726 newArgv[2] = "--page";
727 newArgv[3] = "timeline?bisect";
728 newArgv[4] = 0;
 
 
 
 
 
 
729 g.argv = newArgv;
730 g.argc = 4;
731 cmd_webserver();
732 }else if( strncmp(zCmd, "vlist", n)==0
733 || strncmp(zCmd, "ls", n)==0
734 || strncmp(zCmd, "status", n)==0
735 ){
736
--- src/bisect.c
+++ src/bisect.c
@@ -197,10 +197,26 @@
197 static void bisect_append_skip(int rid){
198 db_multi_exec(
199 "UPDATE vvar SET value=value||' s%d' WHERE name='bisect-log'", rid
200 );
201 }
202
203 /*
204 ** Append a VALUES entry to the bilog table insert
205 */
206 static void bisect_log_append(Blob *pSql,int iSeq,const char *zStat,int iRid){
207 if( (iSeq%6)==3 ){
208 blob_append_sql(pSql, ",\n ");
209 }else if( iSeq>1 ){
210 blob_append_sql(pSql, ",");
211 }
212 if( zStat ){
213 blob_append_sql(pSql, "(%d,%Q,%d)", iSeq, zStat, iRid);
214 }else{
215 blob_append_sql(pSql, "(NULL,NULL,%d)", iRid);
216 }
217 }
218
219 /*
220 ** Create a TEMP table named "bilog" that contains the complete history
221 ** of the current bisect.
222 **
@@ -215,14 +231,14 @@
231 ** in between the inner-most GOOD and BAD nodes.
232 */
233 int bisect_create_bilog_table(int iCurrent, const char *zDesc, int bDetail){
234 char *zLog;
235 Blob log, id;
 
236 int cnt = 0;
237 int lastGood = -1;
238 int lastBad = -1;
239 Blob ins = BLOB_INITIALIZER;
240
241 if( zDesc!=0 ){
242 blob_init(&log, 0, 0);
243 while( zDesc[0]=='y' || zDesc[0]=='n' || zDesc[0]=='s' ){
244 int i;
@@ -253,55 +269,42 @@
269 " rid INTEGER PRIMARY KEY," /* Sequence of events */
270 " stat TEXT," /* Type of occurrence */
271 " seq INTEGER UNIQUE" /* Check-in number */
272 ");"
273 );
274 blob_append_sql(&ins, "INSERT OR IGNORE INTO bilog(seq,stat,rid) VALUES");
 
275 while( blob_token(&log, &id) ){
276 int rid;
277 cnt++;
278 if( blob_str(&id)[0]=='s' ){
279 rid = atoi(blob_str(&id)+1);
280 bisect_log_append(&ins, cnt, "SKIP", rid);
 
281 }else{
282 rid = atoi(blob_str(&id));
283 if( rid>0 ){
284 bisect_log_append(&ins, cnt, "GOOD", rid);
 
285 lastGood = rid;
286 }else{
287 bisect_log_append(&ins, cnt, "BAD", -rid);
 
288 lastBad = -rid;
289 }
290 }
 
 
291 }
292 if( iCurrent>0 ){
293 bisect_log_append(&ins, ++cnt, "CURRENT", iCurrent);
 
 
 
 
294 }
295 if( bDetail && lastGood>0 && lastBad>0 ){
296 PathNode *p;
297 p = path_shortest(lastGood, lastBad, bisect_option("direct-only"),0, 0);
298 while( p ){
299 bisect_log_append(&ins, ++cnt, 0, p->rid);
 
 
 
 
300 p = p->u.pTo;
301 }
302 path_reset();
303 }
304 db_exec_sql(blob_sql_text(&ins));
305 blob_reset(&ins);
306 return 1;
307 }
308
309 /* Return a permalink description of a bisect. Space is obtained from
310 ** fossil_malloc() and should be freed by the caller.
@@ -543,14 +546,16 @@
546 **
547 ** > fossil bisect vlist|ls|status ?-a|--all?
548 **
549 ** List the versions in between the inner-most "bad" and "good".
550 **
551 ** > fossil bisect ui ?HOST@USER:PATH?
552 **
553 ** Like "fossil ui" except start on a timeline that shows only the
554 ** check-ins that are part of the current bisect. If the optional
555 ** fourth term is added, then information is shown for the bisect that
556 ** occurred in the PATH directory by USER on remote machine HOST.
557 **
558 ** > fossil bisect undo
559 **
560 ** Undo the most recent "good", "bad", or "skip" command.
561 */
@@ -719,17 +724,23 @@
724 }
725 }else if( strncmp(zCmd, "reset", n)==0 ){
726 bisect_reset();
727 }else if( strcmp(zCmd, "ui")==0 ){
728 char *newArgv[8];
729 verify_all_options();
730 newArgv[0] = g.argv[0];
731 newArgv[1] = "ui";
732 newArgv[2] = "--page";
733 newArgv[3] = "timeline?bisect";
734 if( g.argc==4 ){
735 newArgv[4] = g.argv[3];
736 g.argc = 5;
737 }else{
738 g.argc = 4;
739 }
740 newArgv[g.argc] = 0;
741 g.argv = newArgv;
 
742 cmd_webserver();
743 }else if( strncmp(zCmd, "vlist", n)==0
744 || strncmp(zCmd, "ls", n)==0
745 || strncmp(zCmd, "status", n)==0
746 ){
747
+2 -2
--- src/branch.c
+++ src/branch.c
@@ -640,12 +640,12 @@
640640
** -M|--unmerged List branches not merged into the current branch
641641
** -p List only private branches
642642
** -r Reverse the sort order
643643
** -t Show recently changed branches first
644644
** --self List only branches where you participate
645
-** --username USER List only branches where USER participate
646
-** --users N List up to N users partipiating
645
+** --username USER List only branches where USER participates
646
+** --users N List up to N users participating
647647
**
648648
** The current branch is marked with an asterisk. Private branches are
649649
** marked with a hash sign.
650650
**
651651
** If GLOB is given, show only branches matching the pattern.
652652
--- src/branch.c
+++ src/branch.c
@@ -640,12 +640,12 @@
640 ** -M|--unmerged List branches not merged into the current branch
641 ** -p List only private branches
642 ** -r Reverse the sort order
643 ** -t Show recently changed branches first
644 ** --self List only branches where you participate
645 ** --username USER List only branches where USER participate
646 ** --users N List up to N users partipiating
647 **
648 ** The current branch is marked with an asterisk. Private branches are
649 ** marked with a hash sign.
650 **
651 ** If GLOB is given, show only branches matching the pattern.
652
--- src/branch.c
+++ src/branch.c
@@ -640,12 +640,12 @@
640 ** -M|--unmerged List branches not merged into the current branch
641 ** -p List only private branches
642 ** -r Reverse the sort order
643 ** -t Show recently changed branches first
644 ** --self List only branches where you participate
645 ** --username USER List only branches where USER participates
646 ** --users N List up to N users participating
647 **
648 ** The current branch is marked with an asterisk. Private branches are
649 ** marked with a hash sign.
650 **
651 ** If GLOB is given, show only branches matching the pattern.
652
+1 -1
--- src/cgi.c
+++ src/cgi.c
@@ -1778,11 +1778,11 @@
17781778
/* The following is a list of environment variables that Fossil considers
17791779
** to be "relevant". */
17801780
static const char *const azCgiVars[] = {
17811781
"COMSPEC", "DOCUMENT_ROOT", "GATEWAY_INTERFACE", "SCGI",
17821782
"HTTP_ACCEPT", "HTTP_ACCEPT_CHARSET", "HTTP_ACCEPT_ENCODING",
1783
- "HTTP_ACCEPT_LANGUAGE", "HTTP_AUTHENICATION",
1783
+ "HTTP_ACCEPT_LANGUAGE", "HTTP_AUTHENTICATION",
17841784
"HTTP_CONNECTION", "HTTP_HOST",
17851785
"HTTP_IF_NONE_MATCH", "HTTP_IF_MODIFIED_SINCE",
17861786
"HTTP_USER_AGENT", "HTTP_REFERER", "PATH_INFO", "PATH_TRANSLATED",
17871787
"QUERY_STRING", "REMOTE_ADDR", "REMOTE_PORT",
17881788
"REMOTE_USER", "REQUEST_METHOD", "REQUEST_SCHEME",
17891789
--- src/cgi.c
+++ src/cgi.c
@@ -1778,11 +1778,11 @@
1778 /* The following is a list of environment variables that Fossil considers
1779 ** to be "relevant". */
1780 static const char *const azCgiVars[] = {
1781 "COMSPEC", "DOCUMENT_ROOT", "GATEWAY_INTERFACE", "SCGI",
1782 "HTTP_ACCEPT", "HTTP_ACCEPT_CHARSET", "HTTP_ACCEPT_ENCODING",
1783 "HTTP_ACCEPT_LANGUAGE", "HTTP_AUTHENICATION",
1784 "HTTP_CONNECTION", "HTTP_HOST",
1785 "HTTP_IF_NONE_MATCH", "HTTP_IF_MODIFIED_SINCE",
1786 "HTTP_USER_AGENT", "HTTP_REFERER", "PATH_INFO", "PATH_TRANSLATED",
1787 "QUERY_STRING", "REMOTE_ADDR", "REMOTE_PORT",
1788 "REMOTE_USER", "REQUEST_METHOD", "REQUEST_SCHEME",
1789
--- src/cgi.c
+++ src/cgi.c
@@ -1778,11 +1778,11 @@
1778 /* The following is a list of environment variables that Fossil considers
1779 ** to be "relevant". */
1780 static const char *const azCgiVars[] = {
1781 "COMSPEC", "DOCUMENT_ROOT", "GATEWAY_INTERFACE", "SCGI",
1782 "HTTP_ACCEPT", "HTTP_ACCEPT_CHARSET", "HTTP_ACCEPT_ENCODING",
1783 "HTTP_ACCEPT_LANGUAGE", "HTTP_AUTHENTICATION",
1784 "HTTP_CONNECTION", "HTTP_HOST",
1785 "HTTP_IF_NONE_MATCH", "HTTP_IF_MODIFIED_SINCE",
1786 "HTTP_USER_AGENT", "HTTP_REFERER", "PATH_INFO", "PATH_TRANSLATED",
1787 "QUERY_STRING", "REMOTE_ADDR", "REMOTE_PORT",
1788 "REMOTE_USER", "REQUEST_METHOD", "REQUEST_SCHEME",
1789
+12 -3
--- src/checkin.c
+++ src/checkin.c
@@ -1563,17 +1563,17 @@
15631563
break;
15641564
}
15651565
diffFiles[i].nName = strlen(diffFiles[i].zName);
15661566
diffFiles[i].nUsed = 0;
15671567
}
1568
- diff_against_disk(0, &DCfg, diffFiles, &prompt);
1568
+ diff_version_to_checkout(0, &DCfg, diffFiles, &prompt);
15691569
for( i=0; diffFiles[i].zName; ++i ){
15701570
fossil_free(diffFiles[i].zName);
15711571
}
15721572
fossil_free(diffFiles);
15731573
}else{
1574
- diff_against_disk(0, &DCfg, 0, &prompt);
1574
+ diff_version_to_checkout(0, &DCfg, 0, &prompt);
15751575
}
15761576
}
15771577
prompt_for_user_comment(pComment, &prompt);
15781578
blob_reset(&prompt);
15791579
}
@@ -2354,10 +2354,12 @@
23542354
** --close Close the branch being committed
23552355
** --date-override DATETIME DATE to use instead of 'now'
23562356
** --delta Use a delta manifest in the commit process
23572357
** --hash Verify file status using hashing rather
23582358
** than relying on file mtimes
2359
+** --if-changes Make this command a silent no-op if there
2360
+** are no changes
23592361
** --ignore-clock-skew If a clock skew is detected, ignore it and
23602362
** behave as if the user had entered 'yes' to
23612363
** the question of whether to proceed despite
23622364
** the skew.
23632365
** --ignore-oversize Do not warn the user about oversized files
@@ -2409,10 +2411,11 @@
24092411
int forceFlag = 0; /* Undocumented: Disables all checks */
24102412
int forceDelta = 0; /* Force a delta-manifest */
24112413
int forceBaseline = 0; /* Force a baseline-manifest */
24122414
int allowConflict = 0; /* Allow unresolve merge conflicts */
24132415
int allowEmpty = 0; /* Allow a commit with no changes */
2416
+ int onlyIfChanges = 0; /* No-op if there are no changes */
24142417
int allowFork = 0; /* Allow the commit to fork */
24152418
int allowOlder = 0; /* Allow a commit older than its ancestor */
24162419
char *zManifestFile; /* Name of the manifest file */
24172420
int useCksum; /* True if checksums should be computed and verified */
24182421
int outputManifest; /* True to output "manifest" and "manifest.uuid" */
@@ -2466,10 +2469,11 @@
24662469
}
24672470
zComment = find_option("comment","m",1);
24682471
forceFlag = find_option("force", "f", 0)!=0;
24692472
allowConflict = find_option("allow-conflict",0,0)!=0;
24702473
allowEmpty = find_option("allow-empty",0,0)!=0;
2474
+ onlyIfChanges = find_option("if-changes",0,0)!=0;
24712475
allowFork = find_option("allow-fork",0,0)!=0;
24722476
if( find_option("override-lock",0,0)!=0 ) allowFork = 1;
24732477
allowOlder = find_option("allow-older",0,0)!=0;
24742478
noPrompt = find_option("no-prompt", 0, 0)!=0;
24752479
noWarningFlag = find_option("no-warnings", 0, 0)!=0;
@@ -2581,10 +2585,16 @@
25812585
if( nTag ){
25822586
int i;
25832587
for(i=0; i<nTag; i++) sCiInfo.azTag[i] = mprintf("%F", sCiInfo.azTag[i]);
25842588
qsort((void*)sCiInfo.azTag, nTag, sizeof(sCiInfo.azTag[0]), tagCmp);
25852589
}
2590
+
2591
+ hasChanges = unsaved_changes(useHash ? CKSIG_HASH : 0);
2592
+ if( hasChanges==0 && onlyIfChanges ){
2593
+ /* "fossil commit --if-changes" is a no-op if there are no changes. */
2594
+ return;
2595
+ }
25862596
25872597
/*
25882598
** Autosync if autosync is enabled and this is not a private check-in.
25892599
*/
25902600
if( !g.markPrivate ){
@@ -2686,11 +2696,10 @@
26862696
"'%s' was renamed to '%s'", zFrom, zTo, zFrom, zTo);
26872697
}
26882698
db_finalize(&q);
26892699
}
26902700
2691
- hasChanges = unsaved_changes(useHash ? CKSIG_HASH : 0);
26922701
db_begin_transaction();
26932702
db_record_repository_filename(0);
26942703
if( hasChanges==0 && !isAMerge && !allowEmpty && !forceFlag ){
26952704
fossil_fatal("nothing has changed; use --allow-empty to override");
26962705
}
26972706
--- src/checkin.c
+++ src/checkin.c
@@ -1563,17 +1563,17 @@
1563 break;
1564 }
1565 diffFiles[i].nName = strlen(diffFiles[i].zName);
1566 diffFiles[i].nUsed = 0;
1567 }
1568 diff_against_disk(0, &DCfg, diffFiles, &prompt);
1569 for( i=0; diffFiles[i].zName; ++i ){
1570 fossil_free(diffFiles[i].zName);
1571 }
1572 fossil_free(diffFiles);
1573 }else{
1574 diff_against_disk(0, &DCfg, 0, &prompt);
1575 }
1576 }
1577 prompt_for_user_comment(pComment, &prompt);
1578 blob_reset(&prompt);
1579 }
@@ -2354,10 +2354,12 @@
2354 ** --close Close the branch being committed
2355 ** --date-override DATETIME DATE to use instead of 'now'
2356 ** --delta Use a delta manifest in the commit process
2357 ** --hash Verify file status using hashing rather
2358 ** than relying on file mtimes
 
 
2359 ** --ignore-clock-skew If a clock skew is detected, ignore it and
2360 ** behave as if the user had entered 'yes' to
2361 ** the question of whether to proceed despite
2362 ** the skew.
2363 ** --ignore-oversize Do not warn the user about oversized files
@@ -2409,10 +2411,11 @@
2409 int forceFlag = 0; /* Undocumented: Disables all checks */
2410 int forceDelta = 0; /* Force a delta-manifest */
2411 int forceBaseline = 0; /* Force a baseline-manifest */
2412 int allowConflict = 0; /* Allow unresolve merge conflicts */
2413 int allowEmpty = 0; /* Allow a commit with no changes */
 
2414 int allowFork = 0; /* Allow the commit to fork */
2415 int allowOlder = 0; /* Allow a commit older than its ancestor */
2416 char *zManifestFile; /* Name of the manifest file */
2417 int useCksum; /* True if checksums should be computed and verified */
2418 int outputManifest; /* True to output "manifest" and "manifest.uuid" */
@@ -2466,10 +2469,11 @@
2466 }
2467 zComment = find_option("comment","m",1);
2468 forceFlag = find_option("force", "f", 0)!=0;
2469 allowConflict = find_option("allow-conflict",0,0)!=0;
2470 allowEmpty = find_option("allow-empty",0,0)!=0;
 
2471 allowFork = find_option("allow-fork",0,0)!=0;
2472 if( find_option("override-lock",0,0)!=0 ) allowFork = 1;
2473 allowOlder = find_option("allow-older",0,0)!=0;
2474 noPrompt = find_option("no-prompt", 0, 0)!=0;
2475 noWarningFlag = find_option("no-warnings", 0, 0)!=0;
@@ -2581,10 +2585,16 @@
2581 if( nTag ){
2582 int i;
2583 for(i=0; i<nTag; i++) sCiInfo.azTag[i] = mprintf("%F", sCiInfo.azTag[i]);
2584 qsort((void*)sCiInfo.azTag, nTag, sizeof(sCiInfo.azTag[0]), tagCmp);
2585 }
 
 
 
 
 
 
2586
2587 /*
2588 ** Autosync if autosync is enabled and this is not a private check-in.
2589 */
2590 if( !g.markPrivate ){
@@ -2686,11 +2696,10 @@
2686 "'%s' was renamed to '%s'", zFrom, zTo, zFrom, zTo);
2687 }
2688 db_finalize(&q);
2689 }
2690
2691 hasChanges = unsaved_changes(useHash ? CKSIG_HASH : 0);
2692 db_begin_transaction();
2693 db_record_repository_filename(0);
2694 if( hasChanges==0 && !isAMerge && !allowEmpty && !forceFlag ){
2695 fossil_fatal("nothing has changed; use --allow-empty to override");
2696 }
2697
--- src/checkin.c
+++ src/checkin.c
@@ -1563,17 +1563,17 @@
1563 break;
1564 }
1565 diffFiles[i].nName = strlen(diffFiles[i].zName);
1566 diffFiles[i].nUsed = 0;
1567 }
1568 diff_version_to_checkout(0, &DCfg, diffFiles, &prompt);
1569 for( i=0; diffFiles[i].zName; ++i ){
1570 fossil_free(diffFiles[i].zName);
1571 }
1572 fossil_free(diffFiles);
1573 }else{
1574 diff_version_to_checkout(0, &DCfg, 0, &prompt);
1575 }
1576 }
1577 prompt_for_user_comment(pComment, &prompt);
1578 blob_reset(&prompt);
1579 }
@@ -2354,10 +2354,12 @@
2354 ** --close Close the branch being committed
2355 ** --date-override DATETIME DATE to use instead of 'now'
2356 ** --delta Use a delta manifest in the commit process
2357 ** --hash Verify file status using hashing rather
2358 ** than relying on file mtimes
2359 ** --if-changes Make this command a silent no-op if there
2360 ** are no changes
2361 ** --ignore-clock-skew If a clock skew is detected, ignore it and
2362 ** behave as if the user had entered 'yes' to
2363 ** the question of whether to proceed despite
2364 ** the skew.
2365 ** --ignore-oversize Do not warn the user about oversized files
@@ -2409,10 +2411,11 @@
2411 int forceFlag = 0; /* Undocumented: Disables all checks */
2412 int forceDelta = 0; /* Force a delta-manifest */
2413 int forceBaseline = 0; /* Force a baseline-manifest */
2414 int allowConflict = 0; /* Allow unresolve merge conflicts */
2415 int allowEmpty = 0; /* Allow a commit with no changes */
2416 int onlyIfChanges = 0; /* No-op if there are no changes */
2417 int allowFork = 0; /* Allow the commit to fork */
2418 int allowOlder = 0; /* Allow a commit older than its ancestor */
2419 char *zManifestFile; /* Name of the manifest file */
2420 int useCksum; /* True if checksums should be computed and verified */
2421 int outputManifest; /* True to output "manifest" and "manifest.uuid" */
@@ -2466,10 +2469,11 @@
2469 }
2470 zComment = find_option("comment","m",1);
2471 forceFlag = find_option("force", "f", 0)!=0;
2472 allowConflict = find_option("allow-conflict",0,0)!=0;
2473 allowEmpty = find_option("allow-empty",0,0)!=0;
2474 onlyIfChanges = find_option("if-changes",0,0)!=0;
2475 allowFork = find_option("allow-fork",0,0)!=0;
2476 if( find_option("override-lock",0,0)!=0 ) allowFork = 1;
2477 allowOlder = find_option("allow-older",0,0)!=0;
2478 noPrompt = find_option("no-prompt", 0, 0)!=0;
2479 noWarningFlag = find_option("no-warnings", 0, 0)!=0;
@@ -2581,10 +2585,16 @@
2585 if( nTag ){
2586 int i;
2587 for(i=0; i<nTag; i++) sCiInfo.azTag[i] = mprintf("%F", sCiInfo.azTag[i]);
2588 qsort((void*)sCiInfo.azTag, nTag, sizeof(sCiInfo.azTag[0]), tagCmp);
2589 }
2590
2591 hasChanges = unsaved_changes(useHash ? CKSIG_HASH : 0);
2592 if( hasChanges==0 && onlyIfChanges ){
2593 /* "fossil commit --if-changes" is a no-op if there are no changes. */
2594 return;
2595 }
2596
2597 /*
2598 ** Autosync if autosync is enabled and this is not a private check-in.
2599 */
2600 if( !g.markPrivate ){
@@ -2686,11 +2696,10 @@
2696 "'%s' was renamed to '%s'", zFrom, zTo, zFrom, zTo);
2697 }
2698 db_finalize(&q);
2699 }
2700
 
2701 db_begin_transaction();
2702 db_record_repository_filename(0);
2703 if( hasChanges==0 && !isAMerge && !allowEmpty && !forceFlag ){
2704 fossil_fatal("nothing has changed; use --allow-empty to override");
2705 }
2706
+3 -4
--- src/checkout.c
+++ src/checkout.c
@@ -171,23 +171,22 @@
171171
** each character as a flag to enable writing "manifest", "manifest.uuid" or
172172
** "manifest.tags".
173173
*/
174174
void manifest_to_disk(int vid){
175175
char *zManFile;
176
- Blob manifest;
177
- Blob taglist;
178176
int flg;
179177
180178
flg = db_get_manifest_setting();
181179
182180
if( flg & MFESTFLG_RAW ){
183
- blob_zero(&manifest);
181
+ Blob manifest = BLOB_INITIALIZER;
184182
content_get(vid, &manifest);
185183
sterilize_manifest(&manifest, CFTYPE_MANIFEST);
186184
zManFile = mprintf("%smanifest", g.zLocalRoot);
187185
blob_write_to_file(&manifest, zManFile);
188186
free(zManFile);
187
+ blob_reset(&manifest);
189188
}else{
190189
if( !db_exists("SELECT 1 FROM vfile WHERE pathname='manifest'") ){
191190
zManFile = mprintf("%smanifest", g.zLocalRoot);
192191
file_delete(zManFile);
193192
free(zManFile);
@@ -207,11 +206,11 @@
207206
file_delete(zManFile);
208207
free(zManFile);
209208
}
210209
}
211210
if( flg & MFESTFLG_TAGS ){
212
- blob_zero(&taglist);
211
+ Blob taglist = BLOB_INITIALIZER;
213212
zManFile = mprintf("%smanifest.tags", g.zLocalRoot);
214213
get_checkin_taglist(vid, &taglist);
215214
blob_write_to_file(&taglist, zManFile);
216215
free(zManFile);
217216
blob_reset(&taglist);
218217
--- src/checkout.c
+++ src/checkout.c
@@ -171,23 +171,22 @@
171 ** each character as a flag to enable writing "manifest", "manifest.uuid" or
172 ** "manifest.tags".
173 */
174 void manifest_to_disk(int vid){
175 char *zManFile;
176 Blob manifest;
177 Blob taglist;
178 int flg;
179
180 flg = db_get_manifest_setting();
181
182 if( flg & MFESTFLG_RAW ){
183 blob_zero(&manifest);
184 content_get(vid, &manifest);
185 sterilize_manifest(&manifest, CFTYPE_MANIFEST);
186 zManFile = mprintf("%smanifest", g.zLocalRoot);
187 blob_write_to_file(&manifest, zManFile);
188 free(zManFile);
 
189 }else{
190 if( !db_exists("SELECT 1 FROM vfile WHERE pathname='manifest'") ){
191 zManFile = mprintf("%smanifest", g.zLocalRoot);
192 file_delete(zManFile);
193 free(zManFile);
@@ -207,11 +206,11 @@
207 file_delete(zManFile);
208 free(zManFile);
209 }
210 }
211 if( flg & MFESTFLG_TAGS ){
212 blob_zero(&taglist);
213 zManFile = mprintf("%smanifest.tags", g.zLocalRoot);
214 get_checkin_taglist(vid, &taglist);
215 blob_write_to_file(&taglist, zManFile);
216 free(zManFile);
217 blob_reset(&taglist);
218
--- src/checkout.c
+++ src/checkout.c
@@ -171,23 +171,22 @@
171 ** each character as a flag to enable writing "manifest", "manifest.uuid" or
172 ** "manifest.tags".
173 */
174 void manifest_to_disk(int vid){
175 char *zManFile;
 
 
176 int flg;
177
178 flg = db_get_manifest_setting();
179
180 if( flg & MFESTFLG_RAW ){
181 Blob manifest = BLOB_INITIALIZER;
182 content_get(vid, &manifest);
183 sterilize_manifest(&manifest, CFTYPE_MANIFEST);
184 zManFile = mprintf("%smanifest", g.zLocalRoot);
185 blob_write_to_file(&manifest, zManFile);
186 free(zManFile);
187 blob_reset(&manifest);
188 }else{
189 if( !db_exists("SELECT 1 FROM vfile WHERE pathname='manifest'") ){
190 zManFile = mprintf("%smanifest", g.zLocalRoot);
191 file_delete(zManFile);
192 free(zManFile);
@@ -207,11 +206,11 @@
206 file_delete(zManFile);
207 free(zManFile);
208 }
209 }
210 if( flg & MFESTFLG_TAGS ){
211 Blob taglist = BLOB_INITIALIZER;
212 zManFile = mprintf("%smanifest.tags", g.zLocalRoot);
213 get_checkin_taglist(vid, &taglist);
214 blob_write_to_file(&taglist, zManFile);
215 free(zManFile);
216 blob_reset(&taglist);
217
+26 -3
--- src/clearsign.c
+++ src/clearsign.c
@@ -29,28 +29,51 @@
2929
int clearsign(Blob *pIn, Blob *pOut){
3030
char *zRand;
3131
char *zIn;
3232
char *zOut;
3333
char *zBase = db_get("pgp-command", "gpg --clearsign -o ");
34
+ int useSsh = 0;
3435
char *zCmd;
3536
int rc;
3637
if( is_false(zBase) ){
3738
return 0;
3839
}
3940
zRand = db_text(0, "SELECT hex(randomblob(10))");
4041
zOut = mprintf("out-%s", zRand);
41
- zIn = mprintf("in-%z", zRand);
4242
blob_write_to_file(pIn, zOut);
43
- zCmd = mprintf("%s %s %s", zBase, zIn, zOut);
43
+ useSsh = (fossil_strncmp(command_basename(zBase), "ssh", 3)==0);
44
+ if( useSsh ){
45
+ zIn = mprintf("out-%s.sig", zRand);
46
+ zCmd = mprintf("%s %s", zBase, zOut);
47
+ }else{
48
+ zIn = mprintf("in-%z", zRand);
49
+ zCmd = mprintf("%s %s %s", zBase, zIn, zOut);
50
+ }
4451
rc = fossil_system(zCmd);
4552
free(zCmd);
4653
if( rc==0 ){
4754
if( pOut==pIn ){
4855
blob_reset(pIn);
4956
}
5057
blob_zero(pOut);
51
- blob_read_from_file(pOut, zIn, ExtFILE);
58
+ if( useSsh ){
59
+ /* As of 2025, SSH cannot create non-detached SSH signatures */
60
+ /* We put one together */
61
+ Blob tmpBlob;
62
+ blob_zero(&tmpBlob);
63
+ blob_read_from_file(&tmpBlob, zOut, ExtFILE);
64
+ /* Add armor header line and manifest */
65
+ blob_appendf(pOut, "%s", "-----BEGIN SSH SIGNED MESSAGE-----\n\n");
66
+ blob_appendf(pOut, "%s", blob_str(&tmpBlob));
67
+ blob_zero(&tmpBlob);
68
+ blob_read_from_file(&tmpBlob, zIn, ExtFILE);
69
+ /* Add signature - already armored by SSH */
70
+ blob_appendf(pOut, "%s", blob_str(&tmpBlob));
71
+ }else{
72
+ /* Assume that the external command creates non-detached signatures */
73
+ blob_read_from_file(pOut, zIn, ExtFILE);
74
+ }
5275
}else{
5376
if( pOut!=pIn ){
5477
blob_copy(pOut, pIn);
5578
}
5679
}
5780
--- src/clearsign.c
+++ src/clearsign.c
@@ -29,28 +29,51 @@
29 int clearsign(Blob *pIn, Blob *pOut){
30 char *zRand;
31 char *zIn;
32 char *zOut;
33 char *zBase = db_get("pgp-command", "gpg --clearsign -o ");
 
34 char *zCmd;
35 int rc;
36 if( is_false(zBase) ){
37 return 0;
38 }
39 zRand = db_text(0, "SELECT hex(randomblob(10))");
40 zOut = mprintf("out-%s", zRand);
41 zIn = mprintf("in-%z", zRand);
42 blob_write_to_file(pIn, zOut);
43 zCmd = mprintf("%s %s %s", zBase, zIn, zOut);
 
 
 
 
 
 
 
44 rc = fossil_system(zCmd);
45 free(zCmd);
46 if( rc==0 ){
47 if( pOut==pIn ){
48 blob_reset(pIn);
49 }
50 blob_zero(pOut);
51 blob_read_from_file(pOut, zIn, ExtFILE);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52 }else{
53 if( pOut!=pIn ){
54 blob_copy(pOut, pIn);
55 }
56 }
57
--- src/clearsign.c
+++ src/clearsign.c
@@ -29,28 +29,51 @@
29 int clearsign(Blob *pIn, Blob *pOut){
30 char *zRand;
31 char *zIn;
32 char *zOut;
33 char *zBase = db_get("pgp-command", "gpg --clearsign -o ");
34 int useSsh = 0;
35 char *zCmd;
36 int rc;
37 if( is_false(zBase) ){
38 return 0;
39 }
40 zRand = db_text(0, "SELECT hex(randomblob(10))");
41 zOut = mprintf("out-%s", zRand);
 
42 blob_write_to_file(pIn, zOut);
43 useSsh = (fossil_strncmp(command_basename(zBase), "ssh", 3)==0);
44 if( useSsh ){
45 zIn = mprintf("out-%s.sig", zRand);
46 zCmd = mprintf("%s %s", zBase, zOut);
47 }else{
48 zIn = mprintf("in-%z", zRand);
49 zCmd = mprintf("%s %s %s", zBase, zIn, zOut);
50 }
51 rc = fossil_system(zCmd);
52 free(zCmd);
53 if( rc==0 ){
54 if( pOut==pIn ){
55 blob_reset(pIn);
56 }
57 blob_zero(pOut);
58 if( useSsh ){
59 /* As of 2025, SSH cannot create non-detached SSH signatures */
60 /* We put one together */
61 Blob tmpBlob;
62 blob_zero(&tmpBlob);
63 blob_read_from_file(&tmpBlob, zOut, ExtFILE);
64 /* Add armor header line and manifest */
65 blob_appendf(pOut, "%s", "-----BEGIN SSH SIGNED MESSAGE-----\n\n");
66 blob_appendf(pOut, "%s", blob_str(&tmpBlob));
67 blob_zero(&tmpBlob);
68 blob_read_from_file(&tmpBlob, zIn, ExtFILE);
69 /* Add signature - already armored by SSH */
70 blob_appendf(pOut, "%s", blob_str(&tmpBlob));
71 }else{
72 /* Assume that the external command creates non-detached signatures */
73 blob_read_from_file(pOut, zIn, ExtFILE);
74 }
75 }else{
76 if( pOut!=pIn ){
77 blob_copy(pOut, pIn);
78 }
79 }
80
--- src/content.c
+++ src/content.c
@@ -946,10 +946,11 @@
946946
static int looks_like_control_artifact(Blob *p){
947947
const char *z = blob_buffer(p);
948948
int n = blob_size(p);
949949
if( n<10 ) return 0;
950950
if( strncmp(z, "-----BEGIN PGP SIGNED MESSAGE-----", 34)==0 ) return 1;
951
+ if( strncmp(z, "-----BEGIN SSH SIGNED MESSAGE-----", 34)==0 ) return 1;
951952
if( z[0]<'A' || z[0]>'Z' || z[1]!=' ' || z[0]=='I' ) return 0;
952953
if( z[n-1]!='\n' ) return 0;
953954
return 1;
954955
}
955956
956957
--- src/content.c
+++ src/content.c
@@ -946,10 +946,11 @@
946 static int looks_like_control_artifact(Blob *p){
947 const char *z = blob_buffer(p);
948 int n = blob_size(p);
949 if( n<10 ) return 0;
950 if( strncmp(z, "-----BEGIN PGP SIGNED MESSAGE-----", 34)==0 ) return 1;
 
951 if( z[0]<'A' || z[0]>'Z' || z[1]!=' ' || z[0]=='I' ) return 0;
952 if( z[n-1]!='\n' ) return 0;
953 return 1;
954 }
955
956
--- src/content.c
+++ src/content.c
@@ -946,10 +946,11 @@
946 static int looks_like_control_artifact(Blob *p){
947 const char *z = blob_buffer(p);
948 int n = blob_size(p);
949 if( n<10 ) return 0;
950 if( strncmp(z, "-----BEGIN PGP SIGNED MESSAGE-----", 34)==0 ) return 1;
951 if( strncmp(z, "-----BEGIN SSH SIGNED MESSAGE-----", 34)==0 ) return 1;
952 if( z[0]<'A' || z[0]>'Z' || z[1]!=' ' || z[0]=='I' ) return 0;
953 if( z[n-1]!='\n' ) return 0;
954 return 1;
955 }
956
957
+108 -32
--- src/db.c
+++ src/db.c
@@ -170,10 +170,12 @@
170170
void *pAuthArg; /* Argument to the authorizer */
171171
const char *zAuthName; /* Name of the authorizer */
172172
int bProtectTriggers; /* True if protection triggers already exist */
173173
int nProtect; /* Slots of aProtect used */
174174
unsigned aProtect[12]; /* Saved values of protectMask */
175
+ int pauseDmlLog; /* Ignore pDmlLog if positive */
176
+ Blob *pDmlLog; /* Append DML statements here, of not NULL */
175177
} db = {
176178
PROTECT_USER|PROTECT_CONFIG|PROTECT_BASELINE, /* protectMask */
177179
0, 0, 0, 0, 0, 0, 0, {{0}}, {0}, {0}, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0}};
178180
179181
/*
@@ -643,10 +645,43 @@
643645
*/
644646
#define DB_PREPARE_IGNORE_ERROR 0x001 /* Suppress errors */
645647
#define DB_PREPARE_PERSISTENT 0x002 /* Stmt will stick around for a while */
646648
#endif
647649
650
+/*
651
+** If zSql is a DML statement, append it db.pDmlLog.
652
+*/
653
+static void db_append_dml(const char *zSql){
654
+ size_t nSql;
655
+ if( db.pDmlLog==0 ) return;
656
+ if( db.pauseDmlLog ) return;
657
+ if( zSql==0 ) return;
658
+ nSql = strlen(zSql);
659
+ while( nSql>0 && fossil_isspace(zSql[0]) ){ nSql--; zSql++; }
660
+ while( nSql>0 && fossil_isspace(zSql[nSql-1]) ) nSql--;
661
+ if( nSql<6 ) return;
662
+ if( fossil_strnicmp(zSql, "SELECT", 6)==0 ) return;
663
+ if( fossil_strnicmp(zSql, "PRAGMA", 6)==0 ) return;
664
+ blob_append(db.pDmlLog, zSql, nSql);
665
+ if( zSql[nSql-1]!=';' ) blob_append_char(db.pDmlLog, ';');
666
+ blob_append_char(db.pDmlLog, '\n');
667
+}
668
+
669
+/*
670
+** Set the Blob to which DML statement text should be appended. Set it
671
+** to zero to stop appending DML statement text.
672
+*/
673
+void db_append_dml_to_blob(Blob *pBlob){
674
+ db.pDmlLog = pBlob;
675
+}
676
+
677
+/*
678
+** Pause or unpause the DML log
679
+*/
680
+void db_pause_dml_log(void){ db.pauseDmlLog++; }
681
+void db_unpause_dml_log(void){ db.pauseDmlLog--; }
682
+
648683
/*
649684
** Prepare a Stmt. Assume that the Stmt is previously uninitialized.
650685
** If the input string contains multiple SQL statements, only the first
651686
** one is processed. All statements beyond the first are silently ignored.
652687
*/
@@ -658,10 +693,11 @@
658693
blob_zero(&pStmt->sql);
659694
blob_vappendf(&pStmt->sql, zFormat, ap);
660695
va_end(ap);
661696
zSql = blob_str(&pStmt->sql);
662697
db.nPrepare++;
698
+ db_append_dml(zSql);
663699
if( flags & DB_PREPARE_PERSISTENT ){
664700
prepFlags = SQLITE_PREPARE_PERSISTENT;
665701
}
666702
rc = sqlite3_prepare_v3(g.db, zSql, -1, prepFlags, &pStmt->pStmt, &zExtra);
667703
if( rc!=0 && (flags & DB_PREPARE_IGNORE_ERROR)==0 ){
@@ -1047,10 +1083,11 @@
10471083
rc = sqlite3_prepare_v2(g.db, z, -1, &pStmt, &zEnd);
10481084
if( rc ){
10491085
db_err("%s: {%s}", sqlite3_errmsg(g.db), z);
10501086
}else if( pStmt ){
10511087
db.nPrepare++;
1088
+ db_append_dml(sqlite3_sql(pStmt));
10521089
while( sqlite3_step(pStmt)==SQLITE_ROW ){}
10531090
rc = sqlite3_finalize(pStmt);
10541091
if( rc ) db_err("%s: {%.*s}", sqlite3_errmsg(g.db), (int)(zEnd-z), z);
10551092
}
10561093
z = zEnd;
@@ -1312,10 +1349,50 @@
13121349
sqlite3_result_int64(context, rid);
13131350
}
13141351
}
13151352
}
13161353
1354
+
1355
+/*
1356
+** SETTING: timeline-utc boolean default=on
1357
+**
1358
+** If the timeline-utc setting is true, then Fossil tries to understand
1359
+** and display all time values using UTC. If this setting is false, Fossil
1360
+** tries to understand and display time values using the local timezone.
1361
+**
1362
+** The word "timeline" in the name of this setting is historical.
1363
+** This setting applies to all user interfaces of Fossil,
1364
+** not just the timeline.
1365
+**
1366
+** Note that when accessing Fossil using the web interface, the localtime
1367
+** used is the localtime on the server, not on the client.
1368
+*/
1369
+/*
1370
+** Return true if Fossil is set to display times as UTC. Return false
1371
+** if it wants to display times using the local timezone.
1372
+**
1373
+** False is returned if display is set to localtime even if the localtime
1374
+** happens to be the same as UTC.
1375
+*/
1376
+int fossil_ui_utctime(void){
1377
+ if( g.fTimeFormat==0 ){
1378
+ if( db_get_int("timeline-utc", 1) ){
1379
+ g.fTimeFormat = 1; /* UTC */
1380
+ }else{
1381
+ g.fTimeFormat = 2; /* Localtime */
1382
+ }
1383
+ }
1384
+ return g.fTimeFormat==1;
1385
+}
1386
+
1387
+/*
1388
+** Return true if Fossil is set to display times using the local timezone.
1389
+*/
1390
+int fossil_ui_localtime(void){
1391
+ return fossil_ui_utctime()==0;
1392
+}
1393
+
13171394
/*
13181395
** The toLocal() SQL function returns a string that is an argument to a
13191396
** date/time function that is appropriate for modifying the time for display.
13201397
** If UTC time display is selected, no modification occurs. If local time
13211398
** display is selected, the time is adjusted appropriately.
@@ -1327,18 +1404,11 @@
13271404
void db_tolocal_function(
13281405
sqlite3_context *context,
13291406
int argc,
13301407
sqlite3_value **argv
13311408
){
1332
- if( g.fTimeFormat==0 ){
1333
- if( db_get_int("timeline-utc", 1) ){
1334
- g.fTimeFormat = 1;
1335
- }else{
1336
- g.fTimeFormat = 2;
1337
- }
1338
- }
1339
- if( g.fTimeFormat==1 ){
1409
+ if( fossil_ui_utctime() ){
13401410
sqlite3_result_text(context, "0 seconds", -1, SQLITE_STATIC);
13411411
}else{
13421412
sqlite3_result_text(context, "localtime", -1, SQLITE_STATIC);
13431413
}
13441414
}
@@ -1356,18 +1426,11 @@
13561426
void db_fromlocal_function(
13571427
sqlite3_context *context,
13581428
int argc,
13591429
sqlite3_value **argv
13601430
){
1361
- if( g.fTimeFormat==0 ){
1362
- if( db_get_int("timeline-utc", 1) ){
1363
- g.fTimeFormat = 1;
1364
- }else{
1365
- g.fTimeFormat = 2;
1366
- }
1367
- }
1368
- if( g.fTimeFormat==1 ){
1431
+ if( fossil_ui_utctime() ){
13691432
sqlite3_result_text(context, "0 seconds", -1, SQLITE_STATIC);
13701433
}else{
13711434
sqlite3_result_text(context, "utc", -1, SQLITE_STATIC);
13721435
}
13731436
}
@@ -1524,24 +1587,31 @@
15241587
** Register the SQL functions that are useful both to the internal
15251588
** representation and to the "fossil sql" command.
15261589
*/
15271590
void db_add_aux_functions(sqlite3 *db){
15281591
sqlite3_create_collation(db, "uintnocase", SQLITE_UTF8,0,uintNocaseCollFunc);
1529
- sqlite3_create_function(db, "checkin_mtime", 2, SQLITE_UTF8, 0,
1530
- db_checkin_mtime_function, 0, 0);
1531
- sqlite3_create_function(db, "symbolic_name_to_rid", 1, SQLITE_UTF8, 0,
1532
- db_sym2rid_function, 0, 0);
1533
- sqlite3_create_function(db, "symbolic_name_to_rid", 2, SQLITE_UTF8, 0,
1534
- db_sym2rid_function, 0, 0);
1535
- sqlite3_create_function(db, "now", 0, SQLITE_UTF8, 0,
1592
+ sqlite3_create_function(db, "checkin_mtime", 2,
1593
+ SQLITE_UTF8|SQLITE_DETERMINISTIC|SQLITE_INNOCUOUS,
1594
+ 0, db_checkin_mtime_function, 0, 0);
1595
+ sqlite3_create_function(db, "symbolic_name_to_rid", 1,
1596
+ SQLITE_UTF8|SQLITE_DETERMINISTIC|SQLITE_INNOCUOUS,
1597
+ 0, db_sym2rid_function, 0, 0);
1598
+ sqlite3_create_function(db, "symbolic_name_to_rid", 2,
1599
+ SQLITE_UTF8|SQLITE_DETERMINISTIC|SQLITE_INNOCUOUS,
1600
+ 0, db_sym2rid_function, 0, 0);
1601
+ sqlite3_create_function(db, "now", 0,
1602
+ SQLITE_UTF8|SQLITE_INNOCUOUS, 0,
15361603
db_now_function, 0, 0);
1537
- sqlite3_create_function(db, "toLocal", 0, SQLITE_UTF8, 0,
1538
- db_tolocal_function, 0, 0);
1539
- sqlite3_create_function(db, "fromLocal", 0, SQLITE_UTF8, 0,
1540
- db_fromlocal_function, 0, 0);
1541
- sqlite3_create_function(db, "hextoblob", 1, SQLITE_UTF8, 0,
1542
- db_hextoblob, 0, 0);
1604
+ sqlite3_create_function(db, "toLocal", 0,
1605
+ SQLITE_UTF8|SQLITE_DETERMINISTIC|SQLITE_INNOCUOUS,
1606
+ 0, db_tolocal_function, 0, 0);
1607
+ sqlite3_create_function(db, "fromLocal", 0,
1608
+ SQLITE_UTF8|SQLITE_DETERMINISTIC|SQLITE_INNOCUOUS,
1609
+ 0, db_fromlocal_function, 0, 0);
1610
+ sqlite3_create_function(db, "hextoblob", 1,
1611
+ SQLITE_UTF8|SQLITE_DETERMINISTIC|SQLITE_INNOCUOUS,
1612
+ 0, db_hextoblob, 0, 0);
15431613
sqlite3_create_function(db, "capunion", 1, SQLITE_UTF8, 0,
15441614
0, capability_union_step, capability_union_finalize);
15451615
sqlite3_create_function(db, "fullcap", 1, SQLITE_UTF8, 0,
15461616
capability_fullcap, 0, 0);
15471617
sqlite3_create_function(db, "find_emailaddr", 1, SQLITE_UTF8, 0,
@@ -2105,11 +2175,11 @@
21052175
sqlite3 *, char **, const sqlite3_api_routines *
21062176
);
21072177
sqlite3_appendvfs_init(0,0,0);
21082178
g.zVfsName = "apndvfs";
21092179
}
2110
- blob_zero(&bNameCheck);
2180
+ blob_reset(&bNameCheck);
21112181
rc = sqlite3_open_v2(
21122182
zDbName, &db,
21132183
SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE,
21142184
g.zVfsName
21152185
);
@@ -2625,13 +2695,18 @@
26252695
return res;
26262696
}
26272697
26282698
/*
26292699
** COMMAND: test-is-repo
2700
+** Usage: %fossil test-is-repo FILENAME...
2701
+**
2702
+** Test whether the specified files look like a SQLite database
2703
+** containing a Fossil repository schema.
26302704
*/
26312705
void test_is_repo(void){
26322706
int i;
2707
+ verify_all_options();
26332708
for(i=2; i<g.argc; i++){
26342709
fossil_print("%s: %s\n",
26352710
db_looks_like_a_repository(g.argv[i]) ? "yes" : " no",
26362711
g.argv[i]
26372712
);
@@ -4561,11 +4636,11 @@
45614636
** see https://fossil-scm.org/home/doc/trunk/www/globs.md#syntax
45624637
*/
45634638
/*
45644639
** SETTING: clearsign boolean default=off
45654640
** When enabled, fossil will attempt to sign all commits
4566
-** with gpg. When disabled, commits will be unsigned.
4641
+** with gpg or ssh. When disabled, commits will be unsigned.
45674642
*/
45684643
/*
45694644
** SETTING: comment-format width=16 default=1
45704645
** Set the default options for printing timeline comments to the console.
45714646
**
@@ -4827,11 +4902,12 @@
48274902
** files from within the check-out.
48284903
*/
48294904
/*
48304905
** SETTING: pgp-command width=40 sensitive
48314906
** Command used to clear-sign manifests at check-in.
4832
-** Default value is "gpg --clearsign -o"
4907
+** Default value is "gpg --clearsign -o".
4908
+** For SSH, use e.g. "ssh-keygen -q -Y sign -n fossilscm -f ~/.ssh/id_ed25519"
48334909
*/
48344910
/*
48354911
** SETTING: proxy width=32 default=system
48364912
** URL of the HTTP proxy. If undefined or "system", the "http_proxy"
48374913
** environment variable is consulted. If "off", a direct HTTP connection is
48384914
--- src/db.c
+++ src/db.c
@@ -170,10 +170,12 @@
170 void *pAuthArg; /* Argument to the authorizer */
171 const char *zAuthName; /* Name of the authorizer */
172 int bProtectTriggers; /* True if protection triggers already exist */
173 int nProtect; /* Slots of aProtect used */
174 unsigned aProtect[12]; /* Saved values of protectMask */
 
 
175 } db = {
176 PROTECT_USER|PROTECT_CONFIG|PROTECT_BASELINE, /* protectMask */
177 0, 0, 0, 0, 0, 0, 0, {{0}}, {0}, {0}, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0}};
178
179 /*
@@ -643,10 +645,43 @@
643 */
644 #define DB_PREPARE_IGNORE_ERROR 0x001 /* Suppress errors */
645 #define DB_PREPARE_PERSISTENT 0x002 /* Stmt will stick around for a while */
646 #endif
647
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
648 /*
649 ** Prepare a Stmt. Assume that the Stmt is previously uninitialized.
650 ** If the input string contains multiple SQL statements, only the first
651 ** one is processed. All statements beyond the first are silently ignored.
652 */
@@ -658,10 +693,11 @@
658 blob_zero(&pStmt->sql);
659 blob_vappendf(&pStmt->sql, zFormat, ap);
660 va_end(ap);
661 zSql = blob_str(&pStmt->sql);
662 db.nPrepare++;
 
663 if( flags & DB_PREPARE_PERSISTENT ){
664 prepFlags = SQLITE_PREPARE_PERSISTENT;
665 }
666 rc = sqlite3_prepare_v3(g.db, zSql, -1, prepFlags, &pStmt->pStmt, &zExtra);
667 if( rc!=0 && (flags & DB_PREPARE_IGNORE_ERROR)==0 ){
@@ -1047,10 +1083,11 @@
1047 rc = sqlite3_prepare_v2(g.db, z, -1, &pStmt, &zEnd);
1048 if( rc ){
1049 db_err("%s: {%s}", sqlite3_errmsg(g.db), z);
1050 }else if( pStmt ){
1051 db.nPrepare++;
 
1052 while( sqlite3_step(pStmt)==SQLITE_ROW ){}
1053 rc = sqlite3_finalize(pStmt);
1054 if( rc ) db_err("%s: {%.*s}", sqlite3_errmsg(g.db), (int)(zEnd-z), z);
1055 }
1056 z = zEnd;
@@ -1312,10 +1349,50 @@
1312 sqlite3_result_int64(context, rid);
1313 }
1314 }
1315 }
1316
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1317 /*
1318 ** The toLocal() SQL function returns a string that is an argument to a
1319 ** date/time function that is appropriate for modifying the time for display.
1320 ** If UTC time display is selected, no modification occurs. If local time
1321 ** display is selected, the time is adjusted appropriately.
@@ -1327,18 +1404,11 @@
1327 void db_tolocal_function(
1328 sqlite3_context *context,
1329 int argc,
1330 sqlite3_value **argv
1331 ){
1332 if( g.fTimeFormat==0 ){
1333 if( db_get_int("timeline-utc", 1) ){
1334 g.fTimeFormat = 1;
1335 }else{
1336 g.fTimeFormat = 2;
1337 }
1338 }
1339 if( g.fTimeFormat==1 ){
1340 sqlite3_result_text(context, "0 seconds", -1, SQLITE_STATIC);
1341 }else{
1342 sqlite3_result_text(context, "localtime", -1, SQLITE_STATIC);
1343 }
1344 }
@@ -1356,18 +1426,11 @@
1356 void db_fromlocal_function(
1357 sqlite3_context *context,
1358 int argc,
1359 sqlite3_value **argv
1360 ){
1361 if( g.fTimeFormat==0 ){
1362 if( db_get_int("timeline-utc", 1) ){
1363 g.fTimeFormat = 1;
1364 }else{
1365 g.fTimeFormat = 2;
1366 }
1367 }
1368 if( g.fTimeFormat==1 ){
1369 sqlite3_result_text(context, "0 seconds", -1, SQLITE_STATIC);
1370 }else{
1371 sqlite3_result_text(context, "utc", -1, SQLITE_STATIC);
1372 }
1373 }
@@ -1524,24 +1587,31 @@
1524 ** Register the SQL functions that are useful both to the internal
1525 ** representation and to the "fossil sql" command.
1526 */
1527 void db_add_aux_functions(sqlite3 *db){
1528 sqlite3_create_collation(db, "uintnocase", SQLITE_UTF8,0,uintNocaseCollFunc);
1529 sqlite3_create_function(db, "checkin_mtime", 2, SQLITE_UTF8, 0,
1530 db_checkin_mtime_function, 0, 0);
1531 sqlite3_create_function(db, "symbolic_name_to_rid", 1, SQLITE_UTF8, 0,
1532 db_sym2rid_function, 0, 0);
1533 sqlite3_create_function(db, "symbolic_name_to_rid", 2, SQLITE_UTF8, 0,
1534 db_sym2rid_function, 0, 0);
1535 sqlite3_create_function(db, "now", 0, SQLITE_UTF8, 0,
 
 
 
 
1536 db_now_function, 0, 0);
1537 sqlite3_create_function(db, "toLocal", 0, SQLITE_UTF8, 0,
1538 db_tolocal_function, 0, 0);
1539 sqlite3_create_function(db, "fromLocal", 0, SQLITE_UTF8, 0,
1540 db_fromlocal_function, 0, 0);
1541 sqlite3_create_function(db, "hextoblob", 1, SQLITE_UTF8, 0,
1542 db_hextoblob, 0, 0);
 
 
 
1543 sqlite3_create_function(db, "capunion", 1, SQLITE_UTF8, 0,
1544 0, capability_union_step, capability_union_finalize);
1545 sqlite3_create_function(db, "fullcap", 1, SQLITE_UTF8, 0,
1546 capability_fullcap, 0, 0);
1547 sqlite3_create_function(db, "find_emailaddr", 1, SQLITE_UTF8, 0,
@@ -2105,11 +2175,11 @@
2105 sqlite3 *, char **, const sqlite3_api_routines *
2106 );
2107 sqlite3_appendvfs_init(0,0,0);
2108 g.zVfsName = "apndvfs";
2109 }
2110 blob_zero(&bNameCheck);
2111 rc = sqlite3_open_v2(
2112 zDbName, &db,
2113 SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE,
2114 g.zVfsName
2115 );
@@ -2625,13 +2695,18 @@
2625 return res;
2626 }
2627
2628 /*
2629 ** COMMAND: test-is-repo
 
 
 
 
2630 */
2631 void test_is_repo(void){
2632 int i;
 
2633 for(i=2; i<g.argc; i++){
2634 fossil_print("%s: %s\n",
2635 db_looks_like_a_repository(g.argv[i]) ? "yes" : " no",
2636 g.argv[i]
2637 );
@@ -4561,11 +4636,11 @@
4561 ** see https://fossil-scm.org/home/doc/trunk/www/globs.md#syntax
4562 */
4563 /*
4564 ** SETTING: clearsign boolean default=off
4565 ** When enabled, fossil will attempt to sign all commits
4566 ** with gpg. When disabled, commits will be unsigned.
4567 */
4568 /*
4569 ** SETTING: comment-format width=16 default=1
4570 ** Set the default options for printing timeline comments to the console.
4571 **
@@ -4827,11 +4902,12 @@
4827 ** files from within the check-out.
4828 */
4829 /*
4830 ** SETTING: pgp-command width=40 sensitive
4831 ** Command used to clear-sign manifests at check-in.
4832 ** Default value is "gpg --clearsign -o"
 
4833 */
4834 /*
4835 ** SETTING: proxy width=32 default=system
4836 ** URL of the HTTP proxy. If undefined or "system", the "http_proxy"
4837 ** environment variable is consulted. If "off", a direct HTTP connection is
4838
--- src/db.c
+++ src/db.c
@@ -170,10 +170,12 @@
170 void *pAuthArg; /* Argument to the authorizer */
171 const char *zAuthName; /* Name of the authorizer */
172 int bProtectTriggers; /* True if protection triggers already exist */
173 int nProtect; /* Slots of aProtect used */
174 unsigned aProtect[12]; /* Saved values of protectMask */
175 int pauseDmlLog; /* Ignore pDmlLog if positive */
176 Blob *pDmlLog; /* Append DML statements here, of not NULL */
177 } db = {
178 PROTECT_USER|PROTECT_CONFIG|PROTECT_BASELINE, /* protectMask */
179 0, 0, 0, 0, 0, 0, 0, {{0}}, {0}, {0}, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0}};
180
181 /*
@@ -643,10 +645,43 @@
645 */
646 #define DB_PREPARE_IGNORE_ERROR 0x001 /* Suppress errors */
647 #define DB_PREPARE_PERSISTENT 0x002 /* Stmt will stick around for a while */
648 #endif
649
650 /*
651 ** If zSql is a DML statement, append it db.pDmlLog.
652 */
653 static void db_append_dml(const char *zSql){
654 size_t nSql;
655 if( db.pDmlLog==0 ) return;
656 if( db.pauseDmlLog ) return;
657 if( zSql==0 ) return;
658 nSql = strlen(zSql);
659 while( nSql>0 && fossil_isspace(zSql[0]) ){ nSql--; zSql++; }
660 while( nSql>0 && fossil_isspace(zSql[nSql-1]) ) nSql--;
661 if( nSql<6 ) return;
662 if( fossil_strnicmp(zSql, "SELECT", 6)==0 ) return;
663 if( fossil_strnicmp(zSql, "PRAGMA", 6)==0 ) return;
664 blob_append(db.pDmlLog, zSql, nSql);
665 if( zSql[nSql-1]!=';' ) blob_append_char(db.pDmlLog, ';');
666 blob_append_char(db.pDmlLog, '\n');
667 }
668
669 /*
670 ** Set the Blob to which DML statement text should be appended. Set it
671 ** to zero to stop appending DML statement text.
672 */
673 void db_append_dml_to_blob(Blob *pBlob){
674 db.pDmlLog = pBlob;
675 }
676
677 /*
678 ** Pause or unpause the DML log
679 */
680 void db_pause_dml_log(void){ db.pauseDmlLog++; }
681 void db_unpause_dml_log(void){ db.pauseDmlLog--; }
682
683 /*
684 ** Prepare a Stmt. Assume that the Stmt is previously uninitialized.
685 ** If the input string contains multiple SQL statements, only the first
686 ** one is processed. All statements beyond the first are silently ignored.
687 */
@@ -658,10 +693,11 @@
693 blob_zero(&pStmt->sql);
694 blob_vappendf(&pStmt->sql, zFormat, ap);
695 va_end(ap);
696 zSql = blob_str(&pStmt->sql);
697 db.nPrepare++;
698 db_append_dml(zSql);
699 if( flags & DB_PREPARE_PERSISTENT ){
700 prepFlags = SQLITE_PREPARE_PERSISTENT;
701 }
702 rc = sqlite3_prepare_v3(g.db, zSql, -1, prepFlags, &pStmt->pStmt, &zExtra);
703 if( rc!=0 && (flags & DB_PREPARE_IGNORE_ERROR)==0 ){
@@ -1047,10 +1083,11 @@
1083 rc = sqlite3_prepare_v2(g.db, z, -1, &pStmt, &zEnd);
1084 if( rc ){
1085 db_err("%s: {%s}", sqlite3_errmsg(g.db), z);
1086 }else if( pStmt ){
1087 db.nPrepare++;
1088 db_append_dml(sqlite3_sql(pStmt));
1089 while( sqlite3_step(pStmt)==SQLITE_ROW ){}
1090 rc = sqlite3_finalize(pStmt);
1091 if( rc ) db_err("%s: {%.*s}", sqlite3_errmsg(g.db), (int)(zEnd-z), z);
1092 }
1093 z = zEnd;
@@ -1312,10 +1349,50 @@
1349 sqlite3_result_int64(context, rid);
1350 }
1351 }
1352 }
1353
1354
1355 /*
1356 ** SETTING: timeline-utc boolean default=on
1357 **
1358 ** If the timeline-utc setting is true, then Fossil tries to understand
1359 ** and display all time values using UTC. If this setting is false, Fossil
1360 ** tries to understand and display time values using the local timezone.
1361 **
1362 ** The word "timeline" in the name of this setting is historical.
1363 ** This setting applies to all user interfaces of Fossil,
1364 ** not just the timeline.
1365 **
1366 ** Note that when accessing Fossil using the web interface, the localtime
1367 ** used is the localtime on the server, not on the client.
1368 */
1369 /*
1370 ** Return true if Fossil is set to display times as UTC. Return false
1371 ** if it wants to display times using the local timezone.
1372 **
1373 ** False is returned if display is set to localtime even if the localtime
1374 ** happens to be the same as UTC.
1375 */
1376 int fossil_ui_utctime(void){
1377 if( g.fTimeFormat==0 ){
1378 if( db_get_int("timeline-utc", 1) ){
1379 g.fTimeFormat = 1; /* UTC */
1380 }else{
1381 g.fTimeFormat = 2; /* Localtime */
1382 }
1383 }
1384 return g.fTimeFormat==1;
1385 }
1386
1387 /*
1388 ** Return true if Fossil is set to display times using the local timezone.
1389 */
1390 int fossil_ui_localtime(void){
1391 return fossil_ui_utctime()==0;
1392 }
1393
1394 /*
1395 ** The toLocal() SQL function returns a string that is an argument to a
1396 ** date/time function that is appropriate for modifying the time for display.
1397 ** If UTC time display is selected, no modification occurs. If local time
1398 ** display is selected, the time is adjusted appropriately.
@@ -1327,18 +1404,11 @@
1404 void db_tolocal_function(
1405 sqlite3_context *context,
1406 int argc,
1407 sqlite3_value **argv
1408 ){
1409 if( fossil_ui_utctime() ){
 
 
 
 
 
 
 
1410 sqlite3_result_text(context, "0 seconds", -1, SQLITE_STATIC);
1411 }else{
1412 sqlite3_result_text(context, "localtime", -1, SQLITE_STATIC);
1413 }
1414 }
@@ -1356,18 +1426,11 @@
1426 void db_fromlocal_function(
1427 sqlite3_context *context,
1428 int argc,
1429 sqlite3_value **argv
1430 ){
1431 if( fossil_ui_utctime() ){
 
 
 
 
 
 
 
1432 sqlite3_result_text(context, "0 seconds", -1, SQLITE_STATIC);
1433 }else{
1434 sqlite3_result_text(context, "utc", -1, SQLITE_STATIC);
1435 }
1436 }
@@ -1524,24 +1587,31 @@
1587 ** Register the SQL functions that are useful both to the internal
1588 ** representation and to the "fossil sql" command.
1589 */
1590 void db_add_aux_functions(sqlite3 *db){
1591 sqlite3_create_collation(db, "uintnocase", SQLITE_UTF8,0,uintNocaseCollFunc);
1592 sqlite3_create_function(db, "checkin_mtime", 2,
1593 SQLITE_UTF8|SQLITE_DETERMINISTIC|SQLITE_INNOCUOUS,
1594 0, db_checkin_mtime_function, 0, 0);
1595 sqlite3_create_function(db, "symbolic_name_to_rid", 1,
1596 SQLITE_UTF8|SQLITE_DETERMINISTIC|SQLITE_INNOCUOUS,
1597 0, db_sym2rid_function, 0, 0);
1598 sqlite3_create_function(db, "symbolic_name_to_rid", 2,
1599 SQLITE_UTF8|SQLITE_DETERMINISTIC|SQLITE_INNOCUOUS,
1600 0, db_sym2rid_function, 0, 0);
1601 sqlite3_create_function(db, "now", 0,
1602 SQLITE_UTF8|SQLITE_INNOCUOUS, 0,
1603 db_now_function, 0, 0);
1604 sqlite3_create_function(db, "toLocal", 0,
1605 SQLITE_UTF8|SQLITE_DETERMINISTIC|SQLITE_INNOCUOUS,
1606 0, db_tolocal_function, 0, 0);
1607 sqlite3_create_function(db, "fromLocal", 0,
1608 SQLITE_UTF8|SQLITE_DETERMINISTIC|SQLITE_INNOCUOUS,
1609 0, db_fromlocal_function, 0, 0);
1610 sqlite3_create_function(db, "hextoblob", 1,
1611 SQLITE_UTF8|SQLITE_DETERMINISTIC|SQLITE_INNOCUOUS,
1612 0, db_hextoblob, 0, 0);
1613 sqlite3_create_function(db, "capunion", 1, SQLITE_UTF8, 0,
1614 0, capability_union_step, capability_union_finalize);
1615 sqlite3_create_function(db, "fullcap", 1, SQLITE_UTF8, 0,
1616 capability_fullcap, 0, 0);
1617 sqlite3_create_function(db, "find_emailaddr", 1, SQLITE_UTF8, 0,
@@ -2105,11 +2175,11 @@
2175 sqlite3 *, char **, const sqlite3_api_routines *
2176 );
2177 sqlite3_appendvfs_init(0,0,0);
2178 g.zVfsName = "apndvfs";
2179 }
2180 blob_reset(&bNameCheck);
2181 rc = sqlite3_open_v2(
2182 zDbName, &db,
2183 SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE,
2184 g.zVfsName
2185 );
@@ -2625,13 +2695,18 @@
2695 return res;
2696 }
2697
2698 /*
2699 ** COMMAND: test-is-repo
2700 ** Usage: %fossil test-is-repo FILENAME...
2701 **
2702 ** Test whether the specified files look like a SQLite database
2703 ** containing a Fossil repository schema.
2704 */
2705 void test_is_repo(void){
2706 int i;
2707 verify_all_options();
2708 for(i=2; i<g.argc; i++){
2709 fossil_print("%s: %s\n",
2710 db_looks_like_a_repository(g.argv[i]) ? "yes" : " no",
2711 g.argv[i]
2712 );
@@ -4561,11 +4636,11 @@
4636 ** see https://fossil-scm.org/home/doc/trunk/www/globs.md#syntax
4637 */
4638 /*
4639 ** SETTING: clearsign boolean default=off
4640 ** When enabled, fossil will attempt to sign all commits
4641 ** with gpg or ssh. When disabled, commits will be unsigned.
4642 */
4643 /*
4644 ** SETTING: comment-format width=16 default=1
4645 ** Set the default options for printing timeline comments to the console.
4646 **
@@ -4827,11 +4902,12 @@
4902 ** files from within the check-out.
4903 */
4904 /*
4905 ** SETTING: pgp-command width=40 sensitive
4906 ** Command used to clear-sign manifests at check-in.
4907 ** Default value is "gpg --clearsign -o".
4908 ** For SSH, use e.g. "ssh-keygen -q -Y sign -n fossilscm -f ~/.ssh/id_ed25519"
4909 */
4910 /*
4911 ** SETTING: proxy width=32 default=system
4912 ** URL of the HTTP proxy. If undefined or "system", the "http_proxy"
4913 ** environment variable is consulted. If "off", a direct HTTP connection is
4914
+10 -4
--- src/default.css
+++ src/default.css
@@ -748,10 +748,20 @@
748748
border-bottom: 3px solid gold;
749749
}
750750
body.tkt div.content ol.tkt-changes > li:target > ol {
751751
border-left: 1px solid gold;
752752
}
753
+body.cpage-ckout .file-change-line,
754
+body.cpage-info .file-change-line,
755
+body.cpage-vdiff .file-change-line {
756
+ margin-top: 16px;
757
+ margin-bottom: 16px;
758
+ margin-right: 1em /* keep it from nudging right up against the scrollbar-reveal zone */;
759
+ display: flex;
760
+ flex-direction: row;
761
+ justify-content: space-between;
762
+}
753763
754764
span.modpending {
755765
color: #b03800;
756766
font-style: italic;
757767
}
@@ -1818,14 +1828,10 @@
18181828
}
18191829
body.fossil-dark-style .settings-icon {
18201830
filter: invert(100%);
18211831
}
18221832
1823
-input[type="checkbox"].diff-toggle {
1824
- float: right;
1825
-}
1826
-
18271833
body.branch .brlist > table > tbody > tr:hover:not(.selected),
18281834
body.branch .brlist > table > tbody > tr.selected {
18291835
background-color: #ffc;
18301836
}
18311837
body.branch .brlist > table > tbody td:first-child > input {
18321838
--- src/default.css
+++ src/default.css
@@ -748,10 +748,20 @@
748 border-bottom: 3px solid gold;
749 }
750 body.tkt div.content ol.tkt-changes > li:target > ol {
751 border-left: 1px solid gold;
752 }
 
 
 
 
 
 
 
 
 
 
753
754 span.modpending {
755 color: #b03800;
756 font-style: italic;
757 }
@@ -1818,14 +1828,10 @@
1818 }
1819 body.fossil-dark-style .settings-icon {
1820 filter: invert(100%);
1821 }
1822
1823 input[type="checkbox"].diff-toggle {
1824 float: right;
1825 }
1826
1827 body.branch .brlist > table > tbody > tr:hover:not(.selected),
1828 body.branch .brlist > table > tbody > tr.selected {
1829 background-color: #ffc;
1830 }
1831 body.branch .brlist > table > tbody td:first-child > input {
1832
--- src/default.css
+++ src/default.css
@@ -748,10 +748,20 @@
748 border-bottom: 3px solid gold;
749 }
750 body.tkt div.content ol.tkt-changes > li:target > ol {
751 border-left: 1px solid gold;
752 }
753 body.cpage-ckout .file-change-line,
754 body.cpage-info .file-change-line,
755 body.cpage-vdiff .file-change-line {
756 margin-top: 16px;
757 margin-bottom: 16px;
758 margin-right: 1em /* keep it from nudging right up against the scrollbar-reveal zone */;
759 display: flex;
760 flex-direction: row;
761 justify-content: space-between;
762 }
763
764 span.modpending {
765 color: #b03800;
766 font-style: italic;
767 }
@@ -1818,14 +1828,10 @@
1828 }
1829 body.fossil-dark-style .settings-icon {
1830 filter: invert(100%);
1831 }
1832
 
 
 
 
1833 body.branch .brlist > table > tbody > tr:hover:not(.selected),
1834 body.branch .brlist > table > tbody > tr.selected {
1835 background-color: #ffc;
1836 }
1837 body.branch .brlist > table > tbody td:first-child > input {
1838
+10 -4
--- src/default.css
+++ src/default.css
@@ -748,10 +748,20 @@
748748
border-bottom: 3px solid gold;
749749
}
750750
body.tkt div.content ol.tkt-changes > li:target > ol {
751751
border-left: 1px solid gold;
752752
}
753
+body.cpage-ckout .file-change-line,
754
+body.cpage-info .file-change-line,
755
+body.cpage-vdiff .file-change-line {
756
+ margin-top: 16px;
757
+ margin-bottom: 16px;
758
+ margin-right: 1em /* keep it from nudging right up against the scrollbar-reveal zone */;
759
+ display: flex;
760
+ flex-direction: row;
761
+ justify-content: space-between;
762
+}
753763
754764
span.modpending {
755765
color: #b03800;
756766
font-style: italic;
757767
}
@@ -1818,14 +1828,10 @@
18181828
}
18191829
body.fossil-dark-style .settings-icon {
18201830
filter: invert(100%);
18211831
}
18221832
1823
-input[type="checkbox"].diff-toggle {
1824
- float: right;
1825
-}
1826
-
18271833
body.branch .brlist > table > tbody > tr:hover:not(.selected),
18281834
body.branch .brlist > table > tbody > tr.selected {
18291835
background-color: #ffc;
18301836
}
18311837
body.branch .brlist > table > tbody td:first-child > input {
18321838
--- src/default.css
+++ src/default.css
@@ -748,10 +748,20 @@
748 border-bottom: 3px solid gold;
749 }
750 body.tkt div.content ol.tkt-changes > li:target > ol {
751 border-left: 1px solid gold;
752 }
 
 
 
 
 
 
 
 
 
 
753
754 span.modpending {
755 color: #b03800;
756 font-style: italic;
757 }
@@ -1818,14 +1828,10 @@
1818 }
1819 body.fossil-dark-style .settings-icon {
1820 filter: invert(100%);
1821 }
1822
1823 input[type="checkbox"].diff-toggle {
1824 float: right;
1825 }
1826
1827 body.branch .brlist > table > tbody > tr:hover:not(.selected),
1828 body.branch .brlist > table > tbody > tr.selected {
1829 background-color: #ffc;
1830 }
1831 body.branch .brlist > table > tbody td:first-child > input {
1832
--- src/default.css
+++ src/default.css
@@ -748,10 +748,20 @@
748 border-bottom: 3px solid gold;
749 }
750 body.tkt div.content ol.tkt-changes > li:target > ol {
751 border-left: 1px solid gold;
752 }
753 body.cpage-ckout .file-change-line,
754 body.cpage-info .file-change-line,
755 body.cpage-vdiff .file-change-line {
756 margin-top: 16px;
757 margin-bottom: 16px;
758 margin-right: 1em /* keep it from nudging right up against the scrollbar-reveal zone */;
759 display: flex;
760 flex-direction: row;
761 justify-content: space-between;
762 }
763
764 span.modpending {
765 color: #b03800;
766 font-style: italic;
767 }
@@ -1818,14 +1828,10 @@
1828 }
1829 body.fossil-dark-style .settings-icon {
1830 filter: invert(100%);
1831 }
1832
 
 
 
 
1833 body.branch .brlist > table > tbody > tr:hover:not(.selected),
1834 body.branch .brlist > table > tbody > tr.selected {
1835 background-color: #ffc;
1836 }
1837 body.branch .brlist > table > tbody td:first-child > input {
1838
+49 -39
--- src/descendants.c
+++ src/descendants.c
@@ -202,29 +202,28 @@
202202
rLimitMtime = db_double(0.0,
203203
"SELECT mtime FROM event WHERE objid=%d",
204204
ridBackTo);
205205
}
206206
db_multi_exec(
207
- "WITH RECURSIVE "
208
- " parent(pid,cid,isCP) AS ("
209
- " SELECT plink.pid, plink.cid, 0 AS xisCP FROM plink"
210
- " UNION ALL"
211
- " SELECT parentid, childid, 1 FROM cherrypick WHERE NOT isExclude"
212
- " ),"
213
- " ancestor(rid, mtime, isCP) AS ("
214
- " SELECT %d, mtime, 0 FROM event WHERE objid=%d "
215
- " UNION "
216
- " SELECT parent.pid, event.mtime, parent.isCP"
217
- " FROM ancestor, parent, event"
218
- " WHERE parent.cid=ancestor.rid"
219
- " AND event.objid=parent.pid"
220
- " AND NOT ancestor.isCP"
221
- " AND (event.mtime>=%.17g OR parent.pid=%d)"
222
- " ORDER BY mtime DESC LIMIT %d"
223
- " )"
224
- "INSERT OR IGNORE INTO ok"
225
- " SELECT rid FROM ancestor;",
207
+ "WITH RECURSIVE\n"
208
+ " parent(pid,cid,isCP) AS (\n"
209
+ " SELECT plink.pid, plink.cid, 0 AS xisCP FROM plink\n"
210
+ " UNION ALL\n"
211
+ " SELECT parentid, childid, 1 FROM cherrypick WHERE NOT isExclude\n"
212
+ " ),\n"
213
+ " ancestor(rid, mtime, isCP) AS (\n"
214
+ " SELECT %d, mtime, 0 FROM event WHERE objid=%d\n"
215
+ " UNION\n"
216
+ " SELECT parent.pid, event.mtime, parent.isCP\n"
217
+ " FROM ancestor, parent, event\n"
218
+ " WHERE parent.cid=ancestor.rid\n"
219
+ " AND event.objid=parent.pid\n"
220
+ " AND NOT ancestor.isCP\n"
221
+ " AND (event.mtime>=%.17g OR parent.pid=%d)\n"
222
+ " ORDER BY mtime DESC LIMIT %d\n"
223
+ " )\n"
224
+ "INSERT OR IGNORE INTO ok SELECT rid FROM ancestor;",
226225
rid, rid, rLimitMtime, ridBackTo, N
227226
);
228227
if( ridBackTo && db_changes()>1 ){
229228
db_multi_exec("INSERT OR IGNORE INTO ok VALUES(%d)", ridBackTo);
230229
}
@@ -322,18 +321,18 @@
322321
N = -1;
323322
}else if( N<0 ){
324323
N = -N;
325324
}
326325
db_multi_exec(
327
- "WITH RECURSIVE"
328
- " dx(rid,mtime) AS ("
329
- " SELECT %d, 0"
330
- " UNION"
331
- " SELECT plink.cid, plink.mtime FROM dx, plink"
332
- " WHERE plink.pid=dx.rid"
333
- " ORDER BY 2"
334
- " )"
326
+ "WITH RECURSIVE\n"
327
+ " dx(rid,mtime) AS (\n"
328
+ " SELECT %d, 0\n"
329
+ " UNION\n"
330
+ " SELECT plink.cid, plink.mtime FROM dx, plink\n"
331
+ " WHERE plink.pid=dx.rid\n"
332
+ " ORDER BY 2\n"
333
+ " )\n"
335334
"INSERT OR IGNORE INTO ok SELECT rid FROM dx LIMIT %d",
336335
rid, N
337336
);
338337
}
339338
@@ -639,44 +638,56 @@
639638
/* Flag parameters to compute_uses_file() */
640639
#define USESFILE_DELETE 0x01 /* Include the check-ins where file deleted */
641640
642641
#endif
643642
643
+/*
644
+** Append a new VALUES term.
645
+*/
646
+static void uses_file_append_term(Blob *pSql, int *pnCnt, int rid){
647
+ if( *pnCnt==0 ){
648
+ blob_append_sql(pSql, "(%d)", rid);
649
+ *pnCnt = 4;
650
+ }else if( (*pnCnt)%10==9 ){
651
+ blob_append_sql(pSql, ",\n (%d)", rid);
652
+ }else{
653
+ blob_append_sql(pSql, ",(%d)", rid);
654
+ }
655
+ ++*pnCnt;
656
+}
657
+
644658
645659
/*
646660
** Add to table zTab the record ID (rid) of every check-in that contains
647661
** the file fid.
648662
*/
649663
void compute_uses_file(const char *zTab, int fid, int usesFlags){
650664
Bag seen;
651665
Bag pending;
652
- Stmt ins;
666
+ Blob ins = BLOB_INITIALIZER;
667
+ int nIns = 0;
653668
Stmt q;
654669
int rid;
655670
656671
bag_init(&seen);
657672
bag_init(&pending);
658
- db_prepare(&ins, "INSERT OR IGNORE INTO \"%w\" VALUES(:rid)", zTab);
673
+ blob_append_sql(&ins, "INSERT OR IGNORE INTO \"%w\" VALUES", zTab);
659674
db_prepare(&q, "SELECT mid FROM mlink WHERE fid=%d", fid);
660675
while( db_step(&q)==SQLITE_ROW ){
661676
int mid = db_column_int(&q, 0);
662677
bag_insert(&pending, mid);
663678
bag_insert(&seen, mid);
664
- db_bind_int(&ins, ":rid", mid);
665
- db_step(&ins);
666
- db_reset(&ins);
679
+ uses_file_append_term(&ins, &nIns, mid);
667680
}
668681
db_finalize(&q);
669682
670683
db_prepare(&q, "SELECT mid FROM mlink WHERE pid=%d", fid);
671684
while( db_step(&q)==SQLITE_ROW ){
672685
int mid = db_column_int(&q, 0);
673686
bag_insert(&seen, mid);
674687
if( usesFlags & USESFILE_DELETE ){
675
- db_bind_int(&ins, ":rid", mid);
676
- db_step(&ins);
677
- db_reset(&ins);
688
+ uses_file_append_term(&ins, &nIns, mid);
678689
}
679690
}
680691
db_finalize(&q);
681692
db_prepare(&q, "SELECT cid FROM plink WHERE pid=:rid AND isprim");
682693
@@ -686,16 +697,15 @@
686697
while( db_step(&q)==SQLITE_ROW ){
687698
int mid = db_column_int(&q, 0);
688699
if( bag_find(&seen, mid) ) continue;
689700
bag_insert(&seen, mid);
690701
bag_insert(&pending, mid);
691
- db_bind_int(&ins, ":rid", mid);
692
- db_step(&ins);
693
- db_reset(&ins);
702
+ uses_file_append_term(&ins, &nIns, mid);
694703
}
695704
db_reset(&q);
696705
}
697706
db_finalize(&q);
698
- db_finalize(&ins);
707
+ db_exec_sql(blob_str(&ins));
708
+ blob_reset(&ins);
699709
bag_clear(&seen);
700710
bag_clear(&pending);
701711
}
702712
--- src/descendants.c
+++ src/descendants.c
@@ -202,29 +202,28 @@
202 rLimitMtime = db_double(0.0,
203 "SELECT mtime FROM event WHERE objid=%d",
204 ridBackTo);
205 }
206 db_multi_exec(
207 "WITH RECURSIVE "
208 " parent(pid,cid,isCP) AS ("
209 " SELECT plink.pid, plink.cid, 0 AS xisCP FROM plink"
210 " UNION ALL"
211 " SELECT parentid, childid, 1 FROM cherrypick WHERE NOT isExclude"
212 " ),"
213 " ancestor(rid, mtime, isCP) AS ("
214 " SELECT %d, mtime, 0 FROM event WHERE objid=%d "
215 " UNION "
216 " SELECT parent.pid, event.mtime, parent.isCP"
217 " FROM ancestor, parent, event"
218 " WHERE parent.cid=ancestor.rid"
219 " AND event.objid=parent.pid"
220 " AND NOT ancestor.isCP"
221 " AND (event.mtime>=%.17g OR parent.pid=%d)"
222 " ORDER BY mtime DESC LIMIT %d"
223 " )"
224 "INSERT OR IGNORE INTO ok"
225 " SELECT rid FROM ancestor;",
226 rid, rid, rLimitMtime, ridBackTo, N
227 );
228 if( ridBackTo && db_changes()>1 ){
229 db_multi_exec("INSERT OR IGNORE INTO ok VALUES(%d)", ridBackTo);
230 }
@@ -322,18 +321,18 @@
322 N = -1;
323 }else if( N<0 ){
324 N = -N;
325 }
326 db_multi_exec(
327 "WITH RECURSIVE"
328 " dx(rid,mtime) AS ("
329 " SELECT %d, 0"
330 " UNION"
331 " SELECT plink.cid, plink.mtime FROM dx, plink"
332 " WHERE plink.pid=dx.rid"
333 " ORDER BY 2"
334 " )"
335 "INSERT OR IGNORE INTO ok SELECT rid FROM dx LIMIT %d",
336 rid, N
337 );
338 }
339
@@ -639,44 +638,56 @@
639 /* Flag parameters to compute_uses_file() */
640 #define USESFILE_DELETE 0x01 /* Include the check-ins where file deleted */
641
642 #endif
643
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
644
645 /*
646 ** Add to table zTab the record ID (rid) of every check-in that contains
647 ** the file fid.
648 */
649 void compute_uses_file(const char *zTab, int fid, int usesFlags){
650 Bag seen;
651 Bag pending;
652 Stmt ins;
 
653 Stmt q;
654 int rid;
655
656 bag_init(&seen);
657 bag_init(&pending);
658 db_prepare(&ins, "INSERT OR IGNORE INTO \"%w\" VALUES(:rid)", zTab);
659 db_prepare(&q, "SELECT mid FROM mlink WHERE fid=%d", fid);
660 while( db_step(&q)==SQLITE_ROW ){
661 int mid = db_column_int(&q, 0);
662 bag_insert(&pending, mid);
663 bag_insert(&seen, mid);
664 db_bind_int(&ins, ":rid", mid);
665 db_step(&ins);
666 db_reset(&ins);
667 }
668 db_finalize(&q);
669
670 db_prepare(&q, "SELECT mid FROM mlink WHERE pid=%d", fid);
671 while( db_step(&q)==SQLITE_ROW ){
672 int mid = db_column_int(&q, 0);
673 bag_insert(&seen, mid);
674 if( usesFlags & USESFILE_DELETE ){
675 db_bind_int(&ins, ":rid", mid);
676 db_step(&ins);
677 db_reset(&ins);
678 }
679 }
680 db_finalize(&q);
681 db_prepare(&q, "SELECT cid FROM plink WHERE pid=:rid AND isprim");
682
@@ -686,16 +697,15 @@
686 while( db_step(&q)==SQLITE_ROW ){
687 int mid = db_column_int(&q, 0);
688 if( bag_find(&seen, mid) ) continue;
689 bag_insert(&seen, mid);
690 bag_insert(&pending, mid);
691 db_bind_int(&ins, ":rid", mid);
692 db_step(&ins);
693 db_reset(&ins);
694 }
695 db_reset(&q);
696 }
697 db_finalize(&q);
698 db_finalize(&ins);
 
699 bag_clear(&seen);
700 bag_clear(&pending);
701 }
702
--- src/descendants.c
+++ src/descendants.c
@@ -202,29 +202,28 @@
202 rLimitMtime = db_double(0.0,
203 "SELECT mtime FROM event WHERE objid=%d",
204 ridBackTo);
205 }
206 db_multi_exec(
207 "WITH RECURSIVE\n"
208 " parent(pid,cid,isCP) AS (\n"
209 " SELECT plink.pid, plink.cid, 0 AS xisCP FROM plink\n"
210 " UNION ALL\n"
211 " SELECT parentid, childid, 1 FROM cherrypick WHERE NOT isExclude\n"
212 " ),\n"
213 " ancestor(rid, mtime, isCP) AS (\n"
214 " SELECT %d, mtime, 0 FROM event WHERE objid=%d\n"
215 " UNION\n"
216 " SELECT parent.pid, event.mtime, parent.isCP\n"
217 " FROM ancestor, parent, event\n"
218 " WHERE parent.cid=ancestor.rid\n"
219 " AND event.objid=parent.pid\n"
220 " AND NOT ancestor.isCP\n"
221 " AND (event.mtime>=%.17g OR parent.pid=%d)\n"
222 " ORDER BY mtime DESC LIMIT %d\n"
223 " )\n"
224 "INSERT OR IGNORE INTO ok SELECT rid FROM ancestor;",
 
225 rid, rid, rLimitMtime, ridBackTo, N
226 );
227 if( ridBackTo && db_changes()>1 ){
228 db_multi_exec("INSERT OR IGNORE INTO ok VALUES(%d)", ridBackTo);
229 }
@@ -322,18 +321,18 @@
321 N = -1;
322 }else if( N<0 ){
323 N = -N;
324 }
325 db_multi_exec(
326 "WITH RECURSIVE\n"
327 " dx(rid,mtime) AS (\n"
328 " SELECT %d, 0\n"
329 " UNION\n"
330 " SELECT plink.cid, plink.mtime FROM dx, plink\n"
331 " WHERE plink.pid=dx.rid\n"
332 " ORDER BY 2\n"
333 " )\n"
334 "INSERT OR IGNORE INTO ok SELECT rid FROM dx LIMIT %d",
335 rid, N
336 );
337 }
338
@@ -639,44 +638,56 @@
638 /* Flag parameters to compute_uses_file() */
639 #define USESFILE_DELETE 0x01 /* Include the check-ins where file deleted */
640
641 #endif
642
643 /*
644 ** Append a new VALUES term.
645 */
646 static void uses_file_append_term(Blob *pSql, int *pnCnt, int rid){
647 if( *pnCnt==0 ){
648 blob_append_sql(pSql, "(%d)", rid);
649 *pnCnt = 4;
650 }else if( (*pnCnt)%10==9 ){
651 blob_append_sql(pSql, ",\n (%d)", rid);
652 }else{
653 blob_append_sql(pSql, ",(%d)", rid);
654 }
655 ++*pnCnt;
656 }
657
658
659 /*
660 ** Add to table zTab the record ID (rid) of every check-in that contains
661 ** the file fid.
662 */
663 void compute_uses_file(const char *zTab, int fid, int usesFlags){
664 Bag seen;
665 Bag pending;
666 Blob ins = BLOB_INITIALIZER;
667 int nIns = 0;
668 Stmt q;
669 int rid;
670
671 bag_init(&seen);
672 bag_init(&pending);
673 blob_append_sql(&ins, "INSERT OR IGNORE INTO \"%w\" VALUES", zTab);
674 db_prepare(&q, "SELECT mid FROM mlink WHERE fid=%d", fid);
675 while( db_step(&q)==SQLITE_ROW ){
676 int mid = db_column_int(&q, 0);
677 bag_insert(&pending, mid);
678 bag_insert(&seen, mid);
679 uses_file_append_term(&ins, &nIns, mid);
 
 
680 }
681 db_finalize(&q);
682
683 db_prepare(&q, "SELECT mid FROM mlink WHERE pid=%d", fid);
684 while( db_step(&q)==SQLITE_ROW ){
685 int mid = db_column_int(&q, 0);
686 bag_insert(&seen, mid);
687 if( usesFlags & USESFILE_DELETE ){
688 uses_file_append_term(&ins, &nIns, mid);
 
 
689 }
690 }
691 db_finalize(&q);
692 db_prepare(&q, "SELECT cid FROM plink WHERE pid=:rid AND isprim");
693
@@ -686,16 +697,15 @@
697 while( db_step(&q)==SQLITE_ROW ){
698 int mid = db_column_int(&q, 0);
699 if( bag_find(&seen, mid) ) continue;
700 bag_insert(&seen, mid);
701 bag_insert(&pending, mid);
702 uses_file_append_term(&ins, &nIns, mid);
 
 
703 }
704 db_reset(&q);
705 }
706 db_finalize(&q);
707 db_exec_sql(blob_str(&ins));
708 blob_reset(&ins);
709 bag_clear(&seen);
710 bag_clear(&pending);
711 }
712
+9
--- src/diff.c
+++ src/diff.c
@@ -3227,20 +3227,29 @@
32273227
** Initialize the DiffConfig object using command-line options.
32283228
**
32293229
** Process diff-related command-line options and return an appropriate
32303230
** "diffFlags" integer.
32313231
**
3232
+** -b|--browser Show the diff output in a web-browser
32323233
** --brief Show filenames only DIFF_BRIEF
3234
+** --by Shorthand for "--browser -y"
32333235
** -c|--context N N lines of context. nContext
3236
+** --dark Use dark mode for Tcl/Tk and HTML output
32343237
** --html Format for HTML DIFF_HTML
3238
+** -i|--internal Use built-in diff, not an external tool
32353239
** --invert Invert the diff DIFF_INVERT
3240
+** --json Output formatted as JSON
32363241
** -n|--linenum Show line numbers DIFF_LINENO
3242
+** -N|--new-file Alias for --verbose
32373243
** --noopt Disable optimization DIFF_NOOPT
32383244
** --numstat Show change counts DIFF_NUMSTAT
32393245
** --strip-trailing-cr Strip trailing CR DIFF_STRIP_EOLCR
3246
+** --tcl Tcl-formatted output used internally by --tk
32403247
** --unified Unified diff. ~DIFF_SIDEBYSIDE
3248
+** -v|--verbose Show complete text of added or deleted files
32413249
** -w|--ignore-all-space Ignore all whitespaces DIFF_IGNORE_ALLWS
3250
+** --webpage Format output as a stand-alone HTML webpage
32423251
** -W|--width N N character lines. wColumn
32433252
** -y|--side-by-side Side-by-side diff. DIFF_SIDEBYSIDE
32443253
** -Z|--ignore-trailing-space Ignore eol-whitespaces DIFF_IGNORE_EOLWS
32453254
*/
32463255
void diff_options(DiffConfig *pCfg, int isGDiff, int bUnifiedTextOnly){
32473256
--- src/diff.c
+++ src/diff.c
@@ -3227,20 +3227,29 @@
3227 ** Initialize the DiffConfig object using command-line options.
3228 **
3229 ** Process diff-related command-line options and return an appropriate
3230 ** "diffFlags" integer.
3231 **
 
3232 ** --brief Show filenames only DIFF_BRIEF
 
3233 ** -c|--context N N lines of context. nContext
 
3234 ** --html Format for HTML DIFF_HTML
 
3235 ** --invert Invert the diff DIFF_INVERT
 
3236 ** -n|--linenum Show line numbers DIFF_LINENO
 
3237 ** --noopt Disable optimization DIFF_NOOPT
3238 ** --numstat Show change counts DIFF_NUMSTAT
3239 ** --strip-trailing-cr Strip trailing CR DIFF_STRIP_EOLCR
 
3240 ** --unified Unified diff. ~DIFF_SIDEBYSIDE
 
3241 ** -w|--ignore-all-space Ignore all whitespaces DIFF_IGNORE_ALLWS
 
3242 ** -W|--width N N character lines. wColumn
3243 ** -y|--side-by-side Side-by-side diff. DIFF_SIDEBYSIDE
3244 ** -Z|--ignore-trailing-space Ignore eol-whitespaces DIFF_IGNORE_EOLWS
3245 */
3246 void diff_options(DiffConfig *pCfg, int isGDiff, int bUnifiedTextOnly){
3247
--- src/diff.c
+++ src/diff.c
@@ -3227,20 +3227,29 @@
3227 ** Initialize the DiffConfig object using command-line options.
3228 **
3229 ** Process diff-related command-line options and return an appropriate
3230 ** "diffFlags" integer.
3231 **
3232 ** -b|--browser Show the diff output in a web-browser
3233 ** --brief Show filenames only DIFF_BRIEF
3234 ** --by Shorthand for "--browser -y"
3235 ** -c|--context N N lines of context. nContext
3236 ** --dark Use dark mode for Tcl/Tk and HTML output
3237 ** --html Format for HTML DIFF_HTML
3238 ** -i|--internal Use built-in diff, not an external tool
3239 ** --invert Invert the diff DIFF_INVERT
3240 ** --json Output formatted as JSON
3241 ** -n|--linenum Show line numbers DIFF_LINENO
3242 ** -N|--new-file Alias for --verbose
3243 ** --noopt Disable optimization DIFF_NOOPT
3244 ** --numstat Show change counts DIFF_NUMSTAT
3245 ** --strip-trailing-cr Strip trailing CR DIFF_STRIP_EOLCR
3246 ** --tcl Tcl-formatted output used internally by --tk
3247 ** --unified Unified diff. ~DIFF_SIDEBYSIDE
3248 ** -v|--verbose Show complete text of added or deleted files
3249 ** -w|--ignore-all-space Ignore all whitespaces DIFF_IGNORE_ALLWS
3250 ** --webpage Format output as a stand-alone HTML webpage
3251 ** -W|--width N N character lines. wColumn
3252 ** -y|--side-by-side Side-by-side diff. DIFF_SIDEBYSIDE
3253 ** -Z|--ignore-trailing-space Ignore eol-whitespaces DIFF_IGNORE_EOLWS
3254 */
3255 void diff_options(DiffConfig *pCfg, int isGDiff, int bUnifiedTextOnly){
3256
+5 -1
--- src/diff.tcl
+++ src/diff.tcl
@@ -110,11 +110,15 @@
110110
111111
set fromIndex [lsearch -glob $fossilcmd *-from]
112112
set toIndex [lsearch -glob $fossilcmd *-to]
113113
set branchIndex [lsearch -glob $fossilcmd *-branch]
114114
set checkinIndex [lsearch -glob $fossilcmd *-checkin]
115
- set fA {base check-in}
115
+ if {[string match *?--external-baseline* $fossilcmd]} {
116
+ set fA {external baseline}
117
+ } else {
118
+ set fA {base check-in}
119
+ }
116120
set fB {current check-out}
117121
if {$fromIndex > -1} {set fA [lindex $fossilcmd $fromIndex+1]}
118122
if {$toIndex > -1} {set fB [lindex $fossilcmd $toIndex+1]}
119123
if {$branchIndex > -1} {set fA "branch point"; set fB "leaf of branch '[lindex $fossilcmd $branchIndex+1]'"}
120124
if {$checkinIndex > -1} {set fA "primary parent"; set fB [lindex $fossilcmd $checkinIndex+1]}
121125
--- src/diff.tcl
+++ src/diff.tcl
@@ -110,11 +110,15 @@
110
111 set fromIndex [lsearch -glob $fossilcmd *-from]
112 set toIndex [lsearch -glob $fossilcmd *-to]
113 set branchIndex [lsearch -glob $fossilcmd *-branch]
114 set checkinIndex [lsearch -glob $fossilcmd *-checkin]
115 set fA {base check-in}
 
 
 
 
116 set fB {current check-out}
117 if {$fromIndex > -1} {set fA [lindex $fossilcmd $fromIndex+1]}
118 if {$toIndex > -1} {set fB [lindex $fossilcmd $toIndex+1]}
119 if {$branchIndex > -1} {set fA "branch point"; set fB "leaf of branch '[lindex $fossilcmd $branchIndex+1]'"}
120 if {$checkinIndex > -1} {set fA "primary parent"; set fB [lindex $fossilcmd $checkinIndex+1]}
121
--- src/diff.tcl
+++ src/diff.tcl
@@ -110,11 +110,15 @@
110
111 set fromIndex [lsearch -glob $fossilcmd *-from]
112 set toIndex [lsearch -glob $fossilcmd *-to]
113 set branchIndex [lsearch -glob $fossilcmd *-branch]
114 set checkinIndex [lsearch -glob $fossilcmd *-checkin]
115 if {[string match *?--external-baseline* $fossilcmd]} {
116 set fA {external baseline}
117 } else {
118 set fA {base check-in}
119 }
120 set fB {current check-out}
121 if {$fromIndex > -1} {set fA [lindex $fossilcmd $fromIndex+1]}
122 if {$toIndex > -1} {set fB [lindex $fossilcmd $toIndex+1]}
123 if {$branchIndex > -1} {set fA "branch point"; set fB "leaf of branch '[lindex $fossilcmd $branchIndex+1]'"}
124 if {$checkinIndex > -1} {set fA "primary parent"; set fB [lindex $fossilcmd $checkinIndex+1]}
125
+92 -16
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -803,26 +803,27 @@
803803
blob_reset(&file);
804804
return rc;
805805
}
806806
807807
/*
808
-** Run a diff between the version zFrom and files on disk. zFrom might
809
-** be NULL which means to simply show the difference between the edited
810
-** files on disk and the check-out on which they are based.
808
+** Run a diff between the version zFrom and files on disk in the current
809
+** working checkout. zFrom might be NULL which means to simply show the
810
+** difference between the edited files on disk and the check-out on which
811
+** they are based.
811812
**
812813
** Use the internal diff logic if zDiffCmd is NULL. Otherwise call the
813814
** command zDiffCmd to do the diffing.
814815
**
815816
** When using an external diff program, zBinGlob contains the GLOB patterns
816817
** for file names to treat as binary. If fIncludeBinary is zero, these files
817818
** will be skipped in addition to files that may contain binary content.
818819
*/
819
-void diff_against_disk(
820
+void diff_version_to_checkout(
820821
const char *zFrom, /* Version to difference from */
821822
DiffConfig *pCfg, /* Flags controlling diff output */
822823
FileDirList *pFileDir, /* Which files to diff */
823
- Blob *pOut /* Blob to output diff instead of stdout */
824
+ Blob *pOut /* Blob to output diff instead of stdout */
824825
){
825826
int vid;
826827
Blob sql;
827828
Stmt q;
828829
int asNewFile; /* Treat non-existant files as empty files */
@@ -947,20 +948,20 @@
947948
db_finalize(&q);
948949
db_end_transaction(1); /* ROLLBACK */
949950
}
950951
951952
/*
952
-** Run a diff between the undo buffer and files on disk.
953
+** Run a diff from the undo buffer to files on disk.
953954
**
954955
** Use the internal diff logic if zDiffCmd is NULL. Otherwise call the
955956
** command zDiffCmd to do the diffing.
956957
**
957958
** When using an external diff program, zBinGlob contains the GLOB patterns
958959
** for file names to treat as binary. If fIncludeBinary is zero, these files
959960
** will be skipped in addition to files that may contain binary content.
960961
*/
961
-static void diff_against_undo(
962
+static void diff_undo_to_checkout(
962963
DiffConfig *pCfg, /* Flags controlling diff output */
963964
FileDirList *pFileDir /* List of files and directories to diff */
964965
){
965966
Stmt q;
966967
Blob content;
@@ -1107,10 +1108,67 @@
11071108
}
11081109
}
11091110
manifest_destroy(pFrom);
11101111
manifest_destroy(pTo);
11111112
}
1113
+
1114
+/*
1115
+** Compute the difference from an external tree of files to the current
1116
+** working checkout with its edits.
1117
+**
1118
+** To put it another way: Every managed file in the current working
1119
+** checkout is compared to the file with same name under zExternBase. The
1120
+** zExternBase files are on the left and the files in the current working
1121
+** directory are on the right.
1122
+*/
1123
+void diff_externbase_to_checkout(
1124
+ const char *zExternBase, /* Remote tree to use as the baseline */
1125
+ DiffConfig *pCfg, /* Diff settings */
1126
+ FileDirList *pFileDir /* Only look at these files */
1127
+){
1128
+ int vid;
1129
+ Stmt q;
1130
+
1131
+ vid = db_lget_int("checkout",0);
1132
+ if( file_isdir(zExternBase, ExtFILE)!=1 ){
1133
+ fossil_fatal("\"%s\" is not a directory", zExternBase);
1134
+ }
1135
+ db_prepare(&q,
1136
+ "SELECT pathname FROM vfile WHERE vid=%d ORDER BY pathname",
1137
+ vid
1138
+ );
1139
+ while( db_step(&q)==SQLITE_ROW ){
1140
+ const char *zFile; /* Name of file in the repository */
1141
+ char *zLhs; /* Full name of left-hand side file */
1142
+ char *zRhs; /* Full name of right-hand side file */
1143
+ Blob rhs; /* Full text of RHS */
1144
+ Blob lhs; /* Full text of LHS */
1145
+
1146
+ zFile = db_column_text(&q,0);
1147
+ if( !file_dir_match(pFileDir, zFile) ) continue;
1148
+ zLhs = mprintf("%s/%s", zExternBase, zFile);
1149
+ zRhs = mprintf("%s%s", g.zLocalRoot, zFile);
1150
+ if( file_size(zLhs, ExtFILE)<0 ){
1151
+ blob_zero(&lhs);
1152
+ }else{
1153
+ blob_read_from_file(&lhs, zLhs, ExtFILE);
1154
+ }
1155
+ blob_read_from_file(&rhs, zRhs, ExtFILE);
1156
+ if( blob_size(&lhs)!=blob_size(&rhs)
1157
+ || memcmp(blob_buffer(&lhs), blob_buffer(&rhs), blob_size(&lhs))!=0
1158
+ ){
1159
+ diff_print_index(zFile, pCfg, 0);
1160
+ diff_file_mem(&lhs, &rhs, zFile, pCfg);
1161
+ }
1162
+ blob_reset(&lhs);
1163
+ blob_reset(&rhs);
1164
+ fossil_free(zLhs);
1165
+ fossil_free(zRhs);
1166
+ }
1167
+ db_finalize(&q);
1168
+}
1169
+
11121170
11131171
/*
11141172
** Return the name of the external diff command, or return NULL if
11151173
** no external diff command is defined.
11161174
*/
@@ -1243,10 +1301,14 @@
12431301
** option specifies the check-in from which the second version of the file
12441302
** or files is taken. If there is no "--to" option then the (possibly edited)
12451303
** files in the current check-out are used. The "--checkin VERSION" option
12461304
** shows the changes made by check-in VERSION relative to its primary parent.
12471305
** The "--branch BRANCHNAME" shows all the changes on the branch BRANCHNAME.
1306
+**
1307
+** With the "--from VERSION" option, if VERSION is actually a directory name
1308
+** (not a tag or check-in hash) then the files under that directory are used
1309
+** as the baseline for the diff.
12481310
**
12491311
** The "-i" command-line option forces the use of Fossil's own internal
12501312
** diff logic rather than any external diff program that might be configured
12511313
** using the "setting" command. If no external diff program is configured,
12521314
** then the "-i" option is a no-op. The "-i" option converts "gdiff" into
@@ -1275,11 +1337,13 @@
12751337
** with negative N meaning show all content
12761338
** --dark Use dark mode for the Tcl/Tk-based GUI and HTML
12771339
** --diff-binary BOOL Include binary files with external commands
12781340
** --exec-abs-paths Force absolute path names on external commands
12791341
** --exec-rel-paths Force relative path names on external commands
1280
-** -r|--from VERSION Select VERSION as source for the diff
1342
+** -r|--from VERSION Use VERSION as the baseline for the diff, or
1343
+** if VERSION is a directory name, use files in
1344
+** that directory as the baseline.
12811345
** -w|--ignore-all-space Ignore white space when comparing lines
12821346
** -i|--internal Use internal diff logic
12831347
** --invert Invert the diff
12841348
** --json Output formatted as JSON
12851349
** -n|--linenum Show line numbers
@@ -1289,11 +1353,11 @@
12891353
** --strip-trailing-cr Strip trailing CR
12901354
** --tcl Tcl-formatted output used internally by --tk
12911355
** --tclsh PATH Tcl/Tk shell used for --tk (default: "tclsh")
12921356
** --tk Launch a Tcl/Tk GUI for display
12931357
** --to VERSION Select VERSION as target for the diff
1294
-** --undo Diff against the "undo" buffer
1358
+** --undo Use the undo buffer as the baseline
12951359
** --unified Unified diff
12961360
** -v|--verbose Output complete text of added or deleted files
12971361
** -h|--versions Show compared versions in the diff header
12981362
** --webpage Format output as a stand-alone HTML webpage
12991363
** -W|--width N Width of lines in side-by-side diff
@@ -1306,10 +1370,11 @@
13061370
const char *zCheckin; /* Check-in version number */
13071371
const char *zBranch; /* Branch to diff */
13081372
int againstUndo = 0; /* Diff against files in the undo buffer */
13091373
FileDirList *pFileDir = 0; /* Restrict the diff to these files */
13101374
DiffConfig DCfg; /* Diff configuration object */
1375
+ int bFromIsDir = 0; /* True if zFrom is a directory name */
13111376
13121377
if( find_option("tk",0,0)!=0 || has_option("tclsh") ){
13131378
diff_tk("diff", 2);
13141379
return;
13151380
}
@@ -1317,11 +1382,11 @@
13171382
zFrom = find_option("from", "r", 1);
13181383
zTo = find_option("to", 0, 1);
13191384
zCheckin = find_option("checkin", "ci", 1);
13201385
zBranch = find_option("branch", 0, 1);
13211386
againstUndo = find_option("undo",0,0)!=0;
1322
- if( againstUndo && ( zFrom!=0 || zTo!=0 || zCheckin!=0 || zBranch!=0) ){
1387
+ if( againstUndo && (zFrom!=0 || zTo!=0 || zCheckin!=0 || zBranch!=0) ){
13231388
fossil_fatal("cannot use --undo together with --from, --to, --checkin,"
13241389
" or --branch");
13251390
}
13261391
if( zBranch ){
13271392
if( zTo || zFrom || zCheckin ){
@@ -1328,14 +1393,13 @@
13281393
fossil_fatal("cannot use --from, --to, or --checkin with --branch");
13291394
}
13301395
zTo = zBranch;
13311396
zFrom = mprintf("root:%s", zBranch);
13321397
}
1333
- if( zCheckin!=0 && ( zFrom!=0 || zTo!=0 ) ){
1398
+ if( zCheckin!=0 && (zFrom!=0 || zTo!=0) ){
13341399
fossil_fatal("cannot use --checkin together with --from or --to");
13351400
}
1336
- g.diffCnt[0] = g.diffCnt[1] = g.diffCnt[2] = 0;
13371401
if( 0==zCheckin ){
13381402
if( zTo==0 || againstUndo ){
13391403
db_must_be_within_tree();
13401404
}else if( zFrom==0 ){
13411405
fossil_fatal("must use --from if --to is present");
@@ -1343,13 +1407,23 @@
13431407
db_find_and_open_repository(0, 0);
13441408
}
13451409
}else{
13461410
db_find_and_open_repository(0, 0);
13471411
}
1348
- diff_options(&DCfg, isGDiff, 0);
13491412
determine_exec_relative_option(1);
1413
+ if( zFrom!=file_tail(zFrom)
1414
+ && file_isdir(zFrom, ExtFILE)==1
1415
+ && !db_exists("SELECT 1 FROM tag WHERE tagname='sym-%q'", zFrom)
1416
+ ){
1417
+ bFromIsDir = 1;
1418
+ if( zTo ){
1419
+ fossil_fatal("cannot use --to together with \"--from PATH\"");
1420
+ }
1421
+ }
1422
+ diff_options(&DCfg, isGDiff, 0);
13501423
verify_all_options();
1424
+ g.diffCnt[0] = g.diffCnt[1] = g.diffCnt[2] = 0;
13511425
if( g.argc>=3 ){
13521426
int i;
13531427
Blob fname;
13541428
pFileDir = fossil_malloc( sizeof(*pFileDir) * (g.argc-1) );
13551429
memset(pFileDir, 0, sizeof(*pFileDir) * (g.argc-1));
@@ -1376,18 +1450,20 @@
13761450
if( zFrom==0 ){
13771451
fossil_fatal("check-in %s has no parent", zTo);
13781452
}
13791453
}
13801454
diff_begin(&DCfg);
1381
- if( againstUndo ){
1455
+ if( bFromIsDir ){
1456
+ diff_externbase_to_checkout(zFrom, &DCfg, pFileDir);
1457
+ }else if( againstUndo ){
13821458
if( db_lget_int("undo_available",0)==0 ){
13831459
fossil_print("No undo or redo is available\n");
13841460
return;
13851461
}
1386
- diff_against_undo(&DCfg, pFileDir);
1462
+ diff_undo_to_checkout(&DCfg, pFileDir);
13871463
}else if( zTo==0 ){
1388
- diff_against_disk(zFrom, &DCfg, pFileDir, 0);
1464
+ diff_version_to_checkout(zFrom, &DCfg, pFileDir, 0);
13891465
}else{
13901466
diff_two_versions(zFrom, zTo, &DCfg, pFileDir);
13911467
}
13921468
if( pFileDir ){
13931469
int i;
13941470
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -803,26 +803,27 @@
803 blob_reset(&file);
804 return rc;
805 }
806
807 /*
808 ** Run a diff between the version zFrom and files on disk. zFrom might
809 ** be NULL which means to simply show the difference between the edited
810 ** files on disk and the check-out on which they are based.
 
811 **
812 ** Use the internal diff logic if zDiffCmd is NULL. Otherwise call the
813 ** command zDiffCmd to do the diffing.
814 **
815 ** When using an external diff program, zBinGlob contains the GLOB patterns
816 ** for file names to treat as binary. If fIncludeBinary is zero, these files
817 ** will be skipped in addition to files that may contain binary content.
818 */
819 void diff_against_disk(
820 const char *zFrom, /* Version to difference from */
821 DiffConfig *pCfg, /* Flags controlling diff output */
822 FileDirList *pFileDir, /* Which files to diff */
823 Blob *pOut /* Blob to output diff instead of stdout */
824 ){
825 int vid;
826 Blob sql;
827 Stmt q;
828 int asNewFile; /* Treat non-existant files as empty files */
@@ -947,20 +948,20 @@
947 db_finalize(&q);
948 db_end_transaction(1); /* ROLLBACK */
949 }
950
951 /*
952 ** Run a diff between the undo buffer and files on disk.
953 **
954 ** Use the internal diff logic if zDiffCmd is NULL. Otherwise call the
955 ** command zDiffCmd to do the diffing.
956 **
957 ** When using an external diff program, zBinGlob contains the GLOB patterns
958 ** for file names to treat as binary. If fIncludeBinary is zero, these files
959 ** will be skipped in addition to files that may contain binary content.
960 */
961 static void diff_against_undo(
962 DiffConfig *pCfg, /* Flags controlling diff output */
963 FileDirList *pFileDir /* List of files and directories to diff */
964 ){
965 Stmt q;
966 Blob content;
@@ -1107,10 +1108,67 @@
1107 }
1108 }
1109 manifest_destroy(pFrom);
1110 manifest_destroy(pTo);
1111 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1112
1113 /*
1114 ** Return the name of the external diff command, or return NULL if
1115 ** no external diff command is defined.
1116 */
@@ -1243,10 +1301,14 @@
1243 ** option specifies the check-in from which the second version of the file
1244 ** or files is taken. If there is no "--to" option then the (possibly edited)
1245 ** files in the current check-out are used. The "--checkin VERSION" option
1246 ** shows the changes made by check-in VERSION relative to its primary parent.
1247 ** The "--branch BRANCHNAME" shows all the changes on the branch BRANCHNAME.
 
 
 
 
1248 **
1249 ** The "-i" command-line option forces the use of Fossil's own internal
1250 ** diff logic rather than any external diff program that might be configured
1251 ** using the "setting" command. If no external diff program is configured,
1252 ** then the "-i" option is a no-op. The "-i" option converts "gdiff" into
@@ -1275,11 +1337,13 @@
1275 ** with negative N meaning show all content
1276 ** --dark Use dark mode for the Tcl/Tk-based GUI and HTML
1277 ** --diff-binary BOOL Include binary files with external commands
1278 ** --exec-abs-paths Force absolute path names on external commands
1279 ** --exec-rel-paths Force relative path names on external commands
1280 ** -r|--from VERSION Select VERSION as source for the diff
 
 
1281 ** -w|--ignore-all-space Ignore white space when comparing lines
1282 ** -i|--internal Use internal diff logic
1283 ** --invert Invert the diff
1284 ** --json Output formatted as JSON
1285 ** -n|--linenum Show line numbers
@@ -1289,11 +1353,11 @@
1289 ** --strip-trailing-cr Strip trailing CR
1290 ** --tcl Tcl-formatted output used internally by --tk
1291 ** --tclsh PATH Tcl/Tk shell used for --tk (default: "tclsh")
1292 ** --tk Launch a Tcl/Tk GUI for display
1293 ** --to VERSION Select VERSION as target for the diff
1294 ** --undo Diff against the "undo" buffer
1295 ** --unified Unified diff
1296 ** -v|--verbose Output complete text of added or deleted files
1297 ** -h|--versions Show compared versions in the diff header
1298 ** --webpage Format output as a stand-alone HTML webpage
1299 ** -W|--width N Width of lines in side-by-side diff
@@ -1306,10 +1370,11 @@
1306 const char *zCheckin; /* Check-in version number */
1307 const char *zBranch; /* Branch to diff */
1308 int againstUndo = 0; /* Diff against files in the undo buffer */
1309 FileDirList *pFileDir = 0; /* Restrict the diff to these files */
1310 DiffConfig DCfg; /* Diff configuration object */
 
1311
1312 if( find_option("tk",0,0)!=0 || has_option("tclsh") ){
1313 diff_tk("diff", 2);
1314 return;
1315 }
@@ -1317,11 +1382,11 @@
1317 zFrom = find_option("from", "r", 1);
1318 zTo = find_option("to", 0, 1);
1319 zCheckin = find_option("checkin", "ci", 1);
1320 zBranch = find_option("branch", 0, 1);
1321 againstUndo = find_option("undo",0,0)!=0;
1322 if( againstUndo && ( zFrom!=0 || zTo!=0 || zCheckin!=0 || zBranch!=0) ){
1323 fossil_fatal("cannot use --undo together with --from, --to, --checkin,"
1324 " or --branch");
1325 }
1326 if( zBranch ){
1327 if( zTo || zFrom || zCheckin ){
@@ -1328,14 +1393,13 @@
1328 fossil_fatal("cannot use --from, --to, or --checkin with --branch");
1329 }
1330 zTo = zBranch;
1331 zFrom = mprintf("root:%s", zBranch);
1332 }
1333 if( zCheckin!=0 && ( zFrom!=0 || zTo!=0 ) ){
1334 fossil_fatal("cannot use --checkin together with --from or --to");
1335 }
1336 g.diffCnt[0] = g.diffCnt[1] = g.diffCnt[2] = 0;
1337 if( 0==zCheckin ){
1338 if( zTo==0 || againstUndo ){
1339 db_must_be_within_tree();
1340 }else if( zFrom==0 ){
1341 fossil_fatal("must use --from if --to is present");
@@ -1343,13 +1407,23 @@
1343 db_find_and_open_repository(0, 0);
1344 }
1345 }else{
1346 db_find_and_open_repository(0, 0);
1347 }
1348 diff_options(&DCfg, isGDiff, 0);
1349 determine_exec_relative_option(1);
 
 
 
 
 
 
 
 
 
 
1350 verify_all_options();
 
1351 if( g.argc>=3 ){
1352 int i;
1353 Blob fname;
1354 pFileDir = fossil_malloc( sizeof(*pFileDir) * (g.argc-1) );
1355 memset(pFileDir, 0, sizeof(*pFileDir) * (g.argc-1));
@@ -1376,18 +1450,20 @@
1376 if( zFrom==0 ){
1377 fossil_fatal("check-in %s has no parent", zTo);
1378 }
1379 }
1380 diff_begin(&DCfg);
1381 if( againstUndo ){
 
 
1382 if( db_lget_int("undo_available",0)==0 ){
1383 fossil_print("No undo or redo is available\n");
1384 return;
1385 }
1386 diff_against_undo(&DCfg, pFileDir);
1387 }else if( zTo==0 ){
1388 diff_against_disk(zFrom, &DCfg, pFileDir, 0);
1389 }else{
1390 diff_two_versions(zFrom, zTo, &DCfg, pFileDir);
1391 }
1392 if( pFileDir ){
1393 int i;
1394
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -803,26 +803,27 @@
803 blob_reset(&file);
804 return rc;
805 }
806
807 /*
808 ** Run a diff between the version zFrom and files on disk in the current
809 ** working checkout. zFrom might be NULL which means to simply show the
810 ** difference between the edited files on disk and the check-out on which
811 ** they are based.
812 **
813 ** Use the internal diff logic if zDiffCmd is NULL. Otherwise call the
814 ** command zDiffCmd to do the diffing.
815 **
816 ** When using an external diff program, zBinGlob contains the GLOB patterns
817 ** for file names to treat as binary. If fIncludeBinary is zero, these files
818 ** will be skipped in addition to files that may contain binary content.
819 */
820 void diff_version_to_checkout(
821 const char *zFrom, /* Version to difference from */
822 DiffConfig *pCfg, /* Flags controlling diff output */
823 FileDirList *pFileDir, /* Which files to diff */
824 Blob *pOut /* Blob to output diff instead of stdout */
825 ){
826 int vid;
827 Blob sql;
828 Stmt q;
829 int asNewFile; /* Treat non-existant files as empty files */
@@ -947,20 +948,20 @@
948 db_finalize(&q);
949 db_end_transaction(1); /* ROLLBACK */
950 }
951
952 /*
953 ** Run a diff from the undo buffer to files on disk.
954 **
955 ** Use the internal diff logic if zDiffCmd is NULL. Otherwise call the
956 ** command zDiffCmd to do the diffing.
957 **
958 ** When using an external diff program, zBinGlob contains the GLOB patterns
959 ** for file names to treat as binary. If fIncludeBinary is zero, these files
960 ** will be skipped in addition to files that may contain binary content.
961 */
962 static void diff_undo_to_checkout(
963 DiffConfig *pCfg, /* Flags controlling diff output */
964 FileDirList *pFileDir /* List of files and directories to diff */
965 ){
966 Stmt q;
967 Blob content;
@@ -1107,10 +1108,67 @@
1108 }
1109 }
1110 manifest_destroy(pFrom);
1111 manifest_destroy(pTo);
1112 }
1113
1114 /*
1115 ** Compute the difference from an external tree of files to the current
1116 ** working checkout with its edits.
1117 **
1118 ** To put it another way: Every managed file in the current working
1119 ** checkout is compared to the file with same name under zExternBase. The
1120 ** zExternBase files are on the left and the files in the current working
1121 ** directory are on the right.
1122 */
1123 void diff_externbase_to_checkout(
1124 const char *zExternBase, /* Remote tree to use as the baseline */
1125 DiffConfig *pCfg, /* Diff settings */
1126 FileDirList *pFileDir /* Only look at these files */
1127 ){
1128 int vid;
1129 Stmt q;
1130
1131 vid = db_lget_int("checkout",0);
1132 if( file_isdir(zExternBase, ExtFILE)!=1 ){
1133 fossil_fatal("\"%s\" is not a directory", zExternBase);
1134 }
1135 db_prepare(&q,
1136 "SELECT pathname FROM vfile WHERE vid=%d ORDER BY pathname",
1137 vid
1138 );
1139 while( db_step(&q)==SQLITE_ROW ){
1140 const char *zFile; /* Name of file in the repository */
1141 char *zLhs; /* Full name of left-hand side file */
1142 char *zRhs; /* Full name of right-hand side file */
1143 Blob rhs; /* Full text of RHS */
1144 Blob lhs; /* Full text of LHS */
1145
1146 zFile = db_column_text(&q,0);
1147 if( !file_dir_match(pFileDir, zFile) ) continue;
1148 zLhs = mprintf("%s/%s", zExternBase, zFile);
1149 zRhs = mprintf("%s%s", g.zLocalRoot, zFile);
1150 if( file_size(zLhs, ExtFILE)<0 ){
1151 blob_zero(&lhs);
1152 }else{
1153 blob_read_from_file(&lhs, zLhs, ExtFILE);
1154 }
1155 blob_read_from_file(&rhs, zRhs, ExtFILE);
1156 if( blob_size(&lhs)!=blob_size(&rhs)
1157 || memcmp(blob_buffer(&lhs), blob_buffer(&rhs), blob_size(&lhs))!=0
1158 ){
1159 diff_print_index(zFile, pCfg, 0);
1160 diff_file_mem(&lhs, &rhs, zFile, pCfg);
1161 }
1162 blob_reset(&lhs);
1163 blob_reset(&rhs);
1164 fossil_free(zLhs);
1165 fossil_free(zRhs);
1166 }
1167 db_finalize(&q);
1168 }
1169
1170
1171 /*
1172 ** Return the name of the external diff command, or return NULL if
1173 ** no external diff command is defined.
1174 */
@@ -1243,10 +1301,14 @@
1301 ** option specifies the check-in from which the second version of the file
1302 ** or files is taken. If there is no "--to" option then the (possibly edited)
1303 ** files in the current check-out are used. The "--checkin VERSION" option
1304 ** shows the changes made by check-in VERSION relative to its primary parent.
1305 ** The "--branch BRANCHNAME" shows all the changes on the branch BRANCHNAME.
1306 **
1307 ** With the "--from VERSION" option, if VERSION is actually a directory name
1308 ** (not a tag or check-in hash) then the files under that directory are used
1309 ** as the baseline for the diff.
1310 **
1311 ** The "-i" command-line option forces the use of Fossil's own internal
1312 ** diff logic rather than any external diff program that might be configured
1313 ** using the "setting" command. If no external diff program is configured,
1314 ** then the "-i" option is a no-op. The "-i" option converts "gdiff" into
@@ -1275,11 +1337,13 @@
1337 ** with negative N meaning show all content
1338 ** --dark Use dark mode for the Tcl/Tk-based GUI and HTML
1339 ** --diff-binary BOOL Include binary files with external commands
1340 ** --exec-abs-paths Force absolute path names on external commands
1341 ** --exec-rel-paths Force relative path names on external commands
1342 ** -r|--from VERSION Use VERSION as the baseline for the diff, or
1343 ** if VERSION is a directory name, use files in
1344 ** that directory as the baseline.
1345 ** -w|--ignore-all-space Ignore white space when comparing lines
1346 ** -i|--internal Use internal diff logic
1347 ** --invert Invert the diff
1348 ** --json Output formatted as JSON
1349 ** -n|--linenum Show line numbers
@@ -1289,11 +1353,11 @@
1353 ** --strip-trailing-cr Strip trailing CR
1354 ** --tcl Tcl-formatted output used internally by --tk
1355 ** --tclsh PATH Tcl/Tk shell used for --tk (default: "tclsh")
1356 ** --tk Launch a Tcl/Tk GUI for display
1357 ** --to VERSION Select VERSION as target for the diff
1358 ** --undo Use the undo buffer as the baseline
1359 ** --unified Unified diff
1360 ** -v|--verbose Output complete text of added or deleted files
1361 ** -h|--versions Show compared versions in the diff header
1362 ** --webpage Format output as a stand-alone HTML webpage
1363 ** -W|--width N Width of lines in side-by-side diff
@@ -1306,10 +1370,11 @@
1370 const char *zCheckin; /* Check-in version number */
1371 const char *zBranch; /* Branch to diff */
1372 int againstUndo = 0; /* Diff against files in the undo buffer */
1373 FileDirList *pFileDir = 0; /* Restrict the diff to these files */
1374 DiffConfig DCfg; /* Diff configuration object */
1375 int bFromIsDir = 0; /* True if zFrom is a directory name */
1376
1377 if( find_option("tk",0,0)!=0 || has_option("tclsh") ){
1378 diff_tk("diff", 2);
1379 return;
1380 }
@@ -1317,11 +1382,11 @@
1382 zFrom = find_option("from", "r", 1);
1383 zTo = find_option("to", 0, 1);
1384 zCheckin = find_option("checkin", "ci", 1);
1385 zBranch = find_option("branch", 0, 1);
1386 againstUndo = find_option("undo",0,0)!=0;
1387 if( againstUndo && (zFrom!=0 || zTo!=0 || zCheckin!=0 || zBranch!=0) ){
1388 fossil_fatal("cannot use --undo together with --from, --to, --checkin,"
1389 " or --branch");
1390 }
1391 if( zBranch ){
1392 if( zTo || zFrom || zCheckin ){
@@ -1328,14 +1393,13 @@
1393 fossil_fatal("cannot use --from, --to, or --checkin with --branch");
1394 }
1395 zTo = zBranch;
1396 zFrom = mprintf("root:%s", zBranch);
1397 }
1398 if( zCheckin!=0 && (zFrom!=0 || zTo!=0) ){
1399 fossil_fatal("cannot use --checkin together with --from or --to");
1400 }
 
1401 if( 0==zCheckin ){
1402 if( zTo==0 || againstUndo ){
1403 db_must_be_within_tree();
1404 }else if( zFrom==0 ){
1405 fossil_fatal("must use --from if --to is present");
@@ -1343,13 +1407,23 @@
1407 db_find_and_open_repository(0, 0);
1408 }
1409 }else{
1410 db_find_and_open_repository(0, 0);
1411 }
 
1412 determine_exec_relative_option(1);
1413 if( zFrom!=file_tail(zFrom)
1414 && file_isdir(zFrom, ExtFILE)==1
1415 && !db_exists("SELECT 1 FROM tag WHERE tagname='sym-%q'", zFrom)
1416 ){
1417 bFromIsDir = 1;
1418 if( zTo ){
1419 fossil_fatal("cannot use --to together with \"--from PATH\"");
1420 }
1421 }
1422 diff_options(&DCfg, isGDiff, 0);
1423 verify_all_options();
1424 g.diffCnt[0] = g.diffCnt[1] = g.diffCnt[2] = 0;
1425 if( g.argc>=3 ){
1426 int i;
1427 Blob fname;
1428 pFileDir = fossil_malloc( sizeof(*pFileDir) * (g.argc-1) );
1429 memset(pFileDir, 0, sizeof(*pFileDir) * (g.argc-1));
@@ -1376,18 +1450,20 @@
1450 if( zFrom==0 ){
1451 fossil_fatal("check-in %s has no parent", zTo);
1452 }
1453 }
1454 diff_begin(&DCfg);
1455 if( bFromIsDir ){
1456 diff_externbase_to_checkout(zFrom, &DCfg, pFileDir);
1457 }else if( againstUndo ){
1458 if( db_lget_int("undo_available",0)==0 ){
1459 fossil_print("No undo or redo is available\n");
1460 return;
1461 }
1462 diff_undo_to_checkout(&DCfg, pFileDir);
1463 }else if( zTo==0 ){
1464 diff_version_to_checkout(zFrom, &DCfg, pFileDir, 0);
1465 }else{
1466 diff_two_versions(zFrom, zTo, &DCfg, pFileDir);
1467 }
1468 if( pFileDir ){
1469 int i;
1470
+92 -16
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -803,26 +803,27 @@
803803
blob_reset(&file);
804804
return rc;
805805
}
806806
807807
/*
808
-** Run a diff between the version zFrom and files on disk. zFrom might
809
-** be NULL which means to simply show the difference between the edited
810
-** files on disk and the check-out on which they are based.
808
+** Run a diff between the version zFrom and files on disk in the current
809
+** working checkout. zFrom might be NULL which means to simply show the
810
+** difference between the edited files on disk and the check-out on which
811
+** they are based.
811812
**
812813
** Use the internal diff logic if zDiffCmd is NULL. Otherwise call the
813814
** command zDiffCmd to do the diffing.
814815
**
815816
** When using an external diff program, zBinGlob contains the GLOB patterns
816817
** for file names to treat as binary. If fIncludeBinary is zero, these files
817818
** will be skipped in addition to files that may contain binary content.
818819
*/
819
-void diff_against_disk(
820
+void diff_version_to_checkout(
820821
const char *zFrom, /* Version to difference from */
821822
DiffConfig *pCfg, /* Flags controlling diff output */
822823
FileDirList *pFileDir, /* Which files to diff */
823
- Blob *pOut /* Blob to output diff instead of stdout */
824
+ Blob *pOut /* Blob to output diff instead of stdout */
824825
){
825826
int vid;
826827
Blob sql;
827828
Stmt q;
828829
int asNewFile; /* Treat non-existant files as empty files */
@@ -947,20 +948,20 @@
947948
db_finalize(&q);
948949
db_end_transaction(1); /* ROLLBACK */
949950
}
950951
951952
/*
952
-** Run a diff between the undo buffer and files on disk.
953
+** Run a diff from the undo buffer to files on disk.
953954
**
954955
** Use the internal diff logic if zDiffCmd is NULL. Otherwise call the
955956
** command zDiffCmd to do the diffing.
956957
**
957958
** When using an external diff program, zBinGlob contains the GLOB patterns
958959
** for file names to treat as binary. If fIncludeBinary is zero, these files
959960
** will be skipped in addition to files that may contain binary content.
960961
*/
961
-static void diff_against_undo(
962
+static void diff_undo_to_checkout(
962963
DiffConfig *pCfg, /* Flags controlling diff output */
963964
FileDirList *pFileDir /* List of files and directories to diff */
964965
){
965966
Stmt q;
966967
Blob content;
@@ -1107,10 +1108,67 @@
11071108
}
11081109
}
11091110
manifest_destroy(pFrom);
11101111
manifest_destroy(pTo);
11111112
}
1113
+
1114
+/*
1115
+** Compute the difference from an external tree of files to the current
1116
+** working checkout with its edits.
1117
+**
1118
+** To put it another way: Every managed file in the current working
1119
+** checkout is compared to the file with same name under zExternBase. The
1120
+** zExternBase files are on the left and the files in the current working
1121
+** directory are on the right.
1122
+*/
1123
+void diff_externbase_to_checkout(
1124
+ const char *zExternBase, /* Remote tree to use as the baseline */
1125
+ DiffConfig *pCfg, /* Diff settings */
1126
+ FileDirList *pFileDir /* Only look at these files */
1127
+){
1128
+ int vid;
1129
+ Stmt q;
1130
+
1131
+ vid = db_lget_int("checkout",0);
1132
+ if( file_isdir(zExternBase, ExtFILE)!=1 ){
1133
+ fossil_fatal("\"%s\" is not a directory", zExternBase);
1134
+ }
1135
+ db_prepare(&q,
1136
+ "SELECT pathname FROM vfile WHERE vid=%d ORDER BY pathname",
1137
+ vid
1138
+ );
1139
+ while( db_step(&q)==SQLITE_ROW ){
1140
+ const char *zFile; /* Name of file in the repository */
1141
+ char *zLhs; /* Full name of left-hand side file */
1142
+ char *zRhs; /* Full name of right-hand side file */
1143
+ Blob rhs; /* Full text of RHS */
1144
+ Blob lhs; /* Full text of LHS */
1145
+
1146
+ zFile = db_column_text(&q,0);
1147
+ if( !file_dir_match(pFileDir, zFile) ) continue;
1148
+ zLhs = mprintf("%s/%s", zExternBase, zFile);
1149
+ zRhs = mprintf("%s%s", g.zLocalRoot, zFile);
1150
+ if( file_size(zLhs, ExtFILE)<0 ){
1151
+ blob_zero(&lhs);
1152
+ }else{
1153
+ blob_read_from_file(&lhs, zLhs, ExtFILE);
1154
+ }
1155
+ blob_read_from_file(&rhs, zRhs, ExtFILE);
1156
+ if( blob_size(&lhs)!=blob_size(&rhs)
1157
+ || memcmp(blob_buffer(&lhs), blob_buffer(&rhs), blob_size(&lhs))!=0
1158
+ ){
1159
+ diff_print_index(zFile, pCfg, 0);
1160
+ diff_file_mem(&lhs, &rhs, zFile, pCfg);
1161
+ }
1162
+ blob_reset(&lhs);
1163
+ blob_reset(&rhs);
1164
+ fossil_free(zLhs);
1165
+ fossil_free(zRhs);
1166
+ }
1167
+ db_finalize(&q);
1168
+}
1169
+
11121170
11131171
/*
11141172
** Return the name of the external diff command, or return NULL if
11151173
** no external diff command is defined.
11161174
*/
@@ -1243,10 +1301,14 @@
12431301
** option specifies the check-in from which the second version of the file
12441302
** or files is taken. If there is no "--to" option then the (possibly edited)
12451303
** files in the current check-out are used. The "--checkin VERSION" option
12461304
** shows the changes made by check-in VERSION relative to its primary parent.
12471305
** The "--branch BRANCHNAME" shows all the changes on the branch BRANCHNAME.
1306
+**
1307
+** With the "--from VERSION" option, if VERSION is actually a directory name
1308
+** (not a tag or check-in hash) then the files under that directory are used
1309
+** as the baseline for the diff.
12481310
**
12491311
** The "-i" command-line option forces the use of Fossil's own internal
12501312
** diff logic rather than any external diff program that might be configured
12511313
** using the "setting" command. If no external diff program is configured,
12521314
** then the "-i" option is a no-op. The "-i" option converts "gdiff" into
@@ -1275,11 +1337,13 @@
12751337
** with negative N meaning show all content
12761338
** --dark Use dark mode for the Tcl/Tk-based GUI and HTML
12771339
** --diff-binary BOOL Include binary files with external commands
12781340
** --exec-abs-paths Force absolute path names on external commands
12791341
** --exec-rel-paths Force relative path names on external commands
1280
-** -r|--from VERSION Select VERSION as source for the diff
1342
+** -r|--from VERSION Use VERSION as the baseline for the diff, or
1343
+** if VERSION is a directory name, use files in
1344
+** that directory as the baseline.
12811345
** -w|--ignore-all-space Ignore white space when comparing lines
12821346
** -i|--internal Use internal diff logic
12831347
** --invert Invert the diff
12841348
** --json Output formatted as JSON
12851349
** -n|--linenum Show line numbers
@@ -1289,11 +1353,11 @@
12891353
** --strip-trailing-cr Strip trailing CR
12901354
** --tcl Tcl-formatted output used internally by --tk
12911355
** --tclsh PATH Tcl/Tk shell used for --tk (default: "tclsh")
12921356
** --tk Launch a Tcl/Tk GUI for display
12931357
** --to VERSION Select VERSION as target for the diff
1294
-** --undo Diff against the "undo" buffer
1358
+** --undo Use the undo buffer as the baseline
12951359
** --unified Unified diff
12961360
** -v|--verbose Output complete text of added or deleted files
12971361
** -h|--versions Show compared versions in the diff header
12981362
** --webpage Format output as a stand-alone HTML webpage
12991363
** -W|--width N Width of lines in side-by-side diff
@@ -1306,10 +1370,11 @@
13061370
const char *zCheckin; /* Check-in version number */
13071371
const char *zBranch; /* Branch to diff */
13081372
int againstUndo = 0; /* Diff against files in the undo buffer */
13091373
FileDirList *pFileDir = 0; /* Restrict the diff to these files */
13101374
DiffConfig DCfg; /* Diff configuration object */
1375
+ int bFromIsDir = 0; /* True if zFrom is a directory name */
13111376
13121377
if( find_option("tk",0,0)!=0 || has_option("tclsh") ){
13131378
diff_tk("diff", 2);
13141379
return;
13151380
}
@@ -1317,11 +1382,11 @@
13171382
zFrom = find_option("from", "r", 1);
13181383
zTo = find_option("to", 0, 1);
13191384
zCheckin = find_option("checkin", "ci", 1);
13201385
zBranch = find_option("branch", 0, 1);
13211386
againstUndo = find_option("undo",0,0)!=0;
1322
- if( againstUndo && ( zFrom!=0 || zTo!=0 || zCheckin!=0 || zBranch!=0) ){
1387
+ if( againstUndo && (zFrom!=0 || zTo!=0 || zCheckin!=0 || zBranch!=0) ){
13231388
fossil_fatal("cannot use --undo together with --from, --to, --checkin,"
13241389
" or --branch");
13251390
}
13261391
if( zBranch ){
13271392
if( zTo || zFrom || zCheckin ){
@@ -1328,14 +1393,13 @@
13281393
fossil_fatal("cannot use --from, --to, or --checkin with --branch");
13291394
}
13301395
zTo = zBranch;
13311396
zFrom = mprintf("root:%s", zBranch);
13321397
}
1333
- if( zCheckin!=0 && ( zFrom!=0 || zTo!=0 ) ){
1398
+ if( zCheckin!=0 && (zFrom!=0 || zTo!=0) ){
13341399
fossil_fatal("cannot use --checkin together with --from or --to");
13351400
}
1336
- g.diffCnt[0] = g.diffCnt[1] = g.diffCnt[2] = 0;
13371401
if( 0==zCheckin ){
13381402
if( zTo==0 || againstUndo ){
13391403
db_must_be_within_tree();
13401404
}else if( zFrom==0 ){
13411405
fossil_fatal("must use --from if --to is present");
@@ -1343,13 +1407,23 @@
13431407
db_find_and_open_repository(0, 0);
13441408
}
13451409
}else{
13461410
db_find_and_open_repository(0, 0);
13471411
}
1348
- diff_options(&DCfg, isGDiff, 0);
13491412
determine_exec_relative_option(1);
1413
+ if( zFrom!=file_tail(zFrom)
1414
+ && file_isdir(zFrom, ExtFILE)==1
1415
+ && !db_exists("SELECT 1 FROM tag WHERE tagname='sym-%q'", zFrom)
1416
+ ){
1417
+ bFromIsDir = 1;
1418
+ if( zTo ){
1419
+ fossil_fatal("cannot use --to together with \"--from PATH\"");
1420
+ }
1421
+ }
1422
+ diff_options(&DCfg, isGDiff, 0);
13501423
verify_all_options();
1424
+ g.diffCnt[0] = g.diffCnt[1] = g.diffCnt[2] = 0;
13511425
if( g.argc>=3 ){
13521426
int i;
13531427
Blob fname;
13541428
pFileDir = fossil_malloc( sizeof(*pFileDir) * (g.argc-1) );
13551429
memset(pFileDir, 0, sizeof(*pFileDir) * (g.argc-1));
@@ -1376,18 +1450,20 @@
13761450
if( zFrom==0 ){
13771451
fossil_fatal("check-in %s has no parent", zTo);
13781452
}
13791453
}
13801454
diff_begin(&DCfg);
1381
- if( againstUndo ){
1455
+ if( bFromIsDir ){
1456
+ diff_externbase_to_checkout(zFrom, &DCfg, pFileDir);
1457
+ }else if( againstUndo ){
13821458
if( db_lget_int("undo_available",0)==0 ){
13831459
fossil_print("No undo or redo is available\n");
13841460
return;
13851461
}
1386
- diff_against_undo(&DCfg, pFileDir);
1462
+ diff_undo_to_checkout(&DCfg, pFileDir);
13871463
}else if( zTo==0 ){
1388
- diff_against_disk(zFrom, &DCfg, pFileDir, 0);
1464
+ diff_version_to_checkout(zFrom, &DCfg, pFileDir, 0);
13891465
}else{
13901466
diff_two_versions(zFrom, zTo, &DCfg, pFileDir);
13911467
}
13921468
if( pFileDir ){
13931469
int i;
13941470
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -803,26 +803,27 @@
803 blob_reset(&file);
804 return rc;
805 }
806
807 /*
808 ** Run a diff between the version zFrom and files on disk. zFrom might
809 ** be NULL which means to simply show the difference between the edited
810 ** files on disk and the check-out on which they are based.
 
811 **
812 ** Use the internal diff logic if zDiffCmd is NULL. Otherwise call the
813 ** command zDiffCmd to do the diffing.
814 **
815 ** When using an external diff program, zBinGlob contains the GLOB patterns
816 ** for file names to treat as binary. If fIncludeBinary is zero, these files
817 ** will be skipped in addition to files that may contain binary content.
818 */
819 void diff_against_disk(
820 const char *zFrom, /* Version to difference from */
821 DiffConfig *pCfg, /* Flags controlling diff output */
822 FileDirList *pFileDir, /* Which files to diff */
823 Blob *pOut /* Blob to output diff instead of stdout */
824 ){
825 int vid;
826 Blob sql;
827 Stmt q;
828 int asNewFile; /* Treat non-existant files as empty files */
@@ -947,20 +948,20 @@
947 db_finalize(&q);
948 db_end_transaction(1); /* ROLLBACK */
949 }
950
951 /*
952 ** Run a diff between the undo buffer and files on disk.
953 **
954 ** Use the internal diff logic if zDiffCmd is NULL. Otherwise call the
955 ** command zDiffCmd to do the diffing.
956 **
957 ** When using an external diff program, zBinGlob contains the GLOB patterns
958 ** for file names to treat as binary. If fIncludeBinary is zero, these files
959 ** will be skipped in addition to files that may contain binary content.
960 */
961 static void diff_against_undo(
962 DiffConfig *pCfg, /* Flags controlling diff output */
963 FileDirList *pFileDir /* List of files and directories to diff */
964 ){
965 Stmt q;
966 Blob content;
@@ -1107,10 +1108,67 @@
1107 }
1108 }
1109 manifest_destroy(pFrom);
1110 manifest_destroy(pTo);
1111 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1112
1113 /*
1114 ** Return the name of the external diff command, or return NULL if
1115 ** no external diff command is defined.
1116 */
@@ -1243,10 +1301,14 @@
1243 ** option specifies the check-in from which the second version of the file
1244 ** or files is taken. If there is no "--to" option then the (possibly edited)
1245 ** files in the current check-out are used. The "--checkin VERSION" option
1246 ** shows the changes made by check-in VERSION relative to its primary parent.
1247 ** The "--branch BRANCHNAME" shows all the changes on the branch BRANCHNAME.
 
 
 
 
1248 **
1249 ** The "-i" command-line option forces the use of Fossil's own internal
1250 ** diff logic rather than any external diff program that might be configured
1251 ** using the "setting" command. If no external diff program is configured,
1252 ** then the "-i" option is a no-op. The "-i" option converts "gdiff" into
@@ -1275,11 +1337,13 @@
1275 ** with negative N meaning show all content
1276 ** --dark Use dark mode for the Tcl/Tk-based GUI and HTML
1277 ** --diff-binary BOOL Include binary files with external commands
1278 ** --exec-abs-paths Force absolute path names on external commands
1279 ** --exec-rel-paths Force relative path names on external commands
1280 ** -r|--from VERSION Select VERSION as source for the diff
 
 
1281 ** -w|--ignore-all-space Ignore white space when comparing lines
1282 ** -i|--internal Use internal diff logic
1283 ** --invert Invert the diff
1284 ** --json Output formatted as JSON
1285 ** -n|--linenum Show line numbers
@@ -1289,11 +1353,11 @@
1289 ** --strip-trailing-cr Strip trailing CR
1290 ** --tcl Tcl-formatted output used internally by --tk
1291 ** --tclsh PATH Tcl/Tk shell used for --tk (default: "tclsh")
1292 ** --tk Launch a Tcl/Tk GUI for display
1293 ** --to VERSION Select VERSION as target for the diff
1294 ** --undo Diff against the "undo" buffer
1295 ** --unified Unified diff
1296 ** -v|--verbose Output complete text of added or deleted files
1297 ** -h|--versions Show compared versions in the diff header
1298 ** --webpage Format output as a stand-alone HTML webpage
1299 ** -W|--width N Width of lines in side-by-side diff
@@ -1306,10 +1370,11 @@
1306 const char *zCheckin; /* Check-in version number */
1307 const char *zBranch; /* Branch to diff */
1308 int againstUndo = 0; /* Diff against files in the undo buffer */
1309 FileDirList *pFileDir = 0; /* Restrict the diff to these files */
1310 DiffConfig DCfg; /* Diff configuration object */
 
1311
1312 if( find_option("tk",0,0)!=0 || has_option("tclsh") ){
1313 diff_tk("diff", 2);
1314 return;
1315 }
@@ -1317,11 +1382,11 @@
1317 zFrom = find_option("from", "r", 1);
1318 zTo = find_option("to", 0, 1);
1319 zCheckin = find_option("checkin", "ci", 1);
1320 zBranch = find_option("branch", 0, 1);
1321 againstUndo = find_option("undo",0,0)!=0;
1322 if( againstUndo && ( zFrom!=0 || zTo!=0 || zCheckin!=0 || zBranch!=0) ){
1323 fossil_fatal("cannot use --undo together with --from, --to, --checkin,"
1324 " or --branch");
1325 }
1326 if( zBranch ){
1327 if( zTo || zFrom || zCheckin ){
@@ -1328,14 +1393,13 @@
1328 fossil_fatal("cannot use --from, --to, or --checkin with --branch");
1329 }
1330 zTo = zBranch;
1331 zFrom = mprintf("root:%s", zBranch);
1332 }
1333 if( zCheckin!=0 && ( zFrom!=0 || zTo!=0 ) ){
1334 fossil_fatal("cannot use --checkin together with --from or --to");
1335 }
1336 g.diffCnt[0] = g.diffCnt[1] = g.diffCnt[2] = 0;
1337 if( 0==zCheckin ){
1338 if( zTo==0 || againstUndo ){
1339 db_must_be_within_tree();
1340 }else if( zFrom==0 ){
1341 fossil_fatal("must use --from if --to is present");
@@ -1343,13 +1407,23 @@
1343 db_find_and_open_repository(0, 0);
1344 }
1345 }else{
1346 db_find_and_open_repository(0, 0);
1347 }
1348 diff_options(&DCfg, isGDiff, 0);
1349 determine_exec_relative_option(1);
 
 
 
 
 
 
 
 
 
 
1350 verify_all_options();
 
1351 if( g.argc>=3 ){
1352 int i;
1353 Blob fname;
1354 pFileDir = fossil_malloc( sizeof(*pFileDir) * (g.argc-1) );
1355 memset(pFileDir, 0, sizeof(*pFileDir) * (g.argc-1));
@@ -1376,18 +1450,20 @@
1376 if( zFrom==0 ){
1377 fossil_fatal("check-in %s has no parent", zTo);
1378 }
1379 }
1380 diff_begin(&DCfg);
1381 if( againstUndo ){
 
 
1382 if( db_lget_int("undo_available",0)==0 ){
1383 fossil_print("No undo or redo is available\n");
1384 return;
1385 }
1386 diff_against_undo(&DCfg, pFileDir);
1387 }else if( zTo==0 ){
1388 diff_against_disk(zFrom, &DCfg, pFileDir, 0);
1389 }else{
1390 diff_two_versions(zFrom, zTo, &DCfg, pFileDir);
1391 }
1392 if( pFileDir ){
1393 int i;
1394
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -803,26 +803,27 @@
803 blob_reset(&file);
804 return rc;
805 }
806
807 /*
808 ** Run a diff between the version zFrom and files on disk in the current
809 ** working checkout. zFrom might be NULL which means to simply show the
810 ** difference between the edited files on disk and the check-out on which
811 ** they are based.
812 **
813 ** Use the internal diff logic if zDiffCmd is NULL. Otherwise call the
814 ** command zDiffCmd to do the diffing.
815 **
816 ** When using an external diff program, zBinGlob contains the GLOB patterns
817 ** for file names to treat as binary. If fIncludeBinary is zero, these files
818 ** will be skipped in addition to files that may contain binary content.
819 */
820 void diff_version_to_checkout(
821 const char *zFrom, /* Version to difference from */
822 DiffConfig *pCfg, /* Flags controlling diff output */
823 FileDirList *pFileDir, /* Which files to diff */
824 Blob *pOut /* Blob to output diff instead of stdout */
825 ){
826 int vid;
827 Blob sql;
828 Stmt q;
829 int asNewFile; /* Treat non-existant files as empty files */
@@ -947,20 +948,20 @@
948 db_finalize(&q);
949 db_end_transaction(1); /* ROLLBACK */
950 }
951
952 /*
953 ** Run a diff from the undo buffer to files on disk.
954 **
955 ** Use the internal diff logic if zDiffCmd is NULL. Otherwise call the
956 ** command zDiffCmd to do the diffing.
957 **
958 ** When using an external diff program, zBinGlob contains the GLOB patterns
959 ** for file names to treat as binary. If fIncludeBinary is zero, these files
960 ** will be skipped in addition to files that may contain binary content.
961 */
962 static void diff_undo_to_checkout(
963 DiffConfig *pCfg, /* Flags controlling diff output */
964 FileDirList *pFileDir /* List of files and directories to diff */
965 ){
966 Stmt q;
967 Blob content;
@@ -1107,10 +1108,67 @@
1108 }
1109 }
1110 manifest_destroy(pFrom);
1111 manifest_destroy(pTo);
1112 }
1113
1114 /*
1115 ** Compute the difference from an external tree of files to the current
1116 ** working checkout with its edits.
1117 **
1118 ** To put it another way: Every managed file in the current working
1119 ** checkout is compared to the file with same name under zExternBase. The
1120 ** zExternBase files are on the left and the files in the current working
1121 ** directory are on the right.
1122 */
1123 void diff_externbase_to_checkout(
1124 const char *zExternBase, /* Remote tree to use as the baseline */
1125 DiffConfig *pCfg, /* Diff settings */
1126 FileDirList *pFileDir /* Only look at these files */
1127 ){
1128 int vid;
1129 Stmt q;
1130
1131 vid = db_lget_int("checkout",0);
1132 if( file_isdir(zExternBase, ExtFILE)!=1 ){
1133 fossil_fatal("\"%s\" is not a directory", zExternBase);
1134 }
1135 db_prepare(&q,
1136 "SELECT pathname FROM vfile WHERE vid=%d ORDER BY pathname",
1137 vid
1138 );
1139 while( db_step(&q)==SQLITE_ROW ){
1140 const char *zFile; /* Name of file in the repository */
1141 char *zLhs; /* Full name of left-hand side file */
1142 char *zRhs; /* Full name of right-hand side file */
1143 Blob rhs; /* Full text of RHS */
1144 Blob lhs; /* Full text of LHS */
1145
1146 zFile = db_column_text(&q,0);
1147 if( !file_dir_match(pFileDir, zFile) ) continue;
1148 zLhs = mprintf("%s/%s", zExternBase, zFile);
1149 zRhs = mprintf("%s%s", g.zLocalRoot, zFile);
1150 if( file_size(zLhs, ExtFILE)<0 ){
1151 blob_zero(&lhs);
1152 }else{
1153 blob_read_from_file(&lhs, zLhs, ExtFILE);
1154 }
1155 blob_read_from_file(&rhs, zRhs, ExtFILE);
1156 if( blob_size(&lhs)!=blob_size(&rhs)
1157 || memcmp(blob_buffer(&lhs), blob_buffer(&rhs), blob_size(&lhs))!=0
1158 ){
1159 diff_print_index(zFile, pCfg, 0);
1160 diff_file_mem(&lhs, &rhs, zFile, pCfg);
1161 }
1162 blob_reset(&lhs);
1163 blob_reset(&rhs);
1164 fossil_free(zLhs);
1165 fossil_free(zRhs);
1166 }
1167 db_finalize(&q);
1168 }
1169
1170
1171 /*
1172 ** Return the name of the external diff command, or return NULL if
1173 ** no external diff command is defined.
1174 */
@@ -1243,10 +1301,14 @@
1301 ** option specifies the check-in from which the second version of the file
1302 ** or files is taken. If there is no "--to" option then the (possibly edited)
1303 ** files in the current check-out are used. The "--checkin VERSION" option
1304 ** shows the changes made by check-in VERSION relative to its primary parent.
1305 ** The "--branch BRANCHNAME" shows all the changes on the branch BRANCHNAME.
1306 **
1307 ** With the "--from VERSION" option, if VERSION is actually a directory name
1308 ** (not a tag or check-in hash) then the files under that directory are used
1309 ** as the baseline for the diff.
1310 **
1311 ** The "-i" command-line option forces the use of Fossil's own internal
1312 ** diff logic rather than any external diff program that might be configured
1313 ** using the "setting" command. If no external diff program is configured,
1314 ** then the "-i" option is a no-op. The "-i" option converts "gdiff" into
@@ -1275,11 +1337,13 @@
1337 ** with negative N meaning show all content
1338 ** --dark Use dark mode for the Tcl/Tk-based GUI and HTML
1339 ** --diff-binary BOOL Include binary files with external commands
1340 ** --exec-abs-paths Force absolute path names on external commands
1341 ** --exec-rel-paths Force relative path names on external commands
1342 ** -r|--from VERSION Use VERSION as the baseline for the diff, or
1343 ** if VERSION is a directory name, use files in
1344 ** that directory as the baseline.
1345 ** -w|--ignore-all-space Ignore white space when comparing lines
1346 ** -i|--internal Use internal diff logic
1347 ** --invert Invert the diff
1348 ** --json Output formatted as JSON
1349 ** -n|--linenum Show line numbers
@@ -1289,11 +1353,11 @@
1353 ** --strip-trailing-cr Strip trailing CR
1354 ** --tcl Tcl-formatted output used internally by --tk
1355 ** --tclsh PATH Tcl/Tk shell used for --tk (default: "tclsh")
1356 ** --tk Launch a Tcl/Tk GUI for display
1357 ** --to VERSION Select VERSION as target for the diff
1358 ** --undo Use the undo buffer as the baseline
1359 ** --unified Unified diff
1360 ** -v|--verbose Output complete text of added or deleted files
1361 ** -h|--versions Show compared versions in the diff header
1362 ** --webpage Format output as a stand-alone HTML webpage
1363 ** -W|--width N Width of lines in side-by-side diff
@@ -1306,10 +1370,11 @@
1370 const char *zCheckin; /* Check-in version number */
1371 const char *zBranch; /* Branch to diff */
1372 int againstUndo = 0; /* Diff against files in the undo buffer */
1373 FileDirList *pFileDir = 0; /* Restrict the diff to these files */
1374 DiffConfig DCfg; /* Diff configuration object */
1375 int bFromIsDir = 0; /* True if zFrom is a directory name */
1376
1377 if( find_option("tk",0,0)!=0 || has_option("tclsh") ){
1378 diff_tk("diff", 2);
1379 return;
1380 }
@@ -1317,11 +1382,11 @@
1382 zFrom = find_option("from", "r", 1);
1383 zTo = find_option("to", 0, 1);
1384 zCheckin = find_option("checkin", "ci", 1);
1385 zBranch = find_option("branch", 0, 1);
1386 againstUndo = find_option("undo",0,0)!=0;
1387 if( againstUndo && (zFrom!=0 || zTo!=0 || zCheckin!=0 || zBranch!=0) ){
1388 fossil_fatal("cannot use --undo together with --from, --to, --checkin,"
1389 " or --branch");
1390 }
1391 if( zBranch ){
1392 if( zTo || zFrom || zCheckin ){
@@ -1328,14 +1393,13 @@
1393 fossil_fatal("cannot use --from, --to, or --checkin with --branch");
1394 }
1395 zTo = zBranch;
1396 zFrom = mprintf("root:%s", zBranch);
1397 }
1398 if( zCheckin!=0 && (zFrom!=0 || zTo!=0) ){
1399 fossil_fatal("cannot use --checkin together with --from or --to");
1400 }
 
1401 if( 0==zCheckin ){
1402 if( zTo==0 || againstUndo ){
1403 db_must_be_within_tree();
1404 }else if( zFrom==0 ){
1405 fossil_fatal("must use --from if --to is present");
@@ -1343,13 +1407,23 @@
1407 db_find_and_open_repository(0, 0);
1408 }
1409 }else{
1410 db_find_and_open_repository(0, 0);
1411 }
 
1412 determine_exec_relative_option(1);
1413 if( zFrom!=file_tail(zFrom)
1414 && file_isdir(zFrom, ExtFILE)==1
1415 && !db_exists("SELECT 1 FROM tag WHERE tagname='sym-%q'", zFrom)
1416 ){
1417 bFromIsDir = 1;
1418 if( zTo ){
1419 fossil_fatal("cannot use --to together with \"--from PATH\"");
1420 }
1421 }
1422 diff_options(&DCfg, isGDiff, 0);
1423 verify_all_options();
1424 g.diffCnt[0] = g.diffCnt[1] = g.diffCnt[2] = 0;
1425 if( g.argc>=3 ){
1426 int i;
1427 Blob fname;
1428 pFileDir = fossil_malloc( sizeof(*pFileDir) * (g.argc-1) );
1429 memset(pFileDir, 0, sizeof(*pFileDir) * (g.argc-1));
@@ -1376,18 +1450,20 @@
1450 if( zFrom==0 ){
1451 fossil_fatal("check-in %s has no parent", zTo);
1452 }
1453 }
1454 diff_begin(&DCfg);
1455 if( bFromIsDir ){
1456 diff_externbase_to_checkout(zFrom, &DCfg, pFileDir);
1457 }else if( againstUndo ){
1458 if( db_lget_int("undo_available",0)==0 ){
1459 fossil_print("No undo or redo is available\n");
1460 return;
1461 }
1462 diff_undo_to_checkout(&DCfg, pFileDir);
1463 }else if( zTo==0 ){
1464 diff_version_to_checkout(zFrom, &DCfg, pFileDir, 0);
1465 }else{
1466 diff_two_versions(zFrom, zTo, &DCfg, pFileDir);
1467 }
1468 if( pFileDir ){
1469 int i;
1470
+8 -1
--- src/doc.c
+++ src/doc.c
@@ -788,11 +788,11 @@
788788
){
789789
Blob title;
790790
int isPopup = P("popup")!=0;
791791
blob_init(&title,0,0);
792792
if( fossil_strcmp(zMime, "text/x-fossil-wiki")==0 ){
793
- Blob tail;
793
+ Blob tail = BLOB_INITIALIZER;
794794
style_adunit_config(ADUNIT_RIGHT_OK);
795795
if( wiki_find_title(pBody, &title, &tail) ){
796796
if( !isPopup ) style_header("%s", blob_str(&title));
797797
wiki_convert(&tail, 0, WIKI_BUTTONS);
798798
}else{
@@ -801,10 +801,11 @@
801801
}
802802
if( !isPopup ){
803803
document_emit_js();
804804
style_finish_page();
805805
}
806
+ blob_reset(&tail);
806807
}else if( fossil_strcmp(zMime, "text/x-markdown")==0 ){
807808
Blob tail = BLOB_INITIALIZER;
808809
markdown_to_html(pBody, &title, &tail);
809810
if( !isPopup ){
810811
if( blob_size(&title)>0 ){
@@ -816,10 +817,11 @@
816817
convert_href_and_output(&tail);
817818
if( !isPopup ){
818819
document_emit_js();
819820
style_finish_page();
820821
}
822
+ blob_reset(&tail);
821823
}else if( fossil_strcmp(zMime, "text/plain")==0 ){
822824
style_header("%s", zDefaultTitle);
823825
@ <blockquote><pre>
824826
@ %h(blob_str(pBody))
825827
@ </pre></blockquote>
@@ -949,10 +951,11 @@
949951
950952
login_check_credentials();
951953
if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
952954
style_set_current_feature("doc");
953955
blob_init(&title, 0, 0);
956
+ blob_init(&filebody, 0, 0);
954957
zDfltTitle = isUV ? "" : "Documentation";
955958
db_begin_transaction();
956959
while( rid==0 && (++nMiss)<=count(azSuffix) ){
957960
zName = P("name");
958961
if( isUV ){
@@ -1059,10 +1062,12 @@
10591062
}
10601063
cgi_check_for_malice();
10611064
document_render(&filebody, zMime, zDfltTitle, zName);
10621065
if( nMiss>=count(azSuffix) ) cgi_set_status(404, "Not Found");
10631066
db_end_transaction(0);
1067
+ blob_reset(&title);
1068
+ blob_reset(&filebody);
10641069
return;
10651070
10661071
/* Jump here when unable to locate the document */
10671072
doc_not_found:
10681073
db_end_transaction(0);
@@ -1075,10 +1080,12 @@
10751080
@ <p>Document %h(zOrigName) not found
10761081
if( fossil_strcmp(zCheckin,"ckout")!=0 ){
10771082
@ in %z(href("%R/tree?ci=%T",zCheckin))%h(zCheckin)</a>
10781083
}
10791084
style_finish_page();
1085
+ blob_reset(&title);
1086
+ blob_reset(&filebody);
10801087
return;
10811088
}
10821089
10831090
/*
10841091
** The default logo.
10851092
--- src/doc.c
+++ src/doc.c
@@ -788,11 +788,11 @@
788 ){
789 Blob title;
790 int isPopup = P("popup")!=0;
791 blob_init(&title,0,0);
792 if( fossil_strcmp(zMime, "text/x-fossil-wiki")==0 ){
793 Blob tail;
794 style_adunit_config(ADUNIT_RIGHT_OK);
795 if( wiki_find_title(pBody, &title, &tail) ){
796 if( !isPopup ) style_header("%s", blob_str(&title));
797 wiki_convert(&tail, 0, WIKI_BUTTONS);
798 }else{
@@ -801,10 +801,11 @@
801 }
802 if( !isPopup ){
803 document_emit_js();
804 style_finish_page();
805 }
 
806 }else if( fossil_strcmp(zMime, "text/x-markdown")==0 ){
807 Blob tail = BLOB_INITIALIZER;
808 markdown_to_html(pBody, &title, &tail);
809 if( !isPopup ){
810 if( blob_size(&title)>0 ){
@@ -816,10 +817,11 @@
816 convert_href_and_output(&tail);
817 if( !isPopup ){
818 document_emit_js();
819 style_finish_page();
820 }
 
821 }else if( fossil_strcmp(zMime, "text/plain")==0 ){
822 style_header("%s", zDefaultTitle);
823 @ <blockquote><pre>
824 @ %h(blob_str(pBody))
825 @ </pre></blockquote>
@@ -949,10 +951,11 @@
949
950 login_check_credentials();
951 if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
952 style_set_current_feature("doc");
953 blob_init(&title, 0, 0);
 
954 zDfltTitle = isUV ? "" : "Documentation";
955 db_begin_transaction();
956 while( rid==0 && (++nMiss)<=count(azSuffix) ){
957 zName = P("name");
958 if( isUV ){
@@ -1059,10 +1062,12 @@
1059 }
1060 cgi_check_for_malice();
1061 document_render(&filebody, zMime, zDfltTitle, zName);
1062 if( nMiss>=count(azSuffix) ) cgi_set_status(404, "Not Found");
1063 db_end_transaction(0);
 
 
1064 return;
1065
1066 /* Jump here when unable to locate the document */
1067 doc_not_found:
1068 db_end_transaction(0);
@@ -1075,10 +1080,12 @@
1075 @ <p>Document %h(zOrigName) not found
1076 if( fossil_strcmp(zCheckin,"ckout")!=0 ){
1077 @ in %z(href("%R/tree?ci=%T",zCheckin))%h(zCheckin)</a>
1078 }
1079 style_finish_page();
 
 
1080 return;
1081 }
1082
1083 /*
1084 ** The default logo.
1085
--- src/doc.c
+++ src/doc.c
@@ -788,11 +788,11 @@
788 ){
789 Blob title;
790 int isPopup = P("popup")!=0;
791 blob_init(&title,0,0);
792 if( fossil_strcmp(zMime, "text/x-fossil-wiki")==0 ){
793 Blob tail = BLOB_INITIALIZER;
794 style_adunit_config(ADUNIT_RIGHT_OK);
795 if( wiki_find_title(pBody, &title, &tail) ){
796 if( !isPopup ) style_header("%s", blob_str(&title));
797 wiki_convert(&tail, 0, WIKI_BUTTONS);
798 }else{
@@ -801,10 +801,11 @@
801 }
802 if( !isPopup ){
803 document_emit_js();
804 style_finish_page();
805 }
806 blob_reset(&tail);
807 }else if( fossil_strcmp(zMime, "text/x-markdown")==0 ){
808 Blob tail = BLOB_INITIALIZER;
809 markdown_to_html(pBody, &title, &tail);
810 if( !isPopup ){
811 if( blob_size(&title)>0 ){
@@ -816,10 +817,11 @@
817 convert_href_and_output(&tail);
818 if( !isPopup ){
819 document_emit_js();
820 style_finish_page();
821 }
822 blob_reset(&tail);
823 }else if( fossil_strcmp(zMime, "text/plain")==0 ){
824 style_header("%s", zDefaultTitle);
825 @ <blockquote><pre>
826 @ %h(blob_str(pBody))
827 @ </pre></blockquote>
@@ -949,10 +951,11 @@
951
952 login_check_credentials();
953 if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
954 style_set_current_feature("doc");
955 blob_init(&title, 0, 0);
956 blob_init(&filebody, 0, 0);
957 zDfltTitle = isUV ? "" : "Documentation";
958 db_begin_transaction();
959 while( rid==0 && (++nMiss)<=count(azSuffix) ){
960 zName = P("name");
961 if( isUV ){
@@ -1059,10 +1062,12 @@
1062 }
1063 cgi_check_for_malice();
1064 document_render(&filebody, zMime, zDfltTitle, zName);
1065 if( nMiss>=count(azSuffix) ) cgi_set_status(404, "Not Found");
1066 db_end_transaction(0);
1067 blob_reset(&title);
1068 blob_reset(&filebody);
1069 return;
1070
1071 /* Jump here when unable to locate the document */
1072 doc_not_found:
1073 db_end_transaction(0);
@@ -1075,10 +1080,12 @@
1080 @ <p>Document %h(zOrigName) not found
1081 if( fossil_strcmp(zCheckin,"ckout")!=0 ){
1082 @ in %z(href("%R/tree?ci=%T",zCheckin))%h(zCheckin)</a>
1083 }
1084 style_finish_page();
1085 blob_reset(&title);
1086 blob_reset(&filebody);
1087 return;
1088 }
1089
1090 /*
1091 ** The default logo.
1092
+18
--- src/encode.c
+++ src/encode.c
@@ -729,10 +729,28 @@
729729
while( *z && n-- ){
730730
*z = zEncode[zDecode[(*z)&0x7f]&0x1f];
731731
z++;
732732
}
733733
}
734
+
735
+/*
736
+** Decode hexadecimal into a string and return the new string. Space to
737
+** hold the string is obtained from fossil_malloc() and should be released
738
+** by the caller.
739
+**
740
+** If the input is not hex, return NULL.
741
+*/
742
+char *decode16_dup(const char *zIn){
743
+ int nIn = (int)strlen(zIn);
744
+ char *zOut;
745
+ if( !validate16(zIn, nIn) ) return 0;
746
+ zOut = fossil_malloc(nIn/2+1);
747
+ decode16((const u8*)zIn, (u8*)zOut, nIn);
748
+ zOut[nIn/2] = 0;
749
+ return zOut;
750
+}
751
+
734752
735753
/*
736754
** Decode a string encoded using "quoted-printable".
737755
**
738756
** (1) "=" followed by two hex digits becomes a single
739757
--- src/encode.c
+++ src/encode.c
@@ -729,10 +729,28 @@
729 while( *z && n-- ){
730 *z = zEncode[zDecode[(*z)&0x7f]&0x1f];
731 z++;
732 }
733 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
734
735 /*
736 ** Decode a string encoded using "quoted-printable".
737 **
738 ** (1) "=" followed by two hex digits becomes a single
739
--- src/encode.c
+++ src/encode.c
@@ -729,10 +729,28 @@
729 while( *z && n-- ){
730 *z = zEncode[zDecode[(*z)&0x7f]&0x1f];
731 z++;
732 }
733 }
734
735 /*
736 ** Decode hexadecimal into a string and return the new string. Space to
737 ** hold the string is obtained from fossil_malloc() and should be released
738 ** by the caller.
739 **
740 ** If the input is not hex, return NULL.
741 */
742 char *decode16_dup(const char *zIn){
743 int nIn = (int)strlen(zIn);
744 char *zOut;
745 if( !validate16(zIn, nIn) ) return 0;
746 zOut = fossil_malloc(nIn/2+1);
747 decode16((const u8*)zIn, (u8*)zOut, nIn);
748 zOut[nIn/2] = 0;
749 return zOut;
750 }
751
752
753 /*
754 ** Decode a string encoded using "quoted-printable".
755 **
756 ** (1) "=" followed by two hex digits becomes a single
757
+39
--- src/file.c
+++ src/file.c
@@ -555,10 +555,28 @@
555555
if( fossil_isdirsep(z[0]) ) zTail = &z[1];
556556
z++;
557557
}
558558
return zTail;
559559
}
560
+
561
+/*
562
+** Return the tail of a command: the basename of the putative executable (which
563
+** could be quoted when containing spaces) and the following arguments.
564
+*/
565
+const char *command_tail(const char *z){
566
+ const char *zTail = z;
567
+ char chQuote = 0;
568
+ if( !zTail ) return 0;
569
+ while( z[0] && (!fossil_isspace(z[0]) || chQuote) ){
570
+ if( z[0]=='"' || z[0]=='\'' ){
571
+ chQuote = (chQuote==z[0]) ? 0 : z[0];
572
+ }
573
+ if( fossil_isdirsep(z[0]) ) zTail = &z[1];
574
+ z++;
575
+ }
576
+ return zTail;
577
+}
560578
561579
/*
562580
** Return the directory of a file path name. The directory is all components
563581
** except the last one. For example, the directory of "/a/b/c.d" is "/a/b".
564582
** If there is no directory, NULL is returned; otherwise, the returned memory
@@ -570,10 +588,27 @@
570588
return mprintf("%.*s", (int)(zTail-z-1), z);
571589
}else{
572590
return 0;
573591
}
574592
}
593
+
594
+/*
595
+** Return the basename of the putative executable in a command (w/o arguments).
596
+** The returned memory should be freed via fossil_free().
597
+*/
598
+char *command_basename(const char *z){
599
+ const char *zTail = command_tail(z);
600
+ const char *zEnd = zTail;
601
+ while( zEnd[0] && !fossil_isspace(zEnd[0]) && zEnd[0]!='"' && zEnd[0]!='\'' ){
602
+ zEnd++;
603
+ }
604
+ if( zEnd ){
605
+ return mprintf("%.*s", (int)(zEnd-zTail), zTail);
606
+ }else{
607
+ return 0;
608
+ }
609
+}
575610
576611
/* SQL Function: file_dirname(NAME)
577612
**
578613
** Return the directory for NAME
579614
*/
@@ -2973,19 +3008,23 @@
29733008
** Returns 1 if the given directory contains a file named .fslckout, 2
29743009
** if it contains a file named _FOSSIL_, else returns 0.
29753010
*/
29763011
int dir_has_ckout_db(const char *zDir){
29773012
int rc = 0;
3013
+ i64 sz;
29783014
char * zCkoutDb = mprintf("%//.fslckout", zDir);
29793015
if(file_isfile(zCkoutDb, ExtFILE)){
29803016
rc = 1;
29813017
}else{
29823018
fossil_free(zCkoutDb);
29833019
zCkoutDb = mprintf("%//_FOSSIL_", zDir);
29843020
if(file_isfile(zCkoutDb, ExtFILE)){
29853021
rc = 2;
29863022
}
3023
+ }
3024
+ if( rc && ((sz = file_size(zCkoutDb, ExtFILE))<1024 || (sz%512)!=0) ){
3025
+ rc = 0;
29873026
}
29883027
fossil_free(zCkoutDb);
29893028
return rc;
29903029
}
29913030
29923031
--- src/file.c
+++ src/file.c
@@ -555,10 +555,28 @@
555 if( fossil_isdirsep(z[0]) ) zTail = &z[1];
556 z++;
557 }
558 return zTail;
559 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
560
561 /*
562 ** Return the directory of a file path name. The directory is all components
563 ** except the last one. For example, the directory of "/a/b/c.d" is "/a/b".
564 ** If there is no directory, NULL is returned; otherwise, the returned memory
@@ -570,10 +588,27 @@
570 return mprintf("%.*s", (int)(zTail-z-1), z);
571 }else{
572 return 0;
573 }
574 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
575
576 /* SQL Function: file_dirname(NAME)
577 **
578 ** Return the directory for NAME
579 */
@@ -2973,19 +3008,23 @@
2973 ** Returns 1 if the given directory contains a file named .fslckout, 2
2974 ** if it contains a file named _FOSSIL_, else returns 0.
2975 */
2976 int dir_has_ckout_db(const char *zDir){
2977 int rc = 0;
 
2978 char * zCkoutDb = mprintf("%//.fslckout", zDir);
2979 if(file_isfile(zCkoutDb, ExtFILE)){
2980 rc = 1;
2981 }else{
2982 fossil_free(zCkoutDb);
2983 zCkoutDb = mprintf("%//_FOSSIL_", zDir);
2984 if(file_isfile(zCkoutDb, ExtFILE)){
2985 rc = 2;
2986 }
 
 
 
2987 }
2988 fossil_free(zCkoutDb);
2989 return rc;
2990 }
2991
2992
--- src/file.c
+++ src/file.c
@@ -555,10 +555,28 @@
555 if( fossil_isdirsep(z[0]) ) zTail = &z[1];
556 z++;
557 }
558 return zTail;
559 }
560
561 /*
562 ** Return the tail of a command: the basename of the putative executable (which
563 ** could be quoted when containing spaces) and the following arguments.
564 */
565 const char *command_tail(const char *z){
566 const char *zTail = z;
567 char chQuote = 0;
568 if( !zTail ) return 0;
569 while( z[0] && (!fossil_isspace(z[0]) || chQuote) ){
570 if( z[0]=='"' || z[0]=='\'' ){
571 chQuote = (chQuote==z[0]) ? 0 : z[0];
572 }
573 if( fossil_isdirsep(z[0]) ) zTail = &z[1];
574 z++;
575 }
576 return zTail;
577 }
578
579 /*
580 ** Return the directory of a file path name. The directory is all components
581 ** except the last one. For example, the directory of "/a/b/c.d" is "/a/b".
582 ** If there is no directory, NULL is returned; otherwise, the returned memory
@@ -570,10 +588,27 @@
588 return mprintf("%.*s", (int)(zTail-z-1), z);
589 }else{
590 return 0;
591 }
592 }
593
594 /*
595 ** Return the basename of the putative executable in a command (w/o arguments).
596 ** The returned memory should be freed via fossil_free().
597 */
598 char *command_basename(const char *z){
599 const char *zTail = command_tail(z);
600 const char *zEnd = zTail;
601 while( zEnd[0] && !fossil_isspace(zEnd[0]) && zEnd[0]!='"' && zEnd[0]!='\'' ){
602 zEnd++;
603 }
604 if( zEnd ){
605 return mprintf("%.*s", (int)(zEnd-zTail), zTail);
606 }else{
607 return 0;
608 }
609 }
610
611 /* SQL Function: file_dirname(NAME)
612 **
613 ** Return the directory for NAME
614 */
@@ -2973,19 +3008,23 @@
3008 ** Returns 1 if the given directory contains a file named .fslckout, 2
3009 ** if it contains a file named _FOSSIL_, else returns 0.
3010 */
3011 int dir_has_ckout_db(const char *zDir){
3012 int rc = 0;
3013 i64 sz;
3014 char * zCkoutDb = mprintf("%//.fslckout", zDir);
3015 if(file_isfile(zCkoutDb, ExtFILE)){
3016 rc = 1;
3017 }else{
3018 fossil_free(zCkoutDb);
3019 zCkoutDb = mprintf("%//_FOSSIL_", zDir);
3020 if(file_isfile(zCkoutDb, ExtFILE)){
3021 rc = 2;
3022 }
3023 }
3024 if( rc && ((sz = file_size(zCkoutDb, ExtFILE))<1024 || (sz%512)!=0) ){
3025 rc = 0;
3026 }
3027 fossil_free(zCkoutDb);
3028 return rc;
3029 }
3030
3031
+1 -1
--- src/finfo.c
+++ src/finfo.c
@@ -37,11 +37,11 @@
3737
** hash and the check-in and time when the current version of the file
3838
** was created. Use -v for additional information. Add the -r VERSION
3939
** option to see similar information about the same file for the check-in
4040
** specified by VERSION.
4141
**
42
-** In the -s mode prints the status as <status> <revision>. This is
42
+** The -s mode prints the status as <status> <revision>. This is
4343
** a quick status and does not check for up-to-date-ness of the file.
4444
**
4545
** In the -p mode, there's an optional flag "-r|--revision REVISION".
4646
** The specified version (or the latest checked-out version) is printed
4747
** to stdout. The -p mode is another form of the "cat" command.
4848
--- src/finfo.c
+++ src/finfo.c
@@ -37,11 +37,11 @@
37 ** hash and the check-in and time when the current version of the file
38 ** was created. Use -v for additional information. Add the -r VERSION
39 ** option to see similar information about the same file for the check-in
40 ** specified by VERSION.
41 **
42 ** In the -s mode prints the status as <status> <revision>. This is
43 ** a quick status and does not check for up-to-date-ness of the file.
44 **
45 ** In the -p mode, there's an optional flag "-r|--revision REVISION".
46 ** The specified version (or the latest checked-out version) is printed
47 ** to stdout. The -p mode is another form of the "cat" command.
48
--- src/finfo.c
+++ src/finfo.c
@@ -37,11 +37,11 @@
37 ** hash and the check-in and time when the current version of the file
38 ** was created. Use -v for additional information. Add the -r VERSION
39 ** option to see similar information about the same file for the check-in
40 ** specified by VERSION.
41 **
42 ** The -s mode prints the status as <status> <revision>. This is
43 ** a quick status and does not check for up-to-date-ness of the file.
44 **
45 ** In the -p mode, there's an optional flag "-r|--revision REVISION".
46 ** The specified version (or the latest checked-out version) is printed
47 ** to stdout. The -p mode is another form of the "cat" command.
48
--- src/forum.c
+++ src/forum.c
@@ -1830,11 +1830,10 @@
18301830
if( db_int(0, "SELECT count(*) FROM user "
18311831
" WHERE cap GLOB '*5*' AND cap NOT GLOB '*[as6]*'")==0 ){
18321832
@ <p>No non-supervisor moderators
18331833
}else{
18341834
Stmt q = empty_Stmt;
1835
- int nRows = 0;
18361835
db_prepare(&q, "SELECT uid, login, cap FROM user "
18371836
"WHERE cap GLOB '*5*' AND cap NOT GLOB '*[as6]*'"
18381837
" ORDER BY login");
18391838
@ <table class='bordered'>
18401839
@ <thead><tr><th>User</th><th>Capabilities</th></tr></thead>
@@ -1841,11 +1840,10 @@
18411840
@ <tbody>
18421841
while( SQLITE_ROW==db_step(&q) ){
18431842
const int iUid = db_column_int(&q, 0);
18441843
const char *zUser = db_column_text(&q, 1);
18451844
const char *zCap = db_column_text(&q, 2);
1846
- ++nRows;
18471845
@ <tr>
18481846
@ <td><a href='%R/setup_uedit?id=%d(iUid)'>%h(zUser)</a></td>
18491847
@ <td>(%h(zCap))</td>
18501848
@ </tr>
18511849
}
18521850
--- src/forum.c
+++ src/forum.c
@@ -1830,11 +1830,10 @@
1830 if( db_int(0, "SELECT count(*) FROM user "
1831 " WHERE cap GLOB '*5*' AND cap NOT GLOB '*[as6]*'")==0 ){
1832 @ <p>No non-supervisor moderators
1833 }else{
1834 Stmt q = empty_Stmt;
1835 int nRows = 0;
1836 db_prepare(&q, "SELECT uid, login, cap FROM user "
1837 "WHERE cap GLOB '*5*' AND cap NOT GLOB '*[as6]*'"
1838 " ORDER BY login");
1839 @ <table class='bordered'>
1840 @ <thead><tr><th>User</th><th>Capabilities</th></tr></thead>
@@ -1841,11 +1840,10 @@
1841 @ <tbody>
1842 while( SQLITE_ROW==db_step(&q) ){
1843 const int iUid = db_column_int(&q, 0);
1844 const char *zUser = db_column_text(&q, 1);
1845 const char *zCap = db_column_text(&q, 2);
1846 ++nRows;
1847 @ <tr>
1848 @ <td><a href='%R/setup_uedit?id=%d(iUid)'>%h(zUser)</a></td>
1849 @ <td>(%h(zCap))</td>
1850 @ </tr>
1851 }
1852
--- src/forum.c
+++ src/forum.c
@@ -1830,11 +1830,10 @@
1830 if( db_int(0, "SELECT count(*) FROM user "
1831 " WHERE cap GLOB '*5*' AND cap NOT GLOB '*[as6]*'")==0 ){
1832 @ <p>No non-supervisor moderators
1833 }else{
1834 Stmt q = empty_Stmt;
 
1835 db_prepare(&q, "SELECT uid, login, cap FROM user "
1836 "WHERE cap GLOB '*5*' AND cap NOT GLOB '*[as6]*'"
1837 " ORDER BY login");
1838 @ <table class='bordered'>
1839 @ <thead><tr><th>User</th><th>Capabilities</th></tr></thead>
@@ -1841,11 +1840,10 @@
1840 @ <tbody>
1841 while( SQLITE_ROW==db_step(&q) ){
1842 const int iUid = db_column_int(&q, 0);
1843 const char *zUser = db_column_text(&q, 1);
1844 const char *zCap = db_column_text(&q, 2);
 
1845 @ <tr>
1846 @ <td><a href='%R/setup_uedit?id=%d(iUid)'>%h(zUser)</a></td>
1847 @ <td>(%h(zCap))</td>
1848 @ </tr>
1849 }
1850
+90 -26
--- src/fossil.diff.js
+++ src/fossil.diff.js
@@ -1,28 +1,103 @@
11
/**
22
diff-related JS APIs for fossil.
33
*/
44
"use strict";
5
+/* Locate the UI element (if any) into which we can inject some diff-related
6
+ UI controls. */
7
+window.fossil.onPageLoad(function(){
8
+ const potentialParents = window.fossil.page.diffControlContainers = [
9
+ /* CSS selectors for possible parents for injected diff-related UI
10
+ controls. */
11
+ /* Put the most likely pages at the end, as array.pop() is more
12
+ efficient than array.shift() (see loop below). */
13
+ /* /filedit */ 'body.cpage-fileedit #fileedit-tab-diff-buttons',
14
+ /* /wikiedit */ 'body.cpage-wikiedit #wikiedit-tab-diff-buttons',
15
+ /* /fdiff */ 'body.fdiff form div.submenu',
16
+ /* /vdiff */ 'body.vdiff form div.submenu',
17
+ /* /info, /vinfo, /ckout */ 'body.vinfo div.sectionmenu.info-changes-menu'
18
+ ];
19
+ window.fossil.page.diffControlContainer = undefined;
20
+ while( potentialParents.length ){
21
+ if( (window.fossil.page.diffControlContainer
22
+ = document.querySelector(potentialParents.pop())) ){
23
+ break;
24
+ }
25
+ }
26
+});
27
+
528
window.fossil.onPageLoad(function(){
629
/**
730
Adds toggle checkboxes to each file entry in the diff views for
831
/info and similar pages.
932
*/
33
+ if( !window.fossil.page.diffControlContainer ){
34
+ return;
35
+ }
1036
const D = window.fossil.dom;
11
- const isFdiff = !!document.querySelector('body.fdiff');
37
+ const allToggles = [/*collection of all diff-toggle checkboxes*/];
38
+ let checkedCount =
39
+ 0 /* When showing more than one diff, keep track of how many
40
+ "show/hide" checkboxes are are checked so we can update the
41
+ "show/hide all" label dynamically. */;
42
+ let btnAll /* UI control to show/hide all diffs */;
43
+ /* Install a diff-toggle button for the given diff table element. */
1244
const addToggle = function(diffElem){
1345
const sib = diffElem.previousElementSibling,
14
- btn = sib ? D.addClass(D.checkbox(true), 'diff-toggle') : 0;
46
+ ckbox = sib ? D.addClass(D.checkbox(true), 'diff-toggle') : 0;
1547
if(!sib) return;
16
- if(isFdiff) sib.parentElement.insertBefore(
17
- D.append(D.div(),btn),sib.nextElementSibling);
18
- else D.append(sib,btn);
19
- btn.addEventListener('click', function(){
20
- diffElem.classList.toggle('hidden');
48
+ const lblToggle = D.label();
49
+ D.append(lblToggle, ckbox, D.text(" show/hide "));
50
+ allToggles.push(ckbox);
51
+ ++checkedCount;
52
+ /* Make all of the available empty space a click zone for the checkbox */
53
+ lblToggle.style.flexGrow = 1;
54
+ lblToggle.style.textAlign = 'right';
55
+ D.append(sib, lblToggle);
56
+ ckbox.addEventListener('change', function(){
57
+ diffElem.classList[this.checked ? 'remove' : 'add']('hidden');
58
+ if(btnAll){
59
+ checkedCount += (this.checked ? 1 : -1);
60
+ btnAll.innerText = (checkedCount < allToggles.length)
61
+ ? "Show diffs" : "Hide diffs";
62
+ }
63
+ }, false);
64
+ /* Extend the toggle click zone to all of the non-hyperlink
65
+ elements in the left of this area (filenames and hashes). */
66
+ sib.firstElementChild.addEventListener('click', (event)=>{
67
+ if( event.target===sib.firstElementChild ){
68
+ /* Don't respond to clicks bubbling via hyperlink children */
69
+ ckbox.click();;
70
+ }
71
+ }, false);
72
+ };
73
+ if( !document.querySelector('body.fdiff') ){
74
+ /* Don't show the diff toggle button for /fdiff because it only
75
+ has a single file to show (and also a different DOM layout). */
76
+ document.querySelectorAll('table.diff').forEach(addToggle);
77
+ }
78
+ /**
79
+ Set up a "toggle all diffs" button which toggles all of the
80
+ above-installed checkboxes, but only if more than one diff is
81
+ rendered.
82
+ */
83
+ const icm = allToggles.length>1 ? window.fossil.page.diffControlContainer : 0;
84
+ if(icm) {
85
+ btnAll = D.addClass(D.a("#", "Hide diffs"), "button");
86
+ D.append( icm, btnAll );
87
+ btnAll.addEventListener('click', function(ev){
88
+ ev.preventDefault();
89
+ ev.stopPropagation();
90
+ const show = checkedCount < allToggles.length;
91
+ for( const ckbox of allToggles ){
92
+ /* Toggle all entries to match this new state. We use click()
93
+ instead of ckbox.checked=... so that the on-change event handler
94
+ fires. */
95
+ if(ckbox.checked!==show) ckbox.click();
96
+ }
2197
}, false);
22
- };
23
- document.querySelectorAll('table.diff').forEach(addToggle);
98
+ }
2499
});
25100
26101
window.fossil.onPageLoad(function(){
27102
const F = window.fossil, D = F.dom;
28103
const Diff = F.diff = {
@@ -635,26 +710,15 @@
635710
/* Look for a parent element to hold the sbs-sync-scroll toggle
636711
checkbox. This differs per page. If we don't find one, simply
637712
elide that toggle and use whatever preference the user last
638713
specified (defaulting to on). */
639714
let cbSync /* scroll-sync checkbox */;
640
- let eToggleParent /* element to put the sync-scroll checkbox in */;
641
- const potentialParents = [ /* possible parents for the checkbox */
642
- /* Put the most likely pages at the end, as array.pop() is more
643
- efficient than array.shift() (see loop below). */
644
- /* /filedit */ 'body.cpage-fileedit #fileedit-tab-diff-buttons',
645
- /* /wikiedit */ 'body.cpage-wikiedit #wikiedit-tab-diff-buttons',
646
- /* /fdiff */ 'body.fdiff form div.submenu',
647
- /* /vdiff */ 'body.vdiff form div.submenu',
648
- /* /info, /vinfo */ 'body.vinfo div.sectionmenu.info-changes-menu'
649
- ];
650
- while( potentialParents.length ){
651
- if( (eToggleParent = document.querySelector(potentialParents.pop())) ){
652
- break;
653
- }
654
- }
655
- const keySbsScroll = 'sync-diff-scroll' /* F.storage key */;
715
+ let eToggleParent = /* element to put the sync-scroll checkbox in */
716
+ document.querySelector('table.diff.splitdiff')
717
+ ? window.fossil.page.diffControlContainer
718
+ : undefined;
719
+ const keySbsScroll = 'sync-diff-scroll' /* F.storage key for persistent user preference */;
656720
if( eToggleParent ){
657721
/* Add a checkbox to toggle sbs scroll sync. Remember that in
658722
order to be UI-consistent in the /vdiff page we have to ensure
659723
that the checkbox is to the LEFT of of its label. We store the
660724
sync-scroll preference in F.storage (not a cookie) so that it
@@ -661,11 +725,11 @@
661725
persists across page loads and different apps. */
662726
cbSync = D.checkbox(keySbsScroll, F.storage.getBool(keySbsScroll,true));
663727
D.append(eToggleParent, D.append(
664728
D.addClass(D.create('span'), 'input-with-label'),
665729
D.append(D.create('label'),
666
- cbSync, "Sync side-by-side scrolling")
730
+ cbSync, "Scroll Sync")
667731
));
668732
cbSync.addEventListener('change', function(e){
669733
F.storage.set(keySbsScroll, e.target.checked);
670734
});
671735
}
672736
--- src/fossil.diff.js
+++ src/fossil.diff.js
@@ -1,28 +1,103 @@
1 /**
2 diff-related JS APIs for fossil.
3 */
4 "use strict";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5 window.fossil.onPageLoad(function(){
6 /**
7 Adds toggle checkboxes to each file entry in the diff views for
8 /info and similar pages.
9 */
 
 
 
10 const D = window.fossil.dom;
11 const isFdiff = !!document.querySelector('body.fdiff');
 
 
 
 
 
 
12 const addToggle = function(diffElem){
13 const sib = diffElem.previousElementSibling,
14 btn = sib ? D.addClass(D.checkbox(true), 'diff-toggle') : 0;
15 if(!sib) return;
16 if(isFdiff) sib.parentElement.insertBefore(
17 D.append(D.div(),btn),sib.nextElementSibling);
18 else D.append(sib,btn);
19 btn.addEventListener('click', function(){
20 diffElem.classList.toggle('hidden');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21 }, false);
22 };
23 document.querySelectorAll('table.diff').forEach(addToggle);
24 });
25
26 window.fossil.onPageLoad(function(){
27 const F = window.fossil, D = F.dom;
28 const Diff = F.diff = {
@@ -635,26 +710,15 @@
635 /* Look for a parent element to hold the sbs-sync-scroll toggle
636 checkbox. This differs per page. If we don't find one, simply
637 elide that toggle and use whatever preference the user last
638 specified (defaulting to on). */
639 let cbSync /* scroll-sync checkbox */;
640 let eToggleParent /* element to put the sync-scroll checkbox in */;
641 const potentialParents = [ /* possible parents for the checkbox */
642 /* Put the most likely pages at the end, as array.pop() is more
643 efficient than array.shift() (see loop below). */
644 /* /filedit */ 'body.cpage-fileedit #fileedit-tab-diff-buttons',
645 /* /wikiedit */ 'body.cpage-wikiedit #wikiedit-tab-diff-buttons',
646 /* /fdiff */ 'body.fdiff form div.submenu',
647 /* /vdiff */ 'body.vdiff form div.submenu',
648 /* /info, /vinfo */ 'body.vinfo div.sectionmenu.info-changes-menu'
649 ];
650 while( potentialParents.length ){
651 if( (eToggleParent = document.querySelector(potentialParents.pop())) ){
652 break;
653 }
654 }
655 const keySbsScroll = 'sync-diff-scroll' /* F.storage key */;
656 if( eToggleParent ){
657 /* Add a checkbox to toggle sbs scroll sync. Remember that in
658 order to be UI-consistent in the /vdiff page we have to ensure
659 that the checkbox is to the LEFT of of its label. We store the
660 sync-scroll preference in F.storage (not a cookie) so that it
@@ -661,11 +725,11 @@
661 persists across page loads and different apps. */
662 cbSync = D.checkbox(keySbsScroll, F.storage.getBool(keySbsScroll,true));
663 D.append(eToggleParent, D.append(
664 D.addClass(D.create('span'), 'input-with-label'),
665 D.append(D.create('label'),
666 cbSync, "Sync side-by-side scrolling")
667 ));
668 cbSync.addEventListener('change', function(e){
669 F.storage.set(keySbsScroll, e.target.checked);
670 });
671 }
672
--- src/fossil.diff.js
+++ src/fossil.diff.js
@@ -1,28 +1,103 @@
1 /**
2 diff-related JS APIs for fossil.
3 */
4 "use strict";
5 /* Locate the UI element (if any) into which we can inject some diff-related
6 UI controls. */
7 window.fossil.onPageLoad(function(){
8 const potentialParents = window.fossil.page.diffControlContainers = [
9 /* CSS selectors for possible parents for injected diff-related UI
10 controls. */
11 /* Put the most likely pages at the end, as array.pop() is more
12 efficient than array.shift() (see loop below). */
13 /* /filedit */ 'body.cpage-fileedit #fileedit-tab-diff-buttons',
14 /* /wikiedit */ 'body.cpage-wikiedit #wikiedit-tab-diff-buttons',
15 /* /fdiff */ 'body.fdiff form div.submenu',
16 /* /vdiff */ 'body.vdiff form div.submenu',
17 /* /info, /vinfo, /ckout */ 'body.vinfo div.sectionmenu.info-changes-menu'
18 ];
19 window.fossil.page.diffControlContainer = undefined;
20 while( potentialParents.length ){
21 if( (window.fossil.page.diffControlContainer
22 = document.querySelector(potentialParents.pop())) ){
23 break;
24 }
25 }
26 });
27
28 window.fossil.onPageLoad(function(){
29 /**
30 Adds toggle checkboxes to each file entry in the diff views for
31 /info and similar pages.
32 */
33 if( !window.fossil.page.diffControlContainer ){
34 return;
35 }
36 const D = window.fossil.dom;
37 const allToggles = [/*collection of all diff-toggle checkboxes*/];
38 let checkedCount =
39 0 /* When showing more than one diff, keep track of how many
40 "show/hide" checkboxes are are checked so we can update the
41 "show/hide all" label dynamically. */;
42 let btnAll /* UI control to show/hide all diffs */;
43 /* Install a diff-toggle button for the given diff table element. */
44 const addToggle = function(diffElem){
45 const sib = diffElem.previousElementSibling,
46 ckbox = sib ? D.addClass(D.checkbox(true), 'diff-toggle') : 0;
47 if(!sib) return;
48 const lblToggle = D.label();
49 D.append(lblToggle, ckbox, D.text(" show/hide "));
50 allToggles.push(ckbox);
51 ++checkedCount;
52 /* Make all of the available empty space a click zone for the checkbox */
53 lblToggle.style.flexGrow = 1;
54 lblToggle.style.textAlign = 'right';
55 D.append(sib, lblToggle);
56 ckbox.addEventListener('change', function(){
57 diffElem.classList[this.checked ? 'remove' : 'add']('hidden');
58 if(btnAll){
59 checkedCount += (this.checked ? 1 : -1);
60 btnAll.innerText = (checkedCount < allToggles.length)
61 ? "Show diffs" : "Hide diffs";
62 }
63 }, false);
64 /* Extend the toggle click zone to all of the non-hyperlink
65 elements in the left of this area (filenames and hashes). */
66 sib.firstElementChild.addEventListener('click', (event)=>{
67 if( event.target===sib.firstElementChild ){
68 /* Don't respond to clicks bubbling via hyperlink children */
69 ckbox.click();;
70 }
71 }, false);
72 };
73 if( !document.querySelector('body.fdiff') ){
74 /* Don't show the diff toggle button for /fdiff because it only
75 has a single file to show (and also a different DOM layout). */
76 document.querySelectorAll('table.diff').forEach(addToggle);
77 }
78 /**
79 Set up a "toggle all diffs" button which toggles all of the
80 above-installed checkboxes, but only if more than one diff is
81 rendered.
82 */
83 const icm = allToggles.length>1 ? window.fossil.page.diffControlContainer : 0;
84 if(icm) {
85 btnAll = D.addClass(D.a("#", "Hide diffs"), "button");
86 D.append( icm, btnAll );
87 btnAll.addEventListener('click', function(ev){
88 ev.preventDefault();
89 ev.stopPropagation();
90 const show = checkedCount < allToggles.length;
91 for( const ckbox of allToggles ){
92 /* Toggle all entries to match this new state. We use click()
93 instead of ckbox.checked=... so that the on-change event handler
94 fires. */
95 if(ckbox.checked!==show) ckbox.click();
96 }
97 }, false);
98 }
 
99 });
100
101 window.fossil.onPageLoad(function(){
102 const F = window.fossil, D = F.dom;
103 const Diff = F.diff = {
@@ -635,26 +710,15 @@
710 /* Look for a parent element to hold the sbs-sync-scroll toggle
711 checkbox. This differs per page. If we don't find one, simply
712 elide that toggle and use whatever preference the user last
713 specified (defaulting to on). */
714 let cbSync /* scroll-sync checkbox */;
715 let eToggleParent = /* element to put the sync-scroll checkbox in */
716 document.querySelector('table.diff.splitdiff')
717 ? window.fossil.page.diffControlContainer
718 : undefined;
719 const keySbsScroll = 'sync-diff-scroll' /* F.storage key for persistent user preference */;
 
 
 
 
 
 
 
 
 
 
 
720 if( eToggleParent ){
721 /* Add a checkbox to toggle sbs scroll sync. Remember that in
722 order to be UI-consistent in the /vdiff page we have to ensure
723 that the checkbox is to the LEFT of of its label. We store the
724 sync-scroll preference in F.storage (not a cookie) so that it
@@ -661,11 +725,11 @@
725 persists across page loads and different apps. */
726 cbSync = D.checkbox(keySbsScroll, F.storage.getBool(keySbsScroll,true));
727 D.append(eToggleParent, D.append(
728 D.addClass(D.create('span'), 'input-with-label'),
729 D.append(D.create('label'),
730 cbSync, "Scroll Sync")
731 ));
732 cbSync.addEventListener('change', function(e){
733 F.storage.set(keySbsScroll, e.target.checked);
734 });
735 }
736
--- src/fossil.dom.js
+++ src/fossil.dom.js
@@ -87,11 +87,13 @@
8787
const rc = document.createElement('label');
8888
if(forElem){
8989
if(forElem instanceof HTMLElement){
9090
forElem = this.attr(forElem, 'id');
9191
}
92
- dom.attr(rc, 'for', forElem);
92
+ if(forElem){
93
+ dom.attr(rc, 'for', forElem);
94
+ }
9395
}
9496
if(text) this.append(rc, text);
9597
return rc;
9698
};
9799
/**
98100
--- src/fossil.dom.js
+++ src/fossil.dom.js
@@ -87,11 +87,13 @@
87 const rc = document.createElement('label');
88 if(forElem){
89 if(forElem instanceof HTMLElement){
90 forElem = this.attr(forElem, 'id');
91 }
92 dom.attr(rc, 'for', forElem);
 
 
93 }
94 if(text) this.append(rc, text);
95 return rc;
96 };
97 /**
98
--- src/fossil.dom.js
+++ src/fossil.dom.js
@@ -87,11 +87,13 @@
87 const rc = document.createElement('label');
88 if(forElem){
89 if(forElem instanceof HTMLElement){
90 forElem = this.attr(forElem, 'id');
91 }
92 if(forElem){
93 dom.attr(rc, 'for', forElem);
94 }
95 }
96 if(text) this.append(rc, text);
97 return rc;
98 };
99 /**
100
+28 -12
--- src/graph.c
+++ src/graph.c
@@ -495,11 +495,15 @@
495495
**
496496
** TIMELINE_DISJOINT: Omit descenders
497497
** TIMELINE_FILLGAPS: Use step-children
498498
** TIMELINE_XMERGE: Omit off-graph merge lines
499499
*/
500
-void graph_finish(GraphContext *p, const char *zLeftBranch, u32 tmFlags){
500
+void graph_finish(
501
+ GraphContext *p, /* The graph to be laid out */
502
+ Matcher *pLeftBranch, /* Compares true for left-most branch */
503
+ u32 tmFlags /* TIMELINE flags */
504
+){
501505
GraphRow *pRow, *pDesc, *pDup, *pLoop, *pParent;
502506
int i, j;
503507
u64 mask;
504508
int hasDup = 0; /* True if one or more isDup entries */
505509
const char *zTrunk;
@@ -963,12 +967,12 @@
963967
}
964968
}
965969
966970
/*
967971
** Compute the rail mapping that tries to put the branch named
968
- ** zLeftBranch at the left margin. Other branches that merge
969
- ** with zLeftBranch are to the right with merge rails in between.
972
+ ** pLeftBranch at the left margin. Other branches that merge
973
+ ** with pLeftBranch are to the right with merge rails in between.
970974
**
971975
** aMap[X]=Y means that the X-th rail is drawn as the Y-th rail.
972976
**
973977
** Do not move rails around if there are timewarps, because that can
974978
** seriously mess up the display of timewarps. Timewarps should be
@@ -975,10 +979,11 @@
975979
** rare so this should not be a serious limitation to the algorithm.
976980
*/
977981
aMap = p->aiRailMap;
978982
for(i=0; i<=p->mxRail; i++) aMap[i] = i; /* Set up a default mapping */
979983
if( nTimewarp==0 ){
984
+ int kk;
980985
/* Priority bits:
981986
**
982987
** 0x04 The preferred branch
983988
**
984989
** 0x02 A merge rail - a rail that contains merge lines into
@@ -986,17 +991,20 @@
986991
** is defined. This improves the display of r=BRANCH
987992
** options to /timeline.
988993
**
989994
** 0x01 A rail that merges with the preferred branch
990995
*/
991
- u8 aPriority[GR_MAX_RAIL];
992
- memset(aPriority, 0, p->mxRail+1);
993
- if( zLeftBranch ){
994
- char *zLeft = persistBranchName(p, zLeftBranch);
996
+ u16 aPriority[GR_MAX_RAIL];
997
+ int mxMatch = 0;
998
+ memset(aPriority, 0, (p->mxRail+1)*sizeof(aPriority[0]));
999
+ if( pLeftBranch ){
9951000
for(pRow=p->pFirst; pRow; pRow=pRow->pNext){
996
- if( pRow->zBranch==zLeft ){
997
- aPriority[pRow->iRail] |= 4;
1001
+ int iMatch = match_text(pLeftBranch, pRow->zBranch);
1002
+ if( iMatch>0 ){
1003
+ if( iMatch>10 ) iMatch = 10;
1004
+ aPriority[pRow->iRail] |= 1<<(iMatch+1);
1005
+ if( mxMatch<iMatch ) mxMatch = iMatch;
9981006
for(i=0; i<=p->mxRail; i++){
9991007
if( pRow->mergeIn[i] ) aPriority[i] |= 1;
10001008
}
10011009
if( pRow->mergeOut>=0 ) aPriority[pRow->mergeOut] |= 1;
10021010
}
@@ -1007,10 +1015,11 @@
10071015
}
10081016
}
10091017
}else{
10101018
j = 1;
10111019
aPriority[0] = 4;
1020
+ mxMatch = 1;
10121021
for(pRow=p->pFirst; pRow; pRow=pRow->pNext){
10131022
if( pRow->iRail==0 ){
10141023
for(i=0; i<=p->mxRail; i++){
10151024
if( pRow->mergeIn[i] ) aPriority[i] |= 1;
10161025
}
@@ -1020,17 +1029,24 @@
10201029
}
10211030
10221031
#if 0
10231032
fprintf(stderr,"mergeRail: 0x%llx\n", p->mergeRail);
10241033
fprintf(stderr,"Priority:");
1025
- for(i=0; i<=p->mxRail; i++) fprintf(stderr," %d", aPriority[i]);
1034
+ for(i=0; i<=p->mxRail; i++){
1035
+ fprintf(stderr," %x.%x",
1036
+ aPriority[i]/4, aPriority[i]&3);
1037
+ }
10261038
fprintf(stderr,"\n");
10271039
#endif
10281040
10291041
j = 0;
1030
- for(i=0; i<=p->mxRail; i++){
1031
- if( aPriority[i]>=4 ) aMap[i] = j++;
1042
+ for(kk=4; kk<=1<<(mxMatch+1); kk*=2){
1043
+ for(i=0; i<=p->mxRail; i++){
1044
+ if( aPriority[i]>=kk && aPriority[i]<kk*2 ){
1045
+ aMap[i] = j++;
1046
+ }
1047
+ }
10321048
}
10331049
for(i=p->mxRail; i>=0; i--){
10341050
if( aPriority[i]==3 ) aMap[i] = j++;
10351051
}
10361052
for(i=0; i<=p->mxRail; i++){
10371053
--- src/graph.c
+++ src/graph.c
@@ -495,11 +495,15 @@
495 **
496 ** TIMELINE_DISJOINT: Omit descenders
497 ** TIMELINE_FILLGAPS: Use step-children
498 ** TIMELINE_XMERGE: Omit off-graph merge lines
499 */
500 void graph_finish(GraphContext *p, const char *zLeftBranch, u32 tmFlags){
 
 
 
 
501 GraphRow *pRow, *pDesc, *pDup, *pLoop, *pParent;
502 int i, j;
503 u64 mask;
504 int hasDup = 0; /* True if one or more isDup entries */
505 const char *zTrunk;
@@ -963,12 +967,12 @@
963 }
964 }
965
966 /*
967 ** Compute the rail mapping that tries to put the branch named
968 ** zLeftBranch at the left margin. Other branches that merge
969 ** with zLeftBranch are to the right with merge rails in between.
970 **
971 ** aMap[X]=Y means that the X-th rail is drawn as the Y-th rail.
972 **
973 ** Do not move rails around if there are timewarps, because that can
974 ** seriously mess up the display of timewarps. Timewarps should be
@@ -975,10 +979,11 @@
975 ** rare so this should not be a serious limitation to the algorithm.
976 */
977 aMap = p->aiRailMap;
978 for(i=0; i<=p->mxRail; i++) aMap[i] = i; /* Set up a default mapping */
979 if( nTimewarp==0 ){
 
980 /* Priority bits:
981 **
982 ** 0x04 The preferred branch
983 **
984 ** 0x02 A merge rail - a rail that contains merge lines into
@@ -986,17 +991,20 @@
986 ** is defined. This improves the display of r=BRANCH
987 ** options to /timeline.
988 **
989 ** 0x01 A rail that merges with the preferred branch
990 */
991 u8 aPriority[GR_MAX_RAIL];
992 memset(aPriority, 0, p->mxRail+1);
993 if( zLeftBranch ){
994 char *zLeft = persistBranchName(p, zLeftBranch);
995 for(pRow=p->pFirst; pRow; pRow=pRow->pNext){
996 if( pRow->zBranch==zLeft ){
997 aPriority[pRow->iRail] |= 4;
 
 
 
998 for(i=0; i<=p->mxRail; i++){
999 if( pRow->mergeIn[i] ) aPriority[i] |= 1;
1000 }
1001 if( pRow->mergeOut>=0 ) aPriority[pRow->mergeOut] |= 1;
1002 }
@@ -1007,10 +1015,11 @@
1007 }
1008 }
1009 }else{
1010 j = 1;
1011 aPriority[0] = 4;
 
1012 for(pRow=p->pFirst; pRow; pRow=pRow->pNext){
1013 if( pRow->iRail==0 ){
1014 for(i=0; i<=p->mxRail; i++){
1015 if( pRow->mergeIn[i] ) aPriority[i] |= 1;
1016 }
@@ -1020,17 +1029,24 @@
1020 }
1021
1022 #if 0
1023 fprintf(stderr,"mergeRail: 0x%llx\n", p->mergeRail);
1024 fprintf(stderr,"Priority:");
1025 for(i=0; i<=p->mxRail; i++) fprintf(stderr," %d", aPriority[i]);
 
 
 
1026 fprintf(stderr,"\n");
1027 #endif
1028
1029 j = 0;
1030 for(i=0; i<=p->mxRail; i++){
1031 if( aPriority[i]>=4 ) aMap[i] = j++;
 
 
 
 
1032 }
1033 for(i=p->mxRail; i>=0; i--){
1034 if( aPriority[i]==3 ) aMap[i] = j++;
1035 }
1036 for(i=0; i<=p->mxRail; i++){
1037
--- src/graph.c
+++ src/graph.c
@@ -495,11 +495,15 @@
495 **
496 ** TIMELINE_DISJOINT: Omit descenders
497 ** TIMELINE_FILLGAPS: Use step-children
498 ** TIMELINE_XMERGE: Omit off-graph merge lines
499 */
500 void graph_finish(
501 GraphContext *p, /* The graph to be laid out */
502 Matcher *pLeftBranch, /* Compares true for left-most branch */
503 u32 tmFlags /* TIMELINE flags */
504 ){
505 GraphRow *pRow, *pDesc, *pDup, *pLoop, *pParent;
506 int i, j;
507 u64 mask;
508 int hasDup = 0; /* True if one or more isDup entries */
509 const char *zTrunk;
@@ -963,12 +967,12 @@
967 }
968 }
969
970 /*
971 ** Compute the rail mapping that tries to put the branch named
972 ** pLeftBranch at the left margin. Other branches that merge
973 ** with pLeftBranch are to the right with merge rails in between.
974 **
975 ** aMap[X]=Y means that the X-th rail is drawn as the Y-th rail.
976 **
977 ** Do not move rails around if there are timewarps, because that can
978 ** seriously mess up the display of timewarps. Timewarps should be
@@ -975,10 +979,11 @@
979 ** rare so this should not be a serious limitation to the algorithm.
980 */
981 aMap = p->aiRailMap;
982 for(i=0; i<=p->mxRail; i++) aMap[i] = i; /* Set up a default mapping */
983 if( nTimewarp==0 ){
984 int kk;
985 /* Priority bits:
986 **
987 ** 0x04 The preferred branch
988 **
989 ** 0x02 A merge rail - a rail that contains merge lines into
@@ -986,17 +991,20 @@
991 ** is defined. This improves the display of r=BRANCH
992 ** options to /timeline.
993 **
994 ** 0x01 A rail that merges with the preferred branch
995 */
996 u16 aPriority[GR_MAX_RAIL];
997 int mxMatch = 0;
998 memset(aPriority, 0, (p->mxRail+1)*sizeof(aPriority[0]));
999 if( pLeftBranch ){
1000 for(pRow=p->pFirst; pRow; pRow=pRow->pNext){
1001 int iMatch = match_text(pLeftBranch, pRow->zBranch);
1002 if( iMatch>0 ){
1003 if( iMatch>10 ) iMatch = 10;
1004 aPriority[pRow->iRail] |= 1<<(iMatch+1);
1005 if( mxMatch<iMatch ) mxMatch = iMatch;
1006 for(i=0; i<=p->mxRail; i++){
1007 if( pRow->mergeIn[i] ) aPriority[i] |= 1;
1008 }
1009 if( pRow->mergeOut>=0 ) aPriority[pRow->mergeOut] |= 1;
1010 }
@@ -1007,10 +1015,11 @@
1015 }
1016 }
1017 }else{
1018 j = 1;
1019 aPriority[0] = 4;
1020 mxMatch = 1;
1021 for(pRow=p->pFirst; pRow; pRow=pRow->pNext){
1022 if( pRow->iRail==0 ){
1023 for(i=0; i<=p->mxRail; i++){
1024 if( pRow->mergeIn[i] ) aPriority[i] |= 1;
1025 }
@@ -1020,17 +1029,24 @@
1029 }
1030
1031 #if 0
1032 fprintf(stderr,"mergeRail: 0x%llx\n", p->mergeRail);
1033 fprintf(stderr,"Priority:");
1034 for(i=0; i<=p->mxRail; i++){
1035 fprintf(stderr," %x.%x",
1036 aPriority[i]/4, aPriority[i]&3);
1037 }
1038 fprintf(stderr,"\n");
1039 #endif
1040
1041 j = 0;
1042 for(kk=4; kk<=1<<(mxMatch+1); kk*=2){
1043 for(i=0; i<=p->mxRail; i++){
1044 if( aPriority[i]>=kk && aPriority[i]<kk*2 ){
1045 aMap[i] = j++;
1046 }
1047 }
1048 }
1049 for(i=p->mxRail; i>=0; i--){
1050 if( aPriority[i]==3 ) aMap[i] = j++;
1051 }
1052 for(i=0; i<=p->mxRail; i++){
1053
+1 -1
--- src/hook.c
+++ src/hook.c
@@ -233,11 +233,11 @@
233233
** Run the hook script given by ID for testing purposes.
234234
** Options:
235235
**
236236
** --dry-run Print the script on stdout rather than run it
237237
** --base-rcvid N Pretend that the hook-last-rcvid value is N
238
-** --new-rcvid M Pretend that the last rcvid valud is M
238
+** --new-rcvid M Pretend that the last rcvid value is M
239239
** --aux-file NAME NAME is substituted for %A in the script
240240
**
241241
** The --base-rcvid and --new-rcvid options are silently ignored if
242242
** the hook type is not "after-receive". The default values for
243243
** --base-rcvid and --new-rcvid cause the last receive to be processed.
244244
--- src/hook.c
+++ src/hook.c
@@ -233,11 +233,11 @@
233 ** Run the hook script given by ID for testing purposes.
234 ** Options:
235 **
236 ** --dry-run Print the script on stdout rather than run it
237 ** --base-rcvid N Pretend that the hook-last-rcvid value is N
238 ** --new-rcvid M Pretend that the last rcvid valud is M
239 ** --aux-file NAME NAME is substituted for %A in the script
240 **
241 ** The --base-rcvid and --new-rcvid options are silently ignored if
242 ** the hook type is not "after-receive". The default values for
243 ** --base-rcvid and --new-rcvid cause the last receive to be processed.
244
--- src/hook.c
+++ src/hook.c
@@ -233,11 +233,11 @@
233 ** Run the hook script given by ID for testing purposes.
234 ** Options:
235 **
236 ** --dry-run Print the script on stdout rather than run it
237 ** --base-rcvid N Pretend that the hook-last-rcvid value is N
238 ** --new-rcvid M Pretend that the last rcvid value is M
239 ** --aux-file NAME NAME is substituted for %A in the script
240 **
241 ** The --base-rcvid and --new-rcvid options are silently ignored if
242 ** the hook type is not "after-receive". The default values for
243 ** --base-rcvid and --new-rcvid cause the last receive to be processed.
244
+466 -36
--- src/info.c
+++ src/info.c
@@ -320,10 +320,11 @@
320320
|TIMELINE_NOSCROLL
321321
|TIMELINE_XMERGE
322322
|TIMELINE_CHPICK,
323323
0, 0, 0, rid, rid2, 0);
324324
db_finalize(&q);
325
+ blob_reset(&sql);
325326
}
326327
327328
328329
/*
329330
** Append the difference between artifacts to the output
@@ -372,11 +373,13 @@
372373
const char *zNew, /* blob.uuid after change. NULL for deletes */
373374
const char *zOldName, /* Prior name. NULL if no name change. */
374375
DiffConfig *pCfg, /* Flags for text_diff() or NULL to omit all */
375376
int mperm /* executable or symlink permission for zNew */
376377
){
377
- @ <p>
378
+ @ <div class='file-change-line'><span>
379
+ /* Maintenance reminder: the extra level of SPAN is for
380
+ ** arranging new elements via JS. */
378381
if( !g.perm.Hyperlink ){
379382
if( zNew==0 ){
380383
@ Deleted %h(zName).
381384
}else if( zOld==0 ){
382385
@ Added %h(zName).
@@ -391,10 +394,11 @@
391394
@ %h(zName) became a regular file.
392395
}
393396
}else{
394397
@ Changes to %h(zName).
395398
}
399
+ @ </span></div>
396400
if( pCfg ){
397401
append_diff(zOld, zNew, pCfg);
398402
}
399403
}else{
400404
if( zOld && zNew ){
@@ -438,18 +442,20 @@
438442
@ Added %z(href("%R/finfo?name=%T&m=%!S&ci=%!S",zName,zNew,zCkin))\
439443
@ %h(zName)</a> version %z(href("%R/artifact/%!S",zNew))[%S(zNew)]</a>.
440444
}
441445
if( zOld && zNew && fossil_strcmp(zOld,zNew)!=0 ){
442446
if( pCfg ){
447
+ @ </span></div>
443448
append_diff(zOld, zNew, pCfg);
444
- }else{
445
- @ &nbsp;&nbsp;
449
+ }else{
446450
@ %z(href("%R/fdiff?v1=%!S&v2=%!S",zOld,zNew))[diff]</a>
451
+ @ </span></div>
447452
}
453
+ }else{
454
+ @ </span></div>
448455
}
449456
}
450
- @ </p>
451457
}
452458
453459
/*
454460
** Generate javascript to enhance HTML diffs.
455461
*/
@@ -602,10 +608,277 @@
602608
www_print_timeline(&q, TIMELINE_DISJOINT|TIMELINE_GRAPH|TIMELINE_NOSCROLL,
603609
0, 0, 0, rid, 0, 0);
604610
db_finalize(&q);
605611
style_finish_page();
606612
}
613
+
614
+/*
615
+** Render a web-page diff of the changes in the working check-out
616
+*/
617
+static void ckout_normal_diff(int vid){
618
+ int diffType; /* 0: no diff, 1: unified, 2: side-by-side */
619
+ DiffConfig DCfg,*pCfg; /* Diff details */
620
+ const char *zW; /* The "w" query parameter */
621
+ int nChng; /* Number of changes */
622
+ Stmt q;
623
+
624
+ diffType = preferred_diff_type();
625
+ pCfg = construct_diff_flags(diffType, &DCfg);
626
+ nChng = db_int(0, "SELECT count(*) FROM vfile"
627
+ " WHERE vid=%d AND (deleted OR chnged OR rid==0)", vid);
628
+ if( nChng==0 ){
629
+ @ <p>No uncommitted changes</p>
630
+ return;
631
+ }
632
+ db_prepare(&q,
633
+ /* 0 1 2 3 4 5 6 */
634
+ "SELECT pathname, deleted, chnged , rid==0, rid, islink, uuid"
635
+ " FROM vfile LEFT JOIN blob USING(rid)"
636
+ " WHERE vid=%d"
637
+ " AND (deleted OR chnged OR rid==0)"
638
+ " ORDER BY pathname /*scan*/",
639
+ vid
640
+ );
641
+ if( DCfg.diffFlags & DIFF_SIDEBYSIDE ){
642
+ DCfg.diffFlags |= DIFF_HTML | DIFF_NOTTOOBIG;
643
+ }else{
644
+ DCfg.diffFlags |= DIFF_LINENO | DIFF_HTML | DIFF_NOTTOOBIG;
645
+ }
646
+ @ <div class="sectionmenu info-changes-menu">
647
+ zW = (DCfg.diffFlags&DIFF_IGNORE_ALLWS)?"&w":"";
648
+ if( diffType!=1 ){
649
+ @ %z(chref("button","%R?diff=1%s",zW))Unified&nbsp;Diff</a>
650
+ }
651
+ if( diffType!=2 ){
652
+ @ %z(chref("button","%R?diff=2%s",zW))Side-by-Side&nbsp;Diff</a>
653
+ }
654
+ if( diffType!=0 ){
655
+ if( *zW ){
656
+ @ %z(chref("button","%R?diff=%d",diffType))\
657
+ @ Show&nbsp;Whitespace&nbsp;Changes</a>
658
+ }else{
659
+ @ %z(chref("button","%R?diff=%d&w",diffType))Ignore&nbsp;Whitespace</a>
660
+ }
661
+ }
662
+ @ </div>
663
+ while( db_step(&q)==SQLITE_ROW ){
664
+ const char *zTreename = db_column_text(&q,0);
665
+ int isDeleted = db_column_int(&q, 1);
666
+ int isChnged = db_column_int(&q,2);
667
+ int isNew = db_column_int(&q,3);
668
+ int srcid = db_column_int(&q, 4);
669
+ int isLink = db_column_int(&q, 5);
670
+ const char *zUuid = db_column_text(&q, 6);
671
+ int showDiff = 1;
672
+
673
+ DCfg.diffFlags &= (~DIFF_FILE_MASK);
674
+ @ <div class='file-change-line'><span>
675
+ if( isDeleted ){
676
+ @ DELETED %h(zTreename)
677
+ DCfg.diffFlags |= DIFF_FILE_DELETED;
678
+ showDiff = 0;
679
+ }else if( file_access(zTreename, F_OK) ){
680
+ @ MISSING %h(zTreename)
681
+ showDiff = 0;
682
+ }else if( isNew ){
683
+ @ ADDED %h(zTreename)
684
+ DCfg.diffFlags |= DIFF_FILE_ADDED;
685
+ srcid = 0;
686
+ showDiff = 0;
687
+ }else if( isChnged==3 ){
688
+ @ ADDED_BY_MERGE %h(zTreename)
689
+ DCfg.diffFlags |= DIFF_FILE_ADDED;
690
+ srcid = 0;
691
+ showDiff = 0;
692
+ }else if( isChnged==5 ){
693
+ @ ADDED_BY_INTEGRATE %h(zTreename)
694
+ DCfg.diffFlags |= DIFF_FILE_ADDED;
695
+ srcid = 0;
696
+ showDiff = 0;
697
+ }else{
698
+ @ CHANGED %h(zTreename)
699
+ }
700
+ @ </span></div>
701
+ if( showDiff && pCfg ){
702
+ Blob old, new;
703
+ if( !isLink != !file_islink(zTreename) ){
704
+ @ %s(DIFF_CANNOT_COMPUTE_SYMLINK)
705
+ continue;
706
+ }
707
+ if( srcid>0 ){
708
+ content_get(srcid, &old);
709
+ pCfg->zLeftHash = zUuid;
710
+ }else{
711
+ blob_zero(&old);
712
+ pCfg->zLeftHash = 0;
713
+ }
714
+ blob_read_from_file(&new, zTreename, ExtFILE);
715
+ text_diff(&old, &new, cgi_output_blob(), pCfg);
716
+ blob_reset(&old);
717
+ blob_reset(&new);
718
+ }
719
+ }
720
+ db_finalize(&q);
721
+ append_diff_javascript(diffType);
722
+}
723
+
724
+/*
725
+** Render a web-page diff of the changes in the working check-out to
726
+** an external reference.
727
+*/
728
+static void ckout_external_base_diff(int vid, const char *zExBase){
729
+ int diffType; /* 0: no diff, 1: unified, 2: side-by-side */
730
+ DiffConfig DCfg,*pCfg; /* Diff details */
731
+ const char *zW; /* The "w" query parameter */
732
+ Stmt q;
733
+
734
+ diffType = preferred_diff_type();
735
+ pCfg = construct_diff_flags(diffType, &DCfg);
736
+ db_prepare(&q,
737
+ "SELECT pathname FROM vfile WHERE vid=%d ORDER BY pathname", vid
738
+ );
739
+ if( DCfg.diffFlags & DIFF_SIDEBYSIDE ){
740
+ DCfg.diffFlags |= DIFF_HTML | DIFF_NOTTOOBIG;
741
+ }else{
742
+ DCfg.diffFlags |= DIFF_LINENO | DIFF_HTML | DIFF_NOTTOOBIG;
743
+ }
744
+ @ <div class="sectionmenu info-changes-menu">
745
+ zW = (DCfg.diffFlags&DIFF_IGNORE_ALLWS)?"&w":"";
746
+ if( diffType!=1 ){
747
+ @ %z(chref("button","%R?diff=1&exbase=%h%s",zExBase,zW))\
748
+ @ Unified&nbsp;Diff</a>
749
+ }
750
+ if( diffType!=2 ){
751
+ @ %z(chref("button","%R?diff=2&exbase=%h%s",zExBase,zW))\
752
+ @ Side-by-Side&nbsp;Diff</a>
753
+ }
754
+ if( diffType!=0 ){
755
+ if( *zW ){
756
+ @ %z(chref("button","%R?diff=%d&exbase=%h",diffType,zExBase))\
757
+ @ Show&nbsp;Whitespace&nbsp;Changes</a>
758
+ }else{
759
+ @ %z(chref("button","%R?diff=%d&exbase=%h&w",diffType,zExBase))\
760
+ @ Ignore&nbsp;Whitespace</a>
761
+ }
762
+ }
763
+ @ </div>
764
+ while( db_step(&q)==SQLITE_ROW ){
765
+ const char *zFile; /* Name of file in the repository */
766
+ char *zLhs; /* Full name of left-hand side file */
767
+ char *zRhs; /* Full name of right-hand side file */
768
+ Blob rhs; /* Full text of RHS */
769
+ Blob lhs; /* Full text of LHS */
770
+
771
+ zFile = db_column_text(&q,0);
772
+ zLhs = mprintf("%s/%s", zExBase, zFile);
773
+ zRhs = mprintf("%s%s", g.zLocalRoot, zFile);
774
+ if( file_size(zLhs, ExtFILE)<0 ){
775
+ @ <div class='file-change-line'><span>
776
+ @ Missing from external baseline: %h(zFile)
777
+ @ </span></div>
778
+ }else{
779
+ blob_read_from_file(&lhs, zLhs, ExtFILE);
780
+ blob_read_from_file(&rhs, zRhs, ExtFILE);
781
+ if( blob_size(&lhs)!=blob_size(&rhs)
782
+ || memcmp(blob_buffer(&lhs), blob_buffer(&rhs), blob_size(&lhs))!=0
783
+ ){
784
+ @ <div class='file-change-line'><span>
785
+ @ Changes to %h(zFile)
786
+ @ </span></div>
787
+ if( pCfg ){
788
+ char *zFullFN;
789
+ char *zHexFN;
790
+ zFullFN = file_canonical_name_dup(zLhs);
791
+ zHexFN = mprintf("x%H", zFullFN);
792
+ fossil_free(zFullFN);
793
+ pCfg->zLeftHash = zHexFN;
794
+ text_diff(&lhs, &rhs, cgi_output_blob(), pCfg);
795
+ pCfg->zLeftHash = 0;
796
+ fossil_free(zHexFN);
797
+ }
798
+ }
799
+ blob_reset(&lhs);
800
+ blob_reset(&rhs);
801
+ }
802
+ fossil_free(zLhs);
803
+ fossil_free(zRhs);
804
+ }
805
+ db_finalize(&q);
806
+ append_diff_javascript(diffType);
807
+}
808
+
809
+/*
810
+** WEBPAGE: ckout
811
+**
812
+** Show information about the current checkout. This page only functions
813
+** if the web server is run on a loopback interface (in other words, was
814
+** started using "fossil ui" or similar) from within an open check-out.
815
+**
816
+** If the "exbase=PATH" query parameter is provided, then the diff shown
817
+** uses the files in PATH as the baseline. This is the same as using
818
+** the "--from PATH" argument to the "fossil diff" command-line. In fact,
819
+** when using "fossil ui --from PATH", the --from argument becomes the value
820
+** of the exbase query parameter for the start page. Note that if PATH
821
+** is a pure hexadecimal string, it is decoded first before being used as
822
+** the pathname. Real pathnames should contain at least one directory
823
+** separator character.
824
+**
825
+** Other query parameters related to diffs are also accepted.
826
+*/
827
+void ckout_page(void){
828
+ int vid;
829
+ const char *zHome; /* Home directory */
830
+ int nHome;
831
+ const char *zExBase;
832
+ char *zHostname;
833
+ char *zCwd;
834
+
835
+ if( !cgi_is_loopback(g.zIpAddr) || !db_open_local(0) ){
836
+ cgi_redirectf("%R/home");
837
+ return;
838
+ }
839
+ file_chdir(g.zLocalRoot, 0);
840
+ vid = db_lget_int("checkout", 0);
841
+ db_unprotect(PROTECT_ALL);
842
+ vfile_check_signature(vid, CKSIG_ENOTFILE);
843
+ db_protect_pop();
844
+ style_set_current_feature("vinfo");
845
+ zHostname = fossil_hostname();
846
+ zCwd = file_getcwd(0,0);
847
+ zHome = fossil_getenv("HOME");
848
+ if( zHome ){
849
+ nHome = (int)strlen(zHome);
850
+ if( strncmp(zCwd, zHome, nHome)==0 && zCwd[nHome]=='/' ){
851
+ zCwd = mprintf("~%s", zCwd+nHome);
852
+ }
853
+ }else{
854
+ nHome = 0;
855
+ }
856
+ if( zHostname ){
857
+ style_header("Checkout Status: %h on %h", zCwd, zHostname);
858
+ }else{
859
+ style_header("Checkout Status: %h", zCwd);
860
+ }
861
+ render_checkin_context(vid, 0, 0, 0);
862
+ @ <hr>
863
+ zExBase = P("exbase");
864
+ if( zExBase && zExBase[0] ){
865
+ char *zPath = decode16_dup(zExBase);
866
+ char *zCBase = file_canonical_name_dup(zPath?zPath:zExBase);
867
+ if( nHome && strncmp(zCBase, zHome, nHome)==0 && zCBase[nHome]=='/' ){
868
+ @ <p>Using external baseline: ~%h(zCBase+nHome)</p>
869
+ }else{
870
+ @ <p>Using external baseline: %h(zCBase)</p>
871
+ }
872
+ ckout_external_base_diff(vid, zCBase);
873
+ fossil_free(zCBase);
874
+ fossil_free(zPath);
875
+ }else{
876
+ ckout_normal_diff(vid);
877
+ }
878
+ style_finish_page();
879
+}
607880
608881
/*
609882
** WEBPAGE: vinfo
610883
** WEBPAGE: ci
611884
** URL: /ci/ARTIFACTID
@@ -628,11 +901,10 @@
628901
const char *zParent; /* Hash of the parent check-in (if any) */
629902
const char *zRe; /* regex parameter */
630903
ReCompiled *pRe = 0; /* regex */
631904
const char *zW; /* URL param for ignoring whitespace */
632905
const char *zPage = "vinfo"; /* Page that shows diffs */
633
- const char *zPageHide = "ci"; /* Page that hides diffs */
634906
const char *zBrName; /* Branch name */
635907
DiffConfig DCfg,*pCfg; /* Type of diff */
636908
637909
login_check_credentials();
638910
if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
@@ -898,21 +1170,17 @@
8981170
@ <div class="sectionmenu info-changes-menu">
8991171
/* ^^^ .info-changes-menu is used by diff scroll sync */
9001172
pCfg = construct_diff_flags(diffType, &DCfg);
9011173
DCfg.pRe = pRe;
9021174
zW = (DCfg.diffFlags&DIFF_IGNORE_ALLWS)?"&w":"";
903
- if( diffType!=0 ){
904
- @ %z(chref("button","%R/%s/%T?diff=0",zPageHide,zName))\
905
- @ Hide&nbsp;Diffs</a>
906
- }
9071175
if( diffType!=1 ){
9081176
@ %z(chref("button","%R/%s/%T?diff=1%s",zPage,zName,zW))\
909
- @ Unified&nbsp;Diffs</a>
1177
+ @ Unified&nbsp;Diff</a>
9101178
}
9111179
if( diffType!=2 ){
9121180
@ %z(chref("button","%R/%s/%T?diff=2%s",zPage,zName,zW))\
913
- @ Side-by-Side&nbsp;Diffs</a>
1181
+ @ Side-by-Side&nbsp;Diff</a>
9141182
}
9151183
if( diffType!=0 ){
9161184
if( *zW ){
9171185
@ %z(chref("button","%R/%s/%T",zPage,zName))
9181186
@ Show&nbsp;Whitespace&nbsp;Changes</a>
@@ -1268,13 +1536,10 @@
12681536
cgi_check_for_malice();
12691537
style_set_current_feature("vdiff");
12701538
if( zBranch==0 ){
12711539
style_submenu_element("Path", "%R/timeline?me=%T&you=%T", zFrom, zTo);
12721540
}
1273
- if( diffType!=0 ){
1274
- style_submenu_element("Hide Diff", "%R/vdiff?diff=0&%b%b", &qp, &qpGlob);
1275
- }
12761541
if( diffType!=2 ){
12771542
style_submenu_element("Side-by-Side Diff", "%R/vdiff?diff=2&%b%b", &qp,
12781543
&qpGlob);
12791544
}
12801545
if( diffType!=1 ) {
@@ -1668,11 +1933,11 @@
16681933
tag_private_status(rid);
16691934
}
16701935
db_finalize(&q);
16711936
if( db_exists("SELECT 1 FROM tagxref WHERE rid=%d AND tagid=%d",
16721937
rid, TAG_CLUSTER) ){
1673
- @ Cluster
1938
+ @ Cluster %z(href("%R/info/%S",zUuid))%S(zUuid)</a>.
16741939
cnt++;
16751940
}
16761941
if( cnt==0 ){
16771942
@ Unrecognized artifact
16781943
if( pDownloadName && blob_size(pDownloadName)==0 ){
@@ -1933,10 +2198,16 @@
19332198
** WEBPAGE: jchunk hidden
19342199
** URL: /jchunk/HASH?from=N&to=M
19352200
**
19362201
** Return lines of text from a file as a JSON array - one entry in the
19372202
** array for each line of text.
2203
+**
2204
+** The HASH is normally a sha1 or sha3 hash that identifies an artifact
2205
+** in the BLOB table of the database. However, if HASH starts with an "x"
2206
+** and is followed by valid hexadecimal, and if we are running in a
2207
+** "fossil ui" situation (locally and with privilege), then decode the hex
2208
+** into a filename and read the file content from that name.
19382209
**
19392210
** **Warning:** This is an internal-use-only interface that is subject to
19402211
** change at any moment. External application should not use this interface
19412212
** since the application will break when this interface changes, and this
19422213
** interface will undoubtedly change.
@@ -1948,10 +2219,11 @@
19482219
** ajax_route_error().
19492220
*/
19502221
void jchunk_page(void){
19512222
int rid = 0;
19522223
const char *zName = PD("name", "");
2224
+ int nName = (int)(strlen(zName)&0x7fffffff);
19532225
int iFrom = atoi(PD("from","0"));
19542226
int iTo = atoi(PD("to","0"));
19552227
int ln;
19562228
int go = 1;
19572229
const char *zSep;
@@ -1968,36 +2240,57 @@
19682240
cgi_check_for_malice();
19692241
if( !g.perm.Read ){
19702242
ajax_route_error(403, "Access requires Read permissions.");
19712243
return;
19722244
}
1973
-#if 1
1974
- /* Re-enable this block once this code is integrated somewhere into
1975
- the UI. */
1976
- rid = db_int(0, "SELECT rid FROM blob WHERE uuid=%Q", zName);
1977
- if( rid==0 ){
1978
- ajax_route_error(404, "Unknown artifact: %h", zName);
1979
- return;
1980
- }
1981
-#else
1982
- /* This impl is only to simplify "manual" testing via the JS
1983
- console. */
1984
- rid = symbolic_name_to_rid(zName, "*");
1985
- if( rid==0 ){
1986
- ajax_route_error(404, "Unknown artifact: %h", zName);
1987
- return;
1988
- }else if( rid<0 ){
1989
- ajax_route_error(418, "Ambiguous artifact name: %h", zName);
1990
- return;
1991
- }
1992
-#endif
19932245
if( iFrom<1 || iTo<iFrom ){
19942246
ajax_route_error(500, "Invalid line range from=%d, to=%d.",
19952247
iFrom, iTo);
19962248
return;
19972249
}
1998
- content_get(rid, &content);
2250
+ if( zName[0]=='x'
2251
+ && ((nName-1)&1)==0
2252
+ && validate16(&zName[1],nName-1)
2253
+ && g.perm.Admin
2254
+ && cgi_is_loopback(g.zIpAddr)
2255
+ && db_open_local(0)
2256
+ ){
2257
+ /* Treat the HASH as a hex-encoded filename */
2258
+ int n = (nName-1)/2;
2259
+ char *zFN = fossil_malloc(n+1);
2260
+ decode16((const u8*)&zName[1], (u8*)zFN, nName-1);
2261
+ zFN[n] = 0;
2262
+ if( file_size(zFN, ExtFILE)<0 ){
2263
+ blob_zero(&content);
2264
+ }else{
2265
+ blob_read_from_file(&content, zFN, ExtFILE);
2266
+ }
2267
+ fossil_free(zFN);
2268
+ }else{
2269
+ /* Treat the HASH as an artifact hash matching BLOB.UUID */
2270
+#if 1
2271
+ /* Re-enable this block once this code is integrated somewhere into
2272
+ the UI. */
2273
+ rid = db_int(0, "SELECT rid FROM blob WHERE uuid=%Q", zName);
2274
+ if( rid==0 ){
2275
+ ajax_route_error(404, "Unknown artifact: %h", zName);
2276
+ return;
2277
+ }
2278
+#else
2279
+ /* This impl is only to simplify "manual" testing via the JS
2280
+ console. */
2281
+ rid = symbolic_name_to_rid(zName, "*");
2282
+ if( rid==0 ){
2283
+ ajax_route_error(404, "Unknown artifact: %h", zName);
2284
+ return;
2285
+ }else if( rid<0 ){
2286
+ ajax_route_error(418, "Ambiguous artifact name: %h", zName);
2287
+ return;
2288
+ }
2289
+#endif
2290
+ content_get(rid, &content);
2291
+ }
19992292
g.isConst = 1;
20002293
cgi_set_content_type("application/json");
20012294
ln = 0;
20022295
while( go && ln<iFrom ){
20032296
go = blob_line(&content, &line);
@@ -2875,10 +3168,143 @@
28753168
ticket_output_change_artifact(pTktChng, 0, 1, 0);
28763169
manifest_destroy(pTktChng);
28773170
style_finish_page();
28783171
}
28793172
3173
+/*
3174
+** rid is a cluster. Paint a page that contains detailed information
3175
+** about that cluster.
3176
+*/
3177
+static void cluster_info(int rid, const char *zName){
3178
+ Manifest *pCluster;
3179
+ int i;
3180
+ Blob where = BLOB_INITIALIZER;
3181
+ Blob unks = BLOB_INITIALIZER;
3182
+ Stmt q;
3183
+ char *zSha1Bg;
3184
+ char *zSha3Bg;
3185
+ int badRid = 0;
3186
+ int rcvid;
3187
+ int hashClr = PB("hclr");
3188
+ const char *zDate;
3189
+
3190
+ pCluster = manifest_get(rid, CFTYPE_CLUSTER, 0);
3191
+ if( pCluster==0 ){
3192
+ artifact_page();
3193
+ return;
3194
+ }
3195
+ style_header("Cluster %S", zName);
3196
+ rcvid = db_int(0, "SELECT rcvid FROM blob WHERE rid=%d", rid);
3197
+ if( rcvid==0 ){
3198
+ zDate = 0;
3199
+ }else{
3200
+ zDate = db_text(0, "SELECT datetime(mtime) FROM rcvfrom WHERE rcvid=%d",
3201
+ rcvid);
3202
+ }
3203
+ @ <p>Artifact %z(href("%R/artifact/%h",zName))%S(zName)</a> is a cluster
3204
+ @ with %d(pCluster->nCChild) entries
3205
+ if( g.perm.Admin ){
3206
+ @ received <a href="%R/rcvfrom?rcvid=%d(rcvid)">%h(zDate)</a>:
3207
+ }else{
3208
+ @ received %h(zDate):
3209
+ }
3210
+ blob_appendf(&where,"IN(0");
3211
+ for(i=0; i<pCluster->nCChild; i++){
3212
+ int rid = fast_uuid_to_rid(pCluster->azCChild[i]);
3213
+ if( rid ){
3214
+ blob_appendf(&where,",%d", rid);
3215
+ }else{
3216
+ if( blob_size(&unks)>0 ) blob_append_char(&unks, ',');
3217
+ badRid++;
3218
+ blob_append_sql(&unks,"(%d,%Q)",-badRid,pCluster->azCChild[i]);
3219
+ }
3220
+ }
3221
+ blob_append_char(&where,')');
3222
+ describe_artifacts(blob_str(&where));
3223
+ blob_reset(&where);
3224
+ if( badRid>0 ){
3225
+ db_multi_exec(
3226
+ "WITH unks(rx,hx) AS (VALUES %s)\n"
3227
+ "INSERT INTO description(rid,uuid,type,summary) "
3228
+ " SELECT rx, hx, 'phantom', '' FROM unks;",
3229
+ blob_sql_text(&unks)
3230
+ );
3231
+ }
3232
+ blob_reset(&unks);
3233
+ db_prepare(&q,
3234
+ "SELECT rid, uuid, summary, isPrivate, type='phantom', rcvid, ref"
3235
+ " FROM description ORDER BY uuid"
3236
+ );
3237
+ if( skin_detail_boolean("white-foreground") ){
3238
+ zSha1Bg = "#714417";
3239
+ zSha3Bg = "#177117";
3240
+ }else{
3241
+ zSha1Bg = "#ebffb0";
3242
+ zSha3Bg = "#b0ffb0";
3243
+ }
3244
+ @ <table cellpadding="2" cellspacing="0" border="1">
3245
+ if( g.perm.Admin ){
3246
+ @ <tr><th>RID<th>Hash<th>Rcvid<th>Description<th>Ref<th>Remarks
3247
+ }else{
3248
+ @ <tr><th>RID<th>Hash<th>Description<th>Ref<th>Remarks
3249
+ }
3250
+ while( db_step(&q)==SQLITE_ROW ){
3251
+ int rid = db_column_int(&q,0);
3252
+ const char *zUuid = db_column_text(&q, 1);
3253
+ const char *zDesc = db_column_text(&q, 2);
3254
+ int isPriv = db_column_int(&q,3);
3255
+ int isPhantom = db_column_int(&q,4);
3256
+ const char *zRef = db_column_text(&q,6);
3257
+ if( isPriv && !isPhantom && !g.perm.Private && !g.perm.Admin ){
3258
+ /* Don't show private artifacts to users without Private (x) permission */
3259
+ continue;
3260
+ }
3261
+ if( rid<=0 ){
3262
+ @ <tr><td>&nbsp;</td>
3263
+ }else if( hashClr ){
3264
+ const char *zClr = db_column_bytes(&q,1)>40 ? zSha3Bg : zSha1Bg;
3265
+ @ <tr style='background-color:%s(zClr);'><td align="right">%d(rid)</td>
3266
+ }else{
3267
+ @ <tr><td align="right">%d(rid)</td>
3268
+ }
3269
+ if( rid<=0 ){
3270
+ @ <td>&nbsp;%S(zUuid)&nbsp;</td>
3271
+ }else{
3272
+ @ <td>&nbsp;%z(href("%R/info/%!S",zUuid))%S(zUuid)</a>&nbsp;</td>
3273
+ }
3274
+ if( g.perm.Admin ){
3275
+ int rcvid = db_column_int(&q,5);
3276
+ if( rcvid<=0 ){
3277
+ @ <td>&nbsp;
3278
+ }else{
3279
+ @ <td><a href='%R/rcvfrom?rcvid=%d(rcvid)'>%d(rcvid)</a>
3280
+ }
3281
+ }
3282
+ @ <td align="left">%h(zDesc)</td>
3283
+ if( zRef && zRef[0] ){
3284
+ @ <td>%z(href("%R/info/%!S",zRef))%S(zRef)</a>
3285
+ }else{
3286
+ @ <td>&nbsp;
3287
+ }
3288
+ if( isPriv || isPhantom ){
3289
+ if( isPriv==0 ){
3290
+ @ <td>phantom</td>
3291
+ }else if( isPhantom==0 ){
3292
+ @ <td>private</td>
3293
+ }else{
3294
+ @ <td>private,phantom</td>
3295
+ }
3296
+ }else{
3297
+ @ <td>&nbsp;
3298
+ }
3299
+ @ </tr>
3300
+ }
3301
+ @ </table>
3302
+ db_finalize(&q);
3303
+ style_finish_page();
3304
+}
3305
+
28803306
28813307
/*
28823308
** WEBPAGE: info
28833309
** URL: info/NAME
28843310
**
@@ -2963,10 +3389,14 @@
29633389
if( db_exists("SELECT 1 FROM plink WHERE pid=%d", rid) ){
29643390
ci_page();
29653391
}else
29663392
if( db_exists("SELECT 1 FROM attachment WHERE attachid=%d", rid) ){
29673393
ainfo_page();
3394
+ }else
3395
+ if( db_exists("SELECT 1 FROM tagxref WHERE rid=%d AND tagid=%d",
3396
+ rid, TAG_CLUSTER) ){
3397
+ cluster_info(rid, zName);
29683398
}else
29693399
{
29703400
artifact_page();
29713401
}
29723402
}
29733403
--- src/info.c
+++ src/info.c
@@ -320,10 +320,11 @@
320 |TIMELINE_NOSCROLL
321 |TIMELINE_XMERGE
322 |TIMELINE_CHPICK,
323 0, 0, 0, rid, rid2, 0);
324 db_finalize(&q);
 
325 }
326
327
328 /*
329 ** Append the difference between artifacts to the output
@@ -372,11 +373,13 @@
372 const char *zNew, /* blob.uuid after change. NULL for deletes */
373 const char *zOldName, /* Prior name. NULL if no name change. */
374 DiffConfig *pCfg, /* Flags for text_diff() or NULL to omit all */
375 int mperm /* executable or symlink permission for zNew */
376 ){
377 @ <p>
 
 
378 if( !g.perm.Hyperlink ){
379 if( zNew==0 ){
380 @ Deleted %h(zName).
381 }else if( zOld==0 ){
382 @ Added %h(zName).
@@ -391,10 +394,11 @@
391 @ %h(zName) became a regular file.
392 }
393 }else{
394 @ Changes to %h(zName).
395 }
 
396 if( pCfg ){
397 append_diff(zOld, zNew, pCfg);
398 }
399 }else{
400 if( zOld && zNew ){
@@ -438,18 +442,20 @@
438 @ Added %z(href("%R/finfo?name=%T&m=%!S&ci=%!S",zName,zNew,zCkin))\
439 @ %h(zName)</a> version %z(href("%R/artifact/%!S",zNew))[%S(zNew)]</a>.
440 }
441 if( zOld && zNew && fossil_strcmp(zOld,zNew)!=0 ){
442 if( pCfg ){
 
443 append_diff(zOld, zNew, pCfg);
444 }else{
445 @ &nbsp;&nbsp;
446 @ %z(href("%R/fdiff?v1=%!S&v2=%!S",zOld,zNew))[diff]</a>
 
447 }
 
 
448 }
449 }
450 @ </p>
451 }
452
453 /*
454 ** Generate javascript to enhance HTML diffs.
455 */
@@ -602,10 +608,277 @@
602 www_print_timeline(&q, TIMELINE_DISJOINT|TIMELINE_GRAPH|TIMELINE_NOSCROLL,
603 0, 0, 0, rid, 0, 0);
604 db_finalize(&q);
605 style_finish_page();
606 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
607
608 /*
609 ** WEBPAGE: vinfo
610 ** WEBPAGE: ci
611 ** URL: /ci/ARTIFACTID
@@ -628,11 +901,10 @@
628 const char *zParent; /* Hash of the parent check-in (if any) */
629 const char *zRe; /* regex parameter */
630 ReCompiled *pRe = 0; /* regex */
631 const char *zW; /* URL param for ignoring whitespace */
632 const char *zPage = "vinfo"; /* Page that shows diffs */
633 const char *zPageHide = "ci"; /* Page that hides diffs */
634 const char *zBrName; /* Branch name */
635 DiffConfig DCfg,*pCfg; /* Type of diff */
636
637 login_check_credentials();
638 if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
@@ -898,21 +1170,17 @@
898 @ <div class="sectionmenu info-changes-menu">
899 /* ^^^ .info-changes-menu is used by diff scroll sync */
900 pCfg = construct_diff_flags(diffType, &DCfg);
901 DCfg.pRe = pRe;
902 zW = (DCfg.diffFlags&DIFF_IGNORE_ALLWS)?"&w":"";
903 if( diffType!=0 ){
904 @ %z(chref("button","%R/%s/%T?diff=0",zPageHide,zName))\
905 @ Hide&nbsp;Diffs</a>
906 }
907 if( diffType!=1 ){
908 @ %z(chref("button","%R/%s/%T?diff=1%s",zPage,zName,zW))\
909 @ Unified&nbsp;Diffs</a>
910 }
911 if( diffType!=2 ){
912 @ %z(chref("button","%R/%s/%T?diff=2%s",zPage,zName,zW))\
913 @ Side-by-Side&nbsp;Diffs</a>
914 }
915 if( diffType!=0 ){
916 if( *zW ){
917 @ %z(chref("button","%R/%s/%T",zPage,zName))
918 @ Show&nbsp;Whitespace&nbsp;Changes</a>
@@ -1268,13 +1536,10 @@
1268 cgi_check_for_malice();
1269 style_set_current_feature("vdiff");
1270 if( zBranch==0 ){
1271 style_submenu_element("Path", "%R/timeline?me=%T&you=%T", zFrom, zTo);
1272 }
1273 if( diffType!=0 ){
1274 style_submenu_element("Hide Diff", "%R/vdiff?diff=0&%b%b", &qp, &qpGlob);
1275 }
1276 if( diffType!=2 ){
1277 style_submenu_element("Side-by-Side Diff", "%R/vdiff?diff=2&%b%b", &qp,
1278 &qpGlob);
1279 }
1280 if( diffType!=1 ) {
@@ -1668,11 +1933,11 @@
1668 tag_private_status(rid);
1669 }
1670 db_finalize(&q);
1671 if( db_exists("SELECT 1 FROM tagxref WHERE rid=%d AND tagid=%d",
1672 rid, TAG_CLUSTER) ){
1673 @ Cluster
1674 cnt++;
1675 }
1676 if( cnt==0 ){
1677 @ Unrecognized artifact
1678 if( pDownloadName && blob_size(pDownloadName)==0 ){
@@ -1933,10 +2198,16 @@
1933 ** WEBPAGE: jchunk hidden
1934 ** URL: /jchunk/HASH?from=N&to=M
1935 **
1936 ** Return lines of text from a file as a JSON array - one entry in the
1937 ** array for each line of text.
 
 
 
 
 
 
1938 **
1939 ** **Warning:** This is an internal-use-only interface that is subject to
1940 ** change at any moment. External application should not use this interface
1941 ** since the application will break when this interface changes, and this
1942 ** interface will undoubtedly change.
@@ -1948,10 +2219,11 @@
1948 ** ajax_route_error().
1949 */
1950 void jchunk_page(void){
1951 int rid = 0;
1952 const char *zName = PD("name", "");
 
1953 int iFrom = atoi(PD("from","0"));
1954 int iTo = atoi(PD("to","0"));
1955 int ln;
1956 int go = 1;
1957 const char *zSep;
@@ -1968,36 +2240,57 @@
1968 cgi_check_for_malice();
1969 if( !g.perm.Read ){
1970 ajax_route_error(403, "Access requires Read permissions.");
1971 return;
1972 }
1973 #if 1
1974 /* Re-enable this block once this code is integrated somewhere into
1975 the UI. */
1976 rid = db_int(0, "SELECT rid FROM blob WHERE uuid=%Q", zName);
1977 if( rid==0 ){
1978 ajax_route_error(404, "Unknown artifact: %h", zName);
1979 return;
1980 }
1981 #else
1982 /* This impl is only to simplify "manual" testing via the JS
1983 console. */
1984 rid = symbolic_name_to_rid(zName, "*");
1985 if( rid==0 ){
1986 ajax_route_error(404, "Unknown artifact: %h", zName);
1987 return;
1988 }else if( rid<0 ){
1989 ajax_route_error(418, "Ambiguous artifact name: %h", zName);
1990 return;
1991 }
1992 #endif
1993 if( iFrom<1 || iTo<iFrom ){
1994 ajax_route_error(500, "Invalid line range from=%d, to=%d.",
1995 iFrom, iTo);
1996 return;
1997 }
1998 content_get(rid, &content);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1999 g.isConst = 1;
2000 cgi_set_content_type("application/json");
2001 ln = 0;
2002 while( go && ln<iFrom ){
2003 go = blob_line(&content, &line);
@@ -2875,10 +3168,143 @@
2875 ticket_output_change_artifact(pTktChng, 0, 1, 0);
2876 manifest_destroy(pTktChng);
2877 style_finish_page();
2878 }
2879
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2880
2881 /*
2882 ** WEBPAGE: info
2883 ** URL: info/NAME
2884 **
@@ -2963,10 +3389,14 @@
2963 if( db_exists("SELECT 1 FROM plink WHERE pid=%d", rid) ){
2964 ci_page();
2965 }else
2966 if( db_exists("SELECT 1 FROM attachment WHERE attachid=%d", rid) ){
2967 ainfo_page();
 
 
 
 
2968 }else
2969 {
2970 artifact_page();
2971 }
2972 }
2973
--- src/info.c
+++ src/info.c
@@ -320,10 +320,11 @@
320 |TIMELINE_NOSCROLL
321 |TIMELINE_XMERGE
322 |TIMELINE_CHPICK,
323 0, 0, 0, rid, rid2, 0);
324 db_finalize(&q);
325 blob_reset(&sql);
326 }
327
328
329 /*
330 ** Append the difference between artifacts to the output
@@ -372,11 +373,13 @@
373 const char *zNew, /* blob.uuid after change. NULL for deletes */
374 const char *zOldName, /* Prior name. NULL if no name change. */
375 DiffConfig *pCfg, /* Flags for text_diff() or NULL to omit all */
376 int mperm /* executable or symlink permission for zNew */
377 ){
378 @ <div class='file-change-line'><span>
379 /* Maintenance reminder: the extra level of SPAN is for
380 ** arranging new elements via JS. */
381 if( !g.perm.Hyperlink ){
382 if( zNew==0 ){
383 @ Deleted %h(zName).
384 }else if( zOld==0 ){
385 @ Added %h(zName).
@@ -391,10 +394,11 @@
394 @ %h(zName) became a regular file.
395 }
396 }else{
397 @ Changes to %h(zName).
398 }
399 @ </span></div>
400 if( pCfg ){
401 append_diff(zOld, zNew, pCfg);
402 }
403 }else{
404 if( zOld && zNew ){
@@ -438,18 +442,20 @@
442 @ Added %z(href("%R/finfo?name=%T&m=%!S&ci=%!S",zName,zNew,zCkin))\
443 @ %h(zName)</a> version %z(href("%R/artifact/%!S",zNew))[%S(zNew)]</a>.
444 }
445 if( zOld && zNew && fossil_strcmp(zOld,zNew)!=0 ){
446 if( pCfg ){
447 @ </span></div>
448 append_diff(zOld, zNew, pCfg);
449 }else{
 
450 @ %z(href("%R/fdiff?v1=%!S&v2=%!S",zOld,zNew))[diff]</a>
451 @ </span></div>
452 }
453 }else{
454 @ </span></div>
455 }
456 }
 
457 }
458
459 /*
460 ** Generate javascript to enhance HTML diffs.
461 */
@@ -602,10 +608,277 @@
608 www_print_timeline(&q, TIMELINE_DISJOINT|TIMELINE_GRAPH|TIMELINE_NOSCROLL,
609 0, 0, 0, rid, 0, 0);
610 db_finalize(&q);
611 style_finish_page();
612 }
613
614 /*
615 ** Render a web-page diff of the changes in the working check-out
616 */
617 static void ckout_normal_diff(int vid){
618 int diffType; /* 0: no diff, 1: unified, 2: side-by-side */
619 DiffConfig DCfg,*pCfg; /* Diff details */
620 const char *zW; /* The "w" query parameter */
621 int nChng; /* Number of changes */
622 Stmt q;
623
624 diffType = preferred_diff_type();
625 pCfg = construct_diff_flags(diffType, &DCfg);
626 nChng = db_int(0, "SELECT count(*) FROM vfile"
627 " WHERE vid=%d AND (deleted OR chnged OR rid==0)", vid);
628 if( nChng==0 ){
629 @ <p>No uncommitted changes</p>
630 return;
631 }
632 db_prepare(&q,
633 /* 0 1 2 3 4 5 6 */
634 "SELECT pathname, deleted, chnged , rid==0, rid, islink, uuid"
635 " FROM vfile LEFT JOIN blob USING(rid)"
636 " WHERE vid=%d"
637 " AND (deleted OR chnged OR rid==0)"
638 " ORDER BY pathname /*scan*/",
639 vid
640 );
641 if( DCfg.diffFlags & DIFF_SIDEBYSIDE ){
642 DCfg.diffFlags |= DIFF_HTML | DIFF_NOTTOOBIG;
643 }else{
644 DCfg.diffFlags |= DIFF_LINENO | DIFF_HTML | DIFF_NOTTOOBIG;
645 }
646 @ <div class="sectionmenu info-changes-menu">
647 zW = (DCfg.diffFlags&DIFF_IGNORE_ALLWS)?"&w":"";
648 if( diffType!=1 ){
649 @ %z(chref("button","%R?diff=1%s",zW))Unified&nbsp;Diff</a>
650 }
651 if( diffType!=2 ){
652 @ %z(chref("button","%R?diff=2%s",zW))Side-by-Side&nbsp;Diff</a>
653 }
654 if( diffType!=0 ){
655 if( *zW ){
656 @ %z(chref("button","%R?diff=%d",diffType))\
657 @ Show&nbsp;Whitespace&nbsp;Changes</a>
658 }else{
659 @ %z(chref("button","%R?diff=%d&w",diffType))Ignore&nbsp;Whitespace</a>
660 }
661 }
662 @ </div>
663 while( db_step(&q)==SQLITE_ROW ){
664 const char *zTreename = db_column_text(&q,0);
665 int isDeleted = db_column_int(&q, 1);
666 int isChnged = db_column_int(&q,2);
667 int isNew = db_column_int(&q,3);
668 int srcid = db_column_int(&q, 4);
669 int isLink = db_column_int(&q, 5);
670 const char *zUuid = db_column_text(&q, 6);
671 int showDiff = 1;
672
673 DCfg.diffFlags &= (~DIFF_FILE_MASK);
674 @ <div class='file-change-line'><span>
675 if( isDeleted ){
676 @ DELETED %h(zTreename)
677 DCfg.diffFlags |= DIFF_FILE_DELETED;
678 showDiff = 0;
679 }else if( file_access(zTreename, F_OK) ){
680 @ MISSING %h(zTreename)
681 showDiff = 0;
682 }else if( isNew ){
683 @ ADDED %h(zTreename)
684 DCfg.diffFlags |= DIFF_FILE_ADDED;
685 srcid = 0;
686 showDiff = 0;
687 }else if( isChnged==3 ){
688 @ ADDED_BY_MERGE %h(zTreename)
689 DCfg.diffFlags |= DIFF_FILE_ADDED;
690 srcid = 0;
691 showDiff = 0;
692 }else if( isChnged==5 ){
693 @ ADDED_BY_INTEGRATE %h(zTreename)
694 DCfg.diffFlags |= DIFF_FILE_ADDED;
695 srcid = 0;
696 showDiff = 0;
697 }else{
698 @ CHANGED %h(zTreename)
699 }
700 @ </span></div>
701 if( showDiff && pCfg ){
702 Blob old, new;
703 if( !isLink != !file_islink(zTreename) ){
704 @ %s(DIFF_CANNOT_COMPUTE_SYMLINK)
705 continue;
706 }
707 if( srcid>0 ){
708 content_get(srcid, &old);
709 pCfg->zLeftHash = zUuid;
710 }else{
711 blob_zero(&old);
712 pCfg->zLeftHash = 0;
713 }
714 blob_read_from_file(&new, zTreename, ExtFILE);
715 text_diff(&old, &new, cgi_output_blob(), pCfg);
716 blob_reset(&old);
717 blob_reset(&new);
718 }
719 }
720 db_finalize(&q);
721 append_diff_javascript(diffType);
722 }
723
724 /*
725 ** Render a web-page diff of the changes in the working check-out to
726 ** an external reference.
727 */
728 static void ckout_external_base_diff(int vid, const char *zExBase){
729 int diffType; /* 0: no diff, 1: unified, 2: side-by-side */
730 DiffConfig DCfg,*pCfg; /* Diff details */
731 const char *zW; /* The "w" query parameter */
732 Stmt q;
733
734 diffType = preferred_diff_type();
735 pCfg = construct_diff_flags(diffType, &DCfg);
736 db_prepare(&q,
737 "SELECT pathname FROM vfile WHERE vid=%d ORDER BY pathname", vid
738 );
739 if( DCfg.diffFlags & DIFF_SIDEBYSIDE ){
740 DCfg.diffFlags |= DIFF_HTML | DIFF_NOTTOOBIG;
741 }else{
742 DCfg.diffFlags |= DIFF_LINENO | DIFF_HTML | DIFF_NOTTOOBIG;
743 }
744 @ <div class="sectionmenu info-changes-menu">
745 zW = (DCfg.diffFlags&DIFF_IGNORE_ALLWS)?"&w":"";
746 if( diffType!=1 ){
747 @ %z(chref("button","%R?diff=1&exbase=%h%s",zExBase,zW))\
748 @ Unified&nbsp;Diff</a>
749 }
750 if( diffType!=2 ){
751 @ %z(chref("button","%R?diff=2&exbase=%h%s",zExBase,zW))\
752 @ Side-by-Side&nbsp;Diff</a>
753 }
754 if( diffType!=0 ){
755 if( *zW ){
756 @ %z(chref("button","%R?diff=%d&exbase=%h",diffType,zExBase))\
757 @ Show&nbsp;Whitespace&nbsp;Changes</a>
758 }else{
759 @ %z(chref("button","%R?diff=%d&exbase=%h&w",diffType,zExBase))\
760 @ Ignore&nbsp;Whitespace</a>
761 }
762 }
763 @ </div>
764 while( db_step(&q)==SQLITE_ROW ){
765 const char *zFile; /* Name of file in the repository */
766 char *zLhs; /* Full name of left-hand side file */
767 char *zRhs; /* Full name of right-hand side file */
768 Blob rhs; /* Full text of RHS */
769 Blob lhs; /* Full text of LHS */
770
771 zFile = db_column_text(&q,0);
772 zLhs = mprintf("%s/%s", zExBase, zFile);
773 zRhs = mprintf("%s%s", g.zLocalRoot, zFile);
774 if( file_size(zLhs, ExtFILE)<0 ){
775 @ <div class='file-change-line'><span>
776 @ Missing from external baseline: %h(zFile)
777 @ </span></div>
778 }else{
779 blob_read_from_file(&lhs, zLhs, ExtFILE);
780 blob_read_from_file(&rhs, zRhs, ExtFILE);
781 if( blob_size(&lhs)!=blob_size(&rhs)
782 || memcmp(blob_buffer(&lhs), blob_buffer(&rhs), blob_size(&lhs))!=0
783 ){
784 @ <div class='file-change-line'><span>
785 @ Changes to %h(zFile)
786 @ </span></div>
787 if( pCfg ){
788 char *zFullFN;
789 char *zHexFN;
790 zFullFN = file_canonical_name_dup(zLhs);
791 zHexFN = mprintf("x%H", zFullFN);
792 fossil_free(zFullFN);
793 pCfg->zLeftHash = zHexFN;
794 text_diff(&lhs, &rhs, cgi_output_blob(), pCfg);
795 pCfg->zLeftHash = 0;
796 fossil_free(zHexFN);
797 }
798 }
799 blob_reset(&lhs);
800 blob_reset(&rhs);
801 }
802 fossil_free(zLhs);
803 fossil_free(zRhs);
804 }
805 db_finalize(&q);
806 append_diff_javascript(diffType);
807 }
808
809 /*
810 ** WEBPAGE: ckout
811 **
812 ** Show information about the current checkout. This page only functions
813 ** if the web server is run on a loopback interface (in other words, was
814 ** started using "fossil ui" or similar) from within an open check-out.
815 **
816 ** If the "exbase=PATH" query parameter is provided, then the diff shown
817 ** uses the files in PATH as the baseline. This is the same as using
818 ** the "--from PATH" argument to the "fossil diff" command-line. In fact,
819 ** when using "fossil ui --from PATH", the --from argument becomes the value
820 ** of the exbase query parameter for the start page. Note that if PATH
821 ** is a pure hexadecimal string, it is decoded first before being used as
822 ** the pathname. Real pathnames should contain at least one directory
823 ** separator character.
824 **
825 ** Other query parameters related to diffs are also accepted.
826 */
827 void ckout_page(void){
828 int vid;
829 const char *zHome; /* Home directory */
830 int nHome;
831 const char *zExBase;
832 char *zHostname;
833 char *zCwd;
834
835 if( !cgi_is_loopback(g.zIpAddr) || !db_open_local(0) ){
836 cgi_redirectf("%R/home");
837 return;
838 }
839 file_chdir(g.zLocalRoot, 0);
840 vid = db_lget_int("checkout", 0);
841 db_unprotect(PROTECT_ALL);
842 vfile_check_signature(vid, CKSIG_ENOTFILE);
843 db_protect_pop();
844 style_set_current_feature("vinfo");
845 zHostname = fossil_hostname();
846 zCwd = file_getcwd(0,0);
847 zHome = fossil_getenv("HOME");
848 if( zHome ){
849 nHome = (int)strlen(zHome);
850 if( strncmp(zCwd, zHome, nHome)==0 && zCwd[nHome]=='/' ){
851 zCwd = mprintf("~%s", zCwd+nHome);
852 }
853 }else{
854 nHome = 0;
855 }
856 if( zHostname ){
857 style_header("Checkout Status: %h on %h", zCwd, zHostname);
858 }else{
859 style_header("Checkout Status: %h", zCwd);
860 }
861 render_checkin_context(vid, 0, 0, 0);
862 @ <hr>
863 zExBase = P("exbase");
864 if( zExBase && zExBase[0] ){
865 char *zPath = decode16_dup(zExBase);
866 char *zCBase = file_canonical_name_dup(zPath?zPath:zExBase);
867 if( nHome && strncmp(zCBase, zHome, nHome)==0 && zCBase[nHome]=='/' ){
868 @ <p>Using external baseline: ~%h(zCBase+nHome)</p>
869 }else{
870 @ <p>Using external baseline: %h(zCBase)</p>
871 }
872 ckout_external_base_diff(vid, zCBase);
873 fossil_free(zCBase);
874 fossil_free(zPath);
875 }else{
876 ckout_normal_diff(vid);
877 }
878 style_finish_page();
879 }
880
881 /*
882 ** WEBPAGE: vinfo
883 ** WEBPAGE: ci
884 ** URL: /ci/ARTIFACTID
@@ -628,11 +901,10 @@
901 const char *zParent; /* Hash of the parent check-in (if any) */
902 const char *zRe; /* regex parameter */
903 ReCompiled *pRe = 0; /* regex */
904 const char *zW; /* URL param for ignoring whitespace */
905 const char *zPage = "vinfo"; /* Page that shows diffs */
 
906 const char *zBrName; /* Branch name */
907 DiffConfig DCfg,*pCfg; /* Type of diff */
908
909 login_check_credentials();
910 if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
@@ -898,21 +1170,17 @@
1170 @ <div class="sectionmenu info-changes-menu">
1171 /* ^^^ .info-changes-menu is used by diff scroll sync */
1172 pCfg = construct_diff_flags(diffType, &DCfg);
1173 DCfg.pRe = pRe;
1174 zW = (DCfg.diffFlags&DIFF_IGNORE_ALLWS)?"&w":"";
 
 
 
 
1175 if( diffType!=1 ){
1176 @ %z(chref("button","%R/%s/%T?diff=1%s",zPage,zName,zW))\
1177 @ Unified&nbsp;Diff</a>
1178 }
1179 if( diffType!=2 ){
1180 @ %z(chref("button","%R/%s/%T?diff=2%s",zPage,zName,zW))\
1181 @ Side-by-Side&nbsp;Diff</a>
1182 }
1183 if( diffType!=0 ){
1184 if( *zW ){
1185 @ %z(chref("button","%R/%s/%T",zPage,zName))
1186 @ Show&nbsp;Whitespace&nbsp;Changes</a>
@@ -1268,13 +1536,10 @@
1536 cgi_check_for_malice();
1537 style_set_current_feature("vdiff");
1538 if( zBranch==0 ){
1539 style_submenu_element("Path", "%R/timeline?me=%T&you=%T", zFrom, zTo);
1540 }
 
 
 
1541 if( diffType!=2 ){
1542 style_submenu_element("Side-by-Side Diff", "%R/vdiff?diff=2&%b%b", &qp,
1543 &qpGlob);
1544 }
1545 if( diffType!=1 ) {
@@ -1668,11 +1933,11 @@
1933 tag_private_status(rid);
1934 }
1935 db_finalize(&q);
1936 if( db_exists("SELECT 1 FROM tagxref WHERE rid=%d AND tagid=%d",
1937 rid, TAG_CLUSTER) ){
1938 @ Cluster %z(href("%R/info/%S",zUuid))%S(zUuid)</a>.
1939 cnt++;
1940 }
1941 if( cnt==0 ){
1942 @ Unrecognized artifact
1943 if( pDownloadName && blob_size(pDownloadName)==0 ){
@@ -1933,10 +2198,16 @@
2198 ** WEBPAGE: jchunk hidden
2199 ** URL: /jchunk/HASH?from=N&to=M
2200 **
2201 ** Return lines of text from a file as a JSON array - one entry in the
2202 ** array for each line of text.
2203 **
2204 ** The HASH is normally a sha1 or sha3 hash that identifies an artifact
2205 ** in the BLOB table of the database. However, if HASH starts with an "x"
2206 ** and is followed by valid hexadecimal, and if we are running in a
2207 ** "fossil ui" situation (locally and with privilege), then decode the hex
2208 ** into a filename and read the file content from that name.
2209 **
2210 ** **Warning:** This is an internal-use-only interface that is subject to
2211 ** change at any moment. External application should not use this interface
2212 ** since the application will break when this interface changes, and this
2213 ** interface will undoubtedly change.
@@ -1948,10 +2219,11 @@
2219 ** ajax_route_error().
2220 */
2221 void jchunk_page(void){
2222 int rid = 0;
2223 const char *zName = PD("name", "");
2224 int nName = (int)(strlen(zName)&0x7fffffff);
2225 int iFrom = atoi(PD("from","0"));
2226 int iTo = atoi(PD("to","0"));
2227 int ln;
2228 int go = 1;
2229 const char *zSep;
@@ -1968,36 +2240,57 @@
2240 cgi_check_for_malice();
2241 if( !g.perm.Read ){
2242 ajax_route_error(403, "Access requires Read permissions.");
2243 return;
2244 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2245 if( iFrom<1 || iTo<iFrom ){
2246 ajax_route_error(500, "Invalid line range from=%d, to=%d.",
2247 iFrom, iTo);
2248 return;
2249 }
2250 if( zName[0]=='x'
2251 && ((nName-1)&1)==0
2252 && validate16(&zName[1],nName-1)
2253 && g.perm.Admin
2254 && cgi_is_loopback(g.zIpAddr)
2255 && db_open_local(0)
2256 ){
2257 /* Treat the HASH as a hex-encoded filename */
2258 int n = (nName-1)/2;
2259 char *zFN = fossil_malloc(n+1);
2260 decode16((const u8*)&zName[1], (u8*)zFN, nName-1);
2261 zFN[n] = 0;
2262 if( file_size(zFN, ExtFILE)<0 ){
2263 blob_zero(&content);
2264 }else{
2265 blob_read_from_file(&content, zFN, ExtFILE);
2266 }
2267 fossil_free(zFN);
2268 }else{
2269 /* Treat the HASH as an artifact hash matching BLOB.UUID */
2270 #if 1
2271 /* Re-enable this block once this code is integrated somewhere into
2272 the UI. */
2273 rid = db_int(0, "SELECT rid FROM blob WHERE uuid=%Q", zName);
2274 if( rid==0 ){
2275 ajax_route_error(404, "Unknown artifact: %h", zName);
2276 return;
2277 }
2278 #else
2279 /* This impl is only to simplify "manual" testing via the JS
2280 console. */
2281 rid = symbolic_name_to_rid(zName, "*");
2282 if( rid==0 ){
2283 ajax_route_error(404, "Unknown artifact: %h", zName);
2284 return;
2285 }else if( rid<0 ){
2286 ajax_route_error(418, "Ambiguous artifact name: %h", zName);
2287 return;
2288 }
2289 #endif
2290 content_get(rid, &content);
2291 }
2292 g.isConst = 1;
2293 cgi_set_content_type("application/json");
2294 ln = 0;
2295 while( go && ln<iFrom ){
2296 go = blob_line(&content, &line);
@@ -2875,10 +3168,143 @@
3168 ticket_output_change_artifact(pTktChng, 0, 1, 0);
3169 manifest_destroy(pTktChng);
3170 style_finish_page();
3171 }
3172
3173 /*
3174 ** rid is a cluster. Paint a page that contains detailed information
3175 ** about that cluster.
3176 */
3177 static void cluster_info(int rid, const char *zName){
3178 Manifest *pCluster;
3179 int i;
3180 Blob where = BLOB_INITIALIZER;
3181 Blob unks = BLOB_INITIALIZER;
3182 Stmt q;
3183 char *zSha1Bg;
3184 char *zSha3Bg;
3185 int badRid = 0;
3186 int rcvid;
3187 int hashClr = PB("hclr");
3188 const char *zDate;
3189
3190 pCluster = manifest_get(rid, CFTYPE_CLUSTER, 0);
3191 if( pCluster==0 ){
3192 artifact_page();
3193 return;
3194 }
3195 style_header("Cluster %S", zName);
3196 rcvid = db_int(0, "SELECT rcvid FROM blob WHERE rid=%d", rid);
3197 if( rcvid==0 ){
3198 zDate = 0;
3199 }else{
3200 zDate = db_text(0, "SELECT datetime(mtime) FROM rcvfrom WHERE rcvid=%d",
3201 rcvid);
3202 }
3203 @ <p>Artifact %z(href("%R/artifact/%h",zName))%S(zName)</a> is a cluster
3204 @ with %d(pCluster->nCChild) entries
3205 if( g.perm.Admin ){
3206 @ received <a href="%R/rcvfrom?rcvid=%d(rcvid)">%h(zDate)</a>:
3207 }else{
3208 @ received %h(zDate):
3209 }
3210 blob_appendf(&where,"IN(0");
3211 for(i=0; i<pCluster->nCChild; i++){
3212 int rid = fast_uuid_to_rid(pCluster->azCChild[i]);
3213 if( rid ){
3214 blob_appendf(&where,",%d", rid);
3215 }else{
3216 if( blob_size(&unks)>0 ) blob_append_char(&unks, ',');
3217 badRid++;
3218 blob_append_sql(&unks,"(%d,%Q)",-badRid,pCluster->azCChild[i]);
3219 }
3220 }
3221 blob_append_char(&where,')');
3222 describe_artifacts(blob_str(&where));
3223 blob_reset(&where);
3224 if( badRid>0 ){
3225 db_multi_exec(
3226 "WITH unks(rx,hx) AS (VALUES %s)\n"
3227 "INSERT INTO description(rid,uuid,type,summary) "
3228 " SELECT rx, hx, 'phantom', '' FROM unks;",
3229 blob_sql_text(&unks)
3230 );
3231 }
3232 blob_reset(&unks);
3233 db_prepare(&q,
3234 "SELECT rid, uuid, summary, isPrivate, type='phantom', rcvid, ref"
3235 " FROM description ORDER BY uuid"
3236 );
3237 if( skin_detail_boolean("white-foreground") ){
3238 zSha1Bg = "#714417";
3239 zSha3Bg = "#177117";
3240 }else{
3241 zSha1Bg = "#ebffb0";
3242 zSha3Bg = "#b0ffb0";
3243 }
3244 @ <table cellpadding="2" cellspacing="0" border="1">
3245 if( g.perm.Admin ){
3246 @ <tr><th>RID<th>Hash<th>Rcvid<th>Description<th>Ref<th>Remarks
3247 }else{
3248 @ <tr><th>RID<th>Hash<th>Description<th>Ref<th>Remarks
3249 }
3250 while( db_step(&q)==SQLITE_ROW ){
3251 int rid = db_column_int(&q,0);
3252 const char *zUuid = db_column_text(&q, 1);
3253 const char *zDesc = db_column_text(&q, 2);
3254 int isPriv = db_column_int(&q,3);
3255 int isPhantom = db_column_int(&q,4);
3256 const char *zRef = db_column_text(&q,6);
3257 if( isPriv && !isPhantom && !g.perm.Private && !g.perm.Admin ){
3258 /* Don't show private artifacts to users without Private (x) permission */
3259 continue;
3260 }
3261 if( rid<=0 ){
3262 @ <tr><td>&nbsp;</td>
3263 }else if( hashClr ){
3264 const char *zClr = db_column_bytes(&q,1)>40 ? zSha3Bg : zSha1Bg;
3265 @ <tr style='background-color:%s(zClr);'><td align="right">%d(rid)</td>
3266 }else{
3267 @ <tr><td align="right">%d(rid)</td>
3268 }
3269 if( rid<=0 ){
3270 @ <td>&nbsp;%S(zUuid)&nbsp;</td>
3271 }else{
3272 @ <td>&nbsp;%z(href("%R/info/%!S",zUuid))%S(zUuid)</a>&nbsp;</td>
3273 }
3274 if( g.perm.Admin ){
3275 int rcvid = db_column_int(&q,5);
3276 if( rcvid<=0 ){
3277 @ <td>&nbsp;
3278 }else{
3279 @ <td><a href='%R/rcvfrom?rcvid=%d(rcvid)'>%d(rcvid)</a>
3280 }
3281 }
3282 @ <td align="left">%h(zDesc)</td>
3283 if( zRef && zRef[0] ){
3284 @ <td>%z(href("%R/info/%!S",zRef))%S(zRef)</a>
3285 }else{
3286 @ <td>&nbsp;
3287 }
3288 if( isPriv || isPhantom ){
3289 if( isPriv==0 ){
3290 @ <td>phantom</td>
3291 }else if( isPhantom==0 ){
3292 @ <td>private</td>
3293 }else{
3294 @ <td>private,phantom</td>
3295 }
3296 }else{
3297 @ <td>&nbsp;
3298 }
3299 @ </tr>
3300 }
3301 @ </table>
3302 db_finalize(&q);
3303 style_finish_page();
3304 }
3305
3306
3307 /*
3308 ** WEBPAGE: info
3309 ** URL: info/NAME
3310 **
@@ -2963,10 +3389,14 @@
3389 if( db_exists("SELECT 1 FROM plink WHERE pid=%d", rid) ){
3390 ci_page();
3391 }else
3392 if( db_exists("SELECT 1 FROM attachment WHERE attachid=%d", rid) ){
3393 ainfo_page();
3394 }else
3395 if( db_exists("SELECT 1 FROM tagxref WHERE rid=%d AND tagid=%d",
3396 rid, TAG_CLUSTER) ){
3397 cluster_info(rid, zName);
3398 }else
3399 {
3400 artifact_page();
3401 }
3402 }
3403
+37 -10
--- src/main.c
+++ src/main.c
@@ -1330,10 +1330,11 @@
13301330
13311331
/* We should be done with options.. */
13321332
verify_all_options();
13331333
fossil_version_blob(&versionInfo, verboseFlag);
13341334
fossil_print("%s", blob_str(&versionInfo));
1335
+ blob_reset(&versionInfo);
13351336
}
13361337
13371338
13381339
/*
13391340
** WEBPAGE: version
@@ -1634,11 +1635,11 @@
16341635
16351636
/*
16361637
** Return true if it is appropriate to redirect requests to HTTPS.
16371638
**
16381639
** Redirect to https is appropriate if all of the above are true:
1639
-** (1) The redirect-to-https flag has a valud of iLevel or greater.
1640
+** (1) The redirect-to-https flag has a value of iLevel or greater.
16401641
** (2) The current connection is http, not https or ssh
16411642
** (3) The sslNotAvailable flag is clear
16421643
*/
16431644
int fossil_wants_https(int iLevel){
16441645
if( g.sslNotAvailable ) return 0;
@@ -2040,20 +2041,27 @@
20402041
*/
20412042
set_base_url(0);
20422043
if( fossil_redirect_to_https_if_needed(2) ) return;
20432044
if( zPathInfo==0 || zPathInfo[0]==0
20442045
|| (zPathInfo[0]=='/' && zPathInfo[1]==0) ){
2045
- /* Second special case: If the PATH_INFO is blank, issue a redirect to
2046
- ** the home page identified by the "index-page" setting in the repository
2047
- ** CONFIG table, to "/index" if there no "index-page" setting. */
2046
+ /* Second special case: If the PATH_INFO is blank, issue a redirect:
2047
+ ** (1) to "/ckout" if g.useLocalauth and g.localOpen are both set.
2048
+ ** (2) to the home page identified by the "index-page" setting
2049
+ ** in the repository CONFIG table
2050
+ ** (3) to "/index" if there no "index-page" setting in CONFIG
2051
+ */
20482052
#ifdef FOSSIL_ENABLE_JSON
20492053
if(g.json.isJsonMode){
20502054
json_err(FSL_JSON_E_RESOURCE_NOT_FOUND,NULL,1);
20512055
fossil_exit(0);
20522056
}
20532057
#endif
2054
- fossil_redirect_home() /*does not return*/;
2058
+ if( g.useLocalauth && g.localOpen ){
2059
+ cgi_redirectf("%R/ckout");
2060
+ }else{
2061
+ fossil_redirect_home() /*does not return*/;
2062
+ }
20552063
}else{
20562064
zPath = mprintf("%s", zPathInfo);
20572065
}
20582066
20592067
/* Make g.zPath point to the first element of the path. Make
@@ -2912,10 +2920,23 @@
29122920
#if defined(_WIN32)
29132921
_setmode(_fileno(stdout), _O_BINARY);
29142922
#endif
29152923
}
29162924
zIpAddr = find_option("ipaddr",0,1);
2925
+#if defined(_WIN32)
2926
+ /* The undocumented option "--as NAME" causes NAME to become
2927
+ ** the fake command name. This only happens on Windows and only
2928
+ ** if preceded by --in, --out, and --ipaddr. It is a work-around
2929
+ ** to get the original command-name down into the "http" command that
2930
+ ** is run in a subprocess to manage HTTP requests on Windows for
2931
+ ** commands like "fossil ui" and "fossil server".
2932
+ */
2933
+ if( zInFile && zOutFile && zIpAddr ){
2934
+ const char *z = find_option("as",0,1);
2935
+ if( z ) g.zCmdName = z;
2936
+ }
2937
+#endif
29172938
useSCGI = find_option("scgi", 0, 0)!=0;
29182939
if( useSCGI ) g.zReqType = "SCGI";
29192940
zAltBase = find_option("baseurl", 0, 1);
29202941
if( find_option("nodelay",0,0)!=0 ) backoffice_no_delay();
29212942
if( zAltBase ) set_base_url(zAltBase);
@@ -3171,10 +3192,11 @@
31713192
** --errorlog FILE Append HTTP error messages to FILE
31723193
** --extroot DIR Document root for the /ext extension mechanism
31733194
** --files GLOBLIST Comma-separated list of glob patterns for static files
31743195
** --fossilcmd PATH The pathname of the "fossil" executable on the remote
31753196
** system when REPOSITORY is remote.
3197
+** --from PATH Use PATH as the diff baseline for the /ckout page
31763198
** --localauth Enable automatic login for requests from localhost
31773199
** --localhost Listen on 127.0.0.1 only (always true for "ui")
31783200
** --https Indicates that the input is coming through a reverse
31793201
** proxy that has already translated HTTPS into HTTP.
31803202
** --jsmode MODE Determine how JavaScript is delivered with pages.
@@ -3243,10 +3265,11 @@
32433265
const char *zInitPage = 0; /* Start on this page. --page option */
32443266
int findServerArg = 2; /* argv index for find_server_repository() */
32453267
char *zRemote = 0; /* Remote host on which to run "fossil ui" */
32463268
const char *zJsMode; /* The --jsmode parameter */
32473269
const char *zFossilCmd =0; /* Name of "fossil" binary on remote system */
3270
+ const char *zFrom; /* Value for --from */
32483271
32493272
32503273
#if USE_SEE
32513274
db_setup_for_saved_encryption_key();
32523275
#endif
@@ -3279,13 +3302,21 @@
32793302
g.useLocalauth = find_option("localauth", 0, 0)!=0;
32803303
Th_InitTraceLog();
32813304
zPort = find_option("port", "P", 1);
32823305
isUiCmd = g.argv[1][0]=='u';
32833306
if( isUiCmd ){
3307
+ zFrom = find_option("from", 0, 1);
3308
+ if( zFrom && zFrom==file_tail(zFrom) ){
3309
+ fossil_fatal("the argument to --from must be a pathname for"
3310
+ " the \"ui\" command");
3311
+ }
32843312
zInitPage = find_option("page", "p", 1);
32853313
if( zInitPage && zInitPage[0]=='/' ) zInitPage++;
32863314
zFossilCmd = find_option("fossilcmd", 0, 1);
3315
+ if( zFrom && zInitPage==0 ){
3316
+ zInitPage = mprintf("ckout?exbase=%H", zFrom);
3317
+ }
32873318
}
32883319
zNotFound = find_option("notfound", 0, 1);
32893320
allowRepoList = find_option("repolist",0,0)!=0;
32903321
if( find_option("nocompress",0,0)!=0 ) g.fNoHttpCompress = 1;
32913322
zAltBase = find_option("baseurl", 0, 1);
@@ -3384,15 +3415,11 @@
33843415
}
33853416
if( !zRemote ){
33863417
find_server_repository(findServerArg, fCreate);
33873418
}
33883419
if( zInitPage==0 ){
3389
- if( isUiCmd && g.localOpen ){
3390
- zInitPage = "timeline?c=current";
3391
- }else{
3392
- zInitPage = "";
3393
- }
3420
+ zInitPage = "";
33943421
}
33953422
if( zPort ){
33963423
if( strchr(zPort,':') ){
33973424
int i;
33983425
for(i=strlen(zPort)-1; i>=0 && zPort[i]!=':'; i--){}
33993426
--- src/main.c
+++ src/main.c
@@ -1330,10 +1330,11 @@
1330
1331 /* We should be done with options.. */
1332 verify_all_options();
1333 fossil_version_blob(&versionInfo, verboseFlag);
1334 fossil_print("%s", blob_str(&versionInfo));
 
1335 }
1336
1337
1338 /*
1339 ** WEBPAGE: version
@@ -1634,11 +1635,11 @@
1634
1635 /*
1636 ** Return true if it is appropriate to redirect requests to HTTPS.
1637 **
1638 ** Redirect to https is appropriate if all of the above are true:
1639 ** (1) The redirect-to-https flag has a valud of iLevel or greater.
1640 ** (2) The current connection is http, not https or ssh
1641 ** (3) The sslNotAvailable flag is clear
1642 */
1643 int fossil_wants_https(int iLevel){
1644 if( g.sslNotAvailable ) return 0;
@@ -2040,20 +2041,27 @@
2040 */
2041 set_base_url(0);
2042 if( fossil_redirect_to_https_if_needed(2) ) return;
2043 if( zPathInfo==0 || zPathInfo[0]==0
2044 || (zPathInfo[0]=='/' && zPathInfo[1]==0) ){
2045 /* Second special case: If the PATH_INFO is blank, issue a redirect to
2046 ** the home page identified by the "index-page" setting in the repository
2047 ** CONFIG table, to "/index" if there no "index-page" setting. */
 
 
 
2048 #ifdef FOSSIL_ENABLE_JSON
2049 if(g.json.isJsonMode){
2050 json_err(FSL_JSON_E_RESOURCE_NOT_FOUND,NULL,1);
2051 fossil_exit(0);
2052 }
2053 #endif
2054 fossil_redirect_home() /*does not return*/;
 
 
 
 
2055 }else{
2056 zPath = mprintf("%s", zPathInfo);
2057 }
2058
2059 /* Make g.zPath point to the first element of the path. Make
@@ -2912,10 +2920,23 @@
2912 #if defined(_WIN32)
2913 _setmode(_fileno(stdout), _O_BINARY);
2914 #endif
2915 }
2916 zIpAddr = find_option("ipaddr",0,1);
 
 
 
 
 
 
 
 
 
 
 
 
 
2917 useSCGI = find_option("scgi", 0, 0)!=0;
2918 if( useSCGI ) g.zReqType = "SCGI";
2919 zAltBase = find_option("baseurl", 0, 1);
2920 if( find_option("nodelay",0,0)!=0 ) backoffice_no_delay();
2921 if( zAltBase ) set_base_url(zAltBase);
@@ -3171,10 +3192,11 @@
3171 ** --errorlog FILE Append HTTP error messages to FILE
3172 ** --extroot DIR Document root for the /ext extension mechanism
3173 ** --files GLOBLIST Comma-separated list of glob patterns for static files
3174 ** --fossilcmd PATH The pathname of the "fossil" executable on the remote
3175 ** system when REPOSITORY is remote.
 
3176 ** --localauth Enable automatic login for requests from localhost
3177 ** --localhost Listen on 127.0.0.1 only (always true for "ui")
3178 ** --https Indicates that the input is coming through a reverse
3179 ** proxy that has already translated HTTPS into HTTP.
3180 ** --jsmode MODE Determine how JavaScript is delivered with pages.
@@ -3243,10 +3265,11 @@
3243 const char *zInitPage = 0; /* Start on this page. --page option */
3244 int findServerArg = 2; /* argv index for find_server_repository() */
3245 char *zRemote = 0; /* Remote host on which to run "fossil ui" */
3246 const char *zJsMode; /* The --jsmode parameter */
3247 const char *zFossilCmd =0; /* Name of "fossil" binary on remote system */
 
3248
3249
3250 #if USE_SEE
3251 db_setup_for_saved_encryption_key();
3252 #endif
@@ -3279,13 +3302,21 @@
3279 g.useLocalauth = find_option("localauth", 0, 0)!=0;
3280 Th_InitTraceLog();
3281 zPort = find_option("port", "P", 1);
3282 isUiCmd = g.argv[1][0]=='u';
3283 if( isUiCmd ){
 
 
 
 
 
3284 zInitPage = find_option("page", "p", 1);
3285 if( zInitPage && zInitPage[0]=='/' ) zInitPage++;
3286 zFossilCmd = find_option("fossilcmd", 0, 1);
 
 
 
3287 }
3288 zNotFound = find_option("notfound", 0, 1);
3289 allowRepoList = find_option("repolist",0,0)!=0;
3290 if( find_option("nocompress",0,0)!=0 ) g.fNoHttpCompress = 1;
3291 zAltBase = find_option("baseurl", 0, 1);
@@ -3384,15 +3415,11 @@
3384 }
3385 if( !zRemote ){
3386 find_server_repository(findServerArg, fCreate);
3387 }
3388 if( zInitPage==0 ){
3389 if( isUiCmd && g.localOpen ){
3390 zInitPage = "timeline?c=current";
3391 }else{
3392 zInitPage = "";
3393 }
3394 }
3395 if( zPort ){
3396 if( strchr(zPort,':') ){
3397 int i;
3398 for(i=strlen(zPort)-1; i>=0 && zPort[i]!=':'; i--){}
3399
--- src/main.c
+++ src/main.c
@@ -1330,10 +1330,11 @@
1330
1331 /* We should be done with options.. */
1332 verify_all_options();
1333 fossil_version_blob(&versionInfo, verboseFlag);
1334 fossil_print("%s", blob_str(&versionInfo));
1335 blob_reset(&versionInfo);
1336 }
1337
1338
1339 /*
1340 ** WEBPAGE: version
@@ -1634,11 +1635,11 @@
1635
1636 /*
1637 ** Return true if it is appropriate to redirect requests to HTTPS.
1638 **
1639 ** Redirect to https is appropriate if all of the above are true:
1640 ** (1) The redirect-to-https flag has a value of iLevel or greater.
1641 ** (2) The current connection is http, not https or ssh
1642 ** (3) The sslNotAvailable flag is clear
1643 */
1644 int fossil_wants_https(int iLevel){
1645 if( g.sslNotAvailable ) return 0;
@@ -2040,20 +2041,27 @@
2041 */
2042 set_base_url(0);
2043 if( fossil_redirect_to_https_if_needed(2) ) return;
2044 if( zPathInfo==0 || zPathInfo[0]==0
2045 || (zPathInfo[0]=='/' && zPathInfo[1]==0) ){
2046 /* Second special case: If the PATH_INFO is blank, issue a redirect:
2047 ** (1) to "/ckout" if g.useLocalauth and g.localOpen are both set.
2048 ** (2) to the home page identified by the "index-page" setting
2049 ** in the repository CONFIG table
2050 ** (3) to "/index" if there no "index-page" setting in CONFIG
2051 */
2052 #ifdef FOSSIL_ENABLE_JSON
2053 if(g.json.isJsonMode){
2054 json_err(FSL_JSON_E_RESOURCE_NOT_FOUND,NULL,1);
2055 fossil_exit(0);
2056 }
2057 #endif
2058 if( g.useLocalauth && g.localOpen ){
2059 cgi_redirectf("%R/ckout");
2060 }else{
2061 fossil_redirect_home() /*does not return*/;
2062 }
2063 }else{
2064 zPath = mprintf("%s", zPathInfo);
2065 }
2066
2067 /* Make g.zPath point to the first element of the path. Make
@@ -2912,10 +2920,23 @@
2920 #if defined(_WIN32)
2921 _setmode(_fileno(stdout), _O_BINARY);
2922 #endif
2923 }
2924 zIpAddr = find_option("ipaddr",0,1);
2925 #if defined(_WIN32)
2926 /* The undocumented option "--as NAME" causes NAME to become
2927 ** the fake command name. This only happens on Windows and only
2928 ** if preceded by --in, --out, and --ipaddr. It is a work-around
2929 ** to get the original command-name down into the "http" command that
2930 ** is run in a subprocess to manage HTTP requests on Windows for
2931 ** commands like "fossil ui" and "fossil server".
2932 */
2933 if( zInFile && zOutFile && zIpAddr ){
2934 const char *z = find_option("as",0,1);
2935 if( z ) g.zCmdName = z;
2936 }
2937 #endif
2938 useSCGI = find_option("scgi", 0, 0)!=0;
2939 if( useSCGI ) g.zReqType = "SCGI";
2940 zAltBase = find_option("baseurl", 0, 1);
2941 if( find_option("nodelay",0,0)!=0 ) backoffice_no_delay();
2942 if( zAltBase ) set_base_url(zAltBase);
@@ -3171,10 +3192,11 @@
3192 ** --errorlog FILE Append HTTP error messages to FILE
3193 ** --extroot DIR Document root for the /ext extension mechanism
3194 ** --files GLOBLIST Comma-separated list of glob patterns for static files
3195 ** --fossilcmd PATH The pathname of the "fossil" executable on the remote
3196 ** system when REPOSITORY is remote.
3197 ** --from PATH Use PATH as the diff baseline for the /ckout page
3198 ** --localauth Enable automatic login for requests from localhost
3199 ** --localhost Listen on 127.0.0.1 only (always true for "ui")
3200 ** --https Indicates that the input is coming through a reverse
3201 ** proxy that has already translated HTTPS into HTTP.
3202 ** --jsmode MODE Determine how JavaScript is delivered with pages.
@@ -3243,10 +3265,11 @@
3265 const char *zInitPage = 0; /* Start on this page. --page option */
3266 int findServerArg = 2; /* argv index for find_server_repository() */
3267 char *zRemote = 0; /* Remote host on which to run "fossil ui" */
3268 const char *zJsMode; /* The --jsmode parameter */
3269 const char *zFossilCmd =0; /* Name of "fossil" binary on remote system */
3270 const char *zFrom; /* Value for --from */
3271
3272
3273 #if USE_SEE
3274 db_setup_for_saved_encryption_key();
3275 #endif
@@ -3279,13 +3302,21 @@
3302 g.useLocalauth = find_option("localauth", 0, 0)!=0;
3303 Th_InitTraceLog();
3304 zPort = find_option("port", "P", 1);
3305 isUiCmd = g.argv[1][0]=='u';
3306 if( isUiCmd ){
3307 zFrom = find_option("from", 0, 1);
3308 if( zFrom && zFrom==file_tail(zFrom) ){
3309 fossil_fatal("the argument to --from must be a pathname for"
3310 " the \"ui\" command");
3311 }
3312 zInitPage = find_option("page", "p", 1);
3313 if( zInitPage && zInitPage[0]=='/' ) zInitPage++;
3314 zFossilCmd = find_option("fossilcmd", 0, 1);
3315 if( zFrom && zInitPage==0 ){
3316 zInitPage = mprintf("ckout?exbase=%H", zFrom);
3317 }
3318 }
3319 zNotFound = find_option("notfound", 0, 1);
3320 allowRepoList = find_option("repolist",0,0)!=0;
3321 if( find_option("nocompress",0,0)!=0 ) g.fNoHttpCompress = 1;
3322 zAltBase = find_option("baseurl", 0, 1);
@@ -3384,15 +3415,11 @@
3415 }
3416 if( !zRemote ){
3417 find_server_repository(findServerArg, fCreate);
3418 }
3419 if( zInitPage==0 ){
3420 zInitPage = "";
 
 
 
 
3421 }
3422 if( zPort ){
3423 if( strchr(zPort,':') ){
3424 int i;
3425 for(i=strlen(zPort)-1; i>=0 && zPort[i]!=':'; i--){}
3426
+17 -2
--- src/main.mk
+++ src/main.mk
@@ -99,10 +99,11 @@
9999
$(SRCDIR)/lookslike.c \
100100
$(SRCDIR)/main.c \
101101
$(SRCDIR)/manifest.c \
102102
$(SRCDIR)/markdown.c \
103103
$(SRCDIR)/markdown_html.c \
104
+ $(SRCDIR)/match.c \
104105
$(SRCDIR)/md5.c \
105106
$(SRCDIR)/merge.c \
106107
$(SRCDIR)/merge3.c \
107108
$(SRCDIR)/moderate.c \
108109
$(SRCDIR)/name.c \
@@ -364,10 +365,11 @@
364365
$(OBJDIR)/lookslike_.c \
365366
$(OBJDIR)/main_.c \
366367
$(OBJDIR)/manifest_.c \
367368
$(OBJDIR)/markdown_.c \
368369
$(OBJDIR)/markdown_html_.c \
370
+ $(OBJDIR)/match_.c \
369371
$(OBJDIR)/md5_.c \
370372
$(OBJDIR)/merge_.c \
371373
$(OBJDIR)/merge3_.c \
372374
$(OBJDIR)/moderate_.c \
373375
$(OBJDIR)/name_.c \
@@ -513,10 +515,11 @@
513515
$(OBJDIR)/lookslike.o \
514516
$(OBJDIR)/main.o \
515517
$(OBJDIR)/manifest.o \
516518
$(OBJDIR)/markdown.o \
517519
$(OBJDIR)/markdown_html.o \
520
+ $(OBJDIR)/match.o \
518521
$(OBJDIR)/md5.o \
519522
$(OBJDIR)/merge.o \
520523
$(OBJDIR)/merge3.o \
521524
$(OBJDIR)/moderate.o \
522525
$(OBJDIR)/name.o \
@@ -588,10 +591,11 @@
588591
589592
$(OBJDIR):
590593
-mkdir $(OBJDIR)
591594
592595
$(OBJDIR)/translate: $(SRCDIR_tools)/translate.c
596
+ -mkdir -p $(OBJDIR)
593597
$(XBCC) -o $(OBJDIR)/translate $(SRCDIR_tools)/translate.c
594598
595599
$(OBJDIR)/makeheaders: $(SRCDIR_tools)/makeheaders.c
596600
$(XBCC) -o $(OBJDIR)/makeheaders $(SRCDIR_tools)/makeheaders.c
597601
@@ -644,14 +648,15 @@
644648
-DSQLITE_OMIT_SHARED_CACHE \
645649
-DSQLITE_OMIT_LOAD_EXTENSION \
646650
-DSQLITE_MAX_EXPR_DEPTH=0 \
647651
-DSQLITE_ENABLE_LOCKING_STYLE=0 \
648652
-DSQLITE_DEFAULT_FILE_FORMAT=4 \
653
+ -DSQLITE_ENABLE_DBSTAT_VTAB \
649654
-DSQLITE_ENABLE_EXPLAIN_COMMENTS \
650655
-DSQLITE_ENABLE_FTS4 \
651
- -DSQLITE_ENABLE_DBSTAT_VTAB \
652656
-DSQLITE_ENABLE_FTS5 \
657
+ -DSQLITE_ENABLE_MATH_FUNCTIONS \
653658
-DSQLITE_ENABLE_STMTVTAB \
654659
-DSQLITE_HAVE_ZLIB \
655660
-DSQLITE_ENABLE_DBPAGE_VTAB \
656661
-DSQLITE_TRUSTED_SCHEMA=0 \
657662
-DHAVE_USLEEP
@@ -669,14 +674,15 @@
669674
-DSQLITE_OMIT_SHARED_CACHE \
670675
-DSQLITE_OMIT_LOAD_EXTENSION \
671676
-DSQLITE_MAX_EXPR_DEPTH=0 \
672677
-DSQLITE_ENABLE_LOCKING_STYLE=0 \
673678
-DSQLITE_DEFAULT_FILE_FORMAT=4 \
679
+ -DSQLITE_ENABLE_DBSTAT_VTAB \
674680
-DSQLITE_ENABLE_EXPLAIN_COMMENTS \
675681
-DSQLITE_ENABLE_FTS4 \
676
- -DSQLITE_ENABLE_DBSTAT_VTAB \
677682
-DSQLITE_ENABLE_FTS5 \
683
+ -DSQLITE_ENABLE_MATH_FUNCTIONS \
678684
-DSQLITE_ENABLE_STMTVTAB \
679685
-DSQLITE_HAVE_ZLIB \
680686
-DSQLITE_ENABLE_DBPAGE_VTAB \
681687
-DSQLITE_TRUSTED_SCHEMA=0 \
682688
-DHAVE_USLEEP \
@@ -848,10 +854,11 @@
848854
$(OBJDIR)/lookslike_.c:$(OBJDIR)/lookslike.h \
849855
$(OBJDIR)/main_.c:$(OBJDIR)/main.h \
850856
$(OBJDIR)/manifest_.c:$(OBJDIR)/manifest.h \
851857
$(OBJDIR)/markdown_.c:$(OBJDIR)/markdown.h \
852858
$(OBJDIR)/markdown_html_.c:$(OBJDIR)/markdown_html.h \
859
+ $(OBJDIR)/match_.c:$(OBJDIR)/match.h \
853860
$(OBJDIR)/md5_.c:$(OBJDIR)/md5.h \
854861
$(OBJDIR)/merge_.c:$(OBJDIR)/merge.h \
855862
$(OBJDIR)/merge3_.c:$(OBJDIR)/merge3.h \
856863
$(OBJDIR)/moderate_.c:$(OBJDIR)/moderate.h \
857864
$(OBJDIR)/name_.c:$(OBJDIR)/name.h \
@@ -1597,10 +1604,18 @@
15971604
15981605
$(OBJDIR)/markdown_html.o: $(OBJDIR)/markdown_html_.c $(OBJDIR)/markdown_html.h $(SRCDIR)/config.h
15991606
$(XTCC) -o $(OBJDIR)/markdown_html.o -c $(OBJDIR)/markdown_html_.c
16001607
16011608
$(OBJDIR)/markdown_html.h: $(OBJDIR)/headers
1609
+
1610
+$(OBJDIR)/match_.c: $(SRCDIR)/match.c $(OBJDIR)/translate
1611
+ $(OBJDIR)/translate $(SRCDIR)/match.c >$@
1612
+
1613
+$(OBJDIR)/match.o: $(OBJDIR)/match_.c $(OBJDIR)/match.h $(SRCDIR)/config.h
1614
+ $(XTCC) -o $(OBJDIR)/match.o -c $(OBJDIR)/match_.c
1615
+
1616
+$(OBJDIR)/match.h: $(OBJDIR)/headers
16021617
16031618
$(OBJDIR)/md5_.c: $(SRCDIR)/md5.c $(OBJDIR)/translate
16041619
$(OBJDIR)/translate $(SRCDIR)/md5.c >$@
16051620
16061621
$(OBJDIR)/md5.o: $(OBJDIR)/md5_.c $(OBJDIR)/md5.h $(SRCDIR)/config.h
16071622
--- src/main.mk
+++ src/main.mk
@@ -99,10 +99,11 @@
99 $(SRCDIR)/lookslike.c \
100 $(SRCDIR)/main.c \
101 $(SRCDIR)/manifest.c \
102 $(SRCDIR)/markdown.c \
103 $(SRCDIR)/markdown_html.c \
 
104 $(SRCDIR)/md5.c \
105 $(SRCDIR)/merge.c \
106 $(SRCDIR)/merge3.c \
107 $(SRCDIR)/moderate.c \
108 $(SRCDIR)/name.c \
@@ -364,10 +365,11 @@
364 $(OBJDIR)/lookslike_.c \
365 $(OBJDIR)/main_.c \
366 $(OBJDIR)/manifest_.c \
367 $(OBJDIR)/markdown_.c \
368 $(OBJDIR)/markdown_html_.c \
 
369 $(OBJDIR)/md5_.c \
370 $(OBJDIR)/merge_.c \
371 $(OBJDIR)/merge3_.c \
372 $(OBJDIR)/moderate_.c \
373 $(OBJDIR)/name_.c \
@@ -513,10 +515,11 @@
513 $(OBJDIR)/lookslike.o \
514 $(OBJDIR)/main.o \
515 $(OBJDIR)/manifest.o \
516 $(OBJDIR)/markdown.o \
517 $(OBJDIR)/markdown_html.o \
 
518 $(OBJDIR)/md5.o \
519 $(OBJDIR)/merge.o \
520 $(OBJDIR)/merge3.o \
521 $(OBJDIR)/moderate.o \
522 $(OBJDIR)/name.o \
@@ -588,10 +591,11 @@
588
589 $(OBJDIR):
590 -mkdir $(OBJDIR)
591
592 $(OBJDIR)/translate: $(SRCDIR_tools)/translate.c
 
593 $(XBCC) -o $(OBJDIR)/translate $(SRCDIR_tools)/translate.c
594
595 $(OBJDIR)/makeheaders: $(SRCDIR_tools)/makeheaders.c
596 $(XBCC) -o $(OBJDIR)/makeheaders $(SRCDIR_tools)/makeheaders.c
597
@@ -644,14 +648,15 @@
644 -DSQLITE_OMIT_SHARED_CACHE \
645 -DSQLITE_OMIT_LOAD_EXTENSION \
646 -DSQLITE_MAX_EXPR_DEPTH=0 \
647 -DSQLITE_ENABLE_LOCKING_STYLE=0 \
648 -DSQLITE_DEFAULT_FILE_FORMAT=4 \
 
649 -DSQLITE_ENABLE_EXPLAIN_COMMENTS \
650 -DSQLITE_ENABLE_FTS4 \
651 -DSQLITE_ENABLE_DBSTAT_VTAB \
652 -DSQLITE_ENABLE_FTS5 \
 
653 -DSQLITE_ENABLE_STMTVTAB \
654 -DSQLITE_HAVE_ZLIB \
655 -DSQLITE_ENABLE_DBPAGE_VTAB \
656 -DSQLITE_TRUSTED_SCHEMA=0 \
657 -DHAVE_USLEEP
@@ -669,14 +674,15 @@
669 -DSQLITE_OMIT_SHARED_CACHE \
670 -DSQLITE_OMIT_LOAD_EXTENSION \
671 -DSQLITE_MAX_EXPR_DEPTH=0 \
672 -DSQLITE_ENABLE_LOCKING_STYLE=0 \
673 -DSQLITE_DEFAULT_FILE_FORMAT=4 \
 
674 -DSQLITE_ENABLE_EXPLAIN_COMMENTS \
675 -DSQLITE_ENABLE_FTS4 \
676 -DSQLITE_ENABLE_DBSTAT_VTAB \
677 -DSQLITE_ENABLE_FTS5 \
 
678 -DSQLITE_ENABLE_STMTVTAB \
679 -DSQLITE_HAVE_ZLIB \
680 -DSQLITE_ENABLE_DBPAGE_VTAB \
681 -DSQLITE_TRUSTED_SCHEMA=0 \
682 -DHAVE_USLEEP \
@@ -848,10 +854,11 @@
848 $(OBJDIR)/lookslike_.c:$(OBJDIR)/lookslike.h \
849 $(OBJDIR)/main_.c:$(OBJDIR)/main.h \
850 $(OBJDIR)/manifest_.c:$(OBJDIR)/manifest.h \
851 $(OBJDIR)/markdown_.c:$(OBJDIR)/markdown.h \
852 $(OBJDIR)/markdown_html_.c:$(OBJDIR)/markdown_html.h \
 
853 $(OBJDIR)/md5_.c:$(OBJDIR)/md5.h \
854 $(OBJDIR)/merge_.c:$(OBJDIR)/merge.h \
855 $(OBJDIR)/merge3_.c:$(OBJDIR)/merge3.h \
856 $(OBJDIR)/moderate_.c:$(OBJDIR)/moderate.h \
857 $(OBJDIR)/name_.c:$(OBJDIR)/name.h \
@@ -1597,10 +1604,18 @@
1597
1598 $(OBJDIR)/markdown_html.o: $(OBJDIR)/markdown_html_.c $(OBJDIR)/markdown_html.h $(SRCDIR)/config.h
1599 $(XTCC) -o $(OBJDIR)/markdown_html.o -c $(OBJDIR)/markdown_html_.c
1600
1601 $(OBJDIR)/markdown_html.h: $(OBJDIR)/headers
 
 
 
 
 
 
 
 
1602
1603 $(OBJDIR)/md5_.c: $(SRCDIR)/md5.c $(OBJDIR)/translate
1604 $(OBJDIR)/translate $(SRCDIR)/md5.c >$@
1605
1606 $(OBJDIR)/md5.o: $(OBJDIR)/md5_.c $(OBJDIR)/md5.h $(SRCDIR)/config.h
1607
--- src/main.mk
+++ src/main.mk
@@ -99,10 +99,11 @@
99 $(SRCDIR)/lookslike.c \
100 $(SRCDIR)/main.c \
101 $(SRCDIR)/manifest.c \
102 $(SRCDIR)/markdown.c \
103 $(SRCDIR)/markdown_html.c \
104 $(SRCDIR)/match.c \
105 $(SRCDIR)/md5.c \
106 $(SRCDIR)/merge.c \
107 $(SRCDIR)/merge3.c \
108 $(SRCDIR)/moderate.c \
109 $(SRCDIR)/name.c \
@@ -364,10 +365,11 @@
365 $(OBJDIR)/lookslike_.c \
366 $(OBJDIR)/main_.c \
367 $(OBJDIR)/manifest_.c \
368 $(OBJDIR)/markdown_.c \
369 $(OBJDIR)/markdown_html_.c \
370 $(OBJDIR)/match_.c \
371 $(OBJDIR)/md5_.c \
372 $(OBJDIR)/merge_.c \
373 $(OBJDIR)/merge3_.c \
374 $(OBJDIR)/moderate_.c \
375 $(OBJDIR)/name_.c \
@@ -513,10 +515,11 @@
515 $(OBJDIR)/lookslike.o \
516 $(OBJDIR)/main.o \
517 $(OBJDIR)/manifest.o \
518 $(OBJDIR)/markdown.o \
519 $(OBJDIR)/markdown_html.o \
520 $(OBJDIR)/match.o \
521 $(OBJDIR)/md5.o \
522 $(OBJDIR)/merge.o \
523 $(OBJDIR)/merge3.o \
524 $(OBJDIR)/moderate.o \
525 $(OBJDIR)/name.o \
@@ -588,10 +591,11 @@
591
592 $(OBJDIR):
593 -mkdir $(OBJDIR)
594
595 $(OBJDIR)/translate: $(SRCDIR_tools)/translate.c
596 -mkdir -p $(OBJDIR)
597 $(XBCC) -o $(OBJDIR)/translate $(SRCDIR_tools)/translate.c
598
599 $(OBJDIR)/makeheaders: $(SRCDIR_tools)/makeheaders.c
600 $(XBCC) -o $(OBJDIR)/makeheaders $(SRCDIR_tools)/makeheaders.c
601
@@ -644,14 +648,15 @@
648 -DSQLITE_OMIT_SHARED_CACHE \
649 -DSQLITE_OMIT_LOAD_EXTENSION \
650 -DSQLITE_MAX_EXPR_DEPTH=0 \
651 -DSQLITE_ENABLE_LOCKING_STYLE=0 \
652 -DSQLITE_DEFAULT_FILE_FORMAT=4 \
653 -DSQLITE_ENABLE_DBSTAT_VTAB \
654 -DSQLITE_ENABLE_EXPLAIN_COMMENTS \
655 -DSQLITE_ENABLE_FTS4 \
 
656 -DSQLITE_ENABLE_FTS5 \
657 -DSQLITE_ENABLE_MATH_FUNCTIONS \
658 -DSQLITE_ENABLE_STMTVTAB \
659 -DSQLITE_HAVE_ZLIB \
660 -DSQLITE_ENABLE_DBPAGE_VTAB \
661 -DSQLITE_TRUSTED_SCHEMA=0 \
662 -DHAVE_USLEEP
@@ -669,14 +674,15 @@
674 -DSQLITE_OMIT_SHARED_CACHE \
675 -DSQLITE_OMIT_LOAD_EXTENSION \
676 -DSQLITE_MAX_EXPR_DEPTH=0 \
677 -DSQLITE_ENABLE_LOCKING_STYLE=0 \
678 -DSQLITE_DEFAULT_FILE_FORMAT=4 \
679 -DSQLITE_ENABLE_DBSTAT_VTAB \
680 -DSQLITE_ENABLE_EXPLAIN_COMMENTS \
681 -DSQLITE_ENABLE_FTS4 \
 
682 -DSQLITE_ENABLE_FTS5 \
683 -DSQLITE_ENABLE_MATH_FUNCTIONS \
684 -DSQLITE_ENABLE_STMTVTAB \
685 -DSQLITE_HAVE_ZLIB \
686 -DSQLITE_ENABLE_DBPAGE_VTAB \
687 -DSQLITE_TRUSTED_SCHEMA=0 \
688 -DHAVE_USLEEP \
@@ -848,10 +854,11 @@
854 $(OBJDIR)/lookslike_.c:$(OBJDIR)/lookslike.h \
855 $(OBJDIR)/main_.c:$(OBJDIR)/main.h \
856 $(OBJDIR)/manifest_.c:$(OBJDIR)/manifest.h \
857 $(OBJDIR)/markdown_.c:$(OBJDIR)/markdown.h \
858 $(OBJDIR)/markdown_html_.c:$(OBJDIR)/markdown_html.h \
859 $(OBJDIR)/match_.c:$(OBJDIR)/match.h \
860 $(OBJDIR)/md5_.c:$(OBJDIR)/md5.h \
861 $(OBJDIR)/merge_.c:$(OBJDIR)/merge.h \
862 $(OBJDIR)/merge3_.c:$(OBJDIR)/merge3.h \
863 $(OBJDIR)/moderate_.c:$(OBJDIR)/moderate.h \
864 $(OBJDIR)/name_.c:$(OBJDIR)/name.h \
@@ -1597,10 +1604,18 @@
1604
1605 $(OBJDIR)/markdown_html.o: $(OBJDIR)/markdown_html_.c $(OBJDIR)/markdown_html.h $(SRCDIR)/config.h
1606 $(XTCC) -o $(OBJDIR)/markdown_html.o -c $(OBJDIR)/markdown_html_.c
1607
1608 $(OBJDIR)/markdown_html.h: $(OBJDIR)/headers
1609
1610 $(OBJDIR)/match_.c: $(SRCDIR)/match.c $(OBJDIR)/translate
1611 $(OBJDIR)/translate $(SRCDIR)/match.c >$@
1612
1613 $(OBJDIR)/match.o: $(OBJDIR)/match_.c $(OBJDIR)/match.h $(SRCDIR)/config.h
1614 $(XTCC) -o $(OBJDIR)/match.o -c $(OBJDIR)/match_.c
1615
1616 $(OBJDIR)/match.h: $(OBJDIR)/headers
1617
1618 $(OBJDIR)/md5_.c: $(SRCDIR)/md5.c $(OBJDIR)/translate
1619 $(OBJDIR)/translate $(SRCDIR)/md5.c >$@
1620
1621 $(OBJDIR)/md5.o: $(OBJDIR)/md5_.c $(OBJDIR)/md5.h $(SRCDIR)/config.h
1622
+7 -3
--- src/manifest.c
+++ src/manifest.c
@@ -318,18 +318,22 @@
318318
*/
319319
static void remove_pgp_signature(const char **pz, int *pn){
320320
const char *z = *pz;
321321
int n = *pn;
322322
int i;
323
- if( strncmp(z, "-----BEGIN PGP SIGNED MESSAGE-----", 34)!=0 ) return;
324
- for(i=34; i<n && !after_blank_line(z+i); i++){}
323
+ if( strncmp(z, "-----BEGIN PGP SIGNED MESSAGE-----", 34)==0 ) i = 34;
324
+ else if( strncmp(z, "-----BEGIN SSH SIGNED MESSAGE-----", 34)==0 ) i = 34;
325
+ else return;
326
+ for(; i<n && !after_blank_line(z+i); i++){}
325327
if( i>=n ) return;
326328
z += i;
327329
n -= i;
328330
*pz = z;
329331
for(i=n-1; i>=0; i--){
330
- if( z[i]=='\n' && strncmp(&z[i],"\n-----BEGIN PGP SIGNATURE-", 25)==0 ){
332
+ if( z[i]=='\n' &&
333
+ (strncmp(&z[i],"\n-----BEGIN PGP SIGNATURE-----", 29)==0
334
+ || strncmp(&z[i],"\n-----BEGIN SSH SIGNATURE-----", 29)==0 )){
331335
n = i+1;
332336
break;
333337
}
334338
}
335339
*pn = n;
336340
337341
ADDED src/match.c
--- src/manifest.c
+++ src/manifest.c
@@ -318,18 +318,22 @@
318 */
319 static void remove_pgp_signature(const char **pz, int *pn){
320 const char *z = *pz;
321 int n = *pn;
322 int i;
323 if( strncmp(z, "-----BEGIN PGP SIGNED MESSAGE-----", 34)!=0 ) return;
324 for(i=34; i<n && !after_blank_line(z+i); i++){}
 
 
325 if( i>=n ) return;
326 z += i;
327 n -= i;
328 *pz = z;
329 for(i=n-1; i>=0; i--){
330 if( z[i]=='\n' && strncmp(&z[i],"\n-----BEGIN PGP SIGNATURE-", 25)==0 ){
 
 
331 n = i+1;
332 break;
333 }
334 }
335 *pn = n;
336
337 DDED src/match.c
--- src/manifest.c
+++ src/manifest.c
@@ -318,18 +318,22 @@
318 */
319 static void remove_pgp_signature(const char **pz, int *pn){
320 const char *z = *pz;
321 int n = *pn;
322 int i;
323 if( strncmp(z, "-----BEGIN PGP SIGNED MESSAGE-----", 34)==0 ) i = 34;
324 else if( strncmp(z, "-----BEGIN SSH SIGNED MESSAGE-----", 34)==0 ) i = 34;
325 else return;
326 for(; i<n && !after_blank_line(z+i); i++){}
327 if( i>=n ) return;
328 z += i;
329 n -= i;
330 *pz = z;
331 for(i=n-1; i>=0; i--){
332 if( z[i]=='\n' &&
333 (strncmp(&z[i],"\n-----BEGIN PGP SIGNATURE-----", 29)==0
334 || strncmp(&z[i],"\n-----BEGIN SSH SIGNATURE-----", 29)==0 )){
335 n = i+1;
336 break;
337 }
338 }
339 *pn = n;
340
341 DDED src/match.c
+386
--- a/src/match.c
+++ b/src/match.c
@@ -0,0 +1,386 @@
1
+/*
2
+** Copyright (c) 2007 D. Richard Hipp
3
+**
4
+** This program is free software; you can redistribute it and/or
5
+** modify it under the terms of the Simplified BSD License (also
6
+** known as the "2-Clause License" or "FreeBSD License".)
7
+
8
+** This program is distributed in the hope that it will be useful,
9
+** but without any warranty; without even the implied warranty of
10
+** merchantability or fitness for a particular purpose.
11
+**
12
+** Author contact information:
13
+** [email protected]
14
+** http://www.hwaci.com/drh/
15
+**
16
+*******************************************************************************
17
+**
18
+** This file contains code to implement string comparisons using a
19
+** variety of algorithm. The comparison algorithm can be any of:
20
+**
21
+** MS_EXACT The string must exactly match the pattern.
22
+**
23
+** MS_BRLIST The pattern is a space- and/or comma-separated
24
+** list of strings, any one of which may match
25
+** the input string.
26
+**
27
+** MS_GLOB Like BRLIST, except each component of the pattern
28
+** is a GLOB expression.
29
+**
30
+** MS_LIKE Like BRLIST, except each component of the pattern
31
+** is an SQL LIKE expression.
32
+**
33
+** MS_REGEXP Like BRLIST, except each component of the pattern
34
+** is a regular expression.
35
+**
36
+*/
37
+#include "config.h"
38
+#include <string.h>
39
+#include "match.h"
40
+
41
+#if INTERFACE
42
+/*
43
+** Types of comparisons that we are able to perform:
44
+*/
45
+typedef enum {
46
+ MS_EXACT=1, /* Exact string comparison */
47
+ MS_GLOB=2, /* Matches against a list of GLOB patterns. */
48
+ MS_LIKE=3, /* Matches against a list of LIKE patterns. */
49
+ MS_REGEXP=4, /* Matches against a list of regular expressions. */
50
+ MS_BRLIST=5, /* Matches any element of a list */
51
+} MatchStyle;
52
+
53
+/*
54
+** The following object represents a precompiled pattern to use for
55
+** string matching.
56
+**
57
+** * Create an instance of this object using match_create().
58
+** * Do comparisons using match_text().
59
+** * Destroy using match_free() when you are done.
60
+**
61
+*/
62
+struct Matcher {
63
+ MatchStyle style; /* Which algorithm to use */
64
+ int nPattern; /* How many patterns are their */
65
+ char **azPattern; /* List of patterns */
66
+ ReCompiled **aRe; /* List of compiled regular expressions */
67
+};
68
+
69
+#endif /*INTERFACE*/
70
+
71
+/*
72
+** Translate a "match style" text name into the MS_* enum value.
73
+** Return eDflt if no match is found.
74
+*/
75
+MatchStyle match_style(const char *zStyle, MatchStyle eDflt){
76
+ if( zStyle==0 ) return eDflt;
77
+ if( fossil_stricmp(zStyle, "brlist")==0 ) return MS_BRLIST;
78
+ if( fossil_stricmp(zStyle, "list")==0 ) return MS_BRLIST;
79
+ if( fossil_stricmp(zStyle, "regexp")==0 ) return MS_REGEXP;
80
+ if( fossil_stricmp(zStyle, "re")==0 ) return MS_REGEXP;
81
+ if( fossil_stricmp(zStyle, "glob")==0 ) return MS_GLOB;
82
+ if( fossil_stricmp(zStyle, "like")==0 ) return MS_LIKE;
83
+ if( fossil_stricmp(zStyle, "exact")==0 ) return MS_EXACT;
84
+ return eDflt;
85
+}
86
+
87
+
88
+/*
89
+** Create a new Matcher object using the pattern provided.
90
+*/
91
+Matcher *match_create(MatchStyle style, const char *zPat){
92
+ char cDel; /* Delimiter character */
93
+ int i; /* Loop counter */
94
+ Matcher *p; /* The new Matcher to be constructed */
95
+ char *zOne; /* One element of the pattern */
96
+
97
+ if( zPat==0 ) return 0;
98
+ p = fossil_malloc( sizeof(*p) );
99
+ memset(p, 0, sizeof(*p));
100
+ p->style = style;
101
+
102
+ if( style==MS_EXACT ){
103
+ p->nPattern = 1;
104
+ p->azPattern = fossil_malloc( sizeof(p->azPattern[0]) );
105
+ p->azPattern[0] = fossil_strdup(zPat);
106
+ return p;
107
+ }
108
+
109
+ while( 1 ){
110
+ /* Skip leading delimiters. */
111
+ for( ; fossil_isspace(*zPat) || *zPat==','; ++zPat );
112
+
113
+ /* Next non-delimiter character determines quoting. */
114
+ if( zPat[0]==0 ){
115
+ /* Terminate loop at end of string. */
116
+ break;
117
+ }else if( zPat[0]=='\'' || zPat[0]=='"' ){
118
+ /* If word is quoted, prepare to stop at end quote. */
119
+ cDel = zPat[0];
120
+ ++zPat;
121
+ }else{
122
+ /* If word is not quoted, prepare to stop at delimiter. */
123
+ cDel = ',';
124
+ }
125
+
126
+ /* Find the next delimiter character or end of string. */
127
+ for( i=0; zPat[i] && zPat[i]!=cDel; ++i ){
128
+ /* If delimiter is comma, also recognize spaces as delimiters. */
129
+ if( cDel==',' && fossil_isspace(zPat[i]) ){
130
+ break;
131
+ }
132
+
133
+ /* In regexp mode, ignore delimiters following backslashes. */
134
+ if( style==MS_REGEXP && zPat[i]=='\\' && zPat[i+1] ){
135
+ ++i;
136
+ }
137
+ }
138
+
139
+ /* zOne is a zero-terminated copy of the pattern, without delimiters */
140
+ zOne = fossil_strndup(zPat, i);
141
+ zPat += i;
142
+ if( zPat[0] ) zPat++;
143
+
144
+ /* Check for regular expression syntax errors. */
145
+ if( style==MS_REGEXP ){
146
+ ReCompiled *regexp;
147
+ const char *zFail = re_compile(&regexp, zOne, 0);
148
+ if( zFail ){
149
+ re_free(regexp);
150
+ continue;
151
+ }
152
+ p->nPattern++;
153
+ p->aRe = fossil_realloc(p->aRe, sizeof(p->aRe)*p->nPattern);
154
+ p->aRe[p->nPattern-1] = regexp;
155
+ fossil_free(zOne);
156
+ }else{
157
+ p->nPattern++;
158
+ p->azPattern = fossil_realloc(p->azPattern, sizeof(char*)*p->nPattern);
159
+ p->azPattern[p->nPattern-1] = zOne;
160
+ }
161
+ }
162
+ return p;
163
+}
164
+
165
+/*
166
+** Return non-zero (true) if the input string matches the pattern
167
+** described by the matcher.
168
+**
169
+** The return value is really the 1-based index of the particular
170
+** pattern that matched.
171
+*/
172
+int match_text(Matcher *p, const char *zText){
173
+ int i;
174
+ if( p==0 ){
175
+ return zText==0;
176
+ }
177
+ switch( p->style ){
178
+ case MS_BRLIST:
179
+ case MS_EXACT: {
180
+ for(i=0; i<p->nPattern; i++){
181
+ if( strcmp(p->azPattern[i], zText)==0 ) return i+1;
182
+ }
183
+ break;
184
+ }
185
+ case MS_GLOB: {
186
+ for(i=0; i<p->nPattern; i++){
187
+ if( sqlite3_strglob(p->azPattern[i], zText)==0 ) return i+1;
188
+ }
189
+ break;
190
+ }
191
+ case MS_LIKE: {
192
+ for(i=0; i<p->nPattern; i++){
193
+ if( sqlite3_strlike(p->azPattern[i], zText, 0)==0 ) return i+1;
194
+ }
195
+ break;
196
+ }
197
+ case MS_REGEXP: {
198
+ int nText = (int)strlen(zText);
199
+ for(i=0; i<p->nPattern; i++){
200
+ if( re_match(p->aRe[i], (const u8*)zText, nText) ) return i+1;
201
+ }
202
+ break;
203
+ }
204
+ }
205
+ return 0n 0;
206
+}
207
+
208
+
209
+/*
210
+** Destroy a previously allocated Matcher object.
211
+*/
212
+void match_free(Matcher *p){
213
+ int i;
214
+ if( p==0 ) return;
215
+ if( p->style==MS_REGEXP ){
216
+ for(i=0; i<p->nPattern; i++) re_free(p->aRe[i]);
217
+ fossil_free(p->aRe);
218
+ }else{
219
+ for(i=0; i<p->nPattern; i++) fossil_free(p->azPattern[i]);
220
+ fossil_free(p->azPattern);
221
+ }
222
+ memset(p, 0, sizeof(*p));
223
+ fossil_free(p);
224
+}
225
+
226
+
227
+
228
+/*
229
+** Quote a tag string by surrounding it with double quotes and preceding
230
+** internal double quotes and backslashes with backslashes.
231
+*/
232
+static const char *tagQuote(
233
+ int len, /* Maximum length of zTag, or negative for unlimited */
234
+ const char *zTag /* Tag string */
235
+){
236
+ Blob blob = BLOB_INITIALIZER;
237
+ int i, j;
238
+ blob_zero(&blob);
239
+ blob_append(&blob, "\"", 1);
240
+ for( i=j=0; zTag[j] && (len<0 || j<len); ++j ){
241
+ if( zTag[j]=='\"' || zTag[j]=='\\' ){
242
+ if( j>i ){
243
+ blob_append(&blob, zTag+i, j-i);
244
+ }
245
+ blob_append(&blob, "\\", 1);
246
+ i = j;
247
+ }
248
+ }
249
+ if( j>i ){
250
+ blob_append(&blob, zTag+i, j-i);
251
+ }
252
+ blob_append(&blob, "\"", 1);
253
+ return blob_str(&blob);
254
+}
255
+
256
+/*
257
+** Construct the SQL expression that goes into the WHERE clause of a join
258
+** that involves the TAG table and that selects a particular tag out of
259
+** that table.
260
+**
261
+** This function is adapted from glob_expr() to support the MS_EXACT, MS_GLOB,
262
+** MS_LIKE, MS_REGEXP, and MS_BRLIST match styles.
263
+**
264
+** For MS_EXACT, the returned expression
265
+** checks for integer match against the tag ID which is looked up directly by
266
+** this function. For the other modes, the returned SQL expression performs
267
+** string comparisons against the tag names, so it is necessary to join against
268
+** the tag table to access the "tagname" column.
269
+**
270
+** Each pattern is adjusted to start with "sym-" and be anchored at end.
271
+**
272
+** In MS_REGEXP mode, backslash can be used to protect delimiter characters.
273
+** The backslashes are not removed from the regular expression.
274
+**
275
+** In addition to assembling and returning an SQL expression, this function
276
+** makes an English-language description of the patterns being matched, suitable
277
+** for display in the web interface.
278
+**
279
+** If any errors arise during processing, *zError is set to an error message.
280
+** Otherwise it is set to NULL.
281
+*/
282
+const char *match_tag_sqlexpr(
283
+ MatchStyle matchStyle, /* Match style code */
284
+ const char *zTag, /* Tag name, match pattern, or pattern list */
285
+ const char **zDesc, /* Output expression description string */
286
+ const char **zError /* Output error string */
287
+){
288
+ Blob expr = BLOB_INITIALIZER; /* SQL expression string assembly buffer */
289
+ Blob desc = BLOB_INITIALIZER; /* English description of match patterns */
290
+ Blob err = BLOB_INITIALIZER; /* Error text assembly buffer */
291
+ const char *zStart; /* Text at start of expression */
292
+ const char *zDelimiter; /* Text between expression terms */
293
+ const char *zEnd; /* Text at end of expression */
294
+ const char *zPrefix; /* Text before each match pattern */
295
+ const char *zSuffix; /* Text after each match pattern */
296
+ const char *zIntro; /* Text introducing pattern description */
297
+ const char *zPattern = 0; /* Previous quoted pattern */
298
+ const char *zFail = 0; /* Current failure message or NULL if okay */
299
+ const char *zOr = " or "; /* Text before final quoted pattern */
300
+ char cDel; /* Input delimiter character */
301
+ int i; /* Input match pattern length counter */
302
+
303
+ /* Optimize exact matches by looking up the ID in advance to create a simple
304
+ * numeric comparison. Bypass the remainder of this function. */
305
+ if( matchStyle==MS_EXACT ){
306
+ *zDesc = tagQuote(-1, zTag);
307
+ return mprintf("(tagid=%d)", db_int(-1,
308
+ "SELECT tagid FROM tag WHERE tagname='sym-%q'", zTag));
309
+ }
310
+
311
+ /* Decide pattern prefix and suffix strings according to match style. */
312
+ if( matchStyle==MS_GLOB ){
313
+ zStart = "(";
314
+ zDelimiter = " OR ";
315
+ zEnd = ")";
316
+ zPrefix = "tagname GLOB 'sym-";
317
+ zSuffix = "'";
318
+ zIntro = "glob pattern ";
319
+ }else irt = "(";
320
+ zDelimiter = " OR ";
321
+ zEnd = ")";
322
+ zPrefix = "tagname LIKE 'sym-";
323
+ zSuffix = "'";
324
+ zIntro = "SQL LIKE pattern ";
325
+ }else if( matchStyle==MS_REGEXP ){
326
+ zStart = "(tagname REGEXP '^sym-(";
327
+ zDelimiter = "|";
328
+ zEnd = ")$')";
329
+ zPrefix = "";
330
+ zSuffix = "";
331
+ zIntro = "regular expression ";
332
+ }else/* if( matchStyle==MS_BRLIST )*/{
333
+ zStart = "tagname IN ('sym-";
334
+ zDelimiter = "','sym-";
335
+ zEnd = "')";
336
+ zPrefix = "";
337
+ zSuffix = "";
338
+ zIntro = "";
339
+ }
340
+
341
+ /* Convert the list of matches into an SQL expression and text description. */
342
+ blob_zero(&expr);
343
+ blob_zero(&desc);
344
+ blob_zero(&err);
345
+ while( 1 ){
346
+ /* Skip leading delimiters. */
347
+ for( ; fossil_isspace(*zTag) || *zTag==','; ++zTag );
348
+
349
+ /* Next non-delimiter character determines quoting. */
350
+ if( !*zTag ){
351
+ /* Terminate loop at end of string. */
352
+ break;
353
+ }else if( *zTag=='\'' || *zTag=='"' ){
354
+ /* If word is quoted, prepare to stop at end quote. */
355
+ cDel = *zTag;
356
+ ++zTag;
357
+ }else{
358
+ /* If word is not quoted, prepare to stop at delimiter. */
359
+ cDel = ',';
360
+ }
361
+
362
+ /* Find the next delimiter character or end of string. */
363
+ for( i=0; zTag[i] && zTag[i]!=cDel; ++i ){
364
+ /* If delimiter is comma, also recognize spaces as delimiters. */
365
+ if( cDel==',' && fossil_isspace(zTag[i]) ){
366
+ break;
367
+ }
368
+
369
+ /* In regexp mode, ignore delimiters following backslashes. */
370
+ if( matchStyle==MS_REGEXP && zTag[i]=='\\' && zTag[i+1] ){
371
+ ++i;
372
+ }
373
+ }
374
+
375
+ /* Check for regular expression syntax errors. */
376
+ if( matchStyle==MS_REGEXP ){
377
+ ReCompiled *regexp;
378
+ char *zTagDup = fossil_strndup(zTag, i);
379
+ zFail = fossil_re_compile(&regexp, zTagDup, 0);
380
+ re_free(regexp);
381
+ fossil_free(zTagDup);
382
+ }
383
+
384
+ /* Process success and error results. */
385
+ if( !zFail ){
386
+ /* Incorporate
--- a/src/match.c
+++ b/src/match.c
@@ -0,0 +1,386 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
--- a/src/match.c
+++ b/src/match.c
@@ -0,0 +1,386 @@
1 /*
2 ** Copyright (c) 2007 D. Richard Hipp
3 **
4 ** This program is free software; you can redistribute it and/or
5 ** modify it under the terms of the Simplified BSD License (also
6 ** known as the "2-Clause License" or "FreeBSD License".)
7
8 ** This program is distributed in the hope that it will be useful,
9 ** but without any warranty; without even the implied warranty of
10 ** merchantability or fitness for a particular purpose.
11 **
12 ** Author contact information:
13 ** [email protected]
14 ** http://www.hwaci.com/drh/
15 **
16 *******************************************************************************
17 **
18 ** This file contains code to implement string comparisons using a
19 ** variety of algorithm. The comparison algorithm can be any of:
20 **
21 ** MS_EXACT The string must exactly match the pattern.
22 **
23 ** MS_BRLIST The pattern is a space- and/or comma-separated
24 ** list of strings, any one of which may match
25 ** the input string.
26 **
27 ** MS_GLOB Like BRLIST, except each component of the pattern
28 ** is a GLOB expression.
29 **
30 ** MS_LIKE Like BRLIST, except each component of the pattern
31 ** is an SQL LIKE expression.
32 **
33 ** MS_REGEXP Like BRLIST, except each component of the pattern
34 ** is a regular expression.
35 **
36 */
37 #include "config.h"
38 #include <string.h>
39 #include "match.h"
40
41 #if INTERFACE
42 /*
43 ** Types of comparisons that we are able to perform:
44 */
45 typedef enum {
46 MS_EXACT=1, /* Exact string comparison */
47 MS_GLOB=2, /* Matches against a list of GLOB patterns. */
48 MS_LIKE=3, /* Matches against a list of LIKE patterns. */
49 MS_REGEXP=4, /* Matches against a list of regular expressions. */
50 MS_BRLIST=5, /* Matches any element of a list */
51 } MatchStyle;
52
53 /*
54 ** The following object represents a precompiled pattern to use for
55 ** string matching.
56 **
57 ** * Create an instance of this object using match_create().
58 ** * Do comparisons using match_text().
59 ** * Destroy using match_free() when you are done.
60 **
61 */
62 struct Matcher {
63 MatchStyle style; /* Which algorithm to use */
64 int nPattern; /* How many patterns are their */
65 char **azPattern; /* List of patterns */
66 ReCompiled **aRe; /* List of compiled regular expressions */
67 };
68
69 #endif /*INTERFACE*/
70
71 /*
72 ** Translate a "match style" text name into the MS_* enum value.
73 ** Return eDflt if no match is found.
74 */
75 MatchStyle match_style(const char *zStyle, MatchStyle eDflt){
76 if( zStyle==0 ) return eDflt;
77 if( fossil_stricmp(zStyle, "brlist")==0 ) return MS_BRLIST;
78 if( fossil_stricmp(zStyle, "list")==0 ) return MS_BRLIST;
79 if( fossil_stricmp(zStyle, "regexp")==0 ) return MS_REGEXP;
80 if( fossil_stricmp(zStyle, "re")==0 ) return MS_REGEXP;
81 if( fossil_stricmp(zStyle, "glob")==0 ) return MS_GLOB;
82 if( fossil_stricmp(zStyle, "like")==0 ) return MS_LIKE;
83 if( fossil_stricmp(zStyle, "exact")==0 ) return MS_EXACT;
84 return eDflt;
85 }
86
87
88 /*
89 ** Create a new Matcher object using the pattern provided.
90 */
91 Matcher *match_create(MatchStyle style, const char *zPat){
92 char cDel; /* Delimiter character */
93 int i; /* Loop counter */
94 Matcher *p; /* The new Matcher to be constructed */
95 char *zOne; /* One element of the pattern */
96
97 if( zPat==0 ) return 0;
98 p = fossil_malloc( sizeof(*p) );
99 memset(p, 0, sizeof(*p));
100 p->style = style;
101
102 if( style==MS_EXACT ){
103 p->nPattern = 1;
104 p->azPattern = fossil_malloc( sizeof(p->azPattern[0]) );
105 p->azPattern[0] = fossil_strdup(zPat);
106 return p;
107 }
108
109 while( 1 ){
110 /* Skip leading delimiters. */
111 for( ; fossil_isspace(*zPat) || *zPat==','; ++zPat );
112
113 /* Next non-delimiter character determines quoting. */
114 if( zPat[0]==0 ){
115 /* Terminate loop at end of string. */
116 break;
117 }else if( zPat[0]=='\'' || zPat[0]=='"' ){
118 /* If word is quoted, prepare to stop at end quote. */
119 cDel = zPat[0];
120 ++zPat;
121 }else{
122 /* If word is not quoted, prepare to stop at delimiter. */
123 cDel = ',';
124 }
125
126 /* Find the next delimiter character or end of string. */
127 for( i=0; zPat[i] && zPat[i]!=cDel; ++i ){
128 /* If delimiter is comma, also recognize spaces as delimiters. */
129 if( cDel==',' && fossil_isspace(zPat[i]) ){
130 break;
131 }
132
133 /* In regexp mode, ignore delimiters following backslashes. */
134 if( style==MS_REGEXP && zPat[i]=='\\' && zPat[i+1] ){
135 ++i;
136 }
137 }
138
139 /* zOne is a zero-terminated copy of the pattern, without delimiters */
140 zOne = fossil_strndup(zPat, i);
141 zPat += i;
142 if( zPat[0] ) zPat++;
143
144 /* Check for regular expression syntax errors. */
145 if( style==MS_REGEXP ){
146 ReCompiled *regexp;
147 const char *zFail = re_compile(&regexp, zOne, 0);
148 if( zFail ){
149 re_free(regexp);
150 continue;
151 }
152 p->nPattern++;
153 p->aRe = fossil_realloc(p->aRe, sizeof(p->aRe)*p->nPattern);
154 p->aRe[p->nPattern-1] = regexp;
155 fossil_free(zOne);
156 }else{
157 p->nPattern++;
158 p->azPattern = fossil_realloc(p->azPattern, sizeof(char*)*p->nPattern);
159 p->azPattern[p->nPattern-1] = zOne;
160 }
161 }
162 return p;
163 }
164
165 /*
166 ** Return non-zero (true) if the input string matches the pattern
167 ** described by the matcher.
168 **
169 ** The return value is really the 1-based index of the particular
170 ** pattern that matched.
171 */
172 int match_text(Matcher *p, const char *zText){
173 int i;
174 if( p==0 ){
175 return zText==0;
176 }
177 switch( p->style ){
178 case MS_BRLIST:
179 case MS_EXACT: {
180 for(i=0; i<p->nPattern; i++){
181 if( strcmp(p->azPattern[i], zText)==0 ) return i+1;
182 }
183 break;
184 }
185 case MS_GLOB: {
186 for(i=0; i<p->nPattern; i++){
187 if( sqlite3_strglob(p->azPattern[i], zText)==0 ) return i+1;
188 }
189 break;
190 }
191 case MS_LIKE: {
192 for(i=0; i<p->nPattern; i++){
193 if( sqlite3_strlike(p->azPattern[i], zText, 0)==0 ) return i+1;
194 }
195 break;
196 }
197 case MS_REGEXP: {
198 int nText = (int)strlen(zText);
199 for(i=0; i<p->nPattern; i++){
200 if( re_match(p->aRe[i], (const u8*)zText, nText) ) return i+1;
201 }
202 break;
203 }
204 }
205 return 0n 0;
206 }
207
208
209 /*
210 ** Destroy a previously allocated Matcher object.
211 */
212 void match_free(Matcher *p){
213 int i;
214 if( p==0 ) return;
215 if( p->style==MS_REGEXP ){
216 for(i=0; i<p->nPattern; i++) re_free(p->aRe[i]);
217 fossil_free(p->aRe);
218 }else{
219 for(i=0; i<p->nPattern; i++) fossil_free(p->azPattern[i]);
220 fossil_free(p->azPattern);
221 }
222 memset(p, 0, sizeof(*p));
223 fossil_free(p);
224 }
225
226
227
228 /*
229 ** Quote a tag string by surrounding it with double quotes and preceding
230 ** internal double quotes and backslashes with backslashes.
231 */
232 static const char *tagQuote(
233 int len, /* Maximum length of zTag, or negative for unlimited */
234 const char *zTag /* Tag string */
235 ){
236 Blob blob = BLOB_INITIALIZER;
237 int i, j;
238 blob_zero(&blob);
239 blob_append(&blob, "\"", 1);
240 for( i=j=0; zTag[j] && (len<0 || j<len); ++j ){
241 if( zTag[j]=='\"' || zTag[j]=='\\' ){
242 if( j>i ){
243 blob_append(&blob, zTag+i, j-i);
244 }
245 blob_append(&blob, "\\", 1);
246 i = j;
247 }
248 }
249 if( j>i ){
250 blob_append(&blob, zTag+i, j-i);
251 }
252 blob_append(&blob, "\"", 1);
253 return blob_str(&blob);
254 }
255
256 /*
257 ** Construct the SQL expression that goes into the WHERE clause of a join
258 ** that involves the TAG table and that selects a particular tag out of
259 ** that table.
260 **
261 ** This function is adapted from glob_expr() to support the MS_EXACT, MS_GLOB,
262 ** MS_LIKE, MS_REGEXP, and MS_BRLIST match styles.
263 **
264 ** For MS_EXACT, the returned expression
265 ** checks for integer match against the tag ID which is looked up directly by
266 ** this function. For the other modes, the returned SQL expression performs
267 ** string comparisons against the tag names, so it is necessary to join against
268 ** the tag table to access the "tagname" column.
269 **
270 ** Each pattern is adjusted to start with "sym-" and be anchored at end.
271 **
272 ** In MS_REGEXP mode, backslash can be used to protect delimiter characters.
273 ** The backslashes are not removed from the regular expression.
274 **
275 ** In addition to assembling and returning an SQL expression, this function
276 ** makes an English-language description of the patterns being matched, suitable
277 ** for display in the web interface.
278 **
279 ** If any errors arise during processing, *zError is set to an error message.
280 ** Otherwise it is set to NULL.
281 */
282 const char *match_tag_sqlexpr(
283 MatchStyle matchStyle, /* Match style code */
284 const char *zTag, /* Tag name, match pattern, or pattern list */
285 const char **zDesc, /* Output expression description string */
286 const char **zError /* Output error string */
287 ){
288 Blob expr = BLOB_INITIALIZER; /* SQL expression string assembly buffer */
289 Blob desc = BLOB_INITIALIZER; /* English description of match patterns */
290 Blob err = BLOB_INITIALIZER; /* Error text assembly buffer */
291 const char *zStart; /* Text at start of expression */
292 const char *zDelimiter; /* Text between expression terms */
293 const char *zEnd; /* Text at end of expression */
294 const char *zPrefix; /* Text before each match pattern */
295 const char *zSuffix; /* Text after each match pattern */
296 const char *zIntro; /* Text introducing pattern description */
297 const char *zPattern = 0; /* Previous quoted pattern */
298 const char *zFail = 0; /* Current failure message or NULL if okay */
299 const char *zOr = " or "; /* Text before final quoted pattern */
300 char cDel; /* Input delimiter character */
301 int i; /* Input match pattern length counter */
302
303 /* Optimize exact matches by looking up the ID in advance to create a simple
304 * numeric comparison. Bypass the remainder of this function. */
305 if( matchStyle==MS_EXACT ){
306 *zDesc = tagQuote(-1, zTag);
307 return mprintf("(tagid=%d)", db_int(-1,
308 "SELECT tagid FROM tag WHERE tagname='sym-%q'", zTag));
309 }
310
311 /* Decide pattern prefix and suffix strings according to match style. */
312 if( matchStyle==MS_GLOB ){
313 zStart = "(";
314 zDelimiter = " OR ";
315 zEnd = ")";
316 zPrefix = "tagname GLOB 'sym-";
317 zSuffix = "'";
318 zIntro = "glob pattern ";
319 }else irt = "(";
320 zDelimiter = " OR ";
321 zEnd = ")";
322 zPrefix = "tagname LIKE 'sym-";
323 zSuffix = "'";
324 zIntro = "SQL LIKE pattern ";
325 }else if( matchStyle==MS_REGEXP ){
326 zStart = "(tagname REGEXP '^sym-(";
327 zDelimiter = "|";
328 zEnd = ")$')";
329 zPrefix = "";
330 zSuffix = "";
331 zIntro = "regular expression ";
332 }else/* if( matchStyle==MS_BRLIST )*/{
333 zStart = "tagname IN ('sym-";
334 zDelimiter = "','sym-";
335 zEnd = "')";
336 zPrefix = "";
337 zSuffix = "";
338 zIntro = "";
339 }
340
341 /* Convert the list of matches into an SQL expression and text description. */
342 blob_zero(&expr);
343 blob_zero(&desc);
344 blob_zero(&err);
345 while( 1 ){
346 /* Skip leading delimiters. */
347 for( ; fossil_isspace(*zTag) || *zTag==','; ++zTag );
348
349 /* Next non-delimiter character determines quoting. */
350 if( !*zTag ){
351 /* Terminate loop at end of string. */
352 break;
353 }else if( *zTag=='\'' || *zTag=='"' ){
354 /* If word is quoted, prepare to stop at end quote. */
355 cDel = *zTag;
356 ++zTag;
357 }else{
358 /* If word is not quoted, prepare to stop at delimiter. */
359 cDel = ',';
360 }
361
362 /* Find the next delimiter character or end of string. */
363 for( i=0; zTag[i] && zTag[i]!=cDel; ++i ){
364 /* If delimiter is comma, also recognize spaces as delimiters. */
365 if( cDel==',' && fossil_isspace(zTag[i]) ){
366 break;
367 }
368
369 /* In regexp mode, ignore delimiters following backslashes. */
370 if( matchStyle==MS_REGEXP && zTag[i]=='\\' && zTag[i+1] ){
371 ++i;
372 }
373 }
374
375 /* Check for regular expression syntax errors. */
376 if( matchStyle==MS_REGEXP ){
377 ReCompiled *regexp;
378 char *zTagDup = fossil_strndup(zTag, i);
379 zFail = fossil_re_compile(&regexp, zTagDup, 0);
380 re_free(regexp);
381 fossil_free(zTagDup);
382 }
383
384 /* Process success and error results. */
385 if( !zFail ){
386 /* Incorporate
+23 -8
--- src/merge.c
+++ src/merge.c
@@ -28,10 +28,11 @@
2828
*/
2929
static void merge_info_tk(int bDark, int bAll, int nContext){
3030
int i;
3131
Blob script;
3232
const char *zTempFile = 0;
33
+ int bDebug;
3334
char *zCmd;
3435
const char *zTclsh;
3536
zTclsh = find_option("tclsh",0,1);
3637
if( zTclsh==0 ){
3738
zTclsh = db_get("tclsh",0);
@@ -38,10 +39,11 @@
3839
}
3940
/* The undocumented --script FILENAME option causes the Tk script to
4041
** be written into the FILENAME instead of being run. This is used
4142
** for testing and debugging. */
4243
zTempFile = find_option("script",0,1);
44
+ bDebug = find_option("debug",0,0)!=0;
4345
verify_all_options();
4446
4547
blob_zero(&script);
4648
blob_appendf(&script, "set ncontext %d\n", nContext);
4749
blob_appendf(&script, "set fossilcmd {| \"%/\" merge-info}\n",
@@ -93,10 +95,11 @@
9395
blob_reset(&fname);
9496
}
9597
}
9698
blob_appendf(&script, "]\n");
9799
blob_appendf(&script, "set darkmode %d\n", bDark!=0);
100
+ blob_appendf(&script, "set debug %d\n", bDebug!=0);
98101
blob_appendf(&script, "%s", builtin_file("merge.tcl", 0));
99102
if( zTempFile ){
100103
blob_write_to_file(&script, zTempFile);
101104
fossil_print("To see the merge, run: %s \"%s\"\n", zTclsh, zTempFile);
102105
}else{
@@ -114,10 +117,14 @@
114117
* to using the external "tclsh", if available.
115118
*/
116119
#endif
117120
zTempFile = write_blob_to_temp_file(&script);
118121
zCmd = mprintf("%$ %$", zTclsh, zTempFile);
122
+ if( bDebug ){
123
+ fossil_print("%s\n", zCmd);
124
+ fflush(stdout);
125
+ }
119126
fossil_system(zCmd);
120127
file_delete(zTempFile);
121128
fossil_free(zCmd);
122129
}
123130
blob_reset(&script);
@@ -488,10 +495,14 @@
488495
** be a pathname relative to the root of the check-out.
489496
** --tk Bring up a Tcl/Tk GUI that shows the changes
490497
** associated with the most recent merge.
491498
** --html Like --tk but emits HTML to stdout.
492499
** -b|--browser Like --html but show the result in a web browser.
500
+** Additional debugging options available only when --tk is used:
501
+** --debug Show sub-commands run to implement --tk
502
+** --script FILE Write script used to implement --tk into FILE
503
+
493504
*/
494505
void merge_info_cmd(void){
495506
const char *zCnt;
496507
const char *zTcl;
497508
int bTk;
@@ -924,10 +935,11 @@
924935
** -K|--keep-merge-files On merge conflict, retain the temporary files
925936
** used for merging, named *-baseline, *-original,
926937
** and *-merge.
927938
** -n|--dry-run Do not actually change files on disk
928939
** --nosync Do not auto-sync prior to merging
940
+** --noundo Do not record changes in the undo log
929941
** -v|--verbose Show additional details of the merge
930942
*/
931943
void merge_cmd(void){
932944
int vid; /* Current version "V" */
933945
int mid; /* Version we are merging from "M" */
@@ -949,10 +961,11 @@
949961
int nOverwrite = 0; /* Number of unmanaged files overwritten */
950962
char vAncestor = 'p'; /* If P is an ancestor of V then 'p', else 'n' */
951963
const char *zVersion; /* The VERSION argument */
952964
int bMultiMerge = 0; /* True if there are two or more VERSION arguments */
953965
int nMerge = 0; /* Number of prior merges processed */
966
+ int useUndo = 1; /* True to record changes in the undo log */
954967
Stmt q; /* SQL statment used for merge processing */
955968
956969
957970
/* Notation:
958971
**
@@ -997,10 +1010,12 @@
9971010
** * The --dry-run option is also useful in combination with --debug.
9981011
*/
9991012
debugFlag = find_option("debug",0,0)!=0;
10001013
if( debugFlag && verboseFlag ) debugFlag = 2;
10011014
showVfileFlag = find_option("show-vfile",0,0)!=0;
1015
+ useUndo = find_option("noundo",0,0)==0;
1016
+ if( dryRunFlag ) useUndo = 0;
10021017
10031018
verify_all_options();
10041019
db_must_be_within_tree();
10051020
if( zBinGlob==0 ) zBinGlob = db_get("binary-glob",0);
10061021
vid = db_lget_int("checkout", 0);
@@ -1163,11 +1178,11 @@
11631178
integrateFlag ? "integrate:" : "merge-from:");
11641179
print_checkin_description(pid, 12, "baseline:");
11651180
}
11661181
vfile_check_signature(vid, CKSIG_ENOTFILE);
11671182
if( nMerge==0 ) db_begin_transaction();
1168
- if( !dryRunFlag ) undo_begin();
1183
+ if( useUndo ) undo_begin();
11691184
if( load_vfile_from_rid(mid) && !forceMissingFlag ){
11701185
fossil_fatal("missing content, unable to merge");
11711186
}
11721187
if( load_vfile_from_rid(pid) && !forceMissingFlag ){
11731188
fossil_fatal("missing content, unable to merge");
@@ -1420,12 +1435,12 @@
14201435
int ridm = db_column_int(&q, 1);
14211436
const char *zName = db_column_text(&q, 2);
14221437
int islinkm = db_column_int(&q, 3);
14231438
/* Copy content from idm over into idv. Overwrite idv. */
14241439
fossil_print("UPDATE %s\n", zName);
1440
+ if( useUndo ) undo_save(zName);
14251441
if( !dryRunFlag ){
1426
- undo_save(zName);
14271442
db_multi_exec(
14281443
"UPDATE vfile SET mtime=0, mrid=%d, chnged=%d, islink=%d,"
14291444
" mhash=CASE WHEN rid<>%d"
14301445
" THEN (SELECT uuid FROM blob WHERE blob.rid=%d) END"
14311446
" WHERE id=%d", ridm, integrateFlag?4:2, islinkm, ridm, ridm, idv
@@ -1502,11 +1517,11 @@
15021517
}else{
15031518
i64 sz;
15041519
const char *zErrMsg = 0;
15051520
int nc = 0;
15061521
1507
- if( !dryRunFlag ) undo_save(zName);
1522
+ if( useUndo ) undo_save(zName);
15081523
zFullPath = mprintf("%s/%s", g.zLocalRoot, zName);
15091524
sz = file_size(zFullPath, ExtFILE);
15101525
content_get(ridp, &p);
15111526
content_get(ridm, &m);
15121527
if( isBinary ){
@@ -1589,11 +1604,11 @@
15891604
zErrMsg = "local edits lost";
15901605
zFullPath = mprintf("%s/%s", g.zLocalRoot, zName);
15911606
sz = file_size(zFullPath, ExtFILE);
15921607
fossil_free(zFullPath);
15931608
}
1594
- if( !dryRunFlag ) undo_save(zName);
1609
+ if( useUndo ) undo_save(zName);
15951610
db_multi_exec(
15961611
"UPDATE vfile SET deleted=1 WHERE id=%d", idv
15971612
);
15981613
if( !dryRunFlag ){
15991614
char *zFullPath = mprintf("%s%s", g.zLocalRoot, zName);
@@ -1636,12 +1651,12 @@
16361651
int idv = db_column_int(&q, 0);
16371652
const char *zOldName = db_column_text(&q, 1);
16381653
const char *zNewName = db_column_text(&q, 2);
16391654
int isExe = db_column_int(&q, 3);
16401655
fossil_print("RENAME %s -> %s\n", zOldName, zNewName);
1641
- if( !dryRunFlag ) undo_save(zOldName);
1642
- if( !dryRunFlag ) undo_save(zNewName);
1656
+ if( useUndo ) undo_save(zOldName);
1657
+ if( useUndo ) undo_save(zNewName);
16431658
db_multi_exec(
16441659
"UPDATE mergestat SET fnr=fnm WHERE fnp=%Q",
16451660
zOldName
16461661
);
16471662
db_multi_exec(
@@ -1735,12 +1750,12 @@
17351750
"VALUES('ADDED',%Q,%d,%Q)",
17361751
/* fnm */ zName,
17371752
/* ridm */ db_column_int(&q,2),
17381753
/* fnr */ zName
17391754
);
1755
+ if( useUndo ) undo_save(zName);
17401756
if( !dryRunFlag ){
1741
- undo_save(zName);
17421757
vfile_to_disk(0, idm, 0, 0);
17431758
}
17441759
}
17451760
db_finalize(&q);
17461761
@@ -1795,9 +1810,9 @@
17951810
}
17961811
if( bMultiMerge && nConflict==0 ){
17971812
nMerge++;
17981813
goto merge_next_child;
17991814
}
1800
- if( !dryRunFlag ) undo_finish();
1815
+ if( useUndo ) undo_finish();
18011816
18021817
db_end_transaction(dryRunFlag);
18031818
}
18041819
--- src/merge.c
+++ src/merge.c
@@ -28,10 +28,11 @@
28 */
29 static void merge_info_tk(int bDark, int bAll, int nContext){
30 int i;
31 Blob script;
32 const char *zTempFile = 0;
 
33 char *zCmd;
34 const char *zTclsh;
35 zTclsh = find_option("tclsh",0,1);
36 if( zTclsh==0 ){
37 zTclsh = db_get("tclsh",0);
@@ -38,10 +39,11 @@
38 }
39 /* The undocumented --script FILENAME option causes the Tk script to
40 ** be written into the FILENAME instead of being run. This is used
41 ** for testing and debugging. */
42 zTempFile = find_option("script",0,1);
 
43 verify_all_options();
44
45 blob_zero(&script);
46 blob_appendf(&script, "set ncontext %d\n", nContext);
47 blob_appendf(&script, "set fossilcmd {| \"%/\" merge-info}\n",
@@ -93,10 +95,11 @@
93 blob_reset(&fname);
94 }
95 }
96 blob_appendf(&script, "]\n");
97 blob_appendf(&script, "set darkmode %d\n", bDark!=0);
 
98 blob_appendf(&script, "%s", builtin_file("merge.tcl", 0));
99 if( zTempFile ){
100 blob_write_to_file(&script, zTempFile);
101 fossil_print("To see the merge, run: %s \"%s\"\n", zTclsh, zTempFile);
102 }else{
@@ -114,10 +117,14 @@
114 * to using the external "tclsh", if available.
115 */
116 #endif
117 zTempFile = write_blob_to_temp_file(&script);
118 zCmd = mprintf("%$ %$", zTclsh, zTempFile);
 
 
 
 
119 fossil_system(zCmd);
120 file_delete(zTempFile);
121 fossil_free(zCmd);
122 }
123 blob_reset(&script);
@@ -488,10 +495,14 @@
488 ** be a pathname relative to the root of the check-out.
489 ** --tk Bring up a Tcl/Tk GUI that shows the changes
490 ** associated with the most recent merge.
491 ** --html Like --tk but emits HTML to stdout.
492 ** -b|--browser Like --html but show the result in a web browser.
 
 
 
 
493 */
494 void merge_info_cmd(void){
495 const char *zCnt;
496 const char *zTcl;
497 int bTk;
@@ -924,10 +935,11 @@
924 ** -K|--keep-merge-files On merge conflict, retain the temporary files
925 ** used for merging, named *-baseline, *-original,
926 ** and *-merge.
927 ** -n|--dry-run Do not actually change files on disk
928 ** --nosync Do not auto-sync prior to merging
 
929 ** -v|--verbose Show additional details of the merge
930 */
931 void merge_cmd(void){
932 int vid; /* Current version "V" */
933 int mid; /* Version we are merging from "M" */
@@ -949,10 +961,11 @@
949 int nOverwrite = 0; /* Number of unmanaged files overwritten */
950 char vAncestor = 'p'; /* If P is an ancestor of V then 'p', else 'n' */
951 const char *zVersion; /* The VERSION argument */
952 int bMultiMerge = 0; /* True if there are two or more VERSION arguments */
953 int nMerge = 0; /* Number of prior merges processed */
 
954 Stmt q; /* SQL statment used for merge processing */
955
956
957 /* Notation:
958 **
@@ -997,10 +1010,12 @@
997 ** * The --dry-run option is also useful in combination with --debug.
998 */
999 debugFlag = find_option("debug",0,0)!=0;
1000 if( debugFlag && verboseFlag ) debugFlag = 2;
1001 showVfileFlag = find_option("show-vfile",0,0)!=0;
 
 
1002
1003 verify_all_options();
1004 db_must_be_within_tree();
1005 if( zBinGlob==0 ) zBinGlob = db_get("binary-glob",0);
1006 vid = db_lget_int("checkout", 0);
@@ -1163,11 +1178,11 @@
1163 integrateFlag ? "integrate:" : "merge-from:");
1164 print_checkin_description(pid, 12, "baseline:");
1165 }
1166 vfile_check_signature(vid, CKSIG_ENOTFILE);
1167 if( nMerge==0 ) db_begin_transaction();
1168 if( !dryRunFlag ) undo_begin();
1169 if( load_vfile_from_rid(mid) && !forceMissingFlag ){
1170 fossil_fatal("missing content, unable to merge");
1171 }
1172 if( load_vfile_from_rid(pid) && !forceMissingFlag ){
1173 fossil_fatal("missing content, unable to merge");
@@ -1420,12 +1435,12 @@
1420 int ridm = db_column_int(&q, 1);
1421 const char *zName = db_column_text(&q, 2);
1422 int islinkm = db_column_int(&q, 3);
1423 /* Copy content from idm over into idv. Overwrite idv. */
1424 fossil_print("UPDATE %s\n", zName);
 
1425 if( !dryRunFlag ){
1426 undo_save(zName);
1427 db_multi_exec(
1428 "UPDATE vfile SET mtime=0, mrid=%d, chnged=%d, islink=%d,"
1429 " mhash=CASE WHEN rid<>%d"
1430 " THEN (SELECT uuid FROM blob WHERE blob.rid=%d) END"
1431 " WHERE id=%d", ridm, integrateFlag?4:2, islinkm, ridm, ridm, idv
@@ -1502,11 +1517,11 @@
1502 }else{
1503 i64 sz;
1504 const char *zErrMsg = 0;
1505 int nc = 0;
1506
1507 if( !dryRunFlag ) undo_save(zName);
1508 zFullPath = mprintf("%s/%s", g.zLocalRoot, zName);
1509 sz = file_size(zFullPath, ExtFILE);
1510 content_get(ridp, &p);
1511 content_get(ridm, &m);
1512 if( isBinary ){
@@ -1589,11 +1604,11 @@
1589 zErrMsg = "local edits lost";
1590 zFullPath = mprintf("%s/%s", g.zLocalRoot, zName);
1591 sz = file_size(zFullPath, ExtFILE);
1592 fossil_free(zFullPath);
1593 }
1594 if( !dryRunFlag ) undo_save(zName);
1595 db_multi_exec(
1596 "UPDATE vfile SET deleted=1 WHERE id=%d", idv
1597 );
1598 if( !dryRunFlag ){
1599 char *zFullPath = mprintf("%s%s", g.zLocalRoot, zName);
@@ -1636,12 +1651,12 @@
1636 int idv = db_column_int(&q, 0);
1637 const char *zOldName = db_column_text(&q, 1);
1638 const char *zNewName = db_column_text(&q, 2);
1639 int isExe = db_column_int(&q, 3);
1640 fossil_print("RENAME %s -> %s\n", zOldName, zNewName);
1641 if( !dryRunFlag ) undo_save(zOldName);
1642 if( !dryRunFlag ) undo_save(zNewName);
1643 db_multi_exec(
1644 "UPDATE mergestat SET fnr=fnm WHERE fnp=%Q",
1645 zOldName
1646 );
1647 db_multi_exec(
@@ -1735,12 +1750,12 @@
1735 "VALUES('ADDED',%Q,%d,%Q)",
1736 /* fnm */ zName,
1737 /* ridm */ db_column_int(&q,2),
1738 /* fnr */ zName
1739 );
 
1740 if( !dryRunFlag ){
1741 undo_save(zName);
1742 vfile_to_disk(0, idm, 0, 0);
1743 }
1744 }
1745 db_finalize(&q);
1746
@@ -1795,9 +1810,9 @@
1795 }
1796 if( bMultiMerge && nConflict==0 ){
1797 nMerge++;
1798 goto merge_next_child;
1799 }
1800 if( !dryRunFlag ) undo_finish();
1801
1802 db_end_transaction(dryRunFlag);
1803 }
1804
--- src/merge.c
+++ src/merge.c
@@ -28,10 +28,11 @@
28 */
29 static void merge_info_tk(int bDark, int bAll, int nContext){
30 int i;
31 Blob script;
32 const char *zTempFile = 0;
33 int bDebug;
34 char *zCmd;
35 const char *zTclsh;
36 zTclsh = find_option("tclsh",0,1);
37 if( zTclsh==0 ){
38 zTclsh = db_get("tclsh",0);
@@ -38,10 +39,11 @@
39 }
40 /* The undocumented --script FILENAME option causes the Tk script to
41 ** be written into the FILENAME instead of being run. This is used
42 ** for testing and debugging. */
43 zTempFile = find_option("script",0,1);
44 bDebug = find_option("debug",0,0)!=0;
45 verify_all_options();
46
47 blob_zero(&script);
48 blob_appendf(&script, "set ncontext %d\n", nContext);
49 blob_appendf(&script, "set fossilcmd {| \"%/\" merge-info}\n",
@@ -93,10 +95,11 @@
95 blob_reset(&fname);
96 }
97 }
98 blob_appendf(&script, "]\n");
99 blob_appendf(&script, "set darkmode %d\n", bDark!=0);
100 blob_appendf(&script, "set debug %d\n", bDebug!=0);
101 blob_appendf(&script, "%s", builtin_file("merge.tcl", 0));
102 if( zTempFile ){
103 blob_write_to_file(&script, zTempFile);
104 fossil_print("To see the merge, run: %s \"%s\"\n", zTclsh, zTempFile);
105 }else{
@@ -114,10 +117,14 @@
117 * to using the external "tclsh", if available.
118 */
119 #endif
120 zTempFile = write_blob_to_temp_file(&script);
121 zCmd = mprintf("%$ %$", zTclsh, zTempFile);
122 if( bDebug ){
123 fossil_print("%s\n", zCmd);
124 fflush(stdout);
125 }
126 fossil_system(zCmd);
127 file_delete(zTempFile);
128 fossil_free(zCmd);
129 }
130 blob_reset(&script);
@@ -488,10 +495,14 @@
495 ** be a pathname relative to the root of the check-out.
496 ** --tk Bring up a Tcl/Tk GUI that shows the changes
497 ** associated with the most recent merge.
498 ** --html Like --tk but emits HTML to stdout.
499 ** -b|--browser Like --html but show the result in a web browser.
500 ** Additional debugging options available only when --tk is used:
501 ** --debug Show sub-commands run to implement --tk
502 ** --script FILE Write script used to implement --tk into FILE
503
504 */
505 void merge_info_cmd(void){
506 const char *zCnt;
507 const char *zTcl;
508 int bTk;
@@ -924,10 +935,11 @@
935 ** -K|--keep-merge-files On merge conflict, retain the temporary files
936 ** used for merging, named *-baseline, *-original,
937 ** and *-merge.
938 ** -n|--dry-run Do not actually change files on disk
939 ** --nosync Do not auto-sync prior to merging
940 ** --noundo Do not record changes in the undo log
941 ** -v|--verbose Show additional details of the merge
942 */
943 void merge_cmd(void){
944 int vid; /* Current version "V" */
945 int mid; /* Version we are merging from "M" */
@@ -949,10 +961,11 @@
961 int nOverwrite = 0; /* Number of unmanaged files overwritten */
962 char vAncestor = 'p'; /* If P is an ancestor of V then 'p', else 'n' */
963 const char *zVersion; /* The VERSION argument */
964 int bMultiMerge = 0; /* True if there are two or more VERSION arguments */
965 int nMerge = 0; /* Number of prior merges processed */
966 int useUndo = 1; /* True to record changes in the undo log */
967 Stmt q; /* SQL statment used for merge processing */
968
969
970 /* Notation:
971 **
@@ -997,10 +1010,12 @@
1010 ** * The --dry-run option is also useful in combination with --debug.
1011 */
1012 debugFlag = find_option("debug",0,0)!=0;
1013 if( debugFlag && verboseFlag ) debugFlag = 2;
1014 showVfileFlag = find_option("show-vfile",0,0)!=0;
1015 useUndo = find_option("noundo",0,0)==0;
1016 if( dryRunFlag ) useUndo = 0;
1017
1018 verify_all_options();
1019 db_must_be_within_tree();
1020 if( zBinGlob==0 ) zBinGlob = db_get("binary-glob",0);
1021 vid = db_lget_int("checkout", 0);
@@ -1163,11 +1178,11 @@
1178 integrateFlag ? "integrate:" : "merge-from:");
1179 print_checkin_description(pid, 12, "baseline:");
1180 }
1181 vfile_check_signature(vid, CKSIG_ENOTFILE);
1182 if( nMerge==0 ) db_begin_transaction();
1183 if( useUndo ) undo_begin();
1184 if( load_vfile_from_rid(mid) && !forceMissingFlag ){
1185 fossil_fatal("missing content, unable to merge");
1186 }
1187 if( load_vfile_from_rid(pid) && !forceMissingFlag ){
1188 fossil_fatal("missing content, unable to merge");
@@ -1420,12 +1435,12 @@
1435 int ridm = db_column_int(&q, 1);
1436 const char *zName = db_column_text(&q, 2);
1437 int islinkm = db_column_int(&q, 3);
1438 /* Copy content from idm over into idv. Overwrite idv. */
1439 fossil_print("UPDATE %s\n", zName);
1440 if( useUndo ) undo_save(zName);
1441 if( !dryRunFlag ){
 
1442 db_multi_exec(
1443 "UPDATE vfile SET mtime=0, mrid=%d, chnged=%d, islink=%d,"
1444 " mhash=CASE WHEN rid<>%d"
1445 " THEN (SELECT uuid FROM blob WHERE blob.rid=%d) END"
1446 " WHERE id=%d", ridm, integrateFlag?4:2, islinkm, ridm, ridm, idv
@@ -1502,11 +1517,11 @@
1517 }else{
1518 i64 sz;
1519 const char *zErrMsg = 0;
1520 int nc = 0;
1521
1522 if( useUndo ) undo_save(zName);
1523 zFullPath = mprintf("%s/%s", g.zLocalRoot, zName);
1524 sz = file_size(zFullPath, ExtFILE);
1525 content_get(ridp, &p);
1526 content_get(ridm, &m);
1527 if( isBinary ){
@@ -1589,11 +1604,11 @@
1604 zErrMsg = "local edits lost";
1605 zFullPath = mprintf("%s/%s", g.zLocalRoot, zName);
1606 sz = file_size(zFullPath, ExtFILE);
1607 fossil_free(zFullPath);
1608 }
1609 if( useUndo ) undo_save(zName);
1610 db_multi_exec(
1611 "UPDATE vfile SET deleted=1 WHERE id=%d", idv
1612 );
1613 if( !dryRunFlag ){
1614 char *zFullPath = mprintf("%s%s", g.zLocalRoot, zName);
@@ -1636,12 +1651,12 @@
1651 int idv = db_column_int(&q, 0);
1652 const char *zOldName = db_column_text(&q, 1);
1653 const char *zNewName = db_column_text(&q, 2);
1654 int isExe = db_column_int(&q, 3);
1655 fossil_print("RENAME %s -> %s\n", zOldName, zNewName);
1656 if( useUndo ) undo_save(zOldName);
1657 if( useUndo ) undo_save(zNewName);
1658 db_multi_exec(
1659 "UPDATE mergestat SET fnr=fnm WHERE fnp=%Q",
1660 zOldName
1661 );
1662 db_multi_exec(
@@ -1735,12 +1750,12 @@
1750 "VALUES('ADDED',%Q,%d,%Q)",
1751 /* fnm */ zName,
1752 /* ridm */ db_column_int(&q,2),
1753 /* fnr */ zName
1754 );
1755 if( useUndo ) undo_save(zName);
1756 if( !dryRunFlag ){
 
1757 vfile_to_disk(0, idm, 0, 0);
1758 }
1759 }
1760 db_finalize(&q);
1761
@@ -1795,9 +1810,9 @@
1810 }
1811 if( bMultiMerge && nConflict==0 ){
1812 nMerge++;
1813 goto merge_next_child;
1814 }
1815 if( useUndo ) undo_finish();
1816
1817 db_end_transaction(dryRunFlag);
1818 }
1819
+23 -8
--- src/merge.c
+++ src/merge.c
@@ -28,10 +28,11 @@
2828
*/
2929
static void merge_info_tk(int bDark, int bAll, int nContext){
3030
int i;
3131
Blob script;
3232
const char *zTempFile = 0;
33
+ int bDebug;
3334
char *zCmd;
3435
const char *zTclsh;
3536
zTclsh = find_option("tclsh",0,1);
3637
if( zTclsh==0 ){
3738
zTclsh = db_get("tclsh",0);
@@ -38,10 +39,11 @@
3839
}
3940
/* The undocumented --script FILENAME option causes the Tk script to
4041
** be written into the FILENAME instead of being run. This is used
4142
** for testing and debugging. */
4243
zTempFile = find_option("script",0,1);
44
+ bDebug = find_option("debug",0,0)!=0;
4345
verify_all_options();
4446
4547
blob_zero(&script);
4648
blob_appendf(&script, "set ncontext %d\n", nContext);
4749
blob_appendf(&script, "set fossilcmd {| \"%/\" merge-info}\n",
@@ -93,10 +95,11 @@
9395
blob_reset(&fname);
9496
}
9597
}
9698
blob_appendf(&script, "]\n");
9799
blob_appendf(&script, "set darkmode %d\n", bDark!=0);
100
+ blob_appendf(&script, "set debug %d\n", bDebug!=0);
98101
blob_appendf(&script, "%s", builtin_file("merge.tcl", 0));
99102
if( zTempFile ){
100103
blob_write_to_file(&script, zTempFile);
101104
fossil_print("To see the merge, run: %s \"%s\"\n", zTclsh, zTempFile);
102105
}else{
@@ -114,10 +117,14 @@
114117
* to using the external "tclsh", if available.
115118
*/
116119
#endif
117120
zTempFile = write_blob_to_temp_file(&script);
118121
zCmd = mprintf("%$ %$", zTclsh, zTempFile);
122
+ if( bDebug ){
123
+ fossil_print("%s\n", zCmd);
124
+ fflush(stdout);
125
+ }
119126
fossil_system(zCmd);
120127
file_delete(zTempFile);
121128
fossil_free(zCmd);
122129
}
123130
blob_reset(&script);
@@ -488,10 +495,14 @@
488495
** be a pathname relative to the root of the check-out.
489496
** --tk Bring up a Tcl/Tk GUI that shows the changes
490497
** associated with the most recent merge.
491498
** --html Like --tk but emits HTML to stdout.
492499
** -b|--browser Like --html but show the result in a web browser.
500
+** Additional debugging options available only when --tk is used:
501
+** --debug Show sub-commands run to implement --tk
502
+** --script FILE Write script used to implement --tk into FILE
503
+
493504
*/
494505
void merge_info_cmd(void){
495506
const char *zCnt;
496507
const char *zTcl;
497508
int bTk;
@@ -924,10 +935,11 @@
924935
** -K|--keep-merge-files On merge conflict, retain the temporary files
925936
** used for merging, named *-baseline, *-original,
926937
** and *-merge.
927938
** -n|--dry-run Do not actually change files on disk
928939
** --nosync Do not auto-sync prior to merging
940
+** --noundo Do not record changes in the undo log
929941
** -v|--verbose Show additional details of the merge
930942
*/
931943
void merge_cmd(void){
932944
int vid; /* Current version "V" */
933945
int mid; /* Version we are merging from "M" */
@@ -949,10 +961,11 @@
949961
int nOverwrite = 0; /* Number of unmanaged files overwritten */
950962
char vAncestor = 'p'; /* If P is an ancestor of V then 'p', else 'n' */
951963
const char *zVersion; /* The VERSION argument */
952964
int bMultiMerge = 0; /* True if there are two or more VERSION arguments */
953965
int nMerge = 0; /* Number of prior merges processed */
966
+ int useUndo = 1; /* True to record changes in the undo log */
954967
Stmt q; /* SQL statment used for merge processing */
955968
956969
957970
/* Notation:
958971
**
@@ -997,10 +1010,12 @@
9971010
** * The --dry-run option is also useful in combination with --debug.
9981011
*/
9991012
debugFlag = find_option("debug",0,0)!=0;
10001013
if( debugFlag && verboseFlag ) debugFlag = 2;
10011014
showVfileFlag = find_option("show-vfile",0,0)!=0;
1015
+ useUndo = find_option("noundo",0,0)==0;
1016
+ if( dryRunFlag ) useUndo = 0;
10021017
10031018
verify_all_options();
10041019
db_must_be_within_tree();
10051020
if( zBinGlob==0 ) zBinGlob = db_get("binary-glob",0);
10061021
vid = db_lget_int("checkout", 0);
@@ -1163,11 +1178,11 @@
11631178
integrateFlag ? "integrate:" : "merge-from:");
11641179
print_checkin_description(pid, 12, "baseline:");
11651180
}
11661181
vfile_check_signature(vid, CKSIG_ENOTFILE);
11671182
if( nMerge==0 ) db_begin_transaction();
1168
- if( !dryRunFlag ) undo_begin();
1183
+ if( useUndo ) undo_begin();
11691184
if( load_vfile_from_rid(mid) && !forceMissingFlag ){
11701185
fossil_fatal("missing content, unable to merge");
11711186
}
11721187
if( load_vfile_from_rid(pid) && !forceMissingFlag ){
11731188
fossil_fatal("missing content, unable to merge");
@@ -1420,12 +1435,12 @@
14201435
int ridm = db_column_int(&q, 1);
14211436
const char *zName = db_column_text(&q, 2);
14221437
int islinkm = db_column_int(&q, 3);
14231438
/* Copy content from idm over into idv. Overwrite idv. */
14241439
fossil_print("UPDATE %s\n", zName);
1440
+ if( useUndo ) undo_save(zName);
14251441
if( !dryRunFlag ){
1426
- undo_save(zName);
14271442
db_multi_exec(
14281443
"UPDATE vfile SET mtime=0, mrid=%d, chnged=%d, islink=%d,"
14291444
" mhash=CASE WHEN rid<>%d"
14301445
" THEN (SELECT uuid FROM blob WHERE blob.rid=%d) END"
14311446
" WHERE id=%d", ridm, integrateFlag?4:2, islinkm, ridm, ridm, idv
@@ -1502,11 +1517,11 @@
15021517
}else{
15031518
i64 sz;
15041519
const char *zErrMsg = 0;
15051520
int nc = 0;
15061521
1507
- if( !dryRunFlag ) undo_save(zName);
1522
+ if( useUndo ) undo_save(zName);
15081523
zFullPath = mprintf("%s/%s", g.zLocalRoot, zName);
15091524
sz = file_size(zFullPath, ExtFILE);
15101525
content_get(ridp, &p);
15111526
content_get(ridm, &m);
15121527
if( isBinary ){
@@ -1589,11 +1604,11 @@
15891604
zErrMsg = "local edits lost";
15901605
zFullPath = mprintf("%s/%s", g.zLocalRoot, zName);
15911606
sz = file_size(zFullPath, ExtFILE);
15921607
fossil_free(zFullPath);
15931608
}
1594
- if( !dryRunFlag ) undo_save(zName);
1609
+ if( useUndo ) undo_save(zName);
15951610
db_multi_exec(
15961611
"UPDATE vfile SET deleted=1 WHERE id=%d", idv
15971612
);
15981613
if( !dryRunFlag ){
15991614
char *zFullPath = mprintf("%s%s", g.zLocalRoot, zName);
@@ -1636,12 +1651,12 @@
16361651
int idv = db_column_int(&q, 0);
16371652
const char *zOldName = db_column_text(&q, 1);
16381653
const char *zNewName = db_column_text(&q, 2);
16391654
int isExe = db_column_int(&q, 3);
16401655
fossil_print("RENAME %s -> %s\n", zOldName, zNewName);
1641
- if( !dryRunFlag ) undo_save(zOldName);
1642
- if( !dryRunFlag ) undo_save(zNewName);
1656
+ if( useUndo ) undo_save(zOldName);
1657
+ if( useUndo ) undo_save(zNewName);
16431658
db_multi_exec(
16441659
"UPDATE mergestat SET fnr=fnm WHERE fnp=%Q",
16451660
zOldName
16461661
);
16471662
db_multi_exec(
@@ -1735,12 +1750,12 @@
17351750
"VALUES('ADDED',%Q,%d,%Q)",
17361751
/* fnm */ zName,
17371752
/* ridm */ db_column_int(&q,2),
17381753
/* fnr */ zName
17391754
);
1755
+ if( useUndo ) undo_save(zName);
17401756
if( !dryRunFlag ){
1741
- undo_save(zName);
17421757
vfile_to_disk(0, idm, 0, 0);
17431758
}
17441759
}
17451760
db_finalize(&q);
17461761
@@ -1795,9 +1810,9 @@
17951810
}
17961811
if( bMultiMerge && nConflict==0 ){
17971812
nMerge++;
17981813
goto merge_next_child;
17991814
}
1800
- if( !dryRunFlag ) undo_finish();
1815
+ if( useUndo ) undo_finish();
18011816
18021817
db_end_transaction(dryRunFlag);
18031818
}
18041819
--- src/merge.c
+++ src/merge.c
@@ -28,10 +28,11 @@
28 */
29 static void merge_info_tk(int bDark, int bAll, int nContext){
30 int i;
31 Blob script;
32 const char *zTempFile = 0;
 
33 char *zCmd;
34 const char *zTclsh;
35 zTclsh = find_option("tclsh",0,1);
36 if( zTclsh==0 ){
37 zTclsh = db_get("tclsh",0);
@@ -38,10 +39,11 @@
38 }
39 /* The undocumented --script FILENAME option causes the Tk script to
40 ** be written into the FILENAME instead of being run. This is used
41 ** for testing and debugging. */
42 zTempFile = find_option("script",0,1);
 
43 verify_all_options();
44
45 blob_zero(&script);
46 blob_appendf(&script, "set ncontext %d\n", nContext);
47 blob_appendf(&script, "set fossilcmd {| \"%/\" merge-info}\n",
@@ -93,10 +95,11 @@
93 blob_reset(&fname);
94 }
95 }
96 blob_appendf(&script, "]\n");
97 blob_appendf(&script, "set darkmode %d\n", bDark!=0);
 
98 blob_appendf(&script, "%s", builtin_file("merge.tcl", 0));
99 if( zTempFile ){
100 blob_write_to_file(&script, zTempFile);
101 fossil_print("To see the merge, run: %s \"%s\"\n", zTclsh, zTempFile);
102 }else{
@@ -114,10 +117,14 @@
114 * to using the external "tclsh", if available.
115 */
116 #endif
117 zTempFile = write_blob_to_temp_file(&script);
118 zCmd = mprintf("%$ %$", zTclsh, zTempFile);
 
 
 
 
119 fossil_system(zCmd);
120 file_delete(zTempFile);
121 fossil_free(zCmd);
122 }
123 blob_reset(&script);
@@ -488,10 +495,14 @@
488 ** be a pathname relative to the root of the check-out.
489 ** --tk Bring up a Tcl/Tk GUI that shows the changes
490 ** associated with the most recent merge.
491 ** --html Like --tk but emits HTML to stdout.
492 ** -b|--browser Like --html but show the result in a web browser.
 
 
 
 
493 */
494 void merge_info_cmd(void){
495 const char *zCnt;
496 const char *zTcl;
497 int bTk;
@@ -924,10 +935,11 @@
924 ** -K|--keep-merge-files On merge conflict, retain the temporary files
925 ** used for merging, named *-baseline, *-original,
926 ** and *-merge.
927 ** -n|--dry-run Do not actually change files on disk
928 ** --nosync Do not auto-sync prior to merging
 
929 ** -v|--verbose Show additional details of the merge
930 */
931 void merge_cmd(void){
932 int vid; /* Current version "V" */
933 int mid; /* Version we are merging from "M" */
@@ -949,10 +961,11 @@
949 int nOverwrite = 0; /* Number of unmanaged files overwritten */
950 char vAncestor = 'p'; /* If P is an ancestor of V then 'p', else 'n' */
951 const char *zVersion; /* The VERSION argument */
952 int bMultiMerge = 0; /* True if there are two or more VERSION arguments */
953 int nMerge = 0; /* Number of prior merges processed */
 
954 Stmt q; /* SQL statment used for merge processing */
955
956
957 /* Notation:
958 **
@@ -997,10 +1010,12 @@
997 ** * The --dry-run option is also useful in combination with --debug.
998 */
999 debugFlag = find_option("debug",0,0)!=0;
1000 if( debugFlag && verboseFlag ) debugFlag = 2;
1001 showVfileFlag = find_option("show-vfile",0,0)!=0;
 
 
1002
1003 verify_all_options();
1004 db_must_be_within_tree();
1005 if( zBinGlob==0 ) zBinGlob = db_get("binary-glob",0);
1006 vid = db_lget_int("checkout", 0);
@@ -1163,11 +1178,11 @@
1163 integrateFlag ? "integrate:" : "merge-from:");
1164 print_checkin_description(pid, 12, "baseline:");
1165 }
1166 vfile_check_signature(vid, CKSIG_ENOTFILE);
1167 if( nMerge==0 ) db_begin_transaction();
1168 if( !dryRunFlag ) undo_begin();
1169 if( load_vfile_from_rid(mid) && !forceMissingFlag ){
1170 fossil_fatal("missing content, unable to merge");
1171 }
1172 if( load_vfile_from_rid(pid) && !forceMissingFlag ){
1173 fossil_fatal("missing content, unable to merge");
@@ -1420,12 +1435,12 @@
1420 int ridm = db_column_int(&q, 1);
1421 const char *zName = db_column_text(&q, 2);
1422 int islinkm = db_column_int(&q, 3);
1423 /* Copy content from idm over into idv. Overwrite idv. */
1424 fossil_print("UPDATE %s\n", zName);
 
1425 if( !dryRunFlag ){
1426 undo_save(zName);
1427 db_multi_exec(
1428 "UPDATE vfile SET mtime=0, mrid=%d, chnged=%d, islink=%d,"
1429 " mhash=CASE WHEN rid<>%d"
1430 " THEN (SELECT uuid FROM blob WHERE blob.rid=%d) END"
1431 " WHERE id=%d", ridm, integrateFlag?4:2, islinkm, ridm, ridm, idv
@@ -1502,11 +1517,11 @@
1502 }else{
1503 i64 sz;
1504 const char *zErrMsg = 0;
1505 int nc = 0;
1506
1507 if( !dryRunFlag ) undo_save(zName);
1508 zFullPath = mprintf("%s/%s", g.zLocalRoot, zName);
1509 sz = file_size(zFullPath, ExtFILE);
1510 content_get(ridp, &p);
1511 content_get(ridm, &m);
1512 if( isBinary ){
@@ -1589,11 +1604,11 @@
1589 zErrMsg = "local edits lost";
1590 zFullPath = mprintf("%s/%s", g.zLocalRoot, zName);
1591 sz = file_size(zFullPath, ExtFILE);
1592 fossil_free(zFullPath);
1593 }
1594 if( !dryRunFlag ) undo_save(zName);
1595 db_multi_exec(
1596 "UPDATE vfile SET deleted=1 WHERE id=%d", idv
1597 );
1598 if( !dryRunFlag ){
1599 char *zFullPath = mprintf("%s%s", g.zLocalRoot, zName);
@@ -1636,12 +1651,12 @@
1636 int idv = db_column_int(&q, 0);
1637 const char *zOldName = db_column_text(&q, 1);
1638 const char *zNewName = db_column_text(&q, 2);
1639 int isExe = db_column_int(&q, 3);
1640 fossil_print("RENAME %s -> %s\n", zOldName, zNewName);
1641 if( !dryRunFlag ) undo_save(zOldName);
1642 if( !dryRunFlag ) undo_save(zNewName);
1643 db_multi_exec(
1644 "UPDATE mergestat SET fnr=fnm WHERE fnp=%Q",
1645 zOldName
1646 );
1647 db_multi_exec(
@@ -1735,12 +1750,12 @@
1735 "VALUES('ADDED',%Q,%d,%Q)",
1736 /* fnm */ zName,
1737 /* ridm */ db_column_int(&q,2),
1738 /* fnr */ zName
1739 );
 
1740 if( !dryRunFlag ){
1741 undo_save(zName);
1742 vfile_to_disk(0, idm, 0, 0);
1743 }
1744 }
1745 db_finalize(&q);
1746
@@ -1795,9 +1810,9 @@
1795 }
1796 if( bMultiMerge && nConflict==0 ){
1797 nMerge++;
1798 goto merge_next_child;
1799 }
1800 if( !dryRunFlag ) undo_finish();
1801
1802 db_end_transaction(dryRunFlag);
1803 }
1804
--- src/merge.c
+++ src/merge.c
@@ -28,10 +28,11 @@
28 */
29 static void merge_info_tk(int bDark, int bAll, int nContext){
30 int i;
31 Blob script;
32 const char *zTempFile = 0;
33 int bDebug;
34 char *zCmd;
35 const char *zTclsh;
36 zTclsh = find_option("tclsh",0,1);
37 if( zTclsh==0 ){
38 zTclsh = db_get("tclsh",0);
@@ -38,10 +39,11 @@
39 }
40 /* The undocumented --script FILENAME option causes the Tk script to
41 ** be written into the FILENAME instead of being run. This is used
42 ** for testing and debugging. */
43 zTempFile = find_option("script",0,1);
44 bDebug = find_option("debug",0,0)!=0;
45 verify_all_options();
46
47 blob_zero(&script);
48 blob_appendf(&script, "set ncontext %d\n", nContext);
49 blob_appendf(&script, "set fossilcmd {| \"%/\" merge-info}\n",
@@ -93,10 +95,11 @@
95 blob_reset(&fname);
96 }
97 }
98 blob_appendf(&script, "]\n");
99 blob_appendf(&script, "set darkmode %d\n", bDark!=0);
100 blob_appendf(&script, "set debug %d\n", bDebug!=0);
101 blob_appendf(&script, "%s", builtin_file("merge.tcl", 0));
102 if( zTempFile ){
103 blob_write_to_file(&script, zTempFile);
104 fossil_print("To see the merge, run: %s \"%s\"\n", zTclsh, zTempFile);
105 }else{
@@ -114,10 +117,14 @@
117 * to using the external "tclsh", if available.
118 */
119 #endif
120 zTempFile = write_blob_to_temp_file(&script);
121 zCmd = mprintf("%$ %$", zTclsh, zTempFile);
122 if( bDebug ){
123 fossil_print("%s\n", zCmd);
124 fflush(stdout);
125 }
126 fossil_system(zCmd);
127 file_delete(zTempFile);
128 fossil_free(zCmd);
129 }
130 blob_reset(&script);
@@ -488,10 +495,14 @@
495 ** be a pathname relative to the root of the check-out.
496 ** --tk Bring up a Tcl/Tk GUI that shows the changes
497 ** associated with the most recent merge.
498 ** --html Like --tk but emits HTML to stdout.
499 ** -b|--browser Like --html but show the result in a web browser.
500 ** Additional debugging options available only when --tk is used:
501 ** --debug Show sub-commands run to implement --tk
502 ** --script FILE Write script used to implement --tk into FILE
503
504 */
505 void merge_info_cmd(void){
506 const char *zCnt;
507 const char *zTcl;
508 int bTk;
@@ -924,10 +935,11 @@
935 ** -K|--keep-merge-files On merge conflict, retain the temporary files
936 ** used for merging, named *-baseline, *-original,
937 ** and *-merge.
938 ** -n|--dry-run Do not actually change files on disk
939 ** --nosync Do not auto-sync prior to merging
940 ** --noundo Do not record changes in the undo log
941 ** -v|--verbose Show additional details of the merge
942 */
943 void merge_cmd(void){
944 int vid; /* Current version "V" */
945 int mid; /* Version we are merging from "M" */
@@ -949,10 +961,11 @@
961 int nOverwrite = 0; /* Number of unmanaged files overwritten */
962 char vAncestor = 'p'; /* If P is an ancestor of V then 'p', else 'n' */
963 const char *zVersion; /* The VERSION argument */
964 int bMultiMerge = 0; /* True if there are two or more VERSION arguments */
965 int nMerge = 0; /* Number of prior merges processed */
966 int useUndo = 1; /* True to record changes in the undo log */
967 Stmt q; /* SQL statment used for merge processing */
968
969
970 /* Notation:
971 **
@@ -997,10 +1010,12 @@
1010 ** * The --dry-run option is also useful in combination with --debug.
1011 */
1012 debugFlag = find_option("debug",0,0)!=0;
1013 if( debugFlag && verboseFlag ) debugFlag = 2;
1014 showVfileFlag = find_option("show-vfile",0,0)!=0;
1015 useUndo = find_option("noundo",0,0)==0;
1016 if( dryRunFlag ) useUndo = 0;
1017
1018 verify_all_options();
1019 db_must_be_within_tree();
1020 if( zBinGlob==0 ) zBinGlob = db_get("binary-glob",0);
1021 vid = db_lget_int("checkout", 0);
@@ -1163,11 +1178,11 @@
1178 integrateFlag ? "integrate:" : "merge-from:");
1179 print_checkin_description(pid, 12, "baseline:");
1180 }
1181 vfile_check_signature(vid, CKSIG_ENOTFILE);
1182 if( nMerge==0 ) db_begin_transaction();
1183 if( useUndo ) undo_begin();
1184 if( load_vfile_from_rid(mid) && !forceMissingFlag ){
1185 fossil_fatal("missing content, unable to merge");
1186 }
1187 if( load_vfile_from_rid(pid) && !forceMissingFlag ){
1188 fossil_fatal("missing content, unable to merge");
@@ -1420,12 +1435,12 @@
1435 int ridm = db_column_int(&q, 1);
1436 const char *zName = db_column_text(&q, 2);
1437 int islinkm = db_column_int(&q, 3);
1438 /* Copy content from idm over into idv. Overwrite idv. */
1439 fossil_print("UPDATE %s\n", zName);
1440 if( useUndo ) undo_save(zName);
1441 if( !dryRunFlag ){
 
1442 db_multi_exec(
1443 "UPDATE vfile SET mtime=0, mrid=%d, chnged=%d, islink=%d,"
1444 " mhash=CASE WHEN rid<>%d"
1445 " THEN (SELECT uuid FROM blob WHERE blob.rid=%d) END"
1446 " WHERE id=%d", ridm, integrateFlag?4:2, islinkm, ridm, ridm, idv
@@ -1502,11 +1517,11 @@
1517 }else{
1518 i64 sz;
1519 const char *zErrMsg = 0;
1520 int nc = 0;
1521
1522 if( useUndo ) undo_save(zName);
1523 zFullPath = mprintf("%s/%s", g.zLocalRoot, zName);
1524 sz = file_size(zFullPath, ExtFILE);
1525 content_get(ridp, &p);
1526 content_get(ridm, &m);
1527 if( isBinary ){
@@ -1589,11 +1604,11 @@
1604 zErrMsg = "local edits lost";
1605 zFullPath = mprintf("%s/%s", g.zLocalRoot, zName);
1606 sz = file_size(zFullPath, ExtFILE);
1607 fossil_free(zFullPath);
1608 }
1609 if( useUndo ) undo_save(zName);
1610 db_multi_exec(
1611 "UPDATE vfile SET deleted=1 WHERE id=%d", idv
1612 );
1613 if( !dryRunFlag ){
1614 char *zFullPath = mprintf("%s%s", g.zLocalRoot, zName);
@@ -1636,12 +1651,12 @@
1651 int idv = db_column_int(&q, 0);
1652 const char *zOldName = db_column_text(&q, 1);
1653 const char *zNewName = db_column_text(&q, 2);
1654 int isExe = db_column_int(&q, 3);
1655 fossil_print("RENAME %s -> %s\n", zOldName, zNewName);
1656 if( useUndo ) undo_save(zOldName);
1657 if( useUndo ) undo_save(zNewName);
1658 db_multi_exec(
1659 "UPDATE mergestat SET fnr=fnm WHERE fnp=%Q",
1660 zOldName
1661 );
1662 db_multi_exec(
@@ -1735,12 +1750,12 @@
1750 "VALUES('ADDED',%Q,%d,%Q)",
1751 /* fnm */ zName,
1752 /* ridm */ db_column_int(&q,2),
1753 /* fnr */ zName
1754 );
1755 if( useUndo ) undo_save(zName);
1756 if( !dryRunFlag ){
 
1757 vfile_to_disk(0, idm, 0, 0);
1758 }
1759 }
1760 db_finalize(&q);
1761
@@ -1795,9 +1810,9 @@
1810 }
1811 if( bMultiMerge && nConflict==0 ){
1812 nMerge++;
1813 goto merge_next_child;
1814 }
1815 if( useUndo ) undo_finish();
1816
1817 db_end_transaction(dryRunFlag);
1818 }
1819
+6 -1
--- src/merge.tcl
+++ src/merge.tcl
@@ -93,20 +93,25 @@
9393
regexp {[a-z]+} $c type
9494
return $type
9595
}
9696
9797
proc readMerge {args} {
98
- global fossilcmd ncontext current_file
98
+ global fossilcmd ncontext current_file debug
9999
if {$ncontext=="All"} {
100100
set cmd "$fossilcmd -c -1"
101101
} else {
102102
set cmd "$fossilcmd -c $ncontext"
103103
}
104104
if {[info exists current_file]} {
105105
regsub {^[A-Z]+ } $current_file {} fn
106106
append cmd " -tcl [list $fn]"
107107
}
108
+ if {$debug} {
109
+ regsub {^\| +} $cmd {} cmd2
110
+ puts $cmd2
111
+ flush stdout
112
+ }
108113
if {[catch {
109114
set in [open $cmd r]
110115
fconfigure $in -encoding utf-8
111116
set mergetxt [read $in]
112117
close $in
113118
--- src/merge.tcl
+++ src/merge.tcl
@@ -93,20 +93,25 @@
93 regexp {[a-z]+} $c type
94 return $type
95 }
96
97 proc readMerge {args} {
98 global fossilcmd ncontext current_file
99 if {$ncontext=="All"} {
100 set cmd "$fossilcmd -c -1"
101 } else {
102 set cmd "$fossilcmd -c $ncontext"
103 }
104 if {[info exists current_file]} {
105 regsub {^[A-Z]+ } $current_file {} fn
106 append cmd " -tcl [list $fn]"
107 }
 
 
 
 
 
108 if {[catch {
109 set in [open $cmd r]
110 fconfigure $in -encoding utf-8
111 set mergetxt [read $in]
112 close $in
113
--- src/merge.tcl
+++ src/merge.tcl
@@ -93,20 +93,25 @@
93 regexp {[a-z]+} $c type
94 return $type
95 }
96
97 proc readMerge {args} {
98 global fossilcmd ncontext current_file debug
99 if {$ncontext=="All"} {
100 set cmd "$fossilcmd -c -1"
101 } else {
102 set cmd "$fossilcmd -c $ncontext"
103 }
104 if {[info exists current_file]} {
105 regsub {^[A-Z]+ } $current_file {} fn
106 append cmd " -tcl [list $fn]"
107 }
108 if {$debug} {
109 regsub {^\| +} $cmd {} cmd2
110 puts $cmd2
111 flush stdout
112 }
113 if {[catch {
114 set in [open $cmd r]
115 fconfigure $in -encoding utf-8
116 set mergetxt [read $in]
117 close $in
118
+151 -24
--- src/name.c
+++ src/name.c
@@ -65,33 +65,51 @@
6565
** the string is a hash prefix and NULL is returned if it is. If the
6666
** bVerifyNotAHash flag is false, then the result is determined by syntax
6767
** of the input string only, without reference to the artifact table.
6868
*/
6969
char *fossil_expand_datetime(const char *zIn, int bVerifyNotAHash){
70
- static char zEDate[20];
70
+ static char zEDate[24];
7171
static const char aPunct[] = { 0, 0, '-', '-', ' ', ':', ':' };
7272
int n = (int)strlen(zIn);
7373
int i, j;
74
+ int addZulu = 0;
7475
75
- /* Only three forms allowed:
76
- ** (1) YYYYMMDD
77
- ** (2) YYYYMMDDHHMM
78
- ** (3) YYYYMMDDHHMMSS
76
+ /* These forms are allowed:
77
+ **
78
+ ** 123456789 1234 123456789 123456789
79
+ ** (1) YYYYMMDD => YYYY-MM-DD
80
+ ** (2) YYYYMMDDHHMM => YYYY-MM-DD HH:MM
81
+ ** (3) YYYYMMDDHHMMSS => YYYY-MM-DD HH:MM:SS
82
+ **
83
+ ** An optional "Z" zulu timezone designator is allowed at the end.
7984
*/
80
- if( n!=8 && n!=12 && n!=14 ) return 0;
85
+ if( n>0 && (zIn[n-1]=='Z' || zIn[n-1]=='z') ){
86
+ n--;
87
+ addZulu = 1;
88
+ }
89
+ if( n!=8 && n!=12 && n!=14 ){
90
+ return 0;
91
+ }
8192
8293
/* Every character must be a digit */
8394
for(i=0; fossil_isdigit(zIn[i]); i++){}
84
- if( i!=n ) return 0;
95
+ if( i!=n && (!addZulu || i!=n+1) ) return 0;
8596
8697
/* Expand the date */
87
- for(i=j=0; zIn[i]; i++){
98
+ for(i=j=0; i<n; i++){
8899
if( i>=4 && (i%2)==0 ){
89100
zEDate[j++] = aPunct[i/2];
90101
}
91102
zEDate[j++] = zIn[i];
92103
}
104
+ if( addZulu ){
105
+ if( j==10 ){
106
+ memcpy(&zEDate[10]," 00:00", 6);
107
+ j += 6;
108
+ }
109
+ zEDate[j++] = 'Z';
110
+ }
93111
zEDate[j] = 0;
94112
95113
/* Check for reasonable date values.
96114
** Offset references:
97115
** YYYY-MM-DD HH:MM:SS
@@ -111,11 +129,11 @@
111129
if( i>60 ) return 0;
112130
if( n==14 && atoi(zEDate+17)>60 ) return 0;
113131
}
114132
115133
/* The string is not also a hash prefix */
116
- if( bVerifyNotAHash ){
134
+ if( bVerifyNotAHash && !addZulu ){
117135
if( db_exists("SELECT 1 FROM blob WHERE uuid GLOB '%q*'",zIn) ) return 0;
118136
}
119137
120138
/* It looks like this may be a date. Return it with punctuation added. */
121139
return zEDate;
@@ -453,10 +471,12 @@
453471
}else if( fossil_strcmp(zTag, "next")==0 ){
454472
rid = db_int(0, "SELECT cid FROM plink WHERE pid=%d"
455473
" ORDER BY isprim DESC, mtime DESC", ridCkout);
456474
}else if( isCheckin>1 && fossil_strcmp(zTag, "ckout")==0 ){
457475
rid = RID_CKOUT;
476
+ assert(ridCkout>0);
477
+ g.localOpen = ridCkout;
458478
}
459479
if( rid ) return rid;
460480
}
461481
462482
/* Date and times */
@@ -699,10 +719,13 @@
699719
}else if( rid==0 ){
700720
fossil_error(iErrPriority, "cannot resolve name: %s", zName);
701721
return 1;
702722
}else{
703723
blob_reset(pName);
724
+ if( RID_CKOUT==rid ) {
725
+ rid = g.localOpen;
726
+ }
704727
db_blob(pName, "SELECT uuid FROM blob WHERE rid=%d", rid);
705728
return 0;
706729
}
707730
}
708731
@@ -1676,34 +1699,44 @@
16761699
** n=N Show N artifacts
16771700
** s=S Start with artifact number S
16781701
** priv Show only unpublished or private artifacts
16791702
** phan Show only phantom artifacts
16801703
** hclr Color code hash types (SHA1 vs SHA3)
1704
+** recent Show the most recent N artifacts
16811705
*/
16821706
void bloblist_page(void){
16831707
Stmt q;
16841708
int s = atoi(PD("s","0"));
16851709
int n = atoi(PD("n","5000"));
16861710
int mx = db_int(0, "SELECT max(rid) FROM blob");
16871711
int privOnly = PB("priv");
16881712
int phantomOnly = PB("phan");
16891713
int hashClr = PB("hclr");
1714
+ int bRecent = PB("recent");
1715
+ int bUnclst = PB("unclustered");
16901716
char *zRange;
16911717
char *zSha1Bg;
16921718
char *zSha3Bg;
16931719
16941720
login_check_credentials();
16951721
if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
16961722
cgi_check_for_malice();
16971723
style_header("List Of Artifacts");
16981724
style_submenu_element("250 Largest", "bigbloblist");
1725
+ if( bRecent==0 || n!=250 ){
1726
+ style_submenu_element("Recent","bloblist?n=250&recent");
1727
+ }
1728
+ if( bUnclst==0 ){
1729
+ style_submenu_element("Unclustered","bloblist?unclustered");
1730
+ }
16991731
if( g.perm.Admin ){
17001732
style_submenu_element("Artifact Log", "rcvfromlist");
17011733
}
17021734
if( !phantomOnly ){
17031735
style_submenu_element("Phantoms", "bloblist?phan");
17041736
}
1737
+ style_submenu_element("Clusters","clusterlist");
17051738
if( g.perm.Private || g.perm.Admin ){
17061739
if( !privOnly ){
17071740
style_submenu_element("Private", "bloblist?priv");
17081741
}
17091742
}else{
@@ -1710,58 +1743,70 @@
17101743
privOnly = 0;
17111744
}
17121745
if( g.perm.Write ){
17131746
style_submenu_element("Artifact Stats", "artifact_stats");
17141747
}
1715
- if( !privOnly && !phantomOnly && mx>n && P("s")==0 ){
1748
+ if( !privOnly && !phantomOnly && mx>n && P("s")==0 && !bRecent && !bUnclst ){
17161749
int i;
17171750
@ <p>Select a range of artifacts to view:</p>
17181751
@ <ul>
17191752
for(i=1; i<=mx; i+=n){
17201753
@ <li> %z(href("%R/bloblist?s=%d&n=%d",i,n))
17211754
@ %d(i)..%d(i+n-1<mx?i+n-1:mx)</a>
17221755
}
1756
+ @ <li> %z(href("%R/bloblist?n=250&recent"))250 most recent</a>
1757
+ @ <li> %z(href("%R/bloblist?unclustered"))All unclustered</a>
17231758
@ </ul>
17241759
style_finish_page();
17251760
return;
17261761
}
17271762
if( phantomOnly || privOnly || mx>n ){
17281763
style_submenu_element("Index", "bloblist");
17291764
}
17301765
if( privOnly ){
1766
+ @ <h2>Private Artifacts</h2>
17311767
zRange = mprintf("IN private");
17321768
}else if( phantomOnly ){
1769
+ @ <h2>Phantom Artifacts</h2>
17331770
zRange = mprintf("IN phantom");
1771
+ }else if( bUnclst ){
1772
+ @ <h2>Unclustered Artifacts</h2>
1773
+ zRange = mprintf("IN unclustered");
1774
+ }else if( bRecent ){
1775
+ @ <h2>%d(n) Most Recent Artifacts</h2>
1776
+ zRange = mprintf(">=(SELECT rid FROM blob"
1777
+ " ORDER BY rid DESC LIMIT 1 OFFSET %d)",n);
17341778
}else{
17351779
zRange = mprintf("BETWEEN %d AND %d", s, s+n-1);
17361780
}
17371781
describe_artifacts(zRange);
17381782
fossil_free(zRange);
17391783
db_prepare(&q,
1740
- "SELECT rid, uuid, summary, isPrivate, type='phantom', rcvid, ref"
1741
- " FROM description ORDER BY rid"
1784
+ /* 0 1 2 3 4 5 6 */
1785
+ "SELECT rid, uuid, summary, isPrivate, type='phantom', ref, rcvid, "
1786
+ " datetime(rcvfrom.mtime)"
1787
+ " FROM description LEFT JOIN rcvfrom USING(rcvid)"
1788
+ " ORDER BY rid %s",
1789
+ ((bRecent||bUnclst)?"DESC":"ASC")/*safe-for-%s*/
17421790
);
17431791
if( skin_detail_boolean("white-foreground") ){
17441792
zSha1Bg = "#714417";
17451793
zSha3Bg = "#177117";
17461794
}else{
17471795
zSha1Bg = "#ebffb0";
17481796
zSha3Bg = "#b0ffb0";
17491797
}
17501798
@ <table cellpadding="2" cellspacing="0" border="1">
1751
- if( g.perm.Admin ){
1752
- @ <tr><th>RID<th>Hash<th>Rcvid<th>Description<th>Ref<th>Remarks
1753
- }else{
1754
- @ <tr><th>RID<th>Hash<th>Description<th>Ref<th>Remarks
1755
- }
1799
+ @ <tr><th>RID<th>Hash<th>Received<th>Description<th>Ref<th>Remarks
17561800
while( db_step(&q)==SQLITE_ROW ){
17571801
int rid = db_column_int(&q,0);
17581802
const char *zUuid = db_column_text(&q, 1);
17591803
const char *zDesc = db_column_text(&q, 2);
17601804
int isPriv = db_column_int(&q,3);
17611805
int isPhantom = db_column_int(&q,4);
1762
- const char *zRef = db_column_text(&q,6);
1806
+ const char *zRef = db_column_text(&q,5);
1807
+ const char *zDate = db_column_text(&q,7);
17631808
if( isPriv && !isPhantom && !g.perm.Private && !g.perm.Admin ){
17641809
/* Don't show private artifacts to users without Private (x) permission */
17651810
continue;
17661811
}
17671812
if( hashClr ){
@@ -1770,16 +1815,14 @@
17701815
}else{
17711816
@ <tr><td align="right">%d(rid)</td>
17721817
}
17731818
@ <td>&nbsp;%z(href("%R/info/%!S",zUuid))%S(zUuid)</a>&nbsp;</td>
17741819
if( g.perm.Admin ){
1775
- int rcvid = db_column_int(&q,5);
1776
- if( rcvid<=0 ){
1777
- @ <td>&nbsp;
1778
- }else{
1779
- @ <td><a href='%R/rcvfrom?rcvid=%d(rcvid)'>%d(rcvid)</a>
1780
- }
1820
+ int rcvid = db_column_int(&q, 6);
1821
+ @ <td><a href='%R/rcvfrom?rcvid=%d(rcvid)'>%h(zDate)</a>
1822
+ }else{
1823
+ @ <td>%h(zDate)
17811824
}
17821825
@ <td align="left">%h(zDesc)</td>
17831826
if( zRef && zRef[0] ){
17841827
@ <td>%z(href("%R/info/%!S",zRef))%S(zRef)</a>
17851828
}else{
@@ -2163,5 +2206,89 @@
21632206
" ORDER BY 1");
21642207
@ <h1>Hash Prefix Collisions on All Artifacts</h1>
21652208
collision_report("SELECT uuid FROM blob ORDER BY 1");
21662209
style_finish_page();
21672210
}
2211
+
2212
+/*
2213
+** WEBPAGE: clusterlist
2214
+**
2215
+** Show information about all cluster artifacts in the database.
2216
+*/
2217
+void clusterlist_page(void){
2218
+ Stmt q;
2219
+ int cnt = 1;
2220
+ sqlite3_int64 szTotal = 0;
2221
+ sqlite3_int64 szCTotal = 0;
2222
+ login_check_credentials();
2223
+ if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
2224
+ style_header("All Cluster Artifacts");
2225
+ style_submenu_element("All Artifactst", "bloblist");
2226
+ if( g.perm.Admin ){
2227
+ style_submenu_element("Artifact Log", "rcvfromlist");
2228
+ }
2229
+ style_submenu_element("Phantoms", "bloblist?phan");
2230
+ if( g.perm.Write ){
2231
+ style_submenu_element("Artifact Stats", "artifact_stats");
2232
+ }
2233
+
2234
+ db_prepare(&q,
2235
+ "SELECT blob.uuid, "
2236
+ " blob.size, "
2237
+ " octet_length(blob.content), "
2238
+ " datetime(rcvfrom.mtime),"
2239
+ " user.login,"
2240
+ " rcvfrom.ipaddr"
2241
+ " FROM tagxref JOIN blob ON tagxref.rid=blob.rid"
2242
+ " LEFT JOIN rcvfrom ON blob.rcvid=rcvfrom.rcvid"
2243
+ " LEFT JOIN user ON user.uid=rcvfrom.uid"
2244
+ " WHERE tagxref.tagid=%d"
2245
+ " ORDER BY rcvfrom.mtime, blob.uuid",
2246
+ TAG_CLUSTER
2247
+ );
2248
+ @ <table cellpadding="2" cellspacing="0" border="1">
2249
+ @ <tr><th>&nbsp;
2250
+ @ <th>Hash
2251
+ @ <th>Date&nbsp;Received
2252
+ @ <th>Size
2253
+ @ <th>Compressed&nbsp;Size
2254
+ if( g.perm.Admin ){
2255
+ @ <th>User<th>IP-Address
2256
+ }
2257
+ while( db_step(&q)==SQLITE_ROW ){
2258
+ const char *zUuid = db_column_text(&q, 0);
2259
+ sqlite3_int64 sz = db_column_int64(&q, 1);
2260
+ sqlite3_int64 szC = db_column_int64(&q, 2);
2261
+ const char *zDate = db_column_text(&q, 3);
2262
+ const char *zUser = db_column_text(&q, 4);
2263
+ const char *zIp = db_column_text(&q, 5);
2264
+ szTotal += sz;
2265
+ szCTotal += szC;
2266
+ @ <tr><td align="right">%d(cnt++)
2267
+ @ <td><a href="%R/info/%S(zUuid)">%S(zUuid)</a>
2268
+ if( zDate ){
2269
+ @ <td>%h(zDate)
2270
+ }else{
2271
+ @ <td>&nbsp;
2272
+ }
2273
+ @ <td align="right">%,lld(sz)
2274
+ @ <td align="right">%,lld(szC)
2275
+ if( g.perm.Admin ){
2276
+ if( zUser ){
2277
+ @ <td>%h(zUser)
2278
+ }else{
2279
+ @ <td>&nbsp;
2280
+ }
2281
+ if( zIp ){
2282
+ @ <td>%h(zIp)
2283
+ }else{
2284
+ @ <td>&nbsp;
2285
+ }
2286
+ }
2287
+ @ </tr>
2288
+ }
2289
+ @ </table>
2290
+ db_finalize(&q);
2291
+ @ <p>Total size of all clusters: %,lld(szTotal) bytes,
2292
+ @ %,lld(szCTotal) bytes compressed</p>
2293
+ style_finish_page();
2294
+}
21682295
--- src/name.c
+++ src/name.c
@@ -65,33 +65,51 @@
65 ** the string is a hash prefix and NULL is returned if it is. If the
66 ** bVerifyNotAHash flag is false, then the result is determined by syntax
67 ** of the input string only, without reference to the artifact table.
68 */
69 char *fossil_expand_datetime(const char *zIn, int bVerifyNotAHash){
70 static char zEDate[20];
71 static const char aPunct[] = { 0, 0, '-', '-', ' ', ':', ':' };
72 int n = (int)strlen(zIn);
73 int i, j;
 
74
75 /* Only three forms allowed:
76 ** (1) YYYYMMDD
77 ** (2) YYYYMMDDHHMM
78 ** (3) YYYYMMDDHHMMSS
 
 
 
 
79 */
80 if( n!=8 && n!=12 && n!=14 ) return 0;
 
 
 
 
 
 
81
82 /* Every character must be a digit */
83 for(i=0; fossil_isdigit(zIn[i]); i++){}
84 if( i!=n ) return 0;
85
86 /* Expand the date */
87 for(i=j=0; zIn[i]; i++){
88 if( i>=4 && (i%2)==0 ){
89 zEDate[j++] = aPunct[i/2];
90 }
91 zEDate[j++] = zIn[i];
92 }
 
 
 
 
 
 
 
93 zEDate[j] = 0;
94
95 /* Check for reasonable date values.
96 ** Offset references:
97 ** YYYY-MM-DD HH:MM:SS
@@ -111,11 +129,11 @@
111 if( i>60 ) return 0;
112 if( n==14 && atoi(zEDate+17)>60 ) return 0;
113 }
114
115 /* The string is not also a hash prefix */
116 if( bVerifyNotAHash ){
117 if( db_exists("SELECT 1 FROM blob WHERE uuid GLOB '%q*'",zIn) ) return 0;
118 }
119
120 /* It looks like this may be a date. Return it with punctuation added. */
121 return zEDate;
@@ -453,10 +471,12 @@
453 }else if( fossil_strcmp(zTag, "next")==0 ){
454 rid = db_int(0, "SELECT cid FROM plink WHERE pid=%d"
455 " ORDER BY isprim DESC, mtime DESC", ridCkout);
456 }else if( isCheckin>1 && fossil_strcmp(zTag, "ckout")==0 ){
457 rid = RID_CKOUT;
 
 
458 }
459 if( rid ) return rid;
460 }
461
462 /* Date and times */
@@ -699,10 +719,13 @@
699 }else if( rid==0 ){
700 fossil_error(iErrPriority, "cannot resolve name: %s", zName);
701 return 1;
702 }else{
703 blob_reset(pName);
 
 
 
704 db_blob(pName, "SELECT uuid FROM blob WHERE rid=%d", rid);
705 return 0;
706 }
707 }
708
@@ -1676,34 +1699,44 @@
1676 ** n=N Show N artifacts
1677 ** s=S Start with artifact number S
1678 ** priv Show only unpublished or private artifacts
1679 ** phan Show only phantom artifacts
1680 ** hclr Color code hash types (SHA1 vs SHA3)
 
1681 */
1682 void bloblist_page(void){
1683 Stmt q;
1684 int s = atoi(PD("s","0"));
1685 int n = atoi(PD("n","5000"));
1686 int mx = db_int(0, "SELECT max(rid) FROM blob");
1687 int privOnly = PB("priv");
1688 int phantomOnly = PB("phan");
1689 int hashClr = PB("hclr");
 
 
1690 char *zRange;
1691 char *zSha1Bg;
1692 char *zSha3Bg;
1693
1694 login_check_credentials();
1695 if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
1696 cgi_check_for_malice();
1697 style_header("List Of Artifacts");
1698 style_submenu_element("250 Largest", "bigbloblist");
 
 
 
 
 
 
1699 if( g.perm.Admin ){
1700 style_submenu_element("Artifact Log", "rcvfromlist");
1701 }
1702 if( !phantomOnly ){
1703 style_submenu_element("Phantoms", "bloblist?phan");
1704 }
 
1705 if( g.perm.Private || g.perm.Admin ){
1706 if( !privOnly ){
1707 style_submenu_element("Private", "bloblist?priv");
1708 }
1709 }else{
@@ -1710,58 +1743,70 @@
1710 privOnly = 0;
1711 }
1712 if( g.perm.Write ){
1713 style_submenu_element("Artifact Stats", "artifact_stats");
1714 }
1715 if( !privOnly && !phantomOnly && mx>n && P("s")==0 ){
1716 int i;
1717 @ <p>Select a range of artifacts to view:</p>
1718 @ <ul>
1719 for(i=1; i<=mx; i+=n){
1720 @ <li> %z(href("%R/bloblist?s=%d&n=%d",i,n))
1721 @ %d(i)..%d(i+n-1<mx?i+n-1:mx)</a>
1722 }
 
 
1723 @ </ul>
1724 style_finish_page();
1725 return;
1726 }
1727 if( phantomOnly || privOnly || mx>n ){
1728 style_submenu_element("Index", "bloblist");
1729 }
1730 if( privOnly ){
 
1731 zRange = mprintf("IN private");
1732 }else if( phantomOnly ){
 
1733 zRange = mprintf("IN phantom");
 
 
 
 
 
 
 
1734 }else{
1735 zRange = mprintf("BETWEEN %d AND %d", s, s+n-1);
1736 }
1737 describe_artifacts(zRange);
1738 fossil_free(zRange);
1739 db_prepare(&q,
1740 "SELECT rid, uuid, summary, isPrivate, type='phantom', rcvid, ref"
1741 " FROM description ORDER BY rid"
 
 
 
 
1742 );
1743 if( skin_detail_boolean("white-foreground") ){
1744 zSha1Bg = "#714417";
1745 zSha3Bg = "#177117";
1746 }else{
1747 zSha1Bg = "#ebffb0";
1748 zSha3Bg = "#b0ffb0";
1749 }
1750 @ <table cellpadding="2" cellspacing="0" border="1">
1751 if( g.perm.Admin ){
1752 @ <tr><th>RID<th>Hash<th>Rcvid<th>Description<th>Ref<th>Remarks
1753 }else{
1754 @ <tr><th>RID<th>Hash<th>Description<th>Ref<th>Remarks
1755 }
1756 while( db_step(&q)==SQLITE_ROW ){
1757 int rid = db_column_int(&q,0);
1758 const char *zUuid = db_column_text(&q, 1);
1759 const char *zDesc = db_column_text(&q, 2);
1760 int isPriv = db_column_int(&q,3);
1761 int isPhantom = db_column_int(&q,4);
1762 const char *zRef = db_column_text(&q,6);
 
1763 if( isPriv && !isPhantom && !g.perm.Private && !g.perm.Admin ){
1764 /* Don't show private artifacts to users without Private (x) permission */
1765 continue;
1766 }
1767 if( hashClr ){
@@ -1770,16 +1815,14 @@
1770 }else{
1771 @ <tr><td align="right">%d(rid)</td>
1772 }
1773 @ <td>&nbsp;%z(href("%R/info/%!S",zUuid))%S(zUuid)</a>&nbsp;</td>
1774 if( g.perm.Admin ){
1775 int rcvid = db_column_int(&q,5);
1776 if( rcvid<=0 ){
1777 @ <td>&nbsp;
1778 }else{
1779 @ <td><a href='%R/rcvfrom?rcvid=%d(rcvid)'>%d(rcvid)</a>
1780 }
1781 }
1782 @ <td align="left">%h(zDesc)</td>
1783 if( zRef && zRef[0] ){
1784 @ <td>%z(href("%R/info/%!S",zRef))%S(zRef)</a>
1785 }else{
@@ -2163,5 +2206,89 @@
2163 " ORDER BY 1");
2164 @ <h1>Hash Prefix Collisions on All Artifacts</h1>
2165 collision_report("SELECT uuid FROM blob ORDER BY 1");
2166 style_finish_page();
2167 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2168
--- src/name.c
+++ src/name.c
@@ -65,33 +65,51 @@
65 ** the string is a hash prefix and NULL is returned if it is. If the
66 ** bVerifyNotAHash flag is false, then the result is determined by syntax
67 ** of the input string only, without reference to the artifact table.
68 */
69 char *fossil_expand_datetime(const char *zIn, int bVerifyNotAHash){
70 static char zEDate[24];
71 static const char aPunct[] = { 0, 0, '-', '-', ' ', ':', ':' };
72 int n = (int)strlen(zIn);
73 int i, j;
74 int addZulu = 0;
75
76 /* These forms are allowed:
77 **
78 ** 123456789 1234 123456789 123456789
79 ** (1) YYYYMMDD => YYYY-MM-DD
80 ** (2) YYYYMMDDHHMM => YYYY-MM-DD HH:MM
81 ** (3) YYYYMMDDHHMMSS => YYYY-MM-DD HH:MM:SS
82 **
83 ** An optional "Z" zulu timezone designator is allowed at the end.
84 */
85 if( n>0 && (zIn[n-1]=='Z' || zIn[n-1]=='z') ){
86 n--;
87 addZulu = 1;
88 }
89 if( n!=8 && n!=12 && n!=14 ){
90 return 0;
91 }
92
93 /* Every character must be a digit */
94 for(i=0; fossil_isdigit(zIn[i]); i++){}
95 if( i!=n && (!addZulu || i!=n+1) ) return 0;
96
97 /* Expand the date */
98 for(i=j=0; i<n; i++){
99 if( i>=4 && (i%2)==0 ){
100 zEDate[j++] = aPunct[i/2];
101 }
102 zEDate[j++] = zIn[i];
103 }
104 if( addZulu ){
105 if( j==10 ){
106 memcpy(&zEDate[10]," 00:00", 6);
107 j += 6;
108 }
109 zEDate[j++] = 'Z';
110 }
111 zEDate[j] = 0;
112
113 /* Check for reasonable date values.
114 ** Offset references:
115 ** YYYY-MM-DD HH:MM:SS
@@ -111,11 +129,11 @@
129 if( i>60 ) return 0;
130 if( n==14 && atoi(zEDate+17)>60 ) return 0;
131 }
132
133 /* The string is not also a hash prefix */
134 if( bVerifyNotAHash && !addZulu ){
135 if( db_exists("SELECT 1 FROM blob WHERE uuid GLOB '%q*'",zIn) ) return 0;
136 }
137
138 /* It looks like this may be a date. Return it with punctuation added. */
139 return zEDate;
@@ -453,10 +471,12 @@
471 }else if( fossil_strcmp(zTag, "next")==0 ){
472 rid = db_int(0, "SELECT cid FROM plink WHERE pid=%d"
473 " ORDER BY isprim DESC, mtime DESC", ridCkout);
474 }else if( isCheckin>1 && fossil_strcmp(zTag, "ckout")==0 ){
475 rid = RID_CKOUT;
476 assert(ridCkout>0);
477 g.localOpen = ridCkout;
478 }
479 if( rid ) return rid;
480 }
481
482 /* Date and times */
@@ -699,10 +719,13 @@
719 }else if( rid==0 ){
720 fossil_error(iErrPriority, "cannot resolve name: %s", zName);
721 return 1;
722 }else{
723 blob_reset(pName);
724 if( RID_CKOUT==rid ) {
725 rid = g.localOpen;
726 }
727 db_blob(pName, "SELECT uuid FROM blob WHERE rid=%d", rid);
728 return 0;
729 }
730 }
731
@@ -1676,34 +1699,44 @@
1699 ** n=N Show N artifacts
1700 ** s=S Start with artifact number S
1701 ** priv Show only unpublished or private artifacts
1702 ** phan Show only phantom artifacts
1703 ** hclr Color code hash types (SHA1 vs SHA3)
1704 ** recent Show the most recent N artifacts
1705 */
1706 void bloblist_page(void){
1707 Stmt q;
1708 int s = atoi(PD("s","0"));
1709 int n = atoi(PD("n","5000"));
1710 int mx = db_int(0, "SELECT max(rid) FROM blob");
1711 int privOnly = PB("priv");
1712 int phantomOnly = PB("phan");
1713 int hashClr = PB("hclr");
1714 int bRecent = PB("recent");
1715 int bUnclst = PB("unclustered");
1716 char *zRange;
1717 char *zSha1Bg;
1718 char *zSha3Bg;
1719
1720 login_check_credentials();
1721 if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
1722 cgi_check_for_malice();
1723 style_header("List Of Artifacts");
1724 style_submenu_element("250 Largest", "bigbloblist");
1725 if( bRecent==0 || n!=250 ){
1726 style_submenu_element("Recent","bloblist?n=250&recent");
1727 }
1728 if( bUnclst==0 ){
1729 style_submenu_element("Unclustered","bloblist?unclustered");
1730 }
1731 if( g.perm.Admin ){
1732 style_submenu_element("Artifact Log", "rcvfromlist");
1733 }
1734 if( !phantomOnly ){
1735 style_submenu_element("Phantoms", "bloblist?phan");
1736 }
1737 style_submenu_element("Clusters","clusterlist");
1738 if( g.perm.Private || g.perm.Admin ){
1739 if( !privOnly ){
1740 style_submenu_element("Private", "bloblist?priv");
1741 }
1742 }else{
@@ -1710,58 +1743,70 @@
1743 privOnly = 0;
1744 }
1745 if( g.perm.Write ){
1746 style_submenu_element("Artifact Stats", "artifact_stats");
1747 }
1748 if( !privOnly && !phantomOnly && mx>n && P("s")==0 && !bRecent && !bUnclst ){
1749 int i;
1750 @ <p>Select a range of artifacts to view:</p>
1751 @ <ul>
1752 for(i=1; i<=mx; i+=n){
1753 @ <li> %z(href("%R/bloblist?s=%d&n=%d",i,n))
1754 @ %d(i)..%d(i+n-1<mx?i+n-1:mx)</a>
1755 }
1756 @ <li> %z(href("%R/bloblist?n=250&recent"))250 most recent</a>
1757 @ <li> %z(href("%R/bloblist?unclustered"))All unclustered</a>
1758 @ </ul>
1759 style_finish_page();
1760 return;
1761 }
1762 if( phantomOnly || privOnly || mx>n ){
1763 style_submenu_element("Index", "bloblist");
1764 }
1765 if( privOnly ){
1766 @ <h2>Private Artifacts</h2>
1767 zRange = mprintf("IN private");
1768 }else if( phantomOnly ){
1769 @ <h2>Phantom Artifacts</h2>
1770 zRange = mprintf("IN phantom");
1771 }else if( bUnclst ){
1772 @ <h2>Unclustered Artifacts</h2>
1773 zRange = mprintf("IN unclustered");
1774 }else if( bRecent ){
1775 @ <h2>%d(n) Most Recent Artifacts</h2>
1776 zRange = mprintf(">=(SELECT rid FROM blob"
1777 " ORDER BY rid DESC LIMIT 1 OFFSET %d)",n);
1778 }else{
1779 zRange = mprintf("BETWEEN %d AND %d", s, s+n-1);
1780 }
1781 describe_artifacts(zRange);
1782 fossil_free(zRange);
1783 db_prepare(&q,
1784 /* 0 1 2 3 4 5 6 */
1785 "SELECT rid, uuid, summary, isPrivate, type='phantom', ref, rcvid, "
1786 " datetime(rcvfrom.mtime)"
1787 " FROM description LEFT JOIN rcvfrom USING(rcvid)"
1788 " ORDER BY rid %s",
1789 ((bRecent||bUnclst)?"DESC":"ASC")/*safe-for-%s*/
1790 );
1791 if( skin_detail_boolean("white-foreground") ){
1792 zSha1Bg = "#714417";
1793 zSha3Bg = "#177117";
1794 }else{
1795 zSha1Bg = "#ebffb0";
1796 zSha3Bg = "#b0ffb0";
1797 }
1798 @ <table cellpadding="2" cellspacing="0" border="1">
1799 @ <tr><th>RID<th>Hash<th>Received<th>Description<th>Ref<th>Remarks
 
 
 
 
1800 while( db_step(&q)==SQLITE_ROW ){
1801 int rid = db_column_int(&q,0);
1802 const char *zUuid = db_column_text(&q, 1);
1803 const char *zDesc = db_column_text(&q, 2);
1804 int isPriv = db_column_int(&q,3);
1805 int isPhantom = db_column_int(&q,4);
1806 const char *zRef = db_column_text(&q,5);
1807 const char *zDate = db_column_text(&q,7);
1808 if( isPriv && !isPhantom && !g.perm.Private && !g.perm.Admin ){
1809 /* Don't show private artifacts to users without Private (x) permission */
1810 continue;
1811 }
1812 if( hashClr ){
@@ -1770,16 +1815,14 @@
1815 }else{
1816 @ <tr><td align="right">%d(rid)</td>
1817 }
1818 @ <td>&nbsp;%z(href("%R/info/%!S",zUuid))%S(zUuid)</a>&nbsp;</td>
1819 if( g.perm.Admin ){
1820 int rcvid = db_column_int(&q, 6);
1821 @ <td><a href='%R/rcvfrom?rcvid=%d(rcvid)'>%h(zDate)</a>
1822 }else{
1823 @ <td>%h(zDate)
 
 
1824 }
1825 @ <td align="left">%h(zDesc)</td>
1826 if( zRef && zRef[0] ){
1827 @ <td>%z(href("%R/info/%!S",zRef))%S(zRef)</a>
1828 }else{
@@ -2163,5 +2206,89 @@
2206 " ORDER BY 1");
2207 @ <h1>Hash Prefix Collisions on All Artifacts</h1>
2208 collision_report("SELECT uuid FROM blob ORDER BY 1");
2209 style_finish_page();
2210 }
2211
2212 /*
2213 ** WEBPAGE: clusterlist
2214 **
2215 ** Show information about all cluster artifacts in the database.
2216 */
2217 void clusterlist_page(void){
2218 Stmt q;
2219 int cnt = 1;
2220 sqlite3_int64 szTotal = 0;
2221 sqlite3_int64 szCTotal = 0;
2222 login_check_credentials();
2223 if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
2224 style_header("All Cluster Artifacts");
2225 style_submenu_element("All Artifactst", "bloblist");
2226 if( g.perm.Admin ){
2227 style_submenu_element("Artifact Log", "rcvfromlist");
2228 }
2229 style_submenu_element("Phantoms", "bloblist?phan");
2230 if( g.perm.Write ){
2231 style_submenu_element("Artifact Stats", "artifact_stats");
2232 }
2233
2234 db_prepare(&q,
2235 "SELECT blob.uuid, "
2236 " blob.size, "
2237 " octet_length(blob.content), "
2238 " datetime(rcvfrom.mtime),"
2239 " user.login,"
2240 " rcvfrom.ipaddr"
2241 " FROM tagxref JOIN blob ON tagxref.rid=blob.rid"
2242 " LEFT JOIN rcvfrom ON blob.rcvid=rcvfrom.rcvid"
2243 " LEFT JOIN user ON user.uid=rcvfrom.uid"
2244 " WHERE tagxref.tagid=%d"
2245 " ORDER BY rcvfrom.mtime, blob.uuid",
2246 TAG_CLUSTER
2247 );
2248 @ <table cellpadding="2" cellspacing="0" border="1">
2249 @ <tr><th>&nbsp;
2250 @ <th>Hash
2251 @ <th>Date&nbsp;Received
2252 @ <th>Size
2253 @ <th>Compressed&nbsp;Size
2254 if( g.perm.Admin ){
2255 @ <th>User<th>IP-Address
2256 }
2257 while( db_step(&q)==SQLITE_ROW ){
2258 const char *zUuid = db_column_text(&q, 0);
2259 sqlite3_int64 sz = db_column_int64(&q, 1);
2260 sqlite3_int64 szC = db_column_int64(&q, 2);
2261 const char *zDate = db_column_text(&q, 3);
2262 const char *zUser = db_column_text(&q, 4);
2263 const char *zIp = db_column_text(&q, 5);
2264 szTotal += sz;
2265 szCTotal += szC;
2266 @ <tr><td align="right">%d(cnt++)
2267 @ <td><a href="%R/info/%S(zUuid)">%S(zUuid)</a>
2268 if( zDate ){
2269 @ <td>%h(zDate)
2270 }else{
2271 @ <td>&nbsp;
2272 }
2273 @ <td align="right">%,lld(sz)
2274 @ <td align="right">%,lld(szC)
2275 if( g.perm.Admin ){
2276 if( zUser ){
2277 @ <td>%h(zUser)
2278 }else{
2279 @ <td>&nbsp;
2280 }
2281 if( zIp ){
2282 @ <td>%h(zIp)
2283 }else{
2284 @ <td>&nbsp;
2285 }
2286 }
2287 @ </tr>
2288 }
2289 @ </table>
2290 db_finalize(&q);
2291 @ <p>Total size of all clusters: %,lld(szTotal) bytes,
2292 @ %,lld(szCTotal) bytes compressed</p>
2293 style_finish_page();
2294 }
2295
+50 -17
--- src/patch.c
+++ src/patch.c
@@ -81,13 +81,12 @@
8181
sqlite3_context *context,
8282
int argc,
8383
sqlite3_value **argv
8484
){
8585
const char *zFile;
86
- Blob x, y;
86
+ Blob x, y, out;
8787
int rid;
88
- char *aOut;
8988
int nOut;
9089
sqlite3_int64 sz;
9190
9291
rid = sqlite3_value_int(argv[0]);
9392
if( !content_get(rid, &x) ){
@@ -104,34 +103,29 @@
104103
if( sz<0 ){
105104
sqlite3_result_error(context, "mkdelta(X,Y): cannot read file Y", -1);
106105
blob_reset(&x);
107106
return;
108107
}
109
- aOut = sqlite3_malloc64(sz+70);
110
- if( aOut==0 ){
111
- sqlite3_result_error_nomem(context);
112
- blob_reset(&y);
113
- blob_reset(&x);
114
- return;
115
- }
108
+ blob_init(&out, 0, 0);
109
+ blob_resize(&out, sz+70);
116110
if( blob_size(&x)==blob_size(&y)
117111
&& memcmp(blob_buffer(&x), blob_buffer(&y), blob_size(&x))==0
118112
){
119113
blob_reset(&y);
120114
blob_reset(&x);
121115
sqlite3_result_blob64(context, "", 0, SQLITE_STATIC);
122116
return;
123117
}
124118
nOut = delta_create(blob_buffer(&x),blob_size(&x),
125
- blob_buffer(&y),blob_size(&y), aOut);
119
+ blob_buffer(&y),blob_size(&y), blob_buffer(&out));
120
+ blob_resize(&out, nOut);
126121
blob_reset(&x);
127122
blob_reset(&y);
128
- blob_init(&x, aOut, nOut);
129
- blob_compress(&x, &x);
130
- sqlite3_result_blob64(context, blob_buffer(&x), blob_size(&x),
123
+ blob_compress(&out, &out);
124
+ sqlite3_result_blob64(context, blob_buffer(&out), blob_size(&out),
131125
SQLITE_TRANSIENT);
132
- blob_reset(&x);
126
+ blob_reset(&out);
133127
}
134128
135129
136130
/*
137131
** Generate a binary patch file and store it into the file
@@ -387,11 +381,11 @@
387381
if( unsaved_changes(0) ){
388382
if( (mFlags & PATCH_FORCE)==0 ){
389383
fossil_fatal("Cannot apply patch: there are unsaved changes "
390384
"in the current check-out");
391385
}else{
392
- blob_appendf(&cmd, "%$ revert", g.nameOfExe);
386
+ blob_appendf(&cmd, "%$ revert --noundo", g.nameOfExe);
393387
if( mFlags & PATCH_DRYRUN ){
394388
fossil_print("%s\n", blob_str(&cmd));
395389
}else{
396390
int rc = fossil_system(blob_str(&cmd));
397391
if( rc ){
@@ -429,23 +423,27 @@
429423
}
430424
}
431425
}
432426
blob_reset(&cmd);
433427
if( db_table_exists("patch","patchmerge") ){
428
+ int nMerge = 0;
434429
db_prepare(&q,
435430
"SELECT type, mhash, upper(type) FROM patch.patchmerge"
436431
" WHERE type IN ('merge','cherrypick','backout','integrate')"
437432
" AND mhash NOT GLOB '*[^a-fA-F0-9]*';"
438433
);
439434
while( db_step(&q)==SQLITE_ROW ){
440435
const char *zType = db_column_text(&q,0);
441436
blob_append_escaped_arg(&cmd, g.nameOfExe, 1);
442437
if( strcmp(zType,"merge")==0 ){
443
- blob_appendf(&cmd, " merge %s\n", db_column_text(&q,1));
438
+ blob_appendf(&cmd, " merge --noundo --nosync %s\n",
439
+ db_column_text(&q,1));
444440
}else{
445
- blob_appendf(&cmd, " merge --%s %s\n", zType, db_column_text(&q,1));
441
+ blob_appendf(&cmd, " merge --%s --noundo --nosync %s\n",
442
+ zType, db_column_text(&q,1));
446443
}
444
+ nMerge++;
447445
if( mFlags & PATCH_VERBOSE ){
448446
fossil_print("%-10s %s\n", db_column_text(&q,2),
449447
db_column_text(&q,0));
450448
}
451449
}
@@ -458,10 +456,45 @@
458456
fossil_fatal("unable to do merges:\n%s",
459457
blob_str(&cmd));
460458
}
461459
}
462460
blob_reset(&cmd);
461
+
462
+ /* 2024-12-16 https://fossil-scm.org/home/forumpost/51a37054
463
+ ** If one or more merge operations occurred in the patch and there are
464
+ ** files that are marked as "chnged' in the local VFILE but which
465
+ ** are not mentioned as having been modified in the patch, then
466
+ ** revert those files.
467
+ */
468
+ if( nMerge ){
469
+ int vid = db_lget_int("checkout", 0);
470
+ int nRevert = 0;
471
+ blob_append_escaped_arg(&cmd, g.nameOfExe, 1);
472
+ blob_appendf(&cmd, " revert --noundo ");
473
+ db_prepare(&q,
474
+ "SELECT pathname FROM vfile WHERE vid=%d AND chnged "
475
+ "EXCEPT SELECT pathname FROM chng",
476
+ vid
477
+ );
478
+ while( db_step(&q)==SQLITE_ROW ){
479
+ blob_append_escaped_arg(&cmd, db_column_text(&q,0), 1);
480
+ nRevert++;
481
+ }
482
+ db_finalize(&q);
483
+ if( nRevert ){
484
+ if( mFlags & PATCH_DRYRUN ){
485
+ fossil_print("%s", blob_str(&cmd));
486
+ }else{
487
+ int rc = fossil_unsafe_system(blob_str(&cmd));
488
+ if( rc ){
489
+ fossil_fatal("unable to do reverts:\n%s",
490
+ blob_str(&cmd));
491
+ }
492
+ }
493
+ }
494
+ blob_reset(&cmd);
495
+ }
463496
}
464497
465498
/* Deletions */
466499
db_prepare(&q, "SELECT pathname FROM patch.chng"
467500
" WHERE origname IS NULL AND delta IS NULL");
468501
--- src/patch.c
+++ src/patch.c
@@ -81,13 +81,12 @@
81 sqlite3_context *context,
82 int argc,
83 sqlite3_value **argv
84 ){
85 const char *zFile;
86 Blob x, y;
87 int rid;
88 char *aOut;
89 int nOut;
90 sqlite3_int64 sz;
91
92 rid = sqlite3_value_int(argv[0]);
93 if( !content_get(rid, &x) ){
@@ -104,34 +103,29 @@
104 if( sz<0 ){
105 sqlite3_result_error(context, "mkdelta(X,Y): cannot read file Y", -1);
106 blob_reset(&x);
107 return;
108 }
109 aOut = sqlite3_malloc64(sz+70);
110 if( aOut==0 ){
111 sqlite3_result_error_nomem(context);
112 blob_reset(&y);
113 blob_reset(&x);
114 return;
115 }
116 if( blob_size(&x)==blob_size(&y)
117 && memcmp(blob_buffer(&x), blob_buffer(&y), blob_size(&x))==0
118 ){
119 blob_reset(&y);
120 blob_reset(&x);
121 sqlite3_result_blob64(context, "", 0, SQLITE_STATIC);
122 return;
123 }
124 nOut = delta_create(blob_buffer(&x),blob_size(&x),
125 blob_buffer(&y),blob_size(&y), aOut);
 
126 blob_reset(&x);
127 blob_reset(&y);
128 blob_init(&x, aOut, nOut);
129 blob_compress(&x, &x);
130 sqlite3_result_blob64(context, blob_buffer(&x), blob_size(&x),
131 SQLITE_TRANSIENT);
132 blob_reset(&x);
133 }
134
135
136 /*
137 ** Generate a binary patch file and store it into the file
@@ -387,11 +381,11 @@
387 if( unsaved_changes(0) ){
388 if( (mFlags & PATCH_FORCE)==0 ){
389 fossil_fatal("Cannot apply patch: there are unsaved changes "
390 "in the current check-out");
391 }else{
392 blob_appendf(&cmd, "%$ revert", g.nameOfExe);
393 if( mFlags & PATCH_DRYRUN ){
394 fossil_print("%s\n", blob_str(&cmd));
395 }else{
396 int rc = fossil_system(blob_str(&cmd));
397 if( rc ){
@@ -429,23 +423,27 @@
429 }
430 }
431 }
432 blob_reset(&cmd);
433 if( db_table_exists("patch","patchmerge") ){
 
434 db_prepare(&q,
435 "SELECT type, mhash, upper(type) FROM patch.patchmerge"
436 " WHERE type IN ('merge','cherrypick','backout','integrate')"
437 " AND mhash NOT GLOB '*[^a-fA-F0-9]*';"
438 );
439 while( db_step(&q)==SQLITE_ROW ){
440 const char *zType = db_column_text(&q,0);
441 blob_append_escaped_arg(&cmd, g.nameOfExe, 1);
442 if( strcmp(zType,"merge")==0 ){
443 blob_appendf(&cmd, " merge %s\n", db_column_text(&q,1));
 
444 }else{
445 blob_appendf(&cmd, " merge --%s %s\n", zType, db_column_text(&q,1));
 
446 }
 
447 if( mFlags & PATCH_VERBOSE ){
448 fossil_print("%-10s %s\n", db_column_text(&q,2),
449 db_column_text(&q,0));
450 }
451 }
@@ -458,10 +456,45 @@
458 fossil_fatal("unable to do merges:\n%s",
459 blob_str(&cmd));
460 }
461 }
462 blob_reset(&cmd);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
463 }
464
465 /* Deletions */
466 db_prepare(&q, "SELECT pathname FROM patch.chng"
467 " WHERE origname IS NULL AND delta IS NULL");
468
--- src/patch.c
+++ src/patch.c
@@ -81,13 +81,12 @@
81 sqlite3_context *context,
82 int argc,
83 sqlite3_value **argv
84 ){
85 const char *zFile;
86 Blob x, y, out;
87 int rid;
 
88 int nOut;
89 sqlite3_int64 sz;
90
91 rid = sqlite3_value_int(argv[0]);
92 if( !content_get(rid, &x) ){
@@ -104,34 +103,29 @@
103 if( sz<0 ){
104 sqlite3_result_error(context, "mkdelta(X,Y): cannot read file Y", -1);
105 blob_reset(&x);
106 return;
107 }
108 blob_init(&out, 0, 0);
109 blob_resize(&out, sz+70);
 
 
 
 
 
110 if( blob_size(&x)==blob_size(&y)
111 && memcmp(blob_buffer(&x), blob_buffer(&y), blob_size(&x))==0
112 ){
113 blob_reset(&y);
114 blob_reset(&x);
115 sqlite3_result_blob64(context, "", 0, SQLITE_STATIC);
116 return;
117 }
118 nOut = delta_create(blob_buffer(&x),blob_size(&x),
119 blob_buffer(&y),blob_size(&y), blob_buffer(&out));
120 blob_resize(&out, nOut);
121 blob_reset(&x);
122 blob_reset(&y);
123 blob_compress(&out, &out);
124 sqlite3_result_blob64(context, blob_buffer(&out), blob_size(&out),
 
125 SQLITE_TRANSIENT);
126 blob_reset(&out);
127 }
128
129
130 /*
131 ** Generate a binary patch file and store it into the file
@@ -387,11 +381,11 @@
381 if( unsaved_changes(0) ){
382 if( (mFlags & PATCH_FORCE)==0 ){
383 fossil_fatal("Cannot apply patch: there are unsaved changes "
384 "in the current check-out");
385 }else{
386 blob_appendf(&cmd, "%$ revert --noundo", g.nameOfExe);
387 if( mFlags & PATCH_DRYRUN ){
388 fossil_print("%s\n", blob_str(&cmd));
389 }else{
390 int rc = fossil_system(blob_str(&cmd));
391 if( rc ){
@@ -429,23 +423,27 @@
423 }
424 }
425 }
426 blob_reset(&cmd);
427 if( db_table_exists("patch","patchmerge") ){
428 int nMerge = 0;
429 db_prepare(&q,
430 "SELECT type, mhash, upper(type) FROM patch.patchmerge"
431 " WHERE type IN ('merge','cherrypick','backout','integrate')"
432 " AND mhash NOT GLOB '*[^a-fA-F0-9]*';"
433 );
434 while( db_step(&q)==SQLITE_ROW ){
435 const char *zType = db_column_text(&q,0);
436 blob_append_escaped_arg(&cmd, g.nameOfExe, 1);
437 if( strcmp(zType,"merge")==0 ){
438 blob_appendf(&cmd, " merge --noundo --nosync %s\n",
439 db_column_text(&q,1));
440 }else{
441 blob_appendf(&cmd, " merge --%s --noundo --nosync %s\n",
442 zType, db_column_text(&q,1));
443 }
444 nMerge++;
445 if( mFlags & PATCH_VERBOSE ){
446 fossil_print("%-10s %s\n", db_column_text(&q,2),
447 db_column_text(&q,0));
448 }
449 }
@@ -458,10 +456,45 @@
456 fossil_fatal("unable to do merges:\n%s",
457 blob_str(&cmd));
458 }
459 }
460 blob_reset(&cmd);
461
462 /* 2024-12-16 https://fossil-scm.org/home/forumpost/51a37054
463 ** If one or more merge operations occurred in the patch and there are
464 ** files that are marked as "chnged' in the local VFILE but which
465 ** are not mentioned as having been modified in the patch, then
466 ** revert those files.
467 */
468 if( nMerge ){
469 int vid = db_lget_int("checkout", 0);
470 int nRevert = 0;
471 blob_append_escaped_arg(&cmd, g.nameOfExe, 1);
472 blob_appendf(&cmd, " revert --noundo ");
473 db_prepare(&q,
474 "SELECT pathname FROM vfile WHERE vid=%d AND chnged "
475 "EXCEPT SELECT pathname FROM chng",
476 vid
477 );
478 while( db_step(&q)==SQLITE_ROW ){
479 blob_append_escaped_arg(&cmd, db_column_text(&q,0), 1);
480 nRevert++;
481 }
482 db_finalize(&q);
483 if( nRevert ){
484 if( mFlags & PATCH_DRYRUN ){
485 fossil_print("%s", blob_str(&cmd));
486 }else{
487 int rc = fossil_unsafe_system(blob_str(&cmd));
488 if( rc ){
489 fossil_fatal("unable to do reverts:\n%s",
490 blob_str(&cmd));
491 }
492 }
493 }
494 blob_reset(&cmd);
495 }
496 }
497
498 /* Deletions */
499 db_prepare(&q, "SELECT pathname FROM patch.chng"
500 " WHERE origname IS NULL AND delta IS NULL");
501
+14 -1
--- src/printf.c
+++ src/printf.c
@@ -105,10 +105,11 @@
105105
Use %!j to include double-quotes around it. */
106106
#define etSHELLESC 26 /* Escape a filename for use in a shell command: %$
107107
See blob_append_escaped_arg() for details
108108
"%$" -> adds "./" prefix if necessary.
109109
"%!$" -> omits the "./" prefix. */
110
+#define etHEX 27 /* Encode a string as hexadecimal */
110111
111112
112113
/*
113114
** An "etByte" is an 8-bit unsigned value.
114115
*/
@@ -142,11 +143,11 @@
142143
** NB: When modifying this table is it vital that you also update the fmtchr[]
143144
** variable to match!!!
144145
*/
145146
static const char aDigits[] = "0123456789ABCDEF0123456789abcdef";
146147
static const char aPrefix[] = "-x0\000X0";
147
-static const char fmtchr[] = "dsgzqQbBWhRtTwFSjcouxXfeEGin%p/$";
148
+static const char fmtchr[] = "dsgzqQbBWhRtTwFSjcouxXfeEGin%p/$H";
148149
static const et_info fmtinfo[] = {
149150
{ 'd', 10, 1, etRADIX, 0, 0 },
150151
{ 's', 0, 4, etSTRING, 0, 0 },
151152
{ 'g', 0, 1, etGENERIC, 30, 0 },
152153
{ 'z', 0, 6, etDYNSTRING, 0, 0 },
@@ -176,10 +177,11 @@
176177
{ 'n', 0, 0, etSIZE, 0, 0 },
177178
{ '%', 0, 0, etPERCENT, 0, 0 },
178179
{ 'p', 16, 0, etPOINTER, 0, 1 },
179180
{ '/', 0, 0, etPATH, 0, 0 },
180181
{ '$', 0, 0, etSHELLESC, 0, 0 },
182
+ { 'H', 0, 0, etHEX, 0, 0 },
181183
{ etERROR, 0,0,0,0,0} /* Must be last */
182184
};
183185
#define etNINFO count(fmtinfo)
184186
185187
/*
@@ -843,10 +845,21 @@
843845
case etSHELLESC: {
844846
char *zArg = va_arg(ap, char*);
845847
blob_append_escaped_arg(pBlob, zArg, !flag_altform2);
846848
length = width = 0;
847849
break;
850
+ }
851
+ case etHEX: {
852
+ char *zArg = va_arg(ap, char*);
853
+ int szArg = (int)strlen(zArg);
854
+ int szBlob = blob_size(pBlob);
855
+ u8 *aBuf;
856
+ blob_resize(pBlob, szBlob+szArg*2+1);
857
+ aBuf = (u8*)&blob_buffer(pBlob)[szBlob];
858
+ encode16((const u8*)zArg, aBuf, szArg);
859
+ length = width = 0;
860
+ break;
848861
}
849862
case etERROR:
850863
buf[0] = '%';
851864
buf[1] = c;
852865
errorflag = 0;
853866
--- src/printf.c
+++ src/printf.c
@@ -105,10 +105,11 @@
105 Use %!j to include double-quotes around it. */
106 #define etSHELLESC 26 /* Escape a filename for use in a shell command: %$
107 See blob_append_escaped_arg() for details
108 "%$" -> adds "./" prefix if necessary.
109 "%!$" -> omits the "./" prefix. */
 
110
111
112 /*
113 ** An "etByte" is an 8-bit unsigned value.
114 */
@@ -142,11 +143,11 @@
142 ** NB: When modifying this table is it vital that you also update the fmtchr[]
143 ** variable to match!!!
144 */
145 static const char aDigits[] = "0123456789ABCDEF0123456789abcdef";
146 static const char aPrefix[] = "-x0\000X0";
147 static const char fmtchr[] = "dsgzqQbBWhRtTwFSjcouxXfeEGin%p/$";
148 static const et_info fmtinfo[] = {
149 { 'd', 10, 1, etRADIX, 0, 0 },
150 { 's', 0, 4, etSTRING, 0, 0 },
151 { 'g', 0, 1, etGENERIC, 30, 0 },
152 { 'z', 0, 6, etDYNSTRING, 0, 0 },
@@ -176,10 +177,11 @@
176 { 'n', 0, 0, etSIZE, 0, 0 },
177 { '%', 0, 0, etPERCENT, 0, 0 },
178 { 'p', 16, 0, etPOINTER, 0, 1 },
179 { '/', 0, 0, etPATH, 0, 0 },
180 { '$', 0, 0, etSHELLESC, 0, 0 },
 
181 { etERROR, 0,0,0,0,0} /* Must be last */
182 };
183 #define etNINFO count(fmtinfo)
184
185 /*
@@ -843,10 +845,21 @@
843 case etSHELLESC: {
844 char *zArg = va_arg(ap, char*);
845 blob_append_escaped_arg(pBlob, zArg, !flag_altform2);
846 length = width = 0;
847 break;
 
 
 
 
 
 
 
 
 
 
 
848 }
849 case etERROR:
850 buf[0] = '%';
851 buf[1] = c;
852 errorflag = 0;
853
--- src/printf.c
+++ src/printf.c
@@ -105,10 +105,11 @@
105 Use %!j to include double-quotes around it. */
106 #define etSHELLESC 26 /* Escape a filename for use in a shell command: %$
107 See blob_append_escaped_arg() for details
108 "%$" -> adds "./" prefix if necessary.
109 "%!$" -> omits the "./" prefix. */
110 #define etHEX 27 /* Encode a string as hexadecimal */
111
112
113 /*
114 ** An "etByte" is an 8-bit unsigned value.
115 */
@@ -142,11 +143,11 @@
143 ** NB: When modifying this table is it vital that you also update the fmtchr[]
144 ** variable to match!!!
145 */
146 static const char aDigits[] = "0123456789ABCDEF0123456789abcdef";
147 static const char aPrefix[] = "-x0\000X0";
148 static const char fmtchr[] = "dsgzqQbBWhRtTwFSjcouxXfeEGin%p/$H";
149 static const et_info fmtinfo[] = {
150 { 'd', 10, 1, etRADIX, 0, 0 },
151 { 's', 0, 4, etSTRING, 0, 0 },
152 { 'g', 0, 1, etGENERIC, 30, 0 },
153 { 'z', 0, 6, etDYNSTRING, 0, 0 },
@@ -176,10 +177,11 @@
177 { 'n', 0, 0, etSIZE, 0, 0 },
178 { '%', 0, 0, etPERCENT, 0, 0 },
179 { 'p', 16, 0, etPOINTER, 0, 1 },
180 { '/', 0, 0, etPATH, 0, 0 },
181 { '$', 0, 0, etSHELLESC, 0, 0 },
182 { 'H', 0, 0, etHEX, 0, 0 },
183 { etERROR, 0,0,0,0,0} /* Must be last */
184 };
185 #define etNINFO count(fmtinfo)
186
187 /*
@@ -843,10 +845,21 @@
845 case etSHELLESC: {
846 char *zArg = va_arg(ap, char*);
847 blob_append_escaped_arg(pBlob, zArg, !flag_altform2);
848 length = width = 0;
849 break;
850 }
851 case etHEX: {
852 char *zArg = va_arg(ap, char*);
853 int szArg = (int)strlen(zArg);
854 int szBlob = blob_size(pBlob);
855 u8 *aBuf;
856 blob_resize(pBlob, szBlob+szArg*2+1);
857 aBuf = (u8*)&blob_buffer(pBlob)[szBlob];
858 encode16((const u8*)zArg, aBuf, szArg);
859 length = width = 0;
860 break;
861 }
862 case etERROR:
863 buf[0] = '%';
864 buf[1] = c;
865 errorflag = 0;
866
+3 -3
--- src/search.c
+++ src/search.c
@@ -18,11 +18,11 @@
1818
** This file contains code to implement a search functions
1919
** against timeline comments, check-in content, wiki pages, tickets,
2020
** and/or forum posts.
2121
**
2222
** The search can be either a per-query "grep"-like search that scans
23
-** the entire corpus. Or it can use the FTS4 search engine of SQLite.
23
+** the entire corpus. Or it can use the FTS5 search engine of SQLite.
2424
** The choice is an administrator configuration option.
2525
**
2626
** The first option is referred to as "full-scan search". The second
2727
** option is called "indexed search".
2828
**
@@ -570,11 +570,11 @@
570570
**
571571
** Search for timeline entries matching all words provided on the
572572
** command line. Whole-word matches scope more highly than partial
573573
** matches.
574574
**
575
-** Note: The command only search the EVENT table. So it will only
575
+** Note: This command only searches the EVENT table. So it will only
576576
** display check-in comments or other comments that appear on an
577577
** unaugmented timeline. It does not search document text or forum
578578
** messages.
579579
**
580580
** Outputs, by default, some top-N fraction of the results. The -all
@@ -1038,11 +1038,11 @@
10381038
sqlite3_create_function(g.db, "rank", 1, SQLITE_UTF8|SQLITE_INNOCUOUS, 0,
10391039
search_rank_sqlfunc, 0, 0);
10401040
zPat = search_simplify_pattern(zPattern);
10411041
blob_init(&sql, 0, 0);
10421042
if( search_index_type(0)==4 ){
1043
- /* If this repo is still using the legacy FTS4 search index, then
1043
+ /* If this repo is still using the legacy FTS5 search index, then
10441044
** the snippet() function is slightly different */
10451045
zSnippetCall = "snippet(ftsidx,'<mark>','</mark>',' ... ',-1,35)";
10461046
}else{
10471047
/* This is the common case - Using newer FTS5 search index */
10481048
zSnippetCall = "snippet(ftsidx,-1,'<mark>','</mark>',' ... ',35)";
10491049
--- src/search.c
+++ src/search.c
@@ -18,11 +18,11 @@
18 ** This file contains code to implement a search functions
19 ** against timeline comments, check-in content, wiki pages, tickets,
20 ** and/or forum posts.
21 **
22 ** The search can be either a per-query "grep"-like search that scans
23 ** the entire corpus. Or it can use the FTS4 search engine of SQLite.
24 ** The choice is an administrator configuration option.
25 **
26 ** The first option is referred to as "full-scan search". The second
27 ** option is called "indexed search".
28 **
@@ -570,11 +570,11 @@
570 **
571 ** Search for timeline entries matching all words provided on the
572 ** command line. Whole-word matches scope more highly than partial
573 ** matches.
574 **
575 ** Note: The command only search the EVENT table. So it will only
576 ** display check-in comments or other comments that appear on an
577 ** unaugmented timeline. It does not search document text or forum
578 ** messages.
579 **
580 ** Outputs, by default, some top-N fraction of the results. The -all
@@ -1038,11 +1038,11 @@
1038 sqlite3_create_function(g.db, "rank", 1, SQLITE_UTF8|SQLITE_INNOCUOUS, 0,
1039 search_rank_sqlfunc, 0, 0);
1040 zPat = search_simplify_pattern(zPattern);
1041 blob_init(&sql, 0, 0);
1042 if( search_index_type(0)==4 ){
1043 /* If this repo is still using the legacy FTS4 search index, then
1044 ** the snippet() function is slightly different */
1045 zSnippetCall = "snippet(ftsidx,'<mark>','</mark>',' ... ',-1,35)";
1046 }else{
1047 /* This is the common case - Using newer FTS5 search index */
1048 zSnippetCall = "snippet(ftsidx,-1,'<mark>','</mark>',' ... ',35)";
1049
--- src/search.c
+++ src/search.c
@@ -18,11 +18,11 @@
18 ** This file contains code to implement a search functions
19 ** against timeline comments, check-in content, wiki pages, tickets,
20 ** and/or forum posts.
21 **
22 ** The search can be either a per-query "grep"-like search that scans
23 ** the entire corpus. Or it can use the FTS5 search engine of SQLite.
24 ** The choice is an administrator configuration option.
25 **
26 ** The first option is referred to as "full-scan search". The second
27 ** option is called "indexed search".
28 **
@@ -570,11 +570,11 @@
570 **
571 ** Search for timeline entries matching all words provided on the
572 ** command line. Whole-word matches scope more highly than partial
573 ** matches.
574 **
575 ** Note: This command only searches the EVENT table. So it will only
576 ** display check-in comments or other comments that appear on an
577 ** unaugmented timeline. It does not search document text or forum
578 ** messages.
579 **
580 ** Outputs, by default, some top-N fraction of the results. The -all
@@ -1038,11 +1038,11 @@
1038 sqlite3_create_function(g.db, "rank", 1, SQLITE_UTF8|SQLITE_INNOCUOUS, 0,
1039 search_rank_sqlfunc, 0, 0);
1040 zPat = search_simplify_pattern(zPattern);
1041 blob_init(&sql, 0, 0);
1042 if( search_index_type(0)==4 ){
1043 /* If this repo is still using the legacy FTS5 search index, then
1044 ** the snippet() function is slightly different */
1045 zSnippetCall = "snippet(ftsidx,'<mark>','</mark>',' ... ',-1,35)";
1046 }else{
1047 /* This is the common case - Using newer FTS5 search index */
1048 zSnippetCall = "snippet(ftsidx,-1,'<mark>','</mark>',' ... ',35)";
1049
--- src/security_audit.c
+++ src/security_audit.c
@@ -543,11 +543,11 @@
543543
@ Fix this by deactivating the "Allow REMOTE_USER authentication"
544544
@ checkbox on the <a href="setup_access">Access Control</a> page.
545545
}
546546
if( db_get_boolean("http_authentication_ok", 0) ){
547547
@ <li><p><b>Caution:</b>
548
- @ This repository trusts that the HTTP_AUTHENITICATION environment
548
+ @ This repository trusts that the HTTP_AUTHENTICATION environment
549549
@ variable set up by the webserver contains the name of an
550550
@ authenticated user.
551551
@ Fossil's built-in authentication mechanism is bypassed.
552552
@ Fix this by deactivating the "Allow HTTP_AUTHENTICATION authentication"
553553
@ checkbox on the <a href="setup_access">Access Control</a> page.
554554
--- src/security_audit.c
+++ src/security_audit.c
@@ -543,11 +543,11 @@
543 @ Fix this by deactivating the "Allow REMOTE_USER authentication"
544 @ checkbox on the <a href="setup_access">Access Control</a> page.
545 }
546 if( db_get_boolean("http_authentication_ok", 0) ){
547 @ <li><p><b>Caution:</b>
548 @ This repository trusts that the HTTP_AUTHENITICATION environment
549 @ variable set up by the webserver contains the name of an
550 @ authenticated user.
551 @ Fossil's built-in authentication mechanism is bypassed.
552 @ Fix this by deactivating the "Allow HTTP_AUTHENTICATION authentication"
553 @ checkbox on the <a href="setup_access">Access Control</a> page.
554
--- src/security_audit.c
+++ src/security_audit.c
@@ -543,11 +543,11 @@
543 @ Fix this by deactivating the "Allow REMOTE_USER authentication"
544 @ checkbox on the <a href="setup_access">Access Control</a> page.
545 }
546 if( db_get_boolean("http_authentication_ok", 0) ){
547 @ <li><p><b>Caution:</b>
548 @ This repository trusts that the HTTP_AUTHENTICATION environment
549 @ variable set up by the webserver contains the name of an
550 @ authenticated user.
551 @ Fossil's built-in authentication mechanism is bypassed.
552 @ Fix this by deactivating the "Allow HTTP_AUTHENTICATION authentication"
553 @ checkbox on the <a href="setup_access">Access Control</a> page.
554
+71 -35
--- src/setup.c
+++ src/setup.c
@@ -38,26 +38,26 @@
3838
}
3939
}
4040
4141
/*
4242
** Output a single entry for a menu generated using an HTML table.
43
-** If zLink is not NULL or an empty string, then it is the page that
43
+** If zLink is neither NULL nor an empty string, then it is the page that
4444
** the menu entry will hyperlink to. If zLink is NULL or "", then
4545
** the menu entry has no hyperlink - it is disabled.
4646
*/
4747
void setup_menu_entry(
4848
const char *zTitle,
4949
const char *zLink,
50
- const char *zDesc
50
+ const char *zDesc /* Caution! Rendered using %s. May contain raw HTML. */
5151
){
5252
@ <tr><td valign="top" align="right">
5353
if( zLink && zLink[0] ){
5454
@ <a href="%s(zLink)"><nobr>%h(zTitle)</nobr></a>
5555
}else{
56
- @ %h(zTitle)
56
+ @ <nobr>%h(zTitle)</nobr>
5757
}
58
- @ </td><td width="5"></td><td valign="top">%h(zDesc)</td></tr>
58
+ @ </td><td width="5"></td><td valign="top">%s(zDesc)</td></tr>
5959
}
6060
6161
6262
6363
/*
@@ -190,10 +190,11 @@
190190
**
191191
** This page is only accessible by administrators.
192192
*/
193193
void setup_logmenu_page(void){
194194
Blob desc;
195
+ int bErrLog; /* True if Error Log enabled */
195196
blob_init(&desc, 0, 0);
196197
197198
/* Administrator access only */
198199
login_check_credentials();
199200
if( !g.perm.Admin ){
@@ -200,54 +201,89 @@
200201
login_needed(0);
201202
return;
202203
}
203204
style_header("Log Menu");
204205
@ <table border="0" cellspacing="3">
205
- setup_menu_entry("Admin Log", "admin_log",
206
- "The admin log records configuration changes to the repository.\n"
207
- "The admin log is stored in the \"admin_log\" table of the repository.\n"
208
- );
206
+
207
+ if( db_get_boolean("admin-log",0)==0 ){
208
+ blob_appendf(&desc,
209
+ "The admin log records configuration changes to the repository.\n"
210
+ "<b>Disabled</b>: Turn on the "
211
+ " <a href='%R/setup_settings'>admin-log setting</a> to enable."
212
+ );
213
+ setup_menu_entry("Admin Log", 0, blob_str(&desc));
214
+ blob_reset(&desc);
215
+ }else{
216
+ setup_menu_entry("Admin Log", "admin_log",
217
+ "The admin log records configuration changes to the repository\n"
218
+ "in the \"admin_log\" table.\n"
219
+ );
220
+ }
209221
setup_menu_entry("Artifact Log", "rcvfromlist",
210
- "The artifact log records when new content is added to the repository.\n"
211
- "The time and date and origin of the new content is entered into the\n"
212
- "Log. The artifact log is always on and is stored in the \"rcvfrom\"\n"
213
- "table of the repository.\n"
222
+ "The artifact log records when new content is added in the\n"
223
+ "\"rcvfrom\" table.\n"
214224
);
225
+ if( db_get_boolean("access-log",0) ){
226
+ setup_menu_entry("User Log", "user_log",
227
+ "Login attempts recorded in the \"accesslog\" table."
228
+ );
229
+ }else{
230
+ blob_appendf(&desc,
231
+ "Login attempts recorded in the \"accesslog\" table.\n"
232
+ "<b>Disabled</b>: Turn on the "
233
+ "<a href='%R/setup_settings'>access-log setting</a> to enable."
234
+ );
235
+ setup_menu_entry("User Log", 0, blob_str(&desc));
236
+ blob_reset(&desc);
237
+ }
215238
216239
blob_appendf(&desc,
217
- "The error log is a separate text file to which warning and error\n"
240
+ "A separate text file to which warning and error\n"
218241
"messages are appended. A single error log can and often is shared\n"
219242
"across multiple repositories.\n"
220243
);
221244
if( g.zErrlog==0 || fossil_strcmp(g.zErrlog,"-")==0 ){
222
- blob_appendf(&desc,"The error log is disabled for this repository.");
245
+ blob_appendf(&desc,"<b>Disabled</b>: "
246
+ "To enable the error log ");
247
+ if( fossil_strcmp(g.zCmdName, "cgi")==0 ){
248
+ blob_appendf(&desc,
249
+ "make an entry like \"errorlog: <i>FILENAME</i>\""
250
+ " in the CGI script at %h",
251
+ P("SCRIPT_FILENAME")
252
+ );
253
+ }else{
254
+ blob_appendf(&desc,
255
+ " add the \"--errorlog <i>FILENAME</i>\" option to the\n"
256
+ "\"%h %h\" command that launched the server.",
257
+ g.argv[0], g.zCmdName
258
+ );
259
+ }
260
+ bErrLog = 0;
223261
}else{
224
- blob_appendf(&desc,"In this repository, the error log is in the file"
262
+ blob_appendf(&desc,"In this repository, the error log is the file "
225263
"named \"%s\".", g.zErrlog);
264
+ bErrLog = 1;
226265
}
227
- setup_menu_entry("Error Log", "errorlog", blob_str(&desc));
266
+ setup_menu_entry("Error Log", bErrLog ? "errorlog" : 0, blob_str(&desc));
228267
blob_reset(&desc);
229268
230
- setup_menu_entry("Panic Log", "paniclog",
231
- "The panic log is a filtering of the Error Log that shows only the\n"
232
- "most important messages - assertion faults, segmentation faults, and\n"
233
- "similar malfunctions."
234
- );
235
-
236
- setup_menu_entry("User Log", "user_log",
237
- "The user log is a record of login attempts. The user log is stored\n"
238
- "in the \"accesslog\" table of the respository.\n"
239
- );
240
-
241
- setup_menu_entry("Hack Log", "hacklog",
242
- "All 418 hack attempts"
243
- );
244
-
245
- setup_menu_entry("Non-Hack Log", "hacklog?not",
246
- "All log messages that are not hack attempts"
247
- );
248
-
269
+ @ <tr><td><td><td>
270
+ @ &mdash;&mdash;
271
+ @ <i>The remaining links are subsets of the Error Log</i>
272
+ @ &mdash;&mdash;
273
+ @ </td>
274
+
275
+ setup_menu_entry("Panic Log", bErrLog ? "paniclog" : 0,
276
+ "Only the most important messages in the Error Log:\n"
277
+ "assertion faults, segmentation faults, and similar malfunctions.\n"
278
+ );
279
+ setup_menu_entry("Hack Log", bErrLog ? "hacklog" : 0,
280
+ "All code-418 hack attempts in the Error Log"
281
+ );
282
+ setup_menu_entry("Non-Hack Log", bErrLog ? "hacklog?not" : 0,
283
+ "All log messages that are not code-418 hack attempts"
284
+ );
249285
250286
@ </table>
251287
style_finish_page();
252288
}
253289
254290
--- src/setup.c
+++ src/setup.c
@@ -38,26 +38,26 @@
38 }
39 }
40
41 /*
42 ** Output a single entry for a menu generated using an HTML table.
43 ** If zLink is not NULL or an empty string, then it is the page that
44 ** the menu entry will hyperlink to. If zLink is NULL or "", then
45 ** the menu entry has no hyperlink - it is disabled.
46 */
47 void setup_menu_entry(
48 const char *zTitle,
49 const char *zLink,
50 const char *zDesc
51 ){
52 @ <tr><td valign="top" align="right">
53 if( zLink && zLink[0] ){
54 @ <a href="%s(zLink)"><nobr>%h(zTitle)</nobr></a>
55 }else{
56 @ %h(zTitle)
57 }
58 @ </td><td width="5"></td><td valign="top">%h(zDesc)</td></tr>
59 }
60
61
62
63 /*
@@ -190,10 +190,11 @@
190 **
191 ** This page is only accessible by administrators.
192 */
193 void setup_logmenu_page(void){
194 Blob desc;
 
195 blob_init(&desc, 0, 0);
196
197 /* Administrator access only */
198 login_check_credentials();
199 if( !g.perm.Admin ){
@@ -200,54 +201,89 @@
200 login_needed(0);
201 return;
202 }
203 style_header("Log Menu");
204 @ <table border="0" cellspacing="3">
205 setup_menu_entry("Admin Log", "admin_log",
206 "The admin log records configuration changes to the repository.\n"
207 "The admin log is stored in the \"admin_log\" table of the repository.\n"
208 );
 
 
 
 
 
 
 
 
 
 
 
209 setup_menu_entry("Artifact Log", "rcvfromlist",
210 "The artifact log records when new content is added to the repository.\n"
211 "The time and date and origin of the new content is entered into the\n"
212 "Log. The artifact log is always on and is stored in the \"rcvfrom\"\n"
213 "table of the repository.\n"
214 );
 
 
 
 
 
 
 
 
 
 
 
 
 
215
216 blob_appendf(&desc,
217 "The error log is a separate text file to which warning and error\n"
218 "messages are appended. A single error log can and often is shared\n"
219 "across multiple repositories.\n"
220 );
221 if( g.zErrlog==0 || fossil_strcmp(g.zErrlog,"-")==0 ){
222 blob_appendf(&desc,"The error log is disabled for this repository.");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
223 }else{
224 blob_appendf(&desc,"In this repository, the error log is in the file"
225 "named \"%s\".", g.zErrlog);
 
226 }
227 setup_menu_entry("Error Log", "errorlog", blob_str(&desc));
228 blob_reset(&desc);
229
230 setup_menu_entry("Panic Log", "paniclog",
231 "The panic log is a filtering of the Error Log that shows only the\n"
232 "most important messages - assertion faults, segmentation faults, and\n"
233 "similar malfunctions."
234 );
235
236 setup_menu_entry("User Log", "user_log",
237 "The user log is a record of login attempts. The user log is stored\n"
238 "in the \"accesslog\" table of the respository.\n"
239 );
240
241 setup_menu_entry("Hack Log", "hacklog",
242 "All 418 hack attempts"
243 );
244
245 setup_menu_entry("Non-Hack Log", "hacklog?not",
246 "All log messages that are not hack attempts"
247 );
248
249
250 @ </table>
251 style_finish_page();
252 }
253
254
--- src/setup.c
+++ src/setup.c
@@ -38,26 +38,26 @@
38 }
39 }
40
41 /*
42 ** Output a single entry for a menu generated using an HTML table.
43 ** If zLink is neither NULL nor an empty string, then it is the page that
44 ** the menu entry will hyperlink to. If zLink is NULL or "", then
45 ** the menu entry has no hyperlink - it is disabled.
46 */
47 void setup_menu_entry(
48 const char *zTitle,
49 const char *zLink,
50 const char *zDesc /* Caution! Rendered using %s. May contain raw HTML. */
51 ){
52 @ <tr><td valign="top" align="right">
53 if( zLink && zLink[0] ){
54 @ <a href="%s(zLink)"><nobr>%h(zTitle)</nobr></a>
55 }else{
56 @ <nobr>%h(zTitle)</nobr>
57 }
58 @ </td><td width="5"></td><td valign="top">%s(zDesc)</td></tr>
59 }
60
61
62
63 /*
@@ -190,10 +190,11 @@
190 **
191 ** This page is only accessible by administrators.
192 */
193 void setup_logmenu_page(void){
194 Blob desc;
195 int bErrLog; /* True if Error Log enabled */
196 blob_init(&desc, 0, 0);
197
198 /* Administrator access only */
199 login_check_credentials();
200 if( !g.perm.Admin ){
@@ -200,54 +201,89 @@
201 login_needed(0);
202 return;
203 }
204 style_header("Log Menu");
205 @ <table border="0" cellspacing="3">
206
207 if( db_get_boolean("admin-log",0)==0 ){
208 blob_appendf(&desc,
209 "The admin log records configuration changes to the repository.\n"
210 "<b>Disabled</b>: Turn on the "
211 " <a href='%R/setup_settings'>admin-log setting</a> to enable."
212 );
213 setup_menu_entry("Admin Log", 0, blob_str(&desc));
214 blob_reset(&desc);
215 }else{
216 setup_menu_entry("Admin Log", "admin_log",
217 "The admin log records configuration changes to the repository\n"
218 "in the \"admin_log\" table.\n"
219 );
220 }
221 setup_menu_entry("Artifact Log", "rcvfromlist",
222 "The artifact log records when new content is added in the\n"
223 "\"rcvfrom\" table.\n"
 
 
224 );
225 if( db_get_boolean("access-log",0) ){
226 setup_menu_entry("User Log", "user_log",
227 "Login attempts recorded in the \"accesslog\" table."
228 );
229 }else{
230 blob_appendf(&desc,
231 "Login attempts recorded in the \"accesslog\" table.\n"
232 "<b>Disabled</b>: Turn on the "
233 "<a href='%R/setup_settings'>access-log setting</a> to enable."
234 );
235 setup_menu_entry("User Log", 0, blob_str(&desc));
236 blob_reset(&desc);
237 }
238
239 blob_appendf(&desc,
240 "A separate text file to which warning and error\n"
241 "messages are appended. A single error log can and often is shared\n"
242 "across multiple repositories.\n"
243 );
244 if( g.zErrlog==0 || fossil_strcmp(g.zErrlog,"-")==0 ){
245 blob_appendf(&desc,"<b>Disabled</b>: "
246 "To enable the error log ");
247 if( fossil_strcmp(g.zCmdName, "cgi")==0 ){
248 blob_appendf(&desc,
249 "make an entry like \"errorlog: <i>FILENAME</i>\""
250 " in the CGI script at %h",
251 P("SCRIPT_FILENAME")
252 );
253 }else{
254 blob_appendf(&desc,
255 " add the \"--errorlog <i>FILENAME</i>\" option to the\n"
256 "\"%h %h\" command that launched the server.",
257 g.argv[0], g.zCmdName
258 );
259 }
260 bErrLog = 0;
261 }else{
262 blob_appendf(&desc,"In this repository, the error log is the file "
263 "named \"%s\".", g.zErrlog);
264 bErrLog = 1;
265 }
266 setup_menu_entry("Error Log", bErrLog ? "errorlog" : 0, blob_str(&desc));
267 blob_reset(&desc);
268
269 @ <tr><td><td><td>
270 @ &mdash;&mdash;
271 @ <i>The remaining links are subsets of the Error Log</i>
272 @ &mdash;&mdash;
273 @ </td>
274
275 setup_menu_entry("Panic Log", bErrLog ? "paniclog" : 0,
276 "Only the most important messages in the Error Log:\n"
277 "assertion faults, segmentation faults, and similar malfunctions.\n"
278 );
279 setup_menu_entry("Hack Log", bErrLog ? "hacklog" : 0,
280 "All code-418 hack attempts in the Error Log"
281 );
282 setup_menu_entry("Non-Hack Log", bErrLog ? "hacklog?not" : 0,
283 "All log messages that are not code-418 hack attempts"
284 );
 
 
 
285
286 @ </table>
287 style_finish_page();
288 }
289
290
+3 -39
--- src/sitemap.c
+++ src/sitemap.c
@@ -56,22 +56,10 @@
5656
int i;
5757
int isPopup = 0; /* This is an XMLHttpRequest() for /sitemap */
5858
int e = atoi(PD("e","0"));
5959
const char *zExtra;
6060
61
-#if 0 /* Removed 2021-01-26 */
62
- const struct {
63
- const char *zTitle;
64
- const char *zProperty;
65
- } aExtra[] = {
66
- { "Documentation", "sitemap-docidx" },
67
- { "Download", "sitemap-download" },
68
- { "License", "sitemap-license" },
69
- { "Contact", "sitemap-contact" },
70
- };
71
-#endif
72
-
7361
login_check_credentials();
7462
if( P("popup")!=0 ){
7563
/* The "popup" query parameter
7664
** then disable anti-robot defenses */
7765
isPopup = 1;
@@ -87,26 +75,10 @@
8775
@ <ul id="sitemap" class="columns" style="column-width:20em">
8876
if( (e&1)==0 ){
8977
@ <li>%z(href("%R/home"))Home Page</a>
9078
}
9179
92
-#if 0 /* Removed 2021-01-26 */
93
- for(i=0; i<sizeof(aExtra)/sizeof(aExtra[0]); i++){
94
- char *z = db_get(aExtra[i].zProperty,0);
95
- if( z==0 || z[0]==0 ) continue;
96
- if( !inSublist ){
97
- @ <ul>
98
- inSublist = 1;
99
- }
100
- if( z[0]=='/' ){
101
- @ <li>%z(href("%R%s",z))%s(aExtra[i].zTitle)</a></li>
102
- }else{
103
- @ <li>%z(href("%s",z))%s(aExtra[i].zTitle)</a></li>
104
- }
105
- }
106
-#endif
107
-
10880
zExtra = db_get("sitemap-extra",0);
10981
if( zExtra && (e&2)==0 ){
11082
int rc;
11183
char **azExtra = 0;
11284
int *anExtra;
@@ -139,26 +111,18 @@
139111
}
140112
Th_Free(g.interp, azExtra);
141113
}
142114
if( (e&1)!=0 ) goto end_of_sitemap;
143115
144
-#if 0 /* Removed on 2021-02-11. Make a sitemap-extra entry if you */
145
- /* really want this */
146
- if( srchFlags & SRCH_DOC ){
147
- if( !inSublist ){
148
- @ <ul>
149
- inSublist = 1;
150
- }
151
- @ <li>%z(href("%R/docsrch"))Documentation Search</a></li>
152
- }
153
-#endif
154
-
155116
if( inSublist ){
156117
@ </ul>
157118
inSublist = 0;
158119
}
159120
@ </li>
121
+ if( cgi_is_loopback(g.zIpAddr) && db_open_local(0) ){
122
+ @ <li>%z(href("%R/ckout"))Checkout Status</a></li>
123
+ }
160124
if( g.perm.Read ){
161125
const char *zEditGlob = db_get("fileedit-glob","");
162126
@ <li>%z(href("%R/tree"))File Browser</a>
163127
@ <ul>
164128
@ <li>%z(href("%R/tree?type=tree&ci=trunk"))Tree-view,
165129
--- src/sitemap.c
+++ src/sitemap.c
@@ -56,22 +56,10 @@
56 int i;
57 int isPopup = 0; /* This is an XMLHttpRequest() for /sitemap */
58 int e = atoi(PD("e","0"));
59 const char *zExtra;
60
61 #if 0 /* Removed 2021-01-26 */
62 const struct {
63 const char *zTitle;
64 const char *zProperty;
65 } aExtra[] = {
66 { "Documentation", "sitemap-docidx" },
67 { "Download", "sitemap-download" },
68 { "License", "sitemap-license" },
69 { "Contact", "sitemap-contact" },
70 };
71 #endif
72
73 login_check_credentials();
74 if( P("popup")!=0 ){
75 /* The "popup" query parameter
76 ** then disable anti-robot defenses */
77 isPopup = 1;
@@ -87,26 +75,10 @@
87 @ <ul id="sitemap" class="columns" style="column-width:20em">
88 if( (e&1)==0 ){
89 @ <li>%z(href("%R/home"))Home Page</a>
90 }
91
92 #if 0 /* Removed 2021-01-26 */
93 for(i=0; i<sizeof(aExtra)/sizeof(aExtra[0]); i++){
94 char *z = db_get(aExtra[i].zProperty,0);
95 if( z==0 || z[0]==0 ) continue;
96 if( !inSublist ){
97 @ <ul>
98 inSublist = 1;
99 }
100 if( z[0]=='/' ){
101 @ <li>%z(href("%R%s",z))%s(aExtra[i].zTitle)</a></li>
102 }else{
103 @ <li>%z(href("%s",z))%s(aExtra[i].zTitle)</a></li>
104 }
105 }
106 #endif
107
108 zExtra = db_get("sitemap-extra",0);
109 if( zExtra && (e&2)==0 ){
110 int rc;
111 char **azExtra = 0;
112 int *anExtra;
@@ -139,26 +111,18 @@
139 }
140 Th_Free(g.interp, azExtra);
141 }
142 if( (e&1)!=0 ) goto end_of_sitemap;
143
144 #if 0 /* Removed on 2021-02-11. Make a sitemap-extra entry if you */
145 /* really want this */
146 if( srchFlags & SRCH_DOC ){
147 if( !inSublist ){
148 @ <ul>
149 inSublist = 1;
150 }
151 @ <li>%z(href("%R/docsrch"))Documentation Search</a></li>
152 }
153 #endif
154
155 if( inSublist ){
156 @ </ul>
157 inSublist = 0;
158 }
159 @ </li>
 
 
 
160 if( g.perm.Read ){
161 const char *zEditGlob = db_get("fileedit-glob","");
162 @ <li>%z(href("%R/tree"))File Browser</a>
163 @ <ul>
164 @ <li>%z(href("%R/tree?type=tree&ci=trunk"))Tree-view,
165
--- src/sitemap.c
+++ src/sitemap.c
@@ -56,22 +56,10 @@
56 int i;
57 int isPopup = 0; /* This is an XMLHttpRequest() for /sitemap */
58 int e = atoi(PD("e","0"));
59 const char *zExtra;
60
 
 
 
 
 
 
 
 
 
 
 
 
61 login_check_credentials();
62 if( P("popup")!=0 ){
63 /* The "popup" query parameter
64 ** then disable anti-robot defenses */
65 isPopup = 1;
@@ -87,26 +75,10 @@
75 @ <ul id="sitemap" class="columns" style="column-width:20em">
76 if( (e&1)==0 ){
77 @ <li>%z(href("%R/home"))Home Page</a>
78 }
79
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80 zExtra = db_get("sitemap-extra",0);
81 if( zExtra && (e&2)==0 ){
82 int rc;
83 char **azExtra = 0;
84 int *anExtra;
@@ -139,26 +111,18 @@
111 }
112 Th_Free(g.interp, azExtra);
113 }
114 if( (e&1)!=0 ) goto end_of_sitemap;
115
 
 
 
 
 
 
 
 
 
 
 
116 if( inSublist ){
117 @ </ul>
118 inSublist = 0;
119 }
120 @ </li>
121 if( cgi_is_loopback(g.zIpAddr) && db_open_local(0) ){
122 @ <li>%z(href("%R/ckout"))Checkout Status</a></li>
123 }
124 if( g.perm.Read ){
125 const char *zEditGlob = db_get("fileedit-glob","");
126 @ <li>%z(href("%R/tree"))File Browser</a>
127 @ <ul>
128 @ <li>%z(href("%R/tree?type=tree&ci=trunk"))Tree-view,
129
+4 -4
--- src/statrep.c
+++ src/statrep.c
@@ -290,12 +290,12 @@
290290
nEventsPerYear += nCount;
291291
@<tr class='row%d(rowClass)'>
292292
@ <td>
293293
if(includeMonth){
294294
cgi_printf("<a href='%R/timeline?"
295
- "ym=%t&n=%d&y=%s",
296
- zTimeframe, nCount,
295
+ "ym=%t&y=%s",
296
+ zTimeframe,
297297
statsReportTimelineYFlag );
298298
/* Reminder: n=nCount is not actually correct for bymonth unless
299299
that was the only user who caused events.
300300
*/
301301
if( zUserName ){
@@ -731,12 +731,12 @@
731731
? (int)(100 * nCount / nMaxEvents)
732732
: 0;
733733
if(!nSize) nSize = 1;
734734
total += nCount;
735735
cgi_printf("<tr class='row%d'>", ++rowCount % 2 );
736
- cgi_printf("<td><a href='%R/timeline?yw=%t-%s&n=%d&y=%s",
737
- zYear, zWeek, nCount,
736
+ cgi_printf("<td><a href='%R/timeline?yw=%t%s&y=%s",
737
+ zYear, zWeek,
738738
statsReportTimelineYFlag);
739739
if( zUserName ){
740740
cgi_printf("&u=%t",zUserName);
741741
}
742742
cgi_printf("'>%s</a></td>",zWeek);
743743
--- src/statrep.c
+++ src/statrep.c
@@ -290,12 +290,12 @@
290 nEventsPerYear += nCount;
291 @<tr class='row%d(rowClass)'>
292 @ <td>
293 if(includeMonth){
294 cgi_printf("<a href='%R/timeline?"
295 "ym=%t&n=%d&y=%s",
296 zTimeframe, nCount,
297 statsReportTimelineYFlag );
298 /* Reminder: n=nCount is not actually correct for bymonth unless
299 that was the only user who caused events.
300 */
301 if( zUserName ){
@@ -731,12 +731,12 @@
731 ? (int)(100 * nCount / nMaxEvents)
732 : 0;
733 if(!nSize) nSize = 1;
734 total += nCount;
735 cgi_printf("<tr class='row%d'>", ++rowCount % 2 );
736 cgi_printf("<td><a href='%R/timeline?yw=%t-%s&n=%d&y=%s",
737 zYear, zWeek, nCount,
738 statsReportTimelineYFlag);
739 if( zUserName ){
740 cgi_printf("&u=%t",zUserName);
741 }
742 cgi_printf("'>%s</a></td>",zWeek);
743
--- src/statrep.c
+++ src/statrep.c
@@ -290,12 +290,12 @@
290 nEventsPerYear += nCount;
291 @<tr class='row%d(rowClass)'>
292 @ <td>
293 if(includeMonth){
294 cgi_printf("<a href='%R/timeline?"
295 "ym=%t&y=%s",
296 zTimeframe,
297 statsReportTimelineYFlag );
298 /* Reminder: n=nCount is not actually correct for bymonth unless
299 that was the only user who caused events.
300 */
301 if( zUserName ){
@@ -731,12 +731,12 @@
731 ? (int)(100 * nCount / nMaxEvents)
732 : 0;
733 if(!nSize) nSize = 1;
734 total += nCount;
735 cgi_printf("<tr class='row%d'>", ++rowCount % 2 );
736 cgi_printf("<td><a href='%R/timeline?yw=%t%s&y=%s",
737 zYear, zWeek,
738 statsReportTimelineYFlag);
739 if( zUserName ){
740 cgi_printf("&u=%t",zUserName);
741 }
742 cgi_printf("'>%s</a></td>",zWeek);
743
--- src/style.c
+++ src/style.c
@@ -821,10 +821,11 @@
821821
if( g.perm.Debug && P("showqp") ){
822822
@ <div class="debug">
823823
cgi_print_all(0, 0, 0);
824824
@ </div>
825825
}
826
+ fossil_free(zTitle);
826827
}
827828
828829
#if INTERFACE
829830
/* Allowed parameters for style_adunit() */
830831
#define ADUNIT_OFF 0x0001 /* Do not allow ads on this page */
@@ -1300,10 +1301,11 @@
13001301
Th_Store("secureurl", fossil_wants_https(1)? g.zHttpsURL: g.zBaseURL);
13011302
Th_Store("home", g.zTop);
13021303
image_url_var("logo");
13031304
image_url_var("background");
13041305
Th_Render(blob_str(&css));
1306
+ blob_reset(&css);
13051307
13061308
/* Tell CGI that the content returned by this page is considered cacheable */
13071309
g.isConst = 1;
13081310
}
13091311
13101312
--- src/style.c
+++ src/style.c
@@ -821,10 +821,11 @@
821 if( g.perm.Debug && P("showqp") ){
822 @ <div class="debug">
823 cgi_print_all(0, 0, 0);
824 @ </div>
825 }
 
826 }
827
828 #if INTERFACE
829 /* Allowed parameters for style_adunit() */
830 #define ADUNIT_OFF 0x0001 /* Do not allow ads on this page */
@@ -1300,10 +1301,11 @@
1300 Th_Store("secureurl", fossil_wants_https(1)? g.zHttpsURL: g.zBaseURL);
1301 Th_Store("home", g.zTop);
1302 image_url_var("logo");
1303 image_url_var("background");
1304 Th_Render(blob_str(&css));
 
1305
1306 /* Tell CGI that the content returned by this page is considered cacheable */
1307 g.isConst = 1;
1308 }
1309
1310
--- src/style.c
+++ src/style.c
@@ -821,10 +821,11 @@
821 if( g.perm.Debug && P("showqp") ){
822 @ <div class="debug">
823 cgi_print_all(0, 0, 0);
824 @ </div>
825 }
826 fossil_free(zTitle);
827 }
828
829 #if INTERFACE
830 /* Allowed parameters for style_adunit() */
831 #define ADUNIT_OFF 0x0001 /* Do not allow ads on this page */
@@ -1300,10 +1301,11 @@
1301 Th_Store("secureurl", fossil_wants_https(1)? g.zHttpsURL: g.zBaseURL);
1302 Th_Store("home", g.zTop);
1303 image_url_var("logo");
1304 image_url_var("background");
1305 Th_Render(blob_str(&css));
1306 blob_reset(&css);
1307
1308 /* Tell CGI that the content returned by this page is considered cacheable */
1309 g.isConst = 1;
1310 }
1311
1312
+473 -462
--- src/timeline.c
+++ src/timeline.c
@@ -191,11 +191,11 @@
191191
void www_print_timeline(
192192
Stmt *pQuery, /* Query to implement the timeline */
193193
int tmFlags, /* Flags controlling display behavior */
194194
const char *zThisUser, /* Suppress links to this user */
195195
const char *zThisTag, /* Suppress links to this tag */
196
- const char *zLeftBranch, /* Strive to put this branch on the left margin */
196
+ Matcher *pLeftBranch, /* Comparison function to use for zLeftBranch */
197197
int selectedRid, /* Highlight the line with this RID value or zero */
198198
int secondRid, /* Secondary highlight (or zero) */
199199
void (*xExtra)(int) /* Routine to call on each line of display */
200200
){
201201
int mxWikiLen;
@@ -813,11 +813,11 @@
813813
}
814814
if( pendingEndTr ){
815815
@ </td></tr>
816816
}
817817
if( pGraph ){
818
- graph_finish(pGraph, zLeftBranch, tmFlags);
818
+ graph_finish(pGraph, pLeftBranch, tmFlags);
819819
if( pGraph->nErr ){
820820
graph_free(pGraph);
821821
pGraph = 0;
822822
}else{
823823
@ <tr class="timelineBottom" id="btm-%d(iTableId)">\
@@ -1290,12 +1290,13 @@
12901290
const char *zChng, /* The filename GLOB list */
12911291
Blob *pSql /* The SELECT statement under construction */
12921292
){
12931293
if( zChng==0 || zChng[0]==0 ) return;
12941294
blob_append_sql(pSql," AND event.objid IN ("
1295
- "SELECT mlink.mid FROM mlink, filename"
1296
- " WHERE mlink.fnid=filename.fnid AND %s)",
1295
+ "SELECT mlink.mid FROM mlink, filename\n"
1296
+ " WHERE mlink.fnid=filename.fnid\n"
1297
+ " AND %s)",
12971298
glob_expr("filename.name", mprintf("\"%s\"", zChng)));
12981299
}
12991300
static void addFileGlobDescription(
13001301
const char *zChng, /* The filename GLOB list */
13011302
Blob *pDescription /* Result description */
@@ -1303,274 +1304,86 @@
13031304
if( zChng==0 || zChng[0]==0 ) return;
13041305
blob_appendf(pDescription, " that include changes to files matching '%h'",
13051306
zChng);
13061307
}
13071308
1308
-/*
1309
-** Tag match expression type code.
1310
-*/
1311
-typedef enum {
1312
- MS_EXACT, /* Matches a single tag by exact string comparison. */
1313
- MS_GLOB, /* Matches tags against a list of GLOB patterns. */
1314
- MS_LIKE, /* Matches tags against a list of LIKE patterns. */
1315
- MS_REGEXP, /* Matches tags against a list of regular expressions. */
1316
- MS_BRLIST, /* Same as REGEXP, except the regular expression is a list
1317
- ** of branch names */
1318
-} MatchStyle;
1319
-
1320
-/*
1321
-** Quote a tag string by surrounding it with double quotes and preceding
1322
-** internal double quotes and backslashes with backslashes.
1323
-*/
1324
-static const char *tagQuote(
1325
- int len, /* Maximum length of zTag, or negative for unlimited */
1326
- const char *zTag /* Tag string */
1327
-){
1328
- Blob blob = BLOB_INITIALIZER;
1329
- int i, j;
1330
- blob_zero(&blob);
1331
- blob_append(&blob, "\"", 1);
1332
- for( i=j=0; zTag[j] && (len<0 || j<len); ++j ){
1333
- if( zTag[j]=='\"' || zTag[j]=='\\' ){
1334
- if( j>i ){
1335
- blob_append(&blob, zTag+i, j-i);
1336
- }
1337
- blob_append(&blob, "\\", 1);
1338
- i = j;
1339
- }
1340
- }
1341
- if( j>i ){
1342
- blob_append(&blob, zTag+i, j-i);
1343
- }
1344
- blob_append(&blob, "\"", 1);
1345
- return blob_str(&blob);
1346
-}
1347
-
1348
-/*
1349
-** Construct the tag match SQL expression.
1350
-**
1351
-** This function is adapted from glob_expr() to support the MS_EXACT, MS_GLOB,
1352
-** MS_LIKE, MS_REGEXP, and MS_BRLIST match styles.
1353
-**
1354
-** For MS_EXACT, the returned expression
1355
-** checks for integer match against the tag ID which is looked up directly by
1356
-** this function. For the other modes, the returned SQL expression performs
1357
-** string comparisons against the tag names, so it is necessary to join against
1358
-** the tag table to access the "tagname" column.
1359
-**
1360
-** Each pattern is adjusted to to start with "sym-" and be anchored at end.
1361
-**
1362
-** In MS_REGEXP mode, backslash can be used to protect delimiter characters.
1363
-** The backslashes are not removed from the regular expression.
1364
-**
1365
-** In addition to assembling and returning an SQL expression, this function
1366
-** makes an English-language description of the patterns being matched, suitable
1367
-** for display in the web interface.
1368
-**
1369
-** If any errors arise during processing, *zError is set to an error message.
1370
-** Otherwise it is set to NULL.
1371
-*/
1372
-static const char *tagMatchExpression(
1373
- MatchStyle matchStyle, /* Match style code */
1374
- const char *zTag, /* Tag name, match pattern, or pattern list */
1375
- const char **zDesc, /* Output expression description string */
1376
- const char **zError /* Output error string */
1377
-){
1378
- Blob expr = BLOB_INITIALIZER; /* SQL expression string assembly buffer */
1379
- Blob desc = BLOB_INITIALIZER; /* English description of match patterns */
1380
- Blob err = BLOB_INITIALIZER; /* Error text assembly buffer */
1381
- const char *zStart; /* Text at start of expression */
1382
- const char *zDelimiter; /* Text between expression terms */
1383
- const char *zEnd; /* Text at end of expression */
1384
- const char *zPrefix; /* Text before each match pattern */
1385
- const char *zSuffix; /* Text after each match pattern */
1386
- const char *zIntro; /* Text introducing pattern description */
1387
- const char *zPattern = 0; /* Previous quoted pattern */
1388
- const char *zFail = 0; /* Current failure message or NULL if okay */
1389
- const char *zOr = " or "; /* Text before final quoted pattern */
1390
- char cDel; /* Input delimiter character */
1391
- int i; /* Input match pattern length counter */
1392
-
1393
- /* Optimize exact matches by looking up the ID in advance to create a simple
1394
- * numeric comparison. Bypass the remainder of this function. */
1395
- if( matchStyle==MS_EXACT ){
1396
- *zDesc = tagQuote(-1, zTag);
1397
- return mprintf("(tagid=%d)", db_int(-1,
1398
- "SELECT tagid FROM tag WHERE tagname='sym-%q'", zTag));
1399
- }
1400
-
1401
- /* Decide pattern prefix and suffix strings according to match style. */
1402
- if( matchStyle==MS_GLOB ){
1403
- zStart = "(";
1404
- zDelimiter = " OR ";
1405
- zEnd = ")";
1406
- zPrefix = "tagname GLOB 'sym-";
1407
- zSuffix = "'";
1408
- zIntro = "glob pattern ";
1409
- }else if( matchStyle==MS_LIKE ){
1410
- zStart = "(";
1411
- zDelimiter = " OR ";
1412
- zEnd = ")";
1413
- zPrefix = "tagname LIKE 'sym-";
1414
- zSuffix = "'";
1415
- zIntro = "SQL LIKE pattern ";
1416
- }else if( matchStyle==MS_REGEXP ){
1417
- zStart = "(tagname REGEXP '^sym-(";
1418
- zDelimiter = "|";
1419
- zEnd = ")$')";
1420
- zPrefix = "";
1421
- zSuffix = "";
1422
- zIntro = "regular expression ";
1423
- }else/* if( matchStyle==MS_BRLIST )*/{
1424
- zStart = "tagname IN ('sym-";
1425
- zDelimiter = "','sym-";
1426
- zEnd = "')";
1427
- zPrefix = "";
1428
- zSuffix = "";
1429
- zIntro = "";
1430
- }
1431
-
1432
- /* Convert the list of matches into an SQL expression and text description. */
1433
- blob_zero(&expr);
1434
- blob_zero(&desc);
1435
- blob_zero(&err);
1436
- while( 1 ){
1437
- /* Skip leading delimiters. */
1438
- for( ; fossil_isspace(*zTag) || *zTag==','; ++zTag );
1439
-
1440
- /* Next non-delimiter character determines quoting. */
1441
- if( !*zTag ){
1442
- /* Terminate loop at end of string. */
1443
- break;
1444
- }else if( *zTag=='\'' || *zTag=='"' ){
1445
- /* If word is quoted, prepare to stop at end quote. */
1446
- cDel = *zTag;
1447
- ++zTag;
1448
- }else{
1449
- /* If word is not quoted, prepare to stop at delimiter. */
1450
- cDel = ',';
1451
- }
1452
-
1453
- /* Find the next delimiter character or end of string. */
1454
- for( i=0; zTag[i] && zTag[i]!=cDel; ++i ){
1455
- /* If delimiter is comma, also recognize spaces as delimiters. */
1456
- if( cDel==',' && fossil_isspace(zTag[i]) ){
1457
- break;
1458
- }
1459
-
1460
- /* In regexp mode, ignore delimiters following backslashes. */
1461
- if( matchStyle==MS_REGEXP && zTag[i]=='\\' && zTag[i+1] ){
1462
- ++i;
1463
- }
1464
- }
1465
-
1466
- /* Check for regular expression syntax errors. */
1467
- if( matchStyle==MS_REGEXP ){
1468
- ReCompiled *regexp;
1469
- char *zTagDup = fossil_strndup(zTag, i);
1470
- zFail = re_compile(&regexp, zTagDup, 0);
1471
- re_free(regexp);
1472
- fossil_free(zTagDup);
1473
- }
1474
-
1475
- /* Process success and error results. */
1476
- if( !zFail ){
1477
- /* Incorporate the match word into the output expression. %q is used to
1478
- * protect against SQL injection attacks by replacing ' with ''. */
1479
- blob_appendf(&expr, "%s%s%#q%s", blob_size(&expr) ? zDelimiter : zStart,
1480
- zPrefix, i, zTag, zSuffix);
1481
-
1482
- /* Build up the description string. */
1483
- if( !blob_size(&desc) ){
1484
- /* First tag: start with intro followed by first quoted tag. */
1485
- blob_append(&desc, zIntro, -1);
1486
- blob_append(&desc, tagQuote(i, zTag), -1);
1487
- }else{
1488
- if( zPattern ){
1489
- /* Third and subsequent tags: append comma then previous tag. */
1490
- blob_append(&desc, ", ", 2);
1491
- blob_append(&desc, zPattern, -1);
1492
- zOr = ", or ";
1493
- }
1494
-
1495
- /* Second and subsequent tags: store quoted tag for next iteration. */
1496
- zPattern = tagQuote(i, zTag);
1497
- }
1498
- }else{
1499
- /* On error, skip the match word and build up the error message buffer. */
1500
- if( !blob_size(&err) ){
1501
- blob_append(&err, "Error: ", 7);
1502
- }else{
1503
- blob_append(&err, ", ", 2);
1504
- }
1505
- blob_appendf(&err, "(%s%s: %s)", zIntro, tagQuote(i, zTag), zFail);
1506
- }
1507
-
1508
- /* Advance past all consumed input characters. */
1509
- zTag += i;
1510
- if( cDel!=',' && *zTag==cDel ){
1511
- ++zTag;
1512
- }
1513
- }
1514
-
1515
- /* Finalize and extract the pattern description. */
1516
- if( zPattern ){
1517
- blob_append(&desc, zOr, -1);
1518
- blob_append(&desc, zPattern, -1);
1519
- }
1520
- *zDesc = blob_str(&desc);
1521
-
1522
- /* Finalize and extract the error text. */
1523
- *zError = blob_size(&err) ? blob_str(&err) : 0;
1524
-
1525
- /* Finalize and extract the SQL expression. */
1526
- if( blob_size(&expr) ){
1527
- blob_append(&expr, zEnd, -1);
1528
- return blob_str(&expr);
1529
- }
1530
-
1531
- /* If execution reaches this point, the pattern was empty. Return NULL. */
1532
- return 0;
1533
-}
1534
-
15351309
/*
15361310
** Similar to fossil_expand_datetime()
15371311
**
15381312
** Add missing "-" characters into a date/time. Examples:
15391313
**
15401314
** 20190419 => 2019-04-19
15411315
** 201904 => 2019-04
15421316
*/
1543
-const char *timeline_expand_datetime(const char *zIn){
1544
- static char zEDate[20];
1545
- static const char aPunct[] = { 0, 0, '-', '-', ' ', ':', ':' };
1317
+const char *timeline_expand_datetime(const char *zIn, int *pbZulu){
1318
+ static char zEDate[16];
15461319
int n = (int)strlen(zIn);
15471320
int i, j;
15481321
1549
- /* Only three forms allowed:
1322
+ /* These forms are recognized:
1323
+ **
15501324
** (1) YYYYMMDD
15511325
** (2) YYYYMM
15521326
** (3) YYYYWW
15531327
*/
1328
+ if( n && (zIn[n-1]=='Z' || zIn[n-1]=='z') ){
1329
+ n--;
1330
+ if( pbZulu ) *pbZulu = 1;
1331
+ }else{
1332
+ if( pbZulu ) *pbZulu = 0;
1333
+ }
15541334
if( n!=8 && n!=6 ) return zIn;
15551335
15561336
/* Every character must be a digit */
1557
- for(i=0; fossil_isdigit(zIn[i]); i++){}
1337
+ for(i=0; i<n && fossil_isdigit(zIn[i]); i++){}
15581338
if( i!=n ) return zIn;
15591339
15601340
/* Expand the date */
1561
- for(i=j=0; zIn[i]; i++){
1562
- if( i>=4 && (i%2)==0 ){
1563
- zEDate[j++] = aPunct[i/2];
1564
- }
1341
+ for(i=j=0; i<n; i++){
1342
+ if( j==4 || j==7 ) zEDate[j++] = '-';
15651343
zEDate[j++] = zIn[i];
15661344
}
15671345
zEDate[j] = 0;
15681346
15691347
/* It looks like this may be a date. Return it with punctuation added. */
15701348
return zEDate;
15711349
}
1350
+
1351
+/*
1352
+** Check to see if the argument is a date-span for the ymd= query
1353
+** parameter. A valid date-span is of the form:
1354
+**
1355
+** 0123456789 123456 <-- index
1356
+** YYYYMMDD-YYYYMMDD
1357
+**
1358
+** with an optional "Z" timeline modifier at the end. Return true if
1359
+** the input is a valid date space and false if not.
1360
+*/
1361
+static int timeline_is_datespan(const char *zDay){
1362
+ size_t n = strlen(zDay);
1363
+ int i, d, m;
1364
+
1365
+ if( n<17 || n>18 ) return 0;
1366
+ if( n==18 ){
1367
+ if( zDay[17]!='Z' && zDay[17]!='z' ) return 0;
1368
+ n--;
1369
+ }
1370
+ if( zDay[8]!='-' ) return 0;
1371
+ for(i=0; i<17 && (fossil_isdigit(zDay[i]) || i==8); i++){}
1372
+ if( i!=17 ) return 0;
1373
+ i = atoi(zDay);
1374
+ d = i%100;
1375
+ if( d<1 || d>31 ) return 0;
1376
+ m = (i/100)%100;
1377
+ if( m<1 || m>12 ) return 0;
1378
+ i = atoi(zDay+9);
1379
+ d = i%100;
1380
+ if( d<1 || d>31 ) return 0;
1381
+ m = (i/100)%100;
1382
+ if( m<1 || m>12 ) return 0;
1383
+ return 1;
1384
+}
15721385
15731386
/*
15741387
** Find the first check-in encountered with a particular tag
15751388
** when moving either forwards are backwards in time from a
15761389
** particular starting point (iFrom). Return the rid of that
@@ -1591,10 +1404,11 @@
15911404
tagId = db_int(0, "SELECT tagid FROM tag WHERE tagname='sym-%q'", zEnd);
15921405
if( tagId==0 ){
15931406
endId = symbolic_name_to_rid(zEnd, "ci");
15941407
if( endId==0 ) return 0;
15951408
}
1409
+ db_pause_dml_log();
15961410
if( bForward ){
15971411
if( tagId ){
15981412
db_prepare(&q,
15991413
"WITH RECURSIVE dx(id,mtime) AS ("
16001414
" SELECT %d, event.mtime FROM event WHERE objid=%d"
@@ -1658,12 +1472,54 @@
16581472
}
16591473
if( db_step(&q)==SQLITE_ROW ){
16601474
ans = db_column_int(&q, 0);
16611475
}
16621476
db_finalize(&q);
1477
+ db_unpause_dml_log();
16631478
return ans;
16641479
}
1480
+
1481
+/*
1482
+** Add to the (temp) table zTab, RID values for every check-in
1483
+** identifier found on the zExtra string. Check-in names can be separated
1484
+** by commas or by whitespace.
1485
+*/
1486
+static void add_extra_rids(const char *zTab, const char *zExtra){
1487
+ int ii;
1488
+ int rid;
1489
+ int cnt;
1490
+ Blob sql;
1491
+ char *zX;
1492
+ char *zToDel;
1493
+ if( zExtra==0 ) return;
1494
+ cnt = 0;
1495
+ blob_init(&sql, 0, 0);
1496
+ zX = zToDel = fossil_strdup(zExtra);
1497
+ blob_append_sql(&sql, "INSERT OR IGNORE INTO \"%w\" VALUES", zTab);
1498
+ while( zX[0] ){
1499
+ char c;
1500
+ if( zX[0]==',' || zX[0]==' ' ){ zX++; continue; }
1501
+ for(ii=1; zX[ii] && zX[ii]!=',' && zX[ii]!=' '; ii++){}
1502
+ c = zX[ii];
1503
+ zX[ii] = 0;
1504
+ rid = name_to_rid(zX);
1505
+ if( rid>0 ){
1506
+ if( (cnt%10)==4 ){
1507
+ blob_append_sql(&sql,",\n ");
1508
+ }else if( cnt>0 ){
1509
+ blob_append_sql(&sql,",");
1510
+ }
1511
+ blob_append_sql(&sql, "(%d)", rid);
1512
+ cnt++;
1513
+ }
1514
+ zX[ii] = c;
1515
+ zX += ii;
1516
+ }
1517
+ if( cnt ) db_exec_sql(blob_sql_text(&sql));
1518
+ blob_reset(&sql);
1519
+ fossil_free(zToDel);
1520
+}
16651521
16661522
/*
16671523
** COMMAND: test-endpoint
16681524
**
16691525
** Usage: fossil test-endpoint BASE TAG ?OPTIONS?
@@ -1698,21 +1554,21 @@
16981554
/*
16991555
** WEBPAGE: timeline
17001556
**
17011557
** Query parameters:
17021558
**
1703
-** a=TIMEORTAG Show events after TIMEORTAG
1704
-** b=TIMEORTAG Show events before TIMEORTAG
1559
+** a=TIMEORTAG Show events after TIMEORTAG.
1560
+** b=TIMEORTAG Show events before TIMEORTAG.
17051561
** c=TIMEORTAG Show events that happen "circa" TIMEORTAG
17061562
** cf=FILEHASH Show events around the time of the first use of
1707
-** the file with FILEHASH
1563
+** the file with FILEHASH.
17081564
** m=TIMEORTAG Highlight the event at TIMEORTAG, or the closest available
17091565
** event if TIMEORTAG is not part of the timeline. If
17101566
** the t= or r= is used, the m event is added to the timeline
17111567
** if it isn't there already.
1712
-** x=HASHLIST Show all check-ins in the comma-separated HASHLIST
1713
-** in addition to check-ins specified by t= or r=
1568
+** x=LIST Show check-ins in the comma- or space-separated LIST
1569
+** in addition to check-ins specified by other parameters.
17141570
** sel1=TIMEORTAG Highlight the check-in at TIMEORTAG if it is part of
17151571
** the timeline. Similar to m= except TIMEORTAG must
17161572
** match a check-in that is already in the timeline.
17171573
** sel2=TIMEORTAG Like sel1= but use the secondary highlight.
17181574
** n=COUNT Maximum number of events. "all" for no limit
@@ -1732,63 +1588,71 @@
17321588
** from=CX ... shortest path from CX back to CHECKIN
17331589
** ft=CHECKIN "Forward To": Show decendents forward to CHECKIN
17341590
** d=CX ... from CX up to the time of CHECKIN
17351591
** from=CX ... shortest path from CX up to CHECKIN
17361592
** t=TAG Show only check-ins with the given TAG
1737
-** r=TAG Show check-ins related to TAG, equivalent to t=TAG&rel
1738
-** tl=TAGLIST Shorthand for t=TAGLIST&ms=brlist
1739
-** rl=TAGLIST Shorthand for r=TAGLIST&ms=brlist
1593
+** r=TAG Same as 't=TAG&rel'. Mnemonic: "Related"
1594
+** tl=TAGLIST Same as 't=TAGLIST&ms=brlist'. Mnemonic: "Tag List"
1595
+** rl=TAGLIST Same as 'r=TAGLIST&ms=brlist'. Mnemonic: "Related List"
1596
+** ml=TAGLIST Same as 'tl=TAGLIST&mionly'. Mnemonic: "Merge-in List"
1597
+** sl=TAGLIST "Sort List". Draw TAGLIST branches ordered left to right.
17401598
** rel Show related check-ins as well as those matching t=TAG
1741
-** mionly Limit rel to show ancestors but not descendants
1599
+** mionly Show related parents but not related children.
17421600
** nowiki Do not show wiki associated with branch or tag
1743
-** ms=MATCHSTYLE Set tag match style to EXACT, GLOB, LIKE, REGEXP
1601
+** ms=MATCHSTYLE Set tag name match algorithm. One of "exact", "glob",
1602
+** "like", or "regexp".
17441603
** u=USER Only show items associated with USER
17451604
** y=TYPE 'ci', 'w', 't', 'n', 'e', 'f', or 'all'.
17461605
** ss=VIEWSTYLE c: "Compact", v: "Verbose", m: "Modern", j: "Columnar",
1747
-** x: "Classic".
1606
+* x: "Classic".
17481607
** advm Use the "Advanced" or "Busy" menu design.
17491608
** ng No Graph.
17501609
** ncp Omit cherrypick merges
17511610
** nd Do not highlight the focus check-in
17521611
** nsm Omit the submenu
17531612
** nc Omit all graph colors other than highlights
17541613
** v Show details of files changed
17551614
** vfx Show complete text of forum messages
1756
-** f=CHECKIN Show family (immediate parents and children) of CHECKIN
1757
-** from=CHECKIN Path from...
1615
+** f=CHECKIN Family (immediate parents and children) of CHECKIN
1616
+** from=CHECKIN Path through common ancestor from...
17581617
** to=CHECKIN ... to this
17591618
** to2=CHECKIN ... backup name if to= doesn't resolve
17601619
** shortest ... show only the shortest path
17611620
** rel ... also show related checkins
17621621
** bt=PRIOR ... path from CHECKIN back to PRIOR
17631622
** ft=LATER ... path from CHECKIN forward to LATER
1623
+** me=CHECKIN Most direct path from...
1624
+** you=CHECKIN ... to this
1625
+** rel ... also show related checkins
17641626
** uf=FILE_HASH Show only check-ins that contain the given file version
1765
-** All qualifying check-ins are shown unless there is
1766
-** also an n= or n1= query parameter.
1627
+** All qualifying check-ins are shown unless there is
1628
+** also an n= or n1= query parameter.
17671629
** chng=GLOBLIST Show only check-ins that involve changes to a file whose
1768
-** name matches one of the comma-separate GLOBLIST
1630
+** name matches one of the comma-separate GLOBLIST
17691631
** brbg Background color determined by branch name
17701632
** ubg Background color determined by user
17711633
** deltabg Background color red for delta manifests or green
17721634
** for baseline manifests
17731635
** namechng Show only check-ins that have filename changes
17741636
** forks Show only forks and their children
17751637
** cherrypicks Show all cherrypicks
1776
-** ym=YYYY-MM Show only events for the given year/month
1777
-** yw=YYYY-WW Show only events for the given week of the given year
1778
-** yw=YYYY-MM-DD Show events for the week that includes the given day
1779
-** ymd=YYYY-MM-DD Show only events on the given day. The use "ymd=now"
1780
-** to see all changes for the current week.
1638
+** ym=YYYYMM Show only events for the given year/month
1639
+** yw=YYYYWW Show only events for the given week of the given year
1640
+** yw=YYYYMMDD Show events for the week that includes the given day
1641
+** ymd=YYYYMMDD Show only events on the given day. The use "ymd=now"
1642
+** to see all changes for the current week. Add "z" at end
1643
+** to divide days at UTC instead of localtime days.
1644
+** Use ymd=YYYYMMDD-YYYYMMDD (with optional "z") for a range.
17811645
** year=YYYY Show only events on the given year. The use "year=0"
17821646
** to see all changes for the current year.
17831647
** days=N Show events over the previous N days
17841648
** datefmt=N Override the date format: 0=HH:MM, 1=HH:MM:SS,
17851649
** 2=YYYY-MM-DD HH:MM:SS, 3=YYMMDD HH:MM, and 4 means "off".
17861650
** bisect Show the check-ins that are in the current bisect
17871651
** oldestfirst Show events oldest first.
17881652
** showid Show RIDs
1789
-** showsql Show the SQL text
1653
+** showsql Show the SQL used to generate the report
17901654
**
17911655
** p= and d= can appear individually or together. If either p= or d=
17921656
** appear, then u=, y=, a=, and b= are ignored.
17931657
**
17941658
** If both a= and b= appear then both upper and lower bounds are honored.
@@ -1862,14 +1726,20 @@
18621726
int advancedMenu = 0; /* Use the advanced menu design */
18631727
char *zPlural; /* Ending for plural forms */
18641728
int showCherrypicks = 1; /* True to show cherrypick merges */
18651729
int haveParameterN; /* True if n= query parameter present */
18661730
int from_to_mode = 0; /* 0: from,to. 1: from,ft 2: from,bt */
1731
+ int showSql = PB("showsql"); /* True to show the SQL */
1732
+ Blob allSql; /* Copy of all SQL text */
18671733
18681734
login_check_credentials();
18691735
url_initialize(&url, "timeline");
18701736
cgi_query_parameters_to_url(&url);
1737
+ blob_init(&allSql, 0, 0);
1738
+
1739
+ /* The "mionly" query parameter is like "rel", but shows merge-ins only */
1740
+ if( P("mionly")!=0 ) related = 2;
18711741
18721742
(void)P_NoBot("ss")
18731743
/* "ss" is processed via the udc but at least one spider likes to
18741744
** try to SQL inject via this argument, so let's catch that. */;
18751745
@@ -1984,49 +1854,52 @@
19841854
19851855
/* Check for tl=TAGLIST and rl=TAGLIST which are abbreviations for
19861856
** t=TAGLIST&ms=brlist and r=TAGLIST&ms=brlist repectively. */
19871857
if( zBrName==0 && zTagName==0 ){
19881858
const char *z;
1859
+ const char *zPattern = 0;
19891860
if( (z = P("tl"))!=0 ){
1990
- zTagName = z;
1991
- zMatchStyle = "brlist";
1861
+ zPattern = zTagName = z;
1862
+ }else if( (z = P("rl"))!=0 ){
1863
+ zPattern = zBrName = z;
1864
+ if( related==0 ) related = 1;
1865
+ }else if( (z = P("ml"))!=0 ){
1866
+ zPattern = zBrName = z;
1867
+ if( related==0 ) related = 2;
19921868
}
1993
- if( (z = P("rl"))!=0 ){
1994
- zBrName = z;
1995
- related = 1;
1996
- zMatchStyle = "brlist";
1869
+ if( zPattern!=0 && zMatchStyle==0 ){
1870
+ /* If there was no ms= query parameter, set the match style to
1871
+ ** "glob" if the pattern appears to contain GLOB character, or
1872
+ ** "brlist" if it does not. */
1873
+ if( strpbrk(zPattern,"*[?") ){
1874
+ zMatchStyle = "glob";
1875
+ }else{
1876
+ zMatchStyle = "brlist";
1877
+ }
19971878
}
19981879
}
19991880
20001881
/* Convert r=TAG to t=TAG&rel in order to populate the UI style widgets. */
2001
- if( zBrName && !related ){
1882
+ if( zBrName ){
20021883
cgi_delete_query_parameter("r");
20031884
cgi_set_query_parameter("t", zBrName); (void)P("t");
20041885
cgi_set_query_parameter("rel", "1");
20051886
zTagName = zBrName;
2006
- related = 1;
1887
+ if( related==0 ) related = 1;
20071888
zType = "ci";
20081889
}
20091890
20101891
/* Ignore empty tag query strings. */
20111892
if( zTagName && !*zTagName ){
20121893
zTagName = 0;
20131894
}
20141895
20151896
/* Finish preliminary processing of tag match queries. */
1897
+ matchStyle = match_style(zMatchStyle, MS_EXACT);
20161898
if( zTagName ){
20171899
zType = "ci";
2018
- /* Interpet the tag style string. */
2019
- if( fossil_stricmp(zMatchStyle, "glob")==0 ){
2020
- matchStyle = MS_GLOB;
2021
- }else if( fossil_stricmp(zMatchStyle, "like")==0 ){
2022
- matchStyle = MS_LIKE;
2023
- }else if( fossil_stricmp(zMatchStyle, "regexp")==0 ){
2024
- matchStyle = MS_REGEXP;
2025
- }else if( fossil_stricmp(zMatchStyle, "brlist")==0 ){
2026
- matchStyle = MS_BRLIST;
2027
- }else{
1900
+ if( matchStyle==MS_EXACT ){
20281901
/* For exact maching, inhibit links to the selected tag. */
20291902
zThisTag = zTagName;
20301903
Th_Store("current_checkin", zTagName);
20311904
}
20321905
@@ -2034,11 +1907,11 @@
20341907
if( advancedMenu ){
20351908
style_submenu_checkbox("rel", "Related", 0, 0);
20361909
}
20371910
20381911
/* Construct the tag match expression. */
2039
- zTagSql = tagMatchExpression(matchStyle, zTagName, &zMatchDesc, &zError);
1912
+ zTagSql = match_tag_sqlexpr(matchStyle, zTagName, &zMatchDesc, &zError);
20401913
}
20411914
20421915
if( zMark && zMark[0]==0 ){
20431916
if( zAfter ) zMark = zAfter;
20441917
if( zBefore ) zMark = zBefore;
@@ -2082,10 +1955,11 @@
20821955
}
20831956
if( PB("nc") ){
20841957
tmFlags &= ~(TIMELINE_DELTA|TIMELINE_BRCOLOR|TIMELINE_UCOLOR);
20851958
tmFlags |= TIMELINE_NOCOLOR;
20861959
}
1960
+ if( showSql ) db_append_dml_to_blob(&allSql);
20871961
if( zUses!=0 ){
20881962
int ufid = db_int(0, "SELECT rid FROM blob WHERE uuid GLOB '%q*'", zUses);
20891963
if( ufid ){
20901964
zUses = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", ufid);
20911965
db_multi_exec("CREATE TEMP TABLE usesfile(rid INTEGER PRIMARY KEY)");
@@ -2099,42 +1973,42 @@
20991973
}
21001974
if( renameOnly ){
21011975
db_multi_exec(
21021976
"CREATE TEMP TABLE rnfile(rid INTEGER PRIMARY KEY);"
21031977
"INSERT OR IGNORE INTO rnfile"
2104
- " SELECT mid FROM mlink WHERE pfnid>0 AND pfnid!=fnid;"
1978
+ " SELECT mid FROM mlink WHERE pfnid>0 AND pfnid!=fnid;"
21051979
);
21061980
disableY = 1;
21071981
}
21081982
if( forkOnly ){
21091983
db_multi_exec(
21101984
"CREATE TEMP TABLE rnfork(rid INTEGER PRIMARY KEY);\n"
21111985
"INSERT OR IGNORE INTO rnfork(rid)\n"
21121986
" SELECT pid FROM plink\n"
2113
- " WHERE (SELECT value FROM tagxref WHERE tagid=%d AND rid=cid)=="
2114
- " (SELECT value FROM tagxref WHERE tagid=%d AND rid=pid)\n"
2115
- " GROUP BY pid"
1987
+ " WHERE (SELECT value FROM tagxref WHERE tagid=%d AND rid=cid)==\n"
1988
+ " (SELECT value FROM tagxref WHERE tagid=%d AND rid=pid)\n"
1989
+ " GROUP BY pid\n"
21161990
" HAVING count(*)>1;\n"
2117
- "INSERT OR IGNORE INTO rnfork(rid)"
1991
+ "INSERT OR IGNORE INTO rnfork(rid)\n"
21181992
" SELECT cid FROM plink\n"
2119
- " WHERE (SELECT value FROM tagxref WHERE tagid=%d AND rid=cid)=="
2120
- " (SELECT value FROM tagxref WHERE tagid=%d AND rid=pid)\n"
2121
- " GROUP BY cid"
1993
+ " WHERE (SELECT value FROM tagxref WHERE tagid=%d AND rid=cid)==\n"
1994
+ " (SELECT value FROM tagxref WHERE tagid=%d AND rid=pid)\n"
1995
+ " GROUP BY cid\n"
21221996
" HAVING count(*)>1;\n",
21231997
TAG_BRANCH, TAG_BRANCH, TAG_BRANCH, TAG_BRANCH
21241998
);
21251999
db_multi_exec(
21262000
"INSERT OR IGNORE INTO rnfork(rid)\n"
21272001
" SELECT cid FROM plink\n"
2128
- " WHERE pid IN rnfork"
2129
- " AND (SELECT value FROM tagxref WHERE tagid=%d AND rid=cid)=="
2130
- " (SELECT value FROM tagxref WHERE tagid=%d AND rid=pid)\n"
2131
- " UNION "
2002
+ " WHERE pid IN rnfork\n"
2003
+ " AND (SELECT value FROM tagxref WHERE tagid=%d AND rid=cid)==\n"
2004
+ " (SELECT value FROM tagxref WHERE tagid=%d AND rid=pid)\n"
2005
+ " UNION\n"
21322006
" SELECT pid FROM plink\n"
2133
- " WHERE cid IN rnfork"
2134
- " AND (SELECT value FROM tagxref WHERE tagid=%d AND rid=cid)=="
2135
- " (SELECT value FROM tagxref WHERE tagid=%d AND rid=pid)\n",
2007
+ " WHERE cid IN rnfork\n"
2008
+ " AND (SELECT value FROM tagxref WHERE tagid=%d AND rid=cid)==\n"
2009
+ " (SELECT value FROM tagxref WHERE tagid=%d AND rid=pid)\n",
21362010
TAG_BRANCH, TAG_BRANCH, TAG_BRANCH, TAG_BRANCH
21372011
);
21382012
tmFlags |= TIMELINE_UNHIDE;
21392013
zType = "ci";
21402014
disableY = 1;
@@ -2207,77 +2081,114 @@
22072081
PathNode *p = 0;
22082082
const char *zFrom = 0;
22092083
const char *zTo = 0;
22102084
Blob ins;
22112085
int nNodeOnPath = 0;
2086
+ int commonAncs = 0; /* Common ancestors of me_rid and you_rid. */
2087
+ int earlierRid = 0, laterRid = 0;
22122088
22132089
if( from_rid && to_rid ){
22142090
if( from_to_mode==0 ){
22152091
p = path_shortest(from_rid, to_rid, noMerge, 0, 0);
22162092
}else if( from_to_mode==1 ){
22172093
p = path_shortest(from_rid, to_rid, 0, 1, 0);
2094
+ earlierRid = commonAncs = from_rid;
2095
+ laterRid = to_rid;
22182096
}else{
22192097
p = path_shortest(to_rid, from_rid, 0, 1, 0);
2098
+ earlierRid = commonAncs = to_rid;
2099
+ laterRid = from_rid;
22202100
}
22212101
zFrom = P("from");
22222102
zTo = zTo2 ? zTo2 : P("to");
22232103
}else{
2224
- if( path_common_ancestor(me_rid, you_rid) ){
2104
+ commonAncs = path_common_ancestor(me_rid, you_rid);
2105
+ if( commonAncs!=0 ){
22252106
p = path_first();
22262107
}
2227
- zFrom = P("me");
2228
- zTo = P("you");
2108
+ if( commonAncs==you_rid ){
2109
+ zFrom = P("you");
2110
+ zTo = P("me");
2111
+ earlierRid = you_rid;
2112
+ laterRid = me_rid;
2113
+ }else{
2114
+ zFrom = P("me");
2115
+ zTo = P("you");
2116
+ earlierRid = me_rid;
2117
+ laterRid = you_rid;
2118
+ }
22292119
}
22302120
blob_init(&ins, 0, 0);
22312121
db_multi_exec(
2232
- "CREATE TABLE IF NOT EXISTS temp.pathnode(x INTEGER PRIMARY KEY);"
2122
+ "CREATE TEMP TABLE IF NOT EXISTS pathnode(x INTEGER PRIMARY KEY);"
22332123
);
22342124
if( p ){
2125
+ int cnt = 4;
22352126
blob_init(&ins, 0, 0);
22362127
blob_append_sql(&ins, "INSERT INTO pathnode(x) VALUES(%d)", p->rid);
22372128
p = p->u.pTo;
22382129
while( p ){
2239
- blob_append_sql(&ins, ",(%d)", p->rid);
2130
+ if( cnt==8 ){
2131
+ blob_append_sql(&ins, ",\n (%d)", p->rid);
2132
+ cnt = 0;
2133
+ }else{
2134
+ cnt++;
2135
+ blob_append_sql(&ins, ",(%d)", p->rid);
2136
+ }
22402137
p = p->u.pTo;
22412138
}
22422139
}
22432140
path_reset();
22442141
db_multi_exec("%s", blob_str(&ins)/*safe-for-%s*/);
22452142
blob_reset(&ins);
2246
- if( related || P("mionly") ){
2143
+ if( related ){
22472144
db_multi_exec(
2248
- "CREATE TABLE IF NOT EXISTS temp.related(x INTEGER PRIMARY KEY);"
2145
+ "CREATE TEMP TABLE IF NOT EXISTS related(x INTEGER PRIMARY KEY);"
22492146
"INSERT OR IGNORE INTO related(x)"
2250
- " SELECT pid FROM plink WHERE cid IN pathnode AND NOT isprim;"
2147
+ " SELECT pid FROM plink WHERE cid IN pathnode AND NOT isprim;"
22512148
);
2252
- if( P("mionly")==0 ){
2149
+ if( related==1 ){
22532150
db_multi_exec(
22542151
"INSERT OR IGNORE INTO related(x)"
2255
- " SELECT cid FROM plink WHERE pid IN pathnode;"
2152
+ " SELECT cid FROM plink WHERE pid IN pathnode;"
22562153
);
22572154
}
22582155
if( showCherrypicks ){
22592156
db_multi_exec(
22602157
"INSERT OR IGNORE INTO related(x)"
2261
- " SELECT parentid FROM cherrypick WHERE childid IN pathnode;"
2158
+ " SELECT parentid FROM cherrypick WHERE childid IN pathnode;"
22622159
);
2263
- if( P("mionly")==0 ){
2160
+ if( related==1 ){
22642161
db_multi_exec(
22652162
"INSERT OR IGNORE INTO related(x)"
2266
- " SELECT childid FROM cherrypick WHERE parentid IN pathnode;"
2163
+ " SELECT childid FROM cherrypick WHERE parentid IN pathnode;"
22672164
);
22682165
}
2166
+ }
2167
+ if( earlierRid && laterRid && commonAncs==earlierRid ){
2168
+ /* On a query with me=XXX, you=YYY, and rel, omit all nodes that
2169
+ ** are not ancestors of either XXX or YYY, as those nodes tend to
2170
+ ** be extraneous */
2171
+ db_multi_exec(
2172
+ "CREATE TEMP TABLE IF NOT EXISTS ok(rid INTEGER PRIMARY KEY)"
2173
+ );
2174
+ compute_ancestors(laterRid, 0, 0, earlierRid);
2175
+ db_multi_exec(
2176
+ "DELETE FROM related WHERE x NOT IN ok;"
2177
+ );
22692178
}
22702179
db_multi_exec("INSERT OR IGNORE INTO pathnode SELECT x FROM related");
22712180
}
2181
+ add_extra_rids("pathnode",P("x"));
22722182
blob_append_sql(&sql, " AND event.objid IN pathnode");
22732183
if( zChng && zChng[0] ){
22742184
db_multi_exec(
2275
- "DELETE FROM pathnode "
2276
- " WHERE NOT EXISTS(SELECT 1 FROM mlink, filename"
2277
- " WHERE mlink.mid=x"
2278
- " AND mlink.fnid=filename.fnid AND %s)",
2185
+ "DELETE FROM pathnode\n"
2186
+ " WHERE NOT EXISTS(SELECT 1 FROM mlink, filename\n"
2187
+ " WHERE mlink.mid=x\n"
2188
+ " AND mlink.fnid=filename.fnid\n"
2189
+ " AND %s)",
22792190
glob_expr("filename.name", zChng)
22802191
);
22812192
}
22822193
tmFlags |= TIMELINE_XMERGE | TIMELINE_FILLGAPS;
22832194
db_multi_exec("%s", blob_sql_text(&sql));
@@ -2331,18 +2242,18 @@
23312242
if( !haveParameterN ) nEntry = 10;
23322243
}
23332244
db_multi_exec(
23342245
"CREATE TEMP TABLE IF NOT EXISTS ok(rid INTEGER PRIMARY KEY)"
23352246
);
2247
+ add_extra_rids("ok", P("x"));
23362248
zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d",
23372249
p_rid ? p_rid : d_rid);
23382250
zCiName = zDPName;
23392251
if( zCiName==0 ) zCiName = zUuid;
23402252
blob_append_sql(&sql, " AND event.objid IN ok");
23412253
nd = 0;
23422254
if( d_rid ){
2343
- Stmt s;
23442255
double rStopTime = 9e99;
23452256
zFwdTo = P("ft");
23462257
if( zFwdTo ){
23472258
double rStartDate = db_double(0.0,
23482259
"SELECT mtime FROM event WHERE objid=%d", d_rid);
@@ -2354,27 +2265,25 @@
23542265
if( !haveParameterN ) nEntry = 0;
23552266
rStopTime = db_double(9e99,
23562267
"SELECT mtime FROM event WHERE objid=%d", ridFwdTo);
23572268
}
23582269
}
2359
- db_prepare(&s,
2360
- "WITH RECURSIVE"
2361
- " dx(rid,mtime) AS ("
2362
- " SELECT %d, 0"
2363
- " UNION"
2364
- " SELECT plink.cid, plink.mtime FROM dx, plink"
2365
- " WHERE plink.pid=dx.rid"
2366
- " AND (:stop>=8e99 OR plink.mtime<=:stop)"
2367
- " ORDER BY 2"
2368
- " )"
2270
+ if( rStopTime<9e99 ){
2271
+ rStopTime += 5.8e-6; /* Round up by 1/2 second */
2272
+ }
2273
+ db_multi_exec(
2274
+ "WITH RECURSIVE dx(rid,mtime) AS (\n"
2275
+ " SELECT %d, 0\n"
2276
+ " UNION\n"
2277
+ " SELECT plink.cid, plink.mtime FROM dx, plink\n"
2278
+ " WHERE plink.pid=dx.rid\n"
2279
+ " AND plink.mtime<=%.*g\n"
2280
+ " ORDER BY 2\n"
2281
+ ")\n"
23692282
"INSERT OR IGNORE INTO ok SELECT rid FROM dx LIMIT %d",
2370
- d_rid, nEntry<=0 ? -1 : nEntry+1
2283
+ d_rid, rStopTime<8e99 ? 17 : 2, rStopTime, nEntry<=0 ? -1 : nEntry+1
23712284
);
2372
- db_bind_double(&s, ":stop", rStopTime);
2373
- db_step(&s);
2374
- db_finalize(&s);
2375
- /* compute_descendants(d_rid, nEntry==0 ? 0 : nEntry+1); */
23762285
nd = db_int(0, "SELECT count(*)-1 FROM ok");
23772286
if( nd>=0 ) db_multi_exec("%s", blob_sql_text(&sql));
23782287
if( nd>0 || p_rid==0 ){
23792288
blob_appendf(&desc, "%d descendant%s", nd,(1==nd)?"":"s");
23802289
}
@@ -2483,67 +2392,76 @@
24832392
if( zChng && *zChng ){
24842393
addFileGlobExclusion(zChng, &cond);
24852394
tmFlags |= TIMELINE_XMERGE;
24862395
}
24872396
if( zUses ){
2488
- blob_append_sql(&cond, " AND event.objid IN usesfile ");
2397
+ blob_append_sql(&cond, " AND event.objid IN usesfile\n");
24892398
}
24902399
if( renameOnly ){
2491
- blob_append_sql(&cond, " AND event.objid IN rnfile ");
2400
+ blob_append_sql(&cond, " AND event.objid IN rnfile\n");
24922401
}
24932402
if( forkOnly ){
2494
- blob_append_sql(&cond, " AND event.objid IN rnfork ");
2403
+ blob_append_sql(&cond, " AND event.objid IN rnfork\n");
24952404
}
24962405
if( cpOnly && showCherrypicks ){
24972406
db_multi_exec(
24982407
"CREATE TEMP TABLE IF NOT EXISTS cpnodes(rid INTEGER PRIMARY KEY);"
24992408
"INSERT OR IGNORE INTO cpnodes SELECT childid FROM cherrypick;"
25002409
"INSERT OR IGNORE INTO cpnodes SELECT parentid FROM cherrypick;"
25012410
);
2502
- blob_append_sql(&cond, " AND event.objid IN cpnodes ");
2411
+ blob_append_sql(&cond, " AND event.objid IN cpnodes\n");
25032412
}
25042413
if( bisectLocal || zBisect!=0 ){
2505
- blob_append_sql(&cond, " AND event.objid IN (SELECT rid FROM bilog) ");
2414
+ blob_append_sql(&cond, " AND event.objid IN (SELECT rid FROM bilog)\n");
25062415
}
25072416
if( zYearMonth ){
25082417
char *zNext;
2509
- zYearMonth = timeline_expand_datetime(zYearMonth);
2510
- if( strlen(zYearMonth)>7 ){
2511
- zYearMonth = mprintf("%.7s", zYearMonth);
2512
- }
2418
+ int bZulu = 0;
2419
+ const char *zTZMod;
2420
+ zYearMonth = timeline_expand_datetime(zYearMonth, &bZulu);
2421
+ zYearMonth = mprintf("%.7s", zYearMonth);
25132422
if( db_int(0,"SELECT julianday('%q-01') IS NULL", zYearMonth) ){
25142423
zYearMonth = db_text(0, "SELECT strftime('%%Y-%%m','now');");
25152424
}
2516
- zNext = db_text(0, "SELECT strftime('%%Y-%%m','%q-01','+1 month');",
2517
- zYearMonth);
2518
- if( db_int(0,
2519
- "SELECT EXISTS (SELECT 1 FROM event CROSS JOIN blob"
2520
- " WHERE blob.rid=event.objid AND mtime>=julianday('%q-01')%s)",
2521
- zNext, blob_sql_text(&cond))
2522
- ){
2523
- zNewerButton = fossil_strdup(url_render(&url, "ym", zNext, 0, 0));
2524
- zNewerButtonLabel = "Following month";
2525
- }
2526
- fossil_free(zNext);
2527
- zNext = db_text(0, "SELECT strftime('%%Y-%%m','%q-01','-1 month');",
2528
- zYearMonth);
2529
- if( db_int(0,
2530
- "SELECT EXISTS (SELECT 1 FROM event CROSS JOIN blob"
2531
- " WHERE blob.rid=event.objid AND mtime<julianday('%q-01')%s)",
2532
- zYearMonth, blob_sql_text(&cond))
2533
- ){
2534
- zOlderButton = fossil_strdup(url_render(&url, "ym", zNext, 0, 0));
2535
- zOlderButtonLabel = "Previous month";
2536
- }
2537
- fossil_free(zNext);
2538
- blob_append_sql(&cond, " AND %Q=strftime('%%Y-%%m',event.mtime) ",
2539
- zYearMonth);
2540
- nEntry = -1;
2425
+ zTZMod = (bZulu==0 && fossil_ui_localtime()) ? "utc" : "+00:00";
2426
+ if( db_int(0,
2427
+ "SELECT EXISTS (SELECT 1 FROM event CROSS JOIN blob"
2428
+ " WHERE blob.rid=event.objid"
2429
+ " AND mtime>=julianday('%q-01',%Q)%s)",
2430
+ zYearMonth, zTZMod, blob_sql_text(&cond))
2431
+ ){
2432
+ zNext = db_text(0, "SELECT strftime('%%Y%%m%q','%q-01','+1 month');",
2433
+ &"Z"[!bZulu], zYearMonth);
2434
+ zNewerButton = fossil_strdup(url_render(&url, "ym", zNext, 0, 0));
2435
+ zNewerButtonLabel = "Following month";
2436
+ fossil_free(zNext);
2437
+ }
2438
+ if( db_int(0,
2439
+ "SELECT EXISTS (SELECT 1 FROM event CROSS JOIN blob"
2440
+ " WHERE blob.rid=event.objid"
2441
+ " AND mtime<julianday('%q-01',%Q)%s)",
2442
+ zYearMonth, zTZMod, blob_sql_text(&cond))
2443
+ ){
2444
+ zNext = db_text(0, "SELECT strftime('%%Y%%m%q','%q-01','-1 month');",
2445
+ &"Z"[!bZulu], zYearMonth);
2446
+ zOlderButton = fossil_strdup(url_render(&url, "ym", zNext, 0, 0));
2447
+ zOlderButtonLabel = "Previous month";
2448
+ fossil_free(zNext);
2449
+ }
2450
+ blob_append_sql(&cond,
2451
+ " AND event.mtime>=julianday('%q-01',%Q)"
2452
+ " AND event.mtime<julianday('%q-01',%Q,'+1 month')\n",
2453
+ zYearMonth, zTZMod, zYearMonth, zTZMod);
2454
+ nEntry = -1;
2455
+ /* Adjust the zYearMonth for the title */
2456
+ zYearMonth = mprintf("%z-01%s", zYearMonth, &"Z"[!bZulu]);
25412457
}
25422458
else if( zYearWeek ){
25432459
char *z, *zNext;
2544
- zYearWeek = timeline_expand_datetime(zYearWeek);
2460
+ int bZulu = 0;
2461
+ const char *zTZMod;
2462
+ zYearWeek = timeline_expand_datetime(zYearWeek, &bZulu);
25452463
z = db_text(0, "SELECT strftime('%%Y-%%W',%Q)", zYearWeek);
25462464
if( z && z[0] ){
25472465
zYearWeekStart = db_text(0, "SELECT date(%Q,'-6 days','weekday 1')",
25482466
zYearWeek);
25492467
zYearWeek = z;
@@ -2560,64 +2478,152 @@
25602478
"SELECT date('now','-6 days','weekday 1');");
25612479
zYearWeek = db_text(0,
25622480
"SELECT strftime('%%Y-%%W','now','-6 days','weekday 1')");
25632481
}
25642482
}
2565
- zNext = db_text(0, "SELECT date(%Q,'+7 day');", zYearWeekStart);
2566
- if( db_int(0,
2567
- "SELECT EXISTS (SELECT 1 FROM event CROSS JOIN blob"
2568
- " WHERE blob.rid=event.objid AND mtime>=julianday(%Q)%s)",
2569
- zNext, blob_sql_text(&cond))
2570
- ){
2571
- zNewerButton = fossil_strdup(url_render(&url, "yw", zNext, 0, 0));
2572
- zNewerButtonLabel = "Following week";
2573
- }
2574
- fossil_free(zNext);
2575
- zNext = db_text(0, "SELECT date(%Q,'-7 days');", zYearWeekStart);
2576
- if( db_int(0,
2577
- "SELECT EXISTS (SELECT 1 FROM event CROSS JOIN blob"
2578
- " WHERE blob.rid=event.objid AND mtime<julianday(%Q)%s)",
2579
- zYearWeekStart, blob_sql_text(&cond))
2580
- ){
2581
- zOlderButton = fossil_strdup(url_render(&url, "yw", zNext, 0, 0));
2582
- zOlderButtonLabel = "Previous week";
2583
- }
2584
- fossil_free(zNext);
2585
- blob_append_sql(&cond, " AND %Q=strftime('%%Y-%%W',event.mtime) ",
2586
- zYearWeek);
2587
- nEntry = -1;
2483
+ zTZMod = (bZulu==0 && fossil_ui_localtime()) ? "utc" : "+00:00";
2484
+ if( db_int(0,
2485
+ "SELECT EXISTS (SELECT 1 FROM event CROSS JOIN blob"
2486
+ " WHERE blob.rid=event.objid"
2487
+ " AND mtime>=julianday(%Q,%Q)%s)",
2488
+ zYearWeekStart, zTZMod, blob_sql_text(&cond))
2489
+ ){
2490
+ zNext = db_text(0, "SELECT strftime('%%Y%%W%q',%Q,'+7 day');",
2491
+ &"Z"[!bZulu], zYearWeekStart);
2492
+ zNewerButton = fossil_strdup(url_render(&url, "yw", zNext, 0, 0));
2493
+ zNewerButtonLabel = "Following week";
2494
+ fossil_free(zNext);
2495
+ }
2496
+ if( db_int(0,
2497
+ "SELECT EXISTS (SELECT 1 FROM event CROSS JOIN blob"
2498
+ " WHERE blob.rid=event.objid"
2499
+ " AND mtime<julianday(%Q,%Q)%s)",
2500
+ zYearWeekStart, zTZMod, blob_sql_text(&cond))
2501
+ ){
2502
+ zNext = db_text(0, "SELECT strftime('%%Y%%W%q',%Q,'-7 days');",
2503
+ &"Z"[!bZulu], zYearWeekStart);
2504
+ zOlderButton = fossil_strdup(url_render(&url, "yw", zNext, 0, 0));
2505
+ zOlderButtonLabel = "Previous week";
2506
+ fossil_free(zNext);
2507
+ }
2508
+ blob_append_sql(&cond,
2509
+ " AND event.mtime>=julianday(%Q,%Q)"
2510
+ " AND event.mtime<julianday(%Q,%Q,'+7 days')\n",
2511
+ zYearWeekStart, zTZMod, zYearWeekStart, zTZMod);
2512
+ nEntry = -1;
2513
+ if( fossil_ui_localtime() && bZulu ){
2514
+ zYearWeekStart = mprintf("%zZ", zYearWeekStart);
2515
+ }
2516
+ }
2517
+ else if( zDay && timeline_is_datespan(zDay) ){
2518
+ char *zNext;
2519
+ char *zStart, *zEnd;
2520
+ int nDay;
2521
+ int bZulu = 0;
2522
+ const char *zTZMod;
2523
+ zEnd = db_text(0, "SELECT date(%Q)",
2524
+ timeline_expand_datetime(zDay+9, &bZulu));
2525
+ zStart = db_text(0, "SELECT date('%.4q-%.2q-%.2q')",
2526
+ zDay, zDay+4, zDay+6);
2527
+ nDay = db_int(0, "SELECT julianday(%Q)-julianday(%Q)", zEnd, zStart);
2528
+ if( nDay==0 ){
2529
+ zDay = &zDay[9];
2530
+ goto single_ymd;
2531
+ }
2532
+ if( nDay<0 ){
2533
+ char *zTemp = zEnd;
2534
+ zEnd = zStart;
2535
+ zStart = zTemp;
2536
+ nDay = 1 - nDay;
2537
+ }else{
2538
+ nDay += 1;
2539
+ }
2540
+ zTZMod = (bZulu==0 && fossil_ui_localtime()) ? "utc" : "+00:00";
2541
+ if( nDay>0 && db_int(0,
2542
+ "SELECT EXISTS (SELECT 1 FROM event CROSS JOIN blob"
2543
+ " WHERE blob.rid=event.objid"
2544
+ " AND mtime>=julianday(%Q,'1 day',%Q)%s)",
2545
+ zEnd, zTZMod, blob_sql_text(&cond))
2546
+ ){
2547
+ zNext = db_text(0,
2548
+ "SELECT strftime('%%Y%%m%%d-',%Q,'%d days')||"
2549
+ "strftime('%%Y%%m%%d%q',%Q,'%d day');",
2550
+ zStart, nDay, &"Z"[!bZulu], zEnd, nDay);
2551
+ zNewerButton = fossil_strdup(url_render(&url, "ymd", zNext, 0, 0));
2552
+ zNewerButtonLabel = mprintf("Following %d days", nDay);
2553
+ fossil_free(zNext);
2554
+ }
2555
+ if( nDay>1 && db_int(0,
2556
+ "SELECT EXISTS (SELECT 1 FROM event CROSS JOIN blob"
2557
+ " WHERE blob.rid=event.objid"
2558
+ " AND mtime<julianday(%Q,'-1 day',%Q)%s)",
2559
+ zStart, zTZMod, blob_sql_text(&cond))
2560
+ ){
2561
+ zNext = db_text(0,
2562
+ "SELECT strftime('%%Y%%m%%d-',%Q,'%d days')||"
2563
+ "strftime('%%Y%%m%%d%q',%Q,'%d day');",
2564
+ zStart, -nDay, &"Z"[!bZulu], zEnd, -nDay);
2565
+ zOlderButton = fossil_strdup(url_render(&url, "ymd", zNext, 0, 0));
2566
+ zOlderButtonLabel = mprintf("Previous %d days", nDay);
2567
+ fossil_free(zNext);
2568
+ }
2569
+ blob_append_sql(&cond,
2570
+ " AND event.mtime>=julianday(%Q,%Q)"
2571
+ " AND event.mtime<julianday(%Q,%Q,'+1 day')\n",
2572
+ zStart, zTZMod, zEnd, zTZMod);
2573
+ nEntry = -1;
2574
+
2575
+ if( fossil_ui_localtime() && bZulu ){
2576
+ zDay = mprintf("%d days between %zZ and %zZ", nDay, zStart, zEnd);
2577
+ }else{
2578
+ zDay = mprintf("%d days between %z and %z", nDay, zStart, zEnd);
2579
+ }
25882580
}
25892581
else if( zDay ){
25902582
char *zNext;
2591
- zDay = timeline_expand_datetime(zDay);
2583
+ int bZulu = 0;
2584
+ const char *zTZMod;
2585
+ single_ymd:
2586
+ bZulu = 0;
2587
+ zDay = timeline_expand_datetime(zDay, &bZulu);
25922588
zDay = db_text(0, "SELECT date(%Q)", zDay);
25932589
if( zDay==0 || zDay[0]==0 ){
25942590
zDay = db_text(0, "SELECT date('now')");
25952591
}
2596
- zNext = db_text(0, "SELECT date(%Q,'+1 day');", zDay);
2597
- if( db_int(0,
2598
- "SELECT EXISTS (SELECT 1 FROM event CROSS JOIN blob"
2599
- " WHERE blob.rid=event.objid AND mtime>=julianday(%Q)%s)",
2600
- zNext, blob_sql_text(&cond))
2601
- ){
2602
- zNewerButton = fossil_strdup(url_render(&url, "ymd", zNext, 0, 0));
2603
- zNewerButtonLabel = "Following day";
2604
- }
2605
- fossil_free(zNext);
2606
- zNext = db_text(0, "SELECT date(%Q,'-1 day');", zDay);
2607
- if( db_int(0,
2608
- "SELECT EXISTS (SELECT 1 FROM event CROSS JOIN blob"
2609
- " WHERE blob.rid=event.objid AND mtime<julianday(%Q)%s)",
2610
- zDay, blob_sql_text(&cond))
2611
- ){
2612
- zOlderButton = fossil_strdup(url_render(&url, "ymd", zNext, 0, 0));
2613
- zOlderButtonLabel = "Previous day";
2614
- }
2615
- fossil_free(zNext);
2616
- blob_append_sql(&cond, " AND %Q=date(event.mtime) ",
2617
- zDay);
2618
- nEntry = -1;
2592
+ zTZMod = (bZulu==0 && fossil_ui_localtime()) ? "utc" : "+00:00";
2593
+ if( db_int(0,
2594
+ "SELECT EXISTS (SELECT 1 FROM event CROSS JOIN blob"
2595
+ " WHERE blob.rid=event.objid"
2596
+ " AND mtime>=julianday(%Q,'+1 day',%Q)%s)",
2597
+ zDay, zTZMod, blob_sql_text(&cond))
2598
+ ){
2599
+ zNext = db_text(0,"SELECT strftime('%%Y%%m%%d%q',%Q,'+1 day');",
2600
+ &"Z"[!bZulu], zDay);
2601
+ zNewerButton = fossil_strdup(url_render(&url, "ymd", zNext, 0, 0));
2602
+ zNewerButtonLabel = "Following day";
2603
+ fossil_free(zNext);
2604
+ }
2605
+ if( db_int(0,
2606
+ "SELECT EXISTS (SELECT 1 FROM event CROSS JOIN blob"
2607
+ " WHERE blob.rid=event.objid"
2608
+ " AND mtime<julianday(%Q,'-1 day',%Q)%s)",
2609
+ zDay, zTZMod, blob_sql_text(&cond))
2610
+ ){
2611
+ zNext = db_text(0,"SELECT strftime('%%Y%%m%%d%q',%Q,'-1 day');",
2612
+ &"Z"[!bZulu], zDay);
2613
+ zOlderButton = fossil_strdup(url_render(&url, "ymd", zNext, 0, 0));
2614
+ zOlderButtonLabel = "Previous day";
2615
+ fossil_free(zNext);
2616
+ }
2617
+ blob_append_sql(&cond,
2618
+ " AND event.mtime>=julianday(%Q,%Q)"
2619
+ " AND event.mtime<julianday(%Q,%Q,'+1 day')\n",
2620
+ zDay, zTZMod, zDay, zTZMod);
2621
+ nEntry = -1;
2622
+ if( fossil_ui_localtime() && bZulu ){
2623
+ zDay = mprintf("%zZ", zDay); /* Add Z suffix to day for the title */
2624
+ }
26192625
}
26202626
else if( zNDays ){
26212627
nDays = atoi(zNDays);
26222628
if( nDays<1 ) nDays = 1;
26232629
blob_append_sql(&cond, " AND event.mtime>=julianday('now','-%d days') ",
@@ -2663,39 +2669,24 @@
26632669
nEntry = -1;
26642670
}
26652671
if( zTagSql ){
26662672
db_multi_exec(
26672673
"CREATE TEMP TABLE selected_nodes(rid INTEGER PRIMARY KEY);"
2668
- "INSERT OR IGNORE INTO selected_nodes"
2669
- " SELECT tagxref.rid FROM tagxref NATURAL JOIN tag"
2670
- " WHERE %s AND tagtype>0", zTagSql/*safe-for-%s*/
2674
+ "INSERT OR IGNORE INTO selected_nodes\n"
2675
+ " SELECT tagxref.rid FROM tagxref NATURAL JOIN tag\n"
2676
+ " WHERE tagtype>0\n"
2677
+ " AND %s", zTagSql/*safe-for-%s*/
26712678
);
26722679
if( zMark ){
26732680
/* If the t=release option is used with m=UUID, then also
26742681
** include the UUID check-in in the display list */
26752682
int ridMark = name_to_rid(zMark);
26762683
db_multi_exec(
26772684
"INSERT OR IGNORE INTO selected_nodes(rid) VALUES(%d)", ridMark);
26782685
}
2679
- if( P("x")!=0 ){
2680
- char *zX = fossil_strdup(P("x"));
2681
- int ii;
2682
- int ridX;
2683
- while( zX[0] ){
2684
- char c;
2685
- if( zX[0]==',' || zX[0]==' ' ){ zX++; continue; }
2686
- for(ii=1; zX[ii] && zX[ii]!=',' && zX[ii]!=' '; ii++){}
2687
- c = zX[ii];
2688
- zX[ii] = 0;
2689
- ridX = name_to_rid(zX);
2690
- db_multi_exec(
2691
- "INSERT OR IGNORE INTO selected_nodes(rid) VALUES(%d)", ridX);
2692
- zX[ii] = c;
2693
- zX += ii;
2694
- }
2695
- }
2696
- if( !related ){
2686
+ add_extra_rids("selected_nodes",P("x"));
2687
+ if( related==0 ){
26972688
blob_append_sql(&cond, " AND blob.rid IN selected_nodes");
26982689
}else{
26992690
db_multi_exec(
27002691
"CREATE TEMP TABLE related_nodes(rid INTEGER PRIMARY KEY);"
27012692
"INSERT INTO related_nodes SELECT rid FROM selected_nodes;"
@@ -2706,40 +2697,42 @@
27062697
** branch to be included in the report. These related check-ins are
27072698
** useful in helping to visualize what has happened on a quiescent
27082699
** branch that is infrequently merged with a much more activate branch.
27092700
*/
27102701
db_multi_exec(
2711
- "INSERT OR IGNORE INTO related_nodes"
2712
- " SELECT pid FROM selected_nodes CROSS JOIN plink"
2713
- " WHERE selected_nodes.rid=plink.cid;"
2702
+ "INSERT OR IGNORE INTO related_nodes\n"
2703
+ " SELECT pid FROM selected_nodes CROSS JOIN plink\n"
2704
+ " WHERE selected_nodes.rid=plink.cid;"
27142705
);
2715
- if( P("mionly")==0 ){
2706
+ if( related==1 ){
27162707
db_multi_exec(
2717
- "INSERT OR IGNORE INTO related_nodes"
2718
- " SELECT cid FROM selected_nodes CROSS JOIN plink"
2719
- " WHERE selected_nodes.rid=plink.pid;"
2708
+ "INSERT OR IGNORE INTO related_nodes\n"
2709
+ " SELECT cid FROM selected_nodes CROSS JOIN plink\n"
2710
+ " WHERE selected_nodes.rid=plink.pid;"
27202711
);
27212712
if( showCherrypicks ){
27222713
db_multi_exec(
2723
- "INSERT OR IGNORE INTO related_nodes"
2724
- " SELECT childid FROM selected_nodes CROSS JOIN cherrypick"
2725
- " WHERE selected_nodes.rid=cherrypick.parentid;"
2714
+ "INSERT OR IGNORE INTO related_nodes\n"
2715
+ " SELECT childid FROM selected_nodes CROSS JOIN cherrypick\n"
2716
+ " WHERE selected_nodes.rid=cherrypick.parentid;"
27262717
);
27272718
}
27282719
}
27292720
if( showCherrypicks ){
27302721
db_multi_exec(
2731
- "INSERT OR IGNORE INTO related_nodes"
2732
- " SELECT parentid FROM selected_nodes CROSS JOIN cherrypick"
2733
- " WHERE selected_nodes.rid=cherrypick.childid;"
2722
+ "INSERT OR IGNORE INTO related_nodes\n"
2723
+ " SELECT parentid FROM selected_nodes CROSS JOIN cherrypick\n"
2724
+ " WHERE selected_nodes.rid=cherrypick.childid;"
27342725
);
27352726
}
27362727
if( (tmFlags & TIMELINE_UNHIDE)==0 ){
27372728
db_multi_exec(
2738
- "DELETE FROM related_nodes WHERE rid IN "
2739
- " (SELECT related_nodes.rid FROM related_nodes, tagxref"
2740
- " WHERE tagid=%d AND tagtype>0 AND tagxref.rid=related_nodes.rid)",
2729
+ "DELETE FROM related_nodes\n"
2730
+ " WHERE rid IN (SELECT related_nodes.rid\n"
2731
+ " FROM related_nodes, tagxref\n"
2732
+ " WHERE tagid=%d AND tagtype>0\n"
2733
+ " AND tagxref.rid=related_nodes.rid)",
27412734
TAG_HIDDEN
27422735
);
27432736
}
27442737
}
27452738
}
@@ -2829,45 +2822,42 @@
28292822
rCirca = symbolic_name_to_mtime(zCirca, &zCirca);
28302823
blob_append_sql(&sql, "%s", blob_sql_text(&cond));
28312824
if( rAfter>0.0 ){
28322825
if( rBefore>0.0 ){
28332826
blob_append_sql(&sql,
2834
- " AND event.mtime>=%.17g AND event.mtime<=%.17g"
2827
+ " AND event.mtime>=%.17g AND event.mtime<=%.17g\n"
28352828
" ORDER BY event.mtime ASC", rAfter-ONE_SECOND, rBefore+ONE_SECOND);
28362829
nEntry = -1;
28372830
}else{
28382831
blob_append_sql(&sql,
2839
- " AND event.mtime>=%.17g ORDER BY event.mtime ASC",
2832
+ " AND event.mtime>=%.17g\n ORDER BY event.mtime ASC",
28402833
rAfter-ONE_SECOND);
28412834
}
28422835
zCirca = 0;
28432836
url_add_parameter(&url, "c", 0);
28442837
}else if( rBefore>0.0 ){
28452838
blob_append_sql(&sql,
2846
- " AND event.mtime<=%.17g ORDER BY event.mtime DESC",
2839
+ " AND event.mtime<=%.17g\n ORDER BY event.mtime DESC",
28472840
rBefore+ONE_SECOND);
28482841
zCirca = 0;
28492842
url_add_parameter(&url, "c", 0);
28502843
}else if( rCirca>0.0 ){
28512844
Blob sql2;
28522845
blob_init(&sql2, blob_sql_text(&sql), -1);
28532846
blob_append_sql(&sql2,
2854
- " AND event.mtime>=%f ORDER BY event.mtime ASC", rCirca);
2847
+ " AND event.mtime>=%f\n ORDER BY event.mtime ASC", rCirca);
28552848
if( nEntry>0 ){
28562849
blob_append_sql(&sql2," LIMIT %d", (nEntry+1)/2);
28572850
}
2858
- if( PB("showsql") ){
2859
- @ <pre>%h(blob_sql_text(&sql2))</pre>
2860
- }
28612851
db_multi_exec("%s", blob_sql_text(&sql2));
28622852
if( nEntry>0 ){
28632853
nEntry -= db_int(0,"select count(*) from timeline");
28642854
if( nEntry<=0 ) nEntry = 1;
28652855
}
28662856
blob_reset(&sql2);
28672857
blob_append_sql(&sql,
2868
- " AND event.mtime<=%f ORDER BY event.mtime DESC",
2858
+ " AND event.mtime<=%f\n ORDER BY event.mtime DESC",
28692859
rCirca
28702860
);
28712861
if( zMark==0 ) zMark = zCirca;
28722862
}else{
28732863
blob_append_sql(&sql, " ORDER BY event.mtime DESC");
@@ -2876,11 +2866,11 @@
28762866
db_multi_exec("%s", blob_sql_text(&sql));
28772867
28782868
n = db_int(0, "SELECT count(*) FROM timeline WHERE etype!='div' /*scan*/");
28792869
zPlural = n==1 ? "" : "s";
28802870
if( zYearMonth ){
2881
- blob_appendf(&desc, "%d %s%s for the month beginning %h-01",
2871
+ blob_appendf(&desc, "%d %s%s for the month beginning %h",
28822872
n, zEType, zPlural, zYearMonth);
28832873
}else if( zYearWeek ){
28842874
blob_appendf(&desc, "%d %s%s for week %h beginning on %h",
28852875
n, zEType, zPlural, zYearWeek, zYearWeekStart);
28862876
}else if( zDay ){
@@ -3010,12 +3000,14 @@
30103000
style_submenu_multichoice("ms", count(azMatchStyles)/2,azMatchStyles,0);
30113001
}
30123002
}
30133003
blob_zero(&cond);
30143004
}
3015
- if( PB("showsql") ){
3016
- @ <pre>%h(blob_sql_text(&sql))</pre>
3005
+ if( showSql ){
3006
+ db_append_dml_to_blob(0);
3007
+ @ <pre>%h(blob_str(&allSql))</pre>
3008
+ blob_reset(&allSql);
30173009
}
30183010
if( search_restrict(SRCH_CKIN)!=0 ){
30193011
style_submenu_element("Search", "%R/search?y=c");
30203012
}
30213013
if( advancedMenu ){
@@ -3069,18 +3061,36 @@
30693061
if( zNewerButton ){
30703062
@ %z(chref("button","%s",zNewerButton))%h(zNewerButtonLabel)\
30713063
@ &nbsp;&uarr;</a>
30723064
}
30733065
cgi_check_for_malice();
3074
- www_print_timeline(&q, tmFlags, zThisUser, zThisTag, zBrName,
3075
- selectedRid, secondaryRid, 0);
3066
+ {
3067
+ Matcher *pLeftBranch;
3068
+ const char *zPattern = P("sl");
3069
+ if( zPattern!=0 ){
3070
+ MatchStyle ms;
3071
+ if( zMatchStyle!=0 ){
3072
+ ms = matchStyle;
3073
+ }else{
3074
+ ms = strpbrk(zPattern,"*[?")!=0 ? MS_GLOB : MS_BRLIST;
3075
+ }
3076
+ pLeftBranch = match_create(ms,zPattern);
3077
+ }else{
3078
+ pLeftBranch = match_create(matchStyle, zBrName?zBrName:zTagName);
3079
+ }
3080
+ www_print_timeline(&q, tmFlags, zThisUser, zThisTag, pLeftBranch,
3081
+ selectedRid, secondaryRid, 0);
3082
+ match_free(pLeftBranch);
3083
+ }
30763084
db_finalize(&q);
30773085
if( zOlderButton ){
30783086
@ %z(chref("button","%s",zOlderButton))%h(zOlderButtonLabel)\
30793087
@ &nbsp;&darr;</a>
30803088
}
30813089
document_emit_js(/*handles pikchrs rendered above*/);
3090
+ blob_reset(&sql);
3091
+ blob_reset(&desc);
30823092
style_finish_page();
30833093
}
30843094
30853095
/*
30863096
** Translate a timeline entry into the printable format by
@@ -3745,10 +3755,11 @@
37453755
const char *zToday;
37463756
char *zStartOfProject;
37473757
int i;
37483758
Stmt q;
37493759
char *z;
3760
+ int bZulu = 0;
37503761
37513762
login_check_credentials();
37523763
if( (!g.perm.Read && !g.perm.RdTkt && !g.perm.RdWiki && !g.perm.RdForum) ){
37533764
login_needed(g.anon.Read && g.anon.RdTkt && g.anon.RdWiki);
37543765
return;
@@ -3755,11 +3766,11 @@
37553766
}
37563767
style_set_current_feature("timeline");
37573768
style_header("Today In History");
37583769
zToday = (char*)P("today");
37593770
if( zToday ){
3760
- zToday = timeline_expand_datetime(zToday);
3771
+ zToday = timeline_expand_datetime(zToday, &bZulu);
37613772
if( !fossil_isdate(zToday) ) zToday = 0;
37623773
}
37633774
if( zToday==0 ){
37643775
zToday = db_text(0, "SELECT date('now',toLocal())");
37653776
}
37663777
--- src/timeline.c
+++ src/timeline.c
@@ -191,11 +191,11 @@
191 void www_print_timeline(
192 Stmt *pQuery, /* Query to implement the timeline */
193 int tmFlags, /* Flags controlling display behavior */
194 const char *zThisUser, /* Suppress links to this user */
195 const char *zThisTag, /* Suppress links to this tag */
196 const char *zLeftBranch, /* Strive to put this branch on the left margin */
197 int selectedRid, /* Highlight the line with this RID value or zero */
198 int secondRid, /* Secondary highlight (or zero) */
199 void (*xExtra)(int) /* Routine to call on each line of display */
200 ){
201 int mxWikiLen;
@@ -813,11 +813,11 @@
813 }
814 if( pendingEndTr ){
815 @ </td></tr>
816 }
817 if( pGraph ){
818 graph_finish(pGraph, zLeftBranch, tmFlags);
819 if( pGraph->nErr ){
820 graph_free(pGraph);
821 pGraph = 0;
822 }else{
823 @ <tr class="timelineBottom" id="btm-%d(iTableId)">\
@@ -1290,12 +1290,13 @@
1290 const char *zChng, /* The filename GLOB list */
1291 Blob *pSql /* The SELECT statement under construction */
1292 ){
1293 if( zChng==0 || zChng[0]==0 ) return;
1294 blob_append_sql(pSql," AND event.objid IN ("
1295 "SELECT mlink.mid FROM mlink, filename"
1296 " WHERE mlink.fnid=filename.fnid AND %s)",
 
1297 glob_expr("filename.name", mprintf("\"%s\"", zChng)));
1298 }
1299 static void addFileGlobDescription(
1300 const char *zChng, /* The filename GLOB list */
1301 Blob *pDescription /* Result description */
@@ -1303,274 +1304,86 @@
1303 if( zChng==0 || zChng[0]==0 ) return;
1304 blob_appendf(pDescription, " that include changes to files matching '%h'",
1305 zChng);
1306 }
1307
1308 /*
1309 ** Tag match expression type code.
1310 */
1311 typedef enum {
1312 MS_EXACT, /* Matches a single tag by exact string comparison. */
1313 MS_GLOB, /* Matches tags against a list of GLOB patterns. */
1314 MS_LIKE, /* Matches tags against a list of LIKE patterns. */
1315 MS_REGEXP, /* Matches tags against a list of regular expressions. */
1316 MS_BRLIST, /* Same as REGEXP, except the regular expression is a list
1317 ** of branch names */
1318 } MatchStyle;
1319
1320 /*
1321 ** Quote a tag string by surrounding it with double quotes and preceding
1322 ** internal double quotes and backslashes with backslashes.
1323 */
1324 static const char *tagQuote(
1325 int len, /* Maximum length of zTag, or negative for unlimited */
1326 const char *zTag /* Tag string */
1327 ){
1328 Blob blob = BLOB_INITIALIZER;
1329 int i, j;
1330 blob_zero(&blob);
1331 blob_append(&blob, "\"", 1);
1332 for( i=j=0; zTag[j] && (len<0 || j<len); ++j ){
1333 if( zTag[j]=='\"' || zTag[j]=='\\' ){
1334 if( j>i ){
1335 blob_append(&blob, zTag+i, j-i);
1336 }
1337 blob_append(&blob, "\\", 1);
1338 i = j;
1339 }
1340 }
1341 if( j>i ){
1342 blob_append(&blob, zTag+i, j-i);
1343 }
1344 blob_append(&blob, "\"", 1);
1345 return blob_str(&blob);
1346 }
1347
1348 /*
1349 ** Construct the tag match SQL expression.
1350 **
1351 ** This function is adapted from glob_expr() to support the MS_EXACT, MS_GLOB,
1352 ** MS_LIKE, MS_REGEXP, and MS_BRLIST match styles.
1353 **
1354 ** For MS_EXACT, the returned expression
1355 ** checks for integer match against the tag ID which is looked up directly by
1356 ** this function. For the other modes, the returned SQL expression performs
1357 ** string comparisons against the tag names, so it is necessary to join against
1358 ** the tag table to access the "tagname" column.
1359 **
1360 ** Each pattern is adjusted to to start with "sym-" and be anchored at end.
1361 **
1362 ** In MS_REGEXP mode, backslash can be used to protect delimiter characters.
1363 ** The backslashes are not removed from the regular expression.
1364 **
1365 ** In addition to assembling and returning an SQL expression, this function
1366 ** makes an English-language description of the patterns being matched, suitable
1367 ** for display in the web interface.
1368 **
1369 ** If any errors arise during processing, *zError is set to an error message.
1370 ** Otherwise it is set to NULL.
1371 */
1372 static const char *tagMatchExpression(
1373 MatchStyle matchStyle, /* Match style code */
1374 const char *zTag, /* Tag name, match pattern, or pattern list */
1375 const char **zDesc, /* Output expression description string */
1376 const char **zError /* Output error string */
1377 ){
1378 Blob expr = BLOB_INITIALIZER; /* SQL expression string assembly buffer */
1379 Blob desc = BLOB_INITIALIZER; /* English description of match patterns */
1380 Blob err = BLOB_INITIALIZER; /* Error text assembly buffer */
1381 const char *zStart; /* Text at start of expression */
1382 const char *zDelimiter; /* Text between expression terms */
1383 const char *zEnd; /* Text at end of expression */
1384 const char *zPrefix; /* Text before each match pattern */
1385 const char *zSuffix; /* Text after each match pattern */
1386 const char *zIntro; /* Text introducing pattern description */
1387 const char *zPattern = 0; /* Previous quoted pattern */
1388 const char *zFail = 0; /* Current failure message or NULL if okay */
1389 const char *zOr = " or "; /* Text before final quoted pattern */
1390 char cDel; /* Input delimiter character */
1391 int i; /* Input match pattern length counter */
1392
1393 /* Optimize exact matches by looking up the ID in advance to create a simple
1394 * numeric comparison. Bypass the remainder of this function. */
1395 if( matchStyle==MS_EXACT ){
1396 *zDesc = tagQuote(-1, zTag);
1397 return mprintf("(tagid=%d)", db_int(-1,
1398 "SELECT tagid FROM tag WHERE tagname='sym-%q'", zTag));
1399 }
1400
1401 /* Decide pattern prefix and suffix strings according to match style. */
1402 if( matchStyle==MS_GLOB ){
1403 zStart = "(";
1404 zDelimiter = " OR ";
1405 zEnd = ")";
1406 zPrefix = "tagname GLOB 'sym-";
1407 zSuffix = "'";
1408 zIntro = "glob pattern ";
1409 }else if( matchStyle==MS_LIKE ){
1410 zStart = "(";
1411 zDelimiter = " OR ";
1412 zEnd = ")";
1413 zPrefix = "tagname LIKE 'sym-";
1414 zSuffix = "'";
1415 zIntro = "SQL LIKE pattern ";
1416 }else if( matchStyle==MS_REGEXP ){
1417 zStart = "(tagname REGEXP '^sym-(";
1418 zDelimiter = "|";
1419 zEnd = ")$')";
1420 zPrefix = "";
1421 zSuffix = "";
1422 zIntro = "regular expression ";
1423 }else/* if( matchStyle==MS_BRLIST )*/{
1424 zStart = "tagname IN ('sym-";
1425 zDelimiter = "','sym-";
1426 zEnd = "')";
1427 zPrefix = "";
1428 zSuffix = "";
1429 zIntro = "";
1430 }
1431
1432 /* Convert the list of matches into an SQL expression and text description. */
1433 blob_zero(&expr);
1434 blob_zero(&desc);
1435 blob_zero(&err);
1436 while( 1 ){
1437 /* Skip leading delimiters. */
1438 for( ; fossil_isspace(*zTag) || *zTag==','; ++zTag );
1439
1440 /* Next non-delimiter character determines quoting. */
1441 if( !*zTag ){
1442 /* Terminate loop at end of string. */
1443 break;
1444 }else if( *zTag=='\'' || *zTag=='"' ){
1445 /* If word is quoted, prepare to stop at end quote. */
1446 cDel = *zTag;
1447 ++zTag;
1448 }else{
1449 /* If word is not quoted, prepare to stop at delimiter. */
1450 cDel = ',';
1451 }
1452
1453 /* Find the next delimiter character or end of string. */
1454 for( i=0; zTag[i] && zTag[i]!=cDel; ++i ){
1455 /* If delimiter is comma, also recognize spaces as delimiters. */
1456 if( cDel==',' && fossil_isspace(zTag[i]) ){
1457 break;
1458 }
1459
1460 /* In regexp mode, ignore delimiters following backslashes. */
1461 if( matchStyle==MS_REGEXP && zTag[i]=='\\' && zTag[i+1] ){
1462 ++i;
1463 }
1464 }
1465
1466 /* Check for regular expression syntax errors. */
1467 if( matchStyle==MS_REGEXP ){
1468 ReCompiled *regexp;
1469 char *zTagDup = fossil_strndup(zTag, i);
1470 zFail = re_compile(&regexp, zTagDup, 0);
1471 re_free(regexp);
1472 fossil_free(zTagDup);
1473 }
1474
1475 /* Process success and error results. */
1476 if( !zFail ){
1477 /* Incorporate the match word into the output expression. %q is used to
1478 * protect against SQL injection attacks by replacing ' with ''. */
1479 blob_appendf(&expr, "%s%s%#q%s", blob_size(&expr) ? zDelimiter : zStart,
1480 zPrefix, i, zTag, zSuffix);
1481
1482 /* Build up the description string. */
1483 if( !blob_size(&desc) ){
1484 /* First tag: start with intro followed by first quoted tag. */
1485 blob_append(&desc, zIntro, -1);
1486 blob_append(&desc, tagQuote(i, zTag), -1);
1487 }else{
1488 if( zPattern ){
1489 /* Third and subsequent tags: append comma then previous tag. */
1490 blob_append(&desc, ", ", 2);
1491 blob_append(&desc, zPattern, -1);
1492 zOr = ", or ";
1493 }
1494
1495 /* Second and subsequent tags: store quoted tag for next iteration. */
1496 zPattern = tagQuote(i, zTag);
1497 }
1498 }else{
1499 /* On error, skip the match word and build up the error message buffer. */
1500 if( !blob_size(&err) ){
1501 blob_append(&err, "Error: ", 7);
1502 }else{
1503 blob_append(&err, ", ", 2);
1504 }
1505 blob_appendf(&err, "(%s%s: %s)", zIntro, tagQuote(i, zTag), zFail);
1506 }
1507
1508 /* Advance past all consumed input characters. */
1509 zTag += i;
1510 if( cDel!=',' && *zTag==cDel ){
1511 ++zTag;
1512 }
1513 }
1514
1515 /* Finalize and extract the pattern description. */
1516 if( zPattern ){
1517 blob_append(&desc, zOr, -1);
1518 blob_append(&desc, zPattern, -1);
1519 }
1520 *zDesc = blob_str(&desc);
1521
1522 /* Finalize and extract the error text. */
1523 *zError = blob_size(&err) ? blob_str(&err) : 0;
1524
1525 /* Finalize and extract the SQL expression. */
1526 if( blob_size(&expr) ){
1527 blob_append(&expr, zEnd, -1);
1528 return blob_str(&expr);
1529 }
1530
1531 /* If execution reaches this point, the pattern was empty. Return NULL. */
1532 return 0;
1533 }
1534
1535 /*
1536 ** Similar to fossil_expand_datetime()
1537 **
1538 ** Add missing "-" characters into a date/time. Examples:
1539 **
1540 ** 20190419 => 2019-04-19
1541 ** 201904 => 2019-04
1542 */
1543 const char *timeline_expand_datetime(const char *zIn){
1544 static char zEDate[20];
1545 static const char aPunct[] = { 0, 0, '-', '-', ' ', ':', ':' };
1546 int n = (int)strlen(zIn);
1547 int i, j;
1548
1549 /* Only three forms allowed:
 
1550 ** (1) YYYYMMDD
1551 ** (2) YYYYMM
1552 ** (3) YYYYWW
1553 */
 
 
 
 
 
 
1554 if( n!=8 && n!=6 ) return zIn;
1555
1556 /* Every character must be a digit */
1557 for(i=0; fossil_isdigit(zIn[i]); i++){}
1558 if( i!=n ) return zIn;
1559
1560 /* Expand the date */
1561 for(i=j=0; zIn[i]; i++){
1562 if( i>=4 && (i%2)==0 ){
1563 zEDate[j++] = aPunct[i/2];
1564 }
1565 zEDate[j++] = zIn[i];
1566 }
1567 zEDate[j] = 0;
1568
1569 /* It looks like this may be a date. Return it with punctuation added. */
1570 return zEDate;
1571 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1572
1573 /*
1574 ** Find the first check-in encountered with a particular tag
1575 ** when moving either forwards are backwards in time from a
1576 ** particular starting point (iFrom). Return the rid of that
@@ -1591,10 +1404,11 @@
1591 tagId = db_int(0, "SELECT tagid FROM tag WHERE tagname='sym-%q'", zEnd);
1592 if( tagId==0 ){
1593 endId = symbolic_name_to_rid(zEnd, "ci");
1594 if( endId==0 ) return 0;
1595 }
 
1596 if( bForward ){
1597 if( tagId ){
1598 db_prepare(&q,
1599 "WITH RECURSIVE dx(id,mtime) AS ("
1600 " SELECT %d, event.mtime FROM event WHERE objid=%d"
@@ -1658,12 +1472,54 @@
1658 }
1659 if( db_step(&q)==SQLITE_ROW ){
1660 ans = db_column_int(&q, 0);
1661 }
1662 db_finalize(&q);
 
1663 return ans;
1664 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1665
1666 /*
1667 ** COMMAND: test-endpoint
1668 **
1669 ** Usage: fossil test-endpoint BASE TAG ?OPTIONS?
@@ -1698,21 +1554,21 @@
1698 /*
1699 ** WEBPAGE: timeline
1700 **
1701 ** Query parameters:
1702 **
1703 ** a=TIMEORTAG Show events after TIMEORTAG
1704 ** b=TIMEORTAG Show events before TIMEORTAG
1705 ** c=TIMEORTAG Show events that happen "circa" TIMEORTAG
1706 ** cf=FILEHASH Show events around the time of the first use of
1707 ** the file with FILEHASH
1708 ** m=TIMEORTAG Highlight the event at TIMEORTAG, or the closest available
1709 ** event if TIMEORTAG is not part of the timeline. If
1710 ** the t= or r= is used, the m event is added to the timeline
1711 ** if it isn't there already.
1712 ** x=HASHLIST Show all check-ins in the comma-separated HASHLIST
1713 ** in addition to check-ins specified by t= or r=
1714 ** sel1=TIMEORTAG Highlight the check-in at TIMEORTAG if it is part of
1715 ** the timeline. Similar to m= except TIMEORTAG must
1716 ** match a check-in that is already in the timeline.
1717 ** sel2=TIMEORTAG Like sel1= but use the secondary highlight.
1718 ** n=COUNT Maximum number of events. "all" for no limit
@@ -1732,63 +1588,71 @@
1732 ** from=CX ... shortest path from CX back to CHECKIN
1733 ** ft=CHECKIN "Forward To": Show decendents forward to CHECKIN
1734 ** d=CX ... from CX up to the time of CHECKIN
1735 ** from=CX ... shortest path from CX up to CHECKIN
1736 ** t=TAG Show only check-ins with the given TAG
1737 ** r=TAG Show check-ins related to TAG, equivalent to t=TAG&rel
1738 ** tl=TAGLIST Shorthand for t=TAGLIST&ms=brlist
1739 ** rl=TAGLIST Shorthand for r=TAGLIST&ms=brlist
 
 
1740 ** rel Show related check-ins as well as those matching t=TAG
1741 ** mionly Limit rel to show ancestors but not descendants
1742 ** nowiki Do not show wiki associated with branch or tag
1743 ** ms=MATCHSTYLE Set tag match style to EXACT, GLOB, LIKE, REGEXP
 
1744 ** u=USER Only show items associated with USER
1745 ** y=TYPE 'ci', 'w', 't', 'n', 'e', 'f', or 'all'.
1746 ** ss=VIEWSTYLE c: "Compact", v: "Verbose", m: "Modern", j: "Columnar",
1747 ** x: "Classic".
1748 ** advm Use the "Advanced" or "Busy" menu design.
1749 ** ng No Graph.
1750 ** ncp Omit cherrypick merges
1751 ** nd Do not highlight the focus check-in
1752 ** nsm Omit the submenu
1753 ** nc Omit all graph colors other than highlights
1754 ** v Show details of files changed
1755 ** vfx Show complete text of forum messages
1756 ** f=CHECKIN Show family (immediate parents and children) of CHECKIN
1757 ** from=CHECKIN Path from...
1758 ** to=CHECKIN ... to this
1759 ** to2=CHECKIN ... backup name if to= doesn't resolve
1760 ** shortest ... show only the shortest path
1761 ** rel ... also show related checkins
1762 ** bt=PRIOR ... path from CHECKIN back to PRIOR
1763 ** ft=LATER ... path from CHECKIN forward to LATER
 
 
 
1764 ** uf=FILE_HASH Show only check-ins that contain the given file version
1765 ** All qualifying check-ins are shown unless there is
1766 ** also an n= or n1= query parameter.
1767 ** chng=GLOBLIST Show only check-ins that involve changes to a file whose
1768 ** name matches one of the comma-separate GLOBLIST
1769 ** brbg Background color determined by branch name
1770 ** ubg Background color determined by user
1771 ** deltabg Background color red for delta manifests or green
1772 ** for baseline manifests
1773 ** namechng Show only check-ins that have filename changes
1774 ** forks Show only forks and their children
1775 ** cherrypicks Show all cherrypicks
1776 ** ym=YYYY-MM Show only events for the given year/month
1777 ** yw=YYYY-WW Show only events for the given week of the given year
1778 ** yw=YYYY-MM-DD Show events for the week that includes the given day
1779 ** ymd=YYYY-MM-DD Show only events on the given day. The use "ymd=now"
1780 ** to see all changes for the current week.
 
 
1781 ** year=YYYY Show only events on the given year. The use "year=0"
1782 ** to see all changes for the current year.
1783 ** days=N Show events over the previous N days
1784 ** datefmt=N Override the date format: 0=HH:MM, 1=HH:MM:SS,
1785 ** 2=YYYY-MM-DD HH:MM:SS, 3=YYMMDD HH:MM, and 4 means "off".
1786 ** bisect Show the check-ins that are in the current bisect
1787 ** oldestfirst Show events oldest first.
1788 ** showid Show RIDs
1789 ** showsql Show the SQL text
1790 **
1791 ** p= and d= can appear individually or together. If either p= or d=
1792 ** appear, then u=, y=, a=, and b= are ignored.
1793 **
1794 ** If both a= and b= appear then both upper and lower bounds are honored.
@@ -1862,14 +1726,20 @@
1862 int advancedMenu = 0; /* Use the advanced menu design */
1863 char *zPlural; /* Ending for plural forms */
1864 int showCherrypicks = 1; /* True to show cherrypick merges */
1865 int haveParameterN; /* True if n= query parameter present */
1866 int from_to_mode = 0; /* 0: from,to. 1: from,ft 2: from,bt */
 
 
1867
1868 login_check_credentials();
1869 url_initialize(&url, "timeline");
1870 cgi_query_parameters_to_url(&url);
 
 
 
 
1871
1872 (void)P_NoBot("ss")
1873 /* "ss" is processed via the udc but at least one spider likes to
1874 ** try to SQL inject via this argument, so let's catch that. */;
1875
@@ -1984,49 +1854,52 @@
1984
1985 /* Check for tl=TAGLIST and rl=TAGLIST which are abbreviations for
1986 ** t=TAGLIST&ms=brlist and r=TAGLIST&ms=brlist repectively. */
1987 if( zBrName==0 && zTagName==0 ){
1988 const char *z;
 
1989 if( (z = P("tl"))!=0 ){
1990 zTagName = z;
1991 zMatchStyle = "brlist";
 
 
 
 
 
1992 }
1993 if( (z = P("rl"))!=0 ){
1994 zBrName = z;
1995 related = 1;
1996 zMatchStyle = "brlist";
 
 
 
 
 
1997 }
1998 }
1999
2000 /* Convert r=TAG to t=TAG&rel in order to populate the UI style widgets. */
2001 if( zBrName && !related ){
2002 cgi_delete_query_parameter("r");
2003 cgi_set_query_parameter("t", zBrName); (void)P("t");
2004 cgi_set_query_parameter("rel", "1");
2005 zTagName = zBrName;
2006 related = 1;
2007 zType = "ci";
2008 }
2009
2010 /* Ignore empty tag query strings. */
2011 if( zTagName && !*zTagName ){
2012 zTagName = 0;
2013 }
2014
2015 /* Finish preliminary processing of tag match queries. */
 
2016 if( zTagName ){
2017 zType = "ci";
2018 /* Interpet the tag style string. */
2019 if( fossil_stricmp(zMatchStyle, "glob")==0 ){
2020 matchStyle = MS_GLOB;
2021 }else if( fossil_stricmp(zMatchStyle, "like")==0 ){
2022 matchStyle = MS_LIKE;
2023 }else if( fossil_stricmp(zMatchStyle, "regexp")==0 ){
2024 matchStyle = MS_REGEXP;
2025 }else if( fossil_stricmp(zMatchStyle, "brlist")==0 ){
2026 matchStyle = MS_BRLIST;
2027 }else{
2028 /* For exact maching, inhibit links to the selected tag. */
2029 zThisTag = zTagName;
2030 Th_Store("current_checkin", zTagName);
2031 }
2032
@@ -2034,11 +1907,11 @@
2034 if( advancedMenu ){
2035 style_submenu_checkbox("rel", "Related", 0, 0);
2036 }
2037
2038 /* Construct the tag match expression. */
2039 zTagSql = tagMatchExpression(matchStyle, zTagName, &zMatchDesc, &zError);
2040 }
2041
2042 if( zMark && zMark[0]==0 ){
2043 if( zAfter ) zMark = zAfter;
2044 if( zBefore ) zMark = zBefore;
@@ -2082,10 +1955,11 @@
2082 }
2083 if( PB("nc") ){
2084 tmFlags &= ~(TIMELINE_DELTA|TIMELINE_BRCOLOR|TIMELINE_UCOLOR);
2085 tmFlags |= TIMELINE_NOCOLOR;
2086 }
 
2087 if( zUses!=0 ){
2088 int ufid = db_int(0, "SELECT rid FROM blob WHERE uuid GLOB '%q*'", zUses);
2089 if( ufid ){
2090 zUses = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", ufid);
2091 db_multi_exec("CREATE TEMP TABLE usesfile(rid INTEGER PRIMARY KEY)");
@@ -2099,42 +1973,42 @@
2099 }
2100 if( renameOnly ){
2101 db_multi_exec(
2102 "CREATE TEMP TABLE rnfile(rid INTEGER PRIMARY KEY);"
2103 "INSERT OR IGNORE INTO rnfile"
2104 " SELECT mid FROM mlink WHERE pfnid>0 AND pfnid!=fnid;"
2105 );
2106 disableY = 1;
2107 }
2108 if( forkOnly ){
2109 db_multi_exec(
2110 "CREATE TEMP TABLE rnfork(rid INTEGER PRIMARY KEY);\n"
2111 "INSERT OR IGNORE INTO rnfork(rid)\n"
2112 " SELECT pid FROM plink\n"
2113 " WHERE (SELECT value FROM tagxref WHERE tagid=%d AND rid=cid)=="
2114 " (SELECT value FROM tagxref WHERE tagid=%d AND rid=pid)\n"
2115 " GROUP BY pid"
2116 " HAVING count(*)>1;\n"
2117 "INSERT OR IGNORE INTO rnfork(rid)"
2118 " SELECT cid FROM plink\n"
2119 " WHERE (SELECT value FROM tagxref WHERE tagid=%d AND rid=cid)=="
2120 " (SELECT value FROM tagxref WHERE tagid=%d AND rid=pid)\n"
2121 " GROUP BY cid"
2122 " HAVING count(*)>1;\n",
2123 TAG_BRANCH, TAG_BRANCH, TAG_BRANCH, TAG_BRANCH
2124 );
2125 db_multi_exec(
2126 "INSERT OR IGNORE INTO rnfork(rid)\n"
2127 " SELECT cid FROM plink\n"
2128 " WHERE pid IN rnfork"
2129 " AND (SELECT value FROM tagxref WHERE tagid=%d AND rid=cid)=="
2130 " (SELECT value FROM tagxref WHERE tagid=%d AND rid=pid)\n"
2131 " UNION "
2132 " SELECT pid FROM plink\n"
2133 " WHERE cid IN rnfork"
2134 " AND (SELECT value FROM tagxref WHERE tagid=%d AND rid=cid)=="
2135 " (SELECT value FROM tagxref WHERE tagid=%d AND rid=pid)\n",
2136 TAG_BRANCH, TAG_BRANCH, TAG_BRANCH, TAG_BRANCH
2137 );
2138 tmFlags |= TIMELINE_UNHIDE;
2139 zType = "ci";
2140 disableY = 1;
@@ -2207,77 +2081,114 @@
2207 PathNode *p = 0;
2208 const char *zFrom = 0;
2209 const char *zTo = 0;
2210 Blob ins;
2211 int nNodeOnPath = 0;
 
 
2212
2213 if( from_rid && to_rid ){
2214 if( from_to_mode==0 ){
2215 p = path_shortest(from_rid, to_rid, noMerge, 0, 0);
2216 }else if( from_to_mode==1 ){
2217 p = path_shortest(from_rid, to_rid, 0, 1, 0);
 
 
2218 }else{
2219 p = path_shortest(to_rid, from_rid, 0, 1, 0);
 
 
2220 }
2221 zFrom = P("from");
2222 zTo = zTo2 ? zTo2 : P("to");
2223 }else{
2224 if( path_common_ancestor(me_rid, you_rid) ){
 
2225 p = path_first();
2226 }
2227 zFrom = P("me");
2228 zTo = P("you");
 
 
 
 
 
 
 
 
 
2229 }
2230 blob_init(&ins, 0, 0);
2231 db_multi_exec(
2232 "CREATE TABLE IF NOT EXISTS temp.pathnode(x INTEGER PRIMARY KEY);"
2233 );
2234 if( p ){
 
2235 blob_init(&ins, 0, 0);
2236 blob_append_sql(&ins, "INSERT INTO pathnode(x) VALUES(%d)", p->rid);
2237 p = p->u.pTo;
2238 while( p ){
2239 blob_append_sql(&ins, ",(%d)", p->rid);
 
 
 
 
 
 
2240 p = p->u.pTo;
2241 }
2242 }
2243 path_reset();
2244 db_multi_exec("%s", blob_str(&ins)/*safe-for-%s*/);
2245 blob_reset(&ins);
2246 if( related || P("mionly") ){
2247 db_multi_exec(
2248 "CREATE TABLE IF NOT EXISTS temp.related(x INTEGER PRIMARY KEY);"
2249 "INSERT OR IGNORE INTO related(x)"
2250 " SELECT pid FROM plink WHERE cid IN pathnode AND NOT isprim;"
2251 );
2252 if( P("mionly")==0 ){
2253 db_multi_exec(
2254 "INSERT OR IGNORE INTO related(x)"
2255 " SELECT cid FROM plink WHERE pid IN pathnode;"
2256 );
2257 }
2258 if( showCherrypicks ){
2259 db_multi_exec(
2260 "INSERT OR IGNORE INTO related(x)"
2261 " SELECT parentid FROM cherrypick WHERE childid IN pathnode;"
2262 );
2263 if( P("mionly")==0 ){
2264 db_multi_exec(
2265 "INSERT OR IGNORE INTO related(x)"
2266 " SELECT childid FROM cherrypick WHERE parentid IN pathnode;"
2267 );
2268 }
 
 
 
 
 
 
 
 
 
 
 
 
2269 }
2270 db_multi_exec("INSERT OR IGNORE INTO pathnode SELECT x FROM related");
2271 }
 
2272 blob_append_sql(&sql, " AND event.objid IN pathnode");
2273 if( zChng && zChng[0] ){
2274 db_multi_exec(
2275 "DELETE FROM pathnode "
2276 " WHERE NOT EXISTS(SELECT 1 FROM mlink, filename"
2277 " WHERE mlink.mid=x"
2278 " AND mlink.fnid=filename.fnid AND %s)",
 
2279 glob_expr("filename.name", zChng)
2280 );
2281 }
2282 tmFlags |= TIMELINE_XMERGE | TIMELINE_FILLGAPS;
2283 db_multi_exec("%s", blob_sql_text(&sql));
@@ -2331,18 +2242,18 @@
2331 if( !haveParameterN ) nEntry = 10;
2332 }
2333 db_multi_exec(
2334 "CREATE TEMP TABLE IF NOT EXISTS ok(rid INTEGER PRIMARY KEY)"
2335 );
 
2336 zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d",
2337 p_rid ? p_rid : d_rid);
2338 zCiName = zDPName;
2339 if( zCiName==0 ) zCiName = zUuid;
2340 blob_append_sql(&sql, " AND event.objid IN ok");
2341 nd = 0;
2342 if( d_rid ){
2343 Stmt s;
2344 double rStopTime = 9e99;
2345 zFwdTo = P("ft");
2346 if( zFwdTo ){
2347 double rStartDate = db_double(0.0,
2348 "SELECT mtime FROM event WHERE objid=%d", d_rid);
@@ -2354,27 +2265,25 @@
2354 if( !haveParameterN ) nEntry = 0;
2355 rStopTime = db_double(9e99,
2356 "SELECT mtime FROM event WHERE objid=%d", ridFwdTo);
2357 }
2358 }
2359 db_prepare(&s,
2360 "WITH RECURSIVE"
2361 " dx(rid,mtime) AS ("
2362 " SELECT %d, 0"
2363 " UNION"
2364 " SELECT plink.cid, plink.mtime FROM dx, plink"
2365 " WHERE plink.pid=dx.rid"
2366 " AND (:stop>=8e99 OR plink.mtime<=:stop)"
2367 " ORDER BY 2"
2368 " )"
 
 
2369 "INSERT OR IGNORE INTO ok SELECT rid FROM dx LIMIT %d",
2370 d_rid, nEntry<=0 ? -1 : nEntry+1
2371 );
2372 db_bind_double(&s, ":stop", rStopTime);
2373 db_step(&s);
2374 db_finalize(&s);
2375 /* compute_descendants(d_rid, nEntry==0 ? 0 : nEntry+1); */
2376 nd = db_int(0, "SELECT count(*)-1 FROM ok");
2377 if( nd>=0 ) db_multi_exec("%s", blob_sql_text(&sql));
2378 if( nd>0 || p_rid==0 ){
2379 blob_appendf(&desc, "%d descendant%s", nd,(1==nd)?"":"s");
2380 }
@@ -2483,67 +2392,76 @@
2483 if( zChng && *zChng ){
2484 addFileGlobExclusion(zChng, &cond);
2485 tmFlags |= TIMELINE_XMERGE;
2486 }
2487 if( zUses ){
2488 blob_append_sql(&cond, " AND event.objid IN usesfile ");
2489 }
2490 if( renameOnly ){
2491 blob_append_sql(&cond, " AND event.objid IN rnfile ");
2492 }
2493 if( forkOnly ){
2494 blob_append_sql(&cond, " AND event.objid IN rnfork ");
2495 }
2496 if( cpOnly && showCherrypicks ){
2497 db_multi_exec(
2498 "CREATE TEMP TABLE IF NOT EXISTS cpnodes(rid INTEGER PRIMARY KEY);"
2499 "INSERT OR IGNORE INTO cpnodes SELECT childid FROM cherrypick;"
2500 "INSERT OR IGNORE INTO cpnodes SELECT parentid FROM cherrypick;"
2501 );
2502 blob_append_sql(&cond, " AND event.objid IN cpnodes ");
2503 }
2504 if( bisectLocal || zBisect!=0 ){
2505 blob_append_sql(&cond, " AND event.objid IN (SELECT rid FROM bilog) ");
2506 }
2507 if( zYearMonth ){
2508 char *zNext;
2509 zYearMonth = timeline_expand_datetime(zYearMonth);
2510 if( strlen(zYearMonth)>7 ){
2511 zYearMonth = mprintf("%.7s", zYearMonth);
2512 }
2513 if( db_int(0,"SELECT julianday('%q-01') IS NULL", zYearMonth) ){
2514 zYearMonth = db_text(0, "SELECT strftime('%%Y-%%m','now');");
2515 }
2516 zNext = db_text(0, "SELECT strftime('%%Y-%%m','%q-01','+1 month');",
2517 zYearMonth);
2518 if( db_int(0,
2519 "SELECT EXISTS (SELECT 1 FROM event CROSS JOIN blob"
2520 " WHERE blob.rid=event.objid AND mtime>=julianday('%q-01')%s)",
2521 zNext, blob_sql_text(&cond))
2522 ){
2523 zNewerButton = fossil_strdup(url_render(&url, "ym", zNext, 0, 0));
2524 zNewerButtonLabel = "Following month";
2525 }
2526 fossil_free(zNext);
2527 zNext = db_text(0, "SELECT strftime('%%Y-%%m','%q-01','-1 month');",
2528 zYearMonth);
2529 if( db_int(0,
2530 "SELECT EXISTS (SELECT 1 FROM event CROSS JOIN blob"
2531 " WHERE blob.rid=event.objid AND mtime<julianday('%q-01')%s)",
2532 zYearMonth, blob_sql_text(&cond))
2533 ){
2534 zOlderButton = fossil_strdup(url_render(&url, "ym", zNext, 0, 0));
2535 zOlderButtonLabel = "Previous month";
2536 }
2537 fossil_free(zNext);
2538 blob_append_sql(&cond, " AND %Q=strftime('%%Y-%%m',event.mtime) ",
2539 zYearMonth);
2540 nEntry = -1;
 
 
 
 
 
 
 
2541 }
2542 else if( zYearWeek ){
2543 char *z, *zNext;
2544 zYearWeek = timeline_expand_datetime(zYearWeek);
 
 
2545 z = db_text(0, "SELECT strftime('%%Y-%%W',%Q)", zYearWeek);
2546 if( z && z[0] ){
2547 zYearWeekStart = db_text(0, "SELECT date(%Q,'-6 days','weekday 1')",
2548 zYearWeek);
2549 zYearWeek = z;
@@ -2560,64 +2478,152 @@
2560 "SELECT date('now','-6 days','weekday 1');");
2561 zYearWeek = db_text(0,
2562 "SELECT strftime('%%Y-%%W','now','-6 days','weekday 1')");
2563 }
2564 }
2565 zNext = db_text(0, "SELECT date(%Q,'+7 day');", zYearWeekStart);
2566 if( db_int(0,
2567 "SELECT EXISTS (SELECT 1 FROM event CROSS JOIN blob"
2568 " WHERE blob.rid=event.objid AND mtime>=julianday(%Q)%s)",
2569 zNext, blob_sql_text(&cond))
2570 ){
2571 zNewerButton = fossil_strdup(url_render(&url, "yw", zNext, 0, 0));
2572 zNewerButtonLabel = "Following week";
2573 }
2574 fossil_free(zNext);
2575 zNext = db_text(0, "SELECT date(%Q,'-7 days');", zYearWeekStart);
2576 if( db_int(0,
2577 "SELECT EXISTS (SELECT 1 FROM event CROSS JOIN blob"
2578 " WHERE blob.rid=event.objid AND mtime<julianday(%Q)%s)",
2579 zYearWeekStart, blob_sql_text(&cond))
2580 ){
2581 zOlderButton = fossil_strdup(url_render(&url, "yw", zNext, 0, 0));
2582 zOlderButtonLabel = "Previous week";
2583 }
2584 fossil_free(zNext);
2585 blob_append_sql(&cond, " AND %Q=strftime('%%Y-%%W',event.mtime) ",
2586 zYearWeek);
2587 nEntry = -1;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2588 }
2589 else if( zDay ){
2590 char *zNext;
2591 zDay = timeline_expand_datetime(zDay);
 
 
 
 
2592 zDay = db_text(0, "SELECT date(%Q)", zDay);
2593 if( zDay==0 || zDay[0]==0 ){
2594 zDay = db_text(0, "SELECT date('now')");
2595 }
2596 zNext = db_text(0, "SELECT date(%Q,'+1 day');", zDay);
2597 if( db_int(0,
2598 "SELECT EXISTS (SELECT 1 FROM event CROSS JOIN blob"
2599 " WHERE blob.rid=event.objid AND mtime>=julianday(%Q)%s)",
2600 zNext, blob_sql_text(&cond))
2601 ){
2602 zNewerButton = fossil_strdup(url_render(&url, "ymd", zNext, 0, 0));
2603 zNewerButtonLabel = "Following day";
2604 }
2605 fossil_free(zNext);
2606 zNext = db_text(0, "SELECT date(%Q,'-1 day');", zDay);
2607 if( db_int(0,
2608 "SELECT EXISTS (SELECT 1 FROM event CROSS JOIN blob"
2609 " WHERE blob.rid=event.objid AND mtime<julianday(%Q)%s)",
2610 zDay, blob_sql_text(&cond))
2611 ){
2612 zOlderButton = fossil_strdup(url_render(&url, "ymd", zNext, 0, 0));
2613 zOlderButtonLabel = "Previous day";
2614 }
2615 fossil_free(zNext);
2616 blob_append_sql(&cond, " AND %Q=date(event.mtime) ",
2617 zDay);
2618 nEntry = -1;
 
 
 
 
 
 
 
 
 
 
2619 }
2620 else if( zNDays ){
2621 nDays = atoi(zNDays);
2622 if( nDays<1 ) nDays = 1;
2623 blob_append_sql(&cond, " AND event.mtime>=julianday('now','-%d days') ",
@@ -2663,39 +2669,24 @@
2663 nEntry = -1;
2664 }
2665 if( zTagSql ){
2666 db_multi_exec(
2667 "CREATE TEMP TABLE selected_nodes(rid INTEGER PRIMARY KEY);"
2668 "INSERT OR IGNORE INTO selected_nodes"
2669 " SELECT tagxref.rid FROM tagxref NATURAL JOIN tag"
2670 " WHERE %s AND tagtype>0", zTagSql/*safe-for-%s*/
 
2671 );
2672 if( zMark ){
2673 /* If the t=release option is used with m=UUID, then also
2674 ** include the UUID check-in in the display list */
2675 int ridMark = name_to_rid(zMark);
2676 db_multi_exec(
2677 "INSERT OR IGNORE INTO selected_nodes(rid) VALUES(%d)", ridMark);
2678 }
2679 if( P("x")!=0 ){
2680 char *zX = fossil_strdup(P("x"));
2681 int ii;
2682 int ridX;
2683 while( zX[0] ){
2684 char c;
2685 if( zX[0]==',' || zX[0]==' ' ){ zX++; continue; }
2686 for(ii=1; zX[ii] && zX[ii]!=',' && zX[ii]!=' '; ii++){}
2687 c = zX[ii];
2688 zX[ii] = 0;
2689 ridX = name_to_rid(zX);
2690 db_multi_exec(
2691 "INSERT OR IGNORE INTO selected_nodes(rid) VALUES(%d)", ridX);
2692 zX[ii] = c;
2693 zX += ii;
2694 }
2695 }
2696 if( !related ){
2697 blob_append_sql(&cond, " AND blob.rid IN selected_nodes");
2698 }else{
2699 db_multi_exec(
2700 "CREATE TEMP TABLE related_nodes(rid INTEGER PRIMARY KEY);"
2701 "INSERT INTO related_nodes SELECT rid FROM selected_nodes;"
@@ -2706,40 +2697,42 @@
2706 ** branch to be included in the report. These related check-ins are
2707 ** useful in helping to visualize what has happened on a quiescent
2708 ** branch that is infrequently merged with a much more activate branch.
2709 */
2710 db_multi_exec(
2711 "INSERT OR IGNORE INTO related_nodes"
2712 " SELECT pid FROM selected_nodes CROSS JOIN plink"
2713 " WHERE selected_nodes.rid=plink.cid;"
2714 );
2715 if( P("mionly")==0 ){
2716 db_multi_exec(
2717 "INSERT OR IGNORE INTO related_nodes"
2718 " SELECT cid FROM selected_nodes CROSS JOIN plink"
2719 " WHERE selected_nodes.rid=plink.pid;"
2720 );
2721 if( showCherrypicks ){
2722 db_multi_exec(
2723 "INSERT OR IGNORE INTO related_nodes"
2724 " SELECT childid FROM selected_nodes CROSS JOIN cherrypick"
2725 " WHERE selected_nodes.rid=cherrypick.parentid;"
2726 );
2727 }
2728 }
2729 if( showCherrypicks ){
2730 db_multi_exec(
2731 "INSERT OR IGNORE INTO related_nodes"
2732 " SELECT parentid FROM selected_nodes CROSS JOIN cherrypick"
2733 " WHERE selected_nodes.rid=cherrypick.childid;"
2734 );
2735 }
2736 if( (tmFlags & TIMELINE_UNHIDE)==0 ){
2737 db_multi_exec(
2738 "DELETE FROM related_nodes WHERE rid IN "
2739 " (SELECT related_nodes.rid FROM related_nodes, tagxref"
2740 " WHERE tagid=%d AND tagtype>0 AND tagxref.rid=related_nodes.rid)",
 
 
2741 TAG_HIDDEN
2742 );
2743 }
2744 }
2745 }
@@ -2829,45 +2822,42 @@
2829 rCirca = symbolic_name_to_mtime(zCirca, &zCirca);
2830 blob_append_sql(&sql, "%s", blob_sql_text(&cond));
2831 if( rAfter>0.0 ){
2832 if( rBefore>0.0 ){
2833 blob_append_sql(&sql,
2834 " AND event.mtime>=%.17g AND event.mtime<=%.17g"
2835 " ORDER BY event.mtime ASC", rAfter-ONE_SECOND, rBefore+ONE_SECOND);
2836 nEntry = -1;
2837 }else{
2838 blob_append_sql(&sql,
2839 " AND event.mtime>=%.17g ORDER BY event.mtime ASC",
2840 rAfter-ONE_SECOND);
2841 }
2842 zCirca = 0;
2843 url_add_parameter(&url, "c", 0);
2844 }else if( rBefore>0.0 ){
2845 blob_append_sql(&sql,
2846 " AND event.mtime<=%.17g ORDER BY event.mtime DESC",
2847 rBefore+ONE_SECOND);
2848 zCirca = 0;
2849 url_add_parameter(&url, "c", 0);
2850 }else if( rCirca>0.0 ){
2851 Blob sql2;
2852 blob_init(&sql2, blob_sql_text(&sql), -1);
2853 blob_append_sql(&sql2,
2854 " AND event.mtime>=%f ORDER BY event.mtime ASC", rCirca);
2855 if( nEntry>0 ){
2856 blob_append_sql(&sql2," LIMIT %d", (nEntry+1)/2);
2857 }
2858 if( PB("showsql") ){
2859 @ <pre>%h(blob_sql_text(&sql2))</pre>
2860 }
2861 db_multi_exec("%s", blob_sql_text(&sql2));
2862 if( nEntry>0 ){
2863 nEntry -= db_int(0,"select count(*) from timeline");
2864 if( nEntry<=0 ) nEntry = 1;
2865 }
2866 blob_reset(&sql2);
2867 blob_append_sql(&sql,
2868 " AND event.mtime<=%f ORDER BY event.mtime DESC",
2869 rCirca
2870 );
2871 if( zMark==0 ) zMark = zCirca;
2872 }else{
2873 blob_append_sql(&sql, " ORDER BY event.mtime DESC");
@@ -2876,11 +2866,11 @@
2876 db_multi_exec("%s", blob_sql_text(&sql));
2877
2878 n = db_int(0, "SELECT count(*) FROM timeline WHERE etype!='div' /*scan*/");
2879 zPlural = n==1 ? "" : "s";
2880 if( zYearMonth ){
2881 blob_appendf(&desc, "%d %s%s for the month beginning %h-01",
2882 n, zEType, zPlural, zYearMonth);
2883 }else if( zYearWeek ){
2884 blob_appendf(&desc, "%d %s%s for week %h beginning on %h",
2885 n, zEType, zPlural, zYearWeek, zYearWeekStart);
2886 }else if( zDay ){
@@ -3010,12 +3000,14 @@
3010 style_submenu_multichoice("ms", count(azMatchStyles)/2,azMatchStyles,0);
3011 }
3012 }
3013 blob_zero(&cond);
3014 }
3015 if( PB("showsql") ){
3016 @ <pre>%h(blob_sql_text(&sql))</pre>
 
 
3017 }
3018 if( search_restrict(SRCH_CKIN)!=0 ){
3019 style_submenu_element("Search", "%R/search?y=c");
3020 }
3021 if( advancedMenu ){
@@ -3069,18 +3061,36 @@
3069 if( zNewerButton ){
3070 @ %z(chref("button","%s",zNewerButton))%h(zNewerButtonLabel)\
3071 @ &nbsp;&uarr;</a>
3072 }
3073 cgi_check_for_malice();
3074 www_print_timeline(&q, tmFlags, zThisUser, zThisTag, zBrName,
3075 selectedRid, secondaryRid, 0);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3076 db_finalize(&q);
3077 if( zOlderButton ){
3078 @ %z(chref("button","%s",zOlderButton))%h(zOlderButtonLabel)\
3079 @ &nbsp;&darr;</a>
3080 }
3081 document_emit_js(/*handles pikchrs rendered above*/);
 
 
3082 style_finish_page();
3083 }
3084
3085 /*
3086 ** Translate a timeline entry into the printable format by
@@ -3745,10 +3755,11 @@
3745 const char *zToday;
3746 char *zStartOfProject;
3747 int i;
3748 Stmt q;
3749 char *z;
 
3750
3751 login_check_credentials();
3752 if( (!g.perm.Read && !g.perm.RdTkt && !g.perm.RdWiki && !g.perm.RdForum) ){
3753 login_needed(g.anon.Read && g.anon.RdTkt && g.anon.RdWiki);
3754 return;
@@ -3755,11 +3766,11 @@
3755 }
3756 style_set_current_feature("timeline");
3757 style_header("Today In History");
3758 zToday = (char*)P("today");
3759 if( zToday ){
3760 zToday = timeline_expand_datetime(zToday);
3761 if( !fossil_isdate(zToday) ) zToday = 0;
3762 }
3763 if( zToday==0 ){
3764 zToday = db_text(0, "SELECT date('now',toLocal())");
3765 }
3766
--- src/timeline.c
+++ src/timeline.c
@@ -191,11 +191,11 @@
191 void www_print_timeline(
192 Stmt *pQuery, /* Query to implement the timeline */
193 int tmFlags, /* Flags controlling display behavior */
194 const char *zThisUser, /* Suppress links to this user */
195 const char *zThisTag, /* Suppress links to this tag */
196 Matcher *pLeftBranch, /* Comparison function to use for zLeftBranch */
197 int selectedRid, /* Highlight the line with this RID value or zero */
198 int secondRid, /* Secondary highlight (or zero) */
199 void (*xExtra)(int) /* Routine to call on each line of display */
200 ){
201 int mxWikiLen;
@@ -813,11 +813,11 @@
813 }
814 if( pendingEndTr ){
815 @ </td></tr>
816 }
817 if( pGraph ){
818 graph_finish(pGraph, pLeftBranch, tmFlags);
819 if( pGraph->nErr ){
820 graph_free(pGraph);
821 pGraph = 0;
822 }else{
823 @ <tr class="timelineBottom" id="btm-%d(iTableId)">\
@@ -1290,12 +1290,13 @@
1290 const char *zChng, /* The filename GLOB list */
1291 Blob *pSql /* The SELECT statement under construction */
1292 ){
1293 if( zChng==0 || zChng[0]==0 ) return;
1294 blob_append_sql(pSql," AND event.objid IN ("
1295 "SELECT mlink.mid FROM mlink, filename\n"
1296 " WHERE mlink.fnid=filename.fnid\n"
1297 " AND %s)",
1298 glob_expr("filename.name", mprintf("\"%s\"", zChng)));
1299 }
1300 static void addFileGlobDescription(
1301 const char *zChng, /* The filename GLOB list */
1302 Blob *pDescription /* Result description */
@@ -1303,274 +1304,86 @@
1304 if( zChng==0 || zChng[0]==0 ) return;
1305 blob_appendf(pDescription, " that include changes to files matching '%h'",
1306 zChng);
1307 }
1308
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1309 /*
1310 ** Similar to fossil_expand_datetime()
1311 **
1312 ** Add missing "-" characters into a date/time. Examples:
1313 **
1314 ** 20190419 => 2019-04-19
1315 ** 201904 => 2019-04
1316 */
1317 const char *timeline_expand_datetime(const char *zIn, int *pbZulu){
1318 static char zEDate[16];
 
1319 int n = (int)strlen(zIn);
1320 int i, j;
1321
1322 /* These forms are recognized:
1323 **
1324 ** (1) YYYYMMDD
1325 ** (2) YYYYMM
1326 ** (3) YYYYWW
1327 */
1328 if( n && (zIn[n-1]=='Z' || zIn[n-1]=='z') ){
1329 n--;
1330 if( pbZulu ) *pbZulu = 1;
1331 }else{
1332 if( pbZulu ) *pbZulu = 0;
1333 }
1334 if( n!=8 && n!=6 ) return zIn;
1335
1336 /* Every character must be a digit */
1337 for(i=0; i<n && fossil_isdigit(zIn[i]); i++){}
1338 if( i!=n ) return zIn;
1339
1340 /* Expand the date */
1341 for(i=j=0; i<n; i++){
1342 if( j==4 || j==7 ) zEDate[j++] = '-';
 
 
1343 zEDate[j++] = zIn[i];
1344 }
1345 zEDate[j] = 0;
1346
1347 /* It looks like this may be a date. Return it with punctuation added. */
1348 return zEDate;
1349 }
1350
1351 /*
1352 ** Check to see if the argument is a date-span for the ymd= query
1353 ** parameter. A valid date-span is of the form:
1354 **
1355 ** 0123456789 123456 <-- index
1356 ** YYYYMMDD-YYYYMMDD
1357 **
1358 ** with an optional "Z" timeline modifier at the end. Return true if
1359 ** the input is a valid date space and false if not.
1360 */
1361 static int timeline_is_datespan(const char *zDay){
1362 size_t n = strlen(zDay);
1363 int i, d, m;
1364
1365 if( n<17 || n>18 ) return 0;
1366 if( n==18 ){
1367 if( zDay[17]!='Z' && zDay[17]!='z' ) return 0;
1368 n--;
1369 }
1370 if( zDay[8]!='-' ) return 0;
1371 for(i=0; i<17 && (fossil_isdigit(zDay[i]) || i==8); i++){}
1372 if( i!=17 ) return 0;
1373 i = atoi(zDay);
1374 d = i%100;
1375 if( d<1 || d>31 ) return 0;
1376 m = (i/100)%100;
1377 if( m<1 || m>12 ) return 0;
1378 i = atoi(zDay+9);
1379 d = i%100;
1380 if( d<1 || d>31 ) return 0;
1381 m = (i/100)%100;
1382 if( m<1 || m>12 ) return 0;
1383 return 1;
1384 }
1385
1386 /*
1387 ** Find the first check-in encountered with a particular tag
1388 ** when moving either forwards are backwards in time from a
1389 ** particular starting point (iFrom). Return the rid of that
@@ -1591,10 +1404,11 @@
1404 tagId = db_int(0, "SELECT tagid FROM tag WHERE tagname='sym-%q'", zEnd);
1405 if( tagId==0 ){
1406 endId = symbolic_name_to_rid(zEnd, "ci");
1407 if( endId==0 ) return 0;
1408 }
1409 db_pause_dml_log();
1410 if( bForward ){
1411 if( tagId ){
1412 db_prepare(&q,
1413 "WITH RECURSIVE dx(id,mtime) AS ("
1414 " SELECT %d, event.mtime FROM event WHERE objid=%d"
@@ -1658,12 +1472,54 @@
1472 }
1473 if( db_step(&q)==SQLITE_ROW ){
1474 ans = db_column_int(&q, 0);
1475 }
1476 db_finalize(&q);
1477 db_unpause_dml_log();
1478 return ans;
1479 }
1480
1481 /*
1482 ** Add to the (temp) table zTab, RID values for every check-in
1483 ** identifier found on the zExtra string. Check-in names can be separated
1484 ** by commas or by whitespace.
1485 */
1486 static void add_extra_rids(const char *zTab, const char *zExtra){
1487 int ii;
1488 int rid;
1489 int cnt;
1490 Blob sql;
1491 char *zX;
1492 char *zToDel;
1493 if( zExtra==0 ) return;
1494 cnt = 0;
1495 blob_init(&sql, 0, 0);
1496 zX = zToDel = fossil_strdup(zExtra);
1497 blob_append_sql(&sql, "INSERT OR IGNORE INTO \"%w\" VALUES", zTab);
1498 while( zX[0] ){
1499 char c;
1500 if( zX[0]==',' || zX[0]==' ' ){ zX++; continue; }
1501 for(ii=1; zX[ii] && zX[ii]!=',' && zX[ii]!=' '; ii++){}
1502 c = zX[ii];
1503 zX[ii] = 0;
1504 rid = name_to_rid(zX);
1505 if( rid>0 ){
1506 if( (cnt%10)==4 ){
1507 blob_append_sql(&sql,",\n ");
1508 }else if( cnt>0 ){
1509 blob_append_sql(&sql,",");
1510 }
1511 blob_append_sql(&sql, "(%d)", rid);
1512 cnt++;
1513 }
1514 zX[ii] = c;
1515 zX += ii;
1516 }
1517 if( cnt ) db_exec_sql(blob_sql_text(&sql));
1518 blob_reset(&sql);
1519 fossil_free(zToDel);
1520 }
1521
1522 /*
1523 ** COMMAND: test-endpoint
1524 **
1525 ** Usage: fossil test-endpoint BASE TAG ?OPTIONS?
@@ -1698,21 +1554,21 @@
1554 /*
1555 ** WEBPAGE: timeline
1556 **
1557 ** Query parameters:
1558 **
1559 ** a=TIMEORTAG Show events after TIMEORTAG.
1560 ** b=TIMEORTAG Show events before TIMEORTAG.
1561 ** c=TIMEORTAG Show events that happen "circa" TIMEORTAG
1562 ** cf=FILEHASH Show events around the time of the first use of
1563 ** the file with FILEHASH.
1564 ** m=TIMEORTAG Highlight the event at TIMEORTAG, or the closest available
1565 ** event if TIMEORTAG is not part of the timeline. If
1566 ** the t= or r= is used, the m event is added to the timeline
1567 ** if it isn't there already.
1568 ** x=LIST Show check-ins in the comma- or space-separated LIST
1569 ** in addition to check-ins specified by other parameters.
1570 ** sel1=TIMEORTAG Highlight the check-in at TIMEORTAG if it is part of
1571 ** the timeline. Similar to m= except TIMEORTAG must
1572 ** match a check-in that is already in the timeline.
1573 ** sel2=TIMEORTAG Like sel1= but use the secondary highlight.
1574 ** n=COUNT Maximum number of events. "all" for no limit
@@ -1732,63 +1588,71 @@
1588 ** from=CX ... shortest path from CX back to CHECKIN
1589 ** ft=CHECKIN "Forward To": Show decendents forward to CHECKIN
1590 ** d=CX ... from CX up to the time of CHECKIN
1591 ** from=CX ... shortest path from CX up to CHECKIN
1592 ** t=TAG Show only check-ins with the given TAG
1593 ** r=TAG Same as 't=TAG&rel'. Mnemonic: "Related"
1594 ** tl=TAGLIST Same as 't=TAGLIST&ms=brlist'. Mnemonic: "Tag List"
1595 ** rl=TAGLIST Same as 'r=TAGLIST&ms=brlist'. Mnemonic: "Related List"
1596 ** ml=TAGLIST Same as 'tl=TAGLIST&mionly'. Mnemonic: "Merge-in List"
1597 ** sl=TAGLIST "Sort List". Draw TAGLIST branches ordered left to right.
1598 ** rel Show related check-ins as well as those matching t=TAG
1599 ** mionly Show related parents but not related children.
1600 ** nowiki Do not show wiki associated with branch or tag
1601 ** ms=MATCHSTYLE Set tag name match algorithm. One of "exact", "glob",
1602 ** "like", or "regexp".
1603 ** u=USER Only show items associated with USER
1604 ** y=TYPE 'ci', 'w', 't', 'n', 'e', 'f', or 'all'.
1605 ** ss=VIEWSTYLE c: "Compact", v: "Verbose", m: "Modern", j: "Columnar",
1606 * x: "Classic".
1607 ** advm Use the "Advanced" or "Busy" menu design.
1608 ** ng No Graph.
1609 ** ncp Omit cherrypick merges
1610 ** nd Do not highlight the focus check-in
1611 ** nsm Omit the submenu
1612 ** nc Omit all graph colors other than highlights
1613 ** v Show details of files changed
1614 ** vfx Show complete text of forum messages
1615 ** f=CHECKIN Family (immediate parents and children) of CHECKIN
1616 ** from=CHECKIN Path through common ancestor from...
1617 ** to=CHECKIN ... to this
1618 ** to2=CHECKIN ... backup name if to= doesn't resolve
1619 ** shortest ... show only the shortest path
1620 ** rel ... also show related checkins
1621 ** bt=PRIOR ... path from CHECKIN back to PRIOR
1622 ** ft=LATER ... path from CHECKIN forward to LATER
1623 ** me=CHECKIN Most direct path from...
1624 ** you=CHECKIN ... to this
1625 ** rel ... also show related checkins
1626 ** uf=FILE_HASH Show only check-ins that contain the given file version
1627 ** All qualifying check-ins are shown unless there is
1628 ** also an n= or n1= query parameter.
1629 ** chng=GLOBLIST Show only check-ins that involve changes to a file whose
1630 ** name matches one of the comma-separate GLOBLIST
1631 ** brbg Background color determined by branch name
1632 ** ubg Background color determined by user
1633 ** deltabg Background color red for delta manifests or green
1634 ** for baseline manifests
1635 ** namechng Show only check-ins that have filename changes
1636 ** forks Show only forks and their children
1637 ** cherrypicks Show all cherrypicks
1638 ** ym=YYYYMM Show only events for the given year/month
1639 ** yw=YYYYWW Show only events for the given week of the given year
1640 ** yw=YYYYMMDD Show events for the week that includes the given day
1641 ** ymd=YYYYMMDD Show only events on the given day. The use "ymd=now"
1642 ** to see all changes for the current week. Add "z" at end
1643 ** to divide days at UTC instead of localtime days.
1644 ** Use ymd=YYYYMMDD-YYYYMMDD (with optional "z") for a range.
1645 ** year=YYYY Show only events on the given year. The use "year=0"
1646 ** to see all changes for the current year.
1647 ** days=N Show events over the previous N days
1648 ** datefmt=N Override the date format: 0=HH:MM, 1=HH:MM:SS,
1649 ** 2=YYYY-MM-DD HH:MM:SS, 3=YYMMDD HH:MM, and 4 means "off".
1650 ** bisect Show the check-ins that are in the current bisect
1651 ** oldestfirst Show events oldest first.
1652 ** showid Show RIDs
1653 ** showsql Show the SQL used to generate the report
1654 **
1655 ** p= and d= can appear individually or together. If either p= or d=
1656 ** appear, then u=, y=, a=, and b= are ignored.
1657 **
1658 ** If both a= and b= appear then both upper and lower bounds are honored.
@@ -1862,14 +1726,20 @@
1726 int advancedMenu = 0; /* Use the advanced menu design */
1727 char *zPlural; /* Ending for plural forms */
1728 int showCherrypicks = 1; /* True to show cherrypick merges */
1729 int haveParameterN; /* True if n= query parameter present */
1730 int from_to_mode = 0; /* 0: from,to. 1: from,ft 2: from,bt */
1731 int showSql = PB("showsql"); /* True to show the SQL */
1732 Blob allSql; /* Copy of all SQL text */
1733
1734 login_check_credentials();
1735 url_initialize(&url, "timeline");
1736 cgi_query_parameters_to_url(&url);
1737 blob_init(&allSql, 0, 0);
1738
1739 /* The "mionly" query parameter is like "rel", but shows merge-ins only */
1740 if( P("mionly")!=0 ) related = 2;
1741
1742 (void)P_NoBot("ss")
1743 /* "ss" is processed via the udc but at least one spider likes to
1744 ** try to SQL inject via this argument, so let's catch that. */;
1745
@@ -1984,49 +1854,52 @@
1854
1855 /* Check for tl=TAGLIST and rl=TAGLIST which are abbreviations for
1856 ** t=TAGLIST&ms=brlist and r=TAGLIST&ms=brlist repectively. */
1857 if( zBrName==0 && zTagName==0 ){
1858 const char *z;
1859 const char *zPattern = 0;
1860 if( (z = P("tl"))!=0 ){
1861 zPattern = zTagName = z;
1862 }else if( (z = P("rl"))!=0 ){
1863 zPattern = zBrName = z;
1864 if( related==0 ) related = 1;
1865 }else if( (z = P("ml"))!=0 ){
1866 zPattern = zBrName = z;
1867 if( related==0 ) related = 2;
1868 }
1869 if( zPattern!=0 && zMatchStyle==0 ){
1870 /* If there was no ms= query parameter, set the match style to
1871 ** "glob" if the pattern appears to contain GLOB character, or
1872 ** "brlist" if it does not. */
1873 if( strpbrk(zPattern,"*[?") ){
1874 zMatchStyle = "glob";
1875 }else{
1876 zMatchStyle = "brlist";
1877 }
1878 }
1879 }
1880
1881 /* Convert r=TAG to t=TAG&rel in order to populate the UI style widgets. */
1882 if( zBrName ){
1883 cgi_delete_query_parameter("r");
1884 cgi_set_query_parameter("t", zBrName); (void)P("t");
1885 cgi_set_query_parameter("rel", "1");
1886 zTagName = zBrName;
1887 if( related==0 ) related = 1;
1888 zType = "ci";
1889 }
1890
1891 /* Ignore empty tag query strings. */
1892 if( zTagName && !*zTagName ){
1893 zTagName = 0;
1894 }
1895
1896 /* Finish preliminary processing of tag match queries. */
1897 matchStyle = match_style(zMatchStyle, MS_EXACT);
1898 if( zTagName ){
1899 zType = "ci";
1900 if( matchStyle==MS_EXACT ){
 
 
 
 
 
 
 
 
 
1901 /* For exact maching, inhibit links to the selected tag. */
1902 zThisTag = zTagName;
1903 Th_Store("current_checkin", zTagName);
1904 }
1905
@@ -2034,11 +1907,11 @@
1907 if( advancedMenu ){
1908 style_submenu_checkbox("rel", "Related", 0, 0);
1909 }
1910
1911 /* Construct the tag match expression. */
1912 zTagSql = match_tag_sqlexpr(matchStyle, zTagName, &zMatchDesc, &zError);
1913 }
1914
1915 if( zMark && zMark[0]==0 ){
1916 if( zAfter ) zMark = zAfter;
1917 if( zBefore ) zMark = zBefore;
@@ -2082,10 +1955,11 @@
1955 }
1956 if( PB("nc") ){
1957 tmFlags &= ~(TIMELINE_DELTA|TIMELINE_BRCOLOR|TIMELINE_UCOLOR);
1958 tmFlags |= TIMELINE_NOCOLOR;
1959 }
1960 if( showSql ) db_append_dml_to_blob(&allSql);
1961 if( zUses!=0 ){
1962 int ufid = db_int(0, "SELECT rid FROM blob WHERE uuid GLOB '%q*'", zUses);
1963 if( ufid ){
1964 zUses = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", ufid);
1965 db_multi_exec("CREATE TEMP TABLE usesfile(rid INTEGER PRIMARY KEY)");
@@ -2099,42 +1973,42 @@
1973 }
1974 if( renameOnly ){
1975 db_multi_exec(
1976 "CREATE TEMP TABLE rnfile(rid INTEGER PRIMARY KEY);"
1977 "INSERT OR IGNORE INTO rnfile"
1978 " SELECT mid FROM mlink WHERE pfnid>0 AND pfnid!=fnid;"
1979 );
1980 disableY = 1;
1981 }
1982 if( forkOnly ){
1983 db_multi_exec(
1984 "CREATE TEMP TABLE rnfork(rid INTEGER PRIMARY KEY);\n"
1985 "INSERT OR IGNORE INTO rnfork(rid)\n"
1986 " SELECT pid FROM plink\n"
1987 " WHERE (SELECT value FROM tagxref WHERE tagid=%d AND rid=cid)==\n"
1988 " (SELECT value FROM tagxref WHERE tagid=%d AND rid=pid)\n"
1989 " GROUP BY pid\n"
1990 " HAVING count(*)>1;\n"
1991 "INSERT OR IGNORE INTO rnfork(rid)\n"
1992 " SELECT cid FROM plink\n"
1993 " WHERE (SELECT value FROM tagxref WHERE tagid=%d AND rid=cid)==\n"
1994 " (SELECT value FROM tagxref WHERE tagid=%d AND rid=pid)\n"
1995 " GROUP BY cid\n"
1996 " HAVING count(*)>1;\n",
1997 TAG_BRANCH, TAG_BRANCH, TAG_BRANCH, TAG_BRANCH
1998 );
1999 db_multi_exec(
2000 "INSERT OR IGNORE INTO rnfork(rid)\n"
2001 " SELECT cid FROM plink\n"
2002 " WHERE pid IN rnfork\n"
2003 " AND (SELECT value FROM tagxref WHERE tagid=%d AND rid=cid)==\n"
2004 " (SELECT value FROM tagxref WHERE tagid=%d AND rid=pid)\n"
2005 " UNION\n"
2006 " SELECT pid FROM plink\n"
2007 " WHERE cid IN rnfork\n"
2008 " AND (SELECT value FROM tagxref WHERE tagid=%d AND rid=cid)==\n"
2009 " (SELECT value FROM tagxref WHERE tagid=%d AND rid=pid)\n",
2010 TAG_BRANCH, TAG_BRANCH, TAG_BRANCH, TAG_BRANCH
2011 );
2012 tmFlags |= TIMELINE_UNHIDE;
2013 zType = "ci";
2014 disableY = 1;
@@ -2207,77 +2081,114 @@
2081 PathNode *p = 0;
2082 const char *zFrom = 0;
2083 const char *zTo = 0;
2084 Blob ins;
2085 int nNodeOnPath = 0;
2086 int commonAncs = 0; /* Common ancestors of me_rid and you_rid. */
2087 int earlierRid = 0, laterRid = 0;
2088
2089 if( from_rid && to_rid ){
2090 if( from_to_mode==0 ){
2091 p = path_shortest(from_rid, to_rid, noMerge, 0, 0);
2092 }else if( from_to_mode==1 ){
2093 p = path_shortest(from_rid, to_rid, 0, 1, 0);
2094 earlierRid = commonAncs = from_rid;
2095 laterRid = to_rid;
2096 }else{
2097 p = path_shortest(to_rid, from_rid, 0, 1, 0);
2098 earlierRid = commonAncs = to_rid;
2099 laterRid = from_rid;
2100 }
2101 zFrom = P("from");
2102 zTo = zTo2 ? zTo2 : P("to");
2103 }else{
2104 commonAncs = path_common_ancestor(me_rid, you_rid);
2105 if( commonAncs!=0 ){
2106 p = path_first();
2107 }
2108 if( commonAncs==you_rid ){
2109 zFrom = P("you");
2110 zTo = P("me");
2111 earlierRid = you_rid;
2112 laterRid = me_rid;
2113 }else{
2114 zFrom = P("me");
2115 zTo = P("you");
2116 earlierRid = me_rid;
2117 laterRid = you_rid;
2118 }
2119 }
2120 blob_init(&ins, 0, 0);
2121 db_multi_exec(
2122 "CREATE TEMP TABLE IF NOT EXISTS pathnode(x INTEGER PRIMARY KEY);"
2123 );
2124 if( p ){
2125 int cnt = 4;
2126 blob_init(&ins, 0, 0);
2127 blob_append_sql(&ins, "INSERT INTO pathnode(x) VALUES(%d)", p->rid);
2128 p = p->u.pTo;
2129 while( p ){
2130 if( cnt==8 ){
2131 blob_append_sql(&ins, ",\n (%d)", p->rid);
2132 cnt = 0;
2133 }else{
2134 cnt++;
2135 blob_append_sql(&ins, ",(%d)", p->rid);
2136 }
2137 p = p->u.pTo;
2138 }
2139 }
2140 path_reset();
2141 db_multi_exec("%s", blob_str(&ins)/*safe-for-%s*/);
2142 blob_reset(&ins);
2143 if( related ){
2144 db_multi_exec(
2145 "CREATE TEMP TABLE IF NOT EXISTS related(x INTEGER PRIMARY KEY);"
2146 "INSERT OR IGNORE INTO related(x)"
2147 " SELECT pid FROM plink WHERE cid IN pathnode AND NOT isprim;"
2148 );
2149 if( related==1 ){
2150 db_multi_exec(
2151 "INSERT OR IGNORE INTO related(x)"
2152 " SELECT cid FROM plink WHERE pid IN pathnode;"
2153 );
2154 }
2155 if( showCherrypicks ){
2156 db_multi_exec(
2157 "INSERT OR IGNORE INTO related(x)"
2158 " SELECT parentid FROM cherrypick WHERE childid IN pathnode;"
2159 );
2160 if( related==1 ){
2161 db_multi_exec(
2162 "INSERT OR IGNORE INTO related(x)"
2163 " SELECT childid FROM cherrypick WHERE parentid IN pathnode;"
2164 );
2165 }
2166 }
2167 if( earlierRid && laterRid && commonAncs==earlierRid ){
2168 /* On a query with me=XXX, you=YYY, and rel, omit all nodes that
2169 ** are not ancestors of either XXX or YYY, as those nodes tend to
2170 ** be extraneous */
2171 db_multi_exec(
2172 "CREATE TEMP TABLE IF NOT EXISTS ok(rid INTEGER PRIMARY KEY)"
2173 );
2174 compute_ancestors(laterRid, 0, 0, earlierRid);
2175 db_multi_exec(
2176 "DELETE FROM related WHERE x NOT IN ok;"
2177 );
2178 }
2179 db_multi_exec("INSERT OR IGNORE INTO pathnode SELECT x FROM related");
2180 }
2181 add_extra_rids("pathnode",P("x"));
2182 blob_append_sql(&sql, " AND event.objid IN pathnode");
2183 if( zChng && zChng[0] ){
2184 db_multi_exec(
2185 "DELETE FROM pathnode\n"
2186 " WHERE NOT EXISTS(SELECT 1 FROM mlink, filename\n"
2187 " WHERE mlink.mid=x\n"
2188 " AND mlink.fnid=filename.fnid\n"
2189 " AND %s)",
2190 glob_expr("filename.name", zChng)
2191 );
2192 }
2193 tmFlags |= TIMELINE_XMERGE | TIMELINE_FILLGAPS;
2194 db_multi_exec("%s", blob_sql_text(&sql));
@@ -2331,18 +2242,18 @@
2242 if( !haveParameterN ) nEntry = 10;
2243 }
2244 db_multi_exec(
2245 "CREATE TEMP TABLE IF NOT EXISTS ok(rid INTEGER PRIMARY KEY)"
2246 );
2247 add_extra_rids("ok", P("x"));
2248 zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d",
2249 p_rid ? p_rid : d_rid);
2250 zCiName = zDPName;
2251 if( zCiName==0 ) zCiName = zUuid;
2252 blob_append_sql(&sql, " AND event.objid IN ok");
2253 nd = 0;
2254 if( d_rid ){
 
2255 double rStopTime = 9e99;
2256 zFwdTo = P("ft");
2257 if( zFwdTo ){
2258 double rStartDate = db_double(0.0,
2259 "SELECT mtime FROM event WHERE objid=%d", d_rid);
@@ -2354,27 +2265,25 @@
2265 if( !haveParameterN ) nEntry = 0;
2266 rStopTime = db_double(9e99,
2267 "SELECT mtime FROM event WHERE objid=%d", ridFwdTo);
2268 }
2269 }
2270 if( rStopTime<9e99 ){
2271 rStopTime += 5.8e-6; /* Round up by 1/2 second */
2272 }
2273 db_multi_exec(
2274 "WITH RECURSIVE dx(rid,mtime) AS (\n"
2275 " SELECT %d, 0\n"
2276 " UNION\n"
2277 " SELECT plink.cid, plink.mtime FROM dx, plink\n"
2278 " WHERE plink.pid=dx.rid\n"
2279 " AND plink.mtime<=%.*g\n"
2280 " ORDER BY 2\n"
2281 ")\n"
2282 "INSERT OR IGNORE INTO ok SELECT rid FROM dx LIMIT %d",
2283 d_rid, rStopTime<8e99 ? 17 : 2, rStopTime, nEntry<=0 ? -1 : nEntry+1
2284 );
 
 
 
 
2285 nd = db_int(0, "SELECT count(*)-1 FROM ok");
2286 if( nd>=0 ) db_multi_exec("%s", blob_sql_text(&sql));
2287 if( nd>0 || p_rid==0 ){
2288 blob_appendf(&desc, "%d descendant%s", nd,(1==nd)?"":"s");
2289 }
@@ -2483,67 +2392,76 @@
2392 if( zChng && *zChng ){
2393 addFileGlobExclusion(zChng, &cond);
2394 tmFlags |= TIMELINE_XMERGE;
2395 }
2396 if( zUses ){
2397 blob_append_sql(&cond, " AND event.objid IN usesfile\n");
2398 }
2399 if( renameOnly ){
2400 blob_append_sql(&cond, " AND event.objid IN rnfile\n");
2401 }
2402 if( forkOnly ){
2403 blob_append_sql(&cond, " AND event.objid IN rnfork\n");
2404 }
2405 if( cpOnly && showCherrypicks ){
2406 db_multi_exec(
2407 "CREATE TEMP TABLE IF NOT EXISTS cpnodes(rid INTEGER PRIMARY KEY);"
2408 "INSERT OR IGNORE INTO cpnodes SELECT childid FROM cherrypick;"
2409 "INSERT OR IGNORE INTO cpnodes SELECT parentid FROM cherrypick;"
2410 );
2411 blob_append_sql(&cond, " AND event.objid IN cpnodes\n");
2412 }
2413 if( bisectLocal || zBisect!=0 ){
2414 blob_append_sql(&cond, " AND event.objid IN (SELECT rid FROM bilog)\n");
2415 }
2416 if( zYearMonth ){
2417 char *zNext;
2418 int bZulu = 0;
2419 const char *zTZMod;
2420 zYearMonth = timeline_expand_datetime(zYearMonth, &bZulu);
2421 zYearMonth = mprintf("%.7s", zYearMonth);
2422 if( db_int(0,"SELECT julianday('%q-01') IS NULL", zYearMonth) ){
2423 zYearMonth = db_text(0, "SELECT strftime('%%Y-%%m','now');");
2424 }
2425 zTZMod = (bZulu==0 && fossil_ui_localtime()) ? "utc" : "+00:00";
2426 if( db_int(0,
2427 "SELECT EXISTS (SELECT 1 FROM event CROSS JOIN blob"
2428 " WHERE blob.rid=event.objid"
2429 " AND mtime>=julianday('%q-01',%Q)%s)",
2430 zYearMonth, zTZMod, blob_sql_text(&cond))
2431 ){
2432 zNext = db_text(0, "SELECT strftime('%%Y%%m%q','%q-01','+1 month');",
2433 &"Z"[!bZulu], zYearMonth);
2434 zNewerButton = fossil_strdup(url_render(&url, "ym", zNext, 0, 0));
2435 zNewerButtonLabel = "Following month";
2436 fossil_free(zNext);
2437 }
2438 if( db_int(0,
2439 "SELECT EXISTS (SELECT 1 FROM event CROSS JOIN blob"
2440 " WHERE blob.rid=event.objid"
2441 " AND mtime<julianday('%q-01',%Q)%s)",
2442 zYearMonth, zTZMod, blob_sql_text(&cond))
2443 ){
2444 zNext = db_text(0, "SELECT strftime('%%Y%%m%q','%q-01','-1 month');",
2445 &"Z"[!bZulu], zYearMonth);
2446 zOlderButton = fossil_strdup(url_render(&url, "ym", zNext, 0, 0));
2447 zOlderButtonLabel = "Previous month";
2448 fossil_free(zNext);
2449 }
2450 blob_append_sql(&cond,
2451 " AND event.mtime>=julianday('%q-01',%Q)"
2452 " AND event.mtime<julianday('%q-01',%Q,'+1 month')\n",
2453 zYearMonth, zTZMod, zYearMonth, zTZMod);
2454 nEntry = -1;
2455 /* Adjust the zYearMonth for the title */
2456 zYearMonth = mprintf("%z-01%s", zYearMonth, &"Z"[!bZulu]);
2457 }
2458 else if( zYearWeek ){
2459 char *z, *zNext;
2460 int bZulu = 0;
2461 const char *zTZMod;
2462 zYearWeek = timeline_expand_datetime(zYearWeek, &bZulu);
2463 z = db_text(0, "SELECT strftime('%%Y-%%W',%Q)", zYearWeek);
2464 if( z && z[0] ){
2465 zYearWeekStart = db_text(0, "SELECT date(%Q,'-6 days','weekday 1')",
2466 zYearWeek);
2467 zYearWeek = z;
@@ -2560,64 +2478,152 @@
2478 "SELECT date('now','-6 days','weekday 1');");
2479 zYearWeek = db_text(0,
2480 "SELECT strftime('%%Y-%%W','now','-6 days','weekday 1')");
2481 }
2482 }
2483 zTZMod = (bZulu==0 && fossil_ui_localtime()) ? "utc" : "+00:00";
2484 if( db_int(0,
2485 "SELECT EXISTS (SELECT 1 FROM event CROSS JOIN blob"
2486 " WHERE blob.rid=event.objid"
2487 " AND mtime>=julianday(%Q,%Q)%s)",
2488 zYearWeekStart, zTZMod, blob_sql_text(&cond))
2489 ){
2490 zNext = db_text(0, "SELECT strftime('%%Y%%W%q',%Q,'+7 day');",
2491 &"Z"[!bZulu], zYearWeekStart);
2492 zNewerButton = fossil_strdup(url_render(&url, "yw", zNext, 0, 0));
2493 zNewerButtonLabel = "Following week";
2494 fossil_free(zNext);
2495 }
2496 if( db_int(0,
2497 "SELECT EXISTS (SELECT 1 FROM event CROSS JOIN blob"
2498 " WHERE blob.rid=event.objid"
2499 " AND mtime<julianday(%Q,%Q)%s)",
2500 zYearWeekStart, zTZMod, blob_sql_text(&cond))
2501 ){
2502 zNext = db_text(0, "SELECT strftime('%%Y%%W%q',%Q,'-7 days');",
2503 &"Z"[!bZulu], zYearWeekStart);
2504 zOlderButton = fossil_strdup(url_render(&url, "yw", zNext, 0, 0));
2505 zOlderButtonLabel = "Previous week";
2506 fossil_free(zNext);
2507 }
2508 blob_append_sql(&cond,
2509 " AND event.mtime>=julianday(%Q,%Q)"
2510 " AND event.mtime<julianday(%Q,%Q,'+7 days')\n",
2511 zYearWeekStart, zTZMod, zYearWeekStart, zTZMod);
2512 nEntry = -1;
2513 if( fossil_ui_localtime() && bZulu ){
2514 zYearWeekStart = mprintf("%zZ", zYearWeekStart);
2515 }
2516 }
2517 else if( zDay && timeline_is_datespan(zDay) ){
2518 char *zNext;
2519 char *zStart, *zEnd;
2520 int nDay;
2521 int bZulu = 0;
2522 const char *zTZMod;
2523 zEnd = db_text(0, "SELECT date(%Q)",
2524 timeline_expand_datetime(zDay+9, &bZulu));
2525 zStart = db_text(0, "SELECT date('%.4q-%.2q-%.2q')",
2526 zDay, zDay+4, zDay+6);
2527 nDay = db_int(0, "SELECT julianday(%Q)-julianday(%Q)", zEnd, zStart);
2528 if( nDay==0 ){
2529 zDay = &zDay[9];
2530 goto single_ymd;
2531 }
2532 if( nDay<0 ){
2533 char *zTemp = zEnd;
2534 zEnd = zStart;
2535 zStart = zTemp;
2536 nDay = 1 - nDay;
2537 }else{
2538 nDay += 1;
2539 }
2540 zTZMod = (bZulu==0 && fossil_ui_localtime()) ? "utc" : "+00:00";
2541 if( nDay>0 && db_int(0,
2542 "SELECT EXISTS (SELECT 1 FROM event CROSS JOIN blob"
2543 " WHERE blob.rid=event.objid"
2544 " AND mtime>=julianday(%Q,'1 day',%Q)%s)",
2545 zEnd, zTZMod, blob_sql_text(&cond))
2546 ){
2547 zNext = db_text(0,
2548 "SELECT strftime('%%Y%%m%%d-',%Q,'%d days')||"
2549 "strftime('%%Y%%m%%d%q',%Q,'%d day');",
2550 zStart, nDay, &"Z"[!bZulu], zEnd, nDay);
2551 zNewerButton = fossil_strdup(url_render(&url, "ymd", zNext, 0, 0));
2552 zNewerButtonLabel = mprintf("Following %d days", nDay);
2553 fossil_free(zNext);
2554 }
2555 if( nDay>1 && db_int(0,
2556 "SELECT EXISTS (SELECT 1 FROM event CROSS JOIN blob"
2557 " WHERE blob.rid=event.objid"
2558 " AND mtime<julianday(%Q,'-1 day',%Q)%s)",
2559 zStart, zTZMod, blob_sql_text(&cond))
2560 ){
2561 zNext = db_text(0,
2562 "SELECT strftime('%%Y%%m%%d-',%Q,'%d days')||"
2563 "strftime('%%Y%%m%%d%q',%Q,'%d day');",
2564 zStart, -nDay, &"Z"[!bZulu], zEnd, -nDay);
2565 zOlderButton = fossil_strdup(url_render(&url, "ymd", zNext, 0, 0));
2566 zOlderButtonLabel = mprintf("Previous %d days", nDay);
2567 fossil_free(zNext);
2568 }
2569 blob_append_sql(&cond,
2570 " AND event.mtime>=julianday(%Q,%Q)"
2571 " AND event.mtime<julianday(%Q,%Q,'+1 day')\n",
2572 zStart, zTZMod, zEnd, zTZMod);
2573 nEntry = -1;
2574
2575 if( fossil_ui_localtime() && bZulu ){
2576 zDay = mprintf("%d days between %zZ and %zZ", nDay, zStart, zEnd);
2577 }else{
2578 zDay = mprintf("%d days between %z and %z", nDay, zStart, zEnd);
2579 }
2580 }
2581 else if( zDay ){
2582 char *zNext;
2583 int bZulu = 0;
2584 const char *zTZMod;
2585 single_ymd:
2586 bZulu = 0;
2587 zDay = timeline_expand_datetime(zDay, &bZulu);
2588 zDay = db_text(0, "SELECT date(%Q)", zDay);
2589 if( zDay==0 || zDay[0]==0 ){
2590 zDay = db_text(0, "SELECT date('now')");
2591 }
2592 zTZMod = (bZulu==0 && fossil_ui_localtime()) ? "utc" : "+00:00";
2593 if( db_int(0,
2594 "SELECT EXISTS (SELECT 1 FROM event CROSS JOIN blob"
2595 " WHERE blob.rid=event.objid"
2596 " AND mtime>=julianday(%Q,'+1 day',%Q)%s)",
2597 zDay, zTZMod, blob_sql_text(&cond))
2598 ){
2599 zNext = db_text(0,"SELECT strftime('%%Y%%m%%d%q',%Q,'+1 day');",
2600 &"Z"[!bZulu], zDay);
2601 zNewerButton = fossil_strdup(url_render(&url, "ymd", zNext, 0, 0));
2602 zNewerButtonLabel = "Following day";
2603 fossil_free(zNext);
2604 }
2605 if( db_int(0,
2606 "SELECT EXISTS (SELECT 1 FROM event CROSS JOIN blob"
2607 " WHERE blob.rid=event.objid"
2608 " AND mtime<julianday(%Q,'-1 day',%Q)%s)",
2609 zDay, zTZMod, blob_sql_text(&cond))
2610 ){
2611 zNext = db_text(0,"SELECT strftime('%%Y%%m%%d%q',%Q,'-1 day');",
2612 &"Z"[!bZulu], zDay);
2613 zOlderButton = fossil_strdup(url_render(&url, "ymd", zNext, 0, 0));
2614 zOlderButtonLabel = "Previous day";
2615 fossil_free(zNext);
2616 }
2617 blob_append_sql(&cond,
2618 " AND event.mtime>=julianday(%Q,%Q)"
2619 " AND event.mtime<julianday(%Q,%Q,'+1 day')\n",
2620 zDay, zTZMod, zDay, zTZMod);
2621 nEntry = -1;
2622 if( fossil_ui_localtime() && bZulu ){
2623 zDay = mprintf("%zZ", zDay); /* Add Z suffix to day for the title */
2624 }
2625 }
2626 else if( zNDays ){
2627 nDays = atoi(zNDays);
2628 if( nDays<1 ) nDays = 1;
2629 blob_append_sql(&cond, " AND event.mtime>=julianday('now','-%d days') ",
@@ -2663,39 +2669,24 @@
2669 nEntry = -1;
2670 }
2671 if( zTagSql ){
2672 db_multi_exec(
2673 "CREATE TEMP TABLE selected_nodes(rid INTEGER PRIMARY KEY);"
2674 "INSERT OR IGNORE INTO selected_nodes\n"
2675 " SELECT tagxref.rid FROM tagxref NATURAL JOIN tag\n"
2676 " WHERE tagtype>0\n"
2677 " AND %s", zTagSql/*safe-for-%s*/
2678 );
2679 if( zMark ){
2680 /* If the t=release option is used with m=UUID, then also
2681 ** include the UUID check-in in the display list */
2682 int ridMark = name_to_rid(zMark);
2683 db_multi_exec(
2684 "INSERT OR IGNORE INTO selected_nodes(rid) VALUES(%d)", ridMark);
2685 }
2686 add_extra_rids("selected_nodes",P("x"));
2687 if( related==0 ){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2688 blob_append_sql(&cond, " AND blob.rid IN selected_nodes");
2689 }else{
2690 db_multi_exec(
2691 "CREATE TEMP TABLE related_nodes(rid INTEGER PRIMARY KEY);"
2692 "INSERT INTO related_nodes SELECT rid FROM selected_nodes;"
@@ -2706,40 +2697,42 @@
2697 ** branch to be included in the report. These related check-ins are
2698 ** useful in helping to visualize what has happened on a quiescent
2699 ** branch that is infrequently merged with a much more activate branch.
2700 */
2701 db_multi_exec(
2702 "INSERT OR IGNORE INTO related_nodes\n"
2703 " SELECT pid FROM selected_nodes CROSS JOIN plink\n"
2704 " WHERE selected_nodes.rid=plink.cid;"
2705 );
2706 if( related==1 ){
2707 db_multi_exec(
2708 "INSERT OR IGNORE INTO related_nodes\n"
2709 " SELECT cid FROM selected_nodes CROSS JOIN plink\n"
2710 " WHERE selected_nodes.rid=plink.pid;"
2711 );
2712 if( showCherrypicks ){
2713 db_multi_exec(
2714 "INSERT OR IGNORE INTO related_nodes\n"
2715 " SELECT childid FROM selected_nodes CROSS JOIN cherrypick\n"
2716 " WHERE selected_nodes.rid=cherrypick.parentid;"
2717 );
2718 }
2719 }
2720 if( showCherrypicks ){
2721 db_multi_exec(
2722 "INSERT OR IGNORE INTO related_nodes\n"
2723 " SELECT parentid FROM selected_nodes CROSS JOIN cherrypick\n"
2724 " WHERE selected_nodes.rid=cherrypick.childid;"
2725 );
2726 }
2727 if( (tmFlags & TIMELINE_UNHIDE)==0 ){
2728 db_multi_exec(
2729 "DELETE FROM related_nodes\n"
2730 " WHERE rid IN (SELECT related_nodes.rid\n"
2731 " FROM related_nodes, tagxref\n"
2732 " WHERE tagid=%d AND tagtype>0\n"
2733 " AND tagxref.rid=related_nodes.rid)",
2734 TAG_HIDDEN
2735 );
2736 }
2737 }
2738 }
@@ -2829,45 +2822,42 @@
2822 rCirca = symbolic_name_to_mtime(zCirca, &zCirca);
2823 blob_append_sql(&sql, "%s", blob_sql_text(&cond));
2824 if( rAfter>0.0 ){
2825 if( rBefore>0.0 ){
2826 blob_append_sql(&sql,
2827 " AND event.mtime>=%.17g AND event.mtime<=%.17g\n"
2828 " ORDER BY event.mtime ASC", rAfter-ONE_SECOND, rBefore+ONE_SECOND);
2829 nEntry = -1;
2830 }else{
2831 blob_append_sql(&sql,
2832 " AND event.mtime>=%.17g\n ORDER BY event.mtime ASC",
2833 rAfter-ONE_SECOND);
2834 }
2835 zCirca = 0;
2836 url_add_parameter(&url, "c", 0);
2837 }else if( rBefore>0.0 ){
2838 blob_append_sql(&sql,
2839 " AND event.mtime<=%.17g\n ORDER BY event.mtime DESC",
2840 rBefore+ONE_SECOND);
2841 zCirca = 0;
2842 url_add_parameter(&url, "c", 0);
2843 }else if( rCirca>0.0 ){
2844 Blob sql2;
2845 blob_init(&sql2, blob_sql_text(&sql), -1);
2846 blob_append_sql(&sql2,
2847 " AND event.mtime>=%f\n ORDER BY event.mtime ASC", rCirca);
2848 if( nEntry>0 ){
2849 blob_append_sql(&sql2," LIMIT %d", (nEntry+1)/2);
2850 }
 
 
 
2851 db_multi_exec("%s", blob_sql_text(&sql2));
2852 if( nEntry>0 ){
2853 nEntry -= db_int(0,"select count(*) from timeline");
2854 if( nEntry<=0 ) nEntry = 1;
2855 }
2856 blob_reset(&sql2);
2857 blob_append_sql(&sql,
2858 " AND event.mtime<=%f\n ORDER BY event.mtime DESC",
2859 rCirca
2860 );
2861 if( zMark==0 ) zMark = zCirca;
2862 }else{
2863 blob_append_sql(&sql, " ORDER BY event.mtime DESC");
@@ -2876,11 +2866,11 @@
2866 db_multi_exec("%s", blob_sql_text(&sql));
2867
2868 n = db_int(0, "SELECT count(*) FROM timeline WHERE etype!='div' /*scan*/");
2869 zPlural = n==1 ? "" : "s";
2870 if( zYearMonth ){
2871 blob_appendf(&desc, "%d %s%s for the month beginning %h",
2872 n, zEType, zPlural, zYearMonth);
2873 }else if( zYearWeek ){
2874 blob_appendf(&desc, "%d %s%s for week %h beginning on %h",
2875 n, zEType, zPlural, zYearWeek, zYearWeekStart);
2876 }else if( zDay ){
@@ -3010,12 +3000,14 @@
3000 style_submenu_multichoice("ms", count(azMatchStyles)/2,azMatchStyles,0);
3001 }
3002 }
3003 blob_zero(&cond);
3004 }
3005 if( showSql ){
3006 db_append_dml_to_blob(0);
3007 @ <pre>%h(blob_str(&allSql))</pre>
3008 blob_reset(&allSql);
3009 }
3010 if( search_restrict(SRCH_CKIN)!=0 ){
3011 style_submenu_element("Search", "%R/search?y=c");
3012 }
3013 if( advancedMenu ){
@@ -3069,18 +3061,36 @@
3061 if( zNewerButton ){
3062 @ %z(chref("button","%s",zNewerButton))%h(zNewerButtonLabel)\
3063 @ &nbsp;&uarr;</a>
3064 }
3065 cgi_check_for_malice();
3066 {
3067 Matcher *pLeftBranch;
3068 const char *zPattern = P("sl");
3069 if( zPattern!=0 ){
3070 MatchStyle ms;
3071 if( zMatchStyle!=0 ){
3072 ms = matchStyle;
3073 }else{
3074 ms = strpbrk(zPattern,"*[?")!=0 ? MS_GLOB : MS_BRLIST;
3075 }
3076 pLeftBranch = match_create(ms,zPattern);
3077 }else{
3078 pLeftBranch = match_create(matchStyle, zBrName?zBrName:zTagName);
3079 }
3080 www_print_timeline(&q, tmFlags, zThisUser, zThisTag, pLeftBranch,
3081 selectedRid, secondaryRid, 0);
3082 match_free(pLeftBranch);
3083 }
3084 db_finalize(&q);
3085 if( zOlderButton ){
3086 @ %z(chref("button","%s",zOlderButton))%h(zOlderButtonLabel)\
3087 @ &nbsp;&darr;</a>
3088 }
3089 document_emit_js(/*handles pikchrs rendered above*/);
3090 blob_reset(&sql);
3091 blob_reset(&desc);
3092 style_finish_page();
3093 }
3094
3095 /*
3096 ** Translate a timeline entry into the printable format by
@@ -3745,10 +3755,11 @@
3755 const char *zToday;
3756 char *zStartOfProject;
3757 int i;
3758 Stmt q;
3759 char *z;
3760 int bZulu = 0;
3761
3762 login_check_credentials();
3763 if( (!g.perm.Read && !g.perm.RdTkt && !g.perm.RdWiki && !g.perm.RdForum) ){
3764 login_needed(g.anon.Read && g.anon.RdTkt && g.anon.RdWiki);
3765 return;
@@ -3755,11 +3766,11 @@
3766 }
3767 style_set_current_feature("timeline");
3768 style_header("Today In History");
3769 zToday = (char*)P("today");
3770 if( zToday ){
3771 zToday = timeline_expand_datetime(zToday, &bZulu);
3772 if( !fossil_isdate(zToday) ) zToday = 0;
3773 }
3774 if( zToday==0 ){
3775 zToday = db_text(0, "SELECT date('now',toLocal())");
3776 }
3777
+17 -11
--- src/update.c
+++ src/update.c
@@ -514,14 +514,10 @@
514514
zDir = zNext;
515515
}
516516
}
517517
}
518518
}else if( idt>0 && idv>0 && ridt!=ridv && chnged ){
519
- /* Merge the changes in the current tree into the target version */
520
- Blob r, t, v;
521
- int rc;
522
-
523519
if( nameChng ){
524520
fossil_print("MERGE %s -> %s\n", zName, zNewName);
525521
}else{
526522
fossil_print("MERGE %s\n", zName);
527523
}
@@ -528,10 +524,13 @@
528524
if( islinkv || islinkt ){
529525
fossil_print("***** Cannot merge symlink %s\n", zNewName);
530526
zOp = "CONFLICT";
531527
nConflict++;
532528
}else{
529
+ /* Merge the changes in the current tree into the target version */
530
+ Blob r, t, v;
531
+ int rc;
533532
unsigned mergeFlags = dryRunFlag ? MERGE_DRYRUN : 0;
534533
if(keepMergeFlag!=0) mergeFlags |= MERGE_KEEP_FILES;
535534
if( !dryRunFlag && !internalUpdate ) undo_save(zName);
536535
content_get(ridt, &t);
537536
content_get(ridv, &v);
@@ -571,15 +570,15 @@
571570
nConflict++;
572571
zOp = "ERROR";
573572
zErrMsg = "cannot merge binary file";
574573
nc = 1;
575574
}
575
+ blob_reset(&v);
576
+ blob_reset(&t);
577
+ blob_reset(&r);
576578
}
577579
if( nameChng && !dryRunFlag ) file_delete(zFullPath);
578
- blob_reset(&v);
579
- blob_reset(&t);
580
- blob_reset(&r);
581580
}else{
582581
nUpdate--;
583582
if( chnged ){
584583
if( verboseFlag ) fossil_print("EDITED %s\n", zName);
585584
}else{
@@ -854,10 +853,11 @@
854853
**
855854
** If a file is reverted accidentally, it can be restored using
856855
** the "fossil undo" command.
857856
**
858857
** Options:
858
+** --noundo Do not record changes in the undo/redo log.
859859
** -r|--revision VERSION Revert given FILE(s) back to given
860860
** VERSION
861861
**
862862
** See also: [[redo]], [[undo]], [[checkout]], [[update]]
863863
*/
@@ -867,17 +867,19 @@
867867
ManifestFile *pCoFile; /* File within current check-out manifest */
868868
ManifestFile *pRvFile; /* File within revert version manifest */
869869
const char *zFile; /* Filename relative to check-out root */
870870
const char *zRevision; /* Selected revert version, NULL if current */
871871
Blob record = BLOB_INITIALIZER; /* Contents of each reverted file */
872
+ int useUndo = 1; /* True to record changes in UNDO */
872873
int i;
873874
Stmt q;
874875
int revertAll = 0;
875876
int revisionOptNotSupported = 0;
876877
877878
undo_capture_command_line();
878879
zRevision = find_option("revision", "r", 1);
880
+ useUndo = find_option("noundo", 0, 0)==0;
879881
verify_all_options();
880882
881883
if( g.argc<2 ){
882884
usage("?OPTIONS? [FILE] ...");
883885
}
@@ -890,11 +892,15 @@
890892
/* Get manifests of revert version and (if different) current check-out. */
891893
pRvManifest = historical_manifest(zRevision);
892894
pCoManifest = zRevision ? historical_manifest(0) : 0;
893895
894896
db_begin_transaction();
895
- undo_begin();
897
+ if( useUndo ){
898
+ undo_begin();
899
+ }else{
900
+ undo_reset();
901
+ }
896902
db_multi_exec("CREATE TEMP TABLE torevert(name UNIQUE);");
897903
898904
if( g.argc>2 ){
899905
for(i=2; i<g.argc; i++){
900906
Blob fname;
@@ -987,11 +993,11 @@
987993
if( !pRvFile ){
988994
if( db_int(0, "SELECT rid FROM vfile WHERE pathname=%Q OR origname=%Q",
989995
zFile, zFile)==0 ){
990996
fossil_print("UNMANAGE %s\n", zFile);
991997
}else{
992
- undo_save(zFile);
998
+ if( useUndo ) undo_save(zFile);
993999
file_delete(zFull);
9941000
fossil_print("DELETE %s\n", zFile);
9951001
}
9961002
db_multi_exec(
9971003
"UPDATE OR REPLACE vfile"
@@ -1014,11 +1020,11 @@
10141020
}
10151021
10161022
/* Get contents of reverted-to file. */
10171023
content_get(fast_uuid_to_rid(pRvFile->zUuid), &record);
10181024
1019
- undo_save(zFile);
1025
+ if( useUndo ) undo_save(zFile);
10201026
if( file_size(zFull, RepoFILE)>=0
10211027
&& (rvPerm==PERM_LNK || file_islink(0))
10221028
){
10231029
file_delete(zFull);
10241030
}
@@ -1040,12 +1046,12 @@
10401046
}
10411047
blob_reset(&record);
10421048
free(zFull);
10431049
}
10441050
db_finalize(&q);
1045
- undo_finish();
1051
+ if( useUndo) undo_finish();
10461052
db_end_transaction(0);
10471053
10481054
/* Deallocate parsed manifest structures. */
10491055
manifest_destroy(pRvManifest);
10501056
manifest_destroy(pCoManifest);
10511057
}
10521058
--- src/update.c
+++ src/update.c
@@ -514,14 +514,10 @@
514 zDir = zNext;
515 }
516 }
517 }
518 }else if( idt>0 && idv>0 && ridt!=ridv && chnged ){
519 /* Merge the changes in the current tree into the target version */
520 Blob r, t, v;
521 int rc;
522
523 if( nameChng ){
524 fossil_print("MERGE %s -> %s\n", zName, zNewName);
525 }else{
526 fossil_print("MERGE %s\n", zName);
527 }
@@ -528,10 +524,13 @@
528 if( islinkv || islinkt ){
529 fossil_print("***** Cannot merge symlink %s\n", zNewName);
530 zOp = "CONFLICT";
531 nConflict++;
532 }else{
 
 
 
533 unsigned mergeFlags = dryRunFlag ? MERGE_DRYRUN : 0;
534 if(keepMergeFlag!=0) mergeFlags |= MERGE_KEEP_FILES;
535 if( !dryRunFlag && !internalUpdate ) undo_save(zName);
536 content_get(ridt, &t);
537 content_get(ridv, &v);
@@ -571,15 +570,15 @@
571 nConflict++;
572 zOp = "ERROR";
573 zErrMsg = "cannot merge binary file";
574 nc = 1;
575 }
 
 
 
576 }
577 if( nameChng && !dryRunFlag ) file_delete(zFullPath);
578 blob_reset(&v);
579 blob_reset(&t);
580 blob_reset(&r);
581 }else{
582 nUpdate--;
583 if( chnged ){
584 if( verboseFlag ) fossil_print("EDITED %s\n", zName);
585 }else{
@@ -854,10 +853,11 @@
854 **
855 ** If a file is reverted accidentally, it can be restored using
856 ** the "fossil undo" command.
857 **
858 ** Options:
 
859 ** -r|--revision VERSION Revert given FILE(s) back to given
860 ** VERSION
861 **
862 ** See also: [[redo]], [[undo]], [[checkout]], [[update]]
863 */
@@ -867,17 +867,19 @@
867 ManifestFile *pCoFile; /* File within current check-out manifest */
868 ManifestFile *pRvFile; /* File within revert version manifest */
869 const char *zFile; /* Filename relative to check-out root */
870 const char *zRevision; /* Selected revert version, NULL if current */
871 Blob record = BLOB_INITIALIZER; /* Contents of each reverted file */
 
872 int i;
873 Stmt q;
874 int revertAll = 0;
875 int revisionOptNotSupported = 0;
876
877 undo_capture_command_line();
878 zRevision = find_option("revision", "r", 1);
 
879 verify_all_options();
880
881 if( g.argc<2 ){
882 usage("?OPTIONS? [FILE] ...");
883 }
@@ -890,11 +892,15 @@
890 /* Get manifests of revert version and (if different) current check-out. */
891 pRvManifest = historical_manifest(zRevision);
892 pCoManifest = zRevision ? historical_manifest(0) : 0;
893
894 db_begin_transaction();
895 undo_begin();
 
 
 
 
896 db_multi_exec("CREATE TEMP TABLE torevert(name UNIQUE);");
897
898 if( g.argc>2 ){
899 for(i=2; i<g.argc; i++){
900 Blob fname;
@@ -987,11 +993,11 @@
987 if( !pRvFile ){
988 if( db_int(0, "SELECT rid FROM vfile WHERE pathname=%Q OR origname=%Q",
989 zFile, zFile)==0 ){
990 fossil_print("UNMANAGE %s\n", zFile);
991 }else{
992 undo_save(zFile);
993 file_delete(zFull);
994 fossil_print("DELETE %s\n", zFile);
995 }
996 db_multi_exec(
997 "UPDATE OR REPLACE vfile"
@@ -1014,11 +1020,11 @@
1014 }
1015
1016 /* Get contents of reverted-to file. */
1017 content_get(fast_uuid_to_rid(pRvFile->zUuid), &record);
1018
1019 undo_save(zFile);
1020 if( file_size(zFull, RepoFILE)>=0
1021 && (rvPerm==PERM_LNK || file_islink(0))
1022 ){
1023 file_delete(zFull);
1024 }
@@ -1040,12 +1046,12 @@
1040 }
1041 blob_reset(&record);
1042 free(zFull);
1043 }
1044 db_finalize(&q);
1045 undo_finish();
1046 db_end_transaction(0);
1047
1048 /* Deallocate parsed manifest structures. */
1049 manifest_destroy(pRvManifest);
1050 manifest_destroy(pCoManifest);
1051 }
1052
--- src/update.c
+++ src/update.c
@@ -514,14 +514,10 @@
514 zDir = zNext;
515 }
516 }
517 }
518 }else if( idt>0 && idv>0 && ridt!=ridv && chnged ){
 
 
 
 
519 if( nameChng ){
520 fossil_print("MERGE %s -> %s\n", zName, zNewName);
521 }else{
522 fossil_print("MERGE %s\n", zName);
523 }
@@ -528,10 +524,13 @@
524 if( islinkv || islinkt ){
525 fossil_print("***** Cannot merge symlink %s\n", zNewName);
526 zOp = "CONFLICT";
527 nConflict++;
528 }else{
529 /* Merge the changes in the current tree into the target version */
530 Blob r, t, v;
531 int rc;
532 unsigned mergeFlags = dryRunFlag ? MERGE_DRYRUN : 0;
533 if(keepMergeFlag!=0) mergeFlags |= MERGE_KEEP_FILES;
534 if( !dryRunFlag && !internalUpdate ) undo_save(zName);
535 content_get(ridt, &t);
536 content_get(ridv, &v);
@@ -571,15 +570,15 @@
570 nConflict++;
571 zOp = "ERROR";
572 zErrMsg = "cannot merge binary file";
573 nc = 1;
574 }
575 blob_reset(&v);
576 blob_reset(&t);
577 blob_reset(&r);
578 }
579 if( nameChng && !dryRunFlag ) file_delete(zFullPath);
 
 
 
580 }else{
581 nUpdate--;
582 if( chnged ){
583 if( verboseFlag ) fossil_print("EDITED %s\n", zName);
584 }else{
@@ -854,10 +853,11 @@
853 **
854 ** If a file is reverted accidentally, it can be restored using
855 ** the "fossil undo" command.
856 **
857 ** Options:
858 ** --noundo Do not record changes in the undo/redo log.
859 ** -r|--revision VERSION Revert given FILE(s) back to given
860 ** VERSION
861 **
862 ** See also: [[redo]], [[undo]], [[checkout]], [[update]]
863 */
@@ -867,17 +867,19 @@
867 ManifestFile *pCoFile; /* File within current check-out manifest */
868 ManifestFile *pRvFile; /* File within revert version manifest */
869 const char *zFile; /* Filename relative to check-out root */
870 const char *zRevision; /* Selected revert version, NULL if current */
871 Blob record = BLOB_INITIALIZER; /* Contents of each reverted file */
872 int useUndo = 1; /* True to record changes in UNDO */
873 int i;
874 Stmt q;
875 int revertAll = 0;
876 int revisionOptNotSupported = 0;
877
878 undo_capture_command_line();
879 zRevision = find_option("revision", "r", 1);
880 useUndo = find_option("noundo", 0, 0)==0;
881 verify_all_options();
882
883 if( g.argc<2 ){
884 usage("?OPTIONS? [FILE] ...");
885 }
@@ -890,11 +892,15 @@
892 /* Get manifests of revert version and (if different) current check-out. */
893 pRvManifest = historical_manifest(zRevision);
894 pCoManifest = zRevision ? historical_manifest(0) : 0;
895
896 db_begin_transaction();
897 if( useUndo ){
898 undo_begin();
899 }else{
900 undo_reset();
901 }
902 db_multi_exec("CREATE TEMP TABLE torevert(name UNIQUE);");
903
904 if( g.argc>2 ){
905 for(i=2; i<g.argc; i++){
906 Blob fname;
@@ -987,11 +993,11 @@
993 if( !pRvFile ){
994 if( db_int(0, "SELECT rid FROM vfile WHERE pathname=%Q OR origname=%Q",
995 zFile, zFile)==0 ){
996 fossil_print("UNMANAGE %s\n", zFile);
997 }else{
998 if( useUndo ) undo_save(zFile);
999 file_delete(zFull);
1000 fossil_print("DELETE %s\n", zFile);
1001 }
1002 db_multi_exec(
1003 "UPDATE OR REPLACE vfile"
@@ -1014,11 +1020,11 @@
1020 }
1021
1022 /* Get contents of reverted-to file. */
1023 content_get(fast_uuid_to_rid(pRvFile->zUuid), &record);
1024
1025 if( useUndo ) undo_save(zFile);
1026 if( file_size(zFull, RepoFILE)>=0
1027 && (rvPerm==PERM_LNK || file_islink(0))
1028 ){
1029 file_delete(zFull);
1030 }
@@ -1040,12 +1046,12 @@
1046 }
1047 blob_reset(&record);
1048 free(zFull);
1049 }
1050 db_finalize(&q);
1051 if( useUndo) undo_finish();
1052 db_end_transaction(0);
1053
1054 /* Deallocate parsed manifest structures. */
1055 manifest_destroy(pRvManifest);
1056 manifest_destroy(pCoManifest);
1057 }
1058
+1
--- src/util.c
+++ src/util.c
@@ -943,10 +943,11 @@
943943
if( binaryOnPath(azBrowserProg[i]) ){
944944
zBrowser = azBrowserProg[i];
945945
break;
946946
}
947947
}
948
+ zBrowser = mprintf("%s 2>/dev/null", zBrowser);
948949
}
949950
#endif
950951
return zBrowser;
951952
}
952953
953954
--- src/util.c
+++ src/util.c
@@ -943,10 +943,11 @@
943 if( binaryOnPath(azBrowserProg[i]) ){
944 zBrowser = azBrowserProg[i];
945 break;
946 }
947 }
 
948 }
949 #endif
950 return zBrowser;
951 }
952
953
--- src/util.c
+++ src/util.c
@@ -943,10 +943,11 @@
943 if( binaryOnPath(azBrowserProg[i]) ){
944 zBrowser = azBrowserProg[i];
945 break;
946 }
947 }
948 zBrowser = mprintf("%s 2>/dev/null", zBrowser);
949 }
950 #endif
951 return zBrowser;
952 }
953
954
+11 -13
--- src/winhttp.c
+++ src/winhttp.c
@@ -413,25 +413,23 @@
413413
/*
414414
** The repository name is only needed if there was no open check-out. This
415415
** is designed to allow the open check-out for the interactive user to work
416416
** with the local Fossil server started via the "ui" command.
417417
*/
418
- zIp = SocketAddr_toString(&p->addr);
419
- if( (p->flags & HTTP_SERVER_HAD_CHECKOUT)==0 ){
420
- assert( g.zRepositoryName && g.zRepositoryName[0] );
421
- sqlite3_snprintf(sizeof(zCmd), zCmd, "%s--in %s\n--out %s\n--ipaddr %s\n%s",
422
- get_utf8_bom(0), zRequestFName, zReplyFName, zIp, g.zRepositoryName
423
- );
424
- }else{
425
- sqlite3_snprintf(sizeof(zCmd), zCmd, "%s--in %s\n--out %s\n--ipaddr %s",
426
- get_utf8_bom(0), zRequestFName, zReplyFName, zIp
427
- );
428
- }
429
- fossil_free(zIp);
430418
aux = fossil_fopen(zCmdFName, "wb");
431419
if( aux==0 ) goto end_request;
432
- fwrite(zCmd, 1, strlen(zCmd), aux);
420
+ fprintf(aux, "%s--in %s\n", get_utf8_bom(0), zRequestFName);
421
+ zIp = SocketAddr_toString(&p->addr);
422
+ fprintf(aux, "--out %s\n--ipaddr %s\n", zReplyFName, zIp);
423
+ fossil_free(zIp);
424
+ fprintf(aux, "--as %s\n", g.zCmdName);
425
+ if( g.zErrlog && g.zErrlog[0] ){
426
+ fprintf(aux,"--errorlog %s\n", g.zErrlog);
427
+ }
428
+ if( (p->flags & HTTP_SERVER_HAD_CHECKOUT)==0 ){
429
+ fprintf(aux,"%s",g.zRepositoryName);
430
+ }
433431
434432
sqlite3_snprintf(sizeof(zCmd), zCmd,
435433
"\"%s\" http -args \"%s\"%s%s",
436434
g.nameOfExe, zCmdFName,
437435
g.httpUseSSL ? "" : " --nossl", p->zOptions
438436
--- src/winhttp.c
+++ src/winhttp.c
@@ -413,25 +413,23 @@
413 /*
414 ** The repository name is only needed if there was no open check-out. This
415 ** is designed to allow the open check-out for the interactive user to work
416 ** with the local Fossil server started via the "ui" command.
417 */
418 zIp = SocketAddr_toString(&p->addr);
419 if( (p->flags & HTTP_SERVER_HAD_CHECKOUT)==0 ){
420 assert( g.zRepositoryName && g.zRepositoryName[0] );
421 sqlite3_snprintf(sizeof(zCmd), zCmd, "%s--in %s\n--out %s\n--ipaddr %s\n%s",
422 get_utf8_bom(0), zRequestFName, zReplyFName, zIp, g.zRepositoryName
423 );
424 }else{
425 sqlite3_snprintf(sizeof(zCmd), zCmd, "%s--in %s\n--out %s\n--ipaddr %s",
426 get_utf8_bom(0), zRequestFName, zReplyFName, zIp
427 );
428 }
429 fossil_free(zIp);
430 aux = fossil_fopen(zCmdFName, "wb");
431 if( aux==0 ) goto end_request;
432 fwrite(zCmd, 1, strlen(zCmd), aux);
 
 
 
 
 
 
 
 
 
 
433
434 sqlite3_snprintf(sizeof(zCmd), zCmd,
435 "\"%s\" http -args \"%s\"%s%s",
436 g.nameOfExe, zCmdFName,
437 g.httpUseSSL ? "" : " --nossl", p->zOptions
438
--- src/winhttp.c
+++ src/winhttp.c
@@ -413,25 +413,23 @@
413 /*
414 ** The repository name is only needed if there was no open check-out. This
415 ** is designed to allow the open check-out for the interactive user to work
416 ** with the local Fossil server started via the "ui" command.
417 */
 
 
 
 
 
 
 
 
 
 
 
 
418 aux = fossil_fopen(zCmdFName, "wb");
419 if( aux==0 ) goto end_request;
420 fprintf(aux, "%s--in %s\n", get_utf8_bom(0), zRequestFName);
421 zIp = SocketAddr_toString(&p->addr);
422 fprintf(aux, "--out %s\n--ipaddr %s\n", zReplyFName, zIp);
423 fossil_free(zIp);
424 fprintf(aux, "--as %s\n", g.zCmdName);
425 if( g.zErrlog && g.zErrlog[0] ){
426 fprintf(aux,"--errorlog %s\n", g.zErrlog);
427 }
428 if( (p->flags & HTTP_SERVER_HAD_CHECKOUT)==0 ){
429 fprintf(aux,"%s",g.zRepositoryName);
430 }
431
432 sqlite3_snprintf(sizeof(zCmd), zCmd,
433 "\"%s\" http -args \"%s\"%s%s",
434 g.nameOfExe, zCmdFName,
435 g.httpUseSSL ? "" : " --nossl", p->zOptions
436
+55 -2
--- src/xfer.c
+++ src/xfer.c
@@ -1041,10 +1041,43 @@
10411041
}
10421042
db_finalize(&q);
10431043
if( cnt==0 ) pXfer->resync = 0;
10441044
return cnt;
10451045
}
1046
+
1047
+/*
1048
+** Send an igot message for every cluster artifact that is not a phantom,
1049
+** is not shunned, is not private, and that is not in the UNCLUSTERED table.
1050
+** Return the number of cards sent.
1051
+*/
1052
+static int send_all_clusters(Xfer *pXfer){
1053
+ Stmt q;
1054
+ int cnt = 0;
1055
+ const char *zExtra;
1056
+ if( db_table_exists("temp","onremote") ){
1057
+ zExtra = " AND NOT EXISTS(SELECT 1 FROM onremote WHERE rid=blob.rid)";
1058
+ }else{
1059
+ zExtra = "";
1060
+ }
1061
+ db_prepare(&q,
1062
+ "SELECT uuid"
1063
+ " FROM tagxref JOIN blob ON tagxref.rid=blob.rid AND tagxref.tagid=%d"
1064
+ " WHERE NOT EXISTS(SELECT 1 FROM shun WHERE uuid=blob.uuid)"
1065
+ " AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=blob.rid)"
1066
+ " AND NOT EXISTS(SELECT 1 FROM unclustered WHERE rid=blob.rid)"
1067
+ " AND NOT EXISTS(SELECT 1 FROM private WHERE rid=blob.rid)%s",
1068
+ TAG_CLUSTER, zExtra /*safe-for-%s*/
1069
+ );
1070
+ while( db_step(&q)==SQLITE_ROW ){
1071
+ if( cnt==0 ) blob_appendf(pXfer->pOut, "# sending-clusters\n");
1072
+ blob_appendf(pXfer->pOut, "igot %s\n", db_column_text(&q, 0));
1073
+ cnt++;
1074
+ }
1075
+ db_finalize(&q);
1076
+ if( cnt ) blob_appendf(pXfer->pOut, "# end-of-clusters\n");
1077
+ return cnt;
1078
+}
10461079
10471080
/*
10481081
** Send an igot message for every artifact.
10491082
*/
10501083
static void send_all(Xfer *pXfer){
@@ -1781,10 +1814,19 @@
17811814
** The client sends this message to the server to ask the server
17821815
** to tell it about alternative repositories in the reply.
17831816
*/
17841817
if( blob_eq(&xfer.aToken[1], "req-links") ){
17851818
bSendLinks = 1;
1819
+ }else
1820
+
1821
+ /* pragma req-clusters
1822
+ **
1823
+ ** This pragma requests that the server send igot cards for every
1824
+ ** cluster artifact that it knows about.
1825
+ */
1826
+ if( blob_eq(&xfer.aToken[1], "req-clusters") ){
1827
+ send_all_clusters(&xfer);
17861828
}
17871829
17881830
}else
17891831
17901832
/* Unknown message
@@ -1981,11 +2023,11 @@
19812023
int nCardSent = 0; /* Number of cards sent */
19822024
int nCardRcvd = 0; /* Number of cards received */
19832025
int nCycle = 0; /* Number of round trips to the server */
19842026
int size; /* Size of a config value or uvfile */
19852027
int origConfigRcvMask; /* Original value of configRcvMask */
1986
- int nFileRecv; /* Number of files received */
2028
+ int nFileRecv = 0; /* Number of files received */
19872029
int mxPhantomReq = 200; /* Max number of phantoms to request per comm */
19882030
const char *zCookie; /* Server cookie */
19892031
i64 nUncSent, nUncRcvd; /* Bytes sent and received (before compression) */
19902032
i64 nSent, nRcvd; /* Bytes sent and received (after compression) */
19912033
int cloneSeqno = 1; /* Sequence number for clones */
@@ -2007,10 +2049,11 @@
20072049
int uvHashSent = 0; /* The "pragma uv-hash" message has been sent */
20082050
int uvDoPush = 0; /* Generate uvfile messages to send to server */
20092051
int uvPullOnly = 0; /* 1: pull-only. 2: pull-only warning issued */
20102052
int nUvGimmeSent = 0; /* Number of uvgimme cards sent on this cycle */
20112053
int nUvFileRcvd = 0; /* Number of uvfile cards received on this cycle */
2054
+ int nGimmeRcvd = 0; /* Number of gimme cards recevied on the prev cycle */
20122055
sqlite3_int64 mtime; /* Modification time on a UV file */
20132056
int autopushFailed = 0; /* Autopush following commit failed if true */
20142057
const char *zCkinLock; /* Name of check-in to lock. NULL for none */
20152058
const char *zClientId; /* A unique identifier for this check-out */
20162059
unsigned int mHttpFlags;/* Flags for the http_exchange() subsystem */
@@ -2181,15 +2224,21 @@
21812224
*/
21822225
if( (syncFlags & SYNC_PULL)!=0
21832226
|| ((syncFlags & SYNC_CLONE)!=0 && cloneSeqno==1)
21842227
){
21852228
request_phantoms(&xfer, mxPhantomReq);
2229
+ if( xfer.nGimmeSent>0 && nCycle==2 && (syncFlags & SYNC_PULL)!=0 ){
2230
+ blob_appendf(&send, "pragma req-clusters\n");
2231
+ }
21862232
}
21872233
if( syncFlags & SYNC_PUSH ){
21882234
send_unsent(&xfer);
21892235
nCardSent += send_unclustered(&xfer);
21902236
if( syncFlags & SYNC_PRIVATE ) send_private(&xfer);
2237
+ if( nGimmeRcvd>0 && nCycle==2 ){
2238
+ send_all_clusters(&xfer);
2239
+ }
21912240
}
21922241
21932242
/* Client sends configuration parameter requests. On a clone, delay sending
21942243
** this until the second cycle since the login card might fail on
21952244
** the first cycle.
@@ -2369,10 +2418,11 @@
23692418
nCardSent++;
23702419
}
23712420
go = 0;
23722421
nUvGimmeSent = 0;
23732422
nUvFileRcvd = 0;
2423
+ nGimmeRcvd = 0;
23742424
nPriorArtifact = nArtifactRcvd;
23752425
23762426
/* Process the reply that came back from the server */
23772427
while( blob_line(&recv, &xfer.line) ){
23782428
if( blob_buffer(&xfer.line)[0]=='#' ){
@@ -2449,11 +2499,14 @@
24492499
&& blob_is_hname(&xfer.aToken[1])
24502500
){
24512501
remote_unk(&xfer.aToken[1]);
24522502
if( syncFlags & SYNC_PUSH ){
24532503
int rid = rid_from_uuid(&xfer.aToken[1], 0, 0);
2454
- if( rid ) send_file(&xfer, rid, &xfer.aToken[1], 0);
2504
+ if( rid ){
2505
+ send_file(&xfer, rid, &xfer.aToken[1], 0);
2506
+ nGimmeRcvd++;
2507
+ }
24552508
}
24562509
}else
24572510
24582511
/* igot HASH ?PRIVATEFLAG?
24592512
**
24602513
--- src/xfer.c
+++ src/xfer.c
@@ -1041,10 +1041,43 @@
1041 }
1042 db_finalize(&q);
1043 if( cnt==0 ) pXfer->resync = 0;
1044 return cnt;
1045 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1046
1047 /*
1048 ** Send an igot message for every artifact.
1049 */
1050 static void send_all(Xfer *pXfer){
@@ -1781,10 +1814,19 @@
1781 ** The client sends this message to the server to ask the server
1782 ** to tell it about alternative repositories in the reply.
1783 */
1784 if( blob_eq(&xfer.aToken[1], "req-links") ){
1785 bSendLinks = 1;
 
 
 
 
 
 
 
 
 
1786 }
1787
1788 }else
1789
1790 /* Unknown message
@@ -1981,11 +2023,11 @@
1981 int nCardSent = 0; /* Number of cards sent */
1982 int nCardRcvd = 0; /* Number of cards received */
1983 int nCycle = 0; /* Number of round trips to the server */
1984 int size; /* Size of a config value or uvfile */
1985 int origConfigRcvMask; /* Original value of configRcvMask */
1986 int nFileRecv; /* Number of files received */
1987 int mxPhantomReq = 200; /* Max number of phantoms to request per comm */
1988 const char *zCookie; /* Server cookie */
1989 i64 nUncSent, nUncRcvd; /* Bytes sent and received (before compression) */
1990 i64 nSent, nRcvd; /* Bytes sent and received (after compression) */
1991 int cloneSeqno = 1; /* Sequence number for clones */
@@ -2007,10 +2049,11 @@
2007 int uvHashSent = 0; /* The "pragma uv-hash" message has been sent */
2008 int uvDoPush = 0; /* Generate uvfile messages to send to server */
2009 int uvPullOnly = 0; /* 1: pull-only. 2: pull-only warning issued */
2010 int nUvGimmeSent = 0; /* Number of uvgimme cards sent on this cycle */
2011 int nUvFileRcvd = 0; /* Number of uvfile cards received on this cycle */
 
2012 sqlite3_int64 mtime; /* Modification time on a UV file */
2013 int autopushFailed = 0; /* Autopush following commit failed if true */
2014 const char *zCkinLock; /* Name of check-in to lock. NULL for none */
2015 const char *zClientId; /* A unique identifier for this check-out */
2016 unsigned int mHttpFlags;/* Flags for the http_exchange() subsystem */
@@ -2181,15 +2224,21 @@
2181 */
2182 if( (syncFlags & SYNC_PULL)!=0
2183 || ((syncFlags & SYNC_CLONE)!=0 && cloneSeqno==1)
2184 ){
2185 request_phantoms(&xfer, mxPhantomReq);
 
 
 
2186 }
2187 if( syncFlags & SYNC_PUSH ){
2188 send_unsent(&xfer);
2189 nCardSent += send_unclustered(&xfer);
2190 if( syncFlags & SYNC_PRIVATE ) send_private(&xfer);
 
 
 
2191 }
2192
2193 /* Client sends configuration parameter requests. On a clone, delay sending
2194 ** this until the second cycle since the login card might fail on
2195 ** the first cycle.
@@ -2369,10 +2418,11 @@
2369 nCardSent++;
2370 }
2371 go = 0;
2372 nUvGimmeSent = 0;
2373 nUvFileRcvd = 0;
 
2374 nPriorArtifact = nArtifactRcvd;
2375
2376 /* Process the reply that came back from the server */
2377 while( blob_line(&recv, &xfer.line) ){
2378 if( blob_buffer(&xfer.line)[0]=='#' ){
@@ -2449,11 +2499,14 @@
2449 && blob_is_hname(&xfer.aToken[1])
2450 ){
2451 remote_unk(&xfer.aToken[1]);
2452 if( syncFlags & SYNC_PUSH ){
2453 int rid = rid_from_uuid(&xfer.aToken[1], 0, 0);
2454 if( rid ) send_file(&xfer, rid, &xfer.aToken[1], 0);
 
 
 
2455 }
2456 }else
2457
2458 /* igot HASH ?PRIVATEFLAG?
2459 **
2460
--- src/xfer.c
+++ src/xfer.c
@@ -1041,10 +1041,43 @@
1041 }
1042 db_finalize(&q);
1043 if( cnt==0 ) pXfer->resync = 0;
1044 return cnt;
1045 }
1046
1047 /*
1048 ** Send an igot message for every cluster artifact that is not a phantom,
1049 ** is not shunned, is not private, and that is not in the UNCLUSTERED table.
1050 ** Return the number of cards sent.
1051 */
1052 static int send_all_clusters(Xfer *pXfer){
1053 Stmt q;
1054 int cnt = 0;
1055 const char *zExtra;
1056 if( db_table_exists("temp","onremote") ){
1057 zExtra = " AND NOT EXISTS(SELECT 1 FROM onremote WHERE rid=blob.rid)";
1058 }else{
1059 zExtra = "";
1060 }
1061 db_prepare(&q,
1062 "SELECT uuid"
1063 " FROM tagxref JOIN blob ON tagxref.rid=blob.rid AND tagxref.tagid=%d"
1064 " WHERE NOT EXISTS(SELECT 1 FROM shun WHERE uuid=blob.uuid)"
1065 " AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=blob.rid)"
1066 " AND NOT EXISTS(SELECT 1 FROM unclustered WHERE rid=blob.rid)"
1067 " AND NOT EXISTS(SELECT 1 FROM private WHERE rid=blob.rid)%s",
1068 TAG_CLUSTER, zExtra /*safe-for-%s*/
1069 );
1070 while( db_step(&q)==SQLITE_ROW ){
1071 if( cnt==0 ) blob_appendf(pXfer->pOut, "# sending-clusters\n");
1072 blob_appendf(pXfer->pOut, "igot %s\n", db_column_text(&q, 0));
1073 cnt++;
1074 }
1075 db_finalize(&q);
1076 if( cnt ) blob_appendf(pXfer->pOut, "# end-of-clusters\n");
1077 return cnt;
1078 }
1079
1080 /*
1081 ** Send an igot message for every artifact.
1082 */
1083 static void send_all(Xfer *pXfer){
@@ -1781,10 +1814,19 @@
1814 ** The client sends this message to the server to ask the server
1815 ** to tell it about alternative repositories in the reply.
1816 */
1817 if( blob_eq(&xfer.aToken[1], "req-links") ){
1818 bSendLinks = 1;
1819 }else
1820
1821 /* pragma req-clusters
1822 **
1823 ** This pragma requests that the server send igot cards for every
1824 ** cluster artifact that it knows about.
1825 */
1826 if( blob_eq(&xfer.aToken[1], "req-clusters") ){
1827 send_all_clusters(&xfer);
1828 }
1829
1830 }else
1831
1832 /* Unknown message
@@ -1981,11 +2023,11 @@
2023 int nCardSent = 0; /* Number of cards sent */
2024 int nCardRcvd = 0; /* Number of cards received */
2025 int nCycle = 0; /* Number of round trips to the server */
2026 int size; /* Size of a config value or uvfile */
2027 int origConfigRcvMask; /* Original value of configRcvMask */
2028 int nFileRecv = 0; /* Number of files received */
2029 int mxPhantomReq = 200; /* Max number of phantoms to request per comm */
2030 const char *zCookie; /* Server cookie */
2031 i64 nUncSent, nUncRcvd; /* Bytes sent and received (before compression) */
2032 i64 nSent, nRcvd; /* Bytes sent and received (after compression) */
2033 int cloneSeqno = 1; /* Sequence number for clones */
@@ -2007,10 +2049,11 @@
2049 int uvHashSent = 0; /* The "pragma uv-hash" message has been sent */
2050 int uvDoPush = 0; /* Generate uvfile messages to send to server */
2051 int uvPullOnly = 0; /* 1: pull-only. 2: pull-only warning issued */
2052 int nUvGimmeSent = 0; /* Number of uvgimme cards sent on this cycle */
2053 int nUvFileRcvd = 0; /* Number of uvfile cards received on this cycle */
2054 int nGimmeRcvd = 0; /* Number of gimme cards recevied on the prev cycle */
2055 sqlite3_int64 mtime; /* Modification time on a UV file */
2056 int autopushFailed = 0; /* Autopush following commit failed if true */
2057 const char *zCkinLock; /* Name of check-in to lock. NULL for none */
2058 const char *zClientId; /* A unique identifier for this check-out */
2059 unsigned int mHttpFlags;/* Flags for the http_exchange() subsystem */
@@ -2181,15 +2224,21 @@
2224 */
2225 if( (syncFlags & SYNC_PULL)!=0
2226 || ((syncFlags & SYNC_CLONE)!=0 && cloneSeqno==1)
2227 ){
2228 request_phantoms(&xfer, mxPhantomReq);
2229 if( xfer.nGimmeSent>0 && nCycle==2 && (syncFlags & SYNC_PULL)!=0 ){
2230 blob_appendf(&send, "pragma req-clusters\n");
2231 }
2232 }
2233 if( syncFlags & SYNC_PUSH ){
2234 send_unsent(&xfer);
2235 nCardSent += send_unclustered(&xfer);
2236 if( syncFlags & SYNC_PRIVATE ) send_private(&xfer);
2237 if( nGimmeRcvd>0 && nCycle==2 ){
2238 send_all_clusters(&xfer);
2239 }
2240 }
2241
2242 /* Client sends configuration parameter requests. On a clone, delay sending
2243 ** this until the second cycle since the login card might fail on
2244 ** the first cycle.
@@ -2369,10 +2418,11 @@
2418 nCardSent++;
2419 }
2420 go = 0;
2421 nUvGimmeSent = 0;
2422 nUvFileRcvd = 0;
2423 nGimmeRcvd = 0;
2424 nPriorArtifact = nArtifactRcvd;
2425
2426 /* Process the reply that came back from the server */
2427 while( blob_line(&recv, &xfer.line) ){
2428 if( blob_buffer(&xfer.line)[0]=='#' ){
@@ -2449,11 +2499,14 @@
2499 && blob_is_hname(&xfer.aToken[1])
2500 ){
2501 remote_unk(&xfer.aToken[1]);
2502 if( syncFlags & SYNC_PUSH ){
2503 int rid = rid_from_uuid(&xfer.aToken[1], 0, 0);
2504 if( rid ){
2505 send_file(&xfer, rid, &xfer.aToken[1], 0);
2506 nGimmeRcvd++;
2507 }
2508 }
2509 }else
2510
2511 /* igot HASH ?PRIVATEFLAG?
2512 **
2513
--- test/merge1.test
+++ test/merge1.test
@@ -75,10 +75,12 @@
7575
555 - we think it well and other stuff too - 5555
7676
}
7777
write_file_indented t23 {
7878
<<<<<<< BEGIN MERGE CONFLICT: local copy shown first <<<<<<<<<<<< (line 1)
7979
111 - This is line ONE of the demo program - 1111
80
+ ####### SUGGESTED CONFLICT RESOLUTION follows ###################
81
+ 111 - This is line ONE OF the demo program - 1111
8082
||||||| COMMON ANCESTOR content follows ||||||||||||||||||||||||| (line 1)
8183
111 - This is line one of the demo program - 1111
8284
======= MERGED IN content follows =============================== (line 1)
8385
111 - This is line one OF the demo program - 1111
8486
>>>>>>> END MERGE CONFLICT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
@@ -88,10 +90,12 @@
8890
555 - we think it well and other stuff too - 5555
8991
}
9092
write_file_indented t32 {
9193
<<<<<<< BEGIN MERGE CONFLICT: local copy shown first <<<<<<<<<<<< (line 1)
9294
111 - This is line one OF the demo program - 1111
95
+ ####### SUGGESTED CONFLICT RESOLUTION follows ###################
96
+ 111 - This is line ONE OF the demo program - 1111
9397
||||||| COMMON ANCESTOR content follows ||||||||||||||||||||||||| (line 1)
9498
111 - This is line one of the demo program - 1111
9599
======= MERGED IN content follows =============================== (line 1)
96100
111 - This is line ONE of the demo program - 1111
97101
>>>>>>> END MERGE CONFLICT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
@@ -159,10 +163,13 @@
159163
444 - If all goes well, we will be pleased - 4444
160164
555 - we think it well and other stuff too - 5555
161165
}
162166
write_file_indented t32 {
163167
<<<<<<< BEGIN MERGE CONFLICT: local copy shown first <<<<<<<<<<<< (line 1)
168
+ ####### SUGGESTED CONFLICT RESOLUTION follows ###################
169
+ 000 - Zero lines added to the beginning of - 0000
170
+ 111 - This is line one of the demo program - 1111
164171
||||||| COMMON ANCESTOR content follows ||||||||||||||||||||||||| (line 1)
165172
111 - This is line one of the demo program - 1111
166173
======= MERGED IN content follows =============================== (line 1)
167174
000 - Zero lines added to the beginning of - 0000
168175
111 - This is line one of the demo program - 1111
@@ -305,10 +312,19 @@
305312
mnop 2
306313
qrst
307314
uvwx
308315
yzAB 2
309316
CDEF 2
317
+ GHIJ 2
318
+ ####### SUGGESTED CONFLICT RESOLUTION follows ###################
319
+ efgh 2
320
+ ijkl 2
321
+ mnop 3
322
+ qrst 3
323
+ uvwx 3
324
+ yzAB 3
325
+ CDEF 2
310326
GHIJ 2
311327
||||||| COMMON ANCESTOR content follows ||||||||||||||||||||||||| (line 2)
312328
efgh
313329
ijkl
314330
mnop
@@ -372,10 +388,19 @@
372388
ijkl 2
373389
mnop
374390
qrst
375391
uvwx
376392
yzAB 2
393
+ CDEF 2
394
+ GHIJ 2
395
+ ####### SUGGESTED CONFLICT RESOLUTION follows ###################
396
+ efgh 2
397
+ ijkl 2
398
+ mnop 3
399
+ qrst 3
400
+ uvwx 3
401
+ yzAB 3
377402
CDEF 2
378403
GHIJ 2
379404
||||||| COMMON ANCESTOR content follows ||||||||||||||||||||||||| (line 2)
380405
efgh
381406
ijkl
382407
--- test/merge1.test
+++ test/merge1.test
@@ -75,10 +75,12 @@
75 555 - we think it well and other stuff too - 5555
76 }
77 write_file_indented t23 {
78 <<<<<<< BEGIN MERGE CONFLICT: local copy shown first <<<<<<<<<<<< (line 1)
79 111 - This is line ONE of the demo program - 1111
 
 
80 ||||||| COMMON ANCESTOR content follows ||||||||||||||||||||||||| (line 1)
81 111 - This is line one of the demo program - 1111
82 ======= MERGED IN content follows =============================== (line 1)
83 111 - This is line one OF the demo program - 1111
84 >>>>>>> END MERGE CONFLICT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
@@ -88,10 +90,12 @@
88 555 - we think it well and other stuff too - 5555
89 }
90 write_file_indented t32 {
91 <<<<<<< BEGIN MERGE CONFLICT: local copy shown first <<<<<<<<<<<< (line 1)
92 111 - This is line one OF the demo program - 1111
 
 
93 ||||||| COMMON ANCESTOR content follows ||||||||||||||||||||||||| (line 1)
94 111 - This is line one of the demo program - 1111
95 ======= MERGED IN content follows =============================== (line 1)
96 111 - This is line ONE of the demo program - 1111
97 >>>>>>> END MERGE CONFLICT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
@@ -159,10 +163,13 @@
159 444 - If all goes well, we will be pleased - 4444
160 555 - we think it well and other stuff too - 5555
161 }
162 write_file_indented t32 {
163 <<<<<<< BEGIN MERGE CONFLICT: local copy shown first <<<<<<<<<<<< (line 1)
 
 
 
164 ||||||| COMMON ANCESTOR content follows ||||||||||||||||||||||||| (line 1)
165 111 - This is line one of the demo program - 1111
166 ======= MERGED IN content follows =============================== (line 1)
167 000 - Zero lines added to the beginning of - 0000
168 111 - This is line one of the demo program - 1111
@@ -305,10 +312,19 @@
305 mnop 2
306 qrst
307 uvwx
308 yzAB 2
309 CDEF 2
 
 
 
 
 
 
 
 
 
310 GHIJ 2
311 ||||||| COMMON ANCESTOR content follows ||||||||||||||||||||||||| (line 2)
312 efgh
313 ijkl
314 mnop
@@ -372,10 +388,19 @@
372 ijkl 2
373 mnop
374 qrst
375 uvwx
376 yzAB 2
 
 
 
 
 
 
 
 
 
377 CDEF 2
378 GHIJ 2
379 ||||||| COMMON ANCESTOR content follows ||||||||||||||||||||||||| (line 2)
380 efgh
381 ijkl
382
--- test/merge1.test
+++ test/merge1.test
@@ -75,10 +75,12 @@
75 555 - we think it well and other stuff too - 5555
76 }
77 write_file_indented t23 {
78 <<<<<<< BEGIN MERGE CONFLICT: local copy shown first <<<<<<<<<<<< (line 1)
79 111 - This is line ONE of the demo program - 1111
80 ####### SUGGESTED CONFLICT RESOLUTION follows ###################
81 111 - This is line ONE OF the demo program - 1111
82 ||||||| COMMON ANCESTOR content follows ||||||||||||||||||||||||| (line 1)
83 111 - This is line one of the demo program - 1111
84 ======= MERGED IN content follows =============================== (line 1)
85 111 - This is line one OF the demo program - 1111
86 >>>>>>> END MERGE CONFLICT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
@@ -88,10 +90,12 @@
90 555 - we think it well and other stuff too - 5555
91 }
92 write_file_indented t32 {
93 <<<<<<< BEGIN MERGE CONFLICT: local copy shown first <<<<<<<<<<<< (line 1)
94 111 - This is line one OF the demo program - 1111
95 ####### SUGGESTED CONFLICT RESOLUTION follows ###################
96 111 - This is line ONE OF the demo program - 1111
97 ||||||| COMMON ANCESTOR content follows ||||||||||||||||||||||||| (line 1)
98 111 - This is line one of the demo program - 1111
99 ======= MERGED IN content follows =============================== (line 1)
100 111 - This is line ONE of the demo program - 1111
101 >>>>>>> END MERGE CONFLICT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
@@ -159,10 +163,13 @@
163 444 - If all goes well, we will be pleased - 4444
164 555 - we think it well and other stuff too - 5555
165 }
166 write_file_indented t32 {
167 <<<<<<< BEGIN MERGE CONFLICT: local copy shown first <<<<<<<<<<<< (line 1)
168 ####### SUGGESTED CONFLICT RESOLUTION follows ###################
169 000 - Zero lines added to the beginning of - 0000
170 111 - This is line one of the demo program - 1111
171 ||||||| COMMON ANCESTOR content follows ||||||||||||||||||||||||| (line 1)
172 111 - This is line one of the demo program - 1111
173 ======= MERGED IN content follows =============================== (line 1)
174 000 - Zero lines added to the beginning of - 0000
175 111 - This is line one of the demo program - 1111
@@ -305,10 +312,19 @@
312 mnop 2
313 qrst
314 uvwx
315 yzAB 2
316 CDEF 2
317 GHIJ 2
318 ####### SUGGESTED CONFLICT RESOLUTION follows ###################
319 efgh 2
320 ijkl 2
321 mnop 3
322 qrst 3
323 uvwx 3
324 yzAB 3
325 CDEF 2
326 GHIJ 2
327 ||||||| COMMON ANCESTOR content follows ||||||||||||||||||||||||| (line 2)
328 efgh
329 ijkl
330 mnop
@@ -372,10 +388,19 @@
388 ijkl 2
389 mnop
390 qrst
391 uvwx
392 yzAB 2
393 CDEF 2
394 GHIJ 2
395 ####### SUGGESTED CONFLICT RESOLUTION follows ###################
396 efgh 2
397 ijkl 2
398 mnop 3
399 qrst 3
400 uvwx 3
401 yzAB 3
402 CDEF 2
403 GHIJ 2
404 ||||||| COMMON ANCESTOR content follows ||||||||||||||||||||||||| (line 2)
405 efgh
406 ijkl
407
+28 -25
--- test/merge3.test
+++ test/merge3.test
@@ -27,10 +27,13 @@
2727
fossil 3-way-merge t1 t2 t3 t4 {*}$fossil_args
2828
set x [read_file t4]
2929
regsub -all \
3030
{<<<<<<< BEGIN MERGE CONFLICT: local copy shown first <+ \(line \d+\)} \
3131
$x {MINE:} x
32
+ regsub -all \
33
+ {####### SUGGESTED CONFLICT RESOLUTION follows #+} \
34
+ $x {BOT:} x
3235
regsub -all \
3336
{\|\|\|\|\|\|\| COMMON ANCESTOR content follows \|+ \(line \d+\)} \
3437
$x {COM:} x
3538
regsub -all \
3639
{======= MERGED IN content follows =+ \(line \d+\)} \
@@ -73,56 +76,56 @@
7376
} {
7477
1 2 3b 4b 5b 6 7 8 9
7578
} {
7679
1 2 3 4 5c 6 7 8 9
7780
} {
78
- 1 2 MINE: 3b 4b 5b COM: 3 4 5 YOURS: 3 4 5c END 6 7 8 9
81
+ 1 2 MINE: 3b 4b 5b BOT: 3b 4b 5c COM: 3 4 5 YOURS: 3 4 5c END 6 7 8 9
7982
} -expectError
8083
merge-test 4 {
8184
1 2 3 4 5 6 7 8 9
8285
} {
8386
1 2 3b 4b 5b 6b 7 8 9
8487
} {
8588
1 2 3 4 5c 6 7 8 9
8689
} {
87
- 1 2 MINE: 3b 4b 5b 6b COM: 3 4 5 6 YOURS: 3 4 5c 6 END 7 8 9
90
+ 1 2 MINE: 3b 4b 5b 6b BOT: 3b 4b 5b 5c 6 COM: 3 4 5 6 YOURS: 3 4 5c 6 END 7 8 9
8891
} -expectError
8992
merge-test 5 {
9093
1 2 3 4 5 6 7 8 9
9194
} {
9295
1 2 3b 4b 5b 6b 7 8 9
9396
} {
9497
1 2 3 4 5c 6c 7c 8 9
9598
} {
96
- 1 2 MINE: 3b 4b 5b 6b 7 COM: 3 4 5 6 7 YOURS: 3 4 5c 6c 7c END 8 9
99
+ 1 2 MINE: 3b 4b 5b 6b 7 BOT: 3b 4b 5b 5c 6c 7c COM: 3 4 5 6 7 YOURS: 3 4 5c 6c 7c END 8 9
97100
} -expectError
98101
merge-test 6 {
99102
1 2 3 4 5 6 7 8 9
100103
} {
101104
1 2 3b 4b 5b 6b 7 8b 9
102105
} {
103106
1 2 3 4 5c 6c 7c 8 9
104107
} {
105
- 1 2 MINE: 3b 4b 5b 6b 7 COM: 3 4 5 6 7 YOURS: 3 4 5c 6c 7c END 8b 9
108
+ 1 2 MINE: 3b 4b 5b 6b 7 BOT: 3b 4b 5b 5c 6c 7c COM: 3 4 5 6 7 YOURS: 3 4 5c 6c 7c END 8b 9
106109
} -expectError
107110
merge-test 7 {
108111
1 2 3 4 5 6 7 8 9
109112
} {
110113
1 2 3b 4b 5b 6b 7 8b 9
111114
} {
112115
1 2 3 4 5c 6c 7c 8c 9
113116
} {
114
- 1 2 MINE: 3b 4b 5b 6b 7 8b COM: 3 4 5 6 7 8 YOURS: 3 4 5c 6c 7c 8c END 9
117
+ 1 2 MINE: 3b 4b 5b 6b 7 8b BOT: 3b 4b 5b 5c 6c 7c 8c COM: 3 4 5 6 7 8 YOURS: 3 4 5c 6c 7c 8c END 9
115118
} -expectError
116119
merge-test 8 {
117120
1 2 3 4 5 6 7 8 9
118121
} {
119122
1 2 3b 4b 5b 6b 7 8b 9b
120123
} {
121124
1 2 3 4 5c 6c 7c 8c 9
122125
} {
123
- 1 2 MINE: 3b 4b 5b 6b 7 8b 9b COM: 3 4 5 6 7 8 9 YOURS: 3 4 5c 6c 7c 8c 9 END
126
+ 1 2 MINE: 3b 4b 5b 6b 7 8b 9b BOT: 3b 4b 5b 5c 6c 7c 8c 9b COM: 3 4 5 6 7 8 9 YOURS: 3 4 5c 6c 7c 8c 9 END
124127
} -expectError
125128
merge-test 9 {
126129
1 2 3 4 5 6 7 8 9
127130
} {
128131
1 2 3b 4b 5 6 7 8b 9b
@@ -146,11 +149,11 @@
146149
} {
147150
1 2 3b 4b 5 6 7 8b 9b
148151
} {
149152
1 2 3b 4c 5 6c 7c 8 9
150153
} {
151
- 1 2 MINE: 3b 4b COM: 3 4 YOURS: 3b 4c END 5 6c 7c 8b 9b
154
+ 1 2 MINE: 3b 4b BOT: 3b 4c COM: 3 4 YOURS: 3b 4c END 5 6c 7c 8b 9b
152155
} -expectError
153156
merge-test 12 {
154157
1 2 3 4 5 6 7 8 9
155158
} {
156159
1 2 3b4b 5 6 7 8b 9b
@@ -201,20 +204,20 @@
201204
} {
202205
1 6 7 8 9
203206
} {
204207
1 2 3 4 9
205208
} {
206
- 1 MINE: 6 7 8 COM: 2 3 4 5 6 7 8 YOURS: 2 3 4 END 9
209
+ 1 MINE: 6 7 8 BOT: 2 3 4 COM: 2 3 4 5 6 7 8 YOURS: 2 3 4 END 9
207210
} -expectError
208211
merge-test 25 {
209212
1 2 3 4 5 6 7 8 9
210213
} {
211214
1 7 8 9
212215
} {
213216
1 2 3 9
214217
} {
215
- 1 MINE: 7 8 COM: 2 3 4 5 6 7 8 YOURS: 2 3 END 9
218
+ 1 MINE: 7 8 BOT: 2 3 COM: 2 3 4 5 6 7 8 YOURS: 2 3 END 9
216219
} -expectError
217220
218221
merge-test 30 {
219222
1 2 3 4 5 6 7 8 9
220223
} {
@@ -256,20 +259,20 @@
256259
} {
257260
1 2 3 4 9
258261
} {
259262
1 6 7 8 9
260263
} {
261
- 1 MINE: 2 3 4 COM: 2 3 4 5 6 7 8 YOURS: 6 7 8 END 9
264
+ 1 MINE: 2 3 4 BOT: 6 7 8 COM: 2 3 4 5 6 7 8 YOURS: 6 7 8 END 9
262265
} -expectError
263266
merge-test 35 {
264267
1 2 3 4 5 6 7 8 9
265268
} {
266269
1 2 3 9
267270
} {
268271
1 7 8 9
269272
} {
270
- 1 MINE: 2 3 COM: 2 3 4 5 6 7 8 YOURS: 7 8 END 9
273
+ 1 MINE: 2 3 BOT: 7 8 COM: 2 3 4 5 6 7 8 YOURS: 7 8 END 9
271274
} -expectError
272275
273276
merge-test 40 {
274277
2 3 4 5 6 7 8
275278
} {
@@ -311,20 +314,20 @@
311314
} {
312315
6 7 8
313316
} {
314317
2 3 4
315318
} {
316
- MINE: 6 7 8 COM: 2 3 4 5 6 7 8 YOURS: 2 3 4 END
319
+ MINE: 6 7 8 BOT: 2 3 4 COM: 2 3 4 5 6 7 8 YOURS: 2 3 4 END
317320
} -expectError
318321
merge-test 45 {
319322
2 3 4 5 6 7 8
320323
} {
321324
7 8
322325
} {
323326
2 3
324327
} {
325
- MINE: 7 8 COM: 2 3 4 5 6 7 8 YOURS: 2 3 END
328
+ MINE: 7 8 BOT: 2 3 COM: 2 3 4 5 6 7 8 YOURS: 2 3 END
326329
} -expectError
327330
328331
merge-test 50 {
329332
2 3 4 5 6 7 8
330333
} {
@@ -365,20 +368,20 @@
365368
} {
366369
2 3 4
367370
} {
368371
6 7 8
369372
} {
370
- MINE: 2 3 4 COM: 2 3 4 5 6 7 8 YOURS: 6 7 8 END
373
+ MINE: 2 3 4 BOT: 6 7 8 COM: 2 3 4 5 6 7 8 YOURS: 6 7 8 END
371374
} -expectError
372375
merge-test 55 {
373376
2 3 4 5 6 7 8
374377
} {
375378
2 3
376379
} {
377380
7 8
378381
} {
379
- MINE: 2 3 COM: 2 3 4 5 6 7 8 YOURS: 7 8 END
382
+ MINE: 2 3 BOT: 7 8 COM: 2 3 4 5 6 7 8 YOURS: 7 8 END
380383
} -expectError
381384
382385
merge-test 60 {
383386
1 2 3 4 5 6 7 8 9
384387
} {
@@ -420,20 +423,20 @@
420423
} {
421424
1 2b 3b 4b 5b 6 7 8 9
422425
} {
423426
1 2 3 4 9
424427
} {
425
- 1 MINE: 2b 3b 4b 5b 6 7 8 COM: 2 3 4 5 6 7 8 YOURS: 2 3 4 END 9
428
+ 1 MINE: 2b 3b 4b 5b 6 7 8 BOT: 2b 3b 4b 4 COM: 2 3 4 5 6 7 8 YOURS: 2 3 4 END 9
426429
} -expectError
427430
merge-test 65 {
428431
1 2 3 4 5 6 7 8 9
429432
} {
430433
1 2b 3b 4b 5b 6b 7 8 9
431434
} {
432435
1 2 3 9
433436
} {
434
- 1 MINE: 2b 3b 4b 5b 6b 7 8 COM: 2 3 4 5 6 7 8 YOURS: 2 3 END 9
437
+ 1 MINE: 2b 3b 4b 5b 6b 7 8 BOT: 2 3 COM: 2 3 4 5 6 7 8 YOURS: 2 3 END 9
435438
} -expectError
436439
437440
merge-test 70 {
438441
1 2 3 4 5 6 7 8 9
439442
} {
@@ -475,20 +478,20 @@
475478
} {
476479
1 2 3 4 9
477480
} {
478481
1 2b 3b 4b 5b 6 7 8 9
479482
} {
480
- 1 MINE: 2 3 4 COM: 2 3 4 5 6 7 8 YOURS: 2b 3b 4b 5b 6 7 8 END 9
483
+ 1 MINE: 2 3 4 BOT: 2b 3b 4b 5b 6 7 8 COM: 2 3 4 5 6 7 8 YOURS: 2b 3b 4b 5b 6 7 8 END 9
481484
} -expectError
482485
merge-test 75 {
483486
1 2 3 4 5 6 7 8 9
484487
} {
485488
1 2 3 9
486489
} {
487490
1 2b 3b 4b 5b 6b 7 8 9
488491
} {
489
- 1 MINE: 2 3 COM: 2 3 4 5 6 7 8 YOURS: 2b 3b 4b 5b 6b 7 8 END 9
492
+ 1 MINE: 2 3 BOT: 2b 3b 4b 5b 6b 7 8 COM: 2 3 4 5 6 7 8 YOURS: 2b 3b 4b 5b 6b 7 8 END 9
490493
} -expectError
491494
492495
merge-test 80 {
493496
2 3 4 5 6 7 8
494497
} {
@@ -530,20 +533,20 @@
530533
} {
531534
2b 3b 4b 5b 6 7 8
532535
} {
533536
2 3 4
534537
} {
535
- MINE: 2b 3b 4b 5b 6 7 8 COM: 2 3 4 5 6 7 8 YOURS: 2 3 4 END
538
+ MINE: 2b 3b 4b 5b 6 7 8 BOT: 2b 3b 4b 4 COM: 2 3 4 5 6 7 8 YOURS: 2 3 4 END
536539
} -expectError
537540
merge-test 85 {
538541
2 3 4 5 6 7 8
539542
} {
540543
2b 3b 4b 5b 6b 7 8
541544
} {
542545
2 3
543546
} {
544
- MINE: 2b 3b 4b 5b 6b 7 8 COM: 2 3 4 5 6 7 8 YOURS: 2 3 END
547
+ MINE: 2b 3b 4b 5b 6b 7 8 BOT: 2 3 COM: 2 3 4 5 6 7 8 YOURS: 2 3 END
545548
} -expectError
546549
547550
merge-test 90 {
548551
2 3 4 5 6 7 8
549552
} {
@@ -585,20 +588,20 @@
585588
} {
586589
2 3 4
587590
} {
588591
2b 3b 4b 5b 6 7 8
589592
} {
590
- MINE: 2 3 4 COM: 2 3 4 5 6 7 8 YOURS: 2b 3b 4b 5b 6 7 8 END
593
+ MINE: 2 3 4 BOT: 2b 3b 4b 5b 6 7 8 COM: 2 3 4 5 6 7 8 YOURS: 2b 3b 4b 5b 6 7 8 END
591594
} -expectError
592595
merge-test 95 {
593596
2 3 4 5 6 7 8
594597
} {
595598
2 3
596599
} {
597600
2b 3b 4b 5b 6b 7 8
598601
} {
599
- MINE: 2 3 COM: 2 3 4 5 6 7 8 YOURS: 2b 3b 4b 5b 6b 7 8 END
602
+ MINE: 2 3 BOT: 2b 3b 4b 5b 6b 7 8 COM: 2 3 4 5 6 7 8 YOURS: 2b 3b 4b 5b 6b 7 8 END
600603
} -expectError
601604
602605
merge-test 100 {
603606
1 2 3 4 5 6 7 8 9
604607
} {
@@ -631,20 +634,20 @@
631634
} {
632635
1 2 3 4 5 7 8 9b
633636
} {
634637
1 2 3 4 5 7 8 9b a b c d e
635638
} {
636
- 1 2 3 4 5 7 8 MINE: 9b COM: 9 YOURS: 9b a b c d e END
639
+ 1 2 3 4 5 7 8 MINE: 9b BOT: 9b a b c d e COM: 9 YOURS: 9b a b c d e END
637640
} -expectError
638641
merge-test 104 {
639642
1 2 3 4 5 6 7 8 9
640643
} {
641644
1 2 3 4 5 7 8 9b a b c d e
642645
} {
643646
1 2 3 4 5 7 8 9b
644647
} {
645
- 1 2 3 4 5 7 8 MINE: 9b a b c d e COM: 9 YOURS: 9b END
648
+ 1 2 3 4 5 7 8 MINE: 9b a b c d e BOT: 9b COM: 9 YOURS: 9b END
646649
} -expectError
647650
648651
###############################################################################
649652
650653
test_cleanup
651654
--- test/merge3.test
+++ test/merge3.test
@@ -27,10 +27,13 @@
27 fossil 3-way-merge t1 t2 t3 t4 {*}$fossil_args
28 set x [read_file t4]
29 regsub -all \
30 {<<<<<<< BEGIN MERGE CONFLICT: local copy shown first <+ \(line \d+\)} \
31 $x {MINE:} x
 
 
 
32 regsub -all \
33 {\|\|\|\|\|\|\| COMMON ANCESTOR content follows \|+ \(line \d+\)} \
34 $x {COM:} x
35 regsub -all \
36 {======= MERGED IN content follows =+ \(line \d+\)} \
@@ -73,56 +76,56 @@
73 } {
74 1 2 3b 4b 5b 6 7 8 9
75 } {
76 1 2 3 4 5c 6 7 8 9
77 } {
78 1 2 MINE: 3b 4b 5b COM: 3 4 5 YOURS: 3 4 5c END 6 7 8 9
79 } -expectError
80 merge-test 4 {
81 1 2 3 4 5 6 7 8 9
82 } {
83 1 2 3b 4b 5b 6b 7 8 9
84 } {
85 1 2 3 4 5c 6 7 8 9
86 } {
87 1 2 MINE: 3b 4b 5b 6b COM: 3 4 5 6 YOURS: 3 4 5c 6 END 7 8 9
88 } -expectError
89 merge-test 5 {
90 1 2 3 4 5 6 7 8 9
91 } {
92 1 2 3b 4b 5b 6b 7 8 9
93 } {
94 1 2 3 4 5c 6c 7c 8 9
95 } {
96 1 2 MINE: 3b 4b 5b 6b 7 COM: 3 4 5 6 7 YOURS: 3 4 5c 6c 7c END 8 9
97 } -expectError
98 merge-test 6 {
99 1 2 3 4 5 6 7 8 9
100 } {
101 1 2 3b 4b 5b 6b 7 8b 9
102 } {
103 1 2 3 4 5c 6c 7c 8 9
104 } {
105 1 2 MINE: 3b 4b 5b 6b 7 COM: 3 4 5 6 7 YOURS: 3 4 5c 6c 7c END 8b 9
106 } -expectError
107 merge-test 7 {
108 1 2 3 4 5 6 7 8 9
109 } {
110 1 2 3b 4b 5b 6b 7 8b 9
111 } {
112 1 2 3 4 5c 6c 7c 8c 9
113 } {
114 1 2 MINE: 3b 4b 5b 6b 7 8b COM: 3 4 5 6 7 8 YOURS: 3 4 5c 6c 7c 8c END 9
115 } -expectError
116 merge-test 8 {
117 1 2 3 4 5 6 7 8 9
118 } {
119 1 2 3b 4b 5b 6b 7 8b 9b
120 } {
121 1 2 3 4 5c 6c 7c 8c 9
122 } {
123 1 2 MINE: 3b 4b 5b 6b 7 8b 9b COM: 3 4 5 6 7 8 9 YOURS: 3 4 5c 6c 7c 8c 9 END
124 } -expectError
125 merge-test 9 {
126 1 2 3 4 5 6 7 8 9
127 } {
128 1 2 3b 4b 5 6 7 8b 9b
@@ -146,11 +149,11 @@
146 } {
147 1 2 3b 4b 5 6 7 8b 9b
148 } {
149 1 2 3b 4c 5 6c 7c 8 9
150 } {
151 1 2 MINE: 3b 4b COM: 3 4 YOURS: 3b 4c END 5 6c 7c 8b 9b
152 } -expectError
153 merge-test 12 {
154 1 2 3 4 5 6 7 8 9
155 } {
156 1 2 3b4b 5 6 7 8b 9b
@@ -201,20 +204,20 @@
201 } {
202 1 6 7 8 9
203 } {
204 1 2 3 4 9
205 } {
206 1 MINE: 6 7 8 COM: 2 3 4 5 6 7 8 YOURS: 2 3 4 END 9
207 } -expectError
208 merge-test 25 {
209 1 2 3 4 5 6 7 8 9
210 } {
211 1 7 8 9
212 } {
213 1 2 3 9
214 } {
215 1 MINE: 7 8 COM: 2 3 4 5 6 7 8 YOURS: 2 3 END 9
216 } -expectError
217
218 merge-test 30 {
219 1 2 3 4 5 6 7 8 9
220 } {
@@ -256,20 +259,20 @@
256 } {
257 1 2 3 4 9
258 } {
259 1 6 7 8 9
260 } {
261 1 MINE: 2 3 4 COM: 2 3 4 5 6 7 8 YOURS: 6 7 8 END 9
262 } -expectError
263 merge-test 35 {
264 1 2 3 4 5 6 7 8 9
265 } {
266 1 2 3 9
267 } {
268 1 7 8 9
269 } {
270 1 MINE: 2 3 COM: 2 3 4 5 6 7 8 YOURS: 7 8 END 9
271 } -expectError
272
273 merge-test 40 {
274 2 3 4 5 6 7 8
275 } {
@@ -311,20 +314,20 @@
311 } {
312 6 7 8
313 } {
314 2 3 4
315 } {
316 MINE: 6 7 8 COM: 2 3 4 5 6 7 8 YOURS: 2 3 4 END
317 } -expectError
318 merge-test 45 {
319 2 3 4 5 6 7 8
320 } {
321 7 8
322 } {
323 2 3
324 } {
325 MINE: 7 8 COM: 2 3 4 5 6 7 8 YOURS: 2 3 END
326 } -expectError
327
328 merge-test 50 {
329 2 3 4 5 6 7 8
330 } {
@@ -365,20 +368,20 @@
365 } {
366 2 3 4
367 } {
368 6 7 8
369 } {
370 MINE: 2 3 4 COM: 2 3 4 5 6 7 8 YOURS: 6 7 8 END
371 } -expectError
372 merge-test 55 {
373 2 3 4 5 6 7 8
374 } {
375 2 3
376 } {
377 7 8
378 } {
379 MINE: 2 3 COM: 2 3 4 5 6 7 8 YOURS: 7 8 END
380 } -expectError
381
382 merge-test 60 {
383 1 2 3 4 5 6 7 8 9
384 } {
@@ -420,20 +423,20 @@
420 } {
421 1 2b 3b 4b 5b 6 7 8 9
422 } {
423 1 2 3 4 9
424 } {
425 1 MINE: 2b 3b 4b 5b 6 7 8 COM: 2 3 4 5 6 7 8 YOURS: 2 3 4 END 9
426 } -expectError
427 merge-test 65 {
428 1 2 3 4 5 6 7 8 9
429 } {
430 1 2b 3b 4b 5b 6b 7 8 9
431 } {
432 1 2 3 9
433 } {
434 1 MINE: 2b 3b 4b 5b 6b 7 8 COM: 2 3 4 5 6 7 8 YOURS: 2 3 END 9
435 } -expectError
436
437 merge-test 70 {
438 1 2 3 4 5 6 7 8 9
439 } {
@@ -475,20 +478,20 @@
475 } {
476 1 2 3 4 9
477 } {
478 1 2b 3b 4b 5b 6 7 8 9
479 } {
480 1 MINE: 2 3 4 COM: 2 3 4 5 6 7 8 YOURS: 2b 3b 4b 5b 6 7 8 END 9
481 } -expectError
482 merge-test 75 {
483 1 2 3 4 5 6 7 8 9
484 } {
485 1 2 3 9
486 } {
487 1 2b 3b 4b 5b 6b 7 8 9
488 } {
489 1 MINE: 2 3 COM: 2 3 4 5 6 7 8 YOURS: 2b 3b 4b 5b 6b 7 8 END 9
490 } -expectError
491
492 merge-test 80 {
493 2 3 4 5 6 7 8
494 } {
@@ -530,20 +533,20 @@
530 } {
531 2b 3b 4b 5b 6 7 8
532 } {
533 2 3 4
534 } {
535 MINE: 2b 3b 4b 5b 6 7 8 COM: 2 3 4 5 6 7 8 YOURS: 2 3 4 END
536 } -expectError
537 merge-test 85 {
538 2 3 4 5 6 7 8
539 } {
540 2b 3b 4b 5b 6b 7 8
541 } {
542 2 3
543 } {
544 MINE: 2b 3b 4b 5b 6b 7 8 COM: 2 3 4 5 6 7 8 YOURS: 2 3 END
545 } -expectError
546
547 merge-test 90 {
548 2 3 4 5 6 7 8
549 } {
@@ -585,20 +588,20 @@
585 } {
586 2 3 4
587 } {
588 2b 3b 4b 5b 6 7 8
589 } {
590 MINE: 2 3 4 COM: 2 3 4 5 6 7 8 YOURS: 2b 3b 4b 5b 6 7 8 END
591 } -expectError
592 merge-test 95 {
593 2 3 4 5 6 7 8
594 } {
595 2 3
596 } {
597 2b 3b 4b 5b 6b 7 8
598 } {
599 MINE: 2 3 COM: 2 3 4 5 6 7 8 YOURS: 2b 3b 4b 5b 6b 7 8 END
600 } -expectError
601
602 merge-test 100 {
603 1 2 3 4 5 6 7 8 9
604 } {
@@ -631,20 +634,20 @@
631 } {
632 1 2 3 4 5 7 8 9b
633 } {
634 1 2 3 4 5 7 8 9b a b c d e
635 } {
636 1 2 3 4 5 7 8 MINE: 9b COM: 9 YOURS: 9b a b c d e END
637 } -expectError
638 merge-test 104 {
639 1 2 3 4 5 6 7 8 9
640 } {
641 1 2 3 4 5 7 8 9b a b c d e
642 } {
643 1 2 3 4 5 7 8 9b
644 } {
645 1 2 3 4 5 7 8 MINE: 9b a b c d e COM: 9 YOURS: 9b END
646 } -expectError
647
648 ###############################################################################
649
650 test_cleanup
651
--- test/merge3.test
+++ test/merge3.test
@@ -27,10 +27,13 @@
27 fossil 3-way-merge t1 t2 t3 t4 {*}$fossil_args
28 set x [read_file t4]
29 regsub -all \
30 {<<<<<<< BEGIN MERGE CONFLICT: local copy shown first <+ \(line \d+\)} \
31 $x {MINE:} x
32 regsub -all \
33 {####### SUGGESTED CONFLICT RESOLUTION follows #+} \
34 $x {BOT:} x
35 regsub -all \
36 {\|\|\|\|\|\|\| COMMON ANCESTOR content follows \|+ \(line \d+\)} \
37 $x {COM:} x
38 regsub -all \
39 {======= MERGED IN content follows =+ \(line \d+\)} \
@@ -73,56 +76,56 @@
76 } {
77 1 2 3b 4b 5b 6 7 8 9
78 } {
79 1 2 3 4 5c 6 7 8 9
80 } {
81 1 2 MINE: 3b 4b 5b BOT: 3b 4b 5c COM: 3 4 5 YOURS: 3 4 5c END 6 7 8 9
82 } -expectError
83 merge-test 4 {
84 1 2 3 4 5 6 7 8 9
85 } {
86 1 2 3b 4b 5b 6b 7 8 9
87 } {
88 1 2 3 4 5c 6 7 8 9
89 } {
90 1 2 MINE: 3b 4b 5b 6b BOT: 3b 4b 5b 5c 6 COM: 3 4 5 6 YOURS: 3 4 5c 6 END 7 8 9
91 } -expectError
92 merge-test 5 {
93 1 2 3 4 5 6 7 8 9
94 } {
95 1 2 3b 4b 5b 6b 7 8 9
96 } {
97 1 2 3 4 5c 6c 7c 8 9
98 } {
99 1 2 MINE: 3b 4b 5b 6b 7 BOT: 3b 4b 5b 5c 6c 7c COM: 3 4 5 6 7 YOURS: 3 4 5c 6c 7c END 8 9
100 } -expectError
101 merge-test 6 {
102 1 2 3 4 5 6 7 8 9
103 } {
104 1 2 3b 4b 5b 6b 7 8b 9
105 } {
106 1 2 3 4 5c 6c 7c 8 9
107 } {
108 1 2 MINE: 3b 4b 5b 6b 7 BOT: 3b 4b 5b 5c 6c 7c COM: 3 4 5 6 7 YOURS: 3 4 5c 6c 7c END 8b 9
109 } -expectError
110 merge-test 7 {
111 1 2 3 4 5 6 7 8 9
112 } {
113 1 2 3b 4b 5b 6b 7 8b 9
114 } {
115 1 2 3 4 5c 6c 7c 8c 9
116 } {
117 1 2 MINE: 3b 4b 5b 6b 7 8b BOT: 3b 4b 5b 5c 6c 7c 8c COM: 3 4 5 6 7 8 YOURS: 3 4 5c 6c 7c 8c END 9
118 } -expectError
119 merge-test 8 {
120 1 2 3 4 5 6 7 8 9
121 } {
122 1 2 3b 4b 5b 6b 7 8b 9b
123 } {
124 1 2 3 4 5c 6c 7c 8c 9
125 } {
126 1 2 MINE: 3b 4b 5b 6b 7 8b 9b BOT: 3b 4b 5b 5c 6c 7c 8c 9b COM: 3 4 5 6 7 8 9 YOURS: 3 4 5c 6c 7c 8c 9 END
127 } -expectError
128 merge-test 9 {
129 1 2 3 4 5 6 7 8 9
130 } {
131 1 2 3b 4b 5 6 7 8b 9b
@@ -146,11 +149,11 @@
149 } {
150 1 2 3b 4b 5 6 7 8b 9b
151 } {
152 1 2 3b 4c 5 6c 7c 8 9
153 } {
154 1 2 MINE: 3b 4b BOT: 3b 4c COM: 3 4 YOURS: 3b 4c END 5 6c 7c 8b 9b
155 } -expectError
156 merge-test 12 {
157 1 2 3 4 5 6 7 8 9
158 } {
159 1 2 3b4b 5 6 7 8b 9b
@@ -201,20 +204,20 @@
204 } {
205 1 6 7 8 9
206 } {
207 1 2 3 4 9
208 } {
209 1 MINE: 6 7 8 BOT: 2 3 4 COM: 2 3 4 5 6 7 8 YOURS: 2 3 4 END 9
210 } -expectError
211 merge-test 25 {
212 1 2 3 4 5 6 7 8 9
213 } {
214 1 7 8 9
215 } {
216 1 2 3 9
217 } {
218 1 MINE: 7 8 BOT: 2 3 COM: 2 3 4 5 6 7 8 YOURS: 2 3 END 9
219 } -expectError
220
221 merge-test 30 {
222 1 2 3 4 5 6 7 8 9
223 } {
@@ -256,20 +259,20 @@
259 } {
260 1 2 3 4 9
261 } {
262 1 6 7 8 9
263 } {
264 1 MINE: 2 3 4 BOT: 6 7 8 COM: 2 3 4 5 6 7 8 YOURS: 6 7 8 END 9
265 } -expectError
266 merge-test 35 {
267 1 2 3 4 5 6 7 8 9
268 } {
269 1 2 3 9
270 } {
271 1 7 8 9
272 } {
273 1 MINE: 2 3 BOT: 7 8 COM: 2 3 4 5 6 7 8 YOURS: 7 8 END 9
274 } -expectError
275
276 merge-test 40 {
277 2 3 4 5 6 7 8
278 } {
@@ -311,20 +314,20 @@
314 } {
315 6 7 8
316 } {
317 2 3 4
318 } {
319 MINE: 6 7 8 BOT: 2 3 4 COM: 2 3 4 5 6 7 8 YOURS: 2 3 4 END
320 } -expectError
321 merge-test 45 {
322 2 3 4 5 6 7 8
323 } {
324 7 8
325 } {
326 2 3
327 } {
328 MINE: 7 8 BOT: 2 3 COM: 2 3 4 5 6 7 8 YOURS: 2 3 END
329 } -expectError
330
331 merge-test 50 {
332 2 3 4 5 6 7 8
333 } {
@@ -365,20 +368,20 @@
368 } {
369 2 3 4
370 } {
371 6 7 8
372 } {
373 MINE: 2 3 4 BOT: 6 7 8 COM: 2 3 4 5 6 7 8 YOURS: 6 7 8 END
374 } -expectError
375 merge-test 55 {
376 2 3 4 5 6 7 8
377 } {
378 2 3
379 } {
380 7 8
381 } {
382 MINE: 2 3 BOT: 7 8 COM: 2 3 4 5 6 7 8 YOURS: 7 8 END
383 } -expectError
384
385 merge-test 60 {
386 1 2 3 4 5 6 7 8 9
387 } {
@@ -420,20 +423,20 @@
423 } {
424 1 2b 3b 4b 5b 6 7 8 9
425 } {
426 1 2 3 4 9
427 } {
428 1 MINE: 2b 3b 4b 5b 6 7 8 BOT: 2b 3b 4b 4 COM: 2 3 4 5 6 7 8 YOURS: 2 3 4 END 9
429 } -expectError
430 merge-test 65 {
431 1 2 3 4 5 6 7 8 9
432 } {
433 1 2b 3b 4b 5b 6b 7 8 9
434 } {
435 1 2 3 9
436 } {
437 1 MINE: 2b 3b 4b 5b 6b 7 8 BOT: 2 3 COM: 2 3 4 5 6 7 8 YOURS: 2 3 END 9
438 } -expectError
439
440 merge-test 70 {
441 1 2 3 4 5 6 7 8 9
442 } {
@@ -475,20 +478,20 @@
478 } {
479 1 2 3 4 9
480 } {
481 1 2b 3b 4b 5b 6 7 8 9
482 } {
483 1 MINE: 2 3 4 BOT: 2b 3b 4b 5b 6 7 8 COM: 2 3 4 5 6 7 8 YOURS: 2b 3b 4b 5b 6 7 8 END 9
484 } -expectError
485 merge-test 75 {
486 1 2 3 4 5 6 7 8 9
487 } {
488 1 2 3 9
489 } {
490 1 2b 3b 4b 5b 6b 7 8 9
491 } {
492 1 MINE: 2 3 BOT: 2b 3b 4b 5b 6b 7 8 COM: 2 3 4 5 6 7 8 YOURS: 2b 3b 4b 5b 6b 7 8 END 9
493 } -expectError
494
495 merge-test 80 {
496 2 3 4 5 6 7 8
497 } {
@@ -530,20 +533,20 @@
533 } {
534 2b 3b 4b 5b 6 7 8
535 } {
536 2 3 4
537 } {
538 MINE: 2b 3b 4b 5b 6 7 8 BOT: 2b 3b 4b 4 COM: 2 3 4 5 6 7 8 YOURS: 2 3 4 END
539 } -expectError
540 merge-test 85 {
541 2 3 4 5 6 7 8
542 } {
543 2b 3b 4b 5b 6b 7 8
544 } {
545 2 3
546 } {
547 MINE: 2b 3b 4b 5b 6b 7 8 BOT: 2 3 COM: 2 3 4 5 6 7 8 YOURS: 2 3 END
548 } -expectError
549
550 merge-test 90 {
551 2 3 4 5 6 7 8
552 } {
@@ -585,20 +588,20 @@
588 } {
589 2 3 4
590 } {
591 2b 3b 4b 5b 6 7 8
592 } {
593 MINE: 2 3 4 BOT: 2b 3b 4b 5b 6 7 8 COM: 2 3 4 5 6 7 8 YOURS: 2b 3b 4b 5b 6 7 8 END
594 } -expectError
595 merge-test 95 {
596 2 3 4 5 6 7 8
597 } {
598 2 3
599 } {
600 2b 3b 4b 5b 6b 7 8
601 } {
602 MINE: 2 3 BOT: 2b 3b 4b 5b 6b 7 8 COM: 2 3 4 5 6 7 8 YOURS: 2b 3b 4b 5b 6b 7 8 END
603 } -expectError
604
605 merge-test 100 {
606 1 2 3 4 5 6 7 8 9
607 } {
@@ -631,20 +634,20 @@
634 } {
635 1 2 3 4 5 7 8 9b
636 } {
637 1 2 3 4 5 7 8 9b a b c d e
638 } {
639 1 2 3 4 5 7 8 MINE: 9b BOT: 9b a b c d e COM: 9 YOURS: 9b a b c d e END
640 } -expectError
641 merge-test 104 {
642 1 2 3 4 5 6 7 8 9
643 } {
644 1 2 3 4 5 7 8 9b a b c d e
645 } {
646 1 2 3 4 5 7 8 9b
647 } {
648 1 2 3 4 5 7 8 MINE: 9b a b c d e BOT: 9b COM: 9 YOURS: 9b END
649 } -expectError
650
651 ###############################################################################
652
653 test_cleanup
654
--- test/merge4.test
+++ test/merge4.test
@@ -26,15 +26,17 @@
2626
write_file t3 [join [string trim $v2] \n]\n
2727
fossil 3-way-merge t1 t2 t3 t4 {*}$fossil_args
2828
fossil 3-way-merge t1 t3 t2 t5 {*}$fossil_args
2929
set x [read_file t4]
3030
regsub -all {<<<<<<< BEGIN MERGE CONFLICT.*<< \(line \d+\)} $x {>} x
31
+ regsub -all {####### SUGGESTED CONFLICT RESOLUTION.*##} $x {#} x
3132
regsub -all {\|\|\|\|\|\|\|.*======= \(line \d+\)} $x {=} x
3233
regsub -all {>>>>>>> END MERGE CONFLICT.*>>>>} $x {<} x
3334
set x [split [string trim $x] \n]
3435
set y [read_file t5]
3536
regsub -all {<<<<<<< BEGIN MERGE CONFLICT.*<< \(line \d+\)} $y {>} y
37
+ regsub -all {####### SUGGESTED CONFLICT RESOLUTION.*##} $y {#} y
3638
regsub -all {\|\|\|\|\|\|\|.*======= \(line \d+\)} $y {=} y
3739
regsub -all {>>>>>>> END MERGE CONFLICT.*>>>>} $y {<} y
3840
set y [split [string trim $y] \n]
3941
set result1 [string trim $result1]
4042
if {$x!=$result1} {
@@ -58,13 +60,13 @@
5860
} {
5961
1 2b 3b 4b 5 6b 7b 8b 9
6062
} {
6163
1 2 3 4c 5c 6c 7 8 9
6264
} {
63
- 1 > 2b 3b 4b 5 6b 7b 8b = 2 3 4c 5c 6c 7 8 < 9
65
+ 1 > 2b 3b 4b 5 6b 7b 8b # 2b 3b 4c 5c 6c 7b 8b = 2 3 4c 5c 6c 7 8 < 9
6466
} {
65
- 1 > 2 3 4c 5c 6c 7 8 = 2b 3b 4b 5 6b 7b 8b < 9
67
+ 1 > 2 3 4c 5c 6c 7 8 # 2b 3b 4b 5c 6b 7b 8b = 2b 3b 4b 5 6b 7b 8b < 9
6668
} -expectError
6769
merge-test 1001 {
6870
1 2 3 4 5 6 7 8 9
6971
} {
7072
1 2b 3b 4 5 6 7b 8b 9
@@ -80,13 +82,13 @@
8082
} {
8183
2b 3b 4b 5 6b 7b 8b
8284
} {
8385
2 3 4c 5c 6c 7 8
8486
} {
85
- > 2b 3b 4b 5 6b 7b 8b = 2 3 4c 5c 6c 7 8 <
87
+ > 2b 3b 4b 5 6b 7b 8b # 2b 3b 4c 5c 6c 7b 8b = 2 3 4c 5c 6c 7 8 <
8688
} {
87
- > 2 3 4c 5c 6c 7 8 = 2b 3b 4b 5 6b 7b 8b <
89
+ > 2 3 4c 5c 6c 7 8 # 2b 3b 4b 5c 6b 7b 8b = 2b 3b 4b 5 6b 7b 8b <
8890
} -expectError
8991
merge-test 1003 {
9092
2 3 4 5 6 7 8
9193
} {
9294
2b 3b 4 5 6 7b 8b
9395
--- test/merge4.test
+++ test/merge4.test
@@ -26,15 +26,17 @@
26 write_file t3 [join [string trim $v2] \n]\n
27 fossil 3-way-merge t1 t2 t3 t4 {*}$fossil_args
28 fossil 3-way-merge t1 t3 t2 t5 {*}$fossil_args
29 set x [read_file t4]
30 regsub -all {<<<<<<< BEGIN MERGE CONFLICT.*<< \(line \d+\)} $x {>} x
 
31 regsub -all {\|\|\|\|\|\|\|.*======= \(line \d+\)} $x {=} x
32 regsub -all {>>>>>>> END MERGE CONFLICT.*>>>>} $x {<} x
33 set x [split [string trim $x] \n]
34 set y [read_file t5]
35 regsub -all {<<<<<<< BEGIN MERGE CONFLICT.*<< \(line \d+\)} $y {>} y
 
36 regsub -all {\|\|\|\|\|\|\|.*======= \(line \d+\)} $y {=} y
37 regsub -all {>>>>>>> END MERGE CONFLICT.*>>>>} $y {<} y
38 set y [split [string trim $y] \n]
39 set result1 [string trim $result1]
40 if {$x!=$result1} {
@@ -58,13 +60,13 @@
58 } {
59 1 2b 3b 4b 5 6b 7b 8b 9
60 } {
61 1 2 3 4c 5c 6c 7 8 9
62 } {
63 1 > 2b 3b 4b 5 6b 7b 8b = 2 3 4c 5c 6c 7 8 < 9
64 } {
65 1 > 2 3 4c 5c 6c 7 8 = 2b 3b 4b 5 6b 7b 8b < 9
66 } -expectError
67 merge-test 1001 {
68 1 2 3 4 5 6 7 8 9
69 } {
70 1 2b 3b 4 5 6 7b 8b 9
@@ -80,13 +82,13 @@
80 } {
81 2b 3b 4b 5 6b 7b 8b
82 } {
83 2 3 4c 5c 6c 7 8
84 } {
85 > 2b 3b 4b 5 6b 7b 8b = 2 3 4c 5c 6c 7 8 <
86 } {
87 > 2 3 4c 5c 6c 7 8 = 2b 3b 4b 5 6b 7b 8b <
88 } -expectError
89 merge-test 1003 {
90 2 3 4 5 6 7 8
91 } {
92 2b 3b 4 5 6 7b 8b
93
--- test/merge4.test
+++ test/merge4.test
@@ -26,15 +26,17 @@
26 write_file t3 [join [string trim $v2] \n]\n
27 fossil 3-way-merge t1 t2 t3 t4 {*}$fossil_args
28 fossil 3-way-merge t1 t3 t2 t5 {*}$fossil_args
29 set x [read_file t4]
30 regsub -all {<<<<<<< BEGIN MERGE CONFLICT.*<< \(line \d+\)} $x {>} x
31 regsub -all {####### SUGGESTED CONFLICT RESOLUTION.*##} $x {#} x
32 regsub -all {\|\|\|\|\|\|\|.*======= \(line \d+\)} $x {=} x
33 regsub -all {>>>>>>> END MERGE CONFLICT.*>>>>} $x {<} x
34 set x [split [string trim $x] \n]
35 set y [read_file t5]
36 regsub -all {<<<<<<< BEGIN MERGE CONFLICT.*<< \(line \d+\)} $y {>} y
37 regsub -all {####### SUGGESTED CONFLICT RESOLUTION.*##} $y {#} y
38 regsub -all {\|\|\|\|\|\|\|.*======= \(line \d+\)} $y {=} y
39 regsub -all {>>>>>>> END MERGE CONFLICT.*>>>>} $y {<} y
40 set y [split [string trim $y] \n]
41 set result1 [string trim $result1]
42 if {$x!=$result1} {
@@ -58,13 +60,13 @@
60 } {
61 1 2b 3b 4b 5 6b 7b 8b 9
62 } {
63 1 2 3 4c 5c 6c 7 8 9
64 } {
65 1 > 2b 3b 4b 5 6b 7b 8b # 2b 3b 4c 5c 6c 7b 8b = 2 3 4c 5c 6c 7 8 < 9
66 } {
67 1 > 2 3 4c 5c 6c 7 8 # 2b 3b 4b 5c 6b 7b 8b = 2b 3b 4b 5 6b 7b 8b < 9
68 } -expectError
69 merge-test 1001 {
70 1 2 3 4 5 6 7 8 9
71 } {
72 1 2b 3b 4 5 6 7b 8b 9
@@ -80,13 +82,13 @@
82 } {
83 2b 3b 4b 5 6b 7b 8b
84 } {
85 2 3 4c 5c 6c 7 8
86 } {
87 > 2b 3b 4b 5 6b 7b 8b # 2b 3b 4c 5c 6c 7b 8b = 2 3 4c 5c 6c 7 8 <
88 } {
89 > 2 3 4c 5c 6c 7 8 # 2b 3b 4b 5c 6b 7b 8b = 2b 3b 4b 5 6b 7b 8b <
90 } -expectError
91 merge-test 1003 {
92 2 3 4 5 6 7 8
93 } {
94 2b 3b 4 5 6 7b 8b
95
--- test/tester.tcl
+++ test/tester.tcl
@@ -332,10 +332,11 @@
332332
encoding-glob \
333333
exec-rel-paths \
334334
fileedit-glob \
335335
forbid-delta-manifests \
336336
forum-close-policy \
337
+ forum-title \
337338
gdiff-command \
338339
gmerge-command \
339340
hash-digits \
340341
hooks \
341342
http-port \
@@ -372,10 +373,11 @@
372373
ssl-identity \
373374
tclsh \
374375
th1-setup \
375376
th1-uri-regexp \
376377
ticket-default-report \
378
+ timeline-utc \
377379
user-color-map \
378380
uv-sync \
379381
web-browser]
380382
381383
fossil test-th-eval "hasfeature legacyMvRm"
382384
--- test/tester.tcl
+++ test/tester.tcl
@@ -332,10 +332,11 @@
332 encoding-glob \
333 exec-rel-paths \
334 fileedit-glob \
335 forbid-delta-manifests \
336 forum-close-policy \
 
337 gdiff-command \
338 gmerge-command \
339 hash-digits \
340 hooks \
341 http-port \
@@ -372,10 +373,11 @@
372 ssl-identity \
373 tclsh \
374 th1-setup \
375 th1-uri-regexp \
376 ticket-default-report \
 
377 user-color-map \
378 uv-sync \
379 web-browser]
380
381 fossil test-th-eval "hasfeature legacyMvRm"
382
--- test/tester.tcl
+++ test/tester.tcl
@@ -332,10 +332,11 @@
332 encoding-glob \
333 exec-rel-paths \
334 fileedit-glob \
335 forbid-delta-manifests \
336 forum-close-policy \
337 forum-title \
338 gdiff-command \
339 gmerge-command \
340 hash-digits \
341 hooks \
342 http-port \
@@ -372,10 +373,11 @@
373 ssl-identity \
374 tclsh \
375 th1-setup \
376 th1-uri-regexp \
377 ticket-default-report \
378 timeline-utc \
379 user-color-map \
380 uv-sync \
381 web-browser]
382
383 fossil test-th-eval "hasfeature legacyMvRm"
384
--- test/update.test
+++ test/update.test
@@ -57,11 +57,11 @@
5757
5858
###############################################################################
5959
6060
fossil update --verbose
6161
test update-already-up-to-date {
62
- [regexp {^-{79}\ncheckout: .*\nchanges: +None. Already up-to-date$} $RESULT]
62
+ [regexp {^-{79}\ncheckout: .*\nchanges: +None. Already up-to-date.$} $RESULT]
6363
}
6464
6565
# Remaining tests are carried out in the order update_cmd() performs checks.
6666
#
6767
# Common approach for tests below:
6868
--- test/update.test
+++ test/update.test
@@ -57,11 +57,11 @@
57
58 ###############################################################################
59
60 fossil update --verbose
61 test update-already-up-to-date {
62 [regexp {^-{79}\ncheckout: .*\nchanges: +None. Already up-to-date$} $RESULT]
63 }
64
65 # Remaining tests are carried out in the order update_cmd() performs checks.
66 #
67 # Common approach for tests below:
68
--- test/update.test
+++ test/update.test
@@ -57,11 +57,11 @@
57
58 ###############################################################################
59
60 fossil update --verbose
61 test update-already-up-to-date {
62 [regexp {^-{79}\ncheckout: .*\nchanges: +None. Already up-to-date.$} $RESULT]
63 }
64
65 # Remaining tests are carried out in the order update_cmd() performs checks.
66 #
67 # Common approach for tests below:
68
+24 -18
--- tools/emcc.sh.in
+++ tools/emcc.sh.in
@@ -1,6 +1,7 @@
1
-#!/usr/bin/bash
1
+#!/bin/sh
2
+# ^^^^^^^ Please try to keep this script Bourne-compatible.
23
########################################################################
34
# WARNING: emcc.sh is generated from emcc.sh.in by the configure
45
# process. Do not edit emcc.sh directly, as it may be deleted or
56
# overwritten by the configure script.
67
#
@@ -7,54 +8,59 @@
78
# A wrapper around the emcc compiler which uses configure-time state
89
# to locate the Emscripten SDK and import the SDK's environment
910
# script, if needed.
1011
########################################################################
1112
# EMSDK_HOME comes from the configure --with-emsdk=/dir flag.
12
-# EMSDK_ENV is ${thatDir}/emsdk_env.sh and is also set by the
13
+# EMSDK_ENV_SH is ${thatDir}/emsdk_env.sh and is also set by the
1314
# configure process.
1415
EMSDK_HOME="@EMSDK_HOME@"
15
-EMSDK_ENV="@EMSDK_ENV@"
16
+EMSDK_ENV_SH="@EMSDK_ENV_SH@"
17
+emcc="@BIN_EMCC@"
1618
17
-emcc=$(which emcc 2>/dev/null)
19
+if [ x = "x${emcc}" ]; then
20
+ emcc=`which emcc 2>/dev/null`
21
+fi
1822
1923
if [ x = "x${emcc}" ]; then
2024
# If emcc is not found in the path, try to find it via an emsdk
21
- # installation. The SDK variant is the official installation
22
- # style supported by the Emscripten folks, but emcc is also
23
- # available via package managers on some OSes.
25
+ # installation. The SDK variant is the official installation style
26
+ # supported by the Emscripten project, but emcc is also available
27
+ # via package managers on some OSes.
2428
if [ x = "x${EMSDK_HOME}" ]; then
2529
echo "EMSDK_HOME is not set. Pass --with-emsdk=/path/to/emsdk" \
2630
"to the configure script." 1>&2
2731
exit 1
2832
fi
2933
30
- if [ x = "x${EMSDK_ENV}" ]; then
34
+ if [ x = "x${EMSDK_ENV_SH}" ]; then
3135
if [ -f "${EMSDK_HOME}/emsdk_env.sh" ]; then
32
- EMSDK_ENV="${EMSDK_HOME}/emsdk_env.sh"
36
+ EMSDK_ENV_SH="${EMSDK_HOME}/emsdk_env.sh"
3337
else
34
- echo "EMSDK_ENV is not set. Expecting configure script to set it." 1>&2
38
+ echo "EMSDK_ENV_SH is not set. Expecting configure script to set it." 1>&2
3539
exit 2
3640
fi
3741
fi
3842
39
- if [ ! -f "${EMSDK_ENV}" ]; then
40
- echo "emsdk_env script not found: $EMSDK_ENV" 1>&2
43
+ if [ ! -f "${EMSDK_ENV_SH}" ]; then
44
+ echo "emsdk_env script not found: $EMSDK_ENV_SH" 1>&2
4145
exit 3
4246
fi
4347
4448
# $EMSDK is part of the state set by emsdk_env.sh.
4549
if [ x = "x${EMSDK}" ]; then
46
- source "${EMSDK_ENV}" >/dev/null 2>&1 || {
47
- # ^^^ unfortunately outputs lots of noise to stderr
50
+ EMSDK_QUIET=1
51
+ export EMSDK_QUIET
52
+ # ^^^ Squelches informational output from ${EMSDK_ENV_SH}.
53
+ source "${EMSDK_ENV_SH}" || {
4854
rc=$?
49
- echo "Error sourcing ${EMSDK_ENV}"
55
+ echo "Error sourcing ${EMSDK_ENV_SH}"
5056
exit $rc
5157
}
5258
fi
53
- emcc=$(which emcc 2>/dev/null)
59
+ emcc=`which emcc 2>/dev/null`
5460
if [ x = "x${emcc}" ]; then
55
- echo "emcc not found in PATH. Normally that's set up by EMSDK_ENV." 1>&2
61
+ echo "emcc not found in PATH. Normally that's set up by ${EMSDK_ENV_SH}." 1>&2
5662
exit 4
5763
fi
5864
fi
5965
60
-exec emcc "$@"
66
+exec $emcc "$@"
6167
--- tools/emcc.sh.in
+++ tools/emcc.sh.in
@@ -1,6 +1,7 @@
1 #!/usr/bin/bash
 
2 ########################################################################
3 # WARNING: emcc.sh is generated from emcc.sh.in by the configure
4 # process. Do not edit emcc.sh directly, as it may be deleted or
5 # overwritten by the configure script.
6 #
@@ -7,54 +8,59 @@
7 # A wrapper around the emcc compiler which uses configure-time state
8 # to locate the Emscripten SDK and import the SDK's environment
9 # script, if needed.
10 ########################################################################
11 # EMSDK_HOME comes from the configure --with-emsdk=/dir flag.
12 # EMSDK_ENV is ${thatDir}/emsdk_env.sh and is also set by the
13 # configure process.
14 EMSDK_HOME="@EMSDK_HOME@"
15 EMSDK_ENV="@EMSDK_ENV@"
 
16
17 emcc=$(which emcc 2>/dev/null)
 
 
18
19 if [ x = "x${emcc}" ]; then
20 # If emcc is not found in the path, try to find it via an emsdk
21 # installation. The SDK variant is the official installation
22 # style supported by the Emscripten folks, but emcc is also
23 # available via package managers on some OSes.
24 if [ x = "x${EMSDK_HOME}" ]; then
25 echo "EMSDK_HOME is not set. Pass --with-emsdk=/path/to/emsdk" \
26 "to the configure script." 1>&2
27 exit 1
28 fi
29
30 if [ x = "x${EMSDK_ENV}" ]; then
31 if [ -f "${EMSDK_HOME}/emsdk_env.sh" ]; then
32 EMSDK_ENV="${EMSDK_HOME}/emsdk_env.sh"
33 else
34 echo "EMSDK_ENV is not set. Expecting configure script to set it." 1>&2
35 exit 2
36 fi
37 fi
38
39 if [ ! -f "${EMSDK_ENV}" ]; then
40 echo "emsdk_env script not found: $EMSDK_ENV" 1>&2
41 exit 3
42 fi
43
44 # $EMSDK is part of the state set by emsdk_env.sh.
45 if [ x = "x${EMSDK}" ]; then
46 source "${EMSDK_ENV}" >/dev/null 2>&1 || {
47 # ^^^ unfortunately outputs lots of noise to stderr
 
 
48 rc=$?
49 echo "Error sourcing ${EMSDK_ENV}"
50 exit $rc
51 }
52 fi
53 emcc=$(which emcc 2>/dev/null)
54 if [ x = "x${emcc}" ]; then
55 echo "emcc not found in PATH. Normally that's set up by EMSDK_ENV." 1>&2
56 exit 4
57 fi
58 fi
59
60 exec emcc "$@"
61
--- tools/emcc.sh.in
+++ tools/emcc.sh.in
@@ -1,6 +1,7 @@
1 #!/bin/sh
2 # ^^^^^^^ Please try to keep this script Bourne-compatible.
3 ########################################################################
4 # WARNING: emcc.sh is generated from emcc.sh.in by the configure
5 # process. Do not edit emcc.sh directly, as it may be deleted or
6 # overwritten by the configure script.
7 #
@@ -7,54 +8,59 @@
8 # A wrapper around the emcc compiler which uses configure-time state
9 # to locate the Emscripten SDK and import the SDK's environment
10 # script, if needed.
11 ########################################################################
12 # EMSDK_HOME comes from the configure --with-emsdk=/dir flag.
13 # EMSDK_ENV_SH is ${thatDir}/emsdk_env.sh and is also set by the
14 # configure process.
15 EMSDK_HOME="@EMSDK_HOME@"
16 EMSDK_ENV_SH="@EMSDK_ENV_SH@"
17 emcc="@BIN_EMCC@"
18
19 if [ x = "x${emcc}" ]; then
20 emcc=`which emcc 2>/dev/null`
21 fi
22
23 if [ x = "x${emcc}" ]; then
24 # If emcc is not found in the path, try to find it via an emsdk
25 # installation. The SDK variant is the official installation style
26 # supported by the Emscripten project, but emcc is also available
27 # via package managers on some OSes.
28 if [ x = "x${EMSDK_HOME}" ]; then
29 echo "EMSDK_HOME is not set. Pass --with-emsdk=/path/to/emsdk" \
30 "to the configure script." 1>&2
31 exit 1
32 fi
33
34 if [ x = "x${EMSDK_ENV_SH}" ]; then
35 if [ -f "${EMSDK_HOME}/emsdk_env.sh" ]; then
36 EMSDK_ENV_SH="${EMSDK_HOME}/emsdk_env.sh"
37 else
38 echo "EMSDK_ENV_SH is not set. Expecting configure script to set it." 1>&2
39 exit 2
40 fi
41 fi
42
43 if [ ! -f "${EMSDK_ENV_SH}" ]; then
44 echo "emsdk_env script not found: $EMSDK_ENV_SH" 1>&2
45 exit 3
46 fi
47
48 # $EMSDK is part of the state set by emsdk_env.sh.
49 if [ x = "x${EMSDK}" ]; then
50 EMSDK_QUIET=1
51 export EMSDK_QUIET
52 # ^^^ Squelches informational output from ${EMSDK_ENV_SH}.
53 source "${EMSDK_ENV_SH}" || {
54 rc=$?
55 echo "Error sourcing ${EMSDK_ENV_SH}"
56 exit $rc
57 }
58 fi
59 emcc=`which emcc 2>/dev/null`
60 if [ x = "x${emcc}" ]; then
61 echo "emcc not found in PATH. Normally that's set up by ${EMSDK_ENV_SH}." 1>&2
62 exit 4
63 fi
64 fi
65
66 exec $emcc "$@"
67
--- tools/makemake.tcl
+++ tools/makemake.tcl
@@ -132,10 +132,11 @@
132132
lookslike
133133
main
134134
manifest
135135
markdown
136136
markdown_html
137
+ match
137138
md5
138139
merge
139140
merge3
140141
moderate
141142
name
@@ -239,14 +240,15 @@
239240
-DSQLITE_OMIT_SHARED_CACHE
240241
-DSQLITE_OMIT_LOAD_EXTENSION
241242
-DSQLITE_MAX_EXPR_DEPTH=0
242243
-DSQLITE_ENABLE_LOCKING_STYLE=0
243244
-DSQLITE_DEFAULT_FILE_FORMAT=4
245
+ -DSQLITE_ENABLE_DBSTAT_VTAB
244246
-DSQLITE_ENABLE_EXPLAIN_COMMENTS
245247
-DSQLITE_ENABLE_FTS4
246
- -DSQLITE_ENABLE_DBSTAT_VTAB
247248
-DSQLITE_ENABLE_FTS5
249
+ -DSQLITE_ENABLE_MATH_FUNCTIONS
248250
-DSQLITE_ENABLE_STMTVTAB
249251
-DSQLITE_HAVE_ZLIB
250252
-DSQLITE_ENABLE_DBPAGE_VTAB
251253
-DSQLITE_TRUSTED_SCHEMA=0
252254
-DHAVE_USLEEP
@@ -379,10 +381,11 @@
379381
380382
$(OBJDIR):
381383
-mkdir $(OBJDIR)
382384
383385
$(OBJDIR)/translate: $(SRCDIR_tools)/translate.c
386
+ -mkdir -p $(OBJDIR)
384387
$(XBCC) -o $(OBJDIR)/translate $(SRCDIR_tools)/translate.c
385388
386389
$(OBJDIR)/makeheaders: $(SRCDIR_tools)/makeheaders.c
387390
$(XBCC) -o $(OBJDIR)/makeheaders $(SRCDIR_tools)/makeheaders.c
388391
389392
--- tools/makemake.tcl
+++ tools/makemake.tcl
@@ -132,10 +132,11 @@
132 lookslike
133 main
134 manifest
135 markdown
136 markdown_html
 
137 md5
138 merge
139 merge3
140 moderate
141 name
@@ -239,14 +240,15 @@
239 -DSQLITE_OMIT_SHARED_CACHE
240 -DSQLITE_OMIT_LOAD_EXTENSION
241 -DSQLITE_MAX_EXPR_DEPTH=0
242 -DSQLITE_ENABLE_LOCKING_STYLE=0
243 -DSQLITE_DEFAULT_FILE_FORMAT=4
 
244 -DSQLITE_ENABLE_EXPLAIN_COMMENTS
245 -DSQLITE_ENABLE_FTS4
246 -DSQLITE_ENABLE_DBSTAT_VTAB
247 -DSQLITE_ENABLE_FTS5
 
248 -DSQLITE_ENABLE_STMTVTAB
249 -DSQLITE_HAVE_ZLIB
250 -DSQLITE_ENABLE_DBPAGE_VTAB
251 -DSQLITE_TRUSTED_SCHEMA=0
252 -DHAVE_USLEEP
@@ -379,10 +381,11 @@
379
380 $(OBJDIR):
381 -mkdir $(OBJDIR)
382
383 $(OBJDIR)/translate: $(SRCDIR_tools)/translate.c
 
384 $(XBCC) -o $(OBJDIR)/translate $(SRCDIR_tools)/translate.c
385
386 $(OBJDIR)/makeheaders: $(SRCDIR_tools)/makeheaders.c
387 $(XBCC) -o $(OBJDIR)/makeheaders $(SRCDIR_tools)/makeheaders.c
388
389
--- tools/makemake.tcl
+++ tools/makemake.tcl
@@ -132,10 +132,11 @@
132 lookslike
133 main
134 manifest
135 markdown
136 markdown_html
137 match
138 md5
139 merge
140 merge3
141 moderate
142 name
@@ -239,14 +240,15 @@
240 -DSQLITE_OMIT_SHARED_CACHE
241 -DSQLITE_OMIT_LOAD_EXTENSION
242 -DSQLITE_MAX_EXPR_DEPTH=0
243 -DSQLITE_ENABLE_LOCKING_STYLE=0
244 -DSQLITE_DEFAULT_FILE_FORMAT=4
245 -DSQLITE_ENABLE_DBSTAT_VTAB
246 -DSQLITE_ENABLE_EXPLAIN_COMMENTS
247 -DSQLITE_ENABLE_FTS4
 
248 -DSQLITE_ENABLE_FTS5
249 -DSQLITE_ENABLE_MATH_FUNCTIONS
250 -DSQLITE_ENABLE_STMTVTAB
251 -DSQLITE_HAVE_ZLIB
252 -DSQLITE_ENABLE_DBPAGE_VTAB
253 -DSQLITE_TRUSTED_SCHEMA=0
254 -DHAVE_USLEEP
@@ -379,10 +381,11 @@
381
382 $(OBJDIR):
383 -mkdir $(OBJDIR)
384
385 $(OBJDIR)/translate: $(SRCDIR_tools)/translate.c
386 -mkdir -p $(OBJDIR)
387 $(XBCC) -o $(OBJDIR)/translate $(SRCDIR_tools)/translate.c
388
389 $(OBJDIR)/makeheaders: $(SRCDIR_tools)/makeheaders.c
390 $(XBCC) -o $(OBJDIR)/makeheaders $(SRCDIR_tools)/makeheaders.c
391
392
--- tools/translate.c
+++ tools/translate.c
@@ -78,10 +78,21 @@
7878
7979
/*
8080
** Name of files being processed
8181
*/
8282
static const char *zInFile = "(stdin)";
83
+
84
+/*
85
+** The `fossil_isspace()' function copied from the Fossil source code.
86
+** Some MSVC runtime library versions of `isspace()' break with an `assert()' if
87
+** the input is smaller than -1 or greater than 255 in debug builds, due to sign
88
+** extension when promoting `signed char' to `int' for non-ASCII characters. Use
89
+** an `isspace()' replacement instead of explicit type casts to `unsigned char'.
90
+*/
91
+int fossil_isspace(char c){
92
+ return c==' ' || (c<='\r' && c>='\t');
93
+}
8394
8495
/*
8596
** Terminate an active cgi_printf() or free string
8697
*/
8798
static void end_block(FILE *out){
@@ -106,21 +117,21 @@
106117
char zOut[4000]; /* The input line translated into appropriate output */
107118
108119
c1 = c2 = '-';
109120
while( fgets(zLine, sizeof(zLine), in) ){
110121
lineNo++;
111
- for(i=0; zLine[i] && isspace(zLine[i]); i++){}
122
+ for(i=0; zLine[i] && fossil_isspace(zLine[i]); i++){}
112123
if( zLine[i]!='@' ){
113124
if( inPrint || inStr ) end_block(out);
114125
fprintf(out,"%s",zLine);
115126
/* 0123456789 12345 */
116127
if( strncmp(zLine, "/* @-comment: ", 14)==0 ){
117128
c1 = zLine[14];
118129
c2 = zLine[15];
119130
}
120131
i += strlen(&zLine[i]);
121
- while( i>0 && isspace(zLine[i-1]) ){ i--; }
132
+ while( i>0 && fossil_isspace(zLine[i-1]) ){ i--; }
122133
lastWasEq = i>0 && zLine[i-1]=='=';
123134
lastWasComma = i>0 && zLine[i-1]==',';
124135
}else if( lastWasEq || lastWasComma){
125136
/* If the last non-whitespace character before the first @ was
126137
** an "="(var init/set) or a ","(const definition in list) then
@@ -129,11 +140,11 @@
129140
** and end of line.
130141
*/
131142
int indent, omitline;
132143
char *zNewline = "\\n";
133144
i++;
134
- if( isspace(zLine[i]) ){ i++; }
145
+ if( fossil_isspace(zLine[i]) ){ i++; }
135146
indent = i - 2;
136147
if( indent<0 ) indent = 0;
137148
omitline = 0;
138149
for(j=0; zLine[i] && zLine[i]!='\r' && zLine[i]!='\n'; i++){
139150
if( zLine[i]==c1 && (c2==' ' || zLine[i+1]==c2) ){
@@ -147,11 +158,11 @@
147158
break;
148159
}
149160
if( zLine[i]=='\\' || zLine[i]=='"' ){ zOut[j++] = '\\'; }
150161
zOut[j++] = zLine[i];
151162
}
152
- if( zNewline[0] ) while( j>0 && isspace(zOut[j-1]) ){ j--; }
163
+ if( zNewline[0] ) while( j>0 && fossil_isspace(zOut[j-1]) ){ j--; }
153164
zOut[j] = 0;
154165
if( j<=0 && omitline ){
155166
fprintf(out,"\n");
156167
}else{
157168
fprintf(out,"%*s\"%s%s\"\n",indent, "", zOut, zNewline);
@@ -171,11 +182,11 @@
171182
int indent;
172183
int nC;
173184
int nParam;
174185
char c;
175186
i++;
176
- if( isspace(zLine[i]) ){ i++; }
187
+ if( fossil_isspace(zLine[i]) ){ i++; }
177188
indent = i;
178189
for(j=0; zLine[i] && zLine[i]!='\r' && zLine[i]!='\n'; i++){
179190
if( zLine[i]=='\\' && (!zLine[i+1] || zLine[i+1]=='\r'
180191
|| zLine[i+1]=='\n') ){
181192
zNewline = "";
182193
--- tools/translate.c
+++ tools/translate.c
@@ -78,10 +78,21 @@
78
79 /*
80 ** Name of files being processed
81 */
82 static const char *zInFile = "(stdin)";
 
 
 
 
 
 
 
 
 
 
 
83
84 /*
85 ** Terminate an active cgi_printf() or free string
86 */
87 static void end_block(FILE *out){
@@ -106,21 +117,21 @@
106 char zOut[4000]; /* The input line translated into appropriate output */
107
108 c1 = c2 = '-';
109 while( fgets(zLine, sizeof(zLine), in) ){
110 lineNo++;
111 for(i=0; zLine[i] && isspace(zLine[i]); i++){}
112 if( zLine[i]!='@' ){
113 if( inPrint || inStr ) end_block(out);
114 fprintf(out,"%s",zLine);
115 /* 0123456789 12345 */
116 if( strncmp(zLine, "/* @-comment: ", 14)==0 ){
117 c1 = zLine[14];
118 c2 = zLine[15];
119 }
120 i += strlen(&zLine[i]);
121 while( i>0 && isspace(zLine[i-1]) ){ i--; }
122 lastWasEq = i>0 && zLine[i-1]=='=';
123 lastWasComma = i>0 && zLine[i-1]==',';
124 }else if( lastWasEq || lastWasComma){
125 /* If the last non-whitespace character before the first @ was
126 ** an "="(var init/set) or a ","(const definition in list) then
@@ -129,11 +140,11 @@
129 ** and end of line.
130 */
131 int indent, omitline;
132 char *zNewline = "\\n";
133 i++;
134 if( isspace(zLine[i]) ){ i++; }
135 indent = i - 2;
136 if( indent<0 ) indent = 0;
137 omitline = 0;
138 for(j=0; zLine[i] && zLine[i]!='\r' && zLine[i]!='\n'; i++){
139 if( zLine[i]==c1 && (c2==' ' || zLine[i+1]==c2) ){
@@ -147,11 +158,11 @@
147 break;
148 }
149 if( zLine[i]=='\\' || zLine[i]=='"' ){ zOut[j++] = '\\'; }
150 zOut[j++] = zLine[i];
151 }
152 if( zNewline[0] ) while( j>0 && isspace(zOut[j-1]) ){ j--; }
153 zOut[j] = 0;
154 if( j<=0 && omitline ){
155 fprintf(out,"\n");
156 }else{
157 fprintf(out,"%*s\"%s%s\"\n",indent, "", zOut, zNewline);
@@ -171,11 +182,11 @@
171 int indent;
172 int nC;
173 int nParam;
174 char c;
175 i++;
176 if( isspace(zLine[i]) ){ i++; }
177 indent = i;
178 for(j=0; zLine[i] && zLine[i]!='\r' && zLine[i]!='\n'; i++){
179 if( zLine[i]=='\\' && (!zLine[i+1] || zLine[i+1]=='\r'
180 || zLine[i+1]=='\n') ){
181 zNewline = "";
182
--- tools/translate.c
+++ tools/translate.c
@@ -78,10 +78,21 @@
78
79 /*
80 ** Name of files being processed
81 */
82 static const char *zInFile = "(stdin)";
83
84 /*
85 ** The `fossil_isspace()' function copied from the Fossil source code.
86 ** Some MSVC runtime library versions of `isspace()' break with an `assert()' if
87 ** the input is smaller than -1 or greater than 255 in debug builds, due to sign
88 ** extension when promoting `signed char' to `int' for non-ASCII characters. Use
89 ** an `isspace()' replacement instead of explicit type casts to `unsigned char'.
90 */
91 int fossil_isspace(char c){
92 return c==' ' || (c<='\r' && c>='\t');
93 }
94
95 /*
96 ** Terminate an active cgi_printf() or free string
97 */
98 static void end_block(FILE *out){
@@ -106,21 +117,21 @@
117 char zOut[4000]; /* The input line translated into appropriate output */
118
119 c1 = c2 = '-';
120 while( fgets(zLine, sizeof(zLine), in) ){
121 lineNo++;
122 for(i=0; zLine[i] && fossil_isspace(zLine[i]); i++){}
123 if( zLine[i]!='@' ){
124 if( inPrint || inStr ) end_block(out);
125 fprintf(out,"%s",zLine);
126 /* 0123456789 12345 */
127 if( strncmp(zLine, "/* @-comment: ", 14)==0 ){
128 c1 = zLine[14];
129 c2 = zLine[15];
130 }
131 i += strlen(&zLine[i]);
132 while( i>0 && fossil_isspace(zLine[i-1]) ){ i--; }
133 lastWasEq = i>0 && zLine[i-1]=='=';
134 lastWasComma = i>0 && zLine[i-1]==',';
135 }else if( lastWasEq || lastWasComma){
136 /* If the last non-whitespace character before the first @ was
137 ** an "="(var init/set) or a ","(const definition in list) then
@@ -129,11 +140,11 @@
140 ** and end of line.
141 */
142 int indent, omitline;
143 char *zNewline = "\\n";
144 i++;
145 if( fossil_isspace(zLine[i]) ){ i++; }
146 indent = i - 2;
147 if( indent<0 ) indent = 0;
148 omitline = 0;
149 for(j=0; zLine[i] && zLine[i]!='\r' && zLine[i]!='\n'; i++){
150 if( zLine[i]==c1 && (c2==' ' || zLine[i+1]==c2) ){
@@ -147,11 +158,11 @@
158 break;
159 }
160 if( zLine[i]=='\\' || zLine[i]=='"' ){ zOut[j++] = '\\'; }
161 zOut[j++] = zLine[i];
162 }
163 if( zNewline[0] ) while( j>0 && fossil_isspace(zOut[j-1]) ){ j--; }
164 zOut[j] = 0;
165 if( j<=0 && omitline ){
166 fprintf(out,"\n");
167 }else{
168 fprintf(out,"%*s\"%s%s\"\n",indent, "", zOut, zNewline);
@@ -171,11 +182,11 @@
182 int indent;
183 int nC;
184 int nParam;
185 char c;
186 i++;
187 if( fossil_isspace(zLine[i]) ){ i++; }
188 indent = i;
189 for(j=0; zLine[i] && zLine[i]!='\r' && zLine[i]!='\n'; i++){
190 if( zLine[i]=='\\' && (!zLine[i+1] || zLine[i+1]=='\r'
191 || zLine[i+1]=='\n') ){
192 zNewline = "";
193
+12 -6
--- win/Makefile.dmc
+++ win/Makefile.dmc
@@ -26,19 +26,19 @@
2626
CFLAGS = -o
2727
BCC = $(DMDIR)\bin\dmc $(CFLAGS)
2828
TCC = $(DMDIR)\bin\dmc $(CFLAGS) $(DMCDEF) $(SSL) $(INCL)
2929
LIBS = $(DMDIR)\extra\lib\ zlib wsock32 advapi32 dnsapi
3030
31
-SQLITE_OPTIONS = -DNDEBUG=1 -DSQLITE_DQS=0 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_MEMSTATUS=0 -DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS -DSQLITE_OMIT_DECLTYPE -DSQLITE_OMIT_DEPRECATED -DSQLITE_OMIT_PROGRESS_CALLBACK -DSQLITE_OMIT_SHARED_CACHE -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_MAX_EXPR_DEPTH=0 -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_ENABLE_EXPLAIN_COMMENTS -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_DBSTAT_VTAB -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_STMTVTAB -DSQLITE_HAVE_ZLIB -DSQLITE_ENABLE_DBPAGE_VTAB -DSQLITE_TRUSTED_SCHEMA=0 -DHAVE_USLEEP
31
+SQLITE_OPTIONS = -DNDEBUG=1 -DSQLITE_DQS=0 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_MEMSTATUS=0 -DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS -DSQLITE_OMIT_DECLTYPE -DSQLITE_OMIT_DEPRECATED -DSQLITE_OMIT_PROGRESS_CALLBACK -DSQLITE_OMIT_SHARED_CACHE -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_MAX_EXPR_DEPTH=0 -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_ENABLE_DBSTAT_VTAB -DSQLITE_ENABLE_EXPLAIN_COMMENTS -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_MATH_FUNCTIONS -DSQLITE_ENABLE_STMTVTAB -DSQLITE_HAVE_ZLIB -DSQLITE_ENABLE_DBPAGE_VTAB -DSQLITE_TRUSTED_SCHEMA=0 -DHAVE_USLEEP
3232
33
-SHELL_OPTIONS = -DNDEBUG=1 -DSQLITE_DQS=0 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_MEMSTATUS=0 -DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS -DSQLITE_OMIT_DECLTYPE -DSQLITE_OMIT_DEPRECATED -DSQLITE_OMIT_PROGRESS_CALLBACK -DSQLITE_OMIT_SHARED_CACHE -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_MAX_EXPR_DEPTH=0 -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_ENABLE_EXPLAIN_COMMENTS -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_DBSTAT_VTAB -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_STMTVTAB -DSQLITE_HAVE_ZLIB -DSQLITE_ENABLE_DBPAGE_VTAB -DSQLITE_TRUSTED_SCHEMA=0 -DHAVE_USLEEP -Dmain=sqlite3_shell -DSQLITE_SHELL_IS_UTF8=1 -DSQLITE_OMIT_LOAD_EXTENSION=1 -DUSE_SYSTEM_SQLITE=$(USE_SYSTEM_SQLITE) -DSQLITE_SHELL_DBNAME_PROC=sqlcmd_get_dbname -DSQLITE_SHELL_INIT_PROC=sqlcmd_init_proc -Daccess=file_access -Dsystem=fossil_system -Dgetenv=fossil_getenv -Dfopen=fossil_fopen
33
+SHELL_OPTIONS = -DNDEBUG=1 -DSQLITE_DQS=0 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_MEMSTATUS=0 -DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS -DSQLITE_OMIT_DECLTYPE -DSQLITE_OMIT_DEPRECATED -DSQLITE_OMIT_PROGRESS_CALLBACK -DSQLITE_OMIT_SHARED_CACHE -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_MAX_EXPR_DEPTH=0 -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_ENABLE_DBSTAT_VTAB -DSQLITE_ENABLE_EXPLAIN_COMMENTS -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_MATH_FUNCTIONS -DSQLITE_ENABLE_STMTVTAB -DSQLITE_HAVE_ZLIB -DSQLITE_ENABLE_DBPAGE_VTAB -DSQLITE_TRUSTED_SCHEMA=0 -DHAVE_USLEEP -Dmain=sqlite3_shell -DSQLITE_SHELL_IS_UTF8=1 -DSQLITE_OMIT_LOAD_EXTENSION=1 -DUSE_SYSTEM_SQLITE=$(USE_SYSTEM_SQLITE) -DSQLITE_SHELL_DBNAME_PROC=sqlcmd_get_dbname -DSQLITE_SHELL_INIT_PROC=sqlcmd_init_proc -Daccess=file_access -Dsystem=fossil_system -Dgetenv=fossil_getenv -Dfopen=fossil_fopen
3434
3535
PIKCHR_OPTIONS = -DPIKCHR_TOKEN_LIMIT=10000
3636
37
-SRC = add_.c ajax_.c alerts_.c allrepo_.c attach_.c backlink_.c backoffice_.c bag_.c bisect_.c blob_.c branch_.c browse_.c builtin_.c bundle_.c cache_.c capabilities_.c captcha_.c cgi_.c chat_.c checkin_.c checkout_.c clearsign_.c clone_.c color_.c comformat_.c configure_.c content_.c cookies_.c db_.c delta_.c deltacmd_.c deltafunc_.c descendants_.c diff_.c diffcmd_.c dispatch_.c doc_.c encode_.c etag_.c event_.c export_.c extcgi_.c file_.c fileedit_.c finfo_.c foci_.c forum_.c fshell_.c fusefs_.c fuzz_.c glob_.c graph_.c gzip_.c hname_.c hook_.c http_.c http_socket_.c http_ssl_.c http_transport_.c import_.c info_.c interwiki_.c json_.c json_artifact_.c json_branch_.c json_config_.c json_diff_.c json_dir_.c json_finfo_.c json_login_.c json_query_.c json_report_.c json_status_.c json_tag_.c json_timeline_.c json_user_.c json_wiki_.c leaf_.c loadctrl_.c login_.c lookslike_.c main_.c manifest_.c markdown_.c markdown_html_.c md5_.c merge_.c merge3_.c moderate_.c name_.c patch_.c path_.c piechart_.c pikchrshow_.c pivot_.c popen_.c pqueue_.c printf_.c publish_.c purge_.c rebuild_.c regexp_.c repolist_.c report_.c rss_.c schema_.c search_.c security_audit_.c setup_.c setupuser_.c sha1_.c sha1hard_.c sha3_.c shun_.c sitemap_.c skins_.c smtp_.c sqlcmd_.c stash_.c stat_.c statrep_.c style_.c sync_.c tag_.c tar_.c terminal_.c th_main_.c timeline_.c tkt_.c tktsetup_.c undo_.c unicode_.c unversioned_.c update_.c url_.c user_.c utf8_.c util_.c verify_.c vfile_.c wiki_.c wikiformat_.c winfile_.c winhttp_.c xfer_.c xfersetup_.c zip_.c
37
+SRC = add_.c ajax_.c alerts_.c allrepo_.c attach_.c backlink_.c backoffice_.c bag_.c bisect_.c blob_.c branch_.c browse_.c builtin_.c bundle_.c cache_.c capabilities_.c captcha_.c cgi_.c chat_.c checkin_.c checkout_.c clearsign_.c clone_.c color_.c comformat_.c configure_.c content_.c cookies_.c db_.c delta_.c deltacmd_.c deltafunc_.c descendants_.c diff_.c diffcmd_.c dispatch_.c doc_.c encode_.c etag_.c event_.c export_.c extcgi_.c file_.c fileedit_.c finfo_.c foci_.c forum_.c fshell_.c fusefs_.c fuzz_.c glob_.c graph_.c gzip_.c hname_.c hook_.c http_.c http_socket_.c http_ssl_.c http_transport_.c import_.c info_.c interwiki_.c json_.c json_artifact_.c json_branch_.c json_config_.c json_diff_.c json_dir_.c json_finfo_.c json_login_.c json_query_.c json_report_.c json_status_.c json_tag_.c json_timeline_.c json_user_.c json_wiki_.c leaf_.c loadctrl_.c login_.c lookslike_.c main_.c manifest_.c markdown_.c markdown_html_.c match_.c md5_.c merge_.c merge3_.c moderate_.c name_.c patch_.c path_.c piechart_.c pikchrshow_.c pivot_.c popen_.c pqueue_.c printf_.c publish_.c purge_.c rebuild_.c regexp_.c repolist_.c report_.c rss_.c schema_.c search_.c security_audit_.c setup_.c setupuser_.c sha1_.c sha1hard_.c sha3_.c shun_.c sitemap_.c skins_.c smtp_.c sqlcmd_.c stash_.c stat_.c statrep_.c style_.c sync_.c tag_.c tar_.c terminal_.c th_main_.c timeline_.c tkt_.c tktsetup_.c undo_.c unicode_.c unversioned_.c update_.c url_.c user_.c utf8_.c util_.c verify_.c vfile_.c wiki_.c wikiformat_.c winfile_.c winhttp_.c xfer_.c xfersetup_.c zip_.c
3838
39
-OBJ = $(OBJDIR)\add$O $(OBJDIR)\ajax$O $(OBJDIR)\alerts$O $(OBJDIR)\allrepo$O $(OBJDIR)\attach$O $(OBJDIR)\backlink$O $(OBJDIR)\backoffice$O $(OBJDIR)\bag$O $(OBJDIR)\bisect$O $(OBJDIR)\blob$O $(OBJDIR)\branch$O $(OBJDIR)\browse$O $(OBJDIR)\builtin$O $(OBJDIR)\bundle$O $(OBJDIR)\cache$O $(OBJDIR)\capabilities$O $(OBJDIR)\captcha$O $(OBJDIR)\cgi$O $(OBJDIR)\chat$O $(OBJDIR)\checkin$O $(OBJDIR)\checkout$O $(OBJDIR)\clearsign$O $(OBJDIR)\clone$O $(OBJDIR)\color$O $(OBJDIR)\comformat$O $(OBJDIR)\configure$O $(OBJDIR)\content$O $(OBJDIR)\cookies$O $(OBJDIR)\db$O $(OBJDIR)\delta$O $(OBJDIR)\deltacmd$O $(OBJDIR)\deltafunc$O $(OBJDIR)\descendants$O $(OBJDIR)\diff$O $(OBJDIR)\diffcmd$O $(OBJDIR)\dispatch$O $(OBJDIR)\doc$O $(OBJDIR)\encode$O $(OBJDIR)\etag$O $(OBJDIR)\event$O $(OBJDIR)\export$O $(OBJDIR)\extcgi$O $(OBJDIR)\file$O $(OBJDIR)\fileedit$O $(OBJDIR)\finfo$O $(OBJDIR)\foci$O $(OBJDIR)\forum$O $(OBJDIR)\fshell$O $(OBJDIR)\fusefs$O $(OBJDIR)\fuzz$O $(OBJDIR)\glob$O $(OBJDIR)\graph$O $(OBJDIR)\gzip$O $(OBJDIR)\hname$O $(OBJDIR)\hook$O $(OBJDIR)\http$O $(OBJDIR)\http_socket$O $(OBJDIR)\http_ssl$O $(OBJDIR)\http_transport$O $(OBJDIR)\import$O $(OBJDIR)\info$O $(OBJDIR)\interwiki$O $(OBJDIR)\json$O $(OBJDIR)\json_artifact$O $(OBJDIR)\json_branch$O $(OBJDIR)\json_config$O $(OBJDIR)\json_diff$O $(OBJDIR)\json_dir$O $(OBJDIR)\json_finfo$O $(OBJDIR)\json_login$O $(OBJDIR)\json_query$O $(OBJDIR)\json_report$O $(OBJDIR)\json_status$O $(OBJDIR)\json_tag$O $(OBJDIR)\json_timeline$O $(OBJDIR)\json_user$O $(OBJDIR)\json_wiki$O $(OBJDIR)\leaf$O $(OBJDIR)\loadctrl$O $(OBJDIR)\login$O $(OBJDIR)\lookslike$O $(OBJDIR)\main$O $(OBJDIR)\manifest$O $(OBJDIR)\markdown$O $(OBJDIR)\markdown_html$O $(OBJDIR)\md5$O $(OBJDIR)\merge$O $(OBJDIR)\merge3$O $(OBJDIR)\moderate$O $(OBJDIR)\name$O $(OBJDIR)\patch$O $(OBJDIR)\path$O $(OBJDIR)\piechart$O $(OBJDIR)\pikchrshow$O $(OBJDIR)\pivot$O $(OBJDIR)\popen$O $(OBJDIR)\pqueue$O $(OBJDIR)\printf$O $(OBJDIR)\publish$O $(OBJDIR)\purge$O $(OBJDIR)\rebuild$O $(OBJDIR)\regexp$O $(OBJDIR)\repolist$O $(OBJDIR)\report$O $(OBJDIR)\rss$O $(OBJDIR)\schema$O $(OBJDIR)\search$O $(OBJDIR)\security_audit$O $(OBJDIR)\setup$O $(OBJDIR)\setupuser$O $(OBJDIR)\sha1$O $(OBJDIR)\sha1hard$O $(OBJDIR)\sha3$O $(OBJDIR)\shun$O $(OBJDIR)\sitemap$O $(OBJDIR)\skins$O $(OBJDIR)\smtp$O $(OBJDIR)\sqlcmd$O $(OBJDIR)\stash$O $(OBJDIR)\stat$O $(OBJDIR)\statrep$O $(OBJDIR)\style$O $(OBJDIR)\sync$O $(OBJDIR)\tag$O $(OBJDIR)\tar$O $(OBJDIR)\terminal$O $(OBJDIR)\th_main$O $(OBJDIR)\timeline$O $(OBJDIR)\tkt$O $(OBJDIR)\tktsetup$O $(OBJDIR)\undo$O $(OBJDIR)\unicode$O $(OBJDIR)\unversioned$O $(OBJDIR)\update$O $(OBJDIR)\url$O $(OBJDIR)\user$O $(OBJDIR)\utf8$O $(OBJDIR)\util$O $(OBJDIR)\verify$O $(OBJDIR)\vfile$O $(OBJDIR)\wiki$O $(OBJDIR)\wikiformat$O $(OBJDIR)\winfile$O $(OBJDIR)\winhttp$O $(OBJDIR)\xfer$O $(OBJDIR)\xfersetup$O $(OBJDIR)\zip$O $(OBJDIR)\shell$O $(OBJDIR)\sqlite3$O $(OBJDIR)\th$O $(OBJDIR)\th_lang$O
39
+OBJ = $(OBJDIR)\add$O $(OBJDIR)\ajax$O $(OBJDIR)\alerts$O $(OBJDIR)\allrepo$O $(OBJDIR)\attach$O $(OBJDIR)\backlink$O $(OBJDIR)\backoffice$O $(OBJDIR)\bag$O $(OBJDIR)\bisect$O $(OBJDIR)\blob$O $(OBJDIR)\branch$O $(OBJDIR)\browse$O $(OBJDIR)\builtin$O $(OBJDIR)\bundle$O $(OBJDIR)\cache$O $(OBJDIR)\capabilities$O $(OBJDIR)\captcha$O $(OBJDIR)\cgi$O $(OBJDIR)\chat$O $(OBJDIR)\checkin$O $(OBJDIR)\checkout$O $(OBJDIR)\clearsign$O $(OBJDIR)\clone$O $(OBJDIR)\color$O $(OBJDIR)\comformat$O $(OBJDIR)\configure$O $(OBJDIR)\content$O $(OBJDIR)\cookies$O $(OBJDIR)\db$O $(OBJDIR)\delta$O $(OBJDIR)\deltacmd$O $(OBJDIR)\deltafunc$O $(OBJDIR)\descendants$O $(OBJDIR)\diff$O $(OBJDIR)\diffcmd$O $(OBJDIR)\dispatch$O $(OBJDIR)\doc$O $(OBJDIR)\encode$O $(OBJDIR)\etag$O $(OBJDIR)\event$O $(OBJDIR)\export$O $(OBJDIR)\extcgi$O $(OBJDIR)\file$O $(OBJDIR)\fileedit$O $(OBJDIR)\finfo$O $(OBJDIR)\foci$O $(OBJDIR)\forum$O $(OBJDIR)\fshell$O $(OBJDIR)\fusefs$O $(OBJDIR)\fuzz$O $(OBJDIR)\glob$O $(OBJDIR)\graph$O $(OBJDIR)\gzip$O $(OBJDIR)\hname$O $(OBJDIR)\hook$O $(OBJDIR)\http$O $(OBJDIR)\http_socket$O $(OBJDIR)\http_ssl$O $(OBJDIR)\http_transport$O $(OBJDIR)\import$O $(OBJDIR)\info$O $(OBJDIR)\interwiki$O $(OBJDIR)\json$O $(OBJDIR)\json_artifact$O $(OBJDIR)\json_branch$O $(OBJDIR)\json_config$O $(OBJDIR)\json_diff$O $(OBJDIR)\json_dir$O $(OBJDIR)\json_finfo$O $(OBJDIR)\json_login$O $(OBJDIR)\json_query$O $(OBJDIR)\json_report$O $(OBJDIR)\json_status$O $(OBJDIR)\json_tag$O $(OBJDIR)\json_timeline$O $(OBJDIR)\json_user$O $(OBJDIR)\json_wiki$O $(OBJDIR)\leaf$O $(OBJDIR)\loadctrl$O $(OBJDIR)\login$O $(OBJDIR)\lookslike$O $(OBJDIR)\main$O $(OBJDIR)\manifest$O $(OBJDIR)\markdown$O $(OBJDIR)\markdown_html$O $(OBJDIR)\match$O $(OBJDIR)\md5$O $(OBJDIR)\merge$O $(OBJDIR)\merge3$O $(OBJDIR)\moderate$O $(OBJDIR)\name$O $(OBJDIR)\patch$O $(OBJDIR)\path$O $(OBJDIR)\piechart$O $(OBJDIR)\pikchrshow$O $(OBJDIR)\pivot$O $(OBJDIR)\popen$O $(OBJDIR)\pqueue$O $(OBJDIR)\printf$O $(OBJDIR)\publish$O $(OBJDIR)\purge$O $(OBJDIR)\rebuild$O $(OBJDIR)\regexp$O $(OBJDIR)\repolist$O $(OBJDIR)\report$O $(OBJDIR)\rss$O $(OBJDIR)\schema$O $(OBJDIR)\search$O $(OBJDIR)\security_audit$O $(OBJDIR)\setup$O $(OBJDIR)\setupuser$O $(OBJDIR)\sha1$O $(OBJDIR)\sha1hard$O $(OBJDIR)\sha3$O $(OBJDIR)\shun$O $(OBJDIR)\sitemap$O $(OBJDIR)\skins$O $(OBJDIR)\smtp$O $(OBJDIR)\sqlcmd$O $(OBJDIR)\stash$O $(OBJDIR)\stat$O $(OBJDIR)\statrep$O $(OBJDIR)\style$O $(OBJDIR)\sync$O $(OBJDIR)\tag$O $(OBJDIR)\tar$O $(OBJDIR)\terminal$O $(OBJDIR)\th_main$O $(OBJDIR)\timeline$O $(OBJDIR)\tkt$O $(OBJDIR)\tktsetup$O $(OBJDIR)\undo$O $(OBJDIR)\unicode$O $(OBJDIR)\unversioned$O $(OBJDIR)\update$O $(OBJDIR)\url$O $(OBJDIR)\user$O $(OBJDIR)\utf8$O $(OBJDIR)\util$O $(OBJDIR)\verify$O $(OBJDIR)\vfile$O $(OBJDIR)\wiki$O $(OBJDIR)\wikiformat$O $(OBJDIR)\winfile$O $(OBJDIR)\winhttp$O $(OBJDIR)\xfer$O $(OBJDIR)\xfersetup$O $(OBJDIR)\zip$O $(OBJDIR)\shell$O $(OBJDIR)\sqlite3$O $(OBJDIR)\th$O $(OBJDIR)\th_lang$O
4040
4141
4242
RC=$(DMDIR)\bin\rcc
4343
RCFLAGS=-32 -w1 -I$(SRCDIR) /D__DMC__
4444
@@ -53,11 +53,11 @@
5353
5454
$(OBJDIR)\fossil.res: $B\win\fossil.rc
5555
$(RC) $(RCFLAGS) -o$@ $**
5656
5757
$(OBJDIR)\link: $B\win\Makefile.dmc $(OBJDIR)\fossil.res
58
- +echo add ajax alerts allrepo attach backlink backoffice bag bisect blob branch browse builtin bundle cache capabilities captcha cgi chat checkin checkout clearsign clone color comformat configure content cookies db delta deltacmd deltafunc descendants diff diffcmd dispatch doc encode etag event export extcgi file fileedit finfo foci forum fshell fusefs fuzz glob graph gzip hname hook http http_socket http_ssl http_transport import info interwiki json json_artifact json_branch json_config json_diff json_dir json_finfo json_login json_query json_report json_status json_tag json_timeline json_user json_wiki leaf loadctrl login lookslike main manifest markdown markdown_html md5 merge merge3 moderate name patch path piechart pikchrshow pivot popen pqueue printf publish purge rebuild regexp repolist report rss schema search security_audit setup setupuser sha1 sha1hard sha3 shun sitemap skins smtp sqlcmd stash stat statrep style sync tag tar terminal th_main timeline tkt tktsetup undo unicode unversioned update url user utf8 util verify vfile wiki wikiformat winfile winhttp xfer xfersetup zip shell sqlite3 th th_lang > $@
58
+ +echo add ajax alerts allrepo attach backlink backoffice bag bisect blob branch browse builtin bundle cache capabilities captcha cgi chat checkin checkout clearsign clone color comformat configure content cookies db delta deltacmd deltafunc descendants diff diffcmd dispatch doc encode etag event export extcgi file fileedit finfo foci forum fshell fusefs fuzz glob graph gzip hname hook http http_socket http_ssl http_transport import info interwiki json json_artifact json_branch json_config json_diff json_dir json_finfo json_login json_query json_report json_status json_tag json_timeline json_user json_wiki leaf loadctrl login lookslike main manifest markdown markdown_html match md5 merge merge3 moderate name patch path piechart pikchrshow pivot popen pqueue printf publish purge rebuild regexp repolist report rss schema search security_audit setup setupuser sha1 sha1hard sha3 shun sitemap skins smtp sqlcmd stash stat statrep style sync tag tar terminal th_main timeline tkt tktsetup undo unicode unversioned update url user utf8 util verify vfile wiki wikiformat winfile winhttp xfer xfersetup zip shell sqlite3 th th_lang > $@
5959
+echo fossil >> $@
6060
+echo fossil >> $@
6161
+echo $(LIBS) >> $@
6262
+echo. >> $@
6363
+echo fossil >> $@
@@ -635,10 +635,16 @@
635635
$(OBJDIR)\markdown_html$O : markdown_html_.c markdown_html.h
636636
$(TCC) -o$@ -c markdown_html_.c
637637
638638
markdown_html_.c : $(SRCDIR)\markdown_html.c
639639
+translate$E $** > $@
640
+
641
+$(OBJDIR)\match$O : match_.c match.h
642
+ $(TCC) -o$@ -c match_.c
643
+
644
+match_.c : $(SRCDIR)\match.c
645
+ +translate$E $** > $@
640646
641647
$(OBJDIR)\md5$O : md5_.c md5.h
642648
$(TCC) -o$@ -c md5_.c
643649
644650
md5_.c : $(SRCDIR)\md5.c
@@ -1009,7 +1015,7 @@
10091015
10101016
zip_.c : $(SRCDIR)\zip.c
10111017
+translate$E $** > $@
10121018
10131019
headers: makeheaders$E page_index.h builtin_data.h VERSION.h
1014
- +makeheaders$E add_.c:add.h ajax_.c:ajax.h alerts_.c:alerts.h allrepo_.c:allrepo.h attach_.c:attach.h backlink_.c:backlink.h backoffice_.c:backoffice.h bag_.c:bag.h bisect_.c:bisect.h blob_.c:blob.h branch_.c:branch.h browse_.c:browse.h builtin_.c:builtin.h bundle_.c:bundle.h cache_.c:cache.h capabilities_.c:capabilities.h captcha_.c:captcha.h cgi_.c:cgi.h chat_.c:chat.h checkin_.c:checkin.h checkout_.c:checkout.h clearsign_.c:clearsign.h clone_.c:clone.h color_.c:color.h comformat_.c:comformat.h configure_.c:configure.h content_.c:content.h cookies_.c:cookies.h db_.c:db.h delta_.c:delta.h deltacmd_.c:deltacmd.h deltafunc_.c:deltafunc.h descendants_.c:descendants.h diff_.c:diff.h diffcmd_.c:diffcmd.h dispatch_.c:dispatch.h doc_.c:doc.h encode_.c:encode.h etag_.c:etag.h event_.c:event.h export_.c:export.h extcgi_.c:extcgi.h file_.c:file.h fileedit_.c:fileedit.h finfo_.c:finfo.h foci_.c:foci.h forum_.c:forum.h fshell_.c:fshell.h fusefs_.c:fusefs.h fuzz_.c:fuzz.h glob_.c:glob.h graph_.c:graph.h gzip_.c:gzip.h hname_.c:hname.h hook_.c:hook.h http_.c:http.h http_socket_.c:http_socket.h http_ssl_.c:http_ssl.h http_transport_.c:http_transport.h import_.c:import.h info_.c:info.h interwiki_.c:interwiki.h json_.c:json.h json_artifact_.c:json_artifact.h json_branch_.c:json_branch.h json_config_.c:json_config.h json_diff_.c:json_diff.h json_dir_.c:json_dir.h json_finfo_.c:json_finfo.h json_login_.c:json_login.h json_query_.c:json_query.h json_report_.c:json_report.h json_status_.c:json_status.h json_tag_.c:json_tag.h json_timeline_.c:json_timeline.h json_user_.c:json_user.h json_wiki_.c:json_wiki.h leaf_.c:leaf.h loadctrl_.c:loadctrl.h login_.c:login.h lookslike_.c:lookslike.h main_.c:main.h manifest_.c:manifest.h markdown_.c:markdown.h markdown_html_.c:markdown_html.h md5_.c:md5.h merge_.c:merge.h merge3_.c:merge3.h moderate_.c:moderate.h name_.c:name.h patch_.c:patch.h path_.c:path.h piechart_.c:piechart.h pikchrshow_.c:pikchrshow.h pivot_.c:pivot.h popen_.c:popen.h pqueue_.c:pqueue.h printf_.c:printf.h publish_.c:publish.h purge_.c:purge.h rebuild_.c:rebuild.h regexp_.c:regexp.h repolist_.c:repolist.h report_.c:report.h rss_.c:rss.h schema_.c:schema.h search_.c:search.h security_audit_.c:security_audit.h setup_.c:setup.h setupuser_.c:setupuser.h sha1_.c:sha1.h sha1hard_.c:sha1hard.h sha3_.c:sha3.h shun_.c:shun.h sitemap_.c:sitemap.h skins_.c:skins.h smtp_.c:smtp.h sqlcmd_.c:sqlcmd.h stash_.c:stash.h stat_.c:stat.h statrep_.c:statrep.h style_.c:style.h sync_.c:sync.h tag_.c:tag.h tar_.c:tar.h terminal_.c:terminal.h th_main_.c:th_main.h timeline_.c:timeline.h tkt_.c:tkt.h tktsetup_.c:tktsetup.h undo_.c:undo.h unicode_.c:unicode.h unversioned_.c:unversioned.h update_.c:update.h url_.c:url.h user_.c:user.h utf8_.c:utf8.h util_.c:util.h verify_.c:verify.h vfile_.c:vfile.h wiki_.c:wiki.h wikiformat_.c:wikiformat.h winfile_.c:winfile.h winhttp_.c:winhttp.h xfer_.c:xfer.h xfersetup_.c:xfersetup.h zip_.c:zip.h $(SRCDIR_extsrc)\pikchr.c:pikchr.h $(SRCDIR_extsrc)\sqlite3.h $(SRCDIR)\th.h VERSION.h $(SRCDIR_extsrc)\cson_amalgamation.h
1020
+ +makeheaders$E add_.c:add.h ajax_.c:ajax.h alerts_.c:alerts.h allrepo_.c:allrepo.h attach_.c:attach.h backlink_.c:backlink.h backoffice_.c:backoffice.h bag_.c:bag.h bisect_.c:bisect.h blob_.c:blob.h branch_.c:branch.h browse_.c:browse.h builtin_.c:builtin.h bundle_.c:bundle.h cache_.c:cache.h capabilities_.c:capabilities.h captcha_.c:captcha.h cgi_.c:cgi.h chat_.c:chat.h checkin_.c:checkin.h checkout_.c:checkout.h clearsign_.c:clearsign.h clone_.c:clone.h color_.c:color.h comformat_.c:comformat.h configure_.c:configure.h content_.c:content.h cookies_.c:cookies.h db_.c:db.h delta_.c:delta.h deltacmd_.c:deltacmd.h deltafunc_.c:deltafunc.h descendants_.c:descendants.h diff_.c:diff.h diffcmd_.c:diffcmd.h dispatch_.c:dispatch.h doc_.c:doc.h encode_.c:encode.h etag_.c:etag.h event_.c:event.h export_.c:export.h extcgi_.c:extcgi.h file_.c:file.h fileedit_.c:fileedit.h finfo_.c:finfo.h foci_.c:foci.h forum_.c:forum.h fshell_.c:fshell.h fusefs_.c:fusefs.h fuzz_.c:fuzz.h glob_.c:glob.h graph_.c:graph.h gzip_.c:gzip.h hname_.c:hname.h hook_.c:hook.h http_.c:http.h http_socket_.c:http_socket.h http_ssl_.c:http_ssl.h http_transport_.c:http_transport.h import_.c:import.h info_.c:info.h interwiki_.c:interwiki.h json_.c:json.h json_artifact_.c:json_artifact.h json_branch_.c:json_branch.h json_config_.c:json_config.h json_diff_.c:json_diff.h json_dir_.c:json_dir.h json_finfo_.c:json_finfo.h json_login_.c:json_login.h json_query_.c:json_query.h json_report_.c:json_report.h json_status_.c:json_status.h json_tag_.c:json_tag.h json_timeline_.c:json_timeline.h json_user_.c:json_user.h json_wiki_.c:json_wiki.h leaf_.c:leaf.h loadctrl_.c:loadctrl.h login_.c:login.h lookslike_.c:lookslike.h main_.c:main.h manifest_.c:manifest.h markdown_.c:markdown.h markdown_html_.c:markdown_html.h match_.c:match.h md5_.c:md5.h merge_.c:merge.h merge3_.c:merge3.h moderate_.c:moderate.h name_.c:name.h patch_.c:patch.h path_.c:path.h piechart_.c:piechart.h pikchrshow_.c:pikchrshow.h pivot_.c:pivot.h popen_.c:popen.h pqueue_.c:pqueue.h printf_.c:printf.h publish_.c:publish.h purge_.c:purge.h rebuild_.c:rebuild.h regexp_.c:regexp.h repolist_.c:repolist.h report_.c:report.h rss_.c:rss.h schema_.c:schema.h search_.c:search.h security_audit_.c:security_audit.h setup_.c:setup.h setupuser_.c:setupuser.h sha1_.c:sha1.h sha1hard_.c:sha1hard.h sha3_.c:sha3.h shun_.c:shun.h sitemap_.c:sitemap.h skins_.c:skins.h smtp_.c:smtp.h sqlcmd_.c:sqlcmd.h stash_.c:stash.h stat_.c:stat.h statrep_.c:statrep.h style_.c:style.h sync_.c:sync.h tag_.c:tag.h tar_.c:tar.h terminal_.c:terminal.h th_main_.c:th_main.h timeline_.c:timeline.h tkt_.c:tkt.h tktsetup_.c:tktsetup.h undo_.c:undo.h unicode_.c:unicode.h unversioned_.c:unversioned.h update_.c:update.h url_.c:url.h user_.c:user.h utf8_.c:utf8.h util_.c:util.h verify_.c:verify.h vfile_.c:vfile.h wiki_.c:wiki.h wikiformat_.c:wikiformat.h winfile_.c:winfile.h winhttp_.c:winhttp.h xfer_.c:xfer.h xfersetup_.c:xfersetup.h zip_.c:zip.h $(SRCDIR_extsrc)\pikchr.c:pikchr.h $(SRCDIR_extsrc)\sqlite3.h $(SRCDIR)\th.h VERSION.h $(SRCDIR_extsrc)\cson_amalgamation.h
10151021
@copy /Y nul: headers
10161022
--- win/Makefile.dmc
+++ win/Makefile.dmc
@@ -26,19 +26,19 @@
26 CFLAGS = -o
27 BCC = $(DMDIR)\bin\dmc $(CFLAGS)
28 TCC = $(DMDIR)\bin\dmc $(CFLAGS) $(DMCDEF) $(SSL) $(INCL)
29 LIBS = $(DMDIR)\extra\lib\ zlib wsock32 advapi32 dnsapi
30
31 SQLITE_OPTIONS = -DNDEBUG=1 -DSQLITE_DQS=0 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_MEMSTATUS=0 -DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS -DSQLITE_OMIT_DECLTYPE -DSQLITE_OMIT_DEPRECATED -DSQLITE_OMIT_PROGRESS_CALLBACK -DSQLITE_OMIT_SHARED_CACHE -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_MAX_EXPR_DEPTH=0 -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_ENABLE_EXPLAIN_COMMENTS -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_DBSTAT_VTAB -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_STMTVTAB -DSQLITE_HAVE_ZLIB -DSQLITE_ENABLE_DBPAGE_VTAB -DSQLITE_TRUSTED_SCHEMA=0 -DHAVE_USLEEP
32
33 SHELL_OPTIONS = -DNDEBUG=1 -DSQLITE_DQS=0 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_MEMSTATUS=0 -DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS -DSQLITE_OMIT_DECLTYPE -DSQLITE_OMIT_DEPRECATED -DSQLITE_OMIT_PROGRESS_CALLBACK -DSQLITE_OMIT_SHARED_CACHE -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_MAX_EXPR_DEPTH=0 -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_ENABLE_EXPLAIN_COMMENTS -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_DBSTAT_VTAB -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_STMTVTAB -DSQLITE_HAVE_ZLIB -DSQLITE_ENABLE_DBPAGE_VTAB -DSQLITE_TRUSTED_SCHEMA=0 -DHAVE_USLEEP -Dmain=sqlite3_shell -DSQLITE_SHELL_IS_UTF8=1 -DSQLITE_OMIT_LOAD_EXTENSION=1 -DUSE_SYSTEM_SQLITE=$(USE_SYSTEM_SQLITE) -DSQLITE_SHELL_DBNAME_PROC=sqlcmd_get_dbname -DSQLITE_SHELL_INIT_PROC=sqlcmd_init_proc -Daccess=file_access -Dsystem=fossil_system -Dgetenv=fossil_getenv -Dfopen=fossil_fopen
34
35 PIKCHR_OPTIONS = -DPIKCHR_TOKEN_LIMIT=10000
36
37 SRC = add_.c ajax_.c alerts_.c allrepo_.c attach_.c backlink_.c backoffice_.c bag_.c bisect_.c blob_.c branch_.c browse_.c builtin_.c bundle_.c cache_.c capabilities_.c captcha_.c cgi_.c chat_.c checkin_.c checkout_.c clearsign_.c clone_.c color_.c comformat_.c configure_.c content_.c cookies_.c db_.c delta_.c deltacmd_.c deltafunc_.c descendants_.c diff_.c diffcmd_.c dispatch_.c doc_.c encode_.c etag_.c event_.c export_.c extcgi_.c file_.c fileedit_.c finfo_.c foci_.c forum_.c fshell_.c fusefs_.c fuzz_.c glob_.c graph_.c gzip_.c hname_.c hook_.c http_.c http_socket_.c http_ssl_.c http_transport_.c import_.c info_.c interwiki_.c json_.c json_artifact_.c json_branch_.c json_config_.c json_diff_.c json_dir_.c json_finfo_.c json_login_.c json_query_.c json_report_.c json_status_.c json_tag_.c json_timeline_.c json_user_.c json_wiki_.c leaf_.c loadctrl_.c login_.c lookslike_.c main_.c manifest_.c markdown_.c markdown_html_.c md5_.c merge_.c merge3_.c moderate_.c name_.c patch_.c path_.c piechart_.c pikchrshow_.c pivot_.c popen_.c pqueue_.c printf_.c publish_.c purge_.c rebuild_.c regexp_.c repolist_.c report_.c rss_.c schema_.c search_.c security_audit_.c setup_.c setupuser_.c sha1_.c sha1hard_.c sha3_.c shun_.c sitemap_.c skins_.c smtp_.c sqlcmd_.c stash_.c stat_.c statrep_.c style_.c sync_.c tag_.c tar_.c terminal_.c th_main_.c timeline_.c tkt_.c tktsetup_.c undo_.c unicode_.c unversioned_.c update_.c url_.c user_.c utf8_.c util_.c verify_.c vfile_.c wiki_.c wikiformat_.c winfile_.c winhttp_.c xfer_.c xfersetup_.c zip_.c
38
39 OBJ = $(OBJDIR)\add$O $(OBJDIR)\ajax$O $(OBJDIR)\alerts$O $(OBJDIR)\allrepo$O $(OBJDIR)\attach$O $(OBJDIR)\backlink$O $(OBJDIR)\backoffice$O $(OBJDIR)\bag$O $(OBJDIR)\bisect$O $(OBJDIR)\blob$O $(OBJDIR)\branch$O $(OBJDIR)\browse$O $(OBJDIR)\builtin$O $(OBJDIR)\bundle$O $(OBJDIR)\cache$O $(OBJDIR)\capabilities$O $(OBJDIR)\captcha$O $(OBJDIR)\cgi$O $(OBJDIR)\chat$O $(OBJDIR)\checkin$O $(OBJDIR)\checkout$O $(OBJDIR)\clearsign$O $(OBJDIR)\clone$O $(OBJDIR)\color$O $(OBJDIR)\comformat$O $(OBJDIR)\configure$O $(OBJDIR)\content$O $(OBJDIR)\cookies$O $(OBJDIR)\db$O $(OBJDIR)\delta$O $(OBJDIR)\deltacmd$O $(OBJDIR)\deltafunc$O $(OBJDIR)\descendants$O $(OBJDIR)\diff$O $(OBJDIR)\diffcmd$O $(OBJDIR)\dispatch$O $(OBJDIR)\doc$O $(OBJDIR)\encode$O $(OBJDIR)\etag$O $(OBJDIR)\event$O $(OBJDIR)\export$O $(OBJDIR)\extcgi$O $(OBJDIR)\file$O $(OBJDIR)\fileedit$O $(OBJDIR)\finfo$O $(OBJDIR)\foci$O $(OBJDIR)\forum$O $(OBJDIR)\fshell$O $(OBJDIR)\fusefs$O $(OBJDIR)\fuzz$O $(OBJDIR)\glob$O $(OBJDIR)\graph$O $(OBJDIR)\gzip$O $(OBJDIR)\hname$O $(OBJDIR)\hook$O $(OBJDIR)\http$O $(OBJDIR)\http_socket$O $(OBJDIR)\http_ssl$O $(OBJDIR)\http_transport$O $(OBJDIR)\import$O $(OBJDIR)\info$O $(OBJDIR)\interwiki$O $(OBJDIR)\json$O $(OBJDIR)\json_artifact$O $(OBJDIR)\json_branch$O $(OBJDIR)\json_config$O $(OBJDIR)\json_diff$O $(OBJDIR)\json_dir$O $(OBJDIR)\json_finfo$O $(OBJDIR)\json_login$O $(OBJDIR)\json_query$O $(OBJDIR)\json_report$O $(OBJDIR)\json_status$O $(OBJDIR)\json_tag$O $(OBJDIR)\json_timeline$O $(OBJDIR)\json_user$O $(OBJDIR)\json_wiki$O $(OBJDIR)\leaf$O $(OBJDIR)\loadctrl$O $(OBJDIR)\login$O $(OBJDIR)\lookslike$O $(OBJDIR)\main$O $(OBJDIR)\manifest$O $(OBJDIR)\markdown$O $(OBJDIR)\markdown_html$O $(OBJDIR)\md5$O $(OBJDIR)\merge$O $(OBJDIR)\merge3$O $(OBJDIR)\moderate$O $(OBJDIR)\name$O $(OBJDIR)\patch$O $(OBJDIR)\path$O $(OBJDIR)\piechart$O $(OBJDIR)\pikchrshow$O $(OBJDIR)\pivot$O $(OBJDIR)\popen$O $(OBJDIR)\pqueue$O $(OBJDIR)\printf$O $(OBJDIR)\publish$O $(OBJDIR)\purge$O $(OBJDIR)\rebuild$O $(OBJDIR)\regexp$O $(OBJDIR)\repolist$O $(OBJDIR)\report$O $(OBJDIR)\rss$O $(OBJDIR)\schema$O $(OBJDIR)\search$O $(OBJDIR)\security_audit$O $(OBJDIR)\setup$O $(OBJDIR)\setupuser$O $(OBJDIR)\sha1$O $(OBJDIR)\sha1hard$O $(OBJDIR)\sha3$O $(OBJDIR)\shun$O $(OBJDIR)\sitemap$O $(OBJDIR)\skins$O $(OBJDIR)\smtp$O $(OBJDIR)\sqlcmd$O $(OBJDIR)\stash$O $(OBJDIR)\stat$O $(OBJDIR)\statrep$O $(OBJDIR)\style$O $(OBJDIR)\sync$O $(OBJDIR)\tag$O $(OBJDIR)\tar$O $(OBJDIR)\terminal$O $(OBJDIR)\th_main$O $(OBJDIR)\timeline$O $(OBJDIR)\tkt$O $(OBJDIR)\tktsetup$O $(OBJDIR)\undo$O $(OBJDIR)\unicode$O $(OBJDIR)\unversioned$O $(OBJDIR)\update$O $(OBJDIR)\url$O $(OBJDIR)\user$O $(OBJDIR)\utf8$O $(OBJDIR)\util$O $(OBJDIR)\verify$O $(OBJDIR)\vfile$O $(OBJDIR)\wiki$O $(OBJDIR)\wikiformat$O $(OBJDIR)\winfile$O $(OBJDIR)\winhttp$O $(OBJDIR)\xfer$O $(OBJDIR)\xfersetup$O $(OBJDIR)\zip$O $(OBJDIR)\shell$O $(OBJDIR)\sqlite3$O $(OBJDIR)\th$O $(OBJDIR)\th_lang$O
40
41
42 RC=$(DMDIR)\bin\rcc
43 RCFLAGS=-32 -w1 -I$(SRCDIR) /D__DMC__
44
@@ -53,11 +53,11 @@
53
54 $(OBJDIR)\fossil.res: $B\win\fossil.rc
55 $(RC) $(RCFLAGS) -o$@ $**
56
57 $(OBJDIR)\link: $B\win\Makefile.dmc $(OBJDIR)\fossil.res
58 +echo add ajax alerts allrepo attach backlink backoffice bag bisect blob branch browse builtin bundle cache capabilities captcha cgi chat checkin checkout clearsign clone color comformat configure content cookies db delta deltacmd deltafunc descendants diff diffcmd dispatch doc encode etag event export extcgi file fileedit finfo foci forum fshell fusefs fuzz glob graph gzip hname hook http http_socket http_ssl http_transport import info interwiki json json_artifact json_branch json_config json_diff json_dir json_finfo json_login json_query json_report json_status json_tag json_timeline json_user json_wiki leaf loadctrl login lookslike main manifest markdown markdown_html md5 merge merge3 moderate name patch path piechart pikchrshow pivot popen pqueue printf publish purge rebuild regexp repolist report rss schema search security_audit setup setupuser sha1 sha1hard sha3 shun sitemap skins smtp sqlcmd stash stat statrep style sync tag tar terminal th_main timeline tkt tktsetup undo unicode unversioned update url user utf8 util verify vfile wiki wikiformat winfile winhttp xfer xfersetup zip shell sqlite3 th th_lang > $@
59 +echo fossil >> $@
60 +echo fossil >> $@
61 +echo $(LIBS) >> $@
62 +echo. >> $@
63 +echo fossil >> $@
@@ -635,10 +635,16 @@
635 $(OBJDIR)\markdown_html$O : markdown_html_.c markdown_html.h
636 $(TCC) -o$@ -c markdown_html_.c
637
638 markdown_html_.c : $(SRCDIR)\markdown_html.c
639 +translate$E $** > $@
 
 
 
 
 
 
640
641 $(OBJDIR)\md5$O : md5_.c md5.h
642 $(TCC) -o$@ -c md5_.c
643
644 md5_.c : $(SRCDIR)\md5.c
@@ -1009,7 +1015,7 @@
1009
1010 zip_.c : $(SRCDIR)\zip.c
1011 +translate$E $** > $@
1012
1013 headers: makeheaders$E page_index.h builtin_data.h VERSION.h
1014 +makeheaders$E add_.c:add.h ajax_.c:ajax.h alerts_.c:alerts.h allrepo_.c:allrepo.h attach_.c:attach.h backlink_.c:backlink.h backoffice_.c:backoffice.h bag_.c:bag.h bisect_.c:bisect.h blob_.c:blob.h branch_.c:branch.h browse_.c:browse.h builtin_.c:builtin.h bundle_.c:bundle.h cache_.c:cache.h capabilities_.c:capabilities.h captcha_.c:captcha.h cgi_.c:cgi.h chat_.c:chat.h checkin_.c:checkin.h checkout_.c:checkout.h clearsign_.c:clearsign.h clone_.c:clone.h color_.c:color.h comformat_.c:comformat.h configure_.c:configure.h content_.c:content.h cookies_.c:cookies.h db_.c:db.h delta_.c:delta.h deltacmd_.c:deltacmd.h deltafunc_.c:deltafunc.h descendants_.c:descendants.h diff_.c:diff.h diffcmd_.c:diffcmd.h dispatch_.c:dispatch.h doc_.c:doc.h encode_.c:encode.h etag_.c:etag.h event_.c:event.h export_.c:export.h extcgi_.c:extcgi.h file_.c:file.h fileedit_.c:fileedit.h finfo_.c:finfo.h foci_.c:foci.h forum_.c:forum.h fshell_.c:fshell.h fusefs_.c:fusefs.h fuzz_.c:fuzz.h glob_.c:glob.h graph_.c:graph.h gzip_.c:gzip.h hname_.c:hname.h hook_.c:hook.h http_.c:http.h http_socket_.c:http_socket.h http_ssl_.c:http_ssl.h http_transport_.c:http_transport.h import_.c:import.h info_.c:info.h interwiki_.c:interwiki.h json_.c:json.h json_artifact_.c:json_artifact.h json_branch_.c:json_branch.h json_config_.c:json_config.h json_diff_.c:json_diff.h json_dir_.c:json_dir.h json_finfo_.c:json_finfo.h json_login_.c:json_login.h json_query_.c:json_query.h json_report_.c:json_report.h json_status_.c:json_status.h json_tag_.c:json_tag.h json_timeline_.c:json_timeline.h json_user_.c:json_user.h json_wiki_.c:json_wiki.h leaf_.c:leaf.h loadctrl_.c:loadctrl.h login_.c:login.h lookslike_.c:lookslike.h main_.c:main.h manifest_.c:manifest.h markdown_.c:markdown.h markdown_html_.c:markdown_html.h md5_.c:md5.h merge_.c:merge.h merge3_.c:merge3.h moderate_.c:moderate.h name_.c:name.h patch_.c:patch.h path_.c:path.h piechart_.c:piechart.h pikchrshow_.c:pikchrshow.h pivot_.c:pivot.h popen_.c:popen.h pqueue_.c:pqueue.h printf_.c:printf.h publish_.c:publish.h purge_.c:purge.h rebuild_.c:rebuild.h regexp_.c:regexp.h repolist_.c:repolist.h report_.c:report.h rss_.c:rss.h schema_.c:schema.h search_.c:search.h security_audit_.c:security_audit.h setup_.c:setup.h setupuser_.c:setupuser.h sha1_.c:sha1.h sha1hard_.c:sha1hard.h sha3_.c:sha3.h shun_.c:shun.h sitemap_.c:sitemap.h skins_.c:skins.h smtp_.c:smtp.h sqlcmd_.c:sqlcmd.h stash_.c:stash.h stat_.c:stat.h statrep_.c:statrep.h style_.c:style.h sync_.c:sync.h tag_.c:tag.h tar_.c:tar.h terminal_.c:terminal.h th_main_.c:th_main.h timeline_.c:timeline.h tkt_.c:tkt.h tktsetup_.c:tktsetup.h undo_.c:undo.h unicode_.c:unicode.h unversioned_.c:unversioned.h update_.c:update.h url_.c:url.h user_.c:user.h utf8_.c:utf8.h util_.c:util.h verify_.c:verify.h vfile_.c:vfile.h wiki_.c:wiki.h wikiformat_.c:wikiformat.h winfile_.c:winfile.h winhttp_.c:winhttp.h xfer_.c:xfer.h xfersetup_.c:xfersetup.h zip_.c:zip.h $(SRCDIR_extsrc)\pikchr.c:pikchr.h $(SRCDIR_extsrc)\sqlite3.h $(SRCDIR)\th.h VERSION.h $(SRCDIR_extsrc)\cson_amalgamation.h
1015 @copy /Y nul: headers
1016
--- win/Makefile.dmc
+++ win/Makefile.dmc
@@ -26,19 +26,19 @@
26 CFLAGS = -o
27 BCC = $(DMDIR)\bin\dmc $(CFLAGS)
28 TCC = $(DMDIR)\bin\dmc $(CFLAGS) $(DMCDEF) $(SSL) $(INCL)
29 LIBS = $(DMDIR)\extra\lib\ zlib wsock32 advapi32 dnsapi
30
31 SQLITE_OPTIONS = -DNDEBUG=1 -DSQLITE_DQS=0 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_MEMSTATUS=0 -DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS -DSQLITE_OMIT_DECLTYPE -DSQLITE_OMIT_DEPRECATED -DSQLITE_OMIT_PROGRESS_CALLBACK -DSQLITE_OMIT_SHARED_CACHE -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_MAX_EXPR_DEPTH=0 -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_ENABLE_DBSTAT_VTAB -DSQLITE_ENABLE_EXPLAIN_COMMENTS -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_MATH_FUNCTIONS -DSQLITE_ENABLE_STMTVTAB -DSQLITE_HAVE_ZLIB -DSQLITE_ENABLE_DBPAGE_VTAB -DSQLITE_TRUSTED_SCHEMA=0 -DHAVE_USLEEP
32
33 SHELL_OPTIONS = -DNDEBUG=1 -DSQLITE_DQS=0 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_MEMSTATUS=0 -DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS -DSQLITE_OMIT_DECLTYPE -DSQLITE_OMIT_DEPRECATED -DSQLITE_OMIT_PROGRESS_CALLBACK -DSQLITE_OMIT_SHARED_CACHE -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_MAX_EXPR_DEPTH=0 -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_ENABLE_DBSTAT_VTAB -DSQLITE_ENABLE_EXPLAIN_COMMENTS -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_MATH_FUNCTIONS -DSQLITE_ENABLE_STMTVTAB -DSQLITE_HAVE_ZLIB -DSQLITE_ENABLE_DBPAGE_VTAB -DSQLITE_TRUSTED_SCHEMA=0 -DHAVE_USLEEP -Dmain=sqlite3_shell -DSQLITE_SHELL_IS_UTF8=1 -DSQLITE_OMIT_LOAD_EXTENSION=1 -DUSE_SYSTEM_SQLITE=$(USE_SYSTEM_SQLITE) -DSQLITE_SHELL_DBNAME_PROC=sqlcmd_get_dbname -DSQLITE_SHELL_INIT_PROC=sqlcmd_init_proc -Daccess=file_access -Dsystem=fossil_system -Dgetenv=fossil_getenv -Dfopen=fossil_fopen
34
35 PIKCHR_OPTIONS = -DPIKCHR_TOKEN_LIMIT=10000
36
37 SRC = add_.c ajax_.c alerts_.c allrepo_.c attach_.c backlink_.c backoffice_.c bag_.c bisect_.c blob_.c branch_.c browse_.c builtin_.c bundle_.c cache_.c capabilities_.c captcha_.c cgi_.c chat_.c checkin_.c checkout_.c clearsign_.c clone_.c color_.c comformat_.c configure_.c content_.c cookies_.c db_.c delta_.c deltacmd_.c deltafunc_.c descendants_.c diff_.c diffcmd_.c dispatch_.c doc_.c encode_.c etag_.c event_.c export_.c extcgi_.c file_.c fileedit_.c finfo_.c foci_.c forum_.c fshell_.c fusefs_.c fuzz_.c glob_.c graph_.c gzip_.c hname_.c hook_.c http_.c http_socket_.c http_ssl_.c http_transport_.c import_.c info_.c interwiki_.c json_.c json_artifact_.c json_branch_.c json_config_.c json_diff_.c json_dir_.c json_finfo_.c json_login_.c json_query_.c json_report_.c json_status_.c json_tag_.c json_timeline_.c json_user_.c json_wiki_.c leaf_.c loadctrl_.c login_.c lookslike_.c main_.c manifest_.c markdown_.c markdown_html_.c match_.c md5_.c merge_.c merge3_.c moderate_.c name_.c patch_.c path_.c piechart_.c pikchrshow_.c pivot_.c popen_.c pqueue_.c printf_.c publish_.c purge_.c rebuild_.c regexp_.c repolist_.c report_.c rss_.c schema_.c search_.c security_audit_.c setup_.c setupuser_.c sha1_.c sha1hard_.c sha3_.c shun_.c sitemap_.c skins_.c smtp_.c sqlcmd_.c stash_.c stat_.c statrep_.c style_.c sync_.c tag_.c tar_.c terminal_.c th_main_.c timeline_.c tkt_.c tktsetup_.c undo_.c unicode_.c unversioned_.c update_.c url_.c user_.c utf8_.c util_.c verify_.c vfile_.c wiki_.c wikiformat_.c winfile_.c winhttp_.c xfer_.c xfersetup_.c zip_.c
38
39 OBJ = $(OBJDIR)\add$O $(OBJDIR)\ajax$O $(OBJDIR)\alerts$O $(OBJDIR)\allrepo$O $(OBJDIR)\attach$O $(OBJDIR)\backlink$O $(OBJDIR)\backoffice$O $(OBJDIR)\bag$O $(OBJDIR)\bisect$O $(OBJDIR)\blob$O $(OBJDIR)\branch$O $(OBJDIR)\browse$O $(OBJDIR)\builtin$O $(OBJDIR)\bundle$O $(OBJDIR)\cache$O $(OBJDIR)\capabilities$O $(OBJDIR)\captcha$O $(OBJDIR)\cgi$O $(OBJDIR)\chat$O $(OBJDIR)\checkin$O $(OBJDIR)\checkout$O $(OBJDIR)\clearsign$O $(OBJDIR)\clone$O $(OBJDIR)\color$O $(OBJDIR)\comformat$O $(OBJDIR)\configure$O $(OBJDIR)\content$O $(OBJDIR)\cookies$O $(OBJDIR)\db$O $(OBJDIR)\delta$O $(OBJDIR)\deltacmd$O $(OBJDIR)\deltafunc$O $(OBJDIR)\descendants$O $(OBJDIR)\diff$O $(OBJDIR)\diffcmd$O $(OBJDIR)\dispatch$O $(OBJDIR)\doc$O $(OBJDIR)\encode$O $(OBJDIR)\etag$O $(OBJDIR)\event$O $(OBJDIR)\export$O $(OBJDIR)\extcgi$O $(OBJDIR)\file$O $(OBJDIR)\fileedit$O $(OBJDIR)\finfo$O $(OBJDIR)\foci$O $(OBJDIR)\forum$O $(OBJDIR)\fshell$O $(OBJDIR)\fusefs$O $(OBJDIR)\fuzz$O $(OBJDIR)\glob$O $(OBJDIR)\graph$O $(OBJDIR)\gzip$O $(OBJDIR)\hname$O $(OBJDIR)\hook$O $(OBJDIR)\http$O $(OBJDIR)\http_socket$O $(OBJDIR)\http_ssl$O $(OBJDIR)\http_transport$O $(OBJDIR)\import$O $(OBJDIR)\info$O $(OBJDIR)\interwiki$O $(OBJDIR)\json$O $(OBJDIR)\json_artifact$O $(OBJDIR)\json_branch$O $(OBJDIR)\json_config$O $(OBJDIR)\json_diff$O $(OBJDIR)\json_dir$O $(OBJDIR)\json_finfo$O $(OBJDIR)\json_login$O $(OBJDIR)\json_query$O $(OBJDIR)\json_report$O $(OBJDIR)\json_status$O $(OBJDIR)\json_tag$O $(OBJDIR)\json_timeline$O $(OBJDIR)\json_user$O $(OBJDIR)\json_wiki$O $(OBJDIR)\leaf$O $(OBJDIR)\loadctrl$O $(OBJDIR)\login$O $(OBJDIR)\lookslike$O $(OBJDIR)\main$O $(OBJDIR)\manifest$O $(OBJDIR)\markdown$O $(OBJDIR)\markdown_html$O $(OBJDIR)\match$O $(OBJDIR)\md5$O $(OBJDIR)\merge$O $(OBJDIR)\merge3$O $(OBJDIR)\moderate$O $(OBJDIR)\name$O $(OBJDIR)\patch$O $(OBJDIR)\path$O $(OBJDIR)\piechart$O $(OBJDIR)\pikchrshow$O $(OBJDIR)\pivot$O $(OBJDIR)\popen$O $(OBJDIR)\pqueue$O $(OBJDIR)\printf$O $(OBJDIR)\publish$O $(OBJDIR)\purge$O $(OBJDIR)\rebuild$O $(OBJDIR)\regexp$O $(OBJDIR)\repolist$O $(OBJDIR)\report$O $(OBJDIR)\rss$O $(OBJDIR)\schema$O $(OBJDIR)\search$O $(OBJDIR)\security_audit$O $(OBJDIR)\setup$O $(OBJDIR)\setupuser$O $(OBJDIR)\sha1$O $(OBJDIR)\sha1hard$O $(OBJDIR)\sha3$O $(OBJDIR)\shun$O $(OBJDIR)\sitemap$O $(OBJDIR)\skins$O $(OBJDIR)\smtp$O $(OBJDIR)\sqlcmd$O $(OBJDIR)\stash$O $(OBJDIR)\stat$O $(OBJDIR)\statrep$O $(OBJDIR)\style$O $(OBJDIR)\sync$O $(OBJDIR)\tag$O $(OBJDIR)\tar$O $(OBJDIR)\terminal$O $(OBJDIR)\th_main$O $(OBJDIR)\timeline$O $(OBJDIR)\tkt$O $(OBJDIR)\tktsetup$O $(OBJDIR)\undo$O $(OBJDIR)\unicode$O $(OBJDIR)\unversioned$O $(OBJDIR)\update$O $(OBJDIR)\url$O $(OBJDIR)\user$O $(OBJDIR)\utf8$O $(OBJDIR)\util$O $(OBJDIR)\verify$O $(OBJDIR)\vfile$O $(OBJDIR)\wiki$O $(OBJDIR)\wikiformat$O $(OBJDIR)\winfile$O $(OBJDIR)\winhttp$O $(OBJDIR)\xfer$O $(OBJDIR)\xfersetup$O $(OBJDIR)\zip$O $(OBJDIR)\shell$O $(OBJDIR)\sqlite3$O $(OBJDIR)\th$O $(OBJDIR)\th_lang$O
40
41
42 RC=$(DMDIR)\bin\rcc
43 RCFLAGS=-32 -w1 -I$(SRCDIR) /D__DMC__
44
@@ -53,11 +53,11 @@
53
54 $(OBJDIR)\fossil.res: $B\win\fossil.rc
55 $(RC) $(RCFLAGS) -o$@ $**
56
57 $(OBJDIR)\link: $B\win\Makefile.dmc $(OBJDIR)\fossil.res
58 +echo add ajax alerts allrepo attach backlink backoffice bag bisect blob branch browse builtin bundle cache capabilities captcha cgi chat checkin checkout clearsign clone color comformat configure content cookies db delta deltacmd deltafunc descendants diff diffcmd dispatch doc encode etag event export extcgi file fileedit finfo foci forum fshell fusefs fuzz glob graph gzip hname hook http http_socket http_ssl http_transport import info interwiki json json_artifact json_branch json_config json_diff json_dir json_finfo json_login json_query json_report json_status json_tag json_timeline json_user json_wiki leaf loadctrl login lookslike main manifest markdown markdown_html match md5 merge merge3 moderate name patch path piechart pikchrshow pivot popen pqueue printf publish purge rebuild regexp repolist report rss schema search security_audit setup setupuser sha1 sha1hard sha3 shun sitemap skins smtp sqlcmd stash stat statrep style sync tag tar terminal th_main timeline tkt tktsetup undo unicode unversioned update url user utf8 util verify vfile wiki wikiformat winfile winhttp xfer xfersetup zip shell sqlite3 th th_lang > $@
59 +echo fossil >> $@
60 +echo fossil >> $@
61 +echo $(LIBS) >> $@
62 +echo. >> $@
63 +echo fossil >> $@
@@ -635,10 +635,16 @@
635 $(OBJDIR)\markdown_html$O : markdown_html_.c markdown_html.h
636 $(TCC) -o$@ -c markdown_html_.c
637
638 markdown_html_.c : $(SRCDIR)\markdown_html.c
639 +translate$E $** > $@
640
641 $(OBJDIR)\match$O : match_.c match.h
642 $(TCC) -o$@ -c match_.c
643
644 match_.c : $(SRCDIR)\match.c
645 +translate$E $** > $@
646
647 $(OBJDIR)\md5$O : md5_.c md5.h
648 $(TCC) -o$@ -c md5_.c
649
650 md5_.c : $(SRCDIR)\md5.c
@@ -1009,7 +1015,7 @@
1015
1016 zip_.c : $(SRCDIR)\zip.c
1017 +translate$E $** > $@
1018
1019 headers: makeheaders$E page_index.h builtin_data.h VERSION.h
1020 +makeheaders$E add_.c:add.h ajax_.c:ajax.h alerts_.c:alerts.h allrepo_.c:allrepo.h attach_.c:attach.h backlink_.c:backlink.h backoffice_.c:backoffice.h bag_.c:bag.h bisect_.c:bisect.h blob_.c:blob.h branch_.c:branch.h browse_.c:browse.h builtin_.c:builtin.h bundle_.c:bundle.h cache_.c:cache.h capabilities_.c:capabilities.h captcha_.c:captcha.h cgi_.c:cgi.h chat_.c:chat.h checkin_.c:checkin.h checkout_.c:checkout.h clearsign_.c:clearsign.h clone_.c:clone.h color_.c:color.h comformat_.c:comformat.h configure_.c:configure.h content_.c:content.h cookies_.c:cookies.h db_.c:db.h delta_.c:delta.h deltacmd_.c:deltacmd.h deltafunc_.c:deltafunc.h descendants_.c:descendants.h diff_.c:diff.h diffcmd_.c:diffcmd.h dispatch_.c:dispatch.h doc_.c:doc.h encode_.c:encode.h etag_.c:etag.h event_.c:event.h export_.c:export.h extcgi_.c:extcgi.h file_.c:file.h fileedit_.c:fileedit.h finfo_.c:finfo.h foci_.c:foci.h forum_.c:forum.h fshell_.c:fshell.h fusefs_.c:fusefs.h fuzz_.c:fuzz.h glob_.c:glob.h graph_.c:graph.h gzip_.c:gzip.h hname_.c:hname.h hook_.c:hook.h http_.c:http.h http_socket_.c:http_socket.h http_ssl_.c:http_ssl.h http_transport_.c:http_transport.h import_.c:import.h info_.c:info.h interwiki_.c:interwiki.h json_.c:json.h json_artifact_.c:json_artifact.h json_branch_.c:json_branch.h json_config_.c:json_config.h json_diff_.c:json_diff.h json_dir_.c:json_dir.h json_finfo_.c:json_finfo.h json_login_.c:json_login.h json_query_.c:json_query.h json_report_.c:json_report.h json_status_.c:json_status.h json_tag_.c:json_tag.h json_timeline_.c:json_timeline.h json_user_.c:json_user.h json_wiki_.c:json_wiki.h leaf_.c:leaf.h loadctrl_.c:loadctrl.h login_.c:login.h lookslike_.c:lookslike.h main_.c:main.h manifest_.c:manifest.h markdown_.c:markdown.h markdown_html_.c:markdown_html.h match_.c:match.h md5_.c:md5.h merge_.c:merge.h merge3_.c:merge3.h moderate_.c:moderate.h name_.c:name.h patch_.c:patch.h path_.c:path.h piechart_.c:piechart.h pikchrshow_.c:pikchrshow.h pivot_.c:pivot.h popen_.c:popen.h pqueue_.c:pqueue.h printf_.c:printf.h publish_.c:publish.h purge_.c:purge.h rebuild_.c:rebuild.h regexp_.c:regexp.h repolist_.c:repolist.h report_.c:report.h rss_.c:rss.h schema_.c:schema.h search_.c:search.h security_audit_.c:security_audit.h setup_.c:setup.h setupuser_.c:setupuser.h sha1_.c:sha1.h sha1hard_.c:sha1hard.h sha3_.c:sha3.h shun_.c:shun.h sitemap_.c:sitemap.h skins_.c:skins.h smtp_.c:smtp.h sqlcmd_.c:sqlcmd.h stash_.c:stash.h stat_.c:stat.h statrep_.c:statrep.h style_.c:style.h sync_.c:sync.h tag_.c:tag.h tar_.c:tar.h terminal_.c:terminal.h th_main_.c:th_main.h timeline_.c:timeline.h tkt_.c:tkt.h tktsetup_.c:tktsetup.h undo_.c:undo.h unicode_.c:unicode.h unversioned_.c:unversioned.h update_.c:update.h url_.c:url.h user_.c:user.h utf8_.c:utf8.h util_.c:util.h verify_.c:verify.h vfile_.c:vfile.h wiki_.c:wiki.h wikiformat_.c:wikiformat.h winfile_.c:winfile.h winhttp_.c:winhttp.h xfer_.c:xfer.h xfersetup_.c:xfersetup.h zip_.c:zip.h $(SRCDIR_extsrc)\pikchr.c:pikchr.h $(SRCDIR_extsrc)\sqlite3.h $(SRCDIR)\th.h VERSION.h $(SRCDIR_extsrc)\cson_amalgamation.h
1021 @copy /Y nul: headers
1022
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -485,10 +485,11 @@
485485
$(SRCDIR)/lookslike.c \
486486
$(SRCDIR)/main.c \
487487
$(SRCDIR)/manifest.c \
488488
$(SRCDIR)/markdown.c \
489489
$(SRCDIR)/markdown_html.c \
490
+ $(SRCDIR)/match.c \
490491
$(SRCDIR)/md5.c \
491492
$(SRCDIR)/merge.c \
492493
$(SRCDIR)/merge3.c \
493494
$(SRCDIR)/moderate.c \
494495
$(SRCDIR)/name.c \
@@ -750,10 +751,11 @@
750751
$(OBJDIR)/lookslike_.c \
751752
$(OBJDIR)/main_.c \
752753
$(OBJDIR)/manifest_.c \
753754
$(OBJDIR)/markdown_.c \
754755
$(OBJDIR)/markdown_html_.c \
756
+ $(OBJDIR)/match_.c \
755757
$(OBJDIR)/md5_.c \
756758
$(OBJDIR)/merge_.c \
757759
$(OBJDIR)/merge3_.c \
758760
$(OBJDIR)/moderate_.c \
759761
$(OBJDIR)/name_.c \
@@ -899,10 +901,11 @@
899901
$(OBJDIR)/lookslike.o \
900902
$(OBJDIR)/main.o \
901903
$(OBJDIR)/manifest.o \
902904
$(OBJDIR)/markdown.o \
903905
$(OBJDIR)/markdown_html.o \
906
+ $(OBJDIR)/match.o \
904907
$(OBJDIR)/md5.o \
905908
$(OBJDIR)/merge.o \
906909
$(OBJDIR)/merge3.o \
907910
$(OBJDIR)/moderate.o \
908911
$(OBJDIR)/name.o \
@@ -1252,10 +1255,11 @@
12521255
$(OBJDIR)/lookslike_.c:$(OBJDIR)/lookslike.h \
12531256
$(OBJDIR)/main_.c:$(OBJDIR)/main.h \
12541257
$(OBJDIR)/manifest_.c:$(OBJDIR)/manifest.h \
12551258
$(OBJDIR)/markdown_.c:$(OBJDIR)/markdown.h \
12561259
$(OBJDIR)/markdown_html_.c:$(OBJDIR)/markdown_html.h \
1260
+ $(OBJDIR)/match_.c:$(OBJDIR)/match.h \
12571261
$(OBJDIR)/md5_.c:$(OBJDIR)/md5.h \
12581262
$(OBJDIR)/merge_.c:$(OBJDIR)/merge.h \
12591263
$(OBJDIR)/merge3_.c:$(OBJDIR)/merge3.h \
12601264
$(OBJDIR)/moderate_.c:$(OBJDIR)/moderate.h \
12611265
$(OBJDIR)/name_.c:$(OBJDIR)/name.h \
@@ -2003,10 +2007,18 @@
20032007
20042008
$(OBJDIR)/markdown_html.o: $(OBJDIR)/markdown_html_.c $(OBJDIR)/markdown_html.h $(SRCDIR)/config.h
20052009
$(XTCC) -o $(OBJDIR)/markdown_html.o -c $(OBJDIR)/markdown_html_.c
20062010
20072011
$(OBJDIR)/markdown_html.h: $(OBJDIR)/headers
2012
+
2013
+$(OBJDIR)/match_.c: $(SRCDIR)/match.c $(TRANSLATE)
2014
+ $(TRANSLATE) $(SRCDIR)/match.c >$@
2015
+
2016
+$(OBJDIR)/match.o: $(OBJDIR)/match_.c $(OBJDIR)/match.h $(SRCDIR)/config.h
2017
+ $(XTCC) -o $(OBJDIR)/match.o -c $(OBJDIR)/match_.c
2018
+
2019
+$(OBJDIR)/match.h: $(OBJDIR)/headers
20082020
20092021
$(OBJDIR)/md5_.c: $(SRCDIR)/md5.c $(TRANSLATE)
20102022
$(TRANSLATE) $(SRCDIR)/md5.c >$@
20112023
20122024
$(OBJDIR)/md5.o: $(OBJDIR)/md5_.c $(OBJDIR)/md5.h $(SRCDIR)/config.h
@@ -2516,14 +2528,15 @@
25162528
-DSQLITE_OMIT_SHARED_CACHE \
25172529
-DSQLITE_OMIT_LOAD_EXTENSION \
25182530
-DSQLITE_MAX_EXPR_DEPTH=0 \
25192531
-DSQLITE_ENABLE_LOCKING_STYLE=0 \
25202532
-DSQLITE_DEFAULT_FILE_FORMAT=4 \
2533
+ -DSQLITE_ENABLE_DBSTAT_VTAB \
25212534
-DSQLITE_ENABLE_EXPLAIN_COMMENTS \
25222535
-DSQLITE_ENABLE_FTS4 \
2523
- -DSQLITE_ENABLE_DBSTAT_VTAB \
25242536
-DSQLITE_ENABLE_FTS5 \
2537
+ -DSQLITE_ENABLE_MATH_FUNCTIONS \
25252538
-DSQLITE_ENABLE_STMTVTAB \
25262539
-DSQLITE_HAVE_ZLIB \
25272540
-DSQLITE_ENABLE_DBPAGE_VTAB \
25282541
-DSQLITE_TRUSTED_SCHEMA=0 \
25292542
-DHAVE_USLEEP \
@@ -2544,14 +2557,15 @@
25442557
-DSQLITE_OMIT_SHARED_CACHE \
25452558
-DSQLITE_OMIT_LOAD_EXTENSION \
25462559
-DSQLITE_MAX_EXPR_DEPTH=0 \
25472560
-DSQLITE_ENABLE_LOCKING_STYLE=0 \
25482561
-DSQLITE_DEFAULT_FILE_FORMAT=4 \
2562
+ -DSQLITE_ENABLE_DBSTAT_VTAB \
25492563
-DSQLITE_ENABLE_EXPLAIN_COMMENTS \
25502564
-DSQLITE_ENABLE_FTS4 \
2551
- -DSQLITE_ENABLE_DBSTAT_VTAB \
25522565
-DSQLITE_ENABLE_FTS5 \
2566
+ -DSQLITE_ENABLE_MATH_FUNCTIONS \
25532567
-DSQLITE_ENABLE_STMTVTAB \
25542568
-DSQLITE_HAVE_ZLIB \
25552569
-DSQLITE_ENABLE_DBPAGE_VTAB \
25562570
-DSQLITE_TRUSTED_SCHEMA=0 \
25572571
-DHAVE_USLEEP \
25582572
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -485,10 +485,11 @@
485 $(SRCDIR)/lookslike.c \
486 $(SRCDIR)/main.c \
487 $(SRCDIR)/manifest.c \
488 $(SRCDIR)/markdown.c \
489 $(SRCDIR)/markdown_html.c \
 
490 $(SRCDIR)/md5.c \
491 $(SRCDIR)/merge.c \
492 $(SRCDIR)/merge3.c \
493 $(SRCDIR)/moderate.c \
494 $(SRCDIR)/name.c \
@@ -750,10 +751,11 @@
750 $(OBJDIR)/lookslike_.c \
751 $(OBJDIR)/main_.c \
752 $(OBJDIR)/manifest_.c \
753 $(OBJDIR)/markdown_.c \
754 $(OBJDIR)/markdown_html_.c \
 
755 $(OBJDIR)/md5_.c \
756 $(OBJDIR)/merge_.c \
757 $(OBJDIR)/merge3_.c \
758 $(OBJDIR)/moderate_.c \
759 $(OBJDIR)/name_.c \
@@ -899,10 +901,11 @@
899 $(OBJDIR)/lookslike.o \
900 $(OBJDIR)/main.o \
901 $(OBJDIR)/manifest.o \
902 $(OBJDIR)/markdown.o \
903 $(OBJDIR)/markdown_html.o \
 
904 $(OBJDIR)/md5.o \
905 $(OBJDIR)/merge.o \
906 $(OBJDIR)/merge3.o \
907 $(OBJDIR)/moderate.o \
908 $(OBJDIR)/name.o \
@@ -1252,10 +1255,11 @@
1252 $(OBJDIR)/lookslike_.c:$(OBJDIR)/lookslike.h \
1253 $(OBJDIR)/main_.c:$(OBJDIR)/main.h \
1254 $(OBJDIR)/manifest_.c:$(OBJDIR)/manifest.h \
1255 $(OBJDIR)/markdown_.c:$(OBJDIR)/markdown.h \
1256 $(OBJDIR)/markdown_html_.c:$(OBJDIR)/markdown_html.h \
 
1257 $(OBJDIR)/md5_.c:$(OBJDIR)/md5.h \
1258 $(OBJDIR)/merge_.c:$(OBJDIR)/merge.h \
1259 $(OBJDIR)/merge3_.c:$(OBJDIR)/merge3.h \
1260 $(OBJDIR)/moderate_.c:$(OBJDIR)/moderate.h \
1261 $(OBJDIR)/name_.c:$(OBJDIR)/name.h \
@@ -2003,10 +2007,18 @@
2003
2004 $(OBJDIR)/markdown_html.o: $(OBJDIR)/markdown_html_.c $(OBJDIR)/markdown_html.h $(SRCDIR)/config.h
2005 $(XTCC) -o $(OBJDIR)/markdown_html.o -c $(OBJDIR)/markdown_html_.c
2006
2007 $(OBJDIR)/markdown_html.h: $(OBJDIR)/headers
 
 
 
 
 
 
 
 
2008
2009 $(OBJDIR)/md5_.c: $(SRCDIR)/md5.c $(TRANSLATE)
2010 $(TRANSLATE) $(SRCDIR)/md5.c >$@
2011
2012 $(OBJDIR)/md5.o: $(OBJDIR)/md5_.c $(OBJDIR)/md5.h $(SRCDIR)/config.h
@@ -2516,14 +2528,15 @@
2516 -DSQLITE_OMIT_SHARED_CACHE \
2517 -DSQLITE_OMIT_LOAD_EXTENSION \
2518 -DSQLITE_MAX_EXPR_DEPTH=0 \
2519 -DSQLITE_ENABLE_LOCKING_STYLE=0 \
2520 -DSQLITE_DEFAULT_FILE_FORMAT=4 \
 
2521 -DSQLITE_ENABLE_EXPLAIN_COMMENTS \
2522 -DSQLITE_ENABLE_FTS4 \
2523 -DSQLITE_ENABLE_DBSTAT_VTAB \
2524 -DSQLITE_ENABLE_FTS5 \
 
2525 -DSQLITE_ENABLE_STMTVTAB \
2526 -DSQLITE_HAVE_ZLIB \
2527 -DSQLITE_ENABLE_DBPAGE_VTAB \
2528 -DSQLITE_TRUSTED_SCHEMA=0 \
2529 -DHAVE_USLEEP \
@@ -2544,14 +2557,15 @@
2544 -DSQLITE_OMIT_SHARED_CACHE \
2545 -DSQLITE_OMIT_LOAD_EXTENSION \
2546 -DSQLITE_MAX_EXPR_DEPTH=0 \
2547 -DSQLITE_ENABLE_LOCKING_STYLE=0 \
2548 -DSQLITE_DEFAULT_FILE_FORMAT=4 \
 
2549 -DSQLITE_ENABLE_EXPLAIN_COMMENTS \
2550 -DSQLITE_ENABLE_FTS4 \
2551 -DSQLITE_ENABLE_DBSTAT_VTAB \
2552 -DSQLITE_ENABLE_FTS5 \
 
2553 -DSQLITE_ENABLE_STMTVTAB \
2554 -DSQLITE_HAVE_ZLIB \
2555 -DSQLITE_ENABLE_DBPAGE_VTAB \
2556 -DSQLITE_TRUSTED_SCHEMA=0 \
2557 -DHAVE_USLEEP \
2558
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -485,10 +485,11 @@
485 $(SRCDIR)/lookslike.c \
486 $(SRCDIR)/main.c \
487 $(SRCDIR)/manifest.c \
488 $(SRCDIR)/markdown.c \
489 $(SRCDIR)/markdown_html.c \
490 $(SRCDIR)/match.c \
491 $(SRCDIR)/md5.c \
492 $(SRCDIR)/merge.c \
493 $(SRCDIR)/merge3.c \
494 $(SRCDIR)/moderate.c \
495 $(SRCDIR)/name.c \
@@ -750,10 +751,11 @@
751 $(OBJDIR)/lookslike_.c \
752 $(OBJDIR)/main_.c \
753 $(OBJDIR)/manifest_.c \
754 $(OBJDIR)/markdown_.c \
755 $(OBJDIR)/markdown_html_.c \
756 $(OBJDIR)/match_.c \
757 $(OBJDIR)/md5_.c \
758 $(OBJDIR)/merge_.c \
759 $(OBJDIR)/merge3_.c \
760 $(OBJDIR)/moderate_.c \
761 $(OBJDIR)/name_.c \
@@ -899,10 +901,11 @@
901 $(OBJDIR)/lookslike.o \
902 $(OBJDIR)/main.o \
903 $(OBJDIR)/manifest.o \
904 $(OBJDIR)/markdown.o \
905 $(OBJDIR)/markdown_html.o \
906 $(OBJDIR)/match.o \
907 $(OBJDIR)/md5.o \
908 $(OBJDIR)/merge.o \
909 $(OBJDIR)/merge3.o \
910 $(OBJDIR)/moderate.o \
911 $(OBJDIR)/name.o \
@@ -1252,10 +1255,11 @@
1255 $(OBJDIR)/lookslike_.c:$(OBJDIR)/lookslike.h \
1256 $(OBJDIR)/main_.c:$(OBJDIR)/main.h \
1257 $(OBJDIR)/manifest_.c:$(OBJDIR)/manifest.h \
1258 $(OBJDIR)/markdown_.c:$(OBJDIR)/markdown.h \
1259 $(OBJDIR)/markdown_html_.c:$(OBJDIR)/markdown_html.h \
1260 $(OBJDIR)/match_.c:$(OBJDIR)/match.h \
1261 $(OBJDIR)/md5_.c:$(OBJDIR)/md5.h \
1262 $(OBJDIR)/merge_.c:$(OBJDIR)/merge.h \
1263 $(OBJDIR)/merge3_.c:$(OBJDIR)/merge3.h \
1264 $(OBJDIR)/moderate_.c:$(OBJDIR)/moderate.h \
1265 $(OBJDIR)/name_.c:$(OBJDIR)/name.h \
@@ -2003,10 +2007,18 @@
2007
2008 $(OBJDIR)/markdown_html.o: $(OBJDIR)/markdown_html_.c $(OBJDIR)/markdown_html.h $(SRCDIR)/config.h
2009 $(XTCC) -o $(OBJDIR)/markdown_html.o -c $(OBJDIR)/markdown_html_.c
2010
2011 $(OBJDIR)/markdown_html.h: $(OBJDIR)/headers
2012
2013 $(OBJDIR)/match_.c: $(SRCDIR)/match.c $(TRANSLATE)
2014 $(TRANSLATE) $(SRCDIR)/match.c >$@
2015
2016 $(OBJDIR)/match.o: $(OBJDIR)/match_.c $(OBJDIR)/match.h $(SRCDIR)/config.h
2017 $(XTCC) -o $(OBJDIR)/match.o -c $(OBJDIR)/match_.c
2018
2019 $(OBJDIR)/match.h: $(OBJDIR)/headers
2020
2021 $(OBJDIR)/md5_.c: $(SRCDIR)/md5.c $(TRANSLATE)
2022 $(TRANSLATE) $(SRCDIR)/md5.c >$@
2023
2024 $(OBJDIR)/md5.o: $(OBJDIR)/md5_.c $(OBJDIR)/md5.h $(SRCDIR)/config.h
@@ -2516,14 +2528,15 @@
2528 -DSQLITE_OMIT_SHARED_CACHE \
2529 -DSQLITE_OMIT_LOAD_EXTENSION \
2530 -DSQLITE_MAX_EXPR_DEPTH=0 \
2531 -DSQLITE_ENABLE_LOCKING_STYLE=0 \
2532 -DSQLITE_DEFAULT_FILE_FORMAT=4 \
2533 -DSQLITE_ENABLE_DBSTAT_VTAB \
2534 -DSQLITE_ENABLE_EXPLAIN_COMMENTS \
2535 -DSQLITE_ENABLE_FTS4 \
 
2536 -DSQLITE_ENABLE_FTS5 \
2537 -DSQLITE_ENABLE_MATH_FUNCTIONS \
2538 -DSQLITE_ENABLE_STMTVTAB \
2539 -DSQLITE_HAVE_ZLIB \
2540 -DSQLITE_ENABLE_DBPAGE_VTAB \
2541 -DSQLITE_TRUSTED_SCHEMA=0 \
2542 -DHAVE_USLEEP \
@@ -2544,14 +2557,15 @@
2557 -DSQLITE_OMIT_SHARED_CACHE \
2558 -DSQLITE_OMIT_LOAD_EXTENSION \
2559 -DSQLITE_MAX_EXPR_DEPTH=0 \
2560 -DSQLITE_ENABLE_LOCKING_STYLE=0 \
2561 -DSQLITE_DEFAULT_FILE_FORMAT=4 \
2562 -DSQLITE_ENABLE_DBSTAT_VTAB \
2563 -DSQLITE_ENABLE_EXPLAIN_COMMENTS \
2564 -DSQLITE_ENABLE_FTS4 \
 
2565 -DSQLITE_ENABLE_FTS5 \
2566 -DSQLITE_ENABLE_MATH_FUNCTIONS \
2567 -DSQLITE_ENABLE_STMTVTAB \
2568 -DSQLITE_HAVE_ZLIB \
2569 -DSQLITE_ENABLE_DBPAGE_VTAB \
2570 -DSQLITE_TRUSTED_SCHEMA=0 \
2571 -DHAVE_USLEEP \
2572
+14 -2
--- win/Makefile.msc
+++ win/Makefile.msc
@@ -311,14 +311,15 @@
311311
/DSQLITE_OMIT_SHARED_CACHE \
312312
/DSQLITE_OMIT_LOAD_EXTENSION \
313313
/DSQLITE_MAX_EXPR_DEPTH=0 \
314314
/DSQLITE_ENABLE_LOCKING_STYLE=0 \
315315
/DSQLITE_DEFAULT_FILE_FORMAT=4 \
316
+ /DSQLITE_ENABLE_DBSTAT_VTAB \
316317
/DSQLITE_ENABLE_EXPLAIN_COMMENTS \
317318
/DSQLITE_ENABLE_FTS4 \
318
- /DSQLITE_ENABLE_DBSTAT_VTAB \
319319
/DSQLITE_ENABLE_FTS5 \
320
+ /DSQLITE_ENABLE_MATH_FUNCTIONS \
320321
/DSQLITE_ENABLE_STMTVTAB \
321322
/DSQLITE_HAVE_ZLIB \
322323
/DSQLITE_ENABLE_DBPAGE_VTAB \
323324
/DSQLITE_TRUSTED_SCHEMA=0 \
324325
/DHAVE_USLEEP \
@@ -336,14 +337,15 @@
336337
/DSQLITE_OMIT_SHARED_CACHE \
337338
/DSQLITE_OMIT_LOAD_EXTENSION \
338339
/DSQLITE_MAX_EXPR_DEPTH=0 \
339340
/DSQLITE_ENABLE_LOCKING_STYLE=0 \
340341
/DSQLITE_DEFAULT_FILE_FORMAT=4 \
342
+ /DSQLITE_ENABLE_DBSTAT_VTAB \
341343
/DSQLITE_ENABLE_EXPLAIN_COMMENTS \
342344
/DSQLITE_ENABLE_FTS4 \
343
- /DSQLITE_ENABLE_DBSTAT_VTAB \
344345
/DSQLITE_ENABLE_FTS5 \
346
+ /DSQLITE_ENABLE_MATH_FUNCTIONS \
345347
/DSQLITE_ENABLE_STMTVTAB \
346348
/DSQLITE_HAVE_ZLIB \
347349
/DSQLITE_ENABLE_DBPAGE_VTAB \
348350
/DSQLITE_TRUSTED_SCHEMA=0 \
349351
/DHAVE_USLEEP \
@@ -443,10 +445,11 @@
443445
"$(OX)\lookslike_.c" \
444446
"$(OX)\main_.c" \
445447
"$(OX)\manifest_.c" \
446448
"$(OX)\markdown_.c" \
447449
"$(OX)\markdown_html_.c" \
450
+ "$(OX)\match_.c" \
448451
"$(OX)\md5_.c" \
449452
"$(OX)\merge_.c" \
450453
"$(OX)\merge3_.c" \
451454
"$(OX)\moderate_.c" \
452455
"$(OX)\name_.c" \
@@ -708,10 +711,11 @@
708711
"$(OX)\lookslike$O" \
709712
"$(OX)\main$O" \
710713
"$(OX)\manifest$O" \
711714
"$(OX)\markdown$O" \
712715
"$(OX)\markdown_html$O" \
716
+ "$(OX)\match$O" \
713717
"$(OX)\md5$O" \
714718
"$(OX)\merge$O" \
715719
"$(OX)\merge3$O" \
716720
"$(OX)\moderate$O" \
717721
"$(OX)\name$O" \
@@ -957,10 +961,11 @@
957961
echo "$(OX)\lookslike.obj" >> $@
958962
echo "$(OX)\main.obj" >> $@
959963
echo "$(OX)\manifest.obj" >> $@
960964
echo "$(OX)\markdown.obj" >> $@
961965
echo "$(OX)\markdown_html.obj" >> $@
966
+ echo "$(OX)\match.obj" >> $@
962967
echo "$(OX)\md5.obj" >> $@
963968
echo "$(OX)\merge.obj" >> $@
964969
echo "$(OX)\merge3.obj" >> $@
965970
echo "$(OX)\moderate.obj" >> $@
966971
echo "$(OX)\name.obj" >> $@
@@ -1762,10 +1767,16 @@
17621767
"$(OX)\markdown_html$O" : "$(OX)\markdown_html_.c" "$(OX)\markdown_html.h"
17631768
$(TCC) /Fo$@ /Fd$(@D)\ -c "$(OX)\markdown_html_.c"
17641769
17651770
"$(OX)\markdown_html_.c" : "$(SRCDIR)\markdown_html.c"
17661771
"$(OBJDIR)\translate$E" $** > $@
1772
+
1773
+"$(OX)\match$O" : "$(OX)\match_.c" "$(OX)\match.h"
1774
+ $(TCC) /Fo$@ /Fd$(@D)\ -c "$(OX)\match_.c"
1775
+
1776
+"$(OX)\match_.c" : "$(SRCDIR)\match.c"
1777
+ "$(OBJDIR)\translate$E" $** > $@
17671778
17681779
"$(OX)\md5$O" : "$(OX)\md5_.c" "$(OX)\md5.h"
17691780
$(TCC) /Fo$@ /Fd$(@D)\ -c "$(OX)\md5_.c"
17701781
17711782
"$(OX)\md5_.c" : "$(SRCDIR)\md5.c"
@@ -2224,10 +2235,11 @@
22242235
"$(OX)\lookslike_.c":"$(OX)\lookslike.h" \
22252236
"$(OX)\main_.c":"$(OX)\main.h" \
22262237
"$(OX)\manifest_.c":"$(OX)\manifest.h" \
22272238
"$(OX)\markdown_.c":"$(OX)\markdown.h" \
22282239
"$(OX)\markdown_html_.c":"$(OX)\markdown_html.h" \
2240
+ "$(OX)\match_.c":"$(OX)\match.h" \
22292241
"$(OX)\md5_.c":"$(OX)\md5.h" \
22302242
"$(OX)\merge_.c":"$(OX)\merge.h" \
22312243
"$(OX)\merge3_.c":"$(OX)\merge3.h" \
22322244
"$(OX)\moderate_.c":"$(OX)\moderate.h" \
22332245
"$(OX)\name_.c":"$(OX)\name.h" \
22342246
--- win/Makefile.msc
+++ win/Makefile.msc
@@ -311,14 +311,15 @@
311 /DSQLITE_OMIT_SHARED_CACHE \
312 /DSQLITE_OMIT_LOAD_EXTENSION \
313 /DSQLITE_MAX_EXPR_DEPTH=0 \
314 /DSQLITE_ENABLE_LOCKING_STYLE=0 \
315 /DSQLITE_DEFAULT_FILE_FORMAT=4 \
 
316 /DSQLITE_ENABLE_EXPLAIN_COMMENTS \
317 /DSQLITE_ENABLE_FTS4 \
318 /DSQLITE_ENABLE_DBSTAT_VTAB \
319 /DSQLITE_ENABLE_FTS5 \
 
320 /DSQLITE_ENABLE_STMTVTAB \
321 /DSQLITE_HAVE_ZLIB \
322 /DSQLITE_ENABLE_DBPAGE_VTAB \
323 /DSQLITE_TRUSTED_SCHEMA=0 \
324 /DHAVE_USLEEP \
@@ -336,14 +337,15 @@
336 /DSQLITE_OMIT_SHARED_CACHE \
337 /DSQLITE_OMIT_LOAD_EXTENSION \
338 /DSQLITE_MAX_EXPR_DEPTH=0 \
339 /DSQLITE_ENABLE_LOCKING_STYLE=0 \
340 /DSQLITE_DEFAULT_FILE_FORMAT=4 \
 
341 /DSQLITE_ENABLE_EXPLAIN_COMMENTS \
342 /DSQLITE_ENABLE_FTS4 \
343 /DSQLITE_ENABLE_DBSTAT_VTAB \
344 /DSQLITE_ENABLE_FTS5 \
 
345 /DSQLITE_ENABLE_STMTVTAB \
346 /DSQLITE_HAVE_ZLIB \
347 /DSQLITE_ENABLE_DBPAGE_VTAB \
348 /DSQLITE_TRUSTED_SCHEMA=0 \
349 /DHAVE_USLEEP \
@@ -443,10 +445,11 @@
443 "$(OX)\lookslike_.c" \
444 "$(OX)\main_.c" \
445 "$(OX)\manifest_.c" \
446 "$(OX)\markdown_.c" \
447 "$(OX)\markdown_html_.c" \
 
448 "$(OX)\md5_.c" \
449 "$(OX)\merge_.c" \
450 "$(OX)\merge3_.c" \
451 "$(OX)\moderate_.c" \
452 "$(OX)\name_.c" \
@@ -708,10 +711,11 @@
708 "$(OX)\lookslike$O" \
709 "$(OX)\main$O" \
710 "$(OX)\manifest$O" \
711 "$(OX)\markdown$O" \
712 "$(OX)\markdown_html$O" \
 
713 "$(OX)\md5$O" \
714 "$(OX)\merge$O" \
715 "$(OX)\merge3$O" \
716 "$(OX)\moderate$O" \
717 "$(OX)\name$O" \
@@ -957,10 +961,11 @@
957 echo "$(OX)\lookslike.obj" >> $@
958 echo "$(OX)\main.obj" >> $@
959 echo "$(OX)\manifest.obj" >> $@
960 echo "$(OX)\markdown.obj" >> $@
961 echo "$(OX)\markdown_html.obj" >> $@
 
962 echo "$(OX)\md5.obj" >> $@
963 echo "$(OX)\merge.obj" >> $@
964 echo "$(OX)\merge3.obj" >> $@
965 echo "$(OX)\moderate.obj" >> $@
966 echo "$(OX)\name.obj" >> $@
@@ -1762,10 +1767,16 @@
1762 "$(OX)\markdown_html$O" : "$(OX)\markdown_html_.c" "$(OX)\markdown_html.h"
1763 $(TCC) /Fo$@ /Fd$(@D)\ -c "$(OX)\markdown_html_.c"
1764
1765 "$(OX)\markdown_html_.c" : "$(SRCDIR)\markdown_html.c"
1766 "$(OBJDIR)\translate$E" $** > $@
 
 
 
 
 
 
1767
1768 "$(OX)\md5$O" : "$(OX)\md5_.c" "$(OX)\md5.h"
1769 $(TCC) /Fo$@ /Fd$(@D)\ -c "$(OX)\md5_.c"
1770
1771 "$(OX)\md5_.c" : "$(SRCDIR)\md5.c"
@@ -2224,10 +2235,11 @@
2224 "$(OX)\lookslike_.c":"$(OX)\lookslike.h" \
2225 "$(OX)\main_.c":"$(OX)\main.h" \
2226 "$(OX)\manifest_.c":"$(OX)\manifest.h" \
2227 "$(OX)\markdown_.c":"$(OX)\markdown.h" \
2228 "$(OX)\markdown_html_.c":"$(OX)\markdown_html.h" \
 
2229 "$(OX)\md5_.c":"$(OX)\md5.h" \
2230 "$(OX)\merge_.c":"$(OX)\merge.h" \
2231 "$(OX)\merge3_.c":"$(OX)\merge3.h" \
2232 "$(OX)\moderate_.c":"$(OX)\moderate.h" \
2233 "$(OX)\name_.c":"$(OX)\name.h" \
2234
--- win/Makefile.msc
+++ win/Makefile.msc
@@ -311,14 +311,15 @@
311 /DSQLITE_OMIT_SHARED_CACHE \
312 /DSQLITE_OMIT_LOAD_EXTENSION \
313 /DSQLITE_MAX_EXPR_DEPTH=0 \
314 /DSQLITE_ENABLE_LOCKING_STYLE=0 \
315 /DSQLITE_DEFAULT_FILE_FORMAT=4 \
316 /DSQLITE_ENABLE_DBSTAT_VTAB \
317 /DSQLITE_ENABLE_EXPLAIN_COMMENTS \
318 /DSQLITE_ENABLE_FTS4 \
 
319 /DSQLITE_ENABLE_FTS5 \
320 /DSQLITE_ENABLE_MATH_FUNCTIONS \
321 /DSQLITE_ENABLE_STMTVTAB \
322 /DSQLITE_HAVE_ZLIB \
323 /DSQLITE_ENABLE_DBPAGE_VTAB \
324 /DSQLITE_TRUSTED_SCHEMA=0 \
325 /DHAVE_USLEEP \
@@ -336,14 +337,15 @@
337 /DSQLITE_OMIT_SHARED_CACHE \
338 /DSQLITE_OMIT_LOAD_EXTENSION \
339 /DSQLITE_MAX_EXPR_DEPTH=0 \
340 /DSQLITE_ENABLE_LOCKING_STYLE=0 \
341 /DSQLITE_DEFAULT_FILE_FORMAT=4 \
342 /DSQLITE_ENABLE_DBSTAT_VTAB \
343 /DSQLITE_ENABLE_EXPLAIN_COMMENTS \
344 /DSQLITE_ENABLE_FTS4 \
 
345 /DSQLITE_ENABLE_FTS5 \
346 /DSQLITE_ENABLE_MATH_FUNCTIONS \
347 /DSQLITE_ENABLE_STMTVTAB \
348 /DSQLITE_HAVE_ZLIB \
349 /DSQLITE_ENABLE_DBPAGE_VTAB \
350 /DSQLITE_TRUSTED_SCHEMA=0 \
351 /DHAVE_USLEEP \
@@ -443,10 +445,11 @@
445 "$(OX)\lookslike_.c" \
446 "$(OX)\main_.c" \
447 "$(OX)\manifest_.c" \
448 "$(OX)\markdown_.c" \
449 "$(OX)\markdown_html_.c" \
450 "$(OX)\match_.c" \
451 "$(OX)\md5_.c" \
452 "$(OX)\merge_.c" \
453 "$(OX)\merge3_.c" \
454 "$(OX)\moderate_.c" \
455 "$(OX)\name_.c" \
@@ -708,10 +711,11 @@
711 "$(OX)\lookslike$O" \
712 "$(OX)\main$O" \
713 "$(OX)\manifest$O" \
714 "$(OX)\markdown$O" \
715 "$(OX)\markdown_html$O" \
716 "$(OX)\match$O" \
717 "$(OX)\md5$O" \
718 "$(OX)\merge$O" \
719 "$(OX)\merge3$O" \
720 "$(OX)\moderate$O" \
721 "$(OX)\name$O" \
@@ -957,10 +961,11 @@
961 echo "$(OX)\lookslike.obj" >> $@
962 echo "$(OX)\main.obj" >> $@
963 echo "$(OX)\manifest.obj" >> $@
964 echo "$(OX)\markdown.obj" >> $@
965 echo "$(OX)\markdown_html.obj" >> $@
966 echo "$(OX)\match.obj" >> $@
967 echo "$(OX)\md5.obj" >> $@
968 echo "$(OX)\merge.obj" >> $@
969 echo "$(OX)\merge3.obj" >> $@
970 echo "$(OX)\moderate.obj" >> $@
971 echo "$(OX)\name.obj" >> $@
@@ -1762,10 +1767,16 @@
1767 "$(OX)\markdown_html$O" : "$(OX)\markdown_html_.c" "$(OX)\markdown_html.h"
1768 $(TCC) /Fo$@ /Fd$(@D)\ -c "$(OX)\markdown_html_.c"
1769
1770 "$(OX)\markdown_html_.c" : "$(SRCDIR)\markdown_html.c"
1771 "$(OBJDIR)\translate$E" $** > $@
1772
1773 "$(OX)\match$O" : "$(OX)\match_.c" "$(OX)\match.h"
1774 $(TCC) /Fo$@ /Fd$(@D)\ -c "$(OX)\match_.c"
1775
1776 "$(OX)\match_.c" : "$(SRCDIR)\match.c"
1777 "$(OBJDIR)\translate$E" $** > $@
1778
1779 "$(OX)\md5$O" : "$(OX)\md5_.c" "$(OX)\md5.h"
1780 $(TCC) /Fo$@ /Fd$(@D)\ -c "$(OX)\md5_.c"
1781
1782 "$(OX)\md5_.c" : "$(SRCDIR)\md5.c"
@@ -2224,10 +2235,11 @@
2235 "$(OX)\lookslike_.c":"$(OX)\lookslike.h" \
2236 "$(OX)\main_.c":"$(OX)\main.h" \
2237 "$(OX)\manifest_.c":"$(OX)\manifest.h" \
2238 "$(OX)\markdown_.c":"$(OX)\markdown.h" \
2239 "$(OX)\markdown_html_.c":"$(OX)\markdown_html.h" \
2240 "$(OX)\match_.c":"$(OX)\match.h" \
2241 "$(OX)\md5_.c":"$(OX)\md5.h" \
2242 "$(OX)\merge_.c":"$(OX)\merge.h" \
2243 "$(OX)\merge3_.c":"$(OX)\merge3.h" \
2244 "$(OX)\moderate_.c":"$(OX)\moderate.h" \
2245 "$(OX)\name_.c":"$(OX)\name.h" \
2246
+4 -8
--- www/alerts.md
+++ www/alerts.md
@@ -34,15 +34,10 @@
3434
on the Fossil server that will be sending these email alerts, logged
3535
in as a user with [**Admin** capability](./caps/ref.html#a). It is not possible to work on a
3636
clone of the server's repository and push the configuration changes up
3737
to that repo as an Admin user, [on purpose](#backup).
3838
39
-**Important:** Do not confuse that screen with Admin → Email-Server,
40
-which sets up a different subsystem within Fossil. That feature is
41
-related to this document's topic, but it is currently incomplete, so we
42
-do not cover it at this time.
43
-
4439
<a id="cd"></a>
4540
You will also need a CLI window open with its working directory changed
4641
to a checkout directory of the Fossil repository you are setting up to
4742
send email. If you don't `cd` to such a checkout directory first,
4843
you'll need to add `-R /path/to/repo.fossil` to each `fossil` command
@@ -55,13 +50,14 @@
5550
5651
5752
<a id="quick"></a>
5853
## Quick Email Service Setup
5954
60
-If you've already got a working Postfix, Exim, or Sendmail server on the
61
-machine running your Fossil instance(s), and you aren't using Fossil's
62
-`chroot` feature to wall Fossil off from the rest of the machine, it's
55
+If you've already got a working OpenSMTPD, Postfix, Exim, Sendmail,
56
+or similar server on the machine running your Fossil instance(s),
57
+and you aren't using Fossil's [chroot jail feature](./chroot.md)
58
+to wall Fossil off from the rest of the machine, it's
6359
fairly simple to set up email alerts.
6460
6561
(Otherwise, skip [ahead](#advanced) to the sections on advanced email
6662
service setup.)
6763
6864
--- www/alerts.md
+++ www/alerts.md
@@ -34,15 +34,10 @@
34 on the Fossil server that will be sending these email alerts, logged
35 in as a user with [**Admin** capability](./caps/ref.html#a). It is not possible to work on a
36 clone of the server's repository and push the configuration changes up
37 to that repo as an Admin user, [on purpose](#backup).
38
39 **Important:** Do not confuse that screen with Admin → Email-Server,
40 which sets up a different subsystem within Fossil. That feature is
41 related to this document's topic, but it is currently incomplete, so we
42 do not cover it at this time.
43
44 <a id="cd"></a>
45 You will also need a CLI window open with its working directory changed
46 to a checkout directory of the Fossil repository you are setting up to
47 send email. If you don't `cd` to such a checkout directory first,
48 you'll need to add `-R /path/to/repo.fossil` to each `fossil` command
@@ -55,13 +50,14 @@
55
56
57 <a id="quick"></a>
58 ## Quick Email Service Setup
59
60 If you've already got a working Postfix, Exim, or Sendmail server on the
61 machine running your Fossil instance(s), and you aren't using Fossil's
62 `chroot` feature to wall Fossil off from the rest of the machine, it's
 
63 fairly simple to set up email alerts.
64
65 (Otherwise, skip [ahead](#advanced) to the sections on advanced email
66 service setup.)
67
68
--- www/alerts.md
+++ www/alerts.md
@@ -34,15 +34,10 @@
34 on the Fossil server that will be sending these email alerts, logged
35 in as a user with [**Admin** capability](./caps/ref.html#a). It is not possible to work on a
36 clone of the server's repository and push the configuration changes up
37 to that repo as an Admin user, [on purpose](#backup).
38
 
 
 
 
 
39 <a id="cd"></a>
40 You will also need a CLI window open with its working directory changed
41 to a checkout directory of the Fossil repository you are setting up to
42 send email. If you don't `cd` to such a checkout directory first,
43 you'll need to add `-R /path/to/repo.fossil` to each `fossil` command
@@ -55,13 +50,14 @@
50
51
52 <a id="quick"></a>
53 ## Quick Email Service Setup
54
55 If you've already got a working OpenSMTPD, Postfix, Exim, Sendmail,
56 or similar server on the machine running your Fossil instance(s),
57 and you aren't using Fossil's [chroot jail feature](./chroot.md)
58 to wall Fossil off from the rest of the machine, it's
59 fairly simple to set up email alerts.
60
61 (Otherwise, skip [ahead](#advanced) to the sections on advanced email
62 service setup.)
63
64
+20 -22
--- www/build.wiki
+++ www/build.wiki
@@ -147,36 +147,34 @@
147147
148148
<li><i>MinGW / MinGW-w64</i> → The best-supported path is to build
149149
via the MinGW specific Makefile under a POSIX build of GNU make:
150150
"<b>make -f win/Makefile.mingw</b>".</li>
151151
152
-There is limited support for building under MinGW's native Windows port
153
-of GNU Make instead by defining the <tt>USE_WINDOWS=1</tt> variable, but
154
-it's better to build under MSYS, Cygwin, or WSL on Windows since this
155
-mode doesn't take care of cases such as the "openssl" target, which
156
-depends on <tt>sed</tt>. We've gone as far down this path as is
157
-practical short of breaking cross-compilation under Linux, macOS, and so
158
-forth, as we'd have to do to make everything work under
159
-<tt>cmd.exe</tt>.
160
-
161
-Unless you're building under MSYS where commands like "<tt>gcc</tt>"
162
-give MinGW's GCC and not some other version, you will need to make minor
163
-edits to win/Makefile.mingw to configure the cross-compilation
164
-environment. It should suffice to switch to one of the predefined
165
-<tt>PREFIX</tt> values, causing the build to be done using
166
-"<tt>x86_64-w64-mingw32-gcc</tt>" for example, yielding a 64-bit native
167
-Windows binary.
168
-
169152
To enable the native [./th1.md#tclEval | Tcl integration feature], use a
170153
command line like the following (all on one line):
171154
172
-<b>make -f win/Makefile.mingw FOSSIL_ENABLE_TCL=1 FOSSIL_ENABLE_TCL_STUBS=1 FOSSIL_ENABLE_TCL_PRIVATE_STUBS=1</b>
155
+<pre>make -f win/Makefile.mingw FOSSIL_ENABLE_TCL=1 FOSSIL_ENABLE_TCL_STUBS=1 FOSSIL_ENABLE_TCL_PRIVATE_STUBS=1</pre>
173156
174
-Alternatively, running <b>./configure</b> under MSYS should give a
175
-suitable top-level Makefile. However, options passed to configure that are
176
-not applicable on Windows may cause the configuration or compilation to fail
177
-(e.g. fusefs, internal-sqlite, etc).
157
+<li><i>MSYS2 / Cygwin</i> → This is something of a hybrid between
158
+options "a" and "c" above: it configures and builds
159
+<code>fossil.exe</code> much as on Linux, but you get a native Windows
160
+executable out at the end. The primary downside is that this type of
161
+executable can become confused when attempting to interoperate with
162
+fully native Windows EXEs by making assumptions that only hold true when
163
+all elements are running under the Cygwin/MSYS environment. The MSVC and
164
+MinGW options do not have this limitation.
165
+
166
+Even so, there is value to Linux/Unix natives in having this hybrid
167
+while off in Windows-land. The simpler of the two paths is MSYS2, since
168
+it lets you install the necessary prerequisites in a single command
169
+after installing the base environment:
170
+
171
+<pre>pacman -sS gcc make openssl-devel zlib-devel</pre>
172
+
173
+The equivalent in Cygwin's <code>setup.exe</code> requires stepping
174
+through the GUI package chooser, and then if you miss one of the
175
+prereqs, going all the way back through it again until you get it right.
178176
179177
<li><i>MSVC</i> → Use the MSVC makefile.</li>
180178
181179
<em>NB:</em> Run the following <code>nmake</code> commands from a "x64 Native
182180
Tools Command Prompt"; <code>buildmsvc.bat</code> is able to automatically load
183181
--- www/build.wiki
+++ www/build.wiki
@@ -147,36 +147,34 @@
147
148 <li><i>MinGW / MinGW-w64</i> → The best-supported path is to build
149 via the MinGW specific Makefile under a POSIX build of GNU make:
150 "<b>make -f win/Makefile.mingw</b>".</li>
151
152 There is limited support for building under MinGW's native Windows port
153 of GNU Make instead by defining the <tt>USE_WINDOWS=1</tt> variable, but
154 it's better to build under MSYS, Cygwin, or WSL on Windows since this
155 mode doesn't take care of cases such as the "openssl" target, which
156 depends on <tt>sed</tt>. We've gone as far down this path as is
157 practical short of breaking cross-compilation under Linux, macOS, and so
158 forth, as we'd have to do to make everything work under
159 <tt>cmd.exe</tt>.
160
161 Unless you're building under MSYS where commands like "<tt>gcc</tt>"
162 give MinGW's GCC and not some other version, you will need to make minor
163 edits to win/Makefile.mingw to configure the cross-compilation
164 environment. It should suffice to switch to one of the predefined
165 <tt>PREFIX</tt> values, causing the build to be done using
166 "<tt>x86_64-w64-mingw32-gcc</tt>" for example, yielding a 64-bit native
167 Windows binary.
168
169 To enable the native [./th1.md#tclEval | Tcl integration feature], use a
170 command line like the following (all on one line):
171
172 <b>make -f win/Makefile.mingw FOSSIL_ENABLE_TCL=1 FOSSIL_ENABLE_TCL_STUBS=1 FOSSIL_ENABLE_TCL_PRIVATE_STUBS=1</b>
173
174 Alternatively, running <b>./configure</b> under MSYS should give a
175 suitable top-level Makefile. However, options passed to configure that are
176 not applicable on Windows may cause the configuration or compilation to fail
177 (e.g. fusefs, internal-sqlite, etc).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
178
179 <li><i>MSVC</i> → Use the MSVC makefile.</li>
180
181 <em>NB:</em> Run the following <code>nmake</code> commands from a "x64 Native
182 Tools Command Prompt"; <code>buildmsvc.bat</code> is able to automatically load
183
--- www/build.wiki
+++ www/build.wiki
@@ -147,36 +147,34 @@
147
148 <li><i>MinGW / MinGW-w64</i> → The best-supported path is to build
149 via the MinGW specific Makefile under a POSIX build of GNU make:
150 "<b>make -f win/Makefile.mingw</b>".</li>
151
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
152 To enable the native [./th1.md#tclEval | Tcl integration feature], use a
153 command line like the following (all on one line):
154
155 <pre>make -f win/Makefile.mingw FOSSIL_ENABLE_TCL=1 FOSSIL_ENABLE_TCL_STUBS=1 FOSSIL_ENABLE_TCL_PRIVATE_STUBS=1</pre>
156
157 <li><i>MSYS2 / Cygwin</i> → This is something of a hybrid between
158 options "a" and "c" above: it configures and builds
159 <code>fossil.exe</code> much as on Linux, but you get a native Windows
160 executable out at the end. The primary downside is that this type of
161 executable can become confused when attempting to interoperate with
162 fully native Windows EXEs by making assumptions that only hold true when
163 all elements are running under the Cygwin/MSYS environment. The MSVC and
164 MinGW options do not have this limitation.
165
166 Even so, there is value to Linux/Unix natives in having this hybrid
167 while off in Windows-land. The simpler of the two paths is MSYS2, since
168 it lets you install the necessary prerequisites in a single command
169 after installing the base environment:
170
171 <pre>pacman -sS gcc make openssl-devel zlib-devel</pre>
172
173 The equivalent in Cygwin's <code>setup.exe</code> requires stepping
174 through the GUI package chooser, and then if you miss one of the
175 prereqs, going all the way back through it again until you get it right.
176
177 <li><i>MSVC</i> → Use the MSVC makefile.</li>
178
179 <em>NB:</em> Run the following <code>nmake</code> commands from a "x64 Native
180 Tools Command Prompt"; <code>buildmsvc.bat</code> is able to automatically load
181
+53 -1
--- www/changes.wiki
+++ www/changes.wiki
@@ -1,10 +1,62 @@
11
<title>Change Log</title>
22
33
<h2 id='v2_26'>Changes for version 2.26 (pending)</h2>
44
5
- * <i>(pending)</i>
5
+ * Enhanced the --from option on "[/help?cmd=diff|fossil diff]" so that
6
+ it optionally accepts a directory name as its argument, and uses files
7
+ under that directory as the baseline for the diff.
8
+ * Added the [/help?cmd=/ckout|/ckout web page] to provide information
9
+ about pending changes in a working check-out
10
+ * The [/help?cmd=ui|fossil ui] command defaults to using the
11
+ [/help?cmd=/ckout|/ckout page] as its start page. Or, if the
12
+ "--from PATH" option is present, the default start page becomes
13
+ "/ckout?exbase=PATH".
14
+ * Added the [/help?cmd=merge-info|fossil merge-info] command and especially
15
+ the --tk option to that command, to provide analysis of the most recent
16
+ merge or update operation.
17
+ * Added the ability to sign check-ins with SSH keys.
18
+ * Issue a warning if a user tries to commit on a check-in where the
19
+ branch has been changed.
20
+ * When a merge conflict occurs, a new section is added to the conflict
21
+ text that shows Fossil's suggested resolution to the conflict.
22
+ * Add the "Hide diffs/Show diffs" toggle to web-UI diff pages that show
23
+ diffs of multiple files.
24
+ * Enhancements to the [/help?cmd=/timeline|/timeline page]:
25
+ <ol type="a">
26
+ <li> Added the "ml=" ("Merge-in List") query parameter that works
27
+ like "rl=" ("Related List") but adds "mionly" style related
28
+ check-ins instead of the full "rel" style.
29
+ <li> For "tl=", "rl=", and "ml=", the order of the branches in the
30
+ graph now tries to match the order of the branches named in
31
+ the list.
32
+ <li> The "ms=" ("Match Style") query parameter is honored for
33
+ "tl=", "rl=", and "ml=".
34
+ <li> New query parameter "sl=BRANCHLIST" ("Sort List") strives to
35
+ put branches in the specified order in the graph. This
36
+ overrides any "tl=" or similar ordering.
37
+ <li> In the various "from=","to=" query formats, if the one of the
38
+ end points is an ancestor of the other, then the "rel" modifier
39
+ omits check-ins that are not ancestors of the newer endpoint.
40
+ <li> For "tl=" and similar query parameters, if the pattern contains
41
+ GLOB characters, then the matching style ("ms=") is set to GLOB
42
+ automatically and the "ms=" query parameter can be omitted.
43
+ <li> Enhance the "ymd" query parameter so that when used like
44
+ "ymd=YYYYMMDD-YYYYMMDD" it shows all events in the range of
45
+ dates specified.
46
+ <li> Accept the "Z" (Zulu-time) suffix on date arguments for the
47
+ "ymd" and "yw" query parameters.
48
+ </ol>
49
+ * Add the "--if-changes" option to the [/help?cmd=commit|fossil commit]
50
+ command that causes the command to become a quiet no-op if there are
51
+ no pending changes.
52
+ * Added the [/help?cmd=/clusterlist|/clusterlist page] for analysis
53
+ and debugging
54
+ * Fix a bug in [/help?cmd=patch|fossil patch create] that causes
55
+ [/help?cmd=revert|fossil revert] operations that happened on individual
56
+ files after a [/help?cmd=merge|fossil merge] to be omitted from the
57
+ patch.
658
759
<h2 id='v2_25'>Changes for version 2.25 (2024-11-06)</h2>
860
961
* The "[/help?cmd=ui|fossil ui /]" command now works even for repositories
1062
that have non-ASCII filenames
1163
--- www/changes.wiki
+++ www/changes.wiki
@@ -1,10 +1,62 @@
1 <title>Change Log</title>
2
3 <h2 id='v2_26'>Changes for version 2.26 (pending)</h2>
4
5 * <i>(pending)</i>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
7 <h2 id='v2_25'>Changes for version 2.25 (2024-11-06)</h2>
8
9 * The "[/help?cmd=ui|fossil ui /]" command now works even for repositories
10 that have non-ASCII filenames
11
--- www/changes.wiki
+++ www/changes.wiki
@@ -1,10 +1,62 @@
1 <title>Change Log</title>
2
3 <h2 id='v2_26'>Changes for version 2.26 (pending)</h2>
4
5 * Enhanced the --from option on "[/help?cmd=diff|fossil diff]" so that
6 it optionally accepts a directory name as its argument, and uses files
7 under that directory as the baseline for the diff.
8 * Added the [/help?cmd=/ckout|/ckout web page] to provide information
9 about pending changes in a working check-out
10 * The [/help?cmd=ui|fossil ui] command defaults to using the
11 [/help?cmd=/ckout|/ckout page] as its start page. Or, if the
12 "--from PATH" option is present, the default start page becomes
13 "/ckout?exbase=PATH".
14 * Added the [/help?cmd=merge-info|fossil merge-info] command and especially
15 the --tk option to that command, to provide analysis of the most recent
16 merge or update operation.
17 * Added the ability to sign check-ins with SSH keys.
18 * Issue a warning if a user tries to commit on a check-in where the
19 branch has been changed.
20 * When a merge conflict occurs, a new section is added to the conflict
21 text that shows Fossil's suggested resolution to the conflict.
22 * Add the "Hide diffs/Show diffs" toggle to web-UI diff pages that show
23 diffs of multiple files.
24 * Enhancements to the [/help?cmd=/timeline|/timeline page]:
25 <ol type="a">
26 <li> Added the "ml=" ("Merge-in List") query parameter that works
27 like "rl=" ("Related List") but adds "mionly" style related
28 check-ins instead of the full "rel" style.
29 <li> For "tl=", "rl=", and "ml=", the order of the branches in the
30 graph now tries to match the order of the branches named in
31 the list.
32 <li> The "ms=" ("Match Style") query parameter is honored for
33 "tl=", "rl=", and "ml=".
34 <li> New query parameter "sl=BRANCHLIST" ("Sort List") strives to
35 put branches in the specified order in the graph. This
36 overrides any "tl=" or similar ordering.
37 <li> In the various "from=","to=" query formats, if the one of the
38 end points is an ancestor of the other, then the "rel" modifier
39 omits check-ins that are not ancestors of the newer endpoint.
40 <li> For "tl=" and similar query parameters, if the pattern contains
41 GLOB characters, then the matching style ("ms=") is set to GLOB
42 automatically and the "ms=" query parameter can be omitted.
43 <li> Enhance the "ymd" query parameter so that when used like
44 "ymd=YYYYMMDD-YYYYMMDD" it shows all events in the range of
45 dates specified.
46 <li> Accept the "Z" (Zulu-time) suffix on date arguments for the
47 "ymd" and "yw" query parameters.
48 </ol>
49 * Add the "--if-changes" option to the [/help?cmd=commit|fossil commit]
50 command that causes the command to become a quiet no-op if there are
51 no pending changes.
52 * Added the [/help?cmd=/clusterlist|/clusterlist page] for analysis
53 and debugging
54 * Fix a bug in [/help?cmd=patch|fossil patch create] that causes
55 [/help?cmd=revert|fossil revert] operations that happened on individual
56 files after a [/help?cmd=merge|fossil merge] to be omitted from the
57 patch.
58
59 <h2 id='v2_25'>Changes for version 2.25 (2024-11-06)</h2>
60
61 * The "[/help?cmd=ui|fossil ui /]" command now works even for repositories
62 that have non-ASCII filenames
63
+14 -11
--- www/chroot.md
+++ www/chroot.md
@@ -1,21 +1,21 @@
11
# The Server Chroot Jail
22
33
If you run Fossil as root in any mode that [serves data on the
44
network][srv], and you're running it on Unix or a compatible OS, Fossil
55
will drop itself into a [`chroot(2)` jail][cj] shortly after starting
6
-up, once it's done everything that requires root access. Most commonly,
7
-you run Fossil as root to allow it to bind to TCP port 80 for HTTP
8
-service, since normal users are restricted to ports 1024 and up on OSes
9
-where this behavior occurs.
6
+up. The usual reason for launching Fossil
7
+as root to allow it to bind to TCP port 80 for HTTP
8
+service, since normal users are restricted to ports 1024 and higher.
109
1110
Fossil uses the owner of the Fossil repository file as its new user
12
-ID when dropping root privileges.
11
+ID when it drops root privileges.
1312
14
-When this happens, Fossil needs to have all of its dependencies inside
15
-the chroot jail in order to continue work. There are several things you
16
-typically need in order to make things work properly:
13
+When Fossil enters a chroot jail, it needs to have all of its dependencies
14
+inside the chroot jail in order to continue work. There are several
15
+resources that need to be inside the chroot jail with Fossil in order for
16
+Fossil to work correctly:
1717
1818
* the repository file(s)
1919
2020
* `/dev/null` — create it with `mknod(8)` inside the jail directory
2121
([Linux example][mnl], [OpenBSD example][obsd])
@@ -27,16 +27,19 @@
2727
shedding feature][fls]
2828
2929
* any shared libraries your `fossil` binary is linked to, unless you
3030
[configured Fossil with `--static`][bld] to avoid it
3131
32
-Fossil does all of this in order to protect the host OS. You can make it
33
-bypass the jail part of this by passing <tt>--nojail</tt> to <tt>fossil server</tt>,
34
-but you cannot make it skip the dropping of root privileges, on purpose.
32
+Fossil does all of this as one of many layers of defense against
33
+hacks and exploits. You can prevent Fossil from entering the chroot
34
+jail using the <tt>--nojail</tt> option to the
35
+[fossil server command](/help?cmd=server)
36
+but you cannot make Fossil hold onto root privileges. Fossil always drops
37
+root privilege before accepting inputs, for security.
3538
3639
3740
[bld]: https://fossil-scm.org/home/doc/trunk/www/build.wiki
3841
[cj]: https://en.wikipedia.org/wiki/Chroot
3942
[fls]: ./loadmgmt.md
4043
[mnl]: https://fossil-scm.org/forum/forumpost/90caff30cb
4144
[srv]: ./server/
4245
[obsd]: ./server/openbsd/fastcgi.md#chroot
4346
--- www/chroot.md
+++ www/chroot.md
@@ -1,21 +1,21 @@
1 # The Server Chroot Jail
2
3 If you run Fossil as root in any mode that [serves data on the
4 network][srv], and you're running it on Unix or a compatible OS, Fossil
5 will drop itself into a [`chroot(2)` jail][cj] shortly after starting
6 up, once it's done everything that requires root access. Most commonly,
7 you run Fossil as root to allow it to bind to TCP port 80 for HTTP
8 service, since normal users are restricted to ports 1024 and up on OSes
9 where this behavior occurs.
10
11 Fossil uses the owner of the Fossil repository file as its new user
12 ID when dropping root privileges.
13
14 When this happens, Fossil needs to have all of its dependencies inside
15 the chroot jail in order to continue work. There are several things you
16 typically need in order to make things work properly:
 
17
18 * the repository file(s)
19
20 * `/dev/null` — create it with `mknod(8)` inside the jail directory
21 ([Linux example][mnl], [OpenBSD example][obsd])
@@ -27,16 +27,19 @@
27 shedding feature][fls]
28
29 * any shared libraries your `fossil` binary is linked to, unless you
30 [configured Fossil with `--static`][bld] to avoid it
31
32 Fossil does all of this in order to protect the host OS. You can make it
33 bypass the jail part of this by passing <tt>--nojail</tt> to <tt>fossil server</tt>,
34 but you cannot make it skip the dropping of root privileges, on purpose.
 
 
 
35
36
37 [bld]: https://fossil-scm.org/home/doc/trunk/www/build.wiki
38 [cj]: https://en.wikipedia.org/wiki/Chroot
39 [fls]: ./loadmgmt.md
40 [mnl]: https://fossil-scm.org/forum/forumpost/90caff30cb
41 [srv]: ./server/
42 [obsd]: ./server/openbsd/fastcgi.md#chroot
43
--- www/chroot.md
+++ www/chroot.md
@@ -1,21 +1,21 @@
1 # The Server Chroot Jail
2
3 If you run Fossil as root in any mode that [serves data on the
4 network][srv], and you're running it on Unix or a compatible OS, Fossil
5 will drop itself into a [`chroot(2)` jail][cj] shortly after starting
6 up. The usual reason for launching Fossil
7 as root to allow it to bind to TCP port 80 for HTTP
8 service, since normal users are restricted to ports 1024 and higher.
 
9
10 Fossil uses the owner of the Fossil repository file as its new user
11 ID when it drops root privileges.
12
13 When Fossil enters a chroot jail, it needs to have all of its dependencies
14 inside the chroot jail in order to continue work. There are several
15 resources that need to be inside the chroot jail with Fossil in order for
16 Fossil to work correctly:
17
18 * the repository file(s)
19
20 * `/dev/null` — create it with `mknod(8)` inside the jail directory
21 ([Linux example][mnl], [OpenBSD example][obsd])
@@ -27,16 +27,19 @@
27 shedding feature][fls]
28
29 * any shared libraries your `fossil` binary is linked to, unless you
30 [configured Fossil with `--static`][bld] to avoid it
31
32 Fossil does all of this as one of many layers of defense against
33 hacks and exploits. You can prevent Fossil from entering the chroot
34 jail using the <tt>--nojail</tt> option to the
35 [fossil server command](/help?cmd=server)
36 but you cannot make Fossil hold onto root privileges. Fossil always drops
37 root privilege before accepting inputs, for security.
38
39
40 [bld]: https://fossil-scm.org/home/doc/trunk/www/build.wiki
41 [cj]: https://en.wikipedia.org/wiki/Chroot
42 [fls]: ./loadmgmt.md
43 [mnl]: https://fossil-scm.org/forum/forumpost/90caff30cb
44 [srv]: ./server/
45 [obsd]: ./server/openbsd/fastcgi.md#chroot
46
--- www/fossil-is-not-relational.md
+++ www/fossil-is-not-relational.md
@@ -94,11 +94,11 @@
9494
- Specify any specific storage mechanism for the SCM's raw bytes,
9595
which includes both artifacts themselves and client-side file
9696
content. The file format refers to all such content solely by its
9797
unique hash value.
9898
99
-- Specify any optimimizations such as storing file-level changes as
99
+- Specify any optimizations such as storing file-level changes as
100100
deltas between two versions of that content.
101101
102102
Such aspects are all considered to be implementation details of
103103
higher-level applications (be they in the main fossil binary or a
104104
hypothetical 3rd-party application), and have no effect on the
105105
--- www/fossil-is-not-relational.md
+++ www/fossil-is-not-relational.md
@@ -94,11 +94,11 @@
94 - Specify any specific storage mechanism for the SCM's raw bytes,
95 which includes both artifacts themselves and client-side file
96 content. The file format refers to all such content solely by its
97 unique hash value.
98
99 - Specify any optimimizations such as storing file-level changes as
100 deltas between two versions of that content.
101
102 Such aspects are all considered to be implementation details of
103 higher-level applications (be they in the main fossil binary or a
104 hypothetical 3rd-party application), and have no effect on the
105
--- www/fossil-is-not-relational.md
+++ www/fossil-is-not-relational.md
@@ -94,11 +94,11 @@
94 - Specify any specific storage mechanism for the SCM's raw bytes,
95 which includes both artifacts themselves and client-side file
96 content. The file format refers to all such content solely by its
97 unique hash value.
98
99 - Specify any optimizations such as storing file-level changes as
100 deltas between two versions of that content.
101
102 Such aspects are all considered to be implementation details of
103 higher-level applications (be they in the main fossil binary or a
104 hypothetical 3rd-party application), and have no effect on the
105
+1 -1
--- www/hooks.md
+++ www/hooks.md
@@ -116,11 +116,11 @@
116116
script needs to access the repository.
117117
118118
* The %A substitution is the name of a "commit description file" that
119119
shows the details of the commit in progress. To see what a
120120
"commit description file" looks like, set a before-commit hook
121
- with a command of "cat %Q" and then run a sample commit with
121
+ with a command of "cat %A" and then run a sample commit with
122122
the --dry-run option.
123123
124124
* If any before-commit hook returns a non-zero exit code, then
125125
the commit is abandoned. All
126126
before-commit hooks must exit(0) in order for the commit to
127127
--- www/hooks.md
+++ www/hooks.md
@@ -116,11 +116,11 @@
116 script needs to access the repository.
117
118 * The %A substitution is the name of a "commit description file" that
119 shows the details of the commit in progress. To see what a
120 "commit description file" looks like, set a before-commit hook
121 with a command of "cat %Q" and then run a sample commit with
122 the --dry-run option.
123
124 * If any before-commit hook returns a non-zero exit code, then
125 the commit is abandoned. All
126 before-commit hooks must exit(0) in order for the commit to
127
--- www/hooks.md
+++ www/hooks.md
@@ -116,11 +116,11 @@
116 script needs to access the repository.
117
118 * The %A substitution is the name of a "commit description file" that
119 shows the details of the commit in progress. To see what a
120 "commit description file" looks like, set a before-commit hook
121 with a command of "cat %A" and then run a sample commit with
122 the --dry-run option.
123
124 * If any before-commit hook returns a non-zero exit code, then
125 the commit is abandoned. All
126 before-commit hooks must exit(0) in order for the commit to
127
+9 -8
--- www/inout.wiki
+++ www/inout.wiki
@@ -40,18 +40,19 @@
4040
The above commands work best on proper POSIX systems like Linux, macOS,
4141
and the BSDs, where everything <tt>git</tt> sends is consumed by
4242
<tt>fossil</tt> as soon as it can manage, with both programs working
4343
concurrently.
4444
45
-For some reason, the current version of PowerShell included with Windows
46
-chokes on the conversion when the in-flight repository size exceeds
47
-available memory. We do not know why it buffers the entire stream
48
-emitted by "<tt>git fast-export</tt>" before sending it along to Fossil,
49
-but we've seen the problem recur on multiple machines.
50
-
51
-While one workaround is to fall back to <tt>cmd.exe</tt> — which doesn't
52
-seem to be affected by this problem — we instead recommend using
45
+Historically, PowerShell indiscriminately sent objects — as opposed to raw
46
+bytes — through its pipes, and buffered standard input for external processes.
47
+This made it choke on the conversion when the in-flight repository size
48
+exceeded available memory. Starting with version 7.4 (2023-11-16), PowerShell
49
+supports byte stream piping between native commands and file redirection.
50
+
51
+If you are stuck with an older version, one workaround is to fall back to
52
+<tt>cmd.exe</tt> — which doesn't seem to be affected by this problem.
53
+Nevertheless, we instead recommend using
5354
Microsoft's own [https://learn.microsoft.com/en-us/windows/wsl/ | Windows
5455
Subsystem for Linux] or either of the two popular "Git for Windows"
5556
distributions based on MSYS2. They handle pipes the POSIX way, avoiding
5657
any dependency on the amount of data involved.
5758
5859
--- www/inout.wiki
+++ www/inout.wiki
@@ -40,18 +40,19 @@
40 The above commands work best on proper POSIX systems like Linux, macOS,
41 and the BSDs, where everything <tt>git</tt> sends is consumed by
42 <tt>fossil</tt> as soon as it can manage, with both programs working
43 concurrently.
44
45 For some reason, the current version of PowerShell included with Windows
46 chokes on the conversion when the in-flight repository size exceeds
47 available memory. We do not know why it buffers the entire stream
48 emitted by "<tt>git fast-export</tt>" before sending it along to Fossil,
49 but we've seen the problem recur on multiple machines.
50
51 While one workaround is to fall back to <tt>cmd.exe</tt> — which doesn't
52 seem to be affected by this problem — we instead recommend using
 
53 Microsoft's own [https://learn.microsoft.com/en-us/windows/wsl/ | Windows
54 Subsystem for Linux] or either of the two popular "Git for Windows"
55 distributions based on MSYS2. They handle pipes the POSIX way, avoiding
56 any dependency on the amount of data involved.
57
58
--- www/inout.wiki
+++ www/inout.wiki
@@ -40,18 +40,19 @@
40 The above commands work best on proper POSIX systems like Linux, macOS,
41 and the BSDs, where everything <tt>git</tt> sends is consumed by
42 <tt>fossil</tt> as soon as it can manage, with both programs working
43 concurrently.
44
45 Historically, PowerShell indiscriminately sent objects — as opposed to raw
46 bytes — through its pipes, and buffered standard input for external processes.
47 This made it choke on the conversion when the in-flight repository size
48 exceeded available memory. Starting with version 7.4 (2023-11-16), PowerShell
49 supports byte stream piping between native commands and file redirection.
50
51 If you are stuck with an older version, one workaround is to fall back to
52 <tt>cmd.exe</tt> — which doesn't seem to be affected by this problem.
53 Nevertheless, we instead recommend using
54 Microsoft's own [https://learn.microsoft.com/en-us/windows/wsl/ | Windows
55 Subsystem for Linux] or either of the two popular "Git for Windows"
56 distributions based on MSYS2. They handle pipes the POSIX way, avoiding
57 any dependency on the amount of data involved.
58
59
--- www/mirrorlimitations.md
+++ www/mirrorlimitations.md
@@ -46,10 +46,29 @@
4646
However, complex histories with lots of cross-merging
4747
can lead to ambiguities. Fossil keeps
4848
track of historical branch names unambiguously,
4949
but the extra details about branch names that Fossil keeps
5050
at hand cannot be exported to Git.
51
+
52
+An example of the kinds of ambiguities that arise when branch names
53
+are not tracked is a "diamond-merge" history. In a diamond-merge, a
54
+long-running development branch merges enhancements from trunk from
55
+time to time and also periodically merges the development changes back
56
+to trunk at moments when the branch is stable.
57
+An example of diamond-merge in the Fossil source tree itself
58
+can be seen at on the [bv-corrections01 branch](/timeline?r=bv-corrections01).
59
+The distinction between checkins on the branch and checkins on trunk would
60
+be lost in Git, which does not track branches for individual checkins,
61
+and so you cannot (easily) tell which checkins are part of the branch and
62
+which are part of trunk in a diamond-merge history on Git. For that
63
+reason, diamond-merge histories are considered an anti-pattern in Git
64
+and the usual recommendation for Git users is to employ
65
+[rebase](./rebaseharm.md) to clean the history up. The point here is
66
+that if your project has a diamond-merge history that shows up cleanly
67
+in Fossil, it will export to Git and still be technically correct, but
68
+the history display might be a jumbled mess that is difficult for humans
69
+to comprehend.
5170
5271
## (4) Non-unique Tags
5372
5473
Git requires tags to be unique: each tag must refer to exactly one
5574
check-in. Fossil does not have this restriction, and so it is common
5675
--- www/mirrorlimitations.md
+++ www/mirrorlimitations.md
@@ -46,10 +46,29 @@
46 However, complex histories with lots of cross-merging
47 can lead to ambiguities. Fossil keeps
48 track of historical branch names unambiguously,
49 but the extra details about branch names that Fossil keeps
50 at hand cannot be exported to Git.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
52 ## (4) Non-unique Tags
53
54 Git requires tags to be unique: each tag must refer to exactly one
55 check-in. Fossil does not have this restriction, and so it is common
56
--- www/mirrorlimitations.md
+++ www/mirrorlimitations.md
@@ -46,10 +46,29 @@
46 However, complex histories with lots of cross-merging
47 can lead to ambiguities. Fossil keeps
48 track of historical branch names unambiguously,
49 but the extra details about branch names that Fossil keeps
50 at hand cannot be exported to Git.
51
52 An example of the kinds of ambiguities that arise when branch names
53 are not tracked is a "diamond-merge" history. In a diamond-merge, a
54 long-running development branch merges enhancements from trunk from
55 time to time and also periodically merges the development changes back
56 to trunk at moments when the branch is stable.
57 An example of diamond-merge in the Fossil source tree itself
58 can be seen at on the [bv-corrections01 branch](/timeline?r=bv-corrections01).
59 The distinction between checkins on the branch and checkins on trunk would
60 be lost in Git, which does not track branches for individual checkins,
61 and so you cannot (easily) tell which checkins are part of the branch and
62 which are part of trunk in a diamond-merge history on Git. For that
63 reason, diamond-merge histories are considered an anti-pattern in Git
64 and the usual recommendation for Git users is to employ
65 [rebase](./rebaseharm.md) to clean the history up. The point here is
66 that if your project has a diamond-merge history that shows up cleanly
67 in Fossil, it will export to Git and still be technically correct, but
68 the history display might be a jumbled mess that is difficult for humans
69 to comprehend.
70
71 ## (4) Non-unique Tags
72
73 Git requires tags to be unique: each tag must refer to exactly one
74 check-in. Fossil does not have this restriction, and so it is common
75
--- www/permutedindex.html
+++ www/permutedindex.html
@@ -105,10 +105,11 @@
105105
<li><a href="quotes.wiki">Quotes: What People Are Saying About Fossil, Git, and DVCSes in General</a></li>
106106
<li><a href="rebaseharm.md">Rebase Considered Harmful</a></li>
107107
<li><a href="reviews.wiki">Reviews</a></li>
108108
<li><a href="chroot.md">Server Chroot Jail</a></li>
109109
<li><a href="shunning.wiki">Shunning: Deleting Content From Fossil</a></li>
110
+<li><a href="signing.md">Signing Check-ins</a></li>
110111
<li><a href="../../../sitemap">Site Map</a></li>
111112
<li><a href="style.wiki">Source Code Style Guidelines</a></li>
112113
<li><a href="tech_overview.wiki">SQLite Databases Used By Fossil</a></li>
113114
<li><a href="ssl-server.md">SSL/TLS Server Mode</a></li>
114115
<li><a href="backoffice.md">The "Backoffice" mechanism of Fossil</a></li>
115116
--- www/permutedindex.html
+++ www/permutedindex.html
@@ -105,10 +105,11 @@
105 <li><a href="quotes.wiki">Quotes: What People Are Saying About Fossil, Git, and DVCSes in General</a></li>
106 <li><a href="rebaseharm.md">Rebase Considered Harmful</a></li>
107 <li><a href="reviews.wiki">Reviews</a></li>
108 <li><a href="chroot.md">Server Chroot Jail</a></li>
109 <li><a href="shunning.wiki">Shunning: Deleting Content From Fossil</a></li>
 
110 <li><a href="../../../sitemap">Site Map</a></li>
111 <li><a href="style.wiki">Source Code Style Guidelines</a></li>
112 <li><a href="tech_overview.wiki">SQLite Databases Used By Fossil</a></li>
113 <li><a href="ssl-server.md">SSL/TLS Server Mode</a></li>
114 <li><a href="backoffice.md">The "Backoffice" mechanism of Fossil</a></li>
115
--- www/permutedindex.html
+++ www/permutedindex.html
@@ -105,10 +105,11 @@
105 <li><a href="quotes.wiki">Quotes: What People Are Saying About Fossil, Git, and DVCSes in General</a></li>
106 <li><a href="rebaseharm.md">Rebase Considered Harmful</a></li>
107 <li><a href="reviews.wiki">Reviews</a></li>
108 <li><a href="chroot.md">Server Chroot Jail</a></li>
109 <li><a href="shunning.wiki">Shunning: Deleting Content From Fossil</a></li>
110 <li><a href="signing.md">Signing Check-ins</a></li>
111 <li><a href="../../../sitemap">Site Map</a></li>
112 <li><a href="style.wiki">Source Code Style Guidelines</a></li>
113 <li><a href="tech_overview.wiki">SQLite Databases Used By Fossil</a></li>
114 <li><a href="ssl-server.md">SSL/TLS Server Mode</a></li>
115 <li><a href="backoffice.md">The "Backoffice" mechanism of Fossil</a></li>
116
--- www/selfhost.wiki
+++ www/selfhost.wiki
@@ -1,13 +1,13 @@
11
<title>Fossil Self-Hosting Repositories</title>
22
3
-Fossil has self-hosted since 2007-07-21. As of 2017-07-25
3
+Fossil has self-hosted since 2007-07-21. As of 2025-02-11
44
there are three publicly accessible repositories for the Fossil source code:
55
66
1. [https://fossil-scm.org/]
77
2. [https://www2.fossil-scm.org/]
8
- 3. [https://www3.fossil-scm.org/site.cgi]
8
+ 3. [https://www3.fossil-scm.org/]
99
1010
The canonical repository is (1). Repositories (2) and (3) automatically
1111
stay in synchronization with (1) via a
1212
<a href="http://en.wikipedia.org/wiki/Cron">cron job</a> that invokes
1313
"fossil sync" at regular intervals.
@@ -20,11 +20,11 @@
2020
Changes (such as new tickets or wiki or check-ins) can be implemented
2121
on any of the three servers and those changes automatically propagate to the
2222
other two servers.
2323
2424
Server (1) runs as a [./aboutcgi.wiki|CGI script] on a
25
-<a href="http://www.linode.com/">Linode 8192</a> located in Dallas, TX
25
+<a href="http://www.linode.com/">Linode</a> located in Dallas, TX
2626
- on the same virtual machine that
2727
hosts <a href="http://www.sqlite.org/">SQLite</a> and over a
2828
dozen other smaller projects. This demonstrates that Fossil can run on
2929
a low-power host processor.
3030
Multiple fossil-based projects can easily be hosted on the same machine,
@@ -57,10 +57,11 @@
5757
5858
In recent years, virtual private servers have become a more flexible and
5959
less expensive hosting option compared to shared hosting accounts.
6060
So on 2017-07-25, server (3) was moved
6161
onto a $5/month "droplet" [https://en.wikipedia.org/wiki/Virtual_private_server|VPS]
62
+(update: $6/month now)
6263
from [https://www.digitalocean.com|Digital Ocean]
6364
located in San Francisco.
6465
6566
Server (3) is synchronized with the canonical server (1) by running
6667
a command similar to the following via cron:
@@ -68,10 +69,10 @@
6869
<pre>
6970
/usr/local/bin/fossil all sync -u
7071
</pre>
7172
7273
Server (2) is a
73
-<a href="http://www.linode.com/">Linode 4096</a> located in Newark, NJ
74
+<a href="http://www.linode.com/">Linode</a> located in Newark, NJ
7475
and set up just like the canonical server (1) with the addition of a
7576
cron job for synchronization. The same cron job also runs the
7677
[/help?cmd=git|fossil git export] command after each sync in order to
7778
[./mirrortogithub.md#ex1|mirror all changes to GitHub].
7879
7980
ADDED www/signing.md
--- www/selfhost.wiki
+++ www/selfhost.wiki
@@ -1,13 +1,13 @@
1 <title>Fossil Self-Hosting Repositories</title>
2
3 Fossil has self-hosted since 2007-07-21. As of 2017-07-25
4 there are three publicly accessible repositories for the Fossil source code:
5
6 1. [https://fossil-scm.org/]
7 2. [https://www2.fossil-scm.org/]
8 3. [https://www3.fossil-scm.org/site.cgi]
9
10 The canonical repository is (1). Repositories (2) and (3) automatically
11 stay in synchronization with (1) via a
12 <a href="http://en.wikipedia.org/wiki/Cron">cron job</a> that invokes
13 "fossil sync" at regular intervals.
@@ -20,11 +20,11 @@
20 Changes (such as new tickets or wiki or check-ins) can be implemented
21 on any of the three servers and those changes automatically propagate to the
22 other two servers.
23
24 Server (1) runs as a [./aboutcgi.wiki|CGI script] on a
25 <a href="http://www.linode.com/">Linode 8192</a> located in Dallas, TX
26 - on the same virtual machine that
27 hosts <a href="http://www.sqlite.org/">SQLite</a> and over a
28 dozen other smaller projects. This demonstrates that Fossil can run on
29 a low-power host processor.
30 Multiple fossil-based projects can easily be hosted on the same machine,
@@ -57,10 +57,11 @@
57
58 In recent years, virtual private servers have become a more flexible and
59 less expensive hosting option compared to shared hosting accounts.
60 So on 2017-07-25, server (3) was moved
61 onto a $5/month "droplet" [https://en.wikipedia.org/wiki/Virtual_private_server|VPS]
 
62 from [https://www.digitalocean.com|Digital Ocean]
63 located in San Francisco.
64
65 Server (3) is synchronized with the canonical server (1) by running
66 a command similar to the following via cron:
@@ -68,10 +69,10 @@
68 <pre>
69 /usr/local/bin/fossil all sync -u
70 </pre>
71
72 Server (2) is a
73 <a href="http://www.linode.com/">Linode 4096</a> located in Newark, NJ
74 and set up just like the canonical server (1) with the addition of a
75 cron job for synchronization. The same cron job also runs the
76 [/help?cmd=git|fossil git export] command after each sync in order to
77 [./mirrortogithub.md#ex1|mirror all changes to GitHub].
78
79 DDED www/signing.md
--- www/selfhost.wiki
+++ www/selfhost.wiki
@@ -1,13 +1,13 @@
1 <title>Fossil Self-Hosting Repositories</title>
2
3 Fossil has self-hosted since 2007-07-21. As of 2025-02-11
4 there are three publicly accessible repositories for the Fossil source code:
5
6 1. [https://fossil-scm.org/]
7 2. [https://www2.fossil-scm.org/]
8 3. [https://www3.fossil-scm.org/]
9
10 The canonical repository is (1). Repositories (2) and (3) automatically
11 stay in synchronization with (1) via a
12 <a href="http://en.wikipedia.org/wiki/Cron">cron job</a> that invokes
13 "fossil sync" at regular intervals.
@@ -20,11 +20,11 @@
20 Changes (such as new tickets or wiki or check-ins) can be implemented
21 on any of the three servers and those changes automatically propagate to the
22 other two servers.
23
24 Server (1) runs as a [./aboutcgi.wiki|CGI script] on a
25 <a href="http://www.linode.com/">Linode</a> located in Dallas, TX
26 - on the same virtual machine that
27 hosts <a href="http://www.sqlite.org/">SQLite</a> and over a
28 dozen other smaller projects. This demonstrates that Fossil can run on
29 a low-power host processor.
30 Multiple fossil-based projects can easily be hosted on the same machine,
@@ -57,10 +57,11 @@
57
58 In recent years, virtual private servers have become a more flexible and
59 less expensive hosting option compared to shared hosting accounts.
60 So on 2017-07-25, server (3) was moved
61 onto a $5/month "droplet" [https://en.wikipedia.org/wiki/Virtual_private_server|VPS]
62 (update: $6/month now)
63 from [https://www.digitalocean.com|Digital Ocean]
64 located in San Francisco.
65
66 Server (3) is synchronized with the canonical server (1) by running
67 a command similar to the following via cron:
@@ -68,10 +69,10 @@
69 <pre>
70 /usr/local/bin/fossil all sync -u
71 </pre>
72
73 Server (2) is a
74 <a href="http://www.linode.com/">Linode</a> located in Newark, NJ
75 and set up just like the canonical server (1) with the addition of a
76 cron job for synchronization. The same cron job also runs the
77 [/help?cmd=git|fossil git export] command after each sync in order to
78 [./mirrortogithub.md#ex1|mirror all changes to GitHub].
79
80 DDED www/signing.md
--- a/www/signing.md
+++ b/www/signing.md
@@ -0,0 +1,117 @@
1
+# Signing Check-ins
2
+
3
+Fossil can sign check-in manifests. A basic concept in public-key
4
+cryptography, signing can bring some advantages such as authentication and
5
+non-repudiation. In practice, a serious obstacle is the public key
6
+infrastructure – that is, the problem of reliably verifying that a given
7
+public key belongs to its supposed owner (also known as _"signing is easy,
8
+verifying is hard"_).
9
+
10
+Fossil neither creates nor verifies signatures by itself, instead relying on
11
+external tools that have to be installed side-by-side. Historically, the tool
12
+most employed for this task was [GnuPG](https://gnupg.org); recently, there has
13
+been an increase in the usage of [OpenSSH](https://openssh.com) (the minimum
14
+required version is 8.1, released on 2019-10-09).
15
+
16
+## Signing a check-in
17
+
18
+The `clearsign` setting must be on; this will cause every check-in to be signed
19
+(unless you provide the `--nosign` flag to `fossil commit`). To this end,
20
+Fossil calls the command given by the `pgp-command` setting.
21
+
22
+Fossil needs a non-detached signature that includes the rest of the usual
23
+manifest. For GnuPG, this is no problem, but as of 2025 (version 9.9p1) OpenSSH
24
+can create **and verify** only detached signatures; Fossil itself must
25
+attach this signature to the manifest prior to committing. This makes the
26
+verification more complex, as additional steps are needed to extract the
27
+signature and feed it into OpenSSH.
28
+
29
+### GnuPG
30
+
31
+The `pgp-command` setting defaults to
32
+`gpg --clearsign -o`.
33
+(A possible interesting option to `gpg --clearsign` is `-u`, to specify the
34
+user to be used for signing.)
35
+
36
+### OpenSSH
37
+
38
+A reasonable value for `pgp-command` is
39
+
40
+```
41
+ssh-keygen -q -Y sign -n fossilscm -f ~/.ssh/id_ed25519
42
+```
43
+
44
+for Linux, and
45
+
46
+```
47
+ssh-keygen -q -Y sign -n fossilscm -f %USERPROFILE%/.ssh/id_ed25519
48
+```
49
+
50
+for Windows, changing as appropriate `-f` to the path of the private key to be
51
+used.
52
+
53
+The value for `-n` (the _namespace_) can be changed at will, but care has to be
54
+taken to use the same value whenbs, not Fossil
55
+artifacts.
56
+
57
+
58
+## Verifying a signature
59
+
60
+Fossil does not provide an internal method for verifying signatures and
61
+relies – like it does for sig # Signing Check-ins
62
+
63
+Fossil can sign check-in manifests. A basic concept in public-key
64
+cryptography, signing can bring some advantages such as authentication and
65
+non-repudiation. In practice, a serious obstacle is the public key
66
+infrastructure – that is, the problem of reliably verifying that a given
67
+public key belongs to its supposed owner (also known as _"signing is easy,
68
+verifying is hard"_).
69
+
70
+Fossil neither creates nor verifies signatures by itself, instead relying on
71
+external tools that have to be installed side-by-side. Historically, the tool
72
+most employed for this task was [GnuPG](https://gnupg.org); recently, there has
73
+been an increase in the usage of [OpenSSH](https://openssh.com) (the minimum
74
+required version is 8.1, released on 2019-10-09).
75
+
76
+## Signing a check-in
77
+
78
+The `clearsign` setting must be on; this will cause every check-in to be signed
79
+(unless you provide the `--nosign` flag to `fossil commit`). To this end,
80
+Fossil calls the command given by the `pgp-command` setting.
81
+
82
+Fossil needs a non-detached signature that includes the rest of the usual
83
+manifest. For GnuPG, this is no problem, but as of 2025 (version 9.9p1) OpenSSH
84
+can create **and verify** only detached signatures; Fossil itself must
85
+attach this signature to the manifest prior to committing. This makes the
86
+verification more complex, as additional steps are needed to extract the
87
+signature and feed it into OpenSSH.
88
+
89
+### GnuPG
90
+
91
+The `pgp-command` setting defaults to
92
+`gpg --clearsign -o`.
93
+(A possible interesting option to `gpg --clearsign` is `-u`, to specify the
94
+user to be used for signing.)
95
+
96
+### OpenSSH
97
+
98
+A reasonable value for `pgp-command` is
99
+
100
+```
101
+ssh-keygen -q -Y sign -n fossilscm -f ~/.ssh/id_ed25519
102
+```
103
+
104
+for Linux, and
105
+
106
+```
107
+ssh-keygen -q -Y sign -n fossilscm -f %USERPROFILE%/.ssh/id_ed25519
108
+```
109
+
110
+for Windows, changing as appropriate `-f` to the path of the private key to be
111
+used.
112
+
113
+The value for `-n` (the _namespace_) can be changed at will, but care has to be
114
+taken to use the same value when verifying the signature.
115
+
116
+Fossil versions prior to 2.26 do not understand SSH signatures and
117
+will treat artifacts signed this l can sign check-in manifes
--- a/www/signing.md
+++ b/www/signing.md
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
--- a/www/signing.md
+++ b/www/signing.md
@@ -0,0 +1,117 @@
1 # Signing Check-ins
2
3 Fossil can sign check-in manifests. A basic concept in public-key
4 cryptography, signing can bring some advantages such as authentication and
5 non-repudiation. In practice, a serious obstacle is the public key
6 infrastructure – that is, the problem of reliably verifying that a given
7 public key belongs to its supposed owner (also known as _"signing is easy,
8 verifying is hard"_).
9
10 Fossil neither creates nor verifies signatures by itself, instead relying on
11 external tools that have to be installed side-by-side. Historically, the tool
12 most employed for this task was [GnuPG](https://gnupg.org); recently, there has
13 been an increase in the usage of [OpenSSH](https://openssh.com) (the minimum
14 required version is 8.1, released on 2019-10-09).
15
16 ## Signing a check-in
17
18 The `clearsign` setting must be on; this will cause every check-in to be signed
19 (unless you provide the `--nosign` flag to `fossil commit`). To this end,
20 Fossil calls the command given by the `pgp-command` setting.
21
22 Fossil needs a non-detached signature that includes the rest of the usual
23 manifest. For GnuPG, this is no problem, but as of 2025 (version 9.9p1) OpenSSH
24 can create **and verify** only detached signatures; Fossil itself must
25 attach this signature to the manifest prior to committing. This makes the
26 verification more complex, as additional steps are needed to extract the
27 signature and feed it into OpenSSH.
28
29 ### GnuPG
30
31 The `pgp-command` setting defaults to
32 `gpg --clearsign -o`.
33 (A possible interesting option to `gpg --clearsign` is `-u`, to specify the
34 user to be used for signing.)
35
36 ### OpenSSH
37
38 A reasonable value for `pgp-command` is
39
40 ```
41 ssh-keygen -q -Y sign -n fossilscm -f ~/.ssh/id_ed25519
42 ```
43
44 for Linux, and
45
46 ```
47 ssh-keygen -q -Y sign -n fossilscm -f %USERPROFILE%/.ssh/id_ed25519
48 ```
49
50 for Windows, changing as appropriate `-f` to the path of the private key to be
51 used.
52
53 The value for `-n` (the _namespace_) can be changed at will, but care has to be
54 taken to use the same value whenbs, not Fossil
55 artifacts.
56
57
58 ## Verifying a signature
59
60 Fossil does not provide an internal method for verifying signatures and
61 relies – like it does for sig # Signing Check-ins
62
63 Fossil can sign check-in manifests. A basic concept in public-key
64 cryptography, signing can bring some advantages such as authentication and
65 non-repudiation. In practice, a serious obstacle is the public key
66 infrastructure – that is, the problem of reliably verifying that a given
67 public key belongs to its supposed owner (also known as _"signing is easy,
68 verifying is hard"_).
69
70 Fossil neither creates nor verifies signatures by itself, instead relying on
71 external tools that have to be installed side-by-side. Historically, the tool
72 most employed for this task was [GnuPG](https://gnupg.org); recently, there has
73 been an increase in the usage of [OpenSSH](https://openssh.com) (the minimum
74 required version is 8.1, released on 2019-10-09).
75
76 ## Signing a check-in
77
78 The `clearsign` setting must be on; this will cause every check-in to be signed
79 (unless you provide the `--nosign` flag to `fossil commit`). To this end,
80 Fossil calls the command given by the `pgp-command` setting.
81
82 Fossil needs a non-detached signature that includes the rest of the usual
83 manifest. For GnuPG, this is no problem, but as of 2025 (version 9.9p1) OpenSSH
84 can create **and verify** only detached signatures; Fossil itself must
85 attach this signature to the manifest prior to committing. This makes the
86 verification more complex, as additional steps are needed to extract the
87 signature and feed it into OpenSSH.
88
89 ### GnuPG
90
91 The `pgp-command` setting defaults to
92 `gpg --clearsign -o`.
93 (A possible interesting option to `gpg --clearsign` is `-u`, to specify the
94 user to be used for signing.)
95
96 ### OpenSSH
97
98 A reasonable value for `pgp-command` is
99
100 ```
101 ssh-keygen -q -Y sign -n fossilscm -f ~/.ssh/id_ed25519
102 ```
103
104 for Linux, and
105
106 ```
107 ssh-keygen -q -Y sign -n fossilscm -f %USERPROFILE%/.ssh/id_ed25519
108 ```
109
110 for Windows, changing as appropriate `-f` to the path of the private key to be
111 used.
112
113 The value for `-n` (the _namespace_) can be changed at will, but care has to be
114 taken to use the same value when verifying the signature.
115
116 Fossil versions prior to 2.26 do not understand SSH signatures and
117 will treat artifacts signed this l can sign check-in manifes
+197 -88
--- www/ssl-server.md
+++ www/ssl-server.md
@@ -12,76 +12,107 @@
1212
1313
[0]: ./ssl.wiki
1414
[1]: /timeline?c=b05cb4a0e15d0712&y=ci&n=13
1515
1616
Beginning in [late December 2021](/timeline?c=f6263bb64195b07f&y=a&n=13),
17
-this has been fixed. Commands like
17
+Fossil servers are now able to converse directly over TLS. Commands like
1818
1919
* "[fossil server](/help?cmd=server)"
2020
* "[fossil ui](/help?cmd=ui)", and
2121
* "[fossil http](/help?cmd=http)"
2222
23
-now all handle server-mode SSL/TLS encryption natively. It is now possible
24
-to run a secure Fossil server without having to put Fossil behind an encrypting
25
-web server or reverse proxy. Hence, it is now possible to stand up a complete
26
-Fossil project website on an inexpensive VPS with no added software other than
27
-Fossil itself and something like [certbot](https://certbot.eff.org) for
28
-obtaining a CA-signed certificate.
29
-
30
-## Usage
23
+may now handle the encryption natively when suitably configured, without
24
+requiring a third-party proxy layer.
25
+
26
+## <a id="usage"></a>Usage
3127
3228
To put any of the Fossil server commands into SSL/TLS mode, simply
33
-add the "--cert" command-line option.
29
+add the "`--cert`" command-line option:
3430
3531
fossil ui --cert unsafe-builtin
3632
37
-The --cert option is what tells Fossil to use TLS encryption.
38
-Normally, the argument to --cert is the name of a file containing
39
-the certificate (the "fullchain.pem" file) for the website. In this
40
-example, the magic name "unsafe-builtin" is used, which causes Fossil
41
-to use a self-signed cert rather than a real cert obtained from a
42
-[Certificate Authority](https://en.wikipedia.org/wiki/Certificate_authority)
43
-or "CA". As the name implies, this self-signed cert is not secure and
44
-should only be used for testing. Your web-browser will complain bitterly
45
-and will refuse to display the pages using the "unsafe-builtin" cert.
46
-Firefox will allow you to click an "I know the risks" button and continue.
47
-Other web browsers will stubornly refuse to display the page, under the theory
48
-that weak encryption is worse than no encryption at all. Continue reading
49
-to see how to solve this.
50
-
51
-## About Certs
52
-
53
-Certs are based on public-key or asymmetric cryptography. To create a cert,
54
-you first create a new "key pair" consisting of a public key and a private key.
55
-The public key can be freely shared with the world, but you must keep the
56
-private key secret. If anyone gains access to your private key then he will be
57
-able to impersonate you and break into your system.
58
-
59
-To obtain a cert, you send your public key and the name of the domain you
60
-want to protect to a certificate authority. The CA then digitally signs
61
-the combination of those two things using their own private key and sends
62
-the signed combination back to you. The CA's digital signature of your
63
-public key and domain name is the cert.
64
-
65
-SSL/TLS servers need two things in order to prove their identity to clients:
66
-
67
- 1. The cert that was signed by a CA
68
- 2. The private key
69
-
70
-The SSL/TLS servers send the cert to each client, so that the client
71
-can verify it. But the private key is kept strictly private and is never
72
-shared with anyone.
73
-
74
-## How To Tell Fossil About Your Cert And Private Key
75
-
76
-If you do not have your own cert and private key, you can ask Fossil
33
+Here, we are passing the magic name "unsafe-builtin" to cause Fossil to
34
+use a [hard-coded self-signed cert][hcssc] rather than one obtained from
35
+a recognized [Certificate Authority][CA], or "CA".
36
+
37
+As the name implies, this self-signed cert is _not secure_ and should
38
+only be used for testing. Your web browser is likely to complain
39
+bitterly about it and will refuse to display the pages using the
40
+"unsafe-builtin" cert until you placate it. The complexity of the
41
+ceremony demanded depends on how paranoid your browser’s creators have
42
+decided to be. It may require as little as clicking a single big "I know
43
+the risks" type of button, or it may require a sequence be several
44
+clicks designed to discourage the “yes, yes, just let me do the thing”
45
+crowd lest they run themselves into trouble by disregarding well-meant
46
+warnings.
47
+
48
+Our purpose here is to show you an alternate path that will avoid the
49
+issue entirely, not weigh in on which browser handles self-signed
50
+certificates best.
51
+
52
+[CA]: https://en.wikipedia.org/wiki/Certificate_authority
53
+[hcssc]: /info/c2a7b14c3f541edb96?ln=89-116
54
+
55
+## <a id="about"></a>About Certs
56
+
57
+The X.509 certificate system used by browsers to secure TLS connections
58
+is based on asymmetric public-key cryptography. The methods for
59
+obtaining one vary widely, with a resulting tradeoff we may summarize as
60
+trustworthiness versus convenience, the latter characteristic falling as
61
+the former rises.(^No strict correlation exists. CAs have invented
62
+highly inconvenient certification schemes that offer little additional
63
+real-world trustworthiness. Extreme cases along this axis may be fairly
64
+characterized as [security theater][st]. We focus in this document on
65
+well-balanced trade-offs between decreasing convenience and useful
66
+levels of trustworthiness gained thereby.)
67
+
68
+The self-signed method demonstrated above offers approximately zero
69
+trustworthiness, though not zero _value_ since it does still provide
70
+connection encryption.
71
+
72
+More trustworthy methods are necessarily less convenient. One such is to
73
+send your public key and the name of the domain you want to protect to a
74
+recognized CA, which then performs one or more tests to convince itself
75
+that the requester is in control of that domain. If the CA’s tests all
76
+pass, it produces an X.509 certificate bound to that domain, which
77
+includes assorted other information under the CA’s digital signature
78
+attesting to the validity of the document’s contents. The result is sent
79
+back to the requester, which may then use it to transitively attest to
80
+these tests’ success: presuming one cannot fake the type of signature
81
+used, the document must have been signed by the trusted, recognized CA.
82
+
83
+There is one element of the assorted information included with a
84
+certificate that is neither supplied by the requester nor rubber-stamped
85
+on it in passing by the CA. It also generates a one-time key pair and
86
+stores the public half in the certificate. The cryptosystem this keypair
87
+is intended to work with varies both by the CA and by time, as older
88
+systems become obsolete. Details aside, the CA then puts this matching
89
+private half of the key in a separate file, often encrypted under a
90
+separate cryptosystem for security.
91
+
92
+SSL/TLS servers need both resulting halves to make these attestations,
93
+but they send only the public half to the client when establishing the
94
+connection. The client then makes its own checks to determine whether it
95
+trusts the attestations being made.
96
+
97
+A properly written and administered server never releases the private
98
+key to anyone. Ideally, it goes directly from the CA to the requesting
99
+server and never moves from there; then when it expires, the server
100
+deletes it permanently.
101
+
102
+[st]: https://en.wikipedia.org/wiki/Security_theater
103
+
104
+## <a id="startup"></a>How To Tell Fossil About Your Cert And Private Key
105
+
106
+As we saw [above](#usage),
107
+if you do not have your own cert and private key, you can ask Fossil
77108
to use "unsafe-builtin", which is a self-signed cert that is built into
78
-Fossil. This is wildly insecure, since the private key is not really private -
79
-it is [in plain sight](/info/c2a7b14c3f541edb96?ln=89-116) in the Fossil
109
+Fossil. This is wildly insecure, since the private key is not really private;
110
+it is [in plain sight][hcssc] in the Fossil
80111
source tree for anybody to read. <b>Never add the private key that is
81112
built into Fossil to your OS's trust store</b> as doing so will severely
82
-compromise your computer. The built-in cert is only useful for testing.
113
+compromise your computer.[^ssattack] This built-in cert is only useful for testing.
83114
If you want actual security, you will need to come up with your own private
84115
key and cert.
85116
86117
Fossil wants to read certs and public keys in the
87118
[PEM format](https://en.wikipedia.org/wiki/Privacy-Enhanced_Mail).
@@ -98,66 +129,142 @@
98129
*base-64 encoding of the certificate*
99130
-----END CERTIFICATE-----
100131
101132
In both formats, text outside of the delimiters is ignored. That means
102133
that if you have a PEM-formatted private key and a separate PEM-formatted
103
-certificate, you can concatenate the two into a single file and the
134
+certificate, you can concatenate the two into a single file, and the
104135
individual components will still be easily accessible.
105136
106
-If you have a single file that holds both your private key and your
137
+### <a id="cat"></a>Separate or Concatenated?
138
+
139
+Given a single concatenated file that holds both your private key and your
107140
cert, you can hand it off to the "[fossil server](/help?cmd=server)"
108
-command using the --cert option. Like this:
141
+command using the `--cert` option, like this:
109142
110143
fossil server --port 443 --cert mycert.pem /home/www/myproject.fossil
111144
112145
The command above is sufficient to run a fully-encrypted web site for
113146
the "myproject.fossil" Fossil repository. This command must be run as
114147
root, since it wants to listen on TCP port 443, and only root processes are
115148
allowed to do that. This is safe, however, since before reading any
116
-information off of the wire, Fossil will put itself inside a chroot jail
117
-at /home/www and drop all root privileges.
118
-
119
-### Keeping The Cert And Private Key In Separate Files
120
-
121
-If you do not want to combine your cert and private key into a single
122
-big PEM file, you can keep them separate using the --pkey option to
123
-Fossil.
149
+information off of the wire, Fossil will [put itself inside a chroot
150
+jail](./chroot.md) at `/home/www` and drop all root privileges.
151
+
152
+This method of combining your cert and private key into a single big PEM
153
+file carries risks, one of which is that the system administrator must
154
+make both halves readable by the user running the Fossil server. Given
155
+the chroot jail feature, a more secure scheme separates the halves so
156
+that only root can read the private half, which then means that when
157
+Fossil drops its root privileges, it becomes unable to access the
158
+private key on disk. Fossil’s `server` feature includes the `--pkey`
159
+option to allow for that use case:
124160
125161
fossil server --port 443 --cert fullchain.pem --pkey privkey.pem /home/www/myproject.fossil
126162
127
-## The ACME Protocol
163
+[^ssattack]: ^How, you ask? Because the keys are known, they can be used
164
+ to provide signed certificates for **any** other domain. One foolish
165
+ enough to tell their OS’s TLS mechanisms to trust the signing
166
+ certificate is implicitly handing over all TLS encryption controls
167
+ to any attacker that knows they did this. Don’t do it.
168
+
169
+### <a id="chain"></a>Chains and Links
170
+
171
+The file name “`fullchain.pem`” used above is a reference to a term of
172
+art within this world of TLS protocols and their associated X.509
173
+certificates. Within the simplistic scheme originally envisioned by the
174
+creators of SSL — the predecessor to TLS — we were all expected to agree
175
+on a single set of CA root authorities, and we would all agree to get
176
+our certificates from one of them. The real world is more complicated:
177
+
178
+* The closest we have to universal acceptance of CAs is via the
179
+ [CA/Browser Forum][CAB], and even within its select membership there
180
+ is continual argument over which roots are trustworthy. (Hashing
181
+ that out is arguably this group’s key purpose.)
182
+
183
+* CAB’s decision regarding trustworthiness may not match that of any
184
+ given system’s administrator. There are solid, defensible reasons to
185
+ prune back the stock CA root set included with your browser, then to
186
+ augment it with ones CAB _doesn’t_ trust.
187
+
188
+* TLS isn’t limited to use between web browsers and public Internet
189
+ sites. Several common use cases preclude use of the process CAB
190
+ envisions, with servers able to contact Internet-based CA roots as
191
+ part of proving their identity. Different use cases demand different
192
+ CA root authority stores.
193
+
194
+ The most common of these divergent cases are servers behind strict
195
+ firewalls and edge devices that never interact with the public
196
+ Internet. This class ranges from cheap home IoT devices to the
197
+ internal equipment managed by IT for a massive global corporation.
198
+
199
+Your private Fossil server is liable to fall into that last category.
200
+This may then require that you generate a more complicated “chain” of
201
+certificates for Fossil to use here, without which the client may not be
202
+able to get back to a CA root it trusts. This is true regardless of
203
+whether that client is another copy of Fossil or a web browser
204
+traversing Fossil’s web UI, though that fact complicates matters by
205
+allowing for multiple classes of client, each of which may have their
206
+own rules for modifying the stock certificate scheme.
207
+
208
+This is distressingly common, in fact: Fossil links to OpenSSL to
209
+provide its TLS support, but there is a good chance that your browser
210
+uses another TLS implementation entirely. They may or may not agree on a
211
+single CA root store.
212
+
213
+How you accommodate all this complexity varies by the CA and other
214
+details. As but one example, Firefox’s “View Certificate” feature offers
215
+_two_ ways to download a given web site’s certificate: the cert alone or
216
+the “chain” leading back to the root. Depending on the use case, the
217
+standalone certificate might suffice, or you might need some type of
218
+cert chain. Complicating this is that the last link in the chain may be
219
+left off when it is for a mutually trusted CA root, implicitly
220
+completing the chain.
221
+
222
+[CAB]: https://en.wikipedia.org/wiki/CA/Browser_Forum
223
+
224
+## <a id="acme"></a>The ACME Protocol
225
+
226
+The [ACME Protocol][2] simplifies all this by automating the process of
227
+proving to a recognized public CA that you are in control of a given
228
+website. Without this proof, no valid CA will issue a cert for that
229
+domain, as that allows fraudulent impersonation.
128230
129
-The [ACME Protocol][2] is used to prove to a CA that you control a
130
-website. CAs require proof that you control a domain before they
131
-will issue a cert for that domain. The usual means of dealing
132
-with ACME is to run the separate [certbot](https://certbot.eff.org) tool.
231
+The primary implementation of ACME is [certbot], a product of the Let’s
232
+Encrypt organization.
133233
Here is, in a nutshell, what certbot will do to obtain your cert:
134234
135
- 1. Certbot sends your "signing request" (the document that contains
235
+ 1. It sends your "signing request" (the document that contains
136236
your public key and your domain name) to the CA.
137237
138
- 2. After receiving the signing request, the CA needs to verify that you
139
- control the domain of the cert. To do this (or, one common
140
- way of doing this, at least) the CA sends a secret token back to
141
- certbot through a secure backchannel, and instructs certbot to make
142
- that token accessible on the (unencrypted, ordinary "http:") web site
143
- for the domain in a particular file under the ".well-known" subdirectory.
144
-
145
- 3. Certbot puts the token where the CA requested it, then notifies the
146
- CA that it is there.
147
-
148
- 4. The CA accesses the token to confirm that you do indeed control the
149
- website. It then creates the cert and sends it back to certbot.
150
-
151
- 5. Certbot stores your cert and deletes the ".well-known" token.
238
+ 2. After receiving the signing request, the CA needs to verify that
239
+ you control the domain of the cert. One of several methods certbot has
240
+ for accomplishing this is to create a secret token and place it at
241
+ a well-known location, then tell the CA about it over ACME.
242
+
243
+ 3. The CA then tries pulling that token, which if successful proves
244
+ that the requester is able to create arbitrary data on the server,
245
+ implicitly proving control over that server. This must be done
246
+ over the unencrypted HTTP protocol since TLS isn’t working yet.
247
+
248
+ 4. If satisfied by this proof of control, the CA then creates the
249
+ keypair described above and bakes the public half into the
250
+ certificate it signs. It then sends this and the private half of
251
+ the key back to certbot.
252
+
253
+ 5. Certbot stores these halves separately for the reasons sketched
254
+ out above.
255
+
256
+ 6. It then deletes the secret one-time-use token it used to prove
257
+ domain control. ACME’s design precludes replay attacks.
152258
153259
In order for all of this to happen, certbot needs to be able to create
154
-a subdirectory named ".well-known", within a directory you specify, and
260
+a subdirectory named ".well-known", within a directory you specify,
155261
then populate that subdirectory with a token file of some kind. To support
156262
this, the "[fossil server](/help?cmd=server)" and
157263
"[fossil http](/help?cmd=http)" commands have the --acme option.
158
-When the --acme option is specified and Fossil sees a URL where the path
264
+
265
+When specified, Fossil sees a URL where the path
159266
begins with ".well-known", then instead of doing its normal processing, it
160267
looks for a file with that pathname and returns it to the client. If
161268
the "server" or "http" command is referencing a single Fossil repository,
162269
then the ".well-known" sub-directory should be in the same directory as
163270
the repository file. If the "server" or "http" command are run against
@@ -172,9 +279,11 @@
172279
Then you create your public/private key pair and run certbot, giving it
173280
a --webroot of /home/www. Certbot will create the sub-directory
174281
named "/home/www/.well-known" and put token files there, which the CA
175282
will verify. Then certbot will store your new cert in a particular file.
176283
177
-Once certbot has obtained your cert, then you can concatenate that
178
-cert with your private key and run Fossil in SSL/TLS mode as shown above.
284
+Once certbot has obtained your cert, you may either pass the two halves
285
+to Fossil separately using the `--pkey` and `--cert` options described
286
+above, or you may concatenate them and pass that via `--cert` alone.
179287
180288
[2]: https://en.wikipedia.org/wiki/Automated_Certificate_Management_Environment
289
+[certbot]: https://certbot.eff.org
181290
--- www/ssl-server.md
+++ www/ssl-server.md
@@ -12,76 +12,107 @@
12
13 [0]: ./ssl.wiki
14 [1]: /timeline?c=b05cb4a0e15d0712&y=ci&n=13
15
16 Beginning in [late December 2021](/timeline?c=f6263bb64195b07f&y=a&n=13),
17 this has been fixed. Commands like
18
19 * "[fossil server](/help?cmd=server)"
20 * "[fossil ui](/help?cmd=ui)", and
21 * "[fossil http](/help?cmd=http)"
22
23 now all handle server-mode SSL/TLS encryption natively. It is now possible
24 to run a secure Fossil server without having to put Fossil behind an encrypting
25 web server or reverse proxy. Hence, it is now possible to stand up a complete
26 Fossil project website on an inexpensive VPS with no added software other than
27 Fossil itself and something like [certbot](https://certbot.eff.org) for
28 obtaining a CA-signed certificate.
29
30 ## Usage
31
32 To put any of the Fossil server commands into SSL/TLS mode, simply
33 add the "--cert" command-line option.
34
35 fossil ui --cert unsafe-builtin
36
37 The --cert option is what tells Fossil to use TLS encryption.
38 Normally, the argument to --cert is the name of a file containing
39 the certificate (the "fullchain.pem" file) for the website. In this
40 example, the magic name "unsafe-builtin" is used, which causes Fossil
41 to use a self-signed cert rather than a real cert obtained from a
42 [Certificate Authority](https://en.wikipedia.org/wiki/Certificate_authority)
43 or "CA". As the name implies, this self-signed cert is not secure and
44 should only be used for testing. Your web-browser will complain bitterly
45 and will refuse to display the pages using the "unsafe-builtin" cert.
46 Firefox will allow you to click an "I know the risks" button and continue.
47 Other web browsers will stubornly refuse to display the page, under the theory
48 that weak encryption is worse than no encryption at all. Continue reading
49 to see how to solve this.
50
51 ## About Certs
52
53 Certs are based on public-key or asymmetric cryptography. To create a cert,
54 you first create a new "key pair" consisting of a public key and a private key.
55 The public key can be freely shared with the world, but you must keep the
56 private key secret. If anyone gains access to your private key then he will be
57 able to impersonate you and break into your system.
58
59 To obtain a cert, you send your public key and the name of the domain you
60 want to protect to a certificate authority. The CA then digitally signs
61 the combination of those two things using their own private key and sends
62 the signed combination back to you. The CA's digital signature of your
63 public key and domain name is the cert.
64
65 SSL/TLS servers need two things in order to prove their identity to clients:
66
67 1. The cert that was signed by a CA
68 2. The private key
69
70 The SSL/TLS servers send the cert to each client, so that the client
71 can verify it. But the private key is kept strictly private and is never
72 shared with anyone.
73
74 ## How To Tell Fossil About Your Cert And Private Key
75
76 If you do not have your own cert and private key, you can ask Fossil
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77 to use "unsafe-builtin", which is a self-signed cert that is built into
78 Fossil. This is wildly insecure, since the private key is not really private -
79 it is [in plain sight](/info/c2a7b14c3f541edb96?ln=89-116) in the Fossil
80 source tree for anybody to read. <b>Never add the private key that is
81 built into Fossil to your OS's trust store</b> as doing so will severely
82 compromise your computer. The built-in cert is only useful for testing.
83 If you want actual security, you will need to come up with your own private
84 key and cert.
85
86 Fossil wants to read certs and public keys in the
87 [PEM format](https://en.wikipedia.org/wiki/Privacy-Enhanced_Mail).
@@ -98,66 +129,142 @@
98 *base-64 encoding of the certificate*
99 -----END CERTIFICATE-----
100
101 In both formats, text outside of the delimiters is ignored. That means
102 that if you have a PEM-formatted private key and a separate PEM-formatted
103 certificate, you can concatenate the two into a single file and the
104 individual components will still be easily accessible.
105
106 If you have a single file that holds both your private key and your
 
 
107 cert, you can hand it off to the "[fossil server](/help?cmd=server)"
108 command using the --cert option. Like this:
109
110 fossil server --port 443 --cert mycert.pem /home/www/myproject.fossil
111
112 The command above is sufficient to run a fully-encrypted web site for
113 the "myproject.fossil" Fossil repository. This command must be run as
114 root, since it wants to listen on TCP port 443, and only root processes are
115 allowed to do that. This is safe, however, since before reading any
116 information off of the wire, Fossil will put itself inside a chroot jail
117 at /home/www and drop all root privileges.
118
119 ### Keeping The Cert And Private Key In Separate Files
120
121 If you do not want to combine your cert and private key into a single
122 big PEM file, you can keep them separate using the --pkey option to
123 Fossil.
 
 
 
124
125 fossil server --port 443 --cert fullchain.pem --pkey privkey.pem /home/www/myproject.fossil
126
127 ## The ACME Protocol
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
128
129 The [ACME Protocol][2] is used to prove to a CA that you control a
130 website. CAs require proof that you control a domain before they
131 will issue a cert for that domain. The usual means of dealing
132 with ACME is to run the separate [certbot](https://certbot.eff.org) tool.
133 Here is, in a nutshell, what certbot will do to obtain your cert:
134
135 1. Certbot sends your "signing request" (the document that contains
136 your public key and your domain name) to the CA.
137
138 2. After receiving the signing request, the CA needs to verify that you
139 control the domain of the cert. To do this (or, one common
140 way of doing this, at least) the CA sends a secret token back to
141 certbot through a secure backchannel, and instructs certbot to make
142 that token accessible on the (unencrypted, ordinary "http:") web site
143 for the domain in a particular file under the ".well-known" subdirectory.
144
145 3. Certbot puts the token where the CA requested it, then notifies the
146 CA that it is there.
147
148 4. The CA accesses the token to confirm that you do indeed control the
149 website. It then creates the cert and sends it back to certbot.
150
151 5. Certbot stores your cert and deletes the ".well-known" token.
 
 
 
 
 
 
152
153 In order for all of this to happen, certbot needs to be able to create
154 a subdirectory named ".well-known", within a directory you specify, and
155 then populate that subdirectory with a token file of some kind. To support
156 this, the "[fossil server](/help?cmd=server)" and
157 "[fossil http](/help?cmd=http)" commands have the --acme option.
158 When the --acme option is specified and Fossil sees a URL where the path
 
159 begins with ".well-known", then instead of doing its normal processing, it
160 looks for a file with that pathname and returns it to the client. If
161 the "server" or "http" command is referencing a single Fossil repository,
162 then the ".well-known" sub-directory should be in the same directory as
163 the repository file. If the "server" or "http" command are run against
@@ -172,9 +279,11 @@
172 Then you create your public/private key pair and run certbot, giving it
173 a --webroot of /home/www. Certbot will create the sub-directory
174 named "/home/www/.well-known" and put token files there, which the CA
175 will verify. Then certbot will store your new cert in a particular file.
176
177 Once certbot has obtained your cert, then you can concatenate that
178 cert with your private key and run Fossil in SSL/TLS mode as shown above.
 
179
180 [2]: https://en.wikipedia.org/wiki/Automated_Certificate_Management_Environment
 
181
--- www/ssl-server.md
+++ www/ssl-server.md
@@ -12,76 +12,107 @@
12
13 [0]: ./ssl.wiki
14 [1]: /timeline?c=b05cb4a0e15d0712&y=ci&n=13
15
16 Beginning in [late December 2021](/timeline?c=f6263bb64195b07f&y=a&n=13),
17 Fossil servers are now able to converse directly over TLS. Commands like
18
19 * "[fossil server](/help?cmd=server)"
20 * "[fossil ui](/help?cmd=ui)", and
21 * "[fossil http](/help?cmd=http)"
22
23 may now handle the encryption natively when suitably configured, without
24 requiring a third-party proxy layer.
25
26 ## <a id="usage"></a>Usage
 
 
 
 
27
28 To put any of the Fossil server commands into SSL/TLS mode, simply
29 add the "`--cert`" command-line option:
30
31 fossil ui --cert unsafe-builtin
32
33 Here, we are passing the magic name "unsafe-builtin" to cause Fossil to
34 use a [hard-coded self-signed cert][hcssc] rather than one obtained from
35 a recognized [Certificate Authority][CA], or "CA".
36
37 As the name implies, this self-signed cert is _not secure_ and should
38 only be used for testing. Your web browser is likely to complain
39 bitterly about it and will refuse to display the pages using the
40 "unsafe-builtin" cert until you placate it. The complexity of the
41 ceremony demanded depends on how paranoid your browser’s creators have
42 decided to be. It may require as little as clicking a single big "I know
43 the risks" type of button, or it may require a sequence be several
44 clicks designed to discourage the “yes, yes, just let me do the thing”
45 crowd lest they run themselves into trouble by disregarding well-meant
46 warnings.
47
48 Our purpose here is to show you an alternate path that will avoid the
49 issue entirely, not weigh in on which browser handles self-signed
50 certificates best.
51
52 [CA]: https://en.wikipedia.org/wiki/Certificate_authority
53 [hcssc]: /info/c2a7b14c3f541edb96?ln=89-116
54
55 ## <a id="about"></a>About Certs
56
57 The X.509 certificate system used by browsers to secure TLS connections
58 is based on asymmetric public-key cryptography. The methods for
59 obtaining one vary widely, with a resulting tradeoff we may summarize as
60 trustworthiness versus convenience, the latter characteristic falling as
61 the former rises.(^No strict correlation exists. CAs have invented
62 highly inconvenient certification schemes that offer little additional
63 real-world trustworthiness. Extreme cases along this axis may be fairly
64 characterized as [security theater][st]. We focus in this document on
65 well-balanced trade-offs between decreasing convenience and useful
66 levels of trustworthiness gained thereby.)
67
68 The self-signed method demonstrated above offers approximately zero
69 trustworthiness, though not zero _value_ since it does still provide
70 connection encryption.
71
72 More trustworthy methods are necessarily less convenient. One such is to
73 send your public key and the name of the domain you want to protect to a
74 recognized CA, which then performs one or more tests to convince itself
75 that the requester is in control of that domain. If the CA’s tests all
76 pass, it produces an X.509 certificate bound to that domain, which
77 includes assorted other information under the CA’s digital signature
78 attesting to the validity of the document’s contents. The result is sent
79 back to the requester, which may then use it to transitively attest to
80 these tests’ success: presuming one cannot fake the type of signature
81 used, the document must have been signed by the trusted, recognized CA.
82
83 There is one element of the assorted information included with a
84 certificate that is neither supplied by the requester nor rubber-stamped
85 on it in passing by the CA. It also generates a one-time key pair and
86 stores the public half in the certificate. The cryptosystem this keypair
87 is intended to work with varies both by the CA and by time, as older
88 systems become obsolete. Details aside, the CA then puts this matching
89 private half of the key in a separate file, often encrypted under a
90 separate cryptosystem for security.
91
92 SSL/TLS servers need both resulting halves to make these attestations,
93 but they send only the public half to the client when establishing the
94 connection. The client then makes its own checks to determine whether it
95 trusts the attestations being made.
96
97 A properly written and administered server never releases the private
98 key to anyone. Ideally, it goes directly from the CA to the requesting
99 server and never moves from there; then when it expires, the server
100 deletes it permanently.
101
102 [st]: https://en.wikipedia.org/wiki/Security_theater
103
104 ## <a id="startup"></a>How To Tell Fossil About Your Cert And Private Key
105
106 As we saw [above](#usage),
107 if you do not have your own cert and private key, you can ask Fossil
108 to use "unsafe-builtin", which is a self-signed cert that is built into
109 Fossil. This is wildly insecure, since the private key is not really private;
110 it is [in plain sight][hcssc] in the Fossil
111 source tree for anybody to read. <b>Never add the private key that is
112 built into Fossil to your OS's trust store</b> as doing so will severely
113 compromise your computer.[^ssattack] This built-in cert is only useful for testing.
114 If you want actual security, you will need to come up with your own private
115 key and cert.
116
117 Fossil wants to read certs and public keys in the
118 [PEM format](https://en.wikipedia.org/wiki/Privacy-Enhanced_Mail).
@@ -98,66 +129,142 @@
129 *base-64 encoding of the certificate*
130 -----END CERTIFICATE-----
131
132 In both formats, text outside of the delimiters is ignored. That means
133 that if you have a PEM-formatted private key and a separate PEM-formatted
134 certificate, you can concatenate the two into a single file, and the
135 individual components will still be easily accessible.
136
137 ### <a id="cat"></a>Separate or Concatenated?
138
139 Given a single concatenated file that holds both your private key and your
140 cert, you can hand it off to the "[fossil server](/help?cmd=server)"
141 command using the `--cert` option, like this:
142
143 fossil server --port 443 --cert mycert.pem /home/www/myproject.fossil
144
145 The command above is sufficient to run a fully-encrypted web site for
146 the "myproject.fossil" Fossil repository. This command must be run as
147 root, since it wants to listen on TCP port 443, and only root processes are
148 allowed to do that. This is safe, however, since before reading any
149 information off of the wire, Fossil will [put itself inside a chroot
150 jail](./chroot.md) at `/home/www` and drop all root privileges.
151
152 This method of combining your cert and private key into a single big PEM
153 file carries risks, one of which is that the system administrator must
154 make both halves readable by the user running the Fossil server. Given
155 the chroot jail feature, a more secure scheme separates the halves so
156 that only root can read the private half, which then means that when
157 Fossil drops its root privileges, it becomes unable to access the
158 private key on disk. Fossil’s `server` feature includes the `--pkey`
159 option to allow for that use case:
160
161 fossil server --port 443 --cert fullchain.pem --pkey privkey.pem /home/www/myproject.fossil
162
163 [^ssattack]: ^How, you ask? Because the keys are known, they can be used
164 to provide signed certificates for **any** other domain. One foolish
165 enough to tell their OS’s TLS mechanisms to trust the signing
166 certificate is implicitly handing over all TLS encryption controls
167 to any attacker that knows they did this. Don’t do it.
168
169 ### <a id="chain"></a>Chains and Links
170
171 The file name “`fullchain.pem`” used above is a reference to a term of
172 art within this world of TLS protocols and their associated X.509
173 certificates. Within the simplistic scheme originally envisioned by the
174 creators of SSL — the predecessor to TLS — we were all expected to agree
175 on a single set of CA root authorities, and we would all agree to get
176 our certificates from one of them. The real world is more complicated:
177
178 * The closest we have to universal acceptance of CAs is via the
179 [CA/Browser Forum][CAB], and even within its select membership there
180 is continual argument over which roots are trustworthy. (Hashing
181 that out is arguably this group’s key purpose.)
182
183 * CAB’s decision regarding trustworthiness may not match that of any
184 given system’s administrator. There are solid, defensible reasons to
185 prune back the stock CA root set included with your browser, then to
186 augment it with ones CAB _doesn’t_ trust.
187
188 * TLS isn’t limited to use between web browsers and public Internet
189 sites. Several common use cases preclude use of the process CAB
190 envisions, with servers able to contact Internet-based CA roots as
191 part of proving their identity. Different use cases demand different
192 CA root authority stores.
193
194 The most common of these divergent cases are servers behind strict
195 firewalls and edge devices that never interact with the public
196 Internet. This class ranges from cheap home IoT devices to the
197 internal equipment managed by IT for a massive global corporation.
198
199 Your private Fossil server is liable to fall into that last category.
200 This may then require that you generate a more complicated “chain” of
201 certificates for Fossil to use here, without which the client may not be
202 able to get back to a CA root it trusts. This is true regardless of
203 whether that client is another copy of Fossil or a web browser
204 traversing Fossil’s web UI, though that fact complicates matters by
205 allowing for multiple classes of client, each of which may have their
206 own rules for modifying the stock certificate scheme.
207
208 This is distressingly common, in fact: Fossil links to OpenSSL to
209 provide its TLS support, but there is a good chance that your browser
210 uses another TLS implementation entirely. They may or may not agree on a
211 single CA root store.
212
213 How you accommodate all this complexity varies by the CA and other
214 details. As but one example, Firefox’s “View Certificate” feature offers
215 _two_ ways to download a given web site’s certificate: the cert alone or
216 the “chain” leading back to the root. Depending on the use case, the
217 standalone certificate might suffice, or you might need some type of
218 cert chain. Complicating this is that the last link in the chain may be
219 left off when it is for a mutually trusted CA root, implicitly
220 completing the chain.
221
222 [CAB]: https://en.wikipedia.org/wiki/CA/Browser_Forum
223
224 ## <a id="acme"></a>The ACME Protocol
225
226 The [ACME Protocol][2] simplifies all this by automating the process of
227 proving to a recognized public CA that you are in control of a given
228 website. Without this proof, no valid CA will issue a cert for that
229 domain, as that allows fraudulent impersonation.
230
231 The primary implementation of ACME is [certbot], a product of the Let’s
232 Encrypt organization.
 
 
233 Here is, in a nutshell, what certbot will do to obtain your cert:
234
235 1. It sends your "signing request" (the document that contains
236 your public key and your domain name) to the CA.
237
238 2. After receiving the signing request, the CA needs to verify that
239 you control the domain of the cert. One of several methods certbot has
240 for accomplishing this is to create a secret token and place it at
241 a well-known location, then tell the CA about it over ACME.
242
243 3. The CA then tries pulling that token, which if successful proves
244 that the requester is able to create arbitrary data on the server,
245 implicitly proving control over that server. This must be done
246 over the unencrypted HTTP protocol since TLS isn’t working yet.
247
248 4. If satisfied by this proof of control, the CA then creates the
249 keypair described above and bakes the public half into the
250 certificate it signs. It then sends this and the private half of
251 the key back to certbot.
252
253 5. Certbot stores these halves separately for the reasons sketched
254 out above.
255
256 6. It then deletes the secret one-time-use token it used to prove
257 domain control. ACME’s design precludes replay attacks.
258
259 In order for all of this to happen, certbot needs to be able to create
260 a subdirectory named ".well-known", within a directory you specify,
261 then populate that subdirectory with a token file of some kind. To support
262 this, the "[fossil server](/help?cmd=server)" and
263 "[fossil http](/help?cmd=http)" commands have the --acme option.
264
265 When specified, Fossil sees a URL where the path
266 begins with ".well-known", then instead of doing its normal processing, it
267 looks for a file with that pathname and returns it to the client. If
268 the "server" or "http" command is referencing a single Fossil repository,
269 then the ".well-known" sub-directory should be in the same directory as
270 the repository file. If the "server" or "http" command are run against
@@ -172,9 +279,11 @@
279 Then you create your public/private key pair and run certbot, giving it
280 a --webroot of /home/www. Certbot will create the sub-directory
281 named "/home/www/.well-known" and put token files there, which the CA
282 will verify. Then certbot will store your new cert in a particular file.
283
284 Once certbot has obtained your cert, you may either pass the two halves
285 to Fossil separately using the `--pkey` and `--cert` options described
286 above, or you may concatenate them and pass that via `--cert` alone.
287
288 [2]: https://en.wikipedia.org/wiki/Automated_Certificate_Management_Environment
289 [certbot]: https://certbot.eff.org
290
--- www/sync.wiki
+++ www/sync.wiki
@@ -789,10 +789,18 @@
789789
a successful commit. This instructs the server to release
790790
any lock on any check-in previously held by that client.
791791
The ci-unlock pragma helps to avoid false-positive lock warnings
792792
that might arise if a check-in is aborted and then restarted
793793
on a branch.
794
+
795
+<li><b>req-clusters</b> A client sends the "req-clusters" pragma
796
+to the server to ask the server to reply with "igot" cards for
797
+every [./fileformat.wiki#cluster|cluster artifact] that it holds. The
798
+client typically does this when it thinks that it might be attempting
799
+to pull a long chain of cluster artifacts. Sending the artifacts
800
+all at once can dramatically reduce the number of round trip
801
+messages needed to complete the synchronization.
794802
</ol>
795803
796804
<h3 id="comment">3.12 Comment Cards</h3>
797805
798806
Any card that begins with "#" (ASCII 0x23) is a comment card and
799807
--- www/sync.wiki
+++ www/sync.wiki
@@ -789,10 +789,18 @@
789 a successful commit. This instructs the server to release
790 any lock on any check-in previously held by that client.
791 The ci-unlock pragma helps to avoid false-positive lock warnings
792 that might arise if a check-in is aborted and then restarted
793 on a branch.
 
 
 
 
 
 
 
 
794 </ol>
795
796 <h3 id="comment">3.12 Comment Cards</h3>
797
798 Any card that begins with "#" (ASCII 0x23) is a comment card and
799
--- www/sync.wiki
+++ www/sync.wiki
@@ -789,10 +789,18 @@
789 a successful commit. This instructs the server to release
790 any lock on any check-in previously held by that client.
791 The ci-unlock pragma helps to avoid false-positive lock warnings
792 that might arise if a check-in is aborted and then restarted
793 on a branch.
794
795 <li><b>req-clusters</b> A client sends the "req-clusters" pragma
796 to the server to ask the server to reply with "igot" cards for
797 every [./fileformat.wiki#cluster|cluster artifact] that it holds. The
798 client typically does this when it thinks that it might be attempting
799 to pull a long chain of cluster artifacts. Sending the artifacts
800 all at once can dramatically reduce the number of round trip
801 messages needed to complete the synchronization.
802 </ol>
803
804 <h3 id="comment">3.12 Comment Cards</h3>
805
806 Any card that begins with "#" (ASCII 0x23) is a comment card and
807

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button