Fossil SCM

Merge all recent trunk changes into the clear-title branch (since we hold clear title on all recent changes.)

drh 2010-04-02 20:09 clear-title merge
Commit 64541535d92a6fdb5898bf9558982e5fff1b5bf2
+4 -1
--- src/attach.c
+++ src/attach.c
@@ -30,13 +30,16 @@
3030
/*
3131
** WEBPAGE: attachlist
3232
**
3333
** tkt=TICKETUUID
3434
** page=WIKIPAGE
35
-** all
3635
**
3736
** List attachments.
37
+** Either one of tkt= or page= are supplied or neither. If neither
38
+** are given, all attachments are listed. If one is given, only
39
+** attachments for the designated ticket or wiki page are shown.
40
+** TICKETUUID must be complete
3841
*/
3942
void attachlist_page(void){
4043
const char *zPage = P("page");
4144
const char *zTkt = P("tkt");
4245
Blob sql;
4346
--- src/attach.c
+++ src/attach.c
@@ -30,13 +30,16 @@
30 /*
31 ** WEBPAGE: attachlist
32 **
33 ** tkt=TICKETUUID
34 ** page=WIKIPAGE
35 ** all
36 **
37 ** List attachments.
 
 
 
 
38 */
39 void attachlist_page(void){
40 const char *zPage = P("page");
41 const char *zTkt = P("tkt");
42 Blob sql;
43
--- src/attach.c
+++ src/attach.c
@@ -30,13 +30,16 @@
30 /*
31 ** WEBPAGE: attachlist
32 **
33 ** tkt=TICKETUUID
34 ** page=WIKIPAGE
 
35 **
36 ** List attachments.
37 ** Either one of tkt= or page= are supplied or neither. If neither
38 ** are given, all attachments are listed. If one is given, only
39 ** attachments for the designated ticket or wiki page are shown.
40 ** TICKETUUID must be complete
41 */
42 void attachlist_page(void){
43 const char *zPage = P("page");
44 const char *zTkt = P("tkt");
45 Blob sql;
46
+3 -3
--- src/branch.c
+++ src/branch.c
@@ -122,11 +122,11 @@
122122
" AND tagtype>0 AND tagname GLOB 'sym-*'"
123123
" ORDER BY tagname",
124124
rootid);
125125
while( db_step(&q)==SQLITE_ROW ){
126126
const char *zTag = db_column_text(&q, 0);
127
- blob_appendf(&branch, "T -%F *\n", zTag);
127
+ blob_appendf(&branch, "T -%F *\n", zTag);
128128
}
129129
db_finalize(&q);
130130
131131
blob_appendf(&branch, "U %F\n", g.zLogin);
132132
md5sum_blob(&branch, &mcksum);
@@ -246,11 +246,11 @@
246246
247247
db_prepare(&q,
248248
"SELECT DISTINCT value FROM tagxref"
249249
" WHERE tagid=%d AND value NOT NULL"
250250
" AND rid IN leaves"
251
- " ORDER BY value",
251
+ " ORDER BY value /*sort*/",
252252
TAG_BRANCH
253253
);
254254
cnt = 0;
255255
while( db_step(&q)==SQLITE_ROW ){
256256
const char *zBr = db_column_text(&q, 0);
@@ -275,11 +275,11 @@
275275
" WHERE tagid=%d AND value NOT NULL"
276276
" EXCEPT "
277277
"SELECT value FROM tagxref"
278278
" WHERE tagid=%d AND value NOT NULL"
279279
" AND rid IN leaves"
280
- " ORDER BY value",
280
+ " ORDER BY value /*sort*/",
281281
TAG_BRANCH, TAG_BRANCH
282282
);
283283
while( db_step(&q)==SQLITE_ROW ){
284284
const char *zBr = db_column_text(&q, 0);
285285
if( cnt==0 ){
286286
--- src/branch.c
+++ src/branch.c
@@ -122,11 +122,11 @@
122 " AND tagtype>0 AND tagname GLOB 'sym-*'"
123 " ORDER BY tagname",
124 rootid);
125 while( db_step(&q)==SQLITE_ROW ){
126 const char *zTag = db_column_text(&q, 0);
127 blob_appendf(&branch, "T -%F *\n", zTag);
128 }
129 db_finalize(&q);
130
131 blob_appendf(&branch, "U %F\n", g.zLogin);
132 md5sum_blob(&branch, &mcksum);
@@ -246,11 +246,11 @@
246
247 db_prepare(&q,
248 "SELECT DISTINCT value FROM tagxref"
249 " WHERE tagid=%d AND value NOT NULL"
250 " AND rid IN leaves"
251 " ORDER BY value",
252 TAG_BRANCH
253 );
254 cnt = 0;
255 while( db_step(&q)==SQLITE_ROW ){
256 const char *zBr = db_column_text(&q, 0);
@@ -275,11 +275,11 @@
275 " WHERE tagid=%d AND value NOT NULL"
276 " EXCEPT "
277 "SELECT value FROM tagxref"
278 " WHERE tagid=%d AND value NOT NULL"
279 " AND rid IN leaves"
280 " ORDER BY value",
281 TAG_BRANCH, TAG_BRANCH
282 );
283 while( db_step(&q)==SQLITE_ROW ){
284 const char *zBr = db_column_text(&q, 0);
285 if( cnt==0 ){
286
--- src/branch.c
+++ src/branch.c
@@ -122,11 +122,11 @@
122 " AND tagtype>0 AND tagname GLOB 'sym-*'"
123 " ORDER BY tagname",
124 rootid);
125 while( db_step(&q)==SQLITE_ROW ){
126 const char *zTag = db_column_text(&q, 0);
127 blob_appendf(&branch, "T -%F *\n", zTag);
128 }
129 db_finalize(&q);
130
131 blob_appendf(&branch, "U %F\n", g.zLogin);
132 md5sum_blob(&branch, &mcksum);
@@ -246,11 +246,11 @@
246
247 db_prepare(&q,
248 "SELECT DISTINCT value FROM tagxref"
249 " WHERE tagid=%d AND value NOT NULL"
250 " AND rid IN leaves"
251 " ORDER BY value /*sort*/",
252 TAG_BRANCH
253 );
254 cnt = 0;
255 while( db_step(&q)==SQLITE_ROW ){
256 const char *zBr = db_column_text(&q, 0);
@@ -275,11 +275,11 @@
275 " WHERE tagid=%d AND value NOT NULL"
276 " EXCEPT "
277 "SELECT value FROM tagxref"
278 " WHERE tagid=%d AND value NOT NULL"
279 " AND rid IN leaves"
280 " ORDER BY value /*sort*/",
281 TAG_BRANCH, TAG_BRANCH
282 );
283 while( db_step(&q)==SQLITE_ROW ){
284 const char *zBr = db_column_text(&q, 0);
285 if( cnt==0 ){
286
+3 -3
--- src/branch.c
+++ src/branch.c
@@ -122,11 +122,11 @@
122122
" AND tagtype>0 AND tagname GLOB 'sym-*'"
123123
" ORDER BY tagname",
124124
rootid);
125125
while( db_step(&q)==SQLITE_ROW ){
126126
const char *zTag = db_column_text(&q, 0);
127
- blob_appendf(&branch, "T -%F *\n", zTag);
127
+ blob_appendf(&branch, "T -%F *\n", zTag);
128128
}
129129
db_finalize(&q);
130130
131131
blob_appendf(&branch, "U %F\n", g.zLogin);
132132
md5sum_blob(&branch, &mcksum);
@@ -246,11 +246,11 @@
246246
247247
db_prepare(&q,
248248
"SELECT DISTINCT value FROM tagxref"
249249
" WHERE tagid=%d AND value NOT NULL"
250250
" AND rid IN leaves"
251
- " ORDER BY value",
251
+ " ORDER BY value /*sort*/",
252252
TAG_BRANCH
253253
);
254254
cnt = 0;
255255
while( db_step(&q)==SQLITE_ROW ){
256256
const char *zBr = db_column_text(&q, 0);
@@ -275,11 +275,11 @@
275275
" WHERE tagid=%d AND value NOT NULL"
276276
" EXCEPT "
277277
"SELECT value FROM tagxref"
278278
" WHERE tagid=%d AND value NOT NULL"
279279
" AND rid IN leaves"
280
- " ORDER BY value",
280
+ " ORDER BY value /*sort*/",
281281
TAG_BRANCH, TAG_BRANCH
282282
);
283283
while( db_step(&q)==SQLITE_ROW ){
284284
const char *zBr = db_column_text(&q, 0);
285285
if( cnt==0 ){
286286
--- src/branch.c
+++ src/branch.c
@@ -122,11 +122,11 @@
122 " AND tagtype>0 AND tagname GLOB 'sym-*'"
123 " ORDER BY tagname",
124 rootid);
125 while( db_step(&q)==SQLITE_ROW ){
126 const char *zTag = db_column_text(&q, 0);
127 blob_appendf(&branch, "T -%F *\n", zTag);
128 }
129 db_finalize(&q);
130
131 blob_appendf(&branch, "U %F\n", g.zLogin);
132 md5sum_blob(&branch, &mcksum);
@@ -246,11 +246,11 @@
246
247 db_prepare(&q,
248 "SELECT DISTINCT value FROM tagxref"
249 " WHERE tagid=%d AND value NOT NULL"
250 " AND rid IN leaves"
251 " ORDER BY value",
252 TAG_BRANCH
253 );
254 cnt = 0;
255 while( db_step(&q)==SQLITE_ROW ){
256 const char *zBr = db_column_text(&q, 0);
@@ -275,11 +275,11 @@
275 " WHERE tagid=%d AND value NOT NULL"
276 " EXCEPT "
277 "SELECT value FROM tagxref"
278 " WHERE tagid=%d AND value NOT NULL"
279 " AND rid IN leaves"
280 " ORDER BY value",
281 TAG_BRANCH, TAG_BRANCH
282 );
283 while( db_step(&q)==SQLITE_ROW ){
284 const char *zBr = db_column_text(&q, 0);
285 if( cnt==0 ){
286
--- src/branch.c
+++ src/branch.c
@@ -122,11 +122,11 @@
122 " AND tagtype>0 AND tagname GLOB 'sym-*'"
123 " ORDER BY tagname",
124 rootid);
125 while( db_step(&q)==SQLITE_ROW ){
126 const char *zTag = db_column_text(&q, 0);
127 blob_appendf(&branch, "T -%F *\n", zTag);
128 }
129 db_finalize(&q);
130
131 blob_appendf(&branch, "U %F\n", g.zLogin);
132 md5sum_blob(&branch, &mcksum);
@@ -246,11 +246,11 @@
246
247 db_prepare(&q,
248 "SELECT DISTINCT value FROM tagxref"
249 " WHERE tagid=%d AND value NOT NULL"
250 " AND rid IN leaves"
251 " ORDER BY value /*sort*/",
252 TAG_BRANCH
253 );
254 cnt = 0;
255 while( db_step(&q)==SQLITE_ROW ){
256 const char *zBr = db_column_text(&q, 0);
@@ -275,11 +275,11 @@
275 " WHERE tagid=%d AND value NOT NULL"
276 " EXCEPT "
277 "SELECT value FROM tagxref"
278 " WHERE tagid=%d AND value NOT NULL"
279 " AND rid IN leaves"
280 " ORDER BY value /*sort*/",
281 TAG_BRANCH, TAG_BRANCH
282 );
283 while( db_step(&q)==SQLITE_ROW ){
284 const char *zBr = db_column_text(&q, 0);
285 if( cnt==0 ){
286
+6 -6
--- src/browse.c
+++ src/browse.c
@@ -150,14 +150,14 @@
150150
char zShort[20];
151151
memcpy(zShort, zUuid, 10);
152152
zShort[10] = 0;
153153
@ <h2>Files of check-in [<a href="vinfo?name=%T(zUuid)">%s(zShort)</a>]
154154
@ %s(blob_str(&dirname))</h2>
155
- zSubdirLink = mprintf("%s/dir?ci=%s&name=%T", g.zBaseURL, zUuid, zPrefix);
155
+ zSubdirLink = mprintf("%s/dir?ci=%S&name=%T", g.zTop, zUuid, zPrefix);
156156
if( zD ){
157
- style_submenu_element("Top", "Top", "%s/dir?ci=%s", g.zBaseURL, zUuid);
158
- style_submenu_element("All", "All", "%s/dir?name=%t", g.zBaseURL, zD);
157
+ style_submenu_element("Top", "Top", "%s/dir?ci=%S", g.zTop, zUuid);
158
+ style_submenu_element("All", "All", "%s/dir?name=%t", g.zTop, zD);
159159
}else{
160160
style_submenu_element("All", "All", "%s/dir", g.zBaseURL);
161161
}
162162
}else{
163163
@ <h2>The union of all files from all check-ins
@@ -217,15 +217,15 @@
217217
}
218218
219219
/* Generate a multi-column table listing the contents of zD[]
220220
** directory.
221221
*/
222
- mxLen = db_int(12, "SELECT max(length(x)) FROM localfiles");
223
- cnt = db_int(0, "SELECT count(*) FROM localfiles");
222
+ mxLen = db_int(12, "SELECT max(length(x)) FROM localfiles /*scan*/");
223
+ cnt = db_int(0, "SELECT count(*) FROM localfiles /*scan*/");
224224
nCol = 4;
225225
nRow = (cnt+nCol-1)/nCol;
226
- db_prepare(&q, "SELECT x, u FROM localfiles ORDER BY x");
226
+ db_prepare(&q, "SELECT x, u FROM localfiles ORDER BY x /*scan*/");
227227
@ <table border="0" width="100%%"><tr><td valign="top" width="25%%">
228228
i = 0;
229229
while( db_step(&q)==SQLITE_ROW ){
230230
const char *zFN;
231231
if( i==nRow ){
232232
--- src/browse.c
+++ src/browse.c
@@ -150,14 +150,14 @@
150 char zShort[20];
151 memcpy(zShort, zUuid, 10);
152 zShort[10] = 0;
153 @ <h2>Files of check-in [<a href="vinfo?name=%T(zUuid)">%s(zShort)</a>]
154 @ %s(blob_str(&dirname))</h2>
155 zSubdirLink = mprintf("%s/dir?ci=%s&name=%T", g.zBaseURL, zUuid, zPrefix);
156 if( zD ){
157 style_submenu_element("Top", "Top", "%s/dir?ci=%s", g.zBaseURL, zUuid);
158 style_submenu_element("All", "All", "%s/dir?name=%t", g.zBaseURL, zD);
159 }else{
160 style_submenu_element("All", "All", "%s/dir", g.zBaseURL);
161 }
162 }else{
163 @ <h2>The union of all files from all check-ins
@@ -217,15 +217,15 @@
217 }
218
219 /* Generate a multi-column table listing the contents of zD[]
220 ** directory.
221 */
222 mxLen = db_int(12, "SELECT max(length(x)) FROM localfiles");
223 cnt = db_int(0, "SELECT count(*) FROM localfiles");
224 nCol = 4;
225 nRow = (cnt+nCol-1)/nCol;
226 db_prepare(&q, "SELECT x, u FROM localfiles ORDER BY x");
227 @ <table border="0" width="100%%"><tr><td valign="top" width="25%%">
228 i = 0;
229 while( db_step(&q)==SQLITE_ROW ){
230 const char *zFN;
231 if( i==nRow ){
232
--- src/browse.c
+++ src/browse.c
@@ -150,14 +150,14 @@
150 char zShort[20];
151 memcpy(zShort, zUuid, 10);
152 zShort[10] = 0;
153 @ <h2>Files of check-in [<a href="vinfo?name=%T(zUuid)">%s(zShort)</a>]
154 @ %s(blob_str(&dirname))</h2>
155 zSubdirLink = mprintf("%s/dir?ci=%S&name=%T", g.zTop, zUuid, zPrefix);
156 if( zD ){
157 style_submenu_element("Top", "Top", "%s/dir?ci=%S", g.zTop, zUuid);
158 style_submenu_element("All", "All", "%s/dir?name=%t", g.zTop, zD);
159 }else{
160 style_submenu_element("All", "All", "%s/dir", g.zBaseURL);
161 }
162 }else{
163 @ <h2>The union of all files from all check-ins
@@ -217,15 +217,15 @@
217 }
218
219 /* Generate a multi-column table listing the contents of zD[]
220 ** directory.
221 */
222 mxLen = db_int(12, "SELECT max(length(x)) FROM localfiles /*scan*/");
223 cnt = db_int(0, "SELECT count(*) FROM localfiles /*scan*/");
224 nCol = 4;
225 nRow = (cnt+nCol-1)/nCol;
226 db_prepare(&q, "SELECT x, u FROM localfiles ORDER BY x /*scan*/");
227 @ <table border="0" width="100%%"><tr><td valign="top" width="25%%">
228 i = 0;
229 while( db_step(&q)==SQLITE_ROW ){
230 const char *zFN;
231 if( i==nRow ){
232
+27 -1
--- src/db.c
+++ src/db.c
@@ -48,10 +48,11 @@
4848
*/
4949
struct Stmt {
5050
Blob sql; /* The SQL for this statement */
5151
sqlite3_stmt *pStmt; /* The results of sqlite3_prepare() */
5252
Stmt *pNext, *pPrev; /* List of all unfinalized statements */
53
+ int nStep; /* Number of sqlite3_step() calls */
5354
};
5455
#endif /* INTERFACE */
5556
5657
/*
5758
** Call this routine when a database error occurs.
@@ -191,10 +192,11 @@
191192
zSql = blob_str(&pStmt->sql);
192193
if( sqlite3_prepare_v2(g.db, zSql, -1, &pStmt->pStmt, 0)!=0 ){
193194
db_err("%s\n%s", sqlite3_errmsg(g.db), zSql);
194195
}
195196
pStmt->pNext = pStmt->pPrev = 0;
197
+ pStmt->nStep = 0;
196198
return 0;
197199
}
198200
int db_prepare(Stmt *pStmt, const char *zFormat, ...){
199201
int rc;
200202
va_list ap;
@@ -266,23 +268,46 @@
266268
** or SQLITE_OK if the statement finishes successfully.
267269
*/
268270
int db_step(Stmt *pStmt){
269271
int rc;
270272
rc = sqlite3_step(pStmt->pStmt);
273
+ pStmt->nStep++;
271274
return rc;
272275
}
276
+
277
+/*
278
+** Print warnings if a query is inefficient.
279
+*/
280
+static void db_stats(Stmt *pStmt){
281
+#ifdef FOSSIL_DEBUG
282
+ int c1, c2;
283
+ const char *zSql = sqlite3_sql(pStmt->pStmt);
284
+ if( zSql==0 ) return;
285
+ c1 = sqlite3_stmt_status(pStmt->pStmt, SQLITE_STMTSTATUS_FULLSCAN_STEP, 1);
286
+ c2 = sqlite3_stmt_status(pStmt->pStmt, SQLITE_STMTSTATUS_SORT, 1);
287
+ if( c1>pStmt->nStep*4 && strstr(zSql,"/*scan*/")==0 ){
288
+ fossil_warning("%d scan steps for %d rows in [%s]", c1, pStmt->nStep, zSql);
289
+ }else if( c2 && strstr(zSql,"/*sort*/")==0 && strstr(zSql,"/*scan*/")==0 ){
290
+ fossil_warning("sort w/o index in [%s]", zSql);
291
+ }
292
+ pStmt->nStep = 0;
293
+#endif
294
+}
273295
274296
/*
275297
** Reset or finalize a statement.
276298
*/
277299
int db_reset(Stmt *pStmt){
278
- int rc = sqlite3_reset(pStmt->pStmt);
300
+ int rc;
301
+ db_stats(pStmt);
302
+ rc = sqlite3_reset(pStmt->pStmt);
279303
db_check_result(rc);
280304
return rc;
281305
}
282306
int db_finalize(Stmt *pStmt){
283307
int rc;
308
+ db_stats(pStmt);
284309
blob_reset(&pStmt->sql);
285310
rc = sqlite3_finalize(pStmt->pStmt);
286311
db_check_result(rc);
287312
pStmt->pStmt = 0;
288313
if( pStmt->pNext ){
@@ -1188,10 +1213,11 @@
11881213
** so this routine is a no-op.
11891214
*/
11901215
void db_swap_connections(void){
11911216
if( !g.useAttach ){
11921217
sqlite3 *dbTemp = g.db;
1218
+ assert( g.dbConfig!=0 );
11931219
g.db = g.dbConfig;
11941220
g.dbConfig = dbTemp;
11951221
}
11961222
}
11971223
11981224
--- src/db.c
+++ src/db.c
@@ -48,10 +48,11 @@
48 */
49 struct Stmt {
50 Blob sql; /* The SQL for this statement */
51 sqlite3_stmt *pStmt; /* The results of sqlite3_prepare() */
52 Stmt *pNext, *pPrev; /* List of all unfinalized statements */
 
53 };
54 #endif /* INTERFACE */
55
56 /*
57 ** Call this routine when a database error occurs.
@@ -191,10 +192,11 @@
191 zSql = blob_str(&pStmt->sql);
192 if( sqlite3_prepare_v2(g.db, zSql, -1, &pStmt->pStmt, 0)!=0 ){
193 db_err("%s\n%s", sqlite3_errmsg(g.db), zSql);
194 }
195 pStmt->pNext = pStmt->pPrev = 0;
 
196 return 0;
197 }
198 int db_prepare(Stmt *pStmt, const char *zFormat, ...){
199 int rc;
200 va_list ap;
@@ -266,23 +268,46 @@
266 ** or SQLITE_OK if the statement finishes successfully.
267 */
268 int db_step(Stmt *pStmt){
269 int rc;
270 rc = sqlite3_step(pStmt->pStmt);
 
271 return rc;
272 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
273
274 /*
275 ** Reset or finalize a statement.
276 */
277 int db_reset(Stmt *pStmt){
278 int rc = sqlite3_reset(pStmt->pStmt);
 
 
279 db_check_result(rc);
280 return rc;
281 }
282 int db_finalize(Stmt *pStmt){
283 int rc;
 
284 blob_reset(&pStmt->sql);
285 rc = sqlite3_finalize(pStmt->pStmt);
286 db_check_result(rc);
287 pStmt->pStmt = 0;
288 if( pStmt->pNext ){
@@ -1188,10 +1213,11 @@
1188 ** so this routine is a no-op.
1189 */
1190 void db_swap_connections(void){
1191 if( !g.useAttach ){
1192 sqlite3 *dbTemp = g.db;
 
1193 g.db = g.dbConfig;
1194 g.dbConfig = dbTemp;
1195 }
1196 }
1197
1198
--- src/db.c
+++ src/db.c
@@ -48,10 +48,11 @@
48 */
49 struct Stmt {
50 Blob sql; /* The SQL for this statement */
51 sqlite3_stmt *pStmt; /* The results of sqlite3_prepare() */
52 Stmt *pNext, *pPrev; /* List of all unfinalized statements */
53 int nStep; /* Number of sqlite3_step() calls */
54 };
55 #endif /* INTERFACE */
56
57 /*
58 ** Call this routine when a database error occurs.
@@ -191,10 +192,11 @@
192 zSql = blob_str(&pStmt->sql);
193 if( sqlite3_prepare_v2(g.db, zSql, -1, &pStmt->pStmt, 0)!=0 ){
194 db_err("%s\n%s", sqlite3_errmsg(g.db), zSql);
195 }
196 pStmt->pNext = pStmt->pPrev = 0;
197 pStmt->nStep = 0;
198 return 0;
199 }
200 int db_prepare(Stmt *pStmt, const char *zFormat, ...){
201 int rc;
202 va_list ap;
@@ -266,23 +268,46 @@
268 ** or SQLITE_OK if the statement finishes successfully.
269 */
270 int db_step(Stmt *pStmt){
271 int rc;
272 rc = sqlite3_step(pStmt->pStmt);
273 pStmt->nStep++;
274 return rc;
275 }
276
277 /*
278 ** Print warnings if a query is inefficient.
279 */
280 static void db_stats(Stmt *pStmt){
281 #ifdef FOSSIL_DEBUG
282 int c1, c2;
283 const char *zSql = sqlite3_sql(pStmt->pStmt);
284 if( zSql==0 ) return;
285 c1 = sqlite3_stmt_status(pStmt->pStmt, SQLITE_STMTSTATUS_FULLSCAN_STEP, 1);
286 c2 = sqlite3_stmt_status(pStmt->pStmt, SQLITE_STMTSTATUS_SORT, 1);
287 if( c1>pStmt->nStep*4 && strstr(zSql,"/*scan*/")==0 ){
288 fossil_warning("%d scan steps for %d rows in [%s]", c1, pStmt->nStep, zSql);
289 }else if( c2 && strstr(zSql,"/*sort*/")==0 && strstr(zSql,"/*scan*/")==0 ){
290 fossil_warning("sort w/o index in [%s]", zSql);
291 }
292 pStmt->nStep = 0;
293 #endif
294 }
295
296 /*
297 ** Reset or finalize a statement.
298 */
299 int db_reset(Stmt *pStmt){
300 int rc;
301 db_stats(pStmt);
302 rc = sqlite3_reset(pStmt->pStmt);
303 db_check_result(rc);
304 return rc;
305 }
306 int db_finalize(Stmt *pStmt){
307 int rc;
308 db_stats(pStmt);
309 blob_reset(&pStmt->sql);
310 rc = sqlite3_finalize(pStmt->pStmt);
311 db_check_result(rc);
312 pStmt->pStmt = 0;
313 if( pStmt->pNext ){
@@ -1188,10 +1213,11 @@
1213 ** so this routine is a no-op.
1214 */
1215 void db_swap_connections(void){
1216 if( !g.useAttach ){
1217 sqlite3 *dbTemp = g.db;
1218 assert( g.dbConfig!=0 );
1219 g.db = g.dbConfig;
1220 g.dbConfig = dbTemp;
1221 }
1222 }
1223
1224
+27 -1
--- src/db.c
+++ src/db.c
@@ -48,10 +48,11 @@
4848
*/
4949
struct Stmt {
5050
Blob sql; /* The SQL for this statement */
5151
sqlite3_stmt *pStmt; /* The results of sqlite3_prepare() */
5252
Stmt *pNext, *pPrev; /* List of all unfinalized statements */
53
+ int nStep; /* Number of sqlite3_step() calls */
5354
};
5455
#endif /* INTERFACE */
5556
5657
/*
5758
** Call this routine when a database error occurs.
@@ -191,10 +192,11 @@
191192
zSql = blob_str(&pStmt->sql);
192193
if( sqlite3_prepare_v2(g.db, zSql, -1, &pStmt->pStmt, 0)!=0 ){
193194
db_err("%s\n%s", sqlite3_errmsg(g.db), zSql);
194195
}
195196
pStmt->pNext = pStmt->pPrev = 0;
197
+ pStmt->nStep = 0;
196198
return 0;
197199
}
198200
int db_prepare(Stmt *pStmt, const char *zFormat, ...){
199201
int rc;
200202
va_list ap;
@@ -266,23 +268,46 @@
266268
** or SQLITE_OK if the statement finishes successfully.
267269
*/
268270
int db_step(Stmt *pStmt){
269271
int rc;
270272
rc = sqlite3_step(pStmt->pStmt);
273
+ pStmt->nStep++;
271274
return rc;
272275
}
276
+
277
+/*
278
+** Print warnings if a query is inefficient.
279
+*/
280
+static void db_stats(Stmt *pStmt){
281
+#ifdef FOSSIL_DEBUG
282
+ int c1, c2;
283
+ const char *zSql = sqlite3_sql(pStmt->pStmt);
284
+ if( zSql==0 ) return;
285
+ c1 = sqlite3_stmt_status(pStmt->pStmt, SQLITE_STMTSTATUS_FULLSCAN_STEP, 1);
286
+ c2 = sqlite3_stmt_status(pStmt->pStmt, SQLITE_STMTSTATUS_SORT, 1);
287
+ if( c1>pStmt->nStep*4 && strstr(zSql,"/*scan*/")==0 ){
288
+ fossil_warning("%d scan steps for %d rows in [%s]", c1, pStmt->nStep, zSql);
289
+ }else if( c2 && strstr(zSql,"/*sort*/")==0 && strstr(zSql,"/*scan*/")==0 ){
290
+ fossil_warning("sort w/o index in [%s]", zSql);
291
+ }
292
+ pStmt->nStep = 0;
293
+#endif
294
+}
273295
274296
/*
275297
** Reset or finalize a statement.
276298
*/
277299
int db_reset(Stmt *pStmt){
278
- int rc = sqlite3_reset(pStmt->pStmt);
300
+ int rc;
301
+ db_stats(pStmt);
302
+ rc = sqlite3_reset(pStmt->pStmt);
279303
db_check_result(rc);
280304
return rc;
281305
}
282306
int db_finalize(Stmt *pStmt){
283307
int rc;
308
+ db_stats(pStmt);
284309
blob_reset(&pStmt->sql);
285310
rc = sqlite3_finalize(pStmt->pStmt);
286311
db_check_result(rc);
287312
pStmt->pStmt = 0;
288313
if( pStmt->pNext ){
@@ -1188,10 +1213,11 @@
11881213
** so this routine is a no-op.
11891214
*/
11901215
void db_swap_connections(void){
11911216
if( !g.useAttach ){
11921217
sqlite3 *dbTemp = g.db;
1218
+ assert( g.dbConfig!=0 );
11931219
g.db = g.dbConfig;
11941220
g.dbConfig = dbTemp;
11951221
}
11961222
}
11971223
11981224
--- src/db.c
+++ src/db.c
@@ -48,10 +48,11 @@
48 */
49 struct Stmt {
50 Blob sql; /* The SQL for this statement */
51 sqlite3_stmt *pStmt; /* The results of sqlite3_prepare() */
52 Stmt *pNext, *pPrev; /* List of all unfinalized statements */
 
53 };
54 #endif /* INTERFACE */
55
56 /*
57 ** Call this routine when a database error occurs.
@@ -191,10 +192,11 @@
191 zSql = blob_str(&pStmt->sql);
192 if( sqlite3_prepare_v2(g.db, zSql, -1, &pStmt->pStmt, 0)!=0 ){
193 db_err("%s\n%s", sqlite3_errmsg(g.db), zSql);
194 }
195 pStmt->pNext = pStmt->pPrev = 0;
 
196 return 0;
197 }
198 int db_prepare(Stmt *pStmt, const char *zFormat, ...){
199 int rc;
200 va_list ap;
@@ -266,23 +268,46 @@
266 ** or SQLITE_OK if the statement finishes successfully.
267 */
268 int db_step(Stmt *pStmt){
269 int rc;
270 rc = sqlite3_step(pStmt->pStmt);
 
271 return rc;
272 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
273
274 /*
275 ** Reset or finalize a statement.
276 */
277 int db_reset(Stmt *pStmt){
278 int rc = sqlite3_reset(pStmt->pStmt);
 
 
279 db_check_result(rc);
280 return rc;
281 }
282 int db_finalize(Stmt *pStmt){
283 int rc;
 
284 blob_reset(&pStmt->sql);
285 rc = sqlite3_finalize(pStmt->pStmt);
286 db_check_result(rc);
287 pStmt->pStmt = 0;
288 if( pStmt->pNext ){
@@ -1188,10 +1213,11 @@
1188 ** so this routine is a no-op.
1189 */
1190 void db_swap_connections(void){
1191 if( !g.useAttach ){
1192 sqlite3 *dbTemp = g.db;
 
1193 g.db = g.dbConfig;
1194 g.dbConfig = dbTemp;
1195 }
1196 }
1197
1198
--- src/db.c
+++ src/db.c
@@ -48,10 +48,11 @@
48 */
49 struct Stmt {
50 Blob sql; /* The SQL for this statement */
51 sqlite3_stmt *pStmt; /* The results of sqlite3_prepare() */
52 Stmt *pNext, *pPrev; /* List of all unfinalized statements */
53 int nStep; /* Number of sqlite3_step() calls */
54 };
55 #endif /* INTERFACE */
56
57 /*
58 ** Call this routine when a database error occurs.
@@ -191,10 +192,11 @@
192 zSql = blob_str(&pStmt->sql);
193 if( sqlite3_prepare_v2(g.db, zSql, -1, &pStmt->pStmt, 0)!=0 ){
194 db_err("%s\n%s", sqlite3_errmsg(g.db), zSql);
195 }
196 pStmt->pNext = pStmt->pPrev = 0;
197 pStmt->nStep = 0;
198 return 0;
199 }
200 int db_prepare(Stmt *pStmt, const char *zFormat, ...){
201 int rc;
202 va_list ap;
@@ -266,23 +268,46 @@
268 ** or SQLITE_OK if the statement finishes successfully.
269 */
270 int db_step(Stmt *pStmt){
271 int rc;
272 rc = sqlite3_step(pStmt->pStmt);
273 pStmt->nStep++;
274 return rc;
275 }
276
277 /*
278 ** Print warnings if a query is inefficient.
279 */
280 static void db_stats(Stmt *pStmt){
281 #ifdef FOSSIL_DEBUG
282 int c1, c2;
283 const char *zSql = sqlite3_sql(pStmt->pStmt);
284 if( zSql==0 ) return;
285 c1 = sqlite3_stmt_status(pStmt->pStmt, SQLITE_STMTSTATUS_FULLSCAN_STEP, 1);
286 c2 = sqlite3_stmt_status(pStmt->pStmt, SQLITE_STMTSTATUS_SORT, 1);
287 if( c1>pStmt->nStep*4 && strstr(zSql,"/*scan*/")==0 ){
288 fossil_warning("%d scan steps for %d rows in [%s]", c1, pStmt->nStep, zSql);
289 }else if( c2 && strstr(zSql,"/*sort*/")==0 && strstr(zSql,"/*scan*/")==0 ){
290 fossil_warning("sort w/o index in [%s]", zSql);
291 }
292 pStmt->nStep = 0;
293 #endif
294 }
295
296 /*
297 ** Reset or finalize a statement.
298 */
299 int db_reset(Stmt *pStmt){
300 int rc;
301 db_stats(pStmt);
302 rc = sqlite3_reset(pStmt->pStmt);
303 db_check_result(rc);
304 return rc;
305 }
306 int db_finalize(Stmt *pStmt){
307 int rc;
308 db_stats(pStmt);
309 blob_reset(&pStmt->sql);
310 rc = sqlite3_finalize(pStmt->pStmt);
311 db_check_result(rc);
312 pStmt->pStmt = 0;
313 if( pStmt->pNext ){
@@ -1188,10 +1213,11 @@
1213 ** so this routine is a no-op.
1214 */
1215 void db_swap_connections(void){
1216 if( !g.useAttach ){
1217 sqlite3 *dbTemp = g.db;
1218 assert( g.dbConfig!=0 );
1219 g.db = g.dbConfig;
1220 g.dbConfig = dbTemp;
1221 }
1222 }
1223
1224
+6 -4
--- src/diff.c
+++ src/diff.c
@@ -729,21 +729,23 @@
729729
/*
730730
** WEBPAGE: annotate
731731
**
732732
** Query parameters:
733733
**
734
-** mid=NUM The manifest ID at which to start the annotation
735
-** fnid=NUM The filename ID.
734
+** checkin=ID The manifest ID at which to start the annotation
735
+** filename=FILENAME The filename.
736736
*/
737737
void annotation_page(void){
738
- int mid = atoi(PD("mid","0"));
739
- int fnid = atoi(PD("fnid","0"));
738
+ int mid;
739
+ int fnid;
740740
int i;
741741
Annotator ann;
742742
743743
login_check_credentials();
744744
if( !g.okRead ){ login_needed(); return; }
745
+ mid = name_to_rid(PD("checkin","0"));
746
+ fnid = db_int(0, "SELECT fnid FROM filename WHERE name=%Q", P("filename"));
745747
if( mid==0 || fnid==0 ){ fossil_redirect_home(); }
746748
if( !db_exists("SELECT 1 FROM mlink WHERE mid=%d AND fnid=%d",mid,fnid) ){
747749
fossil_redirect_home();
748750
}
749751
style_header("File Annotation");
750752
--- src/diff.c
+++ src/diff.c
@@ -729,21 +729,23 @@
729 /*
730 ** WEBPAGE: annotate
731 **
732 ** Query parameters:
733 **
734 ** mid=NUM The manifest ID at which to start the annotation
735 ** fnid=NUM The filename ID.
736 */
737 void annotation_page(void){
738 int mid = atoi(PD("mid","0"));
739 int fnid = atoi(PD("fnid","0"));
740 int i;
741 Annotator ann;
742
743 login_check_credentials();
744 if( !g.okRead ){ login_needed(); return; }
 
 
745 if( mid==0 || fnid==0 ){ fossil_redirect_home(); }
746 if( !db_exists("SELECT 1 FROM mlink WHERE mid=%d AND fnid=%d",mid,fnid) ){
747 fossil_redirect_home();
748 }
749 style_header("File Annotation");
750
--- src/diff.c
+++ src/diff.c
@@ -729,21 +729,23 @@
729 /*
730 ** WEBPAGE: annotate
731 **
732 ** Query parameters:
733 **
734 ** checkin=ID The manifest ID at which to start the annotation
735 ** filename=FILENAME The filename.
736 */
737 void annotation_page(void){
738 int mid;
739 int fnid;
740 int i;
741 Annotator ann;
742
743 login_check_credentials();
744 if( !g.okRead ){ login_needed(); return; }
745 mid = name_to_rid(PD("checkin","0"));
746 fnid = db_int(0, "SELECT fnid FROM filename WHERE name=%Q", P("filename"));
747 if( mid==0 || fnid==0 ){ fossil_redirect_home(); }
748 if( !db_exists("SELECT 1 FROM mlink WHERE mid=%d AND fnid=%d",mid,fnid) ){
749 fossil_redirect_home();
750 }
751 style_header("File Annotation");
752
+51 -45
--- src/finfo.c
+++ src/finfo.c
@@ -58,19 +58,20 @@
5858
usage("FILENAME");
5959
}
6060
file_tree_name(g.argv[2], &dest, 1);
6161
zFilename = blob_str(&dest);
6262
db_prepare(&q,
63
- "SELECT b.uuid, ci.uuid, date(event.mtime,'localtime'),"
63
+ "SELECT "
64
+ " (SELECT uuid FROM blob WHERE rid=mlink.fid)," /* New file */
65
+ " (SELECT uuid FROM blob WHERE rid=mlink.mid)," /* The check-in */
66
+ " date(event.mtime,'localtime'),"
6467
" coalesce(event.ecomment, event.comment),"
6568
" coalesce(event.euser, event.user)"
66
- " FROM mlink, blob b, event, blob ci"
69
+ " FROM mlink, event"
6770
" WHERE mlink.fnid=(SELECT fnid FROM filename WHERE name=%Q)"
68
- " AND b.rid=mlink.fid"
6971
" AND event.objid=mlink.mid"
70
- " AND event.objid=ci.rid"
71
- " ORDER BY event.mtime DESC LIMIT %d OFFSET %d",
72
+ " ORDER BY event.mtime DESC LIMIT %d OFFSET %d /*sort*/",
7273
zFilename, iLimit, iOffset
7374
);
7475
7576
printf("History of %s\n", zFilename);
7677
while( db_step(&q)==SQLITE_ROW ){
@@ -79,12 +80,17 @@
7980
const char *zDate = db_column_text(&q, 2);
8081
const char *zCom = db_column_text(&q, 3);
8182
const char *zUser = db_column_text(&q, 4);
8283
char *zOut;
8384
printf("%s ", zDate);
84
- zOut = sqlite3_mprintf("[%.10s] %s (user: %s, artifact: [%.10s])",
85
- zCiUuid, zCom, zUser, zFileUuid);
85
+ if( zFileUuid==0 ){
86
+ zOut = sqlite3_mprintf("[%.10s] DELETED %s (user: %s)",
87
+ zCiUuid, zCom, zUser);
88
+ }else{
89
+ zOut = sqlite3_mprintf("[%.10s] %s (user: %s, artifact: [%.10s])",
90
+ zCiUuid, zCom, zUser, zFileUuid);
91
+ }
8692
comment_print(zOut, 11, 79);
8793
sqlite3_free(zOut);
8894
}
8995
db_finalize(&q);
9096
blob_reset(&dest);
@@ -111,28 +117,25 @@
111117
112118
zPrevDate[0] = 0;
113119
zFilename = PD("name","");
114120
db_prepare(&q,
115121
"SELECT"
116
- " substr(b.uuid,1,10),"
117
- " datetime(event.mtime,'localtime'),"
118
- " coalesce(event.ecomment, event.comment),"
119
- " coalesce(event.euser, event.user),"
120
- " mlink.pid,"
121
- " mlink.fid,"
122
- " mlink.mid,"
123
- " mlink.fnid,"
124
- " ci.uuid,"
125
- " event.bgcolor,"
122
+ " datetime(event.mtime,'localtime')," /* Date of change */
123
+ " coalesce(event.ecomment, event.comment)," /* Check-in comment */
124
+ " coalesce(event.euser, event.user)," /* User who made chng */
125
+ " mlink.pid," /* File rid */
126
+ " mlink.fid," /* Parent file rid */
127
+ " (SELECT uuid FROM blob WHERE rid=mlink.pid)," /* Parent file uuid */
128
+ " (SELECT uuid FROM blob WHERE rid=mlink.fid)," /* Current file uuid */
129
+ " (SELECT uuid FROM blob WHERE rid=mlink.mid)," /* Check-in uuid */
130
+ " event.bgcolor," /* Background color */
126131
" (SELECT value FROM tagxref WHERE tagid=%d AND tagtype>0"
127
- " AND tagxref.rid=mlink.mid)"
128
- " FROM mlink, blob b, event, blob ci"
132
+ " AND tagxref.rid=mlink.mid)" /* Tags */
133
+ " FROM mlink, event"
129134
" WHERE mlink.fnid=(SELECT fnid FROM filename WHERE name=%Q)"
130
- " AND b.rid=mlink.fid"
131135
" AND event.objid=mlink.mid"
132
- " AND event.objid=ci.rid"
133
- " ORDER BY event.mtime DESC",
136
+ " ORDER BY event.mtime DESC /*sort*/",
134137
TAG_BRANCH,
135138
zFilename
136139
);
137140
blob_zero(&title);
138141
blob_appendf(&title, "History of ");
@@ -141,21 +144,20 @@
141144
blob_reset(&title);
142145
pGraph = graph_init();
143146
@ <div id="canvas" style="position:relative;width:1px;height:1px;"></div>
144147
@ <table cellspacing=0 border=0 cellpadding=0>
145148
while( db_step(&q)==SQLITE_ROW ){
146
- const char *zUuid = db_column_text(&q, 0);
147
- const char *zDate = db_column_text(&q, 1);
148
- const char *zCom = db_column_text(&q, 2);
149
- const char *zUser = db_column_text(&q, 3);
150
- int fpid = db_column_int(&q, 4);
151
- int frid = db_column_int(&q, 5);
152
- int mid = db_column_int(&q, 6);
153
- int fnid = db_column_int(&q, 7);
154
- const char *zCkin = db_column_text(&q,8);
155
- const char *zBgClr = db_column_text(&q, 9);
156
- const char *zBr = db_column_text(&q, 10);
149
+ const char *zDate = db_column_text(&q, 0);
150
+ const char *zCom = db_column_text(&q, 1);
151
+ const char *zUser = db_column_text(&q, 2);
152
+ int fpid = db_column_int(&q, 3);
153
+ int frid = db_column_int(&q, 4);
154
+ const char *zPUuid = db_column_text(&q, 5);
155
+ const char *zUuid = db_column_text(&q, 6);
156
+ const char *zCkin = db_column_text(&q,7);
157
+ const char *zBgClr = db_column_text(&q, 8);
158
+ const char *zBr = db_column_text(&q, 9);
157159
int gidx;
158160
char zTime[10];
159161
char zShort[20];
160162
char zShortCkin[20];
161163
if( zBr==0 ) zBr = "trunk";
@@ -176,28 +178,32 @@
176178
}else{
177179
@ <td valign="top" align="left">
178180
}
179181
sqlite3_snprintf(sizeof(zShort), zShort, "%.10s", zUuid);
180182
sqlite3_snprintf(sizeof(zShortCkin), zShortCkin, "%.10s", zCkin);
181
- if( g.okHistory ){
182
- @ <a href="%s(g.zTop)/artifact/%s(zUuid)">[%s(zShort)]</a>
183
+ if( zUuid ){
184
+ if( g.okHistory ){
185
+ @ <a href="%s(g.zTop)/artifact/%s(zUuid)">[%S(zUuid)]</a>
186
+ }else{
187
+ @ [%S(zUuid)]
188
+ }
189
+ @ part of check-in
183190
}else{
184
- @ [%s(zShort)]
191
+ @ <b>Deleted</b> by check-in
185192
}
186
- @ part of check-in
187193
hyperlink_to_uuid(zShortCkin);
188194
@ %h(zCom) (user:
189195
hyperlink_to_user(zUser, zDate, "");
190196
@ branch: %h(zBr))
191
- if( g.okHistory ){
192
- if( fpid ){
193
- @ <a href="%s(g.zBaseURL)/fdiff?v1=%d(fpid)&amp;v2=%d(frid)">[diff]</a>
194
- }
195
- @ <a href="%s(g.zBaseURL)/annotate?mid=%d(mid)&amp;fnid=%d(fnid)">
196
- @ [annotate]</a>
197
- @ </td>
198
- }
197
+ if( g.okHistory && zUuid ){
198
+ if( fpid ){
199
+ @ <a href="%s(g.zTop)/fdiff?v1=%s(zPUuid)&amp;v2=%s(zUuid)">[diff]</a>
200
+ }
201
+ @ <a href="%s(g.zTop)/annotate?checkin=%S(zCkin)&amp;filename=%h(zFilename)">
202
+ @ [annotate]</a>
203
+ }
204
+ @ </td>
199205
}
200206
db_finalize(&q);
201207
if( pGraph ){
202208
graph_finish(pGraph, 1);
203209
if( pGraph->nErr ){
204210
--- src/finfo.c
+++ src/finfo.c
@@ -58,19 +58,20 @@
58 usage("FILENAME");
59 }
60 file_tree_name(g.argv[2], &dest, 1);
61 zFilename = blob_str(&dest);
62 db_prepare(&q,
63 "SELECT b.uuid, ci.uuid, date(event.mtime,'localtime'),"
 
 
 
64 " coalesce(event.ecomment, event.comment),"
65 " coalesce(event.euser, event.user)"
66 " FROM mlink, blob b, event, blob ci"
67 " WHERE mlink.fnid=(SELECT fnid FROM filename WHERE name=%Q)"
68 " AND b.rid=mlink.fid"
69 " AND event.objid=mlink.mid"
70 " AND event.objid=ci.rid"
71 " ORDER BY event.mtime DESC LIMIT %d OFFSET %d",
72 zFilename, iLimit, iOffset
73 );
74
75 printf("History of %s\n", zFilename);
76 while( db_step(&q)==SQLITE_ROW ){
@@ -79,12 +80,17 @@
79 const char *zDate = db_column_text(&q, 2);
80 const char *zCom = db_column_text(&q, 3);
81 const char *zUser = db_column_text(&q, 4);
82 char *zOut;
83 printf("%s ", zDate);
84 zOut = sqlite3_mprintf("[%.10s] %s (user: %s, artifact: [%.10s])",
85 zCiUuid, zCom, zUser, zFileUuid);
 
 
 
 
 
86 comment_print(zOut, 11, 79);
87 sqlite3_free(zOut);
88 }
89 db_finalize(&q);
90 blob_reset(&dest);
@@ -111,28 +117,25 @@
111
112 zPrevDate[0] = 0;
113 zFilename = PD("name","");
114 db_prepare(&q,
115 "SELECT"
116 " substr(b.uuid,1,10),"
117 " datetime(event.mtime,'localtime'),"
118 " coalesce(event.ecomment, event.comment),"
119 " coalesce(event.euser, event.user),"
120 " mlink.pid,"
121 " mlink.fid,"
122 " mlink.mid,"
123 " mlink.fnid,"
124 " ci.uuid,"
125 " event.bgcolor,"
126 " (SELECT value FROM tagxref WHERE tagid=%d AND tagtype>0"
127 " AND tagxref.rid=mlink.mid)"
128 " FROM mlink, blob b, event, blob ci"
129 " WHERE mlink.fnid=(SELECT fnid FROM filename WHERE name=%Q)"
130 " AND b.rid=mlink.fid"
131 " AND event.objid=mlink.mid"
132 " AND event.objid=ci.rid"
133 " ORDER BY event.mtime DESC",
134 TAG_BRANCH,
135 zFilename
136 );
137 blob_zero(&title);
138 blob_appendf(&title, "History of ");
@@ -141,21 +144,20 @@
141 blob_reset(&title);
142 pGraph = graph_init();
143 @ <div id="canvas" style="position:relative;width:1px;height:1px;"></div>
144 @ <table cellspacing=0 border=0 cellpadding=0>
145 while( db_step(&q)==SQLITE_ROW ){
146 const char *zUuid = db_column_text(&q, 0);
147 const char *zDate = db_column_text(&q, 1);
148 const char *zCom = db_column_text(&q, 2);
149 const char *zUser = db_column_text(&q, 3);
150 int fpid = db_column_int(&q, 4);
151 int frid = db_column_int(&q, 5);
152 int mid = db_column_int(&q, 6);
153 int fnid = db_column_int(&q, 7);
154 const char *zCkin = db_column_text(&q,8);
155 const char *zBgClr = db_column_text(&q, 9);
156 const char *zBr = db_column_text(&q, 10);
157 int gidx;
158 char zTime[10];
159 char zShort[20];
160 char zShortCkin[20];
161 if( zBr==0 ) zBr = "trunk";
@@ -176,28 +178,32 @@
176 }else{
177 @ <td valign="top" align="left">
178 }
179 sqlite3_snprintf(sizeof(zShort), zShort, "%.10s", zUuid);
180 sqlite3_snprintf(sizeof(zShortCkin), zShortCkin, "%.10s", zCkin);
181 if( g.okHistory ){
182 @ <a href="%s(g.zTop)/artifact/%s(zUuid)">[%s(zShort)]</a>
 
 
 
 
 
183 }else{
184 @ [%s(zShort)]
185 }
186 @ part of check-in
187 hyperlink_to_uuid(zShortCkin);
188 @ %h(zCom) (user:
189 hyperlink_to_user(zUser, zDate, "");
190 @ branch: %h(zBr))
191 if( g.okHistory ){
192 if( fpid ){
193 @ <a href="%s(g.zBaseURL)/fdiff?v1=%d(fpid)&amp;v2=%d(frid)">[diff]</a>
194 }
195 @ <a href="%s(g.zBaseURL)/annotate?mid=%d(mid)&amp;fnid=%d(fnid)">
196 @ [annotate]</a>
197 @ </td>
198 }
199 }
200 db_finalize(&q);
201 if( pGraph ){
202 graph_finish(pGraph, 1);
203 if( pGraph->nErr ){
204
--- src/finfo.c
+++ src/finfo.c
@@ -58,19 +58,20 @@
58 usage("FILENAME");
59 }
60 file_tree_name(g.argv[2], &dest, 1);
61 zFilename = blob_str(&dest);
62 db_prepare(&q,
63 "SELECT "
64 " (SELECT uuid FROM blob WHERE rid=mlink.fid)," /* New file */
65 " (SELECT uuid FROM blob WHERE rid=mlink.mid)," /* The check-in */
66 " date(event.mtime,'localtime'),"
67 " coalesce(event.ecomment, event.comment),"
68 " coalesce(event.euser, event.user)"
69 " FROM mlink, event"
70 " WHERE mlink.fnid=(SELECT fnid FROM filename WHERE name=%Q)"
 
71 " AND event.objid=mlink.mid"
72 " ORDER BY event.mtime DESC LIMIT %d OFFSET %d /*sort*/",
 
73 zFilename, iLimit, iOffset
74 );
75
76 printf("History of %s\n", zFilename);
77 while( db_step(&q)==SQLITE_ROW ){
@@ -79,12 +80,17 @@
80 const char *zDate = db_column_text(&q, 2);
81 const char *zCom = db_column_text(&q, 3);
82 const char *zUser = db_column_text(&q, 4);
83 char *zOut;
84 printf("%s ", zDate);
85 if( zFileUuid==0 ){
86 zOut = sqlite3_mprintf("[%.10s] DELETED %s (user: %s)",
87 zCiUuid, zCom, zUser);
88 }else{
89 zOut = sqlite3_mprintf("[%.10s] %s (user: %s, artifact: [%.10s])",
90 zCiUuid, zCom, zUser, zFileUuid);
91 }
92 comment_print(zOut, 11, 79);
93 sqlite3_free(zOut);
94 }
95 db_finalize(&q);
96 blob_reset(&dest);
@@ -111,28 +117,25 @@
117
118 zPrevDate[0] = 0;
119 zFilename = PD("name","");
120 db_prepare(&q,
121 "SELECT"
122 " datetime(event.mtime,'localtime')," /* Date of change */
123 " coalesce(event.ecomment, event.comment)," /* Check-in comment */
124 " coalesce(event.euser, event.user)," /* User who made chng */
125 " mlink.pid," /* File rid */
126 " mlink.fid," /* Parent file rid */
127 " (SELECT uuid FROM blob WHERE rid=mlink.pid)," /* Parent file uuid */
128 " (SELECT uuid FROM blob WHERE rid=mlink.fid)," /* Current file uuid */
129 " (SELECT uuid FROM blob WHERE rid=mlink.mid)," /* Check-in uuid */
130 " event.bgcolor," /* Background color */
 
131 " (SELECT value FROM tagxref WHERE tagid=%d AND tagtype>0"
132 " AND tagxref.rid=mlink.mid)" /* Tags */
133 " FROM mlink, event"
134 " WHERE mlink.fnid=(SELECT fnid FROM filename WHERE name=%Q)"
 
135 " AND event.objid=mlink.mid"
136 " ORDER BY event.mtime DESC /*sort*/",
 
137 TAG_BRANCH,
138 zFilename
139 );
140 blob_zero(&title);
141 blob_appendf(&title, "History of ");
@@ -141,21 +144,20 @@
144 blob_reset(&title);
145 pGraph = graph_init();
146 @ <div id="canvas" style="position:relative;width:1px;height:1px;"></div>
147 @ <table cellspacing=0 border=0 cellpadding=0>
148 while( db_step(&q)==SQLITE_ROW ){
149 const char *zDate = db_column_text(&q, 0);
150 const char *zCom = db_column_text(&q, 1);
151 const char *zUser = db_column_text(&q, 2);
152 int fpid = db_column_int(&q, 3);
153 int frid = db_column_int(&q, 4);
154 const char *zPUuid = db_column_text(&q, 5);
155 const char *zUuid = db_column_text(&q, 6);
156 const char *zCkin = db_column_text(&q,7);
157 const char *zBgClr = db_column_text(&q, 8);
158 const char *zBr = db_column_text(&q, 9);
 
159 int gidx;
160 char zTime[10];
161 char zShort[20];
162 char zShortCkin[20];
163 if( zBr==0 ) zBr = "trunk";
@@ -176,28 +178,32 @@
178 }else{
179 @ <td valign="top" align="left">
180 }
181 sqlite3_snprintf(sizeof(zShort), zShort, "%.10s", zUuid);
182 sqlite3_snprintf(sizeof(zShortCkin), zShortCkin, "%.10s", zCkin);
183 if( zUuid ){
184 if( g.okHistory ){
185 @ <a href="%s(g.zTop)/artifact/%s(zUuid)">[%S(zUuid)]</a>
186 }else{
187 @ [%S(zUuid)]
188 }
189 @ part of check-in
190 }else{
191 @ <b>Deleted</b> by check-in
192 }
 
193 hyperlink_to_uuid(zShortCkin);
194 @ %h(zCom) (user:
195 hyperlink_to_user(zUser, zDate, "");
196 @ branch: %h(zBr))
197 if( g.okHistory && zUuid ){
198 if( fpid ){
199 @ <a href="%s(g.zTop)/fdiff?v1=%s(zPUuid)&amp;v2=%s(zUuid)">[diff]</a>
200 }
201 @ <a href="%s(g.zTop)/annotate?checkin=%S(zCkin)&amp;filename=%h(zFilename)">
202 @ [annotate]</a>
203 }
204 @ </td>
205 }
206 db_finalize(&q);
207 if( pGraph ){
208 graph_finish(pGraph, 1);
209 if( pGraph->nErr ){
210
+1 -1
--- src/graph.c
+++ src/graph.c
@@ -306,11 +306,11 @@
306306
continue;
307307
}
308308
if( pDesc->aiRaiser[pDesc->iRail]==0 && pDesc->zBranch==pRow->zBranch ){
309309
pRow->iRail = pDesc->iRail;
310310
}else{
311
- pRow->iRail = findFreeRail(p, 0, pDesc->idx, inUse, 0);
311
+ pRow->iRail = findFreeRail(p, 0, pDesc->idx, inUse, pDesc->iRail);
312312
}
313313
pDesc->aiRaiser[pRow->iRail] = pRow->idx;
314314
mask = 1<<pRow->iRail;
315315
if( pRow->isLeaf ){
316316
inUse &= ~mask;
317317
--- src/graph.c
+++ src/graph.c
@@ -306,11 +306,11 @@
306 continue;
307 }
308 if( pDesc->aiRaiser[pDesc->iRail]==0 && pDesc->zBranch==pRow->zBranch ){
309 pRow->iRail = pDesc->iRail;
310 }else{
311 pRow->iRail = findFreeRail(p, 0, pDesc->idx, inUse, 0);
312 }
313 pDesc->aiRaiser[pRow->iRail] = pRow->idx;
314 mask = 1<<pRow->iRail;
315 if( pRow->isLeaf ){
316 inUse &= ~mask;
317
--- src/graph.c
+++ src/graph.c
@@ -306,11 +306,11 @@
306 continue;
307 }
308 if( pDesc->aiRaiser[pDesc->iRail]==0 && pDesc->zBranch==pRow->zBranch ){
309 pRow->iRail = pDesc->iRail;
310 }else{
311 pRow->iRail = findFreeRail(p, 0, pDesc->idx, inUse, pDesc->iRail);
312 }
313 pDesc->aiRaiser[pRow->iRail] = pRow->idx;
314 mask = 1<<pRow->iRail;
315 if( pRow->isLeaf ){
316 inUse &= ~mask;
317
+20 -4
--- src/http.c
+++ src/http.c
@@ -193,22 +193,23 @@
193193
closeConnection = 1;
194194
iLength = -1;
195195
while( (zLine = transport_receive_line())!=0 && zLine[0]!=0 ){
196196
if( strncasecmp(zLine, "http/1.", 7)==0 ){
197197
if( sscanf(zLine, "HTTP/1.%d %d", &iHttpVersion, &rc)!=2 ) goto write_err;
198
- if( rc!=200 ){
198
+ if( rc!=200 && rc!=302 ){
199199
int ii;
200200
for(ii=7; zLine[ii] && zLine[ii]!=' '; ii++){}
201
- printf("ERROR. server says: %s\n", &zLine[ii]);
201
+ while( zLine[ii]==' ' ) ii++;
202
+ fossil_fatal("server says: %s\n", &zLine[ii]);
202203
goto write_err;
203204
}
204205
if( iHttpVersion==0 ){
205206
closeConnection = 1;
206207
}else{
207208
closeConnection = 0;
208209
}
209
- } else if( strncasecmp(zLine, "content-length:", 15)==0 ){
210
+ }else if( strncasecmp(zLine, "content-length:", 15)==0 ){
210211
for(i=15; isspace(zLine[i]); i++){}
211212
iLength = atoi(&zLine[i]);
212213
}else if( strncasecmp(zLine, "connection:", 11)==0 ){
213214
char c;
214215
for(i=11; isspace(zLine[i]); i++){}
@@ -216,18 +217,33 @@
216217
if( c=='c' || c=='C' ){
217218
closeConnection = 1;
218219
}else if( c=='k' || c=='K' ){
219220
closeConnection = 0;
220221
}
222
+ }else if( rc==302 && strncasecmp(zLine, "location:", 9)==0 ){
223
+ int i, j;
224
+ for(i=9; zLine[i] && zLine[i]==' '; i++){}
225
+ if( zLine[i]==0 ) fossil_fatal("malformed redirect: %s", zLine);
226
+ j = strlen(zLine) - 1;
227
+ if( j>4 && strcmp(&zLine[j-4],"/xfer")==0 ) zLine[j-4] = 0;
228
+ printf("redirect to %s\n", &zLine[i]);
229
+ url_parse(&zLine[i]);
230
+ transport_close();
231
+ http_exchange(pSend, pReply, useLogin);
232
+ return;
221233
}
222234
}
235
+ if( rc!=200 ){
236
+ fossil_fatal("\"location:\" missing from 302 redirect reply");
237
+ goto write_err;
238
+ }
223239
224240
/*
225241
** Extract the reply payload that follows the header
226242
*/
227243
if( iLength<0 ){
228
- printf("ERROR. Server did not reply\n");
244
+ fossil_fatal("server did not reply");
229245
goto write_err;
230246
}
231247
blob_zero(pReply);
232248
blob_resize(pReply, iLength);
233249
iLength = transport_receive(blob_buffer(pReply), iLength);
234250
--- src/http.c
+++ src/http.c
@@ -193,22 +193,23 @@
193 closeConnection = 1;
194 iLength = -1;
195 while( (zLine = transport_receive_line())!=0 && zLine[0]!=0 ){
196 if( strncasecmp(zLine, "http/1.", 7)==0 ){
197 if( sscanf(zLine, "HTTP/1.%d %d", &iHttpVersion, &rc)!=2 ) goto write_err;
198 if( rc!=200 ){
199 int ii;
200 for(ii=7; zLine[ii] && zLine[ii]!=' '; ii++){}
201 printf("ERROR. server says: %s\n", &zLine[ii]);
 
202 goto write_err;
203 }
204 if( iHttpVersion==0 ){
205 closeConnection = 1;
206 }else{
207 closeConnection = 0;
208 }
209 } else if( strncasecmp(zLine, "content-length:", 15)==0 ){
210 for(i=15; isspace(zLine[i]); i++){}
211 iLength = atoi(&zLine[i]);
212 }else if( strncasecmp(zLine, "connection:", 11)==0 ){
213 char c;
214 for(i=11; isspace(zLine[i]); i++){}
@@ -216,18 +217,33 @@
216 if( c=='c' || c=='C' ){
217 closeConnection = 1;
218 }else if( c=='k' || c=='K' ){
219 closeConnection = 0;
220 }
 
 
 
 
 
 
 
 
 
 
 
221 }
222 }
 
 
 
 
223
224 /*
225 ** Extract the reply payload that follows the header
226 */
227 if( iLength<0 ){
228 printf("ERROR. Server did not reply\n");
229 goto write_err;
230 }
231 blob_zero(pReply);
232 blob_resize(pReply, iLength);
233 iLength = transport_receive(blob_buffer(pReply), iLength);
234
--- src/http.c
+++ src/http.c
@@ -193,22 +193,23 @@
193 closeConnection = 1;
194 iLength = -1;
195 while( (zLine = transport_receive_line())!=0 && zLine[0]!=0 ){
196 if( strncasecmp(zLine, "http/1.", 7)==0 ){
197 if( sscanf(zLine, "HTTP/1.%d %d", &iHttpVersion, &rc)!=2 ) goto write_err;
198 if( rc!=200 && rc!=302 ){
199 int ii;
200 for(ii=7; zLine[ii] && zLine[ii]!=' '; ii++){}
201 while( zLine[ii]==' ' ) ii++;
202 fossil_fatal("server says: %s\n", &zLine[ii]);
203 goto write_err;
204 }
205 if( iHttpVersion==0 ){
206 closeConnection = 1;
207 }else{
208 closeConnection = 0;
209 }
210 }else if( strncasecmp(zLine, "content-length:", 15)==0 ){
211 for(i=15; isspace(zLine[i]); i++){}
212 iLength = atoi(&zLine[i]);
213 }else if( strncasecmp(zLine, "connection:", 11)==0 ){
214 char c;
215 for(i=11; isspace(zLine[i]); i++){}
@@ -216,18 +217,33 @@
217 if( c=='c' || c=='C' ){
218 closeConnection = 1;
219 }else if( c=='k' || c=='K' ){
220 closeConnection = 0;
221 }
222 }else if( rc==302 && strncasecmp(zLine, "location:", 9)==0 ){
223 int i, j;
224 for(i=9; zLine[i] && zLine[i]==' '; i++){}
225 if( zLine[i]==0 ) fossil_fatal("malformed redirect: %s", zLine);
226 j = strlen(zLine) - 1;
227 if( j>4 && strcmp(&zLine[j-4],"/xfer")==0 ) zLine[j-4] = 0;
228 printf("redirect to %s\n", &zLine[i]);
229 url_parse(&zLine[i]);
230 transport_close();
231 http_exchange(pSend, pReply, useLogin);
232 return;
233 }
234 }
235 if( rc!=200 ){
236 fossil_fatal("\"location:\" missing from 302 redirect reply");
237 goto write_err;
238 }
239
240 /*
241 ** Extract the reply payload that follows the header
242 */
243 if( iLength<0 ){
244 fossil_fatal("server did not reply");
245 goto write_err;
246 }
247 blob_zero(pReply);
248 blob_resize(pReply, iLength);
249 iLength = transport_receive(blob_buffer(pReply), iLength);
250
+43 -45
--- src/info.c
+++ src/info.c
@@ -346,38 +346,36 @@
346346
@ <td>%h(zUser) @ %h(zIpAddr) on %s(zDate)</td></tr>
347347
}
348348
db_finalize(&q);
349349
}
350350
if( g.okHistory ){
351
- char *zShortUuid = mprintf("%.10s", zUuid);
352351
const char *zProjName = db_get("project-name", "unnamed");
353352
@ <tr><th>Timelines:</th><td>
354
- @ <a href="%s(g.zBaseURL)/timeline?p=%d(rid)">ancestors</a>
355
- @ | <a href="%s(g.zBaseURL)/timeline?d=%d(rid)">descendants</a>
356
- @ | <a href="%s(g.zBaseURL)/timeline?d=%d(rid)&p=%d(rid)">both</a>
353
+ @ <a href="%s(g.zBaseURL)/timeline?p=%S(zUuid)">ancestors</a>
354
+ @ | <a href="%s(g.zBaseURL)/timeline?d=%S(zUuid)">descendants</a>
355
+ @ | <a href="%s(g.zBaseURL)/timeline?d=%S(zUuid)&p=%S(zUuid)">both</a>
357356
db_prepare(&q, "SELECT substr(tag.tagname,5) FROM tagxref, tag "
358357
" WHERE rid=%d AND tagtype>0 "
359358
" AND tag.tagid=tagxref.tagid "
360359
" AND +tag.tagname GLOB 'sym-*'", rid);
361360
while( db_step(&q)==SQLITE_ROW ){
362361
const char *zTagName = db_column_text(&q, 0);
363
- @ | <a href="%s(g.zBaseURL)/timeline?t=%T(zTagName)">%h(zTagName)</a>
362
+ @ | <a href="%s(g.zTop)/timeline?t=%T(zTagName)">%h(zTagName)</a>
364363
}
365364
db_finalize(&q);
366365
@ </td></tr>
367366
@ <tr><th>Other&nbsp;Links:</th>
368367
@ <td>
369
- @ <a href="%s(g.zBaseURL)/dir?ci=%s(zShortUuid)">files</a>
370
- @ | <a href="%s(g.zBaseURL)/zip/%s(zProjName)-%s(zShortUuid).zip?uuid=%s(zUuid)">
368
+ @ <a href="%s(g.zTop)/dir?ci=%S(zUuid)">files</a>
369
+ @ | <a href="%s(g.zTop)/zip/%s(zProjName)-%S(zUuid).zip?uuid=%s(zUuid)">
371370
@ ZIP archive</a>
372
- @ | <a href="%s(g.zBaseURL)/artifact/%d(rid)">manifest</a>
371
+ @ | <a href="%s(g.zTop)/artifact/%S(zUuid)">manifest</a>
373372
if( g.okWrite ){
374
- @ | <a href="%s(g.zBaseURL)/ci_edit?r=%d(rid)">edit</a>
373
+ @ | <a href="%s(g.zTop)/ci_edit?r=%S(zUuid)">edit</a>
375374
}
376375
@ </td>
377376
@ </tr>
378
- free(zShortUuid);
379377
}
380378
@ </table></p>
381379
}else{
382380
style_header("Check-in Information");
383381
login_anonymous_available();
@@ -399,14 +397,14 @@
399397
}else{
400398
@ <a href="%s(g.zBaseURL)/vinfo/%T(zName)">[show&nbsp;diffs]</a><br/>
401399
}
402400
}
403401
db_prepare(&q,
404
- "SELECT pid, fid, name, substr(a.uuid,1,10), substr(b.uuid,1,10)"
402
+ "SELECT pid, fid, name,"
403
+ " (SELECT uuid FROM blob WHERE rid=mlink.pid),"
404
+ " (SELECT uuid FROM blob WHERE rid=mlink.fid)"
405405
" FROM mlink JOIN filename ON filename.fnid=mlink.fnid"
406
- " LEFT JOIN blob a ON a.rid=pid"
407
- " LEFT JOIN blob b ON b.rid=fid"
408406
" WHERE mlink.mid=%d"
409407
" ORDER BY name",
410408
rid
411409
);
412410
while( db_step(&q)==SQLITE_ROW ){
@@ -421,24 +419,24 @@
421419
continue;
422420
}else{
423421
@ <p>Changes to %h(zName)</p>
424422
}
425423
}else if( zOld && zNew ){
426
- @ <p>Modified <a href="%s(g.zBaseURL)/finfo?name=%T(zName)">%h(zName)</a>
427
- @ from <a href="%s(g.zBaseURL)/artifact/%s(zOld)">[%s(zOld)]</a>
428
- @ to <a href="%s(g.zBaseURL)/artifact/%s(zNew)">[%s(zNew)].</a>
424
+ @ <p>Modified <a href="%s(g.zTop)/finfo?name=%T(zName)">%h(zName)</a>
425
+ @ from <a href="%s(g.zTop)/artifact/%s(zOld)">[%S(zOld)]</a>
426
+ @ to <a href="%s(g.zTop)/artifact/%s(zNew)">[%S(zNew)].</a>
429427
if( !showDiff ){
430428
@ &nbsp;&nbsp;
431
- @ <a href="%s(g.zBaseURL)/fdiff?v1=%d(pid)&v2=%d(fid)">[diff]</a>
429
+ @ <a href="%s(g.zTop)/fdiff?v1=%S(zOld)&v2=%S(zNew)">[diff]</a>
432430
}
433431
}else if( zOld ){
434
- @ <p>Deleted <a href="%s(g.zBaseURL)/finfo?name=%T(zName)">%h(zName)</a>
435
- @ version <a href="%s(g.zBaseURL)/artifact/%s(zOld)">[%s(zOld)]</a></p>
432
+ @ <p>Deleted <a href="%s(g.zTop)/finfo?name=%T(zName)">%h(zName)</a>
433
+ @ version <a href="%s(g.zTop)/artifact/%s(zOld)">[%S(zOld)]</a></p>
436434
continue;
437435
}else{
438
- @ <p>Added <a href="%s(g.zBaseURL)/finfo?name=%T(zName)">%h(zName)</a>
439
- @ version <a href="%s(g.zBaseURL)/artifact/%s(zNew)">[%s(zNew)]</a></p>
436
+ @ <p>Added <a href="%s(g.zTop)/finfo?name=%T(zName)">%h(zName)</a>
437
+ @ version <a href="%s(g.zTop)/artifact/%s(zNew)">[%S(zNew)]</a></p>
440438
}
441439
if( showDiff ){
442440
@ <blockquote><pre>
443441
append_diff(pid, fid);
444442
@ </pre></blockquote>
@@ -498,13 +496,12 @@
498496
@ <tr><th>Original&nbsp;User:</th><td>
499497
hyperlink_to_user(zUser, zDate, "</td></tr>");
500498
if( g.okHistory ){
501499
@ <tr><th>Commands:</th>
502500
@ <td>
503
- /* @ <a href="%s(g.zBaseURL)/wdiff/%d(rid)">diff</a> | */
504501
@ <a href="%s(g.zBaseURL)/whistory?name=%t(zName)">history</a>
505
- @ | <a href="%s(g.zBaseURL)/artifact/%d(rid)">raw-text</a>
502
+ @ | <a href="%s(g.zBaseURL)/artifact/%S(zUuid)">raw-text</a>
506503
@ </td>
507504
@ </tr>
508505
}
509506
@ </table></p>
510507
}else{
@@ -621,10 +618,12 @@
621618
Blob *pDownloadName /* Fill with an appropriate download name */
622619
){
623620
Stmt q;
624621
int cnt = 0;
625622
int nWiki = 0;
623
+ char *zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
624
+
626625
db_prepare(&q,
627626
"SELECT filename.name, datetime(event.mtime),"
628627
" coalesce(event.ecomment,event.comment),"
629628
" coalesce(event.euser,event.user),"
630629
" b.uuid"
@@ -691,11 +690,11 @@
691690
hyperlink_to_user(zUser,zDate," on");
692691
hyperlink_to_date(zDate,".");
693692
nWiki++;
694693
cnt++;
695694
if( pDownloadName && blob_size(pDownloadName)==0 ){
696
- blob_append(pDownloadName, zPagename, -1);
695
+ blob_appendf(pDownloadName, "%s.wiki", zPagename);
697696
}
698697
}
699698
db_finalize(&q);
700699
if( nWiki==0 ){
701700
db_prepare(&q,
@@ -726,11 +725,11 @@
726725
hyperlink_to_uuid(zUuid);
727726
@ - %w(zCom) by
728727
hyperlink_to_user(zUser,zDate," on");
729728
hyperlink_to_date(zDate, ".");
730729
if( pDownloadName && blob_size(pDownloadName)==0 ){
731
- blob_append(pDownloadName, zUuid, -1);
730
+ blob_appendf(pDownloadName, "%.10s.txt", zUuid);
732731
}
733732
cnt++;
734733
}
735734
db_finalize(&q);
736735
}
@@ -744,11 +743,11 @@
744743
while( db_step(&q)==SQLITE_ROW ){
745744
const char *zTarget = db_column_text(&q, 0);
746745
const char *zFilename = db_column_text(&q, 1);
747746
const char *zDate = db_column_text(&q, 2);
748747
const char *zUser = db_column_text(&q, 3);
749
- const char *zSrc = db_column_text(&q, 4);
748
+ /* const char *zSrc = db_column_text(&q, 4); */
750749
if( cnt>0 ){
751750
@ Also attachment "%h(zFilename)" to
752751
}else{
753752
@ Attachment "%h(zFilename)" to
754753
}
@@ -770,22 +769,21 @@
770769
@ added by
771770
hyperlink_to_user(zUser,zDate," on");
772771
hyperlink_to_date(zDate,".");
773772
cnt++;
774773
if( pDownloadName && blob_size(pDownloadName)==0 ){
775
- blob_append(pDownloadName, zSrc, -1);
774
+ blob_append(pDownloadName, zFilename, -1);
776775
}
777776
}
778777
db_finalize(&q);
779778
if( cnt==0 ){
780
- char *zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
781779
@ Control artifact.
782780
if( pDownloadName && blob_size(pDownloadName)==0 ){
783
- blob_append(pDownloadName, zUuid, -1);
781
+ blob_appendf(pDownloadName, "%.10s.txt", zUuid);
784782
}
785783
}else if( linkToView && g.okHistory ){
786
- @ <a href="%s(g.zBaseURL)/artifact/%d(rid)">[view]</a>
784
+ @ <a href="%s(g.zBaseURL)/artifact/%S(zUuid)">[view]</a>
787785
}
788786
}
789787
790788
791789
/*
@@ -793,12 +791,12 @@
793791
**
794792
** Two arguments, v1 and v2, are integers. Show the difference between
795793
** the two records.
796794
*/
797795
void diff_page(void){
798
- int v1 = name_to_rid(PD("v1","0"));
799
- int v2 = name_to_rid(PD("v2","0"));
796
+ int v1 = name_to_rid(P("v1"));
797
+ int v2 = name_to_rid(P("v2"));
800798
Blob c1, c2, diff;
801799
802800
login_check_credentials();
803801
if( !g.okRead ){ login_needed(); return; }
804802
style_header("Diff");
@@ -929,11 +927,11 @@
929927
@ <h2>Artifact %s(zUuid):</h2>
930928
@ <blockquote>
931929
blob_zero(&downloadName);
932930
object_description(rid, 0, &downloadName);
933931
style_submenu_element("Download", "Download",
934
- "%s/raw/%T?name=%d", g.zBaseURL, blob_str(&downloadName), rid);
932
+ "%s/raw/%T?name=%s", g.zTop, blob_str(&downloadName), zUuid);
935933
@ </blockquote>
936934
@ <hr>
937935
content_get(rid, &content);
938936
@ <blockquote><pre>
939937
hexdump(&content);
@@ -976,30 +974,30 @@
976974
@ <h2>Artifact %s(zUuid)</h2>
977975
@ <blockquote>
978976
blob_zero(&downloadName);
979977
object_description(rid, 0, &downloadName);
980978
style_submenu_element("Download", "Download",
981
- "%s/raw/%T?name=%d", g.zTop, blob_str(&downloadName), rid);
979
+ "%s/raw/%T?name=%s", g.zTop, blob_str(&downloadName), zUuid);
982980
zMime = mimetype_from_name(blob_str(&downloadName));
983981
if( zMime ){
984982
if( strcmp(zMime, "text/html")==0 ){
985983
if( P("txt") ){
986984
style_submenu_element("Html", "Html",
987
- "%s/artifact?name=%d", g.zTop, rid);
985
+ "%s/artifact?name=%s", g.zTop, zUuid);
988986
}else{
989987
renderAsHtml = 1;
990988
style_submenu_element("Text", "Text",
991
- "%s/artifact?name=%d&txt=1", g.zTop, rid);
989
+ "%s/artifact?name=%s&txt=1", g.zTop, zUuid);
992990
}
993991
}else if( strcmp(zMime, "application/x-fossil-wiki")==0 ){
994992
if( P("txt") ){
995993
style_submenu_element("Wiki", "Wiki",
996
- "%s/artifact?name=%d", g.zTop, rid);
994
+ "%s/artifact?name=%s", g.zTop, zUuid);
997995
}else{
998996
renderAsWiki = 1;
999997
style_submenu_element("Text", "Text",
1000
- "%s/artifact?name=%d&txt=1", g.zTop, rid);
998
+ "%s/artifact?name=%s&txt=1", g.zTop, zUuid);
1001999
}
10021000
}
10031001
}
10041002
@ </blockquote>
10051003
@ <hr>
@@ -1015,14 +1013,14 @@
10151013
@ <blockquote>
10161014
if( zMime==0 ){
10171015
@ <pre>
10181016
@ %h(blob_str(&content))
10191017
@ </pre>
1020
- style_submenu_element("Hex","Hex", "%s/hexdump?name=%d", g.zTop, rid);
1018
+ style_submenu_element("Hex","Hex", "%s/hexdump?name=%s", g.zTop, zUuid);
10211019
}else if( strncmp(zMime, "image/", 6)==0 ){
1022
- @ <img src="%s(g.zBaseURL)/raw?name=%d(rid)&m=%s(zMime)"></img>
1023
- style_submenu_element("Hex","Hex", "%s/hexdump?name=%d", g.zTop, rid);
1020
+ @ <img src="%s(g.zBaseURL)/raw?name=%s(zUuid)&m=%s(zMime)"></img>
1021
+ style_submenu_element("Hex","Hex", "%s/hexdump?name=%s", g.zTop, zUuid);
10241022
}else{
10251023
@ <pre>
10261024
hexdump(&content);
10271025
@ </pre>
10281026
}
@@ -1196,17 +1194,17 @@
11961194
int nColor = sizeof(aColor)/sizeof(aColor[0]);
11971195
int i;
11981196
11991197
login_check_credentials();
12001198
if( !g.okWrite ){ login_needed(); return; }
1201
- rid = atoi(PD("r","0"));
1199
+ rid = name_to_rid(P("r"));
12021200
zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
12031201
zComment = db_text(0, "SELECT coalesce(ecomment,comment)"
12041202
" FROM event WHERE objid=%d", rid);
12051203
if( zComment==0 ) fossil_redirect_home();
12061204
if( P("cancel") ){
1207
- cgi_redirectf("ci?name=%d", rid);
1205
+ cgi_redirectf("ci?name=%s", zUuid);
12081206
}
12091207
zNewComment = PD("c",zComment);
12101208
zUser = db_text(0, "SELECT coalesce(euser,user)"
12111209
" FROM event WHERE objid=%d", rid);
12121210
if( zUser==0 ) fossil_redirect_home();
@@ -1315,11 +1313,11 @@
13151313
g.markPrivate = content_is_private(rid);
13161314
nrid = content_put(&ctrl, 0, 0);
13171315
manifest_crosslink(nrid, &ctrl);
13181316
db_end_transaction(0);
13191317
}
1320
- cgi_redirectf("ci?name=%d", rid);
1318
+ cgi_redirectf("ci?name=%s", zUuid);
13211319
}
13221320
blob_zero(&comment);
13231321
blob_append(&comment, zNewComment, -1);
13241322
zUuid[10] = 0;
13251323
style_header("Edit Check-in [%s]", zUuid);
@@ -1357,11 +1355,11 @@
13571355
@ </blockquote>
13581356
@ <hr>
13591357
blob_reset(&suffix);
13601358
}
13611359
@ <p>Make changes to attributes of check-in
1362
- @ [<a href="ci?name=%d(rid)">%s(zUuid)</a>]:</p>
1360
+ @ [<a href="ci?name=%s(zUuid)">%s(zUuid)</a>]:</p>
13631361
@ <form action="%s(g.zBaseURL)/ci_edit" method="POST">
13641362
login_insert_csrf_secret();
13651363
@ <input type="hidden" name="r" value="%d(rid)">
13661364
@ <table border="0" cellspacing="10">
13671365
13681366
--- src/info.c
+++ src/info.c
@@ -346,38 +346,36 @@
346 @ <td>%h(zUser) @ %h(zIpAddr) on %s(zDate)</td></tr>
347 }
348 db_finalize(&q);
349 }
350 if( g.okHistory ){
351 char *zShortUuid = mprintf("%.10s", zUuid);
352 const char *zProjName = db_get("project-name", "unnamed");
353 @ <tr><th>Timelines:</th><td>
354 @ <a href="%s(g.zBaseURL)/timeline?p=%d(rid)">ancestors</a>
355 @ | <a href="%s(g.zBaseURL)/timeline?d=%d(rid)">descendants</a>
356 @ | <a href="%s(g.zBaseURL)/timeline?d=%d(rid)&p=%d(rid)">both</a>
357 db_prepare(&q, "SELECT substr(tag.tagname,5) FROM tagxref, tag "
358 " WHERE rid=%d AND tagtype>0 "
359 " AND tag.tagid=tagxref.tagid "
360 " AND +tag.tagname GLOB 'sym-*'", rid);
361 while( db_step(&q)==SQLITE_ROW ){
362 const char *zTagName = db_column_text(&q, 0);
363 @ | <a href="%s(g.zBaseURL)/timeline?t=%T(zTagName)">%h(zTagName)</a>
364 }
365 db_finalize(&q);
366 @ </td></tr>
367 @ <tr><th>Other&nbsp;Links:</th>
368 @ <td>
369 @ <a href="%s(g.zBaseURL)/dir?ci=%s(zShortUuid)">files</a>
370 @ | <a href="%s(g.zBaseURL)/zip/%s(zProjName)-%s(zShortUuid).zip?uuid=%s(zUuid)">
371 @ ZIP archive</a>
372 @ | <a href="%s(g.zBaseURL)/artifact/%d(rid)">manifest</a>
373 if( g.okWrite ){
374 @ | <a href="%s(g.zBaseURL)/ci_edit?r=%d(rid)">edit</a>
375 }
376 @ </td>
377 @ </tr>
378 free(zShortUuid);
379 }
380 @ </table></p>
381 }else{
382 style_header("Check-in Information");
383 login_anonymous_available();
@@ -399,14 +397,14 @@
399 }else{
400 @ <a href="%s(g.zBaseURL)/vinfo/%T(zName)">[show&nbsp;diffs]</a><br/>
401 }
402 }
403 db_prepare(&q,
404 "SELECT pid, fid, name, substr(a.uuid,1,10), substr(b.uuid,1,10)"
 
 
405 " FROM mlink JOIN filename ON filename.fnid=mlink.fnid"
406 " LEFT JOIN blob a ON a.rid=pid"
407 " LEFT JOIN blob b ON b.rid=fid"
408 " WHERE mlink.mid=%d"
409 " ORDER BY name",
410 rid
411 );
412 while( db_step(&q)==SQLITE_ROW ){
@@ -421,24 +419,24 @@
421 continue;
422 }else{
423 @ <p>Changes to %h(zName)</p>
424 }
425 }else if( zOld && zNew ){
426 @ <p>Modified <a href="%s(g.zBaseURL)/finfo?name=%T(zName)">%h(zName)</a>
427 @ from <a href="%s(g.zBaseURL)/artifact/%s(zOld)">[%s(zOld)]</a>
428 @ to <a href="%s(g.zBaseURL)/artifact/%s(zNew)">[%s(zNew)].</a>
429 if( !showDiff ){
430 @ &nbsp;&nbsp;
431 @ <a href="%s(g.zBaseURL)/fdiff?v1=%d(pid)&v2=%d(fid)">[diff]</a>
432 }
433 }else if( zOld ){
434 @ <p>Deleted <a href="%s(g.zBaseURL)/finfo?name=%T(zName)">%h(zName)</a>
435 @ version <a href="%s(g.zBaseURL)/artifact/%s(zOld)">[%s(zOld)]</a></p>
436 continue;
437 }else{
438 @ <p>Added <a href="%s(g.zBaseURL)/finfo?name=%T(zName)">%h(zName)</a>
439 @ version <a href="%s(g.zBaseURL)/artifact/%s(zNew)">[%s(zNew)]</a></p>
440 }
441 if( showDiff ){
442 @ <blockquote><pre>
443 append_diff(pid, fid);
444 @ </pre></blockquote>
@@ -498,13 +496,12 @@
498 @ <tr><th>Original&nbsp;User:</th><td>
499 hyperlink_to_user(zUser, zDate, "</td></tr>");
500 if( g.okHistory ){
501 @ <tr><th>Commands:</th>
502 @ <td>
503 /* @ <a href="%s(g.zBaseURL)/wdiff/%d(rid)">diff</a> | */
504 @ <a href="%s(g.zBaseURL)/whistory?name=%t(zName)">history</a>
505 @ | <a href="%s(g.zBaseURL)/artifact/%d(rid)">raw-text</a>
506 @ </td>
507 @ </tr>
508 }
509 @ </table></p>
510 }else{
@@ -621,10 +618,12 @@
621 Blob *pDownloadName /* Fill with an appropriate download name */
622 ){
623 Stmt q;
624 int cnt = 0;
625 int nWiki = 0;
 
 
626 db_prepare(&q,
627 "SELECT filename.name, datetime(event.mtime),"
628 " coalesce(event.ecomment,event.comment),"
629 " coalesce(event.euser,event.user),"
630 " b.uuid"
@@ -691,11 +690,11 @@
691 hyperlink_to_user(zUser,zDate," on");
692 hyperlink_to_date(zDate,".");
693 nWiki++;
694 cnt++;
695 if( pDownloadName && blob_size(pDownloadName)==0 ){
696 blob_append(pDownloadName, zPagename, -1);
697 }
698 }
699 db_finalize(&q);
700 if( nWiki==0 ){
701 db_prepare(&q,
@@ -726,11 +725,11 @@
726 hyperlink_to_uuid(zUuid);
727 @ - %w(zCom) by
728 hyperlink_to_user(zUser,zDate," on");
729 hyperlink_to_date(zDate, ".");
730 if( pDownloadName && blob_size(pDownloadName)==0 ){
731 blob_append(pDownloadName, zUuid, -1);
732 }
733 cnt++;
734 }
735 db_finalize(&q);
736 }
@@ -744,11 +743,11 @@
744 while( db_step(&q)==SQLITE_ROW ){
745 const char *zTarget = db_column_text(&q, 0);
746 const char *zFilename = db_column_text(&q, 1);
747 const char *zDate = db_column_text(&q, 2);
748 const char *zUser = db_column_text(&q, 3);
749 const char *zSrc = db_column_text(&q, 4);
750 if( cnt>0 ){
751 @ Also attachment "%h(zFilename)" to
752 }else{
753 @ Attachment "%h(zFilename)" to
754 }
@@ -770,22 +769,21 @@
770 @ added by
771 hyperlink_to_user(zUser,zDate," on");
772 hyperlink_to_date(zDate,".");
773 cnt++;
774 if( pDownloadName && blob_size(pDownloadName)==0 ){
775 blob_append(pDownloadName, zSrc, -1);
776 }
777 }
778 db_finalize(&q);
779 if( cnt==0 ){
780 char *zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
781 @ Control artifact.
782 if( pDownloadName && blob_size(pDownloadName)==0 ){
783 blob_append(pDownloadName, zUuid, -1);
784 }
785 }else if( linkToView && g.okHistory ){
786 @ <a href="%s(g.zBaseURL)/artifact/%d(rid)">[view]</a>
787 }
788 }
789
790
791 /*
@@ -793,12 +791,12 @@
793 **
794 ** Two arguments, v1 and v2, are integers. Show the difference between
795 ** the two records.
796 */
797 void diff_page(void){
798 int v1 = name_to_rid(PD("v1","0"));
799 int v2 = name_to_rid(PD("v2","0"));
800 Blob c1, c2, diff;
801
802 login_check_credentials();
803 if( !g.okRead ){ login_needed(); return; }
804 style_header("Diff");
@@ -929,11 +927,11 @@
929 @ <h2>Artifact %s(zUuid):</h2>
930 @ <blockquote>
931 blob_zero(&downloadName);
932 object_description(rid, 0, &downloadName);
933 style_submenu_element("Download", "Download",
934 "%s/raw/%T?name=%d", g.zBaseURL, blob_str(&downloadName), rid);
935 @ </blockquote>
936 @ <hr>
937 content_get(rid, &content);
938 @ <blockquote><pre>
939 hexdump(&content);
@@ -976,30 +974,30 @@
976 @ <h2>Artifact %s(zUuid)</h2>
977 @ <blockquote>
978 blob_zero(&downloadName);
979 object_description(rid, 0, &downloadName);
980 style_submenu_element("Download", "Download",
981 "%s/raw/%T?name=%d", g.zTop, blob_str(&downloadName), rid);
982 zMime = mimetype_from_name(blob_str(&downloadName));
983 if( zMime ){
984 if( strcmp(zMime, "text/html")==0 ){
985 if( P("txt") ){
986 style_submenu_element("Html", "Html",
987 "%s/artifact?name=%d", g.zTop, rid);
988 }else{
989 renderAsHtml = 1;
990 style_submenu_element("Text", "Text",
991 "%s/artifact?name=%d&txt=1", g.zTop, rid);
992 }
993 }else if( strcmp(zMime, "application/x-fossil-wiki")==0 ){
994 if( P("txt") ){
995 style_submenu_element("Wiki", "Wiki",
996 "%s/artifact?name=%d", g.zTop, rid);
997 }else{
998 renderAsWiki = 1;
999 style_submenu_element("Text", "Text",
1000 "%s/artifact?name=%d&txt=1", g.zTop, rid);
1001 }
1002 }
1003 }
1004 @ </blockquote>
1005 @ <hr>
@@ -1015,14 +1013,14 @@
1015 @ <blockquote>
1016 if( zMime==0 ){
1017 @ <pre>
1018 @ %h(blob_str(&content))
1019 @ </pre>
1020 style_submenu_element("Hex","Hex", "%s/hexdump?name=%d", g.zTop, rid);
1021 }else if( strncmp(zMime, "image/", 6)==0 ){
1022 @ <img src="%s(g.zBaseURL)/raw?name=%d(rid)&m=%s(zMime)"></img>
1023 style_submenu_element("Hex","Hex", "%s/hexdump?name=%d", g.zTop, rid);
1024 }else{
1025 @ <pre>
1026 hexdump(&content);
1027 @ </pre>
1028 }
@@ -1196,17 +1194,17 @@
1196 int nColor = sizeof(aColor)/sizeof(aColor[0]);
1197 int i;
1198
1199 login_check_credentials();
1200 if( !g.okWrite ){ login_needed(); return; }
1201 rid = atoi(PD("r","0"));
1202 zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
1203 zComment = db_text(0, "SELECT coalesce(ecomment,comment)"
1204 " FROM event WHERE objid=%d", rid);
1205 if( zComment==0 ) fossil_redirect_home();
1206 if( P("cancel") ){
1207 cgi_redirectf("ci?name=%d", rid);
1208 }
1209 zNewComment = PD("c",zComment);
1210 zUser = db_text(0, "SELECT coalesce(euser,user)"
1211 " FROM event WHERE objid=%d", rid);
1212 if( zUser==0 ) fossil_redirect_home();
@@ -1315,11 +1313,11 @@
1315 g.markPrivate = content_is_private(rid);
1316 nrid = content_put(&ctrl, 0, 0);
1317 manifest_crosslink(nrid, &ctrl);
1318 db_end_transaction(0);
1319 }
1320 cgi_redirectf("ci?name=%d", rid);
1321 }
1322 blob_zero(&comment);
1323 blob_append(&comment, zNewComment, -1);
1324 zUuid[10] = 0;
1325 style_header("Edit Check-in [%s]", zUuid);
@@ -1357,11 +1355,11 @@
1357 @ </blockquote>
1358 @ <hr>
1359 blob_reset(&suffix);
1360 }
1361 @ <p>Make changes to attributes of check-in
1362 @ [<a href="ci?name=%d(rid)">%s(zUuid)</a>]:</p>
1363 @ <form action="%s(g.zBaseURL)/ci_edit" method="POST">
1364 login_insert_csrf_secret();
1365 @ <input type="hidden" name="r" value="%d(rid)">
1366 @ <table border="0" cellspacing="10">
1367
1368
--- src/info.c
+++ src/info.c
@@ -346,38 +346,36 @@
346 @ <td>%h(zUser) @ %h(zIpAddr) on %s(zDate)</td></tr>
347 }
348 db_finalize(&q);
349 }
350 if( g.okHistory ){
 
351 const char *zProjName = db_get("project-name", "unnamed");
352 @ <tr><th>Timelines:</th><td>
353 @ <a href="%s(g.zBaseURL)/timeline?p=%S(zUuid)">ancestors</a>
354 @ | <a href="%s(g.zBaseURL)/timeline?d=%S(zUuid)">descendants</a>
355 @ | <a href="%s(g.zBaseURL)/timeline?d=%S(zUuid)&p=%S(zUuid)">both</a>
356 db_prepare(&q, "SELECT substr(tag.tagname,5) FROM tagxref, tag "
357 " WHERE rid=%d AND tagtype>0 "
358 " AND tag.tagid=tagxref.tagid "
359 " AND +tag.tagname GLOB 'sym-*'", rid);
360 while( db_step(&q)==SQLITE_ROW ){
361 const char *zTagName = db_column_text(&q, 0);
362 @ | <a href="%s(g.zTop)/timeline?t=%T(zTagName)">%h(zTagName)</a>
363 }
364 db_finalize(&q);
365 @ </td></tr>
366 @ <tr><th>Other&nbsp;Links:</th>
367 @ <td>
368 @ <a href="%s(g.zTop)/dir?ci=%S(zUuid)">files</a>
369 @ | <a href="%s(g.zTop)/zip/%s(zProjName)-%S(zUuid).zip?uuid=%s(zUuid)">
370 @ ZIP archive</a>
371 @ | <a href="%s(g.zTop)/artifact/%S(zUuid)">manifest</a>
372 if( g.okWrite ){
373 @ | <a href="%s(g.zTop)/ci_edit?r=%S(zUuid)">edit</a>
374 }
375 @ </td>
376 @ </tr>
 
377 }
378 @ </table></p>
379 }else{
380 style_header("Check-in Information");
381 login_anonymous_available();
@@ -399,14 +397,14 @@
397 }else{
398 @ <a href="%s(g.zBaseURL)/vinfo/%T(zName)">[show&nbsp;diffs]</a><br/>
399 }
400 }
401 db_prepare(&q,
402 "SELECT pid, fid, name,"
403 " (SELECT uuid FROM blob WHERE rid=mlink.pid),"
404 " (SELECT uuid FROM blob WHERE rid=mlink.fid)"
405 " FROM mlink JOIN filename ON filename.fnid=mlink.fnid"
 
 
406 " WHERE mlink.mid=%d"
407 " ORDER BY name",
408 rid
409 );
410 while( db_step(&q)==SQLITE_ROW ){
@@ -421,24 +419,24 @@
419 continue;
420 }else{
421 @ <p>Changes to %h(zName)</p>
422 }
423 }else if( zOld && zNew ){
424 @ <p>Modified <a href="%s(g.zTop)/finfo?name=%T(zName)">%h(zName)</a>
425 @ from <a href="%s(g.zTop)/artifact/%s(zOld)">[%S(zOld)]</a>
426 @ to <a href="%s(g.zTop)/artifact/%s(zNew)">[%S(zNew)].</a>
427 if( !showDiff ){
428 @ &nbsp;&nbsp;
429 @ <a href="%s(g.zTop)/fdiff?v1=%S(zOld)&v2=%S(zNew)">[diff]</a>
430 }
431 }else if( zOld ){
432 @ <p>Deleted <a href="%s(g.zTop)/finfo?name=%T(zName)">%h(zName)</a>
433 @ version <a href="%s(g.zTop)/artifact/%s(zOld)">[%S(zOld)]</a></p>
434 continue;
435 }else{
436 @ <p>Added <a href="%s(g.zTop)/finfo?name=%T(zName)">%h(zName)</a>
437 @ version <a href="%s(g.zTop)/artifact/%s(zNew)">[%S(zNew)]</a></p>
438 }
439 if( showDiff ){
440 @ <blockquote><pre>
441 append_diff(pid, fid);
442 @ </pre></blockquote>
@@ -498,13 +496,12 @@
496 @ <tr><th>Original&nbsp;User:</th><td>
497 hyperlink_to_user(zUser, zDate, "</td></tr>");
498 if( g.okHistory ){
499 @ <tr><th>Commands:</th>
500 @ <td>
 
501 @ <a href="%s(g.zBaseURL)/whistory?name=%t(zName)">history</a>
502 @ | <a href="%s(g.zBaseURL)/artifact/%S(zUuid)">raw-text</a>
503 @ </td>
504 @ </tr>
505 }
506 @ </table></p>
507 }else{
@@ -621,10 +618,12 @@
618 Blob *pDownloadName /* Fill with an appropriate download name */
619 ){
620 Stmt q;
621 int cnt = 0;
622 int nWiki = 0;
623 char *zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
624
625 db_prepare(&q,
626 "SELECT filename.name, datetime(event.mtime),"
627 " coalesce(event.ecomment,event.comment),"
628 " coalesce(event.euser,event.user),"
629 " b.uuid"
@@ -691,11 +690,11 @@
690 hyperlink_to_user(zUser,zDate," on");
691 hyperlink_to_date(zDate,".");
692 nWiki++;
693 cnt++;
694 if( pDownloadName && blob_size(pDownloadName)==0 ){
695 blob_appendf(pDownloadName, "%s.wiki", zPagename);
696 }
697 }
698 db_finalize(&q);
699 if( nWiki==0 ){
700 db_prepare(&q,
@@ -726,11 +725,11 @@
725 hyperlink_to_uuid(zUuid);
726 @ - %w(zCom) by
727 hyperlink_to_user(zUser,zDate," on");
728 hyperlink_to_date(zDate, ".");
729 if( pDownloadName && blob_size(pDownloadName)==0 ){
730 blob_appendf(pDownloadName, "%.10s.txt", zUuid);
731 }
732 cnt++;
733 }
734 db_finalize(&q);
735 }
@@ -744,11 +743,11 @@
743 while( db_step(&q)==SQLITE_ROW ){
744 const char *zTarget = db_column_text(&q, 0);
745 const char *zFilename = db_column_text(&q, 1);
746 const char *zDate = db_column_text(&q, 2);
747 const char *zUser = db_column_text(&q, 3);
748 /* const char *zSrc = db_column_text(&q, 4); */
749 if( cnt>0 ){
750 @ Also attachment "%h(zFilename)" to
751 }else{
752 @ Attachment "%h(zFilename)" to
753 }
@@ -770,22 +769,21 @@
769 @ added by
770 hyperlink_to_user(zUser,zDate," on");
771 hyperlink_to_date(zDate,".");
772 cnt++;
773 if( pDownloadName && blob_size(pDownloadName)==0 ){
774 blob_append(pDownloadName, zFilename, -1);
775 }
776 }
777 db_finalize(&q);
778 if( cnt==0 ){
 
779 @ Control artifact.
780 if( pDownloadName && blob_size(pDownloadName)==0 ){
781 blob_appendf(pDownloadName, "%.10s.txt", zUuid);
782 }
783 }else if( linkToView && g.okHistory ){
784 @ <a href="%s(g.zBaseURL)/artifact/%S(zUuid)">[view]</a>
785 }
786 }
787
788
789 /*
@@ -793,12 +791,12 @@
791 **
792 ** Two arguments, v1 and v2, are integers. Show the difference between
793 ** the two records.
794 */
795 void diff_page(void){
796 int v1 = name_to_rid(P("v1"));
797 int v2 = name_to_rid(P("v2"));
798 Blob c1, c2, diff;
799
800 login_check_credentials();
801 if( !g.okRead ){ login_needed(); return; }
802 style_header("Diff");
@@ -929,11 +927,11 @@
927 @ <h2>Artifact %s(zUuid):</h2>
928 @ <blockquote>
929 blob_zero(&downloadName);
930 object_description(rid, 0, &downloadName);
931 style_submenu_element("Download", "Download",
932 "%s/raw/%T?name=%s", g.zTop, blob_str(&downloadName), zUuid);
933 @ </blockquote>
934 @ <hr>
935 content_get(rid, &content);
936 @ <blockquote><pre>
937 hexdump(&content);
@@ -976,30 +974,30 @@
974 @ <h2>Artifact %s(zUuid)</h2>
975 @ <blockquote>
976 blob_zero(&downloadName);
977 object_description(rid, 0, &downloadName);
978 style_submenu_element("Download", "Download",
979 "%s/raw/%T?name=%s", g.zTop, blob_str(&downloadName), zUuid);
980 zMime = mimetype_from_name(blob_str(&downloadName));
981 if( zMime ){
982 if( strcmp(zMime, "text/html")==0 ){
983 if( P("txt") ){
984 style_submenu_element("Html", "Html",
985 "%s/artifact?name=%s", g.zTop, zUuid);
986 }else{
987 renderAsHtml = 1;
988 style_submenu_element("Text", "Text",
989 "%s/artifact?name=%s&txt=1", g.zTop, zUuid);
990 }
991 }else if( strcmp(zMime, "application/x-fossil-wiki")==0 ){
992 if( P("txt") ){
993 style_submenu_element("Wiki", "Wiki",
994 "%s/artifact?name=%s", g.zTop, zUuid);
995 }else{
996 renderAsWiki = 1;
997 style_submenu_element("Text", "Text",
998 "%s/artifact?name=%s&txt=1", g.zTop, zUuid);
999 }
1000 }
1001 }
1002 @ </blockquote>
1003 @ <hr>
@@ -1015,14 +1013,14 @@
1013 @ <blockquote>
1014 if( zMime==0 ){
1015 @ <pre>
1016 @ %h(blob_str(&content))
1017 @ </pre>
1018 style_submenu_element("Hex","Hex", "%s/hexdump?name=%s", g.zTop, zUuid);
1019 }else if( strncmp(zMime, "image/", 6)==0 ){
1020 @ <img src="%s(g.zBaseURL)/raw?name=%s(zUuid)&m=%s(zMime)"></img>
1021 style_submenu_element("Hex","Hex", "%s/hexdump?name=%s", g.zTop, zUuid);
1022 }else{
1023 @ <pre>
1024 hexdump(&content);
1025 @ </pre>
1026 }
@@ -1196,17 +1194,17 @@
1194 int nColor = sizeof(aColor)/sizeof(aColor[0]);
1195 int i;
1196
1197 login_check_credentials();
1198 if( !g.okWrite ){ login_needed(); return; }
1199 rid = name_to_rid(P("r"));
1200 zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
1201 zComment = db_text(0, "SELECT coalesce(ecomment,comment)"
1202 " FROM event WHERE objid=%d", rid);
1203 if( zComment==0 ) fossil_redirect_home();
1204 if( P("cancel") ){
1205 cgi_redirectf("ci?name=%s", zUuid);
1206 }
1207 zNewComment = PD("c",zComment);
1208 zUser = db_text(0, "SELECT coalesce(euser,user)"
1209 " FROM event WHERE objid=%d", rid);
1210 if( zUser==0 ) fossil_redirect_home();
@@ -1315,11 +1313,11 @@
1313 g.markPrivate = content_is_private(rid);
1314 nrid = content_put(&ctrl, 0, 0);
1315 manifest_crosslink(nrid, &ctrl);
1316 db_end_transaction(0);
1317 }
1318 cgi_redirectf("ci?name=%s", zUuid);
1319 }
1320 blob_zero(&comment);
1321 blob_append(&comment, zNewComment, -1);
1322 zUuid[10] = 0;
1323 style_header("Edit Check-in [%s]", zUuid);
@@ -1357,11 +1355,11 @@
1355 @ </blockquote>
1356 @ <hr>
1357 blob_reset(&suffix);
1358 }
1359 @ <p>Make changes to attributes of check-in
1360 @ [<a href="ci?name=%s(zUuid)">%s(zUuid)</a>]:</p>
1361 @ <form action="%s(g.zBaseURL)/ci_edit" method="POST">
1362 login_insert_csrf_secret();
1363 @ <input type="hidden" name="r" value="%d(rid)">
1364 @ <table border="0" cellspacing="10">
1365
1366
+12 -1
--- src/login.c
+++ src/login.c
@@ -397,10 +397,21 @@
397397
);
398398
blob_reset(&b);
399399
}
400400
sqlite3_snprintf(sizeof(g.zCsrfToken), g.zCsrfToken, "%.10s", zCookie);
401401
}
402
+
403
+ /* If no user found and the REMOTE_USER environment variable is set,
404
+ ** the accept the value of REMOTE_USER as the user.
405
+ */
406
+ if( uid==0 ){
407
+ const char *zRemoteUser = P("REMOTE_USER");
408
+ if( zRemoteUser && db_get_boolean("remote_user_ok",0) ){
409
+ uid = db_int(0, "SELECT uid FROM user WHERE login=%Q"
410
+ " AND length(cap)>0 AND length(pw)>0", zRemoteUser);
411
+ }
412
+ }
402413
403414
/* If no user found yet, try to log in as "nobody" */
404415
if( uid==0 ){
405416
uid = db_int(0, "SELECT uid FROM user WHERE login='nobody'");
406417
if( uid==0 ){
@@ -476,11 +487,11 @@
476487
case 's': g.okSetup = 1; /* Fall thru into Admin */
477488
case 'a': g.okAdmin = g.okRdTkt = g.okWrTkt = g.okZip =
478489
g.okRdWiki = g.okWrWiki = g.okNewWiki =
479490
g.okApndWiki = g.okHistory = g.okClone =
480491
g.okNewTkt = g.okPassword = g.okRdAddr =
481
- g.okTktFmt = g.okAttach = 1;
492
+ g.okTktFmt = g.okAttach = g.okApndTkt = 1;
482493
/* Fall thru into Read/Write */
483494
case 'i': g.okRead = g.okWrite = 1; break;
484495
case 'o': g.okRead = 1; break;
485496
case 'z': g.okZip = 1; break;
486497
487498
--- src/login.c
+++ src/login.c
@@ -397,10 +397,21 @@
397 );
398 blob_reset(&b);
399 }
400 sqlite3_snprintf(sizeof(g.zCsrfToken), g.zCsrfToken, "%.10s", zCookie);
401 }
 
 
 
 
 
 
 
 
 
 
 
402
403 /* If no user found yet, try to log in as "nobody" */
404 if( uid==0 ){
405 uid = db_int(0, "SELECT uid FROM user WHERE login='nobody'");
406 if( uid==0 ){
@@ -476,11 +487,11 @@
476 case 's': g.okSetup = 1; /* Fall thru into Admin */
477 case 'a': g.okAdmin = g.okRdTkt = g.okWrTkt = g.okZip =
478 g.okRdWiki = g.okWrWiki = g.okNewWiki =
479 g.okApndWiki = g.okHistory = g.okClone =
480 g.okNewTkt = g.okPassword = g.okRdAddr =
481 g.okTktFmt = g.okAttach = 1;
482 /* Fall thru into Read/Write */
483 case 'i': g.okRead = g.okWrite = 1; break;
484 case 'o': g.okRead = 1; break;
485 case 'z': g.okZip = 1; break;
486
487
--- src/login.c
+++ src/login.c
@@ -397,10 +397,21 @@
397 );
398 blob_reset(&b);
399 }
400 sqlite3_snprintf(sizeof(g.zCsrfToken), g.zCsrfToken, "%.10s", zCookie);
401 }
402
403 /* If no user found and the REMOTE_USER environment variable is set,
404 ** the accept the value of REMOTE_USER as the user.
405 */
406 if( uid==0 ){
407 const char *zRemoteUser = P("REMOTE_USER");
408 if( zRemoteUser && db_get_boolean("remote_user_ok",0) ){
409 uid = db_int(0, "SELECT uid FROM user WHERE login=%Q"
410 " AND length(cap)>0 AND length(pw)>0", zRemoteUser);
411 }
412 }
413
414 /* If no user found yet, try to log in as "nobody" */
415 if( uid==0 ){
416 uid = db_int(0, "SELECT uid FROM user WHERE login='nobody'");
417 if( uid==0 ){
@@ -476,11 +487,11 @@
487 case 's': g.okSetup = 1; /* Fall thru into Admin */
488 case 'a': g.okAdmin = g.okRdTkt = g.okWrTkt = g.okZip =
489 g.okRdWiki = g.okWrWiki = g.okNewWiki =
490 g.okApndWiki = g.okHistory = g.okClone =
491 g.okNewTkt = g.okPassword = g.okRdAddr =
492 g.okTktFmt = g.okAttach = g.okApndTkt = 1;
493 /* Fall thru into Read/Write */
494 case 'i': g.okRead = g.okWrite = 1; break;
495 case 'o': g.okRead = 1; break;
496 case 'z': g.okZip = 1; break;
497
498
+46
--- src/main.c
+++ src/main.c
@@ -226,10 +226,11 @@
226226
int main(int argc, char **argv){
227227
const char *zCmdName;
228228
int idx;
229229
int rc;
230230
231
+ sqlite3_config(SQLITE_CONFIG_LOG, fossil_sqlite_log, 0);
231232
g.now = time(0);
232233
g.argc = argc;
233234
g.argv = argv;
234235
if( getenv("GATEWAY_INTERFACE")!=0 ){
235236
zCmdName = "cgi";
@@ -347,10 +348,50 @@
347348
cgi_printf("<p><font color=\"red\">%h</font></p>", z);
348349
}else{
349350
fprintf(stderr, "%s: %s\n", g.argv[0], z);
350351
}
351352
}
353
+
354
+/*
355
+** Return a name for an SQLite error code
356
+*/
357
+static const char *sqlite_error_code_name(int iCode){
358
+ static char zCode[30];
359
+ switch( iCode & 0xff ){
360
+ case SQLITE_OK: return "SQLITE_OK";
361
+ case SQLITE_ERROR: return "SQLITE_ERROR";
362
+ case SQLITE_PERM: return "SQLITE_PERM";
363
+ case SQLITE_ABORT: return "SQLITE_ABORT";
364
+ case SQLITE_BUSY: return "SQLITE_BUSY";
365
+ case SQLITE_NOMEM: return "SQLITE_NOMEM";
366
+ case SQLITE_READONLY: return "SQLITE_READONLY";
367
+ case SQLITE_INTERRUPT: return "SQLITE_INTERRUPT";
368
+ case SQLITE_IOERR: return "SQLITE_IOERR";
369
+ case SQLITE_CORRUPT: return "SQLITE_CORRUPT";
370
+ case SQLITE_FULL: return "SQLITE_FULL";
371
+ case SQLITE_CANTOPEN: return "SQLITE_CANTOPEN";
372
+ case SQLITE_PROTOCOL: return "SQLITE_PROTOCOL";
373
+ case SQLITE_EMPTY: return "SQLITE_EMPTY";
374
+ case SQLITE_SCHEMA: return "SQLITE_SCHEMA";
375
+ case SQLITE_CONSTRAINT: return "SQLITE_CONSTRAINT";
376
+ case SQLITE_MISMATCH: return "SQLITE_MISMATCH";
377
+ case SQLITE_MISUSE: return "SQLITE_MISUSE";
378
+ case SQLITE_NOLFS: return "SQLITE_NOLFS";
379
+ case SQLITE_FORMAT: return "SQLITE_FORMAT";
380
+ case SQLITE_RANGE: return "SQLITE_RANGE";
381
+ case SQLITE_NOTADB: return "SQLITE_NOTADB";
382
+ default: {
383
+ sqlite3_snprintf(sizeof(zCode),zCode,"error code %d",iCode);
384
+ }
385
+ }
386
+ return zCode;
387
+}
388
+
389
+/* Error logs from SQLite */
390
+void fossil_sqlite_log(void *notUsed, int iCode, const char *zErrmsg){
391
+ fossil_warning("%s: %s", sqlite_error_code_name(iCode), zErrmsg);
392
+}
352393
353394
/*
354395
** Print a usage comment and quit
355396
*/
356397
void usage(const char *zFormat){
@@ -608,10 +649,14 @@
608649
if( stat(zRepo, &sStat)!=0 ){
609650
fossil_fatal("cannot stat() repository: %s", zRepo);
610651
}
611652
setgid(sStat.st_gid);
612653
setuid(sStat.st_uid);
654
+ if( g.db!=0 ){
655
+ db_close();
656
+ db_open_repository(zRepo);
657
+ }
613658
}
614659
#endif
615660
return zRepo;
616661
}
617662
@@ -651,10 +696,11 @@
651696
** characters other than alphanumerics, "-", and "_".
652697
*/
653698
for(j=strlen(g.zRepositoryName)+1, k=0; k<i-1; j++, k++){
654699
if( !isalnum(zRepo[j]) && zRepo[j]!='-' ) zRepo[j] = '_';
655700
}
701
+ if( zRepo[0]=='/' && zRepo[1]=='/' ) zRepo++;
656702
657703
if( file_size(zRepo)<1024 ){
658704
if( zNotFound ){
659705
cgi_redirect(zNotFound);
660706
}else{
661707
--- src/main.c
+++ src/main.c
@@ -226,10 +226,11 @@
226 int main(int argc, char **argv){
227 const char *zCmdName;
228 int idx;
229 int rc;
230
 
231 g.now = time(0);
232 g.argc = argc;
233 g.argv = argv;
234 if( getenv("GATEWAY_INTERFACE")!=0 ){
235 zCmdName = "cgi";
@@ -347,10 +348,50 @@
347 cgi_printf("<p><font color=\"red\">%h</font></p>", z);
348 }else{
349 fprintf(stderr, "%s: %s\n", g.argv[0], z);
350 }
351 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
352
353 /*
354 ** Print a usage comment and quit
355 */
356 void usage(const char *zFormat){
@@ -608,10 +649,14 @@
608 if( stat(zRepo, &sStat)!=0 ){
609 fossil_fatal("cannot stat() repository: %s", zRepo);
610 }
611 setgid(sStat.st_gid);
612 setuid(sStat.st_uid);
 
 
 
 
613 }
614 #endif
615 return zRepo;
616 }
617
@@ -651,10 +696,11 @@
651 ** characters other than alphanumerics, "-", and "_".
652 */
653 for(j=strlen(g.zRepositoryName)+1, k=0; k<i-1; j++, k++){
654 if( !isalnum(zRepo[j]) && zRepo[j]!='-' ) zRepo[j] = '_';
655 }
 
656
657 if( file_size(zRepo)<1024 ){
658 if( zNotFound ){
659 cgi_redirect(zNotFound);
660 }else{
661
--- src/main.c
+++ src/main.c
@@ -226,10 +226,11 @@
226 int main(int argc, char **argv){
227 const char *zCmdName;
228 int idx;
229 int rc;
230
231 sqlite3_config(SQLITE_CONFIG_LOG, fossil_sqlite_log, 0);
232 g.now = time(0);
233 g.argc = argc;
234 g.argv = argv;
235 if( getenv("GATEWAY_INTERFACE")!=0 ){
236 zCmdName = "cgi";
@@ -347,10 +348,50 @@
348 cgi_printf("<p><font color=\"red\">%h</font></p>", z);
349 }else{
350 fprintf(stderr, "%s: %s\n", g.argv[0], z);
351 }
352 }
353
354 /*
355 ** Return a name for an SQLite error code
356 */
357 static const char *sqlite_error_code_name(int iCode){
358 static char zCode[30];
359 switch( iCode & 0xff ){
360 case SQLITE_OK: return "SQLITE_OK";
361 case SQLITE_ERROR: return "SQLITE_ERROR";
362 case SQLITE_PERM: return "SQLITE_PERM";
363 case SQLITE_ABORT: return "SQLITE_ABORT";
364 case SQLITE_BUSY: return "SQLITE_BUSY";
365 case SQLITE_NOMEM: return "SQLITE_NOMEM";
366 case SQLITE_READONLY: return "SQLITE_READONLY";
367 case SQLITE_INTERRUPT: return "SQLITE_INTERRUPT";
368 case SQLITE_IOERR: return "SQLITE_IOERR";
369 case SQLITE_CORRUPT: return "SQLITE_CORRUPT";
370 case SQLITE_FULL: return "SQLITE_FULL";
371 case SQLITE_CANTOPEN: return "SQLITE_CANTOPEN";
372 case SQLITE_PROTOCOL: return "SQLITE_PROTOCOL";
373 case SQLITE_EMPTY: return "SQLITE_EMPTY";
374 case SQLITE_SCHEMA: return "SQLITE_SCHEMA";
375 case SQLITE_CONSTRAINT: return "SQLITE_CONSTRAINT";
376 case SQLITE_MISMATCH: return "SQLITE_MISMATCH";
377 case SQLITE_MISUSE: return "SQLITE_MISUSE";
378 case SQLITE_NOLFS: return "SQLITE_NOLFS";
379 case SQLITE_FORMAT: return "SQLITE_FORMAT";
380 case SQLITE_RANGE: return "SQLITE_RANGE";
381 case SQLITE_NOTADB: return "SQLITE_NOTADB";
382 default: {
383 sqlite3_snprintf(sizeof(zCode),zCode,"error code %d",iCode);
384 }
385 }
386 return zCode;
387 }
388
389 /* Error logs from SQLite */
390 void fossil_sqlite_log(void *notUsed, int iCode, const char *zErrmsg){
391 fossil_warning("%s: %s", sqlite_error_code_name(iCode), zErrmsg);
392 }
393
394 /*
395 ** Print a usage comment and quit
396 */
397 void usage(const char *zFormat){
@@ -608,10 +649,14 @@
649 if( stat(zRepo, &sStat)!=0 ){
650 fossil_fatal("cannot stat() repository: %s", zRepo);
651 }
652 setgid(sStat.st_gid);
653 setuid(sStat.st_uid);
654 if( g.db!=0 ){
655 db_close();
656 db_open_repository(zRepo);
657 }
658 }
659 #endif
660 return zRepo;
661 }
662
@@ -651,10 +696,11 @@
696 ** characters other than alphanumerics, "-", and "_".
697 */
698 for(j=strlen(g.zRepositoryName)+1, k=0; k<i-1; j++, k++){
699 if( !isalnum(zRepo[j]) && zRepo[j]!='-' ) zRepo[j] = '_';
700 }
701 if( zRepo[0]=='/' && zRepo[1]=='/' ) zRepo++;
702
703 if( file_size(zRepo)<1024 ){
704 if( zNotFound ){
705 cgi_redirect(zNotFound);
706 }else{
707
+16 -11
--- src/name.c
+++ src/name.c
@@ -280,20 +280,25 @@
280280
*/
281281
int name_to_rid(const char *zName){
282282
int i;
283283
int rid;
284284
Blob name;
285
- for(i=0; zName[i] && isdigit(zName[i]); i++){}
286
- if( zName[i]==0 ){
287
- rid = atoi(zName);
288
- if( db_exists("SELECT 1 FROM blob WHERE rid=%d", rid) ){
289
- return rid;
290
- }
291
- }
285
+
286
+ if( zName==0 || zName[0]==0 ) return 0;
292287
blob_init(&name, zName, -1);
293
- if( name_to_uuid(&name, 1) ){
294
- fossil_fatal("%s", g.zErrMsg);
288
+ if( name_to_uuid(&name, -1) ){
289
+ blob_reset(&name);
290
+ for(i=0; zName[i] && isdigit(zName[i]); i++){}
291
+ if( zName[i]==0 ){
292
+ rid = atoi(zName);
293
+ if( db_exists("SELECT 1 FROM blob WHERE rid=%d", rid) ){
294
+ return rid;
295
+ }
296
+ }
297
+ fossil_error(1, "no such artifact: %s", zName);
298
+ return 0;
299
+ }else{
300
+ rid = db_int(0, "SELECT rid FROM blob WHERE uuid=%B", &name);
301
+ blob_reset(&name);
295302
}
296
- rid = db_int(0, "SELECT rid FROM blob WHERE uuid=%B", &name);
297
- blob_reset(&name);
298303
return rid;
299304
}
300305
--- src/name.c
+++ src/name.c
@@ -280,20 +280,25 @@
280 */
281 int name_to_rid(const char *zName){
282 int i;
283 int rid;
284 Blob name;
285 for(i=0; zName[i] && isdigit(zName[i]); i++){}
286 if( zName[i]==0 ){
287 rid = atoi(zName);
288 if( db_exists("SELECT 1 FROM blob WHERE rid=%d", rid) ){
289 return rid;
290 }
291 }
292 blob_init(&name, zName, -1);
293 if( name_to_uuid(&name, 1) ){
294 fossil_fatal("%s", g.zErrMsg);
 
 
 
 
 
 
 
 
 
 
 
 
295 }
296 rid = db_int(0, "SELECT rid FROM blob WHERE uuid=%B", &name);
297 blob_reset(&name);
298 return rid;
299 }
300
--- src/name.c
+++ src/name.c
@@ -280,20 +280,25 @@
280 */
281 int name_to_rid(const char *zName){
282 int i;
283 int rid;
284 Blob name;
285
286 if( zName==0 || zName[0]==0 ) return 0;
 
 
 
 
 
287 blob_init(&name, zName, -1);
288 if( name_to_uuid(&name, -1) ){
289 blob_reset(&name);
290 for(i=0; zName[i] && isdigit(zName[i]); i++){}
291 if( zName[i]==0 ){
292 rid = atoi(zName);
293 if( db_exists("SELECT 1 FROM blob WHERE rid=%d", rid) ){
294 return rid;
295 }
296 }
297 fossil_error(1, "no such artifact: %s", zName);
298 return 0;
299 }else{
300 rid = db_int(0, "SELECT rid FROM blob WHERE uuid=%B", &name);
301 blob_reset(&name);
302 }
 
 
303 return rid;
304 }
305
--- src/printf.c
+++ src/printf.c
@@ -52,10 +52,11 @@
5252
#define etURLIZE 18 /* Make text safe for HTTP. "/" not encoded */
5353
#define etFOSSILIZE 19 /* The fossil header encoding format. */
5454
#define etPATH 20 /* Path type */
5555
#define etWIKISTR 21 /* Wiki text rendered from a char* */
5656
#define etWIKIBLOB 22 /* Wiki text rendered from a Blob* */
57
+#define etSTRINGID 23 /* String with length limit for a UUID prefix */
5758
5859
5960
/*
6061
** An "etByte" is an 8-bit unsigned value.
6162
*/
@@ -101,10 +102,11 @@
101102
{ 'W', 0, 2, etWIKIBLOB, 0, 0 },
102103
{ 'h', 0, 4, etHTMLIZE, 0, 0 },
103104
{ 't', 0, 4, etHTTPIZE, 0, 0 }, /* "/" -> "%2F" */
104105
{ 'T', 0, 4, etURLIZE, 0, 0 }, /* "/" unchanged */
105106
{ 'F', 0, 4, etFOSSILIZE, 0, 0 },
107
+ { 'S', 0, 4, etSTRINGID, 0, 0 },
106108
{ 'c', 0, 0, etCHARX, 0, 0 },
107109
{ 'o', 8, 0, etRADIX, 0, 2 },
108110
{ 'u', 10, 0, etRADIX, 0, 0 },
109111
{ 'x', 16, 0, etRADIX, 16, 1 },
110112
{ 'X', 16, 0, etRADIX, 0, 4 },
@@ -575,10 +577,14 @@
575577
}
576578
}
577579
bufpt[length]='\0';
578580
break;
579581
}
582
+ case etSTRINGID: {
583
+ precision = 16;
584
+ /* Fall through */
585
+ }
580586
case etSTRING:
581587
case etDYNSTRING: {
582588
int limit = flag_alternateform ? va_arg(ap,int) : -1;
583589
bufpt = va_arg(ap,char*);
584590
if( bufpt==0 ){
585591
--- src/printf.c
+++ src/printf.c
@@ -52,10 +52,11 @@
52 #define etURLIZE 18 /* Make text safe for HTTP. "/" not encoded */
53 #define etFOSSILIZE 19 /* The fossil header encoding format. */
54 #define etPATH 20 /* Path type */
55 #define etWIKISTR 21 /* Wiki text rendered from a char* */
56 #define etWIKIBLOB 22 /* Wiki text rendered from a Blob* */
 
57
58
59 /*
60 ** An "etByte" is an 8-bit unsigned value.
61 */
@@ -101,10 +102,11 @@
101 { 'W', 0, 2, etWIKIBLOB, 0, 0 },
102 { 'h', 0, 4, etHTMLIZE, 0, 0 },
103 { 't', 0, 4, etHTTPIZE, 0, 0 }, /* "/" -> "%2F" */
104 { 'T', 0, 4, etURLIZE, 0, 0 }, /* "/" unchanged */
105 { 'F', 0, 4, etFOSSILIZE, 0, 0 },
 
106 { 'c', 0, 0, etCHARX, 0, 0 },
107 { 'o', 8, 0, etRADIX, 0, 2 },
108 { 'u', 10, 0, etRADIX, 0, 0 },
109 { 'x', 16, 0, etRADIX, 16, 1 },
110 { 'X', 16, 0, etRADIX, 0, 4 },
@@ -575,10 +577,14 @@
575 }
576 }
577 bufpt[length]='\0';
578 break;
579 }
 
 
 
 
580 case etSTRING:
581 case etDYNSTRING: {
582 int limit = flag_alternateform ? va_arg(ap,int) : -1;
583 bufpt = va_arg(ap,char*);
584 if( bufpt==0 ){
585
--- src/printf.c
+++ src/printf.c
@@ -52,10 +52,11 @@
52 #define etURLIZE 18 /* Make text safe for HTTP. "/" not encoded */
53 #define etFOSSILIZE 19 /* The fossil header encoding format. */
54 #define etPATH 20 /* Path type */
55 #define etWIKISTR 21 /* Wiki text rendered from a char* */
56 #define etWIKIBLOB 22 /* Wiki text rendered from a Blob* */
57 #define etSTRINGID 23 /* String with length limit for a UUID prefix */
58
59
60 /*
61 ** An "etByte" is an 8-bit unsigned value.
62 */
@@ -101,10 +102,11 @@
102 { 'W', 0, 2, etWIKIBLOB, 0, 0 },
103 { 'h', 0, 4, etHTMLIZE, 0, 0 },
104 { 't', 0, 4, etHTTPIZE, 0, 0 }, /* "/" -> "%2F" */
105 { 'T', 0, 4, etURLIZE, 0, 0 }, /* "/" unchanged */
106 { 'F', 0, 4, etFOSSILIZE, 0, 0 },
107 { 'S', 0, 4, etSTRINGID, 0, 0 },
108 { 'c', 0, 0, etCHARX, 0, 0 },
109 { 'o', 8, 0, etRADIX, 0, 2 },
110 { 'u', 10, 0, etRADIX, 0, 0 },
111 { 'x', 16, 0, etRADIX, 16, 1 },
112 { 'X', 16, 0, etRADIX, 0, 4 },
@@ -575,10 +577,14 @@
577 }
578 }
579 bufpt[length]='\0';
580 break;
581 }
582 case etSTRINGID: {
583 precision = 16;
584 /* Fall through */
585 }
586 case etSTRING:
587 case etDYNSTRING: {
588 int limit = flag_alternateform ? va_arg(ap,int) : -1;
589 bufpt = va_arg(ap,char*);
590 if( bufpt==0 ){
591
--- src/report.c
+++ src/report.c
@@ -922,10 +922,14 @@
922922
style_submenu_element("Edit", "Edit", "rptedit?rn=%d", rn);
923923
}
924924
if( g.okTktFmt ){
925925
style_submenu_element("SQL", "SQL", "rptsql?rn=%d",rn);
926926
}
927
+ if( g.okNewTkt ){
928
+ style_submenu_element("New Ticket", "Create a new ticket",
929
+ "%s/tktnew", g.zTop);
930
+ }
927931
style_header(zTitle);
928932
output_color_key(zClrKey, 1,
929933
"border=0 cellpadding=3 cellspacing=0 class=\"report\"");
930934
@ <table border=1 cellpadding=2 cellspacing=0 class="report">
931935
sState.rn = rn;
932936
--- src/report.c
+++ src/report.c
@@ -922,10 +922,14 @@
922 style_submenu_element("Edit", "Edit", "rptedit?rn=%d", rn);
923 }
924 if( g.okTktFmt ){
925 style_submenu_element("SQL", "SQL", "rptsql?rn=%d",rn);
926 }
 
 
 
 
927 style_header(zTitle);
928 output_color_key(zClrKey, 1,
929 "border=0 cellpadding=3 cellspacing=0 class=\"report\"");
930 @ <table border=1 cellpadding=2 cellspacing=0 class="report">
931 sState.rn = rn;
932
--- src/report.c
+++ src/report.c
@@ -922,10 +922,14 @@
922 style_submenu_element("Edit", "Edit", "rptedit?rn=%d", rn);
923 }
924 if( g.okTktFmt ){
925 style_submenu_element("SQL", "SQL", "rptsql?rn=%d",rn);
926 }
927 if( g.okNewTkt ){
928 style_submenu_element("New Ticket", "Create a new ticket",
929 "%s/tktnew", g.zTop);
930 }
931 style_header(zTitle);
932 output_color_key(zClrKey, 1,
933 "border=0 cellpadding=3 cellspacing=0 class=\"report\"");
934 @ <table border=1 cellpadding=2 cellspacing=0 class="report">
935 sState.rn = rn;
936
+23 -15
--- src/setup.c
+++ src/setup.c
@@ -181,14 +181,14 @@
181181
@ <tr><td valign="top"><b>s</b></td>
182182
@ <td><i>Setup/Super-user:</i> Setup and configure this website</td></tr>
183183
@ <tr><td valign="top"><b>t</b></td>
184184
@ <td><i>Tkt-Report:</i> Create new bug summary reports</td></tr>
185185
@ <tr><td valign="top"><b>u</b></td>
186
- @ <td><i>Reader:</i> Inherit privileges of
186
+ @ <td><i>Reader:</i> Inherit privileges of
187187
@ user <tt>reader</tt></td></tr>
188188
@ <tr><td valign="top"><b>v</b></td>
189
- @ <td><i>Developer:</i> Inherit privileges of
189
+ @ <td><i>Developer:</i> Inherit privileges of
190190
@ user <tt>developer</tt></td></tr>
191191
@ <tr><td valign="top"><b>w</b></td>
192192
@ <td><i>Write-Tkt:</i> Edit tickets</td></tr>
193193
@ <tr><td valign="top"><b>z</b></td>
194194
@ <td><i>Zip download:</i> Download a baseline via the
@@ -598,11 +598,11 @@
598598
@ Login is prohibited if the password is an empty string.
599599
@ </p></li>
600600
@ </ul>
601601
@
602602
@ <h2>Special Logins</h2>
603
- @
603
+ @
604604
@ <ul>
605605
@ <li><p>
606606
@ No login is required for user "<b>nobody</b>". The capabilities
607607
@ of the <b>nobody</b> user are inherited by all users, regardless of
608608
@ whether or not they are logged in. To disable universal access
@@ -736,17 +736,16 @@
736736
@ from the ~/.fossil database. Password login is always required
737737
@ for incoming web connections on internet addresses other than
738738
@ 127.0.0.1.</p></li>
739739
740740
@ <hr>
741
- onoff_attribute("Show javascript button to fill in CAPTCHA",
742
- "auto-captcha", "autocaptcha", 0);
743
- @ <p>When enabled, a button appears on the login screen for user
744
- @ "anonymous" that will automatically fill in the CAPTCHA password.
745
- @ This is less secure that forcing the user to do it manually, but is
746
- @ probably secure enough and it is certainly more convenient for
747
- @ anonymous users.</p>
741
+ onoff_attribute("Allow REMOTE_USER authentication",
742
+ "remote_user_ok", "remote_user_ok", 0);
743
+ @ <p>When enabled, if the REMOTE_USER environment variable is set to the
744
+ @ login name of a valid user and no other login credentials are available,
745
+ @ then the REMOTE_USER is accepted as an authenticated user.
746
+ @ </p></li>
748747
749748
@ <hr>
750749
entry_attribute("Login expiration time", 6, "cookie-expire", "cex", "8766");
751750
@ <p>The number of hours for which a login is valid. This must be a
752751
@ positive number. The default is 8760 hours which is approximately equal
@@ -756,13 +755,22 @@
756755
entry_attribute("Download packet limit", 10, "max-download", "mxdwn",
757756
"5000000");
758757
@ <p>Fossil tries to limit out-bound sync, clone, and pull packets
759758
@ to this many bytes, uncompressed. If the client requires more data
760759
@ than this, then the client will issue multiple HTTP requests.
761
- @ Values below 1 million are not recommended. 5 million is a
760
+ @ Values below 1 million are not recommended. 5 million is a
762761
@ reasonable number.</p>
763762
763
+ @ <hr>
764
+ onoff_attribute("Show javascript button to fill in CAPTCHA",
765
+ "auto-captcha", "autocaptcha", 0);
766
+ @ <p>When enabled, a button appears on the login screen for user
767
+ @ "anonymous" that will automatically fill in the CAPTCHA password.
768
+ @ This is less secure that forcing the user to do it manually, but is
769
+ @ probably secure enough and it is certainly more convenient for
770
+ @ anonymous users.</p>
771
+
764772
@ <hr>
765773
@ <p><input type="submit" name="submit" value="Apply Changes"></p>
766774
@ </form>
767775
db_end_transaction(0);
768776
style_footer();
@@ -801,11 +809,11 @@
801809
@ show complete diffs of all file changes, or can just list the names of
802810
@ the files that have changed. Users can get to either page by
803811
@ clicking. This setting selects the default.</p>
804812
805813
@ <hr>
806
- entry_attribute("Max timeline comment length", 6,
814
+ entry_attribute("Max timeline comment length", 6,
807815
"timeline-max-comment", "tmc", "0");
808816
@ <p>The maximum length of a comment to be displayed in a timeline.
809817
@ "0" there is no length limit.</p>
810818
811819
@ <hr>
@@ -906,11 +914,11 @@
906914
@ <p><b>Note:</b> Press your browser Reload button after modifying the
907915
@ CSS in order to pull in the modified CSS file.</p>
908916
@ <hr>
909917
@ The default CSS is shown below for reference. Other examples
910918
@ of CSS files can be seen on the <a href="setup_skin">skins page</a>.
911
- @ See also the <a href="setup_header">header</a> and
919
+ @ See also the <a href="setup_header">header</a> and
912920
@ <a href="setup_footer">footer</a> editing screens.
913921
@ <blockquote><pre>
914922
@ %h(zDefaultCSS)
915923
@ </pre></blockquote>
916924
style_footer();
@@ -1009,11 +1017,11 @@
10091017
db_begin_transaction();
10101018
if( P("set")!=0 && zMime && zMime[0] && szImg>0 ){
10111019
Blob img;
10121020
Stmt ins;
10131021
blob_init(&img, aImg, szImg);
1014
- db_prepare(&ins,
1022
+ db_prepare(&ins,
10151023
"REPLACE INTO config(name, value)"
10161024
" VALUES('logo-image',:bytes)"
10171025
);
10181026
db_bind_blob(&ins, ":bytes", &img);
10191027
db_step(&ins);
@@ -1033,11 +1041,11 @@
10331041
}
10341042
style_header("Edit Project Logo");
10351043
@ <p>The current project logo has a MIME-Type of <b>%h(zMime)</b> and looks
10361044
@ like this:</p>
10371045
@ <blockquote><img src="%s(g.zTop)/logo" alt="logo"></blockquote>
1038
- @
1046
+ @
10391047
@ <p>The logo is accessible to all users at this URL:
10401048
@ <a href="%s(g.zBaseURL)/logo">%s(g.zBaseURL)/logo</a>.
10411049
@ The logo may or may not appear on each
10421050
@ page depending on the <a href="setup_editcss">CSS</a> and
10431051
@ <a href="setup_header">header setup</a>.</p>
10441052
--- src/setup.c
+++ src/setup.c
@@ -181,14 +181,14 @@
181 @ <tr><td valign="top"><b>s</b></td>
182 @ <td><i>Setup/Super-user:</i> Setup and configure this website</td></tr>
183 @ <tr><td valign="top"><b>t</b></td>
184 @ <td><i>Tkt-Report:</i> Create new bug summary reports</td></tr>
185 @ <tr><td valign="top"><b>u</b></td>
186 @ <td><i>Reader:</i> Inherit privileges of
187 @ user <tt>reader</tt></td></tr>
188 @ <tr><td valign="top"><b>v</b></td>
189 @ <td><i>Developer:</i> Inherit privileges of
190 @ user <tt>developer</tt></td></tr>
191 @ <tr><td valign="top"><b>w</b></td>
192 @ <td><i>Write-Tkt:</i> Edit tickets</td></tr>
193 @ <tr><td valign="top"><b>z</b></td>
194 @ <td><i>Zip download:</i> Download a baseline via the
@@ -598,11 +598,11 @@
598 @ Login is prohibited if the password is an empty string.
599 @ </p></li>
600 @ </ul>
601 @
602 @ <h2>Special Logins</h2>
603 @
604 @ <ul>
605 @ <li><p>
606 @ No login is required for user "<b>nobody</b>". The capabilities
607 @ of the <b>nobody</b> user are inherited by all users, regardless of
608 @ whether or not they are logged in. To disable universal access
@@ -736,17 +736,16 @@
736 @ from the ~/.fossil database. Password login is always required
737 @ for incoming web connections on internet addresses other than
738 @ 127.0.0.1.</p></li>
739
740 @ <hr>
741 onoff_attribute("Show javascript button to fill in CAPTCHA",
742 "auto-captcha", "autocaptcha", 0);
743 @ <p>When enabled, a button appears on the login screen for user
744 @ "anonymous" that will automatically fill in the CAPTCHA password.
745 @ This is less secure that forcing the user to do it manually, but is
746 @ probably secure enough and it is certainly more convenient for
747 @ anonymous users.</p>
748
749 @ <hr>
750 entry_attribute("Login expiration time", 6, "cookie-expire", "cex", "8766");
751 @ <p>The number of hours for which a login is valid. This must be a
752 @ positive number. The default is 8760 hours which is approximately equal
@@ -756,13 +755,22 @@
756 entry_attribute("Download packet limit", 10, "max-download", "mxdwn",
757 "5000000");
758 @ <p>Fossil tries to limit out-bound sync, clone, and pull packets
759 @ to this many bytes, uncompressed. If the client requires more data
760 @ than this, then the client will issue multiple HTTP requests.
761 @ Values below 1 million are not recommended. 5 million is a
762 @ reasonable number.</p>
763
 
 
 
 
 
 
 
 
 
764 @ <hr>
765 @ <p><input type="submit" name="submit" value="Apply Changes"></p>
766 @ </form>
767 db_end_transaction(0);
768 style_footer();
@@ -801,11 +809,11 @@
801 @ show complete diffs of all file changes, or can just list the names of
802 @ the files that have changed. Users can get to either page by
803 @ clicking. This setting selects the default.</p>
804
805 @ <hr>
806 entry_attribute("Max timeline comment length", 6,
807 "timeline-max-comment", "tmc", "0");
808 @ <p>The maximum length of a comment to be displayed in a timeline.
809 @ "0" there is no length limit.</p>
810
811 @ <hr>
@@ -906,11 +914,11 @@
906 @ <p><b>Note:</b> Press your browser Reload button after modifying the
907 @ CSS in order to pull in the modified CSS file.</p>
908 @ <hr>
909 @ The default CSS is shown below for reference. Other examples
910 @ of CSS files can be seen on the <a href="setup_skin">skins page</a>.
911 @ See also the <a href="setup_header">header</a> and
912 @ <a href="setup_footer">footer</a> editing screens.
913 @ <blockquote><pre>
914 @ %h(zDefaultCSS)
915 @ </pre></blockquote>
916 style_footer();
@@ -1009,11 +1017,11 @@
1009 db_begin_transaction();
1010 if( P("set")!=0 && zMime && zMime[0] && szImg>0 ){
1011 Blob img;
1012 Stmt ins;
1013 blob_init(&img, aImg, szImg);
1014 db_prepare(&ins,
1015 "REPLACE INTO config(name, value)"
1016 " VALUES('logo-image',:bytes)"
1017 );
1018 db_bind_blob(&ins, ":bytes", &img);
1019 db_step(&ins);
@@ -1033,11 +1041,11 @@
1033 }
1034 style_header("Edit Project Logo");
1035 @ <p>The current project logo has a MIME-Type of <b>%h(zMime)</b> and looks
1036 @ like this:</p>
1037 @ <blockquote><img src="%s(g.zTop)/logo" alt="logo"></blockquote>
1038 @
1039 @ <p>The logo is accessible to all users at this URL:
1040 @ <a href="%s(g.zBaseURL)/logo">%s(g.zBaseURL)/logo</a>.
1041 @ The logo may or may not appear on each
1042 @ page depending on the <a href="setup_editcss">CSS</a> and
1043 @ <a href="setup_header">header setup</a>.</p>
1044
--- src/setup.c
+++ src/setup.c
@@ -181,14 +181,14 @@
181 @ <tr><td valign="top"><b>s</b></td>
182 @ <td><i>Setup/Super-user:</i> Setup and configure this website</td></tr>
183 @ <tr><td valign="top"><b>t</b></td>
184 @ <td><i>Tkt-Report:</i> Create new bug summary reports</td></tr>
185 @ <tr><td valign="top"><b>u</b></td>
186 @ <td><i>Reader:</i> Inherit privileges of
187 @ user <tt>reader</tt></td></tr>
188 @ <tr><td valign="top"><b>v</b></td>
189 @ <td><i>Developer:</i> Inherit privileges of
190 @ user <tt>developer</tt></td></tr>
191 @ <tr><td valign="top"><b>w</b></td>
192 @ <td><i>Write-Tkt:</i> Edit tickets</td></tr>
193 @ <tr><td valign="top"><b>z</b></td>
194 @ <td><i>Zip download:</i> Download a baseline via the
@@ -598,11 +598,11 @@
598 @ Login is prohibited if the password is an empty string.
599 @ </p></li>
600 @ </ul>
601 @
602 @ <h2>Special Logins</h2>
603 @
604 @ <ul>
605 @ <li><p>
606 @ No login is required for user "<b>nobody</b>". The capabilities
607 @ of the <b>nobody</b> user are inherited by all users, regardless of
608 @ whether or not they are logged in. To disable universal access
@@ -736,17 +736,16 @@
736 @ from the ~/.fossil database. Password login is always required
737 @ for incoming web connections on internet addresses other than
738 @ 127.0.0.1.</p></li>
739
740 @ <hr>
741 onoff_attribute("Allow REMOTE_USER authentication",
742 "remote_user_ok", "remote_user_ok", 0);
743 @ <p>When enabled, if the REMOTE_USER environment variable is set to the
744 @ login name of a valid user and no other login credentials are available,
745 @ then the REMOTE_USER is accepted as an authenticated user.
746 @ </p></li>
 
747
748 @ <hr>
749 entry_attribute("Login expiration time", 6, "cookie-expire", "cex", "8766");
750 @ <p>The number of hours for which a login is valid. This must be a
751 @ positive number. The default is 8760 hours which is approximately equal
@@ -756,13 +755,22 @@
755 entry_attribute("Download packet limit", 10, "max-download", "mxdwn",
756 "5000000");
757 @ <p>Fossil tries to limit out-bound sync, clone, and pull packets
758 @ to this many bytes, uncompressed. If the client requires more data
759 @ than this, then the client will issue multiple HTTP requests.
760 @ Values below 1 million are not recommended. 5 million is a
761 @ reasonable number.</p>
762
763 @ <hr>
764 onoff_attribute("Show javascript button to fill in CAPTCHA",
765 "auto-captcha", "autocaptcha", 0);
766 @ <p>When enabled, a button appears on the login screen for user
767 @ "anonymous" that will automatically fill in the CAPTCHA password.
768 @ This is less secure that forcing the user to do it manually, but is
769 @ probably secure enough and it is certainly more convenient for
770 @ anonymous users.</p>
771
772 @ <hr>
773 @ <p><input type="submit" name="submit" value="Apply Changes"></p>
774 @ </form>
775 db_end_transaction(0);
776 style_footer();
@@ -801,11 +809,11 @@
809 @ show complete diffs of all file changes, or can just list the names of
810 @ the files that have changed. Users can get to either page by
811 @ clicking. This setting selects the default.</p>
812
813 @ <hr>
814 entry_attribute("Max timeline comment length", 6,
815 "timeline-max-comment", "tmc", "0");
816 @ <p>The maximum length of a comment to be displayed in a timeline.
817 @ "0" there is no length limit.</p>
818
819 @ <hr>
@@ -906,11 +914,11 @@
914 @ <p><b>Note:</b> Press your browser Reload button after modifying the
915 @ CSS in order to pull in the modified CSS file.</p>
916 @ <hr>
917 @ The default CSS is shown below for reference. Other examples
918 @ of CSS files can be seen on the <a href="setup_skin">skins page</a>.
919 @ See also the <a href="setup_header">header</a> and
920 @ <a href="setup_footer">footer</a> editing screens.
921 @ <blockquote><pre>
922 @ %h(zDefaultCSS)
923 @ </pre></blockquote>
924 style_footer();
@@ -1009,11 +1017,11 @@
1017 db_begin_transaction();
1018 if( P("set")!=0 && zMime && zMime[0] && szImg>0 ){
1019 Blob img;
1020 Stmt ins;
1021 blob_init(&img, aImg, szImg);
1022 db_prepare(&ins,
1023 "REPLACE INTO config(name, value)"
1024 " VALUES('logo-image',:bytes)"
1025 );
1026 db_bind_blob(&ins, ":bytes", &img);
1027 db_step(&ins);
@@ -1033,11 +1041,11 @@
1041 }
1042 style_header("Edit Project Logo");
1043 @ <p>The current project logo has a MIME-Type of <b>%h(zMime)</b> and looks
1044 @ like this:</p>
1045 @ <blockquote><img src="%s(g.zTop)/logo" alt="logo"></blockquote>
1046 @
1047 @ <p>The logo is accessible to all users at this URL:
1048 @ <a href="%s(g.zBaseURL)/logo">%s(g.zBaseURL)/logo</a>.
1049 @ The logo may or may not appear on each
1050 @ page depending on the <a href="setup_editcss">CSS</a> and
1051 @ <a href="setup_header">header setup</a>.</p>
1052
+23 -15
--- src/setup.c
+++ src/setup.c
@@ -181,14 +181,14 @@
181181
@ <tr><td valign="top"><b>s</b></td>
182182
@ <td><i>Setup/Super-user:</i> Setup and configure this website</td></tr>
183183
@ <tr><td valign="top"><b>t</b></td>
184184
@ <td><i>Tkt-Report:</i> Create new bug summary reports</td></tr>
185185
@ <tr><td valign="top"><b>u</b></td>
186
- @ <td><i>Reader:</i> Inherit privileges of
186
+ @ <td><i>Reader:</i> Inherit privileges of
187187
@ user <tt>reader</tt></td></tr>
188188
@ <tr><td valign="top"><b>v</b></td>
189
- @ <td><i>Developer:</i> Inherit privileges of
189
+ @ <td><i>Developer:</i> Inherit privileges of
190190
@ user <tt>developer</tt></td></tr>
191191
@ <tr><td valign="top"><b>w</b></td>
192192
@ <td><i>Write-Tkt:</i> Edit tickets</td></tr>
193193
@ <tr><td valign="top"><b>z</b></td>
194194
@ <td><i>Zip download:</i> Download a baseline via the
@@ -598,11 +598,11 @@
598598
@ Login is prohibited if the password is an empty string.
599599
@ </p></li>
600600
@ </ul>
601601
@
602602
@ <h2>Special Logins</h2>
603
- @
603
+ @
604604
@ <ul>
605605
@ <li><p>
606606
@ No login is required for user "<b>nobody</b>". The capabilities
607607
@ of the <b>nobody</b> user are inherited by all users, regardless of
608608
@ whether or not they are logged in. To disable universal access
@@ -736,17 +736,16 @@
736736
@ from the ~/.fossil database. Password login is always required
737737
@ for incoming web connections on internet addresses other than
738738
@ 127.0.0.1.</p></li>
739739
740740
@ <hr>
741
- onoff_attribute("Show javascript button to fill in CAPTCHA",
742
- "auto-captcha", "autocaptcha", 0);
743
- @ <p>When enabled, a button appears on the login screen for user
744
- @ "anonymous" that will automatically fill in the CAPTCHA password.
745
- @ This is less secure that forcing the user to do it manually, but is
746
- @ probably secure enough and it is certainly more convenient for
747
- @ anonymous users.</p>
741
+ onoff_attribute("Allow REMOTE_USER authentication",
742
+ "remote_user_ok", "remote_user_ok", 0);
743
+ @ <p>When enabled, if the REMOTE_USER environment variable is set to the
744
+ @ login name of a valid user and no other login credentials are available,
745
+ @ then the REMOTE_USER is accepted as an authenticated user.
746
+ @ </p></li>
748747
749748
@ <hr>
750749
entry_attribute("Login expiration time", 6, "cookie-expire", "cex", "8766");
751750
@ <p>The number of hours for which a login is valid. This must be a
752751
@ positive number. The default is 8760 hours which is approximately equal
@@ -756,13 +755,22 @@
756755
entry_attribute("Download packet limit", 10, "max-download", "mxdwn",
757756
"5000000");
758757
@ <p>Fossil tries to limit out-bound sync, clone, and pull packets
759758
@ to this many bytes, uncompressed. If the client requires more data
760759
@ than this, then the client will issue multiple HTTP requests.
761
- @ Values below 1 million are not recommended. 5 million is a
760
+ @ Values below 1 million are not recommended. 5 million is a
762761
@ reasonable number.</p>
763762
763
+ @ <hr>
764
+ onoff_attribute("Show javascript button to fill in CAPTCHA",
765
+ "auto-captcha", "autocaptcha", 0);
766
+ @ <p>When enabled, a button appears on the login screen for user
767
+ @ "anonymous" that will automatically fill in the CAPTCHA password.
768
+ @ This is less secure that forcing the user to do it manually, but is
769
+ @ probably secure enough and it is certainly more convenient for
770
+ @ anonymous users.</p>
771
+
764772
@ <hr>
765773
@ <p><input type="submit" name="submit" value="Apply Changes"></p>
766774
@ </form>
767775
db_end_transaction(0);
768776
style_footer();
@@ -801,11 +809,11 @@
801809
@ show complete diffs of all file changes, or can just list the names of
802810
@ the files that have changed. Users can get to either page by
803811
@ clicking. This setting selects the default.</p>
804812
805813
@ <hr>
806
- entry_attribute("Max timeline comment length", 6,
814
+ entry_attribute("Max timeline comment length", 6,
807815
"timeline-max-comment", "tmc", "0");
808816
@ <p>The maximum length of a comment to be displayed in a timeline.
809817
@ "0" there is no length limit.</p>
810818
811819
@ <hr>
@@ -906,11 +914,11 @@
906914
@ <p><b>Note:</b> Press your browser Reload button after modifying the
907915
@ CSS in order to pull in the modified CSS file.</p>
908916
@ <hr>
909917
@ The default CSS is shown below for reference. Other examples
910918
@ of CSS files can be seen on the <a href="setup_skin">skins page</a>.
911
- @ See also the <a href="setup_header">header</a> and
919
+ @ See also the <a href="setup_header">header</a> and
912920
@ <a href="setup_footer">footer</a> editing screens.
913921
@ <blockquote><pre>
914922
@ %h(zDefaultCSS)
915923
@ </pre></blockquote>
916924
style_footer();
@@ -1009,11 +1017,11 @@
10091017
db_begin_transaction();
10101018
if( P("set")!=0 && zMime && zMime[0] && szImg>0 ){
10111019
Blob img;
10121020
Stmt ins;
10131021
blob_init(&img, aImg, szImg);
1014
- db_prepare(&ins,
1022
+ db_prepare(&ins,
10151023
"REPLACE INTO config(name, value)"
10161024
" VALUES('logo-image',:bytes)"
10171025
);
10181026
db_bind_blob(&ins, ":bytes", &img);
10191027
db_step(&ins);
@@ -1033,11 +1041,11 @@
10331041
}
10341042
style_header("Edit Project Logo");
10351043
@ <p>The current project logo has a MIME-Type of <b>%h(zMime)</b> and looks
10361044
@ like this:</p>
10371045
@ <blockquote><img src="%s(g.zTop)/logo" alt="logo"></blockquote>
1038
- @
1046
+ @
10391047
@ <p>The logo is accessible to all users at this URL:
10401048
@ <a href="%s(g.zBaseURL)/logo">%s(g.zBaseURL)/logo</a>.
10411049
@ The logo may or may not appear on each
10421050
@ page depending on the <a href="setup_editcss">CSS</a> and
10431051
@ <a href="setup_header">header setup</a>.</p>
10441052
--- src/setup.c
+++ src/setup.c
@@ -181,14 +181,14 @@
181 @ <tr><td valign="top"><b>s</b></td>
182 @ <td><i>Setup/Super-user:</i> Setup and configure this website</td></tr>
183 @ <tr><td valign="top"><b>t</b></td>
184 @ <td><i>Tkt-Report:</i> Create new bug summary reports</td></tr>
185 @ <tr><td valign="top"><b>u</b></td>
186 @ <td><i>Reader:</i> Inherit privileges of
187 @ user <tt>reader</tt></td></tr>
188 @ <tr><td valign="top"><b>v</b></td>
189 @ <td><i>Developer:</i> Inherit privileges of
190 @ user <tt>developer</tt></td></tr>
191 @ <tr><td valign="top"><b>w</b></td>
192 @ <td><i>Write-Tkt:</i> Edit tickets</td></tr>
193 @ <tr><td valign="top"><b>z</b></td>
194 @ <td><i>Zip download:</i> Download a baseline via the
@@ -598,11 +598,11 @@
598 @ Login is prohibited if the password is an empty string.
599 @ </p></li>
600 @ </ul>
601 @
602 @ <h2>Special Logins</h2>
603 @
604 @ <ul>
605 @ <li><p>
606 @ No login is required for user "<b>nobody</b>". The capabilities
607 @ of the <b>nobody</b> user are inherited by all users, regardless of
608 @ whether or not they are logged in. To disable universal access
@@ -736,17 +736,16 @@
736 @ from the ~/.fossil database. Password login is always required
737 @ for incoming web connections on internet addresses other than
738 @ 127.0.0.1.</p></li>
739
740 @ <hr>
741 onoff_attribute("Show javascript button to fill in CAPTCHA",
742 "auto-captcha", "autocaptcha", 0);
743 @ <p>When enabled, a button appears on the login screen for user
744 @ "anonymous" that will automatically fill in the CAPTCHA password.
745 @ This is less secure that forcing the user to do it manually, but is
746 @ probably secure enough and it is certainly more convenient for
747 @ anonymous users.</p>
748
749 @ <hr>
750 entry_attribute("Login expiration time", 6, "cookie-expire", "cex", "8766");
751 @ <p>The number of hours for which a login is valid. This must be a
752 @ positive number. The default is 8760 hours which is approximately equal
@@ -756,13 +755,22 @@
756 entry_attribute("Download packet limit", 10, "max-download", "mxdwn",
757 "5000000");
758 @ <p>Fossil tries to limit out-bound sync, clone, and pull packets
759 @ to this many bytes, uncompressed. If the client requires more data
760 @ than this, then the client will issue multiple HTTP requests.
761 @ Values below 1 million are not recommended. 5 million is a
762 @ reasonable number.</p>
763
 
 
 
 
 
 
 
 
 
764 @ <hr>
765 @ <p><input type="submit" name="submit" value="Apply Changes"></p>
766 @ </form>
767 db_end_transaction(0);
768 style_footer();
@@ -801,11 +809,11 @@
801 @ show complete diffs of all file changes, or can just list the names of
802 @ the files that have changed. Users can get to either page by
803 @ clicking. This setting selects the default.</p>
804
805 @ <hr>
806 entry_attribute("Max timeline comment length", 6,
807 "timeline-max-comment", "tmc", "0");
808 @ <p>The maximum length of a comment to be displayed in a timeline.
809 @ "0" there is no length limit.</p>
810
811 @ <hr>
@@ -906,11 +914,11 @@
906 @ <p><b>Note:</b> Press your browser Reload button after modifying the
907 @ CSS in order to pull in the modified CSS file.</p>
908 @ <hr>
909 @ The default CSS is shown below for reference. Other examples
910 @ of CSS files can be seen on the <a href="setup_skin">skins page</a>.
911 @ See also the <a href="setup_header">header</a> and
912 @ <a href="setup_footer">footer</a> editing screens.
913 @ <blockquote><pre>
914 @ %h(zDefaultCSS)
915 @ </pre></blockquote>
916 style_footer();
@@ -1009,11 +1017,11 @@
1009 db_begin_transaction();
1010 if( P("set")!=0 && zMime && zMime[0] && szImg>0 ){
1011 Blob img;
1012 Stmt ins;
1013 blob_init(&img, aImg, szImg);
1014 db_prepare(&ins,
1015 "REPLACE INTO config(name, value)"
1016 " VALUES('logo-image',:bytes)"
1017 );
1018 db_bind_blob(&ins, ":bytes", &img);
1019 db_step(&ins);
@@ -1033,11 +1041,11 @@
1033 }
1034 style_header("Edit Project Logo");
1035 @ <p>The current project logo has a MIME-Type of <b>%h(zMime)</b> and looks
1036 @ like this:</p>
1037 @ <blockquote><img src="%s(g.zTop)/logo" alt="logo"></blockquote>
1038 @
1039 @ <p>The logo is accessible to all users at this URL:
1040 @ <a href="%s(g.zBaseURL)/logo">%s(g.zBaseURL)/logo</a>.
1041 @ The logo may or may not appear on each
1042 @ page depending on the <a href="setup_editcss">CSS</a> and
1043 @ <a href="setup_header">header setup</a>.</p>
1044
--- src/setup.c
+++ src/setup.c
@@ -181,14 +181,14 @@
181 @ <tr><td valign="top"><b>s</b></td>
182 @ <td><i>Setup/Super-user:</i> Setup and configure this website</td></tr>
183 @ <tr><td valign="top"><b>t</b></td>
184 @ <td><i>Tkt-Report:</i> Create new bug summary reports</td></tr>
185 @ <tr><td valign="top"><b>u</b></td>
186 @ <td><i>Reader:</i> Inherit privileges of
187 @ user <tt>reader</tt></td></tr>
188 @ <tr><td valign="top"><b>v</b></td>
189 @ <td><i>Developer:</i> Inherit privileges of
190 @ user <tt>developer</tt></td></tr>
191 @ <tr><td valign="top"><b>w</b></td>
192 @ <td><i>Write-Tkt:</i> Edit tickets</td></tr>
193 @ <tr><td valign="top"><b>z</b></td>
194 @ <td><i>Zip download:</i> Download a baseline via the
@@ -598,11 +598,11 @@
598 @ Login is prohibited if the password is an empty string.
599 @ </p></li>
600 @ </ul>
601 @
602 @ <h2>Special Logins</h2>
603 @
604 @ <ul>
605 @ <li><p>
606 @ No login is required for user "<b>nobody</b>". The capabilities
607 @ of the <b>nobody</b> user are inherited by all users, regardless of
608 @ whether or not they are logged in. To disable universal access
@@ -736,17 +736,16 @@
736 @ from the ~/.fossil database. Password login is always required
737 @ for incoming web connections on internet addresses other than
738 @ 127.0.0.1.</p></li>
739
740 @ <hr>
741 onoff_attribute("Allow REMOTE_USER authentication",
742 "remote_user_ok", "remote_user_ok", 0);
743 @ <p>When enabled, if the REMOTE_USER environment variable is set to the
744 @ login name of a valid user and no other login credentials are available,
745 @ then the REMOTE_USER is accepted as an authenticated user.
746 @ </p></li>
 
747
748 @ <hr>
749 entry_attribute("Login expiration time", 6, "cookie-expire", "cex", "8766");
750 @ <p>The number of hours for which a login is valid. This must be a
751 @ positive number. The default is 8760 hours which is approximately equal
@@ -756,13 +755,22 @@
755 entry_attribute("Download packet limit", 10, "max-download", "mxdwn",
756 "5000000");
757 @ <p>Fossil tries to limit out-bound sync, clone, and pull packets
758 @ to this many bytes, uncompressed. If the client requires more data
759 @ than this, then the client will issue multiple HTTP requests.
760 @ Values below 1 million are not recommended. 5 million is a
761 @ reasonable number.</p>
762
763 @ <hr>
764 onoff_attribute("Show javascript button to fill in CAPTCHA",
765 "auto-captcha", "autocaptcha", 0);
766 @ <p>When enabled, a button appears on the login screen for user
767 @ "anonymous" that will automatically fill in the CAPTCHA password.
768 @ This is less secure that forcing the user to do it manually, but is
769 @ probably secure enough and it is certainly more convenient for
770 @ anonymous users.</p>
771
772 @ <hr>
773 @ <p><input type="submit" name="submit" value="Apply Changes"></p>
774 @ </form>
775 db_end_transaction(0);
776 style_footer();
@@ -801,11 +809,11 @@
809 @ show complete diffs of all file changes, or can just list the names of
810 @ the files that have changed. Users can get to either page by
811 @ clicking. This setting selects the default.</p>
812
813 @ <hr>
814 entry_attribute("Max timeline comment length", 6,
815 "timeline-max-comment", "tmc", "0");
816 @ <p>The maximum length of a comment to be displayed in a timeline.
817 @ "0" there is no length limit.</p>
818
819 @ <hr>
@@ -906,11 +914,11 @@
914 @ <p><b>Note:</b> Press your browser Reload button after modifying the
915 @ CSS in order to pull in the modified CSS file.</p>
916 @ <hr>
917 @ The default CSS is shown below for reference. Other examples
918 @ of CSS files can be seen on the <a href="setup_skin">skins page</a>.
919 @ See also the <a href="setup_header">header</a> and
920 @ <a href="setup_footer">footer</a> editing screens.
921 @ <blockquote><pre>
922 @ %h(zDefaultCSS)
923 @ </pre></blockquote>
924 style_footer();
@@ -1009,11 +1017,11 @@
1017 db_begin_transaction();
1018 if( P("set")!=0 && zMime && zMime[0] && szImg>0 ){
1019 Blob img;
1020 Stmt ins;
1021 blob_init(&img, aImg, szImg);
1022 db_prepare(&ins,
1023 "REPLACE INTO config(name, value)"
1024 " VALUES('logo-image',:bytes)"
1025 );
1026 db_bind_blob(&ins, ":bytes", &img);
1027 db_step(&ins);
@@ -1033,11 +1041,11 @@
1041 }
1042 style_header("Edit Project Logo");
1043 @ <p>The current project logo has a MIME-Type of <b>%h(zMime)</b> and looks
1044 @ like this:</p>
1045 @ <blockquote><img src="%s(g.zTop)/logo" alt="logo"></blockquote>
1046 @
1047 @ <p>The logo is accessible to all users at this URL:
1048 @ <a href="%s(g.zBaseURL)/logo">%s(g.zBaseURL)/logo</a>.
1049 @ The logo may or may not appear on each
1050 @ page depending on the <a href="setup_editcss">CSS</a> and
1051 @ <a href="setup_header">header setup</a>.</p>
1052
+511 -427
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1,8 +1,8 @@
11
/******************************************************************************
22
** This file is an amalgamation of many separate C source files from SQLite
3
-** version 3.6.23. By combining all the individual C code files into this
3
+** version 3.6.23.1. By combining all the individual C code files into this
44
** single large file, the entire code can be compiled as a one translation
55
** unit. This allows many compilers to do optimizations that would not be
66
** possible if the files were compiled separately. Performance improvements
77
** of 5% are more are commonly seen when SQLite is compiled as a single
88
** translation unit.
@@ -626,13 +626,13 @@
626626
**
627627
** See also: [sqlite3_libversion()],
628628
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
629629
** [sqlite_version()] and [sqlite_source_id()].
630630
*/
631
-#define SQLITE_VERSION "3.6.23"
631
+#define SQLITE_VERSION "3.6.23.1"
632632
#define SQLITE_VERSION_NUMBER 3006023
633
-#define SQLITE_SOURCE_ID "2010-03-05 13:53:23 27413fc8dd52b754b4be9344a66bb9e0d752d48e"
633
+#define SQLITE_SOURCE_ID "2010-03-26 22:28:06 ex-b078b588d617e07886ad156e9f54ade6d823568e"
634634
635635
/*
636636
** CAPI3REF: Run-Time Library Version Numbers
637637
** KEYWORDS: sqlite3_version, sqlite3_sourceid
638638
**
@@ -10425,11 +10425,11 @@
1042510425
SQLITE_PRIVATE int sqlite3ValueBytes(sqlite3_value*, u8);
1042610426
SQLITE_PRIVATE void sqlite3ValueSetStr(sqlite3_value*, int, const void *,u8,
1042710427
void(*)(void*));
1042810428
SQLITE_PRIVATE void sqlite3ValueFree(sqlite3_value*);
1042910429
SQLITE_PRIVATE sqlite3_value *sqlite3ValueNew(sqlite3 *);
10430
-SQLITE_PRIVATE char *sqlite3Utf16to8(sqlite3 *, const void*, int);
10430
+SQLITE_PRIVATE char *sqlite3Utf16to8(sqlite3 *, const void*, int, u8);
1043110431
#ifdef SQLITE_ENABLE_STAT2
1043210432
SQLITE_PRIVATE char *sqlite3Utf8to16(sqlite3 *, u8, char *, int, int *);
1043310433
#endif
1043410434
SQLITE_PRIVATE int sqlite3ValueFromExpr(sqlite3 *, Expr *, u8, u8, sqlite3_value **);
1043510435
SQLITE_PRIVATE void sqlite3ValueApplyAffinity(sqlite3_value *, u8, u8);
@@ -10866,10 +10866,397 @@
1086610866
** the vdbe.c file.
1086710867
*/
1086810868
SQLITE_PRIVATE const unsigned char sqlite3OpcodeProperty[] = OPFLG_INITIALIZER;
1086910869
1087010870
/************** End of global.c **********************************************/
10871
+/************** Begin file ctime.c *******************************************/
10872
+/*
10873
+** 2010 February 23
10874
+**
10875
+** The author disclaims copyright to this source code. In place of
10876
+** a legal notice, here is a blessing:
10877
+**
10878
+** May you do good and not evil.
10879
+** May you find forgiveness for yourself and forgive others.
10880
+** May you share freely, never taking more than you give.
10881
+**
10882
+*************************************************************************
10883
+**
10884
+** This file implements routines used to report what compile-time options
10885
+** SQLite was built with.
10886
+*/
10887
+
10888
+#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
10889
+
10890
+
10891
+/*
10892
+** An array of names of all compile-time options. This array should
10893
+** be sorted A-Z.
10894
+**
10895
+** This array looks large, but in a typical installation actually uses
10896
+** only a handful of compile-time options, so most times this array is usually
10897
+** rather short and uses little memory space.
10898
+*/
10899
+static const char * const azCompileOpt[] = {
10900
+
10901
+/* These macros are provided to "stringify" the value of the define
10902
+** for those options in which the value is meaningful. */
10903
+#define CTIMEOPT_VAL_(opt) #opt
10904
+#define CTIMEOPT_VAL(opt) CTIMEOPT_VAL_(opt)
10905
+
10906
+#ifdef SQLITE_32BIT_ROWID
10907
+ "32BIT_ROWID",
10908
+#endif
10909
+#ifdef SQLITE_4_BYTE_ALIGNED_MALLOC
10910
+ "4_BYTE_ALIGNED_MALLOC",
10911
+#endif
10912
+#ifdef SQLITE_CASE_SENSITIVE_LIKE
10913
+ "CASE_SENSITIVE_LIKE",
10914
+#endif
10915
+#ifdef SQLITE_CHECK_PAGES
10916
+ "CHECK_PAGES",
10917
+#endif
10918
+#ifdef SQLITE_COVERAGE_TEST
10919
+ "COVERAGE_TEST",
10920
+#endif
10921
+#ifdef SQLITE_DEBUG
10922
+ "DEBUG",
10923
+#endif
10924
+#ifdef SQLITE_DEFAULT_LOCKING_MODE
10925
+ "DEFAULT_LOCKING_MODE=" CTIMEOPT_VAL(SQLITE_DEFAULT_LOCKING_MODE),
10926
+#endif
10927
+#ifdef SQLITE_DISABLE_DIRSYNC
10928
+ "DISABLE_DIRSYNC",
10929
+#endif
10930
+#ifdef SQLITE_DISABLE_LFS
10931
+ "DISABLE_LFS",
10932
+#endif
10933
+#ifdef SQLITE_ENABLE_ATOMIC_WRITE
10934
+ "ENABLE_ATOMIC_WRITE",
10935
+#endif
10936
+#ifdef SQLITE_ENABLE_CEROD
10937
+ "ENABLE_CEROD",
10938
+#endif
10939
+#ifdef SQLITE_ENABLE_COLUMN_METADATA
10940
+ "ENABLE_COLUMN_METADATA",
10941
+#endif
10942
+#ifdef SQLITE_ENABLE_EXPENSIVE_ASSERT
10943
+ "ENABLE_EXPENSIVE_ASSERT",
10944
+#endif
10945
+#ifdef SQLITE_ENABLE_FTS1
10946
+ "ENABLE_FTS1",
10947
+#endif
10948
+#ifdef SQLITE_ENABLE_FTS2
10949
+ "ENABLE_FTS2",
10950
+#endif
10951
+#ifdef SQLITE_ENABLE_FTS3
10952
+ "ENABLE_FTS3",
10953
+#endif
10954
+#ifdef SQLITE_ENABLE_FTS3_PARENTHESIS
10955
+ "ENABLE_FTS3_PARENTHESIS",
10956
+#endif
10957
+#ifdef SQLITE_ENABLE_FTS4
10958
+ "ENABLE_FTS4",
10959
+#endif
10960
+#ifdef SQLITE_ENABLE_ICU
10961
+ "ENABLE_ICU",
10962
+#endif
10963
+#ifdef SQLITE_ENABLE_IOTRACE
10964
+ "ENABLE_IOTRACE",
10965
+#endif
10966
+#ifdef SQLITE_ENABLE_LOAD_EXTENSION
10967
+ "ENABLE_LOAD_EXTENSION",
10968
+#endif
10969
+#ifdef SQLITE_ENABLE_LOCKING_STYLE
10970
+ "ENABLE_LOCKING_STYLE=" CTIMEOPT_VAL(SQLITE_ENABLE_LOCKING_STYLE),
10971
+#endif
10972
+#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
10973
+ "ENABLE_MEMORY_MANAGEMENT",
10974
+#endif
10975
+#ifdef SQLITE_ENABLE_MEMSYS3
10976
+ "ENABLE_MEMSYS3",
10977
+#endif
10978
+#ifdef SQLITE_ENABLE_MEMSYS5
10979
+ "ENABLE_MEMSYS5",
10980
+#endif
10981
+#ifdef SQLITE_ENABLE_OVERSIZE_CELL_CHECK
10982
+ "ENABLE_OVERSIZE_CELL_CHECK",
10983
+#endif
10984
+#ifdef SQLITE_ENABLE_RTREE
10985
+ "ENABLE_RTREE",
10986
+#endif
10987
+#ifdef SQLITE_ENABLE_STAT2
10988
+ "ENABLE_STAT2",
10989
+#endif
10990
+#ifdef SQLITE_ENABLE_UNLOCK_NOTIFY
10991
+ "ENABLE_UNLOCK_NOTIFY",
10992
+#endif
10993
+#ifdef SQLITE_ENABLE_UPDATE_DELETE_LIMIT
10994
+ "ENABLE_UPDATE_DELETE_LIMIT",
10995
+#endif
10996
+#ifdef SQLITE_HAS_CODEC
10997
+ "HAS_CODEC",
10998
+#endif
10999
+#ifdef SQLITE_HAVE_ISNAN
11000
+ "HAVE_ISNAN",
11001
+#endif
11002
+#ifdef SQLITE_HOMEGROWN_RECURSIVE_MUTEX
11003
+ "HOMEGROWN_RECURSIVE_MUTEX",
11004
+#endif
11005
+#ifdef SQLITE_IGNORE_AFP_LOCK_ERRORS
11006
+ "IGNORE_AFP_LOCK_ERRORS",
11007
+#endif
11008
+#ifdef SQLITE_IGNORE_FLOCK_LOCK_ERRORS
11009
+ "IGNORE_FLOCK_LOCK_ERRORS",
11010
+#endif
11011
+#ifdef SQLITE_INT64_TYPE
11012
+ "INT64_TYPE",
11013
+#endif
11014
+#ifdef SQLITE_LOCK_TRACE
11015
+ "LOCK_TRACE",
11016
+#endif
11017
+#ifdef SQLITE_MEMDEBUG
11018
+ "MEMDEBUG",
11019
+#endif
11020
+#ifdef SQLITE_MIXED_ENDIAN_64BIT_FLOAT
11021
+ "MIXED_ENDIAN_64BIT_FLOAT",
11022
+#endif
11023
+#ifdef SQLITE_NO_SYNC
11024
+ "NO_SYNC",
11025
+#endif
11026
+#ifdef SQLITE_OMIT_ALTERTABLE
11027
+ "OMIT_ALTERTABLE",
11028
+#endif
11029
+#ifdef SQLITE_OMIT_ANALYZE
11030
+ "OMIT_ANALYZE",
11031
+#endif
11032
+#ifdef SQLITE_OMIT_ATTACH
11033
+ "OMIT_ATTACH",
11034
+#endif
11035
+#ifdef SQLITE_OMIT_AUTHORIZATION
11036
+ "OMIT_AUTHORIZATION",
11037
+#endif
11038
+#ifdef SQLITE_OMIT_AUTOINCREMENT
11039
+ "OMIT_AUTOINCREMENT",
11040
+#endif
11041
+#ifdef SQLITE_OMIT_AUTOINIT
11042
+ "OMIT_AUTOINIT",
11043
+#endif
11044
+#ifdef SQLITE_OMIT_AUTOVACUUM
11045
+ "OMIT_AUTOVACUUM",
11046
+#endif
11047
+#ifdef SQLITE_OMIT_BETWEEN_OPTIMIZATION
11048
+ "OMIT_BETWEEN_OPTIMIZATION",
11049
+#endif
11050
+#ifdef SQLITE_OMIT_BLOB_LITERAL
11051
+ "OMIT_BLOB_LITERAL",
11052
+#endif
11053
+#ifdef SQLITE_OMIT_BTREECOUNT
11054
+ "OMIT_BTREECOUNT",
11055
+#endif
11056
+#ifdef SQLITE_OMIT_BUILTIN_TEST
11057
+ "OMIT_BUILTIN_TEST",
11058
+#endif
11059
+#ifdef SQLITE_OMIT_CAST
11060
+ "OMIT_CAST",
11061
+#endif
11062
+#ifdef SQLITE_OMIT_CHECK
11063
+ "OMIT_CHECK",
11064
+#endif
11065
+#ifdef SQLITE_OMIT_COMPILEOPTION_DIAGS
11066
+ "OMIT_COMPILEOPTION_DIAGS",
11067
+#endif
11068
+#ifdef SQLITE_OMIT_COMPLETE
11069
+ "OMIT_COMPLETE",
11070
+#endif
11071
+#ifdef SQLITE_OMIT_COMPOUND_SELECT
11072
+ "OMIT_COMPOUND_SELECT",
11073
+#endif
11074
+#ifdef SQLITE_OMIT_DATETIME_FUNCS
11075
+ "OMIT_DATETIME_FUNCS",
11076
+#endif
11077
+#ifdef SQLITE_OMIT_DECLTYPE
11078
+ "OMIT_DECLTYPE",
11079
+#endif
11080
+#ifdef SQLITE_OMIT_DEPRECATED
11081
+ "OMIT_DEPRECATED",
11082
+#endif
11083
+#ifdef SQLITE_OMIT_DISKIO
11084
+ "OMIT_DISKIO",
11085
+#endif
11086
+#ifdef SQLITE_OMIT_EXPLAIN
11087
+ "OMIT_EXPLAIN",
11088
+#endif
11089
+#ifdef SQLITE_OMIT_FLAG_PRAGMAS
11090
+ "OMIT_FLAG_PRAGMAS",
11091
+#endif
11092
+#ifdef SQLITE_OMIT_FLOATING_POINT
11093
+ "OMIT_FLOATING_POINT",
11094
+#endif
11095
+#ifdef SQLITE_OMIT_FOREIGN_KEY
11096
+ "OMIT_FOREIGN_KEY",
11097
+#endif
11098
+#ifdef SQLITE_OMIT_GET_TABLE
11099
+ "OMIT_GET_TABLE",
11100
+#endif
11101
+#ifdef SQLITE_OMIT_GLOBALRECOVER
11102
+ "OMIT_GLOBALRECOVER",
11103
+#endif
11104
+#ifdef SQLITE_OMIT_INCRBLOB
11105
+ "OMIT_INCRBLOB",
11106
+#endif
11107
+#ifdef SQLITE_OMIT_INTEGRITY_CHECK
11108
+ "OMIT_INTEGRITY_CHECK",
11109
+#endif
11110
+#ifdef SQLITE_OMIT_LIKE_OPTIMIZATION
11111
+ "OMIT_LIKE_OPTIMIZATION",
11112
+#endif
11113
+#ifdef SQLITE_OMIT_LOAD_EXTENSION
11114
+ "OMIT_LOAD_EXTENSION",
11115
+#endif
11116
+#ifdef SQLITE_OMIT_LOCALTIME
11117
+ "OMIT_LOCALTIME",
11118
+#endif
11119
+#ifdef SQLITE_OMIT_LOOKASIDE
11120
+ "OMIT_LOOKASIDE",
11121
+#endif
11122
+#ifdef SQLITE_OMIT_MEMORYDB
11123
+ "OMIT_MEMORYDB",
11124
+#endif
11125
+#ifdef SQLITE_OMIT_OR_OPTIMIZATION
11126
+ "OMIT_OR_OPTIMIZATION",
11127
+#endif
11128
+#ifdef SQLITE_OMIT_PAGER_PRAGMAS
11129
+ "OMIT_PAGER_PRAGMAS",
11130
+#endif
11131
+#ifdef SQLITE_OMIT_PRAGMA
11132
+ "OMIT_PRAGMA",
11133
+#endif
11134
+#ifdef SQLITE_OMIT_PROGRESS_CALLBACK
11135
+ "OMIT_PROGRESS_CALLBACK",
11136
+#endif
11137
+#ifdef SQLITE_OMIT_QUICKBALANCE
11138
+ "OMIT_QUICKBALANCE",
11139
+#endif
11140
+#ifdef SQLITE_OMIT_REINDEX
11141
+ "OMIT_REINDEX",
11142
+#endif
11143
+#ifdef SQLITE_OMIT_SCHEMA_PRAGMAS
11144
+ "OMIT_SCHEMA_PRAGMAS",
11145
+#endif
11146
+#ifdef SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS
11147
+ "OMIT_SCHEMA_VERSION_PRAGMAS",
11148
+#endif
11149
+#ifdef SQLITE_OMIT_SHARED_CACHE
11150
+ "OMIT_SHARED_CACHE",
11151
+#endif
11152
+#ifdef SQLITE_OMIT_SUBQUERY
11153
+ "OMIT_SUBQUERY",
11154
+#endif
11155
+#ifdef SQLITE_OMIT_TCL_VARIABLE
11156
+ "OMIT_TCL_VARIABLE",
11157
+#endif
11158
+#ifdef SQLITE_OMIT_TEMPDB
11159
+ "OMIT_TEMPDB",
11160
+#endif
11161
+#ifdef SQLITE_OMIT_TRACE
11162
+ "OMIT_TRACE",
11163
+#endif
11164
+#ifdef SQLITE_OMIT_TRIGGER
11165
+ "OMIT_TRIGGER",
11166
+#endif
11167
+#ifdef SQLITE_OMIT_TRUNCATE_OPTIMIZATION
11168
+ "OMIT_TRUNCATE_OPTIMIZATION",
11169
+#endif
11170
+#ifdef SQLITE_OMIT_UTF16
11171
+ "OMIT_UTF16",
11172
+#endif
11173
+#ifdef SQLITE_OMIT_VACUUM
11174
+ "OMIT_VACUUM",
11175
+#endif
11176
+#ifdef SQLITE_OMIT_VIEW
11177
+ "OMIT_VIEW",
11178
+#endif
11179
+#ifdef SQLITE_OMIT_VIRTUALTABLE
11180
+ "OMIT_VIRTUALTABLE",
11181
+#endif
11182
+#ifdef SQLITE_OMIT_WSD
11183
+ "OMIT_WSD",
11184
+#endif
11185
+#ifdef SQLITE_OMIT_XFER_OPT
11186
+ "OMIT_XFER_OPT",
11187
+#endif
11188
+#ifdef SQLITE_PERFORMANCE_TRACE
11189
+ "PERFORMANCE_TRACE",
11190
+#endif
11191
+#ifdef SQLITE_PROXY_DEBUG
11192
+ "PROXY_DEBUG",
11193
+#endif
11194
+#ifdef SQLITE_SECURE_DELETE
11195
+ "SECURE_DELETE",
11196
+#endif
11197
+#ifdef SQLITE_SMALL_STACK
11198
+ "SMALL_STACK",
11199
+#endif
11200
+#ifdef SQLITE_SOUNDEX
11201
+ "SOUNDEX",
11202
+#endif
11203
+#ifdef SQLITE_TCL
11204
+ "TCL",
11205
+#endif
11206
+#ifdef SQLITE_TEMP_STORE
11207
+ "TEMP_STORE=" CTIMEOPT_VAL(SQLITE_TEMP_STORE),
11208
+#endif
11209
+#ifdef SQLITE_TEST
11210
+ "TEST",
11211
+#endif
11212
+#ifdef SQLITE_THREADSAFE
11213
+ "THREADSAFE=" CTIMEOPT_VAL(SQLITE_THREADSAFE),
11214
+#endif
11215
+#ifdef SQLITE_USE_ALLOCA
11216
+ "USE_ALLOCA",
11217
+#endif
11218
+#ifdef SQLITE_ZERO_MALLOC
11219
+ "ZERO_MALLOC"
11220
+#endif
11221
+};
11222
+
11223
+/*
11224
+** Given the name of a compile-time option, return true if that option
11225
+** was used and false if not.
11226
+**
11227
+** The name can optionally begin with "SQLITE_" but the "SQLITE_" prefix
11228
+** is not required for a match.
11229
+*/
11230
+SQLITE_API int sqlite3_compileoption_used(const char *zOptName){
11231
+ int i, n;
11232
+ if( sqlite3StrNICmp(zOptName, "SQLITE_", 7)==0 ) zOptName += 7;
11233
+ n = sqlite3Strlen30(zOptName);
11234
+
11235
+ /* Since ArraySize(azCompileOpt) is normally in single digits, a
11236
+ ** linear search is adequate. No need for a binary search. */
11237
+ for(i=0; i<ArraySize(azCompileOpt); i++){
11238
+ if( (sqlite3StrNICmp(zOptName, azCompileOpt[i], n)==0)
11239
+ && ( (azCompileOpt[i][n]==0) || (azCompileOpt[i][n]=='=') ) ) return 1;
11240
+ }
11241
+ return 0;
11242
+}
11243
+
11244
+/*
11245
+** Return the N-th compile-time option string. If N is out of range,
11246
+** return a NULL pointer.
11247
+*/
11248
+SQLITE_API const char *sqlite3_compileoption_get(int N){
11249
+ if( N>=0 && N<ArraySize(azCompileOpt) ){
11250
+ return azCompileOpt[N];
11251
+ }
11252
+ return 0;
11253
+}
11254
+
11255
+#endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */
11256
+
11257
+/************** End of ctime.c ***********************************************/
1087111258
/************** Begin file status.c ******************************************/
1087211259
/*
1087311260
** 2008 June 18
1087411261
**
1087511262
** The author disclaims copyright to this source code. In place of
@@ -12996,11 +13383,12 @@
1299613383
*/
1299713384
static void sqlite3MemFree(void *pPrior){
1299813385
struct MemBlockHdr *pHdr;
1299913386
void **pBt;
1300013387
char *z;
13001
- assert( sqlite3GlobalConfig.bMemstat || mem.mutex!=0 );
13388
+ assert( sqlite3GlobalConfig.bMemstat || sqlite3GlobalConfig.bCoreMutex==0
13389
+ || mem.mutex!=0 );
1300213390
pHdr = sqlite3MemsysGetHeader(pPrior);
1300313391
pBt = (void**)pHdr;
1300413392
pBt -= pHdr->nBacktraceSlots;
1300513393
sqlite3_mutex_enter(mem.mutex);
1300613394
if( pHdr->pPrev ){
@@ -15623,11 +16011,13 @@
1562316011
printf("enter mutex %p (%d) with nRef=%d\n", p, p->trace, p->nRef);
1562416012
}
1562516013
#endif
1562616014
}
1562716015
static int winMutexTry(sqlite3_mutex *p){
16016
+#ifndef NDEBUG
1562816017
DWORD tid = GetCurrentThreadId();
16018
+#endif
1562916019
int rc = SQLITE_BUSY;
1563016020
assert( p->id==SQLITE_MUTEX_RECURSIVE || winMutexNotheld2(p, tid) );
1563116021
/*
1563216022
** The sqlite3_mutex_try() routine is very rarely used, and when it
1563316023
** is used it is merely an optimization. So it is OK for it to always
@@ -15661,11 +16051,13 @@
1566116051
** previously entered by the same thread. The behavior
1566216052
** is undefined if the mutex is not currently entered or
1566316053
** is not currently allocated. SQLite will never do either.
1566416054
*/
1566516055
static void winMutexLeave(sqlite3_mutex *p){
15666
- DWORD tid = GetCurrentThreadId();
16056
+#ifndef NDEBUG
16057
+ DWORD tid = GetCurrentThreadId();
16058
+#endif
1566716059
assert( p->nRef>0 );
1566816060
assert( p->owner==tid );
1566916061
p->nRef--;
1567016062
assert( p->nRef==0 || p->id==SQLITE_MUTEX_RECURSIVE );
1567116063
LeaveCriticalSection(&p->mutex);
@@ -18422,23 +18814,25 @@
1842218814
** Memory to hold the UTF-8 string is obtained from sqlite3_malloc and must
1842318815
** be freed by the calling function.
1842418816
**
1842518817
** NULL is returned if there is an allocation error.
1842618818
*/
18427
-SQLITE_PRIVATE char *sqlite3Utf16to8(sqlite3 *db, const void *z, int nByte){
18819
+SQLITE_PRIVATE char *sqlite3Utf16to8(sqlite3 *db, const void *z, int nByte, u8 enc){
1842818820
Mem m;
1842918821
memset(&m, 0, sizeof(m));
1843018822
m.db = db;
18431
- sqlite3VdbeMemSetStr(&m, z, nByte, SQLITE_UTF16NATIVE, SQLITE_STATIC);
18823
+ sqlite3VdbeMemSetStr(&m, z, nByte, enc, SQLITE_STATIC);
1843218824
sqlite3VdbeChangeEncoding(&m, SQLITE_UTF8);
1843318825
if( db->mallocFailed ){
1843418826
sqlite3VdbeMemRelease(&m);
1843518827
m.z = 0;
1843618828
}
1843718829
assert( (m.flags & MEM_Term)!=0 || db->mallocFailed );
1843818830
assert( (m.flags & MEM_Str)!=0 || db->mallocFailed );
18439
- return (m.flags & MEM_Dyn)!=0 ? m.z : sqlite3DbStrDup(db, m.z);
18831
+ assert( (m.flags & MEM_Dyn)!=0 || db->mallocFailed );
18832
+ assert( m.z || db->mallocFailed );
18833
+ return m.z;
1844018834
}
1844118835
1844218836
/*
1844318837
** Convert a UTF-8 string to the UTF-16 encoding specified by parameter
1844418838
** enc. A pointer to the new string is returned, and the value of *pnOut
@@ -19236,11 +19630,11 @@
1923619630
return 2;
1923719631
}
1923819632
1923919633
/* Verify that constants are precomputed correctly */
1924019634
assert( SLOT_2_0 == ((0x7f<<14) | (0x7f)) );
19241
- assert( SLOT_4_2_0 == ((0xf<<28) | (0x7f<<14) | (0x7f)) );
19635
+ assert( SLOT_4_2_0 == ((0xfU<<28) | (0x7f<<14) | (0x7f)) );
1924219636
1924319637
p++;
1924419638
a = a<<14;
1924519639
a |= *p;
1924619640
/* a: p0<<14 | p2 (unmasked) */
@@ -25761,11 +26155,13 @@
2576126155
flags |= SQLITE_OPEN_READONLY;
2576226156
openFlags |= O_RDONLY;
2576326157
fd = open(zName, openFlags, openMode);
2576426158
}
2576526159
if( fd<0 ){
25766
- rc = SQLITE_CANTOPEN_BKPT;
26160
+ sqlite3_log(SQLITE_CANTOPEN, "cannot open file [%s]: %s", zName,
26161
+ strerror(errno));
26162
+ rc = SQLITE_CANTOPEN;
2576726163
goto open_finished;
2576826164
}
2576926165
}
2577026166
assert( fd>=0 );
2577126167
if( pOutFlags ){
@@ -33815,10 +34211,13 @@
3381534211
if( rc==SQLITE_OK ){
3381634212
zMaster = pPager->pTmpSpace;
3381734213
rc = readMasterJournal(pPager->jfd, zMaster, pPager->pVfs->mxPathname+1);
3381834214
testcase( rc!=SQLITE_OK );
3381934215
}
34216
+ if( rc==SQLITE_OK && pPager->noSync==0 && pPager->state>=PAGER_EXCLUSIVE ){
34217
+ rc = sqlite3OsSync(pPager->fd, pPager->sync_flags);
34218
+ }
3382034219
if( rc==SQLITE_OK ){
3382134220
rc = pager_end_transaction(pPager, zMaster[0]!='\0');
3382234221
testcase( rc!=SQLITE_OK );
3382334222
}
3382434223
if( rc==SQLITE_OK && zMaster[0] && res ){
@@ -35135,10 +35534,11 @@
3513535534
}
3513635535
/* pPager->xBusyHandler = 0; */
3513735536
/* pPager->pBusyHandlerArg = 0; */
3513835537
pPager->xReiniter = xReinit;
3513935538
/* memset(pPager->aHash, 0, sizeof(pPager->aHash)); */
35539
+
3514035540
*ppPager = pPager;
3514135541
return SQLITE_OK;
3514235542
}
3514335543
3514435544
@@ -35284,12 +35684,28 @@
3528435684
rc = sqlite3OsRead(pPager->fd, pPg->pData, pPager->pageSize, iOffset);
3528535685
if( rc==SQLITE_IOERR_SHORT_READ ){
3528635686
rc = SQLITE_OK;
3528735687
}
3528835688
if( pgno==1 ){
35289
- u8 *dbFileVers = &((u8*)pPg->pData)[24];
35290
- memcpy(&pPager->dbFileVers, dbFileVers, sizeof(pPager->dbFileVers));
35689
+ if( rc ){
35690
+ /* If the read is unsuccessful, set the dbFileVers[] to something
35691
+ ** that will never be a valid file version. dbFileVers[] is a copy
35692
+ ** of bytes 24..39 of the database. Bytes 28..31 should always be
35693
+ ** zero. Bytes 32..35 and 35..39 should be page numbers which are
35694
+ ** never 0xffffffff. So filling pPager->dbFileVers[] with all 0xff
35695
+ ** bytes should suffice.
35696
+ **
35697
+ ** For an encrypted database, the situation is more complex: bytes
35698
+ ** 24..39 of the database are white noise. But the probability of
35699
+ ** white noising equaling 16 bytes of 0xff is vanishingly small so
35700
+ ** we should still be ok.
35701
+ */
35702
+ memset(pPager->dbFileVers, 0xff, sizeof(pPager->dbFileVers));
35703
+ }else{
35704
+ u8 *dbFileVers = &((u8*)pPg->pData)[24];
35705
+ memcpy(&pPager->dbFileVers, dbFileVers, sizeof(pPager->dbFileVers));
35706
+ }
3529135707
}
3529235708
CODEC1(pPager, pPg->pData, pgno, 3, rc = SQLITE_NOMEM);
3529335709
3529435710
PAGER_INCR(sqlite3_pager_readdb_count);
3529535711
PAGER_INCR(pPager->nRead);
@@ -36786,10 +37202,11 @@
3678637202
if( op==SAVEPOINT_RELEASE ){
3678737203
if( nNew==0 && isOpen(pPager->sjfd) ){
3678837204
/* Only truncate if it is an in-memory sub-journal. */
3678937205
if( sqlite3IsMemJournal(pPager->sjfd) ){
3679037206
rc = sqlite3OsTruncate(pPager->sjfd, 0);
37207
+ assert( rc==SQLITE_OK );
3679137208
}
3679237209
pPager->nSubRec = 0;
3679337210
}
3679437211
}
3679537212
/* Else this is a rollback operation, playback the specified savepoint.
@@ -43199,11 +43616,11 @@
4319943616
if( nOvfl ){
4320043617
rc = getOverflowPage(pBt, ovflPgno, &pOvfl, &iNext);
4320143618
if( rc ) return rc;
4320243619
}
4320343620
43204
- if( (pOvfl || (pOvfl = btreePageLookup(pBt, ovflPgno)))
43621
+ if( ( pOvfl || ((pOvfl = btreePageLookup(pBt, ovflPgno))!=0) )
4320543622
&& sqlite3PagerPageRefcount(pOvfl->pDbPage)!=1
4320643623
){
4320743624
/* There is no reason any cursor should have an outstanding reference
4320843625
** to an overflow page belonging to a cell that is being deleted/updated.
4320943626
** So if there exists more than one reference to this page, then it
@@ -43952,11 +44369,11 @@
4395244369
** the dropCell() routine will overwrite the entire cell with zeroes.
4395344370
** In this case, temporarily copy the cell into the aOvflSpace[]
4395444371
** buffer. It will be copied out again as soon as the aSpace[] buffer
4395544372
** is allocated. */
4395644373
if( pBt->secureDelete ){
43957
- int iOff = apDiv[i] - pParent->aData;
44374
+ int iOff = SQLITE_PTR_TO_INT(apDiv[i]) - SQLITE_PTR_TO_INT(pParent->aData);
4395844375
if( (iOff+szNew[i])>pBt->usableSize ){
4395944376
rc = SQLITE_CORRUPT_BKPT;
4396044377
memset(apOld, 0, (i+1)*sizeof(MemPage*));
4396144378
goto balance_cleanup;
4396244379
}else{
@@ -47321,11 +47738,11 @@
4732147738
SQLITE_PRIVATE void sqlite3VdbeMemShallowCopy(Mem *pTo, const Mem *pFrom, int srcType){
4732247739
assert( (pFrom->flags & MEM_RowSet)==0 );
4732347740
sqlite3VdbeMemReleaseExternal(pTo);
4732447741
memcpy(pTo, pFrom, MEMCELLSIZE);
4732547742
pTo->xDel = 0;
47326
- if( (pFrom->flags&MEM_Dyn)!=0 || pFrom->z==pFrom->zMalloc ){
47743
+ if( (pFrom->flags&MEM_Static)==0 ){
4732747744
pTo->flags &= ~(MEM_Dyn|MEM_Static|MEM_Ephem);
4732847745
assert( srcType==MEM_Ephem || srcType==MEM_Static );
4732947746
pTo->flags |= srcType;
4733047747
}
4733147748
}
@@ -49953,16 +50370,21 @@
4995350370
}
4995450371
4995550372
/* If eStatementOp is non-zero, then a statement transaction needs to
4995650373
** be committed or rolled back. Call sqlite3VdbeCloseStatement() to
4995750374
** do so. If this operation returns an error, and the current statement
49958
- ** error code is SQLITE_OK or SQLITE_CONSTRAINT, then set the error
49959
- ** code to the new value.
50375
+ ** error code is SQLITE_OK or SQLITE_CONSTRAINT, then promote the
50376
+ ** current statement error code.
50377
+ **
50378
+ ** Note that sqlite3VdbeCloseStatement() can only fail if eStatementOp
50379
+ ** is SAVEPOINT_ROLLBACK. But if p->rc==SQLITE_OK then eStatementOp
50380
+ ** must be SAVEPOINT_RELEASE. Hence the NEVER(p->rc==SQLITE_OK) in
50381
+ ** the following code.
4996050382
*/
4996150383
if( eStatementOp ){
4996250384
rc = sqlite3VdbeCloseStatement(p, eStatementOp);
49963
- if( rc && (p->rc==SQLITE_OK || p->rc==SQLITE_CONSTRAINT) ){
50385
+ if( rc && (NEVER(p->rc==SQLITE_OK) || p->rc==SQLITE_CONSTRAINT) ){
4996450386
p->rc = rc;
4996550387
sqlite3DbFree(db, p->zErrMsg);
4996650388
p->zErrMsg = 0;
4996750389
}
4996850390
}
@@ -52577,21 +52999,34 @@
5257752999
** look like a number, leave it alone.
5257853000
*/
5257953001
static void applyNumericAffinity(Mem *pRec){
5258053002
if( (pRec->flags & (MEM_Real|MEM_Int))==0 ){
5258153003
int realnum;
53004
+ u8 enc = pRec->enc;
5258253005
sqlite3VdbeMemNulTerminate(pRec);
52583
- if( (pRec->flags&MEM_Str)
52584
- && sqlite3IsNumber(pRec->z, &realnum, pRec->enc) ){
53006
+ if( (pRec->flags&MEM_Str) && sqlite3IsNumber(pRec->z, &realnum, enc) ){
5258553007
i64 value;
52586
- sqlite3VdbeChangeEncoding(pRec, SQLITE_UTF8);
52587
- if( !realnum && sqlite3Atoi64(pRec->z, &value) ){
53008
+ char *zUtf8 = pRec->z;
53009
+#ifndef SQLITE_OMIT_UTF16
53010
+ if( enc!=SQLITE_UTF8 ){
53011
+ assert( pRec->db );
53012
+ zUtf8 = sqlite3Utf16to8(pRec->db, pRec->z, pRec->n, enc);
53013
+ if( !zUtf8 ) return;
53014
+ }
53015
+#endif
53016
+ if( !realnum && sqlite3Atoi64(zUtf8, &value) ){
5258853017
pRec->u.i = value;
5258953018
MemSetTypeFlag(pRec, MEM_Int);
5259053019
}else{
52591
- sqlite3VdbeMemRealify(pRec);
53020
+ sqlite3AtoF(zUtf8, &pRec->r);
53021
+ MemSetTypeFlag(pRec, MEM_Real);
5259253022
}
53023
+#ifndef SQLITE_OMIT_UTF16
53024
+ if( enc!=SQLITE_UTF8 ){
53025
+ sqlite3DbFree(pRec->db, zUtf8);
53026
+ }
53027
+#endif
5259353028
}
5259453029
}
5259553030
}
5259653031
5259753032
/*
@@ -53039,10 +53474,12 @@
5303953474
i64 b;
5304053475
} ah;
5304153476
struct OP_Ge_stack_vars {
5304253477
int res; /* Result of the comparison of pIn1 against pIn3 */
5304353478
char affinity; /* Affinity to use for comparison */
53479
+ u16 flags1; /* Copy of initial value of pIn1->flags */
53480
+ u16 flags3; /* Copy of initial value of pIn3->flags */
5304453481
} ai;
5304553482
struct OP_Compare_stack_vars {
5304653483
int n;
5304753484
int i;
5304853485
int p1;
@@ -54573,14 +55010,18 @@
5457355010
case OP_Gt: /* same as TK_GT, jump, in1, in3 */
5457455011
case OP_Ge: { /* same as TK_GE, jump, in1, in3 */
5457555012
#if 0 /* local variables moved into u.ai */
5457655013
int res; /* Result of the comparison of pIn1 against pIn3 */
5457755014
char affinity; /* Affinity to use for comparison */
55015
+ u16 flags1; /* Copy of initial value of pIn1->flags */
55016
+ u16 flags3; /* Copy of initial value of pIn3->flags */
5457855017
#endif /* local variables moved into u.ai */
5457955018
5458055019
pIn1 = &aMem[pOp->p1];
5458155020
pIn3 = &aMem[pOp->p3];
55021
+ u.ai.flags1 = pIn1->flags;
55022
+ u.ai.flags3 = pIn3->flags;
5458255023
if( (pIn1->flags | pIn3->flags)&MEM_Null ){
5458355024
/* One or both operands are NULL */
5458455025
if( pOp->p5 & SQLITE_NULLEQ ){
5458555026
/* If SQLITE_NULLEQ is set (which will only happen if the operator is
5458655027
** OP_Eq or OP_Ne) then take the jump or not depending on whether
@@ -54631,10 +55072,14 @@
5463155072
pOut->u.i = u.ai.res;
5463255073
REGISTER_TRACE(pOp->p2, pOut);
5463355074
}else if( u.ai.res ){
5463455075
pc = pOp->p2-1;
5463555076
}
55077
+
55078
+ /* Undo any changes made by applyAffinity() to the input registers. */
55079
+ pIn1->flags = (pIn1->flags&~MEM_TypeMask) | (u.ai.flags1&MEM_TypeMask);
55080
+ pIn3->flags = (pIn3->flags&~MEM_TypeMask) | (u.ai.flags3&MEM_TypeMask);
5463655081
break;
5463755082
}
5463855083
5463955084
/* Opcode: Permutation * * * P4 *
5464055085
**
@@ -61176,14 +61621,10 @@
6117661621
p4 = sqlite3BinaryCompareCollSeq(pParse, pLeft, pRight);
6117761622
p5 = binaryCompareP5(pLeft, pRight, jumpIfNull);
6117861623
addr = sqlite3VdbeAddOp4(pParse->pVdbe, opcode, in2, dest, in1,
6117961624
(void*)p4, P4_COLLSEQ);
6118061625
sqlite3VdbeChangeP5(pParse->pVdbe, (u8)p5);
61181
- if( (p5 & SQLITE_AFF_MASK)!=SQLITE_AFF_NONE ){
61182
- sqlite3ExprCacheAffinityChange(pParse, in1, 1);
61183
- sqlite3ExprCacheAffinityChange(pParse, in2, 1);
61184
- }
6118561626
return addr;
6118661627
}
6118761628
6118861629
#if SQLITE_MAX_EXPR_DEPTH>0
6118961630
/*
@@ -71076,397 +71517,10 @@
7107671517
}
7107771518
return p;
7107871519
}
7107971520
7108071521
/************** End of callback.c ********************************************/
71081
-/************** Begin file ctime.c *******************************************/
71082
-/*
71083
-** 2010 February 23
71084
-**
71085
-** The author disclaims copyright to this source code. In place of
71086
-** a legal notice, here is a blessing:
71087
-**
71088
-** May you do good and not evil.
71089
-** May you find forgiveness for yourself and forgive others.
71090
-** May you share freely, never taking more than you give.
71091
-**
71092
-*************************************************************************
71093
-**
71094
-** This file implements routines used to report what compile-time options
71095
-** SQLite was built with.
71096
-*/
71097
-
71098
-#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
71099
-
71100
-
71101
-/*
71102
-** An array of names of all compile-time options. This array should
71103
-** be sorted A-Z.
71104
-**
71105
-** This array looks large, but in a typical installation actually uses
71106
-** only a handful of compile-time options, so most times this array is usually
71107
-** rather short and uses little memory space.
71108
-*/
71109
-static const char * const azCompileOpt[] = {
71110
-
71111
-/* These macros are provided to "stringify" the value of the define
71112
-** for those options in which the value is meaningful. */
71113
-#define CTIMEOPT_VAL_(opt) #opt
71114
-#define CTIMEOPT_VAL(opt) CTIMEOPT_VAL_(opt)
71115
-
71116
-#ifdef SQLITE_32BIT_ROWID
71117
- "32BIT_ROWID",
71118
-#endif
71119
-#ifdef SQLITE_4_BYTE_ALIGNED_MALLOC
71120
- "4_BYTE_ALIGNED_MALLOC",
71121
-#endif
71122
-#ifdef SQLITE_CASE_SENSITIVE_LIKE
71123
- "CASE_SENSITIVE_LIKE",
71124
-#endif
71125
-#ifdef SQLITE_CHECK_PAGES
71126
- "CHECK_PAGES",
71127
-#endif
71128
-#ifdef SQLITE_COVERAGE_TEST
71129
- "COVERAGE_TEST",
71130
-#endif
71131
-#ifdef SQLITE_DEBUG
71132
- "DEBUG",
71133
-#endif
71134
-#ifdef SQLITE_DEFAULT_LOCKING_MODE
71135
- "DEFAULT_LOCKING_MODE=" CTIMEOPT_VAL(SQLITE_DEFAULT_LOCKING_MODE),
71136
-#endif
71137
-#ifdef SQLITE_DISABLE_DIRSYNC
71138
- "DISABLE_DIRSYNC",
71139
-#endif
71140
-#ifdef SQLITE_DISABLE_LFS
71141
- "DISABLE_LFS",
71142
-#endif
71143
-#ifdef SQLITE_ENABLE_ATOMIC_WRITE
71144
- "ENABLE_ATOMIC_WRITE",
71145
-#endif
71146
-#ifdef SQLITE_ENABLE_CEROD
71147
- "ENABLE_CEROD",
71148
-#endif
71149
-#ifdef SQLITE_ENABLE_COLUMN_METADATA
71150
- "ENABLE_COLUMN_METADATA",
71151
-#endif
71152
-#ifdef SQLITE_ENABLE_EXPENSIVE_ASSERT
71153
- "ENABLE_EXPENSIVE_ASSERT",
71154
-#endif
71155
-#ifdef SQLITE_ENABLE_FTS1
71156
- "ENABLE_FTS1",
71157
-#endif
71158
-#ifdef SQLITE_ENABLE_FTS2
71159
- "ENABLE_FTS2",
71160
-#endif
71161
-#ifdef SQLITE_ENABLE_FTS3
71162
- "ENABLE_FTS3",
71163
-#endif
71164
-#ifdef SQLITE_ENABLE_FTS3_PARENTHESIS
71165
- "ENABLE_FTS3_PARENTHESIS",
71166
-#endif
71167
-#ifdef SQLITE_ENABLE_FTS4
71168
- "ENABLE_FTS4",
71169
-#endif
71170
-#ifdef SQLITE_ENABLE_ICU
71171
- "ENABLE_ICU",
71172
-#endif
71173
-#ifdef SQLITE_ENABLE_IOTRACE
71174
- "ENABLE_IOTRACE",
71175
-#endif
71176
-#ifdef SQLITE_ENABLE_LOAD_EXTENSION
71177
- "ENABLE_LOAD_EXTENSION",
71178
-#endif
71179
-#ifdef SQLITE_ENABLE_LOCKING_STYLE
71180
- "ENABLE_LOCKING_STYLE=" CTIMEOPT_VAL(SQLITE_ENABLE_LOCKING_STYLE),
71181
-#endif
71182
-#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
71183
- "ENABLE_MEMORY_MANAGEMENT",
71184
-#endif
71185
-#ifdef SQLITE_ENABLE_MEMSYS3
71186
- "ENABLE_MEMSYS3",
71187
-#endif
71188
-#ifdef SQLITE_ENABLE_MEMSYS5
71189
- "ENABLE_MEMSYS5",
71190
-#endif
71191
-#ifdef SQLITE_ENABLE_OVERSIZE_CELL_CHECK
71192
- "ENABLE_OVERSIZE_CELL_CHECK",
71193
-#endif
71194
-#ifdef SQLITE_ENABLE_RTREE
71195
- "ENABLE_RTREE",
71196
-#endif
71197
-#ifdef SQLITE_ENABLE_STAT2
71198
- "ENABLE_STAT2",
71199
-#endif
71200
-#ifdef SQLITE_ENABLE_UNLOCK_NOTIFY
71201
- "ENABLE_UNLOCK_NOTIFY",
71202
-#endif
71203
-#ifdef SQLITE_ENABLE_UPDATE_DELETE_LIMIT
71204
- "ENABLE_UPDATE_DELETE_LIMIT",
71205
-#endif
71206
-#ifdef SQLITE_HAS_CODEC
71207
- "HAS_CODEC",
71208
-#endif
71209
-#ifdef SQLITE_HAVE_ISNAN
71210
- "HAVE_ISNAN",
71211
-#endif
71212
-#ifdef SQLITE_HOMEGROWN_RECURSIVE_MUTEX
71213
- "HOMEGROWN_RECURSIVE_MUTEX",
71214
-#endif
71215
-#ifdef SQLITE_IGNORE_AFP_LOCK_ERRORS
71216
- "IGNORE_AFP_LOCK_ERRORS",
71217
-#endif
71218
-#ifdef SQLITE_IGNORE_FLOCK_LOCK_ERRORS
71219
- "IGNORE_FLOCK_LOCK_ERRORS",
71220
-#endif
71221
-#ifdef SQLITE_INT64_TYPE
71222
- "INT64_TYPE",
71223
-#endif
71224
-#ifdef SQLITE_LOCK_TRACE
71225
- "LOCK_TRACE",
71226
-#endif
71227
-#ifdef SQLITE_MEMDEBUG
71228
- "MEMDEBUG",
71229
-#endif
71230
-#ifdef SQLITE_MIXED_ENDIAN_64BIT_FLOAT
71231
- "MIXED_ENDIAN_64BIT_FLOAT",
71232
-#endif
71233
-#ifdef SQLITE_NO_SYNC
71234
- "NO_SYNC",
71235
-#endif
71236
-#ifdef SQLITE_OMIT_ALTERTABLE
71237
- "OMIT_ALTERTABLE",
71238
-#endif
71239
-#ifdef SQLITE_OMIT_ANALYZE
71240
- "OMIT_ANALYZE",
71241
-#endif
71242
-#ifdef SQLITE_OMIT_ATTACH
71243
- "OMIT_ATTACH",
71244
-#endif
71245
-#ifdef SQLITE_OMIT_AUTHORIZATION
71246
- "OMIT_AUTHORIZATION",
71247
-#endif
71248
-#ifdef SQLITE_OMIT_AUTOINCREMENT
71249
- "OMIT_AUTOINCREMENT",
71250
-#endif
71251
-#ifdef SQLITE_OMIT_AUTOINIT
71252
- "OMIT_AUTOINIT",
71253
-#endif
71254
-#ifdef SQLITE_OMIT_AUTOVACUUM
71255
- "OMIT_AUTOVACUUM",
71256
-#endif
71257
-#ifdef SQLITE_OMIT_BETWEEN_OPTIMIZATION
71258
- "OMIT_BETWEEN_OPTIMIZATION",
71259
-#endif
71260
-#ifdef SQLITE_OMIT_BLOB_LITERAL
71261
- "OMIT_BLOB_LITERAL",
71262
-#endif
71263
-#ifdef SQLITE_OMIT_BTREECOUNT
71264
- "OMIT_BTREECOUNT",
71265
-#endif
71266
-#ifdef SQLITE_OMIT_BUILTIN_TEST
71267
- "OMIT_BUILTIN_TEST",
71268
-#endif
71269
-#ifdef SQLITE_OMIT_CAST
71270
- "OMIT_CAST",
71271
-#endif
71272
-#ifdef SQLITE_OMIT_CHECK
71273
- "OMIT_CHECK",
71274
-#endif
71275
-#ifdef SQLITE_OMIT_COMPILEOPTION_DIAGS
71276
- "OMIT_COMPILEOPTION_DIAGS",
71277
-#endif
71278
-#ifdef SQLITE_OMIT_COMPLETE
71279
- "OMIT_COMPLETE",
71280
-#endif
71281
-#ifdef SQLITE_OMIT_COMPOUND_SELECT
71282
- "OMIT_COMPOUND_SELECT",
71283
-#endif
71284
-#ifdef SQLITE_OMIT_DATETIME_FUNCS
71285
- "OMIT_DATETIME_FUNCS",
71286
-#endif
71287
-#ifdef SQLITE_OMIT_DECLTYPE
71288
- "OMIT_DECLTYPE",
71289
-#endif
71290
-#ifdef SQLITE_OMIT_DEPRECATED
71291
- "OMIT_DEPRECATED",
71292
-#endif
71293
-#ifdef SQLITE_OMIT_DISKIO
71294
- "OMIT_DISKIO",
71295
-#endif
71296
-#ifdef SQLITE_OMIT_EXPLAIN
71297
- "OMIT_EXPLAIN",
71298
-#endif
71299
-#ifdef SQLITE_OMIT_FLAG_PRAGMAS
71300
- "OMIT_FLAG_PRAGMAS",
71301
-#endif
71302
-#ifdef SQLITE_OMIT_FLOATING_POINT
71303
- "OMIT_FLOATING_POINT",
71304
-#endif
71305
-#ifdef SQLITE_OMIT_FOREIGN_KEY
71306
- "OMIT_FOREIGN_KEY",
71307
-#endif
71308
-#ifdef SQLITE_OMIT_GET_TABLE
71309
- "OMIT_GET_TABLE",
71310
-#endif
71311
-#ifdef SQLITE_OMIT_GLOBALRECOVER
71312
- "OMIT_GLOBALRECOVER",
71313
-#endif
71314
-#ifdef SQLITE_OMIT_INCRBLOB
71315
- "OMIT_INCRBLOB",
71316
-#endif
71317
-#ifdef SQLITE_OMIT_INTEGRITY_CHECK
71318
- "OMIT_INTEGRITY_CHECK",
71319
-#endif
71320
-#ifdef SQLITE_OMIT_LIKE_OPTIMIZATION
71321
- "OMIT_LIKE_OPTIMIZATION",
71322
-#endif
71323
-#ifdef SQLITE_OMIT_LOAD_EXTENSION
71324
- "OMIT_LOAD_EXTENSION",
71325
-#endif
71326
-#ifdef SQLITE_OMIT_LOCALTIME
71327
- "OMIT_LOCALTIME",
71328
-#endif
71329
-#ifdef SQLITE_OMIT_LOOKASIDE
71330
- "OMIT_LOOKASIDE",
71331
-#endif
71332
-#ifdef SQLITE_OMIT_MEMORYDB
71333
- "OMIT_MEMORYDB",
71334
-#endif
71335
-#ifdef SQLITE_OMIT_OR_OPTIMIZATION
71336
- "OMIT_OR_OPTIMIZATION",
71337
-#endif
71338
-#ifdef SQLITE_OMIT_PAGER_PRAGMAS
71339
- "OMIT_PAGER_PRAGMAS",
71340
-#endif
71341
-#ifdef SQLITE_OMIT_PRAGMA
71342
- "OMIT_PRAGMA",
71343
-#endif
71344
-#ifdef SQLITE_OMIT_PROGRESS_CALLBACK
71345
- "OMIT_PROGRESS_CALLBACK",
71346
-#endif
71347
-#ifdef SQLITE_OMIT_QUICKBALANCE
71348
- "OMIT_QUICKBALANCE",
71349
-#endif
71350
-#ifdef SQLITE_OMIT_REINDEX
71351
- "OMIT_REINDEX",
71352
-#endif
71353
-#ifdef SQLITE_OMIT_SCHEMA_PRAGMAS
71354
- "OMIT_SCHEMA_PRAGMAS",
71355
-#endif
71356
-#ifdef SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS
71357
- "OMIT_SCHEMA_VERSION_PRAGMAS",
71358
-#endif
71359
-#ifdef SQLITE_OMIT_SHARED_CACHE
71360
- "OMIT_SHARED_CACHE",
71361
-#endif
71362
-#ifdef SQLITE_OMIT_SUBQUERY
71363
- "OMIT_SUBQUERY",
71364
-#endif
71365
-#ifdef SQLITE_OMIT_TCL_VARIABLE
71366
- "OMIT_TCL_VARIABLE",
71367
-#endif
71368
-#ifdef SQLITE_OMIT_TEMPDB
71369
- "OMIT_TEMPDB",
71370
-#endif
71371
-#ifdef SQLITE_OMIT_TRACE
71372
- "OMIT_TRACE",
71373
-#endif
71374
-#ifdef SQLITE_OMIT_TRIGGER
71375
- "OMIT_TRIGGER",
71376
-#endif
71377
-#ifdef SQLITE_OMIT_TRUNCATE_OPTIMIZATION
71378
- "OMIT_TRUNCATE_OPTIMIZATION",
71379
-#endif
71380
-#ifdef SQLITE_OMIT_UTF16
71381
- "OMIT_UTF16",
71382
-#endif
71383
-#ifdef SQLITE_OMIT_VACUUM
71384
- "OMIT_VACUUM",
71385
-#endif
71386
-#ifdef SQLITE_OMIT_VIEW
71387
- "OMIT_VIEW",
71388
-#endif
71389
-#ifdef SQLITE_OMIT_VIRTUALTABLE
71390
- "OMIT_VIRTUALTABLE",
71391
-#endif
71392
-#ifdef SQLITE_OMIT_WSD
71393
- "OMIT_WSD",
71394
-#endif
71395
-#ifdef SQLITE_OMIT_XFER_OPT
71396
- "OMIT_XFER_OPT",
71397
-#endif
71398
-#ifdef SQLITE_PERFORMANCE_TRACE
71399
- "PERFORMANCE_TRACE",
71400
-#endif
71401
-#ifdef SQLITE_PROXY_DEBUG
71402
- "PROXY_DEBUG",
71403
-#endif
71404
-#ifdef SQLITE_SECURE_DELETE
71405
- "SECURE_DELETE",
71406
-#endif
71407
-#ifdef SQLITE_SMALL_STACK
71408
- "SMALL_STACK",
71409
-#endif
71410
-#ifdef SQLITE_SOUNDEX
71411
- "SOUNDEX",
71412
-#endif
71413
-#ifdef SQLITE_TCL
71414
- "TCL",
71415
-#endif
71416
-#ifdef SQLITE_TEMP_STORE
71417
- "TEMP_STORE=" CTIMEOPT_VAL(SQLITE_TEMP_STORE),
71418
-#endif
71419
-#ifdef SQLITE_TEST
71420
- "TEST",
71421
-#endif
71422
-#ifdef SQLITE_THREADSAFE
71423
- "THREADSAFE=" CTIMEOPT_VAL(SQLITE_THREADSAFE),
71424
-#endif
71425
-#ifdef SQLITE_USE_ALLOCA
71426
- "USE_ALLOCA",
71427
-#endif
71428
-#ifdef SQLITE_ZERO_MALLOC
71429
- "ZERO_MALLOC"
71430
-#endif
71431
-};
71432
-
71433
-/*
71434
-** Given the name of a compile-time option, return true if that option
71435
-** was used and false if not.
71436
-**
71437
-** The name can optionally begin with "SQLITE_" but the "SQLITE_" prefix
71438
-** is not required for a match.
71439
-*/
71440
-SQLITE_API int sqlite3_compileoption_used(const char *zOptName){
71441
- int i, n;
71442
- if( sqlite3StrNICmp(zOptName, "SQLITE_", 7)==0 ) zOptName += 7;
71443
- n = sqlite3Strlen30(zOptName);
71444
-
71445
- /* Since ArraySize(azCompileOpt) is normally in single digits, a
71446
- ** linear search is adequate. No need for a binary search. */
71447
- for(i=0; i<ArraySize(azCompileOpt); i++){
71448
- if( (sqlite3StrNICmp(zOptName, azCompileOpt[i], n)==0)
71449
- && ( (azCompileOpt[i][n]==0) || (azCompileOpt[i][n]=='=') ) ) return 1;
71450
- }
71451
- return 0;
71452
-}
71453
-
71454
-/*
71455
-** Return the N-th compile-time option string. If N is out of range,
71456
-** return a NULL pointer.
71457
-*/
71458
-SQLITE_API const char *sqlite3_compileoption_get(int N){
71459
- if( N>=0 && N<ArraySize(azCompileOpt) ){
71460
- return azCompileOpt[N];
71461
- }
71462
- return 0;
71463
-}
71464
-
71465
-#endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */
71466
-
71467
-/************** End of ctime.c ***********************************************/
7146871522
/************** Begin file delete.c ******************************************/
7146971523
/*
7147071524
** 2001 September 15
7147171525
**
7147271526
** The author disclaims copyright to this source code. In place of
@@ -80134,11 +80188,11 @@
8013480188
*ppStmt = 0;
8013580189
if( !sqlite3SafetyCheckOk(db) ){
8013680190
return SQLITE_MISUSE_BKPT;
8013780191
}
8013880192
sqlite3_mutex_enter(db->mutex);
80139
- zSql8 = sqlite3Utf16to8(db, zSql, nBytes);
80193
+ zSql8 = sqlite3Utf16to8(db, zSql, nBytes, SQLITE_UTF16NATIVE);
8014080194
if( zSql8 ){
8014180195
rc = sqlite3LockAndPrepare(db, zSql8, -1, saveSqlFlag, 0, ppStmt, &zTail8);
8014280196
}
8014380197
8014480198
if( zTail8 && pzTail ){
@@ -97459,11 +97513,11 @@
9745997513
){
9746097514
int rc;
9746197515
char *zFunc8;
9746297516
sqlite3_mutex_enter(db->mutex);
9746397517
assert( !db->mallocFailed );
97464
- zFunc8 = sqlite3Utf16to8(db, zFunctionName, -1);
97518
+ zFunc8 = sqlite3Utf16to8(db, zFunctionName, -1, SQLITE_UTF16NATIVE);
9746597519
rc = sqlite3CreateFunc(db, zFunc8, nArg, eTextRep, p, xFunc, xStep, xFinal);
9746697520
sqlite3DbFree(db, zFunc8);
9746797521
rc = sqlite3ApiExit(db, rc);
9746897522
sqlite3_mutex_leave(db->mutex);
9746997523
return rc;
@@ -98282,11 +98336,11 @@
9828298336
){
9828398337
int rc = SQLITE_OK;
9828498338
char *zName8;
9828598339
sqlite3_mutex_enter(db->mutex);
9828698340
assert( !db->mallocFailed );
98287
- zName8 = sqlite3Utf16to8(db, zName, -1);
98341
+ zName8 = sqlite3Utf16to8(db, zName, -1, SQLITE_UTF16NATIVE);
9828898342
if( zName8 ){
9828998343
rc = createCollation(db, zName8, (u8)enc, SQLITE_COLL_USER, pCtx, xCompare, 0);
9829098344
sqlite3DbFree(db, zName8);
9829198345
}
9829298346
rc = sqlite3ApiExit(db, rc);
@@ -100273,10 +100327,18 @@
100273100327
p->zDb, p->zName
100274100328
);
100275100329
}
100276100330
return rc;
100277100331
}
100332
+
100333
+/*
100334
+** An sqlite3_exec() callback for fts3TableExists.
100335
+*/
100336
+static int fts3TableExistsCallback(void *pArg, int n, char **pp1, char **pp2){
100337
+ *(int*)pArg = 1;
100338
+ return 1;
100339
+}
100278100340
100279100341
/*
100280100342
** Determine if a table currently exists in the database.
100281100343
*/
100282100344
static void fts3TableExists(
@@ -100286,14 +100348,21 @@
100286100348
const char *zName, /* Name of the FTS3 table */
100287100349
const char *zSuffix, /* Shadow table extension */
100288100350
u8 *pResult /* Write results here */
100289100351
){
100290100352
int rc = SQLITE_OK;
100353
+ int res = 0;
100354
+ char *zSql;
100291100355
if( *pRc ) return;
100292
- fts3DbExec(&rc, db, "SELECT 1 FROM %Q.'%q%s'", zDb, zName, zSuffix);
100293
- *pResult = (rc==SQLITE_OK) ? 1 : 0;
100294
- if( rc!=SQLITE_ERROR ) *pRc = rc;
100356
+ zSql = sqlite3_mprintf(
100357
+ "SELECT 1 FROM %Q.sqlite_master WHERE name='%q%s'",
100358
+ zDb, zName, zSuffix
100359
+ );
100360
+ rc = sqlite3_exec(db, zSql, fts3TableExistsCallback, &res, 0);
100361
+ sqlite3_free(zSql);
100362
+ *pResult = res & 0xff;
100363
+ if( rc!=SQLITE_ABORT ) *pRc = rc;
100295100364
}
100296100365
100297100366
/*
100298100367
** This function is the implementation of both the xConnect and xCreate
100299100368
** methods of the FTS3 virtual table.
@@ -100711,11 +100780,16 @@
100711100780
*piPrev = iVal;
100712100781
}
100713100782
100714100783
/*
100715100784
** When this function is called, *ppPoslist is assumed to point to the
100716
-** start of a position-list.
100785
+** start of a position-list. After it returns, *ppPoslist points to the
100786
+** first byte after the position-list.
100787
+**
100788
+** If pp is not NULL, then the contents of the position list are copied
100789
+** to *pp. *pp is set to point to the first byte past the last byte copied
100790
+** before this function returns.
100717100791
*/
100718100792
static void fts3PoslistCopy(char **pp, char **ppPoslist){
100719100793
char *pEnd = *ppPoslist;
100720100794
char c = 0;
100721100795
@@ -101702,11 +101776,17 @@
101702101776
}
101703101777
101704101778
rc = sqlite3Fts3ExprParse(p->pTokenizer, p->azColumn, p->nColumn,
101705101779
iCol, zQuery, -1, &pCsr->pExpr
101706101780
);
101707
- if( rc!=SQLITE_OK ) return rc;
101781
+ if( rc!=SQLITE_OK ){
101782
+ if( rc==SQLITE_ERROR ){
101783
+ p->base.zErrMsg = sqlite3_mprintf("malformed MATCH expression: [%s]",
101784
+ zQuery);
101785
+ }
101786
+ return rc;
101787
+ }
101708101788
101709101789
rc = evalFts3Expr(p, pCsr->pExpr, &pCsr->aDoclist, &pCsr->nDoclist, 0);
101710101790
pCsr->pNextId = pCsr->aDoclist;
101711101791
pCsr->iPrevId = 0;
101712101792
}
@@ -101855,11 +101935,13 @@
101855101935
101856101936
assert( pCsr );
101857101937
while( pCsr<pEnd ){
101858101938
if( pExpr->iCurrent<iDocid ){
101859101939
fts3PoslistCopy(0, &pCsr);
101860
- fts3GetDeltaVarint(&pCsr, &pExpr->iCurrent);
101940
+ if( pCsr<pEnd ){
101941
+ fts3GetDeltaVarint(&pCsr, &pExpr->iCurrent);
101942
+ }
101861101943
pExpr->pCurrent = pCsr;
101862101944
}else{
101863101945
if( pExpr->iCurrent==iDocid ){
101864101946
int iThis = 0;
101865101947
if( iCol<0 ){
@@ -105105,13 +105187,13 @@
105105105187
/* 3 */ "DELETE FROM %Q.'%q_segments'",
105106105188
/* 4 */ "DELETE FROM %Q.'%q_segdir'",
105107105189
/* 5 */ "DELETE FROM %Q.'%q_docsize'",
105108105190
/* 6 */ "DELETE FROM %Q.'%q_stat'",
105109105191
/* 7 */ "SELECT * FROM %Q.'%q_content' WHERE rowid=?",
105110
-/* 8 */ "SELECT coalesce(max(idx)+1, 0) FROM %Q.'%q_segdir' WHERE level=?",
105192
+/* 8 */ "SELECT (SELECT max(idx) FROM %Q.'%q_segdir' WHERE level = ?) + 1",
105111105193
/* 9 */ "INSERT INTO %Q.'%q_segments'(blockid, block) VALUES(?, ?)",
105112
-/* 10 */ "SELECT coalesce(max(blockid)+1, 1) FROM %Q.'%q_segments'",
105194
+/* 10 */ "SELECT coalesce((SELECT max(blockid) FROM %Q.'%q_segments') + 1, 1)",
105113105195
/* 11 */ "INSERT INTO %Q.'%q_segdir' VALUES(?,?,?,?,?,?)",
105114105196
105115105197
/* Return segments in order from oldest to newest.*/
105116105198
/* 12 */ "SELECT idx, start_block, leaves_end_block, end_block, root "
105117105199
"FROM %Q.'%q_segdir' WHERE level = ? ORDER BY idx ASC",
@@ -108666,15 +108748,17 @@
108666108748
char aBuffer[64];
108667108749
sqlite3_snprintf(sizeof(aBuffer), aBuffer,
108668108750
"%d %d %d %d ", iCol, pTerm-sCtx.aTerm, iStart, iEnd-iStart
108669108751
);
108670108752
rc = fts3StringAppend(&res, aBuffer, -1);
108753
+ }else if( rc==SQLITE_DONE ){
108754
+ rc = SQLITE_CORRUPT;
108671108755
}
108672108756
}
108673108757
}
108674108758
if( rc==SQLITE_DONE ){
108675
- rc = SQLITE_CORRUPT;
108759
+ rc = SQLITE_OK;
108676108760
}
108677108761
108678108762
pMod->xClose(pC);
108679108763
if( rc!=SQLITE_OK ) goto offsets_out;
108680108764
}
108681108765
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1,8 +1,8 @@
1 /******************************************************************************
2 ** This file is an amalgamation of many separate C source files from SQLite
3 ** version 3.6.23. By combining all the individual C code files into this
4 ** single large file, the entire code can be compiled as a one translation
5 ** unit. This allows many compilers to do optimizations that would not be
6 ** possible if the files were compiled separately. Performance improvements
7 ** of 5% are more are commonly seen when SQLite is compiled as a single
8 ** translation unit.
@@ -626,13 +626,13 @@
626 **
627 ** See also: [sqlite3_libversion()],
628 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
629 ** [sqlite_version()] and [sqlite_source_id()].
630 */
631 #define SQLITE_VERSION "3.6.23"
632 #define SQLITE_VERSION_NUMBER 3006023
633 #define SQLITE_SOURCE_ID "2010-03-05 13:53:23 27413fc8dd52b754b4be9344a66bb9e0d752d48e"
634
635 /*
636 ** CAPI3REF: Run-Time Library Version Numbers
637 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
638 **
@@ -10425,11 +10425,11 @@
10425 SQLITE_PRIVATE int sqlite3ValueBytes(sqlite3_value*, u8);
10426 SQLITE_PRIVATE void sqlite3ValueSetStr(sqlite3_value*, int, const void *,u8,
10427 void(*)(void*));
10428 SQLITE_PRIVATE void sqlite3ValueFree(sqlite3_value*);
10429 SQLITE_PRIVATE sqlite3_value *sqlite3ValueNew(sqlite3 *);
10430 SQLITE_PRIVATE char *sqlite3Utf16to8(sqlite3 *, const void*, int);
10431 #ifdef SQLITE_ENABLE_STAT2
10432 SQLITE_PRIVATE char *sqlite3Utf8to16(sqlite3 *, u8, char *, int, int *);
10433 #endif
10434 SQLITE_PRIVATE int sqlite3ValueFromExpr(sqlite3 *, Expr *, u8, u8, sqlite3_value **);
10435 SQLITE_PRIVATE void sqlite3ValueApplyAffinity(sqlite3_value *, u8, u8);
@@ -10866,10 +10866,397 @@
10866 ** the vdbe.c file.
10867 */
10868 SQLITE_PRIVATE const unsigned char sqlite3OpcodeProperty[] = OPFLG_INITIALIZER;
10869
10870 /************** End of global.c **********************************************/
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10871 /************** Begin file status.c ******************************************/
10872 /*
10873 ** 2008 June 18
10874 **
10875 ** The author disclaims copyright to this source code. In place of
@@ -12996,11 +13383,12 @@
12996 */
12997 static void sqlite3MemFree(void *pPrior){
12998 struct MemBlockHdr *pHdr;
12999 void **pBt;
13000 char *z;
13001 assert( sqlite3GlobalConfig.bMemstat || mem.mutex!=0 );
 
13002 pHdr = sqlite3MemsysGetHeader(pPrior);
13003 pBt = (void**)pHdr;
13004 pBt -= pHdr->nBacktraceSlots;
13005 sqlite3_mutex_enter(mem.mutex);
13006 if( pHdr->pPrev ){
@@ -15623,11 +16011,13 @@
15623 printf("enter mutex %p (%d) with nRef=%d\n", p, p->trace, p->nRef);
15624 }
15625 #endif
15626 }
15627 static int winMutexTry(sqlite3_mutex *p){
 
15628 DWORD tid = GetCurrentThreadId();
 
15629 int rc = SQLITE_BUSY;
15630 assert( p->id==SQLITE_MUTEX_RECURSIVE || winMutexNotheld2(p, tid) );
15631 /*
15632 ** The sqlite3_mutex_try() routine is very rarely used, and when it
15633 ** is used it is merely an optimization. So it is OK for it to always
@@ -15661,11 +16051,13 @@
15661 ** previously entered by the same thread. The behavior
15662 ** is undefined if the mutex is not currently entered or
15663 ** is not currently allocated. SQLite will never do either.
15664 */
15665 static void winMutexLeave(sqlite3_mutex *p){
15666 DWORD tid = GetCurrentThreadId();
 
 
15667 assert( p->nRef>0 );
15668 assert( p->owner==tid );
15669 p->nRef--;
15670 assert( p->nRef==0 || p->id==SQLITE_MUTEX_RECURSIVE );
15671 LeaveCriticalSection(&p->mutex);
@@ -18422,23 +18814,25 @@
18422 ** Memory to hold the UTF-8 string is obtained from sqlite3_malloc and must
18423 ** be freed by the calling function.
18424 **
18425 ** NULL is returned if there is an allocation error.
18426 */
18427 SQLITE_PRIVATE char *sqlite3Utf16to8(sqlite3 *db, const void *z, int nByte){
18428 Mem m;
18429 memset(&m, 0, sizeof(m));
18430 m.db = db;
18431 sqlite3VdbeMemSetStr(&m, z, nByte, SQLITE_UTF16NATIVE, SQLITE_STATIC);
18432 sqlite3VdbeChangeEncoding(&m, SQLITE_UTF8);
18433 if( db->mallocFailed ){
18434 sqlite3VdbeMemRelease(&m);
18435 m.z = 0;
18436 }
18437 assert( (m.flags & MEM_Term)!=0 || db->mallocFailed );
18438 assert( (m.flags & MEM_Str)!=0 || db->mallocFailed );
18439 return (m.flags & MEM_Dyn)!=0 ? m.z : sqlite3DbStrDup(db, m.z);
 
 
18440 }
18441
18442 /*
18443 ** Convert a UTF-8 string to the UTF-16 encoding specified by parameter
18444 ** enc. A pointer to the new string is returned, and the value of *pnOut
@@ -19236,11 +19630,11 @@
19236 return 2;
19237 }
19238
19239 /* Verify that constants are precomputed correctly */
19240 assert( SLOT_2_0 == ((0x7f<<14) | (0x7f)) );
19241 assert( SLOT_4_2_0 == ((0xf<<28) | (0x7f<<14) | (0x7f)) );
19242
19243 p++;
19244 a = a<<14;
19245 a |= *p;
19246 /* a: p0<<14 | p2 (unmasked) */
@@ -25761,11 +26155,13 @@
25761 flags |= SQLITE_OPEN_READONLY;
25762 openFlags |= O_RDONLY;
25763 fd = open(zName, openFlags, openMode);
25764 }
25765 if( fd<0 ){
25766 rc = SQLITE_CANTOPEN_BKPT;
 
 
25767 goto open_finished;
25768 }
25769 }
25770 assert( fd>=0 );
25771 if( pOutFlags ){
@@ -33815,10 +34211,13 @@
33815 if( rc==SQLITE_OK ){
33816 zMaster = pPager->pTmpSpace;
33817 rc = readMasterJournal(pPager->jfd, zMaster, pPager->pVfs->mxPathname+1);
33818 testcase( rc!=SQLITE_OK );
33819 }
 
 
 
33820 if( rc==SQLITE_OK ){
33821 rc = pager_end_transaction(pPager, zMaster[0]!='\0');
33822 testcase( rc!=SQLITE_OK );
33823 }
33824 if( rc==SQLITE_OK && zMaster[0] && res ){
@@ -35135,10 +35534,11 @@
35135 }
35136 /* pPager->xBusyHandler = 0; */
35137 /* pPager->pBusyHandlerArg = 0; */
35138 pPager->xReiniter = xReinit;
35139 /* memset(pPager->aHash, 0, sizeof(pPager->aHash)); */
 
35140 *ppPager = pPager;
35141 return SQLITE_OK;
35142 }
35143
35144
@@ -35284,12 +35684,28 @@
35284 rc = sqlite3OsRead(pPager->fd, pPg->pData, pPager->pageSize, iOffset);
35285 if( rc==SQLITE_IOERR_SHORT_READ ){
35286 rc = SQLITE_OK;
35287 }
35288 if( pgno==1 ){
35289 u8 *dbFileVers = &((u8*)pPg->pData)[24];
35290 memcpy(&pPager->dbFileVers, dbFileVers, sizeof(pPager->dbFileVers));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35291 }
35292 CODEC1(pPager, pPg->pData, pgno, 3, rc = SQLITE_NOMEM);
35293
35294 PAGER_INCR(sqlite3_pager_readdb_count);
35295 PAGER_INCR(pPager->nRead);
@@ -36786,10 +37202,11 @@
36786 if( op==SAVEPOINT_RELEASE ){
36787 if( nNew==0 && isOpen(pPager->sjfd) ){
36788 /* Only truncate if it is an in-memory sub-journal. */
36789 if( sqlite3IsMemJournal(pPager->sjfd) ){
36790 rc = sqlite3OsTruncate(pPager->sjfd, 0);
 
36791 }
36792 pPager->nSubRec = 0;
36793 }
36794 }
36795 /* Else this is a rollback operation, playback the specified savepoint.
@@ -43199,11 +43616,11 @@
43199 if( nOvfl ){
43200 rc = getOverflowPage(pBt, ovflPgno, &pOvfl, &iNext);
43201 if( rc ) return rc;
43202 }
43203
43204 if( (pOvfl || (pOvfl = btreePageLookup(pBt, ovflPgno)))
43205 && sqlite3PagerPageRefcount(pOvfl->pDbPage)!=1
43206 ){
43207 /* There is no reason any cursor should have an outstanding reference
43208 ** to an overflow page belonging to a cell that is being deleted/updated.
43209 ** So if there exists more than one reference to this page, then it
@@ -43952,11 +44369,11 @@
43952 ** the dropCell() routine will overwrite the entire cell with zeroes.
43953 ** In this case, temporarily copy the cell into the aOvflSpace[]
43954 ** buffer. It will be copied out again as soon as the aSpace[] buffer
43955 ** is allocated. */
43956 if( pBt->secureDelete ){
43957 int iOff = apDiv[i] - pParent->aData;
43958 if( (iOff+szNew[i])>pBt->usableSize ){
43959 rc = SQLITE_CORRUPT_BKPT;
43960 memset(apOld, 0, (i+1)*sizeof(MemPage*));
43961 goto balance_cleanup;
43962 }else{
@@ -47321,11 +47738,11 @@
47321 SQLITE_PRIVATE void sqlite3VdbeMemShallowCopy(Mem *pTo, const Mem *pFrom, int srcType){
47322 assert( (pFrom->flags & MEM_RowSet)==0 );
47323 sqlite3VdbeMemReleaseExternal(pTo);
47324 memcpy(pTo, pFrom, MEMCELLSIZE);
47325 pTo->xDel = 0;
47326 if( (pFrom->flags&MEM_Dyn)!=0 || pFrom->z==pFrom->zMalloc ){
47327 pTo->flags &= ~(MEM_Dyn|MEM_Static|MEM_Ephem);
47328 assert( srcType==MEM_Ephem || srcType==MEM_Static );
47329 pTo->flags |= srcType;
47330 }
47331 }
@@ -49953,16 +50370,21 @@
49953 }
49954
49955 /* If eStatementOp is non-zero, then a statement transaction needs to
49956 ** be committed or rolled back. Call sqlite3VdbeCloseStatement() to
49957 ** do so. If this operation returns an error, and the current statement
49958 ** error code is SQLITE_OK or SQLITE_CONSTRAINT, then set the error
49959 ** code to the new value.
 
 
 
 
 
49960 */
49961 if( eStatementOp ){
49962 rc = sqlite3VdbeCloseStatement(p, eStatementOp);
49963 if( rc && (p->rc==SQLITE_OK || p->rc==SQLITE_CONSTRAINT) ){
49964 p->rc = rc;
49965 sqlite3DbFree(db, p->zErrMsg);
49966 p->zErrMsg = 0;
49967 }
49968 }
@@ -52577,21 +52999,34 @@
52577 ** look like a number, leave it alone.
52578 */
52579 static void applyNumericAffinity(Mem *pRec){
52580 if( (pRec->flags & (MEM_Real|MEM_Int))==0 ){
52581 int realnum;
 
52582 sqlite3VdbeMemNulTerminate(pRec);
52583 if( (pRec->flags&MEM_Str)
52584 && sqlite3IsNumber(pRec->z, &realnum, pRec->enc) ){
52585 i64 value;
52586 sqlite3VdbeChangeEncoding(pRec, SQLITE_UTF8);
52587 if( !realnum && sqlite3Atoi64(pRec->z, &value) ){
 
 
 
 
 
 
 
52588 pRec->u.i = value;
52589 MemSetTypeFlag(pRec, MEM_Int);
52590 }else{
52591 sqlite3VdbeMemRealify(pRec);
 
52592 }
 
 
 
 
 
52593 }
52594 }
52595 }
52596
52597 /*
@@ -53039,10 +53474,12 @@
53039 i64 b;
53040 } ah;
53041 struct OP_Ge_stack_vars {
53042 int res; /* Result of the comparison of pIn1 against pIn3 */
53043 char affinity; /* Affinity to use for comparison */
 
 
53044 } ai;
53045 struct OP_Compare_stack_vars {
53046 int n;
53047 int i;
53048 int p1;
@@ -54573,14 +55010,18 @@
54573 case OP_Gt: /* same as TK_GT, jump, in1, in3 */
54574 case OP_Ge: { /* same as TK_GE, jump, in1, in3 */
54575 #if 0 /* local variables moved into u.ai */
54576 int res; /* Result of the comparison of pIn1 against pIn3 */
54577 char affinity; /* Affinity to use for comparison */
 
 
54578 #endif /* local variables moved into u.ai */
54579
54580 pIn1 = &aMem[pOp->p1];
54581 pIn3 = &aMem[pOp->p3];
 
 
54582 if( (pIn1->flags | pIn3->flags)&MEM_Null ){
54583 /* One or both operands are NULL */
54584 if( pOp->p5 & SQLITE_NULLEQ ){
54585 /* If SQLITE_NULLEQ is set (which will only happen if the operator is
54586 ** OP_Eq or OP_Ne) then take the jump or not depending on whether
@@ -54631,10 +55072,14 @@
54631 pOut->u.i = u.ai.res;
54632 REGISTER_TRACE(pOp->p2, pOut);
54633 }else if( u.ai.res ){
54634 pc = pOp->p2-1;
54635 }
 
 
 
 
54636 break;
54637 }
54638
54639 /* Opcode: Permutation * * * P4 *
54640 **
@@ -61176,14 +61621,10 @@
61176 p4 = sqlite3BinaryCompareCollSeq(pParse, pLeft, pRight);
61177 p5 = binaryCompareP5(pLeft, pRight, jumpIfNull);
61178 addr = sqlite3VdbeAddOp4(pParse->pVdbe, opcode, in2, dest, in1,
61179 (void*)p4, P4_COLLSEQ);
61180 sqlite3VdbeChangeP5(pParse->pVdbe, (u8)p5);
61181 if( (p5 & SQLITE_AFF_MASK)!=SQLITE_AFF_NONE ){
61182 sqlite3ExprCacheAffinityChange(pParse, in1, 1);
61183 sqlite3ExprCacheAffinityChange(pParse, in2, 1);
61184 }
61185 return addr;
61186 }
61187
61188 #if SQLITE_MAX_EXPR_DEPTH>0
61189 /*
@@ -71076,397 +71517,10 @@
71076 }
71077 return p;
71078 }
71079
71080 /************** End of callback.c ********************************************/
71081 /************** Begin file ctime.c *******************************************/
71082 /*
71083 ** 2010 February 23
71084 **
71085 ** The author disclaims copyright to this source code. In place of
71086 ** a legal notice, here is a blessing:
71087 **
71088 ** May you do good and not evil.
71089 ** May you find forgiveness for yourself and forgive others.
71090 ** May you share freely, never taking more than you give.
71091 **
71092 *************************************************************************
71093 **
71094 ** This file implements routines used to report what compile-time options
71095 ** SQLite was built with.
71096 */
71097
71098 #ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
71099
71100
71101 /*
71102 ** An array of names of all compile-time options. This array should
71103 ** be sorted A-Z.
71104 **
71105 ** This array looks large, but in a typical installation actually uses
71106 ** only a handful of compile-time options, so most times this array is usually
71107 ** rather short and uses little memory space.
71108 */
71109 static const char * const azCompileOpt[] = {
71110
71111 /* These macros are provided to "stringify" the value of the define
71112 ** for those options in which the value is meaningful. */
71113 #define CTIMEOPT_VAL_(opt) #opt
71114 #define CTIMEOPT_VAL(opt) CTIMEOPT_VAL_(opt)
71115
71116 #ifdef SQLITE_32BIT_ROWID
71117 "32BIT_ROWID",
71118 #endif
71119 #ifdef SQLITE_4_BYTE_ALIGNED_MALLOC
71120 "4_BYTE_ALIGNED_MALLOC",
71121 #endif
71122 #ifdef SQLITE_CASE_SENSITIVE_LIKE
71123 "CASE_SENSITIVE_LIKE",
71124 #endif
71125 #ifdef SQLITE_CHECK_PAGES
71126 "CHECK_PAGES",
71127 #endif
71128 #ifdef SQLITE_COVERAGE_TEST
71129 "COVERAGE_TEST",
71130 #endif
71131 #ifdef SQLITE_DEBUG
71132 "DEBUG",
71133 #endif
71134 #ifdef SQLITE_DEFAULT_LOCKING_MODE
71135 "DEFAULT_LOCKING_MODE=" CTIMEOPT_VAL(SQLITE_DEFAULT_LOCKING_MODE),
71136 #endif
71137 #ifdef SQLITE_DISABLE_DIRSYNC
71138 "DISABLE_DIRSYNC",
71139 #endif
71140 #ifdef SQLITE_DISABLE_LFS
71141 "DISABLE_LFS",
71142 #endif
71143 #ifdef SQLITE_ENABLE_ATOMIC_WRITE
71144 "ENABLE_ATOMIC_WRITE",
71145 #endif
71146 #ifdef SQLITE_ENABLE_CEROD
71147 "ENABLE_CEROD",
71148 #endif
71149 #ifdef SQLITE_ENABLE_COLUMN_METADATA
71150 "ENABLE_COLUMN_METADATA",
71151 #endif
71152 #ifdef SQLITE_ENABLE_EXPENSIVE_ASSERT
71153 "ENABLE_EXPENSIVE_ASSERT",
71154 #endif
71155 #ifdef SQLITE_ENABLE_FTS1
71156 "ENABLE_FTS1",
71157 #endif
71158 #ifdef SQLITE_ENABLE_FTS2
71159 "ENABLE_FTS2",
71160 #endif
71161 #ifdef SQLITE_ENABLE_FTS3
71162 "ENABLE_FTS3",
71163 #endif
71164 #ifdef SQLITE_ENABLE_FTS3_PARENTHESIS
71165 "ENABLE_FTS3_PARENTHESIS",
71166 #endif
71167 #ifdef SQLITE_ENABLE_FTS4
71168 "ENABLE_FTS4",
71169 #endif
71170 #ifdef SQLITE_ENABLE_ICU
71171 "ENABLE_ICU",
71172 #endif
71173 #ifdef SQLITE_ENABLE_IOTRACE
71174 "ENABLE_IOTRACE",
71175 #endif
71176 #ifdef SQLITE_ENABLE_LOAD_EXTENSION
71177 "ENABLE_LOAD_EXTENSION",
71178 #endif
71179 #ifdef SQLITE_ENABLE_LOCKING_STYLE
71180 "ENABLE_LOCKING_STYLE=" CTIMEOPT_VAL(SQLITE_ENABLE_LOCKING_STYLE),
71181 #endif
71182 #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
71183 "ENABLE_MEMORY_MANAGEMENT",
71184 #endif
71185 #ifdef SQLITE_ENABLE_MEMSYS3
71186 "ENABLE_MEMSYS3",
71187 #endif
71188 #ifdef SQLITE_ENABLE_MEMSYS5
71189 "ENABLE_MEMSYS5",
71190 #endif
71191 #ifdef SQLITE_ENABLE_OVERSIZE_CELL_CHECK
71192 "ENABLE_OVERSIZE_CELL_CHECK",
71193 #endif
71194 #ifdef SQLITE_ENABLE_RTREE
71195 "ENABLE_RTREE",
71196 #endif
71197 #ifdef SQLITE_ENABLE_STAT2
71198 "ENABLE_STAT2",
71199 #endif
71200 #ifdef SQLITE_ENABLE_UNLOCK_NOTIFY
71201 "ENABLE_UNLOCK_NOTIFY",
71202 #endif
71203 #ifdef SQLITE_ENABLE_UPDATE_DELETE_LIMIT
71204 "ENABLE_UPDATE_DELETE_LIMIT",
71205 #endif
71206 #ifdef SQLITE_HAS_CODEC
71207 "HAS_CODEC",
71208 #endif
71209 #ifdef SQLITE_HAVE_ISNAN
71210 "HAVE_ISNAN",
71211 #endif
71212 #ifdef SQLITE_HOMEGROWN_RECURSIVE_MUTEX
71213 "HOMEGROWN_RECURSIVE_MUTEX",
71214 #endif
71215 #ifdef SQLITE_IGNORE_AFP_LOCK_ERRORS
71216 "IGNORE_AFP_LOCK_ERRORS",
71217 #endif
71218 #ifdef SQLITE_IGNORE_FLOCK_LOCK_ERRORS
71219 "IGNORE_FLOCK_LOCK_ERRORS",
71220 #endif
71221 #ifdef SQLITE_INT64_TYPE
71222 "INT64_TYPE",
71223 #endif
71224 #ifdef SQLITE_LOCK_TRACE
71225 "LOCK_TRACE",
71226 #endif
71227 #ifdef SQLITE_MEMDEBUG
71228 "MEMDEBUG",
71229 #endif
71230 #ifdef SQLITE_MIXED_ENDIAN_64BIT_FLOAT
71231 "MIXED_ENDIAN_64BIT_FLOAT",
71232 #endif
71233 #ifdef SQLITE_NO_SYNC
71234 "NO_SYNC",
71235 #endif
71236 #ifdef SQLITE_OMIT_ALTERTABLE
71237 "OMIT_ALTERTABLE",
71238 #endif
71239 #ifdef SQLITE_OMIT_ANALYZE
71240 "OMIT_ANALYZE",
71241 #endif
71242 #ifdef SQLITE_OMIT_ATTACH
71243 "OMIT_ATTACH",
71244 #endif
71245 #ifdef SQLITE_OMIT_AUTHORIZATION
71246 "OMIT_AUTHORIZATION",
71247 #endif
71248 #ifdef SQLITE_OMIT_AUTOINCREMENT
71249 "OMIT_AUTOINCREMENT",
71250 #endif
71251 #ifdef SQLITE_OMIT_AUTOINIT
71252 "OMIT_AUTOINIT",
71253 #endif
71254 #ifdef SQLITE_OMIT_AUTOVACUUM
71255 "OMIT_AUTOVACUUM",
71256 #endif
71257 #ifdef SQLITE_OMIT_BETWEEN_OPTIMIZATION
71258 "OMIT_BETWEEN_OPTIMIZATION",
71259 #endif
71260 #ifdef SQLITE_OMIT_BLOB_LITERAL
71261 "OMIT_BLOB_LITERAL",
71262 #endif
71263 #ifdef SQLITE_OMIT_BTREECOUNT
71264 "OMIT_BTREECOUNT",
71265 #endif
71266 #ifdef SQLITE_OMIT_BUILTIN_TEST
71267 "OMIT_BUILTIN_TEST",
71268 #endif
71269 #ifdef SQLITE_OMIT_CAST
71270 "OMIT_CAST",
71271 #endif
71272 #ifdef SQLITE_OMIT_CHECK
71273 "OMIT_CHECK",
71274 #endif
71275 #ifdef SQLITE_OMIT_COMPILEOPTION_DIAGS
71276 "OMIT_COMPILEOPTION_DIAGS",
71277 #endif
71278 #ifdef SQLITE_OMIT_COMPLETE
71279 "OMIT_COMPLETE",
71280 #endif
71281 #ifdef SQLITE_OMIT_COMPOUND_SELECT
71282 "OMIT_COMPOUND_SELECT",
71283 #endif
71284 #ifdef SQLITE_OMIT_DATETIME_FUNCS
71285 "OMIT_DATETIME_FUNCS",
71286 #endif
71287 #ifdef SQLITE_OMIT_DECLTYPE
71288 "OMIT_DECLTYPE",
71289 #endif
71290 #ifdef SQLITE_OMIT_DEPRECATED
71291 "OMIT_DEPRECATED",
71292 #endif
71293 #ifdef SQLITE_OMIT_DISKIO
71294 "OMIT_DISKIO",
71295 #endif
71296 #ifdef SQLITE_OMIT_EXPLAIN
71297 "OMIT_EXPLAIN",
71298 #endif
71299 #ifdef SQLITE_OMIT_FLAG_PRAGMAS
71300 "OMIT_FLAG_PRAGMAS",
71301 #endif
71302 #ifdef SQLITE_OMIT_FLOATING_POINT
71303 "OMIT_FLOATING_POINT",
71304 #endif
71305 #ifdef SQLITE_OMIT_FOREIGN_KEY
71306 "OMIT_FOREIGN_KEY",
71307 #endif
71308 #ifdef SQLITE_OMIT_GET_TABLE
71309 "OMIT_GET_TABLE",
71310 #endif
71311 #ifdef SQLITE_OMIT_GLOBALRECOVER
71312 "OMIT_GLOBALRECOVER",
71313 #endif
71314 #ifdef SQLITE_OMIT_INCRBLOB
71315 "OMIT_INCRBLOB",
71316 #endif
71317 #ifdef SQLITE_OMIT_INTEGRITY_CHECK
71318 "OMIT_INTEGRITY_CHECK",
71319 #endif
71320 #ifdef SQLITE_OMIT_LIKE_OPTIMIZATION
71321 "OMIT_LIKE_OPTIMIZATION",
71322 #endif
71323 #ifdef SQLITE_OMIT_LOAD_EXTENSION
71324 "OMIT_LOAD_EXTENSION",
71325 #endif
71326 #ifdef SQLITE_OMIT_LOCALTIME
71327 "OMIT_LOCALTIME",
71328 #endif
71329 #ifdef SQLITE_OMIT_LOOKASIDE
71330 "OMIT_LOOKASIDE",
71331 #endif
71332 #ifdef SQLITE_OMIT_MEMORYDB
71333 "OMIT_MEMORYDB",
71334 #endif
71335 #ifdef SQLITE_OMIT_OR_OPTIMIZATION
71336 "OMIT_OR_OPTIMIZATION",
71337 #endif
71338 #ifdef SQLITE_OMIT_PAGER_PRAGMAS
71339 "OMIT_PAGER_PRAGMAS",
71340 #endif
71341 #ifdef SQLITE_OMIT_PRAGMA
71342 "OMIT_PRAGMA",
71343 #endif
71344 #ifdef SQLITE_OMIT_PROGRESS_CALLBACK
71345 "OMIT_PROGRESS_CALLBACK",
71346 #endif
71347 #ifdef SQLITE_OMIT_QUICKBALANCE
71348 "OMIT_QUICKBALANCE",
71349 #endif
71350 #ifdef SQLITE_OMIT_REINDEX
71351 "OMIT_REINDEX",
71352 #endif
71353 #ifdef SQLITE_OMIT_SCHEMA_PRAGMAS
71354 "OMIT_SCHEMA_PRAGMAS",
71355 #endif
71356 #ifdef SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS
71357 "OMIT_SCHEMA_VERSION_PRAGMAS",
71358 #endif
71359 #ifdef SQLITE_OMIT_SHARED_CACHE
71360 "OMIT_SHARED_CACHE",
71361 #endif
71362 #ifdef SQLITE_OMIT_SUBQUERY
71363 "OMIT_SUBQUERY",
71364 #endif
71365 #ifdef SQLITE_OMIT_TCL_VARIABLE
71366 "OMIT_TCL_VARIABLE",
71367 #endif
71368 #ifdef SQLITE_OMIT_TEMPDB
71369 "OMIT_TEMPDB",
71370 #endif
71371 #ifdef SQLITE_OMIT_TRACE
71372 "OMIT_TRACE",
71373 #endif
71374 #ifdef SQLITE_OMIT_TRIGGER
71375 "OMIT_TRIGGER",
71376 #endif
71377 #ifdef SQLITE_OMIT_TRUNCATE_OPTIMIZATION
71378 "OMIT_TRUNCATE_OPTIMIZATION",
71379 #endif
71380 #ifdef SQLITE_OMIT_UTF16
71381 "OMIT_UTF16",
71382 #endif
71383 #ifdef SQLITE_OMIT_VACUUM
71384 "OMIT_VACUUM",
71385 #endif
71386 #ifdef SQLITE_OMIT_VIEW
71387 "OMIT_VIEW",
71388 #endif
71389 #ifdef SQLITE_OMIT_VIRTUALTABLE
71390 "OMIT_VIRTUALTABLE",
71391 #endif
71392 #ifdef SQLITE_OMIT_WSD
71393 "OMIT_WSD",
71394 #endif
71395 #ifdef SQLITE_OMIT_XFER_OPT
71396 "OMIT_XFER_OPT",
71397 #endif
71398 #ifdef SQLITE_PERFORMANCE_TRACE
71399 "PERFORMANCE_TRACE",
71400 #endif
71401 #ifdef SQLITE_PROXY_DEBUG
71402 "PROXY_DEBUG",
71403 #endif
71404 #ifdef SQLITE_SECURE_DELETE
71405 "SECURE_DELETE",
71406 #endif
71407 #ifdef SQLITE_SMALL_STACK
71408 "SMALL_STACK",
71409 #endif
71410 #ifdef SQLITE_SOUNDEX
71411 "SOUNDEX",
71412 #endif
71413 #ifdef SQLITE_TCL
71414 "TCL",
71415 #endif
71416 #ifdef SQLITE_TEMP_STORE
71417 "TEMP_STORE=" CTIMEOPT_VAL(SQLITE_TEMP_STORE),
71418 #endif
71419 #ifdef SQLITE_TEST
71420 "TEST",
71421 #endif
71422 #ifdef SQLITE_THREADSAFE
71423 "THREADSAFE=" CTIMEOPT_VAL(SQLITE_THREADSAFE),
71424 #endif
71425 #ifdef SQLITE_USE_ALLOCA
71426 "USE_ALLOCA",
71427 #endif
71428 #ifdef SQLITE_ZERO_MALLOC
71429 "ZERO_MALLOC"
71430 #endif
71431 };
71432
71433 /*
71434 ** Given the name of a compile-time option, return true if that option
71435 ** was used and false if not.
71436 **
71437 ** The name can optionally begin with "SQLITE_" but the "SQLITE_" prefix
71438 ** is not required for a match.
71439 */
71440 SQLITE_API int sqlite3_compileoption_used(const char *zOptName){
71441 int i, n;
71442 if( sqlite3StrNICmp(zOptName, "SQLITE_", 7)==0 ) zOptName += 7;
71443 n = sqlite3Strlen30(zOptName);
71444
71445 /* Since ArraySize(azCompileOpt) is normally in single digits, a
71446 ** linear search is adequate. No need for a binary search. */
71447 for(i=0; i<ArraySize(azCompileOpt); i++){
71448 if( (sqlite3StrNICmp(zOptName, azCompileOpt[i], n)==0)
71449 && ( (azCompileOpt[i][n]==0) || (azCompileOpt[i][n]=='=') ) ) return 1;
71450 }
71451 return 0;
71452 }
71453
71454 /*
71455 ** Return the N-th compile-time option string. If N is out of range,
71456 ** return a NULL pointer.
71457 */
71458 SQLITE_API const char *sqlite3_compileoption_get(int N){
71459 if( N>=0 && N<ArraySize(azCompileOpt) ){
71460 return azCompileOpt[N];
71461 }
71462 return 0;
71463 }
71464
71465 #endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */
71466
71467 /************** End of ctime.c ***********************************************/
71468 /************** Begin file delete.c ******************************************/
71469 /*
71470 ** 2001 September 15
71471 **
71472 ** The author disclaims copyright to this source code. In place of
@@ -80134,11 +80188,11 @@
80134 *ppStmt = 0;
80135 if( !sqlite3SafetyCheckOk(db) ){
80136 return SQLITE_MISUSE_BKPT;
80137 }
80138 sqlite3_mutex_enter(db->mutex);
80139 zSql8 = sqlite3Utf16to8(db, zSql, nBytes);
80140 if( zSql8 ){
80141 rc = sqlite3LockAndPrepare(db, zSql8, -1, saveSqlFlag, 0, ppStmt, &zTail8);
80142 }
80143
80144 if( zTail8 && pzTail ){
@@ -97459,11 +97513,11 @@
97459 ){
97460 int rc;
97461 char *zFunc8;
97462 sqlite3_mutex_enter(db->mutex);
97463 assert( !db->mallocFailed );
97464 zFunc8 = sqlite3Utf16to8(db, zFunctionName, -1);
97465 rc = sqlite3CreateFunc(db, zFunc8, nArg, eTextRep, p, xFunc, xStep, xFinal);
97466 sqlite3DbFree(db, zFunc8);
97467 rc = sqlite3ApiExit(db, rc);
97468 sqlite3_mutex_leave(db->mutex);
97469 return rc;
@@ -98282,11 +98336,11 @@
98282 ){
98283 int rc = SQLITE_OK;
98284 char *zName8;
98285 sqlite3_mutex_enter(db->mutex);
98286 assert( !db->mallocFailed );
98287 zName8 = sqlite3Utf16to8(db, zName, -1);
98288 if( zName8 ){
98289 rc = createCollation(db, zName8, (u8)enc, SQLITE_COLL_USER, pCtx, xCompare, 0);
98290 sqlite3DbFree(db, zName8);
98291 }
98292 rc = sqlite3ApiExit(db, rc);
@@ -100273,10 +100327,18 @@
100273 p->zDb, p->zName
100274 );
100275 }
100276 return rc;
100277 }
 
 
 
 
 
 
 
 
100278
100279 /*
100280 ** Determine if a table currently exists in the database.
100281 */
100282 static void fts3TableExists(
@@ -100286,14 +100348,21 @@
100286 const char *zName, /* Name of the FTS3 table */
100287 const char *zSuffix, /* Shadow table extension */
100288 u8 *pResult /* Write results here */
100289 ){
100290 int rc = SQLITE_OK;
 
 
100291 if( *pRc ) return;
100292 fts3DbExec(&rc, db, "SELECT 1 FROM %Q.'%q%s'", zDb, zName, zSuffix);
100293 *pResult = (rc==SQLITE_OK) ? 1 : 0;
100294 if( rc!=SQLITE_ERROR ) *pRc = rc;
 
 
 
 
 
100295 }
100296
100297 /*
100298 ** This function is the implementation of both the xConnect and xCreate
100299 ** methods of the FTS3 virtual table.
@@ -100711,11 +100780,16 @@
100711 *piPrev = iVal;
100712 }
100713
100714 /*
100715 ** When this function is called, *ppPoslist is assumed to point to the
100716 ** start of a position-list.
 
 
 
 
 
100717 */
100718 static void fts3PoslistCopy(char **pp, char **ppPoslist){
100719 char *pEnd = *ppPoslist;
100720 char c = 0;
100721
@@ -101702,11 +101776,17 @@
101702 }
101703
101704 rc = sqlite3Fts3ExprParse(p->pTokenizer, p->azColumn, p->nColumn,
101705 iCol, zQuery, -1, &pCsr->pExpr
101706 );
101707 if( rc!=SQLITE_OK ) return rc;
 
 
 
 
 
 
101708
101709 rc = evalFts3Expr(p, pCsr->pExpr, &pCsr->aDoclist, &pCsr->nDoclist, 0);
101710 pCsr->pNextId = pCsr->aDoclist;
101711 pCsr->iPrevId = 0;
101712 }
@@ -101855,11 +101935,13 @@
101855
101856 assert( pCsr );
101857 while( pCsr<pEnd ){
101858 if( pExpr->iCurrent<iDocid ){
101859 fts3PoslistCopy(0, &pCsr);
101860 fts3GetDeltaVarint(&pCsr, &pExpr->iCurrent);
 
 
101861 pExpr->pCurrent = pCsr;
101862 }else{
101863 if( pExpr->iCurrent==iDocid ){
101864 int iThis = 0;
101865 if( iCol<0 ){
@@ -105105,13 +105187,13 @@
105105 /* 3 */ "DELETE FROM %Q.'%q_segments'",
105106 /* 4 */ "DELETE FROM %Q.'%q_segdir'",
105107 /* 5 */ "DELETE FROM %Q.'%q_docsize'",
105108 /* 6 */ "DELETE FROM %Q.'%q_stat'",
105109 /* 7 */ "SELECT * FROM %Q.'%q_content' WHERE rowid=?",
105110 /* 8 */ "SELECT coalesce(max(idx)+1, 0) FROM %Q.'%q_segdir' WHERE level=?",
105111 /* 9 */ "INSERT INTO %Q.'%q_segments'(blockid, block) VALUES(?, ?)",
105112 /* 10 */ "SELECT coalesce(max(blockid)+1, 1) FROM %Q.'%q_segments'",
105113 /* 11 */ "INSERT INTO %Q.'%q_segdir' VALUES(?,?,?,?,?,?)",
105114
105115 /* Return segments in order from oldest to newest.*/
105116 /* 12 */ "SELECT idx, start_block, leaves_end_block, end_block, root "
105117 "FROM %Q.'%q_segdir' WHERE level = ? ORDER BY idx ASC",
@@ -108666,15 +108748,17 @@
108666 char aBuffer[64];
108667 sqlite3_snprintf(sizeof(aBuffer), aBuffer,
108668 "%d %d %d %d ", iCol, pTerm-sCtx.aTerm, iStart, iEnd-iStart
108669 );
108670 rc = fts3StringAppend(&res, aBuffer, -1);
 
 
108671 }
108672 }
108673 }
108674 if( rc==SQLITE_DONE ){
108675 rc = SQLITE_CORRUPT;
108676 }
108677
108678 pMod->xClose(pC);
108679 if( rc!=SQLITE_OK ) goto offsets_out;
108680 }
108681
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1,8 +1,8 @@
1 /******************************************************************************
2 ** This file is an amalgamation of many separate C source files from SQLite
3 ** version 3.6.23.1. By combining all the individual C code files into this
4 ** single large file, the entire code can be compiled as a one translation
5 ** unit. This allows many compilers to do optimizations that would not be
6 ** possible if the files were compiled separately. Performance improvements
7 ** of 5% are more are commonly seen when SQLite is compiled as a single
8 ** translation unit.
@@ -626,13 +626,13 @@
626 **
627 ** See also: [sqlite3_libversion()],
628 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
629 ** [sqlite_version()] and [sqlite_source_id()].
630 */
631 #define SQLITE_VERSION "3.6.23.1"
632 #define SQLITE_VERSION_NUMBER 3006023
633 #define SQLITE_SOURCE_ID "2010-03-26 22:28:06 ex-b078b588d617e07886ad156e9f54ade6d823568e"
634
635 /*
636 ** CAPI3REF: Run-Time Library Version Numbers
637 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
638 **
@@ -10425,11 +10425,11 @@
10425 SQLITE_PRIVATE int sqlite3ValueBytes(sqlite3_value*, u8);
10426 SQLITE_PRIVATE void sqlite3ValueSetStr(sqlite3_value*, int, const void *,u8,
10427 void(*)(void*));
10428 SQLITE_PRIVATE void sqlite3ValueFree(sqlite3_value*);
10429 SQLITE_PRIVATE sqlite3_value *sqlite3ValueNew(sqlite3 *);
10430 SQLITE_PRIVATE char *sqlite3Utf16to8(sqlite3 *, const void*, int, u8);
10431 #ifdef SQLITE_ENABLE_STAT2
10432 SQLITE_PRIVATE char *sqlite3Utf8to16(sqlite3 *, u8, char *, int, int *);
10433 #endif
10434 SQLITE_PRIVATE int sqlite3ValueFromExpr(sqlite3 *, Expr *, u8, u8, sqlite3_value **);
10435 SQLITE_PRIVATE void sqlite3ValueApplyAffinity(sqlite3_value *, u8, u8);
@@ -10866,10 +10866,397 @@
10866 ** the vdbe.c file.
10867 */
10868 SQLITE_PRIVATE const unsigned char sqlite3OpcodeProperty[] = OPFLG_INITIALIZER;
10869
10870 /************** End of global.c **********************************************/
10871 /************** Begin file ctime.c *******************************************/
10872 /*
10873 ** 2010 February 23
10874 **
10875 ** The author disclaims copyright to this source code. In place of
10876 ** a legal notice, here is a blessing:
10877 **
10878 ** May you do good and not evil.
10879 ** May you find forgiveness for yourself and forgive others.
10880 ** May you share freely, never taking more than you give.
10881 **
10882 *************************************************************************
10883 **
10884 ** This file implements routines used to report what compile-time options
10885 ** SQLite was built with.
10886 */
10887
10888 #ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
10889
10890
10891 /*
10892 ** An array of names of all compile-time options. This array should
10893 ** be sorted A-Z.
10894 **
10895 ** This array looks large, but in a typical installation actually uses
10896 ** only a handful of compile-time options, so most times this array is usually
10897 ** rather short and uses little memory space.
10898 */
10899 static const char * const azCompileOpt[] = {
10900
10901 /* These macros are provided to "stringify" the value of the define
10902 ** for those options in which the value is meaningful. */
10903 #define CTIMEOPT_VAL_(opt) #opt
10904 #define CTIMEOPT_VAL(opt) CTIMEOPT_VAL_(opt)
10905
10906 #ifdef SQLITE_32BIT_ROWID
10907 "32BIT_ROWID",
10908 #endif
10909 #ifdef SQLITE_4_BYTE_ALIGNED_MALLOC
10910 "4_BYTE_ALIGNED_MALLOC",
10911 #endif
10912 #ifdef SQLITE_CASE_SENSITIVE_LIKE
10913 "CASE_SENSITIVE_LIKE",
10914 #endif
10915 #ifdef SQLITE_CHECK_PAGES
10916 "CHECK_PAGES",
10917 #endif
10918 #ifdef SQLITE_COVERAGE_TEST
10919 "COVERAGE_TEST",
10920 #endif
10921 #ifdef SQLITE_DEBUG
10922 "DEBUG",
10923 #endif
10924 #ifdef SQLITE_DEFAULT_LOCKING_MODE
10925 "DEFAULT_LOCKING_MODE=" CTIMEOPT_VAL(SQLITE_DEFAULT_LOCKING_MODE),
10926 #endif
10927 #ifdef SQLITE_DISABLE_DIRSYNC
10928 "DISABLE_DIRSYNC",
10929 #endif
10930 #ifdef SQLITE_DISABLE_LFS
10931 "DISABLE_LFS",
10932 #endif
10933 #ifdef SQLITE_ENABLE_ATOMIC_WRITE
10934 "ENABLE_ATOMIC_WRITE",
10935 #endif
10936 #ifdef SQLITE_ENABLE_CEROD
10937 "ENABLE_CEROD",
10938 #endif
10939 #ifdef SQLITE_ENABLE_COLUMN_METADATA
10940 "ENABLE_COLUMN_METADATA",
10941 #endif
10942 #ifdef SQLITE_ENABLE_EXPENSIVE_ASSERT
10943 "ENABLE_EXPENSIVE_ASSERT",
10944 #endif
10945 #ifdef SQLITE_ENABLE_FTS1
10946 "ENABLE_FTS1",
10947 #endif
10948 #ifdef SQLITE_ENABLE_FTS2
10949 "ENABLE_FTS2",
10950 #endif
10951 #ifdef SQLITE_ENABLE_FTS3
10952 "ENABLE_FTS3",
10953 #endif
10954 #ifdef SQLITE_ENABLE_FTS3_PARENTHESIS
10955 "ENABLE_FTS3_PARENTHESIS",
10956 #endif
10957 #ifdef SQLITE_ENABLE_FTS4
10958 "ENABLE_FTS4",
10959 #endif
10960 #ifdef SQLITE_ENABLE_ICU
10961 "ENABLE_ICU",
10962 #endif
10963 #ifdef SQLITE_ENABLE_IOTRACE
10964 "ENABLE_IOTRACE",
10965 #endif
10966 #ifdef SQLITE_ENABLE_LOAD_EXTENSION
10967 "ENABLE_LOAD_EXTENSION",
10968 #endif
10969 #ifdef SQLITE_ENABLE_LOCKING_STYLE
10970 "ENABLE_LOCKING_STYLE=" CTIMEOPT_VAL(SQLITE_ENABLE_LOCKING_STYLE),
10971 #endif
10972 #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
10973 "ENABLE_MEMORY_MANAGEMENT",
10974 #endif
10975 #ifdef SQLITE_ENABLE_MEMSYS3
10976 "ENABLE_MEMSYS3",
10977 #endif
10978 #ifdef SQLITE_ENABLE_MEMSYS5
10979 "ENABLE_MEMSYS5",
10980 #endif
10981 #ifdef SQLITE_ENABLE_OVERSIZE_CELL_CHECK
10982 "ENABLE_OVERSIZE_CELL_CHECK",
10983 #endif
10984 #ifdef SQLITE_ENABLE_RTREE
10985 "ENABLE_RTREE",
10986 #endif
10987 #ifdef SQLITE_ENABLE_STAT2
10988 "ENABLE_STAT2",
10989 #endif
10990 #ifdef SQLITE_ENABLE_UNLOCK_NOTIFY
10991 "ENABLE_UNLOCK_NOTIFY",
10992 #endif
10993 #ifdef SQLITE_ENABLE_UPDATE_DELETE_LIMIT
10994 "ENABLE_UPDATE_DELETE_LIMIT",
10995 #endif
10996 #ifdef SQLITE_HAS_CODEC
10997 "HAS_CODEC",
10998 #endif
10999 #ifdef SQLITE_HAVE_ISNAN
11000 "HAVE_ISNAN",
11001 #endif
11002 #ifdef SQLITE_HOMEGROWN_RECURSIVE_MUTEX
11003 "HOMEGROWN_RECURSIVE_MUTEX",
11004 #endif
11005 #ifdef SQLITE_IGNORE_AFP_LOCK_ERRORS
11006 "IGNORE_AFP_LOCK_ERRORS",
11007 #endif
11008 #ifdef SQLITE_IGNORE_FLOCK_LOCK_ERRORS
11009 "IGNORE_FLOCK_LOCK_ERRORS",
11010 #endif
11011 #ifdef SQLITE_INT64_TYPE
11012 "INT64_TYPE",
11013 #endif
11014 #ifdef SQLITE_LOCK_TRACE
11015 "LOCK_TRACE",
11016 #endif
11017 #ifdef SQLITE_MEMDEBUG
11018 "MEMDEBUG",
11019 #endif
11020 #ifdef SQLITE_MIXED_ENDIAN_64BIT_FLOAT
11021 "MIXED_ENDIAN_64BIT_FLOAT",
11022 #endif
11023 #ifdef SQLITE_NO_SYNC
11024 "NO_SYNC",
11025 #endif
11026 #ifdef SQLITE_OMIT_ALTERTABLE
11027 "OMIT_ALTERTABLE",
11028 #endif
11029 #ifdef SQLITE_OMIT_ANALYZE
11030 "OMIT_ANALYZE",
11031 #endif
11032 #ifdef SQLITE_OMIT_ATTACH
11033 "OMIT_ATTACH",
11034 #endif
11035 #ifdef SQLITE_OMIT_AUTHORIZATION
11036 "OMIT_AUTHORIZATION",
11037 #endif
11038 #ifdef SQLITE_OMIT_AUTOINCREMENT
11039 "OMIT_AUTOINCREMENT",
11040 #endif
11041 #ifdef SQLITE_OMIT_AUTOINIT
11042 "OMIT_AUTOINIT",
11043 #endif
11044 #ifdef SQLITE_OMIT_AUTOVACUUM
11045 "OMIT_AUTOVACUUM",
11046 #endif
11047 #ifdef SQLITE_OMIT_BETWEEN_OPTIMIZATION
11048 "OMIT_BETWEEN_OPTIMIZATION",
11049 #endif
11050 #ifdef SQLITE_OMIT_BLOB_LITERAL
11051 "OMIT_BLOB_LITERAL",
11052 #endif
11053 #ifdef SQLITE_OMIT_BTREECOUNT
11054 "OMIT_BTREECOUNT",
11055 #endif
11056 #ifdef SQLITE_OMIT_BUILTIN_TEST
11057 "OMIT_BUILTIN_TEST",
11058 #endif
11059 #ifdef SQLITE_OMIT_CAST
11060 "OMIT_CAST",
11061 #endif
11062 #ifdef SQLITE_OMIT_CHECK
11063 "OMIT_CHECK",
11064 #endif
11065 #ifdef SQLITE_OMIT_COMPILEOPTION_DIAGS
11066 "OMIT_COMPILEOPTION_DIAGS",
11067 #endif
11068 #ifdef SQLITE_OMIT_COMPLETE
11069 "OMIT_COMPLETE",
11070 #endif
11071 #ifdef SQLITE_OMIT_COMPOUND_SELECT
11072 "OMIT_COMPOUND_SELECT",
11073 #endif
11074 #ifdef SQLITE_OMIT_DATETIME_FUNCS
11075 "OMIT_DATETIME_FUNCS",
11076 #endif
11077 #ifdef SQLITE_OMIT_DECLTYPE
11078 "OMIT_DECLTYPE",
11079 #endif
11080 #ifdef SQLITE_OMIT_DEPRECATED
11081 "OMIT_DEPRECATED",
11082 #endif
11083 #ifdef SQLITE_OMIT_DISKIO
11084 "OMIT_DISKIO",
11085 #endif
11086 #ifdef SQLITE_OMIT_EXPLAIN
11087 "OMIT_EXPLAIN",
11088 #endif
11089 #ifdef SQLITE_OMIT_FLAG_PRAGMAS
11090 "OMIT_FLAG_PRAGMAS",
11091 #endif
11092 #ifdef SQLITE_OMIT_FLOATING_POINT
11093 "OMIT_FLOATING_POINT",
11094 #endif
11095 #ifdef SQLITE_OMIT_FOREIGN_KEY
11096 "OMIT_FOREIGN_KEY",
11097 #endif
11098 #ifdef SQLITE_OMIT_GET_TABLE
11099 "OMIT_GET_TABLE",
11100 #endif
11101 #ifdef SQLITE_OMIT_GLOBALRECOVER
11102 "OMIT_GLOBALRECOVER",
11103 #endif
11104 #ifdef SQLITE_OMIT_INCRBLOB
11105 "OMIT_INCRBLOB",
11106 #endif
11107 #ifdef SQLITE_OMIT_INTEGRITY_CHECK
11108 "OMIT_INTEGRITY_CHECK",
11109 #endif
11110 #ifdef SQLITE_OMIT_LIKE_OPTIMIZATION
11111 "OMIT_LIKE_OPTIMIZATION",
11112 #endif
11113 #ifdef SQLITE_OMIT_LOAD_EXTENSION
11114 "OMIT_LOAD_EXTENSION",
11115 #endif
11116 #ifdef SQLITE_OMIT_LOCALTIME
11117 "OMIT_LOCALTIME",
11118 #endif
11119 #ifdef SQLITE_OMIT_LOOKASIDE
11120 "OMIT_LOOKASIDE",
11121 #endif
11122 #ifdef SQLITE_OMIT_MEMORYDB
11123 "OMIT_MEMORYDB",
11124 #endif
11125 #ifdef SQLITE_OMIT_OR_OPTIMIZATION
11126 "OMIT_OR_OPTIMIZATION",
11127 #endif
11128 #ifdef SQLITE_OMIT_PAGER_PRAGMAS
11129 "OMIT_PAGER_PRAGMAS",
11130 #endif
11131 #ifdef SQLITE_OMIT_PRAGMA
11132 "OMIT_PRAGMA",
11133 #endif
11134 #ifdef SQLITE_OMIT_PROGRESS_CALLBACK
11135 "OMIT_PROGRESS_CALLBACK",
11136 #endif
11137 #ifdef SQLITE_OMIT_QUICKBALANCE
11138 "OMIT_QUICKBALANCE",
11139 #endif
11140 #ifdef SQLITE_OMIT_REINDEX
11141 "OMIT_REINDEX",
11142 #endif
11143 #ifdef SQLITE_OMIT_SCHEMA_PRAGMAS
11144 "OMIT_SCHEMA_PRAGMAS",
11145 #endif
11146 #ifdef SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS
11147 "OMIT_SCHEMA_VERSION_PRAGMAS",
11148 #endif
11149 #ifdef SQLITE_OMIT_SHARED_CACHE
11150 "OMIT_SHARED_CACHE",
11151 #endif
11152 #ifdef SQLITE_OMIT_SUBQUERY
11153 "OMIT_SUBQUERY",
11154 #endif
11155 #ifdef SQLITE_OMIT_TCL_VARIABLE
11156 "OMIT_TCL_VARIABLE",
11157 #endif
11158 #ifdef SQLITE_OMIT_TEMPDB
11159 "OMIT_TEMPDB",
11160 #endif
11161 #ifdef SQLITE_OMIT_TRACE
11162 "OMIT_TRACE",
11163 #endif
11164 #ifdef SQLITE_OMIT_TRIGGER
11165 "OMIT_TRIGGER",
11166 #endif
11167 #ifdef SQLITE_OMIT_TRUNCATE_OPTIMIZATION
11168 "OMIT_TRUNCATE_OPTIMIZATION",
11169 #endif
11170 #ifdef SQLITE_OMIT_UTF16
11171 "OMIT_UTF16",
11172 #endif
11173 #ifdef SQLITE_OMIT_VACUUM
11174 "OMIT_VACUUM",
11175 #endif
11176 #ifdef SQLITE_OMIT_VIEW
11177 "OMIT_VIEW",
11178 #endif
11179 #ifdef SQLITE_OMIT_VIRTUALTABLE
11180 "OMIT_VIRTUALTABLE",
11181 #endif
11182 #ifdef SQLITE_OMIT_WSD
11183 "OMIT_WSD",
11184 #endif
11185 #ifdef SQLITE_OMIT_XFER_OPT
11186 "OMIT_XFER_OPT",
11187 #endif
11188 #ifdef SQLITE_PERFORMANCE_TRACE
11189 "PERFORMANCE_TRACE",
11190 #endif
11191 #ifdef SQLITE_PROXY_DEBUG
11192 "PROXY_DEBUG",
11193 #endif
11194 #ifdef SQLITE_SECURE_DELETE
11195 "SECURE_DELETE",
11196 #endif
11197 #ifdef SQLITE_SMALL_STACK
11198 "SMALL_STACK",
11199 #endif
11200 #ifdef SQLITE_SOUNDEX
11201 "SOUNDEX",
11202 #endif
11203 #ifdef SQLITE_TCL
11204 "TCL",
11205 #endif
11206 #ifdef SQLITE_TEMP_STORE
11207 "TEMP_STORE=" CTIMEOPT_VAL(SQLITE_TEMP_STORE),
11208 #endif
11209 #ifdef SQLITE_TEST
11210 "TEST",
11211 #endif
11212 #ifdef SQLITE_THREADSAFE
11213 "THREADSAFE=" CTIMEOPT_VAL(SQLITE_THREADSAFE),
11214 #endif
11215 #ifdef SQLITE_USE_ALLOCA
11216 "USE_ALLOCA",
11217 #endif
11218 #ifdef SQLITE_ZERO_MALLOC
11219 "ZERO_MALLOC"
11220 #endif
11221 };
11222
11223 /*
11224 ** Given the name of a compile-time option, return true if that option
11225 ** was used and false if not.
11226 **
11227 ** The name can optionally begin with "SQLITE_" but the "SQLITE_" prefix
11228 ** is not required for a match.
11229 */
11230 SQLITE_API int sqlite3_compileoption_used(const char *zOptName){
11231 int i, n;
11232 if( sqlite3StrNICmp(zOptName, "SQLITE_", 7)==0 ) zOptName += 7;
11233 n = sqlite3Strlen30(zOptName);
11234
11235 /* Since ArraySize(azCompileOpt) is normally in single digits, a
11236 ** linear search is adequate. No need for a binary search. */
11237 for(i=0; i<ArraySize(azCompileOpt); i++){
11238 if( (sqlite3StrNICmp(zOptName, azCompileOpt[i], n)==0)
11239 && ( (azCompileOpt[i][n]==0) || (azCompileOpt[i][n]=='=') ) ) return 1;
11240 }
11241 return 0;
11242 }
11243
11244 /*
11245 ** Return the N-th compile-time option string. If N is out of range,
11246 ** return a NULL pointer.
11247 */
11248 SQLITE_API const char *sqlite3_compileoption_get(int N){
11249 if( N>=0 && N<ArraySize(azCompileOpt) ){
11250 return azCompileOpt[N];
11251 }
11252 return 0;
11253 }
11254
11255 #endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */
11256
11257 /************** End of ctime.c ***********************************************/
11258 /************** Begin file status.c ******************************************/
11259 /*
11260 ** 2008 June 18
11261 **
11262 ** The author disclaims copyright to this source code. In place of
@@ -12996,11 +13383,12 @@
13383 */
13384 static void sqlite3MemFree(void *pPrior){
13385 struct MemBlockHdr *pHdr;
13386 void **pBt;
13387 char *z;
13388 assert( sqlite3GlobalConfig.bMemstat || sqlite3GlobalConfig.bCoreMutex==0
13389 || mem.mutex!=0 );
13390 pHdr = sqlite3MemsysGetHeader(pPrior);
13391 pBt = (void**)pHdr;
13392 pBt -= pHdr->nBacktraceSlots;
13393 sqlite3_mutex_enter(mem.mutex);
13394 if( pHdr->pPrev ){
@@ -15623,11 +16011,13 @@
16011 printf("enter mutex %p (%d) with nRef=%d\n", p, p->trace, p->nRef);
16012 }
16013 #endif
16014 }
16015 static int winMutexTry(sqlite3_mutex *p){
16016 #ifndef NDEBUG
16017 DWORD tid = GetCurrentThreadId();
16018 #endif
16019 int rc = SQLITE_BUSY;
16020 assert( p->id==SQLITE_MUTEX_RECURSIVE || winMutexNotheld2(p, tid) );
16021 /*
16022 ** The sqlite3_mutex_try() routine is very rarely used, and when it
16023 ** is used it is merely an optimization. So it is OK for it to always
@@ -15661,11 +16051,13 @@
16051 ** previously entered by the same thread. The behavior
16052 ** is undefined if the mutex is not currently entered or
16053 ** is not currently allocated. SQLite will never do either.
16054 */
16055 static void winMutexLeave(sqlite3_mutex *p){
16056 #ifndef NDEBUG
16057 DWORD tid = GetCurrentThreadId();
16058 #endif
16059 assert( p->nRef>0 );
16060 assert( p->owner==tid );
16061 p->nRef--;
16062 assert( p->nRef==0 || p->id==SQLITE_MUTEX_RECURSIVE );
16063 LeaveCriticalSection(&p->mutex);
@@ -18422,23 +18814,25 @@
18814 ** Memory to hold the UTF-8 string is obtained from sqlite3_malloc and must
18815 ** be freed by the calling function.
18816 **
18817 ** NULL is returned if there is an allocation error.
18818 */
18819 SQLITE_PRIVATE char *sqlite3Utf16to8(sqlite3 *db, const void *z, int nByte, u8 enc){
18820 Mem m;
18821 memset(&m, 0, sizeof(m));
18822 m.db = db;
18823 sqlite3VdbeMemSetStr(&m, z, nByte, enc, SQLITE_STATIC);
18824 sqlite3VdbeChangeEncoding(&m, SQLITE_UTF8);
18825 if( db->mallocFailed ){
18826 sqlite3VdbeMemRelease(&m);
18827 m.z = 0;
18828 }
18829 assert( (m.flags & MEM_Term)!=0 || db->mallocFailed );
18830 assert( (m.flags & MEM_Str)!=0 || db->mallocFailed );
18831 assert( (m.flags & MEM_Dyn)!=0 || db->mallocFailed );
18832 assert( m.z || db->mallocFailed );
18833 return m.z;
18834 }
18835
18836 /*
18837 ** Convert a UTF-8 string to the UTF-16 encoding specified by parameter
18838 ** enc. A pointer to the new string is returned, and the value of *pnOut
@@ -19236,11 +19630,11 @@
19630 return 2;
19631 }
19632
19633 /* Verify that constants are precomputed correctly */
19634 assert( SLOT_2_0 == ((0x7f<<14) | (0x7f)) );
19635 assert( SLOT_4_2_0 == ((0xfU<<28) | (0x7f<<14) | (0x7f)) );
19636
19637 p++;
19638 a = a<<14;
19639 a |= *p;
19640 /* a: p0<<14 | p2 (unmasked) */
@@ -25761,11 +26155,13 @@
26155 flags |= SQLITE_OPEN_READONLY;
26156 openFlags |= O_RDONLY;
26157 fd = open(zName, openFlags, openMode);
26158 }
26159 if( fd<0 ){
26160 sqlite3_log(SQLITE_CANTOPEN, "cannot open file [%s]: %s", zName,
26161 strerror(errno));
26162 rc = SQLITE_CANTOPEN;
26163 goto open_finished;
26164 }
26165 }
26166 assert( fd>=0 );
26167 if( pOutFlags ){
@@ -33815,10 +34211,13 @@
34211 if( rc==SQLITE_OK ){
34212 zMaster = pPager->pTmpSpace;
34213 rc = readMasterJournal(pPager->jfd, zMaster, pPager->pVfs->mxPathname+1);
34214 testcase( rc!=SQLITE_OK );
34215 }
34216 if( rc==SQLITE_OK && pPager->noSync==0 && pPager->state>=PAGER_EXCLUSIVE ){
34217 rc = sqlite3OsSync(pPager->fd, pPager->sync_flags);
34218 }
34219 if( rc==SQLITE_OK ){
34220 rc = pager_end_transaction(pPager, zMaster[0]!='\0');
34221 testcase( rc!=SQLITE_OK );
34222 }
34223 if( rc==SQLITE_OK && zMaster[0] && res ){
@@ -35135,10 +35534,11 @@
35534 }
35535 /* pPager->xBusyHandler = 0; */
35536 /* pPager->pBusyHandlerArg = 0; */
35537 pPager->xReiniter = xReinit;
35538 /* memset(pPager->aHash, 0, sizeof(pPager->aHash)); */
35539
35540 *ppPager = pPager;
35541 return SQLITE_OK;
35542 }
35543
35544
@@ -35284,12 +35684,28 @@
35684 rc = sqlite3OsRead(pPager->fd, pPg->pData, pPager->pageSize, iOffset);
35685 if( rc==SQLITE_IOERR_SHORT_READ ){
35686 rc = SQLITE_OK;
35687 }
35688 if( pgno==1 ){
35689 if( rc ){
35690 /* If the read is unsuccessful, set the dbFileVers[] to something
35691 ** that will never be a valid file version. dbFileVers[] is a copy
35692 ** of bytes 24..39 of the database. Bytes 28..31 should always be
35693 ** zero. Bytes 32..35 and 35..39 should be page numbers which are
35694 ** never 0xffffffff. So filling pPager->dbFileVers[] with all 0xff
35695 ** bytes should suffice.
35696 **
35697 ** For an encrypted database, the situation is more complex: bytes
35698 ** 24..39 of the database are white noise. But the probability of
35699 ** white noising equaling 16 bytes of 0xff is vanishingly small so
35700 ** we should still be ok.
35701 */
35702 memset(pPager->dbFileVers, 0xff, sizeof(pPager->dbFileVers));
35703 }else{
35704 u8 *dbFileVers = &((u8*)pPg->pData)[24];
35705 memcpy(&pPager->dbFileVers, dbFileVers, sizeof(pPager->dbFileVers));
35706 }
35707 }
35708 CODEC1(pPager, pPg->pData, pgno, 3, rc = SQLITE_NOMEM);
35709
35710 PAGER_INCR(sqlite3_pager_readdb_count);
35711 PAGER_INCR(pPager->nRead);
@@ -36786,10 +37202,11 @@
37202 if( op==SAVEPOINT_RELEASE ){
37203 if( nNew==0 && isOpen(pPager->sjfd) ){
37204 /* Only truncate if it is an in-memory sub-journal. */
37205 if( sqlite3IsMemJournal(pPager->sjfd) ){
37206 rc = sqlite3OsTruncate(pPager->sjfd, 0);
37207 assert( rc==SQLITE_OK );
37208 }
37209 pPager->nSubRec = 0;
37210 }
37211 }
37212 /* Else this is a rollback operation, playback the specified savepoint.
@@ -43199,11 +43616,11 @@
43616 if( nOvfl ){
43617 rc = getOverflowPage(pBt, ovflPgno, &pOvfl, &iNext);
43618 if( rc ) return rc;
43619 }
43620
43621 if( ( pOvfl || ((pOvfl = btreePageLookup(pBt, ovflPgno))!=0) )
43622 && sqlite3PagerPageRefcount(pOvfl->pDbPage)!=1
43623 ){
43624 /* There is no reason any cursor should have an outstanding reference
43625 ** to an overflow page belonging to a cell that is being deleted/updated.
43626 ** So if there exists more than one reference to this page, then it
@@ -43952,11 +44369,11 @@
44369 ** the dropCell() routine will overwrite the entire cell with zeroes.
44370 ** In this case, temporarily copy the cell into the aOvflSpace[]
44371 ** buffer. It will be copied out again as soon as the aSpace[] buffer
44372 ** is allocated. */
44373 if( pBt->secureDelete ){
44374 int iOff = SQLITE_PTR_TO_INT(apDiv[i]) - SQLITE_PTR_TO_INT(pParent->aData);
44375 if( (iOff+szNew[i])>pBt->usableSize ){
44376 rc = SQLITE_CORRUPT_BKPT;
44377 memset(apOld, 0, (i+1)*sizeof(MemPage*));
44378 goto balance_cleanup;
44379 }else{
@@ -47321,11 +47738,11 @@
47738 SQLITE_PRIVATE void sqlite3VdbeMemShallowCopy(Mem *pTo, const Mem *pFrom, int srcType){
47739 assert( (pFrom->flags & MEM_RowSet)==0 );
47740 sqlite3VdbeMemReleaseExternal(pTo);
47741 memcpy(pTo, pFrom, MEMCELLSIZE);
47742 pTo->xDel = 0;
47743 if( (pFrom->flags&MEM_Static)==0 ){
47744 pTo->flags &= ~(MEM_Dyn|MEM_Static|MEM_Ephem);
47745 assert( srcType==MEM_Ephem || srcType==MEM_Static );
47746 pTo->flags |= srcType;
47747 }
47748 }
@@ -49953,16 +50370,21 @@
50370 }
50371
50372 /* If eStatementOp is non-zero, then a statement transaction needs to
50373 ** be committed or rolled back. Call sqlite3VdbeCloseStatement() to
50374 ** do so. If this operation returns an error, and the current statement
50375 ** error code is SQLITE_OK or SQLITE_CONSTRAINT, then promote the
50376 ** current statement error code.
50377 **
50378 ** Note that sqlite3VdbeCloseStatement() can only fail if eStatementOp
50379 ** is SAVEPOINT_ROLLBACK. But if p->rc==SQLITE_OK then eStatementOp
50380 ** must be SAVEPOINT_RELEASE. Hence the NEVER(p->rc==SQLITE_OK) in
50381 ** the following code.
50382 */
50383 if( eStatementOp ){
50384 rc = sqlite3VdbeCloseStatement(p, eStatementOp);
50385 if( rc && (NEVER(p->rc==SQLITE_OK) || p->rc==SQLITE_CONSTRAINT) ){
50386 p->rc = rc;
50387 sqlite3DbFree(db, p->zErrMsg);
50388 p->zErrMsg = 0;
50389 }
50390 }
@@ -52577,21 +52999,34 @@
52999 ** look like a number, leave it alone.
53000 */
53001 static void applyNumericAffinity(Mem *pRec){
53002 if( (pRec->flags & (MEM_Real|MEM_Int))==0 ){
53003 int realnum;
53004 u8 enc = pRec->enc;
53005 sqlite3VdbeMemNulTerminate(pRec);
53006 if( (pRec->flags&MEM_Str) && sqlite3IsNumber(pRec->z, &realnum, enc) ){
 
53007 i64 value;
53008 char *zUtf8 = pRec->z;
53009 #ifndef SQLITE_OMIT_UTF16
53010 if( enc!=SQLITE_UTF8 ){
53011 assert( pRec->db );
53012 zUtf8 = sqlite3Utf16to8(pRec->db, pRec->z, pRec->n, enc);
53013 if( !zUtf8 ) return;
53014 }
53015 #endif
53016 if( !realnum && sqlite3Atoi64(zUtf8, &value) ){
53017 pRec->u.i = value;
53018 MemSetTypeFlag(pRec, MEM_Int);
53019 }else{
53020 sqlite3AtoF(zUtf8, &pRec->r);
53021 MemSetTypeFlag(pRec, MEM_Real);
53022 }
53023 #ifndef SQLITE_OMIT_UTF16
53024 if( enc!=SQLITE_UTF8 ){
53025 sqlite3DbFree(pRec->db, zUtf8);
53026 }
53027 #endif
53028 }
53029 }
53030 }
53031
53032 /*
@@ -53039,10 +53474,12 @@
53474 i64 b;
53475 } ah;
53476 struct OP_Ge_stack_vars {
53477 int res; /* Result of the comparison of pIn1 against pIn3 */
53478 char affinity; /* Affinity to use for comparison */
53479 u16 flags1; /* Copy of initial value of pIn1->flags */
53480 u16 flags3; /* Copy of initial value of pIn3->flags */
53481 } ai;
53482 struct OP_Compare_stack_vars {
53483 int n;
53484 int i;
53485 int p1;
@@ -54573,14 +55010,18 @@
55010 case OP_Gt: /* same as TK_GT, jump, in1, in3 */
55011 case OP_Ge: { /* same as TK_GE, jump, in1, in3 */
55012 #if 0 /* local variables moved into u.ai */
55013 int res; /* Result of the comparison of pIn1 against pIn3 */
55014 char affinity; /* Affinity to use for comparison */
55015 u16 flags1; /* Copy of initial value of pIn1->flags */
55016 u16 flags3; /* Copy of initial value of pIn3->flags */
55017 #endif /* local variables moved into u.ai */
55018
55019 pIn1 = &aMem[pOp->p1];
55020 pIn3 = &aMem[pOp->p3];
55021 u.ai.flags1 = pIn1->flags;
55022 u.ai.flags3 = pIn3->flags;
55023 if( (pIn1->flags | pIn3->flags)&MEM_Null ){
55024 /* One or both operands are NULL */
55025 if( pOp->p5 & SQLITE_NULLEQ ){
55026 /* If SQLITE_NULLEQ is set (which will only happen if the operator is
55027 ** OP_Eq or OP_Ne) then take the jump or not depending on whether
@@ -54631,10 +55072,14 @@
55072 pOut->u.i = u.ai.res;
55073 REGISTER_TRACE(pOp->p2, pOut);
55074 }else if( u.ai.res ){
55075 pc = pOp->p2-1;
55076 }
55077
55078 /* Undo any changes made by applyAffinity() to the input registers. */
55079 pIn1->flags = (pIn1->flags&~MEM_TypeMask) | (u.ai.flags1&MEM_TypeMask);
55080 pIn3->flags = (pIn3->flags&~MEM_TypeMask) | (u.ai.flags3&MEM_TypeMask);
55081 break;
55082 }
55083
55084 /* Opcode: Permutation * * * P4 *
55085 **
@@ -61176,14 +61621,10 @@
61621 p4 = sqlite3BinaryCompareCollSeq(pParse, pLeft, pRight);
61622 p5 = binaryCompareP5(pLeft, pRight, jumpIfNull);
61623 addr = sqlite3VdbeAddOp4(pParse->pVdbe, opcode, in2, dest, in1,
61624 (void*)p4, P4_COLLSEQ);
61625 sqlite3VdbeChangeP5(pParse->pVdbe, (u8)p5);
 
 
 
 
61626 return addr;
61627 }
61628
61629 #if SQLITE_MAX_EXPR_DEPTH>0
61630 /*
@@ -71076,397 +71517,10 @@
71517 }
71518 return p;
71519 }
71520
71521 /************** End of callback.c ********************************************/
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71522 /************** Begin file delete.c ******************************************/
71523 /*
71524 ** 2001 September 15
71525 **
71526 ** The author disclaims copyright to this source code. In place of
@@ -80134,11 +80188,11 @@
80188 *ppStmt = 0;
80189 if( !sqlite3SafetyCheckOk(db) ){
80190 return SQLITE_MISUSE_BKPT;
80191 }
80192 sqlite3_mutex_enter(db->mutex);
80193 zSql8 = sqlite3Utf16to8(db, zSql, nBytes, SQLITE_UTF16NATIVE);
80194 if( zSql8 ){
80195 rc = sqlite3LockAndPrepare(db, zSql8, -1, saveSqlFlag, 0, ppStmt, &zTail8);
80196 }
80197
80198 if( zTail8 && pzTail ){
@@ -97459,11 +97513,11 @@
97513 ){
97514 int rc;
97515 char *zFunc8;
97516 sqlite3_mutex_enter(db->mutex);
97517 assert( !db->mallocFailed );
97518 zFunc8 = sqlite3Utf16to8(db, zFunctionName, -1, SQLITE_UTF16NATIVE);
97519 rc = sqlite3CreateFunc(db, zFunc8, nArg, eTextRep, p, xFunc, xStep, xFinal);
97520 sqlite3DbFree(db, zFunc8);
97521 rc = sqlite3ApiExit(db, rc);
97522 sqlite3_mutex_leave(db->mutex);
97523 return rc;
@@ -98282,11 +98336,11 @@
98336 ){
98337 int rc = SQLITE_OK;
98338 char *zName8;
98339 sqlite3_mutex_enter(db->mutex);
98340 assert( !db->mallocFailed );
98341 zName8 = sqlite3Utf16to8(db, zName, -1, SQLITE_UTF16NATIVE);
98342 if( zName8 ){
98343 rc = createCollation(db, zName8, (u8)enc, SQLITE_COLL_USER, pCtx, xCompare, 0);
98344 sqlite3DbFree(db, zName8);
98345 }
98346 rc = sqlite3ApiExit(db, rc);
@@ -100273,10 +100327,18 @@
100327 p->zDb, p->zName
100328 );
100329 }
100330 return rc;
100331 }
100332
100333 /*
100334 ** An sqlite3_exec() callback for fts3TableExists.
100335 */
100336 static int fts3TableExistsCallback(void *pArg, int n, char **pp1, char **pp2){
100337 *(int*)pArg = 1;
100338 return 1;
100339 }
100340
100341 /*
100342 ** Determine if a table currently exists in the database.
100343 */
100344 static void fts3TableExists(
@@ -100286,14 +100348,21 @@
100348 const char *zName, /* Name of the FTS3 table */
100349 const char *zSuffix, /* Shadow table extension */
100350 u8 *pResult /* Write results here */
100351 ){
100352 int rc = SQLITE_OK;
100353 int res = 0;
100354 char *zSql;
100355 if( *pRc ) return;
100356 zSql = sqlite3_mprintf(
100357 "SELECT 1 FROM %Q.sqlite_master WHERE name='%q%s'",
100358 zDb, zName, zSuffix
100359 );
100360 rc = sqlite3_exec(db, zSql, fts3TableExistsCallback, &res, 0);
100361 sqlite3_free(zSql);
100362 *pResult = res & 0xff;
100363 if( rc!=SQLITE_ABORT ) *pRc = rc;
100364 }
100365
100366 /*
100367 ** This function is the implementation of both the xConnect and xCreate
100368 ** methods of the FTS3 virtual table.
@@ -100711,11 +100780,16 @@
100780 *piPrev = iVal;
100781 }
100782
100783 /*
100784 ** When this function is called, *ppPoslist is assumed to point to the
100785 ** start of a position-list. After it returns, *ppPoslist points to the
100786 ** first byte after the position-list.
100787 **
100788 ** If pp is not NULL, then the contents of the position list are copied
100789 ** to *pp. *pp is set to point to the first byte past the last byte copied
100790 ** before this function returns.
100791 */
100792 static void fts3PoslistCopy(char **pp, char **ppPoslist){
100793 char *pEnd = *ppPoslist;
100794 char c = 0;
100795
@@ -101702,11 +101776,17 @@
101776 }
101777
101778 rc = sqlite3Fts3ExprParse(p->pTokenizer, p->azColumn, p->nColumn,
101779 iCol, zQuery, -1, &pCsr->pExpr
101780 );
101781 if( rc!=SQLITE_OK ){
101782 if( rc==SQLITE_ERROR ){
101783 p->base.zErrMsg = sqlite3_mprintf("malformed MATCH expression: [%s]",
101784 zQuery);
101785 }
101786 return rc;
101787 }
101788
101789 rc = evalFts3Expr(p, pCsr->pExpr, &pCsr->aDoclist, &pCsr->nDoclist, 0);
101790 pCsr->pNextId = pCsr->aDoclist;
101791 pCsr->iPrevId = 0;
101792 }
@@ -101855,11 +101935,13 @@
101935
101936 assert( pCsr );
101937 while( pCsr<pEnd ){
101938 if( pExpr->iCurrent<iDocid ){
101939 fts3PoslistCopy(0, &pCsr);
101940 if( pCsr<pEnd ){
101941 fts3GetDeltaVarint(&pCsr, &pExpr->iCurrent);
101942 }
101943 pExpr->pCurrent = pCsr;
101944 }else{
101945 if( pExpr->iCurrent==iDocid ){
101946 int iThis = 0;
101947 if( iCol<0 ){
@@ -105105,13 +105187,13 @@
105187 /* 3 */ "DELETE FROM %Q.'%q_segments'",
105188 /* 4 */ "DELETE FROM %Q.'%q_segdir'",
105189 /* 5 */ "DELETE FROM %Q.'%q_docsize'",
105190 /* 6 */ "DELETE FROM %Q.'%q_stat'",
105191 /* 7 */ "SELECT * FROM %Q.'%q_content' WHERE rowid=?",
105192 /* 8 */ "SELECT (SELECT max(idx) FROM %Q.'%q_segdir' WHERE level = ?) + 1",
105193 /* 9 */ "INSERT INTO %Q.'%q_segments'(blockid, block) VALUES(?, ?)",
105194 /* 10 */ "SELECT coalesce((SELECT max(blockid) FROM %Q.'%q_segments') + 1, 1)",
105195 /* 11 */ "INSERT INTO %Q.'%q_segdir' VALUES(?,?,?,?,?,?)",
105196
105197 /* Return segments in order from oldest to newest.*/
105198 /* 12 */ "SELECT idx, start_block, leaves_end_block, end_block, root "
105199 "FROM %Q.'%q_segdir' WHERE level = ? ORDER BY idx ASC",
@@ -108666,15 +108748,17 @@
108748 char aBuffer[64];
108749 sqlite3_snprintf(sizeof(aBuffer), aBuffer,
108750 "%d %d %d %d ", iCol, pTerm-sCtx.aTerm, iStart, iEnd-iStart
108751 );
108752 rc = fts3StringAppend(&res, aBuffer, -1);
108753 }else if( rc==SQLITE_DONE ){
108754 rc = SQLITE_CORRUPT;
108755 }
108756 }
108757 }
108758 if( rc==SQLITE_DONE ){
108759 rc = SQLITE_OK;
108760 }
108761
108762 pMod->xClose(pC);
108763 if( rc!=SQLITE_OK ) goto offsets_out;
108764 }
108765
+2 -2
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -105,13 +105,13 @@
105105
**
106106
** See also: [sqlite3_libversion()],
107107
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
108108
** [sqlite_version()] and [sqlite_source_id()].
109109
*/
110
-#define SQLITE_VERSION "3.6.23"
110
+#define SQLITE_VERSION "3.6.23.1"
111111
#define SQLITE_VERSION_NUMBER 3006023
112
-#define SQLITE_SOURCE_ID "2010-03-05 13:53:23 27413fc8dd52b754b4be9344a66bb9e0d752d48e"
112
+#define SQLITE_SOURCE_ID "2010-03-26 22:28:06 b078b588d617e07886ad156e9f54ade6d823568e"
113113
114114
/*
115115
** CAPI3REF: Run-Time Library Version Numbers
116116
** KEYWORDS: sqlite3_version, sqlite3_sourceid
117117
**
118118
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -105,13 +105,13 @@
105 **
106 ** See also: [sqlite3_libversion()],
107 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
108 ** [sqlite_version()] and [sqlite_source_id()].
109 */
110 #define SQLITE_VERSION "3.6.23"
111 #define SQLITE_VERSION_NUMBER 3006023
112 #define SQLITE_SOURCE_ID "2010-03-05 13:53:23 27413fc8dd52b754b4be9344a66bb9e0d752d48e"
113
114 /*
115 ** CAPI3REF: Run-Time Library Version Numbers
116 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
117 **
118
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -105,13 +105,13 @@
105 **
106 ** See also: [sqlite3_libversion()],
107 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
108 ** [sqlite_version()] and [sqlite_source_id()].
109 */
110 #define SQLITE_VERSION "3.6.23.1"
111 #define SQLITE_VERSION_NUMBER 3006023
112 #define SQLITE_SOURCE_ID "2010-03-26 22:28:06 b078b588d617e07886ad156e9f54ade6d823568e"
113
114 /*
115 ** CAPI3REF: Run-Time Library Version Numbers
116 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
117 **
118
--- src/style.c
+++ src/style.c
@@ -407,8 +407,9 @@
407407
#if !defined(__MINGW32__)
408408
@ uid=%d(getuid()), gid=%d(getgid())<br>
409409
#endif
410410
@ g.zBaseURL = %h(g.zBaseURL)<br>
411411
@ g.zTop = %h(g.zTop)<br>
412
+ @ g.zRepositoryName = %h(g.zRepositoryName)<br>
412413
cgi_print_all();
413414
style_footer();
414415
}
415416
--- src/style.c
+++ src/style.c
@@ -407,8 +407,9 @@
407 #if !defined(__MINGW32__)
408 @ uid=%d(getuid()), gid=%d(getgid())<br>
409 #endif
410 @ g.zBaseURL = %h(g.zBaseURL)<br>
411 @ g.zTop = %h(g.zTop)<br>
 
412 cgi_print_all();
413 style_footer();
414 }
415
--- src/style.c
+++ src/style.c
@@ -407,8 +407,9 @@
407 #if !defined(__MINGW32__)
408 @ uid=%d(getuid()), gid=%d(getgid())<br>
409 #endif
410 @ g.zBaseURL = %h(g.zBaseURL)<br>
411 @ g.zTop = %h(g.zTop)<br>
412 @ g.zRepositoryName = %h(g.zRepositoryName)<br>
413 cgi_print_all();
414 style_footer();
415 }
416
+1
--- src/sync.c
+++ src/sync.c
@@ -84,10 +84,11 @@
8484
const char *zPw = 0;
8585
int urlOptional = find_option("autourl",0,0)!=0;
8686
g.dontKeepUrl = find_option("once",0,0)!=0;
8787
url_proxy_options();
8888
db_find_and_open_repository(1);
89
+ db_open_config(0);
8990
if( g.argc==2 ){
9091
zUrl = db_get("last-sync-url", 0);
9192
zPw = db_get("last-sync-pw", 0);
9293
}else if( g.argc==3 ){
9394
zUrl = g.argv[2];
9495
--- src/sync.c
+++ src/sync.c
@@ -84,10 +84,11 @@
84 const char *zPw = 0;
85 int urlOptional = find_option("autourl",0,0)!=0;
86 g.dontKeepUrl = find_option("once",0,0)!=0;
87 url_proxy_options();
88 db_find_and_open_repository(1);
 
89 if( g.argc==2 ){
90 zUrl = db_get("last-sync-url", 0);
91 zPw = db_get("last-sync-pw", 0);
92 }else if( g.argc==3 ){
93 zUrl = g.argv[2];
94
--- src/sync.c
+++ src/sync.c
@@ -84,10 +84,11 @@
84 const char *zPw = 0;
85 int urlOptional = find_option("autourl",0,0)!=0;
86 g.dontKeepUrl = find_option("once",0,0)!=0;
87 url_proxy_options();
88 db_find_and_open_repository(1);
89 db_open_config(0);
90 if( g.argc==2 ){
91 zUrl = db_get("last-sync-url", 0);
92 zPw = db_get("last-sync-pw", 0);
93 }else if( g.argc==3 ){
94 zUrl = g.argv[2];
95
+17 -12
--- src/timeline.c
+++ src/timeline.c
@@ -256,11 +256,11 @@
256256
const char *zBr;
257257
int gidx;
258258
static Stmt qparent;
259259
static Stmt qbranch;
260260
db_static_prepare(&qparent,
261
- "SELECT pid FROM plink WHERE cid=:rid ORDER BY isprim DESC"
261
+ "SELECT pid FROM plink WHERE cid=:rid ORDER BY isprim DESC /*sort*/"
262262
);
263263
db_static_prepare(&qbranch,
264264
"SELECT value FROM tagxref WHERE tagid=%d AND tagtype>0 AND rid=:rid",
265265
TAG_BRANCH
266266
);
@@ -407,18 +407,18 @@
407407
@ var n = document.createElement("div");
408408
@ if( x0>x1 ){ var t=x0; x0=x1; x1=t; }
409409
@ if( y0>y1 ){ var t=y0; y0=y1; y1=t; }
410410
@ var w = x1-x0+1;
411411
@ var h = y1-y0+1;
412
- @ canvasDiv.appendChild(n);
413412
@ n.style.position = "absolute";
414413
@ n.style.overflow = "hidden";
415414
@ n.style.left = x0+"px";
416415
@ n.style.top = y0+"px";
417416
@ n.style.width = w+"px";
418417
@ n.style.height = h+"px";
419418
@ n.style.backgroundColor = color;
419
+ @ canvasDiv.appendChild(n);
420420
@ }
421421
@ function absoluteY(id){
422422
@ var obj = document.getElementById(id);
423423
@ if( !obj ) return;
424424
@ var top = 0;
@@ -512,18 +512,23 @@
512512
@ for(var i in rowinfo){
513513
@ rowinfo[i].y = absoluteY(rowinfo[i].id) + 10 - canvasY;
514514
@ rowinfo[i].x = left + rowinfo[i].r*20;
515515
@ }
516516
@ var btm = rowinfo[rowinfo.length-1].y + 20;
517
- @ canvasDiv.innerHTML = '<canvas id="timeline-canvas" '+
518
- @ 'style="position:absolute;left:'+(left-5)+'px;"' +
519
- @ ' width="'+width+'" height="'+btm+'"></canvas>';
520
- @ realCanvas = document.getElementById('timeline-canvas');
517
+ @ if( btm<32768 ){
518
+ @ canvasDiv.innerHTML = '<canvas id="timeline-canvas" '+
519
+ @ 'style="position:absolute;left:'+(left-5)+'px;"' +
520
+ @ ' width="'+width+'" height="'+btm+'"></canvas>';
521
+ @ realCanvas = document.getElementById('timeline-canvas');
522
+ @ }else{
523
+ @ realCanvas = 0;
524
+ @ }
521525
@ var context;
522526
@ if( realCanvas && realCanvas.getContext
523527
@ && (context = realCanvas.getContext('2d'))) {
524528
@ drawBox = function(color,x0,y0,x1,y1) {
529
+ @ if( y0>32767 || y1>32767 ) return;
525530
@ var colors = {
526531
@ 'white':'rgba(255,255,255,1)',
527532
@ 'black':'rgba(0,0,0,1)'
528533
@ };
529534
@ if( x0>x1 ){ var t=x0; x0=x1; x1=t; }
@@ -675,12 +680,12 @@
675680
void page_timeline(void){
676681
Stmt q; /* Query used to generate the timeline */
677682
Blob sql; /* text of SQL used to generate timeline */
678683
Blob desc; /* Description of the timeline */
679684
int nEntry = atoi(PD("n","20")); /* Max number of entries on timeline */
680
- int p_rid = atoi(PD("p","0")); /* artifact p and its parents */
681
- int d_rid = atoi(PD("d","0")); /* artifact d and its descendants */
685
+ int p_rid = name_to_rid(P("p")); /* artifact p and its parents */
686
+ int d_rid = name_to_rid(P("d")); /* artifact d and its descendants */
682687
const char *zUser = P("u"); /* All entries by this user if not NULL */
683688
const char *zType = PD("y","all"); /* Type of events. All if NULL */
684689
const char *zAfter = P("a"); /* Events after this time */
685690
const char *zBefore = P("b"); /* Events before this time */
686691
const char *zCirca = P("c"); /* Events near this time */
@@ -871,11 +876,11 @@
871876
blob_appendf(&sql, " ORDER BY event.mtime DESC");
872877
}
873878
blob_appendf(&sql, " LIMIT %d", nEntry);
874879
db_multi_exec("%s", blob_str(&sql));
875880
876
- n = db_int(0, "SELECT count(*) FROM timeline");
881
+ n = db_int(0, "SELECT count(*) FROM timeline /*scan*/");
877882
if( n<nEntry && zAfter ){
878883
cgi_redirect(url_render(&url, "a", 0, "b", 0));
879884
}
880885
if( zAfter==0 && zBefore==0 && zCirca==0 ){
881886
blob_appendf(&desc, "%d most recent %ss", n, zEType);
@@ -900,16 +905,16 @@
900905
if( zSearch ){
901906
blob_appendf(&desc, " matching \"%h\"", zSearch);
902907
}
903908
if( g.okHistory ){
904909
if( zAfter || n==nEntry ){
905
- zDate = db_text(0, "SELECT min(timestamp) FROM timeline");
910
+ zDate = db_text(0, "SELECT min(timestamp) FROM timeline /*scan*/");
906911
timeline_submenu(&url, "Older", "b", zDate, "a");
907912
free(zDate);
908913
}
909914
if( zBefore || (zAfter && n==nEntry) ){
910
- zDate = db_text(0, "SELECT max(timestamp) FROM timeline");
915
+ zDate = db_text(0, "SELECT max(timestamp) FROM timeline /*scan*/");
911916
timeline_submenu(&url, "Newer", "a", zDate, "b");
912917
free(zDate);
913918
}else if( tagid==0 ){
914919
if( zType[0]!='a' ){
915920
timeline_submenu(&url, "All Types", "y", "all", 0);
@@ -931,11 +936,11 @@
931936
timeline_submenu(&url, "200 Events", "n", "200", 0);
932937
}
933938
}
934939
}
935940
blob_zero(&sql);
936
- db_prepare(&q, "SELECT * FROM timeline ORDER BY timestamp DESC");
941
+ db_prepare(&q, "SELECT * FROM timeline ORDER BY timestamp DESC /*scan*/");
937942
@ <h2>%b(&desc)</h2>
938943
blob_reset(&desc);
939944
www_print_timeline(&q, tmFlags, 0);
940945
db_finalize(&q);
941946
style_footer();
942947
--- src/timeline.c
+++ src/timeline.c
@@ -256,11 +256,11 @@
256 const char *zBr;
257 int gidx;
258 static Stmt qparent;
259 static Stmt qbranch;
260 db_static_prepare(&qparent,
261 "SELECT pid FROM plink WHERE cid=:rid ORDER BY isprim DESC"
262 );
263 db_static_prepare(&qbranch,
264 "SELECT value FROM tagxref WHERE tagid=%d AND tagtype>0 AND rid=:rid",
265 TAG_BRANCH
266 );
@@ -407,18 +407,18 @@
407 @ var n = document.createElement("div");
408 @ if( x0>x1 ){ var t=x0; x0=x1; x1=t; }
409 @ if( y0>y1 ){ var t=y0; y0=y1; y1=t; }
410 @ var w = x1-x0+1;
411 @ var h = y1-y0+1;
412 @ canvasDiv.appendChild(n);
413 @ n.style.position = "absolute";
414 @ n.style.overflow = "hidden";
415 @ n.style.left = x0+"px";
416 @ n.style.top = y0+"px";
417 @ n.style.width = w+"px";
418 @ n.style.height = h+"px";
419 @ n.style.backgroundColor = color;
 
420 @ }
421 @ function absoluteY(id){
422 @ var obj = document.getElementById(id);
423 @ if( !obj ) return;
424 @ var top = 0;
@@ -512,18 +512,23 @@
512 @ for(var i in rowinfo){
513 @ rowinfo[i].y = absoluteY(rowinfo[i].id) + 10 - canvasY;
514 @ rowinfo[i].x = left + rowinfo[i].r*20;
515 @ }
516 @ var btm = rowinfo[rowinfo.length-1].y + 20;
517 @ canvasDiv.innerHTML = '<canvas id="timeline-canvas" '+
518 @ 'style="position:absolute;left:'+(left-5)+'px;"' +
519 @ ' width="'+width+'" height="'+btm+'"></canvas>';
520 @ realCanvas = document.getElementById('timeline-canvas');
 
 
 
 
521 @ var context;
522 @ if( realCanvas && realCanvas.getContext
523 @ && (context = realCanvas.getContext('2d'))) {
524 @ drawBox = function(color,x0,y0,x1,y1) {
 
525 @ var colors = {
526 @ 'white':'rgba(255,255,255,1)',
527 @ 'black':'rgba(0,0,0,1)'
528 @ };
529 @ if( x0>x1 ){ var t=x0; x0=x1; x1=t; }
@@ -675,12 +680,12 @@
675 void page_timeline(void){
676 Stmt q; /* Query used to generate the timeline */
677 Blob sql; /* text of SQL used to generate timeline */
678 Blob desc; /* Description of the timeline */
679 int nEntry = atoi(PD("n","20")); /* Max number of entries on timeline */
680 int p_rid = atoi(PD("p","0")); /* artifact p and its parents */
681 int d_rid = atoi(PD("d","0")); /* artifact d and its descendants */
682 const char *zUser = P("u"); /* All entries by this user if not NULL */
683 const char *zType = PD("y","all"); /* Type of events. All if NULL */
684 const char *zAfter = P("a"); /* Events after this time */
685 const char *zBefore = P("b"); /* Events before this time */
686 const char *zCirca = P("c"); /* Events near this time */
@@ -871,11 +876,11 @@
871 blob_appendf(&sql, " ORDER BY event.mtime DESC");
872 }
873 blob_appendf(&sql, " LIMIT %d", nEntry);
874 db_multi_exec("%s", blob_str(&sql));
875
876 n = db_int(0, "SELECT count(*) FROM timeline");
877 if( n<nEntry && zAfter ){
878 cgi_redirect(url_render(&url, "a", 0, "b", 0));
879 }
880 if( zAfter==0 && zBefore==0 && zCirca==0 ){
881 blob_appendf(&desc, "%d most recent %ss", n, zEType);
@@ -900,16 +905,16 @@
900 if( zSearch ){
901 blob_appendf(&desc, " matching \"%h\"", zSearch);
902 }
903 if( g.okHistory ){
904 if( zAfter || n==nEntry ){
905 zDate = db_text(0, "SELECT min(timestamp) FROM timeline");
906 timeline_submenu(&url, "Older", "b", zDate, "a");
907 free(zDate);
908 }
909 if( zBefore || (zAfter && n==nEntry) ){
910 zDate = db_text(0, "SELECT max(timestamp) FROM timeline");
911 timeline_submenu(&url, "Newer", "a", zDate, "b");
912 free(zDate);
913 }else if( tagid==0 ){
914 if( zType[0]!='a' ){
915 timeline_submenu(&url, "All Types", "y", "all", 0);
@@ -931,11 +936,11 @@
931 timeline_submenu(&url, "200 Events", "n", "200", 0);
932 }
933 }
934 }
935 blob_zero(&sql);
936 db_prepare(&q, "SELECT * FROM timeline ORDER BY timestamp DESC");
937 @ <h2>%b(&desc)</h2>
938 blob_reset(&desc);
939 www_print_timeline(&q, tmFlags, 0);
940 db_finalize(&q);
941 style_footer();
942
--- src/timeline.c
+++ src/timeline.c
@@ -256,11 +256,11 @@
256 const char *zBr;
257 int gidx;
258 static Stmt qparent;
259 static Stmt qbranch;
260 db_static_prepare(&qparent,
261 "SELECT pid FROM plink WHERE cid=:rid ORDER BY isprim DESC /*sort*/"
262 );
263 db_static_prepare(&qbranch,
264 "SELECT value FROM tagxref WHERE tagid=%d AND tagtype>0 AND rid=:rid",
265 TAG_BRANCH
266 );
@@ -407,18 +407,18 @@
407 @ var n = document.createElement("div");
408 @ if( x0>x1 ){ var t=x0; x0=x1; x1=t; }
409 @ if( y0>y1 ){ var t=y0; y0=y1; y1=t; }
410 @ var w = x1-x0+1;
411 @ var h = y1-y0+1;
 
412 @ n.style.position = "absolute";
413 @ n.style.overflow = "hidden";
414 @ n.style.left = x0+"px";
415 @ n.style.top = y0+"px";
416 @ n.style.width = w+"px";
417 @ n.style.height = h+"px";
418 @ n.style.backgroundColor = color;
419 @ canvasDiv.appendChild(n);
420 @ }
421 @ function absoluteY(id){
422 @ var obj = document.getElementById(id);
423 @ if( !obj ) return;
424 @ var top = 0;
@@ -512,18 +512,23 @@
512 @ for(var i in rowinfo){
513 @ rowinfo[i].y = absoluteY(rowinfo[i].id) + 10 - canvasY;
514 @ rowinfo[i].x = left + rowinfo[i].r*20;
515 @ }
516 @ var btm = rowinfo[rowinfo.length-1].y + 20;
517 @ if( btm<32768 ){
518 @ canvasDiv.innerHTML = '<canvas id="timeline-canvas" '+
519 @ 'style="position:absolute;left:'+(left-5)+'px;"' +
520 @ ' width="'+width+'" height="'+btm+'"></canvas>';
521 @ realCanvas = document.getElementById('timeline-canvas');
522 @ }else{
523 @ realCanvas = 0;
524 @ }
525 @ var context;
526 @ if( realCanvas && realCanvas.getContext
527 @ && (context = realCanvas.getContext('2d'))) {
528 @ drawBox = function(color,x0,y0,x1,y1) {
529 @ if( y0>32767 || y1>32767 ) return;
530 @ var colors = {
531 @ 'white':'rgba(255,255,255,1)',
532 @ 'black':'rgba(0,0,0,1)'
533 @ };
534 @ if( x0>x1 ){ var t=x0; x0=x1; x1=t; }
@@ -675,12 +680,12 @@
680 void page_timeline(void){
681 Stmt q; /* Query used to generate the timeline */
682 Blob sql; /* text of SQL used to generate timeline */
683 Blob desc; /* Description of the timeline */
684 int nEntry = atoi(PD("n","20")); /* Max number of entries on timeline */
685 int p_rid = name_to_rid(P("p")); /* artifact p and its parents */
686 int d_rid = name_to_rid(P("d")); /* artifact d and its descendants */
687 const char *zUser = P("u"); /* All entries by this user if not NULL */
688 const char *zType = PD("y","all"); /* Type of events. All if NULL */
689 const char *zAfter = P("a"); /* Events after this time */
690 const char *zBefore = P("b"); /* Events before this time */
691 const char *zCirca = P("c"); /* Events near this time */
@@ -871,11 +876,11 @@
876 blob_appendf(&sql, " ORDER BY event.mtime DESC");
877 }
878 blob_appendf(&sql, " LIMIT %d", nEntry);
879 db_multi_exec("%s", blob_str(&sql));
880
881 n = db_int(0, "SELECT count(*) FROM timeline /*scan*/");
882 if( n<nEntry && zAfter ){
883 cgi_redirect(url_render(&url, "a", 0, "b", 0));
884 }
885 if( zAfter==0 && zBefore==0 && zCirca==0 ){
886 blob_appendf(&desc, "%d most recent %ss", n, zEType);
@@ -900,16 +905,16 @@
905 if( zSearch ){
906 blob_appendf(&desc, " matching \"%h\"", zSearch);
907 }
908 if( g.okHistory ){
909 if( zAfter || n==nEntry ){
910 zDate = db_text(0, "SELECT min(timestamp) FROM timeline /*scan*/");
911 timeline_submenu(&url, "Older", "b", zDate, "a");
912 free(zDate);
913 }
914 if( zBefore || (zAfter && n==nEntry) ){
915 zDate = db_text(0, "SELECT max(timestamp) FROM timeline /*scan*/");
916 timeline_submenu(&url, "Newer", "a", zDate, "b");
917 free(zDate);
918 }else if( tagid==0 ){
919 if( zType[0]!='a' ){
920 timeline_submenu(&url, "All Types", "y", "all", 0);
@@ -931,11 +936,11 @@
936 timeline_submenu(&url, "200 Events", "n", "200", 0);
937 }
938 }
939 }
940 blob_zero(&sql);
941 db_prepare(&q, "SELECT * FROM timeline ORDER BY timestamp DESC /*scan*/");
942 @ <h2>%b(&desc)</h2>
943 blob_reset(&desc);
944 www_print_timeline(&q, tmFlags, 0);
945 db_finalize(&q);
946 style_footer();
947
+2 -2
--- src/vfile.c
+++ src/vfile.c
@@ -324,11 +324,11 @@
324324
325325
db_must_be_within_tree();
326326
db_prepare(&q,
327327
"SELECT %Q || pathname, pathname, file_is_selected(id), rid FROM vfile"
328328
" WHERE NOT deleted AND vid=%d"
329
- " ORDER BY pathname",
329
+ " ORDER BY pathname /*scan*/",
330330
g.zLocalRoot, vid
331331
);
332332
md5sum_init();
333333
while( db_step(&q)==SQLITE_ROW ){
334334
const char *zFullpath = db_column_text(&q, 0);
@@ -386,11 +386,11 @@
386386
387387
db_must_be_within_tree();
388388
389389
db_prepare(&q, "SELECT pathname, rid FROM vfile"
390390
" WHERE NOT deleted AND rid>0 AND vid=%d"
391
- " ORDER BY pathname",
391
+ " ORDER BY pathname /*scan*/",
392392
vid);
393393
blob_zero(&file);
394394
md5sum_init();
395395
while( db_step(&q)==SQLITE_ROW ){
396396
const char *zName = db_column_text(&q, 0);
397397
--- src/vfile.c
+++ src/vfile.c
@@ -324,11 +324,11 @@
324
325 db_must_be_within_tree();
326 db_prepare(&q,
327 "SELECT %Q || pathname, pathname, file_is_selected(id), rid FROM vfile"
328 " WHERE NOT deleted AND vid=%d"
329 " ORDER BY pathname",
330 g.zLocalRoot, vid
331 );
332 md5sum_init();
333 while( db_step(&q)==SQLITE_ROW ){
334 const char *zFullpath = db_column_text(&q, 0);
@@ -386,11 +386,11 @@
386
387 db_must_be_within_tree();
388
389 db_prepare(&q, "SELECT pathname, rid FROM vfile"
390 " WHERE NOT deleted AND rid>0 AND vid=%d"
391 " ORDER BY pathname",
392 vid);
393 blob_zero(&file);
394 md5sum_init();
395 while( db_step(&q)==SQLITE_ROW ){
396 const char *zName = db_column_text(&q, 0);
397
--- src/vfile.c
+++ src/vfile.c
@@ -324,11 +324,11 @@
324
325 db_must_be_within_tree();
326 db_prepare(&q,
327 "SELECT %Q || pathname, pathname, file_is_selected(id), rid FROM vfile"
328 " WHERE NOT deleted AND vid=%d"
329 " ORDER BY pathname /*scan*/",
330 g.zLocalRoot, vid
331 );
332 md5sum_init();
333 while( db_step(&q)==SQLITE_ROW ){
334 const char *zFullpath = db_column_text(&q, 0);
@@ -386,11 +386,11 @@
386
387 db_must_be_within_tree();
388
389 db_prepare(&q, "SELECT pathname, rid FROM vfile"
390 " WHERE NOT deleted AND rid>0 AND vid=%d"
391 " ORDER BY pathname /*scan*/",
392 vid);
393 blob_zero(&file);
394 md5sum_init();
395 while( db_step(&q)==SQLITE_ROW ){
396 const char *zName = db_column_text(&q, 0);
397
+4 -3
--- src/wiki.c
+++ src/wiki.c
@@ -672,11 +672,11 @@
672672
db_prepare(&q,
673673
"SELECT"
674674
" substr(tagname, 6),"
675675
" (SELECT value FROM tagxref WHERE tagid=tag.tagid ORDER BY mtime DESC)"
676676
" FROM tag WHERE tagname GLOB 'wiki-*'"
677
- " ORDER BY lower(tagname)"
677
+ " ORDER BY lower(tagname) /*sort*/"
678678
);
679679
while( db_step(&q)==SQLITE_ROW ){
680680
const char *zName = db_column_text(&q, 0);
681681
int size = db_column_int(&q, 1);
682682
if( size>0 ){
@@ -703,11 +703,12 @@
703703
if( !g.okRdWiki ){ login_needed(); return; }
704704
zTitle = PD("title","*");
705705
style_header("Wiki Pages Found");
706706
@ <ul>
707707
db_prepare(&q,
708
- "SELECT substr(tagname, 6, 1000) FROM tag WHERE tagname like 'wiki-%%%q%%' ORDER BY lower(tagname)" ,
708
+ "SELECT substr(tagname, 6, 1000) FROM tag WHERE tagname like 'wiki-%%%q%%'"
709
+ " ORDER BY lower(tagname) /*sort*/" ,
709710
zTitle);
710711
while( db_step(&q)==SQLITE_ROW ){
711712
const char *zName = db_column_text(&q, 0);
712713
@ <li><a href="%s(g.zBaseURL)/wiki?name=%T(zName)">%h(zName)</a></li>
713714
}
@@ -1027,11 +1028,11 @@
10271028
}else
10281029
if( strncmp(g.argv[2],"list",n)==0 ){
10291030
Stmt q;
10301031
db_prepare(&q,
10311032
"SELECT substr(tagname, 6) FROM tag WHERE tagname GLOB 'wiki-*'"
1032
- " ORDER BY lower(tagname)"
1033
+ " ORDER BY lower(tagname) /*sort*/"
10331034
);
10341035
while( db_step(&q)==SQLITE_ROW ){
10351036
const char *zName = db_column_text(&q, 0);
10361037
printf( "%s\n",zName);
10371038
}
10381039
--- src/wiki.c
+++ src/wiki.c
@@ -672,11 +672,11 @@
672 db_prepare(&q,
673 "SELECT"
674 " substr(tagname, 6),"
675 " (SELECT value FROM tagxref WHERE tagid=tag.tagid ORDER BY mtime DESC)"
676 " FROM tag WHERE tagname GLOB 'wiki-*'"
677 " ORDER BY lower(tagname)"
678 );
679 while( db_step(&q)==SQLITE_ROW ){
680 const char *zName = db_column_text(&q, 0);
681 int size = db_column_int(&q, 1);
682 if( size>0 ){
@@ -703,11 +703,12 @@
703 if( !g.okRdWiki ){ login_needed(); return; }
704 zTitle = PD("title","*");
705 style_header("Wiki Pages Found");
706 @ <ul>
707 db_prepare(&q,
708 "SELECT substr(tagname, 6, 1000) FROM tag WHERE tagname like 'wiki-%%%q%%' ORDER BY lower(tagname)" ,
 
709 zTitle);
710 while( db_step(&q)==SQLITE_ROW ){
711 const char *zName = db_column_text(&q, 0);
712 @ <li><a href="%s(g.zBaseURL)/wiki?name=%T(zName)">%h(zName)</a></li>
713 }
@@ -1027,11 +1028,11 @@
1027 }else
1028 if( strncmp(g.argv[2],"list",n)==0 ){
1029 Stmt q;
1030 db_prepare(&q,
1031 "SELECT substr(tagname, 6) FROM tag WHERE tagname GLOB 'wiki-*'"
1032 " ORDER BY lower(tagname)"
1033 );
1034 while( db_step(&q)==SQLITE_ROW ){
1035 const char *zName = db_column_text(&q, 0);
1036 printf( "%s\n",zName);
1037 }
1038
--- src/wiki.c
+++ src/wiki.c
@@ -672,11 +672,11 @@
672 db_prepare(&q,
673 "SELECT"
674 " substr(tagname, 6),"
675 " (SELECT value FROM tagxref WHERE tagid=tag.tagid ORDER BY mtime DESC)"
676 " FROM tag WHERE tagname GLOB 'wiki-*'"
677 " ORDER BY lower(tagname) /*sort*/"
678 );
679 while( db_step(&q)==SQLITE_ROW ){
680 const char *zName = db_column_text(&q, 0);
681 int size = db_column_int(&q, 1);
682 if( size>0 ){
@@ -703,11 +703,12 @@
703 if( !g.okRdWiki ){ login_needed(); return; }
704 zTitle = PD("title","*");
705 style_header("Wiki Pages Found");
706 @ <ul>
707 db_prepare(&q,
708 "SELECT substr(tagname, 6, 1000) FROM tag WHERE tagname like 'wiki-%%%q%%'"
709 " ORDER BY lower(tagname) /*sort*/" ,
710 zTitle);
711 while( db_step(&q)==SQLITE_ROW ){
712 const char *zName = db_column_text(&q, 0);
713 @ <li><a href="%s(g.zBaseURL)/wiki?name=%T(zName)">%h(zName)</a></li>
714 }
@@ -1027,11 +1028,11 @@
1028 }else
1029 if( strncmp(g.argv[2],"list",n)==0 ){
1030 Stmt q;
1031 db_prepare(&q,
1032 "SELECT substr(tagname, 6) FROM tag WHERE tagname GLOB 'wiki-*'"
1033 " ORDER BY lower(tagname) /*sort*/"
1034 );
1035 while( db_step(&q)==SQLITE_ROW ){
1036 const char *zName = db_column_text(&q, 0);
1037 printf( "%s\n",zName);
1038 }
1039
--- www/custom_ticket.wiki
+++ www/custom_ticket.wiki
@@ -24,16 +24,19 @@
2424
<h2>Next add assignees</h2><blockquote>
2525
<p>
2626
Back to the "Tickets" admin page, and click "Common". Add something like this:
2727
<pre>
2828
set assigned_choices {
29
+ unassigned
2930
tom
3031
dick
3132
harriet
3233
}
3334
</pre>
34
-Obviously, choose names corresponding to the logins on your system.
35
+Obviously, choose names corresponding to the logins on your system. The
36
+'unassigned' entry is important, as it prevents you from having a NULL in that
37
+field (which causes problems later when editing).
3538
</p>
3639
</blockquote>
3740
3841
<h2>Now modify the 'new ticket' page</h2><blockquote>
3942
<p>
@@ -41,10 +44,11 @@
4144
more tricky. Edit the top part:
4245
<pre>
4346
if {[info exists submit]} {
4447
set status Open
4548
set opened_by $login
49
+ set assigned_to "unassigned"
4650
submit_ticket
4751
}
4852
</pre>
4953
Note the "set opened_by" bit -- that will automatically set the "opened_by"
5054
field to the login name of the bug reporter. Now, skip to the part with "EMail"
5155
--- www/custom_ticket.wiki
+++ www/custom_ticket.wiki
@@ -24,16 +24,19 @@
24 <h2>Next add assignees</h2><blockquote>
25 <p>
26 Back to the "Tickets" admin page, and click "Common". Add something like this:
27 <pre>
28 set assigned_choices {
 
29 tom
30 dick
31 harriet
32 }
33 </pre>
34 Obviously, choose names corresponding to the logins on your system.
 
 
35 </p>
36 </blockquote>
37
38 <h2>Now modify the 'new ticket' page</h2><blockquote>
39 <p>
@@ -41,10 +44,11 @@
41 more tricky. Edit the top part:
42 <pre>
43 if {[info exists submit]} {
44 set status Open
45 set opened_by $login
 
46 submit_ticket
47 }
48 </pre>
49 Note the "set opened_by" bit -- that will automatically set the "opened_by"
50 field to the login name of the bug reporter. Now, skip to the part with "EMail"
51
--- www/custom_ticket.wiki
+++ www/custom_ticket.wiki
@@ -24,16 +24,19 @@
24 <h2>Next add assignees</h2><blockquote>
25 <p>
26 Back to the "Tickets" admin page, and click "Common". Add something like this:
27 <pre>
28 set assigned_choices {
29 unassigned
30 tom
31 dick
32 harriet
33 }
34 </pre>
35 Obviously, choose names corresponding to the logins on your system. The
36 'unassigned' entry is important, as it prevents you from having a NULL in that
37 field (which causes problems later when editing).
38 </p>
39 </blockquote>
40
41 <h2>Now modify the 'new ticket' page</h2><blockquote>
42 <p>
@@ -41,10 +44,11 @@
44 more tricky. Edit the top part:
45 <pre>
46 if {[info exists submit]} {
47 set status Open
48 set opened_by $login
49 set assigned_to "unassigned"
50 submit_ticket
51 }
52 </pre>
53 Note the "set opened_by" bit -- that will automatically set the "opened_by"
54 field to the login name of the bug reporter. Now, skip to the part with "EMail"
55

Keyboard Shortcuts

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