Fossil SCM

Merge enhancements from trunk.

drh 2018-07-21 16:53 forum-v2 merge
Commit 5544931c89891b63726523bb1db677f1ba285f74b54202f2549d1fa1bcd94a62
2 files changed +7 -1 +8 -5
--- src/backoffice.c
+++ src/backoffice.c
@@ -185,11 +185,16 @@
185185
Lease x;
186186
sqlite3_uint64 tmNow;
187187
sqlite3_uint64 idSelf;
188188
int lastWarning = 0;
189189
int warningDelay = 30;
190
+ static int once = 0;
190191
192
+ if( once ){
193
+ fossil_panic("multiple calls to backoffice_run()");
194
+ }
195
+ once = 1;
191196
if( g.db==0 ){
192197
fossil_panic("database not open for backoffice processing");
193198
}
194199
if( db_transaction_nesting_depth()!=0 ){
195200
fossil_panic("transaction %s not closed prior to backoffice processing",
@@ -217,11 +222,12 @@
217222
x.idNext = 0;
218223
x.tmNext = 0;
219224
backofficeWriteLease(&x);
220225
db_end_transaction(0);
221226
if( g.fAnyTrace ){
222
- fprintf(stderr, "/***** Begin Backoffice Processing *****/\n");
227
+ fprintf(stderr, "/***** Begin Backoffice Processing %d *****/\n",
228
+ getpid());
223229
}
224230
backoffice_work();
225231
break;
226232
}
227233
/* This process needs to queue up and wait for the current lease
228234
--- src/backoffice.c
+++ src/backoffice.c
@@ -185,11 +185,16 @@
185 Lease x;
186 sqlite3_uint64 tmNow;
187 sqlite3_uint64 idSelf;
188 int lastWarning = 0;
189 int warningDelay = 30;
 
190
 
 
 
 
191 if( g.db==0 ){
192 fossil_panic("database not open for backoffice processing");
193 }
194 if( db_transaction_nesting_depth()!=0 ){
195 fossil_panic("transaction %s not closed prior to backoffice processing",
@@ -217,11 +222,12 @@
217 x.idNext = 0;
218 x.tmNext = 0;
219 backofficeWriteLease(&x);
220 db_end_transaction(0);
221 if( g.fAnyTrace ){
222 fprintf(stderr, "/***** Begin Backoffice Processing *****/\n");
 
223 }
224 backoffice_work();
225 break;
226 }
227 /* This process needs to queue up and wait for the current lease
228
--- src/backoffice.c
+++ src/backoffice.c
@@ -185,11 +185,16 @@
185 Lease x;
186 sqlite3_uint64 tmNow;
187 sqlite3_uint64 idSelf;
188 int lastWarning = 0;
189 int warningDelay = 30;
190 static int once = 0;
191
192 if( once ){
193 fossil_panic("multiple calls to backoffice_run()");
194 }
195 once = 1;
196 if( g.db==0 ){
197 fossil_panic("database not open for backoffice processing");
198 }
199 if( db_transaction_nesting_depth()!=0 ){
200 fossil_panic("transaction %s not closed prior to backoffice processing",
@@ -217,11 +222,12 @@
222 x.idNext = 0;
223 x.tmNext = 0;
224 backofficeWriteLease(&x);
225 db_end_transaction(0);
226 if( g.fAnyTrace ){
227 fprintf(stderr, "/***** Begin Backoffice Processing %d *****/\n",
228 getpid());
229 }
230 backoffice_work();
231 break;
232 }
233 /* This process needs to queue up and wait for the current lease
234
+8 -5
--- src/db.c
+++ src/db.c
@@ -339,11 +339,14 @@
339339
}
340340
rc = sqlite3_prepare_v3(g.db, zSql, -1, prepFlags, &pStmt->pStmt, 0);
341341
if( rc!=0 && (flags & DB_PREPARE_IGNORE_ERROR)==0 ){
342342
db_err("%s\n%s", sqlite3_errmsg(g.db), zSql);
343343
}
344
- pStmt->pNext = pStmt->pPrev = 0;
344
+ pStmt->pNext = db.pAllStmt;
345
+ pStmt->pPrev = 0;
346
+ if( db.pAllStmt ) db.pAllStmt->pPrev = pStmt;
347
+ db.pAllStmt = pStmt;
345348
pStmt->nStep = 0;
346349
pStmt->rc = rc;
347350
return rc;
348351
}
349352
int db_prepare(Stmt *pStmt, const char *zFormat, ...){
@@ -360,20 +363,20 @@
360363
va_start(ap, zFormat);
361364
rc = db_vprepare(pStmt, DB_PREPARE_IGNORE_ERROR, zFormat, ap);
362365
va_end(ap);
363366
return rc;
364367
}
368
+
369
+/* This variant of db_prepare() checks to see if the statement has
370
+** already been prepared, and if it has it becomes a no-op.
371
+*/
365372
int db_static_prepare(Stmt *pStmt, const char *zFormat, ...){
366373
int rc = SQLITE_OK;
367374
if( blob_size(&pStmt->sql)==0 ){
368375
va_list ap;
369376
va_start(ap, zFormat);
370377
rc = db_vprepare(pStmt, DB_PREPARE_PERSISTENT, zFormat, ap);
371
- pStmt->pNext = db.pAllStmt;
372
- pStmt->pPrev = 0;
373
- if( db.pAllStmt ) db.pAllStmt->pPrev = pStmt;
374
- db.pAllStmt = pStmt;
375378
va_end(ap);
376379
}
377380
return rc;
378381
}
379382
380383
--- src/db.c
+++ src/db.c
@@ -339,11 +339,14 @@
339 }
340 rc = sqlite3_prepare_v3(g.db, zSql, -1, prepFlags, &pStmt->pStmt, 0);
341 if( rc!=0 && (flags & DB_PREPARE_IGNORE_ERROR)==0 ){
342 db_err("%s\n%s", sqlite3_errmsg(g.db), zSql);
343 }
344 pStmt->pNext = pStmt->pPrev = 0;
 
 
 
345 pStmt->nStep = 0;
346 pStmt->rc = rc;
347 return rc;
348 }
349 int db_prepare(Stmt *pStmt, const char *zFormat, ...){
@@ -360,20 +363,20 @@
360 va_start(ap, zFormat);
361 rc = db_vprepare(pStmt, DB_PREPARE_IGNORE_ERROR, zFormat, ap);
362 va_end(ap);
363 return rc;
364 }
 
 
 
 
365 int db_static_prepare(Stmt *pStmt, const char *zFormat, ...){
366 int rc = SQLITE_OK;
367 if( blob_size(&pStmt->sql)==0 ){
368 va_list ap;
369 va_start(ap, zFormat);
370 rc = db_vprepare(pStmt, DB_PREPARE_PERSISTENT, zFormat, ap);
371 pStmt->pNext = db.pAllStmt;
372 pStmt->pPrev = 0;
373 if( db.pAllStmt ) db.pAllStmt->pPrev = pStmt;
374 db.pAllStmt = pStmt;
375 va_end(ap);
376 }
377 return rc;
378 }
379
380
--- src/db.c
+++ src/db.c
@@ -339,11 +339,14 @@
339 }
340 rc = sqlite3_prepare_v3(g.db, zSql, -1, prepFlags, &pStmt->pStmt, 0);
341 if( rc!=0 && (flags & DB_PREPARE_IGNORE_ERROR)==0 ){
342 db_err("%s\n%s", sqlite3_errmsg(g.db), zSql);
343 }
344 pStmt->pNext = db.pAllStmt;
345 pStmt->pPrev = 0;
346 if( db.pAllStmt ) db.pAllStmt->pPrev = pStmt;
347 db.pAllStmt = pStmt;
348 pStmt->nStep = 0;
349 pStmt->rc = rc;
350 return rc;
351 }
352 int db_prepare(Stmt *pStmt, const char *zFormat, ...){
@@ -360,20 +363,20 @@
363 va_start(ap, zFormat);
364 rc = db_vprepare(pStmt, DB_PREPARE_IGNORE_ERROR, zFormat, ap);
365 va_end(ap);
366 return rc;
367 }
368
369 /* This variant of db_prepare() checks to see if the statement has
370 ** already been prepared, and if it has it becomes a no-op.
371 */
372 int db_static_prepare(Stmt *pStmt, const char *zFormat, ...){
373 int rc = SQLITE_OK;
374 if( blob_size(&pStmt->sql)==0 ){
375 va_list ap;
376 va_start(ap, zFormat);
377 rc = db_vprepare(pStmt, DB_PREPARE_PERSISTENT, zFormat, ap);
 
 
 
 
378 va_end(ap);
379 }
380 return rc;
381 }
382
383

Keyboard Shortcuts

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