Fossil SCM

Demonstrate how the mkindex.c utility could be extended to automatically put a complete web-page construction inside a transaction.

drh 2020-05-27 13:28 trunk
Commit 67c420402f2958eed8119ee74b807900147c9927201a01c3fffe463a34b536d6
--- src/dispatch.c
+++ src/dispatch.c
@@ -48,10 +48,11 @@
4848
#define CMDFLAG_SETTING 0x0020 /* A setting */
4949
#define CMDFLAG_VERSIONABLE 0x0040 /* A versionable setting */
5050
#define CMDFLAG_BLOCKTEXT 0x0080 /* Multi-line text setting */
5151
#define CMDFLAG_BOOLEAN 0x0100 /* A boolean setting */
5252
#define CMDFLAG_RAWCONTENT 0x0200 /* Do not interpret POST content */
53
+#define CMDFLAG_RDTRANS 0x0400 /* Run inside a read transaction */
5354
/**************************************************************************/
5455
5556
/* Values for the 2nd parameter to dispatch_name_search() */
5657
#define CMDFLAG_ANY 0x0038 /* Match anything */
5758
#define CMDFLAG_PREFIX 0x0200 /* Prefix match is ok */
5859
--- src/dispatch.c
+++ src/dispatch.c
@@ -48,10 +48,11 @@
48 #define CMDFLAG_SETTING 0x0020 /* A setting */
49 #define CMDFLAG_VERSIONABLE 0x0040 /* A versionable setting */
50 #define CMDFLAG_BLOCKTEXT 0x0080 /* Multi-line text setting */
51 #define CMDFLAG_BOOLEAN 0x0100 /* A boolean setting */
52 #define CMDFLAG_RAWCONTENT 0x0200 /* Do not interpret POST content */
 
53 /**************************************************************************/
54
55 /* Values for the 2nd parameter to dispatch_name_search() */
56 #define CMDFLAG_ANY 0x0038 /* Match anything */
57 #define CMDFLAG_PREFIX 0x0200 /* Prefix match is ok */
58
--- src/dispatch.c
+++ src/dispatch.c
@@ -48,10 +48,11 @@
48 #define CMDFLAG_SETTING 0x0020 /* A setting */
49 #define CMDFLAG_VERSIONABLE 0x0040 /* A versionable setting */
50 #define CMDFLAG_BLOCKTEXT 0x0080 /* Multi-line text setting */
51 #define CMDFLAG_BOOLEAN 0x0100 /* A boolean setting */
52 #define CMDFLAG_RAWCONTENT 0x0200 /* Do not interpret POST content */
53 #define CMDFLAG_RDTRANS 0x0400 /* Run inside a read transaction */
54 /**************************************************************************/
55
56 /* Values for the 2nd parameter to dispatch_name_search() */
57 #define CMDFLAG_ANY 0x0038 /* Match anything */
58 #define CMDFLAG_PREFIX 0x0200 /* Prefix match is ok */
59
+2
--- src/main.c
+++ src/main.c
@@ -1920,11 +1920,13 @@
19201920
rc = TH_OK;
19211921
}
19221922
if( rc==TH_OK || rc==TH_RETURN || rc==TH_CONTINUE ){
19231923
if( rc==TH_OK || rc==TH_RETURN ){
19241924
#endif
1925
+ if( pCmd->eCmdFlags & CMDFLAG_RDTRANS ) db_begin_transaction();
19251926
pCmd->xFunc();
1927
+ if( pCmd->eCmdFlags & CMDFLAG_RDTRANS ) db_commit_transaction();
19261928
#ifdef FOSSIL_ENABLE_TH1_HOOKS
19271929
}
19281930
if( !g.fNoThHook && (rc==TH_OK || rc==TH_CONTINUE) ){
19291931
Th_WebpageNotify(pCmd->zName+1, pCmd->eCmdFlags);
19301932
}
19311933
--- src/main.c
+++ src/main.c
@@ -1920,11 +1920,13 @@
1920 rc = TH_OK;
1921 }
1922 if( rc==TH_OK || rc==TH_RETURN || rc==TH_CONTINUE ){
1923 if( rc==TH_OK || rc==TH_RETURN ){
1924 #endif
 
1925 pCmd->xFunc();
 
1926 #ifdef FOSSIL_ENABLE_TH1_HOOKS
1927 }
1928 if( !g.fNoThHook && (rc==TH_OK || rc==TH_CONTINUE) ){
1929 Th_WebpageNotify(pCmd->zName+1, pCmd->eCmdFlags);
1930 }
1931
--- src/main.c
+++ src/main.c
@@ -1920,11 +1920,13 @@
1920 rc = TH_OK;
1921 }
1922 if( rc==TH_OK || rc==TH_RETURN || rc==TH_CONTINUE ){
1923 if( rc==TH_OK || rc==TH_RETURN ){
1924 #endif
1925 if( pCmd->eCmdFlags & CMDFLAG_RDTRANS ) db_begin_transaction();
1926 pCmd->xFunc();
1927 if( pCmd->eCmdFlags & CMDFLAG_RDTRANS ) db_commit_transaction();
1928 #ifdef FOSSIL_ENABLE_TH1_HOOKS
1929 }
1930 if( !g.fNoThHook && (rc==TH_OK || rc==TH_CONTINUE) ){
1931 Th_WebpageNotify(pCmd->zName+1, pCmd->eCmdFlags);
1932 }
1933
--- src/mkindex.c
+++ src/mkindex.c
@@ -90,10 +90,11 @@
9090
#define CMDFLAG_SETTING 0x0020 /* A setting */
9191
#define CMDFLAG_VERSIONABLE 0x0040 /* A versionable setting */
9292
#define CMDFLAG_BLOCKTEXT 0x0080 /* Multi-line text setting */
9393
#define CMDFLAG_BOOLEAN 0x0100 /* A boolean setting */
9494
#define CMDFLAG_RAWCONTENT 0x0200 /* Do not interpret webpage content */
95
+#define CMDFLAG_RDTRANS 0x0400 /* Run inside a read transaction */
9596
/**************************************************************************/
9697
9798
/*
9899
** Each entry looks like this:
99100
*/
@@ -239,10 +240,12 @@
239240
}else if( j==4 && strncmp(&zLine[i], "test", j)==0 ){
240241
aEntry[nUsed].eType &= ~(CMDFLAG_1ST_TIER|CMDFLAG_2ND_TIER);
241242
aEntry[nUsed].eType |= CMDFLAG_TEST;
242243
}else if( j==11 && strncmp(&zLine[i], "raw-content", j)==0 ){
243244
aEntry[nUsed].eType |= CMDFLAG_RAWCONTENT;
245
+ }else if( j==16 && strncmp(&zLine[i], "read-transaction", j)==0 ){
246
+ aEntry[nUsed].eType |= CMDFLAG_RDTRANS;
244247
}else if( j==7 && strncmp(&zLine[i], "boolean", j)==0 ){
245248
aEntry[nUsed].eType &= ~(CMDFLAG_BLOCKTEXT);
246249
aEntry[nUsed].iWidth = 0;
247250
aEntry[nUsed].eType |= CMDFLAG_BOOLEAN;
248251
}else if( j==10 && strncmp(&zLine[i], "block-text", j)==0 ){
249252
--- src/mkindex.c
+++ src/mkindex.c
@@ -90,10 +90,11 @@
90 #define CMDFLAG_SETTING 0x0020 /* A setting */
91 #define CMDFLAG_VERSIONABLE 0x0040 /* A versionable setting */
92 #define CMDFLAG_BLOCKTEXT 0x0080 /* Multi-line text setting */
93 #define CMDFLAG_BOOLEAN 0x0100 /* A boolean setting */
94 #define CMDFLAG_RAWCONTENT 0x0200 /* Do not interpret webpage content */
 
95 /**************************************************************************/
96
97 /*
98 ** Each entry looks like this:
99 */
@@ -239,10 +240,12 @@
239 }else if( j==4 && strncmp(&zLine[i], "test", j)==0 ){
240 aEntry[nUsed].eType &= ~(CMDFLAG_1ST_TIER|CMDFLAG_2ND_TIER);
241 aEntry[nUsed].eType |= CMDFLAG_TEST;
242 }else if( j==11 && strncmp(&zLine[i], "raw-content", j)==0 ){
243 aEntry[nUsed].eType |= CMDFLAG_RAWCONTENT;
 
 
244 }else if( j==7 && strncmp(&zLine[i], "boolean", j)==0 ){
245 aEntry[nUsed].eType &= ~(CMDFLAG_BLOCKTEXT);
246 aEntry[nUsed].iWidth = 0;
247 aEntry[nUsed].eType |= CMDFLAG_BOOLEAN;
248 }else if( j==10 && strncmp(&zLine[i], "block-text", j)==0 ){
249
--- src/mkindex.c
+++ src/mkindex.c
@@ -90,10 +90,11 @@
90 #define CMDFLAG_SETTING 0x0020 /* A setting */
91 #define CMDFLAG_VERSIONABLE 0x0040 /* A versionable setting */
92 #define CMDFLAG_BLOCKTEXT 0x0080 /* Multi-line text setting */
93 #define CMDFLAG_BOOLEAN 0x0100 /* A boolean setting */
94 #define CMDFLAG_RAWCONTENT 0x0200 /* Do not interpret webpage content */
95 #define CMDFLAG_RDTRANS 0x0400 /* Run inside a read transaction */
96 /**************************************************************************/
97
98 /*
99 ** Each entry looks like this:
100 */
@@ -239,10 +240,12 @@
240 }else if( j==4 && strncmp(&zLine[i], "test", j)==0 ){
241 aEntry[nUsed].eType &= ~(CMDFLAG_1ST_TIER|CMDFLAG_2ND_TIER);
242 aEntry[nUsed].eType |= CMDFLAG_TEST;
243 }else if( j==11 && strncmp(&zLine[i], "raw-content", j)==0 ){
244 aEntry[nUsed].eType |= CMDFLAG_RAWCONTENT;
245 }else if( j==16 && strncmp(&zLine[i], "read-transaction", j)==0 ){
246 aEntry[nUsed].eType |= CMDFLAG_RDTRANS;
247 }else if( j==7 && strncmp(&zLine[i], "boolean", j)==0 ){
248 aEntry[nUsed].eType &= ~(CMDFLAG_BLOCKTEXT);
249 aEntry[nUsed].iWidth = 0;
250 aEntry[nUsed].eType |= CMDFLAG_BOOLEAN;
251 }else if( j==10 && strncmp(&zLine[i], "block-text", j)==0 ){
252
+1 -1
--- src/timeline.c
+++ src/timeline.c
@@ -1579,11 +1579,11 @@
15791579
return zEDate;
15801580
}
15811581
15821582
15831583
/*
1584
-** WEBPAGE: timeline
1584
+** WEBPAGE: timeline read-transaction
15851585
**
15861586
** Query parameters:
15871587
**
15881588
** a=TIMEORTAG After this event
15891589
** b=TIMEORTAG Before this event
15901590
--- src/timeline.c
+++ src/timeline.c
@@ -1579,11 +1579,11 @@
1579 return zEDate;
1580 }
1581
1582
1583 /*
1584 ** WEBPAGE: timeline
1585 **
1586 ** Query parameters:
1587 **
1588 ** a=TIMEORTAG After this event
1589 ** b=TIMEORTAG Before this event
1590
--- src/timeline.c
+++ src/timeline.c
@@ -1579,11 +1579,11 @@
1579 return zEDate;
1580 }
1581
1582
1583 /*
1584 ** WEBPAGE: timeline read-transaction
1585 **
1586 ** Query parameters:
1587 **
1588 ** a=TIMEORTAG After this event
1589 ** b=TIMEORTAG Before this event
1590

Keyboard Shortcuts

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