Overview
SHA1 Hash: | 02920e92b50bdafc72937ee38277829f98ab2c43 |
---|---|
Date: | 2009-12-18 22:16:55 |
User: | drh |
Comment: | Minor cleanup to the implementation of command-line "timeline". |
Timelines: | ancestors | descendants | both | trunk |
Other Links: | files | ZIP archive | manifest |
Tags And Properties
- branch=trunk inherited from [a28c83647d]
- sym-trunk inherited from [a28c83647d]
Changes
[hide diffs]Modified src/timeline.c from [f76d6fc0d6] to [fd4ec7f2dc].
@@ -894,11 +894,11 @@ int n, k; const char *zCount; const char *zType; char *zOrigin; char *zDate; - char *zSQL; + Blob sql; int objid = 0; Blob uuid; int mode = 0 ; /* 0:none 1: before 2:after 3:children 4:parents */ db_find_and_open_repository(1); zCount = find_option("count","n",1); @@ -961,31 +961,33 @@ if( isIsoDate(zOrigin) ) zShift = ",'+1 day'"; } zDate = mprintf("(SELECT julianday(%Q%s, 'utc'))", zOrigin, zShift); } if( mode==0 ) mode = 1; - zSQL = mprintf("%z AND event.mtime %s %s", - timeline_query_for_tty_m(), + blob_zero(&sql); + blob_append(&sql, timeline_query_for_tty(), -1); + blob_appendf(&sql, " AND event.mtime %s %s", (mode==1 || mode==4) ? "<=" : ">=", zDate ); + if( mode==3 || mode==4 ){ db_multi_exec("CREATE TEMP TABLE ok(rid INTEGER PRIMARY KEY)"); if( mode==3 ){ compute_descendants(objid, n); }else{ compute_ancestors(objid, n); } - zSQL = mprintf("%z AND blob.rid IN ok", zSQL); + blob_appendf(&sql, " AND blob.rid IN ok"); } if( zType && (zType[0]!='a') ){ - zSQL = mprintf( "%z AND event.type=%Q ", zSQL, zType); + blob_appendf(&sql, " AND event.type=%Q ", zType); } - zSQL = mprintf("%z ORDER BY event.mtime DESC", zSQL); - db_prepare(&q, zSQL); - free( zSQL ); + blob_appendf(&sql, " ORDER BY event.mtime DESC"); + db_prepare(&q, blob_str(&sql)); + blob_reset(&sql); print_timeline(&q, n); db_finalize(&q); } /*