Fossil SCM
Merge enhancements from trunk.
Commit
5544931c89891b63726523bb1db677f1ba285f74b54202f2549d1fa1bcd94a62
Parent
a2b470f14cd42a0…
2 files changed
+7
-1
+8
-5
+7
-1
| --- src/backoffice.c | ||
| +++ src/backoffice.c | ||
| @@ -185,11 +185,16 @@ | ||
| 185 | 185 | Lease x; |
| 186 | 186 | sqlite3_uint64 tmNow; |
| 187 | 187 | sqlite3_uint64 idSelf; |
| 188 | 188 | int lastWarning = 0; |
| 189 | 189 | int warningDelay = 30; |
| 190 | + static int once = 0; | |
| 190 | 191 | |
| 192 | + if( once ){ | |
| 193 | + fossil_panic("multiple calls to backoffice_run()"); | |
| 194 | + } | |
| 195 | + once = 1; | |
| 191 | 196 | if( g.db==0 ){ |
| 192 | 197 | fossil_panic("database not open for backoffice processing"); |
| 193 | 198 | } |
| 194 | 199 | if( db_transaction_nesting_depth()!=0 ){ |
| 195 | 200 | fossil_panic("transaction %s not closed prior to backoffice processing", |
| @@ -217,11 +222,12 @@ | ||
| 217 | 222 | x.idNext = 0; |
| 218 | 223 | x.tmNext = 0; |
| 219 | 224 | backofficeWriteLease(&x); |
| 220 | 225 | db_end_transaction(0); |
| 221 | 226 | if( g.fAnyTrace ){ |
| 222 | - fprintf(stderr, "/***** Begin Backoffice Processing *****/\n"); | |
| 227 | + fprintf(stderr, "/***** Begin Backoffice Processing %d *****/\n", | |
| 228 | + getpid()); | |
| 223 | 229 | } |
| 224 | 230 | backoffice_work(); |
| 225 | 231 | break; |
| 226 | 232 | } |
| 227 | 233 | /* This process needs to queue up and wait for the current lease |
| 228 | 234 |
| --- 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 |
M
src/db.c
+8
-5
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -339,11 +339,14 @@ | ||
| 339 | 339 | } |
| 340 | 340 | rc = sqlite3_prepare_v3(g.db, zSql, -1, prepFlags, &pStmt->pStmt, 0); |
| 341 | 341 | if( rc!=0 && (flags & DB_PREPARE_IGNORE_ERROR)==0 ){ |
| 342 | 342 | db_err("%s\n%s", sqlite3_errmsg(g.db), zSql); |
| 343 | 343 | } |
| 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; | |
| 345 | 348 | pStmt->nStep = 0; |
| 346 | 349 | pStmt->rc = rc; |
| 347 | 350 | return rc; |
| 348 | 351 | } |
| 349 | 352 | int db_prepare(Stmt *pStmt, const char *zFormat, ...){ |
| @@ -360,20 +363,20 @@ | ||
| 360 | 363 | va_start(ap, zFormat); |
| 361 | 364 | rc = db_vprepare(pStmt, DB_PREPARE_IGNORE_ERROR, zFormat, ap); |
| 362 | 365 | va_end(ap); |
| 363 | 366 | return rc; |
| 364 | 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 | +*/ | |
| 365 | 372 | int db_static_prepare(Stmt *pStmt, const char *zFormat, ...){ |
| 366 | 373 | int rc = SQLITE_OK; |
| 367 | 374 | if( blob_size(&pStmt->sql)==0 ){ |
| 368 | 375 | va_list ap; |
| 369 | 376 | va_start(ap, zFormat); |
| 370 | 377 | 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 | 378 | va_end(ap); |
| 376 | 379 | } |
| 377 | 380 | return rc; |
| 378 | 381 | } |
| 379 | 382 | |
| 380 | 383 |
| --- 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 |