Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Add the "PRAGMA wal_autocheckpoint" command. Rename "PRAGMA checkpoint" to "PRAGMA wal_checkpoint". |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | wal |
Files: | files | file ages | folders |
SHA1: |
714e5947264571386f966aa8fcdd5607 |
User & Date: | dan 2010-05-03 11:05:09.000 |
Context
2010-05-03
| ||
12:14 | Have sqlite3_wal_checkpoint() populate the database handle error message and error code (as returned by sqlite3_errmsg() and sqlite3_errcode()). (check-in: ff234cf574 user: dan tags: wal) | |
11:05 | Add the "PRAGMA wal_autocheckpoint" command. Rename "PRAGMA checkpoint" to "PRAGMA wal_checkpoint". (check-in: 714e594726 user: dan tags: wal) | |
08:19 | Merge two wal leaves. (check-in: 23c0e6c3f3 user: dan tags: wal) | |
Changes
Changes to src/main.c.
︙ | |||
1187 1188 1189 1190 1191 1192 1193 | 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 | - + - + - + | } #ifndef SQLITE_OMIT_WAL /* ** The sqlite3_wal_hook() callback registered by sqlite3_wal_autocheckpoint(). ** Return non-zero, indicating to the caller that a checkpoint should be run, ** if the number of frames in the log file is greater than |
︙ | |||
1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 | 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 | + | void *pArg /* First argument passed to xCallback() */ ){ void *pRet; sqlite3_mutex_enter(db->mutex); pRet = db->pWalArg; db->xWalCallback = xCallback; db->pWalArg = pArg; db->nAutoCheckpoint = 0; sqlite3_mutex_leave(db->mutex); return pRet; } /* ** Checkpoint database zDb. If zDb is NULL, the main database is checkpointed. */ |
︙ | |||
1866 1867 1868 1869 1870 1871 1872 | 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 | - + | SQLITE_DEFAULT_LOCKING_MODE); #endif /* Enable the lookaside-malloc subsystem */ setupLookaside(db, 0, sqlite3GlobalConfig.szLookaside, sqlite3GlobalConfig.nLookaside); |
︙ |
Changes to src/pragma.c.
︙ | |||
1398 1399 1400 1401 1402 1403 1404 | 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 | - + - + + + + + + + + + + + + + + + + + + | sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1); } }else #endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */ #ifndef SQLITE_OMIT_WAL /* |
︙ |
Changes to src/sqliteInt.h.
︙ | |||
820 821 822 823 824 825 826 | 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 | - + | void *pCommitArg; /* Argument to xCommitCallback() */ int (*xCommitCallback)(void*); /* Invoked at every commit. */ void *pRollbackArg; /* Argument to xRollbackCallback() */ void (*xRollbackCallback)(void*); /* Invoked at every commit. */ void *pUpdateArg; void (*xUpdateCallback)(void*,int, const char*,const char*,sqlite_int64); #ifndef SQLITE_OMIT_WAL |
︙ |
Changes to src/sqliteLimit.h.
︙ | |||
104 105 106 107 108 109 110 111 112 113 114 115 116 117 | 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | + + + + + + + + | #ifndef SQLITE_DEFAULT_CACHE_SIZE # define SQLITE_DEFAULT_CACHE_SIZE 2000 #endif #ifndef SQLITE_DEFAULT_TEMP_CACHE_SIZE # define SQLITE_DEFAULT_TEMP_CACHE_SIZE 500 #endif /* ** The default number of frames to accumulate in the log file before ** checkpointing the database in WAL mode. */ #ifndef SQLITE_DEFAULT_WAL_AUTOCHECKPOINT # define SQLITE_DEFAULT_WAL_AUTOCHECKPOINT 1000 #endif /* ** The maximum number of attached databases. This must be between 0 ** and 30. The upper bound on 30 is because a 32-bit integer bitmap ** is used internally to track attached databases. */ #ifndef SQLITE_MAX_ATTACHED # define SQLITE_MAX_ATTACHED 10 |
︙ |
Changes to src/vdbeapi.c.
︙ | |||
317 318 319 320 321 322 323 | 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 | - + | for(i=0; i<db->nDb; i++){ Btree *pBt = db->aDb[i].pBt; if( pBt ){ int nEntry = sqlite3PagerWalCallback(sqlite3BtreePager(pBt)); if( db->xWalCallback && nEntry>0 && rc==SQLITE_OK && db->xWalCallback(db->pWalArg, db, db->aDb[i].zName, nEntry) ){ |
︙ |
Changes to test/savepoint.test.
︙ | |||
788 789 790 791 792 793 794 | 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 | - + | CREATE TABLE t3(a, b, UNIQUE(a, b)); ROLLBACK TO one; } } {} integrity_check savepoint-11.7 do_test savepoint-11.8 { execsql { ROLLBACK } |
︙ |
Changes to test/wal.test.
︙ | |||
345 346 347 348 349 350 351 | 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 | - + | PRAGMA page_size = 1024; CREATE TABLE t1(a, b); INSERT INTO t1 VALUES(1, 2); } list [file size test.db] [file size test.db-wal] } [list 1024 [log_file_size 3 1024]] do_test wal-7.2 { |
︙ | |||
376 377 378 379 380 381 382 | 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 | - + - + | INSERT INTO t1 VALUES(blob(900)); INSERT INTO t1 VALUES(blob(900)); INSERT INTO t1 SELECT blob(900) FROM t1; /* 4 */ INSERT INTO t1 SELECT blob(900) FROM t1; /* 8 */ INSERT INTO t1 SELECT blob(900) FROM t1; /* 16 */ INSERT INTO t1 SELECT blob(900) FROM t1; /* 32 */ INSERT INTO t1 SELECT blob(900) FROM t1; /* 64 */ |
︙ | |||
422 423 424 425 426 427 428 | 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 | - + | file copy test.db-wal test2.db-wal sqlite3_wal db3 test2.db execsql {PRAGMA integrity_check } db3 } {ok} db3 close do_test wal-9.4 { |
︙ | |||
545 546 547 548 549 550 551 | 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 | - + - + - + - + | # Open a read transaction with [db2]. Check that this prevents [db] from # checkpointing the database. But not from writing to it. # do_test wal-10.$tn.11 { sql2 { BEGIN; SELECT * FROM t1 } } {1 2 3 4 5 6 7 8 9 10} do_test wal-10.$tn.12 { |
︙ | |||
612 613 614 615 616 617 618 | 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 | - + - + - + - + | } {1 2 3 4 5 6 7 8 9 10 11 12 13 14} # Set [db3] up as a "region D" reader again. Then upgrade it to a writer # and back down to a reader. Then, check that a checkpoint is not possible # (as [db3] still has a snapshot locked). # do_test wal-10.$tn.23 { |
︙ | |||
681 682 683 684 685 686 687 | 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 | - + - + | BEGIN; SELECT * FROM t1; } } {a b c d} proc busyhandler x { return 1 } db busy busyhandler do_test wal-10.$tn.36 { |
︙ | |||
714 715 716 717 718 719 720 | 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 | - + | PRAGMA cache_size = 10; PRAGMA page_size = 1024; CREATE TABLE t1(x PRIMARY KEY); } list [expr [file size test.db]/1024] [expr [file size test.db-wal]/1044] } {1 3} do_test wal-11.2 { |
︙ | |||
749 750 751 752 753 754 755 | 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 | - + | do_test wal-11.7 { execsql { SELECT count(*) FROM t1; PRAGMA integrity_check; } } {16 ok} do_test wal-11.8 { |
︙ | |||
825 826 827 828 829 830 831 | 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 | - + - + - + | file copy -force test.db-wal test2.db-wal sqlite3_wal db2 test2.db execsql { SELECT * FROM t2 } db2 } {B 1} db2 close do_test wal-12.5 { execsql { |
︙ | |||
951 952 953 954 955 956 957 | 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 | - + - + | db2 eval { INSERT INTO t1 SELECT randomblob(10), randomblob(100); INSERT INTO t1 SELECT randomblob(10), randomblob(100); INSERT INTO t1 SELECT randomblob(10), randomblob(100); INSERT INTO t1 SELECT randomblob(10), randomblob(100); } |
Changes to test/walbak.test.
︙ | |||
67 68 69 70 71 72 73 | 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | - + - + | PRAGMA main.journal_mode; } } {wal} do_test walbak-1.5 { list [file size test.db] [file size test.db-wal] } [list 1024 [log_file_size 6 1024]] do_test walbak-1.6 { |
︙ |
Changes to test/walcrash.test.
︙ | |||
188 189 190 191 192 193 194 | 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 | - + | INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4; /* 12 */ INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4; /* 16 */ INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4; /* 20 */ INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4; /* 24 */ INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4; /* 28 */ INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4; /* 32 */ |
︙ | |||
229 230 231 232 233 234 235 | 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 | - + | INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4; /* 12 */ INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4; /* 16 */ INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4; /* 20 */ INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4; /* 24 */ INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4; /* 28 */ INSERT INTO t1 SELECT randomblob(900) FROM t1 LIMIT 4; /* 32 */ |
︙ | |||
256 257 258 259 260 261 262 | 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 | - + - + | do_test walcrash-7.$i.1 { crashsql -delay 3 -file test.db -seed [incr seed] -blocksize 512 { PRAGMA journal_mode = wal; BEGIN; CREATE TABLE t1(a, b); INSERT INTO t1 VALUES(1, 2); COMMIT; |
︙ |
Changes to test/walhook.test.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | + + + + - - + + - - - - - + - - - + + + + + - + + + - - + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | # 2010 April 19 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is testing the operation of the library in # "PRAGMA journal_mode=WAL" mode. # # More specifically, this file contains regression tests for the # sqlite3_wal_hook() mechanism, including the sqlite3_wal_autocheckpoint() # and "PRAGMA wal_autocheckpoint" convenience interfaces. # set testdir [file dirname $argv0] source $testdir/tester.tcl ifcapable !wal {finish_test ; return } |
Changes to test/walslow.test.
︙ | |||
44 45 46 47 48 49 50 | 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | - + | set w [expr int(rand()*2000)] set x [expr int(rand()*2000)] execsql { INSERT INTO t1 VALUES(randomblob($w), randomblob($x)) } execsql { PRAGMA integrity_check } } {ok} do_test walslow-1.seed=$seed.$iTest.2 { |
︙ |
Changes to test/walthread.test.
︙ | |||
237 238 239 240 241 242 243 | 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 | - + | # rows in the table. # # Each of the N threads runs N read transactions followed by a single write # transaction in a loop as fast as possible. # # There is also a single checkpointer thread. It runs the following loop: # |
︙ | |||
291 292 293 294 295 296 297 | 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 | - + | incr nRun } set nRun } -thread ckpt 1 { set nRun 0 while {[tt_continue]} { |
︙ |