]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Simplify the way in which the database file is truncated when the last
authordan <dan@noemail.net>
Tue, 11 Jul 2017 19:55:38 +0000 (19:55 +0000)
committerdan <dan@noemail.net>
Tue, 11 Jul 2017 19:55:38 +0000 (19:55 +0000)
connection disconnects. Also ignore the error code from the xTruncate call -
as truncating a database file is always optional.

FossilOrigin-Name: b0a49d90fc91acca1306cf6145adc83acd368686768b7eb4a3b27515b3237396

ext/lsm1/lsmInt.h
ext/lsm1/lsm_shared.c
manifest
manifest.uuid

index 9190c7d796954fc1967b5db6503334f9d78edc56..8e956dbb4ce481c8f1620d65af4c1814ac41a2cf 100644 (file)
@@ -589,7 +589,7 @@ struct Snapshot {
 /*
 ** Functions from file "lsm_ckpt.c".
 */
-int lsmCheckpointWrite(lsm_db *, int, u32 *);
+int lsmCheckpointWrite(lsm_db *, u32 *);
 int lsmCheckpointLevels(lsm_db *, int, void **, int *);
 int lsmCheckpointLoadLevels(lsm_db *pDb, void *pVal, int nVal);
 
index 6b41c1dc39467be7490670e99986bfef0c7ea4df..111b0ddbe7d02e110a51ed039292cbb4f0ddfe12 100644 (file)
@@ -230,7 +230,7 @@ static int dbTruncateFile(lsm_db *pDb){
 
     /* If the last block that contains data is not already the last block in
     ** the database file, truncate the database file so that it is. */
-    if( rc==LSM_OK && ctx.nBlock!=pDb->pWorker->nBlock ){
+    if( rc==LSM_OK ){
       rc = lsmFsTruncateDb(
           pDb->pFS, (i64)ctx.nBlock*lsmFsBlockSize(pDb->pFS)
       );
@@ -293,7 +293,7 @@ static void doDbDisconnect(lsm_db *pDb){
 
         /* Write a checkpoint to disk. */
         if( rc==LSM_OK ){
-          rc = lsmCheckpointWrite(pDb, (bReadonly==0), 0);
+          rc = lsmCheckpointWrite(pDb, 0);
         }
 
         /* If the checkpoint was written successfully, delete the log file
@@ -914,7 +914,7 @@ int lsmBlockRefree(lsm_db *pDb, int iBlk){
 ** not be held that long (in case it is required by a client flushing an
 ** in-memory tree to disk).
 */
-int lsmCheckpointWrite(lsm_db *pDb, int bTruncate, u32 *pnWrite){
+int lsmCheckpointWrite(lsm_db *pDb, u32 *pnWrite){
   int rc;                         /* Return Code */
   u32 nWrite = 0;
 
@@ -969,10 +969,6 @@ int lsmCheckpointWrite(lsm_db *pDb, int bTruncate, u32 *pnWrite){
       );
 #endif
     }
-
-    if( rc==LSM_OK && bTruncate && nBlock>0 ){
-      rc = lsmFsTruncateDb(pDb->pFS, (i64)nBlock*lsmFsBlockSize(pDb->pFS));
-    }
   }
 
   lsmShmLock(pDb, LSM_LOCK_CHECKPOINTER, LSM_LOCK_UNLOCK, 0);
@@ -1966,7 +1962,7 @@ int lsm_checkpoint(lsm_db *pDb, int *pnKB){
 
   /* Attempt the checkpoint. If successful, nWrite is set to the number of
   ** pages written between this and the previous checkpoint.  */
-  rc = lsmCheckpointWrite(pDb, 0, &nWrite);
+  rc = lsmCheckpointWrite(pDb, &nWrite);
 
   /* If required, calculate the output variable (KB of data checkpointed). 
   ** Set it to zero if an error occured.  */
index 270e42e442f1e0ddceaac35455a53c5f318ebe0c..da2b01d60f496b4fb23bb10bd4a8a7b4ad164ca2 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\sharmless\scompiler\swarnings\sin\sthe\score.
-D 2017-07-11T18:11:33.473
+C Simplify\sthe\sway\sin\swhich\sthe\sdatabase\sfile\sis\struncated\swhen\sthe\slast\nconnection\sdisconnects.\sAlso\signore\sthe\serror\scode\sfrom\sthe\sxTruncate\scall\s-\nas\struncating\sa\sdatabase\sfile\sis\salways\soptional.
+D 2017-07-11T19:55:38.241
 F Makefile.in 081e48dfe7f995d57ce1a88ddf4d2917b4349158648a6cd45b42beae30de3a12
 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
 F Makefile.msc 20850e3e8d4d4791e0531955852d768eb06f24138214870d543abb1a47346fba
@@ -236,14 +236,14 @@ F ext/lsm1/lsm-test/lsmtest_tdb4.c 47e8bb5eba266472d690fb8264f1855ebdba0ae5a0e54
 F ext/lsm1/lsm-test/lsmtest_util.c 241622db5a332a09c8e6e7606b617d288a37b557f7d3bce0bb97809f67cc2806
 F ext/lsm1/lsm-test/lsmtest_win32.c 0e0a224674c4d3170631c41b026b56c7e1672b151f5261e1b4cc19068641da2d
 F ext/lsm1/lsm.h 0f6f64ff071471cb87bf98beb8386566f30ea001
-F ext/lsm1/lsmInt.h 68945f00c4fc97a5c82bd285a15d0baacd0019cf2e0b7d535759f000459462e1
+F ext/lsm1/lsmInt.h bfa516dca9884de255c6adcb0fc07316770a724d4a52ea6fd54af82a416246b8
 F ext/lsm1/lsm_ckpt.c ac6fb4581983291c2e0be6fbb68f12b26f0c08d606835c05417be1323d0fdd03
 F ext/lsm1/lsm_file.c d4aee18aeb97d2e91ce30a4b46fa4c7006bca1d5e9f9bb2b7897e30ba8bdf002
 F ext/lsm1/lsm_log.c a8bf334532109bba05b09a504ee45fc393828b0d034ca61ab45e3940709d9a7c
 F ext/lsm1/lsm_main.c 15e73ccdafdd44ddeefc29e332079d88ba8f00c12c797b3c2b63d3171b5afce8
 F ext/lsm1/lsm_mem.c 4c51ea9fa285ee6e35301b33491642d071740a0a
 F ext/lsm1/lsm_mutex.c 378edf0a2b142b4f7640ee982df06d50b98788ea
-F ext/lsm1/lsm_shared.c 6b903d1afce9e254b642be7898359b4760afde6fb5740623bae4affff5726ab8
+F ext/lsm1/lsm_shared.c 341c3649575b94a6b1520d50acd540a3ff4036049ee73fbec4e33143ad37f990
 F ext/lsm1/lsm_sorted.c a04518dfbfff0171fafb152a46e9fe9f45e1edbf3570e4533dd58ddb6567f0c9
 F ext/lsm1/lsm_str.c 65e361b488c87b10bf3e5c0070b14ffc602cf84f094880bece77bbf6678bca82
 F ext/lsm1/lsm_tree.c 682679d7ef2b8b6f2fe77aeb532c8d29695bca671c220b0abac77069de5fb9fb
@@ -1631,7 +1631,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 2fe3a84330063378ca9fc5bfc8efe486c52d50b5c40be4f402a4f2318be69436
-R 5233df6163d8e8ff9a79e293df00de6c
-U drh
-Z d9b035cf4c291f130c8cdbd2d8e35ec0
+P 55e93f256018757e5e1cb3b10ef48abf5914e7687419eae58b00998a37061261
+R 7c3852771a4c807385128ef5313db6ce
+U dan
+Z aa49b66b4f30401e0222268e506f5e2a
index 74c8ab24ec59fc8a6da3990ca89007196dbddd65..542c6c0865279ae9be1d7c8cab466ad72108774f 100644 (file)
@@ -1 +1 @@
-55e93f256018757e5e1cb3b10ef48abf5914e7687419eae58b00998a37061261
\ No newline at end of file
+b0a49d90fc91acca1306cf6145adc83acd368686768b7eb4a3b27515b3237396
\ No newline at end of file