Fossil SCM

Bring in latest fixes and features.

andybradford 2013-09-07 21:57 ssh-transport-changes merge
Commit e880c032e9c73db93918c2e5d55e308cf358f5e7
+14
--- src/cgi.c
+++ src/cgi.c
@@ -40,10 +40,14 @@
4040
#include <time.h>
4141
#include <stdio.h>
4242
#include <stdlib.h>
4343
#include <unistd.h>
4444
#include "cgi.h"
45
+#ifdef __CYGWIN__
46
+ __declspec(dllimport) extern __stdcall int ShellExecuteW(void *, void *,
47
+ void *, void *, void *, int);
48
+#endif
4549
4650
#if INTERFACE
4751
/*
4852
** Shortcuts for cgi_parameter. P("x") returns the value of query parameter
4953
** or cookie "x", or NULL if there is no such parameter or cookie. PD("x","y")
@@ -1667,10 +1671,20 @@
16671671
(flags & HTTP_SERVER_SCGI)!=0?"SCGI":"HTTP", iPort);
16681672
fflush(stdout);
16691673
}
16701674
if( zBrowser ){
16711675
zBrowser = mprintf(zBrowser, iPort);
1676
+#if defined(__CYGWIN__)
1677
+ /* On Cygwin, we can do better than "echo" */
1678
+ if( memcmp(zBrowser, "echo ", 5)==0 ){
1679
+ wchar_t *wUrl = fossil_utf8_to_unicode(zBrowser+5);
1680
+ wUrl[wcslen(wUrl)-2] = 0; /* Strip terminating " &" */
1681
+ if( ShellExecuteW(0, L"open", wUrl, 0, 0, 1)<33 ){
1682
+ fossil_warning("cannot start browser\n");
1683
+ }
1684
+ }else
1685
+#endif
16721686
if( system(zBrowser)<0 ){
16731687
fossil_warning("cannot start browser: %s\n", zBrowser);
16741688
}
16751689
}
16761690
while( 1 ){
16771691
--- src/cgi.c
+++ src/cgi.c
@@ -40,10 +40,14 @@
40 #include <time.h>
41 #include <stdio.h>
42 #include <stdlib.h>
43 #include <unistd.h>
44 #include "cgi.h"
 
 
 
 
45
46 #if INTERFACE
47 /*
48 ** Shortcuts for cgi_parameter. P("x") returns the value of query parameter
49 ** or cookie "x", or NULL if there is no such parameter or cookie. PD("x","y")
@@ -1667,10 +1671,20 @@
1667 (flags & HTTP_SERVER_SCGI)!=0?"SCGI":"HTTP", iPort);
1668 fflush(stdout);
1669 }
1670 if( zBrowser ){
1671 zBrowser = mprintf(zBrowser, iPort);
 
 
 
 
 
 
 
 
 
 
1672 if( system(zBrowser)<0 ){
1673 fossil_warning("cannot start browser: %s\n", zBrowser);
1674 }
1675 }
1676 while( 1 ){
1677
--- src/cgi.c
+++ src/cgi.c
@@ -40,10 +40,14 @@
40 #include <time.h>
41 #include <stdio.h>
42 #include <stdlib.h>
43 #include <unistd.h>
44 #include "cgi.h"
45 #ifdef __CYGWIN__
46 __declspec(dllimport) extern __stdcall int ShellExecuteW(void *, void *,
47 void *, void *, void *, int);
48 #endif
49
50 #if INTERFACE
51 /*
52 ** Shortcuts for cgi_parameter. P("x") returns the value of query parameter
53 ** or cookie "x", or NULL if there is no such parameter or cookie. PD("x","y")
@@ -1667,10 +1671,20 @@
1671 (flags & HTTP_SERVER_SCGI)!=0?"SCGI":"HTTP", iPort);
1672 fflush(stdout);
1673 }
1674 if( zBrowser ){
1675 zBrowser = mprintf(zBrowser, iPort);
1676 #if defined(__CYGWIN__)
1677 /* On Cygwin, we can do better than "echo" */
1678 if( memcmp(zBrowser, "echo ", 5)==0 ){
1679 wchar_t *wUrl = fossil_utf8_to_unicode(zBrowser+5);
1680 wUrl[wcslen(wUrl)-2] = 0; /* Strip terminating " &" */
1681 if( ShellExecuteW(0, L"open", wUrl, 0, 0, 1)<33 ){
1682 fossil_warning("cannot start browser\n");
1683 }
1684 }else
1685 #endif
1686 if( system(zBrowser)<0 ){
1687 fossil_warning("cannot start browser: %s\n", zBrowser);
1688 }
1689 }
1690 while( 1 ){
1691
+14
--- src/cgi.c
+++ src/cgi.c
@@ -40,10 +40,14 @@
4040
#include <time.h>
4141
#include <stdio.h>
4242
#include <stdlib.h>
4343
#include <unistd.h>
4444
#include "cgi.h"
45
+#ifdef __CYGWIN__
46
+ __declspec(dllimport) extern __stdcall int ShellExecuteW(void *, void *,
47
+ void *, void *, void *, int);
48
+#endif
4549
4650
#if INTERFACE
4751
/*
4852
** Shortcuts for cgi_parameter. P("x") returns the value of query parameter
4953
** or cookie "x", or NULL if there is no such parameter or cookie. PD("x","y")
@@ -1667,10 +1671,20 @@
16671671
(flags & HTTP_SERVER_SCGI)!=0?"SCGI":"HTTP", iPort);
16681672
fflush(stdout);
16691673
}
16701674
if( zBrowser ){
16711675
zBrowser = mprintf(zBrowser, iPort);
1676
+#if defined(__CYGWIN__)
1677
+ /* On Cygwin, we can do better than "echo" */
1678
+ if( memcmp(zBrowser, "echo ", 5)==0 ){
1679
+ wchar_t *wUrl = fossil_utf8_to_unicode(zBrowser+5);
1680
+ wUrl[wcslen(wUrl)-2] = 0; /* Strip terminating " &" */
1681
+ if( ShellExecuteW(0, L"open", wUrl, 0, 0, 1)<33 ){
1682
+ fossil_warning("cannot start browser\n");
1683
+ }
1684
+ }else
1685
+#endif
16721686
if( system(zBrowser)<0 ){
16731687
fossil_warning("cannot start browser: %s\n", zBrowser);
16741688
}
16751689
}
16761690
while( 1 ){
16771691
--- src/cgi.c
+++ src/cgi.c
@@ -40,10 +40,14 @@
40 #include <time.h>
41 #include <stdio.h>
42 #include <stdlib.h>
43 #include <unistd.h>
44 #include "cgi.h"
 
 
 
 
45
46 #if INTERFACE
47 /*
48 ** Shortcuts for cgi_parameter. P("x") returns the value of query parameter
49 ** or cookie "x", or NULL if there is no such parameter or cookie. PD("x","y")
@@ -1667,10 +1671,20 @@
1667 (flags & HTTP_SERVER_SCGI)!=0?"SCGI":"HTTP", iPort);
1668 fflush(stdout);
1669 }
1670 if( zBrowser ){
1671 zBrowser = mprintf(zBrowser, iPort);
 
 
 
 
 
 
 
 
 
 
1672 if( system(zBrowser)<0 ){
1673 fossil_warning("cannot start browser: %s\n", zBrowser);
1674 }
1675 }
1676 while( 1 ){
1677
--- src/cgi.c
+++ src/cgi.c
@@ -40,10 +40,14 @@
40 #include <time.h>
41 #include <stdio.h>
42 #include <stdlib.h>
43 #include <unistd.h>
44 #include "cgi.h"
45 #ifdef __CYGWIN__
46 __declspec(dllimport) extern __stdcall int ShellExecuteW(void *, void *,
47 void *, void *, void *, int);
48 #endif
49
50 #if INTERFACE
51 /*
52 ** Shortcuts for cgi_parameter. P("x") returns the value of query parameter
53 ** or cookie "x", or NULL if there is no such parameter or cookie. PD("x","y")
@@ -1667,10 +1671,20 @@
1671 (flags & HTTP_SERVER_SCGI)!=0?"SCGI":"HTTP", iPort);
1672 fflush(stdout);
1673 }
1674 if( zBrowser ){
1675 zBrowser = mprintf(zBrowser, iPort);
1676 #if defined(__CYGWIN__)
1677 /* On Cygwin, we can do better than "echo" */
1678 if( memcmp(zBrowser, "echo ", 5)==0 ){
1679 wchar_t *wUrl = fossil_utf8_to_unicode(zBrowser+5);
1680 wUrl[wcslen(wUrl)-2] = 0; /* Strip terminating " &" */
1681 if( ShellExecuteW(0, L"open", wUrl, 0, 0, 1)<33 ){
1682 fossil_warning("cannot start browser\n");
1683 }
1684 }else
1685 #endif
1686 if( system(zBrowser)<0 ){
1687 fossil_warning("cannot start browser: %s\n", zBrowser);
1688 }
1689 }
1690 while( 1 ){
1691
+7 -1
--- src/checkin.c
+++ src/checkin.c
@@ -714,11 +714,11 @@
714714
char *zInit,
715715
CheckinInfo *p,
716716
int parent_rid
717717
){
718718
Blob prompt;
719
-#ifdef _WIN32
719
+#if defined(_WIN32) || defined(__CYGWIN__)
720720
int bomSize;
721721
const unsigned char *bom = get_utf8_bom(&bomSize);
722722
blob_init(&prompt, (const char *) bom, bomSize);
723723
if( zInit && zInit[0]) {
724724
blob_append(&prompt, zInit, -1);
@@ -880,10 +880,11 @@
880880
*/
881881
struct CheckinInfo {
882882
Blob *pComment; /* Check-in comment text */
883883
const char *zMimetype; /* Mimetype of check-in command. May be NULL */
884884
int verifyDate; /* Verify that child is younger */
885
+ int closeFlag; /* Close the branch being committed */
885886
Blob *pCksum; /* Repository checksum. May be 0 */
886887
const char *zDateOvrd; /* Date override. If 0 then use 'now' */
887888
const char *zUserOvrd; /* User override. If 0 then use g.zLogin */
888889
const char *zBranch; /* Branch name. May be 0 */
889890
const char *zColor; /* One-time background color. May be 0 */
@@ -1059,10 +1060,13 @@
10591060
}
10601061
if( zColor && zColor[0] ){
10611062
/* One-time background color */
10621063
blob_appendf(pOut, "T +bgcolor * %F\n", zColor);
10631064
}
1065
+ if( p->closeFlag ){
1066
+ blob_appendf(pOut, "T +closed *\n");
1067
+ }
10641068
db_prepare(&q, "SELECT uuid,merge FROM vmerge JOIN blob ON merge=rid"
10651069
" WHERE id=-4 ORDER BY 1");
10661070
while( db_step(&q)==SQLITE_ROW ){
10671071
const char *zIntegrateUuid = db_column_text(&q, 0);
10681072
int rid = db_column_int(&q, 1);
@@ -1300,10 +1304,11 @@
13001304
** --allow-older allow a commit older than its ancestor
13011305
** --baseline use a baseline manifest in the commit process
13021306
** --bgcolor COLOR apply COLOR to this one check-in only
13031307
** --branch NEW-BRANCH-NAME check in to this new branch
13041308
** --branchcolor COLOR apply given COLOR to the branch
1309
+** --close close the branch being committed
13051310
** --delta use a delta manifest in the commit process
13061311
** -m|--comment COMMENT-TEXT use COMMENT-TEXT as commit comment
13071312
** -M|--message-file FILE read the commit comment from given file
13081313
** --mimetype MIMETYPE mimetype of check-in comment
13091314
** -n|--dry-run If given, display instead of run actions
@@ -1372,10 +1377,11 @@
13721377
allowOlder = find_option("allow-older",0,0)!=0;
13731378
noWarningFlag = find_option("no-warnings", 0, 0)!=0;
13741379
sCiInfo.zBranch = find_option("branch","b",1);
13751380
sCiInfo.zColor = find_option("bgcolor",0,1);
13761381
sCiInfo.zBrClr = find_option("branchcolor",0,1);
1382
+ sCiInfo.closeFlag = find_option("close",0,0)!=0;
13771383
sCiInfo.zMimetype = find_option("mimetype",0,1);
13781384
while( (zTag = find_option("tag",0,1))!=0 ){
13791385
if( zTag[0]==0 ) continue;
13801386
sCiInfo.azTag = fossil_realloc((void*)sCiInfo.azTag, sizeof(char*)*(nTag+2));
13811387
sCiInfo.azTag[nTag++] = zTag;
13821388
--- src/checkin.c
+++ src/checkin.c
@@ -714,11 +714,11 @@
714 char *zInit,
715 CheckinInfo *p,
716 int parent_rid
717 ){
718 Blob prompt;
719 #ifdef _WIN32
720 int bomSize;
721 const unsigned char *bom = get_utf8_bom(&bomSize);
722 blob_init(&prompt, (const char *) bom, bomSize);
723 if( zInit && zInit[0]) {
724 blob_append(&prompt, zInit, -1);
@@ -880,10 +880,11 @@
880 */
881 struct CheckinInfo {
882 Blob *pComment; /* Check-in comment text */
883 const char *zMimetype; /* Mimetype of check-in command. May be NULL */
884 int verifyDate; /* Verify that child is younger */
 
885 Blob *pCksum; /* Repository checksum. May be 0 */
886 const char *zDateOvrd; /* Date override. If 0 then use 'now' */
887 const char *zUserOvrd; /* User override. If 0 then use g.zLogin */
888 const char *zBranch; /* Branch name. May be 0 */
889 const char *zColor; /* One-time background color. May be 0 */
@@ -1059,10 +1060,13 @@
1059 }
1060 if( zColor && zColor[0] ){
1061 /* One-time background color */
1062 blob_appendf(pOut, "T +bgcolor * %F\n", zColor);
1063 }
 
 
 
1064 db_prepare(&q, "SELECT uuid,merge FROM vmerge JOIN blob ON merge=rid"
1065 " WHERE id=-4 ORDER BY 1");
1066 while( db_step(&q)==SQLITE_ROW ){
1067 const char *zIntegrateUuid = db_column_text(&q, 0);
1068 int rid = db_column_int(&q, 1);
@@ -1300,10 +1304,11 @@
1300 ** --allow-older allow a commit older than its ancestor
1301 ** --baseline use a baseline manifest in the commit process
1302 ** --bgcolor COLOR apply COLOR to this one check-in only
1303 ** --branch NEW-BRANCH-NAME check in to this new branch
1304 ** --branchcolor COLOR apply given COLOR to the branch
 
1305 ** --delta use a delta manifest in the commit process
1306 ** -m|--comment COMMENT-TEXT use COMMENT-TEXT as commit comment
1307 ** -M|--message-file FILE read the commit comment from given file
1308 ** --mimetype MIMETYPE mimetype of check-in comment
1309 ** -n|--dry-run If given, display instead of run actions
@@ -1372,10 +1377,11 @@
1372 allowOlder = find_option("allow-older",0,0)!=0;
1373 noWarningFlag = find_option("no-warnings", 0, 0)!=0;
1374 sCiInfo.zBranch = find_option("branch","b",1);
1375 sCiInfo.zColor = find_option("bgcolor",0,1);
1376 sCiInfo.zBrClr = find_option("branchcolor",0,1);
 
1377 sCiInfo.zMimetype = find_option("mimetype",0,1);
1378 while( (zTag = find_option("tag",0,1))!=0 ){
1379 if( zTag[0]==0 ) continue;
1380 sCiInfo.azTag = fossil_realloc((void*)sCiInfo.azTag, sizeof(char*)*(nTag+2));
1381 sCiInfo.azTag[nTag++] = zTag;
1382
--- src/checkin.c
+++ src/checkin.c
@@ -714,11 +714,11 @@
714 char *zInit,
715 CheckinInfo *p,
716 int parent_rid
717 ){
718 Blob prompt;
719 #if defined(_WIN32) || defined(__CYGWIN__)
720 int bomSize;
721 const unsigned char *bom = get_utf8_bom(&bomSize);
722 blob_init(&prompt, (const char *) bom, bomSize);
723 if( zInit && zInit[0]) {
724 blob_append(&prompt, zInit, -1);
@@ -880,10 +880,11 @@
880 */
881 struct CheckinInfo {
882 Blob *pComment; /* Check-in comment text */
883 const char *zMimetype; /* Mimetype of check-in command. May be NULL */
884 int verifyDate; /* Verify that child is younger */
885 int closeFlag; /* Close the branch being committed */
886 Blob *pCksum; /* Repository checksum. May be 0 */
887 const char *zDateOvrd; /* Date override. If 0 then use 'now' */
888 const char *zUserOvrd; /* User override. If 0 then use g.zLogin */
889 const char *zBranch; /* Branch name. May be 0 */
890 const char *zColor; /* One-time background color. May be 0 */
@@ -1059,10 +1060,13 @@
1060 }
1061 if( zColor && zColor[0] ){
1062 /* One-time background color */
1063 blob_appendf(pOut, "T +bgcolor * %F\n", zColor);
1064 }
1065 if( p->closeFlag ){
1066 blob_appendf(pOut, "T +closed *\n");
1067 }
1068 db_prepare(&q, "SELECT uuid,merge FROM vmerge JOIN blob ON merge=rid"
1069 " WHERE id=-4 ORDER BY 1");
1070 while( db_step(&q)==SQLITE_ROW ){
1071 const char *zIntegrateUuid = db_column_text(&q, 0);
1072 int rid = db_column_int(&q, 1);
@@ -1300,10 +1304,11 @@
1304 ** --allow-older allow a commit older than its ancestor
1305 ** --baseline use a baseline manifest in the commit process
1306 ** --bgcolor COLOR apply COLOR to this one check-in only
1307 ** --branch NEW-BRANCH-NAME check in to this new branch
1308 ** --branchcolor COLOR apply given COLOR to the branch
1309 ** --close close the branch being committed
1310 ** --delta use a delta manifest in the commit process
1311 ** -m|--comment COMMENT-TEXT use COMMENT-TEXT as commit comment
1312 ** -M|--message-file FILE read the commit comment from given file
1313 ** --mimetype MIMETYPE mimetype of check-in comment
1314 ** -n|--dry-run If given, display instead of run actions
@@ -1372,10 +1377,11 @@
1377 allowOlder = find_option("allow-older",0,0)!=0;
1378 noWarningFlag = find_option("no-warnings", 0, 0)!=0;
1379 sCiInfo.zBranch = find_option("branch","b",1);
1380 sCiInfo.zColor = find_option("bgcolor",0,1);
1381 sCiInfo.zBrClr = find_option("branchcolor",0,1);
1382 sCiInfo.closeFlag = find_option("close",0,0)!=0;
1383 sCiInfo.zMimetype = find_option("mimetype",0,1);
1384 while( (zTag = find_option("tag",0,1))!=0 ){
1385 if( zTag[0]==0 ) continue;
1386 sCiInfo.azTag = fossil_realloc((void*)sCiInfo.azTag, sizeof(char*)*(nTag+2));
1387 sCiInfo.azTag[nTag++] = zTag;
1388
--- src/cson_amalgamation.c
+++ src/cson_amalgamation.c
@@ -1576,14 +1576,29 @@
15761576
};
15771577
#define cson_string_empty_m {0/*length*/}
15781578
static const cson_string cson_string_empty = cson_string_empty_m;
15791579
15801580
1581
-
1581
+/**
1582
+ Assumes V is a (cson_value*) ans V->value is a (T*). Returns
1583
+ V->value cast to a (T*).
1584
+*/
15821585
#define CSON_CAST(T,V) ((T*)((V)->value))
1586
+/**
1587
+ Assumes V is a pointer to memory which is allocated as part of a
1588
+ cson_value instance (the bytes immediately after that part).
1589
+ Returns a pointer a a cson_value by subtracting sizeof(cson_value)
1590
+ from that address and casting it to a (cson_value*)
1591
+*/
15831592
#define CSON_VCAST(V) ((cson_value *)(((unsigned char *)(V))-sizeof(cson_value)))
15841593
1594
+/**
1595
+ CSON_INT(V) assumes that V is a (cson_value*) of type
1596
+ CSON_TYPE_INTEGER. This macro returns a (cson_int_t*) representing
1597
+ its value (how that is stored depends on whether we are running in
1598
+ 32- or 64-bit mode).
1599
+ */
15851600
#if CSON_VOID_PTR_IS_BIG
15861601
# define CSON_INT(V) ((cson_int_t*)(&((V)->value)))
15871602
#else
15881603
# define CSON_INT(V) ((cson_int_t*)(V)->value)
15891604
#endif
@@ -1592,14 +1607,12 @@
15921607
#define CSON_STR(V) CSON_CAST(cson_string,(V))
15931608
#define CSON_OBJ(V) CSON_CAST(cson_object,(V))
15941609
#define CSON_ARRAY(V) CSON_CAST(cson_array,(V))
15951610
15961611
/**
1597
-
15981612
Holds special shared "constant" (though they are non-const)
1599
- values.
1600
-
1613
+ values.
16011614
*/
16021615
static struct CSON_EMPTY_HOLDER_
16031616
{
16041617
char trueValue;
16051618
cson_string stringValue;
@@ -1809,11 +1822,11 @@
18091822
Frees any resources owned by val, but does not free val itself
18101823
(which may be stack-allocated). If !val or val->api or
18111824
val->api->cleanup are NULL then this is a no-op.
18121825
18131826
If v is a container type (object or array) its children are also
1814
- cleaned up (BUT NOT FREED), recursively.
1827
+ cleaned up, recursively.
18151828
18161829
After calling this, val will have the special "undefined" type.
18171830
*/
18181831
static void cson_value_clean( cson_value * val );
18191832
@@ -1889,11 +1902,11 @@
18891902
18901903
18911904
/**
18921905
Fetches v's string value as a non-const string.
18931906
1894
- cson_strings are supposed to be immutable, but this form provides
1907
+ cson_strings are intended to be immutable, but this form provides
18951908
access to the immutable bits, which are v->length bytes long. A
18961909
length-0 string is returned as NULL from here, as opposed to
18971910
"". (This is a side-effect of the string allocation mechanism.)
18981911
Returns NULL if !v or if v is the internal empty-string singleton.
18991912
*/
@@ -3781,11 +3794,31 @@
37813794
assert( next > pos );
37823795
clen = next - pos;
37833796
assert( clen );
37843797
if( 1 == clen )
37853798
{ /* ASCII */
3786
- assert( *pos == ch );
3799
+#if defined(CSON_FOSSIL_MODE)
3800
+ /* Workaround for fossil repo artifact
3801
+ f460839cff85d4e4f1360b366bb2858cef1411ea,
3802
+ which has what appears to be latin1-encoded
3803
+ text. file(1) thinks it's a FORTRAN program.
3804
+ */
3805
+ if(0xfffd==ch){
3806
+ assert(*pos != ch);
3807
+ /* MARKER("ch=%04x, *pos=%04x\n", ch, *pos); */
3808
+ ch = *pos
3809
+ /* We should arguably translate to '?', and
3810
+ will if this problem ever comes up with a
3811
+ non-latin1 encoding. For latin1 this
3812
+ workaround incidentally corrects the output
3813
+ to proper UTF8-escaped characters, and only
3814
+ for that reason is it being kept around.
3815
+ */;
3816
+ goto assume_latin1;
3817
+ }
3818
+#endif
3819
+ assert( (*pos == ch) && "Invalid UTF8" );
37873820
escChar[1] = 0;
37883821
switch(ch)
37893822
{
37903823
case '\t': escChar[1] = 't'; break;
37913824
case '\r': escChar[1] = 'r'; break;
@@ -3836,10 +3869,13 @@
38363869
}
38373870
continue;
38383871
}
38393872
else
38403873
{ /* UTF: transform it to \uXXXX */
3874
+#if defined(CSON_FOSSIL_MODE)
3875
+ assume_latin1:
3876
+#endif
38413877
memset(ubuf,0,UBLen);
38423878
rc = sprintf(ubuf, "\\u%04x",ch);
38433879
if( rc != 6 )
38443880
{
38453881
rc = cson_rc.RangeError;
@@ -4105,11 +4141,11 @@
41054141
rc = f(state, ",", 1);
41064142
if( 0 == rc )
41074143
{
41084144
rc = doIndent
41094145
? cson_output_indent( f, state, fmt->indentation, level )
4110
- : f( state, " ", 1 );
4146
+ : 0 /*f( state, " ", 1 )*/;
41114147
}
41124148
}
41134149
}
41144150
}
41154151
--level;
@@ -4183,11 +4219,11 @@
41834219
rc = f(state, ",", 1);
41844220
if( 0 == rc )
41854221
{
41864222
rc = doIndent
41874223
? cson_output_indent( f, state, fmt->indentation, level )
4188
- : f( state, " ", 1 );
4224
+ : 0 /*f( state, " ", 1 )*/;
41894225
}
41904226
}
41914227
}
41924228
}
41934229
--level;
@@ -4396,11 +4432,11 @@
43964432
const cson_size_t oldCap = sb->capacity;
43974433
const cson_size_t asz = npos * 2;
43984434
if( asz < npos ) return cson_rc.ArgError; /* overflow */
43994435
else if( 0 != cson_buffer_reserve( sb, asz ) ) return cson_rc.AllocError;
44004436
assert( (sb->capacity > oldCap) && "Internal error in memory buffer management!" );
4401
- /* make sure it gets NULL terminated. */
4437
+ /* make sure it gets NUL terminated. */
44024438
memset( sb->mem + oldCap, 0, (sb->capacity - oldCap) );
44034439
}
44044440
for( i = 0; i < n; ++i, ++sb->used )
44054441
{
44064442
sb->mem[sb->used] = data[i];
44074443
--- src/cson_amalgamation.c
+++ src/cson_amalgamation.c
@@ -1576,14 +1576,29 @@
1576 };
1577 #define cson_string_empty_m {0/*length*/}
1578 static const cson_string cson_string_empty = cson_string_empty_m;
1579
1580
1581
 
 
 
1582 #define CSON_CAST(T,V) ((T*)((V)->value))
 
 
 
 
 
 
1583 #define CSON_VCAST(V) ((cson_value *)(((unsigned char *)(V))-sizeof(cson_value)))
1584
 
 
 
 
 
 
1585 #if CSON_VOID_PTR_IS_BIG
1586 # define CSON_INT(V) ((cson_int_t*)(&((V)->value)))
1587 #else
1588 # define CSON_INT(V) ((cson_int_t*)(V)->value)
1589 #endif
@@ -1592,14 +1607,12 @@
1592 #define CSON_STR(V) CSON_CAST(cson_string,(V))
1593 #define CSON_OBJ(V) CSON_CAST(cson_object,(V))
1594 #define CSON_ARRAY(V) CSON_CAST(cson_array,(V))
1595
1596 /**
1597
1598 Holds special shared "constant" (though they are non-const)
1599 values.
1600
1601 */
1602 static struct CSON_EMPTY_HOLDER_
1603 {
1604 char trueValue;
1605 cson_string stringValue;
@@ -1809,11 +1822,11 @@
1809 Frees any resources owned by val, but does not free val itself
1810 (which may be stack-allocated). If !val or val->api or
1811 val->api->cleanup are NULL then this is a no-op.
1812
1813 If v is a container type (object or array) its children are also
1814 cleaned up (BUT NOT FREED), recursively.
1815
1816 After calling this, val will have the special "undefined" type.
1817 */
1818 static void cson_value_clean( cson_value * val );
1819
@@ -1889,11 +1902,11 @@
1889
1890
1891 /**
1892 Fetches v's string value as a non-const string.
1893
1894 cson_strings are supposed to be immutable, but this form provides
1895 access to the immutable bits, which are v->length bytes long. A
1896 length-0 string is returned as NULL from here, as opposed to
1897 "". (This is a side-effect of the string allocation mechanism.)
1898 Returns NULL if !v or if v is the internal empty-string singleton.
1899 */
@@ -3781,11 +3794,31 @@
3781 assert( next > pos );
3782 clen = next - pos;
3783 assert( clen );
3784 if( 1 == clen )
3785 { /* ASCII */
3786 assert( *pos == ch );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3787 escChar[1] = 0;
3788 switch(ch)
3789 {
3790 case '\t': escChar[1] = 't'; break;
3791 case '\r': escChar[1] = 'r'; break;
@@ -3836,10 +3869,13 @@
3836 }
3837 continue;
3838 }
3839 else
3840 { /* UTF: transform it to \uXXXX */
 
 
 
3841 memset(ubuf,0,UBLen);
3842 rc = sprintf(ubuf, "\\u%04x",ch);
3843 if( rc != 6 )
3844 {
3845 rc = cson_rc.RangeError;
@@ -4105,11 +4141,11 @@
4105 rc = f(state, ",", 1);
4106 if( 0 == rc )
4107 {
4108 rc = doIndent
4109 ? cson_output_indent( f, state, fmt->indentation, level )
4110 : f( state, " ", 1 );
4111 }
4112 }
4113 }
4114 }
4115 --level;
@@ -4183,11 +4219,11 @@
4183 rc = f(state, ",", 1);
4184 if( 0 == rc )
4185 {
4186 rc = doIndent
4187 ? cson_output_indent( f, state, fmt->indentation, level )
4188 : f( state, " ", 1 );
4189 }
4190 }
4191 }
4192 }
4193 --level;
@@ -4396,11 +4432,11 @@
4396 const cson_size_t oldCap = sb->capacity;
4397 const cson_size_t asz = npos * 2;
4398 if( asz < npos ) return cson_rc.ArgError; /* overflow */
4399 else if( 0 != cson_buffer_reserve( sb, asz ) ) return cson_rc.AllocError;
4400 assert( (sb->capacity > oldCap) && "Internal error in memory buffer management!" );
4401 /* make sure it gets NULL terminated. */
4402 memset( sb->mem + oldCap, 0, (sb->capacity - oldCap) );
4403 }
4404 for( i = 0; i < n; ++i, ++sb->used )
4405 {
4406 sb->mem[sb->used] = data[i];
4407
--- src/cson_amalgamation.c
+++ src/cson_amalgamation.c
@@ -1576,14 +1576,29 @@
1576 };
1577 #define cson_string_empty_m {0/*length*/}
1578 static const cson_string cson_string_empty = cson_string_empty_m;
1579
1580
1581 /**
1582 Assumes V is a (cson_value*) ans V->value is a (T*). Returns
1583 V->value cast to a (T*).
1584 */
1585 #define CSON_CAST(T,V) ((T*)((V)->value))
1586 /**
1587 Assumes V is a pointer to memory which is allocated as part of a
1588 cson_value instance (the bytes immediately after that part).
1589 Returns a pointer a a cson_value by subtracting sizeof(cson_value)
1590 from that address and casting it to a (cson_value*)
1591 */
1592 #define CSON_VCAST(V) ((cson_value *)(((unsigned char *)(V))-sizeof(cson_value)))
1593
1594 /**
1595 CSON_INT(V) assumes that V is a (cson_value*) of type
1596 CSON_TYPE_INTEGER. This macro returns a (cson_int_t*) representing
1597 its value (how that is stored depends on whether we are running in
1598 32- or 64-bit mode).
1599 */
1600 #if CSON_VOID_PTR_IS_BIG
1601 # define CSON_INT(V) ((cson_int_t*)(&((V)->value)))
1602 #else
1603 # define CSON_INT(V) ((cson_int_t*)(V)->value)
1604 #endif
@@ -1592,14 +1607,12 @@
1607 #define CSON_STR(V) CSON_CAST(cson_string,(V))
1608 #define CSON_OBJ(V) CSON_CAST(cson_object,(V))
1609 #define CSON_ARRAY(V) CSON_CAST(cson_array,(V))
1610
1611 /**
 
1612 Holds special shared "constant" (though they are non-const)
1613 values.
 
1614 */
1615 static struct CSON_EMPTY_HOLDER_
1616 {
1617 char trueValue;
1618 cson_string stringValue;
@@ -1809,11 +1822,11 @@
1822 Frees any resources owned by val, but does not free val itself
1823 (which may be stack-allocated). If !val or val->api or
1824 val->api->cleanup are NULL then this is a no-op.
1825
1826 If v is a container type (object or array) its children are also
1827 cleaned up, recursively.
1828
1829 After calling this, val will have the special "undefined" type.
1830 */
1831 static void cson_value_clean( cson_value * val );
1832
@@ -1889,11 +1902,11 @@
1902
1903
1904 /**
1905 Fetches v's string value as a non-const string.
1906
1907 cson_strings are intended to be immutable, but this form provides
1908 access to the immutable bits, which are v->length bytes long. A
1909 length-0 string is returned as NULL from here, as opposed to
1910 "". (This is a side-effect of the string allocation mechanism.)
1911 Returns NULL if !v or if v is the internal empty-string singleton.
1912 */
@@ -3781,11 +3794,31 @@
3794 assert( next > pos );
3795 clen = next - pos;
3796 assert( clen );
3797 if( 1 == clen )
3798 { /* ASCII */
3799 #if defined(CSON_FOSSIL_MODE)
3800 /* Workaround for fossil repo artifact
3801 f460839cff85d4e4f1360b366bb2858cef1411ea,
3802 which has what appears to be latin1-encoded
3803 text. file(1) thinks it's a FORTRAN program.
3804 */
3805 if(0xfffd==ch){
3806 assert(*pos != ch);
3807 /* MARKER("ch=%04x, *pos=%04x\n", ch, *pos); */
3808 ch = *pos
3809 /* We should arguably translate to '?', and
3810 will if this problem ever comes up with a
3811 non-latin1 encoding. For latin1 this
3812 workaround incidentally corrects the output
3813 to proper UTF8-escaped characters, and only
3814 for that reason is it being kept around.
3815 */;
3816 goto assume_latin1;
3817 }
3818 #endif
3819 assert( (*pos == ch) && "Invalid UTF8" );
3820 escChar[1] = 0;
3821 switch(ch)
3822 {
3823 case '\t': escChar[1] = 't'; break;
3824 case '\r': escChar[1] = 'r'; break;
@@ -3836,10 +3869,13 @@
3869 }
3870 continue;
3871 }
3872 else
3873 { /* UTF: transform it to \uXXXX */
3874 #if defined(CSON_FOSSIL_MODE)
3875 assume_latin1:
3876 #endif
3877 memset(ubuf,0,UBLen);
3878 rc = sprintf(ubuf, "\\u%04x",ch);
3879 if( rc != 6 )
3880 {
3881 rc = cson_rc.RangeError;
@@ -4105,11 +4141,11 @@
4141 rc = f(state, ",", 1);
4142 if( 0 == rc )
4143 {
4144 rc = doIndent
4145 ? cson_output_indent( f, state, fmt->indentation, level )
4146 : 0 /*f( state, " ", 1 )*/;
4147 }
4148 }
4149 }
4150 }
4151 --level;
@@ -4183,11 +4219,11 @@
4219 rc = f(state, ",", 1);
4220 if( 0 == rc )
4221 {
4222 rc = doIndent
4223 ? cson_output_indent( f, state, fmt->indentation, level )
4224 : 0 /*f( state, " ", 1 )*/;
4225 }
4226 }
4227 }
4228 }
4229 --level;
@@ -4396,11 +4432,11 @@
4432 const cson_size_t oldCap = sb->capacity;
4433 const cson_size_t asz = npos * 2;
4434 if( asz < npos ) return cson_rc.ArgError; /* overflow */
4435 else if( 0 != cson_buffer_reserve( sb, asz ) ) return cson_rc.AllocError;
4436 assert( (sb->capacity > oldCap) && "Internal error in memory buffer management!" );
4437 /* make sure it gets NUL terminated. */
4438 memset( sb->mem + oldCap, 0, (sb->capacity - oldCap) );
4439 }
4440 for( i = 0; i < n; ++i, ++sb->used )
4441 {
4442 sb->mem[sb->used] = data[i];
4443
+1 -4
--- src/diff.c
+++ src/diff.c
@@ -214,21 +214,18 @@
214214
int html, /* True if generating HTML. False for plain text */
215215
ReCompiled *pRe /* Colorize only if line matches this Regex */
216216
){
217217
blob_append(pOut, &cPrefix, 1);
218218
if( html ){
219
- char *zHtml;
220219
if( pRe && re_dline_match(pRe, pLine, 1)==0 ){
221220
cPrefix = ' ';
222221
}else if( cPrefix=='+' ){
223222
blob_append(pOut, "<span class=\"diffadd\">", -1);
224223
}else if( cPrefix=='-' ){
225224
blob_append(pOut, "<span class=\"diffrm\">", -1);
226225
}
227
- zHtml = htmlize(pLine->z, (pLine->h & LENGTH_MASK));
228
- blob_append(pOut, zHtml, -1);
229
- fossil_free(zHtml);
226
+ htmlize_to_blob(pOut, pLine->z, (pLine->h & LENGTH_MASK));
230227
if( cPrefix!=' ' ){
231228
blob_append(pOut, "</span>", -1);
232229
}
233230
}else{
234231
blob_append(pOut, pLine->z, pLine->h & LENGTH_MASK);
235232
--- src/diff.c
+++ src/diff.c
@@ -214,21 +214,18 @@
214 int html, /* True if generating HTML. False for plain text */
215 ReCompiled *pRe /* Colorize only if line matches this Regex */
216 ){
217 blob_append(pOut, &cPrefix, 1);
218 if( html ){
219 char *zHtml;
220 if( pRe && re_dline_match(pRe, pLine, 1)==0 ){
221 cPrefix = ' ';
222 }else if( cPrefix=='+' ){
223 blob_append(pOut, "<span class=\"diffadd\">", -1);
224 }else if( cPrefix=='-' ){
225 blob_append(pOut, "<span class=\"diffrm\">", -1);
226 }
227 zHtml = htmlize(pLine->z, (pLine->h & LENGTH_MASK));
228 blob_append(pOut, zHtml, -1);
229 fossil_free(zHtml);
230 if( cPrefix!=' ' ){
231 blob_append(pOut, "</span>", -1);
232 }
233 }else{
234 blob_append(pOut, pLine->z, pLine->h & LENGTH_MASK);
235
--- src/diff.c
+++ src/diff.c
@@ -214,21 +214,18 @@
214 int html, /* True if generating HTML. False for plain text */
215 ReCompiled *pRe /* Colorize only if line matches this Regex */
216 ){
217 blob_append(pOut, &cPrefix, 1);
218 if( html ){
 
219 if( pRe && re_dline_match(pRe, pLine, 1)==0 ){
220 cPrefix = ' ';
221 }else if( cPrefix=='+' ){
222 blob_append(pOut, "<span class=\"diffadd\">", -1);
223 }else if( cPrefix=='-' ){
224 blob_append(pOut, "<span class=\"diffrm\">", -1);
225 }
226 htmlize_to_blob(pOut, pLine->z, (pLine->h & LENGTH_MASK));
 
 
227 if( cPrefix!=' ' ){
228 blob_append(pOut, "</span>", -1);
229 }
230 }else{
231 blob_append(pOut, pLine->z, pLine->h & LENGTH_MASK);
232
+4 -4
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -642,12 +642,12 @@
642642
@ proc colType {c} {
643643
@ regexp {[a-z]+} $c type
644644
@ return $type
645645
@ }
646646
@
647
-@ proc readDiffs {cmd} {
648
-@ set in [open $cmd r]
647
+@ proc readDiffs {fossilcmd} {
648
+@ set in [open $fossilcmd r]
649649
@ fconfigure $in -encoding utf-8
650650
@ set nDiffs 0
651651
@ array set widths {txt 0 ln 0 mkr 0}
652652
@ while {[gets $in line] != -1} {
653653
@ if {![regexp {^=+\s+(.*?)\s+=+$} $line all fn]} {
@@ -883,11 +883,11 @@
883883
@ ::ttk::scrollbar .sby -command {.txtA yview} -orient vertical
884884
@ ::ttk::scrollbar .sbxA -command {.txtA xview} -orient horizontal
885885
@ ::ttk::scrollbar .sbxB -command {.txtB xview} -orient horizontal
886886
@ frame .spacer
887887
@
888
-@ if {[readDiffs $cmd] == 0} {
888
+@ if {[readDiffs $fossilcmd] == 0} {
889889
@ tk_messageBox -type ok -title $CFG(TITLE) -message "No changes"
890890
@ exit
891891
@ }
892892
@ update idletasks
893893
@
@@ -918,11 +918,11 @@
918918
int i;
919919
Blob script;
920920
char *zTempFile;
921921
char *zCmd;
922922
blob_zero(&script);
923
- blob_appendf(&script, "set cmd {| \"%/\" %s --html -y -i -v",
923
+ blob_appendf(&script, "set fossilcmd {| \"%/\" %s --html -y -i -v",
924924
g.nameOfExe, zSubCmd);
925925
for(i=firstArg; i<g.argc; i++){
926926
const char *z = g.argv[i];
927927
if( z[0]=='-' ){
928928
if( strglob("*-html",z) ) continue;
929929
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -642,12 +642,12 @@
642 @ proc colType {c} {
643 @ regexp {[a-z]+} $c type
644 @ return $type
645 @ }
646 @
647 @ proc readDiffs {cmd} {
648 @ set in [open $cmd r]
649 @ fconfigure $in -encoding utf-8
650 @ set nDiffs 0
651 @ array set widths {txt 0 ln 0 mkr 0}
652 @ while {[gets $in line] != -1} {
653 @ if {![regexp {^=+\s+(.*?)\s+=+$} $line all fn]} {
@@ -883,11 +883,11 @@
883 @ ::ttk::scrollbar .sby -command {.txtA yview} -orient vertical
884 @ ::ttk::scrollbar .sbxA -command {.txtA xview} -orient horizontal
885 @ ::ttk::scrollbar .sbxB -command {.txtB xview} -orient horizontal
886 @ frame .spacer
887 @
888 @ if {[readDiffs $cmd] == 0} {
889 @ tk_messageBox -type ok -title $CFG(TITLE) -message "No changes"
890 @ exit
891 @ }
892 @ update idletasks
893 @
@@ -918,11 +918,11 @@
918 int i;
919 Blob script;
920 char *zTempFile;
921 char *zCmd;
922 blob_zero(&script);
923 blob_appendf(&script, "set cmd {| \"%/\" %s --html -y -i -v",
924 g.nameOfExe, zSubCmd);
925 for(i=firstArg; i<g.argc; i++){
926 const char *z = g.argv[i];
927 if( z[0]=='-' ){
928 if( strglob("*-html",z) ) continue;
929
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -642,12 +642,12 @@
642 @ proc colType {c} {
643 @ regexp {[a-z]+} $c type
644 @ return $type
645 @ }
646 @
647 @ proc readDiffs {fossilcmd} {
648 @ set in [open $fossilcmd r]
649 @ fconfigure $in -encoding utf-8
650 @ set nDiffs 0
651 @ array set widths {txt 0 ln 0 mkr 0}
652 @ while {[gets $in line] != -1} {
653 @ if {![regexp {^=+\s+(.*?)\s+=+$} $line all fn]} {
@@ -883,11 +883,11 @@
883 @ ::ttk::scrollbar .sby -command {.txtA yview} -orient vertical
884 @ ::ttk::scrollbar .sbxA -command {.txtA xview} -orient horizontal
885 @ ::ttk::scrollbar .sbxB -command {.txtB xview} -orient horizontal
886 @ frame .spacer
887 @
888 @ if {[readDiffs $fossilcmd] == 0} {
889 @ tk_messageBox -type ok -title $CFG(TITLE) -message "No changes"
890 @ exit
891 @ }
892 @ update idletasks
893 @
@@ -918,11 +918,11 @@
918 int i;
919 Blob script;
920 char *zTempFile;
921 char *zCmd;
922 blob_zero(&script);
923 blob_appendf(&script, "set fossilcmd {| \"%/\" %s --html -y -i -v",
924 g.nameOfExe, zSubCmd);
925 for(i=firstArg; i<g.argc; i++){
926 const char *z = g.argv[i];
927 if( z[0]=='-' ){
928 if( strglob("*-html",z) ) continue;
929
--- src/encode.c
+++ src/encode.c
@@ -161,10 +161,11 @@
161161
zOut[i++] = "0123456789ABCDEF"[c&0xf];
162162
}
163163
zIn++;
164164
}
165165
zOut[i] = 0;
166
+#undef IsSafeChar
166167
return zOut;
167168
}
168169
169170
/*
170171
** Convert the input string into a form that is suitable for use as
171172
--- src/encode.c
+++ src/encode.c
@@ -161,10 +161,11 @@
161 zOut[i++] = "0123456789ABCDEF"[c&0xf];
162 }
163 zIn++;
164 }
165 zOut[i] = 0;
 
166 return zOut;
167 }
168
169 /*
170 ** Convert the input string into a form that is suitable for use as
171
--- src/encode.c
+++ src/encode.c
@@ -161,10 +161,11 @@
161 zOut[i++] = "0123456789ABCDEF"[c&0xf];
162 }
163 zIn++;
164 }
165 zOut[i] = 0;
166 #undef IsSafeChar
167 return zOut;
168 }
169
170 /*
171 ** Convert the input string into a form that is suitable for use as
172
--- src/json_artifact.c
+++ src/json_artifact.c
@@ -131,11 +131,11 @@
131131
zEUser = db_text(0,
132132
"SELECT value FROM tagxref WHERE tagid=%d AND rid=%d",
133133
TAG_USER, rid);
134134
if(zEUser){
135135
SET("user", json_new_string(zEUser));
136
- if(0!=strcmp(zEUser,zUser)){
136
+ if(0!=fossil_strcmp(zEUser,zUser)){
137137
SET("originUser",json_new_string(zUser));
138138
}
139139
free(zEUser);
140140
}else{
141141
SET("user",json_new_string(zUser));
@@ -145,11 +145,11 @@
145145
zEComment = db_text(0,
146146
"SELECT value FROM tagxref WHERE tagid=%d AND rid=%d",
147147
TAG_COMMENT, rid);
148148
if(zEComment){
149149
SET("comment",json_new_string(zEComment));
150
- if(0 != strcmp(zEComment,zComment)){
150
+ if(0 != fossil_strcmp(zEComment,zComment)){
151151
SET("originComment", json_new_string(zComment));
152152
}
153153
free(zEComment);
154154
}else{
155155
SET("comment",json_new_string(zComment));
@@ -470,11 +470,11 @@
470470
471471
handle_entry:
472472
pay = cson_new_object();
473473
assert( (NULL != zType) && "Internal dispatching error." );
474474
for( ; dispatcher->name; ++dispatcher ){
475
- if(0!=strcmp(dispatcher->name, zType)){
475
+ if(0!=fossil_strcmp(dispatcher->name, zType)){
476476
continue;
477477
}else{
478478
entry = (*dispatcher->func)(pay, rid);
479479
break;
480480
}
481481
--- src/json_artifact.c
+++ src/json_artifact.c
@@ -131,11 +131,11 @@
131 zEUser = db_text(0,
132 "SELECT value FROM tagxref WHERE tagid=%d AND rid=%d",
133 TAG_USER, rid);
134 if(zEUser){
135 SET("user", json_new_string(zEUser));
136 if(0!=strcmp(zEUser,zUser)){
137 SET("originUser",json_new_string(zUser));
138 }
139 free(zEUser);
140 }else{
141 SET("user",json_new_string(zUser));
@@ -145,11 +145,11 @@
145 zEComment = db_text(0,
146 "SELECT value FROM tagxref WHERE tagid=%d AND rid=%d",
147 TAG_COMMENT, rid);
148 if(zEComment){
149 SET("comment",json_new_string(zEComment));
150 if(0 != strcmp(zEComment,zComment)){
151 SET("originComment", json_new_string(zComment));
152 }
153 free(zEComment);
154 }else{
155 SET("comment",json_new_string(zComment));
@@ -470,11 +470,11 @@
470
471 handle_entry:
472 pay = cson_new_object();
473 assert( (NULL != zType) && "Internal dispatching error." );
474 for( ; dispatcher->name; ++dispatcher ){
475 if(0!=strcmp(dispatcher->name, zType)){
476 continue;
477 }else{
478 entry = (*dispatcher->func)(pay, rid);
479 break;
480 }
481
--- src/json_artifact.c
+++ src/json_artifact.c
@@ -131,11 +131,11 @@
131 zEUser = db_text(0,
132 "SELECT value FROM tagxref WHERE tagid=%d AND rid=%d",
133 TAG_USER, rid);
134 if(zEUser){
135 SET("user", json_new_string(zEUser));
136 if(0!=fossil_strcmp(zEUser,zUser)){
137 SET("originUser",json_new_string(zUser));
138 }
139 free(zEUser);
140 }else{
141 SET("user",json_new_string(zUser));
@@ -145,11 +145,11 @@
145 zEComment = db_text(0,
146 "SELECT value FROM tagxref WHERE tagid=%d AND rid=%d",
147 TAG_COMMENT, rid);
148 if(zEComment){
149 SET("comment",json_new_string(zEComment));
150 if(0 != fossil_strcmp(zEComment,zComment)){
151 SET("originComment", json_new_string(zComment));
152 }
153 free(zEComment);
154 }else{
155 SET("comment",json_new_string(zComment));
@@ -470,11 +470,11 @@
470
471 handle_entry:
472 pay = cson_new_object();
473 assert( (NULL != zType) && "Internal dispatching error." );
474 for( ; dispatcher->name; ++dispatcher ){
475 if(0!=fossil_strcmp(dispatcher->name, zType)){
476 continue;
477 }else{
478 entry = (*dispatcher->func)(pay, rid);
479 break;
480 }
481
+4 -6
--- src/main.c
+++ src/main.c
@@ -514,10 +514,11 @@
514514
#ifdef __APPLE__
515515
/* Disable the file alias warning on apple products because Time Machine
516516
** creates lots of aliases and the warning alarms people. */
517517
if( iCode==SQLITE_WARNING ) return;
518518
#endif
519
+ if( iCode==SQLITE_SCHEMA ) return;
519520
fossil_warning("%s: %s", sqlite_error_code_name(iCode), zErrmsg);
520521
}
521522
522523
/*
523524
** This procedure runs first.
@@ -610,11 +611,14 @@
610611
g.argc++;
611612
g.argv = zNewArgv;
612613
}
613614
zCmdName = g.argv[1];
614615
}
616
+#ifndef _WIN32
615617
if( !is_valid_fd(2) ) fossil_panic("file descriptor 2 not open");
618
+ /* if( is_valid_fd(3) ) fossil_warning("file descriptor 3 is open"); */
619
+#endif
616620
rc = name_search(zCmdName, aCommand, count(aCommand), &idx);
617621
if( rc==1 ){
618622
fossil_fatal("%s: unknown command: %s\n"
619623
"%s: use \"help\" for more information\n",
620624
g.argv[0], zCmdName, g.argv[0]);
@@ -1888,17 +1892,11 @@
18881892
zBrowser = db_get("web-browser", 0);
18891893
if( zBrowser==0 ){
18901894
static const char *const azBrowserProg[] =
18911895
{ "xdg-open", "gnome-open", "firefox", "google-chrome" };
18921896
int i;
1893
-#if defined(__CYGWIN__)
1894
- const char *path = fossil_getenv("PROGRAMFILES");
1895
- path = fossil_utf8_to_filename(path);
1896
- zBrowser = mprintf("\"%s/Internet Explorer/iexplore.exe\"", path);
1897
-#else
18981897
zBrowser = "echo";
1899
-#endif
19001898
for(i=0; i<sizeof(azBrowserProg)/sizeof(azBrowserProg[0]); i++){
19011899
if( binaryOnPath(azBrowserProg[i]) ){
19021900
zBrowser = azBrowserProg[i];
19031901
break;
19041902
}
19051903
--- src/main.c
+++ src/main.c
@@ -514,10 +514,11 @@
514 #ifdef __APPLE__
515 /* Disable the file alias warning on apple products because Time Machine
516 ** creates lots of aliases and the warning alarms people. */
517 if( iCode==SQLITE_WARNING ) return;
518 #endif
 
519 fossil_warning("%s: %s", sqlite_error_code_name(iCode), zErrmsg);
520 }
521
522 /*
523 ** This procedure runs first.
@@ -610,11 +611,14 @@
610 g.argc++;
611 g.argv = zNewArgv;
612 }
613 zCmdName = g.argv[1];
614 }
 
615 if( !is_valid_fd(2) ) fossil_panic("file descriptor 2 not open");
 
 
616 rc = name_search(zCmdName, aCommand, count(aCommand), &idx);
617 if( rc==1 ){
618 fossil_fatal("%s: unknown command: %s\n"
619 "%s: use \"help\" for more information\n",
620 g.argv[0], zCmdName, g.argv[0]);
@@ -1888,17 +1892,11 @@
1888 zBrowser = db_get("web-browser", 0);
1889 if( zBrowser==0 ){
1890 static const char *const azBrowserProg[] =
1891 { "xdg-open", "gnome-open", "firefox", "google-chrome" };
1892 int i;
1893 #if defined(__CYGWIN__)
1894 const char *path = fossil_getenv("PROGRAMFILES");
1895 path = fossil_utf8_to_filename(path);
1896 zBrowser = mprintf("\"%s/Internet Explorer/iexplore.exe\"", path);
1897 #else
1898 zBrowser = "echo";
1899 #endif
1900 for(i=0; i<sizeof(azBrowserProg)/sizeof(azBrowserProg[0]); i++){
1901 if( binaryOnPath(azBrowserProg[i]) ){
1902 zBrowser = azBrowserProg[i];
1903 break;
1904 }
1905
--- src/main.c
+++ src/main.c
@@ -514,10 +514,11 @@
514 #ifdef __APPLE__
515 /* Disable the file alias warning on apple products because Time Machine
516 ** creates lots of aliases and the warning alarms people. */
517 if( iCode==SQLITE_WARNING ) return;
518 #endif
519 if( iCode==SQLITE_SCHEMA ) return;
520 fossil_warning("%s: %s", sqlite_error_code_name(iCode), zErrmsg);
521 }
522
523 /*
524 ** This procedure runs first.
@@ -610,11 +611,14 @@
611 g.argc++;
612 g.argv = zNewArgv;
613 }
614 zCmdName = g.argv[1];
615 }
616 #ifndef _WIN32
617 if( !is_valid_fd(2) ) fossil_panic("file descriptor 2 not open");
618 /* if( is_valid_fd(3) ) fossil_warning("file descriptor 3 is open"); */
619 #endif
620 rc = name_search(zCmdName, aCommand, count(aCommand), &idx);
621 if( rc==1 ){
622 fossil_fatal("%s: unknown command: %s\n"
623 "%s: use \"help\" for more information\n",
624 g.argv[0], zCmdName, g.argv[0]);
@@ -1888,17 +1892,11 @@
1892 zBrowser = db_get("web-browser", 0);
1893 if( zBrowser==0 ){
1894 static const char *const azBrowserProg[] =
1895 { "xdg-open", "gnome-open", "firefox", "google-chrome" };
1896 int i;
 
 
 
 
 
1897 zBrowser = "echo";
 
1898 for(i=0; i<sizeof(azBrowserProg)/sizeof(azBrowserProg[0]); i++){
1899 if( binaryOnPath(azBrowserProg[i]) ){
1900 zBrowser = azBrowserProg[i];
1901 break;
1902 }
1903
+4 -6
--- src/main.c
+++ src/main.c
@@ -514,10 +514,11 @@
514514
#ifdef __APPLE__
515515
/* Disable the file alias warning on apple products because Time Machine
516516
** creates lots of aliases and the warning alarms people. */
517517
if( iCode==SQLITE_WARNING ) return;
518518
#endif
519
+ if( iCode==SQLITE_SCHEMA ) return;
519520
fossil_warning("%s: %s", sqlite_error_code_name(iCode), zErrmsg);
520521
}
521522
522523
/*
523524
** This procedure runs first.
@@ -610,11 +611,14 @@
610611
g.argc++;
611612
g.argv = zNewArgv;
612613
}
613614
zCmdName = g.argv[1];
614615
}
616
+#ifndef _WIN32
615617
if( !is_valid_fd(2) ) fossil_panic("file descriptor 2 not open");
618
+ /* if( is_valid_fd(3) ) fossil_warning("file descriptor 3 is open"); */
619
+#endif
616620
rc = name_search(zCmdName, aCommand, count(aCommand), &idx);
617621
if( rc==1 ){
618622
fossil_fatal("%s: unknown command: %s\n"
619623
"%s: use \"help\" for more information\n",
620624
g.argv[0], zCmdName, g.argv[0]);
@@ -1888,17 +1892,11 @@
18881892
zBrowser = db_get("web-browser", 0);
18891893
if( zBrowser==0 ){
18901894
static const char *const azBrowserProg[] =
18911895
{ "xdg-open", "gnome-open", "firefox", "google-chrome" };
18921896
int i;
1893
-#if defined(__CYGWIN__)
1894
- const char *path = fossil_getenv("PROGRAMFILES");
1895
- path = fossil_utf8_to_filename(path);
1896
- zBrowser = mprintf("\"%s/Internet Explorer/iexplore.exe\"", path);
1897
-#else
18981897
zBrowser = "echo";
1899
-#endif
19001898
for(i=0; i<sizeof(azBrowserProg)/sizeof(azBrowserProg[0]); i++){
19011899
if( binaryOnPath(azBrowserProg[i]) ){
19021900
zBrowser = azBrowserProg[i];
19031901
break;
19041902
}
19051903
--- src/main.c
+++ src/main.c
@@ -514,10 +514,11 @@
514 #ifdef __APPLE__
515 /* Disable the file alias warning on apple products because Time Machine
516 ** creates lots of aliases and the warning alarms people. */
517 if( iCode==SQLITE_WARNING ) return;
518 #endif
 
519 fossil_warning("%s: %s", sqlite_error_code_name(iCode), zErrmsg);
520 }
521
522 /*
523 ** This procedure runs first.
@@ -610,11 +611,14 @@
610 g.argc++;
611 g.argv = zNewArgv;
612 }
613 zCmdName = g.argv[1];
614 }
 
615 if( !is_valid_fd(2) ) fossil_panic("file descriptor 2 not open");
 
 
616 rc = name_search(zCmdName, aCommand, count(aCommand), &idx);
617 if( rc==1 ){
618 fossil_fatal("%s: unknown command: %s\n"
619 "%s: use \"help\" for more information\n",
620 g.argv[0], zCmdName, g.argv[0]);
@@ -1888,17 +1892,11 @@
1888 zBrowser = db_get("web-browser", 0);
1889 if( zBrowser==0 ){
1890 static const char *const azBrowserProg[] =
1891 { "xdg-open", "gnome-open", "firefox", "google-chrome" };
1892 int i;
1893 #if defined(__CYGWIN__)
1894 const char *path = fossil_getenv("PROGRAMFILES");
1895 path = fossil_utf8_to_filename(path);
1896 zBrowser = mprintf("\"%s/Internet Explorer/iexplore.exe\"", path);
1897 #else
1898 zBrowser = "echo";
1899 #endif
1900 for(i=0; i<sizeof(azBrowserProg)/sizeof(azBrowserProg[0]); i++){
1901 if( binaryOnPath(azBrowserProg[i]) ){
1902 zBrowser = azBrowserProg[i];
1903 break;
1904 }
1905
--- src/main.c
+++ src/main.c
@@ -514,10 +514,11 @@
514 #ifdef __APPLE__
515 /* Disable the file alias warning on apple products because Time Machine
516 ** creates lots of aliases and the warning alarms people. */
517 if( iCode==SQLITE_WARNING ) return;
518 #endif
519 if( iCode==SQLITE_SCHEMA ) return;
520 fossil_warning("%s: %s", sqlite_error_code_name(iCode), zErrmsg);
521 }
522
523 /*
524 ** This procedure runs first.
@@ -610,11 +611,14 @@
611 g.argc++;
612 g.argv = zNewArgv;
613 }
614 zCmdName = g.argv[1];
615 }
616 #ifndef _WIN32
617 if( !is_valid_fd(2) ) fossil_panic("file descriptor 2 not open");
618 /* if( is_valid_fd(3) ) fossil_warning("file descriptor 3 is open"); */
619 #endif
620 rc = name_search(zCmdName, aCommand, count(aCommand), &idx);
621 if( rc==1 ){
622 fossil_fatal("%s: unknown command: %s\n"
623 "%s: use \"help\" for more information\n",
624 g.argv[0], zCmdName, g.argv[0]);
@@ -1888,17 +1892,11 @@
1892 zBrowser = db_get("web-browser", 0);
1893 if( zBrowser==0 ){
1894 static const char *const azBrowserProg[] =
1895 { "xdg-open", "gnome-open", "firefox", "google-chrome" };
1896 int i;
 
 
 
 
 
1897 zBrowser = "echo";
 
1898 for(i=0; i<sizeof(azBrowserProg)/sizeof(azBrowserProg[0]); i++){
1899 if( binaryOnPath(azBrowserProg[i]) ){
1900 zBrowser = azBrowserProg[i];
1901 break;
1902 }
1903
+22 -17
--- src/manifest.c
+++ src/manifest.c
@@ -469,12 +469,13 @@
469469
470470
/*
471471
** C <comment>
472472
**
473473
** Comment text is fossil-encoded. There may be no more than
474
- ** one C line. C lines are required for manifests and are
475
- ** disallowed on all other control files.
474
+ ** one C line. C lines are required for manifests, are optional
475
+ ** for Events and Attachments, and are disallowed on all other
476
+ ** control files.
476477
*/
477478
case 'C': {
478479
if( p->zComment!=0 ) SYNTAX("more than one C-card");
479480
p->zComment = next_token(&x, 0);
480481
if( p->zComment==0 ) SYNTAX("missing comment text on C-card");
@@ -663,11 +664,13 @@
663664
/*
664665
** P <uuid> ...
665666
**
666667
** Specify one or more other artifacts which are the parents of
667668
** this artifact. The first parent is the primary parent. All
668
- ** others are parents by merge.
669
+ ** others are parents by merge. Note that the initial empty
670
+ ** checkin historically has an empty P-card, so empty P-cards
671
+ ** must be accepted.
669672
*/
670673
case 'P': {
671674
while( (zUuid = next_token(&x, &sz))!=0 ){
672675
if( sz!=UUID_SIZE ) SYNTAX("wrong size UUID on P-card");
673676
if( !validate16(zUuid, UUID_SIZE) )SYNTAX("invalid UUID on P-card");
@@ -1955,46 +1958,42 @@
19551958
if( strcmp(zName, "*branch")==0 ){
19561959
blob_appendf(&comment,
19571960
" Move to branch [/timeline?r=%h&nd&dp=%S | %h].",
19581961
zValue, zUuid, zValue);
19591962
branchMove = 1;
1963
+ continue;
19601964
}else if( strcmp(zName, "*bgcolor")==0 ){
19611965
blob_appendf(&comment,
19621966
" Change branch background color to \"%h\".", zValue);
1967
+ continue;
19631968
}else if( strcmp(zName, "+bgcolor")==0 ){
19641969
blob_appendf(&comment,
19651970
" Change background color to \"%h\".", zValue);
1971
+ continue;
19661972
}else if( strcmp(zName, "-bgcolor")==0 ){
1967
- blob_appendf(&comment, " Cancel background color.");
1973
+ blob_appendf(&comment, " Cancel background color");
19681974
}else if( strcmp(zName, "+comment")==0 ){
19691975
blob_appendf(&comment, " Edit check-in comment.");
1976
+ continue;
19701977
}else if( strcmp(zName, "+user")==0 ){
19711978
blob_appendf(&comment, " Change user to \"%h\".", zValue);
1979
+ continue;
19721980
}else if( strcmp(zName, "+date")==0 ){
19731981
blob_appendf(&comment, " Timestamp %h.", zValue);
1982
+ continue;
19741983
}else if( memcmp(zName, "-sym-",5)==0 ){
1975
- if( !branchMove ) blob_appendf(&comment, " Cancel tag %h.", &zName[5]);
1984
+ if( !branchMove ) blob_appendf(&comment, " Cancel tag \"%h\"", &zName[5]);
19761985
}else if( memcmp(zName, "*sym-",5)==0 ){
19771986
if( !branchMove ){
1978
- blob_appendf(&comment, " Add propagating tag \"%h\".", &zName[5]);
1987
+ blob_appendf(&comment, " Add propagating tag \"%h\"", &zName[5]);
19791988
}
19801989
}else if( memcmp(zName, "+sym-",5)==0 ){
1981
- blob_appendf(&comment, " Add tag \"%h\".", &zName[5]);
1982
- }else if( memcmp(zName, "-sym-",5)==0 ){
1983
- blob_appendf(&comment, " Cancel tag \"%h\".", &zName[5]);
1990
+ blob_appendf(&comment, " Add tag \"%h\"", &zName[5]);
19841991
}else if( strcmp(zName, "+closed")==0 ){
19851992
blob_append(&comment, " Marked \"Closed\"", -1);
1986
- if( zValue && *zValue ){
1987
- blob_appendf(&comment, " with note \"%h\"", zValue);
1988
- }
1989
- blob_append(&comment, ".", 1);
19901993
}else if( strcmp(zName, "-closed")==0 ){
19911994
blob_append(&comment, " Removed the \"Closed\" mark", -1);
1992
- if( zValue && *zValue ){
1993
- blob_appendf(&comment, " with note \"%h\"", zValue);
1994
- }
1995
- blob_append(&comment, ".", 1);
19961995
}else {
19971996
if( zName[0]=='-' ){
19981997
blob_appendf(&comment, " Cancel \"%h\"", &zName[1]);
19991998
}else if( zName[0]=='+' ){
20001999
blob_appendf(&comment, " Add \"%h\"", &zName[1]);
@@ -2004,10 +2003,16 @@
20042003
if( zValue && zValue[0] ){
20052004
blob_appendf(&comment, " with value \"%h\".", zValue);
20062005
}else{
20072006
blob_appendf(&comment, ".");
20082007
}
2008
+ continue;
2009
+ }
2010
+ if( zValue && zValue[0] ){
2011
+ blob_appendf(&comment, " with note \"%h\".", zValue);
2012
+ }else{
2013
+ blob_appendf(&comment, ".");
20092014
}
20102015
}
20112016
/*blob_appendf(&comment, " &#91;[/info/%S | details]&#93;");*/
20122017
if( blob_size(&comment)==0 ) blob_append(&comment, " ", 1);
20132018
db_multi_exec(
20142019
--- src/manifest.c
+++ src/manifest.c
@@ -469,12 +469,13 @@
469
470 /*
471 ** C <comment>
472 **
473 ** Comment text is fossil-encoded. There may be no more than
474 ** one C line. C lines are required for manifests and are
475 ** disallowed on all other control files.
 
476 */
477 case 'C': {
478 if( p->zComment!=0 ) SYNTAX("more than one C-card");
479 p->zComment = next_token(&x, 0);
480 if( p->zComment==0 ) SYNTAX("missing comment text on C-card");
@@ -663,11 +664,13 @@
663 /*
664 ** P <uuid> ...
665 **
666 ** Specify one or more other artifacts which are the parents of
667 ** this artifact. The first parent is the primary parent. All
668 ** others are parents by merge.
 
 
669 */
670 case 'P': {
671 while( (zUuid = next_token(&x, &sz))!=0 ){
672 if( sz!=UUID_SIZE ) SYNTAX("wrong size UUID on P-card");
673 if( !validate16(zUuid, UUID_SIZE) )SYNTAX("invalid UUID on P-card");
@@ -1955,46 +1958,42 @@
1955 if( strcmp(zName, "*branch")==0 ){
1956 blob_appendf(&comment,
1957 " Move to branch [/timeline?r=%h&nd&dp=%S | %h].",
1958 zValue, zUuid, zValue);
1959 branchMove = 1;
 
1960 }else if( strcmp(zName, "*bgcolor")==0 ){
1961 blob_appendf(&comment,
1962 " Change branch background color to \"%h\".", zValue);
 
1963 }else if( strcmp(zName, "+bgcolor")==0 ){
1964 blob_appendf(&comment,
1965 " Change background color to \"%h\".", zValue);
 
1966 }else if( strcmp(zName, "-bgcolor")==0 ){
1967 blob_appendf(&comment, " Cancel background color.");
1968 }else if( strcmp(zName, "+comment")==0 ){
1969 blob_appendf(&comment, " Edit check-in comment.");
 
1970 }else if( strcmp(zName, "+user")==0 ){
1971 blob_appendf(&comment, " Change user to \"%h\".", zValue);
 
1972 }else if( strcmp(zName, "+date")==0 ){
1973 blob_appendf(&comment, " Timestamp %h.", zValue);
 
1974 }else if( memcmp(zName, "-sym-",5)==0 ){
1975 if( !branchMove ) blob_appendf(&comment, " Cancel tag %h.", &zName[5]);
1976 }else if( memcmp(zName, "*sym-",5)==0 ){
1977 if( !branchMove ){
1978 blob_appendf(&comment, " Add propagating tag \"%h\".", &zName[5]);
1979 }
1980 }else if( memcmp(zName, "+sym-",5)==0 ){
1981 blob_appendf(&comment, " Add tag \"%h\".", &zName[5]);
1982 }else if( memcmp(zName, "-sym-",5)==0 ){
1983 blob_appendf(&comment, " Cancel tag \"%h\".", &zName[5]);
1984 }else if( strcmp(zName, "+closed")==0 ){
1985 blob_append(&comment, " Marked \"Closed\"", -1);
1986 if( zValue && *zValue ){
1987 blob_appendf(&comment, " with note \"%h\"", zValue);
1988 }
1989 blob_append(&comment, ".", 1);
1990 }else if( strcmp(zName, "-closed")==0 ){
1991 blob_append(&comment, " Removed the \"Closed\" mark", -1);
1992 if( zValue && *zValue ){
1993 blob_appendf(&comment, " with note \"%h\"", zValue);
1994 }
1995 blob_append(&comment, ".", 1);
1996 }else {
1997 if( zName[0]=='-' ){
1998 blob_appendf(&comment, " Cancel \"%h\"", &zName[1]);
1999 }else if( zName[0]=='+' ){
2000 blob_appendf(&comment, " Add \"%h\"", &zName[1]);
@@ -2004,10 +2003,16 @@
2004 if( zValue && zValue[0] ){
2005 blob_appendf(&comment, " with value \"%h\".", zValue);
2006 }else{
2007 blob_appendf(&comment, ".");
2008 }
 
 
 
 
 
 
2009 }
2010 }
2011 /*blob_appendf(&comment, " &#91;[/info/%S | details]&#93;");*/
2012 if( blob_size(&comment)==0 ) blob_append(&comment, " ", 1);
2013 db_multi_exec(
2014
--- src/manifest.c
+++ src/manifest.c
@@ -469,12 +469,13 @@
469
470 /*
471 ** C <comment>
472 **
473 ** Comment text is fossil-encoded. There may be no more than
474 ** one C line. C lines are required for manifests, are optional
475 ** for Events and Attachments, and are disallowed on all other
476 ** control files.
477 */
478 case 'C': {
479 if( p->zComment!=0 ) SYNTAX("more than one C-card");
480 p->zComment = next_token(&x, 0);
481 if( p->zComment==0 ) SYNTAX("missing comment text on C-card");
@@ -663,11 +664,13 @@
664 /*
665 ** P <uuid> ...
666 **
667 ** Specify one or more other artifacts which are the parents of
668 ** this artifact. The first parent is the primary parent. All
669 ** others are parents by merge. Note that the initial empty
670 ** checkin historically has an empty P-card, so empty P-cards
671 ** must be accepted.
672 */
673 case 'P': {
674 while( (zUuid = next_token(&x, &sz))!=0 ){
675 if( sz!=UUID_SIZE ) SYNTAX("wrong size UUID on P-card");
676 if( !validate16(zUuid, UUID_SIZE) )SYNTAX("invalid UUID on P-card");
@@ -1955,46 +1958,42 @@
1958 if( strcmp(zName, "*branch")==0 ){
1959 blob_appendf(&comment,
1960 " Move to branch [/timeline?r=%h&nd&dp=%S | %h].",
1961 zValue, zUuid, zValue);
1962 branchMove = 1;
1963 continue;
1964 }else if( strcmp(zName, "*bgcolor")==0 ){
1965 blob_appendf(&comment,
1966 " Change branch background color to \"%h\".", zValue);
1967 continue;
1968 }else if( strcmp(zName, "+bgcolor")==0 ){
1969 blob_appendf(&comment,
1970 " Change background color to \"%h\".", zValue);
1971 continue;
1972 }else if( strcmp(zName, "-bgcolor")==0 ){
1973 blob_appendf(&comment, " Cancel background color");
1974 }else if( strcmp(zName, "+comment")==0 ){
1975 blob_appendf(&comment, " Edit check-in comment.");
1976 continue;
1977 }else if( strcmp(zName, "+user")==0 ){
1978 blob_appendf(&comment, " Change user to \"%h\".", zValue);
1979 continue;
1980 }else if( strcmp(zName, "+date")==0 ){
1981 blob_appendf(&comment, " Timestamp %h.", zValue);
1982 continue;
1983 }else if( memcmp(zName, "-sym-",5)==0 ){
1984 if( !branchMove ) blob_appendf(&comment, " Cancel tag \"%h\"", &zName[5]);
1985 }else if( memcmp(zName, "*sym-",5)==0 ){
1986 if( !branchMove ){
1987 blob_appendf(&comment, " Add propagating tag \"%h\"", &zName[5]);
1988 }
1989 }else if( memcmp(zName, "+sym-",5)==0 ){
1990 blob_appendf(&comment, " Add tag \"%h\"", &zName[5]);
 
 
1991 }else if( strcmp(zName, "+closed")==0 ){
1992 blob_append(&comment, " Marked \"Closed\"", -1);
 
 
 
 
1993 }else if( strcmp(zName, "-closed")==0 ){
1994 blob_append(&comment, " Removed the \"Closed\" mark", -1);
 
 
 
 
1995 }else {
1996 if( zName[0]=='-' ){
1997 blob_appendf(&comment, " Cancel \"%h\"", &zName[1]);
1998 }else if( zName[0]=='+' ){
1999 blob_appendf(&comment, " Add \"%h\"", &zName[1]);
@@ -2004,10 +2003,16 @@
2003 if( zValue && zValue[0] ){
2004 blob_appendf(&comment, " with value \"%h\".", zValue);
2005 }else{
2006 blob_appendf(&comment, ".");
2007 }
2008 continue;
2009 }
2010 if( zValue && zValue[0] ){
2011 blob_appendf(&comment, " with note \"%h\".", zValue);
2012 }else{
2013 blob_appendf(&comment, ".");
2014 }
2015 }
2016 /*blob_appendf(&comment, " &#91;[/info/%S | details]&#93;");*/
2017 if( blob_size(&comment)==0 ) blob_append(&comment, " ", 1);
2018 db_multi_exec(
2019
+5 -5
--- src/shell.c
+++ src/shell.c
@@ -69,16 +69,16 @@
6969
#define pclose _pclose
7070
#else
7171
/* Make sure isatty() has a prototype.
7272
*/
7373
extern int isatty(int);
74
-#endif
7574
7675
/* popen and pclose are not C89 functions and so are sometimes omitted from
7776
** the <stdio.h> header */
78
-FILE *popen(const char*,const char*);
79
-int pclose(FILE*);
77
+extern FILE *popen(const char*,const char*);
78
+extern int pclose(FILE*);
79
+#endif
8080
8181
#if defined(_WIN32_WCE)
8282
/* Windows CE (arm-wince-mingw32ce-gcc) does not provide isatty()
8383
* thus we always assume that we have a console. That can be
8484
* overridden with the -batch command line option.
@@ -552,11 +552,11 @@
552552
fputc('\\', out);
553553
fputc('n', out);
554554
}else if( c=='\r' ){
555555
fputc('\\', out);
556556
fputc('r', out);
557
- }else if( !isprint(c) ){
557
+ }else if( !isprint(c&0xff) ){
558558
fprintf(out, "\\%03o", c&0xff);
559559
}else{
560560
fputc(c, out);
561561
}
562562
}
@@ -1278,11 +1278,11 @@
12781278
zType = azArg[1];
12791279
zSql = azArg[2];
12801280
12811281
if( strcmp(zTable, "sqlite_sequence")==0 ){
12821282
zPrepStmt = "DELETE FROM sqlite_sequence;\n";
1283
- }else if( strcmp(zTable, "sqlite_stat1")==0 ){
1283
+ }else if( sqlite3_strglob("sqlite_stat?", zTable)==0 ){
12841284
fprintf(p->out, "ANALYZE sqlite_master;\n");
12851285
}else if( strncmp(zTable, "sqlite_", 7)==0 ){
12861286
return 0;
12871287
}else if( strncmp(zSql, "CREATE VIRTUAL TABLE", 20)==0 ){
12881288
char *zIns;
12891289
--- src/shell.c
+++ src/shell.c
@@ -69,16 +69,16 @@
69 #define pclose _pclose
70 #else
71 /* Make sure isatty() has a prototype.
72 */
73 extern int isatty(int);
74 #endif
75
76 /* popen and pclose are not C89 functions and so are sometimes omitted from
77 ** the <stdio.h> header */
78 FILE *popen(const char*,const char*);
79 int pclose(FILE*);
 
80
81 #if defined(_WIN32_WCE)
82 /* Windows CE (arm-wince-mingw32ce-gcc) does not provide isatty()
83 * thus we always assume that we have a console. That can be
84 * overridden with the -batch command line option.
@@ -552,11 +552,11 @@
552 fputc('\\', out);
553 fputc('n', out);
554 }else if( c=='\r' ){
555 fputc('\\', out);
556 fputc('r', out);
557 }else if( !isprint(c) ){
558 fprintf(out, "\\%03o", c&0xff);
559 }else{
560 fputc(c, out);
561 }
562 }
@@ -1278,11 +1278,11 @@
1278 zType = azArg[1];
1279 zSql = azArg[2];
1280
1281 if( strcmp(zTable, "sqlite_sequence")==0 ){
1282 zPrepStmt = "DELETE FROM sqlite_sequence;\n";
1283 }else if( strcmp(zTable, "sqlite_stat1")==0 ){
1284 fprintf(p->out, "ANALYZE sqlite_master;\n");
1285 }else if( strncmp(zTable, "sqlite_", 7)==0 ){
1286 return 0;
1287 }else if( strncmp(zSql, "CREATE VIRTUAL TABLE", 20)==0 ){
1288 char *zIns;
1289
--- src/shell.c
+++ src/shell.c
@@ -69,16 +69,16 @@
69 #define pclose _pclose
70 #else
71 /* Make sure isatty() has a prototype.
72 */
73 extern int isatty(int);
 
74
75 /* popen and pclose are not C89 functions and so are sometimes omitted from
76 ** the <stdio.h> header */
77 extern FILE *popen(const char*,const char*);
78 extern int pclose(FILE*);
79 #endif
80
81 #if defined(_WIN32_WCE)
82 /* Windows CE (arm-wince-mingw32ce-gcc) does not provide isatty()
83 * thus we always assume that we have a console. That can be
84 * overridden with the -batch command line option.
@@ -552,11 +552,11 @@
552 fputc('\\', out);
553 fputc('n', out);
554 }else if( c=='\r' ){
555 fputc('\\', out);
556 fputc('r', out);
557 }else if( !isprint(c&0xff) ){
558 fprintf(out, "\\%03o", c&0xff);
559 }else{
560 fputc(c, out);
561 }
562 }
@@ -1278,11 +1278,11 @@
1278 zType = azArg[1];
1279 zSql = azArg[2];
1280
1281 if( strcmp(zTable, "sqlite_sequence")==0 ){
1282 zPrepStmt = "DELETE FROM sqlite_sequence;\n";
1283 }else if( sqlite3_strglob("sqlite_stat?", zTable)==0 ){
1284 fprintf(p->out, "ANALYZE sqlite_master;\n");
1285 }else if( strncmp(zTable, "sqlite_", 7)==0 ){
1286 return 0;
1287 }else if( strncmp(zSql, "CREATE VIRTUAL TABLE", 20)==0 ){
1288 char *zIns;
1289
+303 -124
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -656,11 +656,11 @@
656656
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
657657
** [sqlite_version()] and [sqlite_source_id()].
658658
*/
659659
#define SQLITE_VERSION "3.8.1"
660660
#define SQLITE_VERSION_NUMBER 3008001
661
-#define SQLITE_SOURCE_ID "2013-08-30 06:20:23 d9c018f8155ab48df8e0e02519bba50588fe49fc"
661
+#define SQLITE_SOURCE_ID "2013-09-04 04:04:08 8df95bb0b3f72222cf262174247a467c234f9939"
662662
663663
/*
664664
** CAPI3REF: Run-Time Library Version Numbers
665665
** KEYWORDS: sqlite3_version, sqlite3_sourceid
666666
**
@@ -1026,16 +1026,18 @@
10261026
#define SQLITE_IOERR_SHMMAP (SQLITE_IOERR | (21<<8))
10271027
#define SQLITE_IOERR_SEEK (SQLITE_IOERR | (22<<8))
10281028
#define SQLITE_IOERR_DELETE_NOENT (SQLITE_IOERR | (23<<8))
10291029
#define SQLITE_IOERR_MMAP (SQLITE_IOERR | (24<<8))
10301030
#define SQLITE_IOERR_GETTEMPPATH (SQLITE_IOERR | (25<<8))
1031
+#define SQLITE_IOERR_CONVPATH (SQLITE_IOERR | (26<<8))
10311032
#define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8))
10321033
#define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8))
10331034
#define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8))
10341035
#define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8))
10351036
#define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8))
10361037
#define SQLITE_CANTOPEN_FULLPATH (SQLITE_CANTOPEN | (3<<8))
1038
+#define SQLITE_CANTOPEN_CONVPATH (SQLITE_CANTOPEN | (4<<8))
10371039
#define SQLITE_CORRUPT_VTAB (SQLITE_CORRUPT | (1<<8))
10381040
#define SQLITE_READONLY_RECOVERY (SQLITE_READONLY | (1<<8))
10391041
#define SQLITE_READONLY_CANTLOCK (SQLITE_READONLY | (2<<8))
10401042
#define SQLITE_READONLY_ROLLBACK (SQLITE_READONLY | (3<<8))
10411043
#define SQLITE_ABORT_ROLLBACK (SQLITE_ABORT | (2<<8))
@@ -16259,11 +16261,11 @@
1625916261
assert( mem.disallow==0 );
1626016262
assert( (nByte & 7)==0 ); /* EV: R-46199-30249 */
1626116263
pOldHdr = sqlite3MemsysGetHeader(pPrior);
1626216264
pNew = sqlite3MemMalloc(nByte);
1626316265
if( pNew ){
16264
- memcpy(pNew, pPrior, nByte<pOldHdr->iSize ? nByte : pOldHdr->iSize);
16266
+ memcpy(pNew, pPrior, (int)(nByte<pOldHdr->iSize ? nByte : pOldHdr->iSize));
1626516267
if( nByte>pOldHdr->iSize ){
1626616268
randomFill(&((char*)pNew)[pOldHdr->iSize], nByte - (int)pOldHdr->iSize);
1626716269
}
1626816270
sqlite3MemFree(pPrior);
1626916271
}
@@ -23594,10 +23596,19 @@
2359423596
if( aSyscall[i].pCurrent!=0 ) return aSyscall[i].zName;
2359523597
}
2359623598
return 0;
2359723599
}
2359823600
23601
+/*
23602
+** Do not accept any file descriptor less than this value, in order to avoid
23603
+** opening database file using file descriptors that are commonly used for
23604
+** standard input, output, and error.
23605
+*/
23606
+#ifndef SQLITE_MINIMUM_FILE_DESCRIPTOR
23607
+# define SQLITE_MINIMUM_FILE_DESCRIPTOR 3
23608
+#endif
23609
+
2359923610
/*
2360023611
** Invoke open(). Do so multiple times, until it either succeeds or
2360123612
** fails for some reason other than EINTR.
2360223613
**
2360323614
** If the file creation mode "m" is 0 then set it to the default for
@@ -23624,11 +23635,11 @@
2362423635
#endif
2362523636
if( fd<0 ){
2362623637
if( errno==EINTR ) continue;
2362723638
break;
2362823639
}
23629
- if( fd>2 ) break;
23640
+ if( fd>=SQLITE_MINIMUM_FILE_DESCRIPTOR ) break;
2363023641
osClose(fd);
2363123642
sqlite3_log(SQLITE_WARNING,
2363223643
"attempt to open \"%s\" as file descriptor %d", z, fd);
2363323644
fd = -1;
2363423645
if( osOpen("/dev/null", f, m)<0 ) break;
@@ -28373,10 +28384,11 @@
2837328384
** If no suitable temporary file directory can be found, return NULL.
2837428385
*/
2837528386
static const char *unixTempFileDir(void){
2837628387
static const char *azDirs[] = {
2837728388
0,
28389
+ 0,
2837828390
0,
2837928391
"/var/tmp",
2838028392
"/usr/tmp",
2838128393
"/tmp",
2838228394
0 /* List terminator */
@@ -28384,11 +28396,12 @@
2838428396
unsigned int i;
2838528397
struct stat buf;
2838628398
const char *zDir = 0;
2838728399
2838828400
azDirs[0] = sqlite3_temp_directory;
28389
- if( !azDirs[1] ) azDirs[1] = getenv("TMPDIR");
28401
+ if( !azDirs[1] ) azDirs[1] = getenv("SQLITE_TMPDIR");
28402
+ if( !azDirs[2] ) azDirs[2] = getenv("TMPDIR");
2839028403
for(i=0; i<sizeof(azDirs)/sizeof(azDirs[0]); zDir=azDirs[i++]){
2839128404
if( zDir==0 ) continue;
2839228405
if( osStat(zDir, &buf) ) continue;
2839328406
if( !S_ISDIR(buf.st_mode) ) continue;
2839428407
if( osAccess(zDir, 07) ) continue;
@@ -30497,11 +30510,11 @@
3049730510
*/
3049830511
#if SQLITE_OS_WIN /* This file is used for Windows only */
3049930512
3050030513
#ifdef __CYGWIN__
3050130514
# include <sys/cygwin.h>
30502
-/* # include <errno.h> */
30515
+# include <errno.h> /* amalgamator: keep */
3050330516
#endif
3050430517
3050530518
/*
3050630519
** Include code that is common to all os_*.c files
3050730520
*/
@@ -30726,22 +30739,31 @@
3072630739
3072730740
/*
3072830741
** Are most of the Win32 ANSI APIs available (i.e. with certain exceptions
3072930742
** based on the sub-platform)?
3073030743
*/
30731
-#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT
30744
+#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && !defined(SQLITE_WIN32_NO_ANSI)
3073230745
# define SQLITE_WIN32_HAS_ANSI
3073330746
#endif
3073430747
3073530748
/*
3073630749
** Are most of the Win32 Unicode APIs available (i.e. with certain exceptions
3073730750
** based on the sub-platform)?
3073830751
*/
30739
-#if SQLITE_OS_WINCE || SQLITE_OS_WINNT || SQLITE_OS_WINRT
30752
+#if (SQLITE_OS_WINCE || SQLITE_OS_WINNT || SQLITE_OS_WINRT) && \
30753
+ !defined(SQLITE_WIN32_NO_WIDE)
3074030754
# define SQLITE_WIN32_HAS_WIDE
3074130755
#endif
3074230756
30757
+/*
30758
+** Make sure at least one set of Win32 APIs is available.
30759
+*/
30760
+#if !defined(SQLITE_WIN32_HAS_ANSI) && !defined(SQLITE_WIN32_HAS_WIDE)
30761
+# error "At least one of SQLITE_WIN32_HAS_ANSI and SQLITE_WIN32_HAS_WIDE\
30762
+ must be defined."
30763
+#endif
30764
+
3074330765
/*
3074430766
** Maximum pathname length (in chars) for Win32. This should normally be
3074530767
** MAX_PATH.
3074630768
*/
3074730769
#ifndef SQLITE_WIN32_MAX_PATH_CHARS
@@ -30849,11 +30871,11 @@
3084930871
#ifndef FILE_ATTRIBUTE_MASK
3085030872
# define FILE_ATTRIBUTE_MASK (0x0003FFF7)
3085130873
#endif
3085230874
3085330875
#ifndef SQLITE_OMIT_WAL
30854
-/* Forward references */
30876
+/* Forward references to structures used for WAL */
3085530877
typedef struct winShm winShm; /* A connection to shared-memory */
3085630878
typedef struct winShmNode winShmNode; /* A region of shared-memory */
3085730879
#endif
3085830880
3085930881
/*
@@ -31804,11 +31826,11 @@
3180431826
** API as long as we don't call it when running Win95/98/ME. A call to
3180531827
** this routine is used to determine if the host is Win95/98/ME or
3180631828
** WinNT/2K/XP so that we will know whether or not we can safely call
3180731829
** the LockFileEx() API.
3180831830
*/
31809
-#if SQLITE_OS_WINCE || SQLITE_OS_WINRT
31831
+#if SQLITE_OS_WINCE || SQLITE_OS_WINRT || !defined(SQLITE_WIN32_HAS_ANSI)
3181031832
# define osIsNT() (1)
3181131833
#elif !defined(SQLITE_WIN32_HAS_WIDE)
3181231834
# define osIsNT() (0)
3181331835
#else
3181431836
static int osIsNT(void){
@@ -32449,14 +32471,13 @@
3244932471
3245032472
/* Create/open the named mutex */
3245132473
pFile->hMutex = osCreateMutexW(NULL, FALSE, zName);
3245232474
if (!pFile->hMutex){
3245332475
pFile->lastErrno = osGetLastError();
32454
- winLogError(SQLITE_IOERR, pFile->lastErrno,
32455
- "winceCreateLock1", zFilename);
3245632476
sqlite3_free(zName);
32457
- return SQLITE_IOERR;
32477
+ return winLogError(SQLITE_IOERR, pFile->lastErrno,
32478
+ "winceCreateLock1", zFilename);
3245832479
}
3245932480
3246032481
/* Acquire the mutex before continuing */
3246132482
winceMutexAcquire(pFile->hMutex);
3246232483
@@ -32788,11 +32809,11 @@
3278832809
3278932810
if( (dwRet==INVALID_SET_FILE_POINTER
3279032811
&& ((lastErrno = osGetLastError())!=NO_ERROR)) ){
3279132812
pFile->lastErrno = lastErrno;
3279232813
winLogError(SQLITE_IOERR_SEEK, pFile->lastErrno,
32793
- "winSeekFile", pFile->zPath);
32814
+ "winSeekFile", pFile->zPath);
3279432815
OSTRACE(("SEEK file=%p, rc=SQLITE_IOERR_SEEK\n", pFile->h));
3279532816
return 1;
3279632817
}
3279732818
3279832819
OSTRACE(("SEEK file=%p, rc=SQLITE_OK\n", pFile->h));
@@ -32809,11 +32830,11 @@
3280932830
bRet = osSetFilePointerEx(pFile->h, x, 0, FILE_BEGIN);
3281032831
3281132832
if(!bRet){
3281232833
pFile->lastErrno = osGetLastError();
3281332834
winLogError(SQLITE_IOERR_SEEK, pFile->lastErrno,
32814
- "winSeekFile", pFile->zPath);
32835
+ "winSeekFile", pFile->zPath);
3281532836
OSTRACE(("SEEK file=%p, rc=SQLITE_IOERR_SEEK\n", pFile->h));
3281632837
return 1;
3281732838
}
3281832839
3281932840
OSTRACE(("SEEK file=%p, rc=SQLITE_OK\n", pFile->h));
@@ -32820,11 +32841,12 @@
3282032841
return 0;
3282132842
#endif
3282232843
}
3282332844
3282432845
#if SQLITE_MAX_MMAP_SIZE>0
32825
-/* Forward references to VFS methods */
32846
+/* Forward references to VFS helper methods used for memory mapped files */
32847
+static int winMapfile(winFile*, sqlite3_int64);
3282632848
static int winUnmapfile(winFile*);
3282732849
#endif
3282832850
3282932851
/*
3283032852
** Close a file.
@@ -32941,11 +32963,11 @@
3294132963
DWORD lastErrno;
3294232964
if( winRetryIoerr(&nRetry, &lastErrno) ) continue;
3294332965
pFile->lastErrno = lastErrno;
3294432966
OSTRACE(("READ file=%p, rc=SQLITE_IOERR_READ\n", pFile->h));
3294532967
return winLogError(SQLITE_IOERR_READ, pFile->lastErrno,
32946
- "winRead", pFile->zPath);
32968
+ "winRead", pFile->zPath);
3294732969
}
3294832970
winLogIoerr(nRetry);
3294932971
if( nRead<(DWORD)amt ){
3295032972
/* Unread parts of the buffer must be zero-filled */
3295132973
memset(&((char*)pBuf)[nRead], 0, amt-nRead);
@@ -33047,15 +33069,16 @@
3304733069
3304833070
if( rc ){
3304933071
if( ( pFile->lastErrno==ERROR_HANDLE_DISK_FULL )
3305033072
|| ( pFile->lastErrno==ERROR_DISK_FULL )){
3305133073
OSTRACE(("WRITE file=%p, rc=SQLITE_FULL\n", pFile->h));
33052
- return SQLITE_FULL;
33074
+ return winLogError(SQLITE_FULL, pFile->lastErrno,
33075
+ "winWrite1", pFile->zPath);
3305333076
}
3305433077
OSTRACE(("WRITE file=%p, rc=SQLITE_IOERR_WRITE\n", pFile->h));
3305533078
return winLogError(SQLITE_IOERR_WRITE, pFile->lastErrno,
33056
- "winWrite", pFile->zPath);
33079
+ "winWrite2", pFile->zPath);
3305733080
}else{
3305833081
winLogIoerr(nRetry);
3305933082
}
3306033083
OSTRACE(("WRITE file=%p, rc=SQLITE_OK\n", pFile->h));
3306133084
return SQLITE_OK;
@@ -33175,11 +33198,11 @@
3317533198
return SQLITE_OK;
3317633199
}else{
3317733200
pFile->lastErrno = osGetLastError();
3317833201
OSTRACE(("SYNC file=%p, rc=SQLITE_IOERR_FSYNC\n", pFile->h));
3317933202
return winLogError(SQLITE_IOERR_FSYNC, pFile->lastErrno,
33180
- "winSync", pFile->zPath);
33203
+ "winSync", pFile->zPath);
3318133204
}
3318233205
#endif
3318333206
}
3318433207
3318533208
/*
@@ -33216,11 +33239,11 @@
3321633239
*pSize = (((sqlite3_int64)upperBits)<<32) + lowerBits;
3321733240
if( (lowerBits == INVALID_FILE_SIZE)
3321833241
&& ((lastErrno = osGetLastError())!=NO_ERROR) ){
3321933242
pFile->lastErrno = lastErrno;
3322033243
rc = winLogError(SQLITE_IOERR_FSTAT, pFile->lastErrno,
33221
- "winFileSize", pFile->zPath);
33244
+ "winFileSize", pFile->zPath);
3322233245
}
3322333246
}
3322433247
#endif
3322533248
OSTRACE(("SIZE file=%p, pSize=%p, *pSize=%lld, rc=%s\n",
3322633249
pFile->h, pSize, *pSize, sqlite3ErrName(rc)));
@@ -33311,11 +33334,11 @@
3331133334
}
3331233335
#endif
3331333336
if( res==0 && ((lastErrno = osGetLastError())!=ERROR_NOT_LOCKED) ){
3331433337
pFile->lastErrno = lastErrno;
3331533338
winLogError(SQLITE_IOERR_UNLOCK, pFile->lastErrno,
33316
- "winUnlockReadLock", pFile->zPath);
33339
+ "winUnlockReadLock", pFile->zPath);
3331733340
}
3331833341
OSTRACE(("READ-UNLOCK file=%p, rc=%s\n", pFile->h, sqlite3ErrName(res)));
3331933342
return res;
3332033343
}
3332133344
@@ -33524,11 +33547,11 @@
3352433547
winUnlockFile(&pFile->h, SHARED_FIRST, 0, SHARED_SIZE, 0);
3352533548
if( locktype==SHARED_LOCK && !winGetReadLock(pFile) ){
3352633549
/* This should never happen. We should always be able to
3352733550
** reacquire the read lock */
3352833551
rc = winLogError(SQLITE_IOERR_UNLOCK, osGetLastError(),
33529
- "winUnlock", pFile->zPath);
33552
+ "winUnlock", pFile->zPath);
3353033553
}
3353133554
}
3353233555
if( type>=RESERVED_LOCK ){
3353333556
winUnlockFile(&pFile->h, RESERVED_BYTE, 0, 1, 0);
3353433557
}
@@ -33558,15 +33581,14 @@
3355833581
}else{
3355933582
pFile->ctrlFlags |= mask;
3356033583
}
3356133584
}
3356233585
33563
-/* Forward declaration */
33586
+/* Forward references to VFS helper methods used for temporary files */
3356433587
static int winGetTempname(sqlite3_vfs *, char **);
33565
-#if SQLITE_MAX_MMAP_SIZE>0
33566
-static int winMapfile(winFile*, sqlite3_int64);
33567
-#endif
33588
+static int winIsDir(const void *);
33589
+static BOOL winIsDriveLetterAndColon(const char *);
3356833590
3356933591
/*
3357033592
** Control and query of the open file handle.
3357133593
*/
3357233594
static int winFileControl(sqlite3_file *id, int op, void *pArg){
@@ -33640,11 +33662,11 @@
3364033662
char *zTFile = 0;
3364133663
int rc = winGetTempname(pFile->pVfs, &zTFile);
3364233664
if( rc==SQLITE_OK ){
3364333665
*(char**)pArg = zTFile;
3364433666
}
33645
- OSTRACE(("FCNTL file=%p, rc=%d\n", pFile->h, rc));
33667
+ OSTRACE(("FCNTL file=%p, rc=%s\n", pFile->h, sqlite3ErrName(rc)));
3364633668
return rc;
3364733669
}
3364833670
#if SQLITE_MAX_MMAP_SIZE>0
3364933671
case SQLITE_FCNTL_MMAP_SIZE: {
3365033672
i64 newLimit = *(i64*)pArg;
@@ -33658,11 +33680,11 @@
3365833680
if( pFile->mmapSize>0 ){
3365933681
(void)winUnmapfile(pFile);
3366033682
rc = winMapfile(pFile, -1);
3366133683
}
3366233684
}
33663
- OSTRACE(("FCNTL file=%p, rc=%d\n", pFile->h, rc));
33685
+ OSTRACE(("FCNTL file=%p, rc=%s\n", pFile->h, sqlite3ErrName(rc)));
3366433686
return rc;
3366533687
}
3366633688
#endif
3366733689
}
3366833690
OSTRACE(("FCNTL file=%p, rc=SQLITE_NOTFOUND\n", pFile->h));
@@ -33974,11 +33996,11 @@
3397433996
*/
3397533997
if( winShmSystemLock(pShmNode, _SHM_WRLCK, WIN_SHM_DMS, 1)==SQLITE_OK ){
3397633998
rc = winTruncate((sqlite3_file *)&pShmNode->hFile, 0);
3397733999
if( rc!=SQLITE_OK ){
3397834000
rc = winLogError(SQLITE_IOERR_SHMOPEN, osGetLastError(),
33979
- "winOpenShm", pDbFd->zPath);
34001
+ "winOpenShm", pDbFd->zPath);
3398034002
}
3398134003
}
3398234004
if( rc==SQLITE_OK ){
3398334005
winShmSystemLock(pShmNode, _SHM_UNLCK, WIN_SHM_DMS, 1);
3398434006
rc = winShmSystemLock(pShmNode, _SHM_RDLCK, WIN_SHM_DMS, 1);
@@ -34234,11 +34256,11 @@
3423434256
** large enough to contain the requested region).
3423534257
*/
3423634258
rc = winFileSize((sqlite3_file *)&pShmNode->hFile, &sz);
3423734259
if( rc!=SQLITE_OK ){
3423834260
rc = winLogError(SQLITE_IOERR_SHMSIZE, osGetLastError(),
34239
- "winShmMap1", pDbFd->zPath);
34261
+ "winShmMap1", pDbFd->zPath);
3424034262
goto shmpage_out;
3424134263
}
3424234264
3424334265
if( sz<nByte ){
3424434266
/* The requested memory region does not exist. If isWrite is set to
@@ -34249,11 +34271,11 @@
3424934271
*/
3425034272
if( !isWrite ) goto shmpage_out;
3425134273
rc = winTruncate((sqlite3_file *)&pShmNode->hFile, nByte);
3425234274
if( rc!=SQLITE_OK ){
3425334275
rc = winLogError(SQLITE_IOERR_SHMSIZE, osGetLastError(),
34254
- "winShmMap2", pDbFd->zPath);
34276
+ "winShmMap2", pDbFd->zPath);
3425534277
goto shmpage_out;
3425634278
}
3425734279
}
3425834280
3425934281
/* Map the requested memory region into this processes address space. */
@@ -34303,11 +34325,11 @@
3430334325
szRegion, pMap ? "ok" : "failed"));
3430434326
}
3430534327
if( !pMap ){
3430634328
pShmNode->lastErrno = osGetLastError();
3430734329
rc = winLogError(SQLITE_IOERR_SHMMAP, pShmNode->lastErrno,
34308
- "winShmMap3", pDbFd->zPath);
34330
+ "winShmMap3", pDbFd->zPath);
3430934331
if( hMap ) osCloseHandle(hMap);
3431034332
goto shmpage_out;
3431134333
}
3431234334
3431334335
pShmNode->aRegion[pShmNode->nRegion].pMap = pMap;
@@ -34351,11 +34373,11 @@
3435134373
pFile->lastErrno = osGetLastError();
3435234374
OSTRACE(("UNMAP-FILE pid=%lu, pFile=%p, pMapRegion=%p, "
3435334375
"rc=SQLITE_IOERR_MMAP\n", osGetCurrentProcessId(), pFile,
3435434376
pFile->pMapRegion));
3435534377
return winLogError(SQLITE_IOERR_MMAP, pFile->lastErrno,
34356
- "winUnmap1", pFile->zPath);
34378
+ "winUnmapfile1", pFile->zPath);
3435734379
}
3435834380
pFile->pMapRegion = 0;
3435934381
pFile->mmapSize = 0;
3436034382
pFile->mmapSizeActual = 0;
3436134383
}
@@ -34363,11 +34385,11 @@
3436334385
if( !osCloseHandle(pFile->hMap) ){
3436434386
pFile->lastErrno = osGetLastError();
3436534387
OSTRACE(("UNMAP-FILE pid=%lu, pFile=%p, hMap=%p, rc=SQLITE_IOERR_MMAP\n",
3436634388
osGetCurrentProcessId(), pFile, pFile->hMap));
3436734389
return winLogError(SQLITE_IOERR_MMAP, pFile->lastErrno,
34368
- "winUnmap2", pFile->zPath);
34390
+ "winUnmapfile2", pFile->zPath);
3436934391
}
3437034392
pFile->hMap = NULL;
3437134393
}
3437234394
OSTRACE(("UNMAP-FILE pid=%lu, pFile=%p, rc=SQLITE_OK\n",
3437334395
osGetCurrentProcessId(), pFile));
@@ -34438,14 +34460,14 @@
3443834460
(DWORD)(nMap & 0xffffffff), NULL);
3443934461
#endif
3444034462
if( pFd->hMap==NULL ){
3444134463
pFd->lastErrno = osGetLastError();
3444234464
rc = winLogError(SQLITE_IOERR_MMAP, pFd->lastErrno,
34443
- "winMapfile", pFd->zPath);
34465
+ "winMapfile1", pFd->zPath);
3444434466
/* Log the error, but continue normal operation using xRead/xWrite */
34445
- OSTRACE(("MAP-FILE-CREATE pid=%lu, pFile=%p, rc=SQLITE_IOERR_MMAP\n",
34446
- osGetCurrentProcessId(), pFd));
34467
+ OSTRACE(("MAP-FILE-CREATE pid=%lu, pFile=%p, rc=%s\n",
34468
+ osGetCurrentProcessId(), pFd, sqlite3ErrName(rc)));
3444734469
return SQLITE_OK;
3444834470
}
3444934471
assert( (nMap % winSysInfo.dwPageSize)==0 );
3445034472
assert( sizeof(SIZE_T)==sizeof(sqlite3_int64) || nMap<=0xffffffff );
3445134473
#if SQLITE_OS_WINRT
@@ -34455,14 +34477,15 @@
3445534477
#endif
3445634478
if( pNew==NULL ){
3445734479
osCloseHandle(pFd->hMap);
3445834480
pFd->hMap = NULL;
3445934481
pFd->lastErrno = osGetLastError();
34460
- winLogError(SQLITE_IOERR_MMAP, pFd->lastErrno,
34461
- "winMapfile", pFd->zPath);
34462
- OSTRACE(("MAP-FILE-MAP pid=%lu, pFile=%p, rc=SQLITE_IOERR_MMAP\n",
34463
- osGetCurrentProcessId(), pFd));
34482
+ rc = winLogError(SQLITE_IOERR_MMAP, pFd->lastErrno,
34483
+ "winMapfile2", pFd->zPath);
34484
+ /* Log the error, but continue normal operation using xRead/xWrite */
34485
+ OSTRACE(("MAP-FILE-MAP pid=%lu, pFile=%p, rc=%s\n",
34486
+ osGetCurrentProcessId(), pFd, sqlite3ErrName(rc)));
3446434487
return SQLITE_OK;
3446534488
}
3446634489
pFd->pMapRegion = pNew;
3446734490
pFd->mmapSize = nMap;
3446834491
pFd->mmapSizeActual = nMap;
@@ -34596,18 +34619,37 @@
3459634619
**************************** sqlite3_vfs methods ****************************
3459734620
**
3459834621
** This division contains the implementation of methods on the
3459934622
** sqlite3_vfs object.
3460034623
*/
34624
+
34625
+/*
34626
+** Convert a filename from whatever the underlying operating system
34627
+** supports for filenames into UTF-8. Space to hold the result is
34628
+** obtained from malloc and must be freed by the calling function.
34629
+*/
34630
+static char *winConvertToUtf8Filename(const void *zFilename){
34631
+ char *zConverted = 0;
34632
+ if( osIsNT() ){
34633
+ zConverted = winUnicodeToUtf8(zFilename);
34634
+ }
34635
+#ifdef SQLITE_WIN32_HAS_ANSI
34636
+ else{
34637
+ zConverted = sqlite3_win32_mbcs_to_utf8(zFilename);
34638
+ }
34639
+#endif
34640
+ /* caller will handle out of memory */
34641
+ return zConverted;
34642
+}
3460134643
3460234644
/*
3460334645
** Convert a UTF-8 filename into whatever form the underlying
3460434646
** operating system wants filenames in. Space to hold the result
3460534647
** is obtained from malloc and must be freed by the calling
3460634648
** function.
3460734649
*/
34608
-static void *winConvertUtf8Filename(const char *zFilename){
34650
+static void *winConvertFromUtf8Filename(const char *zFilename){
3460934651
void *zConverted = 0;
3461034652
if( osIsNT() ){
3461134653
zConverted = winUtf8ToUnicode(zFilename);
3461234654
}
3461334655
#ifdef SQLITE_WIN32_HAS_ANSI
@@ -34668,11 +34710,94 @@
3466834710
if( sqlite3_temp_directory ){
3466934711
sqlite3_snprintf(nBuf-30, zBuf, "%s%s", sqlite3_temp_directory,
3467034712
winEndsInDirSep(sqlite3_temp_directory) ? "" :
3467134713
winGetDirDep());
3467234714
}
34673
-#if !SQLITE_OS_WINRT
34715
+#if defined(__CYGWIN__)
34716
+ else{
34717
+ static const char *azDirs[] = {
34718
+ 0, /* getenv("SQLITE_TMPDIR") */
34719
+ 0, /* getenv("TMPDIR") */
34720
+ 0, /* getenv("TMP") */
34721
+ 0, /* getenv("TEMP") */
34722
+ 0, /* getenv("USERPROFILE") */
34723
+ "/var/tmp",
34724
+ "/usr/tmp",
34725
+ "/tmp",
34726
+ ".",
34727
+ 0 /* List terminator */
34728
+ };
34729
+ unsigned int i;
34730
+ const char *zDir = 0;
34731
+
34732
+ if( !azDirs[0] ) azDirs[0] = getenv("SQLITE_TMPDIR");
34733
+ if( !azDirs[1] ) azDirs[1] = getenv("TMPDIR");
34734
+ if( !azDirs[2] ) azDirs[2] = getenv("TMP");
34735
+ if( !azDirs[3] ) azDirs[3] = getenv("TEMP");
34736
+ if( !azDirs[4] ) azDirs[4] = getenv("USERPROFILE");
34737
+ for(i=0; i<sizeof(azDirs)/sizeof(azDirs[0]); zDir=azDirs[i++]){
34738
+ void *zConverted;
34739
+ if( zDir==0 ) continue;
34740
+ /* If the path starts with a drive letter followed by the colon
34741
+ ** character, assume it is already a native Win32 path; otherwise,
34742
+ ** it must be converted to a native Win32 path prior via the Cygwin
34743
+ ** API prior to using it.
34744
+ */
34745
+ if( winIsDriveLetterAndColon(zDir) ){
34746
+ zConverted = winConvertFromUtf8Filename(zDir);
34747
+ if( !zConverted ){
34748
+ OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
34749
+ return SQLITE_IOERR_NOMEM;
34750
+ }
34751
+ if( winIsDir(zConverted) ){
34752
+ sqlite3_snprintf(nBuf-30, zBuf, "%s", zDir);
34753
+ sqlite3_free(zConverted);
34754
+ break;
34755
+ }
34756
+ sqlite3_free(zConverted);
34757
+ }else{
34758
+ zConverted = sqlite3MallocZero( nBuf+1 );
34759
+ if( !zConverted ){
34760
+ OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
34761
+ return SQLITE_IOERR_NOMEM;
34762
+ }
34763
+ if( cygwin_conv_path(
34764
+ osIsNT() ? CCP_POSIX_TO_WIN_W : CCP_POSIX_TO_WIN_A, zDir,
34765
+ zConverted, nBuf+1)<0 ){
34766
+ sqlite3_free(zConverted);
34767
+ OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_CONVPATH\n"));
34768
+ return winLogError(SQLITE_IOERR_CONVPATH, (DWORD)errno,
34769
+ "winGetTempname1", zDir);
34770
+ }
34771
+ if( winIsDir(zConverted) ){
34772
+ /* At this point, we know the candidate directory exists and should
34773
+ ** be used. However, we may need to convert the string containing
34774
+ ** its name into UTF-8 (i.e. if it is UTF-16 right now).
34775
+ */
34776
+ if( osIsNT() ){
34777
+ char *zUtf8 = winUnicodeToUtf8(zConverted);
34778
+ if( !zUtf8 ){
34779
+ sqlite3_free(zConverted);
34780
+ OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
34781
+ return SQLITE_IOERR_NOMEM;
34782
+ }
34783
+ sqlite3_snprintf(nBuf-30, zBuf, "%s", zUtf8);
34784
+ sqlite3_free(zUtf8);
34785
+ sqlite3_free(zConverted);
34786
+ break;
34787
+ }else{
34788
+ sqlite3_snprintf(nBuf-30, zBuf, "%s", zConverted);
34789
+ sqlite3_free(zConverted);
34790
+ break;
34791
+ }
34792
+ }
34793
+ sqlite3_free(zConverted);
34794
+ }
34795
+ break;
34796
+ }
34797
+ }
34798
+#elif !SQLITE_OS_WINRT && !defined(__CYGWIN__)
3467434799
else if( osIsNT() ){
3467534800
char *zMulti;
3467634801
LPWSTR zWidePath = sqlite3MallocZero( nBuf*sizeof(WCHAR) );
3467734802
if( !zWidePath ){
3467834803
sqlite3_free(zBuf);
@@ -34681,11 +34806,12 @@
3468134806
}
3468234807
if( osGetTempPathW(nBuf, zWidePath)==0 ){
3468334808
sqlite3_free(zWidePath);
3468434809
sqlite3_free(zBuf);
3468534810
OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_GETTEMPPATH\n"));
34686
- return SQLITE_IOERR_GETTEMPPATH;
34811
+ return winLogError(SQLITE_IOERR_GETTEMPPATH, osGetLastError(),
34812
+ "winGetTempname1", 0);
3468734813
}
3468834814
zMulti = winUnicodeToUtf8(zWidePath);
3468934815
if( zMulti ){
3469034816
sqlite3_snprintf(nBuf-30, zBuf, "%s", zMulti);
3469134817
sqlite3_free(zMulti);
@@ -34707,11 +34833,12 @@
3470734833
return SQLITE_IOERR_NOMEM;
3470834834
}
3470934835
if( osGetTempPathA(nBuf, zMbcsPath)==0 ){
3471034836
sqlite3_free(zBuf);
3471134837
OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_GETTEMPPATH\n"));
34712
- return SQLITE_IOERR_GETTEMPPATH;
34838
+ return winLogError(SQLITE_IOERR_GETTEMPPATH, osGetLastError(),
34839
+ "winGetTempname2", 0);
3471334840
}
3471434841
zUtf8 = sqlite3_win32_mbcs_to_utf8(zMbcsPath);
3471534842
if( zUtf8 ){
3471634843
sqlite3_snprintf(nBuf-30, zBuf, "%s", zUtf8);
3471734844
sqlite3_free(zUtf8);
@@ -34730,11 +34857,11 @@
3473034857
nLen = sqlite3Strlen30(zBuf);
3473134858
3473234859
if( (nLen + sqlite3Strlen30(SQLITE_TEMP_FILE_PREFIX) + 18) >= nBuf ){
3473334860
sqlite3_free(zBuf);
3473434861
OSTRACE(("TEMP-FILENAME rc=SQLITE_ERROR\n"));
34735
- return SQLITE_ERROR;
34862
+ return winLogError(SQLITE_ERROR, 0, "winGetTempname3", 0);
3473634863
}
3473734864
3473834865
sqlite3_snprintf(nBuf-18-nLen, zBuf+nLen, SQLITE_TEMP_FILE_PREFIX);
3473934866
3474034867
j = sqlite3Strlen30(zBuf);
@@ -34886,11 +35013,11 @@
3488635013
*/
3488735014
assert( (eType!=SQLITE_OPEN_MAIN_DB) || (flags & SQLITE_OPEN_URI) ||
3488835015
zUtf8Name[sqlite3Strlen30(zUtf8Name)+1]==0 );
3488935016
3489035017
/* Convert the filename to the system encoding. */
34891
- zConverted = winConvertUtf8Filename(zUtf8Name);
35018
+ zConverted = winConvertFromUtf8Filename(zUtf8Name);
3489235019
if( zConverted==0 ){
3489335020
sqlite3_free(zTmpname);
3489435021
OSTRACE(("OPEN name=%s, rc=SQLITE_IOERR_NOMEM", zUtf8Name));
3489535022
return SQLITE_IOERR_NOMEM;
3489635023
}
@@ -35087,11 +35214,11 @@
3508735214
UNUSED_PARAMETER(syncDir);
3508835215
3508935216
SimulateIOError(return SQLITE_IOERR_DELETE);
3509035217
OSTRACE(("DELETE name=%s, syncDir=%d\n", zFilename, syncDir));
3509135218
35092
- zConverted = winConvertUtf8Filename(zFilename);
35219
+ zConverted = winConvertFromUtf8Filename(zFilename);
3509335220
if( zConverted==0 ){
3509435221
OSTRACE(("DELETE name=%s, rc=SQLITE_IOERR_NOMEM\n", zFilename));
3509535222
return SQLITE_IOERR_NOMEM;
3509635223
}
3509735224
if( osIsNT() ){
@@ -35167,12 +35294,11 @@
3516735294
}
3516835295
} while(1);
3516935296
}
3517035297
#endif
3517135298
if( rc && rc!=SQLITE_IOERR_DELETE_NOENT ){
35172
- rc = winLogError(SQLITE_IOERR_DELETE, lastErrno,
35173
- "winDelete", zFilename);
35299
+ rc = winLogError(SQLITE_IOERR_DELETE, lastErrno, "winDelete", zFilename);
3517435300
}else{
3517535301
winLogIoerr(cnt);
3517635302
}
3517735303
sqlite3_free(zConverted);
3517835304
OSTRACE(("DELETE name=%s, rc=%s\n", zFilename, sqlite3ErrName(rc)));
@@ -35196,11 +35322,11 @@
3519635322
3519735323
SimulateIOError( return SQLITE_IOERR_ACCESS; );
3519835324
OSTRACE(("ACCESS name=%s, flags=%x, pResOut=%p\n",
3519935325
zFilename, flags, pResOut));
3520035326
35201
- zConverted = winConvertUtf8Filename(zFilename);
35327
+ zConverted = winConvertFromUtf8Filename(zFilename);
3520235328
if( zConverted==0 ){
3520335329
OSTRACE(("ACCESS name=%s, rc=SQLITE_IOERR_NOMEM\n", zFilename));
3520435330
return SQLITE_IOERR_NOMEM;
3520535331
}
3520635332
if( osIsNT() ){
@@ -35222,13 +35348,13 @@
3522235348
attr = sAttrData.dwFileAttributes;
3522335349
}
3522435350
}else{
3522535351
winLogIoerr(cnt);
3522635352
if( lastErrno!=ERROR_FILE_NOT_FOUND && lastErrno!=ERROR_PATH_NOT_FOUND ){
35227
- winLogError(SQLITE_IOERR_ACCESS, lastErrno, "winAccess", zFilename);
3522835353
sqlite3_free(zConverted);
35229
- return SQLITE_IOERR_ACCESS;
35354
+ return winLogError(SQLITE_IOERR_ACCESS, lastErrno, "winAccess",
35355
+ zFilename);
3523035356
}else{
3523135357
attr = INVALID_FILE_ATTRIBUTES;
3523235358
}
3523335359
}
3523435360
}
@@ -35254,10 +35380,19 @@
3525435380
OSTRACE(("ACCESS name=%s, pResOut=%p, *pResOut=%d, rc=SQLITE_OK\n",
3525535381
zFilename, pResOut, *pResOut));
3525635382
return SQLITE_OK;
3525735383
}
3525835384
35385
+/*
35386
+** Returns non-zero if the specified path name starts with a drive letter
35387
+** followed by a colon character.
35388
+*/
35389
+static BOOL winIsDriveLetterAndColon(
35390
+ const char *zPathname
35391
+){
35392
+ return ( sqlite3Isalpha(zPathname[0]) && zPathname[1]==':' );
35393
+}
3525935394
3526035395
/*
3526135396
** Returns non-zero if the specified path name should be used verbatim. If
3526235397
** non-zero is returned from this function, the calling function must simply
3526335398
** use the provided path name verbatim -OR- resolve it into a full path name
@@ -35281,11 +35416,11 @@
3528135416
** If the path name starts with a letter and a colon it is either a volume
3528235417
** relative path or an absolute path. Callers of this function must not
3528335418
** attempt to treat it as a relative path name (i.e. they should simply use
3528435419
** it verbatim).
3528535420
*/
35286
- if ( sqlite3Isalpha(zPathname[0]) && zPathname[1]==':' ){
35421
+ if ( winIsDriveLetterAndColon(zPathname) ){
3528735422
return TRUE;
3528835423
}
3528935424
3529035425
/*
3529135426
** If we get to this point, the path name should almost certainly be a purely
@@ -35317,28 +35452,25 @@
3531735452
** for converting the relative path name to an absolute
3531835453
** one by prepending the data directory and a slash.
3531935454
*/
3532035455
char *zOut = sqlite3MallocZero( pVfs->mxPathname+1 );
3532135456
if( !zOut ){
35322
- winLogError(SQLITE_IOERR_NOMEM, 0, "winFullPathname", zRelative);
3532335457
return SQLITE_IOERR_NOMEM;
3532435458
}
3532535459
if( cygwin_conv_path(CCP_POSIX_TO_WIN_A|CCP_RELATIVE, zRelative, zOut,
3532635460
pVfs->mxPathname+1)<0 ){
35327
- winLogError(SQLITE_CANTOPEN_FULLPATH, (DWORD)errno, "cygwin_conv_path",
35328
- zRelative);
3532935461
sqlite3_free(zOut);
35330
- return SQLITE_CANTOPEN_FULLPATH;
35462
+ return winLogError(SQLITE_CANTOPEN_CONVPATH, (DWORD)errno,
35463
+ "winFullPathname1", zRelative);
3533135464
}
3533235465
sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s%s%s",
3533335466
sqlite3_data_directory, winGetDirDep(), zOut);
3533435467
sqlite3_free(zOut);
3533535468
}else{
3533635469
if( cygwin_conv_path(CCP_POSIX_TO_WIN_A, zRelative, zFull, nFull)<0 ){
35337
- winLogError(SQLITE_CANTOPEN_FULLPATH, (DWORD)errno, "cygwin_conv_path",
35338
- zRelative);
35339
- return SQLITE_CANTOPEN_FULLPATH;
35470
+ return winLogError(SQLITE_CANTOPEN_CONVPATH, (DWORD)errno,
35471
+ "winFullPathname2", zRelative);
3534035472
}
3534135473
}
3534235474
return SQLITE_OK;
3534335475
#endif
3534435476
@@ -35367,11 +35499,11 @@
3536735499
char *zOut;
3536835500
3536935501
/* If this path name begins with "/X:", where "X" is any alphabetic
3537035502
** character, discard the initial "/" from the pathname.
3537135503
*/
35372
- if( zRelative[0]=='/' && sqlite3Isalpha(zRelative[1]) && zRelative[2]==':' ){
35504
+ if( zRelative[0]=='/' && winIsDriveLetterAndColon(zRelative+1) ){
3537335505
zRelative++;
3537435506
}
3537535507
3537635508
/* It's odd to simulate an io-error here, but really this is just
3537735509
** using the io-error infrastructure to test that SQLite handles this
@@ -35388,36 +35520,34 @@
3538835520
*/
3538935521
sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s%s%s",
3539035522
sqlite3_data_directory, winGetDirDep(), zRelative);
3539135523
return SQLITE_OK;
3539235524
}
35393
- zConverted = winConvertUtf8Filename(zRelative);
35525
+ zConverted = winConvertFromUtf8Filename(zRelative);
3539435526
if( zConverted==0 ){
3539535527
return SQLITE_IOERR_NOMEM;
3539635528
}
3539735529
if( osIsNT() ){
3539835530
LPWSTR zTemp;
3539935531
nByte = osGetFullPathNameW((LPCWSTR)zConverted, 0, 0, 0);
3540035532
if( nByte==0 ){
35401
- winLogError(SQLITE_ERROR, osGetLastError(),
35402
- "GetFullPathNameW1", zConverted);
3540335533
sqlite3_free(zConverted);
35404
- return SQLITE_CANTOPEN_FULLPATH;
35534
+ return winLogError(SQLITE_CANTOPEN_FULLPATH, osGetLastError(),
35535
+ "winFullPathname1", zRelative);
3540535536
}
3540635537
nByte += 3;
3540735538
zTemp = sqlite3MallocZero( nByte*sizeof(zTemp[0]) );
3540835539
if( zTemp==0 ){
3540935540
sqlite3_free(zConverted);
3541035541
return SQLITE_IOERR_NOMEM;
3541135542
}
3541235543
nByte = osGetFullPathNameW((LPCWSTR)zConverted, nByte, zTemp, 0);
3541335544
if( nByte==0 ){
35414
- winLogError(SQLITE_ERROR, osGetLastError(),
35415
- "GetFullPathNameW2", zConverted);
3541635545
sqlite3_free(zConverted);
3541735546
sqlite3_free(zTemp);
35418
- return SQLITE_CANTOPEN_FULLPATH;
35547
+ return winLogError(SQLITE_CANTOPEN_FULLPATH, osGetLastError(),
35548
+ "winFullPathname2", zRelative);
3541935549
}
3542035550
sqlite3_free(zConverted);
3542135551
zOut = winUnicodeToUtf8(zTemp);
3542235552
sqlite3_free(zTemp);
3542335553
}
@@ -35424,28 +35554,26 @@
3542435554
#ifdef SQLITE_WIN32_HAS_ANSI
3542535555
else{
3542635556
char *zTemp;
3542735557
nByte = osGetFullPathNameA((char*)zConverted, 0, 0, 0);
3542835558
if( nByte==0 ){
35429
- winLogError(SQLITE_ERROR, osGetLastError(),
35430
- "GetFullPathNameA1", zConverted);
3543135559
sqlite3_free(zConverted);
35432
- return SQLITE_CANTOPEN_FULLPATH;
35560
+ return winLogError(SQLITE_CANTOPEN_FULLPATH, osGetLastError(),
35561
+ "winFullPathname3", zRelative);
3543335562
}
3543435563
nByte += 3;
3543535564
zTemp = sqlite3MallocZero( nByte*sizeof(zTemp[0]) );
3543635565
if( zTemp==0 ){
3543735566
sqlite3_free(zConverted);
3543835567
return SQLITE_IOERR_NOMEM;
3543935568
}
3544035569
nByte = osGetFullPathNameA((char*)zConverted, nByte, zTemp, 0);
3544135570
if( nByte==0 ){
35442
- winLogError(SQLITE_ERROR, osGetLastError(),
35443
- "GetFullPathNameA2", zConverted);
3544435571
sqlite3_free(zConverted);
3544535572
sqlite3_free(zTemp);
35446
- return SQLITE_CANTOPEN_FULLPATH;
35573
+ return winLogError(SQLITE_CANTOPEN_FULLPATH, osGetLastError(),
35574
+ "winFullPathname4", zRelative);
3544735575
}
3544835576
sqlite3_free(zConverted);
3544935577
zOut = sqlite3_win32_mbcs_to_utf8(zTemp);
3545035578
sqlite3_free(zTemp);
3545135579
}
@@ -35469,11 +35597,11 @@
3546935597
** Interfaces for opening a shared library, finding entry points
3547035598
** within the shared library, and closing the shared library.
3547135599
*/
3547235600
static void *winDlOpen(sqlite3_vfs *pVfs, const char *zFilename){
3547335601
HANDLE h;
35474
- void *zConverted = winConvertUtf8Filename(zFilename);
35602
+ void *zConverted = winConvertFromUtf8Filename(zFilename);
3547535603
UNUSED_PARAMETER(pVfs);
3547635604
if( zConverted==0 ){
3547735605
return 0;
3547835606
}
3547935607
if( osIsNT() ){
@@ -60283,10 +60411,13 @@
6028360411
alloc.pParse = pParse;
6028460412
alloc.pIdx = pIdx;
6028560413
alloc.ppRec = ppRec;
6028660414
alloc.iVal = iVal;
6028760415
60416
+ /* Skip over any TK_COLLATE nodes */
60417
+ pExpr = sqlite3ExprSkipCollate(pExpr);
60418
+
6028860419
if( !pExpr ){
6028960420
pVal = valueNew(pParse->db, &alloc);
6029060421
if( pVal ){
6029160422
sqlite3VdbeMemSetNull((Mem*)pVal);
6029260423
*pbOk = 1;
@@ -80950,11 +81081,11 @@
8095081081
** SQLITE_ENABLE_STAT3 defined. The functionality of sqlite_stat3
8095181082
** is a superset of sqlite_stat2. The sqlite_stat4 is an enhanced
8095281083
** version of sqlite_stat3 and is only available when compiled with
8095381084
** SQLITE_ENABLE_STAT4 and in SQLite versions 3.8.0 and later. It is
8095481085
** not possible to enable both STAT3 and STAT4 at the same time. If they
80955
-** are both enabled, then STAT4 is precedence.
81086
+** are both enabled, then STAT4 takes precedence.
8095681087
**
8095781088
** For most applications, sqlite_stat1 provides all the statisics required
8095881089
** for the query planner to make good choices.
8095981090
**
8096081091
** Format of sqlite_stat1:
@@ -81261,11 +81392,11 @@
8126181392
u8 *pSpace; /* Allocated space not yet assigned */
8126281393
int i; /* Used to iterate through p->aSample[] */
8126381394
8126481395
p->iGet = -1;
8126581396
p->mxSample = mxSample;
81266
- p->nPSample = sqlite3_value_int64(argv[1])/(mxSample/3+1) + 1;
81397
+ p->nPSample = (tRowcnt)(sqlite3_value_int64(argv[1])/(mxSample/3+1) + 1);
8126781398
p->current.anLt = &p->current.anEq[nColUp];
8126881399
sqlite3_randomness(sizeof(p->iPrn), &p->iPrn);
8126981400
8127081401
/* Set up the Stat4Accum.a[] and aBest[] arrays */
8127181402
p->a = (struct Stat4Sample*)&p->current.anLt[nColUp];
@@ -81298,29 +81429,68 @@
8129881429
0, /* xFinalize */
8129981430
"stat_init", /* zName */
8130081431
0, /* pHash */
8130181432
0 /* pDestructor */
8130281433
};
81434
+
81435
+#ifdef SQLITE_ENABLE_STAT4
81436
+/*
81437
+** pNew and pOld are both candidate non-periodic samples selected for
81438
+** the same column (pNew->iCol==pOld->iCol). Ignoring this column and
81439
+** considering only any trailing columns and the sample hash value, this
81440
+** function returns true if sample pNew is to be preferred over pOld.
81441
+** In other words, if we assume that the cardinalities of the selected
81442
+** column for pNew and pOld are equal, is pNew to be preferred over pOld.
81443
+**
81444
+** This function assumes that for each argument sample, the contents of
81445
+** the anEq[] array from pSample->anEq[pSample->iCol+1] onwards are valid.
81446
+*/
81447
+static int sampleIsBetterPost(
81448
+ Stat4Accum *pAccum,
81449
+ Stat4Sample *pNew,
81450
+ Stat4Sample *pOld
81451
+){
81452
+ int nCol = pAccum->nCol;
81453
+ int i;
81454
+ assert( pNew->iCol==pOld->iCol );
81455
+ for(i=pNew->iCol+1; i<nCol; i++){
81456
+ if( pNew->anEq[i]>pOld->anEq[i] ) return 1;
81457
+ if( pNew->anEq[i]<pOld->anEq[i] ) return 0;
81458
+ }
81459
+ if( pNew->iHash>pOld->iHash ) return 1;
81460
+ return 0;
81461
+}
81462
+#endif
8130381463
8130481464
#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
8130581465
/*
8130681466
** Return true if pNew is to be preferred over pOld.
81467
+**
81468
+** This function assumes that for each argument sample, the contents of
81469
+** the anEq[] array from pSample->anEq[pSample->iCol] onwards are valid.
8130781470
*/
81308
-static int sampleIsBetter(Stat4Sample *pNew, Stat4Sample *pOld){
81471
+static int sampleIsBetter(
81472
+ Stat4Accum *pAccum,
81473
+ Stat4Sample *pNew,
81474
+ Stat4Sample *pOld
81475
+){
8130981476
tRowcnt nEqNew = pNew->anEq[pNew->iCol];
8131081477
tRowcnt nEqOld = pOld->anEq[pOld->iCol];
8131181478
8131281479
assert( pOld->isPSample==0 && pNew->isPSample==0 );
8131381480
assert( IsStat4 || (pNew->iCol==0 && pOld->iCol==0) );
8131481481
81315
- if( (nEqNew>nEqOld)
81316
- || (nEqNew==nEqOld && pNew->iCol<pOld->iCol)
81317
- || (nEqNew==nEqOld && pNew->iCol==pOld->iCol && pNew->iHash>pOld->iHash)
81318
- ){
81319
- return 1;
81482
+ if( (nEqNew>nEqOld) ) return 1;
81483
+#ifdef SQLITE_ENABLE_STAT4
81484
+ if( nEqNew==nEqOld ){
81485
+ if( pNew->iCol<pOld->iCol ) return 1;
81486
+ return (pNew->iCol==pOld->iCol && sampleIsBetterPost(pAccum, pNew, pOld));
8132081487
}
8132181488
return 0;
81489
+#else
81490
+ return (nEqNew==nEqOld && pNew->iHash>pOld->iHash);
81491
+#endif
8132281492
}
8132381493
8132481494
/*
8132581495
** Copy the contents of object (*pFrom) into (*pTo).
8132681496
*/
@@ -81339,15 +81509,14 @@
8133981509
** remove the least desirable sample from p->a[] to make room.
8134081510
*/
8134181511
static void sampleInsert(Stat4Accum *p, Stat4Sample *pNew, int nEqZero){
8134281512
Stat4Sample *pSample;
8134381513
int i;
81344
- i64 iSeq;
81345
- i64 iPos;
8134681514
8134781515
assert( IsStat4 || nEqZero==0 );
8134881516
81517
+#ifdef SQLITE_ENABLE_STAT4
8134981518
if( pNew->isPSample==0 ){
8135081519
Stat4Sample *pUpgrade = 0;
8135181520
assert( pNew->anEq[pNew->iCol]>0 );
8135281521
8135381522
/* This sample is being added because the prefix that ends in column
@@ -81357,12 +81526,13 @@
8135781526
** existing sample that shares this prefix. */
8135881527
for(i=p->nSample-1; i>=0; i--){
8135981528
Stat4Sample *pOld = &p->a[i];
8136081529
if( pOld->anEq[pNew->iCol]==0 ){
8136181530
if( pOld->isPSample ) return;
81362
- assert( sampleIsBetter(pNew, pOld) );
81363
- if( pUpgrade==0 || sampleIsBetter(pOld, pUpgrade) ){
81531
+ assert( pOld->iCol>pNew->iCol );
81532
+ assert( sampleIsBetter(p, pNew, pOld) );
81533
+ if( pUpgrade==0 || sampleIsBetter(p, pOld, pUpgrade) ){
8136481534
pUpgrade = pOld;
8136581535
}
8136681536
}
8136781537
}
8136881538
if( pUpgrade ){
@@ -81369,10 +81539,11 @@
8136981539
pUpgrade->iCol = pNew->iCol;
8137081540
pUpgrade->anEq[pUpgrade->iCol] = pNew->anEq[pUpgrade->iCol];
8137181541
goto find_new_min;
8137281542
}
8137381543
}
81544
+#endif
8137481545
8137581546
/* If necessary, remove sample iMin to make room for the new sample. */
8137681547
if( p->nSample>=p->mxSample ){
8137781548
Stat4Sample *pMin = &p->a[p->iMin];
8137881549
tRowcnt *anEq = pMin->anEq;
@@ -81384,40 +81555,34 @@
8138481555
pSample->anDLt = anDLt;
8138581556
pSample->anLt = anLt;
8138681557
p->nSample = p->mxSample-1;
8138781558
}
8138881559
81389
- /* Figure out where in the a[] array the new sample should be inserted. */
81390
- iSeq = pNew->anLt[p->nCol-1];
81391
- for(iPos=p->nSample; iPos>0; iPos--){
81392
- if( iSeq>p->a[iPos-1].anLt[p->nCol-1] ) break;
81393
- }
81560
+ /* The "rows less-than" for the rowid column must be greater than that
81561
+ ** for the last sample in the p->a[] array. Otherwise, the samples would
81562
+ ** be out of order. */
81563
+#ifdef SQLITE_ENABLE_STAT4
81564
+ assert( p->nSample==0
81565
+ || pNew->anLt[p->nCol-1] > p->a[p->nSample-1].anLt[p->nCol-1] );
81566
+#endif
8139481567
8139581568
/* Insert the new sample */
81396
- pSample = &p->a[iPos];
81397
- if( iPos!=p->nSample ){
81398
- Stat4Sample *pEnd = &p->a[p->nSample];
81399
- tRowcnt *anEq = pEnd->anEq;
81400
- tRowcnt *anLt = pEnd->anLt;
81401
- tRowcnt *anDLt = pEnd->anDLt;
81402
- memmove(&p->a[iPos], &p->a[iPos+1], (p->nSample-iPos)*sizeof(p->a[0]));
81403
- pSample->anEq = anEq;
81404
- pSample->anDLt = anDLt;
81405
- pSample->anLt = anLt;
81406
- }
81407
- p->nSample++;
81569
+ pSample = &p->a[p->nSample];
8140881570
sampleCopy(p, pSample, pNew);
81571
+ p->nSample++;
8140981572
8141081573
/* Zero the first nEqZero entries in the anEq[] array. */
8141181574
memset(pSample->anEq, 0, sizeof(tRowcnt)*nEqZero);
8141281575
81576
+#ifdef SQLITE_ENABLE_STAT4
8141381577
find_new_min:
81578
+#endif
8141481579
if( p->nSample>=p->mxSample ){
8141581580
int iMin = -1;
8141681581
for(i=0; i<p->mxSample; i++){
8141781582
if( p->a[i].isPSample ) continue;
81418
- if( iMin<0 || sampleIsBetter(&p->a[iMin], &p->a[i]) ){
81583
+ if( iMin<0 || sampleIsBetter(p, &p->a[iMin], &p->a[i]) ){
8141981584
iMin = i;
8142081585
}
8142181586
}
8142281587
assert( iMin>=0 );
8142381588
p->iMin = iMin;
@@ -81437,13 +81602,12 @@
8143781602
8143881603
/* Check if any samples from the aBest[] array should be pushed
8143981604
** into IndexSample.a[] at this point. */
8144081605
for(i=(p->nCol-2); i>=iChng; i--){
8144181606
Stat4Sample *pBest = &p->aBest[i];
81442
- if( p->nSample<p->mxSample
81443
- || sampleIsBetter(pBest, &p->a[p->iMin])
81444
- ){
81607
+ pBest->anEq[i] = p->current.anEq[i];
81608
+ if( p->nSample<p->mxSample || sampleIsBetter(p, pBest, &p->a[p->iMin]) ){
8144581609
sampleInsert(p, pBest, i);
8144681610
}
8144781611
}
8144881612
8144981613
/* Update the anEq[] fields of any samples already collected. */
@@ -81466,11 +81630,13 @@
8146681630
sampleInsert(p, &p->current, 0);
8146781631
p->current.isPSample = 0;
8146881632
}else
8146981633
8147081634
/* Or if it is a non-periodic sample. Add it in this case too. */
81471
- if( p->nSample<p->mxSample || sampleIsBetter(&p->current, &p->a[p->iMin]) ){
81635
+ if( p->nSample<p->mxSample
81636
+ || sampleIsBetter(p, &p->current, &p->a[p->iMin])
81637
+ ){
8147281638
sampleInsert(p, &p->current, 0);
8147381639
}
8147481640
}
8147581641
#endif
8147681642
}
@@ -81500,12 +81666,11 @@
8150081666
8150181667
assert( p->nCol>1 ); /* Includes rowid field */
8150281668
assert( iChng<p->nCol );
8150381669
8150481670
if( p->nRow==0 ){
81505
- /* anEq[0] is only zero for the very first call to this function. Do
81506
- ** appropriate initialization */
81671
+ /* This is the first call to this function. Do initialization. */
8150781672
for(i=0; i<p->nCol; i++) p->current.anEq[i] = 1;
8150881673
}else{
8150981674
/* Second and subsequent calls get processed here */
8151081675
samplePushPrevious(p, iChng);
8151181676
@@ -81541,11 +81706,11 @@
8154181706
}
8154281707
8154381708
/* Update the aBest[] array. */
8154481709
for(i=0; i<(p->nCol-1); i++){
8154581710
p->current.iCol = i;
81546
- if( i>=iChng || sampleIsBetter(&p->current, &p->aBest[i]) ){
81711
+ if( i>=iChng || sampleIsBetterPost(p, &p->current, &p->aBest[i]) ){
8154781712
sampleCopy(p, &p->aBest[i], &p->current);
8154881713
}
8154981714
}
8155081715
}
8155181716
#endif
@@ -82249,11 +82414,11 @@
8224982414
IndexSample *pFinal = &aSample[pIdx->nSample-1];
8225082415
int iCol;
8225182416
for(iCol=0; iCol<pIdx->nColumn; iCol++){
8225282417
int i; /* Used to iterate through samples */
8225382418
tRowcnt sumEq = 0; /* Sum of the nEq values */
82254
- int nSum = 0; /* Number of terms contributing to sumEq */
82419
+ tRowcnt nSum = 0; /* Number of terms contributing to sumEq */
8225582420
tRowcnt avgEq = 0;
8225682421
tRowcnt nDLt = pFinal->anDLt[iCol];
8225782422
8225882423
/* Set nSum to the number of distinct (iCol+1) field prefixes that
8225982424
** occur in the stat4 table for this index before pFinal. Set
@@ -105797,13 +105962,13 @@
105797105962
/*
105798105963
** Each instance of this object holds a sequence of WhereLoop objects
105799105964
** that implement some or all of a query plan.
105800105965
**
105801105966
** Think of each WhereLoop object as a node in a graph with arcs
105802
-** showing dependences and costs for travelling between nodes. (That is
105967
+** showing dependencies and costs for travelling between nodes. (That is
105803105968
** not a completely accurate description because WhereLoop costs are a
105804
-** vector, not a scalar, and because dependences are many-to-one, not
105969
+** vector, not a scalar, and because dependencies are many-to-one, not
105805105970
** one-to-one as are graph nodes. But it is a useful visualization aid.)
105806105971
** Then a WherePath object is a path through the graph that visits some
105807105972
** or all of the WhereLoop objects once.
105808105973
**
105809105974
** The "solver" works by creating the N best WherePath objects of length
@@ -108033,16 +108198,19 @@
108033108198
UnpackedRecord *pRec, /* Vector of values to consider */
108034108199
int roundUp, /* Round up if true. Round down if false */
108035108200
tRowcnt *aStat /* OUT: stats written here */
108036108201
){
108037108202
IndexSample *aSample = pIdx->aSample;
108038
- int iCol = pRec->nField-1; /* Index of required stats in anEq[] etc. */
108203
+ int iCol; /* Index of required stats in anEq[] etc. */
108039108204
int iMin = 0; /* Smallest sample not yet tested */
108040108205
int i = pIdx->nSample; /* Smallest sample larger than or equal to pRec */
108041108206
int iTest; /* Next sample to test */
108042108207
int res; /* Result of comparison operation */
108043108208
108209
+ assert( pRec!=0 || pParse->db->mallocFailed );
108210
+ if( pRec==0 ) return;
108211
+ iCol = pRec->nField - 1;
108044108212
assert( pIdx->nSample>0 );
108045108213
assert( pRec->nField>0 && iCol<pIdx->nSampleCol );
108046108214
do{
108047108215
iTest = (iMin+i)/2;
108048108216
res = sqlite3VdbeRecordCompare(aSample[iTest].n, aSample[iTest].p, pRec);
@@ -108165,11 +108333,11 @@
108165108333
&& p->nSample
108166108334
&& OptimizationEnabled(pParse->db, SQLITE_Stat3)
108167108335
){
108168108336
UnpackedRecord *pRec = pBuilder->pRec;
108169108337
tRowcnt a[2];
108170
- u8 aff = p->pTable->aCol[p->aiColumn[0]].affinity;
108338
+ u8 aff;
108171108339
108172108340
/* Variable iLower will be set to the estimate of the number of rows in
108173108341
** the index that are less than the lower bound of the range query. The
108174108342
** lower bound being the concatenation of $P and $L, where $P is the
108175108343
** key-prefix formed by the nEq values matched against the nEq left-most
@@ -108187,10 +108355,15 @@
108187108355
** of iUpper are requested of whereKeyStats() and the smaller used.
108188108356
*/
108189108357
tRowcnt iLower;
108190108358
tRowcnt iUpper;
108191108359
108360
+ if( nEq==p->nColumn ){
108361
+ aff = SQLITE_AFF_INTEGER;
108362
+ }else{
108363
+ aff = p->pTable->aCol[p->aiColumn[nEq]].affinity;
108364
+ }
108192108365
/* Determine iLower and iUpper using ($P) only. */
108193108366
if( nEq==0 ){
108194108367
iLower = 0;
108195108368
iUpper = p->aiRowEst[0];
108196108369
}else{
@@ -109781,19 +109954,21 @@
109781109954
assert( p->rSetup>=pTemplate->rSetup );
109782109955
109783109956
if( (p->prereq & pTemplate->prereq)==p->prereq
109784109957
&& p->rSetup<=pTemplate->rSetup
109785109958
&& p->rRun<=pTemplate->rRun
109959
+ && p->nOut<=pTemplate->nOut
109786109960
){
109787109961
/* This branch taken when p is equal or better than pTemplate in
109788
- ** all of (1) dependences (2) setup-cost, and (3) run-cost. */
109962
+ ** all of (1) dependencies (2) setup-cost, (3) run-cost, and
109963
+ ** (4) number of output rows. */
109789109964
assert( p->rSetup==pTemplate->rSetup );
109790
- if( p->nLTerm<pTemplate->nLTerm
109965
+ if( p->prereq==pTemplate->prereq
109966
+ && p->nLTerm<pTemplate->nLTerm
109791109967
&& (p->wsFlags & WHERE_INDEXED)!=0
109792109968
&& (pTemplate->wsFlags & WHERE_INDEXED)!=0
109793109969
&& p->u.btree.pIndex==pTemplate->u.btree.pIndex
109794
- && p->prereq==pTemplate->prereq
109795109970
){
109796109971
/* Overwrite an existing WhereLoop with an similar one that uses
109797109972
** more terms of the index */
109798109973
pNext = p->pNextLoop;
109799109974
break;
@@ -109803,15 +109978,17 @@
109803109978
goto whereLoopInsert_noop;
109804109979
}
109805109980
}
109806109981
if( (p->prereq & pTemplate->prereq)==pTemplate->prereq
109807109982
&& p->rRun>=pTemplate->rRun
109983
+ && p->nOut>=pTemplate->nOut
109808109984
&& ALWAYS(p->rSetup>=pTemplate->rSetup) /* See SETUP-INVARIANT above */
109809109985
){
109810109986
/* Overwrite an existing WhereLoop with a better one: one that is
109811
- ** better at one of (1) dependences, (2) setup-cost, or (3) run-cost
109812
- ** and is no worse in any of those categories. */
109987
+ ** better at one of (1) dependencies, (2) setup-cost, (3) run-cost
109988
+ ** or (4) number of output rows, and is no worse in any of those
109989
+ ** categories. */
109813109990
pNext = p->pNextLoop;
109814109991
break;
109815109992
}
109816109993
}
109817109994
@@ -111512,11 +111689,11 @@
111512111689
if( pWInfo->nLevel>=2
111513111690
&& pResultSet!=0
111514111691
&& OptimizationEnabled(db, SQLITE_OmitNoopJoin)
111515111692
){
111516111693
Bitmask tabUsed = exprListTableUsage(pMaskSet, pResultSet);
111517
- if( pOrderBy ) tabUsed |= exprListTableUsage(pMaskSet, pOrderBy);
111694
+ if( sWLB.pOrderBy ) tabUsed |= exprListTableUsage(pMaskSet, sWLB.pOrderBy);
111518111695
while( pWInfo->nLevel>=2 ){
111519111696
WhereTerm *pTerm, *pEnd;
111520111697
pLoop = pWInfo->a[pWInfo->nLevel-1].pWLoop;
111521111698
if( (pWInfo->pTabList->a[pLoop->iTab].jointype & JT_LEFT)==0 ) break;
111522111699
if( (wctrlFlags & WHERE_WANT_DISTINCT)==0
@@ -117544,18 +117721,20 @@
117544117721
case SQLITE_IOERR_SHMMAP: zName = "SQLITE_IOERR_SHMMAP"; break;
117545117722
case SQLITE_IOERR_SEEK: zName = "SQLITE_IOERR_SEEK"; break;
117546117723
case SQLITE_IOERR_DELETE_NOENT: zName = "SQLITE_IOERR_DELETE_NOENT";break;
117547117724
case SQLITE_IOERR_MMAP: zName = "SQLITE_IOERR_MMAP"; break;
117548117725
case SQLITE_IOERR_GETTEMPPATH: zName = "SQLITE_IOERR_GETTEMPPATH"; break;
117726
+ case SQLITE_IOERR_CONVPATH: zName = "SQLITE_IOERR_CONVPATH"; break;
117549117727
case SQLITE_CORRUPT: zName = "SQLITE_CORRUPT"; break;
117550117728
case SQLITE_CORRUPT_VTAB: zName = "SQLITE_CORRUPT_VTAB"; break;
117551117729
case SQLITE_NOTFOUND: zName = "SQLITE_NOTFOUND"; break;
117552117730
case SQLITE_FULL: zName = "SQLITE_FULL"; break;
117553117731
case SQLITE_CANTOPEN: zName = "SQLITE_CANTOPEN"; break;
117554117732
case SQLITE_CANTOPEN_NOTEMPDIR: zName = "SQLITE_CANTOPEN_NOTEMPDIR";break;
117555117733
case SQLITE_CANTOPEN_ISDIR: zName = "SQLITE_CANTOPEN_ISDIR"; break;
117556117734
case SQLITE_CANTOPEN_FULLPATH: zName = "SQLITE_CANTOPEN_FULLPATH"; break;
117735
+ case SQLITE_CANTOPEN_CONVPATH: zName = "SQLITE_CANTOPEN_CONVPATH"; break;
117557117736
case SQLITE_PROTOCOL: zName = "SQLITE_PROTOCOL"; break;
117558117737
case SQLITE_EMPTY: zName = "SQLITE_EMPTY"; break;
117559117738
case SQLITE_SCHEMA: zName = "SQLITE_SCHEMA"; break;
117560117739
case SQLITE_TOOBIG: zName = "SQLITE_TOOBIG"; break;
117561117740
case SQLITE_CONSTRAINT: zName = "SQLITE_CONSTRAINT"; break;
117562117741
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -656,11 +656,11 @@
656 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
657 ** [sqlite_version()] and [sqlite_source_id()].
658 */
659 #define SQLITE_VERSION "3.8.1"
660 #define SQLITE_VERSION_NUMBER 3008001
661 #define SQLITE_SOURCE_ID "2013-08-30 06:20:23 d9c018f8155ab48df8e0e02519bba50588fe49fc"
662
663 /*
664 ** CAPI3REF: Run-Time Library Version Numbers
665 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
666 **
@@ -1026,16 +1026,18 @@
1026 #define SQLITE_IOERR_SHMMAP (SQLITE_IOERR | (21<<8))
1027 #define SQLITE_IOERR_SEEK (SQLITE_IOERR | (22<<8))
1028 #define SQLITE_IOERR_DELETE_NOENT (SQLITE_IOERR | (23<<8))
1029 #define SQLITE_IOERR_MMAP (SQLITE_IOERR | (24<<8))
1030 #define SQLITE_IOERR_GETTEMPPATH (SQLITE_IOERR | (25<<8))
 
1031 #define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8))
1032 #define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8))
1033 #define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8))
1034 #define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8))
1035 #define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8))
1036 #define SQLITE_CANTOPEN_FULLPATH (SQLITE_CANTOPEN | (3<<8))
 
1037 #define SQLITE_CORRUPT_VTAB (SQLITE_CORRUPT | (1<<8))
1038 #define SQLITE_READONLY_RECOVERY (SQLITE_READONLY | (1<<8))
1039 #define SQLITE_READONLY_CANTLOCK (SQLITE_READONLY | (2<<8))
1040 #define SQLITE_READONLY_ROLLBACK (SQLITE_READONLY | (3<<8))
1041 #define SQLITE_ABORT_ROLLBACK (SQLITE_ABORT | (2<<8))
@@ -16259,11 +16261,11 @@
16259 assert( mem.disallow==0 );
16260 assert( (nByte & 7)==0 ); /* EV: R-46199-30249 */
16261 pOldHdr = sqlite3MemsysGetHeader(pPrior);
16262 pNew = sqlite3MemMalloc(nByte);
16263 if( pNew ){
16264 memcpy(pNew, pPrior, nByte<pOldHdr->iSize ? nByte : pOldHdr->iSize);
16265 if( nByte>pOldHdr->iSize ){
16266 randomFill(&((char*)pNew)[pOldHdr->iSize], nByte - (int)pOldHdr->iSize);
16267 }
16268 sqlite3MemFree(pPrior);
16269 }
@@ -23594,10 +23596,19 @@
23594 if( aSyscall[i].pCurrent!=0 ) return aSyscall[i].zName;
23595 }
23596 return 0;
23597 }
23598
 
 
 
 
 
 
 
 
 
23599 /*
23600 ** Invoke open(). Do so multiple times, until it either succeeds or
23601 ** fails for some reason other than EINTR.
23602 **
23603 ** If the file creation mode "m" is 0 then set it to the default for
@@ -23624,11 +23635,11 @@
23624 #endif
23625 if( fd<0 ){
23626 if( errno==EINTR ) continue;
23627 break;
23628 }
23629 if( fd>2 ) break;
23630 osClose(fd);
23631 sqlite3_log(SQLITE_WARNING,
23632 "attempt to open \"%s\" as file descriptor %d", z, fd);
23633 fd = -1;
23634 if( osOpen("/dev/null", f, m)<0 ) break;
@@ -28373,10 +28384,11 @@
28373 ** If no suitable temporary file directory can be found, return NULL.
28374 */
28375 static const char *unixTempFileDir(void){
28376 static const char *azDirs[] = {
28377 0,
 
28378 0,
28379 "/var/tmp",
28380 "/usr/tmp",
28381 "/tmp",
28382 0 /* List terminator */
@@ -28384,11 +28396,12 @@
28384 unsigned int i;
28385 struct stat buf;
28386 const char *zDir = 0;
28387
28388 azDirs[0] = sqlite3_temp_directory;
28389 if( !azDirs[1] ) azDirs[1] = getenv("TMPDIR");
 
28390 for(i=0; i<sizeof(azDirs)/sizeof(azDirs[0]); zDir=azDirs[i++]){
28391 if( zDir==0 ) continue;
28392 if( osStat(zDir, &buf) ) continue;
28393 if( !S_ISDIR(buf.st_mode) ) continue;
28394 if( osAccess(zDir, 07) ) continue;
@@ -30497,11 +30510,11 @@
30497 */
30498 #if SQLITE_OS_WIN /* This file is used for Windows only */
30499
30500 #ifdef __CYGWIN__
30501 # include <sys/cygwin.h>
30502 /* # include <errno.h> */
30503 #endif
30504
30505 /*
30506 ** Include code that is common to all os_*.c files
30507 */
@@ -30726,22 +30739,31 @@
30726
30727 /*
30728 ** Are most of the Win32 ANSI APIs available (i.e. with certain exceptions
30729 ** based on the sub-platform)?
30730 */
30731 #if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT
30732 # define SQLITE_WIN32_HAS_ANSI
30733 #endif
30734
30735 /*
30736 ** Are most of the Win32 Unicode APIs available (i.e. with certain exceptions
30737 ** based on the sub-platform)?
30738 */
30739 #if SQLITE_OS_WINCE || SQLITE_OS_WINNT || SQLITE_OS_WINRT
 
30740 # define SQLITE_WIN32_HAS_WIDE
30741 #endif
30742
 
 
 
 
 
 
 
 
30743 /*
30744 ** Maximum pathname length (in chars) for Win32. This should normally be
30745 ** MAX_PATH.
30746 */
30747 #ifndef SQLITE_WIN32_MAX_PATH_CHARS
@@ -30849,11 +30871,11 @@
30849 #ifndef FILE_ATTRIBUTE_MASK
30850 # define FILE_ATTRIBUTE_MASK (0x0003FFF7)
30851 #endif
30852
30853 #ifndef SQLITE_OMIT_WAL
30854 /* Forward references */
30855 typedef struct winShm winShm; /* A connection to shared-memory */
30856 typedef struct winShmNode winShmNode; /* A region of shared-memory */
30857 #endif
30858
30859 /*
@@ -31804,11 +31826,11 @@
31804 ** API as long as we don't call it when running Win95/98/ME. A call to
31805 ** this routine is used to determine if the host is Win95/98/ME or
31806 ** WinNT/2K/XP so that we will know whether or not we can safely call
31807 ** the LockFileEx() API.
31808 */
31809 #if SQLITE_OS_WINCE || SQLITE_OS_WINRT
31810 # define osIsNT() (1)
31811 #elif !defined(SQLITE_WIN32_HAS_WIDE)
31812 # define osIsNT() (0)
31813 #else
31814 static int osIsNT(void){
@@ -32449,14 +32471,13 @@
32449
32450 /* Create/open the named mutex */
32451 pFile->hMutex = osCreateMutexW(NULL, FALSE, zName);
32452 if (!pFile->hMutex){
32453 pFile->lastErrno = osGetLastError();
32454 winLogError(SQLITE_IOERR, pFile->lastErrno,
32455 "winceCreateLock1", zFilename);
32456 sqlite3_free(zName);
32457 return SQLITE_IOERR;
 
32458 }
32459
32460 /* Acquire the mutex before continuing */
32461 winceMutexAcquire(pFile->hMutex);
32462
@@ -32788,11 +32809,11 @@
32788
32789 if( (dwRet==INVALID_SET_FILE_POINTER
32790 && ((lastErrno = osGetLastError())!=NO_ERROR)) ){
32791 pFile->lastErrno = lastErrno;
32792 winLogError(SQLITE_IOERR_SEEK, pFile->lastErrno,
32793 "winSeekFile", pFile->zPath);
32794 OSTRACE(("SEEK file=%p, rc=SQLITE_IOERR_SEEK\n", pFile->h));
32795 return 1;
32796 }
32797
32798 OSTRACE(("SEEK file=%p, rc=SQLITE_OK\n", pFile->h));
@@ -32809,11 +32830,11 @@
32809 bRet = osSetFilePointerEx(pFile->h, x, 0, FILE_BEGIN);
32810
32811 if(!bRet){
32812 pFile->lastErrno = osGetLastError();
32813 winLogError(SQLITE_IOERR_SEEK, pFile->lastErrno,
32814 "winSeekFile", pFile->zPath);
32815 OSTRACE(("SEEK file=%p, rc=SQLITE_IOERR_SEEK\n", pFile->h));
32816 return 1;
32817 }
32818
32819 OSTRACE(("SEEK file=%p, rc=SQLITE_OK\n", pFile->h));
@@ -32820,11 +32841,12 @@
32820 return 0;
32821 #endif
32822 }
32823
32824 #if SQLITE_MAX_MMAP_SIZE>0
32825 /* Forward references to VFS methods */
 
32826 static int winUnmapfile(winFile*);
32827 #endif
32828
32829 /*
32830 ** Close a file.
@@ -32941,11 +32963,11 @@
32941 DWORD lastErrno;
32942 if( winRetryIoerr(&nRetry, &lastErrno) ) continue;
32943 pFile->lastErrno = lastErrno;
32944 OSTRACE(("READ file=%p, rc=SQLITE_IOERR_READ\n", pFile->h));
32945 return winLogError(SQLITE_IOERR_READ, pFile->lastErrno,
32946 "winRead", pFile->zPath);
32947 }
32948 winLogIoerr(nRetry);
32949 if( nRead<(DWORD)amt ){
32950 /* Unread parts of the buffer must be zero-filled */
32951 memset(&((char*)pBuf)[nRead], 0, amt-nRead);
@@ -33047,15 +33069,16 @@
33047
33048 if( rc ){
33049 if( ( pFile->lastErrno==ERROR_HANDLE_DISK_FULL )
33050 || ( pFile->lastErrno==ERROR_DISK_FULL )){
33051 OSTRACE(("WRITE file=%p, rc=SQLITE_FULL\n", pFile->h));
33052 return SQLITE_FULL;
 
33053 }
33054 OSTRACE(("WRITE file=%p, rc=SQLITE_IOERR_WRITE\n", pFile->h));
33055 return winLogError(SQLITE_IOERR_WRITE, pFile->lastErrno,
33056 "winWrite", pFile->zPath);
33057 }else{
33058 winLogIoerr(nRetry);
33059 }
33060 OSTRACE(("WRITE file=%p, rc=SQLITE_OK\n", pFile->h));
33061 return SQLITE_OK;
@@ -33175,11 +33198,11 @@
33175 return SQLITE_OK;
33176 }else{
33177 pFile->lastErrno = osGetLastError();
33178 OSTRACE(("SYNC file=%p, rc=SQLITE_IOERR_FSYNC\n", pFile->h));
33179 return winLogError(SQLITE_IOERR_FSYNC, pFile->lastErrno,
33180 "winSync", pFile->zPath);
33181 }
33182 #endif
33183 }
33184
33185 /*
@@ -33216,11 +33239,11 @@
33216 *pSize = (((sqlite3_int64)upperBits)<<32) + lowerBits;
33217 if( (lowerBits == INVALID_FILE_SIZE)
33218 && ((lastErrno = osGetLastError())!=NO_ERROR) ){
33219 pFile->lastErrno = lastErrno;
33220 rc = winLogError(SQLITE_IOERR_FSTAT, pFile->lastErrno,
33221 "winFileSize", pFile->zPath);
33222 }
33223 }
33224 #endif
33225 OSTRACE(("SIZE file=%p, pSize=%p, *pSize=%lld, rc=%s\n",
33226 pFile->h, pSize, *pSize, sqlite3ErrName(rc)));
@@ -33311,11 +33334,11 @@
33311 }
33312 #endif
33313 if( res==0 && ((lastErrno = osGetLastError())!=ERROR_NOT_LOCKED) ){
33314 pFile->lastErrno = lastErrno;
33315 winLogError(SQLITE_IOERR_UNLOCK, pFile->lastErrno,
33316 "winUnlockReadLock", pFile->zPath);
33317 }
33318 OSTRACE(("READ-UNLOCK file=%p, rc=%s\n", pFile->h, sqlite3ErrName(res)));
33319 return res;
33320 }
33321
@@ -33524,11 +33547,11 @@
33524 winUnlockFile(&pFile->h, SHARED_FIRST, 0, SHARED_SIZE, 0);
33525 if( locktype==SHARED_LOCK && !winGetReadLock(pFile) ){
33526 /* This should never happen. We should always be able to
33527 ** reacquire the read lock */
33528 rc = winLogError(SQLITE_IOERR_UNLOCK, osGetLastError(),
33529 "winUnlock", pFile->zPath);
33530 }
33531 }
33532 if( type>=RESERVED_LOCK ){
33533 winUnlockFile(&pFile->h, RESERVED_BYTE, 0, 1, 0);
33534 }
@@ -33558,15 +33581,14 @@
33558 }else{
33559 pFile->ctrlFlags |= mask;
33560 }
33561 }
33562
33563 /* Forward declaration */
33564 static int winGetTempname(sqlite3_vfs *, char **);
33565 #if SQLITE_MAX_MMAP_SIZE>0
33566 static int winMapfile(winFile*, sqlite3_int64);
33567 #endif
33568
33569 /*
33570 ** Control and query of the open file handle.
33571 */
33572 static int winFileControl(sqlite3_file *id, int op, void *pArg){
@@ -33640,11 +33662,11 @@
33640 char *zTFile = 0;
33641 int rc = winGetTempname(pFile->pVfs, &zTFile);
33642 if( rc==SQLITE_OK ){
33643 *(char**)pArg = zTFile;
33644 }
33645 OSTRACE(("FCNTL file=%p, rc=%d\n", pFile->h, rc));
33646 return rc;
33647 }
33648 #if SQLITE_MAX_MMAP_SIZE>0
33649 case SQLITE_FCNTL_MMAP_SIZE: {
33650 i64 newLimit = *(i64*)pArg;
@@ -33658,11 +33680,11 @@
33658 if( pFile->mmapSize>0 ){
33659 (void)winUnmapfile(pFile);
33660 rc = winMapfile(pFile, -1);
33661 }
33662 }
33663 OSTRACE(("FCNTL file=%p, rc=%d\n", pFile->h, rc));
33664 return rc;
33665 }
33666 #endif
33667 }
33668 OSTRACE(("FCNTL file=%p, rc=SQLITE_NOTFOUND\n", pFile->h));
@@ -33974,11 +33996,11 @@
33974 */
33975 if( winShmSystemLock(pShmNode, _SHM_WRLCK, WIN_SHM_DMS, 1)==SQLITE_OK ){
33976 rc = winTruncate((sqlite3_file *)&pShmNode->hFile, 0);
33977 if( rc!=SQLITE_OK ){
33978 rc = winLogError(SQLITE_IOERR_SHMOPEN, osGetLastError(),
33979 "winOpenShm", pDbFd->zPath);
33980 }
33981 }
33982 if( rc==SQLITE_OK ){
33983 winShmSystemLock(pShmNode, _SHM_UNLCK, WIN_SHM_DMS, 1);
33984 rc = winShmSystemLock(pShmNode, _SHM_RDLCK, WIN_SHM_DMS, 1);
@@ -34234,11 +34256,11 @@
34234 ** large enough to contain the requested region).
34235 */
34236 rc = winFileSize((sqlite3_file *)&pShmNode->hFile, &sz);
34237 if( rc!=SQLITE_OK ){
34238 rc = winLogError(SQLITE_IOERR_SHMSIZE, osGetLastError(),
34239 "winShmMap1", pDbFd->zPath);
34240 goto shmpage_out;
34241 }
34242
34243 if( sz<nByte ){
34244 /* The requested memory region does not exist. If isWrite is set to
@@ -34249,11 +34271,11 @@
34249 */
34250 if( !isWrite ) goto shmpage_out;
34251 rc = winTruncate((sqlite3_file *)&pShmNode->hFile, nByte);
34252 if( rc!=SQLITE_OK ){
34253 rc = winLogError(SQLITE_IOERR_SHMSIZE, osGetLastError(),
34254 "winShmMap2", pDbFd->zPath);
34255 goto shmpage_out;
34256 }
34257 }
34258
34259 /* Map the requested memory region into this processes address space. */
@@ -34303,11 +34325,11 @@
34303 szRegion, pMap ? "ok" : "failed"));
34304 }
34305 if( !pMap ){
34306 pShmNode->lastErrno = osGetLastError();
34307 rc = winLogError(SQLITE_IOERR_SHMMAP, pShmNode->lastErrno,
34308 "winShmMap3", pDbFd->zPath);
34309 if( hMap ) osCloseHandle(hMap);
34310 goto shmpage_out;
34311 }
34312
34313 pShmNode->aRegion[pShmNode->nRegion].pMap = pMap;
@@ -34351,11 +34373,11 @@
34351 pFile->lastErrno = osGetLastError();
34352 OSTRACE(("UNMAP-FILE pid=%lu, pFile=%p, pMapRegion=%p, "
34353 "rc=SQLITE_IOERR_MMAP\n", osGetCurrentProcessId(), pFile,
34354 pFile->pMapRegion));
34355 return winLogError(SQLITE_IOERR_MMAP, pFile->lastErrno,
34356 "winUnmap1", pFile->zPath);
34357 }
34358 pFile->pMapRegion = 0;
34359 pFile->mmapSize = 0;
34360 pFile->mmapSizeActual = 0;
34361 }
@@ -34363,11 +34385,11 @@
34363 if( !osCloseHandle(pFile->hMap) ){
34364 pFile->lastErrno = osGetLastError();
34365 OSTRACE(("UNMAP-FILE pid=%lu, pFile=%p, hMap=%p, rc=SQLITE_IOERR_MMAP\n",
34366 osGetCurrentProcessId(), pFile, pFile->hMap));
34367 return winLogError(SQLITE_IOERR_MMAP, pFile->lastErrno,
34368 "winUnmap2", pFile->zPath);
34369 }
34370 pFile->hMap = NULL;
34371 }
34372 OSTRACE(("UNMAP-FILE pid=%lu, pFile=%p, rc=SQLITE_OK\n",
34373 osGetCurrentProcessId(), pFile));
@@ -34438,14 +34460,14 @@
34438 (DWORD)(nMap & 0xffffffff), NULL);
34439 #endif
34440 if( pFd->hMap==NULL ){
34441 pFd->lastErrno = osGetLastError();
34442 rc = winLogError(SQLITE_IOERR_MMAP, pFd->lastErrno,
34443 "winMapfile", pFd->zPath);
34444 /* Log the error, but continue normal operation using xRead/xWrite */
34445 OSTRACE(("MAP-FILE-CREATE pid=%lu, pFile=%p, rc=SQLITE_IOERR_MMAP\n",
34446 osGetCurrentProcessId(), pFd));
34447 return SQLITE_OK;
34448 }
34449 assert( (nMap % winSysInfo.dwPageSize)==0 );
34450 assert( sizeof(SIZE_T)==sizeof(sqlite3_int64) || nMap<=0xffffffff );
34451 #if SQLITE_OS_WINRT
@@ -34455,14 +34477,15 @@
34455 #endif
34456 if( pNew==NULL ){
34457 osCloseHandle(pFd->hMap);
34458 pFd->hMap = NULL;
34459 pFd->lastErrno = osGetLastError();
34460 winLogError(SQLITE_IOERR_MMAP, pFd->lastErrno,
34461 "winMapfile", pFd->zPath);
34462 OSTRACE(("MAP-FILE-MAP pid=%lu, pFile=%p, rc=SQLITE_IOERR_MMAP\n",
34463 osGetCurrentProcessId(), pFd));
 
34464 return SQLITE_OK;
34465 }
34466 pFd->pMapRegion = pNew;
34467 pFd->mmapSize = nMap;
34468 pFd->mmapSizeActual = nMap;
@@ -34596,18 +34619,37 @@
34596 **************************** sqlite3_vfs methods ****************************
34597 **
34598 ** This division contains the implementation of methods on the
34599 ** sqlite3_vfs object.
34600 */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34601
34602 /*
34603 ** Convert a UTF-8 filename into whatever form the underlying
34604 ** operating system wants filenames in. Space to hold the result
34605 ** is obtained from malloc and must be freed by the calling
34606 ** function.
34607 */
34608 static void *winConvertUtf8Filename(const char *zFilename){
34609 void *zConverted = 0;
34610 if( osIsNT() ){
34611 zConverted = winUtf8ToUnicode(zFilename);
34612 }
34613 #ifdef SQLITE_WIN32_HAS_ANSI
@@ -34668,11 +34710,94 @@
34668 if( sqlite3_temp_directory ){
34669 sqlite3_snprintf(nBuf-30, zBuf, "%s%s", sqlite3_temp_directory,
34670 winEndsInDirSep(sqlite3_temp_directory) ? "" :
34671 winGetDirDep());
34672 }
34673 #if !SQLITE_OS_WINRT
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34674 else if( osIsNT() ){
34675 char *zMulti;
34676 LPWSTR zWidePath = sqlite3MallocZero( nBuf*sizeof(WCHAR) );
34677 if( !zWidePath ){
34678 sqlite3_free(zBuf);
@@ -34681,11 +34806,12 @@
34681 }
34682 if( osGetTempPathW(nBuf, zWidePath)==0 ){
34683 sqlite3_free(zWidePath);
34684 sqlite3_free(zBuf);
34685 OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_GETTEMPPATH\n"));
34686 return SQLITE_IOERR_GETTEMPPATH;
 
34687 }
34688 zMulti = winUnicodeToUtf8(zWidePath);
34689 if( zMulti ){
34690 sqlite3_snprintf(nBuf-30, zBuf, "%s", zMulti);
34691 sqlite3_free(zMulti);
@@ -34707,11 +34833,12 @@
34707 return SQLITE_IOERR_NOMEM;
34708 }
34709 if( osGetTempPathA(nBuf, zMbcsPath)==0 ){
34710 sqlite3_free(zBuf);
34711 OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_GETTEMPPATH\n"));
34712 return SQLITE_IOERR_GETTEMPPATH;
 
34713 }
34714 zUtf8 = sqlite3_win32_mbcs_to_utf8(zMbcsPath);
34715 if( zUtf8 ){
34716 sqlite3_snprintf(nBuf-30, zBuf, "%s", zUtf8);
34717 sqlite3_free(zUtf8);
@@ -34730,11 +34857,11 @@
34730 nLen = sqlite3Strlen30(zBuf);
34731
34732 if( (nLen + sqlite3Strlen30(SQLITE_TEMP_FILE_PREFIX) + 18) >= nBuf ){
34733 sqlite3_free(zBuf);
34734 OSTRACE(("TEMP-FILENAME rc=SQLITE_ERROR\n"));
34735 return SQLITE_ERROR;
34736 }
34737
34738 sqlite3_snprintf(nBuf-18-nLen, zBuf+nLen, SQLITE_TEMP_FILE_PREFIX);
34739
34740 j = sqlite3Strlen30(zBuf);
@@ -34886,11 +35013,11 @@
34886 */
34887 assert( (eType!=SQLITE_OPEN_MAIN_DB) || (flags & SQLITE_OPEN_URI) ||
34888 zUtf8Name[sqlite3Strlen30(zUtf8Name)+1]==0 );
34889
34890 /* Convert the filename to the system encoding. */
34891 zConverted = winConvertUtf8Filename(zUtf8Name);
34892 if( zConverted==0 ){
34893 sqlite3_free(zTmpname);
34894 OSTRACE(("OPEN name=%s, rc=SQLITE_IOERR_NOMEM", zUtf8Name));
34895 return SQLITE_IOERR_NOMEM;
34896 }
@@ -35087,11 +35214,11 @@
35087 UNUSED_PARAMETER(syncDir);
35088
35089 SimulateIOError(return SQLITE_IOERR_DELETE);
35090 OSTRACE(("DELETE name=%s, syncDir=%d\n", zFilename, syncDir));
35091
35092 zConverted = winConvertUtf8Filename(zFilename);
35093 if( zConverted==0 ){
35094 OSTRACE(("DELETE name=%s, rc=SQLITE_IOERR_NOMEM\n", zFilename));
35095 return SQLITE_IOERR_NOMEM;
35096 }
35097 if( osIsNT() ){
@@ -35167,12 +35294,11 @@
35167 }
35168 } while(1);
35169 }
35170 #endif
35171 if( rc && rc!=SQLITE_IOERR_DELETE_NOENT ){
35172 rc = winLogError(SQLITE_IOERR_DELETE, lastErrno,
35173 "winDelete", zFilename);
35174 }else{
35175 winLogIoerr(cnt);
35176 }
35177 sqlite3_free(zConverted);
35178 OSTRACE(("DELETE name=%s, rc=%s\n", zFilename, sqlite3ErrName(rc)));
@@ -35196,11 +35322,11 @@
35196
35197 SimulateIOError( return SQLITE_IOERR_ACCESS; );
35198 OSTRACE(("ACCESS name=%s, flags=%x, pResOut=%p\n",
35199 zFilename, flags, pResOut));
35200
35201 zConverted = winConvertUtf8Filename(zFilename);
35202 if( zConverted==0 ){
35203 OSTRACE(("ACCESS name=%s, rc=SQLITE_IOERR_NOMEM\n", zFilename));
35204 return SQLITE_IOERR_NOMEM;
35205 }
35206 if( osIsNT() ){
@@ -35222,13 +35348,13 @@
35222 attr = sAttrData.dwFileAttributes;
35223 }
35224 }else{
35225 winLogIoerr(cnt);
35226 if( lastErrno!=ERROR_FILE_NOT_FOUND && lastErrno!=ERROR_PATH_NOT_FOUND ){
35227 winLogError(SQLITE_IOERR_ACCESS, lastErrno, "winAccess", zFilename);
35228 sqlite3_free(zConverted);
35229 return SQLITE_IOERR_ACCESS;
 
35230 }else{
35231 attr = INVALID_FILE_ATTRIBUTES;
35232 }
35233 }
35234 }
@@ -35254,10 +35380,19 @@
35254 OSTRACE(("ACCESS name=%s, pResOut=%p, *pResOut=%d, rc=SQLITE_OK\n",
35255 zFilename, pResOut, *pResOut));
35256 return SQLITE_OK;
35257 }
35258
 
 
 
 
 
 
 
 
 
35259
35260 /*
35261 ** Returns non-zero if the specified path name should be used verbatim. If
35262 ** non-zero is returned from this function, the calling function must simply
35263 ** use the provided path name verbatim -OR- resolve it into a full path name
@@ -35281,11 +35416,11 @@
35281 ** If the path name starts with a letter and a colon it is either a volume
35282 ** relative path or an absolute path. Callers of this function must not
35283 ** attempt to treat it as a relative path name (i.e. they should simply use
35284 ** it verbatim).
35285 */
35286 if ( sqlite3Isalpha(zPathname[0]) && zPathname[1]==':' ){
35287 return TRUE;
35288 }
35289
35290 /*
35291 ** If we get to this point, the path name should almost certainly be a purely
@@ -35317,28 +35452,25 @@
35317 ** for converting the relative path name to an absolute
35318 ** one by prepending the data directory and a slash.
35319 */
35320 char *zOut = sqlite3MallocZero( pVfs->mxPathname+1 );
35321 if( !zOut ){
35322 winLogError(SQLITE_IOERR_NOMEM, 0, "winFullPathname", zRelative);
35323 return SQLITE_IOERR_NOMEM;
35324 }
35325 if( cygwin_conv_path(CCP_POSIX_TO_WIN_A|CCP_RELATIVE, zRelative, zOut,
35326 pVfs->mxPathname+1)<0 ){
35327 winLogError(SQLITE_CANTOPEN_FULLPATH, (DWORD)errno, "cygwin_conv_path",
35328 zRelative);
35329 sqlite3_free(zOut);
35330 return SQLITE_CANTOPEN_FULLPATH;
 
35331 }
35332 sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s%s%s",
35333 sqlite3_data_directory, winGetDirDep(), zOut);
35334 sqlite3_free(zOut);
35335 }else{
35336 if( cygwin_conv_path(CCP_POSIX_TO_WIN_A, zRelative, zFull, nFull)<0 ){
35337 winLogError(SQLITE_CANTOPEN_FULLPATH, (DWORD)errno, "cygwin_conv_path",
35338 zRelative);
35339 return SQLITE_CANTOPEN_FULLPATH;
35340 }
35341 }
35342 return SQLITE_OK;
35343 #endif
35344
@@ -35367,11 +35499,11 @@
35367 char *zOut;
35368
35369 /* If this path name begins with "/X:", where "X" is any alphabetic
35370 ** character, discard the initial "/" from the pathname.
35371 */
35372 if( zRelative[0]=='/' && sqlite3Isalpha(zRelative[1]) && zRelative[2]==':' ){
35373 zRelative++;
35374 }
35375
35376 /* It's odd to simulate an io-error here, but really this is just
35377 ** using the io-error infrastructure to test that SQLite handles this
@@ -35388,36 +35520,34 @@
35388 */
35389 sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s%s%s",
35390 sqlite3_data_directory, winGetDirDep(), zRelative);
35391 return SQLITE_OK;
35392 }
35393 zConverted = winConvertUtf8Filename(zRelative);
35394 if( zConverted==0 ){
35395 return SQLITE_IOERR_NOMEM;
35396 }
35397 if( osIsNT() ){
35398 LPWSTR zTemp;
35399 nByte = osGetFullPathNameW((LPCWSTR)zConverted, 0, 0, 0);
35400 if( nByte==0 ){
35401 winLogError(SQLITE_ERROR, osGetLastError(),
35402 "GetFullPathNameW1", zConverted);
35403 sqlite3_free(zConverted);
35404 return SQLITE_CANTOPEN_FULLPATH;
 
35405 }
35406 nByte += 3;
35407 zTemp = sqlite3MallocZero( nByte*sizeof(zTemp[0]) );
35408 if( zTemp==0 ){
35409 sqlite3_free(zConverted);
35410 return SQLITE_IOERR_NOMEM;
35411 }
35412 nByte = osGetFullPathNameW((LPCWSTR)zConverted, nByte, zTemp, 0);
35413 if( nByte==0 ){
35414 winLogError(SQLITE_ERROR, osGetLastError(),
35415 "GetFullPathNameW2", zConverted);
35416 sqlite3_free(zConverted);
35417 sqlite3_free(zTemp);
35418 return SQLITE_CANTOPEN_FULLPATH;
 
35419 }
35420 sqlite3_free(zConverted);
35421 zOut = winUnicodeToUtf8(zTemp);
35422 sqlite3_free(zTemp);
35423 }
@@ -35424,28 +35554,26 @@
35424 #ifdef SQLITE_WIN32_HAS_ANSI
35425 else{
35426 char *zTemp;
35427 nByte = osGetFullPathNameA((char*)zConverted, 0, 0, 0);
35428 if( nByte==0 ){
35429 winLogError(SQLITE_ERROR, osGetLastError(),
35430 "GetFullPathNameA1", zConverted);
35431 sqlite3_free(zConverted);
35432 return SQLITE_CANTOPEN_FULLPATH;
 
35433 }
35434 nByte += 3;
35435 zTemp = sqlite3MallocZero( nByte*sizeof(zTemp[0]) );
35436 if( zTemp==0 ){
35437 sqlite3_free(zConverted);
35438 return SQLITE_IOERR_NOMEM;
35439 }
35440 nByte = osGetFullPathNameA((char*)zConverted, nByte, zTemp, 0);
35441 if( nByte==0 ){
35442 winLogError(SQLITE_ERROR, osGetLastError(),
35443 "GetFullPathNameA2", zConverted);
35444 sqlite3_free(zConverted);
35445 sqlite3_free(zTemp);
35446 return SQLITE_CANTOPEN_FULLPATH;
 
35447 }
35448 sqlite3_free(zConverted);
35449 zOut = sqlite3_win32_mbcs_to_utf8(zTemp);
35450 sqlite3_free(zTemp);
35451 }
@@ -35469,11 +35597,11 @@
35469 ** Interfaces for opening a shared library, finding entry points
35470 ** within the shared library, and closing the shared library.
35471 */
35472 static void *winDlOpen(sqlite3_vfs *pVfs, const char *zFilename){
35473 HANDLE h;
35474 void *zConverted = winConvertUtf8Filename(zFilename);
35475 UNUSED_PARAMETER(pVfs);
35476 if( zConverted==0 ){
35477 return 0;
35478 }
35479 if( osIsNT() ){
@@ -60283,10 +60411,13 @@
60283 alloc.pParse = pParse;
60284 alloc.pIdx = pIdx;
60285 alloc.ppRec = ppRec;
60286 alloc.iVal = iVal;
60287
 
 
 
60288 if( !pExpr ){
60289 pVal = valueNew(pParse->db, &alloc);
60290 if( pVal ){
60291 sqlite3VdbeMemSetNull((Mem*)pVal);
60292 *pbOk = 1;
@@ -80950,11 +81081,11 @@
80950 ** SQLITE_ENABLE_STAT3 defined. The functionality of sqlite_stat3
80951 ** is a superset of sqlite_stat2. The sqlite_stat4 is an enhanced
80952 ** version of sqlite_stat3 and is only available when compiled with
80953 ** SQLITE_ENABLE_STAT4 and in SQLite versions 3.8.0 and later. It is
80954 ** not possible to enable both STAT3 and STAT4 at the same time. If they
80955 ** are both enabled, then STAT4 is precedence.
80956 **
80957 ** For most applications, sqlite_stat1 provides all the statisics required
80958 ** for the query planner to make good choices.
80959 **
80960 ** Format of sqlite_stat1:
@@ -81261,11 +81392,11 @@
81261 u8 *pSpace; /* Allocated space not yet assigned */
81262 int i; /* Used to iterate through p->aSample[] */
81263
81264 p->iGet = -1;
81265 p->mxSample = mxSample;
81266 p->nPSample = sqlite3_value_int64(argv[1])/(mxSample/3+1) + 1;
81267 p->current.anLt = &p->current.anEq[nColUp];
81268 sqlite3_randomness(sizeof(p->iPrn), &p->iPrn);
81269
81270 /* Set up the Stat4Accum.a[] and aBest[] arrays */
81271 p->a = (struct Stat4Sample*)&p->current.anLt[nColUp];
@@ -81298,29 +81429,68 @@
81298 0, /* xFinalize */
81299 "stat_init", /* zName */
81300 0, /* pHash */
81301 0 /* pDestructor */
81302 };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
81303
81304 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
81305 /*
81306 ** Return true if pNew is to be preferred over pOld.
 
 
 
81307 */
81308 static int sampleIsBetter(Stat4Sample *pNew, Stat4Sample *pOld){
 
 
 
 
81309 tRowcnt nEqNew = pNew->anEq[pNew->iCol];
81310 tRowcnt nEqOld = pOld->anEq[pOld->iCol];
81311
81312 assert( pOld->isPSample==0 && pNew->isPSample==0 );
81313 assert( IsStat4 || (pNew->iCol==0 && pOld->iCol==0) );
81314
81315 if( (nEqNew>nEqOld)
81316 || (nEqNew==nEqOld && pNew->iCol<pOld->iCol)
81317 || (nEqNew==nEqOld && pNew->iCol==pOld->iCol && pNew->iHash>pOld->iHash)
81318 ){
81319 return 1;
81320 }
81321 return 0;
 
 
 
81322 }
81323
81324 /*
81325 ** Copy the contents of object (*pFrom) into (*pTo).
81326 */
@@ -81339,15 +81509,14 @@
81339 ** remove the least desirable sample from p->a[] to make room.
81340 */
81341 static void sampleInsert(Stat4Accum *p, Stat4Sample *pNew, int nEqZero){
81342 Stat4Sample *pSample;
81343 int i;
81344 i64 iSeq;
81345 i64 iPos;
81346
81347 assert( IsStat4 || nEqZero==0 );
81348
 
81349 if( pNew->isPSample==0 ){
81350 Stat4Sample *pUpgrade = 0;
81351 assert( pNew->anEq[pNew->iCol]>0 );
81352
81353 /* This sample is being added because the prefix that ends in column
@@ -81357,12 +81526,13 @@
81357 ** existing sample that shares this prefix. */
81358 for(i=p->nSample-1; i>=0; i--){
81359 Stat4Sample *pOld = &p->a[i];
81360 if( pOld->anEq[pNew->iCol]==0 ){
81361 if( pOld->isPSample ) return;
81362 assert( sampleIsBetter(pNew, pOld) );
81363 if( pUpgrade==0 || sampleIsBetter(pOld, pUpgrade) ){
 
81364 pUpgrade = pOld;
81365 }
81366 }
81367 }
81368 if( pUpgrade ){
@@ -81369,10 +81539,11 @@
81369 pUpgrade->iCol = pNew->iCol;
81370 pUpgrade->anEq[pUpgrade->iCol] = pNew->anEq[pUpgrade->iCol];
81371 goto find_new_min;
81372 }
81373 }
 
81374
81375 /* If necessary, remove sample iMin to make room for the new sample. */
81376 if( p->nSample>=p->mxSample ){
81377 Stat4Sample *pMin = &p->a[p->iMin];
81378 tRowcnt *anEq = pMin->anEq;
@@ -81384,40 +81555,34 @@
81384 pSample->anDLt = anDLt;
81385 pSample->anLt = anLt;
81386 p->nSample = p->mxSample-1;
81387 }
81388
81389 /* Figure out where in the a[] array the new sample should be inserted. */
81390 iSeq = pNew->anLt[p->nCol-1];
81391 for(iPos=p->nSample; iPos>0; iPos--){
81392 if( iSeq>p->a[iPos-1].anLt[p->nCol-1] ) break;
81393 }
 
 
81394
81395 /* Insert the new sample */
81396 pSample = &p->a[iPos];
81397 if( iPos!=p->nSample ){
81398 Stat4Sample *pEnd = &p->a[p->nSample];
81399 tRowcnt *anEq = pEnd->anEq;
81400 tRowcnt *anLt = pEnd->anLt;
81401 tRowcnt *anDLt = pEnd->anDLt;
81402 memmove(&p->a[iPos], &p->a[iPos+1], (p->nSample-iPos)*sizeof(p->a[0]));
81403 pSample->anEq = anEq;
81404 pSample->anDLt = anDLt;
81405 pSample->anLt = anLt;
81406 }
81407 p->nSample++;
81408 sampleCopy(p, pSample, pNew);
 
81409
81410 /* Zero the first nEqZero entries in the anEq[] array. */
81411 memset(pSample->anEq, 0, sizeof(tRowcnt)*nEqZero);
81412
 
81413 find_new_min:
 
81414 if( p->nSample>=p->mxSample ){
81415 int iMin = -1;
81416 for(i=0; i<p->mxSample; i++){
81417 if( p->a[i].isPSample ) continue;
81418 if( iMin<0 || sampleIsBetter(&p->a[iMin], &p->a[i]) ){
81419 iMin = i;
81420 }
81421 }
81422 assert( iMin>=0 );
81423 p->iMin = iMin;
@@ -81437,13 +81602,12 @@
81437
81438 /* Check if any samples from the aBest[] array should be pushed
81439 ** into IndexSample.a[] at this point. */
81440 for(i=(p->nCol-2); i>=iChng; i--){
81441 Stat4Sample *pBest = &p->aBest[i];
81442 if( p->nSample<p->mxSample
81443 || sampleIsBetter(pBest, &p->a[p->iMin])
81444 ){
81445 sampleInsert(p, pBest, i);
81446 }
81447 }
81448
81449 /* Update the anEq[] fields of any samples already collected. */
@@ -81466,11 +81630,13 @@
81466 sampleInsert(p, &p->current, 0);
81467 p->current.isPSample = 0;
81468 }else
81469
81470 /* Or if it is a non-periodic sample. Add it in this case too. */
81471 if( p->nSample<p->mxSample || sampleIsBetter(&p->current, &p->a[p->iMin]) ){
 
 
81472 sampleInsert(p, &p->current, 0);
81473 }
81474 }
81475 #endif
81476 }
@@ -81500,12 +81666,11 @@
81500
81501 assert( p->nCol>1 ); /* Includes rowid field */
81502 assert( iChng<p->nCol );
81503
81504 if( p->nRow==0 ){
81505 /* anEq[0] is only zero for the very first call to this function. Do
81506 ** appropriate initialization */
81507 for(i=0; i<p->nCol; i++) p->current.anEq[i] = 1;
81508 }else{
81509 /* Second and subsequent calls get processed here */
81510 samplePushPrevious(p, iChng);
81511
@@ -81541,11 +81706,11 @@
81541 }
81542
81543 /* Update the aBest[] array. */
81544 for(i=0; i<(p->nCol-1); i++){
81545 p->current.iCol = i;
81546 if( i>=iChng || sampleIsBetter(&p->current, &p->aBest[i]) ){
81547 sampleCopy(p, &p->aBest[i], &p->current);
81548 }
81549 }
81550 }
81551 #endif
@@ -82249,11 +82414,11 @@
82249 IndexSample *pFinal = &aSample[pIdx->nSample-1];
82250 int iCol;
82251 for(iCol=0; iCol<pIdx->nColumn; iCol++){
82252 int i; /* Used to iterate through samples */
82253 tRowcnt sumEq = 0; /* Sum of the nEq values */
82254 int nSum = 0; /* Number of terms contributing to sumEq */
82255 tRowcnt avgEq = 0;
82256 tRowcnt nDLt = pFinal->anDLt[iCol];
82257
82258 /* Set nSum to the number of distinct (iCol+1) field prefixes that
82259 ** occur in the stat4 table for this index before pFinal. Set
@@ -105797,13 +105962,13 @@
105797 /*
105798 ** Each instance of this object holds a sequence of WhereLoop objects
105799 ** that implement some or all of a query plan.
105800 **
105801 ** Think of each WhereLoop object as a node in a graph with arcs
105802 ** showing dependences and costs for travelling between nodes. (That is
105803 ** not a completely accurate description because WhereLoop costs are a
105804 ** vector, not a scalar, and because dependences are many-to-one, not
105805 ** one-to-one as are graph nodes. But it is a useful visualization aid.)
105806 ** Then a WherePath object is a path through the graph that visits some
105807 ** or all of the WhereLoop objects once.
105808 **
105809 ** The "solver" works by creating the N best WherePath objects of length
@@ -108033,16 +108198,19 @@
108033 UnpackedRecord *pRec, /* Vector of values to consider */
108034 int roundUp, /* Round up if true. Round down if false */
108035 tRowcnt *aStat /* OUT: stats written here */
108036 ){
108037 IndexSample *aSample = pIdx->aSample;
108038 int iCol = pRec->nField-1; /* Index of required stats in anEq[] etc. */
108039 int iMin = 0; /* Smallest sample not yet tested */
108040 int i = pIdx->nSample; /* Smallest sample larger than or equal to pRec */
108041 int iTest; /* Next sample to test */
108042 int res; /* Result of comparison operation */
108043
 
 
 
108044 assert( pIdx->nSample>0 );
108045 assert( pRec->nField>0 && iCol<pIdx->nSampleCol );
108046 do{
108047 iTest = (iMin+i)/2;
108048 res = sqlite3VdbeRecordCompare(aSample[iTest].n, aSample[iTest].p, pRec);
@@ -108165,11 +108333,11 @@
108165 && p->nSample
108166 && OptimizationEnabled(pParse->db, SQLITE_Stat3)
108167 ){
108168 UnpackedRecord *pRec = pBuilder->pRec;
108169 tRowcnt a[2];
108170 u8 aff = p->pTable->aCol[p->aiColumn[0]].affinity;
108171
108172 /* Variable iLower will be set to the estimate of the number of rows in
108173 ** the index that are less than the lower bound of the range query. The
108174 ** lower bound being the concatenation of $P and $L, where $P is the
108175 ** key-prefix formed by the nEq values matched against the nEq left-most
@@ -108187,10 +108355,15 @@
108187 ** of iUpper are requested of whereKeyStats() and the smaller used.
108188 */
108189 tRowcnt iLower;
108190 tRowcnt iUpper;
108191
 
 
 
 
 
108192 /* Determine iLower and iUpper using ($P) only. */
108193 if( nEq==0 ){
108194 iLower = 0;
108195 iUpper = p->aiRowEst[0];
108196 }else{
@@ -109781,19 +109954,21 @@
109781 assert( p->rSetup>=pTemplate->rSetup );
109782
109783 if( (p->prereq & pTemplate->prereq)==p->prereq
109784 && p->rSetup<=pTemplate->rSetup
109785 && p->rRun<=pTemplate->rRun
 
109786 ){
109787 /* This branch taken when p is equal or better than pTemplate in
109788 ** all of (1) dependences (2) setup-cost, and (3) run-cost. */
 
109789 assert( p->rSetup==pTemplate->rSetup );
109790 if( p->nLTerm<pTemplate->nLTerm
 
109791 && (p->wsFlags & WHERE_INDEXED)!=0
109792 && (pTemplate->wsFlags & WHERE_INDEXED)!=0
109793 && p->u.btree.pIndex==pTemplate->u.btree.pIndex
109794 && p->prereq==pTemplate->prereq
109795 ){
109796 /* Overwrite an existing WhereLoop with an similar one that uses
109797 ** more terms of the index */
109798 pNext = p->pNextLoop;
109799 break;
@@ -109803,15 +109978,17 @@
109803 goto whereLoopInsert_noop;
109804 }
109805 }
109806 if( (p->prereq & pTemplate->prereq)==pTemplate->prereq
109807 && p->rRun>=pTemplate->rRun
 
109808 && ALWAYS(p->rSetup>=pTemplate->rSetup) /* See SETUP-INVARIANT above */
109809 ){
109810 /* Overwrite an existing WhereLoop with a better one: one that is
109811 ** better at one of (1) dependences, (2) setup-cost, or (3) run-cost
109812 ** and is no worse in any of those categories. */
 
109813 pNext = p->pNextLoop;
109814 break;
109815 }
109816 }
109817
@@ -111512,11 +111689,11 @@
111512 if( pWInfo->nLevel>=2
111513 && pResultSet!=0
111514 && OptimizationEnabled(db, SQLITE_OmitNoopJoin)
111515 ){
111516 Bitmask tabUsed = exprListTableUsage(pMaskSet, pResultSet);
111517 if( pOrderBy ) tabUsed |= exprListTableUsage(pMaskSet, pOrderBy);
111518 while( pWInfo->nLevel>=2 ){
111519 WhereTerm *pTerm, *pEnd;
111520 pLoop = pWInfo->a[pWInfo->nLevel-1].pWLoop;
111521 if( (pWInfo->pTabList->a[pLoop->iTab].jointype & JT_LEFT)==0 ) break;
111522 if( (wctrlFlags & WHERE_WANT_DISTINCT)==0
@@ -117544,18 +117721,20 @@
117544 case SQLITE_IOERR_SHMMAP: zName = "SQLITE_IOERR_SHMMAP"; break;
117545 case SQLITE_IOERR_SEEK: zName = "SQLITE_IOERR_SEEK"; break;
117546 case SQLITE_IOERR_DELETE_NOENT: zName = "SQLITE_IOERR_DELETE_NOENT";break;
117547 case SQLITE_IOERR_MMAP: zName = "SQLITE_IOERR_MMAP"; break;
117548 case SQLITE_IOERR_GETTEMPPATH: zName = "SQLITE_IOERR_GETTEMPPATH"; break;
 
117549 case SQLITE_CORRUPT: zName = "SQLITE_CORRUPT"; break;
117550 case SQLITE_CORRUPT_VTAB: zName = "SQLITE_CORRUPT_VTAB"; break;
117551 case SQLITE_NOTFOUND: zName = "SQLITE_NOTFOUND"; break;
117552 case SQLITE_FULL: zName = "SQLITE_FULL"; break;
117553 case SQLITE_CANTOPEN: zName = "SQLITE_CANTOPEN"; break;
117554 case SQLITE_CANTOPEN_NOTEMPDIR: zName = "SQLITE_CANTOPEN_NOTEMPDIR";break;
117555 case SQLITE_CANTOPEN_ISDIR: zName = "SQLITE_CANTOPEN_ISDIR"; break;
117556 case SQLITE_CANTOPEN_FULLPATH: zName = "SQLITE_CANTOPEN_FULLPATH"; break;
 
117557 case SQLITE_PROTOCOL: zName = "SQLITE_PROTOCOL"; break;
117558 case SQLITE_EMPTY: zName = "SQLITE_EMPTY"; break;
117559 case SQLITE_SCHEMA: zName = "SQLITE_SCHEMA"; break;
117560 case SQLITE_TOOBIG: zName = "SQLITE_TOOBIG"; break;
117561 case SQLITE_CONSTRAINT: zName = "SQLITE_CONSTRAINT"; break;
117562
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -656,11 +656,11 @@
656 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
657 ** [sqlite_version()] and [sqlite_source_id()].
658 */
659 #define SQLITE_VERSION "3.8.1"
660 #define SQLITE_VERSION_NUMBER 3008001
661 #define SQLITE_SOURCE_ID "2013-09-04 04:04:08 8df95bb0b3f72222cf262174247a467c234f9939"
662
663 /*
664 ** CAPI3REF: Run-Time Library Version Numbers
665 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
666 **
@@ -1026,16 +1026,18 @@
1026 #define SQLITE_IOERR_SHMMAP (SQLITE_IOERR | (21<<8))
1027 #define SQLITE_IOERR_SEEK (SQLITE_IOERR | (22<<8))
1028 #define SQLITE_IOERR_DELETE_NOENT (SQLITE_IOERR | (23<<8))
1029 #define SQLITE_IOERR_MMAP (SQLITE_IOERR | (24<<8))
1030 #define SQLITE_IOERR_GETTEMPPATH (SQLITE_IOERR | (25<<8))
1031 #define SQLITE_IOERR_CONVPATH (SQLITE_IOERR | (26<<8))
1032 #define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8))
1033 #define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8))
1034 #define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8))
1035 #define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8))
1036 #define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8))
1037 #define SQLITE_CANTOPEN_FULLPATH (SQLITE_CANTOPEN | (3<<8))
1038 #define SQLITE_CANTOPEN_CONVPATH (SQLITE_CANTOPEN | (4<<8))
1039 #define SQLITE_CORRUPT_VTAB (SQLITE_CORRUPT | (1<<8))
1040 #define SQLITE_READONLY_RECOVERY (SQLITE_READONLY | (1<<8))
1041 #define SQLITE_READONLY_CANTLOCK (SQLITE_READONLY | (2<<8))
1042 #define SQLITE_READONLY_ROLLBACK (SQLITE_READONLY | (3<<8))
1043 #define SQLITE_ABORT_ROLLBACK (SQLITE_ABORT | (2<<8))
@@ -16259,11 +16261,11 @@
16261 assert( mem.disallow==0 );
16262 assert( (nByte & 7)==0 ); /* EV: R-46199-30249 */
16263 pOldHdr = sqlite3MemsysGetHeader(pPrior);
16264 pNew = sqlite3MemMalloc(nByte);
16265 if( pNew ){
16266 memcpy(pNew, pPrior, (int)(nByte<pOldHdr->iSize ? nByte : pOldHdr->iSize));
16267 if( nByte>pOldHdr->iSize ){
16268 randomFill(&((char*)pNew)[pOldHdr->iSize], nByte - (int)pOldHdr->iSize);
16269 }
16270 sqlite3MemFree(pPrior);
16271 }
@@ -23594,10 +23596,19 @@
23596 if( aSyscall[i].pCurrent!=0 ) return aSyscall[i].zName;
23597 }
23598 return 0;
23599 }
23600
23601 /*
23602 ** Do not accept any file descriptor less than this value, in order to avoid
23603 ** opening database file using file descriptors that are commonly used for
23604 ** standard input, output, and error.
23605 */
23606 #ifndef SQLITE_MINIMUM_FILE_DESCRIPTOR
23607 # define SQLITE_MINIMUM_FILE_DESCRIPTOR 3
23608 #endif
23609
23610 /*
23611 ** Invoke open(). Do so multiple times, until it either succeeds or
23612 ** fails for some reason other than EINTR.
23613 **
23614 ** If the file creation mode "m" is 0 then set it to the default for
@@ -23624,11 +23635,11 @@
23635 #endif
23636 if( fd<0 ){
23637 if( errno==EINTR ) continue;
23638 break;
23639 }
23640 if( fd>=SQLITE_MINIMUM_FILE_DESCRIPTOR ) break;
23641 osClose(fd);
23642 sqlite3_log(SQLITE_WARNING,
23643 "attempt to open \"%s\" as file descriptor %d", z, fd);
23644 fd = -1;
23645 if( osOpen("/dev/null", f, m)<0 ) break;
@@ -28373,10 +28384,11 @@
28384 ** If no suitable temporary file directory can be found, return NULL.
28385 */
28386 static const char *unixTempFileDir(void){
28387 static const char *azDirs[] = {
28388 0,
28389 0,
28390 0,
28391 "/var/tmp",
28392 "/usr/tmp",
28393 "/tmp",
28394 0 /* List terminator */
@@ -28384,11 +28396,12 @@
28396 unsigned int i;
28397 struct stat buf;
28398 const char *zDir = 0;
28399
28400 azDirs[0] = sqlite3_temp_directory;
28401 if( !azDirs[1] ) azDirs[1] = getenv("SQLITE_TMPDIR");
28402 if( !azDirs[2] ) azDirs[2] = getenv("TMPDIR");
28403 for(i=0; i<sizeof(azDirs)/sizeof(azDirs[0]); zDir=azDirs[i++]){
28404 if( zDir==0 ) continue;
28405 if( osStat(zDir, &buf) ) continue;
28406 if( !S_ISDIR(buf.st_mode) ) continue;
28407 if( osAccess(zDir, 07) ) continue;
@@ -30497,11 +30510,11 @@
30510 */
30511 #if SQLITE_OS_WIN /* This file is used for Windows only */
30512
30513 #ifdef __CYGWIN__
30514 # include <sys/cygwin.h>
30515 # include <errno.h> /* amalgamator: keep */
30516 #endif
30517
30518 /*
30519 ** Include code that is common to all os_*.c files
30520 */
@@ -30726,22 +30739,31 @@
30739
30740 /*
30741 ** Are most of the Win32 ANSI APIs available (i.e. with certain exceptions
30742 ** based on the sub-platform)?
30743 */
30744 #if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && !defined(SQLITE_WIN32_NO_ANSI)
30745 # define SQLITE_WIN32_HAS_ANSI
30746 #endif
30747
30748 /*
30749 ** Are most of the Win32 Unicode APIs available (i.e. with certain exceptions
30750 ** based on the sub-platform)?
30751 */
30752 #if (SQLITE_OS_WINCE || SQLITE_OS_WINNT || SQLITE_OS_WINRT) && \
30753 !defined(SQLITE_WIN32_NO_WIDE)
30754 # define SQLITE_WIN32_HAS_WIDE
30755 #endif
30756
30757 /*
30758 ** Make sure at least one set of Win32 APIs is available.
30759 */
30760 #if !defined(SQLITE_WIN32_HAS_ANSI) && !defined(SQLITE_WIN32_HAS_WIDE)
30761 # error "At least one of SQLITE_WIN32_HAS_ANSI and SQLITE_WIN32_HAS_WIDE\
30762 must be defined."
30763 #endif
30764
30765 /*
30766 ** Maximum pathname length (in chars) for Win32. This should normally be
30767 ** MAX_PATH.
30768 */
30769 #ifndef SQLITE_WIN32_MAX_PATH_CHARS
@@ -30849,11 +30871,11 @@
30871 #ifndef FILE_ATTRIBUTE_MASK
30872 # define FILE_ATTRIBUTE_MASK (0x0003FFF7)
30873 #endif
30874
30875 #ifndef SQLITE_OMIT_WAL
30876 /* Forward references to structures used for WAL */
30877 typedef struct winShm winShm; /* A connection to shared-memory */
30878 typedef struct winShmNode winShmNode; /* A region of shared-memory */
30879 #endif
30880
30881 /*
@@ -31804,11 +31826,11 @@
31826 ** API as long as we don't call it when running Win95/98/ME. A call to
31827 ** this routine is used to determine if the host is Win95/98/ME or
31828 ** WinNT/2K/XP so that we will know whether or not we can safely call
31829 ** the LockFileEx() API.
31830 */
31831 #if SQLITE_OS_WINCE || SQLITE_OS_WINRT || !defined(SQLITE_WIN32_HAS_ANSI)
31832 # define osIsNT() (1)
31833 #elif !defined(SQLITE_WIN32_HAS_WIDE)
31834 # define osIsNT() (0)
31835 #else
31836 static int osIsNT(void){
@@ -32449,14 +32471,13 @@
32471
32472 /* Create/open the named mutex */
32473 pFile->hMutex = osCreateMutexW(NULL, FALSE, zName);
32474 if (!pFile->hMutex){
32475 pFile->lastErrno = osGetLastError();
 
 
32476 sqlite3_free(zName);
32477 return winLogError(SQLITE_IOERR, pFile->lastErrno,
32478 "winceCreateLock1", zFilename);
32479 }
32480
32481 /* Acquire the mutex before continuing */
32482 winceMutexAcquire(pFile->hMutex);
32483
@@ -32788,11 +32809,11 @@
32809
32810 if( (dwRet==INVALID_SET_FILE_POINTER
32811 && ((lastErrno = osGetLastError())!=NO_ERROR)) ){
32812 pFile->lastErrno = lastErrno;
32813 winLogError(SQLITE_IOERR_SEEK, pFile->lastErrno,
32814 "winSeekFile", pFile->zPath);
32815 OSTRACE(("SEEK file=%p, rc=SQLITE_IOERR_SEEK\n", pFile->h));
32816 return 1;
32817 }
32818
32819 OSTRACE(("SEEK file=%p, rc=SQLITE_OK\n", pFile->h));
@@ -32809,11 +32830,11 @@
32830 bRet = osSetFilePointerEx(pFile->h, x, 0, FILE_BEGIN);
32831
32832 if(!bRet){
32833 pFile->lastErrno = osGetLastError();
32834 winLogError(SQLITE_IOERR_SEEK, pFile->lastErrno,
32835 "winSeekFile", pFile->zPath);
32836 OSTRACE(("SEEK file=%p, rc=SQLITE_IOERR_SEEK\n", pFile->h));
32837 return 1;
32838 }
32839
32840 OSTRACE(("SEEK file=%p, rc=SQLITE_OK\n", pFile->h));
@@ -32820,11 +32841,12 @@
32841 return 0;
32842 #endif
32843 }
32844
32845 #if SQLITE_MAX_MMAP_SIZE>0
32846 /* Forward references to VFS helper methods used for memory mapped files */
32847 static int winMapfile(winFile*, sqlite3_int64);
32848 static int winUnmapfile(winFile*);
32849 #endif
32850
32851 /*
32852 ** Close a file.
@@ -32941,11 +32963,11 @@
32963 DWORD lastErrno;
32964 if( winRetryIoerr(&nRetry, &lastErrno) ) continue;
32965 pFile->lastErrno = lastErrno;
32966 OSTRACE(("READ file=%p, rc=SQLITE_IOERR_READ\n", pFile->h));
32967 return winLogError(SQLITE_IOERR_READ, pFile->lastErrno,
32968 "winRead", pFile->zPath);
32969 }
32970 winLogIoerr(nRetry);
32971 if( nRead<(DWORD)amt ){
32972 /* Unread parts of the buffer must be zero-filled */
32973 memset(&((char*)pBuf)[nRead], 0, amt-nRead);
@@ -33047,15 +33069,16 @@
33069
33070 if( rc ){
33071 if( ( pFile->lastErrno==ERROR_HANDLE_DISK_FULL )
33072 || ( pFile->lastErrno==ERROR_DISK_FULL )){
33073 OSTRACE(("WRITE file=%p, rc=SQLITE_FULL\n", pFile->h));
33074 return winLogError(SQLITE_FULL, pFile->lastErrno,
33075 "winWrite1", pFile->zPath);
33076 }
33077 OSTRACE(("WRITE file=%p, rc=SQLITE_IOERR_WRITE\n", pFile->h));
33078 return winLogError(SQLITE_IOERR_WRITE, pFile->lastErrno,
33079 "winWrite2", pFile->zPath);
33080 }else{
33081 winLogIoerr(nRetry);
33082 }
33083 OSTRACE(("WRITE file=%p, rc=SQLITE_OK\n", pFile->h));
33084 return SQLITE_OK;
@@ -33175,11 +33198,11 @@
33198 return SQLITE_OK;
33199 }else{
33200 pFile->lastErrno = osGetLastError();
33201 OSTRACE(("SYNC file=%p, rc=SQLITE_IOERR_FSYNC\n", pFile->h));
33202 return winLogError(SQLITE_IOERR_FSYNC, pFile->lastErrno,
33203 "winSync", pFile->zPath);
33204 }
33205 #endif
33206 }
33207
33208 /*
@@ -33216,11 +33239,11 @@
33239 *pSize = (((sqlite3_int64)upperBits)<<32) + lowerBits;
33240 if( (lowerBits == INVALID_FILE_SIZE)
33241 && ((lastErrno = osGetLastError())!=NO_ERROR) ){
33242 pFile->lastErrno = lastErrno;
33243 rc = winLogError(SQLITE_IOERR_FSTAT, pFile->lastErrno,
33244 "winFileSize", pFile->zPath);
33245 }
33246 }
33247 #endif
33248 OSTRACE(("SIZE file=%p, pSize=%p, *pSize=%lld, rc=%s\n",
33249 pFile->h, pSize, *pSize, sqlite3ErrName(rc)));
@@ -33311,11 +33334,11 @@
33334 }
33335 #endif
33336 if( res==0 && ((lastErrno = osGetLastError())!=ERROR_NOT_LOCKED) ){
33337 pFile->lastErrno = lastErrno;
33338 winLogError(SQLITE_IOERR_UNLOCK, pFile->lastErrno,
33339 "winUnlockReadLock", pFile->zPath);
33340 }
33341 OSTRACE(("READ-UNLOCK file=%p, rc=%s\n", pFile->h, sqlite3ErrName(res)));
33342 return res;
33343 }
33344
@@ -33524,11 +33547,11 @@
33547 winUnlockFile(&pFile->h, SHARED_FIRST, 0, SHARED_SIZE, 0);
33548 if( locktype==SHARED_LOCK && !winGetReadLock(pFile) ){
33549 /* This should never happen. We should always be able to
33550 ** reacquire the read lock */
33551 rc = winLogError(SQLITE_IOERR_UNLOCK, osGetLastError(),
33552 "winUnlock", pFile->zPath);
33553 }
33554 }
33555 if( type>=RESERVED_LOCK ){
33556 winUnlockFile(&pFile->h, RESERVED_BYTE, 0, 1, 0);
33557 }
@@ -33558,15 +33581,14 @@
33581 }else{
33582 pFile->ctrlFlags |= mask;
33583 }
33584 }
33585
33586 /* Forward references to VFS helper methods used for temporary files */
33587 static int winGetTempname(sqlite3_vfs *, char **);
33588 static int winIsDir(const void *);
33589 static BOOL winIsDriveLetterAndColon(const char *);
 
33590
33591 /*
33592 ** Control and query of the open file handle.
33593 */
33594 static int winFileControl(sqlite3_file *id, int op, void *pArg){
@@ -33640,11 +33662,11 @@
33662 char *zTFile = 0;
33663 int rc = winGetTempname(pFile->pVfs, &zTFile);
33664 if( rc==SQLITE_OK ){
33665 *(char**)pArg = zTFile;
33666 }
33667 OSTRACE(("FCNTL file=%p, rc=%s\n", pFile->h, sqlite3ErrName(rc)));
33668 return rc;
33669 }
33670 #if SQLITE_MAX_MMAP_SIZE>0
33671 case SQLITE_FCNTL_MMAP_SIZE: {
33672 i64 newLimit = *(i64*)pArg;
@@ -33658,11 +33680,11 @@
33680 if( pFile->mmapSize>0 ){
33681 (void)winUnmapfile(pFile);
33682 rc = winMapfile(pFile, -1);
33683 }
33684 }
33685 OSTRACE(("FCNTL file=%p, rc=%s\n", pFile->h, sqlite3ErrName(rc)));
33686 return rc;
33687 }
33688 #endif
33689 }
33690 OSTRACE(("FCNTL file=%p, rc=SQLITE_NOTFOUND\n", pFile->h));
@@ -33974,11 +33996,11 @@
33996 */
33997 if( winShmSystemLock(pShmNode, _SHM_WRLCK, WIN_SHM_DMS, 1)==SQLITE_OK ){
33998 rc = winTruncate((sqlite3_file *)&pShmNode->hFile, 0);
33999 if( rc!=SQLITE_OK ){
34000 rc = winLogError(SQLITE_IOERR_SHMOPEN, osGetLastError(),
34001 "winOpenShm", pDbFd->zPath);
34002 }
34003 }
34004 if( rc==SQLITE_OK ){
34005 winShmSystemLock(pShmNode, _SHM_UNLCK, WIN_SHM_DMS, 1);
34006 rc = winShmSystemLock(pShmNode, _SHM_RDLCK, WIN_SHM_DMS, 1);
@@ -34234,11 +34256,11 @@
34256 ** large enough to contain the requested region).
34257 */
34258 rc = winFileSize((sqlite3_file *)&pShmNode->hFile, &sz);
34259 if( rc!=SQLITE_OK ){
34260 rc = winLogError(SQLITE_IOERR_SHMSIZE, osGetLastError(),
34261 "winShmMap1", pDbFd->zPath);
34262 goto shmpage_out;
34263 }
34264
34265 if( sz<nByte ){
34266 /* The requested memory region does not exist. If isWrite is set to
@@ -34249,11 +34271,11 @@
34271 */
34272 if( !isWrite ) goto shmpage_out;
34273 rc = winTruncate((sqlite3_file *)&pShmNode->hFile, nByte);
34274 if( rc!=SQLITE_OK ){
34275 rc = winLogError(SQLITE_IOERR_SHMSIZE, osGetLastError(),
34276 "winShmMap2", pDbFd->zPath);
34277 goto shmpage_out;
34278 }
34279 }
34280
34281 /* Map the requested memory region into this processes address space. */
@@ -34303,11 +34325,11 @@
34325 szRegion, pMap ? "ok" : "failed"));
34326 }
34327 if( !pMap ){
34328 pShmNode->lastErrno = osGetLastError();
34329 rc = winLogError(SQLITE_IOERR_SHMMAP, pShmNode->lastErrno,
34330 "winShmMap3", pDbFd->zPath);
34331 if( hMap ) osCloseHandle(hMap);
34332 goto shmpage_out;
34333 }
34334
34335 pShmNode->aRegion[pShmNode->nRegion].pMap = pMap;
@@ -34351,11 +34373,11 @@
34373 pFile->lastErrno = osGetLastError();
34374 OSTRACE(("UNMAP-FILE pid=%lu, pFile=%p, pMapRegion=%p, "
34375 "rc=SQLITE_IOERR_MMAP\n", osGetCurrentProcessId(), pFile,
34376 pFile->pMapRegion));
34377 return winLogError(SQLITE_IOERR_MMAP, pFile->lastErrno,
34378 "winUnmapfile1", pFile->zPath);
34379 }
34380 pFile->pMapRegion = 0;
34381 pFile->mmapSize = 0;
34382 pFile->mmapSizeActual = 0;
34383 }
@@ -34363,11 +34385,11 @@
34385 if( !osCloseHandle(pFile->hMap) ){
34386 pFile->lastErrno = osGetLastError();
34387 OSTRACE(("UNMAP-FILE pid=%lu, pFile=%p, hMap=%p, rc=SQLITE_IOERR_MMAP\n",
34388 osGetCurrentProcessId(), pFile, pFile->hMap));
34389 return winLogError(SQLITE_IOERR_MMAP, pFile->lastErrno,
34390 "winUnmapfile2", pFile->zPath);
34391 }
34392 pFile->hMap = NULL;
34393 }
34394 OSTRACE(("UNMAP-FILE pid=%lu, pFile=%p, rc=SQLITE_OK\n",
34395 osGetCurrentProcessId(), pFile));
@@ -34438,14 +34460,14 @@
34460 (DWORD)(nMap & 0xffffffff), NULL);
34461 #endif
34462 if( pFd->hMap==NULL ){
34463 pFd->lastErrno = osGetLastError();
34464 rc = winLogError(SQLITE_IOERR_MMAP, pFd->lastErrno,
34465 "winMapfile1", pFd->zPath);
34466 /* Log the error, but continue normal operation using xRead/xWrite */
34467 OSTRACE(("MAP-FILE-CREATE pid=%lu, pFile=%p, rc=%s\n",
34468 osGetCurrentProcessId(), pFd, sqlite3ErrName(rc)));
34469 return SQLITE_OK;
34470 }
34471 assert( (nMap % winSysInfo.dwPageSize)==0 );
34472 assert( sizeof(SIZE_T)==sizeof(sqlite3_int64) || nMap<=0xffffffff );
34473 #if SQLITE_OS_WINRT
@@ -34455,14 +34477,15 @@
34477 #endif
34478 if( pNew==NULL ){
34479 osCloseHandle(pFd->hMap);
34480 pFd->hMap = NULL;
34481 pFd->lastErrno = osGetLastError();
34482 rc = winLogError(SQLITE_IOERR_MMAP, pFd->lastErrno,
34483 "winMapfile2", pFd->zPath);
34484 /* Log the error, but continue normal operation using xRead/xWrite */
34485 OSTRACE(("MAP-FILE-MAP pid=%lu, pFile=%p, rc=%s\n",
34486 osGetCurrentProcessId(), pFd, sqlite3ErrName(rc)));
34487 return SQLITE_OK;
34488 }
34489 pFd->pMapRegion = pNew;
34490 pFd->mmapSize = nMap;
34491 pFd->mmapSizeActual = nMap;
@@ -34596,18 +34619,37 @@
34619 **************************** sqlite3_vfs methods ****************************
34620 **
34621 ** This division contains the implementation of methods on the
34622 ** sqlite3_vfs object.
34623 */
34624
34625 /*
34626 ** Convert a filename from whatever the underlying operating system
34627 ** supports for filenames into UTF-8. Space to hold the result is
34628 ** obtained from malloc and must be freed by the calling function.
34629 */
34630 static char *winConvertToUtf8Filename(const void *zFilename){
34631 char *zConverted = 0;
34632 if( osIsNT() ){
34633 zConverted = winUnicodeToUtf8(zFilename);
34634 }
34635 #ifdef SQLITE_WIN32_HAS_ANSI
34636 else{
34637 zConverted = sqlite3_win32_mbcs_to_utf8(zFilename);
34638 }
34639 #endif
34640 /* caller will handle out of memory */
34641 return zConverted;
34642 }
34643
34644 /*
34645 ** Convert a UTF-8 filename into whatever form the underlying
34646 ** operating system wants filenames in. Space to hold the result
34647 ** is obtained from malloc and must be freed by the calling
34648 ** function.
34649 */
34650 static void *winConvertFromUtf8Filename(const char *zFilename){
34651 void *zConverted = 0;
34652 if( osIsNT() ){
34653 zConverted = winUtf8ToUnicode(zFilename);
34654 }
34655 #ifdef SQLITE_WIN32_HAS_ANSI
@@ -34668,11 +34710,94 @@
34710 if( sqlite3_temp_directory ){
34711 sqlite3_snprintf(nBuf-30, zBuf, "%s%s", sqlite3_temp_directory,
34712 winEndsInDirSep(sqlite3_temp_directory) ? "" :
34713 winGetDirDep());
34714 }
34715 #if defined(__CYGWIN__)
34716 else{
34717 static const char *azDirs[] = {
34718 0, /* getenv("SQLITE_TMPDIR") */
34719 0, /* getenv("TMPDIR") */
34720 0, /* getenv("TMP") */
34721 0, /* getenv("TEMP") */
34722 0, /* getenv("USERPROFILE") */
34723 "/var/tmp",
34724 "/usr/tmp",
34725 "/tmp",
34726 ".",
34727 0 /* List terminator */
34728 };
34729 unsigned int i;
34730 const char *zDir = 0;
34731
34732 if( !azDirs[0] ) azDirs[0] = getenv("SQLITE_TMPDIR");
34733 if( !azDirs[1] ) azDirs[1] = getenv("TMPDIR");
34734 if( !azDirs[2] ) azDirs[2] = getenv("TMP");
34735 if( !azDirs[3] ) azDirs[3] = getenv("TEMP");
34736 if( !azDirs[4] ) azDirs[4] = getenv("USERPROFILE");
34737 for(i=0; i<sizeof(azDirs)/sizeof(azDirs[0]); zDir=azDirs[i++]){
34738 void *zConverted;
34739 if( zDir==0 ) continue;
34740 /* If the path starts with a drive letter followed by the colon
34741 ** character, assume it is already a native Win32 path; otherwise,
34742 ** it must be converted to a native Win32 path prior via the Cygwin
34743 ** API prior to using it.
34744 */
34745 if( winIsDriveLetterAndColon(zDir) ){
34746 zConverted = winConvertFromUtf8Filename(zDir);
34747 if( !zConverted ){
34748 OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
34749 return SQLITE_IOERR_NOMEM;
34750 }
34751 if( winIsDir(zConverted) ){
34752 sqlite3_snprintf(nBuf-30, zBuf, "%s", zDir);
34753 sqlite3_free(zConverted);
34754 break;
34755 }
34756 sqlite3_free(zConverted);
34757 }else{
34758 zConverted = sqlite3MallocZero( nBuf+1 );
34759 if( !zConverted ){
34760 OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
34761 return SQLITE_IOERR_NOMEM;
34762 }
34763 if( cygwin_conv_path(
34764 osIsNT() ? CCP_POSIX_TO_WIN_W : CCP_POSIX_TO_WIN_A, zDir,
34765 zConverted, nBuf+1)<0 ){
34766 sqlite3_free(zConverted);
34767 OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_CONVPATH\n"));
34768 return winLogError(SQLITE_IOERR_CONVPATH, (DWORD)errno,
34769 "winGetTempname1", zDir);
34770 }
34771 if( winIsDir(zConverted) ){
34772 /* At this point, we know the candidate directory exists and should
34773 ** be used. However, we may need to convert the string containing
34774 ** its name into UTF-8 (i.e. if it is UTF-16 right now).
34775 */
34776 if( osIsNT() ){
34777 char *zUtf8 = winUnicodeToUtf8(zConverted);
34778 if( !zUtf8 ){
34779 sqlite3_free(zConverted);
34780 OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
34781 return SQLITE_IOERR_NOMEM;
34782 }
34783 sqlite3_snprintf(nBuf-30, zBuf, "%s", zUtf8);
34784 sqlite3_free(zUtf8);
34785 sqlite3_free(zConverted);
34786 break;
34787 }else{
34788 sqlite3_snprintf(nBuf-30, zBuf, "%s", zConverted);
34789 sqlite3_free(zConverted);
34790 break;
34791 }
34792 }
34793 sqlite3_free(zConverted);
34794 }
34795 break;
34796 }
34797 }
34798 #elif !SQLITE_OS_WINRT && !defined(__CYGWIN__)
34799 else if( osIsNT() ){
34800 char *zMulti;
34801 LPWSTR zWidePath = sqlite3MallocZero( nBuf*sizeof(WCHAR) );
34802 if( !zWidePath ){
34803 sqlite3_free(zBuf);
@@ -34681,11 +34806,12 @@
34806 }
34807 if( osGetTempPathW(nBuf, zWidePath)==0 ){
34808 sqlite3_free(zWidePath);
34809 sqlite3_free(zBuf);
34810 OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_GETTEMPPATH\n"));
34811 return winLogError(SQLITE_IOERR_GETTEMPPATH, osGetLastError(),
34812 "winGetTempname1", 0);
34813 }
34814 zMulti = winUnicodeToUtf8(zWidePath);
34815 if( zMulti ){
34816 sqlite3_snprintf(nBuf-30, zBuf, "%s", zMulti);
34817 sqlite3_free(zMulti);
@@ -34707,11 +34833,12 @@
34833 return SQLITE_IOERR_NOMEM;
34834 }
34835 if( osGetTempPathA(nBuf, zMbcsPath)==0 ){
34836 sqlite3_free(zBuf);
34837 OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_GETTEMPPATH\n"));
34838 return winLogError(SQLITE_IOERR_GETTEMPPATH, osGetLastError(),
34839 "winGetTempname2", 0);
34840 }
34841 zUtf8 = sqlite3_win32_mbcs_to_utf8(zMbcsPath);
34842 if( zUtf8 ){
34843 sqlite3_snprintf(nBuf-30, zBuf, "%s", zUtf8);
34844 sqlite3_free(zUtf8);
@@ -34730,11 +34857,11 @@
34857 nLen = sqlite3Strlen30(zBuf);
34858
34859 if( (nLen + sqlite3Strlen30(SQLITE_TEMP_FILE_PREFIX) + 18) >= nBuf ){
34860 sqlite3_free(zBuf);
34861 OSTRACE(("TEMP-FILENAME rc=SQLITE_ERROR\n"));
34862 return winLogError(SQLITE_ERROR, 0, "winGetTempname3", 0);
34863 }
34864
34865 sqlite3_snprintf(nBuf-18-nLen, zBuf+nLen, SQLITE_TEMP_FILE_PREFIX);
34866
34867 j = sqlite3Strlen30(zBuf);
@@ -34886,11 +35013,11 @@
35013 */
35014 assert( (eType!=SQLITE_OPEN_MAIN_DB) || (flags & SQLITE_OPEN_URI) ||
35015 zUtf8Name[sqlite3Strlen30(zUtf8Name)+1]==0 );
35016
35017 /* Convert the filename to the system encoding. */
35018 zConverted = winConvertFromUtf8Filename(zUtf8Name);
35019 if( zConverted==0 ){
35020 sqlite3_free(zTmpname);
35021 OSTRACE(("OPEN name=%s, rc=SQLITE_IOERR_NOMEM", zUtf8Name));
35022 return SQLITE_IOERR_NOMEM;
35023 }
@@ -35087,11 +35214,11 @@
35214 UNUSED_PARAMETER(syncDir);
35215
35216 SimulateIOError(return SQLITE_IOERR_DELETE);
35217 OSTRACE(("DELETE name=%s, syncDir=%d\n", zFilename, syncDir));
35218
35219 zConverted = winConvertFromUtf8Filename(zFilename);
35220 if( zConverted==0 ){
35221 OSTRACE(("DELETE name=%s, rc=SQLITE_IOERR_NOMEM\n", zFilename));
35222 return SQLITE_IOERR_NOMEM;
35223 }
35224 if( osIsNT() ){
@@ -35167,12 +35294,11 @@
35294 }
35295 } while(1);
35296 }
35297 #endif
35298 if( rc && rc!=SQLITE_IOERR_DELETE_NOENT ){
35299 rc = winLogError(SQLITE_IOERR_DELETE, lastErrno, "winDelete", zFilename);
 
35300 }else{
35301 winLogIoerr(cnt);
35302 }
35303 sqlite3_free(zConverted);
35304 OSTRACE(("DELETE name=%s, rc=%s\n", zFilename, sqlite3ErrName(rc)));
@@ -35196,11 +35322,11 @@
35322
35323 SimulateIOError( return SQLITE_IOERR_ACCESS; );
35324 OSTRACE(("ACCESS name=%s, flags=%x, pResOut=%p\n",
35325 zFilename, flags, pResOut));
35326
35327 zConverted = winConvertFromUtf8Filename(zFilename);
35328 if( zConverted==0 ){
35329 OSTRACE(("ACCESS name=%s, rc=SQLITE_IOERR_NOMEM\n", zFilename));
35330 return SQLITE_IOERR_NOMEM;
35331 }
35332 if( osIsNT() ){
@@ -35222,13 +35348,13 @@
35348 attr = sAttrData.dwFileAttributes;
35349 }
35350 }else{
35351 winLogIoerr(cnt);
35352 if( lastErrno!=ERROR_FILE_NOT_FOUND && lastErrno!=ERROR_PATH_NOT_FOUND ){
 
35353 sqlite3_free(zConverted);
35354 return winLogError(SQLITE_IOERR_ACCESS, lastErrno, "winAccess",
35355 zFilename);
35356 }else{
35357 attr = INVALID_FILE_ATTRIBUTES;
35358 }
35359 }
35360 }
@@ -35254,10 +35380,19 @@
35380 OSTRACE(("ACCESS name=%s, pResOut=%p, *pResOut=%d, rc=SQLITE_OK\n",
35381 zFilename, pResOut, *pResOut));
35382 return SQLITE_OK;
35383 }
35384
35385 /*
35386 ** Returns non-zero if the specified path name starts with a drive letter
35387 ** followed by a colon character.
35388 */
35389 static BOOL winIsDriveLetterAndColon(
35390 const char *zPathname
35391 ){
35392 return ( sqlite3Isalpha(zPathname[0]) && zPathname[1]==':' );
35393 }
35394
35395 /*
35396 ** Returns non-zero if the specified path name should be used verbatim. If
35397 ** non-zero is returned from this function, the calling function must simply
35398 ** use the provided path name verbatim -OR- resolve it into a full path name
@@ -35281,11 +35416,11 @@
35416 ** If the path name starts with a letter and a colon it is either a volume
35417 ** relative path or an absolute path. Callers of this function must not
35418 ** attempt to treat it as a relative path name (i.e. they should simply use
35419 ** it verbatim).
35420 */
35421 if ( winIsDriveLetterAndColon(zPathname) ){
35422 return TRUE;
35423 }
35424
35425 /*
35426 ** If we get to this point, the path name should almost certainly be a purely
@@ -35317,28 +35452,25 @@
35452 ** for converting the relative path name to an absolute
35453 ** one by prepending the data directory and a slash.
35454 */
35455 char *zOut = sqlite3MallocZero( pVfs->mxPathname+1 );
35456 if( !zOut ){
 
35457 return SQLITE_IOERR_NOMEM;
35458 }
35459 if( cygwin_conv_path(CCP_POSIX_TO_WIN_A|CCP_RELATIVE, zRelative, zOut,
35460 pVfs->mxPathname+1)<0 ){
 
 
35461 sqlite3_free(zOut);
35462 return winLogError(SQLITE_CANTOPEN_CONVPATH, (DWORD)errno,
35463 "winFullPathname1", zRelative);
35464 }
35465 sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s%s%s",
35466 sqlite3_data_directory, winGetDirDep(), zOut);
35467 sqlite3_free(zOut);
35468 }else{
35469 if( cygwin_conv_path(CCP_POSIX_TO_WIN_A, zRelative, zFull, nFull)<0 ){
35470 return winLogError(SQLITE_CANTOPEN_CONVPATH, (DWORD)errno,
35471 "winFullPathname2", zRelative);
 
35472 }
35473 }
35474 return SQLITE_OK;
35475 #endif
35476
@@ -35367,11 +35499,11 @@
35499 char *zOut;
35500
35501 /* If this path name begins with "/X:", where "X" is any alphabetic
35502 ** character, discard the initial "/" from the pathname.
35503 */
35504 if( zRelative[0]=='/' && winIsDriveLetterAndColon(zRelative+1) ){
35505 zRelative++;
35506 }
35507
35508 /* It's odd to simulate an io-error here, but really this is just
35509 ** using the io-error infrastructure to test that SQLite handles this
@@ -35388,36 +35520,34 @@
35520 */
35521 sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s%s%s",
35522 sqlite3_data_directory, winGetDirDep(), zRelative);
35523 return SQLITE_OK;
35524 }
35525 zConverted = winConvertFromUtf8Filename(zRelative);
35526 if( zConverted==0 ){
35527 return SQLITE_IOERR_NOMEM;
35528 }
35529 if( osIsNT() ){
35530 LPWSTR zTemp;
35531 nByte = osGetFullPathNameW((LPCWSTR)zConverted, 0, 0, 0);
35532 if( nByte==0 ){
 
 
35533 sqlite3_free(zConverted);
35534 return winLogError(SQLITE_CANTOPEN_FULLPATH, osGetLastError(),
35535 "winFullPathname1", zRelative);
35536 }
35537 nByte += 3;
35538 zTemp = sqlite3MallocZero( nByte*sizeof(zTemp[0]) );
35539 if( zTemp==0 ){
35540 sqlite3_free(zConverted);
35541 return SQLITE_IOERR_NOMEM;
35542 }
35543 nByte = osGetFullPathNameW((LPCWSTR)zConverted, nByte, zTemp, 0);
35544 if( nByte==0 ){
 
 
35545 sqlite3_free(zConverted);
35546 sqlite3_free(zTemp);
35547 return winLogError(SQLITE_CANTOPEN_FULLPATH, osGetLastError(),
35548 "winFullPathname2", zRelative);
35549 }
35550 sqlite3_free(zConverted);
35551 zOut = winUnicodeToUtf8(zTemp);
35552 sqlite3_free(zTemp);
35553 }
@@ -35424,28 +35554,26 @@
35554 #ifdef SQLITE_WIN32_HAS_ANSI
35555 else{
35556 char *zTemp;
35557 nByte = osGetFullPathNameA((char*)zConverted, 0, 0, 0);
35558 if( nByte==0 ){
 
 
35559 sqlite3_free(zConverted);
35560 return winLogError(SQLITE_CANTOPEN_FULLPATH, osGetLastError(),
35561 "winFullPathname3", zRelative);
35562 }
35563 nByte += 3;
35564 zTemp = sqlite3MallocZero( nByte*sizeof(zTemp[0]) );
35565 if( zTemp==0 ){
35566 sqlite3_free(zConverted);
35567 return SQLITE_IOERR_NOMEM;
35568 }
35569 nByte = osGetFullPathNameA((char*)zConverted, nByte, zTemp, 0);
35570 if( nByte==0 ){
 
 
35571 sqlite3_free(zConverted);
35572 sqlite3_free(zTemp);
35573 return winLogError(SQLITE_CANTOPEN_FULLPATH, osGetLastError(),
35574 "winFullPathname4", zRelative);
35575 }
35576 sqlite3_free(zConverted);
35577 zOut = sqlite3_win32_mbcs_to_utf8(zTemp);
35578 sqlite3_free(zTemp);
35579 }
@@ -35469,11 +35597,11 @@
35597 ** Interfaces for opening a shared library, finding entry points
35598 ** within the shared library, and closing the shared library.
35599 */
35600 static void *winDlOpen(sqlite3_vfs *pVfs, const char *zFilename){
35601 HANDLE h;
35602 void *zConverted = winConvertFromUtf8Filename(zFilename);
35603 UNUSED_PARAMETER(pVfs);
35604 if( zConverted==0 ){
35605 return 0;
35606 }
35607 if( osIsNT() ){
@@ -60283,10 +60411,13 @@
60411 alloc.pParse = pParse;
60412 alloc.pIdx = pIdx;
60413 alloc.ppRec = ppRec;
60414 alloc.iVal = iVal;
60415
60416 /* Skip over any TK_COLLATE nodes */
60417 pExpr = sqlite3ExprSkipCollate(pExpr);
60418
60419 if( !pExpr ){
60420 pVal = valueNew(pParse->db, &alloc);
60421 if( pVal ){
60422 sqlite3VdbeMemSetNull((Mem*)pVal);
60423 *pbOk = 1;
@@ -80950,11 +81081,11 @@
81081 ** SQLITE_ENABLE_STAT3 defined. The functionality of sqlite_stat3
81082 ** is a superset of sqlite_stat2. The sqlite_stat4 is an enhanced
81083 ** version of sqlite_stat3 and is only available when compiled with
81084 ** SQLITE_ENABLE_STAT4 and in SQLite versions 3.8.0 and later. It is
81085 ** not possible to enable both STAT3 and STAT4 at the same time. If they
81086 ** are both enabled, then STAT4 takes precedence.
81087 **
81088 ** For most applications, sqlite_stat1 provides all the statisics required
81089 ** for the query planner to make good choices.
81090 **
81091 ** Format of sqlite_stat1:
@@ -81261,11 +81392,11 @@
81392 u8 *pSpace; /* Allocated space not yet assigned */
81393 int i; /* Used to iterate through p->aSample[] */
81394
81395 p->iGet = -1;
81396 p->mxSample = mxSample;
81397 p->nPSample = (tRowcnt)(sqlite3_value_int64(argv[1])/(mxSample/3+1) + 1);
81398 p->current.anLt = &p->current.anEq[nColUp];
81399 sqlite3_randomness(sizeof(p->iPrn), &p->iPrn);
81400
81401 /* Set up the Stat4Accum.a[] and aBest[] arrays */
81402 p->a = (struct Stat4Sample*)&p->current.anLt[nColUp];
@@ -81298,29 +81429,68 @@
81429 0, /* xFinalize */
81430 "stat_init", /* zName */
81431 0, /* pHash */
81432 0 /* pDestructor */
81433 };
81434
81435 #ifdef SQLITE_ENABLE_STAT4
81436 /*
81437 ** pNew and pOld are both candidate non-periodic samples selected for
81438 ** the same column (pNew->iCol==pOld->iCol). Ignoring this column and
81439 ** considering only any trailing columns and the sample hash value, this
81440 ** function returns true if sample pNew is to be preferred over pOld.
81441 ** In other words, if we assume that the cardinalities of the selected
81442 ** column for pNew and pOld are equal, is pNew to be preferred over pOld.
81443 **
81444 ** This function assumes that for each argument sample, the contents of
81445 ** the anEq[] array from pSample->anEq[pSample->iCol+1] onwards are valid.
81446 */
81447 static int sampleIsBetterPost(
81448 Stat4Accum *pAccum,
81449 Stat4Sample *pNew,
81450 Stat4Sample *pOld
81451 ){
81452 int nCol = pAccum->nCol;
81453 int i;
81454 assert( pNew->iCol==pOld->iCol );
81455 for(i=pNew->iCol+1; i<nCol; i++){
81456 if( pNew->anEq[i]>pOld->anEq[i] ) return 1;
81457 if( pNew->anEq[i]<pOld->anEq[i] ) return 0;
81458 }
81459 if( pNew->iHash>pOld->iHash ) return 1;
81460 return 0;
81461 }
81462 #endif
81463
81464 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
81465 /*
81466 ** Return true if pNew is to be preferred over pOld.
81467 **
81468 ** This function assumes that for each argument sample, the contents of
81469 ** the anEq[] array from pSample->anEq[pSample->iCol] onwards are valid.
81470 */
81471 static int sampleIsBetter(
81472 Stat4Accum *pAccum,
81473 Stat4Sample *pNew,
81474 Stat4Sample *pOld
81475 ){
81476 tRowcnt nEqNew = pNew->anEq[pNew->iCol];
81477 tRowcnt nEqOld = pOld->anEq[pOld->iCol];
81478
81479 assert( pOld->isPSample==0 && pNew->isPSample==0 );
81480 assert( IsStat4 || (pNew->iCol==0 && pOld->iCol==0) );
81481
81482 if( (nEqNew>nEqOld) ) return 1;
81483 #ifdef SQLITE_ENABLE_STAT4
81484 if( nEqNew==nEqOld ){
81485 if( pNew->iCol<pOld->iCol ) return 1;
81486 return (pNew->iCol==pOld->iCol && sampleIsBetterPost(pAccum, pNew, pOld));
81487 }
81488 return 0;
81489 #else
81490 return (nEqNew==nEqOld && pNew->iHash>pOld->iHash);
81491 #endif
81492 }
81493
81494 /*
81495 ** Copy the contents of object (*pFrom) into (*pTo).
81496 */
@@ -81339,15 +81509,14 @@
81509 ** remove the least desirable sample from p->a[] to make room.
81510 */
81511 static void sampleInsert(Stat4Accum *p, Stat4Sample *pNew, int nEqZero){
81512 Stat4Sample *pSample;
81513 int i;
 
 
81514
81515 assert( IsStat4 || nEqZero==0 );
81516
81517 #ifdef SQLITE_ENABLE_STAT4
81518 if( pNew->isPSample==0 ){
81519 Stat4Sample *pUpgrade = 0;
81520 assert( pNew->anEq[pNew->iCol]>0 );
81521
81522 /* This sample is being added because the prefix that ends in column
@@ -81357,12 +81526,13 @@
81526 ** existing sample that shares this prefix. */
81527 for(i=p->nSample-1; i>=0; i--){
81528 Stat4Sample *pOld = &p->a[i];
81529 if( pOld->anEq[pNew->iCol]==0 ){
81530 if( pOld->isPSample ) return;
81531 assert( pOld->iCol>pNew->iCol );
81532 assert( sampleIsBetter(p, pNew, pOld) );
81533 if( pUpgrade==0 || sampleIsBetter(p, pOld, pUpgrade) ){
81534 pUpgrade = pOld;
81535 }
81536 }
81537 }
81538 if( pUpgrade ){
@@ -81369,10 +81539,11 @@
81539 pUpgrade->iCol = pNew->iCol;
81540 pUpgrade->anEq[pUpgrade->iCol] = pNew->anEq[pUpgrade->iCol];
81541 goto find_new_min;
81542 }
81543 }
81544 #endif
81545
81546 /* If necessary, remove sample iMin to make room for the new sample. */
81547 if( p->nSample>=p->mxSample ){
81548 Stat4Sample *pMin = &p->a[p->iMin];
81549 tRowcnt *anEq = pMin->anEq;
@@ -81384,40 +81555,34 @@
81555 pSample->anDLt = anDLt;
81556 pSample->anLt = anLt;
81557 p->nSample = p->mxSample-1;
81558 }
81559
81560 /* The "rows less-than" for the rowid column must be greater than that
81561 ** for the last sample in the p->a[] array. Otherwise, the samples would
81562 ** be out of order. */
81563 #ifdef SQLITE_ENABLE_STAT4
81564 assert( p->nSample==0
81565 || pNew->anLt[p->nCol-1] > p->a[p->nSample-1].anLt[p->nCol-1] );
81566 #endif
81567
81568 /* Insert the new sample */
81569 pSample = &p->a[p->nSample];
 
 
 
 
 
 
 
 
 
 
 
81570 sampleCopy(p, pSample, pNew);
81571 p->nSample++;
81572
81573 /* Zero the first nEqZero entries in the anEq[] array. */
81574 memset(pSample->anEq, 0, sizeof(tRowcnt)*nEqZero);
81575
81576 #ifdef SQLITE_ENABLE_STAT4
81577 find_new_min:
81578 #endif
81579 if( p->nSample>=p->mxSample ){
81580 int iMin = -1;
81581 for(i=0; i<p->mxSample; i++){
81582 if( p->a[i].isPSample ) continue;
81583 if( iMin<0 || sampleIsBetter(p, &p->a[iMin], &p->a[i]) ){
81584 iMin = i;
81585 }
81586 }
81587 assert( iMin>=0 );
81588 p->iMin = iMin;
@@ -81437,13 +81602,12 @@
81602
81603 /* Check if any samples from the aBest[] array should be pushed
81604 ** into IndexSample.a[] at this point. */
81605 for(i=(p->nCol-2); i>=iChng; i--){
81606 Stat4Sample *pBest = &p->aBest[i];
81607 pBest->anEq[i] = p->current.anEq[i];
81608 if( p->nSample<p->mxSample || sampleIsBetter(p, pBest, &p->a[p->iMin]) ){
 
81609 sampleInsert(p, pBest, i);
81610 }
81611 }
81612
81613 /* Update the anEq[] fields of any samples already collected. */
@@ -81466,11 +81630,13 @@
81630 sampleInsert(p, &p->current, 0);
81631 p->current.isPSample = 0;
81632 }else
81633
81634 /* Or if it is a non-periodic sample. Add it in this case too. */
81635 if( p->nSample<p->mxSample
81636 || sampleIsBetter(p, &p->current, &p->a[p->iMin])
81637 ){
81638 sampleInsert(p, &p->current, 0);
81639 }
81640 }
81641 #endif
81642 }
@@ -81500,12 +81666,11 @@
81666
81667 assert( p->nCol>1 ); /* Includes rowid field */
81668 assert( iChng<p->nCol );
81669
81670 if( p->nRow==0 ){
81671 /* This is the first call to this function. Do initialization. */
 
81672 for(i=0; i<p->nCol; i++) p->current.anEq[i] = 1;
81673 }else{
81674 /* Second and subsequent calls get processed here */
81675 samplePushPrevious(p, iChng);
81676
@@ -81541,11 +81706,11 @@
81706 }
81707
81708 /* Update the aBest[] array. */
81709 for(i=0; i<(p->nCol-1); i++){
81710 p->current.iCol = i;
81711 if( i>=iChng || sampleIsBetterPost(p, &p->current, &p->aBest[i]) ){
81712 sampleCopy(p, &p->aBest[i], &p->current);
81713 }
81714 }
81715 }
81716 #endif
@@ -82249,11 +82414,11 @@
82414 IndexSample *pFinal = &aSample[pIdx->nSample-1];
82415 int iCol;
82416 for(iCol=0; iCol<pIdx->nColumn; iCol++){
82417 int i; /* Used to iterate through samples */
82418 tRowcnt sumEq = 0; /* Sum of the nEq values */
82419 tRowcnt nSum = 0; /* Number of terms contributing to sumEq */
82420 tRowcnt avgEq = 0;
82421 tRowcnt nDLt = pFinal->anDLt[iCol];
82422
82423 /* Set nSum to the number of distinct (iCol+1) field prefixes that
82424 ** occur in the stat4 table for this index before pFinal. Set
@@ -105797,13 +105962,13 @@
105962 /*
105963 ** Each instance of this object holds a sequence of WhereLoop objects
105964 ** that implement some or all of a query plan.
105965 **
105966 ** Think of each WhereLoop object as a node in a graph with arcs
105967 ** showing dependencies and costs for travelling between nodes. (That is
105968 ** not a completely accurate description because WhereLoop costs are a
105969 ** vector, not a scalar, and because dependencies are many-to-one, not
105970 ** one-to-one as are graph nodes. But it is a useful visualization aid.)
105971 ** Then a WherePath object is a path through the graph that visits some
105972 ** or all of the WhereLoop objects once.
105973 **
105974 ** The "solver" works by creating the N best WherePath objects of length
@@ -108033,16 +108198,19 @@
108198 UnpackedRecord *pRec, /* Vector of values to consider */
108199 int roundUp, /* Round up if true. Round down if false */
108200 tRowcnt *aStat /* OUT: stats written here */
108201 ){
108202 IndexSample *aSample = pIdx->aSample;
108203 int iCol; /* Index of required stats in anEq[] etc. */
108204 int iMin = 0; /* Smallest sample not yet tested */
108205 int i = pIdx->nSample; /* Smallest sample larger than or equal to pRec */
108206 int iTest; /* Next sample to test */
108207 int res; /* Result of comparison operation */
108208
108209 assert( pRec!=0 || pParse->db->mallocFailed );
108210 if( pRec==0 ) return;
108211 iCol = pRec->nField - 1;
108212 assert( pIdx->nSample>0 );
108213 assert( pRec->nField>0 && iCol<pIdx->nSampleCol );
108214 do{
108215 iTest = (iMin+i)/2;
108216 res = sqlite3VdbeRecordCompare(aSample[iTest].n, aSample[iTest].p, pRec);
@@ -108165,11 +108333,11 @@
108333 && p->nSample
108334 && OptimizationEnabled(pParse->db, SQLITE_Stat3)
108335 ){
108336 UnpackedRecord *pRec = pBuilder->pRec;
108337 tRowcnt a[2];
108338 u8 aff;
108339
108340 /* Variable iLower will be set to the estimate of the number of rows in
108341 ** the index that are less than the lower bound of the range query. The
108342 ** lower bound being the concatenation of $P and $L, where $P is the
108343 ** key-prefix formed by the nEq values matched against the nEq left-most
@@ -108187,10 +108355,15 @@
108355 ** of iUpper are requested of whereKeyStats() and the smaller used.
108356 */
108357 tRowcnt iLower;
108358 tRowcnt iUpper;
108359
108360 if( nEq==p->nColumn ){
108361 aff = SQLITE_AFF_INTEGER;
108362 }else{
108363 aff = p->pTable->aCol[p->aiColumn[nEq]].affinity;
108364 }
108365 /* Determine iLower and iUpper using ($P) only. */
108366 if( nEq==0 ){
108367 iLower = 0;
108368 iUpper = p->aiRowEst[0];
108369 }else{
@@ -109781,19 +109954,21 @@
109954 assert( p->rSetup>=pTemplate->rSetup );
109955
109956 if( (p->prereq & pTemplate->prereq)==p->prereq
109957 && p->rSetup<=pTemplate->rSetup
109958 && p->rRun<=pTemplate->rRun
109959 && p->nOut<=pTemplate->nOut
109960 ){
109961 /* This branch taken when p is equal or better than pTemplate in
109962 ** all of (1) dependencies (2) setup-cost, (3) run-cost, and
109963 ** (4) number of output rows. */
109964 assert( p->rSetup==pTemplate->rSetup );
109965 if( p->prereq==pTemplate->prereq
109966 && p->nLTerm<pTemplate->nLTerm
109967 && (p->wsFlags & WHERE_INDEXED)!=0
109968 && (pTemplate->wsFlags & WHERE_INDEXED)!=0
109969 && p->u.btree.pIndex==pTemplate->u.btree.pIndex
 
109970 ){
109971 /* Overwrite an existing WhereLoop with an similar one that uses
109972 ** more terms of the index */
109973 pNext = p->pNextLoop;
109974 break;
@@ -109803,15 +109978,17 @@
109978 goto whereLoopInsert_noop;
109979 }
109980 }
109981 if( (p->prereq & pTemplate->prereq)==pTemplate->prereq
109982 && p->rRun>=pTemplate->rRun
109983 && p->nOut>=pTemplate->nOut
109984 && ALWAYS(p->rSetup>=pTemplate->rSetup) /* See SETUP-INVARIANT above */
109985 ){
109986 /* Overwrite an existing WhereLoop with a better one: one that is
109987 ** better at one of (1) dependencies, (2) setup-cost, (3) run-cost
109988 ** or (4) number of output rows, and is no worse in any of those
109989 ** categories. */
109990 pNext = p->pNextLoop;
109991 break;
109992 }
109993 }
109994
@@ -111512,11 +111689,11 @@
111689 if( pWInfo->nLevel>=2
111690 && pResultSet!=0
111691 && OptimizationEnabled(db, SQLITE_OmitNoopJoin)
111692 ){
111693 Bitmask tabUsed = exprListTableUsage(pMaskSet, pResultSet);
111694 if( sWLB.pOrderBy ) tabUsed |= exprListTableUsage(pMaskSet, sWLB.pOrderBy);
111695 while( pWInfo->nLevel>=2 ){
111696 WhereTerm *pTerm, *pEnd;
111697 pLoop = pWInfo->a[pWInfo->nLevel-1].pWLoop;
111698 if( (pWInfo->pTabList->a[pLoop->iTab].jointype & JT_LEFT)==0 ) break;
111699 if( (wctrlFlags & WHERE_WANT_DISTINCT)==0
@@ -117544,18 +117721,20 @@
117721 case SQLITE_IOERR_SHMMAP: zName = "SQLITE_IOERR_SHMMAP"; break;
117722 case SQLITE_IOERR_SEEK: zName = "SQLITE_IOERR_SEEK"; break;
117723 case SQLITE_IOERR_DELETE_NOENT: zName = "SQLITE_IOERR_DELETE_NOENT";break;
117724 case SQLITE_IOERR_MMAP: zName = "SQLITE_IOERR_MMAP"; break;
117725 case SQLITE_IOERR_GETTEMPPATH: zName = "SQLITE_IOERR_GETTEMPPATH"; break;
117726 case SQLITE_IOERR_CONVPATH: zName = "SQLITE_IOERR_CONVPATH"; break;
117727 case SQLITE_CORRUPT: zName = "SQLITE_CORRUPT"; break;
117728 case SQLITE_CORRUPT_VTAB: zName = "SQLITE_CORRUPT_VTAB"; break;
117729 case SQLITE_NOTFOUND: zName = "SQLITE_NOTFOUND"; break;
117730 case SQLITE_FULL: zName = "SQLITE_FULL"; break;
117731 case SQLITE_CANTOPEN: zName = "SQLITE_CANTOPEN"; break;
117732 case SQLITE_CANTOPEN_NOTEMPDIR: zName = "SQLITE_CANTOPEN_NOTEMPDIR";break;
117733 case SQLITE_CANTOPEN_ISDIR: zName = "SQLITE_CANTOPEN_ISDIR"; break;
117734 case SQLITE_CANTOPEN_FULLPATH: zName = "SQLITE_CANTOPEN_FULLPATH"; break;
117735 case SQLITE_CANTOPEN_CONVPATH: zName = "SQLITE_CANTOPEN_CONVPATH"; break;
117736 case SQLITE_PROTOCOL: zName = "SQLITE_PROTOCOL"; break;
117737 case SQLITE_EMPTY: zName = "SQLITE_EMPTY"; break;
117738 case SQLITE_SCHEMA: zName = "SQLITE_SCHEMA"; break;
117739 case SQLITE_TOOBIG: zName = "SQLITE_TOOBIG"; break;
117740 case SQLITE_CONSTRAINT: zName = "SQLITE_CONSTRAINT"; break;
117741
+3 -1
--- 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-08-30 06:20:23 d9c018f8155ab48df8e0e02519bba50588fe49fc"
112
+#define SQLITE_SOURCE_ID "2013-09-04 04:04:08 8df95bb0b3f72222cf262174247a467c234f9939"
113113
114114
/*
115115
** CAPI3REF: Run-Time Library Version Numbers
116116
** KEYWORDS: sqlite3_version, sqlite3_sourceid
117117
**
@@ -477,16 +477,18 @@
477477
#define SQLITE_IOERR_SHMMAP (SQLITE_IOERR | (21<<8))
478478
#define SQLITE_IOERR_SEEK (SQLITE_IOERR | (22<<8))
479479
#define SQLITE_IOERR_DELETE_NOENT (SQLITE_IOERR | (23<<8))
480480
#define SQLITE_IOERR_MMAP (SQLITE_IOERR | (24<<8))
481481
#define SQLITE_IOERR_GETTEMPPATH (SQLITE_IOERR | (25<<8))
482
+#define SQLITE_IOERR_CONVPATH (SQLITE_IOERR | (26<<8))
482483
#define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8))
483484
#define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8))
484485
#define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8))
485486
#define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8))
486487
#define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8))
487488
#define SQLITE_CANTOPEN_FULLPATH (SQLITE_CANTOPEN | (3<<8))
489
+#define SQLITE_CANTOPEN_CONVPATH (SQLITE_CANTOPEN | (4<<8))
488490
#define SQLITE_CORRUPT_VTAB (SQLITE_CORRUPT | (1<<8))
489491
#define SQLITE_READONLY_RECOVERY (SQLITE_READONLY | (1<<8))
490492
#define SQLITE_READONLY_CANTLOCK (SQLITE_READONLY | (2<<8))
491493
#define SQLITE_READONLY_ROLLBACK (SQLITE_READONLY | (3<<8))
492494
#define SQLITE_ABORT_ROLLBACK (SQLITE_ABORT | (2<<8))
493495
--- 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-08-30 06:20:23 d9c018f8155ab48df8e0e02519bba50588fe49fc"
113
114 /*
115 ** CAPI3REF: Run-Time Library Version Numbers
116 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
117 **
@@ -477,16 +477,18 @@
477 #define SQLITE_IOERR_SHMMAP (SQLITE_IOERR | (21<<8))
478 #define SQLITE_IOERR_SEEK (SQLITE_IOERR | (22<<8))
479 #define SQLITE_IOERR_DELETE_NOENT (SQLITE_IOERR | (23<<8))
480 #define SQLITE_IOERR_MMAP (SQLITE_IOERR | (24<<8))
481 #define SQLITE_IOERR_GETTEMPPATH (SQLITE_IOERR | (25<<8))
 
482 #define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8))
483 #define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8))
484 #define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8))
485 #define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8))
486 #define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8))
487 #define SQLITE_CANTOPEN_FULLPATH (SQLITE_CANTOPEN | (3<<8))
 
488 #define SQLITE_CORRUPT_VTAB (SQLITE_CORRUPT | (1<<8))
489 #define SQLITE_READONLY_RECOVERY (SQLITE_READONLY | (1<<8))
490 #define SQLITE_READONLY_CANTLOCK (SQLITE_READONLY | (2<<8))
491 #define SQLITE_READONLY_ROLLBACK (SQLITE_READONLY | (3<<8))
492 #define SQLITE_ABORT_ROLLBACK (SQLITE_ABORT | (2<<8))
493
--- 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-09-04 04:04:08 8df95bb0b3f72222cf262174247a467c234f9939"
113
114 /*
115 ** CAPI3REF: Run-Time Library Version Numbers
116 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
117 **
@@ -477,16 +477,18 @@
477 #define SQLITE_IOERR_SHMMAP (SQLITE_IOERR | (21<<8))
478 #define SQLITE_IOERR_SEEK (SQLITE_IOERR | (22<<8))
479 #define SQLITE_IOERR_DELETE_NOENT (SQLITE_IOERR | (23<<8))
480 #define SQLITE_IOERR_MMAP (SQLITE_IOERR | (24<<8))
481 #define SQLITE_IOERR_GETTEMPPATH (SQLITE_IOERR | (25<<8))
482 #define SQLITE_IOERR_CONVPATH (SQLITE_IOERR | (26<<8))
483 #define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8))
484 #define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8))
485 #define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8))
486 #define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8))
487 #define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8))
488 #define SQLITE_CANTOPEN_FULLPATH (SQLITE_CANTOPEN | (3<<8))
489 #define SQLITE_CANTOPEN_CONVPATH (SQLITE_CANTOPEN | (4<<8))
490 #define SQLITE_CORRUPT_VTAB (SQLITE_CORRUPT | (1<<8))
491 #define SQLITE_READONLY_RECOVERY (SQLITE_READONLY | (1<<8))
492 #define SQLITE_READONLY_CANTLOCK (SQLITE_READONLY | (2<<8))
493 #define SQLITE_READONLY_ROLLBACK (SQLITE_READONLY | (3<<8))
494 #define SQLITE_ABORT_ROLLBACK (SQLITE_ABORT | (2<<8))
495
+2 -1
--- src/stash.c
+++ src/stash.c
@@ -158,11 +158,11 @@
158158
zComment = find_option("comment", "m", 1);
159159
verify_all_options();
160160
if( zComment==0 ){
161161
Blob prompt; /* Prompt for stash comment */
162162
Blob comment; /* User comment reply */
163
-#ifdef _WIN32
163
+#if defined(_WIN32) || defined(__CYGWIN__)
164164
int bomSize;
165165
const unsigned char *bom = get_utf8_bom(&bomSize);
166166
blob_init(&prompt, (const char *) bom, bomSize);
167167
#else
168168
blob_zero(&prompt);
@@ -639,10 +639,11 @@
639639
}
640640
if( find_option("internal","i",0)==0 ){
641641
zDiffCmd = diff_command_external(0);
642642
}
643643
diffFlags = diff_options();
644
+ if( find_option("verbose","v",0)!=0 ) diffFlags |= DIFF_VERBOSE;
644645
if( g.argc>4 ) usage(mprintf("%s STASHID", zCmd));
645646
if( zDiffCmd ){
646647
zBinGlob = diff_get_binary_glob();
647648
fIncludeBinary = diff_include_binary_files();
648649
}
649650
--- src/stash.c
+++ src/stash.c
@@ -158,11 +158,11 @@
158 zComment = find_option("comment", "m", 1);
159 verify_all_options();
160 if( zComment==0 ){
161 Blob prompt; /* Prompt for stash comment */
162 Blob comment; /* User comment reply */
163 #ifdef _WIN32
164 int bomSize;
165 const unsigned char *bom = get_utf8_bom(&bomSize);
166 blob_init(&prompt, (const char *) bom, bomSize);
167 #else
168 blob_zero(&prompt);
@@ -639,10 +639,11 @@
639 }
640 if( find_option("internal","i",0)==0 ){
641 zDiffCmd = diff_command_external(0);
642 }
643 diffFlags = diff_options();
 
644 if( g.argc>4 ) usage(mprintf("%s STASHID", zCmd));
645 if( zDiffCmd ){
646 zBinGlob = diff_get_binary_glob();
647 fIncludeBinary = diff_include_binary_files();
648 }
649
--- src/stash.c
+++ src/stash.c
@@ -158,11 +158,11 @@
158 zComment = find_option("comment", "m", 1);
159 verify_all_options();
160 if( zComment==0 ){
161 Blob prompt; /* Prompt for stash comment */
162 Blob comment; /* User comment reply */
163 #if defined(_WIN32) || defined(__CYGWIN__)
164 int bomSize;
165 const unsigned char *bom = get_utf8_bom(&bomSize);
166 blob_init(&prompt, (const char *) bom, bomSize);
167 #else
168 blob_zero(&prompt);
@@ -639,10 +639,11 @@
639 }
640 if( find_option("internal","i",0)==0 ){
641 zDiffCmd = diff_command_external(0);
642 }
643 diffFlags = diff_options();
644 if( find_option("verbose","v",0)!=0 ) diffFlags |= DIFF_VERBOSE;
645 if( g.argc>4 ) usage(mprintf("%s STASHID", zCmd));
646 if( zDiffCmd ){
647 zBinGlob = diff_get_binary_glob();
648 fIncludeBinary = diff_include_binary_files();
649 }
650
--- src/style.c
+++ src/style.c
@@ -263,10 +263,11 @@
263263
Th_Store("title", zTitle);
264264
Th_Store("baseurl", g.zBaseURL);
265265
Th_Store("home", g.zTop);
266266
Th_Store("index_page", db_get("index-page","/home"));
267267
Th_Store("current_page", local_zCurrentPage ? local_zCurrentPage : g.zPath);
268
+ Th_Store("csrf_token", g.zCsrfToken);
268269
Th_Store("release_version", RELEASE_VERSION);
269270
Th_Store("manifest_version", MANIFEST_VERSION);
270271
Th_Store("manifest_date", MANIFEST_DATE);
271272
Th_Store("compiler_name", COMPILER_NAME);
272273
if( g.zLogin ){
273274
--- src/style.c
+++ src/style.c
@@ -263,10 +263,11 @@
263 Th_Store("title", zTitle);
264 Th_Store("baseurl", g.zBaseURL);
265 Th_Store("home", g.zTop);
266 Th_Store("index_page", db_get("index-page","/home"));
267 Th_Store("current_page", local_zCurrentPage ? local_zCurrentPage : g.zPath);
 
268 Th_Store("release_version", RELEASE_VERSION);
269 Th_Store("manifest_version", MANIFEST_VERSION);
270 Th_Store("manifest_date", MANIFEST_DATE);
271 Th_Store("compiler_name", COMPILER_NAME);
272 if( g.zLogin ){
273
--- src/style.c
+++ src/style.c
@@ -263,10 +263,11 @@
263 Th_Store("title", zTitle);
264 Th_Store("baseurl", g.zBaseURL);
265 Th_Store("home", g.zTop);
266 Th_Store("index_page", db_get("index-page","/home"));
267 Th_Store("current_page", local_zCurrentPage ? local_zCurrentPage : g.zPath);
268 Th_Store("csrf_token", g.zCsrfToken);
269 Th_Store("release_version", RELEASE_VERSION);
270 Th_Store("manifest_version", MANIFEST_VERSION);
271 Th_Store("manifest_date", MANIFEST_DATE);
272 Th_Store("compiler_name", COMPILER_NAME);
273 if( g.zLogin ){
274
+5 -3
--- src/vfile.c
+++ src/vfile.c
@@ -82,12 +82,14 @@
8282
return;
8383
}
8484
8585
db_begin_transaction();
8686
p = manifest_get(vid, CFTYPE_MANIFEST);
87
- if( p==0 ) return;
88
- db_multi_exec("DELETE FROM vfile WHERE vid=%d", vid);
87
+ if( p==0 ) {
88
+ db_end_transaction(1);
89
+ return;
90
+ }
8991
db_prepare(&ins,
9092
"INSERT INTO vfile(vid,isexe,islink,rid,mrid,pathname) "
9193
" VALUES(:vid,:isexe,:islink,:id,:id,:name)");
9294
db_prepare(&ridq, "SELECT rid,size FROM blob WHERE uuid=:uuid");
9395
db_bind_int(&ins, ":vid", vid);
@@ -95,11 +97,11 @@
9597
while( (pFile = manifest_file_next(p,0))!=0 ){
9698
if( pFile->zUuid==0 || uuid_is_shunned(pFile->zUuid) ) continue;
9799
db_bind_text(&ridq, ":uuid", pFile->zUuid);
98100
if( db_step(&ridq)==SQLITE_ROW ){
99101
rid = db_column_int(&ridq, 0);
100
- size = db_column_int(&ridq, 0);
102
+ size = db_column_int(&ridq, 1);
101103
}else{
102104
rid = 0;
103105
size = 0;
104106
}
105107
db_reset(&ridq);
106108
--- src/vfile.c
+++ src/vfile.c
@@ -82,12 +82,14 @@
82 return;
83 }
84
85 db_begin_transaction();
86 p = manifest_get(vid, CFTYPE_MANIFEST);
87 if( p==0 ) return;
88 db_multi_exec("DELETE FROM vfile WHERE vid=%d", vid);
 
 
89 db_prepare(&ins,
90 "INSERT INTO vfile(vid,isexe,islink,rid,mrid,pathname) "
91 " VALUES(:vid,:isexe,:islink,:id,:id,:name)");
92 db_prepare(&ridq, "SELECT rid,size FROM blob WHERE uuid=:uuid");
93 db_bind_int(&ins, ":vid", vid);
@@ -95,11 +97,11 @@
95 while( (pFile = manifest_file_next(p,0))!=0 ){
96 if( pFile->zUuid==0 || uuid_is_shunned(pFile->zUuid) ) continue;
97 db_bind_text(&ridq, ":uuid", pFile->zUuid);
98 if( db_step(&ridq)==SQLITE_ROW ){
99 rid = db_column_int(&ridq, 0);
100 size = db_column_int(&ridq, 0);
101 }else{
102 rid = 0;
103 size = 0;
104 }
105 db_reset(&ridq);
106
--- src/vfile.c
+++ src/vfile.c
@@ -82,12 +82,14 @@
82 return;
83 }
84
85 db_begin_transaction();
86 p = manifest_get(vid, CFTYPE_MANIFEST);
87 if( p==0 ) {
88 db_end_transaction(1);
89 return;
90 }
91 db_prepare(&ins,
92 "INSERT INTO vfile(vid,isexe,islink,rid,mrid,pathname) "
93 " VALUES(:vid,:isexe,:islink,:id,:id,:name)");
94 db_prepare(&ridq, "SELECT rid,size FROM blob WHERE uuid=:uuid");
95 db_bind_int(&ins, ":vid", vid);
@@ -95,11 +97,11 @@
97 while( (pFile = manifest_file_next(p,0))!=0 ){
98 if( pFile->zUuid==0 || uuid_is_shunned(pFile->zUuid) ) continue;
99 db_bind_text(&ridq, ":uuid", pFile->zUuid);
100 if( db_step(&ridq)==SQLITE_ROW ){
101 rid = db_column_int(&ridq, 0);
102 size = db_column_int(&ridq, 1);
103 }else{
104 rid = 0;
105 size = 0;
106 }
107 db_reset(&ridq);
108
+20 -9
--- src/xfer.c
+++ src/xfer.c
@@ -1320,10 +1320,17 @@
13201320
#define SYNC_CLONE 0x0004
13211321
#define SYNC_PRIVATE 0x0008
13221322
#define SYNC_VERBOSE 0x0010
13231323
#define SYNC_RESYNC 0x0020
13241324
#endif
1325
+
1326
+/*
1327
+** Floating-point absolute value
1328
+*/
1329
+static double fossil_fabs(double x){
1330
+ return x>0.0 ? x : -x;
1331
+}
13251332
13261333
/*
13271334
** Sync to the host identified in g.urlName and g.urlPath. This
13281335
** routine is called by the client.
13291336
**
@@ -1358,10 +1365,11 @@
13581365
int nErr = 0; /* Number of errors */
13591366
int nRoundtrip= 0; /* Number of HTTP requests */
13601367
int nArtifactSent = 0; /* Total artifacts sent */
13611368
int nArtifactRcvd = 0; /* Total artifacts received */
13621369
const char *zOpType = 0;/* Push, Pull, Sync, Clone */
1370
+ double rSkew = 0.0; /* Maximum time skew */
13631371
13641372
if( db_get_boolean("dont-push", 0) ) syncFlags &= ~SYNC_PUSH;
13651373
if( (syncFlags & (SYNC_PUSH|SYNC_PULL|SYNC_CLONE))==0
13661374
&& configRcvMask==0 && configSendMask==0 ) return 0;
13671375
@@ -1558,19 +1566,12 @@
15581566
double rDiff;
15591567
sqlite3_snprintf(sizeof(zTime), zTime, "%.19s", &zLine[12]);
15601568
rDiff = db_double(9e99, "SELECT julianday('%q') - %.17g",
15611569
zTime, rArrivalTime);
15621570
if( rDiff>9e98 || rDiff<-9e98 ) rDiff = 0.0;
1563
- if( (rDiff*24.0*3600.0) > 10.0 ){
1564
- fossil_warning("*** time skew *** server is fast by %s",
1565
- db_timespan_name(rDiff));
1566
- g.clockSkewSeen = 1;
1567
- }else if( rDiff*24.0*3600.0 < -(blob_size(&recv)/5000.0 + 20.0) ){
1568
- fossil_warning("*** time skew *** server is slow by %s",
1569
- db_timespan_name(-rDiff));
1570
- g.clockSkewSeen = 1;
1571
- }
1571
+ if( rDiff*24.0*3600.0 >= -(blob_size(&recv)/5000.0 + 20) ) rDiff = 0.0;
1572
+ if( fossil_fabs(rDiff)>fossil_fabs(rSkew) ) rSkew = rDiff;
15721573
}
15731574
nCardRcvd++;
15741575
continue;
15751576
}
15761577
xfer.nToken = blob_tokenize(&xfer.line, xfer.aToken, count(xfer.aToken));
@@ -1863,10 +1864,20 @@
18631864
** information which is only sent on the second round.
18641865
*/
18651866
if( cloneSeqno<=0 && nCycle>1 ) go = 0;
18661867
};
18671868
transport_stats(&nSent, &nRcvd, 1);
1869
+ if( (rSkew*24.0*3600.0) > 10.0 ){
1870
+ fossil_warning("*** time skew *** server is fast by %s",
1871
+ db_timespan_name(rSkew));
1872
+ g.clockSkewSeen = 1;
1873
+ }else if( rSkew*24.0*3600.0 < -10.0 ){
1874
+ fossil_warning("*** time skew *** server is slow by %s",
1875
+ db_timespan_name(-rSkew));
1876
+ g.clockSkewSeen = 1;
1877
+ }
1878
+
18681879
fossil_force_newline();
18691880
fossil_print(
18701881
"%s finished with %lld bytes sent, %lld bytes received\n",
18711882
zOpType, nSent, nRcvd);
18721883
transport_close();
18731884
--- src/xfer.c
+++ src/xfer.c
@@ -1320,10 +1320,17 @@
1320 #define SYNC_CLONE 0x0004
1321 #define SYNC_PRIVATE 0x0008
1322 #define SYNC_VERBOSE 0x0010
1323 #define SYNC_RESYNC 0x0020
1324 #endif
 
 
 
 
 
 
 
1325
1326 /*
1327 ** Sync to the host identified in g.urlName and g.urlPath. This
1328 ** routine is called by the client.
1329 **
@@ -1358,10 +1365,11 @@
1358 int nErr = 0; /* Number of errors */
1359 int nRoundtrip= 0; /* Number of HTTP requests */
1360 int nArtifactSent = 0; /* Total artifacts sent */
1361 int nArtifactRcvd = 0; /* Total artifacts received */
1362 const char *zOpType = 0;/* Push, Pull, Sync, Clone */
 
1363
1364 if( db_get_boolean("dont-push", 0) ) syncFlags &= ~SYNC_PUSH;
1365 if( (syncFlags & (SYNC_PUSH|SYNC_PULL|SYNC_CLONE))==0
1366 && configRcvMask==0 && configSendMask==0 ) return 0;
1367
@@ -1558,19 +1566,12 @@
1558 double rDiff;
1559 sqlite3_snprintf(sizeof(zTime), zTime, "%.19s", &zLine[12]);
1560 rDiff = db_double(9e99, "SELECT julianday('%q') - %.17g",
1561 zTime, rArrivalTime);
1562 if( rDiff>9e98 || rDiff<-9e98 ) rDiff = 0.0;
1563 if( (rDiff*24.0*3600.0) > 10.0 ){
1564 fossil_warning("*** time skew *** server is fast by %s",
1565 db_timespan_name(rDiff));
1566 g.clockSkewSeen = 1;
1567 }else if( rDiff*24.0*3600.0 < -(blob_size(&recv)/5000.0 + 20.0) ){
1568 fossil_warning("*** time skew *** server is slow by %s",
1569 db_timespan_name(-rDiff));
1570 g.clockSkewSeen = 1;
1571 }
1572 }
1573 nCardRcvd++;
1574 continue;
1575 }
1576 xfer.nToken = blob_tokenize(&xfer.line, xfer.aToken, count(xfer.aToken));
@@ -1863,10 +1864,20 @@
1863 ** information which is only sent on the second round.
1864 */
1865 if( cloneSeqno<=0 && nCycle>1 ) go = 0;
1866 };
1867 transport_stats(&nSent, &nRcvd, 1);
 
 
 
 
 
 
 
 
 
 
1868 fossil_force_newline();
1869 fossil_print(
1870 "%s finished with %lld bytes sent, %lld bytes received\n",
1871 zOpType, nSent, nRcvd);
1872 transport_close();
1873
--- src/xfer.c
+++ src/xfer.c
@@ -1320,10 +1320,17 @@
1320 #define SYNC_CLONE 0x0004
1321 #define SYNC_PRIVATE 0x0008
1322 #define SYNC_VERBOSE 0x0010
1323 #define SYNC_RESYNC 0x0020
1324 #endif
1325
1326 /*
1327 ** Floating-point absolute value
1328 */
1329 static double fossil_fabs(double x){
1330 return x>0.0 ? x : -x;
1331 }
1332
1333 /*
1334 ** Sync to the host identified in g.urlName and g.urlPath. This
1335 ** routine is called by the client.
1336 **
@@ -1358,10 +1365,11 @@
1365 int nErr = 0; /* Number of errors */
1366 int nRoundtrip= 0; /* Number of HTTP requests */
1367 int nArtifactSent = 0; /* Total artifacts sent */
1368 int nArtifactRcvd = 0; /* Total artifacts received */
1369 const char *zOpType = 0;/* Push, Pull, Sync, Clone */
1370 double rSkew = 0.0; /* Maximum time skew */
1371
1372 if( db_get_boolean("dont-push", 0) ) syncFlags &= ~SYNC_PUSH;
1373 if( (syncFlags & (SYNC_PUSH|SYNC_PULL|SYNC_CLONE))==0
1374 && configRcvMask==0 && configSendMask==0 ) return 0;
1375
@@ -1558,19 +1566,12 @@
1566 double rDiff;
1567 sqlite3_snprintf(sizeof(zTime), zTime, "%.19s", &zLine[12]);
1568 rDiff = db_double(9e99, "SELECT julianday('%q') - %.17g",
1569 zTime, rArrivalTime);
1570 if( rDiff>9e98 || rDiff<-9e98 ) rDiff = 0.0;
1571 if( rDiff*24.0*3600.0 >= -(blob_size(&recv)/5000.0 + 20) ) rDiff = 0.0;
1572 if( fossil_fabs(rDiff)>fossil_fabs(rSkew) ) rSkew = rDiff;
 
 
 
 
 
 
 
1573 }
1574 nCardRcvd++;
1575 continue;
1576 }
1577 xfer.nToken = blob_tokenize(&xfer.line, xfer.aToken, count(xfer.aToken));
@@ -1863,10 +1864,20 @@
1864 ** information which is only sent on the second round.
1865 */
1866 if( cloneSeqno<=0 && nCycle>1 ) go = 0;
1867 };
1868 transport_stats(&nSent, &nRcvd, 1);
1869 if( (rSkew*24.0*3600.0) > 10.0 ){
1870 fossil_warning("*** time skew *** server is fast by %s",
1871 db_timespan_name(rSkew));
1872 g.clockSkewSeen = 1;
1873 }else if( rSkew*24.0*3600.0 < -10.0 ){
1874 fossil_warning("*** time skew *** server is slow by %s",
1875 db_timespan_name(-rSkew));
1876 g.clockSkewSeen = 1;
1877 }
1878
1879 fossil_force_newline();
1880 fossil_print(
1881 "%s finished with %lld bytes sent, %lld bytes received\n",
1882 zOpType, nSent, nRcvd);
1883 transport_close();
1884
+20 -9
--- src/xfer.c
+++ src/xfer.c
@@ -1320,10 +1320,17 @@
13201320
#define SYNC_CLONE 0x0004
13211321
#define SYNC_PRIVATE 0x0008
13221322
#define SYNC_VERBOSE 0x0010
13231323
#define SYNC_RESYNC 0x0020
13241324
#endif
1325
+
1326
+/*
1327
+** Floating-point absolute value
1328
+*/
1329
+static double fossil_fabs(double x){
1330
+ return x>0.0 ? x : -x;
1331
+}
13251332
13261333
/*
13271334
** Sync to the host identified in g.urlName and g.urlPath. This
13281335
** routine is called by the client.
13291336
**
@@ -1358,10 +1365,11 @@
13581365
int nErr = 0; /* Number of errors */
13591366
int nRoundtrip= 0; /* Number of HTTP requests */
13601367
int nArtifactSent = 0; /* Total artifacts sent */
13611368
int nArtifactRcvd = 0; /* Total artifacts received */
13621369
const char *zOpType = 0;/* Push, Pull, Sync, Clone */
1370
+ double rSkew = 0.0; /* Maximum time skew */
13631371
13641372
if( db_get_boolean("dont-push", 0) ) syncFlags &= ~SYNC_PUSH;
13651373
if( (syncFlags & (SYNC_PUSH|SYNC_PULL|SYNC_CLONE))==0
13661374
&& configRcvMask==0 && configSendMask==0 ) return 0;
13671375
@@ -1558,19 +1566,12 @@
15581566
double rDiff;
15591567
sqlite3_snprintf(sizeof(zTime), zTime, "%.19s", &zLine[12]);
15601568
rDiff = db_double(9e99, "SELECT julianday('%q') - %.17g",
15611569
zTime, rArrivalTime);
15621570
if( rDiff>9e98 || rDiff<-9e98 ) rDiff = 0.0;
1563
- if( (rDiff*24.0*3600.0) > 10.0 ){
1564
- fossil_warning("*** time skew *** server is fast by %s",
1565
- db_timespan_name(rDiff));
1566
- g.clockSkewSeen = 1;
1567
- }else if( rDiff*24.0*3600.0 < -(blob_size(&recv)/5000.0 + 20.0) ){
1568
- fossil_warning("*** time skew *** server is slow by %s",
1569
- db_timespan_name(-rDiff));
1570
- g.clockSkewSeen = 1;
1571
- }
1571
+ if( rDiff*24.0*3600.0 >= -(blob_size(&recv)/5000.0 + 20) ) rDiff = 0.0;
1572
+ if( fossil_fabs(rDiff)>fossil_fabs(rSkew) ) rSkew = rDiff;
15721573
}
15731574
nCardRcvd++;
15741575
continue;
15751576
}
15761577
xfer.nToken = blob_tokenize(&xfer.line, xfer.aToken, count(xfer.aToken));
@@ -1863,10 +1864,20 @@
18631864
** information which is only sent on the second round.
18641865
*/
18651866
if( cloneSeqno<=0 && nCycle>1 ) go = 0;
18661867
};
18671868
transport_stats(&nSent, &nRcvd, 1);
1869
+ if( (rSkew*24.0*3600.0) > 10.0 ){
1870
+ fossil_warning("*** time skew *** server is fast by %s",
1871
+ db_timespan_name(rSkew));
1872
+ g.clockSkewSeen = 1;
1873
+ }else if( rSkew*24.0*3600.0 < -10.0 ){
1874
+ fossil_warning("*** time skew *** server is slow by %s",
1875
+ db_timespan_name(-rSkew));
1876
+ g.clockSkewSeen = 1;
1877
+ }
1878
+
18681879
fossil_force_newline();
18691880
fossil_print(
18701881
"%s finished with %lld bytes sent, %lld bytes received\n",
18711882
zOpType, nSent, nRcvd);
18721883
transport_close();
18731884
--- src/xfer.c
+++ src/xfer.c
@@ -1320,10 +1320,17 @@
1320 #define SYNC_CLONE 0x0004
1321 #define SYNC_PRIVATE 0x0008
1322 #define SYNC_VERBOSE 0x0010
1323 #define SYNC_RESYNC 0x0020
1324 #endif
 
 
 
 
 
 
 
1325
1326 /*
1327 ** Sync to the host identified in g.urlName and g.urlPath. This
1328 ** routine is called by the client.
1329 **
@@ -1358,10 +1365,11 @@
1358 int nErr = 0; /* Number of errors */
1359 int nRoundtrip= 0; /* Number of HTTP requests */
1360 int nArtifactSent = 0; /* Total artifacts sent */
1361 int nArtifactRcvd = 0; /* Total artifacts received */
1362 const char *zOpType = 0;/* Push, Pull, Sync, Clone */
 
1363
1364 if( db_get_boolean("dont-push", 0) ) syncFlags &= ~SYNC_PUSH;
1365 if( (syncFlags & (SYNC_PUSH|SYNC_PULL|SYNC_CLONE))==0
1366 && configRcvMask==0 && configSendMask==0 ) return 0;
1367
@@ -1558,19 +1566,12 @@
1558 double rDiff;
1559 sqlite3_snprintf(sizeof(zTime), zTime, "%.19s", &zLine[12]);
1560 rDiff = db_double(9e99, "SELECT julianday('%q') - %.17g",
1561 zTime, rArrivalTime);
1562 if( rDiff>9e98 || rDiff<-9e98 ) rDiff = 0.0;
1563 if( (rDiff*24.0*3600.0) > 10.0 ){
1564 fossil_warning("*** time skew *** server is fast by %s",
1565 db_timespan_name(rDiff));
1566 g.clockSkewSeen = 1;
1567 }else if( rDiff*24.0*3600.0 < -(blob_size(&recv)/5000.0 + 20.0) ){
1568 fossil_warning("*** time skew *** server is slow by %s",
1569 db_timespan_name(-rDiff));
1570 g.clockSkewSeen = 1;
1571 }
1572 }
1573 nCardRcvd++;
1574 continue;
1575 }
1576 xfer.nToken = blob_tokenize(&xfer.line, xfer.aToken, count(xfer.aToken));
@@ -1863,10 +1864,20 @@
1863 ** information which is only sent on the second round.
1864 */
1865 if( cloneSeqno<=0 && nCycle>1 ) go = 0;
1866 };
1867 transport_stats(&nSent, &nRcvd, 1);
 
 
 
 
 
 
 
 
 
 
1868 fossil_force_newline();
1869 fossil_print(
1870 "%s finished with %lld bytes sent, %lld bytes received\n",
1871 zOpType, nSent, nRcvd);
1872 transport_close();
1873
--- src/xfer.c
+++ src/xfer.c
@@ -1320,10 +1320,17 @@
1320 #define SYNC_CLONE 0x0004
1321 #define SYNC_PRIVATE 0x0008
1322 #define SYNC_VERBOSE 0x0010
1323 #define SYNC_RESYNC 0x0020
1324 #endif
1325
1326 /*
1327 ** Floating-point absolute value
1328 */
1329 static double fossil_fabs(double x){
1330 return x>0.0 ? x : -x;
1331 }
1332
1333 /*
1334 ** Sync to the host identified in g.urlName and g.urlPath. This
1335 ** routine is called by the client.
1336 **
@@ -1358,10 +1365,11 @@
1365 int nErr = 0; /* Number of errors */
1366 int nRoundtrip= 0; /* Number of HTTP requests */
1367 int nArtifactSent = 0; /* Total artifacts sent */
1368 int nArtifactRcvd = 0; /* Total artifacts received */
1369 const char *zOpType = 0;/* Push, Pull, Sync, Clone */
1370 double rSkew = 0.0; /* Maximum time skew */
1371
1372 if( db_get_boolean("dont-push", 0) ) syncFlags &= ~SYNC_PUSH;
1373 if( (syncFlags & (SYNC_PUSH|SYNC_PULL|SYNC_CLONE))==0
1374 && configRcvMask==0 && configSendMask==0 ) return 0;
1375
@@ -1558,19 +1566,12 @@
1566 double rDiff;
1567 sqlite3_snprintf(sizeof(zTime), zTime, "%.19s", &zLine[12]);
1568 rDiff = db_double(9e99, "SELECT julianday('%q') - %.17g",
1569 zTime, rArrivalTime);
1570 if( rDiff>9e98 || rDiff<-9e98 ) rDiff = 0.0;
1571 if( rDiff*24.0*3600.0 >= -(blob_size(&recv)/5000.0 + 20) ) rDiff = 0.0;
1572 if( fossil_fabs(rDiff)>fossil_fabs(rSkew) ) rSkew = rDiff;
 
 
 
 
 
 
 
1573 }
1574 nCardRcvd++;
1575 continue;
1576 }
1577 xfer.nToken = blob_tokenize(&xfer.line, xfer.aToken, count(xfer.aToken));
@@ -1863,10 +1864,20 @@
1864 ** information which is only sent on the second round.
1865 */
1866 if( cloneSeqno<=0 && nCycle>1 ) go = 0;
1867 };
1868 transport_stats(&nSent, &nRcvd, 1);
1869 if( (rSkew*24.0*3600.0) > 10.0 ){
1870 fossil_warning("*** time skew *** server is fast by %s",
1871 db_timespan_name(rSkew));
1872 g.clockSkewSeen = 1;
1873 }else if( rSkew*24.0*3600.0 < -10.0 ){
1874 fossil_warning("*** time skew *** server is slow by %s",
1875 db_timespan_name(-rSkew));
1876 g.clockSkewSeen = 1;
1877 }
1878
1879 fossil_force_newline();
1880 fossil_print(
1881 "%s finished with %lld bytes sent, %lld bytes received\n",
1882 zOpType, nSent, nRcvd);
1883 transport_close();
1884
--- test/release-checklist.wiki
+++ test/release-checklist.wiki
@@ -55,11 +55,12 @@
5555
<li> <b>valgrind fossil rebuild</b>
5656
<li> <b>valgrind fossil sync</b>
5757
</ol>
5858
5959
<li><p>
60
-Inspect all code changes since the previous release, paying particular
60
+
61
+Inspect [http://www.fossil-scm.org/index.html/vdiff?from=release&to=trunk&sbs=1|all code changes since the previous release], paying particular
6162
attention to the following details:
6263
<ol type="a">
6364
<li> Can a malicious HTTP request cause a buffer overrun.
6465
<li> Can a malicious HTTP request expose privileged information to
6566
unauthorized users.
6667
--- test/release-checklist.wiki
+++ test/release-checklist.wiki
@@ -55,11 +55,12 @@
55 <li> <b>valgrind fossil rebuild</b>
56 <li> <b>valgrind fossil sync</b>
57 </ol>
58
59 <li><p>
60 Inspect all code changes since the previous release, paying particular
 
61 attention to the following details:
62 <ol type="a">
63 <li> Can a malicious HTTP request cause a buffer overrun.
64 <li> Can a malicious HTTP request expose privileged information to
65 unauthorized users.
66
--- test/release-checklist.wiki
+++ test/release-checklist.wiki
@@ -55,11 +55,12 @@
55 <li> <b>valgrind fossil rebuild</b>
56 <li> <b>valgrind fossil sync</b>
57 </ol>
58
59 <li><p>
60
61 Inspect [http://www.fossil-scm.org/index.html/vdiff?from=release&to=trunk&sbs=1|all code changes since the previous release], paying particular
62 attention to the following details:
63 <ol type="a">
64 <li> Can a malicious HTTP request cause a buffer overrun.
65 <li> Can a malicious HTTP request expose privileged information to
66 unauthorized users.
67
--- www/changes.wiki
+++ www/changes.wiki
@@ -9,10 +9,23 @@
99
automatically closes the merged branch when committing.
1010
* Renamed <tt>/stats_report</tt> page to [/reports]. Graph width is now
1111
relative, not absolute.
1212
* Added <tt>yw=YYYY-WW</tt> (year-week) filter to timeline to limit the results
1313
to a specific year and calendar week number, e.g. [/timeline?yw=2013-01].
14
+ * Fixed an obscure condition under which an assertion failure could overwrite
15
+ part of a repository database file, corrupting it. This problem has only
16
+ been seen once in the wild.
17
+ * Added support for unlimited line lengths in side-by-side diffs.
18
+ * New --close option to [/help?cmd=commit | fossil commit], which
19
+ immediately closes the branch being committed.
20
+ * Added <tt>chart</tt> option to [/help?cmd=bisect | fossil bisect].
21
+ * Improvements to the "human or bot?" determination.
22
+ * Reports errors about missing CGI-standard environment variables for HTTP
23
+ servers which do not support them.
24
+ * Minor improvements to sync support on Windows.
25
+ * Added <tt>--scgi</tt> option to [/help?cmd=server | fossil server].
26
+ * Internal improvements to the sync process.
1427
1528
<h2>Changes For Version 1.26 (2013-06-18)</h2>
1629
* The argument to the --port option for the [/help?cmd=ui | fossil ui] and
1730
[/help?cmd=server | fossil server] commands can take an IP address in addition
1831
to the port number, causing Fossil to bind to just that one IP address.
1932
--- www/changes.wiki
+++ www/changes.wiki
@@ -9,10 +9,23 @@
9 automatically closes the merged branch when committing.
10 * Renamed <tt>/stats_report</tt> page to [/reports]. Graph width is now
11 relative, not absolute.
12 * Added <tt>yw=YYYY-WW</tt> (year-week) filter to timeline to limit the results
13 to a specific year and calendar week number, e.g. [/timeline?yw=2013-01].
 
 
 
 
 
 
 
 
 
 
 
 
 
14
15 <h2>Changes For Version 1.26 (2013-06-18)</h2>
16 * The argument to the --port option for the [/help?cmd=ui | fossil ui] and
17 [/help?cmd=server | fossil server] commands can take an IP address in addition
18 to the port number, causing Fossil to bind to just that one IP address.
19
--- www/changes.wiki
+++ www/changes.wiki
@@ -9,10 +9,23 @@
9 automatically closes the merged branch when committing.
10 * Renamed <tt>/stats_report</tt> page to [/reports]. Graph width is now
11 relative, not absolute.
12 * Added <tt>yw=YYYY-WW</tt> (year-week) filter to timeline to limit the results
13 to a specific year and calendar week number, e.g. [/timeline?yw=2013-01].
14 * Fixed an obscure condition under which an assertion failure could overwrite
15 part of a repository database file, corrupting it. This problem has only
16 been seen once in the wild.
17 * Added support for unlimited line lengths in side-by-side diffs.
18 * New --close option to [/help?cmd=commit | fossil commit], which
19 immediately closes the branch being committed.
20 * Added <tt>chart</tt> option to [/help?cmd=bisect | fossil bisect].
21 * Improvements to the "human or bot?" determination.
22 * Reports errors about missing CGI-standard environment variables for HTTP
23 servers which do not support them.
24 * Minor improvements to sync support on Windows.
25 * Added <tt>--scgi</tt> option to [/help?cmd=server | fossil server].
26 * Internal improvements to the sync process.
27
28 <h2>Changes For Version 1.26 (2013-06-18)</h2>
29 * The argument to the --port option for the [/help?cmd=ui | fossil ui] and
30 [/help?cmd=server | fossil server] commands can take an IP address in addition
31 to the port number, causing Fossil to bind to just that one IP address.
32
--- www/makefile.wiki
+++ www/makefile.wiki
@@ -208,11 +208,11 @@
208208
* -Dlocaltime=fossil_localtime
209209
* -DSQLITE_OMIT_LOAD_EXTENSION=1
210210
* -DSQLITE_ENABLE_LOCKING_STYLE=0
211211
* -DSQLITE_THREADSAFE=0
212212
* -DSQLITE_DEFAULT_FILE_FORMAT=4
213
- * -DSQLITE_ENABLE_STAT2
213
+ * -DSQLITE_ENABLE_STAT3
214214
215215
The first and second symbol definitions above are required; the others
216216
are merely recommended. The "localtime()" library function in SQLite must
217217
be redefined to invoke fossil_localtime() instead. The fossil_localtime()
218218
routine will invoke either gmtime() or localtime() depending on the
219219
--- www/makefile.wiki
+++ www/makefile.wiki
@@ -208,11 +208,11 @@
208 * -Dlocaltime=fossil_localtime
209 * -DSQLITE_OMIT_LOAD_EXTENSION=1
210 * -DSQLITE_ENABLE_LOCKING_STYLE=0
211 * -DSQLITE_THREADSAFE=0
212 * -DSQLITE_DEFAULT_FILE_FORMAT=4
213 * -DSQLITE_ENABLE_STAT2
214
215 The first and second symbol definitions above are required; the others
216 are merely recommended. The "localtime()" library function in SQLite must
217 be redefined to invoke fossil_localtime() instead. The fossil_localtime()
218 routine will invoke either gmtime() or localtime() depending on the
219
--- www/makefile.wiki
+++ www/makefile.wiki
@@ -208,11 +208,11 @@
208 * -Dlocaltime=fossil_localtime
209 * -DSQLITE_OMIT_LOAD_EXTENSION=1
210 * -DSQLITE_ENABLE_LOCKING_STYLE=0
211 * -DSQLITE_THREADSAFE=0
212 * -DSQLITE_DEFAULT_FILE_FORMAT=4
213 * -DSQLITE_ENABLE_STAT3
214
215 The first and second symbol definitions above are required; the others
216 are merely recommended. The "localtime()" library function in SQLite must
217 be redefined to invoke fossil_localtime() instead. The fossil_localtime()
218 routine will invoke either gmtime() or localtime() depending on the
219

Keyboard Shortcuts

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