Fossil SCM

Merge updates from trunk.

mistachkin 2013-10-17 21:44 UTC allExtra merge
Commit 9ee11edbc1ddc45f00d5a354bba75f20d25ce76f
+1 -1
--- VERSION
+++ VERSION
@@ -1,1 +1,1 @@
1
-1.27
1
+1.28
22
--- VERSION
+++ VERSION
@@ -1,1 +1,1 @@
1 1.27
2
--- VERSION
+++ VERSION
@@ -1,1 +1,1 @@
1 1.28
2
+26 -2
--- src/cgi.c
+++ src/cgi.c
@@ -830,26 +830,50 @@
830830
831831
/*
832832
** Initialize the query parameter database. Information is pulled from
833833
** the QUERY_STRING environment variable (if it exists), from standard
834834
** input if there is POST data, and from HTTP_COOKIE.
835
+**
836
+** REQUEST_URI, PATH_INFO, and SCRIPT_NAME are related as follows:
837
+**
838
+** REQUEST_URI == SCRIPT_NAME + PATH_INFO
839
+**
840
+** Where "+" means concatenate. Fossil requires SCRIPT_NAME. If
841
+** REQUEST_URI is provided but PATH_INFO is not, then PATH_INFO is
842
+** computed from REQUEST_URI and SCRIPT_NAME. If PATH_INFO is provided
843
+** but REQUEST_URI is not, then compute REQUEST_URI from PATH_INFO and
844
+** SCRIPT_NAME. If neither REQUEST_URI nor PATH_INFO are provided, then
845
+** assume that PATH_INFO is an empty string and set REQUEST_URI equal
846
+** to PATH_INFO.
847
+**
848
+** SCGI typically omits PATH_INFO. CGI sometimes omits REQUEST_URI and
849
+** PATH_INFO when it is empty.
835850
*/
836851
void cgi_init(void){
837852
char *z;
838853
const char *zType;
839854
int len;
840855
const char *zRequestUri = cgi_parameter("REQUEST_URI",0);
841856
const char *zScriptName = cgi_parameter("SCRIPT_NAME",0);
857
+ const char *zPathInfo = cgi_parameter("PATH_INFO","");
842858
843859
#ifdef FOSSIL_ENABLE_JSON
844860
json_main_bootstrap();
845861
#endif
846862
g.isHTTP = 1;
847863
cgi_destination(CGI_BODY);
848
- if( zRequestUri==0 ) malformed_request("missing REQUEST_URI");
849864
if( zScriptName==0 ) malformed_request("missing SCRIPT_NAME");
850
- if( cgi_parameter("PATH_INFO",0)==0 ){
865
+ if( zRequestUri==0 ){
866
+ const char *z = zPathInfo;
867
+ if( zPathInfo==0 ){
868
+ malformed_request("missing PATH_INFO and/or REQUEST_URI");
869
+ }
870
+ if( z[0]=='/' ) z++;
871
+ zRequestUri = mprintf("%s/%s", zScriptName, z);
872
+ cgi_set_parameter("REQUEST_URI", zRequestUri);
873
+ }
874
+ if( zPathInfo==0 ){
851875
int i, j;
852876
for(i=0; zRequestUri[i]==zScriptName[i] && zRequestUri[i]; i++){}
853877
for(j=i; zRequestUri[j] && zRequestUri[j]!='?'; j++){}
854878
cgi_set_parameter("PATH_INFO", mprintf("%.*s", j-i, zRequestUri+i));
855879
}
856880
--- src/cgi.c
+++ src/cgi.c
@@ -830,26 +830,50 @@
830
831 /*
832 ** Initialize the query parameter database. Information is pulled from
833 ** the QUERY_STRING environment variable (if it exists), from standard
834 ** input if there is POST data, and from HTTP_COOKIE.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
835 */
836 void cgi_init(void){
837 char *z;
838 const char *zType;
839 int len;
840 const char *zRequestUri = cgi_parameter("REQUEST_URI",0);
841 const char *zScriptName = cgi_parameter("SCRIPT_NAME",0);
 
842
843 #ifdef FOSSIL_ENABLE_JSON
844 json_main_bootstrap();
845 #endif
846 g.isHTTP = 1;
847 cgi_destination(CGI_BODY);
848 if( zRequestUri==0 ) malformed_request("missing REQUEST_URI");
849 if( zScriptName==0 ) malformed_request("missing SCRIPT_NAME");
850 if( cgi_parameter("PATH_INFO",0)==0 ){
 
 
 
 
 
 
 
 
 
851 int i, j;
852 for(i=0; zRequestUri[i]==zScriptName[i] && zRequestUri[i]; i++){}
853 for(j=i; zRequestUri[j] && zRequestUri[j]!='?'; j++){}
854 cgi_set_parameter("PATH_INFO", mprintf("%.*s", j-i, zRequestUri+i));
855 }
856
--- src/cgi.c
+++ src/cgi.c
@@ -830,26 +830,50 @@
830
831 /*
832 ** Initialize the query parameter database. Information is pulled from
833 ** the QUERY_STRING environment variable (if it exists), from standard
834 ** input if there is POST data, and from HTTP_COOKIE.
835 **
836 ** REQUEST_URI, PATH_INFO, and SCRIPT_NAME are related as follows:
837 **
838 ** REQUEST_URI == SCRIPT_NAME + PATH_INFO
839 **
840 ** Where "+" means concatenate. Fossil requires SCRIPT_NAME. If
841 ** REQUEST_URI is provided but PATH_INFO is not, then PATH_INFO is
842 ** computed from REQUEST_URI and SCRIPT_NAME. If PATH_INFO is provided
843 ** but REQUEST_URI is not, then compute REQUEST_URI from PATH_INFO and
844 ** SCRIPT_NAME. If neither REQUEST_URI nor PATH_INFO are provided, then
845 ** assume that PATH_INFO is an empty string and set REQUEST_URI equal
846 ** to PATH_INFO.
847 **
848 ** SCGI typically omits PATH_INFO. CGI sometimes omits REQUEST_URI and
849 ** PATH_INFO when it is empty.
850 */
851 void cgi_init(void){
852 char *z;
853 const char *zType;
854 int len;
855 const char *zRequestUri = cgi_parameter("REQUEST_URI",0);
856 const char *zScriptName = cgi_parameter("SCRIPT_NAME",0);
857 const char *zPathInfo = cgi_parameter("PATH_INFO","");
858
859 #ifdef FOSSIL_ENABLE_JSON
860 json_main_bootstrap();
861 #endif
862 g.isHTTP = 1;
863 cgi_destination(CGI_BODY);
 
864 if( zScriptName==0 ) malformed_request("missing SCRIPT_NAME");
865 if( zRequestUri==0 ){
866 const char *z = zPathInfo;
867 if( zPathInfo==0 ){
868 malformed_request("missing PATH_INFO and/or REQUEST_URI");
869 }
870 if( z[0]=='/' ) z++;
871 zRequestUri = mprintf("%s/%s", zScriptName, z);
872 cgi_set_parameter("REQUEST_URI", zRequestUri);
873 }
874 if( zPathInfo==0 ){
875 int i, j;
876 for(i=0; zRequestUri[i]==zScriptName[i] && zRequestUri[i]; i++){}
877 for(j=i; zRequestUri[j] && zRequestUri[j]!='?'; j++){}
878 cgi_set_parameter("PATH_INFO", mprintf("%.*s", j-i, zRequestUri+i));
879 }
880
+1 -1
--- src/checkin.c
+++ src/checkin.c
@@ -800,11 +800,11 @@
800800
#else
801801
blob_init(&prompt, zInit, -1);
802802
#endif
803803
blob_append(&prompt,
804804
"\n"
805
- "# Enter comments on this check-in. Lines beginning with # are ignored.\n"
805
+ "# Enter commit message for this check-in. Lines beginning with # are ignored.\n"
806806
"#\n", -1
807807
);
808808
blob_appendf(&prompt, "# user: %s\n", p->zUserOvrd ? p->zUserOvrd : g.zLogin);
809809
if( p->zBranch && p->zBranch[0] ){
810810
blob_appendf(&prompt, "# tags: %s\n#\n", p->zBranch);
811811
--- src/checkin.c
+++ src/checkin.c
@@ -800,11 +800,11 @@
800 #else
801 blob_init(&prompt, zInit, -1);
802 #endif
803 blob_append(&prompt,
804 "\n"
805 "# Enter comments on this check-in. Lines beginning with # are ignored.\n"
806 "#\n", -1
807 );
808 blob_appendf(&prompt, "# user: %s\n", p->zUserOvrd ? p->zUserOvrd : g.zLogin);
809 if( p->zBranch && p->zBranch[0] ){
810 blob_appendf(&prompt, "# tags: %s\n#\n", p->zBranch);
811
--- src/checkin.c
+++ src/checkin.c
@@ -800,11 +800,11 @@
800 #else
801 blob_init(&prompt, zInit, -1);
802 #endif
803 blob_append(&prompt,
804 "\n"
805 "# Enter commit message for this check-in. Lines beginning with # are ignored.\n"
806 "#\n", -1
807 );
808 blob_appendf(&prompt, "# user: %s\n", p->zUserOvrd ? p->zUserOvrd : g.zLogin);
809 if( p->zBranch && p->zBranch[0] ){
810 blob_appendf(&prompt, "# tags: %s\n#\n", p->zBranch);
811
+1 -1
--- src/checkin.c
+++ src/checkin.c
@@ -800,11 +800,11 @@
800800
#else
801801
blob_init(&prompt, zInit, -1);
802802
#endif
803803
blob_append(&prompt,
804804
"\n"
805
- "# Enter comments on this check-in. Lines beginning with # are ignored.\n"
805
+ "# Enter commit message for this check-in. Lines beginning with # are ignored.\n"
806806
"#\n", -1
807807
);
808808
blob_appendf(&prompt, "# user: %s\n", p->zUserOvrd ? p->zUserOvrd : g.zLogin);
809809
if( p->zBranch && p->zBranch[0] ){
810810
blob_appendf(&prompt, "# tags: %s\n#\n", p->zBranch);
811811
--- src/checkin.c
+++ src/checkin.c
@@ -800,11 +800,11 @@
800 #else
801 blob_init(&prompt, zInit, -1);
802 #endif
803 blob_append(&prompt,
804 "\n"
805 "# Enter comments on this check-in. Lines beginning with # are ignored.\n"
806 "#\n", -1
807 );
808 blob_appendf(&prompt, "# user: %s\n", p->zUserOvrd ? p->zUserOvrd : g.zLogin);
809 if( p->zBranch && p->zBranch[0] ){
810 blob_appendf(&prompt, "# tags: %s\n#\n", p->zBranch);
811
--- src/checkin.c
+++ src/checkin.c
@@ -800,11 +800,11 @@
800 #else
801 blob_init(&prompt, zInit, -1);
802 #endif
803 blob_append(&prompt,
804 "\n"
805 "# Enter commit message for this check-in. Lines beginning with # are ignored.\n"
806 "#\n", -1
807 );
808 blob_appendf(&prompt, "# user: %s\n", p->zUserOvrd ? p->zUserOvrd : g.zLogin);
809 if( p->zBranch && p->zBranch[0] ){
810 blob_appendf(&prompt, "# tags: %s\n#\n", p->zBranch);
811
--- src/clone.c
+++ src/clone.c
@@ -131,10 +131,11 @@
131131
}
132132
133133
zDefaultUser = find_option("admin-user","A",1);
134134
135135
url_parse(g.argv[2], URL_PROMPT_PW|URL_ASK_REMEMBER_PW);
136
+ if( zDefaultUser==0 && g.urlUser!=0 ) zDefaultUser = g.urlUser;
136137
if( g.urlIsFile ){
137138
file_copy(g.urlName, g.argv[3]);
138139
db_close(1);
139140
db_open_repository(g.argv[3]);
140141
db_record_repository_filename(g.argv[3]);
141142
--- src/clone.c
+++ src/clone.c
@@ -131,10 +131,11 @@
131 }
132
133 zDefaultUser = find_option("admin-user","A",1);
134
135 url_parse(g.argv[2], URL_PROMPT_PW|URL_ASK_REMEMBER_PW);
 
136 if( g.urlIsFile ){
137 file_copy(g.urlName, g.argv[3]);
138 db_close(1);
139 db_open_repository(g.argv[3]);
140 db_record_repository_filename(g.argv[3]);
141
--- src/clone.c
+++ src/clone.c
@@ -131,10 +131,11 @@
131 }
132
133 zDefaultUser = find_option("admin-user","A",1);
134
135 url_parse(g.argv[2], URL_PROMPT_PW|URL_ASK_REMEMBER_PW);
136 if( zDefaultUser==0 && g.urlUser!=0 ) zDefaultUser = g.urlUser;
137 if( g.urlIsFile ){
138 file_copy(g.urlName, g.argv[3]);
139 db_close(1);
140 db_open_repository(g.argv[3]);
141 db_record_repository_filename(g.argv[3]);
142
+1 -1
--- src/config.h
+++ src/config.h
@@ -26,11 +26,11 @@
2626
# define _FILE_OFFSET_BITS 64
2727
#endif
2828
#define _LARGEFILE_SOURCE 1
2929
3030
/* Make sure that in Win32 builds, _USE_32BIT_TIME_T is always defined. */
31
-#if defined(_WIN32) && !defined(_WIN64)
31
+#if defined(_WIN32) && !defined(_WIN64) && !defined(_USE_32BIT_TIME_T)
3232
# define _USE_32BIT_TIME_T
3333
#endif
3434
3535
#ifdef HAVE_AUTOCONFIG_H
3636
#include "autoconfig.h"
3737
--- src/config.h
+++ src/config.h
@@ -26,11 +26,11 @@
26 # define _FILE_OFFSET_BITS 64
27 #endif
28 #define _LARGEFILE_SOURCE 1
29
30 /* Make sure that in Win32 builds, _USE_32BIT_TIME_T is always defined. */
31 #if defined(_WIN32) && !defined(_WIN64)
32 # define _USE_32BIT_TIME_T
33 #endif
34
35 #ifdef HAVE_AUTOCONFIG_H
36 #include "autoconfig.h"
37
--- src/config.h
+++ src/config.h
@@ -26,11 +26,11 @@
26 # define _FILE_OFFSET_BITS 64
27 #endif
28 #define _LARGEFILE_SOURCE 1
29
30 /* Make sure that in Win32 builds, _USE_32BIT_TIME_T is always defined. */
31 #if defined(_WIN32) && !defined(_WIN64) && !defined(_USE_32BIT_TIME_T)
32 # define _USE_32BIT_TIME_T
33 #endif
34
35 #ifdef HAVE_AUTOCONFIG_H
36 #include "autoconfig.h"
37
+38 -28
--- src/makemake.tcl
+++ src/makemake.tcl
@@ -974,10 +974,13 @@
974974
SRCDIR = $B\src
975975
OBJDIR = .
976976
OX = .
977977
O = .obj
978978
E = .exe
979
+
980
+# Uncomment to enable debug symbols
981
+# DEBUG = 1
979982
980983
# Uncomment to enable JSON API
981984
# FOSSIL_ENABLE_JSON = 1
982985
983986
# Uncomment to enable SSL support
@@ -988,37 +991,44 @@
988991
SSLLIBDIR = $(B)\compat\openssl-1.0.1e\out32
989992
SSLLIB = ssleay32.lib libeay32.lib user32.lib gdi32.lib
990993
!endif
991994
992995
# zlib options
993
-ZINCDIR = $(B)\compat\zlib
994
-ZLIBDIR = $(B)\compat\zlib
995
-ZLIB = zlib.lib
996
-
997
-INCL = -I. -I$(SRCDIR) -I$B\win\include -I$(ZINCDIR)
998
-
999
-!ifdef FOSSIL_ENABLE_SSL
1000
-INCL = $(INCL) -I$(SSLINCDIR)
1001
-!endif
1002
-
1003
-CFLAGS = -nologo -MT -O2
1004
-BCC = $(CC) $(CFLAGS)
1005
-TCC = $(CC) -c $(CFLAGS) $(MSCDEF) $(INCL)
1006
-RCC = rc -D_WIN32 -D_MSC_VER $(MSCDEF) $(INCL)
1007
-LIBS = $(ZLIB) ws2_32.lib advapi32.lib
1008
-LIBDIR = -LIBPATH:$(ZLIBDIR)
1009
-
1010
-!ifdef FOSSIL_ENABLE_JSON
1011
-TCC = $(TCC) -DFOSSIL_ENABLE_JSON=1
1012
-RCC = $(RCC) -DFOSSIL_ENABLE_JSON=1
1013
-!endif
1014
-
1015
-!ifdef FOSSIL_ENABLE_SSL
1016
-TCC = $(TCC) -DFOSSIL_ENABLE_SSL=1
1017
-RCC = $(RCC) -DFOSSIL_ENABLE_SSL=1
1018
-LIBS = $(LIBS) $(SSLLIB)
1019
-LIBDIR = $(LIBDIR) -LIBPATH:$(SSLLIBDIR)
996
+ZINCDIR = $(B)\compat\zlib
997
+ZLIBDIR = $(B)\compat\zlib
998
+ZLIB = zlib.lib
999
+
1000
+INCL = -I. -I$(SRCDIR) -I$B\win\include -I$(ZINCDIR)
1001
+
1002
+!ifdef FOSSIL_ENABLE_SSL
1003
+INCL = $(INCL) -I$(SSLINCDIR)
1004
+!endif
1005
+
1006
+CFLAGS = -nologo -MT -O2
1007
+LDFLAGS = /NODEFAULTLIB:msvcrt
1008
+
1009
+!ifdef DEBUG
1010
+CFLAGS = $(CFLAGS) -Zi
1011
+LDFLAGS = $(LDFLAGS) /DEBUG
1012
+!endif
1013
+
1014
+BCC = $(CC) $(CFLAGS)
1015
+TCC = $(CC) -c $(CFLAGS) $(MSCDEF) $(INCL)
1016
+RCC = rc -D_WIN32 -D_MSC_VER $(MSCDEF) $(INCL)
1017
+LIBS = $(ZLIB) ws2_32.lib advapi32.lib
1018
+LIBDIR = -LIBPATH:$(ZLIBDIR)
1019
+
1020
+!ifdef FOSSIL_ENABLE_JSON
1021
+TCC = $(TCC) -DFOSSIL_ENABLE_JSON=1
1022
+RCC = $(RCC) -DFOSSIL_ENABLE_JSON=1
1023
+!endif
1024
+
1025
+!ifdef FOSSIL_ENABLE_SSL
1026
+TCC = $(TCC) -DFOSSIL_ENABLE_SSL=1
1027
+RCC = $(RCC) -DFOSSIL_ENABLE_SSL=1
1028
+LIBS = $(LIBS) $(SSLLIB)
1029
+LIBDIR = $(LIBDIR) -LIBPATH:$(SSLLIBDIR)
10201030
!endif
10211031
}
10221032
regsub -all {[-]D} $SQLITE_OPTIONS {/D} MSC_SQLITE_OPTIONS
10231033
set j " \\\n "
10241034
writeln "SQLITE_OPTIONS = [join $MSC_SQLITE_OPTIONS $j]\n"
@@ -1053,11 +1063,11 @@
10531063
@echo Building zlib from "$(ZLIBDIR)"...
10541064
@pushd "$(ZLIBDIR)" && nmake /f win32\Makefile.msc $(ZLIB) && popd
10551065
10561066
$(APPNAME) : translate$E mkindex$E headers $(OBJ) $(OX)\linkopts zlib
10571067
cd $(OX)
1058
- link /NODEFAULTLIB:msvcrt -OUT:$@ $(LIBDIR) Wsetargv.obj fossil.res @linkopts
1068
+ link $(LDFLAGS) -OUT:$@ $(LIBDIR) Wsetargv.obj fossil.res @linkopts
10591069
10601070
$(OX)\linkopts: $B\win\Makefile.msc}
10611071
set redir {>}
10621072
foreach s [lsort [concat $src $AdditionalObj]] {
10631073
writeln "\techo \$(OX)\\$s.obj $redir \$@"
10641074
--- src/makemake.tcl
+++ src/makemake.tcl
@@ -974,10 +974,13 @@
974 SRCDIR = $B\src
975 OBJDIR = .
976 OX = .
977 O = .obj
978 E = .exe
 
 
 
979
980 # Uncomment to enable JSON API
981 # FOSSIL_ENABLE_JSON = 1
982
983 # Uncomment to enable SSL support
@@ -988,37 +991,44 @@
988 SSLLIBDIR = $(B)\compat\openssl-1.0.1e\out32
989 SSLLIB = ssleay32.lib libeay32.lib user32.lib gdi32.lib
990 !endif
991
992 # zlib options
993 ZINCDIR = $(B)\compat\zlib
994 ZLIBDIR = $(B)\compat\zlib
995 ZLIB = zlib.lib
996
997 INCL = -I. -I$(SRCDIR) -I$B\win\include -I$(ZINCDIR)
998
999 !ifdef FOSSIL_ENABLE_SSL
1000 INCL = $(INCL) -I$(SSLINCDIR)
1001 !endif
1002
1003 CFLAGS = -nologo -MT -O2
1004 BCC = $(CC) $(CFLAGS)
1005 TCC = $(CC) -c $(CFLAGS) $(MSCDEF) $(INCL)
1006 RCC = rc -D_WIN32 -D_MSC_VER $(MSCDEF) $(INCL)
1007 LIBS = $(ZLIB) ws2_32.lib advapi32.lib
1008 LIBDIR = -LIBPATH:$(ZLIBDIR)
1009
1010 !ifdef FOSSIL_ENABLE_JSON
1011 TCC = $(TCC) -DFOSSIL_ENABLE_JSON=1
1012 RCC = $(RCC) -DFOSSIL_ENABLE_JSON=1
1013 !endif
1014
1015 !ifdef FOSSIL_ENABLE_SSL
1016 TCC = $(TCC) -DFOSSIL_ENABLE_SSL=1
1017 RCC = $(RCC) -DFOSSIL_ENABLE_SSL=1
1018 LIBS = $(LIBS) $(SSLLIB)
1019 LIBDIR = $(LIBDIR) -LIBPATH:$(SSLLIBDIR)
 
 
 
 
 
 
 
1020 !endif
1021 }
1022 regsub -all {[-]D} $SQLITE_OPTIONS {/D} MSC_SQLITE_OPTIONS
1023 set j " \\\n "
1024 writeln "SQLITE_OPTIONS = [join $MSC_SQLITE_OPTIONS $j]\n"
@@ -1053,11 +1063,11 @@
1053 @echo Building zlib from "$(ZLIBDIR)"...
1054 @pushd "$(ZLIBDIR)" && nmake /f win32\Makefile.msc $(ZLIB) && popd
1055
1056 $(APPNAME) : translate$E mkindex$E headers $(OBJ) $(OX)\linkopts zlib
1057 cd $(OX)
1058 link /NODEFAULTLIB:msvcrt -OUT:$@ $(LIBDIR) Wsetargv.obj fossil.res @linkopts
1059
1060 $(OX)\linkopts: $B\win\Makefile.msc}
1061 set redir {>}
1062 foreach s [lsort [concat $src $AdditionalObj]] {
1063 writeln "\techo \$(OX)\\$s.obj $redir \$@"
1064
--- src/makemake.tcl
+++ src/makemake.tcl
@@ -974,10 +974,13 @@
974 SRCDIR = $B\src
975 OBJDIR = .
976 OX = .
977 O = .obj
978 E = .exe
979
980 # Uncomment to enable debug symbols
981 # DEBUG = 1
982
983 # Uncomment to enable JSON API
984 # FOSSIL_ENABLE_JSON = 1
985
986 # Uncomment to enable SSL support
@@ -988,37 +991,44 @@
991 SSLLIBDIR = $(B)\compat\openssl-1.0.1e\out32
992 SSLLIB = ssleay32.lib libeay32.lib user32.lib gdi32.lib
993 !endif
994
995 # zlib options
996 ZINCDIR = $(B)\compat\zlib
997 ZLIBDIR = $(B)\compat\zlib
998 ZLIB = zlib.lib
999
1000 INCL = -I. -I$(SRCDIR) -I$B\win\include -I$(ZINCDIR)
1001
1002 !ifdef FOSSIL_ENABLE_SSL
1003 INCL = $(INCL) -I$(SSLINCDIR)
1004 !endif
1005
1006 CFLAGS = -nologo -MT -O2
1007 LDFLAGS = /NODEFAULTLIB:msvcrt
1008
1009 !ifdef DEBUG
1010 CFLAGS = $(CFLAGS) -Zi
1011 LDFLAGS = $(LDFLAGS) /DEBUG
1012 !endif
1013
1014 BCC = $(CC) $(CFLAGS)
1015 TCC = $(CC) -c $(CFLAGS) $(MSCDEF) $(INCL)
1016 RCC = rc -D_WIN32 -D_MSC_VER $(MSCDEF) $(INCL)
1017 LIBS = $(ZLIB) ws2_32.lib advapi32.lib
1018 LIBDIR = -LIBPATH:$(ZLIBDIR)
1019
1020 !ifdef FOSSIL_ENABLE_JSON
1021 TCC = $(TCC) -DFOSSIL_ENABLE_JSON=1
1022 RCC = $(RCC) -DFOSSIL_ENABLE_JSON=1
1023 !endif
1024
1025 !ifdef FOSSIL_ENABLE_SSL
1026 TCC = $(TCC) -DFOSSIL_ENABLE_SSL=1
1027 RCC = $(RCC) -DFOSSIL_ENABLE_SSL=1
1028 LIBS = $(LIBS) $(SSLLIB)
1029 LIBDIR = $(LIBDIR) -LIBPATH:$(SSLLIBDIR)
1030 !endif
1031 }
1032 regsub -all {[-]D} $SQLITE_OPTIONS {/D} MSC_SQLITE_OPTIONS
1033 set j " \\\n "
1034 writeln "SQLITE_OPTIONS = [join $MSC_SQLITE_OPTIONS $j]\n"
@@ -1053,11 +1063,11 @@
1063 @echo Building zlib from "$(ZLIBDIR)"...
1064 @pushd "$(ZLIBDIR)" && nmake /f win32\Makefile.msc $(ZLIB) && popd
1065
1066 $(APPNAME) : translate$E mkindex$E headers $(OBJ) $(OX)\linkopts zlib
1067 cd $(OX)
1068 link $(LDFLAGS) -OUT:$@ $(LIBDIR) Wsetargv.obj fossil.res @linkopts
1069
1070 $(OX)\linkopts: $B\win\Makefile.msc}
1071 set redir {>}
1072 foreach s [lsort [concat $src $AdditionalObj]] {
1073 writeln "\techo \$(OX)\\$s.obj $redir \$@"
1074
+1 -1
--- src/shell.c
+++ src/shell.c
@@ -1202,11 +1202,11 @@
12021202
}
12031203
do{
12041204
/* extract the data and data types */
12051205
for(i=0; i<nCol; i++){
12061206
aiTypes[i] = x = sqlite3_column_type(pStmt, i);
1207
- if( x==SQLITE_BLOB && pArg->mode==MODE_Insert ){
1207
+ if( x==SQLITE_BLOB && pArg && pArg->mode==MODE_Insert ){
12081208
azVals[i] = "";
12091209
}else{
12101210
azVals[i] = (char*)sqlite3_column_text(pStmt, i);
12111211
}
12121212
if( !azVals[i] && (aiTypes[i]!=SQLITE_NULL) ){
12131213
--- src/shell.c
+++ src/shell.c
@@ -1202,11 +1202,11 @@
1202 }
1203 do{
1204 /* extract the data and data types */
1205 for(i=0; i<nCol; i++){
1206 aiTypes[i] = x = sqlite3_column_type(pStmt, i);
1207 if( x==SQLITE_BLOB && pArg->mode==MODE_Insert ){
1208 azVals[i] = "";
1209 }else{
1210 azVals[i] = (char*)sqlite3_column_text(pStmt, i);
1211 }
1212 if( !azVals[i] && (aiTypes[i]!=SQLITE_NULL) ){
1213
--- src/shell.c
+++ src/shell.c
@@ -1202,11 +1202,11 @@
1202 }
1203 do{
1204 /* extract the data and data types */
1205 for(i=0; i<nCol; i++){
1206 aiTypes[i] = x = sqlite3_column_type(pStmt, i);
1207 if( x==SQLITE_BLOB && pArg && pArg->mode==MODE_Insert ){
1208 azVals[i] = "";
1209 }else{
1210 azVals[i] = (char*)sqlite3_column_text(pStmt, i);
1211 }
1212 if( !azVals[i] && (aiTypes[i]!=SQLITE_NULL) ){
1213
+269 -122
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -135,11 +135,11 @@
135135
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
136136
** [sqlite_version()] and [sqlite_source_id()].
137137
*/
138138
#define SQLITE_VERSION "3.8.1"
139139
#define SQLITE_VERSION_NUMBER 3008001
140
-#define SQLITE_SOURCE_ID "2013-10-11 13:27:26 03593817ab5abdd4bbaa5e47e2e4745eef025af9"
140
+#define SQLITE_SOURCE_ID "2013-10-17 12:57:35 c78be6d786c19073b3a6730dfe3fb1be54f5657a"
141141
142142
/*
143143
** CAPI3REF: Run-Time Library Version Numbers
144144
** KEYWORDS: sqlite3_version, sqlite3_sourceid
145145
**
@@ -1643,31 +1643,31 @@
16431643
** supplied by the application must not invoke any SQLite interface.
16441644
** In a multi-threaded application, the application-defined logger
16451645
** function must be threadsafe. </dd>
16461646
**
16471647
** [[SQLITE_CONFIG_URI]] <dt>SQLITE_CONFIG_URI
1648
-** <dd> This option takes a single argument of type int. If non-zero, then
1648
+** <dd>^(This option takes a single argument of type int. If non-zero, then
16491649
** URI handling is globally enabled. If the parameter is zero, then URI handling
1650
-** is globally disabled. If URI handling is globally enabled, all filenames
1650
+** is globally disabled.)^ ^If URI handling is globally enabled, all filenames
16511651
** passed to [sqlite3_open()], [sqlite3_open_v2()], [sqlite3_open16()] or
16521652
** specified as part of [ATTACH] commands are interpreted as URIs, regardless
16531653
** of whether or not the [SQLITE_OPEN_URI] flag is set when the database
1654
-** connection is opened. If it is globally disabled, filenames are
1654
+** connection is opened. ^If it is globally disabled, filenames are
16551655
** only interpreted as URIs if the SQLITE_OPEN_URI flag is set when the
1656
-** database connection is opened. By default, URI handling is globally
1656
+** database connection is opened. ^(By default, URI handling is globally
16571657
** disabled. The default value may be changed by compiling with the
1658
-** [SQLITE_USE_URI] symbol defined.
1658
+** [SQLITE_USE_URI] symbol defined.)^
16591659
**
16601660
** [[SQLITE_CONFIG_COVERING_INDEX_SCAN]] <dt>SQLITE_CONFIG_COVERING_INDEX_SCAN
1661
-** <dd> This option takes a single integer argument which is interpreted as
1661
+** <dd>^This option takes a single integer argument which is interpreted as
16621662
** a boolean in order to enable or disable the use of covering indices for
1663
-** full table scans in the query optimizer. The default setting is determined
1663
+** full table scans in the query optimizer. ^The default setting is determined
16641664
** by the [SQLITE_ALLOW_COVERING_INDEX_SCAN] compile-time option, or is "on"
16651665
** if that compile-time option is omitted.
16661666
** The ability to disable the use of covering indices for full table scans
16671667
** is because some incorrectly coded legacy applications might malfunction
1668
-** malfunction when the optimization is enabled. Providing the ability to
1668
+** when the optimization is enabled. Providing the ability to
16691669
** disable the optimization allows the older, buggy application code to work
16701670
** without change even with newer versions of SQLite.
16711671
**
16721672
** [[SQLITE_CONFIG_PCACHE]] [[SQLITE_CONFIG_GETPCACHE]]
16731673
** <dt>SQLITE_CONFIG_PCACHE and SQLITE_CONFIG_GETPCACHE
@@ -1692,20 +1692,20 @@
16921692
** configuration option can be seen in the "test_sqllog.c" source file in
16931693
** the canonical SQLite source tree.</dd>
16941694
**
16951695
** [[SQLITE_CONFIG_MMAP_SIZE]]
16961696
** <dt>SQLITE_CONFIG_MMAP_SIZE
1697
-** <dd>SQLITE_CONFIG_MMAP_SIZE takes two 64-bit integer (sqlite3_int64) values
1697
+** <dd>^SQLITE_CONFIG_MMAP_SIZE takes two 64-bit integer (sqlite3_int64) values
16981698
** that are the default mmap size limit (the default setting for
16991699
** [PRAGMA mmap_size]) and the maximum allowed mmap size limit.
1700
-** The default setting can be overridden by each database connection using
1700
+** ^The default setting can be overridden by each database connection using
17011701
** either the [PRAGMA mmap_size] command, or by using the
1702
-** [SQLITE_FCNTL_MMAP_SIZE] file control. The maximum allowed mmap size
1702
+** [SQLITE_FCNTL_MMAP_SIZE] file control. ^(The maximum allowed mmap size
17031703
** cannot be changed at run-time. Nor may the maximum allowed mmap size
17041704
** exceed the compile-time maximum mmap size set by the
1705
-** [SQLITE_MAX_MMAP_SIZE] compile-time option.
1706
-** If either argument to this option is negative, then that argument is
1705
+** [SQLITE_MAX_MMAP_SIZE] compile-time option.)^
1706
+** ^If either argument to this option is negative, then that argument is
17071707
** changed to its compile-time default.
17081708
** </dl>
17091709
*/
17101710
#define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */
17111711
#define SQLITE_CONFIG_MULTITHREAD 2 /* nil */
@@ -12468,14 +12468,14 @@
1246812468
SQLITE_PRIVATE int sqlite3FkRequired(Parse*, Table*, int*, int);
1246912469
SQLITE_PRIVATE u32 sqlite3FkOldmask(Parse*, Table*);
1247012470
SQLITE_PRIVATE FKey *sqlite3FkReferences(Table *);
1247112471
#else
1247212472
#define sqlite3FkActions(a,b,c,d,e,f)
12473
- #define sqlite3FkCheck(a,b,c,d)
12473
+ #define sqlite3FkCheck(a,b,c,d,e,f)
1247412474
#define sqlite3FkDropTable(a,b,c)
12475
- #define sqlite3FkOldmask(a,b) 0
12476
- #define sqlite3FkRequired(a,b,c,d,e,f) 0
12475
+ #define sqlite3FkOldmask(a,b) 0
12476
+ #define sqlite3FkRequired(a,b,c,d) 0
1247712477
#endif
1247812478
#ifndef SQLITE_OMIT_FOREIGN_KEY
1247912479
SQLITE_PRIVATE void sqlite3FkDelete(sqlite3 *, Table*);
1248012480
SQLITE_PRIVATE int sqlite3FkLocateIndex(Parse*,Table*,FKey*,Index**,int**);
1248112481
#else
@@ -14430,10 +14430,14 @@
1443014430
** is available. This routine returns 0 on success and
1443114431
** non-zero on any kind of error.
1443214432
**
1443314433
** If the sqlite3GlobalConfig.bLocaltimeFault variable is true then this
1443414434
** routine will always fail.
14435
+**
14436
+** EVIDENCE-OF: R-62172-00036 In this implementation, the standard C
14437
+** library function localtime_r() is used to assist in the calculation of
14438
+** local time.
1443514439
*/
1443614440
static int osLocaltime(time_t *t, struct tm *pTm){
1443714441
int rc;
1443814442
#if (!defined(HAVE_LOCALTIME_R) || !HAVE_LOCALTIME_R) \
1443914443
&& (!defined(HAVE_LOCALTIME_S) || !HAVE_LOCALTIME_S)
@@ -14486,10 +14490,15 @@
1448614490
memset(&sLocal, 0, sizeof(sLocal));
1448714491
1448814492
x = *p;
1448914493
computeYMD_HMS(&x);
1449014494
if( x.Y<1971 || x.Y>=2038 ){
14495
+ /* EVIDENCE-OF: R-55269-29598 The localtime_r() C function normally only
14496
+ ** works for years between 1970 and 2037. For dates outside this range,
14497
+ ** SQLite attempts to map the year into an equivalent year within this
14498
+ ** range, do the calculation, then map the year back.
14499
+ */
1449114500
x.Y = 2000;
1449214501
x.M = 1;
1449314502
x.D = 1;
1449414503
x.h = 0;
1449514504
x.m = 0;
@@ -33006,12 +33015,11 @@
3300633015
#endif
3300733016
assert( pFile->h!=NULL && pFile->h!=INVALID_HANDLE_VALUE );
3300833017
OSTRACE(("CLOSE file=%p\n", pFile->h));
3300933018
3301033019
#if SQLITE_MAX_MMAP_SIZE>0
33011
- rc = winUnmapfile(pFile);
33012
- if( rc!=SQLITE_OK ) return rc;
33020
+ winUnmapfile(pFile);
3301333021
#endif
3301433022
3301533023
do{
3301633024
rc = osCloseHandle(pFile->h);
3301733025
/* SimulateIOError( rc=0; cnt=MX_CLOSE_ATTEMPT; ); */
@@ -33813,11 +33821,11 @@
3381333821
}
3381433822
*(i64*)pArg = pFile->mmapSizeMax;
3381533823
if( newLimit>=0 && newLimit!=pFile->mmapSizeMax && pFile->nFetchOut==0 ){
3381633824
pFile->mmapSizeMax = newLimit;
3381733825
if( pFile->mmapSize>0 ){
33818
- (void)winUnmapfile(pFile);
33826
+ winUnmapfile(pFile);
3381933827
rc = winMapfile(pFile, -1);
3382033828
}
3382133829
}
3382233830
OSTRACE(("FCNTL file=%p, rc=%s\n", pFile->h, sqlite3ErrName(rc)));
3382333831
return rc;
@@ -34030,11 +34038,11 @@
3403034038
osGetCurrentProcessId(), deleteFlag));
3403134039
pp = &winShmNodeList;
3403234040
while( (p = *pp)!=0 ){
3403334041
if( p->nRef==0 ){
3403434042
int i;
34035
- if( p->mutex ) sqlite3_mutex_free(p->mutex);
34043
+ if( p->mutex ){ sqlite3_mutex_free(p->mutex); }
3403634044
for(i=0; i<p->nRegion; i++){
3403734045
BOOL bRc = osUnmapViewOfFile(p->aRegion[i].pMap);
3403834046
OSTRACE(("SHM-PURGE-UNMAP pid=%lu, region=%d, rc=%s\n",
3403934047
osGetCurrentProcessId(), i, bRc ? "ok" : "failed"));
3404034048
UNUSED_VARIABLE_VALUE(bRc);
@@ -34883,10 +34891,11 @@
3488334891
** API prior to using it.
3488434892
*/
3488534893
if( winIsDriveLetterAndColon(zDir) ){
3488634894
zConverted = winConvertFromUtf8Filename(zDir);
3488734895
if( !zConverted ){
34896
+ sqlite3_free(zBuf);
3488834897
OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
3488934898
return SQLITE_IOERR_NOMEM;
3489034899
}
3489134900
if( winIsDir(zConverted) ){
3489234901
sqlite3_snprintf(nBuf-30, zBuf, "%s", zDir);
@@ -34895,17 +34904,19 @@
3489534904
}
3489634905
sqlite3_free(zConverted);
3489734906
}else{
3489834907
zConverted = sqlite3MallocZero( nBuf+1 );
3489934908
if( !zConverted ){
34909
+ sqlite3_free(zBuf);
3490034910
OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
3490134911
return SQLITE_IOERR_NOMEM;
3490234912
}
3490334913
if( cygwin_conv_path(
3490434914
osIsNT() ? CCP_POSIX_TO_WIN_W : CCP_POSIX_TO_WIN_A, zDir,
3490534915
zConverted, nBuf+1)<0 ){
3490634916
sqlite3_free(zConverted);
34917
+ sqlite3_free(zBuf);
3490734918
OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_CONVPATH\n"));
3490834919
return winLogError(SQLITE_IOERR_CONVPATH, (DWORD)errno,
3490934920
"winGetTempname1", zDir);
3491034921
}
3491134922
if( winIsDir(zConverted) ){
@@ -34915,10 +34926,11 @@
3491534926
*/
3491634927
if( osIsNT() ){
3491734928
char *zUtf8 = winUnicodeToUtf8(zConverted);
3491834929
if( !zUtf8 ){
3491934930
sqlite3_free(zConverted);
34931
+ sqlite3_free(zBuf);
3492034932
OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
3492134933
return SQLITE_IOERR_NOMEM;
3492234934
}
3492334935
sqlite3_snprintf(nBuf-30, zBuf, "%s", zUtf8);
3492434936
sqlite3_free(zUtf8);
@@ -34930,11 +34942,10 @@
3493034942
break;
3493134943
}
3493234944
}
3493334945
sqlite3_free(zConverted);
3493434946
}
34935
- break;
3493634947
}
3493734948
}
3493834949
#elif !SQLITE_OS_WINRT && !defined(__CYGWIN__)
3493934950
else if( osIsNT() ){
3494034951
char *zMulti;
@@ -35300,13 +35311,13 @@
3530035311
pFile->zDeleteOnClose = zConverted;
3530135312
}else
3530235313
#endif
3530335314
{
3530435315
sqlite3_free(zConverted);
35305
- sqlite3_free(zTmpname);
3530635316
}
3530735317
35318
+ sqlite3_free(zTmpname);
3530835319
pFile->pMethod = &winIoMethod;
3530935320
pFile->pVfs = pVfs;
3531035321
pFile->h = h;
3531135322
if( isReadonly ){
3531235323
pFile->ctrlFlags |= WINFILE_RDONLY;
@@ -52033,10 +52044,22 @@
5203352044
** MX_CELL_SIZE(pBt) bytes.
5203452045
*/
5203552046
static void allocateTempSpace(BtShared *pBt){
5203652047
if( !pBt->pTmpSpace ){
5203752048
pBt->pTmpSpace = sqlite3PageMalloc( pBt->pageSize );
52049
+
52050
+ /* One of the uses of pBt->pTmpSpace is to format cells before
52051
+ ** inserting them into a leaf page (function fillInCell()). If
52052
+ ** a cell is less than 4 bytes in size, it is rounded up to 4 bytes
52053
+ ** by the various routines that manipulate binary cells. Which
52054
+ ** can mean that fillInCell() only initializes the first 2 or 3
52055
+ ** bytes of pTmpSpace, but that the first 4 bytes are copied from
52056
+ ** it into a database page. This is not actually a problem, but it
52057
+ ** does cause a valgrind error when the 1 or 2 bytes of unitialized
52058
+ ** data is passed to system call write(). So to avoid this error,
52059
+ ** zero the first 4 bytes of temp space here. */
52060
+ if( pBt->pTmpSpace ) memset(pBt->pTmpSpace, 0, 4);
5203852061
}
5203952062
}
5204052063
5204152064
/*
5204252065
** Free the pBt->pTmpSpace allocation
@@ -60299,11 +60322,13 @@
6029960322
}
6030060323
6030160324
pRec->nField = p->iVal+1;
6030260325
return &pRec->aMem[p->iVal];
6030360326
}
60304
-#endif
60327
+#else
60328
+ UNUSED_PARAMETER(p);
60329
+#endif /* defined(SQLITE_ENABLE_STAT3_OR_STAT4) */
6030560330
return sqlite3ValueNew(db);
6030660331
}
6030760332
6030860333
/*
6030960334
** Extract a value from the supplied expression in the manner described
@@ -60313,11 +60338,11 @@
6031360338
** If pCtx is NULL and an error occurs after the sqlite3_value object
6031460339
** has been allocated, it is freed before returning. Or, if pCtx is not
6031560340
** NULL, it is assumed that the caller will free any allocated object
6031660341
** in all cases.
6031760342
*/
60318
-int valueFromExpr(
60343
+static int valueFromExpr(
6031960344
sqlite3 *db, /* The database connection */
6032060345
Expr *pExpr, /* The expression to evaluate */
6032160346
u8 enc, /* Encoding to use */
6032260347
u8 affinity, /* Affinity to use */
6032360348
sqlite3_value **ppVal, /* Write the new value here */
@@ -60470,10 +60495,11 @@
6047060495
int nVal; /* Bytes of space required for argv[0] */
6047160496
int nRet;
6047260497
sqlite3 *db;
6047360498
u8 *aRet;
6047460499
60500
+ UNUSED_PARAMETER( argc );
6047560501
iSerial = sqlite3VdbeSerialType(argv[0], file_format);
6047660502
nSerial = sqlite3VarintLen(iSerial);
6047760503
nVal = sqlite3VdbeSerialTypeLen(iSerial);
6047860504
db = sqlite3_context_db_handle(context);
6047960505
@@ -75410,10 +75436,14 @@
7541075436
sqlite3ErrorMsg(pParse, "second argument to likelihood() must be a "
7541175437
"constant between 0.0 and 1.0");
7541275438
pNC->nErr++;
7541375439
}
7541475440
}else{
75441
+ /* EVIDENCE-OF: R-61304-29449 The unlikely(X) function is equivalent to
75442
+ ** likelihood(X, 0.0625).
75443
+ ** EVIDENCE-OF: R-01283-11636 The unlikely(X) function is short-hand for
75444
+ ** likelihood(X,0.0625). */
7541575445
pExpr->iTable = 62; /* TUNING: Default 2nd arg to unlikely() is 0.0625 */
7541675446
}
7541775447
}
7541875448
}
7541975449
#ifndef SQLITE_OMIT_AUTHORIZATION
@@ -81284,11 +81314,11 @@
8128481314
** The sqlite_stat2 table is superseded by sqlite_stat3, which is only
8128581315
** created and used by SQLite versions 3.7.9 and later and with
8128681316
** SQLITE_ENABLE_STAT3 defined. The functionality of sqlite_stat3
8128781317
** is a superset of sqlite_stat2. The sqlite_stat4 is an enhanced
8128881318
** version of sqlite_stat3 and is only available when compiled with
81289
-** SQLITE_ENABLE_STAT4 and in SQLite versions 3.8.0 and later. It is
81319
+** SQLITE_ENABLE_STAT4 and in SQLite versions 3.8.1 and later. It is
8129081320
** not possible to enable both STAT3 and STAT4 at the same time. If they
8129181321
** are both enabled, then STAT4 takes precedence.
8129281322
**
8129381323
** For most applications, sqlite_stat1 provides all the statisics required
8129481324
** for the query planner to make good choices.
@@ -81360,16 +81390,16 @@
8136081390
**
8136181391
** The sqlite_stat4 table contains multiple entries for each index.
8136281392
** The idx column names the index and the tbl column is the table of the
8136381393
** index. If the idx and tbl columns are the same, then the sample is
8136481394
** of the INTEGER PRIMARY KEY. The sample column is a blob which is the
81365
-** binary encoding of a key from the index, with the trailing rowid
81366
-** omitted. The nEq column is a list of integers. The first integer
81367
-** is the approximate number of entries in the index whose left-most
81368
-** column exactly matches the left-most column of the sample. The second
81369
-** integer in nEq is the approximate number of entries in the index where
81370
-** the first two columns match the first two columns of the sample.
81395
+** binary encoding of a key from the index. The nEq column is a
81396
+** list of integers. The first integer is the approximate number
81397
+** of entries in the index whose left-most column exactly matches
81398
+** the left-most column of the sample. The second integer in nEq
81399
+** is the approximate number of entries in the index where the
81400
+** first two columns match the first two columns of the sample.
8137181401
** And so forth. nLt is another list of integers that show the approximate
8137281402
** number of entries that are strictly less than the sample. The first
8137381403
** integer in nLt contains the number of entries in the index where the
8137481404
** left-most column is less than the left-most column of the sample.
8137581405
** The K-th integer in the nLt entry is the number of index entries
@@ -81696,11 +81726,11 @@
8169681726
}
8169781727
8169881728
/*
8169981729
** Copy the contents of object (*pFrom) into (*pTo).
8170081730
*/
81701
-void sampleCopy(Stat4Accum *p, Stat4Sample *pTo, Stat4Sample *pFrom){
81731
+static void sampleCopy(Stat4Accum *p, Stat4Sample *pTo, Stat4Sample *pFrom){
8170281732
pTo->iRowid = pFrom->iRowid;
8170381733
pTo->isPSample = pFrom->isPSample;
8170481734
pTo->iCol = pFrom->iCol;
8170581735
pTo->iHash = pFrom->iHash;
8170681736
memcpy(pTo->anEq, pFrom->anEq, sizeof(tRowcnt)*p->nCol);
@@ -81841,10 +81871,15 @@
8184181871
){
8184281872
sampleInsert(p, &p->current, 0);
8184381873
}
8184481874
}
8184581875
#endif
81876
+
81877
+#ifndef SQLITE_ENABLE_STAT3_OR_STAT4
81878
+ UNUSED_PARAMETER( p );
81879
+ UNUSED_PARAMETER( iChng );
81880
+#endif
8184681881
}
8184781882
8184881883
/*
8184981884
** Implementation of the stat_push SQL function: stat_push(P,R,C)
8185081885
** Arguments:
@@ -81866,10 +81901,12 @@
8186681901
8186781902
/* The three function arguments */
8186881903
Stat4Accum *p = (Stat4Accum*)sqlite3_value_blob(argv[0]);
8186981904
int iChng = sqlite3_value_int(argv[1]);
8187081905
81906
+ UNUSED_PARAMETER( argc );
81907
+ UNUSED_PARAMETER( context );
8187181908
assert( p->nCol>1 ); /* Includes rowid field */
8187281909
assert( iChng<p->nCol );
8187381910
8187481911
if( p->nRow==0 ){
8187581912
/* This is the first call to this function. Do initialization. */
@@ -82051,10 +82088,13 @@
8205182088
sqlite3_result_text(context, zRet, -1, sqlite3_free);
8205282089
}
8205382090
}
8205482091
}
8205582092
#endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */
82093
+#ifndef SQLITE_DEBUG
82094
+ UNUSED_PARAMETER( argc );
82095
+#endif
8205682096
}
8205782097
static const FuncDef statGetFuncdef = {
8205882098
1+IsStat34, /* nArg */
8205982099
SQLITE_UTF8, /* funcFlags */
8206082100
0, /* pUserData */
@@ -82069,12 +82109,14 @@
8206982109
8207082110
static void callStatGet(Vdbe *v, int regStat4, int iParam, int regOut){
8207182111
assert( regOut!=regStat4 && regOut!=regStat4+1 );
8207282112
#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
8207382113
sqlite3VdbeAddOp2(v, OP_Integer, iParam, regStat4+1);
82074
-#else
82114
+#elif SQLITE_DEBUG
8207582115
assert( iParam==STAT_GET_STAT1 );
82116
+#else
82117
+ UNUSED_PARAMETER( iParam );
8207682118
#endif
8207782119
sqlite3VdbeAddOp3(v, OP_Function, 0, regStat4, regOut);
8207882120
sqlite3VdbeChangeP4(v, -1, (char*)&statGetFuncdef, P4_FUNCDEF);
8207982121
sqlite3VdbeChangeP5(v, 1 + IsStat34);
8208082122
}
@@ -84833,11 +84875,11 @@
8483384875
*pszEst = 1; /* default size is approx 4 bytes */
8483484876
if( aff<=SQLITE_AFF_NONE ){
8483584877
if( zChar ){
8483684878
while( zChar[0] ){
8483784879
if( sqlite3Isdigit(zChar[0]) ){
84838
- int v;
84880
+ int v = 0;
8483984881
sqlite3GetInt32(zChar, &v);
8484084882
v = v/4 + 1;
8484184883
if( v>255 ) v = 255;
8484284884
*pszEst = v; /* BLOB(k), VARCHAR(k), CHAR(k) -> r=(k/4+1) */
8484384885
break;
@@ -91144,11 +91186,11 @@
9114491186
** generating any VDBE code. If one can be found, then jump over
9114591187
** the entire DELETE if there are no outstanding deferred constraints
9114691188
** when this statement is run. */
9114791189
FKey *p;
9114891190
for(p=pTab->pFKey; p; p=p->pNextFrom){
91149
- if( p->isDeferred ) break;
91191
+ if( p->isDeferred || (db->flags & SQLITE_DeferFKs) ) break;
9115091192
}
9115191193
if( !p ) return;
9115291194
iSkip = sqlite3VdbeMakeLabel(v);
9115391195
sqlite3VdbeAddOp2(v, OP_FkIfZero, 1, iSkip);
9115491196
}
@@ -91158,15 +91200,22 @@
9115891200
pParse->disableTriggers = 0;
9115991201
9116091202
/* If the DELETE has generated immediate foreign key constraint
9116191203
** violations, halt the VDBE and return an error at this point, before
9116291204
** any modifications to the schema are made. This is because statement
91163
- ** transactions are not able to rollback schema changes. */
91164
- sqlite3VdbeAddOp2(v, OP_FkIfZero, 0, sqlite3VdbeCurrentAddr(v)+2);
91165
- sqlite3HaltConstraint(pParse, SQLITE_CONSTRAINT_FOREIGNKEY,
91166
- OE_Abort, "foreign key constraint failed", P4_STATIC
91167
- );
91205
+ ** transactions are not able to rollback schema changes.
91206
+ **
91207
+ ** If the SQLITE_DeferFKs flag is set, then this is not required, as
91208
+ ** the statement transaction will not be rolled back even if FK
91209
+ ** constraints are violated.
91210
+ */
91211
+ if( (db->flags & SQLITE_DeferFKs)==0 ){
91212
+ sqlite3VdbeAddOp2(v, OP_FkIfZero, 0, sqlite3VdbeCurrentAddr(v)+2);
91213
+ sqlite3HaltConstraint(pParse, SQLITE_CONSTRAINT_FOREIGNKEY,
91214
+ OE_Abort, "foreign key constraint failed", P4_STATIC
91215
+ );
91216
+ }
9116891217
9116991218
if( iSkip ){
9117091219
sqlite3VdbeResolveLabel(v, iSkip);
9117191220
}
9117291221
}
@@ -95164,22 +95213,23 @@
9516495213
#define PragTyp_MMAP_SIZE 23
9516595214
#define PragTyp_PAGE_SIZE 24
9516695215
#define PragTyp_SECURE_DELETE 25
9516795216
#define PragTyp_SHRINK_MEMORY 26
9516895217
#define PragTyp_SOFT_HEAP_LIMIT 27
95169
-#define PragTyp_SYNCHRONOUS 28
95170
-#define PragTyp_TABLE_INFO 29
95171
-#define PragTyp_TEMP_STORE 30
95172
-#define PragTyp_TEMP_STORE_DIRECTORY 31
95173
-#define PragTyp_WAL_AUTOCHECKPOINT 32
95174
-#define PragTyp_WAL_CHECKPOINT 33
95175
-#define PragTyp_ACTIVATE_EXTENSIONS 34
95176
-#define PragTyp_HEXKEY 35
95177
-#define PragTyp_KEY 36
95178
-#define PragTyp_REKEY 37
95179
-#define PragTyp_LOCK_STATUS 38
95180
-#define PragTyp_PARSER_TRACE 39
95218
+#define PragTyp_STATS 28
95219
+#define PragTyp_SYNCHRONOUS 29
95220
+#define PragTyp_TABLE_INFO 30
95221
+#define PragTyp_TEMP_STORE 31
95222
+#define PragTyp_TEMP_STORE_DIRECTORY 32
95223
+#define PragTyp_WAL_AUTOCHECKPOINT 33
95224
+#define PragTyp_WAL_CHECKPOINT 34
95225
+#define PragTyp_ACTIVATE_EXTENSIONS 35
95226
+#define PragTyp_HEXKEY 36
95227
+#define PragTyp_KEY 37
95228
+#define PragTyp_REKEY 38
95229
+#define PragTyp_LOCK_STATUS 39
95230
+#define PragTyp_PARSER_TRACE 40
9518195231
#define PragFlag_NeedSchema 0x01
9518295232
static const struct sPragmaNames {
9518395233
const char *const zName; /* Name of pragma */
9518495234
u8 ePragTyp; /* PragTyp_XXX value */
9518595235
u8 mPragFlag; /* Zero or more PragFlag_XXX values */
@@ -95466,10 +95516,16 @@
9546695516
#if defined(SQLITE_DEBUG)
9546795517
{ /* zName: */ "sql_trace",
9546895518
/* ePragTyp: */ PragTyp_FLAG,
9546995519
/* ePragFlag: */ 0,
9547095520
/* iArg: */ SQLITE_SqlTrace },
95521
+#endif
95522
+#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
95523
+ { /* zName: */ "stats",
95524
+ /* ePragTyp: */ PragTyp_STATS,
95525
+ /* ePragFlag: */ PragFlag_NeedSchema,
95526
+ /* iArg: */ 0 },
9547195527
#endif
9547295528
#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
9547395529
{ /* zName: */ "synchronous",
9547495530
/* ePragTyp: */ PragTyp_SYNCHRONOUS,
9547595531
/* ePragFlag: */ PragFlag_NeedSchema,
@@ -95528,11 +95584,11 @@
9552895584
{ /* zName: */ "writable_schema",
9552995585
/* ePragTyp: */ PragTyp_FLAG,
9553095586
/* ePragFlag: */ 0,
9553195587
/* iArg: */ SQLITE_WriteSchema|SQLITE_RecoveryMode },
9553295588
};
95533
-/* Number of pragmas: 55 on by default, 67 total. */
95589
+/* Number of pragmas: 56 on by default, 68 total. */
9553495590
/* End of the automatically generated pragma table.
9553595591
***************************************************************************/
9553695592
9553795593
/*
9553895594
** Interpret the given string as a safety level. Return 0 for OFF,
@@ -96532,10 +96588,40 @@
9653296588
sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 6);
9653396589
}
9653496590
}
9653596591
}
9653696592
break;
96593
+
96594
+ case PragTyp_STATS: {
96595
+ Index *pIdx;
96596
+ HashElem *i;
96597
+ v = sqlite3GetVdbe(pParse);
96598
+ sqlite3VdbeSetNumCols(v, 4);
96599
+ pParse->nMem = 4;
96600
+ sqlite3CodeVerifySchema(pParse, iDb);
96601
+ sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "table", SQLITE_STATIC);
96602
+ sqlite3VdbeSetColName(v, 1, COLNAME_NAME, "index", SQLITE_STATIC);
96603
+ sqlite3VdbeSetColName(v, 2, COLNAME_NAME, "width", SQLITE_STATIC);
96604
+ sqlite3VdbeSetColName(v, 3, COLNAME_NAME, "height", SQLITE_STATIC);
96605
+ for(i=sqliteHashFirst(&pDb->pSchema->tblHash); i; i=sqliteHashNext(i)){
96606
+ Table *pTab = sqliteHashData(i);
96607
+ sqlite3VdbeAddOp4(v, OP_String8, 0, 1, 0, pTab->zName, 0);
96608
+ sqlite3VdbeAddOp2(v, OP_Null, 0, 2);
96609
+ sqlite3VdbeAddOp2(v, OP_Integer,
96610
+ (int)sqlite3LogEstToInt(pTab->szTabRow), 3);
96611
+ sqlite3VdbeAddOp2(v, OP_Integer, (int)pTab->nRowEst, 4);
96612
+ sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 4);
96613
+ for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
96614
+ sqlite3VdbeAddOp4(v, OP_String8, 0, 2, 0, pIdx->zName, 0);
96615
+ sqlite3VdbeAddOp2(v, OP_Integer,
96616
+ (int)sqlite3LogEstToInt(pIdx->szIdxRow), 3);
96617
+ sqlite3VdbeAddOp2(v, OP_Integer, (int)pIdx->aiRowEst[0], 4);
96618
+ sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 4);
96619
+ }
96620
+ }
96621
+ }
96622
+ break;
9653796623
9653896624
case PragTyp_INDEX_INFO: if( zRight ){
9653996625
Index *pIdx;
9654096626
Table *pTab;
9654196627
pIdx = sqlite3FindIndex(db, zRight, zDb);
@@ -96565,30 +96651,21 @@
9656596651
Table *pTab;
9656696652
int i;
9656796653
pTab = sqlite3FindTable(db, zRight, zDb);
9656896654
if( pTab ){
9656996655
v = sqlite3GetVdbe(pParse);
96570
- sqlite3VdbeSetNumCols(v, 4);
96571
- pParse->nMem = 4;
96656
+ sqlite3VdbeSetNumCols(v, 3);
96657
+ pParse->nMem = 3;
9657296658
sqlite3CodeVerifySchema(pParse, iDb);
9657396659
sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "seq", SQLITE_STATIC);
9657496660
sqlite3VdbeSetColName(v, 1, COLNAME_NAME, "name", SQLITE_STATIC);
9657596661
sqlite3VdbeSetColName(v, 2, COLNAME_NAME, "unique", SQLITE_STATIC);
96576
- sqlite3VdbeSetColName(v, 3, COLNAME_NAME, "avgrowsize", SQLITE_STATIC);
96577
- sqlite3VdbeAddOp2(v, OP_Integer, 0, 1);
96578
- sqlite3VdbeAddOp2(v, OP_Null, 0, 2);
96579
- sqlite3VdbeAddOp2(v, OP_Integer, 1, 3);
96580
- sqlite3VdbeAddOp2(v, OP_Integer,
96581
- (int)sqlite3LogEstToInt(pTab->szTabRow), 4);
96582
- sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 4);
96583
- for(pIdx=pTab->pIndex, i=1; pIdx; pIdx=pIdx->pNext, i++){
96662
+ for(pIdx=pTab->pIndex, i=0; pIdx; pIdx=pIdx->pNext, i++){
9658496663
sqlite3VdbeAddOp2(v, OP_Integer, i, 1);
9658596664
sqlite3VdbeAddOp4(v, OP_String8, 0, 2, 0, pIdx->zName, 0);
9658696665
sqlite3VdbeAddOp2(v, OP_Integer, pIdx->onError!=OE_None, 3);
96587
- sqlite3VdbeAddOp2(v, OP_Integer,
96588
- (int)sqlite3LogEstToInt(pIdx->szIdxRow), 4);
96589
- sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 4);
96666
+ sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 3);
9659096667
}
9659196668
}
9659296669
}
9659396670
break;
9659496671
@@ -96718,12 +96795,12 @@
9671896795
if( pTab->nCol+regRow>pParse->nMem ) pParse->nMem = pTab->nCol + regRow;
9671996796
sqlite3OpenTable(pParse, 0, iDb, pTab, OP_OpenRead);
9672096797
sqlite3VdbeAddOp4(v, OP_String8, 0, regResult, 0, pTab->zName,
9672196798
P4_TRANSIENT);
9672296799
for(i=1, pFK=pTab->pFKey; pFK; i++, pFK=pFK->pNextFrom){
96723
- pParent = sqlite3LocateTable(pParse, 0, pFK->zTo, zDb);
96724
- if( pParent==0 ) break;
96800
+ pParent = sqlite3FindTable(db, pFK->zTo, zDb);
96801
+ if( pParent==0 ) continue;
9672596802
pIdx = 0;
9672696803
sqlite3TableLock(pParse, iDb, pParent->tnum, 0, pParent->zName);
9672796804
x = sqlite3FkLocateIndex(pParse, pParent, pFK, &pIdx, 0);
9672896805
if( x==0 ){
9672996806
if( pIdx==0 ){
@@ -96736,22 +96813,24 @@
9673696813
}else{
9673796814
k = 0;
9673896815
break;
9673996816
}
9674096817
}
96818
+ assert( pParse->nErr>0 || pFK==0 );
9674196819
if( pFK ) break;
9674296820
if( pParse->nTab<i ) pParse->nTab = i;
9674396821
addrTop = sqlite3VdbeAddOp1(v, OP_Rewind, 0);
9674496822
for(i=1, pFK=pTab->pFKey; pFK; i++, pFK=pFK->pNextFrom){
96745
- pParent = sqlite3LocateTable(pParse, 0, pFK->zTo, zDb);
96746
- assert( pParent!=0 );
96823
+ pParent = sqlite3FindTable(db, pFK->zTo, zDb);
9674796824
pIdx = 0;
9674896825
aiCols = 0;
96749
- x = sqlite3FkLocateIndex(pParse, pParent, pFK, &pIdx, &aiCols);
96750
- assert( x==0 );
96826
+ if( pParent ){
96827
+ x = sqlite3FkLocateIndex(pParse, pParent, pFK, &pIdx, &aiCols);
96828
+ assert( x==0 );
96829
+ }
9675196830
addrOk = sqlite3VdbeMakeLabel(v);
96752
- if( pIdx==0 ){
96831
+ if( pParent && pIdx==0 ){
9675396832
int iKey = pFK->aCol[0].iFrom;
9675496833
assert( iKey>=0 && iKey<pTab->nCol );
9675596834
if( iKey!=pTab->iPKey ){
9675696835
sqlite3VdbeAddOp3(v, OP_Column, 0, iKey, regRow);
9675796836
sqlite3ColumnDefault(v, pTab, iKey, regRow);
@@ -96765,17 +96844,19 @@
9676596844
sqlite3VdbeAddOp2(v, OP_Goto, 0, addrOk);
9676696845
sqlite3VdbeJumpHere(v, sqlite3VdbeCurrentAddr(v)-2);
9676796846
}else{
9676896847
for(j=0; j<pFK->nCol; j++){
9676996848
sqlite3ExprCodeGetColumnOfTable(v, pTab, 0,
96770
- aiCols ? aiCols[j] : pFK->aCol[0].iFrom, regRow+j);
96849
+ aiCols ? aiCols[j] : pFK->aCol[j].iFrom, regRow+j);
9677196850
sqlite3VdbeAddOp2(v, OP_IsNull, regRow+j, addrOk);
9677296851
}
96773
- sqlite3VdbeAddOp3(v, OP_MakeRecord, regRow, pFK->nCol, regKey);
96774
- sqlite3VdbeChangeP4(v, -1,
96775
- sqlite3IndexAffinityStr(v,pIdx), P4_TRANSIENT);
96776
- sqlite3VdbeAddOp4Int(v, OP_Found, i, addrOk, regKey, 0);
96852
+ if( pParent ){
96853
+ sqlite3VdbeAddOp3(v, OP_MakeRecord, regRow, pFK->nCol, regKey);
96854
+ sqlite3VdbeChangeP4(v, -1,
96855
+ sqlite3IndexAffinityStr(v,pIdx), P4_TRANSIENT);
96856
+ sqlite3VdbeAddOp4Int(v, OP_Found, i, addrOk, regKey, 0);
96857
+ }
9677796858
}
9677896859
sqlite3VdbeAddOp2(v, OP_Rowid, 0, regResult+1);
9677996860
sqlite3VdbeAddOp4(v, OP_String8, 0, regResult+2, 0,
9678096861
pFK->zTo, P4_TRANSIENT);
9678196862
sqlite3VdbeAddOp2(v, OP_Integer, i-1, regResult+3);
@@ -108909,10 +108990,13 @@
108909108990
int iMin = 0; /* Smallest sample not yet tested */
108910108991
int i = pIdx->nSample; /* Smallest sample larger than or equal to pRec */
108911108992
int iTest; /* Next sample to test */
108912108993
int res; /* Result of comparison operation */
108913108994
108995
+#ifndef SQLITE_DEBUG
108996
+ UNUSED_PARAMETER( pParse );
108997
+#endif
108914108998
assert( pRec!=0 || pParse->db->mallocFailed );
108915108999
if( pRec==0 ) return;
108916109000
iCol = pRec->nField - 1;
108917109001
assert( pIdx->nSample>0 );
108918109002
assert( pRec->nField>0 && iCol<pIdx->nSampleCol );
@@ -109026,15 +109110,15 @@
109026109110
WhereTerm *pUpper, /* Upper bound on the range. ex: "x<455" Might be NULL */
109027109111
WhereLoop *pLoop /* Modify the .nOut and maybe .rRun fields */
109028109112
){
109029109113
int rc = SQLITE_OK;
109030109114
int nOut = pLoop->nOut;
109031
- int nEq = pLoop->u.btree.nEq;
109032109115
LogEst nNew;
109033109116
109034109117
#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
109035109118
Index *p = pLoop->u.btree.pIndex;
109119
+ int nEq = pLoop->u.btree.nEq;
109036109120
109037109121
if( p->nSample>0
109038109122
&& nEq==pBuilder->nRecValid
109039109123
&& nEq<p->nSampleCol
109040109124
&& OptimizationEnabled(pParse->db, SQLITE_Stat3)
@@ -110754,11 +110838,11 @@
110754110838
**
110755110839
** In the current implementation, the first extra WHERE clause term reduces
110756110840
** the number of output rows by a factor of 10 and each additional term
110757110841
** reduces the number of output rows by sqrt(2).
110758110842
*/
110759
-static void whereLoopOutputAdjust(WhereClause *pWC, WhereLoop *pLoop, int iCur){
110843
+static void whereLoopOutputAdjust(WhereClause *pWC, WhereLoop *pLoop){
110760110844
WhereTerm *pTerm, *pX;
110761110845
Bitmask notAllowed = ~(pLoop->prereq|pLoop->maskSelf);
110762110846
int i, j;
110763110847
110764110848
if( !OptimizationEnabled(pWC->pWInfo->pParse->db, SQLITE_AdjustOutEst) ){
@@ -110929,12 +111013,12 @@
110929111013
&& !ExprHasProperty(pExpr, EP_xIsSelect) ){
110930111014
rc = whereInScanEst(pParse, pBuilder, pExpr->x.pList, &nOut);
110931111015
}
110932111016
assert( nOut==0 || rc==SQLITE_OK );
110933111017
if( nOut ){
110934
- nOut = sqlite3LogEst(nOut);
110935
- pNew->nOut = MIN(nOut, saved_nOut);
111018
+ pNew->nOut = sqlite3LogEst(nOut);
111019
+ if( pNew->nOut>saved_nOut ) pNew->nOut = saved_nOut;
110936111020
}
110937111021
}
110938111022
#endif
110939111023
if( (pNew->wsFlags & (WHERE_IDX_ONLY|WHERE_IPK))==0 ){
110940111024
/* Each row involves a step of the index, then a binary search of
@@ -110941,11 +111025,11 @@
110941111025
** the main table */
110942111026
pNew->rRun = sqlite3LogEstAdd(pNew->rRun,rLogSize>27 ? rLogSize-17 : 10);
110943111027
}
110944111028
/* Step cost for each output row */
110945111029
pNew->rRun = sqlite3LogEstAdd(pNew->rRun, pNew->nOut);
110946
- whereLoopOutputAdjust(pBuilder->pWC, pNew, pSrc->iCursor);
111030
+ whereLoopOutputAdjust(pBuilder->pWC, pNew);
110947111031
rc = whereLoopInsert(pBuilder, pNew);
110948111032
if( (pNew->wsFlags & WHERE_TOP_LIMIT)==0
110949111033
&& pNew->u.btree.nEq<(pProbe->nColumn + (pProbe->zName!=0))
110950111034
){
110951111035
whereLoopAddBtreeIndex(pBuilder, pSrc, pProbe, nInMul+nIn);
@@ -111145,11 +111229,11 @@
111145111229
pNew->iSortIdx = b ? iSortIdx : 0;
111146111230
/* TUNING: Cost of full table scan is 3*(N + log2(N)).
111147111231
** + The extra 3 factor is to encourage the use of indexed lookups
111148111232
** over full scans. FIXME */
111149111233
pNew->rRun = sqlite3LogEstAdd(rSize,rLogSize) + 16;
111150
- whereLoopOutputAdjust(pWC, pNew, pSrc->iCursor);
111234
+ whereLoopOutputAdjust(pWC, pNew);
111151111235
rc = whereLoopInsert(pBuilder, pNew);
111152111236
pNew->nOut = rSize;
111153111237
if( rc ) break;
111154111238
}else{
111155111239
Bitmask m = pSrc->colUsed & ~columnsInIndex(pProbe);
@@ -111178,11 +111262,11 @@
111178111262
assert( b!=0 );
111179111263
/* TUNING: Cost of scanning a non-covering index is (N+1)*log2(N)
111180111264
** which we will simplify to just N*log2(N) */
111181111265
pNew->rRun = rSize + rLogSize;
111182111266
}
111183
- whereLoopOutputAdjust(pWC, pNew, pSrc->iCursor);
111267
+ whereLoopOutputAdjust(pWC, pNew);
111184111268
rc = whereLoopInsert(pBuilder, pNew);
111185111269
pNew->nOut = rSize;
111186111270
if( rc ) break;
111187111271
}
111188111272
}
@@ -126258,15 +126342,15 @@
126258126342
assert( p->nToken<=MAX_INCR_PHRASE_TOKENS );
126259126343
assert( p->iDoclistToken<MAX_INCR_PHRASE_TOKENS );
126260126344
126261126345
while( bEof==0 ){
126262126346
int bMaxSet = 0;
126263
- sqlite3_int64 iMax; /* Largest docid for all iterators */
126347
+ sqlite3_int64 iMax = 0; /* Largest docid for all iterators */
126264126348
int i; /* Used to iterate through tokens */
126265126349
126266126350
/* Advance the iterator for each token in the phrase once. */
126267
- for(i=0; rc==SQLITE_OK && i<p->nToken; i++){
126351
+ for(i=0; rc==SQLITE_OK && i<p->nToken && bEof==0; i++){
126268126352
rc = incrPhraseTokenNext(pTab, p, i, &a[i], &bEof);
126269126353
if( a[i].bIgnore==0 && (bMaxSet==0 || DOCID_CMP(iMax, a[i].iDocid)<0) ){
126270126354
iMax = a[i].iDocid;
126271126355
bMaxSet = 1;
126272126356
}
@@ -126301,11 +126385,11 @@
126301126385
char *pR = aDoclist;
126302126386
char *pOut = aDoclist;
126303126387
int nDist = p->nToken-1-i;
126304126388
int res = fts3PoslistPhraseMerge(&pOut, nDist, 0, 1, &pL, &pR);
126305126389
if( res==0 ) break;
126306
- nList = (pOut - aDoclist);
126390
+ nList = (int)(pOut - aDoclist);
126307126391
}
126308126392
}
126309126393
if( i==(p->nToken-1) ){
126310126394
pDL->iDocid = iMax;
126311126395
pDL->pList = aDoclist;
@@ -127675,10 +127759,11 @@
127675127759
sqlite3_vtab_cursor base; /* Base class used by SQLite core */
127676127760
Fts3MultiSegReader csr; /* Must be right after "base" */
127677127761
Fts3SegFilter filter;
127678127762
char *zStop;
127679127763
int nStop; /* Byte-length of string zStop */
127764
+ int iLangid; /* Language id to query */
127680127765
int isEof; /* True if cursor is at EOF */
127681127766
sqlite3_int64 iRowid; /* Current rowid */
127682127767
127683127768
int iCol; /* Current value of 'col' column */
127684127769
int nStat; /* Size of aStat[] array */
@@ -127689,11 +127774,12 @@
127689127774
};
127690127775
127691127776
/*
127692127777
** Schema of the terms table.
127693127778
*/
127694
-#define FTS3_TERMS_SCHEMA "CREATE TABLE x(term, col, documents, occurrences)"
127779
+#define FTS3_AUX_SCHEMA \
127780
+ "CREATE TABLE x(term, col, documents, occurrences, languageid HIDDEN)"
127695127781
127696127782
/*
127697127783
** This function does all the work for both the xConnect and xCreate methods.
127698127784
** These tables have no persistent representation of their own, so xConnect
127699127785
** and xCreate are identical operations.
@@ -127736,11 +127822,11 @@
127736127822
}else{
127737127823
zFts3 = argv[3];
127738127824
}
127739127825
nFts3 = (int)strlen(zFts3);
127740127826
127741
- rc = sqlite3_declare_vtab(db, FTS3_TERMS_SCHEMA);
127827
+ rc = sqlite3_declare_vtab(db, FTS3_AUX_SCHEMA);
127742127828
if( rc!=SQLITE_OK ) return rc;
127743127829
127744127830
nByte = sizeof(Fts3auxTable) + sizeof(Fts3Table) + nDb + nFts3 + 2;
127745127831
p = (Fts3auxTable *)sqlite3_malloc(nByte);
127746127832
if( !p ) return SQLITE_NOMEM;
@@ -127796,10 +127882,12 @@
127796127882
){
127797127883
int i;
127798127884
int iEq = -1;
127799127885
int iGe = -1;
127800127886
int iLe = -1;
127887
+ int iLangid = -1;
127888
+ int iNext = 1; /* Next free argvIndex value */
127801127889
127802127890
UNUSED_PARAMETER(pVTab);
127803127891
127804127892
/* This vtab delivers always results in "ORDER BY term ASC" order. */
127805127893
if( pInfo->nOrderBy==1
@@ -127807,40 +127895,52 @@
127807127895
&& pInfo->aOrderBy[0].desc==0
127808127896
){
127809127897
pInfo->orderByConsumed = 1;
127810127898
}
127811127899
127812
- /* Search for equality and range constraints on the "term" column. */
127900
+ /* Search for equality and range constraints on the "term" column.
127901
+ ** And equality constraints on the hidden "languageid" column. */
127813127902
for(i=0; i<pInfo->nConstraint; i++){
127814
- if( pInfo->aConstraint[i].usable && pInfo->aConstraint[i].iColumn==0 ){
127903
+ if( pInfo->aConstraint[i].usable ){
127815127904
int op = pInfo->aConstraint[i].op;
127816
- if( op==SQLITE_INDEX_CONSTRAINT_EQ ) iEq = i;
127817
- if( op==SQLITE_INDEX_CONSTRAINT_LT ) iLe = i;
127818
- if( op==SQLITE_INDEX_CONSTRAINT_LE ) iLe = i;
127819
- if( op==SQLITE_INDEX_CONSTRAINT_GT ) iGe = i;
127820
- if( op==SQLITE_INDEX_CONSTRAINT_GE ) iGe = i;
127905
+ int iCol = pInfo->aConstraint[i].iColumn;
127906
+
127907
+ if( iCol==0 ){
127908
+ if( op==SQLITE_INDEX_CONSTRAINT_EQ ) iEq = i;
127909
+ if( op==SQLITE_INDEX_CONSTRAINT_LT ) iLe = i;
127910
+ if( op==SQLITE_INDEX_CONSTRAINT_LE ) iLe = i;
127911
+ if( op==SQLITE_INDEX_CONSTRAINT_GT ) iGe = i;
127912
+ if( op==SQLITE_INDEX_CONSTRAINT_GE ) iGe = i;
127913
+ }
127914
+ if( iCol==4 ){
127915
+ if( op==SQLITE_INDEX_CONSTRAINT_EQ ) iLangid = i;
127916
+ }
127821127917
}
127822127918
}
127823127919
127824127920
if( iEq>=0 ){
127825127921
pInfo->idxNum = FTS4AUX_EQ_CONSTRAINT;
127826
- pInfo->aConstraintUsage[iEq].argvIndex = 1;
127922
+ pInfo->aConstraintUsage[iEq].argvIndex = iNext++;
127827127923
pInfo->estimatedCost = 5;
127828127924
}else{
127829127925
pInfo->idxNum = 0;
127830127926
pInfo->estimatedCost = 20000;
127831127927
if( iGe>=0 ){
127832127928
pInfo->idxNum += FTS4AUX_GE_CONSTRAINT;
127833
- pInfo->aConstraintUsage[iGe].argvIndex = 1;
127929
+ pInfo->aConstraintUsage[iGe].argvIndex = iNext++;
127834127930
pInfo->estimatedCost /= 2;
127835127931
}
127836127932
if( iLe>=0 ){
127837127933
pInfo->idxNum += FTS4AUX_LE_CONSTRAINT;
127838
- pInfo->aConstraintUsage[iLe].argvIndex = 1 + (iGe>=0);
127934
+ pInfo->aConstraintUsage[iLe].argvIndex = iNext++;
127839127935
pInfo->estimatedCost /= 2;
127840127936
}
127841127937
}
127938
+ if( iLangid>=0 ){
127939
+ pInfo->aConstraintUsage[iLangid].argvIndex = iNext++;
127940
+ pInfo->estimatedCost--;
127941
+ }
127842127942
127843127943
return SQLITE_OK;
127844127944
}
127845127945
127846127946
/*
@@ -127996,21 +128096,42 @@
127996128096
sqlite3_value **apVal /* Arguments for the indexing scheme */
127997128097
){
127998128098
Fts3auxCursor *pCsr = (Fts3auxCursor *)pCursor;
127999128099
Fts3Table *pFts3 = ((Fts3auxTable *)pCursor->pVtab)->pFts3Tab;
128000128100
int rc;
128001
- int isScan;
128101
+ int isScan = 0;
128102
+ int iLangVal = 0; /* Language id to query */
128103
+
128104
+ int iEq = -1; /* Index of term=? value in apVal */
128105
+ int iGe = -1; /* Index of term>=? value in apVal */
128106
+ int iLe = -1; /* Index of term<=? value in apVal */
128107
+ int iLangid = -1; /* Index of languageid=? value in apVal */
128108
+ int iNext = 0;
128002128109
128003128110
UNUSED_PARAMETER(nVal);
128004128111
UNUSED_PARAMETER(idxStr);
128005128112
128006128113
assert( idxStr==0 );
128007128114
assert( idxNum==FTS4AUX_EQ_CONSTRAINT || idxNum==0
128008128115
|| idxNum==FTS4AUX_LE_CONSTRAINT || idxNum==FTS4AUX_GE_CONSTRAINT
128009128116
|| idxNum==(FTS4AUX_LE_CONSTRAINT|FTS4AUX_GE_CONSTRAINT)
128010128117
);
128011
- isScan = (idxNum!=FTS4AUX_EQ_CONSTRAINT);
128118
+
128119
+ if( idxNum==FTS4AUX_EQ_CONSTRAINT ){
128120
+ iEq = iNext++;
128121
+ }else{
128122
+ isScan = 1;
128123
+ if( idxNum & FTS4AUX_GE_CONSTRAINT ){
128124
+ iGe = iNext++;
128125
+ }
128126
+ if( idxNum & FTS4AUX_LE_CONSTRAINT ){
128127
+ iLe = iNext++;
128128
+ }
128129
+ }
128130
+ if( iNext<nVal ){
128131
+ iLangid = iNext++;
128132
+ }
128012128133
128013128134
/* In case this cursor is being reused, close and zero it. */
128014128135
testcase(pCsr->filter.zTerm);
128015128136
sqlite3Fts3SegReaderFinish(&pCsr->csr);
128016128137
sqlite3_free((void *)pCsr->filter.zTerm);
@@ -128018,26 +128139,39 @@
128018128139
memset(&pCsr->csr, 0, ((u8*)&pCsr[1]) - (u8*)&pCsr->csr);
128019128140
128020128141
pCsr->filter.flags = FTS3_SEGMENT_REQUIRE_POS|FTS3_SEGMENT_IGNORE_EMPTY;
128021128142
if( isScan ) pCsr->filter.flags |= FTS3_SEGMENT_SCAN;
128022128143
128023
- if( idxNum&(FTS4AUX_EQ_CONSTRAINT|FTS4AUX_GE_CONSTRAINT) ){
128144
+ if( iEq>=0 || iGe>=0 ){
128024128145
const unsigned char *zStr = sqlite3_value_text(apVal[0]);
128146
+ assert( (iEq==0 && iGe==-1) || (iEq==-1 && iGe==0) );
128025128147
if( zStr ){
128026128148
pCsr->filter.zTerm = sqlite3_mprintf("%s", zStr);
128027128149
pCsr->filter.nTerm = sqlite3_value_bytes(apVal[0]);
128028128150
if( pCsr->filter.zTerm==0 ) return SQLITE_NOMEM;
128029128151
}
128030128152
}
128031
- if( idxNum&FTS4AUX_LE_CONSTRAINT ){
128032
- int iIdx = (idxNum&FTS4AUX_GE_CONSTRAINT) ? 1 : 0;
128033
- pCsr->zStop = sqlite3_mprintf("%s", sqlite3_value_text(apVal[iIdx]));
128034
- pCsr->nStop = sqlite3_value_bytes(apVal[iIdx]);
128153
+
128154
+ if( iLe>=0 ){
128155
+ pCsr->zStop = sqlite3_mprintf("%s", sqlite3_value_text(apVal[iLe]));
128156
+ pCsr->nStop = sqlite3_value_bytes(apVal[iLe]);
128035128157
if( pCsr->zStop==0 ) return SQLITE_NOMEM;
128036128158
}
128159
+
128160
+ if( iLangid>=0 ){
128161
+ iLangVal = sqlite3_value_int(apVal[iLangid]);
128037128162
128038
- rc = sqlite3Fts3SegReaderCursor(pFts3, 0, 0, FTS3_SEGCURSOR_ALL,
128163
+ /* If the user specified a negative value for the languageid, use zero
128164
+ ** instead. This works, as the "languageid=?" constraint will also
128165
+ ** be tested by the VDBE layer. The test will always be false (since
128166
+ ** this module will not return a row with a negative languageid), and
128167
+ ** so the overall query will return zero rows. */
128168
+ if( iLangVal<0 ) iLangVal = 0;
128169
+ }
128170
+ pCsr->iLangid = iLangVal;
128171
+
128172
+ rc = sqlite3Fts3SegReaderCursor(pFts3, iLangVal, 0, FTS3_SEGCURSOR_ALL,
128039128173
pCsr->filter.zTerm, pCsr->filter.nTerm, 0, isScan, &pCsr->csr
128040128174
);
128041128175
if( rc==SQLITE_OK ){
128042128176
rc = sqlite3Fts3SegReaderStart(pFts3, &pCsr->csr, &pCsr->filter);
128043128177
}
@@ -128057,28 +128191,41 @@
128057128191
/*
128058128192
** xColumn - Return a column value.
128059128193
*/
128060128194
static int fts3auxColumnMethod(
128061128195
sqlite3_vtab_cursor *pCursor, /* Cursor to retrieve value from */
128062
- sqlite3_context *pContext, /* Context for sqlite3_result_xxx() calls */
128196
+ sqlite3_context *pCtx, /* Context for sqlite3_result_xxx() calls */
128063128197
int iCol /* Index of column to read value from */
128064128198
){
128065128199
Fts3auxCursor *p = (Fts3auxCursor *)pCursor;
128066128200
128067128201
assert( p->isEof==0 );
128068
- if( iCol==0 ){ /* Column "term" */
128069
- sqlite3_result_text(pContext, p->csr.zTerm, p->csr.nTerm, SQLITE_TRANSIENT);
128070
- }else if( iCol==1 ){ /* Column "col" */
128071
- if( p->iCol ){
128072
- sqlite3_result_int(pContext, p->iCol-1);
128073
- }else{
128074
- sqlite3_result_text(pContext, "*", -1, SQLITE_STATIC);
128075
- }
128076
- }else if( iCol==2 ){ /* Column "documents" */
128077
- sqlite3_result_int64(pContext, p->aStat[p->iCol].nDoc);
128078
- }else{ /* Column "occurrences" */
128079
- sqlite3_result_int64(pContext, p->aStat[p->iCol].nOcc);
128202
+ switch( iCol ){
128203
+ case 0: /* term */
128204
+ sqlite3_result_text(pCtx, p->csr.zTerm, p->csr.nTerm, SQLITE_TRANSIENT);
128205
+ break;
128206
+
128207
+ case 1: /* col */
128208
+ if( p->iCol ){
128209
+ sqlite3_result_int(pCtx, p->iCol-1);
128210
+ }else{
128211
+ sqlite3_result_text(pCtx, "*", -1, SQLITE_STATIC);
128212
+ }
128213
+ break;
128214
+
128215
+ case 2: /* documents */
128216
+ sqlite3_result_int64(pCtx, p->aStat[p->iCol].nDoc);
128217
+ break;
128218
+
128219
+ case 3: /* occurrences */
128220
+ sqlite3_result_int64(pCtx, p->aStat[p->iCol].nOcc);
128221
+ break;
128222
+
128223
+ default: /* languageid */
128224
+ assert( iCol==4 );
128225
+ sqlite3_result_int(pCtx, p->iLangid);
128226
+ break;
128080128227
}
128081128228
128082128229
return SQLITE_OK;
128083128230
}
128084128231
128085128232
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -135,11 +135,11 @@
135 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
136 ** [sqlite_version()] and [sqlite_source_id()].
137 */
138 #define SQLITE_VERSION "3.8.1"
139 #define SQLITE_VERSION_NUMBER 3008001
140 #define SQLITE_SOURCE_ID "2013-10-11 13:27:26 03593817ab5abdd4bbaa5e47e2e4745eef025af9"
141
142 /*
143 ** CAPI3REF: Run-Time Library Version Numbers
144 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
145 **
@@ -1643,31 +1643,31 @@
1643 ** supplied by the application must not invoke any SQLite interface.
1644 ** In a multi-threaded application, the application-defined logger
1645 ** function must be threadsafe. </dd>
1646 **
1647 ** [[SQLITE_CONFIG_URI]] <dt>SQLITE_CONFIG_URI
1648 ** <dd> This option takes a single argument of type int. If non-zero, then
1649 ** URI handling is globally enabled. If the parameter is zero, then URI handling
1650 ** is globally disabled. If URI handling is globally enabled, all filenames
1651 ** passed to [sqlite3_open()], [sqlite3_open_v2()], [sqlite3_open16()] or
1652 ** specified as part of [ATTACH] commands are interpreted as URIs, regardless
1653 ** of whether or not the [SQLITE_OPEN_URI] flag is set when the database
1654 ** connection is opened. If it is globally disabled, filenames are
1655 ** only interpreted as URIs if the SQLITE_OPEN_URI flag is set when the
1656 ** database connection is opened. By default, URI handling is globally
1657 ** disabled. The default value may be changed by compiling with the
1658 ** [SQLITE_USE_URI] symbol defined.
1659 **
1660 ** [[SQLITE_CONFIG_COVERING_INDEX_SCAN]] <dt>SQLITE_CONFIG_COVERING_INDEX_SCAN
1661 ** <dd> This option takes a single integer argument which is interpreted as
1662 ** a boolean in order to enable or disable the use of covering indices for
1663 ** full table scans in the query optimizer. The default setting is determined
1664 ** by the [SQLITE_ALLOW_COVERING_INDEX_SCAN] compile-time option, or is "on"
1665 ** if that compile-time option is omitted.
1666 ** The ability to disable the use of covering indices for full table scans
1667 ** is because some incorrectly coded legacy applications might malfunction
1668 ** malfunction when the optimization is enabled. Providing the ability to
1669 ** disable the optimization allows the older, buggy application code to work
1670 ** without change even with newer versions of SQLite.
1671 **
1672 ** [[SQLITE_CONFIG_PCACHE]] [[SQLITE_CONFIG_GETPCACHE]]
1673 ** <dt>SQLITE_CONFIG_PCACHE and SQLITE_CONFIG_GETPCACHE
@@ -1692,20 +1692,20 @@
1692 ** configuration option can be seen in the "test_sqllog.c" source file in
1693 ** the canonical SQLite source tree.</dd>
1694 **
1695 ** [[SQLITE_CONFIG_MMAP_SIZE]]
1696 ** <dt>SQLITE_CONFIG_MMAP_SIZE
1697 ** <dd>SQLITE_CONFIG_MMAP_SIZE takes two 64-bit integer (sqlite3_int64) values
1698 ** that are the default mmap size limit (the default setting for
1699 ** [PRAGMA mmap_size]) and the maximum allowed mmap size limit.
1700 ** The default setting can be overridden by each database connection using
1701 ** either the [PRAGMA mmap_size] command, or by using the
1702 ** [SQLITE_FCNTL_MMAP_SIZE] file control. The maximum allowed mmap size
1703 ** cannot be changed at run-time. Nor may the maximum allowed mmap size
1704 ** exceed the compile-time maximum mmap size set by the
1705 ** [SQLITE_MAX_MMAP_SIZE] compile-time option.
1706 ** If either argument to this option is negative, then that argument is
1707 ** changed to its compile-time default.
1708 ** </dl>
1709 */
1710 #define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */
1711 #define SQLITE_CONFIG_MULTITHREAD 2 /* nil */
@@ -12468,14 +12468,14 @@
12468 SQLITE_PRIVATE int sqlite3FkRequired(Parse*, Table*, int*, int);
12469 SQLITE_PRIVATE u32 sqlite3FkOldmask(Parse*, Table*);
12470 SQLITE_PRIVATE FKey *sqlite3FkReferences(Table *);
12471 #else
12472 #define sqlite3FkActions(a,b,c,d,e,f)
12473 #define sqlite3FkCheck(a,b,c,d)
12474 #define sqlite3FkDropTable(a,b,c)
12475 #define sqlite3FkOldmask(a,b) 0
12476 #define sqlite3FkRequired(a,b,c,d,e,f) 0
12477 #endif
12478 #ifndef SQLITE_OMIT_FOREIGN_KEY
12479 SQLITE_PRIVATE void sqlite3FkDelete(sqlite3 *, Table*);
12480 SQLITE_PRIVATE int sqlite3FkLocateIndex(Parse*,Table*,FKey*,Index**,int**);
12481 #else
@@ -14430,10 +14430,14 @@
14430 ** is available. This routine returns 0 on success and
14431 ** non-zero on any kind of error.
14432 **
14433 ** If the sqlite3GlobalConfig.bLocaltimeFault variable is true then this
14434 ** routine will always fail.
 
 
 
 
14435 */
14436 static int osLocaltime(time_t *t, struct tm *pTm){
14437 int rc;
14438 #if (!defined(HAVE_LOCALTIME_R) || !HAVE_LOCALTIME_R) \
14439 && (!defined(HAVE_LOCALTIME_S) || !HAVE_LOCALTIME_S)
@@ -14486,10 +14490,15 @@
14486 memset(&sLocal, 0, sizeof(sLocal));
14487
14488 x = *p;
14489 computeYMD_HMS(&x);
14490 if( x.Y<1971 || x.Y>=2038 ){
 
 
 
 
 
14491 x.Y = 2000;
14492 x.M = 1;
14493 x.D = 1;
14494 x.h = 0;
14495 x.m = 0;
@@ -33006,12 +33015,11 @@
33006 #endif
33007 assert( pFile->h!=NULL && pFile->h!=INVALID_HANDLE_VALUE );
33008 OSTRACE(("CLOSE file=%p\n", pFile->h));
33009
33010 #if SQLITE_MAX_MMAP_SIZE>0
33011 rc = winUnmapfile(pFile);
33012 if( rc!=SQLITE_OK ) return rc;
33013 #endif
33014
33015 do{
33016 rc = osCloseHandle(pFile->h);
33017 /* SimulateIOError( rc=0; cnt=MX_CLOSE_ATTEMPT; ); */
@@ -33813,11 +33821,11 @@
33813 }
33814 *(i64*)pArg = pFile->mmapSizeMax;
33815 if( newLimit>=0 && newLimit!=pFile->mmapSizeMax && pFile->nFetchOut==0 ){
33816 pFile->mmapSizeMax = newLimit;
33817 if( pFile->mmapSize>0 ){
33818 (void)winUnmapfile(pFile);
33819 rc = winMapfile(pFile, -1);
33820 }
33821 }
33822 OSTRACE(("FCNTL file=%p, rc=%s\n", pFile->h, sqlite3ErrName(rc)));
33823 return rc;
@@ -34030,11 +34038,11 @@
34030 osGetCurrentProcessId(), deleteFlag));
34031 pp = &winShmNodeList;
34032 while( (p = *pp)!=0 ){
34033 if( p->nRef==0 ){
34034 int i;
34035 if( p->mutex ) sqlite3_mutex_free(p->mutex);
34036 for(i=0; i<p->nRegion; i++){
34037 BOOL bRc = osUnmapViewOfFile(p->aRegion[i].pMap);
34038 OSTRACE(("SHM-PURGE-UNMAP pid=%lu, region=%d, rc=%s\n",
34039 osGetCurrentProcessId(), i, bRc ? "ok" : "failed"));
34040 UNUSED_VARIABLE_VALUE(bRc);
@@ -34883,10 +34891,11 @@
34883 ** API prior to using it.
34884 */
34885 if( winIsDriveLetterAndColon(zDir) ){
34886 zConverted = winConvertFromUtf8Filename(zDir);
34887 if( !zConverted ){
 
34888 OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
34889 return SQLITE_IOERR_NOMEM;
34890 }
34891 if( winIsDir(zConverted) ){
34892 sqlite3_snprintf(nBuf-30, zBuf, "%s", zDir);
@@ -34895,17 +34904,19 @@
34895 }
34896 sqlite3_free(zConverted);
34897 }else{
34898 zConverted = sqlite3MallocZero( nBuf+1 );
34899 if( !zConverted ){
 
34900 OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
34901 return SQLITE_IOERR_NOMEM;
34902 }
34903 if( cygwin_conv_path(
34904 osIsNT() ? CCP_POSIX_TO_WIN_W : CCP_POSIX_TO_WIN_A, zDir,
34905 zConverted, nBuf+1)<0 ){
34906 sqlite3_free(zConverted);
 
34907 OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_CONVPATH\n"));
34908 return winLogError(SQLITE_IOERR_CONVPATH, (DWORD)errno,
34909 "winGetTempname1", zDir);
34910 }
34911 if( winIsDir(zConverted) ){
@@ -34915,10 +34926,11 @@
34915 */
34916 if( osIsNT() ){
34917 char *zUtf8 = winUnicodeToUtf8(zConverted);
34918 if( !zUtf8 ){
34919 sqlite3_free(zConverted);
 
34920 OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
34921 return SQLITE_IOERR_NOMEM;
34922 }
34923 sqlite3_snprintf(nBuf-30, zBuf, "%s", zUtf8);
34924 sqlite3_free(zUtf8);
@@ -34930,11 +34942,10 @@
34930 break;
34931 }
34932 }
34933 sqlite3_free(zConverted);
34934 }
34935 break;
34936 }
34937 }
34938 #elif !SQLITE_OS_WINRT && !defined(__CYGWIN__)
34939 else if( osIsNT() ){
34940 char *zMulti;
@@ -35300,13 +35311,13 @@
35300 pFile->zDeleteOnClose = zConverted;
35301 }else
35302 #endif
35303 {
35304 sqlite3_free(zConverted);
35305 sqlite3_free(zTmpname);
35306 }
35307
 
35308 pFile->pMethod = &winIoMethod;
35309 pFile->pVfs = pVfs;
35310 pFile->h = h;
35311 if( isReadonly ){
35312 pFile->ctrlFlags |= WINFILE_RDONLY;
@@ -52033,10 +52044,22 @@
52033 ** MX_CELL_SIZE(pBt) bytes.
52034 */
52035 static void allocateTempSpace(BtShared *pBt){
52036 if( !pBt->pTmpSpace ){
52037 pBt->pTmpSpace = sqlite3PageMalloc( pBt->pageSize );
 
 
 
 
 
 
 
 
 
 
 
 
52038 }
52039 }
52040
52041 /*
52042 ** Free the pBt->pTmpSpace allocation
@@ -60299,11 +60322,13 @@
60299 }
60300
60301 pRec->nField = p->iVal+1;
60302 return &pRec->aMem[p->iVal];
60303 }
60304 #endif
 
 
60305 return sqlite3ValueNew(db);
60306 }
60307
60308 /*
60309 ** Extract a value from the supplied expression in the manner described
@@ -60313,11 +60338,11 @@
60313 ** If pCtx is NULL and an error occurs after the sqlite3_value object
60314 ** has been allocated, it is freed before returning. Or, if pCtx is not
60315 ** NULL, it is assumed that the caller will free any allocated object
60316 ** in all cases.
60317 */
60318 int valueFromExpr(
60319 sqlite3 *db, /* The database connection */
60320 Expr *pExpr, /* The expression to evaluate */
60321 u8 enc, /* Encoding to use */
60322 u8 affinity, /* Affinity to use */
60323 sqlite3_value **ppVal, /* Write the new value here */
@@ -60470,10 +60495,11 @@
60470 int nVal; /* Bytes of space required for argv[0] */
60471 int nRet;
60472 sqlite3 *db;
60473 u8 *aRet;
60474
 
60475 iSerial = sqlite3VdbeSerialType(argv[0], file_format);
60476 nSerial = sqlite3VarintLen(iSerial);
60477 nVal = sqlite3VdbeSerialTypeLen(iSerial);
60478 db = sqlite3_context_db_handle(context);
60479
@@ -75410,10 +75436,14 @@
75410 sqlite3ErrorMsg(pParse, "second argument to likelihood() must be a "
75411 "constant between 0.0 and 1.0");
75412 pNC->nErr++;
75413 }
75414 }else{
 
 
 
 
75415 pExpr->iTable = 62; /* TUNING: Default 2nd arg to unlikely() is 0.0625 */
75416 }
75417 }
75418 }
75419 #ifndef SQLITE_OMIT_AUTHORIZATION
@@ -81284,11 +81314,11 @@
81284 ** The sqlite_stat2 table is superseded by sqlite_stat3, which is only
81285 ** created and used by SQLite versions 3.7.9 and later and with
81286 ** SQLITE_ENABLE_STAT3 defined. The functionality of sqlite_stat3
81287 ** is a superset of sqlite_stat2. The sqlite_stat4 is an enhanced
81288 ** version of sqlite_stat3 and is only available when compiled with
81289 ** SQLITE_ENABLE_STAT4 and in SQLite versions 3.8.0 and later. It is
81290 ** not possible to enable both STAT3 and STAT4 at the same time. If they
81291 ** are both enabled, then STAT4 takes precedence.
81292 **
81293 ** For most applications, sqlite_stat1 provides all the statisics required
81294 ** for the query planner to make good choices.
@@ -81360,16 +81390,16 @@
81360 **
81361 ** The sqlite_stat4 table contains multiple entries for each index.
81362 ** The idx column names the index and the tbl column is the table of the
81363 ** index. If the idx and tbl columns are the same, then the sample is
81364 ** of the INTEGER PRIMARY KEY. The sample column is a blob which is the
81365 ** binary encoding of a key from the index, with the trailing rowid
81366 ** omitted. The nEq column is a list of integers. The first integer
81367 ** is the approximate number of entries in the index whose left-most
81368 ** column exactly matches the left-most column of the sample. The second
81369 ** integer in nEq is the approximate number of entries in the index where
81370 ** the first two columns match the first two columns of the sample.
81371 ** And so forth. nLt is another list of integers that show the approximate
81372 ** number of entries that are strictly less than the sample. The first
81373 ** integer in nLt contains the number of entries in the index where the
81374 ** left-most column is less than the left-most column of the sample.
81375 ** The K-th integer in the nLt entry is the number of index entries
@@ -81696,11 +81726,11 @@
81696 }
81697
81698 /*
81699 ** Copy the contents of object (*pFrom) into (*pTo).
81700 */
81701 void sampleCopy(Stat4Accum *p, Stat4Sample *pTo, Stat4Sample *pFrom){
81702 pTo->iRowid = pFrom->iRowid;
81703 pTo->isPSample = pFrom->isPSample;
81704 pTo->iCol = pFrom->iCol;
81705 pTo->iHash = pFrom->iHash;
81706 memcpy(pTo->anEq, pFrom->anEq, sizeof(tRowcnt)*p->nCol);
@@ -81841,10 +81871,15 @@
81841 ){
81842 sampleInsert(p, &p->current, 0);
81843 }
81844 }
81845 #endif
 
 
 
 
 
81846 }
81847
81848 /*
81849 ** Implementation of the stat_push SQL function: stat_push(P,R,C)
81850 ** Arguments:
@@ -81866,10 +81901,12 @@
81866
81867 /* The three function arguments */
81868 Stat4Accum *p = (Stat4Accum*)sqlite3_value_blob(argv[0]);
81869 int iChng = sqlite3_value_int(argv[1]);
81870
 
 
81871 assert( p->nCol>1 ); /* Includes rowid field */
81872 assert( iChng<p->nCol );
81873
81874 if( p->nRow==0 ){
81875 /* This is the first call to this function. Do initialization. */
@@ -82051,10 +82088,13 @@
82051 sqlite3_result_text(context, zRet, -1, sqlite3_free);
82052 }
82053 }
82054 }
82055 #endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */
 
 
 
82056 }
82057 static const FuncDef statGetFuncdef = {
82058 1+IsStat34, /* nArg */
82059 SQLITE_UTF8, /* funcFlags */
82060 0, /* pUserData */
@@ -82069,12 +82109,14 @@
82069
82070 static void callStatGet(Vdbe *v, int regStat4, int iParam, int regOut){
82071 assert( regOut!=regStat4 && regOut!=regStat4+1 );
82072 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
82073 sqlite3VdbeAddOp2(v, OP_Integer, iParam, regStat4+1);
82074 #else
82075 assert( iParam==STAT_GET_STAT1 );
 
 
82076 #endif
82077 sqlite3VdbeAddOp3(v, OP_Function, 0, regStat4, regOut);
82078 sqlite3VdbeChangeP4(v, -1, (char*)&statGetFuncdef, P4_FUNCDEF);
82079 sqlite3VdbeChangeP5(v, 1 + IsStat34);
82080 }
@@ -84833,11 +84875,11 @@
84833 *pszEst = 1; /* default size is approx 4 bytes */
84834 if( aff<=SQLITE_AFF_NONE ){
84835 if( zChar ){
84836 while( zChar[0] ){
84837 if( sqlite3Isdigit(zChar[0]) ){
84838 int v;
84839 sqlite3GetInt32(zChar, &v);
84840 v = v/4 + 1;
84841 if( v>255 ) v = 255;
84842 *pszEst = v; /* BLOB(k), VARCHAR(k), CHAR(k) -> r=(k/4+1) */
84843 break;
@@ -91144,11 +91186,11 @@
91144 ** generating any VDBE code. If one can be found, then jump over
91145 ** the entire DELETE if there are no outstanding deferred constraints
91146 ** when this statement is run. */
91147 FKey *p;
91148 for(p=pTab->pFKey; p; p=p->pNextFrom){
91149 if( p->isDeferred ) break;
91150 }
91151 if( !p ) return;
91152 iSkip = sqlite3VdbeMakeLabel(v);
91153 sqlite3VdbeAddOp2(v, OP_FkIfZero, 1, iSkip);
91154 }
@@ -91158,15 +91200,22 @@
91158 pParse->disableTriggers = 0;
91159
91160 /* If the DELETE has generated immediate foreign key constraint
91161 ** violations, halt the VDBE and return an error at this point, before
91162 ** any modifications to the schema are made. This is because statement
91163 ** transactions are not able to rollback schema changes. */
91164 sqlite3VdbeAddOp2(v, OP_FkIfZero, 0, sqlite3VdbeCurrentAddr(v)+2);
91165 sqlite3HaltConstraint(pParse, SQLITE_CONSTRAINT_FOREIGNKEY,
91166 OE_Abort, "foreign key constraint failed", P4_STATIC
91167 );
 
 
 
 
 
 
 
91168
91169 if( iSkip ){
91170 sqlite3VdbeResolveLabel(v, iSkip);
91171 }
91172 }
@@ -95164,22 +95213,23 @@
95164 #define PragTyp_MMAP_SIZE 23
95165 #define PragTyp_PAGE_SIZE 24
95166 #define PragTyp_SECURE_DELETE 25
95167 #define PragTyp_SHRINK_MEMORY 26
95168 #define PragTyp_SOFT_HEAP_LIMIT 27
95169 #define PragTyp_SYNCHRONOUS 28
95170 #define PragTyp_TABLE_INFO 29
95171 #define PragTyp_TEMP_STORE 30
95172 #define PragTyp_TEMP_STORE_DIRECTORY 31
95173 #define PragTyp_WAL_AUTOCHECKPOINT 32
95174 #define PragTyp_WAL_CHECKPOINT 33
95175 #define PragTyp_ACTIVATE_EXTENSIONS 34
95176 #define PragTyp_HEXKEY 35
95177 #define PragTyp_KEY 36
95178 #define PragTyp_REKEY 37
95179 #define PragTyp_LOCK_STATUS 38
95180 #define PragTyp_PARSER_TRACE 39
 
95181 #define PragFlag_NeedSchema 0x01
95182 static const struct sPragmaNames {
95183 const char *const zName; /* Name of pragma */
95184 u8 ePragTyp; /* PragTyp_XXX value */
95185 u8 mPragFlag; /* Zero or more PragFlag_XXX values */
@@ -95466,10 +95516,16 @@
95466 #if defined(SQLITE_DEBUG)
95467 { /* zName: */ "sql_trace",
95468 /* ePragTyp: */ PragTyp_FLAG,
95469 /* ePragFlag: */ 0,
95470 /* iArg: */ SQLITE_SqlTrace },
 
 
 
 
 
 
95471 #endif
95472 #if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
95473 { /* zName: */ "synchronous",
95474 /* ePragTyp: */ PragTyp_SYNCHRONOUS,
95475 /* ePragFlag: */ PragFlag_NeedSchema,
@@ -95528,11 +95584,11 @@
95528 { /* zName: */ "writable_schema",
95529 /* ePragTyp: */ PragTyp_FLAG,
95530 /* ePragFlag: */ 0,
95531 /* iArg: */ SQLITE_WriteSchema|SQLITE_RecoveryMode },
95532 };
95533 /* Number of pragmas: 55 on by default, 67 total. */
95534 /* End of the automatically generated pragma table.
95535 ***************************************************************************/
95536
95537 /*
95538 ** Interpret the given string as a safety level. Return 0 for OFF,
@@ -96532,10 +96588,40 @@
96532 sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 6);
96533 }
96534 }
96535 }
96536 break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96537
96538 case PragTyp_INDEX_INFO: if( zRight ){
96539 Index *pIdx;
96540 Table *pTab;
96541 pIdx = sqlite3FindIndex(db, zRight, zDb);
@@ -96565,30 +96651,21 @@
96565 Table *pTab;
96566 int i;
96567 pTab = sqlite3FindTable(db, zRight, zDb);
96568 if( pTab ){
96569 v = sqlite3GetVdbe(pParse);
96570 sqlite3VdbeSetNumCols(v, 4);
96571 pParse->nMem = 4;
96572 sqlite3CodeVerifySchema(pParse, iDb);
96573 sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "seq", SQLITE_STATIC);
96574 sqlite3VdbeSetColName(v, 1, COLNAME_NAME, "name", SQLITE_STATIC);
96575 sqlite3VdbeSetColName(v, 2, COLNAME_NAME, "unique", SQLITE_STATIC);
96576 sqlite3VdbeSetColName(v, 3, COLNAME_NAME, "avgrowsize", SQLITE_STATIC);
96577 sqlite3VdbeAddOp2(v, OP_Integer, 0, 1);
96578 sqlite3VdbeAddOp2(v, OP_Null, 0, 2);
96579 sqlite3VdbeAddOp2(v, OP_Integer, 1, 3);
96580 sqlite3VdbeAddOp2(v, OP_Integer,
96581 (int)sqlite3LogEstToInt(pTab->szTabRow), 4);
96582 sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 4);
96583 for(pIdx=pTab->pIndex, i=1; pIdx; pIdx=pIdx->pNext, i++){
96584 sqlite3VdbeAddOp2(v, OP_Integer, i, 1);
96585 sqlite3VdbeAddOp4(v, OP_String8, 0, 2, 0, pIdx->zName, 0);
96586 sqlite3VdbeAddOp2(v, OP_Integer, pIdx->onError!=OE_None, 3);
96587 sqlite3VdbeAddOp2(v, OP_Integer,
96588 (int)sqlite3LogEstToInt(pIdx->szIdxRow), 4);
96589 sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 4);
96590 }
96591 }
96592 }
96593 break;
96594
@@ -96718,12 +96795,12 @@
96718 if( pTab->nCol+regRow>pParse->nMem ) pParse->nMem = pTab->nCol + regRow;
96719 sqlite3OpenTable(pParse, 0, iDb, pTab, OP_OpenRead);
96720 sqlite3VdbeAddOp4(v, OP_String8, 0, regResult, 0, pTab->zName,
96721 P4_TRANSIENT);
96722 for(i=1, pFK=pTab->pFKey; pFK; i++, pFK=pFK->pNextFrom){
96723 pParent = sqlite3LocateTable(pParse, 0, pFK->zTo, zDb);
96724 if( pParent==0 ) break;
96725 pIdx = 0;
96726 sqlite3TableLock(pParse, iDb, pParent->tnum, 0, pParent->zName);
96727 x = sqlite3FkLocateIndex(pParse, pParent, pFK, &pIdx, 0);
96728 if( x==0 ){
96729 if( pIdx==0 ){
@@ -96736,22 +96813,24 @@
96736 }else{
96737 k = 0;
96738 break;
96739 }
96740 }
 
96741 if( pFK ) break;
96742 if( pParse->nTab<i ) pParse->nTab = i;
96743 addrTop = sqlite3VdbeAddOp1(v, OP_Rewind, 0);
96744 for(i=1, pFK=pTab->pFKey; pFK; i++, pFK=pFK->pNextFrom){
96745 pParent = sqlite3LocateTable(pParse, 0, pFK->zTo, zDb);
96746 assert( pParent!=0 );
96747 pIdx = 0;
96748 aiCols = 0;
96749 x = sqlite3FkLocateIndex(pParse, pParent, pFK, &pIdx, &aiCols);
96750 assert( x==0 );
 
 
96751 addrOk = sqlite3VdbeMakeLabel(v);
96752 if( pIdx==0 ){
96753 int iKey = pFK->aCol[0].iFrom;
96754 assert( iKey>=0 && iKey<pTab->nCol );
96755 if( iKey!=pTab->iPKey ){
96756 sqlite3VdbeAddOp3(v, OP_Column, 0, iKey, regRow);
96757 sqlite3ColumnDefault(v, pTab, iKey, regRow);
@@ -96765,17 +96844,19 @@
96765 sqlite3VdbeAddOp2(v, OP_Goto, 0, addrOk);
96766 sqlite3VdbeJumpHere(v, sqlite3VdbeCurrentAddr(v)-2);
96767 }else{
96768 for(j=0; j<pFK->nCol; j++){
96769 sqlite3ExprCodeGetColumnOfTable(v, pTab, 0,
96770 aiCols ? aiCols[j] : pFK->aCol[0].iFrom, regRow+j);
96771 sqlite3VdbeAddOp2(v, OP_IsNull, regRow+j, addrOk);
96772 }
96773 sqlite3VdbeAddOp3(v, OP_MakeRecord, regRow, pFK->nCol, regKey);
96774 sqlite3VdbeChangeP4(v, -1,
96775 sqlite3IndexAffinityStr(v,pIdx), P4_TRANSIENT);
96776 sqlite3VdbeAddOp4Int(v, OP_Found, i, addrOk, regKey, 0);
 
 
96777 }
96778 sqlite3VdbeAddOp2(v, OP_Rowid, 0, regResult+1);
96779 sqlite3VdbeAddOp4(v, OP_String8, 0, regResult+2, 0,
96780 pFK->zTo, P4_TRANSIENT);
96781 sqlite3VdbeAddOp2(v, OP_Integer, i-1, regResult+3);
@@ -108909,10 +108990,13 @@
108909 int iMin = 0; /* Smallest sample not yet tested */
108910 int i = pIdx->nSample; /* Smallest sample larger than or equal to pRec */
108911 int iTest; /* Next sample to test */
108912 int res; /* Result of comparison operation */
108913
 
 
 
108914 assert( pRec!=0 || pParse->db->mallocFailed );
108915 if( pRec==0 ) return;
108916 iCol = pRec->nField - 1;
108917 assert( pIdx->nSample>0 );
108918 assert( pRec->nField>0 && iCol<pIdx->nSampleCol );
@@ -109026,15 +109110,15 @@
109026 WhereTerm *pUpper, /* Upper bound on the range. ex: "x<455" Might be NULL */
109027 WhereLoop *pLoop /* Modify the .nOut and maybe .rRun fields */
109028 ){
109029 int rc = SQLITE_OK;
109030 int nOut = pLoop->nOut;
109031 int nEq = pLoop->u.btree.nEq;
109032 LogEst nNew;
109033
109034 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
109035 Index *p = pLoop->u.btree.pIndex;
 
109036
109037 if( p->nSample>0
109038 && nEq==pBuilder->nRecValid
109039 && nEq<p->nSampleCol
109040 && OptimizationEnabled(pParse->db, SQLITE_Stat3)
@@ -110754,11 +110838,11 @@
110754 **
110755 ** In the current implementation, the first extra WHERE clause term reduces
110756 ** the number of output rows by a factor of 10 and each additional term
110757 ** reduces the number of output rows by sqrt(2).
110758 */
110759 static void whereLoopOutputAdjust(WhereClause *pWC, WhereLoop *pLoop, int iCur){
110760 WhereTerm *pTerm, *pX;
110761 Bitmask notAllowed = ~(pLoop->prereq|pLoop->maskSelf);
110762 int i, j;
110763
110764 if( !OptimizationEnabled(pWC->pWInfo->pParse->db, SQLITE_AdjustOutEst) ){
@@ -110929,12 +111013,12 @@
110929 && !ExprHasProperty(pExpr, EP_xIsSelect) ){
110930 rc = whereInScanEst(pParse, pBuilder, pExpr->x.pList, &nOut);
110931 }
110932 assert( nOut==0 || rc==SQLITE_OK );
110933 if( nOut ){
110934 nOut = sqlite3LogEst(nOut);
110935 pNew->nOut = MIN(nOut, saved_nOut);
110936 }
110937 }
110938 #endif
110939 if( (pNew->wsFlags & (WHERE_IDX_ONLY|WHERE_IPK))==0 ){
110940 /* Each row involves a step of the index, then a binary search of
@@ -110941,11 +111025,11 @@
110941 ** the main table */
110942 pNew->rRun = sqlite3LogEstAdd(pNew->rRun,rLogSize>27 ? rLogSize-17 : 10);
110943 }
110944 /* Step cost for each output row */
110945 pNew->rRun = sqlite3LogEstAdd(pNew->rRun, pNew->nOut);
110946 whereLoopOutputAdjust(pBuilder->pWC, pNew, pSrc->iCursor);
110947 rc = whereLoopInsert(pBuilder, pNew);
110948 if( (pNew->wsFlags & WHERE_TOP_LIMIT)==0
110949 && pNew->u.btree.nEq<(pProbe->nColumn + (pProbe->zName!=0))
110950 ){
110951 whereLoopAddBtreeIndex(pBuilder, pSrc, pProbe, nInMul+nIn);
@@ -111145,11 +111229,11 @@
111145 pNew->iSortIdx = b ? iSortIdx : 0;
111146 /* TUNING: Cost of full table scan is 3*(N + log2(N)).
111147 ** + The extra 3 factor is to encourage the use of indexed lookups
111148 ** over full scans. FIXME */
111149 pNew->rRun = sqlite3LogEstAdd(rSize,rLogSize) + 16;
111150 whereLoopOutputAdjust(pWC, pNew, pSrc->iCursor);
111151 rc = whereLoopInsert(pBuilder, pNew);
111152 pNew->nOut = rSize;
111153 if( rc ) break;
111154 }else{
111155 Bitmask m = pSrc->colUsed & ~columnsInIndex(pProbe);
@@ -111178,11 +111262,11 @@
111178 assert( b!=0 );
111179 /* TUNING: Cost of scanning a non-covering index is (N+1)*log2(N)
111180 ** which we will simplify to just N*log2(N) */
111181 pNew->rRun = rSize + rLogSize;
111182 }
111183 whereLoopOutputAdjust(pWC, pNew, pSrc->iCursor);
111184 rc = whereLoopInsert(pBuilder, pNew);
111185 pNew->nOut = rSize;
111186 if( rc ) break;
111187 }
111188 }
@@ -126258,15 +126342,15 @@
126258 assert( p->nToken<=MAX_INCR_PHRASE_TOKENS );
126259 assert( p->iDoclistToken<MAX_INCR_PHRASE_TOKENS );
126260
126261 while( bEof==0 ){
126262 int bMaxSet = 0;
126263 sqlite3_int64 iMax; /* Largest docid for all iterators */
126264 int i; /* Used to iterate through tokens */
126265
126266 /* Advance the iterator for each token in the phrase once. */
126267 for(i=0; rc==SQLITE_OK && i<p->nToken; i++){
126268 rc = incrPhraseTokenNext(pTab, p, i, &a[i], &bEof);
126269 if( a[i].bIgnore==0 && (bMaxSet==0 || DOCID_CMP(iMax, a[i].iDocid)<0) ){
126270 iMax = a[i].iDocid;
126271 bMaxSet = 1;
126272 }
@@ -126301,11 +126385,11 @@
126301 char *pR = aDoclist;
126302 char *pOut = aDoclist;
126303 int nDist = p->nToken-1-i;
126304 int res = fts3PoslistPhraseMerge(&pOut, nDist, 0, 1, &pL, &pR);
126305 if( res==0 ) break;
126306 nList = (pOut - aDoclist);
126307 }
126308 }
126309 if( i==(p->nToken-1) ){
126310 pDL->iDocid = iMax;
126311 pDL->pList = aDoclist;
@@ -127675,10 +127759,11 @@
127675 sqlite3_vtab_cursor base; /* Base class used by SQLite core */
127676 Fts3MultiSegReader csr; /* Must be right after "base" */
127677 Fts3SegFilter filter;
127678 char *zStop;
127679 int nStop; /* Byte-length of string zStop */
 
127680 int isEof; /* True if cursor is at EOF */
127681 sqlite3_int64 iRowid; /* Current rowid */
127682
127683 int iCol; /* Current value of 'col' column */
127684 int nStat; /* Size of aStat[] array */
@@ -127689,11 +127774,12 @@
127689 };
127690
127691 /*
127692 ** Schema of the terms table.
127693 */
127694 #define FTS3_TERMS_SCHEMA "CREATE TABLE x(term, col, documents, occurrences)"
 
127695
127696 /*
127697 ** This function does all the work for both the xConnect and xCreate methods.
127698 ** These tables have no persistent representation of their own, so xConnect
127699 ** and xCreate are identical operations.
@@ -127736,11 +127822,11 @@
127736 }else{
127737 zFts3 = argv[3];
127738 }
127739 nFts3 = (int)strlen(zFts3);
127740
127741 rc = sqlite3_declare_vtab(db, FTS3_TERMS_SCHEMA);
127742 if( rc!=SQLITE_OK ) return rc;
127743
127744 nByte = sizeof(Fts3auxTable) + sizeof(Fts3Table) + nDb + nFts3 + 2;
127745 p = (Fts3auxTable *)sqlite3_malloc(nByte);
127746 if( !p ) return SQLITE_NOMEM;
@@ -127796,10 +127882,12 @@
127796 ){
127797 int i;
127798 int iEq = -1;
127799 int iGe = -1;
127800 int iLe = -1;
 
 
127801
127802 UNUSED_PARAMETER(pVTab);
127803
127804 /* This vtab delivers always results in "ORDER BY term ASC" order. */
127805 if( pInfo->nOrderBy==1
@@ -127807,40 +127895,52 @@
127807 && pInfo->aOrderBy[0].desc==0
127808 ){
127809 pInfo->orderByConsumed = 1;
127810 }
127811
127812 /* Search for equality and range constraints on the "term" column. */
 
127813 for(i=0; i<pInfo->nConstraint; i++){
127814 if( pInfo->aConstraint[i].usable && pInfo->aConstraint[i].iColumn==0 ){
127815 int op = pInfo->aConstraint[i].op;
127816 if( op==SQLITE_INDEX_CONSTRAINT_EQ ) iEq = i;
127817 if( op==SQLITE_INDEX_CONSTRAINT_LT ) iLe = i;
127818 if( op==SQLITE_INDEX_CONSTRAINT_LE ) iLe = i;
127819 if( op==SQLITE_INDEX_CONSTRAINT_GT ) iGe = i;
127820 if( op==SQLITE_INDEX_CONSTRAINT_GE ) iGe = i;
 
 
 
 
 
 
 
127821 }
127822 }
127823
127824 if( iEq>=0 ){
127825 pInfo->idxNum = FTS4AUX_EQ_CONSTRAINT;
127826 pInfo->aConstraintUsage[iEq].argvIndex = 1;
127827 pInfo->estimatedCost = 5;
127828 }else{
127829 pInfo->idxNum = 0;
127830 pInfo->estimatedCost = 20000;
127831 if( iGe>=0 ){
127832 pInfo->idxNum += FTS4AUX_GE_CONSTRAINT;
127833 pInfo->aConstraintUsage[iGe].argvIndex = 1;
127834 pInfo->estimatedCost /= 2;
127835 }
127836 if( iLe>=0 ){
127837 pInfo->idxNum += FTS4AUX_LE_CONSTRAINT;
127838 pInfo->aConstraintUsage[iLe].argvIndex = 1 + (iGe>=0);
127839 pInfo->estimatedCost /= 2;
127840 }
127841 }
 
 
 
 
127842
127843 return SQLITE_OK;
127844 }
127845
127846 /*
@@ -127996,21 +128096,42 @@
127996 sqlite3_value **apVal /* Arguments for the indexing scheme */
127997 ){
127998 Fts3auxCursor *pCsr = (Fts3auxCursor *)pCursor;
127999 Fts3Table *pFts3 = ((Fts3auxTable *)pCursor->pVtab)->pFts3Tab;
128000 int rc;
128001 int isScan;
 
 
 
 
 
 
 
128002
128003 UNUSED_PARAMETER(nVal);
128004 UNUSED_PARAMETER(idxStr);
128005
128006 assert( idxStr==0 );
128007 assert( idxNum==FTS4AUX_EQ_CONSTRAINT || idxNum==0
128008 || idxNum==FTS4AUX_LE_CONSTRAINT || idxNum==FTS4AUX_GE_CONSTRAINT
128009 || idxNum==(FTS4AUX_LE_CONSTRAINT|FTS4AUX_GE_CONSTRAINT)
128010 );
128011 isScan = (idxNum!=FTS4AUX_EQ_CONSTRAINT);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
128012
128013 /* In case this cursor is being reused, close and zero it. */
128014 testcase(pCsr->filter.zTerm);
128015 sqlite3Fts3SegReaderFinish(&pCsr->csr);
128016 sqlite3_free((void *)pCsr->filter.zTerm);
@@ -128018,26 +128139,39 @@
128018 memset(&pCsr->csr, 0, ((u8*)&pCsr[1]) - (u8*)&pCsr->csr);
128019
128020 pCsr->filter.flags = FTS3_SEGMENT_REQUIRE_POS|FTS3_SEGMENT_IGNORE_EMPTY;
128021 if( isScan ) pCsr->filter.flags |= FTS3_SEGMENT_SCAN;
128022
128023 if( idxNum&(FTS4AUX_EQ_CONSTRAINT|FTS4AUX_GE_CONSTRAINT) ){
128024 const unsigned char *zStr = sqlite3_value_text(apVal[0]);
 
128025 if( zStr ){
128026 pCsr->filter.zTerm = sqlite3_mprintf("%s", zStr);
128027 pCsr->filter.nTerm = sqlite3_value_bytes(apVal[0]);
128028 if( pCsr->filter.zTerm==0 ) return SQLITE_NOMEM;
128029 }
128030 }
128031 if( idxNum&FTS4AUX_LE_CONSTRAINT ){
128032 int iIdx = (idxNum&FTS4AUX_GE_CONSTRAINT) ? 1 : 0;
128033 pCsr->zStop = sqlite3_mprintf("%s", sqlite3_value_text(apVal[iIdx]));
128034 pCsr->nStop = sqlite3_value_bytes(apVal[iIdx]);
128035 if( pCsr->zStop==0 ) return SQLITE_NOMEM;
128036 }
 
 
 
128037
128038 rc = sqlite3Fts3SegReaderCursor(pFts3, 0, 0, FTS3_SEGCURSOR_ALL,
 
 
 
 
 
 
 
 
 
128039 pCsr->filter.zTerm, pCsr->filter.nTerm, 0, isScan, &pCsr->csr
128040 );
128041 if( rc==SQLITE_OK ){
128042 rc = sqlite3Fts3SegReaderStart(pFts3, &pCsr->csr, &pCsr->filter);
128043 }
@@ -128057,28 +128191,41 @@
128057 /*
128058 ** xColumn - Return a column value.
128059 */
128060 static int fts3auxColumnMethod(
128061 sqlite3_vtab_cursor *pCursor, /* Cursor to retrieve value from */
128062 sqlite3_context *pContext, /* Context for sqlite3_result_xxx() calls */
128063 int iCol /* Index of column to read value from */
128064 ){
128065 Fts3auxCursor *p = (Fts3auxCursor *)pCursor;
128066
128067 assert( p->isEof==0 );
128068 if( iCol==0 ){ /* Column "term" */
128069 sqlite3_result_text(pContext, p->csr.zTerm, p->csr.nTerm, SQLITE_TRANSIENT);
128070 }else if( iCol==1 ){ /* Column "col" */
128071 if( p->iCol ){
128072 sqlite3_result_int(pContext, p->iCol-1);
128073 }else{
128074 sqlite3_result_text(pContext, "*", -1, SQLITE_STATIC);
128075 }
128076 }else if( iCol==2 ){ /* Column "documents" */
128077 sqlite3_result_int64(pContext, p->aStat[p->iCol].nDoc);
128078 }else{ /* Column "occurrences" */
128079 sqlite3_result_int64(pContext, p->aStat[p->iCol].nOcc);
 
 
 
 
 
 
 
 
 
 
 
 
 
128080 }
128081
128082 return SQLITE_OK;
128083 }
128084
128085
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -135,11 +135,11 @@
135 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
136 ** [sqlite_version()] and [sqlite_source_id()].
137 */
138 #define SQLITE_VERSION "3.8.1"
139 #define SQLITE_VERSION_NUMBER 3008001
140 #define SQLITE_SOURCE_ID "2013-10-17 12:57:35 c78be6d786c19073b3a6730dfe3fb1be54f5657a"
141
142 /*
143 ** CAPI3REF: Run-Time Library Version Numbers
144 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
145 **
@@ -1643,31 +1643,31 @@
1643 ** supplied by the application must not invoke any SQLite interface.
1644 ** In a multi-threaded application, the application-defined logger
1645 ** function must be threadsafe. </dd>
1646 **
1647 ** [[SQLITE_CONFIG_URI]] <dt>SQLITE_CONFIG_URI
1648 ** <dd>^(This option takes a single argument of type int. If non-zero, then
1649 ** URI handling is globally enabled. If the parameter is zero, then URI handling
1650 ** is globally disabled.)^ ^If URI handling is globally enabled, all filenames
1651 ** passed to [sqlite3_open()], [sqlite3_open_v2()], [sqlite3_open16()] or
1652 ** specified as part of [ATTACH] commands are interpreted as URIs, regardless
1653 ** of whether or not the [SQLITE_OPEN_URI] flag is set when the database
1654 ** connection is opened. ^If it is globally disabled, filenames are
1655 ** only interpreted as URIs if the SQLITE_OPEN_URI flag is set when the
1656 ** database connection is opened. ^(By default, URI handling is globally
1657 ** disabled. The default value may be changed by compiling with the
1658 ** [SQLITE_USE_URI] symbol defined.)^
1659 **
1660 ** [[SQLITE_CONFIG_COVERING_INDEX_SCAN]] <dt>SQLITE_CONFIG_COVERING_INDEX_SCAN
1661 ** <dd>^This option takes a single integer argument which is interpreted as
1662 ** a boolean in order to enable or disable the use of covering indices for
1663 ** full table scans in the query optimizer. ^The default setting is determined
1664 ** by the [SQLITE_ALLOW_COVERING_INDEX_SCAN] compile-time option, or is "on"
1665 ** if that compile-time option is omitted.
1666 ** The ability to disable the use of covering indices for full table scans
1667 ** is because some incorrectly coded legacy applications might malfunction
1668 ** when the optimization is enabled. Providing the ability to
1669 ** disable the optimization allows the older, buggy application code to work
1670 ** without change even with newer versions of SQLite.
1671 **
1672 ** [[SQLITE_CONFIG_PCACHE]] [[SQLITE_CONFIG_GETPCACHE]]
1673 ** <dt>SQLITE_CONFIG_PCACHE and SQLITE_CONFIG_GETPCACHE
@@ -1692,20 +1692,20 @@
1692 ** configuration option can be seen in the "test_sqllog.c" source file in
1693 ** the canonical SQLite source tree.</dd>
1694 **
1695 ** [[SQLITE_CONFIG_MMAP_SIZE]]
1696 ** <dt>SQLITE_CONFIG_MMAP_SIZE
1697 ** <dd>^SQLITE_CONFIG_MMAP_SIZE takes two 64-bit integer (sqlite3_int64) values
1698 ** that are the default mmap size limit (the default setting for
1699 ** [PRAGMA mmap_size]) and the maximum allowed mmap size limit.
1700 ** ^The default setting can be overridden by each database connection using
1701 ** either the [PRAGMA mmap_size] command, or by using the
1702 ** [SQLITE_FCNTL_MMAP_SIZE] file control. ^(The maximum allowed mmap size
1703 ** cannot be changed at run-time. Nor may the maximum allowed mmap size
1704 ** exceed the compile-time maximum mmap size set by the
1705 ** [SQLITE_MAX_MMAP_SIZE] compile-time option.)^
1706 ** ^If either argument to this option is negative, then that argument is
1707 ** changed to its compile-time default.
1708 ** </dl>
1709 */
1710 #define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */
1711 #define SQLITE_CONFIG_MULTITHREAD 2 /* nil */
@@ -12468,14 +12468,14 @@
12468 SQLITE_PRIVATE int sqlite3FkRequired(Parse*, Table*, int*, int);
12469 SQLITE_PRIVATE u32 sqlite3FkOldmask(Parse*, Table*);
12470 SQLITE_PRIVATE FKey *sqlite3FkReferences(Table *);
12471 #else
12472 #define sqlite3FkActions(a,b,c,d,e,f)
12473 #define sqlite3FkCheck(a,b,c,d,e,f)
12474 #define sqlite3FkDropTable(a,b,c)
12475 #define sqlite3FkOldmask(a,b) 0
12476 #define sqlite3FkRequired(a,b,c,d) 0
12477 #endif
12478 #ifndef SQLITE_OMIT_FOREIGN_KEY
12479 SQLITE_PRIVATE void sqlite3FkDelete(sqlite3 *, Table*);
12480 SQLITE_PRIVATE int sqlite3FkLocateIndex(Parse*,Table*,FKey*,Index**,int**);
12481 #else
@@ -14430,10 +14430,14 @@
14430 ** is available. This routine returns 0 on success and
14431 ** non-zero on any kind of error.
14432 **
14433 ** If the sqlite3GlobalConfig.bLocaltimeFault variable is true then this
14434 ** routine will always fail.
14435 **
14436 ** EVIDENCE-OF: R-62172-00036 In this implementation, the standard C
14437 ** library function localtime_r() is used to assist in the calculation of
14438 ** local time.
14439 */
14440 static int osLocaltime(time_t *t, struct tm *pTm){
14441 int rc;
14442 #if (!defined(HAVE_LOCALTIME_R) || !HAVE_LOCALTIME_R) \
14443 && (!defined(HAVE_LOCALTIME_S) || !HAVE_LOCALTIME_S)
@@ -14486,10 +14490,15 @@
14490 memset(&sLocal, 0, sizeof(sLocal));
14491
14492 x = *p;
14493 computeYMD_HMS(&x);
14494 if( x.Y<1971 || x.Y>=2038 ){
14495 /* EVIDENCE-OF: R-55269-29598 The localtime_r() C function normally only
14496 ** works for years between 1970 and 2037. For dates outside this range,
14497 ** SQLite attempts to map the year into an equivalent year within this
14498 ** range, do the calculation, then map the year back.
14499 */
14500 x.Y = 2000;
14501 x.M = 1;
14502 x.D = 1;
14503 x.h = 0;
14504 x.m = 0;
@@ -33006,12 +33015,11 @@
33015 #endif
33016 assert( pFile->h!=NULL && pFile->h!=INVALID_HANDLE_VALUE );
33017 OSTRACE(("CLOSE file=%p\n", pFile->h));
33018
33019 #if SQLITE_MAX_MMAP_SIZE>0
33020 winUnmapfile(pFile);
 
33021 #endif
33022
33023 do{
33024 rc = osCloseHandle(pFile->h);
33025 /* SimulateIOError( rc=0; cnt=MX_CLOSE_ATTEMPT; ); */
@@ -33813,11 +33821,11 @@
33821 }
33822 *(i64*)pArg = pFile->mmapSizeMax;
33823 if( newLimit>=0 && newLimit!=pFile->mmapSizeMax && pFile->nFetchOut==0 ){
33824 pFile->mmapSizeMax = newLimit;
33825 if( pFile->mmapSize>0 ){
33826 winUnmapfile(pFile);
33827 rc = winMapfile(pFile, -1);
33828 }
33829 }
33830 OSTRACE(("FCNTL file=%p, rc=%s\n", pFile->h, sqlite3ErrName(rc)));
33831 return rc;
@@ -34030,11 +34038,11 @@
34038 osGetCurrentProcessId(), deleteFlag));
34039 pp = &winShmNodeList;
34040 while( (p = *pp)!=0 ){
34041 if( p->nRef==0 ){
34042 int i;
34043 if( p->mutex ){ sqlite3_mutex_free(p->mutex); }
34044 for(i=0; i<p->nRegion; i++){
34045 BOOL bRc = osUnmapViewOfFile(p->aRegion[i].pMap);
34046 OSTRACE(("SHM-PURGE-UNMAP pid=%lu, region=%d, rc=%s\n",
34047 osGetCurrentProcessId(), i, bRc ? "ok" : "failed"));
34048 UNUSED_VARIABLE_VALUE(bRc);
@@ -34883,10 +34891,11 @@
34891 ** API prior to using it.
34892 */
34893 if( winIsDriveLetterAndColon(zDir) ){
34894 zConverted = winConvertFromUtf8Filename(zDir);
34895 if( !zConverted ){
34896 sqlite3_free(zBuf);
34897 OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
34898 return SQLITE_IOERR_NOMEM;
34899 }
34900 if( winIsDir(zConverted) ){
34901 sqlite3_snprintf(nBuf-30, zBuf, "%s", zDir);
@@ -34895,17 +34904,19 @@
34904 }
34905 sqlite3_free(zConverted);
34906 }else{
34907 zConverted = sqlite3MallocZero( nBuf+1 );
34908 if( !zConverted ){
34909 sqlite3_free(zBuf);
34910 OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
34911 return SQLITE_IOERR_NOMEM;
34912 }
34913 if( cygwin_conv_path(
34914 osIsNT() ? CCP_POSIX_TO_WIN_W : CCP_POSIX_TO_WIN_A, zDir,
34915 zConverted, nBuf+1)<0 ){
34916 sqlite3_free(zConverted);
34917 sqlite3_free(zBuf);
34918 OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_CONVPATH\n"));
34919 return winLogError(SQLITE_IOERR_CONVPATH, (DWORD)errno,
34920 "winGetTempname1", zDir);
34921 }
34922 if( winIsDir(zConverted) ){
@@ -34915,10 +34926,11 @@
34926 */
34927 if( osIsNT() ){
34928 char *zUtf8 = winUnicodeToUtf8(zConverted);
34929 if( !zUtf8 ){
34930 sqlite3_free(zConverted);
34931 sqlite3_free(zBuf);
34932 OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
34933 return SQLITE_IOERR_NOMEM;
34934 }
34935 sqlite3_snprintf(nBuf-30, zBuf, "%s", zUtf8);
34936 sqlite3_free(zUtf8);
@@ -34930,11 +34942,10 @@
34942 break;
34943 }
34944 }
34945 sqlite3_free(zConverted);
34946 }
 
34947 }
34948 }
34949 #elif !SQLITE_OS_WINRT && !defined(__CYGWIN__)
34950 else if( osIsNT() ){
34951 char *zMulti;
@@ -35300,13 +35311,13 @@
35311 pFile->zDeleteOnClose = zConverted;
35312 }else
35313 #endif
35314 {
35315 sqlite3_free(zConverted);
 
35316 }
35317
35318 sqlite3_free(zTmpname);
35319 pFile->pMethod = &winIoMethod;
35320 pFile->pVfs = pVfs;
35321 pFile->h = h;
35322 if( isReadonly ){
35323 pFile->ctrlFlags |= WINFILE_RDONLY;
@@ -52033,10 +52044,22 @@
52044 ** MX_CELL_SIZE(pBt) bytes.
52045 */
52046 static void allocateTempSpace(BtShared *pBt){
52047 if( !pBt->pTmpSpace ){
52048 pBt->pTmpSpace = sqlite3PageMalloc( pBt->pageSize );
52049
52050 /* One of the uses of pBt->pTmpSpace is to format cells before
52051 ** inserting them into a leaf page (function fillInCell()). If
52052 ** a cell is less than 4 bytes in size, it is rounded up to 4 bytes
52053 ** by the various routines that manipulate binary cells. Which
52054 ** can mean that fillInCell() only initializes the first 2 or 3
52055 ** bytes of pTmpSpace, but that the first 4 bytes are copied from
52056 ** it into a database page. This is not actually a problem, but it
52057 ** does cause a valgrind error when the 1 or 2 bytes of unitialized
52058 ** data is passed to system call write(). So to avoid this error,
52059 ** zero the first 4 bytes of temp space here. */
52060 if( pBt->pTmpSpace ) memset(pBt->pTmpSpace, 0, 4);
52061 }
52062 }
52063
52064 /*
52065 ** Free the pBt->pTmpSpace allocation
@@ -60299,11 +60322,13 @@
60322 }
60323
60324 pRec->nField = p->iVal+1;
60325 return &pRec->aMem[p->iVal];
60326 }
60327 #else
60328 UNUSED_PARAMETER(p);
60329 #endif /* defined(SQLITE_ENABLE_STAT3_OR_STAT4) */
60330 return sqlite3ValueNew(db);
60331 }
60332
60333 /*
60334 ** Extract a value from the supplied expression in the manner described
@@ -60313,11 +60338,11 @@
60338 ** If pCtx is NULL and an error occurs after the sqlite3_value object
60339 ** has been allocated, it is freed before returning. Or, if pCtx is not
60340 ** NULL, it is assumed that the caller will free any allocated object
60341 ** in all cases.
60342 */
60343 static int valueFromExpr(
60344 sqlite3 *db, /* The database connection */
60345 Expr *pExpr, /* The expression to evaluate */
60346 u8 enc, /* Encoding to use */
60347 u8 affinity, /* Affinity to use */
60348 sqlite3_value **ppVal, /* Write the new value here */
@@ -60470,10 +60495,11 @@
60495 int nVal; /* Bytes of space required for argv[0] */
60496 int nRet;
60497 sqlite3 *db;
60498 u8 *aRet;
60499
60500 UNUSED_PARAMETER( argc );
60501 iSerial = sqlite3VdbeSerialType(argv[0], file_format);
60502 nSerial = sqlite3VarintLen(iSerial);
60503 nVal = sqlite3VdbeSerialTypeLen(iSerial);
60504 db = sqlite3_context_db_handle(context);
60505
@@ -75410,10 +75436,14 @@
75436 sqlite3ErrorMsg(pParse, "second argument to likelihood() must be a "
75437 "constant between 0.0 and 1.0");
75438 pNC->nErr++;
75439 }
75440 }else{
75441 /* EVIDENCE-OF: R-61304-29449 The unlikely(X) function is equivalent to
75442 ** likelihood(X, 0.0625).
75443 ** EVIDENCE-OF: R-01283-11636 The unlikely(X) function is short-hand for
75444 ** likelihood(X,0.0625). */
75445 pExpr->iTable = 62; /* TUNING: Default 2nd arg to unlikely() is 0.0625 */
75446 }
75447 }
75448 }
75449 #ifndef SQLITE_OMIT_AUTHORIZATION
@@ -81284,11 +81314,11 @@
81314 ** The sqlite_stat2 table is superseded by sqlite_stat3, which is only
81315 ** created and used by SQLite versions 3.7.9 and later and with
81316 ** SQLITE_ENABLE_STAT3 defined. The functionality of sqlite_stat3
81317 ** is a superset of sqlite_stat2. The sqlite_stat4 is an enhanced
81318 ** version of sqlite_stat3 and is only available when compiled with
81319 ** SQLITE_ENABLE_STAT4 and in SQLite versions 3.8.1 and later. It is
81320 ** not possible to enable both STAT3 and STAT4 at the same time. If they
81321 ** are both enabled, then STAT4 takes precedence.
81322 **
81323 ** For most applications, sqlite_stat1 provides all the statisics required
81324 ** for the query planner to make good choices.
@@ -81360,16 +81390,16 @@
81390 **
81391 ** The sqlite_stat4 table contains multiple entries for each index.
81392 ** The idx column names the index and the tbl column is the table of the
81393 ** index. If the idx and tbl columns are the same, then the sample is
81394 ** of the INTEGER PRIMARY KEY. The sample column is a blob which is the
81395 ** binary encoding of a key from the index. The nEq column is a
81396 ** list of integers. The first integer is the approximate number
81397 ** of entries in the index whose left-most column exactly matches
81398 ** the left-most column of the sample. The second integer in nEq
81399 ** is the approximate number of entries in the index where the
81400 ** first two columns match the first two columns of the sample.
81401 ** And so forth. nLt is another list of integers that show the approximate
81402 ** number of entries that are strictly less than the sample. The first
81403 ** integer in nLt contains the number of entries in the index where the
81404 ** left-most column is less than the left-most column of the sample.
81405 ** The K-th integer in the nLt entry is the number of index entries
@@ -81696,11 +81726,11 @@
81726 }
81727
81728 /*
81729 ** Copy the contents of object (*pFrom) into (*pTo).
81730 */
81731 static void sampleCopy(Stat4Accum *p, Stat4Sample *pTo, Stat4Sample *pFrom){
81732 pTo->iRowid = pFrom->iRowid;
81733 pTo->isPSample = pFrom->isPSample;
81734 pTo->iCol = pFrom->iCol;
81735 pTo->iHash = pFrom->iHash;
81736 memcpy(pTo->anEq, pFrom->anEq, sizeof(tRowcnt)*p->nCol);
@@ -81841,10 +81871,15 @@
81871 ){
81872 sampleInsert(p, &p->current, 0);
81873 }
81874 }
81875 #endif
81876
81877 #ifndef SQLITE_ENABLE_STAT3_OR_STAT4
81878 UNUSED_PARAMETER( p );
81879 UNUSED_PARAMETER( iChng );
81880 #endif
81881 }
81882
81883 /*
81884 ** Implementation of the stat_push SQL function: stat_push(P,R,C)
81885 ** Arguments:
@@ -81866,10 +81901,12 @@
81901
81902 /* The three function arguments */
81903 Stat4Accum *p = (Stat4Accum*)sqlite3_value_blob(argv[0]);
81904 int iChng = sqlite3_value_int(argv[1]);
81905
81906 UNUSED_PARAMETER( argc );
81907 UNUSED_PARAMETER( context );
81908 assert( p->nCol>1 ); /* Includes rowid field */
81909 assert( iChng<p->nCol );
81910
81911 if( p->nRow==0 ){
81912 /* This is the first call to this function. Do initialization. */
@@ -82051,10 +82088,13 @@
82088 sqlite3_result_text(context, zRet, -1, sqlite3_free);
82089 }
82090 }
82091 }
82092 #endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */
82093 #ifndef SQLITE_DEBUG
82094 UNUSED_PARAMETER( argc );
82095 #endif
82096 }
82097 static const FuncDef statGetFuncdef = {
82098 1+IsStat34, /* nArg */
82099 SQLITE_UTF8, /* funcFlags */
82100 0, /* pUserData */
@@ -82069,12 +82109,14 @@
82109
82110 static void callStatGet(Vdbe *v, int regStat4, int iParam, int regOut){
82111 assert( regOut!=regStat4 && regOut!=regStat4+1 );
82112 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
82113 sqlite3VdbeAddOp2(v, OP_Integer, iParam, regStat4+1);
82114 #elif SQLITE_DEBUG
82115 assert( iParam==STAT_GET_STAT1 );
82116 #else
82117 UNUSED_PARAMETER( iParam );
82118 #endif
82119 sqlite3VdbeAddOp3(v, OP_Function, 0, regStat4, regOut);
82120 sqlite3VdbeChangeP4(v, -1, (char*)&statGetFuncdef, P4_FUNCDEF);
82121 sqlite3VdbeChangeP5(v, 1 + IsStat34);
82122 }
@@ -84833,11 +84875,11 @@
84875 *pszEst = 1; /* default size is approx 4 bytes */
84876 if( aff<=SQLITE_AFF_NONE ){
84877 if( zChar ){
84878 while( zChar[0] ){
84879 if( sqlite3Isdigit(zChar[0]) ){
84880 int v = 0;
84881 sqlite3GetInt32(zChar, &v);
84882 v = v/4 + 1;
84883 if( v>255 ) v = 255;
84884 *pszEst = v; /* BLOB(k), VARCHAR(k), CHAR(k) -> r=(k/4+1) */
84885 break;
@@ -91144,11 +91186,11 @@
91186 ** generating any VDBE code. If one can be found, then jump over
91187 ** the entire DELETE if there are no outstanding deferred constraints
91188 ** when this statement is run. */
91189 FKey *p;
91190 for(p=pTab->pFKey; p; p=p->pNextFrom){
91191 if( p->isDeferred || (db->flags & SQLITE_DeferFKs) ) break;
91192 }
91193 if( !p ) return;
91194 iSkip = sqlite3VdbeMakeLabel(v);
91195 sqlite3VdbeAddOp2(v, OP_FkIfZero, 1, iSkip);
91196 }
@@ -91158,15 +91200,22 @@
91200 pParse->disableTriggers = 0;
91201
91202 /* If the DELETE has generated immediate foreign key constraint
91203 ** violations, halt the VDBE and return an error at this point, before
91204 ** any modifications to the schema are made. This is because statement
91205 ** transactions are not able to rollback schema changes.
91206 **
91207 ** If the SQLITE_DeferFKs flag is set, then this is not required, as
91208 ** the statement transaction will not be rolled back even if FK
91209 ** constraints are violated.
91210 */
91211 if( (db->flags & SQLITE_DeferFKs)==0 ){
91212 sqlite3VdbeAddOp2(v, OP_FkIfZero, 0, sqlite3VdbeCurrentAddr(v)+2);
91213 sqlite3HaltConstraint(pParse, SQLITE_CONSTRAINT_FOREIGNKEY,
91214 OE_Abort, "foreign key constraint failed", P4_STATIC
91215 );
91216 }
91217
91218 if( iSkip ){
91219 sqlite3VdbeResolveLabel(v, iSkip);
91220 }
91221 }
@@ -95164,22 +95213,23 @@
95213 #define PragTyp_MMAP_SIZE 23
95214 #define PragTyp_PAGE_SIZE 24
95215 #define PragTyp_SECURE_DELETE 25
95216 #define PragTyp_SHRINK_MEMORY 26
95217 #define PragTyp_SOFT_HEAP_LIMIT 27
95218 #define PragTyp_STATS 28
95219 #define PragTyp_SYNCHRONOUS 29
95220 #define PragTyp_TABLE_INFO 30
95221 #define PragTyp_TEMP_STORE 31
95222 #define PragTyp_TEMP_STORE_DIRECTORY 32
95223 #define PragTyp_WAL_AUTOCHECKPOINT 33
95224 #define PragTyp_WAL_CHECKPOINT 34
95225 #define PragTyp_ACTIVATE_EXTENSIONS 35
95226 #define PragTyp_HEXKEY 36
95227 #define PragTyp_KEY 37
95228 #define PragTyp_REKEY 38
95229 #define PragTyp_LOCK_STATUS 39
95230 #define PragTyp_PARSER_TRACE 40
95231 #define PragFlag_NeedSchema 0x01
95232 static const struct sPragmaNames {
95233 const char *const zName; /* Name of pragma */
95234 u8 ePragTyp; /* PragTyp_XXX value */
95235 u8 mPragFlag; /* Zero or more PragFlag_XXX values */
@@ -95466,10 +95516,16 @@
95516 #if defined(SQLITE_DEBUG)
95517 { /* zName: */ "sql_trace",
95518 /* ePragTyp: */ PragTyp_FLAG,
95519 /* ePragFlag: */ 0,
95520 /* iArg: */ SQLITE_SqlTrace },
95521 #endif
95522 #if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
95523 { /* zName: */ "stats",
95524 /* ePragTyp: */ PragTyp_STATS,
95525 /* ePragFlag: */ PragFlag_NeedSchema,
95526 /* iArg: */ 0 },
95527 #endif
95528 #if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
95529 { /* zName: */ "synchronous",
95530 /* ePragTyp: */ PragTyp_SYNCHRONOUS,
95531 /* ePragFlag: */ PragFlag_NeedSchema,
@@ -95528,11 +95584,11 @@
95584 { /* zName: */ "writable_schema",
95585 /* ePragTyp: */ PragTyp_FLAG,
95586 /* ePragFlag: */ 0,
95587 /* iArg: */ SQLITE_WriteSchema|SQLITE_RecoveryMode },
95588 };
95589 /* Number of pragmas: 56 on by default, 68 total. */
95590 /* End of the automatically generated pragma table.
95591 ***************************************************************************/
95592
95593 /*
95594 ** Interpret the given string as a safety level. Return 0 for OFF,
@@ -96532,10 +96588,40 @@
96588 sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 6);
96589 }
96590 }
96591 }
96592 break;
96593
96594 case PragTyp_STATS: {
96595 Index *pIdx;
96596 HashElem *i;
96597 v = sqlite3GetVdbe(pParse);
96598 sqlite3VdbeSetNumCols(v, 4);
96599 pParse->nMem = 4;
96600 sqlite3CodeVerifySchema(pParse, iDb);
96601 sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "table", SQLITE_STATIC);
96602 sqlite3VdbeSetColName(v, 1, COLNAME_NAME, "index", SQLITE_STATIC);
96603 sqlite3VdbeSetColName(v, 2, COLNAME_NAME, "width", SQLITE_STATIC);
96604 sqlite3VdbeSetColName(v, 3, COLNAME_NAME, "height", SQLITE_STATIC);
96605 for(i=sqliteHashFirst(&pDb->pSchema->tblHash); i; i=sqliteHashNext(i)){
96606 Table *pTab = sqliteHashData(i);
96607 sqlite3VdbeAddOp4(v, OP_String8, 0, 1, 0, pTab->zName, 0);
96608 sqlite3VdbeAddOp2(v, OP_Null, 0, 2);
96609 sqlite3VdbeAddOp2(v, OP_Integer,
96610 (int)sqlite3LogEstToInt(pTab->szTabRow), 3);
96611 sqlite3VdbeAddOp2(v, OP_Integer, (int)pTab->nRowEst, 4);
96612 sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 4);
96613 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
96614 sqlite3VdbeAddOp4(v, OP_String8, 0, 2, 0, pIdx->zName, 0);
96615 sqlite3VdbeAddOp2(v, OP_Integer,
96616 (int)sqlite3LogEstToInt(pIdx->szIdxRow), 3);
96617 sqlite3VdbeAddOp2(v, OP_Integer, (int)pIdx->aiRowEst[0], 4);
96618 sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 4);
96619 }
96620 }
96621 }
96622 break;
96623
96624 case PragTyp_INDEX_INFO: if( zRight ){
96625 Index *pIdx;
96626 Table *pTab;
96627 pIdx = sqlite3FindIndex(db, zRight, zDb);
@@ -96565,30 +96651,21 @@
96651 Table *pTab;
96652 int i;
96653 pTab = sqlite3FindTable(db, zRight, zDb);
96654 if( pTab ){
96655 v = sqlite3GetVdbe(pParse);
96656 sqlite3VdbeSetNumCols(v, 3);
96657 pParse->nMem = 3;
96658 sqlite3CodeVerifySchema(pParse, iDb);
96659 sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "seq", SQLITE_STATIC);
96660 sqlite3VdbeSetColName(v, 1, COLNAME_NAME, "name", SQLITE_STATIC);
96661 sqlite3VdbeSetColName(v, 2, COLNAME_NAME, "unique", SQLITE_STATIC);
96662 for(pIdx=pTab->pIndex, i=0; pIdx; pIdx=pIdx->pNext, i++){
 
 
 
 
 
 
 
96663 sqlite3VdbeAddOp2(v, OP_Integer, i, 1);
96664 sqlite3VdbeAddOp4(v, OP_String8, 0, 2, 0, pIdx->zName, 0);
96665 sqlite3VdbeAddOp2(v, OP_Integer, pIdx->onError!=OE_None, 3);
96666 sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 3);
 
 
96667 }
96668 }
96669 }
96670 break;
96671
@@ -96718,12 +96795,12 @@
96795 if( pTab->nCol+regRow>pParse->nMem ) pParse->nMem = pTab->nCol + regRow;
96796 sqlite3OpenTable(pParse, 0, iDb, pTab, OP_OpenRead);
96797 sqlite3VdbeAddOp4(v, OP_String8, 0, regResult, 0, pTab->zName,
96798 P4_TRANSIENT);
96799 for(i=1, pFK=pTab->pFKey; pFK; i++, pFK=pFK->pNextFrom){
96800 pParent = sqlite3FindTable(db, pFK->zTo, zDb);
96801 if( pParent==0 ) continue;
96802 pIdx = 0;
96803 sqlite3TableLock(pParse, iDb, pParent->tnum, 0, pParent->zName);
96804 x = sqlite3FkLocateIndex(pParse, pParent, pFK, &pIdx, 0);
96805 if( x==0 ){
96806 if( pIdx==0 ){
@@ -96736,22 +96813,24 @@
96813 }else{
96814 k = 0;
96815 break;
96816 }
96817 }
96818 assert( pParse->nErr>0 || pFK==0 );
96819 if( pFK ) break;
96820 if( pParse->nTab<i ) pParse->nTab = i;
96821 addrTop = sqlite3VdbeAddOp1(v, OP_Rewind, 0);
96822 for(i=1, pFK=pTab->pFKey; pFK; i++, pFK=pFK->pNextFrom){
96823 pParent = sqlite3FindTable(db, pFK->zTo, zDb);
 
96824 pIdx = 0;
96825 aiCols = 0;
96826 if( pParent ){
96827 x = sqlite3FkLocateIndex(pParse, pParent, pFK, &pIdx, &aiCols);
96828 assert( x==0 );
96829 }
96830 addrOk = sqlite3VdbeMakeLabel(v);
96831 if( pParent && pIdx==0 ){
96832 int iKey = pFK->aCol[0].iFrom;
96833 assert( iKey>=0 && iKey<pTab->nCol );
96834 if( iKey!=pTab->iPKey ){
96835 sqlite3VdbeAddOp3(v, OP_Column, 0, iKey, regRow);
96836 sqlite3ColumnDefault(v, pTab, iKey, regRow);
@@ -96765,17 +96844,19 @@
96844 sqlite3VdbeAddOp2(v, OP_Goto, 0, addrOk);
96845 sqlite3VdbeJumpHere(v, sqlite3VdbeCurrentAddr(v)-2);
96846 }else{
96847 for(j=0; j<pFK->nCol; j++){
96848 sqlite3ExprCodeGetColumnOfTable(v, pTab, 0,
96849 aiCols ? aiCols[j] : pFK->aCol[j].iFrom, regRow+j);
96850 sqlite3VdbeAddOp2(v, OP_IsNull, regRow+j, addrOk);
96851 }
96852 if( pParent ){
96853 sqlite3VdbeAddOp3(v, OP_MakeRecord, regRow, pFK->nCol, regKey);
96854 sqlite3VdbeChangeP4(v, -1,
96855 sqlite3IndexAffinityStr(v,pIdx), P4_TRANSIENT);
96856 sqlite3VdbeAddOp4Int(v, OP_Found, i, addrOk, regKey, 0);
96857 }
96858 }
96859 sqlite3VdbeAddOp2(v, OP_Rowid, 0, regResult+1);
96860 sqlite3VdbeAddOp4(v, OP_String8, 0, regResult+2, 0,
96861 pFK->zTo, P4_TRANSIENT);
96862 sqlite3VdbeAddOp2(v, OP_Integer, i-1, regResult+3);
@@ -108909,10 +108990,13 @@
108990 int iMin = 0; /* Smallest sample not yet tested */
108991 int i = pIdx->nSample; /* Smallest sample larger than or equal to pRec */
108992 int iTest; /* Next sample to test */
108993 int res; /* Result of comparison operation */
108994
108995 #ifndef SQLITE_DEBUG
108996 UNUSED_PARAMETER( pParse );
108997 #endif
108998 assert( pRec!=0 || pParse->db->mallocFailed );
108999 if( pRec==0 ) return;
109000 iCol = pRec->nField - 1;
109001 assert( pIdx->nSample>0 );
109002 assert( pRec->nField>0 && iCol<pIdx->nSampleCol );
@@ -109026,15 +109110,15 @@
109110 WhereTerm *pUpper, /* Upper bound on the range. ex: "x<455" Might be NULL */
109111 WhereLoop *pLoop /* Modify the .nOut and maybe .rRun fields */
109112 ){
109113 int rc = SQLITE_OK;
109114 int nOut = pLoop->nOut;
 
109115 LogEst nNew;
109116
109117 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
109118 Index *p = pLoop->u.btree.pIndex;
109119 int nEq = pLoop->u.btree.nEq;
109120
109121 if( p->nSample>0
109122 && nEq==pBuilder->nRecValid
109123 && nEq<p->nSampleCol
109124 && OptimizationEnabled(pParse->db, SQLITE_Stat3)
@@ -110754,11 +110838,11 @@
110838 **
110839 ** In the current implementation, the first extra WHERE clause term reduces
110840 ** the number of output rows by a factor of 10 and each additional term
110841 ** reduces the number of output rows by sqrt(2).
110842 */
110843 static void whereLoopOutputAdjust(WhereClause *pWC, WhereLoop *pLoop){
110844 WhereTerm *pTerm, *pX;
110845 Bitmask notAllowed = ~(pLoop->prereq|pLoop->maskSelf);
110846 int i, j;
110847
110848 if( !OptimizationEnabled(pWC->pWInfo->pParse->db, SQLITE_AdjustOutEst) ){
@@ -110929,12 +111013,12 @@
111013 && !ExprHasProperty(pExpr, EP_xIsSelect) ){
111014 rc = whereInScanEst(pParse, pBuilder, pExpr->x.pList, &nOut);
111015 }
111016 assert( nOut==0 || rc==SQLITE_OK );
111017 if( nOut ){
111018 pNew->nOut = sqlite3LogEst(nOut);
111019 if( pNew->nOut>saved_nOut ) pNew->nOut = saved_nOut;
111020 }
111021 }
111022 #endif
111023 if( (pNew->wsFlags & (WHERE_IDX_ONLY|WHERE_IPK))==0 ){
111024 /* Each row involves a step of the index, then a binary search of
@@ -110941,11 +111025,11 @@
111025 ** the main table */
111026 pNew->rRun = sqlite3LogEstAdd(pNew->rRun,rLogSize>27 ? rLogSize-17 : 10);
111027 }
111028 /* Step cost for each output row */
111029 pNew->rRun = sqlite3LogEstAdd(pNew->rRun, pNew->nOut);
111030 whereLoopOutputAdjust(pBuilder->pWC, pNew);
111031 rc = whereLoopInsert(pBuilder, pNew);
111032 if( (pNew->wsFlags & WHERE_TOP_LIMIT)==0
111033 && pNew->u.btree.nEq<(pProbe->nColumn + (pProbe->zName!=0))
111034 ){
111035 whereLoopAddBtreeIndex(pBuilder, pSrc, pProbe, nInMul+nIn);
@@ -111145,11 +111229,11 @@
111229 pNew->iSortIdx = b ? iSortIdx : 0;
111230 /* TUNING: Cost of full table scan is 3*(N + log2(N)).
111231 ** + The extra 3 factor is to encourage the use of indexed lookups
111232 ** over full scans. FIXME */
111233 pNew->rRun = sqlite3LogEstAdd(rSize,rLogSize) + 16;
111234 whereLoopOutputAdjust(pWC, pNew);
111235 rc = whereLoopInsert(pBuilder, pNew);
111236 pNew->nOut = rSize;
111237 if( rc ) break;
111238 }else{
111239 Bitmask m = pSrc->colUsed & ~columnsInIndex(pProbe);
@@ -111178,11 +111262,11 @@
111262 assert( b!=0 );
111263 /* TUNING: Cost of scanning a non-covering index is (N+1)*log2(N)
111264 ** which we will simplify to just N*log2(N) */
111265 pNew->rRun = rSize + rLogSize;
111266 }
111267 whereLoopOutputAdjust(pWC, pNew);
111268 rc = whereLoopInsert(pBuilder, pNew);
111269 pNew->nOut = rSize;
111270 if( rc ) break;
111271 }
111272 }
@@ -126258,15 +126342,15 @@
126342 assert( p->nToken<=MAX_INCR_PHRASE_TOKENS );
126343 assert( p->iDoclistToken<MAX_INCR_PHRASE_TOKENS );
126344
126345 while( bEof==0 ){
126346 int bMaxSet = 0;
126347 sqlite3_int64 iMax = 0; /* Largest docid for all iterators */
126348 int i; /* Used to iterate through tokens */
126349
126350 /* Advance the iterator for each token in the phrase once. */
126351 for(i=0; rc==SQLITE_OK && i<p->nToken && bEof==0; i++){
126352 rc = incrPhraseTokenNext(pTab, p, i, &a[i], &bEof);
126353 if( a[i].bIgnore==0 && (bMaxSet==0 || DOCID_CMP(iMax, a[i].iDocid)<0) ){
126354 iMax = a[i].iDocid;
126355 bMaxSet = 1;
126356 }
@@ -126301,11 +126385,11 @@
126385 char *pR = aDoclist;
126386 char *pOut = aDoclist;
126387 int nDist = p->nToken-1-i;
126388 int res = fts3PoslistPhraseMerge(&pOut, nDist, 0, 1, &pL, &pR);
126389 if( res==0 ) break;
126390 nList = (int)(pOut - aDoclist);
126391 }
126392 }
126393 if( i==(p->nToken-1) ){
126394 pDL->iDocid = iMax;
126395 pDL->pList = aDoclist;
@@ -127675,10 +127759,11 @@
127759 sqlite3_vtab_cursor base; /* Base class used by SQLite core */
127760 Fts3MultiSegReader csr; /* Must be right after "base" */
127761 Fts3SegFilter filter;
127762 char *zStop;
127763 int nStop; /* Byte-length of string zStop */
127764 int iLangid; /* Language id to query */
127765 int isEof; /* True if cursor is at EOF */
127766 sqlite3_int64 iRowid; /* Current rowid */
127767
127768 int iCol; /* Current value of 'col' column */
127769 int nStat; /* Size of aStat[] array */
@@ -127689,11 +127774,12 @@
127774 };
127775
127776 /*
127777 ** Schema of the terms table.
127778 */
127779 #define FTS3_AUX_SCHEMA \
127780 "CREATE TABLE x(term, col, documents, occurrences, languageid HIDDEN)"
127781
127782 /*
127783 ** This function does all the work for both the xConnect and xCreate methods.
127784 ** These tables have no persistent representation of their own, so xConnect
127785 ** and xCreate are identical operations.
@@ -127736,11 +127822,11 @@
127822 }else{
127823 zFts3 = argv[3];
127824 }
127825 nFts3 = (int)strlen(zFts3);
127826
127827 rc = sqlite3_declare_vtab(db, FTS3_AUX_SCHEMA);
127828 if( rc!=SQLITE_OK ) return rc;
127829
127830 nByte = sizeof(Fts3auxTable) + sizeof(Fts3Table) + nDb + nFts3 + 2;
127831 p = (Fts3auxTable *)sqlite3_malloc(nByte);
127832 if( !p ) return SQLITE_NOMEM;
@@ -127796,10 +127882,12 @@
127882 ){
127883 int i;
127884 int iEq = -1;
127885 int iGe = -1;
127886 int iLe = -1;
127887 int iLangid = -1;
127888 int iNext = 1; /* Next free argvIndex value */
127889
127890 UNUSED_PARAMETER(pVTab);
127891
127892 /* This vtab delivers always results in "ORDER BY term ASC" order. */
127893 if( pInfo->nOrderBy==1
@@ -127807,40 +127895,52 @@
127895 && pInfo->aOrderBy[0].desc==0
127896 ){
127897 pInfo->orderByConsumed = 1;
127898 }
127899
127900 /* Search for equality and range constraints on the "term" column.
127901 ** And equality constraints on the hidden "languageid" column. */
127902 for(i=0; i<pInfo->nConstraint; i++){
127903 if( pInfo->aConstraint[i].usable ){
127904 int op = pInfo->aConstraint[i].op;
127905 int iCol = pInfo->aConstraint[i].iColumn;
127906
127907 if( iCol==0 ){
127908 if( op==SQLITE_INDEX_CONSTRAINT_EQ ) iEq = i;
127909 if( op==SQLITE_INDEX_CONSTRAINT_LT ) iLe = i;
127910 if( op==SQLITE_INDEX_CONSTRAINT_LE ) iLe = i;
127911 if( op==SQLITE_INDEX_CONSTRAINT_GT ) iGe = i;
127912 if( op==SQLITE_INDEX_CONSTRAINT_GE ) iGe = i;
127913 }
127914 if( iCol==4 ){
127915 if( op==SQLITE_INDEX_CONSTRAINT_EQ ) iLangid = i;
127916 }
127917 }
127918 }
127919
127920 if( iEq>=0 ){
127921 pInfo->idxNum = FTS4AUX_EQ_CONSTRAINT;
127922 pInfo->aConstraintUsage[iEq].argvIndex = iNext++;
127923 pInfo->estimatedCost = 5;
127924 }else{
127925 pInfo->idxNum = 0;
127926 pInfo->estimatedCost = 20000;
127927 if( iGe>=0 ){
127928 pInfo->idxNum += FTS4AUX_GE_CONSTRAINT;
127929 pInfo->aConstraintUsage[iGe].argvIndex = iNext++;
127930 pInfo->estimatedCost /= 2;
127931 }
127932 if( iLe>=0 ){
127933 pInfo->idxNum += FTS4AUX_LE_CONSTRAINT;
127934 pInfo->aConstraintUsage[iLe].argvIndex = iNext++;
127935 pInfo->estimatedCost /= 2;
127936 }
127937 }
127938 if( iLangid>=0 ){
127939 pInfo->aConstraintUsage[iLangid].argvIndex = iNext++;
127940 pInfo->estimatedCost--;
127941 }
127942
127943 return SQLITE_OK;
127944 }
127945
127946 /*
@@ -127996,21 +128096,42 @@
128096 sqlite3_value **apVal /* Arguments for the indexing scheme */
128097 ){
128098 Fts3auxCursor *pCsr = (Fts3auxCursor *)pCursor;
128099 Fts3Table *pFts3 = ((Fts3auxTable *)pCursor->pVtab)->pFts3Tab;
128100 int rc;
128101 int isScan = 0;
128102 int iLangVal = 0; /* Language id to query */
128103
128104 int iEq = -1; /* Index of term=? value in apVal */
128105 int iGe = -1; /* Index of term>=? value in apVal */
128106 int iLe = -1; /* Index of term<=? value in apVal */
128107 int iLangid = -1; /* Index of languageid=? value in apVal */
128108 int iNext = 0;
128109
128110 UNUSED_PARAMETER(nVal);
128111 UNUSED_PARAMETER(idxStr);
128112
128113 assert( idxStr==0 );
128114 assert( idxNum==FTS4AUX_EQ_CONSTRAINT || idxNum==0
128115 || idxNum==FTS4AUX_LE_CONSTRAINT || idxNum==FTS4AUX_GE_CONSTRAINT
128116 || idxNum==(FTS4AUX_LE_CONSTRAINT|FTS4AUX_GE_CONSTRAINT)
128117 );
128118
128119 if( idxNum==FTS4AUX_EQ_CONSTRAINT ){
128120 iEq = iNext++;
128121 }else{
128122 isScan = 1;
128123 if( idxNum & FTS4AUX_GE_CONSTRAINT ){
128124 iGe = iNext++;
128125 }
128126 if( idxNum & FTS4AUX_LE_CONSTRAINT ){
128127 iLe = iNext++;
128128 }
128129 }
128130 if( iNext<nVal ){
128131 iLangid = iNext++;
128132 }
128133
128134 /* In case this cursor is being reused, close and zero it. */
128135 testcase(pCsr->filter.zTerm);
128136 sqlite3Fts3SegReaderFinish(&pCsr->csr);
128137 sqlite3_free((void *)pCsr->filter.zTerm);
@@ -128018,26 +128139,39 @@
128139 memset(&pCsr->csr, 0, ((u8*)&pCsr[1]) - (u8*)&pCsr->csr);
128140
128141 pCsr->filter.flags = FTS3_SEGMENT_REQUIRE_POS|FTS3_SEGMENT_IGNORE_EMPTY;
128142 if( isScan ) pCsr->filter.flags |= FTS3_SEGMENT_SCAN;
128143
128144 if( iEq>=0 || iGe>=0 ){
128145 const unsigned char *zStr = sqlite3_value_text(apVal[0]);
128146 assert( (iEq==0 && iGe==-1) || (iEq==-1 && iGe==0) );
128147 if( zStr ){
128148 pCsr->filter.zTerm = sqlite3_mprintf("%s", zStr);
128149 pCsr->filter.nTerm = sqlite3_value_bytes(apVal[0]);
128150 if( pCsr->filter.zTerm==0 ) return SQLITE_NOMEM;
128151 }
128152 }
128153
128154 if( iLe>=0 ){
128155 pCsr->zStop = sqlite3_mprintf("%s", sqlite3_value_text(apVal[iLe]));
128156 pCsr->nStop = sqlite3_value_bytes(apVal[iLe]);
128157 if( pCsr->zStop==0 ) return SQLITE_NOMEM;
128158 }
128159
128160 if( iLangid>=0 ){
128161 iLangVal = sqlite3_value_int(apVal[iLangid]);
128162
128163 /* If the user specified a negative value for the languageid, use zero
128164 ** instead. This works, as the "languageid=?" constraint will also
128165 ** be tested by the VDBE layer. The test will always be false (since
128166 ** this module will not return a row with a negative languageid), and
128167 ** so the overall query will return zero rows. */
128168 if( iLangVal<0 ) iLangVal = 0;
128169 }
128170 pCsr->iLangid = iLangVal;
128171
128172 rc = sqlite3Fts3SegReaderCursor(pFts3, iLangVal, 0, FTS3_SEGCURSOR_ALL,
128173 pCsr->filter.zTerm, pCsr->filter.nTerm, 0, isScan, &pCsr->csr
128174 );
128175 if( rc==SQLITE_OK ){
128176 rc = sqlite3Fts3SegReaderStart(pFts3, &pCsr->csr, &pCsr->filter);
128177 }
@@ -128057,28 +128191,41 @@
128191 /*
128192 ** xColumn - Return a column value.
128193 */
128194 static int fts3auxColumnMethod(
128195 sqlite3_vtab_cursor *pCursor, /* Cursor to retrieve value from */
128196 sqlite3_context *pCtx, /* Context for sqlite3_result_xxx() calls */
128197 int iCol /* Index of column to read value from */
128198 ){
128199 Fts3auxCursor *p = (Fts3auxCursor *)pCursor;
128200
128201 assert( p->isEof==0 );
128202 switch( iCol ){
128203 case 0: /* term */
128204 sqlite3_result_text(pCtx, p->csr.zTerm, p->csr.nTerm, SQLITE_TRANSIENT);
128205 break;
128206
128207 case 1: /* col */
128208 if( p->iCol ){
128209 sqlite3_result_int(pCtx, p->iCol-1);
128210 }else{
128211 sqlite3_result_text(pCtx, "*", -1, SQLITE_STATIC);
128212 }
128213 break;
128214
128215 case 2: /* documents */
128216 sqlite3_result_int64(pCtx, p->aStat[p->iCol].nDoc);
128217 break;
128218
128219 case 3: /* occurrences */
128220 sqlite3_result_int64(pCtx, p->aStat[p->iCol].nOcc);
128221 break;
128222
128223 default: /* languageid */
128224 assert( iCol==4 );
128225 sqlite3_result_int(pCtx, p->iLangid);
128226 break;
128227 }
128228
128229 return SQLITE_OK;
128230 }
128231
128232
+14 -14
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -107,11 +107,11 @@
107107
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
108108
** [sqlite_version()] and [sqlite_source_id()].
109109
*/
110110
#define SQLITE_VERSION "3.8.1"
111111
#define SQLITE_VERSION_NUMBER 3008001
112
-#define SQLITE_SOURCE_ID "2013-10-11 13:27:26 03593817ab5abdd4bbaa5e47e2e4745eef025af9"
112
+#define SQLITE_SOURCE_ID "2013-10-17 12:57:35 c78be6d786c19073b3a6730dfe3fb1be54f5657a"
113113
114114
/*
115115
** CAPI3REF: Run-Time Library Version Numbers
116116
** KEYWORDS: sqlite3_version, sqlite3_sourceid
117117
**
@@ -1615,31 +1615,31 @@
16151615
** supplied by the application must not invoke any SQLite interface.
16161616
** In a multi-threaded application, the application-defined logger
16171617
** function must be threadsafe. </dd>
16181618
**
16191619
** [[SQLITE_CONFIG_URI]] <dt>SQLITE_CONFIG_URI
1620
-** <dd> This option takes a single argument of type int. If non-zero, then
1620
+** <dd>^(This option takes a single argument of type int. If non-zero, then
16211621
** URI handling is globally enabled. If the parameter is zero, then URI handling
1622
-** is globally disabled. If URI handling is globally enabled, all filenames
1622
+** is globally disabled.)^ ^If URI handling is globally enabled, all filenames
16231623
** passed to [sqlite3_open()], [sqlite3_open_v2()], [sqlite3_open16()] or
16241624
** specified as part of [ATTACH] commands are interpreted as URIs, regardless
16251625
** of whether or not the [SQLITE_OPEN_URI] flag is set when the database
1626
-** connection is opened. If it is globally disabled, filenames are
1626
+** connection is opened. ^If it is globally disabled, filenames are
16271627
** only interpreted as URIs if the SQLITE_OPEN_URI flag is set when the
1628
-** database connection is opened. By default, URI handling is globally
1628
+** database connection is opened. ^(By default, URI handling is globally
16291629
** disabled. The default value may be changed by compiling with the
1630
-** [SQLITE_USE_URI] symbol defined.
1630
+** [SQLITE_USE_URI] symbol defined.)^
16311631
**
16321632
** [[SQLITE_CONFIG_COVERING_INDEX_SCAN]] <dt>SQLITE_CONFIG_COVERING_INDEX_SCAN
1633
-** <dd> This option takes a single integer argument which is interpreted as
1633
+** <dd>^This option takes a single integer argument which is interpreted as
16341634
** a boolean in order to enable or disable the use of covering indices for
1635
-** full table scans in the query optimizer. The default setting is determined
1635
+** full table scans in the query optimizer. ^The default setting is determined
16361636
** by the [SQLITE_ALLOW_COVERING_INDEX_SCAN] compile-time option, or is "on"
16371637
** if that compile-time option is omitted.
16381638
** The ability to disable the use of covering indices for full table scans
16391639
** is because some incorrectly coded legacy applications might malfunction
1640
-** malfunction when the optimization is enabled. Providing the ability to
1640
+** when the optimization is enabled. Providing the ability to
16411641
** disable the optimization allows the older, buggy application code to work
16421642
** without change even with newer versions of SQLite.
16431643
**
16441644
** [[SQLITE_CONFIG_PCACHE]] [[SQLITE_CONFIG_GETPCACHE]]
16451645
** <dt>SQLITE_CONFIG_PCACHE and SQLITE_CONFIG_GETPCACHE
@@ -1664,20 +1664,20 @@
16641664
** configuration option can be seen in the "test_sqllog.c" source file in
16651665
** the canonical SQLite source tree.</dd>
16661666
**
16671667
** [[SQLITE_CONFIG_MMAP_SIZE]]
16681668
** <dt>SQLITE_CONFIG_MMAP_SIZE
1669
-** <dd>SQLITE_CONFIG_MMAP_SIZE takes two 64-bit integer (sqlite3_int64) values
1669
+** <dd>^SQLITE_CONFIG_MMAP_SIZE takes two 64-bit integer (sqlite3_int64) values
16701670
** that are the default mmap size limit (the default setting for
16711671
** [PRAGMA mmap_size]) and the maximum allowed mmap size limit.
1672
-** The default setting can be overridden by each database connection using
1672
+** ^The default setting can be overridden by each database connection using
16731673
** either the [PRAGMA mmap_size] command, or by using the
1674
-** [SQLITE_FCNTL_MMAP_SIZE] file control. The maximum allowed mmap size
1674
+** [SQLITE_FCNTL_MMAP_SIZE] file control. ^(The maximum allowed mmap size
16751675
** cannot be changed at run-time. Nor may the maximum allowed mmap size
16761676
** exceed the compile-time maximum mmap size set by the
1677
-** [SQLITE_MAX_MMAP_SIZE] compile-time option.
1678
-** If either argument to this option is negative, then that argument is
1677
+** [SQLITE_MAX_MMAP_SIZE] compile-time option.)^
1678
+** ^If either argument to this option is negative, then that argument is
16791679
** changed to its compile-time default.
16801680
** </dl>
16811681
*/
16821682
#define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */
16831683
#define SQLITE_CONFIG_MULTITHREAD 2 /* nil */
16841684
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -107,11 +107,11 @@
107 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
108 ** [sqlite_version()] and [sqlite_source_id()].
109 */
110 #define SQLITE_VERSION "3.8.1"
111 #define SQLITE_VERSION_NUMBER 3008001
112 #define SQLITE_SOURCE_ID "2013-10-11 13:27:26 03593817ab5abdd4bbaa5e47e2e4745eef025af9"
113
114 /*
115 ** CAPI3REF: Run-Time Library Version Numbers
116 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
117 **
@@ -1615,31 +1615,31 @@
1615 ** supplied by the application must not invoke any SQLite interface.
1616 ** In a multi-threaded application, the application-defined logger
1617 ** function must be threadsafe. </dd>
1618 **
1619 ** [[SQLITE_CONFIG_URI]] <dt>SQLITE_CONFIG_URI
1620 ** <dd> This option takes a single argument of type int. If non-zero, then
1621 ** URI handling is globally enabled. If the parameter is zero, then URI handling
1622 ** is globally disabled. If URI handling is globally enabled, all filenames
1623 ** passed to [sqlite3_open()], [sqlite3_open_v2()], [sqlite3_open16()] or
1624 ** specified as part of [ATTACH] commands are interpreted as URIs, regardless
1625 ** of whether or not the [SQLITE_OPEN_URI] flag is set when the database
1626 ** connection is opened. If it is globally disabled, filenames are
1627 ** only interpreted as URIs if the SQLITE_OPEN_URI flag is set when the
1628 ** database connection is opened. By default, URI handling is globally
1629 ** disabled. The default value may be changed by compiling with the
1630 ** [SQLITE_USE_URI] symbol defined.
1631 **
1632 ** [[SQLITE_CONFIG_COVERING_INDEX_SCAN]] <dt>SQLITE_CONFIG_COVERING_INDEX_SCAN
1633 ** <dd> This option takes a single integer argument which is interpreted as
1634 ** a boolean in order to enable or disable the use of covering indices for
1635 ** full table scans in the query optimizer. The default setting is determined
1636 ** by the [SQLITE_ALLOW_COVERING_INDEX_SCAN] compile-time option, or is "on"
1637 ** if that compile-time option is omitted.
1638 ** The ability to disable the use of covering indices for full table scans
1639 ** is because some incorrectly coded legacy applications might malfunction
1640 ** malfunction when the optimization is enabled. Providing the ability to
1641 ** disable the optimization allows the older, buggy application code to work
1642 ** without change even with newer versions of SQLite.
1643 **
1644 ** [[SQLITE_CONFIG_PCACHE]] [[SQLITE_CONFIG_GETPCACHE]]
1645 ** <dt>SQLITE_CONFIG_PCACHE and SQLITE_CONFIG_GETPCACHE
@@ -1664,20 +1664,20 @@
1664 ** configuration option can be seen in the "test_sqllog.c" source file in
1665 ** the canonical SQLite source tree.</dd>
1666 **
1667 ** [[SQLITE_CONFIG_MMAP_SIZE]]
1668 ** <dt>SQLITE_CONFIG_MMAP_SIZE
1669 ** <dd>SQLITE_CONFIG_MMAP_SIZE takes two 64-bit integer (sqlite3_int64) values
1670 ** that are the default mmap size limit (the default setting for
1671 ** [PRAGMA mmap_size]) and the maximum allowed mmap size limit.
1672 ** The default setting can be overridden by each database connection using
1673 ** either the [PRAGMA mmap_size] command, or by using the
1674 ** [SQLITE_FCNTL_MMAP_SIZE] file control. The maximum allowed mmap size
1675 ** cannot be changed at run-time. Nor may the maximum allowed mmap size
1676 ** exceed the compile-time maximum mmap size set by the
1677 ** [SQLITE_MAX_MMAP_SIZE] compile-time option.
1678 ** If either argument to this option is negative, then that argument is
1679 ** changed to its compile-time default.
1680 ** </dl>
1681 */
1682 #define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */
1683 #define SQLITE_CONFIG_MULTITHREAD 2 /* nil */
1684
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -107,11 +107,11 @@
107 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
108 ** [sqlite_version()] and [sqlite_source_id()].
109 */
110 #define SQLITE_VERSION "3.8.1"
111 #define SQLITE_VERSION_NUMBER 3008001
112 #define SQLITE_SOURCE_ID "2013-10-17 12:57:35 c78be6d786c19073b3a6730dfe3fb1be54f5657a"
113
114 /*
115 ** CAPI3REF: Run-Time Library Version Numbers
116 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
117 **
@@ -1615,31 +1615,31 @@
1615 ** supplied by the application must not invoke any SQLite interface.
1616 ** In a multi-threaded application, the application-defined logger
1617 ** function must be threadsafe. </dd>
1618 **
1619 ** [[SQLITE_CONFIG_URI]] <dt>SQLITE_CONFIG_URI
1620 ** <dd>^(This option takes a single argument of type int. If non-zero, then
1621 ** URI handling is globally enabled. If the parameter is zero, then URI handling
1622 ** is globally disabled.)^ ^If URI handling is globally enabled, all filenames
1623 ** passed to [sqlite3_open()], [sqlite3_open_v2()], [sqlite3_open16()] or
1624 ** specified as part of [ATTACH] commands are interpreted as URIs, regardless
1625 ** of whether or not the [SQLITE_OPEN_URI] flag is set when the database
1626 ** connection is opened. ^If it is globally disabled, filenames are
1627 ** only interpreted as URIs if the SQLITE_OPEN_URI flag is set when the
1628 ** database connection is opened. ^(By default, URI handling is globally
1629 ** disabled. The default value may be changed by compiling with the
1630 ** [SQLITE_USE_URI] symbol defined.)^
1631 **
1632 ** [[SQLITE_CONFIG_COVERING_INDEX_SCAN]] <dt>SQLITE_CONFIG_COVERING_INDEX_SCAN
1633 ** <dd>^This option takes a single integer argument which is interpreted as
1634 ** a boolean in order to enable or disable the use of covering indices for
1635 ** full table scans in the query optimizer. ^The default setting is determined
1636 ** by the [SQLITE_ALLOW_COVERING_INDEX_SCAN] compile-time option, or is "on"
1637 ** if that compile-time option is omitted.
1638 ** The ability to disable the use of covering indices for full table scans
1639 ** is because some incorrectly coded legacy applications might malfunction
1640 ** when the optimization is enabled. Providing the ability to
1641 ** disable the optimization allows the older, buggy application code to work
1642 ** without change even with newer versions of SQLite.
1643 **
1644 ** [[SQLITE_CONFIG_PCACHE]] [[SQLITE_CONFIG_GETPCACHE]]
1645 ** <dt>SQLITE_CONFIG_PCACHE and SQLITE_CONFIG_GETPCACHE
@@ -1664,20 +1664,20 @@
1664 ** configuration option can be seen in the "test_sqllog.c" source file in
1665 ** the canonical SQLite source tree.</dd>
1666 **
1667 ** [[SQLITE_CONFIG_MMAP_SIZE]]
1668 ** <dt>SQLITE_CONFIG_MMAP_SIZE
1669 ** <dd>^SQLITE_CONFIG_MMAP_SIZE takes two 64-bit integer (sqlite3_int64) values
1670 ** that are the default mmap size limit (the default setting for
1671 ** [PRAGMA mmap_size]) and the maximum allowed mmap size limit.
1672 ** ^The default setting can be overridden by each database connection using
1673 ** either the [PRAGMA mmap_size] command, or by using the
1674 ** [SQLITE_FCNTL_MMAP_SIZE] file control. ^(The maximum allowed mmap size
1675 ** cannot be changed at run-time. Nor may the maximum allowed mmap size
1676 ** exceed the compile-time maximum mmap size set by the
1677 ** [SQLITE_MAX_MMAP_SIZE] compile-time option.)^
1678 ** ^If either argument to this option is negative, then that argument is
1679 ** changed to its compile-time default.
1680 ** </dl>
1681 */
1682 #define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */
1683 #define SQLITE_CONFIG_MULTITHREAD 2 /* nil */
1684
+5 -4
--- src/tkt.c
+++ src/tkt.c
@@ -621,15 +621,16 @@
621621
@ <font color="blue">
622622
@ <p>Ticket artifact that would have been submitted:</p>
623623
@ <blockquote><pre>%h(blob_str(&tktchng))</pre></blockquote>
624624
@ <hr /></font>
625625
return TH_OK;
626
- }else if( g.thTrace ){
627
- Th_Trace("submit_ticket {\n<blockquote><pre>\n%h\n</pre></blockquote>\n"
628
- "}<br />\n",
629
- blob_str(&tktchng));
630626
}else{
627
+ if( g.thTrace ){
628
+ Th_Trace("submit_ticket {\n<blockquote><pre>\n%h\n</pre></blockquote>\n"
629
+ "}<br />\n",
630
+ blob_str(&tktchng));
631
+ }
631632
ticket_put(&tktchng, zUuid,
632633
(g.perm.ModTkt==0 && db_get_boolean("modreq-tkt",0)==1));
633634
}
634635
return ticket_change();
635636
}
636637
--- src/tkt.c
+++ src/tkt.c
@@ -621,15 +621,16 @@
621 @ <font color="blue">
622 @ <p>Ticket artifact that would have been submitted:</p>
623 @ <blockquote><pre>%h(blob_str(&tktchng))</pre></blockquote>
624 @ <hr /></font>
625 return TH_OK;
626 }else if( g.thTrace ){
627 Th_Trace("submit_ticket {\n<blockquote><pre>\n%h\n</pre></blockquote>\n"
628 "}<br />\n",
629 blob_str(&tktchng));
630 }else{
 
 
 
 
 
631 ticket_put(&tktchng, zUuid,
632 (g.perm.ModTkt==0 && db_get_boolean("modreq-tkt",0)==1));
633 }
634 return ticket_change();
635 }
636
--- src/tkt.c
+++ src/tkt.c
@@ -621,15 +621,16 @@
621 @ <font color="blue">
622 @ <p>Ticket artifact that would have been submitted:</p>
623 @ <blockquote><pre>%h(blob_str(&tktchng))</pre></blockquote>
624 @ <hr /></font>
625 return TH_OK;
 
 
 
 
626 }else{
627 if( g.thTrace ){
628 Th_Trace("submit_ticket {\n<blockquote><pre>\n%h\n</pre></blockquote>\n"
629 "}<br />\n",
630 blob_str(&tktchng));
631 }
632 ticket_put(&tktchng, zUuid,
633 (g.perm.ModTkt==0 && db_get_boolean("modreq-tkt",0)==1));
634 }
635 return ticket_change();
636 }
637
+38 -28
--- win/Makefile.msc
+++ win/Makefile.msc
@@ -11,10 +11,13 @@
1111
SRCDIR = $B\src
1212
OBJDIR = .
1313
OX = .
1414
O = .obj
1515
E = .exe
16
+
17
+# Uncomment to enable debug symbols
18
+# DEBUG = 1
1619
1720
# Uncomment to enable JSON API
1821
# FOSSIL_ENABLE_JSON = 1
1922
2023
# Uncomment to enable SSL support
@@ -25,37 +28,44 @@
2528
SSLLIBDIR = $(B)\compat\openssl-1.0.1e\out32
2629
SSLLIB = ssleay32.lib libeay32.lib user32.lib gdi32.lib
2730
!endif
2831
2932
# zlib options
30
-ZINCDIR = $(B)\compat\zlib
31
-ZLIBDIR = $(B)\compat\zlib
32
-ZLIB = zlib.lib
33
-
34
-INCL = -I. -I$(SRCDIR) -I$B\win\include -I$(ZINCDIR)
35
-
36
-!ifdef FOSSIL_ENABLE_SSL
37
-INCL = $(INCL) -I$(SSLINCDIR)
38
-!endif
39
-
40
-CFLAGS = -nologo -MT -O2
41
-BCC = $(CC) $(CFLAGS)
42
-TCC = $(CC) -c $(CFLAGS) $(MSCDEF) $(INCL)
43
-RCC = rc -D_WIN32 -D_MSC_VER $(MSCDEF) $(INCL)
44
-LIBS = $(ZLIB) ws2_32.lib advapi32.lib
45
-LIBDIR = -LIBPATH:$(ZLIBDIR)
46
-
47
-!ifdef FOSSIL_ENABLE_JSON
48
-TCC = $(TCC) -DFOSSIL_ENABLE_JSON=1
49
-RCC = $(RCC) -DFOSSIL_ENABLE_JSON=1
50
-!endif
51
-
52
-!ifdef FOSSIL_ENABLE_SSL
53
-TCC = $(TCC) -DFOSSIL_ENABLE_SSL=1
54
-RCC = $(RCC) -DFOSSIL_ENABLE_SSL=1
55
-LIBS = $(LIBS) $(SSLLIB)
56
-LIBDIR = $(LIBDIR) -LIBPATH:$(SSLLIBDIR)
33
+ZINCDIR = $(B)\compat\zlib
34
+ZLIBDIR = $(B)\compat\zlib
35
+ZLIB = zlib.lib
36
+
37
+INCL = -I. -I$(SRCDIR) -I$B\win\include -I$(ZINCDIR)
38
+
39
+!ifdef FOSSIL_ENABLE_SSL
40
+INCL = $(INCL) -I$(SSLINCDIR)
41
+!endif
42
+
43
+CFLAGS = -nologo -MT -O2
44
+LDFLAGS = /NODEFAULTLIB:msvcrt
45
+
46
+!ifdef DEBUG
47
+CFLAGS = $(CFLAGS) -Zi
48
+LDFLAGS = $(LDFLAGS) /DEBUG
49
+!endif
50
+
51
+BCC = $(CC) $(CFLAGS)
52
+TCC = $(CC) -c $(CFLAGS) $(MSCDEF) $(INCL)
53
+RCC = rc -D_WIN32 -D_MSC_VER $(MSCDEF) $(INCL)
54
+LIBS = $(ZLIB) ws2_32.lib advapi32.lib
55
+LIBDIR = -LIBPATH:$(ZLIBDIR)
56
+
57
+!ifdef FOSSIL_ENABLE_JSON
58
+TCC = $(TCC) -DFOSSIL_ENABLE_JSON=1
59
+RCC = $(RCC) -DFOSSIL_ENABLE_JSON=1
60
+!endif
61
+
62
+!ifdef FOSSIL_ENABLE_SSL
63
+TCC = $(TCC) -DFOSSIL_ENABLE_SSL=1
64
+RCC = $(RCC) -DFOSSIL_ENABLE_SSL=1
65
+LIBS = $(LIBS) $(SSLLIB)
66
+LIBDIR = $(LIBDIR) -LIBPATH:$(SSLLIBDIR)
5767
!endif
5868
5969
SQLITE_OPTIONS = /DSQLITE_OMIT_LOAD_EXTENSION=1 \
6070
/DSQLITE_THREADSAFE=0 \
6171
/DSQLITE_DEFAULT_FILE_FORMAT=4 \
@@ -294,11 +304,11 @@
294304
@echo Building zlib from "$(ZLIBDIR)"...
295305
@pushd "$(ZLIBDIR)" && nmake /f win32\Makefile.msc $(ZLIB) && popd
296306
297307
$(APPNAME) : translate$E mkindex$E headers $(OBJ) $(OX)\linkopts zlib
298308
cd $(OX)
299
- link /NODEFAULTLIB:msvcrt -OUT:$@ $(LIBDIR) Wsetargv.obj fossil.res @linkopts
309
+ link $(LDFLAGS) -OUT:$@ $(LIBDIR) Wsetargv.obj fossil.res @linkopts
300310
301311
$(OX)\linkopts: $B\win\Makefile.msc
302312
echo $(OX)\add.obj > $@
303313
echo $(OX)\allrepo.obj >> $@
304314
echo $(OX)\attach.obj >> $@
305315
--- win/Makefile.msc
+++ win/Makefile.msc
@@ -11,10 +11,13 @@
11 SRCDIR = $B\src
12 OBJDIR = .
13 OX = .
14 O = .obj
15 E = .exe
 
 
 
16
17 # Uncomment to enable JSON API
18 # FOSSIL_ENABLE_JSON = 1
19
20 # Uncomment to enable SSL support
@@ -25,37 +28,44 @@
25 SSLLIBDIR = $(B)\compat\openssl-1.0.1e\out32
26 SSLLIB = ssleay32.lib libeay32.lib user32.lib gdi32.lib
27 !endif
28
29 # zlib options
30 ZINCDIR = $(B)\compat\zlib
31 ZLIBDIR = $(B)\compat\zlib
32 ZLIB = zlib.lib
33
34 INCL = -I. -I$(SRCDIR) -I$B\win\include -I$(ZINCDIR)
35
36 !ifdef FOSSIL_ENABLE_SSL
37 INCL = $(INCL) -I$(SSLINCDIR)
38 !endif
39
40 CFLAGS = -nologo -MT -O2
41 BCC = $(CC) $(CFLAGS)
42 TCC = $(CC) -c $(CFLAGS) $(MSCDEF) $(INCL)
43 RCC = rc -D_WIN32 -D_MSC_VER $(MSCDEF) $(INCL)
44 LIBS = $(ZLIB) ws2_32.lib advapi32.lib
45 LIBDIR = -LIBPATH:$(ZLIBDIR)
46
47 !ifdef FOSSIL_ENABLE_JSON
48 TCC = $(TCC) -DFOSSIL_ENABLE_JSON=1
49 RCC = $(RCC) -DFOSSIL_ENABLE_JSON=1
50 !endif
51
52 !ifdef FOSSIL_ENABLE_SSL
53 TCC = $(TCC) -DFOSSIL_ENABLE_SSL=1
54 RCC = $(RCC) -DFOSSIL_ENABLE_SSL=1
55 LIBS = $(LIBS) $(SSLLIB)
56 LIBDIR = $(LIBDIR) -LIBPATH:$(SSLLIBDIR)
 
 
 
 
 
 
 
57 !endif
58
59 SQLITE_OPTIONS = /DSQLITE_OMIT_LOAD_EXTENSION=1 \
60 /DSQLITE_THREADSAFE=0 \
61 /DSQLITE_DEFAULT_FILE_FORMAT=4 \
@@ -294,11 +304,11 @@
294 @echo Building zlib from "$(ZLIBDIR)"...
295 @pushd "$(ZLIBDIR)" && nmake /f win32\Makefile.msc $(ZLIB) && popd
296
297 $(APPNAME) : translate$E mkindex$E headers $(OBJ) $(OX)\linkopts zlib
298 cd $(OX)
299 link /NODEFAULTLIB:msvcrt -OUT:$@ $(LIBDIR) Wsetargv.obj fossil.res @linkopts
300
301 $(OX)\linkopts: $B\win\Makefile.msc
302 echo $(OX)\add.obj > $@
303 echo $(OX)\allrepo.obj >> $@
304 echo $(OX)\attach.obj >> $@
305
--- win/Makefile.msc
+++ win/Makefile.msc
@@ -11,10 +11,13 @@
11 SRCDIR = $B\src
12 OBJDIR = .
13 OX = .
14 O = .obj
15 E = .exe
16
17 # Uncomment to enable debug symbols
18 # DEBUG = 1
19
20 # Uncomment to enable JSON API
21 # FOSSIL_ENABLE_JSON = 1
22
23 # Uncomment to enable SSL support
@@ -25,37 +28,44 @@
28 SSLLIBDIR = $(B)\compat\openssl-1.0.1e\out32
29 SSLLIB = ssleay32.lib libeay32.lib user32.lib gdi32.lib
30 !endif
31
32 # zlib options
33 ZINCDIR = $(B)\compat\zlib
34 ZLIBDIR = $(B)\compat\zlib
35 ZLIB = zlib.lib
36
37 INCL = -I. -I$(SRCDIR) -I$B\win\include -I$(ZINCDIR)
38
39 !ifdef FOSSIL_ENABLE_SSL
40 INCL = $(INCL) -I$(SSLINCDIR)
41 !endif
42
43 CFLAGS = -nologo -MT -O2
44 LDFLAGS = /NODEFAULTLIB:msvcrt
45
46 !ifdef DEBUG
47 CFLAGS = $(CFLAGS) -Zi
48 LDFLAGS = $(LDFLAGS) /DEBUG
49 !endif
50
51 BCC = $(CC) $(CFLAGS)
52 TCC = $(CC) -c $(CFLAGS) $(MSCDEF) $(INCL)
53 RCC = rc -D_WIN32 -D_MSC_VER $(MSCDEF) $(INCL)
54 LIBS = $(ZLIB) ws2_32.lib advapi32.lib
55 LIBDIR = -LIBPATH:$(ZLIBDIR)
56
57 !ifdef FOSSIL_ENABLE_JSON
58 TCC = $(TCC) -DFOSSIL_ENABLE_JSON=1
59 RCC = $(RCC) -DFOSSIL_ENABLE_JSON=1
60 !endif
61
62 !ifdef FOSSIL_ENABLE_SSL
63 TCC = $(TCC) -DFOSSIL_ENABLE_SSL=1
64 RCC = $(RCC) -DFOSSIL_ENABLE_SSL=1
65 LIBS = $(LIBS) $(SSLLIB)
66 LIBDIR = $(LIBDIR) -LIBPATH:$(SSLLIBDIR)
67 !endif
68
69 SQLITE_OPTIONS = /DSQLITE_OMIT_LOAD_EXTENSION=1 \
70 /DSQLITE_THREADSAFE=0 \
71 /DSQLITE_DEFAULT_FILE_FORMAT=4 \
@@ -294,11 +304,11 @@
304 @echo Building zlib from "$(ZLIBDIR)"...
305 @pushd "$(ZLIBDIR)" && nmake /f win32\Makefile.msc $(ZLIB) && popd
306
307 $(APPNAME) : translate$E mkindex$E headers $(OBJ) $(OX)\linkopts zlib
308 cd $(OX)
309 link $(LDFLAGS) -OUT:$@ $(LIBDIR) Wsetargv.obj fossil.res @linkopts
310
311 $(OX)\linkopts: $B\win\Makefile.msc
312 echo $(OX)\add.obj > $@
313 echo $(OX)\allrepo.obj >> $@
314 echo $(OX)\attach.obj >> $@
315
+2 -1
--- www/build.wiki
+++ www/build.wiki
@@ -136,7 +136,8 @@
136136
generated by configure to add the following lines:
137137
<blockquote><pre>
138138
TCC += -DSQLITE_WITHOUT_ZONEMALLOC
139139
TCC += -DWITHOUT_ICONV
140140
TCC += -Dsocketlen_t=int
141
- </pre></blockquote>
141
+ TCC += -DSQLITE_MAX_MMAP_SIZE=0
142
+</pre></blockquote>
142143
</ul>
143144
--- www/build.wiki
+++ www/build.wiki
@@ -136,7 +136,8 @@
136 generated by configure to add the following lines:
137 <blockquote><pre>
138 TCC += -DSQLITE_WITHOUT_ZONEMALLOC
139 TCC += -DWITHOUT_ICONV
140 TCC += -Dsocketlen_t=int
141 </pre></blockquote>
 
142 </ul>
143
--- www/build.wiki
+++ www/build.wiki
@@ -136,7 +136,8 @@
136 generated by configure to add the following lines:
137 <blockquote><pre>
138 TCC += -DSQLITE_WITHOUT_ZONEMALLOC
139 TCC += -DWITHOUT_ICONV
140 TCC += -Dsocketlen_t=int
141 TCC += -DSQLITE_MAX_MMAP_SIZE=0
142 </pre></blockquote>
143 </ul>
144
+18 -1
--- www/changes.wiki
+++ www/changes.wiki
@@ -1,10 +1,27 @@
11
<title>Change Log</title>
22
33
<h2>Changes For Version 1.28 (as yet unreleased)</h2>
44
* Enhance [/help?cmd=/reports | /reports] to support event type filtering.
5
-
5
+ * When cloning a repository, the user name passed via the URL (if any)
6
+ is now used as the default local admin user's name.
7
+ * Enhance the SSH transport mechanism so that it runs a single instance of
8
+ the "fossil" executable on the remote side, obviating the need for a shell
9
+ on the remote side. Some users may need to add the "?fossil=/path/to/fossil"
10
+ query parameter to "ssh:" URIs if their fossil binary is not in a standard
11
+ place.
12
+ * Add the "[/help?cmd=blame | fossil blame]" command that works just like
13
+ "fossil annotate" but uses a different output format that includes the
14
+ user who made each changes and omits line numbers.
15
+ * Add the "Tarball and ZIP-archive Prefix" configuration parameter under
16
+ Admin/Configuration.
17
+ * Fix CGI processing so that it works on web servers that do not
18
+ supply REQUEST_URI.
19
+ * Add options --dirsonly, --emptydirs, and --allckouts to the
20
+ "[/help?cmd=clean | fossil clean]" command.
21
+ * Ten-fold performance improvement in large "fossil blame" or
22
+ "fossil annotate" commands.
623
724
<h2>Changes For Version 1.27 (2013-09-11)</h2>
825
* Enhance the [/help?cmd=changes | fossil changes],
926
[/help?cmd=clean | fossil clean], [/help?cmd=extras | fossil extras],
1027
[/help?cmd=ls | fossil ls] and [/help?cmd=status | fossil status] commands
1128
--- www/changes.wiki
+++ www/changes.wiki
@@ -1,10 +1,27 @@
1 <title>Change Log</title>
2
3 <h2>Changes For Version 1.28 (as yet unreleased)</h2>
4 * Enhance [/help?cmd=/reports | /reports] to support event type filtering.
5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
7 <h2>Changes For Version 1.27 (2013-09-11)</h2>
8 * Enhance the [/help?cmd=changes | fossil changes],
9 [/help?cmd=clean | fossil clean], [/help?cmd=extras | fossil extras],
10 [/help?cmd=ls | fossil ls] and [/help?cmd=status | fossil status] commands
11
--- www/changes.wiki
+++ www/changes.wiki
@@ -1,10 +1,27 @@
1 <title>Change Log</title>
2
3 <h2>Changes For Version 1.28 (as yet unreleased)</h2>
4 * Enhance [/help?cmd=/reports | /reports] to support event type filtering.
5 * When cloning a repository, the user name passed via the URL (if any)
6 is now used as the default local admin user's name.
7 * Enhance the SSH transport mechanism so that it runs a single instance of
8 the "fossil" executable on the remote side, obviating the need for a shell
9 on the remote side. Some users may need to add the "?fossil=/path/to/fossil"
10 query parameter to "ssh:" URIs if their fossil binary is not in a standard
11 place.
12 * Add the "[/help?cmd=blame | fossil blame]" command that works just like
13 "fossil annotate" but uses a different output format that includes the
14 user who made each changes and omits line numbers.
15 * Add the "Tarball and ZIP-archive Prefix" configuration parameter under
16 Admin/Configuration.
17 * Fix CGI processing so that it works on web servers that do not
18 supply REQUEST_URI.
19 * Add options --dirsonly, --emptydirs, and --allckouts to the
20 "[/help?cmd=clean | fossil clean]" command.
21 * Ten-fold performance improvement in large "fossil blame" or
22 "fossil annotate" commands.
23
24 <h2>Changes For Version 1.27 (2013-09-11)</h2>
25 * Enhance the [/help?cmd=changes | fossil changes],
26 [/help?cmd=clean | fossil clean], [/help?cmd=extras | fossil extras],
27 [/help?cmd=ls | fossil ls] and [/help?cmd=status | fossil status] commands
28
--- www/quickstart.wiki
+++ www/quickstart.wiki
@@ -55,11 +55,11 @@
5555
<b>fossil clone</b> <i>URL repository-filename</i>
5656
</blockquote>
5757
5858
<p>The <i>URL</i> above is the http URL for the fossil repository
5959
you want to clone, and it may include a "user:password" part, e.g.
60
- <tt>http://drh:[email protected]/fossil</tt>. You can
60
+ <tt>http://user:[email protected]/fossil</tt>. You can
6161
call the new repository anything you want - there are no naming
6262
restrictions. As an example, you can clone the fossil repository
6363
this way:</p>
6464
6565
<blockquote>
6666
--- www/quickstart.wiki
+++ www/quickstart.wiki
@@ -55,11 +55,11 @@
55 <b>fossil clone</b> <i>URL repository-filename</i>
56 </blockquote>
57
58 <p>The <i>URL</i> above is the http URL for the fossil repository
59 you want to clone, and it may include a "user:password" part, e.g.
60 <tt>http://drh:[email protected]/fossil</tt>. You can
61 call the new repository anything you want - there are no naming
62 restrictions. As an example, you can clone the fossil repository
63 this way:</p>
64
65 <blockquote>
66
--- www/quickstart.wiki
+++ www/quickstart.wiki
@@ -55,11 +55,11 @@
55 <b>fossil clone</b> <i>URL repository-filename</i>
56 </blockquote>
57
58 <p>The <i>URL</i> above is the http URL for the fossil repository
59 you want to clone, and it may include a "user:password" part, e.g.
60 <tt>http://user:[email protected]/fossil</tt>. You can
61 call the new repository anything you want - there are no naming
62 restrictions. As an example, you can clone the fossil repository
63 this way:</p>
64
65 <blockquote>
66

Keyboard Shortcuts

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