Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Ticket enhancements: Add the TICKET.TKT_CTIME field and make it hold the creation time of the ticket. Make sure that a TICKETCHNG entry is created for each change to the ticket if the TICKETCHNG.TKT_RID field exists. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
8554d3e6569c434609b01f87c5003a53 |
| User & Date: | drh 2013-01-15 03:02:20.339 |
Context
|
2013-01-15
| ||
| 10:15 | Eliminate "continue" statement, makes control flow easier to understand. If we already know a character is non-ASCII, don't need to check for '\\' any more. ... (check-in: 886e1bb2a8 user: jan.nijtmans tags: trunk) | |
| 10:03 | merge trunk ... (check-in: 9a88d1963f user: jan.nijtmans tags: allow-backslash-in-card-filename) | |
| 03:02 | Ticket enhancements: Add the TICKET.TKT_CTIME field and make it hold the creation time of the ticket. Make sure that a TICKETCHNG entry is created for each change to the ticket if the TICKETCHNG.TKT_RID field exists. ... (check-in: 8554d3e656 user: drh tags: trunk) | |
| 02:29 | Fix compiler warnings. ... (check-in: b3bac1158b user: drh tags: trunk) | |
Changes
Changes to src/schema.c.
| ︙ | ︙ | |||
383 384 385 386 387 388 389 390 391 392 393 394 395 396 | @ -- same change in tktsetup.c. @ -- @ CREATE TABLE ticket( @ -- Do not change any column that begins with tkt_ @ tkt_id INTEGER PRIMARY KEY, @ tkt_uuid TEXT UNIQUE, @ tkt_mtime DATE, @ -- Add as many field as required below this line @ type TEXT, @ status TEXT, @ subsystem TEXT, @ priority TEXT, @ severity TEXT, @ foundin TEXT, | > | 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 | @ -- same change in tktsetup.c. @ -- @ CREATE TABLE ticket( @ -- Do not change any column that begins with tkt_ @ tkt_id INTEGER PRIMARY KEY, @ tkt_uuid TEXT UNIQUE, @ tkt_mtime DATE, @ tkt_ctime DATE, @ -- Add as many field as required below this line @ type TEXT, @ status TEXT, @ subsystem TEXT, @ priority TEXT, @ severity TEXT, @ foundin TEXT, |
| ︙ | ︙ |
Changes to src/tkt.c.
| ︙ | ︙ | |||
33 34 35 36 37 38 39 | char *zValue; /* Value to store */ char *zAppend; /* Value to append */ unsigned mUsed; /* 01: TICKET 02: TICKETCHNG */ } *aField; #define USEDBY_TICKET 01 #define USEDBY_TICKETCHNG 02 #define USEDBY_BOTH 03 | | > | | | 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
char *zValue; /* Value to store */
char *zAppend; /* Value to append */
unsigned mUsed; /* 01: TICKET 02: TICKETCHNG */
} *aField;
#define USEDBY_TICKET 01
#define USEDBY_TICKETCHNG 02
#define USEDBY_BOTH 03
static u8 haveTicket = 0; /* True if the TICKET table exists */
static u8 haveTicketCTime = 0; /* True if TICKET.TKT_CTIME exists */
static u8 haveTicketChng = 0; /* True if the TICKETCHNG table exists */
static u8 haveTicketChngRid = 0; /* True if TICKETCHNG.TKT_RID exists */
/*
** Compare two entries in aField[] for sorting purposes
*/
static int nameCmpr(const void *a, const void *b){
return fossil_strcmp(((const struct tktFieldInfo*)a)->zName,
((const struct tktFieldInfo*)b)->zName);
|
| ︙ | ︙ | |||
74 75 76 77 78 79 80 |
static int once = 0;
if( once ) return;
once = 1;
db_prepare(&q, "PRAGMA table_info(ticket)");
while( db_step(&q)==SQLITE_ROW ){
const char *zFieldName = db_column_text(&q, 1);
haveTicket = 1;
| | > > > > | | > | 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
static int once = 0;
if( once ) return;
once = 1;
db_prepare(&q, "PRAGMA table_info(ticket)");
while( db_step(&q)==SQLITE_ROW ){
const char *zFieldName = db_column_text(&q, 1);
haveTicket = 1;
if( memcmp(zFieldName,"tkt_",4)==0 ){
if( strcmp(zFieldName, "tkt_ctime")==0 ) haveTicketCTime = 1;
continue;
}
if( nField%10==0 ){
aField = fossil_realloc(aField, sizeof(aField[0])*(nField+10) );
}
aField[nField].zName = mprintf("%s", zFieldName);
aField[nField].mUsed = USEDBY_TICKET;
nField++;
}
db_finalize(&q);
db_prepare(&q, "PRAGMA table_info(ticketchng)");
while( db_step(&q)==SQLITE_ROW ){
const char *zFieldName = db_column_text(&q, 1);
haveTicketChng = 1;
if( memcmp(zFieldName,"tkt_",4)==0 ){
if( strcmp(zFieldName,"tkt_rid")==0 ) haveTicketChngRid = 1;
continue;
}
if( (i = fieldId(zFieldName))>=0 ){
aField[i].mUsed |= USEDBY_TICKETCHNG;
continue;
}
if( nField%10==0 ){
aField = fossil_realloc(aField, sizeof(aField[0])*(nField+10) );
}
|
| ︙ | ︙ | |||
195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
"VALUES(%Q, 0)", p->zTicketUuid);
tktid = db_last_insert_rowid();
}
blob_zero(&sql1);
blob_zero(&sql2);
blob_zero(&sql3);
blob_appendf(&sql1, "UPDATE OR REPLACE ticket SET tkt_mtime=:mtime");
aUsed = fossil_malloc( nField );
memset(aUsed, 0, nField);
for(i=0; i<p->nField; i++){
const char *zName = p->aField[i].zName;
if( (j = fieldId(zName))<0 ) continue;
aUsed[j] = 1;
if( aField[j].mUsed & USEDBY_TICKET ){
| > > > | 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 |
"VALUES(%Q, 0)", p->zTicketUuid);
tktid = db_last_insert_rowid();
}
blob_zero(&sql1);
blob_zero(&sql2);
blob_zero(&sql3);
blob_appendf(&sql1, "UPDATE OR REPLACE ticket SET tkt_mtime=:mtime");
if( haveTicketCTime ){
blob_appendf(&sql1, ", tkt_ctime=coalesce(tkt_ctime,:mtime)");
}
aUsed = fossil_malloc( nField );
memset(aUsed, 0, nField);
for(i=0; i<p->nField; i++){
const char *zName = p->aField[i].zName;
if( (j = fieldId(zName))<0 ) continue;
aUsed[j] = 1;
if( aField[j].mUsed & USEDBY_TICKET ){
|
| ︙ | ︙ | |||
224 225 226 227 228 229 230 | } blob_appendf(&sql1, " WHERE tkt_id=%d", tktid); db_prepare(&q, "%s", blob_str(&sql1)); db_bind_double(&q, ":mtime", p->rDate); db_step(&q); db_finalize(&q); blob_reset(&sql1); | | | 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 |
}
blob_appendf(&sql1, " WHERE tkt_id=%d", tktid);
db_prepare(&q, "%s", blob_str(&sql1));
db_bind_double(&q, ":mtime", p->rDate);
db_step(&q);
db_finalize(&q);
blob_reset(&sql1);
if( blob_size(&sql2)>0 || haveTicketChngRid ){
int fromTkt = 0;
if( haveTicketChngRid ){
blob_append(&sql2, ",tkt_rid", -1);
blob_appendf(&sql3, ",%d", rid);
}
for(i=0; i<nField; i++){
if( aUsed[i]==0
|
| ︙ | ︙ |
Changes to src/tktsetup.c.
| ︙ | ︙ | |||
65 66 67 68 69 70 71 72 73 74 75 76 77 78 | /* @-comment: ** */ static const char zDefaultTicketTable[] = @ CREATE TABLE ticket( @ -- Do not change any column that begins with tkt_ @ tkt_id INTEGER PRIMARY KEY, @ tkt_uuid TEXT UNIQUE, @ tkt_mtime DATE, @ -- Add as many fields as required below this line @ type TEXT, @ status TEXT, @ subsystem TEXT, @ priority TEXT, @ severity TEXT, @ foundin TEXT, | > | 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | /* @-comment: ** */ static const char zDefaultTicketTable[] = @ CREATE TABLE ticket( @ -- Do not change any column that begins with tkt_ @ tkt_id INTEGER PRIMARY KEY, @ tkt_uuid TEXT UNIQUE, @ tkt_mtime DATE, @ tkt_ctime DATE, @ -- Add as many fields as required below this line @ type TEXT, @ status TEXT, @ subsystem TEXT, @ priority TEXT, @ severity TEXT, @ foundin TEXT, |
| ︙ | ︙ |