Fossil SCM

merge trunk. Upgrade to latest SQLite, with experimental Cygwin fixes.

jan.nijtmans 2013-08-01 13:28 UTC possible-cygwin-fix merge
Commit 7f6019efcf37d7ed0050c2453d20ebeda1094827
--- src/checkin.c
+++ src/checkin.c
@@ -108,10 +108,14 @@
108108
}else if( isChnged ){
109109
if( isChnged==2 ){
110110
blob_appendf(report, "UPDATED_BY_MERGE %s\n", zDisplayName);
111111
}else if( isChnged==3 ){
112112
blob_appendf(report, "ADDED_BY_MERGE %s\n", zDisplayName);
113
+ }else if( isChnged==4 ){
114
+ blob_appendf(report, "UPDATED_BY_INTEGRATE %s\n", zDisplayName);
115
+ }else if( isChnged==5 ){
116
+ blob_appendf(report, "ADDED_BY_INTEGRATE %s\n", zDisplayName);
113117
}else if( file_contains_merge_marker(zFullName) ){
114118
blob_appendf(report, "CONFLICT %s\n", zDisplayName);
115119
}else{
116120
blob_appendf(report, "EDITED %s\n", zDisplayName);
117121
}
@@ -129,10 +133,11 @@
129133
while( db_step(&q)==SQLITE_ROW ){
130134
const char *zLabel = "MERGED_WITH";
131135
switch( db_column_int(&q, 1) ){
132136
case -1: zLabel = "CHERRYPICK "; break;
133137
case -2: zLabel = "BACKOUT "; break;
138
+ case -4: zLabel = "INTEGRATE "; break;
134139
}
135140
blob_append(report, zPrefix, nPrefix);
136141
blob_appendf(report, "%s %s\n", zLabel, db_column_text(&q, 0));
137142
}
138143
db_finalize(&q);
@@ -332,10 +337,14 @@
332337
}else if( chnged ){
333338
if( chnged==2 ){
334339
type = "UPDATED_BY_MERGE ";
335340
}else if( chnged==3 ){
336341
type = "ADDED_BY_MERGE ";
342
+ }else if( chnged==4 ){
343
+ type = "UPDATED_BY_INTEGRATE ";
344
+ }else if( chnged==5 ){
345
+ type = "ADDED_BY_INTEGRATE ";
337346
}else if( file_contains_merge_marker(zFullName) ){
338347
type = "CONFLICT ";
339348
}else{
340349
type = "EDITED ";
341350
}
@@ -1678,10 +1687,43 @@
16781687
** and rollback the transaction.
16791688
*/
16801689
if( dryRunFlag ){
16811690
blob_write_to_file(&manifest, "");
16821691
}
1692
+
1693
+ db_prepare(&q, "SELECT uuid,merge FROM vmerge JOIN blob ON merge=rid"
1694
+ " WHERE id=-4");
1695
+ while( db_step(&q)==SQLITE_ROW ){
1696
+ const char *zIntegrateUuid = db_column_text(&q, 0);
1697
+ int rid = db_column_int(&q, 1);
1698
+ if( !is_a_leaf(rid) ){
1699
+ fossil_print("Not_Closed: %s (not a leaf any more)\n", zIntegrateUuid);
1700
+ }else{
1701
+ if (!db_exists("SELECT 1 FROM tagxref "
1702
+ " WHERE tagid=%d AND rid=%d AND tagtype>0",
1703
+ TAG_CLOSED, rid)
1704
+ ){
1705
+ Blob ctrl;
1706
+ Blob cksum;
1707
+ char *zDate;
1708
+ int nrid;
1709
+
1710
+ blob_zero(&ctrl);
1711
+ zDate = date_in_standard_format(sCiInfo.zDateOvrd ? sCiInfo.zDateOvrd : "now");
1712
+ blob_appendf(&ctrl, "D %s\n", zDate);
1713
+ blob_appendf(&ctrl, "T +closed %s\n", zIntegrateUuid);
1714
+ blob_appendf(&ctrl, "U %F\n", sCiInfo.zUserOvrd ? sCiInfo.zUserOvrd : g.zLogin);
1715
+ md5sum_blob(&ctrl, &cksum);
1716
+ blob_appendf(&ctrl, "Z %b\n", &cksum);
1717
+ nrid = content_put(&ctrl);
1718
+ manifest_crosslink(nrid, &ctrl);
1719
+ assert( blob_is_reset(&ctrl) );
1720
+ }
1721
+ fossil_print("Closed: %s\n", zIntegrateUuid);
1722
+ }
1723
+ }
1724
+ db_finalize(&q);
16831725
16841726
if( outputManifest ){
16851727
zManifestFile = mprintf("%smanifest", g.zLocalRoot);
16861728
blob_write_to_file(&manifest, zManifestFile);
16871729
blob_reset(&manifest);
16881730
--- src/checkin.c
+++ src/checkin.c
@@ -108,10 +108,14 @@
108 }else if( isChnged ){
109 if( isChnged==2 ){
110 blob_appendf(report, "UPDATED_BY_MERGE %s\n", zDisplayName);
111 }else if( isChnged==3 ){
112 blob_appendf(report, "ADDED_BY_MERGE %s\n", zDisplayName);
 
 
 
 
113 }else if( file_contains_merge_marker(zFullName) ){
114 blob_appendf(report, "CONFLICT %s\n", zDisplayName);
115 }else{
116 blob_appendf(report, "EDITED %s\n", zDisplayName);
117 }
@@ -129,10 +133,11 @@
129 while( db_step(&q)==SQLITE_ROW ){
130 const char *zLabel = "MERGED_WITH";
131 switch( db_column_int(&q, 1) ){
132 case -1: zLabel = "CHERRYPICK "; break;
133 case -2: zLabel = "BACKOUT "; break;
 
134 }
135 blob_append(report, zPrefix, nPrefix);
136 blob_appendf(report, "%s %s\n", zLabel, db_column_text(&q, 0));
137 }
138 db_finalize(&q);
@@ -332,10 +337,14 @@
332 }else if( chnged ){
333 if( chnged==2 ){
334 type = "UPDATED_BY_MERGE ";
335 }else if( chnged==3 ){
336 type = "ADDED_BY_MERGE ";
 
 
 
 
337 }else if( file_contains_merge_marker(zFullName) ){
338 type = "CONFLICT ";
339 }else{
340 type = "EDITED ";
341 }
@@ -1678,10 +1687,43 @@
1678 ** and rollback the transaction.
1679 */
1680 if( dryRunFlag ){
1681 blob_write_to_file(&manifest, "");
1682 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1683
1684 if( outputManifest ){
1685 zManifestFile = mprintf("%smanifest", g.zLocalRoot);
1686 blob_write_to_file(&manifest, zManifestFile);
1687 blob_reset(&manifest);
1688
--- src/checkin.c
+++ src/checkin.c
@@ -108,10 +108,14 @@
108 }else if( isChnged ){
109 if( isChnged==2 ){
110 blob_appendf(report, "UPDATED_BY_MERGE %s\n", zDisplayName);
111 }else if( isChnged==3 ){
112 blob_appendf(report, "ADDED_BY_MERGE %s\n", zDisplayName);
113 }else if( isChnged==4 ){
114 blob_appendf(report, "UPDATED_BY_INTEGRATE %s\n", zDisplayName);
115 }else if( isChnged==5 ){
116 blob_appendf(report, "ADDED_BY_INTEGRATE %s\n", zDisplayName);
117 }else if( file_contains_merge_marker(zFullName) ){
118 blob_appendf(report, "CONFLICT %s\n", zDisplayName);
119 }else{
120 blob_appendf(report, "EDITED %s\n", zDisplayName);
121 }
@@ -129,10 +133,11 @@
133 while( db_step(&q)==SQLITE_ROW ){
134 const char *zLabel = "MERGED_WITH";
135 switch( db_column_int(&q, 1) ){
136 case -1: zLabel = "CHERRYPICK "; break;
137 case -2: zLabel = "BACKOUT "; break;
138 case -4: zLabel = "INTEGRATE "; break;
139 }
140 blob_append(report, zPrefix, nPrefix);
141 blob_appendf(report, "%s %s\n", zLabel, db_column_text(&q, 0));
142 }
143 db_finalize(&q);
@@ -332,10 +337,14 @@
337 }else if( chnged ){
338 if( chnged==2 ){
339 type = "UPDATED_BY_MERGE ";
340 }else if( chnged==3 ){
341 type = "ADDED_BY_MERGE ";
342 }else if( chnged==4 ){
343 type = "UPDATED_BY_INTEGRATE ";
344 }else if( chnged==5 ){
345 type = "ADDED_BY_INTEGRATE ";
346 }else if( file_contains_merge_marker(zFullName) ){
347 type = "CONFLICT ";
348 }else{
349 type = "EDITED ";
350 }
@@ -1678,10 +1687,43 @@
1687 ** and rollback the transaction.
1688 */
1689 if( dryRunFlag ){
1690 blob_write_to_file(&manifest, "");
1691 }
1692
1693 db_prepare(&q, "SELECT uuid,merge FROM vmerge JOIN blob ON merge=rid"
1694 " WHERE id=-4");
1695 while( db_step(&q)==SQLITE_ROW ){
1696 const char *zIntegrateUuid = db_column_text(&q, 0);
1697 int rid = db_column_int(&q, 1);
1698 if( !is_a_leaf(rid) ){
1699 fossil_print("Not_Closed: %s (not a leaf any more)\n", zIntegrateUuid);
1700 }else{
1701 if (!db_exists("SELECT 1 FROM tagxref "
1702 " WHERE tagid=%d AND rid=%d AND tagtype>0",
1703 TAG_CLOSED, rid)
1704 ){
1705 Blob ctrl;
1706 Blob cksum;
1707 char *zDate;
1708 int nrid;
1709
1710 blob_zero(&ctrl);
1711 zDate = date_in_standard_format(sCiInfo.zDateOvrd ? sCiInfo.zDateOvrd : "now");
1712 blob_appendf(&ctrl, "D %s\n", zDate);
1713 blob_appendf(&ctrl, "T +closed %s\n", zIntegrateUuid);
1714 blob_appendf(&ctrl, "U %F\n", sCiInfo.zUserOvrd ? sCiInfo.zUserOvrd : g.zLogin);
1715 md5sum_blob(&ctrl, &cksum);
1716 blob_appendf(&ctrl, "Z %b\n", &cksum);
1717 nrid = content_put(&ctrl);
1718 manifest_crosslink(nrid, &ctrl);
1719 assert( blob_is_reset(&ctrl) );
1720 }
1721 fossil_print("Closed: %s\n", zIntegrateUuid);
1722 }
1723 }
1724 db_finalize(&q);
1725
1726 if( outputManifest ){
1727 zManifestFile = mprintf("%smanifest", g.zLocalRoot);
1728 blob_write_to_file(&manifest, zManifestFile);
1729 blob_reset(&manifest);
1730
+5 -5
--- src/event.c
+++ src/event.c
@@ -399,32 +399,32 @@
399399
@ <form method="post" action="%s(g.zTop)/eventedit"><div>
400400
login_insert_csrf_secret();
401401
@ <input type="hidden" name="name" value="%h(zEventId)" />
402402
@ <table border="0" cellspacing="10">
403403
404
- @ <tr><td align="right" valign="top"><b>Event&nbsp;Time:</b></td>
404
+ @ <tr><th align="right" valign="top">Event&nbsp;Time:</th>
405405
@ <td valign="top">
406406
@ <input type="text" name="t" size="25" value="%h(zETime)" />
407407
@ </td></tr>
408408
409
- @ <tr><td align="right" valign="top"><b>Timeline&nbsp;Comment:</b></td>
409
+ @ <tr><th align="right" valign="top">Timeline&nbsp;Comment:</th>
410410
@ <td valign="top">
411411
@ <textarea name="c" class="eventedit" cols="80"
412412
@ rows="3" wrap="virtual">%h(zComment)</textarea>
413413
@ </td></tr>
414414
415
- @ <tr><td align="right" valign="top"><b>Background&nbsp;Color:</b></td>
415
+ @ <tr><th align="right" valign="top">Background&nbsp;Color:</th>
416416
@ <td valign="top">
417417
render_color_chooser(0, zClr, 0, "clr", "cclr");
418418
@ </td></tr>
419419
420
- @ <tr><td align="right" valign="top"><b>Tags:</b></td>
420
+ @ <tr><th align="right" valign="top">Tags:</th>
421421
@ <td valign="top">
422422
@ <input type="text" name="g" size="40" value="%h(zTags)" />
423423
@ </td></tr>
424424
425
- @ <tr><td align="right" valign="top"><b>Page&nbsp;Content:</b></td>
425
+ @ <tr><th align="right" valign="top">Page&nbsp;Content:</th>
426426
@ <td valign="top">
427427
@ <textarea name="w" class="eventedit" cols="80"
428428
@ rows="%d(n)" wrap="virtual">%h(zBody)</textarea>
429429
@ </td></tr>
430430
431431
--- src/event.c
+++ src/event.c
@@ -399,32 +399,32 @@
399 @ <form method="post" action="%s(g.zTop)/eventedit"><div>
400 login_insert_csrf_secret();
401 @ <input type="hidden" name="name" value="%h(zEventId)" />
402 @ <table border="0" cellspacing="10">
403
404 @ <tr><td align="right" valign="top"><b>Event&nbsp;Time:</b></td>
405 @ <td valign="top">
406 @ <input type="text" name="t" size="25" value="%h(zETime)" />
407 @ </td></tr>
408
409 @ <tr><td align="right" valign="top"><b>Timeline&nbsp;Comment:</b></td>
410 @ <td valign="top">
411 @ <textarea name="c" class="eventedit" cols="80"
412 @ rows="3" wrap="virtual">%h(zComment)</textarea>
413 @ </td></tr>
414
415 @ <tr><td align="right" valign="top"><b>Background&nbsp;Color:</b></td>
416 @ <td valign="top">
417 render_color_chooser(0, zClr, 0, "clr", "cclr");
418 @ </td></tr>
419
420 @ <tr><td align="right" valign="top"><b>Tags:</b></td>
421 @ <td valign="top">
422 @ <input type="text" name="g" size="40" value="%h(zTags)" />
423 @ </td></tr>
424
425 @ <tr><td align="right" valign="top"><b>Page&nbsp;Content:</b></td>
426 @ <td valign="top">
427 @ <textarea name="w" class="eventedit" cols="80"
428 @ rows="%d(n)" wrap="virtual">%h(zBody)</textarea>
429 @ </td></tr>
430
431
--- src/event.c
+++ src/event.c
@@ -399,32 +399,32 @@
399 @ <form method="post" action="%s(g.zTop)/eventedit"><div>
400 login_insert_csrf_secret();
401 @ <input type="hidden" name="name" value="%h(zEventId)" />
402 @ <table border="0" cellspacing="10">
403
404 @ <tr><th align="right" valign="top">Event&nbsp;Time:</th>
405 @ <td valign="top">
406 @ <input type="text" name="t" size="25" value="%h(zETime)" />
407 @ </td></tr>
408
409 @ <tr><th align="right" valign="top">Timeline&nbsp;Comment:</th>
410 @ <td valign="top">
411 @ <textarea name="c" class="eventedit" cols="80"
412 @ rows="3" wrap="virtual">%h(zComment)</textarea>
413 @ </td></tr>
414
415 @ <tr><th align="right" valign="top">Background&nbsp;Color:</th>
416 @ <td valign="top">
417 render_color_chooser(0, zClr, 0, "clr", "cclr");
418 @ </td></tr>
419
420 @ <tr><th align="right" valign="top">Tags:</th>
421 @ <td valign="top">
422 @ <input type="text" name="g" size="40" value="%h(zTags)" />
423 @ </td></tr>
424
425 @ <tr><th align="right" valign="top">Page&nbsp;Content:</th>
426 @ <td valign="top">
427 @ <textarea name="w" class="eventedit" cols="80"
428 @ rows="%d(n)" wrap="virtual">%h(zBody)</textarea>
429 @ </td></tr>
430
431
+8 -8
--- src/info.c
+++ src/info.c
@@ -2221,38 +2221,38 @@
22212221
form_begin(0, "%R/ci_edit");
22222222
login_insert_csrf_secret();
22232223
@ <div><input type="hidden" name="r" value="%S(zUuid)" />
22242224
@ <table border="0" cellspacing="10">
22252225
2226
- @ <tr><td align="right" valign="top"><b>User:</b></td>
2226
+ @ <tr><th align="right" valign="top">User:</th>
22272227
@ <td valign="top">
22282228
@ <input type="text" name="u" size="20" value="%h(zNewUser)" />
22292229
@ </td></tr>
22302230
2231
- @ <tr><td align="right" valign="top"><b>Comment:</b></td>
2231
+ @ <tr><th align="right" valign="top">Comment:</th>
22322232
@ <td valign="top">
22332233
@ <textarea name="c" rows="10" cols="80">%h(zNewComment)</textarea>
22342234
@ </td></tr>
22352235
2236
- @ <tr><td align="right" valign="top"><b>Check-in Time:</b></td>
2236
+ @ <tr><th align="right" valign="top">Check-in Time:</th>
22372237
@ <td valign="top">
22382238
@ <input type="text" name="dt" size="20" value="%h(zNewDate)" />
22392239
@ </td></tr>
22402240
22412241
if( zChngTime ){
2242
- @ <tr><td align="right" valign="top"><b>Timestamp of this change:</b></td>
2242
+ @ <tr><th align="right" valign="top">Timestamp of this change:</th>
22432243
@ <td valign="top">
22442244
@ <input type="text" name="chngtime" size="20" value="%h(zChngTime)" />
22452245
@ </td></tr>
22462246
}
22472247
2248
- @ <tr><td align="right" valign="top"><b>Background Color:</b></td>
2248
+ @ <tr><th align="right" valign="top">Background Color:</th>
22492249
@ <td valign="top">
22502250
render_color_chooser(fNewPropagateColor, zNewColor, "pclr", "clr", "clrcust");
22512251
@ </td></tr>
22522252
2253
- @ <tr><td align="right" valign="top"><b>Tags:</b></td>
2253
+ @ <tr><th align="right" valign="top">Tags:</th>
22542254
@ <td valign="top">
22552255
@ <label><input type="checkbox" id="newtag" name="newtag"%s(zNewTagFlag) />
22562256
@ Add the following new tag name to this check-in:</label>
22572257
@ <input type="text" style="width:15;" name="tagname" value="%h(zNewTag)"
22582258
@ onkeyup="gebi('newtag').checked=!!this.value" />
@@ -2281,11 +2281,11 @@
22812281
}
22822282
}
22832283
db_finalize(&q);
22842284
@ </td></tr>
22852285
2286
- @ <tr><td align="right" valign="top"><b>Branching:</b></td>
2286
+ @ <tr><th align="right" valign="top">Branching:</th>
22872287
@ <td valign="top">
22882288
@ <label><input id="newbr" type="checkbox" name="newbr"%s(zNewBrFlag) />
22892289
@ Make this check-in the start of a new branch named:</label>
22902290
@ <input type="text" style="width:15;" name="brname" value="%h(zNewBranch)"
22912291
@ onkeyup="gebi('newbr').checked=!!this.value" />
@@ -2294,11 +2294,11 @@
22942294
if( is_a_leaf(rid)
22952295
&& !db_exists("SELECT 1 FROM tagxref "
22962296
" WHERE tagid=%d AND rid=%d AND tagtype>0",
22972297
TAG_CLOSED, rid)
22982298
){
2299
- @ <tr><td align="right" valign="top"><b>Leaf Closure:</b></td>
2299
+ @ <tr><th align="right" valign="top">Leaf Closure:</th>
23002300
@ <td valign="top">
23012301
@ <label><input type="checkbox" name="close"%s(zCloseFlag) />
23022302
@ Mark this leaf as "closed" so that it no longer appears on the
23032303
@ "leaves" page and is no longer labeled as a "<b>Leaf</b>".</label>
23042304
@ </td></tr>
23052305
--- src/info.c
+++ src/info.c
@@ -2221,38 +2221,38 @@
2221 form_begin(0, "%R/ci_edit");
2222 login_insert_csrf_secret();
2223 @ <div><input type="hidden" name="r" value="%S(zUuid)" />
2224 @ <table border="0" cellspacing="10">
2225
2226 @ <tr><td align="right" valign="top"><b>User:</b></td>
2227 @ <td valign="top">
2228 @ <input type="text" name="u" size="20" value="%h(zNewUser)" />
2229 @ </td></tr>
2230
2231 @ <tr><td align="right" valign="top"><b>Comment:</b></td>
2232 @ <td valign="top">
2233 @ <textarea name="c" rows="10" cols="80">%h(zNewComment)</textarea>
2234 @ </td></tr>
2235
2236 @ <tr><td align="right" valign="top"><b>Check-in Time:</b></td>
2237 @ <td valign="top">
2238 @ <input type="text" name="dt" size="20" value="%h(zNewDate)" />
2239 @ </td></tr>
2240
2241 if( zChngTime ){
2242 @ <tr><td align="right" valign="top"><b>Timestamp of this change:</b></td>
2243 @ <td valign="top">
2244 @ <input type="text" name="chngtime" size="20" value="%h(zChngTime)" />
2245 @ </td></tr>
2246 }
2247
2248 @ <tr><td align="right" valign="top"><b>Background Color:</b></td>
2249 @ <td valign="top">
2250 render_color_chooser(fNewPropagateColor, zNewColor, "pclr", "clr", "clrcust");
2251 @ </td></tr>
2252
2253 @ <tr><td align="right" valign="top"><b>Tags:</b></td>
2254 @ <td valign="top">
2255 @ <label><input type="checkbox" id="newtag" name="newtag"%s(zNewTagFlag) />
2256 @ Add the following new tag name to this check-in:</label>
2257 @ <input type="text" style="width:15;" name="tagname" value="%h(zNewTag)"
2258 @ onkeyup="gebi('newtag').checked=!!this.value" />
@@ -2281,11 +2281,11 @@
2281 }
2282 }
2283 db_finalize(&q);
2284 @ </td></tr>
2285
2286 @ <tr><td align="right" valign="top"><b>Branching:</b></td>
2287 @ <td valign="top">
2288 @ <label><input id="newbr" type="checkbox" name="newbr"%s(zNewBrFlag) />
2289 @ Make this check-in the start of a new branch named:</label>
2290 @ <input type="text" style="width:15;" name="brname" value="%h(zNewBranch)"
2291 @ onkeyup="gebi('newbr').checked=!!this.value" />
@@ -2294,11 +2294,11 @@
2294 if( is_a_leaf(rid)
2295 && !db_exists("SELECT 1 FROM tagxref "
2296 " WHERE tagid=%d AND rid=%d AND tagtype>0",
2297 TAG_CLOSED, rid)
2298 ){
2299 @ <tr><td align="right" valign="top"><b>Leaf Closure:</b></td>
2300 @ <td valign="top">
2301 @ <label><input type="checkbox" name="close"%s(zCloseFlag) />
2302 @ Mark this leaf as "closed" so that it no longer appears on the
2303 @ "leaves" page and is no longer labeled as a "<b>Leaf</b>".</label>
2304 @ </td></tr>
2305
--- src/info.c
+++ src/info.c
@@ -2221,38 +2221,38 @@
2221 form_begin(0, "%R/ci_edit");
2222 login_insert_csrf_secret();
2223 @ <div><input type="hidden" name="r" value="%S(zUuid)" />
2224 @ <table border="0" cellspacing="10">
2225
2226 @ <tr><th align="right" valign="top">User:</th>
2227 @ <td valign="top">
2228 @ <input type="text" name="u" size="20" value="%h(zNewUser)" />
2229 @ </td></tr>
2230
2231 @ <tr><th align="right" valign="top">Comment:</th>
2232 @ <td valign="top">
2233 @ <textarea name="c" rows="10" cols="80">%h(zNewComment)</textarea>
2234 @ </td></tr>
2235
2236 @ <tr><th align="right" valign="top">Check-in Time:</th>
2237 @ <td valign="top">
2238 @ <input type="text" name="dt" size="20" value="%h(zNewDate)" />
2239 @ </td></tr>
2240
2241 if( zChngTime ){
2242 @ <tr><th align="right" valign="top">Timestamp of this change:</th>
2243 @ <td valign="top">
2244 @ <input type="text" name="chngtime" size="20" value="%h(zChngTime)" />
2245 @ </td></tr>
2246 }
2247
2248 @ <tr><th align="right" valign="top">Background Color:</th>
2249 @ <td valign="top">
2250 render_color_chooser(fNewPropagateColor, zNewColor, "pclr", "clr", "clrcust");
2251 @ </td></tr>
2252
2253 @ <tr><th align="right" valign="top">Tags:</th>
2254 @ <td valign="top">
2255 @ <label><input type="checkbox" id="newtag" name="newtag"%s(zNewTagFlag) />
2256 @ Add the following new tag name to this check-in:</label>
2257 @ <input type="text" style="width:15;" name="tagname" value="%h(zNewTag)"
2258 @ onkeyup="gebi('newtag').checked=!!this.value" />
@@ -2281,11 +2281,11 @@
2281 }
2282 }
2283 db_finalize(&q);
2284 @ </td></tr>
2285
2286 @ <tr><th align="right" valign="top">Branching:</th>
2287 @ <td valign="top">
2288 @ <label><input id="newbr" type="checkbox" name="newbr"%s(zNewBrFlag) />
2289 @ Make this check-in the start of a new branch named:</label>
2290 @ <input type="text" style="width:15;" name="brname" value="%h(zNewBranch)"
2291 @ onkeyup="gebi('newbr').checked=!!this.value" />
@@ -2294,11 +2294,11 @@
2294 if( is_a_leaf(rid)
2295 && !db_exists("SELECT 1 FROM tagxref "
2296 " WHERE tagid=%d AND rid=%d AND tagtype>0",
2297 TAG_CLOSED, rid)
2298 ){
2299 @ <tr><th align="right" valign="top">Leaf Closure:</th>
2300 @ <td valign="top">
2301 @ <label><input type="checkbox" name="close"%s(zCloseFlag) />
2302 @ Mark this leaf as "closed" so that it no longer appears on the
2303 @ "leaves" page and is no longer labeled as a "<b>Leaf</b>".</label>
2304 @ </td></tr>
2305
--- src/json_status.c
+++ src/json_status.c
@@ -157,10 +157,11 @@
157157
while( db_step(&q)==SQLITE_ROW ){
158158
const char *zLabel = "MERGED_WITH";
159159
switch( db_column_int(&q, 1) ){
160160
case -1: zLabel = "CHERRYPICK "; break;
161161
case -2: zLabel = "BACKOUT "; break;
162
+ case -4: zLabel = "INTEGRATE "; break;
162163
}
163164
blob_append(report, zPrefix, nPrefix);
164165
blob_appendf(report, "%s %s\n", zLabel, db_column_text(&q, 0));
165166
}
166167
db_finalize(&q);
167168
--- src/json_status.c
+++ src/json_status.c
@@ -157,10 +157,11 @@
157 while( db_step(&q)==SQLITE_ROW ){
158 const char *zLabel = "MERGED_WITH";
159 switch( db_column_int(&q, 1) ){
160 case -1: zLabel = "CHERRYPICK "; break;
161 case -2: zLabel = "BACKOUT "; break;
 
162 }
163 blob_append(report, zPrefix, nPrefix);
164 blob_appendf(report, "%s %s\n", zLabel, db_column_text(&q, 0));
165 }
166 db_finalize(&q);
167
--- src/json_status.c
+++ src/json_status.c
@@ -157,10 +157,11 @@
157 while( db_step(&q)==SQLITE_ROW ){
158 const char *zLabel = "MERGED_WITH";
159 switch( db_column_int(&q, 1) ){
160 case -1: zLabel = "CHERRYPICK "; break;
161 case -2: zLabel = "BACKOUT "; break;
162 case -4: zLabel = "INTEGRATE "; break;
163 }
164 blob_append(report, zPrefix, nPrefix);
165 blob_appendf(report, "%s %s\n", zLabel, db_column_text(&q, 0));
166 }
167 db_finalize(&q);
168
+20 -7
--- src/merge.c
+++ src/merge.c
@@ -91,19 +91,22 @@
9191
** files whose names differ only in case are taken
9292
** to be the same file.
9393
**
9494
** -f|--force Force the merge even if it would be a no-op.
9595
**
96
+** --integrate Merged branch will be closed when committing.
97
+**
9698
** -n|--dry-run If given, display instead of run actions
9799
**
98100
** -v|--verbose Show additional details of the merge
99101
*/
100102
void merge_cmd(void){
101103
int vid; /* Current version "V" */
102104
int mid; /* Version we are merging from "M" */
103105
int pid; /* The pivot version - most recent common ancestor P */
104106
int verboseFlag; /* True if the -v|--verbose option is present */
107
+ int integrateFlag; /* True if the --integrate option is present */
105108
int pickFlag; /* True if the --cherrypick option is present */
106109
int backoutFlag; /* True if the --backout option is present */
107110
int dryRunFlag; /* True if the --dry-run or -n option is present */
108111
int forceFlag; /* True if the --force or -f option is present */
109112
const char *zBinGlob; /* The value of --binary */
@@ -128,10 +131,11 @@
128131
verboseFlag = find_option("verbose","v",0)!=0;
129132
if( !verboseFlag ){
130133
verboseFlag = find_option("detail",0,0)!=0; /* deprecated */
131134
}
132135
pickFlag = find_option("cherrypick",0,0)!=0;
136
+ integrateFlag = find_option("integrate",0,0)!=0;
133137
backoutFlag = find_option("backout",0,0)!=0;
134138
debugFlag = find_option("debug",0,0)!=0;
135139
zBinGlob = find_option("binary",0,1);
136140
dryRunFlag = find_option("dry-run","n",0)!=0;
137141
if( !dryRunFlag ){
@@ -162,12 +166,12 @@
162166
** has not already been merged into the current checkout and (3)
163167
** the leaf is not closed and (4) the leaf is in the same branch
164168
** as the current checkout.
165169
*/
166170
Stmt q;
167
- if( pickFlag || backoutFlag ){
168
- fossil_fatal("cannot use --cherrypick or --backout with a fork merge");
171
+ if( pickFlag || backoutFlag || integrateFlag){
172
+ fossil_fatal("cannot use --backout, --cherrypick or --integrate with a fork merge");
169173
}
170174
mid = db_int(0,
171175
"SELECT leaf.rid"
172176
" FROM leaf, event"
173177
" WHERE leaf.rid=event.objid"
@@ -220,10 +224,13 @@
220224
}
221225
if( pickFlag ){
222226
fossil_fatal("incompatible options: --cherrypick & --baseline");
223227
}
224228
}else if( pickFlag || backoutFlag ){
229
+ if( integrateFlag ){
230
+ fossil_fatal("incompatible options: --integrate & --cherrypick or --backout");
231
+ }
225232
pid = db_int(0, "SELECT pid FROM plink WHERE cid=%d AND isprim", mid);
226233
if( pid<=0 ){
227234
fossil_fatal("cannot find an ancestor for %s", g.argv[2]);
228235
}
229236
}else{
@@ -251,12 +258,16 @@
251258
if( !forceFlag && mid==pid ){
252259
fossil_print("Merge skipped because it is a no-op. "
253260
" Use --force to override.\n");
254261
return;
255262
}
263
+ if( integrateFlag && !is_a_leaf(mid) ){
264
+ fossil_warning("ignoring --integrate: %s is not a leaf", g.argv[2]);
265
+ integrateFlag = 0;
266
+ }
256267
if( verboseFlag ){
257
- print_checkin_description(mid, 12, "merge-from:");
268
+ print_checkin_description(mid, 12, integrateFlag?"integrate:":"merge-from:");
258269
print_checkin_description(pid, 12, "baseline:");
259270
}
260271
vfile_check_signature(vid, CKSIG_ENOTFILE);
261272
db_begin_transaction();
262273
if( !dryRunFlag ) undo_begin();
@@ -434,12 +445,12 @@
434445
int idv;
435446
const char *zName;
436447
char *zFullName;
437448
db_multi_exec(
438449
"INSERT INTO vfile(vid,chnged,deleted,rid,mrid,isexe,islink,pathname)"
439
- " SELECT %d,3,0,rid,mrid,isexe,islink,pathname FROM vfile WHERE id=%d",
440
- vid, idm
450
+ " SELECT %d,%d,0,rid,mrid,isexe,islink,pathname FROM vfile WHERE id=%d",
451
+ vid, integrateFlag?5:3, idm
441452
);
442453
idv = db_last_insert_rowid();
443454
db_multi_exec("UPDATE fv SET idv=%d WHERE rowid=%d", idv, rowid);
444455
zName = db_column_text(&q, 2);
445456
zFullName = mprintf("%s%s", g.zLocalRoot, zName);
@@ -474,12 +485,12 @@
474485
/* Copy content from idm over into idv. Overwrite idv. */
475486
fossil_print("UPDATE %s\n", zName);
476487
if( !dryRunFlag ){
477488
undo_save(zName);
478489
db_multi_exec(
479
- "UPDATE vfile SET mtime=0, mrid=%d, chnged=2, islink=%d "
480
- " WHERE id=%d", ridm, islinkm, idv
490
+ "UPDATE vfile SET mtime=0, mrid=%d, chnged=%d, islink=%d "
491
+ " WHERE id=%d", ridm, integrateFlag?4:2, islinkm, idv
481492
);
482493
vfile_to_disk(0, idv, 0, 0);
483494
}
484495
}
485496
db_finalize(&q);
@@ -644,11 +655,13 @@
644655
" WHERE type='ci' AND objid=%d",
645656
mid
646657
);
647658
}else if( backoutFlag ){
648659
db_multi_exec("INSERT OR IGNORE INTO vmerge(id,merge) VALUES(-2,%d)",pid);
660
+ }else if( integrateFlag ){
661
+ db_multi_exec("INSERT OR IGNORE INTO vmerge(id,merge) VALUES(-4,%d)",mid);
649662
}else{
650663
db_multi_exec("INSERT OR IGNORE INTO vmerge(id,merge) VALUES(0,%d)", mid);
651664
}
652665
undo_finish();
653666
db_end_transaction(dryRunFlag);
654667
}
655668
--- src/merge.c
+++ src/merge.c
@@ -91,19 +91,22 @@
91 ** files whose names differ only in case are taken
92 ** to be the same file.
93 **
94 ** -f|--force Force the merge even if it would be a no-op.
95 **
 
 
96 ** -n|--dry-run If given, display instead of run actions
97 **
98 ** -v|--verbose Show additional details of the merge
99 */
100 void merge_cmd(void){
101 int vid; /* Current version "V" */
102 int mid; /* Version we are merging from "M" */
103 int pid; /* The pivot version - most recent common ancestor P */
104 int verboseFlag; /* True if the -v|--verbose option is present */
 
105 int pickFlag; /* True if the --cherrypick option is present */
106 int backoutFlag; /* True if the --backout option is present */
107 int dryRunFlag; /* True if the --dry-run or -n option is present */
108 int forceFlag; /* True if the --force or -f option is present */
109 const char *zBinGlob; /* The value of --binary */
@@ -128,10 +131,11 @@
128 verboseFlag = find_option("verbose","v",0)!=0;
129 if( !verboseFlag ){
130 verboseFlag = find_option("detail",0,0)!=0; /* deprecated */
131 }
132 pickFlag = find_option("cherrypick",0,0)!=0;
 
133 backoutFlag = find_option("backout",0,0)!=0;
134 debugFlag = find_option("debug",0,0)!=0;
135 zBinGlob = find_option("binary",0,1);
136 dryRunFlag = find_option("dry-run","n",0)!=0;
137 if( !dryRunFlag ){
@@ -162,12 +166,12 @@
162 ** has not already been merged into the current checkout and (3)
163 ** the leaf is not closed and (4) the leaf is in the same branch
164 ** as the current checkout.
165 */
166 Stmt q;
167 if( pickFlag || backoutFlag ){
168 fossil_fatal("cannot use --cherrypick or --backout with a fork merge");
169 }
170 mid = db_int(0,
171 "SELECT leaf.rid"
172 " FROM leaf, event"
173 " WHERE leaf.rid=event.objid"
@@ -220,10 +224,13 @@
220 }
221 if( pickFlag ){
222 fossil_fatal("incompatible options: --cherrypick & --baseline");
223 }
224 }else if( pickFlag || backoutFlag ){
 
 
 
225 pid = db_int(0, "SELECT pid FROM plink WHERE cid=%d AND isprim", mid);
226 if( pid<=0 ){
227 fossil_fatal("cannot find an ancestor for %s", g.argv[2]);
228 }
229 }else{
@@ -251,12 +258,16 @@
251 if( !forceFlag && mid==pid ){
252 fossil_print("Merge skipped because it is a no-op. "
253 " Use --force to override.\n");
254 return;
255 }
 
 
 
 
256 if( verboseFlag ){
257 print_checkin_description(mid, 12, "merge-from:");
258 print_checkin_description(pid, 12, "baseline:");
259 }
260 vfile_check_signature(vid, CKSIG_ENOTFILE);
261 db_begin_transaction();
262 if( !dryRunFlag ) undo_begin();
@@ -434,12 +445,12 @@
434 int idv;
435 const char *zName;
436 char *zFullName;
437 db_multi_exec(
438 "INSERT INTO vfile(vid,chnged,deleted,rid,mrid,isexe,islink,pathname)"
439 " SELECT %d,3,0,rid,mrid,isexe,islink,pathname FROM vfile WHERE id=%d",
440 vid, idm
441 );
442 idv = db_last_insert_rowid();
443 db_multi_exec("UPDATE fv SET idv=%d WHERE rowid=%d", idv, rowid);
444 zName = db_column_text(&q, 2);
445 zFullName = mprintf("%s%s", g.zLocalRoot, zName);
@@ -474,12 +485,12 @@
474 /* Copy content from idm over into idv. Overwrite idv. */
475 fossil_print("UPDATE %s\n", zName);
476 if( !dryRunFlag ){
477 undo_save(zName);
478 db_multi_exec(
479 "UPDATE vfile SET mtime=0, mrid=%d, chnged=2, islink=%d "
480 " WHERE id=%d", ridm, islinkm, idv
481 );
482 vfile_to_disk(0, idv, 0, 0);
483 }
484 }
485 db_finalize(&q);
@@ -644,11 +655,13 @@
644 " WHERE type='ci' AND objid=%d",
645 mid
646 );
647 }else if( backoutFlag ){
648 db_multi_exec("INSERT OR IGNORE INTO vmerge(id,merge) VALUES(-2,%d)",pid);
 
 
649 }else{
650 db_multi_exec("INSERT OR IGNORE INTO vmerge(id,merge) VALUES(0,%d)", mid);
651 }
652 undo_finish();
653 db_end_transaction(dryRunFlag);
654 }
655
--- src/merge.c
+++ src/merge.c
@@ -91,19 +91,22 @@
91 ** files whose names differ only in case are taken
92 ** to be the same file.
93 **
94 ** -f|--force Force the merge even if it would be a no-op.
95 **
96 ** --integrate Merged branch will be closed when committing.
97 **
98 ** -n|--dry-run If given, display instead of run actions
99 **
100 ** -v|--verbose Show additional details of the merge
101 */
102 void merge_cmd(void){
103 int vid; /* Current version "V" */
104 int mid; /* Version we are merging from "M" */
105 int pid; /* The pivot version - most recent common ancestor P */
106 int verboseFlag; /* True if the -v|--verbose option is present */
107 int integrateFlag; /* True if the --integrate option is present */
108 int pickFlag; /* True if the --cherrypick option is present */
109 int backoutFlag; /* True if the --backout option is present */
110 int dryRunFlag; /* True if the --dry-run or -n option is present */
111 int forceFlag; /* True if the --force or -f option is present */
112 const char *zBinGlob; /* The value of --binary */
@@ -128,10 +131,11 @@
131 verboseFlag = find_option("verbose","v",0)!=0;
132 if( !verboseFlag ){
133 verboseFlag = find_option("detail",0,0)!=0; /* deprecated */
134 }
135 pickFlag = find_option("cherrypick",0,0)!=0;
136 integrateFlag = find_option("integrate",0,0)!=0;
137 backoutFlag = find_option("backout",0,0)!=0;
138 debugFlag = find_option("debug",0,0)!=0;
139 zBinGlob = find_option("binary",0,1);
140 dryRunFlag = find_option("dry-run","n",0)!=0;
141 if( !dryRunFlag ){
@@ -162,12 +166,12 @@
166 ** has not already been merged into the current checkout and (3)
167 ** the leaf is not closed and (4) the leaf is in the same branch
168 ** as the current checkout.
169 */
170 Stmt q;
171 if( pickFlag || backoutFlag || integrateFlag){
172 fossil_fatal("cannot use --backout, --cherrypick or --integrate with a fork merge");
173 }
174 mid = db_int(0,
175 "SELECT leaf.rid"
176 " FROM leaf, event"
177 " WHERE leaf.rid=event.objid"
@@ -220,10 +224,13 @@
224 }
225 if( pickFlag ){
226 fossil_fatal("incompatible options: --cherrypick & --baseline");
227 }
228 }else if( pickFlag || backoutFlag ){
229 if( integrateFlag ){
230 fossil_fatal("incompatible options: --integrate & --cherrypick or --backout");
231 }
232 pid = db_int(0, "SELECT pid FROM plink WHERE cid=%d AND isprim", mid);
233 if( pid<=0 ){
234 fossil_fatal("cannot find an ancestor for %s", g.argv[2]);
235 }
236 }else{
@@ -251,12 +258,16 @@
258 if( !forceFlag && mid==pid ){
259 fossil_print("Merge skipped because it is a no-op. "
260 " Use --force to override.\n");
261 return;
262 }
263 if( integrateFlag && !is_a_leaf(mid) ){
264 fossil_warning("ignoring --integrate: %s is not a leaf", g.argv[2]);
265 integrateFlag = 0;
266 }
267 if( verboseFlag ){
268 print_checkin_description(mid, 12, integrateFlag?"integrate:":"merge-from:");
269 print_checkin_description(pid, 12, "baseline:");
270 }
271 vfile_check_signature(vid, CKSIG_ENOTFILE);
272 db_begin_transaction();
273 if( !dryRunFlag ) undo_begin();
@@ -434,12 +445,12 @@
445 int idv;
446 const char *zName;
447 char *zFullName;
448 db_multi_exec(
449 "INSERT INTO vfile(vid,chnged,deleted,rid,mrid,isexe,islink,pathname)"
450 " SELECT %d,%d,0,rid,mrid,isexe,islink,pathname FROM vfile WHERE id=%d",
451 vid, integrateFlag?5:3, idm
452 );
453 idv = db_last_insert_rowid();
454 db_multi_exec("UPDATE fv SET idv=%d WHERE rowid=%d", idv, rowid);
455 zName = db_column_text(&q, 2);
456 zFullName = mprintf("%s%s", g.zLocalRoot, zName);
@@ -474,12 +485,12 @@
485 /* Copy content from idm over into idv. Overwrite idv. */
486 fossil_print("UPDATE %s\n", zName);
487 if( !dryRunFlag ){
488 undo_save(zName);
489 db_multi_exec(
490 "UPDATE vfile SET mtime=0, mrid=%d, chnged=%d, islink=%d "
491 " WHERE id=%d", ridm, integrateFlag?4:2, islinkm, idv
492 );
493 vfile_to_disk(0, idv, 0, 0);
494 }
495 }
496 db_finalize(&q);
@@ -644,11 +655,13 @@
655 " WHERE type='ci' AND objid=%d",
656 mid
657 );
658 }else if( backoutFlag ){
659 db_multi_exec("INSERT OR IGNORE INTO vmerge(id,merge) VALUES(-2,%d)",pid);
660 }else if( integrateFlag ){
661 db_multi_exec("INSERT OR IGNORE INTO vmerge(id,merge) VALUES(-4,%d)",mid);
662 }else{
663 db_multi_exec("INSERT OR IGNORE INTO vmerge(id,merge) VALUES(0,%d)", mid);
664 }
665 undo_finish();
666 db_end_transaction(dryRunFlag);
667 }
668
+11 -10
--- src/schema.c
+++ src/schema.c
@@ -475,25 +475,25 @@
475475
@ --
476476
@ -- The file.rid field is 0 for files or folders that have been
477477
@ -- added but not yet committed.
478478
@ --
479479
@ -- Vfile.chnged is 0 for unmodified files, 1 for files that have
480
-@ -- been edited or which have been subjected to a 3-way merge.
480
+@ -- been edited or which have been subjected to a 3-way merge.
481481
@ -- Vfile.chnged is 2 if the file has been replaced from a different
482482
@ -- version by the merge and 3 if the file has been added by a merge.
483
-@ -- The difference between vfile.chnged==2 and a regular add is that
484
-@ -- with vfile.chnged==2 we know that the current version of the file
485
-@ -- is already in the repository.
486
-@ --
483
+@ -- Vfile.chnged is 4|5 is the same as 2|3, but the operation has been
484
+@ -- done by an --integrate merge. The difference between vfile.chnged==2|4
485
+@ -- and a regular add is that with vfile.chnged==2|4 we know that the
486
+@ -- current version of the file is already in the repository.
487487
@ --
488488
@ CREATE TABLE vfile(
489489
@ id INTEGER PRIMARY KEY, -- ID of the checked out file
490490
@ vid INTEGER REFERENCES blob, -- The baseline this file is part of.
491
-@ chnged INT DEFAULT 0, -- 0:unchnged 1:edited 2:m-chng 3:m-add
492
-@ deleted BOOLEAN DEFAULT 0, -- True if deleted
491
+@ chnged INT DEFAULT 0, -- 0:unchnged 1:edited 2:m-chng 3:m-add 4:i-chng 5:i-add
492
+@ deleted BOOLEAN DEFAULT 0, -- True if deleted
493493
@ isexe BOOLEAN, -- True if file should be executable
494
-@ islink BOOLEAN, -- True if file should be symlink
494
+@ islink BOOLEAN, -- True if file should be symlink
495495
@ rid INTEGER, -- Originally from this repository record
496496
@ mrid INTEGER, -- Based on this record due to a merge
497497
@ mtime INTEGER, -- Mtime of file on disk. sec since 1970
498498
@ pathname TEXT, -- Full pathname relative to root
499499
@ origname TEXT, -- Original pathname. NULL if unchanged
@@ -502,12 +502,13 @@
502502
@
503503
@ -- This table holds a record of uncommitted merges in the local
504504
@ -- file tree. If a VFILE entry with id has merged with another
505505
@ -- record, there is an entry in this table with (id,merge) where
506506
@ -- merge is the RECORD table entry that the file merged against.
507
-@ -- An id of 0 here means the version record itself. When id==(-1)
508
-@ -- that is a cherrypick merge and id==(-2) is a backout merge.
507
+@ -- An id of 0 or <-3 here means the version record itself. When
508
+@ -- id==(-1) that is a cherrypick merge, id==(-2) that is a
509
+@ -- backout merge and id==(-4) is a integrate merge.
509510
@
510511
@ CREATE TABLE vmerge(
511512
@ id INTEGER REFERENCES vfile, -- VFILE entry that has been merged
512513
@ merge INTEGER, -- Merged with this record
513514
@ UNIQUE(id, merge)
514515
--- src/schema.c
+++ src/schema.c
@@ -475,25 +475,25 @@
475 @ --
476 @ -- The file.rid field is 0 for files or folders that have been
477 @ -- added but not yet committed.
478 @ --
479 @ -- Vfile.chnged is 0 for unmodified files, 1 for files that have
480 @ -- been edited or which have been subjected to a 3-way merge.
481 @ -- Vfile.chnged is 2 if the file has been replaced from a different
482 @ -- version by the merge and 3 if the file has been added by a merge.
483 @ -- The difference between vfile.chnged==2 and a regular add is that
484 @ -- with vfile.chnged==2 we know that the current version of the file
485 @ -- is already in the repository.
486 @ --
487 @ --
488 @ CREATE TABLE vfile(
489 @ id INTEGER PRIMARY KEY, -- ID of the checked out file
490 @ vid INTEGER REFERENCES blob, -- The baseline this file is part of.
491 @ chnged INT DEFAULT 0, -- 0:unchnged 1:edited 2:m-chng 3:m-add
492 @ deleted BOOLEAN DEFAULT 0, -- True if deleted
493 @ isexe BOOLEAN, -- True if file should be executable
494 @ islink BOOLEAN, -- True if file should be symlink
495 @ rid INTEGER, -- Originally from this repository record
496 @ mrid INTEGER, -- Based on this record due to a merge
497 @ mtime INTEGER, -- Mtime of file on disk. sec since 1970
498 @ pathname TEXT, -- Full pathname relative to root
499 @ origname TEXT, -- Original pathname. NULL if unchanged
@@ -502,12 +502,13 @@
502 @
503 @ -- This table holds a record of uncommitted merges in the local
504 @ -- file tree. If a VFILE entry with id has merged with another
505 @ -- record, there is an entry in this table with (id,merge) where
506 @ -- merge is the RECORD table entry that the file merged against.
507 @ -- An id of 0 here means the version record itself. When id==(-1)
508 @ -- that is a cherrypick merge and id==(-2) is a backout merge.
 
509 @
510 @ CREATE TABLE vmerge(
511 @ id INTEGER REFERENCES vfile, -- VFILE entry that has been merged
512 @ merge INTEGER, -- Merged with this record
513 @ UNIQUE(id, merge)
514
--- src/schema.c
+++ src/schema.c
@@ -475,25 +475,25 @@
475 @ --
476 @ -- The file.rid field is 0 for files or folders that have been
477 @ -- added but not yet committed.
478 @ --
479 @ -- Vfile.chnged is 0 for unmodified files, 1 for files that have
480 @ -- been edited or which have been subjected to a 3-way merge.
481 @ -- Vfile.chnged is 2 if the file has been replaced from a different
482 @ -- version by the merge and 3 if the file has been added by a merge.
483 @ -- Vfile.chnged is 4|5 is the same as 2|3, but the operation has been
484 @ -- done by an --integrate merge. The difference between vfile.chnged==2|4
485 @ -- and a regular add is that with vfile.chnged==2|4 we know that the
486 @ -- current version of the file is already in the repository.
487 @ --
488 @ CREATE TABLE vfile(
489 @ id INTEGER PRIMARY KEY, -- ID of the checked out file
490 @ vid INTEGER REFERENCES blob, -- The baseline this file is part of.
491 @ chnged INT DEFAULT 0, -- 0:unchnged 1:edited 2:m-chng 3:m-add 4:i-chng 5:i-add
492 @ deleted BOOLEAN DEFAULT 0, -- True if deleted
493 @ isexe BOOLEAN, -- True if file should be executable
494 @ islink BOOLEAN, -- True if file should be symlink
495 @ rid INTEGER, -- Originally from this repository record
496 @ mrid INTEGER, -- Based on this record due to a merge
497 @ mtime INTEGER, -- Mtime of file on disk. sec since 1970
498 @ pathname TEXT, -- Full pathname relative to root
499 @ origname TEXT, -- Original pathname. NULL if unchanged
@@ -502,12 +502,13 @@
502 @
503 @ -- This table holds a record of uncommitted merges in the local
504 @ -- file tree. If a VFILE entry with id has merged with another
505 @ -- record, there is an entry in this table with (id,merge) where
506 @ -- merge is the RECORD table entry that the file merged against.
507 @ -- An id of 0 or <-3 here means the version record itself. When
508 @ -- id==(-1) that is a cherrypick merge, id==(-2) that is a
509 @ -- backout merge and id==(-4) is a integrate merge.
510 @
511 @ CREATE TABLE vmerge(
512 @ id INTEGER REFERENCES vfile, -- VFILE entry that has been merged
513 @ merge INTEGER, -- Merged with this record
514 @ UNIQUE(id, merge)
515
+29 -29
--- src/setup.c
+++ src/setup.c
@@ -197,62 +197,62 @@
197197
@ </td><td class="usetupColumnLayout">
198198
@ <span class="note">Notes:</span>
199199
@ <ol>
200200
@ <li><p>The permission flags are as follows:</p>
201201
@ <table>
202
- @ <tr><td valign="top"><b>a</b></td>
202
+ @ <tr><th valign="top">a</th>
203203
@ <td><i>Admin:</i> Create and delete users</td></tr>
204
- @ <tr><td valign="top"><b>b</b></td>
204
+ @ <tr><th valign="top">b</th>
205205
@ <td><i>Attach:</i> Add attachments to wiki or tickets</td></tr>
206
- @ <tr><td valign="top"><b>c</b></td>
206
+ @ <tr><th valign="top">c</th>
207207
@ <td><i>Append-Tkt:</i> Append to tickets</td></tr>
208
- @ <tr><td valign="top"><b>d</b></td>
208
+ @ <tr><th valign="top">d</th>
209209
@ <td><i>Delete:</i> Delete wiki and tickets</td></tr>
210
- @ <tr><td valign="top"><b>e</b></td>
210
+ @ <tr><th valign="top">e</th>
211211
@ <td><i>Email:</i> View sensitive data such as EMail addresses</td></tr>
212
- @ <tr><td valign="top"><b>f</b></td>
212
+ @ <tr><th valign="top">f</th>
213213
@ <td><i>New-Wiki:</i> Create new wiki pages</td></tr>
214
- @ <tr><td valign="top"><b>g</b></td>
214
+ @ <tr><th valign="top">g</th>
215215
@ <td><i>Clone:</i> Clone the repository</td></tr>
216
- @ <tr><td valign="top"><b>h</b></td>
216
+ @ <tr><th valign="top">h</th>
217217
@ <td><i>Hyperlinks:</i> Show hyperlinks to detailed
218218
@ repository history</td></tr>
219
- @ <tr><td valign="top"><b>i</b></td>
219
+ @ <tr><th valign="top">i</th>
220220
@ <td><i>Check-In:</i> Commit new versions in the repository</td></tr>
221
- @ <tr><td valign="top"><b>j</b></td>
221
+ @ <tr><th valign="top">j</th>
222222
@ <td><i>Read-Wiki:</i> View wiki pages</td></tr>
223
- @ <tr><td valign="top"><b>k</b></td>
223
+ @ <tr><th valign="top">k</th>
224224
@ <td><i>Write-Wiki:</i> Edit wiki pages</td></tr>
225
- @ <tr><td valign="top"><b>l</b></td>
225
+ @ <tr><th valign="top">l</th>
226226
@ <td><i>Mod-Wiki:</i> Moderator for wiki pages</td></tr>
227
- @ <tr><td valign="top"><b>m</b></td>
227
+ @ <tr><th valign="top">m</th>
228228
@ <td><i>Append-Wiki:</i> Append to wiki pages</td></tr>
229
- @ <tr><td valign="top"><b>n</b></td>
229
+ @ <tr><th valign="top">n</th>
230230
@ <td><i>New-Tkt:</i> Create new tickets</td></tr>
231
- @ <tr><td valign="top"><b>o</b></td>
231
+ @ <tr><th valign="top">o</th>
232232
@ <td><i>Check-Out:</i> Check out versions</td></tr>
233
- @ <tr><td valign="top"><b>p</b></td>
233
+ @ <tr><th valign="top">p</th>
234234
@ <td><i>Password:</i> Change your own password</td></tr>
235
- @ <tr><td valign="top"><b>q</b></td>
235
+ @ <tr><th valign="top">q</th>
236236
@ <td><i>Mod-Tkt:</i> Moderator for tickets</td></tr>
237
- @ <tr><td valign="top"><b>r</b></td>
237
+ @ <tr><th valign="top">r</th>
238238
@ <td><i>Read-Tkt:</i> View tickets</td></tr>
239
- @ <tr><td valign="top"><b>s</b></td>
239
+ @ <tr><th valign="top">s</th>
240240
@ <td><i>Setup/Super-user:</i> Setup and configure this website</td></tr>
241
- @ <tr><td valign="top"><b>t</b></td>
241
+ @ <tr><th valign="top">t</th>
242242
@ <td><i>Tkt-Report:</i> Create new bug summary reports</td></tr>
243
- @ <tr><td valign="top"><b>u</b></td>
243
+ @ <tr><th valign="top">u</th>
244244
@ <td><i>Reader:</i> Inherit privileges of
245245
@ user <tt>reader</tt></td></tr>
246
- @ <tr><td valign="top"><b>v</b></td>
246
+ @ <tr><th valign="top">v</th>
247247
@ <td><i>Developer:</i> Inherit privileges of
248248
@ user <tt>developer</tt></td></tr>
249
- @ <tr><td valign="top"><b>w</b></td>
249
+ @ <tr><th valign="top">w</th>
250250
@ <td><i>Write-Tkt:</i> Edit tickets</td></tr>
251
- @ <tr><td valign="top"><b>x</b></td>
251
+ @ <tr><th valign="top">x</th>
252252
@ <td><i>Private:</i> Push and/or pull private branches</td></tr>
253
- @ <tr><td valign="top"><b>z</b></td>
253
+ @ <tr><th valign="top">z</th>
254254
@ <td><i>Zip download:</i> Download a baseline via the
255255
@ <tt>/zip</tt> URL even without
256256
@ check<span class="capability">o</span>ut
257257
@ and <span class="capability">h</span>istory permissions</td></tr>
258258
@ </table>
@@ -1062,23 +1062,23 @@
10621062
@
10631063
@ <form action="%s(g.zTop)/setup_login_group" method="post"><div>
10641064
login_insert_csrf_secret();
10651065
@ <blockquote><table border="0">
10661066
@
1067
- @ <tr><td align="right"><b>Repository filename in group to join:</b></td>
1067
+ @ <tr><th align="right">Repository filename in group to join:</th>
10681068
@ <td width="5"></td><td>
10691069
@ <input type="text" size="50" value="%h(zRepo)" name="repo"></td></tr>
10701070
@
1071
- @ <tr><td align="right"><b>Login on the above repo:</b></td>
1071
+ @ <tr><th align="right">Login on the above repo:</th>
10721072
@ <td width="5"></td><td>
10731073
@ <input type="text" size="20" value="%h(zLogin)" name="login"></td></tr>
10741074
@
1075
- @ <tr><td align="right"><b>Password:</b></td>
1075
+ @ <tr><th align="right">Password:</th>
10761076
@ <td width="5"></td><td>
10771077
@ <input type="password" size="20" name="pw"></td></tr>
10781078
@
1079
- @ <tr><td align="right"><b>Name of login-group:</b></td>
1079
+ @ <tr><th align="right">Name of login-group:</th>
10801080
@ <td width="5"></td><td>
10811081
@ <input type="text" size="30" value="%h(zNewName)" name="newname">
10821082
@ (only used if creating a new login-group).</td></tr>
10831083
@
10841084
@ <tr><td colspan="3" align="center">
10851085
--- src/setup.c
+++ src/setup.c
@@ -197,62 +197,62 @@
197 @ </td><td class="usetupColumnLayout">
198 @ <span class="note">Notes:</span>
199 @ <ol>
200 @ <li><p>The permission flags are as follows:</p>
201 @ <table>
202 @ <tr><td valign="top"><b>a</b></td>
203 @ <td><i>Admin:</i> Create and delete users</td></tr>
204 @ <tr><td valign="top"><b>b</b></td>
205 @ <td><i>Attach:</i> Add attachments to wiki or tickets</td></tr>
206 @ <tr><td valign="top"><b>c</b></td>
207 @ <td><i>Append-Tkt:</i> Append to tickets</td></tr>
208 @ <tr><td valign="top"><b>d</b></td>
209 @ <td><i>Delete:</i> Delete wiki and tickets</td></tr>
210 @ <tr><td valign="top"><b>e</b></td>
211 @ <td><i>Email:</i> View sensitive data such as EMail addresses</td></tr>
212 @ <tr><td valign="top"><b>f</b></td>
213 @ <td><i>New-Wiki:</i> Create new wiki pages</td></tr>
214 @ <tr><td valign="top"><b>g</b></td>
215 @ <td><i>Clone:</i> Clone the repository</td></tr>
216 @ <tr><td valign="top"><b>h</b></td>
217 @ <td><i>Hyperlinks:</i> Show hyperlinks to detailed
218 @ repository history</td></tr>
219 @ <tr><td valign="top"><b>i</b></td>
220 @ <td><i>Check-In:</i> Commit new versions in the repository</td></tr>
221 @ <tr><td valign="top"><b>j</b></td>
222 @ <td><i>Read-Wiki:</i> View wiki pages</td></tr>
223 @ <tr><td valign="top"><b>k</b></td>
224 @ <td><i>Write-Wiki:</i> Edit wiki pages</td></tr>
225 @ <tr><td valign="top"><b>l</b></td>
226 @ <td><i>Mod-Wiki:</i> Moderator for wiki pages</td></tr>
227 @ <tr><td valign="top"><b>m</b></td>
228 @ <td><i>Append-Wiki:</i> Append to wiki pages</td></tr>
229 @ <tr><td valign="top"><b>n</b></td>
230 @ <td><i>New-Tkt:</i> Create new tickets</td></tr>
231 @ <tr><td valign="top"><b>o</b></td>
232 @ <td><i>Check-Out:</i> Check out versions</td></tr>
233 @ <tr><td valign="top"><b>p</b></td>
234 @ <td><i>Password:</i> Change your own password</td></tr>
235 @ <tr><td valign="top"><b>q</b></td>
236 @ <td><i>Mod-Tkt:</i> Moderator for tickets</td></tr>
237 @ <tr><td valign="top"><b>r</b></td>
238 @ <td><i>Read-Tkt:</i> View tickets</td></tr>
239 @ <tr><td valign="top"><b>s</b></td>
240 @ <td><i>Setup/Super-user:</i> Setup and configure this website</td></tr>
241 @ <tr><td valign="top"><b>t</b></td>
242 @ <td><i>Tkt-Report:</i> Create new bug summary reports</td></tr>
243 @ <tr><td valign="top"><b>u</b></td>
244 @ <td><i>Reader:</i> Inherit privileges of
245 @ user <tt>reader</tt></td></tr>
246 @ <tr><td valign="top"><b>v</b></td>
247 @ <td><i>Developer:</i> Inherit privileges of
248 @ user <tt>developer</tt></td></tr>
249 @ <tr><td valign="top"><b>w</b></td>
250 @ <td><i>Write-Tkt:</i> Edit tickets</td></tr>
251 @ <tr><td valign="top"><b>x</b></td>
252 @ <td><i>Private:</i> Push and/or pull private branches</td></tr>
253 @ <tr><td valign="top"><b>z</b></td>
254 @ <td><i>Zip download:</i> Download a baseline via the
255 @ <tt>/zip</tt> URL even without
256 @ check<span class="capability">o</span>ut
257 @ and <span class="capability">h</span>istory permissions</td></tr>
258 @ </table>
@@ -1062,23 +1062,23 @@
1062 @
1063 @ <form action="%s(g.zTop)/setup_login_group" method="post"><div>
1064 login_insert_csrf_secret();
1065 @ <blockquote><table border="0">
1066 @
1067 @ <tr><td align="right"><b>Repository filename in group to join:</b></td>
1068 @ <td width="5"></td><td>
1069 @ <input type="text" size="50" value="%h(zRepo)" name="repo"></td></tr>
1070 @
1071 @ <tr><td align="right"><b>Login on the above repo:</b></td>
1072 @ <td width="5"></td><td>
1073 @ <input type="text" size="20" value="%h(zLogin)" name="login"></td></tr>
1074 @
1075 @ <tr><td align="right"><b>Password:</b></td>
1076 @ <td width="5"></td><td>
1077 @ <input type="password" size="20" name="pw"></td></tr>
1078 @
1079 @ <tr><td align="right"><b>Name of login-group:</b></td>
1080 @ <td width="5"></td><td>
1081 @ <input type="text" size="30" value="%h(zNewName)" name="newname">
1082 @ (only used if creating a new login-group).</td></tr>
1083 @
1084 @ <tr><td colspan="3" align="center">
1085
--- src/setup.c
+++ src/setup.c
@@ -197,62 +197,62 @@
197 @ </td><td class="usetupColumnLayout">
198 @ <span class="note">Notes:</span>
199 @ <ol>
200 @ <li><p>The permission flags are as follows:</p>
201 @ <table>
202 @ <tr><th valign="top">a</th>
203 @ <td><i>Admin:</i> Create and delete users</td></tr>
204 @ <tr><th valign="top">b</th>
205 @ <td><i>Attach:</i> Add attachments to wiki or tickets</td></tr>
206 @ <tr><th valign="top">c</th>
207 @ <td><i>Append-Tkt:</i> Append to tickets</td></tr>
208 @ <tr><th valign="top">d</th>
209 @ <td><i>Delete:</i> Delete wiki and tickets</td></tr>
210 @ <tr><th valign="top">e</th>
211 @ <td><i>Email:</i> View sensitive data such as EMail addresses</td></tr>
212 @ <tr><th valign="top">f</th>
213 @ <td><i>New-Wiki:</i> Create new wiki pages</td></tr>
214 @ <tr><th valign="top">g</th>
215 @ <td><i>Clone:</i> Clone the repository</td></tr>
216 @ <tr><th valign="top">h</th>
217 @ <td><i>Hyperlinks:</i> Show hyperlinks to detailed
218 @ repository history</td></tr>
219 @ <tr><th valign="top">i</th>
220 @ <td><i>Check-In:</i> Commit new versions in the repository</td></tr>
221 @ <tr><th valign="top">j</th>
222 @ <td><i>Read-Wiki:</i> View wiki pages</td></tr>
223 @ <tr><th valign="top">k</th>
224 @ <td><i>Write-Wiki:</i> Edit wiki pages</td></tr>
225 @ <tr><th valign="top">l</th>
226 @ <td><i>Mod-Wiki:</i> Moderator for wiki pages</td></tr>
227 @ <tr><th valign="top">m</th>
228 @ <td><i>Append-Wiki:</i> Append to wiki pages</td></tr>
229 @ <tr><th valign="top">n</th>
230 @ <td><i>New-Tkt:</i> Create new tickets</td></tr>
231 @ <tr><th valign="top">o</th>
232 @ <td><i>Check-Out:</i> Check out versions</td></tr>
233 @ <tr><th valign="top">p</th>
234 @ <td><i>Password:</i> Change your own password</td></tr>
235 @ <tr><th valign="top">q</th>
236 @ <td><i>Mod-Tkt:</i> Moderator for tickets</td></tr>
237 @ <tr><th valign="top">r</th>
238 @ <td><i>Read-Tkt:</i> View tickets</td></tr>
239 @ <tr><th valign="top">s</th>
240 @ <td><i>Setup/Super-user:</i> Setup and configure this website</td></tr>
241 @ <tr><th valign="top">t</th>
242 @ <td><i>Tkt-Report:</i> Create new bug summary reports</td></tr>
243 @ <tr><th valign="top">u</th>
244 @ <td><i>Reader:</i> Inherit privileges of
245 @ user <tt>reader</tt></td></tr>
246 @ <tr><th valign="top">v</th>
247 @ <td><i>Developer:</i> Inherit privileges of
248 @ user <tt>developer</tt></td></tr>
249 @ <tr><th valign="top">w</th>
250 @ <td><i>Write-Tkt:</i> Edit tickets</td></tr>
251 @ <tr><th valign="top">x</th>
252 @ <td><i>Private:</i> Push and/or pull private branches</td></tr>
253 @ <tr><th valign="top">z</th>
254 @ <td><i>Zip download:</i> Download a baseline via the
255 @ <tt>/zip</tt> URL even without
256 @ check<span class="capability">o</span>ut
257 @ and <span class="capability">h</span>istory permissions</td></tr>
258 @ </table>
@@ -1062,23 +1062,23 @@
1062 @
1063 @ <form action="%s(g.zTop)/setup_login_group" method="post"><div>
1064 login_insert_csrf_secret();
1065 @ <blockquote><table border="0">
1066 @
1067 @ <tr><th align="right">Repository filename in group to join:</th>
1068 @ <td width="5"></td><td>
1069 @ <input type="text" size="50" value="%h(zRepo)" name="repo"></td></tr>
1070 @
1071 @ <tr><th align="right">Login on the above repo:</th>
1072 @ <td width="5"></td><td>
1073 @ <input type="text" size="20" value="%h(zLogin)" name="login"></td></tr>
1074 @
1075 @ <tr><th align="right">Password:</th>
1076 @ <td width="5"></td><td>
1077 @ <input type="password" size="20" name="pw"></td></tr>
1078 @
1079 @ <tr><th align="right">Name of login-group:</th>
1080 @ <td width="5"></td><td>
1081 @ <input type="text" size="30" value="%h(zNewName)" name="newname">
1082 @ (only used if creating a new login-group).</td></tr>
1083 @
1084 @ <tr><td colspan="3" align="center">
1085
+5 -7
--- src/shun.c
+++ src/shun.c
@@ -66,11 +66,10 @@
6666
zUuid = zCanonical;
6767
}
6868
}
6969
style_header("Shunned Artifacts");
7070
if( zUuid && P("sub") ){
71
- login_verify_csrf_secret();
7271
db_multi_exec("DELETE FROM shun WHERE uuid='%s'", zUuid);
7372
if( db_exists("SELECT 1 FROM blob WHERE uuid='%s'", zUuid) ){
7473
@ <p class="noMoreShun">Artifact
7574
@ <a href="%s(g.zTop)/artifact/%s(zUuid)">%s(zUuid)</a> is no
7675
@ longer being shunned.</p>
@@ -141,11 +140,10 @@
141140
@ the formerly shunned artifact will be accepted on subsequent sync
142141
@ operations.</p>
143142
@
144143
@ <blockquote>
145144
@ <form method="post" action="%s(g.zTop)/%s(g.zPath)"><div>
146
- login_insert_csrf_secret();
147145
@ <input type="text" name="uuid" size="50" />
148146
@ <input type="submit" name="sub" value="Accept" />
149147
@ </div></form>
150148
@ </blockquote>
151149
@
@@ -293,28 +291,28 @@
293291
" FROM rcvfrom LEFT JOIN user USING(uid)"
294292
" WHERE rcvid=%d",
295293
rcvid
296294
);
297295
@ <table cellspacing="15" cellpadding="0" border="0">
298
- @ <tr><td valign="top" align="right"><b>rcvid:</b></td>
296
+ @ <tr><th valign="top" align="right">rcvid:</th>
299297
@ <td valign="top">%d(rcvid)</td></tr>
300298
if( db_step(&q)==SQLITE_ROW ){
301299
const char *zUser = db_column_text(&q, 0);
302300
const char *zDate = db_column_text(&q, 1);
303301
const char *zIpAddr = db_column_text(&q, 2);
304
- @ <tr><td valign="top" align="right"><b>User:</b></td>
302
+ @ <tr><th valign="top" align="right">User:</th>
305303
@ <td valign="top">%s(zUser)</td></tr>
306
- @ <tr><td valign="top" align="right"><b>Date:</b></td>
304
+ @ <tr><th valign="top" align="right">Date:</th>
307305
@ <td valign="top">%s(zDate)</td></tr>
308
- @ <tr><td valign="top" align="right"><b>IP&nbsp;Address:</b></td>
306
+ @ <tr><th valign="top" align="right">IP&nbsp;Address:</th>
309307
@ <td valign="top">%s(zIpAddr)</td></tr>
310308
}
311309
db_finalize(&q);
312310
db_prepare(&q,
313311
"SELECT rid, uuid, size FROM blob WHERE rcvid=%d", rcvid
314312
);
315
- @ <tr><td valign="top" align="right"><b>Artifacts:</b></td>
313
+ @ <tr><th valign="top" align="right">Artifacts:</th>
316314
@ <td valign="top">
317315
while( db_step(&q)==SQLITE_ROW ){
318316
int rid = db_column_int(&q, 0);
319317
const char *zUuid = db_column_text(&q, 1);
320318
int size = db_column_int(&q, 2);
321319
--- src/shun.c
+++ src/shun.c
@@ -66,11 +66,10 @@
66 zUuid = zCanonical;
67 }
68 }
69 style_header("Shunned Artifacts");
70 if( zUuid && P("sub") ){
71 login_verify_csrf_secret();
72 db_multi_exec("DELETE FROM shun WHERE uuid='%s'", zUuid);
73 if( db_exists("SELECT 1 FROM blob WHERE uuid='%s'", zUuid) ){
74 @ <p class="noMoreShun">Artifact
75 @ <a href="%s(g.zTop)/artifact/%s(zUuid)">%s(zUuid)</a> is no
76 @ longer being shunned.</p>
@@ -141,11 +140,10 @@
141 @ the formerly shunned artifact will be accepted on subsequent sync
142 @ operations.</p>
143 @
144 @ <blockquote>
145 @ <form method="post" action="%s(g.zTop)/%s(g.zPath)"><div>
146 login_insert_csrf_secret();
147 @ <input type="text" name="uuid" size="50" />
148 @ <input type="submit" name="sub" value="Accept" />
149 @ </div></form>
150 @ </blockquote>
151 @
@@ -293,28 +291,28 @@
293 " FROM rcvfrom LEFT JOIN user USING(uid)"
294 " WHERE rcvid=%d",
295 rcvid
296 );
297 @ <table cellspacing="15" cellpadding="0" border="0">
298 @ <tr><td valign="top" align="right"><b>rcvid:</b></td>
299 @ <td valign="top">%d(rcvid)</td></tr>
300 if( db_step(&q)==SQLITE_ROW ){
301 const char *zUser = db_column_text(&q, 0);
302 const char *zDate = db_column_text(&q, 1);
303 const char *zIpAddr = db_column_text(&q, 2);
304 @ <tr><td valign="top" align="right"><b>User:</b></td>
305 @ <td valign="top">%s(zUser)</td></tr>
306 @ <tr><td valign="top" align="right"><b>Date:</b></td>
307 @ <td valign="top">%s(zDate)</td></tr>
308 @ <tr><td valign="top" align="right"><b>IP&nbsp;Address:</b></td>
309 @ <td valign="top">%s(zIpAddr)</td></tr>
310 }
311 db_finalize(&q);
312 db_prepare(&q,
313 "SELECT rid, uuid, size FROM blob WHERE rcvid=%d", rcvid
314 );
315 @ <tr><td valign="top" align="right"><b>Artifacts:</b></td>
316 @ <td valign="top">
317 while( db_step(&q)==SQLITE_ROW ){
318 int rid = db_column_int(&q, 0);
319 const char *zUuid = db_column_text(&q, 1);
320 int size = db_column_int(&q, 2);
321
--- src/shun.c
+++ src/shun.c
@@ -66,11 +66,10 @@
66 zUuid = zCanonical;
67 }
68 }
69 style_header("Shunned Artifacts");
70 if( zUuid && P("sub") ){
 
71 db_multi_exec("DELETE FROM shun WHERE uuid='%s'", zUuid);
72 if( db_exists("SELECT 1 FROM blob WHERE uuid='%s'", zUuid) ){
73 @ <p class="noMoreShun">Artifact
74 @ <a href="%s(g.zTop)/artifact/%s(zUuid)">%s(zUuid)</a> is no
75 @ longer being shunned.</p>
@@ -141,11 +140,10 @@
140 @ the formerly shunned artifact will be accepted on subsequent sync
141 @ operations.</p>
142 @
143 @ <blockquote>
144 @ <form method="post" action="%s(g.zTop)/%s(g.zPath)"><div>
 
145 @ <input type="text" name="uuid" size="50" />
146 @ <input type="submit" name="sub" value="Accept" />
147 @ </div></form>
148 @ </blockquote>
149 @
@@ -293,28 +291,28 @@
291 " FROM rcvfrom LEFT JOIN user USING(uid)"
292 " WHERE rcvid=%d",
293 rcvid
294 );
295 @ <table cellspacing="15" cellpadding="0" border="0">
296 @ <tr><th valign="top" align="right">rcvid:</th>
297 @ <td valign="top">%d(rcvid)</td></tr>
298 if( db_step(&q)==SQLITE_ROW ){
299 const char *zUser = db_column_text(&q, 0);
300 const char *zDate = db_column_text(&q, 1);
301 const char *zIpAddr = db_column_text(&q, 2);
302 @ <tr><th valign="top" align="right">User:</th>
303 @ <td valign="top">%s(zUser)</td></tr>
304 @ <tr><th valign="top" align="right">Date:</th>
305 @ <td valign="top">%s(zDate)</td></tr>
306 @ <tr><th valign="top" align="right">IP&nbsp;Address:</th>
307 @ <td valign="top">%s(zIpAddr)</td></tr>
308 }
309 db_finalize(&q);
310 db_prepare(&q,
311 "SELECT rid, uuid, size FROM blob WHERE rcvid=%d", rcvid
312 );
313 @ <tr><th valign="top" align="right">Artifacts:</th>
314 @ <td valign="top">
315 while( db_step(&q)==SQLITE_ROW ){
316 int rid = db_column_int(&q, 0);
317 const char *zUuid = db_column_text(&q, 1);
318 int size = db_column_int(&q, 2);
319
+137 -111
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -399,13 +399,10 @@
399399
** On Windows, if the SQLITE_WIN32_MALLOC_VALIDATE macro is defined and the
400400
** assert() macro is enabled, each call into the Win32 native heap subsystem
401401
** will cause HeapValidate to be called. If heap validation should fail, an
402402
** assertion will be triggered.
403403
**
404
-** (Historical note: There used to be several other options, but we've
405
-** pared it down to just these three.)
406
-**
407404
** If none of the above are defined, then set SQLITE_SYSTEM_MALLOC as
408405
** the default.
409406
*/
410407
#if defined(SQLITE_SYSTEM_MALLOC) \
411408
+ defined(SQLITE_WIN32_MALLOC) \
@@ -439,24 +436,17 @@
439436
*/
440437
#if !defined(_XOPEN_SOURCE) && !defined(__DARWIN__) && !defined(__APPLE__)
441438
# define _XOPEN_SOURCE 600
442439
#endif
443440
444
-/*
445
-** The TCL headers are only needed when compiling the TCL bindings.
446
-*/
447
-#if defined(SQLITE_TCL) || defined(TCLSH)
448
-# include <tcl.h>
449
-#endif
450
-
451441
/*
452442
** NDEBUG and SQLITE_DEBUG are opposites. It should always be true that
453443
** defined(NDEBUG)==!defined(SQLITE_DEBUG). If this is not currently true,
454444
** make it true by defining or undefining NDEBUG.
455445
**
456
-** Setting NDEBUG makes the code smaller and run faster by disabling the
457
-** number assert() statements in the code. So we want the default action
446
+** Setting NDEBUG makes the code smaller and faster by disabling the
447
+** assert() statements in the code. So we want the default action
458448
** to be for NDEBUG to be set and NDEBUG to be undefined only if SQLITE_DEBUG
459449
** is set. Thus NDEBUG becomes an opt-in rather than an opt-out
460450
** feature.
461451
*/
462452
#if !defined(NDEBUG) && !defined(SQLITE_DEBUG)
@@ -522,11 +512,11 @@
522512
** hint of unplanned behavior.
523513
**
524514
** In other words, ALWAYS and NEVER are added for defensive code.
525515
**
526516
** When doing coverage testing ALWAYS and NEVER are hard-coded to
527
-** be true and false so that the unreachable code then specify will
517
+** be true and false so that the unreachable code they specify will
528518
** not be counted as untested code.
529519
*/
530520
#if defined(SQLITE_COVERAGE_TEST)
531521
# define ALWAYS(X) (1)
532522
# define NEVER(X) (0)
@@ -546,20 +536,16 @@
546536
#define IS_BIG_INT(X) (((X)&~(i64)0xffffffff)!=0)
547537
548538
/*
549539
** The macro unlikely() is a hint that surrounds a boolean
550540
** expression that is usually false. Macro likely() surrounds
551
-** a boolean expression that is usually true. GCC is able to
552
-** use these hints to generate better code, sometimes.
541
+** a boolean expression that is usually true. These hints could,
542
+** in theory, be used by the compiler to generate better code, but
543
+** currently they are just comments for human readers.
553544
*/
554
-#if defined(__GNUC__) && 0
555
-# define likely(X) __builtin_expect((X),1)
556
-# define unlikely(X) __builtin_expect((X),0)
557
-#else
558
-# define likely(X) !!(X)
559
-# define unlikely(X) !!(X)
560
-#endif
545
+#define likely(X) (X)
546
+#define unlikely(X) (X)
561547
562548
/************** Include sqlite3.h in the middle of sqliteInt.h ***************/
563549
/************** Begin file sqlite3.h *****************************************/
564550
/*
565551
** 2001 September 15
@@ -670,11 +656,11 @@
670656
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
671657
** [sqlite_version()] and [sqlite_source_id()].
672658
*/
673659
#define SQLITE_VERSION "3.8.0"
674660
#define SQLITE_VERSION_NUMBER 3008000
675
-#define SQLITE_SOURCE_ID "2013-07-25 17:07:03 8bcbb33fd0a970e16a920e1d35571836dbb9ba50"
661
+#define SQLITE_SOURCE_ID "2013-07-31 23:28:36 136fc2931b156f91cdd76a7a009298cdf09d826a"
676662
677663
/*
678664
** CAPI3REF: Run-Time Library Version Numbers
679665
** KEYWORDS: sqlite3_version, sqlite3_sourceid
680666
**
@@ -1039,10 +1025,11 @@
10391025
#define SQLITE_IOERR_SHMLOCK (SQLITE_IOERR | (20<<8))
10401026
#define SQLITE_IOERR_SHMMAP (SQLITE_IOERR | (21<<8))
10411027
#define SQLITE_IOERR_SEEK (SQLITE_IOERR | (22<<8))
10421028
#define SQLITE_IOERR_DELETE_NOENT (SQLITE_IOERR | (23<<8))
10431029
#define SQLITE_IOERR_MMAP (SQLITE_IOERR | (24<<8))
1030
+#define SQLITE_IOERR_GETTEMPPATH (SQLITE_IOERR | (25<<8))
10441031
#define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8))
10451032
#define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8))
10461033
#define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8))
10471034
#define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8))
10481035
#define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8))
@@ -28374,30 +28361,27 @@
2837428361
*/
2837528362
static const char *unixTempFileDir(void){
2837628363
static const char *azDirs[] = {
2837728364
0,
2837828365
0,
28379
-#ifdef __CYGWIN__
2838028366
0,
2838128367
0,
28382
-#endif
2838328368
"/var/tmp",
2838428369
"/usr/tmp",
2838528370
"/tmp",
28386
- 0 /* List terminator */
28371
+ "."
2838728372
};
2838828373
unsigned int i;
2838928374
struct stat buf;
28390
- const char *zDir = 0;
28375
+ const char *zDir;
2839128376
2839228377
azDirs[0] = sqlite3_temp_directory;
2839328378
if( !azDirs[1] ) azDirs[1] = getenv("TMPDIR");
28394
-#ifdef __CYGWIN__
2839528379
if( !azDirs[2] ) azDirs[2] = getenv("TMP");
2839628380
if( !azDirs[3] ) azDirs[3] = getenv("TEMP");
28397
-#endif
28398
- for(i=0; i<sizeof(azDirs)/sizeof(azDirs[0]); zDir=azDirs[i++]){
28381
+ for(i=0; i<sizeof(azDirs)/sizeof(azDirs[0]); i++){
28382
+ zDir = azDirs[i];
2839928383
if( zDir==0 ) continue;
2840028384
if( osStat(zDir, &buf) ) continue;
2840128385
if( !S_ISDIR(buf.st_mode) ) continue;
2840228386
if( osAccess(zDir, 07) ) continue;
2840328387
break;
@@ -28423,11 +28407,10 @@
2842328407
** function failing.
2842428408
*/
2842528409
SimulateIOError( return SQLITE_IOERR );
2842628410
2842728411
zDir = unixTempFileDir();
28428
- if( zDir==0 ) zDir = ".";
2842928412
2843028413
/* Check that the output buffer is large enough for the temporary file
2843128414
** name. If it is not, return SQLITE_ERROR.
2843228415
*/
2843328416
if( (strlen(zDir) + strlen(SQLITE_TEMP_FILE_PREFIX) + 18) >= (size_t)nBuf ){
@@ -30505,10 +30488,11 @@
3050530488
*/
3050630489
#if SQLITE_OS_WIN /* This file is used for Windows only */
3050730490
3050830491
#ifdef __CYGWIN__
3050930492
# include <sys/cygwin.h>
30493
+/* # include <errno.h> */
3051030494
#endif
3051130495
3051230496
/*
3051330497
** Include code that is common to all os_*.c files
3051430498
*/
@@ -30925,10 +30909,11 @@
3092530909
* zero for the default behavior.
3092630910
*/
3092730911
#ifndef SQLITE_WIN32_HEAP_FLAGS
3092830912
# define SQLITE_WIN32_HEAP_FLAGS (0)
3092930913
#endif
30914
+
3093030915
3093130916
/*
3093230917
** The winMemData structure stores information required by the Win32-specific
3093330918
** sqlite3_mem_methods implementation.
3093430919
*/
@@ -34390,14 +34375,14 @@
3439034375
OSTRACE(("MAP-FILE-CREATE pid=%lu, pFile=%p, rc=SQLITE_IOERR_MMAP\n",
3439134376
osGetCurrentProcessId(), pFd));
3439234377
return SQLITE_OK;
3439334378
}
3439434379
assert( (nMap % winSysInfo.dwPageSize)==0 );
34395
-#if SQLITE_OS_WINRT
34396
- pNew = osMapViewOfFileFromApp(pFd->hMap, flags, 0, nMap);
34397
-#else
3439834380
assert( sizeof(SIZE_T)==sizeof(sqlite3_int64) || nMap<=0xffffffff );
34381
+#if SQLITE_OS_WINRT
34382
+ pNew = osMapViewOfFileFromApp(pFd->hMap, flags, 0, (SIZE_T)nMap);
34383
+#else
3439934384
pNew = osMapViewOfFile(pFd->hMap, flags, 0, 0, (SIZE_T)nMap);
3440034385
#endif
3440134386
if( pNew==NULL ){
3440234387
osCloseHandle(pFd->hMap);
3440334388
pFd->hMap = NULL;
@@ -34564,10 +34549,19 @@
3456434549
return zConverted;
3456534550
}
3456634551
3456734552
static int winIsDir(const void *zConverted);
3456834553
34554
+/*
34555
+** Maximum pathname length (in bytes) for windows. The MAX_PATH macro is
34556
+** in characters, so we allocate 3 bytes per character assuming worst-case
34557
+** 3-bytes-per-character UTF8.
34558
+*/
34559
+#ifndef SQLITE_WIN32_MAX_PATH
34560
+# define SQLITE_WIN32_MAX_PATH (MAX_PATH*3)
34561
+#endif
34562
+
3456934563
/*
3457034564
** Create a temporary file name in zBuf. zBuf must be big enough to
3457134565
** hold at pVfs->mxPathname characters.
3457234566
*/
3457334567
static int getTempname(int nBuf, char *zBuf){
@@ -34575,95 +34569,115 @@
3457534569
"abcdefghijklmnopqrstuvwxyz"
3457634570
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
3457734571
"0123456789";
3457834572
size_t i, j;
3457934573
int nTempPath;
34580
- char zTempPath[MAX_PATH+2];
34574
+ char zTempPath[SQLITE_WIN32_MAX_PATH+2];
3458134575
3458234576
/* It's odd to simulate an io-error here, but really this is just
3458334577
** using the io-error infrastructure to test that SQLite handles this
3458434578
** function failing.
3458534579
*/
3458634580
SimulateIOError( return SQLITE_IOERR );
3458734581
34588
- memset(zTempPath, 0, MAX_PATH+2);
34589
-
3459034582
if( sqlite3_temp_directory ){
34591
- sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", sqlite3_temp_directory);
34583
+ sqlite3_snprintf(SQLITE_WIN32_MAX_PATH-30, zTempPath, "%s",
34584
+ sqlite3_temp_directory);
3459234585
}
3459334586
#if defined(__CYGWIN__)
34594
- static const char *azDirs[] = {
34595
- 0,
34596
- 0,
34597
- 0,
34598
- 0,
34599
- "/var/tmp",
34600
- "/usr/tmp",
34601
- "/tmp",
34602
- 0
34603
- };
34604
- const char *zDir = 0;
34605
- char *zConverted;
34606
-
34607
- azDirs[0] = sqlite3_temp_directory;
34608
- if( !azDirs[1] ) azDirs[1] = getenv("TMPDIR");
34609
- if( !azDirs[2] ) azDirs[2] = getenv("TMP");
34610
- if( !azDirs[3] ) azDirs[3] = getenv("TEMP");
34611
- for(i=0; i<sizeof(azDirs)/sizeof(azDirs[0]); zDir=azDirs[i++]){
34612
- if( zDir==0 || zDir[0]) continue;
34613
- if( zDir[1]!=':' ){
34614
- WCHAR zWidePath[MAX_PATH];
34615
- cygwin_conv_path(CCP_POSIX_TO_WIN_W, zDir, zWidePath, MAX_PATH);
34616
- zDir = unicodeToUtf8(zWidePath);
34617
- if( zDir==0 ){
34618
- OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
34619
- return SQLITE_IOERR_NOMEM;
34620
- }
34621
- }
34622
- /* Convert the filename to the system encoding. */
34623
- zConverted = convertUtf8Filename(zDir);
34624
- if( zConverted==0 ){
34625
- OSTRACE(("TEMP-FILENAME, rc=SQLITE_IOERR_NOMEM"));
34626
- return SQLITE_IOERR_NOMEM;
34627
- }
34628
- if( winIsDir(zConverted) ){
34629
- sqlite3_free(zConverted);
34630
- break;
34631
- }
34632
- sqlite3_free(zConverted);
34633
- }
34634
- sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", zDir);
34587
+ else{
34588
+ static const char *azDirs[] = {
34589
+ 0,
34590
+ 0,
34591
+ 0,
34592
+ 0,
34593
+ "/var/tmp",
34594
+ "/usr/tmp",
34595
+ "/tmp",
34596
+ "."
34597
+ };
34598
+ const char *zDir;
34599
+ WCHAR zWidePath[MAX_PATH];
34600
+
34601
+ if( !azDirs[0] ) azDirs[0] = getenv("TMPDIR");
34602
+ if( !azDirs[1] ) azDirs[1] = getenv("TMP");
34603
+ if( !azDirs[2] ) azDirs[2] = getenv("TEMP");
34604
+ if( !azDirs[3] ) azDirs[3] = getenv("USERPROFILE");
34605
+ for(i=0; i<sizeof(azDirs)/sizeof(azDirs[0]); i++){
34606
+ zDir = azDirs[i];
34607
+ if( zDir==0 || zDir[0]==0 ) continue;
34608
+ if( zDir[1]!=':' ){
34609
+ cygwin_conv_path(CCP_POSIX_TO_WIN_W, zDir, zWidePath, MAX_PATH);
34610
+ zDir = azDirs[i] = unicodeToUtf8(zWidePath);
34611
+ if( zDir==0 ){
34612
+ OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
34613
+ return SQLITE_IOERR_NOMEM;
34614
+ }
34615
+ }else{
34616
+ /* Convert the filename to the system encoding. */
34617
+ osMultiByteToWideChar(CP_UTF8, 0, zDir, -1, zWidePath,
34618
+ MAX_PATH);
34619
+ }
34620
+ if( winIsDir(zWidePath) ){
34621
+ break;
34622
+ }
34623
+ azDirs[i] = ""; /* Don't retry in future call */
34624
+ }
34625
+ sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", zDir);
34626
+ }
3463534627
#elif !SQLITE_OS_WINRT
3463634628
else if( isNT() ){
3463734629
char *zMulti;
3463834630
WCHAR zWidePath[MAX_PATH];
34639
- osGetTempPathW(MAX_PATH-30, zWidePath);
34631
+ if( osGetTempPathW(MAX_PATH-30, zWidePath)==0 ){
34632
+ OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_GETTEMPPATH\n"));
34633
+ return SQLITE_IOERR_GETTEMPPATH;
34634
+ }
3464034635
zMulti = unicodeToUtf8(zWidePath);
3464134636
if( zMulti ){
34642
- sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", zMulti);
34637
+ sqlite3_snprintf(SQLITE_WIN32_MAX_PATH-30, zTempPath, "%s", zMulti);
3464334638
sqlite3_free(zMulti);
3464434639
}else{
3464534640
OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
3464634641
return SQLITE_IOERR_NOMEM;
3464734642
}
3464834643
}
3464934644
#ifdef SQLITE_WIN32_HAS_ANSI
3465034645
else{
3465134646
char *zUtf8;
34652
- char zMbcsPath[MAX_PATH];
34653
- osGetTempPathA(MAX_PATH-30, zMbcsPath);
34647
+ char zMbcsPath[SQLITE_WIN32_MAX_PATH];
34648
+ if( osGetTempPathA(SQLITE_WIN32_MAX_PATH-30, zMbcsPath)==0 ){
34649
+ OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_GETTEMPPATH\n"));
34650
+ return SQLITE_IOERR_GETTEMPPATH;
34651
+ }
3465434652
zUtf8 = sqlite3_win32_mbcs_to_utf8(zMbcsPath);
3465534653
if( zUtf8 ){
34656
- sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", zUtf8);
34654
+ sqlite3_snprintf(SQLITE_WIN32_MAX_PATH-30, zTempPath, "%s", zUtf8);
3465734655
sqlite3_free(zUtf8);
3465834656
}else{
3465934657
OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
3466034658
return SQLITE_IOERR_NOMEM;
3466134659
}
3466234660
}
34663
-#endif
34664
-#endif
34661
+#else
34662
+ else{
34663
+ /*
34664
+ ** Compiled without ANSI support and the current operating system
34665
+ ** is not Windows NT; therefore, just zero the temporary buffer.
34666
+ */
34667
+ memset(zTempPath, 0, SQLITE_WIN32_MAX_PATH+2);
34668
+ }
34669
+#endif /* SQLITE_WIN32_HAS_ANSI */
34670
+#else
34671
+ else{
34672
+ /*
34673
+ ** Compiled for WinRT and the sqlite3_temp_directory is not set;
34674
+ ** therefore, just zero the temporary buffer.
34675
+ */
34676
+ memset(zTempPath, 0, SQLITE_WIN32_MAX_PATH+2);
34677
+ }
34678
+#endif /* !SQLITE_OS_WINRT */
3466534679
3466634680
/* Check that the output buffer is large enough for the temporary file
3466734681
** name. If it is not, return SQLITE_ERROR.
3466834682
*/
3466934683
nTempPath = sqlite3Strlen30(zTempPath);
@@ -34745,11 +34759,11 @@
3474534759
int cnt = 0;
3474634760
3474734761
/* If argument zPath is a NULL pointer, this function is required to open
3474834762
** a temporary file. Use this buffer to store the file name in.
3474934763
*/
34750
- char zTmpname[MAX_PATH+2]; /* Buffer used to create temp filename */
34764
+ char zTmpname[SQLITE_WIN32_MAX_PATH+2]; /* Buffer used to create temp filename */
3475134765
3475234766
int rc = SQLITE_OK; /* Function Return Code */
3475334767
#if !defined(NDEBUG) || SQLITE_OS_WINCE
3475434768
int eType = flags&0xFFFFFF00; /* Type of file to open */
3475534769
#endif
@@ -34811,12 +34825,11 @@
3481134825
/* If the second argument to this function is NULL, generate a
3481234826
** temporary file name to use
3481334827
*/
3481434828
if( !zUtf8Name ){
3481534829
assert(isDelete && !isOpenJournal);
34816
- memset(zTmpname, 0, MAX_PATH+2);
34817
- rc = getTempname(MAX_PATH+2, zTmpname);
34830
+ rc = getTempname(SQLITE_WIN32_MAX_PATH+2, zTmpname);
3481834831
if( rc!=SQLITE_OK ){
3481934832
OSTRACE(("OPEN name=%s, rc=%s", zUtf8Name, sqlite3ErrName(rc)));
3482034833
return rc;
3482134834
}
3482234835
zUtf8Name = zTmpname;
@@ -35243,27 +35256,34 @@
3524335256
){
3524435257
3524535258
#if defined(__CYGWIN__)
3524635259
SimulateIOError( return SQLITE_ERROR );
3524735260
UNUSED_PARAMETER(nFull);
35248
- assert( pVfs->mxPathname>=MAX_PATH );
35261
+ assert( pVfs->mxPathname>=SQLITE_WIN32_MAX_PATH );
3524935262
assert( nFull>=pVfs->mxPathname );
3525035263
if ( sqlite3_data_directory && !winIsVerbatimPathname(zRelative) ){
3525135264
/*
3525235265
** NOTE: We are dealing with a relative path name and the data
3525335266
** directory has been set. Therefore, use it as the basis
3525435267
** for converting the relative path name to an absolute
3525535268
** one by prepending the data directory and a slash.
3525635269
*/
35257
- char zOut[MAX_PATH+1];
35258
- memset(zOut, 0, MAX_PATH+1);
35259
- cygwin_conv_path(CCP_POSIX_TO_WIN_A|CCP_RELATIVE, zRelative, zOut,
35260
- MAX_PATH+1);
35270
+ char zOut[SQLITE_WIN32_MAX_PATH+1];
35271
+ if( cygwin_conv_path(CCP_POSIX_TO_WIN_A|CCP_RELATIVE, zRelative, zOut,
35272
+ SQLITE_WIN32_MAX_PATH+1)<0 ){
35273
+ winLogError(SQLITE_CANTOPEN_FULLPATH, (DWORD)errno, "cygwin_conv_path",
35274
+ zRelative);
35275
+ return SQLITE_CANTOPEN_FULLPATH;
35276
+ }
3526135277
sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s\\%s",
3526235278
sqlite3_data_directory, zOut);
3526335279
}else{
35264
- cygwin_conv_path(CCP_POSIX_TO_WIN_A, zRelative, zFull, nFull);
35280
+ if( cygwin_conv_path(CCP_POSIX_TO_WIN_A, zRelative, zFull, nFull)<0 ){
35281
+ winLogError(SQLITE_CANTOPEN_FULLPATH, (DWORD)errno, "cygwin_conv_path",
35282
+ zRelative);
35283
+ return SQLITE_CANTOPEN_FULLPATH;
35284
+ }
3526535285
}
3526635286
return SQLITE_OK;
3526735287
#endif
3526835288
3526935289
#if (SQLITE_OS_WINCE || SQLITE_OS_WINRT) && !defined(__CYGWIN__)
@@ -35601,11 +35621,11 @@
3560135621
*/
3560235622
SQLITE_API int sqlite3_os_init(void){
3560335623
static sqlite3_vfs winVfs = {
3560435624
3, /* iVersion */
3560535625
sizeof(winFile), /* szOsFile */
35606
- MAX_PATH, /* mxPathname */
35626
+ SQLITE_WIN32_MAX_PATH, /* mxPathname */
3560735627
0, /* pNext */
3560835628
"win32", /* zName */
3560935629
0, /* pAppData */
3561035630
winOpen, /* xOpen */
3561135631
winDelete, /* xDelete */
@@ -107770,10 +107790,11 @@
107770107790
WhereLevel *pLevel; /* The where level to be coded */
107771107791
WhereLoop *pLoop; /* The WhereLoop object being coded */
107772107792
WhereClause *pWC; /* Decomposition of the entire WHERE clause */
107773107793
WhereTerm *pTerm; /* A WHERE clause term */
107774107794
Parse *pParse; /* Parsing context */
107795
+ sqlite3 *db; /* Database connection */
107775107796
Vdbe *v; /* The prepared stmt under constructions */
107776107797
struct SrcList_item *pTabItem; /* FROM clause term being coded */
107777107798
int addrBrk; /* Jump here to break out of the loop */
107778107799
int addrCont; /* Jump here to continue with next cycle */
107779107800
int iRowidReg = 0; /* Rowid is stored in this register, if not zero */
@@ -107781,10 +107802,11 @@
107781107802
Bitmask newNotReady; /* Return value */
107782107803
107783107804
pParse = pWInfo->pParse;
107784107805
v = pParse->pVdbe;
107785107806
pWC = &pWInfo->sWC;
107807
+ db = pParse->db;
107786107808
pLevel = &pWInfo->a[iLevel];
107787107809
pLoop = pLevel->pWLoop;
107788107810
pTabItem = &pWInfo->pTabList->a[pLevel->iFrom];
107789107811
iCur = pTabItem->iCursor;
107790107812
bRev = (pWInfo->revMask>>iLevel)&1;
@@ -108071,11 +108093,11 @@
108071108093
/* Generate code to evaluate all constraint terms using == or IN
108072108094
** and store the values of those terms in an array of registers
108073108095
** starting at regBase.
108074108096
*/
108075108097
regBase = codeAllEqualityTerms(pParse,pLevel,bRev,nExtraReg,&zStartAff);
108076
- zEndAff = sqlite3DbStrDup(pParse->db, zStartAff);
108098
+ zEndAff = sqlite3DbStrDup(db, zStartAff);
108077108099
addrNxt = pLevel->addrNxt;
108078108100
108079108101
/* If we are doing a reverse order scan on an ascending index, or
108080108102
** a forward order scan on a descending index, interchange the
108081108103
** start and end terms (pRangeStart and pRangeEnd).
@@ -108156,12 +108178,12 @@
108156108178
}
108157108179
codeApplyAffinity(pParse, regBase, nEq+1, zEndAff);
108158108180
nConstraint++;
108159108181
testcase( pRangeEnd->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */
108160108182
}
108161
- sqlite3DbFree(pParse->db, zStartAff);
108162
- sqlite3DbFree(pParse->db, zEndAff);
108183
+ sqlite3DbFree(db, zStartAff);
108184
+ sqlite3DbFree(db, zEndAff);
108163108185
108164108186
/* Top of the loop body */
108165108187
pLevel->p2 = sqlite3VdbeCurrentAddr(v);
108166108188
108167108189
/* Check if the index cursor is past the end of the range. */
@@ -108284,11 +108306,11 @@
108284108306
*/
108285108307
if( pWInfo->nLevel>1 ){
108286108308
int nNotReady; /* The number of notReady tables */
108287108309
struct SrcList_item *origSrc; /* Original list of tables */
108288108310
nNotReady = pWInfo->nLevel - iLevel - 1;
108289
- pOrTab = sqlite3StackAllocRaw(pParse->db,
108311
+ pOrTab = sqlite3StackAllocRaw(db,
108290108312
sizeof(*pOrTab)+ nNotReady*sizeof(pOrTab->a[0]));
108291108313
if( pOrTab==0 ) return notReady;
108292108314
pOrTab->nAlloc = (u8)(nNotReady + 1);
108293108315
pOrTab->nSrc = pOrTab->nAlloc;
108294108316
memcpy(pOrTab->a, pTabItem, sizeof(*pTabItem));
@@ -108338,12 +108360,12 @@
108338108360
Expr *pExpr = pWC->a[iTerm].pExpr;
108339108361
if( &pWC->a[iTerm] == pTerm ) continue;
108340108362
if( ExprHasProperty(pExpr, EP_FromJoin) ) continue;
108341108363
if( pWC->a[iTerm].wtFlags & (TERM_ORINFO) ) continue;
108342108364
if( (pWC->a[iTerm].eOperator & WO_ALL)==0 ) continue;
108343
- pExpr = sqlite3ExprDup(pParse->db, pExpr, 0);
108344
- pAndExpr = sqlite3ExprAnd(pParse->db, pAndExpr, pExpr);
108365
+ pExpr = sqlite3ExprDup(db, pExpr, 0);
108366
+ pAndExpr = sqlite3ExprAnd(db, pAndExpr, pExpr);
108345108367
}
108346108368
if( pAndExpr ){
108347108369
pAndExpr = sqlite3PExpr(pParse, TK_AND, 0, pAndExpr, 0);
108348108370
}
108349108371
}
@@ -108359,11 +108381,11 @@
108359108381
}
108360108382
/* Loop through table entries that match term pOrTerm. */
108361108383
pSubWInfo = sqlite3WhereBegin(pParse, pOrTab, pOrExpr, 0, 0,
108362108384
WHERE_OMIT_OPEN_CLOSE | WHERE_AND_ONLY |
108363108385
WHERE_FORCE_TABLE | WHERE_ONETABLE_ONLY, iCovCur);
108364
- assert( pSubWInfo || pParse->nErr || pParse->db->mallocFailed );
108386
+ assert( pSubWInfo || pParse->nErr || db->mallocFailed );
108365108387
if( pSubWInfo ){
108366108388
WhereLoop *pSubLoop;
108367108389
explainOneScan(
108368108390
pParse, pOrTab, &pSubWInfo->a[0], iLevel, pLevel->iFrom, 0
108369108391
);
@@ -108414,17 +108436,17 @@
108414108436
}
108415108437
pLevel->u.pCovidx = pCov;
108416108438
if( pCov ) pLevel->iIdxCur = iCovCur;
108417108439
if( pAndExpr ){
108418108440
pAndExpr->pLeft = 0;
108419
- sqlite3ExprDelete(pParse->db, pAndExpr);
108441
+ sqlite3ExprDelete(db, pAndExpr);
108420108442
}
108421108443
sqlite3VdbeChangeP1(v, iRetInit, sqlite3VdbeCurrentAddr(v));
108422108444
sqlite3VdbeAddOp2(v, OP_Goto, 0, pLevel->addrBrk);
108423108445
sqlite3VdbeResolveLabel(v, iLoopBody);
108424108446
108425
- if( pWInfo->nLevel>1 ) sqlite3StackFree(pParse->db, pOrTab);
108447
+ if( pWInfo->nLevel>1 ) sqlite3StackFree(db, pOrTab);
108426108448
if( !untestedTerms ) disableTerm(pLevel, pTerm);
108427108449
}else
108428108450
#endif /* SQLITE_OMIT_OR_OPTIMIZATION */
108429108451
108430108452
{
@@ -108475,13 +108497,12 @@
108475108497
** and we are coding the t1 loop and the t2 loop has not yet coded,
108476108498
** then we cannot use the "t1.a=t2.b" constraint, but we can code
108477108499
** the implied "t1.a=123" constraint.
108478108500
*/
108479108501
for(pTerm=pWC->a, j=pWC->nTerm; j>0; j--, pTerm++){
108480
- Expr *pE;
108502
+ Expr *pE, *pEAlt;
108481108503
WhereTerm *pAlt;
108482
- Expr sEq;
108483108504
if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
108484108505
if( pTerm->eOperator!=(WO_EQUIV|WO_EQ) ) continue;
108485108506
if( pTerm->leftCursor!=iCur ) continue;
108486108507
if( pLevel->iLeftJoin ) continue;
108487108508
pE = pTerm->pExpr;
@@ -108491,13 +108512,17 @@
108491108512
if( pAlt==0 ) continue;
108492108513
if( pAlt->wtFlags & (TERM_CODED) ) continue;
108493108514
testcase( pAlt->eOperator & WO_EQ );
108494108515
testcase( pAlt->eOperator & WO_IN );
108495108516
VdbeNoopComment((v, "begin transitive constraint"));
108496
- sEq = *pAlt->pExpr;
108497
- sEq.pLeft = pE->pLeft;
108498
- sqlite3ExprIfFalse(pParse, &sEq, addrCont, SQLITE_JUMPIFNULL);
108517
+ pEAlt = sqlite3StackAllocRaw(db, sizeof(*pEAlt));
108518
+ if( pEAlt ){
108519
+ *pEAlt = *pAlt->pExpr;
108520
+ pEAlt->pLeft = pE->pLeft;
108521
+ sqlite3ExprIfFalse(pParse, pEAlt, addrCont, SQLITE_JUMPIFNULL);
108522
+ sqlite3StackFree(db, pEAlt);
108523
+ }
108499108524
}
108500108525
108501108526
/* For a LEFT OUTER JOIN, generate code that will record the fact that
108502108527
** at least one row of the right table has matched the left table.
108503108528
*/
@@ -116436,10 +116461,11 @@
116436116461
case SQLITE_IOERR_SHMLOCK: zName = "SQLITE_IOERR_SHMLOCK"; break;
116437116462
case SQLITE_IOERR_SHMMAP: zName = "SQLITE_IOERR_SHMMAP"; break;
116438116463
case SQLITE_IOERR_SEEK: zName = "SQLITE_IOERR_SEEK"; break;
116439116464
case SQLITE_IOERR_DELETE_NOENT: zName = "SQLITE_IOERR_DELETE_NOENT";break;
116440116465
case SQLITE_IOERR_MMAP: zName = "SQLITE_IOERR_MMAP"; break;
116466
+ case SQLITE_IOERR_GETTEMPPATH: zName = "SQLITE_IOERR_GETTEMPPATH"; break;
116441116467
case SQLITE_CORRUPT: zName = "SQLITE_CORRUPT"; break;
116442116468
case SQLITE_CORRUPT_VTAB: zName = "SQLITE_CORRUPT_VTAB"; break;
116443116469
case SQLITE_NOTFOUND: zName = "SQLITE_NOTFOUND"; break;
116444116470
case SQLITE_FULL: zName = "SQLITE_FULL"; break;
116445116471
case SQLITE_CANTOPEN: zName = "SQLITE_CANTOPEN"; break;
@@ -128264,11 +128290,11 @@
128264128290
}
128265128291
128266128292
128267128293
#ifdef SQLITE_TEST
128268128294
128269
-/* #include <tcl.h> */
128295
+#include <tcl.h>
128270128296
/* #include <string.h> */
128271128297
128272128298
/*
128273128299
** Implementation of a special SQL scalar function for testing tokenizers
128274128300
** designed to be used in concert with the Tcl testing framework. This
128275128301
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -399,13 +399,10 @@
399 ** On Windows, if the SQLITE_WIN32_MALLOC_VALIDATE macro is defined and the
400 ** assert() macro is enabled, each call into the Win32 native heap subsystem
401 ** will cause HeapValidate to be called. If heap validation should fail, an
402 ** assertion will be triggered.
403 **
404 ** (Historical note: There used to be several other options, but we've
405 ** pared it down to just these three.)
406 **
407 ** If none of the above are defined, then set SQLITE_SYSTEM_MALLOC as
408 ** the default.
409 */
410 #if defined(SQLITE_SYSTEM_MALLOC) \
411 + defined(SQLITE_WIN32_MALLOC) \
@@ -439,24 +436,17 @@
439 */
440 #if !defined(_XOPEN_SOURCE) && !defined(__DARWIN__) && !defined(__APPLE__)
441 # define _XOPEN_SOURCE 600
442 #endif
443
444 /*
445 ** The TCL headers are only needed when compiling the TCL bindings.
446 */
447 #if defined(SQLITE_TCL) || defined(TCLSH)
448 # include <tcl.h>
449 #endif
450
451 /*
452 ** NDEBUG and SQLITE_DEBUG are opposites. It should always be true that
453 ** defined(NDEBUG)==!defined(SQLITE_DEBUG). If this is not currently true,
454 ** make it true by defining or undefining NDEBUG.
455 **
456 ** Setting NDEBUG makes the code smaller and run faster by disabling the
457 ** number assert() statements in the code. So we want the default action
458 ** to be for NDEBUG to be set and NDEBUG to be undefined only if SQLITE_DEBUG
459 ** is set. Thus NDEBUG becomes an opt-in rather than an opt-out
460 ** feature.
461 */
462 #if !defined(NDEBUG) && !defined(SQLITE_DEBUG)
@@ -522,11 +512,11 @@
522 ** hint of unplanned behavior.
523 **
524 ** In other words, ALWAYS and NEVER are added for defensive code.
525 **
526 ** When doing coverage testing ALWAYS and NEVER are hard-coded to
527 ** be true and false so that the unreachable code then specify will
528 ** not be counted as untested code.
529 */
530 #if defined(SQLITE_COVERAGE_TEST)
531 # define ALWAYS(X) (1)
532 # define NEVER(X) (0)
@@ -546,20 +536,16 @@
546 #define IS_BIG_INT(X) (((X)&~(i64)0xffffffff)!=0)
547
548 /*
549 ** The macro unlikely() is a hint that surrounds a boolean
550 ** expression that is usually false. Macro likely() surrounds
551 ** a boolean expression that is usually true. GCC is able to
552 ** use these hints to generate better code, sometimes.
 
553 */
554 #if defined(__GNUC__) && 0
555 # define likely(X) __builtin_expect((X),1)
556 # define unlikely(X) __builtin_expect((X),0)
557 #else
558 # define likely(X) !!(X)
559 # define unlikely(X) !!(X)
560 #endif
561
562 /************** Include sqlite3.h in the middle of sqliteInt.h ***************/
563 /************** Begin file sqlite3.h *****************************************/
564 /*
565 ** 2001 September 15
@@ -670,11 +656,11 @@
670 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
671 ** [sqlite_version()] and [sqlite_source_id()].
672 */
673 #define SQLITE_VERSION "3.8.0"
674 #define SQLITE_VERSION_NUMBER 3008000
675 #define SQLITE_SOURCE_ID "2013-07-25 17:07:03 8bcbb33fd0a970e16a920e1d35571836dbb9ba50"
676
677 /*
678 ** CAPI3REF: Run-Time Library Version Numbers
679 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
680 **
@@ -1039,10 +1025,11 @@
1039 #define SQLITE_IOERR_SHMLOCK (SQLITE_IOERR | (20<<8))
1040 #define SQLITE_IOERR_SHMMAP (SQLITE_IOERR | (21<<8))
1041 #define SQLITE_IOERR_SEEK (SQLITE_IOERR | (22<<8))
1042 #define SQLITE_IOERR_DELETE_NOENT (SQLITE_IOERR | (23<<8))
1043 #define SQLITE_IOERR_MMAP (SQLITE_IOERR | (24<<8))
 
1044 #define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8))
1045 #define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8))
1046 #define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8))
1047 #define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8))
1048 #define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8))
@@ -28374,30 +28361,27 @@
28374 */
28375 static const char *unixTempFileDir(void){
28376 static const char *azDirs[] = {
28377 0,
28378 0,
28379 #ifdef __CYGWIN__
28380 0,
28381 0,
28382 #endif
28383 "/var/tmp",
28384 "/usr/tmp",
28385 "/tmp",
28386 0 /* List terminator */
28387 };
28388 unsigned int i;
28389 struct stat buf;
28390 const char *zDir = 0;
28391
28392 azDirs[0] = sqlite3_temp_directory;
28393 if( !azDirs[1] ) azDirs[1] = getenv("TMPDIR");
28394 #ifdef __CYGWIN__
28395 if( !azDirs[2] ) azDirs[2] = getenv("TMP");
28396 if( !azDirs[3] ) azDirs[3] = getenv("TEMP");
28397 #endif
28398 for(i=0; i<sizeof(azDirs)/sizeof(azDirs[0]); zDir=azDirs[i++]){
28399 if( zDir==0 ) continue;
28400 if( osStat(zDir, &buf) ) continue;
28401 if( !S_ISDIR(buf.st_mode) ) continue;
28402 if( osAccess(zDir, 07) ) continue;
28403 break;
@@ -28423,11 +28407,10 @@
28423 ** function failing.
28424 */
28425 SimulateIOError( return SQLITE_IOERR );
28426
28427 zDir = unixTempFileDir();
28428 if( zDir==0 ) zDir = ".";
28429
28430 /* Check that the output buffer is large enough for the temporary file
28431 ** name. If it is not, return SQLITE_ERROR.
28432 */
28433 if( (strlen(zDir) + strlen(SQLITE_TEMP_FILE_PREFIX) + 18) >= (size_t)nBuf ){
@@ -30505,10 +30488,11 @@
30505 */
30506 #if SQLITE_OS_WIN /* This file is used for Windows only */
30507
30508 #ifdef __CYGWIN__
30509 # include <sys/cygwin.h>
 
30510 #endif
30511
30512 /*
30513 ** Include code that is common to all os_*.c files
30514 */
@@ -30925,10 +30909,11 @@
30925 * zero for the default behavior.
30926 */
30927 #ifndef SQLITE_WIN32_HEAP_FLAGS
30928 # define SQLITE_WIN32_HEAP_FLAGS (0)
30929 #endif
 
30930
30931 /*
30932 ** The winMemData structure stores information required by the Win32-specific
30933 ** sqlite3_mem_methods implementation.
30934 */
@@ -34390,14 +34375,14 @@
34390 OSTRACE(("MAP-FILE-CREATE pid=%lu, pFile=%p, rc=SQLITE_IOERR_MMAP\n",
34391 osGetCurrentProcessId(), pFd));
34392 return SQLITE_OK;
34393 }
34394 assert( (nMap % winSysInfo.dwPageSize)==0 );
34395 #if SQLITE_OS_WINRT
34396 pNew = osMapViewOfFileFromApp(pFd->hMap, flags, 0, nMap);
34397 #else
34398 assert( sizeof(SIZE_T)==sizeof(sqlite3_int64) || nMap<=0xffffffff );
 
 
 
34399 pNew = osMapViewOfFile(pFd->hMap, flags, 0, 0, (SIZE_T)nMap);
34400 #endif
34401 if( pNew==NULL ){
34402 osCloseHandle(pFd->hMap);
34403 pFd->hMap = NULL;
@@ -34564,10 +34549,19 @@
34564 return zConverted;
34565 }
34566
34567 static int winIsDir(const void *zConverted);
34568
 
 
 
 
 
 
 
 
 
34569 /*
34570 ** Create a temporary file name in zBuf. zBuf must be big enough to
34571 ** hold at pVfs->mxPathname characters.
34572 */
34573 static int getTempname(int nBuf, char *zBuf){
@@ -34575,95 +34569,115 @@
34575 "abcdefghijklmnopqrstuvwxyz"
34576 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
34577 "0123456789";
34578 size_t i, j;
34579 int nTempPath;
34580 char zTempPath[MAX_PATH+2];
34581
34582 /* It's odd to simulate an io-error here, but really this is just
34583 ** using the io-error infrastructure to test that SQLite handles this
34584 ** function failing.
34585 */
34586 SimulateIOError( return SQLITE_IOERR );
34587
34588 memset(zTempPath, 0, MAX_PATH+2);
34589
34590 if( sqlite3_temp_directory ){
34591 sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", sqlite3_temp_directory);
 
34592 }
34593 #if defined(__CYGWIN__)
34594 static const char *azDirs[] = {
34595 0,
34596 0,
34597 0,
34598 0,
34599 "/var/tmp",
34600 "/usr/tmp",
34601 "/tmp",
34602 0
34603 };
34604 const char *zDir = 0;
34605 char *zConverted;
34606
34607 azDirs[0] = sqlite3_temp_directory;
34608 if( !azDirs[1] ) azDirs[1] = getenv("TMPDIR");
34609 if( !azDirs[2] ) azDirs[2] = getenv("TMP");
34610 if( !azDirs[3] ) azDirs[3] = getenv("TEMP");
34611 for(i=0; i<sizeof(azDirs)/sizeof(azDirs[0]); zDir=azDirs[i++]){
34612 if( zDir==0 || zDir[0]) continue;
34613 if( zDir[1]!=':' ){
34614 WCHAR zWidePath[MAX_PATH];
34615 cygwin_conv_path(CCP_POSIX_TO_WIN_W, zDir, zWidePath, MAX_PATH);
34616 zDir = unicodeToUtf8(zWidePath);
34617 if( zDir==0 ){
34618 OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
34619 return SQLITE_IOERR_NOMEM;
34620 }
34621 }
34622 /* Convert the filename to the system encoding. */
34623 zConverted = convertUtf8Filename(zDir);
34624 if( zConverted==0 ){
34625 OSTRACE(("TEMP-FILENAME, rc=SQLITE_IOERR_NOMEM"));
34626 return SQLITE_IOERR_NOMEM;
34627 }
34628 if( winIsDir(zConverted) ){
34629 sqlite3_free(zConverted);
34630 break;
34631 }
34632 sqlite3_free(zConverted);
34633 }
34634 sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", zDir);
34635 #elif !SQLITE_OS_WINRT
34636 else if( isNT() ){
34637 char *zMulti;
34638 WCHAR zWidePath[MAX_PATH];
34639 osGetTempPathW(MAX_PATH-30, zWidePath);
 
 
 
34640 zMulti = unicodeToUtf8(zWidePath);
34641 if( zMulti ){
34642 sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", zMulti);
34643 sqlite3_free(zMulti);
34644 }else{
34645 OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
34646 return SQLITE_IOERR_NOMEM;
34647 }
34648 }
34649 #ifdef SQLITE_WIN32_HAS_ANSI
34650 else{
34651 char *zUtf8;
34652 char zMbcsPath[MAX_PATH];
34653 osGetTempPathA(MAX_PATH-30, zMbcsPath);
 
 
 
34654 zUtf8 = sqlite3_win32_mbcs_to_utf8(zMbcsPath);
34655 if( zUtf8 ){
34656 sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", zUtf8);
34657 sqlite3_free(zUtf8);
34658 }else{
34659 OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
34660 return SQLITE_IOERR_NOMEM;
34661 }
34662 }
34663 #endif
34664 #endif
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34665
34666 /* Check that the output buffer is large enough for the temporary file
34667 ** name. If it is not, return SQLITE_ERROR.
34668 */
34669 nTempPath = sqlite3Strlen30(zTempPath);
@@ -34745,11 +34759,11 @@
34745 int cnt = 0;
34746
34747 /* If argument zPath is a NULL pointer, this function is required to open
34748 ** a temporary file. Use this buffer to store the file name in.
34749 */
34750 char zTmpname[MAX_PATH+2]; /* Buffer used to create temp filename */
34751
34752 int rc = SQLITE_OK; /* Function Return Code */
34753 #if !defined(NDEBUG) || SQLITE_OS_WINCE
34754 int eType = flags&0xFFFFFF00; /* Type of file to open */
34755 #endif
@@ -34811,12 +34825,11 @@
34811 /* If the second argument to this function is NULL, generate a
34812 ** temporary file name to use
34813 */
34814 if( !zUtf8Name ){
34815 assert(isDelete && !isOpenJournal);
34816 memset(zTmpname, 0, MAX_PATH+2);
34817 rc = getTempname(MAX_PATH+2, zTmpname);
34818 if( rc!=SQLITE_OK ){
34819 OSTRACE(("OPEN name=%s, rc=%s", zUtf8Name, sqlite3ErrName(rc)));
34820 return rc;
34821 }
34822 zUtf8Name = zTmpname;
@@ -35243,27 +35256,34 @@
35243 ){
35244
35245 #if defined(__CYGWIN__)
35246 SimulateIOError( return SQLITE_ERROR );
35247 UNUSED_PARAMETER(nFull);
35248 assert( pVfs->mxPathname>=MAX_PATH );
35249 assert( nFull>=pVfs->mxPathname );
35250 if ( sqlite3_data_directory && !winIsVerbatimPathname(zRelative) ){
35251 /*
35252 ** NOTE: We are dealing with a relative path name and the data
35253 ** directory has been set. Therefore, use it as the basis
35254 ** for converting the relative path name to an absolute
35255 ** one by prepending the data directory and a slash.
35256 */
35257 char zOut[MAX_PATH+1];
35258 memset(zOut, 0, MAX_PATH+1);
35259 cygwin_conv_path(CCP_POSIX_TO_WIN_A|CCP_RELATIVE, zRelative, zOut,
35260 MAX_PATH+1);
 
 
 
35261 sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s\\%s",
35262 sqlite3_data_directory, zOut);
35263 }else{
35264 cygwin_conv_path(CCP_POSIX_TO_WIN_A, zRelative, zFull, nFull);
 
 
 
 
35265 }
35266 return SQLITE_OK;
35267 #endif
35268
35269 #if (SQLITE_OS_WINCE || SQLITE_OS_WINRT) && !defined(__CYGWIN__)
@@ -35601,11 +35621,11 @@
35601 */
35602 SQLITE_API int sqlite3_os_init(void){
35603 static sqlite3_vfs winVfs = {
35604 3, /* iVersion */
35605 sizeof(winFile), /* szOsFile */
35606 MAX_PATH, /* mxPathname */
35607 0, /* pNext */
35608 "win32", /* zName */
35609 0, /* pAppData */
35610 winOpen, /* xOpen */
35611 winDelete, /* xDelete */
@@ -107770,10 +107790,11 @@
107770 WhereLevel *pLevel; /* The where level to be coded */
107771 WhereLoop *pLoop; /* The WhereLoop object being coded */
107772 WhereClause *pWC; /* Decomposition of the entire WHERE clause */
107773 WhereTerm *pTerm; /* A WHERE clause term */
107774 Parse *pParse; /* Parsing context */
 
107775 Vdbe *v; /* The prepared stmt under constructions */
107776 struct SrcList_item *pTabItem; /* FROM clause term being coded */
107777 int addrBrk; /* Jump here to break out of the loop */
107778 int addrCont; /* Jump here to continue with next cycle */
107779 int iRowidReg = 0; /* Rowid is stored in this register, if not zero */
@@ -107781,10 +107802,11 @@
107781 Bitmask newNotReady; /* Return value */
107782
107783 pParse = pWInfo->pParse;
107784 v = pParse->pVdbe;
107785 pWC = &pWInfo->sWC;
 
107786 pLevel = &pWInfo->a[iLevel];
107787 pLoop = pLevel->pWLoop;
107788 pTabItem = &pWInfo->pTabList->a[pLevel->iFrom];
107789 iCur = pTabItem->iCursor;
107790 bRev = (pWInfo->revMask>>iLevel)&1;
@@ -108071,11 +108093,11 @@
108071 /* Generate code to evaluate all constraint terms using == or IN
108072 ** and store the values of those terms in an array of registers
108073 ** starting at regBase.
108074 */
108075 regBase = codeAllEqualityTerms(pParse,pLevel,bRev,nExtraReg,&zStartAff);
108076 zEndAff = sqlite3DbStrDup(pParse->db, zStartAff);
108077 addrNxt = pLevel->addrNxt;
108078
108079 /* If we are doing a reverse order scan on an ascending index, or
108080 ** a forward order scan on a descending index, interchange the
108081 ** start and end terms (pRangeStart and pRangeEnd).
@@ -108156,12 +108178,12 @@
108156 }
108157 codeApplyAffinity(pParse, regBase, nEq+1, zEndAff);
108158 nConstraint++;
108159 testcase( pRangeEnd->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */
108160 }
108161 sqlite3DbFree(pParse->db, zStartAff);
108162 sqlite3DbFree(pParse->db, zEndAff);
108163
108164 /* Top of the loop body */
108165 pLevel->p2 = sqlite3VdbeCurrentAddr(v);
108166
108167 /* Check if the index cursor is past the end of the range. */
@@ -108284,11 +108306,11 @@
108284 */
108285 if( pWInfo->nLevel>1 ){
108286 int nNotReady; /* The number of notReady tables */
108287 struct SrcList_item *origSrc; /* Original list of tables */
108288 nNotReady = pWInfo->nLevel - iLevel - 1;
108289 pOrTab = sqlite3StackAllocRaw(pParse->db,
108290 sizeof(*pOrTab)+ nNotReady*sizeof(pOrTab->a[0]));
108291 if( pOrTab==0 ) return notReady;
108292 pOrTab->nAlloc = (u8)(nNotReady + 1);
108293 pOrTab->nSrc = pOrTab->nAlloc;
108294 memcpy(pOrTab->a, pTabItem, sizeof(*pTabItem));
@@ -108338,12 +108360,12 @@
108338 Expr *pExpr = pWC->a[iTerm].pExpr;
108339 if( &pWC->a[iTerm] == pTerm ) continue;
108340 if( ExprHasProperty(pExpr, EP_FromJoin) ) continue;
108341 if( pWC->a[iTerm].wtFlags & (TERM_ORINFO) ) continue;
108342 if( (pWC->a[iTerm].eOperator & WO_ALL)==0 ) continue;
108343 pExpr = sqlite3ExprDup(pParse->db, pExpr, 0);
108344 pAndExpr = sqlite3ExprAnd(pParse->db, pAndExpr, pExpr);
108345 }
108346 if( pAndExpr ){
108347 pAndExpr = sqlite3PExpr(pParse, TK_AND, 0, pAndExpr, 0);
108348 }
108349 }
@@ -108359,11 +108381,11 @@
108359 }
108360 /* Loop through table entries that match term pOrTerm. */
108361 pSubWInfo = sqlite3WhereBegin(pParse, pOrTab, pOrExpr, 0, 0,
108362 WHERE_OMIT_OPEN_CLOSE | WHERE_AND_ONLY |
108363 WHERE_FORCE_TABLE | WHERE_ONETABLE_ONLY, iCovCur);
108364 assert( pSubWInfo || pParse->nErr || pParse->db->mallocFailed );
108365 if( pSubWInfo ){
108366 WhereLoop *pSubLoop;
108367 explainOneScan(
108368 pParse, pOrTab, &pSubWInfo->a[0], iLevel, pLevel->iFrom, 0
108369 );
@@ -108414,17 +108436,17 @@
108414 }
108415 pLevel->u.pCovidx = pCov;
108416 if( pCov ) pLevel->iIdxCur = iCovCur;
108417 if( pAndExpr ){
108418 pAndExpr->pLeft = 0;
108419 sqlite3ExprDelete(pParse->db, pAndExpr);
108420 }
108421 sqlite3VdbeChangeP1(v, iRetInit, sqlite3VdbeCurrentAddr(v));
108422 sqlite3VdbeAddOp2(v, OP_Goto, 0, pLevel->addrBrk);
108423 sqlite3VdbeResolveLabel(v, iLoopBody);
108424
108425 if( pWInfo->nLevel>1 ) sqlite3StackFree(pParse->db, pOrTab);
108426 if( !untestedTerms ) disableTerm(pLevel, pTerm);
108427 }else
108428 #endif /* SQLITE_OMIT_OR_OPTIMIZATION */
108429
108430 {
@@ -108475,13 +108497,12 @@
108475 ** and we are coding the t1 loop and the t2 loop has not yet coded,
108476 ** then we cannot use the "t1.a=t2.b" constraint, but we can code
108477 ** the implied "t1.a=123" constraint.
108478 */
108479 for(pTerm=pWC->a, j=pWC->nTerm; j>0; j--, pTerm++){
108480 Expr *pE;
108481 WhereTerm *pAlt;
108482 Expr sEq;
108483 if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
108484 if( pTerm->eOperator!=(WO_EQUIV|WO_EQ) ) continue;
108485 if( pTerm->leftCursor!=iCur ) continue;
108486 if( pLevel->iLeftJoin ) continue;
108487 pE = pTerm->pExpr;
@@ -108491,13 +108512,17 @@
108491 if( pAlt==0 ) continue;
108492 if( pAlt->wtFlags & (TERM_CODED) ) continue;
108493 testcase( pAlt->eOperator & WO_EQ );
108494 testcase( pAlt->eOperator & WO_IN );
108495 VdbeNoopComment((v, "begin transitive constraint"));
108496 sEq = *pAlt->pExpr;
108497 sEq.pLeft = pE->pLeft;
108498 sqlite3ExprIfFalse(pParse, &sEq, addrCont, SQLITE_JUMPIFNULL);
 
 
 
 
108499 }
108500
108501 /* For a LEFT OUTER JOIN, generate code that will record the fact that
108502 ** at least one row of the right table has matched the left table.
108503 */
@@ -116436,10 +116461,11 @@
116436 case SQLITE_IOERR_SHMLOCK: zName = "SQLITE_IOERR_SHMLOCK"; break;
116437 case SQLITE_IOERR_SHMMAP: zName = "SQLITE_IOERR_SHMMAP"; break;
116438 case SQLITE_IOERR_SEEK: zName = "SQLITE_IOERR_SEEK"; break;
116439 case SQLITE_IOERR_DELETE_NOENT: zName = "SQLITE_IOERR_DELETE_NOENT";break;
116440 case SQLITE_IOERR_MMAP: zName = "SQLITE_IOERR_MMAP"; break;
 
116441 case SQLITE_CORRUPT: zName = "SQLITE_CORRUPT"; break;
116442 case SQLITE_CORRUPT_VTAB: zName = "SQLITE_CORRUPT_VTAB"; break;
116443 case SQLITE_NOTFOUND: zName = "SQLITE_NOTFOUND"; break;
116444 case SQLITE_FULL: zName = "SQLITE_FULL"; break;
116445 case SQLITE_CANTOPEN: zName = "SQLITE_CANTOPEN"; break;
@@ -128264,11 +128290,11 @@
128264 }
128265
128266
128267 #ifdef SQLITE_TEST
128268
128269 /* #include <tcl.h> */
128270 /* #include <string.h> */
128271
128272 /*
128273 ** Implementation of a special SQL scalar function for testing tokenizers
128274 ** designed to be used in concert with the Tcl testing framework. This
128275
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -399,13 +399,10 @@
399 ** On Windows, if the SQLITE_WIN32_MALLOC_VALIDATE macro is defined and the
400 ** assert() macro is enabled, each call into the Win32 native heap subsystem
401 ** will cause HeapValidate to be called. If heap validation should fail, an
402 ** assertion will be triggered.
403 **
 
 
 
404 ** If none of the above are defined, then set SQLITE_SYSTEM_MALLOC as
405 ** the default.
406 */
407 #if defined(SQLITE_SYSTEM_MALLOC) \
408 + defined(SQLITE_WIN32_MALLOC) \
@@ -439,24 +436,17 @@
436 */
437 #if !defined(_XOPEN_SOURCE) && !defined(__DARWIN__) && !defined(__APPLE__)
438 # define _XOPEN_SOURCE 600
439 #endif
440
 
 
 
 
 
 
 
441 /*
442 ** NDEBUG and SQLITE_DEBUG are opposites. It should always be true that
443 ** defined(NDEBUG)==!defined(SQLITE_DEBUG). If this is not currently true,
444 ** make it true by defining or undefining NDEBUG.
445 **
446 ** Setting NDEBUG makes the code smaller and faster by disabling the
447 ** assert() statements in the code. So we want the default action
448 ** to be for NDEBUG to be set and NDEBUG to be undefined only if SQLITE_DEBUG
449 ** is set. Thus NDEBUG becomes an opt-in rather than an opt-out
450 ** feature.
451 */
452 #if !defined(NDEBUG) && !defined(SQLITE_DEBUG)
@@ -522,11 +512,11 @@
512 ** hint of unplanned behavior.
513 **
514 ** In other words, ALWAYS and NEVER are added for defensive code.
515 **
516 ** When doing coverage testing ALWAYS and NEVER are hard-coded to
517 ** be true and false so that the unreachable code they specify will
518 ** not be counted as untested code.
519 */
520 #if defined(SQLITE_COVERAGE_TEST)
521 # define ALWAYS(X) (1)
522 # define NEVER(X) (0)
@@ -546,20 +536,16 @@
536 #define IS_BIG_INT(X) (((X)&~(i64)0xffffffff)!=0)
537
538 /*
539 ** The macro unlikely() is a hint that surrounds a boolean
540 ** expression that is usually false. Macro likely() surrounds
541 ** a boolean expression that is usually true. These hints could,
542 ** in theory, be used by the compiler to generate better code, but
543 ** currently they are just comments for human readers.
544 */
545 #define likely(X) (X)
546 #define unlikely(X) (X)
 
 
 
 
 
547
548 /************** Include sqlite3.h in the middle of sqliteInt.h ***************/
549 /************** Begin file sqlite3.h *****************************************/
550 /*
551 ** 2001 September 15
@@ -670,11 +656,11 @@
656 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
657 ** [sqlite_version()] and [sqlite_source_id()].
658 */
659 #define SQLITE_VERSION "3.8.0"
660 #define SQLITE_VERSION_NUMBER 3008000
661 #define SQLITE_SOURCE_ID "2013-07-31 23:28:36 136fc2931b156f91cdd76a7a009298cdf09d826a"
662
663 /*
664 ** CAPI3REF: Run-Time Library Version Numbers
665 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
666 **
@@ -1039,10 +1025,11 @@
1025 #define SQLITE_IOERR_SHMLOCK (SQLITE_IOERR | (20<<8))
1026 #define SQLITE_IOERR_SHMMAP (SQLITE_IOERR | (21<<8))
1027 #define SQLITE_IOERR_SEEK (SQLITE_IOERR | (22<<8))
1028 #define SQLITE_IOERR_DELETE_NOENT (SQLITE_IOERR | (23<<8))
1029 #define SQLITE_IOERR_MMAP (SQLITE_IOERR | (24<<8))
1030 #define SQLITE_IOERR_GETTEMPPATH (SQLITE_IOERR | (25<<8))
1031 #define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8))
1032 #define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8))
1033 #define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8))
1034 #define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8))
1035 #define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8))
@@ -28374,30 +28361,27 @@
28361 */
28362 static const char *unixTempFileDir(void){
28363 static const char *azDirs[] = {
28364 0,
28365 0,
 
28366 0,
28367 0,
 
28368 "/var/tmp",
28369 "/usr/tmp",
28370 "/tmp",
28371 "."
28372 };
28373 unsigned int i;
28374 struct stat buf;
28375 const char *zDir;
28376
28377 azDirs[0] = sqlite3_temp_directory;
28378 if( !azDirs[1] ) azDirs[1] = getenv("TMPDIR");
 
28379 if( !azDirs[2] ) azDirs[2] = getenv("TMP");
28380 if( !azDirs[3] ) azDirs[3] = getenv("TEMP");
28381 for(i=0; i<sizeof(azDirs)/sizeof(azDirs[0]); i++){
28382 zDir = azDirs[i];
28383 if( zDir==0 ) continue;
28384 if( osStat(zDir, &buf) ) continue;
28385 if( !S_ISDIR(buf.st_mode) ) continue;
28386 if( osAccess(zDir, 07) ) continue;
28387 break;
@@ -28423,11 +28407,10 @@
28407 ** function failing.
28408 */
28409 SimulateIOError( return SQLITE_IOERR );
28410
28411 zDir = unixTempFileDir();
 
28412
28413 /* Check that the output buffer is large enough for the temporary file
28414 ** name. If it is not, return SQLITE_ERROR.
28415 */
28416 if( (strlen(zDir) + strlen(SQLITE_TEMP_FILE_PREFIX) + 18) >= (size_t)nBuf ){
@@ -30505,10 +30488,11 @@
30488 */
30489 #if SQLITE_OS_WIN /* This file is used for Windows only */
30490
30491 #ifdef __CYGWIN__
30492 # include <sys/cygwin.h>
30493 /* # include <errno.h> */
30494 #endif
30495
30496 /*
30497 ** Include code that is common to all os_*.c files
30498 */
@@ -30925,10 +30909,11 @@
30909 * zero for the default behavior.
30910 */
30911 #ifndef SQLITE_WIN32_HEAP_FLAGS
30912 # define SQLITE_WIN32_HEAP_FLAGS (0)
30913 #endif
30914
30915
30916 /*
30917 ** The winMemData structure stores information required by the Win32-specific
30918 ** sqlite3_mem_methods implementation.
30919 */
@@ -34390,14 +34375,14 @@
34375 OSTRACE(("MAP-FILE-CREATE pid=%lu, pFile=%p, rc=SQLITE_IOERR_MMAP\n",
34376 osGetCurrentProcessId(), pFd));
34377 return SQLITE_OK;
34378 }
34379 assert( (nMap % winSysInfo.dwPageSize)==0 );
 
 
 
34380 assert( sizeof(SIZE_T)==sizeof(sqlite3_int64) || nMap<=0xffffffff );
34381 #if SQLITE_OS_WINRT
34382 pNew = osMapViewOfFileFromApp(pFd->hMap, flags, 0, (SIZE_T)nMap);
34383 #else
34384 pNew = osMapViewOfFile(pFd->hMap, flags, 0, 0, (SIZE_T)nMap);
34385 #endif
34386 if( pNew==NULL ){
34387 osCloseHandle(pFd->hMap);
34388 pFd->hMap = NULL;
@@ -34564,10 +34549,19 @@
34549 return zConverted;
34550 }
34551
34552 static int winIsDir(const void *zConverted);
34553
34554 /*
34555 ** Maximum pathname length (in bytes) for windows. The MAX_PATH macro is
34556 ** in characters, so we allocate 3 bytes per character assuming worst-case
34557 ** 3-bytes-per-character UTF8.
34558 */
34559 #ifndef SQLITE_WIN32_MAX_PATH
34560 # define SQLITE_WIN32_MAX_PATH (MAX_PATH*3)
34561 #endif
34562
34563 /*
34564 ** Create a temporary file name in zBuf. zBuf must be big enough to
34565 ** hold at pVfs->mxPathname characters.
34566 */
34567 static int getTempname(int nBuf, char *zBuf){
@@ -34575,95 +34569,115 @@
34569 "abcdefghijklmnopqrstuvwxyz"
34570 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
34571 "0123456789";
34572 size_t i, j;
34573 int nTempPath;
34574 char zTempPath[SQLITE_WIN32_MAX_PATH+2];
34575
34576 /* It's odd to simulate an io-error here, but really this is just
34577 ** using the io-error infrastructure to test that SQLite handles this
34578 ** function failing.
34579 */
34580 SimulateIOError( return SQLITE_IOERR );
34581
 
 
34582 if( sqlite3_temp_directory ){
34583 sqlite3_snprintf(SQLITE_WIN32_MAX_PATH-30, zTempPath, "%s",
34584 sqlite3_temp_directory);
34585 }
34586 #if defined(__CYGWIN__)
34587 else{
34588 static const char *azDirs[] = {
34589 0,
34590 0,
34591 0,
34592 0,
34593 "/var/tmp",
34594 "/usr/tmp",
34595 "/tmp",
34596 "."
34597 };
34598 const char *zDir;
34599 WCHAR zWidePath[MAX_PATH];
34600
34601 if( !azDirs[0] ) azDirs[0] = getenv("TMPDIR");
34602 if( !azDirs[1] ) azDirs[1] = getenv("TMP");
34603 if( !azDirs[2] ) azDirs[2] = getenv("TEMP");
34604 if( !azDirs[3] ) azDirs[3] = getenv("USERPROFILE");
34605 for(i=0; i<sizeof(azDirs)/sizeof(azDirs[0]); i++){
34606 zDir = azDirs[i];
34607 if( zDir==0 || zDir[0]==0 ) continue;
34608 if( zDir[1]!=':' ){
34609 cygwin_conv_path(CCP_POSIX_TO_WIN_W, zDir, zWidePath, MAX_PATH);
34610 zDir = azDirs[i] = unicodeToUtf8(zWidePath);
34611 if( zDir==0 ){
34612 OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
34613 return SQLITE_IOERR_NOMEM;
34614 }
34615 }else{
34616 /* Convert the filename to the system encoding. */
34617 osMultiByteToWideChar(CP_UTF8, 0, zDir, -1, zWidePath,
34618 MAX_PATH);
34619 }
34620 if( winIsDir(zWidePath) ){
34621 break;
34622 }
34623 azDirs[i] = ""; /* Don't retry in future call */
34624 }
34625 sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", zDir);
34626 }
 
34627 #elif !SQLITE_OS_WINRT
34628 else if( isNT() ){
34629 char *zMulti;
34630 WCHAR zWidePath[MAX_PATH];
34631 if( osGetTempPathW(MAX_PATH-30, zWidePath)==0 ){
34632 OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_GETTEMPPATH\n"));
34633 return SQLITE_IOERR_GETTEMPPATH;
34634 }
34635 zMulti = unicodeToUtf8(zWidePath);
34636 if( zMulti ){
34637 sqlite3_snprintf(SQLITE_WIN32_MAX_PATH-30, zTempPath, "%s", zMulti);
34638 sqlite3_free(zMulti);
34639 }else{
34640 OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
34641 return SQLITE_IOERR_NOMEM;
34642 }
34643 }
34644 #ifdef SQLITE_WIN32_HAS_ANSI
34645 else{
34646 char *zUtf8;
34647 char zMbcsPath[SQLITE_WIN32_MAX_PATH];
34648 if( osGetTempPathA(SQLITE_WIN32_MAX_PATH-30, zMbcsPath)==0 ){
34649 OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_GETTEMPPATH\n"));
34650 return SQLITE_IOERR_GETTEMPPATH;
34651 }
34652 zUtf8 = sqlite3_win32_mbcs_to_utf8(zMbcsPath);
34653 if( zUtf8 ){
34654 sqlite3_snprintf(SQLITE_WIN32_MAX_PATH-30, zTempPath, "%s", zUtf8);
34655 sqlite3_free(zUtf8);
34656 }else{
34657 OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
34658 return SQLITE_IOERR_NOMEM;
34659 }
34660 }
34661 #else
34662 else{
34663 /*
34664 ** Compiled without ANSI support and the current operating system
34665 ** is not Windows NT; therefore, just zero the temporary buffer.
34666 */
34667 memset(zTempPath, 0, SQLITE_WIN32_MAX_PATH+2);
34668 }
34669 #endif /* SQLITE_WIN32_HAS_ANSI */
34670 #else
34671 else{
34672 /*
34673 ** Compiled for WinRT and the sqlite3_temp_directory is not set;
34674 ** therefore, just zero the temporary buffer.
34675 */
34676 memset(zTempPath, 0, SQLITE_WIN32_MAX_PATH+2);
34677 }
34678 #endif /* !SQLITE_OS_WINRT */
34679
34680 /* Check that the output buffer is large enough for the temporary file
34681 ** name. If it is not, return SQLITE_ERROR.
34682 */
34683 nTempPath = sqlite3Strlen30(zTempPath);
@@ -34745,11 +34759,11 @@
34759 int cnt = 0;
34760
34761 /* If argument zPath is a NULL pointer, this function is required to open
34762 ** a temporary file. Use this buffer to store the file name in.
34763 */
34764 char zTmpname[SQLITE_WIN32_MAX_PATH+2]; /* Buffer used to create temp filename */
34765
34766 int rc = SQLITE_OK; /* Function Return Code */
34767 #if !defined(NDEBUG) || SQLITE_OS_WINCE
34768 int eType = flags&0xFFFFFF00; /* Type of file to open */
34769 #endif
@@ -34811,12 +34825,11 @@
34825 /* If the second argument to this function is NULL, generate a
34826 ** temporary file name to use
34827 */
34828 if( !zUtf8Name ){
34829 assert(isDelete && !isOpenJournal);
34830 rc = getTempname(SQLITE_WIN32_MAX_PATH+2, zTmpname);
 
34831 if( rc!=SQLITE_OK ){
34832 OSTRACE(("OPEN name=%s, rc=%s", zUtf8Name, sqlite3ErrName(rc)));
34833 return rc;
34834 }
34835 zUtf8Name = zTmpname;
@@ -35243,27 +35256,34 @@
35256 ){
35257
35258 #if defined(__CYGWIN__)
35259 SimulateIOError( return SQLITE_ERROR );
35260 UNUSED_PARAMETER(nFull);
35261 assert( pVfs->mxPathname>=SQLITE_WIN32_MAX_PATH );
35262 assert( nFull>=pVfs->mxPathname );
35263 if ( sqlite3_data_directory && !winIsVerbatimPathname(zRelative) ){
35264 /*
35265 ** NOTE: We are dealing with a relative path name and the data
35266 ** directory has been set. Therefore, use it as the basis
35267 ** for converting the relative path name to an absolute
35268 ** one by prepending the data directory and a slash.
35269 */
35270 char zOut[SQLITE_WIN32_MAX_PATH+1];
35271 if( cygwin_conv_path(CCP_POSIX_TO_WIN_A|CCP_RELATIVE, zRelative, zOut,
35272 SQLITE_WIN32_MAX_PATH+1)<0 ){
35273 winLogError(SQLITE_CANTOPEN_FULLPATH, (DWORD)errno, "cygwin_conv_path",
35274 zRelative);
35275 return SQLITE_CANTOPEN_FULLPATH;
35276 }
35277 sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s\\%s",
35278 sqlite3_data_directory, zOut);
35279 }else{
35280 if( cygwin_conv_path(CCP_POSIX_TO_WIN_A, zRelative, zFull, nFull)<0 ){
35281 winLogError(SQLITE_CANTOPEN_FULLPATH, (DWORD)errno, "cygwin_conv_path",
35282 zRelative);
35283 return SQLITE_CANTOPEN_FULLPATH;
35284 }
35285 }
35286 return SQLITE_OK;
35287 #endif
35288
35289 #if (SQLITE_OS_WINCE || SQLITE_OS_WINRT) && !defined(__CYGWIN__)
@@ -35601,11 +35621,11 @@
35621 */
35622 SQLITE_API int sqlite3_os_init(void){
35623 static sqlite3_vfs winVfs = {
35624 3, /* iVersion */
35625 sizeof(winFile), /* szOsFile */
35626 SQLITE_WIN32_MAX_PATH, /* mxPathname */
35627 0, /* pNext */
35628 "win32", /* zName */
35629 0, /* pAppData */
35630 winOpen, /* xOpen */
35631 winDelete, /* xDelete */
@@ -107770,10 +107790,11 @@
107790 WhereLevel *pLevel; /* The where level to be coded */
107791 WhereLoop *pLoop; /* The WhereLoop object being coded */
107792 WhereClause *pWC; /* Decomposition of the entire WHERE clause */
107793 WhereTerm *pTerm; /* A WHERE clause term */
107794 Parse *pParse; /* Parsing context */
107795 sqlite3 *db; /* Database connection */
107796 Vdbe *v; /* The prepared stmt under constructions */
107797 struct SrcList_item *pTabItem; /* FROM clause term being coded */
107798 int addrBrk; /* Jump here to break out of the loop */
107799 int addrCont; /* Jump here to continue with next cycle */
107800 int iRowidReg = 0; /* Rowid is stored in this register, if not zero */
@@ -107781,10 +107802,11 @@
107802 Bitmask newNotReady; /* Return value */
107803
107804 pParse = pWInfo->pParse;
107805 v = pParse->pVdbe;
107806 pWC = &pWInfo->sWC;
107807 db = pParse->db;
107808 pLevel = &pWInfo->a[iLevel];
107809 pLoop = pLevel->pWLoop;
107810 pTabItem = &pWInfo->pTabList->a[pLevel->iFrom];
107811 iCur = pTabItem->iCursor;
107812 bRev = (pWInfo->revMask>>iLevel)&1;
@@ -108071,11 +108093,11 @@
108093 /* Generate code to evaluate all constraint terms using == or IN
108094 ** and store the values of those terms in an array of registers
108095 ** starting at regBase.
108096 */
108097 regBase = codeAllEqualityTerms(pParse,pLevel,bRev,nExtraReg,&zStartAff);
108098 zEndAff = sqlite3DbStrDup(db, zStartAff);
108099 addrNxt = pLevel->addrNxt;
108100
108101 /* If we are doing a reverse order scan on an ascending index, or
108102 ** a forward order scan on a descending index, interchange the
108103 ** start and end terms (pRangeStart and pRangeEnd).
@@ -108156,12 +108178,12 @@
108178 }
108179 codeApplyAffinity(pParse, regBase, nEq+1, zEndAff);
108180 nConstraint++;
108181 testcase( pRangeEnd->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */
108182 }
108183 sqlite3DbFree(db, zStartAff);
108184 sqlite3DbFree(db, zEndAff);
108185
108186 /* Top of the loop body */
108187 pLevel->p2 = sqlite3VdbeCurrentAddr(v);
108188
108189 /* Check if the index cursor is past the end of the range. */
@@ -108284,11 +108306,11 @@
108306 */
108307 if( pWInfo->nLevel>1 ){
108308 int nNotReady; /* The number of notReady tables */
108309 struct SrcList_item *origSrc; /* Original list of tables */
108310 nNotReady = pWInfo->nLevel - iLevel - 1;
108311 pOrTab = sqlite3StackAllocRaw(db,
108312 sizeof(*pOrTab)+ nNotReady*sizeof(pOrTab->a[0]));
108313 if( pOrTab==0 ) return notReady;
108314 pOrTab->nAlloc = (u8)(nNotReady + 1);
108315 pOrTab->nSrc = pOrTab->nAlloc;
108316 memcpy(pOrTab->a, pTabItem, sizeof(*pTabItem));
@@ -108338,12 +108360,12 @@
108360 Expr *pExpr = pWC->a[iTerm].pExpr;
108361 if( &pWC->a[iTerm] == pTerm ) continue;
108362 if( ExprHasProperty(pExpr, EP_FromJoin) ) continue;
108363 if( pWC->a[iTerm].wtFlags & (TERM_ORINFO) ) continue;
108364 if( (pWC->a[iTerm].eOperator & WO_ALL)==0 ) continue;
108365 pExpr = sqlite3ExprDup(db, pExpr, 0);
108366 pAndExpr = sqlite3ExprAnd(db, pAndExpr, pExpr);
108367 }
108368 if( pAndExpr ){
108369 pAndExpr = sqlite3PExpr(pParse, TK_AND, 0, pAndExpr, 0);
108370 }
108371 }
@@ -108359,11 +108381,11 @@
108381 }
108382 /* Loop through table entries that match term pOrTerm. */
108383 pSubWInfo = sqlite3WhereBegin(pParse, pOrTab, pOrExpr, 0, 0,
108384 WHERE_OMIT_OPEN_CLOSE | WHERE_AND_ONLY |
108385 WHERE_FORCE_TABLE | WHERE_ONETABLE_ONLY, iCovCur);
108386 assert( pSubWInfo || pParse->nErr || db->mallocFailed );
108387 if( pSubWInfo ){
108388 WhereLoop *pSubLoop;
108389 explainOneScan(
108390 pParse, pOrTab, &pSubWInfo->a[0], iLevel, pLevel->iFrom, 0
108391 );
@@ -108414,17 +108436,17 @@
108436 }
108437 pLevel->u.pCovidx = pCov;
108438 if( pCov ) pLevel->iIdxCur = iCovCur;
108439 if( pAndExpr ){
108440 pAndExpr->pLeft = 0;
108441 sqlite3ExprDelete(db, pAndExpr);
108442 }
108443 sqlite3VdbeChangeP1(v, iRetInit, sqlite3VdbeCurrentAddr(v));
108444 sqlite3VdbeAddOp2(v, OP_Goto, 0, pLevel->addrBrk);
108445 sqlite3VdbeResolveLabel(v, iLoopBody);
108446
108447 if( pWInfo->nLevel>1 ) sqlite3StackFree(db, pOrTab);
108448 if( !untestedTerms ) disableTerm(pLevel, pTerm);
108449 }else
108450 #endif /* SQLITE_OMIT_OR_OPTIMIZATION */
108451
108452 {
@@ -108475,13 +108497,12 @@
108497 ** and we are coding the t1 loop and the t2 loop has not yet coded,
108498 ** then we cannot use the "t1.a=t2.b" constraint, but we can code
108499 ** the implied "t1.a=123" constraint.
108500 */
108501 for(pTerm=pWC->a, j=pWC->nTerm; j>0; j--, pTerm++){
108502 Expr *pE, *pEAlt;
108503 WhereTerm *pAlt;
 
108504 if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
108505 if( pTerm->eOperator!=(WO_EQUIV|WO_EQ) ) continue;
108506 if( pTerm->leftCursor!=iCur ) continue;
108507 if( pLevel->iLeftJoin ) continue;
108508 pE = pTerm->pExpr;
@@ -108491,13 +108512,17 @@
108512 if( pAlt==0 ) continue;
108513 if( pAlt->wtFlags & (TERM_CODED) ) continue;
108514 testcase( pAlt->eOperator & WO_EQ );
108515 testcase( pAlt->eOperator & WO_IN );
108516 VdbeNoopComment((v, "begin transitive constraint"));
108517 pEAlt = sqlite3StackAllocRaw(db, sizeof(*pEAlt));
108518 if( pEAlt ){
108519 *pEAlt = *pAlt->pExpr;
108520 pEAlt->pLeft = pE->pLeft;
108521 sqlite3ExprIfFalse(pParse, pEAlt, addrCont, SQLITE_JUMPIFNULL);
108522 sqlite3StackFree(db, pEAlt);
108523 }
108524 }
108525
108526 /* For a LEFT OUTER JOIN, generate code that will record the fact that
108527 ** at least one row of the right table has matched the left table.
108528 */
@@ -116436,10 +116461,11 @@
116461 case SQLITE_IOERR_SHMLOCK: zName = "SQLITE_IOERR_SHMLOCK"; break;
116462 case SQLITE_IOERR_SHMMAP: zName = "SQLITE_IOERR_SHMMAP"; break;
116463 case SQLITE_IOERR_SEEK: zName = "SQLITE_IOERR_SEEK"; break;
116464 case SQLITE_IOERR_DELETE_NOENT: zName = "SQLITE_IOERR_DELETE_NOENT";break;
116465 case SQLITE_IOERR_MMAP: zName = "SQLITE_IOERR_MMAP"; break;
116466 case SQLITE_IOERR_GETTEMPPATH: zName = "SQLITE_IOERR_GETTEMPPATH"; break;
116467 case SQLITE_CORRUPT: zName = "SQLITE_CORRUPT"; break;
116468 case SQLITE_CORRUPT_VTAB: zName = "SQLITE_CORRUPT_VTAB"; break;
116469 case SQLITE_NOTFOUND: zName = "SQLITE_NOTFOUND"; break;
116470 case SQLITE_FULL: zName = "SQLITE_FULL"; break;
116471 case SQLITE_CANTOPEN: zName = "SQLITE_CANTOPEN"; break;
@@ -128264,11 +128290,11 @@
128290 }
128291
128292
128293 #ifdef SQLITE_TEST
128294
128295 #include <tcl.h>
128296 /* #include <string.h> */
128297
128298 /*
128299 ** Implementation of a special SQL scalar function for testing tokenizers
128300 ** designed to be used in concert with the Tcl testing framework. This
128301
+137 -111
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -399,13 +399,10 @@
399399
** On Windows, if the SQLITE_WIN32_MALLOC_VALIDATE macro is defined and the
400400
** assert() macro is enabled, each call into the Win32 native heap subsystem
401401
** will cause HeapValidate to be called. If heap validation should fail, an
402402
** assertion will be triggered.
403403
**
404
-** (Historical note: There used to be several other options, but we've
405
-** pared it down to just these three.)
406
-**
407404
** If none of the above are defined, then set SQLITE_SYSTEM_MALLOC as
408405
** the default.
409406
*/
410407
#if defined(SQLITE_SYSTEM_MALLOC) \
411408
+ defined(SQLITE_WIN32_MALLOC) \
@@ -439,24 +436,17 @@
439436
*/
440437
#if !defined(_XOPEN_SOURCE) && !defined(__DARWIN__) && !defined(__APPLE__)
441438
# define _XOPEN_SOURCE 600
442439
#endif
443440
444
-/*
445
-** The TCL headers are only needed when compiling the TCL bindings.
446
-*/
447
-#if defined(SQLITE_TCL) || defined(TCLSH)
448
-# include <tcl.h>
449
-#endif
450
-
451441
/*
452442
** NDEBUG and SQLITE_DEBUG are opposites. It should always be true that
453443
** defined(NDEBUG)==!defined(SQLITE_DEBUG). If this is not currently true,
454444
** make it true by defining or undefining NDEBUG.
455445
**
456
-** Setting NDEBUG makes the code smaller and run faster by disabling the
457
-** number assert() statements in the code. So we want the default action
446
+** Setting NDEBUG makes the code smaller and faster by disabling the
447
+** assert() statements in the code. So we want the default action
458448
** to be for NDEBUG to be set and NDEBUG to be undefined only if SQLITE_DEBUG
459449
** is set. Thus NDEBUG becomes an opt-in rather than an opt-out
460450
** feature.
461451
*/
462452
#if !defined(NDEBUG) && !defined(SQLITE_DEBUG)
@@ -522,11 +512,11 @@
522512
** hint of unplanned behavior.
523513
**
524514
** In other words, ALWAYS and NEVER are added for defensive code.
525515
**
526516
** When doing coverage testing ALWAYS and NEVER are hard-coded to
527
-** be true and false so that the unreachable code then specify will
517
+** be true and false so that the unreachable code they specify will
528518
** not be counted as untested code.
529519
*/
530520
#if defined(SQLITE_COVERAGE_TEST)
531521
# define ALWAYS(X) (1)
532522
# define NEVER(X) (0)
@@ -546,20 +536,16 @@
546536
#define IS_BIG_INT(X) (((X)&~(i64)0xffffffff)!=0)
547537
548538
/*
549539
** The macro unlikely() is a hint that surrounds a boolean
550540
** expression that is usually false. Macro likely() surrounds
551
-** a boolean expression that is usually true. GCC is able to
552
-** use these hints to generate better code, sometimes.
541
+** a boolean expression that is usually true. These hints could,
542
+** in theory, be used by the compiler to generate better code, but
543
+** currently they are just comments for human readers.
553544
*/
554
-#if defined(__GNUC__) && 0
555
-# define likely(X) __builtin_expect((X),1)
556
-# define unlikely(X) __builtin_expect((X),0)
557
-#else
558
-# define likely(X) !!(X)
559
-# define unlikely(X) !!(X)
560
-#endif
545
+#define likely(X) (X)
546
+#define unlikely(X) (X)
561547
562548
/************** Include sqlite3.h in the middle of sqliteInt.h ***************/
563549
/************** Begin file sqlite3.h *****************************************/
564550
/*
565551
** 2001 September 15
@@ -670,11 +656,11 @@
670656
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
671657
** [sqlite_version()] and [sqlite_source_id()].
672658
*/
673659
#define SQLITE_VERSION "3.8.0"
674660
#define SQLITE_VERSION_NUMBER 3008000
675
-#define SQLITE_SOURCE_ID "2013-07-25 17:07:03 8bcbb33fd0a970e16a920e1d35571836dbb9ba50"
661
+#define SQLITE_SOURCE_ID "2013-07-31 23:28:36 136fc2931b156f91cdd76a7a009298cdf09d826a"
676662
677663
/*
678664
** CAPI3REF: Run-Time Library Version Numbers
679665
** KEYWORDS: sqlite3_version, sqlite3_sourceid
680666
**
@@ -1039,10 +1025,11 @@
10391025
#define SQLITE_IOERR_SHMLOCK (SQLITE_IOERR | (20<<8))
10401026
#define SQLITE_IOERR_SHMMAP (SQLITE_IOERR | (21<<8))
10411027
#define SQLITE_IOERR_SEEK (SQLITE_IOERR | (22<<8))
10421028
#define SQLITE_IOERR_DELETE_NOENT (SQLITE_IOERR | (23<<8))
10431029
#define SQLITE_IOERR_MMAP (SQLITE_IOERR | (24<<8))
1030
+#define SQLITE_IOERR_GETTEMPPATH (SQLITE_IOERR | (25<<8))
10441031
#define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8))
10451032
#define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8))
10461033
#define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8))
10471034
#define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8))
10481035
#define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8))
@@ -28374,30 +28361,27 @@
2837428361
*/
2837528362
static const char *unixTempFileDir(void){
2837628363
static const char *azDirs[] = {
2837728364
0,
2837828365
0,
28379
-#ifdef __CYGWIN__
2838028366
0,
2838128367
0,
28382
-#endif
2838328368
"/var/tmp",
2838428369
"/usr/tmp",
2838528370
"/tmp",
28386
- 0 /* List terminator */
28371
+ "."
2838728372
};
2838828373
unsigned int i;
2838928374
struct stat buf;
28390
- const char *zDir = 0;
28375
+ const char *zDir;
2839128376
2839228377
azDirs[0] = sqlite3_temp_directory;
2839328378
if( !azDirs[1] ) azDirs[1] = getenv("TMPDIR");
28394
-#ifdef __CYGWIN__
2839528379
if( !azDirs[2] ) azDirs[2] = getenv("TMP");
2839628380
if( !azDirs[3] ) azDirs[3] = getenv("TEMP");
28397
-#endif
28398
- for(i=0; i<sizeof(azDirs)/sizeof(azDirs[0]); zDir=azDirs[i++]){
28381
+ for(i=0; i<sizeof(azDirs)/sizeof(azDirs[0]); i++){
28382
+ zDir = azDirs[i];
2839928383
if( zDir==0 ) continue;
2840028384
if( osStat(zDir, &buf) ) continue;
2840128385
if( !S_ISDIR(buf.st_mode) ) continue;
2840228386
if( osAccess(zDir, 07) ) continue;
2840328387
break;
@@ -28423,11 +28407,10 @@
2842328407
** function failing.
2842428408
*/
2842528409
SimulateIOError( return SQLITE_IOERR );
2842628410
2842728411
zDir = unixTempFileDir();
28428
- if( zDir==0 ) zDir = ".";
2842928412
2843028413
/* Check that the output buffer is large enough for the temporary file
2843128414
** name. If it is not, return SQLITE_ERROR.
2843228415
*/
2843328416
if( (strlen(zDir) + strlen(SQLITE_TEMP_FILE_PREFIX) + 18) >= (size_t)nBuf ){
@@ -30505,10 +30488,11 @@
3050530488
*/
3050630489
#if SQLITE_OS_WIN /* This file is used for Windows only */
3050730490
3050830491
#ifdef __CYGWIN__
3050930492
# include <sys/cygwin.h>
30493
+/* # include <errno.h> */
3051030494
#endif
3051130495
3051230496
/*
3051330497
** Include code that is common to all os_*.c files
3051430498
*/
@@ -30925,10 +30909,11 @@
3092530909
* zero for the default behavior.
3092630910
*/
3092730911
#ifndef SQLITE_WIN32_HEAP_FLAGS
3092830912
# define SQLITE_WIN32_HEAP_FLAGS (0)
3092930913
#endif
30914
+
3093030915
3093130916
/*
3093230917
** The winMemData structure stores information required by the Win32-specific
3093330918
** sqlite3_mem_methods implementation.
3093430919
*/
@@ -34390,14 +34375,14 @@
3439034375
OSTRACE(("MAP-FILE-CREATE pid=%lu, pFile=%p, rc=SQLITE_IOERR_MMAP\n",
3439134376
osGetCurrentProcessId(), pFd));
3439234377
return SQLITE_OK;
3439334378
}
3439434379
assert( (nMap % winSysInfo.dwPageSize)==0 );
34395
-#if SQLITE_OS_WINRT
34396
- pNew = osMapViewOfFileFromApp(pFd->hMap, flags, 0, nMap);
34397
-#else
3439834380
assert( sizeof(SIZE_T)==sizeof(sqlite3_int64) || nMap<=0xffffffff );
34381
+#if SQLITE_OS_WINRT
34382
+ pNew = osMapViewOfFileFromApp(pFd->hMap, flags, 0, (SIZE_T)nMap);
34383
+#else
3439934384
pNew = osMapViewOfFile(pFd->hMap, flags, 0, 0, (SIZE_T)nMap);
3440034385
#endif
3440134386
if( pNew==NULL ){
3440234387
osCloseHandle(pFd->hMap);
3440334388
pFd->hMap = NULL;
@@ -34564,10 +34549,19 @@
3456434549
return zConverted;
3456534550
}
3456634551
3456734552
static int winIsDir(const void *zConverted);
3456834553
34554
+/*
34555
+** Maximum pathname length (in bytes) for windows. The MAX_PATH macro is
34556
+** in characters, so we allocate 3 bytes per character assuming worst-case
34557
+** 3-bytes-per-character UTF8.
34558
+*/
34559
+#ifndef SQLITE_WIN32_MAX_PATH
34560
+# define SQLITE_WIN32_MAX_PATH (MAX_PATH*3)
34561
+#endif
34562
+
3456934563
/*
3457034564
** Create a temporary file name in zBuf. zBuf must be big enough to
3457134565
** hold at pVfs->mxPathname characters.
3457234566
*/
3457334567
static int getTempname(int nBuf, char *zBuf){
@@ -34575,95 +34569,115 @@
3457534569
"abcdefghijklmnopqrstuvwxyz"
3457634570
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
3457734571
"0123456789";
3457834572
size_t i, j;
3457934573
int nTempPath;
34580
- char zTempPath[MAX_PATH+2];
34574
+ char zTempPath[SQLITE_WIN32_MAX_PATH+2];
3458134575
3458234576
/* It's odd to simulate an io-error here, but really this is just
3458334577
** using the io-error infrastructure to test that SQLite handles this
3458434578
** function failing.
3458534579
*/
3458634580
SimulateIOError( return SQLITE_IOERR );
3458734581
34588
- memset(zTempPath, 0, MAX_PATH+2);
34589
-
3459034582
if( sqlite3_temp_directory ){
34591
- sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", sqlite3_temp_directory);
34583
+ sqlite3_snprintf(SQLITE_WIN32_MAX_PATH-30, zTempPath, "%s",
34584
+ sqlite3_temp_directory);
3459234585
}
3459334586
#if defined(__CYGWIN__)
34594
- static const char *azDirs[] = {
34595
- 0,
34596
- 0,
34597
- 0,
34598
- 0,
34599
- "/var/tmp",
34600
- "/usr/tmp",
34601
- "/tmp",
34602
- 0
34603
- };
34604
- const char *zDir = 0;
34605
- char *zConverted;
34606
-
34607
- azDirs[0] = sqlite3_temp_directory;
34608
- if( !azDirs[1] ) azDirs[1] = getenv("TMPDIR");
34609
- if( !azDirs[2] ) azDirs[2] = getenv("TMP");
34610
- if( !azDirs[3] ) azDirs[3] = getenv("TEMP");
34611
- for(i=0; i<sizeof(azDirs)/sizeof(azDirs[0]); zDir=azDirs[i++]){
34612
- if( zDir==0 || zDir[0]) continue;
34613
- if( zDir[1]!=':' ){
34614
- WCHAR zWidePath[MAX_PATH];
34615
- cygwin_conv_path(CCP_POSIX_TO_WIN_W, zDir, zWidePath, MAX_PATH);
34616
- zDir = unicodeToUtf8(zWidePath);
34617
- if( zDir==0 ){
34618
- OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
34619
- return SQLITE_IOERR_NOMEM;
34620
- }
34621
- }
34622
- /* Convert the filename to the system encoding. */
34623
- zConverted = convertUtf8Filename(zDir);
34624
- if( zConverted==0 ){
34625
- OSTRACE(("TEMP-FILENAME, rc=SQLITE_IOERR_NOMEM"));
34626
- return SQLITE_IOERR_NOMEM;
34627
- }
34628
- if( winIsDir(zConverted) ){
34629
- sqlite3_free(zConverted);
34630
- break;
34631
- }
34632
- sqlite3_free(zConverted);
34633
- }
34634
- sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", zDir);
34587
+ else{
34588
+ static const char *azDirs[] = {
34589
+ 0,
34590
+ 0,
34591
+ 0,
34592
+ 0,
34593
+ "/var/tmp",
34594
+ "/usr/tmp",
34595
+ "/tmp",
34596
+ "."
34597
+ };
34598
+ const char *zDir;
34599
+ WCHAR zWidePath[MAX_PATH];
34600
+
34601
+ if( !azDirs[0] ) azDirs[0] = getenv("TMPDIR");
34602
+ if( !azDirs[1] ) azDirs[1] = getenv("TMP");
34603
+ if( !azDirs[2] ) azDirs[2] = getenv("TEMP");
34604
+ if( !azDirs[3] ) azDirs[3] = getenv("USERPROFILE");
34605
+ for(i=0; i<sizeof(azDirs)/sizeof(azDirs[0]); i++){
34606
+ zDir = azDirs[i];
34607
+ if( zDir==0 || zDir[0]==0 ) continue;
34608
+ if( zDir[1]!=':' ){
34609
+ cygwin_conv_path(CCP_POSIX_TO_WIN_W, zDir, zWidePath, MAX_PATH);
34610
+ zDir = azDirs[i] = unicodeToUtf8(zWidePath);
34611
+ if( zDir==0 ){
34612
+ OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
34613
+ return SQLITE_IOERR_NOMEM;
34614
+ }
34615
+ }else{
34616
+ /* Convert the filename to the system encoding. */
34617
+ osMultiByteToWideChar(CP_UTF8, 0, zDir, -1, zWidePath,
34618
+ MAX_PATH);
34619
+ }
34620
+ if( winIsDir(zWidePath) ){
34621
+ break;
34622
+ }
34623
+ azDirs[i] = ""; /* Don't retry in future call */
34624
+ }
34625
+ sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", zDir);
34626
+ }
3463534627
#elif !SQLITE_OS_WINRT
3463634628
else if( isNT() ){
3463734629
char *zMulti;
3463834630
WCHAR zWidePath[MAX_PATH];
34639
- osGetTempPathW(MAX_PATH-30, zWidePath);
34631
+ if( osGetTempPathW(MAX_PATH-30, zWidePath)==0 ){
34632
+ OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_GETTEMPPATH\n"));
34633
+ return SQLITE_IOERR_GETTEMPPATH;
34634
+ }
3464034635
zMulti = unicodeToUtf8(zWidePath);
3464134636
if( zMulti ){
34642
- sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", zMulti);
34637
+ sqlite3_snprintf(SQLITE_WIN32_MAX_PATH-30, zTempPath, "%s", zMulti);
3464334638
sqlite3_free(zMulti);
3464434639
}else{
3464534640
OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
3464634641
return SQLITE_IOERR_NOMEM;
3464734642
}
3464834643
}
3464934644
#ifdef SQLITE_WIN32_HAS_ANSI
3465034645
else{
3465134646
char *zUtf8;
34652
- char zMbcsPath[MAX_PATH];
34653
- osGetTempPathA(MAX_PATH-30, zMbcsPath);
34647
+ char zMbcsPath[SQLITE_WIN32_MAX_PATH];
34648
+ if( osGetTempPathA(SQLITE_WIN32_MAX_PATH-30, zMbcsPath)==0 ){
34649
+ OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_GETTEMPPATH\n"));
34650
+ return SQLITE_IOERR_GETTEMPPATH;
34651
+ }
3465434652
zUtf8 = sqlite3_win32_mbcs_to_utf8(zMbcsPath);
3465534653
if( zUtf8 ){
34656
- sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", zUtf8);
34654
+ sqlite3_snprintf(SQLITE_WIN32_MAX_PATH-30, zTempPath, "%s", zUtf8);
3465734655
sqlite3_free(zUtf8);
3465834656
}else{
3465934657
OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
3466034658
return SQLITE_IOERR_NOMEM;
3466134659
}
3466234660
}
34663
-#endif
34664
-#endif
34661
+#else
34662
+ else{
34663
+ /*
34664
+ ** Compiled without ANSI support and the current operating system
34665
+ ** is not Windows NT; therefore, just zero the temporary buffer.
34666
+ */
34667
+ memset(zTempPath, 0, SQLITE_WIN32_MAX_PATH+2);
34668
+ }
34669
+#endif /* SQLITE_WIN32_HAS_ANSI */
34670
+#else
34671
+ else{
34672
+ /*
34673
+ ** Compiled for WinRT and the sqlite3_temp_directory is not set;
34674
+ ** therefore, just zero the temporary buffer.
34675
+ */
34676
+ memset(zTempPath, 0, SQLITE_WIN32_MAX_PATH+2);
34677
+ }
34678
+#endif /* !SQLITE_OS_WINRT */
3466534679
3466634680
/* Check that the output buffer is large enough for the temporary file
3466734681
** name. If it is not, return SQLITE_ERROR.
3466834682
*/
3466934683
nTempPath = sqlite3Strlen30(zTempPath);
@@ -34745,11 +34759,11 @@
3474534759
int cnt = 0;
3474634760
3474734761
/* If argument zPath is a NULL pointer, this function is required to open
3474834762
** a temporary file. Use this buffer to store the file name in.
3474934763
*/
34750
- char zTmpname[MAX_PATH+2]; /* Buffer used to create temp filename */
34764
+ char zTmpname[SQLITE_WIN32_MAX_PATH+2]; /* Buffer used to create temp filename */
3475134765
3475234766
int rc = SQLITE_OK; /* Function Return Code */
3475334767
#if !defined(NDEBUG) || SQLITE_OS_WINCE
3475434768
int eType = flags&0xFFFFFF00; /* Type of file to open */
3475534769
#endif
@@ -34811,12 +34825,11 @@
3481134825
/* If the second argument to this function is NULL, generate a
3481234826
** temporary file name to use
3481334827
*/
3481434828
if( !zUtf8Name ){
3481534829
assert(isDelete && !isOpenJournal);
34816
- memset(zTmpname, 0, MAX_PATH+2);
34817
- rc = getTempname(MAX_PATH+2, zTmpname);
34830
+ rc = getTempname(SQLITE_WIN32_MAX_PATH+2, zTmpname);
3481834831
if( rc!=SQLITE_OK ){
3481934832
OSTRACE(("OPEN name=%s, rc=%s", zUtf8Name, sqlite3ErrName(rc)));
3482034833
return rc;
3482134834
}
3482234835
zUtf8Name = zTmpname;
@@ -35243,27 +35256,34 @@
3524335256
){
3524435257
3524535258
#if defined(__CYGWIN__)
3524635259
SimulateIOError( return SQLITE_ERROR );
3524735260
UNUSED_PARAMETER(nFull);
35248
- assert( pVfs->mxPathname>=MAX_PATH );
35261
+ assert( pVfs->mxPathname>=SQLITE_WIN32_MAX_PATH );
3524935262
assert( nFull>=pVfs->mxPathname );
3525035263
if ( sqlite3_data_directory && !winIsVerbatimPathname(zRelative) ){
3525135264
/*
3525235265
** NOTE: We are dealing with a relative path name and the data
3525335266
** directory has been set. Therefore, use it as the basis
3525435267
** for converting the relative path name to an absolute
3525535268
** one by prepending the data directory and a slash.
3525635269
*/
35257
- char zOut[MAX_PATH+1];
35258
- memset(zOut, 0, MAX_PATH+1);
35259
- cygwin_conv_path(CCP_POSIX_TO_WIN_A|CCP_RELATIVE, zRelative, zOut,
35260
- MAX_PATH+1);
35270
+ char zOut[SQLITE_WIN32_MAX_PATH+1];
35271
+ if( cygwin_conv_path(CCP_POSIX_TO_WIN_A|CCP_RELATIVE, zRelative, zOut,
35272
+ SQLITE_WIN32_MAX_PATH+1)<0 ){
35273
+ winLogError(SQLITE_CANTOPEN_FULLPATH, (DWORD)errno, "cygwin_conv_path",
35274
+ zRelative);
35275
+ return SQLITE_CANTOPEN_FULLPATH;
35276
+ }
3526135277
sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s\\%s",
3526235278
sqlite3_data_directory, zOut);
3526335279
}else{
35264
- cygwin_conv_path(CCP_POSIX_TO_WIN_A, zRelative, zFull, nFull);
35280
+ if( cygwin_conv_path(CCP_POSIX_TO_WIN_A, zRelative, zFull, nFull)<0 ){
35281
+ winLogError(SQLITE_CANTOPEN_FULLPATH, (DWORD)errno, "cygwin_conv_path",
35282
+ zRelative);
35283
+ return SQLITE_CANTOPEN_FULLPATH;
35284
+ }
3526535285
}
3526635286
return SQLITE_OK;
3526735287
#endif
3526835288
3526935289
#if (SQLITE_OS_WINCE || SQLITE_OS_WINRT) && !defined(__CYGWIN__)
@@ -35601,11 +35621,11 @@
3560135621
*/
3560235622
SQLITE_API int sqlite3_os_init(void){
3560335623
static sqlite3_vfs winVfs = {
3560435624
3, /* iVersion */
3560535625
sizeof(winFile), /* szOsFile */
35606
- MAX_PATH, /* mxPathname */
35626
+ SQLITE_WIN32_MAX_PATH, /* mxPathname */
3560735627
0, /* pNext */
3560835628
"win32", /* zName */
3560935629
0, /* pAppData */
3561035630
winOpen, /* xOpen */
3561135631
winDelete, /* xDelete */
@@ -107770,10 +107790,11 @@
107770107790
WhereLevel *pLevel; /* The where level to be coded */
107771107791
WhereLoop *pLoop; /* The WhereLoop object being coded */
107772107792
WhereClause *pWC; /* Decomposition of the entire WHERE clause */
107773107793
WhereTerm *pTerm; /* A WHERE clause term */
107774107794
Parse *pParse; /* Parsing context */
107795
+ sqlite3 *db; /* Database connection */
107775107796
Vdbe *v; /* The prepared stmt under constructions */
107776107797
struct SrcList_item *pTabItem; /* FROM clause term being coded */
107777107798
int addrBrk; /* Jump here to break out of the loop */
107778107799
int addrCont; /* Jump here to continue with next cycle */
107779107800
int iRowidReg = 0; /* Rowid is stored in this register, if not zero */
@@ -107781,10 +107802,11 @@
107781107802
Bitmask newNotReady; /* Return value */
107782107803
107783107804
pParse = pWInfo->pParse;
107784107805
v = pParse->pVdbe;
107785107806
pWC = &pWInfo->sWC;
107807
+ db = pParse->db;
107786107808
pLevel = &pWInfo->a[iLevel];
107787107809
pLoop = pLevel->pWLoop;
107788107810
pTabItem = &pWInfo->pTabList->a[pLevel->iFrom];
107789107811
iCur = pTabItem->iCursor;
107790107812
bRev = (pWInfo->revMask>>iLevel)&1;
@@ -108071,11 +108093,11 @@
108071108093
/* Generate code to evaluate all constraint terms using == or IN
108072108094
** and store the values of those terms in an array of registers
108073108095
** starting at regBase.
108074108096
*/
108075108097
regBase = codeAllEqualityTerms(pParse,pLevel,bRev,nExtraReg,&zStartAff);
108076
- zEndAff = sqlite3DbStrDup(pParse->db, zStartAff);
108098
+ zEndAff = sqlite3DbStrDup(db, zStartAff);
108077108099
addrNxt = pLevel->addrNxt;
108078108100
108079108101
/* If we are doing a reverse order scan on an ascending index, or
108080108102
** a forward order scan on a descending index, interchange the
108081108103
** start and end terms (pRangeStart and pRangeEnd).
@@ -108156,12 +108178,12 @@
108156108178
}
108157108179
codeApplyAffinity(pParse, regBase, nEq+1, zEndAff);
108158108180
nConstraint++;
108159108181
testcase( pRangeEnd->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */
108160108182
}
108161
- sqlite3DbFree(pParse->db, zStartAff);
108162
- sqlite3DbFree(pParse->db, zEndAff);
108183
+ sqlite3DbFree(db, zStartAff);
108184
+ sqlite3DbFree(db, zEndAff);
108163108185
108164108186
/* Top of the loop body */
108165108187
pLevel->p2 = sqlite3VdbeCurrentAddr(v);
108166108188
108167108189
/* Check if the index cursor is past the end of the range. */
@@ -108284,11 +108306,11 @@
108284108306
*/
108285108307
if( pWInfo->nLevel>1 ){
108286108308
int nNotReady; /* The number of notReady tables */
108287108309
struct SrcList_item *origSrc; /* Original list of tables */
108288108310
nNotReady = pWInfo->nLevel - iLevel - 1;
108289
- pOrTab = sqlite3StackAllocRaw(pParse->db,
108311
+ pOrTab = sqlite3StackAllocRaw(db,
108290108312
sizeof(*pOrTab)+ nNotReady*sizeof(pOrTab->a[0]));
108291108313
if( pOrTab==0 ) return notReady;
108292108314
pOrTab->nAlloc = (u8)(nNotReady + 1);
108293108315
pOrTab->nSrc = pOrTab->nAlloc;
108294108316
memcpy(pOrTab->a, pTabItem, sizeof(*pTabItem));
@@ -108338,12 +108360,12 @@
108338108360
Expr *pExpr = pWC->a[iTerm].pExpr;
108339108361
if( &pWC->a[iTerm] == pTerm ) continue;
108340108362
if( ExprHasProperty(pExpr, EP_FromJoin) ) continue;
108341108363
if( pWC->a[iTerm].wtFlags & (TERM_ORINFO) ) continue;
108342108364
if( (pWC->a[iTerm].eOperator & WO_ALL)==0 ) continue;
108343
- pExpr = sqlite3ExprDup(pParse->db, pExpr, 0);
108344
- pAndExpr = sqlite3ExprAnd(pParse->db, pAndExpr, pExpr);
108365
+ pExpr = sqlite3ExprDup(db, pExpr, 0);
108366
+ pAndExpr = sqlite3ExprAnd(db, pAndExpr, pExpr);
108345108367
}
108346108368
if( pAndExpr ){
108347108369
pAndExpr = sqlite3PExpr(pParse, TK_AND, 0, pAndExpr, 0);
108348108370
}
108349108371
}
@@ -108359,11 +108381,11 @@
108359108381
}
108360108382
/* Loop through table entries that match term pOrTerm. */
108361108383
pSubWInfo = sqlite3WhereBegin(pParse, pOrTab, pOrExpr, 0, 0,
108362108384
WHERE_OMIT_OPEN_CLOSE | WHERE_AND_ONLY |
108363108385
WHERE_FORCE_TABLE | WHERE_ONETABLE_ONLY, iCovCur);
108364
- assert( pSubWInfo || pParse->nErr || pParse->db->mallocFailed );
108386
+ assert( pSubWInfo || pParse->nErr || db->mallocFailed );
108365108387
if( pSubWInfo ){
108366108388
WhereLoop *pSubLoop;
108367108389
explainOneScan(
108368108390
pParse, pOrTab, &pSubWInfo->a[0], iLevel, pLevel->iFrom, 0
108369108391
);
@@ -108414,17 +108436,17 @@
108414108436
}
108415108437
pLevel->u.pCovidx = pCov;
108416108438
if( pCov ) pLevel->iIdxCur = iCovCur;
108417108439
if( pAndExpr ){
108418108440
pAndExpr->pLeft = 0;
108419
- sqlite3ExprDelete(pParse->db, pAndExpr);
108441
+ sqlite3ExprDelete(db, pAndExpr);
108420108442
}
108421108443
sqlite3VdbeChangeP1(v, iRetInit, sqlite3VdbeCurrentAddr(v));
108422108444
sqlite3VdbeAddOp2(v, OP_Goto, 0, pLevel->addrBrk);
108423108445
sqlite3VdbeResolveLabel(v, iLoopBody);
108424108446
108425
- if( pWInfo->nLevel>1 ) sqlite3StackFree(pParse->db, pOrTab);
108447
+ if( pWInfo->nLevel>1 ) sqlite3StackFree(db, pOrTab);
108426108448
if( !untestedTerms ) disableTerm(pLevel, pTerm);
108427108449
}else
108428108450
#endif /* SQLITE_OMIT_OR_OPTIMIZATION */
108429108451
108430108452
{
@@ -108475,13 +108497,12 @@
108475108497
** and we are coding the t1 loop and the t2 loop has not yet coded,
108476108498
** then we cannot use the "t1.a=t2.b" constraint, but we can code
108477108499
** the implied "t1.a=123" constraint.
108478108500
*/
108479108501
for(pTerm=pWC->a, j=pWC->nTerm; j>0; j--, pTerm++){
108480
- Expr *pE;
108502
+ Expr *pE, *pEAlt;
108481108503
WhereTerm *pAlt;
108482
- Expr sEq;
108483108504
if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
108484108505
if( pTerm->eOperator!=(WO_EQUIV|WO_EQ) ) continue;
108485108506
if( pTerm->leftCursor!=iCur ) continue;
108486108507
if( pLevel->iLeftJoin ) continue;
108487108508
pE = pTerm->pExpr;
@@ -108491,13 +108512,17 @@
108491108512
if( pAlt==0 ) continue;
108492108513
if( pAlt->wtFlags & (TERM_CODED) ) continue;
108493108514
testcase( pAlt->eOperator & WO_EQ );
108494108515
testcase( pAlt->eOperator & WO_IN );
108495108516
VdbeNoopComment((v, "begin transitive constraint"));
108496
- sEq = *pAlt->pExpr;
108497
- sEq.pLeft = pE->pLeft;
108498
- sqlite3ExprIfFalse(pParse, &sEq, addrCont, SQLITE_JUMPIFNULL);
108517
+ pEAlt = sqlite3StackAllocRaw(db, sizeof(*pEAlt));
108518
+ if( pEAlt ){
108519
+ *pEAlt = *pAlt->pExpr;
108520
+ pEAlt->pLeft = pE->pLeft;
108521
+ sqlite3ExprIfFalse(pParse, pEAlt, addrCont, SQLITE_JUMPIFNULL);
108522
+ sqlite3StackFree(db, pEAlt);
108523
+ }
108499108524
}
108500108525
108501108526
/* For a LEFT OUTER JOIN, generate code that will record the fact that
108502108527
** at least one row of the right table has matched the left table.
108503108528
*/
@@ -116436,10 +116461,11 @@
116436116461
case SQLITE_IOERR_SHMLOCK: zName = "SQLITE_IOERR_SHMLOCK"; break;
116437116462
case SQLITE_IOERR_SHMMAP: zName = "SQLITE_IOERR_SHMMAP"; break;
116438116463
case SQLITE_IOERR_SEEK: zName = "SQLITE_IOERR_SEEK"; break;
116439116464
case SQLITE_IOERR_DELETE_NOENT: zName = "SQLITE_IOERR_DELETE_NOENT";break;
116440116465
case SQLITE_IOERR_MMAP: zName = "SQLITE_IOERR_MMAP"; break;
116466
+ case SQLITE_IOERR_GETTEMPPATH: zName = "SQLITE_IOERR_GETTEMPPATH"; break;
116441116467
case SQLITE_CORRUPT: zName = "SQLITE_CORRUPT"; break;
116442116468
case SQLITE_CORRUPT_VTAB: zName = "SQLITE_CORRUPT_VTAB"; break;
116443116469
case SQLITE_NOTFOUND: zName = "SQLITE_NOTFOUND"; break;
116444116470
case SQLITE_FULL: zName = "SQLITE_FULL"; break;
116445116471
case SQLITE_CANTOPEN: zName = "SQLITE_CANTOPEN"; break;
@@ -128264,11 +128290,11 @@
128264128290
}
128265128291
128266128292
128267128293
#ifdef SQLITE_TEST
128268128294
128269
-/* #include <tcl.h> */
128295
+#include <tcl.h>
128270128296
/* #include <string.h> */
128271128297
128272128298
/*
128273128299
** Implementation of a special SQL scalar function for testing tokenizers
128274128300
** designed to be used in concert with the Tcl testing framework. This
128275128301
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -399,13 +399,10 @@
399 ** On Windows, if the SQLITE_WIN32_MALLOC_VALIDATE macro is defined and the
400 ** assert() macro is enabled, each call into the Win32 native heap subsystem
401 ** will cause HeapValidate to be called. If heap validation should fail, an
402 ** assertion will be triggered.
403 **
404 ** (Historical note: There used to be several other options, but we've
405 ** pared it down to just these three.)
406 **
407 ** If none of the above are defined, then set SQLITE_SYSTEM_MALLOC as
408 ** the default.
409 */
410 #if defined(SQLITE_SYSTEM_MALLOC) \
411 + defined(SQLITE_WIN32_MALLOC) \
@@ -439,24 +436,17 @@
439 */
440 #if !defined(_XOPEN_SOURCE) && !defined(__DARWIN__) && !defined(__APPLE__)
441 # define _XOPEN_SOURCE 600
442 #endif
443
444 /*
445 ** The TCL headers are only needed when compiling the TCL bindings.
446 */
447 #if defined(SQLITE_TCL) || defined(TCLSH)
448 # include <tcl.h>
449 #endif
450
451 /*
452 ** NDEBUG and SQLITE_DEBUG are opposites. It should always be true that
453 ** defined(NDEBUG)==!defined(SQLITE_DEBUG). If this is not currently true,
454 ** make it true by defining or undefining NDEBUG.
455 **
456 ** Setting NDEBUG makes the code smaller and run faster by disabling the
457 ** number assert() statements in the code. So we want the default action
458 ** to be for NDEBUG to be set and NDEBUG to be undefined only if SQLITE_DEBUG
459 ** is set. Thus NDEBUG becomes an opt-in rather than an opt-out
460 ** feature.
461 */
462 #if !defined(NDEBUG) && !defined(SQLITE_DEBUG)
@@ -522,11 +512,11 @@
522 ** hint of unplanned behavior.
523 **
524 ** In other words, ALWAYS and NEVER are added for defensive code.
525 **
526 ** When doing coverage testing ALWAYS and NEVER are hard-coded to
527 ** be true and false so that the unreachable code then specify will
528 ** not be counted as untested code.
529 */
530 #if defined(SQLITE_COVERAGE_TEST)
531 # define ALWAYS(X) (1)
532 # define NEVER(X) (0)
@@ -546,20 +536,16 @@
546 #define IS_BIG_INT(X) (((X)&~(i64)0xffffffff)!=0)
547
548 /*
549 ** The macro unlikely() is a hint that surrounds a boolean
550 ** expression that is usually false. Macro likely() surrounds
551 ** a boolean expression that is usually true. GCC is able to
552 ** use these hints to generate better code, sometimes.
 
553 */
554 #if defined(__GNUC__) && 0
555 # define likely(X) __builtin_expect((X),1)
556 # define unlikely(X) __builtin_expect((X),0)
557 #else
558 # define likely(X) !!(X)
559 # define unlikely(X) !!(X)
560 #endif
561
562 /************** Include sqlite3.h in the middle of sqliteInt.h ***************/
563 /************** Begin file sqlite3.h *****************************************/
564 /*
565 ** 2001 September 15
@@ -670,11 +656,11 @@
670 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
671 ** [sqlite_version()] and [sqlite_source_id()].
672 */
673 #define SQLITE_VERSION "3.8.0"
674 #define SQLITE_VERSION_NUMBER 3008000
675 #define SQLITE_SOURCE_ID "2013-07-25 17:07:03 8bcbb33fd0a970e16a920e1d35571836dbb9ba50"
676
677 /*
678 ** CAPI3REF: Run-Time Library Version Numbers
679 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
680 **
@@ -1039,10 +1025,11 @@
1039 #define SQLITE_IOERR_SHMLOCK (SQLITE_IOERR | (20<<8))
1040 #define SQLITE_IOERR_SHMMAP (SQLITE_IOERR | (21<<8))
1041 #define SQLITE_IOERR_SEEK (SQLITE_IOERR | (22<<8))
1042 #define SQLITE_IOERR_DELETE_NOENT (SQLITE_IOERR | (23<<8))
1043 #define SQLITE_IOERR_MMAP (SQLITE_IOERR | (24<<8))
 
1044 #define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8))
1045 #define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8))
1046 #define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8))
1047 #define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8))
1048 #define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8))
@@ -28374,30 +28361,27 @@
28374 */
28375 static const char *unixTempFileDir(void){
28376 static const char *azDirs[] = {
28377 0,
28378 0,
28379 #ifdef __CYGWIN__
28380 0,
28381 0,
28382 #endif
28383 "/var/tmp",
28384 "/usr/tmp",
28385 "/tmp",
28386 0 /* List terminator */
28387 };
28388 unsigned int i;
28389 struct stat buf;
28390 const char *zDir = 0;
28391
28392 azDirs[0] = sqlite3_temp_directory;
28393 if( !azDirs[1] ) azDirs[1] = getenv("TMPDIR");
28394 #ifdef __CYGWIN__
28395 if( !azDirs[2] ) azDirs[2] = getenv("TMP");
28396 if( !azDirs[3] ) azDirs[3] = getenv("TEMP");
28397 #endif
28398 for(i=0; i<sizeof(azDirs)/sizeof(azDirs[0]); zDir=azDirs[i++]){
28399 if( zDir==0 ) continue;
28400 if( osStat(zDir, &buf) ) continue;
28401 if( !S_ISDIR(buf.st_mode) ) continue;
28402 if( osAccess(zDir, 07) ) continue;
28403 break;
@@ -28423,11 +28407,10 @@
28423 ** function failing.
28424 */
28425 SimulateIOError( return SQLITE_IOERR );
28426
28427 zDir = unixTempFileDir();
28428 if( zDir==0 ) zDir = ".";
28429
28430 /* Check that the output buffer is large enough for the temporary file
28431 ** name. If it is not, return SQLITE_ERROR.
28432 */
28433 if( (strlen(zDir) + strlen(SQLITE_TEMP_FILE_PREFIX) + 18) >= (size_t)nBuf ){
@@ -30505,10 +30488,11 @@
30505 */
30506 #if SQLITE_OS_WIN /* This file is used for Windows only */
30507
30508 #ifdef __CYGWIN__
30509 # include <sys/cygwin.h>
 
30510 #endif
30511
30512 /*
30513 ** Include code that is common to all os_*.c files
30514 */
@@ -30925,10 +30909,11 @@
30925 * zero for the default behavior.
30926 */
30927 #ifndef SQLITE_WIN32_HEAP_FLAGS
30928 # define SQLITE_WIN32_HEAP_FLAGS (0)
30929 #endif
 
30930
30931 /*
30932 ** The winMemData structure stores information required by the Win32-specific
30933 ** sqlite3_mem_methods implementation.
30934 */
@@ -34390,14 +34375,14 @@
34390 OSTRACE(("MAP-FILE-CREATE pid=%lu, pFile=%p, rc=SQLITE_IOERR_MMAP\n",
34391 osGetCurrentProcessId(), pFd));
34392 return SQLITE_OK;
34393 }
34394 assert( (nMap % winSysInfo.dwPageSize)==0 );
34395 #if SQLITE_OS_WINRT
34396 pNew = osMapViewOfFileFromApp(pFd->hMap, flags, 0, nMap);
34397 #else
34398 assert( sizeof(SIZE_T)==sizeof(sqlite3_int64) || nMap<=0xffffffff );
 
 
 
34399 pNew = osMapViewOfFile(pFd->hMap, flags, 0, 0, (SIZE_T)nMap);
34400 #endif
34401 if( pNew==NULL ){
34402 osCloseHandle(pFd->hMap);
34403 pFd->hMap = NULL;
@@ -34564,10 +34549,19 @@
34564 return zConverted;
34565 }
34566
34567 static int winIsDir(const void *zConverted);
34568
 
 
 
 
 
 
 
 
 
34569 /*
34570 ** Create a temporary file name in zBuf. zBuf must be big enough to
34571 ** hold at pVfs->mxPathname characters.
34572 */
34573 static int getTempname(int nBuf, char *zBuf){
@@ -34575,95 +34569,115 @@
34575 "abcdefghijklmnopqrstuvwxyz"
34576 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
34577 "0123456789";
34578 size_t i, j;
34579 int nTempPath;
34580 char zTempPath[MAX_PATH+2];
34581
34582 /* It's odd to simulate an io-error here, but really this is just
34583 ** using the io-error infrastructure to test that SQLite handles this
34584 ** function failing.
34585 */
34586 SimulateIOError( return SQLITE_IOERR );
34587
34588 memset(zTempPath, 0, MAX_PATH+2);
34589
34590 if( sqlite3_temp_directory ){
34591 sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", sqlite3_temp_directory);
 
34592 }
34593 #if defined(__CYGWIN__)
34594 static const char *azDirs[] = {
34595 0,
34596 0,
34597 0,
34598 0,
34599 "/var/tmp",
34600 "/usr/tmp",
34601 "/tmp",
34602 0
34603 };
34604 const char *zDir = 0;
34605 char *zConverted;
34606
34607 azDirs[0] = sqlite3_temp_directory;
34608 if( !azDirs[1] ) azDirs[1] = getenv("TMPDIR");
34609 if( !azDirs[2] ) azDirs[2] = getenv("TMP");
34610 if( !azDirs[3] ) azDirs[3] = getenv("TEMP");
34611 for(i=0; i<sizeof(azDirs)/sizeof(azDirs[0]); zDir=azDirs[i++]){
34612 if( zDir==0 || zDir[0]) continue;
34613 if( zDir[1]!=':' ){
34614 WCHAR zWidePath[MAX_PATH];
34615 cygwin_conv_path(CCP_POSIX_TO_WIN_W, zDir, zWidePath, MAX_PATH);
34616 zDir = unicodeToUtf8(zWidePath);
34617 if( zDir==0 ){
34618 OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
34619 return SQLITE_IOERR_NOMEM;
34620 }
34621 }
34622 /* Convert the filename to the system encoding. */
34623 zConverted = convertUtf8Filename(zDir);
34624 if( zConverted==0 ){
34625 OSTRACE(("TEMP-FILENAME, rc=SQLITE_IOERR_NOMEM"));
34626 return SQLITE_IOERR_NOMEM;
34627 }
34628 if( winIsDir(zConverted) ){
34629 sqlite3_free(zConverted);
34630 break;
34631 }
34632 sqlite3_free(zConverted);
34633 }
34634 sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", zDir);
34635 #elif !SQLITE_OS_WINRT
34636 else if( isNT() ){
34637 char *zMulti;
34638 WCHAR zWidePath[MAX_PATH];
34639 osGetTempPathW(MAX_PATH-30, zWidePath);
 
 
 
34640 zMulti = unicodeToUtf8(zWidePath);
34641 if( zMulti ){
34642 sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", zMulti);
34643 sqlite3_free(zMulti);
34644 }else{
34645 OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
34646 return SQLITE_IOERR_NOMEM;
34647 }
34648 }
34649 #ifdef SQLITE_WIN32_HAS_ANSI
34650 else{
34651 char *zUtf8;
34652 char zMbcsPath[MAX_PATH];
34653 osGetTempPathA(MAX_PATH-30, zMbcsPath);
 
 
 
34654 zUtf8 = sqlite3_win32_mbcs_to_utf8(zMbcsPath);
34655 if( zUtf8 ){
34656 sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", zUtf8);
34657 sqlite3_free(zUtf8);
34658 }else{
34659 OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
34660 return SQLITE_IOERR_NOMEM;
34661 }
34662 }
34663 #endif
34664 #endif
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34665
34666 /* Check that the output buffer is large enough for the temporary file
34667 ** name. If it is not, return SQLITE_ERROR.
34668 */
34669 nTempPath = sqlite3Strlen30(zTempPath);
@@ -34745,11 +34759,11 @@
34745 int cnt = 0;
34746
34747 /* If argument zPath is a NULL pointer, this function is required to open
34748 ** a temporary file. Use this buffer to store the file name in.
34749 */
34750 char zTmpname[MAX_PATH+2]; /* Buffer used to create temp filename */
34751
34752 int rc = SQLITE_OK; /* Function Return Code */
34753 #if !defined(NDEBUG) || SQLITE_OS_WINCE
34754 int eType = flags&0xFFFFFF00; /* Type of file to open */
34755 #endif
@@ -34811,12 +34825,11 @@
34811 /* If the second argument to this function is NULL, generate a
34812 ** temporary file name to use
34813 */
34814 if( !zUtf8Name ){
34815 assert(isDelete && !isOpenJournal);
34816 memset(zTmpname, 0, MAX_PATH+2);
34817 rc = getTempname(MAX_PATH+2, zTmpname);
34818 if( rc!=SQLITE_OK ){
34819 OSTRACE(("OPEN name=%s, rc=%s", zUtf8Name, sqlite3ErrName(rc)));
34820 return rc;
34821 }
34822 zUtf8Name = zTmpname;
@@ -35243,27 +35256,34 @@
35243 ){
35244
35245 #if defined(__CYGWIN__)
35246 SimulateIOError( return SQLITE_ERROR );
35247 UNUSED_PARAMETER(nFull);
35248 assert( pVfs->mxPathname>=MAX_PATH );
35249 assert( nFull>=pVfs->mxPathname );
35250 if ( sqlite3_data_directory && !winIsVerbatimPathname(zRelative) ){
35251 /*
35252 ** NOTE: We are dealing with a relative path name and the data
35253 ** directory has been set. Therefore, use it as the basis
35254 ** for converting the relative path name to an absolute
35255 ** one by prepending the data directory and a slash.
35256 */
35257 char zOut[MAX_PATH+1];
35258 memset(zOut, 0, MAX_PATH+1);
35259 cygwin_conv_path(CCP_POSIX_TO_WIN_A|CCP_RELATIVE, zRelative, zOut,
35260 MAX_PATH+1);
 
 
 
35261 sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s\\%s",
35262 sqlite3_data_directory, zOut);
35263 }else{
35264 cygwin_conv_path(CCP_POSIX_TO_WIN_A, zRelative, zFull, nFull);
 
 
 
 
35265 }
35266 return SQLITE_OK;
35267 #endif
35268
35269 #if (SQLITE_OS_WINCE || SQLITE_OS_WINRT) && !defined(__CYGWIN__)
@@ -35601,11 +35621,11 @@
35601 */
35602 SQLITE_API int sqlite3_os_init(void){
35603 static sqlite3_vfs winVfs = {
35604 3, /* iVersion */
35605 sizeof(winFile), /* szOsFile */
35606 MAX_PATH, /* mxPathname */
35607 0, /* pNext */
35608 "win32", /* zName */
35609 0, /* pAppData */
35610 winOpen, /* xOpen */
35611 winDelete, /* xDelete */
@@ -107770,10 +107790,11 @@
107770 WhereLevel *pLevel; /* The where level to be coded */
107771 WhereLoop *pLoop; /* The WhereLoop object being coded */
107772 WhereClause *pWC; /* Decomposition of the entire WHERE clause */
107773 WhereTerm *pTerm; /* A WHERE clause term */
107774 Parse *pParse; /* Parsing context */
 
107775 Vdbe *v; /* The prepared stmt under constructions */
107776 struct SrcList_item *pTabItem; /* FROM clause term being coded */
107777 int addrBrk; /* Jump here to break out of the loop */
107778 int addrCont; /* Jump here to continue with next cycle */
107779 int iRowidReg = 0; /* Rowid is stored in this register, if not zero */
@@ -107781,10 +107802,11 @@
107781 Bitmask newNotReady; /* Return value */
107782
107783 pParse = pWInfo->pParse;
107784 v = pParse->pVdbe;
107785 pWC = &pWInfo->sWC;
 
107786 pLevel = &pWInfo->a[iLevel];
107787 pLoop = pLevel->pWLoop;
107788 pTabItem = &pWInfo->pTabList->a[pLevel->iFrom];
107789 iCur = pTabItem->iCursor;
107790 bRev = (pWInfo->revMask>>iLevel)&1;
@@ -108071,11 +108093,11 @@
108071 /* Generate code to evaluate all constraint terms using == or IN
108072 ** and store the values of those terms in an array of registers
108073 ** starting at regBase.
108074 */
108075 regBase = codeAllEqualityTerms(pParse,pLevel,bRev,nExtraReg,&zStartAff);
108076 zEndAff = sqlite3DbStrDup(pParse->db, zStartAff);
108077 addrNxt = pLevel->addrNxt;
108078
108079 /* If we are doing a reverse order scan on an ascending index, or
108080 ** a forward order scan on a descending index, interchange the
108081 ** start and end terms (pRangeStart and pRangeEnd).
@@ -108156,12 +108178,12 @@
108156 }
108157 codeApplyAffinity(pParse, regBase, nEq+1, zEndAff);
108158 nConstraint++;
108159 testcase( pRangeEnd->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */
108160 }
108161 sqlite3DbFree(pParse->db, zStartAff);
108162 sqlite3DbFree(pParse->db, zEndAff);
108163
108164 /* Top of the loop body */
108165 pLevel->p2 = sqlite3VdbeCurrentAddr(v);
108166
108167 /* Check if the index cursor is past the end of the range. */
@@ -108284,11 +108306,11 @@
108284 */
108285 if( pWInfo->nLevel>1 ){
108286 int nNotReady; /* The number of notReady tables */
108287 struct SrcList_item *origSrc; /* Original list of tables */
108288 nNotReady = pWInfo->nLevel - iLevel - 1;
108289 pOrTab = sqlite3StackAllocRaw(pParse->db,
108290 sizeof(*pOrTab)+ nNotReady*sizeof(pOrTab->a[0]));
108291 if( pOrTab==0 ) return notReady;
108292 pOrTab->nAlloc = (u8)(nNotReady + 1);
108293 pOrTab->nSrc = pOrTab->nAlloc;
108294 memcpy(pOrTab->a, pTabItem, sizeof(*pTabItem));
@@ -108338,12 +108360,12 @@
108338 Expr *pExpr = pWC->a[iTerm].pExpr;
108339 if( &pWC->a[iTerm] == pTerm ) continue;
108340 if( ExprHasProperty(pExpr, EP_FromJoin) ) continue;
108341 if( pWC->a[iTerm].wtFlags & (TERM_ORINFO) ) continue;
108342 if( (pWC->a[iTerm].eOperator & WO_ALL)==0 ) continue;
108343 pExpr = sqlite3ExprDup(pParse->db, pExpr, 0);
108344 pAndExpr = sqlite3ExprAnd(pParse->db, pAndExpr, pExpr);
108345 }
108346 if( pAndExpr ){
108347 pAndExpr = sqlite3PExpr(pParse, TK_AND, 0, pAndExpr, 0);
108348 }
108349 }
@@ -108359,11 +108381,11 @@
108359 }
108360 /* Loop through table entries that match term pOrTerm. */
108361 pSubWInfo = sqlite3WhereBegin(pParse, pOrTab, pOrExpr, 0, 0,
108362 WHERE_OMIT_OPEN_CLOSE | WHERE_AND_ONLY |
108363 WHERE_FORCE_TABLE | WHERE_ONETABLE_ONLY, iCovCur);
108364 assert( pSubWInfo || pParse->nErr || pParse->db->mallocFailed );
108365 if( pSubWInfo ){
108366 WhereLoop *pSubLoop;
108367 explainOneScan(
108368 pParse, pOrTab, &pSubWInfo->a[0], iLevel, pLevel->iFrom, 0
108369 );
@@ -108414,17 +108436,17 @@
108414 }
108415 pLevel->u.pCovidx = pCov;
108416 if( pCov ) pLevel->iIdxCur = iCovCur;
108417 if( pAndExpr ){
108418 pAndExpr->pLeft = 0;
108419 sqlite3ExprDelete(pParse->db, pAndExpr);
108420 }
108421 sqlite3VdbeChangeP1(v, iRetInit, sqlite3VdbeCurrentAddr(v));
108422 sqlite3VdbeAddOp2(v, OP_Goto, 0, pLevel->addrBrk);
108423 sqlite3VdbeResolveLabel(v, iLoopBody);
108424
108425 if( pWInfo->nLevel>1 ) sqlite3StackFree(pParse->db, pOrTab);
108426 if( !untestedTerms ) disableTerm(pLevel, pTerm);
108427 }else
108428 #endif /* SQLITE_OMIT_OR_OPTIMIZATION */
108429
108430 {
@@ -108475,13 +108497,12 @@
108475 ** and we are coding the t1 loop and the t2 loop has not yet coded,
108476 ** then we cannot use the "t1.a=t2.b" constraint, but we can code
108477 ** the implied "t1.a=123" constraint.
108478 */
108479 for(pTerm=pWC->a, j=pWC->nTerm; j>0; j--, pTerm++){
108480 Expr *pE;
108481 WhereTerm *pAlt;
108482 Expr sEq;
108483 if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
108484 if( pTerm->eOperator!=(WO_EQUIV|WO_EQ) ) continue;
108485 if( pTerm->leftCursor!=iCur ) continue;
108486 if( pLevel->iLeftJoin ) continue;
108487 pE = pTerm->pExpr;
@@ -108491,13 +108512,17 @@
108491 if( pAlt==0 ) continue;
108492 if( pAlt->wtFlags & (TERM_CODED) ) continue;
108493 testcase( pAlt->eOperator & WO_EQ );
108494 testcase( pAlt->eOperator & WO_IN );
108495 VdbeNoopComment((v, "begin transitive constraint"));
108496 sEq = *pAlt->pExpr;
108497 sEq.pLeft = pE->pLeft;
108498 sqlite3ExprIfFalse(pParse, &sEq, addrCont, SQLITE_JUMPIFNULL);
 
 
 
 
108499 }
108500
108501 /* For a LEFT OUTER JOIN, generate code that will record the fact that
108502 ** at least one row of the right table has matched the left table.
108503 */
@@ -116436,10 +116461,11 @@
116436 case SQLITE_IOERR_SHMLOCK: zName = "SQLITE_IOERR_SHMLOCK"; break;
116437 case SQLITE_IOERR_SHMMAP: zName = "SQLITE_IOERR_SHMMAP"; break;
116438 case SQLITE_IOERR_SEEK: zName = "SQLITE_IOERR_SEEK"; break;
116439 case SQLITE_IOERR_DELETE_NOENT: zName = "SQLITE_IOERR_DELETE_NOENT";break;
116440 case SQLITE_IOERR_MMAP: zName = "SQLITE_IOERR_MMAP"; break;
 
116441 case SQLITE_CORRUPT: zName = "SQLITE_CORRUPT"; break;
116442 case SQLITE_CORRUPT_VTAB: zName = "SQLITE_CORRUPT_VTAB"; break;
116443 case SQLITE_NOTFOUND: zName = "SQLITE_NOTFOUND"; break;
116444 case SQLITE_FULL: zName = "SQLITE_FULL"; break;
116445 case SQLITE_CANTOPEN: zName = "SQLITE_CANTOPEN"; break;
@@ -128264,11 +128290,11 @@
128264 }
128265
128266
128267 #ifdef SQLITE_TEST
128268
128269 /* #include <tcl.h> */
128270 /* #include <string.h> */
128271
128272 /*
128273 ** Implementation of a special SQL scalar function for testing tokenizers
128274 ** designed to be used in concert with the Tcl testing framework. This
128275
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -399,13 +399,10 @@
399 ** On Windows, if the SQLITE_WIN32_MALLOC_VALIDATE macro is defined and the
400 ** assert() macro is enabled, each call into the Win32 native heap subsystem
401 ** will cause HeapValidate to be called. If heap validation should fail, an
402 ** assertion will be triggered.
403 **
 
 
 
404 ** If none of the above are defined, then set SQLITE_SYSTEM_MALLOC as
405 ** the default.
406 */
407 #if defined(SQLITE_SYSTEM_MALLOC) \
408 + defined(SQLITE_WIN32_MALLOC) \
@@ -439,24 +436,17 @@
436 */
437 #if !defined(_XOPEN_SOURCE) && !defined(__DARWIN__) && !defined(__APPLE__)
438 # define _XOPEN_SOURCE 600
439 #endif
440
 
 
 
 
 
 
 
441 /*
442 ** NDEBUG and SQLITE_DEBUG are opposites. It should always be true that
443 ** defined(NDEBUG)==!defined(SQLITE_DEBUG). If this is not currently true,
444 ** make it true by defining or undefining NDEBUG.
445 **
446 ** Setting NDEBUG makes the code smaller and faster by disabling the
447 ** assert() statements in the code. So we want the default action
448 ** to be for NDEBUG to be set and NDEBUG to be undefined only if SQLITE_DEBUG
449 ** is set. Thus NDEBUG becomes an opt-in rather than an opt-out
450 ** feature.
451 */
452 #if !defined(NDEBUG) && !defined(SQLITE_DEBUG)
@@ -522,11 +512,11 @@
512 ** hint of unplanned behavior.
513 **
514 ** In other words, ALWAYS and NEVER are added for defensive code.
515 **
516 ** When doing coverage testing ALWAYS and NEVER are hard-coded to
517 ** be true and false so that the unreachable code they specify will
518 ** not be counted as untested code.
519 */
520 #if defined(SQLITE_COVERAGE_TEST)
521 # define ALWAYS(X) (1)
522 # define NEVER(X) (0)
@@ -546,20 +536,16 @@
536 #define IS_BIG_INT(X) (((X)&~(i64)0xffffffff)!=0)
537
538 /*
539 ** The macro unlikely() is a hint that surrounds a boolean
540 ** expression that is usually false. Macro likely() surrounds
541 ** a boolean expression that is usually true. These hints could,
542 ** in theory, be used by the compiler to generate better code, but
543 ** currently they are just comments for human readers.
544 */
545 #define likely(X) (X)
546 #define unlikely(X) (X)
 
 
 
 
 
547
548 /************** Include sqlite3.h in the middle of sqliteInt.h ***************/
549 /************** Begin file sqlite3.h *****************************************/
550 /*
551 ** 2001 September 15
@@ -670,11 +656,11 @@
656 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
657 ** [sqlite_version()] and [sqlite_source_id()].
658 */
659 #define SQLITE_VERSION "3.8.0"
660 #define SQLITE_VERSION_NUMBER 3008000
661 #define SQLITE_SOURCE_ID "2013-07-31 23:28:36 136fc2931b156f91cdd76a7a009298cdf09d826a"
662
663 /*
664 ** CAPI3REF: Run-Time Library Version Numbers
665 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
666 **
@@ -1039,10 +1025,11 @@
1025 #define SQLITE_IOERR_SHMLOCK (SQLITE_IOERR | (20<<8))
1026 #define SQLITE_IOERR_SHMMAP (SQLITE_IOERR | (21<<8))
1027 #define SQLITE_IOERR_SEEK (SQLITE_IOERR | (22<<8))
1028 #define SQLITE_IOERR_DELETE_NOENT (SQLITE_IOERR | (23<<8))
1029 #define SQLITE_IOERR_MMAP (SQLITE_IOERR | (24<<8))
1030 #define SQLITE_IOERR_GETTEMPPATH (SQLITE_IOERR | (25<<8))
1031 #define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8))
1032 #define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8))
1033 #define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8))
1034 #define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8))
1035 #define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8))
@@ -28374,30 +28361,27 @@
28361 */
28362 static const char *unixTempFileDir(void){
28363 static const char *azDirs[] = {
28364 0,
28365 0,
 
28366 0,
28367 0,
 
28368 "/var/tmp",
28369 "/usr/tmp",
28370 "/tmp",
28371 "."
28372 };
28373 unsigned int i;
28374 struct stat buf;
28375 const char *zDir;
28376
28377 azDirs[0] = sqlite3_temp_directory;
28378 if( !azDirs[1] ) azDirs[1] = getenv("TMPDIR");
 
28379 if( !azDirs[2] ) azDirs[2] = getenv("TMP");
28380 if( !azDirs[3] ) azDirs[3] = getenv("TEMP");
28381 for(i=0; i<sizeof(azDirs)/sizeof(azDirs[0]); i++){
28382 zDir = azDirs[i];
28383 if( zDir==0 ) continue;
28384 if( osStat(zDir, &buf) ) continue;
28385 if( !S_ISDIR(buf.st_mode) ) continue;
28386 if( osAccess(zDir, 07) ) continue;
28387 break;
@@ -28423,11 +28407,10 @@
28407 ** function failing.
28408 */
28409 SimulateIOError( return SQLITE_IOERR );
28410
28411 zDir = unixTempFileDir();
 
28412
28413 /* Check that the output buffer is large enough for the temporary file
28414 ** name. If it is not, return SQLITE_ERROR.
28415 */
28416 if( (strlen(zDir) + strlen(SQLITE_TEMP_FILE_PREFIX) + 18) >= (size_t)nBuf ){
@@ -30505,10 +30488,11 @@
30488 */
30489 #if SQLITE_OS_WIN /* This file is used for Windows only */
30490
30491 #ifdef __CYGWIN__
30492 # include <sys/cygwin.h>
30493 /* # include <errno.h> */
30494 #endif
30495
30496 /*
30497 ** Include code that is common to all os_*.c files
30498 */
@@ -30925,10 +30909,11 @@
30909 * zero for the default behavior.
30910 */
30911 #ifndef SQLITE_WIN32_HEAP_FLAGS
30912 # define SQLITE_WIN32_HEAP_FLAGS (0)
30913 #endif
30914
30915
30916 /*
30917 ** The winMemData structure stores information required by the Win32-specific
30918 ** sqlite3_mem_methods implementation.
30919 */
@@ -34390,14 +34375,14 @@
34375 OSTRACE(("MAP-FILE-CREATE pid=%lu, pFile=%p, rc=SQLITE_IOERR_MMAP\n",
34376 osGetCurrentProcessId(), pFd));
34377 return SQLITE_OK;
34378 }
34379 assert( (nMap % winSysInfo.dwPageSize)==0 );
 
 
 
34380 assert( sizeof(SIZE_T)==sizeof(sqlite3_int64) || nMap<=0xffffffff );
34381 #if SQLITE_OS_WINRT
34382 pNew = osMapViewOfFileFromApp(pFd->hMap, flags, 0, (SIZE_T)nMap);
34383 #else
34384 pNew = osMapViewOfFile(pFd->hMap, flags, 0, 0, (SIZE_T)nMap);
34385 #endif
34386 if( pNew==NULL ){
34387 osCloseHandle(pFd->hMap);
34388 pFd->hMap = NULL;
@@ -34564,10 +34549,19 @@
34549 return zConverted;
34550 }
34551
34552 static int winIsDir(const void *zConverted);
34553
34554 /*
34555 ** Maximum pathname length (in bytes) for windows. The MAX_PATH macro is
34556 ** in characters, so we allocate 3 bytes per character assuming worst-case
34557 ** 3-bytes-per-character UTF8.
34558 */
34559 #ifndef SQLITE_WIN32_MAX_PATH
34560 # define SQLITE_WIN32_MAX_PATH (MAX_PATH*3)
34561 #endif
34562
34563 /*
34564 ** Create a temporary file name in zBuf. zBuf must be big enough to
34565 ** hold at pVfs->mxPathname characters.
34566 */
34567 static int getTempname(int nBuf, char *zBuf){
@@ -34575,95 +34569,115 @@
34569 "abcdefghijklmnopqrstuvwxyz"
34570 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
34571 "0123456789";
34572 size_t i, j;
34573 int nTempPath;
34574 char zTempPath[SQLITE_WIN32_MAX_PATH+2];
34575
34576 /* It's odd to simulate an io-error here, but really this is just
34577 ** using the io-error infrastructure to test that SQLite handles this
34578 ** function failing.
34579 */
34580 SimulateIOError( return SQLITE_IOERR );
34581
 
 
34582 if( sqlite3_temp_directory ){
34583 sqlite3_snprintf(SQLITE_WIN32_MAX_PATH-30, zTempPath, "%s",
34584 sqlite3_temp_directory);
34585 }
34586 #if defined(__CYGWIN__)
34587 else{
34588 static const char *azDirs[] = {
34589 0,
34590 0,
34591 0,
34592 0,
34593 "/var/tmp",
34594 "/usr/tmp",
34595 "/tmp",
34596 "."
34597 };
34598 const char *zDir;
34599 WCHAR zWidePath[MAX_PATH];
34600
34601 if( !azDirs[0] ) azDirs[0] = getenv("TMPDIR");
34602 if( !azDirs[1] ) azDirs[1] = getenv("TMP");
34603 if( !azDirs[2] ) azDirs[2] = getenv("TEMP");
34604 if( !azDirs[3] ) azDirs[3] = getenv("USERPROFILE");
34605 for(i=0; i<sizeof(azDirs)/sizeof(azDirs[0]); i++){
34606 zDir = azDirs[i];
34607 if( zDir==0 || zDir[0]==0 ) continue;
34608 if( zDir[1]!=':' ){
34609 cygwin_conv_path(CCP_POSIX_TO_WIN_W, zDir, zWidePath, MAX_PATH);
34610 zDir = azDirs[i] = unicodeToUtf8(zWidePath);
34611 if( zDir==0 ){
34612 OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
34613 return SQLITE_IOERR_NOMEM;
34614 }
34615 }else{
34616 /* Convert the filename to the system encoding. */
34617 osMultiByteToWideChar(CP_UTF8, 0, zDir, -1, zWidePath,
34618 MAX_PATH);
34619 }
34620 if( winIsDir(zWidePath) ){
34621 break;
34622 }
34623 azDirs[i] = ""; /* Don't retry in future call */
34624 }
34625 sqlite3_snprintf(MAX_PATH-30, zTempPath, "%s", zDir);
34626 }
 
34627 #elif !SQLITE_OS_WINRT
34628 else if( isNT() ){
34629 char *zMulti;
34630 WCHAR zWidePath[MAX_PATH];
34631 if( osGetTempPathW(MAX_PATH-30, zWidePath)==0 ){
34632 OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_GETTEMPPATH\n"));
34633 return SQLITE_IOERR_GETTEMPPATH;
34634 }
34635 zMulti = unicodeToUtf8(zWidePath);
34636 if( zMulti ){
34637 sqlite3_snprintf(SQLITE_WIN32_MAX_PATH-30, zTempPath, "%s", zMulti);
34638 sqlite3_free(zMulti);
34639 }else{
34640 OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
34641 return SQLITE_IOERR_NOMEM;
34642 }
34643 }
34644 #ifdef SQLITE_WIN32_HAS_ANSI
34645 else{
34646 char *zUtf8;
34647 char zMbcsPath[SQLITE_WIN32_MAX_PATH];
34648 if( osGetTempPathA(SQLITE_WIN32_MAX_PATH-30, zMbcsPath)==0 ){
34649 OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_GETTEMPPATH\n"));
34650 return SQLITE_IOERR_GETTEMPPATH;
34651 }
34652 zUtf8 = sqlite3_win32_mbcs_to_utf8(zMbcsPath);
34653 if( zUtf8 ){
34654 sqlite3_snprintf(SQLITE_WIN32_MAX_PATH-30, zTempPath, "%s", zUtf8);
34655 sqlite3_free(zUtf8);
34656 }else{
34657 OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n"));
34658 return SQLITE_IOERR_NOMEM;
34659 }
34660 }
34661 #else
34662 else{
34663 /*
34664 ** Compiled without ANSI support and the current operating system
34665 ** is not Windows NT; therefore, just zero the temporary buffer.
34666 */
34667 memset(zTempPath, 0, SQLITE_WIN32_MAX_PATH+2);
34668 }
34669 #endif /* SQLITE_WIN32_HAS_ANSI */
34670 #else
34671 else{
34672 /*
34673 ** Compiled for WinRT and the sqlite3_temp_directory is not set;
34674 ** therefore, just zero the temporary buffer.
34675 */
34676 memset(zTempPath, 0, SQLITE_WIN32_MAX_PATH+2);
34677 }
34678 #endif /* !SQLITE_OS_WINRT */
34679
34680 /* Check that the output buffer is large enough for the temporary file
34681 ** name. If it is not, return SQLITE_ERROR.
34682 */
34683 nTempPath = sqlite3Strlen30(zTempPath);
@@ -34745,11 +34759,11 @@
34759 int cnt = 0;
34760
34761 /* If argument zPath is a NULL pointer, this function is required to open
34762 ** a temporary file. Use this buffer to store the file name in.
34763 */
34764 char zTmpname[SQLITE_WIN32_MAX_PATH+2]; /* Buffer used to create temp filename */
34765
34766 int rc = SQLITE_OK; /* Function Return Code */
34767 #if !defined(NDEBUG) || SQLITE_OS_WINCE
34768 int eType = flags&0xFFFFFF00; /* Type of file to open */
34769 #endif
@@ -34811,12 +34825,11 @@
34825 /* If the second argument to this function is NULL, generate a
34826 ** temporary file name to use
34827 */
34828 if( !zUtf8Name ){
34829 assert(isDelete && !isOpenJournal);
34830 rc = getTempname(SQLITE_WIN32_MAX_PATH+2, zTmpname);
 
34831 if( rc!=SQLITE_OK ){
34832 OSTRACE(("OPEN name=%s, rc=%s", zUtf8Name, sqlite3ErrName(rc)));
34833 return rc;
34834 }
34835 zUtf8Name = zTmpname;
@@ -35243,27 +35256,34 @@
35256 ){
35257
35258 #if defined(__CYGWIN__)
35259 SimulateIOError( return SQLITE_ERROR );
35260 UNUSED_PARAMETER(nFull);
35261 assert( pVfs->mxPathname>=SQLITE_WIN32_MAX_PATH );
35262 assert( nFull>=pVfs->mxPathname );
35263 if ( sqlite3_data_directory && !winIsVerbatimPathname(zRelative) ){
35264 /*
35265 ** NOTE: We are dealing with a relative path name and the data
35266 ** directory has been set. Therefore, use it as the basis
35267 ** for converting the relative path name to an absolute
35268 ** one by prepending the data directory and a slash.
35269 */
35270 char zOut[SQLITE_WIN32_MAX_PATH+1];
35271 if( cygwin_conv_path(CCP_POSIX_TO_WIN_A|CCP_RELATIVE, zRelative, zOut,
35272 SQLITE_WIN32_MAX_PATH+1)<0 ){
35273 winLogError(SQLITE_CANTOPEN_FULLPATH, (DWORD)errno, "cygwin_conv_path",
35274 zRelative);
35275 return SQLITE_CANTOPEN_FULLPATH;
35276 }
35277 sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s\\%s",
35278 sqlite3_data_directory, zOut);
35279 }else{
35280 if( cygwin_conv_path(CCP_POSIX_TO_WIN_A, zRelative, zFull, nFull)<0 ){
35281 winLogError(SQLITE_CANTOPEN_FULLPATH, (DWORD)errno, "cygwin_conv_path",
35282 zRelative);
35283 return SQLITE_CANTOPEN_FULLPATH;
35284 }
35285 }
35286 return SQLITE_OK;
35287 #endif
35288
35289 #if (SQLITE_OS_WINCE || SQLITE_OS_WINRT) && !defined(__CYGWIN__)
@@ -35601,11 +35621,11 @@
35621 */
35622 SQLITE_API int sqlite3_os_init(void){
35623 static sqlite3_vfs winVfs = {
35624 3, /* iVersion */
35625 sizeof(winFile), /* szOsFile */
35626 SQLITE_WIN32_MAX_PATH, /* mxPathname */
35627 0, /* pNext */
35628 "win32", /* zName */
35629 0, /* pAppData */
35630 winOpen, /* xOpen */
35631 winDelete, /* xDelete */
@@ -107770,10 +107790,11 @@
107790 WhereLevel *pLevel; /* The where level to be coded */
107791 WhereLoop *pLoop; /* The WhereLoop object being coded */
107792 WhereClause *pWC; /* Decomposition of the entire WHERE clause */
107793 WhereTerm *pTerm; /* A WHERE clause term */
107794 Parse *pParse; /* Parsing context */
107795 sqlite3 *db; /* Database connection */
107796 Vdbe *v; /* The prepared stmt under constructions */
107797 struct SrcList_item *pTabItem; /* FROM clause term being coded */
107798 int addrBrk; /* Jump here to break out of the loop */
107799 int addrCont; /* Jump here to continue with next cycle */
107800 int iRowidReg = 0; /* Rowid is stored in this register, if not zero */
@@ -107781,10 +107802,11 @@
107802 Bitmask newNotReady; /* Return value */
107803
107804 pParse = pWInfo->pParse;
107805 v = pParse->pVdbe;
107806 pWC = &pWInfo->sWC;
107807 db = pParse->db;
107808 pLevel = &pWInfo->a[iLevel];
107809 pLoop = pLevel->pWLoop;
107810 pTabItem = &pWInfo->pTabList->a[pLevel->iFrom];
107811 iCur = pTabItem->iCursor;
107812 bRev = (pWInfo->revMask>>iLevel)&1;
@@ -108071,11 +108093,11 @@
108093 /* Generate code to evaluate all constraint terms using == or IN
108094 ** and store the values of those terms in an array of registers
108095 ** starting at regBase.
108096 */
108097 regBase = codeAllEqualityTerms(pParse,pLevel,bRev,nExtraReg,&zStartAff);
108098 zEndAff = sqlite3DbStrDup(db, zStartAff);
108099 addrNxt = pLevel->addrNxt;
108100
108101 /* If we are doing a reverse order scan on an ascending index, or
108102 ** a forward order scan on a descending index, interchange the
108103 ** start and end terms (pRangeStart and pRangeEnd).
@@ -108156,12 +108178,12 @@
108178 }
108179 codeApplyAffinity(pParse, regBase, nEq+1, zEndAff);
108180 nConstraint++;
108181 testcase( pRangeEnd->wtFlags & TERM_VIRTUAL ); /* EV: R-30575-11662 */
108182 }
108183 sqlite3DbFree(db, zStartAff);
108184 sqlite3DbFree(db, zEndAff);
108185
108186 /* Top of the loop body */
108187 pLevel->p2 = sqlite3VdbeCurrentAddr(v);
108188
108189 /* Check if the index cursor is past the end of the range. */
@@ -108284,11 +108306,11 @@
108306 */
108307 if( pWInfo->nLevel>1 ){
108308 int nNotReady; /* The number of notReady tables */
108309 struct SrcList_item *origSrc; /* Original list of tables */
108310 nNotReady = pWInfo->nLevel - iLevel - 1;
108311 pOrTab = sqlite3StackAllocRaw(db,
108312 sizeof(*pOrTab)+ nNotReady*sizeof(pOrTab->a[0]));
108313 if( pOrTab==0 ) return notReady;
108314 pOrTab->nAlloc = (u8)(nNotReady + 1);
108315 pOrTab->nSrc = pOrTab->nAlloc;
108316 memcpy(pOrTab->a, pTabItem, sizeof(*pTabItem));
@@ -108338,12 +108360,12 @@
108360 Expr *pExpr = pWC->a[iTerm].pExpr;
108361 if( &pWC->a[iTerm] == pTerm ) continue;
108362 if( ExprHasProperty(pExpr, EP_FromJoin) ) continue;
108363 if( pWC->a[iTerm].wtFlags & (TERM_ORINFO) ) continue;
108364 if( (pWC->a[iTerm].eOperator & WO_ALL)==0 ) continue;
108365 pExpr = sqlite3ExprDup(db, pExpr, 0);
108366 pAndExpr = sqlite3ExprAnd(db, pAndExpr, pExpr);
108367 }
108368 if( pAndExpr ){
108369 pAndExpr = sqlite3PExpr(pParse, TK_AND, 0, pAndExpr, 0);
108370 }
108371 }
@@ -108359,11 +108381,11 @@
108381 }
108382 /* Loop through table entries that match term pOrTerm. */
108383 pSubWInfo = sqlite3WhereBegin(pParse, pOrTab, pOrExpr, 0, 0,
108384 WHERE_OMIT_OPEN_CLOSE | WHERE_AND_ONLY |
108385 WHERE_FORCE_TABLE | WHERE_ONETABLE_ONLY, iCovCur);
108386 assert( pSubWInfo || pParse->nErr || db->mallocFailed );
108387 if( pSubWInfo ){
108388 WhereLoop *pSubLoop;
108389 explainOneScan(
108390 pParse, pOrTab, &pSubWInfo->a[0], iLevel, pLevel->iFrom, 0
108391 );
@@ -108414,17 +108436,17 @@
108436 }
108437 pLevel->u.pCovidx = pCov;
108438 if( pCov ) pLevel->iIdxCur = iCovCur;
108439 if( pAndExpr ){
108440 pAndExpr->pLeft = 0;
108441 sqlite3ExprDelete(db, pAndExpr);
108442 }
108443 sqlite3VdbeChangeP1(v, iRetInit, sqlite3VdbeCurrentAddr(v));
108444 sqlite3VdbeAddOp2(v, OP_Goto, 0, pLevel->addrBrk);
108445 sqlite3VdbeResolveLabel(v, iLoopBody);
108446
108447 if( pWInfo->nLevel>1 ) sqlite3StackFree(db, pOrTab);
108448 if( !untestedTerms ) disableTerm(pLevel, pTerm);
108449 }else
108450 #endif /* SQLITE_OMIT_OR_OPTIMIZATION */
108451
108452 {
@@ -108475,13 +108497,12 @@
108497 ** and we are coding the t1 loop and the t2 loop has not yet coded,
108498 ** then we cannot use the "t1.a=t2.b" constraint, but we can code
108499 ** the implied "t1.a=123" constraint.
108500 */
108501 for(pTerm=pWC->a, j=pWC->nTerm; j>0; j--, pTerm++){
108502 Expr *pE, *pEAlt;
108503 WhereTerm *pAlt;
 
108504 if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
108505 if( pTerm->eOperator!=(WO_EQUIV|WO_EQ) ) continue;
108506 if( pTerm->leftCursor!=iCur ) continue;
108507 if( pLevel->iLeftJoin ) continue;
108508 pE = pTerm->pExpr;
@@ -108491,13 +108512,17 @@
108512 if( pAlt==0 ) continue;
108513 if( pAlt->wtFlags & (TERM_CODED) ) continue;
108514 testcase( pAlt->eOperator & WO_EQ );
108515 testcase( pAlt->eOperator & WO_IN );
108516 VdbeNoopComment((v, "begin transitive constraint"));
108517 pEAlt = sqlite3StackAllocRaw(db, sizeof(*pEAlt));
108518 if( pEAlt ){
108519 *pEAlt = *pAlt->pExpr;
108520 pEAlt->pLeft = pE->pLeft;
108521 sqlite3ExprIfFalse(pParse, pEAlt, addrCont, SQLITE_JUMPIFNULL);
108522 sqlite3StackFree(db, pEAlt);
108523 }
108524 }
108525
108526 /* For a LEFT OUTER JOIN, generate code that will record the fact that
108527 ** at least one row of the right table has matched the left table.
108528 */
@@ -116436,10 +116461,11 @@
116461 case SQLITE_IOERR_SHMLOCK: zName = "SQLITE_IOERR_SHMLOCK"; break;
116462 case SQLITE_IOERR_SHMMAP: zName = "SQLITE_IOERR_SHMMAP"; break;
116463 case SQLITE_IOERR_SEEK: zName = "SQLITE_IOERR_SEEK"; break;
116464 case SQLITE_IOERR_DELETE_NOENT: zName = "SQLITE_IOERR_DELETE_NOENT";break;
116465 case SQLITE_IOERR_MMAP: zName = "SQLITE_IOERR_MMAP"; break;
116466 case SQLITE_IOERR_GETTEMPPATH: zName = "SQLITE_IOERR_GETTEMPPATH"; break;
116467 case SQLITE_CORRUPT: zName = "SQLITE_CORRUPT"; break;
116468 case SQLITE_CORRUPT_VTAB: zName = "SQLITE_CORRUPT_VTAB"; break;
116469 case SQLITE_NOTFOUND: zName = "SQLITE_NOTFOUND"; break;
116470 case SQLITE_FULL: zName = "SQLITE_FULL"; break;
116471 case SQLITE_CANTOPEN: zName = "SQLITE_CANTOPEN"; break;
@@ -128264,11 +128290,11 @@
128290 }
128291
128292
128293 #ifdef SQLITE_TEST
128294
128295 #include <tcl.h>
128296 /* #include <string.h> */
128297
128298 /*
128299 ** Implementation of a special SQL scalar function for testing tokenizers
128300 ** designed to be used in concert with the Tcl testing framework. This
128301
+2 -1
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -107,11 +107,11 @@
107107
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
108108
** [sqlite_version()] and [sqlite_source_id()].
109109
*/
110110
#define SQLITE_VERSION "3.8.0"
111111
#define SQLITE_VERSION_NUMBER 3008000
112
-#define SQLITE_SOURCE_ID "2013-07-25 17:07:03 8bcbb33fd0a970e16a920e1d35571836dbb9ba50"
112
+#define SQLITE_SOURCE_ID "2013-07-31 23:28:36 136fc2931b156f91cdd76a7a009298cdf09d826a"
113113
114114
/*
115115
** CAPI3REF: Run-Time Library Version Numbers
116116
** KEYWORDS: sqlite3_version, sqlite3_sourceid
117117
**
@@ -476,10 +476,11 @@
476476
#define SQLITE_IOERR_SHMLOCK (SQLITE_IOERR | (20<<8))
477477
#define SQLITE_IOERR_SHMMAP (SQLITE_IOERR | (21<<8))
478478
#define SQLITE_IOERR_SEEK (SQLITE_IOERR | (22<<8))
479479
#define SQLITE_IOERR_DELETE_NOENT (SQLITE_IOERR | (23<<8))
480480
#define SQLITE_IOERR_MMAP (SQLITE_IOERR | (24<<8))
481
+#define SQLITE_IOERR_GETTEMPPATH (SQLITE_IOERR | (25<<8))
481482
#define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8))
482483
#define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8))
483484
#define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8))
484485
#define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8))
485486
#define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8))
486487
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -107,11 +107,11 @@
107 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
108 ** [sqlite_version()] and [sqlite_source_id()].
109 */
110 #define SQLITE_VERSION "3.8.0"
111 #define SQLITE_VERSION_NUMBER 3008000
112 #define SQLITE_SOURCE_ID "2013-07-25 17:07:03 8bcbb33fd0a970e16a920e1d35571836dbb9ba50"
113
114 /*
115 ** CAPI3REF: Run-Time Library Version Numbers
116 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
117 **
@@ -476,10 +476,11 @@
476 #define SQLITE_IOERR_SHMLOCK (SQLITE_IOERR | (20<<8))
477 #define SQLITE_IOERR_SHMMAP (SQLITE_IOERR | (21<<8))
478 #define SQLITE_IOERR_SEEK (SQLITE_IOERR | (22<<8))
479 #define SQLITE_IOERR_DELETE_NOENT (SQLITE_IOERR | (23<<8))
480 #define SQLITE_IOERR_MMAP (SQLITE_IOERR | (24<<8))
 
481 #define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8))
482 #define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8))
483 #define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8))
484 #define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8))
485 #define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8))
486
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -107,11 +107,11 @@
107 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
108 ** [sqlite_version()] and [sqlite_source_id()].
109 */
110 #define SQLITE_VERSION "3.8.0"
111 #define SQLITE_VERSION_NUMBER 3008000
112 #define SQLITE_SOURCE_ID "2013-07-31 23:28:36 136fc2931b156f91cdd76a7a009298cdf09d826a"
113
114 /*
115 ** CAPI3REF: Run-Time Library Version Numbers
116 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
117 **
@@ -476,10 +476,11 @@
476 #define SQLITE_IOERR_SHMLOCK (SQLITE_IOERR | (20<<8))
477 #define SQLITE_IOERR_SHMMAP (SQLITE_IOERR | (21<<8))
478 #define SQLITE_IOERR_SEEK (SQLITE_IOERR | (22<<8))
479 #define SQLITE_IOERR_DELETE_NOENT (SQLITE_IOERR | (23<<8))
480 #define SQLITE_IOERR_MMAP (SQLITE_IOERR | (24<<8))
481 #define SQLITE_IOERR_GETTEMPPATH (SQLITE_IOERR | (25<<8))
482 #define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8))
483 #define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8))
484 #define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8))
485 #define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8))
486 #define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8))
487
+2 -1
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -107,11 +107,11 @@
107107
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
108108
** [sqlite_version()] and [sqlite_source_id()].
109109
*/
110110
#define SQLITE_VERSION "3.8.0"
111111
#define SQLITE_VERSION_NUMBER 3008000
112
-#define SQLITE_SOURCE_ID "2013-07-25 17:07:03 8bcbb33fd0a970e16a920e1d35571836dbb9ba50"
112
+#define SQLITE_SOURCE_ID "2013-07-31 23:28:36 136fc2931b156f91cdd76a7a009298cdf09d826a"
113113
114114
/*
115115
** CAPI3REF: Run-Time Library Version Numbers
116116
** KEYWORDS: sqlite3_version, sqlite3_sourceid
117117
**
@@ -476,10 +476,11 @@
476476
#define SQLITE_IOERR_SHMLOCK (SQLITE_IOERR | (20<<8))
477477
#define SQLITE_IOERR_SHMMAP (SQLITE_IOERR | (21<<8))
478478
#define SQLITE_IOERR_SEEK (SQLITE_IOERR | (22<<8))
479479
#define SQLITE_IOERR_DELETE_NOENT (SQLITE_IOERR | (23<<8))
480480
#define SQLITE_IOERR_MMAP (SQLITE_IOERR | (24<<8))
481
+#define SQLITE_IOERR_GETTEMPPATH (SQLITE_IOERR | (25<<8))
481482
#define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8))
482483
#define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8))
483484
#define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8))
484485
#define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8))
485486
#define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8))
486487
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -107,11 +107,11 @@
107 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
108 ** [sqlite_version()] and [sqlite_source_id()].
109 */
110 #define SQLITE_VERSION "3.8.0"
111 #define SQLITE_VERSION_NUMBER 3008000
112 #define SQLITE_SOURCE_ID "2013-07-25 17:07:03 8bcbb33fd0a970e16a920e1d35571836dbb9ba50"
113
114 /*
115 ** CAPI3REF: Run-Time Library Version Numbers
116 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
117 **
@@ -476,10 +476,11 @@
476 #define SQLITE_IOERR_SHMLOCK (SQLITE_IOERR | (20<<8))
477 #define SQLITE_IOERR_SHMMAP (SQLITE_IOERR | (21<<8))
478 #define SQLITE_IOERR_SEEK (SQLITE_IOERR | (22<<8))
479 #define SQLITE_IOERR_DELETE_NOENT (SQLITE_IOERR | (23<<8))
480 #define SQLITE_IOERR_MMAP (SQLITE_IOERR | (24<<8))
 
481 #define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8))
482 #define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8))
483 #define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8))
484 #define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8))
485 #define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8))
486
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -107,11 +107,11 @@
107 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
108 ** [sqlite_version()] and [sqlite_source_id()].
109 */
110 #define SQLITE_VERSION "3.8.0"
111 #define SQLITE_VERSION_NUMBER 3008000
112 #define SQLITE_SOURCE_ID "2013-07-31 23:28:36 136fc2931b156f91cdd76a7a009298cdf09d826a"
113
114 /*
115 ** CAPI3REF: Run-Time Library Version Numbers
116 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
117 **
@@ -476,10 +476,11 @@
476 #define SQLITE_IOERR_SHMLOCK (SQLITE_IOERR | (20<<8))
477 #define SQLITE_IOERR_SHMMAP (SQLITE_IOERR | (21<<8))
478 #define SQLITE_IOERR_SEEK (SQLITE_IOERR | (22<<8))
479 #define SQLITE_IOERR_DELETE_NOENT (SQLITE_IOERR | (23<<8))
480 #define SQLITE_IOERR_MMAP (SQLITE_IOERR | (24<<8))
481 #define SQLITE_IOERR_GETTEMPPATH (SQLITE_IOERR | (25<<8))
482 #define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8))
483 #define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8))
484 #define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8))
485 #define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8))
486 #define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8))
487
--- src/timeline.c
+++ src/timeline.c
@@ -2202,10 +2202,11 @@
22022202
}
22032203
}
22042204
22052205
/*
22062206
** WEBPAGE: stats_report
2207
+** WEBPAGE: reports
22072208
**
22082209
** Shows activity reports for the repository.
22092210
**
22102211
** Query Parameters:
22112212
**
22122213
--- src/timeline.c
+++ src/timeline.c
@@ -2202,10 +2202,11 @@
2202 }
2203 }
2204
2205 /*
2206 ** WEBPAGE: stats_report
 
2207 **
2208 ** Shows activity reports for the repository.
2209 **
2210 ** Query Parameters:
2211 **
2212
--- src/timeline.c
+++ src/timeline.c
@@ -2202,10 +2202,11 @@
2202 }
2203 }
2204
2205 /*
2206 ** WEBPAGE: stats_report
2207 ** WEBPAGE: reports
2208 **
2209 ** Shows activity reports for the repository.
2210 **
2211 ** Query Parameters:
2212 **
2213
+2 -2
--- src/vfile.c
+++ src/vfile.c
@@ -213,11 +213,11 @@
213213
blob_zero(&fileCksum);
214214
}
215215
if( blob_compare(&fileCksum, &origCksum)==0 ) chnged = 0;
216216
blob_reset(&origCksum);
217217
blob_reset(&fileCksum);
218
- }else if( (chnged==0 || chnged==2)
218
+ }else if( (chnged==0 || chnged==2 || chnged==4)
219219
&& (useMtime==0 || currentMtime!=oldMtime) ){
220220
/* For files that were formerly believed to be unchanged or that were
221221
** changed by merging, if their mtime changes, or unconditionally
222222
** if --sha1sum is used, check to see if they have been edited by
223223
** looking at their SHA1 sum */
@@ -230,11 +230,11 @@
230230
chnged = 1;
231231
}
232232
blob_reset(&origCksum);
233233
blob_reset(&fileCksum);
234234
}
235
- if( (cksigFlags & CKSIG_SETMTIME) && (chnged==0 || chnged==2) ){
235
+ if( (cksigFlags & CKSIG_SETMTIME) && (chnged==0 || chnged==2 || chnged==4) ){
236236
i64 desiredMtime;
237237
if( mtime_of_manifest_file(vid,rid,&desiredMtime)==0 ){
238238
if( currentMtime!=desiredMtime ){
239239
file_set_mtime(zName, desiredMtime);
240240
currentMtime = file_wd_mtime(zName);
241241
--- src/vfile.c
+++ src/vfile.c
@@ -213,11 +213,11 @@
213 blob_zero(&fileCksum);
214 }
215 if( blob_compare(&fileCksum, &origCksum)==0 ) chnged = 0;
216 blob_reset(&origCksum);
217 blob_reset(&fileCksum);
218 }else if( (chnged==0 || chnged==2)
219 && (useMtime==0 || currentMtime!=oldMtime) ){
220 /* For files that were formerly believed to be unchanged or that were
221 ** changed by merging, if their mtime changes, or unconditionally
222 ** if --sha1sum is used, check to see if they have been edited by
223 ** looking at their SHA1 sum */
@@ -230,11 +230,11 @@
230 chnged = 1;
231 }
232 blob_reset(&origCksum);
233 blob_reset(&fileCksum);
234 }
235 if( (cksigFlags & CKSIG_SETMTIME) && (chnged==0 || chnged==2) ){
236 i64 desiredMtime;
237 if( mtime_of_manifest_file(vid,rid,&desiredMtime)==0 ){
238 if( currentMtime!=desiredMtime ){
239 file_set_mtime(zName, desiredMtime);
240 currentMtime = file_wd_mtime(zName);
241
--- src/vfile.c
+++ src/vfile.c
@@ -213,11 +213,11 @@
213 blob_zero(&fileCksum);
214 }
215 if( blob_compare(&fileCksum, &origCksum)==0 ) chnged = 0;
216 blob_reset(&origCksum);
217 blob_reset(&fileCksum);
218 }else if( (chnged==0 || chnged==2 || chnged==4)
219 && (useMtime==0 || currentMtime!=oldMtime) ){
220 /* For files that were formerly believed to be unchanged or that were
221 ** changed by merging, if their mtime changes, or unconditionally
222 ** if --sha1sum is used, check to see if they have been edited by
223 ** looking at their SHA1 sum */
@@ -230,11 +230,11 @@
230 chnged = 1;
231 }
232 blob_reset(&origCksum);
233 blob_reset(&fileCksum);
234 }
235 if( (cksigFlags & CKSIG_SETMTIME) && (chnged==0 || chnged==2 || chnged==4) ){
236 i64 desiredMtime;
237 if( mtime_of_manifest_file(vid,rid,&desiredMtime)==0 ){
238 if( currentMtime!=desiredMtime ){
239 file_set_mtime(zName, desiredMtime);
240 currentMtime = file_wd_mtime(zName);
241
--- www/adding_code.wiki
+++ www/adding_code.wiki
@@ -153,11 +153,11 @@
153153
the output text, if desired. But "fossil_print()" is recommended as
154154
it has extra logic to insert \r characters at the right times on
155155
windows systems.
156156
157157
Once you have the command running, you can then start adding code to
158
-make it do useful things. There are logs of utility functions in
158
+make it do useful things. There are lots of utility functions in
159159
Fossil for parsing command-line options and for
160160
opening and accessing and manipulating the repository and
161161
the working check-out. Study at the implementations of existing commands
162162
to get an idea of how things are done. You can easily find the implementations
163163
of existing commands by searching for "COMMAND: <i>name</i>" in the
164164
--- www/adding_code.wiki
+++ www/adding_code.wiki
@@ -153,11 +153,11 @@
153 the output text, if desired. But "fossil_print()" is recommended as
154 it has extra logic to insert \r characters at the right times on
155 windows systems.
156
157 Once you have the command running, you can then start adding code to
158 make it do useful things. There are logs of utility functions in
159 Fossil for parsing command-line options and for
160 opening and accessing and manipulating the repository and
161 the working check-out. Study at the implementations of existing commands
162 to get an idea of how things are done. You can easily find the implementations
163 of existing commands by searching for "COMMAND: <i>name</i>" in the
164
--- www/adding_code.wiki
+++ www/adding_code.wiki
@@ -153,11 +153,11 @@
153 the output text, if desired. But "fossil_print()" is recommended as
154 it has extra logic to insert \r characters at the right times on
155 windows systems.
156
157 Once you have the command running, you can then start adding code to
158 make it do useful things. There are lots of utility functions in
159 Fossil for parsing command-line options and for
160 opening and accessing and manipulating the repository and
161 the working check-out. Study at the implementations of existing commands
162 to get an idea of how things are done. You can easily find the implementations
163 of existing commands by searching for "COMMAND: <i>name</i>" in the
164
--- www/changes.wiki
+++ www/changes.wiki
@@ -3,10 +3,15 @@
33
<h2>Changes For Version 1.27 (as yet unreleased)</h2>
44
* Enhance the [/help?cmd=changes | fossil changes],
55
[/help?cmd=clean | fossil clean], [/help?cmd=extras | fossil extras],
66
[/help?cmd=ls | fossil ls] and [/help?cmd=status | fossil status] commands
77
to restrict operation to files and directories named on the command-line.
8
+ * New --integrate option to [/help?cmd=merge | fossil merge], which
9
+ automatically closes the merged branch when committing.
10
+ * Renamed <tt>/stats_report</tt> page to [/reports].
11
+ * Added <tt>yw=YYYY-WW</tt> (year-week) filter to timeline to limit the results
12
+ to a specific year and calendar week number, e.g. [/timeline?yw=2013-01].
813
914
<h2>Changes For Version 1.26 (2013-06-18)</h2>
1015
* The argument to the --port option for the [/help?cmd=ui | fossil ui] and
1116
[/help?cmd=server | fossil server] commands can take an IP address in addition
1217
to the port number, causing Fossil to bind to just that one IP address.
1318
--- www/changes.wiki
+++ www/changes.wiki
@@ -3,10 +3,15 @@
3 <h2>Changes For Version 1.27 (as yet unreleased)</h2>
4 * Enhance the [/help?cmd=changes | fossil changes],
5 [/help?cmd=clean | fossil clean], [/help?cmd=extras | fossil extras],
6 [/help?cmd=ls | fossil ls] and [/help?cmd=status | fossil status] commands
7 to restrict operation to files and directories named on the command-line.
 
 
 
 
 
8
9 <h2>Changes For Version 1.26 (2013-06-18)</h2>
10 * The argument to the --port option for the [/help?cmd=ui | fossil ui] and
11 [/help?cmd=server | fossil server] commands can take an IP address in addition
12 to the port number, causing Fossil to bind to just that one IP address.
13
--- www/changes.wiki
+++ www/changes.wiki
@@ -3,10 +3,15 @@
3 <h2>Changes For Version 1.27 (as yet unreleased)</h2>
4 * Enhance the [/help?cmd=changes | fossil changes],
5 [/help?cmd=clean | fossil clean], [/help?cmd=extras | fossil extras],
6 [/help?cmd=ls | fossil ls] and [/help?cmd=status | fossil status] commands
7 to restrict operation to files and directories named on the command-line.
8 * New --integrate option to [/help?cmd=merge | fossil merge], which
9 automatically closes the merged branch when committing.
10 * Renamed <tt>/stats_report</tt> page to [/reports].
11 * Added <tt>yw=YYYY-WW</tt> (year-week) filter to timeline to limit the results
12 to a specific year and calendar week number, e.g. [/timeline?yw=2013-01].
13
14 <h2>Changes For Version 1.26 (2013-06-18)</h2>
15 * The argument to the --port option for the [/help?cmd=ui | fossil ui] and
16 [/help?cmd=server | fossil server] commands can take an IP address in addition
17 to the port number, causing Fossil to bind to just that one IP address.
18

Keyboard Shortcuts

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