]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Have sqlite3_wal_checkpoint() handle a zero-length string in the same way as a NULL...
authordan <dan@noemail.net>
Mon, 3 May 2010 15:58:50 +0000 (15:58 +0000)
committerdan <dan@noemail.net>
Mon, 3 May 2010 15:58:50 +0000 (15:58 +0000)
FossilOrigin-Name: 7fecd21f45b9ce773ffbcef6c84066474e8cd01c

manifest
manifest.uuid
src/main.c
src/pragma.c
test/wal.test

index 53442bd4d4dd7c0817f4ea434c2b428a78e2b819..60ab7c14b6a41931c2c591cc4d6d0dfb8488a7a3 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,8 +1,5 @@
------BEGIN PGP SIGNED MESSAGE-----
-Hash: SHA1
-
-C Use\sVFS\smethod\sxCurrentTimeInt64\sinstead\sof\sxCurrentTime\swhen\sit\sis\savailable.\nProvide\san\simplementation\sof\sxCurrentTimeInt64\sfor\sos_unix.c.
-D 2010-05-03T14:32:30
+C Have\ssqlite3_wal_checkpoint()\shandle\sa\szero-length\sstring\sin\sthe\ssame\sway\sas\sa\sNULL\spointer.\sFix\s"PRAGMA\swal_checkpoint"\sso\sthat\sit\scheckpoints\sall\sattached\sdatabases.
+D 2010-05-03T15:58:51
 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
 F Makefile.in d83a0ffef3dcbfb08b410a6c6dd6c009ec9167fb
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -134,7 +131,7 @@ F src/journal.c b0ea6b70b532961118ab70301c00a33089f9315c
 F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f
 F src/lempar.c 7f026423f4d71d989e719a743f98a1cbd4e6d99e
 F src/loadext.c 1c7a61ce1281041f437333f366a96aa0d29bb581
-F src/main.c 6bc746f6016e0a3e6a7089078d9feffc0aa24a5e
+F src/main.c 23c51a3c67da0c1cceab38f3575fff2f2ae49464
 F src/malloc.c a08f16d134f0bfab6b20c3cd142ebf3e58235a6a
 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645
 F src/mem1.c 89d4ea8d5cdd55635cbaa48ad53132af6294cbb2
@@ -161,7 +158,7 @@ F src/parse.y ace5c7a125d9f2a410e431ee3209034105045f7e
 F src/pcache.c ace8f6a5ecd4711cc66a1b23053be7109bd437cf
 F src/pcache.h c683390d50f856d4cd8e24342ae62027d1bb6050
 F src/pcache1.c 6dc1871ce8ead9187161c370a58cd06c84221f76
-F src/pragma.c 5fa66bc24bd4e842d3edb86a319223b86ba5493c
+F src/pragma.c b9a0a173d5b1e40d2d703a6849a4961c559bf2e8
 F src/prepare.c fd1398cb1da54385ba5bd68d93928f10d10a1d9c
 F src/printf.c 5f5b65a83e63f2096a541a340722a509fa0240a7
 F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50
@@ -761,7 +758,7 @@ F test/vtabE.test 7c4693638d7797ce2eda17af74292b97e705cc61
 F test/vtab_alter.test 9e374885248f69e251bdaacf480b04a197f125e5
 F test/vtab_err.test 0d4d8eb4def1d053ac7c5050df3024fd47a3fbd8
 F test/vtab_shared.test 0eff9ce4f19facbe0a3e693f6c14b80711a4222d
-F test/wal.test 0c7c059c194871dd42811c31599cf74f1e1123e4
+F test/wal.test 0223196f4311a504b0127746613c4434054f7968
 F test/walbak.test a0e45187c7d8928df035dfea29b99b016b21ca3c
 F test/walcrash.test 63edc6a9e05f645b54d649186a5818fc82953e2e
 F test/walhook.test 5f18e0fc8787f1f8889d7a9971af18f334f83786
@@ -811,14 +808,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
 F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
-P de9ae443cc8eebfb0692dcdac93bde9e4c54199a
-R e2427a6bed16c13592f9c9205631cbf2
-U drh
-Z 44856fc90c606c86cc9a47a6ae746757
------BEGIN PGP SIGNATURE-----
-Version: GnuPG v1.4.6 (GNU/Linux)
-
-iD8DBQFL3t6BoxKgR168RlERAmG1AJ9O0XG5Km2CNUBGaWq0PnJbrMhSsgCeJiI9
-DrNwLLIIqnopSV7zMILP0LA=
-=3EtO
------END PGP SIGNATURE-----
+P ab77b3ae6da3370d8bc3b2c9c0edc723b69f5a95
+R 295bc2b46c703594035744e018f208b3
+U dan
+Z 92ca3ad74429d3d61c41c53f30e242bb
index 7eea3a9cfb1c83de9f997b54c3ff5883fa02b502..2fb075b68e3e5d3b4703cb1f0dd877218f35f033 100644 (file)
@@ -1 +1 @@
-ab77b3ae6da3370d8bc3b2c9c0edc723b69f5a95
\ No newline at end of file
+7fecd21f45b9ce773ffbcef6c84066474e8cd01c
\ No newline at end of file
index 77a790d4638a1df45ae9f092b9d40872c0a8a051..962c857d67c9a7a347751269bae18403bebf764d 100644 (file)
@@ -1253,7 +1253,9 @@ void *sqlite3_wal_hook(
 
 
 /*
-** Checkpoint database zDb. If zDb is NULL, the main database is checkpointed.
+** Checkpoint database zDb. If zDb is NULL, or if the buffer zDb points
+** to contains a zero-length string, all attached databases are 
+** checkpointed.
 */
 int sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb){
 #ifdef SQLITE_OMIT_WAL
@@ -1263,7 +1265,7 @@ int sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb){
   int iDb = SQLITE_MAX_ATTACHED;  /* sqlite3.aDb[] index of db to checkpoint */
 
   sqlite3_mutex_enter(db->mutex);
-  if( zDb ){
+  if( zDb && zDb[0] ){
     iDb = sqlite3FindDbName(db, zDb);
   }
   if( iDb<0 ){
index 65a0550bcbe40d825b0b95bb39b2d862dfd32032..c3aaaf9b3ec1935837aa6964af3adb803141c42a 100644 (file)
@@ -1408,7 +1408,7 @@ void sqlite3Pragma(
   */
   if( sqlite3StrICmp(zLeft, "wal_checkpoint")==0 ){
     if( sqlite3ReadSchema(pParse) ) goto pragma_out;
-    sqlite3VdbeAddOp3(v, OP_Checkpoint, iDb, 0, 0);
+    sqlite3VdbeAddOp3(v, OP_Checkpoint, pId2->z?iDb:SQLITE_MAX_ATTACHED, 0, 0);
   }else
 
   /*
index 01e68e943724361b4caa70542c4e28e9e840d4d2..1667f22f3f0f953af42aae227b6b70c1bdec9c7e 100644 (file)
@@ -1046,6 +1046,68 @@ do_test wal-15.4.6 {
   file size test.db
 } [expr 1024*2]
 
+catch { db2 close }
+catch { db close }
+
+#-------------------------------------------------------------------------
+# The following block of tests - wal-16.* - test that if a NULL pointer or
+# an empty string is passed as the second argument of the wal_checkpoint()
+# API, an attempt is made to checkpoint all attached databases.
+#
+foreach {tn ckpt_cmd ckpt_res ckpt_main ckpt_aux} {
+  1 {sqlite3_wal_checkpoint db}              SQLITE_OK     1 1
+  2 {sqlite3_wal_checkpoint db ""}           SQLITE_OK     1 1
+  3 {db eval "PRAGMA wal_checkpoint"}        {}            1 1
+
+  4 {sqlite3_wal_checkpoint db main}         SQLITE_OK     1 0
+  5 {sqlite3_wal_checkpoint db aux}          SQLITE_OK     0 1
+  6 {sqlite3_wal_checkpoint db temp}         SQLITE_OK     0 0
+  7 {db eval "PRAGMA main.wal_checkpoint"}   {}            1 0
+  8 {db eval "PRAGMA aux.wal_checkpoint"}    {}            0 1
+  9 {db eval "PRAGMA temp.wal_checkpoint"}   {}            0 0
+} {
+  do_test wal-16.$tn.1 {
+    file delete -force test2.db test2.db-wal test2.db-journal
+    file delete -force test.db test.db-wal test.db-journal
+
+    sqlite3 db test.db
+    execsql {
+      ATTACH 'test2.db' AS aux;
+      PRAGMA main.journal_mode = WAL;
+      PRAGMA aux.journal_mode = WAL;
+      PRAGMA synchronous = NORMAL;
+    }
+  } {wal wal}
+
+  do_test wal-16.$tn.2 {
+    execsql {
+      CREATE TABLE main.t1(a, b, PRIMARY KEY(a, b));
+      CREATE TABLE aux.t2(a, b, PRIMARY KEY(a, b));
+
+      INSERT INTO t2 VALUES(1, randomblob(1000));
+      INSERT INTO t2 VALUES(2, randomblob(1000));
+      INSERT INTO t1 SELECT * FROM t2;
+    }
+  
+    list [file size test.db] [file size test.db-wal]
+  } [list [expr 1*1024] [log_file_size 10 1024]]
+  do_test wal-16.$tn.3 {
+    list [file size test2.db] [file size test2.db-wal]
+  } [list [expr 1*1024] [log_file_size 16 1024]]
+  
+  do_test wal-16.$tn.4 [list eval $ckpt_cmd] $ckpt_res
+  
+  do_test wal-16.$tn.5 {
+    list [file size test.db] [file size test.db-wal]
+  } [list [expr ($ckpt_main ? 7 : 1)*1024] [log_file_size 10 1024]]
+
+  do_test wal-16.$tn.6 {
+    list [file size test2.db] [file size test2.db-wal]
+  } [list [expr ($ckpt_aux ? 7 : 1)*1024] [log_file_size 16 1024]]
+
+  catch { db close }
+}
+
 catch { db2 close }
 catch { db close }
 finish_test