Fossil SCM

Merged in trunk.

stephan 2020-05-26 07:16 unaddremove-command merge
Commit 58ee06450cc9d7a0368f9add93739cd1668b5611b0724c2965024de60e1be1d2
--- skins/default/header.txt
+++ skins/default/header.txt
@@ -17,17 +17,18 @@
1717
html "<a href='$home$url' class='active $cls'>$name</a>\n"
1818
} else {
1919
html "<a href='$home$url' class='$cls'>$name</a>\n"
2020
}
2121
}
22
-html "<a id='hbbtn' href='$home/sitemap'>&#9776;</a>"
22
+html "<a id='hbbtn' href='$home/sitemap' aria-label='Site Map'>&#9776;</a>"
2323
menulink $index_page Home {}
2424
if {[anycap jor]} {
2525
menulink /timeline Timeline {}
2626
}
2727
if {[hascap oh]} {
28
- menulink /dir?ci=tip Files desktoponly
28
+ if {![info exists current_checkin]} {set current_checkin tip}
29
+ menulink /dir?ci=$current_checkin Files desktoponly
2930
}
3031
if {[hascap o]} {
3132
menulink /brlist Branches desktoponly
3233
menulink /taglist Tags wideonly
3334
}
3435
--- skins/default/header.txt
+++ skins/default/header.txt
@@ -17,17 +17,18 @@
17 html "<a href='$home$url' class='active $cls'>$name</a>\n"
18 } else {
19 html "<a href='$home$url' class='$cls'>$name</a>\n"
20 }
21 }
22 html "<a id='hbbtn' href='$home/sitemap'>&#9776;</a>"
23 menulink $index_page Home {}
24 if {[anycap jor]} {
25 menulink /timeline Timeline {}
26 }
27 if {[hascap oh]} {
28 menulink /dir?ci=tip Files desktoponly
 
29 }
30 if {[hascap o]} {
31 menulink /brlist Branches desktoponly
32 menulink /taglist Tags wideonly
33 }
34
--- skins/default/header.txt
+++ skins/default/header.txt
@@ -17,17 +17,18 @@
17 html "<a href='$home$url' class='active $cls'>$name</a>\n"
18 } else {
19 html "<a href='$home$url' class='$cls'>$name</a>\n"
20 }
21 }
22 html "<a id='hbbtn' href='$home/sitemap' aria-label='Site Map'>&#9776;</a>"
23 menulink $index_page Home {}
24 if {[anycap jor]} {
25 menulink /timeline Timeline {}
26 }
27 if {[hascap oh]} {
28 if {![info exists current_checkin]} {set current_checkin tip}
29 menulink /dir?ci=$current_checkin Files desktoponly
30 }
31 if {[hascap o]} {
32 menulink /brlist Branches desktoponly
33 menulink /taglist Tags wideonly
34 }
35
-1
--- src/add.c
+++ src/add.c
@@ -367,11 +367,10 @@
367367
** -f|--force Add files without prompting
368368
** --ignore <CSG> Ignore unmanaged files matching patterns from
369369
** the comma separated list of glob patterns.
370370
** --clean <CSG> Also ignore files matching patterns from
371371
** the comma separated list of glob patterns.
372
-
373372
** --reset Reset the ADDEd state of a checkout, such
374373
** that all newly-added (but not yet committed)
375374
** files are no longer added. No flags other
376375
** than --verbose and --dry-run may be used
377376
** with --reset.
378377
--- src/add.c
+++ src/add.c
@@ -367,11 +367,10 @@
367 ** -f|--force Add files without prompting
368 ** --ignore <CSG> Ignore unmanaged files matching patterns from
369 ** the comma separated list of glob patterns.
370 ** --clean <CSG> Also ignore files matching patterns from
371 ** the comma separated list of glob patterns.
372
373 ** --reset Reset the ADDEd state of a checkout, such
374 ** that all newly-added (but not yet committed)
375 ** files are no longer added. No flags other
376 ** than --verbose and --dry-run may be used
377 ** with --reset.
378
--- src/add.c
+++ src/add.c
@@ -367,11 +367,10 @@
367 ** -f|--force Add files without prompting
368 ** --ignore <CSG> Ignore unmanaged files matching patterns from
369 ** the comma separated list of glob patterns.
370 ** --clean <CSG> Also ignore files matching patterns from
371 ** the comma separated list of glob patterns.
 
372 ** --reset Reset the ADDEd state of a checkout, such
373 ** that all newly-added (but not yet committed)
374 ** files are no longer added. No flags other
375 ** than --verbose and --dry-run may be used
376 ** with --reset.
377
-1
--- src/add.c
+++ src/add.c
@@ -367,11 +367,10 @@
367367
** -f|--force Add files without prompting
368368
** --ignore <CSG> Ignore unmanaged files matching patterns from
369369
** the comma separated list of glob patterns.
370370
** --clean <CSG> Also ignore files matching patterns from
371371
** the comma separated list of glob patterns.
372
-
373372
** --reset Reset the ADDEd state of a checkout, such
374373
** that all newly-added (but not yet committed)
375374
** files are no longer added. No flags other
376375
** than --verbose and --dry-run may be used
377376
** with --reset.
378377
--- src/add.c
+++ src/add.c
@@ -367,11 +367,10 @@
367 ** -f|--force Add files without prompting
368 ** --ignore <CSG> Ignore unmanaged files matching patterns from
369 ** the comma separated list of glob patterns.
370 ** --clean <CSG> Also ignore files matching patterns from
371 ** the comma separated list of glob patterns.
372
373 ** --reset Reset the ADDEd state of a checkout, such
374 ** that all newly-added (but not yet committed)
375 ** files are no longer added. No flags other
376 ** than --verbose and --dry-run may be used
377 ** with --reset.
378
--- src/add.c
+++ src/add.c
@@ -367,11 +367,10 @@
367 ** -f|--force Add files without prompting
368 ** --ignore <CSG> Ignore unmanaged files matching patterns from
369 ** the comma separated list of glob patterns.
370 ** --clean <CSG> Also ignore files matching patterns from
371 ** the comma separated list of glob patterns.
 
372 ** --reset Reset the ADDEd state of a checkout, such
373 ** that all newly-added (but not yet committed)
374 ** files are no longer added. No flags other
375 ** than --verbose and --dry-run may be used
376 ** with --reset.
377
--- src/allrepo.c
+++ src/allrepo.c
@@ -283,11 +283,13 @@
283283
}else if( strncmp(zCmd, "sync", n)==0 ){
284284
zCmd = "sync -autourl -R";
285285
collect_argument(&extra, "verbose","v");
286286
collect_argument(&extra, "unversioned","u");
287287
}else if( strncmp(zCmd, "test-integrity", n)==0 ){
288
+ collect_argument(&extra, "db-only", "d");
288289
collect_argument(&extra, "parse", 0);
290
+ collect_argument(&extra, "quick", "q");
289291
zCmd = "test-integrity";
290292
}else if( strncmp(zCmd, "test-orphans", n)==0 ){
291293
zCmd = "test-orphans -R";
292294
}else if( strncmp(zCmd, "test-missing", n)==0 ){
293295
zCmd = "test-missing -q -R";
294296
--- src/allrepo.c
+++ src/allrepo.c
@@ -283,11 +283,13 @@
283 }else if( strncmp(zCmd, "sync", n)==0 ){
284 zCmd = "sync -autourl -R";
285 collect_argument(&extra, "verbose","v");
286 collect_argument(&extra, "unversioned","u");
287 }else if( strncmp(zCmd, "test-integrity", n)==0 ){
 
288 collect_argument(&extra, "parse", 0);
 
289 zCmd = "test-integrity";
290 }else if( strncmp(zCmd, "test-orphans", n)==0 ){
291 zCmd = "test-orphans -R";
292 }else if( strncmp(zCmd, "test-missing", n)==0 ){
293 zCmd = "test-missing -q -R";
294
--- src/allrepo.c
+++ src/allrepo.c
@@ -283,11 +283,13 @@
283 }else if( strncmp(zCmd, "sync", n)==0 ){
284 zCmd = "sync -autourl -R";
285 collect_argument(&extra, "verbose","v");
286 collect_argument(&extra, "unversioned","u");
287 }else if( strncmp(zCmd, "test-integrity", n)==0 ){
288 collect_argument(&extra, "db-only", "d");
289 collect_argument(&extra, "parse", 0);
290 collect_argument(&extra, "quick", "q");
291 zCmd = "test-integrity";
292 }else if( strncmp(zCmd, "test-orphans", n)==0 ){
293 zCmd = "test-orphans -R";
294 }else if( strncmp(zCmd, "test-missing", n)==0 ){
295 zCmd = "test-missing -q -R";
296
--- src/browse.c
+++ src/browse.c
@@ -173,10 +173,11 @@
173173
linkTrunk = trunkRid && rid != trunkRid;
174174
linkTip = rid != symbolic_name_to_rid("tip", "ci");
175175
zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
176176
isSymbolicCI = (sqlite3_strnicmp(zUuid, zCI, strlen(zCI))!=0);
177177
isBranchCI = branch_includes_uuid(zCI, zUuid);
178
+ Th_Store("current_checkin", zCI);
178179
}else{
179180
zCI = 0;
180181
}
181182
}
182183
@@ -701,10 +702,11 @@
701702
rNow = db_double(0.0, "SELECT mtime FROM event WHERE objid=%d", rid);
702703
zNow = db_text("", "SELECT datetime(mtime,toLocal())"
703704
" FROM event WHERE objid=%d", rid);
704705
isSymbolicCI = (sqlite3_strnicmp(zUuid, zCI, strlen(zCI)) != 0);
705706
isBranchCI = branch_includes_uuid(zCI, zUuid);
707
+ Th_Store("current_checkin", zCI);
706708
}else{
707709
zCI = 0;
708710
}
709711
}
710712
if( zCI==0 ){
711713
--- src/browse.c
+++ src/browse.c
@@ -173,10 +173,11 @@
173 linkTrunk = trunkRid && rid != trunkRid;
174 linkTip = rid != symbolic_name_to_rid("tip", "ci");
175 zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
176 isSymbolicCI = (sqlite3_strnicmp(zUuid, zCI, strlen(zCI))!=0);
177 isBranchCI = branch_includes_uuid(zCI, zUuid);
 
178 }else{
179 zCI = 0;
180 }
181 }
182
@@ -701,10 +702,11 @@
701 rNow = db_double(0.0, "SELECT mtime FROM event WHERE objid=%d", rid);
702 zNow = db_text("", "SELECT datetime(mtime,toLocal())"
703 " FROM event WHERE objid=%d", rid);
704 isSymbolicCI = (sqlite3_strnicmp(zUuid, zCI, strlen(zCI)) != 0);
705 isBranchCI = branch_includes_uuid(zCI, zUuid);
 
706 }else{
707 zCI = 0;
708 }
709 }
710 if( zCI==0 ){
711
--- src/browse.c
+++ src/browse.c
@@ -173,10 +173,11 @@
173 linkTrunk = trunkRid && rid != trunkRid;
174 linkTip = rid != symbolic_name_to_rid("tip", "ci");
175 zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
176 isSymbolicCI = (sqlite3_strnicmp(zUuid, zCI, strlen(zCI))!=0);
177 isBranchCI = branch_includes_uuid(zCI, zUuid);
178 Th_Store("current_checkin", zCI);
179 }else{
180 zCI = 0;
181 }
182 }
183
@@ -701,10 +702,11 @@
702 rNow = db_double(0.0, "SELECT mtime FROM event WHERE objid=%d", rid);
703 zNow = db_text("", "SELECT datetime(mtime,toLocal())"
704 " FROM event WHERE objid=%d", rid);
705 isSymbolicCI = (sqlite3_strnicmp(zUuid, zCI, strlen(zCI)) != 0);
706 isBranchCI = branch_includes_uuid(zCI, zUuid);
707 Th_Store("current_checkin", zCI);
708 }else{
709 zCI = 0;
710 }
711 }
712 if( zCI==0 ){
713
--- src/capabilities.c
+++ src/capabilities.c
@@ -239,11 +239,11 @@
239239
char *zOneLiner; /* One-line summary */
240240
} aCap[] = {
241241
{ 'a', CAPCLASS_SUPER, 0,
242242
"Admin", "Create and delete users" },
243243
{ 'b', CAPCLASS_WIKI|CAPCLASS_TKT, 0,
244
- "Attach", "Add attchments to wiki or tickets" },
244
+ "Attach", "Add attachments to wiki or tickets" },
245245
{ 'c', CAPCLASS_TKT, 0,
246246
"Append-Tkt", "Append to existing tickets" },
247247
/*
248248
** d unused since fork from CVSTrac;
249249
** see https://fossil-scm.org/forum/forumpost/43c78f4bef
250250
--- src/capabilities.c
+++ src/capabilities.c
@@ -239,11 +239,11 @@
239 char *zOneLiner; /* One-line summary */
240 } aCap[] = {
241 { 'a', CAPCLASS_SUPER, 0,
242 "Admin", "Create and delete users" },
243 { 'b', CAPCLASS_WIKI|CAPCLASS_TKT, 0,
244 "Attach", "Add attchments to wiki or tickets" },
245 { 'c', CAPCLASS_TKT, 0,
246 "Append-Tkt", "Append to existing tickets" },
247 /*
248 ** d unused since fork from CVSTrac;
249 ** see https://fossil-scm.org/forum/forumpost/43c78f4bef
250
--- src/capabilities.c
+++ src/capabilities.c
@@ -239,11 +239,11 @@
239 char *zOneLiner; /* One-line summary */
240 } aCap[] = {
241 { 'a', CAPCLASS_SUPER, 0,
242 "Admin", "Create and delete users" },
243 { 'b', CAPCLASS_WIKI|CAPCLASS_TKT, 0,
244 "Attach", "Add attachments to wiki or tickets" },
245 { 'c', CAPCLASS_TKT, 0,
246 "Append-Tkt", "Append to existing tickets" },
247 /*
248 ** d unused since fork from CVSTrac;
249 ** see https://fossil-scm.org/forum/forumpost/43c78f4bef
250
+2 -1
--- src/captcha.c
+++ src/captcha.c
@@ -558,11 +558,12 @@
558558
/*
559559
** Add a "Speak the captcha" button.
560560
*/
561561
void captcha_speakit_button(unsigned int uSeed, const char *zMsg){
562562
if( zMsg==0 ) zMsg = "Speak the text";
563
- @ <input type="button" value="%h(zMsg)" id="speakthetext">
563
+ @ <input aria-label="%h(zMsg)" type="button" value="%h(zMsg)" \
564
+ @ id="speakthetext">
564565
@ <script nonce="%h(style_nonce())">
565566
@ document.getElementById("speakthetext").onclick = function(){
566567
@ var audio = window.fossilAudioCaptcha \
567568
@ || new Audio("%R/captcha-audio/%u(uSeed)");
568569
@ window.fossilAudioCaptcha = audio;
569570
--- src/captcha.c
+++ src/captcha.c
@@ -558,11 +558,12 @@
558 /*
559 ** Add a "Speak the captcha" button.
560 */
561 void captcha_speakit_button(unsigned int uSeed, const char *zMsg){
562 if( zMsg==0 ) zMsg = "Speak the text";
563 @ <input type="button" value="%h(zMsg)" id="speakthetext">
 
564 @ <script nonce="%h(style_nonce())">
565 @ document.getElementById("speakthetext").onclick = function(){
566 @ var audio = window.fossilAudioCaptcha \
567 @ || new Audio("%R/captcha-audio/%u(uSeed)");
568 @ window.fossilAudioCaptcha = audio;
569
--- src/captcha.c
+++ src/captcha.c
@@ -558,11 +558,12 @@
558 /*
559 ** Add a "Speak the captcha" button.
560 */
561 void captcha_speakit_button(unsigned int uSeed, const char *zMsg){
562 if( zMsg==0 ) zMsg = "Speak the text";
563 @ <input aria-label="%h(zMsg)" type="button" value="%h(zMsg)" \
564 @ id="speakthetext">
565 @ <script nonce="%h(style_nonce())">
566 @ document.getElementById("speakthetext").onclick = function(){
567 @ var audio = window.fossilAudioCaptcha \
568 @ || new Audio("%R/captcha-audio/%u(uSeed)");
569 @ window.fossilAudioCaptcha = audio;
570
+21
--- src/cgi.c
+++ src/cgi.c
@@ -433,10 +433,31 @@
433433
va_list ap;
434434
va_start(ap, zFormat);
435435
cgi_redirect(vmprintf(zFormat, ap));
436436
va_end(ap);
437437
}
438
+
439
+/*
440
+** Add a "Content-disposition: attachment; filename=%s" header to the reply.
441
+*/
442
+void cgi_content_disposition_filename(const char *zFilename){
443
+ char *z;
444
+ int i, n;
445
+
446
+ /* 0123456789 123456789 123456789 123456789 123456*/
447
+ z = mprintf("Content-Disposition: attachment; filename=\"%s\";\r\n",
448
+ file_tail(zFilename));
449
+ n = (int)strlen(z);
450
+ for(i=43; i<n-4; i++){
451
+ char c = z[i];
452
+ if( fossil_isalnum(c) ) continue;
453
+ if( c=='.' || c=='-' || c=='/' ) continue;
454
+ z[i] = '_';
455
+ }
456
+ cgi_append_header(z);
457
+ fossil_free(z);
458
+}
438459
439460
/*
440461
** Return the URL for the caller. This is obtained from either the
441462
** referer CGI parameter, if it exists, or the HTTP_REFERER HTTP parameter.
442463
** If neither exist, return zDefault.
443464
--- src/cgi.c
+++ src/cgi.c
@@ -433,10 +433,31 @@
433 va_list ap;
434 va_start(ap, zFormat);
435 cgi_redirect(vmprintf(zFormat, ap));
436 va_end(ap);
437 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
438
439 /*
440 ** Return the URL for the caller. This is obtained from either the
441 ** referer CGI parameter, if it exists, or the HTTP_REFERER HTTP parameter.
442 ** If neither exist, return zDefault.
443
--- src/cgi.c
+++ src/cgi.c
@@ -433,10 +433,31 @@
433 va_list ap;
434 va_start(ap, zFormat);
435 cgi_redirect(vmprintf(zFormat, ap));
436 va_end(ap);
437 }
438
439 /*
440 ** Add a "Content-disposition: attachment; filename=%s" header to the reply.
441 */
442 void cgi_content_disposition_filename(const char *zFilename){
443 char *z;
444 int i, n;
445
446 /* 0123456789 123456789 123456789 123456789 123456*/
447 z = mprintf("Content-Disposition: attachment; filename=\"%s\";\r\n",
448 file_tail(zFilename));
449 n = (int)strlen(z);
450 for(i=43; i<n-4; i++){
451 char c = z[i];
452 if( fossil_isalnum(c) ) continue;
453 if( c=='.' || c=='-' || c=='/' ) continue;
454 z[i] = '_';
455 }
456 cgi_append_header(z);
457 fossil_free(z);
458 }
459
460 /*
461 ** Return the URL for the caller. This is obtained from either the
462 ** referer CGI parameter, if it exists, or the HTTP_REFERER HTTP parameter.
463 ** If neither exist, return zDefault.
464
--- src/content.c
+++ src/content.c
@@ -944,13 +944,19 @@
944944
** Verify that all content can be extracted from the BLOB table correctly.
945945
** If the BLOB table is correct, then the repository can always be
946946
** successfully reconstructed using "fossil rebuild".
947947
**
948948
** Options:
949
+**
950
+** -d|--db-only Run "PRAGMA integrity_check" on the database only.
951
+** No other validation is performed.
949952
**
950953
** --parse Parse all manifests, wikis, tickets, events, and
951954
** so forth, reporting any errors found.
955
+**
956
+** -q|--quick Run "PRAGMA quick_check" on the database only.
957
+** No other validation is performed.
952958
*/
953959
void test_integrity(void){
954960
Stmt q;
955961
Blob content;
956962
int n1 = 0;
@@ -958,11 +964,25 @@
958964
int nErr = 0;
959965
int total;
960966
int nCA = 0;
961967
int anCA[10];
962968
int bParse = find_option("parse",0,0)!=0;
969
+ int bDbOnly = find_option("db-only","d",0)!=0;
970
+ int bQuick = find_option("quick","q",0)!=0;
963971
db_find_and_open_repository(OPEN_ANY_SCHEMA, 2);
972
+ if( bDbOnly || bQuick ){
973
+ const char *zType = bQuick ? "quick" : "integrity";
974
+ char *zRes;
975
+ zRes = db_text(0,"PRAGMA repository.%s_check", zType/*safe-for-%s*/);
976
+ if( fossil_strcmp(zRes,"ok")!=0 ){
977
+ fossil_print("%s_check failed!\n", zType);
978
+ exit(1);
979
+ }else{
980
+ fossil_print("ok\n");
981
+ }
982
+ return;
983
+ }
964984
memset(anCA, 0, sizeof(anCA));
965985
966986
/* Make sure no public artifact is a delta from a private artifact */
967987
db_prepare(&q,
968988
"SELECT "
969989
--- src/content.c
+++ src/content.c
@@ -944,13 +944,19 @@
944 ** Verify that all content can be extracted from the BLOB table correctly.
945 ** If the BLOB table is correct, then the repository can always be
946 ** successfully reconstructed using "fossil rebuild".
947 **
948 ** Options:
 
 
 
949 **
950 ** --parse Parse all manifests, wikis, tickets, events, and
951 ** so forth, reporting any errors found.
 
 
 
952 */
953 void test_integrity(void){
954 Stmt q;
955 Blob content;
956 int n1 = 0;
@@ -958,11 +964,25 @@
958 int nErr = 0;
959 int total;
960 int nCA = 0;
961 int anCA[10];
962 int bParse = find_option("parse",0,0)!=0;
 
 
963 db_find_and_open_repository(OPEN_ANY_SCHEMA, 2);
 
 
 
 
 
 
 
 
 
 
 
 
964 memset(anCA, 0, sizeof(anCA));
965
966 /* Make sure no public artifact is a delta from a private artifact */
967 db_prepare(&q,
968 "SELECT "
969
--- src/content.c
+++ src/content.c
@@ -944,13 +944,19 @@
944 ** Verify that all content can be extracted from the BLOB table correctly.
945 ** If the BLOB table is correct, then the repository can always be
946 ** successfully reconstructed using "fossil rebuild".
947 **
948 ** Options:
949 **
950 ** -d|--db-only Run "PRAGMA integrity_check" on the database only.
951 ** No other validation is performed.
952 **
953 ** --parse Parse all manifests, wikis, tickets, events, and
954 ** so forth, reporting any errors found.
955 **
956 ** -q|--quick Run "PRAGMA quick_check" on the database only.
957 ** No other validation is performed.
958 */
959 void test_integrity(void){
960 Stmt q;
961 Blob content;
962 int n1 = 0;
@@ -958,11 +964,25 @@
964 int nErr = 0;
965 int total;
966 int nCA = 0;
967 int anCA[10];
968 int bParse = find_option("parse",0,0)!=0;
969 int bDbOnly = find_option("db-only","d",0)!=0;
970 int bQuick = find_option("quick","q",0)!=0;
971 db_find_and_open_repository(OPEN_ANY_SCHEMA, 2);
972 if( bDbOnly || bQuick ){
973 const char *zType = bQuick ? "quick" : "integrity";
974 char *zRes;
975 zRes = db_text(0,"PRAGMA repository.%s_check", zType/*safe-for-%s*/);
976 if( fossil_strcmp(zRes,"ok")!=0 ){
977 fossil_print("%s_check failed!\n", zType);
978 exit(1);
979 }else{
980 fossil_print("ok\n");
981 }
982 return;
983 }
984 memset(anCA, 0, sizeof(anCA));
985
986 /* Make sure no public artifact is a delta from a private artifact */
987 db_prepare(&q,
988 "SELECT "
989
+13 -1
--- src/db.c
+++ src/db.c
@@ -2381,16 +2381,28 @@
23812381
char c = i==argc-1 ? '\n' : ' ';
23822382
fossil_print("%s%c", sqlite3_value_text(argv[i]), c);
23832383
}
23842384
}
23852385
}
2386
-LOCAL int db_sql_trace(unsigned m, void *notUsed, void *pP, void *pX){
2386
+
2387
+/*
2388
+** Callback for sqlite3_trace_v2();
2389
+*/
2390
+int db_sql_trace(unsigned m, void *notUsed, void *pP, void *pX){
23872391
sqlite3_stmt *pStmt = (sqlite3_stmt*)pP;
23882392
char *zSql;
23892393
int n;
23902394
const char *zArg = (const char*)pX;
23912395
char zEnd[40];
2396
+ if( m & SQLITE_TRACE_CLOSE ){
2397
+ /* If we are tracking closes, that means we want to clean up static
2398
+ ** prepared statements. */
2399
+ while( db.pAllStmt ){
2400
+ db_finalize(db.pAllStmt);
2401
+ }
2402
+ return 0;
2403
+ }
23922404
if( zArg[0]=='-' ) return 0;
23932405
if( m & SQLITE_TRACE_PROFILE ){
23942406
sqlite3_int64 nNano = *(sqlite3_int64*)pX;
23952407
double rMillisec = 0.000001 * nNano;
23962408
sqlite3_snprintf(sizeof(zEnd),zEnd," /* %.3fms */\n", rMillisec);
23972409
--- src/db.c
+++ src/db.c
@@ -2381,16 +2381,28 @@
2381 char c = i==argc-1 ? '\n' : ' ';
2382 fossil_print("%s%c", sqlite3_value_text(argv[i]), c);
2383 }
2384 }
2385 }
2386 LOCAL int db_sql_trace(unsigned m, void *notUsed, void *pP, void *pX){
 
 
 
 
2387 sqlite3_stmt *pStmt = (sqlite3_stmt*)pP;
2388 char *zSql;
2389 int n;
2390 const char *zArg = (const char*)pX;
2391 char zEnd[40];
 
 
 
 
 
 
 
 
2392 if( zArg[0]=='-' ) return 0;
2393 if( m & SQLITE_TRACE_PROFILE ){
2394 sqlite3_int64 nNano = *(sqlite3_int64*)pX;
2395 double rMillisec = 0.000001 * nNano;
2396 sqlite3_snprintf(sizeof(zEnd),zEnd," /* %.3fms */\n", rMillisec);
2397
--- src/db.c
+++ src/db.c
@@ -2381,16 +2381,28 @@
2381 char c = i==argc-1 ? '\n' : ' ';
2382 fossil_print("%s%c", sqlite3_value_text(argv[i]), c);
2383 }
2384 }
2385 }
2386
2387 /*
2388 ** Callback for sqlite3_trace_v2();
2389 */
2390 int db_sql_trace(unsigned m, void *notUsed, void *pP, void *pX){
2391 sqlite3_stmt *pStmt = (sqlite3_stmt*)pP;
2392 char *zSql;
2393 int n;
2394 const char *zArg = (const char*)pX;
2395 char zEnd[40];
2396 if( m & SQLITE_TRACE_CLOSE ){
2397 /* If we are tracking closes, that means we want to clean up static
2398 ** prepared statements. */
2399 while( db.pAllStmt ){
2400 db_finalize(db.pAllStmt);
2401 }
2402 return 0;
2403 }
2404 if( zArg[0]=='-' ) return 0;
2405 if( m & SQLITE_TRACE_PROFILE ){
2406 sqlite3_int64 nNano = *(sqlite3_int64*)pX;
2407 double rMillisec = 0.000001 * nNano;
2408 sqlite3_snprintf(sizeof(zEnd),zEnd," /* %.3fms */\n", rMillisec);
2409
--- src/default_css.txt
+++ src/default_css.txt
@@ -860,5 +860,11 @@
860860
// }
861861
// #setup_skinedit_css_defaults > tbody > tr > td:nth-of-type(2) > div {
862862
// max-width: 30em;
863863
// overflow: auto;
864864
// }
865
+input {
866
+ max-width: 95%;
867
+}
868
+textarea {
869
+ max-width: 95%;
870
+}
865871
--- src/default_css.txt
+++ src/default_css.txt
@@ -860,5 +860,11 @@
860 // }
861 // #setup_skinedit_css_defaults > tbody > tr > td:nth-of-type(2) > div {
862 // max-width: 30em;
863 // overflow: auto;
864 // }
 
 
 
 
 
 
865
--- src/default_css.txt
+++ src/default_css.txt
@@ -860,5 +860,11 @@
860 // }
861 // #setup_skinedit_css_defaults > tbody > tr > td:nth-of-type(2) > div {
862 // max-width: 30em;
863 // overflow: auto;
864 // }
865 input {
866 max-width: 95%;
867 }
868 textarea {
869 max-width: 95%;
870 }
871
+19 -14
--- src/doc.c
+++ src/doc.c
@@ -810,11 +810,11 @@
810810
** WEBPAGE: doc
811811
** URL: /uv/FILE
812812
** URL: /doc/CHECKIN/FILE
813813
**
814814
** CHECKIN can be either tag or hash prefix or timestamp identifying a
815
-** particular check, or the name of a branch (meaning the most recent
815
+** particular check-in, or the name of a branch (meaning the most recent
816816
** check-in on that branch) or one of various magic words:
817817
**
818818
** "tip" means the most recent check-in
819819
**
820820
** "ckout" means the current check-out, if the server is run from
@@ -824,11 +824,12 @@
824824
** regardless of what branch it occurs on.
825825
**
826826
** FILE is the name of a file to delivered up as a webpage. FILE is relative
827827
** to the root of the source tree of the repository. The FILE must
828828
** be a part of CHECKIN, except when CHECKIN=="ckout" when FILE is read
829
-** directly from disk and need not be a managed file.
829
+** directly from disk and need not be a managed file. For /uv, FILE
830
+** can also be the hash of the unversioned file.
830831
**
831832
** The "ckout" CHECKIN is intended for development - to provide a mechanism
832833
** for looking at what a file will look like using the /doc webpage after
833834
** it gets checked in.
834835
**
@@ -931,22 +932,26 @@
931932
goto doc_not_found;
932933
}
933934
}
934935
if( isUV ){
935936
if( db_table_exists("repository","unversioned") ){
936
- Stmt q;
937
- db_prepare(&q, "SELECT hash, mtime FROM unversioned"
938
- " WHERE name=%Q", zName);
939
- if( db_step(&q)==SQLITE_ROW ){
940
- etag_check(ETAG_HASH, db_column_text(&q,0));
941
- etag_last_modified(db_column_int64(&q,1));
942
- }
943
- db_finalize(&q);
944
- if( unversioned_content(zName, &filebody)==0 ){
945
- rid = 1;
946
- zDfltTitle = zName;
947
- }
937
+ rid = unversioned_content(zName, &filebody);
938
+ if( rid==1 ){
939
+ Stmt q;
940
+ db_prepare(&q, "SELECT hash, mtime FROM unversioned"
941
+ " WHERE name=%Q", zName);
942
+ if( db_step(&q)==SQLITE_ROW ){
943
+ etag_check(ETAG_HASH, db_column_text(&q,0));
944
+ etag_last_modified(db_column_int64(&q,1));
945
+ }
946
+ db_finalize(&q);
947
+ }else if( rid==2 ){
948
+ zName = db_text(zName,
949
+ "SELECT name FROM unversioned WHERE hash=%Q", zName);
950
+ g.isConst = 1;
951
+ }
952
+ zDfltTitle = zName;
948953
}
949954
}else if( fossil_strcmp(zCheckin,"ckout")==0 ){
950955
/* Read from the local checkout */
951956
char *zFullpath;
952957
db_must_be_within_tree();
953958
--- src/doc.c
+++ src/doc.c
@@ -810,11 +810,11 @@
810 ** WEBPAGE: doc
811 ** URL: /uv/FILE
812 ** URL: /doc/CHECKIN/FILE
813 **
814 ** CHECKIN can be either tag or hash prefix or timestamp identifying a
815 ** particular check, or the name of a branch (meaning the most recent
816 ** check-in on that branch) or one of various magic words:
817 **
818 ** "tip" means the most recent check-in
819 **
820 ** "ckout" means the current check-out, if the server is run from
@@ -824,11 +824,12 @@
824 ** regardless of what branch it occurs on.
825 **
826 ** FILE is the name of a file to delivered up as a webpage. FILE is relative
827 ** to the root of the source tree of the repository. The FILE must
828 ** be a part of CHECKIN, except when CHECKIN=="ckout" when FILE is read
829 ** directly from disk and need not be a managed file.
 
830 **
831 ** The "ckout" CHECKIN is intended for development - to provide a mechanism
832 ** for looking at what a file will look like using the /doc webpage after
833 ** it gets checked in.
834 **
@@ -931,22 +932,26 @@
931 goto doc_not_found;
932 }
933 }
934 if( isUV ){
935 if( db_table_exists("repository","unversioned") ){
936 Stmt q;
937 db_prepare(&q, "SELECT hash, mtime FROM unversioned"
938 " WHERE name=%Q", zName);
939 if( db_step(&q)==SQLITE_ROW ){
940 etag_check(ETAG_HASH, db_column_text(&q,0));
941 etag_last_modified(db_column_int64(&q,1));
942 }
943 db_finalize(&q);
944 if( unversioned_content(zName, &filebody)==0 ){
945 rid = 1;
946 zDfltTitle = zName;
947 }
 
 
 
 
948 }
949 }else if( fossil_strcmp(zCheckin,"ckout")==0 ){
950 /* Read from the local checkout */
951 char *zFullpath;
952 db_must_be_within_tree();
953
--- src/doc.c
+++ src/doc.c
@@ -810,11 +810,11 @@
810 ** WEBPAGE: doc
811 ** URL: /uv/FILE
812 ** URL: /doc/CHECKIN/FILE
813 **
814 ** CHECKIN can be either tag or hash prefix or timestamp identifying a
815 ** particular check-in, or the name of a branch (meaning the most recent
816 ** check-in on that branch) or one of various magic words:
817 **
818 ** "tip" means the most recent check-in
819 **
820 ** "ckout" means the current check-out, if the server is run from
@@ -824,11 +824,12 @@
824 ** regardless of what branch it occurs on.
825 **
826 ** FILE is the name of a file to delivered up as a webpage. FILE is relative
827 ** to the root of the source tree of the repository. The FILE must
828 ** be a part of CHECKIN, except when CHECKIN=="ckout" when FILE is read
829 ** directly from disk and need not be a managed file. For /uv, FILE
830 ** can also be the hash of the unversioned file.
831 **
832 ** The "ckout" CHECKIN is intended for development - to provide a mechanism
833 ** for looking at what a file will look like using the /doc webpage after
834 ** it gets checked in.
835 **
@@ -931,22 +932,26 @@
932 goto doc_not_found;
933 }
934 }
935 if( isUV ){
936 if( db_table_exists("repository","unversioned") ){
937 rid = unversioned_content(zName, &filebody);
938 if( rid==1 ){
939 Stmt q;
940 db_prepare(&q, "SELECT hash, mtime FROM unversioned"
941 " WHERE name=%Q", zName);
942 if( db_step(&q)==SQLITE_ROW ){
943 etag_check(ETAG_HASH, db_column_text(&q,0));
944 etag_last_modified(db_column_int64(&q,1));
945 }
946 db_finalize(&q);
947 }else if( rid==2 ){
948 zName = db_text(zName,
949 "SELECT name FROM unversioned WHERE hash=%Q", zName);
950 g.isConst = 1;
951 }
952 zDfltTitle = zName;
953 }
954 }else if( fossil_strcmp(zCheckin,"ckout")==0 ){
955 /* Read from the local checkout */
956 char *zFullpath;
957 db_must_be_within_tree();
958
+5 -4
--- src/forum.c
+++ src/forum.c
@@ -1013,12 +1013,12 @@
10131013
@ Title: <input type="input" name="title" value="%h(zTitle)" size="50"
10141014
@ maxlength="125"><br>
10151015
}
10161016
@ %z(href("%R/markup_help"))Markup style</a>:
10171017
mimetype_option_menu(zMimetype);
1018
- @ <br><textarea name="content" class="wikiedit" cols="80" \
1019
- @ rows="25" wrap="virtual">%h(zContent)</textarea><br>
1018
+ @ <br><textarea aria-label="Content:" name="content" class="wikiedit" \
1019
+ @ cols="80" rows="25" wrap="virtual">%h(zContent)</textarea><br>
10201020
}
10211021
10221022
/*
10231023
** WEBPAGE: forumnew
10241024
** WEBPAGE: forumedit
@@ -1119,11 +1119,12 @@
11191119
@ <input type="submit" name="submit" value="Submit">
11201120
}else{
11211121
@ <input type="submit" name="submit" value="Submit" disabled>
11221122
}
11231123
if( g.perm.Debug ){
1124
- /* For the test-forumnew page add these extra debugging controls */
1124
+ /* Give extra control over the post to users with the special
1125
+ * Debug capability, which includes Admin and Setup users */
11251126
@ <div class="debug">
11261127
@ <label><input type="checkbox" name="dryrun" %s(PCK("dryrun"))> \
11271128
@ Dry run</label>
11281129
@ <br><label><input type="checkbox" name="domod" %s(PCK("domod"))> \
11291130
@ Require moderator approval</label>
@@ -1235,11 +1236,11 @@
12351236
@ <input type="hidden" name="fpid" value="%h(P("fpid"))">
12361237
@ <input type="hidden" name="nullout" value="1">
12371238
@ <input type="hidden" name="mimetype" value="%h(zMimetype)">
12381239
@ <input type="hidden" name="content" value="%h(zContent)">
12391240
if( zTitle ){
1240
- @ <input type="hidden" name="title" value="%h(zTitle)">
1241
+ @ <input aria-label="Title" type="hidden" name="title" value="%h(zTitle)">
12411242
}
12421243
}else if( P("edit") ){
12431244
/* Provide an edit to the fpid post */
12441245
zMimetype = P("mimetype");
12451246
zContent = PT("content");
12461247
--- src/forum.c
+++ src/forum.c
@@ -1013,12 +1013,12 @@
1013 @ Title: <input type="input" name="title" value="%h(zTitle)" size="50"
1014 @ maxlength="125"><br>
1015 }
1016 @ %z(href("%R/markup_help"))Markup style</a>:
1017 mimetype_option_menu(zMimetype);
1018 @ <br><textarea name="content" class="wikiedit" cols="80" \
1019 @ rows="25" wrap="virtual">%h(zContent)</textarea><br>
1020 }
1021
1022 /*
1023 ** WEBPAGE: forumnew
1024 ** WEBPAGE: forumedit
@@ -1119,11 +1119,12 @@
1119 @ <input type="submit" name="submit" value="Submit">
1120 }else{
1121 @ <input type="submit" name="submit" value="Submit" disabled>
1122 }
1123 if( g.perm.Debug ){
1124 /* For the test-forumnew page add these extra debugging controls */
 
1125 @ <div class="debug">
1126 @ <label><input type="checkbox" name="dryrun" %s(PCK("dryrun"))> \
1127 @ Dry run</label>
1128 @ <br><label><input type="checkbox" name="domod" %s(PCK("domod"))> \
1129 @ Require moderator approval</label>
@@ -1235,11 +1236,11 @@
1235 @ <input type="hidden" name="fpid" value="%h(P("fpid"))">
1236 @ <input type="hidden" name="nullout" value="1">
1237 @ <input type="hidden" name="mimetype" value="%h(zMimetype)">
1238 @ <input type="hidden" name="content" value="%h(zContent)">
1239 if( zTitle ){
1240 @ <input type="hidden" name="title" value="%h(zTitle)">
1241 }
1242 }else if( P("edit") ){
1243 /* Provide an edit to the fpid post */
1244 zMimetype = P("mimetype");
1245 zContent = PT("content");
1246
--- src/forum.c
+++ src/forum.c
@@ -1013,12 +1013,12 @@
1013 @ Title: <input type="input" name="title" value="%h(zTitle)" size="50"
1014 @ maxlength="125"><br>
1015 }
1016 @ %z(href("%R/markup_help"))Markup style</a>:
1017 mimetype_option_menu(zMimetype);
1018 @ <br><textarea aria-label="Content:" name="content" class="wikiedit" \
1019 @ cols="80" rows="25" wrap="virtual">%h(zContent)</textarea><br>
1020 }
1021
1022 /*
1023 ** WEBPAGE: forumnew
1024 ** WEBPAGE: forumedit
@@ -1119,11 +1119,12 @@
1119 @ <input type="submit" name="submit" value="Submit">
1120 }else{
1121 @ <input type="submit" name="submit" value="Submit" disabled>
1122 }
1123 if( g.perm.Debug ){
1124 /* Give extra control over the post to users with the special
1125 * Debug capability, which includes Admin and Setup users */
1126 @ <div class="debug">
1127 @ <label><input type="checkbox" name="dryrun" %s(PCK("dryrun"))> \
1128 @ Dry run</label>
1129 @ <br><label><input type="checkbox" name="domod" %s(PCK("domod"))> \
1130 @ Require moderator approval</label>
@@ -1235,11 +1236,11 @@
1236 @ <input type="hidden" name="fpid" value="%h(P("fpid"))">
1237 @ <input type="hidden" name="nullout" value="1">
1238 @ <input type="hidden" name="mimetype" value="%h(zMimetype)">
1239 @ <input type="hidden" name="content" value="%h(zContent)">
1240 if( zTitle ){
1241 @ <input aria-label="Title" type="hidden" name="title" value="%h(zTitle)">
1242 }
1243 }else if( P("edit") ){
1244 /* Provide an edit to the fpid post */
1245 zMimetype = P("mimetype");
1246 zContent = PT("content");
1247
+14 -6
--- src/http_ssl.c
+++ src/http_ssl.c
@@ -24,19 +24,19 @@
2424
** SSL support is abstracted out into this module because Fossil can
2525
** be compiled without SSL support (which requires OpenSSL library)
2626
*/
2727
2828
#include "config.h"
29
+#include "http_ssl.h"
2930
3031
#ifdef FOSSIL_ENABLE_SSL
3132
3233
#include <openssl/bio.h>
3334
#include <openssl/ssl.h>
3435
#include <openssl/err.h>
3536
#include <openssl/x509.h>
3637
37
-#include "http_ssl.h"
3838
#include <assert.h>
3939
#include <sys/types.h>
4040
4141
/*
4242
** There can only be a single OpenSSL IO connection open at a time.
@@ -328,10 +328,11 @@
328328
ssl_close();
329329
return 1;
330330
}
331331
332332
if( !sslNoCertVerify && SSL_get_verify_result(ssl)!=X509_V_OK ){
333
+ int x;
333334
char *desc, *prompt;
334335
Blob ans;
335336
char cReply;
336337
BIO *mem;
337338
unsigned char md[32];
@@ -338,11 +339,17 @@
338339
char zHash[32*2+1];
339340
unsigned int mdLength = (int)sizeof(md);
340341
341342
memset(md, 0, sizeof(md));
342343
zHash[0] = 0;
343
- if( X509_digest(cert, EVP_sha256(), md, &mdLength) ){
344
+ /* MMNNFFPPS */
345
+#if OPENSSL_VERSION_NUMBER >= 0x010000000
346
+ x = X509_digest(cert, EVP_sha256(), md, &mdLength);
347
+#else
348
+ x = X509_digest(cert, EVP_sha1(), md, &mdLength);
349
+#endif
350
+ if( x ){
344351
int j;
345352
for(j=0; j<mdLength && j*2+1<sizeof(zHash); ++j){
346353
zHash[j*2] = "0123456789abcdef"[md[j]>>4];
347354
zHash[j*2+1] = "0123456789abcdef"[md[j]&0xf];
348355
}
@@ -518,25 +525,26 @@
518525
** for the domains listed. Or if
519526
** the --all option is specified,
520527
** remove all TLS cert exceptions.
521528
*/
522529
void test_tlsconfig_info(void){
523
- const char *zCmd;
524
- size_t nCmd;
525
- int nHit = 0;
526530
#if !defined(FOSSIL_ENABLE_SSL)
527531
fossil_print("TLS disabled in this build\n");
528532
#else
533
+ const char *zCmd;
534
+ size_t nCmd;
535
+ int nHit = 0;
529536
db_find_and_open_repository(OPEN_OK_NOT_FOUND|OPEN_SUBSTITUTE,0);
530537
db_open_config(1,0);
531538
zCmd = g.argc>=3 ? g.argv[2] : "show";
532539
nCmd = strlen(zCmd);
533540
if( strncmp("show",zCmd,nCmd)==0 ){
534541
const char *zName, *zValue;
535542
size_t nName;
536543
Stmt q;
537
- fossil_print("OpenSSL-version: %s\n", SSLeay_version(SSLEAY_VERSION));
544
+ fossil_print("OpenSSL-version: %s (0x%09x)\n",
545
+ SSLeay_version(SSLEAY_VERSION), OPENSSL_VERSION_NUMBER);
538546
fossil_print("OpenSSL-cert-file: %s\n", X509_get_default_cert_file());
539547
fossil_print("OpenSSL-cert-dir: %s\n", X509_get_default_cert_dir());
540548
zName = X509_get_default_cert_file_env();
541549
zValue = fossil_getenv(zName);
542550
if( zValue==0 ) zValue = "";
543551
--- src/http_ssl.c
+++ src/http_ssl.c
@@ -24,19 +24,19 @@
24 ** SSL support is abstracted out into this module because Fossil can
25 ** be compiled without SSL support (which requires OpenSSL library)
26 */
27
28 #include "config.h"
 
29
30 #ifdef FOSSIL_ENABLE_SSL
31
32 #include <openssl/bio.h>
33 #include <openssl/ssl.h>
34 #include <openssl/err.h>
35 #include <openssl/x509.h>
36
37 #include "http_ssl.h"
38 #include <assert.h>
39 #include <sys/types.h>
40
41 /*
42 ** There can only be a single OpenSSL IO connection open at a time.
@@ -328,10 +328,11 @@
328 ssl_close();
329 return 1;
330 }
331
332 if( !sslNoCertVerify && SSL_get_verify_result(ssl)!=X509_V_OK ){
 
333 char *desc, *prompt;
334 Blob ans;
335 char cReply;
336 BIO *mem;
337 unsigned char md[32];
@@ -338,11 +339,17 @@
338 char zHash[32*2+1];
339 unsigned int mdLength = (int)sizeof(md);
340
341 memset(md, 0, sizeof(md));
342 zHash[0] = 0;
343 if( X509_digest(cert, EVP_sha256(), md, &mdLength) ){
 
 
 
 
 
 
344 int j;
345 for(j=0; j<mdLength && j*2+1<sizeof(zHash); ++j){
346 zHash[j*2] = "0123456789abcdef"[md[j]>>4];
347 zHash[j*2+1] = "0123456789abcdef"[md[j]&0xf];
348 }
@@ -518,25 +525,26 @@
518 ** for the domains listed. Or if
519 ** the --all option is specified,
520 ** remove all TLS cert exceptions.
521 */
522 void test_tlsconfig_info(void){
523 const char *zCmd;
524 size_t nCmd;
525 int nHit = 0;
526 #if !defined(FOSSIL_ENABLE_SSL)
527 fossil_print("TLS disabled in this build\n");
528 #else
 
 
 
529 db_find_and_open_repository(OPEN_OK_NOT_FOUND|OPEN_SUBSTITUTE,0);
530 db_open_config(1,0);
531 zCmd = g.argc>=3 ? g.argv[2] : "show";
532 nCmd = strlen(zCmd);
533 if( strncmp("show",zCmd,nCmd)==0 ){
534 const char *zName, *zValue;
535 size_t nName;
536 Stmt q;
537 fossil_print("OpenSSL-version: %s\n", SSLeay_version(SSLEAY_VERSION));
 
538 fossil_print("OpenSSL-cert-file: %s\n", X509_get_default_cert_file());
539 fossil_print("OpenSSL-cert-dir: %s\n", X509_get_default_cert_dir());
540 zName = X509_get_default_cert_file_env();
541 zValue = fossil_getenv(zName);
542 if( zValue==0 ) zValue = "";
543
--- src/http_ssl.c
+++ src/http_ssl.c
@@ -24,19 +24,19 @@
24 ** SSL support is abstracted out into this module because Fossil can
25 ** be compiled without SSL support (which requires OpenSSL library)
26 */
27
28 #include "config.h"
29 #include "http_ssl.h"
30
31 #ifdef FOSSIL_ENABLE_SSL
32
33 #include <openssl/bio.h>
34 #include <openssl/ssl.h>
35 #include <openssl/err.h>
36 #include <openssl/x509.h>
37
 
38 #include <assert.h>
39 #include <sys/types.h>
40
41 /*
42 ** There can only be a single OpenSSL IO connection open at a time.
@@ -328,10 +328,11 @@
328 ssl_close();
329 return 1;
330 }
331
332 if( !sslNoCertVerify && SSL_get_verify_result(ssl)!=X509_V_OK ){
333 int x;
334 char *desc, *prompt;
335 Blob ans;
336 char cReply;
337 BIO *mem;
338 unsigned char md[32];
@@ -338,11 +339,17 @@
339 char zHash[32*2+1];
340 unsigned int mdLength = (int)sizeof(md);
341
342 memset(md, 0, sizeof(md));
343 zHash[0] = 0;
344 /* MMNNFFPPS */
345 #if OPENSSL_VERSION_NUMBER >= 0x010000000
346 x = X509_digest(cert, EVP_sha256(), md, &mdLength);
347 #else
348 x = X509_digest(cert, EVP_sha1(), md, &mdLength);
349 #endif
350 if( x ){
351 int j;
352 for(j=0; j<mdLength && j*2+1<sizeof(zHash); ++j){
353 zHash[j*2] = "0123456789abcdef"[md[j]>>4];
354 zHash[j*2+1] = "0123456789abcdef"[md[j]&0xf];
355 }
@@ -518,25 +525,26 @@
525 ** for the domains listed. Or if
526 ** the --all option is specified,
527 ** remove all TLS cert exceptions.
528 */
529 void test_tlsconfig_info(void){
 
 
 
530 #if !defined(FOSSIL_ENABLE_SSL)
531 fossil_print("TLS disabled in this build\n");
532 #else
533 const char *zCmd;
534 size_t nCmd;
535 int nHit = 0;
536 db_find_and_open_repository(OPEN_OK_NOT_FOUND|OPEN_SUBSTITUTE,0);
537 db_open_config(1,0);
538 zCmd = g.argc>=3 ? g.argv[2] : "show";
539 nCmd = strlen(zCmd);
540 if( strncmp("show",zCmd,nCmd)==0 ){
541 const char *zName, *zValue;
542 size_t nName;
543 Stmt q;
544 fossil_print("OpenSSL-version: %s (0x%09x)\n",
545 SSLeay_version(SSLEAY_VERSION), OPENSSL_VERSION_NUMBER);
546 fossil_print("OpenSSL-cert-file: %s\n", X509_get_default_cert_file());
547 fossil_print("OpenSSL-cert-dir: %s\n", X509_get_default_cert_dir());
548 zName = X509_get_default_cert_file_env();
549 zValue = fossil_getenv(zName);
550 if( zValue==0 ) zValue = "";
551
+36 -19
--- src/info.c
+++ src/info.c
@@ -666,10 +666,11 @@
666666
const char *zOrigDate;
667667
int okWiki = 0;
668668
Blob wiki_read_links = BLOB_INITIALIZER;
669669
Blob wiki_add_links = BLOB_INITIALIZER;
670670
671
+ Th_Store("current_checkin", zName);
671672
style_header("Check-in [%S]", zUuid);
672673
login_anonymous_available();
673674
zEUser = db_text(0,
674675
"SELECT value FROM tagxref"
675676
" WHERE tagid=%d AND rid=%d AND tagtype>0",
@@ -1753,13 +1754,18 @@
17531754
style_footer();
17541755
}
17551756
17561757
/*
17571758
** WEBPAGE: raw
1758
-** URL: /raw?name=ARTIFACTID&m=TYPE
1759
+** URL: /raw/ARTIFACTID
17591760
** URL: /raw?ci=BRANCH&filename=NAME
17601761
**
1762
+** Additional query parameters:
1763
+**
1764
+** m=MIMETYPE The mimetype is MIMETYPE
1765
+** at=FILENAME Content-disposition; attachment; filename=FILENAME;
1766
+**
17611767
** Return the uninterpreted content of an artifact. Used primarily
17621768
** to view artifacts that are images.
17631769
*/
17641770
void rawartifact_page(void){
17651771
int rid = 0;
@@ -1815,26 +1821,37 @@
18151821
** NULL, guess at the MIME-type based on the filename
18161822
** associated with the artifact.
18171823
*/
18181824
void deliver_artifact(int rid, const char *zMime){
18191825
Blob content;
1826
+ const char *zAttachName = P("at");
18201827
if( zMime==0 ){
1821
- char *zFName = db_text(0, "SELECT filename.name FROM mlink, filename"
1822
- " WHERE mlink.fid=%d"
1823
- " AND filename.fnid=mlink.fnid", rid);
1824
- if( !zFName ){
1828
+ char *zFN = (char*)zAttachName;
1829
+ if( zFN==0 ){
1830
+ zFN = db_text(0, "SELECT filename.name FROM mlink, filename"
1831
+ " WHERE mlink.fid=%d"
1832
+ " AND filename.fnid=mlink.fnid", rid);
1833
+ }
1834
+ if( zFN==0 ){
18251835
/* Look also at the attachment table */
1826
- zFName = db_text(0, "SELECT attachment.filename FROM attachment, blob"
1827
- " WHERE blob.rid=%d"
1828
- " AND attachment.src=blob.uuid", rid);
1836
+ zFN = db_text(0, "SELECT attachment.filename FROM attachment, blob"
1837
+ " WHERE blob.rid=%d"
1838
+ " AND attachment.src=blob.uuid", rid);
1839
+ }
1840
+ if( zFN ){
1841
+ zMime = mimetype_from_name(zFN);
18291842
}
1830
- if( zFName ) zMime = mimetype_from_name(zFName);
1831
- if( zMime==0 ) zMime = "application/x-fossil-artifact";
1843
+ if( zMime==0 ){
1844
+ zMime = "application/x-fossil-artifact";
1845
+ }
18321846
}
18331847
content_get(rid, &content);
18341848
fossil_free(style_csp(1));
18351849
cgi_set_content_type(zMime);
1850
+ if( zAttachName ){
1851
+ cgi_content_disposition_filename(zAttachName);
1852
+ }
18361853
cgi_set_content(&content);
18371854
}
18381855
18391856
/*
18401857
** Render a hex dump of a file.
@@ -1928,12 +1945,12 @@
19281945
@ :</h2>
19291946
}
19301947
blob_zero(&downloadName);
19311948
if( P("verbose")!=0 ) objdescFlags |= OBJDESC_DETAIL;
19321949
object_description(rid, objdescFlags, 0, &downloadName);
1933
- style_submenu_element("Download", "%s/raw/%T?name=%s",
1934
- g.zTop, blob_str(&downloadName), zUuid);
1950
+ style_submenu_element("Download", "%R/raw/%s?at=%T",
1951
+ zUuid, file_tail(blob_str(&downloadName)));
19351952
@ <hr />
19361953
content_get(rid, &content);
19371954
@ <blockquote><pre>
19381955
hexdump(&content);
19391956
@ </pre></blockquote>
@@ -2258,12 +2275,13 @@
22582275
if( asText ) objdescFlags &= ~OBJDESC_BASE;
22592276
objType = object_description(rid, objdescFlags,
22602277
(isFile?zName:0), &downloadName);
22612278
}
22622279
if( !descOnly && P("download")!=0 ){
2263
- cgi_redirectf("%R/raw/%T?name=%s", blob_str(&downloadName),
2264
- db_text("?", "SELECT uuid FROM blob WHERE rid=%d", rid));
2280
+ cgi_redirectf("%R/raw/%s?at=%T",
2281
+ db_text("x", "SELECT uuid FROM blob WHERE rid=%d", rid),
2282
+ file_tail(blob_str(&downloadName)));
22652283
/*NOTREACHED*/
22662284
}
22672285
if( g.perm.Admin ){
22682286
const char *zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d", rid);
22692287
if( db_exists("SELECT 1 FROM shun WHERE uuid=%Q", zUuid) ){
@@ -2304,12 +2322,11 @@
23042322
const char *zIp = db_column_text(&q,2);
23052323
@ <p>Received on %s(zDate) from %h(zUser) at %h(zIp).</p>
23062324
}
23072325
db_finalize(&q);
23082326
}
2309
- style_submenu_element("Download", "%R/raw/%T?name=%s",
2310
- blob_str(&downloadName), zUuid);
2327
+ style_submenu_element("Download", "%R/raw/%s?at=%T", zUuid, file_tail(zName));
23112328
if( db_exists("SELECT 1 FROM mlink WHERE fid=%d", rid) ){
23122329
style_submenu_element("Check-ins Using", "%R/timeline?n=200&uf=%s", zUuid);
23132330
}
23142331
zMime = mimetype_from_name(blob_str(&downloadName));
23152332
if( zMime ){
@@ -2339,11 +2356,11 @@
23392356
@ <hr />
23402357
content_get(rid, &content);
23412358
if( renderAsWiki ){
23422359
wiki_render_by_mimetype(&content, zMime);
23432360
}else if( renderAsHtml ){
2344
- @ <iframe src="%R/raw/%T(blob_str(&downloadName))?name=%s(zUuid)"
2361
+ @ <iframe src="%R/raw/%s(zUuid)"
23452362
@ width="100%%" frameborder="0" marginwidth="0" marginheight="0"
23462363
@ sandbox="allow-same-origin" id="ifm1">
23472364
@ </iframe>
23482365
@ <script nonce="%h(style_nonce())">
23492366
@ document.getElementById("ifm1").addEventListener("load",
@@ -2768,15 +2785,15 @@
27682785
**
27692786
** Edit a check-in. (Check-ins are immutable and do not really change.
27702787
** This page really creates supplemental tags that affect the display
27712788
** of the check-in.)
27722789
**
2773
-** Query parmeters:
2790
+** Query parameters:
27742791
**
27752792
** rid=INTEGER Record ID of the check-in to edit (REQUIRED)
27762793
**
2777
-** POST parameters after pressing "Perview", "Cancel", or "Apply":
2794
+** POST parameters after pressing "Preview", "Cancel", or "Apply":
27782795
**
27792796
** c=TEXT New check-in comment
27802797
** u=TEXT New user name
27812798
** newclr Apply a background color
27822799
** clr=TEXT New background color (only if newclr)
27832800
--- src/info.c
+++ src/info.c
@@ -666,10 +666,11 @@
666 const char *zOrigDate;
667 int okWiki = 0;
668 Blob wiki_read_links = BLOB_INITIALIZER;
669 Blob wiki_add_links = BLOB_INITIALIZER;
670
 
671 style_header("Check-in [%S]", zUuid);
672 login_anonymous_available();
673 zEUser = db_text(0,
674 "SELECT value FROM tagxref"
675 " WHERE tagid=%d AND rid=%d AND tagtype>0",
@@ -1753,13 +1754,18 @@
1753 style_footer();
1754 }
1755
1756 /*
1757 ** WEBPAGE: raw
1758 ** URL: /raw?name=ARTIFACTID&m=TYPE
1759 ** URL: /raw?ci=BRANCH&filename=NAME
1760 **
 
 
 
 
 
1761 ** Return the uninterpreted content of an artifact. Used primarily
1762 ** to view artifacts that are images.
1763 */
1764 void rawartifact_page(void){
1765 int rid = 0;
@@ -1815,26 +1821,37 @@
1815 ** NULL, guess at the MIME-type based on the filename
1816 ** associated with the artifact.
1817 */
1818 void deliver_artifact(int rid, const char *zMime){
1819 Blob content;
 
1820 if( zMime==0 ){
1821 char *zFName = db_text(0, "SELECT filename.name FROM mlink, filename"
1822 " WHERE mlink.fid=%d"
1823 " AND filename.fnid=mlink.fnid", rid);
1824 if( !zFName ){
 
 
 
1825 /* Look also at the attachment table */
1826 zFName = db_text(0, "SELECT attachment.filename FROM attachment, blob"
1827 " WHERE blob.rid=%d"
1828 " AND attachment.src=blob.uuid", rid);
 
 
 
1829 }
1830 if( zFName ) zMime = mimetype_from_name(zFName);
1831 if( zMime==0 ) zMime = "application/x-fossil-artifact";
 
1832 }
1833 content_get(rid, &content);
1834 fossil_free(style_csp(1));
1835 cgi_set_content_type(zMime);
 
 
 
1836 cgi_set_content(&content);
1837 }
1838
1839 /*
1840 ** Render a hex dump of a file.
@@ -1928,12 +1945,12 @@
1928 @ :</h2>
1929 }
1930 blob_zero(&downloadName);
1931 if( P("verbose")!=0 ) objdescFlags |= OBJDESC_DETAIL;
1932 object_description(rid, objdescFlags, 0, &downloadName);
1933 style_submenu_element("Download", "%s/raw/%T?name=%s",
1934 g.zTop, blob_str(&downloadName), zUuid);
1935 @ <hr />
1936 content_get(rid, &content);
1937 @ <blockquote><pre>
1938 hexdump(&content);
1939 @ </pre></blockquote>
@@ -2258,12 +2275,13 @@
2258 if( asText ) objdescFlags &= ~OBJDESC_BASE;
2259 objType = object_description(rid, objdescFlags,
2260 (isFile?zName:0), &downloadName);
2261 }
2262 if( !descOnly && P("download")!=0 ){
2263 cgi_redirectf("%R/raw/%T?name=%s", blob_str(&downloadName),
2264 db_text("?", "SELECT uuid FROM blob WHERE rid=%d", rid));
 
2265 /*NOTREACHED*/
2266 }
2267 if( g.perm.Admin ){
2268 const char *zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d", rid);
2269 if( db_exists("SELECT 1 FROM shun WHERE uuid=%Q", zUuid) ){
@@ -2304,12 +2322,11 @@
2304 const char *zIp = db_column_text(&q,2);
2305 @ <p>Received on %s(zDate) from %h(zUser) at %h(zIp).</p>
2306 }
2307 db_finalize(&q);
2308 }
2309 style_submenu_element("Download", "%R/raw/%T?name=%s",
2310 blob_str(&downloadName), zUuid);
2311 if( db_exists("SELECT 1 FROM mlink WHERE fid=%d", rid) ){
2312 style_submenu_element("Check-ins Using", "%R/timeline?n=200&uf=%s", zUuid);
2313 }
2314 zMime = mimetype_from_name(blob_str(&downloadName));
2315 if( zMime ){
@@ -2339,11 +2356,11 @@
2339 @ <hr />
2340 content_get(rid, &content);
2341 if( renderAsWiki ){
2342 wiki_render_by_mimetype(&content, zMime);
2343 }else if( renderAsHtml ){
2344 @ <iframe src="%R/raw/%T(blob_str(&downloadName))?name=%s(zUuid)"
2345 @ width="100%%" frameborder="0" marginwidth="0" marginheight="0"
2346 @ sandbox="allow-same-origin" id="ifm1">
2347 @ </iframe>
2348 @ <script nonce="%h(style_nonce())">
2349 @ document.getElementById("ifm1").addEventListener("load",
@@ -2768,15 +2785,15 @@
2768 **
2769 ** Edit a check-in. (Check-ins are immutable and do not really change.
2770 ** This page really creates supplemental tags that affect the display
2771 ** of the check-in.)
2772 **
2773 ** Query parmeters:
2774 **
2775 ** rid=INTEGER Record ID of the check-in to edit (REQUIRED)
2776 **
2777 ** POST parameters after pressing "Perview", "Cancel", or "Apply":
2778 **
2779 ** c=TEXT New check-in comment
2780 ** u=TEXT New user name
2781 ** newclr Apply a background color
2782 ** clr=TEXT New background color (only if newclr)
2783
--- src/info.c
+++ src/info.c
@@ -666,10 +666,11 @@
666 const char *zOrigDate;
667 int okWiki = 0;
668 Blob wiki_read_links = BLOB_INITIALIZER;
669 Blob wiki_add_links = BLOB_INITIALIZER;
670
671 Th_Store("current_checkin", zName);
672 style_header("Check-in [%S]", zUuid);
673 login_anonymous_available();
674 zEUser = db_text(0,
675 "SELECT value FROM tagxref"
676 " WHERE tagid=%d AND rid=%d AND tagtype>0",
@@ -1753,13 +1754,18 @@
1754 style_footer();
1755 }
1756
1757 /*
1758 ** WEBPAGE: raw
1759 ** URL: /raw/ARTIFACTID
1760 ** URL: /raw?ci=BRANCH&filename=NAME
1761 **
1762 ** Additional query parameters:
1763 **
1764 ** m=MIMETYPE The mimetype is MIMETYPE
1765 ** at=FILENAME Content-disposition; attachment; filename=FILENAME;
1766 **
1767 ** Return the uninterpreted content of an artifact. Used primarily
1768 ** to view artifacts that are images.
1769 */
1770 void rawartifact_page(void){
1771 int rid = 0;
@@ -1815,26 +1821,37 @@
1821 ** NULL, guess at the MIME-type based on the filename
1822 ** associated with the artifact.
1823 */
1824 void deliver_artifact(int rid, const char *zMime){
1825 Blob content;
1826 const char *zAttachName = P("at");
1827 if( zMime==0 ){
1828 char *zFN = (char*)zAttachName;
1829 if( zFN==0 ){
1830 zFN = db_text(0, "SELECT filename.name FROM mlink, filename"
1831 " WHERE mlink.fid=%d"
1832 " AND filename.fnid=mlink.fnid", rid);
1833 }
1834 if( zFN==0 ){
1835 /* Look also at the attachment table */
1836 zFN = db_text(0, "SELECT attachment.filename FROM attachment, blob"
1837 " WHERE blob.rid=%d"
1838 " AND attachment.src=blob.uuid", rid);
1839 }
1840 if( zFN ){
1841 zMime = mimetype_from_name(zFN);
1842 }
1843 if( zMime==0 ){
1844 zMime = "application/x-fossil-artifact";
1845 }
1846 }
1847 content_get(rid, &content);
1848 fossil_free(style_csp(1));
1849 cgi_set_content_type(zMime);
1850 if( zAttachName ){
1851 cgi_content_disposition_filename(zAttachName);
1852 }
1853 cgi_set_content(&content);
1854 }
1855
1856 /*
1857 ** Render a hex dump of a file.
@@ -1928,12 +1945,12 @@
1945 @ :</h2>
1946 }
1947 blob_zero(&downloadName);
1948 if( P("verbose")!=0 ) objdescFlags |= OBJDESC_DETAIL;
1949 object_description(rid, objdescFlags, 0, &downloadName);
1950 style_submenu_element("Download", "%R/raw/%s?at=%T",
1951 zUuid, file_tail(blob_str(&downloadName)));
1952 @ <hr />
1953 content_get(rid, &content);
1954 @ <blockquote><pre>
1955 hexdump(&content);
1956 @ </pre></blockquote>
@@ -2258,12 +2275,13 @@
2275 if( asText ) objdescFlags &= ~OBJDESC_BASE;
2276 objType = object_description(rid, objdescFlags,
2277 (isFile?zName:0), &downloadName);
2278 }
2279 if( !descOnly && P("download")!=0 ){
2280 cgi_redirectf("%R/raw/%s?at=%T",
2281 db_text("x", "SELECT uuid FROM blob WHERE rid=%d", rid),
2282 file_tail(blob_str(&downloadName)));
2283 /*NOTREACHED*/
2284 }
2285 if( g.perm.Admin ){
2286 const char *zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d", rid);
2287 if( db_exists("SELECT 1 FROM shun WHERE uuid=%Q", zUuid) ){
@@ -2304,12 +2322,11 @@
2322 const char *zIp = db_column_text(&q,2);
2323 @ <p>Received on %s(zDate) from %h(zUser) at %h(zIp).</p>
2324 }
2325 db_finalize(&q);
2326 }
2327 style_submenu_element("Download", "%R/raw/%s?at=%T", zUuid, file_tail(zName));
 
2328 if( db_exists("SELECT 1 FROM mlink WHERE fid=%d", rid) ){
2329 style_submenu_element("Check-ins Using", "%R/timeline?n=200&uf=%s", zUuid);
2330 }
2331 zMime = mimetype_from_name(blob_str(&downloadName));
2332 if( zMime ){
@@ -2339,11 +2356,11 @@
2356 @ <hr />
2357 content_get(rid, &content);
2358 if( renderAsWiki ){
2359 wiki_render_by_mimetype(&content, zMime);
2360 }else if( renderAsHtml ){
2361 @ <iframe src="%R/raw/%s(zUuid)"
2362 @ width="100%%" frameborder="0" marginwidth="0" marginheight="0"
2363 @ sandbox="allow-same-origin" id="ifm1">
2364 @ </iframe>
2365 @ <script nonce="%h(style_nonce())">
2366 @ document.getElementById("ifm1").addEventListener("load",
@@ -2768,15 +2785,15 @@
2785 **
2786 ** Edit a check-in. (Check-ins are immutable and do not really change.
2787 ** This page really creates supplemental tags that affect the display
2788 ** of the check-in.)
2789 **
2790 ** Query parameters:
2791 **
2792 ** rid=INTEGER Record ID of the check-in to edit (REQUIRED)
2793 **
2794 ** POST parameters after pressing "Preview", "Cancel", or "Apply":
2795 **
2796 ** c=TEXT New check-in comment
2797 ** u=TEXT New user name
2798 ** newclr Apply a background color
2799 ** clr=TEXT New background color (only if newclr)
2800
+34 -28
--- src/login.c
+++ src/login.c
@@ -678,20 +678,18 @@
678678
}else{
679679
zAnonPw = 0;
680680
}
681681
@ <table class="login_out">
682682
@ <tr>
683
- @ <td class="form_label">User ID:</td>
684
- if( anonFlag ){
685
- @ <td><input type="text" id="u" name="u" value="anonymous" size="30"></td>
686
- }else{
687
- @ <td><input type="text" id="u" name="u" value="" size="30" /></td>
688
- }
683
+ @ <td class="form_label" id="userlabel1">User ID:</td>
684
+ @ <td><input type="text" id="u" aria-labelledby="userlabel1" name="u" \
685
+ @ size="30" value="%s(anonFlag?"anonymous":"")"></td>
689686
@ </tr>
690687
@ <tr>
691
- @ <td class="form_label">Password:</td>
692
- @ <td><input type="password" id="p" name="p" value="" size="30" />\
688
+ @ <td class="form_label" id="pswdlabel">Password:</td>
689
+ @ <td><input aria-labelledby="pswdlabel" type="password" id="p" \
690
+ @ name="p" value="" size="30" />\
693691
if( zAnonPw && !noAnon ){
694692
captcha_speakit_button(uSeed, "Speak password for \"anonymous\"");
695693
}
696694
@ </td>
697695
@ </tr>
@@ -750,16 +748,19 @@
750748
if( g.perm.Password ){
751749
@ <hr>
752750
@ <p>Change Password for user <b>%h(g.zLogin)</b>:</p>
753751
form_begin(0, "%R/login");
754752
@ <table>
755
- @ <tr><td class="form_label">Old Password:</td>
756
- @ <td><input type="password" name="p" size="30" /></td></tr>
757
- @ <tr><td class="form_label">New Password:</td>
758
- @ <td><input type="password" name="n1" size="30" /></td></tr>
759
- @ <tr><td class="form_label">Repeat New Password:</td>
760
- @ <td><input type="password" name="n2" size="30" /></td></tr>
753
+ @ <tr><td class="form_label" id="oldpw">Old Password:</td>
754
+ @ <td><input aria-labelledby="oldpw" type="password" name="p" \
755
+ @ size="30"/></td></tr>
756
+ @ <tr><td class="form_label" id="newpw">New Password:</td>
757
+ @ <td><input aria-labelledby="newpw" type="password" name="n1" \
758
+ @ size="30" /></td></tr>
759
+ @ <tr><td class="form_label" id="reppw">Repeat New Password:</td>
760
+ @ <td><input aria-labledby="reppw" type="password" name="n2" \
761
+ @ size="30" /></td></tr>
761762
@ <tr><td></td>
762763
@ <td><input type="submit" value="Change Password" /></td></tr>
763764
@ </table>
764765
@ </form>
765766
}
@@ -1690,57 +1691,62 @@
16901691
@ <input type="hidden" name="g" value="%h(P("g"))" />
16911692
}
16921693
@ <p><input type="hidden" name="captchaseed" value="%u(uSeed)" />
16931694
@ <table class="login_out">
16941695
@ <tr>
1695
- @ <td class="form_label" align="right">User ID:</td>
1696
- @ <td><input type="text" name="u" value="%h(zUserID)" size="30"></td>
1696
+ @ <td class="form_label" align="right" id="uid">User ID:</td>
1697
+ @ <td><input aria-labelledby="uid" type="text" name="u" \
1698
+ @ value="%h(zUserID)" size="30"></td>
16971699
@
16981700
if( iErrLine==1 ){
16991701
@ <tr><td><td><span class='loginError'>&uarr; %h(zErr)</span></td></tr>
17001702
}
17011703
@ <tr>
1702
- @ <td class="form_label" align="right">Display Name:</td>
1703
- @ <td><input type="text" name="dn" value="%h(zDName)" size="30"></td>
1704
+ @ <td class="form_label" align="right" id="dpyname">Display Name:</td>
1705
+ @ <td><input aria-labelledby="dpyname" type="text" name="dn" \
1706
+ @ value="%h(zDName)" size="30"></td>
17041707
@ </tr>
17051708
if( iErrLine==2 ){
17061709
@ <tr><td><td><span class='loginError'>&uarr; %h(zErr)</span></td></tr>
17071710
}
17081711
@ </tr>
17091712
@ <tr>
1710
- @ <td class="form_label" align="right">Email Address:</td>
1711
- @ <td><input type="text" name="ea" value="%h(zEAddr)" size="30"></td>
1713
+ @ <td class="form_label" align="right" id="emaddr">Email Address:</td>
1714
+ @ <td><input aria-labelledby="emaddr" type="text" name="ea" \
1715
+ @ value="%h(zEAddr)" size="30"></td>
17121716
@ </tr>
17131717
if( iErrLine==3 ){
17141718
@ <tr><td><td><span class='loginError'>&uarr; %h(zErr)</span></td></tr>
17151719
}
17161720
if( canDoAlerts ){
17171721
int a = atoi(PD("alerts","1"));
17181722
@ <tr>
1719
- @ <td class="form_label" align="right">Email&nbsp;Alerts?</td>
1720
- @ <td><select size='1' name='alerts'>
1723
+ @ <td class="form_label" align="right" id="emalrt">Email&nbsp;Alerts?</td>
1724
+ @ <td><select aria-labelledby="emalrt" size='1' name='alerts'>
17211725
@ <option value="1" %s(a?"selected":"")>Yes</option>
17221726
@ <option value="0" %s(!a?"selected":"")>No</option>
17231727
@ </select></td></tr>
17241728
}
17251729
@ <tr>
1726
- @ <td class="form_label" align="right">Password:</td>
1727
- @ <td><input type="password" name="p" value="%h(zPasswd)" size="30"></td>
1730
+ @ <td class="form_label" align="right" id="pswd">Password:</td>
1731
+ @ <td><input aria-labelledby="pswd" type="password" name="p" \
1732
+ @ value="%h(zPasswd)" size="30"></td>
17281733
@ <tr>
17291734
if( iErrLine==4 ){
17301735
@ <tr><td><td><span class='loginError'>&uarr; %h(zErr)</span></td></tr>
17311736
}
17321737
@ <tr>
1733
- @ <td class="form_label" align="right">Confirm:</td>
1734
- @ <td><input type="password" name="cp" value="%h(zConfirm)" size="30"></td>
1738
+ @ <td class="form_label" align="right" id="pwcfrm">Confirm:</td>
1739
+ @ <td><input aria-labelledby="pwcfrm" type="password" name="cp" \
1740
+ @ value="%h(zConfirm)" size="30"></td>
17351741
@ </tr>
17361742
if( iErrLine==5 ){
17371743
@ <tr><td><td><span class='loginError'>&uarr; %h(zErr)</span></td></tr>
17381744
}
17391745
@ <tr>
1740
- @ <td class="form_label" align="right">Captcha:</td>
1741
- @ <td><input type="text" name="captcha" \
1746
+ @ <td class="form_label" align="right" id="cptcha">Captcha:</td>
1747
+ @ <td><input type="text" name="captcha" aria-labelledby="cptcha" \
17421748
@ value="%h(captchaIsCorrect?zDecoded:"")" size="30">
17431749
captcha_speakit_button(uSeed, "Speak the captcha text");
17441750
@ </td>
17451751
@ </tr>
17461752
if( iErrLine==6 ){
17471753
--- src/login.c
+++ src/login.c
@@ -678,20 +678,18 @@
678 }else{
679 zAnonPw = 0;
680 }
681 @ <table class="login_out">
682 @ <tr>
683 @ <td class="form_label">User ID:</td>
684 if( anonFlag ){
685 @ <td><input type="text" id="u" name="u" value="anonymous" size="30"></td>
686 }else{
687 @ <td><input type="text" id="u" name="u" value="" size="30" /></td>
688 }
689 @ </tr>
690 @ <tr>
691 @ <td class="form_label">Password:</td>
692 @ <td><input type="password" id="p" name="p" value="" size="30" />\
 
693 if( zAnonPw && !noAnon ){
694 captcha_speakit_button(uSeed, "Speak password for \"anonymous\"");
695 }
696 @ </td>
697 @ </tr>
@@ -750,16 +748,19 @@
750 if( g.perm.Password ){
751 @ <hr>
752 @ <p>Change Password for user <b>%h(g.zLogin)</b>:</p>
753 form_begin(0, "%R/login");
754 @ <table>
755 @ <tr><td class="form_label">Old Password:</td>
756 @ <td><input type="password" name="p" size="30" /></td></tr>
757 @ <tr><td class="form_label">New Password:</td>
758 @ <td><input type="password" name="n1" size="30" /></td></tr>
759 @ <tr><td class="form_label">Repeat New Password:</td>
760 @ <td><input type="password" name="n2" size="30" /></td></tr>
 
 
 
761 @ <tr><td></td>
762 @ <td><input type="submit" value="Change Password" /></td></tr>
763 @ </table>
764 @ </form>
765 }
@@ -1690,57 +1691,62 @@
1690 @ <input type="hidden" name="g" value="%h(P("g"))" />
1691 }
1692 @ <p><input type="hidden" name="captchaseed" value="%u(uSeed)" />
1693 @ <table class="login_out">
1694 @ <tr>
1695 @ <td class="form_label" align="right">User ID:</td>
1696 @ <td><input type="text" name="u" value="%h(zUserID)" size="30"></td>
 
1697 @
1698 if( iErrLine==1 ){
1699 @ <tr><td><td><span class='loginError'>&uarr; %h(zErr)</span></td></tr>
1700 }
1701 @ <tr>
1702 @ <td class="form_label" align="right">Display Name:</td>
1703 @ <td><input type="text" name="dn" value="%h(zDName)" size="30"></td>
 
1704 @ </tr>
1705 if( iErrLine==2 ){
1706 @ <tr><td><td><span class='loginError'>&uarr; %h(zErr)</span></td></tr>
1707 }
1708 @ </tr>
1709 @ <tr>
1710 @ <td class="form_label" align="right">Email Address:</td>
1711 @ <td><input type="text" name="ea" value="%h(zEAddr)" size="30"></td>
 
1712 @ </tr>
1713 if( iErrLine==3 ){
1714 @ <tr><td><td><span class='loginError'>&uarr; %h(zErr)</span></td></tr>
1715 }
1716 if( canDoAlerts ){
1717 int a = atoi(PD("alerts","1"));
1718 @ <tr>
1719 @ <td class="form_label" align="right">Email&nbsp;Alerts?</td>
1720 @ <td><select size='1' name='alerts'>
1721 @ <option value="1" %s(a?"selected":"")>Yes</option>
1722 @ <option value="0" %s(!a?"selected":"")>No</option>
1723 @ </select></td></tr>
1724 }
1725 @ <tr>
1726 @ <td class="form_label" align="right">Password:</td>
1727 @ <td><input type="password" name="p" value="%h(zPasswd)" size="30"></td>
 
1728 @ <tr>
1729 if( iErrLine==4 ){
1730 @ <tr><td><td><span class='loginError'>&uarr; %h(zErr)</span></td></tr>
1731 }
1732 @ <tr>
1733 @ <td class="form_label" align="right">Confirm:</td>
1734 @ <td><input type="password" name="cp" value="%h(zConfirm)" size="30"></td>
 
1735 @ </tr>
1736 if( iErrLine==5 ){
1737 @ <tr><td><td><span class='loginError'>&uarr; %h(zErr)</span></td></tr>
1738 }
1739 @ <tr>
1740 @ <td class="form_label" align="right">Captcha:</td>
1741 @ <td><input type="text" name="captcha" \
1742 @ value="%h(captchaIsCorrect?zDecoded:"")" size="30">
1743 captcha_speakit_button(uSeed, "Speak the captcha text");
1744 @ </td>
1745 @ </tr>
1746 if( iErrLine==6 ){
1747
--- src/login.c
+++ src/login.c
@@ -678,20 +678,18 @@
678 }else{
679 zAnonPw = 0;
680 }
681 @ <table class="login_out">
682 @ <tr>
683 @ <td class="form_label" id="userlabel1">User ID:</td>
684 @ <td><input type="text" id="u" aria-labelledby="userlabel1" name="u" \
685 @ size="30" value="%s(anonFlag?"anonymous":"")"></td>
 
 
 
686 @ </tr>
687 @ <tr>
688 @ <td class="form_label" id="pswdlabel">Password:</td>
689 @ <td><input aria-labelledby="pswdlabel" type="password" id="p" \
690 @ name="p" value="" size="30" />\
691 if( zAnonPw && !noAnon ){
692 captcha_speakit_button(uSeed, "Speak password for \"anonymous\"");
693 }
694 @ </td>
695 @ </tr>
@@ -750,16 +748,19 @@
748 if( g.perm.Password ){
749 @ <hr>
750 @ <p>Change Password for user <b>%h(g.zLogin)</b>:</p>
751 form_begin(0, "%R/login");
752 @ <table>
753 @ <tr><td class="form_label" id="oldpw">Old Password:</td>
754 @ <td><input aria-labelledby="oldpw" type="password" name="p" \
755 @ size="30"/></td></tr>
756 @ <tr><td class="form_label" id="newpw">New Password:</td>
757 @ <td><input aria-labelledby="newpw" type="password" name="n1" \
758 @ size="30" /></td></tr>
759 @ <tr><td class="form_label" id="reppw">Repeat New Password:</td>
760 @ <td><input aria-labledby="reppw" type="password" name="n2" \
761 @ size="30" /></td></tr>
762 @ <tr><td></td>
763 @ <td><input type="submit" value="Change Password" /></td></tr>
764 @ </table>
765 @ </form>
766 }
@@ -1690,57 +1691,62 @@
1691 @ <input type="hidden" name="g" value="%h(P("g"))" />
1692 }
1693 @ <p><input type="hidden" name="captchaseed" value="%u(uSeed)" />
1694 @ <table class="login_out">
1695 @ <tr>
1696 @ <td class="form_label" align="right" id="uid">User ID:</td>
1697 @ <td><input aria-labelledby="uid" type="text" name="u" \
1698 @ value="%h(zUserID)" size="30"></td>
1699 @
1700 if( iErrLine==1 ){
1701 @ <tr><td><td><span class='loginError'>&uarr; %h(zErr)</span></td></tr>
1702 }
1703 @ <tr>
1704 @ <td class="form_label" align="right" id="dpyname">Display Name:</td>
1705 @ <td><input aria-labelledby="dpyname" type="text" name="dn" \
1706 @ value="%h(zDName)" size="30"></td>
1707 @ </tr>
1708 if( iErrLine==2 ){
1709 @ <tr><td><td><span class='loginError'>&uarr; %h(zErr)</span></td></tr>
1710 }
1711 @ </tr>
1712 @ <tr>
1713 @ <td class="form_label" align="right" id="emaddr">Email Address:</td>
1714 @ <td><input aria-labelledby="emaddr" type="text" name="ea" \
1715 @ value="%h(zEAddr)" size="30"></td>
1716 @ </tr>
1717 if( iErrLine==3 ){
1718 @ <tr><td><td><span class='loginError'>&uarr; %h(zErr)</span></td></tr>
1719 }
1720 if( canDoAlerts ){
1721 int a = atoi(PD("alerts","1"));
1722 @ <tr>
1723 @ <td class="form_label" align="right" id="emalrt">Email&nbsp;Alerts?</td>
1724 @ <td><select aria-labelledby="emalrt" size='1' name='alerts'>
1725 @ <option value="1" %s(a?"selected":"")>Yes</option>
1726 @ <option value="0" %s(!a?"selected":"")>No</option>
1727 @ </select></td></tr>
1728 }
1729 @ <tr>
1730 @ <td class="form_label" align="right" id="pswd">Password:</td>
1731 @ <td><input aria-labelledby="pswd" type="password" name="p" \
1732 @ value="%h(zPasswd)" size="30"></td>
1733 @ <tr>
1734 if( iErrLine==4 ){
1735 @ <tr><td><td><span class='loginError'>&uarr; %h(zErr)</span></td></tr>
1736 }
1737 @ <tr>
1738 @ <td class="form_label" align="right" id="pwcfrm">Confirm:</td>
1739 @ <td><input aria-labelledby="pwcfrm" type="password" name="cp" \
1740 @ value="%h(zConfirm)" size="30"></td>
1741 @ </tr>
1742 if( iErrLine==5 ){
1743 @ <tr><td><td><span class='loginError'>&uarr; %h(zErr)</span></td></tr>
1744 }
1745 @ <tr>
1746 @ <td class="form_label" align="right" id="cptcha">Captcha:</td>
1747 @ <td><input type="text" name="captcha" aria-labelledby="cptcha" \
1748 @ value="%h(captchaIsCorrect?zDecoded:"")" size="30">
1749 captcha_speakit_button(uSeed, "Speak the captcha text");
1750 @ </td>
1751 @ </tr>
1752 if( iErrLine==6 ){
1753
+3 -3
--- src/printf.c
+++ src/printf.c
@@ -34,11 +34,11 @@
3434
** The following macros help determine those lengths. FOSSIL_HASH_DIGITS
3535
** is the default number of digits to display to humans. This value can
3636
** be overridden using the hash-digits setting. FOSSIL_HASH_DIGITS_URL
3737
** is the minimum number of digits to be used in URLs. The number used
3838
** will always be at least 6 more than the number used for human output,
39
-** or 40 if the number of digits in human output is 34 or more.
39
+** or HNAME_MAX, whichever is least.
4040
*/
4141
#ifndef FOSSIL_HASH_DIGITS
4242
# define FOSSIL_HASH_DIGITS 10 /* For %S (human display) */
4343
#endif
4444
#ifndef FOSSIL_HASH_DIGITS_URL
@@ -54,14 +54,14 @@
5454
static int nDigitHuman = 0;
5555
static int nDigitUrl = 0;
5656
if( nDigitHuman==0 ){
5757
nDigitHuman = db_get_int("hash-digits", FOSSIL_HASH_DIGITS);
5858
if( nDigitHuman < 6 ) nDigitHuman = 6;
59
- if( nDigitHuman > 40 ) nDigitHuman = 40;
59
+ if( nDigitHuman > HNAME_MAX ) nDigitHuman = HNAME_MAX;
6060
nDigitUrl = nDigitHuman + 6;
6161
if( nDigitUrl < FOSSIL_HASH_DIGITS_URL ) nDigitUrl = FOSSIL_HASH_DIGITS_URL;
62
- if( nDigitUrl > 40 ) nDigitUrl = 40;
62
+ if( nDigitUrl > HNAME_MAX ) nDigitUrl = HNAME_MAX;
6363
}
6464
return bForUrl ? nDigitUrl : nDigitHuman;
6565
}
6666
6767
/*
6868
--- src/printf.c
+++ src/printf.c
@@ -34,11 +34,11 @@
34 ** The following macros help determine those lengths. FOSSIL_HASH_DIGITS
35 ** is the default number of digits to display to humans. This value can
36 ** be overridden using the hash-digits setting. FOSSIL_HASH_DIGITS_URL
37 ** is the minimum number of digits to be used in URLs. The number used
38 ** will always be at least 6 more than the number used for human output,
39 ** or 40 if the number of digits in human output is 34 or more.
40 */
41 #ifndef FOSSIL_HASH_DIGITS
42 # define FOSSIL_HASH_DIGITS 10 /* For %S (human display) */
43 #endif
44 #ifndef FOSSIL_HASH_DIGITS_URL
@@ -54,14 +54,14 @@
54 static int nDigitHuman = 0;
55 static int nDigitUrl = 0;
56 if( nDigitHuman==0 ){
57 nDigitHuman = db_get_int("hash-digits", FOSSIL_HASH_DIGITS);
58 if( nDigitHuman < 6 ) nDigitHuman = 6;
59 if( nDigitHuman > 40 ) nDigitHuman = 40;
60 nDigitUrl = nDigitHuman + 6;
61 if( nDigitUrl < FOSSIL_HASH_DIGITS_URL ) nDigitUrl = FOSSIL_HASH_DIGITS_URL;
62 if( nDigitUrl > 40 ) nDigitUrl = 40;
63 }
64 return bForUrl ? nDigitUrl : nDigitHuman;
65 }
66
67 /*
68
--- src/printf.c
+++ src/printf.c
@@ -34,11 +34,11 @@
34 ** The following macros help determine those lengths. FOSSIL_HASH_DIGITS
35 ** is the default number of digits to display to humans. This value can
36 ** be overridden using the hash-digits setting. FOSSIL_HASH_DIGITS_URL
37 ** is the minimum number of digits to be used in URLs. The number used
38 ** will always be at least 6 more than the number used for human output,
39 ** or HNAME_MAX, whichever is least.
40 */
41 #ifndef FOSSIL_HASH_DIGITS
42 # define FOSSIL_HASH_DIGITS 10 /* For %S (human display) */
43 #endif
44 #ifndef FOSSIL_HASH_DIGITS_URL
@@ -54,14 +54,14 @@
54 static int nDigitHuman = 0;
55 static int nDigitUrl = 0;
56 if( nDigitHuman==0 ){
57 nDigitHuman = db_get_int("hash-digits", FOSSIL_HASH_DIGITS);
58 if( nDigitHuman < 6 ) nDigitHuman = 6;
59 if( nDigitHuman > HNAME_MAX ) nDigitHuman = HNAME_MAX;
60 nDigitUrl = nDigitHuman + 6;
61 if( nDigitUrl < FOSSIL_HASH_DIGITS_URL ) nDigitUrl = FOSSIL_HASH_DIGITS_URL;
62 if( nDigitUrl > HNAME_MAX ) nDigitUrl = HNAME_MAX;
63 }
64 return bForUrl ? nDigitUrl : nDigitHuman;
65 }
66
67 /*
68
+32 -25
--- src/setup.c
+++ src/setup.c
@@ -201,16 +201,17 @@
201201
admin_log("Set option [%q] to [%q].",
202202
zVar, iQ ? "on" : "off");
203203
iVal = iQ;
204204
}
205205
}
206
- @ <label><input type="checkbox" name="%s(zQParm)"
206
+ @ <label><input type="checkbox" name="%s(zQParm)" \
207
+ @ aria-label="%s(zLabel[0]?zLabel:zQParm)" \
207208
if( iVal ){
208
- @ checked="checked"
209
+ @ checked="checked" \
209210
}
210211
if( disabled ){
211
- @ disabled="disabled"
212
+ @ disabled="disabled" \
212213
}
213214
@ /> <b>%s(zLabel)</b></label>
214215
}
215216
216217
/*
@@ -232,12 +233,12 @@
232233
db_set(zVar, zQ, 0);
233234
admin_log("Set entry_attribute %Q to: %.*s%s",
234235
zVar, 20, zQ, (nZQ>20 ? "..." : ""));
235236
zVal = zQ;
236237
}
237
- @ <input type="text" id="%s(zQParm)" name="%s(zQParm)" value="%h(zVal)" \
238
- @ size="%d(width)" \
238
+ @ <input aria-label="%h(zLabel[0]?zLabel:zQParm)" type="text" \
239
+ @ id="%s(zQParm)" name="%s(zQParm)" value="%h(zVal)" size="%d(width)" \
239240
if( disabled ){
240241
@ disabled="disabled" \
241242
}
242243
@ /> <b>%s(zLabel)</b>
243244
}
@@ -263,16 +264,17 @@
263264
admin_log("Set textarea_attribute %Q to: %.*s%s",
264265
zVar, 20, zQ, (nZQ>20 ? "..." : ""));
265266
z = zQ;
266267
}
267268
if( rows>0 && cols>0 ){
268
- @ <textarea id="id%s(zQP)" name="%s(zQP)" rows="%d(rows)"
269
+ @ <textarea id="id%s(zQP)" name="%s(zQP)" rows="%d(rows)" \
270
+ @ aria-label="%h(zLabel[0]?zLabel:zQP)" \
269271
if( disabled ){
270
- @ disabled="disabled"
272
+ @ disabled="disabled" \
271273
}
272274
@ cols="%d(cols)">%h(z)</textarea>
273
- if( zLabel && *zLabel ){
275
+ if( *zLabel ){
274276
@ <span class="textareaLabel">%s(zLabel)</span>
275277
}
276278
}
277279
return z;
278280
}
@@ -297,11 +299,11 @@
297299
db_set(zVar, zQ, 0);
298300
admin_log("Set multiple_choice_attribute %Q to: %.*s%s",
299301
zVar, 20, zQ, (nZQ>20 ? "..." : ""));
300302
z = zQ;
301303
}
302
- @ <select size="1" name="%s(zQP)" id="id%s(zQP)">
304
+ @ <select aria-label="%h(zLabel)" size="1" name="%s(zQP)" id="id%s(zQP)">
303305
for(i=0; i<nChoice*2; i+=2){
304306
const char *zSel = fossil_strcmp(azChoice[i],z)==0 ? " selected" : "";
305307
@ <option value="%h(azChoice[i])"%s(zSel)>%h(azChoice[i+1])</option>
306308
}
307309
@ </select> <b>%h(zLabel)</b>
@@ -398,11 +400,11 @@
398400
@ <hr />
399401
onoff_attribute("Allow HTTP_AUTHENTICATION authentication",
400402
"http_authentication_ok", "http_authentication_ok", 0, 0);
401403
@ <p>When enabled, allow the use of the HTTP_AUTHENTICATION environment
402404
@ variable or the "Authentication:" HTTP header to find the username and
403
- @ password. This is another way of supporting Basic Authenitication.
405
+ @ password. This is another way of supporting Basic Authentication.
404406
@ (Property: "http_authentication_ok")
405407
@ </p>
406408
@
407409
@ <hr />
408410
entry_attribute("Login expiration time", 6, "cookie-expire", "cex",
@@ -606,25 +608,30 @@
606608
@
607609
@ <form action="%s(g.zTop)/setup_login_group" method="post"><div>
608610
login_insert_csrf_secret();
609611
@ <blockquote><table border="0">
610612
@
611
- @ <tr><th align="right">Repository filename in group to join:</th>
612
- @ <td width="5"></td><td>
613
- @ <input type="text" size="50" value="%h(zRepo)" name="repo"></td></tr>
614
- @
615
- @ <tr><th align="right">Login on the above repo:</th>
616
- @ <td width="5"></td><td>
617
- @ <input type="text" size="20" value="%h(zLogin)" name="login"></td></tr>
618
- @
619
- @ <tr><th align="right">Password:</th>
620
- @ <td width="5"></td><td>
621
- @ <input type="password" size="20" name="pw"></td></tr>
622
- @
623
- @ <tr><th align="right">Name of login-group:</th>
624
- @ <td width="5"></td><td>
625
- @ <input type="text" size="30" value="%h(zNewName)" name="newname">
613
+ @ <tr><th align="right" id="rfigtj">Repository filename \
614
+ @ in group to join:</th>
615
+ @ <td width="5"></td><td>
616
+ @ <input aria-labelledby="rfigtj" type="text" size="50" \
617
+ @ value="%h(zRepo)" name="repo"></td></tr>
618
+ @
619
+ @ <tr><th align="right" id="lotar">Login on the above repo:</th>
620
+ @ <td width="5"></td><td>
621
+ @ <input aria-labelledby="lotar" type="text" size="20" \
622
+ @ value="%h(zLogin)" name="login"></td></tr>
623
+ @
624
+ @ <tr><th align="right" id="lgpw">Password:</th>
625
+ @ <td width="5"></td><td>
626
+ @ <input aria-labelledby="lgpw" type="password" size="20" name="pw">\
627
+ @ </td></tr>
628
+ @
629
+ @ <tr><th align="right" id="nolg">Name of login-group:</th>
630
+ @ <td width="5"></td><td>
631
+ @ <input aria-labelledby="nolg" type="text" size="30" \
632
+ @ value="%h(zNewName)" name="newname">
626633
@ (only used if creating a new login-group).</td></tr>
627634
@
628635
@ <tr><td colspan="3" align="center">
629636
@ <input type="submit" value="Join" name="join"></td></tr>
630637
@ </table></blockquote></div></form>
631638
--- src/setup.c
+++ src/setup.c
@@ -201,16 +201,17 @@
201 admin_log("Set option [%q] to [%q].",
202 zVar, iQ ? "on" : "off");
203 iVal = iQ;
204 }
205 }
206 @ <label><input type="checkbox" name="%s(zQParm)"
 
207 if( iVal ){
208 @ checked="checked"
209 }
210 if( disabled ){
211 @ disabled="disabled"
212 }
213 @ /> <b>%s(zLabel)</b></label>
214 }
215
216 /*
@@ -232,12 +233,12 @@
232 db_set(zVar, zQ, 0);
233 admin_log("Set entry_attribute %Q to: %.*s%s",
234 zVar, 20, zQ, (nZQ>20 ? "..." : ""));
235 zVal = zQ;
236 }
237 @ <input type="text" id="%s(zQParm)" name="%s(zQParm)" value="%h(zVal)" \
238 @ size="%d(width)" \
239 if( disabled ){
240 @ disabled="disabled" \
241 }
242 @ /> <b>%s(zLabel)</b>
243 }
@@ -263,16 +264,17 @@
263 admin_log("Set textarea_attribute %Q to: %.*s%s",
264 zVar, 20, zQ, (nZQ>20 ? "..." : ""));
265 z = zQ;
266 }
267 if( rows>0 && cols>0 ){
268 @ <textarea id="id%s(zQP)" name="%s(zQP)" rows="%d(rows)"
 
269 if( disabled ){
270 @ disabled="disabled"
271 }
272 @ cols="%d(cols)">%h(z)</textarea>
273 if( zLabel && *zLabel ){
274 @ <span class="textareaLabel">%s(zLabel)</span>
275 }
276 }
277 return z;
278 }
@@ -297,11 +299,11 @@
297 db_set(zVar, zQ, 0);
298 admin_log("Set multiple_choice_attribute %Q to: %.*s%s",
299 zVar, 20, zQ, (nZQ>20 ? "..." : ""));
300 z = zQ;
301 }
302 @ <select size="1" name="%s(zQP)" id="id%s(zQP)">
303 for(i=0; i<nChoice*2; i+=2){
304 const char *zSel = fossil_strcmp(azChoice[i],z)==0 ? " selected" : "";
305 @ <option value="%h(azChoice[i])"%s(zSel)>%h(azChoice[i+1])</option>
306 }
307 @ </select> <b>%h(zLabel)</b>
@@ -398,11 +400,11 @@
398 @ <hr />
399 onoff_attribute("Allow HTTP_AUTHENTICATION authentication",
400 "http_authentication_ok", "http_authentication_ok", 0, 0);
401 @ <p>When enabled, allow the use of the HTTP_AUTHENTICATION environment
402 @ variable or the "Authentication:" HTTP header to find the username and
403 @ password. This is another way of supporting Basic Authenitication.
404 @ (Property: "http_authentication_ok")
405 @ </p>
406 @
407 @ <hr />
408 entry_attribute("Login expiration time", 6, "cookie-expire", "cex",
@@ -606,25 +608,30 @@
606 @
607 @ <form action="%s(g.zTop)/setup_login_group" method="post"><div>
608 login_insert_csrf_secret();
609 @ <blockquote><table border="0">
610 @
611 @ <tr><th align="right">Repository filename in group to join:</th>
612 @ <td width="5"></td><td>
613 @ <input type="text" size="50" value="%h(zRepo)" name="repo"></td></tr>
614 @
615 @ <tr><th align="right">Login on the above repo:</th>
616 @ <td width="5"></td><td>
617 @ <input type="text" size="20" value="%h(zLogin)" name="login"></td></tr>
618 @
619 @ <tr><th align="right">Password:</th>
620 @ <td width="5"></td><td>
621 @ <input type="password" size="20" name="pw"></td></tr>
622 @
623 @ <tr><th align="right">Name of login-group:</th>
624 @ <td width="5"></td><td>
625 @ <input type="text" size="30" value="%h(zNewName)" name="newname">
 
 
 
 
 
626 @ (only used if creating a new login-group).</td></tr>
627 @
628 @ <tr><td colspan="3" align="center">
629 @ <input type="submit" value="Join" name="join"></td></tr>
630 @ </table></blockquote></div></form>
631
--- src/setup.c
+++ src/setup.c
@@ -201,16 +201,17 @@
201 admin_log("Set option [%q] to [%q].",
202 zVar, iQ ? "on" : "off");
203 iVal = iQ;
204 }
205 }
206 @ <label><input type="checkbox" name="%s(zQParm)" \
207 @ aria-label="%s(zLabel[0]?zLabel:zQParm)" \
208 if( iVal ){
209 @ checked="checked" \
210 }
211 if( disabled ){
212 @ disabled="disabled" \
213 }
214 @ /> <b>%s(zLabel)</b></label>
215 }
216
217 /*
@@ -232,12 +233,12 @@
233 db_set(zVar, zQ, 0);
234 admin_log("Set entry_attribute %Q to: %.*s%s",
235 zVar, 20, zQ, (nZQ>20 ? "..." : ""));
236 zVal = zQ;
237 }
238 @ <input aria-label="%h(zLabel[0]?zLabel:zQParm)" type="text" \
239 @ id="%s(zQParm)" name="%s(zQParm)" value="%h(zVal)" size="%d(width)" \
240 if( disabled ){
241 @ disabled="disabled" \
242 }
243 @ /> <b>%s(zLabel)</b>
244 }
@@ -263,16 +264,17 @@
264 admin_log("Set textarea_attribute %Q to: %.*s%s",
265 zVar, 20, zQ, (nZQ>20 ? "..." : ""));
266 z = zQ;
267 }
268 if( rows>0 && cols>0 ){
269 @ <textarea id="id%s(zQP)" name="%s(zQP)" rows="%d(rows)" \
270 @ aria-label="%h(zLabel[0]?zLabel:zQP)" \
271 if( disabled ){
272 @ disabled="disabled" \
273 }
274 @ cols="%d(cols)">%h(z)</textarea>
275 if( *zLabel ){
276 @ <span class="textareaLabel">%s(zLabel)</span>
277 }
278 }
279 return z;
280 }
@@ -297,11 +299,11 @@
299 db_set(zVar, zQ, 0);
300 admin_log("Set multiple_choice_attribute %Q to: %.*s%s",
301 zVar, 20, zQ, (nZQ>20 ? "..." : ""));
302 z = zQ;
303 }
304 @ <select aria-label="%h(zLabel)" size="1" name="%s(zQP)" id="id%s(zQP)">
305 for(i=0; i<nChoice*2; i+=2){
306 const char *zSel = fossil_strcmp(azChoice[i],z)==0 ? " selected" : "";
307 @ <option value="%h(azChoice[i])"%s(zSel)>%h(azChoice[i+1])</option>
308 }
309 @ </select> <b>%h(zLabel)</b>
@@ -398,11 +400,11 @@
400 @ <hr />
401 onoff_attribute("Allow HTTP_AUTHENTICATION authentication",
402 "http_authentication_ok", "http_authentication_ok", 0, 0);
403 @ <p>When enabled, allow the use of the HTTP_AUTHENTICATION environment
404 @ variable or the "Authentication:" HTTP header to find the username and
405 @ password. This is another way of supporting Basic Authentication.
406 @ (Property: "http_authentication_ok")
407 @ </p>
408 @
409 @ <hr />
410 entry_attribute("Login expiration time", 6, "cookie-expire", "cex",
@@ -606,25 +608,30 @@
608 @
609 @ <form action="%s(g.zTop)/setup_login_group" method="post"><div>
610 login_insert_csrf_secret();
611 @ <blockquote><table border="0">
612 @
613 @ <tr><th align="right" id="rfigtj">Repository filename \
614 @ in group to join:</th>
615 @ <td width="5"></td><td>
616 @ <input aria-labelledby="rfigtj" type="text" size="50" \
617 @ value="%h(zRepo)" name="repo"></td></tr>
618 @
619 @ <tr><th align="right" id="lotar">Login on the above repo:</th>
620 @ <td width="5"></td><td>
621 @ <input aria-labelledby="lotar" type="text" size="20" \
622 @ value="%h(zLogin)" name="login"></td></tr>
623 @
624 @ <tr><th align="right" id="lgpw">Password:</th>
625 @ <td width="5"></td><td>
626 @ <input aria-labelledby="lgpw" type="password" size="20" name="pw">\
627 @ </td></tr>
628 @
629 @ <tr><th align="right" id="nolg">Name of login-group:</th>
630 @ <td width="5"></td><td>
631 @ <input aria-labelledby="nolg" type="text" size="30" \
632 @ value="%h(zNewName)" name="newname">
633 @ (only used if creating a new login-group).</td></tr>
634 @
635 @ <tr><td colspan="3" align="center">
636 @ <input type="submit" value="Join" name="join"></td></tr>
637 @ </table></blockquote></div></form>
638
+16 -12
--- src/setupuser.c
+++ src/setupuser.c
@@ -534,24 +534,27 @@
534534
@ <input type="hidden" name="pw" value="*">
535535
}
536536
@ <input type="hidden" name="referer" value="%h(cgi_referer("setup_ulist"))">
537537
@ <table width="100%%">
538538
@ <tr>
539
- @ <td class="usetupEditLabel">User ID:</td>
539
+ @ <td class="usetupEditLabel" id="suuid">User ID:</td>
540540
if( uid ){
541
- @ <td>%d(uid) <input type="hidden" name="id" value="%d(uid)" />\
541
+ @ <td>%d(uid) <input aria-labelledby="suuid" type="hidden" \
542
+ @ name="id" value="%d(uid)"/>\
542543
@ </td>
543544
}else{
544
- @ <td>(new user)<input type="hidden" name="id" value="0" /></td>
545
+ @ <td>(new user)<input aria-labelledby="suuid" type="hidden" name="id" \
546
+ @ value="0" /></td>
545547
}
546548
@ </tr>
547549
@ <tr>
548
- @ <td class="usetupEditLabel">Login:</td>
550
+ @ <td class="usetupEditLabel" id="sulgn">Login:</td>
549551
if( login_is_special(zLogin) ){
550552
@ <td><b>%h(zLogin)</b></td>
551553
}else{
552
- @ <td><input type="text" name="login" value="%h(zLogin)" />\
554
+ @ <td><input aria-labelledby="sulgn" type="text" name="login" \
555
+ @ value="%h(zLogin)" />
553556
if( alert_tables_exist() ){
554557
int sid;
555558
sid = db_int(0, "SELECT subscriberId FROM subscriber"
556559
" WHERE suname=%Q", zLogin);
557560
if( sid>0 ){
@@ -559,12 +562,13 @@
559562
@ (subscription info for %h(zLogin))</a>\
560563
}
561564
}
562565
@ </td></tr>
563566
@ <tr>
564
- @ <td class="usetupEditLabel">Contact&nbsp;Info:</td>
565
- @ <td><textarea name="info" cols="40" rows="2">%h(zInfo)</textarea></td>
567
+ @ <td class="usetupEditLabel" id="sucnfo">Contact&nbsp;Info:</td>
568
+ @ <td><textarea aria-labelledby="sucnfo" name="info" cols="40" \
569
+ @ rows="2">%h(zInfo)</textarea></td>
566570
}
567571
@ </tr>
568572
@ <tr>
569573
@ <td class="usetupEditLabel">Capabilities:</td>
570574
@ <td width="100%%">
@@ -653,19 +657,19 @@
653657
@ <a href="%R/setup_ucap_list">(key)</a>
654658
@ </td>
655659
@ </tr>
656660
if( !login_is_special(zLogin) ){
657661
@ <tr>
658
- @ <td align="right">Password:</td>
662
+ @ <td align="right" id="supw">Password:</td>
659663
if( zPw[0] ){
660664
/* Obscure the password for all users */
661
- @ <td><input type="password" autocomplete="off" name="pw"\
662
- @ value="**********" /></td>
665
+ @ <td><input aria-labelledby="supw" type="password" autocomplete="off" \
666
+ @ name="pw" value="**********" /></td>
663667
}else{
664668
/* Show an empty password as an empty input field */
665
- @ <td><input type="password" autocomplete="off" name="pw"\
666
- @ value="" /></td>
669
+ @ <td><input aria-labelledby="supw" type="password" name="pw" \
670
+ @ autocomplete="off" value="" /></td>
667671
}
668672
@ </tr>
669673
}
670674
zGroup = login_group_name();
671675
if( zGroup ){
672676
--- src/setupuser.c
+++ src/setupuser.c
@@ -534,24 +534,27 @@
534 @ <input type="hidden" name="pw" value="*">
535 }
536 @ <input type="hidden" name="referer" value="%h(cgi_referer("setup_ulist"))">
537 @ <table width="100%%">
538 @ <tr>
539 @ <td class="usetupEditLabel">User ID:</td>
540 if( uid ){
541 @ <td>%d(uid) <input type="hidden" name="id" value="%d(uid)" />\
 
542 @ </td>
543 }else{
544 @ <td>(new user)<input type="hidden" name="id" value="0" /></td>
 
545 }
546 @ </tr>
547 @ <tr>
548 @ <td class="usetupEditLabel">Login:</td>
549 if( login_is_special(zLogin) ){
550 @ <td><b>%h(zLogin)</b></td>
551 }else{
552 @ <td><input type="text" name="login" value="%h(zLogin)" />\
 
553 if( alert_tables_exist() ){
554 int sid;
555 sid = db_int(0, "SELECT subscriberId FROM subscriber"
556 " WHERE suname=%Q", zLogin);
557 if( sid>0 ){
@@ -559,12 +562,13 @@
559 @ (subscription info for %h(zLogin))</a>\
560 }
561 }
562 @ </td></tr>
563 @ <tr>
564 @ <td class="usetupEditLabel">Contact&nbsp;Info:</td>
565 @ <td><textarea name="info" cols="40" rows="2">%h(zInfo)</textarea></td>
 
566 }
567 @ </tr>
568 @ <tr>
569 @ <td class="usetupEditLabel">Capabilities:</td>
570 @ <td width="100%%">
@@ -653,19 +657,19 @@
653 @ <a href="%R/setup_ucap_list">(key)</a>
654 @ </td>
655 @ </tr>
656 if( !login_is_special(zLogin) ){
657 @ <tr>
658 @ <td align="right">Password:</td>
659 if( zPw[0] ){
660 /* Obscure the password for all users */
661 @ <td><input type="password" autocomplete="off" name="pw"\
662 @ value="**********" /></td>
663 }else{
664 /* Show an empty password as an empty input field */
665 @ <td><input type="password" autocomplete="off" name="pw"\
666 @ value="" /></td>
667 }
668 @ </tr>
669 }
670 zGroup = login_group_name();
671 if( zGroup ){
672
--- src/setupuser.c
+++ src/setupuser.c
@@ -534,24 +534,27 @@
534 @ <input type="hidden" name="pw" value="*">
535 }
536 @ <input type="hidden" name="referer" value="%h(cgi_referer("setup_ulist"))">
537 @ <table width="100%%">
538 @ <tr>
539 @ <td class="usetupEditLabel" id="suuid">User ID:</td>
540 if( uid ){
541 @ <td>%d(uid) <input aria-labelledby="suuid" type="hidden" \
542 @ name="id" value="%d(uid)"/>\
543 @ </td>
544 }else{
545 @ <td>(new user)<input aria-labelledby="suuid" type="hidden" name="id" \
546 @ value="0" /></td>
547 }
548 @ </tr>
549 @ <tr>
550 @ <td class="usetupEditLabel" id="sulgn">Login:</td>
551 if( login_is_special(zLogin) ){
552 @ <td><b>%h(zLogin)</b></td>
553 }else{
554 @ <td><input aria-labelledby="sulgn" type="text" name="login" \
555 @ value="%h(zLogin)" />
556 if( alert_tables_exist() ){
557 int sid;
558 sid = db_int(0, "SELECT subscriberId FROM subscriber"
559 " WHERE suname=%Q", zLogin);
560 if( sid>0 ){
@@ -559,12 +562,13 @@
562 @ (subscription info for %h(zLogin))</a>\
563 }
564 }
565 @ </td></tr>
566 @ <tr>
567 @ <td class="usetupEditLabel" id="sucnfo">Contact&nbsp;Info:</td>
568 @ <td><textarea aria-labelledby="sucnfo" name="info" cols="40" \
569 @ rows="2">%h(zInfo)</textarea></td>
570 }
571 @ </tr>
572 @ <tr>
573 @ <td class="usetupEditLabel">Capabilities:</td>
574 @ <td width="100%%">
@@ -653,19 +657,19 @@
657 @ <a href="%R/setup_ucap_list">(key)</a>
658 @ </td>
659 @ </tr>
660 if( !login_is_special(zLogin) ){
661 @ <tr>
662 @ <td align="right" id="supw">Password:</td>
663 if( zPw[0] ){
664 /* Obscure the password for all users */
665 @ <td><input aria-labelledby="supw" type="password" autocomplete="off" \
666 @ name="pw" value="**********" /></td>
667 }else{
668 /* Show an empty password as an empty input field */
669 @ <td><input aria-labelledby="supw" type="password" name="pw" \
670 @ autocomplete="off" value="" /></td>
671 }
672 @ </tr>
673 }
674 zGroup = login_group_name();
675 if( zGroup ){
676
+10 -4
--- src/shell.c
+++ src/shell.c
@@ -6589,10 +6589,11 @@
65896589
** sqlar support.
65906590
*/
65916591
/* #include "sqlite3ext.h" */
65926592
SQLITE_EXTENSION_INIT1
65936593
#include <zlib.h>
6594
+#include <assert.h>
65946595
65956596
/*
65966597
** Implementation of the "sqlar_compress(X)" SQL function.
65976598
**
65986599
** If the type of X is SQLITE_BLOB, and compressing that blob using
@@ -7998,18 +7999,23 @@
79987999
while( rc==SQLITE_OK && sqlite3_step(pExplain)==SQLITE_ROW ){
79998000
/* int iId = sqlite3_column_int(pExplain, 0); */
80008001
/* int iParent = sqlite3_column_int(pExplain, 1); */
80018002
/* int iNotUsed = sqlite3_column_int(pExplain, 2); */
80028003
const char *zDetail = (const char*)sqlite3_column_text(pExplain, 3);
8003
- int nDetail = STRLEN(zDetail);
8004
+ int nDetail;
80048005
int i;
80058006
8007
+ if( !zDetail ) continue;
8008
+ nDetail = STRLEN(zDetail);
8009
+
80068010
for(i=0; i<nDetail; i++){
80078011
const char *zIdx = 0;
8008
- if( memcmp(&zDetail[i], " USING INDEX ", 13)==0 ){
8012
+ if( i+13<nDetail && memcmp(&zDetail[i], " USING INDEX ", 13)==0 ){
80098013
zIdx = &zDetail[i+13];
8010
- }else if( memcmp(&zDetail[i], " USING COVERING INDEX ", 22)==0 ){
8014
+ }else if( i+22<nDetail
8015
+ && memcmp(&zDetail[i], " USING COVERING INDEX ", 22)==0
8016
+ ){
80118017
zIdx = &zDetail[i+22];
80128018
}
80138019
if( zIdx ){
80148020
const char *zSql;
80158021
int nIdx = 0;
@@ -8820,11 +8826,11 @@
88208826
sqlite3_free(p->zCandidates);
88218827
sqlite3_free(p);
88228828
}
88238829
}
88248830
8825
-#endif /* ifndef SQLITE_OMIT_VIRTUAL_TABLE */
8831
+#endif /* ifndef SQLITE_OMIT_VIRTUALTABLE */
88268832
88278833
/************************* End ../ext/expert/sqlite3expert.c ********************/
88288834
88298835
#if !defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_ENABLE_DBPAGE_VTAB)
88308836
/************************* Begin ../ext/misc/dbdata.c ******************/
88318837
--- src/shell.c
+++ src/shell.c
@@ -6589,10 +6589,11 @@
6589 ** sqlar support.
6590 */
6591 /* #include "sqlite3ext.h" */
6592 SQLITE_EXTENSION_INIT1
6593 #include <zlib.h>
 
6594
6595 /*
6596 ** Implementation of the "sqlar_compress(X)" SQL function.
6597 **
6598 ** If the type of X is SQLITE_BLOB, and compressing that blob using
@@ -7998,18 +7999,23 @@
7998 while( rc==SQLITE_OK && sqlite3_step(pExplain)==SQLITE_ROW ){
7999 /* int iId = sqlite3_column_int(pExplain, 0); */
8000 /* int iParent = sqlite3_column_int(pExplain, 1); */
8001 /* int iNotUsed = sqlite3_column_int(pExplain, 2); */
8002 const char *zDetail = (const char*)sqlite3_column_text(pExplain, 3);
8003 int nDetail = STRLEN(zDetail);
8004 int i;
8005
 
 
 
8006 for(i=0; i<nDetail; i++){
8007 const char *zIdx = 0;
8008 if( memcmp(&zDetail[i], " USING INDEX ", 13)==0 ){
8009 zIdx = &zDetail[i+13];
8010 }else if( memcmp(&zDetail[i], " USING COVERING INDEX ", 22)==0 ){
 
 
8011 zIdx = &zDetail[i+22];
8012 }
8013 if( zIdx ){
8014 const char *zSql;
8015 int nIdx = 0;
@@ -8820,11 +8826,11 @@
8820 sqlite3_free(p->zCandidates);
8821 sqlite3_free(p);
8822 }
8823 }
8824
8825 #endif /* ifndef SQLITE_OMIT_VIRTUAL_TABLE */
8826
8827 /************************* End ../ext/expert/sqlite3expert.c ********************/
8828
8829 #if !defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_ENABLE_DBPAGE_VTAB)
8830 /************************* Begin ../ext/misc/dbdata.c ******************/
8831
--- src/shell.c
+++ src/shell.c
@@ -6589,10 +6589,11 @@
6589 ** sqlar support.
6590 */
6591 /* #include "sqlite3ext.h" */
6592 SQLITE_EXTENSION_INIT1
6593 #include <zlib.h>
6594 #include <assert.h>
6595
6596 /*
6597 ** Implementation of the "sqlar_compress(X)" SQL function.
6598 **
6599 ** If the type of X is SQLITE_BLOB, and compressing that blob using
@@ -7998,18 +7999,23 @@
7999 while( rc==SQLITE_OK && sqlite3_step(pExplain)==SQLITE_ROW ){
8000 /* int iId = sqlite3_column_int(pExplain, 0); */
8001 /* int iParent = sqlite3_column_int(pExplain, 1); */
8002 /* int iNotUsed = sqlite3_column_int(pExplain, 2); */
8003 const char *zDetail = (const char*)sqlite3_column_text(pExplain, 3);
8004 int nDetail;
8005 int i;
8006
8007 if( !zDetail ) continue;
8008 nDetail = STRLEN(zDetail);
8009
8010 for(i=0; i<nDetail; i++){
8011 const char *zIdx = 0;
8012 if( i+13<nDetail && memcmp(&zDetail[i], " USING INDEX ", 13)==0 ){
8013 zIdx = &zDetail[i+13];
8014 }else if( i+22<nDetail
8015 && memcmp(&zDetail[i], " USING COVERING INDEX ", 22)==0
8016 ){
8017 zIdx = &zDetail[i+22];
8018 }
8019 if( zIdx ){
8020 const char *zSql;
8021 int nIdx = 0;
@@ -8820,11 +8826,11 @@
8826 sqlite3_free(p->zCandidates);
8827 sqlite3_free(p);
8828 }
8829 }
8830
8831 #endif /* ifndef SQLITE_OMIT_VIRTUALTABLE */
8832
8833 /************************* End ../ext/expert/sqlite3expert.c ********************/
8834
8835 #if !defined(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_ENABLE_DBPAGE_VTAB)
8836 /************************* Begin ../ext/misc/dbdata.c ******************/
8837
+7 -2
--- src/skins.c
+++ src/skins.c
@@ -281,10 +281,13 @@
281281
** Return an identifier that is (probably) different for every skin
282282
** but that is (probably) the same if the skin is unchanged. This
283283
** identifier can be attached to resource URLs to force reloading when
284284
** the resources change but allow the resources to be read from cache
285285
** as long as they are unchanged.
286
+**
287
+** The zResource argument is the name of a CONFIG setting that
288
+** defines the resource. Examples: "css", "logo-image".
286289
*/
287290
unsigned int skin_id(const char *zResource){
288291
unsigned int h = 0;
289292
if( zAltSkinDir ){
290293
h = skin_hash(0, zAltSkinDir);
@@ -293,11 +296,13 @@
293296
}else{
294297
char *zMTime = db_get_mtime(zResource, 0, 0);
295298
h = skin_hash(0, zMTime);
296299
fossil_free(zMTime);
297300
}
298
- h = skin_hash(h, MANIFEST_UUID);
301
+
302
+ /* Change the ID every time Fossil is recompiled */
303
+ h = skin_hash(h, fossil_exe_id());
299304
return h;
300305
}
301306
302307
/*
303308
** For a skin named zSkinName, compute the name of the CONFIG table
@@ -1117,11 +1122,11 @@
11171122
if( !g.perm.Admin ){
11181123
@ <p>Only administrators are allowed to publish draft skins. Contact
11191124
@ an administrator to get this "draft%d(iSkin)" skin published.</p>
11201125
}else{
11211126
@ <p>When the draft%d(iSkin) skin is ready for production use,
1122
- @ make it the default scan by clicking the acknowledgements and
1127
+ @ make it the default skin by clicking the acknowledgements and
11231128
@ pressing the button below:</p>
11241129
@
11251130
@ <form method='POST' action='%R/setup_skin#step7'>
11261131
@ <p class='skinInput'>
11271132
@ <input type='hidden' name='sk' value='%d(iSkin)'>
11281133
--- src/skins.c
+++ src/skins.c
@@ -281,10 +281,13 @@
281 ** Return an identifier that is (probably) different for every skin
282 ** but that is (probably) the same if the skin is unchanged. This
283 ** identifier can be attached to resource URLs to force reloading when
284 ** the resources change but allow the resources to be read from cache
285 ** as long as they are unchanged.
 
 
 
286 */
287 unsigned int skin_id(const char *zResource){
288 unsigned int h = 0;
289 if( zAltSkinDir ){
290 h = skin_hash(0, zAltSkinDir);
@@ -293,11 +296,13 @@
293 }else{
294 char *zMTime = db_get_mtime(zResource, 0, 0);
295 h = skin_hash(0, zMTime);
296 fossil_free(zMTime);
297 }
298 h = skin_hash(h, MANIFEST_UUID);
 
 
299 return h;
300 }
301
302 /*
303 ** For a skin named zSkinName, compute the name of the CONFIG table
@@ -1117,11 +1122,11 @@
1117 if( !g.perm.Admin ){
1118 @ <p>Only administrators are allowed to publish draft skins. Contact
1119 @ an administrator to get this "draft%d(iSkin)" skin published.</p>
1120 }else{
1121 @ <p>When the draft%d(iSkin) skin is ready for production use,
1122 @ make it the default scan by clicking the acknowledgements and
1123 @ pressing the button below:</p>
1124 @
1125 @ <form method='POST' action='%R/setup_skin#step7'>
1126 @ <p class='skinInput'>
1127 @ <input type='hidden' name='sk' value='%d(iSkin)'>
1128
--- src/skins.c
+++ src/skins.c
@@ -281,10 +281,13 @@
281 ** Return an identifier that is (probably) different for every skin
282 ** but that is (probably) the same if the skin is unchanged. This
283 ** identifier can be attached to resource URLs to force reloading when
284 ** the resources change but allow the resources to be read from cache
285 ** as long as they are unchanged.
286 **
287 ** The zResource argument is the name of a CONFIG setting that
288 ** defines the resource. Examples: "css", "logo-image".
289 */
290 unsigned int skin_id(const char *zResource){
291 unsigned int h = 0;
292 if( zAltSkinDir ){
293 h = skin_hash(0, zAltSkinDir);
@@ -293,11 +296,13 @@
296 }else{
297 char *zMTime = db_get_mtime(zResource, 0, 0);
298 h = skin_hash(0, zMTime);
299 fossil_free(zMTime);
300 }
301
302 /* Change the ID every time Fossil is recompiled */
303 h = skin_hash(h, fossil_exe_id());
304 return h;
305 }
306
307 /*
308 ** For a skin named zSkinName, compute the name of the CONFIG table
@@ -1117,11 +1122,11 @@
1122 if( !g.perm.Admin ){
1123 @ <p>Only administrators are allowed to publish draft skins. Contact
1124 @ an administrator to get this "draft%d(iSkin)" skin published.</p>
1125 }else{
1126 @ <p>When the draft%d(iSkin) skin is ready for production use,
1127 @ make it the default skin by clicking the acknowledgements and
1128 @ pressing the button below:</p>
1129 @
1130 @ <form method='POST' action='%R/setup_skin#step7'>
1131 @ <p class='skinInput'>
1132 @ <input type='hidden' name='sk' value='%d(iSkin)'>
1133
--- src/sqlcmd.c
+++ src/sqlcmd.c
@@ -164,10 +164,11 @@
164164
static int sqlcmd_autoinit(
165165
sqlite3 *db,
166166
const char **pzErrMsg,
167167
const void *notUsed
168168
){
169
+ int mTrace = SQLITE_TRACE_CLOSE;
169170
add_content_sql_commands(db);
170171
db_add_aux_functions(db);
171172
re_add_sql_func(db);
172173
search_sql_setup(db);
173174
foci_register(db);
@@ -186,10 +187,14 @@
186187
char *zSql = sqlite3_mprintf("ATTACH %Q AS 'configdb' KEY ''",
187188
g.zConfigDbName);
188189
sqlite3_exec(db, zSql, 0, 0, 0);
189190
sqlite3_free(zSql);
190191
}
192
+ /* Arrange to trace close operations so that static prepared statements
193
+ ** will get cleaned up when the shell closes the database connection */
194
+ if( g.fSqlTrace ) mTrace |= SQLITE_TRACE_PROFILE;
195
+ sqlite3_trace_v2(db, mTrace, db_sql_trace, 0);
191196
return SQLITE_OK;
192197
}
193198
194199
/*
195200
** atexit() handler that cleans up global state modified by this module.
196201
--- src/sqlcmd.c
+++ src/sqlcmd.c
@@ -164,10 +164,11 @@
164 static int sqlcmd_autoinit(
165 sqlite3 *db,
166 const char **pzErrMsg,
167 const void *notUsed
168 ){
 
169 add_content_sql_commands(db);
170 db_add_aux_functions(db);
171 re_add_sql_func(db);
172 search_sql_setup(db);
173 foci_register(db);
@@ -186,10 +187,14 @@
186 char *zSql = sqlite3_mprintf("ATTACH %Q AS 'configdb' KEY ''",
187 g.zConfigDbName);
188 sqlite3_exec(db, zSql, 0, 0, 0);
189 sqlite3_free(zSql);
190 }
 
 
 
 
191 return SQLITE_OK;
192 }
193
194 /*
195 ** atexit() handler that cleans up global state modified by this module.
196
--- src/sqlcmd.c
+++ src/sqlcmd.c
@@ -164,10 +164,11 @@
164 static int sqlcmd_autoinit(
165 sqlite3 *db,
166 const char **pzErrMsg,
167 const void *notUsed
168 ){
169 int mTrace = SQLITE_TRACE_CLOSE;
170 add_content_sql_commands(db);
171 db_add_aux_functions(db);
172 re_add_sql_func(db);
173 search_sql_setup(db);
174 foci_register(db);
@@ -186,10 +187,14 @@
187 char *zSql = sqlite3_mprintf("ATTACH %Q AS 'configdb' KEY ''",
188 g.zConfigDbName);
189 sqlite3_exec(db, zSql, 0, 0, 0);
190 sqlite3_free(zSql);
191 }
192 /* Arrange to trace close operations so that static prepared statements
193 ** will get cleaned up when the shell closes the database connection */
194 if( g.fSqlTrace ) mTrace |= SQLITE_TRACE_PROFILE;
195 sqlite3_trace_v2(db, mTrace, db_sql_trace, 0);
196 return SQLITE_OK;
197 }
198
199 /*
200 ** atexit() handler that cleans up global state modified by this module.
201
+299 -143
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1,8 +1,8 @@
11
/******************************************************************************
22
** This file is an amalgamation of many separate C source files from SQLite
3
-** version 3.32.0. By combining all the individual C code files into this
3
+** version 3.32.1. By combining all the individual C code files into this
44
** single large file, the entire code can be compiled as a single translation
55
** unit. This allows many compilers to do optimizations that would not be
66
** possible if the files were compiled separately. Performance improvements
77
** of 5% or more are commonly seen when SQLite is compiled as a single
88
** translation unit.
@@ -1160,13 +1160,13 @@
11601160
**
11611161
** See also: [sqlite3_libversion()],
11621162
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
11631163
** [sqlite_version()] and [sqlite_source_id()].
11641164
*/
1165
-#define SQLITE_VERSION "3.32.0"
1166
-#define SQLITE_VERSION_NUMBER 3032000
1167
-#define SQLITE_SOURCE_ID "2020-05-08 19:02:21 3a16c0ce4d8851f79f670d94786032c8007619154ece44647dc9cc5b1f9654ff"
1165
+#define SQLITE_VERSION "3.32.1"
1166
+#define SQLITE_VERSION_NUMBER 3032001
1167
+#define SQLITE_SOURCE_ID "2020-05-25 16:19:56 0c1fcf4711a2e66c813aed38cf41cd3e2123ee8eb6db98118086764c4ba83350"
11681168
11691169
/*
11701170
** CAPI3REF: Run-Time Library Version Numbers
11711171
** KEYWORDS: sqlite3_version sqlite3_sourceid
11721172
**
@@ -6532,11 +6532,11 @@
65326532
** when first called if N is less than or equal to zero or if a memory
65336533
** allocate error occurs.
65346534
**
65356535
** ^(The amount of space allocated by sqlite3_aggregate_context(C,N) is
65366536
** determined by the N parameter on first successful call. Changing the
6537
-** value of N in any subsequents call to sqlite3_aggregate_context() within
6537
+** value of N in any subsequent call to sqlite3_aggregate_context() within
65386538
** the same aggregate function instance will not resize the memory
65396539
** allocation.)^ Within the xFinal callback, it is customary to set
65406540
** N=0 in calls to sqlite3_aggregate_context(C,N) so that no
65416541
** pointless memory allocations occur.
65426542
**
@@ -17119,11 +17119,11 @@
1711917119
#define SQLITE_FUNC_EPHEM 0x0010 /* Ephemeral. Delete with VDBE */
1712017120
#define SQLITE_FUNC_NEEDCOLL 0x0020 /* sqlite3GetFuncCollSeq() might be called*/
1712117121
#define SQLITE_FUNC_LENGTH 0x0040 /* Built-in length() function */
1712217122
#define SQLITE_FUNC_TYPEOF 0x0080 /* Built-in typeof() function */
1712317123
#define SQLITE_FUNC_COUNT 0x0100 /* Built-in count(*) aggregate */
17124
-#define SQLITE_FUNC_COALESCE 0x0200 /* Built-in coalesce() or ifnull() */
17124
+/* 0x0200 -- available for reuse */
1712517125
#define SQLITE_FUNC_UNLIKELY 0x0400 /* Built-in unlikely() function */
1712617126
#define SQLITE_FUNC_CONSTANT 0x0800 /* Constant inputs give a constant output */
1712717127
#define SQLITE_FUNC_MINMAX 0x1000 /* True for min() and max() aggregates */
1712817128
#define SQLITE_FUNC_SLOCHNG 0x2000 /* "Slow Change". Value constant during a
1712917129
** single query - might change over time */
@@ -17140,10 +17140,11 @@
1714017140
#define INLINEFUNC_coalesce 0
1714117141
#define INLINEFUNC_implies_nonnull_row 1
1714217142
#define INLINEFUNC_expr_implies_expr 2
1714317143
#define INLINEFUNC_expr_compare 3
1714417144
#define INLINEFUNC_affinity 4
17145
+#define INLINEFUNC_iif 5
1714517146
#define INLINEFUNC_unlikely 99 /* Default case */
1714617147
1714717148
/*
1714817149
** The following three macros, FUNCTION(), LIKEFUNC() and AGGREGATE() are
1714917150
** used to create the initializers for the FuncDef structures.
@@ -17840,11 +17841,11 @@
1784017841
/*
1784117842
** An instance of this structure contains information needed to generate
1784217843
** code for a SELECT that contains aggregate functions.
1784317844
**
1784417845
** If Expr.op==TK_AGG_COLUMN or TK_AGG_FUNCTION then Expr.pAggInfo is a
17845
-** pointer to this structure. The Expr.iColumn field is the index in
17846
+** pointer to this structure. The Expr.iAgg field is the index in
1784617847
** AggInfo.aCol[] or AggInfo.aFunc[] of information needed to generate
1784717848
** code for that node.
1784817849
**
1784917850
** AggInfo.pGroupBy and AggInfo.aFunc.pExpr point to fields within the
1785017851
** original Select structure that describes the SELECT statement. These
@@ -19079,10 +19080,13 @@
1907919080
SQLITE_PRIVATE int sqlite3WalkSelectExpr(Walker*, Select*);
1908019081
SQLITE_PRIVATE int sqlite3WalkSelectFrom(Walker*, Select*);
1908119082
SQLITE_PRIVATE int sqlite3ExprWalkNoop(Walker*, Expr*);
1908219083
SQLITE_PRIVATE int sqlite3SelectWalkNoop(Walker*, Select*);
1908319084
SQLITE_PRIVATE int sqlite3SelectWalkFail(Walker*, Select*);
19085
+SQLITE_PRIVATE int sqlite3WalkerDepthIncrease(Walker*,Select*);
19086
+SQLITE_PRIVATE void sqlite3WalkerDepthDecrease(Walker*,Select*);
19087
+
1908419088
#ifdef SQLITE_DEBUG
1908519089
SQLITE_PRIVATE void sqlite3SelectWalkAssert2(Walker*, Select*);
1908619090
#endif
1908719091
1908819092
/*
@@ -20064,12 +20068,14 @@
2006420068
# define sqlite3VtabInSync(db) ((db)->nVTrans>0 && (db)->aVTrans==0)
2006520069
#endif
2006620070
SQLITE_PRIVATE int sqlite3ReadOnlyShadowTables(sqlite3 *db);
2006720071
#ifndef SQLITE_OMIT_VIRTUALTABLE
2006820072
SQLITE_PRIVATE int sqlite3ShadowTableName(sqlite3 *db, const char *zName);
20073
+SQLITE_PRIVATE int sqlite3IsShadowTableOf(sqlite3*,Table*,const char*);
2006920074
#else
2007020075
# define sqlite3ShadowTableName(A,B) 0
20076
+# define sqlite3IsShadowTableOf(A,B,C) 0
2007120077
#endif
2007220078
SQLITE_PRIVATE int sqlite3VtabEponymousTableInit(Parse*,Module*);
2007320079
SQLITE_PRIVATE void sqlite3VtabEponymousTableClear(sqlite3*,Module*);
2007420080
SQLITE_PRIVATE void sqlite3VtabMakeWritable(Parse*,Table*);
2007520081
SQLITE_PRIVATE void sqlite3VtabBeginParse(Parse*, Token*, Token*, Token*, int);
@@ -27924,11 +27930,11 @@
2792427930
}
2792527931
}else{
2792627932
assert( sqlite3MemdebugHasType(p, (MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) );
2792727933
assert( sqlite3MemdebugNoType(p, (u8)~(MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) );
2792827934
sqlite3MemdebugSetType(p, MEMTYPE_HEAP);
27929
- pNew = sqlite3_realloc64(p, n);
27935
+ pNew = sqlite3Realloc(p, n);
2793027936
if( !pNew ){
2793127937
sqlite3OomFault(db);
2793227938
}
2793327939
sqlite3MemdebugSetType(pNew,
2793427940
(db->lookaside.bDisable==0 ? MEMTYPE_LOOKASIDE : MEMTYPE_HEAP));
@@ -28271,10 +28277,17 @@
2827128277
#ifndef SQLITE_PRINT_BUF_SIZE
2827228278
# define SQLITE_PRINT_BUF_SIZE 70
2827328279
#endif
2827428280
#define etBUFSIZE SQLITE_PRINT_BUF_SIZE /* Size of the output buffer */
2827528281
28282
+/*
28283
+** Hard limit on the precision of floating-point conversions.
28284
+*/
28285
+#ifndef SQLITE_PRINTF_PRECISION_LIMIT
28286
+# define SQLITE_FP_PRECISION_LIMIT 100000000
28287
+#endif
28288
+
2827628289
/*
2827728290
** Render a string given by "fmt" into the StrAccum object.
2827828291
*/
2827928292
SQLITE_API void sqlite3_str_vappendf(
2828028293
sqlite3_str *pAccum, /* Accumulate results here */
@@ -28471,10 +28484,12 @@
2847128484
** precision The specified precision. The default
2847228485
** is -1.
2847328486
** xtype The class of the conversion.
2847428487
** infop Pointer to the appropriate info struct.
2847528488
*/
28489
+ assert( width>=0 );
28490
+ assert( precision>=(-1) );
2847628491
switch( xtype ){
2847728492
case etPOINTER:
2847828493
flag_long = sizeof(char*)==sizeof(i64) ? 2 :
2847928494
sizeof(char*)==sizeof(long int) ? 1 : 0;
2848028495
/* Fall through into the next case */
@@ -28592,10 +28607,15 @@
2859228607
}
2859328608
#ifdef SQLITE_OMIT_FLOATING_POINT
2859428609
length = 0;
2859528610
#else
2859628611
if( precision<0 ) precision = 6; /* Set default precision */
28612
+#ifdef SQLITE_FP_PRECISION_LIMIT
28613
+ if( precision>SQLITE_FP_PRECISION_LIMIT ){
28614
+ precision = SQLITE_FP_PRECISION_LIMIT;
28615
+ }
28616
+#endif
2859728617
if( realvalue<0.0 ){
2859828618
realvalue = -realvalue;
2859928619
prefix = '-';
2860028620
}else{
2860128621
prefix = flag_prefix;
@@ -28874,11 +28894,11 @@
2887428894
}else{
2887528895
escarg = va_arg(ap,char*);
2887628896
}
2887728897
isnull = escarg==0;
2887828898
if( isnull ) escarg = (xtype==etSQLESCAPE2 ? "NULL" : "(NULL)");
28879
- /* For %q, %Q, and %w, the precision is the number of byte (or
28899
+ /* For %q, %Q, and %w, the precision is the number of bytes (or
2888028900
** characters if the ! flags is present) to use from the input.
2888128901
** Because of the extra quoting characters inserted, the number
2888228902
** of output characters may be larger than the precision.
2888328903
*/
2888428904
k = precision;
@@ -29001,11 +29021,11 @@
2900129021
p->nAlloc = (int)szNew;
2900229022
}
2900329023
if( p->db ){
2900429024
zNew = sqlite3DbRealloc(p->db, zOld, p->nAlloc);
2900529025
}else{
29006
- zNew = sqlite3_realloc64(zOld, p->nAlloc);
29026
+ zNew = sqlite3Realloc(zOld, p->nAlloc);
2900729027
}
2900829028
if( zNew ){
2900929029
assert( p->zText!=0 || p->nChar==0 );
2901029030
if( !isMalloced(p) && p->nChar>0 ) memcpy(zNew, p->zText, p->nChar);
2901129031
p->zText = zNew;
@@ -29343,11 +29363,11 @@
2934329363
** and segfaults if you give it a long long int.
2934429364
*/
2934529365
SQLITE_PRIVATE void sqlite3DebugPrintf(const char *zFormat, ...){
2934629366
va_list ap;
2934729367
StrAccum acc;
29348
- char zBuf[500];
29368
+ char zBuf[SQLITE_PRINT_BUF_SIZE*10];
2934929369
sqlite3StrAccumInit(&acc, 0, zBuf, sizeof(zBuf), 0);
2935029370
va_start(ap,zFormat);
2935129371
sqlite3_str_vappendf(&acc, zFormat, ap);
2935229372
va_end(ap);
2935329373
sqlite3StrAccumFinish(&acc);
@@ -29959,12 +29979,13 @@
2995929979
#else
2996029980
pWin = 0;
2996129981
#endif
2996229982
}
2996329983
if( pExpr->op==TK_AGG_FUNCTION ){
29964
- sqlite3TreeViewLine(pView, "AGG_FUNCTION%d %Q%s",
29965
- pExpr->op2, pExpr->u.zToken, zFlgs);
29984
+ sqlite3TreeViewLine(pView, "AGG_FUNCTION%d %Q%s iAgg=%d agg=%p",
29985
+ pExpr->op2, pExpr->u.zToken, zFlgs,
29986
+ pExpr->iAgg, pExpr->pAggInfo);
2996629987
}else if( pExpr->op2!=0 ){
2996729988
const char *zOp2;
2996829989
char zBuf[8];
2996929990
sqlite3_snprintf(sizeof(zBuf),zBuf,"0x%02x",pExpr->op2);
2997029991
zOp2 = zBuf;
@@ -30853,10 +30874,11 @@
3085330874
/* UTF-16 Little-endian -> UTF-8 */
3085430875
while( zIn<zTerm ){
3085530876
c = *(zIn++);
3085630877
c += (*(zIn++))<<8;
3085730878
if( c>=0xd800 && c<0xe000 ){
30879
+#ifdef SQLITE_REPLACE_INVALID_UTF
3085830880
if( c>=0xdc00 || zIn>=zTerm ){
3085930881
c = 0xfffd;
3086030882
}else{
3086130883
int c2 = *(zIn++);
3086230884
c2 += (*(zIn++))<<8;
@@ -30865,19 +30887,27 @@
3086530887
c = 0xfffd;
3086630888
}else{
3086730889
c = ((c&0x3ff)<<10) + (c2&0x3ff) + 0x10000;
3086830890
}
3086930891
}
30892
+#else
30893
+ if( zIn<zTerm ){
30894
+ int c2 = (*zIn++);
30895
+ c2 += ((*zIn++)<<8);
30896
+ c = (c2&0x03FF) + ((c&0x003F)<<10) + (((c&0x03C0)+0x0040)<<10);
30897
+ }
30898
+#endif
3087030899
}
3087130900
WRITE_UTF8(z, c);
3087230901
}
3087330902
}else{
3087430903
/* UTF-16 Big-endian -> UTF-8 */
3087530904
while( zIn<zTerm ){
3087630905
c = (*(zIn++))<<8;
3087730906
c += *(zIn++);
3087830907
if( c>=0xd800 && c<0xe000 ){
30908
+#ifdef SQLITE_REPLACE_INVALID_UTF
3087930909
if( c>=0xdc00 || zIn>=zTerm ){
3088030910
c = 0xfffd;
3088130911
}else{
3088230912
int c2 = (*(zIn++))<<8;
3088330913
c2 += *(zIn++);
@@ -30886,10 +30916,17 @@
3088630916
c = 0xfffd;
3088730917
}else{
3088830918
c = ((c&0x3ff)<<10) + (c2&0x3ff) + 0x10000;
3088930919
}
3089030920
}
30921
+#else
30922
+ if( zIn<zTerm ){
30923
+ int c2 = ((*zIn++)<<8);
30924
+ c2 += (*zIn++);
30925
+ c = (c2&0x03FF) + ((c&0x003F)<<10) + (((c&0x03C0)+0x0040)<<10);
30926
+ }
30927
+#endif
3089130928
}
3089230929
WRITE_UTF8(z, c);
3089330930
}
3089430931
}
3089530932
pMem->n = (int)(z - zOut);
@@ -45048,10 +45085,11 @@
4504845085
}
4504945086
4505045087
/* Forward references to VFS helper methods used for temporary files */
4505145088
static int winGetTempname(sqlite3_vfs *, char **);
4505245089
static int winIsDir(const void *);
45090
+static BOOL winIsLongPathPrefix(const char *);
4505345091
static BOOL winIsDriveLetterAndColon(const char *);
4505445092
4505545093
/*
4505645094
** Control and query of the open file handle.
4505745095
*/
@@ -46817,11 +46855,13 @@
4681746855
pFile->pVfs = pVfs;
4681846856
pFile->h = h;
4681946857
if( isReadonly ){
4682046858
pFile->ctrlFlags |= WINFILE_RDONLY;
4682146859
}
46822
- if( sqlite3_uri_boolean(zName, "psow", SQLITE_POWERSAFE_OVERWRITE) ){
46860
+ if( (flags & SQLITE_OPEN_MAIN_DB)
46861
+ && sqlite3_uri_boolean(zName, "psow", SQLITE_POWERSAFE_OVERWRITE)
46862
+ ){
4682346863
pFile->ctrlFlags |= WINFILE_PSOW;
4682446864
}
4682546865
pFile->lastErrno = NO_ERROR;
4682646866
pFile->zPath = zName;
4682746867
#if SQLITE_MAX_MMAP_SIZE>0
@@ -47026,10 +47066,21 @@
4702647066
*pResOut = rc;
4702747067
OSTRACE(("ACCESS name=%s, pResOut=%p, *pResOut=%d, rc=SQLITE_OK\n",
4702847068
zFilename, pResOut, *pResOut));
4702947069
return SQLITE_OK;
4703047070
}
47071
+
47072
+/*
47073
+** Returns non-zero if the specified path name starts with the "long path"
47074
+** prefix.
47075
+*/
47076
+static BOOL winIsLongPathPrefix(
47077
+ const char *zPathname
47078
+){
47079
+ return ( zPathname[0]=='\\' && zPathname[1]=='\\'
47080
+ && zPathname[2]=='?' && zPathname[3]=='\\' );
47081
+}
4703147082
4703247083
/*
4703347084
** Returns non-zero if the specified path name starts with a drive letter
4703447085
** followed by a colon character.
4703547086
*/
@@ -47091,14 +47142,15 @@
4709147142
DWORD nByte;
4709247143
void *zConverted;
4709347144
char *zOut;
4709447145
#endif
4709547146
47096
- /* If this path name begins with "/X:", where "X" is any alphabetic
47097
- ** character, discard the initial "/" from the pathname.
47147
+ /* If this path name begins with "/X:" or "\\?\", where "X" is any
47148
+ ** alphabetic character, discard the initial "/" from the pathname.
4709847149
*/
47099
- if( zRelative[0]=='/' && winIsDriveLetterAndColon(zRelative+1) ){
47150
+ if( zRelative[0]=='/' && (winIsDriveLetterAndColon(zRelative+1)
47151
+ || winIsLongPathPrefix(zRelative+1)) ){
4710047152
zRelative++;
4710147153
}
4710247154
4710347155
#if defined(__CYGWIN__)
4710447156
SimulateIOError( return SQLITE_ERROR );
@@ -47850,11 +47902,11 @@
4785047902
if( newSz>p->szMax ){
4785147903
return SQLITE_FULL;
4785247904
}
4785347905
newSz *= 2;
4785447906
if( newSz>p->szMax ) newSz = p->szMax;
47855
- pNew = sqlite3_realloc64(p->aData, newSz);
47907
+ pNew = sqlite3Realloc(p->aData, newSz);
4785647908
if( pNew==0 ) return SQLITE_NOMEM;
4785747909
p->aData = pNew;
4785847910
p->szAlloc = newSz;
4785947911
return SQLITE_OK;
4786047912
}
@@ -48297,14 +48349,15 @@
4829748349
*/
4829848350
SQLITE_PRIVATE int sqlite3MemdbInit(void){
4829948351
sqlite3_vfs *pLower = sqlite3_vfs_find(0);
4830048352
int sz = pLower->szOsFile;
4830148353
memdb_vfs.pAppData = pLower;
48302
- /* In all known configurations of SQLite, the size of a default
48303
- ** sqlite3_file is greater than the size of a memdb sqlite3_file.
48304
- ** Should that ever change, remove the following NEVER() */
48305
- if( NEVER(sz<sizeof(MemFile)) ) sz = sizeof(MemFile);
48354
+ /* The following conditional can only be true when compiled for
48355
+ ** Windows x86 and SQLITE_MAX_MMAP_SIZE=0. We always leave
48356
+ ** it in, to be safe, but it is marked as NO_TEST since there
48357
+ ** is no way to reach it under most builds. */
48358
+ if( sz<sizeof(MemFile) ) sz = sizeof(MemFile); /*NO_TEST*/
4830648359
memdb_vfs.szOsFile = sz;
4830748360
return sqlite3_vfs_register(&memdb_vfs, 0);
4830848361
}
4830948362
#endif /* SQLITE_ENABLE_DESERIALIZE */
4831048363
@@ -59820,11 +59873,11 @@
5982059873
5982159874
/* Enlarge the pWal->apWiData[] array if required */
5982259875
if( pWal->nWiData<=iPage ){
5982359876
sqlite3_int64 nByte = sizeof(u32*)*(iPage+1);
5982459877
volatile u32 **apNew;
59825
- apNew = (volatile u32 **)sqlite3_realloc64((void *)pWal->apWiData, nByte);
59878
+ apNew = (volatile u32 **)sqlite3Realloc((void *)pWal->apWiData, nByte);
5982659879
if( !apNew ){
5982759880
*ppPage = 0;
5982859881
return SQLITE_NOMEM_BKPT;
5982959882
}
5983059883
memset((void*)&apNew[pWal->nWiData], 0,
@@ -59941,29 +59994,47 @@
5994159994
5994259995
aOut[0] = s1;
5994359996
aOut[1] = s2;
5994459997
}
5994559998
59999
+/*
60000
+** If there is the possibility of concurrent access to the SHM file
60001
+** from multiple threads and/or processes, then do a memory barrier.
60002
+*/
5994660003
static void walShmBarrier(Wal *pWal){
5994760004
if( pWal->exclusiveMode!=WAL_HEAPMEMORY_MODE ){
5994860005
sqlite3OsShmBarrier(pWal->pDbFd);
5994960006
}
5995060007
}
5995160008
60009
+/*
60010
+** Add the SQLITE_NO_TSAN as part of the return-type of a function
60011
+** definition as a hint that the function contains constructs that
60012
+** might give false-positive TSAN warnings.
60013
+**
60014
+** See tag-20200519-1.
60015
+*/
60016
+#if defined(__clang__) && !defined(SQLITE_NO_TSAN)
60017
+# define SQLITE_NO_TSAN __attribute__((no_sanitize_thread))
60018
+#else
60019
+# define SQLITE_NO_TSAN
60020
+#endif
60021
+
5995260022
/*
5995360023
** Write the header information in pWal->hdr into the wal-index.
5995460024
**
5995560025
** The checksum on pWal->hdr is updated before it is written.
5995660026
*/
59957
-static void walIndexWriteHdr(Wal *pWal){
60027
+static SQLITE_NO_TSAN void walIndexWriteHdr(Wal *pWal){
5995860028
volatile WalIndexHdr *aHdr = walIndexHdr(pWal);
5995960029
const int nCksum = offsetof(WalIndexHdr, aCksum);
5996060030
5996160031
assert( pWal->writeLock );
5996260032
pWal->hdr.isInit = 1;
5996360033
pWal->hdr.iVersion = WALINDEX_MAX_VERSION;
5996460034
walChecksumBytes(1, (u8*)&pWal->hdr, nCksum, 0, pWal->hdr.aCksum);
60035
+ /* Possible TSAN false-positive. See tag-20200519-1 */
5996560036
memcpy((void*)&aHdr[1], (const void*)&pWal->hdr, sizeof(WalIndexHdr));
5996660037
walShmBarrier(pWal);
5996760038
memcpy((void*)&aHdr[0], (const void*)&pWal->hdr, sizeof(WalIndexHdr));
5996860039
}
5996960040
@@ -61074,11 +61145,11 @@
6107461145
pWal->nCkpt++;
6107561146
pWal->hdr.mxFrame = 0;
6107661147
sqlite3Put4byte((u8*)&aSalt[0], 1 + sqlite3Get4byte((u8*)&aSalt[0]));
6107761148
memcpy(&pWal->hdr.aSalt[1], &salt1, 4);
6107861149
walIndexWriteHdr(pWal);
61079
- pInfo->nBackfill = 0;
61150
+ AtomicStore(&pInfo->nBackfill, 0);
6108061151
pInfo->nBackfillAttempted = 0;
6108161152
pInfo->aReadMark[1] = 0;
6108261153
for(i=2; i<WAL_NREADER; i++) pInfo->aReadMark[i] = READMARK_NOT_USED;
6108361154
assert( pInfo->aReadMark[0]==0 );
6108461155
}
@@ -61149,36 +61220,17 @@
6114961220
** cannot be backfilled from the WAL.
6115061221
*/
6115161222
mxSafeFrame = pWal->hdr.mxFrame;
6115261223
mxPage = pWal->hdr.nPage;
6115361224
for(i=1; i<WAL_NREADER; i++){
61154
- /* Thread-sanitizer reports that the following is an unsafe read,
61155
- ** as some other thread may be in the process of updating the value
61156
- ** of the aReadMark[] slot. The assumption here is that if that is
61157
- ** happening, the other client may only be increasing the value,
61158
- ** not decreasing it. So assuming either that either the "old" or
61159
- ** "new" version of the value is read, and not some arbitrary value
61160
- ** that would never be written by a real client, things are still
61161
- ** safe.
61162
- **
61163
- ** Astute readers have pointed out that the assumption stated in the
61164
- ** last sentence of the previous paragraph is not guaranteed to be
61165
- ** true for all conforming systems. However, the assumption is true
61166
- ** for all compilers and architectures in common use today (circa
61167
- ** 2019-11-27) and the alternatives are both slow and complex, and
61168
- ** so we will continue to go with the current design for now. If this
61169
- ** bothers you, or if you really are running on a system where aligned
61170
- ** 32-bit reads and writes are not atomic, then you can simply avoid
61171
- ** the use of WAL mode, or only use WAL mode together with
61172
- ** PRAGMA locking_mode=EXCLUSIVE and all will be well.
61173
- */
61174
- u32 y = pInfo->aReadMark[i];
61225
+ u32 y = AtomicLoad(pInfo->aReadMark+i);
6117561226
if( mxSafeFrame>y ){
6117661227
assert( y<=pWal->hdr.mxFrame );
6117761228
rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_READ_LOCK(i), 1);
6117861229
if( rc==SQLITE_OK ){
61179
- pInfo->aReadMark[i] = (i==1 ? mxSafeFrame : READMARK_NOT_USED);
61230
+ u32 iMark = (i==1 ? mxSafeFrame : READMARK_NOT_USED);
61231
+ AtomicStore(pInfo->aReadMark+i, iMark);
6118061232
walUnlockExclusive(pWal, WAL_READ_LOCK(i), 1);
6118161233
}else if( rc==SQLITE_BUSY ){
6118261234
mxSafeFrame = y;
6118361235
xBusy = 0;
6118461236
}else{
@@ -61192,11 +61244,11 @@
6119261244
rc = walIteratorInit(pWal, pInfo->nBackfill, &pIter);
6119361245
assert( rc==SQLITE_OK || pIter==0 );
6119461246
}
6119561247
6119661248
if( pIter
61197
- && (rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_READ_LOCK(0),1))==SQLITE_OK
61249
+ && (rc = walBusyLock(pWal,xBusy,pBusyArg,WAL_READ_LOCK(0),1))==SQLITE_OK
6119861250
){
6119961251
u32 nBackfill = pInfo->nBackfill;
6120061252
6120161253
pInfo->nBackfillAttempted = mxSafeFrame;
6120261254
@@ -61248,11 +61300,11 @@
6124861300
if( rc==SQLITE_OK ){
6124961301
rc = sqlite3OsSync(pWal->pDbFd, CKPT_SYNC_FLAGS(sync_flags));
6125061302
}
6125161303
}
6125261304
if( rc==SQLITE_OK ){
61253
- pInfo->nBackfill = mxSafeFrame;
61305
+ AtomicStore(&pInfo->nBackfill, mxSafeFrame);
6125461306
}
6125561307
}
6125661308
6125761309
/* Release the reader lock held while backfilling */
6125861310
walUnlockExclusive(pWal, WAL_READ_LOCK(0), 1);
@@ -61407,11 +61459,11 @@
6140761459
** and *pChanged is set to 1.
6140861460
**
6140961461
** If the checksum cannot be verified return non-zero. If the header
6141061462
** is read successfully and the checksum verified, return zero.
6141161463
*/
61412
-static int walIndexTryHdr(Wal *pWal, int *pChanged){
61464
+static SQLITE_NO_TSAN int walIndexTryHdr(Wal *pWal, int *pChanged){
6141361465
u32 aCksum[2]; /* Checksum on the header content */
6141461466
WalIndexHdr h1, h2; /* Two copies of the header content */
6141561467
WalIndexHdr volatile *aHdr; /* Header in shared memory */
6141661468
6141761469
/* The first page of the wal-index must be mapped at this point. */
@@ -61420,17 +61472,23 @@
6142061472
/* Read the header. This might happen concurrently with a write to the
6142161473
** same area of shared memory on a different CPU in a SMP,
6142261474
** meaning it is possible that an inconsistent snapshot is read
6142361475
** from the file. If this happens, return non-zero.
6142461476
**
61477
+ ** tag-20200519-1:
6142561478
** There are two copies of the header at the beginning of the wal-index.
6142661479
** When reading, read [0] first then [1]. Writes are in the reverse order.
6142761480
** Memory barriers are used to prevent the compiler or the hardware from
61428
- ** reordering the reads and writes.
61481
+ ** reordering the reads and writes. TSAN and similar tools can sometimes
61482
+ ** give false-positive warnings about these accesses because the tools do not
61483
+ ** account for the double-read and the memory barrier. The use of mutexes
61484
+ ** here would be problematic as the memory being accessed is potentially
61485
+ ** shared among multiple processes and not all mutex implementions work
61486
+ ** reliably in that environment.
6142961487
*/
6143061488
aHdr = walIndexHdr(pWal);
61431
- memcpy(&h1, (void *)&aHdr[0], sizeof(h1));
61489
+ memcpy(&h1, (void *)&aHdr[0], sizeof(h1)); /* Possible TSAN false-positive */
6143261490
walShmBarrier(pWal);
6143361491
memcpy(&h2, (void *)&aHdr[1], sizeof(h2));
6143461492
6143561493
if( memcmp(&h1, &h2, sizeof(h1))!=0 ){
6143661494
return 1; /* Dirty read */
@@ -61871,11 +61929,11 @@
6187161929
}
6187261930
6187361931
assert( pWal->nWiData>0 );
6187461932
assert( pWal->apWiData[0]!=0 );
6187561933
pInfo = walCkptInfo(pWal);
61876
- if( !useWal && pInfo->nBackfill==pWal->hdr.mxFrame
61934
+ if( !useWal && AtomicLoad(&pInfo->nBackfill)==pWal->hdr.mxFrame
6187761935
#ifdef SQLITE_ENABLE_SNAPSHOT
6187861936
&& (pWal->pSnapshot==0 || pWal->hdr.mxFrame==0)
6187961937
#endif
6188061938
){
6188161939
/* The WAL has been completely backfilled (or it is empty).
@@ -62038,11 +62096,11 @@
6203862096
void *pBuf2 = sqlite3_malloc(szPage);
6203962097
if( pBuf1==0 || pBuf2==0 ){
6204062098
rc = SQLITE_NOMEM;
6204162099
}else{
6204262100
u32 i = pInfo->nBackfillAttempted;
62043
- for(i=pInfo->nBackfillAttempted; i>pInfo->nBackfill; i--){
62101
+ for(i=pInfo->nBackfillAttempted; i>AtomicLoad(&pInfo->nBackfill); i--){
6204462102
WalHashLoc sLoc; /* Hash table location */
6204562103
u32 pgno; /* Page number in db file */
6204662104
i64 iDbOff; /* Offset of db file entry */
6204762105
i64 iWalOff; /* Offset of wal file entry */
6204862106
@@ -62093,16 +62151,18 @@
6209362151
** needs to be flushed.
6209462152
*/
6209562153
SQLITE_PRIVATE int sqlite3WalBeginReadTransaction(Wal *pWal, int *pChanged){
6209662154
int rc; /* Return code */
6209762155
int cnt = 0; /* Number of TryBeginRead attempts */
62156
+#ifdef SQLITE_ENABLE_SNAPSHOT
62157
+ int bChanged = 0;
62158
+ WalIndexHdr *pSnapshot = pWal->pSnapshot;
62159
+#endif
6209862160
6209962161
assert( pWal->ckptLock==0 );
6210062162
6210162163
#ifdef SQLITE_ENABLE_SNAPSHOT
62102
- int bChanged = 0;
62103
- WalIndexHdr *pSnapshot = pWal->pSnapshot;
6210462164
if( pSnapshot ){
6210562165
if( memcmp(pSnapshot, &pWal->hdr, sizeof(WalIndexHdr))!=0 ){
6210662166
bChanged = 1;
6210762167
}
6210862168
@@ -62267,26 +62327,28 @@
6226762327
for(iHash=walFramePage(iLast); iHash>=iMinHash; iHash--){
6226862328
WalHashLoc sLoc; /* Hash table location */
6226962329
int iKey; /* Hash slot index */
6227062330
int nCollide; /* Number of hash collisions remaining */
6227162331
int rc; /* Error code */
62332
+ u32 iH;
6227262333
6227362334
rc = walHashGet(pWal, iHash, &sLoc);
6227462335
if( rc!=SQLITE_OK ){
6227562336
return rc;
6227662337
}
6227762338
nCollide = HASHTABLE_NSLOT;
62278
- for(iKey=walHash(pgno); sLoc.aHash[iKey]; iKey=walNextHash(iKey)){
62279
- u32 iH = sLoc.aHash[iKey];
62339
+ iKey = walHash(pgno);
62340
+ while( (iH = AtomicLoad(&sLoc.aHash[iKey]))!=0 ){
6228062341
u32 iFrame = iH + sLoc.iZero;
6228162342
if( iFrame<=iLast && iFrame>=pWal->minFrame && sLoc.aPgno[iH]==pgno ){
6228262343
assert( iFrame>iRead || CORRUPT_DB );
6228362344
iRead = iFrame;
6228462345
}
6228562346
if( (nCollide--)==0 ){
6228662347
return SQLITE_CORRUPT_BKPT;
6228762348
}
62349
+ iKey = walNextHash(iKey);
6228862350
}
6228962351
if( iRead ) break;
6229062352
}
6229162353
6229262354
#ifdef SQLITE_ENABLE_EXPENSIVE_ASSERT
@@ -79307,10 +79369,11 @@
7930779369
char *zP4;
7930879370
char *zCom;
7930979371
sqlite3 dummyDb;
7931079372
static const char *zFormat1 = "%4d %-13s %4d %4d %4d %-13s %.2X %s\n";
7931179373
if( pOut==0 ) pOut = stdout;
79374
+ sqlite3BeginBenignMalloc();
7931279375
dummyDb.mallocFailed = 1;
7931379376
zP4 = sqlite3VdbeDisplayP4(&dummyDb, pOp);
7931479377
#ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS
7931579378
zCom = sqlite3VdbeDisplayComment(0, pOp, zP4);
7931679379
#else
@@ -79325,10 +79388,11 @@
7932579388
zCom ? zCom : ""
7932679389
);
7932779390
fflush(pOut);
7932879391
sqlite3_free(zP4);
7932979392
sqlite3_free(zCom);
79393
+ sqlite3EndBenignMalloc();
7933079394
}
7933179395
#endif
7933279396
7933379397
/*
7933479398
** Initialize an array of N Mem element.
@@ -84066,11 +84130,11 @@
8406684130
p->db->errCode = SQLITE_OK;
8406784131
8406884132
/* If the bit corresponding to this variable in Vdbe.expmask is set, then
8406984133
** binding a new value to this variable invalidates the current query plan.
8407084134
**
84071
- ** IMPLEMENTATION-OF: R-48440-37595 If the specific value bound to host
84135
+ ** IMPLEMENTATION-OF: R-57496-20354 If the specific value bound to a host
8407284136
** parameter in the WHERE clause might influence the choice of query plan
8407384137
** for a statement, then the statement will be automatically recompiled,
8407484138
** as if there had been a schema change, on the first sqlite3_step() call
8407584139
** following any change to the bindings of that parameter.
8407684140
*/
@@ -96365,12 +96429,12 @@
9636596429
*************************************************************************
9636696430
**
9636796431
** This file implements virtual-tables for examining the bytecode content
9636896432
** of a prepared statement.
9636996433
*/
96370
-#ifdef SQLITE_ENABLE_BYTECODE_VTAB
9637196434
/* #include "sqliteInt.h" */
96435
+#if defined(SQLITE_ENABLE_BYTECODE_VTAB) && !defined(SQLITE_OMIT_VIRTUALTABLE)
9637296436
/* #include "vdbeInt.h" */
9637396437
9637496438
/* An instance of the bytecode() table-valued function.
9637596439
*/
9637696440
typedef struct bytecodevtab bytecodevtab;
@@ -96771,10 +96835,12 @@
9677196835
if( rc==SQLITE_OK ){
9677296836
rc = sqlite3_create_module(db, "tables_used", &bytecodevtabModule, &db);
9677396837
}
9677496838
return rc;
9677596839
}
96840
+#elif defined(SQLITE_ENABLE_BYTECODE_VTAB)
96841
+SQLITE_PRIVATE int sqlite3VdbeBytecodeVtabInit(sqlite3 *db){ return SQLITE_OK; }
9677696842
#endif /* SQLITE_ENABLE_BYTECODE_VTAB */
9677796843
9677896844
/************** End of vdbevtab.c ********************************************/
9677996845
/************** Begin file memjournal.c **************************************/
9678096846
/*
@@ -97416,10 +97482,47 @@
9741697482
}
9741797483
p = p->pPrior;
9741897484
}while( p!=0 );
9741997485
return WRC_Continue;
9742097486
}
97487
+
97488
+/* Increase the walkerDepth when entering a subquery, and
97489
+** descrease when leaving the subquery.
97490
+*/
97491
+SQLITE_PRIVATE int sqlite3WalkerDepthIncrease(Walker *pWalker, Select *pSelect){
97492
+ UNUSED_PARAMETER(pSelect);
97493
+ pWalker->walkerDepth++;
97494
+ return WRC_Continue;
97495
+}
97496
+SQLITE_PRIVATE void sqlite3WalkerDepthDecrease(Walker *pWalker, Select *pSelect){
97497
+ UNUSED_PARAMETER(pSelect);
97498
+ pWalker->walkerDepth--;
97499
+}
97500
+
97501
+
97502
+/*
97503
+** No-op routine for the parse-tree walker.
97504
+**
97505
+** When this routine is the Walker.xExprCallback then expression trees
97506
+** are walked without any actions being taken at each node. Presumably,
97507
+** when this routine is used for Walker.xExprCallback then
97508
+** Walker.xSelectCallback is set to do something useful for every
97509
+** subquery in the parser tree.
97510
+*/
97511
+SQLITE_PRIVATE int sqlite3ExprWalkNoop(Walker *NotUsed, Expr *NotUsed2){
97512
+ UNUSED_PARAMETER2(NotUsed, NotUsed2);
97513
+ return WRC_Continue;
97514
+}
97515
+
97516
+/*
97517
+** No-op routine for the parse-tree walker for SELECT statements.
97518
+** subquery in the parser tree.
97519
+*/
97520
+SQLITE_PRIVATE int sqlite3SelectWalkNoop(Walker *NotUsed, Select *NotUsed2){
97521
+ UNUSED_PARAMETER2(NotUsed, NotUsed2);
97522
+ return WRC_Continue;
97523
+}
9742197524
9742297525
/************** End of walker.c **********************************************/
9742397526
/************** Begin file resolve.c *****************************************/
9742497527
/*
9742597528
** 2008 August 18
@@ -97445,10 +97548,12 @@
9744597548
** This needs to occur when copying a TK_AGG_FUNCTION node from an
9744697549
** outer query into an inner subquery.
9744797550
**
9744897551
** incrAggFunctionDepth(pExpr,n) is the main routine. incrAggDepth(..)
9744997552
** is a helper function - a callback for the tree walker.
97553
+**
97554
+** See also the sqlite3WindowExtraAggFuncDepth() routine in window.c
9745097555
*/
9745197556
static int incrAggDepth(Walker *pWalker, Expr *pExpr){
9745297557
if( pExpr->op==TK_AGG_FUNCTION ) pExpr->op2 += pWalker->u.n;
9745397558
return WRC_Continue;
9745497559
}
@@ -103075,10 +103180,17 @@
103075103180
}
103076103181
setDoNotMergeFlagOnCopy(v);
103077103182
sqlite3VdbeResolveLabel(v, endCoalesce);
103078103183
break;
103079103184
}
103185
+ case INLINEFUNC_iif: {
103186
+ Expr caseExpr;
103187
+ memset(&caseExpr, 0, sizeof(caseExpr));
103188
+ caseExpr.op = TK_CASE;
103189
+ caseExpr.x.pList = pFarg;
103190
+ return sqlite3ExprCodeTarget(pParse, &caseExpr, target);
103191
+ }
103080103192
103081103193
default: {
103082103194
/* The UNLIKELY() function is a no-op. The result is the value
103083103195
** of the first argument.
103084103196
*/
@@ -103179,11 +103291,14 @@
103179103291
op = pExpr->op;
103180103292
}
103181103293
switch( op ){
103182103294
case TK_AGG_COLUMN: {
103183103295
AggInfo *pAggInfo = pExpr->pAggInfo;
103184
- struct AggInfo_col *pCol = &pAggInfo->aCol[pExpr->iAgg];
103296
+ struct AggInfo_col *pCol;
103297
+ assert( pAggInfo!=0 );
103298
+ assert( pExpr->iAgg>=0 && pExpr->iAgg<pAggInfo->nColumn );
103299
+ pCol = &pAggInfo->aCol[pExpr->iAgg];
103185103300
if( !pAggInfo->directMode ){
103186103301
assert( pCol->iMem>0 );
103187103302
return pCol->iMem;
103188103303
}else if( pAggInfo->useSortingIdx ){
103189103304
Table *pTab = pCol->pTab;
@@ -103479,11 +103594,14 @@
103479103594
sqlite3VdbeJumpHere(v, addr);
103480103595
break;
103481103596
}
103482103597
case TK_AGG_FUNCTION: {
103483103598
AggInfo *pInfo = pExpr->pAggInfo;
103484
- if( pInfo==0 ){
103599
+ if( pInfo==0
103600
+ || NEVER(pExpr->iAgg<0)
103601
+ || NEVER(pExpr->iAgg>=pInfo->nFunc)
103602
+ ){
103485103603
assert( !ExprHasProperty(pExpr, EP_IntValue) );
103486103604
sqlite3ErrorMsg(pParse, "misuse of aggregate: %s()", pExpr->u.zToken);
103487103605
}else{
103488103606
return pInfo->aFunc[pExpr->iAgg].iMem;
103489103607
}
@@ -105235,19 +105353,10 @@
105235105353
}
105236105354
}
105237105355
}
105238105356
return WRC_Continue;
105239105357
}
105240
-static int analyzeAggregatesInSelect(Walker *pWalker, Select *pSelect){
105241
- UNUSED_PARAMETER(pSelect);
105242
- pWalker->walkerDepth++;
105243
- return WRC_Continue;
105244
-}
105245
-static void analyzeAggregatesInSelectEnd(Walker *pWalker, Select *pSelect){
105246
- UNUSED_PARAMETER(pSelect);
105247
- pWalker->walkerDepth--;
105248
-}
105249105358
105250105359
/*
105251105360
** Analyze the pExpr expression looking for aggregate functions and
105252105361
** for variables that need to be added to AggInfo object that pNC->pAggInfo
105253105362
** points to. Additional entries are made on the AggInfo object as
@@ -105257,12 +105366,12 @@
105257105366
** analyzed by sqlite3ResolveExprNames().
105258105367
*/
105259105368
SQLITE_PRIVATE void sqlite3ExprAnalyzeAggregates(NameContext *pNC, Expr *pExpr){
105260105369
Walker w;
105261105370
w.xExprCallback = analyzeAggregate;
105262
- w.xSelectCallback = analyzeAggregatesInSelect;
105263
- w.xSelectCallback2 = analyzeAggregatesInSelectEnd;
105371
+ w.xSelectCallback = sqlite3WalkerDepthIncrease;
105372
+ w.xSelectCallback2 = sqlite3WalkerDepthDecrease;
105264105373
w.walkerDepth = 0;
105265105374
w.u.pNC = pNC;
105266105375
w.pParse = 0;
105267105376
assert( pNC->pSrcList!=0 );
105268105377
sqlite3WalkExpr(&w, pExpr);
@@ -105497,11 +105606,14 @@
105497105606
if( !zName ) goto exit_rename_table;
105498105607
105499105608
/* Check that a table or index named 'zName' does not already exist
105500105609
** in database iDb. If so, this is an error.
105501105610
*/
105502
- if( sqlite3FindTable(db, zName, zDb) || sqlite3FindIndex(db, zName, zDb) ){
105611
+ if( sqlite3FindTable(db, zName, zDb)
105612
+ || sqlite3FindIndex(db, zName, zDb)
105613
+ || sqlite3IsShadowTableOf(db, pTab, zName)
105614
+ ){
105503105615
sqlite3ErrorMsg(pParse,
105504105616
"there is already another table or index with this name: %s", zName);
105505105617
goto exit_rename_table;
105506105618
}
105507105619
@@ -110244,26 +110356,43 @@
110244110356
** exists */
110245110357
if( db->auth.authLevel<UAUTH_Admin && sqlite3UserAuthTable(zName)!=0 ){
110246110358
return 0;
110247110359
}
110248110360
#endif
110249
- while(1){
110250
- for(i=OMIT_TEMPDB; i<db->nDb; i++){
110251
- int j = (i<2) ? i^1 : i; /* Search TEMP before MAIN */
110252
- if( zDatabase==0 || sqlite3DbIsNamed(db, j, zDatabase) ){
110253
- assert( sqlite3SchemaMutexHeld(db, j, 0) );
110254
- p = sqlite3HashFind(&db->aDb[j].pSchema->tblHash, zName);
110255
- if( p ) return p;
110256
- }
110257
- }
110258
- /* Not found. If the name we were looking for was temp.sqlite_master
110259
- ** then change the name to sqlite_temp_master and try again. */
110260
- if( sqlite3StrICmp(zName, MASTER_NAME)!=0 ) break;
110261
- if( sqlite3_stricmp(zDatabase, db->aDb[1].zDbSName)!=0 ) break;
110262
- zName = TEMP_MASTER_NAME;
110263
- }
110264
- return 0;
110361
+ if( zDatabase ){
110362
+ for(i=0; i<db->nDb; i++){
110363
+ if( sqlite3StrICmp(zDatabase, db->aDb[i].zDbSName)==0 ) break;
110364
+ }
110365
+ if( i>=db->nDb ){
110366
+ /* No match against the official names. But always match "main"
110367
+ ** to schema 0 as a legacy fallback. */
110368
+ if( sqlite3StrICmp(zDatabase,"main")==0 ){
110369
+ i = 0;
110370
+ }else{
110371
+ return 0;
110372
+ }
110373
+ }
110374
+ p = sqlite3HashFind(&db->aDb[i].pSchema->tblHash, zName);
110375
+ if( p==0 && i==1 && sqlite3StrICmp(zName, MASTER_NAME)==0 ){
110376
+ /* All temp.sqlite_master to be an alias for sqlite_temp_master */
110377
+ p = sqlite3HashFind(&db->aDb[1].pSchema->tblHash, TEMP_MASTER_NAME);
110378
+ }
110379
+ }else{
110380
+ /* Match against TEMP first */
110381
+ p = sqlite3HashFind(&db->aDb[1].pSchema->tblHash, zName);
110382
+ if( p ) return p;
110383
+ /* The main database is second */
110384
+ p = sqlite3HashFind(&db->aDb[0].pSchema->tblHash, zName);
110385
+ if( p ) return p;
110386
+ /* Attached databases are in order of attachment */
110387
+ for(i=2; i<db->nDb; i++){
110388
+ assert( sqlite3SchemaMutexHeld(db, i, 0) );
110389
+ p = sqlite3HashFind(&db->aDb[i].pSchema->tblHash, zName);
110390
+ if( p ) break;
110391
+ }
110392
+ }
110393
+ return p;
110265110394
}
110266110395
110267110396
/*
110268110397
** Locate the in-memory structure that describes a particular database
110269110398
** table given the name of that table and (optionally) the name of the
@@ -112063,10 +112192,32 @@
112063112192
assert( pPk->nColumn==j );
112064112193
assert( pTab->nNVCol<=j );
112065112194
recomputeColumnsNotIndexed(pPk);
112066112195
}
112067112196
112197
+
112198
+#ifndef SQLITE_OMIT_VIRTUALTABLE
112199
+/*
112200
+** Return true if pTab is a virtual table and zName is a shadow table name
112201
+** for that virtual table.
112202
+*/
112203
+SQLITE_PRIVATE int sqlite3IsShadowTableOf(sqlite3 *db, Table *pTab, const char *zName){
112204
+ int nName; /* Length of zName */
112205
+ Module *pMod; /* Module for the virtual table */
112206
+
112207
+ if( !IsVirtual(pTab) ) return 0;
112208
+ nName = sqlite3Strlen30(pTab->zName);
112209
+ if( sqlite3_strnicmp(zName, pTab->zName, nName)!=0 ) return 0;
112210
+ if( zName[nName]!='_' ) return 0;
112211
+ pMod = (Module*)sqlite3HashFind(&db->aModule, pTab->azModuleArg[0]);
112212
+ if( pMod==0 ) return 0;
112213
+ if( pMod->pModule->iVersion<3 ) return 0;
112214
+ if( pMod->pModule->xShadowName==0 ) return 0;
112215
+ return pMod->pModule->xShadowName(zName+nName+1);
112216
+}
112217
+#endif /* ifndef SQLITE_OMIT_VIRTUALTABLE */
112218
+
112068112219
#ifndef SQLITE_OMIT_VIRTUALTABLE
112069112220
/*
112070112221
** Return true if zName is a shadow table name in the current database
112071112222
** connection.
112072112223
**
@@ -112074,26 +112225,21 @@
112074112225
** restored to its original value prior to this routine returning.
112075112226
*/
112076112227
SQLITE_PRIVATE int sqlite3ShadowTableName(sqlite3 *db, const char *zName){
112077112228
char *zTail; /* Pointer to the last "_" in zName */
112078112229
Table *pTab; /* Table that zName is a shadow of */
112079
- Module *pMod; /* Module for the virtual table */
112080
-
112081112230
zTail = strrchr(zName, '_');
112082112231
if( zTail==0 ) return 0;
112083112232
*zTail = 0;
112084112233
pTab = sqlite3FindTable(db, zName, 0);
112085112234
*zTail = '_';
112086112235
if( pTab==0 ) return 0;
112087112236
if( !IsVirtual(pTab) ) return 0;
112088
- pMod = (Module*)sqlite3HashFind(&db->aModule, pTab->azModuleArg[0]);
112089
- if( pMod==0 ) return 0;
112090
- if( pMod->pModule->iVersion<3 ) return 0;
112091
- if( pMod->pModule->xShadowName==0 ) return 0;
112092
- return pMod->pModule->xShadowName(zTail+1);
112237
+ return sqlite3IsShadowTableOf(db, pTab, zName);
112093112238
}
112094112239
#endif /* ifndef SQLITE_OMIT_VIRTUALTABLE */
112240
+
112095112241
112096112242
#ifdef SQLITE_DEBUG
112097112243
/*
112098112244
** Mark all nodes of an expression as EP_Immutable, indicating that
112099112245
** they should not be changed. Expressions attached to a table or
@@ -117780,11 +117926,11 @@
117780117926
if( (cntExpand&(cntExpand-1))==0 ){
117781117927
/* Grow the size of the output buffer only on substitutions
117782117928
** whose index is a power of two: 1, 2, 4, 8, 16, 32, ... */
117783117929
u8 *zOld;
117784117930
zOld = zOut;
117785
- zOut = sqlite3_realloc64(zOut, (int)nOut + (nOut - nStr - 1));
117931
+ zOut = sqlite3Realloc(zOut, (int)nOut + (nOut - nStr - 1));
117786117932
if( zOut==0 ){
117787117933
sqlite3_result_error_nomem(context);
117788117934
sqlite3_free(zOld);
117789117935
return;
117790117936
}
@@ -118477,11 +118623,11 @@
118477118623
FUNCTION(round, 2, 0, 0, roundFunc ),
118478118624
#endif
118479118625
FUNCTION(upper, 1, 0, 0, upperFunc ),
118480118626
FUNCTION(lower, 1, 0, 0, lowerFunc ),
118481118627
FUNCTION(hex, 1, 0, 0, hexFunc ),
118482
- INLINE_FUNC(ifnull, 2, INLINEFUNC_coalesce, SQLITE_FUNC_COALESCE),
118628
+ INLINE_FUNC(ifnull, 2, INLINEFUNC_coalesce, 0 ),
118483118629
VFUNCTION(random, 0, 0, 0, randomFunc ),
118484118630
VFUNCTION(randomblob, 1, 0, 0, randomBlob ),
118485118631
FUNCTION(nullif, 2, 0, 1, nullifFunc ),
118486118632
DFUNCTION(sqlite_version, 0, 0, 0, versionFunc ),
118487118633
DFUNCTION(sqlite_source_id, 0, 0, 0, sourceidFunc ),
@@ -118517,11 +118663,12 @@
118517118663
#ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION
118518118664
FUNCTION(unknown, -1, 0, 0, unknownFunc ),
118519118665
#endif
118520118666
FUNCTION(coalesce, 1, 0, 0, 0 ),
118521118667
FUNCTION(coalesce, 0, 0, 0, 0 ),
118522
- INLINE_FUNC(coalesce, -1, INLINEFUNC_coalesce, SQLITE_FUNC_COALESCE),
118668
+ INLINE_FUNC(coalesce, -1, INLINEFUNC_coalesce, 0 ),
118669
+ INLINE_FUNC(iif, 3, INLINEFUNC_iif, 0 ),
118523118670
};
118524118671
#ifndef SQLITE_OMIT_ALTERTABLE
118525118672
sqlite3AlterFunctions();
118526118673
#endif
118527118674
sqlite3WindowFunctions();
@@ -121942,11 +122089,11 @@
121942122089
}
121943122090
if( bAffinityDone==0 && (pUpIdx==0 || pUpIdx==pIdx) ){
121944122091
sqlite3TableAffinity(v, pTab, regNewData+1);
121945122092
bAffinityDone = 1;
121946122093
}
121947
- VdbeNoopComment((v, "uniqueness check for %s", pIdx->zName));
122094
+ VdbeNoopComment((v, "prep index %s", pIdx->zName));
121948122095
iThisCur = iIdxCur+ix;
121949122096
121950122097
121951122098
/* Skip partial indices for which the WHERE clause is not true */
121952122099
if( pIdx->pPartIdxWhere ){
@@ -133914,33 +134061,10 @@
133914134061
}
133915134062
}
133916134063
return WRC_Continue;
133917134064
}
133918134065
133919
-/*
133920
-** No-op routine for the parse-tree walker.
133921
-**
133922
-** When this routine is the Walker.xExprCallback then expression trees
133923
-** are walked without any actions being taken at each node. Presumably,
133924
-** when this routine is used for Walker.xExprCallback then
133925
-** Walker.xSelectCallback is set to do something useful for every
133926
-** subquery in the parser tree.
133927
-*/
133928
-SQLITE_PRIVATE int sqlite3ExprWalkNoop(Walker *NotUsed, Expr *NotUsed2){
133929
- UNUSED_PARAMETER2(NotUsed, NotUsed2);
133930
- return WRC_Continue;
133931
-}
133932
-
133933
-/*
133934
-** No-op routine for the parse-tree walker for SELECT statements.
133935
-** subquery in the parser tree.
133936
-*/
133937
-SQLITE_PRIVATE int sqlite3SelectWalkNoop(Walker *NotUsed, Select *NotUsed2){
133938
- UNUSED_PARAMETER2(NotUsed, NotUsed2);
133939
- return WRC_Continue;
133940
-}
133941
-
133942134066
#if SQLITE_DEBUG
133943134067
/*
133944134068
** Always assert. This xSelectCallback2 implementation proves that the
133945134069
** xSelectCallback2 is never invoked.
133946134070
*/
@@ -135107,11 +135231,11 @@
135107135231
sAggInfo.mxReg = pParse->nMem;
135108135232
if( db->mallocFailed ) goto select_end;
135109135233
#if SELECTTRACE_ENABLED
135110135234
if( sqlite3SelectTrace & 0x400 ){
135111135235
int ii;
135112
- SELECTTRACE(0x400,pParse,p,("After aggregate analysis:\n"));
135236
+ SELECTTRACE(0x400,pParse,p,("After aggregate analysis %p:\n", &sAggInfo));
135113135237
sqlite3TreeViewSelect(0, p, 0);
135114135238
for(ii=0; ii<sAggInfo.nColumn; ii++){
135115135239
sqlite3DebugPrintf("agg-column[%d] iMem=%d\n",
135116135240
ii, sAggInfo.aCol[ii].iMem);
135117135241
sqlite3TreeViewExpr(0, sAggInfo.aCol[ii].pExpr, 0);
@@ -135570,11 +135694,11 @@
135570135694
need = nCol;
135571135695
}
135572135696
if( p->nData + need > p->nAlloc ){
135573135697
char **azNew;
135574135698
p->nAlloc = p->nAlloc*2 + need;
135575
- azNew = sqlite3_realloc64( p->azResult, sizeof(char*)*p->nAlloc );
135699
+ azNew = sqlite3Realloc( p->azResult, sizeof(char*)*p->nAlloc );
135576135700
if( azNew==0 ) goto malloc_failed;
135577135701
p->azResult = azNew;
135578135702
}
135579135703
135580135704
/* If this is the first row, then generate an extra row containing
@@ -135679,11 +135803,11 @@
135679135803
sqlite3_free_table(&res.azResult[1]);
135680135804
return rc;
135681135805
}
135682135806
if( res.nAlloc>res.nData ){
135683135807
char **azNew;
135684
- azNew = sqlite3_realloc64( res.azResult, sizeof(char*)*res.nData );
135808
+ azNew = sqlite3Realloc( res.azResult, sizeof(char*)*res.nData );
135685135809
if( azNew==0 ){
135686135810
sqlite3_free_table(&res.azResult[1]);
135687135811
db->errCode = SQLITE_NOMEM;
135688135812
return SQLITE_NOMEM_BKPT;
135689135813
}
@@ -136969,14 +137093,14 @@
136969137093
** Therefore, the P4 parameter is only required if the default value for
136970137094
** the column is a literal number, string or null. The sqlite3ValueFromExpr()
136971137095
** function is capable of transforming these types of expressions into
136972137096
** sqlite3_value objects.
136973137097
**
136974
-** If parameter iReg is not negative, code an OP_RealAffinity instruction
136975
-** on register iReg. This is used when an equivalent integer value is
136976
-** stored in place of an 8-byte floating point value in order to save
136977
-** space.
137098
+** If column as REAL affinity and the table is an ordinary b-tree table
137099
+** (not a virtual table) then the value might have been stored as an
137100
+** integer. In that case, add an OP_RealAffinity opcode to make sure
137101
+** it has been converted into REAL.
136978137102
*/
136979137103
SQLITE_PRIVATE void sqlite3ColumnDefault(Vdbe *v, Table *pTab, int i, int iReg){
136980137104
assert( pTab!=0 );
136981137105
if( !pTab->pSelect ){
136982137106
sqlite3_value *pValue = 0;
@@ -136989,11 +137113,11 @@
136989137113
if( pValue ){
136990137114
sqlite3VdbeAppendP4(v, pValue, P4_MEM);
136991137115
}
136992137116
}
136993137117
#ifndef SQLITE_OMIT_FLOATING_POINT
136994
- if( pTab->aCol[i].affinity==SQLITE_AFF_REAL ){
137118
+ if( pTab->aCol[i].affinity==SQLITE_AFF_REAL && !IsVirtual(pTab) ){
136995137119
sqlite3VdbeAddOp1(v, OP_RealAffinity, iReg);
136996137120
}
136997137121
#endif
136998137122
}
136999137123
@@ -139838,11 +139962,11 @@
139838139962
assert( IsVirtual(pTab) );
139839139963
for(i=0; i<pToplevel->nVtabLock; i++){
139840139964
if( pTab==pToplevel->apVtabLock[i] ) return;
139841139965
}
139842139966
n = (pToplevel->nVtabLock+1)*sizeof(pToplevel->apVtabLock[0]);
139843
- apVtabLock = sqlite3_realloc64(pToplevel->apVtabLock, n);
139967
+ apVtabLock = sqlite3Realloc(pToplevel->apVtabLock, n);
139844139968
if( apVtabLock ){
139845139969
pToplevel->apVtabLock = apVtabLock;
139846139970
pToplevel->apVtabLock[pToplevel->nVtabLock++] = pTab;
139847139971
}else{
139848139972
sqlite3OomFault(pToplevel->db);
@@ -151130,24 +151254,47 @@
151130151254
){
151131151255
if( pAppend ){
151132151256
int i;
151133151257
int nInit = pList ? pList->nExpr : 0;
151134151258
for(i=0; i<pAppend->nExpr; i++){
151135
- int iDummy;
151136151259
Expr *pDup = sqlite3ExprDup(pParse->db, pAppend->a[i].pExpr, 0);
151137151260
assert( pDup==0 || !ExprHasProperty(pDup, EP_MemToken) );
151138
- if( bIntToNull && pDup && sqlite3ExprIsInteger(pDup, &iDummy) ){
151139
- pDup->op = TK_NULL;
151140
- pDup->flags &= ~(EP_IntValue|EP_IsTrue|EP_IsFalse);
151141
- pDup->u.zToken = 0;
151261
+ if( bIntToNull && pDup ){
151262
+ int iDummy;
151263
+ Expr *pSub;
151264
+ for(pSub=pDup; ExprHasProperty(pSub, EP_Skip); pSub=pSub->pLeft){
151265
+ assert( pSub );
151266
+ }
151267
+ if( sqlite3ExprIsInteger(pSub, &iDummy) ){
151268
+ pSub->op = TK_NULL;
151269
+ pSub->flags &= ~(EP_IntValue|EP_IsTrue|EP_IsFalse);
151270
+ pSub->u.zToken = 0;
151271
+ }
151142151272
}
151143151273
pList = sqlite3ExprListAppend(pParse, pList, pDup);
151144151274
if( pList ) pList->a[nInit+i].sortFlags = pAppend->a[i].sortFlags;
151145151275
}
151146151276
}
151147151277
return pList;
151148151278
}
151279
+
151280
+/*
151281
+** When rewriting a query, if the new subquery in the FROM clause
151282
+** contains TK_AGG_FUNCTION nodes that refer to an outer query,
151283
+** then we have to increase the Expr->op2 values of those nodes
151284
+** due to the extra subquery layer that was added.
151285
+**
151286
+** See also the incrAggDepth() routine in resolve.c
151287
+*/
151288
+static int sqlite3WindowExtraAggFuncDepth(Walker *pWalker, Expr *pExpr){
151289
+ if( pExpr->op==TK_AGG_FUNCTION
151290
+ && pExpr->op2>=pWalker->walkerDepth
151291
+ ){
151292
+ pExpr->op2++;
151293
+ }
151294
+ return WRC_Continue;
151295
+}
151149151296
151150151297
/*
151151151298
** If the SELECT statement passed as the second argument does not invoke
151152151299
** any SQL window functions, this function is a no-op. Otherwise, it
151153151300
** rewrites the SELECT statement so that window function xStep functions
@@ -151254,10 +151401,11 @@
151254151401
pParse, pSublist, pSrc, pWhere, pGroupBy, pHaving, pSort, 0, 0
151255151402
);
151256151403
p->pSrc = sqlite3SrcListAppend(pParse, 0, 0, 0);
151257151404
if( p->pSrc ){
151258151405
Table *pTab2;
151406
+ Walker w;
151259151407
p->pSrc->a[0].pSelect = pSub;
151260151408
sqlite3SrcListAssignCursors(pParse, p->pSrc);
151261151409
pSub->selFlags |= SF_Expanded;
151262151410
pTab2 = sqlite3ResultSetOfSelect(pParse, pSub, SQLITE_AFF_NONE);
151263151411
pSub->selFlags |= (selFlags & SF_Aggregate);
@@ -151269,10 +151417,15 @@
151269151417
}else{
151270151418
memcpy(pTab, pTab2, sizeof(Table));
151271151419
pTab->tabFlags |= TF_Ephemeral;
151272151420
p->pSrc->a[0].pTab = pTab;
151273151421
pTab = pTab2;
151422
+ memset(&w, 0, sizeof(w));
151423
+ w.xExprCallback = sqlite3WindowExtraAggFuncDepth;
151424
+ w.xSelectCallback = sqlite3WalkerDepthIncrease;
151425
+ w.xSelectCallback2 = sqlite3WalkerDepthDecrease;
151426
+ sqlite3WalkSelect(&w, pSub);
151274151427
}
151275151428
}else{
151276151429
sqlite3SelectDelete(db, pSub);
151277151430
}
151278151431
if( db->mallocFailed ) rc = SQLITE_NOMEM;
@@ -160322,10 +160475,11 @@
160322160475
}
160323160476
#endif
160324160477
if( rc==SQLITE_OK ){
160325160478
sqlite3PCacheBufferSetup( sqlite3GlobalConfig.pPage,
160326160479
sqlite3GlobalConfig.szPage, sqlite3GlobalConfig.nPage);
160480
+ sqlite3MemoryBarrier();
160327160481
sqlite3GlobalConfig.isInit = 1;
160328160482
#ifdef SQLITE_EXTRA_INIT
160329160483
bRunExtraInit = 1;
160330160484
#endif
160331160485
}
@@ -163270,11 +163424,11 @@
163270163424
assert( SQLITE_OPEN_CREATE == 0x04 );
163271163425
testcase( (1<<(flags&7))==0x02 ); /* READONLY */
163272163426
testcase( (1<<(flags&7))==0x04 ); /* READWRITE */
163273163427
testcase( (1<<(flags&7))==0x40 ); /* READWRITE | CREATE */
163274163428
if( ((1<<(flags&7)) & 0x46)==0 ){
163275
- rc = SQLITE_MISUSE_BKPT; /* IMP: R-65497-44594 */
163429
+ rc = SQLITE_MISUSE_BKPT; /* IMP: R-18321-05872 */
163276163430
}else{
163277163431
rc = sqlite3ParseUri(zVfs, zFilename, &flags, &db->pVfs, &zOpen, &zErrMsg);
163278163432
}
163279163433
if( rc!=SQLITE_OK ){
163280163434
if( rc==SQLITE_NOMEM ) sqlite3OomFault(db);
@@ -171194,10 +171348,11 @@
171194171348
while( *pRc==SQLITE_OK && pLeft->bEof==0 ){
171195171349
memset(pDl->pList, 0, pDl->nList);
171196171350
fts3EvalNextRow(pCsr, pLeft, pRc);
171197171351
}
171198171352
}
171353
+ pRight->bEof = pLeft->bEof = 1;
171199171354
}
171200171355
}
171201171356
break;
171202171357
}
171203171358
@@ -182739,11 +182894,11 @@
182739182894
iStart = pExpr->iPhrase * p->nCol;
182740182895
}else{
182741182896
iStart = pExpr->iPhrase * ((p->nCol + 31) / 32);
182742182897
}
182743182898
182744
- while( 1 ){
182899
+ if( pIter ) while( 1 ){
182745182900
int nHit = fts3ColumnlistCount(&pIter);
182746182901
if( (pPhrase->iColumn>=pTab->nColumn || pPhrase->iColumn==iCol) ){
182747182902
if( p->flag==FTS3_MATCHINFO_LHITS ){
182748182903
p->aMatchinfo[iStart + iCol] = (u32)nHit;
182749182904
}else if( nHit ){
@@ -184653,10 +184808,11 @@
184653184808
}
184654184809
184655184810
/* Append N bytes from zIn onto the end of the JsonString string.
184656184811
*/
184657184812
static void jsonAppendRaw(JsonString *p, const char *zIn, u32 N){
184813
+ if( N==0 ) return;
184658184814
if( (N+p->nUsed >= p->nAlloc) && jsonGrow(p,N)!=0 ) return;
184659184815
memcpy(p->zBuf+p->nUsed, zIn, N);
184660184816
p->nUsed += N;
184661184817
}
184662184818
@@ -224664,11 +224820,11 @@
224664224820
int nArg, /* Number of args */
224665224821
sqlite3_value **apUnused /* Function arguments */
224666224822
){
224667224823
assert( nArg==0 );
224668224824
UNUSED_PARAM2(nArg, apUnused);
224669
- sqlite3_result_text(pCtx, "fts5: 2020-05-08 19:02:21 3a16c0ce4d8851f79f670d94786032c8007619154ece44647dc9cc5b1f9654ff", -1, SQLITE_TRANSIENT);
224825
+ sqlite3_result_text(pCtx, "fts5: 2020-05-25 16:19:56 0c1fcf4711a2e66c813aed38cf41cd3e2123ee8eb6db98118086764c4ba83350", -1, SQLITE_TRANSIENT);
224670224826
}
224671224827
224672224828
/*
224673224829
** Return true if zName is the extension on one of the shadow tables used
224674224830
** by this module.
@@ -229447,12 +229603,12 @@
229447229603
}
229448229604
#endif /* SQLITE_CORE */
229449229605
#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
229450229606
229451229607
/************** End of stmt.c ************************************************/
229452
-#if __LINE__!=229452
229608
+#if __LINE__!=229608
229453229609
#undef SQLITE_SOURCE_ID
229454
-#define SQLITE_SOURCE_ID "2020-05-08 19:02:21 3a16c0ce4d8851f79f670d94786032c8007619154ece44647dc9cc5b1f96alt2"
229610
+#define SQLITE_SOURCE_ID "2020-05-25 16:19:56 0c1fcf4711a2e66c813aed38cf41cd3e2123ee8eb6db98118086764c4ba8alt2"
229455229611
#endif
229456229612
/* Return the source-id for this library */
229457229613
SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
229458229614
/************************** End of sqlite3.c ******************************/
229459229615
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1,8 +1,8 @@
1 /******************************************************************************
2 ** This file is an amalgamation of many separate C source files from SQLite
3 ** version 3.32.0. By combining all the individual C code files into this
4 ** single large file, the entire code can be compiled as a single translation
5 ** unit. This allows many compilers to do optimizations that would not be
6 ** possible if the files were compiled separately. Performance improvements
7 ** of 5% or more are commonly seen when SQLite is compiled as a single
8 ** translation unit.
@@ -1160,13 +1160,13 @@
1160 **
1161 ** See also: [sqlite3_libversion()],
1162 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
1163 ** [sqlite_version()] and [sqlite_source_id()].
1164 */
1165 #define SQLITE_VERSION "3.32.0"
1166 #define SQLITE_VERSION_NUMBER 3032000
1167 #define SQLITE_SOURCE_ID "2020-05-08 19:02:21 3a16c0ce4d8851f79f670d94786032c8007619154ece44647dc9cc5b1f9654ff"
1168
1169 /*
1170 ** CAPI3REF: Run-Time Library Version Numbers
1171 ** KEYWORDS: sqlite3_version sqlite3_sourceid
1172 **
@@ -6532,11 +6532,11 @@
6532 ** when first called if N is less than or equal to zero or if a memory
6533 ** allocate error occurs.
6534 **
6535 ** ^(The amount of space allocated by sqlite3_aggregate_context(C,N) is
6536 ** determined by the N parameter on first successful call. Changing the
6537 ** value of N in any subsequents call to sqlite3_aggregate_context() within
6538 ** the same aggregate function instance will not resize the memory
6539 ** allocation.)^ Within the xFinal callback, it is customary to set
6540 ** N=0 in calls to sqlite3_aggregate_context(C,N) so that no
6541 ** pointless memory allocations occur.
6542 **
@@ -17119,11 +17119,11 @@
17119 #define SQLITE_FUNC_EPHEM 0x0010 /* Ephemeral. Delete with VDBE */
17120 #define SQLITE_FUNC_NEEDCOLL 0x0020 /* sqlite3GetFuncCollSeq() might be called*/
17121 #define SQLITE_FUNC_LENGTH 0x0040 /* Built-in length() function */
17122 #define SQLITE_FUNC_TYPEOF 0x0080 /* Built-in typeof() function */
17123 #define SQLITE_FUNC_COUNT 0x0100 /* Built-in count(*) aggregate */
17124 #define SQLITE_FUNC_COALESCE 0x0200 /* Built-in coalesce() or ifnull() */
17125 #define SQLITE_FUNC_UNLIKELY 0x0400 /* Built-in unlikely() function */
17126 #define SQLITE_FUNC_CONSTANT 0x0800 /* Constant inputs give a constant output */
17127 #define SQLITE_FUNC_MINMAX 0x1000 /* True for min() and max() aggregates */
17128 #define SQLITE_FUNC_SLOCHNG 0x2000 /* "Slow Change". Value constant during a
17129 ** single query - might change over time */
@@ -17140,10 +17140,11 @@
17140 #define INLINEFUNC_coalesce 0
17141 #define INLINEFUNC_implies_nonnull_row 1
17142 #define INLINEFUNC_expr_implies_expr 2
17143 #define INLINEFUNC_expr_compare 3
17144 #define INLINEFUNC_affinity 4
 
17145 #define INLINEFUNC_unlikely 99 /* Default case */
17146
17147 /*
17148 ** The following three macros, FUNCTION(), LIKEFUNC() and AGGREGATE() are
17149 ** used to create the initializers for the FuncDef structures.
@@ -17840,11 +17841,11 @@
17840 /*
17841 ** An instance of this structure contains information needed to generate
17842 ** code for a SELECT that contains aggregate functions.
17843 **
17844 ** If Expr.op==TK_AGG_COLUMN or TK_AGG_FUNCTION then Expr.pAggInfo is a
17845 ** pointer to this structure. The Expr.iColumn field is the index in
17846 ** AggInfo.aCol[] or AggInfo.aFunc[] of information needed to generate
17847 ** code for that node.
17848 **
17849 ** AggInfo.pGroupBy and AggInfo.aFunc.pExpr point to fields within the
17850 ** original Select structure that describes the SELECT statement. These
@@ -19079,10 +19080,13 @@
19079 SQLITE_PRIVATE int sqlite3WalkSelectExpr(Walker*, Select*);
19080 SQLITE_PRIVATE int sqlite3WalkSelectFrom(Walker*, Select*);
19081 SQLITE_PRIVATE int sqlite3ExprWalkNoop(Walker*, Expr*);
19082 SQLITE_PRIVATE int sqlite3SelectWalkNoop(Walker*, Select*);
19083 SQLITE_PRIVATE int sqlite3SelectWalkFail(Walker*, Select*);
 
 
 
19084 #ifdef SQLITE_DEBUG
19085 SQLITE_PRIVATE void sqlite3SelectWalkAssert2(Walker*, Select*);
19086 #endif
19087
19088 /*
@@ -20064,12 +20068,14 @@
20064 # define sqlite3VtabInSync(db) ((db)->nVTrans>0 && (db)->aVTrans==0)
20065 #endif
20066 SQLITE_PRIVATE int sqlite3ReadOnlyShadowTables(sqlite3 *db);
20067 #ifndef SQLITE_OMIT_VIRTUALTABLE
20068 SQLITE_PRIVATE int sqlite3ShadowTableName(sqlite3 *db, const char *zName);
 
20069 #else
20070 # define sqlite3ShadowTableName(A,B) 0
 
20071 #endif
20072 SQLITE_PRIVATE int sqlite3VtabEponymousTableInit(Parse*,Module*);
20073 SQLITE_PRIVATE void sqlite3VtabEponymousTableClear(sqlite3*,Module*);
20074 SQLITE_PRIVATE void sqlite3VtabMakeWritable(Parse*,Table*);
20075 SQLITE_PRIVATE void sqlite3VtabBeginParse(Parse*, Token*, Token*, Token*, int);
@@ -27924,11 +27930,11 @@
27924 }
27925 }else{
27926 assert( sqlite3MemdebugHasType(p, (MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) );
27927 assert( sqlite3MemdebugNoType(p, (u8)~(MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) );
27928 sqlite3MemdebugSetType(p, MEMTYPE_HEAP);
27929 pNew = sqlite3_realloc64(p, n);
27930 if( !pNew ){
27931 sqlite3OomFault(db);
27932 }
27933 sqlite3MemdebugSetType(pNew,
27934 (db->lookaside.bDisable==0 ? MEMTYPE_LOOKASIDE : MEMTYPE_HEAP));
@@ -28271,10 +28277,17 @@
28271 #ifndef SQLITE_PRINT_BUF_SIZE
28272 # define SQLITE_PRINT_BUF_SIZE 70
28273 #endif
28274 #define etBUFSIZE SQLITE_PRINT_BUF_SIZE /* Size of the output buffer */
28275
 
 
 
 
 
 
 
28276 /*
28277 ** Render a string given by "fmt" into the StrAccum object.
28278 */
28279 SQLITE_API void sqlite3_str_vappendf(
28280 sqlite3_str *pAccum, /* Accumulate results here */
@@ -28471,10 +28484,12 @@
28471 ** precision The specified precision. The default
28472 ** is -1.
28473 ** xtype The class of the conversion.
28474 ** infop Pointer to the appropriate info struct.
28475 */
 
 
28476 switch( xtype ){
28477 case etPOINTER:
28478 flag_long = sizeof(char*)==sizeof(i64) ? 2 :
28479 sizeof(char*)==sizeof(long int) ? 1 : 0;
28480 /* Fall through into the next case */
@@ -28592,10 +28607,15 @@
28592 }
28593 #ifdef SQLITE_OMIT_FLOATING_POINT
28594 length = 0;
28595 #else
28596 if( precision<0 ) precision = 6; /* Set default precision */
 
 
 
 
 
28597 if( realvalue<0.0 ){
28598 realvalue = -realvalue;
28599 prefix = '-';
28600 }else{
28601 prefix = flag_prefix;
@@ -28874,11 +28894,11 @@
28874 }else{
28875 escarg = va_arg(ap,char*);
28876 }
28877 isnull = escarg==0;
28878 if( isnull ) escarg = (xtype==etSQLESCAPE2 ? "NULL" : "(NULL)");
28879 /* For %q, %Q, and %w, the precision is the number of byte (or
28880 ** characters if the ! flags is present) to use from the input.
28881 ** Because of the extra quoting characters inserted, the number
28882 ** of output characters may be larger than the precision.
28883 */
28884 k = precision;
@@ -29001,11 +29021,11 @@
29001 p->nAlloc = (int)szNew;
29002 }
29003 if( p->db ){
29004 zNew = sqlite3DbRealloc(p->db, zOld, p->nAlloc);
29005 }else{
29006 zNew = sqlite3_realloc64(zOld, p->nAlloc);
29007 }
29008 if( zNew ){
29009 assert( p->zText!=0 || p->nChar==0 );
29010 if( !isMalloced(p) && p->nChar>0 ) memcpy(zNew, p->zText, p->nChar);
29011 p->zText = zNew;
@@ -29343,11 +29363,11 @@
29343 ** and segfaults if you give it a long long int.
29344 */
29345 SQLITE_PRIVATE void sqlite3DebugPrintf(const char *zFormat, ...){
29346 va_list ap;
29347 StrAccum acc;
29348 char zBuf[500];
29349 sqlite3StrAccumInit(&acc, 0, zBuf, sizeof(zBuf), 0);
29350 va_start(ap,zFormat);
29351 sqlite3_str_vappendf(&acc, zFormat, ap);
29352 va_end(ap);
29353 sqlite3StrAccumFinish(&acc);
@@ -29959,12 +29979,13 @@
29959 #else
29960 pWin = 0;
29961 #endif
29962 }
29963 if( pExpr->op==TK_AGG_FUNCTION ){
29964 sqlite3TreeViewLine(pView, "AGG_FUNCTION%d %Q%s",
29965 pExpr->op2, pExpr->u.zToken, zFlgs);
 
29966 }else if( pExpr->op2!=0 ){
29967 const char *zOp2;
29968 char zBuf[8];
29969 sqlite3_snprintf(sizeof(zBuf),zBuf,"0x%02x",pExpr->op2);
29970 zOp2 = zBuf;
@@ -30853,10 +30874,11 @@
30853 /* UTF-16 Little-endian -> UTF-8 */
30854 while( zIn<zTerm ){
30855 c = *(zIn++);
30856 c += (*(zIn++))<<8;
30857 if( c>=0xd800 && c<0xe000 ){
 
30858 if( c>=0xdc00 || zIn>=zTerm ){
30859 c = 0xfffd;
30860 }else{
30861 int c2 = *(zIn++);
30862 c2 += (*(zIn++))<<8;
@@ -30865,19 +30887,27 @@
30865 c = 0xfffd;
30866 }else{
30867 c = ((c&0x3ff)<<10) + (c2&0x3ff) + 0x10000;
30868 }
30869 }
 
 
 
 
 
 
 
30870 }
30871 WRITE_UTF8(z, c);
30872 }
30873 }else{
30874 /* UTF-16 Big-endian -> UTF-8 */
30875 while( zIn<zTerm ){
30876 c = (*(zIn++))<<8;
30877 c += *(zIn++);
30878 if( c>=0xd800 && c<0xe000 ){
 
30879 if( c>=0xdc00 || zIn>=zTerm ){
30880 c = 0xfffd;
30881 }else{
30882 int c2 = (*(zIn++))<<8;
30883 c2 += *(zIn++);
@@ -30886,10 +30916,17 @@
30886 c = 0xfffd;
30887 }else{
30888 c = ((c&0x3ff)<<10) + (c2&0x3ff) + 0x10000;
30889 }
30890 }
 
 
 
 
 
 
 
30891 }
30892 WRITE_UTF8(z, c);
30893 }
30894 }
30895 pMem->n = (int)(z - zOut);
@@ -45048,10 +45085,11 @@
45048 }
45049
45050 /* Forward references to VFS helper methods used for temporary files */
45051 static int winGetTempname(sqlite3_vfs *, char **);
45052 static int winIsDir(const void *);
 
45053 static BOOL winIsDriveLetterAndColon(const char *);
45054
45055 /*
45056 ** Control and query of the open file handle.
45057 */
@@ -46817,11 +46855,13 @@
46817 pFile->pVfs = pVfs;
46818 pFile->h = h;
46819 if( isReadonly ){
46820 pFile->ctrlFlags |= WINFILE_RDONLY;
46821 }
46822 if( sqlite3_uri_boolean(zName, "psow", SQLITE_POWERSAFE_OVERWRITE) ){
 
 
46823 pFile->ctrlFlags |= WINFILE_PSOW;
46824 }
46825 pFile->lastErrno = NO_ERROR;
46826 pFile->zPath = zName;
46827 #if SQLITE_MAX_MMAP_SIZE>0
@@ -47026,10 +47066,21 @@
47026 *pResOut = rc;
47027 OSTRACE(("ACCESS name=%s, pResOut=%p, *pResOut=%d, rc=SQLITE_OK\n",
47028 zFilename, pResOut, *pResOut));
47029 return SQLITE_OK;
47030 }
 
 
 
 
 
 
 
 
 
 
 
47031
47032 /*
47033 ** Returns non-zero if the specified path name starts with a drive letter
47034 ** followed by a colon character.
47035 */
@@ -47091,14 +47142,15 @@
47091 DWORD nByte;
47092 void *zConverted;
47093 char *zOut;
47094 #endif
47095
47096 /* If this path name begins with "/X:", where "X" is any alphabetic
47097 ** character, discard the initial "/" from the pathname.
47098 */
47099 if( zRelative[0]=='/' && winIsDriveLetterAndColon(zRelative+1) ){
 
47100 zRelative++;
47101 }
47102
47103 #if defined(__CYGWIN__)
47104 SimulateIOError( return SQLITE_ERROR );
@@ -47850,11 +47902,11 @@
47850 if( newSz>p->szMax ){
47851 return SQLITE_FULL;
47852 }
47853 newSz *= 2;
47854 if( newSz>p->szMax ) newSz = p->szMax;
47855 pNew = sqlite3_realloc64(p->aData, newSz);
47856 if( pNew==0 ) return SQLITE_NOMEM;
47857 p->aData = pNew;
47858 p->szAlloc = newSz;
47859 return SQLITE_OK;
47860 }
@@ -48297,14 +48349,15 @@
48297 */
48298 SQLITE_PRIVATE int sqlite3MemdbInit(void){
48299 sqlite3_vfs *pLower = sqlite3_vfs_find(0);
48300 int sz = pLower->szOsFile;
48301 memdb_vfs.pAppData = pLower;
48302 /* In all known configurations of SQLite, the size of a default
48303 ** sqlite3_file is greater than the size of a memdb sqlite3_file.
48304 ** Should that ever change, remove the following NEVER() */
48305 if( NEVER(sz<sizeof(MemFile)) ) sz = sizeof(MemFile);
 
48306 memdb_vfs.szOsFile = sz;
48307 return sqlite3_vfs_register(&memdb_vfs, 0);
48308 }
48309 #endif /* SQLITE_ENABLE_DESERIALIZE */
48310
@@ -59820,11 +59873,11 @@
59820
59821 /* Enlarge the pWal->apWiData[] array if required */
59822 if( pWal->nWiData<=iPage ){
59823 sqlite3_int64 nByte = sizeof(u32*)*(iPage+1);
59824 volatile u32 **apNew;
59825 apNew = (volatile u32 **)sqlite3_realloc64((void *)pWal->apWiData, nByte);
59826 if( !apNew ){
59827 *ppPage = 0;
59828 return SQLITE_NOMEM_BKPT;
59829 }
59830 memset((void*)&apNew[pWal->nWiData], 0,
@@ -59941,29 +59994,47 @@
59941
59942 aOut[0] = s1;
59943 aOut[1] = s2;
59944 }
59945
 
 
 
 
59946 static void walShmBarrier(Wal *pWal){
59947 if( pWal->exclusiveMode!=WAL_HEAPMEMORY_MODE ){
59948 sqlite3OsShmBarrier(pWal->pDbFd);
59949 }
59950 }
59951
 
 
 
 
 
 
 
 
 
 
 
 
 
59952 /*
59953 ** Write the header information in pWal->hdr into the wal-index.
59954 **
59955 ** The checksum on pWal->hdr is updated before it is written.
59956 */
59957 static void walIndexWriteHdr(Wal *pWal){
59958 volatile WalIndexHdr *aHdr = walIndexHdr(pWal);
59959 const int nCksum = offsetof(WalIndexHdr, aCksum);
59960
59961 assert( pWal->writeLock );
59962 pWal->hdr.isInit = 1;
59963 pWal->hdr.iVersion = WALINDEX_MAX_VERSION;
59964 walChecksumBytes(1, (u8*)&pWal->hdr, nCksum, 0, pWal->hdr.aCksum);
 
59965 memcpy((void*)&aHdr[1], (const void*)&pWal->hdr, sizeof(WalIndexHdr));
59966 walShmBarrier(pWal);
59967 memcpy((void*)&aHdr[0], (const void*)&pWal->hdr, sizeof(WalIndexHdr));
59968 }
59969
@@ -61074,11 +61145,11 @@
61074 pWal->nCkpt++;
61075 pWal->hdr.mxFrame = 0;
61076 sqlite3Put4byte((u8*)&aSalt[0], 1 + sqlite3Get4byte((u8*)&aSalt[0]));
61077 memcpy(&pWal->hdr.aSalt[1], &salt1, 4);
61078 walIndexWriteHdr(pWal);
61079 pInfo->nBackfill = 0;
61080 pInfo->nBackfillAttempted = 0;
61081 pInfo->aReadMark[1] = 0;
61082 for(i=2; i<WAL_NREADER; i++) pInfo->aReadMark[i] = READMARK_NOT_USED;
61083 assert( pInfo->aReadMark[0]==0 );
61084 }
@@ -61149,36 +61220,17 @@
61149 ** cannot be backfilled from the WAL.
61150 */
61151 mxSafeFrame = pWal->hdr.mxFrame;
61152 mxPage = pWal->hdr.nPage;
61153 for(i=1; i<WAL_NREADER; i++){
61154 /* Thread-sanitizer reports that the following is an unsafe read,
61155 ** as some other thread may be in the process of updating the value
61156 ** of the aReadMark[] slot. The assumption here is that if that is
61157 ** happening, the other client may only be increasing the value,
61158 ** not decreasing it. So assuming either that either the "old" or
61159 ** "new" version of the value is read, and not some arbitrary value
61160 ** that would never be written by a real client, things are still
61161 ** safe.
61162 **
61163 ** Astute readers have pointed out that the assumption stated in the
61164 ** last sentence of the previous paragraph is not guaranteed to be
61165 ** true for all conforming systems. However, the assumption is true
61166 ** for all compilers and architectures in common use today (circa
61167 ** 2019-11-27) and the alternatives are both slow and complex, and
61168 ** so we will continue to go with the current design for now. If this
61169 ** bothers you, or if you really are running on a system where aligned
61170 ** 32-bit reads and writes are not atomic, then you can simply avoid
61171 ** the use of WAL mode, or only use WAL mode together with
61172 ** PRAGMA locking_mode=EXCLUSIVE and all will be well.
61173 */
61174 u32 y = pInfo->aReadMark[i];
61175 if( mxSafeFrame>y ){
61176 assert( y<=pWal->hdr.mxFrame );
61177 rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_READ_LOCK(i), 1);
61178 if( rc==SQLITE_OK ){
61179 pInfo->aReadMark[i] = (i==1 ? mxSafeFrame : READMARK_NOT_USED);
 
61180 walUnlockExclusive(pWal, WAL_READ_LOCK(i), 1);
61181 }else if( rc==SQLITE_BUSY ){
61182 mxSafeFrame = y;
61183 xBusy = 0;
61184 }else{
@@ -61192,11 +61244,11 @@
61192 rc = walIteratorInit(pWal, pInfo->nBackfill, &pIter);
61193 assert( rc==SQLITE_OK || pIter==0 );
61194 }
61195
61196 if( pIter
61197 && (rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_READ_LOCK(0),1))==SQLITE_OK
61198 ){
61199 u32 nBackfill = pInfo->nBackfill;
61200
61201 pInfo->nBackfillAttempted = mxSafeFrame;
61202
@@ -61248,11 +61300,11 @@
61248 if( rc==SQLITE_OK ){
61249 rc = sqlite3OsSync(pWal->pDbFd, CKPT_SYNC_FLAGS(sync_flags));
61250 }
61251 }
61252 if( rc==SQLITE_OK ){
61253 pInfo->nBackfill = mxSafeFrame;
61254 }
61255 }
61256
61257 /* Release the reader lock held while backfilling */
61258 walUnlockExclusive(pWal, WAL_READ_LOCK(0), 1);
@@ -61407,11 +61459,11 @@
61407 ** and *pChanged is set to 1.
61408 **
61409 ** If the checksum cannot be verified return non-zero. If the header
61410 ** is read successfully and the checksum verified, return zero.
61411 */
61412 static int walIndexTryHdr(Wal *pWal, int *pChanged){
61413 u32 aCksum[2]; /* Checksum on the header content */
61414 WalIndexHdr h1, h2; /* Two copies of the header content */
61415 WalIndexHdr volatile *aHdr; /* Header in shared memory */
61416
61417 /* The first page of the wal-index must be mapped at this point. */
@@ -61420,17 +61472,23 @@
61420 /* Read the header. This might happen concurrently with a write to the
61421 ** same area of shared memory on a different CPU in a SMP,
61422 ** meaning it is possible that an inconsistent snapshot is read
61423 ** from the file. If this happens, return non-zero.
61424 **
 
61425 ** There are two copies of the header at the beginning of the wal-index.
61426 ** When reading, read [0] first then [1]. Writes are in the reverse order.
61427 ** Memory barriers are used to prevent the compiler or the hardware from
61428 ** reordering the reads and writes.
 
 
 
 
 
61429 */
61430 aHdr = walIndexHdr(pWal);
61431 memcpy(&h1, (void *)&aHdr[0], sizeof(h1));
61432 walShmBarrier(pWal);
61433 memcpy(&h2, (void *)&aHdr[1], sizeof(h2));
61434
61435 if( memcmp(&h1, &h2, sizeof(h1))!=0 ){
61436 return 1; /* Dirty read */
@@ -61871,11 +61929,11 @@
61871 }
61872
61873 assert( pWal->nWiData>0 );
61874 assert( pWal->apWiData[0]!=0 );
61875 pInfo = walCkptInfo(pWal);
61876 if( !useWal && pInfo->nBackfill==pWal->hdr.mxFrame
61877 #ifdef SQLITE_ENABLE_SNAPSHOT
61878 && (pWal->pSnapshot==0 || pWal->hdr.mxFrame==0)
61879 #endif
61880 ){
61881 /* The WAL has been completely backfilled (or it is empty).
@@ -62038,11 +62096,11 @@
62038 void *pBuf2 = sqlite3_malloc(szPage);
62039 if( pBuf1==0 || pBuf2==0 ){
62040 rc = SQLITE_NOMEM;
62041 }else{
62042 u32 i = pInfo->nBackfillAttempted;
62043 for(i=pInfo->nBackfillAttempted; i>pInfo->nBackfill; i--){
62044 WalHashLoc sLoc; /* Hash table location */
62045 u32 pgno; /* Page number in db file */
62046 i64 iDbOff; /* Offset of db file entry */
62047 i64 iWalOff; /* Offset of wal file entry */
62048
@@ -62093,16 +62151,18 @@
62093 ** needs to be flushed.
62094 */
62095 SQLITE_PRIVATE int sqlite3WalBeginReadTransaction(Wal *pWal, int *pChanged){
62096 int rc; /* Return code */
62097 int cnt = 0; /* Number of TryBeginRead attempts */
 
 
 
 
62098
62099 assert( pWal->ckptLock==0 );
62100
62101 #ifdef SQLITE_ENABLE_SNAPSHOT
62102 int bChanged = 0;
62103 WalIndexHdr *pSnapshot = pWal->pSnapshot;
62104 if( pSnapshot ){
62105 if( memcmp(pSnapshot, &pWal->hdr, sizeof(WalIndexHdr))!=0 ){
62106 bChanged = 1;
62107 }
62108
@@ -62267,26 +62327,28 @@
62267 for(iHash=walFramePage(iLast); iHash>=iMinHash; iHash--){
62268 WalHashLoc sLoc; /* Hash table location */
62269 int iKey; /* Hash slot index */
62270 int nCollide; /* Number of hash collisions remaining */
62271 int rc; /* Error code */
 
62272
62273 rc = walHashGet(pWal, iHash, &sLoc);
62274 if( rc!=SQLITE_OK ){
62275 return rc;
62276 }
62277 nCollide = HASHTABLE_NSLOT;
62278 for(iKey=walHash(pgno); sLoc.aHash[iKey]; iKey=walNextHash(iKey)){
62279 u32 iH = sLoc.aHash[iKey];
62280 u32 iFrame = iH + sLoc.iZero;
62281 if( iFrame<=iLast && iFrame>=pWal->minFrame && sLoc.aPgno[iH]==pgno ){
62282 assert( iFrame>iRead || CORRUPT_DB );
62283 iRead = iFrame;
62284 }
62285 if( (nCollide--)==0 ){
62286 return SQLITE_CORRUPT_BKPT;
62287 }
 
62288 }
62289 if( iRead ) break;
62290 }
62291
62292 #ifdef SQLITE_ENABLE_EXPENSIVE_ASSERT
@@ -79307,10 +79369,11 @@
79307 char *zP4;
79308 char *zCom;
79309 sqlite3 dummyDb;
79310 static const char *zFormat1 = "%4d %-13s %4d %4d %4d %-13s %.2X %s\n";
79311 if( pOut==0 ) pOut = stdout;
 
79312 dummyDb.mallocFailed = 1;
79313 zP4 = sqlite3VdbeDisplayP4(&dummyDb, pOp);
79314 #ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS
79315 zCom = sqlite3VdbeDisplayComment(0, pOp, zP4);
79316 #else
@@ -79325,10 +79388,11 @@
79325 zCom ? zCom : ""
79326 );
79327 fflush(pOut);
79328 sqlite3_free(zP4);
79329 sqlite3_free(zCom);
 
79330 }
79331 #endif
79332
79333 /*
79334 ** Initialize an array of N Mem element.
@@ -84066,11 +84130,11 @@
84066 p->db->errCode = SQLITE_OK;
84067
84068 /* If the bit corresponding to this variable in Vdbe.expmask is set, then
84069 ** binding a new value to this variable invalidates the current query plan.
84070 **
84071 ** IMPLEMENTATION-OF: R-48440-37595 If the specific value bound to host
84072 ** parameter in the WHERE clause might influence the choice of query plan
84073 ** for a statement, then the statement will be automatically recompiled,
84074 ** as if there had been a schema change, on the first sqlite3_step() call
84075 ** following any change to the bindings of that parameter.
84076 */
@@ -96365,12 +96429,12 @@
96365 *************************************************************************
96366 **
96367 ** This file implements virtual-tables for examining the bytecode content
96368 ** of a prepared statement.
96369 */
96370 #ifdef SQLITE_ENABLE_BYTECODE_VTAB
96371 /* #include "sqliteInt.h" */
 
96372 /* #include "vdbeInt.h" */
96373
96374 /* An instance of the bytecode() table-valued function.
96375 */
96376 typedef struct bytecodevtab bytecodevtab;
@@ -96771,10 +96835,12 @@
96771 if( rc==SQLITE_OK ){
96772 rc = sqlite3_create_module(db, "tables_used", &bytecodevtabModule, &db);
96773 }
96774 return rc;
96775 }
 
 
96776 #endif /* SQLITE_ENABLE_BYTECODE_VTAB */
96777
96778 /************** End of vdbevtab.c ********************************************/
96779 /************** Begin file memjournal.c **************************************/
96780 /*
@@ -97416,10 +97482,47 @@
97416 }
97417 p = p->pPrior;
97418 }while( p!=0 );
97419 return WRC_Continue;
97420 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
97421
97422 /************** End of walker.c **********************************************/
97423 /************** Begin file resolve.c *****************************************/
97424 /*
97425 ** 2008 August 18
@@ -97445,10 +97548,12 @@
97445 ** This needs to occur when copying a TK_AGG_FUNCTION node from an
97446 ** outer query into an inner subquery.
97447 **
97448 ** incrAggFunctionDepth(pExpr,n) is the main routine. incrAggDepth(..)
97449 ** is a helper function - a callback for the tree walker.
 
 
97450 */
97451 static int incrAggDepth(Walker *pWalker, Expr *pExpr){
97452 if( pExpr->op==TK_AGG_FUNCTION ) pExpr->op2 += pWalker->u.n;
97453 return WRC_Continue;
97454 }
@@ -103075,10 +103180,17 @@
103075 }
103076 setDoNotMergeFlagOnCopy(v);
103077 sqlite3VdbeResolveLabel(v, endCoalesce);
103078 break;
103079 }
 
 
 
 
 
 
 
103080
103081 default: {
103082 /* The UNLIKELY() function is a no-op. The result is the value
103083 ** of the first argument.
103084 */
@@ -103179,11 +103291,14 @@
103179 op = pExpr->op;
103180 }
103181 switch( op ){
103182 case TK_AGG_COLUMN: {
103183 AggInfo *pAggInfo = pExpr->pAggInfo;
103184 struct AggInfo_col *pCol = &pAggInfo->aCol[pExpr->iAgg];
 
 
 
103185 if( !pAggInfo->directMode ){
103186 assert( pCol->iMem>0 );
103187 return pCol->iMem;
103188 }else if( pAggInfo->useSortingIdx ){
103189 Table *pTab = pCol->pTab;
@@ -103479,11 +103594,14 @@
103479 sqlite3VdbeJumpHere(v, addr);
103480 break;
103481 }
103482 case TK_AGG_FUNCTION: {
103483 AggInfo *pInfo = pExpr->pAggInfo;
103484 if( pInfo==0 ){
 
 
 
103485 assert( !ExprHasProperty(pExpr, EP_IntValue) );
103486 sqlite3ErrorMsg(pParse, "misuse of aggregate: %s()", pExpr->u.zToken);
103487 }else{
103488 return pInfo->aFunc[pExpr->iAgg].iMem;
103489 }
@@ -105235,19 +105353,10 @@
105235 }
105236 }
105237 }
105238 return WRC_Continue;
105239 }
105240 static int analyzeAggregatesInSelect(Walker *pWalker, Select *pSelect){
105241 UNUSED_PARAMETER(pSelect);
105242 pWalker->walkerDepth++;
105243 return WRC_Continue;
105244 }
105245 static void analyzeAggregatesInSelectEnd(Walker *pWalker, Select *pSelect){
105246 UNUSED_PARAMETER(pSelect);
105247 pWalker->walkerDepth--;
105248 }
105249
105250 /*
105251 ** Analyze the pExpr expression looking for aggregate functions and
105252 ** for variables that need to be added to AggInfo object that pNC->pAggInfo
105253 ** points to. Additional entries are made on the AggInfo object as
@@ -105257,12 +105366,12 @@
105257 ** analyzed by sqlite3ResolveExprNames().
105258 */
105259 SQLITE_PRIVATE void sqlite3ExprAnalyzeAggregates(NameContext *pNC, Expr *pExpr){
105260 Walker w;
105261 w.xExprCallback = analyzeAggregate;
105262 w.xSelectCallback = analyzeAggregatesInSelect;
105263 w.xSelectCallback2 = analyzeAggregatesInSelectEnd;
105264 w.walkerDepth = 0;
105265 w.u.pNC = pNC;
105266 w.pParse = 0;
105267 assert( pNC->pSrcList!=0 );
105268 sqlite3WalkExpr(&w, pExpr);
@@ -105497,11 +105606,14 @@
105497 if( !zName ) goto exit_rename_table;
105498
105499 /* Check that a table or index named 'zName' does not already exist
105500 ** in database iDb. If so, this is an error.
105501 */
105502 if( sqlite3FindTable(db, zName, zDb) || sqlite3FindIndex(db, zName, zDb) ){
 
 
 
105503 sqlite3ErrorMsg(pParse,
105504 "there is already another table or index with this name: %s", zName);
105505 goto exit_rename_table;
105506 }
105507
@@ -110244,26 +110356,43 @@
110244 ** exists */
110245 if( db->auth.authLevel<UAUTH_Admin && sqlite3UserAuthTable(zName)!=0 ){
110246 return 0;
110247 }
110248 #endif
110249 while(1){
110250 for(i=OMIT_TEMPDB; i<db->nDb; i++){
110251 int j = (i<2) ? i^1 : i; /* Search TEMP before MAIN */
110252 if( zDatabase==0 || sqlite3DbIsNamed(db, j, zDatabase) ){
110253 assert( sqlite3SchemaMutexHeld(db, j, 0) );
110254 p = sqlite3HashFind(&db->aDb[j].pSchema->tblHash, zName);
110255 if( p ) return p;
110256 }
110257 }
110258 /* Not found. If the name we were looking for was temp.sqlite_master
110259 ** then change the name to sqlite_temp_master and try again. */
110260 if( sqlite3StrICmp(zName, MASTER_NAME)!=0 ) break;
110261 if( sqlite3_stricmp(zDatabase, db->aDb[1].zDbSName)!=0 ) break;
110262 zName = TEMP_MASTER_NAME;
110263 }
110264 return 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110265 }
110266
110267 /*
110268 ** Locate the in-memory structure that describes a particular database
110269 ** table given the name of that table and (optionally) the name of the
@@ -112063,10 +112192,32 @@
112063 assert( pPk->nColumn==j );
112064 assert( pTab->nNVCol<=j );
112065 recomputeColumnsNotIndexed(pPk);
112066 }
112067
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
112068 #ifndef SQLITE_OMIT_VIRTUALTABLE
112069 /*
112070 ** Return true if zName is a shadow table name in the current database
112071 ** connection.
112072 **
@@ -112074,26 +112225,21 @@
112074 ** restored to its original value prior to this routine returning.
112075 */
112076 SQLITE_PRIVATE int sqlite3ShadowTableName(sqlite3 *db, const char *zName){
112077 char *zTail; /* Pointer to the last "_" in zName */
112078 Table *pTab; /* Table that zName is a shadow of */
112079 Module *pMod; /* Module for the virtual table */
112080
112081 zTail = strrchr(zName, '_');
112082 if( zTail==0 ) return 0;
112083 *zTail = 0;
112084 pTab = sqlite3FindTable(db, zName, 0);
112085 *zTail = '_';
112086 if( pTab==0 ) return 0;
112087 if( !IsVirtual(pTab) ) return 0;
112088 pMod = (Module*)sqlite3HashFind(&db->aModule, pTab->azModuleArg[0]);
112089 if( pMod==0 ) return 0;
112090 if( pMod->pModule->iVersion<3 ) return 0;
112091 if( pMod->pModule->xShadowName==0 ) return 0;
112092 return pMod->pModule->xShadowName(zTail+1);
112093 }
112094 #endif /* ifndef SQLITE_OMIT_VIRTUALTABLE */
 
112095
112096 #ifdef SQLITE_DEBUG
112097 /*
112098 ** Mark all nodes of an expression as EP_Immutable, indicating that
112099 ** they should not be changed. Expressions attached to a table or
@@ -117780,11 +117926,11 @@
117780 if( (cntExpand&(cntExpand-1))==0 ){
117781 /* Grow the size of the output buffer only on substitutions
117782 ** whose index is a power of two: 1, 2, 4, 8, 16, 32, ... */
117783 u8 *zOld;
117784 zOld = zOut;
117785 zOut = sqlite3_realloc64(zOut, (int)nOut + (nOut - nStr - 1));
117786 if( zOut==0 ){
117787 sqlite3_result_error_nomem(context);
117788 sqlite3_free(zOld);
117789 return;
117790 }
@@ -118477,11 +118623,11 @@
118477 FUNCTION(round, 2, 0, 0, roundFunc ),
118478 #endif
118479 FUNCTION(upper, 1, 0, 0, upperFunc ),
118480 FUNCTION(lower, 1, 0, 0, lowerFunc ),
118481 FUNCTION(hex, 1, 0, 0, hexFunc ),
118482 INLINE_FUNC(ifnull, 2, INLINEFUNC_coalesce, SQLITE_FUNC_COALESCE),
118483 VFUNCTION(random, 0, 0, 0, randomFunc ),
118484 VFUNCTION(randomblob, 1, 0, 0, randomBlob ),
118485 FUNCTION(nullif, 2, 0, 1, nullifFunc ),
118486 DFUNCTION(sqlite_version, 0, 0, 0, versionFunc ),
118487 DFUNCTION(sqlite_source_id, 0, 0, 0, sourceidFunc ),
@@ -118517,11 +118663,12 @@
118517 #ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION
118518 FUNCTION(unknown, -1, 0, 0, unknownFunc ),
118519 #endif
118520 FUNCTION(coalesce, 1, 0, 0, 0 ),
118521 FUNCTION(coalesce, 0, 0, 0, 0 ),
118522 INLINE_FUNC(coalesce, -1, INLINEFUNC_coalesce, SQLITE_FUNC_COALESCE),
 
118523 };
118524 #ifndef SQLITE_OMIT_ALTERTABLE
118525 sqlite3AlterFunctions();
118526 #endif
118527 sqlite3WindowFunctions();
@@ -121942,11 +122089,11 @@
121942 }
121943 if( bAffinityDone==0 && (pUpIdx==0 || pUpIdx==pIdx) ){
121944 sqlite3TableAffinity(v, pTab, regNewData+1);
121945 bAffinityDone = 1;
121946 }
121947 VdbeNoopComment((v, "uniqueness check for %s", pIdx->zName));
121948 iThisCur = iIdxCur+ix;
121949
121950
121951 /* Skip partial indices for which the WHERE clause is not true */
121952 if( pIdx->pPartIdxWhere ){
@@ -133914,33 +134061,10 @@
133914 }
133915 }
133916 return WRC_Continue;
133917 }
133918
133919 /*
133920 ** No-op routine for the parse-tree walker.
133921 **
133922 ** When this routine is the Walker.xExprCallback then expression trees
133923 ** are walked without any actions being taken at each node. Presumably,
133924 ** when this routine is used for Walker.xExprCallback then
133925 ** Walker.xSelectCallback is set to do something useful for every
133926 ** subquery in the parser tree.
133927 */
133928 SQLITE_PRIVATE int sqlite3ExprWalkNoop(Walker *NotUsed, Expr *NotUsed2){
133929 UNUSED_PARAMETER2(NotUsed, NotUsed2);
133930 return WRC_Continue;
133931 }
133932
133933 /*
133934 ** No-op routine for the parse-tree walker for SELECT statements.
133935 ** subquery in the parser tree.
133936 */
133937 SQLITE_PRIVATE int sqlite3SelectWalkNoop(Walker *NotUsed, Select *NotUsed2){
133938 UNUSED_PARAMETER2(NotUsed, NotUsed2);
133939 return WRC_Continue;
133940 }
133941
133942 #if SQLITE_DEBUG
133943 /*
133944 ** Always assert. This xSelectCallback2 implementation proves that the
133945 ** xSelectCallback2 is never invoked.
133946 */
@@ -135107,11 +135231,11 @@
135107 sAggInfo.mxReg = pParse->nMem;
135108 if( db->mallocFailed ) goto select_end;
135109 #if SELECTTRACE_ENABLED
135110 if( sqlite3SelectTrace & 0x400 ){
135111 int ii;
135112 SELECTTRACE(0x400,pParse,p,("After aggregate analysis:\n"));
135113 sqlite3TreeViewSelect(0, p, 0);
135114 for(ii=0; ii<sAggInfo.nColumn; ii++){
135115 sqlite3DebugPrintf("agg-column[%d] iMem=%d\n",
135116 ii, sAggInfo.aCol[ii].iMem);
135117 sqlite3TreeViewExpr(0, sAggInfo.aCol[ii].pExpr, 0);
@@ -135570,11 +135694,11 @@
135570 need = nCol;
135571 }
135572 if( p->nData + need > p->nAlloc ){
135573 char **azNew;
135574 p->nAlloc = p->nAlloc*2 + need;
135575 azNew = sqlite3_realloc64( p->azResult, sizeof(char*)*p->nAlloc );
135576 if( azNew==0 ) goto malloc_failed;
135577 p->azResult = azNew;
135578 }
135579
135580 /* If this is the first row, then generate an extra row containing
@@ -135679,11 +135803,11 @@
135679 sqlite3_free_table(&res.azResult[1]);
135680 return rc;
135681 }
135682 if( res.nAlloc>res.nData ){
135683 char **azNew;
135684 azNew = sqlite3_realloc64( res.azResult, sizeof(char*)*res.nData );
135685 if( azNew==0 ){
135686 sqlite3_free_table(&res.azResult[1]);
135687 db->errCode = SQLITE_NOMEM;
135688 return SQLITE_NOMEM_BKPT;
135689 }
@@ -136969,14 +137093,14 @@
136969 ** Therefore, the P4 parameter is only required if the default value for
136970 ** the column is a literal number, string or null. The sqlite3ValueFromExpr()
136971 ** function is capable of transforming these types of expressions into
136972 ** sqlite3_value objects.
136973 **
136974 ** If parameter iReg is not negative, code an OP_RealAffinity instruction
136975 ** on register iReg. This is used when an equivalent integer value is
136976 ** stored in place of an 8-byte floating point value in order to save
136977 ** space.
136978 */
136979 SQLITE_PRIVATE void sqlite3ColumnDefault(Vdbe *v, Table *pTab, int i, int iReg){
136980 assert( pTab!=0 );
136981 if( !pTab->pSelect ){
136982 sqlite3_value *pValue = 0;
@@ -136989,11 +137113,11 @@
136989 if( pValue ){
136990 sqlite3VdbeAppendP4(v, pValue, P4_MEM);
136991 }
136992 }
136993 #ifndef SQLITE_OMIT_FLOATING_POINT
136994 if( pTab->aCol[i].affinity==SQLITE_AFF_REAL ){
136995 sqlite3VdbeAddOp1(v, OP_RealAffinity, iReg);
136996 }
136997 #endif
136998 }
136999
@@ -139838,11 +139962,11 @@
139838 assert( IsVirtual(pTab) );
139839 for(i=0; i<pToplevel->nVtabLock; i++){
139840 if( pTab==pToplevel->apVtabLock[i] ) return;
139841 }
139842 n = (pToplevel->nVtabLock+1)*sizeof(pToplevel->apVtabLock[0]);
139843 apVtabLock = sqlite3_realloc64(pToplevel->apVtabLock, n);
139844 if( apVtabLock ){
139845 pToplevel->apVtabLock = apVtabLock;
139846 pToplevel->apVtabLock[pToplevel->nVtabLock++] = pTab;
139847 }else{
139848 sqlite3OomFault(pToplevel->db);
@@ -151130,24 +151254,47 @@
151130 ){
151131 if( pAppend ){
151132 int i;
151133 int nInit = pList ? pList->nExpr : 0;
151134 for(i=0; i<pAppend->nExpr; i++){
151135 int iDummy;
151136 Expr *pDup = sqlite3ExprDup(pParse->db, pAppend->a[i].pExpr, 0);
151137 assert( pDup==0 || !ExprHasProperty(pDup, EP_MemToken) );
151138 if( bIntToNull && pDup && sqlite3ExprIsInteger(pDup, &iDummy) ){
151139 pDup->op = TK_NULL;
151140 pDup->flags &= ~(EP_IntValue|EP_IsTrue|EP_IsFalse);
151141 pDup->u.zToken = 0;
 
 
 
 
 
 
 
151142 }
151143 pList = sqlite3ExprListAppend(pParse, pList, pDup);
151144 if( pList ) pList->a[nInit+i].sortFlags = pAppend->a[i].sortFlags;
151145 }
151146 }
151147 return pList;
151148 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
151149
151150 /*
151151 ** If the SELECT statement passed as the second argument does not invoke
151152 ** any SQL window functions, this function is a no-op. Otherwise, it
151153 ** rewrites the SELECT statement so that window function xStep functions
@@ -151254,10 +151401,11 @@
151254 pParse, pSublist, pSrc, pWhere, pGroupBy, pHaving, pSort, 0, 0
151255 );
151256 p->pSrc = sqlite3SrcListAppend(pParse, 0, 0, 0);
151257 if( p->pSrc ){
151258 Table *pTab2;
 
151259 p->pSrc->a[0].pSelect = pSub;
151260 sqlite3SrcListAssignCursors(pParse, p->pSrc);
151261 pSub->selFlags |= SF_Expanded;
151262 pTab2 = sqlite3ResultSetOfSelect(pParse, pSub, SQLITE_AFF_NONE);
151263 pSub->selFlags |= (selFlags & SF_Aggregate);
@@ -151269,10 +151417,15 @@
151269 }else{
151270 memcpy(pTab, pTab2, sizeof(Table));
151271 pTab->tabFlags |= TF_Ephemeral;
151272 p->pSrc->a[0].pTab = pTab;
151273 pTab = pTab2;
 
 
 
 
 
151274 }
151275 }else{
151276 sqlite3SelectDelete(db, pSub);
151277 }
151278 if( db->mallocFailed ) rc = SQLITE_NOMEM;
@@ -160322,10 +160475,11 @@
160322 }
160323 #endif
160324 if( rc==SQLITE_OK ){
160325 sqlite3PCacheBufferSetup( sqlite3GlobalConfig.pPage,
160326 sqlite3GlobalConfig.szPage, sqlite3GlobalConfig.nPage);
 
160327 sqlite3GlobalConfig.isInit = 1;
160328 #ifdef SQLITE_EXTRA_INIT
160329 bRunExtraInit = 1;
160330 #endif
160331 }
@@ -163270,11 +163424,11 @@
163270 assert( SQLITE_OPEN_CREATE == 0x04 );
163271 testcase( (1<<(flags&7))==0x02 ); /* READONLY */
163272 testcase( (1<<(flags&7))==0x04 ); /* READWRITE */
163273 testcase( (1<<(flags&7))==0x40 ); /* READWRITE | CREATE */
163274 if( ((1<<(flags&7)) & 0x46)==0 ){
163275 rc = SQLITE_MISUSE_BKPT; /* IMP: R-65497-44594 */
163276 }else{
163277 rc = sqlite3ParseUri(zVfs, zFilename, &flags, &db->pVfs, &zOpen, &zErrMsg);
163278 }
163279 if( rc!=SQLITE_OK ){
163280 if( rc==SQLITE_NOMEM ) sqlite3OomFault(db);
@@ -171194,10 +171348,11 @@
171194 while( *pRc==SQLITE_OK && pLeft->bEof==0 ){
171195 memset(pDl->pList, 0, pDl->nList);
171196 fts3EvalNextRow(pCsr, pLeft, pRc);
171197 }
171198 }
 
171199 }
171200 }
171201 break;
171202 }
171203
@@ -182739,11 +182894,11 @@
182739 iStart = pExpr->iPhrase * p->nCol;
182740 }else{
182741 iStart = pExpr->iPhrase * ((p->nCol + 31) / 32);
182742 }
182743
182744 while( 1 ){
182745 int nHit = fts3ColumnlistCount(&pIter);
182746 if( (pPhrase->iColumn>=pTab->nColumn || pPhrase->iColumn==iCol) ){
182747 if( p->flag==FTS3_MATCHINFO_LHITS ){
182748 p->aMatchinfo[iStart + iCol] = (u32)nHit;
182749 }else if( nHit ){
@@ -184653,10 +184808,11 @@
184653 }
184654
184655 /* Append N bytes from zIn onto the end of the JsonString string.
184656 */
184657 static void jsonAppendRaw(JsonString *p, const char *zIn, u32 N){
 
184658 if( (N+p->nUsed >= p->nAlloc) && jsonGrow(p,N)!=0 ) return;
184659 memcpy(p->zBuf+p->nUsed, zIn, N);
184660 p->nUsed += N;
184661 }
184662
@@ -224664,11 +224820,11 @@
224664 int nArg, /* Number of args */
224665 sqlite3_value **apUnused /* Function arguments */
224666 ){
224667 assert( nArg==0 );
224668 UNUSED_PARAM2(nArg, apUnused);
224669 sqlite3_result_text(pCtx, "fts5: 2020-05-08 19:02:21 3a16c0ce4d8851f79f670d94786032c8007619154ece44647dc9cc5b1f9654ff", -1, SQLITE_TRANSIENT);
224670 }
224671
224672 /*
224673 ** Return true if zName is the extension on one of the shadow tables used
224674 ** by this module.
@@ -229447,12 +229603,12 @@
229447 }
229448 #endif /* SQLITE_CORE */
229449 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
229450
229451 /************** End of stmt.c ************************************************/
229452 #if __LINE__!=229452
229453 #undef SQLITE_SOURCE_ID
229454 #define SQLITE_SOURCE_ID "2020-05-08 19:02:21 3a16c0ce4d8851f79f670d94786032c8007619154ece44647dc9cc5b1f96alt2"
229455 #endif
229456 /* Return the source-id for this library */
229457 SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
229458 /************************** End of sqlite3.c ******************************/
229459
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1,8 +1,8 @@
1 /******************************************************************************
2 ** This file is an amalgamation of many separate C source files from SQLite
3 ** version 3.32.1. By combining all the individual C code files into this
4 ** single large file, the entire code can be compiled as a single translation
5 ** unit. This allows many compilers to do optimizations that would not be
6 ** possible if the files were compiled separately. Performance improvements
7 ** of 5% or more are commonly seen when SQLite is compiled as a single
8 ** translation unit.
@@ -1160,13 +1160,13 @@
1160 **
1161 ** See also: [sqlite3_libversion()],
1162 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
1163 ** [sqlite_version()] and [sqlite_source_id()].
1164 */
1165 #define SQLITE_VERSION "3.32.1"
1166 #define SQLITE_VERSION_NUMBER 3032001
1167 #define SQLITE_SOURCE_ID "2020-05-25 16:19:56 0c1fcf4711a2e66c813aed38cf41cd3e2123ee8eb6db98118086764c4ba83350"
1168
1169 /*
1170 ** CAPI3REF: Run-Time Library Version Numbers
1171 ** KEYWORDS: sqlite3_version sqlite3_sourceid
1172 **
@@ -6532,11 +6532,11 @@
6532 ** when first called if N is less than or equal to zero or if a memory
6533 ** allocate error occurs.
6534 **
6535 ** ^(The amount of space allocated by sqlite3_aggregate_context(C,N) is
6536 ** determined by the N parameter on first successful call. Changing the
6537 ** value of N in any subsequent call to sqlite3_aggregate_context() within
6538 ** the same aggregate function instance will not resize the memory
6539 ** allocation.)^ Within the xFinal callback, it is customary to set
6540 ** N=0 in calls to sqlite3_aggregate_context(C,N) so that no
6541 ** pointless memory allocations occur.
6542 **
@@ -17119,11 +17119,11 @@
17119 #define SQLITE_FUNC_EPHEM 0x0010 /* Ephemeral. Delete with VDBE */
17120 #define SQLITE_FUNC_NEEDCOLL 0x0020 /* sqlite3GetFuncCollSeq() might be called*/
17121 #define SQLITE_FUNC_LENGTH 0x0040 /* Built-in length() function */
17122 #define SQLITE_FUNC_TYPEOF 0x0080 /* Built-in typeof() function */
17123 #define SQLITE_FUNC_COUNT 0x0100 /* Built-in count(*) aggregate */
17124 /* 0x0200 -- available for reuse */
17125 #define SQLITE_FUNC_UNLIKELY 0x0400 /* Built-in unlikely() function */
17126 #define SQLITE_FUNC_CONSTANT 0x0800 /* Constant inputs give a constant output */
17127 #define SQLITE_FUNC_MINMAX 0x1000 /* True for min() and max() aggregates */
17128 #define SQLITE_FUNC_SLOCHNG 0x2000 /* "Slow Change". Value constant during a
17129 ** single query - might change over time */
@@ -17140,10 +17140,11 @@
17140 #define INLINEFUNC_coalesce 0
17141 #define INLINEFUNC_implies_nonnull_row 1
17142 #define INLINEFUNC_expr_implies_expr 2
17143 #define INLINEFUNC_expr_compare 3
17144 #define INLINEFUNC_affinity 4
17145 #define INLINEFUNC_iif 5
17146 #define INLINEFUNC_unlikely 99 /* Default case */
17147
17148 /*
17149 ** The following three macros, FUNCTION(), LIKEFUNC() and AGGREGATE() are
17150 ** used to create the initializers for the FuncDef structures.
@@ -17840,11 +17841,11 @@
17841 /*
17842 ** An instance of this structure contains information needed to generate
17843 ** code for a SELECT that contains aggregate functions.
17844 **
17845 ** If Expr.op==TK_AGG_COLUMN or TK_AGG_FUNCTION then Expr.pAggInfo is a
17846 ** pointer to this structure. The Expr.iAgg field is the index in
17847 ** AggInfo.aCol[] or AggInfo.aFunc[] of information needed to generate
17848 ** code for that node.
17849 **
17850 ** AggInfo.pGroupBy and AggInfo.aFunc.pExpr point to fields within the
17851 ** original Select structure that describes the SELECT statement. These
@@ -19079,10 +19080,13 @@
19080 SQLITE_PRIVATE int sqlite3WalkSelectExpr(Walker*, Select*);
19081 SQLITE_PRIVATE int sqlite3WalkSelectFrom(Walker*, Select*);
19082 SQLITE_PRIVATE int sqlite3ExprWalkNoop(Walker*, Expr*);
19083 SQLITE_PRIVATE int sqlite3SelectWalkNoop(Walker*, Select*);
19084 SQLITE_PRIVATE int sqlite3SelectWalkFail(Walker*, Select*);
19085 SQLITE_PRIVATE int sqlite3WalkerDepthIncrease(Walker*,Select*);
19086 SQLITE_PRIVATE void sqlite3WalkerDepthDecrease(Walker*,Select*);
19087
19088 #ifdef SQLITE_DEBUG
19089 SQLITE_PRIVATE void sqlite3SelectWalkAssert2(Walker*, Select*);
19090 #endif
19091
19092 /*
@@ -20064,12 +20068,14 @@
20068 # define sqlite3VtabInSync(db) ((db)->nVTrans>0 && (db)->aVTrans==0)
20069 #endif
20070 SQLITE_PRIVATE int sqlite3ReadOnlyShadowTables(sqlite3 *db);
20071 #ifndef SQLITE_OMIT_VIRTUALTABLE
20072 SQLITE_PRIVATE int sqlite3ShadowTableName(sqlite3 *db, const char *zName);
20073 SQLITE_PRIVATE int sqlite3IsShadowTableOf(sqlite3*,Table*,const char*);
20074 #else
20075 # define sqlite3ShadowTableName(A,B) 0
20076 # define sqlite3IsShadowTableOf(A,B,C) 0
20077 #endif
20078 SQLITE_PRIVATE int sqlite3VtabEponymousTableInit(Parse*,Module*);
20079 SQLITE_PRIVATE void sqlite3VtabEponymousTableClear(sqlite3*,Module*);
20080 SQLITE_PRIVATE void sqlite3VtabMakeWritable(Parse*,Table*);
20081 SQLITE_PRIVATE void sqlite3VtabBeginParse(Parse*, Token*, Token*, Token*, int);
@@ -27924,11 +27930,11 @@
27930 }
27931 }else{
27932 assert( sqlite3MemdebugHasType(p, (MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) );
27933 assert( sqlite3MemdebugNoType(p, (u8)~(MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) );
27934 sqlite3MemdebugSetType(p, MEMTYPE_HEAP);
27935 pNew = sqlite3Realloc(p, n);
27936 if( !pNew ){
27937 sqlite3OomFault(db);
27938 }
27939 sqlite3MemdebugSetType(pNew,
27940 (db->lookaside.bDisable==0 ? MEMTYPE_LOOKASIDE : MEMTYPE_HEAP));
@@ -28271,10 +28277,17 @@
28277 #ifndef SQLITE_PRINT_BUF_SIZE
28278 # define SQLITE_PRINT_BUF_SIZE 70
28279 #endif
28280 #define etBUFSIZE SQLITE_PRINT_BUF_SIZE /* Size of the output buffer */
28281
28282 /*
28283 ** Hard limit on the precision of floating-point conversions.
28284 */
28285 #ifndef SQLITE_PRINTF_PRECISION_LIMIT
28286 # define SQLITE_FP_PRECISION_LIMIT 100000000
28287 #endif
28288
28289 /*
28290 ** Render a string given by "fmt" into the StrAccum object.
28291 */
28292 SQLITE_API void sqlite3_str_vappendf(
28293 sqlite3_str *pAccum, /* Accumulate results here */
@@ -28471,10 +28484,12 @@
28484 ** precision The specified precision. The default
28485 ** is -1.
28486 ** xtype The class of the conversion.
28487 ** infop Pointer to the appropriate info struct.
28488 */
28489 assert( width>=0 );
28490 assert( precision>=(-1) );
28491 switch( xtype ){
28492 case etPOINTER:
28493 flag_long = sizeof(char*)==sizeof(i64) ? 2 :
28494 sizeof(char*)==sizeof(long int) ? 1 : 0;
28495 /* Fall through into the next case */
@@ -28592,10 +28607,15 @@
28607 }
28608 #ifdef SQLITE_OMIT_FLOATING_POINT
28609 length = 0;
28610 #else
28611 if( precision<0 ) precision = 6; /* Set default precision */
28612 #ifdef SQLITE_FP_PRECISION_LIMIT
28613 if( precision>SQLITE_FP_PRECISION_LIMIT ){
28614 precision = SQLITE_FP_PRECISION_LIMIT;
28615 }
28616 #endif
28617 if( realvalue<0.0 ){
28618 realvalue = -realvalue;
28619 prefix = '-';
28620 }else{
28621 prefix = flag_prefix;
@@ -28874,11 +28894,11 @@
28894 }else{
28895 escarg = va_arg(ap,char*);
28896 }
28897 isnull = escarg==0;
28898 if( isnull ) escarg = (xtype==etSQLESCAPE2 ? "NULL" : "(NULL)");
28899 /* For %q, %Q, and %w, the precision is the number of bytes (or
28900 ** characters if the ! flags is present) to use from the input.
28901 ** Because of the extra quoting characters inserted, the number
28902 ** of output characters may be larger than the precision.
28903 */
28904 k = precision;
@@ -29001,11 +29021,11 @@
29021 p->nAlloc = (int)szNew;
29022 }
29023 if( p->db ){
29024 zNew = sqlite3DbRealloc(p->db, zOld, p->nAlloc);
29025 }else{
29026 zNew = sqlite3Realloc(zOld, p->nAlloc);
29027 }
29028 if( zNew ){
29029 assert( p->zText!=0 || p->nChar==0 );
29030 if( !isMalloced(p) && p->nChar>0 ) memcpy(zNew, p->zText, p->nChar);
29031 p->zText = zNew;
@@ -29343,11 +29363,11 @@
29363 ** and segfaults if you give it a long long int.
29364 */
29365 SQLITE_PRIVATE void sqlite3DebugPrintf(const char *zFormat, ...){
29366 va_list ap;
29367 StrAccum acc;
29368 char zBuf[SQLITE_PRINT_BUF_SIZE*10];
29369 sqlite3StrAccumInit(&acc, 0, zBuf, sizeof(zBuf), 0);
29370 va_start(ap,zFormat);
29371 sqlite3_str_vappendf(&acc, zFormat, ap);
29372 va_end(ap);
29373 sqlite3StrAccumFinish(&acc);
@@ -29959,12 +29979,13 @@
29979 #else
29980 pWin = 0;
29981 #endif
29982 }
29983 if( pExpr->op==TK_AGG_FUNCTION ){
29984 sqlite3TreeViewLine(pView, "AGG_FUNCTION%d %Q%s iAgg=%d agg=%p",
29985 pExpr->op2, pExpr->u.zToken, zFlgs,
29986 pExpr->iAgg, pExpr->pAggInfo);
29987 }else if( pExpr->op2!=0 ){
29988 const char *zOp2;
29989 char zBuf[8];
29990 sqlite3_snprintf(sizeof(zBuf),zBuf,"0x%02x",pExpr->op2);
29991 zOp2 = zBuf;
@@ -30853,10 +30874,11 @@
30874 /* UTF-16 Little-endian -> UTF-8 */
30875 while( zIn<zTerm ){
30876 c = *(zIn++);
30877 c += (*(zIn++))<<8;
30878 if( c>=0xd800 && c<0xe000 ){
30879 #ifdef SQLITE_REPLACE_INVALID_UTF
30880 if( c>=0xdc00 || zIn>=zTerm ){
30881 c = 0xfffd;
30882 }else{
30883 int c2 = *(zIn++);
30884 c2 += (*(zIn++))<<8;
@@ -30865,19 +30887,27 @@
30887 c = 0xfffd;
30888 }else{
30889 c = ((c&0x3ff)<<10) + (c2&0x3ff) + 0x10000;
30890 }
30891 }
30892 #else
30893 if( zIn<zTerm ){
30894 int c2 = (*zIn++);
30895 c2 += ((*zIn++)<<8);
30896 c = (c2&0x03FF) + ((c&0x003F)<<10) + (((c&0x03C0)+0x0040)<<10);
30897 }
30898 #endif
30899 }
30900 WRITE_UTF8(z, c);
30901 }
30902 }else{
30903 /* UTF-16 Big-endian -> UTF-8 */
30904 while( zIn<zTerm ){
30905 c = (*(zIn++))<<8;
30906 c += *(zIn++);
30907 if( c>=0xd800 && c<0xe000 ){
30908 #ifdef SQLITE_REPLACE_INVALID_UTF
30909 if( c>=0xdc00 || zIn>=zTerm ){
30910 c = 0xfffd;
30911 }else{
30912 int c2 = (*(zIn++))<<8;
30913 c2 += *(zIn++);
@@ -30886,10 +30916,17 @@
30916 c = 0xfffd;
30917 }else{
30918 c = ((c&0x3ff)<<10) + (c2&0x3ff) + 0x10000;
30919 }
30920 }
30921 #else
30922 if( zIn<zTerm ){
30923 int c2 = ((*zIn++)<<8);
30924 c2 += (*zIn++);
30925 c = (c2&0x03FF) + ((c&0x003F)<<10) + (((c&0x03C0)+0x0040)<<10);
30926 }
30927 #endif
30928 }
30929 WRITE_UTF8(z, c);
30930 }
30931 }
30932 pMem->n = (int)(z - zOut);
@@ -45048,10 +45085,11 @@
45085 }
45086
45087 /* Forward references to VFS helper methods used for temporary files */
45088 static int winGetTempname(sqlite3_vfs *, char **);
45089 static int winIsDir(const void *);
45090 static BOOL winIsLongPathPrefix(const char *);
45091 static BOOL winIsDriveLetterAndColon(const char *);
45092
45093 /*
45094 ** Control and query of the open file handle.
45095 */
@@ -46817,11 +46855,13 @@
46855 pFile->pVfs = pVfs;
46856 pFile->h = h;
46857 if( isReadonly ){
46858 pFile->ctrlFlags |= WINFILE_RDONLY;
46859 }
46860 if( (flags & SQLITE_OPEN_MAIN_DB)
46861 && sqlite3_uri_boolean(zName, "psow", SQLITE_POWERSAFE_OVERWRITE)
46862 ){
46863 pFile->ctrlFlags |= WINFILE_PSOW;
46864 }
46865 pFile->lastErrno = NO_ERROR;
46866 pFile->zPath = zName;
46867 #if SQLITE_MAX_MMAP_SIZE>0
@@ -47026,10 +47066,21 @@
47066 *pResOut = rc;
47067 OSTRACE(("ACCESS name=%s, pResOut=%p, *pResOut=%d, rc=SQLITE_OK\n",
47068 zFilename, pResOut, *pResOut));
47069 return SQLITE_OK;
47070 }
47071
47072 /*
47073 ** Returns non-zero if the specified path name starts with the "long path"
47074 ** prefix.
47075 */
47076 static BOOL winIsLongPathPrefix(
47077 const char *zPathname
47078 ){
47079 return ( zPathname[0]=='\\' && zPathname[1]=='\\'
47080 && zPathname[2]=='?' && zPathname[3]=='\\' );
47081 }
47082
47083 /*
47084 ** Returns non-zero if the specified path name starts with a drive letter
47085 ** followed by a colon character.
47086 */
@@ -47091,14 +47142,15 @@
47142 DWORD nByte;
47143 void *zConverted;
47144 char *zOut;
47145 #endif
47146
47147 /* If this path name begins with "/X:" or "\\?\", where "X" is any
47148 ** alphabetic character, discard the initial "/" from the pathname.
47149 */
47150 if( zRelative[0]=='/' && (winIsDriveLetterAndColon(zRelative+1)
47151 || winIsLongPathPrefix(zRelative+1)) ){
47152 zRelative++;
47153 }
47154
47155 #if defined(__CYGWIN__)
47156 SimulateIOError( return SQLITE_ERROR );
@@ -47850,11 +47902,11 @@
47902 if( newSz>p->szMax ){
47903 return SQLITE_FULL;
47904 }
47905 newSz *= 2;
47906 if( newSz>p->szMax ) newSz = p->szMax;
47907 pNew = sqlite3Realloc(p->aData, newSz);
47908 if( pNew==0 ) return SQLITE_NOMEM;
47909 p->aData = pNew;
47910 p->szAlloc = newSz;
47911 return SQLITE_OK;
47912 }
@@ -48297,14 +48349,15 @@
48349 */
48350 SQLITE_PRIVATE int sqlite3MemdbInit(void){
48351 sqlite3_vfs *pLower = sqlite3_vfs_find(0);
48352 int sz = pLower->szOsFile;
48353 memdb_vfs.pAppData = pLower;
48354 /* The following conditional can only be true when compiled for
48355 ** Windows x86 and SQLITE_MAX_MMAP_SIZE=0. We always leave
48356 ** it in, to be safe, but it is marked as NO_TEST since there
48357 ** is no way to reach it under most builds. */
48358 if( sz<sizeof(MemFile) ) sz = sizeof(MemFile); /*NO_TEST*/
48359 memdb_vfs.szOsFile = sz;
48360 return sqlite3_vfs_register(&memdb_vfs, 0);
48361 }
48362 #endif /* SQLITE_ENABLE_DESERIALIZE */
48363
@@ -59820,11 +59873,11 @@
59873
59874 /* Enlarge the pWal->apWiData[] array if required */
59875 if( pWal->nWiData<=iPage ){
59876 sqlite3_int64 nByte = sizeof(u32*)*(iPage+1);
59877 volatile u32 **apNew;
59878 apNew = (volatile u32 **)sqlite3Realloc((void *)pWal->apWiData, nByte);
59879 if( !apNew ){
59880 *ppPage = 0;
59881 return SQLITE_NOMEM_BKPT;
59882 }
59883 memset((void*)&apNew[pWal->nWiData], 0,
@@ -59941,29 +59994,47 @@
59994
59995 aOut[0] = s1;
59996 aOut[1] = s2;
59997 }
59998
59999 /*
60000 ** If there is the possibility of concurrent access to the SHM file
60001 ** from multiple threads and/or processes, then do a memory barrier.
60002 */
60003 static void walShmBarrier(Wal *pWal){
60004 if( pWal->exclusiveMode!=WAL_HEAPMEMORY_MODE ){
60005 sqlite3OsShmBarrier(pWal->pDbFd);
60006 }
60007 }
60008
60009 /*
60010 ** Add the SQLITE_NO_TSAN as part of the return-type of a function
60011 ** definition as a hint that the function contains constructs that
60012 ** might give false-positive TSAN warnings.
60013 **
60014 ** See tag-20200519-1.
60015 */
60016 #if defined(__clang__) && !defined(SQLITE_NO_TSAN)
60017 # define SQLITE_NO_TSAN __attribute__((no_sanitize_thread))
60018 #else
60019 # define SQLITE_NO_TSAN
60020 #endif
60021
60022 /*
60023 ** Write the header information in pWal->hdr into the wal-index.
60024 **
60025 ** The checksum on pWal->hdr is updated before it is written.
60026 */
60027 static SQLITE_NO_TSAN void walIndexWriteHdr(Wal *pWal){
60028 volatile WalIndexHdr *aHdr = walIndexHdr(pWal);
60029 const int nCksum = offsetof(WalIndexHdr, aCksum);
60030
60031 assert( pWal->writeLock );
60032 pWal->hdr.isInit = 1;
60033 pWal->hdr.iVersion = WALINDEX_MAX_VERSION;
60034 walChecksumBytes(1, (u8*)&pWal->hdr, nCksum, 0, pWal->hdr.aCksum);
60035 /* Possible TSAN false-positive. See tag-20200519-1 */
60036 memcpy((void*)&aHdr[1], (const void*)&pWal->hdr, sizeof(WalIndexHdr));
60037 walShmBarrier(pWal);
60038 memcpy((void*)&aHdr[0], (const void*)&pWal->hdr, sizeof(WalIndexHdr));
60039 }
60040
@@ -61074,11 +61145,11 @@
61145 pWal->nCkpt++;
61146 pWal->hdr.mxFrame = 0;
61147 sqlite3Put4byte((u8*)&aSalt[0], 1 + sqlite3Get4byte((u8*)&aSalt[0]));
61148 memcpy(&pWal->hdr.aSalt[1], &salt1, 4);
61149 walIndexWriteHdr(pWal);
61150 AtomicStore(&pInfo->nBackfill, 0);
61151 pInfo->nBackfillAttempted = 0;
61152 pInfo->aReadMark[1] = 0;
61153 for(i=2; i<WAL_NREADER; i++) pInfo->aReadMark[i] = READMARK_NOT_USED;
61154 assert( pInfo->aReadMark[0]==0 );
61155 }
@@ -61149,36 +61220,17 @@
61220 ** cannot be backfilled from the WAL.
61221 */
61222 mxSafeFrame = pWal->hdr.mxFrame;
61223 mxPage = pWal->hdr.nPage;
61224 for(i=1; i<WAL_NREADER; i++){
61225 u32 y = AtomicLoad(pInfo->aReadMark+i);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61226 if( mxSafeFrame>y ){
61227 assert( y<=pWal->hdr.mxFrame );
61228 rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_READ_LOCK(i), 1);
61229 if( rc==SQLITE_OK ){
61230 u32 iMark = (i==1 ? mxSafeFrame : READMARK_NOT_USED);
61231 AtomicStore(pInfo->aReadMark+i, iMark);
61232 walUnlockExclusive(pWal, WAL_READ_LOCK(i), 1);
61233 }else if( rc==SQLITE_BUSY ){
61234 mxSafeFrame = y;
61235 xBusy = 0;
61236 }else{
@@ -61192,11 +61244,11 @@
61244 rc = walIteratorInit(pWal, pInfo->nBackfill, &pIter);
61245 assert( rc==SQLITE_OK || pIter==0 );
61246 }
61247
61248 if( pIter
61249 && (rc = walBusyLock(pWal,xBusy,pBusyArg,WAL_READ_LOCK(0),1))==SQLITE_OK
61250 ){
61251 u32 nBackfill = pInfo->nBackfill;
61252
61253 pInfo->nBackfillAttempted = mxSafeFrame;
61254
@@ -61248,11 +61300,11 @@
61300 if( rc==SQLITE_OK ){
61301 rc = sqlite3OsSync(pWal->pDbFd, CKPT_SYNC_FLAGS(sync_flags));
61302 }
61303 }
61304 if( rc==SQLITE_OK ){
61305 AtomicStore(&pInfo->nBackfill, mxSafeFrame);
61306 }
61307 }
61308
61309 /* Release the reader lock held while backfilling */
61310 walUnlockExclusive(pWal, WAL_READ_LOCK(0), 1);
@@ -61407,11 +61459,11 @@
61459 ** and *pChanged is set to 1.
61460 **
61461 ** If the checksum cannot be verified return non-zero. If the header
61462 ** is read successfully and the checksum verified, return zero.
61463 */
61464 static SQLITE_NO_TSAN int walIndexTryHdr(Wal *pWal, int *pChanged){
61465 u32 aCksum[2]; /* Checksum on the header content */
61466 WalIndexHdr h1, h2; /* Two copies of the header content */
61467 WalIndexHdr volatile *aHdr; /* Header in shared memory */
61468
61469 /* The first page of the wal-index must be mapped at this point. */
@@ -61420,17 +61472,23 @@
61472 /* Read the header. This might happen concurrently with a write to the
61473 ** same area of shared memory on a different CPU in a SMP,
61474 ** meaning it is possible that an inconsistent snapshot is read
61475 ** from the file. If this happens, return non-zero.
61476 **
61477 ** tag-20200519-1:
61478 ** There are two copies of the header at the beginning of the wal-index.
61479 ** When reading, read [0] first then [1]. Writes are in the reverse order.
61480 ** Memory barriers are used to prevent the compiler or the hardware from
61481 ** reordering the reads and writes. TSAN and similar tools can sometimes
61482 ** give false-positive warnings about these accesses because the tools do not
61483 ** account for the double-read and the memory barrier. The use of mutexes
61484 ** here would be problematic as the memory being accessed is potentially
61485 ** shared among multiple processes and not all mutex implementions work
61486 ** reliably in that environment.
61487 */
61488 aHdr = walIndexHdr(pWal);
61489 memcpy(&h1, (void *)&aHdr[0], sizeof(h1)); /* Possible TSAN false-positive */
61490 walShmBarrier(pWal);
61491 memcpy(&h2, (void *)&aHdr[1], sizeof(h2));
61492
61493 if( memcmp(&h1, &h2, sizeof(h1))!=0 ){
61494 return 1; /* Dirty read */
@@ -61871,11 +61929,11 @@
61929 }
61930
61931 assert( pWal->nWiData>0 );
61932 assert( pWal->apWiData[0]!=0 );
61933 pInfo = walCkptInfo(pWal);
61934 if( !useWal && AtomicLoad(&pInfo->nBackfill)==pWal->hdr.mxFrame
61935 #ifdef SQLITE_ENABLE_SNAPSHOT
61936 && (pWal->pSnapshot==0 || pWal->hdr.mxFrame==0)
61937 #endif
61938 ){
61939 /* The WAL has been completely backfilled (or it is empty).
@@ -62038,11 +62096,11 @@
62096 void *pBuf2 = sqlite3_malloc(szPage);
62097 if( pBuf1==0 || pBuf2==0 ){
62098 rc = SQLITE_NOMEM;
62099 }else{
62100 u32 i = pInfo->nBackfillAttempted;
62101 for(i=pInfo->nBackfillAttempted; i>AtomicLoad(&pInfo->nBackfill); i--){
62102 WalHashLoc sLoc; /* Hash table location */
62103 u32 pgno; /* Page number in db file */
62104 i64 iDbOff; /* Offset of db file entry */
62105 i64 iWalOff; /* Offset of wal file entry */
62106
@@ -62093,16 +62151,18 @@
62151 ** needs to be flushed.
62152 */
62153 SQLITE_PRIVATE int sqlite3WalBeginReadTransaction(Wal *pWal, int *pChanged){
62154 int rc; /* Return code */
62155 int cnt = 0; /* Number of TryBeginRead attempts */
62156 #ifdef SQLITE_ENABLE_SNAPSHOT
62157 int bChanged = 0;
62158 WalIndexHdr *pSnapshot = pWal->pSnapshot;
62159 #endif
62160
62161 assert( pWal->ckptLock==0 );
62162
62163 #ifdef SQLITE_ENABLE_SNAPSHOT
 
 
62164 if( pSnapshot ){
62165 if( memcmp(pSnapshot, &pWal->hdr, sizeof(WalIndexHdr))!=0 ){
62166 bChanged = 1;
62167 }
62168
@@ -62267,26 +62327,28 @@
62327 for(iHash=walFramePage(iLast); iHash>=iMinHash; iHash--){
62328 WalHashLoc sLoc; /* Hash table location */
62329 int iKey; /* Hash slot index */
62330 int nCollide; /* Number of hash collisions remaining */
62331 int rc; /* Error code */
62332 u32 iH;
62333
62334 rc = walHashGet(pWal, iHash, &sLoc);
62335 if( rc!=SQLITE_OK ){
62336 return rc;
62337 }
62338 nCollide = HASHTABLE_NSLOT;
62339 iKey = walHash(pgno);
62340 while( (iH = AtomicLoad(&sLoc.aHash[iKey]))!=0 ){
62341 u32 iFrame = iH + sLoc.iZero;
62342 if( iFrame<=iLast && iFrame>=pWal->minFrame && sLoc.aPgno[iH]==pgno ){
62343 assert( iFrame>iRead || CORRUPT_DB );
62344 iRead = iFrame;
62345 }
62346 if( (nCollide--)==0 ){
62347 return SQLITE_CORRUPT_BKPT;
62348 }
62349 iKey = walNextHash(iKey);
62350 }
62351 if( iRead ) break;
62352 }
62353
62354 #ifdef SQLITE_ENABLE_EXPENSIVE_ASSERT
@@ -79307,10 +79369,11 @@
79369 char *zP4;
79370 char *zCom;
79371 sqlite3 dummyDb;
79372 static const char *zFormat1 = "%4d %-13s %4d %4d %4d %-13s %.2X %s\n";
79373 if( pOut==0 ) pOut = stdout;
79374 sqlite3BeginBenignMalloc();
79375 dummyDb.mallocFailed = 1;
79376 zP4 = sqlite3VdbeDisplayP4(&dummyDb, pOp);
79377 #ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS
79378 zCom = sqlite3VdbeDisplayComment(0, pOp, zP4);
79379 #else
@@ -79325,10 +79388,11 @@
79388 zCom ? zCom : ""
79389 );
79390 fflush(pOut);
79391 sqlite3_free(zP4);
79392 sqlite3_free(zCom);
79393 sqlite3EndBenignMalloc();
79394 }
79395 #endif
79396
79397 /*
79398 ** Initialize an array of N Mem element.
@@ -84066,11 +84130,11 @@
84130 p->db->errCode = SQLITE_OK;
84131
84132 /* If the bit corresponding to this variable in Vdbe.expmask is set, then
84133 ** binding a new value to this variable invalidates the current query plan.
84134 **
84135 ** IMPLEMENTATION-OF: R-57496-20354 If the specific value bound to a host
84136 ** parameter in the WHERE clause might influence the choice of query plan
84137 ** for a statement, then the statement will be automatically recompiled,
84138 ** as if there had been a schema change, on the first sqlite3_step() call
84139 ** following any change to the bindings of that parameter.
84140 */
@@ -96365,12 +96429,12 @@
96429 *************************************************************************
96430 **
96431 ** This file implements virtual-tables for examining the bytecode content
96432 ** of a prepared statement.
96433 */
 
96434 /* #include "sqliteInt.h" */
96435 #if defined(SQLITE_ENABLE_BYTECODE_VTAB) && !defined(SQLITE_OMIT_VIRTUALTABLE)
96436 /* #include "vdbeInt.h" */
96437
96438 /* An instance of the bytecode() table-valued function.
96439 */
96440 typedef struct bytecodevtab bytecodevtab;
@@ -96771,10 +96835,12 @@
96835 if( rc==SQLITE_OK ){
96836 rc = sqlite3_create_module(db, "tables_used", &bytecodevtabModule, &db);
96837 }
96838 return rc;
96839 }
96840 #elif defined(SQLITE_ENABLE_BYTECODE_VTAB)
96841 SQLITE_PRIVATE int sqlite3VdbeBytecodeVtabInit(sqlite3 *db){ return SQLITE_OK; }
96842 #endif /* SQLITE_ENABLE_BYTECODE_VTAB */
96843
96844 /************** End of vdbevtab.c ********************************************/
96845 /************** Begin file memjournal.c **************************************/
96846 /*
@@ -97416,10 +97482,47 @@
97482 }
97483 p = p->pPrior;
97484 }while( p!=0 );
97485 return WRC_Continue;
97486 }
97487
97488 /* Increase the walkerDepth when entering a subquery, and
97489 ** descrease when leaving the subquery.
97490 */
97491 SQLITE_PRIVATE int sqlite3WalkerDepthIncrease(Walker *pWalker, Select *pSelect){
97492 UNUSED_PARAMETER(pSelect);
97493 pWalker->walkerDepth++;
97494 return WRC_Continue;
97495 }
97496 SQLITE_PRIVATE void sqlite3WalkerDepthDecrease(Walker *pWalker, Select *pSelect){
97497 UNUSED_PARAMETER(pSelect);
97498 pWalker->walkerDepth--;
97499 }
97500
97501
97502 /*
97503 ** No-op routine for the parse-tree walker.
97504 **
97505 ** When this routine is the Walker.xExprCallback then expression trees
97506 ** are walked without any actions being taken at each node. Presumably,
97507 ** when this routine is used for Walker.xExprCallback then
97508 ** Walker.xSelectCallback is set to do something useful for every
97509 ** subquery in the parser tree.
97510 */
97511 SQLITE_PRIVATE int sqlite3ExprWalkNoop(Walker *NotUsed, Expr *NotUsed2){
97512 UNUSED_PARAMETER2(NotUsed, NotUsed2);
97513 return WRC_Continue;
97514 }
97515
97516 /*
97517 ** No-op routine for the parse-tree walker for SELECT statements.
97518 ** subquery in the parser tree.
97519 */
97520 SQLITE_PRIVATE int sqlite3SelectWalkNoop(Walker *NotUsed, Select *NotUsed2){
97521 UNUSED_PARAMETER2(NotUsed, NotUsed2);
97522 return WRC_Continue;
97523 }
97524
97525 /************** End of walker.c **********************************************/
97526 /************** Begin file resolve.c *****************************************/
97527 /*
97528 ** 2008 August 18
@@ -97445,10 +97548,12 @@
97548 ** This needs to occur when copying a TK_AGG_FUNCTION node from an
97549 ** outer query into an inner subquery.
97550 **
97551 ** incrAggFunctionDepth(pExpr,n) is the main routine. incrAggDepth(..)
97552 ** is a helper function - a callback for the tree walker.
97553 **
97554 ** See also the sqlite3WindowExtraAggFuncDepth() routine in window.c
97555 */
97556 static int incrAggDepth(Walker *pWalker, Expr *pExpr){
97557 if( pExpr->op==TK_AGG_FUNCTION ) pExpr->op2 += pWalker->u.n;
97558 return WRC_Continue;
97559 }
@@ -103075,10 +103180,17 @@
103180 }
103181 setDoNotMergeFlagOnCopy(v);
103182 sqlite3VdbeResolveLabel(v, endCoalesce);
103183 break;
103184 }
103185 case INLINEFUNC_iif: {
103186 Expr caseExpr;
103187 memset(&caseExpr, 0, sizeof(caseExpr));
103188 caseExpr.op = TK_CASE;
103189 caseExpr.x.pList = pFarg;
103190 return sqlite3ExprCodeTarget(pParse, &caseExpr, target);
103191 }
103192
103193 default: {
103194 /* The UNLIKELY() function is a no-op. The result is the value
103195 ** of the first argument.
103196 */
@@ -103179,11 +103291,14 @@
103291 op = pExpr->op;
103292 }
103293 switch( op ){
103294 case TK_AGG_COLUMN: {
103295 AggInfo *pAggInfo = pExpr->pAggInfo;
103296 struct AggInfo_col *pCol;
103297 assert( pAggInfo!=0 );
103298 assert( pExpr->iAgg>=0 && pExpr->iAgg<pAggInfo->nColumn );
103299 pCol = &pAggInfo->aCol[pExpr->iAgg];
103300 if( !pAggInfo->directMode ){
103301 assert( pCol->iMem>0 );
103302 return pCol->iMem;
103303 }else if( pAggInfo->useSortingIdx ){
103304 Table *pTab = pCol->pTab;
@@ -103479,11 +103594,14 @@
103594 sqlite3VdbeJumpHere(v, addr);
103595 break;
103596 }
103597 case TK_AGG_FUNCTION: {
103598 AggInfo *pInfo = pExpr->pAggInfo;
103599 if( pInfo==0
103600 || NEVER(pExpr->iAgg<0)
103601 || NEVER(pExpr->iAgg>=pInfo->nFunc)
103602 ){
103603 assert( !ExprHasProperty(pExpr, EP_IntValue) );
103604 sqlite3ErrorMsg(pParse, "misuse of aggregate: %s()", pExpr->u.zToken);
103605 }else{
103606 return pInfo->aFunc[pExpr->iAgg].iMem;
103607 }
@@ -105235,19 +105353,10 @@
105353 }
105354 }
105355 }
105356 return WRC_Continue;
105357 }
 
 
 
 
 
 
 
 
 
105358
105359 /*
105360 ** Analyze the pExpr expression looking for aggregate functions and
105361 ** for variables that need to be added to AggInfo object that pNC->pAggInfo
105362 ** points to. Additional entries are made on the AggInfo object as
@@ -105257,12 +105366,12 @@
105366 ** analyzed by sqlite3ResolveExprNames().
105367 */
105368 SQLITE_PRIVATE void sqlite3ExprAnalyzeAggregates(NameContext *pNC, Expr *pExpr){
105369 Walker w;
105370 w.xExprCallback = analyzeAggregate;
105371 w.xSelectCallback = sqlite3WalkerDepthIncrease;
105372 w.xSelectCallback2 = sqlite3WalkerDepthDecrease;
105373 w.walkerDepth = 0;
105374 w.u.pNC = pNC;
105375 w.pParse = 0;
105376 assert( pNC->pSrcList!=0 );
105377 sqlite3WalkExpr(&w, pExpr);
@@ -105497,11 +105606,14 @@
105606 if( !zName ) goto exit_rename_table;
105607
105608 /* Check that a table or index named 'zName' does not already exist
105609 ** in database iDb. If so, this is an error.
105610 */
105611 if( sqlite3FindTable(db, zName, zDb)
105612 || sqlite3FindIndex(db, zName, zDb)
105613 || sqlite3IsShadowTableOf(db, pTab, zName)
105614 ){
105615 sqlite3ErrorMsg(pParse,
105616 "there is already another table or index with this name: %s", zName);
105617 goto exit_rename_table;
105618 }
105619
@@ -110244,26 +110356,43 @@
110356 ** exists */
110357 if( db->auth.authLevel<UAUTH_Admin && sqlite3UserAuthTable(zName)!=0 ){
110358 return 0;
110359 }
110360 #endif
110361 if( zDatabase ){
110362 for(i=0; i<db->nDb; i++){
110363 if( sqlite3StrICmp(zDatabase, db->aDb[i].zDbSName)==0 ) break;
110364 }
110365 if( i>=db->nDb ){
110366 /* No match against the official names. But always match "main"
110367 ** to schema 0 as a legacy fallback. */
110368 if( sqlite3StrICmp(zDatabase,"main")==0 ){
110369 i = 0;
110370 }else{
110371 return 0;
110372 }
110373 }
110374 p = sqlite3HashFind(&db->aDb[i].pSchema->tblHash, zName);
110375 if( p==0 && i==1 && sqlite3StrICmp(zName, MASTER_NAME)==0 ){
110376 /* All temp.sqlite_master to be an alias for sqlite_temp_master */
110377 p = sqlite3HashFind(&db->aDb[1].pSchema->tblHash, TEMP_MASTER_NAME);
110378 }
110379 }else{
110380 /* Match against TEMP first */
110381 p = sqlite3HashFind(&db->aDb[1].pSchema->tblHash, zName);
110382 if( p ) return p;
110383 /* The main database is second */
110384 p = sqlite3HashFind(&db->aDb[0].pSchema->tblHash, zName);
110385 if( p ) return p;
110386 /* Attached databases are in order of attachment */
110387 for(i=2; i<db->nDb; i++){
110388 assert( sqlite3SchemaMutexHeld(db, i, 0) );
110389 p = sqlite3HashFind(&db->aDb[i].pSchema->tblHash, zName);
110390 if( p ) break;
110391 }
110392 }
110393 return p;
110394 }
110395
110396 /*
110397 ** Locate the in-memory structure that describes a particular database
110398 ** table given the name of that table and (optionally) the name of the
@@ -112063,10 +112192,32 @@
112192 assert( pPk->nColumn==j );
112193 assert( pTab->nNVCol<=j );
112194 recomputeColumnsNotIndexed(pPk);
112195 }
112196
112197
112198 #ifndef SQLITE_OMIT_VIRTUALTABLE
112199 /*
112200 ** Return true if pTab is a virtual table and zName is a shadow table name
112201 ** for that virtual table.
112202 */
112203 SQLITE_PRIVATE int sqlite3IsShadowTableOf(sqlite3 *db, Table *pTab, const char *zName){
112204 int nName; /* Length of zName */
112205 Module *pMod; /* Module for the virtual table */
112206
112207 if( !IsVirtual(pTab) ) return 0;
112208 nName = sqlite3Strlen30(pTab->zName);
112209 if( sqlite3_strnicmp(zName, pTab->zName, nName)!=0 ) return 0;
112210 if( zName[nName]!='_' ) return 0;
112211 pMod = (Module*)sqlite3HashFind(&db->aModule, pTab->azModuleArg[0]);
112212 if( pMod==0 ) return 0;
112213 if( pMod->pModule->iVersion<3 ) return 0;
112214 if( pMod->pModule->xShadowName==0 ) return 0;
112215 return pMod->pModule->xShadowName(zName+nName+1);
112216 }
112217 #endif /* ifndef SQLITE_OMIT_VIRTUALTABLE */
112218
112219 #ifndef SQLITE_OMIT_VIRTUALTABLE
112220 /*
112221 ** Return true if zName is a shadow table name in the current database
112222 ** connection.
112223 **
@@ -112074,26 +112225,21 @@
112225 ** restored to its original value prior to this routine returning.
112226 */
112227 SQLITE_PRIVATE int sqlite3ShadowTableName(sqlite3 *db, const char *zName){
112228 char *zTail; /* Pointer to the last "_" in zName */
112229 Table *pTab; /* Table that zName is a shadow of */
 
 
112230 zTail = strrchr(zName, '_');
112231 if( zTail==0 ) return 0;
112232 *zTail = 0;
112233 pTab = sqlite3FindTable(db, zName, 0);
112234 *zTail = '_';
112235 if( pTab==0 ) return 0;
112236 if( !IsVirtual(pTab) ) return 0;
112237 return sqlite3IsShadowTableOf(db, pTab, zName);
 
 
 
 
112238 }
112239 #endif /* ifndef SQLITE_OMIT_VIRTUALTABLE */
112240
112241
112242 #ifdef SQLITE_DEBUG
112243 /*
112244 ** Mark all nodes of an expression as EP_Immutable, indicating that
112245 ** they should not be changed. Expressions attached to a table or
@@ -117780,11 +117926,11 @@
117926 if( (cntExpand&(cntExpand-1))==0 ){
117927 /* Grow the size of the output buffer only on substitutions
117928 ** whose index is a power of two: 1, 2, 4, 8, 16, 32, ... */
117929 u8 *zOld;
117930 zOld = zOut;
117931 zOut = sqlite3Realloc(zOut, (int)nOut + (nOut - nStr - 1));
117932 if( zOut==0 ){
117933 sqlite3_result_error_nomem(context);
117934 sqlite3_free(zOld);
117935 return;
117936 }
@@ -118477,11 +118623,11 @@
118623 FUNCTION(round, 2, 0, 0, roundFunc ),
118624 #endif
118625 FUNCTION(upper, 1, 0, 0, upperFunc ),
118626 FUNCTION(lower, 1, 0, 0, lowerFunc ),
118627 FUNCTION(hex, 1, 0, 0, hexFunc ),
118628 INLINE_FUNC(ifnull, 2, INLINEFUNC_coalesce, 0 ),
118629 VFUNCTION(random, 0, 0, 0, randomFunc ),
118630 VFUNCTION(randomblob, 1, 0, 0, randomBlob ),
118631 FUNCTION(nullif, 2, 0, 1, nullifFunc ),
118632 DFUNCTION(sqlite_version, 0, 0, 0, versionFunc ),
118633 DFUNCTION(sqlite_source_id, 0, 0, 0, sourceidFunc ),
@@ -118517,11 +118663,12 @@
118663 #ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION
118664 FUNCTION(unknown, -1, 0, 0, unknownFunc ),
118665 #endif
118666 FUNCTION(coalesce, 1, 0, 0, 0 ),
118667 FUNCTION(coalesce, 0, 0, 0, 0 ),
118668 INLINE_FUNC(coalesce, -1, INLINEFUNC_coalesce, 0 ),
118669 INLINE_FUNC(iif, 3, INLINEFUNC_iif, 0 ),
118670 };
118671 #ifndef SQLITE_OMIT_ALTERTABLE
118672 sqlite3AlterFunctions();
118673 #endif
118674 sqlite3WindowFunctions();
@@ -121942,11 +122089,11 @@
122089 }
122090 if( bAffinityDone==0 && (pUpIdx==0 || pUpIdx==pIdx) ){
122091 sqlite3TableAffinity(v, pTab, regNewData+1);
122092 bAffinityDone = 1;
122093 }
122094 VdbeNoopComment((v, "prep index %s", pIdx->zName));
122095 iThisCur = iIdxCur+ix;
122096
122097
122098 /* Skip partial indices for which the WHERE clause is not true */
122099 if( pIdx->pPartIdxWhere ){
@@ -133914,33 +134061,10 @@
134061 }
134062 }
134063 return WRC_Continue;
134064 }
134065
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
134066 #if SQLITE_DEBUG
134067 /*
134068 ** Always assert. This xSelectCallback2 implementation proves that the
134069 ** xSelectCallback2 is never invoked.
134070 */
@@ -135107,11 +135231,11 @@
135231 sAggInfo.mxReg = pParse->nMem;
135232 if( db->mallocFailed ) goto select_end;
135233 #if SELECTTRACE_ENABLED
135234 if( sqlite3SelectTrace & 0x400 ){
135235 int ii;
135236 SELECTTRACE(0x400,pParse,p,("After aggregate analysis %p:\n", &sAggInfo));
135237 sqlite3TreeViewSelect(0, p, 0);
135238 for(ii=0; ii<sAggInfo.nColumn; ii++){
135239 sqlite3DebugPrintf("agg-column[%d] iMem=%d\n",
135240 ii, sAggInfo.aCol[ii].iMem);
135241 sqlite3TreeViewExpr(0, sAggInfo.aCol[ii].pExpr, 0);
@@ -135570,11 +135694,11 @@
135694 need = nCol;
135695 }
135696 if( p->nData + need > p->nAlloc ){
135697 char **azNew;
135698 p->nAlloc = p->nAlloc*2 + need;
135699 azNew = sqlite3Realloc( p->azResult, sizeof(char*)*p->nAlloc );
135700 if( azNew==0 ) goto malloc_failed;
135701 p->azResult = azNew;
135702 }
135703
135704 /* If this is the first row, then generate an extra row containing
@@ -135679,11 +135803,11 @@
135803 sqlite3_free_table(&res.azResult[1]);
135804 return rc;
135805 }
135806 if( res.nAlloc>res.nData ){
135807 char **azNew;
135808 azNew = sqlite3Realloc( res.azResult, sizeof(char*)*res.nData );
135809 if( azNew==0 ){
135810 sqlite3_free_table(&res.azResult[1]);
135811 db->errCode = SQLITE_NOMEM;
135812 return SQLITE_NOMEM_BKPT;
135813 }
@@ -136969,14 +137093,14 @@
137093 ** Therefore, the P4 parameter is only required if the default value for
137094 ** the column is a literal number, string or null. The sqlite3ValueFromExpr()
137095 ** function is capable of transforming these types of expressions into
137096 ** sqlite3_value objects.
137097 **
137098 ** If column as REAL affinity and the table is an ordinary b-tree table
137099 ** (not a virtual table) then the value might have been stored as an
137100 ** integer. In that case, add an OP_RealAffinity opcode to make sure
137101 ** it has been converted into REAL.
137102 */
137103 SQLITE_PRIVATE void sqlite3ColumnDefault(Vdbe *v, Table *pTab, int i, int iReg){
137104 assert( pTab!=0 );
137105 if( !pTab->pSelect ){
137106 sqlite3_value *pValue = 0;
@@ -136989,11 +137113,11 @@
137113 if( pValue ){
137114 sqlite3VdbeAppendP4(v, pValue, P4_MEM);
137115 }
137116 }
137117 #ifndef SQLITE_OMIT_FLOATING_POINT
137118 if( pTab->aCol[i].affinity==SQLITE_AFF_REAL && !IsVirtual(pTab) ){
137119 sqlite3VdbeAddOp1(v, OP_RealAffinity, iReg);
137120 }
137121 #endif
137122 }
137123
@@ -139838,11 +139962,11 @@
139962 assert( IsVirtual(pTab) );
139963 for(i=0; i<pToplevel->nVtabLock; i++){
139964 if( pTab==pToplevel->apVtabLock[i] ) return;
139965 }
139966 n = (pToplevel->nVtabLock+1)*sizeof(pToplevel->apVtabLock[0]);
139967 apVtabLock = sqlite3Realloc(pToplevel->apVtabLock, n);
139968 if( apVtabLock ){
139969 pToplevel->apVtabLock = apVtabLock;
139970 pToplevel->apVtabLock[pToplevel->nVtabLock++] = pTab;
139971 }else{
139972 sqlite3OomFault(pToplevel->db);
@@ -151130,24 +151254,47 @@
151254 ){
151255 if( pAppend ){
151256 int i;
151257 int nInit = pList ? pList->nExpr : 0;
151258 for(i=0; i<pAppend->nExpr; i++){
 
151259 Expr *pDup = sqlite3ExprDup(pParse->db, pAppend->a[i].pExpr, 0);
151260 assert( pDup==0 || !ExprHasProperty(pDup, EP_MemToken) );
151261 if( bIntToNull && pDup ){
151262 int iDummy;
151263 Expr *pSub;
151264 for(pSub=pDup; ExprHasProperty(pSub, EP_Skip); pSub=pSub->pLeft){
151265 assert( pSub );
151266 }
151267 if( sqlite3ExprIsInteger(pSub, &iDummy) ){
151268 pSub->op = TK_NULL;
151269 pSub->flags &= ~(EP_IntValue|EP_IsTrue|EP_IsFalse);
151270 pSub->u.zToken = 0;
151271 }
151272 }
151273 pList = sqlite3ExprListAppend(pParse, pList, pDup);
151274 if( pList ) pList->a[nInit+i].sortFlags = pAppend->a[i].sortFlags;
151275 }
151276 }
151277 return pList;
151278 }
151279
151280 /*
151281 ** When rewriting a query, if the new subquery in the FROM clause
151282 ** contains TK_AGG_FUNCTION nodes that refer to an outer query,
151283 ** then we have to increase the Expr->op2 values of those nodes
151284 ** due to the extra subquery layer that was added.
151285 **
151286 ** See also the incrAggDepth() routine in resolve.c
151287 */
151288 static int sqlite3WindowExtraAggFuncDepth(Walker *pWalker, Expr *pExpr){
151289 if( pExpr->op==TK_AGG_FUNCTION
151290 && pExpr->op2>=pWalker->walkerDepth
151291 ){
151292 pExpr->op2++;
151293 }
151294 return WRC_Continue;
151295 }
151296
151297 /*
151298 ** If the SELECT statement passed as the second argument does not invoke
151299 ** any SQL window functions, this function is a no-op. Otherwise, it
151300 ** rewrites the SELECT statement so that window function xStep functions
@@ -151254,10 +151401,11 @@
151401 pParse, pSublist, pSrc, pWhere, pGroupBy, pHaving, pSort, 0, 0
151402 );
151403 p->pSrc = sqlite3SrcListAppend(pParse, 0, 0, 0);
151404 if( p->pSrc ){
151405 Table *pTab2;
151406 Walker w;
151407 p->pSrc->a[0].pSelect = pSub;
151408 sqlite3SrcListAssignCursors(pParse, p->pSrc);
151409 pSub->selFlags |= SF_Expanded;
151410 pTab2 = sqlite3ResultSetOfSelect(pParse, pSub, SQLITE_AFF_NONE);
151411 pSub->selFlags |= (selFlags & SF_Aggregate);
@@ -151269,10 +151417,15 @@
151417 }else{
151418 memcpy(pTab, pTab2, sizeof(Table));
151419 pTab->tabFlags |= TF_Ephemeral;
151420 p->pSrc->a[0].pTab = pTab;
151421 pTab = pTab2;
151422 memset(&w, 0, sizeof(w));
151423 w.xExprCallback = sqlite3WindowExtraAggFuncDepth;
151424 w.xSelectCallback = sqlite3WalkerDepthIncrease;
151425 w.xSelectCallback2 = sqlite3WalkerDepthDecrease;
151426 sqlite3WalkSelect(&w, pSub);
151427 }
151428 }else{
151429 sqlite3SelectDelete(db, pSub);
151430 }
151431 if( db->mallocFailed ) rc = SQLITE_NOMEM;
@@ -160322,10 +160475,11 @@
160475 }
160476 #endif
160477 if( rc==SQLITE_OK ){
160478 sqlite3PCacheBufferSetup( sqlite3GlobalConfig.pPage,
160479 sqlite3GlobalConfig.szPage, sqlite3GlobalConfig.nPage);
160480 sqlite3MemoryBarrier();
160481 sqlite3GlobalConfig.isInit = 1;
160482 #ifdef SQLITE_EXTRA_INIT
160483 bRunExtraInit = 1;
160484 #endif
160485 }
@@ -163270,11 +163424,11 @@
163424 assert( SQLITE_OPEN_CREATE == 0x04 );
163425 testcase( (1<<(flags&7))==0x02 ); /* READONLY */
163426 testcase( (1<<(flags&7))==0x04 ); /* READWRITE */
163427 testcase( (1<<(flags&7))==0x40 ); /* READWRITE | CREATE */
163428 if( ((1<<(flags&7)) & 0x46)==0 ){
163429 rc = SQLITE_MISUSE_BKPT; /* IMP: R-18321-05872 */
163430 }else{
163431 rc = sqlite3ParseUri(zVfs, zFilename, &flags, &db->pVfs, &zOpen, &zErrMsg);
163432 }
163433 if( rc!=SQLITE_OK ){
163434 if( rc==SQLITE_NOMEM ) sqlite3OomFault(db);
@@ -171194,10 +171348,11 @@
171348 while( *pRc==SQLITE_OK && pLeft->bEof==0 ){
171349 memset(pDl->pList, 0, pDl->nList);
171350 fts3EvalNextRow(pCsr, pLeft, pRc);
171351 }
171352 }
171353 pRight->bEof = pLeft->bEof = 1;
171354 }
171355 }
171356 break;
171357 }
171358
@@ -182739,11 +182894,11 @@
182894 iStart = pExpr->iPhrase * p->nCol;
182895 }else{
182896 iStart = pExpr->iPhrase * ((p->nCol + 31) / 32);
182897 }
182898
182899 if( pIter ) while( 1 ){
182900 int nHit = fts3ColumnlistCount(&pIter);
182901 if( (pPhrase->iColumn>=pTab->nColumn || pPhrase->iColumn==iCol) ){
182902 if( p->flag==FTS3_MATCHINFO_LHITS ){
182903 p->aMatchinfo[iStart + iCol] = (u32)nHit;
182904 }else if( nHit ){
@@ -184653,10 +184808,11 @@
184808 }
184809
184810 /* Append N bytes from zIn onto the end of the JsonString string.
184811 */
184812 static void jsonAppendRaw(JsonString *p, const char *zIn, u32 N){
184813 if( N==0 ) return;
184814 if( (N+p->nUsed >= p->nAlloc) && jsonGrow(p,N)!=0 ) return;
184815 memcpy(p->zBuf+p->nUsed, zIn, N);
184816 p->nUsed += N;
184817 }
184818
@@ -224664,11 +224820,11 @@
224820 int nArg, /* Number of args */
224821 sqlite3_value **apUnused /* Function arguments */
224822 ){
224823 assert( nArg==0 );
224824 UNUSED_PARAM2(nArg, apUnused);
224825 sqlite3_result_text(pCtx, "fts5: 2020-05-25 16:19:56 0c1fcf4711a2e66c813aed38cf41cd3e2123ee8eb6db98118086764c4ba83350", -1, SQLITE_TRANSIENT);
224826 }
224827
224828 /*
224829 ** Return true if zName is the extension on one of the shadow tables used
224830 ** by this module.
@@ -229447,12 +229603,12 @@
229603 }
229604 #endif /* SQLITE_CORE */
229605 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
229606
229607 /************** End of stmt.c ************************************************/
229608 #if __LINE__!=229608
229609 #undef SQLITE_SOURCE_ID
229610 #define SQLITE_SOURCE_ID "2020-05-25 16:19:56 0c1fcf4711a2e66c813aed38cf41cd3e2123ee8eb6db98118086764c4ba8alt2"
229611 #endif
229612 /* Return the source-id for this library */
229613 SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
229614 /************************** End of sqlite3.c ******************************/
229615
+4 -4
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -121,13 +121,13 @@
121121
**
122122
** See also: [sqlite3_libversion()],
123123
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
124124
** [sqlite_version()] and [sqlite_source_id()].
125125
*/
126
-#define SQLITE_VERSION "3.32.0"
127
-#define SQLITE_VERSION_NUMBER 3032000
128
-#define SQLITE_SOURCE_ID "2020-05-08 19:02:21 3a16c0ce4d8851f79f670d94786032c8007619154ece44647dc9cc5b1f9654ff"
126
+#define SQLITE_VERSION "3.32.1"
127
+#define SQLITE_VERSION_NUMBER 3032001
128
+#define SQLITE_SOURCE_ID "2020-05-25 16:19:56 0c1fcf4711a2e66c813aed38cf41cd3e2123ee8eb6db98118086764c4ba83350"
129129
130130
/*
131131
** CAPI3REF: Run-Time Library Version Numbers
132132
** KEYWORDS: sqlite3_version sqlite3_sourceid
133133
**
@@ -5493,11 +5493,11 @@
54935493
** when first called if N is less than or equal to zero or if a memory
54945494
** allocate error occurs.
54955495
**
54965496
** ^(The amount of space allocated by sqlite3_aggregate_context(C,N) is
54975497
** determined by the N parameter on first successful call. Changing the
5498
-** value of N in any subsequents call to sqlite3_aggregate_context() within
5498
+** value of N in any subsequent call to sqlite3_aggregate_context() within
54995499
** the same aggregate function instance will not resize the memory
55005500
** allocation.)^ Within the xFinal callback, it is customary to set
55015501
** N=0 in calls to sqlite3_aggregate_context(C,N) so that no
55025502
** pointless memory allocations occur.
55035503
**
55045504
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -121,13 +121,13 @@
121 **
122 ** See also: [sqlite3_libversion()],
123 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
124 ** [sqlite_version()] and [sqlite_source_id()].
125 */
126 #define SQLITE_VERSION "3.32.0"
127 #define SQLITE_VERSION_NUMBER 3032000
128 #define SQLITE_SOURCE_ID "2020-05-08 19:02:21 3a16c0ce4d8851f79f670d94786032c8007619154ece44647dc9cc5b1f9654ff"
129
130 /*
131 ** CAPI3REF: Run-Time Library Version Numbers
132 ** KEYWORDS: sqlite3_version sqlite3_sourceid
133 **
@@ -5493,11 +5493,11 @@
5493 ** when first called if N is less than or equal to zero or if a memory
5494 ** allocate error occurs.
5495 **
5496 ** ^(The amount of space allocated by sqlite3_aggregate_context(C,N) is
5497 ** determined by the N parameter on first successful call. Changing the
5498 ** value of N in any subsequents call to sqlite3_aggregate_context() within
5499 ** the same aggregate function instance will not resize the memory
5500 ** allocation.)^ Within the xFinal callback, it is customary to set
5501 ** N=0 in calls to sqlite3_aggregate_context(C,N) so that no
5502 ** pointless memory allocations occur.
5503 **
5504
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -121,13 +121,13 @@
121 **
122 ** See also: [sqlite3_libversion()],
123 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
124 ** [sqlite_version()] and [sqlite_source_id()].
125 */
126 #define SQLITE_VERSION "3.32.1"
127 #define SQLITE_VERSION_NUMBER 3032001
128 #define SQLITE_SOURCE_ID "2020-05-25 16:19:56 0c1fcf4711a2e66c813aed38cf41cd3e2123ee8eb6db98118086764c4ba83350"
129
130 /*
131 ** CAPI3REF: Run-Time Library Version Numbers
132 ** KEYWORDS: sqlite3_version sqlite3_sourceid
133 **
@@ -5493,11 +5493,11 @@
5493 ** when first called if N is less than or equal to zero or if a memory
5494 ** allocate error occurs.
5495 **
5496 ** ^(The amount of space allocated by sqlite3_aggregate_context(C,N) is
5497 ** determined by the N parameter on first successful call. Changing the
5498 ** value of N in any subsequent call to sqlite3_aggregate_context() within
5499 ** the same aggregate function instance will not resize the memory
5500 ** allocation.)^ Within the xFinal callback, it is customary to set
5501 ** N=0 in calls to sqlite3_aggregate_context(C,N) so that no
5502 ** pointless memory allocations occur.
5503 **
5504
+1 -1
--- src/th_main.c
+++ src/th_main.c
@@ -1500,11 +1500,11 @@
15001500
if( argc!=3 ){
15011501
return Th_WrongNumArgs(interp, "unversioned content FILENAME");
15021502
}
15031503
if( Th_IsRepositoryOpen() ){
15041504
Blob content;
1505
- if( unversioned_content(argv[2], &content)==0 ){
1505
+ if( unversioned_content(argv[2], &content)!=0 ){
15061506
Th_SetResult(interp, blob_str(&content), blob_size(&content));
15071507
blob_reset(&content);
15081508
return TH_OK;
15091509
}else{
15101510
return TH_ERROR;
15111511
--- src/th_main.c
+++ src/th_main.c
@@ -1500,11 +1500,11 @@
1500 if( argc!=3 ){
1501 return Th_WrongNumArgs(interp, "unversioned content FILENAME");
1502 }
1503 if( Th_IsRepositoryOpen() ){
1504 Blob content;
1505 if( unversioned_content(argv[2], &content)==0 ){
1506 Th_SetResult(interp, blob_str(&content), blob_size(&content));
1507 blob_reset(&content);
1508 return TH_OK;
1509 }else{
1510 return TH_ERROR;
1511
--- src/th_main.c
+++ src/th_main.c
@@ -1500,11 +1500,11 @@
1500 if( argc!=3 ){
1501 return Th_WrongNumArgs(interp, "unversioned content FILENAME");
1502 }
1503 if( Th_IsRepositoryOpen() ){
1504 Blob content;
1505 if( unversioned_content(argv[2], &content)!=0 ){
1506 Th_SetResult(interp, blob_str(&content), blob_size(&content));
1507 blob_reset(&content);
1508 return TH_OK;
1509 }else{
1510 return TH_ERROR;
1511
--- src/timeline.c
+++ src/timeline.c
@@ -1796,10 +1796,11 @@
17961796
}else if( fossil_stricmp(zMatchStyle, "regexp")==0 ){
17971797
matchStyle = MS_REGEXP;
17981798
}else{
17991799
/* For exact maching, inhibit links to the selected tag. */
18001800
zThisTag = zTagName;
1801
+ Th_Store("current_checkin", zTagName);
18011802
}
18021803
18031804
/* Display a checkbox to enable/disable display of related check-ins. */
18041805
if( advancedMenu ){
18051806
style_submenu_checkbox("rel", "Related", 0, 0);
18061807
--- src/timeline.c
+++ src/timeline.c
@@ -1796,10 +1796,11 @@
1796 }else if( fossil_stricmp(zMatchStyle, "regexp")==0 ){
1797 matchStyle = MS_REGEXP;
1798 }else{
1799 /* For exact maching, inhibit links to the selected tag. */
1800 zThisTag = zTagName;
 
1801 }
1802
1803 /* Display a checkbox to enable/disable display of related check-ins. */
1804 if( advancedMenu ){
1805 style_submenu_checkbox("rel", "Related", 0, 0);
1806
--- src/timeline.c
+++ src/timeline.c
@@ -1796,10 +1796,11 @@
1796 }else if( fossil_stricmp(zMatchStyle, "regexp")==0 ){
1797 matchStyle = MS_REGEXP;
1798 }else{
1799 /* For exact maching, inhibit links to the selected tag. */
1800 zThisTag = zTagName;
1801 Th_Store("current_checkin", zTagName);
1802 }
1803
1804 /* Display a checkbox to enable/disable display of related check-ins. */
1805 if( advancedMenu ){
1806 style_submenu_checkbox("rel", "Related", 0, 0);
1807
--- src/unversioned.c
+++ src/unversioned.c
@@ -85,25 +85,40 @@
8585
}
8686
8787
/*
8888
** Initialize pContent to be the content of an unversioned file zName.
8989
**
90
-** Return 0 on success. Return 1 if zName is not found.
90
+** Return 0 on failures.
91
+** Return 1 if the file is found by name.
92
+** Return 2 if the file is found by hash.
9193
*/
9294
int unversioned_content(const char *zName, Blob *pContent){
9395
Stmt q;
94
- int rc = 1;
96
+ int rc = 0;
9597
blob_init(pContent, 0, 0);
96
- db_prepare(&q, "SELECT encoding, content FROM unversioned WHERE name=%Q", zName);
98
+ db_prepare(&q, "SELECT encoding, content FROM unversioned WHERE name=%Q",
99
+ zName);
97100
if( db_step(&q)==SQLITE_ROW ){
98101
db_column_blob(&q, 1, pContent);
99102
if( db_column_int(&q, 0)==1 ){
100103
blob_uncompress(pContent, pContent);
101104
}
102
- rc = 0;
105
+ rc = 1;
103106
}
104107
db_finalize(&q);
108
+ if( rc==0 && validate16(zName,-1) ){
109
+ db_prepare(&q, "SELECT encoding, content FROM unversioned WHERE hash=%Q",
110
+ zName);
111
+ if( db_step(&q)==SQLITE_ROW ){
112
+ db_column_blob(&q, 1, pContent);
113
+ if( db_column_int(&q, 0)==1 ){
114
+ blob_uncompress(pContent, pContent);
115
+ }
116
+ rc = 2;
117
+ }
118
+ db_finalize(&q);
119
+ }
105120
return rc;
106121
}
107122
108123
/*
109124
** Write unversioned content into the database.
@@ -328,11 +343,11 @@
328343
int i;
329344
verify_all_options();
330345
db_begin_transaction();
331346
for(i=3; i<g.argc; i++){
332347
Blob content;
333
- if( unversioned_content(g.argv[i], &content)==0 ){
348
+ if( unversioned_content(g.argv[i], &content)!=0 ){
334349
blob_write_to_file(&content, "-");
335350
}
336351
blob_reset(&content);
337352
}
338353
db_end_transaction(0);
@@ -352,11 +367,11 @@
352367
}
353368
zTFile = fossil_temp_filename();
354369
if( zTFile==0 ) fossil_fatal("cannot find a temporary filename");
355370
db_begin_transaction();
356371
content_rcvid_init("#!fossil unversioned edit");
357
- if( unversioned_content(zUVFile, &content) ){
372
+ if( unversioned_content(zUVFile, &content)==0 ){
358373
fossil_fatal("no such uv-file: %Q", zUVFile);
359374
}
360375
if( looks_like_binary(&content) ){
361376
fossil_fatal("cannot edit binary content");
362377
}
@@ -381,11 +396,11 @@
381396
blob_reset(&content);
382397
}else if( memcmp(zCmd, "export", nCmd)==0 ){
383398
Blob content;
384399
verify_all_options();
385400
if( g.argc!=5 ) usage("export UVFILE OUTPUT");
386
- if( unversioned_content(g.argv[3], &content) ){
401
+ if( unversioned_content(g.argv[3], &content)==0 ){
387402
fossil_fatal("no such uv-file: %Q", g.argv[3]);
388403
}
389404
blob_write_to_file(&content, g.argv[4]);
390405
blob_reset(&content);
391406
}else if( memcmp(zCmd, "hash", nCmd)==0 ){ /* undocumented */
392407
--- src/unversioned.c
+++ src/unversioned.c
@@ -85,25 +85,40 @@
85 }
86
87 /*
88 ** Initialize pContent to be the content of an unversioned file zName.
89 **
90 ** Return 0 on success. Return 1 if zName is not found.
 
 
91 */
92 int unversioned_content(const char *zName, Blob *pContent){
93 Stmt q;
94 int rc = 1;
95 blob_init(pContent, 0, 0);
96 db_prepare(&q, "SELECT encoding, content FROM unversioned WHERE name=%Q", zName);
 
97 if( db_step(&q)==SQLITE_ROW ){
98 db_column_blob(&q, 1, pContent);
99 if( db_column_int(&q, 0)==1 ){
100 blob_uncompress(pContent, pContent);
101 }
102 rc = 0;
103 }
104 db_finalize(&q);
 
 
 
 
 
 
 
 
 
 
 
 
105 return rc;
106 }
107
108 /*
109 ** Write unversioned content into the database.
@@ -328,11 +343,11 @@
328 int i;
329 verify_all_options();
330 db_begin_transaction();
331 for(i=3; i<g.argc; i++){
332 Blob content;
333 if( unversioned_content(g.argv[i], &content)==0 ){
334 blob_write_to_file(&content, "-");
335 }
336 blob_reset(&content);
337 }
338 db_end_transaction(0);
@@ -352,11 +367,11 @@
352 }
353 zTFile = fossil_temp_filename();
354 if( zTFile==0 ) fossil_fatal("cannot find a temporary filename");
355 db_begin_transaction();
356 content_rcvid_init("#!fossil unversioned edit");
357 if( unversioned_content(zUVFile, &content) ){
358 fossil_fatal("no such uv-file: %Q", zUVFile);
359 }
360 if( looks_like_binary(&content) ){
361 fossil_fatal("cannot edit binary content");
362 }
@@ -381,11 +396,11 @@
381 blob_reset(&content);
382 }else if( memcmp(zCmd, "export", nCmd)==0 ){
383 Blob content;
384 verify_all_options();
385 if( g.argc!=5 ) usage("export UVFILE OUTPUT");
386 if( unversioned_content(g.argv[3], &content) ){
387 fossil_fatal("no such uv-file: %Q", g.argv[3]);
388 }
389 blob_write_to_file(&content, g.argv[4]);
390 blob_reset(&content);
391 }else if( memcmp(zCmd, "hash", nCmd)==0 ){ /* undocumented */
392
--- src/unversioned.c
+++ src/unversioned.c
@@ -85,25 +85,40 @@
85 }
86
87 /*
88 ** Initialize pContent to be the content of an unversioned file zName.
89 **
90 ** Return 0 on failures.
91 ** Return 1 if the file is found by name.
92 ** Return 2 if the file is found by hash.
93 */
94 int unversioned_content(const char *zName, Blob *pContent){
95 Stmt q;
96 int rc = 0;
97 blob_init(pContent, 0, 0);
98 db_prepare(&q, "SELECT encoding, content FROM unversioned WHERE name=%Q",
99 zName);
100 if( db_step(&q)==SQLITE_ROW ){
101 db_column_blob(&q, 1, pContent);
102 if( db_column_int(&q, 0)==1 ){
103 blob_uncompress(pContent, pContent);
104 }
105 rc = 1;
106 }
107 db_finalize(&q);
108 if( rc==0 && validate16(zName,-1) ){
109 db_prepare(&q, "SELECT encoding, content FROM unversioned WHERE hash=%Q",
110 zName);
111 if( db_step(&q)==SQLITE_ROW ){
112 db_column_blob(&q, 1, pContent);
113 if( db_column_int(&q, 0)==1 ){
114 blob_uncompress(pContent, pContent);
115 }
116 rc = 2;
117 }
118 db_finalize(&q);
119 }
120 return rc;
121 }
122
123 /*
124 ** Write unversioned content into the database.
@@ -328,11 +343,11 @@
343 int i;
344 verify_all_options();
345 db_begin_transaction();
346 for(i=3; i<g.argc; i++){
347 Blob content;
348 if( unversioned_content(g.argv[i], &content)!=0 ){
349 blob_write_to_file(&content, "-");
350 }
351 blob_reset(&content);
352 }
353 db_end_transaction(0);
@@ -352,11 +367,11 @@
367 }
368 zTFile = fossil_temp_filename();
369 if( zTFile==0 ) fossil_fatal("cannot find a temporary filename");
370 db_begin_transaction();
371 content_rcvid_init("#!fossil unversioned edit");
372 if( unversioned_content(zUVFile, &content)==0 ){
373 fossil_fatal("no such uv-file: %Q", zUVFile);
374 }
375 if( looks_like_binary(&content) ){
376 fossil_fatal("cannot edit binary content");
377 }
@@ -381,11 +396,11 @@
396 blob_reset(&content);
397 }else if( memcmp(zCmd, "export", nCmd)==0 ){
398 Blob content;
399 verify_all_options();
400 if( g.argc!=5 ) usage("export UVFILE OUTPUT");
401 if( unversioned_content(g.argv[3], &content)==0 ){
402 fossil_fatal("no such uv-file: %Q", g.argv[3]);
403 }
404 blob_write_to_file(&content, g.argv[4]);
405 blob_reset(&content);
406 }else if( memcmp(zCmd, "hash", nCmd)==0 ){ /* undocumented */
407
+2 -2
--- www/cgi.wiki
+++ www/cgi.wiki
@@ -14,12 +14,12 @@
1414
script]. CGI is the technique that the three
1515
[./selfhost.wiki|self-hosting Fossil repositories] all use.
1616
1717
Setting up a Fossil server using CGI is mostly about writing a short
1818
script (usually just 2 lines line) in the cgi-bin folder of an ordinary
19
-web-browser. But there are a lot of extra options that can be added
20
-to this script, to customize the configuration. This article descripts
19
+web-server. But there are a lot of extra options that can be added
20
+to this script, to customize the configuration. This article describes
2121
those options.
2222
2323
<h1>CGI Script Options</h1>
2424
2525
The CGI script used to launch a Fossil server will usually look something
2626
--- www/cgi.wiki
+++ www/cgi.wiki
@@ -14,12 +14,12 @@
14 script]. CGI is the technique that the three
15 [./selfhost.wiki|self-hosting Fossil repositories] all use.
16
17 Setting up a Fossil server using CGI is mostly about writing a short
18 script (usually just 2 lines line) in the cgi-bin folder of an ordinary
19 web-browser. But there are a lot of extra options that can be added
20 to this script, to customize the configuration. This article descripts
21 those options.
22
23 <h1>CGI Script Options</h1>
24
25 The CGI script used to launch a Fossil server will usually look something
26
--- www/cgi.wiki
+++ www/cgi.wiki
@@ -14,12 +14,12 @@
14 script]. CGI is the technique that the three
15 [./selfhost.wiki|self-hosting Fossil repositories] all use.
16
17 Setting up a Fossil server using CGI is mostly about writing a short
18 script (usually just 2 lines line) in the cgi-bin folder of an ordinary
19 web-server. But there are a lot of extra options that can be added
20 to this script, to customize the configuration. This article describes
21 those options.
22
23 <h1>CGI Script Options</h1>
24
25 The CGI script used to launch a Fossil server will usually look something
26
--- www/changes.wiki
+++ www/changes.wiki
@@ -1,9 +1,14 @@
11
<title>Change Log</title>
22
3
+<a name='v2_12'></a>
4
+<h2>Changes for Version 2.12 (pending)</h2>
5
+
6
+ * <i>(no changes yet...)</i>
7
+
38
<a name='v2_11'></a>
4
-<h2>Changes for Version 2.11 (pending)</h2>
9
+<h2>Changes for Version 2.11 (2020-05-25)</h2>
510
611
* Support [/md_rules|Markdown] in the default ticket configuration.
712
* Timestamp strings in [./checkin_names.wiki|object names]
813
can now omit punctation. So, for example, "202004181942" and
914
"2020-04-18 19:42" mean the same thing.
1015
--- www/changes.wiki
+++ www/changes.wiki
@@ -1,9 +1,14 @@
1 <title>Change Log</title>
2
 
 
 
 
 
3 <a name='v2_11'></a>
4 <h2>Changes for Version 2.11 (pending)</h2>
5
6 * Support [/md_rules|Markdown] in the default ticket configuration.
7 * Timestamp strings in [./checkin_names.wiki|object names]
8 can now omit punctation. So, for example, "202004181942" and
9 "2020-04-18 19:42" mean the same thing.
10
--- www/changes.wiki
+++ www/changes.wiki
@@ -1,9 +1,14 @@
1 <title>Change Log</title>
2
3 <a name='v2_12'></a>
4 <h2>Changes for Version 2.12 (pending)</h2>
5
6 * <i>(no changes yet...)</i>
7
8 <a name='v2_11'></a>
9 <h2>Changes for Version 2.11 (2020-05-25)</h2>
10
11 * Support [/md_rules|Markdown] in the default ticket configuration.
12 * Timestamp strings in [./checkin_names.wiki|object names]
13 can now omit punctation. So, for example, "202004181942" and
14 "2020-04-18 19:42" mean the same thing.
15
+1 -1
--- www/index.wiki
+++ www/index.wiki
@@ -9,11 +9,11 @@
99
<li> [./build.wiki | Install]
1010
<li> [https://fossil-scm.org/forum | Support/Forum ]
1111
<li> [./hints.wiki | Tips &amp; Hints]
1212
<li> [./changes.wiki | Change Log]
1313
<li> [../COPYRIGHT-BSD2.txt | License]
14
-<li> [./userlinks.wiki | User inks]
14
+<li> [./userlinks.wiki | User Links]
1515
<li> [./hacker-howto.wiki | Hacker How-To]
1616
<li> [./fossil-v-git.wiki | Fossil vs. Git]
1717
<li> [./permutedindex.html | Documentation Index]
1818
</ul>
1919
<img src="fossil3.gif" align="center">
2020
--- www/index.wiki
+++ www/index.wiki
@@ -9,11 +9,11 @@
9 <li> [./build.wiki | Install]
10 <li> [https://fossil-scm.org/forum | Support/Forum ]
11 <li> [./hints.wiki | Tips &amp; Hints]
12 <li> [./changes.wiki | Change Log]
13 <li> [../COPYRIGHT-BSD2.txt | License]
14 <li> [./userlinks.wiki | User inks]
15 <li> [./hacker-howto.wiki | Hacker How-To]
16 <li> [./fossil-v-git.wiki | Fossil vs. Git]
17 <li> [./permutedindex.html | Documentation Index]
18 </ul>
19 <img src="fossil3.gif" align="center">
20
--- www/index.wiki
+++ www/index.wiki
@@ -9,11 +9,11 @@
9 <li> [./build.wiki | Install]
10 <li> [https://fossil-scm.org/forum | Support/Forum ]
11 <li> [./hints.wiki | Tips &amp; Hints]
12 <li> [./changes.wiki | Change Log]
13 <li> [../COPYRIGHT-BSD2.txt | License]
14 <li> [./userlinks.wiki | User Links]
15 <li> [./hacker-howto.wiki | Hacker How-To]
16 <li> [./fossil-v-git.wiki | Fossil vs. Git]
17 <li> [./permutedindex.html | Documentation Index]
18 </ul>
19 <img src="fossil3.gif" align="center">
20

Keyboard Shortcuts

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