Fossil SCM

Improvements to handling of localtime. The 'utc' and 'localtime' query parameters now work on all web pages. Timestamps can be expressed with a timezone modifier and that works correctly.

drh 2015-12-23 11:10 trunk
Commit ea63a2d1f409581afde02949a51b68ac30133a0e
+4 -5
--- src/attach.c
+++ src/attach.c
@@ -41,15 +41,14 @@
4141
4242
if( zPage && zTkt ) zTkt = 0;
4343
login_check_credentials();
4444
blob_zero(&sql);
4545
blob_append_sql(&sql,
46
- "SELECT datetime(mtime%s), src, target, filename,"
46
+ "SELECT datetime(mtime,toLocal()), src, target, filename,"
4747
" comment, user,"
4848
" (SELECT uuid FROM blob WHERE rid=attachid), attachid"
49
- " FROM attachment",
50
- timeline_utc()
49
+ " FROM attachment"
5150
);
5251
if( zPage ){
5352
if( g.perm.RdWiki==0 ){ login_needed(g.anon.RdWiki); return; }
5453
style_header("Attachments To %h", zPage);
5554
blob_append_sql(&sql, " WHERE target=%Q", zPage);
@@ -574,16 +573,16 @@
574573
const char *zHeader /* Header to display with attachments */
575574
){
576575
int cnt = 0;
577576
Stmt q;
578577
db_prepare(&q,
579
- "SELECT datetime(mtime%s), filename, user,"
578
+ "SELECT datetime(mtime,toLocal()), filename, user,"
580579
" (SELECT uuid FROM blob WHERE rid=attachid), src"
581580
" FROM attachment"
582581
" WHERE isLatest AND src!='' AND target=%Q"
583582
" ORDER BY mtime DESC",
584
- timeline_utc(), zTarget
583
+ zTarget
585584
);
586585
while( db_step(&q)==SQLITE_ROW ){
587586
const char *zDate = db_column_text(&q, 0);
588587
const char *zFile = db_column_text(&q, 1);
589588
const char *zUser = db_column_text(&q, 2);
590589
--- src/attach.c
+++ src/attach.c
@@ -41,15 +41,14 @@
41
42 if( zPage && zTkt ) zTkt = 0;
43 login_check_credentials();
44 blob_zero(&sql);
45 blob_append_sql(&sql,
46 "SELECT datetime(mtime%s), src, target, filename,"
47 " comment, user,"
48 " (SELECT uuid FROM blob WHERE rid=attachid), attachid"
49 " FROM attachment",
50 timeline_utc()
51 );
52 if( zPage ){
53 if( g.perm.RdWiki==0 ){ login_needed(g.anon.RdWiki); return; }
54 style_header("Attachments To %h", zPage);
55 blob_append_sql(&sql, " WHERE target=%Q", zPage);
@@ -574,16 +573,16 @@
574 const char *zHeader /* Header to display with attachments */
575 ){
576 int cnt = 0;
577 Stmt q;
578 db_prepare(&q,
579 "SELECT datetime(mtime%s), filename, user,"
580 " (SELECT uuid FROM blob WHERE rid=attachid), src"
581 " FROM attachment"
582 " WHERE isLatest AND src!='' AND target=%Q"
583 " ORDER BY mtime DESC",
584 timeline_utc(), zTarget
585 );
586 while( db_step(&q)==SQLITE_ROW ){
587 const char *zDate = db_column_text(&q, 0);
588 const char *zFile = db_column_text(&q, 1);
589 const char *zUser = db_column_text(&q, 2);
590
--- src/attach.c
+++ src/attach.c
@@ -41,15 +41,14 @@
41
42 if( zPage && zTkt ) zTkt = 0;
43 login_check_credentials();
44 blob_zero(&sql);
45 blob_append_sql(&sql,
46 "SELECT datetime(mtime,toLocal()), src, target, filename,"
47 " comment, user,"
48 " (SELECT uuid FROM blob WHERE rid=attachid), attachid"
49 " FROM attachment"
 
50 );
51 if( zPage ){
52 if( g.perm.RdWiki==0 ){ login_needed(g.anon.RdWiki); return; }
53 style_header("Attachments To %h", zPage);
54 blob_append_sql(&sql, " WHERE target=%Q", zPage);
@@ -574,16 +573,16 @@
573 const char *zHeader /* Header to display with attachments */
574 ){
575 int cnt = 0;
576 Stmt q;
577 db_prepare(&q,
578 "SELECT datetime(mtime,toLocal()), filename, user,"
579 " (SELECT uuid FROM blob WHERE rid=attachid), src"
580 " FROM attachment"
581 " WHERE isLatest AND src!='' AND target=%Q"
582 " ORDER BY mtime DESC",
583 zTarget
584 );
585 while( db_step(&q)==SQLITE_ROW ){
586 const char *zDate = db_column_text(&q, 0);
587 const char *zFile = db_column_text(&q, 1);
588 const char *zUser = db_column_text(&q, 2);
589
+3 -3
--- src/browse.c
+++ src/browse.c
@@ -599,19 +599,19 @@
599599
int trunkRid = symbolic_name_to_rid("tag:trunk", "ci");
600600
linkTrunk = trunkRid && rid != trunkRid;
601601
linkTip = rid != symbolic_name_to_rid("tip", "ci");
602602
zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
603603
rNow = db_double(0.0, "SELECT mtime FROM event WHERE objid=%d", rid);
604
- zNow = db_text("", "SELECT datetime(mtime,'localtime')"
604
+ zNow = db_text("", "SELECT datetime(mtime,toLocal())"
605605
" FROM event WHERE objid=%d", rid);
606606
}else{
607607
zCI = 0;
608608
}
609609
}
610610
if( zCI==0 ){
611611
rNow = db_double(0.0, "SELECT max(mtime) FROM event");
612
- zNow = db_text("", "SELECT datetime(max(mtime),'localtime') FROM event");
612
+ zNow = db_text("", "SELECT datetime(max(mtime),toLocal()) FROM event");
613613
}
614614
615615
/* Compute the title of the page */
616616
blob_zero(&dirname);
617617
if( zD ){
@@ -1029,11 +1029,11 @@
10291029
if( rid==0 ){
10301030
fossil_fatal("not a valid check-in: %s", zName);
10311031
}
10321032
zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d", rid);
10331033
baseTime = db_double(0.0,"SELECT mtime FROM event WHERE objid=%d", rid);
1034
- zNow = db_text("", "SELECT datetime(mtime,'localtime') FROM event"
1034
+ zNow = db_text("", "SELECT datetime(mtime,toLocal()) FROM event"
10351035
" WHERE objid=%d", rid);
10361036
style_submenu_element("Tree-View", "Tree-View",
10371037
"%R/tree?ci=%T&mtime=1&type=tree",
10381038
zName);
10391039
style_header("File Ages");
10401040
--- src/browse.c
+++ src/browse.c
@@ -599,19 +599,19 @@
599 int trunkRid = symbolic_name_to_rid("tag:trunk", "ci");
600 linkTrunk = trunkRid && rid != trunkRid;
601 linkTip = rid != symbolic_name_to_rid("tip", "ci");
602 zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
603 rNow = db_double(0.0, "SELECT mtime FROM event WHERE objid=%d", rid);
604 zNow = db_text("", "SELECT datetime(mtime,'localtime')"
605 " FROM event WHERE objid=%d", rid);
606 }else{
607 zCI = 0;
608 }
609 }
610 if( zCI==0 ){
611 rNow = db_double(0.0, "SELECT max(mtime) FROM event");
612 zNow = db_text("", "SELECT datetime(max(mtime),'localtime') FROM event");
613 }
614
615 /* Compute the title of the page */
616 blob_zero(&dirname);
617 if( zD ){
@@ -1029,11 +1029,11 @@
1029 if( rid==0 ){
1030 fossil_fatal("not a valid check-in: %s", zName);
1031 }
1032 zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d", rid);
1033 baseTime = db_double(0.0,"SELECT mtime FROM event WHERE objid=%d", rid);
1034 zNow = db_text("", "SELECT datetime(mtime,'localtime') FROM event"
1035 " WHERE objid=%d", rid);
1036 style_submenu_element("Tree-View", "Tree-View",
1037 "%R/tree?ci=%T&mtime=1&type=tree",
1038 zName);
1039 style_header("File Ages");
1040
--- src/browse.c
+++ src/browse.c
@@ -599,19 +599,19 @@
599 int trunkRid = symbolic_name_to_rid("tag:trunk", "ci");
600 linkTrunk = trunkRid && rid != trunkRid;
601 linkTip = rid != symbolic_name_to_rid("tip", "ci");
602 zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
603 rNow = db_double(0.0, "SELECT mtime FROM event WHERE objid=%d", rid);
604 zNow = db_text("", "SELECT datetime(mtime,toLocal())"
605 " FROM event WHERE objid=%d", rid);
606 }else{
607 zCI = 0;
608 }
609 }
610 if( zCI==0 ){
611 rNow = db_double(0.0, "SELECT max(mtime) FROM event");
612 zNow = db_text("", "SELECT datetime(max(mtime),toLocal()) FROM event");
613 }
614
615 /* Compute the title of the page */
616 blob_zero(&dirname);
617 if( zD ){
@@ -1029,11 +1029,11 @@
1029 if( rid==0 ){
1030 fossil_fatal("not a valid check-in: %s", zName);
1031 }
1032 zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d", rid);
1033 baseTime = db_double(0.0,"SELECT mtime FROM event WHERE objid=%d", rid);
1034 zNow = db_text("", "SELECT datetime(mtime,toLocal()) FROM event"
1035 " WHERE objid=%d", rid);
1036 style_submenu_element("Tree-View", "Tree-View",
1037 "%R/tree?ci=%T&mtime=1&type=tree",
1038 zName);
1039 style_header("File Ages");
1040
+3 -3
--- src/checkin.c
+++ src/checkin.c
@@ -327,11 +327,11 @@
327327
zOrderBy = "mtime DESC";
328328
}
329329
330330
compute_fileage(rid,0);
331331
db_prepare(&q,
332
- "SELECT datetime(fileage.mtime, 'localtime'), fileage.pathname,\n"
332
+ "SELECT datetime(fileage.mtime, toLocal()), fileage.pathname,\n"
333333
" blob.size\n"
334334
" FROM fileage, blob\n"
335335
" WHERE blob.rid=fileage.fid %s\n"
336336
" ORDER BY %s;", blob_sql_text(&where), zOrderBy /*safe-for-%s*/
337337
);
@@ -429,14 +429,14 @@
429429
}
430430
vfile_check_signature(vid, 0);
431431
if( showAge ){
432432
db_prepare(&q,
433433
"SELECT pathname, deleted, rid, chnged, coalesce(origname!=pathname,0),"
434
- " datetime(checkin_mtime(%d,rid),'unixepoch'%s)"
434
+ " datetime(checkin_mtime(%d,rid),'unixepoch',toLocal())"
435435
" FROM vfile %s"
436436
" ORDER BY %s",
437
- vid, timeline_utc(), blob_sql_text(&where), zOrderBy /*safe-for-%s*/
437
+ vid, blob_sql_text(&where), zOrderBy /*safe-for-%s*/
438438
);
439439
}else{
440440
db_prepare(&q,
441441
"SELECT pathname, deleted, rid, chnged,"
442442
" coalesce(origname!=pathname,0), islink"
443443
--- src/checkin.c
+++ src/checkin.c
@@ -327,11 +327,11 @@
327 zOrderBy = "mtime DESC";
328 }
329
330 compute_fileage(rid,0);
331 db_prepare(&q,
332 "SELECT datetime(fileage.mtime, 'localtime'), fileage.pathname,\n"
333 " blob.size\n"
334 " FROM fileage, blob\n"
335 " WHERE blob.rid=fileage.fid %s\n"
336 " ORDER BY %s;", blob_sql_text(&where), zOrderBy /*safe-for-%s*/
337 );
@@ -429,14 +429,14 @@
429 }
430 vfile_check_signature(vid, 0);
431 if( showAge ){
432 db_prepare(&q,
433 "SELECT pathname, deleted, rid, chnged, coalesce(origname!=pathname,0),"
434 " datetime(checkin_mtime(%d,rid),'unixepoch'%s)"
435 " FROM vfile %s"
436 " ORDER BY %s",
437 vid, timeline_utc(), blob_sql_text(&where), zOrderBy /*safe-for-%s*/
438 );
439 }else{
440 db_prepare(&q,
441 "SELECT pathname, deleted, rid, chnged,"
442 " coalesce(origname!=pathname,0), islink"
443
--- src/checkin.c
+++ src/checkin.c
@@ -327,11 +327,11 @@
327 zOrderBy = "mtime DESC";
328 }
329
330 compute_fileage(rid,0);
331 db_prepare(&q,
332 "SELECT datetime(fileage.mtime, toLocal()), fileage.pathname,\n"
333 " blob.size\n"
334 " FROM fileage, blob\n"
335 " WHERE blob.rid=fileage.fid %s\n"
336 " ORDER BY %s;", blob_sql_text(&where), zOrderBy /*safe-for-%s*/
337 );
@@ -429,14 +429,14 @@
429 }
430 vfile_check_signature(vid, 0);
431 if( showAge ){
432 db_prepare(&q,
433 "SELECT pathname, deleted, rid, chnged, coalesce(origname!=pathname,0),"
434 " datetime(checkin_mtime(%d,rid),'unixepoch',toLocal())"
435 " FROM vfile %s"
436 " ORDER BY %s",
437 vid, blob_sql_text(&where), zOrderBy /*safe-for-%s*/
438 );
439 }else{
440 db_prepare(&q,
441 "SELECT pathname, deleted, rid, chnged,"
442 " coalesce(origname!=pathname,0), islink"
443
--- src/codecheck1.c
+++ src/codecheck1.c
@@ -250,11 +250,10 @@
250250
** SQL using %s.
251251
*/
252252
static const char *azSafeFunc[] = {
253253
"filename_collation",
254254
"db_name",
255
- "timeline_utc",
256255
"leaf_is_closed_sql",
257256
"timeline_query_for_www",
258257
"timeline_query_for_tty",
259258
"blob_sql_text",
260259
"glob_expr",
261260
--- src/codecheck1.c
+++ src/codecheck1.c
@@ -250,11 +250,10 @@
250 ** SQL using %s.
251 */
252 static const char *azSafeFunc[] = {
253 "filename_collation",
254 "db_name",
255 "timeline_utc",
256 "leaf_is_closed_sql",
257 "timeline_query_for_www",
258 "timeline_query_for_tty",
259 "blob_sql_text",
260 "glob_expr",
261
--- src/codecheck1.c
+++ src/codecheck1.c
@@ -250,11 +250,10 @@
250 ** SQL using %s.
251 */
252 static const char *azSafeFunc[] = {
253 "filename_collation",
254 "db_name",
 
255 "leaf_is_closed_sql",
256 "timeline_query_for_www",
257 "timeline_query_for_tty",
258 "blob_sql_text",
259 "glob_expr",
260
+64 -1
--- src/db.c
+++ src/db.c
@@ -791,10 +791,69 @@
791791
}else{
792792
sqlite3_result_int64(context, rid);
793793
}
794794
}
795795
}
796
+
797
+/*
798
+** The toLocal() SQL function returns a string that is an argument to a
799
+** date/time function that is appropriate for modifying the time for display.
800
+** If UTC time display is selected, no modification occurs. If local time
801
+** display is selected, the time is adjusted appropriately.
802
+**
803
+** Example usage:
804
+**
805
+** SELECT datetime('now',toLocal());
806
+*/
807
+void db_tolocal_function(
808
+ sqlite3_context *context,
809
+ int argc,
810
+ sqlite3_value **argv
811
+){
812
+ if( g.fTimeFormat==0 ){
813
+ if( db_get_int("timeline-utc", 1) ){
814
+ g.fTimeFormat = 1;
815
+ }else{
816
+ g.fTimeFormat = 2;
817
+ }
818
+ }
819
+ if( g.fTimeFormat==1 ){
820
+ sqlite3_result_text(context, "0 seconds", -1, SQLITE_STATIC);
821
+ }else{
822
+ sqlite3_result_text(context, "localtime", -1, SQLITE_STATIC);
823
+ }
824
+}
825
+
826
+/*
827
+** The fromLocal() SQL function returns a string that is an argument to a
828
+** date/time function that is appropriate to convert an input time to UTC.
829
+** If UTC time display is selected, no modification occurs. If local time
830
+** display is selected, the time is adjusted from local to UTC.
831
+**
832
+** Example usage:
833
+**
834
+** SELECT julianday(:user_input,fromLocal());
835
+*/
836
+void db_fromlocal_function(
837
+ sqlite3_context *context,
838
+ int argc,
839
+ sqlite3_value **argv
840
+){
841
+ if( g.fTimeFormat==0 ){
842
+ if( db_get_int("timeline-utc", 1) ){
843
+ g.fTimeFormat = 1;
844
+ }else{
845
+ g.fTimeFormat = 2;
846
+ }
847
+ }
848
+ if( g.fTimeFormat==1 ){
849
+ sqlite3_result_text(context, "0 seconds", -1, SQLITE_STATIC);
850
+ }else{
851
+ sqlite3_result_text(context, "utc", -1, SQLITE_STATIC);
852
+ }
853
+}
854
+
796855
797856
/*
798857
** Register the SQL functions that are useful both to the internal
799858
** representation and to the "fossil sql" command.
800859
*/
@@ -804,11 +863,15 @@
804863
sqlite3_create_function(db, "symbolic_name_to_rid", 1, SQLITE_UTF8, 0,
805864
db_sym2rid_function, 0, 0);
806865
sqlite3_create_function(db, "symbolic_name_to_rid", 2, SQLITE_UTF8, 0,
807866
db_sym2rid_function, 0, 0);
808867
sqlite3_create_function(db, "now", 0, SQLITE_UTF8, 0,
809
- db_now_function, 0, 0);
868
+ db_now_function, 0, 0);
869
+ sqlite3_create_function(db, "toLocal", 0, SQLITE_UTF8, 0,
870
+ db_tolocal_function, 0, 0);
871
+ sqlite3_create_function(db, "fromLocal", 0, SQLITE_UTF8, 0,
872
+ db_fromlocal_function, 0, 0);
810873
}
811874
812875
813876
/*
814877
** Open a database file. Return a pointer to the new database
815878
--- src/db.c
+++ src/db.c
@@ -791,10 +791,69 @@
791 }else{
792 sqlite3_result_int64(context, rid);
793 }
794 }
795 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
796
797 /*
798 ** Register the SQL functions that are useful both to the internal
799 ** representation and to the "fossil sql" command.
800 */
@@ -804,11 +863,15 @@
804 sqlite3_create_function(db, "symbolic_name_to_rid", 1, SQLITE_UTF8, 0,
805 db_sym2rid_function, 0, 0);
806 sqlite3_create_function(db, "symbolic_name_to_rid", 2, SQLITE_UTF8, 0,
807 db_sym2rid_function, 0, 0);
808 sqlite3_create_function(db, "now", 0, SQLITE_UTF8, 0,
809 db_now_function, 0, 0);
 
 
 
 
810 }
811
812
813 /*
814 ** Open a database file. Return a pointer to the new database
815
--- src/db.c
+++ src/db.c
@@ -791,10 +791,69 @@
791 }else{
792 sqlite3_result_int64(context, rid);
793 }
794 }
795 }
796
797 /*
798 ** The toLocal() SQL function returns a string that is an argument to a
799 ** date/time function that is appropriate for modifying the time for display.
800 ** If UTC time display is selected, no modification occurs. If local time
801 ** display is selected, the time is adjusted appropriately.
802 **
803 ** Example usage:
804 **
805 ** SELECT datetime('now',toLocal());
806 */
807 void db_tolocal_function(
808 sqlite3_context *context,
809 int argc,
810 sqlite3_value **argv
811 ){
812 if( g.fTimeFormat==0 ){
813 if( db_get_int("timeline-utc", 1) ){
814 g.fTimeFormat = 1;
815 }else{
816 g.fTimeFormat = 2;
817 }
818 }
819 if( g.fTimeFormat==1 ){
820 sqlite3_result_text(context, "0 seconds", -1, SQLITE_STATIC);
821 }else{
822 sqlite3_result_text(context, "localtime", -1, SQLITE_STATIC);
823 }
824 }
825
826 /*
827 ** The fromLocal() SQL function returns a string that is an argument to a
828 ** date/time function that is appropriate to convert an input time to UTC.
829 ** If UTC time display is selected, no modification occurs. If local time
830 ** display is selected, the time is adjusted from local to UTC.
831 **
832 ** Example usage:
833 **
834 ** SELECT julianday(:user_input,fromLocal());
835 */
836 void db_fromlocal_function(
837 sqlite3_context *context,
838 int argc,
839 sqlite3_value **argv
840 ){
841 if( g.fTimeFormat==0 ){
842 if( db_get_int("timeline-utc", 1) ){
843 g.fTimeFormat = 1;
844 }else{
845 g.fTimeFormat = 2;
846 }
847 }
848 if( g.fTimeFormat==1 ){
849 sqlite3_result_text(context, "0 seconds", -1, SQLITE_STATIC);
850 }else{
851 sqlite3_result_text(context, "utc", -1, SQLITE_STATIC);
852 }
853 }
854
855
856 /*
857 ** Register the SQL functions that are useful both to the internal
858 ** representation and to the "fossil sql" command.
859 */
@@ -804,11 +863,15 @@
863 sqlite3_create_function(db, "symbolic_name_to_rid", 1, SQLITE_UTF8, 0,
864 db_sym2rid_function, 0, 0);
865 sqlite3_create_function(db, "symbolic_name_to_rid", 2, SQLITE_UTF8, 0,
866 db_sym2rid_function, 0, 0);
867 sqlite3_create_function(db, "now", 0, SQLITE_UTF8, 0,
868 db_now_function, 0, 0);
869 sqlite3_create_function(db, "toLocal", 0, SQLITE_UTF8, 0,
870 db_tolocal_function, 0, 0);
871 sqlite3_create_function(db, "fromLocal", 0, SQLITE_UTF8, 0,
872 db_fromlocal_function, 0, 0);
873 }
874
875
876 /*
877 ** Open a database file. Return a pointer to the new database
878
+4 -4
--- src/finfo.c
+++ src/finfo.c
@@ -182,11 +182,11 @@
182182
if( rid==0 ){
183183
fossil_fatal("no history for file: %b", &fname);
184184
}
185185
zFilename = blob_str(&fname);
186186
db_prepare(&q,
187
- "SELECT DISTINCT b.uuid, ci.uuid, date(event.mtime%s),"
187
+ "SELECT DISTINCT b.uuid, ci.uuid, date(event.mtime,toLocal()),"
188188
" coalesce(event.ecomment, event.comment),"
189189
" coalesce(event.euser, event.user),"
190190
" (SELECT value FROM tagxref WHERE tagid=%d AND tagtype>0"
191191
" AND tagxref.rid=mlink.mid)" /* Tags */
192192
" FROM mlink, blob b, event, blob ci, filename"
@@ -194,11 +194,11 @@
194194
" AND mlink.fnid=filename.fnid"
195195
" AND b.rid=mlink.fid"
196196
" AND event.objid=mlink.mid"
197197
" AND event.objid=ci.rid"
198198
" ORDER BY event.mtime DESC LIMIT %d OFFSET %d",
199
- timeline_utc(), TAG_BRANCH, zFilename, filename_collation(),
199
+ TAG_BRANCH, zFilename, filename_collation(),
200200
iLimit, iOffset
201201
);
202202
blob_zero(&line);
203203
if( iBrief ){
204204
fossil_print("History of %s\n", blob_str(&fname));
@@ -332,11 +332,11 @@
332332
}
333333
url_add_parameter(&url, "name", zFilename);
334334
blob_zero(&sql);
335335
blob_append_sql(&sql,
336336
"SELECT"
337
- " datetime(min(event.mtime)%s)," /* Date of change */
337
+ " datetime(min(event.mtime),toLocal())," /* Date of change */
338338
" coalesce(event.ecomment, event.comment)," /* Check-in comment */
339339
" coalesce(event.euser, event.user)," /* User who made chng */
340340
" mlink.pid," /* Parent file rid */
341341
" mlink.fid," /* File rid */
342342
" (SELECT uuid FROM blob WHERE rid=mlink.pid)," /* Parent file uuid */
@@ -348,11 +348,11 @@
348348
" mlink.mid," /* check-in ID */
349349
" mlink.pfnid" /* Previous filename */
350350
" FROM mlink, event"
351351
" WHERE mlink.fnid=%d"
352352
" AND event.objid=mlink.mid",
353
- timeline_utc(), TAG_BRANCH, fnid
353
+ TAG_BRANCH, fnid
354354
);
355355
if( (zA = P("a"))!=0 ){
356356
blob_append_sql(&sql, " AND event.mtime>=julianday('%q')", zA);
357357
url_add_parameter(&url, "a", zA);
358358
}
359359
--- src/finfo.c
+++ src/finfo.c
@@ -182,11 +182,11 @@
182 if( rid==0 ){
183 fossil_fatal("no history for file: %b", &fname);
184 }
185 zFilename = blob_str(&fname);
186 db_prepare(&q,
187 "SELECT DISTINCT b.uuid, ci.uuid, date(event.mtime%s),"
188 " coalesce(event.ecomment, event.comment),"
189 " coalesce(event.euser, event.user),"
190 " (SELECT value FROM tagxref WHERE tagid=%d AND tagtype>0"
191 " AND tagxref.rid=mlink.mid)" /* Tags */
192 " FROM mlink, blob b, event, blob ci, filename"
@@ -194,11 +194,11 @@
194 " AND mlink.fnid=filename.fnid"
195 " AND b.rid=mlink.fid"
196 " AND event.objid=mlink.mid"
197 " AND event.objid=ci.rid"
198 " ORDER BY event.mtime DESC LIMIT %d OFFSET %d",
199 timeline_utc(), TAG_BRANCH, zFilename, filename_collation(),
200 iLimit, iOffset
201 );
202 blob_zero(&line);
203 if( iBrief ){
204 fossil_print("History of %s\n", blob_str(&fname));
@@ -332,11 +332,11 @@
332 }
333 url_add_parameter(&url, "name", zFilename);
334 blob_zero(&sql);
335 blob_append_sql(&sql,
336 "SELECT"
337 " datetime(min(event.mtime)%s)," /* Date of change */
338 " coalesce(event.ecomment, event.comment)," /* Check-in comment */
339 " coalesce(event.euser, event.user)," /* User who made chng */
340 " mlink.pid," /* Parent file rid */
341 " mlink.fid," /* File rid */
342 " (SELECT uuid FROM blob WHERE rid=mlink.pid)," /* Parent file uuid */
@@ -348,11 +348,11 @@
348 " mlink.mid," /* check-in ID */
349 " mlink.pfnid" /* Previous filename */
350 " FROM mlink, event"
351 " WHERE mlink.fnid=%d"
352 " AND event.objid=mlink.mid",
353 timeline_utc(), TAG_BRANCH, fnid
354 );
355 if( (zA = P("a"))!=0 ){
356 blob_append_sql(&sql, " AND event.mtime>=julianday('%q')", zA);
357 url_add_parameter(&url, "a", zA);
358 }
359
--- src/finfo.c
+++ src/finfo.c
@@ -182,11 +182,11 @@
182 if( rid==0 ){
183 fossil_fatal("no history for file: %b", &fname);
184 }
185 zFilename = blob_str(&fname);
186 db_prepare(&q,
187 "SELECT DISTINCT b.uuid, ci.uuid, date(event.mtime,toLocal()),"
188 " coalesce(event.ecomment, event.comment),"
189 " coalesce(event.euser, event.user),"
190 " (SELECT value FROM tagxref WHERE tagid=%d AND tagtype>0"
191 " AND tagxref.rid=mlink.mid)" /* Tags */
192 " FROM mlink, blob b, event, blob ci, filename"
@@ -194,11 +194,11 @@
194 " AND mlink.fnid=filename.fnid"
195 " AND b.rid=mlink.fid"
196 " AND event.objid=mlink.mid"
197 " AND event.objid=ci.rid"
198 " ORDER BY event.mtime DESC LIMIT %d OFFSET %d",
199 TAG_BRANCH, zFilename, filename_collation(),
200 iLimit, iOffset
201 );
202 blob_zero(&line);
203 if( iBrief ){
204 fossil_print("History of %s\n", blob_str(&fname));
@@ -332,11 +332,11 @@
332 }
333 url_add_parameter(&url, "name", zFilename);
334 blob_zero(&sql);
335 blob_append_sql(&sql,
336 "SELECT"
337 " datetime(min(event.mtime),toLocal())," /* Date of change */
338 " coalesce(event.ecomment, event.comment)," /* Check-in comment */
339 " coalesce(event.euser, event.user)," /* User who made chng */
340 " mlink.pid," /* Parent file rid */
341 " mlink.fid," /* File rid */
342 " (SELECT uuid FROM blob WHERE rid=mlink.pid)," /* Parent file uuid */
@@ -348,11 +348,11 @@
348 " mlink.mid," /* check-in ID */
349 " mlink.pfnid" /* Previous filename */
350 " FROM mlink, event"
351 " WHERE mlink.fnid=%d"
352 " AND event.objid=mlink.mid",
353 TAG_BRANCH, fnid
354 );
355 if( (zA = P("a"))!=0 ){
356 blob_append_sql(&sql, " AND event.mtime>=julianday('%q')", zA);
357 url_add_parameter(&url, "a", zA);
358 }
359
+5 -5
--- src/info.c
+++ src/info.c
@@ -233,15 +233,15 @@
233233
Stmt q;
234234
int cnt = 0;
235235
db_prepare(&q,
236236
"SELECT tag.tagid, tagname, "
237237
" (SELECT uuid FROM blob WHERE rid=tagxref.srcid AND rid!=%d),"
238
- " value, datetime(tagxref.mtime%s), tagtype,"
238
+ " value, datetime(tagxref.mtime,toLocal()), tagtype,"
239239
" (SELECT uuid FROM blob WHERE rid=tagxref.origid AND rid!=%d)"
240240
" FROM tagxref JOIN tag ON tagxref.tagid=tag.tagid"
241241
" WHERE tagxref.rid=%d"
242
- " ORDER BY tagname /*sort*/", rid, timeline_utc(), rid, rid
242
+ " ORDER BY tagname /*sort*/", rid, rid, rid
243243
);
244244
while( db_step(&q)==SQLITE_ROW ){
245245
const char *zTagname = db_column_text(&q, 1);
246246
const char *zSrcUuid = db_column_text(&q, 2);
247247
const char *zValue = db_column_text(&q, 3);
@@ -546,16 +546,16 @@
546546
" WHERE plink.cid=%d AND blob.rid=plink.pid AND plink.isprim",
547547
rid
548548
);
549549
isLeaf = is_a_leaf(rid);
550550
db_prepare(&q1,
551
- "SELECT uuid, datetime(mtime%s), user, comment,"
552
- " datetime(omtime%s), mtime"
551
+ "SELECT uuid, datetime(mtime,toLocal()), user, comment,"
552
+ " datetime(omtime,toLocal()), mtime"
553553
" FROM blob, event"
554554
" WHERE blob.rid=%d"
555555
" AND event.objid=%d",
556
- timeline_utc(), timeline_utc(), rid, rid
556
+ rid, rid
557557
);
558558
sideBySide = !is_false(PD("sbs","1"));
559559
if( db_step(&q1)==SQLITE_ROW ){
560560
const char *zUuid = db_column_text(&q1, 0);
561561
char *zEUser, *zEComment;
562562
--- src/info.c
+++ src/info.c
@@ -233,15 +233,15 @@
233 Stmt q;
234 int cnt = 0;
235 db_prepare(&q,
236 "SELECT tag.tagid, tagname, "
237 " (SELECT uuid FROM blob WHERE rid=tagxref.srcid AND rid!=%d),"
238 " value, datetime(tagxref.mtime%s), tagtype,"
239 " (SELECT uuid FROM blob WHERE rid=tagxref.origid AND rid!=%d)"
240 " FROM tagxref JOIN tag ON tagxref.tagid=tag.tagid"
241 " WHERE tagxref.rid=%d"
242 " ORDER BY tagname /*sort*/", rid, timeline_utc(), rid, rid
243 );
244 while( db_step(&q)==SQLITE_ROW ){
245 const char *zTagname = db_column_text(&q, 1);
246 const char *zSrcUuid = db_column_text(&q, 2);
247 const char *zValue = db_column_text(&q, 3);
@@ -546,16 +546,16 @@
546 " WHERE plink.cid=%d AND blob.rid=plink.pid AND plink.isprim",
547 rid
548 );
549 isLeaf = is_a_leaf(rid);
550 db_prepare(&q1,
551 "SELECT uuid, datetime(mtime%s), user, comment,"
552 " datetime(omtime%s), mtime"
553 " FROM blob, event"
554 " WHERE blob.rid=%d"
555 " AND event.objid=%d",
556 timeline_utc(), timeline_utc(), rid, rid
557 );
558 sideBySide = !is_false(PD("sbs","1"));
559 if( db_step(&q1)==SQLITE_ROW ){
560 const char *zUuid = db_column_text(&q1, 0);
561 char *zEUser, *zEComment;
562
--- src/info.c
+++ src/info.c
@@ -233,15 +233,15 @@
233 Stmt q;
234 int cnt = 0;
235 db_prepare(&q,
236 "SELECT tag.tagid, tagname, "
237 " (SELECT uuid FROM blob WHERE rid=tagxref.srcid AND rid!=%d),"
238 " value, datetime(tagxref.mtime,toLocal()), tagtype,"
239 " (SELECT uuid FROM blob WHERE rid=tagxref.origid AND rid!=%d)"
240 " FROM tagxref JOIN tag ON tagxref.tagid=tag.tagid"
241 " WHERE tagxref.rid=%d"
242 " ORDER BY tagname /*sort*/", rid, rid, rid
243 );
244 while( db_step(&q)==SQLITE_ROW ){
245 const char *zTagname = db_column_text(&q, 1);
246 const char *zSrcUuid = db_column_text(&q, 2);
247 const char *zValue = db_column_text(&q, 3);
@@ -546,16 +546,16 @@
546 " WHERE plink.cid=%d AND blob.rid=plink.pid AND plink.isprim",
547 rid
548 );
549 isLeaf = is_a_leaf(rid);
550 db_prepare(&q1,
551 "SELECT uuid, datetime(mtime,toLocal()), user, comment,"
552 " datetime(omtime,toLocal()), mtime"
553 " FROM blob, event"
554 " WHERE blob.rid=%d"
555 " AND event.objid=%d",
556 rid, rid
557 );
558 sideBySide = !is_false(PD("sbs","1"));
559 if( db_step(&q1)==SQLITE_ROW ){
560 const char *zUuid = db_column_text(&q1, 0);
561 char *zEUser, *zEComment;
562
--- src/json_timeline.c
+++ src/json_timeline.c
@@ -228,18 +228,18 @@
228228
zBefore = zAfter ? NULL : json_find_option_cstr("before",NULL,"b");
229229
230230
if(zAfter&&*zAfter){
231231
while( fossil_isspace(*zAfter) ) ++zAfter;
232232
blob_appendf(pSql,
233
- " AND event.mtime>=(SELECT julianday(%Q,'utc')) "
233
+ " AND event.mtime>=(SELECT julianday(%Q,fromLocal())) "
234234
" ORDER BY event.mtime ASC ",
235235
zAfter);
236236
rc = 1;
237237
}else if(zBefore && *zBefore){
238238
while( fossil_isspace(*zBefore) ) ++zBefore;
239239
blob_appendf(pSql,
240
- " AND event.mtime<=(SELECT julianday(%Q,'utc')) "
240
+ " AND event.mtime<=(SELECT julianday(%Q,fromLocal())) "
241241
" ORDER BY event.mtime DESC ",
242242
zBefore);
243243
rc = -1;
244244
}else{
245245
blob_append(pSql, " ORDER BY event.mtime DESC ", -1);
246246
--- src/json_timeline.c
+++ src/json_timeline.c
@@ -228,18 +228,18 @@
228 zBefore = zAfter ? NULL : json_find_option_cstr("before",NULL,"b");
229
230 if(zAfter&&*zAfter){
231 while( fossil_isspace(*zAfter) ) ++zAfter;
232 blob_appendf(pSql,
233 " AND event.mtime>=(SELECT julianday(%Q,'utc')) "
234 " ORDER BY event.mtime ASC ",
235 zAfter);
236 rc = 1;
237 }else if(zBefore && *zBefore){
238 while( fossil_isspace(*zBefore) ) ++zBefore;
239 blob_appendf(pSql,
240 " AND event.mtime<=(SELECT julianday(%Q,'utc')) "
241 " ORDER BY event.mtime DESC ",
242 zBefore);
243 rc = -1;
244 }else{
245 blob_append(pSql, " ORDER BY event.mtime DESC ", -1);
246
--- src/json_timeline.c
+++ src/json_timeline.c
@@ -228,18 +228,18 @@
228 zBefore = zAfter ? NULL : json_find_option_cstr("before",NULL,"b");
229
230 if(zAfter&&*zAfter){
231 while( fossil_isspace(*zAfter) ) ++zAfter;
232 blob_appendf(pSql,
233 " AND event.mtime>=(SELECT julianday(%Q,fromLocal())) "
234 " ORDER BY event.mtime ASC ",
235 zAfter);
236 rc = 1;
237 }else if(zBefore && *zBefore){
238 while( fossil_isspace(*zBefore) ) ++zBefore;
239 blob_appendf(pSql,
240 " AND event.mtime<=(SELECT julianday(%Q,fromLocal())) "
241 " ORDER BY event.mtime DESC ",
242 zBefore);
243 rc = -1;
244 }else{
245 blob_append(pSql, " ORDER BY event.mtime DESC ", -1);
246
+2 -2
--- src/leaf.c
+++ src/leaf.c
@@ -224,17 +224,17 @@
224224
blob_init(&msg, 0, 0);
225225
blob_appendf(&msg, "WARNING: multiple open leaf check-ins on %s:", zBr);
226226
db_prepare(&q,
227227
"SELECT"
228228
" (SELECT uuid FROM blob WHERE rid=leaf.rid),"
229
- " (SELECT datetime(mtime%s) FROM event WHERE objid=leaf.rid),"
229
+ " (SELECT datetime(mtime,toLocal()) FROM event WHERE objid=leaf.rid),"
230230
" leaf.rid"
231231
" FROM leaf"
232232
" WHERE (SELECT value FROM tagxref WHERE tagid=%d AND rid=leaf.rid)=%Q"
233233
" AND NOT %z"
234234
" ORDER BY 2 DESC",
235
- timeline_utc(), TAG_BRANCH, zBr, leaf_is_closed_sql("leaf.rid")
235
+ TAG_BRANCH, zBr, leaf_is_closed_sql("leaf.rid")
236236
);
237237
while( db_step(&q)==SQLITE_ROW ){
238238
blob_appendf(&msg, "\n (%d) %s [%S]%s",
239239
++n, db_column_text(&q,1), db_column_text(&q,0),
240240
db_column_int(&q,2)==currentCkout ? " (current)" : "");
241241
--- src/leaf.c
+++ src/leaf.c
@@ -224,17 +224,17 @@
224 blob_init(&msg, 0, 0);
225 blob_appendf(&msg, "WARNING: multiple open leaf check-ins on %s:", zBr);
226 db_prepare(&q,
227 "SELECT"
228 " (SELECT uuid FROM blob WHERE rid=leaf.rid),"
229 " (SELECT datetime(mtime%s) FROM event WHERE objid=leaf.rid),"
230 " leaf.rid"
231 " FROM leaf"
232 " WHERE (SELECT value FROM tagxref WHERE tagid=%d AND rid=leaf.rid)=%Q"
233 " AND NOT %z"
234 " ORDER BY 2 DESC",
235 timeline_utc(), TAG_BRANCH, zBr, leaf_is_closed_sql("leaf.rid")
236 );
237 while( db_step(&q)==SQLITE_ROW ){
238 blob_appendf(&msg, "\n (%d) %s [%S]%s",
239 ++n, db_column_text(&q,1), db_column_text(&q,0),
240 db_column_int(&q,2)==currentCkout ? " (current)" : "");
241
--- src/leaf.c
+++ src/leaf.c
@@ -224,17 +224,17 @@
224 blob_init(&msg, 0, 0);
225 blob_appendf(&msg, "WARNING: multiple open leaf check-ins on %s:", zBr);
226 db_prepare(&q,
227 "SELECT"
228 " (SELECT uuid FROM blob WHERE rid=leaf.rid),"
229 " (SELECT datetime(mtime,toLocal()) FROM event WHERE objid=leaf.rid),"
230 " leaf.rid"
231 " FROM leaf"
232 " WHERE (SELECT value FROM tagxref WHERE tagid=%d AND rid=leaf.rid)=%Q"
233 " AND NOT %z"
234 " ORDER BY 2 DESC",
235 TAG_BRANCH, zBr, leaf_is_closed_sql("leaf.rid")
236 );
237 while( db_step(&q)==SQLITE_ROW ){
238 blob_appendf(&msg, "\n (%d) %s [%S]%s",
239 ++n, db_column_text(&q,1), db_column_text(&q,0),
240 db_column_int(&q,2)==currentCkout ? " (current)" : "");
241
+7
--- src/main.c
+++ src/main.c
@@ -1553,10 +1553,17 @@
15531553
){
15541554
const char *zPathInfo;
15551555
char *zPath = NULL;
15561556
int idx;
15571557
int i;
1558
+
1559
+ /* Handle universal query parameters */
1560
+ if( PB("utc") ){
1561
+ g.fTimeFormat = 1;
1562
+ }else if( PB("localtime") ){
1563
+ g.fTimeFormat = 2;
1564
+ }
15581565
15591566
/* If the repository has not been opened already, then find the
15601567
** repository based on the first element of PATH_INFO and open it.
15611568
*/
15621569
zPathInfo = PD("PATH_INFO","");
15631570
--- src/main.c
+++ src/main.c
@@ -1553,10 +1553,17 @@
1553 ){
1554 const char *zPathInfo;
1555 char *zPath = NULL;
1556 int idx;
1557 int i;
 
 
 
 
 
 
 
1558
1559 /* If the repository has not been opened already, then find the
1560 ** repository based on the first element of PATH_INFO and open it.
1561 */
1562 zPathInfo = PD("PATH_INFO","");
1563
--- src/main.c
+++ src/main.c
@@ -1553,10 +1553,17 @@
1553 ){
1554 const char *zPathInfo;
1555 char *zPath = NULL;
1556 int idx;
1557 int i;
1558
1559 /* Handle universal query parameters */
1560 if( PB("utc") ){
1561 g.fTimeFormat = 1;
1562 }else if( PB("localtime") ){
1563 g.fTimeFormat = 2;
1564 }
1565
1566 /* If the repository has not been opened already, then find the
1567 ** repository based on the first element of PATH_INFO and open it.
1568 */
1569 zPathInfo = PD("PATH_INFO","");
1570
+4 -4
--- src/merge.c
+++ src/merge.c
@@ -26,17 +26,17 @@
2626
** Print information about a particular check-in.
2727
*/
2828
void print_checkin_description(int rid, int indent, const char *zLabel){
2929
Stmt q;
3030
db_prepare(&q,
31
- "SELECT datetime(mtime%s),"
31
+ "SELECT datetime(mtime,toLocal()),"
3232
" coalesce(euser,user), coalesce(ecomment,comment),"
3333
" (SELECT uuid FROM blob WHERE rid=%d),"
3434
" (SELECT group_concat(substr(tagname,5), ', ') FROM tag, tagxref"
3535
" WHERE tagname GLOB 'sym-*' AND tag.tagid=tagxref.tagid"
3636
" AND tagxref.rid=%d AND tagxref.tagtype>0)"
37
- " FROM event WHERE objid=%d", timeline_utc(), rid, rid, rid);
37
+ " FROM event WHERE objid=%d", rid, rid, rid);
3838
if( db_step(&q)==SQLITE_ROW ){
3939
const char *zTagList = db_column_text(&q, 4);
4040
char *zCom;
4141
if( zTagList && zTagList[0] ){
4242
zCom = mprintf("%s (%s)", db_column_text(&q, 2), zTagList);
@@ -263,16 +263,16 @@
263263
TAG_BRANCH, vid)
264264
);
265265
}
266266
db_prepare(&q,
267267
"SELECT blob.uuid,"
268
- " datetime(event.mtime%s),"
268
+ " datetime(event.mtime,toLocal()),"
269269
" coalesce(ecomment, comment),"
270270
" coalesce(euser, user)"
271271
" FROM event, blob"
272272
" WHERE event.objid=%d AND blob.rid=%d",
273
- timeline_utc(), mid, mid
273
+ mid, mid
274274
);
275275
if( db_step(&q)==SQLITE_ROW ){
276276
char *zCom = mprintf("Merging fork [%S] at %s by %s: \"%s\"",
277277
db_column_text(&q, 0), db_column_text(&q, 1),
278278
db_column_text(&q, 3), db_column_text(&q, 2));
279279
--- src/merge.c
+++ src/merge.c
@@ -26,17 +26,17 @@
26 ** Print information about a particular check-in.
27 */
28 void print_checkin_description(int rid, int indent, const char *zLabel){
29 Stmt q;
30 db_prepare(&q,
31 "SELECT datetime(mtime%s),"
32 " coalesce(euser,user), coalesce(ecomment,comment),"
33 " (SELECT uuid FROM blob WHERE rid=%d),"
34 " (SELECT group_concat(substr(tagname,5), ', ') FROM tag, tagxref"
35 " WHERE tagname GLOB 'sym-*' AND tag.tagid=tagxref.tagid"
36 " AND tagxref.rid=%d AND tagxref.tagtype>0)"
37 " FROM event WHERE objid=%d", timeline_utc(), rid, rid, rid);
38 if( db_step(&q)==SQLITE_ROW ){
39 const char *zTagList = db_column_text(&q, 4);
40 char *zCom;
41 if( zTagList && zTagList[0] ){
42 zCom = mprintf("%s (%s)", db_column_text(&q, 2), zTagList);
@@ -263,16 +263,16 @@
263 TAG_BRANCH, vid)
264 );
265 }
266 db_prepare(&q,
267 "SELECT blob.uuid,"
268 " datetime(event.mtime%s),"
269 " coalesce(ecomment, comment),"
270 " coalesce(euser, user)"
271 " FROM event, blob"
272 " WHERE event.objid=%d AND blob.rid=%d",
273 timeline_utc(), mid, mid
274 );
275 if( db_step(&q)==SQLITE_ROW ){
276 char *zCom = mprintf("Merging fork [%S] at %s by %s: \"%s\"",
277 db_column_text(&q, 0), db_column_text(&q, 1),
278 db_column_text(&q, 3), db_column_text(&q, 2));
279
--- src/merge.c
+++ src/merge.c
@@ -26,17 +26,17 @@
26 ** Print information about a particular check-in.
27 */
28 void print_checkin_description(int rid, int indent, const char *zLabel){
29 Stmt q;
30 db_prepare(&q,
31 "SELECT datetime(mtime,toLocal()),"
32 " coalesce(euser,user), coalesce(ecomment,comment),"
33 " (SELECT uuid FROM blob WHERE rid=%d),"
34 " (SELECT group_concat(substr(tagname,5), ', ') FROM tag, tagxref"
35 " WHERE tagname GLOB 'sym-*' AND tag.tagid=tagxref.tagid"
36 " AND tagxref.rid=%d AND tagxref.tagtype>0)"
37 " FROM event WHERE objid=%d", rid, rid, rid);
38 if( db_step(&q)==SQLITE_ROW ){
39 const char *zTagList = db_column_text(&q, 4);
40 char *zCom;
41 if( zTagList && zTagList[0] ){
42 zCom = mprintf("%s (%s)", db_column_text(&q, 2), zTagList);
@@ -263,16 +263,16 @@
263 TAG_BRANCH, vid)
264 );
265 }
266 db_prepare(&q,
267 "SELECT blob.uuid,"
268 " datetime(event.mtime,toLocal()),"
269 " coalesce(ecomment, comment),"
270 " coalesce(euser, user)"
271 " FROM event, blob"
272 " WHERE event.objid=%d AND blob.rid=%d",
273 mid, mid
274 );
275 if( db_step(&q)==SQLITE_ROW ){
276 char *zCom = mprintf("Merging fork [%S] at %s by %s: \"%s\"",
277 db_column_text(&q, 0), db_column_text(&q, 1),
278 db_column_text(&q, 3), db_column_text(&q, 2));
279
+10 -10
--- src/name.c
+++ src/name.c
@@ -154,19 +154,19 @@
154154
155155
/* Date and times */
156156
if( memcmp(zTag, "date:", 5)==0 ){
157157
rid = db_int(0,
158158
"SELECT objid FROM event"
159
- " WHERE mtime<=julianday(%Q,'utc') AND type GLOB '%q'"
159
+ " WHERE mtime<=julianday(%Q,fromLocal()) AND type GLOB '%q'"
160160
" ORDER BY mtime DESC LIMIT 1",
161161
&zTag[5], zType);
162162
return rid;
163163
}
164164
if( fossil_isdate(zTag) ){
165165
rid = db_int(0,
166166
"SELECT objid FROM event"
167
- " WHERE mtime<=julianday(%Q,'utc') AND type GLOB '%q'"
167
+ " WHERE mtime<=julianday(%Q,fromLocal()) AND type GLOB '%q'"
168168
" ORDER BY mtime DESC LIMIT 1",
169169
zTag, zType);
170170
if( rid) return rid;
171171
}
172172
@@ -530,15 +530,15 @@
530530
Stmt q;
531531
int cnt;
532532
533533
/* Basic information about the object. */
534534
db_prepare(&q,
535
- "SELECT uuid, size, datetime(mtime%s), ipaddr"
535
+ "SELECT uuid, size, datetime(mtime,toLocal()), ipaddr"
536536
" FROM blob, rcvfrom"
537537
" WHERE rid=%d"
538538
" AND rcvfrom.rcvid=blob.rcvid",
539
- timeline_utc(), rid);
539
+ rid);
540540
if( db_step(&q)==SQLITE_ROW ){
541541
if( verboseFlag ){
542542
fossil_print("artifact: %s (%d)\n", db_column_text(&q,0), rid);
543543
fossil_print("size: %d bytes\n", db_column_int(&q,1));
544544
fossil_print("received: %s from %s\n",
@@ -585,13 +585,13 @@
585585
if( cnt ) fossil_print("\n");
586586
db_finalize(&q);
587587
588588
/* Check for entries on the timeline that reference this object */
589589
db_prepare(&q,
590
- "SELECT type, datetime(mtime%s),"
590
+ "SELECT type, datetime(mtime,toLocal()),"
591591
" coalesce(euser,user), coalesce(ecomment,comment)"
592
- " FROM event WHERE objid=%d", timeline_utc(), rid);
592
+ " FROM event WHERE objid=%d", rid);
593593
if( db_step(&q)==SQLITE_ROW ){
594594
const char *zType;
595595
switch( db_column_text(&q,0)[0] ){
596596
case 'c': zType = "Check-in"; break;
597597
case 'w': zType = "Wiki-edit"; break;
@@ -607,19 +607,19 @@
607607
}
608608
db_finalize(&q);
609609
610610
/* Check to see if this object is used as a file in a check-in */
611611
db_prepare(&q,
612
- "SELECT filename.name, blob.uuid, datetime(event.mtime%s),"
612
+ "SELECT filename.name, blob.uuid, datetime(event.mtime,toLocal()),"
613613
" coalesce(euser,user), coalesce(ecomment,comment)"
614614
" FROM mlink, filename, blob, event"
615615
" WHERE mlink.fid=%d"
616616
" AND filename.fnid=mlink.fnid"
617617
" AND event.objid=mlink.mid"
618618
" AND blob.rid=mlink.mid"
619619
" ORDER BY event.mtime DESC /*sort*/",
620
- timeline_utc(), rid);
620
+ rid);
621621
while( db_step(&q)==SQLITE_ROW ){
622622
fossil_print("file: %s\n", db_column_text(&q,0));
623623
fossil_print(" part of [%S] by %s on %s\n",
624624
db_column_text(&q, 1),
625625
db_column_text(&q, 3),
@@ -632,21 +632,21 @@
632632
/* Check to see if this object is used as an attachment */
633633
db_prepare(&q,
634634
"SELECT attachment.filename,"
635635
" attachment.comment,"
636636
" attachment.user,"
637
- " datetime(attachment.mtime%s),"
637
+ " datetime(attachment.mtime,toLocal()),"
638638
" attachment.target,"
639639
" CASE WHEN EXISTS(SELECT 1 FROM tag WHERE tagname=('tkt-'||target))"
640640
" THEN 'ticket'"
641641
" WHEN EXISTS(SELECT 1 FROM tag WHERE tagname=('wiki-'||target))"
642642
" THEN 'wiki' END,"
643643
" attachment.attachid,"
644644
" (SELECT uuid FROM blob WHERE rid=attachid)"
645645
" FROM attachment JOIN blob ON attachment.src=blob.uuid"
646646
" WHERE blob.rid=%d",
647
- timeline_utc(), rid
647
+ rid
648648
);
649649
while( db_step(&q)==SQLITE_ROW ){
650650
fossil_print("attachment: %s\n", db_column_text(&q,0));
651651
fossil_print(" attached to %s %s\n",
652652
db_column_text(&q,5), db_column_text(&q,4));
653653
--- src/name.c
+++ src/name.c
@@ -154,19 +154,19 @@
154
155 /* Date and times */
156 if( memcmp(zTag, "date:", 5)==0 ){
157 rid = db_int(0,
158 "SELECT objid FROM event"
159 " WHERE mtime<=julianday(%Q,'utc') AND type GLOB '%q'"
160 " ORDER BY mtime DESC LIMIT 1",
161 &zTag[5], zType);
162 return rid;
163 }
164 if( fossil_isdate(zTag) ){
165 rid = db_int(0,
166 "SELECT objid FROM event"
167 " WHERE mtime<=julianday(%Q,'utc') AND type GLOB '%q'"
168 " ORDER BY mtime DESC LIMIT 1",
169 zTag, zType);
170 if( rid) return rid;
171 }
172
@@ -530,15 +530,15 @@
530 Stmt q;
531 int cnt;
532
533 /* Basic information about the object. */
534 db_prepare(&q,
535 "SELECT uuid, size, datetime(mtime%s), ipaddr"
536 " FROM blob, rcvfrom"
537 " WHERE rid=%d"
538 " AND rcvfrom.rcvid=blob.rcvid",
539 timeline_utc(), rid);
540 if( db_step(&q)==SQLITE_ROW ){
541 if( verboseFlag ){
542 fossil_print("artifact: %s (%d)\n", db_column_text(&q,0), rid);
543 fossil_print("size: %d bytes\n", db_column_int(&q,1));
544 fossil_print("received: %s from %s\n",
@@ -585,13 +585,13 @@
585 if( cnt ) fossil_print("\n");
586 db_finalize(&q);
587
588 /* Check for entries on the timeline that reference this object */
589 db_prepare(&q,
590 "SELECT type, datetime(mtime%s),"
591 " coalesce(euser,user), coalesce(ecomment,comment)"
592 " FROM event WHERE objid=%d", timeline_utc(), rid);
593 if( db_step(&q)==SQLITE_ROW ){
594 const char *zType;
595 switch( db_column_text(&q,0)[0] ){
596 case 'c': zType = "Check-in"; break;
597 case 'w': zType = "Wiki-edit"; break;
@@ -607,19 +607,19 @@
607 }
608 db_finalize(&q);
609
610 /* Check to see if this object is used as a file in a check-in */
611 db_prepare(&q,
612 "SELECT filename.name, blob.uuid, datetime(event.mtime%s),"
613 " coalesce(euser,user), coalesce(ecomment,comment)"
614 " FROM mlink, filename, blob, event"
615 " WHERE mlink.fid=%d"
616 " AND filename.fnid=mlink.fnid"
617 " AND event.objid=mlink.mid"
618 " AND blob.rid=mlink.mid"
619 " ORDER BY event.mtime DESC /*sort*/",
620 timeline_utc(), rid);
621 while( db_step(&q)==SQLITE_ROW ){
622 fossil_print("file: %s\n", db_column_text(&q,0));
623 fossil_print(" part of [%S] by %s on %s\n",
624 db_column_text(&q, 1),
625 db_column_text(&q, 3),
@@ -632,21 +632,21 @@
632 /* Check to see if this object is used as an attachment */
633 db_prepare(&q,
634 "SELECT attachment.filename,"
635 " attachment.comment,"
636 " attachment.user,"
637 " datetime(attachment.mtime%s),"
638 " attachment.target,"
639 " CASE WHEN EXISTS(SELECT 1 FROM tag WHERE tagname=('tkt-'||target))"
640 " THEN 'ticket'"
641 " WHEN EXISTS(SELECT 1 FROM tag WHERE tagname=('wiki-'||target))"
642 " THEN 'wiki' END,"
643 " attachment.attachid,"
644 " (SELECT uuid FROM blob WHERE rid=attachid)"
645 " FROM attachment JOIN blob ON attachment.src=blob.uuid"
646 " WHERE blob.rid=%d",
647 timeline_utc(), rid
648 );
649 while( db_step(&q)==SQLITE_ROW ){
650 fossil_print("attachment: %s\n", db_column_text(&q,0));
651 fossil_print(" attached to %s %s\n",
652 db_column_text(&q,5), db_column_text(&q,4));
653
--- src/name.c
+++ src/name.c
@@ -154,19 +154,19 @@
154
155 /* Date and times */
156 if( memcmp(zTag, "date:", 5)==0 ){
157 rid = db_int(0,
158 "SELECT objid FROM event"
159 " WHERE mtime<=julianday(%Q,fromLocal()) AND type GLOB '%q'"
160 " ORDER BY mtime DESC LIMIT 1",
161 &zTag[5], zType);
162 return rid;
163 }
164 if( fossil_isdate(zTag) ){
165 rid = db_int(0,
166 "SELECT objid FROM event"
167 " WHERE mtime<=julianday(%Q,fromLocal()) AND type GLOB '%q'"
168 " ORDER BY mtime DESC LIMIT 1",
169 zTag, zType);
170 if( rid) return rid;
171 }
172
@@ -530,15 +530,15 @@
530 Stmt q;
531 int cnt;
532
533 /* Basic information about the object. */
534 db_prepare(&q,
535 "SELECT uuid, size, datetime(mtime,toLocal()), ipaddr"
536 " FROM blob, rcvfrom"
537 " WHERE rid=%d"
538 " AND rcvfrom.rcvid=blob.rcvid",
539 rid);
540 if( db_step(&q)==SQLITE_ROW ){
541 if( verboseFlag ){
542 fossil_print("artifact: %s (%d)\n", db_column_text(&q,0), rid);
543 fossil_print("size: %d bytes\n", db_column_int(&q,1));
544 fossil_print("received: %s from %s\n",
@@ -585,13 +585,13 @@
585 if( cnt ) fossil_print("\n");
586 db_finalize(&q);
587
588 /* Check for entries on the timeline that reference this object */
589 db_prepare(&q,
590 "SELECT type, datetime(mtime,toLocal()),"
591 " coalesce(euser,user), coalesce(ecomment,comment)"
592 " FROM event WHERE objid=%d", rid);
593 if( db_step(&q)==SQLITE_ROW ){
594 const char *zType;
595 switch( db_column_text(&q,0)[0] ){
596 case 'c': zType = "Check-in"; break;
597 case 'w': zType = "Wiki-edit"; break;
@@ -607,19 +607,19 @@
607 }
608 db_finalize(&q);
609
610 /* Check to see if this object is used as a file in a check-in */
611 db_prepare(&q,
612 "SELECT filename.name, blob.uuid, datetime(event.mtime,toLocal()),"
613 " coalesce(euser,user), coalesce(ecomment,comment)"
614 " FROM mlink, filename, blob, event"
615 " WHERE mlink.fid=%d"
616 " AND filename.fnid=mlink.fnid"
617 " AND event.objid=mlink.mid"
618 " AND blob.rid=mlink.mid"
619 " ORDER BY event.mtime DESC /*sort*/",
620 rid);
621 while( db_step(&q)==SQLITE_ROW ){
622 fossil_print("file: %s\n", db_column_text(&q,0));
623 fossil_print(" part of [%S] by %s on %s\n",
624 db_column_text(&q, 1),
625 db_column_text(&q, 3),
@@ -632,21 +632,21 @@
632 /* Check to see if this object is used as an attachment */
633 db_prepare(&q,
634 "SELECT attachment.filename,"
635 " attachment.comment,"
636 " attachment.user,"
637 " datetime(attachment.mtime,toLocal()),"
638 " attachment.target,"
639 " CASE WHEN EXISTS(SELECT 1 FROM tag WHERE tagname=('tkt-'||target))"
640 " THEN 'ticket'"
641 " WHEN EXISTS(SELECT 1 FROM tag WHERE tagname=('wiki-'||target))"
642 " THEN 'wiki' END,"
643 " attachment.attachid,"
644 " (SELECT uuid FROM blob WHERE rid=attachid)"
645 " FROM attachment JOIN blob ON attachment.src=blob.uuid"
646 " WHERE blob.rid=%d",
647 rid
648 );
649 while( db_step(&q)==SQLITE_ROW ){
650 fossil_print("attachment: %s\n", db_column_text(&q,0));
651 fossil_print(" attached to %s %s\n",
652 db_column_text(&q,5), db_column_text(&q,4));
653
+1 -1
--- src/purge.c
+++ src/purge.c
@@ -492,11 +492,11 @@
492492
/* The "checkins" subcommand goes here in alphabetical order, but it must
493493
** be moved to the end since it is the default case */
494494
}else if( strncmp(zSubcmd, "list", n)==0 || strcmp(zSubcmd,"ls")==0 ){
495495
int showDetail = find_option("l","l",0)!=0;
496496
if( !db_table_exists("repository","purgeevent") ) return;
497
- db_prepare(&q, "SELECT peid, datetime(ctime,'unixepoch','localtime')"
497
+ db_prepare(&q, "SELECT peid, datetime(ctime,'unixepoch',toLocal())"
498498
" FROM purgeevent");
499499
while( db_step(&q)==SQLITE_ROW ){
500500
fossil_print("%4d on %s\n", db_column_int(&q,0), db_column_text(&q,1));
501501
if( showDetail ){
502502
purge_list_event_content(db_column_int(&q,0));
503503
--- src/purge.c
+++ src/purge.c
@@ -492,11 +492,11 @@
492 /* The "checkins" subcommand goes here in alphabetical order, but it must
493 ** be moved to the end since it is the default case */
494 }else if( strncmp(zSubcmd, "list", n)==0 || strcmp(zSubcmd,"ls")==0 ){
495 int showDetail = find_option("l","l",0)!=0;
496 if( !db_table_exists("repository","purgeevent") ) return;
497 db_prepare(&q, "SELECT peid, datetime(ctime,'unixepoch','localtime')"
498 " FROM purgeevent");
499 while( db_step(&q)==SQLITE_ROW ){
500 fossil_print("%4d on %s\n", db_column_int(&q,0), db_column_text(&q,1));
501 if( showDetail ){
502 purge_list_event_content(db_column_int(&q,0));
503
--- src/purge.c
+++ src/purge.c
@@ -492,11 +492,11 @@
492 /* The "checkins" subcommand goes here in alphabetical order, but it must
493 ** be moved to the end since it is the default case */
494 }else if( strncmp(zSubcmd, "list", n)==0 || strcmp(zSubcmd,"ls")==0 ){
495 int showDetail = find_option("l","l",0)!=0;
496 if( !db_table_exists("repository","purgeevent") ) return;
497 db_prepare(&q, "SELECT peid, datetime(ctime,'unixepoch',toLocal())"
498 " FROM purgeevent");
499 while( db_step(&q)==SQLITE_ROW ){
500 fossil_print("%4d on %s\n", db_column_int(&q,0), db_column_text(&q,1));
501 if( showDetail ){
502 purge_list_event_content(db_column_int(&q,0));
503
+2 -3
--- src/search.c
+++ src/search.c
@@ -567,17 +567,16 @@
567567
568568
db_multi_exec(
569569
"CREATE TEMP TABLE srch(rid,uuid,date,comment,x);"
570570
"CREATE INDEX srch_idx1 ON srch(x);"
571571
"INSERT INTO srch(rid,uuid,date,comment,x)"
572
- " SELECT blob.rid, uuid, datetime(event.mtime%s),"
572
+ " SELECT blob.rid, uuid, datetime(event.mtime,toLocal()),"
573573
" coalesce(ecomment,comment),"
574574
" search_score()"
575575
" FROM event, blob"
576576
" WHERE blob.rid=event.objid"
577
- " AND search_match(coalesce(ecomment,comment));",
578
- timeline_utc()
577
+ " AND search_match(coalesce(ecomment,comment));"
579578
);
580579
iBest = db_int(0, "SELECT max(x) FROM srch");
581580
blob_append(&sql,
582581
"SELECT rid, uuid, date, comment, 0, 0 FROM srch "
583582
"WHERE 1 ", -1);
584583
--- src/search.c
+++ src/search.c
@@ -567,17 +567,16 @@
567
568 db_multi_exec(
569 "CREATE TEMP TABLE srch(rid,uuid,date,comment,x);"
570 "CREATE INDEX srch_idx1 ON srch(x);"
571 "INSERT INTO srch(rid,uuid,date,comment,x)"
572 " SELECT blob.rid, uuid, datetime(event.mtime%s),"
573 " coalesce(ecomment,comment),"
574 " search_score()"
575 " FROM event, blob"
576 " WHERE blob.rid=event.objid"
577 " AND search_match(coalesce(ecomment,comment));",
578 timeline_utc()
579 );
580 iBest = db_int(0, "SELECT max(x) FROM srch");
581 blob_append(&sql,
582 "SELECT rid, uuid, date, comment, 0, 0 FROM srch "
583 "WHERE 1 ", -1);
584
--- src/search.c
+++ src/search.c
@@ -567,17 +567,16 @@
567
568 db_multi_exec(
569 "CREATE TEMP TABLE srch(rid,uuid,date,comment,x);"
570 "CREATE INDEX srch_idx1 ON srch(x);"
571 "INSERT INTO srch(rid,uuid,date,comment,x)"
572 " SELECT blob.rid, uuid, datetime(event.mtime,toLocal()),"
573 " coalesce(ecomment,comment),"
574 " search_score()"
575 " FROM event, blob"
576 " WHERE blob.rid=event.objid"
577 " AND search_match(coalesce(ecomment,comment));"
 
578 );
579 iBest = db_int(0, "SELECT max(x) FROM srch");
580 blob_append(&sql,
581 "SELECT rid, uuid, date, comment, 0, 0 FROM srch "
582 "WHERE 1 ", -1);
583
+64 -48
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -325,11 +325,11 @@
325325
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
326326
** [sqlite_version()] and [sqlite_source_id()].
327327
*/
328328
#define SQLITE_VERSION "3.10.0"
329329
#define SQLITE_VERSION_NUMBER 3010000
330
-#define SQLITE_SOURCE_ID "2015-12-11 13:51:02 e998513e442ce1206b12dc28bdc996d7b5f9f94d"
330
+#define SQLITE_SOURCE_ID "2015-12-23 10:54:48 b910a3d53769689d9212a06f974ccce54844bbe4"
331331
332332
/*
333333
** CAPI3REF: Run-Time Library Version Numbers
334334
** KEYWORDS: sqlite3_version, sqlite3_sourceid
335335
**
@@ -14256,10 +14256,11 @@
1425614256
SQLITE_PRIVATE void sqlite3ExprCachePop(Parse*);
1425714257
SQLITE_PRIVATE void sqlite3ExprCacheRemove(Parse*, int, int);
1425814258
SQLITE_PRIVATE void sqlite3ExprCacheClear(Parse*);
1425914259
SQLITE_PRIVATE void sqlite3ExprCacheAffinityChange(Parse*, int, int);
1426014260
SQLITE_PRIVATE void sqlite3ExprCode(Parse*, Expr*, int);
14261
+SQLITE_PRIVATE void sqlite3ExprCodeCopy(Parse*, Expr*, int);
1426114262
SQLITE_PRIVATE void sqlite3ExprCodeFactorable(Parse*, Expr*, int);
1426214263
SQLITE_PRIVATE void sqlite3ExprCodeAtInit(Parse*, Expr*, int, u8);
1426314264
SQLITE_PRIVATE int sqlite3ExprCodeTemp(Parse*, Expr*, int*);
1426414265
SQLITE_PRIVATE int sqlite3ExprCodeTarget(Parse*, Expr*, int);
1426514266
SQLITE_PRIVATE void sqlite3ExprCodeAndCache(Parse*, Expr*, int);
@@ -16491,10 +16492,11 @@
1649116492
double s; /* Seconds */
1649216493
char validYMD; /* True (1) if Y,M,D are valid */
1649316494
char validHMS; /* True (1) if h,m,s are valid */
1649416495
char validJD; /* True (1) if iJD is valid */
1649516496
char validTZ; /* True (1) if tz is valid */
16497
+ char tzSet; /* Timezone was set explicitly */
1649616498
};
1649716499
1649816500
1649916501
/*
1650016502
** Convert zDate into one or more integers. Additional arguments
@@ -16584,10 +16586,11 @@
1658416586
}
1658516587
zDate += 5;
1658616588
p->tz = sgn*(nMn + nHr*60);
1658716589
zulu_time:
1658816590
while( sqlite3Isspace(*zDate) ){ zDate++; }
16591
+ p->tzSet = 1;
1658916592
return *zDate!=0;
1659016593
}
1659116594
1659216595
/*
1659316596
** Parse times of the form HH:MM or HH:MM:SS or HH:MM:SS.FFFF.
@@ -17016,17 +17019,22 @@
1701617019
clearYMD_HMS_TZ(p);
1701717020
rc = 0;
1701817021
}
1701917022
#ifndef SQLITE_OMIT_LOCALTIME
1702017023
else if( strcmp(z, "utc")==0 ){
17021
- sqlite3_int64 c1;
17022
- computeJD(p);
17023
- c1 = localtimeOffset(p, pCtx, &rc);
17024
- if( rc==SQLITE_OK ){
17025
- p->iJD -= c1;
17026
- clearYMD_HMS_TZ(p);
17027
- p->iJD += c1 - localtimeOffset(p, pCtx, &rc);
17024
+ if( p->tzSet==0 ){
17025
+ sqlite3_int64 c1;
17026
+ computeJD(p);
17027
+ c1 = localtimeOffset(p, pCtx, &rc);
17028
+ if( rc==SQLITE_OK ){
17029
+ p->iJD -= c1;
17030
+ clearYMD_HMS_TZ(p);
17031
+ p->iJD += c1 - localtimeOffset(p, pCtx, &rc);
17032
+ }
17033
+ p->tzSet = 1;
17034
+ }else{
17035
+ rc = SQLITE_OK;
1702817036
}
1702917037
}
1703017038
#endif
1703117039
break;
1703217040
}
@@ -19662,11 +19670,11 @@
1966219670
** This version of the memory allocation subsystem is included
1966319671
** in the build only if SQLITE_ENABLE_MEMSYS5 is defined.
1966419672
**
1966519673
** This memory allocator uses the following algorithm:
1966619674
**
19667
-** 1. All memory allocations sizes are rounded up to a power of 2.
19675
+** 1. All memory allocation sizes are rounded up to a power of 2.
1966819676
**
1966919677
** 2. If two adjacent free blocks are the halves of a larger block,
1967019678
** then the two blocks are coalesced into the single larger block.
1967119679
**
1967219680
** 3. New memory is allocated from the first available free block.
@@ -19754,11 +19762,11 @@
1975419762
u32 maxRequest; /* Largest allocation (exclusive of internal frag) */
1975519763
1975619764
/*
1975719765
** Lists of free blocks. aiFreelist[0] is a list of free blocks of
1975819766
** size mem5.szAtom. aiFreelist[1] holds blocks of size szAtom*2.
19759
- ** and so forth.
19767
+ ** aiFreelist[2] holds free blocks of size szAtom*4. And so forth.
1976019768
*/
1976119769
int aiFreelist[LOGMAX+1];
1976219770
1976319771
/*
1976419772
** Space for tracking which blocks are checked out and the size
@@ -19820,25 +19828,22 @@
1982019828
}
1982119829
mem5.aiFreelist[iLogsize] = i;
1982219830
}
1982319831
1982419832
/*
19825
-** If the STATIC_MEM mutex is not already held, obtain it now. The mutex
19826
-** will already be held (obtained by code in malloc.c) if
19827
-** sqlite3GlobalConfig.bMemStat is true.
19833
+** Obtain or release the mutex needed to access global data structures.
1982819834
*/
1982919835
static void memsys5Enter(void){
1983019836
sqlite3_mutex_enter(mem5.mutex);
1983119837
}
1983219838
static void memsys5Leave(void){
1983319839
sqlite3_mutex_leave(mem5.mutex);
1983419840
}
1983519841
1983619842
/*
19837
-** Return the size of an outstanding allocation, in bytes. The
19838
-** size returned omits the 8-byte header overhead. This only
19839
-** works for chunks that are currently checked out.
19843
+** Return the size of an outstanding allocation, in bytes.
19844
+** This only works for chunks that are currently checked out.
1984019845
*/
1984119846
static int memsys5Size(void *p){
1984219847
int iSize, i;
1984319848
assert( p!=0 );
1984419849
i = (int)(((u8 *)p-mem5.zPool)/mem5.szAtom);
@@ -19867,20 +19872,16 @@
1986719872
assert( nByte>0 );
1986819873
1986919874
/* Keep track of the maximum allocation request. Even unfulfilled
1987019875
** requests are counted */
1987119876
if( (u32)nByte>mem5.maxRequest ){
19877
+ /* Abort if the requested allocation size is larger than the largest
19878
+ ** power of two that we can represent using 32-bit signed integers. */
19879
+ if( nByte > 0x40000000 ) return 0;
1987219880
mem5.maxRequest = nByte;
1987319881
}
1987419882
19875
- /* Abort if the requested allocation size is larger than the largest
19876
- ** power of two that we can represent using 32-bit signed integers.
19877
- */
19878
- if( nByte > 0x40000000 ){
19879
- return 0;
19880
- }
19881
-
1988219883
/* Round nByte up to the next valid power of two */
1988319884
for(iFullSz=mem5.szAtom,iLogsize=0; iFullSz<nByte; iFullSz*=2,iLogsize++){}
1988419885
1988519886
/* Make sure mem5.aiFreelist[iLogsize] contains at least one free
1988619887
** block. If not, then split a block of the next larger power of
@@ -20035,17 +20036,15 @@
2003520036
}
2003620037
nOld = memsys5Size(pPrior);
2003720038
if( nBytes<=nOld ){
2003820039
return pPrior;
2003920040
}
20040
- memsys5Enter();
20041
- p = memsys5MallocUnsafe(nBytes);
20041
+ p = memsys5Malloc(nBytes);
2004220042
if( p ){
2004320043
memcpy(p, pPrior, nOld);
20044
- memsys5FreeUnsafe(pPrior);
20044
+ memsys5Free(pPrior);
2004520045
}
20046
- memsys5Leave();
2004720046
return p;
2004820047
}
2004920048
2005020049
/*
2005120050
** Round up a request size to the next valid allocation size. If
@@ -41848,11 +41847,11 @@
4184841847
** Free an allocated buffer obtained from pcache1Alloc().
4184941848
*/
4185041849
static void pcache1Free(void *p){
4185141850
int nFreed = 0;
4185241851
if( p==0 ) return;
41853
- if( p>=pcache1.pStart && p<pcache1.pEnd ){
41852
+ if( SQLITE_WITHIN(p, pcache1.pStart, pcache1.pEnd) ){
4185441853
PgFreeslot *pSlot;
4185541854
sqlite3_mutex_enter(pcache1.mutex);
4185641855
sqlite3StatusDown(SQLITE_STATUS_PAGECACHE_USED, 1);
4185741856
pSlot = (PgFreeslot*)p;
4185841857
pSlot->pNext = pcache1.pFree;
@@ -53187,10 +53186,11 @@
5318753186
** with *pSnapshot and set *pChanged as appropriate for opening the
5318853187
** snapshot. */
5318953188
if( !memcmp(pSnapshot->aSalt, pWal->hdr.aSalt, sizeof(pWal->hdr.aSalt))
5319053189
&& pSnapshot->mxFrame>=pInfo->nBackfillAttempted
5319153190
){
53191
+ assert( pWal->readLock>0 );
5319253192
memcpy(&pWal->hdr, pSnapshot, sizeof(WalIndexHdr));
5319353193
*pChanged = bChanged;
5319453194
}else{
5319553195
rc = SQLITE_BUSY_SNAPSHOT;
5319653196
}
@@ -61549,11 +61549,11 @@
6154961549
memcpy(&pTmp[i], &aData[i], usableSize - i);
6155061550
6155161551
pData = pEnd;
6155261552
for(i=0; i<nCell; i++){
6155361553
u8 *pCell = apCell[i];
61554
- if( pCell>aData && pCell<pEnd ){
61554
+ if( SQLITE_WITHIN(pCell,aData,pEnd) ){
6155561555
pCell = &pTmp[pCell - aData];
6155661556
}
6155761557
pData -= szCell[i];
6155861558
put2byte(pCellptr, (pData - aData));
6155961559
pCellptr += 2;
@@ -61660,11 +61660,11 @@
6166061660
u8 *pFree = 0;
6166161661
int szFree = 0;
6166261662
6166361663
for(i=iFirst; i<iEnd; i++){
6166461664
u8 *pCell = pCArray->apCell[i];
61665
- if( pCell>=pStart && pCell<pEnd ){
61665
+ if( SQLITE_WITHIN(pCell, pStart, pEnd) ){
6166661666
int sz;
6166761667
/* No need to use cachedCellSize() here. The sizes of all cells that
6166861668
** are to be freed have already been computing while deciding which
6166961669
** cells need freeing */
6167061670
sz = pCArray->szCell[i]; assert( sz>0 );
@@ -75650,10 +75650,11 @@
7565075650
** then the result is always NULL.
7565175651
** The jump is taken if the SQLITE_JUMPIFNULL bit is set.
7565275652
*/
7565375653
if( pOp->p5 & SQLITE_STOREP2 ){
7565475654
pOut = &aMem[pOp->p2];
75655
+ memAboutToChange(p, pOut);
7565575656
MemSetTypeFlag(pOut, MEM_Null);
7565675657
REGISTER_TRACE(pOp->p2, pOut);
7565775658
}else{
7565875659
VdbeBranchTaken(2,3);
7565975660
if( pOp->p5 & SQLITE_JUMPIFNULL ){
@@ -76192,10 +76193,12 @@
7619276193
|| (offset64 > pC->payloadSize)
7619376194
){
7619476195
rc = SQLITE_CORRUPT_BKPT;
7619576196
goto op_column_error;
7619676197
}
76198
+ }else{
76199
+ VVA_ONLY( t = 0; ) /* Only needed by assert() statements */
7619776200
}
7619876201
7619976202
/* If after trying to extract new entries from the header, nHdrParsed is
7620076203
** still not up to p2, that means that the record has fewer than p2
7620176204
** columns. So the result will be either the default value or a NULL.
@@ -88316,11 +88319,11 @@
8831688319
i16 iTabCol = pIdx->aiColumn[iIdxCol];
8831788320
if( iTabCol==XN_EXPR ){
8831888321
assert( pIdx->aColExpr );
8831988322
assert( pIdx->aColExpr->nExpr>iIdxCol );
8832088323
pParse->iSelfTab = iTabCur;
88321
- sqlite3ExprCode(pParse, pIdx->aColExpr->a[iIdxCol].pExpr, regOut);
88324
+ sqlite3ExprCodeCopy(pParse, pIdx->aColExpr->a[iIdxCol].pExpr, regOut);
8832288325
}else{
8832388326
sqlite3ExprCodeGetColumnOfTable(pParse->pVdbe, pIdx->pTable, iTabCur,
8832488327
iTabCol, regOut);
8832588328
}
8832688329
}
@@ -89169,16 +89172,28 @@
8916989172
assert( target>0 && target<=pParse->nMem );
8917089173
if( pExpr && pExpr->op==TK_REGISTER ){
8917189174
sqlite3VdbeAddOp2(pParse->pVdbe, OP_Copy, pExpr->iTable, target);
8917289175
}else{
8917389176
inReg = sqlite3ExprCodeTarget(pParse, pExpr, target);
89174
- assert( pParse->pVdbe || pParse->db->mallocFailed );
89177
+ assert( pParse->pVdbe!=0 || pParse->db->mallocFailed );
8917589178
if( inReg!=target && pParse->pVdbe ){
8917689179
sqlite3VdbeAddOp2(pParse->pVdbe, OP_SCopy, inReg, target);
8917789180
}
8917889181
}
8917989182
}
89183
+
89184
+/*
89185
+** Make a transient copy of expression pExpr and then code it using
89186
+** sqlite3ExprCode(). This routine works just like sqlite3ExprCode()
89187
+** except that the input expression is guaranteed to be unchanged.
89188
+*/
89189
+SQLITE_PRIVATE void sqlite3ExprCodeCopy(Parse *pParse, Expr *pExpr, int target){
89190
+ sqlite3 *db = pParse->db;
89191
+ pExpr = sqlite3ExprDup(db, pExpr, 0);
89192
+ if( !db->mallocFailed ) sqlite3ExprCode(pParse, pExpr, target);
89193
+ sqlite3ExprDelete(db, pExpr);
89194
+}
8918089195
8918189196
/*
8918289197
** Generate code that will evaluate expression pExpr and store the
8918389198
** results in register target. The results are guaranteed to appear
8918489199
** in register target. If the expression is constant, then this routine
@@ -104114,11 +104129,11 @@
104114104129
for(i=0; i<pIdx->nColumn; i++){
104115104130
int iField = pIdx->aiColumn[i];
104116104131
int x;
104117104132
if( iField==XN_EXPR ){
104118104133
pParse->ckBase = regNewData+1;
104119
- sqlite3ExprCode(pParse, pIdx->aColExpr->a[i].pExpr, regIdx+i);
104134
+ sqlite3ExprCodeCopy(pParse, pIdx->aColExpr->a[i].pExpr, regIdx+i);
104120104135
pParse->ckBase = 0;
104121104136
VdbeComment((v, "%s column %d", pIdx->zName, i));
104122104137
}else{
104123104138
if( iField==XN_ROWID || iField==pTab->iPKey ){
104124104139
if( regRowid==regIdx+i ) continue; /* ROWID already in regIdx+i */
@@ -106627,11 +106642,11 @@
106627106642
{ /* zName: */ "page_size",
106628106643
/* ePragTyp: */ PragTyp_PAGE_SIZE,
106629106644
/* ePragFlag: */ 0,
106630106645
/* iArg: */ 0 },
106631106646
#endif
106632
-#if defined(SQLITE_DEBUG)
106647
+#if defined(SQLITE_DEBUG) && !defined(SQLITE_OMIT_PARSER_TRACE)
106633106648
{ /* zName: */ "parser_trace",
106634106649
/* ePragTyp: */ PragTyp_PARSER_TRACE,
106635106650
/* ePragFlag: */ 0,
106636106651
/* iArg: */ 0 },
106637106652
#endif
@@ -171613,11 +171628,11 @@
171613171628
}else{
171614171629
rc = sqlite3Fts5IterPoslist(pTerm->pIter, pColset, &a, &n, &dummy);
171615171630
}
171616171631
if( rc!=SQLITE_OK ) goto ismatch_out;
171617171632
sqlite3Fts5PoslistReaderInit(a, n, &aIter[i]);
171618
- aIter[i].bFlag = bFlag;
171633
+ aIter[i].bFlag = (u8)bFlag;
171619171634
if( aIter[i].bEof ) goto ismatch_out;
171620171635
}
171621171636
171622171637
while( 1 ){
171623171638
int bMatch;
@@ -173611,11 +173626,11 @@
173611173626
int nSz = (p->nData - p->iSzPoslist - 1); /* Size in bytes */
173612173627
int nPos = nSz*2 + p->bDel; /* Value of nPos field */
173613173628
173614173629
assert( p->bDel==0 || p->bDel==1 );
173615173630
if( nPos<=127 ){
173616
- pPtr[p->iSzPoslist] = nPos;
173631
+ pPtr[p->iSzPoslist] = (u8)nPos;
173617173632
}else{
173618173633
int nByte = sqlite3Fts5GetVarintLen((u32)nPos);
173619173634
memmove(&pPtr[p->iSzPoslist + nByte], &pPtr[p->iSzPoslist + 1], nSz);
173620173635
sqlite3Fts5PutVarint(&pPtr[p->iSzPoslist], nPos);
173621173636
p->nData += (nByte-1);
@@ -176287,11 +176302,11 @@
176287176302
}else{
176288176303
iRes = i2;
176289176304
}
176290176305
}
176291176306
176292
- pRes->iFirst = iRes;
176307
+ pRes->iFirst = (u16)iRes;
176293176308
return 0;
176294176309
}
176295176310
176296176311
/*
176297176312
** Move the seg-iter so that it points to the first rowid on page iLeafPgno.
@@ -176454,11 +176469,11 @@
176454176469
pNew = pOther;
176455176470
}else if( (pOther->iRowid>pIter->iSwitchRowid)==pIter->bRev ){
176456176471
pIter->iSwitchRowid = pOther->iRowid;
176457176472
}
176458176473
}
176459
- pRes->iFirst = (pNew - pIter->aSeg);
176474
+ pRes->iFirst = (u16)(pNew - pIter->aSeg);
176460176475
if( i==1 ) break;
176461176476
176462176477
pOther = &pIter->aSeg[ pIter->aFirst[i ^ 0x0001].iFirst ];
176463176478
}
176464176479
}
@@ -176605,11 +176620,11 @@
176605176620
}
176606176621
}
176607176622
*ppOut = pNew = fts5MultiIterAlloc(p, nSeg);
176608176623
if( pNew==0 ) return;
176609176624
pNew->bRev = (0!=(flags & FTS5INDEX_QUERY_DESC));
176610
- pNew->bSkipEmpty = bSkipEmpty;
176625
+ pNew->bSkipEmpty = (u8)bSkipEmpty;
176611176626
pNew->pStruct = pStruct;
176612176627
fts5StructureRef(pStruct);
176613176628
176614176629
/* Initialize each of the component segment iterators. */
176615176630
if( iLevel<0 ){
@@ -177068,11 +177083,11 @@
177068177083
177069177084
assert( (pPage->pgidx.n==0)==(pWriter->bFirstTermInPage) );
177070177085
177071177086
/* Set the szLeaf header field. */
177072177087
assert( 0==fts5GetU16(&pPage->buf.p[2]) );
177073
- fts5PutU16(&pPage->buf.p[2], pPage->buf.n);
177088
+ fts5PutU16(&pPage->buf.p[2], (u16)pPage->buf.n);
177074177089
177075177090
if( pWriter->bFirstTermInPage ){
177076177091
/* No term was written to this page. */
177077177092
assert( pPage->pgidx.n==0 );
177078177093
fts5WriteBtreeNoTerm(p, pWriter);
@@ -177200,11 +177215,11 @@
177200177215
177201177216
/* If this is to be the first rowid written to the page, set the
177202177217
** rowid-pointer in the page-header. Also append a value to the dlidx
177203177218
** buffer, in case a doclist-index is required. */
177204177219
if( pWriter->bFirstRowidInPage ){
177205
- fts5PutU16(pPage->buf.p, pPage->buf.n);
177220
+ fts5PutU16(pPage->buf.p, (u16)pPage->buf.n);
177206177221
fts5WriteDlidxAppend(p, pWriter, iRowid);
177207177222
}
177208177223
177209177224
/* Write the rowid. */
177210177225
if( pWriter->bFirstRowidInDoclist || pWriter->bFirstRowidInPage ){
@@ -177358,11 +177373,11 @@
177358177373
fts5BufferAppendVarint(&p->rc, &buf, pSeg->term.n);
177359177374
fts5BufferAppendBlob(&p->rc, &buf, pSeg->term.n, pSeg->term.p);
177360177375
fts5BufferAppendBlob(&p->rc, &buf, pData->szLeaf-iOff, &pData->p[iOff]);
177361177376
if( p->rc==SQLITE_OK ){
177362177377
/* Set the szLeaf field */
177363
- fts5PutU16(&buf.p[2], buf.n);
177378
+ fts5PutU16(&buf.p[2], (u16)buf.n);
177364177379
}
177365177380
177366177381
/* Set up the new page-index array */
177367177382
fts5BufferAppendVarint(&p->rc, &buf, 4);
177368177383
if( pSeg->iLeafPgno==pSeg->iTermLeafPgno
@@ -177724,11 +177739,11 @@
177724177739
nCopy = fts5GetPoslistSize(&pDoclist[iOff], &nPos, &bDummy);
177725177740
nCopy += nPos;
177726177741
iRowid += iDelta;
177727177742
177728177743
if( writer.bFirstRowidInPage ){
177729
- fts5PutU16(&pBuf->p[0], pBuf->n); /* first rowid on page */
177744
+ fts5PutU16(&pBuf->p[0], (u16)pBuf->n); /* first rowid on page */
177730177745
pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], iRowid);
177731177746
writer.bFirstRowidInPage = 0;
177732177747
fts5WriteDlidxAppend(p, &writer, iRowid);
177733177748
}else{
177734177749
pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], iDelta);
@@ -178521,11 +178536,12 @@
178521178536
178522178537
for(i=0; i<pConfig->nPrefix && rc==SQLITE_OK; i++){
178523178538
int nByte = fts5IndexCharlenToBytelen(pToken, nToken, pConfig->aPrefix[i]);
178524178539
if( nByte ){
178525178540
rc = sqlite3Fts5HashWrite(p->pHash,
178526
- p->iWriteRowid, iCol, iPos, FTS5_MAIN_PREFIX+i+1, pToken, nByte
178541
+ p->iWriteRowid, iCol, iPos, (char)(FTS5_MAIN_PREFIX+i+1), pToken,
178542
+ nByte
178527178543
);
178528178544
}
178529178545
}
178530178546
178531178547
return rc;
@@ -178571,11 +178587,11 @@
178571178587
}
178572178588
}
178573178589
178574178590
if( iIdx<=pConfig->nPrefix ){
178575178591
Fts5Structure *pStruct = fts5StructureRead(p);
178576
- buf.p[0] = FTS5_MAIN_PREFIX + iIdx;
178592
+ buf.p[0] = (u8)(FTS5_MAIN_PREFIX + iIdx);
178577178593
if( pStruct ){
178578178594
fts5MultiIterNew(p, pStruct, 1, flags, buf.p, nToken+1, -1, 0, &pRet);
178579178595
fts5StructureRelease(pStruct);
178580178596
}
178581178597
}else{
@@ -180277,11 +180293,11 @@
180277180293
iNext = 1;
180278180294
for(i=0; i<sizeof(aConstraint)/sizeof(aConstraint[0]); i++){
180279180295
struct Constraint *pC = &aConstraint[i];
180280180296
if( pC->iConsIndex>=0 ){
180281180297
pInfo->aConstraintUsage[pC->iConsIndex].argvIndex = iNext++;
180282
- pInfo->aConstraintUsage[pC->iConsIndex].omit = pC->omit;
180298
+ pInfo->aConstraintUsage[pC->iConsIndex].omit = (unsigned char)pC->omit;
180283180299
}
180284180300
}
180285180301
180286180302
pInfo->idxNum = idxFlags;
180287180303
return SQLITE_OK;
@@ -182123,11 +182139,11 @@
182123182139
sqlite3_context *pCtx, /* Function call context */
182124182140
int nArg, /* Number of args */
182125182141
sqlite3_value **apVal /* Function arguments */
182126182142
){
182127182143
assert( nArg==0 );
182128
- sqlite3_result_text(pCtx, "fts5: 2015-12-11 13:51:02 e998513e442ce1206b12dc28bdc996d7b5f9f94d", -1, SQLITE_TRANSIENT);
182144
+ sqlite3_result_text(pCtx, "fts5: 2015-12-18 16:29:47 8bf5e056eb8beb6e0ed5874fb24d7fe9f0b66d2b", -1, SQLITE_TRANSIENT);
182129182145
}
182130182146
182131182147
static int fts5Init(sqlite3 *db){
182132182148
static const sqlite3_module fts5Mod = {
182133182149
/* iVersion */ 2,
@@ -183590,11 +183606,11 @@
183590183606
while( zCsr<zTerm ){
183591183607
int iCode;
183592183608
int bToken;
183593183609
READ_UTF8(zCsr, zTerm, iCode);
183594183610
if( iCode<128 ){
183595
- p->aTokenChar[iCode] = bTokenChars;
183611
+ p->aTokenChar[iCode] = (unsigned char)bTokenChars;
183596183612
}else{
183597183613
bToken = sqlite3Fts5UnicodeIsalnum(iCode);
183598183614
assert( (bToken==0 || bToken==1) );
183599183615
assert( (bTokenChars==0 || bTokenChars==1) );
183600183616
if( bToken!=bTokenChars && sqlite3Fts5UnicodeIsdiacritic(iCode)==0 ){
183601183617
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -325,11 +325,11 @@
325 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
326 ** [sqlite_version()] and [sqlite_source_id()].
327 */
328 #define SQLITE_VERSION "3.10.0"
329 #define SQLITE_VERSION_NUMBER 3010000
330 #define SQLITE_SOURCE_ID "2015-12-11 13:51:02 e998513e442ce1206b12dc28bdc996d7b5f9f94d"
331
332 /*
333 ** CAPI3REF: Run-Time Library Version Numbers
334 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
335 **
@@ -14256,10 +14256,11 @@
14256 SQLITE_PRIVATE void sqlite3ExprCachePop(Parse*);
14257 SQLITE_PRIVATE void sqlite3ExprCacheRemove(Parse*, int, int);
14258 SQLITE_PRIVATE void sqlite3ExprCacheClear(Parse*);
14259 SQLITE_PRIVATE void sqlite3ExprCacheAffinityChange(Parse*, int, int);
14260 SQLITE_PRIVATE void sqlite3ExprCode(Parse*, Expr*, int);
 
14261 SQLITE_PRIVATE void sqlite3ExprCodeFactorable(Parse*, Expr*, int);
14262 SQLITE_PRIVATE void sqlite3ExprCodeAtInit(Parse*, Expr*, int, u8);
14263 SQLITE_PRIVATE int sqlite3ExprCodeTemp(Parse*, Expr*, int*);
14264 SQLITE_PRIVATE int sqlite3ExprCodeTarget(Parse*, Expr*, int);
14265 SQLITE_PRIVATE void sqlite3ExprCodeAndCache(Parse*, Expr*, int);
@@ -16491,10 +16492,11 @@
16491 double s; /* Seconds */
16492 char validYMD; /* True (1) if Y,M,D are valid */
16493 char validHMS; /* True (1) if h,m,s are valid */
16494 char validJD; /* True (1) if iJD is valid */
16495 char validTZ; /* True (1) if tz is valid */
 
16496 };
16497
16498
16499 /*
16500 ** Convert zDate into one or more integers. Additional arguments
@@ -16584,10 +16586,11 @@
16584 }
16585 zDate += 5;
16586 p->tz = sgn*(nMn + nHr*60);
16587 zulu_time:
16588 while( sqlite3Isspace(*zDate) ){ zDate++; }
 
16589 return *zDate!=0;
16590 }
16591
16592 /*
16593 ** Parse times of the form HH:MM or HH:MM:SS or HH:MM:SS.FFFF.
@@ -17016,17 +17019,22 @@
17016 clearYMD_HMS_TZ(p);
17017 rc = 0;
17018 }
17019 #ifndef SQLITE_OMIT_LOCALTIME
17020 else if( strcmp(z, "utc")==0 ){
17021 sqlite3_int64 c1;
17022 computeJD(p);
17023 c1 = localtimeOffset(p, pCtx, &rc);
17024 if( rc==SQLITE_OK ){
17025 p->iJD -= c1;
17026 clearYMD_HMS_TZ(p);
17027 p->iJD += c1 - localtimeOffset(p, pCtx, &rc);
 
 
 
 
 
17028 }
17029 }
17030 #endif
17031 break;
17032 }
@@ -19662,11 +19670,11 @@
19662 ** This version of the memory allocation subsystem is included
19663 ** in the build only if SQLITE_ENABLE_MEMSYS5 is defined.
19664 **
19665 ** This memory allocator uses the following algorithm:
19666 **
19667 ** 1. All memory allocations sizes are rounded up to a power of 2.
19668 **
19669 ** 2. If two adjacent free blocks are the halves of a larger block,
19670 ** then the two blocks are coalesced into the single larger block.
19671 **
19672 ** 3. New memory is allocated from the first available free block.
@@ -19754,11 +19762,11 @@
19754 u32 maxRequest; /* Largest allocation (exclusive of internal frag) */
19755
19756 /*
19757 ** Lists of free blocks. aiFreelist[0] is a list of free blocks of
19758 ** size mem5.szAtom. aiFreelist[1] holds blocks of size szAtom*2.
19759 ** and so forth.
19760 */
19761 int aiFreelist[LOGMAX+1];
19762
19763 /*
19764 ** Space for tracking which blocks are checked out and the size
@@ -19820,25 +19828,22 @@
19820 }
19821 mem5.aiFreelist[iLogsize] = i;
19822 }
19823
19824 /*
19825 ** If the STATIC_MEM mutex is not already held, obtain it now. The mutex
19826 ** will already be held (obtained by code in malloc.c) if
19827 ** sqlite3GlobalConfig.bMemStat is true.
19828 */
19829 static void memsys5Enter(void){
19830 sqlite3_mutex_enter(mem5.mutex);
19831 }
19832 static void memsys5Leave(void){
19833 sqlite3_mutex_leave(mem5.mutex);
19834 }
19835
19836 /*
19837 ** Return the size of an outstanding allocation, in bytes. The
19838 ** size returned omits the 8-byte header overhead. This only
19839 ** works for chunks that are currently checked out.
19840 */
19841 static int memsys5Size(void *p){
19842 int iSize, i;
19843 assert( p!=0 );
19844 i = (int)(((u8 *)p-mem5.zPool)/mem5.szAtom);
@@ -19867,20 +19872,16 @@
19867 assert( nByte>0 );
19868
19869 /* Keep track of the maximum allocation request. Even unfulfilled
19870 ** requests are counted */
19871 if( (u32)nByte>mem5.maxRequest ){
 
 
 
19872 mem5.maxRequest = nByte;
19873 }
19874
19875 /* Abort if the requested allocation size is larger than the largest
19876 ** power of two that we can represent using 32-bit signed integers.
19877 */
19878 if( nByte > 0x40000000 ){
19879 return 0;
19880 }
19881
19882 /* Round nByte up to the next valid power of two */
19883 for(iFullSz=mem5.szAtom,iLogsize=0; iFullSz<nByte; iFullSz*=2,iLogsize++){}
19884
19885 /* Make sure mem5.aiFreelist[iLogsize] contains at least one free
19886 ** block. If not, then split a block of the next larger power of
@@ -20035,17 +20036,15 @@
20035 }
20036 nOld = memsys5Size(pPrior);
20037 if( nBytes<=nOld ){
20038 return pPrior;
20039 }
20040 memsys5Enter();
20041 p = memsys5MallocUnsafe(nBytes);
20042 if( p ){
20043 memcpy(p, pPrior, nOld);
20044 memsys5FreeUnsafe(pPrior);
20045 }
20046 memsys5Leave();
20047 return p;
20048 }
20049
20050 /*
20051 ** Round up a request size to the next valid allocation size. If
@@ -41848,11 +41847,11 @@
41848 ** Free an allocated buffer obtained from pcache1Alloc().
41849 */
41850 static void pcache1Free(void *p){
41851 int nFreed = 0;
41852 if( p==0 ) return;
41853 if( p>=pcache1.pStart && p<pcache1.pEnd ){
41854 PgFreeslot *pSlot;
41855 sqlite3_mutex_enter(pcache1.mutex);
41856 sqlite3StatusDown(SQLITE_STATUS_PAGECACHE_USED, 1);
41857 pSlot = (PgFreeslot*)p;
41858 pSlot->pNext = pcache1.pFree;
@@ -53187,10 +53186,11 @@
53187 ** with *pSnapshot and set *pChanged as appropriate for opening the
53188 ** snapshot. */
53189 if( !memcmp(pSnapshot->aSalt, pWal->hdr.aSalt, sizeof(pWal->hdr.aSalt))
53190 && pSnapshot->mxFrame>=pInfo->nBackfillAttempted
53191 ){
 
53192 memcpy(&pWal->hdr, pSnapshot, sizeof(WalIndexHdr));
53193 *pChanged = bChanged;
53194 }else{
53195 rc = SQLITE_BUSY_SNAPSHOT;
53196 }
@@ -61549,11 +61549,11 @@
61549 memcpy(&pTmp[i], &aData[i], usableSize - i);
61550
61551 pData = pEnd;
61552 for(i=0; i<nCell; i++){
61553 u8 *pCell = apCell[i];
61554 if( pCell>aData && pCell<pEnd ){
61555 pCell = &pTmp[pCell - aData];
61556 }
61557 pData -= szCell[i];
61558 put2byte(pCellptr, (pData - aData));
61559 pCellptr += 2;
@@ -61660,11 +61660,11 @@
61660 u8 *pFree = 0;
61661 int szFree = 0;
61662
61663 for(i=iFirst; i<iEnd; i++){
61664 u8 *pCell = pCArray->apCell[i];
61665 if( pCell>=pStart && pCell<pEnd ){
61666 int sz;
61667 /* No need to use cachedCellSize() here. The sizes of all cells that
61668 ** are to be freed have already been computing while deciding which
61669 ** cells need freeing */
61670 sz = pCArray->szCell[i]; assert( sz>0 );
@@ -75650,10 +75650,11 @@
75650 ** then the result is always NULL.
75651 ** The jump is taken if the SQLITE_JUMPIFNULL bit is set.
75652 */
75653 if( pOp->p5 & SQLITE_STOREP2 ){
75654 pOut = &aMem[pOp->p2];
 
75655 MemSetTypeFlag(pOut, MEM_Null);
75656 REGISTER_TRACE(pOp->p2, pOut);
75657 }else{
75658 VdbeBranchTaken(2,3);
75659 if( pOp->p5 & SQLITE_JUMPIFNULL ){
@@ -76192,10 +76193,12 @@
76192 || (offset64 > pC->payloadSize)
76193 ){
76194 rc = SQLITE_CORRUPT_BKPT;
76195 goto op_column_error;
76196 }
 
 
76197 }
76198
76199 /* If after trying to extract new entries from the header, nHdrParsed is
76200 ** still not up to p2, that means that the record has fewer than p2
76201 ** columns. So the result will be either the default value or a NULL.
@@ -88316,11 +88319,11 @@
88316 i16 iTabCol = pIdx->aiColumn[iIdxCol];
88317 if( iTabCol==XN_EXPR ){
88318 assert( pIdx->aColExpr );
88319 assert( pIdx->aColExpr->nExpr>iIdxCol );
88320 pParse->iSelfTab = iTabCur;
88321 sqlite3ExprCode(pParse, pIdx->aColExpr->a[iIdxCol].pExpr, regOut);
88322 }else{
88323 sqlite3ExprCodeGetColumnOfTable(pParse->pVdbe, pIdx->pTable, iTabCur,
88324 iTabCol, regOut);
88325 }
88326 }
@@ -89169,16 +89172,28 @@
89169 assert( target>0 && target<=pParse->nMem );
89170 if( pExpr && pExpr->op==TK_REGISTER ){
89171 sqlite3VdbeAddOp2(pParse->pVdbe, OP_Copy, pExpr->iTable, target);
89172 }else{
89173 inReg = sqlite3ExprCodeTarget(pParse, pExpr, target);
89174 assert( pParse->pVdbe || pParse->db->mallocFailed );
89175 if( inReg!=target && pParse->pVdbe ){
89176 sqlite3VdbeAddOp2(pParse->pVdbe, OP_SCopy, inReg, target);
89177 }
89178 }
89179 }
 
 
 
 
 
 
 
 
 
 
 
 
89180
89181 /*
89182 ** Generate code that will evaluate expression pExpr and store the
89183 ** results in register target. The results are guaranteed to appear
89184 ** in register target. If the expression is constant, then this routine
@@ -104114,11 +104129,11 @@
104114 for(i=0; i<pIdx->nColumn; i++){
104115 int iField = pIdx->aiColumn[i];
104116 int x;
104117 if( iField==XN_EXPR ){
104118 pParse->ckBase = regNewData+1;
104119 sqlite3ExprCode(pParse, pIdx->aColExpr->a[i].pExpr, regIdx+i);
104120 pParse->ckBase = 0;
104121 VdbeComment((v, "%s column %d", pIdx->zName, i));
104122 }else{
104123 if( iField==XN_ROWID || iField==pTab->iPKey ){
104124 if( regRowid==regIdx+i ) continue; /* ROWID already in regIdx+i */
@@ -106627,11 +106642,11 @@
106627 { /* zName: */ "page_size",
106628 /* ePragTyp: */ PragTyp_PAGE_SIZE,
106629 /* ePragFlag: */ 0,
106630 /* iArg: */ 0 },
106631 #endif
106632 #if defined(SQLITE_DEBUG)
106633 { /* zName: */ "parser_trace",
106634 /* ePragTyp: */ PragTyp_PARSER_TRACE,
106635 /* ePragFlag: */ 0,
106636 /* iArg: */ 0 },
106637 #endif
@@ -171613,11 +171628,11 @@
171613 }else{
171614 rc = sqlite3Fts5IterPoslist(pTerm->pIter, pColset, &a, &n, &dummy);
171615 }
171616 if( rc!=SQLITE_OK ) goto ismatch_out;
171617 sqlite3Fts5PoslistReaderInit(a, n, &aIter[i]);
171618 aIter[i].bFlag = bFlag;
171619 if( aIter[i].bEof ) goto ismatch_out;
171620 }
171621
171622 while( 1 ){
171623 int bMatch;
@@ -173611,11 +173626,11 @@
173611 int nSz = (p->nData - p->iSzPoslist - 1); /* Size in bytes */
173612 int nPos = nSz*2 + p->bDel; /* Value of nPos field */
173613
173614 assert( p->bDel==0 || p->bDel==1 );
173615 if( nPos<=127 ){
173616 pPtr[p->iSzPoslist] = nPos;
173617 }else{
173618 int nByte = sqlite3Fts5GetVarintLen((u32)nPos);
173619 memmove(&pPtr[p->iSzPoslist + nByte], &pPtr[p->iSzPoslist + 1], nSz);
173620 sqlite3Fts5PutVarint(&pPtr[p->iSzPoslist], nPos);
173621 p->nData += (nByte-1);
@@ -176287,11 +176302,11 @@
176287 }else{
176288 iRes = i2;
176289 }
176290 }
176291
176292 pRes->iFirst = iRes;
176293 return 0;
176294 }
176295
176296 /*
176297 ** Move the seg-iter so that it points to the first rowid on page iLeafPgno.
@@ -176454,11 +176469,11 @@
176454 pNew = pOther;
176455 }else if( (pOther->iRowid>pIter->iSwitchRowid)==pIter->bRev ){
176456 pIter->iSwitchRowid = pOther->iRowid;
176457 }
176458 }
176459 pRes->iFirst = (pNew - pIter->aSeg);
176460 if( i==1 ) break;
176461
176462 pOther = &pIter->aSeg[ pIter->aFirst[i ^ 0x0001].iFirst ];
176463 }
176464 }
@@ -176605,11 +176620,11 @@
176605 }
176606 }
176607 *ppOut = pNew = fts5MultiIterAlloc(p, nSeg);
176608 if( pNew==0 ) return;
176609 pNew->bRev = (0!=(flags & FTS5INDEX_QUERY_DESC));
176610 pNew->bSkipEmpty = bSkipEmpty;
176611 pNew->pStruct = pStruct;
176612 fts5StructureRef(pStruct);
176613
176614 /* Initialize each of the component segment iterators. */
176615 if( iLevel<0 ){
@@ -177068,11 +177083,11 @@
177068
177069 assert( (pPage->pgidx.n==0)==(pWriter->bFirstTermInPage) );
177070
177071 /* Set the szLeaf header field. */
177072 assert( 0==fts5GetU16(&pPage->buf.p[2]) );
177073 fts5PutU16(&pPage->buf.p[2], pPage->buf.n);
177074
177075 if( pWriter->bFirstTermInPage ){
177076 /* No term was written to this page. */
177077 assert( pPage->pgidx.n==0 );
177078 fts5WriteBtreeNoTerm(p, pWriter);
@@ -177200,11 +177215,11 @@
177200
177201 /* If this is to be the first rowid written to the page, set the
177202 ** rowid-pointer in the page-header. Also append a value to the dlidx
177203 ** buffer, in case a doclist-index is required. */
177204 if( pWriter->bFirstRowidInPage ){
177205 fts5PutU16(pPage->buf.p, pPage->buf.n);
177206 fts5WriteDlidxAppend(p, pWriter, iRowid);
177207 }
177208
177209 /* Write the rowid. */
177210 if( pWriter->bFirstRowidInDoclist || pWriter->bFirstRowidInPage ){
@@ -177358,11 +177373,11 @@
177358 fts5BufferAppendVarint(&p->rc, &buf, pSeg->term.n);
177359 fts5BufferAppendBlob(&p->rc, &buf, pSeg->term.n, pSeg->term.p);
177360 fts5BufferAppendBlob(&p->rc, &buf, pData->szLeaf-iOff, &pData->p[iOff]);
177361 if( p->rc==SQLITE_OK ){
177362 /* Set the szLeaf field */
177363 fts5PutU16(&buf.p[2], buf.n);
177364 }
177365
177366 /* Set up the new page-index array */
177367 fts5BufferAppendVarint(&p->rc, &buf, 4);
177368 if( pSeg->iLeafPgno==pSeg->iTermLeafPgno
@@ -177724,11 +177739,11 @@
177724 nCopy = fts5GetPoslistSize(&pDoclist[iOff], &nPos, &bDummy);
177725 nCopy += nPos;
177726 iRowid += iDelta;
177727
177728 if( writer.bFirstRowidInPage ){
177729 fts5PutU16(&pBuf->p[0], pBuf->n); /* first rowid on page */
177730 pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], iRowid);
177731 writer.bFirstRowidInPage = 0;
177732 fts5WriteDlidxAppend(p, &writer, iRowid);
177733 }else{
177734 pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], iDelta);
@@ -178521,11 +178536,12 @@
178521
178522 for(i=0; i<pConfig->nPrefix && rc==SQLITE_OK; i++){
178523 int nByte = fts5IndexCharlenToBytelen(pToken, nToken, pConfig->aPrefix[i]);
178524 if( nByte ){
178525 rc = sqlite3Fts5HashWrite(p->pHash,
178526 p->iWriteRowid, iCol, iPos, FTS5_MAIN_PREFIX+i+1, pToken, nByte
 
178527 );
178528 }
178529 }
178530
178531 return rc;
@@ -178571,11 +178587,11 @@
178571 }
178572 }
178573
178574 if( iIdx<=pConfig->nPrefix ){
178575 Fts5Structure *pStruct = fts5StructureRead(p);
178576 buf.p[0] = FTS5_MAIN_PREFIX + iIdx;
178577 if( pStruct ){
178578 fts5MultiIterNew(p, pStruct, 1, flags, buf.p, nToken+1, -1, 0, &pRet);
178579 fts5StructureRelease(pStruct);
178580 }
178581 }else{
@@ -180277,11 +180293,11 @@
180277 iNext = 1;
180278 for(i=0; i<sizeof(aConstraint)/sizeof(aConstraint[0]); i++){
180279 struct Constraint *pC = &aConstraint[i];
180280 if( pC->iConsIndex>=0 ){
180281 pInfo->aConstraintUsage[pC->iConsIndex].argvIndex = iNext++;
180282 pInfo->aConstraintUsage[pC->iConsIndex].omit = pC->omit;
180283 }
180284 }
180285
180286 pInfo->idxNum = idxFlags;
180287 return SQLITE_OK;
@@ -182123,11 +182139,11 @@
182123 sqlite3_context *pCtx, /* Function call context */
182124 int nArg, /* Number of args */
182125 sqlite3_value **apVal /* Function arguments */
182126 ){
182127 assert( nArg==0 );
182128 sqlite3_result_text(pCtx, "fts5: 2015-12-11 13:51:02 e998513e442ce1206b12dc28bdc996d7b5f9f94d", -1, SQLITE_TRANSIENT);
182129 }
182130
182131 static int fts5Init(sqlite3 *db){
182132 static const sqlite3_module fts5Mod = {
182133 /* iVersion */ 2,
@@ -183590,11 +183606,11 @@
183590 while( zCsr<zTerm ){
183591 int iCode;
183592 int bToken;
183593 READ_UTF8(zCsr, zTerm, iCode);
183594 if( iCode<128 ){
183595 p->aTokenChar[iCode] = bTokenChars;
183596 }else{
183597 bToken = sqlite3Fts5UnicodeIsalnum(iCode);
183598 assert( (bToken==0 || bToken==1) );
183599 assert( (bTokenChars==0 || bTokenChars==1) );
183600 if( bToken!=bTokenChars && sqlite3Fts5UnicodeIsdiacritic(iCode)==0 ){
183601
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -325,11 +325,11 @@
325 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
326 ** [sqlite_version()] and [sqlite_source_id()].
327 */
328 #define SQLITE_VERSION "3.10.0"
329 #define SQLITE_VERSION_NUMBER 3010000
330 #define SQLITE_SOURCE_ID "2015-12-23 10:54:48 b910a3d53769689d9212a06f974ccce54844bbe4"
331
332 /*
333 ** CAPI3REF: Run-Time Library Version Numbers
334 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
335 **
@@ -14256,10 +14256,11 @@
14256 SQLITE_PRIVATE void sqlite3ExprCachePop(Parse*);
14257 SQLITE_PRIVATE void sqlite3ExprCacheRemove(Parse*, int, int);
14258 SQLITE_PRIVATE void sqlite3ExprCacheClear(Parse*);
14259 SQLITE_PRIVATE void sqlite3ExprCacheAffinityChange(Parse*, int, int);
14260 SQLITE_PRIVATE void sqlite3ExprCode(Parse*, Expr*, int);
14261 SQLITE_PRIVATE void sqlite3ExprCodeCopy(Parse*, Expr*, int);
14262 SQLITE_PRIVATE void sqlite3ExprCodeFactorable(Parse*, Expr*, int);
14263 SQLITE_PRIVATE void sqlite3ExprCodeAtInit(Parse*, Expr*, int, u8);
14264 SQLITE_PRIVATE int sqlite3ExprCodeTemp(Parse*, Expr*, int*);
14265 SQLITE_PRIVATE int sqlite3ExprCodeTarget(Parse*, Expr*, int);
14266 SQLITE_PRIVATE void sqlite3ExprCodeAndCache(Parse*, Expr*, int);
@@ -16491,10 +16492,11 @@
16492 double s; /* Seconds */
16493 char validYMD; /* True (1) if Y,M,D are valid */
16494 char validHMS; /* True (1) if h,m,s are valid */
16495 char validJD; /* True (1) if iJD is valid */
16496 char validTZ; /* True (1) if tz is valid */
16497 char tzSet; /* Timezone was set explicitly */
16498 };
16499
16500
16501 /*
16502 ** Convert zDate into one or more integers. Additional arguments
@@ -16584,10 +16586,11 @@
16586 }
16587 zDate += 5;
16588 p->tz = sgn*(nMn + nHr*60);
16589 zulu_time:
16590 while( sqlite3Isspace(*zDate) ){ zDate++; }
16591 p->tzSet = 1;
16592 return *zDate!=0;
16593 }
16594
16595 /*
16596 ** Parse times of the form HH:MM or HH:MM:SS or HH:MM:SS.FFFF.
@@ -17016,17 +17019,22 @@
17019 clearYMD_HMS_TZ(p);
17020 rc = 0;
17021 }
17022 #ifndef SQLITE_OMIT_LOCALTIME
17023 else if( strcmp(z, "utc")==0 ){
17024 if( p->tzSet==0 ){
17025 sqlite3_int64 c1;
17026 computeJD(p);
17027 c1 = localtimeOffset(p, pCtx, &rc);
17028 if( rc==SQLITE_OK ){
17029 p->iJD -= c1;
17030 clearYMD_HMS_TZ(p);
17031 p->iJD += c1 - localtimeOffset(p, pCtx, &rc);
17032 }
17033 p->tzSet = 1;
17034 }else{
17035 rc = SQLITE_OK;
17036 }
17037 }
17038 #endif
17039 break;
17040 }
@@ -19662,11 +19670,11 @@
19670 ** This version of the memory allocation subsystem is included
19671 ** in the build only if SQLITE_ENABLE_MEMSYS5 is defined.
19672 **
19673 ** This memory allocator uses the following algorithm:
19674 **
19675 ** 1. All memory allocation sizes are rounded up to a power of 2.
19676 **
19677 ** 2. If two adjacent free blocks are the halves of a larger block,
19678 ** then the two blocks are coalesced into the single larger block.
19679 **
19680 ** 3. New memory is allocated from the first available free block.
@@ -19754,11 +19762,11 @@
19762 u32 maxRequest; /* Largest allocation (exclusive of internal frag) */
19763
19764 /*
19765 ** Lists of free blocks. aiFreelist[0] is a list of free blocks of
19766 ** size mem5.szAtom. aiFreelist[1] holds blocks of size szAtom*2.
19767 ** aiFreelist[2] holds free blocks of size szAtom*4. And so forth.
19768 */
19769 int aiFreelist[LOGMAX+1];
19770
19771 /*
19772 ** Space for tracking which blocks are checked out and the size
@@ -19820,25 +19828,22 @@
19828 }
19829 mem5.aiFreelist[iLogsize] = i;
19830 }
19831
19832 /*
19833 ** Obtain or release the mutex needed to access global data structures.
 
 
19834 */
19835 static void memsys5Enter(void){
19836 sqlite3_mutex_enter(mem5.mutex);
19837 }
19838 static void memsys5Leave(void){
19839 sqlite3_mutex_leave(mem5.mutex);
19840 }
19841
19842 /*
19843 ** Return the size of an outstanding allocation, in bytes.
19844 ** This only works for chunks that are currently checked out.
 
19845 */
19846 static int memsys5Size(void *p){
19847 int iSize, i;
19848 assert( p!=0 );
19849 i = (int)(((u8 *)p-mem5.zPool)/mem5.szAtom);
@@ -19867,20 +19872,16 @@
19872 assert( nByte>0 );
19873
19874 /* Keep track of the maximum allocation request. Even unfulfilled
19875 ** requests are counted */
19876 if( (u32)nByte>mem5.maxRequest ){
19877 /* Abort if the requested allocation size is larger than the largest
19878 ** power of two that we can represent using 32-bit signed integers. */
19879 if( nByte > 0x40000000 ) return 0;
19880 mem5.maxRequest = nByte;
19881 }
19882
 
 
 
 
 
 
 
19883 /* Round nByte up to the next valid power of two */
19884 for(iFullSz=mem5.szAtom,iLogsize=0; iFullSz<nByte; iFullSz*=2,iLogsize++){}
19885
19886 /* Make sure mem5.aiFreelist[iLogsize] contains at least one free
19887 ** block. If not, then split a block of the next larger power of
@@ -20035,17 +20036,15 @@
20036 }
20037 nOld = memsys5Size(pPrior);
20038 if( nBytes<=nOld ){
20039 return pPrior;
20040 }
20041 p = memsys5Malloc(nBytes);
 
20042 if( p ){
20043 memcpy(p, pPrior, nOld);
20044 memsys5Free(pPrior);
20045 }
 
20046 return p;
20047 }
20048
20049 /*
20050 ** Round up a request size to the next valid allocation size. If
@@ -41848,11 +41847,11 @@
41847 ** Free an allocated buffer obtained from pcache1Alloc().
41848 */
41849 static void pcache1Free(void *p){
41850 int nFreed = 0;
41851 if( p==0 ) return;
41852 if( SQLITE_WITHIN(p, pcache1.pStart, pcache1.pEnd) ){
41853 PgFreeslot *pSlot;
41854 sqlite3_mutex_enter(pcache1.mutex);
41855 sqlite3StatusDown(SQLITE_STATUS_PAGECACHE_USED, 1);
41856 pSlot = (PgFreeslot*)p;
41857 pSlot->pNext = pcache1.pFree;
@@ -53187,10 +53186,11 @@
53186 ** with *pSnapshot and set *pChanged as appropriate for opening the
53187 ** snapshot. */
53188 if( !memcmp(pSnapshot->aSalt, pWal->hdr.aSalt, sizeof(pWal->hdr.aSalt))
53189 && pSnapshot->mxFrame>=pInfo->nBackfillAttempted
53190 ){
53191 assert( pWal->readLock>0 );
53192 memcpy(&pWal->hdr, pSnapshot, sizeof(WalIndexHdr));
53193 *pChanged = bChanged;
53194 }else{
53195 rc = SQLITE_BUSY_SNAPSHOT;
53196 }
@@ -61549,11 +61549,11 @@
61549 memcpy(&pTmp[i], &aData[i], usableSize - i);
61550
61551 pData = pEnd;
61552 for(i=0; i<nCell; i++){
61553 u8 *pCell = apCell[i];
61554 if( SQLITE_WITHIN(pCell,aData,pEnd) ){
61555 pCell = &pTmp[pCell - aData];
61556 }
61557 pData -= szCell[i];
61558 put2byte(pCellptr, (pData - aData));
61559 pCellptr += 2;
@@ -61660,11 +61660,11 @@
61660 u8 *pFree = 0;
61661 int szFree = 0;
61662
61663 for(i=iFirst; i<iEnd; i++){
61664 u8 *pCell = pCArray->apCell[i];
61665 if( SQLITE_WITHIN(pCell, pStart, pEnd) ){
61666 int sz;
61667 /* No need to use cachedCellSize() here. The sizes of all cells that
61668 ** are to be freed have already been computing while deciding which
61669 ** cells need freeing */
61670 sz = pCArray->szCell[i]; assert( sz>0 );
@@ -75650,10 +75650,11 @@
75650 ** then the result is always NULL.
75651 ** The jump is taken if the SQLITE_JUMPIFNULL bit is set.
75652 */
75653 if( pOp->p5 & SQLITE_STOREP2 ){
75654 pOut = &aMem[pOp->p2];
75655 memAboutToChange(p, pOut);
75656 MemSetTypeFlag(pOut, MEM_Null);
75657 REGISTER_TRACE(pOp->p2, pOut);
75658 }else{
75659 VdbeBranchTaken(2,3);
75660 if( pOp->p5 & SQLITE_JUMPIFNULL ){
@@ -76192,10 +76193,12 @@
76193 || (offset64 > pC->payloadSize)
76194 ){
76195 rc = SQLITE_CORRUPT_BKPT;
76196 goto op_column_error;
76197 }
76198 }else{
76199 VVA_ONLY( t = 0; ) /* Only needed by assert() statements */
76200 }
76201
76202 /* If after trying to extract new entries from the header, nHdrParsed is
76203 ** still not up to p2, that means that the record has fewer than p2
76204 ** columns. So the result will be either the default value or a NULL.
@@ -88316,11 +88319,11 @@
88319 i16 iTabCol = pIdx->aiColumn[iIdxCol];
88320 if( iTabCol==XN_EXPR ){
88321 assert( pIdx->aColExpr );
88322 assert( pIdx->aColExpr->nExpr>iIdxCol );
88323 pParse->iSelfTab = iTabCur;
88324 sqlite3ExprCodeCopy(pParse, pIdx->aColExpr->a[iIdxCol].pExpr, regOut);
88325 }else{
88326 sqlite3ExprCodeGetColumnOfTable(pParse->pVdbe, pIdx->pTable, iTabCur,
88327 iTabCol, regOut);
88328 }
88329 }
@@ -89169,16 +89172,28 @@
89172 assert( target>0 && target<=pParse->nMem );
89173 if( pExpr && pExpr->op==TK_REGISTER ){
89174 sqlite3VdbeAddOp2(pParse->pVdbe, OP_Copy, pExpr->iTable, target);
89175 }else{
89176 inReg = sqlite3ExprCodeTarget(pParse, pExpr, target);
89177 assert( pParse->pVdbe!=0 || pParse->db->mallocFailed );
89178 if( inReg!=target && pParse->pVdbe ){
89179 sqlite3VdbeAddOp2(pParse->pVdbe, OP_SCopy, inReg, target);
89180 }
89181 }
89182 }
89183
89184 /*
89185 ** Make a transient copy of expression pExpr and then code it using
89186 ** sqlite3ExprCode(). This routine works just like sqlite3ExprCode()
89187 ** except that the input expression is guaranteed to be unchanged.
89188 */
89189 SQLITE_PRIVATE void sqlite3ExprCodeCopy(Parse *pParse, Expr *pExpr, int target){
89190 sqlite3 *db = pParse->db;
89191 pExpr = sqlite3ExprDup(db, pExpr, 0);
89192 if( !db->mallocFailed ) sqlite3ExprCode(pParse, pExpr, target);
89193 sqlite3ExprDelete(db, pExpr);
89194 }
89195
89196 /*
89197 ** Generate code that will evaluate expression pExpr and store the
89198 ** results in register target. The results are guaranteed to appear
89199 ** in register target. If the expression is constant, then this routine
@@ -104114,11 +104129,11 @@
104129 for(i=0; i<pIdx->nColumn; i++){
104130 int iField = pIdx->aiColumn[i];
104131 int x;
104132 if( iField==XN_EXPR ){
104133 pParse->ckBase = regNewData+1;
104134 sqlite3ExprCodeCopy(pParse, pIdx->aColExpr->a[i].pExpr, regIdx+i);
104135 pParse->ckBase = 0;
104136 VdbeComment((v, "%s column %d", pIdx->zName, i));
104137 }else{
104138 if( iField==XN_ROWID || iField==pTab->iPKey ){
104139 if( regRowid==regIdx+i ) continue; /* ROWID already in regIdx+i */
@@ -106627,11 +106642,11 @@
106642 { /* zName: */ "page_size",
106643 /* ePragTyp: */ PragTyp_PAGE_SIZE,
106644 /* ePragFlag: */ 0,
106645 /* iArg: */ 0 },
106646 #endif
106647 #if defined(SQLITE_DEBUG) && !defined(SQLITE_OMIT_PARSER_TRACE)
106648 { /* zName: */ "parser_trace",
106649 /* ePragTyp: */ PragTyp_PARSER_TRACE,
106650 /* ePragFlag: */ 0,
106651 /* iArg: */ 0 },
106652 #endif
@@ -171613,11 +171628,11 @@
171628 }else{
171629 rc = sqlite3Fts5IterPoslist(pTerm->pIter, pColset, &a, &n, &dummy);
171630 }
171631 if( rc!=SQLITE_OK ) goto ismatch_out;
171632 sqlite3Fts5PoslistReaderInit(a, n, &aIter[i]);
171633 aIter[i].bFlag = (u8)bFlag;
171634 if( aIter[i].bEof ) goto ismatch_out;
171635 }
171636
171637 while( 1 ){
171638 int bMatch;
@@ -173611,11 +173626,11 @@
173626 int nSz = (p->nData - p->iSzPoslist - 1); /* Size in bytes */
173627 int nPos = nSz*2 + p->bDel; /* Value of nPos field */
173628
173629 assert( p->bDel==0 || p->bDel==1 );
173630 if( nPos<=127 ){
173631 pPtr[p->iSzPoslist] = (u8)nPos;
173632 }else{
173633 int nByte = sqlite3Fts5GetVarintLen((u32)nPos);
173634 memmove(&pPtr[p->iSzPoslist + nByte], &pPtr[p->iSzPoslist + 1], nSz);
173635 sqlite3Fts5PutVarint(&pPtr[p->iSzPoslist], nPos);
173636 p->nData += (nByte-1);
@@ -176287,11 +176302,11 @@
176302 }else{
176303 iRes = i2;
176304 }
176305 }
176306
176307 pRes->iFirst = (u16)iRes;
176308 return 0;
176309 }
176310
176311 /*
176312 ** Move the seg-iter so that it points to the first rowid on page iLeafPgno.
@@ -176454,11 +176469,11 @@
176469 pNew = pOther;
176470 }else if( (pOther->iRowid>pIter->iSwitchRowid)==pIter->bRev ){
176471 pIter->iSwitchRowid = pOther->iRowid;
176472 }
176473 }
176474 pRes->iFirst = (u16)(pNew - pIter->aSeg);
176475 if( i==1 ) break;
176476
176477 pOther = &pIter->aSeg[ pIter->aFirst[i ^ 0x0001].iFirst ];
176478 }
176479 }
@@ -176605,11 +176620,11 @@
176620 }
176621 }
176622 *ppOut = pNew = fts5MultiIterAlloc(p, nSeg);
176623 if( pNew==0 ) return;
176624 pNew->bRev = (0!=(flags & FTS5INDEX_QUERY_DESC));
176625 pNew->bSkipEmpty = (u8)bSkipEmpty;
176626 pNew->pStruct = pStruct;
176627 fts5StructureRef(pStruct);
176628
176629 /* Initialize each of the component segment iterators. */
176630 if( iLevel<0 ){
@@ -177068,11 +177083,11 @@
177083
177084 assert( (pPage->pgidx.n==0)==(pWriter->bFirstTermInPage) );
177085
177086 /* Set the szLeaf header field. */
177087 assert( 0==fts5GetU16(&pPage->buf.p[2]) );
177088 fts5PutU16(&pPage->buf.p[2], (u16)pPage->buf.n);
177089
177090 if( pWriter->bFirstTermInPage ){
177091 /* No term was written to this page. */
177092 assert( pPage->pgidx.n==0 );
177093 fts5WriteBtreeNoTerm(p, pWriter);
@@ -177200,11 +177215,11 @@
177215
177216 /* If this is to be the first rowid written to the page, set the
177217 ** rowid-pointer in the page-header. Also append a value to the dlidx
177218 ** buffer, in case a doclist-index is required. */
177219 if( pWriter->bFirstRowidInPage ){
177220 fts5PutU16(pPage->buf.p, (u16)pPage->buf.n);
177221 fts5WriteDlidxAppend(p, pWriter, iRowid);
177222 }
177223
177224 /* Write the rowid. */
177225 if( pWriter->bFirstRowidInDoclist || pWriter->bFirstRowidInPage ){
@@ -177358,11 +177373,11 @@
177373 fts5BufferAppendVarint(&p->rc, &buf, pSeg->term.n);
177374 fts5BufferAppendBlob(&p->rc, &buf, pSeg->term.n, pSeg->term.p);
177375 fts5BufferAppendBlob(&p->rc, &buf, pData->szLeaf-iOff, &pData->p[iOff]);
177376 if( p->rc==SQLITE_OK ){
177377 /* Set the szLeaf field */
177378 fts5PutU16(&buf.p[2], (u16)buf.n);
177379 }
177380
177381 /* Set up the new page-index array */
177382 fts5BufferAppendVarint(&p->rc, &buf, 4);
177383 if( pSeg->iLeafPgno==pSeg->iTermLeafPgno
@@ -177724,11 +177739,11 @@
177739 nCopy = fts5GetPoslistSize(&pDoclist[iOff], &nPos, &bDummy);
177740 nCopy += nPos;
177741 iRowid += iDelta;
177742
177743 if( writer.bFirstRowidInPage ){
177744 fts5PutU16(&pBuf->p[0], (u16)pBuf->n); /* first rowid on page */
177745 pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], iRowid);
177746 writer.bFirstRowidInPage = 0;
177747 fts5WriteDlidxAppend(p, &writer, iRowid);
177748 }else{
177749 pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], iDelta);
@@ -178521,11 +178536,12 @@
178536
178537 for(i=0; i<pConfig->nPrefix && rc==SQLITE_OK; i++){
178538 int nByte = fts5IndexCharlenToBytelen(pToken, nToken, pConfig->aPrefix[i]);
178539 if( nByte ){
178540 rc = sqlite3Fts5HashWrite(p->pHash,
178541 p->iWriteRowid, iCol, iPos, (char)(FTS5_MAIN_PREFIX+i+1), pToken,
178542 nByte
178543 );
178544 }
178545 }
178546
178547 return rc;
@@ -178571,11 +178587,11 @@
178587 }
178588 }
178589
178590 if( iIdx<=pConfig->nPrefix ){
178591 Fts5Structure *pStruct = fts5StructureRead(p);
178592 buf.p[0] = (u8)(FTS5_MAIN_PREFIX + iIdx);
178593 if( pStruct ){
178594 fts5MultiIterNew(p, pStruct, 1, flags, buf.p, nToken+1, -1, 0, &pRet);
178595 fts5StructureRelease(pStruct);
178596 }
178597 }else{
@@ -180277,11 +180293,11 @@
180293 iNext = 1;
180294 for(i=0; i<sizeof(aConstraint)/sizeof(aConstraint[0]); i++){
180295 struct Constraint *pC = &aConstraint[i];
180296 if( pC->iConsIndex>=0 ){
180297 pInfo->aConstraintUsage[pC->iConsIndex].argvIndex = iNext++;
180298 pInfo->aConstraintUsage[pC->iConsIndex].omit = (unsigned char)pC->omit;
180299 }
180300 }
180301
180302 pInfo->idxNum = idxFlags;
180303 return SQLITE_OK;
@@ -182123,11 +182139,11 @@
182139 sqlite3_context *pCtx, /* Function call context */
182140 int nArg, /* Number of args */
182141 sqlite3_value **apVal /* Function arguments */
182142 ){
182143 assert( nArg==0 );
182144 sqlite3_result_text(pCtx, "fts5: 2015-12-18 16:29:47 8bf5e056eb8beb6e0ed5874fb24d7fe9f0b66d2b", -1, SQLITE_TRANSIENT);
182145 }
182146
182147 static int fts5Init(sqlite3 *db){
182148 static const sqlite3_module fts5Mod = {
182149 /* iVersion */ 2,
@@ -183590,11 +183606,11 @@
183606 while( zCsr<zTerm ){
183607 int iCode;
183608 int bToken;
183609 READ_UTF8(zCsr, zTerm, iCode);
183610 if( iCode<128 ){
183611 p->aTokenChar[iCode] = (unsigned char)bTokenChars;
183612 }else{
183613 bToken = sqlite3Fts5UnicodeIsalnum(iCode);
183614 assert( (bToken==0 || bToken==1) );
183615 assert( (bTokenChars==0 || bTokenChars==1) );
183616 if( bToken!=bTokenChars && sqlite3Fts5UnicodeIsdiacritic(iCode)==0 ){
183617
+1 -1
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -111,11 +111,11 @@
111111
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
112112
** [sqlite_version()] and [sqlite_source_id()].
113113
*/
114114
#define SQLITE_VERSION "3.10.0"
115115
#define SQLITE_VERSION_NUMBER 3010000
116
-#define SQLITE_SOURCE_ID "2015-12-11 13:51:02 e998513e442ce1206b12dc28bdc996d7b5f9f94d"
116
+#define SQLITE_SOURCE_ID "2015-12-23 10:54:48 b910a3d53769689d9212a06f974ccce54844bbe4"
117117
118118
/*
119119
** CAPI3REF: Run-Time Library Version Numbers
120120
** KEYWORDS: sqlite3_version, sqlite3_sourceid
121121
**
122122
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -111,11 +111,11 @@
111 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
112 ** [sqlite_version()] and [sqlite_source_id()].
113 */
114 #define SQLITE_VERSION "3.10.0"
115 #define SQLITE_VERSION_NUMBER 3010000
116 #define SQLITE_SOURCE_ID "2015-12-11 13:51:02 e998513e442ce1206b12dc28bdc996d7b5f9f94d"
117
118 /*
119 ** CAPI3REF: Run-Time Library Version Numbers
120 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
121 **
122
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -111,11 +111,11 @@
111 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
112 ** [sqlite_version()] and [sqlite_source_id()].
113 */
114 #define SQLITE_VERSION "3.10.0"
115 #define SQLITE_VERSION_NUMBER 3010000
116 #define SQLITE_SOURCE_ID "2015-12-23 10:54:48 b910a3d53769689d9212a06f974ccce54844bbe4"
117
118 /*
119 ** CAPI3REF: Run-Time Library Version Numbers
120 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
121 **
122
+2 -2
--- src/th_main.c
+++ src/th_main.c
@@ -167,11 +167,11 @@
167167
int rid;
168168
169169
rid = th1_name_to_typed_rid(interp, zRev, "ci");
170170
compute_fileage(rid, zGlob);
171171
db_prepare(&q,
172
- "SELECT datetime(fileage.mtime, 'localtime'), fileage.pathname,\n"
172
+ "SELECT datetime(fileage.mtime, toLocal()), fileage.pathname,\n"
173173
" blob.size\n"
174174
" FROM fileage, blob\n"
175175
" WHERE blob.rid=fileage.fid \n"
176176
" ORDER BY %s;", zOrderBy /*safe-for-%s*/
177177
);
@@ -549,11 +549,11 @@
549549
const char **argv,
550550
int *argl
551551
){
552552
char *zOut;
553553
if( argc>=2 && argl[1]==6 && memcmp(argv[1],"-local",6)==0 ){
554
- zOut = db_text("??", "SELECT datetime('now'%s)", timeline_utc());
554
+ zOut = db_text("??", "SELECT datetime('now',toLocal())");
555555
}else{
556556
zOut = db_text("??", "SELECT datetime('now')");
557557
}
558558
Th_SetResult(interp, zOut, -1);
559559
free(zOut);
560560
--- src/th_main.c
+++ src/th_main.c
@@ -167,11 +167,11 @@
167 int rid;
168
169 rid = th1_name_to_typed_rid(interp, zRev, "ci");
170 compute_fileage(rid, zGlob);
171 db_prepare(&q,
172 "SELECT datetime(fileage.mtime, 'localtime'), fileage.pathname,\n"
173 " blob.size\n"
174 " FROM fileage, blob\n"
175 " WHERE blob.rid=fileage.fid \n"
176 " ORDER BY %s;", zOrderBy /*safe-for-%s*/
177 );
@@ -549,11 +549,11 @@
549 const char **argv,
550 int *argl
551 ){
552 char *zOut;
553 if( argc>=2 && argl[1]==6 && memcmp(argv[1],"-local",6)==0 ){
554 zOut = db_text("??", "SELECT datetime('now'%s)", timeline_utc());
555 }else{
556 zOut = db_text("??", "SELECT datetime('now')");
557 }
558 Th_SetResult(interp, zOut, -1);
559 free(zOut);
560
--- src/th_main.c
+++ src/th_main.c
@@ -167,11 +167,11 @@
167 int rid;
168
169 rid = th1_name_to_typed_rid(interp, zRev, "ci");
170 compute_fileage(rid, zGlob);
171 db_prepare(&q,
172 "SELECT datetime(fileage.mtime, toLocal()), fileage.pathname,\n"
173 " blob.size\n"
174 " FROM fileage, blob\n"
175 " WHERE blob.rid=fileage.fid \n"
176 " ORDER BY %s;", zOrderBy /*safe-for-%s*/
177 );
@@ -549,11 +549,11 @@
549 const char **argv,
550 int *argl
551 ){
552 char *zOut;
553 if( argc>=2 && argl[1]==6 && memcmp(argv[1],"-local",6)==0 ){
554 zOut = db_text("??", "SELECT datetime('now',toLocal())");
555 }else{
556 zOut = db_text("??", "SELECT datetime('now')");
557 }
558 Th_SetResult(interp, zOut, -1);
559 free(zOut);
560
+6 -32
--- src/timeline.c
+++ src/timeline.c
@@ -1027,16 +1027,15 @@
10271027
/*
10281028
** Return a pointer to a constant string that forms the basis
10291029
** for a timeline query for the WWW interface.
10301030
*/
10311031
const char *timeline_query_for_www(void){
1032
- static const char *zBase = 0;
1033
- static const char zBaseSql[] =
1032
+ static const char zBase[] =
10341033
@ SELECT
10351034
@ blob.rid AS blobRid,
10361035
@ uuid AS uuid,
1037
- @ datetime(event.mtime%s) AS timestamp,
1036
+ @ datetime(event.mtime,toLocal()) AS timestamp,
10381037
@ coalesce(ecomment, comment) AS comment,
10391038
@ coalesce(euser, user) AS user,
10401039
@ blob.rid IN leaf AS leaf,
10411040
@ bgcolor AS bgColor,
10421041
@ event.type AS eventType,
@@ -1047,13 +1046,10 @@
10471046
@ brief AS brief,
10481047
@ event.mtime AS mtime
10491048
@ FROM event CROSS JOIN blob
10501049
@ WHERE blob.rid=event.objid
10511050
;
1052
- if( zBase==0 ){
1053
- zBase = mprintf(zBaseSql /*works-like: "%s"*/, timeline_utc());
1054
- }
10551051
return zBase;
10561052
}
10571053
10581054
/*
10591055
** Generate a submenu element with a single parameter change.
@@ -1077,11 +1073,11 @@
10771073
double symbolic_name_to_mtime(const char *z){
10781074
double mtime;
10791075
int rid;
10801076
if( z==0 ) return -1.0;
10811077
if( fossil_isdate(z) ){
1082
- mtime = db_double(0.0, "SELECT julianday(%Q,'utc')", z);
1078
+ mtime = db_double(0.0, "SELECT julianday(%Q,fromLocal())", z);
10831079
if( mtime>0.0 ) return mtime;
10841080
}
10851081
rid = symbolic_name_to_rid(z, "*");
10861082
if( rid ){
10871083
mtime = db_double(0.0, "SELECT mtime FROM event WHERE objid=%d", rid);
@@ -1939,11 +1935,11 @@
19391935
const char *timeline_query_for_tty(void){
19401936
static const char zBaseSql[] =
19411937
@ SELECT
19421938
@ blob.rid AS rid,
19431939
@ uuid,
1944
- @ datetime(event.mtime%s) AS mDateTime,
1940
+ @ datetime(event.mtime,toLocal()) AS mDateTime,
19451941
@ coalesce(ecomment,comment)
19461942
@ || ' (user: ' || coalesce(euser,user,'?')
19471943
@ || (SELECT case when length(x)>0 then ' tags: ' || x else '' end
19481944
@ FROM (SELECT group_concat(substr(tagname,5), ', ') AS x
19491945
@ FROM tag, tagxref
@@ -1960,11 +1956,11 @@
19601956
@ AND tagxref.tagtype>0
19611957
@ AND tagxref.rid=blob.rid
19621958
@ WHERE blob.rid=event.objid
19631959
@ AND tag.tagname='branch'
19641960
;
1965
- return mprintf(zBaseSql /*works-like: "%s"*/, timeline_utc());
1961
+ return zBaseSql;
19661962
}
19671963
19681964
/*
19691965
** Return true if the input string is a date in the ISO 8601 format:
19701966
** YYYY-MM-DD.
@@ -2118,11 +2114,11 @@
21182114
fossil_fatal("cannot compute descendants or ancestors of a date");
21192115
}
21202116
if( mode==0 ){
21212117
if( isIsoDate(zOrigin) ) zShift = ",'+1 day'";
21222118
}
2123
- zDate = mprintf("(SELECT julianday(%Q%s, 'utc'))", zOrigin, zShift);
2119
+ zDate = mprintf("(SELECT julianday(%Q%s, fromLocal())", zOrigin, zShift);
21242120
}
21252121
21262122
if( zFilePattern ){
21272123
if( zType==0 ){
21282124
/* When zFilePattern is specified and type is not specified, only show
@@ -2187,32 +2183,10 @@
21872183
blob_reset(&sql);
21882184
print_timeline(&q, n, width, verboseFlag);
21892185
db_finalize(&q);
21902186
}
21912187
2192
-/*
2193
-** Return one of two things:
2194
-**
2195
-** ",'localtime'" if the timeline-utc property is set to 0.
2196
-**
2197
-** "" (empty string) otherwise.
2198
-*/
2199
-const char *timeline_utc(){
2200
- if( g.fTimeFormat==0 ){
2201
- if( db_get_int("timeline-utc", 1) ){
2202
- g.fTimeFormat = 1;
2203
- }else{
2204
- g.fTimeFormat = 2;
2205
- }
2206
- }
2207
- if( g.fTimeFormat==1 ){
2208
- return "";
2209
- }else{
2210
- return ",'localtime'";
2211
- }
2212
-}
2213
-
22142188
22152189
/*
22162190
** COMMAND: test-timewarp-list
22172191
**
22182192
** Usage: %fossil test-timewarp-list ?-v|---verbose?
22192193
--- src/timeline.c
+++ src/timeline.c
@@ -1027,16 +1027,15 @@
1027 /*
1028 ** Return a pointer to a constant string that forms the basis
1029 ** for a timeline query for the WWW interface.
1030 */
1031 const char *timeline_query_for_www(void){
1032 static const char *zBase = 0;
1033 static const char zBaseSql[] =
1034 @ SELECT
1035 @ blob.rid AS blobRid,
1036 @ uuid AS uuid,
1037 @ datetime(event.mtime%s) AS timestamp,
1038 @ coalesce(ecomment, comment) AS comment,
1039 @ coalesce(euser, user) AS user,
1040 @ blob.rid IN leaf AS leaf,
1041 @ bgcolor AS bgColor,
1042 @ event.type AS eventType,
@@ -1047,13 +1046,10 @@
1047 @ brief AS brief,
1048 @ event.mtime AS mtime
1049 @ FROM event CROSS JOIN blob
1050 @ WHERE blob.rid=event.objid
1051 ;
1052 if( zBase==0 ){
1053 zBase = mprintf(zBaseSql /*works-like: "%s"*/, timeline_utc());
1054 }
1055 return zBase;
1056 }
1057
1058 /*
1059 ** Generate a submenu element with a single parameter change.
@@ -1077,11 +1073,11 @@
1077 double symbolic_name_to_mtime(const char *z){
1078 double mtime;
1079 int rid;
1080 if( z==0 ) return -1.0;
1081 if( fossil_isdate(z) ){
1082 mtime = db_double(0.0, "SELECT julianday(%Q,'utc')", z);
1083 if( mtime>0.0 ) return mtime;
1084 }
1085 rid = symbolic_name_to_rid(z, "*");
1086 if( rid ){
1087 mtime = db_double(0.0, "SELECT mtime FROM event WHERE objid=%d", rid);
@@ -1939,11 +1935,11 @@
1939 const char *timeline_query_for_tty(void){
1940 static const char zBaseSql[] =
1941 @ SELECT
1942 @ blob.rid AS rid,
1943 @ uuid,
1944 @ datetime(event.mtime%s) AS mDateTime,
1945 @ coalesce(ecomment,comment)
1946 @ || ' (user: ' || coalesce(euser,user,'?')
1947 @ || (SELECT case when length(x)>0 then ' tags: ' || x else '' end
1948 @ FROM (SELECT group_concat(substr(tagname,5), ', ') AS x
1949 @ FROM tag, tagxref
@@ -1960,11 +1956,11 @@
1960 @ AND tagxref.tagtype>0
1961 @ AND tagxref.rid=blob.rid
1962 @ WHERE blob.rid=event.objid
1963 @ AND tag.tagname='branch'
1964 ;
1965 return mprintf(zBaseSql /*works-like: "%s"*/, timeline_utc());
1966 }
1967
1968 /*
1969 ** Return true if the input string is a date in the ISO 8601 format:
1970 ** YYYY-MM-DD.
@@ -2118,11 +2114,11 @@
2118 fossil_fatal("cannot compute descendants or ancestors of a date");
2119 }
2120 if( mode==0 ){
2121 if( isIsoDate(zOrigin) ) zShift = ",'+1 day'";
2122 }
2123 zDate = mprintf("(SELECT julianday(%Q%s, 'utc'))", zOrigin, zShift);
2124 }
2125
2126 if( zFilePattern ){
2127 if( zType==0 ){
2128 /* When zFilePattern is specified and type is not specified, only show
@@ -2187,32 +2183,10 @@
2187 blob_reset(&sql);
2188 print_timeline(&q, n, width, verboseFlag);
2189 db_finalize(&q);
2190 }
2191
2192 /*
2193 ** Return one of two things:
2194 **
2195 ** ",'localtime'" if the timeline-utc property is set to 0.
2196 **
2197 ** "" (empty string) otherwise.
2198 */
2199 const char *timeline_utc(){
2200 if( g.fTimeFormat==0 ){
2201 if( db_get_int("timeline-utc", 1) ){
2202 g.fTimeFormat = 1;
2203 }else{
2204 g.fTimeFormat = 2;
2205 }
2206 }
2207 if( g.fTimeFormat==1 ){
2208 return "";
2209 }else{
2210 return ",'localtime'";
2211 }
2212 }
2213
2214
2215 /*
2216 ** COMMAND: test-timewarp-list
2217 **
2218 ** Usage: %fossil test-timewarp-list ?-v|---verbose?
2219
--- src/timeline.c
+++ src/timeline.c
@@ -1027,16 +1027,15 @@
1027 /*
1028 ** Return a pointer to a constant string that forms the basis
1029 ** for a timeline query for the WWW interface.
1030 */
1031 const char *timeline_query_for_www(void){
1032 static const char zBase[] =
 
1033 @ SELECT
1034 @ blob.rid AS blobRid,
1035 @ uuid AS uuid,
1036 @ datetime(event.mtime,toLocal()) AS timestamp,
1037 @ coalesce(ecomment, comment) AS comment,
1038 @ coalesce(euser, user) AS user,
1039 @ blob.rid IN leaf AS leaf,
1040 @ bgcolor AS bgColor,
1041 @ event.type AS eventType,
@@ -1047,13 +1046,10 @@
1046 @ brief AS brief,
1047 @ event.mtime AS mtime
1048 @ FROM event CROSS JOIN blob
1049 @ WHERE blob.rid=event.objid
1050 ;
 
 
 
1051 return zBase;
1052 }
1053
1054 /*
1055 ** Generate a submenu element with a single parameter change.
@@ -1077,11 +1073,11 @@
1073 double symbolic_name_to_mtime(const char *z){
1074 double mtime;
1075 int rid;
1076 if( z==0 ) return -1.0;
1077 if( fossil_isdate(z) ){
1078 mtime = db_double(0.0, "SELECT julianday(%Q,fromLocal())", z);
1079 if( mtime>0.0 ) return mtime;
1080 }
1081 rid = symbolic_name_to_rid(z, "*");
1082 if( rid ){
1083 mtime = db_double(0.0, "SELECT mtime FROM event WHERE objid=%d", rid);
@@ -1939,11 +1935,11 @@
1935 const char *timeline_query_for_tty(void){
1936 static const char zBaseSql[] =
1937 @ SELECT
1938 @ blob.rid AS rid,
1939 @ uuid,
1940 @ datetime(event.mtime,toLocal()) AS mDateTime,
1941 @ coalesce(ecomment,comment)
1942 @ || ' (user: ' || coalesce(euser,user,'?')
1943 @ || (SELECT case when length(x)>0 then ' tags: ' || x else '' end
1944 @ FROM (SELECT group_concat(substr(tagname,5), ', ') AS x
1945 @ FROM tag, tagxref
@@ -1960,11 +1956,11 @@
1956 @ AND tagxref.tagtype>0
1957 @ AND tagxref.rid=blob.rid
1958 @ WHERE blob.rid=event.objid
1959 @ AND tag.tagname='branch'
1960 ;
1961 return zBaseSql;
1962 }
1963
1964 /*
1965 ** Return true if the input string is a date in the ISO 8601 format:
1966 ** YYYY-MM-DD.
@@ -2118,11 +2114,11 @@
2114 fossil_fatal("cannot compute descendants or ancestors of a date");
2115 }
2116 if( mode==0 ){
2117 if( isIsoDate(zOrigin) ) zShift = ",'+1 day'";
2118 }
2119 zDate = mprintf("(SELECT julianday(%Q%s, fromLocal())", zOrigin, zShift);
2120 }
2121
2122 if( zFilePattern ){
2123 if( zType==0 ){
2124 /* When zFilePattern is specified and type is not specified, only show
@@ -2187,32 +2183,10 @@
2183 blob_reset(&sql);
2184 print_timeline(&q, n, width, verboseFlag);
2185 db_finalize(&q);
2186 }
2187
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2188
2189 /*
2190 ** COMMAND: test-timewarp-list
2191 **
2192 ** Usage: %fossil test-timewarp-list ?-v|---verbose?
2193
+8 -8
--- src/tkt.c
+++ src/tkt.c
@@ -137,13 +137,13 @@
137137
const char *zName;
138138
Stmt q;
139139
int i, n, size, j;
140140
141141
zName = PD("name","-none-");
142
- db_prepare(&q, "SELECT datetime(tkt_mtime%s) AS tkt_datetime, *"
142
+ db_prepare(&q, "SELECT datetime(tkt_mtime,toLocal()) AS tkt_datetime, *"
143143
" FROM ticket WHERE tkt_uuid GLOB '%q*'",
144
- timeline_utc(), zName);
144
+ zName);
145145
if( db_step(&q)==SQLITE_ROW ){
146146
n = db_column_count(&q);
147147
for(i=0; i<n; i++){
148148
const char *zVal = db_column_text(&q, i);
149149
const char *zName = db_column_name(&q, i);
@@ -946,21 +946,21 @@
946946
@ No such ticket: %h(zUuid)
947947
style_footer();
948948
return;
949949
}
950950
db_prepare(&q,
951
- "SELECT datetime(mtime%s), objid, uuid, NULL, NULL, NULL"
951
+ "SELECT datetime(mtime,toLocal()), objid, uuid, NULL, NULL, NULL"
952952
" FROM event, blob"
953953
" WHERE objid IN (SELECT rid FROM tagxref WHERE tagid=%d)"
954954
" AND blob.rid=event.objid"
955955
" UNION "
956
- "SELECT datetime(mtime%s), attachid, uuid, src, filename, user"
956
+ "SELECT datetime(mtime,toLocal()), attachid, uuid, src, filename, user"
957957
" FROM attachment, blob"
958958
" WHERE target=(SELECT substr(tagname,5) FROM tag WHERE tagid=%d)"
959959
" AND blob.rid=attachid"
960960
" ORDER BY 1",
961
- timeline_utc(), tagid, timeline_utc(), tagid
961
+ tagid, tagid
962962
);
963963
while( db_step(&q)==SQLITE_ROW ){
964964
Manifest *pTicket;
965965
const char *zDate = db_column_text(&q, 0);
966966
int rid = db_column_int(&q, 1);
@@ -1254,22 +1254,22 @@
12541254
zTktUuid);
12551255
if( tagid==0 ){
12561256
fossil_fatal("no such ticket %h", zTktUuid);
12571257
}
12581258
db_prepare(&q,
1259
- "SELECT datetime(mtime%s), objid, NULL, NULL, NULL"
1259
+ "SELECT datetime(mtime,toLocal()), objid, NULL, NULL, NULL"
12601260
" FROM event, blob"
12611261
" WHERE objid IN (SELECT rid FROM tagxref WHERE tagid=%d)"
12621262
" AND blob.rid=event.objid"
12631263
" UNION "
1264
- "SELECT datetime(mtime%s), attachid, filename, "
1264
+ "SELECT datetime(mtime,toLocal()), attachid, filename, "
12651265
" src, user"
12661266
" FROM attachment, blob"
12671267
" WHERE target=(SELECT substr(tagname,5) FROM tag WHERE tagid=%d)"
12681268
" AND blob.rid=attachid"
12691269
" ORDER BY 1 DESC",
1270
- timeline_utc(), tagid, timeline_utc(), tagid
1270
+ tagid, tagid
12711271
);
12721272
while( db_step(&q)==SQLITE_ROW ){
12731273
Manifest *pTicket;
12741274
const char *zDate = db_column_text(&q, 0);
12751275
int rid = db_column_int(&q, 1);
12761276
--- src/tkt.c
+++ src/tkt.c
@@ -137,13 +137,13 @@
137 const char *zName;
138 Stmt q;
139 int i, n, size, j;
140
141 zName = PD("name","-none-");
142 db_prepare(&q, "SELECT datetime(tkt_mtime%s) AS tkt_datetime, *"
143 " FROM ticket WHERE tkt_uuid GLOB '%q*'",
144 timeline_utc(), zName);
145 if( db_step(&q)==SQLITE_ROW ){
146 n = db_column_count(&q);
147 for(i=0; i<n; i++){
148 const char *zVal = db_column_text(&q, i);
149 const char *zName = db_column_name(&q, i);
@@ -946,21 +946,21 @@
946 @ No such ticket: %h(zUuid)
947 style_footer();
948 return;
949 }
950 db_prepare(&q,
951 "SELECT datetime(mtime%s), objid, uuid, NULL, NULL, NULL"
952 " FROM event, blob"
953 " WHERE objid IN (SELECT rid FROM tagxref WHERE tagid=%d)"
954 " AND blob.rid=event.objid"
955 " UNION "
956 "SELECT datetime(mtime%s), attachid, uuid, src, filename, user"
957 " FROM attachment, blob"
958 " WHERE target=(SELECT substr(tagname,5) FROM tag WHERE tagid=%d)"
959 " AND blob.rid=attachid"
960 " ORDER BY 1",
961 timeline_utc(), tagid, timeline_utc(), tagid
962 );
963 while( db_step(&q)==SQLITE_ROW ){
964 Manifest *pTicket;
965 const char *zDate = db_column_text(&q, 0);
966 int rid = db_column_int(&q, 1);
@@ -1254,22 +1254,22 @@
1254 zTktUuid);
1255 if( tagid==0 ){
1256 fossil_fatal("no such ticket %h", zTktUuid);
1257 }
1258 db_prepare(&q,
1259 "SELECT datetime(mtime%s), objid, NULL, NULL, NULL"
1260 " FROM event, blob"
1261 " WHERE objid IN (SELECT rid FROM tagxref WHERE tagid=%d)"
1262 " AND blob.rid=event.objid"
1263 " UNION "
1264 "SELECT datetime(mtime%s), attachid, filename, "
1265 " src, user"
1266 " FROM attachment, blob"
1267 " WHERE target=(SELECT substr(tagname,5) FROM tag WHERE tagid=%d)"
1268 " AND blob.rid=attachid"
1269 " ORDER BY 1 DESC",
1270 timeline_utc(), tagid, timeline_utc(), tagid
1271 );
1272 while( db_step(&q)==SQLITE_ROW ){
1273 Manifest *pTicket;
1274 const char *zDate = db_column_text(&q, 0);
1275 int rid = db_column_int(&q, 1);
1276
--- src/tkt.c
+++ src/tkt.c
@@ -137,13 +137,13 @@
137 const char *zName;
138 Stmt q;
139 int i, n, size, j;
140
141 zName = PD("name","-none-");
142 db_prepare(&q, "SELECT datetime(tkt_mtime,toLocal()) AS tkt_datetime, *"
143 " FROM ticket WHERE tkt_uuid GLOB '%q*'",
144 zName);
145 if( db_step(&q)==SQLITE_ROW ){
146 n = db_column_count(&q);
147 for(i=0; i<n; i++){
148 const char *zVal = db_column_text(&q, i);
149 const char *zName = db_column_name(&q, i);
@@ -946,21 +946,21 @@
946 @ No such ticket: %h(zUuid)
947 style_footer();
948 return;
949 }
950 db_prepare(&q,
951 "SELECT datetime(mtime,toLocal()), objid, uuid, NULL, NULL, NULL"
952 " FROM event, blob"
953 " WHERE objid IN (SELECT rid FROM tagxref WHERE tagid=%d)"
954 " AND blob.rid=event.objid"
955 " UNION "
956 "SELECT datetime(mtime,toLocal()), attachid, uuid, src, filename, user"
957 " FROM attachment, blob"
958 " WHERE target=(SELECT substr(tagname,5) FROM tag WHERE tagid=%d)"
959 " AND blob.rid=attachid"
960 " ORDER BY 1",
961 tagid, tagid
962 );
963 while( db_step(&q)==SQLITE_ROW ){
964 Manifest *pTicket;
965 const char *zDate = db_column_text(&q, 0);
966 int rid = db_column_int(&q, 1);
@@ -1254,22 +1254,22 @@
1254 zTktUuid);
1255 if( tagid==0 ){
1256 fossil_fatal("no such ticket %h", zTktUuid);
1257 }
1258 db_prepare(&q,
1259 "SELECT datetime(mtime,toLocal()), objid, NULL, NULL, NULL"
1260 " FROM event, blob"
1261 " WHERE objid IN (SELECT rid FROM tagxref WHERE tagid=%d)"
1262 " AND blob.rid=event.objid"
1263 " UNION "
1264 "SELECT datetime(mtime,toLocal()), attachid, filename, "
1265 " src, user"
1266 " FROM attachment, blob"
1267 " WHERE target=(SELECT substr(tagname,5) FROM tag WHERE tagid=%d)"
1268 " AND blob.rid=attachid"
1269 " ORDER BY 1 DESC",
1270 tagid, tagid
1271 );
1272 while( db_step(&q)==SQLITE_ROW ){
1273 Manifest *pTicket;
1274 const char *zDate = db_column_text(&q, 0);
1275 int rid = db_column_int(&q, 1);
1276
+2 -2
--- src/user.c
+++ src/user.c
@@ -459,12 +459,12 @@
459459
return;
460460
}
461461
style_header("Access Log");
462462
blob_zero(&sql);
463463
blob_append_sql(&sql,
464
- "SELECT uname, ipaddr, datetime(mtime%s), success"
465
- " FROM accesslog", timeline_utc()
464
+ "SELECT uname, ipaddr, datetime(mtime,toLocal()), success"
465
+ " FROM accesslog"
466466
);
467467
if( y==1 ){
468468
blob_append(&sql, " WHERE success", -1);
469469
}else if( y==2 ){
470470
blob_append(&sql, " WHERE NOT success", -1);
471471
--- src/user.c
+++ src/user.c
@@ -459,12 +459,12 @@
459 return;
460 }
461 style_header("Access Log");
462 blob_zero(&sql);
463 blob_append_sql(&sql,
464 "SELECT uname, ipaddr, datetime(mtime%s), success"
465 " FROM accesslog", timeline_utc()
466 );
467 if( y==1 ){
468 blob_append(&sql, " WHERE success", -1);
469 }else if( y==2 ){
470 blob_append(&sql, " WHERE NOT success", -1);
471
--- src/user.c
+++ src/user.c
@@ -459,12 +459,12 @@
459 return;
460 }
461 style_header("Access Log");
462 blob_zero(&sql);
463 blob_append_sql(&sql,
464 "SELECT uname, ipaddr, datetime(mtime,toLocal()), success"
465 " FROM accesslog"
466 );
467 if( y==1 ){
468 blob_append(&sql, " WHERE success", -1);
469 }else if( y==2 ){
470 blob_append(&sql, " WHERE NOT success", -1);
471

Keyboard Shortcuts

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